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

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 (194) 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/collection-manager/Configuration/AddCollectionAction.js +31 -25
  5. package/es/collection-manager/Configuration/AddFieldAction.js +45 -32
  6. package/es/collection-manager/Configuration/AddSubFieldAction.js +24 -19
  7. package/es/collection-manager/Configuration/ConfigurationTabs.js +57 -50
  8. package/es/collection-manager/hooks/useOptions.js +39 -36
  9. package/es/collection-manager/interfaces/integer.js +1 -1
  10. package/es/collection-manager/interfaces/number.js +3 -3
  11. package/es/collection-manager/interfaces/percent.js +3 -3
  12. package/es/formula/Expression.js +66 -46
  13. package/es/hooks/index.d.ts +1 -0
  14. package/es/hooks/index.js +1 -0
  15. package/es/hooks/useAdminSchemaUid.d.ts +1 -0
  16. package/es/hooks/useAdminSchemaUid.js +6 -0
  17. package/es/hooks/useMenuItem.d.ts +37 -0
  18. package/es/hooks/useMenuItem.js +90 -0
  19. package/es/index.d.ts +2 -3
  20. package/es/index.js +3 -4
  21. package/es/locale/en_US.d.ts +3 -1
  22. package/es/locale/en_US.js +4 -2
  23. package/es/locale/es_ES.d.ts +1 -1
  24. package/es/locale/es_ES.js +1 -1
  25. package/es/locale/ja_JP.d.ts +3 -1
  26. package/es/locale/ja_JP.js +4 -2
  27. package/es/locale/pt_BR.d.ts +1 -1
  28. package/es/locale/pt_BR.js +1 -1
  29. package/es/locale/ru_RU.d.ts +1 -1
  30. package/es/locale/ru_RU.js +1 -1
  31. package/es/locale/zh_CN.d.ts +3 -1
  32. package/es/locale/zh_CN.js +3 -1
  33. package/es/pm/Card.js +5 -5
  34. package/es/pm/PluginManagerLink.js +16 -12
  35. package/es/pm/index.d.ts +2 -1
  36. package/es/pm/index.js +36 -22
  37. package/es/route-switch/antd/admin-layout/index.js +4 -4
  38. package/es/schema-component/antd/action/Action.Designer.js +3 -5
  39. package/es/schema-component/antd/action/Action.Drawer.js +1 -1
  40. package/es/schema-component/antd/action/ActionBar.js +1 -1
  41. package/es/schema-component/antd/association-field/SubTable.js +1 -1
  42. package/es/schema-component/antd/calendar/DeleteEvent.js +1 -1
  43. package/es/schema-component/antd/cascader/Cascader.js +1 -1
  44. package/es/schema-component/antd/form-item/FormItem.js +10 -3
  45. package/es/schema-component/antd/grid-card/GridCard.Designer.js +3 -4
  46. package/es/schema-component/antd/index.less +1 -3
  47. package/es/schema-component/antd/menu/Menu.js +306 -156
  48. package/es/schema-component/antd/page/Page.js +29 -23
  49. package/es/schema-component/antd/remote-select/RemoteSelect.js +58 -10
  50. package/es/schema-component/antd/remote-select/utils.d.ts +4 -0
  51. package/es/schema-component/antd/remote-select/utils.js +31 -0
  52. package/es/schema-component/antd/table-v2/FilterDynamicComponent.js +17 -2
  53. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +51 -12
  54. package/es/schema-component/antd/table-v2/Table.js +9 -7
  55. package/es/schema-component/antd/tabs/Tabs.js +35 -22
  56. package/es/schema-component/antd/tabs/context.d.ts +1 -1
  57. package/es/schema-component/antd/upload/ReadPretty.js +7 -3
  58. package/es/schema-component/antd/variable/VariableSelect.js +1 -1
  59. package/es/schema-component/common/utils/uitls.d.ts +1 -0
  60. package/es/schema-component/common/utils/uitls.js +1 -1
  61. package/es/schema-initializer/SchemaInitializer.d.ts +7 -2
  62. package/es/schema-initializer/SchemaInitializer.js +155 -102
  63. package/es/schema-initializer/SelectCollection.d.ts +1 -2
  64. package/es/schema-initializer/SelectCollection.js +19 -16
  65. package/es/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
  66. package/es/schema-initializer/buttons/TableActionInitializers.js +5 -5
  67. package/es/schema-initializer/buttons/TableColumnInitializers.js +3 -2
  68. package/es/schema-initializer/components/CreateRecordAction.js +37 -27
  69. package/es/schema-initializer/components/assigned-field/AssignedField.js +2 -1
  70. package/es/schema-initializer/items/CalendarBlockInitializer.js +2 -2
  71. package/es/schema-initializer/utils.d.ts +0 -1
  72. package/es/schema-initializer/utils.js +40 -25
  73. package/es/schema-settings/SchemaSettings.js +123 -46
  74. package/es/schema-settings/VariableInput/hooks/useFormVariable.d.ts +19 -0
  75. package/es/schema-settings/VariableInput/hooks/useFormVariable.js +89 -0
  76. package/es/schema-settings/VariableInput/hooks/useIterationVariable.d.ts +8 -0
  77. package/es/schema-settings/VariableInput/hooks/useIterationVariable.js +77 -0
  78. package/es/schema-settings/VariableInput/hooks/useVariableOptions.d.ts +5 -12
  79. package/es/schema-settings/VariableInput/hooks/useVariableOptions.js +19 -3
  80. package/es/schema-templates/BlockTemplateDetails.js +5 -1
  81. package/es/schema-templates/BlockTemplatePage.js +4 -1
  82. package/es/user/ChangePassword.d.ts +1 -2
  83. package/es/user/ChangePassword.js +30 -26
  84. package/es/user/CurrentUser.js +172 -141
  85. package/es/user/EditProfile.d.ts +1 -2
  86. package/es/user/EditProfile.js +30 -24
  87. package/es/user/LanguageSettings.d.ts +1 -2
  88. package/es/user/LanguageSettings.js +67 -64
  89. package/es/user/SigninPage.js +25 -22
  90. package/es/user/SwitchRole.d.ts +1 -2
  91. package/es/user/SwitchRole.js +54 -49
  92. package/es/user/ThemeSettings.d.ts +1 -2
  93. package/es/user/ThemeSettings.js +56 -52
  94. package/lib/acl/Configuration/MenuItemsProvider.js +3 -3
  95. package/lib/application/Application.js +2 -2
  96. package/lib/auth/SigninPage.js +25 -22
  97. package/lib/collection-manager/Configuration/AddCollectionAction.js +29 -23
  98. package/lib/collection-manager/Configuration/AddFieldAction.js +43 -30
  99. package/lib/collection-manager/Configuration/AddSubFieldAction.js +22 -17
  100. package/lib/collection-manager/Configuration/ConfigurationTabs.js +57 -49
  101. package/lib/collection-manager/hooks/useOptions.js +39 -36
  102. package/lib/collection-manager/interfaces/integer.js +1 -1
  103. package/lib/collection-manager/interfaces/number.js +3 -3
  104. package/lib/collection-manager/interfaces/percent.js +3 -3
  105. package/lib/formula/Expression.js +64 -44
  106. package/lib/hooks/index.d.ts +1 -0
  107. package/lib/hooks/index.js +11 -0
  108. package/lib/hooks/useAdminSchemaUid.d.ts +1 -0
  109. package/lib/hooks/useAdminSchemaUid.js +13 -0
  110. package/lib/hooks/useMenuItem.d.ts +37 -0
  111. package/lib/hooks/useMenuItem.js +104 -0
  112. package/lib/index.d.ts +2 -3
  113. package/lib/index.js +22 -33
  114. package/lib/locale/en_US.d.ts +3 -1
  115. package/lib/locale/en_US.js +4 -2
  116. package/lib/locale/es_ES.d.ts +1 -1
  117. package/lib/locale/es_ES.js +1 -1
  118. package/lib/locale/ja_JP.d.ts +3 -1
  119. package/lib/locale/ja_JP.js +4 -2
  120. package/lib/locale/pt_BR.d.ts +1 -1
  121. package/lib/locale/pt_BR.js +1 -1
  122. package/lib/locale/ru_RU.d.ts +1 -1
  123. package/lib/locale/ru_RU.js +1 -1
  124. package/lib/locale/zh_CN.d.ts +3 -1
  125. package/lib/locale/zh_CN.js +3 -1
  126. package/lib/pm/Card.js +6 -6
  127. package/lib/pm/PluginManagerLink.js +15 -10
  128. package/lib/pm/index.d.ts +2 -1
  129. package/lib/pm/index.js +37 -23
  130. package/lib/route-switch/antd/admin-layout/index.js +3 -3
  131. package/lib/schema-component/antd/action/Action.Designer.js +2 -4
  132. package/lib/schema-component/antd/action/Action.Drawer.js +1 -1
  133. package/lib/schema-component/antd/association-field/SubTable.js +1 -1
  134. package/lib/schema-component/antd/calendar/DeleteEvent.js +1 -1
  135. package/lib/schema-component/antd/cascader/Cascader.js +1 -1
  136. package/lib/schema-component/antd/form-item/FormItem.js +10 -3
  137. package/lib/schema-component/antd/grid-card/GridCard.Designer.js +4 -5
  138. package/lib/schema-component/antd/index.less +1 -3
  139. package/lib/schema-component/antd/menu/Menu.js +304 -154
  140. package/lib/schema-component/antd/page/Page.js +29 -23
  141. package/lib/schema-component/antd/remote-select/RemoteSelect.js +55 -7
  142. package/lib/schema-component/antd/remote-select/utils.d.ts +4 -0
  143. package/lib/schema-component/antd/remote-select/utils.js +41 -0
  144. package/lib/schema-component/antd/table-v2/FilterDynamicComponent.js +17 -2
  145. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +50 -11
  146. package/lib/schema-component/antd/table-v2/Table.js +9 -7
  147. package/lib/schema-component/antd/tabs/Tabs.js +34 -21
  148. package/lib/schema-component/antd/tabs/context.d.ts +1 -1
  149. package/lib/schema-component/antd/upload/ReadPretty.js +7 -3
  150. package/lib/schema-component/antd/variable/VariableSelect.js +1 -1
  151. package/lib/schema-component/common/utils/uitls.d.ts +1 -0
  152. package/lib/schema-component/common/utils/uitls.js +3 -1
  153. package/lib/schema-initializer/SchemaInitializer.d.ts +7 -2
  154. package/lib/schema-initializer/SchemaInitializer.js +154 -101
  155. package/lib/schema-initializer/SelectCollection.d.ts +1 -2
  156. package/lib/schema-initializer/SelectCollection.js +22 -17
  157. package/lib/schema-initializer/buttons/TableActionColumnInitializers.js +1 -1
  158. package/lib/schema-initializer/buttons/TableActionInitializers.js +5 -5
  159. package/lib/schema-initializer/buttons/TableColumnInitializers.js +2 -1
  160. package/lib/schema-initializer/components/CreateRecordAction.js +35 -25
  161. package/lib/schema-initializer/components/assigned-field/AssignedField.js +2 -1
  162. package/lib/schema-initializer/items/CalendarBlockInitializer.js +9 -9
  163. package/lib/schema-initializer/utils.d.ts +0 -1
  164. package/lib/schema-initializer/utils.js +41 -25
  165. package/lib/schema-settings/SchemaSettings.js +122 -45
  166. package/lib/schema-settings/VariableInput/hooks/useFormVariable.d.ts +19 -0
  167. package/lib/schema-settings/VariableInput/hooks/useFormVariable.js +96 -0
  168. package/lib/schema-settings/VariableInput/hooks/useIterationVariable.d.ts +8 -0
  169. package/lib/schema-settings/VariableInput/hooks/useIterationVariable.js +84 -0
  170. package/lib/schema-settings/VariableInput/hooks/useVariableOptions.d.ts +5 -12
  171. package/lib/schema-settings/VariableInput/hooks/useVariableOptions.js +19 -3
  172. package/lib/schema-templates/BlockTemplateDetails.js +5 -1
  173. package/lib/schema-templates/BlockTemplatePage.js +5 -2
  174. package/lib/user/ChangePassword.d.ts +1 -2
  175. package/lib/user/ChangePassword.js +30 -26
  176. package/lib/user/CurrentUser.js +166 -135
  177. package/lib/user/EditProfile.d.ts +1 -2
  178. package/lib/user/EditProfile.js +31 -25
  179. package/lib/user/LanguageSettings.d.ts +1 -2
  180. package/lib/user/LanguageSettings.js +66 -63
  181. package/lib/user/SigninPage.js +25 -22
  182. package/lib/user/SwitchRole.d.ts +1 -2
  183. package/lib/user/SwitchRole.js +57 -51
  184. package/lib/user/ThemeSettings.d.ts +1 -2
  185. package/lib/user/ThemeSettings.js +59 -54
  186. package/package.json +9 -8
  187. package/es/settings-form/SettingsForm.d.ts +0 -13
  188. package/es/settings-form/SettingsForm.js +0 -309
  189. package/es/settings-form/index.d.ts +0 -1
  190. package/es/settings-form/index.js +0 -1
  191. package/lib/settings-form/SettingsForm.d.ts +0 -13
  192. package/lib/settings-form/SettingsForm.js +0 -320
  193. package/lib/settings-form/index.d.ts +0 -1
  194. package/lib/settings-form/index.js +0 -16
