@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/dist/esm/index.js CHANGED
@@ -764,6 +764,7 @@ function TypeSelector(props) {
764
764
  // src/components/json-schema-editor/index.tsx
765
765
  import React10, { useMemo as useMemo4, useState as useState4 } from "react";
766
766
  import { Button as Button2, Checkbox } from "antd";
767
+ import { I18n as I18n2 } from "@flowgram.ai/editor";
767
768
  import {
768
769
  DownOutlined as DownOutlined2,
769
770
  ExpandAltOutlined,
@@ -1274,7 +1275,25 @@ function BlurInput(props) {
1274
1275
  }
1275
1276
 
1276
1277
  // src/components/json-schema-editor/index.tsx
1277
- import { I18n as I18n2 } from "@flowgram.ai/editor";
1278
+ function getSchemaDefaultValue(schema) {
1279
+ switch (schema?.type) {
1280
+ case "string":
1281
+ return "";
1282
+ case "integer":
1283
+ case "number":
1284
+ return 0;
1285
+ case "boolean":
1286
+ return false;
1287
+ case "object":
1288
+ return "{}";
1289
+ case "array":
1290
+ return "[]";
1291
+ case "map":
1292
+ return "[]";
1293
+ default:
1294
+ return void 0;
1295
+ }
1296
+ }
1278
1297
  function JsonSchemaEditor(props) {
1279
1298
  const { value = { type: "object" }, config = {}, onChange: onChangeProps } = props;
1280
1299
  const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(
@@ -1366,9 +1385,11 @@ function PropertyEdit(props) {
1366
1385
  {
1367
1386
  value: typeSelectorValue,
1368
1387
  onChange: (_value) => {
1388
+ const nextTypeSchema = _value || {};
1369
1389
  onChangeProps?.({
1370
1390
  ...value || {},
1371
- ..._value
1391
+ ...nextTypeSchema,
1392
+ default: getSchemaDefaultValue(nextTypeSchema)
1372
1393
  });
1373
1394
  }
1374
1395
  }