@flowgram.ai/form-materials 0.1.0-alpha.17 → 0.1.0-alpha.19

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 (227) hide show
  1. package/dist/cjs/components/batch-outputs/index.js +5 -3
  2. package/dist/cjs/components/batch-outputs/styles.css +13 -0
  3. package/dist/cjs/components/blur-input/index.js +1 -0
  4. package/dist/cjs/components/code-editor/editor.js +16 -12
  5. package/dist/cjs/components/code-editor/styles.css +4 -0
  6. package/dist/cjs/components/code-editor/theme/dark.js +1 -1
  7. package/dist/cjs/components/code-editor/theme/light.js +1 -1
  8. package/dist/cjs/components/code-editor-mini/index.js +2 -16
  9. package/dist/cjs/components/condition-context/hooks/use-condition.js +17 -1
  10. package/dist/cjs/components/condition-row/index.js +26 -12
  11. package/dist/cjs/components/condition-row/styles.css +19 -0
  12. package/dist/cjs/components/coze-editor-extensions/extensions/inputs-tree.js +2 -2
  13. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +31 -11
  14. package/dist/{esm/components/coze-editor-extensions/styles.mjs → cjs/components/coze-editor-extensions/styles.css} +19 -18
  15. package/dist/cjs/components/db-condition-row/index.js +29 -14
  16. package/dist/cjs/components/db-condition-row/styles.css +30 -0
  17. package/dist/cjs/components/display-inputs-values/index.js +3 -2
  18. package/dist/cjs/components/display-inputs-values/styles.css +6 -0
  19. package/dist/cjs/components/display-outputs/index.js +5 -4
  20. package/dist/cjs/components/display-outputs/styles.css +6 -0
  21. package/dist/cjs/components/display-schema-tag/index.js +7 -4
  22. package/dist/cjs/components/display-schema-tag/styles.css +21 -0
  23. package/dist/cjs/components/display-schema-tree/index.js +12 -7
  24. package/dist/cjs/components/display-schema-tree/styles.css +64 -0
  25. package/dist/cjs/components/dynamic-value-input/index.js +9 -5
  26. package/dist/{esm/components/dynamic-value-input/styles.mjs → cjs/components/dynamic-value-input/styles.css} +24 -30
  27. package/dist/cjs/components/inputs-values/index.js +5 -3
  28. package/dist/cjs/components/inputs-values/styles.css +13 -0
  29. package/dist/cjs/components/inputs-values-tree/icon.js +70 -0
  30. package/dist/cjs/components/inputs-values-tree/index.js +4 -3
  31. package/dist/cjs/components/inputs-values-tree/row.js +19 -15
  32. package/dist/cjs/components/inputs-values-tree/styles.css +85 -0
  33. package/dist/cjs/components/json-schema-editor/default-value.js +2 -2
  34. package/dist/cjs/components/json-schema-editor/hooks.js +55 -48
  35. package/dist/cjs/components/json-schema-editor/icon.js +70 -0
  36. package/dist/cjs/components/json-schema-editor/index.js +37 -25
  37. package/dist/cjs/components/json-schema-editor/styles.css +113 -0
  38. package/dist/cjs/components/prompt-editor/editor.js +16 -6
  39. package/dist/cjs/components/prompt-editor/styles.css +10 -0
  40. package/dist/cjs/components/prompt-editor-with-inputs/index.js +16 -26
  41. package/dist/cjs/components/prompt-editor-with-variables/index.js +17 -26
  42. package/dist/cjs/components/variable-selector/context.js +7 -3
  43. package/dist/cjs/components/variable-selector/index.js +16 -10
  44. package/dist/{esm/components/variable-selector/styles.mjs → cjs/components/variable-selector/styles.css} +37 -29
  45. package/dist/cjs/components/variable-selector/use-variable-tree.js +3 -1
  46. package/dist/cjs/shared/inject-material/index.js +1 -1
  47. package/dist/esm/components/batch-outputs/index.mjs +5 -3
  48. package/dist/esm/components/batch-outputs/styles.css +13 -0
  49. package/dist/esm/components/blur-input/index.mjs +1 -0
  50. package/dist/esm/components/code-editor/editor.mjs +16 -11
  51. package/dist/esm/components/code-editor/styles.css +4 -0
  52. package/dist/esm/components/code-editor/theme/dark.mjs +1 -1
  53. package/dist/esm/components/code-editor/theme/light.mjs +1 -1
  54. package/dist/esm/components/code-editor-mini/index.mjs +2 -6
  55. package/dist/esm/components/condition-context/hooks/use-condition.mjs +18 -2
  56. package/dist/esm/components/condition-row/index.mjs +26 -12
  57. package/dist/esm/components/condition-row/styles.css +19 -0
  58. package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +3 -3
  59. package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +32 -12
  60. package/dist/esm/components/coze-editor-extensions/styles.css +37 -0
  61. package/dist/esm/components/db-condition-row/index.mjs +29 -14
  62. package/dist/esm/components/db-condition-row/styles.css +30 -0
  63. package/dist/esm/components/display-inputs-values/index.mjs +3 -2
  64. package/dist/esm/components/display-inputs-values/styles.css +6 -0
  65. package/dist/esm/components/display-outputs/index.mjs +5 -4
  66. package/dist/esm/components/display-outputs/styles.css +6 -0
  67. package/dist/esm/components/display-schema-tag/index.mjs +8 -5
  68. package/dist/esm/components/display-schema-tag/styles.css +21 -0
  69. package/dist/esm/components/display-schema-tree/index.mjs +12 -7
  70. package/dist/esm/components/display-schema-tree/styles.css +64 -0
  71. package/dist/esm/components/dynamic-value-input/index.mjs +9 -5
  72. package/dist/esm/components/dynamic-value-input/styles.css +48 -0
  73. package/dist/esm/components/inputs-values/index.mjs +5 -3
  74. package/dist/esm/components/inputs-values/styles.css +13 -0
  75. package/dist/esm/components/inputs-values-tree/icon.mjs +26 -0
  76. package/dist/esm/components/inputs-values-tree/index.mjs +4 -3
  77. package/dist/esm/components/inputs-values-tree/row.mjs +18 -14
  78. package/dist/esm/components/inputs-values-tree/styles.css +85 -0
  79. package/dist/esm/components/json-schema-editor/default-value.mjs +2 -2
  80. package/dist/esm/components/json-schema-editor/hooks.mjs +55 -48
  81. package/dist/esm/components/json-schema-editor/icon.mjs +26 -0
  82. package/dist/esm/components/json-schema-editor/index.mjs +36 -24
  83. package/dist/esm/components/json-schema-editor/styles.css +113 -0
  84. package/dist/esm/components/prompt-editor/editor.mjs +16 -6
  85. package/dist/esm/components/prompt-editor/styles.css +10 -0
  86. package/dist/esm/components/prompt-editor-with-inputs/index.mjs +12 -4
  87. package/dist/esm/components/prompt-editor-with-variables/index.mjs +13 -4
  88. package/dist/esm/components/variable-selector/context.mjs +7 -3
  89. package/dist/esm/components/variable-selector/index.mjs +17 -11
  90. package/{src/components/variable-selector/styles.tsx → dist/esm/components/variable-selector/styles.css} +35 -38
  91. package/dist/esm/components/variable-selector/use-variable-tree.mjs +3 -1
  92. package/dist/esm/shared/inject-material/index.mjs +1 -1
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/dist/types/components/batch-outputs/index.d.ts +1 -0
  95. package/dist/types/components/blur-input/index.d.ts +1 -1
  96. package/dist/types/components/code-editor/editor.d.ts +1 -0
  97. package/dist/types/components/condition-context/hooks/use-condition.d.ts +16 -1
  98. package/dist/types/components/condition-row/index.d.ts +5 -1
  99. package/dist/types/components/coze-editor-extensions/extensions/inputs-tree.d.ts +3 -3
  100. package/dist/types/components/coze-editor-extensions/extensions/variable-tag.d.ts +1 -0
  101. package/dist/types/components/coze-editor-extensions/index.d.ts +1 -1
  102. package/dist/types/components/db-condition-row/index.d.ts +4 -0
  103. package/dist/types/components/db-condition-row/types.d.ts +0 -1
  104. package/dist/types/components/display-inputs-values/index.d.ts +3 -1
  105. package/dist/types/components/display-outputs/index.d.ts +1 -0
  106. package/dist/types/components/display-schema-tag/index.d.ts +1 -0
  107. package/dist/types/components/display-schema-tree/index.d.ts +1 -0
  108. package/dist/types/components/dynamic-value-input/index.d.ts +1 -0
  109. package/dist/types/components/inputs-values/index.d.ts +1 -0
  110. package/dist/types/components/inputs-values-tree/icon.d.ts +6 -0
  111. package/dist/types/components/inputs-values-tree/index.d.ts +1 -0
  112. package/dist/types/components/inputs-values-tree/row.d.ts +1 -0
  113. package/dist/types/components/inputs-values-tree/types.d.ts +3 -2
  114. package/dist/types/components/json-schema-editor/icon.d.ts +6 -0
  115. package/dist/types/components/json-schema-editor/index.d.ts +1 -0
  116. package/dist/types/components/prompt-editor/editor.d.ts +1 -0
  117. package/dist/types/components/prompt-editor-with-inputs/index.d.ts +7 -2
  118. package/dist/types/components/prompt-editor-with-variables/index.d.ts +5 -2
  119. package/dist/types/components/variable-selector/context.d.ts +16 -3
  120. package/dist/types/components/variable-selector/index.d.ts +1 -0
  121. package/dist/types/index.d.ts +1 -1
  122. package/dist/types/shared/flow-value/index.d.ts +1 -1
  123. package/dist/types/shared/flow-value/types.d.ts +3 -0
  124. package/dist/types/shared/index.d.ts +1 -1
  125. package/package.json +7 -10
  126. package/src/components/batch-outputs/index.tsx +5 -5
  127. package/src/components/batch-outputs/{styles.tsx → styles.css} +4 -6
  128. package/src/components/blur-input/index.tsx +2 -1
  129. package/src/components/code-editor/editor.tsx +19 -14
  130. package/src/components/code-editor/styles.css +11 -0
  131. package/src/components/code-editor/theme/dark.ts +1 -1
  132. package/src/components/code-editor/theme/light.ts +1 -1
  133. package/src/components/code-editor-mini/index.tsx +2 -9
  134. package/src/components/condition-context/hooks/use-condition.tsx +51 -7
  135. package/src/components/condition-row/index.tsx +27 -22
  136. package/src/components/condition-row/{styles.tsx → styles.css} +11 -11
  137. package/src/components/coze-editor-extensions/extensions/inputs-tree.tsx +7 -6
  138. package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +19 -14
  139. package/src/components/coze-editor-extensions/{styles.tsx → styles.css} +8 -11
  140. package/src/components/db-condition-row/index.tsx +29 -26
  141. package/src/components/db-condition-row/{styles.tsx → styles.css} +14 -16
  142. package/src/components/db-condition-row/types.ts +0 -1
  143. package/src/components/display-inputs-values/index.tsx +5 -4
  144. package/src/components/display-inputs-values/{styles.ts → styles.css} +2 -4
  145. package/src/components/display-outputs/index.tsx +5 -5
  146. package/src/components/display-outputs/{styles.ts → styles.css} +2 -4
  147. package/src/components/display-schema-tag/index.tsx +7 -7
  148. package/src/components/display-schema-tag/{styles.ts → styles.css} +7 -10
  149. package/src/components/display-schema-tree/index.tsx +10 -10
  150. package/src/components/display-schema-tree/{styles.tsx → styles.css} +18 -24
  151. package/src/components/dynamic-value-input/index.tsx +6 -6
  152. package/src/components/dynamic-value-input/{styles.tsx → styles.css} +9 -12
  153. package/src/components/inputs-values/index.tsx +5 -5
  154. package/src/components/inputs-values/{styles.tsx → styles.css} +4 -6
  155. package/src/components/inputs-values-tree/icon.tsx +28 -0
  156. package/src/components/inputs-values-tree/index.tsx +8 -6
  157. package/src/components/inputs-values-tree/row.tsx +25 -27
  158. package/src/components/inputs-values-tree/styles.css +94 -0
  159. package/src/components/inputs-values-tree/types.ts +3 -2
  160. package/src/components/json-schema-editor/default-value.tsx +2 -4
  161. package/src/components/json-schema-editor/hooks.tsx +60 -53
  162. package/src/components/json-schema-editor/icon.tsx +28 -0
  163. package/src/components/json-schema-editor/index.tsx +45 -50
  164. package/src/components/json-schema-editor/styles.css +135 -0
  165. package/src/components/prompt-editor/editor.tsx +18 -7
  166. package/src/components/prompt-editor/styles.css +14 -0
  167. package/src/components/prompt-editor-with-inputs/index.tsx +18 -5
  168. package/src/components/prompt-editor-with-variables/index.tsx +13 -5
  169. package/src/components/variable-selector/context.tsx +22 -2
  170. package/src/components/variable-selector/index.tsx +24 -14
  171. package/src/components/variable-selector/styles.css +70 -0
  172. package/src/components/variable-selector/use-variable-tree.tsx +9 -1
  173. package/src/index.ts +1 -0
  174. package/src/shared/flow-value/index.ts +1 -0
  175. package/src/shared/flow-value/types.ts +4 -0
  176. package/src/shared/index.ts +1 -0
  177. package/src/shared/inject-material/index.tsx +1 -1
  178. package/dist/cjs/components/batch-outputs/styles.js +0 -60
  179. package/dist/cjs/components/condition-row/styles.js +0 -77
  180. package/dist/cjs/components/coze-editor-extensions/styles.js +0 -89
  181. package/dist/cjs/components/db-condition-row/styles.js +0 -94
  182. package/dist/cjs/components/display-inputs-values/styles.js +0 -51
  183. package/dist/cjs/components/display-outputs/styles.js +0 -51
  184. package/dist/cjs/components/display-schema-tag/styles.js +0 -71
  185. package/dist/cjs/components/display-schema-tree/styles.js +0 -135
  186. package/dist/cjs/components/dynamic-value-input/styles.js +0 -107
  187. package/dist/cjs/components/inputs-values/styles.js +0 -60
  188. package/dist/cjs/components/inputs-values-tree/styles.js +0 -177
  189. package/dist/cjs/components/json-schema-editor/styles.js +0 -231
  190. package/dist/cjs/components/prompt-editor/styles.js +0 -55
  191. package/dist/cjs/components/prompt-editor-with-inputs/editor.js +0 -47
  192. package/dist/cjs/components/prompt-editor-with-variables/editor.js +0 -48
  193. package/dist/cjs/components/variable-selector/styles.js +0 -114
  194. package/dist/esm/components/batch-outputs/styles.mjs +0 -13
  195. package/dist/esm/components/condition-row/styles.mjs +0 -21
  196. package/dist/esm/components/db-condition-row/styles.mjs +0 -32
  197. package/dist/esm/components/display-inputs-values/styles.mjs +0 -7
  198. package/dist/esm/components/display-outputs/styles.mjs +0 -7
  199. package/dist/esm/components/display-schema-tag/styles.mjs +0 -21
  200. package/dist/esm/components/display-schema-tree/styles.mjs +0 -79
  201. package/dist/esm/components/inputs-values/styles.mjs +0 -13
  202. package/dist/esm/components/inputs-values-tree/styles.mjs +0 -105
  203. package/dist/esm/components/json-schema-editor/styles.mjs +0 -138
  204. package/dist/esm/components/prompt-editor/styles.mjs +0 -11
  205. package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +0 -13
  206. package/dist/esm/components/prompt-editor-with-variables/editor.mjs +0 -14
  207. package/dist/types/components/batch-outputs/styles.d.ts +0 -6
  208. package/dist/types/components/condition-row/styles.d.ts +0 -9
  209. package/dist/types/components/coze-editor-extensions/styles.d.ts +0 -9
  210. package/dist/types/components/db-condition-row/styles.d.ts +0 -12
  211. package/dist/types/components/display-inputs-values/styles.d.ts +0 -5
  212. package/dist/types/components/display-outputs/styles.d.ts +0 -5
  213. package/dist/types/components/display-schema-tag/styles.d.ts +0 -8
  214. package/dist/types/components/display-schema-tree/styles.d.ts +0 -11
  215. package/dist/types/components/dynamic-value-input/styles.d.ts +0 -8
  216. package/dist/types/components/inputs-values/styles.d.ts +0 -6
  217. package/dist/types/components/inputs-values-tree/styles.d.ts +0 -23
  218. package/dist/types/components/json-schema-editor/styles.d.ts +0 -30
  219. package/dist/types/components/prompt-editor/styles.d.ts +0 -7
  220. package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +0 -10
  221. package/dist/types/components/prompt-editor-with-variables/editor.d.ts +0 -9
  222. package/dist/types/components/variable-selector/styles.d.ts +0 -14
  223. package/src/components/inputs-values-tree/styles.tsx +0 -128
  224. package/src/components/json-schema-editor/styles.tsx +0 -168
  225. package/src/components/prompt-editor/styles.tsx +0 -18
  226. package/src/components/prompt-editor-with-inputs/editor.tsx +0 -24
  227. package/src/components/prompt-editor-with-variables/editor.tsx +0 -20
