@flowgram.ai/form-antd-materials 1.0.9 → 1.0.11

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-antd-materials",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "homepage": "https://flowgram.ai/",
5
5
  "repository": "https://github.com/bytedance/flowgram.ai",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "@ant-design/icons": "5.x",
21
21
  "antd": "^5.25.4",
22
22
  "lodash-es": "^4.17.21",
23
- "@flowgram.ai/editor": "1.0.9"
23
+ "@flowgram.ai/editor": "1.0.11"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/lodash-es": "^4.17.12",
@@ -36,8 +36,8 @@
36
36
  "tsup": "^8.0.1",
37
37
  "typescript": "^5.8.3",
38
38
  "vitest": "^3.2.4",
39
- "@flowgram.ai/eslint-config": "1.0.9",
40
- "@flowgram.ai/ts-config": "1.0.9"
39
+ "@flowgram.ai/eslint-config": "1.0.11",
40
+ "@flowgram.ai/ts-config": "1.0.11"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": ">=16.8",
@@ -6,6 +6,7 @@
6
6
  import React, { useMemo, useState } from 'react';
7
7
 
8
8
  import { Button, Checkbox } from 'antd';
9
+ import { I18n } from '@flowgram.ai/editor';
9
10
  import {
10
11
  DownOutlined,
11
12
  ExpandAltOutlined,
@@ -39,7 +40,26 @@ import {
39
40
  import { usePropertiesEdit } from './hooks';
40
41
  import { DefaultValue } from './default-value';
41
42
  import { BlurInput } from './components/blur-input';
42
- import { I18n } from '@flowgram.ai/editor';
43
+
44
+ function getSchemaDefaultValue(schema: Partial<IJsonSchema> | undefined) {
45
+ switch (schema?.type) {
46
+ case 'string':
47
+ return '';
48
+ case 'integer':
49
+ case 'number':
50
+ return 0;
51
+ case 'boolean':
52
+ return false;
53
+ case 'object':
54
+ return '{}';
55
+ case 'array':
56
+ return '[]';
57
+ case 'map':
58
+ return '[]';
59
+ default:
60
+ return undefined;
61
+ }
62
+ }
43
63
 
44
64
  export function JsonSchemaEditor(props: {
45
65
  value?: IJsonSchema;
@@ -166,9 +186,11 @@ function PropertyEdit(props: {
166
186
  <TypeSelector
167
187
  value={typeSelectorValue}
168
188
  onChange={(_value) => {
189
+ const nextTypeSchema = _value || {};
169
190
  onChangeProps?.({
170
191
  ...(value || {}),
171
- ..._value,
192
+ ...nextTypeSchema,
193
+ default: getSchemaDefaultValue(nextTypeSchema),
172
194
  });
173
195
  }}
174
196
  />