@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,45 +1,96 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
7
  import { connect, mapProps, observer } from '@formily/react';
8
+ import { observable } from '@formily/reactive';
2
9
  import { Tree as AntdTree } from 'antd';
3
- import React from 'react';
10
+ import _ from 'lodash';
11
+ import React, { useMemo } from 'react';
4
12
  import { useTranslation } from 'react-i18next';
13
+ import { mergeFilter } from '../../block-provider';
5
14
  import { useCollectionManager } from '../../collection-manager';
6
- import { AssociationSelect, SchemaComponent } from '../../schema-component';
15
+ import { AssociationSelect, SchemaComponent, SchemaComponentContext, removeNullCondition } from '../../schema-component';
7
16
  import { AsDefaultTemplate } from './components/AsDefaultTemplate';
8
17
  import { ArrayCollapse } from './components/DataTemplateTitle';
18
+ import { Designer, getSelectedIdFilter } from './components/Designer';
9
19
  import { useCollectionState } from './hooks/useCollectionState';
10
20
  var Tree = connect(AntdTree, mapProps({
11
21
  value: 'checkedKeys',
12
- dataSource: 'treeData',
13
- onInput: 'onCheck'
22
+ dataSource: 'treeData'
23
+ // onInput: 'onCheck',
14
24
  }));
