ronds-metadata 1.1.79 → 1.1.81

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.
@@ -1,14 +1,18 @@
1
+ import "antd/es/row/style";
2
+ import _Row from "antd/es/row";
1
3
  import "antd/es/form/style";
2
4
  import _Form from "antd/es/form";
3
5
  import "antd/es/button/style";
4
6
  import _Button from "antd/es/button";
5
7
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
8
+ import "antd/es/col/style";
9
+ import _Col from "antd/es/col";
6
10
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
11
 
8
12
  /*
9
13
  * @Author: wangxian
10
14
  * @Date: 2021-09-18 14:15:04
11
- * @LastEditTime: 2022-12-05 09:45:03
15
+ * @LastEditTime: 2023-01-10 15:06:46
12
16
  */
13
17
  import React from 'react';
14
18
  import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
@@ -55,13 +59,16 @@ function Index(props) {
55
59
  setHelp(arr[arr.length - 1]);
56
60
  }
57
61
  }, [items]);
58
- return /*#__PURE__*/React.createElement(React.Fragment, null, !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && /*#__PURE__*/React.createElement("div", {
62
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, null, /*#__PURE__*/React.createElement(_Col, {
63
+ span: (formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan : 24
64
+ }, !(extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.titleHidden) && /*#__PURE__*/React.createElement("div", {
59
65
  style: {
60
66
  position: 'relative',
61
- width: '100%'
67
+ width: '100%',
68
+ textAlign: "".concat((formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? 'right' : 'left')
62
69
  }
63
70
  }, /*#__PURE__*/React.createElement("div", {
64
- className: "ant-form-item-label mt-1"
71
+ className: "ant-form-item-label mt-1 "
65
72
  }, /*#__PURE__*/React.createElement("label", {
66
73
  className: "".concat((extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.require) && 'ant-form-item-required')
67
74
  }, extraInfo.label || fieldRule && ((_fieldRule$ = fieldRule[0]) === null || _fieldRule$ === void 0 ? void 0 : (_fieldRule$$value = _fieldRule$.value) === null || _fieldRule$$value === void 0 ? void 0 : _fieldRule$$value.label) || fieldRule && ((_fieldRule$2 = fieldRule[0]) === null || _fieldRule$2 === void 0 ? void 0 : (_fieldRule$2$value = _fieldRule$2.value) === null || _fieldRule$2$value === void 0 ? void 0 : _fieldRule$2$value.common.label) || id)), formContext.isShowTypeInfo && /*#__PURE__*/React.createElement("div", {
@@ -72,7 +79,9 @@ function Index(props) {
72
79
  top: '19px',
73
80
  background: '#fff'
74
81
  }
75
- }, help || (items === null || items === void 0 ? void 0 : items.type))), extraInfo.layout === 'table' && items.type === 'ref' ? /*#__PURE__*/React.createElement(TableArray, {
82
+ }, help || (items === null || items === void 0 ? void 0 : items.type)))), /*#__PURE__*/React.createElement(_Col, {
83
+ span: (formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) && (formContext === null || formContext === void 0 ? void 0 : formContext.layout) === 'horizontal' ? 24 - (formContext === null || formContext === void 0 ? void 0 : formContext.labelSpan) : 24
84
+ }, extraInfo.layout === 'table' && items.type === 'ref' ? /*#__PURE__*/React.createElement(TableArray, {
76
85
  initValue: formContext.initialValues,
77
86
  readonly: (_extraInfo$disabled = extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.disabled) !== null && _extraInfo$disabled !== void 0 ? _extraInfo$disabled : disabled,
78
87
  addButtonHidden: extraInfo === null || extraInfo === void 0 ? void 0 : extraInfo.addButtonHidden,
@@ -128,7 +137,7 @@ function Index(props) {
128
137
  },
129
138
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null)
130
139
  }, tr('添加'))));
131
- })));
140
+ })))));
132
141
  }
133
142
 
134
143
  export default /*#__PURE__*/React.memo(Index);
@@ -3,6 +3,10 @@ import "antd/es/form/style";
3
3
  import _Form from "antd/es/form";
4
4
  import "antd/es/select/style";
5
5
  import _Select from "antd/es/select";
6
+ import "antd/es/row/style";
7
+ import _Row from "antd/es/row";
8
+ import "antd/es/col/style";
9
+ import _Col from "antd/es/col";
6
10
  import "antd/es/button/style";
7
11
  import _Button from "antd/es/button";
8
12
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
@@ -175,7 +179,7 @@ function Index(props) {
175
179
  };
176
180
  }(), [refId]);
