@nocobase/client 0.7.2-alpha.7 → 0.7.4-alpha.4

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 (175) hide show
  1. package/es/application/Application.d.ts +1 -0
  2. package/es/application/Application.js +7 -1
  3. package/es/block-provider/FormBlockProvider.js +15 -3
  4. package/es/block-provider/TableFieldProvider.d.ts +1 -0
  5. package/es/block-provider/TableFieldProvider.js +5 -2
  6. package/es/block-provider/TableSelectorProvider.js +42 -14
  7. package/es/block-provider/hooks/index.d.ts +6 -0
  8. package/es/block-provider/hooks/index.js +159 -65
  9. package/es/collection-manager/CollectionField.js +11 -4
  10. package/es/collection-manager/Configuration/AddFieldAction.js +6 -0
  11. package/es/collection-manager/Configuration/EditFieldAction.js +7 -0
  12. package/es/collection-manager/Configuration/index.js +5 -1
  13. package/es/collection-manager/Configuration/schemas/collections.js +2 -1
  14. package/es/collection-manager/interfaces/checkbox.js +1 -0
  15. package/es/collection-manager/interfaces/checkboxGroup.js +1 -0
  16. package/es/collection-manager/interfaces/datetime.js +1 -0
  17. package/es/collection-manager/interfaces/email.js +1 -0
  18. package/es/collection-manager/interfaces/icon.js +1 -0
  19. package/es/collection-manager/interfaces/input.js +104 -0
  20. package/es/collection-manager/interfaces/integer.js +64 -0
  21. package/es/collection-manager/interfaces/m2m.js +2 -0
  22. package/es/collection-manager/interfaces/m2o.js +1 -0
  23. package/es/collection-manager/interfaces/markdown.js +35 -0
  24. package/es/collection-manager/interfaces/multipleSelect.js +1 -0
  25. package/es/collection-manager/interfaces/number.js +56 -0
  26. package/es/collection-manager/interfaces/o2m.js +1 -0
  27. package/es/collection-manager/interfaces/o2o.js +3 -0
  28. package/es/collection-manager/interfaces/password.js +37 -1
  29. package/es/collection-manager/interfaces/percent.js +98 -0
  30. package/es/collection-manager/interfaces/phone.js +1 -0
  31. package/es/collection-manager/interfaces/properties/index.d.ts +1 -0
  32. package/es/collection-manager/interfaces/properties/index.js +1 -0
  33. package/es/collection-manager/interfaces/properties/operators.js +4 -4
  34. package/es/collection-manager/interfaces/radioGroup.js +1 -0
  35. package/es/collection-manager/interfaces/richText.js +35 -0
  36. package/es/collection-manager/interfaces/select.js +1 -0
  37. package/es/collection-manager/interfaces/textarea.js +35 -0
  38. package/es/collection-manager/interfaces/time.js +1 -0
  39. package/es/file-manager/FileStorageShortcut.js +2 -2
  40. package/es/locale/en_US.d.ts +8 -2
  41. package/es/locale/en_US.js +9 -3
  42. package/es/locale/zh_CN.d.ts +28 -2
  43. package/es/locale/zh_CN.js +29 -3
  44. package/es/plugin-manager/PluginManager.d.ts +1 -0
  45. package/es/plugin-manager/PluginManager.js +20 -6
  46. package/es/schema-component/antd/action/Action.Modal.js +1 -1
  47. package/es/schema-component/antd/calendar/Calendar.Designer.js +16 -10
  48. package/es/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
  49. package/es/schema-component/antd/date-picker/DatePicker.js +1 -1
  50. package/es/schema-component/antd/date-picker/ReadPretty.js +1 -1
  51. package/es/schema-component/antd/date-picker/util.d.ts +0 -10
  52. package/es/schema-component/antd/date-picker/util.js +1 -79
  53. package/es/schema-component/antd/form-item/FormItem.js +193 -10
  54. package/es/schema-component/antd/grid/Grid.js +72 -6
  55. package/es/schema-component/antd/input-number/InputNumber.d.ts +1 -5
  56. package/es/schema-component/antd/input-number/InputNumber.js +25 -1
  57. package/es/schema-component/antd/input-number/ReadPretty.js +2 -4
  58. package/es/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
  59. package/es/schema-component/antd/menu/Menu.js +6 -3
  60. package/es/schema-component/antd/percent/Percent.js +2 -2
  61. package/es/schema-component/antd/record-picker/InputRecordPicker.js +27 -13
  62. package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +5 -3
  63. package/es/schema-component/antd/table/Table.Array.js +2 -2
  64. package/es/schema-component/antd/table/Table.Void.js +11 -1
  65. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
  66. package/es/schema-component/antd/table-v2/Table.d.ts +0 -11
  67. package/es/schema-component/antd/table-v2/Table.js +163 -92
  68. package/es/schema-component/antd/table-v2/TableField.js +3 -0
  69. package/es/schema-component/antd/tabs/Tabs.Designer.js +23 -12
  70. package/es/schema-component/antd/tabs/Tabs.js +7 -1
  71. package/es/schema-component/antd/time-picker/ReadPretty.js +11 -5
  72. package/es/schema-component/core/DesignableSwitch.js +7 -1
  73. package/es/schema-component/hooks/useDesignable.js +21 -21
  74. package/es/schema-component/hooks/useProps.js +1 -1
  75. package/es/schema-initializer/buttons/FormItemInitializers.js +14 -3
  76. package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
  77. package/es/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -3
  78. package/es/schema-initializer/buttons/RecordBlockInitializers.js +32 -3
  79. package/es/schema-initializer/buttons/TabPaneInitializers.js +11 -3
  80. package/es/schema-initializer/buttons/TableActionInitializers.js +11 -0
  81. package/es/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
  82. package/es/schema-initializer/components/assigned-field/AssignedField.js +255 -69
  83. package/es/schema-initializer/items/index.d.ts +2 -0
  84. package/es/schema-initializer/items/index.js +48 -2
  85. package/es/schema-initializer/utils.js +22 -2
  86. package/es/schema-settings/SchemaSettings.js +7 -0
  87. package/es/system-settings/SystemSettingsShortcut.js +35 -12
  88. package/lib/application/Application.d.ts +1 -0
  89. package/lib/application/Application.js +11 -2
  90. package/lib/block-provider/FormBlockProvider.js +15 -2
  91. package/lib/block-provider/TableFieldProvider.d.ts +1 -0
  92. package/lib/block-provider/TableFieldProvider.js +4 -1
  93. package/lib/block-provider/TableSelectorProvider.js +42 -14
  94. package/lib/block-provider/hooks/index.d.ts +6 -0
  95. package/lib/block-provider/hooks/index.js +168 -67
  96. package/lib/collection-manager/CollectionField.js +12 -4
  97. package/lib/collection-manager/Configuration/AddFieldAction.js +6 -0
  98. package/lib/collection-manager/Configuration/EditFieldAction.js +7 -0
  99. package/lib/collection-manager/Configuration/index.js +5 -0
  100. package/lib/collection-manager/Configuration/schemas/collections.js +2 -1
  101. package/lib/collection-manager/interfaces/checkbox.js +1 -0
  102. package/lib/collection-manager/interfaces/checkboxGroup.js +1 -0
  103. package/lib/collection-manager/interfaces/datetime.js +1 -0
  104. package/lib/collection-manager/interfaces/email.js +1 -0
  105. package/lib/collection-manager/interfaces/icon.js +1 -0
  106. package/lib/collection-manager/interfaces/input.js +105 -0
  107. package/lib/collection-manager/interfaces/integer.js +66 -0
  108. package/lib/collection-manager/interfaces/m2m.js +2 -0
  109. package/lib/collection-manager/interfaces/m2o.js +1 -0
  110. package/lib/collection-manager/interfaces/markdown.js +36 -0
  111. package/lib/collection-manager/interfaces/multipleSelect.js +1 -0
  112. package/lib/collection-manager/interfaces/number.js +57 -0
  113. package/lib/collection-manager/interfaces/o2m.js +1 -0
  114. package/lib/collection-manager/interfaces/o2o.js +3 -0
  115. package/lib/collection-manager/interfaces/password.js +38 -1
  116. package/lib/collection-manager/interfaces/percent.js +100 -0
  117. package/lib/collection-manager/interfaces/phone.js +1 -0
  118. package/lib/collection-manager/interfaces/properties/index.d.ts +1 -0
  119. package/lib/collection-manager/interfaces/properties/index.js +1 -0
  120. package/lib/collection-manager/interfaces/properties/operators.js +4 -4
  121. package/lib/collection-manager/interfaces/radioGroup.js +1 -0
  122. package/lib/collection-manager/interfaces/richText.js +36 -0
  123. package/lib/collection-manager/interfaces/select.js +1 -0
  124. package/lib/collection-manager/interfaces/textarea.js +36 -0
  125. package/lib/collection-manager/interfaces/time.js +1 -0
  126. package/lib/file-manager/FileStorageShortcut.js +1 -1
  127. package/lib/locale/en_US.d.ts +8 -2
  128. package/lib/locale/en_US.js +9 -3
  129. package/lib/locale/zh_CN.d.ts +28 -2
  130. package/lib/locale/zh_CN.js +29 -3
  131. package/lib/plugin-manager/PluginManager.d.ts +1 -0
  132. package/lib/plugin-manager/PluginManager.js +23 -5
  133. package/lib/schema-component/antd/action/Action.Modal.js +1 -1
  134. package/lib/schema-component/antd/calendar/Calendar.Designer.js +16 -10
  135. package/lib/schema-component/antd/date-picker/DatePicker.d.ts +1 -1
  136. package/lib/schema-component/antd/date-picker/DatePicker.js +2 -2
  137. package/lib/schema-component/antd/date-picker/ReadPretty.js +6 -6
  138. package/lib/schema-component/antd/date-picker/util.d.ts +0 -10
  139. package/lib/schema-component/antd/date-picker/util.js +6 -89
  140. package/lib/schema-component/antd/form-item/FormItem.js +196 -12
  141. package/lib/schema-component/antd/grid/Grid.js +69 -3
  142. package/lib/schema-component/antd/input-number/InputNumber.d.ts +1 -5
  143. package/lib/schema-component/antd/input-number/InputNumber.js +28 -1
  144. package/lib/schema-component/antd/input-number/ReadPretty.js +2 -5
  145. package/lib/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
  146. package/lib/schema-component/antd/menu/Menu.js +6 -3
  147. package/lib/schema-component/antd/percent/Percent.js +2 -2
  148. package/lib/schema-component/antd/record-picker/InputRecordPicker.js +27 -12
  149. package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +4 -2
  150. package/lib/schema-component/antd/table/Table.Array.js +2 -2
  151. package/lib/schema-component/antd/table/Table.Void.js +11 -1
  152. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +3 -1
  153. package/lib/schema-component/antd/table-v2/Table.d.ts +0 -11
  154. package/lib/schema-component/antd/table-v2/Table.js +172 -94
  155. package/lib/schema-component/antd/table-v2/TableField.js +3 -0
  156. package/lib/schema-component/antd/tabs/Tabs.Designer.js +23 -12
  157. package/lib/schema-component/antd/tabs/Tabs.js +8 -1
  158. package/lib/schema-component/antd/time-picker/ReadPretty.js +10 -3
  159. package/lib/schema-component/core/DesignableSwitch.js +8 -1
  160. package/lib/schema-component/hooks/useDesignable.js +21 -21
  161. package/lib/schema-component/hooks/useProps.js +1 -1
  162. package/lib/schema-initializer/buttons/FormItemInitializers.js +14 -2
  163. package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
  164. package/lib/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -2
  165. package/lib/schema-initializer/buttons/RecordBlockInitializers.js +34 -4
  166. package/lib/schema-initializer/buttons/TabPaneInitializers.js +11 -3
  167. package/lib/schema-initializer/buttons/TableActionInitializers.js +11 -0
  168. package/lib/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
  169. package/lib/schema-initializer/components/assigned-field/AssignedField.js +257 -66
  170. package/lib/schema-initializer/items/index.d.ts +2 -0
  171. package/lib/schema-initializer/items/index.js +54 -2
  172. package/lib/schema-initializer/utils.js +22 -2
  173. package/lib/schema-settings/SchemaSettings.js +7 -0
  174. package/lib/system-settings/SystemSettingsShortcut.js +37 -13
  175. package/package.json +7 -4
