@nocobase/client 0.9.2-alpha.3 → 0.9.3-alpha.1

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 (237) hide show
  1. package/es/acl/Configuration/schemas/useRoleResourceValues.d.ts +1 -14
  2. package/es/api-client/hooks/useRequest.d.ts +1 -14
  3. package/es/api-client/hooks/useRequest.js +48 -53
  4. package/es/block-provider/DetailsBlockProvider.js +13 -1
  5. package/es/block-provider/FormBlockProvider.js +30 -13
  6. package/es/block-provider/hooks/index.d.ts +11 -1
  7. package/es/block-provider/hooks/index.js +527 -301
  8. package/es/collection-manager/Configuration/CollectionFields.js +1 -2
  9. package/es/collection-manager/Configuration/EditCollectionAction.d.ts +1 -14
  10. package/es/collection-manager/action-hooks.d.ts +4 -43
  11. package/es/collection-manager/action-hooks.js +18 -7
  12. package/es/collection-manager/interfaces/createdBy.js +1 -1
  13. package/es/collection-manager/interfaces/linkTo.js +5 -40
  14. package/es/collection-manager/interfaces/m2m.js +6 -39
  15. package/es/collection-manager/interfaces/m2o.js +6 -39
  16. package/es/collection-manager/interfaces/o2m.js +6 -69
  17. package/es/collection-manager/interfaces/o2o.js +31 -122
  18. package/es/collection-manager/interfaces/types.d.ts +2 -0
  19. package/es/collection-manager/interfaces/updatedBy.js +1 -1
  20. package/es/collection-manager/sub-table.d.ts +1 -14
  21. package/es/collection-manager/templates/tree.js +2 -2
  22. package/es/filter-provider/FilterProvider.js +3 -1
  23. package/es/locale/en_US.d.ts +4 -1
  24. package/es/locale/en_US.js +6 -3
  25. package/es/locale/ja_JP.d.ts +4 -1
  26. package/es/locale/ja_JP.js +4 -1
  27. package/es/locale/pt_BR.d.ts +1 -1
  28. package/es/locale/pt_BR.js +1 -1
  29. package/es/locale/zh_CN.d.ts +5 -1
  30. package/es/locale/zh_CN.js +5 -1
  31. package/es/schema-component/antd/action/Action.Designer.js +4 -5
  32. package/es/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -0
  33. package/es/schema-component/antd/association-field/AssociationFieldProvider.js +19 -0
  34. package/es/schema-component/antd/association-field/AssociationSelect.d.ts +14 -0
  35. package/es/schema-component/antd/association-field/AssociationSelect.js +118 -0
  36. package/es/schema-component/antd/association-field/Editable.d.ts +2 -0
  37. package/es/schema-component/antd/association-field/Editable.js +88 -0
  38. package/es/schema-component/antd/association-field/FileManager.d.ts +4 -0
  39. package/es/schema-component/antd/association-field/FileManager.js +243 -0
  40. package/es/schema-component/antd/association-field/InternalNester.d.ts +1 -0
  41. package/es/schema-component/antd/association-field/InternalNester.js +28 -0
  42. package/es/schema-component/antd/association-field/InternalPicker.d.ts +2 -0
  43. package/es/schema-component/antd/association-field/InternalPicker.js +267 -0
  44. package/es/schema-component/antd/association-field/InternalSubTable.d.ts +1 -0
  45. package/es/schema-component/antd/association-field/InternalSubTable.js +28 -0
  46. package/es/schema-component/antd/association-field/InternalViewer.d.ts +2 -0
  47. package/es/schema-component/antd/association-field/InternalViewer.js +115 -0
  48. package/es/schema-component/antd/association-field/Nester.d.ts +1 -0
  49. package/es/schema-component/antd/association-field/Nester.js +80 -0
  50. package/es/schema-component/antd/association-field/ReadPretty.d.ts +2 -0
  51. package/es/schema-component/antd/association-field/ReadPretty.js +38 -0
  52. package/es/schema-component/antd/association-field/SubTable.d.ts +1 -0
  53. package/es/schema-component/antd/association-field/SubTable.js +25 -0
  54. package/es/schema-component/antd/association-field/context.d.ts +7 -0
  55. package/es/schema-component/antd/association-field/context.js +2 -0
  56. package/es/schema-component/antd/association-field/hooks.d.ts +8 -0
  57. package/es/schema-component/antd/association-field/hooks.js +96 -0
  58. package/es/schema-component/antd/association-field/index.d.ts +1 -0
  59. package/es/schema-component/antd/association-field/index.js +14 -0
  60. package/es/schema-component/antd/association-field/schema.d.ts +142 -0
  61. package/es/schema-component/antd/association-field/schema.js +141 -0
  62. package/es/schema-component/antd/association-field/util.d.ts +8 -0
  63. package/es/schema-component/antd/association-field/util.js +84 -0
  64. package/es/schema-component/antd/association-filter/AssociationFilter.FilterBlockInitializer.js +2 -2
  65. package/es/schema-component/antd/association-select/AssociationSelect.js +11 -2
  66. package/es/schema-component/antd/expand-action/Expand.Action.Design.d.ts +1 -0
  67. package/es/schema-component/antd/expand-action/Expand.Action.Design.js +112 -0
  68. package/es/schema-component/antd/expand-action/Expand.Action.d.ts +1 -0
  69. package/es/schema-component/antd/expand-action/Expand.Action.js +40 -0
  70. package/es/schema-component/antd/expand-action/index.d.ts +1 -0
  71. package/es/schema-component/antd/expand-action/index.js +5 -0
  72. package/es/schema-component/antd/filter/Filter.Action.Designer.js +10 -12
  73. package/es/schema-component/antd/filter/FilterItem.js +1 -1
  74. package/es/schema-component/antd/filter/useOperators.d.ts +1 -1
  75. package/es/schema-component/antd/form-item/FormItem.d.ts +2 -1
  76. package/es/schema-component/antd/form-item/FormItem.js +206 -58
  77. package/es/schema-component/antd/form-item/SchemaSettingOptions.js +36 -58
  78. package/es/schema-component/antd/form-v2/utils.js +6 -4
  79. package/es/schema-component/antd/gantt/components/gantt/gantt.js +3 -3
  80. package/es/schema-component/antd/gantt/components/other/tooltip.js +1 -1
  81. package/es/schema-component/antd/index.d.ts +3 -1
  82. package/es/schema-component/antd/index.js +3 -1
  83. package/es/schema-component/antd/menu/Menu.js +6 -3
  84. package/es/schema-component/antd/record-picker/InputRecordPicker.d.ts +1 -0
  85. package/es/schema-component/antd/record-picker/InputRecordPicker.js +40 -17
  86. package/es/schema-component/antd/remote-select/RemoteSelect.js +16 -18
  87. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +18 -9
  88. package/es/schema-component/antd/table-v2/Table.Index.d.ts +1 -0
  89. package/es/schema-component/antd/table-v2/Table.Index.js +6 -0
  90. package/es/schema-component/antd/table-v2/Table.js +9 -5
  91. package/es/schema-component/antd/table-v2/index.js +3 -1
  92. package/es/schema-component/antd/table-v2/utils.js +1 -1
  93. package/es/schema-component/antd/variable/Input.js +15 -16
  94. package/es/schema-component/antd/variable/TextArea.js +2 -5
  95. package/es/schema-component/antd/variable/Variable.d.ts +2 -0
  96. package/es/schema-component/antd/variable/Variable.js +5 -2
  97. package/es/schema-component/common/dnd-context/index.js +3 -2
  98. package/es/schema-component/common/sortable-item/SortableItem.js +4 -1
  99. package/es/schema-component/common/utils/uitls.js +1 -1
  100. package/es/schema-component/hooks/index.d.ts +1 -0
  101. package/es/schema-component/hooks/index.js +2 -1
  102. package/es/schema-component/hooks/useFieldModeOptions.d.ts +4 -0
  103. package/es/schema-component/hooks/useFieldModeOptions.js +105 -0
  104. package/es/schema-initializer/components/CreateRecordAction.d.ts +1 -1
  105. package/es/schema-initializer/components/CreateRecordAction.js +4 -3
  106. package/es/schema-initializer/items/ExpandActionInitializer.d.ts +0 -1
  107. package/es/schema-initializer/items/ExpandActionInitializer.js +9 -34
  108. package/es/schema-initializer/items/SelectActionInitializer.d.ts +1 -0
  109. package/es/schema-initializer/items/SelectActionInitializer.js +65 -0
  110. package/es/schema-initializer/items/index.d.ts +1 -0
  111. package/es/schema-initializer/items/index.js +2 -1
  112. package/es/schema-initializer/utils.js +57 -43
  113. package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +1 -1
  114. package/es/schema-settings/LinkageRules/Variables.d.ts +1 -1
  115. package/es/schema-settings/LinkageRules/Variables.js +7 -4
  116. package/es/schema-settings/SchemaSettings.js +3 -3
  117. package/es/schema-settings/VariableInput/VariableInput.d.ts +3 -2
  118. package/es/schema-settings/VariableInput/VariableInput.js +3 -1
  119. package/lib/acl/Configuration/schemas/useRoleResourceValues.d.ts +1 -14
  120. package/lib/api-client/hooks/useRequest.d.ts +1 -14
  121. package/lib/api-client/hooks/useRequest.js +48 -53
  122. package/lib/block-provider/DetailsBlockProvider.js +13 -1
  123. package/lib/block-provider/FormBlockProvider.js +31 -15
  124. package/lib/block-provider/hooks/index.d.ts +11 -1
  125. package/lib/block-provider/hooks/index.js +537 -308
  126. package/lib/collection-manager/Configuration/CollectionFields.js +1 -2
  127. package/lib/collection-manager/Configuration/EditCollectionAction.d.ts +1 -14
  128. package/lib/collection-manager/action-hooks.d.ts +4 -43
  129. package/lib/collection-manager/action-hooks.js +18 -7
  130. package/lib/collection-manager/interfaces/createdBy.js +1 -1
  131. package/lib/collection-manager/interfaces/linkTo.js +4 -39
  132. package/lib/collection-manager/interfaces/m2m.js +5 -38
  133. package/lib/collection-manager/interfaces/m2o.js +5 -38
  134. package/lib/collection-manager/interfaces/o2m.js +8 -71
  135. package/lib/collection-manager/interfaces/o2o.js +36 -127
  136. package/lib/collection-manager/interfaces/types.d.ts +2 -0
  137. package/lib/collection-manager/interfaces/updatedBy.js +1 -1
  138. package/lib/collection-manager/sub-table.d.ts +1 -14
  139. package/lib/collection-manager/templates/tree.js +2 -2
  140. package/lib/filter-provider/FilterProvider.js +3 -1
  141. package/lib/locale/en_US.d.ts +4 -1
  142. package/lib/locale/en_US.js +6 -3
  143. package/lib/locale/ja_JP.d.ts +4 -1
  144. package/lib/locale/ja_JP.js +4 -1
  145. package/lib/locale/pt_BR.d.ts +1 -1
  146. package/lib/locale/pt_BR.js +1 -1
  147. package/lib/locale/zh_CN.d.ts +5 -1
  148. package/lib/locale/zh_CN.js +5 -1
  149. package/lib/schema-component/antd/action/Action.Designer.js +4 -5
  150. package/lib/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -0
  151. package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +28 -0
  152. package/lib/schema-component/antd/association-field/AssociationSelect.d.ts +14 -0
  153. package/lib/schema-component/antd/association-field/AssociationSelect.js +129 -0
  154. package/lib/schema-component/antd/association-field/Editable.d.ts +2 -0
  155. package/lib/schema-component/antd/association-field/Editable.js +97 -0
  156. package/lib/schema-component/antd/association-field/FileManager.d.ts +4 -0
  157. package/lib/schema-component/antd/association-field/FileManager.js +253 -0
  158. package/lib/schema-component/antd/association-field/InternalNester.d.ts +1 -0
  159. package/lib/schema-component/antd/association-field/InternalNester.js +39 -0
  160. package/lib/schema-component/antd/association-field/InternalPicker.d.ts +2 -0
  161. package/lib/schema-component/antd/association-field/InternalPicker.js +277 -0
  162. package/lib/schema-component/antd/association-field/InternalSubTable.d.ts +1 -0
  163. package/lib/schema-component/antd/association-field/InternalSubTable.js +39 -0
  164. package/lib/schema-component/antd/association-field/InternalViewer.d.ts +2 -0
  165. package/lib/schema-component/antd/association-field/InternalViewer.js +126 -0
  166. package/lib/schema-component/antd/association-field/Nester.d.ts +1 -0
  167. package/lib/schema-component/antd/association-field/Nester.js +89 -0
  168. package/lib/schema-component/antd/association-field/ReadPretty.d.ts +2 -0
  169. package/lib/schema-component/antd/association-field/ReadPretty.js +47 -0
  170. package/lib/schema-component/antd/association-field/SubTable.d.ts +1 -0
  171. package/lib/schema-component/antd/association-field/SubTable.js +33 -0
  172. package/lib/schema-component/antd/association-field/context.d.ts +7 -0
  173. package/lib/schema-component/antd/association-field/context.js +9 -0
  174. package/lib/schema-component/antd/association-field/hooks.d.ts +8 -0
  175. package/lib/schema-component/antd/association-field/hooks.js +107 -0
  176. package/lib/schema-component/antd/association-field/index.d.ts +1 -0
  177. package/lib/schema-component/antd/association-field/index.js +21 -0
  178. package/lib/schema-component/antd/association-field/schema.d.ts +142 -0
  179. package/lib/schema-component/antd/association-field/schema.js +148 -0
  180. package/lib/schema-component/antd/association-field/util.d.ts +8 -0
  181. package/lib/schema-component/antd/association-field/util.js +98 -0
  182. package/lib/schema-component/antd/association-filter/AssociationFilter.FilterBlockInitializer.js +2 -2
  183. package/lib/schema-component/antd/association-select/AssociationSelect.js +10 -1
  184. package/lib/schema-component/antd/expand-action/Expand.Action.Design.d.ts +1 -0
  185. package/lib/schema-component/antd/expand-action/Expand.Action.Design.js +120 -0
  186. package/lib/schema-component/antd/expand-action/Expand.Action.d.ts +1 -0
  187. package/lib/schema-component/antd/expand-action/Expand.Action.js +48 -0
  188. package/lib/schema-component/antd/expand-action/index.d.ts +1 -0
  189. package/lib/schema-component/antd/expand-action/index.js +12 -0
  190. package/lib/schema-component/antd/filter/Filter.Action.Designer.js +10 -12
  191. package/lib/schema-component/antd/filter/FilterItem.js +1 -1
  192. package/lib/schema-component/antd/filter/useOperators.d.ts +1 -1
  193. package/lib/schema-component/antd/form-item/FormItem.d.ts +2 -1
  194. package/lib/schema-component/antd/form-item/FormItem.js +204 -55
  195. package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +34 -56
  196. package/lib/schema-component/antd/form-v2/utils.js +6 -5
  197. package/lib/schema-component/antd/gantt/components/gantt/gantt.js +3 -3
  198. package/lib/schema-component/antd/gantt/components/other/tooltip.js +1 -1
  199. package/lib/schema-component/antd/index.d.ts +3 -1
  200. package/lib/schema-component/antd/index.js +33 -11
  201. package/lib/schema-component/antd/menu/Menu.js +6 -3
  202. package/lib/schema-component/antd/record-picker/InputRecordPicker.d.ts +1 -0
  203. package/lib/schema-component/antd/record-picker/InputRecordPicker.js +42 -18
  204. package/lib/schema-component/antd/remote-select/RemoteSelect.js +15 -17
  205. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +18 -9
  206. package/lib/schema-component/antd/table-v2/Table.Index.d.ts +1 -0
  207. package/lib/schema-component/antd/table-v2/Table.Index.js +14 -0
  208. package/lib/schema-component/antd/table-v2/Table.js +9 -5
  209. package/lib/schema-component/antd/table-v2/index.js +3 -1
  210. package/lib/schema-component/antd/table-v2/utils.js +1 -1
  211. package/lib/schema-component/antd/variable/Input.js +15 -16
  212. package/lib/schema-component/antd/variable/TextArea.js +2 -5
  213. package/lib/schema-component/antd/variable/Variable.d.ts +2 -0
  214. package/lib/schema-component/antd/variable/Variable.js +6 -2
  215. package/lib/schema-component/common/dnd-context/index.js +3 -2
  216. package/lib/schema-component/common/sortable-item/SortableItem.js +4 -1
  217. package/lib/schema-component/common/utils/uitls.js +1 -1
  218. package/lib/schema-component/hooks/index.d.ts +1 -0
  219. package/lib/schema-component/hooks/index.js +11 -0
  220. package/lib/schema-component/hooks/useFieldModeOptions.d.ts +4 -0
  221. package/lib/schema-component/hooks/useFieldModeOptions.js +112 -0
  222. package/lib/schema-initializer/components/CreateRecordAction.d.ts +1 -1
  223. package/lib/schema-initializer/components/CreateRecordAction.js +4 -3
  224. package/lib/schema-initializer/items/ExpandActionInitializer.d.ts +0 -1
  225. package/lib/schema-initializer/items/ExpandActionInitializer.js +11 -37
  226. package/lib/schema-initializer/items/SelectActionInitializer.d.ts +1 -0
  227. package/lib/schema-initializer/items/SelectActionInitializer.js +73 -0
  228. package/lib/schema-initializer/items/index.d.ts +1 -0
  229. package/lib/schema-initializer/items/index.js +11 -0
  230. package/lib/schema-initializer/utils.js +56 -42
  231. package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +1 -1
  232. package/lib/schema-settings/LinkageRules/Variables.d.ts +1 -1
  233. package/lib/schema-settings/LinkageRules/Variables.js +7 -4
  234. package/lib/schema-settings/SchemaSettings.js +4 -4
  235. package/lib/schema-settings/VariableInput/VariableInput.d.ts +3 -2
  236. package/lib/schema-settings/VariableInput/VariableInput.js +3 -1
  237. package/package.json +5 -6
