diff --git a/packages/entity/src/behavior-components/expression.jsx b/packages/entity/src/behavior-components/expression.jsx index 1185af2..a620c18 100644 --- a/packages/entity/src/behavior-components/expression.jsx +++ b/packages/entity/src/behavior-components/expression.jsx @@ -15,9 +15,10 @@ import Variant from './variant'; const Expression = ({ context, - value, path, type, + value, + vararg, }) => { const latus = useLatus(); const patch = useJsonPatcher(); @@ -60,7 +61,6 @@ const Expression = ({ if (isKey(op)) { const isFirst = 0 === i; const isLast = i === ops.length - 1 ? true : isInvocation(ops[i + 1]); - const isUndefined = 'undefined' === description.type || 'undefined' === type; Renderables.push( {Renderables} @@ -306,7 +306,9 @@ const Expression = ({ ); }; -Expression.defaultProps = {}; +Expression.defaultProps = { + vararg: false, +}; Expression.displayName = 'Expression'; @@ -327,6 +329,7 @@ Expression.propTypes = { // eslint-disable-next-line react/forbid-prop-types value: PropTypes.any, }).isRequired, + vararg: PropTypes.bool, path: PropTypes.string.isRequired, type: PropTypes.string.isRequired, }; diff --git a/packages/entity/src/behavior-components/expression/invocation.jsx b/packages/entity/src/behavior-components/expression/invocation.jsx index a881c1b..0c599d0 100644 --- a/packages/entity/src/behavior-components/expression/invocation.jsx +++ b/packages/entity/src/behavior-components/expression/invocation.jsx @@ -58,8 +58,9 @@ const Invocation = ({ /> ); } - const options = description?.args?.[i].options; - const type = description?.args?.[i].type || 'undefined'; + const j = description.vararg ? Math.min(description?.args?.length - 1, i) : i; + const options = description?.args?.[j].options; + const type = description?.args?.[j].type || 'undefined'; return ( ); }; - const isVarArg = 'undefined' === description.type; + const isVarArg = 'undefined' === description.type || description.vararg; const args = op.args.concat(); if (isVarArg) { args.push({type: 'undefined'}); @@ -108,6 +113,7 @@ Invocation.propTypes = { }), ), type: PropTypes.string, + vararg: PropTypes.bool, }).isRequired, onChange: PropTypes.func.isRequired, op: PropTypes.shape({