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

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 (272) hide show
  1. package/bin/run.sh +3 -2
  2. package/dist/cjs/components/blur-input/index.js +2 -12
  3. package/dist/cjs/components/code-editor/editor-all.js +52 -0
  4. package/dist/cjs/components/code-editor/editor-json.js +71 -0
  5. package/dist/cjs/components/code-editor/editor-python.js +63 -0
  6. package/dist/cjs/components/code-editor/editor-shell.js +63 -0
  7. package/dist/cjs/components/code-editor/editor-sql.js +71 -0
  8. package/dist/cjs/components/code-editor/editor-ts.js +80 -0
  9. package/dist/cjs/components/code-editor/editor.js +45 -57
  10. package/dist/cjs/components/code-editor/factory.js +96 -0
  11. package/dist/cjs/components/code-editor/index.js +31 -28
  12. package/dist/cjs/components/code-editor/theme/dark.js +120 -50
  13. package/dist/cjs/components/code-editor/theme/light.js +110 -61
  14. package/dist/cjs/components/code-editor/utils.js +1 -0
  15. package/dist/cjs/components/condition-context/context.js +59 -0
  16. package/dist/cjs/components/condition-context/hooks/use-condition.js +97 -0
  17. package/dist/cjs/components/condition-context/index.js +47 -0
  18. package/dist/cjs/components/condition-context/op.js +117 -0
  19. package/dist/cjs/components/condition-row/index.js +43 -26
  20. package/dist/cjs/components/condition-row/types.js +1 -35
  21. package/dist/cjs/components/{prompt-editor-with-inputs/inputs-picker.js → coze-editor-extensions/extensions/inputs-tree.js} +70 -2
  22. package/dist/cjs/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.js +4 -3
  23. package/dist/cjs/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.js +13 -7
  24. package/dist/cjs/components/coze-editor-extensions/index.js +86 -0
  25. package/dist/cjs/components/db-condition-row/index.js +59 -34
  26. package/dist/cjs/components/display-schema-tree/index.js +2 -2
  27. package/dist/cjs/components/index.js +49 -4
  28. package/dist/cjs/components/json-editor-with-variables/editor.js +10 -7
  29. package/dist/cjs/components/prompt-editor-with-inputs/editor.js +2 -2
  30. package/dist/cjs/components/prompt-editor-with-variables/editor.js +3 -4
  31. package/dist/cjs/components/{condition-row/hooks/useRule.js → sql-editor-with-variables/editor.js} +19 -34
  32. package/dist/cjs/components/sql-editor-with-variables/index.js +57 -0
  33. package/dist/cjs/components/type-selector/index.js +2 -2
  34. package/dist/cjs/components/variable-selector/use-variable-tree.js +1 -2
  35. package/dist/cjs/effects/provide-batch-input/index.js +1 -1
  36. package/dist/cjs/effects/provide-json-schema-outputs/index.js +1 -1
  37. package/dist/cjs/form-plugins/batch-outputs-plugin/index.js +9 -2
  38. package/dist/cjs/form-plugins/infer-assign-plugin/index.js +1 -1
  39. package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +30 -3
  40. package/dist/cjs/index.js +44 -2
  41. package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +1 -0
  42. package/dist/cjs/plugins/json-schema-preset/index.js +3 -13
  43. package/dist/cjs/{components/code-editor/init-worker.js → plugins/json-schema-preset/react.js} +18 -23
  44. package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +33 -4
  45. package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +23 -0
  46. package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +31 -2
  47. package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +9 -1
  48. package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +34 -1
  49. package/dist/cjs/plugins/json-schema-preset/type-definition/map.js +54 -0
  50. package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +34 -1
  51. package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +9 -4
  52. package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +30 -1
  53. package/dist/cjs/plugins/json-schema-preset/types.js +18 -0
  54. package/dist/cjs/shared/flow-value/utils.js +22 -8
  55. package/dist/cjs/shared/inject-material/index.js +2 -1
  56. package/dist/esm/components/blur-input/index.mjs +2 -2
  57. package/dist/esm/components/code-editor/editor-all.mjs +18 -0
  58. package/dist/esm/components/code-editor/editor-json.mjs +16 -0
  59. package/dist/esm/components/code-editor/editor-python.mjs +8 -0
  60. package/dist/esm/components/code-editor/editor-shell.mjs +8 -0
  61. package/dist/esm/components/code-editor/editor-sql.mjs +16 -0
  62. package/dist/esm/components/code-editor/editor-ts.mjs +22 -0
  63. package/dist/esm/components/code-editor/editor.mjs +38 -33
  64. package/dist/esm/components/code-editor/factory.mjs +36 -0
  65. package/dist/esm/components/code-editor/index.mjs +8 -5
  66. package/dist/esm/components/code-editor/theme/dark.mjs +117 -50
  67. package/dist/esm/components/code-editor/theme/light.mjs +108 -62
  68. package/dist/esm/components/code-editor/utils.mjs +1 -0
  69. package/dist/esm/components/condition-context/context.mjs +19 -0
  70. package/dist/esm/components/condition-context/hooks/use-condition.mjs +63 -0
  71. package/dist/esm/components/condition-context/index.mjs +4 -0
  72. package/dist/esm/components/condition-context/op.mjs +80 -0
  73. package/dist/esm/components/condition-row/index.mjs +45 -28
  74. package/dist/esm/components/condition-row/types.mjs +0 -18
  75. package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +135 -0
  76. package/dist/esm/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.mjs +4 -3
  77. package/dist/esm/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.mjs +13 -7
  78. package/dist/esm/components/coze-editor-extensions/index.mjs +18 -0
  79. package/dist/esm/components/db-condition-row/index.mjs +59 -34
  80. package/dist/esm/components/display-schema-tree/index.mjs +1 -1
  81. package/dist/esm/components/index.mjs +5 -2
  82. package/dist/esm/components/json-editor-with-variables/editor.mjs +10 -7
  83. package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +2 -2
  84. package/dist/esm/components/prompt-editor-with-variables/editor.mjs +3 -4
  85. package/dist/esm/components/sql-editor-with-variables/editor.mjs +19 -0
  86. package/dist/esm/components/sql-editor-with-variables/index.mjs +5 -0
  87. package/dist/esm/components/type-selector/index.mjs +1 -1
  88. package/dist/esm/components/variable-selector/use-variable-tree.mjs +1 -2
  89. package/dist/esm/effects/provide-batch-input/index.mjs +2 -2
  90. package/dist/esm/effects/provide-json-schema-outputs/index.mjs +2 -2
  91. package/dist/esm/form-plugins/batch-outputs-plugin/index.mjs +10 -3
  92. package/dist/esm/form-plugins/infer-assign-plugin/index.mjs +2 -2
  93. package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +31 -4
  94. package/dist/esm/index.mjs +2 -2
  95. package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +2 -1
  96. package/dist/esm/plugins/json-schema-preset/index.mjs +3 -13
  97. package/dist/esm/plugins/json-schema-preset/react.mjs +14 -0
  98. package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +33 -4
  99. package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +23 -0
  100. package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +31 -2
  101. package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +7 -2
  102. package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +34 -1
  103. package/dist/esm/plugins/json-schema-preset/type-definition/map.mjs +20 -0
  104. package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +34 -1
  105. package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +9 -4
  106. package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +30 -1
  107. package/dist/esm/plugins/json-schema-preset/types.mjs +0 -0
  108. package/dist/esm/shared/flow-value/utils.mjs +22 -8
  109. package/dist/esm/shared/inject-material/index.mjs +2 -1
  110. package/dist/tsconfig.tsbuildinfo +1 -1
  111. package/dist/types/components/blur-input/index.d.ts +7 -1
  112. package/dist/types/components/code-editor/editor-all.d.ts +8 -0
  113. package/dist/types/components/code-editor/editor-json.d.ts +6 -0
  114. package/dist/types/components/code-editor/editor-python.d.ts +6 -0
  115. package/dist/types/components/code-editor/editor-shell.d.ts +6 -0
  116. package/dist/types/components/code-editor/editor-sql.d.ts +6 -0
  117. package/dist/types/components/code-editor/editor-ts.d.ts +6 -0
  118. package/dist/types/components/code-editor/editor.d.ts +3 -4
  119. package/dist/types/components/code-editor/factory.d.ts +13 -0
  120. package/dist/types/components/code-editor/index.d.ts +7 -2
  121. package/dist/types/components/code-editor/theme/dark.d.ts +29 -0
  122. package/dist/types/components/code-editor/theme/light.d.ts +24 -0
  123. package/dist/types/components/code-editor/utils.d.ts +1 -1
  124. package/dist/types/components/code-editor-mini/index.d.ts +3 -0
  125. package/dist/types/components/condition-context/context.d.ts +14 -0
  126. package/dist/types/components/condition-context/hooks/use-condition.d.ts +29 -0
  127. package/dist/types/components/condition-context/index.d.ts +8 -0
  128. package/dist/types/components/condition-context/op.d.ts +22 -0
  129. package/dist/types/components/condition-context/types.d.ts +14 -0
  130. package/dist/types/components/condition-row/index.d.ts +4 -7
  131. package/dist/types/components/condition-row/types.d.ts +0 -24
  132. package/dist/types/components/{prompt-editor-with-inputs/inputs-picker.d.ts → coze-editor-extensions/extensions/inputs-tree.d.ts} +5 -0
  133. package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.d.ts +3 -1
  134. package/dist/types/components/coze-editor-extensions/index.d.ts +18 -0
  135. package/dist/types/components/db-condition-row/index.d.ts +4 -3
  136. package/dist/types/components/db-condition-row/types.d.ts +0 -8
  137. package/dist/types/components/display-schema-tree/index.d.ts +1 -1
  138. package/dist/types/components/dynamic-value-input/index.d.ts +3 -1
  139. package/dist/types/components/index.d.ts +4 -1
  140. package/dist/types/components/sql-editor-with-variables/editor.d.ts +9 -0
  141. package/dist/types/components/sql-editor-with-variables/index.d.ts +6 -0
  142. package/dist/types/components/type-selector/index.d.ts +3 -1
  143. package/dist/types/components/variable-selector/index.d.ts +4 -2
  144. package/dist/types/form-plugins/batch-outputs-plugin/index.d.ts +4 -0
  145. package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +4 -0
  146. package/dist/types/index.d.ts +1 -1
  147. package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +1 -1
  148. package/dist/types/plugins/json-schema-preset/index.d.ts +3 -7
  149. package/dist/types/plugins/json-schema-preset/react.d.ts +11 -0
  150. package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +1 -1
  151. package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +1 -1
  152. package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +1 -1
  153. package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +3 -1
  154. package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +1 -1
  155. package/dist/types/plugins/json-schema-preset/type-definition/map.d.ts +6 -0
  156. package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +1 -1
  157. package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +1 -1
  158. package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +1 -1
  159. package/dist/types/plugins/json-schema-preset/{manager.d.ts → types.d.ts} +5 -0
  160. package/dist/types/shared/flow-value/utils.d.ts +3 -1
  161. package/dist/types/shared/inject-material/index.d.ts +6 -4
  162. package/dist/types/validate/validate-flow-value/index.d.ts +1 -1
  163. package/package.json +56 -17
  164. package/src/components/blur-input/index.tsx +9 -1
  165. package/src/components/code-editor/editor-all.tsx +30 -0
  166. package/src/components/code-editor/editor-json.tsx +25 -0
  167. package/src/components/code-editor/editor-python.tsx +18 -0
  168. package/src/components/code-editor/editor-shell.tsx +18 -0
  169. package/src/components/code-editor/editor-sql.tsx +24 -0
  170. package/src/components/code-editor/editor-ts.tsx +31 -0
  171. package/src/components/code-editor/editor.tsx +45 -36
  172. package/src/components/code-editor/factory.tsx +61 -0
  173. package/src/components/code-editor/index.tsx +7 -7
  174. package/src/components/code-editor/theme/dark.ts +62 -77
  175. package/src/components/code-editor/theme/light.ts +60 -91
  176. package/src/components/code-editor/utils.ts +4 -0
  177. package/src/components/code-editor-mini/index.tsx +3 -0
  178. package/src/components/condition-context/context.tsx +28 -0
  179. package/src/components/condition-context/hooks/use-condition.tsx +99 -0
  180. package/src/components/condition-context/index.tsx +14 -0
  181. package/src/components/condition-context/op.ts +86 -0
  182. package/src/components/condition-context/types.ts +22 -0
  183. package/src/components/condition-row/index.tsx +44 -22
  184. package/src/components/condition-row/types.ts +0 -30
  185. package/src/components/{prompt-editor-with-inputs/inputs-picker.tsx → coze-editor-extensions/extensions/inputs-tree.tsx} +95 -5
  186. package/src/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.tsx +6 -3
  187. package/src/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.tsx +12 -3
  188. package/src/components/coze-editor-extensions/index.tsx +33 -0
  189. package/src/components/db-condition-row/index.tsx +76 -24
  190. package/src/components/db-condition-row/types.ts +0 -13
  191. package/src/components/display-schema-tree/index.tsx +6 -4
  192. package/src/components/index.ts +29 -1
  193. package/src/components/json-editor-with-variables/editor.tsx +7 -8
  194. package/src/components/prompt-editor-with-inputs/editor.tsx +2 -3
  195. package/src/components/prompt-editor-with-variables/editor.tsx +3 -5
  196. package/src/components/sql-editor-with-variables/editor.tsx +28 -0
  197. package/src/components/sql-editor-with-variables/index.tsx +12 -0
  198. package/src/components/type-selector/index.tsx +2 -3
  199. package/src/components/variable-selector/index.tsx +2 -2
  200. package/src/components/variable-selector/use-variable-tree.tsx +7 -4
  201. package/src/effects/provide-batch-input/index.ts +1 -2
  202. package/src/effects/provide-json-schema-outputs/index.ts +1 -2
  203. package/src/form-plugins/batch-outputs-plugin/index.ts +64 -46
  204. package/src/form-plugins/infer-assign-plugin/index.ts +1 -2
  205. package/src/form-plugins/infer-inputs-plugin/index.ts +62 -14
  206. package/src/index.ts +19 -0
  207. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +4 -2
  208. package/src/plugins/json-schema-preset/index.tsx +4 -20
  209. package/src/plugins/json-schema-preset/react.tsx +31 -0
  210. package/src/plugins/json-schema-preset/type-definition/array.tsx +13 -4
  211. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +17 -1
  212. package/src/plugins/json-schema-preset/type-definition/date-time.tsx +21 -2
  213. package/src/plugins/json-schema-preset/type-definition/index.tsx +10 -1
  214. package/src/plugins/json-schema-preset/type-definition/integer.tsx +19 -1
  215. package/src/plugins/json-schema-preset/type-definition/map.tsx +31 -0
  216. package/src/plugins/json-schema-preset/type-definition/number.tsx +19 -1
  217. package/src/plugins/json-schema-preset/type-definition/object.tsx +9 -4
  218. package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -1
  219. package/src/plugins/json-schema-preset/{manager.ts → types.ts} +7 -0
  220. package/src/shared/flow-value/utils.ts +22 -9
  221. package/src/shared/inject-material/index.tsx +10 -6
  222. package/src/validate/validate-flow-value/index.tsx +1 -2
  223. package/dist/cjs/components/code-editor/language-features.js +0 -21
  224. package/dist/cjs/components/condition-row/constants.js +0 -165
  225. package/dist/cjs/components/condition-row/hooks/useOp.js +0 -78
  226. package/dist/cjs/components/db-condition-row/hooks/use-left.js +0 -86
  227. package/dist/cjs/components/db-condition-row/hooks/use-op.js +0 -79
  228. package/dist/cjs/components/json-editor-with-variables/extensions/variable-tag.js +0 -151
  229. package/dist/cjs/components/json-editor-with-variables/extensions/variable-tree.js +0 -97
  230. package/dist/cjs/components/prompt-editor-with-inputs/extensions/inputs-tree.js +0 -101
  231. package/dist/cjs/components/prompt-editor-with-variables/styles.js +0 -89
  232. package/dist/esm/components/code-editor/init-worker.mjs +0 -19
  233. package/dist/esm/components/code-editor/language-features.mjs +0 -15
  234. package/dist/esm/components/condition-row/constants.mjs +0 -128
  235. package/dist/esm/components/condition-row/hooks/useOp.mjs +0 -44
  236. package/dist/esm/components/condition-row/hooks/useRule.mjs +0 -34
  237. package/dist/esm/components/db-condition-row/hooks/use-left.mjs +0 -52
  238. package/dist/esm/components/db-condition-row/hooks/use-op.mjs +0 -45
  239. package/dist/esm/components/json-editor-with-variables/extensions/variable-tree.mjs +0 -63
  240. package/dist/esm/components/prompt-editor-with-inputs/extensions/inputs-tree.mjs +0 -67
  241. package/dist/esm/components/prompt-editor-with-inputs/inputs-picker.mjs +0 -70
  242. package/dist/esm/components/prompt-editor-with-variables/extensions/variable-tag.mjs +0 -117
  243. package/dist/esm/components/prompt-editor-with-variables/styles.mjs +0 -36
  244. package/dist/types/components/code-editor/init-worker.d.ts +0 -5
  245. package/dist/types/components/code-editor/language-features.d.ts +0 -5
  246. package/dist/types/components/condition-row/constants.d.ts +0 -7
  247. package/dist/types/components/condition-row/hooks/useOp.d.ts +0 -18
  248. package/dist/types/components/condition-row/hooks/useRule.d.ts +0 -9
  249. package/dist/types/components/db-condition-row/hooks/use-left.d.ts +0 -18
  250. package/dist/types/components/db-condition-row/hooks/use-op.d.ts +0 -18
  251. package/dist/types/components/prompt-editor-with-inputs/extensions/inputs-tree.d.ts +0 -9
  252. package/dist/types/components/prompt-editor-with-variables/extensions/variable-tag.d.ts +0 -5
  253. package/dist/types/components/prompt-editor-with-variables/extensions/variable-tree.d.ts +0 -6
  254. package/dist/types/components/prompt-editor-with-variables/styles.d.ts +0 -9
  255. package/src/components/code-editor/init-worker.ts +0 -27
  256. package/src/components/code-editor/language-features.ts +0 -23
  257. package/src/components/condition-row/constants.ts +0 -134
  258. package/src/components/condition-row/hooks/useOp.tsx +0 -56
  259. package/src/components/condition-row/hooks/useRule.ts +0 -35
  260. package/src/components/db-condition-row/hooks/use-left.tsx +0 -66
  261. package/src/components/db-condition-row/hooks/use-op.tsx +0 -59
  262. package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +0 -174
  263. package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +0 -83
  264. package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +0 -94
  265. package/src/components/prompt-editor-with-variables/styles.tsx +0 -44
  266. /package/dist/cjs/{plugins/json-schema-preset/manager.js → components/condition-context/types.js} +0 -0
  267. /package/dist/cjs/components/{json-editor-with-variables → coze-editor-extensions}/styles.js +0 -0
  268. /package/dist/esm/{plugins/json-schema-preset/manager.mjs → components/condition-context/types.mjs} +0 -0
  269. /package/dist/esm/components/{json-editor-with-variables → coze-editor-extensions}/styles.mjs +0 -0
  270. /package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.d.ts +0 -0
  271. /package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/styles.d.ts +0 -0
  272. /package/src/components/{json-editor-with-variables → coze-editor-extensions}/styles.tsx +0 -0