@@ -0,0 +1,28 @@
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 Icon from '@douyinfe/semi-icons';
9
+
10
+ const iconAddChildrenSvg = (
11
+ <svg
12
+ className="icon-icon icon-icon-coz_add_node "
13
+ width="1em"
14
+ height="1em"
15
+ viewBox="0 0 24 24"
16
+ fill="currentColor"
17
+ xmlns="http://www.w3.org/2000/svg"
18
+ >
19
+ <path
20
+ fillRule="evenodd"
21
+ clipRule="evenodd"
22
+ d="M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
23
+ ></path>
24
+ <path d="M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z"></path>
25
+ </svg>
26
+ );
27
+
28
+ export const IconAddChildren = () => <Icon size="small" svg={iconAddChildrenSvg} />;
@@ -9,25 +9,27 @@ import { I18n } from '@flowgram.ai/editor';
9
9
  import { Button } from '@douyinfe/semi-ui';
10
10
  import { IconPlus } from '@douyinfe/semi-icons';
11
11
 
12
- import { FlowValueUtils } from '@/shared';
12
+ import { FlowValueUtils, IFlowValue, IInputsValues } from '@/shared';
13
13
  import { useObjectList } from '@/hooks';
14
14
 
15
15
  import { PropsType } from './types';
16
- import { UITreeItems } from './styles';
16
+ import './styles.css';
17
17
  import { InputValueRow } from './row';
