@nocobase/client 0.10.0-alpha.2 → 0.10.0-alpha.4

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 (236) hide show
  1. package/es/acl/Configuration/MenuItemsProvider.js +3 -3
  2. package/es/application/Application.js +2 -2
  3. package/es/auth/SigninPage.js +12 -9
  4. package/es/block-provider/GanttBlockProvider.js +5 -4
  5. package/es/block-provider/TableBlockProvider.d.ts +1 -0
  6. package/es/block-provider/TableBlockProvider.js +51 -17
  7. package/es/collection-manager/Configuration/AddCollectionAction.js +31 -25
  8. package/es/collection-manager/Configuration/AddFieldAction.js +45 -32
  9. package/es/collection-manager/Configuration/AddSubFieldAction.js +24 -19
  10. package/es/collection-manager/Configuration/ConfigurationTabs.js +57 -50
  11. package/es/collection-manager/hooks/useOptions.js +39 -36
  12. package/es/collection-manager/interfaces/integer.js +1 -1
  13. package/es/collection-manager/interfaces/number.js +3 -3
  14. package/es/collection-manager/interfaces/percent.js +3 -3
  15. package/es/formula/Expression.js +66 -46
  16. package/es/hooks/index.d.ts +1 -0
  17. package/es/hooks/index.js +1 -0
  18. package/es/hooks/useAdminSchemaUid.d.ts +1 -0
  19. package/es/hooks/useAdminSchemaUid.js +6 -0
  20. package/es/hooks/useMenuItem.d.ts +37 -0
  21. package/es/hooks/useMenuItem.js +93 -0
  22. package/es/index.d.ts +2 -3
  23. package/es/index.js +3 -4
  24. package/es/locale/en_US.d.ts +3 -1
  25. package/es/locale/en_US.js +4 -2
  26. package/es/locale/es_ES.d.ts +1 -1
  27. package/es/locale/es_ES.js +1 -1
  28. package/es/locale/ja_JP.d.ts +3 -1
  29. package/es/locale/ja_JP.js +4 -2
  30. package/es/locale/pt_BR.d.ts +1 -1
  31. package/es/locale/pt_BR.js +1 -1
  32. package/es/locale/ru_RU.d.ts +1 -1
  33. package/es/locale/ru_RU.js +1 -1
  34. package/es/locale/zh_CN.d.ts +3 -1
  35. package/es/locale/zh_CN.js +3 -1
  36. package/es/pm/Card.js +5 -5
  37. package/es/pm/PluginManagerLink.js +16 -12
  38. package/es/pm/index.d.ts +2 -1
  39. package/es/pm/index.js +36 -22
  40. package/es/route-switch/antd/admin-layout/index.js +5 -5
  41. package/es/schema-component/antd/action/Action.Designer.js +3 -5
  42. package/es/schema-component/antd/action/Action.Drawer.js +1 -1
  43. package/es/schema-component/antd/action/ActionBar.js +1 -1
  44. package/es/schema-component/antd/association-field/Editable.js +1 -2
  45. package/es/schema-component/antd/association-field/Nester.js +7 -1
  46. package/es/schema-component/antd/association-field/SubTable.js +1 -1
  47. package/es/schema-component/antd/calendar/DeleteEvent.js +1 -1
  48. package/es/schema-component/antd/cascader/Cascader.js +1 -1
  49. package/es/schema-component/antd/form-item/FormItem.js +10 -3
  50. package/es/schema-component/antd/form-v2/Form.js +2 -2
  51. package/es/schema-component/antd/gantt/components/gantt/gantt.js +0 -1
  52. package/es/schema-component/antd/gantt/components/grid/grid-body.js +3 -3
  53. package/es/schema-component/antd/gantt/components/task-item/bar/bar-small.js +1 -1
  54. package/es/schema-component/antd/gantt/components/task-item/task-item.js +1 -1
  55. package/es/schema-component/antd/gantt/helpers/bar-helper.d.ts +1 -1
  56. package/es/schema-component/antd/gantt/helpers/bar-helper.js +4 -4
  57. package/es/schema-component/antd/gantt/helpers/other-helper.js +3 -1
  58. package/es/schema-component/antd/grid/Grid.js +2 -2
  59. package/es/schema-component/antd/grid-card/GridCard.Designer.js +3 -4
  60. package/es/schema-component/antd/grid-card/GridCard.Item.js +3 -3
  61. package/es/schema-component/antd/index.less +1 -3
  62. package/es/schema-component/antd/list/List.Decorator.js +3 -3
  63. package/es/schema-component/antd/list/List.Item.js +2 -2
  64. package/es/schema-component/antd/list/List.d.ts +2 -2
  65. package/es/schema-component/antd/list/List.js +6 -6
  66. package/es/schema-component/antd/menu/Menu.js +306 -156
  67. package/es/schema-component/antd/page/Page.js +29 -23
  68. package/es/schema-component/antd/remote-select/RemoteSelect.js +60 -10
  69. package/es/schema-component/antd/remote-select/utils.d.ts +4 -0
  70. package/es/schema-component/antd/remote-select/utils.js +31 -0
  71. package/es/schema-component/antd/table-v2/FilterDynamicComponent.js +17 -2
  72. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +51 -12
  73. package/es/schema-component/antd/table-v2/Table.js +28 -47
  74. package/es/schema-component/antd/table-v2/utils.d.ts +0 -1
  75. package/es/schema-component/antd/table-v2/utils.js +0 -28
  76. package/es/schema-component/antd/tabs/Tabs.js +35 -22
  77. package/es/schema-component/antd/tabs/context.d.ts +1 -1
  78. package/es/schema-component/antd/upload/ReadPretty.js +7 -3
  79. package/es/schema-component/antd/variable/VariableSelect.js +1 -1
  80. package/es/schema-component/common/utils/uitls.d.ts +1 -0
  81. package/es/schema-component/common/utils/uitls.js +1 -1
  82. package/es/schema-initializer/SchemaInitializer.d.ts +7 -2
  83. package/es/schema-initializer/SchemaInitializer.js +158 -103
  84. package/es/schema-initializer/SelectCollection.d.ts +1 -2
  85. package/es/schema-initializer/SelectCollection.js +19 -16
  86. package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
  87. package/es/schema-initializer/buttons/TableActionInitializers.js +5 -5
  88. package/es/schema-initializer/buttons/TableColumnInitializers.js +3 -2
  89. package/es/schema-initializer/components/CreateRecordAction.js +37 -27
  90. package/es/schema-initializer/components/assigned-field/AssignedField.js +2 -1
  91. package/es/schema-initializer/items/CalendarBlockInitializer.js +2 -2
  92. package/es/schema-initializer/utils.d.ts +0 -1
  93. package/es/schema-initializer/utils.js +40 -25
  94. package/es/schema-settings/SchemaSettings.js +110 -29
  95. package/es/schema-settings/VariableInput/hooks/useFormVariable.d.ts +19 -0
  96. package/es/schema-settings/VariableInput/hooks/useFormVariable.js +89 -0
  97. package/es/schema-settings/VariableInput/hooks/useIterationVariable.d.ts +8 -0
  98. package/es/schema-settings/VariableInput/hooks/useIterationVariable.js +77 -0
  99. package/es/schema-settings/VariableInput/hooks/useVariableOptions.d.ts +5 -12
  100. package/es/schema-settings/VariableInput/hooks/useVariableOptions.js +19 -3
  101. package/es/schema-templates/BlockTemplateDetails.js +5 -1
  102. package/es/schema-templates/BlockTemplatePage.js +4 -1
  103. package/es/user/ChangePassword.d.ts +1 -2
  104. package/es/user/ChangePassword.js +30 -26
  105. package/es/user/CurrentUser.js +172 -141
  106. package/es/user/EditProfile.d.ts +1 -2
  107. package/es/user/EditProfile.js +30 -24
  108. package/es/user/LanguageSettings.d.ts +1 -2
  109. package/es/user/LanguageSettings.js +67 -64
  110. package/es/user/SigninPage.js +25 -22
  111. package/es/user/SwitchRole.d.ts +1 -2
  112. package/es/user/SwitchRole.js +54 -49
  113. package/es/user/ThemeSettings.d.ts +1 -2
  114. package/es/user/ThemeSettings.js +56 -52
  115. package/lib/acl/Configuration/MenuItemsProvider.js +3 -3
  116. package/lib/application/Application.js +2 -2
  117. package/lib/auth/SigninPage.js +25 -22
  118. package/lib/block-provider/GanttBlockProvider.js +5 -4
  119. package/lib/block-provider/TableBlockProvider.d.ts +1 -0
  120. package/lib/block-provider/TableBlockProvider.js +53 -17
  121. package/lib/collection-manager/Configuration/AddCollectionAction.js +29 -23
  122. package/lib/collection-manager/Configuration/AddFieldAction.js +43 -30
  123. package/lib/collection-manager/Configuration/AddSubFieldAction.js +22 -17
  124. package/lib/collection-manager/Configuration/ConfigurationTabs.js +57 -49
  125. package/lib/collection-manager/hooks/useOptions.js +39 -36
  126. package/lib/collection-manager/interfaces/integer.js +1 -1
  127. package/lib/collection-manager/interfaces/number.js +3 -3
  128. package/lib/collection-manager/interfaces/percent.js +3 -3
  129. package/lib/formula/Expression.js +64 -44
  130. package/lib/hooks/index.d.ts +1 -0
  131. package/lib/hooks/index.js +11 -0
  132. package/lib/hooks/useAdminSchemaUid.d.ts +1 -0
  133. package/lib/hooks/useAdminSchemaUid.js +13 -0
  134. package/lib/hooks/useMenuItem.d.ts +37 -0
  135. package/lib/hooks/useMenuItem.js +108 -0
  136. package/lib/index.d.ts +2 -3
  137. package/lib/index.js +22 -33
  138. package/lib/locale/en_US.d.ts +3 -1
  139. package/lib/locale/en_US.js +4 -2
  140. package/lib/locale/es_ES.d.ts +1 -1
  141. package/lib/locale/es_ES.js +1 -1
  142. package/lib/locale/ja_JP.d.ts +3 -1
  143. package/lib/locale/ja_JP.js +4 -2
  144. package/lib/locale/pt_BR.d.ts +1 -1
  145. package/lib/locale/pt_BR.js +1 -1
  146. package/lib/locale/ru_RU.d.ts +1 -1
  147. package/lib/locale/ru_RU.js +1 -1
  148. package/lib/locale/zh_CN.d.ts +3 -1
  149. package/lib/locale/zh_CN.js +3 -1
  150. package/lib/pm/Card.js +6 -6
  151. package/lib/pm/PluginManagerLink.js +15 -10
  152. package/lib/pm/index.d.ts +2 -1
  153. package/lib/pm/index.js +37 -23
  154. package/lib/route-switch/antd/admin-layout/index.js +4 -4
  155. package/lib/schema-component/antd/action/Action.Designer.js +2 -4
  156. package/lib/schema-component/antd/action/Action.Drawer.js +1 -1
  157. package/lib/schema-component/antd/association-field/Editable.js +0 -1
  158. package/lib/schema-component/antd/association-field/Nester.js +6 -0
  159. package/lib/schema-component/antd/association-field/SubTable.js +1 -1
  160. package/lib/schema-component/antd/calendar/DeleteEvent.js +1 -1
  161. package/lib/schema-component/antd/cascader/Cascader.js +1 -1
  162. package/lib/schema-component/antd/form-item/FormItem.js +10 -3
  163. package/lib/schema-component/antd/form-v2/Form.js +2 -2
  164. package/lib/schema-component/antd/gantt/components/gantt/gantt.js +0 -1
  165. package/lib/schema-component/antd/gantt/components/grid/grid-body.js +2 -2
  166. package/lib/schema-component/antd/gantt/components/task-item/bar/bar-small.js +1 -1
  167. package/lib/schema-component/antd/gantt/components/task-item/task-item.js +1 -1
  168. package/lib/schema-component/antd/gantt/helpers/bar-helper.d.ts +1 -1
  169. package/lib/schema-component/antd/gantt/helpers/bar-helper.js +4 -4
  170. package/lib/schema-component/antd/gantt/helpers/other-helper.js +3 -1
  171. package/lib/schema-component/antd/grid/Grid.js +1 -1
  172. package/lib/schema-component/antd/grid-card/GridCard.Designer.js +4 -5
  173. package/lib/schema-component/antd/grid-card/GridCard.Item.js +8 -8
  174. package/lib/schema-component/antd/index.less +1 -3
  175. package/lib/schema-component/antd/list/List.Decorator.js +3 -3
  176. package/lib/schema-component/antd/list/List.Item.js +6 -6
  177. package/lib/schema-component/antd/list/List.d.ts +2 -2
  178. package/lib/schema-component/antd/list/List.js +24 -24
  179. package/lib/schema-component/antd/menu/Menu.js +304 -154
  180. package/lib/schema-component/antd/page/Page.js +29 -23
  181. package/lib/schema-component/antd/remote-select/RemoteSelect.js +57 -7
  182. package/lib/schema-component/antd/remote-select/utils.d.ts +4 -0
  183. package/lib/schema-component/antd/remote-select/utils.js +41 -0
  184. package/lib/schema-component/antd/table-v2/FilterDynamicComponent.js +17 -2
  185. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +50 -11
  186. package/lib/schema-component/antd/table-v2/Table.js +26 -45
  187. package/lib/schema-component/antd/table-v2/utils.d.ts +0 -1
  188. package/lib/schema-component/antd/table-v2/utils.js +0 -29
  189. package/lib/schema-component/antd/tabs/Tabs.js +34 -21
  190. package/lib/schema-component/antd/tabs/context.d.ts +1 -1
  191. package/lib/schema-component/antd/upload/ReadPretty.js +7 -3
  192. package/lib/schema-component/antd/variable/VariableSelect.js +1 -1
  193. package/lib/schema-component/common/utils/uitls.d.ts +1 -0
  194. package/lib/schema-component/common/utils/uitls.js +3 -1
  195. package/lib/schema-initializer/SchemaInitializer.d.ts +7 -2
  196. package/lib/schema-initializer/SchemaInitializer.js +155 -101
  197. package/lib/schema-initializer/SelectCollection.d.ts +1 -2
  198. package/lib/schema-initializer/SelectCollection.js +22 -17
  199. package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
  200. package/lib/schema-initializer/buttons/TableActionInitializers.js +5 -5
  201. package/lib/schema-initializer/buttons/TableColumnInitializers.js +2 -1
  202. package/lib/schema-initializer/components/CreateRecordAction.js +35 -25
  203. package/lib/schema-initializer/components/assigned-field/AssignedField.js +2 -1
  204. package/lib/schema-initializer/items/CalendarBlockInitializer.js +9 -9
  205. package/lib/schema-initializer/utils.d.ts +0 -1
  206. package/lib/schema-initializer/utils.js +41 -25
  207. package/lib/schema-settings/SchemaSettings.js +106 -27
  208. package/lib/schema-settings/VariableInput/hooks/useFormVariable.d.ts +19 -0
  209. package/lib/schema-settings/VariableInput/hooks/useFormVariable.js +96 -0
  210. package/lib/schema-settings/VariableInput/hooks/useIterationVariable.d.ts +8 -0
  211. package/lib/schema-settings/VariableInput/hooks/useIterationVariable.js +84 -0
  212. package/lib/schema-settings/VariableInput/hooks/useVariableOptions.d.ts +5 -12
  213. package/lib/schema-settings/VariableInput/hooks/useVariableOptions.js +19 -3
  214. package/lib/schema-templates/BlockTemplateDetails.js +5 -1
  215. package/lib/schema-templates/BlockTemplatePage.js +5 -2
  216. package/lib/user/ChangePassword.d.ts +1 -2
  217. package/lib/user/ChangePassword.js +30 -26
  218. package/lib/user/CurrentUser.js +166 -135
  219. package/lib/user/EditProfile.d.ts +1 -2
  220. package/lib/user/EditProfile.js +31 -25
  221. package/lib/user/LanguageSettings.d.ts +1 -2
  222. package/lib/user/LanguageSettings.js +66 -63
  223. package/lib/user/SigninPage.js +25 -22
  224. package/lib/user/SwitchRole.d.ts +1 -2
  225. package/lib/user/SwitchRole.js +57 -51
  226. package/lib/user/ThemeSettings.d.ts +1 -2
  227. package/lib/user/ThemeSettings.js +59 -54
  228. package/package.json +9 -8
  229. package/es/settings-form/SettingsForm.d.ts +0 -13
  230. package/es/settings-form/SettingsForm.js +0 -309
  231. package/es/settings-form/index.d.ts +0 -1
  232. package/es/settings-form/index.js +0 -1
  233. package/lib/settings-form/SettingsForm.d.ts +0 -13
  234. package/lib/settings-form/SettingsForm.js +0 -320
  235. package/lib/settings-form/index.d.ts +0 -1
  236. package/lib/settings-form/index.js +0 -16
