ronds-metadata 1.0.14 → 1.0.18

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.
@@ -14,7 +14,7 @@ import _Input from "antd/es/input";
14
14
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
15
15
  import React from 'react';
16
16
  import { MinusCircleOutlined, PlusOutlined, ReloadOutlined } from '@ant-design/icons';
17
- import { BASIC_TYPES_OPTIONS, NUMBER_FORMAT_OPTIONS } from '../constant';
17
+ import { ARRAY_TYPES_OPTIONS, BASIC_TYPES_OPTIONS, NUMBER_FORMAT_OPTIONS } from '../constant';
18
18
  import { useMetaType } from '../hooks';
19
19
 
20
20
  var MetaPropsEdit = function MetaPropsEdit(props) {
@@ -114,7 +114,7 @@ var MetaPropsEdit = function MetaPropsEdit(props) {
114
114
  return (prevValues === null || prevValues === void 0 ? void 0 : (_prevValues$name$inde = prevValues[name][index]) === null || _prevValues$name$inde === void 0 ? void 0 : _prevValues$name$inde.type) !== (currentValues === null || currentValues === void 0 ? void 0 : (_currentValues$name$i = currentValues[name][index]) === null || _currentValues$name$i === void 0 ? void 0 : _currentValues$name$i.type) || (prevValues === null || prevValues === void 0 ? void 0 : (_prevValues$name$inde2 = prevValues[name][index]) === null || _prevValues$name$inde2 === void 0 ? void 0 : _prevValues$name$inde2.items) !== (currentValues === null || currentValues === void 0 ? void 0 : (_currentValues$name$i2 = currentValues[name][index]) === null || _currentValues$name$i2 === void 0 ? void 0 : _currentValues$name$i2.items);
115
115
  }
116
116
  }, function (_ref2) {
117
- var _properties$index, _properties$index2, _properties$index2$it;
117
+ var _properties$index, _properties$index2, _properties$index2$it, _properties$index3, _properties$index3$it;
118
118
 
119
119
  var getFieldValue = _ref2.getFieldValue;
120
120
 
@@ -216,7 +216,7 @@ var MetaPropsEdit = function MetaPropsEdit(props) {
216
216
  style: {
217
217
  width: '180px'
218
218
  },
219
- options: BASIC_TYPES_OPTIONS
219
+ options: ARRAY_TYPES_OPTIONS
220
220
  })), _properties && ((_properties$index2 = _properties[index]) === null || _properties$index2 === void 0 ? void 0 : (_properties$index2$it = _properties$index2.items) === null || _properties$index2$it === void 0 ? void 0 : _properties$index2$it.type) === 'ref' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
221
221
  label: "Ref",
222
222
  name: [field.name, 'items', 'refId'],
@@ -258,7 +258,19 @@ var MetaPropsEdit = function MetaPropsEdit(props) {
258
258
  }, 100);
259
259
  },
260
260
  icon: /*#__PURE__*/React.createElement(ReloadOutlined, null)
261
- })))));
261
+ })))), _properties && ((_properties$index3 = _properties[index]) === null || _properties$index3 === void 0 ? void 0 : (_properties$index3$it = _properties$index3.items) === null || _properties$index3$it === void 0 ? void 0 : _properties$index3$it.type) === 'number' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form.Item, _extends({}, field, {
262
+ label: "format",
263
+ name: [field.name, 'items', 'format'],
264
+ fieldKey: [field.fieldKey, 'items', 'format'],
265
+ rules: [{
266
+ required: true
267
+ }]
268
+ }), /*#__PURE__*/React.createElement(_Select, {
269
+ style: {
270
+ width: '180px'
271
+ },
272
+ options: NUMBER_FORMAT_OPTIONS
273
+ }))));
262
274
 
263
275
  case 'enum':
264
276
  return /*#__PURE__*/React.createElement("div", {
@@ -2,6 +2,10 @@ export declare const BASIC_TYPES_OPTIONS: {
2
2
  label: string;
3
3
  value: string;
4
4
  }[];
5
+ export declare const ARRAY_TYPES_OPTIONS: {
6
+ label: string;
7
+ value: string;
8
+ }[];
5
9
  export declare const OUTERMOST_TYPES_OPTIONS: {
6
10
  label: string;
7
11
  value: string;
@@ -17,6 +17,19 @@ export var BASIC_TYPES_OPTIONS = [{
17
17
  label: '引用类型',
18
18
  value: 'ref'
19
19
  }];
20
+ export var ARRAY_TYPES_OPTIONS = [{
21
+ label: '数字',
22
+ value: 'number'
23
+ }, {
24
+ label: '文本',
25
+ value: 'text'
26
+ }, {
27
+ label: '布尔类型',
28
+ value: 'bool'
29
+ }, {
30
+ label: '引用类型',
31
+ value: 'ref'
32
+ }];
20
33
  export var OUTERMOST_TYPES_OPTIONS = [{
21
34
  label: '对象',
22
35
  value: 'object'
@@ -69,6 +69,7 @@ var MetadataEdit = function MetadataEdit(props) {
69
69
  if (initialValues) {
70
70
  form.setFieldsValue(_objectSpread({}, initialValues));
71
71
  setMetaSchema(_objectSpread({}, initialValues));
72
+ processFileds(initialValues);
72
73
  }
73
74
  }, [form, initialValues]);
74
75
 
@@ -111,8 +112,7 @@ var MetadataEdit = function MetadataEdit(props) {
111
112
  return;
112
113
  }
113
114
 
114
- var _properties = form.getFieldValue('properties');
115
-
115
+ var _properties = metaSchema.properties;
116
116
  var _curFields = _properties[index];
117
117
 
118
118
  if (_curFields && _curFields.id) {
@@ -142,6 +142,21 @@ var MetadataEdit = function MetadataEdit(props) {
142
142
  setOutType(value);
143
143
  };
144
144
 
145
+ var processFileds = function processFileds(schema) {
146
+ var _properties = schema.properties;
147
+ var _fields = fields;
148
+
149
+ if (_properties) {
150
+ for (var i = 0; i < _properties.length; i++) {
151
+ if (_properties[i].fields) {
152
+ _fields[_properties[i].id] = _properties[i].fields;
153
+ }
154
+ }
155
+
156
+ setFields(_objectSpread({}, _fields));
157
+ }
158
+ };
159
+
145
160
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Form, {
146
161
  className: "metadata-edit",
147
162
  initialValues: initialValues,
@@ -1,5 +1,4 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
3
  import React from 'react';
5
4
  export var useGetExtraInfo = function useGetExtraInfo(fields, id, form) {
@@ -18,11 +17,11 @@ export var useGetExtraInfo = function useGetExtraInfo(fields, id, form) {
18
17
 
19
18
  for (var k in extraInfo) {
20
19
  _extraInfo[k] = extraInfo[k];
21
- }
20
+ } // 暂时注释加载默认值
21
+ // if (_extraInfo?.defaultValue) {
22
+ // form.setFieldsValue({ [id]: _extraInfo?.defaultValue });
23
+ // }
22
24
 
23
- if (_extraInfo === null || _extraInfo === void 0 ? void 0 : _extraInfo.defaultValue) {
24
- form.setFieldsValue(_defineProperty({}, id, _extraInfo === null || _extraInfo === void 0 ? void 0 : _extraInfo.defaultValue));
25
- }
26
25
 
27
26
  setExtra(_objectSpread({}, _extraInfo));
28
27
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.0.14",
4
+ "version": "1.0.18",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",