@nocobase/client 0.12.0-alpha.2 → 0.12.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 (161) hide show
  1. package/es/api-client/hooks/useRequest.js +16 -1
  2. package/es/block-provider/BlockProvider.js +2 -2
  3. package/es/block-provider/hooks/index.js +16 -18
  4. package/es/collection-manager/Configuration/AddCollectionAction.js +2 -2
  5. package/es/collection-manager/Configuration/AddFieldAction.js +2 -1
  6. package/es/collection-manager/Configuration/EditFieldAction.js +2 -1
  7. package/es/collection-manager/action-hooks.js +3 -1
  8. package/es/global-theme/AntdAppProvider.js +5 -1
  9. package/es/locale/en_US.d.ts +4 -0
  10. package/es/locale/en_US.js +4 -0
  11. package/es/locale/ja_JP.d.ts +1 -0
  12. package/es/locale/ja_JP.js +1 -0
  13. package/es/locale/zh_CN.d.ts +6 -0
  14. package/es/locale/zh_CN.js +7 -1
  15. package/es/pm/Card.js +6 -1
  16. package/es/schema-component/antd/action/Action.Designer.js +243 -54
  17. package/es/schema-component/antd/action/Action.Drawer.js +2 -2
  18. package/es/schema-component/antd/action/Action.Modal.js +1 -1
  19. package/es/schema-component/antd/action/Action.js +15 -19
  20. package/es/schema-component/antd/appends-tree-select/AppendsTreeSelect.d.ts +8 -2
  21. package/es/schema-component/antd/appends-tree-select/AppendsTreeSelect.js +67 -36
  22. package/es/schema-component/antd/association-field/AssociationFieldProvider.js +3 -15
  23. package/es/schema-component/antd/association-field/Editable.js +2 -1
  24. package/es/schema-component/antd/association-field/FileManager.js +4 -3
  25. package/es/schema-component/antd/association-field/InternalNester.d.ts +1 -1
  26. package/es/schema-component/antd/association-field/InternalNester.js +6 -4
  27. package/es/schema-component/antd/association-field/InternalPicker.js +2 -1
  28. package/es/schema-component/antd/association-field/InternalPopoverNester.d.ts +2 -0
  29. package/es/schema-component/antd/association-field/InternalPopoverNester.js +95 -0
  30. package/es/schema-component/antd/association-field/InternalSubTable.js +2 -5
  31. package/es/schema-component/antd/association-field/InternalViewer.js +1 -1
  32. package/es/schema-component/antd/association-field/hooks.js +77 -5
  33. package/es/schema-component/antd/association-field/util.d.ts +4 -0
  34. package/es/schema-component/antd/association-field/util.js +32 -1
  35. package/es/schema-component/antd/color-picker/ReadPretty.js +1 -1
  36. package/es/schema-component/antd/form-item/FormItem.js +36 -112
  37. package/es/schema-component/antd/form-v2/Templates.js +12 -5
  38. package/es/schema-component/antd/grid-card/GridCard.Item.js +4 -4
  39. package/es/schema-component/antd/input/EllipsisWithTooltip.js +2 -1
  40. package/es/schema-component/antd/list/List.Item.js +3 -3
  41. package/es/schema-component/antd/markdown/Markdown.Void.js +6 -1
  42. package/es/schema-component/antd/markdown/Markdown.js +6 -1
  43. package/es/schema-component/antd/markdown/style.js +2 -4
  44. package/es/schema-component/antd/quick-edit/QuickEdit.js +5 -3
  45. package/es/schema-component/antd/remote-select/RemoteSelect.js +11 -79
  46. package/es/schema-component/antd/rich-text/RichText.js +7 -2
  47. package/es/schema-component/antd/table-v2/Table.Column.Designer.js +45 -35
  48. package/es/schema-component/antd/table-v2/Table.js +12 -10
  49. package/es/schema-component/antd/table-v2/utils.d.ts +5 -0
  50. package/es/schema-component/antd/table-v2/utils.js +14 -1
  51. package/es/schema-component/antd/variable/Input.js +2 -1
  52. package/es/schema-component/antd/variable/TextArea.js +1 -1
  53. package/es/schema-component/common/utils/uitls.js +19 -2
  54. package/es/schema-component/hooks/useFieldModeOptions.d.ts +1 -1
  55. package/es/schema-component/hooks/useFieldModeOptions.js +23 -9
  56. package/es/schema-initializer/buttons/FormActionInitializers.d.ts +75 -0
  57. package/es/schema-initializer/buttons/FormActionInitializers.js +39 -11
  58. package/es/schema-initializer/buttons/RecordBlockInitializers.js +12 -0
  59. package/es/schema-initializer/items/CreateActionInitializer.js +2 -1
  60. package/es/schema-initializer/items/CreateSubmitActionInitializer.js +3 -0
  61. package/es/schema-initializer/items/RecordAssociationGridCardBlockInitializer.d.ts +2 -0
  62. package/es/schema-initializer/items/RecordAssociationGridCardBlockInitializer.js +74 -0
  63. package/es/schema-initializer/items/RecordAssociationListBlockInitializer.d.ts +2 -0
  64. package/es/schema-initializer/items/RecordAssociationListBlockInitializer.js +74 -0
  65. package/es/schema-initializer/items/RecordFormBlockInitializer.js +3 -2
  66. package/es/schema-initializer/items/RecordReadPrettyFormBlockInitializer.js +3 -2
  67. package/es/schema-initializer/items/UpdateSubmitActionInitializer.js +3 -0
  68. package/es/schema-initializer/items/index.d.ts +2 -0
  69. package/es/schema-initializer/items/index.js +2 -0
  70. package/es/schema-initializer/utils.js +6 -4
  71. package/es/schema-settings/DataTemplates/hooks/useCollectionState.js +2 -2
  72. package/es/schema-settings/DataTemplates/utils.js +1 -1
  73. package/es/schema-settings/LinkageRules/components/LinkageHeader.js +2 -2
  74. package/es/schema-settings/SchemaSettings.js +132 -19
  75. package/es/schema-settings/VariableInput/VariableInput.js +6 -3
  76. package/es/schema-settings/VariableInput/hooks/useContextAssociationFields.d.ts +4 -1
  77. package/es/schema-settings/VariableInput/hooks/useContextAssociationFields.js +22 -5
  78. package/es/schema-templates/SchemaTemplateManagerProvider.js +6 -1
  79. package/lib/api-client/hooks/useRequest.js +16 -1
  80. package/lib/block-provider/BlockProvider.js +2 -2
  81. package/lib/block-provider/hooks/index.js +21 -23
  82. package/lib/collection-manager/Configuration/AddCollectionAction.js +2 -2
  83. package/lib/collection-manager/Configuration/AddFieldAction.js +2 -1
  84. package/lib/collection-manager/Configuration/EditFieldAction.js +2 -1
  85. package/lib/collection-manager/action-hooks.js +3 -1
  86. package/lib/global-theme/AntdAppProvider.js +5 -1
  87. package/lib/locale/en_US.d.ts +4 -0
  88. package/lib/locale/en_US.js +4 -0
  89. package/lib/locale/ja_JP.d.ts +1 -0
  90. package/lib/locale/ja_JP.js +1 -0
  91. package/lib/locale/zh_CN.d.ts +6 -0
  92. package/lib/locale/zh_CN.js +7 -1
  93. package/lib/pm/Card.js +6 -1
  94. package/lib/schema-component/antd/action/Action.Designer.js +242 -53
  95. package/lib/schema-component/antd/action/Action.Drawer.js +2 -2
  96. package/lib/schema-component/antd/action/Action.Modal.js +1 -1
  97. package/lib/schema-component/antd/action/Action.js +15 -19
  98. package/lib/schema-component/antd/appends-tree-select/AppendsTreeSelect.d.ts +8 -2
  99. package/lib/schema-component/antd/appends-tree-select/AppendsTreeSelect.js +66 -35
  100. package/lib/schema-component/antd/association-field/AssociationFieldProvider.js +3 -15
  101. package/lib/schema-component/antd/association-field/Editable.js +2 -1
  102. package/lib/schema-component/antd/association-field/FileManager.js +4 -3
  103. package/lib/schema-component/antd/association-field/InternalNester.d.ts +1 -1
  104. package/lib/schema-component/antd/association-field/InternalNester.js +5 -3
  105. package/lib/schema-component/antd/association-field/InternalPicker.js +2 -1
  106. package/lib/schema-component/antd/association-field/InternalPopoverNester.d.ts +2 -0
  107. package/lib/schema-component/antd/association-field/InternalPopoverNester.js +104 -0
  108. package/lib/schema-component/antd/association-field/InternalSubTable.js +1 -4
  109. package/lib/schema-component/antd/association-field/InternalViewer.js +1 -1
  110. package/lib/schema-component/antd/association-field/hooks.js +76 -4
  111. package/lib/schema-component/antd/association-field/util.d.ts +4 -0
  112. package/lib/schema-component/antd/association-field/util.js +37 -2
  113. package/lib/schema-component/antd/color-picker/ReadPretty.js +1 -1
  114. package/lib/schema-component/antd/form-item/FormItem.js +34 -110
  115. package/lib/schema-component/antd/form-v2/Templates.js +12 -5
  116. package/lib/schema-component/antd/grid-card/GridCard.Item.js +3 -3
  117. package/lib/schema-component/antd/input/EllipsisWithTooltip.js +2 -1
  118. package/lib/schema-component/antd/list/List.Item.js +2 -2
  119. package/lib/schema-component/antd/markdown/Markdown.Void.js +6 -1
  120. package/lib/schema-component/antd/markdown/Markdown.js +6 -1
  121. package/lib/schema-component/antd/markdown/style.js +2 -4
  122. package/lib/schema-component/antd/quick-edit/QuickEdit.js +5 -3
  123. package/lib/schema-component/antd/remote-select/RemoteSelect.js +11 -79
  124. package/lib/schema-component/antd/rich-text/RichText.js +6 -1
  125. package/lib/schema-component/antd/table-v2/Table.Column.Designer.js +44 -34
  126. package/lib/schema-component/antd/table-v2/Table.js +11 -9
  127. package/lib/schema-component/antd/table-v2/utils.d.ts +5 -0
  128. package/lib/schema-component/antd/table-v2/utils.js +16 -2
  129. package/lib/schema-component/antd/variable/Input.js +2 -1
  130. package/lib/schema-component/antd/variable/TextArea.js +1 -1
  131. package/lib/schema-component/common/utils/uitls.js +19 -2
  132. package/lib/schema-component/hooks/useFieldModeOptions.d.ts +1 -1
  133. package/lib/schema-component/hooks/useFieldModeOptions.js +23 -9
  134. package/lib/schema-initializer/buttons/FormActionInitializers.d.ts +75 -0
  135. package/lib/schema-initializer/buttons/FormActionInitializers.js +39 -11
  136. package/lib/schema-initializer/buttons/RecordBlockInitializers.js +12 -0
  137. package/lib/schema-initializer/items/CreateActionInitializer.js +2 -1
  138. package/lib/schema-initializer/items/CreateSubmitActionInitializer.js +3 -0
  139. package/lib/schema-initializer/items/RecordAssociationGridCardBlockInitializer.d.ts +2 -0
  140. package/lib/schema-initializer/items/RecordAssociationGridCardBlockInitializer.js +82 -0
  141. package/lib/schema-initializer/items/RecordAssociationListBlockInitializer.d.ts +2 -0
  142. package/lib/schema-initializer/items/RecordAssociationListBlockInitializer.js +82 -0
  143. package/lib/schema-initializer/items/RecordFormBlockInitializer.js +3 -2
  144. package/lib/schema-initializer/items/RecordReadPrettyFormBlockInitializer.js +3 -2
  145. package/lib/schema-initializer/items/UpdateSubmitActionInitializer.js +3 -0
  146. package/lib/schema-initializer/items/index.d.ts +2 -0
  147. package/lib/schema-initializer/items/index.js +22 -0
  148. package/lib/schema-initializer/utils.js +6 -4
  149. package/lib/schema-settings/DataTemplates/hooks/useCollectionState.js +2 -2
  150. package/lib/schema-settings/DataTemplates/utils.js +1 -1
  151. package/lib/schema-settings/LinkageRules/components/LinkageHeader.js +1 -1
  152. package/lib/schema-settings/SchemaSettings.js +131 -18
  153. package/lib/schema-settings/VariableInput/VariableInput.js +5 -2
  154. package/lib/schema-settings/VariableInput/hooks/useContextAssociationFields.d.ts +4 -1
  155. package/lib/schema-settings/VariableInput/hooks/useContextAssociationFields.js +24 -6
  156. package/lib/schema-templates/SchemaTemplateManagerProvider.js +6 -1
  157. package/package.json +5 -5
  158. package/es/schema-component/antd/remote-select/utils.d.ts +0 -4
  159. package/es/schema-component/antd/remote-select/utils.js +0 -31
  160. package/lib/schema-component/antd/remote-select/utils.d.ts +0 -4
  161. package/lib/schema-component/antd/remote-select/utils.js +0 -41
