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

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 (477) hide show
  1. package/bin/run.sh +6 -0
  2. package/dist/cjs/components/assign-row/index.js +112 -0
  3. package/dist/cjs/components/assign-row/types.js +18 -0
  4. package/dist/cjs/components/assign-rows/index.js +85 -0
  5. package/dist/cjs/components/batch-outputs/index.js +91 -0
  6. package/dist/cjs/components/batch-outputs/styles.js +60 -0
  7. package/dist/cjs/components/batch-outputs/types.js +18 -0
  8. package/dist/cjs/components/batch-variable-selector/index.js +53 -0
  9. package/dist/cjs/components/blur-input/index.js +64 -0
  10. package/dist/cjs/components/code-editor/editor.js +117 -0
  11. package/dist/cjs/components/code-editor/index.js +57 -0
  12. package/dist/cjs/components/code-editor/init-worker.js +56 -0
  13. package/dist/cjs/components/code-editor/language-features.js +21 -0
  14. package/dist/cjs/components/code-editor/theme/dark.js +188 -0
  15. package/dist/cjs/components/code-editor/theme/index.js +11 -0
  16. package/dist/cjs/components/code-editor/theme/light.js +195 -0
  17. package/dist/cjs/components/code-editor/utils.js +42 -0
  18. package/dist/cjs/components/code-editor-mini/index.js +66 -0
  19. package/dist/cjs/components/condition-row/constants.js +165 -0
  20. package/dist/cjs/components/condition-row/hooks/useOp.js +78 -0
  21. package/dist/cjs/components/condition-row/hooks/useRule.js +68 -0
  22. package/dist/cjs/components/condition-row/index.js +123 -0
  23. package/dist/cjs/components/condition-row/styles.js +77 -0
  24. package/dist/cjs/components/condition-row/types.js +52 -0
  25. package/dist/cjs/components/constant-input/index.js +80 -0
  26. package/dist/cjs/components/constant-input/types.js +18 -0
  27. package/dist/cjs/components/db-condition-row/hooks/use-left.js +86 -0
  28. package/dist/cjs/components/db-condition-row/hooks/use-op.js +79 -0
  29. package/dist/cjs/components/db-condition-row/index.js +115 -0
  30. package/dist/cjs/components/db-condition-row/styles.js +94 -0
  31. package/dist/cjs/components/db-condition-row/types.js +18 -0
  32. package/dist/cjs/components/display-flow-value/index.js +64 -0
  33. package/dist/cjs/components/display-inputs-values/index.js +76 -0
  34. package/dist/cjs/components/display-inputs-values/styles.js +51 -0
  35. package/dist/cjs/components/display-outputs/index.js +72 -0
  36. package/dist/cjs/components/display-outputs/styles.js +51 -0
  37. package/dist/cjs/components/display-schema-tag/index.js +77 -0
  38. package/dist/cjs/components/display-schema-tag/styles.js +71 -0
  39. package/dist/cjs/components/display-schema-tree/index.js +93 -0
  40. package/dist/cjs/components/display-schema-tree/styles.js +135 -0
  41. package/dist/cjs/components/dynamic-value-input/hooks.js +99 -0
  42. package/dist/cjs/components/dynamic-value-input/index.js +174 -0
  43. package/dist/cjs/components/dynamic-value-input/styles.js +107 -0
  44. package/dist/cjs/components/index.js +156 -0
  45. package/dist/cjs/components/inputs-values/index.js +112 -0
  46. package/dist/cjs/components/inputs-values/styles.js +60 -0
  47. package/dist/cjs/components/inputs-values/types.js +18 -0
  48. package/dist/cjs/components/inputs-values-tree/hooks/use-child-list.js +77 -0
  49. package/dist/cjs/components/inputs-values-tree/index.js +87 -0
  50. package/dist/cjs/components/inputs-values-tree/row.js +183 -0
  51. package/dist/cjs/components/inputs-values-tree/styles.js +177 -0
  52. package/dist/cjs/components/inputs-values-tree/types.js +18 -0
  53. package/dist/cjs/components/json-editor-with-variables/editor.js +81 -0
  54. package/dist/cjs/components/json-editor-with-variables/extensions/variable-tag.js +151 -0
  55. package/dist/cjs/components/json-editor-with-variables/extensions/variable-tree.js +97 -0
  56. package/dist/cjs/components/json-editor-with-variables/index.js +57 -0
  57. package/dist/cjs/components/json-editor-with-variables/styles.js +89 -0
  58. package/dist/cjs/components/json-schema-editor/default-value.js +54 -0
  59. package/dist/cjs/components/json-schema-editor/hooks.js +130 -0
  60. package/dist/cjs/components/json-schema-editor/index.js +246 -0
  61. package/dist/cjs/components/json-schema-editor/styles.js +231 -0
  62. package/dist/cjs/components/json-schema-editor/types.js +18 -0
  63. package/dist/cjs/components/prompt-editor/editor.js +99 -0
  64. package/dist/cjs/components/prompt-editor/extensions/jinja.js +73 -0
  65. package/dist/cjs/components/prompt-editor/extensions/language-support.js +48 -0
  66. package/dist/cjs/components/prompt-editor/extensions/markdown.js +81 -0
  67. package/dist/cjs/components/prompt-editor/index.js +57 -0
  68. package/dist/cjs/components/prompt-editor/styles.js +55 -0
  69. package/dist/cjs/components/prompt-editor/types.js +7 -0
  70. package/dist/cjs/components/prompt-editor-with-inputs/editor.js +47 -0
  71. package/dist/cjs/components/prompt-editor-with-inputs/extensions/inputs-tree.js +101 -0
  72. package/dist/cjs/components/prompt-editor-with-inputs/index.js +57 -0
  73. package/dist/cjs/components/prompt-editor-with-inputs/inputs-picker.js +104 -0
  74. package/dist/cjs/components/prompt-editor-with-variables/editor.js +49 -0
  75. package/dist/cjs/components/prompt-editor-with-variables/extensions/variable-tag.js +151 -0
  76. package/dist/cjs/components/prompt-editor-with-variables/extensions/variable-tree.js +103 -0
  77. package/dist/cjs/components/prompt-editor-with-variables/index.js +57 -0
  78. package/dist/cjs/components/prompt-editor-with-variables/styles.js +89 -0
  79. package/dist/cjs/components/type-selector/index.js +139 -0
  80. package/dist/cjs/components/variable-selector/context.js +56 -0
  81. package/dist/cjs/components/variable-selector/index.js +143 -0
  82. package/dist/cjs/components/variable-selector/styles.js +114 -0
  83. package/dist/cjs/components/variable-selector/use-variable-tree.js +100 -0
  84. package/dist/cjs/effects/auto-rename-ref/index.js +98 -0
  85. package/dist/cjs/effects/index.js +60 -0
  86. package/dist/cjs/effects/listen-ref-schema-change/index.js +57 -0
  87. package/dist/cjs/effects/listen-ref-value-change/index.js +54 -0
  88. package/dist/cjs/effects/provide-batch-input/index.js +64 -0
  89. package/dist/cjs/effects/provide-json-schema-outputs/index.js +49 -0
  90. package/dist/cjs/effects/sync-variable-title/index.js +52 -0
  91. package/dist/cjs/effects/validate-when-variable-sync/index.js +49 -0
  92. package/dist/cjs/form-plugins/batch-outputs-plugin/index.js +97 -0
  93. package/dist/cjs/form-plugins/index.js +47 -0
  94. package/dist/cjs/form-plugins/infer-assign-plugin/index.js +72 -0
  95. package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +47 -0
  96. package/dist/cjs/hooks/index.js +36 -0
  97. package/dist/cjs/hooks/use-object-list/index.js +136 -0
  98. package/dist/cjs/index.js +228 -0
  99. package/dist/cjs/plugins/disable-declaration-plugin/create-disable-declaration-plugin.js +51 -0
  100. package/dist/cjs/plugins/disable-declaration-plugin/index.js +36 -0
  101. package/dist/cjs/plugins/index.js +49 -0
  102. package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +49 -0
  103. package/dist/cjs/plugins/json-schema-preset/index.js +57 -0
  104. package/dist/cjs/plugins/json-schema-preset/manager.js +18 -0
  105. package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +49 -0
  106. package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +63 -0
  107. package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +52 -0
  108. package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +53 -0
  109. package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +49 -0
  110. package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +49 -0
  111. package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +49 -0
  112. package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +54 -0
  113. package/dist/cjs/shared/flow-value/index.js +36 -0
  114. package/dist/cjs/shared/flow-value/schema.js +82 -0
  115. package/dist/cjs/shared/flow-value/types.js +18 -0
  116. package/dist/cjs/shared/flow-value/utils.js +142 -0
  117. package/dist/cjs/shared/format-legacy-refs/index.js +99 -0
  118. package/dist/cjs/shared/index.js +73 -0
  119. package/dist/cjs/shared/inject-material/index.js +65 -0
  120. package/dist/cjs/shared/lazy-suspense/index.js +58 -0
  121. package/dist/cjs/shared/polyfill-create-root/index.js +53 -0
  122. package/dist/cjs/validate/index.js +36 -0
  123. package/dist/cjs/validate/validate-flow-value/index.js +63 -0
  124. package/dist/esm/components/assign-row/index.mjs +78 -0
  125. package/dist/esm/components/assign-row/types.mjs +0 -0
  126. package/dist/esm/components/assign-rows/index.mjs +51 -0
  127. package/dist/esm/components/batch-outputs/index.mjs +57 -0
  128. package/dist/esm/components/batch-outputs/styles.mjs +13 -0
  129. package/dist/esm/components/batch-outputs/types.mjs +0 -0
  130. package/dist/esm/components/batch-variable-selector/index.mjs +19 -0
  131. package/dist/esm/components/blur-input/index.mjs +20 -0
  132. package/dist/esm/components/code-editor/editor.mjs +55 -0
  133. package/dist/esm/components/code-editor/index.mjs +5 -0
  134. package/dist/esm/components/code-editor/init-worker.mjs +19 -0
  135. package/dist/esm/components/code-editor/language-features.mjs +15 -0
  136. package/dist/esm/components/code-editor/theme/dark.mjs +154 -0
  137. package/dist/esm/components/code-editor/theme/index.mjs +5 -0
  138. package/dist/esm/components/code-editor/theme/light.mjs +161 -0
  139. package/dist/esm/components/code-editor/utils.mjs +8 -0
  140. package/dist/esm/components/code-editor-mini/index.mjs +22 -0
  141. package/dist/esm/components/condition-row/constants.mjs +128 -0
  142. package/dist/esm/components/condition-row/hooks/useOp.mjs +44 -0
  143. package/dist/esm/components/condition-row/hooks/useRule.mjs +34 -0
  144. package/dist/esm/components/condition-row/index.mjs +89 -0
  145. package/dist/esm/components/condition-row/styles.mjs +21 -0
  146. package/dist/esm/components/condition-row/types.mjs +18 -0
  147. package/dist/esm/components/constant-input/index.mjs +36 -0
  148. package/dist/esm/components/constant-input/types.mjs +0 -0
  149. package/dist/esm/components/db-condition-row/hooks/use-left.mjs +52 -0
  150. package/dist/esm/components/db-condition-row/hooks/use-op.mjs +45 -0
  151. package/dist/esm/components/db-condition-row/index.mjs +81 -0
  152. package/dist/esm/components/db-condition-row/styles.mjs +32 -0
  153. package/dist/esm/components/db-condition-row/types.mjs +0 -0
  154. package/dist/esm/components/display-flow-value/index.mjs +30 -0
  155. package/dist/esm/components/display-inputs-values/index.mjs +39 -0
  156. package/dist/esm/components/display-inputs-values/styles.mjs +7 -0
  157. package/dist/esm/components/display-outputs/index.mjs +38 -0
  158. package/dist/esm/components/display-outputs/styles.mjs +7 -0
  159. package/dist/esm/components/display-schema-tag/index.mjs +33 -0
  160. package/dist/esm/components/display-schema-tag/styles.mjs +21 -0
  161. package/dist/esm/components/display-schema-tree/index.mjs +49 -0
  162. package/dist/esm/components/display-schema-tree/styles.mjs +79 -0
  163. package/dist/esm/components/dynamic-value-input/hooks.mjs +59 -0
  164. package/dist/esm/components/dynamic-value-input/index.mjs +137 -0
  165. package/dist/esm/components/dynamic-value-input/styles.mjs +54 -0
  166. package/dist/esm/components/index.mjs +26 -0
  167. package/dist/esm/components/inputs-values/index.mjs +78 -0
  168. package/dist/esm/components/inputs-values/styles.mjs +13 -0
  169. package/dist/esm/components/inputs-values/types.mjs +0 -0
  170. package/dist/esm/components/inputs-values-tree/hooks/use-child-list.mjs +43 -0
  171. package/dist/esm/components/inputs-values-tree/index.mjs +53 -0
  172. package/dist/esm/components/inputs-values-tree/row.mjs +149 -0
  173. package/dist/esm/components/inputs-values-tree/styles.mjs +105 -0
  174. package/dist/esm/components/inputs-values-tree/types.mjs +0 -0
  175. package/dist/esm/components/json-editor-with-variables/editor.mjs +47 -0
  176. package/dist/esm/components/json-editor-with-variables/extensions/variable-tag.mjs +117 -0
  177. package/dist/esm/components/json-editor-with-variables/extensions/variable-tree.mjs +63 -0
  178. package/dist/esm/components/json-editor-with-variables/index.mjs +5 -0
  179. package/dist/esm/components/json-editor-with-variables/styles.mjs +36 -0
  180. package/dist/esm/components/json-schema-editor/default-value.mjs +20 -0
  181. package/dist/esm/components/json-schema-editor/hooks.mjs +96 -0
  182. package/dist/esm/components/json-schema-editor/index.mjs +212 -0
  183. package/dist/esm/components/json-schema-editor/styles.mjs +138 -0
  184. package/dist/esm/components/json-schema-editor/types.mjs +0 -0
  185. package/dist/esm/components/prompt-editor/editor.mjs +52 -0
  186. package/dist/esm/components/prompt-editor/extensions/jinja.mjs +39 -0
  187. package/dist/esm/components/prompt-editor/extensions/language-support.mjs +14 -0
  188. package/dist/esm/components/prompt-editor/extensions/markdown.mjs +47 -0
  189. package/dist/esm/components/prompt-editor/index.mjs +5 -0
  190. package/dist/esm/components/prompt-editor/styles.mjs +11 -0
  191. package/dist/esm/components/prompt-editor/types.mjs +1 -0
  192. package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +13 -0
  193. package/dist/esm/components/prompt-editor-with-inputs/extensions/inputs-tree.mjs +67 -0
  194. package/dist/esm/components/prompt-editor-with-inputs/index.mjs +5 -0
  195. package/dist/esm/components/prompt-editor-with-inputs/inputs-picker.mjs +70 -0
  196. package/dist/esm/components/prompt-editor-with-variables/editor.mjs +15 -0
  197. package/dist/esm/components/prompt-editor-with-variables/extensions/variable-tag.mjs +117 -0
  198. package/dist/esm/components/prompt-editor-with-variables/extensions/variable-tree.mjs +69 -0
  199. package/dist/esm/components/prompt-editor-with-variables/index.mjs +5 -0
  200. package/dist/esm/components/prompt-editor-with-variables/styles.mjs +36 -0
  201. package/dist/esm/components/type-selector/index.mjs +96 -0
  202. package/dist/esm/components/variable-selector/context.mjs +16 -0
  203. package/dist/esm/components/variable-selector/index.mjs +100 -0
  204. package/dist/esm/components/variable-selector/styles.mjs +58 -0
  205. package/dist/esm/components/variable-selector/use-variable-tree.mjs +66 -0
  206. package/dist/esm/effects/auto-rename-ref/index.mjs +64 -0
  207. package/dist/esm/effects/index.mjs +8 -0
  208. package/dist/esm/effects/listen-ref-schema-change/index.mjs +23 -0
  209. package/dist/esm/effects/listen-ref-value-change/index.mjs +20 -0
  210. package/dist/esm/effects/provide-batch-input/index.mjs +30 -0
  211. package/dist/esm/effects/provide-json-schema-outputs/index.mjs +15 -0
  212. package/dist/esm/effects/sync-variable-title/index.mjs +18 -0
  213. package/dist/esm/effects/validate-when-variable-sync/index.mjs +15 -0
  214. package/dist/esm/form-plugins/batch-outputs-plugin/index.mjs +60 -0
  215. package/dist/esm/form-plugins/index.mjs +4 -0
  216. package/dist/esm/form-plugins/infer-assign-plugin/index.mjs +38 -0
  217. package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +13 -0
  218. package/dist/esm/hooks/index.mjs +2 -0
  219. package/dist/esm/hooks/use-object-list/index.mjs +102 -0
  220. package/dist/esm/index.mjs +8 -0
  221. package/dist/esm/plugins/disable-declaration-plugin/create-disable-declaration-plugin.mjs +17 -0
  222. package/dist/esm/plugins/disable-declaration-plugin/index.mjs +2 -0
  223. package/dist/esm/plugins/index.mjs +3 -0
  224. package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +15 -0
  225. package/dist/esm/plugins/json-schema-preset/index.mjs +14 -0
  226. package/dist/esm/plugins/json-schema-preset/manager.mjs +0 -0
  227. package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +15 -0
  228. package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +29 -0
  229. package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +18 -0
  230. package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +19 -0
  231. package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +15 -0
  232. package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +15 -0
  233. package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +15 -0
  234. package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +20 -0
  235. package/dist/esm/shared/flow-value/index.mjs +2 -0
  236. package/dist/esm/shared/flow-value/schema.mjs +26 -0
  237. package/dist/esm/shared/flow-value/types.mjs +0 -0
  238. package/dist/esm/shared/flow-value/utils.mjs +108 -0
  239. package/dist/esm/shared/format-legacy-refs/index.mjs +50 -0
  240. package/dist/esm/shared/index.mjs +6 -0
  241. package/dist/esm/shared/inject-material/index.mjs +21 -0
  242. package/dist/esm/shared/lazy-suspense/index.mjs +21 -0
  243. package/dist/esm/shared/polyfill-create-root/index.mjs +16 -0
  244. package/dist/esm/validate/index.mjs +2 -0
  245. package/dist/esm/validate/validate-flow-value/index.mjs +29 -0
  246. package/dist/tsconfig.tsbuildinfo +1 -0
  247. package/dist/types/components/assign-row/index.d.ts +8 -0
  248. package/dist/types/components/assign-row/types.d.ts +20 -0
  249. package/dist/types/components/assign-rows/index.d.ts +11 -0
  250. package/dist/types/components/batch-outputs/index.d.ts +7 -0
  251. package/dist/types/components/batch-outputs/styles.d.ts +6 -0
  252. package/dist/types/components/batch-outputs/types.d.ts +18 -0
  253. package/dist/types/components/batch-variable-selector/index.d.ts +7 -0
  254. package/dist/types/components/blur-input/index.d.ts +7 -0
  255. package/dist/types/components/code-editor/editor.d.ts +23 -0
  256. package/dist/types/components/code-editor/index.d.ts +6 -0
  257. package/{src/validate/index.tsx → dist/types/components/code-editor/init-worker.d.ts} +1 -2
  258. package/{src/typings/index.ts → dist/types/components/code-editor/language-features.d.ts} +1 -2
  259. package/dist/types/components/code-editor/theme/dark.d.ts +6 -0
  260. package/{src/hooks/index.tsx → dist/types/components/code-editor/theme/index.d.ts} +1 -2
  261. package/dist/types/components/code-editor/theme/light.d.ts +6 -0
  262. package/dist/types/components/code-editor/utils.d.ts +5 -0
  263. package/dist/types/components/code-editor-mini/index.d.ts +7 -0
  264. package/dist/types/components/condition-row/constants.d.ts +7 -0
  265. package/dist/types/components/condition-row/hooks/useOp.d.ts +18 -0
  266. package/dist/types/components/condition-row/hooks/useRule.d.ts +9 -0
  267. package/dist/types/components/condition-row/index.d.ts +22 -0
  268. package/dist/types/components/condition-row/styles.d.ts +9 -0
  269. package/dist/types/components/condition-row/types.d.ts +34 -0
  270. package/dist/types/components/constant-input/index.d.ts +8 -0
  271. package/dist/types/components/constant-input/types.d.ts +16 -0
  272. package/dist/types/components/db-condition-row/hooks/use-left.d.ts +18 -0
  273. package/dist/types/components/db-condition-row/hooks/use-op.d.ts +18 -0
  274. package/dist/types/components/db-condition-row/index.d.ts +19 -0
  275. package/dist/types/components/db-condition-row/styles.d.ts +12 -0
  276. package/dist/types/components/db-condition-row/types.d.ts +25 -0
  277. package/dist/types/components/display-flow-value/index.d.ts +15 -0
  278. package/dist/types/components/display-inputs-values/index.d.ts +14 -0
  279. package/dist/types/components/display-inputs-values/styles.d.ts +5 -0
  280. package/dist/types/components/display-outputs/index.d.ts +14 -0
  281. package/dist/types/components/display-outputs/styles.d.ts +5 -0
  282. package/dist/types/components/display-schema-tag/index.d.ts +14 -0
  283. package/dist/types/components/display-schema-tag/styles.d.ts +8 -0
  284. package/dist/types/components/display-schema-tree/index.d.ts +16 -0
  285. package/dist/types/components/display-schema-tree/styles.d.ts +11 -0
  286. package/dist/types/components/dynamic-value-input/hooks.d.ts +28 -0
  287. package/dist/types/components/dynamic-value-input/index.d.ts +27 -0
  288. package/dist/types/components/dynamic-value-input/styles.d.ts +8 -0
  289. package/dist/types/components/index.d.ts +29 -0
  290. package/dist/types/components/inputs-values/index.d.ts +7 -0
  291. package/dist/types/components/inputs-values/styles.d.ts +6 -0
  292. package/dist/types/components/inputs-values/types.d.ts +19 -0
  293. package/dist/types/components/inputs-values-tree/hooks/use-child-list.d.ts +19 -0
  294. package/dist/types/components/inputs-values-tree/index.d.ts +7 -0
  295. package/dist/types/components/inputs-values-tree/row.d.ts +15 -0
  296. package/dist/types/components/inputs-values-tree/styles.d.ts +23 -0
  297. package/dist/types/components/inputs-values-tree/types.d.ts +18 -0
  298. package/dist/types/components/json-editor-with-variables/editor.d.ts +9 -0
  299. package/dist/types/components/json-editor-with-variables/extensions/variable-tag.d.ts +5 -0
  300. package/dist/types/components/json-editor-with-variables/extensions/variable-tree.d.ts +6 -0
  301. package/dist/types/components/json-editor-with-variables/index.d.ts +6 -0
  302. package/dist/types/components/json-editor-with-variables/styles.d.ts +9 -0
  303. package/dist/types/components/json-schema-editor/default-value.d.ts +17 -0
  304. package/dist/types/components/json-schema-editor/hooks.d.ts +12 -0
  305. package/dist/types/components/json-schema-editor/index.d.ts +14 -0
  306. package/dist/types/components/json-schema-editor/styles.d.ts +30 -0
  307. package/dist/types/components/json-schema-editor/types.d.ts +20 -0
  308. package/dist/types/components/prompt-editor/editor.d.ts +15 -0
  309. package/dist/types/components/prompt-editor/extensions/jinja.d.ts +6 -0
  310. package/dist/types/components/prompt-editor/extensions/language-support.d.ts +6 -0
  311. package/dist/types/components/prompt-editor/extensions/markdown.d.ts +6 -0
  312. package/dist/types/components/prompt-editor/index.d.ts +6 -0
  313. package/dist/types/components/prompt-editor/styles.d.ts +7 -0
  314. package/dist/types/components/prompt-editor/types.d.ts +16 -0
  315. package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +10 -0
  316. package/dist/types/components/prompt-editor-with-inputs/extensions/inputs-tree.d.ts +9 -0
  317. package/dist/types/components/prompt-editor-with-inputs/index.d.ts +6 -0
  318. package/dist/types/components/prompt-editor-with-inputs/inputs-picker.d.ts +9 -0
  319. package/dist/types/components/prompt-editor-with-variables/editor.d.ts +9 -0
  320. package/dist/types/components/prompt-editor-with-variables/extensions/variable-tag.d.ts +5 -0
  321. package/dist/types/components/prompt-editor-with-variables/extensions/variable-tree.d.ts +6 -0
  322. package/dist/types/components/prompt-editor-with-variables/index.d.ts +6 -0
  323. package/dist/types/components/prompt-editor-with-variables/styles.d.ts +9 -0
  324. package/dist/types/components/type-selector/index.d.ts +23 -0
  325. package/dist/types/components/variable-selector/context.d.ts +16 -0
  326. package/dist/types/components/variable-selector/index.d.ts +29 -0
  327. package/dist/types/components/variable-selector/styles.d.ts +14 -0
  328. package/dist/types/components/variable-selector/use-variable-tree.d.ts +18 -0
  329. package/dist/types/effects/auto-rename-ref/index.d.ts +17 -0
  330. package/dist/types/effects/index.d.ts +11 -0
  331. package/dist/types/effects/listen-ref-schema-change/index.d.ts +22 -0
  332. package/dist/types/effects/listen-ref-value-change/index.d.ts +22 -0
  333. package/dist/types/effects/provide-batch-input/index.d.ts +6 -0
  334. package/dist/types/effects/provide-json-schema-outputs/index.d.ts +6 -0
  335. package/dist/types/effects/sync-variable-title/index.d.ts +6 -0
  336. package/dist/types/effects/validate-when-variable-sync/index.d.ts +8 -0
  337. package/dist/types/form-plugins/batch-outputs-plugin/index.d.ts +12 -0
  338. package/dist/types/form-plugins/index.d.ts +7 -0
  339. package/dist/types/form-plugins/infer-assign-plugin/index.d.ts +10 -0
  340. package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +11 -0
  341. package/dist/types/hooks/index.d.ts +5 -0
  342. package/dist/types/hooks/use-object-list/index.d.ts +22 -0
  343. package/dist/types/index.d.ts +11 -0
  344. package/dist/types/plugins/disable-declaration-plugin/create-disable-declaration-plugin.d.ts +5 -0
  345. package/dist/types/plugins/disable-declaration-plugin/index.d.ts +5 -0
  346. package/dist/types/plugins/index.d.ts +6 -0
  347. package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +9 -0
  348. package/dist/types/plugins/json-schema-preset/index.d.ts +13 -0
  349. package/dist/types/plugins/json-schema-preset/manager.d.ts +17 -0
  350. package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +6 -0
  351. package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +6 -0
  352. package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +6 -0
  353. package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +5 -0
  354. package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +6 -0
  355. package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +6 -0
  356. package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +6 -0
  357. package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +6 -0
  358. package/dist/types/shared/flow-value/index.d.ts +6 -0
  359. package/dist/types/shared/flow-value/schema.d.ts +107 -0
  360. package/dist/types/shared/flow-value/types.d.ts +32 -0
  361. package/dist/types/shared/flow-value/utils.d.ts +65 -0
  362. package/dist/types/shared/format-legacy-refs/index.d.ts +84 -0
  363. package/dist/types/shared/index.d.ts +9 -0
  364. package/dist/types/shared/inject-material/index.d.ts +46 -0
  365. package/dist/types/shared/lazy-suspense/index.d.ts +7 -0
  366. package/dist/types/shared/polyfill-create-root/index.d.ts +10 -0
  367. package/dist/types/validate/index.d.ts +5 -0
  368. package/dist/types/validate/validate-flow-value/index.d.ts +19 -0
  369. package/package.json +22 -23
  370. package/src/components/assign-row/index.tsx +3 -3
  371. package/src/components/assign-row/types.ts +1 -1
  372. package/src/components/batch-outputs/index.tsx +3 -2
  373. package/src/components/batch-outputs/types.ts +1 -1
  374. package/src/components/code-editor/editor.tsx +97 -0
  375. package/src/components/code-editor/index.tsx +5 -89
  376. package/src/components/code-editor/init-worker.ts +27 -0
  377. package/src/components/code-editor/language-features.ts +6 -27
  378. package/src/components/code-editor/theme/dark.ts +50 -31
  379. package/src/components/code-editor/theme/index.ts +1 -1
  380. package/src/components/code-editor/theme/light.ts +57 -33
  381. package/src/components/code-editor-mini/index.tsx +2 -2
  382. package/src/components/condition-row/constants.ts +8 -0
  383. package/src/components/condition-row/hooks/useRule.ts +1 -1
  384. package/src/components/condition-row/index.tsx +4 -0
  385. package/src/components/condition-row/types.ts +1 -1
  386. package/src/components/constant-input/index.tsx +1 -1
  387. package/src/components/db-condition-row/hooks/use-left.tsx +66 -0
  388. package/src/components/db-condition-row/hooks/use-op.tsx +59 -0
  389. package/src/components/db-condition-row/index.tsx +93 -0
  390. package/src/components/db-condition-row/styles.tsx +43 -0
  391. package/src/components/db-condition-row/types.ts +34 -0
  392. package/src/components/display-flow-value/index.tsx +3 -13
  393. package/src/components/display-inputs-values/index.tsx +44 -6
  394. package/src/components/dynamic-value-input/hooks.ts +25 -4
  395. package/src/components/dynamic-value-input/index.tsx +21 -12
  396. package/src/components/dynamic-value-input/styles.tsx +14 -4
  397. package/src/components/index.ts +50 -22
  398. package/src/components/inputs-values/index.tsx +15 -4
  399. package/src/components/inputs-values/styles.tsx +1 -1
  400. package/src/components/inputs-values/types.ts +1 -1
  401. package/src/components/inputs-values-tree/hooks/use-child-list.tsx +76 -0
  402. package/src/components/inputs-values-tree/index.tsx +62 -0
  403. package/src/components/inputs-values-tree/row.tsx +177 -0
  404. package/src/components/inputs-values-tree/styles.tsx +128 -0
  405. package/src/components/inputs-values-tree/types.ts +21 -0
  406. package/src/components/json-editor-with-variables/editor.tsx +69 -0
  407. package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +7 -6
  408. package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +3 -3
  409. package/src/components/json-editor-with-variables/index.tsx +5 -59
  410. package/src/components/json-schema-editor/default-value.tsx +1 -3
  411. package/src/components/json-schema-editor/hooks.tsx +14 -3
  412. package/src/components/json-schema-editor/index.tsx +18 -58
  413. package/src/components/json-schema-editor/styles.tsx +12 -55
  414. package/src/components/json-schema-editor/types.ts +0 -1
  415. package/src/components/prompt-editor/editor.tsx +81 -0
  416. package/src/components/prompt-editor/extensions/jinja.tsx +2 -2
  417. package/src/components/prompt-editor/extensions/language-support.tsx +2 -2
  418. package/src/components/prompt-editor/extensions/markdown.tsx +2 -2
  419. package/src/components/prompt-editor/index.tsx +5 -62
  420. package/src/components/prompt-editor/types.tsx +1 -1
  421. package/src/components/prompt-editor-with-inputs/editor.tsx +25 -0
  422. package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +15 -4
  423. package/src/components/prompt-editor-with-inputs/index.tsx +5 -16
  424. package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +34 -17
  425. package/src/components/prompt-editor-with-variables/editor.tsx +22 -0
  426. package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +13 -21
  427. package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +16 -4
  428. package/src/components/prompt-editor-with-variables/index.tsx +5 -13
  429. package/src/components/type-selector/index.tsx +12 -2
  430. package/src/components/variable-selector/context.tsx +28 -0
  431. package/src/components/variable-selector/index.tsx +10 -1
  432. package/src/components/variable-selector/use-variable-tree.tsx +3 -3
  433. package/src/effects/auto-rename-ref/index.ts +8 -55
  434. package/src/effects/index.ts +7 -7
  435. package/src/effects/listen-ref-schema-change/index.ts +1 -1
  436. package/src/effects/listen-ref-value-change/index.ts +1 -1
  437. package/src/effects/provide-batch-input/index.ts +1 -1
  438. package/src/effects/validate-when-variable-sync/index.ts +1 -1
  439. package/src/form-plugins/batch-outputs-plugin/index.ts +1 -1
  440. package/src/form-plugins/index.ts +3 -3
  441. package/src/form-plugins/infer-assign-plugin/index.ts +2 -2
  442. package/src/form-plugins/infer-inputs-plugin/index.ts +4 -76
  443. package/src/hooks/index.ts +6 -0
  444. package/src/hooks/use-object-list/index.tsx +35 -7
  445. package/src/index.ts +98 -7
  446. package/src/plugins/index.ts +11 -2
  447. package/src/plugins/json-schema-preset/index.tsx +4 -4
  448. package/src/plugins/json-schema-preset/manager.ts +1 -0
  449. package/src/plugins/json-schema-preset/type-definition/date-time.tsx +25 -0
  450. package/src/plugins/json-schema-preset/type-definition/index.tsx +2 -0
  451. package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -9
  452. package/src/shared/flow-value/index.ts +16 -0
  453. package/src/shared/flow-value/schema.ts +38 -0
  454. package/src/{typings/flow-value/index.ts → shared/flow-value/types.ts} +3 -1
  455. package/src/shared/flow-value/utils.ts +200 -0
  456. package/src/shared/format-legacy-refs/index.ts +1 -1
  457. package/src/shared/index.ts +26 -2
  458. package/src/shared/lazy-suspense/index.tsx +28 -0
  459. package/src/shared/polyfill-create-root/index.tsx +33 -0
  460. package/src/validate/index.ts +6 -0
  461. package/src/validate/validate-flow-value/index.tsx +4 -16
  462. package/bin/index.ts +0 -91
  463. package/bin/materials.ts +0 -107
  464. package/bin/project.ts +0 -95
  465. package/bin/utils/import.ts +0 -127
  466. package/bin/utils/traverse-file.ts +0 -60
  467. package/dist/esm/index.js +0 -3864
  468. package/dist/esm/index.js.map +0 -1
  469. package/dist/index.d.mts +0 -763
  470. package/dist/index.d.ts +0 -763
  471. package/dist/index.js +0 -3849
  472. package/dist/index.js.map +0 -1
  473. package/src/components/inputs-values/components/blur-input.tsx +0 -27
  474. package/src/components/json-schema-editor/components/blur-input.tsx +0 -27
  475. package/src/plugins/disable-declaration-plugin/config.json +0 -5
  476. package/src/plugins/json-schema-preset/config.json +0 -9
  477. /package/src/components/{assign-row/components/blur-input.tsx → blur-input/index.tsx} +0 -0
