@nocobase/client 0.9.2-alpha.4 → 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 (211) hide show
  1. package/es/block-provider/DetailsBlockProvider.js +13 -1
  2. package/es/block-provider/FormBlockProvider.js +30 -13
  3. package/es/block-provider/hooks/index.d.ts +10 -0
  4. package/es/block-provider/hooks/index.js +498 -281
  5. package/es/collection-manager/Configuration/CollectionFields.js +1 -2
  6. package/es/collection-manager/Configuration/EditFieldAction.js +0 -1
  7. package/es/collection-manager/Configuration/OverridingCollectionField.js +0 -1
  8. package/es/collection-manager/action-hooks.d.ts +1 -1
  9. package/es/collection-manager/action-hooks.js +18 -7
  10. package/es/collection-manager/interfaces/createdBy.js +1 -1
  11. package/es/collection-manager/interfaces/linkTo.js +3 -39
  12. package/es/collection-manager/interfaces/m2m.js +4 -38
  13. package/es/collection-manager/interfaces/m2o.js +4 -38
  14. package/es/collection-manager/interfaces/o2m.js +4 -68
  15. package/es/collection-manager/interfaces/o2o.js +25 -119
  16. package/es/collection-manager/interfaces/updatedBy.js +1 -1
  17. package/es/collection-manager/templates/tree.js +2 -2
  18. package/es/filter-provider/FilterProvider.js +3 -1
  19. package/es/locale/en_US.d.ts +3 -0
  20. package/es/locale/en_US.js +5 -2
  21. package/es/locale/ja_JP.d.ts +3 -0
  22. package/es/locale/ja_JP.js +3 -0
  23. package/es/locale/zh_CN.d.ts +4 -0
  24. package/es/locale/zh_CN.js +4 -0
  25. package/es/schema-component/antd/action/Action.Designer.js +4 -5
  26. package/es/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -0
  27. package/es/schema-component/antd/association-field/AssociationFieldProvider.js +19 -0
  28. package/es/schema-component/antd/association-field/AssociationSelect.d.ts +14 -0
  29. package/es/schema-component/antd/association-field/AssociationSelect.js +118 -0
  30. package/es/schema-component/antd/association-field/Editable.d.ts +2 -0
  31. package/es/schema-component/antd/association-field/Editable.js +88 -0
  32. package/es/schema-component/antd/association-field/FileManager.d.ts +4 -0
  33. package/es/schema-component/antd/association-field/FileManager.js +243 -0
  34. package/es/schema-component/antd/association-field/InternalNester.d.ts +1 -0
  35. package/es/schema-component/antd/association-field/InternalNester.js +28 -0
  36. package/es/schema-component/antd/association-field/InternalPicker.d.ts +2 -0
  37. package/es/schema-component/antd/association-field/InternalPicker.js +267 -0
  38. package/es/schema-component/antd/association-field/InternalSubTable.d.ts +1 -0
  39. package/es/schema-component/antd/association-field/InternalSubTable.js +28 -0
  40. package/es/schema-component/antd/association-field/InternalViewer.d.ts +2 -0
  41. package/es/schema-component/antd/association-field/InternalViewer.js +115 -0
  42. package/es/schema-component/antd/association-field/Nester.d.ts +1 -0
  43. package/es/schema-component/antd/association-field/Nester.js +80 -0
  44. package/es/schema-component/antd/association-field/ReadPretty.d.ts +2 -0
  45. package/es/schema-component/antd/association-field/ReadPretty.js +38 -0
  46. package/es/schema-component/antd/association-field/SubTable.d.ts +1 -0
  47. package/es/schema-component/antd/association-field/SubTable.js +25 -0
  48. package/es/schema-component/antd/association-field/context.d.ts +7 -0
  49. package/es/schema-component/antd/association-field/context.js +2 -0
  50. package/es/schema-component/antd/association-field/hooks.d.ts +8 -0
  51. package/es/schema-component/antd/association-field/hooks.js +96 -0
  52. package/es/schema-component/antd/association-field/index.d.ts +1 -0
  53. package/es/schema-component/antd/association-field/index.js +14 -0
  54. package/es/schema-component/antd/association-field/schema.d.ts +142 -0
  55. package/es/schema-component/antd/association-field/schema.js +141 -0
  56. package/es/schema-component/antd/association-field/util.d.ts +8 -0
  57. package/es/schema-component/antd/association-field/util.js +84 -0
  58. package/es/schema-component/antd/expand-action/Expand.Action.Design.d.ts +1 -0
  59. package/es/schema-component/antd/expand-action/Expand.Action.Design.js +112 -0
  60. package/es/schema-component/antd/expand-action/Expand.Action.d.ts +1 -0
  61. package/es/schema-component/antd/expand-action/Expand.Action.js +40 -0
  62. package/es/schema-component/antd/expand-action/index.d.ts +1 -0
  63. package/es/schema-component/antd/expand-action/index.js +5 -0
  64. package/es/schema-component/antd/filter/Filter.Action.Designer.js +10 -12
  65. package/es/schema-component/antd/filter/FilterItem.js +1 -1
  66. package/es/schema-component/antd/filter/useOperators.d.ts +1 -1
  67. package/es/schema-component/antd/form-item/FormItem.d.ts +2 -1
  68. package/es/schema-component/antd/form-item/FormItem.js +183 -52
  69. package/es/schema-component/antd/form-item/SchemaSettingOptions.js +36 -58
  70. package/es/schema-component/antd/form-v2/utils.js +3 -1
  71. package/es/schema-component/antd/gantt/components/other/tooltip.js +1 -1
  72. package/es/schema-component/antd/index.d.ts +3 -1
  73. package/es/schema-component/antd/index.js +3 -1
  74. package/es/schema-component/antd/menu/Menu.js +6 -3
  75. package/es/schema-component/antd/record-picker/InputRecordPicker.d.ts +1 -0
  76. package/es/schema-component/antd/record-picker/InputRecordPicker.js +32 -12
  77. package/es/schema-component/antd/remote-select/RemoteSelect.js +16 -18
  78. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +18 -9
  79. package/es/schema-component/antd/table-v2/Table.Index.d.ts +1 -0
  80. package/es/schema-component/antd/table-v2/Table.Index.js +6 -0
  81. package/es/schema-component/antd/table-v2/Table.js +9 -5
  82. package/es/schema-component/antd/table-v2/index.js +3 -1
  83. package/es/schema-component/antd/table-v2/utils.js +1 -1
  84. package/es/schema-component/antd/variable/Input.js +5 -5
  85. package/es/schema-component/antd/variable/TextArea.js +2 -5
  86. package/es/schema-component/common/dnd-context/index.js +3 -2
  87. package/es/schema-component/common/sortable-item/SortableItem.js +4 -1
  88. package/es/schema-component/common/utils/uitls.js +1 -1
  89. package/es/schema-component/hooks/index.d.ts +1 -0
  90. package/es/schema-component/hooks/index.js +2 -1
  91. package/es/schema-component/hooks/useFieldModeOptions.d.ts +4 -0
  92. package/es/schema-component/hooks/useFieldModeOptions.js +105 -0
  93. package/es/schema-initializer/components/CreateRecordAction.d.ts +1 -1
  94. package/es/schema-initializer/components/CreateRecordAction.js +4 -3
  95. package/es/schema-initializer/items/ExpandActionInitializer.d.ts +0 -1
  96. package/es/schema-initializer/items/ExpandActionInitializer.js +9 -34
  97. package/es/schema-initializer/items/SelectActionInitializer.d.ts +1 -0
  98. package/es/schema-initializer/items/SelectActionInitializer.js +65 -0
  99. package/es/schema-initializer/items/index.d.ts +1 -0
  100. package/es/schema-initializer/items/index.js +2 -1
  101. package/es/schema-initializer/utils.js +20 -8
  102. package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +1 -1
  103. package/es/schema-settings/LinkageRules/Variables.d.ts +1 -1
  104. package/es/schema-settings/LinkageRules/Variables.js +7 -4
  105. package/es/schema-settings/SchemaSettings.js +2 -2
  106. package/lib/block-provider/DetailsBlockProvider.js +13 -1
  107. package/lib/block-provider/FormBlockProvider.js +31 -15
  108. package/lib/block-provider/hooks/index.d.ts +10 -0
  109. package/lib/block-provider/hooks/index.js +509 -289
  110. package/lib/collection-manager/Configuration/CollectionFields.js +1 -2
  111. package/lib/collection-manager/Configuration/EditFieldAction.js +0 -1
  112. package/lib/collection-manager/Configuration/OverridingCollectionField.js +0 -1
  113. package/lib/collection-manager/action-hooks.d.ts +1 -1
  114. package/lib/collection-manager/action-hooks.js +18 -7
  115. package/lib/collection-manager/interfaces/createdBy.js +1 -1
  116. package/lib/collection-manager/interfaces/linkTo.js +2 -38
  117. package/lib/collection-manager/interfaces/m2m.js +3 -37
  118. package/lib/collection-manager/interfaces/m2o.js +3 -37
  119. package/lib/collection-manager/interfaces/o2m.js +6 -70
  120. package/lib/collection-manager/interfaces/o2o.js +30 -124
  121. package/lib/collection-manager/interfaces/updatedBy.js +1 -1
  122. package/lib/collection-manager/templates/tree.js +2 -2
  123. package/lib/filter-provider/FilterProvider.js +3 -1
  124. package/lib/locale/en_US.d.ts +3 -0
  125. package/lib/locale/en_US.js +5 -2
  126. package/lib/locale/ja_JP.d.ts +3 -0
  127. package/lib/locale/ja_JP.js +3 -0
  128. package/lib/locale/zh_CN.d.ts +4 -0
  129. package/lib/locale/zh_CN.js +4 -0
  130. package/lib/schema-component/antd/action/Action.Designer.js +4 -5
  131. package/lib/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -0
  132. package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +28 -0
  133. package/lib/schema-component/antd/association-field/AssociationSelect.d.ts +14 -0
  134. package/lib/schema-component/antd/association-field/AssociationSelect.js +129 -0
  135. package/lib/schema-component/antd/association-field/Editable.d.ts +2 -0
  136. package/lib/schema-component/antd/association-field/Editable.js +97 -0
  137. package/lib/schema-component/antd/association-field/FileManager.d.ts +4 -0
  138. package/lib/schema-component/antd/association-field/FileManager.js +253 -0
  139. package/lib/schema-component/antd/association-field/InternalNester.d.ts +1 -0
  140. package/lib/schema-component/antd/association-field/InternalNester.js +39 -0
  141. package/lib/schema-component/antd/association-field/InternalPicker.d.ts +2 -0
  142. package/lib/schema-component/antd/association-field/InternalPicker.js +277 -0
  143. package/lib/schema-component/antd/association-field/InternalSubTable.d.ts +1 -0
  144. package/lib/schema-component/antd/association-field/InternalSubTable.js +39 -0
  145. package/lib/schema-component/antd/association-field/InternalViewer.d.ts +2 -0
  146. package/lib/schema-component/antd/association-field/InternalViewer.js +126 -0
  147. package/lib/schema-component/antd/association-field/Nester.d.ts +1 -0
  148. package/lib/schema-component/antd/association-field/Nester.js +89 -0
  149. package/lib/schema-component/antd/association-field/ReadPretty.d.ts +2 -0
  150. package/lib/schema-component/antd/association-field/ReadPretty.js +47 -0
  151. package/lib/schema-component/antd/association-field/SubTable.d.ts +1 -0
  152. package/lib/schema-component/antd/association-field/SubTable.js +33 -0
  153. package/lib/schema-component/antd/association-field/context.d.ts +7 -0
  154. package/lib/schema-component/antd/association-field/context.js +9 -0
  155. package/lib/schema-component/antd/association-field/hooks.d.ts +8 -0
  156. package/lib/schema-component/antd/association-field/hooks.js +107 -0
  157. package/lib/schema-component/antd/association-field/index.d.ts +1 -0
  158. package/lib/schema-component/antd/association-field/index.js +21 -0
  159. package/lib/schema-component/antd/association-field/schema.d.ts +142 -0
  160. package/lib/schema-component/antd/association-field/schema.js +148 -0
  161. package/lib/schema-component/antd/association-field/util.d.ts +8 -0
  162. package/lib/schema-component/antd/association-field/util.js +98 -0
  163. package/lib/schema-component/antd/expand-action/Expand.Action.Design.d.ts +1 -0
  164. package/lib/schema-component/antd/expand-action/Expand.Action.Design.js +120 -0
  165. package/lib/schema-component/antd/expand-action/Expand.Action.d.ts +1 -0
  166. package/lib/schema-component/antd/expand-action/Expand.Action.js +48 -0
  167. package/lib/schema-component/antd/expand-action/index.d.ts +1 -0
  168. package/lib/schema-component/antd/expand-action/index.js +12 -0
  169. package/lib/schema-component/antd/filter/Filter.Action.Designer.js +10 -12
  170. package/lib/schema-component/antd/filter/FilterItem.js +1 -1
  171. package/lib/schema-component/antd/filter/useOperators.d.ts +1 -1
  172. package/lib/schema-component/antd/form-item/FormItem.d.ts +2 -1
  173. package/lib/schema-component/antd/form-item/FormItem.js +180 -48
  174. package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +34 -56
  175. package/lib/schema-component/antd/form-v2/utils.js +3 -1
  176. package/lib/schema-component/antd/gantt/components/other/tooltip.js +1 -1
  177. package/lib/schema-component/antd/index.d.ts +3 -1
  178. package/lib/schema-component/antd/index.js +33 -11
  179. package/lib/schema-component/antd/menu/Menu.js +6 -3
  180. package/lib/schema-component/antd/record-picker/InputRecordPicker.d.ts +1 -0
  181. package/lib/schema-component/antd/record-picker/InputRecordPicker.js +34 -13
  182. package/lib/schema-component/antd/remote-select/RemoteSelect.js +15 -17
  183. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +18 -9
  184. package/lib/schema-component/antd/table-v2/Table.Index.d.ts +1 -0
  185. package/lib/schema-component/antd/table-v2/Table.Index.js +14 -0
  186. package/lib/schema-component/antd/table-v2/Table.js +9 -5
  187. package/lib/schema-component/antd/table-v2/index.js +3 -1
  188. package/lib/schema-component/antd/table-v2/utils.js +1 -1
  189. package/lib/schema-component/antd/variable/Input.js +5 -5
  190. package/lib/schema-component/antd/variable/TextArea.js +2 -5
  191. package/lib/schema-component/common/dnd-context/index.js +3 -2
  192. package/lib/schema-component/common/sortable-item/SortableItem.js +4 -1
  193. package/lib/schema-component/common/utils/uitls.js +1 -1
  194. package/lib/schema-component/hooks/index.d.ts +1 -0
  195. package/lib/schema-component/hooks/index.js +11 -0
  196. package/lib/schema-component/hooks/useFieldModeOptions.d.ts +4 -0
  197. package/lib/schema-component/hooks/useFieldModeOptions.js +112 -0
  198. package/lib/schema-initializer/components/CreateRecordAction.d.ts +1 -1
  199. package/lib/schema-initializer/components/CreateRecordAction.js +4 -3
  200. package/lib/schema-initializer/items/ExpandActionInitializer.d.ts +0 -1
  201. package/lib/schema-initializer/items/ExpandActionInitializer.js +11 -37
  202. package/lib/schema-initializer/items/SelectActionInitializer.d.ts +1 -0
  203. package/lib/schema-initializer/items/SelectActionInitializer.js +73 -0
  204. package/lib/schema-initializer/items/index.d.ts +1 -0
  205. package/lib/schema-initializer/items/index.js +11 -0
  206. package/lib/schema-initializer/utils.js +20 -8
  207. package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +1 -1
  208. package/lib/schema-settings/LinkageRules/Variables.d.ts +1 -1
  209. package/lib/schema-settings/LinkageRules/Variables.js +7 -4
  210. package/lib/schema-settings/SchemaSettings.js +3 -3
  211. package/package.json +5 -6