@@ -1,52 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import { useTypeManager } from "@flowgram.ai/json-schema";
4
- import { Icon } from "@douyinfe/semi-ui";
5
- import { ConditionRow } from "../../index.mjs";
6
- import { UIOptionLabel, UISelect } from "../styles.mjs";
7
- const defaultRules = ConditionRow.defaultRules;
8
- function useLeft({ left, options, userRules, readonly, onChange }) {
9
- const rules = useMemo(()=>({
10
- ...defaultRules,
11
- ...userRules || {}
12
- }), [
13
- userRules
14
- ]);
15
- const typeManager = useTypeManager();
16
- const rule = useMemo(()=>{
17
- if (!left) return;
18
- const option = options?.find((item)=>item.value === left);
19
- if (!option?.schema?.type) return;
20
- return rules[option.schema.type];
21
- }, [
22
- left,
23
- options,
24
- rules
25
- ]);
26
- const renderDBOptionSelect = ()=>/*#__PURE__*/ jsx(UISelect, {
27
- disabled: readonly,
28
- size: "small",
29
- style: {
30
- width: '100%'
31
- },
32
- value: left,
33
- onChange: (v)=>onChange(v),
34
- optionList: options?.map((item)=>({
35
- label: /*#__PURE__*/ jsxs(UIOptionLabel, {
36
- children: [
37
- /*#__PURE__*/ jsx(Icon, {
38
- size: "small",
39
- svg: typeManager.getDisplayIcon(item.schema)
40
- }),
41
- item.label
42
- ]
43
- }),
44
- value: item.value
45
- })) || []
46
- });
47
- return {
48
- rule,
49
- renderDBOptionSelect
50
- };
51
- }
52
- export { useLeft };
@@ -1,45 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import { I18n } from "@flowgram.ai/editor";
4
- import { Button, Select } from "@douyinfe/semi-ui";
5
- import { IconChevronDownStroked } from "@douyinfe/semi-icons";
6
- import { ConditionRow } from "../../index.mjs";
7
- const defaultOpConfigs = ConditionRow.defaultOpConfigs;
8
- function useOp({ rule, op, onChange, readonly, userOps }) {
9
- const options = useMemo(()=>Object.keys(rule || {}).map((_op)=>({
10
- ...defaultOpConfigs[_op] || {},
11
- ...userOps?.[_op] || {},
12
- value: _op,
13
- label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
14
- })), [
15
- rule,
16
- userOps
17
- ]);
18
- const opConfig = useMemo(()=>defaultOpConfigs[op], [
19
- op
20
- ]);
21
- const renderOpSelect = ()=>/*#__PURE__*/ jsx(Select, {
22
- style: {
23
- height: 22
24
- },
25
- disabled: readonly,
26
- size: "small",
27
- value: op,
28
- optionList: options,
29
- onChange: (v)=>{
30
- onChange(v);
31
- },
32
- triggerRender: ({ value })=>/*#__PURE__*/ jsx(Button, {
33
- size: "small",
34
- disabled: !rule,
35
- children: opConfig?.abbreviation || /*#__PURE__*/ jsx(IconChevronDownStroked, {
36
- size: "small"
37
- })
38
- })
39
- });
40
- return {
41
- renderOpSelect,
42
- opConfig
43
- };
44
- }
45
- export { useOp };
@@ -1,63 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from "react";
3
- import { Mention, PositionMirror, getCurrentMentionReplaceRange, useEditor } from "@flowgram.ai/coze-editor/react";
4
- import { Popover, Tree } from "@douyinfe/semi-ui";
5
- import { useVariableTree } from "../../variable-selector/index.mjs";
6
- function VariableTree() {
7
- const [posKey, setPosKey] = useState('');
8
- const [visible, setVisible] = useState(false);
9
- const [position, setPosition] = useState(-1);
10
- const editor = useEditor();
11
- function insert(variablePath) {
12
- const range = getCurrentMentionReplaceRange(editor.$view.state);
13
- if (!range) return;
14
- editor.replaceText({
15
- ...range,
16
- text: '{{' + variablePath + '}}'
17
- });
18
- setVisible(false);
19
- }
20
- function handleOpenChange(e) {
21
- setPosition(e.state.selection.main.head);
22
- setVisible(e.value);
23
- }
24
- useEffect(()=>{
25
- if (!editor) return;
26
- }, [
27
- editor,
28
- visible
29
- ]);
30
- const treeData = useVariableTree({});
31
- return /*#__PURE__*/ jsxs(Fragment, {
32
- children: [
33
- /*#__PURE__*/ jsx(Mention, {
34
- triggerCharacters: [
35
- '@'
36
- ],
37
- onOpenChange: handleOpenChange
38
- }),
39
- /*#__PURE__*/ jsx(Popover, {
40
- visible: visible,
41
- trigger: "custom",
42
- position: "topLeft",
43
- rePosKey: posKey,
44
- content: /*#__PURE__*/ jsx("div", {
45
- style: {
46
- width: 300
47
- },
48
- children: /*#__PURE__*/ jsx(Tree, {
49
- treeData: treeData,
50
- onSelect: (v)=>{
51
- insert(v);
52
- }
53
- })
54
- }),
55
- children: /*#__PURE__*/ jsx(PositionMirror, {
56
- position: position,
57
- onChange: ()=>setPosKey(String(Math.random()))
58
- })
59
- })
60
- ]
61
- });
62
- }
63
- export { VariableTree };
@@ -1,67 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from "react";
3
- import { Mention, PositionMirror, getCurrentMentionReplaceRange, useEditor } from "@flowgram.ai/coze-editor/react";
4
- import { Popover } from "@douyinfe/semi-ui";
5
- import { InputsPicker } from "../inputs-picker.mjs";
6
- function InputsTree({ inputsValues }) {
7
- const [posKey, setPosKey] = useState('');
8
- const [visible, setVisible] = useState(false);
9
- const [position, setPosition] = useState(-1);
10
- const editor = useEditor();
11
- function insert(variablePath) {
12
- const range = getCurrentMentionReplaceRange(editor.$view.state);
13
- if (!range) return;
14
- let { from, to } = range;
15
- while('{' === editor.$view.state.doc.sliceString(from - 1, from))from--;
16
- while('}' === editor.$view.state.doc.sliceString(to, to + 1))to++;
17
- editor.replaceText({
18
- ...range,
19
- text: '{{' + variablePath + '}}'
20
- });
21
- setVisible(false);
22
- }
23
- function handleOpenChange(e) {
24
- setPosition(e.state.selection.main.head);
25
- setVisible(e.value);
26
- }
27
- useEffect(()=>{
28
- if (!editor) return;
29
- }, [
30
- editor,
31
- visible
32
- ]);
33
- return /*#__PURE__*/ jsxs(Fragment, {
34
- children: [
35
- /*#__PURE__*/ jsx(Mention, {
36
- triggerCharacters: [
37
- '{',
38
- '{}',
39
- '@'
40
- ],
41
- onOpenChange: handleOpenChange
42
- }),
43
- /*#__PURE__*/ jsx(Popover, {
44
- visible: visible,
45
- trigger: "custom",
46
- position: "topLeft",
47
- rePosKey: posKey,
48
- content: /*#__PURE__*/ jsx("div", {
49
- style: {
50
- width: 300
51
- },
52
- children: /*#__PURE__*/ jsx(InputsPicker, {
53
- inputsValues: inputsValues,
54
- onSelect: (v)=>{
55
- insert(v);
56
- }
57
- })
58
- }),
59
- children: /*#__PURE__*/ jsx(PositionMirror, {
60
- position: position,
61
- onChange: ()=>setPosKey(String(Math.random()))
62
- })
63
- })
64
- ]
65
- });
66
- }
67
- export { InputsTree };
@@ -1,70 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import { isPlainObject, last } from "lodash-es";
4
- import { ASTMatch, useScopeAvailable } from "@flowgram.ai/editor";
5
- import { Tree } from "@douyinfe/semi-ui";
6
- import { FlowValueUtils } from "../../shared/index.mjs";
7
- function InputsPicker({ inputsValues, onSelect }) {
8
- const available = useScopeAvailable();
9
- const getArrayDrilldown = (type, depth = 1)=>{
10
- if (ASTMatch.isArray(type.items)) return getArrayDrilldown(type.items, depth + 1);
11
- return {
12
- type: type.items,
13
- depth: depth
14
- };
15
- };
16
- const renderVariable = (variable, keyPath)=>{
17
- let type = variable?.type;
18
- let children;
19
- if (ASTMatch.isObject(type)) children = (type.properties || []).map((_property)=>renderVariable(_property, [
20
- ...keyPath,
21
- _property.key
22
- ])).filter(Boolean);
23
- if (ASTMatch.isArray(type)) {
24
- const drilldown = getArrayDrilldown(type);
25
- if (ASTMatch.isObject(drilldown.type)) children = (drilldown.type.properties || []).map((_property)=>renderVariable(_property, [
26
- ...keyPath,
27
- ...new Array(drilldown.depth).fill('[0]'),
28
- _property.key
29
- ])).filter(Boolean);
30
- }
31
- const key = keyPath.map((_key, idx)=>'[0]' === _key || 0 === idx ? _key : `.${_key}`).join('');
32
- return {
33
- key: key,
34
- label: last(keyPath),
35
- value: key,
36
- children
37
- };
38
- };
39
- const getTreeData = (value, keyPath)=>{
40
- const currKey = keyPath.join('.');
41
- if (FlowValueUtils.isFlowValue(value)) {
42
- if (FlowValueUtils.isRef(value)) {
43
- const variable = available.getByKeyPath(value.content || []);
44
- if (variable) return renderVariable(variable, keyPath);
45
- }
46
- return {
47
- key: currKey,
48
- value: currKey,
49
- label: last(keyPath)
50
- };
51
- }
52
- if (isPlainObject(value)) return {
53
- key: currKey,
54
- value: currKey,
55
- label: last(keyPath),
56
- children: Object.entries(value).map(([key, value])=>getTreeData(value, [
57
- ...keyPath,
58
- key
59
- ])).filter(Boolean)
60
- };
61
- };
62
- const treeData = useMemo(()=>Object.entries(inputsValues).map(([key, value])=>getTreeData(value, [
63
- key
64
- ])).filter(Boolean), []);
65
- return /*#__PURE__*/ jsx(Tree, {
66
- treeData: treeData,
67
- onSelect: (v)=>onSelect(v)
68
- });
69
- }
70
- export { InputsPicker };
@@ -1,117 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useLayoutEffect } from "react";
3
- import { isEqual, last } from "lodash-es";
4
- import { Disposable, DisposableCollection, useCurrentScope } from "@flowgram.ai/editor";
5
- import { useInjector } from "@flowgram.ai/coze-editor/react";
6
- import { Popover } from "@douyinfe/semi-ui";
7
- import { IconIssueStroked } from "@douyinfe/semi-icons";
8
- import { Decoration, EditorView, MatchDecorator, ViewPlugin, WidgetType } from "@codemirror/view";
9
- import { polyfillCreateRoot } from "../../../shared/index.mjs";
10
- import { UIPopoverContent, UIRootTitle, UITag, UIVarName } from "../styles.mjs";
11
- class VariableTagWidget extends WidgetType {
12
- constructor({ keyPath, scope }){
13
- super(), this.toDispose = new DisposableCollection(), this.renderIcon = (icon)=>{
14
- if ('string' == typeof icon) return /*#__PURE__*/ jsx("img", {
15
- style: {
16
- marginRight: 8
17
- },
18
- width: 12,
19
- height: 12,
20
- src: icon
21
- });
22
- return icon;
23
- };
24
- this.keyPath = keyPath;
25
- this.scope = scope;
26
- }
27
- renderVariable(v) {
28
- if (!v) return void this.root.render(/*#__PURE__*/ jsx(UITag, {
29
- prefixIcon: /*#__PURE__*/ jsx(IconIssueStroked, {}),
30
- color: "amber",
31
- children: "Unknown"
32
- }));
33
- const rootField = last(v.parentFields);
34
- const rootTitle = /*#__PURE__*/ jsx(UIRootTitle, {
35
- children: rootField?.meta.title ? `${rootField.meta.title} -` : ''
36
- });
37
- const rootIcon = this.renderIcon(rootField?.meta.icon);
38
- this.root.render(/*#__PURE__*/ jsx(Popover, {
39
- content: /*#__PURE__*/ jsxs(UIPopoverContent, {
40
- children: [
41
- rootIcon,
42
- rootTitle,
43
- /*#__PURE__*/ jsx(UIVarName, {
44
- children: v?.keyPath.slice(1).join('.')
45
- })
46
- ]
47
- }),
48
- children: /*#__PURE__*/ jsxs(UITag, {
49
- prefixIcon: rootIcon,
50
- children: [
51
- rootTitle,
52
- /*#__PURE__*/ jsx(UIVarName, {
53
- children: v?.key
54
- })
55
- ]
56
- })
57
- }));
58
- }
59
- toDOM(view) {
60
- const dom = document.createElement('span');
61
- this.root = polyfillCreateRoot(dom);
62
- this.toDispose.push(Disposable.create(()=>{
63
- this.root.unmount();
64
- }));
65
- this.toDispose.push(this.scope.available.trackByKeyPath(this.keyPath, (v)=>{
66
- this.renderVariable(v);
67
- }, {
68
- triggerOnInit: false
69
- }));
70
- this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
71
- return dom;
72
- }
73
- eq(other) {
74
- return isEqual(this.keyPath, other.keyPath);
75
- }
76
- ignoreEvent() {
77
- return false;
78
- }
79
- destroy(dom) {
80
- this.toDispose.dispose();
81
- }
82
- }
83
- function VariableTagInject() {
84
- const injector = useInjector();
85
- const scope = useCurrentScope();
86
- useLayoutEffect(()=>{
87
- const atMatcher = new MatchDecorator({
88
- regexp: /\{\{([^\}\{]+)\}\}/g,
89
- decoration: (match)=>Decoration.replace({
90
- widget: new VariableTagWidget({
91
- keyPath: match[1]?.split('.') ?? [],
92
- scope
93
- })
94
- })
95
- });
96
- return injector.inject([
97
- ViewPlugin.fromClass(class {
98
- constructor(view){
99
- this.view = view;
100
- this.decorations = atMatcher.createDeco(view);
101
- }
102
- update() {
103
- this.decorations = atMatcher.createDeco(this.view);
104
- }
105
- }, {
106
- decorations: (p)=>p.decorations,
107
- provide (p) {
108
- return EditorView.atomicRanges.of((view)=>view.plugin(p)?.decorations ?? Decoration.none);
109
- }
110
- })
111
- ]);
112
- }, [
113
- injector
114
- ]);
115
- return null;
116
- }
117
- export { VariableTagInject };
@@ -1,36 +0,0 @@
1
- import styled_components from "styled-components";
2
- import { Tag } from "@douyinfe/semi-ui";
3
- const UIRootTitle = styled_components.div`
4
- margin-right: 4px;
5
- min-width: 20px;
6
- overflow: hidden;
7
- text-overflow: ellipsis;
8
- white-space: nowrap;
9
- color: var(--semi-color-text-2);
10
- `;
11
- const UIVarName = styled_components.div`
12
- overflow: hidden;
13
- text-overflow: ellipsis;
14
- white-space: nowrap;
15
- `;
16
- const UITag = styled_components(Tag)`
17
- display: inline-flex;
18
- align-items: center;
19
- justify-content: flex-start;
20
- max-width: 300px;
21
-
22
- & .semi-tag-content-center {
23
- justify-content: flex-start;
24
- }
25
-
26
- &.semi-tag {
27
- margin: 0 5px;
28
- }
29
- `;
30
- const UIPopoverContent = styled_components.div`
31
- padding: 10px;
32
- display: inline-flex;
33
- align-items: center;
34
- justify-content: flex-start;
35
- `;
36
- export { UIPopoverContent, UIRootTitle, UITag, UIVarName };
@@ -1,5 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- export declare const initTsWorker: () => void;
@@ -1,5 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- export {};
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { IRules, OpConfigs } from './types';
6
- export declare const defaultRules: IRules;
7
- export declare const defaultOpConfigs: OpConfigs;
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import React from 'react';
6
- import { IRule, OpConfigs } from '../types';
7
- interface HookParams {
8
- rule?: IRule;
9
- op?: string;
10
- onChange: (op: string) => void;
11
- readonly?: boolean;
12
- userOps?: OpConfigs;
13
- }
14
- export declare function useOp({ rule, op, onChange, readonly, userOps }: HookParams): {
15
- renderOpSelect: () => React.JSX.Element;
16
- opConfig: import("../types").OpConfig;
17
- };
18
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { IFlowRefValue } from '../../../shared';
6
- import { IRules } from '../types';
7
- export declare function useRule(left?: IFlowRefValue, userRules?: IRules): {
8
- rule: Partial<Record<string, string | null>> | undefined;
9
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import React from 'react';
6
- import { DBConditionOptionType, IRules } from '../types';
7
- interface HookParams {
8
- left?: string;
9
- options?: DBConditionOptionType[];
10
- userRules?: IRules;
11
- readonly?: boolean;
12
- onChange: (leftKey: string) => void;
13
- }
14
- export declare function useLeft({ left, options, userRules, readonly, onChange }: HookParams): {
15
- rule: Partial<Record<string, string | null>> | undefined;
16
- renderDBOptionSelect: () => React.JSX.Element;
17
- };
18
- export {};
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import React from 'react';
6
- import { IRule, OpConfigs } from '../types';
7
- interface HookParams {
8
- rule?: IRule;
9
- op?: string;
10
- onChange: (op: string) => void;
11
- readonly?: boolean;
12
- userOps?: OpConfigs;
13
- }
14
- export declare function useOp({ rule, op, onChange, readonly, userOps }: HookParams): {
15
- renderOpSelect: () => React.JSX.Element;
16
- opConfig: import("../../condition-row/types").OpConfig;
17
- };
18
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import React from 'react';
6
- import { IFlowValue } from '../../../shared';
7
- export declare function InputsTree({ inputsValues }: {
8
- inputsValues: Record<string, IFlowValue>;
9
- }): React.JSX.Element;
@@ -1,5 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- export declare function VariableTagInject(): null;
@@ -1,6 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import React from 'react';
6
- export declare function VariableTree(): React.JSX.Element;
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { Tag } from '@douyinfe/semi-ui';
6
- export declare const UIRootTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
7
- export declare const UIVarName: import("styled-components").StyledComponent<"div", any, {}, never>;
8
- export declare const UITag: import("styled-components").StyledComponent<typeof Tag, any, {}, never>;
9
- export declare const UIPopoverContent: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,27 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { typescript } from '@flowgram.ai/coze-editor/language-typescript';
7
-
8
- let tsWorkerInit = false;
9
-
10
- export const initTsWorker = () => {
11
- if (tsWorkerInit) {
12
- return;
13
- }
14
- tsWorkerInit = true;
15
-
16
- const tsWorker = new Worker(
17
- new URL(`@flowgram.ai/coze-editor/language-typescript/worker`, import.meta.url),
18
- { type: 'module' }
19
- );
20
- typescript.languageService.initialize(tsWorker, {
21
- compilerOptions: {
22
- // eliminate Promise error
23
- lib: ['es2015', 'dom'],
24
- noImplicitAny: false,
25
- },
26
- });
27
- };
@@ -1,23 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { languages } from '@flowgram.ai/coze-editor/preset-code';
7
- import { typescript } from '@flowgram.ai/coze-editor/language-typescript';
8
- import { shell } from '@flowgram.ai/coze-editor/language-shell';
9
- import { python } from '@flowgram.ai/coze-editor/language-python';
10
- import { json } from '@flowgram.ai/coze-editor/language-json';
11
- import { mixLanguages } from '@flowgram.ai/coze-editor';
12
-
13
- languages.register('python', python);
14
- languages.register('shell', shell);
15
- languages.register('typescript', typescript);
16
-
17
- languages.register('json', {
18
- // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
19
- language: mixLanguages({
20
- outerLanguage: json.language,
21
- }),
22
- languageService: json.languageService,
23
- });