177
181
  React.useEffect(function () {
178
- if (refId) {
182
+ if (refId && formContext.__TYPE__) {
179
183
  var server = new MetadataService();
180
184
  getSchemaByRefId(server, formContext.__TYPE__);
181
185
  return function () {
@@ -195,7 +199,9 @@ function Index(props) {
195
199
  if (isRefForm && !field && schema.length > 0) {
196
200
  var _fieldRule$, _fieldRule$$value, _fieldRule$2, _fieldRule$2$value, _fieldRule$2$value$co;
197
201
 
198
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
202
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Row, null, /*#__PURE__*/React.createElement(_Col, {
203
+ span: 24
204
+ }, /*#__PURE__*/React.createElement("div", {
199
205
  style: {
200
206
  display: 'flex',
201
207
  alignItems: 'center'
@@ -220,7 +226,9 @@ function Index(props) {
220
226
  setIsFold(!isFold);
221
227
  },
222
228
  icon: isFold ? /*#__PURE__*/React.createElement(CaretDownOutlined, null) : /*#__PURE__*/React.createElement(CaretUpOutlined, null)
223
- }))), /*#__PURE__*/React.createElement("div", {
229
+ })))), /*#__PURE__*/React.createElement(_Col, {
230
+ span: 24
231
+ }, /*#__PURE__*/React.createElement("div", {
224
232
  style: {
225
233
  padding: '10px',
226
234
  border: '1px solid var(--ronds-metadata-color-border-1)',
@@ -233,7 +241,7 @@ function Index(props) {
233
241
  value: {
234
242
  fields: refFieldsRef.current
235
243
  }
236
- }, renderForm(schema, formOptions, formContext.colSpan))));
244
+ }, renderForm(schema, formOptions, formContext.colSpan))))));
237
245
  }
238
246
 
239
247
  if (isRefForm && field && schema.length > 0) {
@@ -49,7 +49,7 @@ var MetadataForm = function MetadataForm(props) {
49
49
  mySchma = _React$useState2[0],
50
50
  setMySchema = _React$useState2[1];
51
51
 
52
- var _React$useState3 = React.useState([]),
52
+ var _React$useState3 = React.useState(),
53
53
  _React$useState4 = _slicedToArray(_React$useState3, 2),
54
54
  innerSchemas = _React$useState4[0],
55
55
  setInnerSchemas = _React$useState4[1];
@@ -104,6 +104,7 @@ var MetadataForm = function MetadataForm(props) {
104
104
  React.useEffect(function () {
105
105
  if (schema && schema.length > 0) {
106
106
  setMySchema(_toConsumableArray(schema));
107
+ setInnerSchemas(undefined);
107
108
  }
108
109
  }, [schema]);
109
110
  React.useEffect(function () {
@@ -194,6 +195,8 @@ var MetadataForm = function MetadataForm(props) {
194
195
  value: {
195
196
  fields: fields,
196
197
  colSpan: colSpan,
198
+ labelSpan: labelSpan,
199
+ layout: layout,
197
200
  form: form,
198
201
  stream$: stream$,
199
202
  initialValues: initialValues,
@@ -203,11 +206,11 @@ var MetadataForm = function MetadataForm(props) {
203
206
  }
204
207
  }, /*#__PURE__*/React.createElement(_Form, {
205
208
  className: "metadata-form",
206
- wrapperCol: labelSpan ? {
209
+ wrapperCol: labelSpan && layout === 'horizontal' ? {
207
210
  span: 24 - labelSpan,
208
211
  offset: 0
209
212
  } : undefined,
210
- labelCol: labelSpan ? {
213
+ labelCol: labelSpan && layout === 'horizontal' ? {
211
214
  span: labelSpan,
212
215
  offset: 0
213
216
  } : undefined,
@@ -11,7 +11,7 @@
11
11
  .ant-form-item-label {
12
12
  padding: 0px !important;
13
13
  }
14
-
14
+
15
15
  .ant-input-number,
16
16
  .ant-picker {
17
17
  width: 100%;
@@ -4,6 +4,8 @@ import { IMetaData } from '../../framework/metadata/types';
4
4
  export interface IMetadataFormContextProps {
5
5
  fields: any;
6
6
  colSpan: number;
7
+ labelSpan: number;
8
+ layout: 'vertical' | 'horizontal';
7
9
  form: FormInstance;
8
10
  stream$: any;
9
11
  initialValues: any;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author:wangxian
3
3
  * @Date: 2021-09-18 14:15:04
4
- * @LastEditTime: 2022-11-02 10:58:49
4
+ * @LastEditTime: 2023-01-10 15:05:31
5
5
  */
6
6
  import React from 'react';
7
7
  export var MetadataFormContext = /*#__PURE__*/React.createContext(null);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.1.79",
4
+ "version": "1.1.81",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",