@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
@@ -11,6 +11,7 @@ var _css = require("@emotion/css");
11
11
  var _antd = require("@formily/antd");
12
12
  var _react = require("@formily/react");
13
13
  var _shared = require("@formily/shared");
14
+ var _antd2 = require("antd");
14
15
  var _lodash = _interopRequireDefault(require("lodash"));
15
16
  var _moment = _interopRequireDefault(require("moment"));
16
17
  var _react2 = _interopRequireWildcard(require("react"));
@@ -19,19 +20,21 @@ var _ACLProvider = require("../../../acl/ACLProvider");
19
20
  var _blockProvider = require("../../../block-provider");
20
21
  var _collectionManager = require("../../../collection-manager");
21
22
  var _CollectionFields = require("../../../collection-manager/Configuration/CollectionFields");
23
+ var _GeneralSchemaItems = require("../../../schema-items/GeneralSchemaItems");
22
24
  var _schemaSettings = require("../../../schema-settings");
23
25
  var _VariableInput = require("../../../schema-settings/VariableInput/VariableInput");
24
- var _FilterDynamicComponent = require("../table-v2/FilterDynamicComponent");
26
+ var _useIsShowMultipleSwitch = require("../../../schema-settings/hooks/useIsShowMultipleSwitch");
25
27
  var _uitls = require("../../common/utils/uitls");
26
28
  var _core = require("../../core");
27
- var _filter = require("../filter");
28
29
  var _hooks = require("../../hooks");
29
30
  var _blockItem = require("../block-item");
31
+ var _filter = require("../filter");
30
32
  var _shared2 = require("../input/shared");
33
+ var _FilterDynamicComponent = require("../table-v2/FilterDynamicComponent");
31
34
  var _variable = require("../variable");
32
35
  var _FormItem = require("./FormItem.FilterFormDesigner");
33
36
  var _SchemaSettingOptions = require("./SchemaSettingOptions");
34
- var _templateObject, _templateObject2;
37
+ var _templateObject, _templateObject2, _templateObject3;
35
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
36
39
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -73,10 +76,12 @@ var FormItem = (0, _react.observer)(function (props) {
73
76
  }
74
77
  }
75
78
  }, []);
