@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,6 +1,6 @@
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
2
  var _excluded = ["children"];
3
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
3
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
4
4
  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; }
5
5
  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); } }
6
6
  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); }); }; }
@@ -19,10 +19,11 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
19
19
  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; }
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 { PlusOutlined } from '@ant-design/icons';
22
+ import { PageHeader as AntdPageHeader } from '@ant-design/pro-layout';
22
23
  import { css } from '@emotion/css';
23
24
  import { FormDialog, FormLayout } from '@formily/antd';
24
25
  import { Schema, SchemaOptionsContext, useFieldSchema } from '@formily/react';
25
- import { Button, PageHeader as AntdPageHeader, Spin, Tabs } from 'antd';
26
+ import { Button, Spin, Tabs } from 'antd';
26
27
  import classNames from 'classnames';
27
28
  import React, { useContext, useEffect, useMemo, useState } from 'react';
28
29
  import { ErrorBoundary } from 'react-error-boundary';
@@ -41,6 +42,8 @@ import { PageDesigner, PageTabDesigner } from './PageTabDesigner';
41
42
  var designerCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n &:hover {\n > .general-schema-designer {\n display: block;\n }\n }\n &.nb-action-link {\n > .general-schema-designer {\n top: var(--nb-designer-offset);\n bottom: var(--nb-designer-offset);\n right: var(--nb-designer-offset);\n left: var(--nb-designer-offset);\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"])));
42
43
  var pageDesignerCss = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n z-index: 20;\n flex: 1;\n display: flex;\n flex-direction: column;\n\n &:hover {\n > .general-schema-designer {\n display: block;\n }\n }\n .ant-page-header {\n z-index: 1;\n position: relative;\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 z-index: 9999;\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"])));
43
44
  var pageWithFixedBlockCss = classNames(['nb-page-content', css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n height: 100%;\n > .nb-grid:not(:last-child) {\n > .nb-schema-initializer-button {\n display: none;\n }\n }\n "])))]);
45
+ var pageHeaderCss = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-color: white;\n &.ant-page-header-has-footer {\n padding-top: 12px;\n padding-bottom: 0;\n .ant-page-header-heading-left {\n /* margin: 0; */\n }\n .ant-page-header-footer {\n margin-top: 0;\n }\n }\n"])));
46
+ var height0 = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 0;\n height: 0;\n"])));
44
47
  export var Page = function Page(props) {
45
48
  var _fieldSchema$xCompon, _fieldSchema$xCompon2, _fieldSchema$xCompon3;
46
49
  var children = props.children,
@@ -90,6 +93,7 @@ export var Page = function Page(props) {
90
93
  var handleErrors = function handleErrors(error) {
91
94
  console.error(error);
92
95
  };
96
+ var pageHeaderTitle = hidePageTitle ? undefined : fieldSchema.title || compile(title);
93
97
  return /*#__PURE__*/React.createElement(FilterBlockProvider, null, /*#__PURE__*/React.createElement("div", {
94
98
  className: pageDesignerCss
95
99
  }, /*#__PURE__*/React.createElement(PageDesigner, {
@@ -99,9 +103,10 @@ export var Page = function Page(props) {
99
103
  setHeight(Math.floor((_ref === null || _ref === void 0 ? void 0 : _ref.getBoundingClientRect().height) || 0) + 1);
100
104
  }
101
105
  }, !disablePageHeader && /*#__PURE__*/React.createElement(AntdPageHeader, _objectSpread(_objectSpread({
102
- className: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n &.has-footer {\n padding-top: 12px;\n .ant-page-header-heading-left {\n /* margin: 0; */\n }\n .ant-page-header-footer {\n margin-top: 0;\n }\n }\n "]))),
106
+ className: classNames(pageHeaderCss, pageHeaderTitle || enablePageTabs ? '' : height0),
103
107
  ghost: false,
104
- title: hidePageTitle ? undefined : fieldSchema.title || compile(title)
108
+ // 如果标题为空的时候会导致 PageHeader 不渲染,所以这里设置一个空白字符,然后再设置高度为 0
109
+ title: pageHeaderTitle || ' '
105
110
  }, others), {}, {
106
111
  footer: enablePageTabs && /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement(Tabs, {
107
112
  size: 'small',
@@ -116,7 +121,7 @@ export var Page = function Page(props) {
116
121
  },
117
122
  tabBarExtraContent: dn.designable && /*#__PURE__*/React.createElement(Button, {
118
123
  icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
119
- className: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border-color: rgb(241, 139, 98) !important;\n color: rgb(241, 139, 98) !important;\n "]))),
124
+ className: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n border-color: rgb(241, 139, 98) !important;\n color: rgb(241, 139, 98) !important;\n "]))),
120
125
  type: 'dashed',
121
126
  onClick: function () {
122
127
  var _onClick = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -173,24 +178,25 @@ export var Page = function Page(props) {
173
178
  }
174
179
  return onClick;
175
180
  }()
176
- }, t('Add tab'))
177
- }, fieldSchema.mapProperties(function (schema) {
178
- return /*#__PURE__*/React.createElement(Tabs.TabPane, {
179
- tab: /*#__PURE__*/React.createElement(SortableItem, {
180
- id: schema.name,
181
- schema: schema,
182
- className: classNames('nb-action-link', designerCss, props.className)
183
- }, schema['x-icon'] && /*#__PURE__*/React.createElement(Icon, {
184
- style: {
185
- marginRight: 8
186
- },
187
- type: schema['x-icon']
188
- }), /*#__PURE__*/React.createElement("span", null, schema.title || t('Unnamed')), /*#__PURE__*/React.createElement(PageTabDesigner, {
189
- schema: schema
190
- })),
191
- key: schema.name
192
- });
193
- })))
181
+ }, t('Add tab')),
182
+ items: fieldSchema.mapProperties(function (schema) {
183
+ return {
184
+ label: /*#__PURE__*/React.createElement(SortableItem, {
185
+ id: schema.name,
186
+ schema: schema,
187
+ className: classNames('nb-action-link', designerCss, props.className)
188
+ }, schema['x-icon'] && /*#__PURE__*/React.createElement(Icon, {
189
+ style: {
190
+ marginRight: 8
191
+ },
192
+ type: schema['x-icon']
193
+ }), /*#__PURE__*/React.createElement("span", null, schema.title || t('Unnamed')), /*#__PURE__*/React.createElement(PageTabDesigner, {
194
+ schema: schema
195
+ })),
196
+ key: schema.name
197
+ };
198
+ })
199
+ }))
194
200
  }))), /*#__PURE__*/React.createElement("div", {
195
201
  className: "nb-page-wrapper",
196
202
  style: {
@@ -17,16 +17,20 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
17
  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; }
18
18
  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; }
19
19
  import { LoadingOutlined } from '@ant-design/icons';
20
- import { connect, mapProps, mapReadPretty, useField, useFieldSchema } from '@formily/react';
21
- import { Tag, Divider } from 'antd';
20
+ import { connect, mapProps, mapReadPretty, useField, useFieldSchema, useForm } from '@formily/react';
21
+ import { Divider, Tag } from 'antd';
22
+ import flat from 'flat';
22
23
  import { uniqBy } from 'lodash';
23
24
  import moment from 'moment';
24
25
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
25
26
  import { useRequest } from '../../../api-client';
27
+ import { useBlockRequestContext } from '../../../block-provider/BlockProvider';
26
28
  import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
27
29
  import { useCollection, useCollectionManager } from '../../../collection-manager';
28
- import { Select, defaultFieldNames } from '../select';
30
+ import { getInnermostKeyAndValue } from '../../common/utils/uitls';
31
+ import { defaultFieldNames, Select } from '../select';
29
32
  import { ReadPretty } from './ReadPretty';
33
+ import { extractFilterfield, extractValuesByPattern, generatePattern, parseVariables } from './utils';
30
34
  var EMPTY = 'N/A';
31
35
  var InternalRemoteSelect = connect(function (props) {
32
36
  var _fieldSchema$xCompon, _field$componentProps, _field$componentProps2, _field$componentProps3, _service$params;
@@ -48,10 +52,12 @@ var InternalRemoteSelect = connect(function (props) {
48
52
  _useState2 = _slicedToArray(_useState, 2),
49
53
  open = _useState2[0],
50
54
  setOpen = _useState2[1];
55
+ var form = useForm();
51
56
  var firstRun = useRef(false);
52
57
  var fieldSchema = useFieldSchema();
53
58
  var isQuickAdd = ((_fieldSchema$xCompon = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon === void 0 ? void 0 : _fieldSchema$xCompon.addMode) === 'quickAdd';
54
59
  var field = useField();
60
+ var ctx = useBlockRequestContext();
55
61
  var _useCollection = useCollection(),
56
62
  getField = _useCollection.getField;
57
63
  var searchData = useRef(null);
@@ -117,15 +123,60 @@ var InternalRemoteSelect = connect(function (props) {
117
123
  return options;
118
124
  }
119
125
  }, [targetField === null || targetField === void 0 ? void 0 : targetField.uiSchema, fieldNames]);
126
+ var parseFilter = function parseFilter(rules) {
127
+ if (!rules) {
128
+ return undefined;
129
+ }
130
+ var type = Object.keys(rules)[0] || '$and';
131
+ var conditions = rules[type];
132
+ var results = [];
133
+ conditions === null || conditions === void 0 ? void 0 : conditions.forEach(function (c) {
134
+ var _jsonlogic$value, _jsonlogic$value$matc;
135
+ var jsonlogic = getInnermostKeyAndValue(c);
136
+ var regex = /{{(.*?)}}/;
137
+ var matches = (_jsonlogic$value = jsonlogic.value) === null || _jsonlogic$value === void 0 ? void 0 : (_jsonlogic$value$matc = _jsonlogic$value.match) === null || _jsonlogic$value$matc === void 0 ? void 0 : _jsonlogic$value$matc.call(_jsonlogic$value, regex);
138
+ if (!matches || !matches[1].includes('$form') && !matches[1].includes('$iteration')) {
139
+ results.push(c);
140
+ return;
141
+ }
142
+ var associationfield = extractFilterfield(matches[1]);
143
+ var filterCollectionField = getCollectionJoinField("".concat(ctx.props.collection, ".").concat(associationfield));
144
+ if (['o2m', 'm2m'].includes(filterCollectionField === null || filterCollectionField === void 0 ? void 0 : filterCollectionField.interface)) {
145
+ // 对多子表单
146
+ var pattern = generatePattern(matches === null || matches === void 0 ? void 0 : matches[1], associationfield);
147
+ var parseValue = extractValuesByPattern(flat(form.values), pattern);
148
+ var filters = parseValue.map(function (v) {
149
+ return JSON.parse(JSON.stringify(c).replace(jsonlogic.value, v));
150
+ });
151
+ results.push({
152
+ $or: filters
153
+ });
154
+ } else {
155
+ var variablesCtx = {
156
+ $form: form.values,
157
+ $iteration: form.values
158
+ };
159
+ var str = matches === null || matches === void 0 ? void 0 : matches[1];
160
+ if (str.includes('$iteration')) {
161
+ var path = field.path.segments.concat([]);
162
+ path.pop();
163
+ str = str.replace('$iteration.', "$iteration.".concat(path.join('.'), "."));
164
+ }
165
+ var _parseValue = parseVariables(str, variablesCtx);
166
+ var filterObj = JSON.parse(JSON.stringify(c).replace(jsonlogic.value, str.endsWith('id') ? _parseValue !== null && _parseValue !== void 0 ? _parseValue : 0 : _parseValue));
167
+ results.push(filterObj);
168
+ }
169
+ });
170
+ return _defineProperty({}, type, results);
171
+ };
120
172
  var _useRequest = useRequest(_objectSpread(_objectSpread({
121
173
  action: 'list'
122
174
  }, service), {}, {
123
175
  params: _objectSpread(_objectSpread({
124
176
  pageSize: 200
125
177
  }, service === null || service === void 0 ? void 0 : service.params), {}, {
126
- // fields: [fieldNames.label, fieldNames.value, ...(service?.params?.fields || [])],
127
178
  // search needs
128
- filter: mergeFilter([((_field$componentProps = field.componentProps) === null || _field$componentProps === void 0 ? void 0 : (_field$componentProps2 = _field$componentProps.service) === null || _field$componentProps2 === void 0 ? void 0 : (_field$componentProps3 = _field$componentProps2.params) === null || _field$componentProps3 === void 0 ? void 0 : _field$componentProps3.filter) || (service === null || service === void 0 ? void 0 : (_service$params = service.params) === null || _service$params === void 0 ? void 0 : _service$params.filter)])
179
+ filter: mergeFilter([parseFilter((_field$componentProps = field.componentProps) === null || _field$componentProps === void 0 ? void 0 : (_field$componentProps2 = _field$componentProps.service) === null || _field$componentProps2 === void 0 ? void 0 : (_field$componentProps3 = _field$componentProps2.params) === null || _field$componentProps3 === void 0 ? void 0 : _field$componentProps3.filter) || (service === null || service === void 0 ? void 0 : (_service$params = service.params) === null || _service$params === void 0 ? void 0 : _service$params.filter)])
129
180
  })
130
181
  }), {
131
182
  manual: manual,
@@ -159,7 +210,7 @@ var InternalRemoteSelect = connect(function (props) {
159
210
  }
160
211
  }, [runDep]);
161
212
  var onSearch = /*#__PURE__*/function () {
162
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(search) {
213
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(search) {
163
214
  var _field$componentProps4, _field$componentProps5, _field$componentProps6, _service$params2;
164
215
  return _regeneratorRuntime().wrap(function _callee$(_context) {
165
216
  while (1) switch (_context.prev = _context.next) {
@@ -175,7 +226,7 @@ var InternalRemoteSelect = connect(function (props) {
175
226
  }, _callee);
176
227
  }));
177
228
  return function onSearch(_x2) {
178
- return _ref.apply(this, arguments);
229
+ return _ref2.apply(this, arguments);
179
230
  };
180
231
  }();
181
232
  var options = useMemo(function () {
@@ -189,10 +240,9 @@ var InternalRemoteSelect = connect(function (props) {
189
240
  var onDropdownVisibleChange = function onDropdownVisibleChange(visible) {
190
241
  setOpen(visible);
191
242
  searchData.current = null;
192
- if (firstRun.current && (data === null || data === void 0 ? void 0 : data.data.length) > 0) {
193
- return;
243
+ if (visible) {
244
+ run();
194
245
  }
195
- run();
196
246
  firstRun.current = true;
197
247
  };
198
248
  return /*#__PURE__*/React.createElement(Select, _objectSpread(_objectSpread({
@@ -0,0 +1,4 @@
1
+ export declare const parseVariables: (str: string, ctx: any) => any;
2
+ export declare function extractFilterfield(str: any): any;
3
+ export declare function extractValuesByPattern(obj: any, pattern: any): any[];
4
+ export declare function generatePattern(str: any, fieldName: any): any;
@@ -0,0 +1,31 @@
1
+ import { get, isFunction } from 'lodash';
2
+ export var parseVariables = function parseVariables(str, ctx) {
3
+ if (str) {
4
+ var result = get(ctx, str);
5
+ return isFunction(result) ? result() : result;
6
+ } else {
7
+ return str;
8
+ }
9
+ };
10
+ export function extractFilterfield(str) {
11
+ var match = str.match(/^\$form\.([^.[\]]+)/);
12
+ if (match) {
13
+ return match[1];
14
+ }
15
+ return null;
16
+ }
17
+ export function extractValuesByPattern(obj, pattern) {
18
+ var regexPattern = new RegExp(pattern.replace(/\*/g, '\\d+'));
19
+ var result = [];
20
+ for (var key in obj) {
21
+ if (regexPattern.test(key)) {
22
+ var value = obj[key];
23
+ result.push(value);
24
+ }
25
+ }
26
+ return result;
27
+ }
28
+ export function generatePattern(str, fieldName) {
29
+ var result = str.replace("$form.".concat(fieldName, "."), "".concat(fieldName, ".*."));
30
+ return result;
31
+ }
@@ -1,11 +1,26 @@
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 = ["value", "onChange", "renderSchemaComponent", "form", "collectionField"];
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ 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); }
8
+ 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; }
9
+ 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; }
1
10
  import React from 'react';
2
11
  import { useVariableOptions } from '../../../schema-settings/VariableInput/hooks/useVariableOptions';
3
12
  import { Variable } from '../variable';
4
13
  export function FilterDynamicComponent(props) {
5
14
  var value = props.value,
6
15
  onChange = props.onChange,
7
- renderSchemaComponent = props.renderSchemaComponent;
8
- var options = useVariableOptions();
16
+ renderSchemaComponent = props.renderSchemaComponent,
17
+ form = props.form,
18
+ collectionField = props.collectionField,
19
+ other = _objectWithoutProperties(props, _excluded);
20
+ var options = useVariableOptions(_objectSpread({
21
+ form: form,
22
+ collectionField: collectionField
23
+ }, other));
9
24
  return /*#__PURE__*/React.createElement(Variable.Input, {
10
25
  value: value,
11
26
  onChange: onChange,
@@ -6,11 +6,14 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import { useField, useFieldSchema } from '@formily/react';
8
8
  import React from 'react';
9
+ import { set } from 'lodash';
9
10
  import { useTranslation } from 'react-i18next';
10
- import { useCollectionManager } from '../../../collection-manager';
11
+ import { useCollectionManager, useCollectionFilterOptions } from '../../../collection-manager';
11
12
  import { GeneralSchemaDesigner, SchemaSettings, isPatternDisabled } from '../../../schema-settings';
12
13
  import { useCompile, useDesignable } from '../../hooks';
13
14
  import { useAssociationFieldContext } from '../association-field/hooks';
15
+ import { FilterDynamicComponent } from './FilterDynamicComponent';
16
+ import { removeNullCondition } from '../filter';
14
17
  var useLabelFields = function useLabelFields(collectionName) {
15
18
  var _targetFields$filter, _targetFields$filter$, _targetFields$filter$2;
16
19
  // 需要在组件顶层调用
@@ -32,7 +35,7 @@ var useLabelFields = function useLabelFields(collectionName) {
32
35
  });
33
36
  };
34
37
  export var TableColumnDesigner = function TableColumnDesigner(props) {
35
- var _fieldSchema$xCompon, _uiSchema$xComponent, _collectionField$targ, _collectionField$uiSc, _columnSchema$xCompo, _fieldSchema$xCompon2;
38
+ var _fieldSchema$xCompon, _uiSchema$xComponent, _collectionField$targ, _fieldSchema$xCompon2, _fieldSchema$xCompon3, _fieldSchema$xCompon4, _collectionField$uiSc, _columnSchema$xCompo, _fieldSchema$xCompon5;
36
39
  var uiSchema = props.uiSchema,
37
40
  fieldSchema = props.fieldSchema,
38
41
  collectionField = props.collectionField;
@@ -54,6 +57,8 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
54
57
  var _useAssociationFieldC = useAssociationFieldContext(),
55
58
  currentMode = _useAssociationFieldC.currentMode,
56
59
  tableField = _useAssociationFieldC.field;
60
+ var defaultFilter = (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : (_fieldSchema$xCompon3 = _fieldSchema$xCompon2.service) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : (_fieldSchema$xCompon4 = _fieldSchema$xCompon3.params) === null || _fieldSchema$xCompon4 === void 0 ? void 0 : _fieldSchema$xCompon4.filter) || {};
61
+ var dataSource = useCollectionFilterOptions(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
57
62
  var readOnlyMode = 'editable';
58
63
  if (fieldSchema['x-disabled'] === true) {
59
64
  readOnlyMode = 'readonly';
@@ -93,6 +98,40 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
93
98
  }
94
99
  dn.refresh();
95
100
  }
101
+ }), currentMode && !field.readPretty && /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
102
+ title: t('Set the data scope'),
103
+ schema: {
104
+ type: 'object',
105
+ title: t('Set the data scope'),
106
+ properties: {
107
+ filter: {
108
+ default: defaultFilter,
109
+ enum: dataSource,
110
+ 'x-component': 'Filter',
111
+ 'x-component-props': {
112
+ dynamicComponent: function dynamicComponent(props) {
113
+ return FilterDynamicComponent(_objectSpread({}, props));
114
+ }
115
+ }
116
+ }
117
+ }
118
+ },
119
+ onSubmit: function onSubmit(_ref2) {
120
+ var _field$path, _field$path2, _schema;
121
+ var filter = _ref2.filter;
122
+ filter = removeNullCondition(filter);
123
+ set(field.componentProps, 'service.params.filter', filter);
124
+ fieldSchema['x-component-props'] = field.componentProps;
125
+ var path = (_field$path = field.path) === null || _field$path === void 0 ? void 0 : _field$path.splice(((_field$path2 = field.path) === null || _field$path2 === void 0 ? void 0 : _field$path2.length) - 1, 1);
126
+ tableField === null || tableField === void 0 ? void 0 : tableField.value.map(function (_, index) {
127
+ field.form.query("".concat(path.concat("".concat(index, ".") + fieldSchema.name))).take(function (f) {
128
+ set(f.componentProps, 'service.params.filter', filter);
129
+ });
130
+ });
131
+ dn.emit('patch', {
132
+ schema: (_schema = {}, _defineProperty(_schema, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema, 'x-component-props', field.componentProps), _schema)
133
+ });
134
+ }
96
135
  }), /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
97
136
  title: t('Column width'),
98
137
  schema: {
@@ -107,8 +146,8 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
107
146
  }
108
147
  }
109
148
  },
110
- onSubmit: function onSubmit(_ref2) {
111
- var width = _ref2.width;
149
+ onSubmit: function onSubmit(_ref3) {
150
+ var width = _ref3.width;
112
151
  var props = columnSchema['x-component-props'] || {};
113
152
  props['width'] = width;
114
153
  var schema = _defineProperty({}, 'x-uid', columnSchema['x-uid']);
@@ -137,7 +176,7 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
137
176
  }
138
177
  }), ['linkTo', 'm2m', 'm2o', 'o2m', 'obo', 'oho', 'snapshot', 'createdBy', 'updatedBy'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) && !isFileField && readOnlyMode === 'read-pretty' && /*#__PURE__*/React.createElement(SchemaSettings.SwitchItem, {
139
178
  title: t('Enable link'),
140
- checked: ((_fieldSchema$xCompon2 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon2 === void 0 ? void 0 : _fieldSchema$xCompon2.enableLink) !== false,
179
+ checked: ((_fieldSchema$xCompon5 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon5 === void 0 ? void 0 : _fieldSchema$xCompon5.enableLink) !== false,
141
180
  onChange: function onChange(flag) {
142
181
  fieldSchema['x-component-props'] = _objectSpread(_objectSpread({}, fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component-props']), {}, {
143
182
  enableLink: flag
@@ -158,8 +197,8 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
158
197
  options: options,
159
198
  value: fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames['label'],
160
199
  onChange: function onChange(label) {
161
- var _collectionField$uiSc2, _fieldSchema$xCompon3;
162
- var fieldNames = _objectSpread(_objectSpread(_objectSpread({}, collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc2 = collectionField.uiSchema) === null || _collectionField$uiSc2 === void 0 ? void 0 : _collectionField$uiSc2['x-component-props']['fieldNames']), fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon3 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon3 === void 0 ? void 0 : _fieldSchema$xCompon3['fieldNames']), {}, {
200
+ var _collectionField$uiSc2, _fieldSchema$xCompon6;
201
+ var fieldNames = _objectSpread(_objectSpread(_objectSpread({}, collectionField === null || collectionField === void 0 ? void 0 : (_collectionField$uiSc2 = collectionField.uiSchema) === null || _collectionField$uiSc2 === void 0 ? void 0 : _collectionField$uiSc2['x-component-props']['fieldNames']), fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon6 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon6 === void 0 ? void 0 : _fieldSchema$xCompon6['fieldNames']), {}, {
163
202
  label: label
164
203
  });
165
204
  fieldSchema['x-component-props']['fieldNames'] = fieldNames;
@@ -179,11 +218,11 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
179
218
  title: t('Required'),
180
219
  checked: fieldSchema.required,
181
220
  onChange: function onChange(required) {
182
- var _field$path, _field$path2;
221
+ var _field$path3, _field$path4;
183
222
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
184
223
  fieldSchema['required'] = required;
185
224
  schema['required'] = required;
186
- var path = (_field$path = field.path) === null || _field$path === void 0 ? void 0 : _field$path.splice(((_field$path2 = field.path) === null || _field$path2 === void 0 ? void 0 : _field$path2.length) - 1, 1);
225
+ var path = (_field$path3 = field.path) === null || _field$path3 === void 0 ? void 0 : _field$path3.splice(((_field$path4 = field.path) === null || _field$path4 === void 0 ? void 0 : _field$path4.length) - 1, 1);
187
226
  tableField === null || tableField === void 0 ? void 0 : tableField.value.map(function (_, index) {
188
227
  field.form.query("".concat(path.concat("".concat(index, ".") + fieldSchema.name))).take(function (f) {
189
228
  f.required = required;
@@ -209,9 +248,9 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
209
248
  }],
210
249
  value: readOnlyMode,
211
250
  onChange: function onChange(v) {
212
- var _field$path3, _field$path4;
251
+ var _field$path5, _field$path6;
213
252
  var schema = _defineProperty({}, 'x-uid', fieldSchema['x-uid']);
214
- var path = (_field$path3 = field.path) === null || _field$path3 === void 0 ? void 0 : _field$path3.splice(((_field$path4 = field.path) === null || _field$path4 === void 0 ? void 0 : _field$path4.length) - 1, 1);
253
+ var path = (_field$path5 = field.path) === null || _field$path5 === void 0 ? void 0 : _field$path5.splice(((_field$path6 = field.path) === null || _field$path6 === void 0 ? void 0 : _field$path6.length) - 1, 1);
215
254
  switch (v) {
216
255
  case 'readonly':
217
256
  {
@@ -261,7 +300,7 @@ export var TableColumnDesigner = function TableColumnDesigner(props) {
261
300
  dn.refresh();
262
301
  }
263
302
  }), /*#__PURE__*/React.createElement(SchemaSettings.Divider, null), /*#__PURE__*/React.createElement(SchemaSettings.Remove, {
264
- removeParentsIfNoChildren: true,
303
+ removeParentsIfNoChildren: !isSubTableColumn,
265
304
  breakRemoveOn: {
266
305
  'x-component': 'Grid'
267
306
  },