@flowgram.ai/form-materials 0.4.2 → 0.4.4
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/bin/index.ts +0 -11
- package/bin/materials.ts +29 -2
- package/dist/esm/index.js +115 -50
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +175 -112
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/dynamic-value-input/index.tsx +20 -11
- package/src/components/inputs-values/index.tsx +12 -1
- package/src/components/inputs-values-tree/hooks/use-child-list.tsx +1 -1
- package/src/components/inputs-values-tree/index.tsx +7 -1
- package/src/components/inputs-values-tree/row.tsx +5 -1
- package/src/components/json-editor-with-variables/extensions/variable-tag.tsx +1 -1
- package/src/components/json-editor-with-variables/index.tsx +2 -1
- package/src/components/json-schema-editor/index.tsx +1 -1
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +11 -0
- package/src/components/prompt-editor-with-inputs/index.tsx +1 -2
- package/src/components/prompt-editor-with-inputs/inputs-picker.tsx +34 -17
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +1 -1
- package/src/components/prompt-editor-with-variables/extensions/variable-tree.tsx +13 -1
- package/src/components/type-selector/index.tsx +12 -2
- package/src/index.ts +1 -0
- package/src/shared/flow-value/utils.ts +1 -1
- package/src/typings/flow-value/index.ts +1 -1
- package/src/validate/validate-flow-value/index.tsx +4 -16
package/bin/index.ts
CHANGED
|
@@ -72,17 +72,6 @@ program
|
|
|
72
72
|
let { packagesToInstall } = copyMaterial(material, projectInfo);
|
|
73
73
|
|
|
74
74
|
// 4. Install the dependencies
|
|
75
|
-
packagesToInstall = packagesToInstall.map((_pkg) => {
|
|
76
|
-
if (
|
|
77
|
-
_pkg.startsWith(`@flowgram.ai/`) &&
|
|
78
|
-
projectInfo.flowgramVersion !== 'workspace:*' &&
|
|
79
|
-
!_pkg.endsWith(`@${projectInfo.flowgramVersion}`)
|
|
80
|
-
) {
|
|
81
|
-
return `${_pkg}@${projectInfo.flowgramVersion}`;
|
|
82
|
-
}
|
|
83
|
-
return _pkg;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
75
|
console.log(chalk.bold('These npm dependencies will be added to your project'));
|
|
87
76
|
console.log(packagesToInstall);
|
|
88
77
|
installDependencies(packagesToInstall, projectInfo);
|
package/bin/materials.ts
CHANGED
|
@@ -61,12 +61,21 @@ export function listAllMaterials(): Material[] {
|
|
|
61
61
|
return _materials;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
export const getFormMaterialDependencies = (): Record<string, string> => {
|
|
65
|
+
const packageJsonPath: string = path.join(__dirname, '..', 'package.json');
|
|
66
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
67
|
+
|
|
68
|
+
return packageJson.dependencies;
|
|
69
|
+
};
|
|
70
|
+
|
|
64
71
|
export const copyMaterial = (
|
|
65
72
|
material: Material,
|
|
66
73
|
projectInfo: ProjectInfo
|
|
67
74
|
): {
|
|
68
75
|
packagesToInstall: string[];
|
|
69
76
|
} => {
|
|
77
|
+
const formMaterialDependencies = getFormMaterialDependencies();
|
|
78
|
+
|
|
70
79
|
const sourceDir: string = material.path;
|
|
71
80
|
const materialRoot: string = path.join(
|
|
72
81
|
projectInfo.projectPath,
|
|
@@ -92,10 +101,28 @@ export const copyMaterial = (
|
|
|
92
101
|
{ ...importDeclaration, source: '@flowgram.ai/form-materials' },
|
|
93
102
|
])
|
|
94
103
|
);
|
|
104
|
+
if (projectInfo.flowgramVersion !== 'workspace:*') {
|
|
105
|
+
packagesToInstall.add(`@flowgram.ai/form-materials@${projectInfo.flowgramVersion}`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
95
108
|
packagesToInstall.add('@flowgram.ai/form-materials');
|
|
96
109
|
} else if (!source.startsWith('.') && !source.startsWith('react')) {
|
|
97
|
-
// check if is
|
|
98
|
-
|
|
110
|
+
// check if is in form material dependencies
|
|
111
|
+
const [dep, version] =
|
|
112
|
+
Object.entries(formMaterialDependencies).find(([_key]) => source.startsWith(_key)) ||
|
|
113
|
+
[];
|
|
114
|
+
if (!dep) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (version === 'workspace:*') {
|
|
118
|
+
if (projectInfo.flowgramVersion !== 'workspace:*') {
|
|
119
|
+
packagesToInstall.add(`${dep}@${projectInfo.flowgramVersion}`);
|
|
120
|
+
} else {
|
|
121
|
+
packagesToInstall.add(dep);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
packagesToInstall.add(`${dep}@${version}`);
|
|
125
|
+
}
|
|
99
126
|
}
|
|
100
127
|
}
|
|
101
128
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -183,13 +183,13 @@ var FlowValueUtils;
|
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
FlowValueUtils2.traverse = traverse;
|
|
186
|
-
function
|
|
187
|
-
const keyPathReg =
|
|
186
|
+
function getTemplateKeyPaths(value) {
|
|
187
|
+
const keyPathReg = /\{\{([^\}\{]+)\}\}/g;
|
|
188
188
|
return uniq(value.content?.match(keyPathReg) || []).map(
|
|
189
189
|
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
190
190
|
);
|
|
191
191
|
}
|
|
192
|
-
FlowValueUtils2.getTemplateKeyPaths =
|
|
192
|
+
FlowValueUtils2.getTemplateKeyPaths = getTemplateKeyPaths;
|
|
193
193
|
function inferConstantJsonSchema(value) {
|
|
194
194
|
if (value?.schema) {
|
|
195
195
|
return value.schema;
|
|
@@ -1052,12 +1052,24 @@ function TypeSelector(props) {
|
|
|
1052
1052
|
}),
|
|
1053
1053
|
[]
|
|
1054
1054
|
);
|
|
1055
|
+
const isDisabled = readonly || disabled;
|
|
1055
1056
|
return /* @__PURE__ */ React13.createElement(
|
|
1056
1057
|
Cascader,
|
|
1057
1058
|
{
|
|
1058
|
-
disabled:
|
|
1059
|
+
disabled: isDisabled,
|
|
1059
1060
|
size: "small",
|
|
1060
|
-
triggerRender: () => /* @__PURE__ */ React13.createElement(
|
|
1061
|
+
triggerRender: () => /* @__PURE__ */ React13.createElement(
|
|
1062
|
+
IconButton,
|
|
1063
|
+
{
|
|
1064
|
+
size: "small",
|
|
1065
|
+
style: {
|
|
1066
|
+
...isDisabled ? { pointerEvents: "none" } : {},
|
|
1067
|
+
...style || {}
|
|
1068
|
+
},
|
|
1069
|
+
disabled: isDisabled,
|
|
1070
|
+
icon
|
|
1071
|
+
}
|
|
1072
|
+
),
|
|
1061
1073
|
treeData: options,
|
|
1062
1074
|
value: selectValue,
|
|
1063
1075
|
leafOnly: true,
|
|
@@ -1436,7 +1448,7 @@ function PropertyEdit(props) {
|
|
|
1436
1448
|
BlurInput,
|
|
1437
1449
|
{
|
|
1438
1450
|
disabled: readonly,
|
|
1439
|
-
placeholder: config?.placeholder ?? "Input Variable Name",
|
|
1451
|
+
placeholder: config?.placeholder ?? I18n9.t("Input Variable Name"),
|
|
1440
1452
|
size: "small",
|
|
1441
1453
|
value: name,
|
|
1442
1454
|
onChange: (value2) => onChange("name", value2)
|
|
@@ -1541,7 +1553,10 @@ function BatchVariableSelector(props) {
|
|
|
1541
1553
|
|
|
1542
1554
|
// src/components/dynamic-value-input/index.tsx
|
|
1543
1555
|
import React20 from "react";
|
|
1544
|
-
import {
|
|
1556
|
+
import {
|
|
1557
|
+
JsonSchemaUtils as JsonSchemaUtils4,
|
|
1558
|
+
useTypeManager as useTypeManager3
|
|
1559
|
+
} from "@flowgram.ai/json-schema";
|
|
1545
1560
|
import { IconButton as IconButton3 } from "@douyinfe/semi-ui";
|
|
1546
1561
|
import { IconSetting } from "@douyinfe/semi-icons";
|
|
1547
1562
|
|
|
@@ -1651,6 +1666,11 @@ function useIncludeSchema(schemaFromProps) {
|
|
|
1651
1666
|
}
|
|
1652
1667
|
|
|
1653
1668
|
// src/components/dynamic-value-input/index.tsx
|
|
1669
|
+
var DEFAULT_VALUE = {
|
|
1670
|
+
type: "constant",
|
|
1671
|
+
content: "",
|
|
1672
|
+
schema: { type: "string" }
|
|
1673
|
+
};
|
|
1654
1674
|
function DynamicValueInput({
|
|
1655
1675
|
value,
|
|
1656
1676
|
onChange,
|
|
@@ -1662,6 +1682,7 @@ function DynamicValueInput({
|
|
|
1662
1682
|
const refVariable = useRefVariable(value);
|
|
1663
1683
|
const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
|
|
1664
1684
|
const includeSchema = useIncludeSchema(schemaFromProps);
|
|
1685
|
+
const typeManager = useTypeManager3();
|
|
1665
1686
|
const renderTypeSelector = () => {
|
|
1666
1687
|
if (schemaFromProps) {
|
|
1667
1688
|
return /* @__PURE__ */ React20.createElement(TypeSelector, { value: schemaFromProps, readonly: true });
|
|
@@ -1676,20 +1697,18 @@ function DynamicValueInput({
|
|
|
1676
1697
|
value: selectSchema,
|
|
1677
1698
|
onChange: (_v) => {
|
|
1678
1699
|
setSelectSchema(_v || { type: "string" });
|
|
1679
|
-
|
|
1700
|
+
const schema = _v || { type: "string" };
|
|
1701
|
+
let content = typeManager.getDefaultValue(schema);
|
|
1680
1702
|
if (_v?.type === "object") {
|
|
1681
1703
|
content = "{}";
|
|
1682
1704
|
}
|
|
1683
1705
|
if (_v?.type === "array") {
|
|
1684
1706
|
content = "[]";
|
|
1685
1707
|
}
|
|
1686
|
-
if (_v?.type === "boolean") {
|
|
1687
|
-
content = false;
|
|
1688
|
-
}
|
|
1689
1708
|
onChange({
|
|
1690
1709
|
type: "constant",
|
|
1691
1710
|
content,
|
|
1692
|
-
schema
|
|
1711
|
+
schema
|
|
1693
1712
|
});
|
|
1694
1713
|
},
|
|
1695
1714
|
readonly
|
|
@@ -1703,7 +1722,7 @@ function DynamicValueInput({
|
|
|
1703
1722
|
{
|
|
1704
1723
|
style: { width: "100%" },
|
|
1705
1724
|
value: value?.content,
|
|
1706
|
-
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } :
|
|
1725
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
|
|
1707
1726
|
includeSchema,
|
|
1708
1727
|
readonly
|
|
1709
1728
|
}
|
|
@@ -1721,7 +1740,7 @@ function DynamicValueInput({
|
|
|
1721
1740
|
InjectVariableSelector,
|
|
1722
1741
|
{
|
|
1723
1742
|
style: { width: "100%" },
|
|
1724
|
-
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } :
|
|
1743
|
+
onChange: (_v) => onChange(_v ? { type: "ref", content: _v } : DEFAULT_VALUE),
|
|
1725
1744
|
includeSchema,
|
|
1726
1745
|
readonly
|
|
1727
1746
|
}
|
|
@@ -2367,8 +2386,16 @@ function VariableTree() {
|
|
|
2367
2386
|
if (!range) {
|
|
2368
2387
|
return;
|
|
2369
2388
|
}
|
|
2389
|
+
let { from, to } = range;
|
|
2390
|
+
while (editor.$view.state.doc.sliceString(from - 1, from) === "{") {
|
|
2391
|
+
from--;
|
|
2392
|
+
}
|
|
2393
|
+
while (editor.$view.state.doc.sliceString(to, to + 1) === "}") {
|
|
2394
|
+
to++;
|
|
2395
|
+
}
|
|
2370
2396
|
editor.replaceText({
|
|
2371
|
-
|
|
2397
|
+
from,
|
|
2398
|
+
to,
|
|
2372
2399
|
text: "{{" + variablePath + "}}"
|
|
2373
2400
|
});
|
|
2374
2401
|
setVisible(false);
|
|
@@ -2540,7 +2567,7 @@ function VariableTagInject() {
|
|
|
2540
2567
|
const scope = useCurrentScope();
|
|
2541
2568
|
useLayoutEffect4(() => {
|
|
2542
2569
|
const atMatcher = new MatchDecorator({
|
|
2543
|
-
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2570
|
+
regexp: /\{\{([^\}\{]+)\}\}/g,
|
|
2544
2571
|
decoration: (match) => Decoration.replace({
|
|
2545
2572
|
widget: new VariableTagWidget({
|
|
2546
2573
|
keyPath: match[1]?.split(".") ?? [],
|
|
@@ -2593,7 +2620,7 @@ import {
|
|
|
2593
2620
|
|
|
2594
2621
|
// src/components/prompt-editor-with-inputs/inputs-picker.tsx
|
|
2595
2622
|
import React28, { useMemo as useMemo9 } from "react";
|
|
2596
|
-
import { last as last2 } from "lodash";
|
|
2623
|
+
import { isPlainObject as isPlainObject2, last as last2 } from "lodash";
|
|
2597
2624
|
import {
|
|
2598
2625
|
ASTMatch as ASTMatch3,
|
|
2599
2626
|
useScopeAvailable as useScopeAvailable3
|
|
@@ -2636,20 +2663,32 @@ function InputsPicker({
|
|
|
2636
2663
|
children
|
|
2637
2664
|
};
|
|
2638
2665
|
};
|
|
2639
|
-
const
|
|
2640
|
-
|
|
2641
|
-
|
|
2666
|
+
const getTreeData = (value, keyPath) => {
|
|
2667
|
+
const currKey = keyPath.join(".");
|
|
2668
|
+
if (FlowValueUtils.isFlowValue(value)) {
|
|
2669
|
+
if (FlowValueUtils.isRef(value)) {
|
|
2642
2670
|
const variable = available.getByKeyPath(value.content || []);
|
|
2643
2671
|
if (variable) {
|
|
2644
|
-
return renderVariable(variable,
|
|
2672
|
+
return renderVariable(variable, keyPath);
|
|
2645
2673
|
}
|
|
2646
2674
|
}
|
|
2647
2675
|
return {
|
|
2648
|
-
key,
|
|
2649
|
-
value:
|
|
2650
|
-
label:
|
|
2676
|
+
key: currKey,
|
|
2677
|
+
value: currKey,
|
|
2678
|
+
label: last2(keyPath)
|
|
2651
2679
|
};
|
|
2652
|
-
}
|
|
2680
|
+
}
|
|
2681
|
+
if (isPlainObject2(value)) {
|
|
2682
|
+
return {
|
|
2683
|
+
key: currKey,
|
|
2684
|
+
value: currKey,
|
|
2685
|
+
label: last2(keyPath),
|
|
2686
|
+
children: Object.entries(value).map(([key, value2]) => getTreeData(value2, [...keyPath, key])).filter(Boolean)
|
|
2687
|
+
};
|
|
2688
|
+
}
|
|
2689
|
+
};
|
|
2690
|
+
const treeData = useMemo9(
|
|
2691
|
+
() => Object.entries(inputsValues).map(([key, value]) => getTreeData(value, [key])).filter(Boolean),
|
|
2653
2692
|
[]
|
|
2654
2693
|
);
|
|
2655
2694
|
return /* @__PURE__ */ React28.createElement(Tree2, { treeData, onSelect: (v) => onSelect(v) });
|
|
@@ -2666,6 +2705,13 @@ function InputsTree({ inputsValues }) {
|
|
|
2666
2705
|
if (!range) {
|
|
2667
2706
|
return;
|
|
2668
2707
|
}
|
|
2708
|
+
let { from, to } = range;
|
|
2709
|
+
while (editor.$view.state.doc.sliceString(from - 1, from) === "{") {
|
|
2710
|
+
from--;
|
|
2711
|
+
}
|
|
2712
|
+
while (editor.$view.state.doc.sliceString(to, to + 1) === "}") {
|
|
2713
|
+
to++;
|
|
2714
|
+
}
|
|
2669
2715
|
editor.replaceText({
|
|
2670
2716
|
...range,
|
|
2671
2717
|
text: "{{" + variablePath + "}}"
|
|
@@ -2905,7 +2951,7 @@ function VariableTagInject2() {
|
|
|
2905
2951
|
const scope = useCurrentScope2();
|
|
2906
2952
|
useLayoutEffect5(() => {
|
|
2907
2953
|
const atMatcher = new MatchDecorator2({
|
|
2908
|
-
regexp: /\{\{([^\}]+)\}\}/g,
|
|
2954
|
+
regexp: /\{\{([^\}\{]+)\}\}/g,
|
|
2909
2955
|
decoration: (match) => Decoration2.replace({
|
|
2910
2956
|
widget: new VariableTagWidget2({
|
|
2911
2957
|
keyPath: match[1]?.split(".") ?? [],
|
|
@@ -2939,6 +2985,7 @@ function VariableTagInject2() {
|
|
|
2939
2985
|
}
|
|
2940
2986
|
|
|
2941
2987
|
// src/components/json-editor-with-variables/index.tsx
|
|
2988
|
+
import { I18n as I18n13 } from "@flowgram.ai/editor";
|
|
2942
2989
|
function findAllMatches(inputString, regex) {
|
|
2943
2990
|
const globalRegex = new RegExp(
|
|
2944
2991
|
regex,
|
|
@@ -2972,7 +3019,7 @@ function JsonEditorWithVariables(props) {
|
|
|
2972
3019
|
CodeEditor,
|
|
2973
3020
|
{
|
|
2974
3021
|
languageId: "json",
|
|
2975
|
-
activeLinePlaceholder: "Press '@' to Select variable",
|
|
3022
|
+
activeLinePlaceholder: I18n13.t("Press '@' to Select variable"),
|
|
2976
3023
|
...props,
|
|
2977
3024
|
options: {
|
|
2978
3025
|
transformer,
|
|
@@ -2986,7 +3033,7 @@ function JsonEditorWithVariables(props) {
|
|
|
2986
3033
|
|
|
2987
3034
|
// src/components/inputs-values/index.tsx
|
|
2988
3035
|
import React34 from "react";
|
|
2989
|
-
import { I18n as
|
|
3036
|
+
import { I18n as I18n14 } from "@flowgram.ai/editor";
|
|
2990
3037
|
import { Button as Button4, IconButton as IconButton4 } from "@douyinfe/semi-ui";
|
|
2991
3038
|
import { IconDelete as IconDelete2, IconPlus as IconPlus3 } from "@douyinfe/semi-icons";
|
|
2992
3039
|
|
|
@@ -3027,7 +3074,7 @@ function InputsValues({
|
|
|
3027
3074
|
size: "small",
|
|
3028
3075
|
value: item.key,
|
|
3029
3076
|
onChange: (v) => updateKey(item.id, v),
|
|
3030
|
-
placeholder:
|
|
3077
|
+
placeholder: I18n14.t("Input Key")
|
|
3031
3078
|
}
|
|
3032
3079
|
), /* @__PURE__ */ React34.createElement(
|
|
3033
3080
|
InjectDynamicValueInput,
|
|
@@ -3052,7 +3099,20 @@ function InputsValues({
|
|
|
3052
3099
|
size: "small",
|
|
3053
3100
|
onClick: () => remove(item.id)
|
|
3054
3101
|
}
|
|
3055
|
-
)))), /* @__PURE__ */ React34.createElement(
|
|
3102
|
+
)))), /* @__PURE__ */ React34.createElement(
|
|
3103
|
+
Button4,
|
|
3104
|
+
{
|
|
3105
|
+
disabled: readonly,
|
|
3106
|
+
icon: /* @__PURE__ */ React34.createElement(IconPlus3, null),
|
|
3107
|
+
size: "small",
|
|
3108
|
+
onClick: () => add({
|
|
3109
|
+
type: "constant",
|
|
3110
|
+
content: "",
|
|
3111
|
+
schema: { type: "string" }
|
|
3112
|
+
})
|
|
3113
|
+
},
|
|
3114
|
+
I18n14.t("Add")
|
|
3115
|
+
));
|
|
3056
3116
|
}
|
|
3057
3117
|
|
|
3058
3118
|
// src/components/display-schema-tree/index.tsx
|
|
@@ -3282,7 +3342,7 @@ function DisplayFlowValue({ value, title, showIconInTree }) {
|
|
|
3282
3342
|
|
|
3283
3343
|
// src/components/display-inputs-values/index.tsx
|
|
3284
3344
|
import React39, { useMemo as useMemo11 } from "react";
|
|
3285
|
-
import { isPlainObject as
|
|
3345
|
+
import { isPlainObject as isPlainObject3 } from "lodash";
|
|
3286
3346
|
import { useScopeAvailable as useScopeAvailable5 } from "@flowgram.ai/editor";
|
|
3287
3347
|
|
|
3288
3348
|
// src/components/display-inputs-values/styles.ts
|
|
@@ -3300,7 +3360,7 @@ function DisplayInputsValues({ value, showIconInTree }) {
|
|
|
3300
3360
|
if (FlowValueUtils.isFlowValue(value2)) {
|
|
3301
3361
|
return /* @__PURE__ */ React39.createElement(DisplayFlowValue, { key, title: key, value: value2, showIconInTree });
|
|
3302
3362
|
}
|
|
3303
|
-
if (
|
|
3363
|
+
if (isPlainObject3(value2)) {
|
|
3304
3364
|
return /* @__PURE__ */ React39.createElement(
|
|
3305
3365
|
DisplayInputsValueAllInTag,
|
|
3306
3366
|
{
|
|
@@ -3450,7 +3510,7 @@ function AssignRows(props) {
|
|
|
3450
3510
|
|
|
3451
3511
|
// src/components/inputs-values-tree/index.tsx
|
|
3452
3512
|
import React45 from "react";
|
|
3453
|
-
import { I18n as
|
|
3513
|
+
import { I18n as I18n16 } from "@flowgram.ai/editor";
|
|
3454
3514
|
import { Button as Button6 } from "@douyinfe/semi-ui";
|
|
3455
3515
|
import { IconPlus as IconPlus5 } from "@douyinfe/semi-icons";
|
|
3456
3516
|
|
|
@@ -3560,16 +3620,16 @@ var IconAddChildren2 = () => /* @__PURE__ */ React43.createElement(Icon4, { size
|
|
|
3560
3620
|
|
|
3561
3621
|
// src/components/inputs-values-tree/row.tsx
|
|
3562
3622
|
import React44, { useMemo as useMemo13, useState as useState10 } from "react";
|
|
3563
|
-
import { I18n as
|
|
3623
|
+
import { I18n as I18n15 } from "@flowgram.ai/editor";
|
|
3564
3624
|
import { IconButton as IconButton6, Input as Input7 } from "@douyinfe/semi-ui";
|
|
3565
3625
|
import { IconChevronDown as IconChevronDown2, IconChevronRight as IconChevronRight2, IconDelete as IconDelete3 } from "@douyinfe/semi-icons";
|
|
3566
3626
|
|
|
3567
3627
|
// src/components/inputs-values-tree/hooks/use-child-list.tsx
|
|
3568
3628
|
import { useMemo as useMemo12 } from "react";
|
|
3569
|
-
import { isPlainObject as
|
|
3629
|
+
import { isPlainObject as isPlainObject4 } from "lodash";
|
|
3570
3630
|
function useChildList(value, onChange) {
|
|
3571
3631
|
const canAddField = useMemo12(() => {
|
|
3572
|
-
if (!
|
|
3632
|
+
if (!isPlainObject4(value)) {
|
|
3573
3633
|
return false;
|
|
3574
3634
|
}
|
|
3575
3635
|
if (FlowValueUtils.isFlowValue(value)) {
|
|
@@ -3578,7 +3638,7 @@ function useChildList(value, onChange) {
|
|
|
3578
3638
|
return true;
|
|
3579
3639
|
}, [value]);
|
|
3580
3640
|
const objectListValue = useMemo12(() => {
|
|
3581
|
-
if (
|
|
3641
|
+
if (isPlainObject4(value)) {
|
|
3582
3642
|
if (FlowValueUtils.isFlowValue(value)) {
|
|
3583
3643
|
return void 0;
|
|
3584
3644
|
}
|
|
@@ -3617,7 +3677,7 @@ var AddObjectChildStrategy = {
|
|
|
3617
3677
|
size: "small",
|
|
3618
3678
|
disabled: true,
|
|
3619
3679
|
style: { pointerEvents: "none" },
|
|
3620
|
-
value:
|
|
3680
|
+
value: I18n15.t("Configure via child fields")
|
|
3621
3681
|
}
|
|
3622
3682
|
)
|
|
3623
3683
|
};
|
|
@@ -3658,7 +3718,7 @@ function InputValueRow(props) {
|
|
|
3658
3718
|
size: "small",
|
|
3659
3719
|
value: keyName,
|
|
3660
3720
|
onChange: (v) => onUpdateKey?.(v),
|
|
3661
|
-
placeholder:
|
|
3721
|
+
placeholder: I18n15.t("Input Key")
|
|
3662
3722
|
}
|
|
3663
3723
|
), /* @__PURE__ */ React44.createElement(
|
|
3664
3724
|
InjectDynamicValueInput,
|
|
@@ -3681,7 +3741,11 @@ function InputValueRow(props) {
|
|
|
3681
3741
|
theme: "borderless",
|
|
3682
3742
|
icon: /* @__PURE__ */ React44.createElement(IconAddChildren2, null),
|
|
3683
3743
|
onClick: () => {
|
|
3684
|
-
add(
|
|
3744
|
+
add({
|
|
3745
|
+
type: "constant",
|
|
3746
|
+
content: "",
|
|
3747
|
+
schema: { type: "string" }
|
|
3748
|
+
});
|
|
3685
3749
|
setCollapse(true);
|
|
3686
3750
|
}
|
|
3687
3751
|
}
|
|
@@ -3746,9 +3810,15 @@ function InputsValuesTree(props) {
|
|
|
3746
3810
|
disabled: readonly,
|
|
3747
3811
|
icon: /* @__PURE__ */ React45.createElement(IconPlus5, null),
|
|
3748
3812
|
size: "small",
|
|
3749
|
-
onClick:
|
|
3813
|
+
onClick: () => {
|
|
3814
|
+
add({
|
|
3815
|
+
type: "constant",
|
|
3816
|
+
content: "",
|
|
3817
|
+
schema: { type: "string" }
|
|
3818
|
+
});
|
|
3819
|
+
}
|
|
3750
3820
|
},
|
|
3751
|
-
|
|
3821
|
+
I18n16.t("Add")
|
|
3752
3822
|
));
|
|
3753
3823
|
}
|
|
3754
3824
|
|
|
@@ -4129,7 +4199,7 @@ var createInferAssignPlugin = defineFormPluginCreator3({
|
|
|
4129
4199
|
});
|
|
4130
4200
|
|
|
4131
4201
|
// src/validate/validate-flow-value/index.tsx
|
|
4132
|
-
import { isNil
|
|
4202
|
+
import { isNil } from "lodash";
|
|
4133
4203
|
import { FeedbackLevel, getNodeScope as getNodeScope7 } from "@flowgram.ai/editor";
|
|
4134
4204
|
function validateFlowValue(value, ctx) {
|
|
4135
4205
|
const { node, required, errorMessages } = ctx;
|
|
@@ -4153,7 +4223,7 @@ function validateFlowValue(value, ctx) {
|
|
|
4153
4223
|
}
|
|
4154
4224
|
}
|
|
4155
4225
|
if (value?.type === "template") {
|
|
4156
|
-
const allRefs = getTemplateKeyPaths(value);
|
|
4226
|
+
const allRefs = FlowValueUtils.getTemplateKeyPaths(value);
|
|
4157
4227
|
for (const ref of allRefs) {
|
|
4158
4228
|
const variable = getNodeScope7(node).available.getByKeyPath(ref);
|
|
4159
4229
|
if (!variable) {
|
|
@@ -4166,12 +4236,6 @@ function validateFlowValue(value, ctx) {
|
|
|
4166
4236
|
}
|
|
4167
4237
|
return void 0;
|
|
4168
4238
|
}
|
|
4169
|
-
function getTemplateKeyPaths(value) {
|
|
4170
|
-
const keyPathReg = /{{(.*?)}}/g;
|
|
4171
|
-
return uniq2(value.content?.match(keyPathReg) || []).map(
|
|
4172
|
-
(_keyPath) => _keyPath.slice(2, -2).split(".")
|
|
4173
|
-
);
|
|
4174
|
-
}
|
|
4175
4239
|
export {
|
|
4176
4240
|
AssignRow,
|
|
4177
4241
|
AssignRows,
|
|
@@ -4225,6 +4289,7 @@ export {
|
|
|
4225
4289
|
provideBatchOutputsEffect,
|
|
4226
4290
|
provideJsonSchemaOutputs,
|
|
4227
4291
|
syncVariableTitle,
|
|
4292
|
+
useObjectList,
|
|
4228
4293
|
useTypeManager,
|
|
4229
4294
|
useVariableTree,
|
|
4230
4295
|
validateFlowValue,
|