@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,46 +1,62 @@
1
1
  import { createTheme, tags } from "@flowgram.ai/coze-editor/preset-code";
2
2
  const colors = {
3
- background: '#FFFFFF',
4
- comment: '#6B7280',
5
- key: '#2563EB',
6
- variable: '#DC2626',
7
- string: '#059669',
8
- number: '#EA580C',
9
- boolean: '#7C3AED',
10
- null: '#7C3AED',
11
- separator: '#374151'
3
+ background: '#f4f5f5',
4
+ foreground: '#444d56',
5
+ selection: '#0366d625',
6
+ cursor: '#044289',
7
+ dropdownBackground: '#fff',
8
+ dropdownBorder: '#e1e4e8',
9
+ activeLine: '#c6c6c622',
10
+ matchingBracket: '#34d05840',
11
+ keyword: '#d73a49',
12
+ storage: '#d73a49',
13
+ variable: '#e36209',
14
+ parameter: '#24292e',
15
+ function: '#005cc5',
16
+ string: '#032f62',
17
+ constant: '#005cc5',
18
+ type: '#005cc5',
19
+ class: '#6f42c1',
20
+ number: '#005cc5',
21
+ comment: '#6a737d',
22
+ heading: '#005cc5',
23
+ invalid: '#cb2431',
24
+ regexp: '#032f62'
12
25
  };