@@ -1,5 +1,5 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
3
3
  var _excluded = ["children", "fieldSchema"],
4
4
  _excluded2 = ["title", "dn"],
5
5
  _excluded3 = ["title", "options", "value", "onChange", "openOnHover", "onClick"],
@@ -8,7 +8,6 @@ var _excluded = ["children", "fieldSchema"],
8
8
  _excluded6 = ["schema"],
9
9
  _excluded7 = ["title", "onSubmit", "initialValues", "initialSchema", "schema", "modalTip", "components"],
10
10
  _excluded8 = ["hidden", "title", "components", "scope", "effects", "schema", "onSubmit", "asyncGetInitialValues", "initialValues", "width"];
11
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
12
11
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
13
12
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
14
13
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -17,6 +16,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
17
16
  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; }
18
17
  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); } }
19
18
  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
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
20
20
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
21
  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."); }
22
22
  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); }
@@ -43,7 +43,7 @@ import React, { createContext, useCallback, useContext, useMemo, useState,
43
43
  useTransition as useReactTransition } from 'react';
44
44
  import { createPortal } from 'react-dom';
45
45
  import { useTranslation } from 'react-i18next';
46
- import { ActionContextProvider, APIClientProvider, CollectionManagerContext, CollectionProvider, createDesignable, findFormBlock, FormDialog, FormProvider, RemoteSchemaComponent, SchemaComponent, SchemaComponentContext, SchemaComponentOptions, useAPIClient, useBlockRequestContext, useCollection, useCollectionManager, useCompile, useDesignable, useFilterBlock, useGlobalTheme, useLinkageCollectionFilterOptions } from '..';
46
+ import { ActionContextProvider, APIClientProvider, CollectionManagerContext, CollectionProvider, createDesignable, findFormBlock, FormDialog, FormProvider, RemoteSchemaComponent, SchemaComponent, SchemaComponentContext, SchemaComponentOptions, useAPIClient, useBlockRequestContext, useCollection, useCollectionManager, useCompile, useDesignable, useFilterBlock, useGlobalTheme, useLinkageCollectionFilterOptions, useSortFields, useActionContext } from '..';
47
47
  import { useTableBlockContext } from '../block-provider';
