@flowgram.ai/form-materials 0.2.14 → 0.2.15
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 +54 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +50 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/json-schema-editor/index.tsx +8 -2
- package/src/effects/index.ts +2 -0
- package/src/effects/provide-json-schema-outputs/config.json +8 -0
- package/src/effects/provide-json-schema-outputs/index.ts +23 -0
- package/src/effects/sync-variable-title/config.json +5 -0
- package/src/effects/sync-variable-title/index.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/form-materials",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"chalk": "^5.3.0",
|
|
31
31
|
"inquirer": "^9.2.7",
|
|
32
32
|
"immer": "~10.1.1",
|
|
33
|
-
"@flowgram.ai/editor": "0.2.
|
|
33
|
+
"@flowgram.ai/editor": "0.2.15"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/lodash": "^4.14.137",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"tsup": "^8.0.1",
|
|
47
47
|
"typescript": "^5.0.4",
|
|
48
48
|
"vitest": "^0.34.6",
|
|
49
|
-
"@flowgram.ai/ts-config": "0.2.
|
|
50
|
-
"@flowgram.ai/eslint-config": "0.2.
|
|
49
|
+
"@flowgram.ai/ts-config": "0.2.15",
|
|
50
|
+
"@flowgram.ai/eslint-config": "0.2.15"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=16.8",
|
|
@@ -38,6 +38,7 @@ export function JsonSchemaEditor(props: {
|
|
|
38
38
|
value?: IJsonSchema;
|
|
39
39
|
onChange?: (value: IJsonSchema) => void;
|
|
40
40
|
config?: ConfigType;
|
|
41
|
+
className?: string;
|
|
41
42
|
}) {
|
|
42
43
|
const { value = { type: 'object' }, config = {}, onChange: onChangeProps } = props;
|
|
43
44
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
|
|
@@ -46,7 +47,7 @@ export function JsonSchemaEditor(props: {
|
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
return (
|
|
49
|
-
<UIContainer>
|
|
50
|
+
<UIContainer className={props.className}>
|
|
50
51
|
<UIProperties>
|
|
51
52
|
{propertyList.map((_property, index) => (
|
|
52
53
|
<PropertyEdit
|
|
@@ -63,7 +64,12 @@ export function JsonSchemaEditor(props: {
|
|
|
63
64
|
/>
|
|
64
65
|
))}
|
|
65
66
|
</UIProperties>
|
|
66
|
-
<Button
|
|
67
|
+
<Button
|
|
68
|
+
size="small"
|
|
69
|
+
style={{ marginTop: 10, marginLeft: 16 }}
|
|
70
|
+
icon={<IconPlus />}
|
|
71
|
+
onClick={onAddProperty}
|
|
72
|
+
>
|
|
67
73
|
{config?.addButtonText ?? 'Add'}
|
|
68
74
|
</Button>
|
|
69
75
|
</UIContainer>
|
package/src/effects/index.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ASTFactory,
|
|
3
|
+
EffectOptions,
|
|
4
|
+
FlowNodeRegistry,
|
|
5
|
+
createEffectFromVariableProvider,
|
|
6
|
+
getNodeForm,
|
|
7
|
+
} from '@flowgram.ai/editor';
|
|
8
|
+
|
|
9
|
+
import { JsonSchemaUtils } from '../../utils';
|
|
10
|
+
import { IJsonSchema } from '../../typings';
|
|
11
|
+
|
|
12
|
+
export const provideJsonSchemaOutputs: EffectOptions[] = createEffectFromVariableProvider({
|
|
13
|
+
parse: (value: IJsonSchema, ctx) => [
|
|
14
|
+
ASTFactory.createVariableDeclaration({
|
|
15
|
+
key: `${ctx.node.id}`,
|
|
16
|
+
meta: {
|
|
17
|
+
title: getNodeForm(ctx.node)?.getValueIn('title') || ctx.node.id,
|
|
18
|
+
icon: ctx.node.getNodeRegistry<FlowNodeRegistry>().info?.icon,
|
|
19
|
+
},
|
|
20
|
+
type: JsonSchemaUtils.schemaToAST(value),
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DataEvent,
|
|
3
|
+
Effect,
|
|
4
|
+
EffectOptions,
|
|
5
|
+
FlowNodeRegistry,
|
|
6
|
+
FlowNodeVariableData,
|
|
7
|
+
} from '@flowgram.ai/editor';
|
|
8
|
+
|
|
9
|
+
export const syncVariableTitle: EffectOptions[] = [
|
|
10
|
+
{
|
|
11
|
+
event: DataEvent.onValueChange,
|
|
12
|
+
effect: (({ value, context }) => {
|
|
13
|
+
context.node.getData(FlowNodeVariableData).allScopes.forEach((_scope) => {
|
|
14
|
+
_scope.output.variables.forEach((_var) => {
|
|
15
|
+
_var.updateMeta({
|
|
16
|
+
title: value || context.node.id,
|
|
17
|
+
icon: context.node.getNodeRegistry<FlowNodeRegistry>().info?.icon,
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}) as Effect,
|
|
22
|
+
},
|
|
23
|
+
];
|