@@ -0,0 +1,267 @@
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
+ var _excluded = ["onRowSelectionChange", "rowKey"],
3
+ _excluded2 = ["value", "multiple", "onChange", "quickUpload", "selectFile"];
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ 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."); }
6
+ 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); }
7
+ 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; }
8
+ 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; } }
9
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+ 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; }
11
+ 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; }
12
+ 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; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ 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); }
15
+ 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; }
16
+ 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; }
17
+ import { RecursionField, observer, useField, useFieldSchema } from '@formily/react';
18
+ import { Button, Input, Select } from 'antd';
19
+ import { differenceBy, unionBy } from 'lodash';
20
+ import React, { useContext, useEffect, useState } from 'react';
21
+ import { useTranslation } from 'react-i18next';
22
+ import { FormProvider, RecordPickerContext, RecordPickerProvider, SchemaComponentOptions, useActionContext } from '../..';
23
+ import { TableSelectorParamsProvider, useTableSelectorProps as useTsp } from '../../../block-provider/TableSelectorProvider';
24
+ import { CollectionProvider, useCollection } from '../../../collection-manager';
25
+ import { useCompile } from '../../hooks';
26
+ import { ActionContext } from '../action';
27
+ import { useFieldNames, useInsertSchema } from './hooks';
28
+ import schema from './schema';
29
+ import { flatData, getLabelFormatValue, useLabelUiSchema } from './util';
30
+ var useTableSelectorProps = function useTableSelectorProps() {
31
+ var field = useField();
32
+ var _useContext = useContext(RecordPickerContext),
33
+ multiple = _useContext.multiple,
34
+ _useContext$options = _useContext.options,
35
+ options = _useContext$options === void 0 ? [] : _useContext$options,
36
+ setSelectedRows = _useContext.setSelectedRows,
37
+ _useContext$selectedR = _useContext.selectedRows,
38
+ rcSelectRows = _useContext$selectedR === void 0 ? [] : _useContext$selectedR,
39
+ onChange = _useContext.onChange;
40
+ var _useTsp = useTsp(),
41
+ _onRowSelectionChange = _useTsp.onRowSelectionChange,
42
+ _useTsp$rowKey = _useTsp.rowKey,
43
+ rowKey = _useTsp$rowKey === void 0 ? 'id' : _useTsp$rowKey,
44
+ others = _objectWithoutProperties(_useTsp, _excluded);
45
+ var _useActionContext = useActionContext(),
46
+ setVisible = _useActionContext.setVisible;
47
+ return _objectSpread(_objectSpread({}, others), {}, {
48
+ rowKey: rowKey,
49
+ rowSelection: {
50
+ type: multiple ? 'checkbox' : 'radio',
51
+ selectedRowKeys: rcSelectRows === null || rcSelectRows === void 0 ? void 0 : rcSelectRows.filter(function (item) {
52
+ return options.every(function (row) {
53
+ return row[rowKey] !== item[rowKey];
54
+ });
55
+ }).map(function (item) {
56
+ return item[rowKey];
57
+ })
58
+ },
59
+ onRowSelectionChange: function onRowSelectionChange(selectedRowKeys, selectedRows) {
60
+ if (multiple) {
61
+ var scopeRows = flatData(field.value) || [];
62
+ var allSelectedRows = rcSelectRows || [];
63
+ var otherRows = differenceBy(allSelectedRows, scopeRows, rowKey);
64
+ var unionSelectedRows = unionBy(otherRows, selectedRows, rowKey);
65
+ var unionSelectedRowKeys = unionSelectedRows.map(function (item) {
66
+ return item[rowKey];
67
+ });
68
+ setSelectedRows === null || setSelectedRows === void 0 ? void 0 : setSelectedRows(unionSelectedRows);
69
+ _onRowSelectionChange === null || _onRowSelectionChange === void 0 ? void 0 : _onRowSelectionChange(unionSelectedRowKeys, unionSelectedRows);
70
+ } else {
71
+ setSelectedRows === null || setSelectedRows === void 0 ? void 0 : setSelectedRows(selectedRows);
72
+ _onRowSelectionChange === null || _onRowSelectionChange === void 0 ? void 0 : _onRowSelectionChange(selectedRowKeys, selectedRows);
73
+ onChange((selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows[0]) || null);
74
+ setVisible(false);
75
+ }
76
+ }
77
+ });
78
+ };
79
+ export var InternalPicker = observer(function (props) {
80
+ var value = props.value,
81
+ multiple = props.multiple,
82
+ _onChange = props.onChange,
83
+ quickUpload = props.quickUpload,
84
+ selectFile = props.selectFile,
85
+ others = _objectWithoutProperties(props, _excluded2);
86
+ var field = useField();
87
+ var fieldNames = useFieldNames(props);
88
+ var _useState = useState(false),
89
+ _useState2 = _slicedToArray(_useState, 2),
90
+ visibleAddNewer = _useState2[0],
91
+ setVisibleAddNewer = _useState2[1];
92
+ var _useState3 = useState(false),
93
+ _useState4 = _slicedToArray(_useState3, 2),
94
+ visibleSelector = _useState4[0],
95
+ setVisibleSelector = _useState4[1];
96
+ var fieldSchema = useFieldSchema();
97
+ var insertAddNewer = useInsertSchema('AddNewer');
98
+ var insertSelector = useInsertSchema('Selector');
99
+ var _useCollection = useCollection(),
100
+ getField = _useCollection.getField;
101
+ var _useTranslation = useTranslation(),
102
+ t = _useTranslation.t;
103
+ var collectionField = getField(field.props.name);
104
+ var addbuttonClick = function addbuttonClick() {
105
+ insertAddNewer(schema.AddNewer);
106
+ setVisibleAddNewer(true);
107
+ };
108
+ var compile = useCompile();
109
+ var labelUiSchema = useLabelUiSchema(collectionField, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label');
110
+ var isAllowAddNew = fieldSchema['x-add-new'];
111
+ var _useState5 = useState([]),
112
+ _useState6 = _slicedToArray(_useState5, 2),
113
+ selectedRows = _useState6[0],
114
+ setSelectedRows = _useState6[1];
115
+ var _useState7 = useState([]),
116
+ _useState8 = _slicedToArray(_useState7, 2),
117
+ options = _useState8[0],
118
+ setOptions = _useState8[1];
119
+ var pickerProps = {
120
+ size: 'small',
121
+ fieldNames: fieldNames,
122
+ multiple: multiple !== false && ['o2m', 'm2m'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface),
123
+ association: {
124
+ target: collectionField === null || collectionField === void 0 ? void 0 : collectionField.target
125
+ },
126
+ options: options,
127
+ onChange: props === null || props === void 0 ? void 0 : props.onChange,
128
+ selectedRows: selectedRows,
129
+ setSelectedRows: setSelectedRows,
130
+ collectionField: collectionField
131
+ };
132
+ useEffect(function () {
133
+ if (value && Object.keys(value).length > 0) {
134
+ var opts = (Array.isArray(value) ? value : value ? [value] : []).map(function (option) {
135
+ var label = option[fieldNames.label];
136
+ return _objectSpread(_objectSpread({}, option), {}, _defineProperty({}, fieldNames.label, getLabelFormatValue(compile(labelUiSchema), compile(label))));
137
+ });
138
+ setOptions(opts);
139
+ }
140
+ }, [value, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label]);
141
+ var getValue = function getValue() {
142
+ if (multiple == null) return null;
143
+ return Array.isArray(value) ? value === null || value === void 0 ? void 0 : value.map(function (v) {
144
+ return v[fieldNames.value];
145
+ }) : value === null || value === void 0 ? void 0 : value[fieldNames.value];
146
+ };
147
+ var getFilter = function getFilter() {
148
+ var targetKey = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetKey) || 'id';
149
+ var list = options.map(function (option) {
150
+ return option[targetKey];
151
+ }).filter(Boolean);
152
+ var filter = list.length ? {
153
+ $and: [_defineProperty({}, "".concat(targetKey, ".$ne"), list)]
154
+ } : {};
155
+ return filter;
156
+ };
157
+ var usePickActionProps = function usePickActionProps() {
158
+ var _useActionContext2 = useActionContext(),
159
+ setVisible = _useActionContext2.setVisible;
160
+ var _useContext2 = useContext(RecordPickerContext),
161
+ multiple = _useContext2.multiple,
162
+ selectedRows = _useContext2.selectedRows,
163
+ onChange = _useContext2.onChange,
164
+ options = _useContext2.options,
165
+ collectionField = _useContext2.collectionField;
166
+ return {
167
+ onClick: function onClick() {
168
+ if (multiple) {
169
+ onChange(unionBy(selectedRows, options, (collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetKey) || 'id'));
170
+ } else {
171
+ onChange((selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows[0]) || null);
172
+ }
173
+ setVisible(false);
174
+ }
175
+ };
176
+ };
177
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input.Group, {
178
+ compact: true,
179
+ style: {
180
+ display: 'flex'
181
+ }
182
+ }, /*#__PURE__*/React.createElement("div", {
183
+ style: {
184
+ width: '100%'
185
+ }
186
+ }, /*#__PURE__*/React.createElement(Select, _objectSpread(_objectSpread({
187
+ style: {
188
+ width: '100%'
189
+ }
190
+ }, others), {}, {
191
+ mode: multiple ? 'multiple' : props.mode,
192
+ fieldNames: fieldNames,
193
+ onDropdownVisibleChange: function onDropdownVisibleChange(open) {
194
+ insertSelector(schema.Selector);
195
+ setVisibleSelector(true);
196
+ },
197
+ allowClear: true,
198
+ onChange: function onChange(changed) {
199
+ if (!changed) {
200
+ var _value = multiple ? [] : null;
201
+ _onChange(_value);
202
+ setSelectedRows(_value);
203
+ } else if (Array.isArray(changed)) {
204
+ if (!changed.length) {
205
+ _onChange([]);
206
+ setSelectedRows([]);
207
+ return;
208
+ }
209
+ var values = options === null || options === void 0 ? void 0 : options.filter(function (option) {
210
+ return changed.includes(option[fieldNames.value]);
211
+ });
212
+ _onChange(values);
213
+ setSelectedRows(values);
214
+ }
215
+ },
216
+ options: options,
217
+ value: getValue(),
218
+ open: false
219
+ }))), isAllowAddNew && /*#__PURE__*/React.createElement(Button, {
220
+ style: {
221
+ width: 'auto'
222
+ },
223
+ type: 'default',
224
+ onClick: function onClick() {
225
+ addbuttonClick();
226
+ }
227
+ }, t('Add new'))), /*#__PURE__*/React.createElement(ActionContext.Provider, {
228
+ value: {
229
+ openMode: 'drawer',
230
+ visible: visibleAddNewer,
231
+ setVisible: setVisibleAddNewer
232
+ }
233
+ }, /*#__PURE__*/React.createElement(CollectionProvider, {
234
+ name: collectionField.target
235
+ }, /*#__PURE__*/React.createElement(RecursionField, {
236
+ onlyRenderProperties: true,
237
+ basePath: field.address,
238
+ schema: fieldSchema,
239
+ filterProperties: function filterProperties(s) {
240
+ return s['x-component'] === 'AssociationField.AddNewer';
241
+ }
242
+ }))), /*#__PURE__*/React.createElement(ActionContext.Provider, {
243
+ value: {
244
+ openMode: 'drawer',
245
+ visible: visibleSelector,
246
+ setVisible: setVisibleSelector
247
+ }
248
+ }, /*#__PURE__*/React.createElement(RecordPickerProvider, _objectSpread({}, pickerProps), /*#__PURE__*/React.createElement(CollectionProvider, {
249
+ name: collectionField.target
250
+ }, /*#__PURE__*/React.createElement(FormProvider, null, /*#__PURE__*/React.createElement(TableSelectorParamsProvider, {
251
+ params: {
252
+ filter: getFilter()
253
+ }
254
+ }, /*#__PURE__*/React.createElement(SchemaComponentOptions, {
255
+ scope: {
256
+ usePickActionProps: usePickActionProps,
257
+ useTableSelectorProps: useTableSelectorProps
258
+ }
259
+ }, /*#__PURE__*/React.createElement(RecursionField, {
260
+ onlyRenderProperties: true,
261
+ basePath: field.address,
262
+ schema: fieldSchema,
263
+ filterProperties: function filterProperties(s) {
264
+ return s['x-component'] === 'AssociationField.Selector';
265
+ }
266
+ }))))))));
267
+ });
@@ -0,0 +1 @@
1
+ export declare const InternalSubTable: () => JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { FormLayout } from '@formily/antd';
2
+ import { RecursionField, useField, useFieldSchema } from '@formily/react';
3
+ import React, { useEffect } from 'react';
4
+ import { CollectionProvider } from '../../../collection-manager';
5
+ import { useAssociationFieldContext, useInsertSchema } from './hooks';
6
+ import schema from './schema';
7
+ export var InternalSubTable = function InternalSubTable() {
8
+ var field = useField();
9
+ var fieldSchema = useFieldSchema();
10
+ var insert = useInsertSchema('SubTable');
11
+ var _useAssociationFieldC = useAssociationFieldContext(),
12
+ options = _useAssociationFieldC.options;
13
+ useEffect(function () {
14
+ insert(schema.SubTable);
15
+ }, []);
16
+ return /*#__PURE__*/React.createElement(CollectionProvider, {
17
+ name: options.target
18
+ }, /*#__PURE__*/React.createElement(FormLayout, {
19
+ layout: 'vertical'
20
+ }, /*#__PURE__*/React.createElement(RecursionField, {
21
+ onlyRenderProperties: true,
22
+ basePath: field.address,
23
+ schema: fieldSchema,
24
+ filterProperties: function filterProperties(s) {
25
+ return s['x-component'] === 'AssociationField.SubTable';
26
+ }
27
+ })));
28
+ };
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const ReadPrettyInternalViewer: React.FC;
@@ -0,0 +1,115 @@
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; }
7
+ import { RecursionField, observer, useField, useFieldSchema } from '@formily/react';
8
+ import { toArr } from '@formily/shared';
9
+ import React, { Fragment, useRef, useState } from 'react';
10
+ import { BlockAssociationContext, WithoutTableFieldResource } from '../../../block-provider';
11
+ import { CollectionProvider, useCollection, useCollectionManager } from '../../../collection-manager';
12
+ import { RecordProvider, useRecord } from '../../../record-provider';
13
+ import { FormProvider } from '../../core';
14
+ import { useCompile } from '../../hooks';
15
+ import { ActionContext, useActionContext } from '../action';
16
+ import { EllipsisWithTooltip } from '../input/EllipsisWithTooltip';
17
+ import { useFieldNames, useInsertSchema } from './hooks';
18
+ import schema from './schema';
19
+ import { getLabelFormatValue, useLabelUiSchema } from './util';
20
+ var toValue = function toValue(value, placeholder) {
21
+ if (value === null || value === undefined) {
22
+ return placeholder;
23
+ }
24
+ return value;
25
+ };
26
+ export var ReadPrettyInternalViewer = observer(function (props) {
27
+ var _collectionField$targ;
28
+ var fieldSchema = useFieldSchema();
29
+ var recordCtx = useRecord();
30
+ var enableLink = fieldSchema['x-component-props'].enableLink;
31
+ var _useCollectionManager = useCollectionManager(),
32
+ getCollectionJoinField = _useCollectionManager.getCollectionJoinField;
33
+ // value 做了转换,但 props.value 和原来 useField().value 的值不一致
34
+ var field = useField();
35
+ var fieldNames = useFieldNames(props);
36
+ var _useState = useState(false),
37
+ _useState2 = _slicedToArray(_useState, 2),
38
+ visible = _useState2[0],
39
+ setVisible = _useState2[1];
40
+ var insertViewer = useInsertSchema('Viewer');
41
+ var _useCollection = useCollection(),
42
+ getField = _useCollection.getField;
43
+ var collectionField = getField(fieldSchema.name) || getCollectionJoinField(fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-collection-field']);
44
+ var _useState3 = useState({}),
45
+ _useState4 = _slicedToArray(_useState3, 2),
46
+ record = _useState4[0],
47
+ setRecord = _useState4[1];
48
+ var compile = useCompile();
49
+ var labelUiSchema = useLabelUiSchema(collectionField, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label');
50
+ var _useActionContext = useActionContext(),
51
+ snapshot = _useActionContext.snapshot;
52
+ var ellipsisWithTooltipRef = useRef();
53
+ var renderRecords = function renderRecords() {
54
+ return toArr(props.value).map(function (record, index, arr) {
55
+ var val = toValue(compile(record === null || record === void 0 ? void 0 : record[(fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label']), 'N/A');
56
+ var text = getLabelFormatValue(compile(labelUiSchema), val, true);
57
+ return /*#__PURE__*/React.createElement(Fragment, {
58
+ key: "".concat(record.id, "_").concat(index)
59
+ }, /*#__PURE__*/React.createElement("span", null, snapshot ? text : enableLink !== false ? /*#__PURE__*/React.createElement("a", {
60
+ onClick: function onClick(e) {
61
+ var _ellipsisWithTooltipR;
62
+ e.stopPropagation();
63
+ e.preventDefault();
64
+ insertViewer(schema.Viewer);
65
+ setVisible(true);
66
+ setRecord(record);
67
+ ellipsisWithTooltipRef === null || ellipsisWithTooltipRef === void 0 ? void 0 : (_ellipsisWithTooltipR = ellipsisWithTooltipRef.current) === null || _ellipsisWithTooltipR === void 0 ? void 0 : _ellipsisWithTooltipR.setPopoverVisible(false);
68
+ }
69
+ }, text) : text), index < arr.length - 1 ? /*#__PURE__*/React.createElement("span", {
70
+ style: {
71
+ marginRight: 4,
72
+ color: '#aaa'
73
+ }
74
+ }, ",") : null);
75
+ });
76
+ };
77
+ var renderWithoutTableFieldResourceProvider = function renderWithoutTableFieldResourceProvider() {
78
+ return /*#__PURE__*/React.createElement(WithoutTableFieldResource.Provider, {
79
+ value: true
80
+ }, /*#__PURE__*/React.createElement(FormProvider, null, /*#__PURE__*/React.createElement(RecursionField, {
81
+ schema: fieldSchema,
82
+ onlyRenderProperties: true,
83
+ basePath: field.address,
84
+ filterProperties: function filterProperties(s) {
85
+ return s['x-component'] === 'AssociationField.Viewer';
86
+ }
87
+ })));
88
+ };
89
+ var renderRecordProvider = function renderRecordProvider() {
90
+ var _fieldSchema$xCollec;
91
+ var collectionFieldNames = fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCollec = fieldSchema['x-collection-field']) === null || _fieldSchema$xCollec === void 0 ? void 0 : _fieldSchema$xCollec.split('.');
92
+ return collectionFieldNames && collectionFieldNames.length > 2 ? /*#__PURE__*/React.createElement(RecordProvider, {
93
+ record: recordCtx[collectionFieldNames[1]]
94
+ }, /*#__PURE__*/React.createElement(RecordProvider, {
95
+ record: record
96
+ }, renderWithoutTableFieldResourceProvider())) : /*#__PURE__*/React.createElement(RecordProvider, {
97
+ record: record
98
+ }, renderWithoutTableFieldResourceProvider());
99
+ };
100
+ return collectionField ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BlockAssociationContext.Provider, {
101
+ value: "".concat(collectionField.collectionName, ".").concat(collectionField.name)
102
+ }, /*#__PURE__*/React.createElement(CollectionProvider, {
103
+ name: (_collectionField$targ = collectionField.target) !== null && _collectionField$targ !== void 0 ? _collectionField$targ : collectionField.targetCollection
104
+ }, /*#__PURE__*/React.createElement(EllipsisWithTooltip, {
105
+ ellipsis: true,
106
+ ref: ellipsisWithTooltipRef
107
+ }, renderRecords()), /*#__PURE__*/React.createElement(ActionContext.Provider, {
108
+ value: {
109
+ visible: visible,
110
+ setVisible: setVisible,
111
+ openMode: 'drawer',
112
+ snapshot: collectionField.interface === 'snapshot'
113
+ }
114
+ }, renderRecordProvider())))) : null;
115
+ });
@@ -0,0 +1 @@
1
+ export declare const Nester: (props: any) => JSX.Element;
@@ -0,0 +1,80 @@
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); }
7
+ import { RecursionField, observer, useFieldSchema } from '@formily/react';
8
+ import { Button, Card, Divider } from 'antd';
9
+ import { CloseCircleOutlined } from '@ant-design/icons';
10
+ import React, { useContext } from 'react';
11
+ import { AssociationFieldContext } from './context';
12
+ import { useAssociationFieldContext } from './hooks';
13
+ import { useTranslation } from 'react-i18next';
14
+ // import { useRemoveActionProps } from '../../../block-provider/hooks';
15
+ export var Nester = function Nester(props) {
16
+ var _useContext = useContext(AssociationFieldContext),
17
+ options = _useContext.options;
18
+ if (['hasOne', 'belongsTo'].includes(options.type)) {
19
+ return /*#__PURE__*/React.createElement(ToOneNester, _objectSpread({}, props));
20
+ }
21
+ if (['hasMany', 'belongsToMany'].includes(options.type)) {
22
+ return /*#__PURE__*/React.createElement(ToManyNester, _objectSpread({}, props));
23
+ }
24
+ return null;
25
+ };
26
+ var ToOneNester = function ToOneNester(props) {
27
+ return /*#__PURE__*/React.createElement(Card, {
28
+ bordered: true
29
+ }, props.children);
30
+ };
31
+ var toArr = function toArr(value) {
32
+ if (!value) {
33
+ return [];
34
+ }
35
+ if (Array.isArray(value)) {
36
+ return value;
37
+ }
38
+ return [value];
39
+ };
40
+ var ToManyNester = observer(function (props) {
41
+ var fieldSchema = useFieldSchema();
42
+ var _useAssociationFieldC = useAssociationFieldContext(),
43
+ field = _useAssociationFieldC.field;
44
+ var values = toArr(field.value);
45
+ var _useTranslation = useTranslation(),
46
+ t = _useTranslation.t;
47
+ // const { onClick } = useRemoveActionProps(`${collectionField.collectionName}.${collectionField.target}`);
48
+ return /*#__PURE__*/React.createElement(Card, {
49
+ bordered: true,
50
+ style: {
51
+ position: 'relative'
52
+ }
53
+ }, values.map(function (value, index) {
54
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !field.readPretty && /*#__PURE__*/React.createElement("div", {
55
+ style: {
56
+ textAlign: 'right'
57
+ }
58
+ }, /*#__PURE__*/React.createElement(CloseCircleOutlined, {
59
+ style: {
60
+ zIndex: 1000,
61
+ position: 'absolute',
62
+ color: '#a8a3a3'
63
+ },
64
+ onClick: function onClick() {
65
+ field.value.splice(index, 1);
66
+ }
67
+ })), /*#__PURE__*/React.createElement(RecursionField, {
68
+ onlyRenderProperties: true,
69
+ basePath: field.address.concat(index),
70
+ schema: fieldSchema
71
+ }), /*#__PURE__*/React.createElement(Divider, null));
72
+ }), field.editable && /*#__PURE__*/React.createElement(Button, {
73
+ type: 'dashed',
74
+ block: true,
75
+ onClick: function onClick() {
76
+ field.value = field.value || [];
77
+ field.value.push({});
78
+ }
79
+ }, t('Add new')));
80
+ });
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const ReadPretty: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
@@ -0,0 +1,38 @@
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); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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."); }
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); }
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; }
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; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import React, { useEffect, useState } from 'react';
14
+ import { useField, observer } from '@formily/react';
15
+ import { AssociationFieldProvider } from './AssociationFieldProvider';
16
+ import { InternalNester } from './InternalNester';
17
+ import { ReadPrettyInternalViewer } from './InternalViewer';
18
+ import { useCollection, useCollectionManager } from '../../../collection-manager';
19
+ import { InternalSubTable } from './InternalSubTable';
20
+ import { FileManageReadPretty } from './FileManager';
21
+ export var ReadPretty = observer(function (props) {
22
+ var _getCollection;
23
+ var field = useField();
24
+ var _useCollection = useCollection(),
25
+ getField = _useCollection.getField;
26
+ var _useCollectionManager = useCollectionManager(),
27
+ getCollection = _useCollectionManager.getCollection;
28
+ var collectionField = getField(field.props.name);
29
+ var isFileCollection = ((_getCollection = getCollection(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target)) === null || _getCollection === void 0 ? void 0 : _getCollection.template) === 'file';
30
+ var _useState = useState(props.mode || (isFileCollection ? 'FileManager' : 'Select')),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ currentMode = _useState2[0],
33
+ setCurrentMode = _useState2[1];
34
+ useEffect(function () {
35
+ props.mode && setCurrentMode(props.mode);
36
+ }, [props.mode]);
37
+ return /*#__PURE__*/React.createElement(AssociationFieldProvider, null, ['Select', 'Picker'].includes(currentMode) && /*#__PURE__*/React.createElement(ReadPrettyInternalViewer, _objectSpread({}, props)), currentMode === 'Nester' && /*#__PURE__*/React.createElement(InternalNester, _objectSpread({}, props)), currentMode === 'SubTable' && /*#__PURE__*/React.createElement(InternalSubTable, _objectSpread({}, props)), currentMode === 'FileManager' && /*#__PURE__*/React.createElement(FileManageReadPretty, _objectSpread({}, props)));
38
+ });
@@ -0,0 +1 @@
1
+ export declare const SubTable: any;
@@ -0,0 +1,25 @@
1
+ import { observer } from '@formily/react';
2
+ import { Button } from 'antd';
3
+ import React from 'react';
4
+ import { Table } from '../table-v2/Table';
5
+ import { useAssociationFieldContext } from './hooks';
6
+ export var SubTable = observer(function (props) {
7
+ var _useAssociationFieldC = useAssociationFieldContext(),
8
+ field = _useAssociationFieldC.field;
9
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Table, {
10
+ size: 'small',
11
+ showIndex: true,
12
+ field: field,
13
+ pagination: false
14
+ }), field.editable && /*#__PURE__*/React.createElement(Button, {
15
+ type: 'dashed',
16
+ block: true,
17
+ style: {
18
+ marginTop: 12
19
+ },
20
+ onClick: function onClick() {
21
+ field.value = field.value || [];
22
+ field.value.push({});
23
+ }
24
+ }, "Add new"));
25
+ });
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { GeneralField } from '@formily/core';
3
+ export interface AssociationFieldContextProps {
4
+ options: any;
5
+ field: GeneralField;
6
+ }
7
+ export declare const AssociationFieldContext: import("react").Context<AssociationFieldContextProps>;
@@ -0,0 +1,2 @@
1
+ import { createContext } from 'react';
2
+ export var AssociationFieldContext = /*#__PURE__*/createContext(null);
@@ -0,0 +1,8 @@
1
+ import { GeneralField } from '@formily/core';
2
+ export declare const useInsertSchema: (component: any) => (ss: any) => void;
3
+ export declare function useAssociationFieldContext<F extends GeneralField>(): {
4
+ options: any;
5
+ field: F;
6
+ };
7
+ export default function useServiceOptions(props: any): any;
8
+ export declare const useFieldNames: (props: any) => any;