@nocobase/client-v2 2.1.0-alpha.40 → 2.1.0-alpha.45

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 (278) hide show
  1. package/es/Application.d.ts +7 -0
  2. package/es/BaseApplication.d.ts +13 -0
  3. package/es/RouterManager.d.ts +1 -0
  4. package/es/collection-field-interface/CollectionFieldInterface.d.ts +51 -15
  5. package/es/collection-field-interface/CollectionFieldInterfaceManager.d.ts +82 -3
  6. package/es/collection-manager/field-configure.d.ts +80 -0
  7. package/es/collection-manager/field-validation.d.ts +43 -0
  8. package/es/collection-manager/filter-operators/index.d.ts +46 -0
  9. package/es/collection-manager/filter-operators/operators.d.ts +30 -0
  10. package/es/collection-manager/interfaces/checkbox.d.ts +1 -41
  11. package/es/collection-manager/interfaces/checkboxGroup.d.ts +12 -44
  12. package/es/collection-manager/interfaces/collection.d.ts +12 -51
  13. package/es/collection-manager/interfaces/color.d.ts +1 -16
  14. package/es/collection-manager/interfaces/createdAt.d.ts +1 -44
  15. package/es/collection-manager/interfaces/createdBy.d.ts +0 -4
  16. package/es/collection-manager/interfaces/dateOnly.d.ts +7 -44
  17. package/es/collection-manager/interfaces/datetime.d.ts +1 -44
  18. package/es/collection-manager/interfaces/datetimeNoTz.d.ts +1 -44
  19. package/es/collection-manager/interfaces/email.d.ts +1 -29
  20. package/es/collection-manager/interfaces/id.d.ts +1 -16
  21. package/es/collection-manager/interfaces/index.d.ts +2 -3
  22. package/es/collection-manager/interfaces/input.d.ts +1 -102
  23. package/es/collection-manager/interfaces/integer.d.ts +1 -95
  24. package/es/collection-manager/interfaces/json.d.ts +16 -7
  25. package/es/collection-manager/interfaces/m2m.d.ts +11 -19
  26. package/es/collection-manager/interfaces/m2o.d.ts +11 -19
  27. package/es/collection-manager/interfaces/markdown.d.ts +1 -63
  28. package/es/collection-manager/interfaces/multipleSelect.d.ts +12 -44
  29. package/es/collection-manager/interfaces/nanoid.d.ts +1 -34
  30. package/es/collection-manager/interfaces/number.d.ts +1 -87
  31. package/es/collection-manager/interfaces/o2m.d.ts +12 -24
  32. package/es/collection-manager/interfaces/obo.d.ts +207 -0
  33. package/es/collection-manager/interfaces/oho.d.ts +207 -0
  34. package/es/collection-manager/interfaces/password.d.ts +1 -56
  35. package/es/collection-manager/interfaces/percent.d.ts +1 -84
  36. package/es/collection-manager/interfaces/phone.d.ts +1 -25
  37. package/es/collection-manager/interfaces/properties/index.d.ts +0 -28
  38. package/es/collection-manager/interfaces/radioGroup.d.ts +1 -29
  39. package/es/collection-manager/interfaces/richText.d.ts +1 -63
  40. package/es/collection-manager/interfaces/select.d.ts +12 -44
  41. package/es/collection-manager/interfaces/snowflake-id.d.ts +1 -34
  42. package/es/collection-manager/interfaces/tableoid.d.ts +1 -10
  43. package/es/collection-manager/interfaces/textarea.d.ts +1 -51
  44. package/es/collection-manager/interfaces/time.d.ts +1 -16
  45. package/es/collection-manager/interfaces/types.d.ts +3 -12
  46. package/es/collection-manager/interfaces/unixTimestamp.d.ts +1 -44
  47. package/es/collection-manager/interfaces/updatedAt.d.ts +1 -44
  48. package/es/collection-manager/interfaces/updatedBy.d.ts +0 -4
  49. package/es/collection-manager/interfaces/url.d.ts +1 -20
  50. package/es/collection-manager/interfaces/uuid.d.ts +1 -34
  51. package/es/collection-manager/template-fields.d.ts +53 -0
  52. package/es/components/KeepAlive.d.ts +22 -0
  53. package/es/components/RouterBridge.d.ts +9 -0
  54. package/es/components/form/DialogFormLayout.d.ts +5 -29
  55. package/es/components/form/VariableInput.d.ts +53 -2
  56. package/es/components/form/filter/CollectionFilter.d.ts +49 -0
  57. package/es/components/form/filter/CollectionFilterItem.d.ts +49 -0
  58. package/es/components/form/filter/DateFilterDynamicComponent.d.ts +57 -0
  59. package/es/components/form/filter/FilterValueInput.d.ts +29 -0
  60. package/es/components/form/filter/index.d.ts +11 -0
  61. package/es/components/form/filter/useFilterActionProps.d.ts +96 -0
  62. package/es/components/form/index.d.ts +1 -0
  63. package/es/data-source/ExtendCollectionsProvider.d.ts +50 -0
  64. package/es/data-source/index.d.ts +9 -0
  65. package/es/flow/FlowPage.d.ts +2 -1
  66. package/es/flow/admin-shell/AdminLayoutRouteCoordinator.d.ts +8 -40
  67. package/es/flow/admin-shell/BaseLayoutModel.d.ts +89 -0
  68. package/es/flow/admin-shell/BaseLayoutRouteCoordinator.d.ts +74 -0
  69. package/es/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.d.ts +12 -0
  70. package/es/flow/admin-shell/admin-layout/AdminLayoutModel.d.ts +7 -92
  71. package/es/flow/admin-shell/admin-layout/AppListRender.d.ts +11 -0
  72. package/es/flow/admin-shell/admin-layout/index.d.ts +3 -0
  73. package/es/flow/admin-shell/admin-layout/useApplications.d.ts +3 -2
  74. package/es/flow/admin-shell/useAdminLayoutRoutePage.d.ts +2 -2
  75. package/es/flow/admin-shell/useLayoutRoutePage.d.ts +23 -0
  76. package/es/flow/components/FlowRoute.d.ts +10 -1
  77. package/es/flow/components/filter/index.d.ts +2 -0
  78. package/es/flow/components/filter/useFilterOptions.d.ts +66 -0
  79. package/es/flow/index.d.ts +4 -0
  80. package/es/flow/models/base/PageModel/PageModel.d.ts +3 -1
  81. package/es/flow/models/blocks/assign-form/assignFieldValuesFlow.d.ts +84 -0
  82. package/es/flow/models/blocks/assign-form/index.d.ts +1 -0
  83. package/es/flow/models/blocks/form/FormActionGroupModel.d.ts +1 -0
  84. package/es/flow/models/blocks/form/FormActionModel.d.ts +9 -2
  85. package/es/flow/models/blocks/table/TableBlockModel.d.ts +10 -0
  86. package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.d.ts +1 -1
  87. package/es/flow-compat/passwordUtils.d.ts +1 -1
  88. package/es/index.d.ts +6 -0
  89. package/es/index.mjs +552 -459
  90. package/es/layout-manager/LayoutContentRoute.d.ts +14 -0
  91. package/es/layout-manager/LayoutManager.d.ts +22 -0
  92. package/es/layout-manager/LayoutRoute.d.ts +14 -0
  93. package/es/layout-manager/index.d.ts +13 -0
  94. package/es/layout-manager/types.d.ts +20 -0
  95. package/es/layout-manager/utils.d.ts +14 -0
  96. package/es/nocobase-buildin-plugin/index.d.ts +3 -10
  97. package/es/settings-center/index.d.ts +1 -1
  98. package/es/settings-center/plugin-manager/BulkEnableButton.d.ts +15 -0
  99. package/es/settings-center/plugin-manager/PluginCard.d.ts +15 -0
  100. package/es/settings-center/plugin-manager/PluginDetail.d.ts +16 -0
  101. package/es/settings-center/{PluginManagerPage.d.ts → plugin-manager/index.d.ts} +1 -7
  102. package/es/settings-center/plugin-manager/types.d.ts +34 -0
  103. package/lib/index.js +552 -459
  104. package/package.json +8 -7
  105. package/src/Application.tsx +51 -12
  106. package/src/BaseApplication.tsx +32 -0
  107. package/src/PluginSettingsManager.ts +1 -1
  108. package/src/RouterManager.tsx +17 -1
  109. package/src/__tests__/PluginSettingsManager.test.ts +41 -2
  110. package/src/__tests__/app.test.tsx +17 -1
  111. package/src/__tests__/globalDeps.test.ts +1 -0
  112. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +45 -2
  113. package/src/__tests__/plugin-manager.test.tsx +177 -0
  114. package/src/__tests__/settings-center.test.tsx +24 -2
  115. package/src/collection-field-interface/CollectionFieldInterface.ts +71 -77
  116. package/src/collection-field-interface/CollectionFieldInterfaceManager.ts +201 -4
  117. package/src/collection-manager/field-configure.ts +548 -0
  118. package/src/collection-manager/field-validation.ts +195 -0
  119. package/src/collection-manager/filter-operators/index.ts +176 -0
  120. package/src/collection-manager/{interfaces/properties → filter-operators}/operators.ts +24 -13
  121. package/src/collection-manager/interfaces/checkbox.ts +2 -9
  122. package/src/collection-manager/interfaces/checkboxGroup.ts +2 -10
  123. package/src/collection-manager/interfaces/collection.ts +2 -15
  124. package/src/collection-manager/interfaces/color.ts +2 -2
  125. package/src/collection-manager/interfaces/createdAt.ts +2 -2
  126. package/src/collection-manager/interfaces/createdBy.ts +1 -12
  127. package/src/collection-manager/interfaces/dateOnly.ts +8 -2
  128. package/src/collection-manager/interfaces/datetime.ts +2 -2
  129. package/src/collection-manager/interfaces/datetimeNoTz.ts +2 -2
  130. package/src/collection-manager/interfaces/email.ts +2 -9
  131. package/src/collection-manager/interfaces/id.ts +1 -2
  132. package/src/collection-manager/interfaces/index.ts +2 -3
  133. package/src/collection-manager/interfaces/input.ts +2 -133
  134. package/src/collection-manager/interfaces/integer.ts +2 -71
  135. package/src/collection-manager/interfaces/json.tsx +17 -11
  136. package/src/collection-manager/interfaces/m2m.tsx +0 -21
  137. package/src/collection-manager/interfaces/m2o.tsx +0 -22
  138. package/src/collection-manager/interfaces/markdown.ts +2 -51
  139. package/src/collection-manager/interfaces/multipleSelect.ts +2 -14
  140. package/src/collection-manager/interfaces/nanoid.ts +2 -2
  141. package/src/collection-manager/interfaces/number.ts +2 -85
  142. package/src/collection-manager/interfaces/o2m.tsx +1 -22
  143. package/src/collection-manager/interfaces/obo.tsx +145 -0
  144. package/src/collection-manager/interfaces/oho.tsx +145 -0
  145. package/src/collection-manager/interfaces/password.ts +2 -44
  146. package/src/collection-manager/interfaces/percent.ts +2 -74
  147. package/src/collection-manager/interfaces/phone.ts +2 -2
  148. package/src/collection-manager/interfaces/properties/index.ts +0 -133
  149. package/src/collection-manager/interfaces/radioGroup.ts +2 -2
  150. package/src/collection-manager/interfaces/richText.ts +2 -51
  151. package/src/collection-manager/interfaces/select.ts +2 -14
  152. package/src/collection-manager/interfaces/snowflake-id.ts +2 -2
  153. package/src/collection-manager/interfaces/tableoid.ts +1 -2
  154. package/src/collection-manager/interfaces/textarea.ts +2 -51
  155. package/src/collection-manager/interfaces/time.ts +2 -2
  156. package/src/collection-manager/interfaces/types.ts +4 -12
  157. package/src/collection-manager/interfaces/unixTimestamp.tsx +2 -2
  158. package/src/collection-manager/interfaces/updatedAt.ts +2 -2
  159. package/src/collection-manager/interfaces/updatedBy.ts +1 -12
  160. package/src/collection-manager/interfaces/url.ts +2 -4
  161. package/src/collection-manager/interfaces/uuid.ts +2 -2
  162. package/src/collection-manager/template-fields.ts +109 -0
  163. package/src/components/KeepAlive.tsx +131 -0
  164. package/src/components/README.md +90 -6
  165. package/src/components/README.zh-CN.md +90 -7
  166. package/src/components/RouterBridge.tsx +28 -4
  167. package/src/components/__tests__/KeepAlive.test.tsx +63 -0
  168. package/src/components/__tests__/RouterBridge.test.tsx +27 -0
  169. package/src/components/form/DialogFormLayout.tsx +5 -29
  170. package/src/components/form/VariableInput.tsx +101 -28
  171. package/src/components/form/__tests__/VariableInput.test.ts +85 -0
  172. package/src/components/form/filter/CollectionFilter.tsx +111 -0
  173. package/src/components/form/filter/CollectionFilterItem.tsx +184 -0
  174. package/src/components/form/filter/DateFilterDynamicComponent.tsx +283 -0
  175. package/src/components/form/filter/FilterValueInput.tsx +198 -0
  176. package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +247 -0
  177. package/src/components/form/filter/__tests__/DateFilterDynamicComponent.test.tsx +148 -0
  178. package/src/components/form/filter/__tests__/FilterValueInput.test.tsx +243 -0
  179. package/src/components/form/filter/__tests__/compileFilterGroup.test.ts +146 -0
  180. package/src/components/form/filter/index.ts +13 -0
  181. package/src/components/form/filter/useFilterActionProps.ts +203 -0
  182. package/src/components/form/index.tsx +1 -0
  183. package/src/data-source/ExtendCollectionsProvider.tsx +144 -0
  184. package/src/data-source/__tests__/ExtendCollectionsProvider.test.tsx +264 -0
  185. package/src/data-source/index.ts +10 -0
  186. package/src/flow/FlowPage.tsx +35 -7
  187. package/src/flow/__tests__/FlowPage.test.tsx +79 -0
  188. package/src/flow/__tests__/FlowRoute.test.tsx +529 -2
  189. package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +191 -0
  190. package/src/flow/actions/__tests__/openView.subModelKey.test.tsx +33 -0
  191. package/src/flow/actions/aclCheck.tsx +4 -0
  192. package/src/flow/actions/aclCheckRefresh.tsx +4 -0
  193. package/src/flow/actions/dateTimeFormat.tsx +12 -8
  194. package/src/flow/actions/linkageRules.tsx +122 -0
  195. package/src/flow/actions/openView.tsx +28 -4
  196. package/src/flow/admin-shell/AdminLayoutRouteCoordinator.ts +11 -329
  197. package/src/flow/admin-shell/BaseLayoutModel.tsx +455 -0
  198. package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +502 -0
  199. package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +547 -3
  200. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +35 -7
  201. package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +160 -0
  202. package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +0 -12
  203. package/src/flow/admin-shell/admin-layout/AdminLayoutModel.tsx +28 -201
  204. package/src/flow/admin-shell/admin-layout/AdminLayoutSlotModels.tsx +11 -2
  205. package/src/flow/admin-shell/admin-layout/AppListRender.tsx +139 -0
  206. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +1 -26
  207. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +149 -27
  208. package/src/flow/admin-shell/admin-layout/index.ts +3 -0
  209. package/src/flow/admin-shell/admin-layout/useApplications.tsx +34 -1
  210. package/src/flow/admin-shell/useAdminLayoutRoutePage.ts +10 -26
  211. package/src/flow/admin-shell/useLayoutRoutePage.ts +61 -0
  212. package/src/flow/components/AdminLayout.tsx +4 -154
  213. package/src/flow/components/FlowRoute.tsx +105 -15
  214. package/src/flow/components/filter/index.ts +3 -0
  215. package/src/flow/components/filter/useFilterOptions.ts +102 -0
  216. package/src/flow/index.ts +4 -0
  217. package/src/flow/models/actions/UpdateRecordActionModel.tsx +14 -95
  218. package/src/flow/models/actions/UpdateRecordActionUtils.ts +4 -7
  219. package/src/flow/models/actions/__tests__/AssignFormRefill.test.ts +26 -1
  220. package/src/flow/models/base/ActionModel.tsx +8 -1
  221. package/src/flow/models/base/PageModel/PageModel.tsx +51 -18
  222. package/src/flow/models/base/PageModel/RootPageModel.tsx +6 -13
  223. package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +102 -1
  224. package/src/flow/models/base/RouteModel.tsx +1 -1
  225. package/src/flow/models/blocks/assign-form/AssignFormItemModel.tsx +63 -2
  226. package/src/flow/models/blocks/assign-form/assignFieldValuesFlow.tsx +206 -0
  227. package/src/flow/models/blocks/assign-form/index.ts +1 -0
  228. package/src/flow/models/blocks/form/FormActionGroupModel.tsx +14 -0
  229. package/src/flow/models/blocks/form/FormActionModel.tsx +30 -3
  230. package/src/flow/models/blocks/form/FormItemModel.tsx +8 -1
  231. package/src/flow/models/blocks/form/__tests__/FormActionGroupModel.test.ts +46 -0
  232. package/src/flow/models/blocks/form/__tests__/submitHandler.test.ts +71 -0
  233. package/src/flow/models/blocks/form/submitHandler.ts +8 -1
  234. package/src/flow/models/blocks/form/submitValues.ts +4 -1
  235. package/src/flow/models/blocks/table/TableBlockModel.tsx +118 -16
  236. package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowSelection.test.tsx +114 -0
  237. package/src/flow/models/fields/AssociationFieldModel/SubFormFieldModel.tsx +7 -1
  238. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.tsx +1 -1
  239. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.tsx +6 -5
  240. package/src/flow/models/fields/ClickableFieldModel.tsx +9 -1
  241. package/src/flow/models/fields/CollectionSelectorFieldModel.tsx +8 -2
  242. package/src/flow/models/fields/DisplayEnumFieldModel.tsx +8 -2
  243. package/src/flow/models/fields/DisplayTimeFieldModel.tsx +1 -1
  244. package/src/flow/models/fields/TimeFieldModel.tsx +1 -1
  245. package/src/flow/models/fields/__tests__/TimeFieldModel.test.tsx +61 -0
  246. package/src/flow/models/fields/mobile-components/MobileDatePicker.tsx +19 -3
  247. package/src/flow/models/fields/mobile-components/__tests__/MobileDatePicker.test.tsx +94 -0
  248. package/src/flow/models/topbar/TopbarActionModel.tsx +1 -1
  249. package/src/flow/utils/__tests__/dateTimeFormat.test.ts +91 -0
  250. package/src/index.ts +6 -0
  251. package/src/layout-manager/LayoutContentRoute.tsx +90 -0
  252. package/src/layout-manager/LayoutManager.tsx +185 -0
  253. package/src/layout-manager/LayoutRoute.tsx +138 -0
  254. package/src/layout-manager/__tests__/LayoutManager.test.tsx +335 -0
  255. package/src/layout-manager/__tests__/LayoutRoute.test.tsx +473 -0
  256. package/src/layout-manager/index.ts +14 -0
  257. package/src/layout-manager/types.ts +22 -0
  258. package/src/layout-manager/utils.ts +37 -0
  259. package/src/nocobase-buildin-plugin/index.tsx +69 -67
  260. package/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts +1 -0
  261. package/src/settings-center/index.ts +1 -1
  262. package/src/settings-center/plugin-manager/BulkEnableButton.tsx +111 -0
  263. package/src/settings-center/plugin-manager/PluginCard.tsx +270 -0
  264. package/src/settings-center/plugin-manager/PluginDetail.tsx +195 -0
  265. package/src/settings-center/plugin-manager/index.tsx +254 -0
  266. package/src/settings-center/plugin-manager/types.ts +35 -0
  267. package/src/settings-center/utils.tsx +8 -1
  268. package/src/theme/__tests__/globalStyles.test.ts +24 -0
  269. package/src/theme/globalStyles.ts +10 -0
  270. package/src/utils/globalDeps.ts +2 -0
  271. package/es/collection-manager/interfaces/linkTo.d.ts +0 -90
  272. package/es/collection-manager/interfaces/o2o.d.ts +0 -621
  273. package/es/collection-manager/interfaces/properties/operators.d.ts +0 -294
  274. package/es/collection-manager/interfaces/subTable.d.ts +0 -172
  275. package/src/collection-manager/interfaces/linkTo.ts +0 -120
  276. package/src/collection-manager/interfaces/o2o.tsx +0 -561
  277. package/src/collection-manager/interfaces/subTable.ts +0 -218
  278. package/src/settings-center/PluginManagerPage.tsx +0 -162
