@flowgram.ai/form-materials 0.2.29 → 0.2.31
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.
- package/dist/esm/index.js +116 -57
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +144 -81
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/code-editor/index.tsx +7 -0
- package/src/components/code-editor/language-features.ts +22 -1
- package/src/components/condition-row/constants.ts +2 -8
- package/src/components/inputs-values/components/blur-input.tsx +27 -0
- package/src/components/inputs-values/index.tsx +16 -3
- package/src/components/inputs-values/types.ts +2 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +6 -3
- package/src/components/variable-selector/index.tsx +4 -2
- package/src/components/variable-selector/use-variable-tree.tsx +6 -3
- package/src/hooks/use-object-list/index.tsx +16 -3
- package/src/typings/flow-value/index.ts +8 -0
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import React$1 from 'react';
|
|
|
2
2
|
import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
3
3
|
import { InferValues } from '@coze-editor/editor/react';
|
|
4
4
|
import preset from '@coze-editor/editor/preset-code';
|
|
5
|
-
import { EffectOptions, ASTNodeJSON, ASTNode, BaseType, FormPluginCreator } from '@flowgram.ai/editor';
|
|
5
|
+
import { BaseVariableField, EffectOptions, ASTNodeJSON, ASTNode, BaseType, FormPluginCreator } from '@flowgram.ai/editor';
|
|
6
6
|
import * as _flowgram_ai_node from '@flowgram.ai/node';
|
|
7
7
|
import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
8
8
|
|
|
@@ -36,9 +36,14 @@ type IBasicJsonSchema = IJsonSchema<JsonSchemaBasicType>;
|
|
|
36
36
|
* SPDX-License-Identifier: MIT
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
+
type VariableField = BaseVariableField<{
|
|
40
|
+
icon?: string | JSX.Element;
|
|
41
|
+
title?: string;
|
|
42
|
+
}>;
|
|
39
43
|
declare function useVariableTree(params: {
|
|
40
44
|
includeSchema?: IJsonSchema | IJsonSchema[];
|
|
41
45
|
excludeSchema?: IJsonSchema | IJsonSchema[];
|
|
46
|
+
customSkip?: (variable: VariableField) => boolean;
|
|
42
47
|
}): TreeNodeData[];
|
|
43
48
|
|
|
44
49
|
/**
|
|
@@ -69,22 +74,29 @@ declare const VariableSelector: ({ value, config, onChange, style, readonly, inc
|
|
|
69
74
|
* SPDX-License-Identifier: MIT
|
|
70
75
|
*/
|
|
71
76
|
|
|
77
|
+
interface IFlowValueExtra {
|
|
78
|
+
index?: number;
|
|
79
|
+
}
|
|
72
80
|
interface IFlowConstantValue {
|
|
73
81
|
type: 'constant';
|
|
74
82
|
content?: string | number | boolean;
|
|
75
83
|
schema?: IJsonSchema;
|
|
84
|
+
extra?: IFlowValueExtra;
|
|
76
85
|
}
|
|
77
86
|
interface IFlowRefValue {
|
|
78
87
|
type: 'ref';
|
|
79
88
|
content?: string[];
|
|
89
|
+
extra?: IFlowValueExtra;
|
|
80
90
|
}
|
|
81
91
|
interface IFlowExpressionValue {
|
|
82
92
|
type: 'expression';
|
|
83
93
|
content?: string;
|
|
94
|
+
extra?: IFlowValueExtra;
|
|
84
95
|
}
|
|
85
96
|
interface IFlowTemplateValue {
|
|
86
97
|
type: 'template';
|
|
87
98
|
content?: string;
|
|
99
|
+
extra?: IFlowValueExtra;
|
|
88
100
|
}
|
|
89
101
|
type IFlowValue = IFlowConstantValue | IFlowRefValue | IFlowExpressionValue | IFlowTemplateValue;
|
|
90
102
|
type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
|
|
@@ -342,6 +354,7 @@ interface PropsType {
|
|
|
342
354
|
onChange: (value?: Record<string, IFlowValue | undefined>) => void;
|
|
343
355
|
readonly?: boolean;
|
|
344
356
|
hasError?: boolean;
|
|
357
|
+
schema?: IJsonSchema;
|
|
345
358
|
style?: React.CSSProperties;
|
|
346
359
|
constantProps?: {
|
|
347
360
|
strategies?: Strategy[];
|
|
@@ -354,7 +367,7 @@ interface PropsType {
|
|
|
354
367
|
* SPDX-License-Identifier: MIT
|
|
355
368
|
*/
|
|
356
369
|
|
|
357
|
-
declare function InputsValues({ value, onChange, style, readonly, constantProps }: PropsType): React$1.JSX.Element;
|
|
370
|
+
declare function InputsValues({ value, onChange, style, readonly, constantProps, schema, hasError, }: PropsType): React$1.JSX.Element;
|
|
358
371
|
|
|
359
372
|
/**
|
|
360
373
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
@@ -537,4 +550,4 @@ interface InputConfig {
|
|
|
537
550
|
}
|
|
538
551
|
declare const createInferInputsPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig>;
|
|
539
552
|
|
|
540
|
-
export { ArrayIcons, BatchOutputs, BatchVariableSelector, CodeEditor, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, DynamicValueInput, type IBasicJsonSchema, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IJsonSchema, InputsValues, JsonEditorWithVariables, type JsonSchemaBasicType, JsonSchemaEditor, JsonSchemaUtils, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, VariableTypeIcons, autoRenameRefEffect, createBatchOutputsFormPlugin, createInferInputsPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getSchemaIcon, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useVariableTree };
|
|
553
|
+
export { ArrayIcons, BatchOutputs, BatchVariableSelector, CodeEditor, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, DynamicValueInput, type IBasicJsonSchema, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, type IJsonSchema, InputsValues, JsonEditorWithVariables, type JsonSchemaBasicType, JsonSchemaEditor, JsonSchemaUtils, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, VariableTypeIcons, autoRenameRefEffect, createBatchOutputsFormPlugin, createInferInputsPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getSchemaIcon, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useVariableTree };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React$1 from 'react';
|
|
|
2
2
|
import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
3
3
|
import { InferValues } from '@coze-editor/editor/react';
|
|
4
4
|
import preset from '@coze-editor/editor/preset-code';
|
|
5
|
-
import { EffectOptions, ASTNodeJSON, ASTNode, BaseType, FormPluginCreator } from '@flowgram.ai/editor';
|
|
5
|
+
import { BaseVariableField, EffectOptions, ASTNodeJSON, ASTNode, BaseType, FormPluginCreator } from '@flowgram.ai/editor';
|
|
6
6
|
import * as _flowgram_ai_node from '@flowgram.ai/node';
|
|
7
7
|
import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
8
8
|
|
|
@@ -36,9 +36,14 @@ type IBasicJsonSchema = IJsonSchema<JsonSchemaBasicType>;
|
|
|
36
36
|
* SPDX-License-Identifier: MIT
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
+
type VariableField = BaseVariableField<{
|
|
40
|
+
icon?: string | JSX.Element;
|
|
41
|
+
title?: string;
|
|
42
|
+
}>;
|
|
39
43
|
declare function useVariableTree(params: {
|
|
40
44
|
includeSchema?: IJsonSchema | IJsonSchema[];
|
|
41
45
|
excludeSchema?: IJsonSchema | IJsonSchema[];
|
|
46
|
+
customSkip?: (variable: VariableField) => boolean;
|
|
42
47
|
}): TreeNodeData[];
|
|
43
48
|
|
|
44
49
|
/**
|
|
@@ -69,22 +74,29 @@ declare const VariableSelector: ({ value, config, onChange, style, readonly, inc
|
|
|
69
74
|
* SPDX-License-Identifier: MIT
|
|
70
75
|
*/
|
|
71
76
|
|
|
77
|
+
interface IFlowValueExtra {
|
|
78
|
+
index?: number;
|
|
79
|
+
}
|
|
72
80
|
interface IFlowConstantValue {
|
|
73
81
|
type: 'constant';
|
|
74
82
|
content?: string | number | boolean;
|
|
75
83
|
schema?: IJsonSchema;
|
|
84
|
+
extra?: IFlowValueExtra;
|
|
76
85
|
}
|
|
77
86
|
interface IFlowRefValue {
|
|
78
87
|
type: 'ref';
|
|
79
88
|
content?: string[];
|
|
89
|
+
extra?: IFlowValueExtra;
|
|
80
90
|
}
|
|
81
91
|
interface IFlowExpressionValue {
|
|
82
92
|
type: 'expression';
|
|
83
93
|
content?: string;
|
|
94
|
+
extra?: IFlowValueExtra;
|
|
84
95
|
}
|
|
85
96
|
interface IFlowTemplateValue {
|
|
86
97
|
type: 'template';
|
|
87
98
|
content?: string;
|
|
99
|
+
extra?: IFlowValueExtra;
|
|
88
100
|
}
|
|
89
101
|
type IFlowValue = IFlowConstantValue | IFlowRefValue | IFlowExpressionValue | IFlowTemplateValue;
|
|
90
102
|
type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
|
|
@@ -342,6 +354,7 @@ interface PropsType {
|
|
|
342
354
|
onChange: (value?: Record<string, IFlowValue | undefined>) => void;
|
|
343
355
|
readonly?: boolean;
|
|
344
356
|
hasError?: boolean;
|
|
357
|
+
schema?: IJsonSchema;
|
|
345
358
|
style?: React.CSSProperties;
|
|
346
359
|
constantProps?: {
|
|
347
360
|
strategies?: Strategy[];
|
|
@@ -354,7 +367,7 @@ interface PropsType {
|
|
|
354
367
|
* SPDX-License-Identifier: MIT
|
|
355
368
|
*/
|
|
356
369
|
|
|
357
|
-
declare function InputsValues({ value, onChange, style, readonly, constantProps }: PropsType): React$1.JSX.Element;
|
|
370
|
+
declare function InputsValues({ value, onChange, style, readonly, constantProps, schema, hasError, }: PropsType): React$1.JSX.Element;
|
|
358
371
|
|
|
359
372
|
/**
|
|
360
373
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
@@ -537,4 +550,4 @@ interface InputConfig {
|
|
|
537
550
|
}
|
|
538
551
|
declare const createInferInputsPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig>;
|
|
539
552
|
|
|
540
|
-
export { ArrayIcons, BatchOutputs, BatchVariableSelector, CodeEditor, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, DynamicValueInput, type IBasicJsonSchema, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IJsonSchema, InputsValues, JsonEditorWithVariables, type JsonSchemaBasicType, JsonSchemaEditor, JsonSchemaUtils, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, VariableTypeIcons, autoRenameRefEffect, createBatchOutputsFormPlugin, createInferInputsPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getSchemaIcon, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useVariableTree };
|
|
553
|
+
export { ArrayIcons, BatchOutputs, BatchVariableSelector, CodeEditor, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, DynamicValueInput, type IBasicJsonSchema, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IFlowValueExtra, type IJsonSchema, InputsValues, JsonEditorWithVariables, type JsonSchemaBasicType, JsonSchemaEditor, JsonSchemaUtils, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, VariableTypeIcons, autoRenameRefEffect, createBatchOutputsFormPlugin, createInferInputsPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getSchemaIcon, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useVariableTree };
|
package/dist/index.js
CHANGED
|
@@ -67,6 +67,10 @@ __export(src_exports, {
|
|
|
67
67
|
});
|
|
68
68
|
module.exports = __toCommonJS(src_exports);
|
|
69
69
|
|
|
70
|
+
// ../../../common/temp/node_modules/.pnpm/tsup@8.3.5_typescript@5.8.3/node_modules/tsup/assets/cjs_shims.js
|
|
71
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
72
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
73
|
+
|
|
70
74
|
// src/components/variable-selector/index.tsx
|
|
71
75
|
var import_react3 = __toESM(require("react"));
|
|
72
76
|
var import_semi_ui3 = require("@douyinfe/semi-ui");
|
|
@@ -593,7 +597,7 @@ var JsonSchemaUtils;
|
|
|
593
597
|
|
|
594
598
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
595
599
|
function useVariableTree(params) {
|
|
596
|
-
const { includeSchema, excludeSchema } = params;
|
|
600
|
+
const { includeSchema, excludeSchema, customSkip } = params;
|
|
597
601
|
const variables = (0, import_editor2.useAvailableVariables)();
|
|
598
602
|
const getVariableTypeIcon = (0, import_react2.useCallback)((variable) => {
|
|
599
603
|
if (variable.meta?.icon) {
|
|
@@ -630,7 +634,8 @@ function useVariableTree(params) {
|
|
|
630
634
|
const key = keyPath.join(".");
|
|
631
635
|
const isSchemaInclude = includeSchema ? JsonSchemaUtils.isASTMatchSchema(type, includeSchema) : true;
|
|
632
636
|
const isSchemaExclude = excludeSchema ? JsonSchemaUtils.isASTMatchSchema(type, excludeSchema) : false;
|
|
633
|
-
const
|
|
637
|
+
const isCustomSkip = customSkip ? customSkip(variable) : false;
|
|
638
|
+
const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip;
|
|
634
639
|
if (!isSchemaMatch && !children?.length) {
|
|
635
640
|
return null;
|
|
636
641
|
}
|
|
@@ -642,7 +647,8 @@ function useVariableTree(params) {
|
|
|
642
647
|
icon: getVariableTypeIcon(variable),
|
|
643
648
|
children,
|
|
644
649
|
disabled: !isSchemaMatch,
|
|
645
|
-
rootMeta: parentFields[0]?.meta
|
|
650
|
+
rootMeta: parentFields[0]?.meta || variable.meta,
|
|
651
|
+
isRoot: !parentFields?.length
|
|
646
652
|
};
|
|
647
653
|
};
|
|
648
654
|
return [...variables.slice(0).reverse()].map((_variable) => renderVariable(_variable)).filter(Boolean);
|
|
@@ -765,7 +771,7 @@ var VariableSelector = ({
|
|
|
765
771
|
);
|
|
766
772
|
}
|
|
767
773
|
const rootIcon = renderIcon(_option.rootMeta?.icon || _option?.icon);
|
|
768
|
-
const rootTitle = /* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title}
|
|
774
|
+
const rootTitle = /* @__PURE__ */ import_react3.default.createElement(UIRootTitle, null, _option.rootMeta?.title ? `${_option.rootMeta?.title} ${_option.isRoot ? "" : "-"} ` : null);
|
|
769
775
|
return /* @__PURE__ */ import_react3.default.createElement("div", null, /* @__PURE__ */ import_react3.default.createElement(
|
|
770
776
|
import_semi_ui3.Popover,
|
|
771
777
|
{
|
|
@@ -779,7 +785,7 @@ var VariableSelector = ({
|
|
|
779
785
|
onClose: () => onChange(void 0)
|
|
780
786
|
},
|
|
781
787
|
rootTitle,
|
|
782
|
-
/* @__PURE__ */ import_react3.default.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
788
|
+
!_option.isRoot && /* @__PURE__ */ import_react3.default.createElement(UIVarName, { $inSelector: true }, _option.label)
|
|
783
789
|
)
|
|
784
790
|
));
|
|
785
791
|
},
|
|
@@ -1806,8 +1812,8 @@ var rules = {
|
|
|
1806
1812
|
["not_contains" /* NOT_CONTAINS */]: "string",
|
|
1807
1813
|
["in" /* IN */]: "array",
|
|
1808
1814
|
["nin" /* NIN */]: "array",
|
|
1809
|
-
["is_empty" /* IS_EMPTY */]:
|
|
1810
|
-
["is_not_empty" /* IS_NOT_EMPTY */]:
|
|
1815
|
+
["is_empty" /* IS_EMPTY */]: null,
|
|
1816
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1811
1817
|
},
|
|
1812
1818
|
number: {
|
|
1813
1819
|
["eq" /* EQ */]: "number",
|
|
@@ -1817,9 +1823,7 @@ var rules = {
|
|
|
1817
1823
|
["lt" /* LT */]: "number",
|
|
1818
1824
|
["lte" /* LTE */]: "number",
|
|
1819
1825
|
["in" /* IN */]: "array",
|
|
1820
|
-
["nin" /* NIN */]: "array"
|
|
1821
|
-
["is_empty" /* IS_EMPTY */]: null,
|
|
1822
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1826
|
+
["nin" /* NIN */]: "array"
|
|
1823
1827
|
},
|
|
1824
1828
|
integer: {
|
|
1825
1829
|
["eq" /* EQ */]: "number",
|
|
@@ -1829,9 +1833,7 @@ var rules = {
|
|
|
1829
1833
|
["lt" /* LT */]: "number",
|
|
1830
1834
|
["lte" /* LTE */]: "number",
|
|
1831
1835
|
["in" /* IN */]: "array",
|
|
1832
|
-
["nin" /* NIN */]: "array"
|
|
1833
|
-
["is_empty" /* IS_EMPTY */]: null,
|
|
1834
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1836
|
+
["nin" /* NIN */]: "array"
|
|
1835
1837
|
},
|
|
1836
1838
|
boolean: {
|
|
1837
1839
|
["eq" /* EQ */]: "boolean",
|
|
@@ -1839,9 +1841,7 @@ var rules = {
|
|
|
1839
1841
|
["is_true" /* IS_TRUE */]: null,
|
|
1840
1842
|
["is_false" /* IS_FALSE */]: null,
|
|
1841
1843
|
["in" /* IN */]: "array",
|
|
1842
|
-
["nin" /* NIN */]: "array"
|
|
1843
|
-
["is_empty" /* IS_EMPTY */]: null,
|
|
1844
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1844
|
+
["nin" /* NIN */]: "array"
|
|
1845
1845
|
},
|
|
1846
1846
|
object: {
|
|
1847
1847
|
["is_empty" /* IS_EMPTY */]: null,
|
|
@@ -2023,12 +2023,13 @@ function genId2() {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
function useObjectList({
|
|
2025
2025
|
value,
|
|
2026
|
-
onChange
|
|
2026
|
+
onChange,
|
|
2027
|
+
sortIndexKey
|
|
2027
2028
|
}) {
|
|
2028
2029
|
const [list, setList] = (0, import_react16.useState)([]);
|
|
2029
2030
|
(0, import_react16.useEffect)(() => {
|
|
2030
2031
|
setList((_prevList) => {
|
|
2031
|
-
const newKeys = Object.
|
|
2032
|
+
const newKeys = Object.entries(value || {}).sort((a, b) => (0, import_lodash4.get)(a[1], sortIndexKey || 0) - (0, import_lodash4.get)(b[1], sortIndexKey || 0)).map(([key]) => key);
|
|
2032
2033
|
const oldKeys = _prevList.map((item) => item.key).filter(Boolean);
|
|
2033
2034
|
const addKeys = (0, import_lodash4.difference)(newKeys, oldKeys);
|
|
2034
2035
|
return _prevList.filter((item) => !item.key || newKeys.includes(item.key)).map((item) => ({
|
|
@@ -2065,7 +2066,12 @@ function useObjectList({
|
|
|
2065
2066
|
});
|
|
2066
2067
|
onChange(
|
|
2067
2068
|
Object.fromEntries(
|
|
2068
|
-
nextList.filter((item) => item.key).map((item) => [item.key, item.value])
|
|
2069
|
+
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
2070
|
+
if ((0, import_lodash4.isObject)(_res[1]) && sortIndexKey) {
|
|
2071
|
+
(0, import_lodash4.set)(_res[1], sortIndexKey, idx);
|
|
2072
|
+
}
|
|
2073
|
+
return _res;
|
|
2074
|
+
})
|
|
2069
2075
|
)
|
|
2070
2076
|
);
|
|
2071
2077
|
return nextList;
|
|
@@ -2452,8 +2458,9 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2452
2458
|
);
|
|
2453
2459
|
return;
|
|
2454
2460
|
}
|
|
2455
|
-
const rootField = (0, import_lodash5.last)(v.parentFields);
|
|
2456
|
-
const
|
|
2461
|
+
const rootField = (0, import_lodash5.last)(v.parentFields) || v;
|
|
2462
|
+
const isRoot = v.parentFields.length === 0;
|
|
2463
|
+
const rootTitle = /* @__PURE__ */ import_react28.default.createElement(UIRootTitle2, null, rootField?.meta.title ? `${rootField.meta.title} ${isRoot ? "" : "-"} ` : "");
|
|
2457
2464
|
const rootIcon = this.renderIcon(rootField?.meta.icon);
|
|
2458
2465
|
this.renderReact(
|
|
2459
2466
|
/* @__PURE__ */ import_react28.default.createElement(
|
|
@@ -2461,7 +2468,7 @@ var VariableTagWidget = class extends import_view3.WidgetType {
|
|
|
2461
2468
|
{
|
|
2462
2469
|
content: /* @__PURE__ */ import_react28.default.createElement(UIPopoverContent2, null, rootIcon, rootTitle, /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.keyPath.slice(1).join(".")))
|
|
2463
2470
|
},
|
|
2464
|
-
/* @__PURE__ */ import_react28.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.key))
|
|
2471
|
+
/* @__PURE__ */ import_react28.default.createElement(UITag2, { prefixIcon: rootIcon }, rootTitle, !isRoot && /* @__PURE__ */ import_react28.default.createElement(UIVarName2, null, v?.key))
|
|
2465
2472
|
)
|
|
2466
2473
|
);
|
|
2467
2474
|
}
|
|
@@ -2688,11 +2695,47 @@ function getSuffixByLanguageId(languageId) {
|
|
|
2688
2695
|
return "";
|
|
2689
2696
|
}
|
|
2690
2697
|
|
|
2698
|
+
// src/components/code-editor/language-features.ts
|
|
2699
|
+
var import_preset_code = require("@coze-editor/editor/preset-code");
|
|
2700
|
+
var import_language_typescript = require("@coze-editor/editor/language-typescript");
|
|
2701
|
+
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
2702
|
+
var import_language_python = require("@coze-editor/editor/language-python");
|
|
2703
|
+
var import_language_json = require("@coze-editor/editor/language-json");
|
|
2704
|
+
var import_editor10 = require("@coze-editor/editor");
|
|
2705
|
+
import_preset_code.languages.register("python", import_language_python.python);
|
|
2706
|
+
import_preset_code.languages.register("shell", import_language_shell.shell);
|
|
2707
|
+
import_preset_code.languages.register("typescript", import_language_typescript.typescript);
|
|
2708
|
+
import_preset_code.languages.register("json", {
|
|
2709
|
+
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
2710
|
+
language: (0, import_editor10.mixLanguages)({
|
|
2711
|
+
outerLanguage: import_language_json.json.language
|
|
2712
|
+
}),
|
|
2713
|
+
languageService: import_language_json.json.languageService
|
|
2714
|
+
});
|
|
2715
|
+
var tsWorkerInit = false;
|
|
2716
|
+
var initTsWorker = () => {
|
|
2717
|
+
if (tsWorkerInit) {
|
|
2718
|
+
return;
|
|
2719
|
+
}
|
|
2720
|
+
tsWorkerInit = true;
|
|
2721
|
+
const tsWorker = new Worker(
|
|
2722
|
+
new URL(`@coze-editor/editor/language-typescript/worker`, importMetaUrl),
|
|
2723
|
+
{ type: "module" }
|
|
2724
|
+
);
|
|
2725
|
+
import_language_typescript.typescript.languageService.initialize(tsWorker, {
|
|
2726
|
+
compilerOptions: {
|
|
2727
|
+
// eliminate Promise error
|
|
2728
|
+
lib: ["es2015", "dom"],
|
|
2729
|
+
noImplicitAny: false
|
|
2730
|
+
}
|
|
2731
|
+
});
|
|
2732
|
+
};
|
|
2733
|
+
|
|
2691
2734
|
// src/components/code-editor/theme/index.ts
|
|
2692
|
-
var
|
|
2735
|
+
var import_preset_code4 = require("@coze-editor/editor/preset-code");
|
|
2693
2736
|
|
|
2694
2737
|
// src/components/code-editor/theme/light.ts
|
|
2695
|
-
var
|
|
2738
|
+
var import_preset_code2 = require("@coze-editor/editor/preset-code");
|
|
2696
2739
|
var colors = {
|
|
2697
2740
|
background: "#F7F7FC",
|
|
2698
2741
|
// syntax
|
|
@@ -2704,7 +2747,7 @@ var colors = {
|
|
|
2704
2747
|
null: "#2B57D9",
|
|
2705
2748
|
separator: "#0F1529D1"
|
|
2706
2749
|
};
|
|
2707
|
-
var lightTheme = (0,
|
|
2750
|
+
var lightTheme = (0, import_preset_code2.createTheme)({
|
|
2708
2751
|
variant: "light",
|
|
2709
2752
|
settings: {
|
|
2710
2753
|
background: "#fff",
|
|
@@ -2747,63 +2790,63 @@ var lightTheme = (0, import_preset_code.createTheme)({
|
|
|
2747
2790
|
styles: [
|
|
2748
2791
|
// JSON
|
|
2749
2792
|
{
|
|
2750
|
-
tag:
|
|
2793
|
+
tag: import_preset_code2.tags.comment,
|
|
2751
2794
|
color: colors.comment
|
|
2752
2795
|
},
|
|
2753
2796
|
{
|
|
2754
|
-
tag: [
|
|
2797
|
+
tag: [import_preset_code2.tags.propertyName],
|
|
2755
2798
|
color: colors.key
|
|
2756
2799
|
},
|
|
2757
2800
|
{
|
|
2758
|
-
tag: [
|
|
2801
|
+
tag: [import_preset_code2.tags.string],
|
|
2759
2802
|
color: colors.string
|
|
2760
2803
|
},
|
|
2761
2804
|
{
|
|
2762
|
-
tag: [
|
|
2805
|
+
tag: [import_preset_code2.tags.number],
|
|
2763
2806
|
color: colors.number
|
|
2764
2807
|
},
|
|
2765
2808
|
{
|
|
2766
|
-
tag: [
|
|
2809
|
+
tag: [import_preset_code2.tags.bool],
|
|
2767
2810
|
color: colors.boolean
|
|
2768
2811
|
},
|
|
2769
2812
|
{
|
|
2770
|
-
tag: [
|
|
2813
|
+
tag: [import_preset_code2.tags.null],
|
|
2771
2814
|
color: colors.null
|
|
2772
2815
|
},
|
|
2773
2816
|
{
|
|
2774
|
-
tag: [
|
|
2817
|
+
tag: [import_preset_code2.tags.separator],
|
|
2775
2818
|
color: colors.separator
|
|
2776
2819
|
},
|
|
2777
2820
|
// markdown
|
|
2778
2821
|
{
|
|
2779
|
-
tag: [
|
|
2822
|
+
tag: [import_preset_code2.tags.heading],
|
|
2780
2823
|
color: "#3e76ef"
|
|
2781
2824
|
},
|
|
2782
2825
|
{
|
|
2783
|
-
tag: [
|
|
2826
|
+
tag: [import_preset_code2.tags.processingInstruction],
|
|
2784
2827
|
color: "#3e76ef"
|
|
2785
2828
|
},
|
|
2786
2829
|
// shell
|
|
2787
2830
|
// curl
|
|
2788
2831
|
{
|
|
2789
|
-
tag: [
|
|
2832
|
+
tag: [import_preset_code2.tags.standard(import_preset_code2.tags.variableName)],
|
|
2790
2833
|
color: "#00804A"
|
|
2791
2834
|
},
|
|
2792
2835
|
// -X
|
|
2793
2836
|
{
|
|
2794
|
-
tag: [
|
|
2837
|
+
tag: [import_preset_code2.tags.attributeName],
|
|
2795
2838
|
color: "#C74200"
|
|
2796
2839
|
},
|
|
2797
2840
|
// url in string (includes quotes), e.g. "https://..."
|
|
2798
2841
|
{
|
|
2799
|
-
tag: [
|
|
2842
|
+
tag: [import_preset_code2.tags.special(import_preset_code2.tags.string)],
|
|
2800
2843
|
color: "#2B57D9"
|
|
2801
2844
|
}
|
|
2802
2845
|
]
|
|
2803
2846
|
});
|
|
2804
2847
|
|
|
2805
2848
|
// src/components/code-editor/theme/dark.ts
|
|
2806
|
-
var
|
|
2849
|
+
var import_preset_code3 = require("@coze-editor/editor/preset-code");
|
|
2807
2850
|
var colors2 = {
|
|
2808
2851
|
background: "#151B27",
|
|
2809
2852
|
// syntax
|
|
@@ -2815,7 +2858,7 @@ var colors2 = {
|
|
|
2815
2858
|
null: "#78B0FF",
|
|
2816
2859
|
separator: "#FFFFFFC9"
|
|
2817
2860
|
};
|
|
2818
|
-
var darkTheme = (0,
|
|
2861
|
+
var darkTheme = (0, import_preset_code3.createTheme)({
|
|
2819
2862
|
variant: "dark",
|
|
2820
2863
|
settings: {
|
|
2821
2864
|
background: colors2.background,
|
|
@@ -2858,82 +2901,64 @@ var darkTheme = (0, import_preset_code2.createTheme)({
|
|
|
2858
2901
|
styles: [
|
|
2859
2902
|
// json
|
|
2860
2903
|
{
|
|
2861
|
-
tag:
|
|
2904
|
+
tag: import_preset_code3.tags.comment,
|
|
2862
2905
|
color: colors2.comment
|
|
2863
2906
|
},
|
|
2864
2907
|
{
|
|
2865
|
-
tag: [
|
|
2908
|
+
tag: [import_preset_code3.tags.propertyName],
|
|
2866
2909
|
color: colors2.key
|
|
2867
2910
|
},
|
|
2868
2911
|
{
|
|
2869
|
-
tag: [
|
|
2912
|
+
tag: [import_preset_code3.tags.string],
|
|
2870
2913
|
color: colors2.string
|
|
2871
2914
|
},
|
|
2872
2915
|
{
|
|
2873
|
-
tag: [
|
|
2916
|
+
tag: [import_preset_code3.tags.number],
|
|
2874
2917
|
color: colors2.number
|
|
2875
2918
|
},
|
|
2876
2919
|
{
|
|
2877
|
-
tag: [
|
|
2920
|
+
tag: [import_preset_code3.tags.bool],
|
|
2878
2921
|
color: colors2.boolean
|
|
2879
2922
|
},
|
|
2880
2923
|
{
|
|
2881
|
-
tag: [
|
|
2924
|
+
tag: [import_preset_code3.tags.null],
|
|
2882
2925
|
color: colors2.null
|
|
2883
2926
|
},
|
|
2884
2927
|
{
|
|
2885
|
-
tag: [
|
|
2928
|
+
tag: [import_preset_code3.tags.separator],
|
|
2886
2929
|
color: colors2.separator
|
|
2887
2930
|
},
|
|
2888
2931
|
// markdown
|
|
2889
2932
|
{
|
|
2890
|
-
tag: [
|
|
2933
|
+
tag: [import_preset_code3.tags.heading],
|
|
2891
2934
|
color: "#6b6bff"
|
|
2892
2935
|
},
|
|
2893
2936
|
{
|
|
2894
|
-
tag: [
|
|
2937
|
+
tag: [import_preset_code3.tags.processingInstruction],
|
|
2895
2938
|
color: "#6b6bff"
|
|
2896
2939
|
},
|
|
2897
2940
|
// shell
|
|
2898
2941
|
// curl
|
|
2899
2942
|
{
|
|
2900
|
-
tag: [
|
|
2943
|
+
tag: [import_preset_code3.tags.standard(import_preset_code3.tags.variableName)],
|
|
2901
2944
|
color: "#3BEB84"
|
|
2902
2945
|
},
|
|
2903
2946
|
// -X
|
|
2904
2947
|
{
|
|
2905
|
-
tag: [
|
|
2948
|
+
tag: [import_preset_code3.tags.attributeName],
|
|
2906
2949
|
color: "#FF9933"
|
|
2907
2950
|
},
|
|
2908
2951
|
// url in string (includes quotes), e.g. "https://..."
|
|
2909
2952
|
{
|
|
2910
|
-
tag: [
|
|
2953
|
+
tag: [import_preset_code3.tags.special(import_preset_code3.tags.string)],
|
|
2911
2954
|
color: "#78B0FF"
|
|
2912
2955
|
}
|
|
2913
2956
|
]
|
|
2914
2957
|
});
|
|
2915
2958
|
|
|
2916
2959
|
// src/components/code-editor/theme/index.ts
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
// src/components/code-editor/language-features.ts
|
|
2921
|
-
var import_preset_code4 = require("@coze-editor/editor/preset-code");
|
|
2922
|
-
var import_language_typescript = require("@coze-editor/editor/language-typescript");
|
|
2923
|
-
var import_language_shell = require("@coze-editor/editor/language-shell");
|
|
2924
|
-
var import_language_python = require("@coze-editor/editor/language-python");
|
|
2925
|
-
var import_language_json = require("@coze-editor/editor/language-json");
|
|
2926
|
-
var import_editor10 = require("@coze-editor/editor");
|
|
2927
|
-
import_preset_code4.languages.register("python", import_language_python.python);
|
|
2928
|
-
import_preset_code4.languages.register("typescript", import_language_typescript.typescript);
|
|
2929
|
-
import_preset_code4.languages.register("shell", import_language_shell.shell);
|
|
2930
|
-
import_preset_code4.languages.register("json", {
|
|
2931
|
-
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
2932
|
-
language: (0, import_editor10.mixLanguages)({
|
|
2933
|
-
outerLanguage: import_language_json.json.language
|
|
2934
|
-
}),
|
|
2935
|
-
languageService: import_language_json.json.languageService
|
|
2936
|
-
});
|
|
2960
|
+
import_preset_code4.themes.register("dark", darkTheme);
|
|
2961
|
+
import_preset_code4.themes.register("light", lightTheme);
|
|
2937
2962
|
|
|
2938
2963
|
// src/components/code-editor/index.tsx
|
|
2939
2964
|
var OriginCodeEditor = (0, import_react36.createRenderer)(import_preset_code5.default, [
|
|
@@ -2955,6 +2980,11 @@ function CodeEditor({
|
|
|
2955
2980
|
readonly
|
|
2956
2981
|
}) {
|
|
2957
2982
|
const editorRef = (0, import_react35.useRef)(null);
|
|
2983
|
+
(0, import_react35.useEffect)(() => {
|
|
2984
|
+
if (languageId === "typescript") {
|
|
2985
|
+
initTsWorker();
|
|
2986
|
+
}
|
|
2987
|
+
}, [languageId]);
|
|
2958
2988
|
(0, import_react35.useEffect)(() => {
|
|
2959
2989
|
if (editorRef.current?.getValue() !== value) {
|
|
2960
2990
|
editorRef.current?.setValue(String(value || ""));
|
|
@@ -3240,7 +3270,7 @@ function JsonEditorWithVariables(props) {
|
|
|
3240
3270
|
}
|
|
3241
3271
|
|
|
3242
3272
|
// src/components/inputs-values/index.tsx
|
|
3243
|
-
var
|
|
3273
|
+
var import_react43 = __toESM(require("react"));
|
|
3244
3274
|
var import_semi_ui20 = require("@douyinfe/semi-ui");
|
|
3245
3275
|
var import_semi_icons11 = require("@douyinfe/semi-icons");
|
|
3246
3276
|
|
|
@@ -3258,43 +3288,76 @@ var UIRow3 = import_styled_components9.default.div`
|
|
|
3258
3288
|
gap: 5px;
|
|
3259
3289
|
`;
|
|
3260
3290
|
|
|
3291
|
+
// src/components/inputs-values/components/blur-input.tsx
|
|
3292
|
+
var import_react42 = __toESM(require("react"));
|
|
3293
|
+
var import_input2 = __toESM(require("@douyinfe/semi-ui/lib/es/input"));
|
|
3294
|
+
function BlurInput2(props) {
|
|
3295
|
+
const [value, setValue] = (0, import_react42.useState)("");
|
|
3296
|
+
(0, import_react42.useEffect)(() => {
|
|
3297
|
+
setValue(props.value);
|
|
3298
|
+
}, [props.value]);
|
|
3299
|
+
return /* @__PURE__ */ import_react42.default.createElement(
|
|
3300
|
+
import_input2.default,
|
|
3301
|
+
{
|
|
3302
|
+
...props,
|
|
3303
|
+
value,
|
|
3304
|
+
onChange: (value2) => {
|
|
3305
|
+
setValue(value2);
|
|
3306
|
+
},
|
|
3307
|
+
onBlur: (e) => props.onChange?.(value, e)
|
|
3308
|
+
}
|
|
3309
|
+
);
|
|
3310
|
+
}
|
|
3311
|
+
|
|
3261
3312
|
// src/components/inputs-values/index.tsx
|
|
3262
|
-
function InputsValues({
|
|
3313
|
+
function InputsValues({
|
|
3314
|
+
value,
|
|
3315
|
+
onChange,
|
|
3316
|
+
style,
|
|
3317
|
+
readonly,
|
|
3318
|
+
constantProps,
|
|
3319
|
+
schema,
|
|
3320
|
+
hasError
|
|
3321
|
+
}) {
|
|
3263
3322
|
const { list, updateKey, updateValue, remove, add } = useObjectList({
|
|
3264
3323
|
value,
|
|
3265
|
-
onChange
|
|
3324
|
+
onChange,
|
|
3325
|
+
sortIndexKey: "extra.index"
|
|
3266
3326
|
});
|
|
3267
|
-
return /* @__PURE__ */
|
|
3268
|
-
|
|
3327
|
+
return /* @__PURE__ */ import_react43.default.createElement("div", null, /* @__PURE__ */ import_react43.default.createElement(UIRows2, { style }, list.map((item) => /* @__PURE__ */ import_react43.default.createElement(UIRow3, { key: item.id }, /* @__PURE__ */ import_react43.default.createElement(
|
|
3328
|
+
BlurInput2,
|
|
3269
3329
|
{
|
|
3270
3330
|
style: { width: 100, minWidth: 100, maxWidth: 100 },
|
|
3271
3331
|
disabled: readonly,
|
|
3272
3332
|
size: "small",
|
|
3273
3333
|
value: item.key,
|
|
3274
|
-
onChange: (v) => updateKey(item.id, v)
|
|
3334
|
+
onChange: (v) => updateKey(item.id, v),
|
|
3335
|
+
placeholder: "Input Key"
|
|
3275
3336
|
}
|
|
3276
|
-
), /* @__PURE__ */
|
|
3337
|
+
), /* @__PURE__ */ import_react43.default.createElement(
|
|
3277
3338
|
DynamicValueInput,
|
|
3278
3339
|
{
|
|
3279
3340
|
style: { flexGrow: 1 },
|
|
3280
3341
|
readonly,
|
|
3281
3342
|
value: item.value,
|
|
3282
3343
|
onChange: (v) => updateValue(item.id, v),
|
|
3344
|
+
schema,
|
|
3345
|
+
hasError,
|
|
3283
3346
|
constantProps: {
|
|
3284
3347
|
...constantProps,
|
|
3285
3348
|
strategies: [...constantProps?.strategies || []]
|
|
3286
3349
|
}
|
|
3287
3350
|
}
|
|
3288
|
-
), /* @__PURE__ */
|
|
3351
|
+
), /* @__PURE__ */ import_react43.default.createElement(
|
|
3289
3352
|
import_semi_ui20.IconButton,
|
|
3290
3353
|
{
|
|
3291
3354
|
disabled: readonly,
|
|
3292
3355
|
theme: "borderless",
|
|
3293
|
-
icon: /* @__PURE__ */
|
|
3356
|
+
icon: /* @__PURE__ */ import_react43.default.createElement(import_semi_icons11.IconDelete, { size: "small" }),
|
|
3294
3357
|
size: "small",
|
|
3295
3358
|
onClick: () => remove(item.id)
|
|
3296
3359
|
}
|
|
3297
|
-
)))), /* @__PURE__ */
|
|
3360
|
+
)))), /* @__PURE__ */ import_react43.default.createElement(import_semi_ui20.Button, { disabled: readonly, icon: /* @__PURE__ */ import_react43.default.createElement(import_semi_icons11.IconPlus, null), size: "small", onClick: add }, "Add"));
|
|
3298
3361
|
}
|
|
3299
3362
|
|
|
3300
3363
|
// src/effects/provide-batch-input/index.ts
|