@nocobase/client 0.9.4-alpha.1 → 0.9.4-alpha.2

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.
Files changed (49) hide show
  1. package/es/locale/zh_CN.d.ts +1 -0
  2. package/es/locale/zh_CN.js +2 -1
  3. package/es/pm/PluginManagerLink.js +22 -14
  4. package/es/schema-component/antd/action/Action.Designer.js +2 -2
  5. package/es/schema-component/antd/action/Action.Drawer.js +1 -1
  6. package/es/schema-component/antd/action/Action.js +2 -2
  7. package/es/schema-component/antd/association-field/AssociationFieldProvider.js +47 -5
  8. package/es/schema-component/antd/association-field/Editable.js +1 -33
  9. package/es/schema-component/antd/association-field/Nester.js +10 -3
  10. package/es/schema-component/antd/association-field/context.d.ts +2 -0
  11. package/es/schema-component/antd/association-field/hooks.d.ts +2 -0
  12. package/es/schema-component/antd/filter/FilterAction.js +2 -2
  13. package/es/schema-component/antd/form-item/FormItem.js +25 -8
  14. package/es/schema-component/antd/form-v2/Templates.js +2 -0
  15. package/es/schema-component/antd/icon-picker/IconPicker.js +2 -2
  16. package/es/schema-component/antd/input/EllipsisWithTooltip.js +2 -2
  17. package/es/schema-component/antd/remote-select/RemoteSelect.js +1 -1
  18. package/es/schema-component/antd/select/Select.js +13 -4
  19. package/es/schema-component/common/sortable-item/SortableItem.js +3 -4
  20. package/es/schema-settings/DataTemplates/components/AsDefaultTemplate.js +1 -1
  21. package/es/schema-settings/DataTemplates/components/DataTemplateTitle.js +9 -13
  22. package/es/schema-settings/SchemaSettings.js +2 -2
  23. package/es/settings-form/SettingsForm.js +2 -2
  24. package/es/user/CurrentUser.js +2 -2
  25. package/lib/locale/zh_CN.d.ts +1 -0
  26. package/lib/locale/zh_CN.js +2 -1
  27. package/lib/pm/PluginManagerLink.js +21 -13
  28. package/lib/schema-component/antd/action/Action.Designer.js +2 -2
  29. package/lib/schema-component/antd/action/Action.Drawer.js +1 -1
  30. package/lib/schema-component/antd/action/Action.js +2 -2
  31. package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +46 -4
  32. package/lib/schema-component/antd/association-field/Editable.js +2 -35
  33. package/lib/schema-component/antd/association-field/Nester.js +10 -3
  34. package/lib/schema-component/antd/association-field/context.d.ts +2 -0
  35. package/lib/schema-component/antd/association-field/hooks.d.ts +2 -0
  36. package/lib/schema-component/antd/filter/FilterAction.js +2 -2
  37. package/lib/schema-component/antd/form-item/FormItem.js +25 -8
  38. package/lib/schema-component/antd/form-v2/Templates.js +2 -0
  39. package/lib/schema-component/antd/icon-picker/IconPicker.js +2 -2
  40. package/lib/schema-component/antd/input/EllipsisWithTooltip.js +2 -2
  41. package/lib/schema-component/antd/remote-select/RemoteSelect.js +1 -1
  42. package/lib/schema-component/antd/select/Select.js +12 -3
  43. package/lib/schema-component/common/sortable-item/SortableItem.js +3 -4
  44. package/lib/schema-settings/DataTemplates/components/AsDefaultTemplate.js +1 -1
  45. package/lib/schema-settings/DataTemplates/components/DataTemplateTitle.js +10 -14
  46. package/lib/schema-settings/SchemaSettings.js +2 -2
  47. package/lib/settings-form/SettingsForm.js +2 -2
  48. package/lib/user/CurrentUser.js +2 -2
  49. package/package.json +5 -5
