@flowgram.ai/form-materials 0.4.12 → 0.4.14

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 (149) hide show
  1. package/dist/cjs/components/code-editor/editor.js +54 -77
  2. package/dist/cjs/components/code-editor/index.js +10 -2
  3. package/dist/cjs/components/code-editor/language-features.js +119 -16
  4. package/dist/cjs/components/code-editor/theme/dark.js +120 -50
  5. package/dist/cjs/components/code-editor/theme/light.js +110 -61
  6. package/dist/cjs/components/condition-context/context.js +59 -0
  7. package/dist/cjs/components/condition-context/hooks/use-condition.js +97 -0
  8. package/dist/cjs/components/condition-context/index.js +47 -0
  9. package/dist/cjs/components/condition-context/op.js +117 -0
  10. package/dist/cjs/components/condition-row/index.js +43 -26
  11. package/dist/cjs/components/condition-row/types.js +1 -35
  12. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +4 -3
  13. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tree.js +3 -0
  14. package/dist/cjs/components/db-condition-row/index.js +59 -34
  15. package/dist/cjs/components/variable-selector/index.js +0 -1
  16. package/dist/cjs/form-plugins/batch-outputs-plugin/index.js +8 -1
  17. package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +30 -3
  18. package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +1 -0
  19. package/dist/cjs/plugins/json-schema-preset/react.js +1 -0
  20. package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +30 -1
  21. package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +23 -0
  22. package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +31 -2
  23. package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +9 -1
  24. package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +34 -1
  25. package/dist/cjs/{components/code-editor/init-worker.js → plugins/json-schema-preset/type-definition/map.js} +21 -23
  26. package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +34 -1
  27. package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +6 -1
  28. package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +30 -1
  29. package/dist/cjs/plugins/json-schema-preset/types.js +18 -0
  30. package/dist/cjs/shared/flow-value/utils.js +22 -8
  31. package/dist/esm/components/code-editor/editor.mjs +4 -9
  32. package/dist/esm/components/code-editor/index.mjs +5 -2
  33. package/dist/esm/components/code-editor/language-features.mjs +49 -13
  34. package/dist/esm/components/code-editor/theme/dark.mjs +117 -50
  35. package/dist/esm/components/code-editor/theme/light.mjs +108 -62
  36. package/dist/esm/components/condition-context/context.mjs +19 -0
  37. package/dist/esm/components/condition-context/hooks/use-condition.mjs +63 -0
  38. package/dist/esm/components/condition-context/index.mjs +4 -0
  39. package/dist/esm/components/condition-context/op.mjs +80 -0
  40. package/dist/esm/components/condition-row/index.mjs +45 -28
  41. package/dist/esm/components/condition-row/types.mjs +0 -18
  42. package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +4 -3
  43. package/dist/esm/components/coze-editor-extensions/extensions/variable-tree.mjs +3 -0
  44. package/dist/esm/components/db-condition-row/index.mjs +59 -34
  45. package/dist/esm/components/variable-selector/index.mjs +0 -1
  46. package/dist/esm/form-plugins/batch-outputs-plugin/index.mjs +8 -1
  47. package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +31 -4
  48. package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +2 -1
  49. package/dist/esm/plugins/json-schema-preset/react.mjs +2 -1
  50. package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +30 -1
  51. package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +23 -0
  52. package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +31 -2
  53. package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +7 -2
  54. package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +34 -1
  55. package/dist/esm/plugins/json-schema-preset/type-definition/map.mjs +20 -0
  56. package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +34 -1
  57. package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +6 -1
  58. package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +30 -1
  59. package/dist/esm/plugins/json-schema-preset/types.mjs +0 -0
  60. package/dist/esm/shared/flow-value/utils.mjs +22 -8
  61. package/dist/tsconfig.tsbuildinfo +1 -1
  62. package/dist/types/components/code-editor/editor.d.ts +0 -2
  63. package/dist/types/components/code-editor/language-features.d.ts +4 -1
  64. package/dist/types/components/code-editor/theme/dark.d.ts +29 -0
  65. package/dist/types/components/code-editor/theme/light.d.ts +24 -0
  66. package/dist/types/components/condition-context/context.d.ts +14 -0
  67. package/dist/types/components/condition-context/hooks/use-condition.d.ts +29 -0
  68. package/dist/types/components/condition-context/index.d.ts +8 -0
  69. package/dist/types/components/condition-context/op.d.ts +22 -0
  70. package/dist/types/components/condition-context/types.d.ts +14 -0
  71. package/dist/types/components/condition-row/index.d.ts +4 -7
  72. package/dist/types/components/condition-row/types.d.ts +0 -24
  73. package/dist/types/components/db-condition-row/index.d.ts +4 -3
  74. package/dist/types/components/db-condition-row/types.d.ts +0 -8
  75. package/dist/types/form-plugins/batch-outputs-plugin/index.d.ts +4 -0
  76. package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +4 -0
  77. package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +1 -1
  78. package/dist/types/plugins/json-schema-preset/index.d.ts +1 -1
  79. package/dist/types/plugins/json-schema-preset/react.d.ts +1 -1
  80. package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +1 -1
  81. package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +1 -1
  82. package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +1 -1
  83. package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +3 -1
  84. package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +1 -1
  85. package/dist/types/plugins/json-schema-preset/type-definition/map.d.ts +6 -0
  86. package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +1 -1
  87. package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +1 -1
  88. package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +1 -1
  89. package/dist/types/plugins/json-schema-preset/{manager.d.ts → types.d.ts} +5 -0
  90. package/dist/types/shared/flow-value/utils.d.ts +3 -1
  91. package/package.json +9 -8
  92. package/src/components/code-editor/editor.tsx +7 -10
  93. package/src/components/code-editor/index.tsx +3 -1
  94. package/src/components/code-editor/language-features.ts +52 -14
  95. package/src/components/code-editor/theme/dark.ts +62 -77
  96. package/src/components/code-editor/theme/light.ts +60 -91
  97. package/src/components/condition-context/context.tsx +28 -0
  98. package/src/components/condition-context/hooks/use-condition.tsx +99 -0
  99. package/src/components/condition-context/index.tsx +14 -0
  100. package/src/components/condition-context/op.ts +86 -0
  101. package/src/components/condition-context/types.ts +22 -0
  102. package/src/components/condition-row/index.tsx +44 -22
  103. package/src/components/condition-row/types.ts +0 -30
  104. package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +6 -3
  105. package/src/components/coze-editor-extensions/extensions/variable-tree.tsx +3 -0
  106. package/src/components/db-condition-row/index.tsx +76 -24
  107. package/src/components/db-condition-row/types.ts +0 -13
  108. package/src/components/variable-selector/index.tsx +0 -2
  109. package/src/form-plugins/batch-outputs-plugin/index.ts +63 -44
  110. package/src/form-plugins/infer-inputs-plugin/index.ts +62 -14
  111. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +4 -2
  112. package/src/plugins/json-schema-preset/index.tsx +1 -1
  113. package/src/plugins/json-schema-preset/react.tsx +5 -2
  114. package/src/plugins/json-schema-preset/type-definition/array.tsx +10 -1
  115. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +17 -1
  116. package/src/plugins/json-schema-preset/type-definition/date-time.tsx +21 -2
  117. package/src/plugins/json-schema-preset/type-definition/index.tsx +10 -1
  118. package/src/plugins/json-schema-preset/type-definition/integer.tsx +19 -1
  119. package/src/plugins/json-schema-preset/type-definition/map.tsx +31 -0
  120. package/src/plugins/json-schema-preset/type-definition/number.tsx +19 -1
  121. package/src/plugins/json-schema-preset/type-definition/object.tsx +6 -1
  122. package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -1
  123. package/src/plugins/json-schema-preset/{manager.ts → types.ts} +7 -0
  124. package/src/shared/flow-value/utils.ts +22 -9
  125. package/dist/cjs/components/condition-row/constants.js +0 -165
  126. package/dist/cjs/components/condition-row/hooks/useOp.js +0 -78
  127. package/dist/cjs/components/condition-row/hooks/useRule.js +0 -68
  128. package/dist/cjs/components/db-condition-row/hooks/use-left.js +0 -86
  129. package/dist/cjs/components/db-condition-row/hooks/use-op.js +0 -79
  130. package/dist/esm/components/code-editor/init-worker.mjs +0 -19
  131. package/dist/esm/components/condition-row/constants.mjs +0 -128
  132. package/dist/esm/components/condition-row/hooks/useOp.mjs +0 -44
  133. package/dist/esm/components/condition-row/hooks/useRule.mjs +0 -34
  134. package/dist/esm/components/db-condition-row/hooks/use-left.mjs +0 -52
  135. package/dist/esm/components/db-condition-row/hooks/use-op.mjs +0 -45
  136. package/dist/types/components/code-editor/init-worker.d.ts +0 -5
  137. package/dist/types/components/condition-row/constants.d.ts +0 -7
  138. package/dist/types/components/condition-row/hooks/useOp.d.ts +0 -18
  139. package/dist/types/components/condition-row/hooks/useRule.d.ts +0 -9
  140. package/dist/types/components/db-condition-row/hooks/use-left.d.ts +0 -18
  141. package/dist/types/components/db-condition-row/hooks/use-op.d.ts +0 -18
  142. package/src/components/code-editor/init-worker.ts +0 -27
  143. package/src/components/condition-row/constants.ts +0 -134
  144. package/src/components/condition-row/hooks/useOp.tsx +0 -56
  145. package/src/components/condition-row/hooks/useRule.ts +0 -35
  146. package/src/components/db-condition-row/hooks/use-left.tsx +0 -66
  147. package/src/components/db-condition-row/hooks/use-op.tsx +0 -59
  148. /package/dist/cjs/{plugins/json-schema-preset/manager.js → components/condition-context/types.js} +0 -0
  149. /package/dist/esm/{plugins/json-schema-preset/manager.mjs → components/condition-context/types.mjs} +0 -0
