feat: assignment
This commit is contained in:
parent
d35f9bd598
commit
d877180476
|
@ -11,6 +11,7 @@ import classnames from 'classnames';
|
||||||
|
|
||||||
import Invocation from './expression/invocation';
|
import Invocation from './expression/invocation';
|
||||||
import Key from './expression/key';
|
import Key from './expression/key';
|
||||||
|
import Variant from './variant';
|
||||||
|
|
||||||
const Expression = ({
|
const Expression = ({
|
||||||
context,
|
context,
|
||||||
|
@ -21,7 +22,7 @@ const Expression = ({
|
||||||
const latus = useLatus();
|
const latus = useLatus();
|
||||||
const patch = useJsonPatcher();
|
const patch = useJsonPatcher();
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const {ops} = value;
|
const {ops, value: expressionValue} = value;
|
||||||
const Renderables = [];
|
const Renderables = [];
|
||||||
let opsCount = 0;
|
let opsCount = 0;
|
||||||
// eslint-disable-next-line react/destructuring-assignment
|
// eslint-disable-next-line react/destructuring-assignment
|
||||||
|
@ -205,6 +206,57 @@ const Expression = ({
|
||||||
opsCount += 1;
|
opsCount += 1;
|
||||||
}
|
}
|
||||||
const [lastOp] = ops.slice(-1);
|
const [lastOp] = ops.slice(-1);
|
||||||
|
if (
|
||||||
|
'void' === type
|
||||||
|
&& !description.args
|
||||||
|
&& isKey(lastOp)
|
||||||
|
) {
|
||||||
|
const opPath = join(path, 'value');
|
||||||
|
Renderables.push(
|
||||||
|
<Key
|
||||||
|
childrenDescription={{
|
||||||
|
'.': {label: '', type: description.type},
|
||||||
|
'≔': {label: '', type: 'void'},
|
||||||
|
}}
|
||||||
|
key={opPath}
|
||||||
|
onChange={(event, value) => {
|
||||||
|
if ('.' === value) {
|
||||||
|
patch({
|
||||||
|
op: 'remove',
|
||||||
|
path: opPath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
patch({
|
||||||
|
path: opPath,
|
||||||
|
value: {
|
||||||
|
type: 'literal',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
path={opPath}
|
||||||
|
value={expressionValue ? '≔' : '.'}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
if (expressionValue) {
|
||||||
|
Renderables.push(
|
||||||
|
<Variant
|
||||||
|
context={context}
|
||||||
|
onChange={(event, value, localPath) => {
|
||||||
|
patch({
|
||||||
|
path: localPath,
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
key={join(opPath, 'expression')}
|
||||||
|
path={opPath}
|
||||||
|
type={description.type}
|
||||||
|
value={expressionValue}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
let realType;
|
let realType;
|
||||||
if (isKey(lastOp)) {
|
if (isKey(lastOp)) {
|
||||||
realType = description.args
|
realType = description.args
|
||||||
|
@ -214,6 +266,9 @@ const Expression = ({
|
||||||
if (isInvocation(lastOp)) {
|
if (isInvocation(lastOp)) {
|
||||||
realType = description.type;
|
realType = description.type;
|
||||||
}
|
}
|
||||||
|
if (expressionValue) {
|
||||||
|
realType = 'void';
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classnames(
|
className={classnames(
|
||||||
|
@ -244,6 +299,8 @@ Expression.propTypes = {
|
||||||
key: PropTypes.string,
|
key: PropTypes.string,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
// eslint-disable-next-line react/forbid-prop-types
|
||||||
|
value: PropTypes.any,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
path: PropTypes.string.isRequired,
|
path: PropTypes.string.isRequired,
|
||||||
type: PropTypes.string.isRequired,
|
type: PropTypes.string.isRequired,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user