@flowgram.ai/form-materials 0.1.0-alpha.11 → 0.1.0-alpha.12

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 (121) hide show
  1. package/bin/index.ts +11 -5
  2. package/bin/materials.ts +10 -1
  3. package/dist/esm/index.js +1917 -1371
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.mts +320 -113
  6. package/dist/index.d.ts +320 -113
  7. package/dist/index.js +2023 -1484
  8. package/dist/index.js.map +1 -1
  9. package/package.json +5 -4
  10. package/src/components/assign-row/components/blur-input.tsx +27 -0
  11. package/src/components/assign-row/config.json +11 -0
  12. package/src/components/assign-row/index.tsx +84 -0
  13. package/src/components/assign-row/types.ts +25 -0
  14. package/src/components/assign-rows/config.json +11 -0
  15. package/src/components/assign-rows/index.tsx +59 -0
  16. package/src/components/batch-outputs/config.json +2 -1
  17. package/src/components/batch-outputs/index.tsx +4 -12
  18. package/src/components/batch-variable-selector/config.json +6 -2
  19. package/src/components/batch-variable-selector/index.tsx +1 -1
  20. package/src/components/code-editor/index.tsx +7 -0
  21. package/src/components/code-editor/language-features.ts +22 -1
  22. package/src/components/code-editor/theme/light.ts +1 -1
  23. package/src/components/code-editor-mini/config.json +7 -0
  24. package/src/components/code-editor-mini/index.tsx +31 -0
  25. package/src/components/condition-row/config.json +10 -2
  26. package/src/components/condition-row/constants.ts +6 -8
  27. package/src/components/condition-row/hooks/useOp.tsx +3 -1
  28. package/src/components/condition-row/hooks/useRule.ts +2 -2
  29. package/src/components/condition-row/index.tsx +2 -1
  30. package/src/components/condition-row/types.ts +3 -1
  31. package/src/components/constant-input/config.json +6 -3
  32. package/src/components/constant-input/index.tsx +18 -62
  33. package/src/components/constant-input/types.ts +6 -9
  34. package/src/components/display-flow-value/config.json +8 -0
  35. package/src/components/display-flow-value/index.tsx +59 -0
  36. package/src/components/display-inputs-values/config.json +9 -0
  37. package/src/components/display-inputs-values/index.tsx +27 -0
  38. package/src/components/display-inputs-values/styles.ts +12 -0
  39. package/src/components/display-outputs/config.json +10 -0
  40. package/src/components/display-outputs/index.tsx +64 -0
  41. package/src/components/display-outputs/styles.ts +12 -0
  42. package/src/components/display-schema-tag/config.json +10 -0
  43. package/src/components/display-schema-tag/index.tsx +44 -0
  44. package/src/components/display-schema-tag/styles.ts +28 -0
  45. package/src/components/display-schema-tree/config.json +11 -0
  46. package/src/components/display-schema-tree/index.tsx +74 -0
  47. package/src/components/display-schema-tree/styles.tsx +90 -0
  48. package/src/components/dynamic-value-input/config.json +11 -2
  49. package/src/components/dynamic-value-input/hooks.ts +53 -0
  50. package/src/components/dynamic-value-input/index.tsx +64 -13
  51. package/src/components/dynamic-value-input/styles.tsx +28 -2
  52. package/src/components/index.ts +9 -0
  53. package/src/components/inputs-values/components/blur-input.tsx +27 -0
  54. package/src/components/inputs-values/config.json +13 -0
  55. package/src/components/inputs-values/index.tsx +73 -0
  56. package/src/components/inputs-values/styles.tsx +19 -0
  57. package/src/components/inputs-values/types.ts +22 -0
  58. package/src/components/json-schema-editor/config.json +2 -2
  59. package/src/components/json-schema-editor/default-value.tsx +1 -1
  60. package/src/components/json-schema-editor/hooks.tsx +1 -1
  61. package/src/components/json-schema-editor/index.tsx +15 -2
  62. package/src/components/json-schema-editor/types.ts +1 -1
  63. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +1 -1
  64. package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +6 -3
  65. package/src/components/type-selector/config.json +6 -2
  66. package/src/components/type-selector/index.tsx +55 -12
  67. package/src/components/variable-selector/config.json +6 -2
  68. package/src/components/variable-selector/index.tsx +34 -13
  69. package/src/components/variable-selector/styles.tsx +18 -8
  70. package/src/components/variable-selector/use-variable-tree.tsx +19 -22
  71. package/src/effects/index.ts +3 -1
  72. package/src/effects/listen-ref-schema-change/config.json +10 -0
  73. package/src/effects/listen-ref-schema-change/index.ts +56 -0
  74. package/src/effects/listen-ref-value-change/config.json +9 -0
  75. package/src/effects/listen-ref-value-change/index.ts +53 -0
  76. package/src/effects/provide-json-schema-outputs/config.json +4 -5
  77. package/src/effects/provide-json-schema-outputs/index.ts +1 -3
  78. package/src/effects/sync-variable-title/index.ts +1 -0
  79. package/src/effects/validate-when-variable-sync/config.json +5 -0
  80. package/src/effects/validate-when-variable-sync/index.ts +35 -0
  81. package/src/form-plugins/index.ts +3 -1
  82. package/src/form-plugins/infer-assign-plugin/config.json +7 -0
  83. package/src/form-plugins/infer-assign-plugin/index.ts +90 -0
  84. package/src/form-plugins/infer-inputs-plugin/config.json +9 -0
  85. package/src/form-plugins/infer-inputs-plugin/index.ts +108 -0
  86. package/src/hooks/index.tsx +6 -0
  87. package/src/hooks/use-object-list/config.json +8 -0
  88. package/src/hooks/use-object-list/index.tsx +136 -0
  89. package/src/index.ts +3 -1
  90. package/src/{typings/json-schema → plugins/disable-declaration-plugin}/config.json +1 -1
  91. package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
  92. package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
  93. package/src/plugins/index.ts +7 -0
  94. package/src/plugins/json-schema-preset/config.json +9 -0
  95. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +28 -0
  96. package/src/plugins/json-schema-preset/index.tsx +41 -0
  97. package/src/plugins/json-schema-preset/manager.ts +18 -0
  98. package/src/plugins/json-schema-preset/type-definition/array.tsx +24 -0
  99. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +32 -0
  100. package/src/plugins/json-schema-preset/type-definition/index.tsx +24 -0
  101. package/src/plugins/json-schema-preset/type-definition/integer.tsx +24 -0
  102. package/src/plugins/json-schema-preset/type-definition/number.tsx +24 -0
  103. package/src/plugins/json-schema-preset/type-definition/object.tsx +24 -0
  104. package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -0
  105. package/src/{utils → shared}/index.ts +0 -1
  106. package/src/typings/flow-value/config.json +3 -1
  107. package/src/typings/flow-value/index.ts +11 -0
  108. package/src/typings/index.ts +0 -1
  109. package/src/validate/index.tsx +6 -0
  110. package/src/validate/validate-flow-value/config.json +7 -0
  111. package/src/validate/validate-flow-value/index.tsx +73 -0
  112. package/src/components/batch-outputs/use-list.ts +0 -86
  113. package/src/components/type-selector/constants.tsx +0 -364
  114. package/src/effects/provide-batch-outputs/config.json +0 -5
  115. package/src/effects/provide-batch-outputs/index.ts +0 -38
  116. package/src/typings/json-schema/index.ts +0 -36
  117. package/src/utils/json-schema/config.json +0 -5
  118. package/src/utils/json-schema/index.ts +0 -180
  119. /package/src/{utils → shared}/format-legacy-refs/config.json +0 -0
  120. /package/src/{utils → shared}/format-legacy-refs/index.ts +0 -0
  121. /package/src/{utils → shared}/format-legacy-refs/readme.md +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/form-materials",
