@flowgram.ai/form-materials 0.1.0-alpha.18 → 0.1.0-alpha.20

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 (260) hide show
  1. package/dist/cjs/components/assign-rows/index.js +8 -2
  2. package/dist/cjs/components/batch-outputs/index.js +5 -3
  3. package/dist/cjs/components/batch-outputs/styles.css +13 -0
  4. package/dist/cjs/components/blur-input/index.js +5 -1
  5. package/dist/cjs/components/code-editor/editor.js +16 -12
  6. package/dist/cjs/components/code-editor/styles.css +4 -0
  7. package/dist/cjs/components/code-editor/theme/dark.js +1 -1
  8. package/dist/cjs/components/code-editor/theme/light.js +1 -1
  9. package/dist/cjs/components/code-editor-mini/index.js +2 -16
  10. package/dist/cjs/components/condition-context/hooks/use-condition.js +21 -1
  11. package/dist/cjs/components/condition-row/index.js +26 -12
  12. package/dist/cjs/components/condition-row/styles.css +19 -0
  13. package/dist/cjs/components/coze-editor-extensions/extensions/inputs-tree.js +2 -2
  14. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +44 -15
  15. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tree.js +7 -3
  16. package/dist/{esm/components/coze-editor-extensions/styles.mjs → cjs/components/coze-editor-extensions/styles.css} +19 -18
  17. package/dist/cjs/components/db-condition-row/index.js +29 -14
  18. package/dist/cjs/components/db-condition-row/styles.css +30 -0
  19. package/dist/cjs/components/display-inputs-values/index.js +3 -2
  20. package/dist/cjs/components/display-inputs-values/styles.css +6 -0
  21. package/dist/cjs/components/display-outputs/index.js +8 -6
  22. package/dist/cjs/components/display-outputs/styles.css +6 -0
  23. package/dist/cjs/components/display-schema-tag/index.js +7 -4
  24. package/dist/cjs/components/display-schema-tag/styles.css +21 -0
  25. package/dist/cjs/components/display-schema-tree/index.js +12 -7
  26. package/dist/cjs/components/display-schema-tree/styles.css +64 -0
  27. package/dist/cjs/components/dynamic-value-input/index.js +9 -5
  28. package/dist/{esm/components/dynamic-value-input/styles.mjs → cjs/components/dynamic-value-input/styles.css} +24 -30
  29. package/dist/cjs/components/index.js +5 -1
  30. package/dist/cjs/components/inputs-values/index.js +5 -3
  31. package/dist/cjs/components/inputs-values/styles.css +13 -0
  32. package/dist/cjs/components/inputs-values-tree/icon.js +70 -0
  33. package/dist/cjs/components/inputs-values-tree/index.js +4 -3
  34. package/dist/cjs/components/inputs-values-tree/row.js +19 -15
  35. package/dist/cjs/components/inputs-values-tree/styles.css +85 -0
  36. package/dist/cjs/components/{display-inputs-values/styles.js → json-schema-creator/index.js} +4 -19
  37. package/dist/cjs/components/json-schema-creator/json-input-modal.js +96 -0
  38. package/dist/cjs/components/{prompt-editor-with-variables/editor.js → json-schema-creator/json-schema-creator.js} +23 -11
  39. package/dist/cjs/components/{batch-outputs/styles.js → json-schema-creator/utils/json-to-schema.js} +35 -28
  40. package/dist/cjs/components/json-schema-editor/default-value.js +2 -2
  41. package/dist/cjs/components/json-schema-editor/hooks.js +55 -48
  42. package/dist/cjs/components/json-schema-editor/icon.js +70 -0
  43. package/dist/cjs/components/json-schema-editor/index.js +37 -25
  44. package/dist/cjs/components/json-schema-editor/styles.css +113 -0
  45. package/dist/cjs/components/prompt-editor/editor.js +16 -6
  46. package/dist/cjs/components/prompt-editor/styles.css +10 -0
  47. package/dist/cjs/components/prompt-editor-with-inputs/index.js +16 -26
  48. package/dist/cjs/components/prompt-editor-with-variables/index.js +17 -26
  49. package/dist/cjs/components/variable-selector/context.js +7 -3
  50. package/dist/cjs/components/variable-selector/index.js +16 -10
  51. package/dist/{esm/components/variable-selector/styles.mjs → cjs/components/variable-selector/styles.css} +37 -29
  52. package/dist/cjs/components/variable-selector/use-variable-tree.js +3 -1
  53. package/dist/cjs/effects/validate-when-variable-sync/index.js +3 -3
  54. package/dist/cjs/index.js +3 -0
  55. package/dist/cjs/shared/inject-material/index.js +1 -1
  56. package/dist/esm/components/assign-rows/index.mjs +9 -3
  57. package/dist/esm/components/batch-outputs/index.mjs +5 -3
  58. package/dist/esm/components/batch-outputs/styles.css +13 -0
  59. package/dist/esm/components/blur-input/index.mjs +5 -1
  60. package/dist/esm/components/code-editor/editor.mjs +16 -11
  61. package/dist/esm/components/code-editor/styles.css +4 -0
  62. package/dist/esm/components/code-editor/theme/dark.mjs +1 -1
  63. package/dist/esm/components/code-editor/theme/light.mjs +1 -1
  64. package/dist/esm/components/code-editor-mini/index.mjs +2 -6
  65. package/dist/esm/components/condition-context/hooks/use-condition.mjs +22 -2
  66. package/dist/esm/components/condition-row/index.mjs +26 -12
  67. package/dist/esm/components/condition-row/styles.css +19 -0
  68. package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +3 -3
  69. package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +45 -16
  70. package/dist/esm/components/coze-editor-extensions/extensions/variable-tree.mjs +8 -4
  71. package/dist/esm/components/coze-editor-extensions/styles.css +37 -0
  72. package/dist/esm/components/db-condition-row/index.mjs +29 -14
  73. package/dist/esm/components/db-condition-row/styles.css +30 -0
  74. package/dist/esm/components/display-inputs-values/index.mjs +3 -2
  75. package/dist/esm/components/display-inputs-values/styles.css +6 -0
  76. package/dist/esm/components/display-outputs/index.mjs +9 -7
  77. package/dist/esm/components/display-outputs/styles.css +6 -0
  78. package/dist/esm/components/display-schema-tag/index.mjs +8 -5
  79. package/dist/esm/components/display-schema-tag/styles.css +21 -0
  80. package/dist/esm/components/display-schema-tree/index.mjs +12 -7
  81. package/dist/esm/components/display-schema-tree/styles.css +64 -0
  82. package/dist/esm/components/dynamic-value-input/index.mjs +9 -5
  83. package/dist/esm/components/dynamic-value-input/styles.css +48 -0
  84. package/dist/esm/components/index.mjs +2 -1
  85. package/dist/esm/components/inputs-values/index.mjs +5 -3
  86. package/dist/esm/components/inputs-values/styles.css +13 -0
  87. package/dist/esm/components/inputs-values-tree/icon.mjs +26 -0
  88. package/dist/esm/components/inputs-values-tree/index.mjs +4 -3
  89. package/dist/esm/components/inputs-values-tree/row.mjs +18 -14
  90. package/dist/esm/components/inputs-values-tree/styles.css +85 -0
  91. package/dist/esm/components/json-schema-creator/index.mjs +2 -0
  92. package/dist/esm/components/json-schema-creator/json-input-modal.mjs +62 -0
  93. package/dist/esm/components/json-schema-creator/json-schema-creator.mjs +26 -0
  94. package/dist/esm/components/json-schema-creator/utils/json-to-schema.mjs +33 -0
  95. package/dist/esm/components/json-schema-editor/default-value.mjs +2 -2
  96. package/dist/esm/components/json-schema-editor/hooks.mjs +55 -48
  97. package/dist/esm/components/json-schema-editor/icon.mjs +26 -0
  98. package/dist/esm/components/json-schema-editor/index.mjs +36 -24
  99. package/dist/esm/components/json-schema-editor/styles.css +113 -0
  100. package/dist/esm/components/prompt-editor/editor.mjs +16 -6
  101. package/dist/esm/components/prompt-editor/styles.css +10 -0
  102. package/dist/esm/components/prompt-editor-with-inputs/index.mjs +12 -4
  103. package/dist/esm/components/prompt-editor-with-variables/index.mjs +13 -4
  104. package/dist/esm/components/variable-selector/context.mjs +7 -3
  105. package/dist/esm/components/variable-selector/index.mjs +17 -11
  106. package/{src/components/variable-selector/styles.tsx → dist/esm/components/variable-selector/styles.css} +35 -38
  107. package/dist/esm/components/variable-selector/use-variable-tree.mjs +3 -1
  108. package/dist/esm/effects/validate-when-variable-sync/index.mjs +3 -3
  109. package/dist/esm/index.mjs +2 -2
  110. package/dist/esm/shared/inject-material/index.mjs +1 -1
  111. package/dist/tsconfig.tsbuildinfo +1 -1
  112. package/dist/types/components/assign-rows/index.d.ts +2 -0
  113. package/dist/types/components/batch-outputs/index.d.ts +1 -0
  114. package/dist/types/components/blur-input/index.d.ts +1 -1
  115. package/dist/types/components/code-editor/editor.d.ts +1 -0
  116. package/dist/types/components/condition-context/hooks/use-condition.d.ts +16 -1
  117. package/dist/types/components/condition-row/index.d.ts +5 -1
  118. package/dist/types/components/coze-editor-extensions/extensions/inputs-tree.d.ts +3 -3
  119. package/dist/types/components/coze-editor-extensions/extensions/variable-tag.d.ts +1 -0
  120. package/dist/types/components/coze-editor-extensions/index.d.ts +1 -1
  121. package/dist/types/components/db-condition-row/index.d.ts +4 -0
  122. package/dist/types/components/db-condition-row/types.d.ts +0 -1
  123. package/dist/types/components/display-inputs-values/index.d.ts +3 -1
  124. package/dist/types/components/display-outputs/index.d.ts +3 -1
  125. package/dist/types/components/display-schema-tag/index.d.ts +1 -0
  126. package/dist/types/components/display-schema-tree/index.d.ts +1 -0
  127. package/dist/types/components/dynamic-value-input/index.d.ts +1 -0
  128. package/dist/types/components/index.d.ts +1 -0
  129. package/dist/types/components/inputs-values/index.d.ts +1 -0
  130. package/dist/types/components/inputs-values-tree/icon.d.ts +6 -0
  131. package/dist/types/components/inputs-values-tree/index.d.ts +1 -0
  132. package/dist/types/components/inputs-values-tree/row.d.ts +1 -0
  133. package/dist/types/components/inputs-values-tree/types.d.ts +3 -2
  134. package/dist/types/components/json-schema-creator/index.d.ts +6 -0
  135. package/dist/types/components/json-schema-creator/json-input-modal.d.ts +13 -0
  136. package/dist/types/components/json-schema-creator/json-schema-creator.d.ts +11 -0
  137. package/dist/types/components/json-schema-creator/utils/json-to-schema.d.ts +6 -0
  138. package/dist/types/components/json-schema-editor/icon.d.ts +6 -0
  139. package/dist/types/components/json-schema-editor/index.d.ts +1 -0
  140. package/dist/types/components/prompt-editor/editor.d.ts +1 -0
  141. package/dist/types/components/prompt-editor-with-inputs/index.d.ts +7 -2
  142. package/dist/types/components/prompt-editor-with-variables/index.d.ts +5 -2
  143. package/dist/types/components/variable-selector/context.d.ts +16 -3
  144. package/dist/types/components/variable-selector/index.d.ts +1 -0
  145. package/dist/types/index.d.ts +2 -2
  146. package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +7 -3
  147. package/dist/types/shared/flow-value/index.d.ts +1 -1
  148. package/dist/types/shared/flow-value/types.d.ts +3 -0
  149. package/dist/types/shared/index.d.ts +1 -1
  150. package/package.json +7 -10
  151. package/src/components/assign-rows/index.tsx +7 -6
  152. package/src/components/batch-outputs/index.tsx +5 -5
  153. package/src/components/batch-outputs/{styles.tsx → styles.css} +4 -6
  154. package/src/components/blur-input/index.tsx +6 -2
  155. package/src/components/code-editor/editor.tsx +19 -14
  156. package/src/components/code-editor/styles.css +11 -0
  157. package/src/components/code-editor/theme/dark.ts +1 -1
  158. package/src/components/code-editor/theme/light.ts +1 -1
  159. package/src/components/code-editor-mini/index.tsx +2 -9
  160. package/src/components/condition-context/hooks/use-condition.tsx +55 -7
  161. package/src/components/condition-row/index.tsx +27 -22
  162. package/src/components/condition-row/{styles.tsx → styles.css} +11 -11
  163. package/src/components/coze-editor-extensions/extensions/inputs-tree.tsx +7 -6
  164. package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +35 -22
  165. package/src/components/coze-editor-extensions/extensions/variable-tree.tsx +14 -4
  166. package/src/components/coze-editor-extensions/{styles.tsx → styles.css} +8 -11
  167. package/src/components/db-condition-row/index.tsx +29 -26
  168. package/src/components/db-condition-row/{styles.tsx → styles.css} +14 -16
  169. package/src/components/db-condition-row/types.ts +0 -1
  170. package/src/components/display-inputs-values/index.tsx +5 -4
  171. package/src/components/display-inputs-values/{styles.ts → styles.css} +2 -4
  172. package/src/components/display-outputs/index.tsx +9 -8
  173. package/src/components/display-outputs/{styles.ts → styles.css} +2 -4
  174. package/src/components/display-schema-tag/index.tsx +7 -7
  175. package/src/components/display-schema-tag/{styles.ts → styles.css} +7 -10
  176. package/src/components/display-schema-tree/index.tsx +10 -10
  177. package/src/components/display-schema-tree/{styles.tsx → styles.css} +18 -24
  178. package/src/components/dynamic-value-input/index.tsx +6 -6
  179. package/src/components/dynamic-value-input/{styles.tsx → styles.css} +9 -12
  180. package/src/components/index.ts +1 -0
  181. package/src/components/inputs-values/index.tsx +5 -5
  182. package/src/components/inputs-values/{styles.tsx → styles.css} +4 -6
  183. package/src/components/inputs-values-tree/icon.tsx +28 -0
  184. package/src/components/inputs-values-tree/index.tsx +8 -6
  185. package/src/components/inputs-values-tree/row.tsx +25 -27
  186. package/src/components/inputs-values-tree/styles.css +94 -0
  187. package/src/components/inputs-values-tree/types.ts +3 -2
  188. package/src/components/json-schema-creator/index.tsx +7 -0
  189. package/src/components/json-schema-creator/json-input-modal.tsx +61 -0
  190. package/src/components/json-schema-creator/json-schema-creator.tsx +37 -0
  191. package/src/components/json-schema-creator/utils/json-to-schema.ts +50 -0
  192. package/src/components/json-schema-editor/default-value.tsx +2 -4
  193. package/src/components/json-schema-editor/hooks.tsx +60 -53
  194. package/src/components/json-schema-editor/icon.tsx +28 -0
  195. package/src/components/json-schema-editor/index.tsx +45 -50
  196. package/src/components/json-schema-editor/styles.css +135 -0
  197. package/src/components/prompt-editor/editor.tsx +18 -7
  198. package/src/components/prompt-editor/styles.css +14 -0
  199. package/src/components/prompt-editor-with-inputs/index.tsx +18 -5
  200. package/src/components/prompt-editor-with-variables/index.tsx +13 -5
  201. package/src/components/variable-selector/context.tsx +22 -2
  202. package/src/components/variable-selector/index.tsx +24 -14
  203. package/src/components/variable-selector/styles.css +70 -0
  204. package/src/components/variable-selector/use-variable-tree.tsx +9 -1
  205. package/src/effects/validate-when-variable-sync/index.ts +7 -3
  206. package/src/index.ts +3 -0
  207. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +17 -12
  208. package/src/shared/flow-value/index.ts +1 -0
  209. package/src/shared/flow-value/types.ts +4 -0
  210. package/src/shared/index.ts +1 -0
  211. package/src/shared/inject-material/index.tsx +1 -1
  212. package/dist/cjs/components/condition-row/styles.js +0 -77
  213. package/dist/cjs/components/coze-editor-extensions/styles.js +0 -89
  214. package/dist/cjs/components/db-condition-row/styles.js +0 -94
  215. package/dist/cjs/components/display-outputs/styles.js +0 -51
  216. package/dist/cjs/components/display-schema-tag/styles.js +0 -71
  217. package/dist/cjs/components/display-schema-tree/styles.js +0 -135
  218. package/dist/cjs/components/dynamic-value-input/styles.js +0 -107
  219. package/dist/cjs/components/inputs-values/styles.js +0 -60
  220. package/dist/cjs/components/inputs-values-tree/styles.js +0 -177
  221. package/dist/cjs/components/json-schema-editor/styles.js +0 -231
  222. package/dist/cjs/components/prompt-editor/styles.js +0 -55
  223. package/dist/cjs/components/prompt-editor-with-inputs/editor.js +0 -47
  224. package/dist/cjs/components/variable-selector/styles.js +0 -114
  225. package/dist/esm/components/batch-outputs/styles.mjs +0 -13
  226. package/dist/esm/components/condition-row/styles.mjs +0 -21
  227. package/dist/esm/components/db-condition-row/styles.mjs +0 -32
  228. package/dist/esm/components/display-inputs-values/styles.mjs +0 -7
  229. package/dist/esm/components/display-outputs/styles.mjs +0 -7
  230. package/dist/esm/components/display-schema-tag/styles.mjs +0 -21
  231. package/dist/esm/components/display-schema-tree/styles.mjs +0 -79
  232. package/dist/esm/components/inputs-values/styles.mjs +0 -13
  233. package/dist/esm/components/inputs-values-tree/styles.mjs +0 -105
  234. package/dist/esm/components/json-schema-editor/styles.mjs +0 -138
  235. package/dist/esm/components/prompt-editor/styles.mjs +0 -11
  236. package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +0 -13
  237. package/dist/esm/components/prompt-editor-with-variables/editor.mjs +0 -14
  238. package/dist/types/components/batch-outputs/styles.d.ts +0 -6
  239. package/dist/types/components/condition-row/styles.d.ts +0 -9
  240. package/dist/types/components/coze-editor-extensions/styles.d.ts +0 -9
  241. package/dist/types/components/db-condition-row/styles.d.ts +0 -12
  242. package/dist/types/components/display-inputs-values/styles.d.ts +0 -5
  243. package/dist/types/components/display-outputs/styles.d.ts +0 -5
  244. package/dist/types/components/display-schema-tag/styles.d.ts +0 -8
  245. package/dist/types/components/display-schema-tree/styles.d.ts +0 -11
  246. package/dist/types/components/dynamic-value-input/styles.d.ts +0 -8
  247. package/dist/types/components/inputs-values/styles.d.ts +0 -6
  248. package/dist/types/components/inputs-values-tree/styles.d.ts +0 -23
  249. package/dist/types/components/json-schema-editor/styles.d.ts +0 -30
  250. package/dist/types/components/prompt-editor/styles.d.ts +0 -7
  251. package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +0 -10
  252. package/dist/types/components/prompt-editor-with-variables/editor.d.ts +0 -9
  253. package/dist/types/components/variable-selector/styles.d.ts +0 -14
  254. package/src/components/inputs-values-tree/styles.tsx +0 -128
  255. package/src/components/json-schema-editor/styles.tsx +0 -168
  256. package/src/components/prompt-editor/styles.tsx +0 -18
  257. package/src/components/prompt-editor-with-inputs/editor.tsx +0 -24
  258. package/src/components/prompt-editor-with-variables/editor.tsx +0 -20
  259. package/src/shared/inject-material/README.md +0 -170
  260. package/src/shared/inject-material/README.zh.md +0 -174