package/dist/index.js DELETED
@@ -1,3849 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- AssignRow: () => AssignRow,
34
- AssignRows: () => AssignRows,
35
- BatchOutputs: () => BatchOutputs,
36
- BatchVariableSelector: () => BatchVariableSelector,
37
- CodeEditor: () => CodeEditor,
38
- CodeEditorMini: () => CodeEditorMini,
39
- ConditionRow: () => ConditionRow,
40
- ConstantInput: () => ConstantInput,
41
- DisplayFlowValue: () => DisplayFlowValue,
42
- DisplayInputsValues: () => DisplayInputsValues,
43
- DisplayOutputs: () => DisplayOutputs,
44
- DisplaySchemaTag: () => DisplaySchemaTag,
45
- DisplaySchemaTree: () => DisplaySchemaTree,
46
- DynamicValueInput: () => DynamicValueInput,
47
- InjectDynamicValueInput: () => InjectDynamicValueInput,
48
- InjectTypeSelector: () => InjectTypeSelector,
49
- InjectVariableSelector: () => InjectVariableSelector,
50
- InputsValues: () => InputsValues,
51
- JsonEditorWithVariables: () => JsonEditorWithVariables,
52
- JsonSchemaEditor: () => JsonSchemaEditor,
53
- JsonSchemaTypePresetProvider: () => JsonSchemaTypePresetProvider,
54
- JsonSchemaUtils: () => import_json_schema3.JsonSchemaUtils,
55
- PromptEditor: () => PromptEditor,
56
- PromptEditorWithInputs: () => PromptEditorWithInputs,
57
- PromptEditorWithVariables: () => PromptEditorWithVariables,
58
- TypeSelector: () => TypeSelector,
59
- VariableSelector: () => VariableSelector,
60
- autoRenameRefEffect: () => autoRenameRefEffect,
61
- createBatchOutputsFormPlugin: () => createBatchOutputsFormPlugin,
62
- createDisableDeclarationPlugin: () => createDisableDeclarationPlugin,
63
- createInferAssignPlugin: () => createInferAssignPlugin,
64
- createInferInputsPlugin: () => createInferInputsPlugin,
65
- createInjectMaterial: () => createInjectMaterial,
66
- createTypePresetPlugin: () => createTypePresetPlugin,
67
- formatLegacyRefOnInit: () => formatLegacyRefOnInit,
68
- formatLegacyRefOnSubmit: () => formatLegacyRefOnSubmit,
69
- formatLegacyRefToNewRef: () => formatLegacyRefToNewRef,
70
- formatNewRefToLegacyRef: () => formatNewRefToLegacyRef,
71
- getTypeSelectValue: () => getTypeSelectValue,
72
- isLegacyFlowRefValueSchema: () => isLegacyFlowRefValueSchema,
73
- isNewFlowRefValueSchema: () => isNewFlowRefValueSchema,
74
- listenRefSchemaChange: () => listenRefSchemaChange,
75
- listenRefValueChange: () => listenRefValueChange,
76
- parseTypeSelectValue: () => parseTypeSelectValue,
77
- provideBatchInputEffect: () => provideBatchInputEffect,
78
- provideBatchOutputsEffect: () => provideBatchOutputsEffect,
79
- provideJsonSchemaOutputs: () => provideJsonSchemaOutputs,
80
- syncVariableTitle: () => syncVariableTitle,
81
- useTypeManager: () => useTypeManager,
82
- useVariableTree: () => useVariableTree,
83
- validateFlowValue: () => validateFlowValue,
84
- validateWhenVariableSync: () => validateWhenVariableSync
85
- });
86
- module.exports = __toCommonJS(src_exports);
87
-
88
- // ../../../common/temp/node_modules/.pnpm/tsup@8.3.5_typescript@5.8.3/node_modules/tsup/assets/cjs_shims.js
89
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
90
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
91
-
92
- // src/components/variable-selector/index.tsx
93
- var import_react13 = __toESM(require("react"));
94
- var import_editor12 = require("@flowgram.ai/editor");
95
- var import_semi_ui7 = require("@douyinfe/semi-ui");
96
- var import_semi_icons = require("@douyinfe/semi-icons");
97
-
98
- // src/shared/format-legacy-refs/index.ts
99
- var import_lodash = require("lodash");
100
- function formatLegacyRefOnSubmit(value) {
101
- if ((0, import_lodash.isObject)(value)) {
102
- if (isLegacyFlowRefValueSchema(value)) {
103
- return formatLegacyRefToNewRef(value);
104
- }
105
- return Object.fromEntries(
106
- Object.entries(value).map(([key, value2]) => [
107
- key,
108
- formatLegacyRefOnSubmit(value2)
109
- ])
110
- );
111
- }
112
- if (Array.isArray(value)) {
113
- return value.map(formatLegacyRefOnSubmit);
114
- }
115
- return value;
116
- }
117
- function formatLegacyRefOnInit(value) {
118
- if ((0, import_lodash.isObject)(value)) {
119
- if (isNewFlowRefValueSchema(value)) {
120
- return formatNewRefToLegacyRef(value);
121
- }
122
- return Object.fromEntries(
123
- Object.entries(value).map(([key, value2]) => [
124
- key,
125
- formatLegacyRefOnInit(value2)
126
- ])
127
- );
128
- }
129
- if (Array.isArray(value)) {
130
- return value.map(formatLegacyRefOnInit);
131
- }
132
- return value;
133
- }
134
- function isLegacyFlowRefValueSchema(value) {
135
- return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
136
- }
137
- function isNewFlowRefValueSchema(value) {
138
- return (0, import_lodash.isObject)(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
139
- }
140
- function formatLegacyRefToNewRef(value) {
141
- const keyPath = value.content.split(".");
142
- if (keyPath[1] === "outputs") {
143
- return {
144
- type: "ref",
145
- content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
146
- };
147
- }
148
- return {
149
- type: "ref",
150
- content: keyPath
151
- };
152
- }
153
- function formatNewRefToLegacyRef(value) {
154
- return {
155
- type: "ref",
156
- content: value.content.join(".")
157
- };
158
- }
159
-
160
- // src/shared/inject-material/index.tsx
161
- var import_react = __toESM(require("react"));
162
- var import_editor = require("@flowgram.ai/editor");
163
- function createInjectMaterial(Component, params) {
164
- const InjectComponent = (props) => {
165
- const container = (0, import_editor.usePlaygroundContainer)();
166
- if (!container?.isBound(import_editor.FlowRendererRegistry)) {
167
- return import_react.default.createElement(Component, { ...props });
168
- }
169
- const rendererRegistry = container.get(import_editor.FlowRendererRegistry);
170
- const renderKey = params?.renderKey || Component.renderKey || Component.name || "";
171
- const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);
172
- if (renderer?.type !== import_editor.FlowRendererComponentType.REACT) {
173
- return import_react.default.createElement(Component, { ...props });
174
- }
175
- return import_react.default.createElement(renderer.renderer, {
176
- ...props
177
- });
178
- };
179
- return InjectComponent;
180
- }
181
-
182
- // src/components/variable-selector/use-variable-tree.tsx
183
- var import_react12 = __toESM(require("react"));
184
- var import_json_schema4 = require("@flowgram.ai/json-schema");
185
- var import_editor11 = require("@flowgram.ai/editor");
186
- var import_semi_ui5 = require("@douyinfe/semi-ui");
187
-
188
- // src/plugins/json-schema-preset/index.tsx
189
- var import_react11 = __toESM(require("react"));
190
- var import_json_schema3 = require("@flowgram.ai/json-schema");
191
-
192
- // src/plugins/json-schema-preset/type-definition/index.tsx
193
- var import_json_schema = require("@flowgram.ai/json-schema");
194
-
195
- // src/plugins/json-schema-preset/type-definition/string.tsx
196
- var import_react2 = __toESM(require("react"));
197
- var import_editor2 = require("@flowgram.ai/editor");
198
- var import_semi_ui = require("@douyinfe/semi-ui");
199
- var stringRegistry = {
200
- type: "string",
201
- ConstantRenderer: (props) => /* @__PURE__ */ import_react2.default.createElement(
202
- import_semi_ui.Input,
203
- {
204
- placeholder: import_editor2.I18n.t("Please Input String"),
205
- size: "small",
206
- disabled: props.readonly,
207
- ...props
208
- }
209
- )
210
- };
211
-
212
- // src/plugins/json-schema-preset/type-definition/object.tsx
213
- var import_react6 = __toESM(require("react"));
214
- var import_editor4 = require("@flowgram.ai/editor");
215
-
216
- // src/components/code-editor-mini/index.tsx
217
- var import_react5 = __toESM(require("react"));
218
- var import_styled_components = __toESM(require("styled-components"));
219
-
220
- // src/components/code-editor/index.tsx
221
- var import_react3 = __toESM(require("react"));
222
- var import_react4 = require("@coze-editor/editor/react");
223
- var import_preset_code5 = __toESM(require("@coze-editor/editor/preset-code"));
224
- var import_view = require("@codemirror/view");
225
-
226
- // src/components/code-editor/utils.ts
227
- function getSuffixByLanguageId(languageId) {
228
- if (languageId === "python") {
229
- return ".py";
230
- }
231
- if (languageId === "typescript") {
232
- return ".ts";
233
- }
234
- if (languageId === "shell") {
235
- return ".sh";
236
- }
237
- if (languageId === "json") {
238
- return ".json";
239
- }
240
- return "";
241
- }
242
-
243
- // src/components/code-editor/language-features.ts
244
- var import_preset_code = require("@coze-editor/editor/preset-code");
245
- var import_language_typescript = require("@coze-editor/editor/language-typescript");
246
- var import_language_shell = require("@coze-editor/editor/language-shell");
247
- var import_language_python = require("@coze-editor/editor/language-python");
248
- var import_language_json = require("@coze-editor/editor/language-json");
249
- var import_editor3 = require("@coze-editor/editor");
250
- import_preset_code.languages.register("python", import_language_python.python);
251
- import_preset_code.languages.register("shell", import_language_shell.shell);
252
- import_preset_code.languages.register("typescript", import_language_typescript.typescript);
253
- import_preset_code.languages.register("json", {
254
- // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
255
- language: (0, import_editor3.mixLanguages)({
256
- outerLanguage: import_language_json.json.language
257
- }),
258
- languageService: import_language_json.json.languageService
259
- });
260
- var tsWorkerInit = false;
261
- var initTsWorker = () => {
262
- if (tsWorkerInit) {
263
- return;
264
- }
265
- tsWorkerInit = true;
266
- const tsWorker = new Worker(
267
- new URL(`@coze-editor/editor/language-typescript/worker`, importMetaUrl),
268
- { type: "module" }
269
- );
270
- import_language_typescript.typescript.languageService.initialize(tsWorker, {
271
- compilerOptions: {
272
- // eliminate Promise error
273
- lib: ["es2015", "dom"],
274
- noImplicitAny: false
275
- }
276
- });
277
- };
278
-
279
- // src/components/code-editor/theme/index.ts
280
- var import_preset_code4 = require("@coze-editor/editor/preset-code");
281
-
282
- // src/components/code-editor/theme/light.ts
283
- var import_preset_code2 = require("@coze-editor/editor/preset-code");
284
- var colors = {
285
- background: "#F7F7FC",
286
- // syntax
287
- comment: "#000A298A",
288
- key: "#00818C",
289
- string: "#D1009D",
290
- number: "#C74200",
291
- boolean: "#2B57D9",
292
- null: "#2B57D9",
293
- separator: "#0F1529D1"
294
- };
295
- var lightTheme = (0, import_preset_code2.createTheme)({
296
- variant: "light",
297
- settings: {
298
- background: "#fff",
299
- foreground: "#000",
300
- caret: "#000",
301
- selection: "#d9d9d9",
302
- gutterBackground: "#f0f0f0",
303
- gutterForeground: "#666",
304
- gutterBorderColor: "transparent",
305
- gutterBorderWidth: 0,
306
- lineHighlight: "#e1e1e180",
307
- bracketColors: ["#FFD700", "#DD99FF", "#78B0FF"],
308
- tooltip: {
309
- backgroundColor: "#f0f0f0",
310
- color: "#000",
311
- border: "1px solid #ccc"
312
- },
313
- link: {
314
- color: "#007bff"
315
- },
316
- completionItemHover: {
317
- backgroundColor: "#f0f0f0"
318
- },
319
- completionItemSelected: {
320
- backgroundColor: "#e0e0e0"
321
- },
322
- completionItemIcon: {
323
- color: "#333"
324
- },
325
- completionItemLabel: {
326
- color: "#333"
327
- },
328
- completionItemInfo: {
329
- color: "#333"
330
- },
331
- completionItemDetail: {
332
- color: "#666"
333
- }
334
- },
335
- styles: [
336
- // JSON
337
- {
338
- tag: import_preset_code2.tags.comment,
339
- color: colors.comment
340
- },
341
- {
342
- tag: [import_preset_code2.tags.propertyName],
343
- color: colors.key
344
- },
345
- {
346
- tag: [import_preset_code2.tags.string],
347
- color: colors.string
348
- },
349
- {
350
- tag: [import_preset_code2.tags.number],
351
- color: colors.number
352
- },
353
- {
354
- tag: [import_preset_code2.tags.bool],
355
- color: colors.boolean
356
- },
357
- {
358
- tag: [import_preset_code2.tags.null],
359
- color: colors.null
360
- },
361
- {
362
- tag: [import_preset_code2.tags.separator],
363
- color: colors.separator
364
- },
365
- // markdown
366
- {
367
- tag: [import_preset_code2.tags.heading],
368
- color: "#3e76ef"
369
- },
370
- {
371
- tag: [import_preset_code2.tags.processingInstruction],
372
- color: "#3e76ef"
373
- },
374
- // shell
375
- // curl
376
- {
377
- tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
378
- color: "#00804A"
379
- },
380
- // -X
381
- {
382
- tag: [import_preset_code2.tags.attributeName],
383
- color: "#C74200"
384
- },
385
- // url in string (includes quotes), e.g. "https://..."
386
- {
387
- tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
388
- color: "#2B57D9"
389
- }
390
- ]
391
- });
392
-
393
- // src/components/code-editor/theme/dark.ts
394
- var import_preset_code3 = require("@coze-editor/editor/preset-code");
395
- var colors2 = {
396
- background: "#151B27",
397
- // syntax
398
- comment: "#FFFFFF63",
399
- key: "#39E5D7",
400
- string: "#FF94D2",
401
- number: "#FF9933",
402
- boolean: "#78B0FF",
403
- null: "#78B0FF",
404
- separator: "#FFFFFFC9"
405
- };
406
- var darkTheme = (0, import_preset_code3.createTheme)({
407
- variant: "dark",
408
- settings: {
409
- background: colors2.background,
410
- foreground: "#fff",
411
- caret: "#AEAFAD",
412
- selection: "#d9d9d942",
413
- gutterBackground: colors2.background,
414
- gutterForeground: "#FFFFFF63",
415
- gutterBorderColor: "transparent",
416
- gutterBorderWidth: 0,
417
- lineHighlight: "#272e3d36",
418
- bracketColors: ["#FFEF61", "#DD99FF", "#78B0FF"],
419
- tooltip: {
420
- backgroundColor: "#363D4D",
421
- color: "#fff",
422
- border: "none"
423
- },
424
- link: {
425
- color: "#4daafc"
426
- },
427
- completionItemHover: {
428
- backgroundColor: "#FFFFFF0F"
429
- },
430
- completionItemSelected: {
431
- backgroundColor: "#FFFFFF17"
432
- },
433
- completionItemIcon: {
434
- color: "#FFFFFFC9"
435
- },
436
- completionItemLabel: {
437
- color: "#FFFFFFC9"
438
- },
439
- completionItemInfo: {
440
- color: "#FFFFFFC9"
441
- },
442
- completionItemDetail: {
443
- color: "#FFFFFF63"
444
- }
445
- },
446
- styles: [
447
- // json
448
- {
449
- tag: import_preset_code3.tags.comment,
450
- color: colors2.comment
451
- },
452
- {
453
- tag: [import_preset_code3.tags.propertyName],
454
- color: colors2.key
455
- },
456
- {
457
- tag: [import_preset_code3.tags.string],
458
- color: colors2.string
459
- },
460
- {
461
- tag: [import_preset_code3.tags.number],
462
- color: colors2.number
463
- },
464
- {
465
- tag: [import_preset_code3.tags.bool],
466
- color: colors2.boolean
467
- },
468
- {
469
- tag: [import_preset_code3.tags.null],
470
- color: colors2.null
471
- },
472
- {
473
- tag: [import_preset_code3.tags.separator],
474
- color: colors2.separator
475
- },
476
- // markdown
477
- {
478
- tag: [import_preset_code3.tags.heading],
479
- color: "#6b6bff"
480
- },
481
- {
482
- tag: [import_preset_code3.tags.processingInstruction],
483
- color: "#6b6bff"
484
- },
485
- // shell
486
- // curl
487
- {
488
- tag: [import_preset_code3.tags.standard(import_preset_code3.tags.variableName)],
489
- color: "#3BEB84"
490
- },
491
- // -X
492
- {
493
- tag: [import_preset_code3.tags.attributeName],
494
- color: "#FF9933"
495
- },
496
- // url in string (includes quotes), e.g. "https://..."
497
- {
498
- tag: [import_preset_code3.tags.special(import_preset_code3.tags.string)],
499
- color: "#78B0FF"
500
- }
501
- ]
502
- });
503
-
504
- // src/components/code-editor/theme/index.ts
505
- import_preset_code4.themes.register("dark", darkTheme);
506
- import_preset_code4.themes.register("light", lightTheme);
507
-
508
- // src/components/code-editor/index.tsx
509
- var OriginCodeEditor = (0, import_react4.createRenderer)(import_preset_code5.default, [
510
- import_view.EditorView.theme({
511
- "&.cm-focused": {
512
- outline: "none"
513
- }
514
- })
515
- ]);
516
- function CodeEditor({
517
- value,
518
- onChange,
519
- languageId = "python",
520
- theme = "light",
521
- children,
522
- placeholder,
523
- activeLinePlaceholder,
524
- options,
525
- readonly
526
- }) {
527
- const editorRef = (0, import_react3.useRef)(null);
528
- (0, import_react3.useEffect)(() => {
529
- if (languageId === "typescript") {
530
- initTsWorker();
531
- }
532
- }, [languageId]);
533
- (0, import_react3.useEffect)(() => {
534
- if (editorRef.current?.getValue() !== value) {
535
- editorRef.current?.setValue(String(value || ""));
536
- }
537
- }, [value]);
538
- return /* @__PURE__ */ import_react3.default.createElement(import_react4.EditorProvider, null, /* @__PURE__ */ import_react3.default.createElement(
539
- OriginCodeEditor,
540
- {
541
- defaultValue: value,
542
- options: {
543
- uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
544
- languageId,
545
- theme,
546
- placeholder,
547
- readOnly: readonly,
548
- editable: !readonly,
549
- ...options || {}
550
- },
551
- didMount: (editor) => {
552
- editorRef.current = editor;
553
- },
554
- onChange: (e) => onChange?.(e.value)
555
- },
556
- activeLinePlaceholder && /* @__PURE__ */ import_react3.default.createElement(import_react4.ActiveLinePlaceholder, null, activeLinePlaceholder),
557
- children
558
- ));
559
- }
560
-
561
- // src/components/code-editor-mini/index.tsx
562
- var UIMini = import_styled_components.default.div`
563
- .ͼ1 .cm-content {
564
- padding: 0;
565
- }
566
- `;
567
- function CodeEditorMini(props) {
568
- return /* @__PURE__ */ import_react5.default.createElement(UIMini, null, /* @__PURE__ */ import_react5.default.createElement(
569
- CodeEditor,
570
- {
571
- ...props,
572
- options: {
573
- lineNumbersGutter: false,
574
- foldGutter: false,
575
- ...props.options || {}
576
- }
577
- }
578
- ));
579
- }
580
-
581
- // src/plugins/json-schema-preset/type-definition/object.tsx
582
- var objectRegistry = {
583
- type: "object",
584
- ConstantRenderer: (props) => /* @__PURE__ */ import_react6.default.createElement(
585
- CodeEditorMini,
586
- {
587
- value: props.value,
588
- onChange: (v) => props.onChange?.(v),
589
- languageId: "json",
590
- placeholder: import_editor4.I18n.t("Please Input Object"),
591
- readonly: props.readonly
592
- }
593
- )
594
- };
595
-
596
- // src/plugins/json-schema-preset/type-definition/number.tsx
597
- var import_react7 = __toESM(require("react"));
598
- var import_editor5 = require("@flowgram.ai/editor");
599
- var import_semi_ui2 = require("@douyinfe/semi-ui");
600
- var numberRegistry = {
601
- type: "number",
602
- ConstantRenderer: (props) => /* @__PURE__ */ import_react7.default.createElement(
603
- import_semi_ui2.InputNumber,
604
- {
605
- placeholder: import_editor5.I18n.t("Please Input Number"),
606
- size: "small",
607
- disabled: props.readonly,
608
- hideButtons: true,
609
- ...props
610
- }
611
- )
612
- };
613
-
614
- // src/plugins/json-schema-preset/type-definition/integer.tsx
615
- var import_react8 = __toESM(require("react"));
616
- var import_editor6 = require("@flowgram.ai/editor");
617
- var import_semi_ui3 = require("@douyinfe/semi-ui");
618
- var integerRegistry = {
619
- type: "integer",
620
- ConstantRenderer: (props) => /* @__PURE__ */ import_react8.default.createElement(
621
- import_semi_ui3.InputNumber,
622
- {
623
- placeholder: import_editor6.I18n.t("Please Input Integer"),
624
- size: "small",
625
- disabled: props.readonly,
626
- precision: 0,
627
- ...props
628
- }
629
- )
630
- };
631
-
632
- // src/plugins/json-schema-preset/type-definition/boolean.tsx
633
- var import_react9 = __toESM(require("react"));
634
- var import_editor7 = require("@flowgram.ai/editor");
635
- var import_semi_ui4 = require("@douyinfe/semi-ui");
636
- var booleanRegistry = {
637
- type: "boolean",
638
- ConstantRenderer: (props) => {
639
- const { value, onChange, ...rest } = props;
640
- return /* @__PURE__ */ import_react9.default.createElement(
641
- import_semi_ui4.Select,
642
- {
643
- placeholder: import_editor7.I18n.t("Please Select Boolean"),
644
- size: "small",
645
- disabled: props.readonly,
646
- optionList: [
647
- { label: import_editor7.I18n.t("True"), value: 1 },
648
- { label: import_editor7.I18n.t("False"), value: 0 }
649
- ],
650
- value: value ? 1 : 0,
651
- onChange: (value2) => onChange?.(!!value2),
652
- ...rest
653
- }
654
- );
655
- }
656
- };
657
-
658
- // src/plugins/json-schema-preset/type-definition/array.tsx
659
- var import_react10 = __toESM(require("react"));
660
- var import_editor8 = require("@flowgram.ai/editor");
661
- var arrayRegistry = {
662
- type: "array",
663
- ConstantRenderer: (props) => /* @__PURE__ */ import_react10.default.createElement(
664
- CodeEditorMini,
665
- {
666
- value: props.value,
667
- languageId: "json",
668
- onChange: (v) => props.onChange?.(v),
669
- placeholder: import_editor8.I18n.t("Please Input Array"),
670
- readonly: props.readonly
671
- }
672
- )
673
- };
674
-
675
- // src/plugins/json-schema-preset/type-definition/index.tsx
676
- var jsonSchemaTypePreset = [
677
- stringRegistry,
678
- objectRegistry,
679
- numberRegistry,
680
- integerRegistry,
681
- booleanRegistry,
682
- arrayRegistry
683
- ];
684
- jsonSchemaTypePreset.forEach((_type) => import_json_schema.jsonSchemaTypeManager.register(_type));
685
-
686
- // src/plugins/json-schema-preset/create-type-preset-plugin.tsx
687
- var import_json_schema2 = require("@flowgram.ai/json-schema");
688
- var import_editor9 = require("@flowgram.ai/editor");
689
- var createTypePresetPlugin = (0, import_editor9.definePluginCreator)({
690
- onInit(ctx, opts) {
691
- const typeManager = ctx.get(import_json_schema2.BaseTypeManager);
692
- jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
693
- opts.types?.forEach((_type) => typeManager.register(_type));
694
- opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
695
- },
696
- containerModules: [import_json_schema2.jsonSchemaContainerModule]
697
- });
698
-
699
- // src/plugins/json-schema-preset/index.tsx
700
- var useTypeManager = () => (0, import_json_schema3.useTypeManager)();
701
- var JsonSchemaTypePresetProvider = ({
702
- types = [],
703
- children
704
- }) => /* @__PURE__ */ import_react11.default.createElement(import_json_schema3.TypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
705
-
706
- // src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
707
- var import_editor10 = require("@flowgram.ai/editor");
708
- var createDisableDeclarationPlugin = (0, import_editor10.definePluginCreator)({
709
- onInit(ctx) {
710
- const variableEngine = ctx.get(import_editor10.VariableEngine);
711
- const handleEvent = (action) => {
712
- if (import_editor10.ASTMatch.isVariableDeclaration(action.ast)) {
713
- if (!action.ast.meta?.disabled) {
714
- action.ast.updateMeta({
715
- ...action.ast.meta || {},
716
- disabled: true
717
- });
718
- }
719
- }
720
- };
721
- variableEngine.onGlobalEvent("NewAST", handleEvent);
722
- variableEngine.onGlobalEvent("UpdateAST", handleEvent);
723
- }
724
- });
725
-
726
- // src/components/variable-selector/use-variable-tree.tsx
727
- function useVariableTree(params) {
728
- const { includeSchema, excludeSchema, customSkip } = params;
729
- const typeManager = useTypeManager();
730
- const variables = (0, import_editor11.useAvailableVariables)();
731
- const getVariableTypeIcon = (0, import_react12.useCallback)((variable) => {
732
- if (variable.meta?.icon) {
733
- if (typeof variable.meta.icon === "string") {
734
- return /* @__PURE__ */ import_react12.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: variable.meta.icon });
735
- }
736
- return variable.meta.icon;
737
- }
738
- const schema = import_json_schema4.JsonSchemaUtils.astToSchema(variable.type, { drilldownObject: false });
739
- return /* @__PURE__ */ import_react12.default.createElement(import_semi_ui5.Icon, { size: "small", svg: typeManager.getDisplayIcon(schema || {}) });
740
- }, []);
741
- const renderVariable = (variable, parentFields = []) => {
742
- let type = variable?.type;
743
- if (!type) {
744
- return null;
745
- }
746
- let children;
747
- if (import_editor11.ASTMatch.isObject(type)) {
748
- children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
749
- }
750
- const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
751
- const key = keyPath.join(".");
752
- const isSchemaInclude = includeSchema ? import_json_schema4.JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
753
- const isSchemaExclude = excludeSchema ? import_json_schema4.JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
754
- const isCustomSkip = customSkip ? customSkip(variable) : false;
755
- const isMetaDisabled = variable.meta?.disabled;
756
- const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
757
- if (!isSchemaMatch && !children?.length) {
758
- return null;
759
- }
760
- return {
761
- key,
762
- label: variable.meta?.title || variable.key,
763
- value: key,
764
- keyPath,
765
- icon: getVariableTypeIcon(variable),
766
- children,
767
- disabled: !isSchemaMatch,
768
- rootMeta: parentFields[0]?.meta || variable.meta,
769
- isRoot: !parentFields?.length
770
- };
771
- };
772
- return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
773
- }
774
-
775
- // src/components/variable-selector/styles.tsx
776
- var import_styled_components2 = __toESM(require("styled-components"));
777
- var import_semi_ui6 = require("@douyinfe/semi-ui");
778
- var UIRootTitle = import_styled_components2.default.div`
779
- margin-right: 4px;
780
- min-width: 20px;
781
- overflow: hidden;
782
- text-overflow: ellipsis;
783
- white-space: nowrap;
784
- color: var(--semi-color-text-2);
785
- `;
786
- var UIVarName = import_styled_components2.default.div`
787
- overflow: hidden;
788
- text-overflow: ellipsis;
789
- white-space: nowrap;
790
-
791
- ${({ $inSelector }) => $inSelector && import_styled_components2.css`
792
- min-width: 50%;
793
- `}
794
- `;
795
- var UITag = (0, import_styled_components2.default)(import_semi_ui6.Tag)`
796
- width: 100%;
797
- display: flex;
798
- align-items: center;
799
- justify-content: flex-start;
800
-
801
- & .semi-tag-content-center {
802
- justify-content: flex-start;
803
- }
804
-
805
- &.semi-tag {
806
- margin: 0;
807
- height: 22px;
808
- }
809
- `;
810
- var UITreeSelect = (0, import_styled_components2.default)(import_semi_ui6.TreeSelect)`
811
- outline: ${({ $error }) => $error ? "1px solid red" : "none"};
812
-
813
- & .semi-tree-select-selection {
814
- padding: 0px;
815
- height: 22px;
816
- }
817
-
818
- & .semi-tree-select-selection-content {
819
- width: 100%;
820
- }
821
-
822
- & .semi-tree-select-selection-placeholder {
823
- padding-left: 10px;
824
- }
825
- `;
826
- var UIPopoverContent = import_styled_components2.default.div`
827
- padding: 10px;
828
- display: inline-flex;
829
- align-items: center;
830
- justify-content: flex-start;
831
- white-space: nowrap;
832
- `;
833
-
834
- // src/components/variable-selector/index.tsx
835
- var VariableSelector = ({
836
- value,
837
- config = {},
838
- onChange,
839
- style,
840
- readonly = false,
841
- includeSchema,
842
- excludeSchema,
843
- hasError,
844
- triggerRender
845
- }) => {
846
- const treeData = useVariableTree({ includeSchema, excludeSchema });
847
- const treeValue = (0, import_react13.useMemo)(() => {
848
- if (typeof value === "string") {
849
- console.warn(
850
- "The Value of VariableSelector is a string, it should be an ARRAY. \n",
851
- "Please check the value of VariableSelector \n"
852
- );
853
- return value;
854
- }
855
- return value?.join(".");
856
- }, [value]);
857
- const renderIcon = (icon) => {
858
- if (typeof icon === "string") {
859
- return /* @__PURE__ */ import_react13.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
860
- }
861
- return icon;
862
- };
863
- return /* @__PURE__ */ import_react13.default.createElement(import_react13.default.Fragment, null, /* @__PURE__ */ import_react13.default.createElement(
864
- UITreeSelect,
865
- {
866
- dropdownMatchSelectWidth: false,
867
- disabled: readonly,
868
- treeData,
869
- size: "small",
870
- value: treeValue,
871
- clearIcon: null,
872
- $error: hasError,
873
- style,
874
- validateStatus: hasError ? "error" : void 0,
875
- onChange: (_, _config) => {
876
- onChange(_config.keyPath);
877
- },
878
- renderSelectedItem: (_option) => {
879
- if (!_option?.keyPath) {
880
- return /* @__PURE__ */ import_react13.default.createElement(
881
- UITag,
882
- {
883
- prefixIcon: /* @__PURE__ */ import_react13.default.createElement(import_semi_icons.IconIssueStroked, null),
884
- color: "amber",
885
- closable: !readonly,
886
- onClose: () => onChange(void 0)
887
- },
888
- config?.notFoundContent ?? "Undefined"
889
- );
890
- }
891
- const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
892
- const rootTitle = /* @__PURE__ */ import_react13.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
893
- return /* @__PURE__ */ import_react13.default.createElement("div", null, /* @__PURE__ */ import_react13.default.createElement(
894
- import_semi_ui7.Popover,
895
- {
896
- content: /* @__PURE__ */ import_react13.default.createElement(UIPopoverContent, null, rootIcon, rootTitle, /* @__PURE__ */ import_react13.default.createElement(UIVarName, null, _option.keyPath.slice(1).join(".")))
897
- },
898
- /* @__PURE__ */ import_react13.default.createElement(
899
- UITag,
900
- {
901
- prefixIcon: rootIcon,
902
- closable: !readonly,
903
- onClose: () => onChange(void 0)
904
- },
905
- rootTitle,
906
- !_option.isRoot && /* @__PURE__ */ import_react13.default.createElement(UIVarName, { $inSelector: true }, _option.label)
907
- )
908
- ));
909
- },
910
- showClear: false,
911
- arrowIcon: /* @__PURE__ */ import_react13.default.createElement(import_semi_icons.IconChevronDownStroked, { size: "small" }),
912
- triggerRender,
913
- placeholder: config?.placeholder ?? import_editor12.I18n.t("Select Variable")
914
- }
915
- ));
916
- };
917
- VariableSelector.renderKey = "variable-selector-render-key";
918
- var InjectVariableSelector = createInjectMaterial(VariableSelector);
919
-
920
- // src/components/type-selector/index.tsx
921
- var import_react14 = __toESM(require("react"));
922
- var import_semi_ui8 = require("@douyinfe/semi-ui");
923
- var labelStyle = { display: "flex", alignItems: "center", gap: 5 };
924
- var getTypeSelectValue = (value) => {
925
- if (value?.type === "array" && value?.items) {
926
- return [value.type, ...getTypeSelectValue(value.items) || []];
927
- }
928
- return value?.type ? [value.type] : void 0;
929
- };
930
- var parseTypeSelectValue = (value) => {
931
- const [type, ...subTypes] = value || [];
932
- if (type === "array") {
933
- return { type: "array", items: parseTypeSelectValue(subTypes) };
934
- }
935
- return { type };
936
- };
937
- function TypeSelector(props) {
938
- const { value, onChange, readonly, disabled, style } = props;
939
- const selectValue = (0, import_react14.useMemo)(() => getTypeSelectValue(value), [value]);
940
- const typeManager = useTypeManager();
941
- const icon = typeManager.getDisplayIcon(value || {});
942
- const options = (0, import_react14.useMemo)(
943
- () => typeManager.getTypeRegistriesWithParentType().map((_type) => {
944
- const isArray2 = _type.type === "array";
945
- return {
946
- label: /* @__PURE__ */ import_react14.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.Icon, { size: "small", svg: _type.icon }), typeManager.getTypeBySchema(_type)?.label || _type.type),
947
- value: _type.type,
948
- children: isArray2 ? typeManager.getTypeRegistriesWithParentType("array").map((_type2) => ({
949
- label: /* @__PURE__ */ import_react14.default.createElement("div", { style: labelStyle }, /* @__PURE__ */ import_react14.default.createElement(
950
- import_semi_ui8.Icon,
951
- {
952
- size: "small",
953
- svg: typeManager.getDisplayIcon({
954
- type: "array",
955
- items: { type: _type2.type }
956
- })
957
- }
958
- ), typeManager.getTypeBySchema(_type2)?.label || _type2.type),
959
- value: _type2.type
960
- })) : []
961
- };
962
- }),
963
- []
964
- );
965
- return /* @__PURE__ */ import_react14.default.createElement(
966
- import_semi_ui8.Cascader,
967
- {
968
- disabled: readonly || disabled,
969
- size: "small",
970
- triggerRender: () => /* @__PURE__ */ import_react14.default.createElement(import_semi_ui8.IconButton, { size: "small", style, disabled: readonly || disabled, icon }),
971
- treeData: options,
972
- value: selectValue,
973
- leafOnly: true,
974
- onChange: (value2) => {
975
- onChange?.(parseTypeSelectValue(value2));
976
- }
977
- }
978
- );
979
- }
980
- TypeSelector.renderKey = "type-selector-render-key";
981
- var InjectTypeSelector = createInjectMaterial(TypeSelector);
982
-
983
- // src/components/json-schema-editor/index.tsx
984
- var import_react20 = __toESM(require("react"));
985
- var import_editor14 = require("@flowgram.ai/editor");
986
- var import_semi_ui10 = require("@douyinfe/semi-ui");
987
- var import_semi_icons3 = require("@douyinfe/semi-icons");
988
-
989
- // src/components/json-schema-editor/styles.tsx
990
- var import_react15 = __toESM(require("react"));
991
- var import_styled_components3 = __toESM(require("styled-components"));
992
- var import_semi_icons2 = __toESM(require("@douyinfe/semi-icons"));
993
- var UIContainer = import_styled_components3.default.div`
994
- /* & .semi-input {
995
- background-color: #fff;
996
- border-radius: 6px;
997
- height: 24px;
998
- } */
999
- `;
1000
- var UIRow = import_styled_components3.default.div`
1001
- display: flex;
1002
- align-items: center;
1003
- gap: 6px;
1004
- `;
1005
- var UICollapseTrigger = import_styled_components3.default.div`
1006
- cursor: pointer;
1007
- margin-right: 5px;
1008
- `;
1009
- var UIExpandDetail = import_styled_components3.default.div`
1010
- display: flex;
1011
- flex-direction: column;
1012
- `;
1013
- var UILabel = import_styled_components3.default.div`
1014
- font-size: 12px;
1015
- color: #999;
1016
- font-weight: 400;
1017
- margin-bottom: 2px;
1018
- `;
1019
- var UIProperties = import_styled_components3.default.div`
1020
- display: grid;
1021
- grid-template-columns: auto 1fr;
1022
-
1023
- ${({ $shrink }) => $shrink && import_styled_components3.css`
1024
- padding-left: 10px;
1025
- margin-top: 10px;
1026
- `}
1027
- `;
1028
- var UIPropertyLeft = import_styled_components3.default.div`
1029
- grid-column: 1;
1030
- position: relative;
1031
- width: 16px;
1032
-
1033
- ${({ $showLine, $isLast, $parentType }) => {
1034
- let height = "100%";
1035
- if ($parentType && $isLast) {
1036
- height = "24px";
1037
- }
1038
- return $showLine && import_styled_components3.css`
1039
- &::before {
1040
- /* 竖线 */
1041
- content: '';
1042
- height: ${height};
1043
- position: absolute;
1044
- left: -22px;
1045
- top: -16px;
1046
- width: 1px;
1047
- background: #d9d9d9;
1048
- display: block;
1049
- }
1050
-
1051
- &::after {
1052
- /* 横线 */
1053
- content: '';
1054
- position: absolute;
1055
- left: -22px; // 横线起点和竖线对齐
1056
- top: 8px; // 跟随你的行高调整
1057
- width: 18px; // 横线长度
1058
- height: 1px;
1059
- background: #d9d9d9;
1060
- display: block;
1061
- }
1062
- `;
1063
- }}
1064
- `;
1065
- var UIPropertyRight = import_styled_components3.default.div`
1066
- grid-column: 2;
1067
- margin-bottom: 10px;
1068
-
1069
- &:last-child {
1070
- margin-bottom: 0px;
1071
- }
1072
- `;
1073
- var UIPropertyMain = import_styled_components3.default.div`
1074
- display: flex;
1075
- flex-direction: column;
1076
- gap: 10px;
1077
- position: relative;
1078
-
1079
- ${({ $expand, type, $collapse, $showCollapse }) => {
1080
- const beforeElement = `
1081
- &::before {
1082
- /* \u7AD6\u7EBF */
1083
- content: '';
1084
- height: 100%;
1085
- position: absolute;
1086
- left: -12px;
1087
- top: 18px;
1088
- width: 1px;
1089
- background: #d9d9d9;
1090
- display: block;
1091
- }`;
1092
- return $expand && import_styled_components3.css`
1093
- background-color: #f5f5f5;
1094
- padding: 10px;
1095
- border-radius: 4px;
1096
-
1097
- ${$showCollapse && $collapse && (type === "array" || type === "object") && import_styled_components3.css`
1098
- ${beforeElement}
1099
- `}
1100
- `;
1101
- }}
1102
- `;
1103
- var UICollapsible = import_styled_components3.default.div`
1104
- display: none;
1105
-
1106
- ${({ $collapse }) => $collapse && import_styled_components3.css`
1107
- display: block;
1108
- `}
1109
- `;
1110
- var UIName = import_styled_components3.default.div`
1111
- flex-grow: 1;
1112
- `;
1113
- var UIType = import_styled_components3.default.div``;
1114
- var UIRequired = import_styled_components3.default.div``;
1115
- var UIActions = import_styled_components3.default.div`
1116
- white-space: nowrap;
1117
- `;
1118
- var iconAddChildrenSvg = /* @__PURE__ */ import_react15.default.createElement(
1119
- "svg",
1120
- {
1121
- className: "icon-icon icon-icon-coz_add_node ",
1122
- width: "1em",
1123
- height: "1em",
1124
- viewBox: "0 0 24 24",
1125
- fill: "currentColor",
1126
- xmlns: "http://www.w3.org/2000/svg"
1127
- },
1128
- /* @__PURE__ */ import_react15.default.createElement(
1129
- "path",
1130
- {
1131
- fillRule: "evenodd",
1132
- clipRule: "evenodd",
1133
- d: "M11 6.49988C11 8.64148 9.50397 10.4337 7.49995 10.8884V15.4998C7.49995 16.0521 7.94767 16.4998 8.49995 16.4998H11.208C11.0742 16.8061 11 17.1443 11 17.4998C11 17.8554 11.0742 18.1936 11.208 18.4998H8.49995C6.8431 18.4998 5.49995 17.1567 5.49995 15.4998V10.8884C3.49599 10.4336 2 8.64145 2 6.49988C2 4.0146 4.01472 1.99988 6.5 1.99988C8.98528 1.99988 11 4.0146 11 6.49988ZM6.5 8.99988C7.88071 8.99988 9 7.88059 9 6.49988C9 5.11917 7.88071 3.99988 6.5 3.99988C5.11929 3.99988 4 5.11917 4 6.49988C4 7.88059 5.11929 8.99988 6.5 8.99988Z"
1134
- }
1135
- ),
1136
- /* @__PURE__ */ import_react15.default.createElement("path", { d: "M17.5 12.4999C18.0523 12.4999 18.5 12.9476 18.5 13.4999V16.4999H21.5C22.0523 16.4999 22.5 16.9476 22.5 17.4999C22.5 18.0522 22.0523 18.4999 21.5 18.4999H18.5V21.4999C18.5 22.0522 18.0523 22.4999 17.5 22.4999C16.9477 22.4999 16.5 22.0522 16.5 21.4999V18.4999H13.5C12.9477 18.4999 12.5 18.0522 12.5 17.4999C12.5 16.9476 12.9477 16.4999 13.5 16.4999H16.5V13.4999C16.5 12.9476 16.9477 12.4999 17.5 12.4999Z" })
1137
- );
1138
- var IconAddChildren = () => /* @__PURE__ */ import_react15.default.createElement(import_semi_icons2.default, { size: "small", svg: iconAddChildrenSvg });
1139
- var DefaultValueWrapper = import_styled_components3.default.div`
1140
- margin: 0;
1141
- `;
1142
- var ConstantInputWrapper = import_styled_components3.default.div`
1143
- flex-grow: 1;
1144
-
1145
- & .semi-tree-select,
1146
- & .semi-input-number,
1147
- & .semi-select {
1148
- width: 100%;
1149
- }
1150
- `;
1151
-
1152
- // src/components/json-schema-editor/hooks.tsx
1153
- var import_react16 = require("react");
1154
- var import_lodash2 = require("lodash");
1155
- var import_immer = require("immer");
1156
- var import_json_schema5 = require("@flowgram.ai/json-schema");
1157
- var _id = 0;
1158
- function genId() {
1159
- return _id++;
1160
- }
1161
- function usePropertiesEdit(value, onChange) {
1162
- const typeManager = (0, import_json_schema5.useTypeManager)();
1163
- const drilldownSchema = typeManager.getPropertiesParent(value || {});
1164
- const canAddField = typeManager.canAddField(value || {});
1165
- const [propertyList, setPropertyList] = (0, import_react16.useState)([]);
1166
- (0, import_react16.useEffect)(() => {
1167
- setPropertyList((_list) => {
1168
- const newNames = Object.entries(drilldownSchema?.properties || {}).sort(([, a], [, b]) => (a.extra?.index ?? 0) - (b.extra?.index ?? 0)).map(([key]) => key);
1169
- const oldNames = _list.map((item) => item.name).filter(Boolean);
1170
- const addNames = (0, import_lodash2.difference)(newNames, oldNames);
1171
- return _list.filter((item) => !item.name || newNames.includes(item.name)).map((item) => ({
1172
- key: item.key,
1173
- name: item.name,
1174
- isPropertyRequired: drilldownSchema?.required?.includes(item.name || "") || false,
1175
- ...item
1176
- })).concat(
1177
- addNames.map((_name) => ({
1178
- key: genId(),
1179
- name: _name,
1180
- isPropertyRequired: drilldownSchema?.required?.includes(_name) || false,
1181
- ...drilldownSchema?.properties?.[_name] || {}
1182
- }))
1183
- );
1184
- });
1185
- }, [drilldownSchema]);
1186
- const updatePropertyList = (updater) => {
1187
- setPropertyList((_list) => {
1188
- const next = updater(_list);
1189
- const nextProperties = {};
1190
- const nextRequired = [];
1191
- for (const _property of next) {
1192
- if (!_property.name) {
1193
- continue;
1194
- }
1195
- nextProperties[_property.name] = (0, import_lodash2.omit)(_property, ["key", "name", "isPropertyRequired"]);
1196
- if (_property.isPropertyRequired) {
1197
- nextRequired.push(_property.name);
1198
- }
1199
- }
1200
- onChange?.(
1201
- (0, import_immer.produce)(value || {}, (draft) => {
1202
- const propertiesParent = typeManager.getPropertiesParent(draft);
1203
- if (propertiesParent) {
1204
- propertiesParent.properties = nextProperties;
1205
- propertiesParent.required = nextRequired;
1206
- return;
1207
- }
1208
- })
1209
- );
1210
- return next;
1211
- });
1212
- };
1213
- const onAddProperty = () => {
1214
- setPropertyList((_list) => [
1215
- ..._list,
1216
- { key: genId(), name: "", type: "string", extra: { index: _list.length + 1 } }
1217
- ]);
1218
- };
1219
- const onRemoveProperty = (key) => {
1220
- updatePropertyList((_list) => _list.filter((_property) => _property.key !== key));
1221
- };
1222
- const onEditProperty = (key, nextValue) => {
1223
- updatePropertyList(
1224
- (_list) => _list.map((_property) => _property.key === key ? nextValue : _property)
1225
- );
1226
- };
1227
- (0, import_react16.useEffect)(() => {
1228
- if (!canAddField) {
1229
- setPropertyList([]);
1230
- }
1231
- }, [canAddField]);
1232
- return {
1233
- propertyList,
1234
- canAddField,
1235
- onAddProperty,
1236
- onRemoveProperty,
1237
- onEditProperty
1238
- };
1239
- }
1240
-
1241
- // src/components/json-schema-editor/default-value.tsx
1242
- var import_react18 = __toESM(require("react"));
1243
- var import_editor13 = require("@flowgram.ai/editor");
1244
-
1245
- // src/components/constant-input/index.tsx
1246
- var import_react17 = __toESM(require("react"));
1247
- var import_semi_ui9 = require("@douyinfe/semi-ui");
1248
- function ConstantInput(props) {
1249
- const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
1250
- const typeManager = useTypeManager();
1251
- const Renderer2 = (0, import_react17.useMemo)(() => {
1252
- const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
1253
- if (!strategy) {
1254
- return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
1255
- }
1256
- return strategy?.Renderer;
1257
- }, [strategies, schema]);
1258
- if (!Renderer2) {
1259
- if (fallbackRenderer) {
1260
- return import_react17.default.createElement(fallbackRenderer, {
1261
- value,
1262
- onChange,
1263
- readonly,
1264
- ...rest
1265
- });
1266
- }
1267
- return /* @__PURE__ */ import_react17.default.createElement(import_semi_ui9.Input, { size: "small", disabled: true, placeholder: "Unsupported type" });
1268
- }
1269
- return /* @__PURE__ */ import_react17.default.createElement(Renderer2, { value, onChange, readonly, ...rest });
1270
- }
1271
-
1272
- // src/components/json-schema-editor/default-value.tsx
1273
- function DefaultValue(props) {
1274
- const { value, schema, onChange, placeholder } = props;
1275
- return /* @__PURE__ */ import_react18.default.createElement(ConstantInputWrapper, null, /* @__PURE__ */ import_react18.default.createElement(
1276
- ConstantInput,
1277
- {
1278
- value,
1279
- onChange: (_v) => onChange(_v),
1280
- schema: schema || { type: "string" },
1281
- placeholder: placeholder ?? import_editor13.I18n.t("Default value if parameter is not provided")
1282
- }
1283
- ));
1284
- }
1285
-
1286
- // src/components/json-schema-editor/components/blur-input.tsx
1287
- var import_react19 = __toESM(require("react"));
1288
- var import_input = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
1289
- function BlurInput(props) {
1290
- const [value, setValue] = (0, import_react19.useState)("");
1291
- (0, import_react19.useEffect)(() => {
1292
- setValue(props.value);
1293
- }, [props.value]);
1294
- return /* @__PURE__ */ import_react19.default.createElement(
1295
- import_input.default,
1296
- {
1297
- ...props,
1298
- value,
1299
- onChange: (value2) => {
1300
- setValue(value2);
1301
- },
1302
- onBlur: (e) => props.onChange?.(value, e)
1303
- }
1304
- );
1305
- }
1306
-
1307
- // src/components/json-schema-editor/index.tsx
1308
- var DEFAULT = { type: "object" };
1309
- function JsonSchemaEditor(props) {
1310
- const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
1311
- const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
1312
- value,
1313
- onChangeProps
1314
- );
1315
- return /* @__PURE__ */ import_react20.default.createElement(UIContainer, { className: props.className }, /* @__PURE__ */ import_react20.default.createElement(UIProperties, null, propertyList.map((_property, index) => /* @__PURE__ */ import_react20.default.createElement(
1316
- PropertyEdit,
1317
- {
1318
- readonly,
1319
- key: _property.key,
1320
- value: _property,
1321
- config,
1322
- $index: index,
1323
- onChange: (_v) => {
1324
- onEditProperty(_property.key, _v);
1325
- },
1326
- onRemove: () => {
1327
- onRemoveProperty(_property.key);
1328
- }
1329
- }
1330
- ))), /* @__PURE__ */ import_react20.default.createElement(
1331
- import_semi_ui10.Button,
1332
- {
1333
- disabled: readonly,
1334
- size: "small",
1335
- style: { marginTop: 10, marginLeft: 16 },
1336
- icon: /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconPlus, null),
1337
- onClick: onAddProperty
1338
- },
1339
- config?.addButtonText ?? import_editor14.I18n.t("Add")
1340
- ));
1341
- }
1342
- function PropertyEdit(props) {
1343
- const {
1344
- value,
1345
- config,
1346
- readonly,
1347
- $level = 0,
1348
- onChange: onChangeProps,
1349
- onRemove,
1350
- $index,
1351
- $isFirst,
1352
- $isLast,
1353
- $parentExpand = false,
1354
- $parentType = "",
1355
- $showLine
1356
- } = props;
1357
- const [expand, setExpand] = (0, import_react20.useState)(false);
1358
- const [collapse, setCollapse] = (0, import_react20.useState)(false);
1359
- const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
1360
- const typeSelectorValue = (0, import_react20.useMemo)(() => ({ type, items }), [type, items]);
1361
- const { propertyList, canAddField, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
1362
- const onChange = (key, _value) => {
1363
- onChangeProps?.({
1364
- ...value || {},
1365
- [key]: _value
1366
- });
1367
- };
1368
- const showCollapse = canAddField && propertyList.length > 0;
1369
- return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(
1370
- UIPropertyLeft,
1371
- {
1372
- type,
1373
- $index,
1374
- $isFirst,
1375
- $isLast,
1376
- $showLine,
1377
- $isExpand: expand,
1378
- $parentExpand,
1379
- $parentType
1380
- },
1381
- showCollapse && /* @__PURE__ */ import_react20.default.createElement(UICollapseTrigger, { onClick: () => setCollapse((_collapse) => !_collapse) }, collapse ? /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconChevronDown, { size: "small" }) : /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconChevronRight, { size: "small" }))
1382
- ), /* @__PURE__ */ import_react20.default.createElement(UIPropertyRight, null, /* @__PURE__ */ import_react20.default.createElement(
1383
- UIPropertyMain,
1384
- {
1385
- $showCollapse: showCollapse,
1386
- $collapse: collapse,
1387
- $expand: expand,
1388
- type
1389
- },
1390
- /* @__PURE__ */ import_react20.default.createElement(UIRow, null, /* @__PURE__ */ import_react20.default.createElement(UIName, null, /* @__PURE__ */ import_react20.default.createElement(
1391
- BlurInput,
1392
- {
1393
- disabled: readonly,
1394
- placeholder: config?.placeholder ?? "Input Variable Name",
1395
- size: "small",
1396
- value: name,
1397
- onChange: (value2) => onChange("name", value2)
1398
- }
1399
- )), /* @__PURE__ */ import_react20.default.createElement(UIType, null, /* @__PURE__ */ import_react20.default.createElement(
1400
- InjectTypeSelector,
1401
- {
1402
- value: typeSelectorValue,
1403
- readonly,
1404
- onChange: (_value) => {
1405
- onChangeProps?.({
1406
- ...value || {},
1407
- ..._value
1408
- });
1409
- }
1410
- }
1411
- )), /* @__PURE__ */ import_react20.default.createElement(UIRequired, null, /* @__PURE__ */ import_react20.default.createElement(
1412
- import_semi_ui10.Checkbox,
1413
- {
1414
- disabled: readonly,
1415
- checked: isPropertyRequired,
1416
- onChange: (e) => onChange("isPropertyRequired", e.target.checked)
1417
- }
1418
- )), /* @__PURE__ */ import_react20.default.createElement(UIActions, null, /* @__PURE__ */ import_react20.default.createElement(
1419
- import_semi_ui10.IconButton,
1420
- {
1421
- disabled: readonly,
1422
- size: "small",
1423
- theme: "borderless",
1424
- icon: expand ? /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconShrink, { size: "small" }) : /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconExpand, { size: "small" }),
1425
- onClick: () => {
1426
- setExpand((_expand) => !_expand);
1427
- }
1428
- }
1429
- ), canAddField && /* @__PURE__ */ import_react20.default.createElement(
1430
- import_semi_ui10.IconButton,
1431
- {
1432
- disabled: readonly,
1433
- size: "small",
1434
- theme: "borderless",
1435
- icon: /* @__PURE__ */ import_react20.default.createElement(IconAddChildren, null),
1436
- onClick: () => {
1437
- onAddProperty();
1438
- setCollapse(true);
1439
- }
1440
- }
1441
- ), /* @__PURE__ */ import_react20.default.createElement(
1442
- import_semi_ui10.IconButton,
1443
- {
1444
- disabled: readonly,
1445
- size: "small",
1446
- theme: "borderless",
1447
- icon: /* @__PURE__ */ import_react20.default.createElement(import_semi_icons3.IconMinus, { size: "small" }),
1448
- onClick: onRemove
1449
- }
1450
- ))),
1451
- expand && /* @__PURE__ */ import_react20.default.createElement(UIExpandDetail, null, /* @__PURE__ */ import_react20.default.createElement(UILabel, null, config?.descTitle ?? import_editor14.I18n.t("Description")), /* @__PURE__ */ import_react20.default.createElement(
1452
- BlurInput,
1453
- {
1454
- disabled: readonly,
1455
- size: "small",
1456
- value: description,
1457
- onChange: (value2) => onChange("description", value2),
1458
- placeholder: config?.descPlaceholder ?? import_editor14.I18n.t("Help LLM to understand the property")
1459
- }
1460
- ), $level === 0 && /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(UILabel, { style: { marginTop: 10 } }, config?.defaultValueTitle ?? import_editor14.I18n.t("Default Value")), /* @__PURE__ */ import_react20.default.createElement(DefaultValueWrapper, null, /* @__PURE__ */ import_react20.default.createElement(
1461
- DefaultValue,
1462
- {
1463
- value: defaultValue,
1464
- schema: value,
1465
- type,
1466
- placeholder: config?.defaultValuePlaceholder ?? import_editor14.I18n.t("Default Value"),
1467
- jsonFormatText: config?.jsonFormatText,
1468
- onChange: (value2) => onChange("default", value2)
1469
- }
1470
- ))))
1471
- ), showCollapse && /* @__PURE__ */ import_react20.default.createElement(UICollapsible, { $collapse: collapse }, /* @__PURE__ */ import_react20.default.createElement(UIProperties, { $shrink: true }, propertyList.map((_property, index) => /* @__PURE__ */ import_react20.default.createElement(
1472
- PropertyEdit,
1473
- {
1474
- readonly,
1475
- key: _property.key,
1476
- value: _property,
1477
- config,
1478
- $level: $level + 1,
1479
- $parentExpand: expand,
1480
- $parentType: type,
1481
- onChange: (_v) => {
1482
- onEditProperty(_property.key, _v);
1483
- },
1484
- onRemove: () => {
1485
- onRemoveProperty(_property.key);
1486
- },
1487
- $isLast: index === propertyList.length - 1,
1488
- $isFirst: index === 0,
1489
- $index: index,
1490
- $showLine: true
1491
- }
1492
- ))))));
1493
- }
1494
-
1495
- // src/components/batch-variable-selector/index.tsx
1496
- var import_react21 = __toESM(require("react"));
1497
- var import_editor15 = require("@flowgram.ai/editor");
1498
- var batchVariableSchema = {
1499
- type: "array",
1500
- extra: { weak: true }
1501
- };
1502
- function BatchVariableSelector(props) {
1503
- return /* @__PURE__ */ import_react21.default.createElement(import_editor15.PrivateScopeProvider, null, /* @__PURE__ */ import_react21.default.createElement(VariableSelector, { ...props, includeSchema: batchVariableSchema }));
1504
- }
1505
-
1506
- // src/components/dynamic-value-input/index.tsx
1507
- var import_react23 = __toESM(require("react"));
1508
- var import_json_schema6 = require("@flowgram.ai/json-schema");
1509
- var import_semi_ui11 = require("@douyinfe/semi-ui");
1510
- var import_semi_icons4 = require("@douyinfe/semi-icons");
1511
-
1512
- // src/components/dynamic-value-input/styles.tsx
1513
- var import_styled_components4 = __toESM(require("styled-components"));
1514
- var UIContainer2 = import_styled_components4.default.div`
1515
- display: flex;
1516
- align-items: center;
1517
- border-radius: 4px;
1518
- border: 1px solid var(--semi-color-border);
1519
-
1520
- overflow: hidden;
1521
-
1522
- background-color: var(--semi-color-fill-0);
1523
- `;
1524
- var UIMain = import_styled_components4.default.div`
1525
- flex-grow: 1;
1526
- overflow: hidden;
1527
- min-width: 0;
1528
-
1529
- & .semi-tree-select,
1530
- & .semi-input-number,
1531
- & .semi-select {
1532
- width: 100%;
1533
- border: none;
1534
- border-radius: 0;
1535
- }
1536
-
1537
- & .semi-input-wrapper {
1538
- border: none;
1539
- border-radius: 0;
1540
- }
1541
- `;
1542
- var UIType2 = import_styled_components4.default.div`
1543
- border-right: 1px solid #e5e5e5;
1544
-
1545
- & .semi-button {
1546
- border-radius: 0;
1547
- }
1548
- `;
1549
- var UITrigger = import_styled_components4.default.div`
1550
- border-left: 1px solid #e5e5e5;
1551
-
1552
- & .semi-button {
1553
- border-radius: 0;
1554
- }
1555
- `;
1556
-
1557
- // src/components/dynamic-value-input/hooks.ts
1558
- var import_react22 = require("react");
1559
- var import_editor16 = require("@flowgram.ai/editor");
1560
- function useRefVariable(value) {
1561
- const available = (0, import_editor16.useScopeAvailable)();
1562
- const refVariable = (0, import_react22.useMemo)(() => {
1563
- if (value?.type === "ref") {
1564
- return available.getByKeyPath(value.content);
1565
- }
1566
- }, [value, available]);
1567
- return refVariable;
1568
- }
1569
- function useSelectSchema(schemaFromProps, constantProps, value) {
1570
- let defaultSelectSchema = schemaFromProps || constantProps?.schema || { type: "string" };
1571
- if (value?.type === "constant") {
1572
- defaultSelectSchema = value?.schema || defaultSelectSchema;
1573
- }
1574
- const [selectSchema, setSelectSchema] = (0, import_react22.useState)(defaultSelectSchema);
1575
- return [selectSchema, setSelectSchema];
1576
- }
1577
- function useIncludeSchema(schemaFromProps) {
1578
- const includeSchema = (0, import_react22.useMemo)(() => {
1579
- if (!schemaFromProps) {
1580
- return;
1581
- }
1582
- if (schemaFromProps?.type === "number") {
1583
- return [schemaFromProps, { type: "integer" }];
1584
- }
1585
- return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
1586
- }, [schemaFromProps]);
1587
- return includeSchema;
1588
- }
1589
-
1590
- // src/components/dynamic-value-input/index.tsx
1591
- function DynamicValueInput({
1592
- value,
1593
- onChange,
1594
- readonly,
1595
- style,
1596
- schema: schemaFromProps,
1597
- constantProps
1598
- }) {
1599
- const refVariable = useRefVariable(value);
1600
- const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
1601
- const includeSchema = useIncludeSchema(schemaFromProps);
1602
- const renderTypeSelector = () => {
1603
- if (schemaFromProps) {
1604
- return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
1605
- }
1606
- if (value?.type === "ref") {
1607
- const schema = refVariable?.type ? import_json_schema6.JsonSchemaUtils.astToSchema(refVariable?.type) : void 0;
1608
- return /* @__PURE__ */ import_react23.default.createElement(TypeSelector, { value: schema, readonly: true });
1609
- }
1610
- return /* @__PURE__ */ import_react23.default.createElement(
1611
- TypeSelector,
1612
- {
1613
- value: selectSchema,
1614
- onChange: (_v) => {
1615
- setSelectSchema(_v || { type: "string" });
1616
- let content;
1617
- if (_v?.type === "object") {
1618
- content = "{}";
1619
- }
1620
- if (_v?.type === "array") {
1621
- content = "[]";
1622
- }
1623
- if (_v?.type === "boolean") {
1624
- content = false;
1625
- }
1626
- onChange({
1627
- type: "constant",
1628
- content,
1629
- schema: _v || { type: "string" }
1630
- });
1631
- },
1632
- readonly
1633
- }
1634
- );
1635
- };
1636
- const renderMain = () => {
1637
- if (value?.type === "ref") {
1638
- return /* @__PURE__ */ import_react23.default.createElement(
1639
- InjectVariableSelector,
1640
- {
1641
- style: { width: "100%" },
1642
- value: value?.content,
1643
- onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1644
- includeSchema,
1645
- readonly
1646
- }
1647
- );
1648
- }
1649
- const constantSchema = schemaFromProps || selectSchema || { type: "string" };
1650
- return /* @__PURE__ */ import_react23.default.createElement(
1651
- ConstantInput,
1652
- {
1653
- value: value?.content,
1654
- onChange: (_v) => onChange({ type: "constant", content: _v, schema: constantSchema }),
1655
- schema: constantSchema || { type: "string" },
1656
- readonly,
1657
- strategies: [...constantProps?.strategies || []],
1658
- fallbackRenderer: () => /* @__PURE__ */ import_react23.default.createElement(
1659
- InjectVariableSelector,
1660
- {
1661
- style: { width: "100%" },
1662
- onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : void 0),
1663
- includeSchema,
1664
- readonly
1665
- }
1666
- ),
1667
- ...constantProps
1668
- }
1669
- );
1670
- };
1671
- const renderTrigger = () => /* @__PURE__ */ import_react23.default.createElement(
1672
- InjectVariableSelector,
1673
- {
1674
- style: { width: "100%" },
1675
- value: value?.type === "ref" ? value?.content : void 0,
1676
- onChange: (_v) => onChange({ type: "ref", content: _v }),
1677
- includeSchema,
1678
- readonly,
1679
- triggerRender: () => /* @__PURE__ */ import_react23.default.createElement(import_semi_ui11.IconButton, { disabled: readonly, size: "small", icon: /* @__PURE__ */ import_react23.default.createElement(import_semi_icons4.IconSetting, { size: "small" }) })
1680
- }
1681
- );
1682
- return /* @__PURE__ */ import_react23.default.createElement(UIContainer2, { style }, /* @__PURE__ */ import_react23.default.createElement(UIType2, null, renderTypeSelector()), /* @__PURE__ */ import_react23.default.createElement(UIMain, null, renderMain()), /* @__PURE__ */ import_react23.default.createElement(UITrigger, null, renderTrigger()));
1683
- }
1684
- DynamicValueInput.renderKey = "dynamic-value-input-render-key";
1685
- var InjectDynamicValueInput = createInjectMaterial(DynamicValueInput);
1686
-
1687
- // src/components/condition-row/index.tsx
1688
- var import_react26 = __toESM(require("react"));
1689
- var import_editor19 = require("@flowgram.ai/editor");
1690
- var import_semi_ui13 = require("@douyinfe/semi-ui");
1691
-
1692
- // src/components/condition-row/styles.tsx
1693
- var import_styled_components5 = __toESM(require("styled-components"));
1694
- var UIContainer3 = import_styled_components5.default.div`
1695
- display: flex;
1696
- align-items: center;
1697
- gap: 4px;
1698
- `;
1699
- var UIOperator = import_styled_components5.default.div``;
1700
- var UILeft = import_styled_components5.default.div`
1701
- width: 100%;
1702
- `;
1703
- var UIRight = import_styled_components5.default.div`
1704
- width: 100%;
1705
- `;
1706
- var UIValues = import_styled_components5.default.div`
1707
- flex-grow: 1;
1708
- display: flex;
1709
- flex-direction: column;
1710
- align-items: center;
1711
- gap: 4px;
1712
- `;
1713
-
1714
- // src/components/condition-row/hooks/useRule.ts
1715
- var import_react24 = require("react");
1716
- var import_json_schema7 = require("@flowgram.ai/json-schema");
1717
- var import_editor17 = require("@flowgram.ai/editor");
1718
-
1719
- // src/components/condition-row/constants.ts
1720
- var defaultRules = {
1721
- string: {
1722
- ["eq" /* EQ */]: "string",
1723
- ["neq" /* NEQ */]: "string",
1724
- ["contains" /* CONTAINS */]: "string",
1725
- ["not_contains" /* NOT_CONTAINS */]: "string",
1726
- ["in" /* IN */]: "array",
1727
- ["nin" /* NIN */]: "array",
1728
- ["is_empty" /* IS_EMPTY */]: null,
1729
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1730
- },
1731
- number: {
1732
- ["eq" /* EQ */]: "number",
1733
- ["neq" /* NEQ */]: "number",
1734
- ["gt" /* GT */]: "number",
1735
- ["gte" /* GTE */]: "number",
1736
- ["lt" /* LT */]: "number",
1737
- ["lte" /* LTE */]: "number",
1738
- ["in" /* IN */]: "array",
1739
- ["nin" /* NIN */]: "array"
1740
- },
1741
- integer: {
1742
- ["eq" /* EQ */]: "number",
1743
- ["neq" /* NEQ */]: "number",
1744
- ["gt" /* GT */]: "number",
1745
- ["gte" /* GTE */]: "number",
1746
- ["lt" /* LT */]: "number",
1747
- ["lte" /* LTE */]: "number",
1748
- ["in" /* IN */]: "array",
1749
- ["nin" /* NIN */]: "array"
1750
- },
1751
- boolean: {
1752
- ["eq" /* EQ */]: "boolean",
1753
- ["neq" /* NEQ */]: "boolean",
1754
- ["is_true" /* IS_TRUE */]: null,
1755
- ["is_false" /* IS_FALSE */]: null,
1756
- ["in" /* IN */]: "array",
1757
- ["nin" /* NIN */]: "array"
1758
- },
1759
- object: {
1760
- ["is_empty" /* IS_EMPTY */]: null,
1761
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1762
- },
1763
- array: {
1764
- ["is_empty" /* IS_EMPTY */]: null,
1765
- ["is_not_empty" /* IS_NOT_EMPTY */]: null,
1766
- ["contains" /* CONTAINS */]: "array",
1767
- ["not_contains" /* NOT_CONTAINS */]: "array",
1768
- ["eq" /* EQ */]: "array",
1769
- ["neq" /* NEQ */]: "array"
1770
- },
1771
- map: {
1772
- ["is_empty" /* IS_EMPTY */]: null,
1773
- ["is_not_empty" /* IS_NOT_EMPTY */]: null
1774
- }
1775
- };
1776
- var defaultOpConfigs = {
1777
- ["eq" /* EQ */]: {
1778
- label: "Equal",
1779
- abbreviation: "="
1780
- },
1781
- ["neq" /* NEQ */]: {
1782
- label: "Not Equal",
1783
- abbreviation: "\u2260"
1784
- },
1785
- ["gt" /* GT */]: {
1786
- label: "Greater Than",
1787
- abbreviation: ">"
1788
- },
1789
- ["gte" /* GTE */]: {
1790
- label: "Greater Than or Equal",
1791
- abbreviation: ">="
1792
- },
1793
- ["lt" /* LT */]: {
1794
- label: "Less Than",
1795
- abbreviation: "<"
1796
- },
1797
- ["lte" /* LTE */]: {
1798
- label: "Less Than or Equal",
1799
- abbreviation: "<="
1800
- },
1801
- ["in" /* IN */]: {
1802
- label: "In",
1803
- abbreviation: "\u2208"
1804
- },
1805
- ["nin" /* NIN */]: {
1806
- label: "Not In",
1807
- abbreviation: "\u2209"
1808
- },
1809
- ["contains" /* CONTAINS */]: {
1810
- label: "Contains",
1811
- abbreviation: "\u2287"
1812
- },
1813
- ["not_contains" /* NOT_CONTAINS */]: {
1814
- label: "Not Contains",
1815
- abbreviation: "\u2289"
1816
- },
1817
- ["is_empty" /* IS_EMPTY */]: {
1818
- label: "Is Empty",
1819
- abbreviation: "=",
1820
- rightDisplay: "Empty"
1821
- },
1822
- ["is_not_empty" /* IS_NOT_EMPTY */]: {
1823
- label: "Is Not Empty",
1824
- abbreviation: "\u2260",
1825
- rightDisplay: "Empty"
1826
- },
1827
- ["is_true" /* IS_TRUE */]: {
1828
- label: "Is True",
1829
- abbreviation: "=",
1830
- rightDisplay: "True"
1831
- },
1832
- ["is_false" /* IS_FALSE */]: {
1833
- label: "Is False",
1834
- abbreviation: "=",
1835
- rightDisplay: "False"
1836
- }
1837
- };
1838
-
1839
- // src/components/condition-row/hooks/useRule.ts
1840
- function useRule(left, userRules) {
1841
- const available = (0, import_editor17.useScopeAvailable)();
1842
- const rules = (0, import_react24.useMemo)(() => ({ ...defaultRules, ...userRules || {} }), [userRules]);
1843
- const variable = (0, import_react24.useMemo)(() => {
1844
- if (!left) return void 0;
1845
- return available.getByKeyPath(left.content);
1846
- }, [available, left]);
1847
- const rule = (0, import_react24.useMemo)(() => {
1848
- if (!variable) return void 0;
1849
- const schema = import_json_schema7.JsonSchemaUtils.astToSchema(variable.type, { drilldown: false });
1850
- return rules[schema?.type];
1851
- }, [variable?.type, rules]);
1852
- return { rule };
1853
- }
1854
-
1855
- // src/components/condition-row/hooks/useOp.tsx
1856
- var import_react25 = __toESM(require("react"));
1857
- var import_editor18 = require("@flowgram.ai/editor");
1858
- var import_semi_ui12 = require("@douyinfe/semi-ui");
1859
- var import_semi_icons5 = require("@douyinfe/semi-icons");
1860
- function useOp({ rule, op, onChange, readonly, userOps }) {
1861
- const options = (0, import_react25.useMemo)(
1862
- () => Object.keys(rule || {}).map((_op) => ({
1863
- ...defaultOpConfigs[_op] || {},
1864
- ...userOps?.[_op] || {},
1865
- value: _op,
1866
- label: import_editor18.I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
1867
- })),
1868
- [rule, userOps]
1869
- );
1870
- const opConfig = (0, import_react25.useMemo)(() => defaultOpConfigs[op], [op]);
1871
- const renderOpSelect = () => /* @__PURE__ */ import_react25.default.createElement(
1872
- import_semi_ui12.Select,
1873
- {
1874
- style: { height: 22 },
1875
- disabled: readonly,
1876
- size: "small",
1877
- value: op,
1878
- optionList: options,
1879
- onChange: (v) => {
1880
- onChange(v);
1881
- },
1882
- triggerRender: ({ value }) => /* @__PURE__ */ import_react25.default.createElement(import_semi_ui12.Button, { size: "small", disabled: !rule }, opConfig?.abbreviation || /* @__PURE__ */ import_react25.default.createElement(import_semi_icons5.IconChevronDownStroked, { size: "small" }))
1883
- }
1884
- );
1885
- return { renderOpSelect, opConfig };
1886
- }
1887
-
1888
- // src/components/condition-row/index.tsx
1889
- var defaultRuleConfig = {
1890
- ops: {},
1891
- rules: {}
1892
- };
1893
- function ConditionRow({
1894
- style,
1895
- value,
1896
- onChange,
1897
- readonly,
1898
- ruleConfig = defaultRuleConfig
1899
- }) {
1900
- const { left, operator, right } = value || {};
1901
- const { rule } = useRule(left, ruleConfig.rules);
1902
- const { renderOpSelect, opConfig } = useOp({
1903
- rule,
1904
- op: operator,
1905
- onChange: (v) => onChange({ ...value, operator: v }),
1906
- readonly,
1907
- userOps: ruleConfig.ops
1908
- });
1909
- const targetSchema = (0, import_react26.useMemo)(() => {
1910
- const targetType = rule?.[operator || ""] || null;
1911
- return targetType ? { type: targetType, extra: { weak: true } } : null;
1912
- }, [rule, opConfig]);
1913
- return /* @__PURE__ */ import_react26.default.createElement(UIContainer3, { style }, /* @__PURE__ */ import_react26.default.createElement(UIOperator, null, renderOpSelect()), /* @__PURE__ */ import_react26.default.createElement(UIValues, null, /* @__PURE__ */ import_react26.default.createElement(UILeft, null, /* @__PURE__ */ import_react26.default.createElement(
1914
- InjectVariableSelector,
1915
- {
1916
- readonly,
1917
- style: { width: "100%" },
1918
- value: left?.content,
1919
- onChange: (v) => onChange({
1920
- ...value,
1921
- left: {
1922
- type: "ref",
1923
- content: v
1924
- }
1925
- })
1926
- }
1927
- )), /* @__PURE__ */ import_react26.default.createElement(UIRight, null, targetSchema ? /* @__PURE__ */ import_react26.default.createElement(
1928
- InjectDynamicValueInput,
1929
- {
1930
- readonly: readonly || !rule,
1931
- value: right,
1932
- schema: targetSchema,
1933
- onChange: (v) => onChange({ ...value, right: v })
1934
- }
1935
- ) : /* @__PURE__ */ import_react26.default.createElement(
1936
- import_semi_ui13.Input,
1937
- {
1938
- size: "small",
1939
- disabled: true,
1940
- style: { pointerEvents: "none" },
1941
- value: opConfig?.rightDisplay || import_editor19.I18n.t("Empty")
1942
- }
1943
- ))));
1944
- }
1945
-
1946
- // src/components/batch-outputs/index.tsx
1947
- var import_react28 = __toESM(require("react"));
1948
- var import_semi_ui14 = require("@douyinfe/semi-ui");
1949
- var import_semi_icons6 = require("@douyinfe/semi-icons");
1950
-
1951
- // src/hooks/use-object-list/index.tsx
1952
- var import_react27 = require("react");
1953
- var import_nanoid = require("nanoid");
1954
- var import_lodash3 = require("lodash");
1955
- function genId2() {
1956
- return (0, import_nanoid.nanoid)();
1957
- }
1958
- function useObjectList({
1959
- value,
1960
- onChange,
1961
- sortIndexKey
1962
- }) {
1963
- const [list, setList] = (0, import_react27.useState)([]);
1964
- (0, import_react27.useEffect)(() => {
1965
- setList((_prevList) => {
1966
- const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash3.get)(a[1], sortIndexKey || 0) - (0, import_lodash3.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
1967
- const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
1968
- const addKeys = (0, import_lodash3.difference)(newKeys, oldKeys);
1969
- return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
1970
- id: item.id,
1971
- key: item.key,
1972
- value: item.key ? value?.[item.key] : item.value
1973
- })).concat(
1974
- addKeys.map((_key) => ({
1975
- id: genId2(),
1976
- key: _key,
1977
- value: value?.[_key]
1978
- }))
1979
- );
1980
- });
1981
- }, [value]);
1982
- const add = () => {
1983
- setList((prevList) => [
1984
- ...prevList,
1985
- {
1986
- id: genId2()
1987
- }
1988
- ]);
1989
- };
1990
- const updateValue = (itemId, value2) => {
1991
- setList((prevList) => {
1992
- const nextList = prevList.map((_item) => {
1993
- if (_item.id === itemId) {
1994
- return {
1995
- ..._item,
1996
- value: value2
1997
- };
1998
- }
1999
- return _item;
2000
- });
2001
- onChange(
2002
- Object.fromEntries(
2003
- nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
2004
- if ((0, import_lodash3.isObject)(_res[1]) && sortIndexKey) {
2005
- (0, import_lodash3.set)(_res[1], sortIndexKey, idx);
2006
- }
2007
- return _res;
2008
- })
2009
- )
2010
- );
2011
- return nextList;
2012
- });
2013
- };
2014
- const updateKey = (itemId, key) => {
2015
- setList((prevList) => {
2016
- const nextList = prevList.map((_item) => {
2017
- if (_item.id === itemId) {
2018
- return {
2019
- ..._item,
2020
- key
2021
- };
2022
- }
2023
- return _item;
2024
- });
2025
- onChange(
2026
- Object.fromEntries(
2027
- nextList.filter((item) => item.key).map((item) => [item.key, item.value])
2028
- )
2029
- );
2030
- return nextList;
2031
- });
2032
- };
2033
- const remove = (itemId) => {
2034
- setList((prevList) => {
2035
- const nextList = prevList.filter((_item) => _item.id !== itemId);
2036
- onChange(
2037
- Object.fromEntries(
2038
- nextList.filter((item) => item.key).map((item) => [item.key, item.value])
2039
- )
2040
- );
2041
- return nextList;
2042
- });
2043
- };
2044
- return { list, add, updateKey, updateValue, remove };
2045
- }
2046
-
2047
- // src/components/batch-outputs/styles.tsx
2048
- var import_styled_components6 = __toESM(require("styled-components"));
2049
- var UIRows = import_styled_components6.default.div`
2050
- display: flex;
2051
- flex-direction: column;
2052
- gap: 10px;
2053
- margin-bottom: 10px;
2054
- `;
2055
- var UIRow2 = import_styled_components6.default.div`
2056
- display: flex;
2057
- align-items: center;
2058
- gap: 5px;
2059
- `;
2060
-
2061
- // src/components/batch-outputs/index.tsx
2062
- function BatchOutputs(props) {
2063
- const { readonly, style } = props;
2064
- const { list, add, updateKey, updateValue, remove } = useObjectList(props);
2065
- return /* @__PURE__ */ import_react28.default.createElement("div", null, /* @__PURE__ */ import_react28.default.createElement(UIRows, { style }, list.map((item) => /* @__PURE__ */ import_react28.default.createElement(UIRow2, { key: item.id }, /* @__PURE__ */ import_react28.default.createElement(
2066
- import_semi_ui14.Input,
2067
- {
2068
- style: { width: 100 },
2069
- disabled: readonly,
2070
- size: "small",
2071
- value: item.key,
2072
- onChange: (v) => updateKey(item.id, v)
2073
- }
2074
- ), /* @__PURE__ */ import_react28.default.createElement(
2075
- InjectVariableSelector,
2076
- {
2077
- style: { flexGrow: 1 },
2078
- readonly,
2079
- value: item.value?.content,
2080
- onChange: (v) => updateValue(item.id, { type: "ref", content: v })
2081
- }
2082
- ), /* @__PURE__ */ import_react28.default.createElement(
2083
- import_semi_ui14.Button,
2084
- {
2085
- disabled: readonly,
2086
- icon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons6.IconDelete, null),
2087
- size: "small",
2088
- onClick: () => remove(item.id)
2089
- }
2090
- )))), /* @__PURE__ */ import_react28.default.createElement(import_semi_ui14.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react28.default.createElement(import_semi_icons6.IconPlus, null), size: "small", onClick: add }, "Add"));
2091
- }
2092
-
2093
- // src/components/prompt-editor/index.tsx
2094
- var import_react35 = __toESM(require("react"));
2095
- var import_react36 = require("@coze-editor/editor/react");
2096
- var import_preset_prompt2 = __toESM(require("@coze-editor/editor/preset-prompt"));
2097
-
2098
- // src/components/prompt-editor/styles.tsx
2099
- var import_styled_components7 = __toESM(require("styled-components"));
2100
- var UIContainer4 = import_styled_components7.default.div`
2101
- background-color: var(--semi-color-fill-0);
2102
- padding-left: 10px;
2103
- padding-right: 6px;
2104
-
2105
- ${({ $hasError }) => $hasError && import_styled_components7.css`
2106
- border: 1px solid var(--semi-color-danger-6);
2107
- `}
2108
- `;
2109
-
2110
- // src/components/prompt-editor/extensions/markdown.tsx
2111
- var import_react29 = require("react");
2112
- var import_react30 = require("@coze-editor/editor/react");
2113
- var import_editor20 = require("@coze-editor/editor");
2114
- var import_view2 = require("@codemirror/view");
2115
- function MarkdownHighlight() {
2116
- const injector = (0, import_react30.useInjector)();
2117
- (0, import_react29.useLayoutEffect)(
2118
- () => injector.inject([
2119
- import_editor20.astDecorator.whole.of((cursor) => {
2120
- if (cursor.name.startsWith("ATXHeading")) {
2121
- return {
2122
- type: "className",
2123
- className: "heading"
2124
- };
2125
- }
2126
- if (cursor.name === "Emphasis") {
2127
- return {
2128
- type: "className",
2129
- className: "emphasis"
2130
- };
2131
- }
2132
- if (cursor.name === "StrongEmphasis") {
2133
- return {
2134
- type: "className",
2135
- className: "strong-emphasis"
2136
- };
2137
- }
2138
- if (cursor.name === "ListMark" || cursor.name === "QuoteMark") {
2139
- return {
2140
- type: "className",
2141
- className: "mark"
2142
- };
2143
- }
2144
- }),
2145
- import_view2.EditorView.theme({
2146
- ".heading": {
2147
- color: "#00818C",
2148
- fontWeight: "bold"
2149
- },
2150
- ".emphasis": {
2151
- fontStyle: "italic"
2152
- },
2153
- ".strong-emphasis": {
2154
- fontWeight: "bold"
2155
- },
2156
- ".mark": {
2157
- color: "#4E40E5"
2158
- }
2159
- })
2160
- ]),
2161
- [injector]
2162
- );
2163
- return null;
2164
- }
2165
- var markdown_default = MarkdownHighlight;
2166
-
2167
- // src/components/prompt-editor/extensions/language-support.tsx
2168
- var import_react31 = require("react");
2169
- var import_react32 = require("@coze-editor/editor/react");
2170
- var import_preset_prompt = require("@coze-editor/editor/preset-prompt");
2171
- function LanguageSupport() {
2172
- const injector = (0, import_react32.useInjector)();
2173
- (0, import_react31.useLayoutEffect)(() => injector.inject([import_preset_prompt.languageSupport]), [injector]);
2174
- return null;
2175
- }
2176
- var language_support_default = LanguageSupport;
2177
-
2178
- // src/components/prompt-editor/extensions/jinja.tsx
2179
- var import_react33 = require("react");
2180
- var import_react34 = require("@coze-editor/editor/react");
2181
- var import_editor21 = require("@coze-editor/editor");
2182
- var import_view3 = require("@codemirror/view");
2183
- function JinjaHighlight() {
2184
- const injector = (0, import_react34.useInjector)();
2185
- (0, import_react33.useLayoutEffect)(
2186
- () => injector.inject([
2187
- import_editor21.astDecorator.whole.of((cursor) => {
2188
- if (cursor.name === "JinjaStatementStart" || cursor.name === "JinjaStatementEnd") {
2189
- return {
2190
- type: "className",
2191
- className: "jinja-statement-bracket"
2192
- };
2193
- }
2194
- if (cursor.name === "JinjaComment") {
2195
- return {
2196
- type: "className",
2197
- className: "jinja-comment"
2198
- };
2199
- }
2200
- if (cursor.name === "JinjaExpression") {
2201
- return {
2202
- type: "className",
2203
- className: "jinja-expression"
2204
- };
2205
- }
2206
- }),
2207
- import_view3.EditorView.theme({
2208
- ".jinja-statement-bracket": {
2209
- color: "#D1009D"
2210
- },
2211
- ".jinja-comment": {
2212
- color: "#0607094D"
2213
- },
2214
- ".jinja-expression": {
2215
- color: "#4E40E5"
2216
- }
2217
- })
2218
- ]),
2219
- [injector]
2220
- );
2221
- return null;
2222
- }
2223
- var jinja_default = JinjaHighlight;
2224
-
2225
- // src/components/prompt-editor/index.tsx
2226
- function PromptEditor(props) {
2227
- const {
2228
- value,
2229
- onChange,
2230
- readonly,
2231
- placeholder,
2232
- activeLinePlaceholder,
2233
- style,
2234
- hasError,
2235
- children,
2236
- disableMarkdownHighlight
2237
- } = props || {};
2238
- const editorRef = (0, import_react35.useRef)(null);
2239
- (0, import_react35.useEffect)(() => {
2240
- if (editorRef.current?.getValue() !== value?.content) {
2241
- editorRef.current?.setValue(String(value?.content || ""));
2242
- }
2243
- }, [value]);
2244
- return /* @__PURE__ */ import_react35.default.createElement(UIContainer4, { $hasError: hasError, style }, /* @__PURE__ */ import_react35.default.createElement(import_react36.EditorProvider, null, /* @__PURE__ */ import_react35.default.createElement(
2245
- import_react36.Renderer,
2246
- {
2247
- didMount: (editor) => {
2248
- editorRef.current = editor;
2249
- },
2250
- plugins: import_preset_prompt2.default,
2251
- defaultValue: String(value?.content),
2252
- options: {
2253
- readOnly: readonly,
2254
- editable: !readonly,
2255
- placeholder
2256
- },
2257
- onChange: (e) => {
2258
- onChange({ type: "template", content: e.value });
2259
- }
2260
- }
2261
- ), activeLinePlaceholder && /* @__PURE__ */ import_react35.default.createElement(import_react36.ActiveLinePlaceholder, null, activeLinePlaceholder), !disableMarkdownHighlight && /* @__PURE__ */ import_react35.default.createElement(markdown_default, null), /* @__PURE__ */ import_react35.default.createElement(language_support_default, null), /* @__PURE__ */ import_react35.default.createElement(jinja_default, null), children));
2262
- }
2263
-
2264
- // src/components/prompt-editor-with-variables/index.tsx
2265
- var import_react41 = __toESM(require("react"));
2266
-
2267
- // src/components/prompt-editor-with-variables/extensions/variable-tree.tsx
2268
- var import_react37 = __toESM(require("react"));
2269
- var import_semi_ui15 = require("@douyinfe/semi-ui");
2270
- var import_react38 = require("@coze-editor/editor/react");
2271
- function VariableTree() {
2272
- const [posKey, setPosKey] = (0, import_react37.useState)("");
2273
- const [visible, setVisible] = (0, import_react37.useState)(false);
2274
- const [position, setPosition] = (0, import_react37.useState)(-1);
2275
- const editor = (0, import_react38.useEditor)();
2276
- function insert(variablePath) {
2277
- const range = (0, import_react38.getCurrentMentionReplaceRange)(editor.$view.state);
2278
- if (!range) {
2279
- return;
2280
- }
2281
- editor.replaceText({
2282
- ...range,
2283
- text: "{{" + variablePath + "}}"
2284
- });
2285
- setVisible(false);
2286
- }
2287
- function handleOpenChange(e) {
2288
- setPosition(e.state.selection.main.head);
2289
- setVisible(e.value);
2290
- }
2291
- (0, import_react37.useEffect)(() => {
2292
- if (!editor) {
2293
- return;
2294
- }
2295
- }, [editor, visible]);
2296
- const treeData = useVariableTree({});
2297
- return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement(import_react38.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react37.default.createElement(
2298
- import_semi_ui15.Popover,
2299
- {
2300
- visible,
2301
- trigger: "custom",
2302
- position: "topLeft",
2303
- rePosKey: posKey,
2304
- content: /* @__PURE__ */ import_react37.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react37.default.createElement(
2305
- import_semi_ui15.Tree,
2306
- {
2307
- treeData,
2308
- onSelect: (v) => {
2309
- insert(v);
2310
- }
2311
- }
2312
- ))
2313
- },
2314
- /* @__PURE__ */ import_react37.default.createElement(
2315
- import_react38.PositionMirror,
2316
- {
2317
- position,
2318
- onChange: () => setPosKey(String(Math.random()))
2319
- }
2320
- )
2321
- ));
2322
- }
2323
-
2324
- // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2325
- var import_react_dom = __toESM(require("react-dom"));
2326
- var import_react39 = __toESM(require("react"));
2327
- var import_lodash4 = require("lodash");
2328
- var import_editor22 = require("@flowgram.ai/editor");
2329
- var import_semi_ui17 = require("@douyinfe/semi-ui");
2330
- var import_semi_icons7 = require("@douyinfe/semi-icons");
2331
- var import_react40 = require("@coze-editor/editor/react");
2332
- var import_view4 = require("@codemirror/view");
2333
-
2334
- // src/components/prompt-editor-with-variables/styles.tsx
2335
- var import_styled_components8 = __toESM(require("styled-components"));
2336
- var import_semi_ui16 = require("@douyinfe/semi-ui");
2337
- var UIRootTitle2 = import_styled_components8.default.div`
2338
- margin-right: 4px;
2339
- min-width: 20px;
2340
- overflow: hidden;
2341
- text-overflow: ellipsis;
2342
- white-space: nowrap;
2343
- color: var(--semi-color-text-2);
2344
- `;
2345
- var UIVarName2 = import_styled_components8.default.div`
2346
- overflow: hidden;
2347
- text-overflow: ellipsis;
2348
- white-space: nowrap;
2349
- `;
2350
- var UITag2 = (0, import_styled_components8.default)(import_semi_ui16.Tag)`
2351
- display: inline-flex;
2352
- align-items: center;
2353
- justify-content: flex-start;
2354
- max-width: 300px;
2355
-
2356
- & .semi-tag-content-center {
2357
- justify-content: flex-start;
2358
- }
2359
-
2360
- &.semi-tag {
2361
- margin: 0 5px;
2362
- }
2363
- `;
2364
- var UIPopoverContent2 = import_styled_components8.default.div`
2365
- padding: 10px;
2366
- display: inline-flex;
2367
- align-items: center;
2368
- justify-content: flex-start;
2369
- `;
2370
-
2371
- // src/components/prompt-editor-with-variables/extensions/variable-tag.tsx
2372
- var VariableTagWidget = class extends import_view4.WidgetType {
2373
- constructor({ keyPath, scope }) {
2374
- super();
2375
- this.toDispose = new import_editor22.DisposableCollection();
2376
- this.renderIcon = (icon) => {
2377
- if (typeof icon === "string") {
2378
- return /* @__PURE__ */ import_react39.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2379
- }
2380
- return icon;
2381
- };
2382
- this.keyPath = keyPath;
2383
- this.scope = scope;
2384
- }
2385
- renderReact(jsx) {
2386
- import_react_dom.default.render(jsx, this.rootDOM);
2387
- }
2388
- renderVariable(v) {
2389
- if (!v) {
2390
- this.renderReact(
2391
- /* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: /* @__PURE__ */ import_react39.default.createElement(import_semi_icons7.IconIssueStroked, null), color: "amber" }, "Unknown")
2392
- );
2393
- return;
2394
- }
2395
- const rootField = (0, import_lodash4.last)(v.parentFields) || v;
2396
- const isRoot = v.parentFields.length === 0;
2397
- const rootTitle = /* @__PURE__ */ import_react39.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
2398
- const rootIcon = this.renderIcon(rootField?.meta.icon);
2399
- this.renderReact(
2400
- /* @__PURE__ */ import_react39.default.createElement(
2401
- import_semi_ui17.Popover,
2402
- {
2403
- content: /* @__PURE__ */ import_react39.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react39.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
2404
- },
2405
- /* @__PURE__ */ import_react39.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react39.default.createElement(UIVarName2, null, v?.key))
2406
- )
2407
- );
2408
- }
2409
- toDOM(view) {
2410
- const dom = document.createElement("span");
2411
- this.rootDOM = dom;
2412
- this.toDispose.push(
2413
- import_editor22.Disposable.create(() => {
2414
- import_react_dom.default.unmountComponentAtNode(this.rootDOM);
2415
- })
2416
- );
2417
- this.toDispose.push(
2418
- this.scope.available.trackByKeyPath(
2419
- this.keyPath,
2420
- (v) => {
2421
- this.renderVariable(v);
2422
- },
2423
- { triggerOnInit: false }
2424
- )
2425
- );
2426
- this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
2427
- return dom;
2428
- }
2429
- eq(other) {
2430
- return (0, import_lodash4.isEqual)(this.keyPath, other.keyPath);
2431
- }
2432
- ignoreEvent() {
2433
- return false;
2434
- }
2435
- destroy(dom) {
2436
- this.toDispose.dispose();
2437
- }
2438
- };
2439
- function VariableTagInject() {
2440
- const injector = (0, import_react40.useInjector)();
2441
- const scope = (0, import_editor22.useCurrentScope)();
2442
- (0, import_react39.useLayoutEffect)(() => {
2443
- const atMatcher = new import_view4.MatchDecorator({
2444
- regexp: /\{\{([^\}]+)\}\}/g,
2445
- decoration: (match) => import_view4.Decoration.replace({
2446
- widget: new VariableTagWidget({
2447
- keyPath: match[1]?.split(".") ?? [],
2448
- scope
2449
- })
2450
- })
2451
- });
2452
- return injector.inject([
2453
- import_view4.ViewPlugin.fromClass(
2454
- class {
2455
- constructor(view) {
2456
- this.view = view;
2457
- this.decorations = atMatcher.createDeco(view);
2458
- }
2459
- update() {
2460
- this.decorations = atMatcher.createDeco(this.view);
2461
- }
2462
- },
2463
- {
2464
- decorations: (p) => p.decorations,
2465
- provide(p) {
2466
- return import_view4.EditorView.atomicRanges.of(
2467
- (view) => view.plugin(p)?.decorations ?? import_view4.Decoration.none
2468
- );
2469
- }
2470
- }
2471
- )
2472
- ]);
2473
- }, [injector]);
2474
- return null;
2475
- }
2476
-
2477
- // src/components/prompt-editor-with-variables/index.tsx
2478
- function PromptEditorWithVariables(props) {
2479
- return /* @__PURE__ */ import_react41.default.createElement(PromptEditor, { ...props }, /* @__PURE__ */ import_react41.default.createElement(VariableTree, null), /* @__PURE__ */ import_react41.default.createElement(VariableTagInject, null));
2480
- }
2481
-
2482
- // src/components/prompt-editor-with-inputs/index.tsx
2483
- var import_react45 = __toESM(require("react"));
2484
-
2485
- // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2486
- var import_react43 = __toESM(require("react"));
2487
- var import_semi_ui19 = require("@douyinfe/semi-ui");
2488
- var import_react44 = require("@coze-editor/editor/react");
2489
-
2490
- // src/components/prompt-editor-with-inputs/inputs-picker.tsx
2491
- var import_react42 = __toESM(require("react"));
2492
- var import_lodash5 = require("lodash");
2493
- var import_editor23 = require("@flowgram.ai/editor");
2494
- var import_semi_ui18 = require("@douyinfe/semi-ui");
2495
- function InputsPicker({
2496
- inputsValues,
2497
- onSelect
2498
- }) {
2499
- const available = (0, import_editor23.useScopeAvailable)();
2500
- const getArrayDrilldown = (type, depth = 1) => {
2501
- if (import_editor23.ASTMatch.isArray(type.items)) {
2502
- return getArrayDrilldown(type.items, depth + 1);
2503
- }
2504
- return { type: type.items, depth };
2505
- };
2506
- const renderVariable = (variable, keyPath) => {
2507
- let type = variable?.type;
2508
- let children;
2509
- if (import_editor23.ASTMatch.isObject(type)) {
2510
- children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
2511
- }
2512
- if (import_editor23.ASTMatch.isArray(type)) {
2513
- const drilldown = getArrayDrilldown(type);
2514
- if (import_editor23.ASTMatch.isObject(drilldown.type)) {
2515
- children = (drilldown.type.properties || []).map(
2516
- (_property) => renderVariable(_property, [
2517
- ...keyPath,
2518
- ...new Array(drilldown.depth).fill("[0]"),
2519
- _property.key
2520
- ])
2521
- ).filter(Boolean);
2522
- }
2523
- }
2524
- const key = keyPath.map((_key, idx) => _key === "[0]" || idx === 0 ? _key : `.${_key}`).join("");
2525
- return {
2526
- key,
2527
- label: (0, import_lodash5.last)(keyPath),
2528
- value: key,
2529
- children
2530
- };
2531
- };
2532
- const treeData = (0, import_react42.useMemo)(
2533
- () => Object.entries(inputsValues).map(([key, value]) => {
2534
- if (value?.type === "ref") {
2535
- const variable = available.getByKeyPath(value.content || []);
2536
- if (variable) {
2537
- return renderVariable(variable, [key]);
2538
- }
2539
- }
2540
- return {
2541
- key,
2542
- value: key,
2543
- label: key
2544
- };
2545
- }),
2546
- []
2547
- );
2548
- return /* @__PURE__ */ import_react42.default.createElement(import_semi_ui18.Tree, { treeData, onSelect: (v) => onSelect(v) });
2549
- }
2550
-
2551
- // src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx
2552
- function InputsTree({ inputsValues }) {
2553
- const [posKey, setPosKey] = (0, import_react43.useState)("");
2554
- const [visible, setVisible] = (0, import_react43.useState)(false);
2555
- const [position, setPosition] = (0, import_react43.useState)(-1);
2556
- const editor = (0, import_react44.useEditor)();
2557
- function insert(variablePath) {
2558
- const range = (0, import_react44.getCurrentMentionReplaceRange)(editor.$view.state);
2559
- if (!range) {
2560
- return;
2561
- }
2562
- editor.replaceText({
2563
- ...range,
2564
- text: "{{" + variablePath + "}}"
2565
- });
2566
- setVisible(false);
2567
- }
2568
- function handleOpenChange(e) {
2569
- setPosition(e.state.selection.main.head);
2570
- setVisible(e.value);
2571
- }
2572
- (0, import_react43.useEffect)(() => {
2573
- if (!editor) {
2574
- return;
2575
- }
2576
- }, [editor, visible]);
2577
- return /* @__PURE__ */ import_react43.default.createElement(import_react43.default.Fragment, null, /* @__PURE__ */ import_react43.default.createElement(import_react44.Mention, { triggerCharacters: ["{", "{}", "@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react43.default.createElement(
2578
- import_semi_ui19.Popover,
2579
- {
2580
- visible,
2581
- trigger: "custom",
2582
- position: "topLeft",
2583
- rePosKey: posKey,
2584
- content: /* @__PURE__ */ import_react43.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react43.default.createElement(
2585
- InputsPicker,
2586
- {
2587
- inputsValues,
2588
- onSelect: (v) => {
2589
- insert(v);
2590
- }
2591
- }
2592
- ))
2593
- },
2594
- /* @__PURE__ */ import_react43.default.createElement(
2595
- import_react44.PositionMirror,
2596
- {
2597
- position,
2598
- onChange: () => setPosKey(String(Math.random()))
2599
- }
2600
- )
2601
- ));
2602
- }
2603
-
2604
- // src/components/prompt-editor-with-inputs/index.tsx
2605
- function PromptEditorWithInputs({ inputsValues, ...restProps }) {
2606
- return /* @__PURE__ */ import_react45.default.createElement(PromptEditor, { ...restProps }, /* @__PURE__ */ import_react45.default.createElement(InputsTree, { inputsValues }));
2607
- }
2608
-
2609
- // src/components/json-editor-with-variables/index.tsx
2610
- var import_react50 = __toESM(require("react"));
2611
- var import_preset_code6 = require("@coze-editor/editor/preset-code");
2612
-
2613
- // src/components/json-editor-with-variables/extensions/variable-tree.tsx
2614
- var import_react46 = __toESM(require("react"));
2615
- var import_semi_ui20 = require("@douyinfe/semi-ui");
2616
- var import_react47 = require("@coze-editor/editor/react");
2617
- function VariableTree2() {
2618
- const [posKey, setPosKey] = (0, import_react46.useState)("");
2619
- const [visible, setVisible] = (0, import_react46.useState)(false);
2620
- const [position, setPosition] = (0, import_react46.useState)(-1);
2621
- const editor = (0, import_react47.useEditor)();
2622
- function insert(variablePath) {
2623
- const range = (0, import_react47.getCurrentMentionReplaceRange)(editor.$view.state);
2624
- if (!range) {
2625
- return;
2626
- }
2627
- editor.replaceText({
2628
- ...range,
2629
- text: "{{" + variablePath + "}}"
2630
- });
2631
- setVisible(false);
2632
- }
2633
- function handleOpenChange(e) {
2634
- setPosition(e.state.selection.main.head);
2635
- setVisible(e.value);
2636
- }
2637
- (0, import_react46.useEffect)(() => {
2638
- if (!editor) {
2639
- return;
2640
- }
2641
- }, [editor, visible]);
2642
- const treeData = useVariableTree({});
2643
- return /* @__PURE__ */ import_react46.default.createElement(import_react46.default.Fragment, null, /* @__PURE__ */ import_react46.default.createElement(import_react47.Mention, { triggerCharacters: ["@"], onOpenChange: handleOpenChange }), /* @__PURE__ */ import_react46.default.createElement(
2644
- import_semi_ui20.Popover,
2645
- {
2646
- visible,
2647
- trigger: "custom",
2648
- position: "topLeft",
2649
- rePosKey: posKey,
2650
- content: /* @__PURE__ */ import_react46.default.createElement("div", { style: { width: 300 } }, /* @__PURE__ */ import_react46.default.createElement(
2651
- import_semi_ui20.Tree,
2652
- {
2653
- treeData,
2654
- onSelect: (v) => {
2655
- insert(v);
2656
- }
2657
- }
2658
- ))
2659
- },
2660
- /* @__PURE__ */ import_react46.default.createElement(
2661
- import_react47.PositionMirror,
2662
- {
2663
- position,
2664
- onChange: () => setPosKey(String(Math.random()))
2665
- }
2666
- )
2667
- ));
2668
- }
2669
-
2670
- // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2671
- var import_react48 = __toESM(require("react"));
2672
- var import_client = require("react-dom/client");
2673
- var import_lodash6 = require("lodash");
2674
- var import_editor24 = require("@flowgram.ai/editor");
2675
- var import_semi_ui22 = require("@douyinfe/semi-ui");
2676
- var import_semi_icons8 = require("@douyinfe/semi-icons");
2677
- var import_react49 = require("@coze-editor/editor/react");
2678
- var import_view5 = require("@codemirror/view");
2679
-
2680
- // src/components/json-editor-with-variables/styles.tsx
2681
- var import_styled_components9 = __toESM(require("styled-components"));
2682
- var import_semi_ui21 = require("@douyinfe/semi-ui");
2683
- var UIRootTitle3 = import_styled_components9.default.div`
2684
- margin-right: 4px;
2685
- min-width: 20px;
2686
- overflow: hidden;
2687
- text-overflow: ellipsis;
2688
- white-space: nowrap;
2689
- color: var(--semi-color-text-2);
2690
- `;
2691
- var UIVarName3 = import_styled_components9.default.div`
2692
- overflow: hidden;
2693
- text-overflow: ellipsis;
2694
- white-space: nowrap;
2695
- `;
2696
- var UITag3 = (0, import_styled_components9.default)(import_semi_ui21.Tag)`
2697
- display: inline-flex;
2698
- align-items: center;
2699
- justify-content: flex-start;
2700
- max-width: 300px;
2701
-
2702
- & .semi-tag-content-center {
2703
- justify-content: flex-start;
2704
- }
2705
-
2706
- &.semi-tag {
2707
- margin: 0 5px;
2708
- }
2709
- `;
2710
- var UIPopoverContent3 = import_styled_components9.default.div`
2711
- padding: 10px;
2712
- display: inline-flex;
2713
- align-items: center;
2714
- justify-content: flex-start;
2715
- `;
2716
-
2717
- // src/components/json-editor-with-variables/extensions/variable-tag.tsx
2718
- var VariableTagWidget2 = class extends import_view5.WidgetType {
2719
- constructor({ keyPath, scope }) {
2720
- super();
2721
- this.toDispose = new import_editor24.DisposableCollection();
2722
- this.renderIcon = (icon) => {
2723
- if (typeof icon === "string") {
2724
- return /* @__PURE__ */ import_react48.default.createElement("img", { style: { marginRight: 8 }, width: 12, height: 12, src: icon });
2725
- }
2726
- return icon;
2727
- };
2728
- this.keyPath = keyPath;
2729
- this.scope = scope;
2730
- }
2731
- renderVariable(v) {
2732
- if (!v) {
2733
- this.root.render(
2734
- /* @__PURE__ */ import_react48.default.createElement(UITag3, { prefixIcon: /* @__PURE__ */ import_react48.default.createElement(import_semi_icons8.IconIssueStroked, null), color: "amber" }, "Unknown")
2735
- );
2736
- return;
2737
- }
2738
- const rootField = (0, import_lodash6.last)(v.parentFields);
2739
- const rootTitle = /* @__PURE__ */ import_react48.default.createElement(UIRootTitle3, null, rootField?.meta.title ? `${rootField.meta.title} -` : "");
2740
- const rootIcon = this.renderIcon(rootField?.meta.icon);
2741
- this.root.render(
2742
- /* @__PURE__ */ import_react48.default.createElement(
2743
- import_semi_ui22.Popover,
2744
- {
2745
- content: /* @__PURE__ */ import_react48.default.createElement(UIPopoverContent3, null, rootIcon, rootTitle, /* @__PURE__ */ import_react48.default.createElement(UIVarName3, null, v?.keyPath.slice(1).join(".")))
2746
- },
2747
- /* @__PURE__ */ import_react48.default.createElement(UITag3, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react48.default.createElement(UIVarName3, null, v?.key))
2748
- )
2749
- );
2750
- }
2751
- toDOM(view) {
2752
- const dom = document.createElement("span");
2753
- this.root = (0, import_client.createRoot)(dom);
2754
- this.toDispose.push(
2755
- import_editor24.Disposable.create(() => {
2756
- this.root.unmount();
2757
- })
2758
- );
2759
- this.toDispose.push(
2760
- this.scope.available.trackByKeyPath(
2761
- this.keyPath,
2762
- (v) => {
2763
- this.renderVariable(v);
2764
- },
2765
- { triggerOnInit: false }
2766
- )
2767
- );
2768
- this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
2769
- return dom;
2770
- }
2771
- eq(other) {
2772
- return (0, import_lodash6.isEqual)(this.keyPath, other.keyPath);
2773
- }
2774
- ignoreEvent() {
2775
- return false;
2776
- }
2777
- destroy(dom) {
2778
- this.toDispose.dispose();
2779
- }
2780
- };
2781
- function VariableTagInject2() {
2782
- const injector = (0, import_react49.useInjector)();
2783
- const scope = (0, import_editor24.useCurrentScope)();
2784
- (0, import_react48.useLayoutEffect)(() => {
2785
- const atMatcher = new import_view5.MatchDecorator({
2786
- regexp: /\{\{([^\}]+)\}\}/g,
2787
- decoration: (match) => import_view5.Decoration.replace({
2788
- widget: new VariableTagWidget2({
2789
- keyPath: match[1]?.split(".") ?? [],
2790
- scope
2791
- })
2792
- })
2793
- });
2794
- return injector.inject([
2795
- import_view5.ViewPlugin.fromClass(
2796
- class {
2797
- constructor(view) {
2798
- this.view = view;
2799
- this.decorations = atMatcher.createDeco(view);
2800
- }
2801
- update() {
2802
- this.decorations = atMatcher.createDeco(this.view);
2803
- }
2804
- },
2805
- {
2806
- decorations: (p) => p.decorations,
2807
- provide(p) {
2808
- return import_view5.EditorView.atomicRanges.of(
2809
- (view) => view.plugin(p)?.decorations ?? import_view5.Decoration.none
2810
- );
2811
- }
2812
- }
2813
- )
2814
- ]);
2815
- }, [injector]);
2816
- return null;
2817
- }
2818
-
2819
- // src/components/json-editor-with-variables/index.tsx
2820
- function findAllMatches(inputString, regex) {
2821
- const globalRegex = new RegExp(
2822
- regex,
2823
- regex.flags.includes("g") ? regex.flags : regex.flags + "g"
2824
- );
2825
- let match;
2826
- const matches = [];
2827
- while ((match = globalRegex.exec(inputString)) !== null) {
2828
- if (match.index === globalRegex.lastIndex) {
2829
- globalRegex.lastIndex++;
2830
- }
2831
- matches.push({
2832
- match: match[0],
2833
- range: [match.index, match.index + match[0].length]
2834
- });
2835
- }
2836
- return matches;
2837
- }
2838
- var transformer = (0, import_preset_code6.transformerCreator)((text) => {
2839
- const originalSource = text.toString();
2840
- const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
2841
- if (matches.length > 0) {
2842
- matches.forEach(({ range }) => {
2843
- text.replaceRange(range[0], range[1], "null");
2844
- });
2845
- }
2846
- return text;
2847
- });
2848
- function JsonEditorWithVariables(props) {
2849
- return /* @__PURE__ */ import_react50.default.createElement(
2850
- CodeEditor,
2851
- {
2852
- languageId: "json",
2853
- activeLinePlaceholder: "Press '@' to Select variable",
2854
- ...props,
2855
- options: {
2856
- transformer,
2857
- ...props.options || {}
2858
- }
2859
- },
2860
- /* @__PURE__ */ import_react50.default.createElement(VariableTree2, null),
2861
- /* @__PURE__ */ import_react50.default.createElement(VariableTagInject2, null)
2862
- );
2863
- }
2864
-
2865
- // src/components/inputs-values/index.tsx
2866
- var import_react52 = __toESM(require("react"));
2867
- var import_editor25 = require("@flowgram.ai/editor");
2868
- var import_semi_ui23 = require("@douyinfe/semi-ui");
2869
- var import_semi_icons9 = require("@douyinfe/semi-icons");
2870
-
2871
- // src/components/inputs-values/styles.tsx
2872
- var import_styled_components10 = __toESM(require("styled-components"));
2873
- var UIRows2 = import_styled_components10.default.div`
2874
- display: flex;
2875
- flex-direction: column;
2876
- gap: 10px;
2877
- margin-bottom: 10px;
2878
- `;
2879
- var UIRow3 = import_styled_components10.default.div`
2880
- display: flex;
2881
- align-items: center;
2882
- gap: 5px;
2883
- `;
2884
-
2885
- // src/components/inputs-values/components/blur-input.tsx
2886
- var import_react51 = __toESM(require("react"));
2887
- var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
2888
- function BlurInput2(props) {
2889
- const [value, setValue] = (0, import_react51.useState)("");
2890
- (0, import_react51.useEffect)(() => {
2891
- setValue(props.value);
2892
- }, [props.value]);
2893
- return /* @__PURE__ */ import_react51.default.createElement(
2894
- import_input2.default,
2895
- {
2896
- ...props,
2897
- value,
2898
- onChange: (value2) => {
2899
- setValue(value2);
2900
- },
2901
- onBlur: (e) => props.onChange?.(value, e)
2902
- }
2903
- );
2904
- }
2905
-
2906
- // src/components/inputs-values/index.tsx
2907
- function InputsValues({
2908
- value,
2909
- onChange,
2910
- style,
2911
- readonly,
2912
- constantProps,
2913
- schema,
2914
- hasError
2915
- }) {
2916
- const { list, updateKey, updateValue, remove, add } = useObjectList({
2917
- value,
2918
- onChange,
2919
- sortIndexKey: "extra.index"
2920
- });
2921
- return /* @__PURE__ */ import_react52.default.createElement("div", null, /* @__PURE__ */ import_react52.default.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ import_react52.default.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ import_react52.default.createElement(
2922
- BlurInput2,
2923
- {
2924
- style: { width: 100, minWidth: 100, maxWidth: 100 },
2925
- disabled: readonly,
2926
- size: "small",
2927
- value: item.key,
2928
- onChange: (v) => updateKey(item.id, v),
2929
- placeholder: import_editor25.I18n.t("Input Key")
2930
- }
2931
- ), /* @__PURE__ */ import_react52.default.createElement(
2932
- InjectDynamicValueInput,
2933
- {
2934
- style: { flexGrow: 1 },
2935
- readonly,
2936
- value: item.value,
2937
- onChange: (v) => updateValue(item.id, v),
2938
- schema,
2939
- hasError,
2940
- constantProps: {
2941
- ...constantProps,
2942
- strategies: [...constantProps?.strategies || []]
2943
- }
2944
- }
2945
- ), /* @__PURE__ */ import_react52.default.createElement(
2946
- import_semi_ui23.IconButton,
2947
- {
2948
- disabled: readonly,
2949
- theme: "borderless",
2950
- icon: /* @__PURE__ */ import_react52.default.createElement(import_semi_icons9.IconDelete, { size: "small" }),
2951
- size: "small",
2952
- onClick: () => remove(item.id)
2953
- }
2954
- )))), /* @__PURE__ */ import_react52.default.createElement(import_semi_ui23.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react52.default.createElement(import_semi_icons9.IconPlus, null), size: "small", onClick: add }, "Add"));
2955
- }
2956
-
2957
- // src/components/display-schema-tree/index.tsx
2958
- var import_react53 = __toESM(require("react"));
2959
-
2960
- // src/components/display-schema-tree/styles.tsx
2961
- var import_styled_components11 = __toESM(require("styled-components"));
2962
- var TreeRow = import_styled_components11.default.div`
2963
- display: flex;
2964
- align-items: center;
2965
-
2966
- .tree-icon {
2967
- margin-right: 8px;
2968
- width: 14px;
2969
- height: 14px;
2970
- }
2971
-
2972
- height: 27px;
2973
- white-space: nowrap;
2974
- `;
2975
- var HorizontalLine = import_styled_components11.default.div`
2976
- position: relative;
2977
-
2978
- &::before,
2979
- &::after {
2980
- content: '';
2981
- position: absolute;
2982
- background-color: var(--semi-color-text-3);
2983
- }
2984
-
2985
- &::after {
2986
- top: 0px;
2987
- right: 6px;
2988
- width: 15px;
2989
- height: 1px;
2990
- }
2991
- `;
2992
- var TreeTitle = import_styled_components11.default.div`
2993
- // overflow: hidden;
2994
- // text-overflow: ellipsis;
2995
- `;
2996
- var TreeLevel = import_styled_components11.default.div`
2997
- padding-left: 30px;
2998
- position: relative;
2999
-
3000
- /* &::before {
3001
- content: '';
3002
- position: absolute;
3003
- background-color: var(--semi-color-text-3);
3004
- top: 0px;
3005
- bottom: 0px;
3006
- left: -22px;
3007
- width: 1px;
3008
- } */
3009
- `;
3010
- var TreeItem = import_styled_components11.default.div`
3011
- position: relative;
3012
-
3013
- &::before {
3014
- content: '';
3015
- position: absolute;
3016
- background-color: var(--semi-color-text-3);
3017
- }
3018
-
3019
- &:not(:last-child)::before {
3020
- width: 1px;
3021
- top: 0;
3022
- bottom: 0;
3023
- left: -22px;
3024
- }
3025
-
3026
- &:last-child::before {
3027
- width: 1px;
3028
- top: 0;
3029
- height: 14px;
3030
- left: -22px;
3031
- }
3032
-
3033
- ${(props) => props.depth === 0 && import_styled_components11.css`
3034
- &::before {
3035
- width: 0px !important;
3036
- }
3037
- `}
3038
- `;
3039
-
3040
- // src/components/display-schema-tree/index.tsx
3041
- function DisplaySchemaTree(props) {
3042
- return /* @__PURE__ */ import_react53.default.createElement(SchemaTree, { ...props });
3043
- }
3044
- function SchemaTree(props) {
3045
- const {
3046
- value: schema = {},
3047
- drilldown = true,
3048
- depth = 0,
3049
- showIcon = true,
3050
- parentKey = ""
3051
- } = props || {};
3052
- const typeManager = useTypeManager();
3053
- const config = typeManager.getTypeBySchema(schema);
3054
- const title = typeManager.getComplexText(schema);
3055
- const icon = typeManager?.getDisplayIcon(schema);
3056
- let properties = drilldown && config ? config.getTypeSchemaProperties(schema) : {};
3057
- const childEntries = Object.entries(properties || {});
3058
- return /* @__PURE__ */ import_react53.default.createElement(TreeItem, { depth, key: parentKey || "root" }, /* @__PURE__ */ import_react53.default.createElement(TreeRow, null, depth !== 0 && /* @__PURE__ */ import_react53.default.createElement(HorizontalLine, null), showIcon && icon && import_react53.default.cloneElement(icon, {
3059
- className: "tree-icon"
3060
- }), /* @__PURE__ */ import_react53.default.createElement(TreeTitle, null, parentKey ? /* @__PURE__ */ import_react53.default.createElement(import_react53.default.Fragment, null, `${parentKey} (`, title, ")") : title)), childEntries?.length ? /* @__PURE__ */ import_react53.default.createElement(TreeLevel, null, childEntries.map(([key, value]) => /* @__PURE__ */ import_react53.default.createElement(SchemaTree, { key, ...props, parentKey: key, value, depth: depth + 1 }))) : null);
3061
- }
3062
-
3063
- // src/components/display-outputs/index.tsx
3064
- var import_react55 = __toESM(require("react"));
3065
- var import_json_schema8 = require("@flowgram.ai/json-schema");
3066
- var import_editor26 = require("@flowgram.ai/editor");
3067
-
3068
- // src/components/display-schema-tag/index.tsx
3069
- var import_react54 = __toESM(require("react"));
3070
- var import_semi_ui25 = require("@douyinfe/semi-ui");
3071
-
3072
- // src/components/display-schema-tag/styles.ts
3073
- var import_styled_components12 = __toESM(require("styled-components"));
3074
- var import_semi_ui24 = require("@douyinfe/semi-ui");
3075
- var PopoverContent = import_styled_components12.default.div`
3076
- padding: 10px;
3077
- `;
3078
- var StyledTag = (0, import_styled_components12.default)(import_semi_ui24.Tag)`
3079
- padding: 4px;
3080
-
3081
- .tag-icon {
3082
- width: 12px;
3083
- height: 12px;
3084
- }
3085
- `;
3086
- var TitleSpan = import_styled_components12.default.span`
3087
- display: inline-block;
3088
- margin-left: 4px;
3089
- margin-top: -1px;
3090
- overflow: hidden;
3091
- text-overflow: ellipsis;
3092
- `;
3093
-
3094
- // src/components/display-schema-tag/index.tsx
3095
- function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }) {
3096
- const typeManager = useTypeManager();
3097
- const icon = typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: "unknown" });
3098
- return /* @__PURE__ */ import_react54.default.createElement(
3099
- import_semi_ui25.Popover,
3100
- {
3101
- content: /* @__PURE__ */ import_react54.default.createElement(PopoverContent, null, /* @__PURE__ */ import_react54.default.createElement(DisplaySchemaTree, { value, typeManager, showIcon: showIconInTree }))
3102
- },
3103
- /* @__PURE__ */ import_react54.default.createElement(StyledTag, { color: warning ? "amber" : "white" }, icon && import_react54.default.cloneElement(icon, {
3104
- className: "tag-icon"
3105
- }), title && /* @__PURE__ */ import_react54.default.createElement(TitleSpan, null, title))
3106
- );
3107
- }
3108
-
3109
- // src/components/display-outputs/styles.ts
3110
- var import_styled_components13 = __toESM(require("styled-components"));
3111
- var DisplayOutputsWrapper = import_styled_components13.default.div`
3112
- display: flex;
3113
- gap: 5px;
3114
- flex-wrap: wrap;
3115
- `;
3116
-
3117
- // src/components/display-outputs/index.tsx
3118
- function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
3119
- const scope = (0, import_editor26.useCurrentScope)();
3120
- const refresh = (0, import_editor26.useRefresh)();
3121
- (0, import_react55.useEffect)(() => {
3122
- if (!displayFromScope) {
3123
- return () => null;
3124
- }
3125
- const disposable = scope.output.onListOrAnyVarChange(() => {
3126
- refresh();
3127
- });
3128
- return () => {
3129
- disposable.dispose();
3130
- };
3131
- }, [displayFromScope]);
3132
- const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr) => {
3133
- acm = {
3134
- ...acm,
3135
- ...import_json_schema8.JsonSchemaUtils.astToSchema(curr.type)?.properties || {}
3136
- };
3137
- return acm;
3138
- }, {}) : value?.properties || {};
3139
- const childEntries = Object.entries(properties || {});
3140
- return /* @__PURE__ */ import_react55.default.createElement(DisplayOutputsWrapper, null, childEntries.map(([key, schema]) => /* @__PURE__ */ import_react55.default.createElement(
3141
- DisplaySchemaTag,
3142
- {
3143
- key,
3144
- title: key,
3145
- value: schema,
3146
- showIconInTree,
3147
- warning: !schema
3148
- }
3149
- )));
3150
- }
3151
-
3152
- // src/components/display-flow-value/index.tsx
3153
- var import_react56 = __toESM(require("react"));
3154
- var import_json_schema9 = require("@flowgram.ai/json-schema");
3155
- var import_editor27 = require("@flowgram.ai/editor");
3156
- function DisplayFlowValue({ value, title, showIconInTree }) {
3157
- const available = (0, import_editor27.useScopeAvailable)();
3158
- const variable = value?.type === "ref" ? available.getByKeyPath(value?.content) : void 0;
3159
- const schema = (0, import_react56.useMemo)(() => {
3160
- if (value?.type === "ref") {
3161
- return import_json_schema9.JsonSchemaUtils.astToSchema(variable?.type);
3162
- }
3163
- if (value?.type === "template") {
3164
- return { type: "string" };
3165
- }
3166
- if (value?.type === "constant") {
3167
- if (value?.schema) {
3168
- return value?.schema;
3169
- }
3170
- if (typeof value?.content === "string") {
3171
- return { type: "string" };
3172
- }
3173
- if (typeof value?.content === "number") {
3174
- return { type: "number" };
3175
- }
3176
- if (typeof value?.content === "boolean") {
3177
- return { type: "boolean" };
3178
- }
3179
- }
3180
- return { type: "unknown" };
3181
- }, [value, variable?.hash]);
3182
- return /* @__PURE__ */ import_react56.default.createElement(
3183
- DisplaySchemaTag,
3184
- {
3185
- title,
3186
- value: schema,
3187
- showIconInTree,
3188
- warning: value?.type === "ref" && !variable
3189
- }
3190
- );
3191
- }
3192
-
3193
- // src/components/display-inputs-values/index.tsx
3194
- var import_react57 = __toESM(require("react"));
3195
-
3196
- // src/components/display-inputs-values/styles.ts
3197
- var import_styled_components14 = __toESM(require("styled-components"));
3198
- var DisplayInputsWrapper = import_styled_components14.default.div`
3199
- display: flex;
3200
- gap: 5px;
3201
- flex-wrap: wrap;
3202
- `;
3203
-
3204
- // src/components/display-inputs-values/index.tsx
3205
- function DisplayInputsValues({ value, showIconInTree }) {
3206
- const childEntries = Object.entries(value || {});
3207
- return /* @__PURE__ */ import_react57.default.createElement(DisplayInputsWrapper, null, childEntries.map(([key, value2]) => /* @__PURE__ */ import_react57.default.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree })));
3208
- }
3209
-
3210
- // src/components/assign-rows/index.tsx
3211
- var import_react60 = __toESM(require("react"));
3212
- var import_editor28 = require("@flowgram.ai/editor");
3213
- var import_semi_ui27 = require("@douyinfe/semi-ui");
3214
- var import_semi_icons11 = require("@douyinfe/semi-icons");
3215
-
3216
- // src/components/assign-row/index.tsx
3217
- var import_react59 = __toESM(require("react"));
3218
- var import_semi_ui26 = require("@douyinfe/semi-ui");
3219
- var import_semi_icons10 = require("@douyinfe/semi-icons");
3220
-
3221
- // src/components/assign-row/components/blur-input.tsx
3222
- var import_react58 = __toESM(require("react"));
3223
- var import_input3 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
3224
- function BlurInput3(props) {
3225
- const [value, setValue] = (0, import_react58.useState)("");
3226
- (0, import_react58.useEffect)(() => {
3227
- setValue(props.value);
3228
- }, [props.value]);
3229
- return /* @__PURE__ */ import_react58.default.createElement(
3230
- import_input3.default,
3231
- {
3232
- ...props,
3233
- value,
3234
- onChange: (value2) => {
3235
- setValue(value2);
3236
- },
3237
- onBlur: (e) => props.onChange?.(value, e)
3238
- }
3239
- );
3240
- }
3241
-
3242
- // src/components/assign-row/index.tsx
3243
- function AssignRow(props) {
3244
- const {
3245
- value = {
3246
- operator: "assign"
3247
- },
3248
- onChange,
3249
- onDelete,
3250
- readonly
3251
- } = props;
3252
- return /* @__PURE__ */ import_react59.default.createElement("div", { style: { display: "flex", alignItems: "center", gap: 5 } }, /* @__PURE__ */ import_react59.default.createElement("div", { style: { width: 150, minWidth: 150, maxWidth: 150 } }, value?.operator === "assign" ? /* @__PURE__ */ import_react59.default.createElement(
3253
- InjectVariableSelector,
3254
- {
3255
- style: { width: "100%", height: 26 },
3256
- value: value?.left?.content,
3257
- config: { placeholder: "Select Left" },
3258
- onChange: (v) => onChange?.({
3259
- ...value,
3260
- left: { type: "ref", content: v }
3261
- })
3262
- }
3263
- ) : /* @__PURE__ */ import_react59.default.createElement(
3264
- BlurInput3,
3265
- {
3266
- style: { height: 26 },
3267
- size: "small",
3268
- placeholder: "Input Name",
3269
- value: value?.left,
3270
- onChange: (v) => onChange?.({
3271
- ...value,
3272
- left: v
3273
- })
3274
- }
3275
- )), /* @__PURE__ */ import_react59.default.createElement("div", { style: { flexGrow: 1 } }, /* @__PURE__ */ import_react59.default.createElement(
3276
- InjectDynamicValueInput,
3277
- {
3278
- readonly,
3279
- value: value?.right,
3280
- onChange: (v) => onChange?.({
3281
- ...value,
3282
- right: v
3283
- })
3284
- }
3285
- )), onDelete && /* @__PURE__ */ import_react59.default.createElement("div", null, /* @__PURE__ */ import_react59.default.createElement(
3286
- import_semi_ui26.IconButton,
3287
- {
3288
- size: "small",
3289
- theme: "borderless",
3290
- icon: /* @__PURE__ */ import_react59.default.createElement(import_semi_icons10.IconMinus, null),
3291
- onClick: () => onDelete?.()
3292
- }
3293
- )));
3294
- }
3295
-
3296
- // src/components/assign-rows/index.tsx
3297
- function AssignRows(props) {
3298
- const { name, readonly } = props;
3299
- return /* @__PURE__ */ import_react60.default.createElement(import_editor28.FieldArray, { name }, ({ field }) => /* @__PURE__ */ import_react60.default.createElement(import_react60.default.Fragment, null, field.map((childField, index) => /* @__PURE__ */ import_react60.default.createElement(
3300
- AssignRow,
3301
- {
3302
- key: childField.key,
3303
- readonly,
3304
- value: childField.value,
3305
- onChange: (value) => {
3306
- childField.onChange(value);
3307
- },
3308
- onDelete: () => field.remove(index)
3309
- }
3310
- )), /* @__PURE__ */ import_react60.default.createElement("div", { style: { display: "flex", gap: 5 } }, /* @__PURE__ */ import_react60.default.createElement(
3311
- import_semi_ui27.Button,
3312
- {
3313
- size: "small",
3314
- theme: "borderless",
3315
- icon: /* @__PURE__ */ import_react60.default.createElement(import_semi_icons11.IconPlus, null),
3316
- onClick: () => field.append({ operator: "assign" })
3317
- },
3318
- "Assign"
3319
- ), /* @__PURE__ */ import_react60.default.createElement(
3320
- import_semi_ui27.Button,
3321
- {
3322
- size: "small",
3323
- theme: "borderless",
3324
- icon: /* @__PURE__ */ import_react60.default.createElement(import_semi_icons11.IconPlus, null),
3325
- onClick: () => field.append({ operator: "declare" })
3326
- },
3327
- "Declaration"
3328
- ))));
3329
- }
3330
-
3331
- // src/effects/provide-batch-input/index.ts
3332
- var import_editor29 = require("@flowgram.ai/editor");
3333
- var provideBatchInputEffect = (0, import_editor29.createEffectFromVariableProvider)({
3334
- private: true,
3335
- parse: (value, ctx) => [
3336
- import_editor29.ASTFactory.createVariableDeclaration({
3337
- key: `${ctx.node.id}_locals`,
3338
- meta: {
3339
- title: (0, import_editor29.getNodeForm)(ctx.node)?.getValueIn("title"),
3340
- icon: ctx.node.getNodeRegistry().info?.icon
3341
- },
3342
- type: import_editor29.ASTFactory.createObject({
3343
- properties: [
3344
- import_editor29.ASTFactory.createProperty({
3345
- key: "item",
3346
- initializer: import_editor29.ASTFactory.createEnumerateExpression({
3347
- enumerateFor: import_editor29.ASTFactory.createKeyPathExpression({
3348
- keyPath: value.content || []
3349
- })
3350
- })
3351
- }),
3352
- import_editor29.ASTFactory.createProperty({
3353
- key: "index",
3354
- type: import_editor29.ASTFactory.createNumber()
3355
- })
3356
- ]
3357
- })
3358
- })
3359
- ]
3360
- });
3361
-
3362
- // src/effects/auto-rename-ref/index.ts
3363
- var import_lodash7 = require("lodash");
3364
- var import_editor30 = require("@flowgram.ai/editor");
3365
- var autoRenameRefEffect = [
3366
- {
3367
- event: import_editor30.DataEvent.onValueInit,
3368
- effect: (params) => {
3369
- const { context, form, name } = params;
3370
- const renameService = context.node.getService(import_editor30.VariableFieldKeyRenameService);
3371
- const disposable = renameService.onRename(({ before, after }) => {
3372
- const beforeKeyPath = [
3373
- ...before.parentFields.map((_field) => _field.key).reverse(),
3374
- before.key
3375
- ];
3376
- const afterKeyPath = [
3377
- ...after.parentFields.map((_field) => _field.key).reverse(),
3378
- after.key
3379
- ];
3380
- traverseRef(name, form.getValueIn(name), (_drilldownName, _v) => {
3381
- if (_v.type === "ref") {
3382
- if (isKeyPathMatch(_v.content, beforeKeyPath)) {
3383
- _v.content = [...afterKeyPath, ...(_v.content || [])?.slice(beforeKeyPath.length)];
3384
- form.setValueIn(_drilldownName, _v);
3385
- }
3386
- } else if (_v.type === "template") {
3387
- const templateKeyPaths = getTemplateKeyPaths(_v);
3388
- let hasMatch = false;
3389
- templateKeyPaths.forEach((_keyPath) => {
3390
- if (isKeyPathMatch(_keyPath, beforeKeyPath)) {
3391
- hasMatch = true;
3392
- const nextKeyPath = [
3393
- ...afterKeyPath,
3394
- ...(_keyPath || [])?.slice(beforeKeyPath.length)
3395
- ];
3396
- _v.content = _v.content?.replace(
3397
- `{{${_keyPath.join(".")}}`,
3398
- `{{${nextKeyPath.join(".")}}`
3399
- );
3400
- }
3401
- });
3402
- if (hasMatch) {
3403
- form.setValueIn(_drilldownName, { ..._v });
3404
- }
3405
- }
3406
- });
3407
- });
3408
- return () => {
3409
- disposable.dispose();
3410
- };
3411
- }
3412
- }
3413
- ];
3414
- function isKeyPathMatch(keyPath = [], targetKeyPath) {
3415
- return targetKeyPath.every((_key, index) => _key === keyPath[index]);
3416
- }
3417
- function getTemplateKeyPaths(value) {
3418
- const keyPathReg = /{{(.*?)}}/g;
3419
- return (0, import_lodash7.uniq)(value.content?.match(keyPathReg) || []).map(
3420
- (_keyPath) => _keyPath.slice(2, -2).split(".")
3421
- );
3422
- }
3423
- function isRef(value) {
3424
- return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3425
- }
3426
- function isTemplate(value) {
3427
- return value?.type === "template" && typeof value?.content === "string";
3428
- }
3429
- function traverseRef(name, value, cb) {
3430
- if ((0, import_lodash7.isObject)(value)) {
3431
- if (isRef(value)) {
3432
- cb(name, value);
3433
- return;
3434
- }
3435
- if (isTemplate(value)) {
3436
- cb(name, value);
3437
- return;
3438
- }
3439
- Object.entries(value).forEach(([_key, _value]) => {
3440
- traverseRef(`${name}.${_key}`, _value, cb);
3441
- });
3442
- return;
3443
- }
3444
- if ((0, import_lodash7.isArray)(value)) {
3445
- value.forEach((_value, idx) => {
3446
- traverseRef(`${name}[${idx}]`, _value, cb);
3447
- });
3448
- return;
3449
- }
3450
- return;
3451
- }
3452
-
3453
- // src/effects/provide-json-schema-outputs/index.ts
3454
- var import_json_schema10 = require("@flowgram.ai/json-schema");
3455
- var import_editor31 = require("@flowgram.ai/editor");
3456
- var provideJsonSchemaOutputs = (0, import_editor31.createEffectFromVariableProvider)({
3457
- parse: (value, ctx) => [
3458
- import_editor31.ASTFactory.createVariableDeclaration({
3459
- key: `${ctx.node.id}`,
3460
- meta: {
3461
- title: (0, import_editor31.getNodeForm)(ctx.node)?.getValueIn("title") || ctx.node.id,
3462
- icon: ctx.node.getNodeRegistry().info?.icon
3463
- },
3464
- type: import_json_schema10.JsonSchemaUtils.schemaToAST(value)
3465
- })
3466
- ]
3467
- });
3468
-
3469
- // src/effects/sync-variable-title/index.ts
3470
- var import_editor32 = require("@flowgram.ai/editor");
3471
- var syncVariableTitle = [
3472
- {
3473
- event: import_editor32.DataEvent.onValueChange,
3474
- effect: ({ value, context }) => {
3475
- context.node.getData(import_editor32.FlowNodeVariableData).allScopes.forEach((_scope) => {
3476
- _scope.output.variables.forEach((_var) => {
3477
- _var.updateMeta({
3478
- ..._var.meta || {},
3479
- title: value || context.node.id,
3480
- icon: context.node.getNodeRegistry().info?.icon
3481
- });
3482
- });
3483
- });
3484
- }
3485
- }
3486
- ];
3487
-
3488
- // src/effects/validate-when-variable-sync/index.ts
3489
- var import_lodash8 = require("lodash");
3490
- var import_editor33 = require("@flowgram.ai/editor");
3491
- var validateWhenVariableSync = ({
3492
- scope
3493
- } = {}) => [
3494
- {
3495
- event: import_editor33.DataEvent.onValueInit,
3496
- effect: ({ context, form }) => {
3497
- const nodeScope = scope === "private" ? (0, import_editor33.getNodePrivateScope)(context.node) : (0, import_editor33.getNodeScope)(context.node);
3498
- const disposable = nodeScope.available.onListOrAnyVarChange(() => {
3499
- if (!(0, import_lodash8.isEmpty)(form.state.errors)) {
3500
- form.validate();
3501
- }
3502
- });
3503
- return () => disposable.dispose();
3504
- }
3505
- }
3506
- ];
3507
-
3508
- // src/effects/listen-ref-value-change/index.ts
3509
- var import_editor34 = require("@flowgram.ai/editor");
3510
- var listenRefValueChange = (cb) => [
3511
- {
3512
- event: import_editor34.DataEvent.onValueInitOrChange,
3513
- effect: (params) => {
3514
- const { context, value } = params;
3515
- if (value?.type !== "ref") {
3516
- return () => null;
3517
- }
3518
- const disposable = (0, import_editor34.getNodeScope)(context.node).available.trackByKeyPath(
3519
- value?.content || [],
3520
- (v) => {
3521
- cb({ ...params, variable: v });
3522
- }
3523
- );
3524
- return () => {
3525
- disposable.dispose();
3526
- };
3527
- }
3528
- }
3529
- ];
3530
-
3531
- // src/effects/listen-ref-schema-change/index.ts
3532
- var import_json_schema11 = require("@flowgram.ai/json-schema");
3533
- var import_editor35 = require("@flowgram.ai/editor");
3534
- var listenRefSchemaChange = (cb) => [
3535
- {
3536
- event: import_editor35.DataEvent.onValueInitOrChange,
3537
- effect: (params) => {
3538
- const { context, value } = params;
3539
- if (value?.type !== "ref") {
3540
- return () => null;
3541
- }
3542
- const disposable = (0, import_editor35.getNodeScope)(context.node).available.trackByKeyPath(
3543
- value?.content || [],
3544
- (_type) => {
3545
- cb({ ...params, schema: import_json_schema11.JsonSchemaUtils.astToSchema(_type) });
3546
- },
3547
- {
3548
- selector: (_v) => _v?.type
3549
- }
3550
- );
3551
- return () => {
3552
- disposable.dispose();
3553
- };
3554
- }
3555
- }
3556
- ];
3557
-
3558
- // src/form-plugins/batch-outputs-plugin/index.ts
3559
- var import_editor36 = require("@flowgram.ai/editor");
3560
- var provideBatchOutputsEffect = (0, import_editor36.createEffectFromVariableProvider)({
3561
- parse: (value, ctx) => [
3562
- import_editor36.ASTFactory.createVariableDeclaration({
3563
- key: `${ctx.node.id}`,
3564
- meta: {
3565
- title: (0, import_editor36.getNodeForm)(ctx.node)?.getValueIn("title"),
3566
- icon: ctx.node.getNodeRegistry().info?.icon
3567
- },
3568
- type: import_editor36.ASTFactory.createObject({
3569
- properties: Object.entries(value).map(
3570
- ([_key, value2]) => import_editor36.ASTFactory.createProperty({
3571
- key: _key,
3572
- initializer: import_editor36.ASTFactory.createWrapArrayExpression({
3573
- wrapFor: import_editor36.ASTFactory.createKeyPathExpression({
3574
- keyPath: value2?.content || []
3575
- })
3576
- })
3577
- })
3578
- )
3579
- })
3580
- })
3581
- ]
3582
- });
3583
- var createBatchOutputsFormPlugin = (0, import_editor36.defineFormPluginCreator)({
3584
- name: "batch-outputs-plugin",
3585
- onSetupFormMeta({ mergeEffect }, { outputKey }) {
3586
- mergeEffect({
3587
- [outputKey]: provideBatchOutputsEffect
3588
- });
3589
- },
3590
- onInit(ctx, { outputKey }) {
3591
- const chainTransformService = ctx.node.getService(import_editor36.ScopeChainTransformService);
3592
- const batchNodeType = ctx.node.flowNodeType;
3593
- const transformerId = `${batchNodeType}-outputs`;
3594
- if (chainTransformService.hasTransformer(transformerId)) {
3595
- return;
3596
- }
3597
- chainTransformService.registerTransformer(transformerId, {
3598
- transformCovers: (covers, ctx2) => {
3599
- const node = ctx2.scope.meta?.node;
3600
- if (node?.parent?.flowNodeType === batchNodeType) {
3601
- return [...covers, (0, import_editor36.getNodeScope)(node.parent)];
3602
- }
3603
- return covers;
3604
- },
3605
- transformDeps(scopes, ctx2) {
3606
- const scopeMeta = ctx2.scope.meta;
3607
- if (scopeMeta?.type === import_editor36.FlowNodeScopeType.private) {
3608
- return scopes;
3609
- }
3610
- const node = scopeMeta?.node;
3611
- if (node?.flowNodeType === batchNodeType) {
3612
- const childBlocks = node.blocks;
3613
- return [
3614
- (0, import_editor36.getNodePrivateScope)(node),
3615
- ...childBlocks.map((_childBlock) => (0, import_editor36.getNodeScope)(_childBlock))
3616
- ];
3617
- }
3618
- return scopes;
3619
- }
3620
- });
3621
- }
3622
- });
3623
-
3624
- // src/form-plugins/infer-inputs-plugin/index.ts
3625
- var import_lodash9 = require("lodash");
3626
- var import_json_schema12 = require("@flowgram.ai/json-schema");
3627
- var import_editor37 = require("@flowgram.ai/editor");
3628
- var createInferInputsPlugin = (0, import_editor37.defineFormPluginCreator)({
3629
- onSetupFormMeta({ addFormatOnSubmit }, { sourceKey, targetKey, scope }) {
3630
- if (!sourceKey || !targetKey) {
3631
- return;
3632
- }
3633
- addFormatOnSubmit((formData, ctx) => {
3634
- (0, import_lodash9.set)(
3635
- formData,
3636
- targetKey,
3637
- infer(
3638
- (0, import_lodash9.get)(formData, sourceKey),
3639
- scope === "private" ? (0, import_editor37.getNodePrivateScope)(ctx.node) : (0, import_editor37.getNodeScope)(ctx.node)
3640
- )
3641
- );
3642
- return formData;
3643
- });
3644
- }
3645
- });
3646
- function isRef2(value) {
3647
- return value?.type === "ref" && Array.isArray(value?.content) && typeof value?.content[0] === "string";
3648
- }
3649
- function isTemplate2(value) {
3650
- return value?.type === "template" && typeof value?.content === "string";
3651
- }
3652
- function isConstant(value) {
3653
- return value?.type === "constant" && typeof value?.content !== "undefined";
3654
- }
3655
- var infer = (values, scope) => {
3656
- if (typeof values === "object") {
3657
- if (isConstant(values)) {
3658
- if (values?.schema) {
3659
- return values.schema;
3660
- }
3661
- if (typeof values.content === "string") {
3662
- return {
3663
- type: "string"
3664
- };
3665
- }
3666
- if (typeof values.content === "number") {
3667
- return {
3668
- type: "number"
3669
- };
3670
- }
3671
- if (typeof values.content === "boolean") {
3672
- return {
3673
- type: "boolean"
3674
- };
3675
- }
3676
- }
3677
- if (isRef2(values)) {
3678
- const variable = scope.available.getByKeyPath(values?.content);
3679
- const schema = variable?.type ? import_json_schema12.JsonSchemaUtils.astToSchema(variable?.type) : void 0;
3680
- return schema;
3681
- }
3682
- if (isTemplate2(values)) {
3683
- return {
3684
- type: "string"
3685
- };
3686
- }
3687
- return {
3688
- type: "object",
3689
- properties: Object.keys(values).reduce((acc, key) => {
3690
- const schema = infer(values[key], scope);
3691
- if (schema) {
3692
- acc[key] = schema;
3693
- }
3694
- return acc;
3695
- }, {})
3696
- };
3697
- }
3698
- };
3699
-
3700
- // src/form-plugins/infer-assign-plugin/index.ts
3701
- var import_lodash10 = require("lodash");
3702
- var import_json_schema13 = require("@flowgram.ai/json-schema");
3703
- var import_editor38 = require("@flowgram.ai/editor");
3704
- var createInferAssignPlugin = (0, import_editor38.defineFormPluginCreator)({
3705
- onSetupFormMeta({ addFormatOnSubmit, mergeEffect }, { assignKey, outputKey }) {
3706
- if (!assignKey || !outputKey) {
3707
- return;
3708
- }
3709
- mergeEffect({
3710
- [assignKey]: (0, import_editor38.createEffectFromVariableProvider)({
3711
- parse: (value, ctx) => {
3712
- const declareRows = (0, import_lodash10.uniqBy)(
3713
- value.filter((_v) => _v.operator === "declare" && _v.left && _v.right),
3714
- "left"
3715
- );
3716
- return [
3717
- import_editor38.ASTFactory.createVariableDeclaration({
3718
- key: `${ctx.node.id}`,
3719
- meta: {
3720
- title: (0, import_editor38.getNodeForm)(ctx.node)?.getValueIn("title"),
3721
- icon: ctx.node.getNodeRegistry().info?.icon
3722
- },
3723
- type: import_editor38.ASTFactory.createObject({
3724
- properties: declareRows.map(
3725
- (_v) => import_editor38.ASTFactory.createProperty({
3726
- key: _v.left,
3727
- type: _v.right?.type === "constant" ? import_json_schema13.JsonSchemaUtils.schemaToAST(_v.right?.schema || {}) : void 0,
3728
- initializer: _v.right?.type === "ref" ? import_editor38.ASTFactory.createKeyPathExpression({
3729
- keyPath: _v.right?.content || []
3730
- }) : {}
3731
- })
3732
- )
3733
- })
3734
- })
3735
- ];
3736
- }
3737
- })
3738
- });
3739
- addFormatOnSubmit((formData, ctx) => {
3740
- (0, import_lodash10.set)(
3741
- formData,
3742
- outputKey,
3743
- import_json_schema13.JsonSchemaUtils.astToSchema((0, import_editor38.getNodeScope)(ctx.node).output.variables?.[0]?.type)
3744
- );
3745
- return formData;
3746
- });
3747
- }
3748
- });
3749
-
3750
- // src/validate/validate-flow-value/index.tsx
3751
- var import_lodash11 = require("lodash");
3752
- var import_editor39 = require("@flowgram.ai/editor");
3753
- function validateFlowValue(value, ctx) {
3754
- const { node, required, errorMessages } = ctx;
3755
- const {
3756
- required: requiredMessage = "Field is required",
3757
- unknownVariable: unknownVariableMessage = "Unknown Variable"
3758
- } = errorMessages || {};
3759
- if (required && ((0, import_lodash11.isNil)(value) || (0, import_lodash11.isNil)(value?.content) || value?.content === "")) {
3760
- return {
3761
- level: import_editor39.FeedbackLevel.Error,
3762
- message: requiredMessage
3763
- };
3764
- }
3765
- if (value?.type === "ref") {
3766
- const variable = (0, import_editor39.getNodeScope)(node).available.getByKeyPath(value?.content || []);
3767
- if (!variable) {
3768
- return {
3769
- level: import_editor39.FeedbackLevel.Error,
3770
- message: unknownVariableMessage
3771
- };
3772
- }
3773
- }
3774
- if (value?.type === "template") {
3775
- const allRefs = getTemplateKeyPaths2(value);
3776
- for (const ref of allRefs) {
3777
- const variable = (0, import_editor39.getNodeScope)(node).available.getByKeyPath(ref);
3778
- if (!variable) {
3779
- return {
3780
- level: import_editor39.FeedbackLevel.Error,
3781
- message: unknownVariableMessage
3782
- };
3783
- }
3784
- }
3785
- }
3786
- return void 0;
3787
- }
3788
- function getTemplateKeyPaths2(value) {
3789
- const keyPathReg = /{{(.*?)}}/g;
3790
- return (0, import_lodash11.uniq)(value.content?.match(keyPathReg) || []).map(
3791
- (_keyPath) => _keyPath.slice(2, -2).split(".")
3792
- );
3793
- }
3794
- // Annotate the CommonJS export names for ESM import in node:
3795
- 0 && (module.exports = {
3796
- AssignRow,
3797
- AssignRows,
3798
- BatchOutputs,
3799
- BatchVariableSelector,
3800
- CodeEditor,
3801
- CodeEditorMini,
3802
- ConditionRow,
3803
- ConstantInput,
3804
- DisplayFlowValue,
3805
- DisplayInputsValues,
3806
- DisplayOutputs,
3807
- DisplaySchemaTag,
3808
- DisplaySchemaTree,
3809
- DynamicValueInput,
3810
- InjectDynamicValueInput,
3811
- InjectTypeSelector,
3812
- InjectVariableSelector,
3813
- InputsValues,
3814
- JsonEditorWithVariables,
3815
- JsonSchemaEditor,
3816
- JsonSchemaTypePresetProvider,
3817
- JsonSchemaUtils,
3818
- PromptEditor,
3819
- PromptEditorWithInputs,
3820
- PromptEditorWithVariables,
3821
- TypeSelector,
3822
- VariableSelector,
3823
- autoRenameRefEffect,
3824
- createBatchOutputsFormPlugin,
3825
- createDisableDeclarationPlugin,
3826
- createInferAssignPlugin,
3827
- createInferInputsPlugin,
3828
- createInjectMaterial,
3829
- createTypePresetPlugin,
3830
- formatLegacyRefOnInit,
3831
- formatLegacyRefOnSubmit,
3832
- formatLegacyRefToNewRef,
3833
- formatNewRefToLegacyRef,
3834
- getTypeSelectValue,
3835
- isLegacyFlowRefValueSchema,
3836
- isNewFlowRefValueSchema,
3837
- listenRefSchemaChange,
3838
- listenRefValueChange,
3839
- parseTypeSelectValue,
3840
- provideBatchInputEffect,
3841
- provideBatchOutputsEffect,
3842
- provideJsonSchemaOutputs,
3843
- syncVariableTitle,
3844
- useTypeManager,
3845
- useVariableTree,
3846
- validateFlowValue,
3847
- validateWhenVariableSync
3848
- });
3849
- //# sourceMappingURL=index.js.map