@@ -3,7 +3,7 @@ var _excluded = ["onSelect", "mode", "selectedUid", "defaultSelectedUid", "sideM
3
3
  _excluded3 = ["icon"],
4
4
  _excluded4 = ["icon"];
5
5
 
6
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
6
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
7
7
 
8
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
9
 
@@ -274,6 +274,7 @@ Menu.Item = observer(function (props) {
274
274
  var field = useField();
275
275
  var Designer = useContext(MenuItemDesignerContext);
276
276
  return /*#__PURE__*/React.createElement(AntdMenu.Item, _objectSpread(_objectSpread({}, others), {}, {
277
+ className: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n :active {\n background: inherit;\n }\n "]))),
277
278
  key: schema.name,
278
279
  eventKey: schema.name,
279
280
  schema: schema
@@ -282,7 +283,7 @@ Menu.Item = observer(function (props) {
282
283
  }, /*#__PURE__*/React.createElement(Icon, {
283
284
  type: icon
284
285
  }), /*#__PURE__*/React.createElement("span", {
285
- className: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n width: 100%;\n vertical-align: middle;\n "])))
286
+ className: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n width: 100%;\n vertical-align: middle;\n "])))
286
287
  }, field.title), /*#__PURE__*/React.createElement(Designer, null)));
287
288
  });
288
289
  Menu.URL = observer(function (props) {
@@ -293,6 +294,7 @@ Menu.URL = observer(function (props) {
293
294
  var field = useField();
294
295
  var Designer = useContext(MenuItemDesignerContext);
295
296
  return /*#__PURE__*/React.createElement(AntdMenu.Item, _objectSpread(_objectSpread({}, others), {}, {
297
+ className: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n :active {\n background: inherit;\n }\n "]))),
296
298
  key: schema.name,
297
299
  eventKey: schema.name,
298
300
  schema: schema,
@@ -304,7 +306,7 @@ Menu.URL = observer(function (props) {
304
306
  }, /*#__PURE__*/React.createElement(Icon, {
305
307
  type: icon
306
308
  }), /*#__PURE__*/React.createElement("span", {
307
- className: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n width: 100%;\n vertical-align: middle;\n "])))
309
+ className: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n width: 100%;\n vertical-align: middle;\n "])))
308
310
  }, field.title), /*#__PURE__*/React.createElement(Designer, null)));
309
311
  });
310
312
  Menu.SubMenu = observer(function (props) {
@@ -321,6 +323,7 @@ Menu.SubMenu = observer(function (props) {
321
323
  }
322
324
 
323
325
  return /*#__PURE__*/React.createElement(AntdMenu.SubMenu, _objectSpread(_objectSpread({}, others), {}, {
326
+ className: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n :active {\n background: inherit;\n }\n "]))),
324
327
  key: schema.name,
325
328
  eventKey: schema.name,
326
329
  title: /*#__PURE__*/React.createElement(SortableItem, {
@@ -14,10 +14,10 @@ export var Percent = connect(function (props) {
14
14
  _onChange = props.onChange;
15
15
  return /*#__PURE__*/React.createElement(InputNumber, _objectSpread(_objectSpread({}, props), {}, {
16
16
  addonAfter: "%",
17
- value: math.round(value * 100, 9),
17
+ value: value ? math.round(value * 100, 9) : null,
18
18
  onChange: function onChange(v) {
19
19
  if (_onChange) {
20
- _onChange(math.round(v / 100, 9));
20
+ _onChange(v ? math.round(v / 100, 9) : null);
21
21
  }
22
22
  }
23
23
  }));
@@ -23,8 +23,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
23
23
 
24
24
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
25
25
 
26
- import { RecursionField, useFieldSchema } from '@formily/react';
26
+ import { RecursionField, useField, useFieldSchema } from '@formily/react';
27
27
  import { Select } from 'antd';
28
+ import { differenceBy, unionBy } from 'lodash';
28
29
  import React, { createContext, useContext, useEffect, useState } from 'react';
29
30
  import { useTableSelectorProps as useTsp } from '../../../block-provider/TableSelectorProvider';
30
31
  import { CollectionProvider, useCollection } from '../../../collection-manager';
@@ -35,31 +36,44 @@ import { useFieldNames } from './useFieldNames';
35
36
  var RecordPickerContext = /*#__PURE__*/createContext(null);
36
37
 
37
38
  var useTableSelectorProps = function useTableSelectorProps() {
39
+ var field = useField();
40
+
38
41
  var _useContext = useContext(RecordPickerContext),
39
42
  multiple = _useContext.multiple,
40
43
  value = _useContext.value,
41
44
  setSelectedRows = _useContext.setSelectedRows,
42
- selectedRows = _useContext.selectedRows;
45
+ rcSelectRows = _useContext.selectedRows;
43
46
 
44
47
  var _useTsp = useTsp(),
45
48
  _onRowSelectionChange = _useTsp.onRowSelectionChange,
46
49
  rowKey = _useTsp.rowKey,
47
- others = _objectWithoutProperties(_useTsp, _excluded);
50
+ others = _objectWithoutProperties(_useTsp, _excluded); // console.log('useTableSelectorProps', field.value, value);
51
+
48
52
 
49
53
  return _objectSpread(_objectSpread({}, others), {}, {
50
54
  rowKey: rowKey,
51
55
  rowSelection: {
52
56
  type: multiple ? 'checkbox' : 'radio',
53
- defaultSelectedRowKeys: selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (item) {
54
- return item[rowKey || 'id'];
55
- }),
56
- selectedRowKeys: selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (item) {
57
+ // defaultSelectedRowKeys: rcSelectRows?.map((item) => item[rowKey||'id']),
58
+ selectedRowKeys: rcSelectRows === null || rcSelectRows === void 0 ? void 0 : rcSelectRows.map(function (item) {
57
59
  return item[rowKey || 'id'];
58
60
  })
59
61
  },
60
62
  onRowSelectionChange: function onRowSelectionChange(selectedRowKeys, selectedRows) {
61
- _onRowSelectionChange === null || _onRowSelectionChange === void 0 ? void 0 : _onRowSelectionChange(selectedRowKeys, selectedRows);
62
- setSelectedRows === null || setSelectedRows === void 0 ? void 0 : setSelectedRows(selectedRows);
63
+ if (multiple) {
64
+ var scopeRows = field.value || [];
65
+ var allSelectedRows = rcSelectRows || [];
66
+ var otherRows = differenceBy(allSelectedRows, scopeRows, rowKey || 'id');
67
+ var unionSelectedRows = unionBy(otherRows, selectedRows, rowKey || 'id');
68
+ var unionSelectedRowKeys = unionSelectedRows.map(function (item) {
69
+ return item[rowKey || 'id'];
70
+ });
71
+ setSelectedRows === null || setSelectedRows === void 0 ? void 0 : setSelectedRows(unionSelectedRows);
72
+ _onRowSelectionChange === null || _onRowSelectionChange === void 0 ? void 0 : _onRowSelectionChange(unionSelectedRowKeys, unionSelectedRows);
73
+ } else {
74
+ setSelectedRows === null || setSelectedRows === void 0 ? void 0 : setSelectedRows(selectedRows);
75
+ _onRowSelectionChange === null || _onRowSelectionChange === void 0 ? void 0 : _onRowSelectionChange(selectedRowKeys, selectedRows);
76
+ }
63
77
  }
64
78
  });
65
79
  };
@@ -137,13 +151,13 @@ export var InputRecordPicker = function InputRecordPicker(props) {
137
151
  setSelectedRows(opts);
138
152
  }
139
153
  }, [value]);
140
- useEffect(function () {});
141
154
 
142
155
  var getValue = function getValue() {
143
- if (multiple == null) return null;
144
- return multiple ? Array.isArray(value) ? value === null || value === void 0 ? void 0 : value.map(function (v) {
156
+ if (multiple == null) return null; // console.log('getValue', multiple, value, Array.isArray(value));
157
+
158
+ return Array.isArray(value) ? value === null || value === void 0 ? void 0 : value.map(function (v) {
145
159
  return v[fieldNames.value];
146
- }) : [] : value === null || value === void 0 ? void 0 : value[fieldNames.value];
160
+ }) : value === null || value === void 0 ? void 0 : value[fieldNames.value];
147
161
  };
148
162
 
149
163
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Select, _objectSpread(_objectSpread({}, others), {}, {
@@ -12,7 +12,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
13
  import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
14
14
  import { toArr } from '@formily/shared';
15
- import React, { useRef, useState } from 'react';
15
+ import React, { Fragment, useRef, useState } from 'react';
16
16
  import { BlockAssociationContext, WithoutTableFieldResource } from '../../../block-provider';
17
17
  import { CollectionProvider, useCollection, useCollectionManager } from '../../../collection-manager';
18
18
  import { RecordProvider, useRecord } from '../../../record-provider';
@@ -57,7 +57,9 @@ export var ReadPrettyRecordPicker = observer(function (props) {
57
57
 
58
58
  var renderRecords = function renderRecords() {
59
59
  return toArr(field.value).map(function (record, index, arr) {
60
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("a", {
60
+ return /*#__PURE__*/React.createElement(Fragment, {
61
+ key: "".concat(record.id, "_").concat(index)
62
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("a", {
61
63
  onClick: function onClick(e) {
62
64
  var _ellipsisWithTooltipR;
63
65
 
@@ -67,7 +69,7 @@ export var ReadPrettyRecordPicker = observer(function (props) {
67
69
  setRecord(record);
68
70
  ellipsisWithTooltipRef === null || ellipsisWithTooltipRef === void 0 ? void 0 : (_ellipsisWithTooltipR = ellipsisWithTooltipRef.current) === null || _ellipsisWithTooltipR === void 0 ? void 0 : _ellipsisWithTooltipR.setPopoverVisible(false);
69
71
  }
70
- }, compile(record === null || record === void 0 ? void 0 : record[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label']))), index < arr.length - 1 ? /*#__PURE__*/React.createElement("span", {
72
+ }, compile(record === null || record === void 0 ? void 0 : record[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label']) || (record === null || record === void 0 ? void 0 : record[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || 'value']) || (record === null || record === void 0 ? void 0 : record.id))), index < arr.length - 1 ? /*#__PURE__*/React.createElement("span", {
71
73
  style: {
72
74
  marginRight: 4,
73
75
  color: '#aaa'
@@ -71,8 +71,8 @@ var useTableColumns = function useTableColumns() {
71
71
  render: function render(v, record) {
72
72
  var _field$value;
73
73
 
74
- var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record);
75
- console.log((Date.now() - start) / 1000);
74
+ var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record); // console.log((Date.now() - start) / 1000);
75
+
76
76
  return /*#__PURE__*/React.createElement(RecordIndexProvider, {
77
77
  index: index
78
78
  }, /*#__PURE__*/React.createElement(RecordProvider, {
@@ -13,7 +13,7 @@ import { useAttach } from '../../hooks';
13
13
  import { TableArray } from './Table.Array';
14
14
 
15
15
  var usePaginationProps = function usePaginationProps(props, service) {
16
- var _props$request, _props$request$params;
16
+ var _props$request, _props$request$params, _service$data;
17
17
 
18
18
  if (props.pagination === false) {
19
19
  return false;
@@ -27,6 +27,16 @@ var usePaginationProps = function usePaginationProps(props, service) {
27
27
  pagination.defaultPageSize = props === null || props === void 0 ? void 0 : (_props$request2 = props.request) === null || _props$request2 === void 0 ? void 0 : (_props$request2$param = _props$request2.params) === null || _props$request2$param === void 0 ? void 0 : _props$request2$param.pageSize;
28
28
  }
29
29
 
30
+ if (!pagination.total && (service === null || service === void 0 ? void 0 : (_service$data = service.data) === null || _service$data === void 0 ? void 0 : _service$data.meta)) {
31
+ var _service$data$meta = service.data.meta,
32
+ count = _service$data$meta.count,
33
+ page = _service$data$meta.page,
34
+ pageSize = _service$data$meta.pageSize;
35
+ pagination.total = count;
36
+ pagination.current = page;
37
+ pagination.pageSize = pageSize;
38
+ }
39
+
30
40
  return _objectSpread(_objectSpread({
31
41
  showSizeChanger: true
32
42
  }, pagination), {}, {
@@ -114,7 +114,9 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
114
114
  options: options,
115
115
  value: fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames['label'],
116
116
  onChange: function onChange(label) {
117
- var fieldNames = _objectSpread(_objectSpread({}, fieldSchema['x-component-props']['fieldNames']), {}, {
117
+ var _collectionField$uiSc2, _fieldSchema$xCompon2;
118
+
119
+ var fieldNames = _objectSpread(_objectSpread(_objectSpread({}, collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc2 = collectionField.uiSchema) === null || _collectionField$uiSc2 === void 0 ? void 0 : _collectionField$uiSc2['x-component-props']['fieldNames']), fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2['fieldNames']), {}, {
118
120
  label: label
119
121
  });
120
122
 
@@ -1,12 +1 @@
1
- export declare const components: {
2
- header: {
3
- wrapper: (props: any) => JSX.Element;
4
- cell: (props: any) => JSX.Element;
5
- };
6
- body: {
7
- wrapper: (props: any) => JSX.Element;
8
- row: (props: any) => JSX.Element;
9
- cell: (props: any) => JSX.Element;
10
- };
11
- };
12
1
  export declare const Table: any;
@@ -1,32 +1,30 @@
1
1
  var _excluded = ["pagination", "useProps", "onChange"],
2
2
  _excluded2 = ["pagination"],
3
- _excluded3 = ["dragSort", "showIndex", "onRowDragEnd", "onRowSelectionChange", "onChange", "rowSelection"];
3
+ _excluded3 = ["dragSort", "showIndex", "onRowSelectionChange", "onChange", "rowSelection", "rowKey", "required"];
4
4
 
5
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
6
-
7
- 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); } }
8
-
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); }); }; }
5
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
10
6
 
11
7
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
12
8
 
13
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
14
10
 
15
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
16
-
17
11
  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; }
18
12
 
19
13
  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; }
20
14
 
21
15
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
16
 
17
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
18
+
23
19
  import { MenuOutlined } from '@ant-design/icons';
20
+ import { SortableContext, useSortable } from '@dnd-kit/sortable';
24
21
  import { css } from '@emotion/css';
25
22
  import { observer, RecursionField, useField, useFieldSchema } from '@formily/react';
23
+ import { reaction } from '@formily/reactive';
24
+ import { useMemoizedFn } from 'ahooks';
26
25
  import { Table as AntdTable } from 'antd';
27
26
  import { default as classNames, default as cls } from 'classnames';
28
- import React from 'react';
29
- import ReactDragListView from 'react-drag-listview';
27
+ import React, { useCallback, useEffect, useMemo } from 'react';
30
28
  import { useTranslation } from 'react-i18next';
31
29
  import { DndContext } from '../..';
32
30
  import { RecordIndexProvider, RecordProvider, useSchemaInitializer } from '../../../';
@@ -48,8 +46,7 @@ var useTableColumns = function useTableColumns() {
48
46
 
49
47
  var _useSchemaInitializer = useSchemaInitializer(schema['x-initializer']),
50
48
  exists = _useSchemaInitializer.exists,
51
- render = _useSchemaInitializer.render; // console.log('useTableColumns', exists);
52
-
49
+ render = _useSchemaInitializer.render;
53
50
 
54
51
  var columns = schema.reduceProperties(function (buf, s) {
55
52
  if (isColumnComponent(s)) {
@@ -64,7 +61,6 @@ var useTableColumns = function useTableColumns() {
64
61
  }
65
62
  }, []);
66
63
  var dataIndex = (collectionFields === null || collectionFields === void 0 ? void 0 : collectionFields.length) > 0 ? collectionFields[0].name : s.name;
67
- console.log('useTableColumns', s.name, s, field.value);
68
64
  return {
69
65
  title: /*#__PURE__*/React.createElement(RecursionField, {
70
66
  name: s.name,
@@ -80,7 +76,6 @@ var useTableColumns = function useTableColumns() {
80
76
 
81
77
  var index = (_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.indexOf(record); // console.log((Date.now() - start) / 1000);
82
78
 
83
- console.log('useTableColumns.index', index, record);
84
79
  return /*#__PURE__*/React.createElement(RecordIndexProvider, {
85
80
  index: index
86
81
  }, /*#__PURE__*/React.createElement(RecordProvider, {
@@ -105,39 +100,41 @@ var useTableColumns = function useTableColumns() {
105
100
  });
106
101
  };
107
102
 
108
- export var components = {
109
- header: {
110
- wrapper: function wrapper(props) {
111
- return /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement("thead", _objectSpread({}, props)));
112
- },
113
- cell: function cell(props) {
114
- return /*#__PURE__*/React.createElement("th", _objectSpread(_objectSpread({}, props), {}, {
115
- className: cls(props.className, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n max-width: 300px;\n white-space: nowrap;\n &:hover .general-schema-designer {\n display: block;\n }\n "]))))
116
- }));
117
- }
118
- },
119
- body: {
120
- wrapper: function wrapper(props) {
121
- return /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement("tbody", _objectSpread({}, props)));
122
- },
123
- row: function row(props) {
124
- return /*#__PURE__*/React.createElement("tr", _objectSpread({}, props));
125
- },
126
- cell: function cell(props) {
127
- return /*#__PURE__*/React.createElement("td", _objectSpread(_objectSpread({}, props), {}, {
128
- className: classNames(props.className, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n max-width: 300px;\n white-space: nowrap;\n .nb-read-pretty-input-number {\n text-align: right;\n }\n "]))))
129
- }));
130
- }
131
- }
103
+ var topActiveClass = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n & > td {\n border-top: 2px solid rgba(241, 139, 98, 0.6) !important;\n }\n"])));
104
+ var bottomActiveClass = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n & > td {\n border-bottom: 2px solid rgba(241, 139, 98, 0.6) !important;\n }\n"])));
105
+
106
+ var SortableRow = function SortableRow(props) {
107
+ var _props$dataRowKey, _active$data$current$, _active$data$current, _over$data$current$so, _over$data$current;
108
+
109
+ var id = (_props$dataRowKey = props['data-row-key']) === null || _props$dataRowKey === void 0 ? void 0 : _props$dataRowKey.toString();
110
+
111
+ var _useSortable = useSortable({
112
+ id: id
113
+ }),
114
+ setNodeRef = _useSortable.setNodeRef,
115
+ isOver = _useSortable.isOver,
116
+ active = _useSortable.active,
117
+ over = _useSortable.over;
118
+
119
+ var className = ((_active$data$current$ = active === null || active === void 0 ? void 0 : (_active$data$current = active.data.current) === null || _active$data$current === void 0 ? void 0 : _active$data$current.sortable.index) !== null && _active$data$current$ !== void 0 ? _active$data$current$ : -1) > ((_over$data$current$so = over === null || over === void 0 ? void 0 : (_over$data$current = over.data.current) === null || _over$data$current === void 0 ? void 0 : _over$data$current.sortable.index) !== null && _over$data$current$so !== void 0 ? _over$data$current$so : -1) ? topActiveClass : bottomActiveClass;
120
+ return /*#__PURE__*/React.createElement("tr", _objectSpread(_objectSpread({
121
+ ref: (active === null || active === void 0 ? void 0 : active.id) !== id ? setNodeRef : null
122
+ }, props), {}, {
123
+ className: classNames(_defineProperty({}, className, active && isOver))
124
+ }));
132
125
  };
133
126
 
134
- var SortHandle = function SortHandle() {
135
- return /*#__PURE__*/React.createElement(MenuOutlined, {
136
- className: 'drag-handle',
127
+ var SortHandle = function SortHandle(props) {
128
+ var _useSortable2 = useSortable({
129
+ id: props.id
130
+ }),
131
+ listeners = _useSortable2.listeners;
132
+
133
+ return /*#__PURE__*/React.createElement(MenuOutlined, _objectSpread(_objectSpread({}, listeners), {}, {
137
134
  style: {
138
135
  cursor: 'grab'
139
136
  }
140
- });
137
+ }));
141
138
  };
142
139
 
143
140
  var TableIndex = function TableIndex(props) {
@@ -172,6 +169,25 @@ var usePaginationProps = function usePaginationProps(pagination1, pagination2) {
172
169
  }, pagination1), pagination2);
173
170
  };
174
171
 
172
+ var useValidator = function useValidator(validator) {
173
+ var field = useField();
174
+ useEffect(function () {
175
+ var dispose = reaction(function () {
176
+ return field.value;
177
+ }, function (value) {
178
+ var message = validator(value);
179
+ field.setFeedback({
180
+ type: 'error',
181
+ code: 'ValidateError',
182
+ messages: message ? [message] : []
183
+ });
184
+ });
185
+ return function () {
186
+ dispose();
187
+ };
188
+ }, []);
189
+ };
190
+
175
191
  export var Table = observer(function (props) {
176
192
  var _field$data, _field$value3, _field$value3$slice;
177
193
 
@@ -192,13 +208,92 @@ export var Table = observer(function (props) {
192
208
  dragSort = _others1$others$dragS === void 0 ? false : _others1$others$dragS,
193
209
  _others1$others$showI = _others1$others.showIndex,
194
210
  showIndex = _others1$others$showI === void 0 ? true : _others1$others$showI,
195
- onRowDragEnd = _others1$others.onRowDragEnd,
196
211
  onRowSelectionChange = _others1$others.onRowSelectionChange,
197
212
  onTableChange = _others1$others.onChange,
198
213
  rowSelection = _others1$others.rowSelection,
214
+ rowKey = _others1$others.rowKey,
215
+ required = _others1$others.required,
199
216
  others = _objectWithoutProperties(_others1$others, _excluded3);
200
217
 
218
+ var onRowDragEnd = useMemoizedFn(others.onRowDragEnd || function () {});
201
219
  var paginationProps = usePaginationProps(pagination1, pagination2);
220
+ var requiredValidator = field.required || required;
221
+ useEffect(function () {
222
+ field.setValidator(function (value) {
223
+ if (requiredValidator) {
224
+ return Array.isArray(value) && value.length > 0 ? null : 'The field value is required';
225
+ }
226
+
227
+ return;
228
+ });
229
+ }, [requiredValidator]);
230
+ var components = useMemo(function () {
231
+ return {
232
+ header: {
233
+ wrapper: function wrapper(props) {
234
+ return /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement("thead", _objectSpread({}, props)));
235
+ },
236
+ cell: function cell(props) {
237
+ return /*#__PURE__*/React.createElement("th", _objectSpread(_objectSpread({}, props), {}, {
238
+ className: cls(props.className, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n max-width: 300px;\n white-space: nowrap;\n &:hover .general-schema-designer {\n display: block;\n }\n "]))))
239
+ }));
240
+ }
241
+ },
242
+ body: {
243
+ wrapper: function wrapper(props) {
244
+ return /*#__PURE__*/React.createElement(DndContext, {
245
+ onDragEnd: function onDragEnd(e) {
246
+ var _e$active, _e$active$data$curren, _e$active$data$curren2, _e$over, _e$over$data$current, _e$over$data$current$;
247
+
248
+ if (!e.active || !e.over) {
249
+ console.warn('move cancel');
250
+ return;
251
+ }
252
+
253
+ var fromIndex = (_e$active = e.active) === null || _e$active === void 0 ? void 0 : (_e$active$data$curren = _e$active.data.current) === null || _e$active$data$curren === void 0 ? void 0 : (_e$active$data$curren2 = _e$active$data$curren.sortable) === null || _e$active$data$curren2 === void 0 ? void 0 : _e$active$data$curren2.index;
254
+ var toIndex = (_e$over = e.over) === null || _e$over === void 0 ? void 0 : (_e$over$data$current = _e$over.data.current) === null || _e$over$data$current === void 0 ? void 0 : (_e$over$data$current$ = _e$over$data$current.sortable) === null || _e$over$data$current$ === void 0 ? void 0 : _e$over$data$current$.index;
255
+ var from = field.value[fromIndex];
256
+ var to = field.value[toIndex];
257
+ field.move(fromIndex, toIndex);
258
+ onRowDragEnd({
259
+ fromIndex: fromIndex,
260
+ toIndex: toIndex,
261
+ from: from,
262
+ to: to
263
+ });
264
+ }
265
+ }, /*#__PURE__*/React.createElement("tbody", _objectSpread({}, props)));
266
+ },
267
+ row: function row(props) {
268
+ return /*#__PURE__*/React.createElement(SortableRow, _objectSpread({}, props));
269
+ },
270
+ cell: function cell(props) {
271
+ return /*#__PURE__*/React.createElement("td", _objectSpread(_objectSpread({}, props), {}, {
272
+ className: classNames(props.className, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n max-width: 300px;\n white-space: nowrap;\n .nb-read-pretty-input-number {\n text-align: right;\n }\n "]))))
273
+ }));
274
+ }
275
+ }
276
+ };
277
+ }, [field, onRowDragEnd, dragSort]);
278
+
279
+ var defaultRowKey = function defaultRowKey(record) {
280
+ var _field$value2, _field$value2$indexOf;
281
+
282
+ return (_field$value2 = field.value) === null || _field$value2 === void 0 ? void 0 : (_field$value2$indexOf = _field$value2.indexOf) === null || _field$value2$indexOf === void 0 ? void 0 : _field$value2$indexOf.call(_field$value2, record);
283
+ };
284
+
285
+ var getRowKey = function getRowKey(record) {
286
+ if (typeof rowKey === 'string') {
287
+ var _record$rowKey;
288
+
289
+ return (_record$rowKey = record[rowKey]) === null || _record$rowKey === void 0 ? void 0 : _record$rowKey.toString();
290
+ } else {
291
+ var _ref2;
292
+
293
+ return (_ref2 = (rowKey !== null && rowKey !== void 0 ? rowKey : defaultRowKey)(record)) === null || _ref2 === void 0 ? void 0 : _ref2.toString();
294
+ }
295
+ };
296
+
202
297
  var restProps = {
203
298
  rowSelection: rowSelection ? _objectSpread({
204
299
  type: 'checkbox',
@@ -223,62 +318,32 @@ export var Table = observer(function (props) {
223
318
  }
224
319
 
225
320
  return /*#__PURE__*/React.createElement("div", {
226
- className: classNames(checked ? 'checked' : null, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-evenly;\n padding-right: 8px;\n .nb-table-index {\n opacity: 0;\n }\n &:not(.checked) {\n .nb-table-index {\n opacity: 1;\n }\n }\n &:hover {\n .nb-table-index {\n opacity: 0;\n }\n .nb-origin-node {\n display: block;\n }\n }\n "]))))
321
+ className: classNames(checked ? 'checked' : null, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-evenly;\n padding-right: 8px;\n .nb-table-index {\n opacity: 0;\n }\n &:not(.checked) {\n .nb-table-index {\n opacity: 1;\n }\n }\n &:hover {\n .nb-table-index {\n opacity: 0;\n }\n .nb-origin-node {\n display: block;\n }\n }\n "]))))
227
322
  }, /*#__PURE__*/React.createElement("div", {
228
- className: classNames(checked ? 'checked' : null, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-evenly;\n "]))))
229
- }, dragSort && /*#__PURE__*/React.createElement(SortHandle, null), showIndex && /*#__PURE__*/React.createElement(TableIndex, {
323
+ className: classNames(checked ? 'checked' : null, css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n align-items: center;\n justify-content: space-evenly;\n "]))))
324
+ }, dragSort && /*#__PURE__*/React.createElement(SortHandle, {
325
+ id: getRowKey(record)
326
+ }), showIndex && /*#__PURE__*/React.createElement(TableIndex, {
230
327
  index: index
231
328
  })), /*#__PURE__*/React.createElement("div", {
232
- className: classNames('nb-origin-node', checked ? 'checked' : null, css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n right: 50%;\n transform: translateX(50%);\n &:not(.checked) {\n display: none;\n }\n "]))))
329
+ className: classNames('nb-origin-node', checked ? 'checked' : null, css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: absolute;\n right: 50%;\n transform: translateX(50%);\n &:not(.checked) {\n display: none;\n }\n "]))))
233
330
  }, originNode));
234
331
  }
235
332
  }, rowSelection) : undefined
236
333
  };
237
-
238
- var defaultRowKey = function defaultRowKey(record) {
239
- var _field$value2, _field$value2$indexOf;
240
-
241
- return (_field$value2 = field.value) === null || _field$value2 === void 0 ? void 0 : (_field$value2$indexOf = _field$value2.indexOf) === null || _field$value2$indexOf === void 0 ? void 0 : _field$value2$indexOf.call(_field$value2, record);
242
- };
243
-
334
+ var SortableWrapper = useCallback(function (_ref3) {
335
+ var children = _ref3.children;
336
+ return dragSort ? /*#__PURE__*/React.createElement(SortableContext, {
337
+ items: field.value.map(getRowKey),
338
+ children: children
339
+ }) : /*#__PURE__*/React.createElement(React.Fragment, {
340
+ children: children
341
+ });
342
+ }, [field, dragSort]);
244
343
  return /*#__PURE__*/React.createElement("div", {
245
- className: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n .ant-table {\n overflow-x: auto;\n overflow-y: hidden;\n }\n "])))
246
- }, /*#__PURE__*/React.createElement(ReactDragListView, {
247
- handleSelector: '.drag-handle',
248
- onDragEnd: function () {
249
- var _onDragEnd = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(fromIndex, toIndex) {
250
- var from, to;
251
- return regeneratorRuntime.wrap(function _callee$(_context) {
252
- while (1) {
253
- switch (_context.prev = _context.next) {
254
- case 0:
255
- from = field.value[fromIndex];
256
- to = field.value[toIndex];
257
- field.move(fromIndex, toIndex);
258
- onRowDragEnd({
259
- fromIndex: fromIndex,
260
- toIndex: toIndex,
261
- from: from,
262
- to: to
263
- });
264
-
265
- case 4:
266
- case "end":
267
- return _context.stop();
268
- }
269
- }
270
- }, _callee);
271
- }));
272
-
273
- function onDragEnd(_x, _x2) {
274
- return _onDragEnd.apply(this, arguments);
275
- }
276
-
277
- return onDragEnd;
278
- }(),
279
- lineClassName: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n border-bottom: 2px solid rgba(241, 139, 98, 0.6) !important;\n "])))
280
- }, /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread(_objectSpread({
281
- rowKey: defaultRowKey
344
+ className: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n .ant-table {\n overflow-x: auto;\n overflow-y: hidden;\n }\n "])))
345
+ }, /*#__PURE__*/React.createElement(SortableWrapper, null, /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread(_objectSpread({
346
+ rowKey: rowKey !== null && rowKey !== void 0 ? rowKey : defaultRowKey
282
347
  }, others), restProps), {}, {
283
348
  pagination: paginationProps,
284
349
  components: components,
@@ -289,5 +354,11 @@ export var Table = observer(function (props) {
289
354
  // scroll={{ x: 12 * 300 + 80 }}
290
355
  columns: columns,
291
356
  dataSource: field === null || field === void 0 ? void 0 : (_field$value3 = field.value) === null || _field$value3 === void 0 ? void 0 : (_field$value3$slice = _field$value3.slice) === null || _field$value3$slice === void 0 ? void 0 : _field$value3$slice.call(_field$value3)
292
- }))));
357
+ }))), field.errors.length > 0 && /*#__PURE__*/React.createElement("div", {
358
+ className: "ant-formily-item-error-help ant-formily-item-help ant-formily-item-help-enter ant-formily-item-help-enter-active"
359
+ }, field.errors.map(function (error) {
360
+ return error.messages.map(function (message) {
361
+ return /*#__PURE__*/React.createElement("div", null, message);
362
+ });
363
+ })));
293
364
  });
@@ -32,6 +32,9 @@ export var TableField = observer(function (props) {
32
32
  ctx.field.added.add(fieldSchema.name);
33
33
  }
34
34
  }, []);
35
+ useEffect(function () {
36
+ field.decoratorProps.asterisk = fieldSchema.required;
37
+ }, [fieldSchema.required]);
35
38
  return /*#__PURE__*/React.createElement("div", null, props.children);
36
39
  });
37
40
  TableField.ActionBar = observer(function (props) {