@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
@@ -20,6 +20,7 @@ var _reactI18next = require("react-i18next");
20
20
  var _2 = require("..");
21
21
  var _hooks = require("../block-provider/hooks");
22
22
  var _utils = require("../filter-provider/utils");
23
+ var _useMenuItem4 = require("../hooks/useMenuItem");
23
24
  var _utilts = require("../schema-component/antd/association-filter/utilts");
24
25
  var _schemaTemplates = require("../schema-templates");
25
26
  var _BlockTemplate = require("../schema-templates/BlockTemplate");
@@ -27,7 +28,6 @@ var _DataTemplates = require("./DataTemplates");
27
28
  var _EnableChildCollections = require("./EnableChildCollections");
28
29
  var _LinkageRules = require("./LinkageRules");
29
30
  var _actionHooks = require("./LinkageRules/action-hooks");
30
- var _templateObject;
31
31
  var _excluded = ["children", "fieldSchema"],
32
32
  _excluded2 = ["title", "dn"],
33
33
  _excluded3 = ["title", "options", "value", "onChange", "openOnHover", "onClick"],
@@ -36,6 +36,7 @@ var _excluded = ["children", "fieldSchema"],
36
36
  _excluded6 = ["schema"],
37
37
  _excluded7 = ["title", "onSubmit", "initialValues", "initialSchema", "schema", "modalTip", "components"],
38
38
  _excluded8 = ["hidden", "title", "components", "scope", "effects", "schema", "onSubmit", "asyncGetInitialValues", "initialValues", "width"];
39
+ var _templateObject, _templateObject2;
39
40
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
40
41
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
41
42
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -47,7 +48,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
47
48
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
48
49
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
49
50
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
50
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
51
51
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
52
52
  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."); }
53
53
  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); }
@@ -61,7 +61,12 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
61
61
  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); }
62
62
  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; }
63
63
  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; }
64
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
64
65
  var SchemaSettingsContext = /*#__PURE__*/(0, _react2.createContext)(null);
66
+ /**
67
+ * 用于去除菜单的消失动画,优化操作体验
68
+ */
69
+ var hidden = (0, _css.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: none;\n"])));
65
70
  var useSchemaSettings = function useSchemaSettings() {
66
71
  return (0, _react2.useContext)(SchemaSettingsContext);
67
72
  };
@@ -84,6 +89,7 @@ var SchemaSettingsProvider = function SchemaSettingsProvider(props) {
84
89
  }, children);
85
90
  };
86
91
  exports.SchemaSettingsProvider = SchemaSettingsProvider;
92
+ var overlayClassName = (0, _classnames.default)('nb-schema-initializer-button-overlay', (0, _css.css)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .ant-dropdown-menu-item-group-list {\n max-height: 40vh;\n overflow: auto;\n }\n "]))));
87
93
  var SchemaSettings = function SchemaSettings(props) {
88
94
  var title = props.title,
89
95
  dn = props.dn,
@@ -92,22 +98,42 @@ var SchemaSettings = function SchemaSettings(props) {
92
98
  _useState2 = _slicedToArray(_useState, 2),
93
99
  visible = _useState2[0],
94
100
  setVisible = _useState2[1];
95
- var DropdownMenu = /*#__PURE__*/_react2.default.createElement(_antd2.Dropdown, {
96
- open: visible,
97
- onOpenChange: function onOpenChange(visible) {
98
- setVisible(visible);
99
- },
100
- overlay: /*#__PURE__*/_react2.default.createElement(_antd2.Menu, null, props.children),
101
- overlayClassName: (0, _classnames.default)('nb-schema-initializer-button-overlay', (0, _css.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ant-dropdown-menu-item-group-list {\n max-height: 40vh;\n overflow: auto;\n }\n "]))))
102
- }, typeof title === 'string' ? /*#__PURE__*/_react2.default.createElement("span", null, title) : title);
101
+ var _useMenuItem = (0, _useMenuItem4.useMenuItem)(),
102
+ Component = _useMenuItem.Component,
103
+ getMenuItems = _useMenuItem.getMenuItems;
104
+ var _useReactTransition = (0, _react2.useTransition)(),
105
+ _useReactTransition2 = _slicedToArray(_useReactTransition, 2),
106
+ isPending = _useReactTransition2[0],
107
+ startTransition = _useReactTransition2[1];
108
+ var changeMenu = function changeMenu(v) {
109
+ startTransition(function () {
110
+ setVisible(v);
111
+ });
112
+ };
113
+ var items = getMenuItems(function () {
114
+ return props.children;
115
+ });
116
+ var dropdownMenu = function dropdownMenu() {
117
+ return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement(Component, null), /*#__PURE__*/_react2.default.createElement(_antd2.Dropdown, {
118
+ open: visible,
119
+ onOpenChange: function onOpenChange() {
120
+ changeMenu(!visible);
121
+ },
122
+ menu: {
123
+ items: items,
124
+ className: (0, _classnames.default)(_defineProperty({}, hidden, !visible))
125
+ },
126
+ overlayClassName: overlayClassName
127
+ }, typeof title === 'string' ? /*#__PURE__*/_react2.default.createElement("span", null, title) : title));
128
+ };
103
129
  if (dn) {
104
130
  return /*#__PURE__*/_react2.default.createElement(SchemaSettingsProvider, _objectSpread({
105
131
  visible: visible,
106
132
  setVisible: setVisible,
107
133
  dn: dn
108
- }, others), DropdownMenu);
134
+ }, others), dropdownMenu());
109
135
  }
110
- return DropdownMenu;
136
+ return dropdownMenu();
111
137
  };
