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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/es/acl/ACLProvider.js +2 -2
  2. package/es/acl/Configuration/RoleConfigure.js +15 -8
  3. package/es/api-client/APIClient.d.ts +2 -0
  4. package/es/api-client/APIClient.js +11 -0
  5. package/es/block-provider/BlockProvider.js +58 -17
  6. package/es/block-provider/hooks/index.js +81 -60
  7. package/es/collection-manager/CollectionField.js +3 -3
  8. package/es/collection-manager/CollectionFieldProvider.js +2 -1
  9. package/es/collection-manager/Configuration/AddFieldAction.js +3 -3
  10. package/es/collection-manager/Configuration/CollectionFields.d.ts +1 -1
  11. package/es/collection-manager/Configuration/CollectionFields.js +1 -3
  12. package/es/collection-manager/Configuration/ConfigurationTabs.js +7 -6
  13. package/es/collection-manager/hooks/useCollection.d.ts +1 -1
  14. package/es/collection-manager/hooks/useCollectionDataSource.js +4 -4
  15. package/es/collection-manager/interfaces/m2m.js +1 -1
  16. package/es/collection-manager/interfaces/m2o.js +1 -1
  17. package/es/collection-manager/interfaces/o2m.js +1 -1
  18. package/es/collection-manager/interfaces/o2o.js +2 -2
  19. package/es/collection-manager/templates/expression.js +1 -1
  20. package/es/filter-provider/utils.js +1 -1
  21. package/es/index.d.ts +1 -0
  22. package/es/index.js +1 -0
  23. package/es/locale/en_US.d.ts +16 -1
  24. package/es/locale/en_US.js +17 -2
  25. package/es/locale/es_ES.d.ts +692 -0
  26. package/es/locale/es_ES.js +691 -0
  27. package/es/locale/ja_JP.d.ts +5 -1
  28. package/es/locale/ja_JP.js +6 -2
  29. package/es/locale/pt_BR.d.ts +5 -1
  30. package/es/locale/pt_BR.js +6 -2
  31. package/es/locale/ru_RU.d.ts +5 -1
  32. package/es/locale/ru_RU.js +6 -2
  33. package/es/locale/tr_TR.d.ts +5 -1
  34. package/es/locale/tr_TR.js +6 -2
  35. package/es/locale/zh_CN.d.ts +25 -2
  36. package/es/locale/zh_CN.js +26 -3
  37. package/es/pm/PluginManagerLink.js +22 -14
  38. package/es/record-provider/index.d.ts +4 -0
  39. package/es/record-provider/index.js +3 -0
  40. package/es/schema-component/antd/action/Action.Designer.js +6 -3
  41. package/es/schema-component/antd/action/Action.Drawer.js +5 -2
  42. package/es/schema-component/antd/action/Action.js +2 -2
  43. package/es/schema-component/antd/action/ActionBar.js +25 -18
  44. package/es/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -2
  45. package/es/schema-component/antd/association-field/AssociationFieldProvider.js +62 -9
  46. package/es/schema-component/antd/association-field/AssociationSelect.js +10 -65
  47. package/es/schema-component/antd/association-field/Editable.d.ts +1 -1
  48. package/es/schema-component/antd/association-field/Editable.js +32 -40
  49. package/es/schema-component/antd/association-field/InternalNester.js +4 -3
  50. package/es/schema-component/antd/association-field/InternalPicker.js +29 -60
  51. package/es/schema-component/antd/association-field/InternalViewer.js +9 -12
  52. package/es/schema-component/antd/association-field/Nester.js +19 -21
  53. package/es/schema-component/antd/association-field/ReadPretty.d.ts +1 -1
  54. package/es/schema-component/antd/association-field/ReadPretty.js +9 -25
  55. package/es/schema-component/antd/association-field/components/CreateRecordAction.d.ts +2 -0
  56. package/es/schema-component/antd/association-field/components/CreateRecordAction.js +61 -0
  57. package/es/schema-component/antd/association-field/context.d.ts +5 -2
  58. package/es/schema-component/antd/association-field/context.js +1 -1
  59. package/es/schema-component/antd/association-field/hooks.d.ts +3 -0
  60. package/es/schema-component/antd/association-field/hooks.js +10 -10
  61. package/es/schema-component/antd/association-filter/AssociationFilter.Item.js +3 -3
  62. package/es/schema-component/antd/association-select/AssociationSelect.js +49 -231
  63. package/es/schema-component/antd/association-select/useServiceOptions.js +2 -2
  64. package/es/schema-component/antd/collection-select/CollectionSelect.js +5 -0
  65. package/es/schema-component/antd/filter/FilterAction.js +2 -2
  66. package/es/schema-component/antd/form/Form.js +4 -4
  67. package/es/schema-component/antd/form-item/FormItem.js +126 -145
  68. package/es/schema-component/antd/form-item/SchemaSettingOptions.js +3 -3
  69. package/es/schema-component/antd/form-v2/Form.Designer.js +1 -0
  70. package/es/schema-component/antd/form-v2/Templates.d.ts +20 -0
  71. package/es/schema-component/antd/form-v2/Templates.js +42 -12
  72. package/es/schema-component/antd/grid/Grid.js +34 -24
  73. package/es/schema-component/antd/grid-card/GridCard.Decorator.d.ts +5 -0
  74. package/es/schema-component/antd/grid-card/GridCard.Decorator.js +65 -0
  75. package/es/schema-component/antd/grid-card/GridCard.Designer.d.ts +1 -0
  76. package/es/schema-component/antd/grid-card/GridCard.Designer.js +243 -0
  77. package/es/schema-component/antd/grid-card/GridCard.Item.d.ts +1 -0
  78. package/es/schema-component/antd/grid-card/GridCard.Item.js +18 -0
  79. package/es/schema-component/antd/grid-card/GridCard.d.ts +8 -0
  80. package/es/schema-component/antd/grid-card/GridCard.js +103 -0
  81. package/es/schema-component/antd/grid-card/hooks.d.ts +4 -0
  82. package/es/schema-component/antd/grid-card/hooks.js +9 -0
  83. package/es/schema-component/antd/grid-card/index.d.ts +1 -0
  84. package/es/schema-component/antd/grid-card/index.js +1 -0
  85. package/es/schema-component/antd/grid-card/options.d.ts +20 -0
  86. package/es/schema-component/antd/grid-card/options.js +20 -0
  87. package/es/schema-component/antd/icon-picker/IconPicker.js +2 -2
  88. package/es/schema-component/antd/index.d.ts +2 -0
  89. package/es/schema-component/antd/index.js +2 -0
  90. package/es/schema-component/antd/input/EllipsisWithTooltip.js +2 -2
  91. package/es/schema-component/antd/list/List.Decorator.d.ts +5 -0
  92. package/es/schema-component/antd/list/List.Decorator.js +59 -0
  93. package/es/schema-component/antd/list/List.Designer.d.ts +1 -0
  94. package/es/schema-component/antd/list/List.Designer.js +205 -0
  95. package/es/schema-component/antd/list/List.Item.d.ts +1 -0
  96. package/es/schema-component/antd/list/List.Item.js +15 -0
  97. package/es/schema-component/antd/list/List.d.ts +8 -0
  98. package/es/schema-component/antd/list/List.js +83 -0
  99. package/es/schema-component/antd/list/hooks.d.ts +4 -0
  100. package/es/schema-component/antd/list/hooks.js +9 -0
  101. package/es/schema-component/antd/list/index.d.ts +1 -0
  102. package/es/schema-component/antd/list/index.js +1 -0
  103. package/es/schema-component/antd/remote-select/RemoteSelect.js +12 -10
  104. package/es/schema-component/antd/select/Select.js +15 -4
  105. package/es/schema-component/antd/table/Table.Void.Designer.js +1 -0
  106. package/es/schema-component/antd/table-v2/TableBlockDesigner.js +2 -1
  107. package/es/schema-component/antd/table-v2/TableSelectorDesigner.js +1 -0
  108. package/es/schema-component/antd/table-v2/hooks/useUserVariable.d.ts +22 -0
  109. package/es/schema-component/antd/table-v2/hooks/useUserVariable.js +65 -0
  110. package/es/schema-component/antd/variable/Input.js +6 -3
  111. package/es/schema-component/common/dnd-context/index.js +2 -2
  112. package/es/schema-component/common/sortable-item/SortableItem.js +3 -4
  113. package/es/schema-component/core/SchemaComponentProvider.js +2 -2
  114. package/es/schema-initializer/SchemaInitializerProvider.d.ts +1 -0
  115. package/es/schema-initializer/SchemaInitializerProvider.js +23 -10
  116. package/es/schema-initializer/buttons/BlockInitializers.js +10 -0
  117. package/es/schema-initializer/buttons/CustomFormItemInitializers.js +4 -2
  118. package/es/schema-initializer/buttons/FormActionInitializers.d.ts +0 -116
  119. package/es/schema-initializer/buttons/FormActionInitializers.js +106 -100
  120. package/es/schema-initializer/buttons/GanttActionInitializers.d.ts +0 -19
  121. package/es/schema-initializer/buttons/GridCardActionInitializers.d.ts +195 -0
  122. package/es/schema-initializer/buttons/GridCardActionInitializers.js +278 -0
  123. package/es/schema-initializer/buttons/ListActionInitializers.d.ts +195 -0
  124. package/es/schema-initializer/buttons/ListActionInitializers.js +278 -0
  125. package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
  126. package/es/schema-initializer/buttons/TableActionInitializers.d.ts +0 -20
  127. package/es/schema-initializer/buttons/TableActionInitializers.js +29 -35
  128. package/es/schema-initializer/buttons/TableColumnInitializers.js +4 -1
  129. package/es/schema-initializer/buttons/index.d.ts +3 -0
  130. package/es/schema-initializer/buttons/index.js +3 -0
  131. package/es/schema-initializer/components/BulkEditField.js +7 -5
  132. package/es/schema-initializer/components/CreateRecordAction.d.ts +1 -0
  133. package/es/schema-initializer/components/CreateRecordAction.js +51 -30
  134. package/es/schema-initializer/components/DeletedField.d.ts +1 -0
  135. package/es/schema-initializer/components/DeletedField.js +11 -0
  136. package/es/schema-initializer/components/assigned-field/AssignedField.js +35 -23
  137. package/es/schema-initializer/items/GridCardBlockInitializer.d.ts +1 -0
  138. package/es/schema-initializer/items/GridCardBlockInitializer.js +47 -0
  139. package/es/schema-initializer/items/ListBlockInitializer.d.ts +1 -0
  140. package/es/schema-initializer/items/ListBlockInitializer.js +47 -0
  141. package/es/schema-initializer/items/index.d.ts +3 -1
  142. package/es/schema-initializer/items/index.js +4 -2
  143. package/es/schema-initializer/utils.d.ts +112 -0
  144. package/es/schema-initializer/utils.js +206 -32
  145. package/es/schema-items/GeneralSchemaItems.d.ts +4 -0
  146. package/es/schema-items/GeneralSchemaItems.js +148 -0
  147. package/es/schema-items/index.d.ts +1 -0
  148. package/es/schema-items/index.js +2 -1
  149. package/es/schema-settings/DataTemplates/FormDataTemplates.d.ts +1 -0
  150. package/es/schema-settings/DataTemplates/FormDataTemplates.js +117 -42
  151. package/es/schema-settings/DataTemplates/components/AsDefaultTemplate.js +1 -1
  152. package/es/schema-settings/DataTemplates/components/DataTemplateTitle.js +9 -13
  153. package/es/schema-settings/DataTemplates/components/Designer.d.ts +7 -0
  154. package/es/schema-settings/DataTemplates/components/Designer.js +179 -0
  155. package/es/schema-settings/DataTemplates/hooks/useCollectionState.d.ts +6 -1
  156. package/es/schema-settings/DataTemplates/hooks/useCollectionState.js +204 -96
  157. package/es/schema-settings/GeneralSchemaDesigner.js +19 -15
  158. package/es/schema-settings/SchemaSettings.d.ts +1 -1
  159. package/es/schema-settings/SchemaSettings.js +54 -30
  160. package/es/schema-settings/VariableInput/hooks/useUserVariable.js +1 -1
  161. package/es/schema-settings/hooks/useIsShowMultipleSwitch.d.ts +4 -0
  162. package/es/schema-settings/hooks/useIsShowMultipleSwitch.js +18 -0
  163. package/es/schema-templates/BlockTemplateDetails.js +1 -1
  164. package/es/settings-form/SettingsForm.js +2 -2
  165. package/es/user/CurrentUser.js +120 -12
  166. package/lib/acl/ACLProvider.js +2 -2
  167. package/lib/acl/Configuration/RoleConfigure.js +15 -8
  168. package/lib/api-client/APIClient.d.ts +2 -0
  169. package/lib/api-client/APIClient.js +11 -0
  170. package/lib/block-provider/BlockProvider.js +57 -16
  171. package/lib/block-provider/hooks/index.js +80 -59
  172. package/lib/collection-manager/CollectionField.js +3 -3
  173. package/lib/collection-manager/CollectionFieldProvider.js +2 -1
  174. package/lib/collection-manager/Configuration/AddFieldAction.js +2 -2
  175. package/lib/collection-manager/Configuration/CollectionFields.d.ts +1 -1
  176. package/lib/collection-manager/Configuration/CollectionFields.js +1 -3
  177. package/lib/collection-manager/Configuration/ConfigurationTabs.js +7 -6
  178. package/lib/collection-manager/hooks/useCollection.d.ts +1 -1
  179. package/lib/collection-manager/hooks/useCollectionDataSource.js +4 -4
  180. package/lib/collection-manager/interfaces/m2m.js +1 -1
  181. package/lib/collection-manager/interfaces/m2o.js +1 -1
  182. package/lib/collection-manager/interfaces/o2m.js +1 -1
  183. package/lib/collection-manager/interfaces/o2o.js +2 -2
  184. package/lib/collection-manager/templates/expression.js +1 -1
  185. package/lib/filter-provider/utils.js +1 -1
  186. package/lib/index.d.ts +1 -0
  187. package/lib/index.js +11 -0
  188. package/lib/locale/en_US.d.ts +16 -1
  189. package/lib/locale/en_US.js +17 -2
  190. package/lib/locale/es_ES.d.ts +692 -0
  191. package/lib/locale/es_ES.js +698 -0
  192. package/lib/locale/ja_JP.d.ts +5 -1
  193. package/lib/locale/ja_JP.js +6 -2
  194. package/lib/locale/pt_BR.d.ts +5 -1
  195. package/lib/locale/pt_BR.js +6 -2
  196. package/lib/locale/ru_RU.d.ts +5 -1
  197. package/lib/locale/ru_RU.js +6 -2
  198. package/lib/locale/tr_TR.d.ts +5 -1
  199. package/lib/locale/tr_TR.js +6 -2
  200. package/lib/locale/zh_CN.d.ts +25 -2
  201. package/lib/locale/zh_CN.js +26 -3
  202. package/lib/pm/PluginManagerLink.js +21 -13
  203. package/lib/record-provider/index.d.ts +4 -0
  204. package/lib/record-provider/index.js +5 -1
  205. package/lib/schema-component/antd/action/Action.Designer.js +6 -3
  206. package/lib/schema-component/antd/action/Action.Drawer.js +5 -2
  207. package/lib/schema-component/antd/action/Action.js +2 -2
  208. package/lib/schema-component/antd/action/ActionBar.js +23 -16
  209. package/lib/schema-component/antd/association-field/AssociationFieldProvider.d.ts +2 -2
  210. package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +62 -8
  211. package/lib/schema-component/antd/association-field/AssociationSelect.js +9 -66
  212. package/lib/schema-component/antd/association-field/Editable.d.ts +1 -1
  213. package/lib/schema-component/antd/association-field/Editable.js +33 -42
  214. package/lib/schema-component/antd/association-field/InternalNester.js +2 -2
  215. package/lib/schema-component/antd/association-field/InternalPicker.js +25 -56
  216. package/lib/schema-component/antd/association-field/InternalViewer.js +7 -10
  217. package/lib/schema-component/antd/association-field/Nester.js +19 -21
  218. package/lib/schema-component/antd/association-field/ReadPretty.d.ts +1 -1
  219. package/lib/schema-component/antd/association-field/ReadPretty.js +10 -27
  220. package/lib/schema-component/antd/association-field/components/CreateRecordAction.d.ts +2 -0
  221. package/lib/schema-component/antd/association-field/components/CreateRecordAction.js +71 -0
  222. package/lib/schema-component/antd/association-field/context.d.ts +5 -2
  223. package/lib/schema-component/antd/association-field/context.js +1 -1
  224. package/lib/schema-component/antd/association-field/hooks.d.ts +3 -0
  225. package/lib/schema-component/antd/association-field/hooks.js +10 -10
  226. package/lib/schema-component/antd/association-filter/AssociationFilter.Item.js +3 -3
  227. package/lib/schema-component/antd/association-select/AssociationSelect.js +49 -231
  228. package/lib/schema-component/antd/association-select/useServiceOptions.js +2 -2
  229. package/lib/schema-component/antd/collection-select/CollectionSelect.js +5 -0
  230. package/lib/schema-component/antd/filter/FilterAction.js +2 -2
  231. package/lib/schema-component/antd/form/Form.js +4 -4
  232. package/lib/schema-component/antd/form-item/FormItem.js +122 -141
  233. package/lib/schema-component/antd/form-item/SchemaSettingOptions.js +3 -3
  234. package/lib/schema-component/antd/form-v2/Form.Designer.js +1 -0
  235. package/lib/schema-component/antd/form-v2/Templates.d.ts +20 -0
  236. package/lib/schema-component/antd/form-v2/Templates.js +41 -11
  237. package/lib/schema-component/antd/grid/Grid.js +33 -23
  238. package/lib/schema-component/antd/grid-card/GridCard.Decorator.d.ts +5 -0
  239. package/lib/schema-component/antd/grid-card/GridCard.Decorator.js +77 -0
  240. package/lib/schema-component/antd/grid-card/GridCard.Designer.d.ts +1 -0
  241. package/lib/schema-component/antd/grid-card/GridCard.Designer.js +253 -0
  242. package/lib/schema-component/antd/grid-card/GridCard.Item.d.ts +1 -0
  243. package/lib/schema-component/antd/grid-card/GridCard.Item.js +26 -0
  244. package/lib/schema-component/antd/grid-card/GridCard.d.ts +8 -0
  245. package/lib/schema-component/antd/grid-card/GridCard.js +112 -0
  246. package/lib/schema-component/antd/grid-card/hooks.d.ts +4 -0
  247. package/lib/schema-component/antd/grid-card/hooks.js +16 -0
  248. package/lib/schema-component/antd/grid-card/index.d.ts +1 -0
  249. package/lib/schema-component/antd/grid-card/index.js +16 -0
  250. package/lib/schema-component/antd/grid-card/options.d.ts +20 -0
  251. package/lib/schema-component/antd/grid-card/options.js +31 -0
  252. package/lib/schema-component/antd/icon-picker/IconPicker.js +2 -2
  253. package/lib/schema-component/antd/index.d.ts +2 -0
  254. package/lib/schema-component/antd/index.js +22 -0
  255. package/lib/schema-component/antd/input/EllipsisWithTooltip.js +2 -2
  256. package/lib/schema-component/antd/list/List.Decorator.d.ts +5 -0
  257. package/lib/schema-component/antd/list/List.Decorator.js +71 -0
  258. package/lib/schema-component/antd/list/List.Designer.d.ts +1 -0
  259. package/lib/schema-component/antd/list/List.Designer.js +213 -0
  260. package/lib/schema-component/antd/list/List.Item.d.ts +1 -0
  261. package/lib/schema-component/antd/list/List.Item.js +23 -0
  262. package/lib/schema-component/antd/list/List.d.ts +8 -0
  263. package/lib/schema-component/antd/list/List.js +92 -0
  264. package/lib/schema-component/antd/list/hooks.d.ts +4 -0
  265. package/lib/schema-component/antd/list/hooks.js +16 -0
  266. package/lib/schema-component/antd/list/index.d.ts +1 -0
  267. package/lib/schema-component/antd/list/index.js +16 -0
  268. package/lib/schema-component/antd/remote-select/RemoteSelect.js +11 -9
  269. package/lib/schema-component/antd/select/Select.js +14 -3
  270. package/lib/schema-component/antd/table/Table.Void.Designer.js +1 -0
  271. package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +2 -1
  272. package/lib/schema-component/antd/table-v2/TableSelectorDesigner.js +1 -0
  273. package/lib/schema-component/antd/table-v2/hooks/useUserVariable.d.ts +22 -0
  274. package/lib/schema-component/antd/table-v2/hooks/useUserVariable.js +73 -0
  275. package/lib/schema-component/antd/variable/Input.js +6 -3
  276. package/lib/schema-component/common/dnd-context/index.js +2 -2
  277. package/lib/schema-component/common/sortable-item/SortableItem.js +3 -4
  278. package/lib/schema-component/core/SchemaComponentProvider.js +2 -2
  279. package/lib/schema-initializer/SchemaInitializerProvider.d.ts +1 -0
  280. package/lib/schema-initializer/SchemaInitializerProvider.js +22 -9
  281. package/lib/schema-initializer/buttons/BlockInitializers.js +10 -0
  282. package/lib/schema-initializer/buttons/CustomFormItemInitializers.js +4 -2
  283. package/lib/schema-initializer/buttons/FormActionInitializers.d.ts +0 -116
  284. package/lib/schema-initializer/buttons/FormActionInitializers.js +106 -100
  285. package/lib/schema-initializer/buttons/GanttActionInitializers.d.ts +0 -19
  286. package/lib/schema-initializer/buttons/GridCardActionInitializers.d.ts +195 -0
  287. package/lib/schema-initializer/buttons/GridCardActionInitializers.js +285 -0
  288. package/lib/schema-initializer/buttons/ListActionInitializers.d.ts +195 -0
  289. package/lib/schema-initializer/buttons/ListActionInitializers.js +285 -0
  290. package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
  291. package/lib/schema-initializer/buttons/TableActionInitializers.d.ts +0 -20
  292. package/lib/schema-initializer/buttons/TableActionInitializers.js +29 -35
  293. package/lib/schema-initializer/buttons/TableColumnInitializers.js +4 -1
  294. package/lib/schema-initializer/buttons/index.d.ts +3 -0
  295. package/lib/schema-initializer/buttons/index.js +22 -0
  296. package/lib/schema-initializer/components/BulkEditField.js +7 -5
  297. package/lib/schema-initializer/components/CreateRecordAction.d.ts +1 -0
  298. package/lib/schema-initializer/components/CreateRecordAction.js +54 -32
  299. package/lib/schema-initializer/components/DeletedField.d.ts +1 -0
  300. package/lib/schema-initializer/components/DeletedField.js +19 -0
  301. package/lib/schema-initializer/components/assigned-field/AssignedField.js +34 -22
  302. package/lib/schema-initializer/items/GridCardBlockInitializer.d.ts +1 -0
  303. package/lib/schema-initializer/items/GridCardBlockInitializer.js +55 -0
  304. package/lib/schema-initializer/items/ListBlockInitializer.d.ts +1 -0
  305. package/lib/schema-initializer/items/ListBlockInitializer.js +55 -0
  306. package/lib/schema-initializer/items/index.d.ts +3 -1
  307. package/lib/schema-initializer/items/index.js +33 -11
  308. package/lib/schema-initializer/utils.d.ts +112 -0
  309. package/lib/schema-initializer/utils.js +209 -33
  310. package/lib/schema-items/GeneralSchemaItems.d.ts +4 -0
  311. package/lib/schema-items/GeneralSchemaItems.js +156 -0
  312. package/lib/schema-items/index.d.ts +1 -0
  313. package/lib/schema-items/index.js +11 -0
  314. package/lib/schema-settings/DataTemplates/FormDataTemplates.d.ts +1 -0
  315. package/lib/schema-settings/DataTemplates/FormDataTemplates.js +119 -41
  316. package/lib/schema-settings/DataTemplates/components/AsDefaultTemplate.js +1 -1
  317. package/lib/schema-settings/DataTemplates/components/DataTemplateTitle.js +10 -14
  318. package/lib/schema-settings/DataTemplates/components/Designer.d.ts +7 -0
  319. package/lib/schema-settings/DataTemplates/components/Designer.js +188 -0
  320. package/lib/schema-settings/DataTemplates/hooks/useCollectionState.d.ts +6 -1
  321. package/lib/schema-settings/DataTemplates/hooks/useCollectionState.js +204 -95
  322. package/lib/schema-settings/GeneralSchemaDesigner.js +21 -15
  323. package/lib/schema-settings/SchemaSettings.d.ts +1 -1
  324. package/lib/schema-settings/SchemaSettings.js +53 -29
  325. package/lib/schema-settings/VariableInput/hooks/useUserVariable.js +1 -1
  326. package/lib/schema-settings/hooks/useIsShowMultipleSwitch.d.ts +4 -0
  327. package/lib/schema-settings/hooks/useIsShowMultipleSwitch.js +24 -0
  328. package/lib/settings-form/SettingsForm.js +2 -2
  329. package/lib/user/CurrentUser.js +118 -10
  330. package/package.json +5 -5
  331. package/tsconfig.json +8 -0
