refactor: varargs
This commit is contained in:
parent
ab7a28bed4
commit
3af9037da4
|
@ -95,7 +95,7 @@ const Expression = ({
|
||||||
}}
|
}}
|
||||||
key={opPath}
|
key={opPath}
|
||||||
onChange={((i) => (event, value, localPath) => {
|
onChange={((i) => (event, value, localPath) => {
|
||||||
if (0 === value.indexOf('.')) {
|
if ('.' === value || '...' === value) {
|
||||||
const parts = localPath.split('/');
|
const parts = localPath.split('/');
|
||||||
parts.pop();
|
parts.pop();
|
||||||
parts.pop();
|
parts.pop();
|
||||||
|
@ -282,6 +282,7 @@ const Expression = ({
|
||||||
path={opPath}
|
path={opPath}
|
||||||
type={description.type}
|
type={description.type}
|
||||||
value={expressionValue}
|
value={expressionValue}
|
||||||
|
vararg={vararg}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ const Literal = ({
|
||||||
type,
|
type,
|
||||||
options,
|
options,
|
||||||
value,
|
value,
|
||||||
|
vararg,
|
||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line react/destructuring-assignment
|
// eslint-disable-next-line react/destructuring-assignment
|
||||||
const contextDescription = context.describe();
|
const contextDescription = context.describe();
|
||||||
|
@ -129,12 +130,17 @@ const Literal = ({
|
||||||
? {'.': {label: '', type: 'undefined'}}
|
? {'.': {label: '', type: 'undefined'}}
|
||||||
: {}
|
: {}
|
||||||
),
|
),
|
||||||
|
...(
|
||||||
|
vararg
|
||||||
|
? {'...': {label: '', type: 'undefined'}}
|
||||||
|
: {}
|
||||||
|
),
|
||||||
'[literal]': {label: '', type: value.type},
|
'[literal]': {label: '', type: value.type},
|
||||||
...contextDescription.children,
|
...contextDescription.children,
|
||||||
'[key]': {label: '', type: value.type},
|
'[key]': {label: '', type: value.type},
|
||||||
}}
|
}}
|
||||||
onChange={(event, value) => {
|
onChange={(event, value) => {
|
||||||
if ('.' === value) {
|
if ('.' === value || '...' === value) {
|
||||||
patch({
|
patch({
|
||||||
op: 'remove',
|
op: 'remove',
|
||||||
path,
|
path,
|
||||||
|
@ -188,6 +194,7 @@ const Literal = ({
|
||||||
|
|
||||||
Literal.defaultProps = {
|
Literal.defaultProps = {
|
||||||
options: [],
|
options: [],
|
||||||
|
vararg: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
Literal.displayName = 'Literal';
|
Literal.displayName = 'Literal';
|
||||||
|
@ -202,6 +209,7 @@ Literal.propTypes = {
|
||||||
path: PropTypes.string.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
// eslint-disable-next-line react/forbid-prop-types
|
// eslint-disable-next-line react/forbid-prop-types
|
||||||
value: PropTypes.any.isRequired,
|
value: PropTypes.any.isRequired,
|
||||||
|
vararg: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Literal;
|
export default Literal;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user