48
48
  import { findFilterTargets, updateFilterTargets } from '../block-provider/hooks';
49
49
  import { getSupportFieldsByAssociation, getSupportFieldsByForeignKey, isSameCollection, useSupportedBlocks } from '../filter-provider/utils';
@@ -111,6 +111,7 @@ export var SchemaSettings = function SchemaSettings(props) {
111
111
  onOpenChange: function onOpenChange(open) {
112
112
  changeMenu(open);
113
113
  },
114
+ overlayClassName: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ant-dropdown-menu-item-group-list {\n max-height: 300px;\n overflow-y: auto;\n }\n "]))),
114
115
  menu: {
115
116
  items: items
116
117
  }
@@ -799,7 +800,7 @@ SchemaSettings.CascaderItem = function (props) {
799
800
  display: 'flex',
800
801
  justifyContent: 'space-between'
801
802
  }
802
- }, title, /*#__PURE__*/React.createElement(Cascader, {
803
+ }, title, /*#__PURE__*/React.createElement(Cascader, _objectSpread({
803
804
  bordered: false,
804
805
  defaultValue: value,
805
806
  onChange: onChange,
@@ -808,7 +809,7 @@ SchemaSettings.CascaderItem = function (props) {
808
809
  textAlign: 'right',
809
810
  minWidth: 100
810
811
  }
811
- })));
812
+ }, props))));
812
813
  };