@@ -1,19 +1,72 @@
1
- import { useField, useFieldSchema } from '@formily/react';
2
- import React, { useMemo } from 'react';
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 { observer, useField, useFieldSchema } from '@formily/react';
8
+ import React, { useEffect, useMemo, useState } from 'react';
3
9
  import { useCollectionManager } from '../../../collection-manager';
4
10
  import { AssociationFieldContext } from './context';
5
- export function AssociationFieldProvider(props) {
11
+ export var AssociationFieldProvider = observer(function (props) {
12
+ var _fieldSchema$xCompon, _fieldSchema$xCompon2, _fieldSchema$xCompon4;
6
13
  var field = useField();
7
14
  var _useCollectionManager = useCollectionManager(),
8
- getCollectionField = _useCollectionManager.getCollectionField;
15
+ getCollectionJoinField = _useCollectionManager.getCollectionJoinField,
16
+ getCollection = _useCollectionManager.getCollection;
9
17
  var fieldSchema = useFieldSchema();
18
+ var allowMultiple = ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.multiple) !== false;
19
+ var allowDissociate = ((_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.allowDissociate) !== false;
10
20
  var collectionField = useMemo(function () {
11
- return getCollectionField(fieldSchema['x-collection-field']);
21
+ return getCollectionJoinField(fieldSchema['x-collection-field']);
22
+ }, [fieldSchema['x-collection-field'], fieldSchema.name]);
23
+ var isFileCollection = useMemo(function () {
24
+ var _getCollection;
25
+ return ((_getCollection = getCollection(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target)) === null || _getCollection === void 0 ? void 0 : _getCollection.template) === 'file';
12
26
  }, [fieldSchema['x-collection-field']]);
13
- return /*#__PURE__*/React.createElement(AssociationFieldContext.Provider, {
27
+ var currentMode = useMemo(function () {
28
+ var _fieldSchema$xCompon3;
29
+ return ((_fieldSchema$xCompon3 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : _fieldSchema$xCompon3.mode) || (isFileCollection ? 'FileManager' : 'Select');
30
+ }, [(_fieldSchema$xCompon4 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.mode]);
31
+ var _useState = useState(true),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ loading = _useState2[0],
34
+ setLoading = _useState2[1];
35
+ useEffect(function () {
36
+ setLoading(true);
37
+ if (!collectionField) {
38
+ setLoading(false);
39
+ return;
40
+ }
41
+ if (field.value !== null && field.value !== undefined) {
42
+ // Nester 子表单时,如果没数据初始化一个 [null] 的占位
43
+ if (currentMode === 'Nester' && Array.isArray(field.value)) {
44
+ if (field.value.length === 0 && ['belongsToMany', 'hasMany'].includes(collectionField.type)) {
45
+ field.value = [null];
46
+ }
47
+ }
48
+ setLoading(false);
49
+ return;
50
+ }
51
+ if (currentMode === 'Nester') {
52
+ if (['belongsTo', 'hasOne'].includes(collectionField.type)) {
53
+ field.value = {};
54
+ } else if (['belongsToMany', 'hasMany'].includes(collectionField.type)) {
55
+ field.value = [null];
56
+ }
57
+ }
58
+ setLoading(false);
59
+ }, [currentMode, collectionField, field.value]);
60
+ if (loading) {
61
+ return null;
62
+ }
63
+ return collectionField ? /*#__PURE__*/React.createElement(AssociationFieldContext.Provider, {
14
64
  value: {
15
65
  options: collectionField,
16
- field: field
66
+ field: field,
67
+ allowMultiple: allowMultiple,
68
+ allowDissociate: allowDissociate,
69
+ currentMode: currentMode
17
70
  }
18
- }, props.children);
19
- }
71
+ }, props.children) : null;
72
+ });
@@ -1,64 +1,24 @@
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); }
1
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; }
2
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; }
3
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; }
4
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
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); }
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
7
  import { LoadingOutlined } from '@ant-design/icons';
