@flowgram.ai/form-materials 0.4.8 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.sh +6 -0
- package/dist/cjs/components/assign-row/index.js +112 -0
- package/dist/cjs/components/assign-row/types.js +18 -0
- package/dist/cjs/components/assign-rows/index.js +85 -0
- package/dist/cjs/components/batch-outputs/index.js +91 -0
- package/dist/cjs/components/batch-outputs/styles.js +60 -0
- package/dist/cjs/components/batch-outputs/types.js +18 -0
- package/dist/cjs/components/batch-variable-selector/index.js +53 -0
- package/dist/cjs/components/blur-input/index.js +64 -0
- package/dist/cjs/components/code-editor/editor.js +117 -0
- package/dist/cjs/components/code-editor/index.js +57 -0
- package/dist/cjs/components/code-editor/init-worker.js +56 -0
- package/dist/cjs/components/code-editor/language-features.js +21 -0
- package/dist/cjs/components/code-editor/theme/dark.js +188 -0
- package/dist/cjs/components/code-editor/theme/index.js +11 -0
- package/dist/cjs/components/code-editor/theme/light.js +195 -0
- package/dist/cjs/components/code-editor/utils.js +42 -0
- package/dist/cjs/components/code-editor-mini/index.js +66 -0
- package/dist/cjs/components/condition-row/constants.js +165 -0
- package/dist/cjs/components/condition-row/hooks/useOp.js +78 -0
- package/dist/cjs/components/condition-row/hooks/useRule.js +68 -0
- package/dist/cjs/components/condition-row/index.js +123 -0
- package/dist/cjs/components/condition-row/styles.js +77 -0
- package/dist/cjs/components/condition-row/types.js +52 -0
- package/dist/cjs/components/constant-input/index.js +80 -0
- package/dist/cjs/components/constant-input/types.js +18 -0
- package/dist/cjs/components/db-condition-row/hooks/use-left.js +86 -0
- package/dist/cjs/components/db-condition-row/hooks/use-op.js +79 -0
- package/dist/cjs/components/db-condition-row/index.js +115 -0
- package/dist/cjs/components/db-condition-row/styles.js +94 -0
- package/dist/cjs/components/db-condition-row/types.js +18 -0
- package/dist/cjs/components/display-flow-value/index.js +64 -0
- package/dist/cjs/components/display-inputs-values/index.js +76 -0
- package/dist/cjs/components/display-inputs-values/styles.js +51 -0
- package/dist/cjs/components/display-outputs/index.js +72 -0
- package/dist/cjs/components/display-outputs/styles.js +51 -0
- package/dist/cjs/components/display-schema-tag/index.js +77 -0
- package/dist/cjs/components/display-schema-tag/styles.js +71 -0
- package/dist/cjs/components/display-schema-tree/index.js +93 -0
- package/dist/cjs/components/display-schema-tree/styles.js +135 -0
- package/dist/cjs/components/dynamic-value-input/hooks.js +99 -0
- package/dist/cjs/components/dynamic-value-input/index.js +174 -0
- package/dist/cjs/components/dynamic-value-input/styles.js +107 -0
- package/dist/cjs/components/index.js +156 -0
- package/dist/cjs/components/inputs-values/index.js +112 -0
- package/dist/cjs/components/inputs-values/styles.js +60 -0
- package/dist/cjs/components/inputs-values/types.js +18 -0
- package/dist/cjs/components/inputs-values-tree/hooks/use-child-list.js +77 -0
- package/dist/cjs/components/inputs-values-tree/index.js +87 -0
- package/dist/cjs/components/inputs-values-tree/row.js +183 -0
- package/dist/cjs/components/inputs-values-tree/styles.js +177 -0
- package/dist/cjs/components/inputs-values-tree/types.js +18 -0
- package/dist/cjs/components/json-editor-with-variables/editor.js +81 -0
- package/dist/cjs/components/json-editor-with-variables/extensions/variable-tag.js +151 -0
- package/dist/cjs/components/json-editor-with-variables/extensions/variable-tree.js +97 -0
- package/dist/cjs/components/json-editor-with-variables/index.js +57 -0
- package/dist/cjs/components/json-editor-with-variables/styles.js +89 -0
- package/dist/cjs/components/json-schema-editor/default-value.js +54 -0
- package/dist/cjs/components/json-schema-editor/hooks.js +130 -0
- package/dist/cjs/components/json-schema-editor/index.js +246 -0
- package/dist/cjs/components/json-schema-editor/styles.js +231 -0
- package/dist/cjs/components/json-schema-editor/types.js +18 -0
- package/dist/cjs/components/prompt-editor/editor.js +99 -0
- package/dist/cjs/components/prompt-editor/extensions/jinja.js +73 -0
- package/dist/cjs/components/prompt-editor/extensions/language-support.js +48 -0
- package/dist/cjs/components/prompt-editor/extensions/markdown.js +81 -0
- package/dist/cjs/components/prompt-editor/index.js +57 -0
- package/dist/cjs/components/prompt-editor/styles.js +55 -0
- package/dist/cjs/components/prompt-editor/types.js +7 -0
- package/dist/cjs/components/prompt-editor-with-inputs/editor.js +47 -0
- package/dist/cjs/components/prompt-editor-with-inputs/extensions/inputs-tree.js +101 -0
- package/dist/cjs/components/prompt-editor-with-inputs/index.js +57 -0
- package/dist/cjs/components/prompt-editor-with-inputs/inputs-picker.js +104 -0
- package/dist/cjs/components/prompt-editor-with-variables/editor.js +49 -0
- package/dist/cjs/components/prompt-editor-with-variables/extensions/variable-tag.js +151 -0
- package/dist/cjs/components/prompt-editor-with-variables/extensions/variable-tree.js +103 -0
- package/dist/cjs/components/prompt-editor-with-variables/index.js +57 -0
- package/dist/cjs/components/prompt-editor-with-variables/styles.js +89 -0
- package/dist/cjs/components/type-selector/index.js +139 -0
- package/dist/cjs/components/variable-selector/context.js +56 -0
- package/dist/cjs/components/variable-selector/index.js +143 -0
- package/dist/cjs/components/variable-selector/styles.js +114 -0
- package/dist/cjs/components/variable-selector/use-variable-tree.js +100 -0
- package/dist/cjs/effects/auto-rename-ref/index.js +98 -0
- package/dist/cjs/effects/index.js +60 -0
- package/dist/cjs/effects/listen-ref-schema-change/index.js +57 -0
- package/dist/cjs/effects/listen-ref-value-change/index.js +54 -0
- package/dist/cjs/effects/provide-batch-input/index.js +64 -0
- package/dist/cjs/effects/provide-json-schema-outputs/index.js +49 -0
- package/dist/cjs/effects/sync-variable-title/index.js +52 -0
- package/dist/cjs/effects/validate-when-variable-sync/index.js +49 -0
- package/dist/cjs/form-plugins/batch-outputs-plugin/index.js +97 -0
- package/dist/cjs/form-plugins/index.js +47 -0
- package/dist/cjs/form-plugins/infer-assign-plugin/index.js +72 -0
- package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +47 -0
- package/dist/cjs/hooks/index.js +36 -0
- package/dist/cjs/hooks/use-object-list/index.js +136 -0
- package/dist/cjs/index.js +228 -0
- package/dist/cjs/plugins/disable-declaration-plugin/create-disable-declaration-plugin.js +51 -0
- package/dist/cjs/plugins/disable-declaration-plugin/index.js +36 -0
- package/dist/cjs/plugins/index.js +49 -0
- package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +49 -0
- package/dist/cjs/plugins/json-schema-preset/index.js +57 -0
- package/dist/cjs/plugins/json-schema-preset/manager.js +18 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +49 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +63 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +52 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +53 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +49 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +49 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +49 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +54 -0
- package/dist/cjs/shared/flow-value/index.js +36 -0
- package/dist/cjs/shared/flow-value/schema.js +82 -0
- package/dist/cjs/shared/flow-value/types.js +18 -0
- package/dist/cjs/shared/flow-value/utils.js +142 -0
- package/dist/cjs/shared/format-legacy-refs/index.js +99 -0
- package/dist/cjs/shared/index.js +73 -0
- package/dist/cjs/shared/inject-material/index.js +65 -0
- package/dist/cjs/shared/lazy-suspense/index.js +58 -0
- package/dist/cjs/shared/polyfill-create-root/index.js +53 -0
- package/dist/cjs/validate/index.js +36 -0
- package/dist/cjs/validate/validate-flow-value/index.js +63 -0
- package/dist/esm/components/assign-row/index.mjs +78 -0
- package/dist/esm/components/assign-row/types.mjs +0 -0
- package/dist/esm/components/assign-rows/index.mjs +51 -0
- package/dist/esm/components/batch-outputs/index.mjs +57 -0
- package/dist/esm/components/batch-outputs/styles.mjs +13 -0
- package/dist/esm/components/batch-outputs/types.mjs +0 -0
- package/dist/esm/components/batch-variable-selector/index.mjs +19 -0
- package/dist/esm/components/blur-input/index.mjs +20 -0
- package/dist/esm/components/code-editor/editor.mjs +55 -0
- package/dist/esm/components/code-editor/index.mjs +5 -0
- package/dist/esm/components/code-editor/init-worker.mjs +19 -0
- package/dist/esm/components/code-editor/language-features.mjs +15 -0
- package/dist/esm/components/code-editor/theme/dark.mjs +154 -0
- package/dist/esm/components/code-editor/theme/index.mjs +5 -0
- package/dist/esm/components/code-editor/theme/light.mjs +161 -0
- package/dist/esm/components/code-editor/utils.mjs +8 -0
- package/dist/esm/components/code-editor-mini/index.mjs +22 -0
- package/dist/esm/components/condition-row/constants.mjs +128 -0
- package/dist/esm/components/condition-row/hooks/useOp.mjs +44 -0
- package/dist/esm/components/condition-row/hooks/useRule.mjs +34 -0
- package/dist/esm/components/condition-row/index.mjs +89 -0
- package/dist/esm/components/condition-row/styles.mjs +21 -0
- package/dist/esm/components/condition-row/types.mjs +18 -0
- package/dist/esm/components/constant-input/index.mjs +36 -0
- package/dist/esm/components/constant-input/types.mjs +0 -0
- package/dist/esm/components/db-condition-row/hooks/use-left.mjs +52 -0
- package/dist/esm/components/db-condition-row/hooks/use-op.mjs +45 -0
- package/dist/esm/components/db-condition-row/index.mjs +81 -0
- package/dist/esm/components/db-condition-row/styles.mjs +32 -0
- package/dist/esm/components/db-condition-row/types.mjs +0 -0
- package/dist/esm/components/display-flow-value/index.mjs +30 -0
- package/dist/esm/components/display-inputs-values/index.mjs +39 -0
- package/dist/esm/components/display-inputs-values/styles.mjs +7 -0
- package/dist/esm/components/display-outputs/index.mjs +38 -0
- package/dist/esm/components/display-outputs/styles.mjs +7 -0
- package/dist/esm/components/display-schema-tag/index.mjs +33 -0
- package/dist/esm/components/display-schema-tag/styles.mjs +21 -0
- package/dist/esm/components/display-schema-tree/index.mjs +49 -0
- package/dist/esm/components/display-schema-tree/styles.mjs +79 -0
- package/dist/esm/components/dynamic-value-input/hooks.mjs +59 -0
- package/dist/esm/components/dynamic-value-input/index.mjs +137 -0
- package/dist/esm/components/dynamic-value-input/styles.mjs +54 -0
- package/dist/esm/components/index.mjs +26 -0
- package/dist/esm/components/inputs-values/index.mjs +78 -0
- package/dist/esm/components/inputs-values/styles.mjs +13 -0
- package/dist/esm/components/inputs-values/types.mjs +0 -0
- package/dist/esm/components/inputs-values-tree/hooks/use-child-list.mjs +43 -0
- package/dist/esm/components/inputs-values-tree/index.mjs +53 -0
- package/dist/esm/components/inputs-values-tree/row.mjs +149 -0
- package/dist/esm/components/inputs-values-tree/styles.mjs +105 -0
- package/dist/esm/components/inputs-values-tree/types.mjs +0 -0
- package/dist/esm/components/json-editor-with-variables/editor.mjs +47 -0
- package/dist/esm/components/json-editor-with-variables/extensions/variable-tag.mjs +117 -0
- package/dist/esm/components/json-editor-with-variables/extensions/variable-tree.mjs +63 -0
- package/dist/esm/components/json-editor-with-variables/index.mjs +5 -0
- package/dist/esm/components/json-editor-with-variables/styles.mjs +36 -0
- package/dist/esm/components/json-schema-editor/default-value.mjs +20 -0
- package/dist/esm/components/json-schema-editor/hooks.mjs +96 -0
- package/dist/esm/components/json-schema-editor/index.mjs +212 -0
- package/dist/esm/components/json-schema-editor/styles.mjs +138 -0
- package/dist/esm/components/json-schema-editor/types.mjs +0 -0
- package/dist/esm/components/prompt-editor/editor.mjs +52 -0
- package/dist/esm/components/prompt-editor/extensions/jinja.mjs +39 -0
- package/dist/esm/components/prompt-editor/extensions/language-support.mjs +14 -0
- package/dist/esm/components/prompt-editor/extensions/markdown.mjs +47 -0
- package/dist/esm/components/prompt-editor/index.mjs +5 -0
- package/dist/esm/components/prompt-editor/styles.mjs +11 -0
- package/dist/esm/components/prompt-editor/types.mjs +1 -0
- package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +13 -0
- package/dist/esm/components/prompt-editor-with-inputs/extensions/inputs-tree.mjs +67 -0
- package/dist/esm/components/prompt-editor-with-inputs/index.mjs +5 -0
- package/dist/esm/components/prompt-editor-with-inputs/inputs-picker.mjs +70 -0
- package/dist/esm/components/prompt-editor-with-variables/editor.mjs +15 -0
- package/dist/esm/components/prompt-editor-with-variables/extensions/variable-tag.mjs +117 -0
- package/dist/esm/components/prompt-editor-with-variables/extensions/variable-tree.mjs +69 -0
- package/dist/esm/components/prompt-editor-with-variables/index.mjs +5 -0
- package/dist/esm/components/prompt-editor-with-variables/styles.mjs +36 -0
- package/dist/esm/components/type-selector/index.mjs +96 -0
- package/dist/esm/components/variable-selector/context.mjs +16 -0
- package/dist/esm/components/variable-selector/index.mjs +100 -0
- package/dist/esm/components/variable-selector/styles.mjs +58 -0
- package/dist/esm/components/variable-selector/use-variable-tree.mjs +66 -0
- package/dist/esm/effects/auto-rename-ref/index.mjs +64 -0
- package/dist/esm/effects/index.mjs +8 -0
- package/dist/esm/effects/listen-ref-schema-change/index.mjs +23 -0
- package/dist/esm/effects/listen-ref-value-change/index.mjs +20 -0
- package/dist/esm/effects/provide-batch-input/index.mjs +30 -0
- package/dist/esm/effects/provide-json-schema-outputs/index.mjs +15 -0
- package/dist/esm/effects/sync-variable-title/index.mjs +18 -0
- package/dist/esm/effects/validate-when-variable-sync/index.mjs +15 -0
- package/dist/esm/form-plugins/batch-outputs-plugin/index.mjs +60 -0
- package/dist/esm/form-plugins/index.mjs +4 -0
- package/dist/esm/form-plugins/infer-assign-plugin/index.mjs +38 -0
- package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +13 -0
- package/dist/esm/hooks/index.mjs +2 -0
- package/dist/esm/hooks/use-object-list/index.mjs +102 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/plugins/disable-declaration-plugin/create-disable-declaration-plugin.mjs +17 -0
- package/dist/esm/plugins/disable-declaration-plugin/index.mjs +2 -0
- package/dist/esm/plugins/index.mjs +3 -0
- package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +15 -0
- package/dist/esm/plugins/json-schema-preset/index.mjs +14 -0
- package/dist/esm/plugins/json-schema-preset/manager.mjs +0 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +15 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +29 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +18 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +19 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +15 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +15 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +15 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +20 -0
- package/dist/esm/shared/flow-value/index.mjs +2 -0
- package/dist/esm/shared/flow-value/schema.mjs +26 -0
- package/dist/esm/shared/flow-value/types.mjs +0 -0
- package/dist/esm/shared/flow-value/utils.mjs +108 -0
- package/dist/esm/shared/format-legacy-refs/index.mjs +50 -0
- package/dist/esm/shared/index.mjs +6 -0
- package/dist/esm/shared/inject-material/index.mjs +21 -0
- package/dist/esm/shared/lazy-suspense/index.mjs +21 -0
- package/dist/esm/shared/polyfill-create-root/index.mjs +16 -0
- package/dist/esm/validate/index.mjs +2 -0
- package/dist/esm/validate/validate-flow-value/index.mjs +29 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/components/assign-row/index.d.ts +8 -0
- package/dist/types/components/assign-row/types.d.ts +20 -0
- package/dist/types/components/assign-rows/index.d.ts +11 -0
- package/dist/types/components/batch-outputs/index.d.ts +7 -0
- package/dist/types/components/batch-outputs/styles.d.ts +6 -0
- package/dist/types/components/batch-outputs/types.d.ts +18 -0
- package/dist/types/components/batch-variable-selector/index.d.ts +7 -0
- package/dist/types/components/blur-input/index.d.ts +7 -0
- package/dist/types/components/code-editor/editor.d.ts +23 -0
- package/dist/types/components/code-editor/index.d.ts +6 -0
- package/{src/validate/index.tsx → dist/types/components/code-editor/init-worker.d.ts} +1 -2
- package/{src/typings/index.ts → dist/types/components/code-editor/language-features.d.ts} +1 -2
- package/dist/types/components/code-editor/theme/dark.d.ts +6 -0
- package/{src/hooks/index.tsx → dist/types/components/code-editor/theme/index.d.ts} +1 -2
- package/dist/types/components/code-editor/theme/light.d.ts +6 -0
- package/dist/types/components/code-editor/utils.d.ts +5 -0
- package/dist/types/components/code-editor-mini/index.d.ts +7 -0
- package/dist/types/components/condition-row/constants.d.ts +7 -0
- package/dist/types/components/condition-row/hooks/useOp.d.ts +18 -0
- package/dist/types/components/condition-row/hooks/useRule.d.ts +9 -0
- package/dist/types/components/condition-row/index.d.ts +22 -0
- package/dist/types/components/condition-row/styles.d.ts +9 -0
- package/dist/types/components/condition-row/types.d.ts +34 -0
- package/dist/types/components/constant-input/index.d.ts +8 -0
- package/dist/types/components/constant-input/types.d.ts +16 -0
- package/dist/types/components/db-condition-row/hooks/use-left.d.ts +18 -0
- package/dist/types/components/db-condition-row/hooks/use-op.d.ts +18 -0
- package/dist/types/components/db-condition-row/index.d.ts +19 -0
- package/dist/types/components/db-condition-row/styles.d.ts +12 -0
- package/dist/types/components/db-condition-row/types.d.ts +25 -0
- package/dist/types/components/display-flow-value/index.d.ts +15 -0
- package/dist/types/components/display-inputs-values/index.d.ts +14 -0
- package/dist/types/components/display-inputs-values/styles.d.ts +5 -0
- package/dist/types/components/display-outputs/index.d.ts +14 -0
- package/dist/types/components/display-outputs/styles.d.ts +5 -0
- package/dist/types/components/display-schema-tag/index.d.ts +14 -0
- package/dist/types/components/display-schema-tag/styles.d.ts +8 -0
- package/dist/types/components/display-schema-tree/index.d.ts +16 -0
- package/dist/types/components/display-schema-tree/styles.d.ts +11 -0
- package/dist/types/components/dynamic-value-input/hooks.d.ts +28 -0
- package/dist/types/components/dynamic-value-input/index.d.ts +27 -0
- package/dist/types/components/dynamic-value-input/styles.d.ts +8 -0
- package/dist/types/components/index.d.ts +29 -0
- package/dist/types/components/inputs-values/index.d.ts +7 -0
- package/dist/types/components/inputs-values/styles.d.ts +6 -0
- package/dist/types/components/inputs-values/types.d.ts +19 -0
- package/dist/types/components/inputs-values-tree/hooks/use-child-list.d.ts +19 -0
- package/dist/types/components/inputs-values-tree/index.d.ts +7 -0
- package/dist/types/components/inputs-values-tree/row.d.ts +15 -0
- package/dist/types/components/inputs-values-tree/styles.d.ts +23 -0
- package/dist/types/components/inputs-values-tree/types.d.ts +18 -0
- package/dist/types/components/json-editor-with-variables/editor.d.ts +9 -0
- package/dist/types/components/json-editor-with-variables/extensions/variable-tag.d.ts +5 -0
- package/dist/types/components/json-editor-with-variables/extensions/variable-tree.d.ts +6 -0
- package/dist/types/components/json-editor-with-variables/index.d.ts +6 -0
- package/dist/types/components/json-editor-with-variables/styles.d.ts +9 -0
- package/dist/types/components/json-schema-editor/default-value.d.ts +17 -0
- package/dist/types/components/json-schema-editor/hooks.d.ts +12 -0
- package/dist/types/components/json-schema-editor/index.d.ts +14 -0
- package/dist/types/components/json-schema-editor/styles.d.ts +30 -0
- package/dist/types/components/json-schema-editor/types.d.ts +20 -0
- package/dist/types/components/prompt-editor/editor.d.ts +15 -0
- package/dist/types/components/prompt-editor/extensions/jinja.d.ts +6 -0
- package/dist/types/components/prompt-editor/extensions/language-support.d.ts +6 -0
- package/dist/types/components/prompt-editor/extensions/markdown.d.ts +6 -0
- package/dist/types/components/prompt-editor/index.d.ts +6 -0
- package/dist/types/components/prompt-editor/styles.d.ts +7 -0
- package/dist/types/components/prompt-editor/types.d.ts +16 -0
- package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +10 -0
- package/dist/types/components/prompt-editor-with-inputs/extensions/inputs-tree.d.ts +9 -0
- package/dist/types/components/prompt-editor-with-inputs/index.d.ts +6 -0
- package/dist/types/components/prompt-editor-with-inputs/inputs-picker.d.ts +9 -0
- package/dist/types/components/prompt-editor-with-variables/editor.d.ts +9 -0
- package/dist/types/components/prompt-editor-with-variables/extensions/variable-tag.d.ts +5 -0
- package/dist/types/components/prompt-editor-with-variables/extensions/variable-tree.d.ts +6 -0
- package/dist/types/components/prompt-editor-with-variables/index.d.ts +6 -0
- package/dist/types/components/prompt-editor-with-variables/styles.d.ts +9 -0
- package/dist/types/components/type-selector/index.d.ts +23 -0
- package/dist/types/components/variable-selector/context.d.ts +16 -0
- package/dist/types/components/variable-selector/index.d.ts +29 -0
- package/dist/types/components/variable-selector/styles.d.ts +14 -0
- package/dist/types/components/variable-selector/use-variable-tree.d.ts +18 -0
- package/dist/types/effects/auto-rename-ref/index.d.ts +17 -0
- package/dist/types/effects/index.d.ts +11 -0
- package/dist/types/effects/listen-ref-schema-change/index.d.ts +22 -0
- package/dist/types/effects/listen-ref-value-change/index.d.ts +22 -0
- package/dist/types/effects/provide-batch-input/index.d.ts +6 -0
- package/dist/types/effects/provide-json-schema-outputs/index.d.ts +6 -0
- package/dist/types/effects/sync-variable-title/index.d.ts +6 -0
- package/dist/types/effects/validate-when-variable-sync/index.d.ts +8 -0
- package/dist/types/form-plugins/batch-outputs-plugin/index.d.ts +12 -0
- package/dist/types/form-plugins/index.d.ts +7 -0
- package/dist/types/form-plugins/infer-assign-plugin/index.d.ts +10 -0
- package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +11 -0
- package/dist/types/hooks/index.d.ts +5 -0
- package/dist/types/hooks/use-object-list/index.d.ts +22 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/plugins/disable-declaration-plugin/create-disable-declaration-plugin.d.ts +5 -0
- package/dist/types/plugins/disable-declaration-plugin/index.d.ts +5 -0
- package/dist/types/plugins/index.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +9 -0
- package/dist/types/plugins/json-schema-preset/index.d.ts +13 -0
- package/dist/types/plugins/json-schema-preset/manager.d.ts +17 -0
- package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +5 -0
- package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +6 -0
- package/dist/types/shared/flow-value/index.d.ts +6 -0
- package/dist/types/shared/flow-value/schema.d.ts +107 -0
- package/dist/types/shared/flow-value/types.d.ts +32 -0
- package/dist/types/shared/flow-value/utils.d.ts +65 -0
- package/dist/types/shared/format-legacy-refs/index.d.ts +84 -0
- package/dist/types/shared/index.d.ts +9 -0
- package/dist/types/shared/inject-material/index.d.ts +46 -0
- package/dist/types/shared/lazy-suspense/index.d.ts +7 -0
- package/dist/types/shared/polyfill-create-root/index.d.ts +10 -0
- package/dist/types/validate/index.d.ts +5 -0
- package/dist/types/validate/validate-flow-value/index.d.ts +19 -0
- package/package.json +19 -21
- package/src/components/assign-row/index.tsx +3 -3
- package/src/components/assign-row/types.ts +1 -1
- package/src/components/batch-outputs/types.ts +1 -1
- package/src/components/code-editor/editor.tsx +10 -9
- package/src/components/code-editor/init-worker.ts +27 -0
- package/src/components/code-editor/language-features.ts +6 -27
- package/src/components/code-editor/theme/dark.ts +1 -1
- package/src/components/code-editor/theme/index.ts +1 -1
- package/src/components/code-editor/theme/light.ts +1 -1
- package/src/components/condition-row/hooks/useRule.ts +1 -1
- package/src/components/condition-row/types.ts +1 -1
- package/src/components/constant-input/index.tsx +1 -1
- package/src/components/db-condition-row/types.ts +1 -1
- package/src/components/display-flow-value/index.tsx +1 -1
- package/src/components/dynamic-value-input/hooks.ts +1 -1
- package/src/components/dynamic-value-input/index.tsx +1 -1
- package/src/components/index.ts +50 -25
- package/src/components/inputs-values/index.tsx +1 -1
- package/src/components/inputs-values/types.ts +1 -1
- package/src/components/inputs-values-tree/row.tsx +1 -1
- package/src/components/json-editor-with-variables/editor.tsx +2 -2
- package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +1 -1
- package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +3 -3
- package/src/components/prompt-editor/editor.tsx +2 -2
- package/src/components/prompt-editor/extensions/jinja.tsx +2 -2
- package/src/components/prompt-editor/extensions/language-support.tsx +2 -2
- package/src/components/prompt-editor/extensions/markdown.tsx +2 -2
- package/src/components/prompt-editor/types.tsx +1 -1
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +4 -4
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +3 -3
- package/src/effects/auto-rename-ref/index.ts +1 -1
- package/src/effects/index.ts +7 -7
- package/src/effects/listen-ref-schema-change/index.ts +1 -1
- package/src/effects/listen-ref-value-change/index.ts +1 -1
- package/src/effects/provide-batch-input/index.ts +1 -1
- package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
- package/src/form-plugins/index.ts +3 -3
- package/src/form-plugins/infer-assign-plugin/index.ts +1 -1
- package/src/hooks/index.ts +6 -0
- package/src/index.ts +98 -8
- package/src/plugins/index.ts +11 -2
- package/src/plugins/json-schema-preset/index.tsx +4 -4
- package/src/shared/flow-value/index.ts +11 -1
- package/src/shared/flow-value/utils.ts +1 -2
- package/src/shared/index.ts +26 -5
- package/src/validate/index.ts +6 -0
- package/src/validate/validate-flow-value/index.tsx +1 -1
- package/bin/index.ts +0 -80
- package/bin/materials.ts +0 -134
- package/bin/project.ts +0 -95
- package/bin/utils/import.ts +0 -127
- package/bin/utils/traverse-file.ts +0 -60
- package/dist/esm/chunk-727SU246.js +0 -13
- package/dist/esm/chunk-727SU246.js.map +0 -1
- package/dist/esm/chunk-DEZUEMUM.js +0 -284
- package/dist/esm/chunk-DEZUEMUM.js.map +0 -1
- package/dist/esm/chunk-IHOHRV5V.js +0 -477
- package/dist/esm/chunk-IHOHRV5V.js.map +0 -1
- package/dist/esm/editor-4X7K477H.js +0 -282
- package/dist/esm/editor-4X7K477H.js.map +0 -1
- package/dist/esm/editor-6UMULJYB.js +0 -180
- package/dist/esm/editor-6UMULJYB.js.map +0 -1
- package/dist/esm/editor-E2BQTPCD.js +0 -388
- package/dist/esm/editor-E2BQTPCD.js.map +0 -1
- package/dist/esm/editor-OXPGKPF5.js +0 -167
- package/dist/esm/editor-OXPGKPF5.js.map +0 -1
- package/dist/esm/editor-Z24WLBPO.js +0 -249
- package/dist/esm/editor-Z24WLBPO.js.map +0 -1
- package/dist/esm/index.js +0 -2668
- package/dist/esm/index.js.map +0 -1
- package/dist/index.d.mts +0 -1002
- package/dist/index.d.ts +0 -1002
- package/dist/index.js +0 -5127
- package/dist/index.js.map +0 -1
- package/src/components/assign-row/components/blur-input.tsx +0 -27
- /package/src/{typings/flow-value/index.ts → shared/flow-value/types.ts} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { I18n } from "@flowgram.ai/editor";
|
|
4
|
+
import { transformerCreator } from "@flowgram.ai/coze-editor/preset-code";
|
|
5
|
+
import { CodeEditor } from "../code-editor/index.mjs";
|
|
6
|
+
import { VariableTree } from "./extensions/variable-tree.mjs";
|
|
7
|
+
import { VariableTagInject } from "./extensions/variable-tag.mjs";
|
|
8
|
+
function findAllMatches(inputString, regex) {
|
|
9
|
+
const globalRegex = new RegExp(regex, regex.flags.includes('g') ? regex.flags : regex.flags + 'g');
|
|
10
|
+
let match;
|
|
11
|
+
const matches = [];
|
|
12
|
+
while(null !== (match = globalRegex.exec(inputString))){
|
|
13
|
+
if (match.index === globalRegex.lastIndex) globalRegex.lastIndex++;
|
|
14
|
+
matches.push({
|
|
15
|
+
match: match[0],
|
|
16
|
+
range: [
|
|
17
|
+
match.index,
|
|
18
|
+
match.index + match[0].length
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return matches;
|
|
23
|
+
}
|
|
24
|
+
const transformer = transformerCreator((text)=>{
|
|
25
|
+
const originalSource = text.toString();
|
|
26
|
+
const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
|
|
27
|
+
if (matches.length > 0) matches.forEach(({ range })=>{
|
|
28
|
+
text.replaceRange(range[0], range[1], 'null');
|
|
29
|
+
});
|
|
30
|
+
return text;
|
|
31
|
+
});
|
|
32
|
+
function JsonEditorWithVariables(props) {
|
|
33
|
+
return /*#__PURE__*/ jsxs(CodeEditor, {
|
|
34
|
+
languageId: "json",
|
|
35
|
+
activeLinePlaceholder: I18n.t("Press '@' to Select variable"),
|
|
36
|
+
...props,
|
|
37
|
+
options: {
|
|
38
|
+
transformer,
|
|
39
|
+
...props.options || {}
|
|
40
|
+
},
|
|
41
|
+
children: [
|
|
42
|
+
/*#__PURE__*/ jsx(VariableTree, {}),
|
|
43
|
+
/*#__PURE__*/ jsx(VariableTagInject, {})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export { JsonEditorWithVariables };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect } from "react";
|
|
3
|
+
import { isEqual, last } from "lodash-es";
|
|
4
|
+
import { Disposable, DisposableCollection, useCurrentScope } from "@flowgram.ai/editor";
|
|
5
|
+
import { useInjector } from "@flowgram.ai/coze-editor/react";
|
|
6
|
+
import { Popover } from "@douyinfe/semi-ui";
|
|
7
|
+
import { IconIssueStroked } from "@douyinfe/semi-icons";
|
|
8
|
+
import { Decoration, EditorView, MatchDecorator, ViewPlugin, WidgetType } from "@codemirror/view";
|
|
9
|
+
import { polyfillCreateRoot } from "../../../shared/index.mjs";
|
|
10
|
+
import { UIPopoverContent, UIRootTitle, UITag, UIVarName } from "../styles.mjs";
|
|
11
|
+
class VariableTagWidget extends WidgetType {
|
|
12
|
+
constructor({ keyPath, scope }){
|
|
13
|
+
super(), this.toDispose = new DisposableCollection(), this.renderIcon = (icon)=>{
|
|
14
|
+
if ('string' == typeof icon) return /*#__PURE__*/ jsx("img", {
|
|
15
|
+
style: {
|
|
16
|
+
marginRight: 8
|
|
17
|
+
},
|
|
18
|
+
width: 12,
|
|
19
|
+
height: 12,
|
|
20
|
+
src: icon
|
|
21
|
+
});
|
|
22
|
+
return icon;
|
|
23
|
+
};
|
|
24
|
+
this.keyPath = keyPath;
|
|
25
|
+
this.scope = scope;
|
|
26
|
+
}
|
|
27
|
+
renderVariable(v) {
|
|
28
|
+
if (!v) return void this.root.render(/*#__PURE__*/ jsx(UITag, {
|
|
29
|
+
prefixIcon: /*#__PURE__*/ jsx(IconIssueStroked, {}),
|
|
30
|
+
color: "amber",
|
|
31
|
+
children: "Unknown"
|
|
32
|
+
}));
|
|
33
|
+
const rootField = last(v.parentFields);
|
|
34
|
+
const rootTitle = /*#__PURE__*/ jsx(UIRootTitle, {
|
|
35
|
+
children: rootField?.meta.title ? `${rootField.meta.title} -` : ''
|
|
36
|
+
});
|
|
37
|
+
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
38
|
+
this.root.render(/*#__PURE__*/ jsx(Popover, {
|
|
39
|
+
content: /*#__PURE__*/ jsxs(UIPopoverContent, {
|
|
40
|
+
children: [
|
|
41
|
+
rootIcon,
|
|
42
|
+
rootTitle,
|
|
43
|
+
/*#__PURE__*/ jsx(UIVarName, {
|
|
44
|
+
children: v?.keyPath.slice(1).join('.')
|
|
45
|
+
})
|
|
46
|
+
]
|
|
47
|
+
}),
|
|
48
|
+
children: /*#__PURE__*/ jsxs(UITag, {
|
|
49
|
+
prefixIcon: rootIcon,
|
|
50
|
+
children: [
|
|
51
|
+
rootTitle,
|
|
52
|
+
/*#__PURE__*/ jsx(UIVarName, {
|
|
53
|
+
children: v?.key
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
})
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
toDOM(view) {
|
|
60
|
+
const dom = document.createElement('span');
|
|
61
|
+
this.root = polyfillCreateRoot(dom);
|
|
62
|
+
this.toDispose.push(Disposable.create(()=>{
|
|
63
|
+
this.root.unmount();
|
|
64
|
+
}));
|
|
65
|
+
this.toDispose.push(this.scope.available.trackByKeyPath(this.keyPath, (v)=>{
|
|
66
|
+
this.renderVariable(v);
|
|
67
|
+
}, {
|
|
68
|
+
triggerOnInit: false
|
|
69
|
+
}));
|
|
70
|
+
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
71
|
+
return dom;
|
|
72
|
+
}
|
|
73
|
+
eq(other) {
|
|
74
|
+
return isEqual(this.keyPath, other.keyPath);
|
|
75
|
+
}
|
|
76
|
+
ignoreEvent() {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
destroy(dom) {
|
|
80
|
+
this.toDispose.dispose();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function VariableTagInject() {
|
|
84
|
+
const injector = useInjector();
|
|
85
|
+
const scope = useCurrentScope();
|
|
86
|
+
useLayoutEffect(()=>{
|
|
87
|
+
const atMatcher = new MatchDecorator({
|
|
88
|
+
regexp: /\{\{([^\}\{]+)\}\}/g,
|
|
89
|
+
decoration: (match)=>Decoration.replace({
|
|
90
|
+
widget: new VariableTagWidget({
|
|
91
|
+
keyPath: match[1]?.split('.') ?? [],
|
|
92
|
+
scope
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
return injector.inject([
|
|
97
|
+
ViewPlugin.fromClass(class {
|
|
98
|
+
constructor(view){
|
|
99
|
+
this.view = view;
|
|
100
|
+
this.decorations = atMatcher.createDeco(view);
|
|
101
|
+
}
|
|
102
|
+
update() {
|
|
103
|
+
this.decorations = atMatcher.createDeco(this.view);
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
decorations: (p)=>p.decorations,
|
|
107
|
+
provide (p) {
|
|
108
|
+
return EditorView.atomicRanges.of((view)=>view.plugin(p)?.decorations ?? Decoration.none);
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
]);
|
|
112
|
+
}, [
|
|
113
|
+
injector
|
|
114
|
+
]);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
export { VariableTagInject };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { Mention, PositionMirror, getCurrentMentionReplaceRange, useEditor } from "@flowgram.ai/coze-editor/react";
|
|
4
|
+
import { Popover, Tree } from "@douyinfe/semi-ui";
|
|
5
|
+
import { useVariableTree } from "../../variable-selector/index.mjs";
|
|
6
|
+
function VariableTree() {
|
|
7
|
+
const [posKey, setPosKey] = useState('');
|
|
8
|
+
const [visible, setVisible] = useState(false);
|
|
9
|
+
const [position, setPosition] = useState(-1);
|
|
10
|
+
const editor = useEditor();
|
|
11
|
+
function insert(variablePath) {
|
|
12
|
+
const range = getCurrentMentionReplaceRange(editor.$view.state);
|
|
13
|
+
if (!range) return;
|
|
14
|
+
editor.replaceText({
|
|
15
|
+
...range,
|
|
16
|
+
text: '{{' + variablePath + '}}'
|
|
17
|
+
});
|
|
18
|
+
setVisible(false);
|
|
19
|
+
}
|
|
20
|
+
function handleOpenChange(e) {
|
|
21
|
+
setPosition(e.state.selection.main.head);
|
|
22
|
+
setVisible(e.value);
|
|
23
|
+
}
|
|
24
|
+
useEffect(()=>{
|
|
25
|
+
if (!editor) return;
|
|
26
|
+
}, [
|
|
27
|
+
editor,
|
|
28
|
+
visible
|
|
29
|
+
]);
|
|
30
|
+
const treeData = useVariableTree({});
|
|
31
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ jsx(Mention, {
|
|
34
|
+
triggerCharacters: [
|
|
35
|
+
'@'
|
|
36
|
+
],
|
|
37
|
+
onOpenChange: handleOpenChange
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ jsx(Popover, {
|
|
40
|
+
visible: visible,
|
|
41
|
+
trigger: "custom",
|
|
42
|
+
position: "topLeft",
|
|
43
|
+
rePosKey: posKey,
|
|
44
|
+
content: /*#__PURE__*/ jsx("div", {
|
|
45
|
+
style: {
|
|
46
|
+
width: 300
|
|
47
|
+
},
|
|
48
|
+
children: /*#__PURE__*/ jsx(Tree, {
|
|
49
|
+
treeData: treeData,
|
|
50
|
+
onSelect: (v)=>{
|
|
51
|
+
insert(v);
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
}),
|
|
55
|
+
children: /*#__PURE__*/ jsx(PositionMirror, {
|
|
56
|
+
position: position,
|
|
57
|
+
onChange: ()=>setPosKey(String(Math.random()))
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export { VariableTree };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import styled_components from "styled-components";
|
|
2
|
+
import { Tag } from "@douyinfe/semi-ui";
|
|
3
|
+
const UIRootTitle = styled_components.div`
|
|
4
|
+
margin-right: 4px;
|
|
5
|
+
min-width: 20px;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
text-overflow: ellipsis;
|
|
8
|
+
white-space: nowrap;
|
|
9
|
+
color: var(--semi-color-text-2);
|
|
10
|
+
`;
|
|
11
|
+
const UIVarName = styled_components.div`
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
text-overflow: ellipsis;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
`;
|
|
16
|
+
const UITag = styled_components(Tag)`
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: flex-start;
|
|
20
|
+
max-width: 300px;
|
|
21
|
+
|
|
22
|
+
& .semi-tag-content-center {
|
|
23
|
+
justify-content: flex-start;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.semi-tag {
|
|
27
|
+
margin: 0 5px;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
const UIPopoverContent = styled_components.div`
|
|
31
|
+
padding: 10px;
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: flex-start;
|
|
35
|
+
`;
|
|
36
|
+
export { UIPopoverContent, UIRootTitle, UITag, UIVarName };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { I18n } from "@flowgram.ai/editor";
|
|
4
|
+
import { ConstantInput } from "../constant-input/index.mjs";
|
|
5
|
+
import { ConstantInputWrapper } from "./styles.mjs";
|
|
6
|
+
function DefaultValue(props) {
|
|
7
|
+
const { value, schema, onChange, placeholder } = props;
|
|
8
|
+
return /*#__PURE__*/ jsx(ConstantInputWrapper, {
|
|
9
|
+
children: /*#__PURE__*/ jsx(ConstantInput, {
|
|
10
|
+
value: value,
|
|
11
|
+
onChange: (_v)=>onChange(_v),
|
|
12
|
+
schema: schema || {
|
|
13
|
+
type: 'string'
|
|
14
|
+
},
|
|
15
|
+
placeholder: placeholder ?? I18n.t('Default value if parameter is not provided'),
|
|
16
|
+
enableMultiLineStr: true
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export { DefaultValue };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { difference, omit } from "lodash-es";
|
|
3
|
+
import { produce } from "immer";
|
|
4
|
+
import { useTypeManager } from "@flowgram.ai/json-schema";
|
|
5
|
+
let _id = 0;
|
|
6
|
+
function genId() {
|
|
7
|
+
return _id++;
|
|
8
|
+
}
|
|
9
|
+
function usePropertiesEdit(value, onChange) {
|
|
10
|
+
const typeManager = useTypeManager();
|
|
11
|
+
const drilldownSchema = typeManager.getPropertiesParent(value || {});
|
|
12
|
+
const canAddField = typeManager.canAddField(value || {});
|
|
13
|
+
const [propertyList, setPropertyList] = useState([]);
|
|
14
|
+
const effectVersion = useRef(0);
|
|
15
|
+
const changeVersion = useRef(0);
|
|
16
|
+
useEffect(()=>{
|
|
17
|
+
effectVersion.current = effectVersion.current + 1;
|
|
18
|
+
if (effectVersion.current === changeVersion.current) return;
|
|
19
|
+
effectVersion.current = changeVersion.current;
|
|
20
|
+
setPropertyList((_list)=>{
|
|
21
|
+
const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b])=>(a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key])=>key);
|
|
22
|
+
const oldNames = _list.map((item)=>item.name).filter(Boolean);
|
|
23
|
+
const addNames = difference(newNames, oldNames);
|
|
24
|
+
return _list.filter((item)=>!item.name || newNames.includes(item.name)).map((item)=>({
|
|
25
|
+
key: item.key,
|
|
26
|
+
name: item.name,
|
|
27
|
+
isPropertyRequired: drilldownSchema?.required?.includes(item.name || '') || false,
|
|
28
|
+
...drilldownSchema?.properties?.[item.name || ''] || item || {}
|
|
29
|
+
})).concat(addNames.map((_name)=>({
|
|
30
|
+
key: genId(),
|
|
31
|
+
name: _name,
|
|
32
|
+
isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
|
|
33
|
+
...drilldownSchema?.properties?.[_name] || {}
|
|
34
|
+
})));
|
|
35
|
+
});
|
|
36
|
+
}, [
|
|
37
|
+
drilldownSchema
|
|
38
|
+
]);
|
|
39
|
+
const updatePropertyList = (updater)=>{
|
|
40
|
+
changeVersion.current = changeVersion.current + 1;
|
|
41
|
+
setPropertyList((_list)=>{
|
|
42
|
+
const next = updater(_list);
|
|
43
|
+
const nextProperties = {};
|
|
44
|
+
const nextRequired = [];
|
|
45
|
+
for (const _property of next)if (_property.name) {
|
|
46
|
+
nextProperties[_property.name] = omit(_property, [
|
|
47
|
+
'key',
|
|
48
|
+
'name',
|
|
49
|
+
'isPropertyRequired'
|
|
50
|
+
]);
|
|
51
|
+
if (_property.isPropertyRequired) nextRequired.push(_property.name);
|
|
52
|
+
}
|
|
53
|
+
onChange?.(produce(value || {}, (draft)=>{
|
|
54
|
+
const propertiesParent = typeManager.getPropertiesParent(draft);
|
|
55
|
+
if (propertiesParent) {
|
|
56
|
+
propertiesParent.properties = nextProperties;
|
|
57
|
+
propertiesParent.required = nextRequired;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
return next;
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const onAddProperty = ()=>{
|
|
65
|
+
setPropertyList((_list)=>[
|
|
66
|
+
..._list,
|
|
67
|
+
{
|
|
68
|
+
key: genId(),
|
|
69
|
+
name: '',
|
|
70
|
+
type: 'string',
|
|
71
|
+
extra: {
|
|
72
|
+
index: _list.length + 1
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
]);
|
|
76
|
+
};
|
|
77
|
+
const onRemoveProperty = (key)=>{
|
|
78
|
+
updatePropertyList((_list)=>_list.filter((_property)=>_property.key !== key));
|
|
79
|
+
};
|
|
80
|
+
const onEditProperty = (key, nextValue)=>{
|
|
81
|
+
updatePropertyList((_list)=>_list.map((_property)=>_property.key === key ? nextValue : _property));
|
|
82
|
+
};
|
|
83
|
+
useEffect(()=>{
|
|
84
|
+
if (!canAddField) setPropertyList([]);
|
|
85
|
+
}, [
|
|
86
|
+
canAddField
|
|
87
|
+
]);
|
|
88
|
+
return {
|
|
89
|
+
propertyList,
|
|
90
|
+
canAddField,
|
|
91
|
+
onAddProperty,
|
|
92
|
+
onRemoveProperty,
|
|
93
|
+
onEditProperty
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export { usePropertiesEdit };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import { I18n } from "@flowgram.ai/editor";
|
|
4
|
+
import { Button, Checkbox, IconButton } from "@douyinfe/semi-ui";
|
|
5
|
+
import { IconChevronDown, IconChevronRight, IconExpand, IconMinus, IconPlus, IconShrink } from "@douyinfe/semi-icons";
|
|
6
|
+
import { InjectTypeSelector } from "../type-selector/index.mjs";
|
|
7
|
+
import { BlurInput } from "../blur-input/index.mjs";
|
|
8
|
+
import { DefaultValueWrapper, IconAddChildren, UIActions, UICollapseTrigger, UICollapsible, UIContainer, UIExpandDetail, UILabel, UIName, UIRequired, UIRow, UITreeItemLeft, UITreeItemMain, UITreeItemRight, UITreeItems, UIType } from "./styles.mjs";
|
|
9
|
+
import { usePropertiesEdit } from "./hooks.mjs";
|
|
10
|
+
import { DefaultValue } from "./default-value.mjs";
|
|
11
|
+
const DEFAULT = {
|
|
12
|
+
type: 'object'
|
|
13
|
+
};
|
|
14
|
+
function JsonSchemaEditor(props) {
|
|
15
|
+
const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
|
|
16
|
+
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
17
|
+
return /*#__PURE__*/ jsxs(UIContainer, {
|
|
18
|
+
className: props.className,
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx(UITreeItems, {
|
|
21
|
+
children: propertyList.map((_property)=>/*#__PURE__*/ jsx(PropertyEdit, {
|
|
22
|
+
readonly: readonly,
|
|
23
|
+
value: _property,
|
|
24
|
+
config: config,
|
|
25
|
+
onChange: (_v)=>{
|
|
26
|
+
onEditProperty(_property.key, _v);
|
|
27
|
+
},
|
|
28
|
+
onRemove: ()=>{
|
|
29
|
+
onRemoveProperty(_property.key);
|
|
30
|
+
}
|
|
31
|
+
}, _property.key))
|
|
32
|
+
}),
|
|
33
|
+
/*#__PURE__*/ jsx(Button, {
|
|
34
|
+
disabled: readonly,
|
|
35
|
+
size: "small",
|
|
36
|
+
style: {
|
|
37
|
+
marginTop: 10,
|
|
38
|
+
marginLeft: 16
|
|
39
|
+
},
|
|
40
|
+
icon: /*#__PURE__*/ jsx(IconPlus, {}),
|
|
41
|
+
onClick: onAddProperty,
|
|
42
|
+
children: config?.addButtonText ?? I18n.t('Add')
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function PropertyEdit(props) {
|
|
48
|
+
const { value, config, readonly, $level = 0, onChange: onChangeProps, onRemove, $isLast } = props;
|
|
49
|
+
const [expand, setExpand] = useState(false);
|
|
50
|
+
const [collapse, setCollapse] = useState(false);
|
|
51
|
+
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
52
|
+
const typeSelectorValue = useMemo(()=>({
|
|
53
|
+
type,
|
|
54
|
+
items
|
|
55
|
+
}), [
|
|
56
|
+
type,
|
|
57
|
+
items
|
|
58
|
+
]);
|
|
59
|
+
const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
60
|
+
const onChange = (key, _value)=>{
|
|
61
|
+
onChangeProps?.({
|
|
62
|
+
...value || {},
|
|
63
|
+
[key]: _value
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const showCollapse = canAddField && propertyList.length > 0;
|
|
67
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
68
|
+
children: [
|
|
69
|
+
/*#__PURE__*/ jsx(UITreeItemLeft, {
|
|
70
|
+
$isLast: $isLast,
|
|
71
|
+
$showLine: $level > 0,
|
|
72
|
+
$showCollapse: showCollapse,
|
|
73
|
+
children: showCollapse && /*#__PURE__*/ jsx(UICollapseTrigger, {
|
|
74
|
+
onClick: ()=>setCollapse((_collapse)=>!_collapse),
|
|
75
|
+
children: collapse ? /*#__PURE__*/ jsx(IconChevronDown, {
|
|
76
|
+
size: "small"
|
|
77
|
+
}) : /*#__PURE__*/ jsx(IconChevronRight, {
|
|
78
|
+
size: "small"
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ jsxs(UITreeItemRight, {
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ jsxs(UITreeItemMain, {
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ jsxs(UIRow, {
|
|
87
|
+
children: [
|
|
88
|
+
/*#__PURE__*/ jsx(UIName, {
|
|
89
|
+
children: /*#__PURE__*/ jsx(BlurInput, {
|
|
90
|
+
disabled: readonly,
|
|
91
|
+
placeholder: config?.placeholder ?? I18n.t('Input Variable Name'),
|
|
92
|
+
size: "small",
|
|
93
|
+
value: name,
|
|
94
|
+
onChange: (value)=>onChange('name', value)
|
|
95
|
+
})
|
|
96
|
+
}),
|
|
97
|
+
/*#__PURE__*/ jsx(UIType, {
|
|
98
|
+
children: /*#__PURE__*/ jsx(InjectTypeSelector, {
|
|
99
|
+
value: typeSelectorValue,
|
|
100
|
+
readonly: readonly,
|
|
101
|
+
onChange: (_value)=>{
|
|
102
|
+
onChangeProps?.({
|
|
103
|
+
...value || {},
|
|
104
|
+
..._value
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
/*#__PURE__*/ jsx(UIRequired, {
|
|
110
|
+
children: /*#__PURE__*/ jsx(Checkbox, {
|
|
111
|
+
disabled: readonly,
|
|
112
|
+
checked: isPropertyRequired,
|
|
113
|
+
onChange: (e)=>onChange('isPropertyRequired', e.target.checked)
|
|
114
|
+
})
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ jsxs(UIActions, {
|
|
117
|
+
children: [
|
|
118
|
+
/*#__PURE__*/ jsx(IconButton, {
|
|
119
|
+
disabled: readonly,
|
|
120
|
+
size: "small",
|
|
121
|
+
theme: "borderless",
|
|
122
|
+
icon: expand ? /*#__PURE__*/ jsx(IconShrink, {
|
|
123
|
+
size: "small"
|
|
124
|
+
}) : /*#__PURE__*/ jsx(IconExpand, {
|
|
125
|
+
size: "small"
|
|
126
|
+
}),
|
|
127
|
+
onClick: ()=>{
|
|
128
|
+
setExpand((_expand)=>!_expand);
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
canAddField && /*#__PURE__*/ jsx(IconButton, {
|
|
132
|
+
disabled: readonly,
|
|
133
|
+
size: "small",
|
|
134
|
+
theme: "borderless",
|
|
135
|
+
icon: /*#__PURE__*/ jsx(IconAddChildren, {}),
|
|
136
|
+
onClick: ()=>{
|
|
137
|
+
onAddProperty();
|
|
138
|
+
setCollapse(true);
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ jsx(IconButton, {
|
|
142
|
+
disabled: readonly,
|
|
143
|
+
size: "small",
|
|
144
|
+
theme: "borderless",
|
|
145
|
+
icon: /*#__PURE__*/ jsx(IconMinus, {
|
|
146
|
+
size: "small"
|
|
147
|
+
}),
|
|
148
|
+
onClick: onRemove
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
}),
|
|
154
|
+
expand && /*#__PURE__*/ jsxs(UIExpandDetail, {
|
|
155
|
+
children: [
|
|
156
|
+
/*#__PURE__*/ jsx(UILabel, {
|
|
157
|
+
children: config?.descTitle ?? I18n.t("Description")
|
|
158
|
+
}),
|
|
159
|
+
/*#__PURE__*/ jsx(BlurInput, {
|
|
160
|
+
disabled: readonly,
|
|
161
|
+
size: "small",
|
|
162
|
+
value: description,
|
|
163
|
+
onChange: (value)=>onChange("description", value),
|
|
164
|
+
placeholder: config?.descPlaceholder ?? I18n.t('Help LLM to understand the property')
|
|
165
|
+
}),
|
|
166
|
+
0 === $level && /*#__PURE__*/ jsxs(Fragment, {
|
|
167
|
+
children: [
|
|
168
|
+
/*#__PURE__*/ jsx(UILabel, {
|
|
169
|
+
style: {
|
|
170
|
+
marginTop: 10
|
|
171
|
+
},
|
|
172
|
+
children: config?.defaultValueTitle ?? I18n.t('Default Value')
|
|
173
|
+
}),
|
|
174
|
+
/*#__PURE__*/ jsx(DefaultValueWrapper, {
|
|
175
|
+
children: /*#__PURE__*/ jsx(DefaultValue, {
|
|
176
|
+
value: defaultValue,
|
|
177
|
+
schema: value,
|
|
178
|
+
placeholder: config?.defaultValuePlaceholder ?? I18n.t('Default Value'),
|
|
179
|
+
onChange: (value)=>onChange('default', value)
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
}),
|
|
188
|
+
showCollapse && /*#__PURE__*/ jsx(UICollapsible, {
|
|
189
|
+
$collapse: collapse,
|
|
190
|
+
children: /*#__PURE__*/ jsx(UITreeItems, {
|
|
191
|
+
$shrink: true,
|
|
192
|
+
children: propertyList.map((_property, index)=>/*#__PURE__*/ jsx(PropertyEdit, {
|
|
193
|
+
readonly: readonly,
|
|
194
|
+
value: _property,
|
|
195
|
+
config: config,
|
|
196
|
+
$level: $level + 1,
|
|
197
|
+
onChange: (_v)=>{
|
|
198
|
+
onEditProperty(_property.key, _v);
|
|
199
|
+
},
|
|
200
|
+
onRemove: ()=>{
|
|
201
|
+
onRemoveProperty(_property.key);
|
|
202
|
+
},
|
|
203
|
+
$isLast: index === propertyList.length - 1
|
|
204
|
+
}, _property.key))
|
|
205
|
+
})
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
export { JsonSchemaEditor };
|