@flowgram.ai/form-materials 0.5.5 → 0.5.7

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 (208) 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 +4 -1
  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-mini/index.js +2 -16
  7. package/dist/cjs/components/condition-context/hooks/use-condition.js +17 -1
  8. package/dist/cjs/components/condition-row/index.js +26 -12
  9. package/dist/cjs/components/condition-row/styles.css +19 -0
  10. package/dist/cjs/components/coze-editor-extensions/extensions/inputs-tree.js +2 -2
  11. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +44 -15
  12. package/dist/{esm/components/coze-editor-extensions/styles.mjs → cjs/components/coze-editor-extensions/styles.css} +19 -18
  13. package/dist/cjs/components/db-condition-row/index.js +29 -14
  14. package/dist/cjs/components/db-condition-row/styles.css +30 -0
  15. package/dist/cjs/components/display-inputs-values/index.js +3 -2
  16. package/dist/cjs/components/display-inputs-values/styles.css +6 -0
  17. package/dist/cjs/components/display-outputs/index.js +5 -4
  18. package/dist/cjs/components/display-outputs/styles.css +6 -0
  19. package/dist/cjs/components/display-schema-tag/index.js +7 -4
  20. package/dist/cjs/components/display-schema-tag/styles.css +21 -0
  21. package/dist/cjs/components/display-schema-tree/index.js +12 -7
  22. package/dist/cjs/components/display-schema-tree/styles.css +64 -0
  23. package/dist/cjs/components/dynamic-value-input/index.js +9 -5
  24. package/dist/{esm/components/dynamic-value-input/styles.mjs → cjs/components/dynamic-value-input/styles.css} +23 -30
  25. package/dist/cjs/components/inputs-values/index.js +5 -3
  26. package/dist/cjs/components/inputs-values/styles.css +13 -0
  27. package/dist/cjs/components/inputs-values-tree/icon.js +70 -0
  28. package/dist/cjs/components/inputs-values-tree/index.js +3 -2
  29. package/dist/cjs/components/inputs-values-tree/row.js +19 -15
  30. package/dist/cjs/components/inputs-values-tree/styles.css +85 -0
  31. package/dist/cjs/components/json-schema-editor/default-value.js +2 -2
  32. package/dist/cjs/components/json-schema-editor/icon.js +70 -0
  33. package/dist/cjs/components/json-schema-editor/index.js +37 -25
  34. package/dist/cjs/components/json-schema-editor/styles.css +113 -0
  35. package/dist/cjs/components/prompt-editor/editor.js +16 -6
  36. package/dist/cjs/components/prompt-editor/styles.css +10 -0
  37. package/dist/cjs/components/prompt-editor-with-inputs/index.js +16 -26
  38. package/dist/cjs/components/prompt-editor-with-variables/index.js +17 -26
  39. package/dist/cjs/components/variable-selector/context.js +7 -3
  40. package/dist/cjs/components/variable-selector/index.js +16 -10
  41. package/dist/{esm/components/variable-selector/styles.mjs → cjs/components/variable-selector/styles.css} +37 -29
  42. package/dist/cjs/components/variable-selector/use-variable-tree.js +3 -1
  43. package/dist/cjs/effects/validate-when-variable-sync/index.js +3 -3
  44. package/dist/cjs/shared/inject-material/index.js +1 -1
  45. package/dist/esm/components/batch-outputs/index.mjs +5 -3
  46. package/dist/esm/components/batch-outputs/styles.css +13 -0
  47. package/dist/esm/components/blur-input/index.mjs +4 -1
  48. package/dist/esm/components/code-editor/editor.mjs +16 -11
  49. package/dist/esm/components/code-editor/styles.css +4 -0
  50. package/dist/esm/components/code-editor-mini/index.mjs +2 -6
  51. package/dist/esm/components/condition-context/hooks/use-condition.mjs +18 -2
  52. package/dist/esm/components/condition-row/index.mjs +26 -12
  53. package/dist/esm/components/condition-row/styles.css +19 -0
  54. package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +3 -3
  55. package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +45 -16
  56. package/dist/esm/components/coze-editor-extensions/styles.css +37 -0
  57. package/dist/esm/components/db-condition-row/index.mjs +29 -14
  58. package/dist/esm/components/db-condition-row/styles.css +30 -0
  59. package/dist/esm/components/display-inputs-values/index.mjs +3 -2
  60. package/dist/esm/components/display-inputs-values/styles.css +6 -0
  61. package/dist/esm/components/display-outputs/index.mjs +5 -4
  62. package/dist/esm/components/display-outputs/styles.css +6 -0
  63. package/dist/esm/components/display-schema-tag/index.mjs +8 -5
  64. package/dist/esm/components/display-schema-tag/styles.css +21 -0
  65. package/dist/esm/components/display-schema-tree/index.mjs +12 -7
  66. package/dist/esm/components/display-schema-tree/styles.css +64 -0
  67. package/dist/esm/components/dynamic-value-input/index.mjs +9 -5
  68. package/dist/esm/components/dynamic-value-input/styles.css +48 -0
  69. package/dist/esm/components/inputs-values/index.mjs +5 -3
  70. package/dist/esm/components/inputs-values/styles.css +13 -0
  71. package/dist/esm/components/inputs-values-tree/icon.mjs +26 -0
  72. package/dist/esm/components/inputs-values-tree/index.mjs +3 -2
  73. package/dist/esm/components/inputs-values-tree/row.mjs +18 -14
  74. package/dist/esm/components/inputs-values-tree/styles.css +85 -0
  75. package/dist/esm/components/json-schema-editor/default-value.mjs +2 -2
  76. package/dist/esm/components/json-schema-editor/icon.mjs +26 -0
  77. package/dist/esm/components/json-schema-editor/index.mjs +36 -24
  78. package/dist/esm/components/json-schema-editor/styles.css +113 -0
  79. package/dist/esm/components/prompt-editor/editor.mjs +16 -6
  80. package/dist/esm/components/prompt-editor/styles.css +10 -0
  81. package/dist/esm/components/prompt-editor-with-inputs/index.mjs +12 -4
  82. package/dist/esm/components/prompt-editor-with-variables/index.mjs +13 -4
  83. package/dist/esm/components/variable-selector/context.mjs +7 -3
  84. package/dist/esm/components/variable-selector/index.mjs +17 -11
  85. package/{src/components/variable-selector/styles.tsx → dist/esm/components/variable-selector/styles.css} +35 -38
  86. package/dist/esm/components/variable-selector/use-variable-tree.mjs +3 -1
  87. package/dist/esm/effects/validate-when-variable-sync/index.mjs +3 -3
  88. package/dist/esm/shared/inject-material/index.mjs +1 -1
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/dist/types/components/batch-outputs/index.d.ts +1 -0
  91. package/dist/types/components/code-editor/editor.d.ts +1 -0
  92. package/dist/types/components/condition-context/hooks/use-condition.d.ts +16 -1
  93. package/dist/types/components/condition-row/index.d.ts +5 -1
  94. package/dist/types/components/coze-editor-extensions/extensions/variable-tag.d.ts +1 -0
  95. package/dist/types/components/db-condition-row/index.d.ts +4 -0
  96. package/dist/types/components/db-condition-row/types.d.ts +0 -1
  97. package/dist/types/components/display-inputs-values/index.d.ts +1 -0
  98. package/dist/types/components/display-outputs/index.d.ts +1 -0
  99. package/dist/types/components/display-schema-tag/index.d.ts +1 -0
  100. package/dist/types/components/display-schema-tree/index.d.ts +1 -0
  101. package/dist/types/components/dynamic-value-input/index.d.ts +1 -0
  102. package/dist/types/components/inputs-values/index.d.ts +1 -0
  103. package/dist/types/components/inputs-values-tree/icon.d.ts +6 -0
  104. package/dist/types/components/inputs-values-tree/index.d.ts +1 -0
  105. package/dist/types/components/inputs-values-tree/row.d.ts +1 -0
  106. package/dist/types/components/json-schema-editor/icon.d.ts +6 -0
  107. package/dist/types/components/json-schema-editor/index.d.ts +1 -0
  108. package/dist/types/components/prompt-editor/editor.d.ts +1 -0
  109. package/dist/types/components/prompt-editor-with-inputs/index.d.ts +7 -2
  110. package/dist/types/components/prompt-editor-with-variables/index.d.ts +5 -2
  111. package/dist/types/components/variable-selector/context.d.ts +16 -3
  112. package/dist/types/components/variable-selector/index.d.ts +1 -0
  113. package/package.json +7 -10
  114. package/src/components/batch-outputs/index.tsx +5 -5
  115. package/src/components/batch-outputs/{styles.tsx → styles.css} +4 -6
  116. package/src/components/blur-input/index.tsx +4 -1
  117. package/src/components/code-editor/editor.tsx +19 -14
  118. package/src/components/code-editor/styles.css +11 -0
  119. package/src/components/code-editor-mini/index.tsx +2 -9
  120. package/src/components/condition-context/hooks/use-condition.tsx +51 -7
  121. package/src/components/condition-row/index.tsx +27 -22
  122. package/src/components/condition-row/{styles.tsx → styles.css} +10 -11
  123. package/src/components/coze-editor-extensions/extensions/inputs-tree.tsx +3 -3
  124. package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +35 -22
  125. package/src/components/coze-editor-extensions/{styles.tsx → styles.css} +8 -11
  126. package/src/components/db-condition-row/index.tsx +29 -26
  127. package/src/components/db-condition-row/{styles.tsx → styles.css} +14 -16
  128. package/src/components/db-condition-row/types.ts +0 -1
  129. package/src/components/display-inputs-values/index.tsx +3 -3
  130. package/src/components/display-inputs-values/{styles.ts → styles.css} +2 -4
  131. package/src/components/display-outputs/index.tsx +5 -5
  132. package/src/components/display-outputs/{styles.ts → styles.css} +2 -4
  133. package/src/components/display-schema-tag/index.tsx +7 -7
  134. package/src/components/display-schema-tag/{styles.ts → styles.css} +7 -10
  135. package/src/components/display-schema-tree/index.tsx +10 -10
  136. package/src/components/display-schema-tree/{styles.tsx → styles.css} +18 -24
  137. package/src/components/dynamic-value-input/index.tsx +6 -6
  138. package/src/components/dynamic-value-input/{styles.tsx → styles.css} +8 -12
  139. package/src/components/inputs-values/index.tsx +5 -5
  140. package/src/components/inputs-values/{styles.tsx → styles.css} +4 -6
  141. package/src/components/inputs-values-tree/icon.tsx +28 -0
  142. package/src/components/inputs-values-tree/index.tsx +3 -3
  143. package/src/components/inputs-values-tree/row.tsx +25 -27
  144. package/src/components/inputs-values-tree/styles.css +94 -0
  145. package/src/components/json-schema-editor/default-value.tsx +2 -4
  146. package/src/components/json-schema-editor/icon.tsx +28 -0
  147. package/src/components/json-schema-editor/index.tsx +45 -50
  148. package/src/components/json-schema-editor/styles.css +135 -0
  149. package/src/components/prompt-editor/editor.tsx +18 -7
  150. package/src/components/prompt-editor/styles.css +14 -0
  151. package/src/components/prompt-editor-with-inputs/index.tsx +18 -5
  152. package/src/components/prompt-editor-with-variables/index.tsx +13 -5
  153. package/src/components/variable-selector/context.tsx +22 -2
  154. package/src/components/variable-selector/index.tsx +24 -14
  155. package/src/components/variable-selector/styles.css +70 -0
  156. package/src/components/variable-selector/use-variable-tree.tsx +9 -1
  157. package/src/effects/validate-when-variable-sync/index.ts +7 -3
  158. package/src/shared/inject-material/index.tsx +1 -1
  159. package/dist/cjs/components/batch-outputs/styles.js +0 -60
  160. package/dist/cjs/components/condition-row/styles.js +0 -78
  161. package/dist/cjs/components/coze-editor-extensions/styles.js +0 -89
  162. package/dist/cjs/components/db-condition-row/styles.js +0 -94
  163. package/dist/cjs/components/display-inputs-values/styles.js +0 -51
  164. package/dist/cjs/components/display-outputs/styles.js +0 -51
  165. package/dist/cjs/components/display-schema-tag/styles.js +0 -71
  166. package/dist/cjs/components/display-schema-tree/styles.js +0 -135
  167. package/dist/cjs/components/dynamic-value-input/styles.js +0 -108
  168. package/dist/cjs/components/inputs-values/styles.js +0 -60
  169. package/dist/cjs/components/inputs-values-tree/styles.js +0 -177
  170. package/dist/cjs/components/json-schema-editor/styles.js +0 -231
  171. package/dist/cjs/components/prompt-editor/styles.js +0 -55
  172. package/dist/cjs/components/prompt-editor-with-inputs/editor.js +0 -47
  173. package/dist/cjs/components/prompt-editor-with-variables/editor.js +0 -48
  174. package/dist/cjs/components/variable-selector/styles.js +0 -114
  175. package/dist/esm/components/batch-outputs/styles.mjs +0 -13
  176. package/dist/esm/components/condition-row/styles.mjs +0 -22
  177. package/dist/esm/components/db-condition-row/styles.mjs +0 -32
  178. package/dist/esm/components/display-inputs-values/styles.mjs +0 -7
  179. package/dist/esm/components/display-outputs/styles.mjs +0 -7
  180. package/dist/esm/components/display-schema-tag/styles.mjs +0 -21
  181. package/dist/esm/components/display-schema-tree/styles.mjs +0 -79
  182. package/dist/esm/components/inputs-values/styles.mjs +0 -13
  183. package/dist/esm/components/inputs-values-tree/styles.mjs +0 -105
  184. package/dist/esm/components/json-schema-editor/styles.mjs +0 -138
  185. package/dist/esm/components/prompt-editor/styles.mjs +0 -11
  186. package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +0 -13
  187. package/dist/esm/components/prompt-editor-with-variables/editor.mjs +0 -14
  188. package/dist/types/components/batch-outputs/styles.d.ts +0 -6
  189. package/dist/types/components/condition-row/styles.d.ts +0 -9
  190. package/dist/types/components/coze-editor-extensions/styles.d.ts +0 -9
  191. package/dist/types/components/db-condition-row/styles.d.ts +0 -12
  192. package/dist/types/components/display-inputs-values/styles.d.ts +0 -5
  193. package/dist/types/components/display-outputs/styles.d.ts +0 -5
  194. package/dist/types/components/display-schema-tag/styles.d.ts +0 -8
  195. package/dist/types/components/display-schema-tree/styles.d.ts +0 -11
  196. package/dist/types/components/dynamic-value-input/styles.d.ts +0 -8
  197. package/dist/types/components/inputs-values/styles.d.ts +0 -6
  198. package/dist/types/components/inputs-values-tree/styles.d.ts +0 -23
  199. package/dist/types/components/json-schema-editor/styles.d.ts +0 -30
  200. package/dist/types/components/prompt-editor/styles.d.ts +0 -7
  201. package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +0 -11
  202. package/dist/types/components/prompt-editor-with-variables/editor.d.ts +0 -9
  203. package/dist/types/components/variable-selector/styles.d.ts +0 -14
  204. package/src/components/inputs-values-tree/styles.tsx +0 -128
  205. package/src/components/json-schema-editor/styles.tsx +0 -168
  206. package/src/components/prompt-editor/styles.tsx +0 -18
  207. package/src/components/prompt-editor-with-inputs/editor.tsx +0 -25
  208. package/src/components/prompt-editor-with-variables/editor.tsx +0 -20