14
8
  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';
9
+ import { Input } from 'antd';
10
+ import React from 'react';
21
11
  import { RemoteSelect } from '../remote-select';
22
- import useServiceOptions, { useInsertSchema } from './hooks';
23
- import schema from './schema';
12
+ import useServiceOptions from './hooks';
24
13
  var InternalAssociationSelect = observer(function (props) {
25
14
  var fieldNames = props.fieldNames,
26
15
  _props$objectValue = props.objectValue,
27
16
  objectValue = _props$objectValue === void 0 ? true : _props$objectValue;
28
17
  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
18
  var fieldSchema = useFieldSchema();
38
- var isFilterForm = fieldSchema['x-designer'] === 'FormItem.FilterFormDesigner';
19
+ var service = useServiceOptions(props);
39
20
  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
- }, []);
21
+ var value = Array.isArray(props.value) ? props.value.filter(Boolean) : props.value;
62
22
  return /*#__PURE__*/React.createElement("div", {
63
23
  key: fieldSchema.name
64
24
  }, /*#__PURE__*/React.createElement(Input.Group, {
@@ -74,34 +34,19 @@ var InternalAssociationSelect = observer(function (props) {
74
34
  objectValue: objectValue,
75
35
  value: value,
76
36
  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, {
37
+ })), isAllowAddNew && /*#__PURE__*/React.createElement(RecursionField, {
92
38
  onlyRenderProperties: true,
93
39
  basePath: field.address,
94
40
  schema: fieldSchema,
95
41
  filterProperties: function filterProperties(s) {
96
- return s['x-component'] === 'AssociationField.AddNewer';
42
+ return s['x-component'] === 'Action';
97
43
  }
98
- }))));
44
+ })));
99
45
  });
