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

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 (227) hide show
  1. package/dist/cjs/components/batch-outputs/index.js +5 -3
  2. package/dist/cjs/components/batch-outputs/styles.css +13 -0
  3. package/dist/cjs/components/blur-input/index.js +1 -0
  4. package/dist/cjs/components/code-editor/editor.js +16 -12
  5. package/dist/cjs/components/code-editor/styles.css +4 -0
  6. package/dist/cjs/components/code-editor/theme/dark.js +1 -1
  7. package/dist/cjs/components/code-editor/theme/light.js +1 -1
  8. package/dist/cjs/components/code-editor-mini/index.js +2 -16
  9. package/dist/cjs/components/condition-context/hooks/use-condition.js +17 -1
  10. package/dist/cjs/components/condition-row/index.js +26 -12
  11. package/dist/cjs/components/condition-row/styles.css +19 -0
  12. package/dist/cjs/components/coze-editor-extensions/extensions/inputs-tree.js +2 -2
  13. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +31 -11
  14. package/dist/{esm/components/coze-editor-extensions/styles.mjs → cjs/components/coze-editor-extensions/styles.css} +19 -18
  15. package/dist/cjs/components/db-condition-row/index.js +29 -14
  16. package/dist/cjs/components/db-condition-row/styles.css +30 -0
  17. package/dist/cjs/components/display-inputs-values/index.js +3 -2
  18. package/dist/cjs/components/display-inputs-values/styles.css +6 -0
  19. package/dist/cjs/components/display-outputs/index.js +5 -4
  20. package/dist/cjs/components/display-outputs/styles.css +6 -0
  21. package/dist/cjs/components/display-schema-tag/index.js +7 -4
  22. package/dist/cjs/components/display-schema-tag/styles.css +21 -0
  23. package/dist/cjs/components/display-schema-tree/index.js +12 -7
  24. package/dist/cjs/components/display-schema-tree/styles.css +64 -0
  25. package/dist/cjs/components/dynamic-value-input/index.js +9 -5
  26. package/dist/{esm/components/dynamic-value-input/styles.mjs → cjs/components/dynamic-value-input/styles.css} +24 -30
  27. package/dist/cjs/components/inputs-values/index.js +5 -3
  28. package/dist/cjs/components/inputs-values/styles.css +13 -0
  29. package/dist/cjs/components/inputs-values-tree/icon.js +70 -0
  30. package/dist/cjs/components/inputs-values-tree/index.js +4 -3
  31. package/dist/cjs/components/inputs-values-tree/row.js +19 -15
  32. package/dist/cjs/components/inputs-values-tree/styles.css +85 -0
  33. package/dist/cjs/components/json-schema-editor/default-value.js +2 -2
  34. package/dist/cjs/components/json-schema-editor/hooks.js +55 -48
  35. package/dist/cjs/components/json-schema-editor/icon.js +70 -0
  36. package/dist/cjs/components/json-schema-editor/index.js +37 -25
  37. package/dist/cjs/components/json-schema-editor/styles.css +113 -0
  38. package/dist/cjs/components/prompt-editor/editor.js +16 -6
  39. package/dist/cjs/components/prompt-editor/styles.css +10 -0
  40. package/dist/cjs/components/prompt-editor-with-inputs/index.js +16 -26
  41. package/dist/cjs/components/prompt-editor-with-variables/index.js +17 -26
  42. package/dist/cjs/components/variable-selector/context.js +7 -3
  43. package/dist/cjs/components/variable-selector/index.js +16 -10
  44. package/dist/{esm/components/variable-selector/styles.mjs → cjs/components/variable-selector/styles.css} +37 -29
  45. package/dist/cjs/components/variable-selector/use-variable-tree.js +3 -1
  46. package/dist/cjs/shared/inject-material/index.js +1 -1
  47. package/dist/esm/components/batch-outputs/index.mjs +5 -3
  48. package/dist/esm/components/batch-outputs/styles.css +13 -0
  49. package/dist/esm/components/blur-input/index.mjs +1 -0
  50. package/dist/esm/components/code-editor/editor.mjs +16 -11
  51. package/dist/esm/components/code-editor/styles.css +4 -0
  52. package/dist/esm/components/code-editor/theme/dark.mjs +1 -1
  53. package/dist/esm/components/code-editor/theme/light.mjs +1 -1
  54. package/dist/esm/components/code-editor-mini/index.mjs +2 -6
  55. package/dist/esm/components/condition-context/hooks/use-condition.mjs +18 -2
  56. package/dist/esm/components/condition-row/index.mjs +26 -12
  57. package/dist/esm/components/condition-row/styles.css +19 -0
  58. package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +3 -3
  59. package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +32 -12
  60. package/dist/esm/components/coze-editor-extensions/styles.css +37 -0
  61. package/dist/esm/components/db-condition-row/index.mjs +29 -14
  62. package/dist/esm/components/db-condition-row/styles.css +30 -0
  63. package/dist/esm/components/display-inputs-values/index.mjs +3 -2
  64. package/dist/esm/components/display-inputs-values/styles.css +6 -0
  65. package/dist/esm/components/display-outputs/index.mjs +5 -4
  66. package/dist/esm/components/display-outputs/styles.css +6 -0
  67. package/dist/esm/components/display-schema-tag/index.mjs +8 -5
  68. package/dist/esm/components/display-schema-tag/styles.css +21 -0
  69. package/dist/esm/components/display-schema-tree/index.mjs +12 -7
  70. package/dist/esm/components/display-schema-tree/styles.css +64 -0
  71. package/dist/esm/components/dynamic-value-input/index.mjs +9 -5
  72. package/dist/esm/components/dynamic-value-input/styles.css +48 -0
  73. package/dist/esm/components/inputs-values/index.mjs +5 -3
  74. package/dist/esm/components/inputs-values/styles.css +13 -0
  75. package/dist/esm/components/inputs-values-tree/icon.mjs +26 -0
  76. package/dist/esm/components/inputs-values-tree/index.mjs +4 -3
  77. package/dist/esm/components/inputs-values-tree/row.mjs +18 -14
  78. package/dist/esm/components/inputs-values-tree/styles.css +85 -0
  79. package/dist/esm/components/json-schema-editor/default-value.mjs +2 -2
  80. package/dist/esm/components/json-schema-editor/hooks.mjs +55 -48
  81. package/dist/esm/components/json-schema-editor/icon.mjs +26 -0
  82. package/dist/esm/components/json-schema-editor/index.mjs +36 -24
  83. package/dist/esm/components/json-schema-editor/styles.css +113 -0
  84. package/dist/esm/components/prompt-editor/editor.mjs +16 -6
  85. package/dist/esm/components/prompt-editor/styles.css +10 -0
  86. package/dist/esm/components/prompt-editor-with-inputs/index.mjs +12 -4
  87. package/dist/esm/components/prompt-editor-with-variables/index.mjs +13 -4
  88. package/dist/esm/components/variable-selector/context.mjs +7 -3
  89. package/dist/esm/components/variable-selector/index.mjs +17 -11
  90. package/{src/components/variable-selector/styles.tsx → dist/esm/components/variable-selector/styles.css} +35 -38
  91. package/dist/esm/components/variable-selector/use-variable-tree.mjs +3 -1
  92. package/dist/esm/shared/inject-material/index.mjs +1 -1
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/dist/types/components/batch-outputs/index.d.ts +1 -0
  95. package/dist/types/components/blur-input/index.d.ts +1 -1
  96. package/dist/types/components/code-editor/editor.d.ts +1 -0
  97. package/dist/types/components/condition-context/hooks/use-condition.d.ts +16 -1
  98. package/dist/types/components/condition-row/index.d.ts +5 -1
  99. package/dist/types/components/coze-editor-extensions/extensions/inputs-tree.d.ts +3 -3
  100. package/dist/types/components/coze-editor-extensions/extensions/variable-tag.d.ts +1 -0
  101. package/dist/types/components/coze-editor-extensions/index.d.ts +1 -1
  102. package/dist/types/components/db-condition-row/index.d.ts +4 -0
  103. package/dist/types/components/db-condition-row/types.d.ts +0 -1
  104. package/dist/types/components/display-inputs-values/index.d.ts +3 -1
  105. package/dist/types/components/display-outputs/index.d.ts +1 -0
  106. package/dist/types/components/display-schema-tag/index.d.ts +1 -0
  107. package/dist/types/components/display-schema-tree/index.d.ts +1 -0
  108. package/dist/types/components/dynamic-value-input/index.d.ts +1 -0
  109. package/dist/types/components/inputs-values/index.d.ts +1 -0
  110. package/dist/types/components/inputs-values-tree/icon.d.ts +6 -0
  111. package/dist/types/components/inputs-values-tree/index.d.ts +1 -0
  112. package/dist/types/components/inputs-values-tree/row.d.ts +1 -0
  113. package/dist/types/components/inputs-values-tree/types.d.ts +3 -2
  114. package/dist/types/components/json-schema-editor/icon.d.ts +6 -0
  115. package/dist/types/components/json-schema-editor/index.d.ts +1 -0
  116. package/dist/types/components/prompt-editor/editor.d.ts +1 -0
  117. package/dist/types/components/prompt-editor-with-inputs/index.d.ts +7 -2
  118. package/dist/types/components/prompt-editor-with-variables/index.d.ts +5 -2
  119. package/dist/types/components/variable-selector/context.d.ts +16 -3
  120. package/dist/types/components/variable-selector/index.d.ts +1 -0
  121. package/dist/types/index.d.ts +1 -1
  122. package/dist/types/shared/flow-value/index.d.ts +1 -1
  123. package/dist/types/shared/flow-value/types.d.ts +3 -0
  124. package/dist/types/shared/index.d.ts +1 -1
  125. package/package.json +7 -10
  126. package/src/components/batch-outputs/index.tsx +5 -5
  127. package/src/components/batch-outputs/{styles.tsx → styles.css} +4 -6
  128. package/src/components/blur-input/index.tsx +2 -1
  129. package/src/components/code-editor/editor.tsx +19 -14
  130. package/src/components/code-editor/styles.css +11 -0
  131. package/src/components/code-editor/theme/dark.ts +1 -1
  132. package/src/components/code-editor/theme/light.ts +1 -1
  133. package/src/components/code-editor-mini/index.tsx +2 -9
  134. package/src/components/condition-context/hooks/use-condition.tsx +51 -7
  135. package/src/components/condition-row/index.tsx +27 -22
  136. package/src/components/condition-row/{styles.tsx → styles.css} +11 -11
  137. package/src/components/coze-editor-extensions/extensions/inputs-tree.tsx +7 -6
  138. package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +19 -14
  139. package/src/components/coze-editor-extensions/{styles.tsx → styles.css} +8 -11
  140. package/src/components/db-condition-row/index.tsx +29 -26
  141. package/src/components/db-condition-row/{styles.tsx → styles.css} +14 -16
  142. package/src/components/db-condition-row/types.ts +0 -1
  143. package/src/components/display-inputs-values/index.tsx +5 -4
  144. package/src/components/display-inputs-values/{styles.ts → styles.css} +2 -4
  145. package/src/components/display-outputs/index.tsx +5 -5
  146. package/src/components/display-outputs/{styles.ts → styles.css} +2 -4
  147. package/src/components/display-schema-tag/index.tsx +7 -7
  148. package/src/components/display-schema-tag/{styles.ts → styles.css} +7 -10
  149. package/src/components/display-schema-tree/index.tsx +10 -10
  150. package/src/components/display-schema-tree/{styles.tsx → styles.css} +18 -24
  151. package/src/components/dynamic-value-input/index.tsx +6 -6
  152. package/src/components/dynamic-value-input/{styles.tsx → styles.css} +9 -12
  153. package/src/components/inputs-values/index.tsx +5 -5
  154. package/src/components/inputs-values/{styles.tsx → styles.css} +4 -6
  155. package/src/components/inputs-values-tree/icon.tsx +28 -0
  156. package/src/components/inputs-values-tree/index.tsx +8 -6
  157. package/src/components/inputs-values-tree/row.tsx +25 -27
  158. package/src/components/inputs-values-tree/styles.css +94 -0
  159. package/src/components/inputs-values-tree/types.ts +3 -2
  160. package/src/components/json-schema-editor/default-value.tsx +2 -4
  161. package/src/components/json-schema-editor/hooks.tsx +60 -53
  162. package/src/components/json-schema-editor/icon.tsx +28 -0
  163. package/src/components/json-schema-editor/index.tsx +45 -50
  164. package/src/components/json-schema-editor/styles.css +135 -0
  165. package/src/components/prompt-editor/editor.tsx +18 -7
  166. package/src/components/prompt-editor/styles.css +14 -0
  167. package/src/components/prompt-editor-with-inputs/index.tsx +18 -5
  168. package/src/components/prompt-editor-with-variables/index.tsx +13 -5
  169. package/src/components/variable-selector/context.tsx +22 -2
  170. package/src/components/variable-selector/index.tsx +24 -14
  171. package/src/components/variable-selector/styles.css +70 -0
  172. package/src/components/variable-selector/use-variable-tree.tsx +9 -1
  173. package/src/index.ts +1 -0
  174. package/src/shared/flow-value/index.ts +1 -0
  175. package/src/shared/flow-value/types.ts +4 -0
  176. package/src/shared/index.ts +1 -0
  177. package/src/shared/inject-material/index.tsx +1 -1
  178. package/dist/cjs/components/batch-outputs/styles.js +0 -60
  179. package/dist/cjs/components/condition-row/styles.js +0 -77
  180. package/dist/cjs/components/coze-editor-extensions/styles.js +0 -89
  181. package/dist/cjs/components/db-condition-row/styles.js +0 -94
  182. package/dist/cjs/components/display-inputs-values/styles.js +0 -51
  183. package/dist/cjs/components/display-outputs/styles.js +0 -51
  184. package/dist/cjs/components/display-schema-tag/styles.js +0 -71
  185. package/dist/cjs/components/display-schema-tree/styles.js +0 -135
  186. package/dist/cjs/components/dynamic-value-input/styles.js +0 -107
  187. package/dist/cjs/components/inputs-values/styles.js +0 -60
  188. package/dist/cjs/components/inputs-values-tree/styles.js +0 -177
  189. package/dist/cjs/components/json-schema-editor/styles.js +0 -231
  190. package/dist/cjs/components/prompt-editor/styles.js +0 -55
  191. package/dist/cjs/components/prompt-editor-with-inputs/editor.js +0 -47
  192. package/dist/cjs/components/prompt-editor-with-variables/editor.js +0 -48
  193. package/dist/cjs/components/variable-selector/styles.js +0 -114
  194. package/dist/esm/components/batch-outputs/styles.mjs +0 -13
  195. package/dist/esm/components/condition-row/styles.mjs +0 -21
  196. package/dist/esm/components/db-condition-row/styles.mjs +0 -32
  197. package/dist/esm/components/display-inputs-values/styles.mjs +0 -7
  198. package/dist/esm/components/display-outputs/styles.mjs +0 -7
  199. package/dist/esm/components/display-schema-tag/styles.mjs +0 -21
  200. package/dist/esm/components/display-schema-tree/styles.mjs +0 -79
  201. package/dist/esm/components/inputs-values/styles.mjs +0 -13
  202. package/dist/esm/components/inputs-values-tree/styles.mjs +0 -105
  203. package/dist/esm/components/json-schema-editor/styles.mjs +0 -138
  204. package/dist/esm/components/prompt-editor/styles.mjs +0 -11
  205. package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +0 -13
  206. package/dist/esm/components/prompt-editor-with-variables/editor.mjs +0 -14
  207. package/dist/types/components/batch-outputs/styles.d.ts +0 -6
  208. package/dist/types/components/condition-row/styles.d.ts +0 -9
  209. package/dist/types/components/coze-editor-extensions/styles.d.ts +0 -9
  210. package/dist/types/components/db-condition-row/styles.d.ts +0 -12
  211. package/dist/types/components/display-inputs-values/styles.d.ts +0 -5
  212. package/dist/types/components/display-outputs/styles.d.ts +0 -5
  213. package/dist/types/components/display-schema-tag/styles.d.ts +0 -8
  214. package/dist/types/components/display-schema-tree/styles.d.ts +0 -11
  215. package/dist/types/components/dynamic-value-input/styles.d.ts +0 -8
  216. package/dist/types/components/inputs-values/styles.d.ts +0 -6
  217. package/dist/types/components/inputs-values-tree/styles.d.ts +0 -23
  218. package/dist/types/components/json-schema-editor/styles.d.ts +0 -30
  219. package/dist/types/components/prompt-editor/styles.d.ts +0 -7
  220. package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +0 -10
  221. package/dist/types/components/prompt-editor-with-variables/editor.d.ts +0 -9
  222. package/dist/types/components/variable-selector/styles.d.ts +0 -14
  223. package/src/components/inputs-values-tree/styles.tsx +0 -128
  224. package/src/components/json-schema-editor/styles.tsx +0 -168
  225. package/src/components/prompt-editor/styles.tsx +0 -18
  226. package/src/components/prompt-editor-with-inputs/editor.tsx +0 -24
  227. package/src/components/prompt-editor-with-variables/editor.tsx +0 -20
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ .gedit-m-json-schema-editor-container {
7
+ /* & .semi-input {
8
+ background-color: #fff;
9
+ border-radius: 6px;
10
+ height: 24px;
11
+ } */
12
+ }
13
+
14
+ .gedit-m-json-schema-editor-row {
15
+ display: flex;
16
+ align-items: center;
17
+ gap: 6px;
18
+ }
19
+
20
+ .gedit-m-json-schema-editor-collapse-trigger {
21
+ cursor: pointer;
22
+ margin-right: 5px;
23
+ }
24
+
25
+ .gedit-m-json-schema-editor-expand-detail {
26
+ display: flex;
27
+ flex-direction: column;
28
+ }
29
+
30
+ .gedit-m-json-schema-editor-label {
31
+ font-size: 12px;
32
+ color: #999;
33
+ font-weight: 400;
34
+ margin-bottom: 2px;
35
+ }
36
+
37
+ .gedit-m-json-schema-editor-tree-items {
38
+ display: grid;
39
+ grid-template-columns: auto 1fr;
40
+ }
41
+
42
+ .gedit-m-json-schema-editor-tree-items.shrink {
43
+ padding-left: 3px;
44
+ margin-top: 10px;
45
+ }
46
+
47
+ .gedit-m-json-schema-editor-tree-item-left {
48
+ grid-column: 1;
49
+ position: relative;
50
+ width: 16px;
51
+ }
52
+
53
+ .gedit-m-json-schema-editor-tree-item-left.show-line::before {
54
+ /* 竖线 */
55
+ content: "";
56
+ height: var(--line-height, 100%);
57
+ position: absolute;
58
+ left: -14px;
59
+ top: -16px;
60
+ width: 1px;
61
+ background: #d9d9d9;
62
+ display: block;
63
+ }
64
+
65
+ .gedit-m-json-schema-editor-tree-item-left.show-line::after {
66
+ /* 横线 */
67
+ content: "";
68
+ position: absolute;
69
+ left: -14px; /* 横线起点和竖线对齐 */
70
+ top: 8px; /* 跟随你的行高调整 */
71
+ width: var(--line-width, 30px); /* 横线长度 */
72
+ height: 1px;
73
+ background: #d9d9d9;
74
+ display: block;
75
+ }
76
+
77
+ .gedit-m-json-schema-editor-tree-item-left.show-line.is-last::before {
78
+ height: 24px;
79
+ }
80
+
81
+ .gedit-m-json-schema-editor-tree-item-left.show-line.show-collapse::after {
82
+ width: 12px;
83
+ }
84
+
85
+ .gedit-m-json-schema-editor-tree-item-right {
86
+ grid-column: 2;
87
+ margin-bottom: 10px;
88
+
89
+ &:last-child {
90
+ margin-bottom: 0px;
91
+ }
92
+ }
93
+
94
+ .gedit-m-json-schema-editor-tree-item-main {
95
+ display: flex;
96
+ flex-direction: column;
97
+ gap: 10px;
98
+ position: relative;
99
+ }
100
+
101
+ .gedit-m-json-schema-editor-collapsible {
102
+ display: none;
103
+ }
104
+
105
+ .gedit-m-json-schema-editor-collapsible.collapse {
106
+ display: block;
107
+ }
108
+
109
+ .gedit-m-json-schema-editor-name {
110
+ flex-grow: 1;
111
+ }
112
+
113
+ .gedit-m-json-schema-editor-type {
114
+ }
115
+
116
+ .gedit-m-json-schema-editor-required {
117
+ }
118
+
119
+ .gedit-m-json-schema-editor-actions {
120
+ white-space: nowrap;
121
+ }
122
+
123
+ .gedit-m-json-schema-editor-default-value-wrapper {
124
+ margin: 0;
125
+ }
126
+
127
+ .gedit-m-json-schema-editor-constant-input-wrapper {
128
+ flex-grow: 1;
129
+
130
+ & .semi-tree-select,
131
+ & .semi-input-number,
132
+ & .semi-select {
133
+ width: 100%;
134
+ }
135
+ }
@@ -14,11 +14,12 @@ import {
14
14
  import preset, { EditorAPI } from '@flowgram.ai/coze-editor/preset-prompt';
15
15
 
16
16
  import { PropsType } from './types';
17
- import { UIContainer } from './styles';
18
17
  import MarkdownHighlight from './extensions/markdown';
19
18
  import LanguageSupport from './extensions/language-support';
20
19
  import JinjaHighlight from './extensions/jinja';
21
20
 
21
+ import './styles.css';
22
+
22
23
  type Preset = typeof preset;
23
24
  type Options = Partial<InferValues<Preset[number]>>;
24
25
 
@@ -42,22 +43,32 @@ export function PromptEditor(props: PromptEditorPropsType) {
42
43
 
43
44
  const editorRef = useRef<EditorAPI | null>(null);
44
45
 
46
+ const editorValue = String(value?.content || '');
47
+
45
48
  useEffect(() => {
46
49
  // listen to value change
47
- if (editorRef.current?.getValue() !== value?.content) {
48
- editorRef.current?.setValue(String(value?.content || ''));
50
+ if (editorRef.current?.getValue() !== editorValue) {
51
+ // apply updates on readonly mode
52
+ const editorView = editorRef.current?.$view;
53
+ editorView?.dispatch({
54
+ changes: {
55
+ from: 0,
56
+ to: editorView?.state.doc.length,
57
+ insert: editorValue,
58
+ },
59
+ });
49
60
  }
50
- }, [value]);
61
+ }, [editorValue]);
51
62
 
52
63
  return (
53
- <UIContainer $hasError={hasError} style={style}>
64
+ <div className={`gedit-m-prompt-editor-container ${hasError ? 'has-error' : ''}`} style={style}>
54
65
  <EditorProvider>
55
66
  <Renderer
56
67
  didMount={(editor: EditorAPI) => {
57
68
  editorRef.current = editor;
58
69
  }}
59
70
  plugins={preset}
60
- defaultValue={String(value?.content)}
71
+ defaultValue={editorValue}
61
72
  options={{
62
73
  readOnly: readonly,
63
74
  editable: !readonly,
@@ -76,6 +87,6 @@ export function PromptEditor(props: PromptEditorPropsType) {
76
87
  <JinjaHighlight />
77
88
  {children}
78
89
  </EditorProvider>
79
- </UIContainer>
90
+ </div>
80
91
  );
81
92
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ .gedit-m-prompt-editor-container {
7
+ background-color: var(--semi-color-fill-0);
8
+ padding-left: 10px;
9
+ padding-right: 6px;
10
+ }
11
+
12
+ .gedit-m-prompt-editor-container.has-error {
13
+ border: 1px solid var(--semi-color-danger-6);
14
+ }
@@ -3,10 +3,23 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import { lazySuspense } from '@/shared';
6
+ import React from 'react';
7
7
 
8
- export const PromptEditorWithInputs = lazySuspense(() =>
9
- import('./editor').then((module) => ({ default: module.PromptEditorWithInputs }))
10
- );
8
+ import type { IInputsValues } from '@/shared/flow-value';
9
+ import { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';
10
+ import { EditorInputsTree } from '@/components/coze-editor-extensions';
11
11
 
12
- export type { PromptEditorWithInputsProps } from './editor';
12
+ export interface PromptEditorWithInputsProps extends PromptEditorPropsType {
13
+ inputsValues: IInputsValues;
14
+ }
15
+
16
+ export function PromptEditorWithInputs({
17
+ inputsValues,
18
+ ...restProps
19
+ }: PromptEditorWithInputsProps) {
20
+ return (
21
+ <PromptEditor {...restProps}>
22
+ <EditorInputsTree inputsValues={inputsValues} />
23
+ </PromptEditor>
24
+ );
25
+ }
@@ -3,10 +3,18 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import { lazySuspense } from '@/shared';
6
+ import React from 'react';
7
7
 
8
- export const PromptEditorWithVariables = lazySuspense(() =>
9
- import('./editor').then((module) => ({ default: module.PromptEditorWithVariables }))
10
- );
8
+ import { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';
9
+ import { EditorVariableTree, EditorVariableTagInject } from '@/components/coze-editor-extensions';
11
10
 
12
- export type { PromptEditorWithVariablesProps } from './editor';
11
+ export interface PromptEditorWithVariablesProps extends PromptEditorPropsType {}
12
+
13
+ export function PromptEditorWithVariables(props: PromptEditorWithVariablesProps) {
14
+ return (
15
+ <PromptEditor {...props}>
16
+ <EditorVariableTree />
17
+ <EditorVariableTagInject />
18
+ </PromptEditor>
19
+ );
20
+ }
@@ -5,10 +5,19 @@
5
5
 
6
6
  import React, { createContext, useContext, useMemo } from 'react';
7
7
 
8
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
8
9
  import { BaseVariableField } from '@flowgram.ai/editor';
9
10
 
11
+ type VariableField = BaseVariableField<{
12
+ icon?: string | JSX.Element;
13
+ title?: string;
14
+ disabled?: boolean;
15
+ }>;
16
+
10
17
  export const VariableSelectorContext = createContext<{
11
- skipVariable?: (variable?: BaseVariableField) => boolean;
18
+ includeSchema?: IJsonSchema | IJsonSchema[];
19
+ excludeSchema?: IJsonSchema | IJsonSchema[];
20
+ skipVariable?: (variable: VariableField) => boolean;
12
21
  }>({});
13
22
 
14
23
  export const useVariableSelectorContext = () => useContext(VariableSelectorContext);
@@ -16,11 +25,22 @@ export const useVariableSelectorContext = () => useContext(VariableSelectorConte
16
25
  export const VariableSelectorProvider = ({
17
26
  children,
18
27
  skipVariable,
28
+ includeSchema,
29
+ excludeSchema,
19
30
  }: {
20
31
  skipVariable?: (variable?: BaseVariableField) => boolean;
32
+ includeSchema?: IJsonSchema | IJsonSchema[];
33
+ excludeSchema?: IJsonSchema | IJsonSchema[];
21
34
  children: React.ReactNode;
22
35
  }) => {
23
- const context = useMemo(() => ({ skipVariable }), [skipVariable]);
36
+ const context = useMemo(
37
+ () => ({
38
+ skipVariable,
39
+ includeSchema,
40
+ excludeSchema,
41
+ }),
42
+ [skipVariable, includeSchema, excludeSchema]
43
+ );
24
44
 
25
45
  return (
26
46
  <VariableSelectorContext.Provider value={context}>{children}</VariableSelectorContext.Provider>
@@ -9,15 +9,16 @@ import { IJsonSchema } from '@flowgram.ai/json-schema';
9
9
  import { I18n } from '@flowgram.ai/editor';
10
10
  import { type TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
11
11
  import { type TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
12
- import { Popover } from '@douyinfe/semi-ui';
12
+ import { Popover, Tag, TreeSelect } from '@douyinfe/semi-ui';
13
13
  import { IconChevronDownStroked, IconIssueStroked } from '@douyinfe/semi-icons';
14
14
 
15
15
  import { createInjectMaterial } from '@/shared';
16
16
 
17
17
  import { useVariableTree } from './use-variable-tree';
18
- import { UIPopoverContent, UIRootTitle, UITag, UITreeSelect, UIVarName } from './styles';
19
18
  import { useVariableSelectorContext } from './context';
20
19
 
20
+ import './styles.css';
21
+
21
22
  export interface VariableSelectorProps {
22
23
  value?: string[];
23
24
  config?: {
@@ -75,62 +76,71 @@ export const VariableSelector = ({
75
76
 
76
77
  return (
77
78
  <>
78
- <UITreeSelect
79
+ <TreeSelect
80
+ className={`gedit-m-variable-selector-tree-select ${hasError ? 'error' : ''}`}
79
81
  dropdownMatchSelectWidth={false}
80
82
  disabled={readonly}
81
83
  treeData={treeData}
82
84
  size="small"
83
85
  value={treeValue}
84
86
  clearIcon={null}
85
- $error={hasError}
86
87
  style={style}
87
88
  validateStatus={hasError ? 'error' : undefined}
89
+ dropdownClassName="gedit-m-variable-selector-dropdown"
88
90
  onChange={(_, _config) => {
89
91
  onChange((_config as TreeNodeData).keyPath as string[]);
90
92
  }}
91
93
  renderSelectedItem={(_option: TreeNodeData) => {
92
94
  if (!_option?.keyPath) {
93
95
  return (
94
- <UITag
96
+ <Tag
97
+ className="gedit-m-variable-selector-tag"
95
98
  prefixIcon={<IconIssueStroked />}
96
99
  color="amber"
97
100
  closable={!readonly}
98
101
  onClose={() => onChange(undefined)}
99
102
  >
100
103
  {config?.notFoundContent ?? 'Undefined'}
101
- </UITag>
104
+ </Tag>
102
105
  );
103
106
  }
104
107
 
105
108
  const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
106
109
 
107
110
  const rootTitle = (
108
- <UIRootTitle>
111
+ <div className="gedit-m-variable-selector-root-title">
109
112
  {_option.rootMeta?.title
110
113
  ? `${_option.rootMeta?.title} ${_option.isRoot ? '' : '-'} `
111
114
  : null}
112
- </UIRootTitle>
115
+ </div>
113
116
  );
114
117
 
115
118
  return (
116
119
  <div>
117
120
  <Popover
118
121
  content={
119
- <UIPopoverContent>
122
+ <div className="gedit-m-variable-selector-tag-pop">
120
123
  {rootIcon}
121
124
  {rootTitle}
122
- <UIVarName>{_option.keyPath.slice(1).join('.')}</UIVarName>
123
- </UIPopoverContent>
125
+ <div className="gedit-m-variable-selector-var-name">
126
+ {_option.keyPath.slice(1).join('.')}
127
+ </div>
128
+ </div>
124
129
  }
125
130
  >
126
- <UITag
131
+ <Tag
132
+ className="gedit-m-variable-selector-tag"
127
133
  prefixIcon={rootIcon}
128
134
  closable={!readonly}
129
135
  onClose={() => onChange(undefined)}
130
136
  >
131
137
  {rootTitle}
132
- {!_option.isRoot && <UIVarName $inSelector>{_option.label}</UIVarName>}
133
- </UITag>
138
+ {!_option.isRoot && (
139
+ <div className="gedit-m-variable-selector-var-name in-selector">
140
+ {_option.label}
141
+ </div>
142
+ )}
143
+ </Tag>
134
144
  </Popover>
135
145
  </div>
136
146
  );
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ .gedit-m-variable-selector-root-title {
7
+ margin-right: 4px;
8
+ min-width: 20px;
9
+ overflow: hidden;
10
+ text-overflow: ellipsis;
11
+ white-space: nowrap;
12
+ color: var(--semi-color-text-2);
13
+ }
14
+
15
+ .gedit-m-variable-selector-var-name {
16
+ overflow: hidden;
17
+ text-overflow: ellipsis;
18
+ white-space: nowrap;
19
+
20
+ &.in-selector {
21
+ min-width: 50%;
22
+ }
23
+ }
24
+
25
+ .gedit-m-variable-selector-tag {
26
+ width: 100%;
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: flex-start;
30
+ margin: 0;
31
+ height: 22px;
32
+
33
+ .semi-tag-content-center {
34
+ justify-content: flex-start;
35
+ }
36
+ }
37
+
38
+ .gedit-m-variable-selector-tree-select {
39
+ outline: none;
40
+
41
+ &.error {
42
+ outline: 1px solid red;
43
+ }
44
+
45
+ .semi-tree-select-selection {
46
+ padding: 0px;
47
+ height: 22px;
48
+ }
49
+
50
+ .semi-tree-select-selection-content {
51
+ width: 100%;
52
+ }
53
+
54
+ .semi-tree-select-selection-placeholder {
55
+ padding-left: 10px;
56
+ }
57
+ }
58
+
59
+ .gedit-m-variable-selector-tag-pop {
60
+ padding: 10px;
61
+ display: inline-flex;
62
+ align-items: center;
63
+ justify-content: flex-start;
64
+ white-space: nowrap;
65
+ }
66
+
67
+ .gedit-m-variable-selector-dropdown {
68
+ max-height: 300px;
69
+ overflow: auto;
70
+ }
@@ -15,6 +15,8 @@ import { ASTMatch, BaseVariableField, useAvailableVariables } from '@flowgram.ai
15
15
  import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
16
16
  import { Icon } from '@douyinfe/semi-ui';
17
17
 
18
+ import { useVariableSelectorContext } from './context';
19
+
18
20
  type VariableField = BaseVariableField<{
19
21
  icon?: string | JSX.Element;
20
22
  title?: string;
@@ -26,7 +28,13 @@ export function useVariableTree(params: {
26
28
  excludeSchema?: IJsonSchema | IJsonSchema[];
27
29
  skipVariable?: (variable: VariableField) => boolean;
28
30
  }): TreeNodeData[] {
29
- const { includeSchema, excludeSchema, skipVariable } = params;
31
+ const context = useVariableSelectorContext();
32
+
33
+ const {
34
+ includeSchema = context.includeSchema,
35
+ excludeSchema = context.excludeSchema,
36
+ skipVariable = context.skipVariable,
37
+ } = params;
30
38
 
31
39
  const typeManager = useTypeManager() as JsonSchemaTypeManager;
32
40
  const variables = useAvailableVariables();
package/src/index.ts CHANGED
@@ -115,6 +115,7 @@ export {
115
115
  type IFlowTemplateValue,
116
116
  type IFlowValue,
117
117
  type IFlowValueExtra,
118
+ type IInputsValues,
118
119
  type IPolyfillRoot,
119
120
  unstableSetCreateRoot,
120
121
  withSuspense,
@@ -13,4 +13,5 @@ export {
13
13
  type IFlowExpressionValue,
14
14
  type IFlowTemplateValue,
15
15
  type IFlowConstantRefValue,
16
+ type IInputsValues,
16
17
  } from './types';
@@ -43,3 +43,7 @@ export type IFlowValue =
43
43
  | IFlowTemplateValue;
44
44
 
45
45
  export type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
46
+
47
+ export interface IInputsValues {
48
+ [key: string]: IInputsValues | IFlowValue | undefined;
49
+ }
@@ -13,6 +13,7 @@ export {
13
13
  type IFlowTemplateValue,
14
14
  type IFlowValue,
15
15
  type IFlowValueExtra,
16
+ type IInputsValues,
16
17
  } from './flow-value';
17
18
  export {
18
19
  formatLegacyRefOnInit,
@@ -62,7 +62,7 @@ export function createInjectMaterial<Props>(
62
62
  const container = usePlaygroundContainer();
63
63
 
64
64
  // Check if renderer registry is bound in container
65
- if (!container?.isBound(FlowRendererRegistry)) {
65
+ if (!container?.isBound?.(FlowRendererRegistry)) {
66
66
  // If no registry, use default component directly
67
67
  return React.createElement(Component as (props?: any) => any, { ...props });
68
68
  }
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- UIRows: ()=>UIRows,
37
- UIRow: ()=>UIRow
38
- });
39
- const external_styled_components_namespaceObject = require("styled-components");
40
- var external_styled_components_default = /*#__PURE__*/ __webpack_require__.n(external_styled_components_namespaceObject);
41
- const UIRows = external_styled_components_default().div`
42
- display: flex;
43
- flex-direction: column;
44
- gap: 10px;
45
- margin-bottom: 10px;
46
- `;
47
- const UIRow = external_styled_components_default().div`
48
- display: flex;
49
- align-items: center;
50
- gap: 5px;
51
- `;
52
- exports.UIRow = __webpack_exports__.UIRow;
53
- exports.UIRows = __webpack_exports__.UIRows;
54
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
55
- "UIRow",
56
- "UIRows"
57
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
58
- Object.defineProperty(exports, '__esModule', {
59
- value: true
60
- });
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- UIOperator: ()=>UIOperator,
37
- UIContainer: ()=>UIContainer,
38
- UIRight: ()=>UIRight,
39
- UIValues: ()=>UIValues,
40
- UILeft: ()=>UILeft
41
- });
42
- const external_styled_components_namespaceObject = require("styled-components");
43
- var external_styled_components_default = /*#__PURE__*/ __webpack_require__.n(external_styled_components_namespaceObject);
44
- const UIContainer = external_styled_components_default().div`
45
- display: flex;
46
- align-items: center;
47
- gap: 4px;
48
- `;
49
- const UIOperator = external_styled_components_default().div``;
50
- const UILeft = external_styled_components_default().div`
51
- width: 100%;
52
- `;
53
- const UIRight = external_styled_components_default().div`
54
- width: 100%;
55
- `;
56
- const UIValues = external_styled_components_default().div`
57
- flex-grow: 1;
58
- display: flex;
59
- flex-direction: column;
60
- align-items: center;
61
- gap: 4px;
62
- `;
63
- exports.UIContainer = __webpack_exports__.UIContainer;
64
- exports.UILeft = __webpack_exports__.UILeft;
65
- exports.UIOperator = __webpack_exports__.UIOperator;
66
- exports.UIRight = __webpack_exports__.UIRight;
67
- exports.UIValues = __webpack_exports__.UIValues;
68
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
69
- "UIContainer",
70
- "UILeft",
71
- "UIOperator",
72
- "UIRight",
73
- "UIValues"
74
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
75
- Object.defineProperty(exports, '__esModule', {
76
- value: true
77
- });