Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: explore infinite nesting (WIP) #638

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@app-builder/services/editor/ast-editor';
import {
useDefaultCoerceToConstant,
useGetAstNodeOption,
useGetAstNodeOperandProps,
useOperandOptions,
} from '@app-builder/services/editor/options';
import { useFormatReturnValue } from '@app-builder/services/editor/return-value';
Expand Down Expand Up @@ -39,27 +39,24 @@ export function AstBuilderNode({
}: AstBuilderNodeProps) {
if (isMainAstBinaryNode(astNode)) {
return (
<div className="flex w-full flex-col gap-2">
<MainAstBinaryOperatorLine
treePath={treePath}
mainAstNode={astNode}
viewOnly={viewOnly}
root={root}
/>
</div>
// it looks like the previous container was not necessary anymore. It still need to be checked
<MainAstBinaryOperatorLine
treePath={treePath}
mainAstNode={astNode}
viewOnly={viewOnly}
root={root}
/>
);
}

if (isMainAstUnaryNode(astNode)) {
return (
<div className="flex w-full flex-col gap-2">
<MainAstUnaryOperatorLine
treePath={treePath}
mainAstNode={astNode}
viewOnly={viewOnly}
root={root}
/>
</div>
<MainAstUnaryOperatorLine
treePath={treePath}
mainAstNode={astNode}
viewOnly={viewOnly}
root={root}
/>
);
}

Expand All @@ -85,14 +82,14 @@ export function OperandBuilderNode({
onSave?: (astNode: AstNode) => void;
}) {
const enumValues = useEnumValuesFromNeighbour(treePath);
const getAstNodeOption = useGetAstNodeOption();

const options = useOperandOptions(enumValues);
const coerceToConstant = useDefaultCoerceToConstant();

const operandProps = React.useMemo(() => {
return getAstNodeOption(astNode, { enumValues });
}, [astNode, enumValues, getAstNodeOption]);
const getAstNodeOperandProps = useGetAstNodeOperandProps();
const astNodeOperandProps = React.useMemo(() => {
return getAstNodeOperandProps(astNode, { enumValues });
}, [astNode, enumValues, getAstNodeOperandProps]);

const evaluation = useEvaluation(treePath);
const formatReturnValue = useFormatReturnValue();
Expand All @@ -113,7 +110,7 @@ export function OperandBuilderNode({
validationStatus={validationStatus}
astNodeErrors={evaluation}
returnValue={returnValue}
{...operandProps}
{...astNodeOperandProps}
/>
);
}
Loading
Loading