@@ -26,7 +26,7 @@ export var tree = {
26
26
  onDelete: 'CASCADE',
27
27
  uiSchema: {
28
28
  title: '{{t("Parent")}}',
29
- 'x-component': 'RecordPicker',
29
+ 'x-component': 'AssociationField',
30
30
  'x-component-props': {
31
31
  // mode: 'tags',
32
32
  multiple: false,
@@ -45,7 +45,7 @@ export var tree = {
45
45
  onDelete: 'CASCADE',
46
46
  uiSchema: {
47
47
  title: '{{t("Children")}}',
48
- 'x-component': 'RecordPicker',
48
+ 'x-component': 'AssociationField',
49
49
  'x-component-props': {
50
50
  // mode: 'tags',
51
51
  multiple: true,
@@ -21,6 +21,7 @@ import { mergeFilter } from '../block-provider/SharedFilterProvider';
21
21
  import { useCollection } from '../collection-manager';
22
22
  import { removeNullCondition } from '../schema-component';
23
23
  import { useAssociatedFields } from './utils';
24
+ import { uniqBy } from 'lodash';
24
25
  var FilterContext = /*#__PURE__*/createContext(null);
25
26
  /**
26
27
  * 主要用于记录当前页面中的数据区块的信息,用于在过滤区块中使用
@@ -121,8 +122,9 @@ export var useFilterBlock = function useFilterBlock() {
121
122
  existingBlock.defaultFilter = block.defaultFilter;
122
123
  return;
123
124
  }
125
+ // 由于 setDataBlocks 是异步操作,所以上面的 existingBlock 在判断时有可能用的是旧的 dataBlocks,所以下面还需要根据 uid 进行去重操作
124
126
  setDataBlocks(function (prev) {
125
- return [].concat(_toConsumableArray(prev), [block]);
127
+ return uniqBy([].concat(_toConsumableArray(prev), [block]), 'uid');
126
128
  });
127
129
  };
128
130
  var getDataBlocks = function getDataBlocks() {
@@ -241,6 +241,7 @@ declare const _default: {
241
241
  "Link to": string;
242
242
  "Link to description": string;
243
243
  "Sub-table": string;
244
+ "Sub-details": string;
244
245
  "System info": string;
245
246
  "Created at": string;
246
247
  "Last updated at": string;
@@ -282,6 +283,8 @@ declare const _default: {
282
283
  "Field component": string;
283
284
  Subtable: string;
284
285
  Subform: string;
286
+ "Field mode": string;
287
+ "Allow add new data": string;
285
288
  "Record picker": string;
286
289
  "Toggles the subfield mode": string;
287
290
  "Selector mode": string;
@@ -241,6 +241,7 @@ export default {
241
241
  "Link to": "Link to",
242
242
  "Link to description": "Used to create collection relationships quickly and compatible with most common scenarios. Suitable for non-developer use. When present as a field, it is a drop-down selection used to select records from the target collection. Once created, it will simultaneously generate the associated fields of the current collection in the target collection.",
243
243
  "Sub-table": "Sub-table",
244
+ "Sub-details": "Sub-details",
244
245
  "System info": "System info",
245
246
  "Created at": "Created at",
246
247
  "Last updated at": "Last updated at",
@@ -281,12 +282,14 @@ export default {
281
282
  "Display field title": "Display field title",
282
283
  "Field component": "Field component",
283
284
  "Subtable": "Subtable",
284
- "Subform": "Subform",
285
+ "Subform": "Sub-form",
286
+ "Field mode": "Field mode",
287
+ "Allow add new data": "Allow add new data",
285
288
  "Record picker": "Record picker",
286
289
  "Toggles the subfield mode": "Toggles the subfield mode",
287
290
  "Selector mode": "Selector mode",
288
291
  "Subtable mode": "Subtable mode",
289
- "Subform mode": "Subform mode",
292
+ "Subform mode": "Sub-form mode",
290
293
  "Edit block title": "Edit block title",
291
294
  "Block title": "Block title",
292
295
  "Pattern": "Pattern",
@@ -556,6 +556,9 @@ declare const _default: {
556
556
  "Field component": string;
557
557
  Subtable: string;
558
558
  Subform: string;
559
+ "Sub-details": string;
560
+ "Field mode": string;
561
+ "Allow add new data": string;
559
562
  "Regular expression": string;
560
563
  "Enabled languages": string;
561
564
  "View all plugins": string;
@@ -556,6 +556,9 @@ export default {
556
556
  "Field component": "フィールドコンポーネント",
557
557
  "Subtable": "サブテーブル",
558
558
  "Subform": "サブフォーム",
559
+ "Sub-details": "サブリスト",
560
+ "Field mode": "フィールドコンポーネント",
561
+ "Allow add new data": "データの追加を許可",
559
562
  "Regular expression": "正規表現",
560
563
  "Enabled languages": "利用可能な言語",
561
564
  "View all plugins": "すべてのプラグラインを見る",
@@ -214,6 +214,7 @@ declare const _default: {
214
214
  "Edit collection": string;
215
215
  "Configure fields": string;
216
216
  "Configure columns": string;
217
+ "Please select the records you want to delete": string;
217
218
  "Edit field": string;
218
219
  Override: string;
219
220
  "Override field": string;
@@ -300,11 +301,14 @@ declare const _default: {
300
301
  "Field component": string;
301
302
  Subtable: string;
302
303
  Subform: string;
304
+ "Sub-details": string;
303
305
  "Record picker": string;
304
306
  "Toggles the subfield mode": string;
305
307
  "Selector mode": string;
306
308
  "Subtable mode": string;
307
309
  "Subform mode": string;
310
+ "Field mode": string;
311
+ "Allow add new data": string;
308
312
  "Edit block title": string;
309
313
  "Block title": string;
310
314
  Pattern: string;
@@ -214,6 +214,7 @@ export default {
214
214
  "Edit collection": "编辑数据表",
215
215
  "Configure fields": "配置字段",
216
216
  "Configure columns": "配置字段",
217
+ "Please select the records you want to delete": "请选择要删除的记录",
217
218
  "Edit field": "编辑字段",
218
219
  "Override": "重写",
219
220
  "Override field": "重写字段",
@@ -300,11 +301,14 @@ export default {
300
301
  "Field component": "字段组件",
301
302
  "Subtable": "子表格",
302
303
  "Subform": "子表单",
304
+ "Sub-details": "子详情",
303
305
  "Record picker": "数据选择器",
304
306
  "Toggles the subfield mode": "切换子字段模式",
305
307
  "Selector mode": "选择器模式",
306
308
  "Subtable mode": "子表格模式",
307
309
  "Subform mode": "子表单模式",
310
+ "Field mode": "字段组件",
311
+ "Allow add new data": "允许添加数据",
308
312
  "Edit block title": "编辑区块标题",
309
313
  "Block title": "区块标题",
310
314
  "Pattern": "模式",
@@ -58,6 +58,7 @@ export var ActionDesigner = function ActionDesigner(props) {
58
58
  dn = _useDesignable.dn;
59
59
  var _useTranslation2 = useTranslation(),
60
60
  t = _useTranslation2.t;
61
+ var isAction = useLinkageAction();
61
62
  var isPopupAction = ['create', 'update', 'view', 'customize:popup'].includes(fieldSchema['x-action'] || '');
62
63
  var isUpdateModePopupAction = ['customize:bulkUpdate', 'customize:bulkEdit'].includes(fieldSchema['x-action']);
63
64
  var _useState = useState(),
@@ -65,9 +66,8 @@ export var ActionDesigner = function ActionDesigner(props) {
65
66
  initialSchema = _useState2[0],
66
67
  setInitialSchema = _useState2[1];
67
68
  var actionType = (_fieldSchema$xAction = fieldSchema['x-action']) !== null && _fieldSchema$xAction !== void 0 ? _fieldSchema$xAction : '';
68
- var isLinkageAction = linkageAction || useLinkageAction();
69
+ var isLinkageAction = linkageAction || isAction;
69
70
  var isChildCollectionAction = getChildrenCollections(name).length > 0 && fieldSchema['x-action'] === 'create';
70
- var isSupportEditButton = fieldSchema['x-action'] !== 'expandAll';
71
71
  var isLink = fieldSchema['x-component'] === 'Action.Link';
72
72
  useEffect(function () {
73
73
  var schemaUid = uid();
@@ -96,8 +96,7 @@ export var ActionDesigner = function ActionDesigner(props) {
96
96
  'x-component': 'Input',
97
97
  title: t('Button title'),
98
98
  default: fieldSchema.title,
99
- 'x-component-props': {},
100
- 'x-visible': isSupportEditButton
99
+ 'x-component-props': {}
101
100
  // description: `原字段标题:${collectionField?.uiSchema?.title}`,
102
101
  },
103
102
 
@@ -107,7 +106,7 @@ export var ActionDesigner = function ActionDesigner(props) {
107
106
  title: t('Button icon'),
108
107
  default: fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.icon,
109
108
  'x-component-props': {},
110
- 'x-visible': isSupportEditButton && !isLink
109
+ 'x-visible': !isLink
111
110
  // description: `原字段标题:${collectionField?.uiSchema?.title}`,
112
111
  },
113
112
 
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function AssociationFieldProvider(props: any): JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { useField, useFieldSchema } from '@formily/react';
2
+ import React, { useMemo } from 'react';
3
+ import { useCollectionManager } from '../../../collection-manager';
4
+ import { AssociationFieldContext } from './context';
5
+ export function AssociationFieldProvider(props) {
6
+ var field = useField();
7
+ var _useCollectionManager = useCollectionManager(),
8
+ getCollectionField = _useCollectionManager.getCollectionField;
9
+ var fieldSchema = useFieldSchema();
10
+ var collectionField = useMemo(function () {
11
+ return getCollectionField(fieldSchema['x-collection-field']);
12
+ }, [fieldSchema['x-collection-field']]);
13
+ return /*#__PURE__*/React.createElement(AssociationFieldContext.Provider, {
14
+ value: {
15
+ options: collectionField,
16
+ field: field
17
+ }
18
+ }, props.children);
19
+ }
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { RemoteSelectProps } from '../remote-select';
3
+ export declare type AssociationSelectProps<P = any> = RemoteSelectProps<P> & {
4
+ action?: string;
5
+ multiple?: boolean;
6
+ };
7
+ interface AssociationSelectInterface {
8
+ (props: any): React.ReactElement;
9
+ Designer: React.FC;
10
+ FilterDesigner: React.FC;
11
+ }
12
+ export declare const AssociationSelect: AssociationSelectInterface;
13
+ export declare const AssociationSelectReadPretty: React.ForwardRefExoticComponent<Pick<Partial<any>, string | number | symbol> & React.RefAttributes<unknown>>;
14
+ export {};
@@ -0,0 +1,118 @@
1
+ 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; }
2
+ 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; }
3
+ 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; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ 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); }
6
+ 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); }
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 { LoadingOutlined } from '@ant-design/icons';
14
+ import { RecursionField, connect, mapProps, observer, useField, useFieldSchema } from '@formily/react';
15
+ import { Button, Input } from 'antd';
16
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
17
+ import { useTranslation } from 'react-i18next';
18
+ import { CollectionProvider, useCollection } from '../../../collection-manager';
19
+ import { useFieldTitle } from '../../hooks';
20
+ import { ActionContext } from '../action';
21
+ import { RemoteSelect } from '../remote-select';
22
+ import useServiceOptions, { useInsertSchema } from './hooks';
23
+ import schema from './schema';
24
+ var InternalAssociationSelect = observer(function (props) {
25
+ var fieldNames = props.fieldNames,
26
+ _props$objectValue = props.objectValue,
27
+ objectValue = _props$objectValue === void 0 ? true : _props$objectValue;
28
+ var field = useField();
29
+ var _useState = useState(false),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ visibleAddNewer = _useState2[0],
32
+ setVisibleAddNewer = _useState2[1];
33
+ var _useCollection = useCollection(),
34
+ getField = _useCollection.getField;
35
+ var collectionField = getField(field.props.name);
36
+ var service = useServiceOptions(props);
37
+ var fieldSchema = useFieldSchema();
38
+ var isFilterForm = fieldSchema['x-designer'] === 'FormItem.FilterFormDesigner';
39
+ var isAllowAddNew = fieldSchema['x-add-new'];
40
+ var insertAddNewer = useInsertSchema('AddNewer');
41
+ var _useTranslation = useTranslation(),
42
+ t = _useTranslation.t;
43
+ var normalizeValues = useCallback(function (obj) {
44
+ if (!objectValue && _typeof(obj) === 'object') {
45
+ return obj[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value];
46
+ }
47
+ return obj;
48
+ }, [objectValue, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value]);
49
+ var value = useMemo(function () {
50
+ if (props.value === undefined || props.value === null || !Object.keys(props.value).length) {
51
+ return;
52
+ }
53
+ if (Array.isArray(props.value)) {
54
+ return props.value;
55
+ } else {
56
+ return props.value;
57
+ }
58
+ }, [props.value, normalizeValues]);
59
+ useEffect(function () {
60
+ field.value = value;
61
+ }, []);
62
+ return /*#__PURE__*/React.createElement("div", {
63
+ key: fieldSchema.name
64
+ }, /*#__PURE__*/React.createElement(Input.Group, {
65
+ compact: true,
66
+ style: {
67
+ display: 'flex'
68
+ }
69
+ }, /*#__PURE__*/React.createElement(RemoteSelect, _objectSpread(_objectSpread({
70
+ style: {
71
+ width: '100%'
72
+ }
73
+ }, props), {}, {
74
+ objectValue: objectValue,
75
+ value: value,
76
+ service: service
77
+ })), isAllowAddNew && !field.readPretty && !isFilterForm && /*#__PURE__*/React.createElement(Button, {
78
+ type: 'default',
79
+ onClick: function onClick() {
80
+ insertAddNewer(schema.AddNewer);
81
+ setVisibleAddNewer(true);
82
+ }
83
+ }, t('Add new'))), /*#__PURE__*/React.createElement(ActionContext.Provider, {
84
+ value: {
85
+ openMode: 'drawer',
86
+ visible: visibleAddNewer,
87
+ setVisible: setVisibleAddNewer
88
+ }
89
+ }, /*#__PURE__*/React.createElement(CollectionProvider, {
90
+ name: collectionField.target
91
+ }, /*#__PURE__*/React.createElement(RecursionField, {
92
+ onlyRenderProperties: true,
93
+ basePath: field.address,
94
+ schema: fieldSchema,
95
+ filterProperties: function filterProperties(s) {
96
+ return s['x-component'] === 'AssociationField.AddNewer';
97
+ }
98
+ }))));
99
+ });
100
+ export var AssociationSelect = InternalAssociationSelect;
101
+ export var AssociationSelectReadPretty = connect(function (props) {
102
+ if (props.fieldNames) {
103
+ var service = useServiceOptions(props);
104
+ useFieldTitle();
105
+ return /*#__PURE__*/React.createElement(RemoteSelect.ReadPretty, _objectSpread(_objectSpread({}, props), {}, {
106
+ service: service
107
+ }));
108
+ }
109
+ return null;
110
+ }, mapProps({
111
+ dataSource: 'options',
112
+ loading: true
113
+ }, function (props, field) {
114
+ return _objectSpread(_objectSpread({}, props), {}, {
115
+ fieldNames: props.fieldNames && _objectSpread(_objectSpread({}, props.fieldNames), field.componentProps.fieldNames),
116
+ suffixIcon: (field === null || field === void 0 ? void 0 : field['loading']) || (field === null || field === void 0 ? void 0 : field['validating']) ? /*#__PURE__*/React.createElement(LoadingOutlined, null) : props.suffixIcon
117
+ });
118
+ }));
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Editable: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
@@ -0,0 +1,88 @@
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 _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ 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; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ import { observer, useField, useFieldSchema, useForm } from '@formily/react';
17
+ import React, { useEffect, useState } from 'react';
18
+ import { AssociationFieldProvider } from './AssociationFieldProvider';
19
+ import { InternalNester } from './InternalNester';
20
+ import { InternalPicker } from './InternalPicker';
21
+ import { AssociationSelect } from './AssociationSelect';
22
+ import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
23
+ import { useCollection, useCollectionManager } from '../../../collection-manager';
24
+ import { SchemaComponentOptions } from '../../';
25
+ import { InternalSubTable } from './InternalSubTable';
26
+ import { InternalFileManager } from './FileManager';
27
+ export var Editable = observer(function (props) {
28
+ var _getCollection;
29
+ useEffect(function () {
30
+ props.mode && setCurrentMode(props.mode);
31
+ }, [props.mode]);
32
+ var multiple = props.multiple;
33
+ var field = useField();
34
+ var form = useForm();
35
+ var fieldSchema = useFieldSchema();
36
+ var _useCollection = useCollection(),
37
+ getField = _useCollection.getField;
38
+ var _useCollectionManager = useCollectionManager(),
39
+ getCollection = _useCollectionManager.getCollection;
40
+ var collectionField = getField(field.props.name);
41
+ var isFileCollection = ((_getCollection = getCollection(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target)) === null || _getCollection === void 0 ? void 0 : _getCollection.template) === 'file';
42
+ var _useState = useState(props.mode || (isFileCollection ? 'FileManager' : 'Select')),
43
+ _useState2 = _slicedToArray(_useState, 2),
44
+ currentMode = _useState2[0],
45
+ setCurrentMode = _useState2[1];
46
+ var useCreateActionProps = function useCreateActionProps() {
47
+ var _useCAP = useCAP(),
48
+ _onClick = _useCAP.onClick;
49
+ var actionField = useField();
50
+ return {
51
+ onClick: function onClick() {
52
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
53
+ var _actionField$data, _actionField$data$dat;
54
+ var _ref, data, values, value;
55
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
56
+ while (1) switch (_context.prev = _context.next) {
57
+ case 0:
58
+ _context.next = 2;
59
+ return _onClick();
60
+ case 2:
61
+ _ref = ((_actionField$data = actionField.data) === null || _actionField$data === void 0 ? void 0 : (_actionField$data$dat = _actionField$data.data) === null || _actionField$data$dat === void 0 ? void 0 : _actionField$data$dat.data) || {}, data = _ref.data;
62
+ if (['m2m', 'o2m'].includes(collectionField.interface) && multiple !== false) {
63
+ values = JSON.parse(JSON.stringify(form.values[fieldSchema.name] || []));
64
+ values.push(_objectSpread({}, data));
65
+ setTimeout(function () {
66
+ form.setValuesIn(field.props.name, values);
67
+ }, 100);
68
+ } else {
69
+ value = _objectSpread({}, data);
70
+ setTimeout(function () {
71
+ form.setValuesIn(field.props.name, value);
72
+ }, 100);
73
+ }
74
+ case 4:
75
+ case "end":
76
+ return _context.stop();
77
+ }
78
+ }, _callee);
79
+ }))();
80
+ }
81
+ };
82
+ };
83
+ return /*#__PURE__*/React.createElement(AssociationFieldProvider, null, /*#__PURE__*/React.createElement(SchemaComponentOptions, {
84
+ scope: {
85
+ useCreateActionProps: useCreateActionProps
86
+ }
87
+ }, currentMode === 'Picker' && /*#__PURE__*/React.createElement(InternalPicker, _objectSpread({}, props)), currentMode === 'Nester' && /*#__PURE__*/React.createElement(InternalNester, _objectSpread({}, props)), currentMode === 'Select' && /*#__PURE__*/React.createElement(AssociationSelect, _objectSpread({}, props)), currentMode === 'SubTable' && /*#__PURE__*/React.createElement(InternalSubTable, _objectSpread({}, props)), currentMode === 'FileManager' && /*#__PURE__*/React.createElement(InternalFileManager, _objectSpread({}, props))));
88
+ });
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ declare const InternalFileManager: (props: any) => JSX.Element;
3
+ declare const FileManageReadPretty: React.ForwardRefExoticComponent<Pick<Partial<any>, string | number | symbol> & React.RefAttributes<unknown>>;
4
+ export { InternalFileManager, FileManageReadPretty };