@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
@@ -1,14 +1,9 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _excluded = ["onSelect", "mode", "selectedUid", "defaultSelectedUid", "sideMenuRefScopeKey", "defaultSelectedKeys", "defaultOpenKeys"],
3
- _excluded2 = ["icon"],
4
- _excluded3 = ["icon"],
5
- _excluded4 = ["icon"];
6
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
- 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); }
2
+ var _excluded = ["onSelect", "mode", "selectedUid", "defaultSelectedUid", "sideMenuRefScopeKey", "defaultSelectedKeys", "defaultOpenKeys", "children"],
3
+ _excluded2 = ["icon", "children"],
4
+ _excluded3 = ["icon", "children"],
5
+ _excluded4 = ["icon", "children"];
6
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
12
7
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
9
  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); }
@@ -17,21 +12,170 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
17
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
13
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
14
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
+ 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); }
20
20
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
21
21
  import { css } from '@emotion/css';
22
- import { observer, RecursionField, SchemaExpressionScopeContext, useField, useFieldSchema } from '@formily/react';
22
+ import { FieldContext, observer, RecursionField, SchemaContext, SchemaExpressionScopeContext, useField, useFieldSchema } from '@formily/react';
23
+ import { error } from '@nocobase/utils/client';
23
24
  import { Menu as AntdMenu } from 'antd';
24
- import React, { createContext, useContext, useEffect, useState } from 'react';
25
+ import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
25
26
  import { createPortal } from 'react-dom';
26
27
  import { useTranslation } from 'react-i18next';
27
28
  import { createDesignable, DndContext, SortableItem, useDesignable, useDesigner } from '../..';
28
29
  import { Icon, useAPIClient, useSchemaInitializer } from '../../../';
30
+ import { useCollectMenuItems, useMenuItem } from '../../../hooks/useMenuItem';
29
31
  import { useProps } from '../../hooks/useProps';
30
32
  import { MenuDesigner } from './Menu.Designer';
31
33
  import { findKeysByUid, findMenuItem } from './util';
