@sheinx/hooks 3.5.2 → 3.5.3-beta.2
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/cjs/common/use-list-select/use-list-select-multiple.js +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.js +6 -3
- package/cjs/components/use-datepicker/use-datepicker-range.d.ts +2 -0
- package/cjs/components/use-datepicker/use-datepicker-range.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-range.js +15 -0
- package/cjs/components/use-datepicker/use-time.d.ts +1 -1
- package/cjs/components/use-datepicker/use-time.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-time.js +20 -4
- package/cjs/components/use-datepicker/use-time.type.d.ts +2 -0
- package/cjs/components/use-datepicker/use-time.type.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.d.ts.map +1 -1
- package/cjs/components/use-datepicker/util.js +5 -2
- package/cjs/components/use-form/form-func-context.d.ts +2 -2
- package/cjs/components/use-form/form-func-context.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-context.type.d.ts +12 -2
- package/cjs/components/use-form/use-form-context.type.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-control/use-form-control.js +6 -6
- package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts +4 -0
- package/cjs/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
- package/cjs/components/use-form/use-form-fieldset/use-form-fieldset.js +2 -1
- package/cjs/components/use-form/use-form.d.ts +5 -3
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +113 -40
- package/cjs/components/use-form/use-form.type.d.ts +27 -7
- package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-expand.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-expand.js +3 -2
- package/cjs/components/use-tabs/context.d.ts +3 -3
- package/cjs/components/use-tabs/context.d.ts.map +1 -1
- package/cjs/components/use-tabs/context.js +4 -1
- package/cjs/components/use-tabs/context.type.d.ts +15 -3
- package/cjs/components/use-tabs/context.type.d.ts.map +1 -1
- package/cjs/components/use-tabs/use-tabs.d.ts +4 -2
- package/cjs/components/use-tabs/use-tabs.d.ts.map +1 -1
- package/cjs/components/use-tabs/use-tabs.js +6 -0
- package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
- package/cjs/components/use-tree/use-tree.js +2 -1
- package/cjs/components/use-upload/xhr.d.ts.map +1 -1
- package/cjs/components/use-upload/xhr.js +2 -1
- package/cjs/utils/dom/element.d.ts +1 -0
- package/cjs/utils/dom/element.d.ts.map +1 -1
- package/cjs/utils/dom/element.js +5 -0
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.d.ts.map +1 -1
- package/cjs/utils/index.js +12 -0
- package/cjs/utils/lazyload.d.ts.map +1 -1
- package/cjs/utils/lazyload.js +4 -1
- package/cjs/utils/number.d.ts.map +1 -1
- package/cjs/utils/number.js +2 -1
- package/cjs/utils/render.d.ts.map +1 -1
- package/cjs/utils/render.js +2 -1
- package/cjs/utils/rule/length.d.ts.map +1 -1
- package/cjs/utils/rule/length.js +2 -1
- package/cjs/utils/rule/regexp.d.ts.map +1 -1
- package/cjs/utils/rule/regexp.js +2 -1
- package/cjs/utils/rule/rule.d.ts.map +1 -1
- package/cjs/utils/rule/rule.js +3 -2
- package/cjs/utils/validate/get-rule.js +1 -1
- package/cjs/utils/validate/type.d.ts.map +1 -1
- package/cjs/utils/validate/type.js +2 -1
- package/cjs/utils/warning.d.ts +8 -0
- package/cjs/utils/warning.d.ts.map +1 -0
- package/cjs/utils/warning.js +36 -0
- package/esm/common/use-list-select/use-list-select-multiple.js +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.js +6 -3
- package/esm/components/use-datepicker/use-datepicker-range.d.ts +2 -0
- package/esm/components/use-datepicker/use-datepicker-range.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-range.js +15 -0
- package/esm/components/use-datepicker/use-time.d.ts +1 -1
- package/esm/components/use-datepicker/use-time.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-time.js +20 -4
- package/esm/components/use-datepicker/use-time.type.d.ts +2 -0
- package/esm/components/use-datepicker/use-time.type.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.d.ts.map +1 -1
- package/esm/components/use-datepicker/util.js +4 -2
- package/esm/components/use-form/form-func-context.d.ts +2 -2
- package/esm/components/use-form/form-func-context.d.ts.map +1 -1
- package/esm/components/use-form/use-form-context.type.d.ts +12 -2
- package/esm/components/use-form/use-form-context.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
- package/esm/components/use-form/use-form-control/use-form-control.js +6 -6
- package/esm/components/use-form/use-form-control/use-form-control.type.d.ts +4 -0
- package/esm/components/use-form/use-form-control/use-form-control.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.d.ts.map +1 -1
- package/esm/components/use-form/use-form-fieldset/use-form-fieldset.js +2 -1
- package/esm/components/use-form/use-form.d.ts +5 -3
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +113 -40
- package/esm/components/use-form/use-form.type.d.ts +27 -7
- package/esm/components/use-form/use-form.type.d.ts.map +1 -1
- package/esm/components/use-table/use-table-expand.d.ts.map +1 -1
- package/esm/components/use-table/use-table-expand.js +3 -2
- package/esm/components/use-tabs/context.d.ts +3 -3
- package/esm/components/use-tabs/context.d.ts.map +1 -1
- package/esm/components/use-tabs/context.js +4 -1
- package/esm/components/use-tabs/context.type.d.ts +15 -3
- package/esm/components/use-tabs/context.type.d.ts.map +1 -1
- package/esm/components/use-tabs/use-tabs.d.ts +4 -2
- package/esm/components/use-tabs/use-tabs.d.ts.map +1 -1
- package/esm/components/use-tabs/use-tabs.js +6 -0
- package/esm/components/use-tree/use-tree.d.ts.map +1 -1
- package/esm/components/use-tree/use-tree.js +2 -1
- package/esm/components/use-upload/xhr.d.ts.map +1 -1
- package/esm/components/use-upload/xhr.js +2 -1
- package/esm/utils/dom/element.d.ts +1 -0
- package/esm/utils/dom/element.d.ts.map +1 -1
- package/esm/utils/dom/element.js +4 -0
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -0
- package/esm/utils/lazyload.d.ts.map +1 -1
- package/esm/utils/lazyload.js +5 -2
- package/esm/utils/number.d.ts.map +1 -1
- package/esm/utils/number.js +2 -1
- package/esm/utils/render.d.ts.map +1 -1
- package/esm/utils/render.js +2 -1
- package/esm/utils/rule/length.d.ts.map +1 -1
- package/esm/utils/rule/length.js +2 -1
- package/esm/utils/rule/regexp.d.ts.map +1 -1
- package/esm/utils/rule/regexp.js +2 -1
- package/esm/utils/rule/rule.d.ts.map +1 -1
- package/esm/utils/rule/rule.js +3 -2
- package/esm/utils/validate/get-rule.js +1 -1
- package/esm/utils/validate/type.d.ts.map +1 -1
- package/esm/utils/validate/type.js +2 -1
- package/esm/utils/warning.d.ts +8 -0
- package/esm/utils/warning.d.ts.map +1 -0
- package/esm/utils/warning.js +30 -0
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
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); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -17,14 +16,15 @@ var _utils = require("../../utils");
|
|
|
17
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
17
|
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); }
|
|
19
18
|
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; }
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
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); } }
|
|
22
|
+
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); }); }; }
|
|
20
23
|
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; }
|
|
21
24
|
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; }
|
|
22
25
|
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; }
|
|
23
26
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
24
27
|
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); }
|
|
25
|
-
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; }
|
|
26
|
-
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); } }
|
|
27
|
-
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); }); }; }
|
|
28
28
|
var globalKey = '__global__&&@@';
|
|
29
29
|
var emptyObj = {};
|
|
30
30
|
var useForm = function useForm(props) {
|
|
@@ -45,6 +45,7 @@ var useForm = function useForm(props) {
|
|
|
45
45
|
_props$throttle = props.throttle,
|
|
46
46
|
throttle = _props$throttle === void 0 ? 1000 : _props$throttle,
|
|
47
47
|
size = props.size,
|
|
48
|
+
formName = props.name,
|
|
48
49
|
reserveAble = props.reserveAble,
|
|
49
50
|
scrollParent = props.scrollParent;
|
|
50
51
|
var deepSetOptions = {
|
|
@@ -52,7 +53,7 @@ var useForm = function useForm(props) {
|
|
|
52
53
|
forceSet: true
|
|
53
54
|
};
|
|
54
55
|
var preValue = (0, _useDefaultValue.usePrevious)(props.value);
|
|
55
|
-
var
|
|
56
|
+
var formDomRef = React.useRef();
|
|
56
57
|
var _React$useRef = React.useRef({
|
|
57
58
|
defaultValues: {},
|
|
58
59
|
validateMap: {},
|
|
@@ -114,9 +115,9 @@ var useForm = function useForm(props) {
|
|
|
114
115
|
onError === null || onError === void 0 || onError(err);
|
|
115
116
|
if (!props.scrollToError) return;
|
|
116
117
|
setTimeout(function () {
|
|
117
|
-
var
|
|
118
|
+
var _formDomRef$current;
|
|
118
119
|
var selector = "[".concat((0, _attribute.getDataAttributeName)('status'), "=\"error\"]");
|
|
119
|
-
var el = (
|
|
120
|
+
var el = (_formDomRef$current = formDomRef.current) === null || _formDomRef$current === void 0 ? void 0 : _formDomRef$current.querySelector(selector);
|
|
120
121
|
if (el) {
|
|
121
122
|
el.scrollIntoView();
|
|
122
123
|
var focusableSelectors = 'textarea, input,[tabindex]:not([tabindex="-1"])';
|
|
@@ -139,32 +140,106 @@ var useForm = function useForm(props) {
|
|
|
139
140
|
context.value = newValue;
|
|
140
141
|
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, context.value);
|
|
141
142
|
});
|
|
143
|
+
var getValue = (0, _usePersistFn.default)(function (name) {
|
|
144
|
+
if (name) {
|
|
145
|
+
return (0, _utils.deepGet)(context.value, name);
|
|
146
|
+
}
|
|
147
|
+
return context.value;
|
|
148
|
+
});
|
|
142
149
|
var validateFields = (0, _usePersistFn.default)(function (fields) {
|
|
143
150
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
144
151
|
return new Promise(function (resolve, reject) {
|
|
145
|
-
var
|
|
152
|
+
var finalFields = fields ? ((0, _utils.isArray)(fields) ? fields : [fields]).filter(function (key) {
|
|
146
153
|
return context.validateMap[key];
|
|
147
154
|
}) : Object.keys(context.validateMap);
|
|
148
|
-
var validates =
|
|
155
|
+
var validates = finalFields.map(function (key) {
|
|
149
156
|
var validateField = context.validateMap[key];
|
|
150
157
|
return Array.from(validateField).map(function (validate) {
|
|
151
158
|
return validate(key, (0, _utils.deepGet)(context.value, key), context.value, config);
|
|
152
159
|
});
|
|
153
160
|
});
|
|
154
|
-
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
resolve(true);
|
|
161
|
+
if (config.type === 'withValue') {
|
|
162
|
+
var validatorValue = context.value;
|
|
163
|
+
if (fields) {
|
|
164
|
+
var fieldArray = (0, _utils.isArray)(fields) ? fields : [fields];
|
|
165
|
+
validatorValue = fieldArray.reduce(function (prev, cur) {
|
|
166
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, cur, getValue(cur)));
|
|
167
|
+
}, {});
|
|
162
168
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
Promise.all(validates.flat()).then(function (results) {
|
|
170
|
+
var errors = results.filter(function (n) {
|
|
171
|
+
return n !== true;
|
|
172
|
+
});
|
|
173
|
+
if (errors.length > 0) {
|
|
174
|
+
var errorFields = [];
|
|
175
|
+
for (var _key in context.errors) {
|
|
176
|
+
if (context.errors[_key]) {
|
|
177
|
+
var _context$errors$_key;
|
|
178
|
+
errorFields.push({
|
|
179
|
+
name: _key,
|
|
180
|
+
errors: [((_context$errors$_key = context.errors[_key]) === null || _context$errors$_key === void 0 ? void 0 : _context$errors$_key.message) || '']
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
reject({
|
|
185
|
+
values: validatorValue,
|
|
186
|
+
errorFields: errorFields
|
|
187
|
+
});
|
|
188
|
+
} else {
|
|
189
|
+
resolve(validatorValue);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
Promise.all(validates.flat()).then(function (results) {
|
|
194
|
+
var error = results.find(function (n) {
|
|
195
|
+
return n !== true;
|
|
196
|
+
});
|
|
197
|
+
if (error !== undefined) {
|
|
198
|
+
reject(error);
|
|
199
|
+
} else {
|
|
200
|
+
resolve(true);
|
|
201
|
+
}
|
|
202
|
+
}).catch(function (e) {
|
|
203
|
+
reject((0, _utils.wrapFormError)(e));
|
|
204
|
+
});
|
|
205
|
+
}
|
|
166
206
|
});
|
|
167
207
|
});
|
|
208
|
+
var scrollToField = (0, _usePersistFn.default)(function (name) {
|
|
209
|
+
var _document;
|
|
210
|
+
var scrollIntoViewOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
211
|
+
if (!name) return;
|
|
212
|
+
var fieldId = (0, _utils.getFieldId)(name, formName);
|
|
213
|
+
if (!fieldId) return;
|
|
214
|
+
var element = (_document = document) === null || _document === void 0 ? void 0 : _document.getElementById(fieldId);
|
|
215
|
+
if (element) {
|
|
216
|
+
// 查找可滚动的父元素
|
|
217
|
+
var parentEl = (0, _utils.getClosestScrollContainer)(element);
|
|
218
|
+
if (parentEl) {
|
|
219
|
+
var parentRect = parentEl.getBoundingClientRect();
|
|
220
|
+
var elementRect = element.getBoundingClientRect();
|
|
221
|
+
|
|
222
|
+
// 判断父元素是否在可见范围内
|
|
223
|
+
var isVisibleY = elementRect.top >= parentRect.top && elementRect.bottom <= parentRect.bottom;
|
|
224
|
+
var isVisibleX = elementRect.left >= parentRect.left && elementRect.right <= parentRect.right;
|
|
225
|
+
if (!isVisibleY || !isVisibleX) {
|
|
226
|
+
// 计算元素相对于父元素的偏移量
|
|
227
|
+
var offsetTop = element.offsetTop - parentEl.offsetTop;
|
|
228
|
+
var offsetLeft = element.offsetLeft - parentEl.offsetLeft;
|
|
229
|
+
parentEl.scrollTop = offsetTop;
|
|
230
|
+
parentEl.scrollLeft = offsetLeft;
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
// 如果没有找到可滚动的父元素,使用默认行为
|
|
234
|
+
element.scrollIntoView(_objectSpread({
|
|
235
|
+
behavior: 'smooth'
|
|
236
|
+
}, scrollIntoViewOptions));
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
// todo: 统一警告|错误信息(by Tom)
|
|
240
|
+
console.warn("[shineout] fieldId: ".concat(fieldId, " not found"));
|
|
241
|
+
}
|
|
242
|
+
});
|
|
168
243
|
var remove = function remove() {
|
|
169
244
|
if (!context.removeArr.size) return;
|
|
170
245
|
if (context.unmounted) return;
|
|
@@ -182,12 +257,6 @@ var useForm = function useForm(props) {
|
|
|
182
257
|
}
|
|
183
258
|
context.removeTimer = setTimeout(remove);
|
|
184
259
|
};
|
|
185
|
-
var getValue = (0, _usePersistFn.default)(function (name) {
|
|
186
|
-
if (name) {
|
|
187
|
-
return (0, _utils.deepGet)(context.value, name);
|
|
188
|
-
}
|
|
189
|
-
return context.value;
|
|
190
|
-
});
|
|
191
260
|
var setValue = (0, _usePersistFn.default)(function (vals) {
|
|
192
261
|
var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
193
262
|
validate: false
|
|
@@ -195,9 +264,11 @@ var useForm = function useForm(props) {
|
|
|
195
264
|
onChange(function (draft) {
|
|
196
265
|
var values = Object.keys(vals);
|
|
197
266
|
// 针对 name 为数组模式,如 datepicker 的 name={['startTime', 'endTime']} 时,前者校验可能需要依赖后者,因此需要提前将后者数据整合至 draft 用于多字段整合校验
|
|
198
|
-
var nextDraft =
|
|
267
|
+
var nextDraft = (0, _immer.current)(draft);
|
|
268
|
+
values.forEach(function (key) {
|
|
269
|
+
(0, _utils.deepSet)(nextDraft, key, vals[key], deepSetOptions);
|
|
270
|
+
});
|
|
199
271
|
values.forEach(function (key) {
|
|
200
|
-
(0, _utils.deepSet)(draft, key, vals[key], deepSetOptions);
|
|
201
272
|
if (option.validate) {
|
|
202
273
|
var _context$validateMap$;
|
|
203
274
|
(_context$validateMap$ = context.validateMap[key]) === null || _context$validateMap$ === void 0 || _context$validateMap$.forEach(function (validate) {
|
|
@@ -256,7 +327,7 @@ var useForm = function useForm(props) {
|
|
|
256
327
|
context.submitLock = false;
|
|
257
328
|
}, throttle);
|
|
258
329
|
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
259
|
-
var _props$onSubmit,
|
|
330
|
+
var _props$onSubmit, _context$value, result, _props$onSubmit2, _context$value2;
|
|
260
331
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
261
332
|
while (1) switch (_context.prev = _context.next) {
|
|
262
333
|
case 0:
|
|
@@ -264,7 +335,7 @@ var useForm = function useForm(props) {
|
|
|
264
335
|
_context.next = 3;
|
|
265
336
|
break;
|
|
266
337
|
}
|
|
267
|
-
(_props$onSubmit = props.onSubmit) === null || _props$onSubmit === void 0 || _props$onSubmit.call(props, (
|
|
338
|
+
(_props$onSubmit = props.onSubmit) === null || _props$onSubmit === void 0 || _props$onSubmit.call(props, (_context$value = context.value) !== null && _context$value !== void 0 ? _context$value : {});
|
|
268
339
|
return _context.abrupt("return");
|
|
269
340
|
case 3:
|
|
270
341
|
_context.next = 5;
|
|
@@ -279,7 +350,7 @@ var useForm = function useForm(props) {
|
|
|
279
350
|
_context.next = 10;
|
|
280
351
|
break;
|
|
281
352
|
}
|
|
282
|
-
(_props$onSubmit2 = props.onSubmit) === null || _props$onSubmit2 === void 0 || _props$onSubmit2.call(props, (
|
|
353
|
+
(_props$onSubmit2 = props.onSubmit) === null || _props$onSubmit2 === void 0 || _props$onSubmit2.call(props, (_context$value2 = context.value) !== null && _context$value2 !== void 0 ? _context$value2 : {});
|
|
283
354
|
_context.next = 12;
|
|
284
355
|
break;
|
|
285
356
|
case 10:
|
|
@@ -338,7 +409,7 @@ var useForm = function useForm(props) {
|
|
|
338
409
|
var externalProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
339
410
|
var externalEventHandlers = (0, _utils.extractEventHandlers)(externalProps);
|
|
340
411
|
return _objectSpread(_objectSpread(_objectSpread({}, externalProps), externalEventHandlers), {}, {
|
|
341
|
-
ref:
|
|
412
|
+
ref: formDomRef,
|
|
342
413
|
disabled: !!disabled,
|
|
343
414
|
onSubmit: handleSubmit(externalEventHandlers),
|
|
344
415
|
onReset: handleReset(externalEventHandlers)
|
|
@@ -349,8 +420,8 @@ var useForm = function useForm(props) {
|
|
|
349
420
|
});
|
|
350
421
|
var controlFunc = (0, _useLatestObj.default)({
|
|
351
422
|
bind: function bind(n, df, validate, updateFn) {
|
|
352
|
-
if (context.names.has(n)) {
|
|
353
|
-
|
|
423
|
+
if (process.env.NODE_ENV !== 'production' && context.names.has(n)) {
|
|
424
|
+
_utils.devUseWarning.warn("name \"".concat(n, "\" already exist in Form component"));
|
|
354
425
|
}
|
|
355
426
|
context.names.add(n);
|
|
356
427
|
if (!context.validateMap[n]) {
|
|
@@ -372,10 +443,10 @@ var useForm = function useForm(props) {
|
|
|
372
443
|
});
|
|
373
444
|
}
|
|
374
445
|
},
|
|
375
|
-
unbind: function unbind(n, reserveAble,
|
|
446
|
+
unbind: function unbind(n, reserveAble, validateField, update) {
|
|
376
447
|
var validateFieldSet = context.validateMap[n];
|
|
377
|
-
if (
|
|
378
|
-
validateFieldSet.delete(
|
|
448
|
+
if (validateField && validateFieldSet.has(validateField)) {
|
|
449
|
+
validateFieldSet.delete(validateField);
|
|
379
450
|
}
|
|
380
451
|
var updateFieldSet = context.updateMap[n];
|
|
381
452
|
if (update && updateFieldSet.has(update)) {
|
|
@@ -436,7 +507,8 @@ var useForm = function useForm(props) {
|
|
|
436
507
|
validateFields: validateFields,
|
|
437
508
|
validateFieldset: validateFieldset,
|
|
438
509
|
insertError: insertError,
|
|
439
|
-
spliceError: spliceError
|
|
510
|
+
spliceError: spliceError,
|
|
511
|
+
scrollToField: scrollToField
|
|
440
512
|
});
|
|
441
513
|
var formConfig = React.useMemo(function () {
|
|
442
514
|
return {
|
|
@@ -447,9 +519,10 @@ var useForm = function useForm(props) {
|
|
|
447
519
|
inline: inline,
|
|
448
520
|
disabled: disabled,
|
|
449
521
|
size: size,
|
|
450
|
-
reserveAble: reserveAble
|
|
522
|
+
reserveAble: reserveAble,
|
|
523
|
+
formName: formName
|
|
451
524
|
};
|
|
452
|
-
}, [labelWidth, labelAlign, labelVerticalAlign, keepErrorHeight, inline, disabled, size, reserveAble]);
|
|
525
|
+
}, [labelWidth, labelAlign, labelVerticalAlign, keepErrorHeight, inline, disabled, size, reserveAble, formName]);
|
|
453
526
|
var updateValue = function updateValue() {
|
|
454
527
|
if (props.value !== context.lastValue && props.value !== context.value) {
|
|
455
528
|
context.value = (0, _utils.deepClone)(props.value) || emptyObj;
|
|
@@ -3,9 +3,19 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { AddNoProps, ObjectType } from '../../common/type';
|
|
4
4
|
import { FormItemRule } from '../../utils/rule/rule.type';
|
|
5
5
|
import { FormError } from '../../utils';
|
|
6
|
-
export type
|
|
6
|
+
export type KeyType = string | number | symbol;
|
|
7
|
+
export interface ValidationError<T> {
|
|
8
|
+
values: T;
|
|
9
|
+
errorFields: {
|
|
10
|
+
name: string;
|
|
11
|
+
errors: string[];
|
|
12
|
+
}[];
|
|
13
|
+
}
|
|
14
|
+
export type ValidateFnConfig = {
|
|
15
|
+
type?: 'forcePass' | 'withValue';
|
|
7
16
|
ignoreBind?: boolean;
|
|
8
|
-
}
|
|
17
|
+
};
|
|
18
|
+
export type ValidateFn = (name: string, value: any, formData: ObjectType, config?: ValidateFnConfig) => Promise<true | FormError>;
|
|
9
19
|
export type UpdateFn = (formValue: ObjectType, errors: ObjectType<Error | undefined>, serverErrors: ObjectType<Error | undefined>) => void;
|
|
10
20
|
export interface FormContextValueType {
|
|
11
21
|
func?: {
|
|
@@ -74,8 +84,14 @@ export interface FormCommonConfig extends FormLabelConfig {
|
|
|
74
84
|
* @version 3.5.0
|
|
75
85
|
*/
|
|
76
86
|
reserveAble?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* @en The name of the form, will be used as the prefix of the form field id, and can enable the <label for="id" /> function after setting
|
|
89
|
+
* @cn 表单名称,会作为表单字段 id 的前缀,设置后可开启 <label for="id" /> 功能
|
|
90
|
+
* @version 3.5.2
|
|
91
|
+
*/
|
|
92
|
+
formName?: string;
|
|
77
93
|
}
|
|
78
|
-
export interface FormFunc {
|
|
94
|
+
export interface FormFunc<T = any> {
|
|
79
95
|
setValue: (vals: {
|
|
80
96
|
[key: string]: any;
|
|
81
97
|
}, option?: {
|
|
@@ -87,9 +103,7 @@ export interface FormFunc {
|
|
|
87
103
|
setError: (name: string, e: Error | undefined) => void;
|
|
88
104
|
getErrors: () => ObjectType<Error | undefined>;
|
|
89
105
|
clearValidate: (names?: string[]) => void;
|
|
90
|
-
validateFields: (fields?: string | string[], config?:
|
|
91
|
-
ignoreBind?: boolean;
|
|
92
|
-
}) => Promise<true>;
|
|
106
|
+
validateFields: (fields?: string | string[], config?: ValidateFnConfig) => Promise<Partial<T>>;
|
|
93
107
|
validateFieldset: (name: string) => void;
|
|
94
108
|
insertError: (name: string, index: number, error?: Error) => void;
|
|
95
109
|
spliceError: (name: string, index: number) => void;
|
|
@@ -155,13 +169,19 @@ export interface BaseFormProps<T> extends FormCommonConfig {
|
|
|
155
169
|
* @private 内部属性
|
|
156
170
|
*/
|
|
157
171
|
error?: ObjectType<string | Error>;
|
|
172
|
+
/**
|
|
173
|
+
* @en The name of the form, will be used as the prefix of the form field id, and can enable the <label for="id" /> function after setting
|
|
174
|
+
* @cn 表单名称,会作为表单字段 id 的前缀,设置后可使用 formRef 的 scrollToField 方法
|
|
175
|
+
* @version 3.5.3
|
|
176
|
+
*/
|
|
177
|
+
name?: string;
|
|
158
178
|
}
|
|
159
179
|
export type UseFormProps<T> = BaseFormProps<T>;
|
|
160
180
|
export type FormContext = {
|
|
161
181
|
defaultValues: ObjectType;
|
|
162
182
|
validateMap: ObjectType<Set<(name: string, v: any, formValue: ObjectType, config?: {
|
|
163
183
|
ignoreBind?: boolean;
|
|
164
|
-
}) => Promise<
|
|
184
|
+
}) => Promise<true | FormError>>>;
|
|
165
185
|
removeArr: Set<string>;
|
|
166
186
|
removeTimer?: number | NodeJS.Timeout;
|
|
167
187
|
names: Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form.type.d.ts","sourceRoot":"","sources":["use-form.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"use-form.type.d.ts","sourceRoot":"","sources":["use-form.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,MAAM,EAAE,CAAC,CAAC;IACV,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,EAAE,CAAC;CACL;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,MAAM,M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AAE,UAAU,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IACtC,YAAY,EAAE,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,CACzE,mBAAmB,EACnB,MAAM,CACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-expand.d.ts","sourceRoot":"","sources":["use-table-expand.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-table-expand.d.ts","sourceRoot":"","sources":["use-table-expand.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKrE,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC;IAC7F,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AAED,eAAO,MAAM,cAAc,UAAW,mBAAmB;6BAa/C,kBAAkB,GAAG,CAAC,QAAQ,GAAG,SAAS,MAAM;wBAThB,GAAG,SAAS,MAAM;CA2C3D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -7,7 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useTableExpand = exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _usePersistFn = _interopRequireDefault(require("../../common/use-persist-fn"));
|
|
10
|
-
var _render = require("
|
|
10
|
+
var _render = require("../../utils/render");
|
|
11
|
+
var _utils = require("../../utils");
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
13
|
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); }
|
|
13
14
|
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; }
|
|
@@ -62,7 +63,7 @@ var useTableExpand = exports.useTableExpand = function useTableExpand(props) {
|
|
|
62
63
|
return col.type === 'expand' || col.type === 'row-expand';
|
|
63
64
|
}).length;
|
|
64
65
|
if (expandNum > 1) {
|
|
65
|
-
|
|
66
|
+
_utils.devUseWarning.error('columns should not have more than one expand column');
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TabsProviderProps, TabsContextProps } from './context.type';
|
|
3
|
-
export declare const TabsContext: React.Context<TabsContextProps
|
|
4
|
-
export declare const Provider: (props: TabsProviderProps) => JSX.Element;
|
|
5
|
-
export declare const useTabsContext: () => TabsContextProps
|
|
3
|
+
export declare const TabsContext: React.Context<TabsContextProps<any>>;
|
|
4
|
+
export declare const Provider: <TabData>(props: TabsProviderProps<TabData>) => JSX.Element;
|
|
5
|
+
export declare const useTabsContext: <TabData>() => TabsContextProps<TabData>;
|
|
6
6
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,eAAO,MAAM,WAAW,sCAA8E,CAAC;AAEvG,eAAO,MAAM,QAAQ,6DAGpB,CAAC;AAEF,eAAO,MAAM,cAAc,0CAA8E,CAAC"}
|
|
@@ -10,7 +10,10 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
13
|
-
var TabsContext = exports.TabsContext = /*#__PURE__*/React.createContext({
|
|
13
|
+
var TabsContext = exports.TabsContext = /*#__PURE__*/React.createContext({
|
|
14
|
+
tabs: [],
|
|
15
|
+
setTabs: function setTabs() {}
|
|
16
|
+
});
|
|
14
17
|
var Provider = exports.Provider = function Provider(props) {
|
|
15
18
|
var children = props.children,
|
|
16
19
|
value = props.value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TabsShapeType } from './use-tabs.type';
|
|
3
|
-
export interface TabsContextProps {
|
|
3
|
+
export interface TabsContextProps<TabData = any> {
|
|
4
4
|
/**
|
|
5
5
|
* @private 内部属性
|
|
6
6
|
*/
|
|
@@ -34,9 +34,21 @@ export interface TabsContextProps {
|
|
|
34
34
|
* @private 内部属性
|
|
35
35
|
*/
|
|
36
36
|
onCollapsible?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* @private 内部属性
|
|
39
|
+
*/
|
|
40
|
+
tabs: TabData[];
|
|
41
|
+
/**
|
|
42
|
+
* @private 内部属性
|
|
43
|
+
*/
|
|
44
|
+
setTabs: React.Dispatch<React.SetStateAction<TabData[]>>;
|
|
45
|
+
/**
|
|
46
|
+
* @private 内部属性
|
|
47
|
+
*/
|
|
48
|
+
color?: string;
|
|
37
49
|
}
|
|
38
|
-
export interface TabsProviderProps {
|
|
39
|
-
value: TabsContextProps
|
|
50
|
+
export interface TabsProviderProps<TabData> {
|
|
51
|
+
value: TabsContextProps<TabData>;
|
|
40
52
|
children?: React.ReactNode;
|
|
41
53
|
}
|
|
42
54
|
//# sourceMappingURL=context.type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.type.d.ts","sourceRoot":"","sources":["context.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,gBAAgB;
|
|
1
|
+
{"version":3,"file":"context.type.d.ts","sourceRoot":"","sources":["context.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,gBAAgB,CAAC,OAAO,GAAG,GAAG;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC1C;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B;;OAEG;IACH,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB,CAAC,OAAO;IACxC,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BaseTabsProps } from './use-tabs.type';
|
|
3
|
-
declare const useTabs: (props: BaseTabsProps) => {
|
|
3
|
+
declare const useTabs: <TabData = any>(props: BaseTabsProps) => {
|
|
4
4
|
active: string | number | undefined;
|
|
5
5
|
onChange: (key: string | number) => void;
|
|
6
|
-
|
|
6
|
+
tabs: TabData[];
|
|
7
|
+
setTabs: import("react").Dispatch<import("react").SetStateAction<TabData[]>>;
|
|
8
|
+
Provider: <TabData_1>(props: import("./context.type").TabsProviderProps<TabData_1>) => JSX.Element;
|
|
7
9
|
};
|
|
8
10
|
export default useTabs;
|
|
9
11
|
//# sourceMappingURL=use-tabs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tabs.d.ts","sourceRoot":"","sources":["use-tabs.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,QAAA,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"use-tabs.d.ts","sourceRoot":"","sources":["use-tabs.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,QAAA,MAAM,OAAO,yBAA0B,aAAa;;oBAYvB,MAAM,GAAG,MAAM;;;;CAY3C,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -21,6 +21,10 @@ var useTabs = function useTabs(props) {
|
|
|
21
21
|
_useState2 = _slicedToArray(_useState, 2),
|
|
22
22
|
activeTabs = _useState2[0],
|
|
23
23
|
setActiveTabs = _useState2[1];
|
|
24
|
+
var _useState3 = (0, _react.useState)([]),
|
|
25
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
26
|
+
tabs = _useState4[0],
|
|
27
|
+
setTabs = _useState4[1];
|
|
24
28
|
var getActive = function getActive() {
|
|
25
29
|
if (props.active === undefined) {
|
|
26
30
|
return activeTabs;
|
|
@@ -34,6 +38,8 @@ var useTabs = function useTabs(props) {
|
|
|
34
38
|
return {
|
|
35
39
|
active: getActive(),
|
|
36
40
|
onChange: handleChange,
|
|
41
|
+
tabs: tabs,
|
|
42
|
+
setTabs: setTabs,
|
|
37
43
|
Provider: _context.Provider
|
|
38
44
|
};
|
|
39
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAUjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CA4bZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -9,6 +9,7 @@ var _useLatestObj = _interopRequireDefault(require("../../common/use-latest-obj"
|
|
|
9
9
|
var _useInputAble2 = require("../../common/use-input-able");
|
|
10
10
|
var _usePersistFn = require("../../common/use-persist-fn");
|
|
11
11
|
var _is = require("../../utils/is");
|
|
12
|
+
var _utils = require("../../utils");
|
|
12
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
14
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
15
|
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."); }
|
|
@@ -236,7 +237,7 @@ var useTree = function useTree(props) {
|
|
|
236
237
|
var id = getKey(item, path[path.length - 1], i);
|
|
237
238
|
// 重复 id 警告
|
|
238
239
|
if (context.dataMap.get(id)) {
|
|
239
|
-
|
|
240
|
+
_utils.devUseWarning.error("There is already a key \"".concat(id, "\" exists. The key must be unique."));
|
|
240
241
|
continue;
|
|
241
242
|
}
|
|
242
243
|
// 制作 data mapping
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["xhr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xhr.d.ts","sourceRoot":"","sources":["xhr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAoBlD,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,aAAa,CAAC,GAAG,CAAC,8BA8ChD"}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = _default;
|
|
7
|
+
var _utils = require("../../utils");
|
|
7
8
|
function createCORSRequest(method, url) {
|
|
8
9
|
var xhr = new XMLHttpRequest();
|
|
9
10
|
if ('withCredentials' in xhr) {
|
|
@@ -34,7 +35,7 @@ function _default(args) {
|
|
|
34
35
|
onStart = args.onStart,
|
|
35
36
|
responseType = args.responseType;
|
|
36
37
|
if (!url) {
|
|
37
|
-
|
|
38
|
+
_utils.devUseWarning.error("action is required, but its value is ".concat(url));
|
|
38
39
|
return undefined;
|
|
39
40
|
}
|
|
40
41
|
var data = new FormData();
|
|
@@ -16,4 +16,5 @@ export declare function getClosestScrollContainer(element: HTMLElement | null):
|
|
|
16
16
|
export declare function getClosestFixedContainer(element: Element | HTMLElement | null): HTMLElement | null;
|
|
17
17
|
export declare function cssSupport(attr: keyof CSSStyleDeclaration, value: string): boolean;
|
|
18
18
|
export declare const parsePxToNumber: (str: string) => number;
|
|
19
|
+
export declare const getFieldId: (name?: string, formName?: string) => string | undefined;
|
|
19
20
|
//# sourceMappingURL=element.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,WAAW,UAAQ,EACnB,SAAS,CAAC,EAAE,MAAM,G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