18
18
 
19
19
  export function InputsValuesTree(props: PropsType) {
20
20
  const { value, onChange, readonly, hasError, constantProps } = props;
21
21
 
22
- const { list, updateKey, updateValue, remove, add } = useObjectList({
22
+ const { list, updateKey, updateValue, remove, add } = useObjectList<
23
+ IInputsValues | IFlowValue | undefined
24
+ >({
23
25
  value,
24
- onChange,
26
+ onChange: (v) => onChange?.(v as IInputsValues),
25
27
  sortIndexKey: (value) => (FlowValueUtils.isFlowValue(value) ? 'extra.index' : ''),
26
28
  });
27
29
 
28
30
  return (
29
31
  <div>
30
- <UITreeItems>
32
+ <div className="gedit-m-inputs-values-tree-tree-items">
31
33
  {list.map((item) => (
32
34
  <InputValueRow
33
35
  key={item.id}
@@ -41,7 +43,7 @@ export function InputsValuesTree(props: PropsType) {
41
43
  constantProps={constantProps}
42
44
  />
43
45
  ))}
44
- </UITreeItems>
46
+ </div>
45
47
  <Button
46
48
  style={{ marginTop: 10, marginLeft: 16 }}
47
49
  disabled={readonly}
@@ -13,20 +13,11 @@ import { IFlowConstantValue } from '@/shared';
13
13
  import { ConstantInputStrategy } from '@/components/constant-input';
14
14
 
15
15
  import { PropsType } from './types';
16
- import {
17
- IconAddChildren,
18
- UIActions,
19
- UICollapseTrigger,
20
- UICollapsible,
21
- UIRow,
22
- UITreeItemLeft,
23
- UITreeItemMain,
24
- UITreeItemRight,
25
- UITreeItems,
26
- } from './styles';
16
+ import './styles.css';
27
17
  import { useChildList } from './hooks/use-child-list';
28
18
  import { InjectDynamicValueInput } from '../dynamic-value-input';
29
19
  import { BlurInput } from '../blur-input';
20
+ import { IconAddChildren } from './icon';
30
21
 
31
22
  const AddObjectChildStrategy: ConstantInputStrategy = {
32
23
  hit: (schema) => schema.type === 'object',
@@ -88,16 +79,23 @@ export function InputValueRow(
88
79
 
89
80
  return (
90
81
  <>
91
- <UITreeItemLeft $isLast={$isLast} $showLine={$level > 0} $showCollapse={hasChildren}>
82
+ <div
83
+ className={`gedit-m-inputs-values-tree-tree-item-left ${$level > 0 ? 'show-line' : ''} ${
84
+ $isLast ? 'is-last' : ''
85
+ } ${hasChildren ? 'show-collapse' : ''}`}
86
+ >
92
87
  {hasChildren && (
93
- <UICollapseTrigger onClick={() => setCollapse((_collapse) => !_collapse)}>
88
+ <div
89
+ className="gedit-m-inputs-values-tree-collapse-trigger"
90
+ onClick={() => setCollapse((_collapse) => !_collapse)}
91
+ >
94
92
  {collapse ? <IconChevronDown size="small" /> : <IconChevronRight size="small" />}
95
- </UICollapseTrigger>
93
+ </div>
96
94
  )}
97
- </UITreeItemLeft>
98
- <UITreeItemRight>
99
- <UITreeItemMain>
100
- <UIRow>
95
+ </div>
96
+ <div className="gedit-m-inputs-values-tree-tree-item-right">
97
+ <div className="gedit-m-inputs-values-tree-tree-item-main">
98
+ <div className="gedit-m-inputs-values-tree-row">
101
99
  <BlurInput
102
100
  style={{ width: 100, minWidth: 100, maxWidth: 100 }}
103
101
  disabled={readonly}
@@ -117,7 +115,7 @@ export function InputValueRow(
117
115
  strategies,
118
116
  }}
119
117
  />
120
- <UIActions>
118
+ <div className="gedit-m-inputs-values-tree-actions">
121
119
  {canAddField && (
122
120
  <IconButton
123
121
  disabled={readonly}
@@ -141,12 +139,12 @@ export function InputValueRow(
141
139
  size="small"
142
140
  onClick={() => onRemove?.()}
143
141
  />
144
- </UIActions>
145
- </UIRow>
146
- </UITreeItemMain>
142
+ </div>
143
+ </div>
144
+ </div>
147
145
  {hasChildren && (
148
- <UICollapsible $collapse={collapse}>
149
- <UITreeItems $shrink={true}>
146
+ <div className={`gedit-m-inputs-values-tree-collapsible ${collapse ? 'collapse' : ''}`}>
147
+ <div className="gedit-m-inputs-values-tree-tree-items shrink">
150
148
  {list.map((_item, index) => (
151
149
  <InputValueRow
152
150
  readonly={readonly}
@@ -168,10 +166,10 @@ export function InputValueRow(
168
166
  $isLast={index === list.length - 1}
169
167
  />
170
168
  ))}
171
- </UITreeItems>
172
- </UICollapsible>
169
+ </div>
170
+ </div>
173
171
  )}
174
- </UITreeItemRight>
172
+ </div>
175
173
  </>
176
174
  );
177
175
  }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ .gedit-m-inputs-values-tree-container {
7
+ }
8
+
9
+ .gedit-m-inputs-values-tree-row {
10
+ display: flex;
11
+ align-items: flex-start;
12
+ gap: 5px;
13
+ }
14
+
15
+ .gedit-m-inputs-values-tree-collapse-trigger {
16
+ cursor: pointer;
17
+ margin-right: 5px;
18
+ }
19
+
20
+ .gedit-m-inputs-values-tree-tree-items {
21
+ display: grid;
22
+ grid-template-columns: auto 1fr;
23
+ }
24
+
25
+ .gedit-m-inputs-values-tree-tree-items.shrink {
26
+ padding-left: 3px;
27
+ margin-top: 10px;
28
+ }
29
+
30
+ .gedit-m-inputs-values-tree-tree-item-left {
31
+ grid-column: 1;
32
+ position: relative;
33
+ width: 16px;
34
+ }
35
+
36
+ .gedit-m-inputs-values-tree-tree-item-left.show-line::before {
37
+ /* 竖线 */
38
+ content: "";
39
+ height: var(--line-height, 100%);
40
+ position: absolute;
41
+ left: -14px;
42
+ top: -16px;
43
+ width: 1px;
44
+ background: #d9d9d9;
45
+ display: block;
46
+ }
47
+
48
+ .gedit-m-inputs-values-tree-tree-item-left.show-line::after {
49
+ /* 横线 */
50
+ content: "";
51
+ position: absolute;
52
+ left: -14px; /* 横线起点和竖线对齐 */
53
+ top: 8px; /* 跟随你的行高调整 */
54
+ width: var(--line-width, 30px); /* 横线长度 */
55
+ height: 1px;
56
+ background: #d9d9d9;
57
+ display: block;
58
+ }
59
+
60
+ .gedit-m-inputs-values-tree-tree-item-left.show-line.is-last::before {
61
+ height: 24px;
62
+ }
63
+
64
+ .gedit-m-inputs-values-tree-tree-item-left.show-line.show-collapse::after {
65
+ width: 12px;
66
+ }
67
+
68
+ .gedit-m-inputs-values-tree-tree-item-right {
69
+ grid-column: 2;
70
+ margin-bottom: 10px;
71
+
72
+ &:last-child {
73
+ margin-bottom: 0px;
74
+ }
75
+ }
76
+
77
+ .gedit-m-inputs-values-tree-tree-item-main {
78
+ display: flex;
79
+ flex-direction: column;
80
+ gap: 10px;
81
+ position: relative;
82
+ }
83
+
84
+ .gedit-m-inputs-values-tree-collapsible {
85
+ display: none;
86
+ }
87
+
88
+ .gedit-m-inputs-values-tree-collapsible.collapse {
89
+ display: block;
90
+ }
91
+
92
+ .gedit-m-inputs-values-tree-actions {
93
+ white-space: nowrap;
94
+ }
@@ -5,11 +5,12 @@
5
5
 
6
6
  import { IJsonSchema } from '@flowgram.ai/json-schema';
7
7
 
8
+ import { IInputsValues } from '@/shared';
8
9
  import { ConstantInputStrategy } from '@/components/constant-input';
9
10
 
10
11
  export interface PropsType {
11
- value?: any;
12
- onChange: (value?: any) => void;
12
+ value?: IInputsValues;
13
+ onChange: (value?: IInputsValues) => void;
13
14
  readonly?: boolean;
14
15
  hasError?: boolean;
15
16
  schema?: IJsonSchema;
@@ -10,8 +10,6 @@ import { I18n } from '@flowgram.ai/editor';
10
10
 
11
11
  import { ConstantInput } from '@/components/constant-input';
12
12
 
13
- import { ConstantInputWrapper } from './styles';
14
-
15
13
  /**
16
14
  * Renders the corresponding default value input component based on different data types.
17
15
  * @param props - Component properties, including value, type, placeholder, onChange.
@@ -26,7 +24,7 @@ export function DefaultValue(props: {
26
24
  const { value, schema, onChange, placeholder } = props;
27
25
 
28
26
  return (
29
- <ConstantInputWrapper>
27
+ <div className="gedit-m-json-schema-editor-constant-input-wrapper">
30
28
  <ConstantInput
31
29
  value={value}
32
30
  onChange={(_v) => onChange(_v)}
@@ -34,6 +32,6 @@ export function DefaultValue(props: {
34
32
  placeholder={placeholder ?? I18n.t('Default value if parameter is not provided')}
35
33
  enableMultiLineStr
36
34
  />
37
- </ConstantInputWrapper>
35
+ </div>
38
36
  );
39
37
  }
@@ -27,6 +27,7 @@ export function usePropertiesEdit(
27
27
  const canAddField = typeManager.canAddField(value || {});
28
28
 
29
29
  const [propertyList, setPropertyList] = useState<PropertyValueType[]>([]);
30
+ const latestPropertyListRef = useRef(propertyList);
30
31
 
31
32
  const effectVersion = useRef(0);
32
33
  const changeVersion = useRef(0);
@@ -39,77 +40,82 @@ export function usePropertiesEdit(
39
40
  effectVersion.current = changeVersion.current;
40
41
 
41
42
  // If the value is changed, update the property list
42
- setPropertyList((_list) => {
43
- const newNames = Object.entries(drilldownSchema?.properties || {})
44
- .sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0))
45
- .map(([key]) => key);
46
-
47
- const oldNames = _list.map((item) => item.name).filter(Boolean) as string[];
48
- const addNames = difference(newNames, oldNames);
49
-
50
- return _list
51
- .filter((item) => !item.name || newNames.includes(item.name))
52
- .map((item) => ({
53
- key: item.key,
54
- name: item.name,
55
- isPropertyRequired: drilldownSchema?.required?.includes(item.name || '') || false,
56
- ...(drilldownSchema?.properties?.[item.name || ''] || item || {}),
43
+ const _list = latestPropertyListRef.current;
44
+
45
+ const newNames = Object.entries(drilldownSchema?.properties || {})
46
+ .sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0))
47
+ .map(([key]) => key);
48
+
49
+ const oldNames = _list.map((item) => item.name).filter(Boolean) as string[];
50
+ const addNames = difference(newNames, oldNames);
51
+
52
+ const next = _list
53
+ .filter((item) => !item.name || newNames.includes(item.name))
54
+ .map((item) => ({
55
+ key: item.key,
56
+ name: item.name,
57
+ isPropertyRequired: drilldownSchema?.required?.includes(item.name || '') || false,
58
+ ...(drilldownSchema?.properties?.[item.name || ''] || item || {}),
59
+ }))
60
+ .concat(
61
+ addNames.map((_name) => ({
62
+ key: genId(),
63
+ name: _name,
64
+ isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
65
+ ...(drilldownSchema?.properties?.[_name] || {}),
57
66
  }))
58
- .concat(
59
- addNames.map((_name) => ({
60
- key: genId(),
61
- name: _name,
62
- isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
63
- ...(drilldownSchema?.properties?.[_name] || {}),
64
- }))
65
- );
66
- });
67
+ );
68
+
69
+ latestPropertyListRef.current = next;
70
+
71
+ setPropertyList(next);
67
72
  }, [drilldownSchema]);
68
73
 
69
74
  const updatePropertyList = (updater: (list: PropertyValueType[]) => PropertyValueType[]) => {
70
75
  changeVersion.current = changeVersion.current + 1;
71
76
 
72
- setPropertyList((_list) => {
73
- const next = updater(_list);
77
+ const next = updater(latestPropertyListRef.current);
78
+ latestPropertyListRef.current = next;
79
+ setPropertyList(next);
74
80
 
75
- // onChange to parent
76
- const nextProperties: Record<string, IJsonSchema> = {};
77
- const nextRequired: string[] = [];
81
+ // onChange to parent
82
+ const nextProperties: Record<string, IJsonSchema> = {};
83
+ const nextRequired: string[] = [];
78
84
 
79
- for (const _property of next) {
80
- if (!_property.name) {
81
- continue;
82
- }
85
+ for (const _property of next) {
86
+ if (!_property.name) {
87
+ continue;
88
+ }
83
89
 
84
- nextProperties[_property.name] = omit(_property, ['key', 'name', 'isPropertyRequired']);
90
+ nextProperties[_property.name] = omit(_property, ['key', 'name', 'isPropertyRequired']);
85
91
 
86
- if (_property.isPropertyRequired) {
87
- nextRequired.push(_property.name);
88
- }
92
+ if (_property.isPropertyRequired) {
93
+ nextRequired.push(_property.name);
89
94
  }
95
+ }
90
96
 
91
- onChange?.(
92
- produce(value || {}, (draft) => {
93
- const propertiesParent = typeManager.getPropertiesParent(draft);
94
-
95
- if (propertiesParent) {
96
- propertiesParent.properties = nextProperties;
97
- propertiesParent.required = nextRequired;
98
- return;
99
- }
100
- })
101
- );
97
+ onChange?.(
98
+ produce(value || {}, (draft) => {
99
+ const propertiesParent = typeManager.getPropertiesParent(draft);
102
100
 
103
- return next;
104
- });
101
+ if (propertiesParent) {
102
+ propertiesParent.properties = nextProperties;
103
+ propertiesParent.required = nextRequired;
104
+ return;
105
+ }
106
+ })
107
+ );
105
108
  };
106
109
 
107
110
  const onAddProperty = () => {
108
- // set property list only, not trigger updatePropertyList
109
- setPropertyList((_list) => [
111
+ const _list = latestPropertyListRef.current;
112
+ const next = [
110
113
  ..._list,
111
114
  { key: genId(), name: '', type: 'string', extra: { index: _list.length + 1 } },
112
- ]);
115
+ ];
116
+
117
+ latestPropertyListRef.current = next;
118
+ setPropertyList(next);
113
119
  };
114
120
 
115
121
  const onRemoveProperty = (key: number) => {
@@ -124,6 +130,7 @@ export function usePropertiesEdit(
124
130
 
125
131
  useEffect(() => {
126
132
  if (!canAddField) {
133
+ latestPropertyListRef.current = [];
127
134
  setPropertyList([]);
128
135
  }
129
136
  }, [canAddField]);
@@ -0,0 +1,28 @@
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 Icon from '@douyinfe/semi-icons';
9
+
10
+ const iconAddChildrenSvg = (
11
+ <svg
12
+ className="icon-icon icon-icon-coz_add_node "
13
+ width="1em"
14
+ height="1em"
15
+ viewBox="0 0 24 24"
16
+ fill="currentColor"
17
+ xmlns="http://www.w3.org/2000/svg"
18
+ >
19
+ <path
20
+ fillRule="evenodd"
21
+ clipRule="evenodd"
22
+ d="M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
23
+ ></path>
24
+ <path d="M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z"></path>
25
+ </svg>
26
+ );
27
+
28
+ export const IconAddChildren = () => <Icon size="small" svg={iconAddChildrenSvg} />;
@@ -21,26 +21,12 @@ import { InjectTypeSelector } from '@/components/type-selector';
21
21
  import { BlurInput } from '@/components/blur-input';
22
22
 
23
23
  import { ConfigType, PropertyValueType } from './types';
24
- import {
25
- IconAddChildren,
26
- UIActions,
27
- UICollapseTrigger,
28
- UICollapsible,
29
- UIContainer,
30
- UIExpandDetail,
31
- UILabel,
32
- UITreeItems,
33
- UITreeItemLeft,
34
- UITreeItemMain,
35
- UITreeItemRight,
36
- UIRequired,
37
- UIType,
38
- } from './styles';
39
- import { UIName } from './styles';
40
- import { DefaultValueWrapper, UIRow } from './styles';
24
+ import { IconAddChildren } from './icon';
41
25
  import { usePropertiesEdit } from './hooks';
42
26
  import { DefaultValue } from './default-value';
43
27
 
28
+ import './styles.css';
29
+
44
30
  const DEFAULT = { type: 'object' };
45
31
 
46
32
  export function JsonSchemaEditor(props: {
@@ -57,8 +43,8 @@ export function JsonSchemaEditor(props: {
57
43
  );
58
44
 
59
45
  return (
60
- <UIContainer className={props.className}>
61
- <UITreeItems>
46
+ <div className="gedit-m-json-schema-editor-container">
47
+ <div className="gedit-m-json-schema-editor-tree-items">
62
48
  {propertyList.map((_property) => (
63
49
  <PropertyEdit
64
50
  readonly={readonly}
@@ -73,7 +59,7 @@ export function JsonSchemaEditor(props: {
73
59
  }}
74
60
  />
75
61
  ))}
76
- </UITreeItems>
62
+ </div>
77
63
  <Button
78
64
  disabled={readonly}
79
65
  size="small"
@@ -83,7 +69,7 @@ export function JsonSchemaEditor(props: {
83
69
  >
84
70
  {config?.addButtonText ?? I18n.t('Add')}
85
71
  </Button>
86
- </UIContainer>
72
+ </div>
87
73
  );
88
74
  }
89
75
 
@@ -119,17 +105,24 @@ function PropertyEdit(props: {
119
105
 
120
106
  return (
121
107
  <>
122
- <UITreeItemLeft $isLast={$isLast} $showLine={$level > 0} $showCollapse={showCollapse}>
108
+ <div
109
+ className={`gedit-m-json-schema-editor-tree-item-left ${$level > 0 ? 'show-line' : ''} ${
110
+ $isLast ? 'is-last' : ''
111
+ } ${showCollapse ? 'show-collapse' : ''}`}
112
+ >
123
113
  {showCollapse && (
124
- <UICollapseTrigger onClick={() => setCollapse((_collapse) => !_collapse)}>
114
+ <div
115
+ className="gedit-m-json-schema-editor-collapse-trigger"
116
+ onClick={() => setCollapse((_collapse) => !_collapse)}
117
+ >
125
118
  {collapse ? <IconChevronDown size="small" /> : <IconChevronRight size="small" />}
126
- </UICollapseTrigger>
119
+ </div>
127
120
  )}
128
- </UITreeItemLeft>
129
- <UITreeItemRight>
130
- <UITreeItemMain>
131
- <UIRow>
132
- <UIName>
121
+ </div>
122
+ <div className="gedit-m-json-schema-editor-tree-item-right">
123
+ <div className="gedit-m-json-schema-editor-tree-item-main">
124
+ <div className="gedit-m-json-schema-editor-row">
125
+ <div className="gedit-m-json-schema-editor-name">
133
126
  <BlurInput
134
127
  disabled={readonly}
135
128
  placeholder={config?.placeholder ?? I18n.t('Input Variable Name')}
@@ -137,8 +130,8 @@ function PropertyEdit(props: {
137
130
  value={name}
138
131
  onChange={(value) => onChange('name', value)}
139
132
  />
140
- </UIName>
141
- <UIType>
133
+ </div>
134
+ <div className="gedit-m-json-schema-editor-type">
142
135
  <InjectTypeSelector
143
136
  value={typeSelectorValue}
144
137
  readonly={readonly}
@@ -149,15 +142,15 @@ function PropertyEdit(props: {
149
142
  });
150
143
  }}
151
144
  />
152
- </UIType>
153
- <UIRequired>
145
+ </div>
146
+ <div className="gedit-m-json-schema-editor-required">
154
147
  <Checkbox
155
148
  disabled={readonly}
156
149
  checked={isPropertyRequired}
157
150
  onChange={(e) => onChange('isPropertyRequired', e.target.checked)}
158
151
  />
159
- </UIRequired>
160
- <UIActions>
152
+ </div>
153
+ <div className="gedit-m-json-schema-editor-actions">
161
154
  <IconButton
162
155
  disabled={readonly}
163
156
  size="small"
@@ -186,11 +179,13 @@ function PropertyEdit(props: {
186
179
  icon={<IconMinus size="small" />}
187
180
  onClick={onRemove}
188
181
  />
189
- </UIActions>
190
- </UIRow>
182
+ </div>
183
+ </div>
191
184
  {expand && (
192
- <UIExpandDetail>
193
- <UILabel>{config?.descTitle ?? I18n.t('Description')}</UILabel>
185
+ <div className="gedit-m-json-schema-editor-expand-detail">
186
+ <div className="gedit-m-json-schema-editor-label">
187
+ {config?.descTitle ?? I18n.t('Description')}
188
+ </div>
194
189
  <BlurInput
195
190
  disabled={readonly}
196
191
  size="small"
@@ -202,25 +197,25 @@ function PropertyEdit(props: {
202
197
  />
203
198
  {$level === 0 && (
204
199
  <>
205
- <UILabel style={{ marginTop: 10 }}>
200
+ <div className="gedit-m-json-schema-editor-label" style={{ marginTop: 10 }}>
206
201
  {config?.defaultValueTitle ?? I18n.t('Default Value')}
207
- </UILabel>
208
- <DefaultValueWrapper>
202
+ </div>
203
+ <div className="gedit-m-json-schema-editor-default-value-wrapper">
209
204
  <DefaultValue
210
205
  value={defaultValue}
211
206
  schema={value}
212
207
  placeholder={config?.defaultValuePlaceholder ?? I18n.t('Default Value')}
213
208
  onChange={(value) => onChange('default', value)}
214
209
  />
215
- </DefaultValueWrapper>
210
+ </div>
216
211
  </>
217
212
  )}
218
- </UIExpandDetail>
213
+ </div>
219
214
  )}
220
- </UITreeItemMain>
215
+ </div>
221
216
  {showCollapse && (
222
- <UICollapsible $collapse={collapse}>
223
- <UITreeItems $shrink={true}>
217
+ <div className={`gedit-m-json-schema-editor-collapsible ${collapse ? 'collapse' : ''}`}>
218
+ <div className="gedit-m-json-schema-editor-tree-items shrink">
224
219
  {propertyList.map((_property, index) => (
225
220
  <PropertyEdit
226
221
  readonly={readonly}
@@ -237,10 +232,10 @@ function PropertyEdit(props: {
237
232
  $isLast={index === propertyList.length - 1}
238
233
  />
239
234
  ))}
240
- </UITreeItems>
241
- </UICollapsible>
235
+ </div>
236
+ </div>
242
237
  )}
243
- </UITreeItemRight>
238
+ </div>
244
239
  </>
245
240
  );
246
241
  }