@@ -7,14 +7,10 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { Field } from '@formily/core';
11
10
  import { ISchema } from '@formily/react';
12
- import { uid } from '@formily/shared';
13
11
  import { css } from '@emotion/css';
14
12
  import { DateFormatCom } from '../../../flow/components/ExpiresRadio';
15
13
 
16
- export * as operators from './operators';
17
-
18
14
  export const type: ISchema = {
19
15
  type: 'string',
20
16
  title: '{{t("Storage type")}}',
@@ -51,17 +47,6 @@ export const unique = {
51
47
  'x-decorator': 'FormItem',
52
48
  'x-component': 'Checkbox',
53
49
  'x-disabled': '{{ !createMainOnly || primaryKeyOnly }}',
54
- 'x-reactions': [
55
- {
56
- dependencies: ['primaryKey'],
57
- when: '{{$deps[0]}}',
58
- fulfill: {
59
- state: {
60
- value: false,
61
- },
62
- },
63
- },
64
- ],
65
50
  };
66
51
  export const primaryKey = {
67
52
  type: 'boolean',
@@ -69,17 +54,6 @@ export const primaryKey = {
69
54
  'x-decorator': 'FormItem',
70
55
  'x-component': 'Checkbox',
71
56
  'x-disabled': '{{ !createMainOnly || primaryKeyOnly }}',
72
- 'x-reactions': [
73
- {
74
- dependencies: ['unique'],
75
- when: '{{$deps[0]&&createMainOnly}}',
76
- fulfill: {
77
- state: {
78
- value: false,
79
- },
80
- },
81
- },
82
- ],
83
57
  };
84
58
 
85
59
  export const autoIncrement = {
@@ -89,17 +63,6 @@ export const autoIncrement = {
89
63
  'x-decorator': 'FormItem',
90
64
  'x-component': 'Checkbox',
91
65
  'x-disabled': '{{ !createMainOnly }}',
92
- 'x-reactions': [
93
- {
94
- dependencies: ['primaryKey'],
95
- when: '{{$deps[0]&&createMainOnly}}',
96
- fulfill: {
97
- state: {
98
- value: true,
99
- },
100
- },
101
- },
102
- ],
103
66
  };
104
67
 
105
68
  export const autoFill = {
@@ -155,56 +118,6 @@ export const reverseFieldProperties: Record<string, ISchema> = {
155
118
  'x-decorator': 'FormItem',
156
119
  'x-component': 'Checkbox',
157
120
  'x-content': '{{t("Create inverse field in the target collection")}}',
158
- 'x-reactions': [
159
- {
160
- target: 'reverseField.type',
161
- when: '{{!!$self.value}}',
162
- fulfill: {
163
- state: {
164
- hidden: false,
165
- },
166
- },
167
- otherwise: {
168
- state: {
169
- hidden: true,
170
- },
171
- },
172
- },
173
- {
174
- target: 'reverseField.uiSchema.title',
175
- when: '{{!!$self.value}}',
176
- fulfill: {
177
- state: {
178
- hidden: false,
179
- },
180
- },
181
- otherwise: {
182
- state: {
183
- hidden: true,
184
- },
185
- },
186
- },
187
- {
188
- target: 'reverseField.name',
189
- when: '{{!!$self.value}}',
190
- fulfill: {
191
- state: {
192
- hidden: false,
193
- },
194
- },
195
- otherwise: {
196
- state: {
197
- hidden: true,
198
- },
199
- },
200
- },
201
- (field) => {
202
- const values = field.form.values;
203
- const { reverseField } = values;
204
- field.value = !!reverseField?.key;
205
- field.disabled = !!reverseField?.key;
206
- },
207
- ],
208
121
  },
209
122
  'reverseField.type': {
210
123
  ...relationshipType,
@@ -308,44 +221,12 @@ export const dateTimeProps: { [key: string]: ISchema } = {
308
221
  value: 'custom',
309
222
  },
310
223
  ],
311
- 'x-reactions': {
312
- dependencies: ['uiSchema.x-component-props.picker'],
313
- fulfill: {
314
- state: {
315
- value: `{{ getPickerFormat($deps[0])}}`,
316
- componentProps: { picker: `{{$deps[0]}}` },
317
- },
318
- },
319
- },
320
224
  },
321
225
  'uiSchema.x-component-props.showTime': {
322
226
  type: 'boolean',
323
227
  'x-decorator': 'FormItem',
324
228
  'x-component': 'Checkbox',
325
229
  'x-content': '{{t("Show time")}}',
326
- 'x-reactions': [
327
- `{{(field) => {
328
- field.query('..[].timeFormat').take(f => {
329
- f.display = field.value ? 'visible' : 'none';
330
- f.value='HH:mm:ss'
331
- });
332
- }}}`,
333
- {
334
- dependencies: ['uiSchema.x-component-props.picker'],
335
- when: '{{$deps[0]==="date"}}',
336
- fulfill: {
337
- state: {
338
- hidden: false,
339
- },
340
- },
341
- otherwise: {
342
- state: {
343
- hidden: true,
344
- value: false,
345
- },
346
- },
347
- },
348
- ],
349
230
  },
350
231
  'uiSchema.x-component-props.timeFormat': {
351
232
  type: 'string',
@@ -363,14 +244,6 @@ export const dateTimeProps: { [key: string]: ISchema } = {
363
244
  value: 'HH:mm:ss',
364
245
  },
365
246
  ],
366
- 'x-reactions': {
367
- dependencies: ['uiSchema.x-component-props.showTime'],
368
- fulfill: {
369
- state: {
370
- hidden: `{{ !$deps[0] }}`,
371
- },
372
- },
373
- },
374
247
  },
375
248
  };
376
249
 
@@ -446,12 +319,6 @@ export const dataSource: ISchema = {
446
319
  required: true,
447
320
  'x-decorator': 'FormItem',
448
321
  'x-component': 'Input',
449
- 'x-reactions': (field: Field) => {
450
- if (!field.initialValue && !field.initialized) {
451
- field.initialValue = uid();
452
- field.setValue(uid());
453
- }
454
- },
455
322
  },
456
323
  },