13
26
  const lightTheme = createTheme({
14
27
  variant: 'light',
15
28
  settings: {
16
- background: '#FFFFFF',
17
- foreground: '#1F2937',
18
- caret: '#2563EB',
19
- selection: '#E5E7EB',
20
- gutterBackground: '#F9FAFB',
21
- gutterForeground: '#6B7280',
29
+ background: colors.background,
30
+ foreground: colors.foreground,
31
+ caret: colors.cursor,
32
+ selection: colors.selection,
33
+ gutterBackground: colors.background,
34
+ gutterForeground: colors.foreground,
22
35
  gutterBorderColor: 'transparent',
23
36
  gutterBorderWidth: 0,
24
- lineHighlight: '#F3F4F680',
37
+ lineHighlight: colors.background,
25
38
  bracketColors: [
26
39
  '#F59E0B',
27
40
  '#8B5CF6',
28
41
  '#06B6D4'
29
42
  ],
30
43
  tooltip: {
31
- backgroundColor: '#FFFFFF',
32
- color: '#1F2937',
33
- border: '1px solid #E5E7EB',
34
- boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)'
44
+ backgroundColor: colors.dropdownBackground,
45
+ color: colors.foreground,
46
+ border: 'none',
47
+ boxShadow: '0 0 1px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .1)!important',
48
+ maxWidth: '400px'
35
49
  },
36
50
  link: {
37
- color: '#2563EB'
51
+ color: '#2563EB',
52
+ caret: colors.cursor
38
53
  },
39
54
  completionItemHover: {
40
55
  backgroundColor: '#F3F4F6'
41
56
  },
42
57
  completionItemSelected: {
43
- backgroundColor: '#E5E7EB'
58
+ backgroundColor: colors.selection,
59
+ color: colors.foreground
44
60
  },
45
61
  completionItemIcon: {
46
62
  color: '#4B5563'
@@ -57,105 +73,135 @@ const lightTheme = createTheme({
57
73
  },
58
74
  styles: [
59
75
  {
60
- tag: tags.comment,
61
- color: colors.comment
76
+ tag: tags.keyword,
77
+ color: colors.keyword
62
78
  },
63
79
  {
64
80
  tag: [
65
- tags.propertyName
81
+ tags.name,
82
+ tags.deleted,
83
+ tags.character,
84
+ tags.macroName
66
85
  ],
67
- color: colors.key
86
+ color: colors.variable
68
87
  },
69
88
  {
70
89
  tag: [
71
- tags.variableName
90
+ tags.propertyName
72
91
  ],
73
- color: colors.variable
92
+ color: colors.function
74
93
  },
75
94
  {
76
95
  tag: [
77
- tags.string
96
+ tags.processingInstruction,
97
+ tags.string,
98
+ tags.inserted,
99
+ tags.special(tags.string)
78
100
  ],
79
101
  color: colors.string
80
102
  },
81
103
  {
82
104
  tag: [
83
- tags.number
105
+ tags["function"](tags.variableName),
106
+ tags.labelName
84
107
  ],
85
- color: colors.number
108
+ color: colors.function
86
109
  },
87
110
  {
88
111
  tag: [
89
- tags.bool
112
+ tags.color,
113
+ tags.constant(tags.name),
114
+ tags.standard(tags.name)
90
115
  ],
91
- color: colors.boolean
116
+ color: colors.constant
92
117
  },
93
118
  {
94
119
  tag: [
95
- tags["null"]
120
+ tags.definition(tags.name),
121
+ tags.separator
96
122
  ],
97
- color: colors.null
123
+ color: colors.variable
98
124
  },
99
125
  {
100
126
  tag: [
101
- tags.separator
127
+ tags.className
102
128
  ],
103
- color: colors.separator
129
+ color: colors.class
104
130
  },
105
131
  {
106
132
  tag: [
107
- tags.heading
133
+ tags.number,
134
+ tags.changed,
135
+ tags.annotation,
136
+ tags.modifier,
137
+ tags.self,
138
+ tags.namespace
108
139
  ],
109
- color: '#2563EB'
140
+ color: colors.number
110
141
  },
111
142
  {
112
143
  tag: [
113
- tags.processingInstruction
144
+ tags.typeName
114
145
  ],
115
- color: '#2563EB'
146
+ color: colors.type,
147
+ fontStyle: colors.type
116
148
  },
117
149
  {
118
150
  tag: [
119
- tags.definitionKeyword
151
+ tags.operator,
152
+ tags.operatorKeyword
120
153
  ],
121
- color: '#9333EA'
154
+ color: colors.keyword
122
155
  },
123
156
  {
124
157
  tag: [
125
- tags.modifier
158
+ tags.url,
159
+ tags.escape,
160
+ tags.regexp,
161
+ tags.link
126
162
  ],
127
- color: '#9333EA'
163
+ color: colors.regexp
128
164
  },
129
165
  {
130
166
  tag: [
131
- tags.controlKeyword
167
+ tags.meta,
168
+ tags.comment
132
169
  ],
133
- color: '#9333EA'
170
+ color: colors.comment
134
171
  },
135
172
  {
136
- tag: [
137
- tags.operatorKeyword
138
- ],
139
- color: '#9333EA'
173
+ tag: tags.strong,
174
+ fontWeight: 'bold'
140
175
  },
141
176
  {
142
- tag: [
143
- tags.standard(tags.variableName)
144
- ],
145
- color: '#059669'
177
+ tag: tags.emphasis,
178
+ fontStyle: 'italic'
146
179
  },
147
180
  {
148
- tag: [
149
- tags.attributeName
150
- ],
151
- color: '#EA580C'
181
+ tag: tags.link,
182
+ textDecoration: 'underline'
183
+ },
184
+ {
185
+ tag: tags.heading,
186
+ fontWeight: 'bold',
187
+ color: colors.heading
152
188
  },
153
189
  {
154
190
  tag: [
155
- tags.special(tags.string)
191
+ tags.atom,
192
+ tags.bool,
193
+ tags.special(tags.variableName)
156
194
  ],
157
- color: '#2563EB'
195
+ color: colors.variable
196
+ },
197
+ {
198
+ tag: tags.invalid,
199
+ color: colors.invalid
200
+ },
201
+ {
202
+ tag: tags.strikethrough,
203
+ textDecoration: 'line-through'
158
204
  }
159
205
  ]
160
206
  });
161
- export { lightTheme };
207
+ export { colors, lightTheme };
@@ -3,6 +3,7 @@ function getSuffixByLanguageId(languageId) {
3
3
  if ("typescript" === languageId) return '.ts';
4
4
  if ('shell' === languageId) return '.sh';
5
5
  if ('json' === languageId) return '.json';
6
+ if ('sql' === languageId) return '.sql';
6
7
  return '';
7
8
  }
8
9
  export { getSuffixByLanguageId };
@@ -0,0 +1,19 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ import { defaultConditionOpConfigs } from "./op.mjs";
4
+ const ConditionContext = /*#__PURE__*/ createContext({
5
+ rules: {},
6
+ ops: defaultConditionOpConfigs
7
+ });
8
+ const ConditionProvider = (props)=>{
9
+ const { rules, ops } = props;
10
+ return /*#__PURE__*/ jsx(ConditionContext.Provider, {
11
+ value: {
12
+ rules,
13
+ ops
14
+ },
15
+ children: props.children
16
+ });
17
+ };
18
+ const useConditionContext = ()=>useContext(ConditionContext);
19
+ export { ConditionContext, ConditionProvider, useConditionContext };
@@ -0,0 +1,63 @@
1
+ import { useMemo } from "react";
2
+ import { I18n } from "@flowgram.ai/editor";
3
+ import { useTypeManager } from "../../../plugins/index.mjs";
4
+ import { useConditionContext } from "../context.mjs";
5
+ function useCondition({ leftSchema, operator, ruleConfig }) {
6
+ const typeManager = useTypeManager();
7
+ const { rules: contextRules, ops: contextOps } = useConditionContext();
8
+ const userRules = useMemo(()=>ruleConfig?.rules || contextRules || {}, [
9
+ contextRules,
10
+ ruleConfig?.rules
11
+ ]);
12
+ const allOps = useMemo(()=>ruleConfig?.ops || contextOps || {}, [
13
+ contextOps,
14
+ ruleConfig?.ops
15
+ ]);
16
+ const config = useMemo(()=>leftSchema ? typeManager.getTypeBySchema(leftSchema) : void 0, [
17
+ leftSchema,
18
+ typeManager
19
+ ]);
20
+ const rule = useMemo(()=>{
21
+ if (!config) return;
22
+ if (userRules[config.type]) return userRules[config.type];
23
+ if ('function' == typeof config.conditionRule) return config.conditionRule(leftSchema);
24
+ return config.conditionRule;
25
+ }, [
26
+ userRules,
27
+ leftSchema,
28
+ config
29
+ ]);
30
+ const opOptionList = useMemo(()=>Object.keys(rule || {}).filter((_op)=>allOps[_op]).map((_op)=>({
31
+ ...allOps?.[_op] || {},
32
+ value: _op,
33
+ label: I18n.t(allOps?.[_op]?.label || _op)
34
+ })), [
35
+ rule,
36
+ allOps
37
+ ]);
38
+ const targetSchema = useMemo(()=>{
39
+ const targetType = rule?.[operator || ''] || null;
40
+ if (!targetType) return;
41
+ if ('string' == typeof targetType) return {
42
+ type: targetType,
43
+ extra: {
44
+ weak: true
45
+ }
46
+ };
47
+ return targetType;
48
+ }, [
49
+ rule,
50
+ operator
51
+ ]);
52
+ const opConfig = useMemo(()=>allOps[operator || ''], [
53
+ operator,
54
+ allOps
55
+ ]);
56
+ return {
57
+ rule,
58
+ opConfig,
59
+ opOptionList,
60
+ targetSchema
61
+ };
62
+ }
63
+ export { useCondition };
@@ -0,0 +1,4 @@
1
+ import { ConditionPresetOp } from "./op.mjs";
2
+ import { ConditionProvider, useConditionContext } from "./context.mjs";
3
+ import { useCondition } from "./hooks/use-condition.mjs";
4
+ export { ConditionPresetOp, ConditionProvider, useCondition, useConditionContext };
@@ -0,0 +1,80 @@
1
+ var op_ConditionPresetOp = /*#__PURE__*/ function(ConditionPresetOp) {
2
+ ConditionPresetOp["EQ"] = "eq";
3
+ ConditionPresetOp["NEQ"] = "neq";
4
+ ConditionPresetOp["GT"] = "gt";
5
+ ConditionPresetOp["GTE"] = "gte";
6
+ ConditionPresetOp["LT"] = "lt";
7
+ ConditionPresetOp["LTE"] = "lte";
8
+ ConditionPresetOp["IN"] = "in";
9
+ ConditionPresetOp["NIN"] = "nin";
10
+ ConditionPresetOp["CONTAINS"] = "contains";
11
+ ConditionPresetOp["NOT_CONTAINS"] = "not_contains";
12
+ ConditionPresetOp["IS_EMPTY"] = "is_empty";
13
+ ConditionPresetOp["IS_NOT_EMPTY"] = "is_not_empty";
14
+ ConditionPresetOp["IS_TRUE"] = "is_true";
15
+ ConditionPresetOp["IS_FALSE"] = "is_false";
16
+ return ConditionPresetOp;
17
+ }({});
18
+ const defaultConditionOpConfigs = {
19
+ ["eq"]: {
20
+ label: 'Equal',
21
+ abbreviation: '='
22
+ },
23
+ ["neq"]: {
24
+ label: 'Not Equal',
25
+ abbreviation: '≠'
26
+ },
27
+ ["gt"]: {
28
+ label: 'Greater Than',
29
+ abbreviation: '>'
30
+ },
31
+ ["gte"]: {
32
+ label: 'Greater Than or Equal',
33
+ abbreviation: '>='
34
+ },
35
+ ["lt"]: {
36
+ label: 'Less Than',
37
+ abbreviation: '<'
38
+ },
39
+ ["lte"]: {
40
+ label: 'Less Than or Equal',
41
+ abbreviation: '<='
42
+ },
43
+ ["in"]: {
44
+ label: 'In',
45
+ abbreviation: '∈'
46
+ },
47
+ ["nin"]: {
48
+ label: 'Not In',
49
+ abbreviation: '∉'
50
+ },
51
+ ["contains"]: {
52
+ label: 'Contains',
53
+ abbreviation: '⊇'
54
+ },
55
+ ["not_contains"]: {
56
+ label: 'Not Contains',
57
+ abbreviation: '⊉'
58
+ },
59
+ ["is_empty"]: {
60
+ label: 'Is Empty',
61
+ abbreviation: '=',
62
+ rightDisplay: 'Empty'
63
+ },
64
+ ["is_not_empty"]: {
65
+ label: 'Is Not Empty',
66
+ abbreviation: '≠',
67
+ rightDisplay: 'Empty'
68
+ },
69
+ ["is_true"]: {
70
+ label: 'Is True',
71
+ abbreviation: '=',
72
+ rightDisplay: 'True'
73
+ },
74
+ ["is_false"]: {
75
+ label: 'Is False',
76
+ abbreviation: '=',
77
+ rightDisplay: 'False'
78
+ }
79
+ };
80
+ export { op_ConditionPresetOp as ConditionPresetOp, defaultConditionOpConfigs };
@@ -1,42 +1,61 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useMemo } from "react";
3
- import { I18n } from "@flowgram.ai/editor";
4
- import { Input } from "@douyinfe/semi-ui";
3
+ import { JsonSchemaUtils } from "@flowgram.ai/json-schema";
4
+ import { I18n, useScopeAvailable } from "@flowgram.ai/editor";
5
+ import { Button, Input, Select } from "@douyinfe/semi-ui";
6
+ import { IconChevronDownStroked } from "@douyinfe/semi-icons";
5
7
  import { InjectVariableSelector } from "../variable-selector/index.mjs";
6
8
  import { InjectDynamicValueInput } from "../dynamic-value-input/index.mjs";
9
+ import { useCondition } from "../condition-context/index.mjs";
7
10
  import { UIContainer, UILeft, UIOperator, UIRight, UIValues } from "./styles.mjs";
8
- import { useRule } from "./hooks/useRule.mjs";
9
- import { useOp } from "./hooks/useOp.mjs";
10
- import { defaultOpConfigs, defaultRules } from "./constants.mjs";
11
11
  const defaultRuleConfig = {
12
12
  ops: {},
13
13
  rules: {}
14
14
  };
15
15
  function ConditionRow({ style, value, onChange, readonly, ruleConfig = defaultRuleConfig }) {
16
16
  const { left, operator, right } = value || {};
17
- const { rule } = useRule(left, ruleConfig.rules);
18
- const { renderOpSelect, opConfig } = useOp({
19
- rule,
20
- op: operator,
21
- onChange: (v)=>onChange({
22
- ...value,
23
- operator: v
24
- }),
25
- readonly,
26
- userOps: ruleConfig.ops
27
- });
28
- const targetSchema = useMemo(()=>{
29
- const targetType = rule?.[operator || ''] || null;
30
- return targetType ? {
31
- type: targetType,
32
- extra: {
33
- weak: true
34
- }
35
- } : null;
17
+ const available = useScopeAvailable();
18
+ const variable = useMemo(()=>{
19
+ if (!left) return;
20
+ return available.getByKeyPath(left.content);
21
+ }, [
22
+ available,
23
+ left
24
+ ]);
25
+ const leftSchema = useMemo(()=>{
26
+ if (!variable) return;
27
+ return JsonSchemaUtils.astToSchema(variable.type, {
28
+ drilldown: false
29
+ });
36
30
  }, [
37
- rule,
38
- opConfig
31
+ variable?.type?.hash
39
32
  ]);
33
+ const { rule, opConfig, opOptionList, targetSchema } = useCondition({
34
+ leftSchema,
35
+ operator
36
+ });
37
+ const renderOpSelect = ()=>/*#__PURE__*/ jsx(Select, {
38
+ style: {
39
+ height: 22
40
+ },
41
+ disabled: readonly,
42
+ size: "small",
43
+ value: operator,
44
+ optionList: opOptionList,
45
+ onChange: (v)=>{
46
+ onChange({
47
+ ...value,
48
+ operator: v
49
+ });
50
+ },
51
+ triggerRender: ({ value })=>/*#__PURE__*/ jsx(Button, {
52
+ size: "small",
53
+ disabled: !rule,
54
+ children: opConfig?.abbreviation || /*#__PURE__*/ jsx(IconChevronDownStroked, {
55
+ size: "small"
56
+ })
57
+ })
58
+ });
40
59
  return /*#__PURE__*/ jsxs(UIContainer, {
41
60
  style: style,
42
61
  children: [
@@ -84,6 +103,4 @@ function ConditionRow({ style, value, onChange, readonly, ruleConfig = defaultRu
84
103
  ]
85
104
  });
86
105
  }
87
- ConditionRow.defaultRules = defaultRules;
88
- ConditionRow.defaultOpConfigs = defaultOpConfigs;
89
106
  export { ConditionRow };
@@ -1,18 +0,0 @@
1
- var types_Op = /*#__PURE__*/ function(Op) {
2
- Op["EQ"] = "eq";
3
- Op["NEQ"] = "neq";
4
- Op["GT"] = "gt";
5
- Op["GTE"] = "gte";
6
- Op["LT"] = "lt";
7
- Op["LTE"] = "lte";
8
- Op["IN"] = "in";
9
- Op["NIN"] = "nin";
10
- Op["CONTAINS"] = "contains";
11
- Op["NOT_CONTAINS"] = "not_contains";
12
- Op["IS_EMPTY"] = "is_empty";
13
- Op["IS_NOT_EMPTY"] = "is_not_empty";
14
- Op["IS_TRUE"] = "is_true";
15
- Op["IS_FALSE"] = "is_false";
16
- return Op;
17
- }({});
18
- export { types_Op as Op };
@@ -0,0 +1,135 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from "react";
3
+ import { isPlainObject, last } from "lodash-es";
4
+ import { ASTMatch, useScopeAvailable } from "@flowgram.ai/editor";
5
+ import { Mention, PositionMirror, getCurrentMentionReplaceRange, useEditor } from "@flowgram.ai/coze-editor/react";
6
+ import { Popover, Tree } from "@douyinfe/semi-ui";
7
+ import { FlowValueUtils } from "../../../shared/index.mjs";
8
+ function InputsPicker({ inputsValues, onSelect }) {
9
+ const available = useScopeAvailable();
10
+ const getArrayDrilldown = (type, depth = 1)=>{
11
+ if (ASTMatch.isArray(type.items)) return getArrayDrilldown(type.items, depth + 1);
12
+ return {
13
+ type: type.items,
14
+ depth: depth
15
+ };
16
+ };
17
+ const renderVariable = (variable, keyPath)=>{
18
+ let type = variable?.type;
19
+ let children;
20
+ if (ASTMatch.isObject(type)) children = (type.properties || []).map((_property)=>renderVariable(_property, [
21
+ ...keyPath,
22
+ _property.key
23
+ ])).filter(Boolean);
24
+ if (ASTMatch.isArray(type)) {
25
+ const drilldown = getArrayDrilldown(type);
26
+ if (ASTMatch.isObject(drilldown.type)) children = (drilldown.type.properties || []).map((_property)=>renderVariable(_property, [
27
+ ...keyPath,
28
+ ...new Array(drilldown.depth).fill('[0]'),
29
+ _property.key
30
+ ])).filter(Boolean);
31
+ }
32
+ const key = keyPath.map((_key, idx)=>'[0]' === _key || 0 === idx ? _key : `.${_key}`).join('');
33
+ return {
34
+ key: key,
35
+ label: last(keyPath),
36
+ value: key,
37
+ children
38
+ };
39
+ };
40
+ const getTreeData = (value, keyPath)=>{
41
+ const currKey = keyPath.join('.');
42
+ if (FlowValueUtils.isFlowValue(value)) {
43
+ if (FlowValueUtils.isRef(value)) {
44
+ const variable = available.getByKeyPath(value.content || []);
45
+ if (variable) return renderVariable(variable, keyPath);
46
+ }
47
+ return {
48
+ key: currKey,
49
+ value: currKey,
50
+ label: last(keyPath)
51
+ };
52
+ }
53
+ if (isPlainObject(value)) return {
54
+ key: currKey,
55
+ value: currKey,
56
+ label: last(keyPath),
57
+ children: Object.entries(value).map(([key, value])=>getTreeData(value, [
58
+ ...keyPath,
59
+ key
60
+ ])).filter(Boolean)
61
+ };
62
+ };
63
+ const treeData = useMemo(()=>Object.entries(inputsValues).map(([key, value])=>getTreeData(value, [
64
+ key
65
+ ])).filter(Boolean), []);
66
+ return /*#__PURE__*/ jsx(Tree, {
67
+ treeData: treeData,
68
+ onSelect: (v)=>onSelect(v)
69
+ });
70
+ }
71
+ const DEFAULT_TRIGGER_CHARACTERS = [
72
+ '{',
73
+ '{}',
74
+ '@'
75
+ ];
76
+ function InputsTree({ inputsValues, triggerCharacters = DEFAULT_TRIGGER_CHARACTERS }) {
77
+ const [posKey, setPosKey] = useState('');
78
+ const [visible, setVisible] = useState(false);
79
+ const [position, setPosition] = useState(-1);
80
+ const editor = useEditor();
81
+ function insert(variablePath) {
82
+ const range = getCurrentMentionReplaceRange(editor.$view.state);
83
+ if (!range) return;
84
+ let { from, to } = range;
85
+ while('{' === editor.$view.state.doc.sliceString(from - 1, from))from--;
86
+ while('}' === editor.$view.state.doc.sliceString(to, to + 1))to++;
87
+ editor.replaceText({
88
+ ...range,
89
+ text: '{{' + variablePath + '}}'
90
+ });
91
+ setVisible(false);
92
+ }
93
+ function handleOpenChange(e) {
94
+ setPosition(e.state.selection.main.head);
95
+ setVisible(e.value);
96
+ }
97
+ useEffect(()=>{
98
+ if (!editor) return;
99
+ }, [
100
+ editor,
101
+ visible
102
+ ]);
103
+ return /*#__PURE__*/ jsxs(Fragment, {
104
+ children: [
105
+ /*#__PURE__*/ jsx(Mention, {
106
+ triggerCharacters: triggerCharacters,
107
+ onOpenChange: handleOpenChange
108
+ }),
109
+ /*#__PURE__*/ jsx(Popover, {
110
+ visible: visible,
111
+ trigger: "custom",
112
+ position: "topLeft",
113
+ rePosKey: posKey,
114
+ content: /*#__PURE__*/ jsx("div", {
115
+ style: {
116
+ width: 300,
117
+ maxHeight: 300,
118
+ overflowY: 'auto'
119
+ },
120
+ children: /*#__PURE__*/ jsx(InputsPicker, {
121
+ inputsValues: inputsValues,
122
+ onSelect: (v)=>{
123
+ insert(v);
124
+ }
125
+ })
126
+ }),
127
+ children: /*#__PURE__*/ jsx(PositionMirror, {
128
+ position: position,
129
+ onChange: ()=>setPosKey(String(Math.random()))
130
+ })
131
+ })
132
+ ]
133
+ });
134
+ }
135
+ export { InputsPicker, InputsTree };