@flowgram-vue/form-materials 0.2.0

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.
Files changed (177) hide show
  1. package/LICENSE +22 -0
  2. package/bin/run.sh +7 -0
  3. package/dist/index.cjs +0 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +0 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +86 -0
  9. package/src/components/assign-row/assign-row.vue +69 -0
  10. package/src/components/assign-row/index.ts +7 -0
  11. package/src/components/assign-row/types.ts +25 -0
  12. package/src/components/assign-rows/assign-rows.vue +44 -0
  13. package/src/components/assign-rows/index.ts +6 -0
  14. package/src/components/batch-outputs/batch-outputs.vue +46 -0
  15. package/src/components/batch-outputs/index.ts +6 -0
  16. package/src/components/batch-outputs/styles.css +17 -0
  17. package/src/components/batch-outputs/types.ts +23 -0
  18. package/src/components/batch-variable-selector/batch-variable-selector.vue +24 -0
  19. package/src/components/batch-variable-selector/index.ts +6 -0
  20. package/src/components/blur-input/blur-input.vue +47 -0
  21. package/src/components/blur-input/index.ts +6 -0
  22. package/src/components/code-editor/base-code-editor.vue +44 -0
  23. package/src/components/code-editor/index.ts +58 -0
  24. package/src/components/code-editor/styles.css +27 -0
  25. package/src/components/code-editor/types.ts +20 -0
  26. package/src/components/code-editor/utils.ts +24 -0
  27. package/src/components/code-editor-mini/code-editor-mini.vue +16 -0
  28. package/src/components/code-editor-mini/index.ts +6 -0
  29. package/src/components/condition-context/context.ts +45 -0
  30. package/src/components/condition-context/hooks/use-condition.ts +120 -0
  31. package/src/components/condition-context/index.ts +14 -0
  32. package/src/components/condition-context/op.ts +86 -0
  33. package/src/components/condition-context/types.ts +22 -0
  34. package/src/components/condition-row/condition-row.vue +126 -0
  35. package/src/components/condition-row/index.ts +7 -0
  36. package/src/components/condition-row/styles.css +30 -0
  37. package/src/components/condition-row/types.ts +12 -0
  38. package/src/components/constant-input/constant-input.vue +48 -0
  39. package/src/components/constant-input/index.ts +7 -0
  40. package/src/components/constant-input/types.ts +23 -0
  41. package/src/components/coze-editor-extensions/extensions/inputs-tree.vue +16 -0
  42. package/src/components/coze-editor-extensions/extensions/variable-tag.vue +10 -0
  43. package/src/components/coze-editor-extensions/extensions/variable-tree.vue +18 -0
  44. package/src/components/coze-editor-extensions/index.ts +22 -0
  45. package/src/components/coze-editor-extensions/styles.css +41 -0
  46. package/src/components/db-condition-row/db-condition-row.vue +112 -0
  47. package/src/components/db-condition-row/index.ts +7 -0
  48. package/src/components/db-condition-row/styles.css +41 -0
  49. package/src/components/db-condition-row/types.ts +20 -0
  50. package/src/components/display-flow-value/display-flow-value.vue +46 -0
  51. package/src/components/display-flow-value/index.ts +6 -0
  52. package/src/components/display-inputs-values/display-inputs-value-all-in-tag.vue +26 -0
  53. package/src/components/display-inputs-values/display-inputs-values.vue +43 -0
  54. package/src/components/display-inputs-values/index.ts +7 -0
  55. package/src/components/display-inputs-values/styles.css +10 -0
  56. package/src/components/display-outputs/display-outputs.vue +62 -0
  57. package/src/components/display-outputs/index.ts +6 -0
  58. package/src/components/display-outputs/styles.css +10 -0
  59. package/src/components/display-schema-tag/display-schema-tag.vue +41 -0
  60. package/src/components/display-schema-tag/index.ts +6 -0
  61. package/src/components/display-schema-tag/styles.css +25 -0
  62. package/src/components/display-schema-tree/display-schema-tree.vue +55 -0
  63. package/src/components/display-schema-tree/index.ts +6 -0
  64. package/src/components/display-schema-tree/styles.css +84 -0
  65. package/src/components/dynamic-value-input/dynamic-value-input.vue +145 -0
  66. package/src/components/dynamic-value-input/hooks.ts +71 -0
  67. package/src/components/dynamic-value-input/index.ts +10 -0
  68. package/src/components/dynamic-value-input/styles.css +59 -0
  69. package/src/components/index.ts +84 -0
  70. package/src/components/inputs-values/index.ts +6 -0
  71. package/src/components/inputs-values/inputs-values.vue +67 -0
  72. package/src/components/inputs-values/styles.css +17 -0
  73. package/src/components/inputs-values/types.ts +23 -0
  74. package/src/components/inputs-values-tree/hooks/use-child-list.ts +65 -0
  75. package/src/components/inputs-values-tree/index.ts +6 -0
  76. package/src/components/inputs-values-tree/inputs-values-tree.vue +59 -0
  77. package/src/components/inputs-values-tree/row.vue +139 -0
  78. package/src/components/inputs-values-tree/styles.css +94 -0
  79. package/src/components/inputs-values-tree/types.ts +23 -0
  80. package/src/components/json-editor-with-variables/index.ts +7 -0
  81. package/src/components/json-editor-with-variables/json-editor-with-variables.vue +24 -0
  82. package/src/components/json-editor-with-variables/types.ts +8 -0
  83. package/src/components/json-schema-creator/index.ts +7 -0
  84. package/src/components/json-schema-creator/json-input-modal.vue +51 -0
  85. package/src/components/json-schema-creator/json-schema-creator.vue +27 -0
  86. package/src/components/json-schema-creator/types.ts +10 -0
  87. package/src/components/json-schema-creator/utils/json-to-schema.ts +50 -0
  88. package/src/components/json-schema-editor/default-value.vue +30 -0
  89. package/src/components/json-schema-editor/hooks.ts +134 -0
  90. package/src/components/json-schema-editor/index.ts +6 -0
  91. package/src/components/json-schema-editor/json-schema-editor.vue +53 -0
  92. package/src/components/json-schema-editor/property-edit.vue +222 -0
  93. package/src/components/json-schema-editor/styles.css +135 -0
  94. package/src/components/json-schema-editor/types.ts +25 -0
  95. package/src/components/prompt-editor/index.ts +7 -0
  96. package/src/components/prompt-editor/prompt-editor.vue +40 -0
  97. package/src/components/prompt-editor/styles.css +14 -0
  98. package/src/components/prompt-editor/types.ts +20 -0
  99. package/src/components/prompt-editor-with-inputs/index.ts +7 -0
  100. package/src/components/prompt-editor-with-inputs/prompt-editor-with-inputs.vue +18 -0
  101. package/src/components/prompt-editor-with-inputs/types.ts +11 -0
  102. package/src/components/prompt-editor-with-variables/index.ts +7 -0
  103. package/src/components/prompt-editor-with-variables/prompt-editor-with-variables.vue +19 -0
  104. package/src/components/prompt-editor-with-variables/types.ts +8 -0
  105. package/src/components/sql-editor-with-variables/index.ts +7 -0
  106. package/src/components/sql-editor-with-variables/sql-editor-with-variables.vue +24 -0
  107. package/src/components/sql-editor-with-variables/types.ts +8 -0
  108. package/src/components/type-selector/index.ts +11 -0
  109. package/src/components/type-selector/type-selector.vue +79 -0
  110. package/src/components/type-selector/types.ts +33 -0
  111. package/src/components/variable-selector/context.ts +44 -0
  112. package/src/components/variable-selector/index.ts +13 -0
  113. package/src/components/variable-selector/styles.css +70 -0
  114. package/src/components/variable-selector/types.ts +22 -0
  115. package/src/components/variable-selector/use-variable-tree.ts +108 -0
  116. package/src/components/variable-selector/variable-selector.vue +139 -0
  117. package/src/effects/auto-rename-ref/index.ts +109 -0
  118. package/src/effects/index.ts +12 -0
  119. package/src/effects/listen-ref-schema-change/index.ts +56 -0
  120. package/src/effects/listen-ref-value-change/index.ts +53 -0
  121. package/src/effects/provide-batch-input/index.ts +40 -0
  122. package/src/effects/provide-json-schema-outputs/index.ts +23 -0
  123. package/src/effects/sync-variable-title/index.ts +25 -0
  124. package/src/effects/validate-when-variable-sync/index.ts +34 -0
  125. package/src/env.d.ts +12 -0
  126. package/src/form-plugins/batch-outputs-plugin/index.ts +120 -0
  127. package/src/form-plugins/index.ts +8 -0
  128. package/src/form-plugins/infer-assign-plugin/index.ts +87 -0
  129. package/src/form-plugins/infer-inputs-plugin/index.ts +85 -0
  130. package/src/hooks/index.ts +6 -0
  131. package/src/hooks/use-object-list/index.ts +161 -0
  132. package/src/index.ts +125 -0
  133. package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +27 -0
  134. package/src/plugins/disable-declaration-plugin/index.ts +6 -0
  135. package/src/plugins/index.ts +16 -0
  136. package/src/plugins/json-schema-preset/create-type-preset-plugin.ts +35 -0
  137. package/src/plugins/json-schema-preset/index.ts +25 -0
  138. package/src/plugins/json-schema-preset/type-definition/array.ts +38 -0
  139. package/src/plugins/json-schema-preset/type-definition/boolean.ts +47 -0
  140. package/src/plugins/json-schema-preset/type-definition/date-time.ts +60 -0
  141. package/src/plugins/json-schema-preset/type-definition/enum.ts +31 -0
  142. package/src/plugins/json-schema-preset/type-definition/index.ts +37 -0
  143. package/src/plugins/json-schema-preset/type-definition/integer.ts +47 -0
  144. package/src/plugins/json-schema-preset/type-definition/map.ts +34 -0
  145. package/src/plugins/json-schema-preset/type-definition/number.ts +46 -0
  146. package/src/plugins/json-schema-preset/type-definition/object.ts +34 -0
  147. package/src/plugins/json-schema-preset/type-definition/string.ts +52 -0
  148. package/src/plugins/json-schema-preset/types.ts +25 -0
  149. package/src/plugins/json-schema-preset/vue.ts +38 -0
  150. package/src/shared/flow-value/index.ts +17 -0
  151. package/src/shared/flow-value/schema.ts +38 -0
  152. package/src/shared/flow-value/types.ts +49 -0
  153. package/src/shared/flow-value/utils.ts +213 -0
  154. package/src/shared/format-legacy-refs/index.ts +158 -0
  155. package/src/shared/format-legacy-refs/readme.md +38 -0
  156. package/src/shared/index.ts +32 -0
  157. package/src/shared/inject-material/index.ts +50 -0
  158. package/src/shared/lazy-suspense/index.ts +20 -0
  159. package/src/shared/polyfill-create-root/index.ts +38 -0
  160. package/src/ui/fg-button.vue +27 -0
  161. package/src/ui/fg-cascader.vue +92 -0
  162. package/src/ui/fg-checkbox.vue +25 -0
  163. package/src/ui/fg-icon-button.vue +31 -0
  164. package/src/ui/fg-input.vue +50 -0
  165. package/src/ui/fg-modal.vue +37 -0
  166. package/src/ui/fg-popover.vue +19 -0
  167. package/src/ui/fg-select.vue +81 -0
  168. package/src/ui/fg-tag.vue +37 -0
  169. package/src/ui/fg-textarea.vue +42 -0
  170. package/src/ui/fg-tree-nodes.vue +48 -0
  171. package/src/ui/fg-tree-select.vue +86 -0
  172. package/src/ui/icons.ts +60 -0
  173. package/src/ui/index.ts +20 -0
  174. package/src/ui/styles.css +277 -0
  175. package/src/ui/types.ts +36 -0
  176. package/src/validate/index.ts +6 -0
  177. package/src/validate/validate-flow-value/index.ts +62 -0