3
- "version": "0.1.0-alpha.11",
3
+ "version": "0.1.0-alpha.12",
4
4
  "homepage": "https://flowgram.ai/",
5
5
  "repository": "https://github.com/bytedance/flowgram.ai",
6
6
  "license": "MIT",
@@ -34,7 +34,8 @@
34
34
  "@codemirror/view": "~6.38.0",
35
35
  "@codemirror/state": "~6.5.2",
36
36
  "typescript": "^5.8.3",
37
- "@flowgram.ai/editor": "0.1.0-alpha.11"
37
+ "@flowgram.ai/editor": "0.1.0-alpha.12",
38
+ "@flowgram.ai/json-schema": "0.1.0-alpha.12"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/lodash": "^4.14.137",
@@ -50,8 +51,8 @@
50
51
  "tsup": "^8.0.1",
51
52
  "typescript": "^5.8.3",
52
53
  "vitest": "^0.34.6",
53
- "@flowgram.ai/ts-config": "0.1.0-alpha.11",
54
- "@flowgram.ai/eslint-config": "0.1.0-alpha.11"
54
+ "@flowgram.ai/eslint-config": "0.1.0-alpha.12",
55
+ "@flowgram.ai/ts-config": "0.1.0-alpha.12"
55
56
  },
56
57
  "peerDependencies": {
57
58
  "react": ">=16.8",
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import React, { useEffect, useState } from 'react';
7
+
8
+ import Input, { InputProps } from '@douyinfe/semi-ui/lib/es/input';
9
+
10
+ export function BlurInput(props: InputProps) {
11
+ const [value, setValue] = useState('');
12
+
13
+ useEffect(() => {
14
+ setValue(props.value as string);
15
+ }, [props.value]);
16
+
17
+ return (
18
+ <Input
19
+ {...props}
20
+ value={value}
21
+ onChange={(value) => {
22
+ setValue(value);
23
+ }}
24
+ onBlur={(e) => props.onChange?.(value, e)}
25
+ />
26
+ );
27
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "assign-row",
3
+ "depMaterials": [
4
+ "flow-value",
5
+ "dynamic-value-input",
6
+ "variable-selector"
7
+ ],
8
+ "depPackages": [
9
+ "@douyinfe/semi-ui"
10
+ ]
11
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import React from 'react';
7
+
8
+ import { IconButton } from '@douyinfe/semi-ui';
9
+ import { IconMinus } from '@douyinfe/semi-icons';
10
+
11
+ import { IFlowConstantRefValue } from '@/typings';
12
+
13
+ import { AssignRowProps } from './types';
14
+ import { BlurInput } from './components/blur-input';
15
+ import { VariableSelector } from '../variable-selector';
16
+ import { DynamicValueInput } from '../dynamic-value-input';
17
+
18
+ export function AssignRow(props: AssignRowProps) {
19
+ const {
20
+ value = {
21
+ operator: 'assign',
22
+ },
23
+ onChange,
24
+ onDelete,
25
+ readonly,
26
+ } = props;
27
+
28
+ return (
29
+ <div style={{ display: 'flex', alignItems: 'center', gap: 5 }}>
30
+ <div style={{ width: 150, minWidth: 150, maxWidth: 150 }}>
31
+ {value?.operator === 'assign' ? (
32
+ <VariableSelector
33
+ style={{ width: '100%', height: 26 }}
34
+ value={value?.left?.content}
35
+ config={{ placeholder: 'Select Left' }}
36
+ onChange={(v) =>
37
+ onChange?.({
38
+ ...value,
39
+ left: { type: 'ref', content: v },
40
+ })
41
+ }
42
+ />
43
+ ) : (
44
+ <BlurInput
45
+ style={{ height: 26 }}
46
+ size="small"
47
+ placeholder="Input Name"
48
+ value={value?.left}
49
+ onChange={(v) =>
50
+ onChange?.({
51
+ ...value,
52
+ left: v,
53
+ })
54
+ }
55
+ />
56
+ )}
57
+ </div>
58
+ <div style={{ flexGrow: 1 }}>
59
+ <DynamicValueInput
60
+ readonly={readonly}
61
+ value={value?.right as IFlowConstantRefValue | undefined}
62
+ onChange={(v) =>
63
+ onChange?.({
64
+ ...value,
65
+ right: v,
66
+ })
67
+ }
68
+ />
69
+ </div>
70
+ {onDelete && (
71
+ <div>
72
+ <IconButton
73
+ size="small"
74
+ theme="borderless"
75
+ icon={<IconMinus />}
76
+ onClick={() => onDelete?.()}
77
+ />
78
+ </div>
79
+ )}
80
+ </div>
81
+ );
82
+ }
83
+
84
+ export { AssignValueType } from './types';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { IFlowRefValue, IFlowValue } from '@/typings';
7
+
8
+ export type AssignValueType =
9
+ | {
10
+ operator: 'assign';
11
+ left?: IFlowRefValue;
12
+ right?: IFlowValue;
13
+ }
14
+ | {
15
+ operator: 'declare';
16
+ left?: string;
17
+ right?: IFlowValue;
18
+ };
19
+
20
+ export interface AssignRowProps {
21
+ value?: AssignValueType;
22
+ onChange?: (value?: AssignValueType) => void;
23
+ onDelete?: () => void;
24
+ readonly?: boolean;
25
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "assign-rows",
3
+ "depMaterials": [
4
+ "flow-value",
5
+ "dynamic-value-input",
6
+ "variable-selector"
7
+ ],
8
+ "depPackages": [
9
+ "@douyinfe/semi-ui"
10
+ ]
11
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import React from 'react';
7
+
8
+ import { FieldArray, FieldArrayRenderProps } from '@flowgram.ai/editor';
9
+ import { Button } from '@douyinfe/semi-ui';
10
+ import { IconPlus } from '@douyinfe/semi-icons';
11
+
12
+ import { AssignRow, AssignValueType } from '../assign-row';
13
+
14
+ interface AssignRowsProps {
15
+ name: string;
16
+ readonly?: boolean;
17
+ }
18
+
19
+ export function AssignRows(props: AssignRowsProps) {
20
+ const { name, readonly } = props;
21
+
22
+ return (
23
+ <FieldArray name={name}>
24
+ {({ field }: FieldArrayRenderProps<AssignValueType | undefined>) => (
25
+ <>
26
+ {field.map((childField, index) => (
27
+ <AssignRow
28
+ key={childField.key}
29
+ readonly={readonly}
30
+ value={childField.value}
31
+ onChange={(value) => {
32
+ childField.onChange(value);
33
+ }}
34
+ onDelete={() => field.remove(index)}
35
+ />
36
+ ))}
37
+ <div style={{ display: 'flex', gap: 5 }}>
38
+ <Button
39
+ size="small"
40
+ theme="borderless"
41
+ icon={<IconPlus />}
42
+ onClick={() => field.append({ operator: 'assign' })}
43
+ >
44
+ Assign
45
+ </Button>
46
+ <Button
47
+ size="small"
48
+ theme="borderless"
49
+ icon={<IconPlus />}
50
+ onClick={() => field.append({ operator: 'declare' })}
51
+ >
52
+ Declaration
53
+ </Button>
54
+ </div>
55
+ </>
56
+ )}
57
+ </FieldArray>
58
+ );
59
+ }
@@ -2,7 +2,8 @@
2
2
  "name": "batch-outputs",
3
3
  "depMaterials": [
4
4
  "flow-value",
5
- "variable-selector"
5
+ "variable-selector",
6
+ "use-object-list"
6
7
  ],
7
8
  "depPackages": [
8
9
  "@douyinfe/semi-ui",
@@ -8,15 +8,15 @@ import React from 'react';
8
8
  import { Button, Input } from '@douyinfe/semi-ui';
9
9
  import { IconDelete, IconPlus } from '@douyinfe/semi-icons';
10
10
 
11
- import { useList } from './use-list';
12
11
  import { PropsType } from './types';
13
12
  import { VariableSelector } from '../variable-selector';
13
+ import { useObjectList } from '../../hooks';
14
14
  import { UIRow, UIRows } from './styles';
15
15
 
16
16
  export function BatchOutputs(props: PropsType) {
17
17
  const { readonly, style } = props;
18
18
 
19
- const { list, add, update, remove } = useList(props);
19
+ const { list, add, updateKey, updateValue, remove } = useObjectList(props);
20
20
 
21
21
  return (
22
22
  <div>
@@ -28,21 +28,13 @@ export function BatchOutputs(props: PropsType) {
28
28
  disabled={readonly}
29
29
  size="small"
30
30
  value={item.key}
31
- onChange={(v) => update({ ...item, key: v })}
31
+ onChange={(v) => updateKey(item.id, v)}
32
32
  />
33
33
  <VariableSelector
34
34
  style={{ flexGrow: 1 }}
35
35
  readonly={readonly}
36
36
  value={item.value?.content}
37
- onChange={(v) =>
38
- update({
39
- ...item,
40
- value: {
41
- type: 'ref',
42
- content: v,
43
- },
44
- })
45
- }
37
+ onChange={(v) => updateValue(item.id, { type: 'ref', content: v })}
46
38
  />
47
39
  <Button
48
40
  disabled={readonly}
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "name": "batch-variable-selector",
3
- "depMaterials": ["variable-selector"],
4
- "depPackages": []
3
+ "depMaterials": [
4
+ "variable-selector"
5
+ ],
6
+ "depPackages": [
7
+ "@flowgram.ai/json-schema"
8
+ ]
5
9
  }
@@ -5,10 +5,10 @@
5
5
 
6
6
  import React from 'react';
7
7
 
8
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
8
9
  import { PrivateScopeProvider } from '@flowgram.ai/editor';
9
10
 
10
11
  import { VariableSelector, VariableSelectorProps } from '../variable-selector';
11
- import { IJsonSchema } from '../../typings';
12
12
 
13
13
  const batchVariableSchema: IJsonSchema = {
14
14
  type: 'array',
@@ -15,6 +15,7 @@ import preset, { type EditorAPI } from '@coze-editor/editor/preset-code';
15
15
  import { EditorView } from '@codemirror/view';
16
16
 
17
17
  import { getSuffixByLanguageId } from './utils';
18
+ import { initTsWorker } from './language-features';
18
19
 
19
20
  import './theme';
20
21
  import './language-features';
@@ -54,6 +55,12 @@ export function CodeEditor({
54
55
  }: CodeEditorPropsType) {
55
56
  const editorRef = useRef<EditorAPI | null>(null);
56
57
 
58
+ useEffect(() => {
59
+ if (languageId === 'typescript') {
60
+ initTsWorker();
61
+ }
62
+ }, [languageId]);
63
+
57
64
  useEffect(() => {
58
65
  // listen to value change
59
66
  if (editorRef.current?.getValue() !== value) {
@@ -11,8 +11,8 @@ import { json } from '@coze-editor/editor/language-json';
11
11
  import { mixLanguages } from '@coze-editor/editor';
12
12
 
13
13
  languages.register('python', python);
14
- languages.register('typescript', typescript);
15
14
  languages.register('shell', shell);
15
+ languages.register('typescript', typescript);
16
16
 
17
17
  languages.register('json', {
18
18
  // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
@@ -21,3 +21,24 @@ languages.register('json', {
21
21
  }),
22
22
  languageService: json.languageService,
23
23
  });
24
+
25
+ let tsWorkerInit = false;
26
+
27
+ export const initTsWorker = () => {
28
+ if (tsWorkerInit) {
29
+ return;
30
+ }
31
+ tsWorkerInit = true;
32
+
33
+ const tsWorker = new Worker(
34
+ new URL(`@coze-editor/editor/language-typescript/worker`, import.meta.url),
35
+ { type: 'module' }
36
+ );
37
+ typescript.languageService.initialize(tsWorker, {
38
+ compilerOptions: {
39
+ // eliminate Promise error
40
+ lib: ['es2015', 'dom'],
41
+ noImplicitAny: false,
42
+ },
43
+ });
44
+ };
@@ -29,7 +29,7 @@ export const lightTheme: Extension = createTheme({
29
29
  gutterForeground: '#666',
30
30
  gutterBorderColor: 'transparent',
31
31
  gutterBorderWidth: 0,
32
- lineHighlight: '#f0f0f0',
32
+ lineHighlight: '#e1e1e180',
33
33
  bracketColors: ['#FFD700', '#DD99FF', '#78B0FF'],
34
34
  tooltip: {
35
35
  backgroundColor: '#f0f0f0',
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "code-editor-mini",
3
+ "depMaterials": [
4
+ "code-editor"
5
+ ],
6
+ "depPackages": []
7
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import React from 'react';
7
+
8
+ import styled from 'styled-components';
9
+
10
+ import { CodeEditor, CodeEditorPropsType } from '../code-editor';
11
+
12
+ const UIMini = styled.div`
13
+ .ͼ1 .cm-content {
14
+ padding: 0;
15
+ }
16
+ `;
17
+
18
+ export function CodeEditorMini(props: CodeEditorPropsType) {
19
+ return (
20
+ <UIMini>
21
+ <CodeEditor
22
+ {...props}
23
+ options={{
24
+ lineNumbersGutter: false,
25
+ foldGutter: false,
26
+ ...(props.options || {}),
27
+ }}
28
+ />
29
+ </UIMini>
30
+ );
31
+ }
@@ -1,5 +1,13 @@
1
1
  {
2
2
  "name": "condition-row",
3
- "depMaterials": ["variable-selector", "dynamic-value-input", "flow-value", "utils/json-schema", "typings/json-schema"],
4
- "depPackages": ["@douyinfe/semi-ui", "styled-components"]
3
+ "depMaterials": [
4
+ "variable-selector",
5
+ "dynamic-value-input",
6
+ "flow-value"
7
+ ],
8
+ "depPackages": [
9
+ "@douyinfe/semi-ui",
10
+ "styled-components",
11
+ "@flowgram.ai/json-schema"
12
+ ]
5
13
  }
@@ -13,8 +13,8 @@ export const rules: IRules = {
13
13
  [Op.NOT_CONTAINS]: 'string',
14
14
  [Op.IN]: 'array',
15
15
  [Op.NIN]: 'array',
16
- [Op.IS_EMPTY]: 'string',
17
- [Op.IS_NOT_EMPTY]: 'string',
16
+ [Op.IS_EMPTY]: null,
17
+ [Op.IS_NOT_EMPTY]: null,
18
18
  },
19
19
  number: {
20
20
  [Op.EQ]: 'number',
@@ -25,8 +25,6 @@ export const rules: IRules = {
25
25
  [Op.LTE]: 'number',
26
26
  [Op.IN]: 'array',
27
27
  [Op.NIN]: 'array',
28
- [Op.IS_EMPTY]: null,
29
- [Op.IS_NOT_EMPTY]: null,
30
28
  },
31
29
  integer: {
32
30
  [Op.EQ]: 'number',
@@ -37,8 +35,6 @@ export const rules: IRules = {
37
35
  [Op.LTE]: 'number',
38
36
  [Op.IN]: 'array',
39
37
  [Op.NIN]: 'array',
40
- [Op.IS_EMPTY]: null,
41
- [Op.IS_NOT_EMPTY]: null,
42
38
  },
43
39
  boolean: {
44
40
  [Op.EQ]: 'boolean',
@@ -47,8 +43,6 @@ export const rules: IRules = {
47
43
  [Op.IS_FALSE]: null,
48
44
  [Op.IN]: 'array',
49
45
  [Op.NIN]: 'array',
50
- [Op.IS_EMPTY]: null,
51
- [Op.IS_NOT_EMPTY]: null,
52
46
  },
53
47
  object: {
54
48
  [Op.IS_EMPTY]: null,
@@ -57,6 +51,10 @@ export const rules: IRules = {
57
51
  array: {
58
52
  [Op.IS_EMPTY]: null,
59
53
  [Op.IS_NOT_EMPTY]: null,
54
+ [Op.CONTAINS]: 'array',
55
+ [Op.NOT_CONTAINS]: 'array',
56
+ [Op.EQ]: 'array',
57
+ [Op.NEQ]: 'array',
60
58
  },
61
59
  map: {
62
60
  [Op.IS_EMPTY]: null,
@@ -15,9 +15,10 @@ interface HookParams {
15
15
  rule?: IRule;
16
16
  op?: Op;
17
17
  onChange: (op: Op) => void;
18
+ readonly?: boolean;
18
19
  }
19
20
 
20
- export function useOp({ rule, op, onChange }: HookParams) {
21
+ export function useOp({ rule, op, onChange, readonly }: HookParams) {
21
22
  const options = useMemo(
22
23
  () =>
23
24
  Object.keys(rule || {}).map((_op) => ({
@@ -32,6 +33,7 @@ export function useOp({ rule, op, onChange }: HookParams) {
32
33
  const renderOpSelect = () => (
33
34
  <Select
34
35
  style={{ height: 22 }}
36
+ disabled={readonly}
35
37
  size="small"
36
38
  value={op}
37
39
  optionList={options}
@@ -5,11 +5,11 @@
5
5
 
6
6
  import { useMemo } from 'react';
7
7
 
8
+ import { JsonSchemaUtils, JsonSchemaBasicType } from '@flowgram.ai/json-schema';
8
9
  import { useScopeAvailable } from '@flowgram.ai/editor';
9
10
 
10
11
  import { rules } from '../constants';
11
- import { JsonSchemaUtils } from '../../../utils';
12
- import { IFlowRefValue, JsonSchemaBasicType } from '../../../typings';
12
+ import { IFlowRefValue } from '../../../typings';
13
13
 
14
14
  export function useRule(left?: IFlowRefValue) {
15
15
  const available = useScopeAvailable();
@@ -5,6 +5,7 @@
5
5
 
6
6
  import React, { useMemo } from 'react';
7
7
 
8
+ import { JsonSchemaBasicType } from '@flowgram.ai/json-schema';
8
9
  import { Input } from '@douyinfe/semi-ui';
9
10
 
10
11
  import { ConditionRowValueType, Op } from './types';
@@ -13,7 +14,6 @@ import { useRule } from './hooks/useRule';
13
14
  import { useOp } from './hooks/useOp';
14
15
  import { VariableSelector } from '../variable-selector';
15
16
  import { DynamicValueInput } from '../dynamic-value-input';
16
- import { JsonSchemaBasicType } from '../../typings';
17
17
 
18
18
  interface PropTypes {
19
19
  value?: ConditionRowValueType;
@@ -29,6 +29,7 @@ export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
29
29
  rule,
30
30
  op: operator,
31
31
  onChange: (v) => onChange({ ...value, operator: v }),
32
+ readonly,
32
33
  });
33
34
 
34
35
  const targetSchema = useMemo(() => {
@@ -3,7 +3,9 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import { IFlowConstantRefValue, IFlowRefValue, JsonSchemaBasicType } from '../../typings';
6
+ import { JsonSchemaBasicType } from '@flowgram.ai/json-schema';
7
+
8
+ import { IFlowConstantRefValue, IFlowRefValue } from '../../typings';
7
9
 
8
10
  export enum Op {
9
11
  EQ = 'eq',
@@ -1,6 +1,9 @@
1
-
2
1
  {
3
2
  "name": "constant-input",
4
- "depMaterials": ["typings/json-schema"],
5
- "depPackages": ["@douyinfe/semi-ui"]
3
+ "depMaterials": [
4
+ "plugins/json-schema-preset"
5
+ ],
6
+ "depPackages": [
7
+ "@douyinfe/semi-ui"
8
+ ]
6
9
  }