112
138
  exports.SchemaSettings = SchemaSettings;
113
139
  SchemaSettings.Template = function Template(props) {
@@ -461,14 +487,17 @@ SchemaSettings.FormItemTemplate = function FormItemTemplate(props) {
461
487
  }, t('Save as block template'));
462
488
  };
463
489
  SchemaSettings.Item = function Item(props) {
490
+ var _useCollectMenuItems = (0, _useMenuItem4.useCollectMenuItems)(),
491
+ pushMenuItem = _useCollectMenuItems.pushMenuItem;
492
+ var _useCollectMenuItem = (0, _useMenuItem4.useCollectMenuItem)(),
493
+ collectMenuItem = _useCollectMenuItem.collectMenuItem;
464
494
  var eventKey = props.eventKey;
465
495
  var key = (0, _react2.useMemo)(function () {
466
496
  return (0, _shared.uid)();
467
497
  }, []);
468
- return /*#__PURE__*/_react2.default.createElement(_antd2.Menu.Item, _objectSpread(_objectSpread({
498
+ var item = _objectSpread(_objectSpread({}, _lodash.default.omit(props, ['children'])), {}, {
469
499
  key: key,
470
- eventKey: eventKey || key
471
- }, props), {}, {
500
+ eventKey: eventKey || key,
472
501
  onClick: function onClick(info) {
473
502
  var _props$onClick;
474
503
  info.domEvent.preventDefault();
@@ -477,17 +506,67 @@ SchemaSettings.Item = function Item(props) {
477
506
  },
478
507
  style: {
479
508
  minWidth: 120
480
- }
481
- }), props.children || props.title);
509
+ },
510
+ label: props.children || props.title,
511
+ title: props.title
512
+ });
513
+ pushMenuItem === null || pushMenuItem === void 0 ? void 0 : pushMenuItem(item);
514
+ collectMenuItem === null || collectMenuItem === void 0 ? void 0 : collectMenuItem(item);
515
+ return null;
482
516
  };