package/src/index.ts ADDED
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export {
7
+ AssignRow,
8
+ AssignRows,
9
+ BaseCodeEditor,
10
+ BatchOutputs,
11
+ BatchVariableSelector,
12
+ BlurInput,
13
+ CodeEditor,
14
+ CodeEditorMini,
15
+ ConditionPresetOp,
16
+ ConditionProvider,
17
+ ConditionRow,
18
+ ConstantInput,
19
+ DBConditionRow,
20
+ DisplayFlowValue,
21
+ DisplayInputsValueAllInTag,
22
+ DisplayInputsValues,
23
+ DisplayOutputs,
24
+ DisplaySchemaTag,
25
+ DisplaySchemaTree,
26
+ DynamicValueInput,
27
+ EditorInputsTree,
28
+ EditorVariableTagInject,
29
+ EditorVariableTree,
30
+ InjectDynamicValueInput,
31
+ InjectTypeSelector,
32
+ InjectVariableSelector,
33
+ InputsValues,
34
+ InputsValuesTree,
35
+ JsonCodeEditor,
36
+ JsonEditorWithVariables,
37
+ JsonSchemaCreator,
38
+ JsonSchemaEditor,
39
+ PromptEditor,
40
+ PromptEditorWithInputs,
41
+ PromptEditorWithVariables,
42
+ PythonCodeEditor,
43
+ SQLCodeEditor,
44
+ SQLEditorWithVariables,
45
+ ShellCodeEditor,
46
+ TypeScriptCodeEditor,
47
+ TypeSelector,
48
+ VariableSelector,
49
+ VariableSelectorProvider,
50
+ getTypeSelectValue,
51
+ parseTypeSelectValue,
52
+ type AssignValueType,
53
+ type CodeEditorPropsType,
54
+ type ConditionOpConfig,
55
+ type ConditionOpConfigs,
56
+ type ConditionRowValueType,
57
+ type ConstantInputStrategy,
58
+ type DBConditionOptionType,
59
+ type DBConditionRowValueType,
60
+ type IConditionRule,
61
+ type IConditionRuleFactory,
62
+ type JsonEditorWithVariablesProps,
63
+ type JsonSchemaCreatorProps,
64
+ type PromptEditorPropsType,
65
+ type PromptEditorWithInputsProps,
66
+ type PromptEditorWithVariablesProps,
67
+ type SQLEditorWithVariablesProps,
68
+ type TypeSelectorProps,
69
+ type VariableSelectorProps,
70
+ useCondition,
71
+ useConditionContext,
72
+ useVariableTree,
73
+ } from './components';
74
+ export {
75
+ autoRenameRefEffect,
76
+ listenRefSchemaChange,
77
+ listenRefValueChange,
78
+ provideBatchInputEffect,
79
+ provideJsonSchemaOutputs,
80
+ syncVariableTitle,
81
+ validateWhenVariableSync,
82
+ } from './effects';
83
+ export {
84
+ createBatchOutputsFormPlugin,
85
+ createInferAssignPlugin,
86
+ createInferInputsPlugin,
87
+ provideBatchOutputsEffect,
88
+ } from './form-plugins';
89
+ export { useObjectList } from './hooks';
90
+ export {
91
+ JsonSchemaTypePresetProvider,
92
+ JsonSchemaUtils,
93
+ createDisableDeclarationPlugin,
94
+ createTypePresetPlugin,
95
+ type ConstantRendererProps,
96
+ type IJsonSchema,
97
+ type JsonSchemaBasicType,
98
+ type JsonSchemaTypeRegistry,
99
+ useTypeManager,
100
+ } from './plugins';
101
+ export {
102
+ FlowValueUtils,
103
+ createInjectMaterial,
104
+ formatLegacyRefOnInit,
105
+ formatLegacyRefOnSubmit,
106
+ formatLegacyRefToNewRef,
107
+ formatNewRefToLegacyRef,
108
+ isLegacyFlowRefValueSchema,
109
+ isNewFlowRefValueSchema,
110
+ lazySuspense,
111
+ polyfillCreateRoot,
112
+ type FlowValueType,
113
+ type IFlowConstantRefValue,
114
+ type IFlowConstantValue,
115
+ type IFlowExpressionValue,
116
+ type IFlowRefValue,
117
+ type IFlowTemplateValue,
118
+ type IFlowValue,
119
+ type IFlowValueExtra,
120
+ type IInputsValues,
121
+ type IPolyfillRoot,
122
+ unstableSetCreateRoot,
123
+ withSuspense,
124
+ } from './shared';
125
+ export { validateFlowValue } from './validate';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { ASTMatch, type GlobalEventActionType, VariableEngine } from '@flowgram-vue/variable-core';
7
+ import { definePluginCreator } from '@flowgram-vue/core';
8
+
9
+ export const createDisableDeclarationPlugin = definePluginCreator<void>({
10
+ onInit(ctx) {
11
+ const variableEngine = ctx.get(VariableEngine);
12
+
13
+ const handleEvent = (action: GlobalEventActionType) => {
14
+ if (ASTMatch.isVariableDeclaration(action.ast)) {
15
+ if (!action.ast.meta?.disabled) {
16
+ action.ast.updateMeta({
17
+ ...(action.ast.meta || {}),
18
+ disabled: true,
19
+ });
20
+ }
21
+ }
22
+ };
23
+
24
+ variableEngine.onGlobalEvent('NewAST', handleEvent);
25
+ variableEngine.onGlobalEvent('UpdateAST', handleEvent);
26
+ },
27
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export { createDisableDeclarationPlugin } from './create-disable-declaration-plugin';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export { createDisableDeclarationPlugin } from './disable-declaration-plugin';
7
+ export {
8
+ JsonSchemaTypePresetProvider,
9
+ JsonSchemaUtils,
10
+ createTypePresetPlugin,
11
+ type ConstantRendererProps,
12
+ type IJsonSchema,
13
+ type JsonSchemaBasicType,
14
+ type JsonSchemaTypeRegistry,
15
+ useTypeManager,
16
+ } from './json-schema-preset';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import {
7
+ BaseTypeManager,
8
+ jsonSchemaContainerModule,
9
+ JsonSchemaTypeManager,
10
+ } from '@flowgram-vue/json-schema';
11
+ import { definePluginCreator, type PluginCreator } from '@flowgram-vue/core';
12
+
13
+ import { JsonSchemaTypeRegistry } from './types';
14
+ import { initRegistries, jsonSchemaTypePreset } from './type-definition';
15
+
16
+ initRegistries();
17
+
18
+ type TypePresetRegistry = Partial<JsonSchemaTypeRegistry> & Pick<JsonSchemaTypeRegistry, 'type'>;
19
+
20
+ interface TypePresetPluginOptions {
21
+ types?: TypePresetRegistry[];
22
+ unregisterTypes?: string[];
23
+ }
24
+
25
+ export const createTypePresetPlugin: PluginCreator<TypePresetPluginOptions> =
26
+ definePluginCreator<TypePresetPluginOptions>({
27
+ onInit(ctx, opts) {
28
+ const typeManager = ctx.get(BaseTypeManager) as unknown as JsonSchemaTypeManager;
29
+ jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
30
+
31
+ opts.types?.forEach((_type) => typeManager.register(_type));
32
+ opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
33
+ },
34
+ containerModules: [jsonSchemaContainerModule],
35
+ });
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import {
7
+ type JsonSchemaBasicType,
8
+ JsonSchemaUtils,
9
+ type IJsonSchema,
10
+ } from '@flowgram-vue/json-schema';
11
+
12
+ import { type ConstantRendererProps, type JsonSchemaTypeRegistry } from './types';
13
+ import { useTypeManager, JsonSchemaTypePresetProvider } from './vue';
14
+ import { createTypePresetPlugin } from './create-type-preset-plugin';
15
+
16
+ export {
17
+ createTypePresetPlugin,
18
+ useTypeManager,
19
+ JsonSchemaTypePresetProvider,
20
+ JsonSchemaUtils,
21
+ type IJsonSchema,
22
+ type JsonSchemaTypeRegistry,
23
+ type ConstantRendererProps,
24
+ type JsonSchemaBasicType,
25
+ };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+ import { I18n } from '@flowgram-vue/i18n';
8
+
9
+ import { JsonCodeEditor } from '@/components/code-editor';
10
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
+
12
+ import { type JsonSchemaTypeRegistry } from '../types';
13
+
14
+ export const arrayRegistry: Partial<JsonSchemaTypeRegistry> = {
15
+ type: 'array',
16
+ ConstantRenderer: defineComponent({
17
+ name: 'ArrayConstantRenderer',
18
+ props: ['value', 'onChange', 'readonly'],
19
+ setup(props) {
20
+ return () =>
21
+ h(JsonCodeEditor, {
22
+ mini: true,
23
+ value: props.value,
24
+ readonly: props.readonly,
25
+ placeholder: I18n.t('Please Input Array'),
26
+ onChange: (v: string) => props.onChange?.(v),
27
+ });
28
+ },
29
+ }),
30
+ conditionRule: {
31
+ [ConditionPresetOp.IS_EMPTY]: null,
32
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
33
+ [ConditionPresetOp.CONTAINS]: { type: 'array', extra: { weak: true } },
34
+ [ConditionPresetOp.NOT_CONTAINS]: { type: 'array', extra: { weak: true } },
35
+ [ConditionPresetOp.EQ]: { type: 'array', extra: { weak: true } },
36
+ [ConditionPresetOp.NEQ]: { type: 'array', extra: { weak: true } },
37
+ },
38
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+ import { I18n } from '@flowgram-vue/i18n';
8
+
9
+ import { FgSelect } from '@/ui';
10
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
+
12
+ import { type JsonSchemaTypeRegistry } from '../types';
13
+
14
+ export const booleanRegistry: Partial<JsonSchemaTypeRegistry> = {
15
+ type: 'boolean',
16
+ ConstantRenderer: defineComponent({
17
+ name: 'BooleanConstantRenderer',
18
+ props: ['value', 'onChange', 'readonly', 'schema'],
19
+ setup(props) {
20
+ return () =>
21
+ h(FgSelect, {
22
+ value: props.value ? 1 : 0,
23
+ disabled: props.readonly,
24
+ placeholder: I18n.t('Please Select Boolean'),
25
+ options: [
26
+ { label: I18n.t('True'), value: 1 },
27
+ { label: I18n.t('False'), value: 0 },
28
+ ],
29
+ onChange: (v: string | number) => props.onChange?.(!!v),
30
+ });
31
+ },
32
+ }),
33
+ conditionRule: {
34
+ [ConditionPresetOp.EQ]: { type: 'boolean' },
35
+ [ConditionPresetOp.NEQ]: { type: 'boolean' },
36
+ [ConditionPresetOp.IS_TRUE]: null,
37
+ [ConditionPresetOp.IS_FALSE]: null,
38
+ [ConditionPresetOp.IN]: {
39
+ type: 'array',
40
+ items: { type: 'boolean' },
41
+ },
42
+ [ConditionPresetOp.NIN]: {
43
+ type: 'array',
44
+ items: { type: 'boolean' },
45
+ },
46
+ },
47
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+ import { format } from 'date-fns';
8
+
9
+ import { FgInput } from '@/ui';
10
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
+
12
+ import { type JsonSchemaTypeRegistry } from '../types';
13
+
14
+ const DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
15
+
16
+ const stringifyDateTime = (value: unknown) => {
17
+ if (value === null || value === undefined || value === '') {
18
+ return '';
19
+ }
20
+
21
+ const date =
22
+ value instanceof Date
23
+ ? value
24
+ : typeof value === 'number'
25
+ ? new Date(value)
26
+ : new Date(String(value));
27
+
28
+ if (Number.isNaN(date.getTime())) {
29
+ return '';
30
+ }
31
+
32
+ return format(date, DATE_TIME_FORMAT);
33
+ };
34
+
35
+ export const dateTimeRegistry: Partial<JsonSchemaTypeRegistry> = {
36
+ type: 'date-time',
37
+ ConstantRenderer: defineComponent({
38
+ name: 'DateTimeConstantRenderer',
39
+ props: ['value', 'onChange', 'readonly', 'schema'],
40
+ setup(props) {
41
+ return () =>
42
+ h(FgInput, {
43
+ type: 'datetime-local',
44
+ value: props.value,
45
+ disabled: props.readonly,
46
+ onChange: (v: string) => props.onChange?.(stringifyDateTime(v)),
47
+ });
48
+ },
49
+ }),
50
+ conditionRule: {
51
+ [ConditionPresetOp.EQ]: { type: 'date-time' },
52
+ [ConditionPresetOp.NEQ]: { type: 'date-time' },
53
+ [ConditionPresetOp.GT]: { type: 'date-time' },
54
+ [ConditionPresetOp.GTE]: { type: 'date-time' },
55
+ [ConditionPresetOp.LT]: { type: 'date-time' },
56
+ [ConditionPresetOp.LTE]: { type: 'date-time' },
57
+ [ConditionPresetOp.IS_EMPTY]: null,
58
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
59
+ },
60
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+
8
+ import { FgSelect } from '@/ui';
9
+
10
+ import { type JsonSchemaTypeRegistry } from '../types';
11
+
12
+ export const enumRegistry: Partial<JsonSchemaTypeRegistry> = {
13
+ type: 'enum',
14
+ parentType: [],
15
+ ConstantRenderer: defineComponent({
16
+ name: 'EnumConstantRenderer',
17
+ props: ['value', 'onChange', 'readonly', 'schema'],
18
+ setup(props) {
19
+ return () =>
20
+ h(FgSelect, {
21
+ value: props.value,
22
+ disabled: props.readonly,
23
+ options: (props.schema?.enum || []).map((value: string | number) => ({
24
+ label: `${value}`,
25
+ value,
26
+ })),
27
+ onChange: (v: string | number) => props.onChange?.(v),
28
+ });
29
+ },
30
+ }),
31
+ };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { jsonSchemaTypeManager } from '@flowgram-vue/json-schema';
7
+
8
+ import { stringRegistry } from './string';
9
+ import { objectRegistry } from './object';
10
+ import { numberRegistry } from './number';
11
+ import { mapRegistry } from './map';
12
+ import { integerRegistry } from './integer';
13
+ import { enumRegistry } from './enum';
14
+ import { dateTimeRegistry } from './date-time';
15
+ import { booleanRegistry } from './boolean';
16
+ import { arrayRegistry } from './array';
17
+ import { type JsonSchemaTypeRegistry } from '../types';
18
+
19
+ export const jsonSchemaTypePreset = [
20
+ stringRegistry,
21
+ objectRegistry,
22
+ numberRegistry,
23
+ integerRegistry,
24
+ booleanRegistry,
25
+ arrayRegistry,
26
+ mapRegistry,
27
+ enumRegistry,
28
+ dateTimeRegistry,
29
+ ];
30
+
31
+ export const initRegistries = () => {
32
+ if ((jsonSchemaTypeManager.getTypeByName('string') as JsonSchemaTypeRegistry)?.ConstantRenderer) {
33
+ return;
34
+ }
35
+
36
+ jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
37
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+ import { I18n } from '@flowgram-vue/i18n';
8
+
9
+ import { FgInput } from '@/ui';
10
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
+
12
+ import { type JsonSchemaTypeRegistry } from '../types';
13
+
14
+ export const integerRegistry: Partial<JsonSchemaTypeRegistry> = {
15
+ type: 'integer',
16
+ ConstantRenderer: defineComponent({
17
+ name: 'IntegerConstantRenderer',
18
+ props: ['value', 'onChange', 'readonly', 'schema', 'placeholder'],
19
+ setup(props) {
20
+ return () =>
21
+ h(FgInput, {
22
+ type: 'number',
23
+ value: props.value,
24
+ disabled: props.readonly,
25
+ placeholder: props.placeholder || I18n.t('Please Input Integer'),
26
+ onChange: (v: string) =>
27
+ props.onChange?.(v === '' ? undefined : Math.trunc(Number(v))),
28
+ });
29
+ },
30
+ }),
31
+ conditionRule: {
32
+ [ConditionPresetOp.EQ]: { type: 'number' },
33
+ [ConditionPresetOp.NEQ]: { type: 'number' },
34
+ [ConditionPresetOp.GT]: { type: 'number' },
35
+ [ConditionPresetOp.GTE]: { type: 'number' },
36
+ [ConditionPresetOp.LT]: { type: 'number' },
37
+ [ConditionPresetOp.LTE]: { type: 'number' },
38
+ [ConditionPresetOp.IN]: {
39
+ type: 'array',
40
+ extra: { weak: true },
41
+ },
42
+ [ConditionPresetOp.NIN]: {
43
+ type: 'array',
44
+ extra: { weak: true },
45
+ },
46
+ },
47
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+ import { I18n } from '@flowgram-vue/i18n';
8
+
9
+ import { JsonCodeEditor } from '@/components/code-editor';
10
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
+
12
+ import { type JsonSchemaTypeRegistry } from '../types';
13
+
14
+ export const mapRegistry: Partial<JsonSchemaTypeRegistry> = {
15
+ type: 'map',
16
+ ConstantRenderer: defineComponent({
17
+ name: 'MapConstantRenderer',
18
+ props: ['value', 'onChange', 'readonly'],
19
+ setup(props) {
20
+ return () =>
21
+ h(JsonCodeEditor, {
22
+ mini: true,
23
+ value: props.value,
24
+ readonly: props.readonly,
25
+ placeholder: I18n.t('Please Input Map'),
26
+ onChange: (v: string) => props.onChange?.(v),
27
+ });
28
+ },
29
+ }),
30
+ conditionRule: {
31
+ [ConditionPresetOp.IS_EMPTY]: null,
32
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
33
+ },
34
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+ import { I18n } from '@flowgram-vue/i18n';
8
+
9
+ import { FgInput } from '@/ui';
10
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
+
12
+ import { type JsonSchemaTypeRegistry } from '../types';
13
+
14
+ export const numberRegistry: Partial<JsonSchemaTypeRegistry> = {
15
+ type: 'number',
16
+ ConstantRenderer: defineComponent({
17
+ name: 'NumberConstantRenderer',
18
+ props: ['value', 'onChange', 'readonly', 'schema', 'placeholder'],
19
+ setup(props) {
20
+ return () =>
21
+ h(FgInput, {
22
+ type: 'number',
23
+ value: props.value,
24
+ disabled: props.readonly,
25
+ placeholder: props.placeholder || I18n.t('Please Input Number'),
26
+ onChange: (v: string) => props.onChange?.(v === '' ? undefined : Number(v)),
27
+ });
28
+ },
29
+ }),
30
+ conditionRule: {
31
+ [ConditionPresetOp.EQ]: { type: 'number' },
32
+ [ConditionPresetOp.NEQ]: { type: 'number' },
33
+ [ConditionPresetOp.GT]: { type: 'number' },
34
+ [ConditionPresetOp.GTE]: { type: 'number' },
35
+ [ConditionPresetOp.LT]: { type: 'number' },
36
+ [ConditionPresetOp.LTE]: { type: 'number' },
37
+ [ConditionPresetOp.IN]: {
38
+ type: 'array',
39
+ extra: { weak: true },
40
+ },
41
+ [ConditionPresetOp.NIN]: {
42
+ type: 'array',
43
+ extra: { weak: true },
44
+ },
45
+ },
46
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+ import { I18n } from '@flowgram-vue/i18n';
8
+
9
+ import { JsonCodeEditor } from '@/components/code-editor';
10
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
+
12
+ import { type JsonSchemaTypeRegistry } from '../types';
13
+
14
+ export const objectRegistry: Partial<JsonSchemaTypeRegistry> = {
15
+ type: 'object',
16
+ ConstantRenderer: defineComponent({
17
+ name: 'ObjectConstantRenderer',
18
+ props: ['value', 'onChange', 'readonly'],
19
+ setup(props) {
20
+ return () =>
21
+ h(JsonCodeEditor, {
22
+ mini: true,
23
+ value: props.value,
24
+ readonly: props.readonly,
25
+ placeholder: I18n.t('Please Input Object'),
26
+ onChange: (v: string) => props.onChange?.(v),
27
+ });
28
+ },
29
+ }),
30
+ conditionRule: {
31
+ [ConditionPresetOp.IS_EMPTY]: null,
32
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
33
+ },
34
+ };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { defineComponent, h } from 'vue';
7
+ import { I18n } from '@flowgram-vue/i18n';
8
+
9
+ import { FgInput, FgTextarea } from '@/ui';
10
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
+
12
+ import { type JsonSchemaTypeRegistry } from '../types';
13
+
14
+ export const stringRegistry: Partial<JsonSchemaTypeRegistry> = {
15
+ type: 'string',
16
+ ConstantRenderer: defineComponent({
17
+ name: 'StringConstantRenderer',
18
+ props: ['value', 'onChange', 'readonly', 'schema', 'enableMultiLineStr', 'placeholder'],
19
+ setup(props) {
20
+ return () =>
21
+ props.enableMultiLineStr
22
+ ? h(FgTextarea, {
23
+ value: props.value,
24
+ disabled: props.readonly,
25
+ placeholder: props.placeholder || I18n.t('Please Input String'),
26
+ onChange: (v: string) => props.onChange?.(v),
27
+ })
28
+ : h(FgInput, {
29
+ value: props.value,
30
+ disabled: props.readonly,
31
+ placeholder: props.placeholder || I18n.t('Please Input String'),
32
+ onChange: (v: string) => props.onChange?.(v),
33
+ });
34
+ },
35
+ }),
36
+ conditionRule: {
37
+ [ConditionPresetOp.EQ]: { type: 'string' },
38
+ [ConditionPresetOp.NEQ]: { type: 'string' },
39
+ [ConditionPresetOp.CONTAINS]: { type: 'string' },
40
+ [ConditionPresetOp.NOT_CONTAINS]: { type: 'string' },
41
+ [ConditionPresetOp.IN]: {
42
+ type: 'array',
43
+ items: { type: 'string' },
44
+ },
45
+ [ConditionPresetOp.NIN]: {
46
+ type: 'array',
47
+ items: { type: 'string' },
48
+ },
49
+ [ConditionPresetOp.IS_EMPTY]: null,
50
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
51
+ },
52
+ };