@hanwenbo/x-web-pro-components 0.0.1
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.
- package/LICENSE +21 -0
- package/es/blocks/index.d.ts +1 -0
- package/es/blocks/index.js +2 -0
- package/es/blocks/shared.d.ts +24 -0
- package/es/blocks/shared.js +77 -0
- package/es/components/card/index.d.ts +82 -0
- package/es/components/card/index.js +361 -0
- package/es/components/descriptions/index.d.ts +31 -0
- package/es/components/descriptions/index.js +434 -0
- package/es/components/field/index.d.ts +75 -0
- package/es/components/field/index.js +761 -0
- package/es/components/form/captcha.d.ts +19 -0
- package/es/components/form/captcha.js +165 -0
- package/es/components/form/colorPicker.d.ts +7 -0
- package/es/components/form/colorPicker.js +73 -0
- package/es/components/form/fieldControls.d.ts +43 -0
- package/es/components/form/fieldControls.js +282 -0
- package/es/components/form/index.d.ts +285 -0
- package/es/components/form/index.js +2268 -0
- package/es/components/form/loginForm.d.ts +22 -0
- package/es/components/form/loginForm.js +159 -0
- package/es/components/form/schemaForm.d.ts +30 -0
- package/es/components/form/schemaForm.js +644 -0
- package/es/components/form/stepsForm.d.ts +26 -0
- package/es/components/form/stepsForm.js +183 -0
- package/es/components/form/uploadButton.d.ts +20 -0
- package/es/components/form/uploadButton.js +134 -0
- package/es/components/form/uploadDragger.d.ts +13 -0
- package/es/components/form/uploadDragger.js +144 -0
- package/es/components/index.d.ts +9 -0
- package/es/components/index.js +9 -0
- package/es/components/layout/components/Help/index.d.ts +72 -0
- package/es/components/layout/components/Help/index.js +350 -0
- package/es/components/layout/index.d.ts +182 -0
- package/es/components/layout/index.js +892 -0
- package/es/components/list/index.d.ts +80 -0
- package/es/components/list/index.js +431 -0
- package/es/components/provider/context.d.ts +7 -0
- package/es/components/provider/context.js +21 -0
- package/es/components/provider/index.d.ts +28 -0
- package/es/components/provider/index.js +117 -0
- package/es/components/provider/intl.d.ts +38 -0
- package/es/components/provider/intl.js +112 -0
- package/es/components/provider/types.d.ts +37 -0
- package/es/components/provider/types.js +1 -0
- package/es/components/provider/useStyle/index.d.ts +28 -0
- package/es/components/provider/useStyle/index.js +208 -0
- package/es/components/skeleton/index.d.ts +61 -0
- package/es/components/skeleton/index.js +388 -0
- package/es/components/table/dragSortTable.d.ts +8 -0
- package/es/components/table/dragSortTable.js +229 -0
- package/es/components/table/editableTable.d.ts +31 -0
- package/es/components/table/editableTable.js +507 -0
- package/es/components/table/index.d.ts +52 -0
- package/es/components/table/index.js +1554 -0
- package/es/components/table/listToolBar.d.ts +48 -0
- package/es/components/table/listToolBar.js +194 -0
- package/es/components/table/search.d.ts +5 -0
- package/es/components/table/search.js +13 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/types.d.ts +219 -0
- package/es/types.js +1 -0
- package/es/utils/attachPropertiesToComponent.d.ts +1 -0
- package/es/utils/attachPropertiesToComponent.js +6 -0
- package/es/utils/getRequestParams.d.ts +19 -0
- package/es/utils/getRequestParams.js +57 -0
- package/es/utils/getTableListColumns.d.ts +20 -0
- package/es/utils/getTableListColumns.js +36 -0
- package/es/utils/index.d.ts +4 -0
- package/es/utils/index.js +4 -0
- package/es/utils/loading.d.ts +3 -0
- package/es/utils/loading.js +25 -0
- package/es/version.d.ts +2 -0
- package/es/version.js +2 -0
- package/lib/blocks/index.d.ts +1 -0
- package/lib/blocks/index.js +5 -0
- package/lib/blocks/shared.d.ts +24 -0
- package/lib/blocks/shared.js +83 -0
- package/lib/components/card/index.d.ts +82 -0
- package/lib/components/card/index.js +368 -0
- package/lib/components/descriptions/index.d.ts +31 -0
- package/lib/components/descriptions/index.js +440 -0
- package/lib/components/field/index.d.ts +75 -0
- package/lib/components/field/index.js +767 -0
- package/lib/components/form/captcha.d.ts +19 -0
- package/lib/components/form/captcha.js +172 -0
- package/lib/components/form/colorPicker.d.ts +7 -0
- package/lib/components/form/colorPicker.js +79 -0
- package/lib/components/form/fieldControls.d.ts +43 -0
- package/lib/components/form/fieldControls.js +288 -0
- package/lib/components/form/index.d.ts +285 -0
- package/lib/components/form/index.js +2332 -0
- package/lib/components/form/loginForm.d.ts +22 -0
- package/lib/components/form/loginForm.js +165 -0
- package/lib/components/form/schemaForm.d.ts +30 -0
- package/lib/components/form/schemaForm.js +651 -0
- package/lib/components/form/stepsForm.d.ts +26 -0
- package/lib/components/form/stepsForm.js +189 -0
- package/lib/components/form/uploadButton.d.ts +20 -0
- package/lib/components/form/uploadButton.js +141 -0
- package/lib/components/form/uploadDragger.d.ts +13 -0
- package/lib/components/form/uploadDragger.js +151 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +104 -0
- package/lib/components/layout/components/Help/index.d.ts +72 -0
- package/lib/components/layout/components/Help/index.js +356 -0
- package/lib/components/layout/index.d.ts +182 -0
- package/lib/components/layout/index.js +930 -0
- package/lib/components/list/index.d.ts +80 -0
- package/lib/components/list/index.js +438 -0
- package/lib/components/provider/context.d.ts +7 -0
- package/lib/components/provider/context.js +27 -0
- package/lib/components/provider/index.d.ts +28 -0
- package/lib/components/provider/index.js +174 -0
- package/lib/components/provider/intl.d.ts +38 -0
- package/lib/components/provider/intl.js +118 -0
- package/lib/components/provider/types.d.ts +37 -0
- package/lib/components/provider/types.js +5 -0
- package/lib/components/provider/useStyle/index.d.ts +28 -0
- package/lib/components/provider/useStyle/index.js +217 -0
- package/lib/components/skeleton/index.d.ts +61 -0
- package/lib/components/skeleton/index.js +394 -0
- package/lib/components/table/dragSortTable.d.ts +8 -0
- package/lib/components/table/dragSortTable.js +236 -0
- package/lib/components/table/editableTable.d.ts +31 -0
- package/lib/components/table/editableTable.js +514 -0
- package/lib/components/table/index.d.ts +52 -0
- package/lib/components/table/index.js +1699 -0
- package/lib/components/table/listToolBar.d.ts +48 -0
- package/lib/components/table/listToolBar.js +200 -0
- package/lib/components/table/search.d.ts +5 -0
- package/lib/components/table/search.js +20 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +49 -0
- package/lib/types.d.ts +219 -0
- package/lib/types.js +5 -0
- package/lib/utils/attachPropertiesToComponent.d.ts +1 -0
- package/lib/utils/attachPropertiesToComponent.js +12 -0
- package/lib/utils/getRequestParams.d.ts +19 -0
- package/lib/utils/getRequestParams.js +63 -0
- package/lib/utils/getTableListColumns.d.ts +20 -0
- package/lib/utils/getTableListColumns.js +42 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +49 -0
- package/lib/utils/loading.d.ts +3 -0
- package/lib/utils/loading.js +31 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.js +8 -0
- package/package.json +68 -0
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SchemaForm = exports.BetaSchemaForm = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _button = require("@hanwenbo/x-web-ui/button");
|
|
9
|
+
var _card = require("@hanwenbo/x-web-ui/card");
|
|
10
|
+
var _divider = require("@hanwenbo/x-web-ui/divider");
|
|
11
|
+
var _form = require("@hanwenbo/x-web-ui/form");
|
|
12
|
+
var _index = require("./index");
|
|
13
|
+
var _field = require("../field");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
var _excluded = ["columns", "layoutType", "form", "formRef", "shouldUpdate", "steps", "onValuesChange", "onFinish", "initialValues"];
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
19
|
+
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); } }
|
|
20
|
+
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); }); }; }
|
|
21
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
22
|
+
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."); }
|
|
23
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
24
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
+
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; }
|
|
26
|
+
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; }
|
|
27
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
28
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
+
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; }
|
|
31
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
32
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
34
|
+
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."); }
|
|
35
|
+
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); }
|
|
36
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
37
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
38
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
39
|
+
var WIDTH_CLASS_MAP = {
|
|
40
|
+
xs: 'w-[104px]',
|
|
41
|
+
sm: 'w-[216px]',
|
|
42
|
+
md: 'w-[328px]',
|
|
43
|
+
lg: 'w-[440px]',
|
|
44
|
+
xl: 'w-[552px]'
|
|
45
|
+
};
|
|
46
|
+
var OVERLAY_ADAPTIVE_LAYOUTS = new Set(['ModalForm', 'DrawerForm']);
|
|
47
|
+
var OVERLAY_FULL_ROW_TYPES = new Set(['textarea', 'divider', 'dependency', 'group', 'formSet', 'formList', 'digitRange', 'dateRange', 'dateMonthRange', 'dateWeekRange', 'dateQuarterRange', 'dateTimeRange', 'dateYearRange', 'timeRange', 'upload', 'uploadButton', 'uploadDragger', 'fieldSet']);
|
|
48
|
+
var DEFAULT_LIST_ITEM = '列表项';
|
|
49
|
+
var DEFAULT_GROUP_TITLE = '字段分组';
|
|
50
|
+
var DEFAULT_FORM_SET_TITLE = '字段集合';
|
|
51
|
+
var isColumnMatrix = function isColumnMatrix(columns) {
|
|
52
|
+
return Array.isArray(columns[0]);
|
|
53
|
+
};
|
|
54
|
+
var toNamePathArray = function toNamePathArray(name) {
|
|
55
|
+
if (name === undefined || name === null) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
return Array.isArray(name) ? _toConsumableArray(name) : [name];
|
|
59
|
+
};
|
|
60
|
+
var combineNamePath = function combineNamePath(prefix, name) {
|
|
61
|
+
if (prefix === undefined || prefix === null) {
|
|
62
|
+
return name;
|
|
63
|
+
}
|
|
64
|
+
return [].concat(_toConsumableArray(toNamePathArray(prefix)), _toConsumableArray(toNamePathArray(name)));
|
|
65
|
+
};
|
|
66
|
+
var getValueByNamePath = function getValueByNamePath(source, name) {
|
|
67
|
+
return toNamePathArray(name).reduce(function (current, key) {
|
|
68
|
+
return current == null ? current : current[key];
|
|
69
|
+
}, source);
|
|
70
|
+
};
|
|
71
|
+
var setValueByNamePath = function setValueByNamePath(source, name, value) {
|
|
72
|
+
var path = toNamePathArray(name);
|
|
73
|
+
if (!path.length) {
|
|
74
|
+
return source;
|
|
75
|
+
}
|
|
76
|
+
var nextSource = Array.isArray(source) ? _toConsumableArray(source) : _objectSpread({}, source);
|
|
77
|
+
var cursor = nextSource;
|
|
78
|
+
path.forEach(function (segment, index) {
|
|
79
|
+
if (index === path.length - 1) {
|
|
80
|
+
cursor[segment] = value;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
var nextValue = cursor[segment];
|
|
84
|
+
var clonedValue = Array.isArray(nextValue) ? _toConsumableArray(nextValue) : nextValue && _typeof(nextValue) === 'object' ? _objectSpread({}, nextValue) : typeof path[index + 1] === 'number' ? [] : {};
|
|
85
|
+
cursor[segment] = clonedValue;
|
|
86
|
+
cursor = clonedValue;
|
|
87
|
+
});
|
|
88
|
+
return nextSource;
|
|
89
|
+
};
|
|
90
|
+
var mergeObjects = function mergeObjects(source, patch) {
|
|
91
|
+
if (!patch || _typeof(patch) !== 'object' || Array.isArray(patch)) {
|
|
92
|
+
return source;
|
|
93
|
+
}
|
|
94
|
+
return _objectSpread(_objectSpread({}, source), patch);
|
|
95
|
+
};
|
|
96
|
+
var mergeFieldWidth = function mergeFieldWidth(fieldProps, width) {
|
|
97
|
+
if (!width) {
|
|
98
|
+
return fieldProps;
|
|
99
|
+
}
|
|
100
|
+
var widthClass = typeof width === 'number' ? undefined : WIDTH_CLASS_MAP[String(width)];
|
|
101
|
+
return _objectSpread(_objectSpread({}, fieldProps), {}, {
|
|
102
|
+
style: typeof width === 'number' ? _objectSpread({
|
|
103
|
+
width: width
|
|
104
|
+
}, (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.style) || {}) : fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.style,
|
|
105
|
+
className: [widthClass, fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.className].filter(Boolean).join(' ')
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
var shouldOverlayTakeFullRow = function shouldOverlayTakeFullRow(columnItem, layoutType) {
|
|
109
|
+
if (!OVERLAY_ADAPTIVE_LAYOUTS.has(String(layoutType))) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (Number(columnItem.colSize || 1) > 1) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return OVERLAY_FULL_ROW_TYPES.has(String(columnItem.valueType || 'text'));
|
|
116
|
+
};
|
|
117
|
+
var runMaybeFunction = function runMaybeFunction(value) {
|
|
118
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
119
|
+
args[_key - 1] = arguments[_key];
|
|
120
|
+
}
|
|
121
|
+
if (typeof value === 'function') {
|
|
122
|
+
return value.apply(void 0, args);
|
|
123
|
+
}
|
|
124
|
+
return value;
|
|
125
|
+
};
|
|
126
|
+
var getSchemaFieldKey = function getSchemaFieldKey(columnItem, index, prefix) {
|
|
127
|
+
var _columnItem$name;
|
|
128
|
+
if (columnItem.valueType === 'dependency' || columnItem.valueType === 'divider') {
|
|
129
|
+
return "schema-".concat(String(columnItem.valueType), "-").concat(index);
|
|
130
|
+
}
|
|
131
|
+
if (columnItem.key !== undefined && columnItem.key !== null) {
|
|
132
|
+
return String(columnItem.key);
|
|
133
|
+
}
|
|
134
|
+
var name = (_columnItem$name = columnItem.name) !== null && _columnItem$name !== void 0 ? _columnItem$name : columnItem.dataIndex;
|
|
135
|
+
if (name !== undefined) {
|
|
136
|
+
return [].concat(_toConsumableArray(toNamePathArray(prefix)), _toConsumableArray(toNamePathArray(name))).join('.');
|
|
137
|
+
}
|
|
138
|
+
return "schema-field-".concat(index);
|
|
139
|
+
};
|
|
140
|
+
var getSchemaFieldName = function getSchemaFieldName(columnItem) {
|
|
141
|
+
if (columnItem.name !== undefined) {
|
|
142
|
+
return columnItem.name;
|
|
143
|
+
}
|
|
144
|
+
if (columnItem.dataIndex !== undefined) {
|
|
145
|
+
return columnItem.dataIndex;
|
|
146
|
+
}
|
|
147
|
+
if (columnItem.key !== undefined) {
|
|
148
|
+
return String(columnItem.key);
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
};
|
|
152
|
+
var getSchemaTitle = function getSchemaTitle(columnItem, fallback) {
|
|
153
|
+
var _columnItem$title;
|
|
154
|
+
if (typeof columnItem.title === 'function') {
|
|
155
|
+
try {
|
|
156
|
+
return columnItem.title({});
|
|
157
|
+
} catch (_unused) {
|
|
158
|
+
return fallback;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return (_columnItem$title = columnItem.title) !== null && _columnItem$title !== void 0 ? _columnItem$title : fallback;
|
|
162
|
+
};
|
|
163
|
+
var getResolvedColumns = function getResolvedColumns(columns, values) {
|
|
164
|
+
var nextColumns = runMaybeFunction(columns, values);
|
|
165
|
+
if (!Array.isArray(nextColumns)) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
return nextColumns;
|
|
169
|
+
};
|
|
170
|
+
var resolveDependencyNames = function resolveDependencyNames(name) {
|
|
171
|
+
if (name === undefined || name === null) {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
if (!Array.isArray(name)) {
|
|
175
|
+
return [name];
|
|
176
|
+
}
|
|
177
|
+
if (!name.length) {
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
if (typeof name[0] === 'string' || typeof name[0] === 'number') {
|
|
181
|
+
return name;
|
|
182
|
+
}
|
|
183
|
+
return name;
|
|
184
|
+
};
|
|
185
|
+
var sortSchemaColumns = function sortSchemaColumns(columns) {
|
|
186
|
+
return _toConsumableArray(columns).sort(function (a, b) {
|
|
187
|
+
if (a.order || b.order) {
|
|
188
|
+
return (b.order || 0) - (a.order || 0);
|
|
189
|
+
}
|
|
190
|
+
return 0;
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
var isSearchLayout = function isSearchLayout(layoutType) {
|
|
194
|
+
return layoutType === 'QueryFilter' || layoutType === 'LightFilter';
|
|
195
|
+
};
|
|
196
|
+
var getSearchInitialValueSnapshotKey = function getSearchInitialValueSnapshotKey(name) {
|
|
197
|
+
return JSON.stringify(toNamePathArray(name));
|
|
198
|
+
};
|
|
199
|
+
var getSchemaColumnInitialValue = function getSchemaColumnInitialValue(columnItem, layoutType, searchInitialValueSnapshot, name) {
|
|
200
|
+
if (!isSearchLayout(layoutType)) {
|
|
201
|
+
return columnItem.initialValue;
|
|
202
|
+
}
|
|
203
|
+
if (!searchInitialValueSnapshot || name === undefined) {
|
|
204
|
+
return columnItem.searchInitialValue;
|
|
205
|
+
}
|
|
206
|
+
var snapshotKey = getSearchInitialValueSnapshotKey(name);
|
|
207
|
+
if (!searchInitialValueSnapshot.has(snapshotKey)) {
|
|
208
|
+
searchInitialValueSnapshot.set(snapshotKey, columnItem.searchInitialValue);
|
|
209
|
+
}
|
|
210
|
+
return searchInitialValueSnapshot.get(snapshotKey);
|
|
211
|
+
};
|
|
212
|
+
var getConvertedInitialValue = function getConvertedInitialValue(columnItem, name, initialValue) {
|
|
213
|
+
if (initialValue === undefined || !columnItem.convertValue) {
|
|
214
|
+
return initialValue;
|
|
215
|
+
}
|
|
216
|
+
return columnItem.convertValue(initialValue, name, _defineProperty({}, toNamePathArray(name).join('.'), initialValue));
|
|
217
|
+
};
|
|
218
|
+
var applySchemaConvertValues = function applySchemaConvertValues(values, columns) {
|
|
219
|
+
var normalizedColumns = isColumnMatrix(columns) ? columns.flat() : columns;
|
|
220
|
+
var nextValues = Array.isArray(values) ? _toConsumableArray(values) : _objectSpread({}, values);
|
|
221
|
+
var walk = function walk(items, prefix) {
|
|
222
|
+
items.forEach(function (columnItem) {
|
|
223
|
+
var valueType = String(columnItem.valueType || 'text');
|
|
224
|
+
var name = getSchemaFieldName(columnItem);
|
|
225
|
+
var fullName = name !== undefined ? combineNamePath(prefix, name) : prefix;
|
|
226
|
+
var nestedColumns = getResolvedColumns(columnItem.columns, nextValues);
|
|
227
|
+
if (valueType === 'dependency' || valueType === 'group') {
|
|
228
|
+
if (nestedColumns.length) {
|
|
229
|
+
walk(nestedColumns, prefix);
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (valueType === 'formSet') {
|
|
234
|
+
if (nestedColumns.length && fullName !== undefined) {
|
|
235
|
+
walk(nestedColumns, fullName);
|
|
236
|
+
}
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (valueType === 'formList') {
|
|
240
|
+
if (nestedColumns.length && fullName !== undefined) {
|
|
241
|
+
var currentList = getValueByNamePath(nextValues, fullName);
|
|
242
|
+
if (Array.isArray(currentList)) {
|
|
243
|
+
currentList.forEach(function (_, listIndex) {
|
|
244
|
+
walk(nestedColumns, combineNamePath(fullName, listIndex));
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (fullName === undefined || !columnItem.convertValue) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
var rawValue = getValueByNamePath(nextValues, fullName);
|
|
254
|
+
if (rawValue === undefined) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
nextValues = setValueByNamePath(nextValues, fullName, columnItem.convertValue(rawValue, fullName, nextValues));
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
walk(normalizedColumns);
|
|
261
|
+
return nextValues;
|
|
262
|
+
};
|
|
263
|
+
var applySchemaTransforms = function applySchemaTransforms(values, columns) {
|
|
264
|
+
var normalizedColumns = isColumnMatrix(columns) ? columns.flat() : columns;
|
|
265
|
+
var nextValues = Array.isArray(values) ? _toConsumableArray(values) : _objectSpread({}, values);
|
|
266
|
+
var walk = function walk(items, prefix) {
|
|
267
|
+
items.forEach(function (columnItem) {
|
|
268
|
+
var valueType = String(columnItem.valueType || 'text');
|
|
269
|
+
var name = getSchemaFieldName(columnItem);
|
|
270
|
+
var fullName = name !== undefined ? combineNamePath(prefix, name) : prefix;
|
|
271
|
+
var nestedColumns = getResolvedColumns(columnItem.columns, nextValues);
|
|
272
|
+
if (valueType === 'dependency') {
|
|
273
|
+
if (nestedColumns.length) {
|
|
274
|
+
walk(nestedColumns, prefix);
|
|
275
|
+
}
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (valueType === 'group') {
|
|
279
|
+
if (nestedColumns.length) {
|
|
280
|
+
walk(nestedColumns, prefix);
|
|
281
|
+
}
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (valueType === 'formSet') {
|
|
285
|
+
if (nestedColumns.length && fullName !== undefined) {
|
|
286
|
+
walk(nestedColumns, fullName);
|
|
287
|
+
}
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (valueType === 'formList') {
|
|
291
|
+
if (nestedColumns.length && fullName !== undefined) {
|
|
292
|
+
var currentList = getValueByNamePath(nextValues, fullName);
|
|
293
|
+
if (Array.isArray(currentList)) {
|
|
294
|
+
currentList.forEach(function (_, listIndex) {
|
|
295
|
+
walk(nestedColumns, combineNamePath(fullName, listIndex));
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (columnItem.transform && fullName !== undefined) {
|
|
302
|
+
var rawValue = getValueByNamePath(nextValues, fullName);
|
|
303
|
+
var transformedValue = columnItem.transform(rawValue, fullName, nextValues);
|
|
304
|
+
if (transformedValue && _typeof(transformedValue) === 'object' && !Array.isArray(transformedValue)) {
|
|
305
|
+
nextValues = mergeObjects(nextValues, transformedValue);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (transformedValue !== undefined) {
|
|
309
|
+
nextValues = setValueByNamePath(nextValues, fullName, transformedValue);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
walk(normalizedColumns);
|
|
315
|
+
return nextValues;
|
|
316
|
+
};
|
|
317
|
+
var resolveSearchFieldValueType = function resolveSearchFieldValueType(valueType, layoutType) {
|
|
318
|
+
var normalizedValueType = String(valueType || 'text');
|
|
319
|
+
if ((layoutType === 'QueryFilter' || layoutType === 'LightFilter') && normalizedValueType === 'textarea') {
|
|
320
|
+
return 'text';
|
|
321
|
+
}
|
|
322
|
+
return normalizedValueType;
|
|
323
|
+
};
|
|
324
|
+
var renderSchemaFieldControl = function renderSchemaFieldControl(columnItem, form, fieldProps, layoutType) {
|
|
325
|
+
var customRenderer = columnItem.formItemRender || columnItem.renderFormItem;
|
|
326
|
+
if (customRenderer) {
|
|
327
|
+
return customRenderer(columnItem, {
|
|
328
|
+
type: 'form'
|
|
329
|
+
}, form);
|
|
330
|
+
}
|
|
331
|
+
var effectiveValueType = resolveSearchFieldValueType(columnItem.valueType, layoutType);
|
|
332
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_field.ProField, {
|
|
333
|
+
mode: columnItem.readonly ? 'read' : 'edit',
|
|
334
|
+
valueType: effectiveValueType,
|
|
335
|
+
valueEnum: columnItem.valueEnum,
|
|
336
|
+
fieldProps: fieldProps,
|
|
337
|
+
placeholder: fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.placeholder
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
var renderSchemaColumns = function renderSchemaColumns(columns, form, currentValues, prefix, layoutType, searchInitialValueSnapshot) {
|
|
341
|
+
return sortSchemaColumns(columns).map(function (columnItem, index) {
|
|
342
|
+
var key = getSchemaFieldKey(columnItem, index, prefix);
|
|
343
|
+
var dependencyNames = columnItem.dependencies || [];
|
|
344
|
+
var renderColumnNode = function renderColumnNode(currentForm, nextValues) {
|
|
345
|
+
var values = nextValues;
|
|
346
|
+
var valueType = String(columnItem.valueType || 'text');
|
|
347
|
+
var titleNode = getSchemaTitle(columnItem);
|
|
348
|
+
var name = getSchemaFieldName(columnItem);
|
|
349
|
+
var fullName = name !== undefined ? combineNamePath(prefix, name) : undefined;
|
|
350
|
+
var nestedColumns = getResolvedColumns(columnItem.columns, values);
|
|
351
|
+
var rawFieldProps = runMaybeFunction(columnItem.fieldProps, currentForm, columnItem) || {};
|
|
352
|
+
var formItemProps = runMaybeFunction(columnItem.formItemProps, currentForm, columnItem) || {};
|
|
353
|
+
var fieldProps = mergeFieldWidth(rawFieldProps, columnItem.width);
|
|
354
|
+
var fullRowClassName = shouldOverlayTakeFullRow(columnItem, layoutType) ? 'w-full basis-full' : undefined;
|
|
355
|
+
var isQueryForm = isSearchLayout(layoutType);
|
|
356
|
+
if (valueType === 'option' || isQueryForm && (columnItem.hideInSearch || columnItem.search === false) || !isQueryForm && columnItem.hideInForm) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
if (valueType === 'divider') {
|
|
360
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
361
|
+
className: fullRowClassName,
|
|
362
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_divider.Divider, {
|
|
363
|
+
children: titleNode
|
|
364
|
+
})
|
|
365
|
+
}, key);
|
|
366
|
+
}
|
|
367
|
+
if (valueType === 'dependency') {
|
|
368
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
369
|
+
className: fullRowClassName,
|
|
370
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ProFormDependency, {
|
|
371
|
+
name: resolveDependencyNames(columnItem.name),
|
|
372
|
+
children: function children(dependencyValues) {
|
|
373
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
374
|
+
className: "w-full basis-full space-y-4",
|
|
375
|
+
children: renderSchemaColumns(getResolvedColumns(columnItem.columns, dependencyValues), currentForm, dependencyValues, prefix, layoutType, searchInitialValueSnapshot)
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
})
|
|
379
|
+
}, key);
|
|
380
|
+
}
|
|
381
|
+
if (valueType === 'group') {
|
|
382
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
383
|
+
className: [fullRowClassName, 'space-y-3'].filter(Boolean).join(' '),
|
|
384
|
+
children: [titleNode ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
385
|
+
className: "text-sm font-medium text-foreground",
|
|
386
|
+
children: titleNode
|
|
387
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ProFormGroup, {
|
|
388
|
+
className: "gap-4",
|
|
389
|
+
children: renderSchemaColumns(nestedColumns, currentForm, values, prefix, layoutType, searchInitialValueSnapshot)
|
|
390
|
+
})]
|
|
391
|
+
}, key);
|
|
392
|
+
}
|
|
393
|
+
if (valueType === 'formSet') {
|
|
394
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
395
|
+
className: [fullRowClassName, 'space-y-3'].filter(Boolean).join(' '),
|
|
396
|
+
children: [titleNode ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
397
|
+
className: "text-sm font-medium text-foreground",
|
|
398
|
+
children: titleNode
|
|
399
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
400
|
+
className: "text-sm font-medium text-foreground",
|
|
401
|
+
children: DEFAULT_FORM_SET_TITLE
|
|
402
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
403
|
+
className: "rounded-2xl border border-border bg-card p-4",
|
|
404
|
+
children: renderSchemaColumns(nestedColumns, currentForm, values, fullName, layoutType, searchInitialValueSnapshot)
|
|
405
|
+
})]
|
|
406
|
+
}, key);
|
|
407
|
+
}
|
|
408
|
+
if (valueType === 'formList' && fullName !== undefined) {
|
|
409
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
410
|
+
className: [fullRowClassName, 'space-y-3 rounded-2xl border border-border bg-card p-4'].filter(Boolean).join(' '),
|
|
411
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
412
|
+
className: "flex items-center justify-between gap-3",
|
|
413
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
414
|
+
className: "text-sm font-medium text-foreground",
|
|
415
|
+
children: titleNode || DEFAULT_LIST_ITEM
|
|
416
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
417
|
+
size: "small",
|
|
418
|
+
type: "button",
|
|
419
|
+
onClick: function onClick() {
|
|
420
|
+
var nextList = currentForm.getFieldValue(fullName) || [];
|
|
421
|
+
currentForm.setFieldValue(fullName, nextList.concat([{}]));
|
|
422
|
+
},
|
|
423
|
+
children: "\u65B0\u589E\u4E00\u9879"
|
|
424
|
+
})]
|
|
425
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_form.Form.List, {
|
|
426
|
+
name: fullName,
|
|
427
|
+
initialValue: getSchemaColumnInitialValue(columnItem, layoutType, searchInitialValueSnapshot, fullName),
|
|
428
|
+
rules: formItemProps.rules,
|
|
429
|
+
children: function children(fields, operation, meta) {
|
|
430
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
431
|
+
className: "space-y-3",
|
|
432
|
+
children: [fields.map(function (field, listIndex) {
|
|
433
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_card.Card, {
|
|
434
|
+
className: "rounded-2xl border border-border bg-background shadow-none",
|
|
435
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
436
|
+
className: "mb-4 flex items-center justify-between gap-3",
|
|
437
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
438
|
+
className: "text-sm font-medium text-foreground",
|
|
439
|
+
children: [titleNode || DEFAULT_LIST_ITEM, " ", listIndex + 1]
|
|
440
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
|
|
441
|
+
size: "small",
|
|
442
|
+
variant: "outline",
|
|
443
|
+
type: "button",
|
|
444
|
+
onClick: function onClick() {
|
|
445
|
+
operation.remove(field.name);
|
|
446
|
+
},
|
|
447
|
+
children: "\u5220\u9664"
|
|
448
|
+
})]
|
|
449
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
450
|
+
className: "space-y-4",
|
|
451
|
+
children: renderSchemaColumns(nestedColumns, currentForm, values, field.name, layoutType, searchInitialValueSnapshot)
|
|
452
|
+
})]
|
|
453
|
+
}, field.key);
|
|
454
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_form.Form.ErrorList, {
|
|
455
|
+
errors: meta.errors,
|
|
456
|
+
warnings: meta.warnings
|
|
457
|
+
})]
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
})]
|
|
461
|
+
}, key);
|
|
462
|
+
}
|
|
463
|
+
if (fullName === undefined) {
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
var schemaControl = renderSchemaFieldControl(columnItem, currentForm, fieldProps, layoutType);
|
|
467
|
+
var labelNode = titleNode !== null && titleNode !== void 0 ? titleNode : key;
|
|
468
|
+
var searchSafeFormItemProps = _objectSpread({}, formItemProps);
|
|
469
|
+
delete searchSafeFormItemProps.initialValue;
|
|
470
|
+
var mergedFormItemProps = _objectSpread(_objectSpread({
|
|
471
|
+
name: fullName,
|
|
472
|
+
label: labelNode,
|
|
473
|
+
initialValue: getConvertedInitialValue(columnItem, fullName, getSchemaColumnInitialValue(columnItem, layoutType, searchInitialValueSnapshot, fullName)),
|
|
474
|
+
tooltip: columnItem.tooltip
|
|
475
|
+
}, isQueryForm ? searchSafeFormItemProps : formItemProps), {}, {
|
|
476
|
+
rootClassName: [formItemProps.rootClassName, fullRowClassName].filter(Boolean).join(' ')
|
|
477
|
+
});
|
|
478
|
+
if (columnItem.ignoreFormItem) {
|
|
479
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
480
|
+
className: [fullRowClassName, 'space-y-2'].filter(Boolean).join(' '),
|
|
481
|
+
children: [labelNode ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
482
|
+
className: "text-sm font-medium text-foreground",
|
|
483
|
+
children: labelNode
|
|
484
|
+
}) : null, schemaControl]
|
|
485
|
+
}, key);
|
|
486
|
+
}
|
|
487
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
488
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_form.Form.Item, _objectSpread(_objectSpread({}, mergedFormItemProps), {}, {
|
|
489
|
+
children: schemaControl
|
|
490
|
+
}))
|
|
491
|
+
}, key);
|
|
492
|
+
};
|
|
493
|
+
if (dependencyNames.length > 0) {
|
|
494
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ProFormDependency, {
|
|
495
|
+
name: dependencyNames,
|
|
496
|
+
children: function children(dependencyValues, dependencyForm) {
|
|
497
|
+
return renderColumnNode(dependencyForm, dependencyValues);
|
|
498
|
+
}
|
|
499
|
+
}, key);
|
|
500
|
+
}
|
|
501
|
+
return renderColumnNode(form, currentValues);
|
|
502
|
+
}).filter(Boolean);
|
|
503
|
+
};
|
|
504
|
+
var BetaSchemaForm = exports.BetaSchemaForm = function BetaSchemaForm(_ref) {
|
|
505
|
+
var columns = _ref.columns,
|
|
506
|
+
_ref$layoutType = _ref.layoutType,
|
|
507
|
+
layoutType = _ref$layoutType === void 0 ? 'Form' : _ref$layoutType,
|
|
508
|
+
controlledForm = _ref.form,
|
|
509
|
+
formRef = _ref.formRef,
|
|
510
|
+
_ref$shouldUpdate = _ref.shouldUpdate,
|
|
511
|
+
shouldUpdate = _ref$shouldUpdate === void 0 ? true : _ref$shouldUpdate,
|
|
512
|
+
steps = _ref.steps,
|
|
513
|
+
onValuesChange = _ref.onValuesChange,
|
|
514
|
+
onFinish = _ref.onFinish,
|
|
515
|
+
initialValues = _ref.initialValues,
|
|
516
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
517
|
+
var _useForm = (0, _form.useForm)(controlledForm),
|
|
518
|
+
_useForm2 = _slicedToArray(_useForm, 1),
|
|
519
|
+
form = _useForm2[0];
|
|
520
|
+
var resolvedInitialValues = (0, _react.useMemo)(function () {
|
|
521
|
+
return applySchemaConvertValues(initialValues || {}, columns);
|
|
522
|
+
}, [columns, initialValues]);
|
|
523
|
+
var _useState = (0, _react.useState)(function () {
|
|
524
|
+
return resolvedInitialValues;
|
|
525
|
+
}),
|
|
526
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
527
|
+
schemaValues = _useState2[0],
|
|
528
|
+
setSchemaValues = _useState2[1];
|
|
529
|
+
var _useState3 = (0, _react.useState)(0),
|
|
530
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
531
|
+
schemaTick = _useState4[0],
|
|
532
|
+
setSchemaTick = _useState4[1];
|
|
533
|
+
var oldValuesRef = (0, _react.useRef)(undefined);
|
|
534
|
+
var searchInitialValueSnapshotRef = (0, _react.useRef)(undefined);
|
|
535
|
+
if (!searchInitialValueSnapshotRef.current) {
|
|
536
|
+
searchInitialValueSnapshotRef.current = new Map();
|
|
537
|
+
}
|
|
538
|
+
var searchInitialValueSnapshot = isSearchLayout(layoutType) ? searchInitialValueSnapshotRef.current : undefined;
|
|
539
|
+
(0, _react.useEffect)(function () {
|
|
540
|
+
if (formRef) {
|
|
541
|
+
formRef.current = form;
|
|
542
|
+
}
|
|
543
|
+
}, [form, formRef]);
|
|
544
|
+
(0, _react.useEffect)(function () {
|
|
545
|
+
setSchemaValues(resolvedInitialValues);
|
|
546
|
+
}, [resolvedInitialValues]);
|
|
547
|
+
var fields = (0, _react.useMemo)(function () {
|
|
548
|
+
if (isColumnMatrix(columns)) {
|
|
549
|
+
return [];
|
|
550
|
+
}
|
|
551
|
+
return renderSchemaColumns(columns, form, schemaValues, undefined, layoutType, searchInitialValueSnapshot);
|
|
552
|
+
}, [columns, form, layoutType, schemaTick, schemaValues, searchInitialValueSnapshot]);
|
|
553
|
+
var stepFields = (0, _react.useMemo)(function () {
|
|
554
|
+
if (!isColumnMatrix(columns)) {
|
|
555
|
+
return [];
|
|
556
|
+
}
|
|
557
|
+
return columns.map(function (stepColumns) {
|
|
558
|
+
return renderSchemaColumns(stepColumns, form, schemaValues, undefined, layoutType, searchInitialValueSnapshot);
|
|
559
|
+
});
|
|
560
|
+
}, [columns, form, layoutType, schemaTick, schemaValues, searchInitialValueSnapshot]);
|
|
561
|
+
var handleValuesChange = function handleValuesChange(changedValues, values) {
|
|
562
|
+
setSchemaValues(values);
|
|
563
|
+
var shouldRefresh = shouldUpdate === true || typeof shouldUpdate === 'function' && shouldUpdate(values, oldValuesRef.current);
|
|
564
|
+
oldValuesRef.current = values;
|
|
565
|
+
if (shouldRefresh) {
|
|
566
|
+
setSchemaTick(function (value) {
|
|
567
|
+
return value + 1;
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
onValuesChange === null || onValuesChange === void 0 || onValuesChange(changedValues, values);
|
|
571
|
+
};
|
|
572
|
+
var handleFinish = /*#__PURE__*/function () {
|
|
573
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values) {
|
|
574
|
+
var transformedValues;
|
|
575
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
576
|
+
while (1) switch (_context.prev = _context.next) {
|
|
577
|
+
case 0:
|
|
578
|
+
transformedValues = applySchemaTransforms(values, columns);
|
|
579
|
+
return _context.abrupt("return", onFinish === null || onFinish === void 0 ? void 0 : onFinish(transformedValues));
|
|
580
|
+
case 2:
|
|
581
|
+
case "end":
|
|
582
|
+
return _context.stop();
|
|
583
|
+
}
|
|
584
|
+
}, _callee);
|
|
585
|
+
}));
|
|
586
|
+
return function handleFinish(_x) {
|
|
587
|
+
return _ref2.apply(this, arguments);
|
|
588
|
+
};
|
|
589
|
+
}();
|
|
590
|
+
if (layoutType === 'ModalForm') {
|
|
591
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ModalForm, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
592
|
+
form: form,
|
|
593
|
+
initialValues: resolvedInitialValues,
|
|
594
|
+
onValuesChange: handleValuesChange,
|
|
595
|
+
onFinish: handleFinish,
|
|
596
|
+
children: fields
|
|
597
|
+
}));
|
|
598
|
+
}
|
|
599
|
+
if (layoutType === 'DrawerForm') {
|
|
600
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.DrawerForm, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
601
|
+
form: form,
|
|
602
|
+
initialValues: resolvedInitialValues,
|
|
603
|
+
onValuesChange: handleValuesChange,
|
|
604
|
+
onFinish: handleFinish,
|
|
605
|
+
children: fields
|
|
606
|
+
}));
|
|
607
|
+
}
|
|
608
|
+
if (layoutType === 'QueryFilter') {
|
|
609
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.QueryFilter, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
610
|
+
form: form,
|
|
611
|
+
initialValues: resolvedInitialValues,
|
|
612
|
+
onValuesChange: handleValuesChange,
|
|
613
|
+
onFinish: handleFinish,
|
|
614
|
+
children: fields
|
|
615
|
+
}));
|
|
616
|
+
}
|
|
617
|
+
if (layoutType === 'LightFilter') {
|
|
618
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.LightFilter, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
619
|
+
form: form,
|
|
620
|
+
initialValues: resolvedInitialValues,
|
|
621
|
+
onValuesChange: handleValuesChange,
|
|
622
|
+
onFinish: handleFinish,
|
|
623
|
+
children: fields
|
|
624
|
+
}));
|
|
625
|
+
}
|
|
626
|
+
if (layoutType === 'StepsForm') {
|
|
627
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.StepsForm, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
628
|
+
form: form,
|
|
629
|
+
initialValues: resolvedInitialValues,
|
|
630
|
+
onValuesChange: handleValuesChange,
|
|
631
|
+
onFinish: handleFinish,
|
|
632
|
+
children: stepFields.map(function (stepChildren, index) {
|
|
633
|
+
var _steps$index, _steps$index2;
|
|
634
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.StepsForm.StepForm, {
|
|
635
|
+
title: (steps === null || steps === void 0 || (_steps$index = steps[index]) === null || _steps$index === void 0 ? void 0 : _steps$index.title) || "\u6B65\u9AA4 ".concat(index + 1),
|
|
636
|
+
description: steps === null || steps === void 0 || (_steps$index2 = steps[index]) === null || _steps$index2 === void 0 ? void 0 : _steps$index2.description,
|
|
637
|
+
children: stepChildren
|
|
638
|
+
}, "schema-step-".concat(index));
|
|
639
|
+
})
|
|
640
|
+
}));
|
|
641
|
+
}
|
|
642
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ProForm, _objectSpread(_objectSpread({}, restProps), {}, {
|
|
643
|
+
form: form,
|
|
644
|
+
initialValues: resolvedInitialValues,
|
|
645
|
+
onValuesChange: handleValuesChange,
|
|
646
|
+
onFinish: handleFinish,
|
|
647
|
+
children: fields
|
|
648
|
+
}));
|
|
649
|
+
};
|
|
650
|
+
var SchemaForm = exports.SchemaForm = BetaSchemaForm;
|
|
651
|
+
var _default = exports.default = BetaSchemaForm;
|