@@ -26,15 +26,15 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  validateWhenVariableSync: ()=>validateWhenVariableSync
28
28
  });
29
- const external_lodash_es_namespaceObject = require("lodash-es");
30
29
  const editor_namespaceObject = require("@flowgram.ai/editor");
31
30
  const validateWhenVariableSync = ({ scope } = {})=>[
32
31
  {
33
32
  event: editor_namespaceObject.DataEvent.onValueInit,
34
- effect: ({ context, form })=>{
33
+ effect: ({ context, form, name })=>{
35
34
  const nodeScope = 'private' === scope ? (0, editor_namespaceObject.getNodePrivateScope)(context.node) : (0, editor_namespaceObject.getNodeScope)(context.node);
36
35
  const disposable = nodeScope.available.onListOrAnyVarChange(()=>{
37
- if (!(0, external_lodash_es_namespaceObject.isEmpty)(form.state.errors)) form.validate();
36
+ const errorKeys = Object.entries(form.state.errors || {}).filter(([_, errors])=>errors?.length > 0).filter(([key])=>key.startsWith(name) || name.startsWith(key)).map(([key])=>key);
37
+ if (errorKeys.length > 0) form.validate();
38
38
  });
39
39
  return ()=>disposable.dispose();
40
40
  }
@@ -42,7 +42,7 @@ function createInjectMaterial(Component, params) {
42
42
  const renderKey = params?.renderKey || Component.renderKey || Component.name || '';
43
43
  const InjectComponent = (props)=>{
44
44
  const container = (0, editor_namespaceObject.usePlaygroundContainer)();
45
- if (!container?.isBound(editor_namespaceObject.FlowRendererRegistry)) return /*#__PURE__*/ external_react_default().createElement(Component, {
45
+ if (!container?.isBound?.(editor_namespaceObject.FlowRendererRegistry)) return /*#__PURE__*/ external_react_default().createElement(Component, {
46
46
  ...props
47
47
  });
48
48
  const rendererRegistry = container.get(editor_namespaceObject.FlowRendererRegistry);
@@ -5,15 +5,17 @@ import { Button, Input } from "@douyinfe/semi-ui";
5
5
  import { IconDelete, IconPlus } from "@douyinfe/semi-icons";
6
6
  import { useObjectList } from "../../hooks/index.mjs";
7
7
  import { InjectVariableSelector } from "../variable-selector/index.mjs";
8
- import { UIRow, UIRows } from "./styles.mjs";
8
+ import "./styles.css";
9
9
  function BatchOutputs(props) {
10
10
  const { readonly, style } = props;
11
11
  const { list, add, updateKey, updateValue, remove } = useObjectList(props);
12
12
  return /*#__PURE__*/ jsxs("div", {
13
13
  children: [
14
- /*#__PURE__*/ jsx(UIRows, {
14
+ /*#__PURE__*/ jsx("div", {
15
+ className: "gedit-m-batch-outputs-rows",
15
16
  style: style,
16
- children: list.map((item)=>/*#__PURE__*/ jsxs(UIRow, {
17
+ children: list.map((item)=>/*#__PURE__*/ jsxs("div", {
18
+ className: "gedit-m-batch-outputs-row",
17
19
  children: [
18
20
  /*#__PURE__*/ jsx(Input, {
19
21
  style: {
@@ -0,0 +1,13 @@
1
+ .gedit-m-batch-outputs-rows {
2
+ flex-direction: column;
3
+ gap: 10px;
4
+ margin-bottom: 10px;
5
+ display: flex;
6
+ }
7
+
8
+ .gedit-m-batch-outputs-row {
9
+ align-items: center;
10
+ gap: 5px;
11
+ display: flex;
12
+ }
13
+
@@ -15,7 +15,10 @@ function BlurInput(props) {
15
15
  onChange: (value)=>{
16
16
  setValue(value);
17
17
  },
18
- onBlur: (e)=>props.onChange?.(value, e)
18
+ onBlur: (e)=>{
19
+ props.onChange?.(value, e);
20
+ props.onBlur?.(e);
21
+ }
19
22
  });
20
23
  }
21
24
  export { BlurInput };
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef } from "react";
3
- import styled_components, { css } from "styled-components";
4
3
  import { ActiveLinePlaceholder, EditorProvider, createRenderer } from "@flowgram.ai/coze-editor/react";
5
4
  import preset_code from "@flowgram.ai/coze-editor/preset-code";
6
5
  import { EditorView } from "@codemirror/view";
7
6
  import { getSuffixByLanguageId } from "./utils.mjs";
7
+ import "./styles.css";
8
8
  const OriginCodeEditor = createRenderer(preset_code, [
9
9
  EditorView.theme({
10
10
  '&.cm-focused': {
@@ -12,23 +12,28 @@ const OriginCodeEditor = createRenderer(preset_code, [
12
12
  }
13
13
  })
14
14
  ]);
15
- const UIContainer = styled_components.div`
16
- ${({ $mini })=>$mini && css`
17
- height: 24px;
18
- `}
19
- `;
20
15
  function BaseCodeEditor({ value, onChange, languageId = 'python', theme = 'light', children, placeholder, activeLinePlaceholder, options, readonly, mini }) {
21
16
  const editorRef = useRef(null);
17
+ const editorValue = String(value || '');
22
18
  useEffect(()=>{
23
- if (editorRef.current?.getValue() !== value) editorRef.current?.setValue(String(value || ''));
19
+ if (editorRef.current?.getValue() !== editorValue) {
20
+ const editorView = editorRef.current?.$view;
21
+ editorView?.dispatch({
22
+ changes: {
23
+ from: 0,
24
+ to: editorView?.state.doc.length,
25
+ insert: editorValue
26
+ }
27
+ });
28
+ }
24
29
  }, [
25
- value
30
+ editorValue
26
31
  ]);
27
- return /*#__PURE__*/ jsx(UIContainer, {
28
- $mini: mini,
32
+ return /*#__PURE__*/ jsx("div", {
33
+ className: `gedit-m-code-editor-container ${mini ? 'mini' : ''}`,
29
34
  children: /*#__PURE__*/ jsx(EditorProvider, {
30
35
  children: /*#__PURE__*/ jsxs(OriginCodeEditor, {
31
- defaultValue: String(value || ''),
36
+ defaultValue: editorValue,
32
37
  options: {
33
38
  uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
34
39
  languageId,
@@ -0,0 +1,4 @@
1
+ .gedit-m-code-editor-container.mini {
2
+ height: 24px;
3
+ }
4
+
@@ -1,13 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import "react";
3
- import styled_components from "styled-components";
4
3
  import { CodeEditor } from "../code-editor/index.mjs";
5
- const UIMini = styled_components.div`
6
- .ͼ1 .cm-content {
7
- }
8
- `;
9
4
  function CodeEditorMini(props) {
10
- return /*#__PURE__*/ jsx(UIMini, {
5
+ return /*#__PURE__*/ jsx("div", {
6
+ className: "gedit-m-code-editor-mini",
11
7
  children: /*#__PURE__*/ jsx(CodeEditor, {
12
8
  ...props,
13
9
  options: {
@@ -1,8 +1,8 @@
1
- import { useMemo } from "react";
1
+ import { useEffect, useMemo, useRef } from "react";
2
2
  import { I18n } from "@flowgram.ai/editor";
3
3
  import { useTypeManager } from "../../../plugins/index.mjs";
4
4
  import { useConditionContext } from "../context.mjs";
5
- function useCondition({ leftSchema, operator, ruleConfig }) {
5
+ function useCondition({ leftSchema, operator, onClearOp, onClearRight, ruleConfig }) {
6
6
  const typeManager = useTypeManager();
7
7
  const { rules: contextRules, ops: contextOps } = useConditionContext();
8
8
  const userRules = useMemo(()=>ruleConfig?.rules || contextRules || {}, [
@@ -35,6 +35,14 @@ function useCondition({ leftSchema, operator, ruleConfig }) {
35
35
  rule,
36
36
  allOps
37
37
  ]);
38
+ useEffect(()=>{
39
+ if (!operator || !rule) return;
40
+ if (!opOptionList.find((item)=>item.value === operator)) onClearOp?.();
41
+ }, [
42
+ operator,
43
+ opOptionList,
44
+ onClearOp
45
+ ]);
38
46
  const targetSchema = useMemo(()=>{
39
47
  const targetType = rule?.[operator || ''] || null;
40
48
  if (!targetType) return;
@@ -49,6 +57,14 @@ function useCondition({ leftSchema, operator, ruleConfig }) {
49
57
  rule,
50
58
  operator
51
59
  ]);
60
+ const prevTargetSchemaRef = useRef(void 0);
61
+ useEffect(()=>{
62
+ if (prevTargetSchemaRef.current?.type !== targetSchema?.type) onClearRight?.();
63
+ prevTargetSchemaRef.current = targetSchema;
64
+ }, [
65
+ targetSchema,
66
+ onClearRight
67
+ ]);
52
68
  const opConfig = useMemo(()=>allOps[operator || ''], [
53
69
  operator,
54
70
  allOps
@@ -7,12 +7,8 @@ import { IconChevronDownStroked } from "@douyinfe/semi-icons";
7
7
  import { InjectVariableSelector } from "../variable-selector/index.mjs";
8
8
  import { InjectDynamicValueInput } from "../dynamic-value-input/index.mjs";
9
9
  import { useCondition } from "../condition-context/index.mjs";
10
- import { UIContainer, UILeft, UIOperator, UIRight, UIValues } from "./styles.mjs";
11
- const defaultRuleConfig = {
12
- ops: {},
13
- rules: {}
14
- };
15
- function ConditionRow({ style, value, onChange, readonly, ruleConfig = defaultRuleConfig }) {
10
+ import "./styles.css";
11
+ function ConditionRow({ style, value, onChange, readonly, ruleConfig }) {
16
12
  const { left, operator, right } = value || {};
17
13
  const available = useScopeAvailable();
18
14
  const variable = useMemo(()=>{
@@ -32,7 +28,20 @@ function ConditionRow({ style, value, onChange, readonly, ruleConfig = defaultRu
32
28
  ]);
33
29
  const { rule, opConfig, opOptionList, targetSchema } = useCondition({
34
30
  leftSchema,
35
- operator
31
+ operator,
32
+ ruleConfig,
33
+ onClearOp () {
34
+ onChange({
35
+ ...value,
36
+ operator: void 0
37
+ });
38
+ },
39
+ onClearRight () {
40
+ onChange({
41
+ ...value,
42
+ right: void 0
43
+ });
44
+ }
36
45
  });
37
46
  const renderOpSelect = ()=>/*#__PURE__*/ jsx(Select, {
38
47
  style: {
@@ -56,15 +65,19 @@ function ConditionRow({ style, value, onChange, readonly, ruleConfig = defaultRu
56
65
  })
57
66
  })
58
67
  });
59
- return /*#__PURE__*/ jsxs(UIContainer, {
68
+ return /*#__PURE__*/ jsxs("div", {
69
+ className: "gedit-m-condition-row-container",
60
70
  style: style,
61
71
  children: [
62
- /*#__PURE__*/ jsx(UIOperator, {
72
+ /*#__PURE__*/ jsx("div", {
73
+ className: "gedit-m-condition-row-operator",
63
74
  children: renderOpSelect()
64
75
  }),
65
- /*#__PURE__*/ jsxs(UIValues, {
76
+ /*#__PURE__*/ jsxs("div", {
77
+ className: "gedit-m-condition-row-values",
66
78
  children: [
67
- /*#__PURE__*/ jsx(UILeft, {
79
+ /*#__PURE__*/ jsx("div", {
80
+ className: "gedit-m-condition-row-left",
68
81
  children: /*#__PURE__*/ jsx(InjectVariableSelector, {
69
82
  readonly: readonly,
70
83
  style: {
@@ -80,7 +93,8 @@ function ConditionRow({ style, value, onChange, readonly, ruleConfig = defaultRu
80
93
  })
81
94
  })
82
95
  }),
83
- /*#__PURE__*/ jsx(UIRight, {
96
+ /*#__PURE__*/ jsx("div", {
97
+ className: "gedit-m-condition-row-right",
84
98
  children: targetSchema ? /*#__PURE__*/ jsx(InjectDynamicValueInput, {
85
99
  readonly: readonly || !rule,
86
100
  value: right,
@@ -0,0 +1,19 @@
1
+ .gedit-m-condition-row-container {
2
+ align-items: center;
3
+ gap: 4px;
4
+ display: flex;
5
+ }
6
+
7
+ .gedit-m-condition-row-left, .gedit-m-condition-row-right {
8
+ width: 100%;
9
+ }
10
+
11
+ .gedit-m-condition-row-values {
12
+ flex-direction: column;
13
+ flex-grow: 1;
14
+ align-items: center;
15
+ gap: 4px;
16
+ display: flex;
17
+ overflow: hidden;
18
+ }
19
+
@@ -1,12 +1,12 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useState } from "react";
3
3
  import { isPlainObject, last } from "lodash-es";
4
- import { ASTMatch, useScopeAvailable } from "@flowgram.ai/editor";
4
+ import { ASTMatch, useCurrentScope } from "@flowgram.ai/editor";
5
5
  import { Mention, PositionMirror, getCurrentMentionReplaceRange, useEditor } from "@flowgram.ai/coze-editor/react";
6
6
  import { Popover, Tree } from "@douyinfe/semi-ui";
7
7
  import { FlowValueUtils } from "../../../shared/index.mjs";
8
8
  function InputsPicker({ inputsValues, onSelect }) {
9
- const available = useScopeAvailable();
9
+ const scope = useCurrentScope();
10
10
  const getArrayDrilldown = (type, depth = 1)=>{
11
11
  if (ASTMatch.isArray(type.items)) return getArrayDrilldown(type.items, depth + 1);
12
12
  return {
@@ -41,7 +41,7 @@ function InputsPicker({ inputsValues, onSelect }) {
41
41
  const currKey = keyPath.join('.');
42
42
  if (FlowValueUtils.isFlowValue(value)) {
43
43
  if (FlowValueUtils.isRef(value)) {
44
- const variable = available.getByKeyPath(value.content || []);
44
+ const variable = scope?.available?.getByKeyPath(value.content || []);
45
45
  if (variable) return renderVariable(variable, keyPath);
46
46
  }
47
47
  return {
@@ -3,11 +3,11 @@ import { useLayoutEffect } from "react";
3
3
  import { isEqual, last } from "lodash-es";
4
4
  import { Disposable, DisposableCollection, useCurrentScope } from "@flowgram.ai/editor";
5
5
  import { useInjector } from "@flowgram.ai/coze-editor/react";
6
- import { Popover } from "@douyinfe/semi-ui";
6
+ import { Popover, Tag } from "@douyinfe/semi-ui";
7
7
  import { IconIssueStroked } from "@douyinfe/semi-icons";
8
8
  import { Decoration, EditorView, MatchDecorator, ViewPlugin, WidgetType } from "@codemirror/view";
9
9
  import { polyfillCreateRoot } from "../../../shared/index.mjs";
10
- import { UIPopoverContent, UIRootTitle, UITag, UIVarName } from "../styles.mjs";
10
+ import "../styles.css";
11
11
  class VariableTagWidget extends WidgetType {
12
12
  constructor({ keyPath, scope }){
13
13
  super(), this.toDispose = new DisposableCollection(), this.renderIcon = (icon)=>{
@@ -25,32 +25,50 @@ class VariableTagWidget extends WidgetType {
25
25
  this.scope = scope;
26
26
  }
27
27
  renderVariable(v) {
28
- if (!v) return void this.root.render(/*#__PURE__*/ jsx(UITag, {
29
- prefixIcon: /*#__PURE__*/ jsx(IconIssueStroked, {}),
28
+ if (!v) return void this.root.render(/*#__PURE__*/ jsxs(Tag, {
29
+ className: "gedit-m-coze-editor-tag",
30
30
  color: "amber",
31
- children: "Unknown"
31
+ children: [
32
+ /*#__PURE__*/ jsx(IconIssueStroked, {
33
+ style: {
34
+ marginRight: '4px'
35
+ }
36
+ }),
37
+ /*#__PURE__*/ jsx("span", {
38
+ children: "Unknown"
39
+ })
40
+ ]
32
41
  }));
33
42
  const rootField = last(v.parentFields) || v;
34
43
  const isRoot = v === rootField;
35
- const rootTitle = /*#__PURE__*/ jsx(UIRootTitle, {
44
+ const rootTitle = /*#__PURE__*/ jsx("span", {
45
+ className: "gedit-m-coze-editor-root-title",
36
46
  children: rootField.meta?.title ? `${rootField.meta.title} ${isRoot ? '' : '-'} ` : ''
37
47
  });
38
48
  const rootIcon = this.renderIcon(rootField?.meta.icon);
39
49
  this.root.render(/*#__PURE__*/ jsx(Popover, {
40
- content: /*#__PURE__*/ jsxs(UIPopoverContent, {
50
+ content: /*#__PURE__*/ jsxs("div", {
51
+ className: "gedit-m-coze-editor-popover-content",
41
52
  children: [
42
53
  rootIcon,
43
54
  rootTitle,
44
- /*#__PURE__*/ jsx(UIVarName, {
55
+ /*#__PURE__*/ jsx("span", {
56
+ className: "gedit-m-coze-editor-var-name",
45
57
  children: v?.keyPath.slice(1).join('.')
46
58
  })
47
59
  ]
48
60
  }),
49
- children: /*#__PURE__*/ jsxs(UITag, {
50
- prefixIcon: rootIcon,
61
+ children: /*#__PURE__*/ jsxs(Tag, {
62
+ className: "gedit-m-coze-editor-tag",
63
+ style: {
64
+ display: 'inline-flex',
65
+ alignItems: 'center'
66
+ },
51
67
  children: [
68
+ rootIcon,
52
69
  rootTitle,
53
- !isRoot && /*#__PURE__*/ jsx(UIVarName, {
70
+ !isRoot && /*#__PURE__*/ jsx("span", {
71
+ className: "gedit-m-coze-editor-var-name",
54
72
  children: v?.key
55
73
  })
56
74
  ]
@@ -63,12 +81,21 @@ class VariableTagWidget extends WidgetType {
63
81
  this.toDispose.push(Disposable.create(()=>{
64
82
  this.root.unmount();
65
83
  }));
66
- this.toDispose.push(this.scope.available.trackByKeyPath(this.keyPath, (v)=>{
67
- this.renderVariable(v);
68
- }, {
84
+ const refresh = ()=>{
85
+ this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
86
+ };
87
+ this.toDispose.push(this.scope.available.trackByKeyPath(this.keyPath, refresh, {
88
+ triggerOnInit: false
89
+ }));
90
+ if (this.keyPath?.[0]) this.toDispose.push(this.scope.available.trackByKeyPath([
91
+ this.keyPath[0]
92
+ ], refresh, {
93
+ selector: (curr)=>({
94
+ ...curr?.meta
95
+ }),
69
96
  triggerOnInit: false
70
97
  }));
71
- this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
98
+ refresh();
72
99
  return dom;
73
100
  }
74
101
  eq(other) {
@@ -83,7 +110,9 @@ class VariableTagWidget extends WidgetType {
83
110
  }
84
111
  function VariableTagInject() {
85
112
  const injector = useInjector();
86
- const scope = useCurrentScope();
113
+ const scope = useCurrentScope({
114
+ strict: true
115
+ });
87
116
  useLayoutEffect(()=>{
88
117
  const atMatcher = new MatchDecorator({
89
118
  regexp: /\{\{([^\}\{]+)\}\}/g,
@@ -0,0 +1,37 @@
1
+ .gedit-m-coze-editor-root-title {
2
+ text-overflow: ellipsis;
3
+ white-space: nowrap;
4
+ min-width: 20px;
5
+ color: var(--semi-color-text-2);
6
+ margin-right: 4px;
7
+ overflow: hidden;
8
+ }
9
+
10
+ .gedit-m-coze-editor-var-name {
11
+ text-overflow: ellipsis;
12
+ white-space: nowrap;
13
+ overflow: hidden;
14
+ }
15
+
16
+ .gedit-m-coze-editor-tag {
17
+ justify-content: flex-start;
18
+ align-items: center;
19
+ max-width: 300px;
20
+ display: inline-flex;
21
+
22
+ & .semi-tag-content-center {
23
+ justify-content: flex-start;
24
+ }
25
+
26
+ &.semi-tag {
27
+ margin: 0 5px;
28
+ }
29
+ }
30
+
31
+ .gedit-m-coze-editor-popover-content {
32
+ justify-content: flex-start;
33
+ align-items: center;
34
+ padding: 10px;
35
+ display: inline-flex;
36
+ }
37
+
@@ -6,12 +6,8 @@ import { IconChevronDownStroked } from "@douyinfe/semi-icons";
6
6
  import { useTypeManager } from "../../plugins/index.mjs";
7
7
  import { InjectDynamicValueInput } from "../dynamic-value-input/index.mjs";
8
8
  import { useCondition } from "../condition-context/index.mjs";
9
- import { UIContainer, UILeft, UIOperator, UIOptionLabel, UIRight, UISelect, UIValues } from "./styles.mjs";
10
- const defaultRuleConfig = {
11
- ops: {},
12
- rules: {}
13
- };
14
- function DBConditionRow({ style, value, onChange, readonly, options, ruleConfig = defaultRuleConfig }) {
9
+ import "./styles.css";
10
+ function DBConditionRow({ style, value, onChange, readonly, options, ruleConfig }) {
15
11
  const { left, operator, right } = value || {};
16
12
  const typeManager = useTypeManager();
17
13
  const leftSchema = useMemo(()=>options?.find((item)=>item.value === left)?.schema, [
@@ -21,9 +17,22 @@ function DBConditionRow({ style, value, onChange, readonly, options, ruleConfig
21
17
  const { opConfig, rule, opOptionList, targetSchema } = useCondition({
22
18
  leftSchema,
23
19
  operator,
24
- ruleConfig
20
+ ruleConfig,
21
+ onClearOp () {
22
+ onChange({
23
+ ...value,
24
+ operator: void 0
25
+ });
26
+ },
27
+ onClearRight () {
28
+ onChange({
29
+ ...value,
30
+ right: void 0
31
+ });
32
+ }
25
33
  });
26
- const renderDBOptionSelect = ()=>/*#__PURE__*/ jsx(UISelect, {
34
+ const renderDBOptionSelect = ()=>/*#__PURE__*/ jsx(Select, {
35
+ className: "gedit-m-db-condition-row-select",
27
36
  disabled: readonly,
28
37
  size: "small",
29
38
  style: {
@@ -35,7 +44,8 @@ function DBConditionRow({ style, value, onChange, readonly, options, ruleConfig
35
44
  left: v
36
45
  }),
37
46
  optionList: options?.map((item)=>({
38
- label: /*#__PURE__*/ jsxs(UIOptionLabel, {
47
+ label: /*#__PURE__*/ jsxs("div", {
48
+ className: "gedit-m-db-condition-row-option-label",
39
49
  children: [
40
50
  /*#__PURE__*/ jsx(Icon, {
41
51
  size: "small",
@@ -69,18 +79,23 @@ function DBConditionRow({ style, value, onChange, readonly, options, ruleConfig
69
79
  })
70
80
  })
71
81
  });
72
- return /*#__PURE__*/ jsxs(UIContainer, {
82
+ return /*#__PURE__*/ jsxs("div", {
83
+ className: "gedit-m-db-condition-row-container",
73
84
  style: style,
74
85
  children: [
75
- /*#__PURE__*/ jsx(UIOperator, {
86
+ /*#__PURE__*/ jsx("div", {
87
+ className: "gedit-m-db-condition-row-operator",
76
88
  children: renderOpSelect()
77
89
  }),
78
- /*#__PURE__*/ jsxs(UIValues, {
90
+ /*#__PURE__*/ jsxs("div", {
91
+ className: "gedit-m-db-condition-row-values",
79
92
  children: [
80
- /*#__PURE__*/ jsx(UILeft, {
93
+ /*#__PURE__*/ jsx("div", {
94
+ className: "gedit-m-db-condition-row-left",
81
95
  children: renderDBOptionSelect()
82
96
  }),
83
- /*#__PURE__*/ jsx(UIRight, {
97
+ /*#__PURE__*/ jsx("div", {
98
+ className: "gedit-m-db-condition-row-right",
84
99
  children: targetSchema ? /*#__PURE__*/ jsx(InjectDynamicValueInput, {
85
100
  readonly: readonly || !rule,
86
101
  value: right,
@@ -0,0 +1,30 @@
1
+ .gedit-m-db-condition-row-container {
2
+ align-items: center;
3
+ gap: 4px;
4
+ display: flex;
5
+ }
6
+
7
+ .gedit-m-db-condition-row-left, .gedit-m-db-condition-row-right {
8
+ width: 100%;
9
+ }
10
+
11
+ .gedit-m-db-condition-row-values {
12
+ flex-direction: column;
13
+ flex-grow: 1;
14
+ align-items: center;
15
+ gap: 4px;
16
+ display: flex;
17
+ }
18
+
19
+ .gedit-m-db-condition-row-option-label {
20
+ align-items: center;
21
+ gap: 10px;
22
+ display: flex;
23
+ }
24
+
25
+ .gedit-m-db-condition-row-select {
26
+ & .semi-select-selection {
27
+ margin-left: 5px;
28
+ }
29
+ }
30
+
@@ -4,11 +4,12 @@ import { isPlainObject } from "lodash-es";
4
4
  import { useScopeAvailable } from "@flowgram.ai/editor";
5
5
  import { FlowValueUtils } from "../../shared/index.mjs";
6
6
  import { DisplayFlowValue } from "../display-flow-value/index.mjs";
7
- import { DisplayInputsWrapper } from "./styles.mjs";
7
+ import "./styles.css";
8
8
  import { DisplaySchemaTag } from "../display-schema-tag/index.mjs";
9
9
  function DisplayInputsValues({ value, showIconInTree }) {
10
10
  const childEntries = Object.entries(value || {});
11
- return /*#__PURE__*/ jsx(DisplayInputsWrapper, {
11
+ return /*#__PURE__*/ jsx("div", {
12
+ className: "gedit-m-display-inputs-wrapper",
12
13
  children: childEntries.map(([key, value])=>{
13
14
  if (FlowValueUtils.isFlowValue(value)) return /*#__PURE__*/ jsx(DisplayFlowValue, {
14
15
  title: key,
@@ -0,0 +1,6 @@
1
+ .gedit-m-display-inputs-wrapper {
2
+ flex-wrap: wrap;
3
+ gap: 5px;
4
+ display: flex;
5
+ }
6
+
@@ -3,12 +3,12 @@ import { useEffect } from "react";
3
3
  import { JsonSchemaUtils } from "@flowgram.ai/json-schema";
4
4
  import { useCurrentScope, useRefresh } from "@flowgram.ai/editor";
5
5
  import { DisplaySchemaTag } from "../display-schema-tag/index.mjs";
6
- import { DisplayOutputsWrapper } from "./styles.mjs";
6
+ import "./styles.css";
7
7
  function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
8
8
  const scope = useCurrentScope();
9
9
  const refresh = useRefresh();
10
10
  useEffect(()=>{
11
- if (!displayFromScope) return ()=>null;
11
+ if (!displayFromScope || !scope) return ()=>null;
12
12
  const disposable = scope.output.onListOrAnyVarChange(()=>{
13
13
  refresh();
14
14
  });
@@ -18,7 +18,7 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
18
18
  }, [
19
19
  displayFromScope
20
20
  ]);
21
- const properties = displayFromScope ? scope.output.variables?.reduce((acm, curr)=>{
21
+ const properties = displayFromScope ? (scope?.output.variables || []).reduce((acm, curr)=>{
22
22
  acm = {
23
23
  ...acm,
24
24
  ...JsonSchemaUtils.astToSchema(curr.type)?.properties || {}
@@ -26,7 +26,8 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
26
26
  return acm;
27
27
  }, {}) : value?.properties || {};
28
28
  const childEntries = Object.entries(properties || {});
29
- return /*#__PURE__*/ jsx(DisplayOutputsWrapper, {
29
+ return /*#__PURE__*/ jsx("div", {
30
+ className: "gedit-m-display-outputs-wrapper",
30
31
  children: childEntries.map(([key, schema])=>/*#__PURE__*/ jsx(DisplaySchemaTag, {
31
32
  title: key,
32
33
  value: schema,
@@ -0,0 +1,6 @@
1
+ .gedit-m-display-outputs-wrapper {
2
+ flex-wrap: wrap;
3
+ gap: 5px;
4
+ display: flex;
5
+ }
6
+