@flowgram.ai/form-materials 0.3.0 → 0.3.1
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/materials.ts +9 -1
- package/dist/esm/index.js +117 -87
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +94 -87
- package/dist/index.d.ts +94 -87
- package/dist/index.js +191 -164
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/condition-row/constants.ts +4 -0
- package/src/components/constant-input/index.tsx +1 -1
- package/src/components/constant-input/types.ts +1 -1
- package/src/components/display-schema-tag/index.tsx +1 -1
- package/src/components/display-schema-tree/index.tsx +1 -1
- package/src/components/json-schema-editor/config.json +1 -1
- package/src/components/type-selector/index.tsx +1 -1
- package/src/components/variable-selector/use-variable-tree.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/plugins/disable-declaration-plugin/config.json +5 -0
- package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
- package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
- package/src/plugins/index.ts +7 -0
- package/src/{shared → plugins}/json-schema-preset/create-type-preset-plugin.tsx +4 -2
- package/src/shared/index.ts +0 -1
- /package/src/{shared → plugins}/json-schema-preset/config.json +0 -0
- /package/src/{shared → plugins}/json-schema-preset/index.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/manager.ts +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/array.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/boolean.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/index.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/integer.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/number.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/object.tsx +0 -0
- /package/src/{shared → plugins}/json-schema-preset/type-definition/string.tsx +0 -0
package/bin/materials.ts
CHANGED
|
@@ -22,7 +22,15 @@ export interface Material {
|
|
|
22
22
|
[key: string]: any; // For other properties from config.json
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const _types: string[] = [
|
|
25
|
+
const _types: string[] = [
|
|
26
|
+
'components',
|
|
27
|
+
'effects',
|
|
28
|
+
'plugins',
|
|
29
|
+
'shared',
|
|
30
|
+
'typings',
|
|
31
|
+
'form-plugins',
|
|
32
|
+
'hooks',
|
|
33
|
+
];
|
|
26
34
|
|
|
27
35
|
export function listAllMaterials(): Material[] {
|
|
28
36
|
const _materials: Material[] = [];
|
package/dist/esm/index.js
CHANGED
|
@@ -6,72 +6,10 @@ import { IconChevronDownStroked, IconIssueStroked } from "@douyinfe/semi-icons";
|
|
|
6
6
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
7
7
|
import React10, { useCallback } from "react";
|
|
8
8
|
import { JsonSchemaUtils as JsonSchemaUtils2 } from "@flowgram.ai/json-schema";
|
|
9
|
-
import { ASTMatch, useAvailableVariables } from "@flowgram.ai/editor";
|
|
9
|
+
import { ASTMatch as ASTMatch2, useAvailableVariables } from "@flowgram.ai/editor";
|
|
10
10
|
import { Icon } from "@douyinfe/semi-ui";
|
|
11
11
|
|
|
12
|
-
// src/
|
|
13
|
-
import { isObject } from "lodash";
|
|
14
|
-
function formatLegacyRefOnSubmit(value) {
|
|
15
|
-
if (isObject(value)) {
|
|
16
|
-
if (isLegacyFlowRefValueSchema(value)) {
|
|
17
|
-
return formatLegacyRefToNewRef(value);
|
|
18
|
-
}
|
|
19
|
-
return Object.fromEntries(
|
|
20
|
-
Object.entries(value).map(([key, value2]) => [
|
|
21
|
-
key,
|
|
22
|
-
formatLegacyRefOnSubmit(value2)
|
|
23
|
-
])
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
if (Array.isArray(value)) {
|
|
27
|
-
return value.map(formatLegacyRefOnSubmit);
|
|
28
|
-
}
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
function formatLegacyRefOnInit(value) {
|
|
32
|
-
if (isObject(value)) {
|
|
33
|
-
if (isNewFlowRefValueSchema(value)) {
|
|
34
|
-
return formatNewRefToLegacyRef(value);
|
|
35
|
-
}
|
|
36
|
-
return Object.fromEntries(
|
|
37
|
-
Object.entries(value).map(([key, value2]) => [
|
|
38
|
-
key,
|
|
39
|
-
formatLegacyRefOnInit(value2)
|
|
40
|
-
])
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
if (Array.isArray(value)) {
|
|
44
|
-
return value.map(formatLegacyRefOnInit);
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
function isLegacyFlowRefValueSchema(value) {
|
|
49
|
-
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
50
|
-
}
|
|
51
|
-
function isNewFlowRefValueSchema(value) {
|
|
52
|
-
return isObject(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
53
|
-
}
|
|
54
|
-
function formatLegacyRefToNewRef(value) {
|
|
55
|
-
const keyPath = value.content.split(".");
|
|
56
|
-
if (keyPath[1] === "outputs") {
|
|
57
|
-
return {
|
|
58
|
-
type: "ref",
|
|
59
|
-
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
type: "ref",
|
|
64
|
-
content: keyPath
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function formatNewRefToLegacyRef(value) {
|
|
68
|
-
return {
|
|
69
|
-
type: "ref",
|
|
70
|
-
content: value.content.join(".")
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// src/shared/json-schema-preset/index.tsx
|
|
12
|
+
// src/plugins/json-schema-preset/index.tsx
|
|
75
13
|
import React9 from "react";
|
|
76
14
|
import {
|
|
77
15
|
JsonSchemaUtils,
|
|
@@ -79,10 +17,10 @@ import {
|
|
|
79
17
|
TypePresetProvider as OriginTypePresetProvider
|
|
80
18
|
} from "@flowgram.ai/json-schema";
|
|
81
19
|
|
|
82
|
-
// src/
|
|
20
|
+
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
83
21
|
import { jsonSchemaTypeManager } from "@flowgram.ai/json-schema";
|
|
84
22
|
|
|
85
|
-
// src/
|
|
23
|
+
// src/plugins/json-schema-preset/type-definition/string.tsx
|
|
86
24
|
import React from "react";
|
|
87
25
|
import { Input } from "@douyinfe/semi-ui";
|
|
88
26
|
var stringRegistry = {
|
|
@@ -90,7 +28,7 @@ var stringRegistry = {
|
|
|
90
28
|
ConstantRenderer: (props) => /* @__PURE__ */ React.createElement(Input, { placeholder: "Please Input String", size: "small", disabled: props.readonly, ...props })
|
|
91
29
|
};
|
|
92
30
|
|
|
93
|
-
// src/
|
|
31
|
+
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
94
32
|
import React4 from "react";
|
|
95
33
|
|
|
96
34
|
// src/components/code-editor-mini/index.tsx
|
|
@@ -462,7 +400,7 @@ function CodeEditorMini(props) {
|
|
|
462
400
|
));
|
|
463
401
|
}
|
|
464
402
|
|
|
465
|
-
// src/
|
|
403
|
+
// src/plugins/json-schema-preset/type-definition/object.tsx
|
|
466
404
|
var objectRegistry = {
|
|
467
405
|
type: "object",
|
|
468
406
|
ConstantRenderer: (props) => /* @__PURE__ */ React4.createElement(
|
|
@@ -477,7 +415,7 @@ var objectRegistry = {
|
|
|
477
415
|
)
|
|
478
416
|
};
|
|
479
417
|
|
|
480
|
-
// src/
|
|
418
|
+
// src/plugins/json-schema-preset/type-definition/number.tsx
|
|
481
419
|
import React5 from "react";
|
|
482
420
|
import { InputNumber } from "@douyinfe/semi-ui";
|
|
483
421
|
var numberRegistry = {
|
|
@@ -494,7 +432,7 @@ var numberRegistry = {
|
|
|
494
432
|
)
|
|
495
433
|
};
|
|
496
434
|
|
|
497
|
-
// src/
|
|
435
|
+
// src/plugins/json-schema-preset/type-definition/integer.tsx
|
|
498
436
|
import React6 from "react";
|
|
499
437
|
import { InputNumber as InputNumber2 } from "@douyinfe/semi-ui";
|
|
500
438
|
var integerRegistry = {
|
|
@@ -511,7 +449,7 @@ var integerRegistry = {
|
|
|
511
449
|
)
|
|
512
450
|
};
|
|
513
451
|
|
|
514
|
-
// src/
|
|
452
|
+
// src/plugins/json-schema-preset/type-definition/boolean.tsx
|
|
515
453
|
import React7 from "react";
|
|
516
454
|
import { Select } from "@douyinfe/semi-ui";
|
|
517
455
|
var booleanRegistry = {
|
|
@@ -536,7 +474,7 @@ var booleanRegistry = {
|
|
|
536
474
|
}
|
|
537
475
|
};
|
|
538
476
|
|
|
539
|
-
// src/
|
|
477
|
+
// src/plugins/json-schema-preset/type-definition/array.tsx
|
|
540
478
|
import React8 from "react";
|
|
541
479
|
var arrayRegistry = {
|
|
542
480
|
type: "array",
|
|
@@ -552,7 +490,7 @@ var arrayRegistry = {
|
|
|
552
490
|
)
|
|
553
491
|
};
|
|
554
492
|
|
|
555
|
-
// src/
|
|
493
|
+
// src/plugins/json-schema-preset/type-definition/index.tsx
|
|
556
494
|
var jsonSchemaTypePreset = [
|
|
557
495
|
stringRegistry,
|
|
558
496
|
objectRegistry,
|
|
@@ -563,7 +501,7 @@ var jsonSchemaTypePreset = [
|
|
|
563
501
|
];
|
|
564
502
|
jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
|
|
565
503
|
|
|
566
|
-
// src/
|
|
504
|
+
// src/plugins/json-schema-preset/create-type-preset-plugin.tsx
|
|
567
505
|
import {
|
|
568
506
|
BaseTypeManager,
|
|
569
507
|
jsonSchemaContainerModule
|
|
@@ -573,18 +511,43 @@ var createTypePresetPlugin = definePluginCreator({
|
|
|
573
511
|
onInit(ctx, opts) {
|
|
574
512
|
const typeManager = ctx.get(BaseTypeManager);
|
|
575
513
|
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
576
|
-
opts.types
|
|
514
|
+
opts.types?.forEach((_type) => typeManager.register(_type));
|
|
515
|
+
opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
|
|
577
516
|
},
|
|
578
517
|
containerModules: [jsonSchemaContainerModule]
|
|
579
518
|
});
|
|
580
519
|
|
|
581
|
-
// src/
|
|
520
|
+
// src/plugins/json-schema-preset/index.tsx
|
|
582
521
|
var useTypeManager = () => useOriginTypeManager();
|
|
583
522
|
var JsonSchemaTypePresetProvider = ({
|
|
584
523
|
types = [],
|
|
585
524
|
children
|
|
586
525
|
}) => /* @__PURE__ */ React9.createElement(OriginTypePresetProvider, { types: [...jsonSchemaTypePreset, ...types] }, children);
|
|
587
526
|
|
|
527
|
+
// src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts
|
|
528
|
+
import {
|
|
529
|
+
ASTMatch,
|
|
530
|
+
definePluginCreator as definePluginCreator2,
|
|
531
|
+
VariableEngine
|
|
532
|
+
} from "@flowgram.ai/editor";
|
|
533
|
+
var createDisableDeclarationPlugin = definePluginCreator2({
|
|
534
|
+
onInit(ctx) {
|
|
535
|
+
const variableEngine = ctx.get(VariableEngine);
|
|
536
|
+
const handleEvent = (action) => {
|
|
537
|
+
if (ASTMatch.isVariableDeclaration(action.ast)) {
|
|
538
|
+
if (!action.ast.meta?.disabled) {
|
|
539
|
+
action.ast.updateMeta({
|
|
540
|
+
...action.ast.meta || {},
|
|
541
|
+
disabled: true
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
variableEngine.onGlobalEvent("NewAST", handleEvent);
|
|
547
|
+
variableEngine.onGlobalEvent("UpdateAST", handleEvent);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
|
|
588
551
|
// src/components/variable-selector/use-variable-tree.tsx
|
|
589
552
|
function useVariableTree(params) {
|
|
590
553
|
const { includeSchema, excludeSchema, customSkip } = params;
|
|
@@ -606,7 +569,7 @@ function useVariableTree(params) {
|
|
|
606
569
|
return null;
|
|
607
570
|
}
|
|
608
571
|
let children;
|
|
609
|
-
if (
|
|
572
|
+
if (ASTMatch2.isObject(type)) {
|
|
610
573
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...parentFields, variable])).filter(Boolean);
|
|
611
574
|
}
|
|
612
575
|
const keyPath = [...parentFields.map((_field) => _field.key), variable.key];
|
|
@@ -1766,7 +1729,11 @@ var rules = {
|
|
|
1766
1729
|
},
|
|
1767
1730
|
array: {
|
|
1768
1731
|
["is_empty" /* IS_EMPTY */]: null,
|
|
1769
|
-
["is_not_empty" /* IS_NOT_EMPTY */]: null
|
|
1732
|
+
["is_not_empty" /* IS_NOT_EMPTY */]: null,
|
|
1733
|
+
["contains" /* CONTAINS */]: "array",
|
|
1734
|
+
["not_contains" /* NOT_CONTAINS */]: "array",
|
|
1735
|
+
["eq" /* EQ */]: "array",
|
|
1736
|
+
["neq" /* NEQ */]: "array"
|
|
1770
1737
|
},
|
|
1771
1738
|
map: {
|
|
1772
1739
|
["is_empty" /* IS_EMPTY */]: null,
|
|
@@ -1936,7 +1903,7 @@ import { IconDelete, IconPlus as IconPlus2 } from "@douyinfe/semi-icons";
|
|
|
1936
1903
|
// src/hooks/use-object-list/index.tsx
|
|
1937
1904
|
import { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1938
1905
|
import { nanoid } from "nanoid";
|
|
1939
|
-
import { difference, get, isObject
|
|
1906
|
+
import { difference, get, isObject, set } from "lodash";
|
|
1940
1907
|
function genId2() {
|
|
1941
1908
|
return nanoid();
|
|
1942
1909
|
}
|
|
@@ -1986,7 +1953,7 @@ function useObjectList({
|
|
|
1986
1953
|
onChange(
|
|
1987
1954
|
Object.fromEntries(
|
|
1988
1955
|
nextList.filter((item) => item.key).map((item) => [item.key, item.value]).map((_res, idx) => {
|
|
1989
|
-
if (
|
|
1956
|
+
if (isObject(_res[1]) && sortIndexKey) {
|
|
1990
1957
|
set(_res[1], sortIndexKey, idx);
|
|
1991
1958
|
}
|
|
1992
1959
|
return _res;
|
|
@@ -2496,7 +2463,7 @@ import {
|
|
|
2496
2463
|
import React27, { useMemo as useMemo10 } from "react";
|
|
2497
2464
|
import { last as last2 } from "lodash";
|
|
2498
2465
|
import {
|
|
2499
|
-
ASTMatch as
|
|
2466
|
+
ASTMatch as ASTMatch3,
|
|
2500
2467
|
useScopeAvailable as useScopeAvailable3
|
|
2501
2468
|
} from "@flowgram.ai/editor";
|
|
2502
2469
|
import { Tree as Tree2 } from "@douyinfe/semi-ui";
|
|
@@ -2506,7 +2473,7 @@ function InputsPicker({
|
|
|
2506
2473
|
}) {
|
|
2507
2474
|
const available = useScopeAvailable3();
|
|
2508
2475
|
const getArrayDrilldown = (type, depth = 1) => {
|
|
2509
|
-
if (
|
|
2476
|
+
if (ASTMatch3.isArray(type.items)) {
|
|
2510
2477
|
return getArrayDrilldown(type.items, depth + 1);
|
|
2511
2478
|
}
|
|
2512
2479
|
return { type: type.items, depth };
|
|
@@ -2514,12 +2481,12 @@ function InputsPicker({
|
|
|
2514
2481
|
const renderVariable = (variable, keyPath) => {
|
|
2515
2482
|
let type = variable?.type;
|
|
2516
2483
|
let children;
|
|
2517
|
-
if (
|
|
2484
|
+
if (ASTMatch3.isObject(type)) {
|
|
2518
2485
|
children = (type.properties || []).map((_property) => renderVariable(_property, [...keyPath, _property.key])).filter(Boolean);
|
|
2519
2486
|
}
|
|
2520
|
-
if (
|
|
2487
|
+
if (ASTMatch3.isArray(type)) {
|
|
2521
2488
|
const drilldown = getArrayDrilldown(type);
|
|
2522
|
-
if (
|
|
2489
|
+
if (ASTMatch3.isObject(drilldown.type)) {
|
|
2523
2490
|
children = (drilldown.type.properties || []).map(
|
|
2524
2491
|
(_property) => renderVariable(_property, [
|
|
2525
2492
|
...keyPath,
|
|
@@ -3256,7 +3223,7 @@ var provideBatchInputEffect = createEffectFromVariableProvider({
|
|
|
3256
3223
|
});
|
|
3257
3224
|
|
|
3258
3225
|
// src/effects/auto-rename-ref/index.ts
|
|
3259
|
-
import { isArray, isObject as
|
|
3226
|
+
import { isArray, isObject as isObject2, uniq } from "lodash";
|
|
3260
3227
|
import {
|
|
3261
3228
|
DataEvent,
|
|
3262
3229
|
VariableFieldKeyRenameService
|
|
@@ -3326,7 +3293,7 @@ function isTemplate(value) {
|
|
|
3326
3293
|
return value?.type === "template" && typeof value?.content === "string";
|
|
3327
3294
|
}
|
|
3328
3295
|
function traverseRef(name, value, cb) {
|
|
3329
|
-
if (
|
|
3296
|
+
if (isObject2(value)) {
|
|
3330
3297
|
if (isRef(value)) {
|
|
3331
3298
|
cb(name, value);
|
|
3332
3299
|
return;
|
|
@@ -3391,6 +3358,68 @@ var syncVariableTitle = [
|
|
|
3391
3358
|
}
|
|
3392
3359
|
];
|
|
3393
3360
|
|
|
3361
|
+
// src/shared/format-legacy-refs/index.ts
|
|
3362
|
+
import { isObject as isObject3 } from "lodash";
|
|
3363
|
+
function formatLegacyRefOnSubmit(value) {
|
|
3364
|
+
if (isObject3(value)) {
|
|
3365
|
+
if (isLegacyFlowRefValueSchema(value)) {
|
|
3366
|
+
return formatLegacyRefToNewRef(value);
|
|
3367
|
+
}
|
|
3368
|
+
return Object.fromEntries(
|
|
3369
|
+
Object.entries(value).map(([key, value2]) => [
|
|
3370
|
+
key,
|
|
3371
|
+
formatLegacyRefOnSubmit(value2)
|
|
3372
|
+
])
|
|
3373
|
+
);
|
|
3374
|
+
}
|
|
3375
|
+
if (Array.isArray(value)) {
|
|
3376
|
+
return value.map(formatLegacyRefOnSubmit);
|
|
3377
|
+
}
|
|
3378
|
+
return value;
|
|
3379
|
+
}
|
|
3380
|
+
function formatLegacyRefOnInit(value) {
|
|
3381
|
+
if (isObject3(value)) {
|
|
3382
|
+
if (isNewFlowRefValueSchema(value)) {
|
|
3383
|
+
return formatNewRefToLegacyRef(value);
|
|
3384
|
+
}
|
|
3385
|
+
return Object.fromEntries(
|
|
3386
|
+
Object.entries(value).map(([key, value2]) => [
|
|
3387
|
+
key,
|
|
3388
|
+
formatLegacyRefOnInit(value2)
|
|
3389
|
+
])
|
|
3390
|
+
);
|
|
3391
|
+
}
|
|
3392
|
+
if (Array.isArray(value)) {
|
|
3393
|
+
return value.map(formatLegacyRefOnInit);
|
|
3394
|
+
}
|
|
3395
|
+
return value;
|
|
3396
|
+
}
|
|
3397
|
+
function isLegacyFlowRefValueSchema(value) {
|
|
3398
|
+
return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && typeof value.content === "string";
|
|
3399
|
+
}
|
|
3400
|
+
function isNewFlowRefValueSchema(value) {
|
|
3401
|
+
return isObject3(value) && Object.keys(value).length === 2 && value.type === "ref" && Array.isArray(value.content);
|
|
3402
|
+
}
|
|
3403
|
+
function formatLegacyRefToNewRef(value) {
|
|
3404
|
+
const keyPath = value.content.split(".");
|
|
3405
|
+
if (keyPath[1] === "outputs") {
|
|
3406
|
+
return {
|
|
3407
|
+
type: "ref",
|
|
3408
|
+
content: [`${keyPath[0]}.${keyPath[1]}`, ...keyPath.length > 2 ? keyPath.slice(2) : []]
|
|
3409
|
+
};
|
|
3410
|
+
}
|
|
3411
|
+
return {
|
|
3412
|
+
type: "ref",
|
|
3413
|
+
content: keyPath
|
|
3414
|
+
};
|
|
3415
|
+
}
|
|
3416
|
+
function formatNewRefToLegacyRef(value) {
|
|
3417
|
+
return {
|
|
3418
|
+
type: "ref",
|
|
3419
|
+
content: value.content.join(".")
|
|
3420
|
+
};
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3394
3423
|
// src/form-plugins/batch-outputs-plugin/index.ts
|
|
3395
3424
|
import {
|
|
3396
3425
|
ASTFactory as ASTFactory3,
|
|
@@ -3570,6 +3599,7 @@ export {
|
|
|
3570
3599
|
VariableSelector,
|
|
3571
3600
|
autoRenameRefEffect,
|
|
3572
3601
|
createBatchOutputsFormPlugin,
|
|
3602
|
+
createDisableDeclarationPlugin,
|
|
3573
3603
|
createInferInputsPlugin,
|
|
3574
3604
|
createTypePresetPlugin,
|
|
3575
3605
|
formatLegacyRefOnInit,
|