79
+ var _props$showTitle = props.showTitle,
80
+ showTitle = _props$showTitle === void 0 ? true : _props$showTitle;
76
81
  return /*#__PURE__*/_react2.default.createElement(_ACLProvider.ACLCollectionFieldProvider, null, /*#__PURE__*/_react2.default.createElement(_blockItem.BlockItem, {
77
82
  className: 'nb-form-item'
78
83
  }, /*#__PURE__*/_react2.default.createElement(_antd.FormItem, _objectSpread(_objectSpread({
79
- className: "".concat((0, _css.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n & .ant-space {\n flex-wrap: wrap;\n }\n "]))))
84
+ className: (0, _css.cx)((0, _css.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n & .ant-space {\n flex-wrap: wrap;\n }\n "]))), _defineProperty({}, (0, _css.css)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n > .ant-formily-item-label {\n display: none;\n }\n "]))), showTitle === false))
80
85
  }, props), {}, {
81
86
  extra: typeof field.description === 'string' ? /*#__PURE__*/_react2.default.createElement("div", {
82
87
  dangerouslySetInnerHTML: {
@@ -87,7 +92,7 @@ var FormItem = (0, _react.observer)(function (props) {
87
92
  });
88
93
  exports.FormItem = FormItem;
89
94
  FormItem.Designer = function Designer() {
90
- var _interfaceConfig$vali, _collectionField$uiSc, _getCollectionFields, _field$componentProps, _field$componentProps2, _field$componentProps3, _field$componentProps4, _field$componentProps5, _field$componentProps6, _field$componentProps7, _collectionField$uiSc2, _fieldSchema$xDecora, _fieldSchema$xCompon, _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _field$componentProps8, _field$componentProps9;
95
+ var _interfaceConfig$vali, _collectionField$uiSc, _getCollectionFields, _field$componentProps, _field$componentProps2, _field$componentProps3, _field$componentProps4, _field$componentProps5, _field$componentProps6, _field$componentProps7, _fieldSchema$xCompon, _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _fieldSchema$xCompon5, _fieldSchema$xCompon6, _fieldSchema$xCompon7, _fieldSchema$xCompon8, _fieldSchema$xCompon9, _fieldSchema$xCompon10, _field$componentProps8, _field$componentProps9;
91
96
  var _useCollectionManager = (0, _collectionManager.useCollectionManager)(),
92
97
  getCollectionFields = _useCollectionManager.getCollectionFields,
93
98
  getInterface = _useCollectionManager.getInterface,
@@ -95,7 +100,6 @@ FormItem.Designer = function Designer() {
95
100
  getCollection = _useCollectionManager.getCollection;
96
101
  var _useCollection = (0, _collectionManager.useCollection)(),
97
102
  getField = _useCollection.getField;
98
- var tk = (0, _blockProvider.useFilterByTk)();
99
103
  var _useFormBlockContext = (0, _blockProvider.useFormBlockContext)(),
100
104
  form = _useFormBlockContext.form;
101
105
  var field = (0, _react.useField)();
@@ -108,6 +112,7 @@ FormItem.Designer = function Designer() {
108
112
  insertAdjacent = _useDesignable.insertAdjacent;
109
113
  var compile = (0, _hooks.useCompile)();
110
114
  var variablesCtx = (0, _uitls.useVariablesCtx)();
115
+ var IsShowMultipleSwitch = (0, _useIsShowMultipleSwitch.useIsShowMultipleSwitch)();
111
116
  var collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
112
117
  var targetCollection = getCollection(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
113
118
  var interfaceConfig = getInterface(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface);
@@ -147,7 +152,7 @@ FormItem.Designer = function Designer() {
147
152
  var fieldMode = (field === null || field === void 0 ? void 0 : (_field$componentProps7 = field.componentProps) === null || _field$componentProps7 === void 0 ? void 0 : _field$componentProps7['mode']) || (isFileField ? 'FileManager' : 'Select');
148
153
  var isSelectFieldMode = fieldMode === 'Select';
149
154
  var sort = defaultSort === null || defaultSort === void 0 ? void 0 : defaultSort.map(function (item) {
150
- return item.startsWith('-') ? {
155
+ return (item === null || item === void 0 ? void 0 : item.startsWith('-')) ? {
151
156
  field: item.substring(1),
152
157
  direction: 'desc'
153
158
  } : {
@@ -155,111 +160,15 @@ FormItem.Designer = function Designer() {
155
160
  direction: 'asc'
156
161
  };
157
162
  });
158
- return /*#__PURE__*/_react2.default.createElement(_schemaSettings.GeneralSchemaDesigner, null, collectionField && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.ModalItem, {
159
- key: "edit-field-title",
160
- title: t('Edit field title'),
161
- schema: {
162
- type: 'object',
163
- title: t('Edit field title'),
164
- properties: {
165
- title: {
166
- title: t('Field title'),
167
- default: field === null || field === void 0 ? void 0 : field.title,
168
- description: "".concat(t('Original field title: ')).concat(collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc2 = collectionField.uiSchema) === null || _collectionField$uiSc2 === void 0 ? void 0 : _collectionField$uiSc2.title),
169
- 'x-decorator': 'FormItem',
170
- 'x-component': 'Input',
171
- 'x-component-props': {}
172
- }
173
- }
174
- },
175
- onSubmit: function onSubmit(_ref) {
176
- var title = _ref.title;
177
- if (title) {
178
- field.title = title;
179
- fieldSchema.title = title;
180
- dn.emit('patch', {
181
- schema: {
182
- 'x-uid': fieldSchema['x-uid'],
183
- title: fieldSchema.title
184
- }
185
- });
186
- }
187
- dn.refresh();
188
- }
189
- }), !field.readPretty && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.ModalItem, {
190
- key: "edit-description",
191
- title: t('Edit description'),
192
- schema: {
193
- type: 'object',
194
- title: t('Edit description'),
195
- properties: {
196
- description: {
197
- // title: t('Description'),
198
- default: field === null || field === void 0 ? void 0 : field.description,
199
- 'x-decorator': 'FormItem',
200
- 'x-component': 'Input.TextArea',
201
- 'x-component-props': {}
202
- }
203
- }
204
- },
205
- onSubmit: function onSubmit(_ref2) {
206
- var description = _ref2.description;
207
- field.description = description;
208
- fieldSchema.description = description;
209
- dn.emit('patch', {
210
- schema: {
211
- 'x-uid': fieldSchema['x-uid'],
212
- description: fieldSchema.description
213
- }
214
- });
215
- dn.refresh();
216
- }
217
- }), field.readPretty && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.ModalItem, {
218
- key: "edit-tooltip",
219
- title: t('Edit tooltip'),
220
- schema: {
221
- type: 'object',
222
- title: t('Edit description'),
223
- properties: {
224
- tooltip: {
225
- default: fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xDecora = fieldSchema['x-decorator-props']) === null || _fieldSchema$xDecora === void 0 ? void 0 : _fieldSchema$xDecora.tooltip,
226
- 'x-decorator': 'FormItem',
227
- 'x-component': 'Input.TextArea',
228
- 'x-component-props': {}
229
- }
230
- }
231
- },
232
- onSubmit: function onSubmit(_ref3) {
233
- var tooltip = _ref3.tooltip;
234
- field.decoratorProps.tooltip = tooltip;
235
- fieldSchema['x-decorator-props'] = fieldSchema['x-decorator-props'] || {};
236
- fieldSchema['x-decorator-props']['tooltip'] = tooltip;
237
- dn.emit('patch', {
238
- schema: {
239
- 'x-uid': fieldSchema['x-uid'],
240
- 'x-decorator-props': fieldSchema['x-decorator-props']
241
- }
242
- });
243
- dn.refresh();
244
- }
245
- }), !field.readPretty && fieldSchema['x-component'] !== 'FormField' && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
246
- key: "required",
247
- title: t('Required'),
248
- checked: fieldSchema.required,
249
- onChange: function onChange(required) {
250
- var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
251
- field.required = required;
252
- fieldSchema['required'] = required;
253
- schema['required'] = required;
254
- dn.emit('patch', {
255
- schema: schema
256
- });
257
- refresh();
258
- }
259
- }), !(form === null || form === void 0 ? void 0 : form.readPretty) && isFileField ? /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
163
+ var fieldSchemaWithoutRequired = _lodash.default.omit(fieldSchema, 'required');
164
+ var isSubFormMode = ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.mode) === 'Nester';
165
+ var isPickerMode = ((_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.mode) === 'Picker';
166
+ var showFieldMode = isAssociationField && fieldModeOptions && !isTableField;
167
+ var showModeSelect = showFieldMode && isPickerMode;
168
+ return /*#__PURE__*/_react2.default.createElement(_schemaSettings.GeneralSchemaDesigner, null, /*#__PURE__*/_react2.default.createElement(_GeneralSchemaItems.GeneralSchemaItems, null), !(form === null || form === void 0 ? void 0 : form.readPretty) && isFileField ? /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
260
169
  key: "quick-upload",
261
170
  title: t('Quick upload'),
262
- checked: ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.quickUpload) !== false,
171
+ checked: ((_fieldSchema$xCompon3 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : _fieldSchema$xCompon3.quickUpload) !== false,
263
172
  onChange: function onChange(value) {
264
173
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
265
174
  field.componentProps.quickUpload = value;
@@ -274,7 +183,7 @@ FormItem.Designer = function Designer() {
274
183
  }) : null, !(form === null || form === void 0 ? void 0 : form.readPretty) && isFileField ? /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
275
184
  key: "select-file",
276
185
  title: t('Select file'),
277
- checked: ((_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.selectFile) !== false,
186
+ checked: ((_fieldSchema$xCompon4 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.selectFile) !== false,
278
187
  onChange: function onChange(value) {
279
188
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
280
189
  field.componentProps.selectFile = value;
@@ -374,7 +283,7 @@ FormItem.Designer = function Designer() {
374
283
  }
375
284
  },
376
285
  onSubmit: function onSubmit(v) {
377
- var _collectionField$uiSc3;
286
+ var _collectionField$uiSc2;
378
287
  var rules = [];
379
288
  var _iterator = _createForOfIteratorHelper(v.rules),
380
289
  _step;
@@ -412,7 +321,7 @@ FormItem.Designer = function Designer() {
412
321
  _iterator2.f();
413
322
  }
414
323
  }
415
- var concatValidator = _lodash.default.concat([], (collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc3 = collectionField.uiSchema) === null || _collectionField$uiSc3 === void 0 ? void 0 : _collectionField$uiSc3['x-validator']) || [], rules);
324
+ var concatValidator = _lodash.default.concat([], (collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc2 = collectionField.uiSchema) === null || _collectionField$uiSc2 === void 0 ? void 0 : _collectionField$uiSc2['x-validator']) || [], rules);
416
325
  field.validator = concatValidator;
417
326
  fieldSchema['x-validator'] = rules;
418
327
  schema['x-validator'] = rules;
@@ -433,10 +342,10 @@ FormItem.Designer = function Designer() {
433
342
  type: 'object',
434
343
  title: t('Set default value'),
435
344
  properties: {
436
- default: (0, _variable.isInvariable)(interfaceConfig) ? _objectSpread(_objectSpread({}, fieldSchema || {}), {}, {
345
+ default: (0, _variable.isInvariable)(interfaceConfig) ? _objectSpread(_objectSpread({}, fieldSchemaWithoutRequired || {}), {}, {
437
346
  'x-decorator': 'FormItem',
438
347
  'x-component-props': _objectSpread(_objectSpread({}, fieldSchema['x-component-props']), {}, {
439
- component: (collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) && collectionField.interface !== 'chinaRegion' ? 'AssociationSelect' : undefined,
348
+ component: (collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) && (collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) !== 'chinaRegion' ? 'AssociationSelect' : undefined,
440
349
  service: {
441
350
  resource: collectionField === null || collectionField === void 0 ? void 0 : collectionField.target
442
351
  },
@@ -450,7 +359,7 @@ FormItem.Designer = function Designer() {
450
359
  default: getFieldDefaultValue(fieldSchema, collectionField),
451
360
  'x-read-pretty': false,
452
361
  'x-disabled': false
453
- }) : _objectSpread(_objectSpread({}, fieldSchema || {}), {}, {
362
+ }) : _objectSpread(_objectSpread({}, fieldSchemaWithoutRequired || {}), {}, {
454
363
  'x-decorator': 'FormItem',
455
364
  'x-component': 'VariableInput',
456
365
  'x-component-props': _objectSpread(_objectSpread({}, (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component-props']) || {}), {}, {
@@ -458,7 +367,7 @@ FormItem.Designer = function Designer() {
458
367
  schema: collectionField === null || collectionField === void 0 ? void 0 : collectionField.uiSchema,
459
368
  className: defaultInputStyle,
460
369
  renderSchemaComponent: function Com(props) {
461
- var s = _lodash.default.cloneDeep(fieldSchema) || {};
370
+ var s = _lodash.default.cloneDeep(fieldSchemaWithoutRequired) || {};
462
371
  s.title = '';
463
372
  s['x-read-pretty'] = false;
464
373
  s['x-disabled'] = false;
@@ -514,15 +423,15 @@ FormItem.Designer = function Designer() {
514
423
  }
515
424
  }
516
425
  },
517
- onSubmit: function onSubmit(_ref4) {
518
- var _schema6;
519
- var filter = _ref4.filter;
426
+ onSubmit: function onSubmit(_ref) {
427
+ var _schema5;
428
+ var filter = _ref.filter;
520
429
  filter = (0, _filter.removeNullCondition)(filter);
521
430
  _lodash.default.set(field.componentProps, 'service.params.filter', filter);
522
431
  fieldSchema['x-component-props'] = field.componentProps;
523
432
  field.componentProps = field.componentProps;
524
433
  dn.emit('patch', {
525
- schema: (_schema6 = {}, _defineProperty(_schema6, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema6, 'x-component-props', field.componentProps), _schema6)
434
+ schema: (_schema5 = {}, _defineProperty(_schema5, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema5, 'x-component-props', field.componentProps), _schema5)
526
435
  });
527
436
  }
528
437
  }), isSelectFieldMode && !field.readPretty && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.ModalItem, {
@@ -554,6 +463,7 @@ FormItem.Designer = function Designer() {
554
463
  field: {
555
464
  type: 'string',
556
465
  enum: sortFields,
466
+ required: true,
557
467
  'x-decorator': 'FormItem',
558
468
  'x-component': 'Select',
559
469
  'x-component-props': {
@@ -596,19 +506,19 @@ FormItem.Designer = function Designer() {
596
506
  }
597
507
  }
598
508
  },
599
- onSubmit: function onSubmit(_ref5) {
600
- var _schema7;
601
- var sort = _ref5.sort;
509
+ onSubmit: function onSubmit(_ref2) {
510
+ var _schema6;
511
+ var sort = _ref2.sort;
602
512
  var sortArr = sort.map(function (item) {
603
513
  return item.direction === 'desc' ? "-".concat(item.field) : item.field;
604
514
  });
605
515
  _lodash.default.set(field.componentProps, 'service.params.sort', sortArr);
606
516
  fieldSchema['x-component-props'] = field.componentProps;
607
517
  dn.emit('patch', {
608
- schema: (_schema7 = {}, _defineProperty(_schema7, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema7, 'x-component-props', field.componentProps), _schema7)
518
+ schema: (_schema6 = {}, _defineProperty(_schema6, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema6, 'x-component-props', field.componentProps), _schema6)
609
519
  });
610
520
  }
611
- }), isAssociationField && fieldModeOptions && !isTableField && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SelectItem, {
521
+ }), showFieldMode && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SelectItem, {
612
522
  key: "field-mode",
613
523
  title: t('Field mode'),
614
524
  options: fieldModeOptions,
@@ -620,20 +530,75 @@ FormItem.Designer = function Designer() {
620
530
  schema['x-component-props'] = fieldSchema['x-component-props'];
621
531
  field.componentProps = field.componentProps || {};
622
532
  field.componentProps.mode = mode;
623
- if (mode === 'Nester') {
624
- var initValue = ['o2m', 'm2m'].includes(collectionField.interface) ? [] : {};
625
- field.value = field.value || initValue;
626
- }
533
+ // if (mode === 'Nester') {
534
+ // const initValue = ['hasMany', 'belongsToMany'].includes(collectionField?.type) ? [{}] : {};
535
+ // field.value = field.value || initValue;
536
+ // }
627
537
  dn.emit('patch', {
628
538
  schema: schema
629
539
  });
630
540
  dn.refresh();
631
541
  }
632
- }), !field.readPretty && isAssociationField && ['Select', 'Picker'].includes(fieldMode) && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
542
+ }), showModeSelect && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.Item, null, /*#__PURE__*/_react2.default.createElement("div", {
543
+ style: {
544
+ alignItems: 'center',
545
+ display: 'flex',
546
+ justifyContent: 'space-between'
547
+ }
548
+ }, t('Popup size'), /*#__PURE__*/_react2.default.createElement(_antd2.Select, {
549
+ bordered: false,
550
+ options: [{
551
+ label: t('Small'),
552
+ value: 'small'
553
+ }, {
554
+ label: t('Middle'),
555
+ value: 'middle'
556
+ }, {
557
+ label: t('Large'),
558
+ value: 'large'
559
+ }],
560
+ value: (_fieldSchema$xCompon5 = fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon6 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon6 === void 0 ? void 0 : _fieldSchema$xCompon6['openSize']) !== null && _fieldSchema$xCompon5 !== void 0 ? _fieldSchema$xCompon5 : (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon7 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon7 === void 0 ? void 0 : _fieldSchema$xCompon7['openMode']) == 'modal' ? 'large' : 'middle',
561
+ onChange: function onChange(value) {
562
+ field.componentProps.openSize = value;
563
+ fieldSchema['x-component-props'] = field.componentProps;
564
+ dn.emit('patch', {
565
+ schema: {
566
+ 'x-uid': fieldSchema['x-uid'],
567
+ 'x-component-props': fieldSchema['x-component-props']
568
+ }
569
+ });
570
+ dn.refresh();
571
+ },
572
+ style: {
573
+ textAlign: 'right',
574
+ minWidth: 100
575
+ }
576
+ }))), !field.readPretty && isAssociationField && ['Select', 'Picker'].includes(fieldMode) && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
633
577
  key: "allowAddNew",
634
578
  title: t('Allow add new data'),
635
579
  checked: fieldSchema['x-add-new'],
636
580
  onChange: function onChange(allowAddNew) {
581
+ var hasAddNew = fieldSchema.reduceProperties(function (buf, schema) {
582
+ if (schema['x-component'] === 'Action') {
583
+ return schema;
584
+ }
585
+ return buf;
586
+ }, null);
587
+ if (!hasAddNew) {
588
+ var addNewActionschema = {
589
+ 'x-action': 'create',
590
+ title: "{{t('Add new')}}",
591
+ 'x-designer': 'Action.Designer',
592
+ 'x-component': 'Action',
593
+ 'x-decorator': 'ACLActionProvider',
594
+ 'x-component-props': {
595
+ openMode: 'drawer',
596
+ type: 'default',
597
+ component: 'CreateRecordAction'
598
+ }
599
+ };
600
+ insertAdjacent('afterBegin', addNewActionschema);
601
+ }
637
602
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
638
603
  field['x-add-new'] = allowAddNew;
639
604
  fieldSchema['x-add-new'] = allowAddNew;
@@ -643,10 +608,10 @@ FormItem.Designer = function Designer() {
643
608
  });
644
609
  refresh();
645
610
  }
646
- }), form && !(form === null || form === void 0 ? void 0 : form.readPretty) && ['o2m', 'm2m'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) && fieldSchema['x-component'] !== 'TableField' && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
611
+ }), IsShowMultipleSwitch() ? /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
647
612
  key: "multiple",
648
- title: t('Multiple'),
649
- checked: ((_fieldSchema$xCompon3 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : _fieldSchema$xCompon3.multiple) === undefined ? true : fieldSchema['x-component-props'].multiple,
613
+ title: t('Allow multiple'),
614
+ checked: ((_fieldSchema$xCompon8 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon8 === void 0 ? void 0 : _fieldSchema$xCompon8.multiple) === undefined ? true : fieldSchema['x-component-props'].multiple,
650
615
  onChange: function onChange(value) {
651
616
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
652
617
  fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
@@ -659,9 +624,25 @@ FormItem.Designer = function Designer() {
659
624
  });
660
625
  refresh();
661
626
  }
662
- }), field.readPretty && options.length > 0 && fieldSchema['x-component'] === 'CollectionField' && !isFileField && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
627
+ }) : null, IsShowMultipleSwitch() && isSubFormMode ? /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
628
+ key: "allowDissociate",
629
+ title: t('Allow dissociate'),
630
+ checked: ((_fieldSchema$xCompon9 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon9 === void 0 ? void 0 : _fieldSchema$xCompon9.allowDissociate) !== false,
631
+ onChange: function onChange(value) {
632
+ var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
633
+ fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
634
+ field.componentProps = field.componentProps || {};
635
+ fieldSchema['x-component-props'].allowDissociate = value;
636
+ field.componentProps.allowDissociate = value;
637
+ schema['x-component-props'] = fieldSchema['x-component-props'];
638
+ dn.emit('patch', {
639
+ schema: schema
640
+ });
641
+ refresh();
642
+ }
643
+ }) : null, field.readPretty && options.length > 0 && fieldSchema['x-component'] === 'CollectionField' && !isFileField && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SwitchItem, {
663
644
  title: t('Enable link'),
664
- checked: ((_fieldSchema$xCompon4 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.enableLink) !== false,
645
+ checked: ((_fieldSchema$xCompon10 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon10 === void 0 ? void 0 : _fieldSchema$xCompon10.enableLink) !== false,
665
646
  onChange: function onChange(flag) {
666
647
  fieldSchema['x-component-props'] = _objectSpread(_objectSpread({}, fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component-props']), {}, {
667
648
  enableLink: flag
@@ -727,15 +708,15 @@ FormItem.Designer = function Designer() {
727
708
  });
728
709
  dn.refresh();
729
710
  }
730
- }), options.length > 0 && fieldSchema['x-component'] === 'CollectionField' && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SelectItem, {
711
+ }), options.length > 0 && isAssociationField && /*#__PURE__*/_react2.default.createElement(_schemaSettings.SchemaSettings.SelectItem, {
731
712
  key: "title-field",
732
713
  title: t('Title field'),
733
714
  options: options,
734
715
  value: field === null || field === void 0 ? void 0 : (_field$componentProps8 = field.componentProps) === null || _field$componentProps8 === void 0 ? void 0 : (_field$componentProps9 = _field$componentProps8.fieldNames) === null || _field$componentProps9 === void 0 ? void 0 : _field$componentProps9.label,
735
716
  onChange: function onChange(label) {
736
- var _collectionField$uiSc4, _collectionField$uiSc5;
717
+ var _collectionField$uiSc3, _collectionField$uiSc4;
737
718
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
738
- var fieldNames = _objectSpread(_objectSpread(_objectSpread({}, collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc4 = collectionField.uiSchema) === null || _collectionField$uiSc4 === void 0 ? void 0 : (_collectionField$uiSc5 = _collectionField$uiSc4['x-component-props']) === null || _collectionField$uiSc5 === void 0 ? void 0 : _collectionField$uiSc5['fieldNames']), field.componentProps.fieldNames), {}, {
719
+ var fieldNames = _objectSpread(_objectSpread(_objectSpread({}, collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc3 = collectionField.uiSchema) === null || _collectionField$uiSc3 === void 0 ? void 0 : (_collectionField$uiSc4 = _collectionField$uiSc3['x-component-props']) === null || _collectionField$uiSc4 === void 0 ? void 0 : _collectionField$uiSc4['fieldNames']), field.componentProps.fieldNames), {}, {
739
720
  label: label
740
721
  });
741
722
  fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
@@ -763,9 +744,9 @@ function isFileCollection(collection) {
763
744
  }
764
745
  FormItem.FilterFormDesigner = _FormItem.FilterFormDesigner;
765
746
  function getFieldDefaultValue(fieldSchema, collectionField) {
766
- var _collectionField$uiSc6;
747
+ var _collectionField$uiSc5;
767
748
  var result = (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema.default) || (collectionField === null || collectionField === void 0 ? void 0 : collectionField.defaultValue);
768
- if ((collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc6 = collectionField.uiSchema) === null || _collectionField$uiSc6 === void 0 ? void 0 : _collectionField$uiSc6['x-component']) === 'DatePicker' && result) {
749
+ if ((collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc5 = collectionField.uiSchema) === null || _collectionField$uiSc5 === void 0 ? void 0 : _collectionField$uiSc5['x-component']) === 'DatePicker' && result) {
769
750
  return (0, _moment.default)(result);
770
751
  }
771
752
  return result;
@@ -378,11 +378,11 @@ var EditDefaultValue = function EditDefaultValue() {
378
378
  type: 'object',
379
379
  title: t('Set default value'),
380
380
  properties: {
381
- default: _objectSpread(_objectSpread({}, collectionField.uiSchema), {}, {
381
+ default: _objectSpread(_objectSpread({}, collectionField === null || collectionField === void 0 ? void 0 : collectionField.uiSchema), {}, {
382
382
  name: 'default',
383
383
  title: t('Default value'),
384
384
  'x-decorator': 'FormItem',
385
- default: fieldSchema.default || collectionField.defaultValue
385
+ default: fieldSchema.default || (collectionField === null || collectionField === void 0 ? void 0 : collectionField.defaultValue)
386
386
  })
387
387
  }
388
388
  },
@@ -576,7 +576,7 @@ var EditTitleField = function EditTitleField() {
576
576
  dn = _useDesignable10.dn;
577
577
  var compile = (0, _hooks.useCompile)();
578
578
  var collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
579
- var targetFields = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) ? getCollectionFields(collectionField.target) : (_getCollectionFields = getCollectionFields(collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetCollection)) !== null && _getCollectionFields !== void 0 ? _getCollectionFields : [];
579
+ var targetFields = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) ? getCollectionFields(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target) : (_getCollectionFields = getCollectionFields(collectionField === null || collectionField === void 0 ? void 0 : collectionField.targetCollection)) !== null && _getCollectionFields !== void 0 ? _getCollectionFields : [];
580
580
  var options = targetFields.filter(function (field) {
581
581
  return !(field === null || field === void 0 ? void 0 : field.target) && field.type !== 'boolean';
582
582
  }).map(function (field) {
@@ -171,6 +171,7 @@ var DetailsDesigner = function DetailsDesigner() {
171
171
  field: {
172
172
  type: 'string',
173
173
  enum: sortFields,
174
+ required: true,
174
175
  'x-decorator': 'FormItem',
175
176
  'x-component': 'Select',
176
177
  'x-component-props': {
@@ -1,3 +1,23 @@
1
+ export interface ITemplate {
2
+ config?: {
3
+ [key: string]: {
4
+ /** 设置的数据范围 */
5
+ filter?: any;
6
+ /** 设置的标题字段 */
7
+ titleField?: string;
8
+ };
9
+ };
10
+ items: {
11
+ key: string;
12
+ title: string;
13
+ collection: string;
14
+ dataId: number;
15
+ fields: string[];
16
+ default?: boolean;
17
+ }[];
18
+ /** 是否在 Form 区块显示模板选择器 */
19
+ display: boolean;
20
+ }
1
21
  export declare const Templates: ({ style, form }: {
2
22
  style?: {};
3
23
  form: any;
@@ -40,6 +40,24 @@ var useDataTemplates = function useDataTemplates() {
40
40
  items = _findDataTemplates$it === void 0 ? [] : _findDataTemplates$it,
41
41
  _findDataTemplates$di = _findDataTemplates.display,
42
42
  display = _findDataTemplates$di === void 0 ? true : _findDataTemplates$di;
43
+ var _useCollectionManager = (0, _collectionManager.useCollectionManager)(),
44
+ getCollectionJoinField = _useCollectionManager.getCollectionJoinField;
45
+ // 过滤掉已经被删除的字段
46
+ items.forEach(function (item) {
47
+ try {
48
+ var _item$fields;
49
+ item.fields = (_item$fields = item.fields) === null || _item$fields === void 0 ? void 0 : _item$fields.map(function (field) {
50
+ var joinField = getCollectionJoinField("".concat(item.collection, ".").concat(field));
51
+ if (joinField) {
52
+ return field;
53
+ }
54
+ return '';
55
+ }).filter(Boolean);
56
+ } catch (err) {
57
+ (0, _client.error)(err);
58
+ item.fields = [];
59
+ }
60
+ });
43
61
  var templates = [{
44
62
  key: 'none',
45
63
  title: t('None')
@@ -55,7 +73,9 @@ var useDataTemplates = function useDataTemplates() {
55
73
  templates: templates,
56
74
  display: display,
57
75
  defaultTemplate: defaultTemplate,
58
- enabled: items.length > 0
76
+ enabled: items.length > 0 && items.every(function (item) {
77
+ return item.dataId !== undefined;
78
+ })
59
79
  };
60
80
  };
61
81
  var Templates = function Templates(_ref) {
@@ -67,8 +87,6 @@ var Templates = function Templates(_ref) {
67
87
  display = _useDataTemplates.display,
68
88
  enabled = _useDataTemplates.enabled,
69
89
  defaultTemplate = _useDataTemplates.defaultTemplate;
70
- var _useCollectionManager = (0, _collectionManager.useCollectionManager)(),
71
- getCollectionField = _useCollectionManager.getCollectionField;
72
90
  var _React$useState = _react2.default.useState((defaultTemplate === null || defaultTemplate === void 0 ? void 0 : defaultTemplate.key) || 'none'),
73
91
  _React$useState2 = _slicedToArray(_React$useState, 2),
74
92
  value = _React$useState2[0],
@@ -77,15 +95,16 @@ var Templates = function Templates(_ref) {
77
95
  var _useTranslation2 = (0, _reactI18next.useTranslation)(),
78
96
  t = _useTranslation2.t;
79
97
  (0, _react2.useEffect)(function () {
80
- if (defaultTemplate) {
81
- fetchTemplateData(api, defaultTemplate).then(function (data) {
82
- if (form) {
98
+ if (enabled && defaultTemplate) {
99
+ fetchTemplateData(api, defaultTemplate, t).then(function (data) {
100
+ if (form && data) {
83
101
  (0, _client.forEach)(data, function (value, key) {
84
102
  if (value) {
85
103
  form.values[key] = value;
86
104
  }
87
105
  });
88
106
  }
107
+ return data;
89
108
  }).catch(function (err) {
90
109
  console.error(err);
91
110
  });
@@ -98,14 +117,19 @@ var Templates = function Templates(_ref) {
98
117
  case 0:
99
118
  setValue(value);
100
119
  if (option.key !== 'none') {
101
- fetchTemplateData(api, option).then(function (data) {
102
- if (form) {
120
+ fetchTemplateData(api, option, t).then(function (data) {
121
+ if (form && data) {
122
+ // 切换之前先把之前的数据清空
123
+ form.reset();
103
124
  (0, _client.forEach)(data, function (value, key) {
104
125
  if (value) {
105
126
  form.values[key] = value;
106
127
  }
107
128
  });
108
129
  }
130
+ return data;
131
+ }).catch(function (err) {
132
+ console.error(err);
109
133
  });
110
134
  } else {
111
135
  form === null || form === void 0 ? void 0 : form.reset();
@@ -158,14 +182,20 @@ function findDataTemplates(fieldSchema) {
158
182
  }
159
183
  return {};
160
184
  }
161
- function fetchTemplateData(_x4, _x5) {
185
+ function fetchTemplateData(_x4, _x5, _x6) {
162
186
  return _fetchTemplateData.apply(this, arguments);
163
187
  }
164
188
  function _fetchTemplateData() {
165
- _fetchTemplateData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(api, template) {
189
+ _fetchTemplateData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(api, template, t) {
166
190
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
167
191
  while (1) switch (_context2.prev = _context2.next) {
168
192
  case 0:
193
+ if (!(template.fields.length === 0)) {
194
+ _context2.next = 2;
195
+ break;
196
+ }
197
+ return _context2.abrupt("return");
198
+ case 2:
169
199
  return _context2.abrupt("return", api.resource(template.collection).get({
170
200
  filterByTk: template.dataId,
171
201
  fields: template.fields,
@@ -174,7 +204,7 @@ function _fetchTemplateData() {
174
204
  var _data$data;
175
205
  return (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.data;
176
206
  }));
177
- case 1:
207
+ case 3:
178
208
  case "end":
179
209
  return _context2.stop();
180
210
  }