@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
@@ -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,90 @@
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 React, { createContext, useCallback, useContext, useRef } from 'react';
8
+ export var GetMenuItemContext = /*#__PURE__*/createContext(null);
9
+ export var GetMenuItemsContext = /*#__PURE__*/createContext(null);
10
+ /**
11
+ * 用于为 SchemaInitializer.Item 组件提供一些方法,比如收集菜单项数据
12
+ * @returns
13
+ */
14
+ export var useCollectMenuItem = function useCollectMenuItem() {
15
+ return useContext(GetMenuItemContext) || {};
16
+ };
17
+ export var useCollectMenuItems = function useCollectMenuItems() {
18
+ return useContext(GetMenuItemsContext) || {};
19
+ };
20
+ /**
21
+ * 用于在 antd 从 4.x 升级到 5.x 中,用于把 SchemaInitializer.Item 组件这种写法转换成 Menu 组件的 items 写法
22
+ * @returns
23
+ */
24
+ export var useMenuItem = function useMenuItem() {
25
+ var list = useRef([]);
26
+ var renderItems = useRef(null);
27
+ var shouldRerender = useRef(false);
28
+ var Component = useCallback(function () {
29
+ if (!shouldRerender.current) {
30
+ return null;
31
+ }
32
+ shouldRerender.current = false;
33
+ if (renderItems.current) {
34
+ return renderItems.current();
35
+ }
36
+ return /*#__PURE__*/React.createElement(React.Fragment, null, list.current.map(function (Com, index) {
37
+ return /*#__PURE__*/React.createElement(Com, {
38
+ key: index
39
+ });
40
+ }));
41
+ }, []);
42
+ var getMenuItems = useCallback(function (Com) {
43
+ var items = [];
44
+ var pushMenuItem = function pushMenuItem(item) {
45
+ items.push(item);
46
+ items.sort(function (a, b) {
47
+ return (a.order || 0) - (b.order || 0);
48
+ });
49
+ };
50
+ shouldRerender.current = true;
51
+ renderItems.current = function () {
52
+ var notDeleteItems = items.filter(function (item) {
53
+ return item.notdelete;
54
+ });
55
+ items.length = 0;
56
+ items.push.apply(items, _toConsumableArray(notDeleteItems));
57
+ return /*#__PURE__*/React.createElement(GetMenuItemsContext.Provider, {
58
+ value: {
59
+ pushMenuItem: pushMenuItem
60
+ }
61
+ }, Com());
62
+ };
63
+ return items;
64
+ }, []);
65
+ var getMenuItem = useCallback(function (Com) {
66
+ var item = {};
67
+ var collectMenuItem = function collectMenuItem(menuItem) {
68
+ Object.assign(item, menuItem);
69
+ };
70
+ shouldRerender.current = true;
71
+ list.current.push(function () {
72
+ return /*#__PURE__*/React.createElement(GetMenuItemContext.Provider, {
73
+ value: {
74
+ collectMenuItem: collectMenuItem
75
+ }
76
+ }, Com());
77
+ });
78
+ return item;
79
+ }, []);
80
+ // 防止 list 有重复元素
81
+ var clean = useCallback(function () {
82
+ list.current = [];
83
+ }, []);
84
+ return {
85
+ Component: Component,
86
+ getMenuItems: getMenuItems,
87
+ getMenuItem: getMenuItem,
88
+ clean: clean
89
+ };
90
+ };
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;
@@ -280,7 +280,7 @@ export default {
280
280
  "Display field title": "Mostrar título de campo",
281
281
  "Field component": "Componente del campo",
282
282
  "Subtable": "Subtabla",
283
- "Subform": "Subformulario",
283
+ "Sub-form": "Subformulario",
284
284
  "Record picker": "Selector de registros",
285
285
  "Toggles the subfield mode": "Alterna el modo de subcampo",
286
286
  "Selector mode": "Modo selector",
@@ -540,7 +540,7 @@ declare const _default: {
540
540
  "Quick upload": string;
541
541
  "Select file": string;
542
542
  Subtable: string;
543
- Subform: string;
543
+ "Sub-form": string;
544
544
  "Sub-details": string;
545
545
  "Field mode": string;
546
546
  "Allow add new data": string;
@@ -612,5 +612,7 @@ declare const _default: {
612
612
  "Update or create": string;
613
613
  "Find by the following fields": string;
614
614
  Create: string;
615
+ "Current form": string;
616
+ "Current object": string;
615
617
  };
616
618
  export default _default;
@@ -540,7 +540,7 @@ export default {
540
540
  "Quick upload": "クイックアップロード",
541
541
  "Select file": "ファイルを選択",
542
542
  "Subtable": "サブテーブル",
543
- "Subform": "サブフォーム",
543
+ "Sub-form": "サブフォーム",
544
544
  "Sub-details": "サブリスト",
545
545
  "Field mode": "フィールドコンポーネント",
546
546
  "Allow add new data": "データの追加を許可",
@@ -612,5 +612,7 @@ export default {
612
612
  "First or create": "存在しない場合に追加",
613
613
  "Update or create": "存在しなければ新規、存在すれば更新",
614
614
  "Find by the following fields": "次のフィールドで検索",
615
- "Create": "新規のみ"
615
+ "Create": "新規のみ",
616
+ "Current form": "現在のフォーム",
617
+ "Current object": "現在のオブジェクト"
616
618
  };
@@ -244,7 +244,7 @@ declare const _default: {
244
244
  "Select file": string;
245
245
  "Allow multiple": string;
246
246
  Subtable: string;
247
- Subform: string;
247
+ "Sub-form": string;
248
248
  "Record picker": string;
249
249
  "Toggles the subfield mode": string;
250
250
  "Selector mode": string;
@@ -244,7 +244,7 @@ export default {
244
244
  "Select file": "Selecionar arquivo",
245
245
  "Allow multiple": "Permitir múltiplos",
246
246
  "Subtable": "Subtabela",
247
- "Subform": "Subformulário",
247
+ "Sub-form": "Subformulário",
248
248
  "Record picker": "Selecionador de registros",
249
249
  "Toggles the subfield mode": "Alterna o modo de subcampo",
250
250
  "Selector mode": "Modo de seleção",
@@ -478,7 +478,7 @@ declare const _default: {
478
478
  "Quick upload": string;
479
479
  "Select file": string;
480
480
  Subtable: string;
481
- Subform: string;
481
+ "Sub-form": string;
482
482
  "Regular expression": string;
483
483
  "Enabled languages": string;
484
484
  "View all plugins": string;
@@ -478,7 +478,7 @@ export default {
478
478
  "Quick upload": "Быстрая загрузка",
479
479
  "Select file": "Выбрать файл",
480
480
  "Subtable": "Подтаблица",
481
- "Subform": "Подформа",
481
+ "Sub-form": "Подформа",
482
482
  "Regular expression": "Образец",
483
483
  "Enabled languages": "Включенные языки",
484
484
  "View all plugins": "Посмотреть все плагины",
@@ -313,7 +313,7 @@ declare const _default: {
313
313
  "Quick upload": string;
314
314
  "Select file": string;
315
315
  Subtable: string;
316
- Subform: string;
316
+ "Sub-form": string;
317
317
  "Sub-details": string;
318
318
  "Record picker": string;
319
319
  "Toggles the subfield mode": string;
@@ -748,6 +748,8 @@ declare const _default: {
748
748
  "Update or create": string;
749
749
  "Find by the following fields": string;
750
750
  Create: string;
751
+ "Current form": string;
752
+ "Current object": string;
751
753
  "Quick create": string;
752
754
  Dropdown: string;
753
755
  "Pop-up": string;
@@ -313,7 +313,7 @@ export default {
313
313
  "Quick upload": "快速上传",
314
314
  "Select file": "选择文件",
315
315
  "Subtable": "子表格",
316
- "Subform": "子表单",
316
+ "Sub-form": "子表单",
317
317
  "Sub-details": "子详情",
318
318
  "Record picker": "数据选择器",
319
319
  "Toggles the subfield mode": "切换子字段模式",
@@ -749,6 +749,8 @@ export default {
749
749
  "Update or create": "不存在时新增,存在时更新",
750
750
  "Find by the following fields": "通过以下字段查找",
751
751
  "Create": "仅新增",
752
+ "Current form": "当前表单",
753
+ "Current object": "当前对象",
752
754
  "Quick create": "快速创建",
753
755
  "Dropdown": "下拉菜单",
754
756
  "Pop-up": "弹窗",
package/es/pm/Card.js CHANGED
@@ -10,14 +10,14 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
10
10
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
11
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import React, { useEffect, useMemo, useState, useCallback } from 'react';
14
- import { useAPIClient, useRequest } from '../api-client';
15
- import { Avatar, Card, message, Modal, Popconfirm, Spin, Switch, Tabs, Tag, Tooltip, Typography } from 'antd';
13
+ import { DeleteOutlined, SettingOutlined } from '@ant-design/icons';
16
14
  import { css } from '@emotion/css';
15
+ import { Avatar, Card, Modal, Popconfirm, Spin, Switch, Tabs, Tag, Tooltip, Typography, message } from 'antd';
17
16
  import cls from 'classnames';
18
- import { useNavigate } from 'react-router-dom';
17
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
19
18
  import { useTranslation } from 'react-i18next';
20
- import { DeleteOutlined, SettingOutlined } from '@ant-design/icons';
19
+ import { useNavigate } from 'react-router-dom';
20
+ import { useAPIClient, useRequest } from '../api-client';
21
21
  import { useParseMarkdown } from '../schema-component/antd/markdown/util';
22
22
  /**
23
23
  * get color by string
@@ -16,12 +16,13 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
16
16
  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); }
17
17
  import { ApiOutlined, SettingOutlined } from '@ant-design/icons';
18
18
  import { Button, Dropdown, Tooltip } from 'antd';
19
- import React, { useContext, useState } from 'react';
19
+ import _ from 'lodash';
20
+ import React, { useContext, useMemo, useState } from 'react';
20
21
  import { useTranslation } from 'react-i18next';
21
22
  import { useNavigate } from 'react-router-dom';
22
23
  import { useACLRoleContext } from '../acl/ACLProvider';
23
24
  import { ActionContextProvider, useCompile } from '../schema-component';
24
- import { getPluginsTabs, SettingsCenterContext } from './index';
25
+ import { SettingsCenterContext, getPluginsTabs } from './index';
25
26
  export var PluginManagerLink = function PluginManagerLink() {
26
27
  var _useTranslation = useTranslation(),
27
28
  t = _useTranslation.t;
@@ -36,7 +37,7 @@ export var PluginManagerLink = function PluginManagerLink() {
36
37
  }
37
38
  }));
38
39
  };
39
- var getBookmarkTabs = function getBookmarkTabs(data) {
40
+ var getBookmarkTabs = _.memoize(function (data) {
40
41
  var bookmarkTabs = [];
41
42
  data.forEach(function (plugin) {
42
43
  var tabs = plugin.tabs;
@@ -47,7 +48,7 @@ var getBookmarkTabs = function getBookmarkTabs(data) {
47
48
  });
48
49
  });
49
50
  return bookmarkTabs;
50
- };
51
+ });
51
52
  export var SettingsCenterDropdown = function SettingsCenterDropdown() {
52
53
  var _useACLRoleContext = useACLRoleContext(),
53
54
  _useACLRoleContext$sn = _useACLRoleContext.snippets,
@@ -63,14 +64,8 @@ export var SettingsCenterDropdown = function SettingsCenterDropdown() {
63
64
  var itemData = useContext(SettingsCenterContext);
64
65
  var pluginsTabs = getPluginsTabs(itemData, snippets);
65
66
  var bookmarkTabs = getBookmarkTabs(pluginsTabs);
66
- return /*#__PURE__*/React.createElement(ActionContextProvider, {
67
- value: {
68
- visible: visible,
69
- setVisible: setVisible
70
- }
71
- }, /*#__PURE__*/React.createElement(Dropdown, {
72
- placement: "bottom",
73
- menu: {
67
+ var menu = useMemo(function () {
68
+ return {
74
69
  items: [].concat(_toConsumableArray(bookmarkTabs.map(function (tab) {
75
70
  return {
76
71
  key: "/admin/settings/".concat(tab.path),
@@ -86,7 +81,16 @@ export var SettingsCenterDropdown = function SettingsCenterDropdown() {
86
81
  var key = _ref.key;
87
82
  navigate(key);
88
83
  }
84
+ };
85
+ }, [bookmarkTabs]);
86
+ return /*#__PURE__*/React.createElement(ActionContextProvider, {
87
+ value: {
88
+ visible: visible,
89
+ setVisible: setVisible
89
90
  }
91
+ }, /*#__PURE__*/React.createElement(Dropdown, {
92
+ placement: "bottom",
93
+ menu: menu
90
94
  }, /*#__PURE__*/React.createElement(Button, {
91
95
  icon: /*#__PURE__*/React.createElement(SettingOutlined, null)
92
96
  })));
package/es/pm/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import _ from 'lodash';
1
2
  import React from 'react';
2
3
  export interface TData {
3
4
  data: IPluginData[];
@@ -29,7 +30,7 @@ export interface AllowedActions {
29
30
  destroy: number[];
30
31
  }
31
32
  export declare const SettingsCenterContext: React.Context<any>;
32
- export declare const getPluginsTabs: (items: any, snippets: any) => any[];
33
+ export declare const getPluginsTabs: ((items: any, snippets: any) => any[]) & _.MemoizedFunction;
33
34
  export declare const SettingsCenterProvider: (props: any) => React.JSX.Element;
34
35
  export declare const PMProvider: (props: any) => React.JSX.Element;
35
36
  export default PMProvider;