@@ -1,7 +1,7 @@
1
1
  import { Spin } from 'antd';
2
2
  import React, { createContext, useContext } from 'react';
3
3
  import { useRequest } from '../../api-client';
4
- import { useRoute } from '../../route-switch';
4
+ import { useAdminSchemaUid } from '../../hooks';
5
5
  var MenuItemsContext = /*#__PURE__*/createContext(null);
6
6
  export var toItems = function toItems() {
7
7
  var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -26,9 +26,9 @@ export var useMenuItems = function useMenuItems() {
26
26
  };
27
27
  export var MenuItemsProvider = function MenuItemsProvider(props) {
28
28
  var _service$data, _service$data$data;
29
- var route = useRoute();
29
+ var adminSchemaUid = useAdminSchemaUid();
30
30
  var options = {
31
- url: "uiSchemas:getProperties/".concat(route.uiSchemaUid)
31
+ url: "uiSchemas:getProperties/".concat(adminSchemaUid)
32
32
  };
33
33
  var service = useRequest(options);
34
34
  if (service.loading) {
@@ -29,6 +29,8 @@ import { Link, NavLink } from 'react-router-dom';
29
29
  import { ACLProvider } from '../acl';
30
30
  import { AntdConfigProvider } from '../antd-config-provider';
31
31
  import { APIClient, APIClientProvider } from '../api-client';
32
+ import { SigninPage, SignupPage } from '../auth';
33
+ import { SigninPageExtensionProvider } from '../auth/SigninPageExtension';
32
34
  import { BlockSchemaComponentProvider } from '../block-provider';
33
35
  import { RemoteDocumentTitleProvider } from '../document-title';
34
36
  import { i18n } from '../i18n';
@@ -40,8 +42,6 @@ import { ErrorFallback } from '../schema-component/antd/error-fallback';
40
42
  import { SchemaInitializerProvider } from '../schema-initializer';
41
43
  import { BlockTemplateDetails, BlockTemplatePage } from '../schema-templates';
42
44
  import { SystemSettingsProvider } from '../system-settings';
43
- import { SigninPage, SignupPage } from '../auth';
44
- import { SigninPageExtensionProvider } from '../auth/SigninPageExtension';
45
45
  import { compose } from './compose';
46
46
  export var getCurrentTimezone = function getCurrentTimezone() {
47
47
  var timezoneOffset = new Date().getTimezoneOffset() / -60;
@@ -15,14 +15,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
15
15
  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; }
16
16
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
- import { Space, Tabs } from 'antd';
19
- import React, { useCallback, useContext, createContext, createElement, useState } from 'react';
20
18
  import { css } from '@emotion/css';
19
+ import { useForm } from '@formily/react';
20
+ import { Space, Tabs } from 'antd';
21
+ import React, { createContext, createElement, useCallback, useContext, useState } from 'react';
21
22
  import { useTranslation } from 'react-i18next';
22
23
  import { useNavigate, useSearchParams } from 'react-router-dom';
23
24
  import { useAPIClient, useCurrentDocumentTitle, useRequest, useViewport } from '..';
24
25
  import { useSigninPageExtension } from './SigninPageExtension';
25
- import { useForm } from '@formily/react';
26
26
  var SigninPageContext = /*#__PURE__*/createContext({});
27
27
  export var SigninPageProvider = function SigninPageProvider(props) {
28
28
  var components = useContext(SigninPageContext);
@@ -129,12 +129,15 @@ export var SigninPage = function SigninPage() {
129
129
  }, /*#__PURE__*/React.createElement(Space, {
130
130
  direction: "vertical",
131
131
  className: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n "])))
132
- }, tabs.length > 1 ? /*#__PURE__*/React.createElement(Tabs, null, tabs.map(function (tab) {
133
- return /*#__PURE__*/React.createElement(Tabs.TabPane, {
134
- tab: tab.tabTitle,
135
- key: tab.name
136
- }, tab.component);
137
- })) : tabs.length ? /*#__PURE__*/React.createElement("div", null, tabs[0].component) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(Space, {
132
+ }, tabs.length > 1 ? /*#__PURE__*/React.createElement(Tabs, {
133
+ items: tabs.map(function (tab) {
134
+ return {
135
+ label: tab.tabTitle,
136
+ key: tab.name,
137
+ children: tab.component
138
+ };
139
+ })
140
+ }) : tabs.length ? /*#__PURE__*/React.createElement("div", null, tabs[0].component) : /*#__PURE__*/React.createElement(React.Fragment, null), /*#__PURE__*/React.createElement(Space, {
138
141
  direction: "vertical",
139
142
  className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n "])))
140
143
  }, signinExtension)));
@@ -21,9 +21,9 @@ import { DownOutlined, PlusOutlined } from '@ant-design/icons';
21
21
  import { ArrayTable } from '@formily/antd';
22
22
  import { useField, useForm } from '@formily/react';
23
23
  import { uid } from '@formily/shared';
24
- import { Button, Dropdown, Menu } from 'antd';
24
+ import { Button, Dropdown } from 'antd';
25
25
  import { cloneDeep } from 'lodash';
26
- import React, { useState } from 'react';
26
+ import React, { useMemo, useState } from 'react';
27
27
  import { useTranslation } from 'react-i18next';
28
28
  import { useRequest } from '../../api-client';
29
29
  import { RecordProvider, useRecord } from '../../record-provider';
@@ -308,21 +308,38 @@ export var AddCollectionAction = function AddCollectionAction(props) {
308
308
  var compile = useCompile();
309
309
  var _useTranslation = useTranslation(),
310
310
  t = _useTranslation.t;
311
- var collectionTemplates = templateOptions();
312
- var items = [];
313
- collectionTemplates.forEach(function (item) {
314
- if (item.divider) {
315
- items.push({
316
- type: 'divider'
311
+ var collectionTemplates = useMemo(templateOptions, []);
312
+ var items = useMemo(function () {
313
+ var result = [];
314
+ collectionTemplates.forEach(function (item) {
315
+ if (item.divider) {
316
+ result.push({
317
+ type: 'divider'
318
+ });
319
+ }
320
+ result.push({
321
+ label: compile(item.title),
322
+ key: item.name
317
323
  });
318
- }
319
- items.push({
320
- label: compile(item.title),
321
- key: item.name
322
324
  });
323
- });
325
+ return result;
326
+ }, [collectionTemplates]);
324
327
  var _useResourceActionCon2 = useResourceActionContext(),
325
328
  category = _useResourceActionCon2.state.category;
329
+ var menu = useMemo(function () {
330
+ return {
331
+ style: {
332
+ maxHeight: '60vh',
333
+ overflow: 'auto'
334
+ },
335
+ onClick: function onClick(info) {
336
+ var schema = getSchema(getTemplate(info.key), category, compile);
337
+ setSchema(schema);
338
+ setVisible(true);
339
+ },
340
+ items: items
341
+ };
342
+ }, [category, items]);
326
343
  return /*#__PURE__*/React.createElement(RecordProvider, {
327
344
  record: record
328
345
  }, /*#__PURE__*/React.createElement(ActionContextProvider, {
@@ -334,18 +351,7 @@ export var AddCollectionAction = function AddCollectionAction(props) {
334
351
  getPopupContainer: getContainer,
335
352
  trigger: trigger,
336
353
  align: align,
337
- overlay: /*#__PURE__*/React.createElement(Menu, {
338
- style: {
339
- maxHeight: '60vh',
340
- overflow: 'auto'
341
- },
342
- onClick: function onClick(info) {
343
- var schema = getSchema(getTemplate(info.key), category, compile);
344
- setSchema(schema);
345
- setVisible(true);
346
- },
347
- items: items
348
- })
354
+ menu: menu
349
355
  }, children || /*#__PURE__*/React.createElement(Button, {
350
356
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
351
357
  type: 'primary'
@@ -17,9 +17,9 @@ import { PlusOutlined } from '@ant-design/icons';
17
17
  import { ArrayTable } from '@formily/antd';
18
18
  import { useField, useForm } from '@formily/react';
19
19
  import { uid } from '@formily/shared';
20
- import { Button, Dropdown, Menu } from 'antd';
20
+ import { Button, Dropdown } from 'antd';
21
21
  import { cloneDeep } from 'lodash';
22
- import React, { useState } from 'react';
22
+ import React, { useCallback, useMemo, useState } from 'react';
23
23
  import { useTranslation } from 'react-i18next';
24
24
  import { useRequest } from '../../api-client';
25
25
  import { RecordProvider, useRecord } from '../../record-provider';
@@ -27,7 +27,6 @@ import { ActionContextProvider, SchemaComponent, useActionContext, useCompile }
27
27
  import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider';
28
28
  import { useCancelAction } from '../action-hooks';
29
29
  import { useCollectionManager } from '../hooks';
30
- import { useOptions } from '../hooks/useOptions';
31
30
  import * as components from './components';
32
31
  import { getOptions } from './interfaces';
33
32
  var getSchema = function getSchema(schema, record, compile) {
@@ -217,8 +216,7 @@ export var AddFieldAction = function AddFieldAction(props) {
217
216
  var compile = useCompile();
218
217
  var _useTranslation = useTranslation(),
219
218
  t = _useTranslation.t;
220
- var options = useOptions();
221
- var getFieldOptions = function getFieldOptions() {
219
+ var getFieldOptions = useCallback(function () {
222
220
  var _ref = getTemplate(record.template) || {},
223
221
  availableFieldInterfaces = _ref.availableFieldInterfaces;
224
222
  var _ref2 = availableFieldInterfaces || {},
@@ -260,19 +258,32 @@ export var AddFieldAction = function AddFieldAction(props) {
260
258
  }
261
259
  });
262
260
  return optionArr;
263
- };
264
- return record.template !== 'view' && /*#__PURE__*/React.createElement(RecordProvider, {
265
- record: record
266
- }, /*#__PURE__*/React.createElement(ActionContextProvider, {
267
- value: {
268
- visible: visible,
269
- setVisible: setVisible
270
- }
271
- }, /*#__PURE__*/React.createElement(Dropdown, {
272
- getPopupContainer: getContainer,
273
- trigger: trigger,
274
- align: align,
275
- overlay: /*#__PURE__*/React.createElement(Menu, {
261
+ }, [getTemplate, record]);
262
+ var items = useMemo(function () {
263
+ return getFieldOptions().map(function (option) {
264
+ if (option.children.length === 0) {
265
+ return null;
266
+ }
267
+ return {
268
+ type: 'group',
269
+ label: compile(option.label),
270
+ title: compile(option.label),
271
+ key: option.label,
272
+ children: option.children.filter(function (child) {
273
+ return !['o2o', 'subTable', 'linkTo'].includes(child.name);
274
+ }).map(function (child) {
275
+ return {
276
+ label: compile(child.title),
277
+ title: compile(child.title),
278
+ key: child.name,
279
+ dataTargetScope: child.targetScope
280
+ };
281
+ })
282
+ };
283
+ });
284
+ }, [getFieldOptions]);
285
+ var menu = useMemo(function () {
286
+ return {
276
287
  style: {
277
288
  maxHeight: '60vh',
278
289
  overflow: 'auto'
@@ -286,20 +297,22 @@ export var AddFieldAction = function AddFieldAction(props) {
286
297
  setSchema(schema);
287
298
  setVisible(true);
288
299
  }
289
- }
290
- }, getFieldOptions().map(function (option) {
291
- return option.children.length > 0 && /*#__PURE__*/React.createElement(Menu.ItemGroup, {
292
- key: option.label,
293
- title: compile(option.label)
294
- }, option.children.filter(function (child) {
295
- return !['o2o', 'subTable', 'linkTo'].includes(child.name);
296
- }).map(function (child) {
297
- return /*#__PURE__*/React.createElement(Menu.Item, {
298
- key: child.name,
299
- "data-targetScope": child.targetScope
300
- }, compile(child.title));
301
- }));
302
- }))
300
+ },
301
+ items: items
302
+ };
303
+ }, [getInterface, items, record]);
304
+ return record.template !== 'view' && /*#__PURE__*/React.createElement(RecordProvider, {
305
+ record: record
306
+ }, /*#__PURE__*/React.createElement(ActionContextProvider, {
307
+ value: {
308
+ visible: visible,
309
+ setVisible: setVisible
310
+ }
311
+ }, /*#__PURE__*/React.createElement(Dropdown, {
312
+ getPopupContainer: getContainer,
313
+ trigger: trigger,
314
+ align: align,
315
+ menu: menu
303
316
  }, children || /*#__PURE__*/React.createElement(Button, {
304
317
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
305
318
  type: 'primary'
@@ -16,9 +16,9 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
16
16
  import { PlusOutlined } from '@ant-design/icons';
17
17
  import { ArrayTable } from '@formily/antd';
18
18
  import { uid } from '@formily/shared';
19
- import { Button, Dropdown, Menu } from 'antd';
19
+ import { Button, Dropdown } from 'antd';
20
20
  import { cloneDeep } from 'lodash';
21
- import React, { useState } from 'react';
21
+ import React, { useMemo, useState } from 'react';
22
22
  import { useTranslation } from 'react-i18next';
23
23
  import { useRequest } from '../../api-client';
24
24
  import { RecordProvider } from '../../record-provider';
@@ -122,26 +122,23 @@ export var AddSubFieldAction = function AddSubFieldAction() {
122
122
  var options = useOptions();
123
123
  var _useTranslation = useTranslation(),
124
124
  t = _useTranslation.t;
125
- var items = options.map(function (option) {
126
- var children = option.children.map(function (child) {
125
+ var items = useMemo(function () {
126
+ return options.map(function (option) {
127
+ var children = option.children.map(function (child) {
128
+ return {
129
+ label: compile(child.title),
130
+ key: child.name
131
+ };
132
+ });
127
133
  return {
128
- label: compile(child.title),
129
- key: child.name
134
+ label: compile(option.label),
135
+ key: option.key,
136
+ children: children
130
137
  };
131
138
  });
139
+ }, [options]);
140
+ var menu = useMemo(function () {
132
141
  return {
133
- label: compile(option.label),
134
- key: option.key,
135
- children: children
136
- };
137
- });
138
- return /*#__PURE__*/React.createElement(ActionContextProvider, {
139
- value: {
140
- visible: visible,
141
- setVisible: setVisible
142
- }
143
- }, /*#__PURE__*/React.createElement(Dropdown, {
144
- overlay: /*#__PURE__*/React.createElement(Menu, {
145
142
  style: {
146
143
  maxHeight: '60vh',
147
144
  overflow: 'auto'
@@ -152,7 +149,15 @@ export var AddSubFieldAction = function AddSubFieldAction() {
152
149
  setVisible(true);
153
150
  },
154
151
  items: items
155
- })
152
+ };
153
+ }, [items]);
154
+ return /*#__PURE__*/React.createElement(ActionContextProvider, {
155
+ value: {
156
+ visible: visible,
157
+ setVisible: setVisible
158
+ }
159
+ }, /*#__PURE__*/React.createElement(Dropdown, {
160
+ menu: menu
156
161
  }, /*#__PURE__*/React.createElement(Button, {
157
162
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
158
163
  type: 'primary'
@@ -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',