32
34
  var subMenuDesignerCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n display: inline-block;\n margin-left: -24px;\n margin-right: -34px;\n padding: 0 34px 0 24px;\n width: calc(100% + 58px);\n &:hover {\n > .general-schema-designer {\n display: block;\n }\n }\n &.nb-action-link {\n > .general-schema-designer {\n top: -10px;\n bottom: -10px;\n left: -10px;\n right: -10px;\n }\n }\n > .general-schema-designer {\n position: absolute;\n z-index: 999;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n background: rgba(241, 139, 98, 0.06);\n border: 0;\n pointer-events: none;\n > .general-schema-designer-icons {\n position: absolute;\n right: 2px;\n top: 2px;\n line-height: 16px;\n pointer-events: all;\n .ant-space-item {\n background-color: #f18b62;\n color: #fff;\n line-height: 16px;\n width: 16px;\n padding-left: 1px;\n }\n }\n }\n"])));
33
35
  var designerCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-left: -20px;\n margin-right: -20px;\n padding: 0 20px;\n width: calc(100% + 40px);\n &:hover {\n > .general-schema-designer {\n display: block;\n }\n }\n &.nb-action-link {\n > .general-schema-designer {\n top: -10px;\n bottom: -10px;\n left: -10px;\n right: -10px;\n }\n }\n > .general-schema-designer {\n position: absolute;\n z-index: 999;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n background: rgba(241, 139, 98, 0.06);\n border: 0;\n pointer-events: none;\n > .general-schema-designer-icons {\n position: absolute;\n right: 2px;\n top: 2px;\n line-height: 16px;\n pointer-events: all;\n .ant-space-item {\n background-color: #f18b62;\n color: #fff;\n line-height: 16px;\n width: 16px;\n padding-left: 1px;\n }\n }\n }\n"])));
34
- var antdMenuClass = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .ant-menu-item:hover {\n > .ant-menu-title-content > div {\n .general-schema-designer {\n display: block;\n }\n }\n }\n"])));
36
+ var headerMenuClass = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .ant-menu-item:hover {\n > .ant-menu-title-content > div {\n .general-schema-designer {\n display: block;\n }\n }\n }\n"])));
37
+ var sideMenuClass = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n overflow-x: hidden;\n .ant-menu-item {\n > .ant-menu-title-content {\n margin-left: -24px;\n margin-right: -16px;\n padding: 0 16px 0 24px;\n > div {\n > .general-schema-designer {\n right: 6px !important;\n }\n }\n }\n }\n .ant-menu-submenu-title {\n .ant-menu-title-content {\n margin-left: -24px;\n margin-right: -34px;\n padding: 0 34px 0 24px;\n > div {\n > .general-schema-designer {\n right: 6px !important;\n }\n > span.anticon {\n margin-right: 10px;\n }\n }\n }\n }\n"])));
38
+ var menuItemClass = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n :active {\n background: inherit;\n }\n"])));
39
+ var HeaderMenu = function HeaderMenu(_ref) {
40
+ var others = _ref.others,
41
+ schema = _ref.schema,
42
+ mode = _ref.mode,
43
+ _onSelect = _ref.onSelect,
44
+ setLoading = _ref.setLoading,
45
+ setDefaultSelectedKeys = _ref.setDefaultSelectedKeys,
46
+ defaultSelectedKeys = _ref.defaultSelectedKeys,
47
+ defaultOpenKeys = _ref.defaultOpenKeys,
48
+ selectedKeys = _ref.selectedKeys,
49
+ designable = _ref.designable,
50
+ render = _ref.render,
51
+ children = _ref.children;
52
+ var _useMenuItem = useMenuItem(),
53
+ Component = _useMenuItem.Component,
54
+ getMenuItems = _useMenuItem.getMenuItems;
55
+ var items = useMemo(function () {
56
+ var designerBtn = {
57
+ key: 'x-designer-button',
58
+ disabled: true,
59
+ style: {
60
+ padding: '0 8px',
61
+ order: 9999
62
+ },
63
+ label: render({
64
+ style: {
65
+ background: 'none'
66
+ }
67
+ }),
68
+ notdelete: true
69
+ };
70
+ var result = getMenuItems(function () {
71
+ return children;
72
+ });
73
+ if (designable) {
74
+ result.push(designerBtn);
75
+ }
76
+ return result;
77
+ }, [children, designable]);
78
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Component, null), /*#__PURE__*/React.createElement(AntdMenu, _objectSpread(_objectSpread({}, others), {}, {
79
+ className: headerMenuClass,
80
+ onSelect: function onSelect(info) {
81
+ var s = schema.properties[info.key];
82
+ if (mode === 'mix') {
83
+ if (s['x-component'] !== 'Menu.SubMenu') {
84
+ _onSelect === null || _onSelect === void 0 ? void 0 : _onSelect(info);
85
+ } else {
86
+ var menuItemSchema = findMenuItem(s);
87
+ if (!menuItemSchema) {
88
+ return _onSelect === null || _onSelect === void 0 ? void 0 : _onSelect(info);
89
+ }
90
+ // TODO
91
+ setLoading(true);
92
+ var keys = findKeysByUid(schema, menuItemSchema['x-uid']);
93
+ setDefaultSelectedKeys(keys);
94
+ setTimeout(function () {
95
+ setLoading(false);
96
+ }, 100);
97
+ _onSelect === null || _onSelect === void 0 ? void 0 : _onSelect({
98
+ key: menuItemSchema.name,
99
+ item: {
100
+ props: {
101
+ schema: menuItemSchema
102
+ }
103
+ }
104
+ });
105
+ }
106
+ } else {
107
+ _onSelect === null || _onSelect === void 0 ? void 0 : _onSelect(info);
108
+ }
109
+ },
110
+ mode: mode === 'mix' ? 'horizontal' : mode,
111
+ defaultOpenKeys: defaultOpenKeys,
112
+ defaultSelectedKeys: defaultSelectedKeys,
113
+ selectedKeys: selectedKeys,
114
+ items: items
115
+ })));
116
+ };
117
+ var SideMenu = function SideMenu(_ref2) {
118
+ var _sideMenuRef$current;
119
+ var loading = _ref2.loading,
120
+ mode = _ref2.mode,
121
+ sideMenuSchema = _ref2.sideMenuSchema,
122
+ sideMenuRef = _ref2.sideMenuRef,
123
+ defaultOpenKeys = _ref2.defaultOpenKeys,
124
+ defaultSelectedKeys = _ref2.defaultSelectedKeys,
125
+ _onSelect2 = _ref2.onSelect,
126
+ render = _ref2.render,
127
+ t = _ref2.t,
128
+ api = _ref2.api,
129
+ refresh = _ref2.refresh,
130
+ designable = _ref2.designable;
131
+ var _useMenuItem2 = useMenuItem(),
132
+ Component = _useMenuItem2.Component,
133
+ getMenuItems = _useMenuItem2.getMenuItems;
134
+ var items = useMemo(function () {
135
+ var result = getMenuItems(function () {
136
+ return /*#__PURE__*/React.createElement(RecursionField, {
137
+ schema: sideMenuSchema,
138
+ onlyRenderProperties: true
139
+ });
140
+ });
141
+ if (designable) {
142
+ result.push({
143
+ key: 'x-designer-button',
144
+ disabled: true,
145
+ label: render({
146
+ insert: function insert(s) {
147
+ var dn = createDesignable({
148
+ t: t,
149
+ api: api,
150
+ refresh: refresh,
151
+ current: sideMenuSchema
152
+ });
153
+ dn.loadAPIClientEvents();
154
+ dn.insertAdjacent('beforeEnd', s);
155
+ }
156
+ }),
157
+ order: 1,
158
+ notdelete: true
159
+ });
160
+ }
161
+ return result;
162
+ }, [render, sideMenuSchema, designable, loading]);
163
+ if (loading) {
164
+ return null;
165
+ }
166
+ return mode === 'mix' && (sideMenuSchema === null || sideMenuSchema === void 0 ? void 0 : sideMenuSchema['x-component']) === 'Menu.SubMenu' && (sideMenuRef === null || sideMenuRef === void 0 ? void 0 : (_sideMenuRef$current = sideMenuRef.current) === null || _sideMenuRef$current === void 0 ? void 0 : _sideMenuRef$current.firstChild) && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(MenuModeContext.Provider, {
167
+ value: 'inline'
168
+ }, /*#__PURE__*/React.createElement(Component, null), /*#__PURE__*/React.createElement(AntdMenu, {
169
+ mode: 'inline',
170
+ defaultOpenKeys: defaultOpenKeys,
171
+ defaultSelectedKeys: defaultSelectedKeys,
172
+ onSelect: function onSelect(info) {
173
+ _onSelect2 === null || _onSelect2 === void 0 ? void 0 : _onSelect2(info);
174
+ },
175
+ className: sideMenuClass,
176
+ items: items
177
+ })), sideMenuRef.current.firstChild);
178
+ };
35
179
  var MenuModeContext = /*#__PURE__*/createContext(null);
36
180
  MenuModeContext.displayName = 'MenuModeContext';
37
181
  var useSideMenuRef = function useSideMenuRef() {
@@ -47,15 +191,15 @@ var useSideMenuRef = function useSideMenuRef() {
47
191
  var MenuItemDesignerContext = /*#__PURE__*/createContext(null);
48
192
  MenuItemDesignerContext.displayName = 'MenuItemDesignerContext';
49
193
  export var Menu = observer(function (props) {
50
- var _sideMenuRef$current;
51
194
  var _useProps = useProps(props),
52
- _onSelect = _useProps.onSelect,
195
+ onSelect = _useProps.onSelect,
53
196
  mode = _useProps.mode,
54
197
  selectedUid = _useProps.selectedUid,
55
198
  defaultSelectedUid = _useProps.defaultSelectedUid,
56
199
  sideMenuRefScopeKey = _useProps.sideMenuRefScopeKey,
57
200
  dSelectedKeys = _useProps.defaultSelectedKeys,
58
201
  dOpenKeys = _useProps.defaultOpenKeys,
202
+ children = _useProps.children,
59
203
  others = _objectWithoutProperties(_useProps, _excluded);
60
204
  var _useTranslation = useTranslation(),
61
205
  t = _useTranslation.t;
@@ -96,20 +240,23 @@ export var Menu = observer(function (props) {
96
240
  _useState8 = _slicedToArray(_useState7, 2),
97
241
  defaultOpenKeys = _useState8[0],
98
242
  setDefaultOpenKeys = _useState8[1];
99
- var _useState9 = useState(function () {
100
- var key = (defaultSelectedKeys === null || defaultSelectedKeys === void 0 ? void 0 : defaultSelectedKeys[0]) || null;
101
- if (mode === 'mix' && key) {
102
- var _schema$properties;
103
- var s = (_schema$properties = schema.properties) === null || _schema$properties === void 0 ? void 0 : _schema$properties[key];
104
- if (s['x-component'] === 'Menu.SubMenu') {
105
- return s;
106
- }
243
+ var sideMenuSchema = useMemo(function () {
244
+ var key;
245
+ if (selectedUid) {
246
+ var keys = findKeysByUid(schema, selectedUid);
247
+ key = (keys === null || keys === void 0 ? void 0 : keys[0]) || null;
248
+ } else {
249
+ key = (defaultSelectedKeys === null || defaultSelectedKeys === void 0 ? void 0 : defaultSelectedKeys[0]) || null;
250
+ }
251
+ if (mode === 'mix' && key) {
252
+ var _schema$properties;
253
+ var s = (_schema$properties = schema.properties) === null || _schema$properties === void 0 ? void 0 : _schema$properties[key];
254
+ if (s['x-component'] === 'Menu.SubMenu') {
255
+ return s;
107
256
  }
108
- return null;
109
- }),
110
- _useState10 = _slicedToArray(_useState9, 2),
111
- sideMenuSchema = _useState10[0],
112
- setSideMenuSchema = _useState10[1];
257
+ }
258
+ return null;
259
+ }, [defaultSelectedKeys, mode, schema, selectedUid]);
113
260
  useEffect(function () {
114
261
  if (!selectedUid) {
115
262
  setSelectedKeys(undefined);
@@ -120,18 +267,6 @@ export var Menu = observer(function (props) {
120
267
  if (['inline', 'mix'].includes(mode)) {
121
268
  setDefaultOpenKeys(dOpenKeys || keys);
122
269
  }
123
- var key = (keys === null || keys === void 0 ? void 0 : keys[0]) || null;
124
- if (mode === 'mix') {
125
- if (key) {
126
- var _schema$properties2;
127
- var s = (_schema$properties2 = schema.properties) === null || _schema$properties2 === void 0 ? void 0 : _schema$properties2[key];
128
- if (s['x-component'] === 'Menu.SubMenu') {
129
- setSideMenuSchema(s);
130
- }
131
- } else {
132
- setSideMenuSchema(null);
133
- }
134
- }
135
270
  }, [selectedUid]);
136
271
  useEffect(function () {
137
272
  if (['inline', 'mix'].includes(mode)) {
@@ -144,156 +279,171 @@ export var Menu = observer(function (props) {
144
279
  value: Designer
145
280
  }, /*#__PURE__*/React.createElement(MenuModeContext.Provider, {
146
281
  value: mode
147
- }, /*#__PURE__*/React.createElement(AntdMenu, _objectSpread(_objectSpread({}, others), {}, {
148
- className: antdMenuClass,
149
- onSelect: function onSelect(info) {
150
- var s = schema.properties[info.key];
151
- if (mode === 'mix') {
152
- setSideMenuSchema(s);
153
- if (s['x-component'] !== 'Menu.SubMenu') {
154
- _onSelect && _onSelect(info);
155
- } else {
156
- var menuItemSchema = findMenuItem(s);
157
- if (!menuItemSchema) {
158
- return;
159
- }
160
- // TODO
161
- setLoading(true);
162
- var keys = findKeysByUid(schema, menuItemSchema['x-uid']);
163
- setDefaultSelectedKeys(keys);
164
- setTimeout(function () {
165
- setLoading(false);
166
- }, 100);
167
- _onSelect && _onSelect({
168
- key: menuItemSchema.name,
169
- item: {
170
- props: {
171
- schema: menuItemSchema
172
- }
173
- }
174
- });
175
- }
176
- } else {
177
- _onSelect && _onSelect(info);
178
- }
179
- },
180
- mode: mode === 'mix' ? 'horizontal' : mode,
181
- defaultOpenKeys: defaultOpenKeys,
282
+ }, /*#__PURE__*/React.createElement(HeaderMenu, {
283
+ others: others,
284
+ schema: schema,
285
+ mode: mode,
286
+ onSelect: onSelect,
287
+ setLoading: setLoading,
288
+ setDefaultSelectedKeys: setDefaultSelectedKeys,
182
289
  defaultSelectedKeys: defaultSelectedKeys,
183
- selectedKeys: selectedKeys
184
- }), designable && /*#__PURE__*/React.createElement(AntdMenu.Item, {
185
- disabled: true,
186
- key: "x-designer-button",
187
- style: {
188
- padding: '0 8px',
189
- order: 9999
190
- }
191
- }, render({
192
- style: {
193
- background: 'none'
194
- }
195
- })), props.children), loading ? null : mode === 'mix' && (sideMenuSchema === null || sideMenuSchema === void 0 ? void 0 : sideMenuSchema['x-component']) === 'Menu.SubMenu' && (sideMenuRef === null || sideMenuRef === void 0 ? void 0 : (_sideMenuRef$current = sideMenuRef.current) === null || _sideMenuRef$current === void 0 ? void 0 : _sideMenuRef$current.firstChild) && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(MenuModeContext.Provider, {
196
- value: 'inline'
197
- }, /*#__PURE__*/React.createElement(AntdMenu, {
198
- mode: 'inline',
290
+ defaultOpenKeys: defaultOpenKeys,
291
+ selectedKeys: selectedKeys,
292
+ designable: designable,
293
+ render: render
294
+ }, children), /*#__PURE__*/React.createElement(SideMenu, {
295
+ loading: loading,
296
+ mode: mode,
297
+ sideMenuSchema: sideMenuSchema,
298
+ sideMenuRef: sideMenuRef,
199
299
  defaultOpenKeys: defaultOpenKeys,
200
300
  defaultSelectedKeys: defaultSelectedKeys,
201
- onSelect: function onSelect(info) {
202
- _onSelect && _onSelect(info);
203
- },
204
- className: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n height: 100%;\n overflow-y: auto;\n overflow-x: hidden;\n .ant-menu-item {\n > .ant-menu-title-content {\n margin-left: -24px;\n margin-right: -16px;\n padding: 0 16px 0 24px;\n > div {\n > .general-schema-designer {\n right: 6px !important;\n }\n }\n }\n }\n .ant-menu-submenu-title {\n .ant-menu-title-content {\n margin-left: -24px;\n margin-right: -34px;\n padding: 0 34px 0 24px;\n > div {\n > .general-schema-designer {\n right: 6px !important;\n }\n > span.anticon {\n margin-right: 10px;\n }\n }\n }\n }\n "])))
205
- }, /*#__PURE__*/React.createElement(RecursionField, {
206
- schema: sideMenuSchema,
207
- onlyRenderProperties: true
208
- }), render({
209
- style: {
210
- margin: 8
211
- },
212
- insert: function insert(s) {
213
- var dn = createDesignable({
214
- t: t,
215
- api: api,
216
- refresh: refresh,
217
- current: sideMenuSchema
218
- });
219
- dn.loadAPIClientEvents();
220
- dn.insertAdjacent('beforeEnd', s);
221
- }
222
- }))), sideMenuRef.current.firstChild))));
301
+ onSelect: onSelect,
302
+ render: render,
303
+ t: t,
304
+ api: api,
305
+ refresh: refresh,
306
+ designable: designable
307
+ }))));
223
308
  }, {
224
309
  displayName: 'Menu'
225
310
  });
226
311
  Menu.Item = observer(function (props) {
312
+ var _useCollectMenuItems = useCollectMenuItems(),
313
+ pushMenuItem = _useCollectMenuItems.pushMenuItem;
227
314
  var icon = props.icon,
315
+ children = props.children,
228
316
  others = _objectWithoutProperties(props, _excluded2);
229
317
  var schema = useFieldSchema();
230
318
  var field = useField();
231
319
  var Designer = useContext(MenuItemDesignerContext);
232
- return /*#__PURE__*/React.createElement(AntdMenu.Item, _objectSpread(_objectSpread({}, others), {}, {
233
- className: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n :active {\n background: inherit;\n }\n "]))),
234
- key: schema.name,
235
- eventKey: schema.name,
236
- schema: schema
237
- }), /*#__PURE__*/React.createElement(SortableItem, {
238
- className: designerCss,
239
- removeParentsIfNoChildren: false
240
- }, /*#__PURE__*/React.createElement(Icon, {
241
- type: icon
242
- }), /*#__PURE__*/React.createElement("span", {
243
- className: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n width: 100%;\n vertical-align: middle;\n "])))
244
- }, field.title), Designer && /*#__PURE__*/React.createElement(Designer, null)));
320
+ var item = useMemo(function () {
321
+ return _objectSpread(_objectSpread({}, others), {}, {
322
+ className: menuItemClass,
323
+ key: schema.name,
324
+ eventKey: schema.name,
325
+ schema: schema,
326
+ label: /*#__PURE__*/React.createElement(SchemaContext.Provider, {
327
+ value: schema
328
+ }, /*#__PURE__*/React.createElement(FieldContext.Provider, {
329
+ value: field
330
+ }, /*#__PURE__*/React.createElement(SortableItem, {
331
+ className: designerCss,
332
+ removeParentsIfNoChildren: false
333
+ }, /*#__PURE__*/React.createElement(Icon, {
334
+ type: icon
335
+ }), /*#__PURE__*/React.createElement("span", {
336
+ style: {
337
+ overflow: 'hidden',
338
+ textOverflow: 'ellipsis',
339
+ display: 'inline-block',
340
+ width: '100%',
341
+ verticalAlign: 'middle'
342
+ }
343
+ }, field.title), /*#__PURE__*/React.createElement(Designer, null))))
344
+ });
345
+ }, [field.title, icon, schema, Designer]);
346
+ if (!pushMenuItem) {
347
+ error('Menu.Item must be wrapped by GetMenuItemsContext.Provider');
348
+ return null;
349
+ }
350
+ pushMenuItem(item);
351
+ return null;
245
352
  }, {
246
353
  displayName: 'Menu.Item'
247
354
  });
248
355
  Menu.URL = observer(function (props) {
356
+ var _useCollectMenuItems2 = useCollectMenuItems(),
357
+ pushMenuItem = _useCollectMenuItems2.pushMenuItem;
249
358
  var icon = props.icon,
359
+ children = props.children,
250
360
  others = _objectWithoutProperties(props, _excluded3);
251
361
  var schema = useFieldSchema();
252
362
  var field = useField();
253
363
  var Designer = useContext(MenuItemDesignerContext);
254
- return /*#__PURE__*/React.createElement(AntdMenu.Item, _objectSpread(_objectSpread({}, others), {}, {
255
- className: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n :active {\n background: inherit;\n }\n "]))),
256
- key: schema.name,
257
- eventKey: schema.name,
258
- schema: schema,
259
- onClick: function onClick() {
260
- window.open(props.href, '_blank');
261
- }
262
- }), /*#__PURE__*/React.createElement(SortableItem, {
263
- className: designerCss,
264
- removeParentsIfNoChildren: false
265
- }, /*#__PURE__*/React.createElement(Icon, {
266
- type: icon
267
- }), /*#__PURE__*/React.createElement("span", {
268
- className: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n overflow: hidden;\n text-overflow: ellipsis;\n display: inline-block;\n width: 100%;\n vertical-align: middle;\n "])))
269
- }, field.title), Designer && /*#__PURE__*/React.createElement(Designer, null)));
364
+ if (!pushMenuItem) {
365
+ error('Menu.URL must be wrapped by GetMenuItemsContext.Provider');
366
+ return null;
367
+ }
368
+ var item = useMemo(function () {
369
+ return _objectSpread(_objectSpread({}, others), {}, {
370
+ className: menuItemClass,
371
+ key: schema.name,
372
+ eventKey: schema.name,
373
+ schema: schema,
374
+ onClick: function onClick() {
375
+ window.open(props.href, '_blank');
376
+ },
377
+ label: /*#__PURE__*/React.createElement(SchemaContext.Provider, {
378
+ value: schema
379
+ }, /*#__PURE__*/React.createElement(FieldContext.Provider, {
380
+ value: field
381
+ }, /*#__PURE__*/React.createElement(SortableItem, {
382
+ className: designerCss,
383
+ removeParentsIfNoChildren: false
384
+ }, /*#__PURE__*/React.createElement(Icon, {
385
+ type: icon
386
+ }), /*#__PURE__*/React.createElement("span", {
387
+ style: {
388
+ overflow: 'hidden',
389
+ textOverflow: 'ellipsis',
390
+ display: 'inline-block',
391
+ width: '100%',
392
+ verticalAlign: 'middle'
393
+ }
394
+ }, field.title), /*#__PURE__*/React.createElement(Designer, null))))
395
+ });
396
+ }, [field.title, icon, props.href, schema, Designer]);
397
+ pushMenuItem(item);
398
+ return null;
270
399
  }, {
271
400
  displayName: 'MenuURL'
272
401
  });
273
402
  Menu.SubMenu = observer(function (props) {
403
+ var _useMenuItem3 = useMenuItem(),
404
+ Component = _useMenuItem3.Component,
405
+ getMenuItems = _useMenuItem3.getMenuItems;
406
+ var _useCollectMenuItems3 = useCollectMenuItems(),
407
+ pushMenuItem = _useCollectMenuItems3.pushMenuItem;
274
408
  var icon = props.icon,
409
+ children = props.children,
275
410
  others = _objectWithoutProperties(props, _excluded4);
276
411
  var schema = useFieldSchema();
277
412
  var field = useField();
278
413
  var mode = useContext(MenuModeContext);
279
414
  var Designer = useContext(MenuItemDesignerContext);
415
+ var submenu = useMemo(function () {
416
+ return _objectSpread(_objectSpread({}, others), {}, {
417
+ className: menuItemClass,
418
+ key: schema.name,
419
+ eventKey: schema.name,
420
+ label: /*#__PURE__*/React.createElement(SchemaContext.Provider, {
421
+ value: schema
422
+ }, /*#__PURE__*/React.createElement(FieldContext.Provider, {
423
+ value: field
424
+ }, /*#__PURE__*/React.createElement(SortableItem, {
425
+ className: subMenuDesignerCss,
426
+ removeParentsIfNoChildren: false
427
+ }, /*#__PURE__*/React.createElement(Icon, {
428
+ type: icon
429
+ }), field.title, /*#__PURE__*/React.createElement(Designer, null)))),
430
+ children: getMenuItems(function () {
431
+ return /*#__PURE__*/React.createElement(RecursionField, {
432
+ schema: schema,
433
+ onlyRenderProperties: true
434
+ });
435
+ })
436
+ });
437
+ }, [field.title, icon, schema, children, Designer]);
438
+ if (!pushMenuItem) {
439
+ error('Menu.SubMenu must be wrapped by GetMenuItemsContext.Provider');
440
+ return null;
441
+ }
280
442
  if (mode === 'mix') {
281
443
  return /*#__PURE__*/React.createElement(Menu.Item, _objectSpread({}, props));
282
444
  }
283
- return /*#__PURE__*/React.createElement(AntdMenu.SubMenu, _objectSpread(_objectSpread({}, others), {}, {
284
- className: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n :active {\n background: inherit;\n }\n "]))),
285
- key: schema.name,
286
- eventKey: schema.name,
287
- title: /*#__PURE__*/React.createElement(SortableItem, {
288
- className: subMenuDesignerCss,
289
- removeParentsIfNoChildren: false
290
- }, /*#__PURE__*/React.createElement(Icon, {
291
- type: icon
292
- }), field.title, Designer && /*#__PURE__*/React.createElement(Designer, null))
293
- }), /*#__PURE__*/React.createElement(RecursionField, {
294
- schema: schema,
295
- onlyRenderProperties: true
296
- }));
445
+ pushMenuItem(submenu);
446
+ return /*#__PURE__*/React.createElement(Component, null);
297
447
  }, {
298
448
  displayName: 'Menu.SubMenu'
299
449
  });