@flowgram.ai/form-materials 0.2.15 → 0.2.17
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 +6 -1
- package/bin/project.ts +5 -0
- package/dist/esm/index.js +207 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +149 -6
- package/dist/index.d.ts +149 -6
- package/dist/index.js +202 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/batch-outputs/config.json +12 -0
- package/src/components/batch-outputs/index.tsx +61 -0
- package/src/components/batch-outputs/styles.tsx +19 -0
- package/src/components/batch-outputs/types.ts +22 -0
- package/src/components/batch-outputs/use-list.ts +86 -0
- package/src/components/batch-variable-selector/index.tsx +5 -0
- package/src/components/condition-row/constants.ts +5 -0
- package/src/components/condition-row/hooks/useOp.tsx +5 -0
- package/src/components/condition-row/hooks/useRule.ts +5 -0
- package/src/components/condition-row/index.tsx +6 -1
- package/src/components/condition-row/styles.tsx +5 -0
- package/src/components/condition-row/types.ts +5 -0
- package/src/components/constant-input/index.tsx +5 -0
- package/src/components/constant-input/types.ts +5 -0
- package/src/components/dynamic-value-input/index.tsx +6 -0
- package/src/components/dynamic-value-input/styles.tsx +5 -0
- package/src/components/index.ts +6 -0
- package/src/components/json-schema-editor/components/blur-input.tsx +5 -0
- package/src/components/json-schema-editor/default-value.tsx +5 -0
- package/src/components/json-schema-editor/hooks.tsx +5 -0
- package/src/components/json-schema-editor/index.tsx +5 -0
- package/src/components/json-schema-editor/styles.tsx +5 -0
- package/src/components/json-schema-editor/types.ts +5 -0
- package/src/components/json-schema-editor/utils.ts +5 -0
- package/src/components/type-selector/constants.tsx +5 -0
- package/src/components/type-selector/index.tsx +5 -0
- package/src/components/variable-selector/index.tsx +7 -0
- package/src/components/variable-selector/styles.tsx +5 -0
- package/src/components/variable-selector/use-variable-tree.tsx +8 -3
- package/src/effects/auto-rename-ref/index.ts +5 -0
- package/src/effects/index.ts +5 -0
- package/src/effects/provide-batch-input/index.ts +5 -0
- package/src/effects/provide-batch-outputs/index.ts +5 -1
- package/src/effects/provide-json-schema-outputs/index.ts +5 -0
- package/src/effects/sync-variable-title/index.ts +5 -0
- package/src/form-plugins/batch-outputs-plugin/config.json +7 -0
- package/src/form-plugins/batch-outputs-plugin/index.ts +104 -0
- package/src/form-plugins/index.ts +6 -0
- package/src/index.ts +6 -0
- package/src/typings/flow-value/index.ts +5 -0
- package/src/typings/index.ts +5 -0
- package/src/typings/json-schema/index.ts +5 -0
- package/src/utils/format-legacy-refs/index.ts +5 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/json-schema/index.ts +6 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ASTFactory,
|
|
8
|
+
createEffectFromVariableProvider,
|
|
9
|
+
defineFormPluginCreator,
|
|
10
|
+
FlowNodeRegistry,
|
|
11
|
+
getNodeForm,
|
|
12
|
+
getNodePrivateScope,
|
|
13
|
+
getNodeScope,
|
|
14
|
+
ScopeChainTransformService,
|
|
15
|
+
type EffectOptions,
|
|
16
|
+
type FormPluginCreator,
|
|
17
|
+
FlowNodeScopeType,
|
|
18
|
+
} from '@flowgram.ai/editor';
|
|
19
|
+
|
|
20
|
+
import { IFlowRefValue } from '../../typings';
|
|
21
|
+
|
|
22
|
+
export const provideBatchOutputsEffect: EffectOptions[] = createEffectFromVariableProvider({
|
|
23
|
+
parse: (value: Record<string, IFlowRefValue>, ctx) => [
|
|
24
|
+
ASTFactory.createVariableDeclaration({
|
|
25
|
+
key: `${ctx.node.id}`,
|
|
26
|
+
meta: {
|
|
27
|
+
title: getNodeForm(ctx.node)?.getValueIn('title'),
|
|
28
|
+
icon: ctx.node.getNodeRegistry<FlowNodeRegistry>().info?.icon,
|
|
29
|
+
},
|
|
30
|
+
type: ASTFactory.createObject({
|
|
31
|
+
properties: Object.entries(value).map(([_key, value]) =>
|
|
32
|
+
ASTFactory.createProperty({
|
|
33
|
+
key: _key,
|
|
34
|
+
initializer: ASTFactory.createWrapArrayExpression({
|
|
35
|
+
wrapFor: ASTFactory.createKeyPathExpression({
|
|
36
|
+
keyPath: value?.content || [],
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
})
|
|
40
|
+
),
|
|
41
|
+
}),
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Free Layout only right now
|
|
48
|
+
*/
|
|
49
|
+
export const createBatchOutputsFormPlugin: FormPluginCreator<{ outputKey: string }> =
|
|
50
|
+
defineFormPluginCreator({
|
|
51
|
+
name: 'batch-outputs-plugin',
|
|
52
|
+
onSetupFormMeta({ mergeEffect }, { outputKey }) {
|
|
53
|
+
mergeEffect({
|
|
54
|
+
[outputKey]: provideBatchOutputsEffect,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
onInit(ctx, { outputKey }) {
|
|
58
|
+
const chainTransformService = ctx.node.getService(ScopeChainTransformService);
|
|
59
|
+
|
|
60
|
+
const batchNodeType = ctx.node.flowNodeType;
|
|
61
|
+
|
|
62
|
+
const transformerId = `${batchNodeType}-outputs`;
|
|
63
|
+
|
|
64
|
+
if (chainTransformService.hasTransformer(transformerId)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
chainTransformService.registerTransformer(transformerId, {
|
|
69
|
+
transformCovers: (covers, ctx) => {
|
|
70
|
+
const node = ctx.scope.meta?.node;
|
|
71
|
+
|
|
72
|
+
// Child Node's variable can cover parent
|
|
73
|
+
if (node?.parent?.flowNodeType === batchNodeType) {
|
|
74
|
+
return [...covers, getNodeScope(node.parent)];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return covers;
|
|
78
|
+
},
|
|
79
|
+
transformDeps(scopes, ctx) {
|
|
80
|
+
const scopeMeta = ctx.scope.meta;
|
|
81
|
+
|
|
82
|
+
if (scopeMeta?.type === FlowNodeScopeType.private) {
|
|
83
|
+
return scopes;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const node = scopeMeta?.node;
|
|
87
|
+
|
|
88
|
+
// Public of Loop Node depends on child Node
|
|
89
|
+
if (node?.flowNodeType === batchNodeType) {
|
|
90
|
+
// Get all child blocks
|
|
91
|
+
const childBlocks = node.blocks;
|
|
92
|
+
|
|
93
|
+
// public scope of all child blocks
|
|
94
|
+
return [
|
|
95
|
+
getNodePrivateScope(node),
|
|
96
|
+
...childBlocks.map((_childBlock) => getNodeScope(_childBlock)),
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return scopes;
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
});
|
package/src/index.ts
CHANGED
package/src/typings/index.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import { get } from 'lodash';
|
|
2
7
|
import { ASTFactory, ASTKind, ASTMatch, ASTNode, ASTNodeJSON, BaseType } from '@flowgram.ai/editor';
|
|
3
8
|
|
|
@@ -109,7 +114,7 @@ export namespace JsonSchemaUtils {
|
|
|
109
114
|
type: 'object',
|
|
110
115
|
properties: drilldown
|
|
111
116
|
? Object.fromEntries(
|
|
112
|
-
|
|
117
|
+
typeAST.properties.map((property) => [property.key, astToSchema(property.type)!])
|
|
113
118
|
)
|
|
114
119
|
: {},
|
|
115
120
|
};
|