25
+
15
26
  export var FormDataTemplates = observer(function (props) {
16
- var useProps = props.useProps;
27
+ var useProps = props.useProps,
28
+ formSchema = props.formSchema,
29
+ designerCtx = props.designerCtx;
17
30
  var _useProps = useProps(),
18
31
  defaultValues = _useProps.defaultValues,
19
32
  collectionName = _useProps.collectionName;
20
33
  var _useCollectionState = useCollectionState(collectionName),
21
34
  collectionList = _useCollectionState.collectionList,
22
- getEnableFieldTree = _useCollectionState.getEnableFieldTree;
35
+ getEnableFieldTree = _useCollectionState.getEnableFieldTree,
36
+ onLoadData = _useCollectionState.onLoadData,
37
+ onCheck = _useCollectionState.onCheck;
23
38
  var _useCollectionManager = useCollectionManager(),
24
39
  getCollection = _useCollectionManager.getCollection,
25
40
  getCollectionField = _useCollectionManager.getCollectionField;
26
- var collection = getCollection(collectionName);
27
41
  var _useTranslation = useTranslation(),
28
42
  t = _useTranslation.t;
29
- var field = getCollectionField("".concat(collectionName, ".").concat((collection === null || collection === void 0 ? void 0 : collection.titleField) || 'id'));
30
- return /*#__PURE__*/React.createElement(SchemaComponent, {
31
- components: {
43
+ // 不要在后面的数组中依赖 defaultValues,否则会因为 defaultValues 的变化导致 activeData 响应性丢失
44
+ var activeData = useMemo(function () {
45
+ return observable(defaultValues || {
46
+ items: [],
47
+ display: true,
48
+ config: _defineProperty({}, collectionName, {
49
+ titleField: '',
50
+ filter: {}
51
+ })
52
+ });
53
+ }, []);
54
+ var getTargetField = function getTargetField(collectionName) {
55
+ var _activeData$config$co;
56
+ var collection = getCollection(collectionName);
57
+ return getCollectionField("".concat(collectionName, ".").concat((activeData === null || activeData === void 0 ? void 0 : (_activeData$config$co = activeData.config[collectionName]) === null || _activeData$config$co === void 0 ? void 0 : _activeData$config$co.titleField) || (collection === null || collection === void 0 ? void 0 : collection.titleField) || 'id'));
58
+ };
59
+ var getFieldNames = function getFieldNames(collectionName) {
60
+ var _activeData$config, _activeData$config$co2;
61
+ var collection = getCollection(collectionName);
62
+ return {
63
+ label: getLabel(((_activeData$config = activeData.config) === null || _activeData$config === void 0 ? void 0 : (_activeData$config$co2 = _activeData$config[collectionName]) === null || _activeData$config$co2 === void 0 ? void 0 : _activeData$config$co2.titleField) || (collection === null || collection === void 0 ? void 0 : collection.titleField) || 'id'),
64
+ value: 'id'
65
+ };
66
+ };
67
+ var getFilter = function getFilter(collectionName, value) {
68
+ var _activeData$config2, _activeData$config2$c;
69
+ var filter = (_activeData$config2 = activeData.config) === null || _activeData$config2 === void 0 ? void 0 : (_activeData$config2$c = _activeData$config2[collectionName]) === null || _activeData$config2$c === void 0 ? void 0 : _activeData$config2$c.filter;
70
+ return _.isEmpty(filter) ? {} : removeNullCondition(mergeFilter([filter, getSelectedIdFilter(value)], '$or'));
71
+ };
72
+ var components = useMemo(function () {
73
+ return {
32
74
  ArrayCollapse: ArrayCollapse
33
- },
34
- scope: {
35
- getEnableFieldTree: getEnableFieldTree
36
- },
37
- schema: {
75
+ };
76
+ }, []);
77
+ var scope = useMemo(function () {
78
+ return {
79
+ getEnableFieldTree: getEnableFieldTree,
80
+ getTargetField: getTargetField,
81
+ getFieldNames: getFieldNames,
82
+ getFilter: getFilter,
83
+ getResource: getResource,
84
+ collectionName: collectionName
85
+ };
86
+ }, []);
87
+ var schema = useMemo(function () {
88
+ return {
38
89
  type: 'object',
39
90
  properties: {
40
91
  items: {
41
92
  type: 'array',
42
- default: defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.items,
93
+ default: activeData === null || activeData === void 0 ? void 0 : activeData.items,
43
94
  'x-component': 'ArrayCollapse',
44
95
  'x-decorator': 'FormItem',
45
96
  'x-component-props': {
@@ -49,7 +100,9 @@ export var FormDataTemplates = observer(function (props) {
49
100
  type: 'object',
50
101
  'x-component': 'ArrayCollapse.CollapsePanel',
51
102
  'x-component-props': {
52
- extra: [/*#__PURE__*/React.createElement(AsDefaultTemplate, null)]
103
+ extra: [/*#__PURE__*/React.createElement(AsDefaultTemplate, {
104
+ key: "0"
105
+ })]
53
106
  },
54
107
  properties: {
55
108
  layout: {
@@ -58,14 +111,13 @@ export var FormDataTemplates = observer(function (props) {
58
111
  'x-component-props': {
59
112
  layout: 'vertical'
60
113
  },
61
- // TODO: 翻译
62
114
  properties: {
63
115
  collection: {
64
116
  type: 'string',
65
117
  title: '{{ t("Collection") }}',
66
118
  required: true,
67
119
  description: t('If collection inherits, choose inherited collections as templates'),
68
- default: collectionName,
120
+ default: '{{ collectionName }}',
69
121
  'x-display': collectionList.length > 1 ? 'visible' : 'hidden',
70
122
  'x-decorator': 'FormItem',
71
123
  'x-component': 'Select',
@@ -78,31 +130,27 @@ export var FormDataTemplates = observer(function (props) {
78
130
  title: '{{ t("Template Data") }}',
79
131
  required: true,
80
132
  description: t('Select an existing piece of data as the initialization data for the form'),
133
+ 'x-designer': Designer,
134
+ 'x-designer-props': {
135
+ formSchema: formSchema,
136
+ data: activeData
137
+ },
81
138
  'x-decorator': 'FormItem',
82
139
  'x-component': AssociationSelect,
83
140
  'x-component-props': {
84
141
  service: {
85
- resource: collectionName
142
+ resource: '{{ $record.collection || collectionName }}',
143
+ params: {
144
+ filter: '{{ getFilter($self.componentProps.service.resource, $self.value) }}'
145
+ }
86
146
  },
87
147
  action: 'list',
88
148
  multiple: false,
89
149
  objectValue: false,
90
150
  manual: false,
91
- targetField: field,
92
- mapOptions: function mapOptions(option) {
93
- try {
94
- var label = getLabel(collection);
95
- option[label] = /*#__PURE__*/React.createElement(React.Fragment, null, "#", option.id, " ", option[label]);
96
- return option;
97
- } catch (error) {
98
- console.error(error);
99
- return option;
100
- }
101
- },
102
- fieldNames: {
103
- label: getLabel(collection),
104
- value: 'id'
105
- }
151
+ targetField: '{{ getTargetField($self.componentProps.service.resource) }}',
152
+ mapOptions: getMapOptions(),
153
+ fieldNames: '{{ getFieldNames($self.componentProps.service.resource) }}'
106
154
  },
107
155
  'x-reactions': [{
108
156
  dependencies: ['.collection'],
@@ -111,7 +159,7 @@ export var FormDataTemplates = observer(function (props) {
111
159
  disabled: '{{ !$deps[0] }}',
112
160
  componentProps: {
113
161
  service: {
114
- resource: '{{ $deps[0] }}'
162
+ resource: '{{ getResource($deps[0], $self) }}'
115
163
  }
116
164
  }
117
165
  }
@@ -128,7 +176,10 @@ export var FormDataTemplates = observer(function (props) {
128
176
  'x-component-props': {
129
177
  treeData: [],
130
178
  checkable: true,
179
+ checkStrictly: true,
131
180
  selectable: false,
181
+ loadData: onLoadData,
182
+ onCheck: onCheck,
132
183
  rootStyle: {
133
184
  padding: '8px 0',
134
185
  border: '1px solid #d9d9d9',
@@ -144,7 +195,7 @@ export var FormDataTemplates = observer(function (props) {
144
195
  state: {
145
196
  disabled: '{{ !$deps[0] }}',
146
197
  componentProps: {
147
- treeData: '{{ getEnableFieldTree($deps[0]) }}'
198
+ treeData: '{{ getEnableFieldTree($deps[0], $self) }}'
148
199
  }
149
200
  }
150
201
  }
@@ -177,14 +228,38 @@ export var FormDataTemplates = observer(function (props) {
177
228
  display: {
178
229
  type: 'boolean',
179
230
  'x-content': '{{ t("Display data template selector") }}',
180
- default: (defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.display) !== false,
231
+ default: (activeData === null || activeData === void 0 ? void 0 : activeData.display) !== false,
181
232
  'x-decorator': 'FormItem',
182
233
  'x-component': 'Checkbox'
183
234
  }
184
235
  }
185
- }
186
- });
236
+ };
237
+ }, []);
238
+ return /*#__PURE__*/React.createElement(SchemaComponentContext.Provider, {
239
+ value: _objectSpread(_objectSpread({}, designerCtx), {}, {
240
+ designable: true
241
+ })
242
+ }, /*#__PURE__*/React.createElement(SchemaComponent, {
243
+ components: components,
244
+ scope: scope,
245
+ schema: schema
246
+ }));
187
247
  });
188
- function getLabel(collection) {
189
- return !(collection === null || collection === void 0 ? void 0 : collection.titleField) || collection.titleField === 'id' ? 'label' : collection === null || collection === void 0 ? void 0 : collection.titleField;
248
+ export function getLabel(titleField) {
249
+ return titleField || 'label';
250
+ }
251
+ function getMapOptions() {
252
+ return function (option) {
253
+ if ((option === null || option === void 0 ? void 0 : option.id) === undefined) {
254
+ return null;
255
+ }
256
+ return option;
257
+ };
258
+ }
259
+ function getResource(resource, field) {
260
+ if (resource !== field.componentProps.service.resource) {
261
+ // 切换 collection 后,之前选中的其它 collection 的数据就没有意义了,需要清空
262
+ field.value = undefined;
263
+ }
264
+ return resource;
190
265
  }
@@ -8,7 +8,7 @@ import { ArrayBase } from '@formily/antd';
8
8
  import { Switch } from 'antd';
9
9
  import React from 'react';
10
10
  import { useTranslation } from 'react-i18next';
11
- export var AsDefaultTemplate = /*#__PURE__*/React.forwardRef(function (props) {
11
+ export var AsDefaultTemplate = /*#__PURE__*/React.forwardRef(function (props, ref) {
12
12
  var _array$field;
13
13
  var array = ArrayBase.useArray();
14
14
  var index = ArrayBase.useIndex(props.index);
@@ -1,15 +1,15 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
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."); }
4
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); }
5
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; }
6
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; } }
7
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
- 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; }
10
- 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; }
11
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
- 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); }
13
13
  import { CopyOutlined } from '@ant-design/icons';
14
14
  import { ArrayBase } from '@formily/antd';
15
15
  import { RecursionField, observer, useField, useFieldSchema } from '@formily/react';
@@ -19,7 +19,7 @@ import cls from 'classnames';
19
19
  import { clone } from 'lodash';
20
20
  import React, { Fragment, useEffect, useState } from 'react';
21
21
  import { useTranslation } from 'react-i18next';
22
- var DataTemplateTitle = function DataTemplateTitle(props) {
22
+ var DataTemplateTitle = observer(function (props) {
23
23
  var _array$field;
24
24
  var array = ArrayBase.useArray();
25
25
  var index = ArrayBase.useIndex(props.index);
@@ -40,15 +40,11 @@ var DataTemplateTitle = function DataTemplateTitle(props) {
40
40
  placeholder: t('Template name'),
41
41
  onChange: function onChange(ev) {
42
42
  ev.stopPropagation();
43
- array.field.value.splice(index, 1, _objectSpread(_objectSpread({}, value), {}, {
44
- title: ev.target.value
45
- }));
43
+ value.title = ev.target.value;
46
44
  },
47
45
  onBlur: function onBlur(ev) {
48
46
  ev.stopPropagation();
49
- array.field.value.splice(index, 1, _objectSpread(_objectSpread({}, value), {}, {
50
- title: ev.target.value
51
- }));
47
+ value.title = ev.target.value;
52
48
  },
53
49
  autoSize: true,
54
50
  style: {
@@ -59,7 +55,7 @@ var DataTemplateTitle = function DataTemplateTitle(props) {
59
55
  e.stopPropagation();
60
56
  }
61
57
  });
62
- };
58
+ });
63
59
  var isAdditionComponent = function isAdditionComponent(schema) {
64
60
  var _schema$xComponent, _schema$xComponent$in;
65
61
  return ((_schema$xComponent = schema['x-component']) === null || _schema$xComponent === void 0 ? void 0 : (_schema$xComponent$in = _schema$xComponent.indexOf) === null || _schema$xComponent$in === void 0 ? void 0 : _schema$xComponent$in.call(_schema$xComponent, 'Addition')) > -1;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export declare const Designer: React.MemoExoticComponent<React.FunctionComponent<unknown>>;
3
+ export declare function getSelectedIdFilter(selectedId: any): {
4
+ id: {
5
+ $eq: any;
6
+ };
7
+ };
@@ -0,0 +1,179 @@
1
+ var _excluded = ["title", "options", "value", "onChange"];
2
+ 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); }
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ 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; }
7
+ 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; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
+ 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); }
10
+ import { observer, useField, useFieldSchema } from '@formily/react';
11
+ import { error } from '@nocobase/utils/client';
12
+ import { Select } from 'antd';
13
+ import _ from 'lodash';
14
+ import React from 'react';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { GeneralSchemaDesigner, SchemaSettings } from '../..';
17
+ import { mergeFilter } from '../../../block-provider';
18
+ import { useCollectionFilterOptions, useCollectionManager } from '../../../collection-manager';
19
+ import { isTitleField } from '../../../collection-manager/Configuration/CollectionFields';
20
+ import { removeNullCondition, useCompile, useDesignable } from '../../../schema-component';
21
+ import { FilterDynamicComponent } from '../../../schema-component/antd/table-v2/FilterDynamicComponent';
22
+ export var Designer = observer(function () {
23
+ var _useCollectionManager = useCollectionManager(),
24
+ getCollectionFields = _useCollectionManager.getCollectionFields,
25
+ getCollectionField = _useCollectionManager.getCollectionField,
26
+ getCollection = _useCollectionManager.getCollection;
27
+ var field = useField();
28
+ var fieldSchema = useFieldSchema();
29
+ var _useTranslation = useTranslation(),
30
+ t = _useTranslation.t;
31
+ var _useDesignable = useDesignable(),
32
+ dn = _useDesignable.dn;
33
+ var compile = useCompile();
34
+ var _fieldSchema$xDesign = fieldSchema['x-designer-props'],
35
+ formSchema = _fieldSchema$xDesign.formSchema,
36
+ data = _fieldSchema$xDesign.data;
37
+ // 在这里读取 resource 的值,当 resource 变化时,会触发该组件的更新
38
+ var collectionName = field.componentProps.service.resource;
39
+ var collection = getCollection(collectionName);
40
+ var collectionFields = getCollectionFields(collectionName);
41
+ var dataSource = useCollectionFilterOptions(collectionName);
42
+ if (!data) {
43
+ error('data is required');
44
+ return null;
45
+ }
46
+ var getFilter = function getFilter() {
47
+ var _data$config, _data$config$collecti;
48
+ return ((_data$config = data.config) === null || _data$config === void 0 ? void 0 : (_data$config$collecti = _data$config[collectionName]) === null || _data$config$collecti === void 0 ? void 0 : _data$config$collecti.filter) || {};
49
+ };
50
+ var setFilter = function setFilter(filter) {
51
+ try {
52
+ _.set(data, "config.".concat(collectionName, ".filter"), removeNullCondition(filter));
53
+ } catch (err) {
54
+ error(err);
55
+ }
56
+ };
57
+ var getTitleFIeld = function getTitleFIeld() {
58
+ var _data$config2, _data$config2$collect;
59
+ return ((_data$config2 = data.config) === null || _data$config2 === void 0 ? void 0 : (_data$config2$collect = _data$config2[collectionName]) === null || _data$config2$collect === void 0 ? void 0 : _data$config2$collect.titleField) || (collection === null || collection === void 0 ? void 0 : collection.titleField) || 'id';
60
+ };
61
+ var setTitleField = function setTitleField(titleField) {
62
+ try {
63
+ _.set(data, "config.".concat(collectionName, ".titleField"), titleField);
64
+ } catch (err) {
65
+ error(err);
66
+ }
67
+ };
68
+ var options = collectionFields.filter(function (field) {
69
+ return isTitleField(field);
70
+ }).map(function (field) {
71
+ var _field$uiSchema;
72
+ return {
73
+ value: field === null || field === void 0 ? void 0 : field.name,
74
+ label: compile(field === null || field === void 0 ? void 0 : (_field$uiSchema = field.uiSchema) === null || _field$uiSchema === void 0 ? void 0 : _field$uiSchema.title) || (field === null || field === void 0 ? void 0 : field.name)
75
+ };
76
+ });
77
+ return /*#__PURE__*/React.createElement(GeneralSchemaDesigner, {
78
+ draggable: false
79
+ }, /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
80
+ title: t('Set the data scope'),
81
+ schema: {
82
+ type: 'object',
83
+ title: t('Set the data scope'),
84
+ properties: {
85
+ filter: {
86
+ default: getFilter(),
87
+ // title: '数据范围',
88
+ enum: dataSource,
89
+ 'x-component': 'Filter',
90
+ 'x-component-props': {
91
+ dynamicComponent: function dynamicComponent(props) {
92
+ return FilterDynamicComponent(_objectSpread({}, props));
93
+ }
94
+ }
95
+ }
96
+ }
97
+ },
98
+ onSubmit: function onSubmit(_ref) {
99
+ var _schema;
100
+ var filter = _ref.filter;
101
+ setFilter(filter);
102
+ try {
103
+ // 不仅更新当前模板,也更新同级的其它模板
104
+ field.query('fieldReaction.items.*.layout.dataId').forEach(function (item) {
105
+ if (item.componentProps.service.resource !== collectionName) {
106
+ return;
107
+ }
108
+ item.componentProps.service.params = {
109
+ filter: _.isEmpty(filter) ? {} : removeNullCondition(mergeFilter([filter, getSelectedIdFilter(field.value)], '$or'))
110
+ };
111
+ });
112
+ } catch (err) {
113
+ error(err);
114
+ }
115
+ formSchema['x-data-templates'] = data;
116
+ dn.emit('patch', {
117
+ schema: (_schema = {}, _defineProperty(_schema, 'x-uid', formSchema['x-uid']), _defineProperty(_schema, 'x-data-templates', data), _schema)
118
+ });
119
+ dn.refresh();
120
+ }
121
+ }), /*#__PURE__*/React.createElement(SelectItem, {
122
+ key: "title-field",
123
+ title: t('Title field'),
124
+ options: options,
125
+ value: getTitleFIeld(),
126
+ onChange: function onChange(label) {
127
+ var _schema2;
128
+ setTitleField(label);
129
+ try {
130
+ // 不仅更新当前模板,也更新同级的其它模板
131
+ field.query('fieldReaction.items.*.layout.dataId').forEach(function (item) {
132
+ if (item.componentProps.service.resource !== collectionName) {
133
+ return;
134
+ }
135
+ item.componentProps.fieldNames.label = label;
136
+ item.componentProps.targetField = getCollectionField("".concat(collectionName, ".").concat(label || (collection === null || collection === void 0 ? void 0 : collection.titleField) || 'id'));
137
+ });
138
+ } catch (err) {
139
+ console.error(err);
140
+ }
141
+ formSchema['x-data-templates'] = data;
142
+ var schema = (_schema2 = {}, _defineProperty(_schema2, 'x-uid', formSchema['x-uid']), _defineProperty(_schema2, 'x-data-templates', data), _schema2);
143
+ dn.emit('patch', {
144
+ schema: schema
145
+ });
146
+ dn.refresh();
147
+ }
148
+ }));
149
+ });
150
+ export function getSelectedIdFilter(selectedId) {
151
+ return selectedId ? {
152
+ id: {
153
+ $eq: selectedId
154
+ }
155
+ } : null;
156
+ }
157
+ function SelectItem(props) {
158
+ var title = props.title,
159
+ options = props.options,
160
+ value = props.value,
161
+ onChange = props.onChange,
162
+ others = _objectWithoutProperties(props, _excluded);
163
+ return /*#__PURE__*/React.createElement(SchemaSettings.Item, _objectSpread({}, others), /*#__PURE__*/React.createElement("div", {
164
+ style: {
165
+ alignItems: 'center',
166
+ display: 'flex',
167
+ justifyContent: 'space-between'
168
+ }
169
+ }, title, /*#__PURE__*/React.createElement(Select, _objectSpread({
170
+ bordered: false,
171
+ value: value,
172
+ onChange: onChange,
173
+ options: options,
174
+ style: {
175
+ textAlign: 'right',
176
+ minWidth: 100
177
+ }
178
+ }, others))));
179
+ }
@@ -1,13 +1,18 @@
1
+ import { ArrayField } from '@formily/core';
1
2
  import React from 'react';
2
3
  export declare const useCollectionState: (currentCollectionName: string) => {
3
4
  collectionList: {
4
5
  label: any;
5
6
  value: string;
6
7
  }[];
7
- getEnableFieldTree: (collectionName: string) => {
8
+ getEnableFieldTree: (collectionName: string, fields: ArrayField) => {
8
9
  title: React.FunctionComponentElement<any>;
9
10
  key: any;
11
+ isLeaf: boolean;
12
+ field: import("../../../collection-manager").CollectionFieldOptions;
10
13
  type: string;
11
14
  tag: any;
12
15
  }[];
16
+ onLoadData: (node: any) => Promise<unknown>;
17
+ onCheck: (checkedKeys: any, { node, checked }: any) => void;
13
18
  };