457
324
  },
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
11
- import { dataSource, defaultProps, operators } from './properties';
11
+ import { dataSource, defaultProps } from './properties';
12
12
 
13
13
  export class RadioGroupFieldInterface extends CollectionFieldInterface {
14
14
  name = 'radioGroup';
@@ -31,7 +31,7 @@ export class RadioGroupFieldInterface extends CollectionFieldInterface {
31
31
  'uiSchema.enum': dataSource,
32
32
  };
33
33
  filterable = {
34
- operators: operators.enumType,
34
+ operators: 'enumType',
35
35
  };
36
36
  titleUsable = true;
37
37
  }
@@ -7,9 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import type { ISchema } from '@formily/react';
11
- import { i18n } from '../../i18n';
12
- import { defaultProps, operators } from './properties';
10
+ import { defaultProps } from './properties';
13
11
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
14
12
 
15
13
  export class RichTextFieldInterface extends CollectionFieldInterface {
@@ -31,54 +29,7 @@ export class RichTextFieldInterface extends CollectionFieldInterface {
31
29
  properties = {
32
30
  ...defaultProps,
33
31
  };
34
- schemaInitialize(schema: ISchema, { block }) {
35
- if (['Table', 'Kanban'].includes(block)) {
36
- schema['x-component-props'] = schema['x-component-props'] || {};
37
- schema['x-component-props']['ellipsis'] = true;
38
- }
39
- }
40
- validateSchema = (fieldSchema) => {
41
- return {
42
- max: {
43
- type: 'number',
44
- title: '{{ t("Max length") }}',
45
- minimum: 0,
46
- 'x-decorator': 'FormItem',
47
- 'x-component': 'InputNumber',
48
- 'x-component-props': {
49
- precision: 0,
50
- },
51
- 'x-reactions': `{{(field) => {
52
- const targetValue = field.query('.min').value();
53
- field.selfErrors =
54
- !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
55
- 'Max length must greater than min length',
56
- )}' : ''
57
- }}}`,
58
- },
59
- min: {
60
- type: 'number',
61
- title: '{{ t("Min length") }}',
62
- minimum: 0,
63
- 'x-decorator': 'FormItem',
64
- 'x-component': 'InputNumber',
65
- 'x-component-props': {
66
- precision: 0,
67
- },
68
- 'x-reactions': {
69
- dependencies: ['.max'],
70
- fulfill: {
71
- state: {
72
- selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
73
- 'Min length must less than max length',
74
- )}' : ''}}`,
75
- },
76
- },
77
- },
78
- },
79
- };
80
- };
81
32
  filterable = {
82
- operators: operators.bigField,
33
+ operators: 'bigField',
83
34
  };
