@nocobase/client 0.9.0-alpha.2 → 0.9.1-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 (327) hide show
  1. package/es/acl/ACLProvider.js +7 -8
  2. package/es/api-client/APIClient.js +6 -0
  3. package/es/block-provider/BlockProvider.js +9 -6
  4. package/es/block-provider/FormBlockProvider.js +18 -9
  5. package/es/block-provider/KanbanBlockProvider.js +1 -1
  6. package/es/block-provider/SharedFilterProvider.js +9 -1
  7. package/es/block-provider/TableBlockProvider.js +1 -1
  8. package/es/block-provider/TableSelectorProvider.js +2 -2
  9. package/es/block-provider/hooks/index.js +22 -7
  10. package/es/collection-manager/CollectionManagerProvider.d.ts +1 -0
  11. package/es/collection-manager/CollectionManagerProvider.js +71 -9
  12. package/es/collection-manager/CollectionManagerShortcut.js +36 -23
  13. package/es/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
  14. package/es/collection-manager/Configuration/AddCategoryAction.js +117 -0
  15. package/es/collection-manager/Configuration/AddCollectionAction.js +8 -3
  16. package/es/collection-manager/Configuration/AddFieldAction.js +1 -0
  17. package/es/collection-manager/Configuration/ConfigurationTable.js +33 -4
  18. package/es/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
  19. package/es/collection-manager/Configuration/ConfigurationTabs.js +381 -0
  20. package/es/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
  21. package/es/collection-manager/Configuration/EditCategoryAction.js +150 -0
  22. package/es/collection-manager/Configuration/EditCollectionAction.js +6 -2
  23. package/es/collection-manager/Configuration/OverridingCollectionField.js +17 -8
  24. package/es/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
  25. package/es/collection-manager/Configuration/components/CollectionCategory.js +13 -0
  26. package/es/collection-manager/Configuration/index.d.ts +3 -0
  27. package/es/collection-manager/Configuration/index.js +3 -0
  28. package/es/collection-manager/Configuration/schemas/collections.d.ts +3 -0
  29. package/es/collection-manager/Configuration/schemas/collections.js +309 -176
  30. package/es/collection-manager/Configuration/templates.d.ts +1 -0
  31. package/es/collection-manager/Configuration/templates.js +1 -1
  32. package/es/collection-manager/action-hooks.d.ts +4 -0
  33. package/es/collection-manager/action-hooks.js +26 -12
  34. package/es/collection-manager/context.d.ts +4 -0
  35. package/es/collection-manager/context.js +5 -1
  36. package/es/collection-manager/hooks/useCollectionManager.d.ts +7 -0
  37. package/es/collection-manager/hooks/useCollectionManager.js +52 -7
  38. package/es/collection-manager/interfaces/m2m.js +2 -2
  39. package/es/collection-manager/interfaces/properties/index.d.ts +0 -56
  40. package/es/collection-manager/interfaces/properties/index.js +1 -2
  41. package/es/collection-manager/templates/calendar.js +1 -1
  42. package/es/collection-manager/templates/general.js +1 -1
  43. package/es/collection-manager/templates/properties/index.d.ts +12 -1
  44. package/es/collection-manager/templates/properties/index.js +11 -0
  45. package/es/i18n/i18n.js +3 -1
  46. package/es/locale/en_US.d.ts +23 -0
  47. package/es/locale/en_US.js +23 -0
  48. package/es/locale/ja_JP.d.ts +23 -0
  49. package/es/locale/ja_JP.js +24 -1
  50. package/es/locale/ru_RU.d.ts +1 -0
  51. package/es/locale/ru_RU.js +1 -0
  52. package/es/locale/zh_CN.d.ts +43 -4
  53. package/es/locale/zh_CN.js +44 -5
  54. package/es/route-switch/antd/admin-layout/index.js +13 -33
  55. package/es/schema-component/antd/action/Action.Designer.js +28 -15
  56. package/es/schema-component/antd/action/Action.js +28 -5
  57. package/es/schema-component/antd/action/utils.d.ts +1 -0
  58. package/es/schema-component/antd/action/utils.js +49 -0
  59. package/es/schema-component/antd/association-filter/AssociationFilter.js +4 -4
  60. package/es/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
  61. package/es/schema-component/antd/association-select/useServiceOptions.js +47 -6
  62. package/es/schema-component/antd/calendar/Calendar.Designer.js +17 -36
  63. package/es/schema-component/antd/checkbox/Checkbox.js +9 -8
  64. package/es/schema-component/antd/date-picker/util.d.ts +1 -1
  65. package/es/schema-component/antd/date-picker/util.js +1 -1
  66. package/es/schema-component/antd/filter/DynamicComponent.js +3 -1
  67. package/es/schema-component/antd/filter/Filter.js +2 -1
  68. package/es/schema-component/antd/filter/FilterGroup.js +7 -4
  69. package/es/schema-component/antd/filter/FilterItem.js +3 -2
  70. package/es/schema-component/antd/filter/context.d.ts +1 -0
  71. package/es/schema-component/antd/filter/useValues.js +14 -11
  72. package/es/schema-component/antd/form/Form.js +11 -5
  73. package/es/schema-component/antd/form-item/FormItem.js +17 -8
  74. package/es/schema-component/antd/form-v2/Form.Designer.js +2 -0
  75. package/es/schema-component/antd/form-v2/Form.js +94 -7
  76. package/es/schema-component/antd/form-v2/utils.d.ts +5 -0
  77. package/es/schema-component/antd/form-v2/utils.js +161 -0
  78. package/es/schema-component/antd/g2plot/G2Plot.js +3 -1
  79. package/es/schema-component/antd/grid/Grid.js +10 -5
  80. package/es/schema-component/antd/icon-picker/IconPicker.js +1 -0
  81. package/es/schema-component/antd/index.d.ts +1 -0
  82. package/es/schema-component/antd/index.js +1 -0
  83. package/es/schema-component/antd/input/Input.d.ts +2 -1
  84. package/es/schema-component/antd/input/Json.d.ts +5 -3
  85. package/es/schema-component/antd/input/Json.js +3 -2
  86. package/es/schema-component/antd/input/ReadPretty.js +1 -1
  87. package/es/schema-component/antd/input-number/InputNumber.js +3 -1
  88. package/es/schema-component/antd/page/FixedBlock.js +3 -1
  89. package/es/schema-component/antd/page/Page.js +11 -5
  90. package/es/schema-component/antd/page/PageTabDesigner.js +3 -3
  91. package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
  92. package/es/schema-component/antd/record-picker/RecordPicker.js +1 -2
  93. package/es/schema-component/antd/record-picker/util.js +7 -0
  94. package/es/schema-component/antd/remote-select/RemoteSelect.d.ts +2 -0
  95. package/es/schema-component/antd/remote-select/RemoteSelect.js +78 -36
  96. package/es/schema-component/antd/rich-text/RichText.js +4 -2
  97. package/es/schema-component/antd/select/Select.js +14 -4
  98. package/es/schema-component/antd/table/Table.Array.js +10 -3
  99. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
  100. package/es/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
  101. package/es/schema-component/antd/tabs/Tabs.Designer.js +1 -0
  102. package/es/schema-component/antd/tabs/Tabs.js +1 -0
  103. package/es/schema-component/antd/time-picker/TimePicker.js +1 -1
  104. package/es/schema-component/antd/variable/Input.d.ts +2 -0
  105. package/es/schema-component/antd/variable/Input.js +244 -0
  106. package/es/schema-component/antd/variable/JSONInput.d.ts +2 -0
  107. package/es/schema-component/antd/variable/JSONInput.js +82 -0
  108. package/es/schema-component/antd/variable/TextArea.d.ts +2 -0
  109. package/es/schema-component/antd/variable/TextArea.js +322 -0
  110. package/es/schema-component/antd/variable/Variable.d.ts +8 -0
  111. package/es/schema-component/antd/variable/Variable.js +11 -0
  112. package/es/schema-component/antd/variable/index.d.ts +1 -0
  113. package/es/schema-component/antd/variable/index.js +1 -0
  114. package/es/schema-component/common/sortable-item/SortableItem.js +36 -6
  115. package/es/schema-component/common/utils/logic.js +523 -0
  116. package/es/schema-component/common/utils/uitls.d.ts +1 -0
  117. package/es/schema-component/common/utils/uitls.js +89 -0
  118. package/es/schema-initializer/SchemaInitializer.js +9 -4
  119. package/es/schema-initializer/buttons/BlockInitializers.d.ts +2 -184
  120. package/es/schema-initializer/buttons/BlockInitializers.js +1 -102
  121. package/es/schema-initializer/buttons/RecordBlockInitializers.js +72 -16
  122. package/es/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
  123. package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -3
  124. package/es/schema-initializer/components/CreateRecordAction.d.ts +3 -0
  125. package/es/schema-initializer/components/CreateRecordAction.js +174 -0
  126. package/es/schema-initializer/components/index.d.ts +1 -0
  127. package/es/schema-initializer/components/index.js +2 -1
  128. package/es/schema-initializer/index.d.ts +2 -1
  129. package/es/schema-initializer/index.js +2 -1
  130. package/es/schema-initializer/items/CalendarBlockInitializer.js +24 -41
  131. package/es/schema-initializer/items/CreateActionInitializer.js +3 -3
  132. package/es/schema-initializer/items/RecordFormBlockInitializer.js +9 -9
  133. package/es/schema-initializer/items/index.d.ts +4 -4
  134. package/es/schema-initializer/items/index.js +6 -6
  135. package/es/schema-initializer/utils.js +22 -7
  136. package/es/schema-settings/EnableChildCollections/index.d.ts +2 -0
  137. package/es/schema-settings/EnableChildCollections/index.js +141 -0
  138. package/es/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
  139. package/es/schema-settings/LinkageRules/DynamicComponent.js +113 -0
  140. package/es/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
  141. package/es/schema-settings/LinkageRules/FilterDynamicComponent.js +15 -0
  142. package/es/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
  143. package/es/schema-settings/LinkageRules/LinkageRuleAction.js +162 -0
  144. package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
  145. package/es/schema-settings/LinkageRules/LinkageRuleActionGroup.js +71 -0
  146. package/es/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
  147. package/es/schema-settings/LinkageRules/ValueDynamicComponent.js +82 -0
  148. package/es/schema-settings/LinkageRules/Variables.d.ts +7 -0
  149. package/es/schema-settings/LinkageRules/Variables.js +115 -0
  150. package/es/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
  151. package/es/schema-settings/LinkageRules/action-hooks.js +115 -0
  152. package/es/schema-settings/LinkageRules/context.d.ts +13 -0
  153. package/es/schema-settings/LinkageRules/context.js +4 -0
  154. package/es/schema-settings/LinkageRules/index.d.ts +2 -0
  155. package/es/schema-settings/LinkageRules/index.js +132 -0
  156. package/es/schema-settings/LinkageRules/type.d.ts +13 -0
  157. package/es/schema-settings/LinkageRules/type.js +15 -0
  158. package/es/schema-settings/LinkageRules/useValues.d.ts +1 -0
  159. package/es/schema-settings/LinkageRules/useValues.js +84 -0
  160. package/es/schema-settings/SchemaSettings.d.ts +4 -1
  161. package/es/schema-settings/SchemaSettings.js +219 -26
  162. package/es/schema-templates/BlockTemplate.js +9 -1
  163. package/es/system-settings/SystemSettingsShortcut.js +1 -1
  164. package/lib/acl/ACLProvider.js +7 -8
  165. package/lib/api-client/APIClient.js +6 -0
  166. package/lib/block-provider/BlockProvider.js +9 -6
  167. package/lib/block-provider/FormBlockProvider.js +17 -8
  168. package/lib/block-provider/KanbanBlockProvider.js +1 -1
  169. package/lib/block-provider/SharedFilterProvider.js +9 -3
  170. package/lib/block-provider/TableBlockProvider.js +1 -1
  171. package/lib/block-provider/TableSelectorProvider.js +2 -2
  172. package/lib/block-provider/hooks/index.js +23 -7
  173. package/lib/collection-manager/CollectionManagerProvider.d.ts +1 -0
  174. package/lib/collection-manager/CollectionManagerProvider.js +81 -16
  175. package/lib/collection-manager/CollectionManagerShortcut.js +36 -23
  176. package/lib/collection-manager/Configuration/AddCategoryAction.d.ts +2 -0
  177. package/lib/collection-manager/Configuration/AddCategoryAction.js +145 -0
  178. package/lib/collection-manager/Configuration/AddCollectionAction.js +8 -3
  179. package/lib/collection-manager/Configuration/AddFieldAction.js +1 -0
  180. package/lib/collection-manager/Configuration/ConfigurationTable.js +34 -4
  181. package/lib/collection-manager/Configuration/ConfigurationTabs.d.ts +1 -0
  182. package/lib/collection-manager/Configuration/ConfigurationTabs.js +407 -0
  183. package/lib/collection-manager/Configuration/EditCategoryAction.d.ts +2 -0
  184. package/lib/collection-manager/Configuration/EditCategoryAction.js +178 -0
  185. package/lib/collection-manager/Configuration/EditCollectionAction.js +6 -2
  186. package/lib/collection-manager/Configuration/OverridingCollectionField.js +17 -8
  187. package/lib/collection-manager/Configuration/components/CollectionCategory.d.ts +2 -0
  188. package/lib/collection-manager/Configuration/components/CollectionCategory.js +27 -0
  189. package/lib/collection-manager/Configuration/index.d.ts +3 -0
  190. package/lib/collection-manager/Configuration/index.js +39 -0
  191. package/lib/collection-manager/Configuration/schemas/collections.d.ts +3 -0
  192. package/lib/collection-manager/Configuration/schemas/collections.js +316 -178
  193. package/lib/collection-manager/Configuration/templates.d.ts +1 -0
  194. package/lib/collection-manager/Configuration/templates.js +2 -0
  195. package/lib/collection-manager/action-hooks.d.ts +4 -0
  196. package/lib/collection-manager/action-hooks.js +30 -13
  197. package/lib/collection-manager/context.d.ts +4 -0
  198. package/lib/collection-manager/context.js +7 -2
  199. package/lib/collection-manager/hooks/useCollectionManager.d.ts +7 -0
  200. package/lib/collection-manager/hooks/useCollectionManager.js +52 -6
  201. package/lib/collection-manager/interfaces/m2m.js +2 -2
  202. package/lib/collection-manager/interfaces/properties/index.d.ts +0 -56
  203. package/lib/collection-manager/interfaces/properties/index.js +1 -2
  204. package/lib/collection-manager/templates/calendar.js +1 -1
  205. package/lib/collection-manager/templates/general.js +1 -1
  206. package/lib/collection-manager/templates/properties/index.d.ts +12 -1
  207. package/lib/collection-manager/templates/properties/index.js +11 -0
  208. package/lib/i18n/i18n.js +3 -1
  209. package/lib/locale/en_US.d.ts +23 -0
  210. package/lib/locale/en_US.js +23 -0
  211. package/lib/locale/ja_JP.d.ts +23 -0
  212. package/lib/locale/ja_JP.js +24 -1
  213. package/lib/locale/ru_RU.d.ts +1 -0
  214. package/lib/locale/ru_RU.js +1 -0
  215. package/lib/locale/zh_CN.d.ts +43 -4
  216. package/lib/locale/zh_CN.js +44 -5
  217. package/lib/route-switch/antd/admin-layout/index.js +13 -33
  218. package/lib/schema-component/antd/action/Action.Designer.js +30 -14
  219. package/lib/schema-component/antd/action/Action.js +29 -3
  220. package/lib/schema-component/antd/action/utils.d.ts +1 -0
  221. package/lib/schema-component/antd/action/utils.js +58 -2
  222. package/lib/schema-component/antd/association-filter/AssociationFilter.js +3 -3
  223. package/lib/schema-component/antd/association-select/AssociationSelect.d.ts +2 -2
  224. package/lib/schema-component/antd/association-select/useServiceOptions.js +47 -4
  225. package/lib/schema-component/antd/calendar/Calendar.Designer.js +15 -33
  226. package/lib/schema-component/antd/checkbox/Checkbox.js +8 -7
  227. package/lib/schema-component/antd/date-picker/util.d.ts +1 -1
  228. package/lib/schema-component/antd/date-picker/util.js +1 -1
  229. package/lib/schema-component/antd/filter/DynamicComponent.js +3 -1
  230. package/lib/schema-component/antd/filter/Filter.js +2 -1
  231. package/lib/schema-component/antd/filter/FilterGroup.js +7 -4
  232. package/lib/schema-component/antd/filter/FilterItem.js +3 -2
  233. package/lib/schema-component/antd/filter/context.d.ts +1 -0
  234. package/lib/schema-component/antd/filter/useValues.js +15 -11
  235. package/lib/schema-component/antd/form/Form.js +9 -3
  236. package/lib/schema-component/antd/form-item/FormItem.js +21 -7
  237. package/lib/schema-component/antd/form-v2/Form.Designer.js +2 -0
  238. package/lib/schema-component/antd/form-v2/Form.js +93 -5
  239. package/lib/schema-component/antd/form-v2/utils.d.ts +5 -0
  240. package/lib/schema-component/antd/form-v2/utils.js +181 -0
  241. package/lib/schema-component/antd/g2plot/G2Plot.js +3 -1
  242. package/lib/schema-component/antd/grid/Grid.js +10 -5
  243. package/lib/schema-component/antd/icon-picker/IconPicker.js +1 -0
  244. package/lib/schema-component/antd/index.d.ts +1 -0
  245. package/lib/schema-component/antd/index.js +13 -0
  246. package/lib/schema-component/antd/input/Input.d.ts +2 -1
  247. package/lib/schema-component/antd/input/Json.d.ts +5 -3
  248. package/lib/schema-component/antd/input/Json.js +6 -3
  249. package/lib/schema-component/antd/input/ReadPretty.js +1 -1
  250. package/lib/schema-component/antd/input-number/InputNumber.js +2 -0
  251. package/lib/schema-component/antd/page/FixedBlock.js +3 -1
  252. package/lib/schema-component/antd/page/Page.js +14 -5
  253. package/lib/schema-component/antd/page/PageTabDesigner.js +1 -1
  254. package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
  255. package/lib/schema-component/antd/record-picker/RecordPicker.js +1 -2
  256. package/lib/schema-component/antd/record-picker/util.js +7 -0
  257. package/lib/schema-component/antd/remote-select/RemoteSelect.d.ts +2 -0
  258. package/lib/schema-component/antd/remote-select/RemoteSelect.js +78 -37
  259. package/lib/schema-component/antd/rich-text/RichText.js +4 -2
  260. package/lib/schema-component/antd/select/Select.js +14 -4
  261. package/lib/schema-component/antd/table/Table.Array.js +8 -1
  262. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +2 -2
  263. package/lib/schema-component/antd/table-v2/TableBlockDesigner.js +3 -2
  264. package/lib/schema-component/antd/tabs/Tabs.Designer.js +1 -0
  265. package/lib/schema-component/antd/tabs/Tabs.js +1 -0
  266. package/lib/schema-component/antd/time-picker/TimePicker.js +1 -1
  267. package/lib/schema-component/antd/variable/Input.d.ts +2 -0
  268. package/lib/schema-component/antd/variable/Input.js +262 -0
  269. package/lib/schema-component/antd/variable/JSONInput.d.ts +2 -0
  270. package/lib/schema-component/antd/variable/JSONInput.js +100 -0
  271. package/lib/schema-component/antd/variable/TextArea.d.ts +2 -0
  272. package/lib/schema-component/antd/variable/TextArea.js +341 -0
  273. package/lib/schema-component/antd/variable/Variable.d.ts +8 -0
  274. package/lib/schema-component/antd/variable/Variable.js +25 -0
  275. package/lib/schema-component/antd/variable/index.d.ts +1 -0
  276. package/lib/schema-component/antd/variable/index.js +18 -0
  277. package/lib/schema-component/common/sortable-item/SortableItem.js +36 -6
  278. package/lib/schema-component/common/utils/logic.js +525 -0
  279. package/lib/schema-component/common/utils/uitls.d.ts +1 -0
  280. package/lib/schema-component/common/utils/uitls.js +103 -0
  281. package/lib/schema-initializer/SchemaInitializer.js +9 -4
  282. package/lib/schema-initializer/buttons/BlockInitializers.d.ts +2 -184
  283. package/lib/schema-initializer/buttons/BlockInitializers.js +0 -108
  284. package/lib/schema-initializer/buttons/RecordBlockInitializers.js +72 -16
  285. package/lib/schema-initializer/buttons/TableActionColumnInitializers.d.ts +1 -0
  286. package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +3 -1
  287. package/lib/schema-initializer/components/CreateRecordAction.d.ts +3 -0
  288. package/lib/schema-initializer/components/CreateRecordAction.js +199 -0
  289. package/lib/schema-initializer/components/index.d.ts +1 -0
  290. package/lib/schema-initializer/components/index.js +13 -0
  291. package/lib/schema-initializer/index.d.ts +2 -1
  292. package/lib/schema-initializer/index.js +51 -2
  293. package/lib/schema-initializer/items/CalendarBlockInitializer.js +16 -33
  294. package/lib/schema-initializer/items/CreateActionInitializer.js +3 -3
  295. package/lib/schema-initializer/items/RecordFormBlockInitializer.js +3 -3
  296. package/lib/schema-initializer/items/index.d.ts +4 -4
  297. package/lib/schema-initializer/items/index.js +52 -52
  298. package/lib/schema-initializer/utils.js +22 -6
  299. package/lib/schema-settings/EnableChildCollections/index.d.ts +2 -0
  300. package/lib/schema-settings/EnableChildCollections/index.js +156 -0
  301. package/lib/schema-settings/LinkageRules/DynamicComponent.d.ts +1 -0
  302. package/lib/schema-settings/LinkageRules/DynamicComponent.js +139 -0
  303. package/lib/schema-settings/LinkageRules/FilterDynamicComponent.d.ts +2 -0
  304. package/lib/schema-settings/LinkageRules/FilterDynamicComponent.js +27 -0
  305. package/lib/schema-settings/LinkageRules/LinkageRuleAction.d.ts +3 -0
  306. package/lib/schema-settings/LinkageRules/LinkageRuleAction.js +190 -0
  307. package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.d.ts +3 -0
  308. package/lib/schema-settings/LinkageRules/LinkageRuleActionGroup.js +90 -0
  309. package/lib/schema-settings/LinkageRules/ValueDynamicComponent.d.ts +1 -0
  310. package/lib/schema-settings/LinkageRules/ValueDynamicComponent.js +104 -0
  311. package/lib/schema-settings/LinkageRules/Variables.d.ts +7 -0
  312. package/lib/schema-settings/LinkageRules/Variables.js +124 -0
  313. package/lib/schema-settings/LinkageRules/action-hooks.d.ts +1 -0
  314. package/lib/schema-settings/LinkageRules/action-hooks.js +127 -0
  315. package/lib/schema-settings/LinkageRules/context.d.ts +13 -0
  316. package/lib/schema-settings/LinkageRules/context.js +15 -0
  317. package/lib/schema-settings/LinkageRules/index.d.ts +2 -0
  318. package/lib/schema-settings/LinkageRules/index.js +149 -0
  319. package/lib/schema-settings/LinkageRules/type.d.ts +13 -0
  320. package/lib/schema-settings/LinkageRules/type.js +22 -0
  321. package/lib/schema-settings/LinkageRules/useValues.d.ts +1 -0
  322. package/lib/schema-settings/LinkageRules/useValues.js +95 -0
  323. package/lib/schema-settings/SchemaSettings.d.ts +4 -1
  324. package/lib/schema-settings/SchemaSettings.js +243 -48
  325. package/lib/schema-templates/BlockTemplate.js +9 -1
  326. package/lib/system-settings/SystemSettingsShortcut.js +1 -1
  327. package/package.json +4 -4