@@ -15,31 +15,23 @@ import { InjectDynamicValueInput } from '@/components/dynamic-value-input';
15
15
  import { IConditionRule, ConditionOpConfigs, useCondition } from '@/components/condition-context';
16
16
 
17
17
  import { ConditionRowValueType } from './types';
18
- import { UIContainer, UILeft, UIOperator, UIRight, UIValues } from './styles';
18
+ import './styles.css';
19
19
 
20
20
  interface PropTypes {
21
21
  value?: ConditionRowValueType;
22
22
  onChange: (value?: ConditionRowValueType) => void;
23
23
  style?: React.CSSProperties;
24
24
  readonly?: boolean;
25
+ /**
26
+ * @deprecated use ConditionContext instead to pass ruleConfig to multiple
27
+ */
25
28
  ruleConfig?: {
26
29
  ops?: ConditionOpConfigs;
27
30
  rules?: Record<string, IConditionRule>;
28
31
  };
29
32
  }
30
33
 
31
- const defaultRuleConfig = {
32
- ops: {},
33
- rules: {},
34
- };
35
-
36
- export function ConditionRow({
37
- style,
38
- value,
39
- onChange,
40
- readonly,
41
- ruleConfig = defaultRuleConfig,
42
- }: PropTypes) {
34
+ export function ConditionRow({ style, value, onChange, readonly, ruleConfig }: PropTypes) {
43
35
  const { left, operator, right } = value || {};
44
36
 
45
37
  const available = useScopeAvailable();
@@ -57,6 +49,19 @@ export function ConditionRow({
57
49
  const { rule, opConfig, opOptionList, targetSchema } = useCondition({
58
50
  leftSchema,
59
51
  operator,
52
+ ruleConfig,
53
+ onClearOp() {
54
+ onChange({
55
+ ...value,
56
+ operator: undefined,
57
+ });
58
+ },
59
+ onClearRight() {
60
+ onChange({
61
+ ...value,
62
+ right: undefined,
63
+ });
64
+ },
60
65
  });
61
66
 
62
67
  const renderOpSelect = () => (
@@ -81,10 +86,10 @@ export function ConditionRow({
81
86
  );
82
87
 
83
88
  return (
84
- <UIContainer style={style}>
85
- <UIOperator>{renderOpSelect()}</UIOperator>
86
- <UIValues>
87
- <UILeft>
89
+ <div className="gedit-m-condition-row-container" style={style}>
90
+ <div className="gedit-m-condition-row-operator">{renderOpSelect()}</div>
91
+ <div className="gedit-m-condition-row-values">
92
+ <div className="gedit-m-condition-row-left">
88
93
  <InjectVariableSelector
89
94
  readonly={readonly}
90
95
  style={{ width: '100%' }}
@@ -99,8 +104,8 @@ export function ConditionRow({
99
104
  })
100
105
  }
101
106
  />
102
- </UILeft>
103
- <UIRight>
107
+ </div>
108
+ <div className="gedit-m-condition-row-right">
104
109
  {targetSchema ? (
105
110
  <InjectDynamicValueInput
106
111
  readonly={readonly || !rule}
@@ -116,9 +121,9 @@ export function ConditionRow({
116
121
  value={opConfig?.rightDisplay || I18n.t('Empty')}
117
122
  />
118
123
  )}
119
- </UIRight>
120
- </UIValues>
121
- </UIContainer>
124
+ </div>
125
+ </div>
126
+ </div>
122
127
  );
123
128
  }
124
129
 
@@ -3,28 +3,28 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import styled from 'styled-components';
7
-
8
- export const UIContainer = styled.div`
6
+ .gedit-m-condition-row-container {
9
7
  display: flex;
10
8
  align-items: center;
11
9
  gap: 4px;
12
- `;
10
+ }
13
11
 
14
- export const UIOperator = styled.div``;
12
+ .gedit-m-condition-row-operator {
13
+ }
15
14
 
16
- export const UILeft = styled.div`
15
+ .gedit-m-condition-row-left {
17
16
  width: 100%;
18
- `;
17
+ }
19
18
 
20
- export const UIRight = styled.div`
19
+ .gedit-m-condition-row-right {
21
20
  width: 100%;
22
- `;
21
+ }
23
22
 
24
- export const UIValues = styled.div`
23
+ .gedit-m-condition-row-values {
25
24
  flex-grow: 1;
26
25
  display: flex;
27
26
  flex-direction: column;
28
27
  align-items: center;
29
28
  gap: 4px;
30
- `;
29
+ overflow: hidden;
30
+ }
@@ -11,7 +11,7 @@ import {
11
11
  ASTMatch,
12
12
  type BaseType,
13
13
  type BaseVariableField,
14
- useScopeAvailable,
14
+ useCurrentScope,
15
15
  } from '@flowgram.ai/editor';
16
16
  import {
17
17
  Mention,
@@ -24,7 +24,8 @@ import { EditorAPI } from '@flowgram.ai/coze-editor/preset-prompt';
24
24
  import { type TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
25
25
  import { Tree, Popover } from '@douyinfe/semi-ui';
26
26
 
27
- import { IFlowValue, FlowValueUtils } from '@/shared';
27
+ import { IInputsValues } from '@/shared/flow-value/types';
28
+ import { FlowValueUtils } from '@/shared';
28
29
 
29
30
  type VariableField = BaseVariableField<{ icon?: string | JSX.Element; title?: string }>;
30
31
 
@@ -32,10 +33,10 @@ export function InputsPicker({
32
33
  inputsValues,
33
34
  onSelect,
34
35
  }: {
35
- inputsValues: any;
36
+ inputsValues: IInputsValues;
36
37
  onSelect: (v: string) => void;
37
38
  }) {
38
- const available = useScopeAvailable();
39
+ const scope = useCurrentScope();
39
40
 
40
41
  const getArrayDrilldown = (type: ArrayType, depth = 1): { type: BaseType; depth: number } => {
41
42
  if (ASTMatch.isArray(type.items)) {
@@ -89,7 +90,7 @@ export function InputsPicker({
89
90
 
90
91
  if (FlowValueUtils.isFlowValue(value)) {
91
92
  if (FlowValueUtils.isRef(value)) {
92
- const variable = available.getByKeyPath(value.content || []);
93
+ const variable = scope?.available?.getByKeyPath(value.content || []);
93
94
  if (variable) {
94
95
  return renderVariable(variable, keyPath);
95
96
  }
@@ -130,7 +131,7 @@ export function InputsTree({
130
131
  inputsValues,
131
132
  triggerCharacters = DEFAULT_TRIGGER_CHARACTERS,
132
133
  }: {
133
- inputsValues: Record<string, IFlowValue>;
134
+ inputsValues: IInputsValues;
134
135
  triggerCharacters?: string[];
135
136
  }) {
136
137
  const [posKey, setPosKey] = useState('');
@@ -14,7 +14,7 @@ import {
14
14
  useCurrentScope,
15
15
  } from '@flowgram.ai/editor';
16
16
  import { useInjector } from '@flowgram.ai/coze-editor/react';
17
- import { Popover } from '@douyinfe/semi-ui';
17
+ import { Popover, Tag } from '@douyinfe/semi-ui';
18
18
  import { IconIssueStroked } from '@douyinfe/semi-icons';
19
19
  import {
20
20
  Decoration,
@@ -27,7 +27,7 @@ import {
27
27
 
28
28
  import { IPolyfillRoot, polyfillCreateRoot } from '@/shared';
29
29
 
30
- import { UIPopoverContent, UIRootTitle, UITag, UIVarName } from '../styles';
30
+ import '../styles.css';
31
31
 
32
32
  class VariableTagWidget extends WidgetType {
33
33
  keyPath?: string[];
@@ -56,9 +56,10 @@ class VariableTagWidget extends WidgetType {
56
56
  renderVariable(v?: BaseVariableField) {
57
57
  if (!v) {
58
58
  this.root.render(
59
- <UITag prefixIcon={<IconIssueStroked />} color="amber">
60
- Unknown
61
- </UITag>
59
+ <Tag className="gedit-m-coze-editor-tag" color="amber">
60
+ <IconIssueStroked style={{ marginRight: '4px' }} />
61
+ <span>Unknown</span>
62
+ </Tag>
62
63
  );
63
64
  return;
64
65
  }
@@ -67,26 +68,30 @@ class VariableTagWidget extends WidgetType {
67
68
  const isRoot = v === rootField;
68
69
 
69
70
  const rootTitle = (
70
- <UIRootTitle>
71
+ <span className="gedit-m-coze-editor-root-title">
71
72
  {rootField.meta?.title ? `${rootField.meta.title} ${isRoot ? '' : '-'} ` : ''}
72
- </UIRootTitle>
73
+ </span>
73
74
  );
74
75
  const rootIcon = this.renderIcon(rootField?.meta.icon);
75
76
 
76
77
  this.root.render(
77
78
  <Popover
78
79
  content={
79
- <UIPopoverContent>
80
+ <div className="gedit-m-coze-editor-popover-content">
80
81
  {rootIcon}
81
82
  {rootTitle}
82
- <UIVarName>{v?.keyPath.slice(1).join('.')}</UIVarName>
83
- </UIPopoverContent>
83
+ <span className="gedit-m-coze-editor-var-name">{v?.keyPath.slice(1).join('.')}</span>
84
+ </div>
84
85
  }
85
86
  >
86
- <UITag prefixIcon={rootIcon}>
87
+ <Tag
88
+ className="gedit-m-coze-editor-tag"
89
+ style={{ display: 'inline-flex', alignItems: 'center' }}
90
+ >
91
+ {rootIcon}
87
92
  {rootTitle}
88
- {!isRoot && <UIVarName>{v?.key}</UIVarName>}
89
- </UITag>
93
+ {!isRoot && <span className="gedit-m-coze-editor-var-name">{v?.key}</span>}
94
+ </Tag>
90
95
  </Popover>
91
96
  );
92
97
  }
@@ -102,17 +107,25 @@ class VariableTagWidget extends WidgetType {
102
107
  })
103
108
  );
104
109
 
110
+ const refresh = () => {
111
+ this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
112
+ };
113
+
105
114
  this.toDispose.push(
106
- this.scope.available.trackByKeyPath(
107
- this.keyPath,
108
- (v) => {
109
- this.renderVariable(v);
110
- },
111
- { triggerOnInit: false }
112
- )
115
+ this.scope.available.trackByKeyPath(this.keyPath, refresh, { triggerOnInit: false })
113
116
  );
114
117
 
115
- this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
118
+ if (this.keyPath?.[0]) {
119
+ this.toDispose.push(
120
+ // listen to root title changed
121
+ this.scope.available.trackByKeyPath<{ title?: string }>([this.keyPath[0]], refresh, {
122
+ selector: (curr) => ({ ...curr?.meta }),
123
+ triggerOnInit: false,
124
+ })
125
+ );
126
+ }
127
+
128
+ refresh();
116
129
 
117
130
  return dom;
118
131
  }
@@ -133,7 +146,7 @@ class VariableTagWidget extends WidgetType {
133
146
  export function VariableTagInject() {
134
147
  const injector = useInjector();
135
148
 
136
- const scope = useCurrentScope();
149
+ const scope = useCurrentScope({ strict: true });
137
150
 
138
151
  // 基于 {{var}} 的正则进行匹配,匹配后进行自定义渲染
139
152
  useLayoutEffect(() => {
@@ -3,8 +3,9 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import React, { useEffect, useState } from 'react';
6
+ import React, { useCallback, useEffect, useState } from 'react';
7
7
 
8
+ import { debounce } from 'lodash-es';
8
9
  import {
9
10
  Mention,
10
11
  MentionOpenChangeEvent,
@@ -69,6 +70,11 @@ export function VariableTree({
69
70
 
70
71
  const treeData = useVariableTree({});
71
72
 
73
+ const debounceUpdatePosKey = useCallback(
74
+ debounce(() => setPosKey(String(Math.random())), 100),
75
+ []
76
+ );
77
+
72
78
  return (
73
79
  <>
74
80
  <Mention triggerCharacters={triggerCharacters} onOpenChange={handleOpenChange} />
@@ -82,8 +88,9 @@ export function VariableTree({
82
88
  <div style={{ width: 300, maxHeight: 300, overflowY: 'auto' }}>
83
89
  <Tree
84
90
  treeData={treeData}
85
- onExpand={(v) => {
86
- setPosKey(String(Math.random()));
91
+ onExpand={() => {
92
+ // When Expand, an animation is triggered, so we need to update the position by debounce
93
+ debounceUpdatePosKey();
87
94
  }}
88
95
  onSelect={(v) => {
89
96
  insert(v);
@@ -96,7 +103,10 @@ export function VariableTree({
96
103
  <PositionMirror
97
104
  position={position}
98
105
  // When Doc scroll, update position
99
- onChange={() => setPosKey(String(Math.random()))}
106
+ onChange={() => {
107
+ // Update immediately to avoid the popover position lagging behind the cursor
108
+ setPosKey(String(Math.random()));
109
+ }}
100
110
  />
101
111
  </Popover>
102
112
  </>
@@ -3,25 +3,22 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import styled from 'styled-components';
7
- import { Tag } from '@douyinfe/semi-ui';
8
-
9
- export const UIRootTitle = styled.div`
6
+ .gedit-m-coze-editor-root-title {
10
7
  margin-right: 4px;
11
8
  min-width: 20px;
12
9
  overflow: hidden;
13
10
  text-overflow: ellipsis;
14
11
  white-space: nowrap;
15
12
  color: var(--semi-color-text-2);
16
- `;
13
+ }
17
14
 
18
- export const UIVarName = styled.div`
15
+ .gedit-m-coze-editor-var-name {
19
16
  overflow: hidden;
20
17
  text-overflow: ellipsis;
21
18
  white-space: nowrap;
22
- `;
19
+ }
23
20
 
24
- export const UITag = styled(Tag)`
21
+ .gedit-m-coze-editor-tag {
25
22
  display: inline-flex;
26
23
  align-items: center;
27
24
  justify-content: flex-start;
@@ -34,11 +31,11 @@ export const UITag = styled(Tag)`
34
31
  &.semi-tag {
35
32
  margin: 0 5px;
36
33
  }
37
- `;
34
+ }
38
35
 
39
- export const UIPopoverContent = styled.div`
36
+ .gedit-m-coze-editor-popover-content {
40
37
  padding: 10px;
41
38
  display: inline-flex;
42
39
  align-items: center;
43
40
  justify-content: flex-start;
44
- `;
41
+ }
@@ -18,15 +18,7 @@ import {
18
18
  } from '@/components/condition-context';
19
19
 
20
20
  import { DBConditionOptionType, DBConditionRowValueType } from './types';
21
- import {
22
- UIContainer,
23
- UILeft,
24
- UIOperator,
25
- UIOptionLabel,
26
- UIRight,
27
- UISelect,
28
- UIValues,
29
- } from './styles';
21
+ import './styles.css';
30
22
 
31
23
  interface PropTypes {
32
24
  value?: DBConditionRowValueType;
@@ -34,24 +26,22 @@ interface PropTypes {
34
26
  style?: React.CSSProperties;
35
27
  options?: DBConditionOptionType[];
36
28
  readonly?: boolean;
29
+ /**
30
+ * @deprecated use ConditionContext instead to pass ruleConfig to multiple
31
+ */
37
32
  ruleConfig?: {
38
33
  ops?: ConditionOpConfigs;
39
34
  rules?: Record<string, IConditionRule>;
40
35
  };
41
36
  }
42
37
 
43
- const defaultRuleConfig = {
44
- ops: {},
45
- rules: {},
46
- };
47
-
48
38
  export function DBConditionRow({
49
39
  style,
50
40
  value,
51
41
  onChange,
52
42
  readonly,
53
43
  options,
54
- ruleConfig = defaultRuleConfig,
44
+ ruleConfig,
55
45
  }: PropTypes) {
56
46
  const { left, operator, right } = value || {};
57
47
 
@@ -66,10 +56,23 @@ export function DBConditionRow({
66
56
  leftSchema,
67
57
  operator,
68
58
  ruleConfig,
59
+ onClearOp() {
60
+ onChange({
61
+ ...value,
62
+ operator: undefined,
63
+ });
64
+ },
65
+ onClearRight() {
66
+ onChange({
67
+ ...value,
68
+ right: undefined,
69
+ });
70
+ },
69
71
  });
70
72
 
71
73
  const renderDBOptionSelect = () => (
72
- <UISelect
74
+ <Select
75
+ className="gedit-m-db-condition-row-select"
73
76
  disabled={readonly}
74
77
  size="small"
75
78
  style={{ width: '100%' }}
@@ -83,10 +86,10 @@ export function DBConditionRow({
83
86
  optionList={
84
87
  options?.map((item) => ({
85
88
  label: (
86
- <UIOptionLabel>
89
+ <div className="gedit-m-db-condition-row-option-label">
87
90
  <Icon size="small" svg={typeManager.getDisplayIcon(item.schema)} />
88
91
  {item.label}
89
- </UIOptionLabel>
92
+ </div>
90
93
  ),
91
94
  value: item.value,
92
95
  })) || []
@@ -116,11 +119,11 @@ export function DBConditionRow({
116
119
  );
117
120
 
118
121
  return (
119
- <UIContainer style={style}>
120
- <UIOperator>{renderOpSelect()}</UIOperator>
121
- <UIValues>
122
- <UILeft>{renderDBOptionSelect()}</UILeft>
123
- <UIRight>
122
+ <div className="gedit-m-db-condition-row-container" style={style}>
123
+ <div className="gedit-m-db-condition-row-operator">{renderOpSelect()}</div>
124
+ <div className="gedit-m-db-condition-row-values">
125
+ <div className="gedit-m-db-condition-row-left">{renderDBOptionSelect()}</div>
126
+ <div className="gedit-m-db-condition-row-right">
124
127
  {targetSchema ? (
125
128
  <InjectDynamicValueInput
126
129
  readonly={readonly || !rule}
@@ -136,9 +139,9 @@ export function DBConditionRow({
136
139
  value={opConfig?.rightDisplay || I18n.t('Empty')}
137
140
  />
138
141
  )}
139
- </UIRight>
140
- </UIValues>
141
- </UIContainer>
142
+ </div>
143
+ </div>
144
+ </div>
142
145
  );
143
146
  }
144
147
 
@@ -3,41 +3,39 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import styled from 'styled-components';
7
- import { Select } from '@douyinfe/semi-ui';
8
-
9
- export const UIContainer = styled.div`
6
+ .gedit-m-db-condition-row-container {
10
7
  display: flex;
11
8
  align-items: center;
12
9
  gap: 4px;
13
- `;
10
+ }
14
11
 
15
- export const UIOperator = styled.div``;
12
+ .gedit-m-db-condition-row-operator {
13
+ }
16
14
 
17
- export const UILeft = styled.div`
15
+ .gedit-m-db-condition-row-left {
18
16
  width: 100%;
19
- `;
17
+ }
20
18
 
21
- export const UIRight = styled.div`
19
+ .gedit-m-db-condition-row-right {
22
20
  width: 100%;
23
- `;
21
+ }
24
22
 
25
- export const UIValues = styled.div`
23
+ .gedit-m-db-condition-row-values {
26
24
  flex-grow: 1;
27
25
  display: flex;
28
26
  flex-direction: column;
29
27
  align-items: center;
30
28
  gap: 4px;
31
- `;
29
+ }
32
30
 
33
- export const UIOptionLabel = styled.div`
31
+ .gedit-m-db-condition-row-option-label {
34
32
  display: flex;
35
33
  align-items: center;
36
34
  gap: 10px;
37
- `;
35
+ }
38
36
 
39
- export const UISelect = styled(Select)`
37
+ .gedit-m-db-condition-row-select {
40
38
  & .semi-select-selection {
41
39
  margin-left: 5px;
42
40
  }
43
- `;
41
+ }
@@ -9,7 +9,6 @@ import { IFlowConstantRefValue } from '@/shared';
9
9
 
10
10
  export interface DBConditionRowValueType {
11
11
  left?: string;
12
- schema?: IJsonSchema;
13
12
  operator?: string;
14
13
  right?: IFlowConstantRefValue;
15
14
  }
@@ -8,14 +8,15 @@ import React, { useMemo } from 'react';
8
8
  import { isPlainObject } from 'lodash-es';
9
9
  import { useScopeAvailable } from '@flowgram.ai/editor';
10
10
 
11
+ import { IInputsValues } from '@/shared/flow-value';
11
12
  import { FlowValueUtils } from '@/shared';
12
13
  import { DisplayFlowValue } from '@/components/display-flow-value';
13
14
 
14
- import { DisplayInputsWrapper } from './styles';
15
+ import './styles.css';
15
16
  import { DisplaySchemaTag } from '../display-schema-tag';
16
17
 
17
18
  interface PropsType {
18
- value?: any;
19
+ value?: IInputsValues;
19
20
  showIconInTree?: boolean;
20
21
  }
21
22
 
@@ -23,7 +24,7 @@ export function DisplayInputsValues({ value, showIconInTree }: PropsType) {
23
24
  const childEntries = Object.entries(value || {});
24
25
 
25
26
  return (
26
- <DisplayInputsWrapper>
27
+ <div className="gedit-m-display-inputs-wrapper">
27
28
  {childEntries.map(([key, value]) => {
28
29
  if (FlowValueUtils.isFlowValue(value)) {
29
30
  return (
@@ -44,7 +45,7 @@ export function DisplayInputsValues({ value, showIconInTree }: PropsType) {
44
45
 
45
46
  return null;
46
47
  })}
47
- </DisplayInputsWrapper>
48
+ </div>
48
49
  );
49
50
  }
50
51
 
@@ -3,10 +3,8 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import styled from 'styled-components';
7
-
8
- export const DisplayInputsWrapper = styled.div`
6
+ .gedit-m-display-inputs-wrapper {
9
7
  display: flex;
10
8
  gap: 5px;
11
9
  flex-wrap: wrap;
12
- `;
10
+ }
@@ -3,28 +3,29 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import React, { useEffect } from 'react';
6
+ import React, { useLayoutEffect } from 'react';
7
7
 
8
8
  import { IJsonSchema, JsonSchemaTypeManager, JsonSchemaUtils } from '@flowgram.ai/json-schema';
9
9
  import { useCurrentScope, useRefresh } from '@flowgram.ai/editor';
10
10
 
11
11
  import { DisplaySchemaTag } from '@/components/display-schema-tag';
12
12
 
13
- import { DisplayOutputsWrapper } from './styles';
13
+ import './styles.css';
14
14
 
15
15
  interface PropsType {
16
16
  value?: IJsonSchema;
17
17
  showIconInTree?: boolean;
18
18
  displayFromScope?: boolean;
19
19
  typeManager?: JsonSchemaTypeManager;
20
+ style?: React.CSSProperties;
20
21
  }
21
22
 
22
- export function DisplayOutputs({ value, showIconInTree, displayFromScope }: PropsType) {
23
+ export function DisplayOutputs({ value, showIconInTree, displayFromScope, style }: PropsType) {
23
24
  const scope = useCurrentScope();
24
25
  const refresh = useRefresh();
25
26
 
26
- useEffect(() => {
27
- if (!displayFromScope) {
27
+ useLayoutEffect(() => {
28
+ if (!displayFromScope || !scope) {
28
29
  return () => null;
29
30
  }
30
31
 
@@ -38,7 +39,7 @@ export function DisplayOutputs({ value, showIconInTree, displayFromScope }: Prop
38
39
  }, [displayFromScope]);
39
40
 
40
41
  const properties: IJsonSchema['properties'] = displayFromScope
41
- ? scope.output.variables?.reduce((acm, curr) => {
42
+ ? (scope?.output.variables || []).reduce((acm, curr) => {
42
43
  acm = {
43
44
  ...acm,
44
45
  ...(JsonSchemaUtils.astToSchema(curr.type)?.properties || {}),
@@ -50,7 +51,7 @@ export function DisplayOutputs({ value, showIconInTree, displayFromScope }: Prop
50
51
  const childEntries = Object.entries(properties || {});
51
52
 
52
53
  return (
53
- <DisplayOutputsWrapper>
54
+ <div className="gedit-m-display-outputs-wrapper" style={style}>
54
55
  {childEntries.map(([key, schema]) => (
55
56
  <DisplaySchemaTag
56
57
  key={key}
@@ -60,6 +61,6 @@ export function DisplayOutputs({ value, showIconInTree, displayFromScope }: Prop
60
61
  warning={!schema}
61
62
  />
62
63
  ))}
63
- </DisplayOutputsWrapper>
64
+ </div>
64
65
  );
65
66
  }