84
35
  }
@@ -7,8 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { ISchema } from '@formily/react';
11
- import { dataSource, defaultProps, operators } from './properties';
10
+ import { dataSource, defaultProps } from './properties';
12
11
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
13
12
 
14
13
  export class SelectFieldInterface extends CollectionFieldInterface {
@@ -33,18 +32,7 @@ export class SelectFieldInterface extends CollectionFieldInterface {
33
32
  'uiSchema.enum': dataSource,
34
33
  };
35
34
  filterable = {
36
- operators: operators.enumType,
35
+ operators: 'enumType',
37
36
  };
38
37
  titleUsable = true;
39
- schemaInitialize(schema: ISchema, { block }) {
40
- const props = (schema['x-component-props'] = schema['x-component-props'] || {});
41
- props.style = {
42
- ...(props.style || {}),
43
- width: '100%',
44
- };
45
-
46
- if (['Table', 'Kanban'].includes(block)) {
47
- props['ellipsis'] = true;
48
- }
49
- }
50
38
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
11
- import { defaultProps, operators, unique, primaryKey } from './properties';
11
+ import { defaultProps, unique, primaryKey } from './properties';
12
12
 
13
13
  export class SnowflakeIdFieldInterface extends CollectionFieldInterface {
14
14
  name = 'snowflakeId';
@@ -52,7 +52,7 @@ export class SnowflakeIdFieldInterface extends CollectionFieldInterface {
52
52
  },
53
53
  };
54
54
  filterable = {
55
- operators: operators.number,
55
+ operators: 'number',
56
56
  };
57
57
 
58
58
  description =
@@ -8,7 +8,6 @@
8
8
  */
9
9
 
10
10
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
11
- import { operators } from './properties';
12
11
 
13
12
  export class TableoidFieldInterface extends CollectionFieldInterface {
14
13
  name = 'tableoid';
@@ -48,6 +47,6 @@ export class TableoidFieldInterface extends CollectionFieldInterface {
48
47
  },
49
48
  };
50
49
  filterable = {
51
- operators: operators.tableoid,
50
+ operators: 'tableoid',
52
51
  };
53
52
  }