@@ -310,6 +310,7 @@ declare const _default: {
310
310
  "Display field title": string;
311
311
  "Field component": string;
312
312
  "Allow multiple": string;
313
+ "Allow dissociate": string;
313
314
  "Quick upload": string;
314
315
  "Select file": string;
315
316
  Subtable: string;
@@ -309,7 +309,8 @@ export default {
309
309
  "Display association fields": "显示关联表的字段",
310
310
  "Display field title": "显示字段标题",
311
311
  "Field component": "字段组件",
312
- "Allow multiple": "允许多选",
312
+ "Allow multiple": "允许添加/关联多条",
313
+ "Allow dissociate": "允许移除已关联记录",
313
314
  "Quick upload": "快速上传",
314
315
  "Select file": "选择文件",
315
316
  "Subtable": "子表格",
@@ -1,4 +1,8 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
2
6
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
7
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
8
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -11,7 +15,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
11
15
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
16
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
17
  import { ApiOutlined, SettingOutlined } from '@ant-design/icons';
14
- import { Button, Dropdown, Menu, Tooltip } from 'antd';
18
+ import { Button, Dropdown, Tooltip } from 'antd';
15
19
  import React, { useContext, useState } from 'react';
16
20
  import { useTranslation } from 'react-i18next';
17
21
  import { useHistory } from 'react-router-dom';
@@ -66,19 +70,23 @@ export var SettingsCenterDropdown = function SettingsCenterDropdown() {
66
70
  }
67
71
  }, /*#__PURE__*/React.createElement(Dropdown, {
68
72
  placement: "bottom",
69
- overlay: /*#__PURE__*/React.createElement(Menu, null, bookmarkTabs.map(function (tab) {
70
- return /*#__PURE__*/React.createElement(Menu.Item, {
71
- onClick: function onClick() {
72
- history.push('/admin/settings/' + tab.path);
73
- },
74
- key: tab.path
75
- }, compile(tab.title));
76
- }), /*#__PURE__*/React.createElement(Menu.Divider, null), /*#__PURE__*/React.createElement(Menu.Item, {
77
- onClick: function onClick() {
78
- history.push('/admin/settings');
79
- },
80
- key: "/admin/settings"
81
- }, t('All plugin settings')))
73
+ menu: {
74
+ items: [].concat(_toConsumableArray(bookmarkTabs.map(function (tab) {
75
+ return {
76
+ key: "/admin/settings/".concat(tab.path),
77
+ label: compile(tab.title)
78
+ };
79
+ })), [{
80
+ type: 'divider'
81
+ }, {
82
+ key: '/admin/settings',
83
+ label: t('All plugin settings')
84
+ }]),
85
+ onClick: function onClick(_ref) {
86
+ var key = _ref.key;
87
+ history.push(key);
88
+ }
89
+ }
82
90
  }, /*#__PURE__*/React.createElement(Button, {
83
91
  icon: /*#__PURE__*/React.createElement(SettingOutlined, null)
84
92
  })));
@@ -290,7 +290,7 @@ export var ActionDesigner = function ActionDesigner(props) {
290
290
  }
291
291
  }), isChildCollectionAction && /*#__PURE__*/React.createElement(SchemaSettings.EnableChildCollections, {
292
292
  collectionName: name
293
- }), !isDelete && [/*#__PURE__*/React.createElement(SchemaSettings.Divider, null), /*#__PURE__*/React.createElement(SchemaSettings.Remove, {
293
+ }), !isDelete && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SchemaSettings.Divider, null), /*#__PURE__*/React.createElement(SchemaSettings.Remove, {
294
294
  removeParentsIfNoChildren: true,
295
295
  breakRemoveOn: function breakRemoveOn(s) {
296
296
  return s['x-component'] === 'Space' || s['x-component'].endsWith('ActionBar');
@@ -298,5 +298,5 @@ export var ActionDesigner = function ActionDesigner(props) {
298
298
  confirm: {
299
299
  title: t('Delete action')
300
300
  }
301
- })]));
301
+ }))));
302
302
  };
