@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
@@ -6,45 +6,61 @@
6
6
  import { createTheme, tags as t } from '@flowgram.ai/coze-editor/preset-code';
7
7
  import { type Extension } from '@codemirror/state';
8
8
 
9
- const colors = {
10
- background: '#FFFFFF',
11
- comment: '#6B7280',
12
- key: '#2563EB',
13
- variable: '#DC2626',
14
- string: '#059669',
15
- number: '#EA580C',
16
- boolean: '#7C3AED',
17
- null: '#7C3AED',
18
- separator: '#374151',
9
+ export const colors = {
10
+ background: '#f4f5f5',
11
+ foreground: '#444d56',
12
+ selection: '#0366d625',
13
+ cursor: '#044289',
14
+ dropdownBackground: '#fff',
15
+ dropdownBorder: '#e1e4e8',
16
+ activeLine: '#c6c6c622',
17
+ matchingBracket: '#34d05840',
18
+ keyword: '#d73a49',
19
+ storage: '#d73a49',
20
+ variable: '#e36209',
21
+ parameter: '#24292e',
22
+ function: '#005cc5',
23
+ string: '#032f62',
24
+ constant: '#005cc5',
25
+ type: '#005cc5',
26
+ class: '#6f42c1',
27
+ number: '#005cc5',
28
+ comment: '#6a737d',
29
+ heading: '#005cc5',
30
+ invalid: '#cb2431',
31
+ regexp: '#032f62',
19
32
  };
20
33
 
21
34
  export const lightTheme: Extension = createTheme({
22
35
  variant: 'light',
23
36
  settings: {
24
- background: '#FFFFFF',
25
- foreground: '#1F2937',
26
- caret: '#2563EB',
27
- selection: '#E5E7EB',
28
- gutterBackground: '#F9FAFB',
29
- gutterForeground: '#6B7280',
37
+ background: colors.background,
38
+ foreground: colors.foreground,
39
+ caret: colors.cursor,
40
+ selection: colors.selection,
41
+ gutterBackground: colors.background,
42
+ gutterForeground: colors.foreground,
30
43
  gutterBorderColor: 'transparent',
31
44
  gutterBorderWidth: 0,
32
- lineHighlight: '#F3F4F680',
45
+ lineHighlight: colors.background,
33
46
  bracketColors: ['#F59E0B', '#8B5CF6', '#06B6D4'],
34
47
  tooltip: {
35
- backgroundColor: '#FFFFFF',
36
- color: '#1F2937',
37
- border: '1px solid #E5E7EB',
38
- boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
48
+ backgroundColor: colors.dropdownBackground,
49
+ color: colors.foreground,
50
+ border: 'none',
51
+ boxShadow: '0 0 1px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .1)!important',
52
+ maxWidth: '400px',
39
53
  },
40
54
  link: {
41
55
  color: '#2563EB',
56
+ caret: colors.cursor,
42
57
  },
43
58
  completionItemHover: {
44
59
  backgroundColor: '#F3F4F6',
45
60
  },
46
61
  completionItemSelected: {
47
- backgroundColor: '#E5E7EB',
62
+ backgroundColor: colors.selection,
63
+ color: colors.foreground,
48
64
  },
49
65
  completionItemIcon: {
50
66
  color: '#4B5563',
@@ -60,84 +76,37 @@ export const lightTheme: Extension = createTheme({
60
76
  },
61
77
  },
62
78
  styles: [
63
- // JSON
64
- {
65
- tag: t.comment,
66
- color: colors.comment,
67
- },
68
- {
69
- tag: [t.propertyName],
70
- color: colors.key,
71
- },
79
+ { tag: t.keyword, color: colors.keyword },
72
80
  {
73
- tag: [t.variableName],
81
+ tag: [t.name, t.deleted, t.character, t.macroName],
74
82
  color: colors.variable,
75
83
  },
76
-
84
+ { tag: [t.propertyName], color: colors.function },
77
85
  {
78
- tag: [t.string],
86
+ tag: [t.processingInstruction, t.string, t.inserted, t.special(t.string)],
79
87
  color: colors.string,
80
88
  },
89
+ { tag: [t.function(t.variableName), t.labelName], color: colors.function },
81
90
  {
82
- tag: [t.number],
83
- color: colors.number,
84
- },
85
- {
86
- tag: [t.bool],
87
- color: colors.boolean,
88
- },
89
- {
90
- tag: [t.null],
91
- color: colors.null,
92
- },
93
- {
94
- tag: [t.separator],
95
- color: colors.separator,
96
- },
97
-
98
- // markdown
99
- {
100
- tag: [t.heading],
101
- color: '#2563EB',
102
- },
103
- {
104
- tag: [t.processingInstruction],
105
- color: '#2563EB',
106
- },
107
-
108
- // js
109
- {
110
- tag: [t.definitionKeyword],
111
- color: '#9333EA',
112
- },
113
- {
114
- tag: [t.modifier],
115
- color: '#9333EA',
116
- },
117
- {
118
- tag: [t.controlKeyword],
119
- color: '#9333EA',
91
+ tag: [t.color, t.constant(t.name), t.standard(t.name)],
92
+ color: colors.constant,
120
93
  },
94
+ { tag: [t.definition(t.name), t.separator], color: colors.variable },
95
+ { tag: [t.className], color: colors.class },
121
96
  {
122
- tag: [t.operatorKeyword],
123
- color: '#9333EA',
124
- },
125
-
126
- // shell
127
- // curl
128
- {
129
- tag: [t.standard(t.variableName)],
130
- color: '#059669',
131
- },
132
- // -X
133
- {
134
- tag: [t.attributeName],
135
- color: '#EA580C',
136
- },
137
- // url in string (includes quotes), e.g. "https://..."
138
- {
139
- tag: [t.special(t.string)],
140
- color: '#2563EB',
97
+ tag: [t.number, t.changed, t.annotation, t.modifier, t.self, t.namespace],
98
+ color: colors.number,
141
99
  },
100
+ { tag: [t.typeName], color: colors.type, fontStyle: colors.type },
101
+ { tag: [t.operator, t.operatorKeyword], color: colors.keyword },
102
+ { tag: [t.url, t.escape, t.regexp, t.link], color: colors.regexp },
103
+ { tag: [t.meta, t.comment], color: colors.comment },
104
+ { tag: t.strong, fontWeight: 'bold' },
105
+ { tag: t.emphasis, fontStyle: 'italic' },
106
+ { tag: t.link, textDecoration: 'underline' },
107
+ { tag: t.heading, fontWeight: 'bold', color: colors.heading },
108
+ { tag: [t.atom, t.bool, t.special(t.variableName)], color: colors.variable },
109
+ { tag: t.invalid, color: colors.invalid },
110
+ { tag: t.strikethrough, textDecoration: 'line-through' },
142
111
  ],
143
112
  });
@@ -16,5 +16,9 @@ export function getSuffixByLanguageId(languageId: string) {
16
16
  if (languageId === 'json') {
17
17
  return '.json';
18
18
  }
19
+ if (languageId === 'sql') {
20
+ return '.sql';
21
+ }
22
+
19
23
  return '';
20
24
  }
@@ -14,6 +14,9 @@ const UIMini = styled.div`
14
14
  }
15
15
  `;
16
16
 
17
+ /**
18
+ * @deprecated use mini in CodeEditorPropsType instead
19
+ */
17
20
  export function CodeEditorMini(props: CodeEditorPropsType) {
18
21
  return (
19
22
  <UIMini>
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import React, { createContext, useContext } from 'react';
7
+
8
+ import { IConditionRule, ConditionOpConfigs } from './types';
9
+ import { defaultConditionOpConfigs } from './op';
10
+
11
+ interface ContextType {
12
+ rules?: Record<string, IConditionRule>;
13
+ ops?: ConditionOpConfigs;
14
+ }
15
+
16
+ export const ConditionContext = createContext<ContextType>({
17
+ rules: {},
18
+ ops: defaultConditionOpConfigs,
19
+ });
20
+
21
+ export const ConditionProvider = (props: React.PropsWithChildren<ContextType>) => {
22
+ const { rules, ops } = props;
23
+ return (
24
+ <ConditionContext.Provider value={{ rules, ops }}>{props.children}</ConditionContext.Provider>
25
+ );
26
+ };
27
+
28
+ export const useConditionContext = () => useContext(ConditionContext);
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { useMemo } from 'react';
7
+
8
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
9
+ import { I18n } from '@flowgram.ai/editor';
10
+
11
+ import { useTypeManager } from '@/plugins';
12
+
13
+ import { IConditionRule, ConditionOpConfigs } from '../types';
14
+ import { useConditionContext } from '../context';
15
+
16
+ interface HooksParams {
17
+ leftSchema?: IJsonSchema;
18
+ operator?: string;
19
+
20
+ /**
21
+ * custom rule config
22
+ */
23
+ ruleConfig?: {
24
+ ops?: ConditionOpConfigs;
25
+ rules?: Record<string, IConditionRule>;
26
+ };
27
+ }
28
+
29
+ export function useCondition({ leftSchema, operator, ruleConfig }: HooksParams) {
30
+ const typeManager = useTypeManager();
31
+ const { rules: contextRules, ops: contextOps } = useConditionContext();
32
+
33
+ // 合并用户规则和上下文规则
34
+ const userRules = useMemo(
35
+ () => ruleConfig?.rules || contextRules || {},
36
+ [contextRules, ruleConfig?.rules]
37
+ );
38
+
39
+ // 合并用户操作符和上下文操作符
40
+ const allOps = useMemo(() => ruleConfig?.ops || contextOps || {}, [contextOps, ruleConfig?.ops]);
41
+
42
+ // 获取类型配置
43
+ const config = useMemo(
44
+ () => (leftSchema ? typeManager.getTypeBySchema(leftSchema) : undefined),
45
+ [leftSchema, typeManager]
46
+ );
47
+
48
+ // 计算规则
49
+ const rule = useMemo(() => {
50
+ if (!config) {
51
+ return undefined;
52
+ }
53
+ if (userRules[config.type]) {
54
+ return userRules[config.type];
55
+ }
56
+ if (typeof config.conditionRule === 'function') {
57
+ return config.conditionRule(leftSchema);
58
+ }
59
+ return config.conditionRule;
60
+ }, [userRules, leftSchema, config]);
61
+
62
+ // 计算操作符选项列表
63
+ const opOptionList = useMemo(
64
+ () =>
65
+ Object.keys(rule || {})
66
+ .filter((_op) => allOps[_op])
67
+ .map((_op) => ({
68
+ ...(allOps?.[_op] || {}),
69
+ value: _op,
70
+ label: I18n.t(allOps?.[_op]?.label || _op),
71
+ })),
72
+ [rule, allOps]
73
+ );
74
+
75
+ // get target schema
76
+ const targetSchema = useMemo(() => {
77
+ const targetType: string | IJsonSchema | null = rule?.[operator || ''] || null;
78
+
79
+ if (!targetType) {
80
+ return undefined;
81
+ }
82
+
83
+ if (typeof targetType === 'string') {
84
+ return { type: targetType, extra: { weak: true } };
85
+ }
86
+
87
+ return targetType;
88
+ }, [rule, operator]);
89
+
90
+ // get current operator config
91
+ const opConfig = useMemo(() => allOps[operator || ''], [operator, allOps]);
92
+
93
+ return {
94
+ rule,
95
+ opConfig,
96
+ opOptionList,
97
+ targetSchema,
98
+ };
99
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export {
7
+ type IConditionRule,
8
+ type IConditionRuleFactory,
9
+ type ConditionOpConfigs,
10
+ type ConditionOpConfig,
11
+ } from './types';
12
+ export { ConditionPresetOp } from './op';
13
+ export { ConditionProvider, useConditionContext } from './context';
14
+ export { useCondition } from './hooks/use-condition';
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { ConditionOpConfigs } from './types';
7
+
8
+ export enum ConditionPresetOp {
9
+ EQ = 'eq',
10
+ NEQ = 'neq',
11
+ GT = 'gt',
12
+ GTE = 'gte',
13
+ LT = 'lt',
14
+ LTE = 'lte',
15
+ IN = 'in',
16
+ NIN = 'nin',
17
+ CONTAINS = 'contains',
18
+ NOT_CONTAINS = 'not_contains',
19
+ IS_EMPTY = 'is_empty',
20
+ IS_NOT_EMPTY = 'is_not_empty',
21
+ IS_TRUE = 'is_true',
22
+ IS_FALSE = 'is_false',
23
+ }
24
+
25
+ export const defaultConditionOpConfigs: ConditionOpConfigs = {
26
+ [ConditionPresetOp.EQ]: {
27
+ label: 'Equal',
28
+ abbreviation: '=',
29
+ },
30
+ [ConditionPresetOp.NEQ]: {
31
+ label: 'Not Equal',
32
+ abbreviation: '≠',
33
+ },
34
+ [ConditionPresetOp.GT]: {
35
+ label: 'Greater Than',
36
+ abbreviation: '>',
37
+ },
38
+ [ConditionPresetOp.GTE]: {
39
+ label: 'Greater Than or Equal',
40
+ abbreviation: '>=',
41
+ },
42
+ [ConditionPresetOp.LT]: {
43
+ label: 'Less Than',
44
+ abbreviation: '<',
45
+ },
46
+ [ConditionPresetOp.LTE]: {
47
+ label: 'Less Than or Equal',
48
+ abbreviation: '<=',
49
+ },
50
+ [ConditionPresetOp.IN]: {
51
+ label: 'In',
52
+ abbreviation: '∈',
53
+ },
54
+ [ConditionPresetOp.NIN]: {
55
+ label: 'Not In',
56
+ abbreviation: '∉',
57
+ },
58
+ [ConditionPresetOp.CONTAINS]: {
59
+ label: 'Contains',
60
+ abbreviation: '⊇',
61
+ },
62
+ [ConditionPresetOp.NOT_CONTAINS]: {
63
+ label: 'Not Contains',
64
+ abbreviation: '⊉',
65
+ },
66
+ [ConditionPresetOp.IS_EMPTY]: {
67
+ label: 'Is Empty',
68
+ abbreviation: '=',
69
+ rightDisplay: 'Empty',
70
+ },
71
+ [ConditionPresetOp.IS_NOT_EMPTY]: {
72
+ label: 'Is Not Empty',
73
+ abbreviation: '≠',
74
+ rightDisplay: 'Empty',
75
+ },
76
+ [ConditionPresetOp.IS_TRUE]: {
77
+ label: 'Is True',
78
+ abbreviation: '=',
79
+ rightDisplay: 'True',
80
+ },
81
+ [ConditionPresetOp.IS_FALSE]: {
82
+ label: 'Is False',
83
+ abbreviation: '=',
84
+ rightDisplay: 'False',
85
+ },
86
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { type IJsonSchema } from '@flowgram.ai/json-schema';
7
+
8
+ export interface ConditionOpConfig {
9
+ label: string;
10
+ abbreviation: string;
11
+ // When right is not a value, display this text
12
+ rightDisplay?: string;
13
+ }
14
+
15
+ export type OpKey = string;
16
+
17
+ export type ConditionOpConfigs = Record<OpKey, ConditionOpConfig>;
18
+
19
+ export type IConditionRule = Record<OpKey, string | IJsonSchema | null>;
20
+ export type IConditionRuleFactory = (
21
+ schema?: IJsonSchema
22
+ ) => Record<OpKey, string | IJsonSchema | null>;
@@ -5,17 +5,17 @@
5
5
 
6
6
  import React, { useMemo } from 'react';
7
7
 
8
- import { I18n } from '@flowgram.ai/editor';
9
- import { Input } from '@douyinfe/semi-ui';
8
+ import { JsonSchemaUtils } from '@flowgram.ai/json-schema';
9
+ import { I18n, useScopeAvailable } from '@flowgram.ai/editor';
10
+ import { Button, Input, Select } from '@douyinfe/semi-ui';
11
+ import { IconChevronDownStroked } from '@douyinfe/semi-icons';
10
12
 
11
13
  import { InjectVariableSelector } from '@/components/variable-selector';
12
14
  import { InjectDynamicValueInput } from '@/components/dynamic-value-input';
15
+ import { IConditionRule, ConditionOpConfigs, useCondition } from '@/components/condition-context';
13
16
 
14
- import { ConditionRowValueType, IRules, OpConfigs } from './types';
17
+ import { ConditionRowValueType } from './types';
15
18
  import { UIContainer, UILeft, UIOperator, UIRight, UIValues } from './styles';
16
- import { useRule } from './hooks/useRule';
17
- import { useOp } from './hooks/useOp';
18
- import { defaultOpConfigs, defaultRules } from './constants';
19
19
 
20
20
  interface PropTypes {
21
21
  value?: ConditionRowValueType;
@@ -23,8 +23,8 @@ interface PropTypes {
23
23
  style?: React.CSSProperties;
24
24
  readonly?: boolean;
25
25
  ruleConfig?: {
26
- ops?: OpConfigs;
27
- rules?: IRules;
26
+ ops?: ConditionOpConfigs;
27
+ rules?: Record<string, IConditionRule>;
28
28
  };
29
29
  }
30
30
 
@@ -41,19 +41,44 @@ export function ConditionRow({
41
41
  ruleConfig = defaultRuleConfig,
42
42
  }: PropTypes) {
43
43
  const { left, operator, right } = value || {};
44
- const { rule } = useRule(left, ruleConfig.rules);
45
- const { renderOpSelect, opConfig } = useOp({
46
- rule,
47
- op: operator,
48
- onChange: (v) => onChange({ ...value, operator: v }),
49
- readonly,
50
- userOps: ruleConfig.ops,
44
+
45
+ const available = useScopeAvailable();
46
+
47
+ const variable = useMemo(() => {
48
+ if (!left) return undefined;
49
+ return available.getByKeyPath(left.content);
50
+ }, [available, left]);
51
+
52
+ const leftSchema = useMemo(() => {
53
+ if (!variable) return undefined;
54
+ return JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
55
+ }, [variable?.type?.hash]);
56
+
57
+ const { rule, opConfig, opOptionList, targetSchema } = useCondition({
58
+ leftSchema,
59
+ operator,
51
60
  });
52
61
 
53
- const targetSchema = useMemo(() => {
54
- const targetType: string | null = rule?.[operator || ''] || null;
55
- return targetType ? { type: targetType, extra: { weak: true } } : null;
56
- }, [rule, opConfig]);
62
+ const renderOpSelect = () => (
63
+ <Select
64
+ style={{ height: 22 }}
65
+ disabled={readonly}
66
+ size="small"
67
+ value={operator}
68
+ optionList={opOptionList}
69
+ onChange={(v) => {
70
+ onChange({
71
+ ...value,
72
+ operator: v as string,
73
+ });
74
+ }}
75
+ triggerRender={({ value }) => (
76
+ <Button size="small" disabled={!rule}>
77
+ {opConfig?.abbreviation || <IconChevronDownStroked size="small" />}
78
+ </Button>
79
+ )}
80
+ />
81
+ );
57
82
 
58
83
  return (
59
84
  <UIContainer style={style}>
@@ -97,7 +122,4 @@ export function ConditionRow({
97
122
  );
98
123
  }
99
124
 
100
- ConditionRow.defaultRules = defaultRules;
101
- ConditionRow.defaultOpConfigs = defaultOpConfigs;
102
-
103
125
  export { type ConditionRowValueType };
@@ -5,36 +5,6 @@
5
5
 
6
6
  import { IFlowConstantRefValue, IFlowRefValue } from '@/shared';
7
7
 
8
- export enum Op {
9
- EQ = 'eq',
10
- NEQ = 'neq',
11
- GT = 'gt',
12
- GTE = 'gte',
13
- LT = 'lt',
14
- LTE = 'lte',
15
- IN = 'in',
16
- NIN = 'nin',
17
- CONTAINS = 'contains',
18
- NOT_CONTAINS = 'not_contains',
19
- IS_EMPTY = 'is_empty',
20
- IS_NOT_EMPTY = 'is_not_empty',
21
- IS_TRUE = 'is_true',
22
- IS_FALSE = 'is_false',
23
- }
24
-
25
- export interface OpConfig {
26
- label: string;
27
- abbreviation: string;
28
- // When right is not a value, display this text
29
- rightDisplay?: string;
30
- }
31
-
32
- export type OpConfigs = Record<string, OpConfig>;
33
-
34
- export type IRule = Partial<Record<string, string | null>>;
35
-
36
- export type IRules = Record<string, IRule>;
37
-
38
8
  export interface ConditionRowValueType {
39
9
  left?: IFlowRefValue;
40
10
  operator?: string;