@@ -7,9 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { ISchema } from '@formily/react';
11
- import { i18n } from '../../i18n';
12
- import { defaultProps, operators } from './properties';
10
+ import { defaultProps } from './properties';
13
11
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
14
12
 
15
13
  export class TextareaFieldInterface extends CollectionFieldInterface {
@@ -40,54 +38,7 @@ export class TextareaFieldInterface extends CollectionFieldInterface {
40
38
  'x-component': 'Checkbox',
41
39
  },
42
40
  };
43
- schemaInitialize(schema: ISchema, { block }) {
44
- if (['Table', 'Kanban'].includes(block)) {
45
- schema['x-component-props'] = schema['x-component-props'] || {};
46
- schema['x-component-props']['ellipsis'] = true;
47
- }
48
- }
49
- validateSchema = (fieldSchema) => {
50
- return {
51
- max: {
52
- type: 'number',
53
- title: '{{ t("Max length") }}',
54
- minimum: 0,
55
- 'x-decorator': 'FormItem',
56
- 'x-component': 'InputNumber',
57
- 'x-component-props': {
58
- precision: 0,
59
- },
60
- 'x-reactions': `{{(field) => {
61
- const targetValue = field.query('.min').value();
62
- field.selfErrors =
63
- !!targetValue && !!field.value && targetValue > field.value ? '${i18n.t(
64
- 'Max length must greater than min length',
65
- )}' : ''
66
- }}}`,
67
- },
68
- min: {
69
- type: 'number',
70
- title: '{{ t("Min length") }}',
71
- minimum: 0,
72
- 'x-decorator': 'FormItem',
73
- 'x-component': 'InputNumber',
74
- 'x-component-props': {
75
- precision: 0,
76
- },
77
- 'x-reactions': {
78
- dependencies: ['.max'],
79
- fulfill: {
80
- state: {
81
- selfErrors: `{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '${i18n.t(
82
- 'Min length must less than max length',
83
- )}' : ''}}`,
84
- },
85
- },
86
- },
87
- },
88
- };
89
- };
90
41
  filterable = {
91
- operators: operators.string,
42
+ operators: 'string',
92
43
  };