@@ -49,7 +49,7 @@ export var ActionDrawer = observer(function (props) {
49
49
  title: field.title
50
50
  }, others), {}, {
51
51
  destroyOnClose: true,
52
- visible: visible,
52
+ open: visible,
53
53
  onClose: function onClose() {
54
54
  return setVisible(false, true);
55
55
  },
@@ -148,8 +148,8 @@ Action.Popover = observer(function (props) {
148
148
  setVisible = _useActionContext.setVisible;
149
149
  return /*#__PURE__*/React.createElement(Popover, _objectSpread(_objectSpread({}, props), {}, {
150
150
  destroyTooltipOnHide: true,
151
- visible: visible,
152
- onVisibleChange: function onVisibleChange(visible) {
151
+ open: visible,
152
+ onOpenChange: function onOpenChange(visible) {
153
153
  setVisible(visible);
154
154
  },
155
155
  content: props.children
@@ -1,14 +1,22 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  import { observer, useField, useFieldSchema } from '@formily/react';
2
- import React, { useMemo } from 'react';
8
+ import React, { useEffect, useMemo, useState } from 'react';
3
9
  import { useCollectionManager } from '../../../collection-manager';
4
10
  import { AssociationFieldContext } from './context';
5
11
  export var AssociationFieldProvider = observer(function (props) {
6
- var _fieldSchema$xCompon2;
12
+ var _fieldSchema$xCompon, _fieldSchema$xCompon2, _fieldSchema$xCompon4;
7
13
  var field = useField();
8
14
  var _useCollectionManager = useCollectionManager(),
9
15
  getCollectionJoinField = _useCollectionManager.getCollectionJoinField,
10
16
  getCollection = _useCollectionManager.getCollection;
11
17
  var fieldSchema = useFieldSchema();
18
+ var allowMultiple = ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.multiple) !== false;
19
+ var allowDissociate = ((_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.allowDissociate) !== false;
12
20
  var collectionField = useMemo(function () {
13
21
  return getCollectionJoinField(fieldSchema['x-collection-field']);
14
22
  }, [fieldSchema['x-collection-field'], fieldSchema.name]);
@@ -17,13 +25,47 @@ export var AssociationFieldProvider = observer(function (props) {
17
25
  return ((_getCollection = getCollection(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target)) === null || _getCollection === void 0 ? void 0 : _getCollection.template) === 'file';
18
26
  }, [fieldSchema['x-collection-field']]);
19
27
  var currentMode = useMemo(function () {
20
- var _fieldSchema$xCompon;
21
- return ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.mode) || (isFileCollection ? 'FileManager' : 'Select');
22
- }, [(_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.mode]);
28
+ var _fieldSchema$xCompon3;
29
+ return ((_fieldSchema$xCompon3 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : _fieldSchema$xCompon3.mode) || (isFileCollection ? 'FileManager' : 'Select');
30
+ }, [(_fieldSchema$xCompon4 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.mode]);
31
+ var _useState = useState(true),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ loading = _useState2[0],
34
+ setLoading = _useState2[1];
35
+ useEffect(function () {
36
+ setLoading(true);
37
+ if (!collectionField) {
38
+ setLoading(false);
39
+ return;
40
+ }
41
+ if (field.value !== null && field.value !== undefined) {
42
+ // Nester 子表单时,如果没数据初始化一个 [null] 的占位
43
+ if (currentMode === 'Nester' && Array.isArray(field.value)) {
44
+ if (field.value.length === 0 && ['belongsToMany', 'hasMany'].includes(collectionField.type)) {
45
+ field.value = [null];
46
+ }
47
+ }
48
+ setLoading(false);
49
+ return;
50
+ }
51
+ if (currentMode === 'Nester') {
52
+ if (['belongsTo', 'hasOne'].includes(collectionField.type)) {
53
+ field.value = {};
54
+ } else if (['belongsToMany', 'hasMany'].includes(collectionField.type)) {
55
+ field.value = [null];
56
+ }
57
+ }
58
+ setLoading(false);
59
+ }, [currentMode, collectionField, field.value]);
60
+ if (loading) {
61
+ return null;
62
+ }
23
63
  return collectionField ? /*#__PURE__*/React.createElement(AssociationFieldContext.Provider, {
24
64
  value: {
25
65
  options: collectionField,
26
66
  field: field,
67
+ allowMultiple: allowMultiple,
68
+ allowDissociate: allowDissociate,
27
69
  currentMode: currentMode
28
70
  }
29
71
  }, props.children) : null;
@@ -7,14 +7,8 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
7
7
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
8
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
9
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
10
  import { observer, useField, useFieldSchema, useForm } from '@formily/react';
17
- import React, { useEffect, useState } from 'react';
11
+ import React from 'react';
18
12
  import { SchemaComponentOptions } from '../../';
19
13
  import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
20
14
  import { AssociationFieldProvider } from './AssociationFieldProvider';
@@ -33,32 +27,6 @@ var EditableAssociationField = observer(function (props) {
33
27
  var _useAssociationFieldC = useAssociationFieldContext(),
34
28
  collectionField = _useAssociationFieldC.options,
35
29
  currentMode = _useAssociationFieldC.currentMode;
36
- var _useState = useState(true),
37
- _useState2 = _slicedToArray(_useState, 2),
38
- loading = _useState2[0],
39
- setLoading = _useState2[1];
40
- useEffect(function () {
41
- setLoading(true);
42
- if (!collectionField) {
43
- setLoading(false);
44
- return;
45
- }
46
- if (field.value !== null && field.value !== undefined) {
47
- setLoading(false);
48
- return;
49
- }
50
- if (currentMode === 'Nester') {
51
- if (['belongsTo', 'hasOne'].includes(collectionField.type)) {
52
- field.value = {};
53
- } else if (['belongsToMany', 'hasMany'].includes(collectionField.type)) {
54
- field.value = [null];
55
- }
56
- }
57
- setLoading(false);
58
- }, [currentMode, collectionField, field.value]);
59
- if (loading) {
60
- return null;
61
- }
62
30
  var useCreateActionProps = function useCreateActionProps() {
63
31
  var _useCAP = useCAP(),
64
32
  _onClick = _useCAP.onClick;
@@ -30,7 +30,10 @@ var ToOneNester = function ToOneNester(props) {
30
30
  var ToManyNester = observer(function (props) {
31
31
  var fieldSchema = useFieldSchema();
32
32
  var _useAssociationFieldC = useAssociationFieldContext(),
33
- field = _useAssociationFieldC.field;
33
+ options = _useAssociationFieldC.options,
34
+ field = _useAssociationFieldC.field,
35
+ allowMultiple = _useAssociationFieldC.allowMultiple,
36
+ allowDissociate = _useAssociationFieldC.allowDissociate;
34
37
  var _useTranslation = useTranslation(),
35
38
  t = _useTranslation.t;
36
39
  return /*#__PURE__*/React.createElement(Card, {
@@ -39,7 +42,11 @@ var ToManyNester = observer(function (props) {
39
42
  position: 'relative'
40
43
  }
41
44
  }, (field.value || []).map(function (value, index) {
42
- return /*#__PURE__*/React.createElement(React.Fragment, null, !field.readPretty && /*#__PURE__*/React.createElement("div", {
45
+ var allowed = allowDissociate;
46
+ if (!allowDissociate) {
47
+ allowed = !(value === null || value === void 0 ? void 0 : value[options.targetKey]);
48
+ }
49
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !field.readPretty && allowed && /*#__PURE__*/React.createElement("div", {
43
50
  style: {
44
51
  textAlign: 'right'
45
52
  }
@@ -59,7 +66,7 @@ var ToManyNester = observer(function (props) {
59
66
  basePath: field.address.concat(index),
60
67
  schema: fieldSchema
61
68
  }), /*#__PURE__*/React.createElement(Divider, null));
62
- }), field.editable && /*#__PURE__*/React.createElement(Button, {
69
+ }), field.editable && allowMultiple && /*#__PURE__*/React.createElement(Button, {
63
70
  type: 'dashed',
64
71
  block: true,
65
72
  onClick: function onClick() {
@@ -4,5 +4,7 @@ export interface AssociationFieldContextProps {
4
4
  options?: any;
5
5
  field?: GeneralField;
6
6
  currentMode?: string;
7
+ allowMultiple?: boolean;
8
+ allowDissociate?: boolean;
7
9
  }
8
10
  export declare const AssociationFieldContext: import("react").Context<AssociationFieldContextProps>;
@@ -4,6 +4,8 @@ export declare function useAssociationFieldContext<F extends GeneralField>(): {
4
4
  options: any;
5
5
  field: F;
6
6
  currentMode: string;
7
+ allowMultiple?: boolean;
8
+ allowDissociate?: boolean;
7
9
  };
8
10
  export default function useServiceOptions(props: any): any;
9
11
  export declare const useFieldNames: (props: any) => any;
@@ -59,8 +59,8 @@ export var FilterAction = observer(function (props) {
59
59
  }, /*#__PURE__*/React.createElement(Popover, {
60
60
  destroyTooltipOnHide: true,
61
61
  placement: 'bottomLeft',
62
- visible: visible,
63
- onVisibleChange: function onVisibleChange(visible) {
62
+ open: visible,
63
+ onOpenChange: function onOpenChange(visible) {
64
64
  setVisible(visible);
65
65
  },
66
66
  trigger: 'click',
@@ -13,6 +13,7 @@ import { css, cx } from '@emotion/css';
13
13
  import { ArrayCollapse, ArrayItems, FormLayout, FormItem as Item } from '@formily/antd';
14
14
  import { observer, useField, useFieldSchema } from '@formily/react';
15
15
  import { uid } from '@formily/shared';
16
+ import { Select } from 'antd';
16
17
  import _ from 'lodash';
17
18
  import moment from 'moment';
18
19
  import React, { useContext, useEffect } from 'react';
@@ -35,7 +36,6 @@ import { FilterDynamicComponent } from '../table-v2/FilterDynamicComponent';
35
36
  import { isInvariable } from '../variable';
36
37
  import { FilterFormDesigner } from './FormItem.FilterFormDesigner';
37
38
  import { useEnsureOperatorsValid } from './SchemaSettingOptions';
38
- import { Select } from 'antd';
39
39
  var defaultInputStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n & > .nb-form-item {\n flex: 1;\n }\n"])));
40
40
  var divWrap = function divWrap(schema) {
41
41
  return {
@@ -80,7 +80,7 @@ export var FormItem = observer(function (props) {
80
80
  }))));
81
81
  });
82
82
  FormItem.Designer = function Designer() {
83
- var _interfaceConfig$vali, _collectionField$uiSc, _getCollectionFields, _field$componentProps, _field$componentProps2, _field$componentProps3, _field$componentProps4, _field$componentProps5, _field$componentProps6, _field$componentProps7, _fieldSchema$xCompon, _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _fieldSchema$xCompon5, _fieldSchema$xCompon6, _fieldSchema$xCompon7, _field$componentProps8, _field$componentProps9;
83
+ var _interfaceConfig$vali, _collectionField$uiSc, _getCollectionFields, _field$componentProps, _field$componentProps2, _field$componentProps3, _field$componentProps4, _field$componentProps5, _field$componentProps6, _field$componentProps7, _fieldSchema$xCompon, _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _fieldSchema$xCompon5, _fieldSchema$xCompon6, _fieldSchema$xCompon7, _fieldSchema$xCompon8, _fieldSchema$xCompon9, _fieldSchema$xCompon10, _field$componentProps8, _field$componentProps9;
84
84
  var _useCollectionManager = useCollectionManager(),
85
85
  getCollectionFields = _useCollectionManager.getCollectionFields,
86
86
  getInterface = _useCollectionManager.getInterface,
@@ -149,13 +149,14 @@ FormItem.Designer = function Designer() {
149
149
  };
150
150
  });
151
151
  var fieldSchemaWithoutRequired = _.omit(fieldSchema, 'required');
152
- var isPickerMode = fieldSchema['x-component-props'].mode === 'Picker';
152
+ var isSubFormMode = ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.mode) === 'Nester';
153
+ var isPickerMode = ((_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.mode) === 'Picker';
153
154
  var showFieldMode = isAssociationField && fieldModeOptions && !isTableField;
154
155
  var showModeSelect = showFieldMode && isPickerMode;
155
156
  return /*#__PURE__*/React.createElement(GeneralSchemaDesigner, null, /*#__PURE__*/React.createElement(GeneralSchemaItems, null), !(form === null || form === void 0 ? void 0 : form.readPretty) && isFileField ? /*#__PURE__*/React.createElement(SchemaSettings.SwitchItem, {
156
157
  key: "quick-upload",
157
158
  title: t('Quick upload'),
158
- checked: ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.quickUpload) !== false,
159
+ checked: ((_fieldSchema$xCompon3 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : _fieldSchema$xCompon3.quickUpload) !== false,
159
160
  onChange: function onChange(value) {
160
161
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
161
162
  field.componentProps.quickUpload = value;
@@ -170,7 +171,7 @@ FormItem.Designer = function Designer() {
170
171
  }) : null, !(form === null || form === void 0 ? void 0 : form.readPretty) && isFileField ? /*#__PURE__*/React.createElement(SchemaSettings.SwitchItem, {
171
172
  key: "select-file",
172
173
  title: t('Select file'),
173
- checked: ((_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.selectFile) !== false,
174
+ checked: ((_fieldSchema$xCompon4 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.selectFile) !== false,
174
175
  onChange: function onChange(value) {
175
176
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
176
177
  field.componentProps.selectFile = value;
@@ -544,7 +545,7 @@ FormItem.Designer = function Designer() {
544
545
  label: t('Large'),
545
546
  value: 'large'
546
547
  }],
547
- value: (_fieldSchema$xCompon3 = fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon4 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4['openSize']) !== null && _fieldSchema$xCompon3 !== void 0 ? _fieldSchema$xCompon3 : (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon5 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon5 === void 0 ? void 0 : _fieldSchema$xCompon5['openMode']) == 'modal' ? 'large' : 'middle',
548
+ value: (_fieldSchema$xCompon5 = fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon6 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon6 === void 0 ? void 0 : _fieldSchema$xCompon6['openSize']) !== null && _fieldSchema$xCompon5 !== void 0 ? _fieldSchema$xCompon5 : (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon7 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon7 === void 0 ? void 0 : _fieldSchema$xCompon7['openMode']) == 'modal' ? 'large' : 'middle',
548
549
  onChange: function onChange(value) {
549
550
  field.componentProps.openSize = value;
550
551
  fieldSchema['x-component-props'] = field.componentProps;
@@ -598,7 +599,7 @@ FormItem.Designer = function Designer() {
598
599
  }), IsShowMultipleSwitch() ? /*#__PURE__*/React.createElement(SchemaSettings.SwitchItem, {
599
600
  key: "multiple",
600
601
  title: t('Allow multiple'),
601
- checked: ((_fieldSchema$xCompon6 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon6 === void 0 ? void 0 : _fieldSchema$xCompon6.multiple) === undefined ? true : fieldSchema['x-component-props'].multiple,
602
+ checked: ((_fieldSchema$xCompon8 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon8 === void 0 ? void 0 : _fieldSchema$xCompon8.multiple) === undefined ? true : fieldSchema['x-component-props'].multiple,
602
603
  onChange: function onChange(value) {
603
604
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
604
605
  fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
@@ -611,9 +612,25 @@ FormItem.Designer = function Designer() {
611
612
  });
612
613
  refresh();
613
614
  }
615
+ }) : null, IsShowMultipleSwitch() && isSubFormMode ? /*#__PURE__*/React.createElement(SchemaSettings.SwitchItem, {
616
+ key: "allowDissociate",
617
+ title: t('Allow dissociate'),
618
+ checked: ((_fieldSchema$xCompon9 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon9 === void 0 ? void 0 : _fieldSchema$xCompon9.allowDissociate) !== false,
619
+ onChange: function onChange(value) {
620
+ var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
621
+ fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
622
+ field.componentProps = field.componentProps || {};
623
+ fieldSchema['x-component-props'].allowDissociate = value;
624
+ field.componentProps.allowDissociate = value;
625
+ schema['x-component-props'] = fieldSchema['x-component-props'];
626
+ dn.emit('patch', {
627
+ schema: schema
628
+ });
629
+ refresh();
630
+ }
614
631
  }) : null, field.readPretty && options.length > 0 && fieldSchema['x-component'] === 'CollectionField' && !isFileField && /*#__PURE__*/React.createElement(SchemaSettings.SwitchItem, {
615
632
  title: t('Enable link'),
616
- checked: ((_fieldSchema$xCompon7 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon7 === void 0 ? void 0 : _fieldSchema$xCompon7.enableLink) !== false,
633
+ checked: ((_fieldSchema$xCompon10 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon10 === void 0 ? void 0 : _fieldSchema$xCompon10.enableLink) !== false,
617
634
  onChange: function onChange(flag) {
618
635
  fieldSchema['x-component-props'] = _objectSpread(_objectSpread({}, fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component-props']), {}, {
619
636
  enableLink: flag
@@ -110,6 +110,8 @@ export var Templates = function Templates(_ref) {
110
110
  if (option.key !== 'none') {
111
111
  fetchTemplateData(api, option, t).then(function (data) {
112
112
  if (form && data) {
113
+ // 切换之前先把之前的数据清空
114
+ form.reset();
113
115
  forEach(data, function (value, key) {
114
116
  if (value) {
115
117
  form.values[key] = value;
@@ -37,8 +37,8 @@ function IconField(props) {
37
37
  compact: true
38
38
  }, /*#__PURE__*/React.createElement(Popover, {
39
39
  placement: 'bottom',
40
- visible: visible,
41
- onVisibleChange: function onVisibleChange(val) {
40
+ open: visible,
41
+ onOpenChange: function onOpenChange(val) {
42
42
  if (disabled) {
43
43
  return;
44
44
  }
@@ -53,8 +53,8 @@ export var EllipsisWithTooltip = /*#__PURE__*/forwardRef(function (props, ref) {
53
53
  return contentWidth > offsetWidth;
54
54
  };
55
55
  return /*#__PURE__*/React.createElement(Popover, {
56
- visible: ellipsis && visible,
57
- onVisibleChange: function onVisibleChange(visible) {
56
+ open: ellipsis && visible,
57
+ onOpenChange: function onOpenChange(visible) {
58
58
  setVisible(ellipsis && visible);
59
59
  },
60
60
  content: /*#__PURE__*/React.createElement("div", {
@@ -190,7 +190,7 @@ var InternalRemoteSelect = connect(function (props) {
190
190
  objectValue: objectValue,
191
191
  value: value
192
192
  }, others), {}, {
193
- loading: loading,
193
+ loading: data ? loading : true,
194
194
  options: mapOptionsToTags(options)
195
195
  }));
196
196
  }, mapProps({
@@ -1,5 +1,5 @@
1
- var _excluded = ["value", "options", "onChange", "fieldNames", "mode"],
2
- _excluded2 = ["objectValue", "value"];
1
+ var _excluded = ["value", "options", "onChange", "fieldNames", "mode", "loading"],
2
+ _excluded2 = ["objectValue", "loading", "value"];
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -11,7 +11,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
11
11
  import { LoadingOutlined } from '@ant-design/icons';
12
12
  import { connect, mapProps, mapReadPretty } from '@formily/react';
13
13
  import { isValid, toArr } from '@formily/shared';
14
- import { Select as AntdSelect } from 'antd';
14
+ import { Select as AntdSelect, Spin, Empty } from 'antd';
15
15
  import React from 'react';
16
16
  import { ReadPretty } from './ReadPretty';
17
17
  import { defaultFieldNames, getCurrentOptions } from './shared';
@@ -24,6 +24,7 @@ var ObjectSelect = function ObjectSelect(props) {
24
24
  _onChange = props.onChange,
25
25
  fieldNames = props.fieldNames,
26
26
  mode = props.mode,
27
+ loading = props.loading,
27
28
  others = _objectWithoutProperties(props, _excluded);
28
29
  var toValue = function toValue(v) {
29
30
  var _getCurrentOptions;
@@ -50,6 +51,9 @@ var ObjectSelect = function ObjectSelect(props) {
50
51
  value: toValue(value),
51
52
  allowClear: true,
52
53
  labelInValue: true,
54
+ notFoundContent: loading ? /*#__PURE__*/React.createElement(Spin, null) : /*#__PURE__*/React.createElement(Empty, {
55
+ image: Empty.PRESENTED_IMAGE_SIMPLE
56
+ }),
53
57
  options: options,
54
58
  fieldNames: fieldNames,
55
59
  showSearch: true,
@@ -81,6 +85,7 @@ var filterOption = function filterOption(input, option) {
81
85
  };
82
86
  var InternalSelect = connect(function (props) {
83
87
  var objectValue = props.objectValue,
88
+ loading = props.loading,
84
89
  value = props.value,
85
90
  others = _objectWithoutProperties(props, _excluded2);
86
91
  var mode = props.multiple ? 'multiple' : props.mode;
@@ -90,7 +95,8 @@ var InternalSelect = connect(function (props) {
90
95
  if (objectValue) {
91
96
  return /*#__PURE__*/React.createElement(ObjectSelect, _objectSpread(_objectSpread({}, others), {}, {
92
97
  value: value,
93
- mode: mode
98
+ mode: mode,
99
+ loading: loading
94
100
  }));
95
101
  }
96
102
  return /*#__PURE__*/React.createElement(AntdSelect, _objectSpread(_objectSpread({
@@ -98,6 +104,9 @@ var InternalSelect = connect(function (props) {
98
104
  filterOption: filterOption,
99
105
  allowClear: true,
100
106
  dropdownMatchSelectWidth: false,
107
+ notFoundContent: loading ? /*#__PURE__*/React.createElement(Spin, null) : /*#__PURE__*/React.createElement(Empty, {
108
+ image: Empty.PRESENTED_IMAGE_SIMPLE
109
+ }),
101
110
  value: value
102
111
  }, others), {}, {
103
112
  onChange: function onChange(changed) {
@@ -1,6 +1,6 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
2
  var _excluded = ["component", "style", "children", "openMode"],
3
- _excluded2 = ["schema", "id"];
3
+ _excluded2 = ["schema", "id", "removeParentsIfNoChildren"];
4
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -72,18 +72,17 @@ var useSortableItemId = function useSortableItemId(props) {
72
72
  return field.address.toString();
73
73
  };
74
74
  export var SortableItem = observer(function (props) {
75
- var _others$removeParents;
76
75
  var _useSortableItemProps = useSortableItemProps(props),
77
76
  schema = _useSortableItemProps.schema,
78
77
  id = _useSortableItemProps.id,
78
+ removeParentsIfNoChildren = _useSortableItemProps.removeParentsIfNoChildren,
79
79
  others = _objectWithoutProperties(_useSortableItemProps, _excluded2);
80
- var removeParentsIfNoChildren = (_others$removeParents = others.removeParentsIfNoChildren) !== null && _others$removeParents !== void 0 ? _others$removeParents : true;
81
80
  return /*#__PURE__*/React.createElement(SortableProvider, {
82
81
  id: id,
83
82
  data: {
84
83
  insertAdjacent: 'afterEnd',
85
84
  schema: schema,
86
- removeParentsIfNoChildren: removeParentsIfNoChildren
85
+ removeParentsIfNoChildren: removeParentsIfNoChildren !== null && removeParentsIfNoChildren !== void 0 ? removeParentsIfNoChildren : true
87
86
  }
88
87
  }, /*#__PURE__*/React.createElement(Sortable, _objectSpread({}, others), props.children));
89
88
  });
@@ -8,7 +8,7 @@ import { ArrayBase } from '@formily/antd';
8
8
  import { Switch } from 'antd';
9
9
  import React from 'react';
10
10
  import { useTranslation } from 'react-i18next';
11
- export var AsDefaultTemplate = /*#__PURE__*/React.forwardRef(function (props) {
11
+ export var AsDefaultTemplate = /*#__PURE__*/React.forwardRef(function (props, ref) {
12
12
  var _array$field;
13
13
  var array = ArrayBase.useArray();
14
14
  var index = ArrayBase.useIndex(props.index);
@@ -1,15 +1,15 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
11
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
7
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
13
  import { CopyOutlined } from '@ant-design/icons';
14
14
  import { ArrayBase } from '@formily/antd';
15
15
  import { RecursionField, observer, useField, useFieldSchema } from '@formily/react';
@@ -19,7 +19,7 @@ import cls from 'classnames';
19
19
  import { clone } from 'lodash';
20
20
  import React, { Fragment, useEffect, useState } from 'react';
21
21
  import { useTranslation } from 'react-i18next';
22
- var DataTemplateTitle = function DataTemplateTitle(props) {
22
+ var DataTemplateTitle = observer(function (props) {
23
23
  var _array$field;
24
24
  var array = ArrayBase.useArray();
25
25
  var index = ArrayBase.useIndex(props.index);
@@ -40,15 +40,11 @@ var DataTemplateTitle = function DataTemplateTitle(props) {
40
40
  placeholder: t('Template name'),
41
41
  onChange: function onChange(ev) {
42
42
  ev.stopPropagation();
43
- array.field.value.splice(index, 1, _objectSpread(_objectSpread({}, value), {}, {
44
- title: ev.target.value
45
- }));
43
+ value.title = ev.target.value;
46
44
  },
47
45
  onBlur: function onBlur(ev) {
48
46
  ev.stopPropagation();
49
- array.field.value.splice(index, 1, _objectSpread(_objectSpread({}, value), {}, {
50
- title: ev.target.value
51
- }));
47
+ value.title = ev.target.value;
52
48
  },
53
49
  autoSize: true,
54
50
  style: {
@@ -59,7 +55,7 @@ var DataTemplateTitle = function DataTemplateTitle(props) {
59
55
  e.stopPropagation();
60
56
  }
61
57
  });
62
- };
58
+ });
63
59
  var isAdditionComponent = function isAdditionComponent(schema) {
64
60
  var _schema$xComponent, _schema$xComponent$in;
65
61
  return ((_schema$xComponent = schema['x-component']) === null || _schema$xComponent === void 0 ? void 0 : (_schema$xComponent$in = _schema$xComponent.indexOf) === null || _schema$xComponent$in === void 0 ? void 0 : _schema$xComponent$in.call(_schema$xComponent, 'Addition')) > -1;