@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.
Files changed (54) hide show
  1. package/bin/materials.ts +6 -1
  2. package/bin/project.ts +5 -0
  3. package/dist/esm/index.js +207 -8
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.mts +149 -6
  6. package/dist/index.d.ts +149 -6
  7. package/dist/index.js +202 -9
  8. package/dist/index.js.map +1 -1
  9. package/package.json +4 -4
  10. package/src/components/batch-outputs/config.json +12 -0
  11. package/src/components/batch-outputs/index.tsx +61 -0
  12. package/src/components/batch-outputs/styles.tsx +19 -0
  13. package/src/components/batch-outputs/types.ts +22 -0
  14. package/src/components/batch-outputs/use-list.ts +86 -0
  15. package/src/components/batch-variable-selector/index.tsx +5 -0
  16. package/src/components/condition-row/constants.ts +5 -0
  17. package/src/components/condition-row/hooks/useOp.tsx +5 -0
  18. package/src/components/condition-row/hooks/useRule.ts +5 -0
  19. package/src/components/condition-row/index.tsx +6 -1
  20. package/src/components/condition-row/styles.tsx +5 -0
  21. package/src/components/condition-row/types.ts +5 -0
  22. package/src/components/constant-input/index.tsx +5 -0
  23. package/src/components/constant-input/types.ts +5 -0
  24. package/src/components/dynamic-value-input/index.tsx +6 -0
  25. package/src/components/dynamic-value-input/styles.tsx +5 -0
  26. package/src/components/index.ts +6 -0
  27. package/src/components/json-schema-editor/components/blur-input.tsx +5 -0
  28. package/src/components/json-schema-editor/default-value.tsx +5 -0
  29. package/src/components/json-schema-editor/hooks.tsx +5 -0
  30. package/src/components/json-schema-editor/index.tsx +5 -0
  31. package/src/components/json-schema-editor/styles.tsx +5 -0
  32. package/src/components/json-schema-editor/types.ts +5 -0
  33. package/src/components/json-schema-editor/utils.ts +5 -0
  34. package/src/components/type-selector/constants.tsx +5 -0
  35. package/src/components/type-selector/index.tsx +5 -0
  36. package/src/components/variable-selector/index.tsx +7 -0
  37. package/src/components/variable-selector/styles.tsx +5 -0
  38. package/src/components/variable-selector/use-variable-tree.tsx +8 -3
  39. package/src/effects/auto-rename-ref/index.ts +5 -0
  40. package/src/effects/index.ts +5 -0
  41. package/src/effects/provide-batch-input/index.ts +5 -0
  42. package/src/effects/provide-batch-outputs/index.ts +5 -1
  43. package/src/effects/provide-json-schema-outputs/index.ts +5 -0
  44. package/src/effects/sync-variable-title/index.ts +5 -0
  45. package/src/form-plugins/batch-outputs-plugin/config.json +7 -0
  46. package/src/form-plugins/batch-outputs-plugin/index.ts +104 -0
  47. package/src/form-plugins/index.ts +6 -0
  48. package/src/index.ts +6 -0
  49. package/src/typings/flow-value/index.ts +5 -0
  50. package/src/typings/index.ts +5 -0
  51. package/src/typings/json-schema/index.ts +5 -0
  52. package/src/utils/format-legacy-refs/index.ts +5 -0
  53. package/src/utils/index.ts +5 -0
  54. 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
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export { createBatchOutputsFormPlugin } from './batch-outputs-plugin';
package/src/index.ts CHANGED
@@ -1,4 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  export * from './components';
2
7
  export * from './effects';
3
8
  export * from './utils';
4
9
  export * from './typings';
10
+ export * from './form-plugins';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  export interface IFlowConstantValue {
2
7
  type: 'constant';
3
8
  content?: string | number | boolean;
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  export * from './flow-value';
2
7
  export * from './json-schema';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  export type JsonSchemaBasicType =
2
7
  | 'boolean'
3
8
  | 'string'
@@ -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 { isObject } from 'lodash';
2
7
 
3
8
  interface LegacyFlowRefValueSchema {
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
1
6
  export * from './format-legacy-refs';
2
7
  export * from './json-schema';
@@ -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
- Object.entries(typeAST.properties).map(([key, value]) => [key, astToSchema(value)!])
117
+ typeAST.properties.map((property) => [property.key, astToSchema(property.type)!])
113
118
  )
114
119
  : {},
115
120
  };