@flowgram.ai/form-materials 0.2.14 → 0.2.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/form-materials",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
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.14"
33
+ "@flowgram.ai/editor": "0.2.16"
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.14",
50
- "@flowgram.ai/eslint-config": "0.2.14"
49
+ "@flowgram.ai/eslint-config": "0.2.16",
50
+ "@flowgram.ai/ts-config": "0.2.16"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "react": ">=16.8",
@@ -68,4 +68,4 @@ export function ConditionRow({ style, value, onChange, readonly }: PropTypes) {
68
68
  );
69
69
  }
70
70
 
71
- export { ConditionRowValueType };
71
+ export { type ConditionRowValueType };
@@ -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 size="small" style={{ marginTop: 10 }} icon={<IconPlus />} onClick={onAddProperty}>
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>
@@ -1,3 +1,5 @@
1
1
  export * from './provide-batch-input';
2
2
  export * from './provide-batch-outputs';
3
3
  export * from './auto-rename-ref';
4
+ export * from './provide-json-schema-outputs';
5
+ export * from './sync-variable-title';
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "provide-json-schema-outputs",
3
+ "depMaterials": [
4
+ "typings/json-schema",
5
+ "utils/json-schema"
6
+ ],
7
+ "depPackages": []
8
+ }
@@ -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,5 @@
1
+ {
2
+ "name": "sync-variable-title",
3
+ "depMaterials": [],
4
+ "depPackages": []
5
+ }
@@ -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
+ ];