100
46
  export var AssociationSelect = InternalAssociationSelect;
101
47
  export var AssociationSelectReadPretty = connect(function (props) {
48
+ var service = useServiceOptions(props);
102
49
  if (props.fieldNames) {
103
- var service = useServiceOptions(props);
104
- useFieldTitle();
105
50
  return /*#__PURE__*/React.createElement(RemoteSelect.ReadPretty, _objectSpread(_objectSpread({}, props), {}, {
106
51
  service: service
107
52
  }));
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const Editable: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
2
+ export declare const Editable: React.MemoExoticComponent<React.FunctionComponent<unknown>>;
@@ -7,42 +7,26 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
7
7
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
8
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
9
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
10
  import { observer, useField, useFieldSchema, useForm } from '@formily/react';
17
- import React, { useEffect, useState } from 'react';
11
+ import React from 'react';
12
+ import { SchemaComponentOptions } from '../../';
13
+ import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
18
14
  import { AssociationFieldProvider } from './AssociationFieldProvider';
15
+ import { AssociationSelect } from './AssociationSelect';
16
+ import { InternalFileManager } from './FileManager';
19
17
  import { InternalNester } from './InternalNester';
20
18
  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
19
  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]);
20
+ import { CreateRecordAction } from './components/CreateRecordAction';
21
+ import { useAssociationFieldContext } from './hooks';
22
+ var EditableAssociationField = observer(function (props) {
32
23
  var multiple = props.multiple;
33
24
  var field = useField();
34
25
  var form = useForm();
35
26
  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];
27
+ var _useAssociationFieldC = useAssociationFieldContext(),
28
+ collectionField = _useAssociationFieldC.options,
29
+ currentMode = _useAssociationFieldC.currentMode;
46
30
  var useCreateActionProps = function useCreateActionProps() {
47
31
  var _useCAP = useCAP(),
48
32
  _onClick = _useCAP.onClick;
@@ -59,17 +43,19 @@ export var Editable = observer(function (props) {
59
43
  return _onClick();
60
44
  case 2:
61
45
  _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);
46
+ if (data) {
47
+ if (['m2m', 'o2m'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) && multiple !== false) {
48
+ values = JSON.parse(JSON.stringify(form.values[fieldSchema.name] || []));
49
+ values.push(_objectSpread({}, data));
50
+ setTimeout(function () {
51
+ form.setValuesIn(field.props.name, values);
52
+ }, 100);
53
+ } else {
54
+ value = _objectSpread({}, data);
55
+ setTimeout(function () {
56
+ form.setValuesIn(field.props.name, value);
57
+ }, 100);
58
+ }
73
59
  }
74
60
  case 4:
75
61
  case "end":
@@ -80,9 +66,15 @@ export var Editable = observer(function (props) {
80
66
  }
81
67
  };
82
68
  };
83
- return /*#__PURE__*/React.createElement(AssociationFieldProvider, null, /*#__PURE__*/React.createElement(SchemaComponentOptions, {
69
+ return /*#__PURE__*/React.createElement(SchemaComponentOptions, {
84
70
  scope: {
85
71
  useCreateActionProps: useCreateActionProps
72
+ },
73
+ components: {
74
+ CreateRecordAction: CreateRecordAction
86
75
  }
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))));
76
+ }, 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)));
77
+ });
78
+ export var Editable = observer(function (props) {
79
+ return /*#__PURE__*/React.createElement(AssociationFieldProvider, null, /*#__PURE__*/React.createElement(EditableAssociationField, _objectSpread({}, props)));
88
80
  });