93
44
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
11
- import { defaultProps, operators, timeProps } from './properties';
11
+ import { defaultProps, timeProps } from './properties';
12
12
 
13
13
  export class TimeFieldInterface extends CollectionFieldInterface {
14
14
  name = 'time';
@@ -31,7 +31,7 @@ export class TimeFieldInterface extends CollectionFieldInterface {
31
31
  ...timeProps,
32
32
  };
33
33
  filterable = {
34
- operators: operators.time,
34
+ operators: 'time',
35
35
  };
36
36
  titleUsable = true;
37
37
  }
@@ -9,6 +9,8 @@
9
9
 
10
10
  import { ISchema } from '@formily/react';
11
11
 
12
+ import type { FieldFilterable, FieldFilterOperator } from '../filter-operators';
13
+
12
14
  interface IDefault {
13
15
  type: string;
14
16
  uiSchema?: ISchema;
@@ -19,22 +21,12 @@ export interface IField extends ISchema {
19
21
  group?: string;
20
22
  order?: number;
21
23
  default?: IDefault;
22
- operators?: any[];
24
+ operators?: FieldFilterOperator[];
23
25
  /**
24
26
  * - 如果该值为空,则在 Filter 组件中该字段会被过滤掉
25
27
  * - 如果该值为空,则不会在变量列表中看到该字段
26
28
  */
27
- filterable?: {
28
- /**
29
- * 字段所支持的操作符,会在 Filter 组件中显示,比如设置 `数据范围` 的时候可以看见
30
- */
31
- operators?: any[];
32
- /**
33
- * 为当前字段添加子选项,这个子选项会在 Filter 组件中显示,比如设置 `数据范围` 的时候可以看见
34
- */
35
- children?: any[];
36
- [key: string]: any;
37
- };
29
+ filterable?: FieldFilterable;
38
30
  // NOTE: set to `true` means field could be used as a title field
39
31
  titleUsable?: boolean;
40
32
  [key: string]: any;
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
11
- import { defaultProps, operators, dateTimeProps } from './properties';
11
+ import { defaultProps, dateTimeProps } from './properties';
12
12
  export class UnixTimestampFieldInterface extends CollectionFieldInterface {
13
13
  name = 'unixTimestamp';
14
14
  type = 'object';
@@ -62,7 +62,7 @@ export class UnixTimestampFieldInterface extends CollectionFieldInterface {
62
62
  },
63
63
  };
64
64
  filterable = {
65
- operators: operators.datetime,
65
+ operators: 'datetime',
66
66
  };
67
67
  titleUsable = true;
68
68
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
11
- import { dateTimeProps, defaultProps, operators } from './properties';
11
+ import { dateTimeProps, defaultProps } from './properties';
12
12
 
13
13
  export class UpdatedAtFieldInterface extends CollectionFieldInterface {
14
14
  name = 'updatedAt';
@@ -35,7 +35,7 @@ export class UpdatedAtFieldInterface extends CollectionFieldInterface {
35
35
  ...dateTimeProps,
36
36
  };
37
37
  filterable = {
38
- operators: operators.datetime,
38
+ operators: 'datetime',
39
39
  };
40
40
  titleUsable = true;
41
41
  }
@@ -7,10 +7,8 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { ISchema } from '@formily/react';
11
- import { cloneDeep } from 'lodash';
12
10
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
13
- import { defaultProps, recordPickerViewer } from './properties';
11
+ import { defaultProps } from './properties';
14
12
 
15
13
  export class UpdatedByFieldInterface extends CollectionFieldInterface {
16
14
  name = 'updatedBy';
@@ -66,14 +64,5 @@ export class UpdatedByFieldInterface extends CollectionFieldInterface {
66
64
  // },
67
65
  // ],
68
66
  };
69
- schemaInitialize(schema: ISchema, { block }) {
70
- schema['properties'] = {
71
- viewer: cloneDeep(recordPickerViewer),
72
- };
73
- if (['Table', 'Kanban'].includes(block)) {
74
- schema['x-component-props'] = schema['x-component-props'] || {};
75
- schema['x-component-props']['ellipsis'] = true;
76
- }
77
- }
78
67
  description = '{{t("Store the last update user of each record")}}';
79
68
  }
@@ -7,8 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { ISchema } from '@formily/react';
11
- import { defaultProps, operators } from './properties';
10
+ import { defaultProps } from './properties';
12
11
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
13
12
 
14
13
  export class UrlFieldInterface extends CollectionFieldInterface {
@@ -35,7 +34,6 @@ export class UrlFieldInterface extends CollectionFieldInterface {
35
34
  },
36
35
  ];
37
36
  availableTypes = ['string', 'text'];
38
- schemaInitialize(schema: ISchema, { block }) {}
39
37
  validationType = 'string';
40
38
  availableValidationOptions = ['uri', 'pattern'];
41
39
  properties = {
@@ -43,6 +41,6 @@ export class UrlFieldInterface extends CollectionFieldInterface {
43
41
  };
44
42
  titleUsable = true;
45
43
  filterable = {
46
- operators: operators.string,
44
+ operators: 'string',
47
45
  };
48
46
  }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import { CollectionFieldInterface } from '../../collection-field-interface/CollectionFieldInterface';
11
- import { operators, autoFill, primaryKey, unique } from './properties';
11
+ import { autoFill, primaryKey, unique } from './properties';
12
12
 
13
13
  export class UUIDFieldInterface extends CollectionFieldInterface {
14
14
  name = 'uuid';
@@ -66,7 +66,7 @@ export class UUIDFieldInterface extends CollectionFieldInterface {
66
66
  },
67
67
  };
68
68
  filterable = {
69
- operators: operators.string,
69
+ operators: 'string',
70
70
  };
71
71
  titleUsable = true;
72
72
  }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ import { cloneDeep, merge } from 'lodash';
11
+ import type { ReactNode } from 'react';
12
+
13
+ export interface CollectionTemplateFieldOption {
14
+ label: ReactNode;
15
+ value: string | number | boolean;
16
+ [key: string]: unknown;
17
+ }
18
+
19
+ export interface CollectionTemplateField {
20
+ name: string;
21
+ interface?: string;
22
+ type?: string;
23
+ title?: ReactNode;
24
+ options?: CollectionTemplateFieldOption[];
25
+ component?: string;
26
+ componentProps?: Record<string, unknown>;
27
+ uiSchema?: Record<string, unknown>;
28
+ [key: string]: unknown;
29
+ }
30
+
31
+ interface FieldInterfaceConfigureLike {
32
+ default?: {
33
+ uiSchema?: Record<string, unknown>;
34
+ [key: string]: unknown;
35
+ };
36
+ }
37
+
38
+ interface FieldInterfaceLike {
39
+ default?: {
40
+ uiSchema?: Record<string, unknown>;
41
+ [key: string]: unknown;
42
+ };
43
+ }
44
+
45
+ export interface CollectionTemplateFieldNormalizeManager {
46
+ getFieldInterfaceConfigure?: (
47
+ name: string,
48
+ collectionInfo?: Record<string, unknown>,
49
+ ) => FieldInterfaceConfigureLike | undefined;
50
+ getFieldInterface?: (name: string) => FieldInterfaceLike | undefined;
51
+ }
52
+
53
+ export interface NormalizeCollectionTemplateFieldOptions {
54
+ collectionInfo?: Record<string, unknown>;
55
+ }
56
+
57
+ export function normalizeCollectionTemplateField(
58
+ field: CollectionTemplateField,
59
+ manager?: CollectionTemplateFieldNormalizeManager,
60
+ options: NormalizeCollectionTemplateFieldOptions = {},
61
+ ) {
62
+ const fieldInterfaceName = field.interface;
63
+ const fieldInterfaceDefault = fieldInterfaceName
64
+ ? manager?.getFieldInterfaceConfigure?.(fieldInterfaceName, options.collectionInfo)?.default ||
65
+ manager?.getFieldInterface?.(fieldInterfaceName)?.default
66
+ : undefined;
67
+
68
+ const normalized = merge({}, cloneDeep(fieldInterfaceDefault || {}), cloneDeep(field));
69
+ const uiSchema = merge({}, cloneDeep(fieldInterfaceDefault?.uiSchema || {}), cloneDeep(field.uiSchema || {}));
70
+
71
+ if (field.title !== undefined) {
72
+ uiSchema.title = field.title;
73
+ }
74
+
75
+ if (field.options !== undefined) {
76
+ uiSchema.enum = cloneDeep(field.options);
77
+ }
78
+
79
+ if (field.component !== undefined) {
80
+ uiSchema['x-component'] = field.component;
81
+ }
82
+
83
+ if (field.componentProps !== undefined) {
84
+ uiSchema['x-component-props'] = merge(
85
+ {},
86
+ cloneDeep(fieldInterfaceDefault?.uiSchema?.['x-component-props'] || {}),
87
+ cloneDeep(field.componentProps),
88
+ );
89
+ }
90
+
91
+ delete normalized.title;
92
+ delete normalized.options;
93
+ delete normalized.component;
94
+ delete normalized.componentProps;
95
+
96
+ if (Object.keys(uiSchema).length) {
97
+ normalized.uiSchema = uiSchema;
98
+ }
99
+
100
+ return normalized;
101
+ }
102
+
103
+ export function normalizeCollectionTemplateFields(
104
+ fields: CollectionTemplateField[] = [],
105
+ manager?: CollectionTemplateFieldNormalizeManager,
106
+ options?: NormalizeCollectionTemplateFieldOptions,
107
+ ) {
108
+ return fields.map((field) => normalizeCollectionTemplateField(field, manager, options));
109
+ }