@@ -45,7 +45,7 @@ import { useResourceActionContext, useResourceContext } from '../ResourceActionP
45
45
  import * as components from './components';
46
46
  import { templateOptions } from './templates';
47
47
 
48
- var getSchema = function getSchema(schema, record, compile) {
48
+ var getSchema = function getSchema(schema, category, compile) {
49
49
  if (!schema) {
50
50
  return;
51
51
  }
@@ -60,7 +60,8 @@ var getSchema = function getSchema(schema, record, compile) {
60
60
 
61
61
  var initialValue = _objectSpread({
62
62
  name: "t_".concat(uid()),
63
- template: schema.name
63
+ template: schema.name,
64
+ category: category
64
65
  }, cloneDeep(schema.default));
65
66
 
66
67
  if (initialValue.reverseField) {
@@ -342,6 +343,10 @@ export var AddCollectionAction = function AddCollectionAction(props) {
342
343
  key: option.name
343
344
  };
344
345
  });
346
+
347
+ var _useResourceActionCon2 = useResourceActionContext(),
348
+ category = _useResourceActionCon2.state.category;
349
+
345
350
  return /*#__PURE__*/React.createElement(RecordProvider, {
346
351
  record: record
347
352
  }, /*#__PURE__*/React.createElement(ActionContext.Provider, {
@@ -359,7 +364,7 @@ export var AddCollectionAction = function AddCollectionAction(props) {
359
364
  overflow: 'auto'
360
365
  },
361
366
  onClick: function onClick(info) {
362
- var schema = getSchema(getTemplate(info.key), record, compile);
367
+ var schema = getSchema(getTemplate(info.key), category, compile);
363
368
  setSchema(schema);
364
369
  setVisible(true);
365
370
  },
@@ -334,6 +334,7 @@ export var AddFieldAction = function AddFieldAction(props) {
334
334
  useCancelAction: useCancelAction,
335
335
  createOnly: true,
336
336
  isOverride: false,
337
+ override: false,
337
338
  useCreateCollectionField: useCreateCollectionField,
338
339
  record: record,
339
340
  showReverseFieldConfig: true,
@@ -29,6 +29,7 @@ import { useCurrentAppInfo } from '../../appInfo';
29
29
  import { useRecord } from '../../record-provider';
30
30
  import { SchemaComponent, SchemaComponentContext, useCompile } from '../../schema-component';
31
31
  import { useCancelAction } from '../action-hooks';
32
+ import { CollectionCategroriesContext } from '../context';
32
33
  import { useCollectionManager } from '../hooks/useCollectionManager';
33
34
  import { DataSourceContext } from '../sub-table';
34
35
  import { AddSubFieldAction } from './AddSubFieldAction';
@@ -131,6 +132,7 @@ export var ConfigurationTable = function ConfigurationTable() {
131
132
  var _useCurrentAppInfo = useCurrentAppInfo(),
132
133
  database = _useCurrentAppInfo.data.database;
133
134
 
135
+ var data = useContext(CollectionCategroriesContext);
134
136
  var collectonsRef = useRef();
135
137
  collectonsRef.current = collections;
136
138
  var compile = useCompile();
@@ -148,9 +150,9 @@ export var ConfigurationTable = function ConfigurationTable() {
148
150
  return _context3.abrupt("return", (_collectonsRef$curren = collectonsRef.current) === null || _collectonsRef$curren === void 0 ? void 0 : _collectonsRef$curren.filter(function (item) {
149
151
  return !(item.autoCreate && item.isThrough);
150
152
  }).filter(function (item) {
151
- var _targetScope$template, _targetScope$name;
153
+ var _targetScope$template, _targetScope$field$pr;
152
154
 
153
- return targetScope ? ((_targetScope$template = targetScope['template']) === null || _targetScope$template === void 0 ? void 0 : _targetScope$template.includes(item.template)) || ((_targetScope$name = targetScope['name']) === null || _targetScope$name === void 0 ? void 0 : _targetScope$name.includes(item.name)) : true;
155
+ return targetScope ? ((_targetScope$template = targetScope['template']) === null || _targetScope$template === void 0 ? void 0 : _targetScope$template.includes(item.template)) || ((_targetScope$field$pr = targetScope[field.props.name]) === null || _targetScope$field$pr === void 0 ? void 0 : _targetScope$field$pr.includes(item.name)) : true;
154
156
  }).map(function (item) {
155
157
  return {
156
158
  label: compile(item.title),
@@ -171,8 +173,34 @@ export var ConfigurationTable = function ConfigurationTable() {
171
173
  };
172
174
  }();
173
175
 
176
+ var loadCategories = /*#__PURE__*/function () {
177
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
178
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
179
+ while (1) {
180
+ switch (_context4.prev = _context4.next) {
181
+ case 0:
182
+ return _context4.abrupt("return", data.data.map(function (item) {
183
+ return {
184
+ label: compile(item.name),
185
+ value: item.id
186
+ };
187
+ }));
188
+
189
+ case 1:
190
+ case "end":
191
+ return _context4.stop();
192
+ }
193
+ }
194
+ }, _callee4);
195
+ }));
196
+
197
+ return function loadCategories() {
198
+ return _ref2.apply(this, arguments);
199
+ };
200
+ }();
201
+
174
202
  var ctx = useContext(SchemaComponentContext);
175
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SchemaComponentContext.Provider, {
203
+ return /*#__PURE__*/React.createElement(SchemaComponentContext.Provider, {
176
204
  value: _objectSpread(_objectSpread({}, ctx), {}, {
177
205
  designable: false
178
206
  })
@@ -190,11 +218,12 @@ export var ConfigurationTable = function ConfigurationTable() {
190
218
  useSelectedRowKeys: useSelectedRowKeys,
191
219
  useAsyncDataSource: useAsyncDataSource,
192
220
  loadCollections: loadCollections,
221
+ loadCategories: loadCategories,
193
222
  useCurrentFields: useCurrentFields,
194
223
  useNewId: useNewId,
195
224
  useCancelAction: useCancelAction,
196
225
  interfaces: interfaces,
197
226
  enableInherits: (database === null || database === void 0 ? void 0 : database.dialect) === 'postgres'
198
227
  }
199
- })));
228
+ }));
200
229
  };
@@ -0,0 +1 @@
1
+ export declare const ConfigurationTabs: () => JSX.Element;
@@ -0,0 +1,381 @@
1
+ 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); } }
2
+
3
+ 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); }); }; }
4
+
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+
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
+
11
+ 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; }
12
+
13
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
+
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+
17
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
+
19
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
+
21
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
+
23
+ import { MenuOutlined } from '@ant-design/icons';
24
+ import { DndContext, DragOverlay, MouseSensor, useDraggable, useDroppable, useSensor, useSensors } from '@dnd-kit/core';
25
+ import { observer, RecursionField } from '@formily/react';
26
+ import { uid } from '@formily/shared';
27
+ import { Badge, Card, Dropdown, Menu, Modal, Tabs } from 'antd';
28
+ import React, { useContext, useState } from 'react';
29
+ import { useAPIClient } from '../../api-client';
30
+ import { SchemaComponent, SchemaComponentOptions, useCompile } from '../../schema-component';
31
+ import { CollectionCategroriesContext } from '../context';
32
+ import { useResourceActionContext } from '../ResourceActionProvider';
33
+ import { collectionTableSchema } from './schemas/collections';
34
+
35
+ function Draggable(props) {
36
+ var _useDraggable = useDraggable({
37
+ id: props.id,
38
+ data: props.data
39
+ }),
40
+ attributes = _useDraggable.attributes,
41
+ listeners = _useDraggable.listeners,
42
+ setNodeRef = _useDraggable.setNodeRef;
43
+
44
+ return /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({
45
+ ref: setNodeRef
46
+ }, listeners), attributes), /*#__PURE__*/React.createElement("div", null, props.children));
47
+ }
48
+
49
+ function Droppable(props) {
50
+ var _useDroppable = useDroppable({
51
+ id: props.id,
52
+ data: props.data
53
+ }),
54
+ isOver = _useDroppable.isOver,
55
+ setNodeRef = _useDroppable.setNodeRef;
56
+
57
+ var style = isOver ? {
58
+ color: 'green'
59
+ } : undefined;
60
+ return /*#__PURE__*/React.createElement("div", {
61
+ ref: setNodeRef,
62
+ style: style
63
+ }, props.children);
64
+ }
65
+
66
+ var TabTitle = observer(function (_ref) {
67
+ var item = _ref.item;
68
+ return /*#__PURE__*/React.createElement(Droppable, {
69
+ id: item.id.toString(),
70
+ data: item
71
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Draggable, {
72
+ id: item.id.toString(),
73
+ data: item
74
+ }, /*#__PURE__*/React.createElement(TabBar, {
75
+ item: item
76
+ }))));
77
+ });
78
+
79
+ var TabBar = function TabBar(_ref2) {
80
+ var item = _ref2.item;
81
+ var compile = useCompile();
82
+ return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Badge, {
83
+ color: item.color
84
+ }), compile(item.name));
85
+ };
86
+
87
+ var DndProvider = observer(function (props) {
88
+ var _useState = useState(null),
89
+ _useState2 = _slicedToArray(_useState, 2),
90
+ activeTab = _useState2[0],
91
+ setActiveId = _useState2[1];
92
+
93
+ var _useContext = useContext(CollectionCategroriesContext),
94
+ refresh = _useContext.refresh;
95
+
96
+ var _useResourceActionCon = useResourceActionContext(),
97
+ refreshCM = _useResourceActionCon.refresh;
98
+
99
+ var api = useAPIClient();
100
+
101
+ var onDragEnd = /*#__PURE__*/function () {
102
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(props) {
103
+ var active, over;
104
+ return regeneratorRuntime.wrap(function _callee$(_context) {
105
+ while (1) {
106
+ switch (_context.prev = _context.next) {
107
+ case 0:
108
+ active = props.active, over = props.over;
109
+ setTimeout(function () {
110
+ setActiveId(null);
111
+ });
112
+
113
+ if (!(over && over.id !== active.id)) {
114
+ _context.next = 9;
115
+ break;
116
+ }
117
+
118
+ _context.next = 5;
119
+ return api.resource('collectionCategories').move({
120
+ sourceId: active.id,
121
+ targetId: over.id
122
+ });
123
+
124
+ case 5:
125
+ _context.next = 7;
126
+ return refresh();
127
+
128
+ case 7:
129
+ _context.next = 9;
130
+ return refreshCM();
131
+
132
+ case 9:
133
+ case "end":
134
+ return _context.stop();
135
+ }
136
+ }
137
+ }, _callee);
138
+ }));
139
+
140
+ return function onDragEnd(_x) {
141
+ return _ref3.apply(this, arguments);
142
+ };
143
+ }();
144
+
145
+ function onDragStart(event) {
146
+ var _event$active;
147
+
148
+ setActiveId((_event$active = event.active) === null || _event$active === void 0 ? void 0 : _event$active.data.current);
149
+ }
150
+
151
+ var mouseSensor = useSensor(MouseSensor, {
152
+ activationConstraint: {
153
+ distance: 10
154
+ }
155
+ });
156
+ var sensors = useSensors(mouseSensor);
157
+ return /*#__PURE__*/React.createElement(DndContext, {
158
+ sensors: sensors,
159
+ onDragEnd: onDragEnd,
160
+ onDragStart: onDragStart
161
+ }, props.children, /*#__PURE__*/React.createElement(DragOverlay, null, activeTab ? /*#__PURE__*/React.createElement("span", {
162
+ style: {
163
+ whiteSpace: 'nowrap'
164
+ }
165
+ }, /*#__PURE__*/React.createElement(TabBar, {
166
+ item: activeTab
167
+ })) : null));
168
+ });
169
+ export var ConfigurationTabs = function ConfigurationTabs() {
170
+ var _useContext2 = useContext(CollectionCategroriesContext),
171
+ data = _useContext2.data,
172
+ refresh = _useContext2.refresh;
173
+
174
+ var _useResourceActionCon2 = useResourceActionContext(),
175
+ refreshCM = _useResourceActionCon2.refresh,
176
+ run = _useResourceActionCon2.run,
177
+ defaultRequest = _useResourceActionCon2.defaultRequest,
178
+ setState = _useResourceActionCon2.setState;
179
+
180
+ var _useState3 = useState('all'),
181
+ _useState4 = _slicedToArray(_useState3, 2),
182
+ key = _useState4[0],
183
+ setKey = _useState4[1];
184
+
185
+ var tabsItems = data.sort(function (a, b) {
186
+ return b.sort - a.sort;
187
+ }).concat().map(function (v) {
188
+ return _objectSpread(_objectSpread({}, v), {}, {
189
+ schema: collectionTableSchema
190
+ });
191
+ });
192
+ !tabsItems.find(function (v) {
193
+ return v.id === 'all';
194
+ }) && tabsItems.unshift({
195
+ name: '{{t("All collections")}}',
196
+ id: 'all',
197
+ sort: 0,
198
+ closable: false,
199
+ schema: collectionTableSchema
200
+ });
201
+ var compile = useCompile();
202
+
203
+ var _useState5 = useState('all'),
204
+ _useState6 = _slicedToArray(_useState5, 2),
205
+ activeKey = _useState6[0],
206
+ setActiveKey = _useState6[1];
207
+
208
+ var api = useAPIClient();
209
+
210
+ var onChange = function onChange(key) {
211
+ setActiveKey(key);
212
+ setKey(uid());
213
+
214
+ if (key !== 'all') {
215
+ var _defaultRequest$param;
216
+
217
+ var prevFilter = defaultRequest === null || defaultRequest === void 0 ? void 0 : (_defaultRequest$param = defaultRequest.params) === null || _defaultRequest$param === void 0 ? void 0 : _defaultRequest$param.filter;
218
+ var filter = {
219
+ $and: [prevFilter, {
220
+ 'category.id': key
221
+ }]
222
+ };
223
+ run({
224
+ filter: filter
225
+ });
226
+ setState === null || setState === void 0 ? void 0 : setState({
227
+ category: [+key],
228
+ params: [{
229
+ filter: filter
230
+ }]
231
+ });
232
+ } else {
233
+ run();
234
+ setState === null || setState === void 0 ? void 0 : setState({
235
+ category: [],
236
+ params: []
237
+ });
238
+ }
239
+ };
240
+
241
+ var remove = function remove(key) {
242
+ Modal.confirm({
243
+ title: compile("{{t('Delete category')}}"),
244
+ content: compile("{{t('Are you sure you want to delete it?')}}"),
245
+ onOk: function () {
246
+ var _onOk = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
247
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
248
+ while (1) {
249
+ switch (_context2.prev = _context2.next) {
250
+ case 0:
251
+ _context2.next = 2;
252
+ return api.resource('collectionCategories').destroy({
253
+ filter: {
254
+ id: key
255
+ }
256
+ });
257
+
258
+ case 2:
259
+ key === +activeKey && setActiveKey('all');
260
+ _context2.next = 5;
261
+ return refresh();
262
+
263
+ case 5:
264
+ _context2.next = 7;
265
+ return refreshCM();
266
+
267
+ case 7:
268
+ case "end":
269
+ return _context2.stop();
270
+ }
271
+ }
272
+ }, _callee2);
273
+ }));
274
+
275
+ function onOk() {
276
+ return _onOk.apply(this, arguments);
277
+ }
278
+
279
+ return onOk;
280
+ }()
281
+ });
282
+ };
283
+
284
+ var loadCategories = /*#__PURE__*/function () {
285
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
286
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
287
+ while (1) {
288
+ switch (_context3.prev = _context3.next) {
289
+ case 0:
290
+ return _context3.abrupt("return", data.map(function (item) {
291
+ return {
292
+ label: compile(item.name),
293
+ value: item.id
294
+ };
295
+ }));
296
+
297
+ case 1:
298
+ case "end":
299
+ return _context3.stop();
300
+ }
301
+ }
302
+ }, _callee3);
303
+ }));
304
+
305
+ return function loadCategories() {
306
+ return _ref4.apply(this, arguments);
307
+ };
308
+ }();
309
+
310
+ var menu = function menu(item) {
311
+ return /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Item, {
312
+ key: 'edit'
313
+ }, /*#__PURE__*/React.createElement(SchemaComponent, {
314
+ schema: {
315
+ type: 'void',
316
+ properties: _defineProperty({}, uid(), {
317
+ 'x-component': 'EditCategory',
318
+ 'x-component-props': {
319
+ item: item
320
+ }
321
+ })
322
+ }
323
+ })), /*#__PURE__*/React.createElement(Menu.Item, {
324
+ key: "delete",
325
+ onClick: function onClick() {
326
+ return remove(item.id);
327
+ }
328
+ }, compile("{{t('Delete category')}}")));
329
+ };
330
+
331
+ return /*#__PURE__*/React.createElement(DndProvider, null, /*#__PURE__*/React.createElement(Tabs, {
332
+ addIcon: /*#__PURE__*/React.createElement(SchemaComponent, {
333
+ schema: {
334
+ type: 'void',
335
+ properties: {
336
+ addCategories: {
337
+ type: 'void',
338
+ title: '{{ t("Add category") }}',
339
+ 'x-component': 'AddCategory',
340
+ 'x-component-props': {
341
+ type: 'primary'
342
+ }
343
+ }
344
+ }
345
+ }
346
+ }),
347
+ onChange: onChange,
348
+ defaultActiveKey: "all",
349
+ type: "editable-card",
350
+ destroyInactiveTabPane: true,
351
+ tabBarStyle: {
352
+ marginBottom: '0px'
353
+ }
354
+ }, tabsItems.map(function (item) {
355
+ return /*#__PURE__*/React.createElement(Tabs.TabPane, {
356
+ tab: item.id !== 'all' ? /*#__PURE__*/React.createElement("div", {
357
+ "data-no-dnd": "true"
358
+ }, /*#__PURE__*/React.createElement(TabTitle, {
359
+ item: item
360
+ })) : compile(item.name),
361
+ key: item.id,
362
+ closable: item.closable,
363
+ closeIcon: /*#__PURE__*/React.createElement(Dropdown, {
364
+ overlay: menu(item)
365
+ }, /*#__PURE__*/React.createElement(MenuOutlined, null))
366
+ }, /*#__PURE__*/React.createElement(Card, {
367
+ bordered: false
368
+ }, /*#__PURE__*/React.createElement(SchemaComponentOptions, {
369
+ inherit: true,
370
+ scope: {
371
+ loadCategories: loadCategories,
372
+ categoryVisible: item.id === 'all',
373
+ categoryId: item.id
374
+ }
375
+ }, /*#__PURE__*/React.createElement(RecursionField, {
376
+ name: key,
377
+ schema: item.schema,
378
+ onlyRenderProperties: true
379
+ }))));
380
+ })));
381
+ };
@@ -0,0 +1,2 @@
1
+ export declare const EditCategory: (props: any) => JSX.Element;
2
+ export declare const EditCategoryAction: (props: any) => JSX.Element;
@@ -0,0 +1,150 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ 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); }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ 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; }
14
+
15
+ 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; }
16
+
17
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+
19
+ 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); } }
20
+
21
+ 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); }); }; }
22
+
23
+ import { useForm } from '@formily/react';
24
+ import { cloneDeep } from 'lodash';
25
+ import React, { useContext, useEffect, useState } from 'react';
26
+ import { useAPIClient, useRequest } from '../../api-client';
27
+ import { RecordProvider, useRecord } from '../../record-provider';
28
+ import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
29
+ import { useCancelAction } from '../action-hooks';
30
+ import { CollectionCategroriesContext } from '../context';
31
+ import { useResourceActionContext } from '../ResourceActionProvider';
32
+ import * as components from './components';
33
+ import { collectionCategoryEditSchema } from './schemas/collections';
34
+
35
+ var useEditCategry = function useEditCategry() {
36
+ var form = useForm();
37
+ var ctx = useActionContext();
38
+
39
+ var _useContext = useContext(CollectionCategroriesContext),
40
+ refresh = _useContext.refresh;
41
+
42
+ var _useResourceActionCon = useResourceActionContext(),
43
+ refreshCM = _useResourceActionCon.refresh;
44
+
45
+ var api = useAPIClient();
46
+
47
+ var _useRecord = useRecord(),
48
+ id = _useRecord.id;
49
+
50
+ return {
51
+ run: function run() {
52
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
53
+ var values;
54
+ return regeneratorRuntime.wrap(function _callee$(_context) {
55
+ while (1) {
56
+ switch (_context.prev = _context.next) {
57
+ case 0:
58
+ _context.next = 2;
59
+ return form.submit();
60
+
61
+ case 2:
62
+ values = cloneDeep(form.values);
63
+ _context.next = 5;
64
+ return api.resource('collectionCategories').update({
65
+ filter: {
66
+ id: id
67
+ },
68
+ values: _objectSpread({}, values)
69
+ });
70
+
71
+ case 5:
72
+ ctx.setVisible(false);
73
+ _context.next = 8;
74
+ return form.reset();
75
+
76
+ case 8:
77
+ _context.next = 10;
78
+ return refresh();
79
+
80
+ case 10:
81
+ _context.next = 12;
82
+ return refreshCM();
83
+
84
+ case 12:
85
+ case "end":
86
+ return _context.stop();
87
+ }
88
+ }
89
+ }, _callee);
90
+ }))();
91
+ }
92
+ };
93
+ };
94
+
95
+ var useValuesFromRecord = function useValuesFromRecord(options) {
96
+ var record = useRecord();
97
+ var result = useRequest(function () {
98
+ return Promise.resolve({
99
+ data: _objectSpread({}, record)
100
+ });
101
+ }, _objectSpread(_objectSpread({}, options), {}, {
102
+ manual: true
103
+ }));
104
+ var ctx = useActionContext();
105
+ useEffect(function () {
106
+ if (ctx.visible) {
107
+ result.run();
108
+ }
109
+ }, [ctx.visible]);
110
+ return result;
111
+ };
112
+
113
+ export var EditCategory = function EditCategory(props) {
114
+ return /*#__PURE__*/React.createElement(EditCategoryAction, _objectSpread({}, props));
115
+ };
116
+ export var EditCategoryAction = function EditCategoryAction(props) {
117
+ var scope = props.scope,
118
+ getContainer = props.getContainer,
119
+ item = props.item,
120
+ children = props.children;
121
+
122
+ var _useState = useState(false),
123
+ _useState2 = _slicedToArray(_useState, 2),
124
+ visible = _useState2[0],
125
+ setVisible = _useState2[1];
126
+
127
+ var compile = useCompile();
128
+ return /*#__PURE__*/React.createElement(RecordProvider, {
129
+ record: item
130
+ }, /*#__PURE__*/React.createElement(ActionContext.Provider, {
131
+ value: {
132
+ visible: visible,
133
+ setVisible: setVisible
134
+ }
135
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, children || /*#__PURE__*/React.createElement("span", {
136
+ onClick: function onClick() {
137
+ return setVisible(true);
138
+ }
139
+ }, compile('{{ t("Edit category") }}'))), /*#__PURE__*/React.createElement(SchemaComponent, {
140
+ schema: collectionCategoryEditSchema,
141
+ components: _objectSpread({}, components),
142
+ scope: _objectSpread({
143
+ getContainer: getContainer,
144
+ useCancelAction: useCancelAction,
145
+ createOnly: true,
146
+ useEditCategry: useEditCategry,
147
+ useValuesFromRecord: useValuesFromRecord
148
+ }, scope)
149
+ })));
150
+ };
@@ -100,9 +100,13 @@ export var useValuesFromRecord = function useValuesFromRecord(options) {
100
100
  var record = useRecord();
101
101
  var result = useRequest(function () {
102
102
  return Promise.resolve({
103
- data: _objectSpread({
103
+ data: _objectSpread(_objectSpread({
104
104
  autoGenId: true
105
- }, record)
105
+ }, record), {}, {
106
+ category: record === null || record === void 0 ? void 0 : record.category.map(function (v) {
107
+ return v.id;
108
+ })
109
+ })
106
110
  });
107
111
  }, _objectSpread(_objectSpread({}, options), {}, {
108
112
  manual: true