@@ -2,19 +2,20 @@ import { FormLayout } from '@formily/antd';
2
2
  import { RecursionField, useField, useFieldSchema } from '@formily/react';
3
3
  import React, { useEffect } from 'react';
4
4
  import { CollectionProvider } from '../../../collection-manager';
5
- import { useAssociationFieldContext, useInsertSchema } from './hooks';
5
+ import { useInsertSchema } from './hooks';
6
+ import { useAssociationFieldContext } from './hooks';
6
7
  import schema from './schema';
7
8
  export var InternalNester = function InternalNester() {
8
9
  var field = useField();
9
10
  var fieldSchema = useFieldSchema();
10
11
  var insertNester = useInsertSchema('Nester');
11
12
  var _useAssociationFieldC = useAssociationFieldContext(),
12
- options = _useAssociationFieldC.options;
13
+ collectionField = _useAssociationFieldC.options;
13
14
  useEffect(function () {
14
15
  insertNester(schema.Nester);
15
16
  }, []);
16
17
  return /*#__PURE__*/React.createElement(CollectionProvider, {
17
- name: options.target
18
+ name: collectionField.target
18
19
  }, /*#__PURE__*/React.createElement(FormLayout, {
19
20
  layout: 'vertical'
20
21
  }, /*#__PURE__*/React.createElement(RecursionField, {
@@ -15,16 +15,15 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
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
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
17
  import { RecursionField, observer, useField, useFieldSchema } from '@formily/react';
18
- import { Button, Input, Select } from 'antd';
18
+ import { Input, Select } from 'antd';
19
19
  import { differenceBy, unionBy } from 'lodash';
20
- import React, { useContext, useEffect, useState } from 'react';
21
- import { useTranslation } from 'react-i18next';
20
+ import React, { useContext, useMemo, useState } from 'react';
22
21
  import { FormProvider, RecordPickerContext, RecordPickerProvider, SchemaComponentOptions, useActionContext } from '../..';
23
22
  import { TableSelectorParamsProvider, useTableSelectorProps as useTsp } from '../../../block-provider/TableSelectorProvider';
24
- import { CollectionProvider, useCollection } from '../../../collection-manager';
23
+ import { CollectionProvider } from '../../../collection-manager';
25
24
  import { useCompile } from '../../hooks';
26
25
  import { ActionContext } from '../action';
27
- import { useFieldNames, useInsertSchema } from './hooks';
26
+ import { useAssociationFieldContext, useFieldNames, useInsertSchema } from './hooks';
28
27
  import schema from './schema';
29
28
  import { flatData, getLabelFormatValue, useLabelUiSchema } from './util';
30
29
  var useTableSelectorProps = function useTableSelectorProps() {
@@ -87,35 +86,29 @@ export var InternalPicker = observer(function (props) {
87
86
  var fieldNames = useFieldNames(props);
88
87
  var _useState = useState(false),
89
88
  _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];
89
+ visibleSelector = _useState2[0],
90
+ setVisibleSelector = _useState2[1];
96
91
  var fieldSchema = useFieldSchema();
97
- var insertAddNewer = useInsertSchema('AddNewer');
98
92
  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
- };
93
+ var _useAssociationFieldC = useAssociationFieldContext(),
94
+ collectionField = _useAssociationFieldC.options;
108
95
  var compile = useCompile();
109
96
  var labelUiSchema = useLabelUiSchema(collectionField, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label');
110
97
  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];
98
+ var _useState3 = useState([]),
99
+ _useState4 = _slicedToArray(_useState3, 2),
100
+ selectedRows = _useState4[0],
101
+ setSelectedRows = _useState4[1];
102
+ var options = useMemo(function () {
103
+ if (value && Object.keys(value).length > 0) {
104
+ var opts = (Array.isArray(value) ? value : value ? [value] : []).filter(Boolean).map(function (option) {
105
+ var label = option === null || option === void 0 ? void 0 : option[fieldNames.label];
106
+ return _objectSpread(_objectSpread({}, option), {}, _defineProperty({}, fieldNames.label, getLabelFormatValue(compile(labelUiSchema), compile(label))));
107
+ });
108
+ return opts;
109
+ }
110
+ return [];
111
+ }, [value, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label]);
119
112
  var pickerProps = {
120
113
  size: 'small',
121
114
  fieldNames: fieldNames,
@@ -129,19 +122,11 @@ export var InternalPicker = observer(function (props) {
129
122
  setSelectedRows: setSelectedRows,
130
123
  collectionField: collectionField
131
124
  };
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
125
  var getValue = function getValue() {
126
+ var _value$filter;
142
127
  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];
128
+ return Array.isArray(value) ? (_value$filter = value.filter(Boolean)) === null || _value$filter === void 0 ? void 0 : _value$filter.map(function (v) {
129
+ return v === null || v === void 0 ? void 0 : v[fieldNames.value];
145
130
  }) : value === null || value === void 0 ? void 0 : value[fieldNames.value];
146
131
  };
147
132
  var getFilter = function getFilter() {
@@ -216,37 +201,21 @@ export var InternalPicker = observer(function (props) {
216
201
  options: options,
217
202
  value: getValue(),
218
203
  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, {
204
+ }))), isAllowAddNew && /*#__PURE__*/React.createElement(RecursionField, {
236
205
  onlyRenderProperties: true,
237
206
  basePath: field.address,
238
207
  schema: fieldSchema,
239
208
  filterProperties: function filterProperties(s) {
240
- return s['x-component'] === 'AssociationField.AddNewer';
209
+ return s['x-component'] === 'Action';
241
210
  }
242
- }))), /*#__PURE__*/React.createElement(ActionContext.Provider, {
211
+ })), /*#__PURE__*/React.createElement(ActionContext.Provider, {
243
212
  value: {
244
213
  openMode: 'drawer',
245
214
  visible: visibleSelector,
246
215
  setVisible: setVisibleSelector
247
216
  }
248
217
  }, /*#__PURE__*/React.createElement(RecordPickerProvider, _objectSpread({}, pickerProps), /*#__PURE__*/React.createElement(CollectionProvider, {
249
- name: collectionField.target
218
+ name: collectionField === null || collectionField === void 0 ? void 0 : collectionField.target
250
219
  }, /*#__PURE__*/React.createElement(FormProvider, null, /*#__PURE__*/React.createElement(TableSelectorParamsProvider, {
251
220
  params: {
252
221
  filter: getFilter()
@@ -8,13 +8,13 @@ import { RecursionField, observer, useField, useFieldSchema } from '@formily/rea
8
8
  import { toArr } from '@formily/shared';
9
9
  import React, { Fragment, useRef, useState } from 'react';
10
10
  import { BlockAssociationContext, WithoutTableFieldResource } from '../../../block-provider';
11
- import { CollectionProvider, useCollection, useCollectionManager } from '../../../collection-manager';
11
+ import { CollectionProvider } from '../../../collection-manager';
12
12
  import { RecordProvider, useRecord } from '../../../record-provider';
13
13
  import { FormProvider } from '../../core';
14
14
  import { useCompile } from '../../hooks';
15
15
  import { ActionContext, useActionContext } from '../action';
16
16
  import { EllipsisWithTooltip } from '../input/EllipsisWithTooltip';
17
- import { useFieldNames, useInsertSchema } from './hooks';
17
+ import { useAssociationFieldContext, useFieldNames, useInsertSchema } from './hooks';
18
18
  import schema from './schema';
19
19
  import { getLabelFormatValue, useLabelUiSchema } from './util';
20
20
  var toValue = function toValue(value, placeholder) {
@@ -28,8 +28,6 @@ export var ReadPrettyInternalViewer = observer(function (props) {
28
28
  var fieldSchema = useFieldSchema();
29
29
  var recordCtx = useRecord();
30
30
  var enableLink = fieldSchema['x-component-props'].enableLink;
31
- var _useCollectionManager = useCollectionManager(),
32
- getCollectionJoinField = _useCollectionManager.getCollectionJoinField;
33
31
  // value 做了转换,但 props.value 和原来 useField().value 的值不一致
34
32
  var field = useField();
35
33
  var fieldNames = useFieldNames(props);
@@ -38,9 +36,8 @@ export var ReadPrettyInternalViewer = observer(function (props) {
38
36
  visible = _useState2[0],
39
37
  setVisible = _useState2[1];
40
38
  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']);
39
+ var _useAssociationFieldC = useAssociationFieldContext(),
40
+ collectionField = _useAssociationFieldC.options;
44
41
  var _useState3 = useState({}),
45
42
  _useState4 = _slicedToArray(_useState3, 2),
46
43
  record = _useState4[0],
@@ -97,10 +94,10 @@ export var ReadPrettyInternalViewer = observer(function (props) {
97
94
  record: record
98
95
  }, renderWithoutTableFieldResourceProvider());
99
96
  };
100
- return collectionField ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BlockAssociationContext.Provider, {
101
- value: "".concat(collectionField.collectionName, ".").concat(collectionField.name)
97
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BlockAssociationContext.Provider, {
98
+ value: "".concat(collectionField === null || collectionField === void 0 ? void 0 : collectionField.collectionName, ".").concat(collectionField === null || collectionField === void 0 ? void 0 : collectionField.name)
102
99
  }, /*#__PURE__*/React.createElement(CollectionProvider, {
103
- name: (_collectionField$targ = collectionField.target) !== null && _collectionField$targ !== void 0 ? _collectionField$targ : collectionField.targetCollection
100
+ name: (_collectionField$targ = collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) !== null && _collectionField$targ !== void 0 ? _collectionField$targ : collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetCollection
104
101
  }, /*#__PURE__*/React.createElement(EllipsisWithTooltip, {
105
102
  ellipsis: true,
106
103
  ref: ellipsisWithTooltipRef
@@ -109,7 +106,7 @@ export var ReadPrettyInternalViewer = observer(function (props) {
109
106
  visible: visible,
110
107
  setVisible: setVisible,
111
108
  openMode: 'drawer',
112
- snapshot: collectionField.interface === 'snapshot'
109
+ snapshot: (collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) === 'snapshot'
113
110
  }
114
- }, renderRecordProvider())))) : null;
111
+ }, renderRecordProvider()))));
115
112
  });
@@ -4,14 +4,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
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
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
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 { CloseCircleOutlined } from '@ant-design/icons';
7
8
  import { RecursionField, observer, useFieldSchema } from '@formily/react';
8
9
  import { Button, Card, Divider } from 'antd';
9
- import { CloseCircleOutlined } from '@ant-design/icons';
10
10
  import React, { useContext } from 'react';
11
+ import { useTranslation } from 'react-i18next';
11
12
  import { AssociationFieldContext } from './context';
12
13
  import { useAssociationFieldContext } from './hooks';
13
- import { useTranslation } from 'react-i18next';
14
- // import { useRemoveActionProps } from '../../../block-provider/hooks';
15
14
  export var Nester = function Nester(props) {
16
15
  var _useContext = useContext(AssociationFieldContext),
17
16
  options = _useContext.options;
@@ -28,30 +27,26 @@ var ToOneNester = function ToOneNester(props) {
28
27
  bordered: true
29
28
  }, props.children);
30
29
  };
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
30
  var ToManyNester = observer(function (props) {
41
31
  var fieldSchema = useFieldSchema();
42
32
  var _useAssociationFieldC = useAssociationFieldContext(),
43
- field = _useAssociationFieldC.field;
44
- var values = toArr(field.value);
33
+ options = _useAssociationFieldC.options,
34
+ field = _useAssociationFieldC.field,
35
+ allowMultiple = _useAssociationFieldC.allowMultiple,
36
+ allowDissociate = _useAssociationFieldC.allowDissociate;
45
37
  var _useTranslation = useTranslation(),
46
38
  t = _useTranslation.t;
47
- // const { onClick } = useRemoveActionProps(`${collectionField.collectionName}.${collectionField.target}`);
48
39
  return /*#__PURE__*/React.createElement(Card, {
49
40
  bordered: true,
50
41
  style: {
51
42
  position: 'relative'
52
43
  }
53
- }, values.map(function (value, index) {
54
- return /*#__PURE__*/React.createElement(React.Fragment, null, !field.readPretty && /*#__PURE__*/React.createElement("div", {
44
+ }, (field.value || []).map(function (value, index) {
45
+ var allowed = allowDissociate;
46
+ if (!allowDissociate) {
47
+ allowed = !(value === null || value === void 0 ? void 0 : value[options.targetKey]);
48
+ }
49
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !field.readPretty && allowed && /*#__PURE__*/React.createElement("div", {
55
50
  style: {
56
51
  textAlign: 'right'
57
52
  }
@@ -62,19 +57,22 @@ var ToManyNester = observer(function (props) {
62
57
  color: '#a8a3a3'
63
58
  },
64
59
  onClick: function onClick() {
65
- field.value.splice(index, 1);
60
+ var result = field.value;
61
+ result.splice(index, 1);
62
+ field.value = result;
66
63
  }
67
64
  })), /*#__PURE__*/React.createElement(RecursionField, {
68
65
  onlyRenderProperties: true,
69
66
  basePath: field.address.concat(index),
70
67
  schema: fieldSchema
71
68
  }), /*#__PURE__*/React.createElement(Divider, null));
72
- }), field.editable && /*#__PURE__*/React.createElement(Button, {
69
+ }), field.editable && allowMultiple && /*#__PURE__*/React.createElement(Button, {
73
70
  type: 'dashed',
74
71
  block: true,
75
72
  onClick: function onClick() {
76
- field.value = field.value || [];
77
- field.value.push({});
73
+ var result = field.value;
74
+ result.push({});
75
+ field.value = result;
78
76
  }
79
77
  }, t('Add new')));
80
78
  });
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const ReadPretty: React.MemoExoticComponent<React.FunctionComponent<Pick<any, string | number | symbol>>>;
2
+ export declare const ReadPretty: React.MemoExoticComponent<React.FunctionComponent<unknown>>;