483
- SchemaSettings.ItemGroup = function (props) {
484
- return /*#__PURE__*/_react2.default.createElement(_antd2.Menu.ItemGroup, _objectSpread({}, props));
517
+ SchemaSettings.ItemGroup = function ItemGroup(props) {
518
+ var _useMenuItem2 = (0, _useMenuItem4.useMenuItem)(),
519
+ Component = _useMenuItem2.Component,
520
+ getMenuItems = _useMenuItem2.getMenuItems;
521
+ var _useCollectMenuItems2 = (0, _useMenuItem4.useCollectMenuItems)(),
522
+ pushMenuItem = _useCollectMenuItems2.pushMenuItem;
523
+ var key = (0, _react2.useMemo)(function () {
524
+ return (0, _shared.uid)();
525
+ }, []);
526
+ var item = {
527
+ key: key,
528
+ type: 'group',
529
+ title: props.title,
530
+ label: props.title,
531
+ children: getMenuItems(function () {
532
+ return props.children;
533
+ })
534
+ };
535
+ pushMenuItem(item);
536
+ return /*#__PURE__*/_react2.default.createElement(Component, null);
485
537
  };
486
- SchemaSettings.SubMenu = function (props) {
487
- return /*#__PURE__*/_react2.default.createElement(_antd2.Menu.SubMenu, _objectSpread({}, props));
538
+ SchemaSettings.SubMenu = function SubMenu(props) {
539
+ var _useMenuItem3 = (0, _useMenuItem4.useMenuItem)(),
540
+ Component = _useMenuItem3.Component,
541
+ getMenuItems = _useMenuItem3.getMenuItems;
542
+ var _useCollectMenuItems3 = (0, _useMenuItem4.useCollectMenuItems)(),
543
+ pushMenuItem = _useCollectMenuItems3.pushMenuItem;
544
+ var key = (0, _react2.useMemo)(function () {
545
+ return (0, _shared.uid)();
546
+ }, []);
547
+ var item = {
548
+ key: key,
549
+ label: props.title,
550
+ title: props.title,
551
+ children: getMenuItems(function () {
552
+ return props.children;
553
+ })
554
+ };
555
+ pushMenuItem(item);
556
+ return /*#__PURE__*/_react2.default.createElement(Component, null);
488
557
  };
489
- SchemaSettings.Divider = function (props) {
490
- return /*#__PURE__*/_react2.default.createElement(_antd2.Menu.Divider, _objectSpread({}, props));
558
+ SchemaSettings.Divider = function Divider() {
559
+ var _useCollectMenuItems4 = (0, _useMenuItem4.useCollectMenuItems)(),
560
+ pushMenuItem = _useCollectMenuItems4.pushMenuItem;
561
+ var key = (0, _react2.useMemo)(function () {
562
+ return (0, _shared.uid)();
563
+ }, []);
564
+ var item = {
565
+ key: key,
566
+ type: 'divider'
567
+ };
568
+ pushMenuItem(item);
569
+ return null;
491
570
  };
492
571
  SchemaSettings.Remove = function Remove(props) {
493
572
  var confirm = props.confirm,
@@ -541,6 +620,7 @@ SchemaSettings.ConnectDataBlocks = function ConnectDataBlocks(props) {
541
620
  var _useFilterBlock = (0, _2.useFilterBlock)(),
542
621
  inProvider = _useFilterBlock.inProvider;
543
622
  var dataBlocks = (0, _utils.useSupportedBlocks)(type);
623
+ // eslint-disable-next-line prefer-const
544
624
  var _findFilterTargets = (0, _hooks.findFilterTargets)(fieldSchema),
545
625
  _findFilterTargets$ta = _findFilterTargets.targets,
546
626
  targets = _findFilterTargets$ta === void 0 ? [] : _findFilterTargets$ta,
@@ -650,14 +730,14 @@ SchemaSettings.ConnectDataBlocks = function ConnectDataBlocks(props) {
650
730
  });
651
731
  return /*#__PURE__*/_react2.default.createElement(SchemaSettings.SubMenu, {
652
732
  title: t('Connect data blocks')
653
- }, Content.length ? Content : /*#__PURE__*/_react2.default.createElement(_antd2.Empty, {
733
+ }, Content.length ? Content : /*#__PURE__*/_react2.default.createElement(SchemaSettings.Item, null, /*#__PURE__*/_react2.default.createElement(_antd2.Empty, {
654
734
  style: {
655
735
  width: 160,
656
736
  padding: '0 1em'
657
737
  },
658
738
  description: emptyDescription,
659
739
  image: _antd2.Empty.PRESENTED_IMAGE_SIMPLE
660
- }));
740
+ })));
661
741
  };
662
742
  SchemaSettings.SelectItem = function SelectItem(props) {
663
743
  var title = props.title,
@@ -885,7 +965,7 @@ SchemaSettings.ActionModalItem = /*#__PURE__*/_react2.default.memo(function (pro
885
965
  title: compile(title)
886
966
  }, others), {}, {
887
967
  destroyOnClose: true,
888
- visible: visible,
968
+ open: visible,
889
969
  onCancel: cancelHandler,
890
970
  footer: /*#__PURE__*/_react2.default.createElement(_antd2.Space, null, /*#__PURE__*/_react2.default.createElement(_antd2.Button, {
891
971
  onClick: cancelHandler
@@ -1265,7 +1345,6 @@ SchemaSettings.EnableChildCollections = function EnableChildCollectionsItem(prop
1265
1345
  ArrayItems: _antd.ArrayItems,
1266
1346
  FormLayout: _antd.FormLayout
1267
1347
  },
1268
- width: 600,
1269
1348
  schema: {
1270
1349
  type: 'object',
1271
1350
  title: t('Enable child collections'),
@@ -0,0 +1,19 @@
1
+ import { Schema } from '@formily/react';
2
+ export declare const useFormVariable: ({ blockForm, rootCollection, operator, schema, level, }: {
3
+ blockForm?: any;
4
+ rootCollection: string;
5
+ operator?: any;
6
+ schema: Schema;
7
+ level?: number;
8
+ }) => {
9
+ label: string;
10
+ value: string;
11
+ key: string;
12
+ children: any[];
13
+ isLeaf: boolean;
14
+ field: {
15
+ target: string;
16
+ };
17
+ depth: number;
18
+ loadChildren: (option: any) => Promise<void>;
19
+ };
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useFormVariable = void 0;
7
+ var _react = require("react");
8
+ var _schemaComponent = require("../../../schema-component");
9
+ var getChildren = function getChildren(options, _ref) {
10
+ var depth = _ref.depth,
11
+ maxDepth = _ref.maxDepth,
12
+ loadChildren = _ref.loadChildren,
13
+ compile = _ref.compile;
14
+ var result = options.map(function (option) {
15
+ if (!option.target) {
16
+ return {
17
+ key: option.name,
18
+ value: option.name,
19
+ label: compile(option.title),
20
+ depth: depth
21
+ };
22
+ }
23
+ if (depth >= maxDepth) {
24
+ return null;
25
+ }
26
+ return {
27
+ key: option.name,
28
+ value: option.name,
29
+ label: compile(option.title),
30
+ children: [],
31
+ isLeaf: false,
32
+ field: option,
33
+ depth: depth,
34
+ loadChildren: loadChildren
35
+ };
36
+ }).filter(Boolean);
37
+ return result;
38
+ };
39
+ var useFormVariable = function useFormVariable(_ref2) {
40
+ var blockForm = _ref2.blockForm,
41
+ rootCollection = _ref2.rootCollection,
42
+ operator = _ref2.operator,
43
+ schema = _ref2.schema,
44
+ level = _ref2.level;
45
+ var compile = (0, _schemaComponent.useCompile)();
46
+ var getFilterOptions = (0, _schemaComponent.useGetFilterOptions)();
47
+ var loadChildren = function loadChildren(option) {
48
+ var _option$field;
49
+ if (!((_option$field = option.field) === null || _option$field === void 0 ? void 0 : _option$field.target)) {
50
+ return new Promise(function (resolve) {
51
+ resolve(void 0);
52
+ });
53
+ }
54
+ var collectionName = option.field.target;
55
+ var fields = getFilterOptions(collectionName);
56
+ var allowFields = option.depth === 0 ? fields.filter(function (field) {
57
+ return Object.keys(blockForm.fields).some(function (name) {
58
+ return name.includes(".".concat(field.name));
59
+ });
60
+ }) : fields;
61
+ return new Promise(function (resolve) {
62
+ setTimeout(function () {
63
+ var children = getChildren(allowFields, {
64
+ depth: option.depth + 1,
65
+ maxDepth: 4,
66
+ loadChildren: loadChildren,
67
+ compile: compile
68
+ }) || [];
69
+ if (children.length === 0) {
70
+ option.disabled = true;
71
+ resolve();
72
+ return;
73
+ }
74
+ option.children = children;
75
+ resolve();
76
+ // 延迟 5 毫秒,防止阻塞主线程,导致 UI 卡顿
77
+ }, 5);
78
+ });
79
+ };
80
+ var result = (0, _react.useMemo)(function () {
81
+ return blockForm && {
82
+ label: "{{t(\"Current form\")}}",
83
+ value: '$form',
84
+ key: '$form',
85
+ children: [],
86
+ isLeaf: false,
87
+ field: {
88
+ target: rootCollection
89
+ },
90
+ depth: 0,
91
+ loadChildren: loadChildren
92
+ };
93
+ }, [rootCollection]);
94
+ return result;
95
+ };
96
+ exports.useFormVariable = useFormVariable;
@@ -0,0 +1,8 @@
1
+ export declare const useIterationVariable: ({ blockForm, collectionField, operator, schema, level, rootCollection, }: {
2
+ blockForm?: any;
3
+ collectionField: any;
4
+ operator?: any;
5
+ schema: any;
6
+ level?: number;
7
+ rootCollection?: string;
8
+ }) => any;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIterationVariable = void 0;
7
+ var _react = require("react");
8
+ var _schemaComponent = require("../../../schema-component");
9
+ var getChildren = function getChildren(options, _ref) {
10
+ var schema = _ref.schema,
11
+ operator = _ref.operator,
12
+ maxDepth = _ref.maxDepth,
13
+ _ref$count = _ref.count,
14
+ count = _ref$count === void 0 ? 1 : _ref$count,
15
+ getFilterOptions = _ref.getFilterOptions;
16
+ if (count > maxDepth) {
17
+ return [];
18
+ }
19
+ var result = options.map(function (option) {
20
+ if (option.type !== 'belongsTo' && option.type !== 'hasOne' || !option.target) {
21
+ return {
22
+ key: option.name,
23
+ value: option.name,
24
+ label: option.title,
25
+ // TODO: 现在是通过组件的名称来过滤能够被选择的选项,这样的坏处是不够精确,后续可以优化
26
+ // disabled: schema?.['x-component'] !== option.schema?.['x-component'],
27
+ disabled: false
28
+ };
29
+ }
30
+ var children = getChildren(getFilterOptions(option.target), {
31
+ schema: schema,
32
+ operator: operator,
33
+ maxDepth: maxDepth,
34
+ count: count + 1,
35
+ getFilterOptions: getFilterOptions
36
+ }) || [];
37
+ return {
38
+ key: option.name,
39
+ value: option.name,
40
+ label: option.title,
41
+ children: children,
42
+ disabled: children.every(function (child) {
43
+ return child.disabled;
44
+ })
45
+ };
46
+ });
47
+ return result;
48
+ };
49
+ var useIterationVariable = function useIterationVariable(_ref2) {
50
+ var blockForm = _ref2.blockForm,
51
+ collectionField = _ref2.collectionField,
52
+ operator = _ref2.operator,
53
+ schema = _ref2.schema,
54
+ level = _ref2.level,
55
+ rootCollection = _ref2.rootCollection;
56
+ var compile = (0, _schemaComponent.useCompile)();
57
+ var getFilterOptions = (0, _schemaComponent.useGetFilterOptions)();
58
+ var fields = getFilterOptions(collectionField === null || collectionField === void 0 ? void 0 : collectionField.collectionName);
59
+ var children = (0, _react.useMemo)(function () {
60
+ var allowFields = fields.filter(function (field) {
61
+ return Object.keys(blockForm.fields).some(function (name) {
62
+ return name.includes(field.name);
63
+ });
64
+ });
65
+ return getChildren(allowFields, {
66
+ schema: schema,
67
+ operator: operator,
68
+ maxDepth: level || 3,
69
+ getFilterOptions: getFilterOptions
70
+ }) || [];
71
+ }, [operator, schema, blockForm]);
72
+ return (0, _react.useMemo)(function () {
73
+ return rootCollection !== (collectionField === null || collectionField === void 0 ? void 0 : collectionField.collectionName) && children.length > 0 ? compile({
74
+ label: "{{t(\"Current object\")}}",
75
+ value: '$iteration',
76
+ key: '$iteration',
77
+ disabled: children.every(function (option) {
78
+ return option.disabled;
79
+ }),
80
+ children: children
81
+ }) : null;
82
+ }, [children]);
83
+ };
84
+ exports.useIterationVariable = useIterationVariable;
@@ -1,12 +1,5 @@
1
- export declare const useVariableOptions: () => ({
2
- label: string;
3
- value: string;
4
- key: string;
5
- disabled: boolean;
6
- children: {
7
- key: string;
8
- value: string;
9
- label: string;
10
- disabled: boolean;
11
- }[];
12
- } | import("../type").Option)[];
1
+ export declare const useVariableOptions: ({ form, collectionField, rootCollection }: {
2
+ form: any;
3
+ collectionField: any;
4
+ rootCollection: any;
5
+ }) => any[];
@@ -8,7 +8,12 @@ var _react = require("react");
8
8
  var _useValues2 = require("../../../schema-component/antd/filter/useValues");
9
9
  var _useDateVariable = require("./useDateVariable");
10
10
  var _useUserVariable = require("./useUserVariable");
11
- var useVariableOptions = function useVariableOptions() {
11
+ var _useFormVariable = require("./useFormVariable");
12
+ var _useIterationVariable = require("./useIterationVariable");
13
+ var useVariableOptions = function useVariableOptions(_ref) {
14
+ var form = _ref.form,
15
+ collectionField = _ref.collectionField,
16
+ rootCollection = _ref.rootCollection;
12
17
  var _useValues = (0, _useValues2.useValues)(),
13
18
  operator = _useValues.operator,
14
19
  schema = _useValues.schema;
@@ -20,9 +25,20 @@ var useVariableOptions = function useVariableOptions() {
20
25
  operator: operator,
21
26
  schema: schema
22
27
  });
28
+ var formVariabele = (0, _useFormVariable.useFormVariable)({
29
+ blockForm: form,
30
+ rootCollection: rootCollection,
31
+ schema: schema
32
+ });
33
+ var iterationVariabele = (0, _useIterationVariable.useIterationVariable)({
34
+ blockForm: form,
35
+ collectionField: collectionField,
36
+ schema: schema,
37
+ rootCollection: rootCollection
38
+ });
23
39
  var result = (0, _react.useMemo)(function () {
24
- return [userVariable, dateVariable];
25
- }, [dateVariable, userVariable]);
40
+ return [userVariable, dateVariable, formVariabele, iterationVariabele].filter(Boolean);
41
+ }, [dateVariable, userVariable, formVariabele, iterationVariabele]);
26
42
  if (!operator || !schema) return [];
27
43
  return result;
28
44
  };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.BlockTemplateDetails = void 0;
8
+ var _proLayout = require("@ant-design/pro-layout");
8
9
  var _antd = require("antd");
9
10
  var _react = _interopRequireWildcard(require("react"));
10
11
  var _reactRouterDom = require("react-router-dom");
@@ -92,7 +93,10 @@ var BlockTemplateDetails = function BlockTemplateDetails() {
92
93
  if (loading) {
93
94
  return /*#__PURE__*/_react.default.createElement(_antd.Spin, null);
94
95
  }
95
- return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_antd.PageHeader, {
96
+ return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_proLayout.PageHeader, {
97
+ style: {
98
+ backgroundColor: 'white'
99
+ },
96
100
  onBack: function onBack() {
97
101
  navigate('/admin/plugins/block-templates');
98
102
  },
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.BlockTemplatesPane = exports.BlockTemplatePage = void 0;
7
- var _antd = require("antd");
7
+ var _proLayout = require("@ant-design/pro-layout");
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactI18next = require("react-i18next");
10
10
  var _collectionManager = require("../collection-manager");
@@ -15,7 +15,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
15
15
  var BlockTemplatePage = function BlockTemplatePage() {
16
16
  var _useTranslation = (0, _reactI18next.useTranslation)(),
17
17
  t = _useTranslation.t;
18
- return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_antd.PageHeader, {
18
+ return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_proLayout.PageHeader, {
19
+ style: {
20
+ backgroundColor: 'white'
21
+ },
19
22
  ghost: false,
20
23
  title: t('Block templates')
21
24
  }), /*#__PURE__*/_react.default.createElement("div", {
@@ -1,2 +1 @@
1
- import React from 'react';
2
- export declare const ChangePassword: () => React.JSX.Element;
1
+ export declare const useChangePassword: () => import("antd/lib/menu/hooks/useItems").ItemType;