@@ -1,134 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { IRules, Op, OpConfigs } from './types';
7
-
8
- export const defaultRules: IRules = {
9
- string: {
10
- [Op.EQ]: 'string',
11
- [Op.NEQ]: 'string',
12
- [Op.CONTAINS]: 'string',
13
- [Op.NOT_CONTAINS]: 'string',
14
- [Op.IN]: 'array',
15
- [Op.NIN]: 'array',
16
- [Op.IS_EMPTY]: null,
17
- [Op.IS_NOT_EMPTY]: null,
18
- },
19
- number: {
20
- [Op.EQ]: 'number',
21
- [Op.NEQ]: 'number',
22
- [Op.GT]: 'number',
23
- [Op.GTE]: 'number',
24
- [Op.LT]: 'number',
25
- [Op.LTE]: 'number',
26
- [Op.IN]: 'array',
27
- [Op.NIN]: 'array',
28
- },
29
- integer: {
30
- [Op.EQ]: 'number',
31
- [Op.NEQ]: 'number',
32
- [Op.GT]: 'number',
33
- [Op.GTE]: 'number',
34
- [Op.LT]: 'number',
35
- [Op.LTE]: 'number',
36
- [Op.IN]: 'array',
37
- [Op.NIN]: 'array',
38
- },
39
- boolean: {
40
- [Op.EQ]: 'boolean',
41
- [Op.NEQ]: 'boolean',
42
- [Op.IS_TRUE]: null,
43
- [Op.IS_FALSE]: null,
44
- [Op.IN]: 'array',
45
- [Op.NIN]: 'array',
46
- },
47
- object: {
48
- [Op.IS_EMPTY]: null,
49
- [Op.IS_NOT_EMPTY]: null,
50
- },
51
- array: {
52
- [Op.IS_EMPTY]: null,
53
- [Op.IS_NOT_EMPTY]: null,
54
- [Op.CONTAINS]: 'array',
55
- [Op.NOT_CONTAINS]: 'array',
56
- [Op.EQ]: 'array',
57
- [Op.NEQ]: 'array',
58
- },
59
- map: {
60
- [Op.IS_EMPTY]: null,
61
- [Op.IS_NOT_EMPTY]: null,
62
- },
63
- ['date-time']: {
64
- [Op.EQ]: 'date-time',
65
- [Op.NEQ]: 'date-time',
66
- [Op.GT]: 'date-time',
67
- [Op.GTE]: 'date-time',
68
- [Op.LT]: 'date-time',
69
- [Op.LTE]: 'date-time',
70
- },
71
- };
72
-
73
- export const defaultOpConfigs: OpConfigs = {
74
- [Op.EQ]: {
75
- label: 'Equal',
76
- abbreviation: '=',
77
- },
78
- [Op.NEQ]: {
79
- label: 'Not Equal',
80
- abbreviation: '≠',
81
- },
82
- [Op.GT]: {
83
- label: 'Greater Than',
84
- abbreviation: '>',
85
- },
86
- [Op.GTE]: {
87
- label: 'Greater Than or Equal',
88
- abbreviation: '>=',
89
- },
90
- [Op.LT]: {
91
- label: 'Less Than',
92
- abbreviation: '<',
93
- },
94
- [Op.LTE]: {
95
- label: 'Less Than or Equal',
96
- abbreviation: '<=',
97
- },
98
- [Op.IN]: {
99
- label: 'In',
100
- abbreviation: '∈',
101
- },
102
- [Op.NIN]: {
103
- label: 'Not In',
104
- abbreviation: '∉',
105
- },
106
- [Op.CONTAINS]: {
107
- label: 'Contains',
108
- abbreviation: '⊇',
109
- },
110
- [Op.NOT_CONTAINS]: {
111
- label: 'Not Contains',
112
- abbreviation: '⊉',
113
- },
114
- [Op.IS_EMPTY]: {
115
- label: 'Is Empty',
116
- abbreviation: '=',
117
- rightDisplay: 'Empty',
118
- },
119
- [Op.IS_NOT_EMPTY]: {
120
- label: 'Is Not Empty',
121
- abbreviation: '≠',
122
- rightDisplay: 'Empty',
123
- },
124
- [Op.IS_TRUE]: {
125
- label: 'Is True',
126
- abbreviation: '=',
127
- rightDisplay: 'True',
128
- },
129
- [Op.IS_FALSE]: {
130
- label: 'Is False',
131
- abbreviation: '=',
132
- rightDisplay: 'False',
133
- },
134
- };
@@ -1,56 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import React, { useMemo } from 'react';
7
-
8
- import { I18n } from '@flowgram.ai/editor';
9
- import { Button, Select } from '@douyinfe/semi-ui';
10
- import { IconChevronDownStroked } from '@douyinfe/semi-icons';
11
-
12
- import { IRule, OpConfigs } from '../types';
13
- import { defaultOpConfigs } from '../constants';
14
-
15
- interface HookParams {
16
- rule?: IRule;
17
- op?: string;
18
- onChange: (op: string) => void;
19
- readonly?: boolean;
20
- userOps?: OpConfigs;
21
- }
22
-
23
- export function useOp({ rule, op, onChange, readonly, userOps }: HookParams) {
24
- const options = useMemo(
25
- () =>
26
- Object.keys(rule || {}).map((_op) => ({
27
- ...(defaultOpConfigs[_op] || {}),
28
- ...(userOps?.[_op] || {}),
29
- value: _op,
30
- label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label),
31
- })),
32
- [rule, userOps]
33
- );
34
-
35
- const opConfig = useMemo(() => defaultOpConfigs[op as string], [op]);
36
-
37
- const renderOpSelect = () => (
38
- <Select
39
- style={{ height: 22 }}
40
- disabled={readonly}
41
- size="small"
42
- value={op}
43
- optionList={options}
44
- onChange={(v) => {
45
- onChange(v as string);
46
- }}
47
- triggerRender={({ value }) => (
48
- <Button size="small" disabled={!rule}>
49
- {opConfig?.abbreviation || <IconChevronDownStroked size="small" />}
50
- </Button>
51
- )}
52
- />
53
- );
54
-
55
- return { renderOpSelect, opConfig };
56
- }
@@ -1,35 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { useMemo } from 'react';
7
-
8
- import { JsonSchemaUtils, JsonSchemaBasicType } from '@flowgram.ai/json-schema';
9
- import { useScopeAvailable } from '@flowgram.ai/editor';
10
-
11
- import { IFlowRefValue } from '@/shared';
12
-
13
- import { IRules } from '../types';
14
- import { defaultRules } from '../constants';
15
-
16
- export function useRule(left?: IFlowRefValue, userRules?: IRules) {
17
- const available = useScopeAvailable();
18
-
19
- const rules = useMemo(() => ({ ...defaultRules, ...(userRules || {}) }), [userRules]);
20
-
21
- const variable = useMemo(() => {
22
- if (!left) return undefined;
23
- return available.getByKeyPath(left.content);
24
- }, [available, left]);
25
-
26
- const rule = useMemo(() => {
27
- if (!variable) return undefined;
28
-
29
- const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
30
-
31
- return rules[schema?.type as JsonSchemaBasicType];
32
- }, [variable?.type, rules]);
33
-
34
- return { rule };
35
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { useMemo } from 'react';
7
- import React from 'react';
8
-
9
- import { JsonSchemaTypeManager, useTypeManager } from '@flowgram.ai/json-schema';
10
- import { Icon } from '@douyinfe/semi-ui';
11
-
12
- import { ConditionRow } from '@/components';
13
-
14
- import { DBConditionOptionType, IRules } from '../types';
15
- import { UIOptionLabel, UISelect } from '../styles';
16
-
17
- const defaultRules = ConditionRow.defaultRules;
18
-
19
- interface HookParams {
20
- left?: string;
21
- options?: DBConditionOptionType[];
22
- userRules?: IRules;
23
- readonly?: boolean;
24
- onChange: (leftKey: string) => void;
25
- }
26
-
27
- export function useLeft({ left, options, userRules, readonly, onChange }: HookParams) {
28
- const rules = useMemo(() => ({ ...defaultRules, ...(userRules || {}) }), [userRules]);
29
-
30
- const typeManager = useTypeManager() as JsonSchemaTypeManager;
31
-
32
- const rule = useMemo(() => {
33
- if (!left) return undefined;
34
-
35
- const option = options?.find((item) => item.value === left);
36
-
37
- if (!option?.schema?.type) {
38
- return undefined;
39
- }
40
-
41
- return rules[option.schema.type];
42
- }, [left, options, rules]);
43
-
44
- const renderDBOptionSelect = () => (
45
- <UISelect
46
- disabled={readonly}
47
- size="small"
48
- style={{ width: '100%' }}
49
- value={left}
50
- onChange={(v) => onChange(v as string)}
51
- optionList={
52
- options?.map((item) => ({
53
- label: (
54
- <UIOptionLabel>
55
- <Icon size="small" svg={typeManager.getDisplayIcon(item.schema)} />
56
- {item.label}
57
- </UIOptionLabel>
58
- ),
59
- value: item.value,
60
- })) || []
61
- }
62
- />
63
- );
64
-
65
- return { rule, renderDBOptionSelect };
66
- }
@@ -1,59 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import React, { useMemo } from 'react';
7
-
8
- import { I18n } from '@flowgram.ai/editor';
9
- import { Button, Select } from '@douyinfe/semi-ui';
10
- import { IconChevronDownStroked } from '@douyinfe/semi-icons';
11
-
12
- import { ConditionRow } from '@/components';
13
-
14
- import { IRule, OpConfigs } from '../types';
15
-
16
- const defaultOpConfigs = ConditionRow.defaultOpConfigs;
17
-
18
- interface HookParams {
19
- rule?: IRule;
20
- op?: string;
21
- onChange: (op: string) => void;
22
- readonly?: boolean;
23
- userOps?: OpConfigs;
24
- }
25
-
26
- export function useOp({ rule, op, onChange, readonly, userOps }: HookParams) {
27
- const options = useMemo(
28
- () =>
29
- Object.keys(rule || {}).map((_op) => ({
30
- ...(defaultOpConfigs[_op] || {}),
31
- ...(userOps?.[_op] || {}),
32
- value: _op,
33
- label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label),
34
- })),
35
- [rule, userOps]
36
- );
37
-
38
- const opConfig = useMemo(() => defaultOpConfigs[op as string], [op]);
39
-
40
- const renderOpSelect = () => (
41
- <Select
42
- style={{ height: 22 }}
43
- disabled={readonly}
44
- size="small"
45
- value={op}
46
- optionList={options}
47
- onChange={(v) => {
48
- onChange(v as string);
49
- }}
50
- triggerRender={({ value }) => (
51
- <Button size="small" disabled={!rule}>
52
- {opConfig?.abbreviation || <IconChevronDownStroked size="small" />}
53
- </Button>
54
- )}
55
- />
56
- );
57
-
58
- return { renderOpSelect, opConfig };
59
- }