@@ -17,7 +17,8 @@ import { MenuOutlined } from '@ant-design/icons';
17
17
  import { DndContext, DragOverlay, MouseSensor, useDraggable, useDroppable, useSensor, useSensors } from '@dnd-kit/core';
18
18
  import { RecursionField, observer } from '@formily/react';
19
19
  import { uid } from '@formily/shared';
20
- import { Badge, Card, Dropdown, Menu, Modal, Tabs } from 'antd';
20
+ import { Badge, Card, Dropdown, Modal, Tabs } from 'antd';
21
+ import _ from 'lodash';
21
22
  import React, { useContext, useState } from 'react';
22
23
  import { useAPIClient } from '../../api-client';
23
24
  import { SchemaComponent, SchemaComponentOptions, useCompile } from '../../schema-component';
@@ -262,26 +263,30 @@ export var ConfigurationTabs = function ConfigurationTabs() {
262
263
  return _ref4.apply(this, arguments);
263
264
  };
264
265
  }();
265
- var menu = function menu(item) {
266
- return /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(Menu.Item, {
267
- key: 'edit'
268
- }, /*#__PURE__*/React.createElement(SchemaComponent, {
269
- schema: {
270
- type: 'void',
271
- properties: _defineProperty({}, uid(), {
272
- 'x-component': 'EditCategory',
273
- 'x-component-props': {
274
- item: item
266
+ var menu = _.memoize(function (item) {
267
+ return {
268
+ items: [{
269
+ key: 'edit',
270
+ label: /*#__PURE__*/React.createElement(SchemaComponent, {
271
+ schema: {
272
+ type: 'void',
273
+ properties: _defineProperty({}, uid(), {
274
+ 'x-component': 'EditCategory',
275
+ 'x-component-props': {
276
+ item: item
277
+ }
278
+ })
275
279
  }
276
280
  })
277
- }
278
- })), /*#__PURE__*/React.createElement(Menu.Item, {
279
- key: "delete",
280
- onClick: function onClick() {
281
- return remove(item.id);
282
- }
283
- }, compile("{{t('Delete category')}}")));
284
- };
281
+ }, {
282
+ key: 'delete',
283
+ label: compile("{{t('Delete category')}}"),
284
+ onClick: function onClick() {
285
+ return remove(item.id);
286
+ }
287
+ }]
288
+ };
289
+ });
285
290
  return /*#__PURE__*/React.createElement(DndProvider, null, /*#__PURE__*/React.createElement(Tabs, {
286
291
  addIcon: /*#__PURE__*/React.createElement(SchemaComponent, {
287
292
  schema: {
@@ -304,35 +309,37 @@ export var ConfigurationTabs = function ConfigurationTabs() {
304
309
  destroyInactiveTabPane: true,
305
310
  tabBarStyle: {
306
311
  marginBottom: '0px'
307
- }
308
- }, tabsItems.map(function (item) {
309
- return /*#__PURE__*/React.createElement(Tabs.TabPane, {
310
- tab: item.id !== 'all' ? /*#__PURE__*/React.createElement("div", {
311
- "data-no-dnd": "true"
312
- }, /*#__PURE__*/React.createElement(TabTitle, {
313
- item: item
314
- })) : compile(item.name),
315
- key: item.id,
316
- closable: item.closable,
317
- closeIcon: /*#__PURE__*/React.createElement(Dropdown, {
318
- overlay: menu(item)
319
- }, /*#__PURE__*/React.createElement(MenuOutlined, null))
320
- }, /*#__PURE__*/React.createElement(Card, {
321
- bordered: false
322
- }, /*#__PURE__*/React.createElement(SchemaComponentOptions, {
323
- components: {
324
- CollectionFields: CollectionFields
325
- },
326
- inherit: true,
327
- scope: {
328
- loadCategories: loadCategories,
329
- categoryVisible: item.id === 'all',
330
- categoryId: item.id
331
- }
332
- }, /*#__PURE__*/React.createElement(RecursionField, {
333
- name: key,
334
- schema: item.schema,
335
- onlyRenderProperties: true
336
- }))));
337
- })));
312
+ },
313
+ items: tabsItems.map(function (item) {
314
+ return {
315
+ label: item.id !== 'all' ? /*#__PURE__*/React.createElement("div", {
316
+ "data-no-dnd": "true"
317
+ }, /*#__PURE__*/React.createElement(TabTitle, {
318
+ item: item
319
+ })) : compile(item.name),
320
+ key: item.id,
321
+ closable: item.closable,
322
+ closeIcon: /*#__PURE__*/React.createElement(Dropdown, {
323
+ menu: menu(item)
324
+ }, /*#__PURE__*/React.createElement(MenuOutlined, null)),
325
+ children: /*#__PURE__*/React.createElement(Card, {
326
+ bordered: false
327
+ }, /*#__PURE__*/React.createElement(SchemaComponentOptions, {
328
+ components: {
329
+ CollectionFields: CollectionFields
330
+ },
331
+ inherit: true,
332
+ scope: {
333
+ loadCategories: loadCategories,
334
+ categoryVisible: item.id === 'all',
335
+ categoryId: item.id
336
+ }
337
+ }, /*#__PURE__*/React.createElement(RecursionField, {
338
+ name: key,
339
+ schema: item.schema,
340
+ onlyRenderProperties: true
341
+ })))
342
+ };
343
+ })
344
+ }));
338
345
  };
@@ -5,45 +5,48 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import set from 'lodash/set';
8
+ import { useMemo } from 'react';
8
9
  import { useCollectionManager } from './useCollectionManager';
9
10
  export var useOptions = function useOptions() {
10
11
  var _useCollectionManager = useCollectionManager(),
11
12
  interfaces = _useCollectionManager.interfaces;
12
- var fields = {};
13
- Object.keys(interfaces).forEach(function (type) {
14
- var schema = interfaces[type];
15
- registerField(schema.group || 'others', type, _objectSpread({
16
- order: 0
17
- }, schema));
18
- });
19
- function registerField(group, type, schema) {
20
- fields[group] = fields[group] || {};
21
- set(fields, [group, type], schema);
22
- }
23
- var groupLabels = {
24
- basic: '{{t("Basic")}}',
25
- choices: '{{t("Choices")}}',
26
- media: '{{t("Media")}}',
27
- datetime: '{{t("Date & Time")}}',
28
- relation: '{{t("Relation")}}',
29
- advanced: '{{t("Advanced type")}}',
30
- systemInfo: '{{t("System info")}}',
31
- others: '{{t("Others")}}'
32
- };
33
- return Object.keys(groupLabels).map(function (groupName) {
34
- return {
35
- label: groupLabels[groupName],
36
- key: groupName,
37
- children: Object.keys(fields[groupName] || {}).map(function (type) {
38
- var field = fields[groupName][type];
39
- return _objectSpread({
40
- value: type,
41
- label: field.title,
42
- name: type
43
- }, fields[groupName][type]);
44
- }).sort(function (a, b) {
45
- return a.order - b.order;
46
- })
13
+ return useMemo(function () {
14
+ var fields = {};
15
+ Object.keys(interfaces).forEach(function (type) {
16
+ var schema = interfaces[type];
17
+ registerField(schema.group || 'others', type, _objectSpread({
18
+ order: 0
19
+ }, schema));
20
+ });
21
+ function registerField(group, type, schema) {
22
+ fields[group] = fields[group] || {};
23
+ set(fields, [group, type], schema);
24
+ }
25
+ var groupLabels = {
26
+ basic: '{{t("Basic")}}',
27
+ choices: '{{t("Choices")}}',
28
+ media: '{{t("Media")}}',
29
+ datetime: '{{t("Date & Time")}}',
30
+ relation: '{{t("Relation")}}',
31
+ advanced: '{{t("Advanced type")}}',
32
+ systemInfo: '{{t("System info")}}',
33
+ others: '{{t("Others")}}'
47
34
  };
48
- });
35
+ return Object.keys(groupLabels).map(function (groupName) {
36
+ return {
37
+ label: groupLabels[groupName],
38
+ key: groupName,
39
+ children: Object.keys(fields[groupName] || {}).map(function (type) {
40
+ var field = fields[groupName][type];
41
+ return _objectSpread({
42
+ value: type,
43
+ label: field.title,
44
+ name: type
45
+ }, fields[groupName][type]);
46
+ }).sort(function (a, b) {
47
+ return a.order - b.order;
48
+ })
49
+ };
50
+ });
51
+ }, [interfaces]);
49
52
  };
@@ -27,7 +27,7 @@ export var integer = {
27
27
  'x-component': 'InputNumber',
28
28
  'x-component-props': {
29
29
  stringMode: true,
30
- step: '0'
30
+ step: '1'
31
31
  },
32
32
  'x-validator': 'integer'
33
33
  }
@@ -22,7 +22,7 @@ export var number = {
22
22
  'x-component': 'InputNumber',
23
23
  'x-component-props': {
24
24
  stringMode: true,
25
- step: '0'
25
+ step: '1'
26
26
  }
27
27
  }
28
28
  },
@@ -35,9 +35,9 @@ export var number = {
35
35
  title: '{{t("Precision")}}',
36
36
  'x-component': 'Select',
37
37
  'x-decorator': 'FormItem',
38
- default: '0',
38
+ default: '1',
39
39
  enum: [{
40
- value: '0',
40
+ value: '1',
41
41
  label: '1'
42
42
  }, {
43
43
  value: '0.1',
@@ -59,7 +59,7 @@ export var percent = {
59
59
  'x-component': 'Percent',
60
60
  'x-component-props': {
61
61
  stringMode: true,
62
- step: '0',
62
+ step: '1',
63
63
  addonAfter: '%'
64
64
  }
65
65
  }
@@ -83,9 +83,9 @@ export var percent = {
83
83
  title: '{{t("Precision")}}',
84
84
  'x-component': 'Select',
85
85
  'x-decorator': 'FormItem',
86
- default: '0',
86
+ default: '1',
87
87
  enum: [{
88
- value: '0',
88
+ value: '1',
89
89
  label: '1%'
90
90
  }, {
91
91
  value: '0.1',
@@ -14,8 +14,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
14
14
  import { css } from '@emotion/css';
15
15
  import { onFormSubmitValidateStart } from '@formily/core';
16
16
  import { useField, useFormEffects } from '@formily/react';
17
- import { Dropdown, Menu } from 'antd';
18
- import React, { useEffect, useRef, useState } from 'react';
17
+ import { Dropdown } from 'antd';
18
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
19
19
  import { useTranslation } from 'react-i18next';
20
20
  function pasteHtml(html) {
21
21
  var selectPastedContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
@@ -97,18 +97,26 @@ export var Expression = function Expression(props) {
97
97
  _useState2 = _slicedToArray(_useState, 2),
98
98
  changed = _useState2[0],
99
99
  setChanged = _useState2[1];
100
- var onChange = function onChange(value) {
100
+ var onChange = useCallback(function (value) {
101
101
  setChanged(true);
102
102
  props.onChange(value);
103
- };
104
- var numColumns = new Map();
105
- var scope = {};
106
- fields.filter(function (field) {
107
- return supports.includes(field.interface);
108
- }).forEach(function (field) {
109
- numColumns.set(field.name, field.uiSchema.title);
110
- scope[field.name] = 1;
111
- });
103
+ }, [props.onChange]);
104
+ var _useMemo = useMemo(function () {
105
+ var numColumns = new Map();
106
+ var scope = {};
107
+ fields.filter(function (field) {
108
+ return supports.includes(field.interface);
109
+ }).forEach(function (field) {
110
+ numColumns.set(field.name, field.uiSchema.title);
111
+ scope[field.name] = 1;
112
+ });
113
+ return {
114
+ numColumns: numColumns,
115
+ scope: scope
116
+ };
117
+ }, [fields, supports]),
118
+ numColumns = _useMemo.numColumns,
119
+ scope = _useMemo.scope;
112
120
  var keys = Array.from(numColumns.keys());
113
121
  var _useState3 = useState(function () {
114
122
  var scope = {};
@@ -135,39 +143,51 @@ export var Expression = function Expression(props) {
135
143
  var val = renderExp(value || '', scope);
136
144
  setHtml(val);
137
145
  }, [value]);
138
- var menu = /*#__PURE__*/React.createElement(Menu, null, keys.length > 0 ? keys.map(function (key) {
139
- return /*#__PURE__*/React.createElement(Menu.Item, {
140
- disabled: true,
141
- key: key
142
- }, /*#__PURE__*/React.createElement("button", {
143
- onClick: function () {
144
- var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(args) {
145
- var val, text;
146
- return _regeneratorRuntime().wrap(function _callee$(_context) {
147
- while (1) switch (_context.prev = _context.next) {
148
- case 0:
149
- inputRef.current.focus();
150
- val = numColumns.get(key);
151
- pasteHtml(" <span class=\"ant-tag\" style=\"margin: 0 3px;\" contentEditable=\"false\" data-key=\"".concat(key, "\">").concat(val, "</span> "));
152
- text = getValue(inputRef.current);
153
- onChange(text);
154
- console.log('onChange', text);
155
- case 6:
156
- case "end":
157
- return _context.stop();
158
- }
159
- }, _callee);
160
- }));
161
- function onClick(_x2) {
162
- return _onClick.apply(this, arguments);
163
- }
164
- return onClick;
165
- }()
166
- }, numColumns.get(key)));
167
- }) : /*#__PURE__*/React.createElement(Menu.Item, {
168
- disabled: true,
169
- key: 0
170
- }, t('No available fields')));
146
+ var menuItems = useMemo(function () {
147
+ if (keys.length > 0) {
148
+ return keys.map(function (key) {
149
+ return {
150
+ key: key,
151
+ disabled: true,
152
+ label: /*#__PURE__*/React.createElement("button", {
153
+ onClick: function () {
154
+ var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(args) {
155
+ var val, text;
156
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
157
+ while (1) switch (_context.prev = _context.next) {
158
+ case 0:
159
+ inputRef.current.focus();
160
+ val = numColumns.get(key);
161
+ pasteHtml(" <span class=\"ant-tag\" style=\"margin: 0 3px;\" contentEditable=\"false\" data-key=\"".concat(key, "\">").concat(val, "</span> "));
162
+ text = getValue(inputRef.current);
163
+ onChange(text);
164
+ case 5:
165
+ case "end":
166
+ return _context.stop();
167
+ }
168
+ }, _callee);
169
+ }));
170
+ function onClick(_x2) {
171
+ return _onClick.apply(this, arguments);
172
+ }
173
+ return onClick;
174
+ }()
175
+ }, numColumns.get(key))
176
+ };
177
+ });
178
+ } else {
179
+ return [{
180
+ key: 0,
181
+ disabled: true,
182
+ label: t('No available fields')
183
+ }];
184
+ }
185
+ }, [keys, numColumns, onChange]);
186
+ var menu = useMemo(function () {
187
+ return {
188
+ items: menuItems
189
+ };
190
+ }, [menuItems]);
171
191
  useFormEffects(function () {
172
192
  onFormSubmitValidateStart(function () {
173
193
  try {
@@ -185,7 +205,7 @@ export var Expression = function Expression(props) {
185
205
  });
186
206
  return /*#__PURE__*/React.createElement(Dropdown, {
187
207
  trigger: ['click'],
188
- overlay: menu,
208
+ menu: menu,
189
209
  overlayClassName: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ant-dropdown-menu-item {\n padding: 0;\n }\n button {\n cursor: pointer;\n padding: 5px 12px;\n text-align: left;\n color: rgba(0, 0, 0, 0.85);\n width: 100%;\n line-height: inherit;\n height: auto;\n border: 0px;\n background-color: transparent;\n &:hover {\n background-color: #f5f5f5;\n }\n }\n "])))
190
210
  }, /*#__PURE__*/React.createElement("div", {
191
211
  onKeyDown: function onKeyDown(e) {
@@ -1 +1,2 @@
1
+ export * from './useAdminSchemaUid';
1
2
  export * from './useViewport';
package/es/hooks/index.js CHANGED
@@ -1 +1,2 @@
1
+ export * from './useAdminSchemaUid';
1
2
  export * from './useViewport';
@@ -0,0 +1 @@
1
+ export declare const useAdminSchemaUid: () => any;
@@ -0,0 +1,6 @@
1
+ import { useSystemSettings } from '../system-settings';
2
+ export var useAdminSchemaUid = function useAdminSchemaUid() {
3
+ var _ctx$data, _ctx$data$data, _ctx$data$data$option;
4
+ var ctx = useSystemSettings();
5
+ return ctx === null || ctx === void 0 ? void 0 : (_ctx$data = ctx.data) === null || _ctx$data === void 0 ? void 0 : (_ctx$data$data = _ctx$data.data) === null || _ctx$data$data === void 0 ? void 0 : (_ctx$data$data$option = _ctx$data$data.options) === null || _ctx$data$data$option === void 0 ? void 0 : _ctx$data$data$option.adminSchemaUid;
6
+ };
@@ -0,0 +1,37 @@
1
+ import { MenuProps } from 'antd';
2
+ import React, { ReactNode } from 'react';
3
+ declare type Item = MenuProps['items'][0] & {
4
+ /** 在清空数组时,如果该字段为 true 则保留该选项 */
5
+ notdelete?: boolean;
6
+ /** 用于给列表排序 */
7
+ order?: number;
8
+ };
9
+ export declare const GetMenuItemContext: React.Context<{
10
+ collectMenuItem?(item: Item): void;
11
+ onChange?: () => void;
12
+ }>;
13
+ export declare const GetMenuItemsContext: React.Context<{
14
+ pushMenuItem?(item: Item): void;
15
+ }>;
16
+ /**
17
+ * 用于为 SchemaInitializer.Item 组件提供一些方法,比如收集菜单项数据
18
+ * @returns
19
+ */
20
+ export declare const useCollectMenuItem: () => {
21
+ collectMenuItem?(item: Item): void;
22
+ onChange?: () => void;
23
+ };
24
+ export declare const useCollectMenuItems: () => {
25
+ pushMenuItem?(item: Item): void;
26
+ };
27
+ /**
28
+ * 用于在 antd 从 4.x 升级到 5.x 中,用于把 SchemaInitializer.Item 组件这种写法转换成 Menu 组件的 items 写法
29
+ * @returns
30
+ */
31
+ export declare const useMenuItem: () => {
32
+ Component: () => React.JSX.Element;
33
+ getMenuItems: (Com: () => ReactNode) => Item[];
34
+ getMenuItem: (Com: () => JSX.Element) => Item;
35
+ clean: () => void;
36
+ };
37
+ export {};
@@ -0,0 +1,93 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ import _ from 'lodash';
8
+ import React, { createContext, useCallback, useContext, useRef } from 'react';
9
+ export var GetMenuItemContext = /*#__PURE__*/createContext(null);
10
+ export var GetMenuItemsContext = /*#__PURE__*/createContext(null);
11
+ /**
12
+ * 用于为 SchemaInitializer.Item 组件提供一些方法,比如收集菜单项数据
13
+ * @returns
14
+ */
15
+ export var useCollectMenuItem = function useCollectMenuItem() {
16
+ return useContext(GetMenuItemContext) || {};
17
+ };
18
+ export var useCollectMenuItems = function useCollectMenuItems() {
19
+ return useContext(GetMenuItemsContext) || {};
20
+ };
21
+ /**
22
+ * 用于在 antd 从 4.x 升级到 5.x 中,用于把 SchemaInitializer.Item 组件这种写法转换成 Menu 组件的 items 写法
23
+ * @returns
24
+ */
25
+ export var useMenuItem = function useMenuItem() {
26
+ var list = useRef([]);
27
+ var renderItems = useRef(null);
28
+ var shouldRerender = useRef(false);
29
+ var Component = useCallback(function () {
30
+ if (!shouldRerender.current) {
31
+ return null;
32
+ }
33
+ shouldRerender.current = false;
34
+ if (renderItems.current) {
35
+ return renderItems.current();
36
+ }
37
+ return /*#__PURE__*/React.createElement(React.Fragment, null, list.current.map(function (Com, index) {
38
+ return /*#__PURE__*/React.createElement(Com, {
39
+ key: index
40
+ });
41
+ }));
42
+ }, []);
43
+ var getMenuItems = useCallback(function (Com) {
44
+ var items = [];
45
+ var pushMenuItem = function pushMenuItem(item) {
46
+ items.push(item);
47
+ items.sort(function (a, b) {
48
+ return (a.order || 0) - (b.order || 0);
49
+ });
50
+ };
51
+ shouldRerender.current = true;
52
+ renderItems.current = function () {
53
+ var notDeleteItems = items.filter(function (item) {
54
+ return item.notdelete;
55
+ }).map(function (item) {
56
+ return _.omit(item, 'notdelete');
57
+ });
58
+ items.length = 0;
59
+ items.push.apply(items, _toConsumableArray(notDeleteItems));
60
+ return /*#__PURE__*/React.createElement(GetMenuItemsContext.Provider, {
61
+ value: {
62
+ pushMenuItem: pushMenuItem
63
+ }
64
+ }, Com());
65
+ };
66
+ return items;
67
+ }, []);
68
+ var getMenuItem = useCallback(function (Com) {
69
+ var item = {};
70
+ var collectMenuItem = function collectMenuItem(menuItem) {
71
+ Object.assign(item, menuItem);
72
+ };
73
+ shouldRerender.current = true;
74
+ list.current.push(function () {
75
+ return /*#__PURE__*/React.createElement(GetMenuItemContext.Provider, {
76
+ value: {
77
+ collectMenuItem: collectMenuItem
78
+ }
79
+ }, Com());
80
+ });
81
+ return item;
82
+ }, []);
83
+ // 防止 list 有重复元素
84
+ var clean = useCallback(function () {
85
+ list.current = [];
86
+ }, []);
87
+ return {
88
+ Component: Component,
89
+ getMenuItems: getMenuItems,
90
+ getMenuItem: getMenuItem,
91
+ clean: clean
92
+ };
93
+ };
package/es/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from './collection-manager';
13
13
  export * from './document-title';
14
14
  export * from './filter-provider';
15
15
  export * from './formula';
16
+ export * from './hooks';
16
17
  export * from './i18n';
17
18
  export * from './icon';
18
19
  export * from './plugin-manager';
@@ -22,10 +23,8 @@ export * from './record-provider';
22
23
  export * from './route-switch';
23
24
  export * from './schema-component';
24
25
  export * from './schema-initializer';
26
+ export * from './schema-items';
25
27
  export * from './schema-settings';
26
28
  export * from './schema-templates';
27
- export * from './schema-items';
28
- export * from './settings-form';
29
29
  export * from './system-settings';
30
30
  export * from './user';
31
- export * from './hooks';
package/es/index.js CHANGED
@@ -13,6 +13,7 @@ export * from './collection-manager';
13
13
  export * from './document-title';
14
14
  export * from './filter-provider';
15
15
  export * from './formula';
16
+ export * from './hooks';
16
17
  export * from './i18n';
17
18
  export * from './icon';
18
19
  export * from './plugin-manager';
@@ -22,10 +23,8 @@ export * from './record-provider';
22
23
  export * from './route-switch';
23
24
  export * from './schema-component';
24
25
  export * from './schema-initializer';
26
+ export * from './schema-items';
25
27
  export * from './schema-settings';
26
28
  export * from './schema-templates';
27
- export * from './schema-items';
28
- export * from './settings-form';
29
29
  export * from './system-settings';
30
- export * from './user';
31
- export * from './hooks';
30
+ export * from './user';
@@ -294,7 +294,7 @@ declare const _default: {
294
294
  "Quick upload": string;
295
295
  "Select file": string;
296
296
  Subtable: string;
297
- Subform: string;
297
+ "Sub-form": string;
298
298
  "Field mode": string;
299
299
  "Allow add new data": string;
300
300
  "Record picker": string;
@@ -704,5 +704,7 @@ declare const _default: {
704
704
  "Update or create": string;
705
705
  "Find by the following fields": string;
706
706
  Create: string;
707
+ "Current form": string;
708
+ "Current object": string;
707
709
  };
708
710
  export default _default;
@@ -294,7 +294,7 @@ export default {
294
294
  "Quick upload": "Quick upload",
295
295
  "Select file": "Select file",
296
296
  "Subtable": "Sub-table",
297
- "Subform": "Sub-form",
297
+ "Sub-form": "Sub-form",
298
298
  "Field mode": "Field mode",
299
299
  "Allow add new data": "Allow add new data",
300
300
  "Record picker": "Record picker",
@@ -703,5 +703,7 @@ export default {
703
703
  "First or create": "First or create",
704
704
  "Update or create": "Update or create",
705
705
  "Find by the following fields": "Find by the following fields",
706
- "Create": "Create"
706
+ "Create": "Create",
707
+ "Current form": "Current form",
708
+ "Current object": "Current object"
707
709
  };
@@ -280,7 +280,7 @@ declare const _default: {
280
280
  "Display field title": string;
281
281
  "Field component": string;
282
282
  Subtable: string;
283
- Subform: string;
283
+ "Sub-form": string;
284
284
  "Record picker": string;
285
285
  "Toggles the subfield mode": string;
286
286
  "Selector mode": string;