813
814
  SchemaSettings.SwitchItem = function SwitchItem(props) {
814
815
  var title = props.title,
@@ -1045,9 +1046,7 @@ SchemaSettings.ModalItem = function ModalItem(props) {
1045
1046
  components: options.components
1046
1047
  }, /*#__PURE__*/React.createElement(FormLayout, {
1047
1048
  layout: 'vertical',
1048
- style: {
1049
- minWidth: 520
1050
- }
1049
+ className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n // screen > 576px\n @media (min-width: 576px) {\n min-width: 520px;\n }\n\n // screen <= 576px\n @media (max-width: 576px) {\n min-width: 320px;\n }\n "])))
1051
1050
  }, /*#__PURE__*/React.createElement(APIClientProvider, {
1052
1051
  apiClient: apiClient
1053
1052
  }, /*#__PURE__*/React.createElement(SchemaComponent, {
@@ -1460,7 +1459,7 @@ SchemaSettings.DataFormat = function DateFormatConfig(props) {
1460
1459
  'x-decorator': 'FormItem',
1461
1460
  'x-decorator-props': {},
1462
1461
  'x-component-props': {
1463
- className: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ant-radio-wrapper {\n display: flex;\n margin: 5px 0px;\n }\n "]))),
1462
+ className: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .ant-radio-wrapper {\n display: flex;\n margin: 5px 0px;\n }\n "]))),
1464
1463
  defaultValue: 'dddd',
1465
1464
  formats: ['MMMMM Do YYYY', 'YYYY-MM-DD', 'MM/DD/YY', 'YYYY/MM/DD', 'DD/MM/YYYY']
1466
1465
  },
@@ -1509,10 +1508,10 @@ SchemaSettings.DataFormat = function DateFormatConfig(props) {
1509
1508
  'x-component': ExpiresRadio,
1510
1509
  'x-decorator': 'FormItem',
1511
1510
  'x-decorator-props': {
1512
- className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-bottom: 0px;\n "])))
1511
+ className: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n margin-bottom: 0px;\n "])))
1513
1512
  },
1514
1513
  'x-component-props': {
1515
- className: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: red;\n .ant-radio-wrapper {\n display: flex;\n margin: 5px 0px;\n }\n "]))),
1514
+ className: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n color: red;\n .ant-radio-wrapper {\n display: flex;\n margin: 5px 0px;\n }\n "]))),
1516
1515
  defaultValue: 'h:mm a',
1517
1516
  formats: ['hh:mm:ss a', 'HH:mm:ss'],
1518
1517
  timeFormat: true
@@ -1551,7 +1550,7 @@ SchemaSettings.DataFormat = function DateFormatConfig(props) {
1551
1550
  }
1552
1551
  });
1553
1552
  };
1554
- var defaultInputStyle = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n & > .nb-form-item {\n flex: 1;\n }\n"])));
1553
+ var defaultInputStyle = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n & > .nb-form-item {\n flex: 1;\n }\n"])));
1555
1554
  export var findParentFieldSchema = function findParentFieldSchema(fieldSchema) {
1556
1555
  var parent = fieldSchema.parent;
1557
1556
  while (parent) {
@@ -1562,7 +1561,7 @@ export var findParentFieldSchema = function findParentFieldSchema(fieldSchema) {
1562
1561
  }
1563
1562
  };
1564
1563
  SchemaSettings.DefaultValue = function DefaultValueConfigure(props) {
1565
- var _props$fieldSchema;
1564
+ var _props$fieldSchema, _actionCtx$fieldSchem;
1566
1565
  var variablesCtx = useVariablesCtx();
1567
1566
  var currentSchema = useFieldSchema();
1568
1567
  var fieldSchema = (_props$fieldSchema = props === null || props === void 0 ? void 0 : props.fieldSchema) !== null && _props$fieldSchema !== void 0 ? _props$fieldSchema : currentSchema;
@@ -1571,6 +1570,7 @@ SchemaSettings.DefaultValue = function DefaultValueConfigure(props) {
1571
1570
  dn = _useDesignable7.dn;
1572
1571
  var _useTranslation12 = useTranslation(),
1573
1572
  t = _useTranslation12.t;
1573
+ var actionCtx = useActionContext();
1574
1574
  var targetField;
1575
1575
  var _useCollection2 = useCollection(),
1576
1576
  getField = _useCollection2.getField;
@@ -1585,7 +1585,7 @@ SchemaSettings.DefaultValue = function DefaultValueConfigure(props) {
1585
1585
  var parentFieldSchema = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) === 'm2o' && findParentFieldSchema(fieldSchema);
1586
1586
  var parentCollectionField = parentFieldSchema && getCollectionJoinField(parentFieldSchema === null || parentFieldSchema === void 0 ? void 0 : parentFieldSchema['x-collection-field']);
1587
1587
  var tableCtx = useTableBlockContext();
1588
- var isAllowContextVariable = (collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) === 'm2m' || (parentCollectionField === null || parentCollectionField === void 0 ? void 0 : parentCollectionField.type) === 'hasMany' && (collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) === 'm2o';
1588
+ var isAllowContexVariable = (actionCtx === null || actionCtx === void 0 ? void 0 : (_actionCtx$fieldSchem = actionCtx.fieldSchema) === null || _actionCtx$fieldSchem === void 0 ? void 0 : _actionCtx$fieldSchem['x-action']) === 'customize:create' && ((collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) === 'm2m' || (parentCollectionField === null || parentCollectionField === void 0 ? void 0 : parentCollectionField.type) === 'hasMany' && (collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) === 'm2o');
1589
1589
  return /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
1590
1590
  title: t('Set default value'),
1591
1591
  components: {
@@ -1603,7 +1603,7 @@ SchemaSettings.DefaultValue = function DefaultValueConfigure(props) {
1603
1603
  'x-component': 'VariableInput',
1604
1604
  'x-component-props': _objectSpread(_objectSpread({}, (fieldSchema === null || fieldSchema === void 0 ? void 0 : fieldSchema['x-component-props']) || {}), {}, {
1605
1605
  collectionField: collectionField,
1606
- contextCollectionName: isAllowContextVariable && tableCtx.collection,
1606
+ contextCollectionName: isAllowContexVariable && tableCtx.collection,
1607
1607
  schema: collectionField === null || collectionField === void 0 ? void 0 : collectionField.uiSchema,
1608
1608
  className: defaultInputStyle,
1609
1609
  renderSchemaComponent: function Com(props) {
@@ -1614,10 +1614,11 @@ SchemaSettings.DefaultValue = function DefaultValueConfigure(props) {
1614
1614
  s['x-read-pretty'] = false;
1615
1615
  s['x-disabled'] = false;
1616
1616
  var schema = _objectSpread(_objectSpread({}, s || {}), {}, {
1617
+ 'x-decorator': 'FormItem',
1617
1618
  'x-component-props': _objectSpread(_objectSpread({}, s['x-component-props']), {}, {
1618
1619
  collectionName: collectionField === null || collectionField === void 0 ? void 0 : collectionField.collectionName,
1619
1620
  targetField: targetField,
1620
- onChange: props.onChange,
1621
+ onChange: (collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) !== 'richText' ? props.onChange : null,
1621
1622
  defaultValue: getFieldDefaultValue(s, collectionField),
1622
1623
  style: {
1623
1624
  width: '100%',
@@ -1651,9 +1652,121 @@ SchemaSettings.DefaultValue = function DefaultValueConfigure(props) {
1651
1652
  }
1652
1653
  });
1653
1654
  };
1655
+ SchemaSettings.SortingRule = function SortRuleConfigure(props) {
1656
+ var _props$fieldSchema2, _fieldSchema$xCompon8, _fieldSchema$xCompon9, _fieldSchema$xCompon10;
1657
+ var field = useField();
1658
+ var _useDesignable8 = useDesignable(),
1659
+ dn = _useDesignable8.dn;
1660
+ var _useTranslation13 = useTranslation(),
1661
+ t = _useTranslation13.t;
1662
+ var currentSchema = useFieldSchema();
1663
+ var _useCollection3 = useCollection(),
1664
+ getField = _useCollection3.getField;
1665
+ var _useCollectionManager7 = useCollectionManager(),
1666
+ getCollectionJoinField = _useCollectionManager7.getCollectionJoinField;
1667
+ var fieldSchema = (_props$fieldSchema2 = props === null || props === void 0 ? void 0 : props.fieldSchema) !== null && _props$fieldSchema2 !== void 0 ? _props$fieldSchema2 : currentSchema;
1668
+ var collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
1669
+ var sortFields = useSortFields(collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
1670
+ var defaultSort = ((_fieldSchema$xCompon8 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon8 === void 0 ? void 0 : (_fieldSchema$xCompon9 = _fieldSchema$xCompon8.service) === null || _fieldSchema$xCompon9 === void 0 ? void 0 : (_fieldSchema$xCompon10 = _fieldSchema$xCompon9.params) === null || _fieldSchema$xCompon10 === void 0 ? void 0 : _fieldSchema$xCompon10.sort) || [];
1671
+ var sort = defaultSort === null || defaultSort === void 0 ? void 0 : defaultSort.map(function (item) {
1672
+ return item !== null && item !== void 0 && item.startsWith('-') ? {
1673
+ field: item.substring(1),
1674
+ direction: 'desc'
1675
+ } : {
1676
+ field: item,
1677
+ direction: 'asc'
1678
+ };
1679
+ });
1680
+ return /*#__PURE__*/React.createElement(SchemaSettings.ModalItem, {
1681
+ title: t('Set default sorting rules'),
1682
+ components: {
1683
+ ArrayItems: ArrayItems
1684
+ },
1685
+ schema: {
1686
+ type: 'object',
1687
+ title: t('Set default sorting rules'),
1688
+ properties: {
1689
+ sort: {
1690
+ type: 'array',
1691
+ default: sort,
1692
+ 'x-component': 'ArrayItems',
1693
+ 'x-decorator': 'FormItem',
1694
+ items: {
1695
+ type: 'object',
1696
+ properties: {
1697
+ space: {
1698
+ type: 'void',
1699
+ 'x-component': 'Space',
1700
+ properties: {
1701
+ sort: {
1702
+ type: 'void',
1703
+ 'x-decorator': 'FormItem',
1704
+ 'x-component': 'ArrayItems.SortHandle'
1705
+ },
1706
+ field: {
1707
+ type: 'string',
1708
+ enum: sortFields,
1709
+ required: true,
1710
+ 'x-decorator': 'FormItem',
1711
+ 'x-component': 'Select',
1712
+ 'x-component-props': {
1713
+ style: {
1714
+ width: 260
1715
+ }
1716
+ }
1717
+ },
1718
+ direction: {
1719
+ type: 'string',
1720
+ 'x-decorator': 'FormItem',
1721
+ 'x-component': 'Radio.Group',
1722
+ 'x-component-props': {
1723
+ optionType: 'button'
1724
+ },
1725
+ enum: [{
1726
+ label: t('ASC'),
1727
+ value: 'asc'
1728
+ }, {
1729
+ label: t('DESC'),
1730
+ value: 'desc'
1731
+ }]
1732
+ },
1733
+ remove: {
1734
+ type: 'void',
1735
+ 'x-decorator': 'FormItem',
1736
+ 'x-component': 'ArrayItems.Remove'
1737
+ }
1738
+ }
1739
+ }
1740
+ }
1741
+ },
1742
+ properties: {
1743
+ add: {
1744
+ type: 'void',
1745
+ title: t('Add sort field'),
1746
+ 'x-component': 'ArrayItems.Addition'
1747
+ }
1748
+ }
1749
+ }
1750
+ }
1751
+ },
1752
+ onSubmit: function onSubmit(_ref5) {
1753
+ var _props$onSubmitCallBa, _schema9;
1754
+ var sort = _ref5.sort;
1755
+ var sortArr = sort.map(function (item) {
1756
+ return item.direction === 'desc' ? "-".concat(item.field) : item.field;
1757
+ });
1758
+ _.set(field.componentProps, 'service.params.sort', sortArr);
1759
+ props === null || props === void 0 ? void 0 : (_props$onSubmitCallBa = props.onSubmitCallBack) === null || _props$onSubmitCallBa === void 0 ? void 0 : _props$onSubmitCallBa.call(props, sortArr);
1760
+ fieldSchema['x-component-props'] = field.componentProps;
1761
+ dn.emit('patch', {
1762
+ schema: (_schema9 = {}, _defineProperty(_schema9, 'x-uid', fieldSchema['x-uid']), _defineProperty(_schema9, 'x-component-props', field.componentProps), _schema9)
1763
+ });
1764
+ }
1765
+ });
1766
+ };
1654
1767
  // 是否显示默认值配置项
1655
1768
  export var isShowDefaultValue = function isShowDefaultValue(collectionField, getInterface) {
1656
- return !['o2o', 'oho', 'obo', 'o2m', 'attachment', 'expression'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) && !isSystemField(collectionField, getInterface);
1769
+ return !['o2o', 'oho', 'obo', 'o2m', 'attachment', 'expression', 'point', 'lineString', 'circle', 'polygon'].includes(collectionField === null || collectionField === void 0 ? void 0 : collectionField.interface) && !isSystemField(collectionField, getInterface);
1657
1770
  };
1658
1771
  // 是否是系统字段
1659
1772
  export var isSystemField = function isSystemField(collectionField, getInterface) {
@@ -1661,6 +1774,6 @@ export var isSystemField = function isSystemField(collectionField, getInterface)
1661
1774
  return (i === null || i === void 0 ? void 0 : i.group) === 'systemInfo';
1662
1775
  };
1663
1776
  export var isPatternDisabled = function isPatternDisabled(fieldSchema) {
1664
- var _fieldSchema$xCompon8;
1665
- return (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon8 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon8 === void 0 ? void 0 : _fieldSchema$xCompon8['pattern-disable']) == true;
1777
+ var _fieldSchema$xCompon11;
1778
+ return (fieldSchema === null || fieldSchema === void 0 ? void 0 : (_fieldSchema$xCompon11 = fieldSchema['x-component-props']) === null || _fieldSchema$xCompon11 === void 0 ? void 0 : _fieldSchema$xCompon11['pattern-disable']) == true;
1666
1779
  };
@@ -1,6 +1,6 @@
1
1
  import React, { useMemo } from 'react';
2
2
  import { useCompile, Variable } from '../../schema-component';
3
- import { useContextAssociationFields } from './hooks/useContextAssociationFields';
3
+ import { useContextAssociationFields, useIsSameOrChildCollection } from './hooks/useContextAssociationFields';
4
4
  import { useUserVariable } from './hooks/useUserVariable';
5
5
  export var VariableInput = function VariableInput(props) {
6
6
  var value = props.value,
@@ -19,8 +19,11 @@ export var VariableInput = function VariableInput(props) {
19
19
  var contextVariable = useContextAssociationFields({
20
20
  schema: schema,
21
21
  maxDepth: 2,
22
- contextCollectionName: contextCollectionName
22
+ contextCollectionName: contextCollectionName,
23
+ collectionField: collectionField
23
24
  });
25
+ var getIsSameOrChildCollection = useIsSameOrChildCollection();
26
+ var isAllowTableContext = getIsSameOrChildCollection(contextCollectionName, collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
24
27
  var scope = useMemo(function () {
25
28
  var data = [compile({
26
29
  label: "{{t(\"Date variables\")}}",
@@ -47,7 +50,7 @@ export var VariableInput = function VariableInput(props) {
47
50
  onChange: onChange,
48
51
  scope: scope,
49
52
  style: style,
50
- changeOnSelect: contextCollectionName !== null
53
+ changeOnSelect: isAllowTableContext
51
54
  }, /*#__PURE__*/React.createElement(RenderSchemaComponent, {
52
55
  value: value,
53
56
  onChange: onChange
@@ -1,6 +1,9 @@
1
+ import { CollectionFieldOptions } from '../../../collection-manager';
1
2
  import { Option } from '../type';
2
- export declare const useContextAssociationFields: ({ schema, maxDepth, contextCollectionName, }: {
3
+ export declare const useIsSameOrChildCollection: () => (contextCollection: any, targetCollection: any) => boolean;
4
+ export declare const useContextAssociationFields: ({ schema, maxDepth, contextCollectionName, collectionField, }: {
3
5
  schema: any;
4
6
  maxDepth?: number;
5
7
  contextCollectionName: string;
8
+ collectionField: CollectionFieldOptions;
6
9
  }) => Option;
@@ -1,21 +1,35 @@
1
1
  import { error } from '@nocobase/utils/client';
2
2
  import { useMemo } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
+ import { useCollectionManager } from '../../../collection-manager';
4
5
  import { useCompile, useGetFilterOptions } from '../../../schema-component';
5
- var getChildren = function getChildren(options, _ref) {
6
+ export var useIsSameOrChildCollection = function useIsSameOrChildCollection() {
7
+ var _useCollectionManager = useCollectionManager(),
8
+ getChildrenCollections = _useCollectionManager.getChildrenCollections;
9
+ return function (contextCollection, targetCollection) {
10
+ if (contextCollection === targetCollection) {
11
+ return true;
12
+ }
13
+ var childrens = getChildrenCollections(targetCollection);
14
+ return childrens === null || childrens === void 0 ? void 0 : childrens.some(function (v) {
15
+ return v.name === contextCollection;
16
+ });
17
+ };
18
+ };
19
+ var getChildren = function getChildren(options, _ref, collectionField, getIsSameOrChildCollection) {
6
20
  var schema = _ref.schema,
7
21
  depth = _ref.depth,
8
22
  maxDepth = _ref.maxDepth,
9
23
  loadChildren = _ref.loadChildren,
10
24
  compile = _ref.compile;
11
25
  var result = options.map(function (option) {
26
+ var disabled = !getIsSameOrChildCollection(option.target, collectionField === null || collectionField === void 0 ? void 0 : collectionField.target);
12
27
  if (!option.target) {
13
28
  return {
14
29
  key: option.name,
15
30
  value: option.name,
16
31
  label: compile(option.title),
17
- // TODO: 现在是通过组件的名称来过滤能够被选择的选项,这样的坏处是不够精确,后续可以优化
18
- // disabled: schema?.['x-component'] !== option.schema?.['x-component'],
32
+ disabled: disabled,
19
33
  isLeaf: true,
20
34
  depth: depth
21
35
  };
@@ -27,6 +41,7 @@ var getChildren = function getChildren(options, _ref) {
27
41
  key: option.name,
28
42
  value: option.name,
29
43
  label: compile(option.title),
44
+ disabled: disabled,
30
45
  isLeaf: true,
31
46
  field: option,
32
47
  depth: depth,
@@ -39,11 +54,13 @@ export var useContextAssociationFields = function useContextAssociationFields(_r
39
54
  var schema = _ref2.schema,
40
55
  _ref2$maxDepth = _ref2.maxDepth,
41
56
  maxDepth = _ref2$maxDepth === void 0 ? 3 : _ref2$maxDepth,
42
- contextCollectionName = _ref2.contextCollectionName;
57
+ contextCollectionName = _ref2.contextCollectionName,
58
+ collectionField = _ref2.collectionField;
43
59
  var _useTranslation = useTranslation(),
44
60
  t = _useTranslation.t;
45
61
  var compile = useCompile();
46
62
  var getFilterOptions = useGetFilterOptions();
63
+ var getIsSameOrChildCollection = useIsSameOrChildCollection();
47
64
  var loadChildren = function loadChildren(option) {
48
65
  var _option$field;
49
66
  if (!((_option$field = option.field) !== null && _option$field !== void 0 && _option$field.target)) {
@@ -65,7 +82,7 @@ export var useContextAssociationFields = function useContextAssociationFields(_r
65
82
  maxDepth: maxDepth,
66
83
  loadChildren: loadChildren,
67
84
  compile: compile
68
- }) || [];
85
+ }, collectionField, getIsSameOrChildCollection) || [];
69
86
  if (children.length === 0) {
70
87
  option.disabled = true;
71
88
  option.children = [];
@@ -24,6 +24,7 @@ import { cloneDeep } from 'lodash';
24
24
  import React, { createContext, useContext, useMemo } from 'react';
25
25
  import { useAPIClient, useRequest } from '../api-client';
26
26
  import { Plugin } from '../application/Plugin';
27
+ import { useCollectionManager } from '../collection-manager';
27
28
  import { BlockTemplate } from './BlockTemplate';
28
29
  export var SchemaTemplateManagerContext = /*#__PURE__*/createContext({});
29
30
  export var SchemaTemplateManagerProvider = function SchemaTemplateManagerProvider(props) {
@@ -55,6 +56,8 @@ export var useSchemaTemplate = function useSchemaTemplate() {
55
56
  }, [schemaId, templateKey]);
56
57
  };
57
58
  export var useSchemaTemplateManager = function useSchemaTemplateManager() {
59
+ var _useCollectionManager = useCollectionManager(),
60
+ getInheritCollections = _useCollectionManager.getInheritCollections;
58
61
  var _useContext = useContext(SchemaTemplateManagerContext),
59
62
  refresh = _useContext.refresh,
60
63
  _useContext$templates = _useContext.templates,
@@ -185,8 +188,10 @@ export var useSchemaTemplateManager = function useSchemaTemplateManager() {
185
188
  getTemplatesByCollection: function getTemplatesByCollection(collectionName) {
186
189
  var _templates$filter;
187
190
  var resourceName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
191
+ var parentCollections = getInheritCollections(collectionName);
192
+ var totalCollections = parentCollections.concat([collectionName]);
188
193
  var items = templates === null || templates === void 0 ? void 0 : (_templates$filter = templates.filter) === null || _templates$filter === void 0 ? void 0 : _templates$filter.call(templates, function (template) {
189
- return template.collectionName === collectionName;
194
+ return totalCollections.includes(template.collectionName);
190
195
  });
191
196
  return items || [];
192
197
  },
@@ -37,7 +37,7 @@ function useRequest(service) {
37
37
  var tempService;
38
38
  if (typeof service === 'function') {
39
39
  tempService = service;
40
- } else {
40
+ } else if (service) {
41
41
  tempService = /*#__PURE__*/function () {
42
42
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
43
43
  var params,
@@ -72,6 +72,21 @@ function useRequest(service) {
72
72
  return _ref.apply(this, arguments);
73
73
  };
74
74
  }();
75
+ } else {
76
+ tempService = /*#__PURE__*/function () {
77
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
78
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
79
+ while (1) switch (_context2.prev = _context2.next) {
80
+ case 0:
81
+ case "end":
82
+ return _context2.stop();
83
+ }
84
+ }, _callee2);
85
+ }));
86
+ return function tempService() {
87
+ return _ref2.apply(this, arguments);
88
+ };
89
+ }();
75
90
  }
76
91
  var tempOptions = _objectSpread(_objectSpread({}, options), {}, {
77
92
  onSuccess: function onSuccess() {
@@ -75,6 +75,8 @@ var useResource = function useResource(props) {
75
75
  var association = useAssociation(props);
76
76
  var sourceId = useSourceId === null || useSourceId === void 0 ? void 0 : useSourceId();
77
77
  var field = (0, _react.useField)();
78
+ var withoutTableFieldResource = (0, _react2.useContext)(_.WithoutTableFieldResource);
79
+ var __parent = (0, _react2.useContext)(BlockRequestContext);
78
80
  if (block === 'TableField') {
79
81
  var _record$__parent;
80
82
  var options = {
@@ -85,8 +87,6 @@ var useResource = function useResource(props) {
85
87
  };
86
88
  return new _.TableFieldResource(options);
87
89
  }
88
- var withoutTableFieldResource = (0, _react2.useContext)(_.WithoutTableFieldResource);
89
- var __parent = (0, _react2.useContext)(BlockRequestContext);
90
90
  if (!withoutTableFieldResource && (__parent === null || __parent === void 0 ? void 0 : __parent.block) === 'TableField' && (__parent === null || __parent === void 0 ? void 0 : __parent.resource) instanceof _.TableFieldResource) {
91
91
  return __parent.resource;
92
92
  }