@lemon-fe/components 0.1.119 → 0.1.122
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/es/Actions/index.js +17 -45
- package/es/BaseTable/Actions.d.ts +1 -0
- package/es/BaseTable/Actions.js +8 -30
- package/es/BaseTable/ResizeHeaderCell.js +12 -39
- package/es/BaseTable/VirtualBody.js +11 -50
- package/es/BaseTable/index.d.ts +1 -0
- package/es/BaseTable/index.js +109 -196
- package/es/BaseTable/utils.js +0 -4
- package/es/ColorPicker/index.js +13 -31
- package/es/Dropdown/index.js +9 -19
- package/es/DurationPicker/index.d.ts +1 -0
- package/es/DurationPicker/index.js +12 -40
- package/es/EditableTable/EditableCell.js +9 -12
- package/es/EditableTable/EditableTableFormItem.d.ts +1 -0
- package/es/EditableTable/EditableTableFormItem.js +8 -16
- package/es/EditableTable/Table.js +28 -103
- package/es/EditableTable/util.d.ts +1 -1
- package/es/EditableTable/util.js +23 -99
- package/es/Filter/index.d.ts +8 -1
- package/es/Filter/index.js +118 -196
- package/es/Filter/typings.d.ts +1 -0
- package/es/FormHorizontal/index.js +0 -5
- package/es/FormInline/index.js +5 -21
- package/es/FormLayout/index.js +6 -11
- package/es/FormTable/index.js +12 -46
- package/es/Icons/BigTip/index.js +2 -14
- package/es/Icons/Calendar.js +0 -5
- package/es/Icons/Close.js +0 -5
- package/es/Icons/CollapseUp.js +0 -5
- package/es/Icons/DarkSearch.js +0 -5
- package/es/Icons/Down.js +0 -5
- package/es/Icons/Empty.js +0 -2
- package/es/Icons/LookUp.js +0 -5
- package/es/Icons/More.js +0 -5
- package/es/Icons/Search.js +0 -5
- package/es/Icons/Tip.js +2 -19
- package/es/InputMaxLength/index.js +9 -29
- package/es/Layout/index.js +23 -45
- package/es/MainFramework/components/DropMenu/index.d.ts +1 -0
- package/es/MainFramework/components/DropMenu/index.js +8 -19
- package/es/MainFramework/components/Menu/index.d.ts +1 -0
- package/es/MainFramework/components/Menu/index.js +22 -88
- package/es/MainFramework/components/RefreshButton/index.d.ts +1 -0
- package/es/MainFramework/components/RefreshButton/index.js +5 -14
- package/es/MainFramework/components/TabBar/index.d.ts +1 -0
- package/es/MainFramework/components/TabBar/index.js +6 -21
- package/es/MainFramework/index.js +18 -18
- package/es/PageLoading/index.js +0 -2
- package/es/Popup/index.js +30 -73
- package/es/Portal/index.js +13 -31
- package/es/Section/TabBar.js +6 -16
- package/es/Section/index.js +14 -22
- package/es/SelectView/index.d.ts +1 -1
- package/es/SelectView/index.js +25 -62
- package/es/SiderTree/TreeNodeTitle.d.ts +1 -0
- package/es/SiderTree/TreeNodeTitle.js +8 -24
- package/es/SiderTree/index.js +15 -50
- package/es/SymbolIcon/index.js +4 -9
- package/es/TabBar/index.js +7 -17
- package/es/Table/index.d.ts +2 -1
- package/es/Table/index.js +90 -124
- package/es/TipMark/index.js +7 -17
- package/es/init.js +11 -27
- package/es/utils.js +0 -2
- package/package.json +4 -4
package/es/EditableTable/util.js
CHANGED
|
@@ -1,53 +1,32 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
1
2
|
var _excluded = ["validator"];
|
|
2
|
-
|
|
3
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
-
|
|
5
4
|
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."); }
|
|
6
|
-
|
|
7
5
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
|
|
9
6
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
|
|
7
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
11
8
|
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); } }
|
|
12
|
-
|
|
13
9
|
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); }); }; }
|
|
14
|
-
|
|
15
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
|
|
17
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
|
|
19
12
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
|
-
|
|
21
13
|
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; }
|
|
22
|
-
|
|
23
14
|
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; }
|
|
24
|
-
|
|
25
15
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
26
|
-
|
|
27
16
|
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."); }
|
|
28
|
-
|
|
29
17
|
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); }
|
|
30
|
-
|
|
31
18
|
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; }
|
|
32
|
-
|
|
33
19
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
34
|
-
|
|
35
20
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
36
|
-
|
|
37
21
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
38
|
-
|
|
39
22
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
40
|
-
|
|
41
23
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
42
|
-
|
|
43
24
|
import { debounce } from 'lodash';
|
|
44
25
|
import Scheme from 'async-validator';
|
|
45
26
|
export var FormStore = /*#__PURE__*/function () {
|
|
46
27
|
function FormStore(initialData, keys) {
|
|
47
28
|
var _this = this;
|
|
48
|
-
|
|
49
29
|
_classCallCheck(this, FormStore);
|
|
50
|
-
|
|
51
30
|
this.data = [];
|
|
52
31
|
this.keys = [];
|
|
53
32
|
this.focused = null;
|
|
@@ -60,31 +39,24 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
60
39
|
_this.validator.validate(record).then(function () {
|
|
61
40
|
_this.notify(rowKey, function (_ref) {
|
|
62
41
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
42
|
+
colKey = _ref2[0],
|
|
43
|
+
cb = _ref2[1];
|
|
66
44
|
_this.removeError(rowKey, colKey);
|
|
67
|
-
|
|
68
45
|
cb({
|
|
69
46
|
errors: null
|
|
70
47
|
});
|
|
71
48
|
});
|
|
72
49
|
}).catch(function (_ref3) {
|
|
73
50
|
var fields = _ref3.fields;
|
|
74
|
-
|
|
75
51
|
_this.notify(rowKey, function (_ref4) {
|
|
76
52
|
var _fields$colKey;
|
|
77
|
-
|
|
78
53
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
54
|
+
colKey = _ref5[0],
|
|
55
|
+
cb = _ref5[1];
|
|
82
56
|
var errors = ((_fields$colKey = fields[colKey]) === null || _fields$colKey === void 0 ? void 0 : _fields$colKey.map(function (item) {
|
|
83
57
|
return item.message || "".concat(colKey, "\u8F93\u5165\u9519\u8BEF");
|
|
84
58
|
})) || null;
|
|
85
|
-
|
|
86
59
|
_this.setError(rowKey, colKey, errors);
|
|
87
|
-
|
|
88
60
|
cb({
|
|
89
61
|
errors: errors
|
|
90
62
|
});
|
|
@@ -95,16 +67,13 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
95
67
|
this.data = initialData;
|
|
96
68
|
this.keys = keys;
|
|
97
69
|
}
|
|
98
|
-
|
|
99
70
|
_createClass(FormStore, [{
|
|
100
71
|
key: "setError",
|
|
101
72
|
value: function setError(rowKey, colKey, messages) {
|
|
102
73
|
var error = this.errors.get(rowKey);
|
|
103
|
-
|
|
104
74
|
if (error === undefined) {
|
|
105
75
|
error = new Map();
|
|
106
76
|
}
|
|
107
|
-
|
|
108
77
|
error.set(colKey, messages);
|
|
109
78
|
this.errors.set(rowKey, error);
|
|
110
79
|
}
|
|
@@ -112,13 +81,10 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
112
81
|
key: "removeError",
|
|
113
82
|
value: function removeError(rowKey, colKey) {
|
|
114
83
|
var error = this.errors.get(rowKey);
|
|
115
|
-
|
|
116
84
|
if (error === undefined) {
|
|
117
85
|
return;
|
|
118
86
|
}
|
|
119
|
-
|
|
120
87
|
error.delete(colKey);
|
|
121
|
-
|
|
122
88
|
if (error.size <= 0) {
|
|
123
89
|
this.errors.delete(rowKey);
|
|
124
90
|
}
|
|
@@ -127,11 +93,9 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
127
93
|
key: "getError",
|
|
128
94
|
value: function getError(rowKey, colKey) {
|
|
129
95
|
var error = this.errors.get(rowKey);
|
|
130
|
-
|
|
131
96
|
if (error === undefined) {
|
|
132
97
|
return null;
|
|
133
98
|
}
|
|
134
|
-
|
|
135
99
|
return error.get(colKey) || null;
|
|
136
100
|
}
|
|
137
101
|
}, {
|
|
@@ -140,13 +104,11 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
140
104
|
var descriptor = {};
|
|
141
105
|
validators.forEach(function (_ref6) {
|
|
142
106
|
var _ref7 = _slicedToArray(_ref6, 2),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
107
|
+
key = _ref7[0],
|
|
108
|
+
rules = _ref7[1];
|
|
146
109
|
descriptor[key] = rules.map(function (rule) {
|
|
147
110
|
var validator = rule.validator,
|
|
148
|
-
|
|
149
|
-
|
|
111
|
+
restRule = _objectWithoutProperties(rule, _excluded);
|
|
150
112
|
return _objectSpread(_objectSpread({}, restRule), {}, {
|
|
151
113
|
asyncValidator: validator ? function (mRule, value, _, record) {
|
|
152
114
|
return validator(mRule, value, record);
|
|
@@ -165,11 +127,10 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
165
127
|
}, {
|
|
166
128
|
key: "validate",
|
|
167
129
|
value: function () {
|
|
168
|
-
var _validate = _asyncToGenerator( /*#__PURE__*/
|
|
130
|
+
var _validate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
169
131
|
var _this2 = this;
|
|
170
|
-
|
|
171
132
|
var result, rejected;
|
|
172
|
-
return
|
|
133
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
173
134
|
while (1) {
|
|
174
135
|
switch (_context.prev = _context.next) {
|
|
175
136
|
case 0:
|
|
@@ -177,9 +138,7 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
177
138
|
_context.next = 2;
|
|
178
139
|
break;
|
|
179
140
|
}
|
|
180
|
-
|
|
181
141
|
return _context.abrupt("return", Promise.resolve(true));
|
|
182
|
-
|
|
183
142
|
case 2:
|
|
184
143
|
_context.next = 4;
|
|
185
144
|
return Promise.allSettled(this.data.map(function (record, index) {
|
|
@@ -187,63 +146,49 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
187
146
|
return _this2.validator.validate(record).then(function () {
|
|
188
147
|
_this2.notify(rowKey, function (_ref8) {
|
|
189
148
|
var _ref9 = _slicedToArray(_ref8, 2),
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
149
|
+
colKey = _ref9[0],
|
|
150
|
+
cb = _ref9[1];
|
|
193
151
|
_this2.removeError(rowKey, colKey);
|
|
194
|
-
|
|
195
152
|
cb({
|
|
196
153
|
errors: null
|
|
197
154
|
});
|
|
198
155
|
});
|
|
199
|
-
|
|
200
156
|
return true;
|
|
201
157
|
}).catch(function (_ref10) {
|
|
202
158
|
var fields = _ref10.fields;
|
|
203
|
-
|
|
204
159
|
_this2.notify(rowKey, function (_ref11) {
|
|
205
160
|
var _fields$colKey2;
|
|
206
|
-
|
|
207
161
|
var _ref12 = _slicedToArray(_ref11, 2),
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
162
|
+
colKey = _ref12[0],
|
|
163
|
+
cb = _ref12[1];
|
|
211
164
|
var errors = ((_fields$colKey2 = fields[colKey]) === null || _fields$colKey2 === void 0 ? void 0 : _fields$colKey2.map(function (item) {
|
|
212
165
|
return item.message || "".concat(colKey, "\u8F93\u5165\u9519\u8BEF");
|
|
213
166
|
})) || null;
|
|
214
|
-
|
|
215
167
|
_this2.setError(rowKey, colKey, errors);
|
|
216
|
-
|
|
217
168
|
cb({
|
|
218
169
|
errors: errors
|
|
219
170
|
});
|
|
220
171
|
});
|
|
221
|
-
|
|
222
172
|
return Promise.reject({
|
|
223
173
|
index: index,
|
|
224
174
|
fields: fields
|
|
225
175
|
});
|
|
226
176
|
});
|
|
227
177
|
}));
|
|
228
|
-
|
|
229
178
|
case 4:
|
|
230
179
|
result = _context.sent;
|
|
231
180
|
rejected = result.filter(function (item) {
|
|
232
181
|
return item.status === 'rejected';
|
|
233
182
|
});
|
|
234
|
-
|
|
235
183
|
if (!(rejected.length > 0)) {
|
|
236
184
|
_context.next = 8;
|
|
237
185
|
break;
|
|
238
186
|
}
|
|
239
|
-
|
|
240
187
|
return _context.abrupt("return", Promise.reject(rejected.map(function (item) {
|
|
241
188
|
return item.reason;
|
|
242
189
|
})));
|
|
243
|
-
|
|
244
190
|
case 8:
|
|
245
191
|
return _context.abrupt("return", true);
|
|
246
|
-
|
|
247
192
|
case 9:
|
|
248
193
|
case "end":
|
|
249
194
|
return _context.stop();
|
|
@@ -251,50 +196,41 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
251
196
|
}
|
|
252
197
|
}, _callee, this);
|
|
253
198
|
}));
|
|
254
|
-
|
|
255
199
|
function validate() {
|
|
256
200
|
return _validate.apply(this, arguments);
|
|
257
201
|
}
|
|
258
|
-
|
|
259
202
|
return validate;
|
|
260
203
|
}()
|
|
261
204
|
}, {
|
|
262
205
|
key: "setData",
|
|
263
206
|
value: function setData(index, value) {
|
|
264
207
|
var record = _objectSpread(_objectSpread({}, this.data[index]), value);
|
|
265
|
-
|
|
266
208
|
var rowKey = this.keys[index];
|
|
267
209
|
this.data = _toConsumableArray(this.data);
|
|
268
210
|
this.data[index] = record;
|
|
269
211
|
this.notify(rowKey, function (_ref13) {
|
|
270
212
|
var _ref14 = _slicedToArray(_ref13, 2),
|
|
271
|
-
|
|
272
|
-
|
|
213
|
+
cb = _ref14[1];
|
|
273
214
|
cb({
|
|
274
215
|
record: record
|
|
275
216
|
});
|
|
276
217
|
});
|
|
277
|
-
|
|
278
218
|
if (this.handler !== undefined) {
|
|
279
219
|
this.handler(this.data);
|
|
280
220
|
}
|
|
281
|
-
|
|
282
221
|
this.validateRecord(record, rowKey);
|
|
283
222
|
}
|
|
284
223
|
}, {
|
|
285
224
|
key: "update",
|
|
286
225
|
value: function update(value, keys) {
|
|
287
226
|
var _this3 = this;
|
|
288
|
-
|
|
289
227
|
if (value === this.data) {
|
|
290
228
|
return;
|
|
291
229
|
}
|
|
292
|
-
|
|
293
230
|
keys.forEach(function (key, index) {
|
|
294
231
|
_this3.notify(key, function (_ref15) {
|
|
295
232
|
var _ref16 = _slicedToArray(_ref15, 2),
|
|
296
|
-
|
|
297
|
-
|
|
233
|
+
cb = _ref16[1];
|
|
298
234
|
cb({
|
|
299
235
|
record: value[index]
|
|
300
236
|
});
|
|
@@ -307,33 +243,28 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
307
243
|
key: "focus",
|
|
308
244
|
value: function focus(rowKey, colKey) {
|
|
309
245
|
var _ref17 = this.focused || [],
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
246
|
+
_ref18 = _slicedToArray(_ref17, 2),
|
|
247
|
+
prevRowKey = _ref18[0],
|
|
248
|
+
prevColKey = _ref18[1];
|
|
314
249
|
if (prevRowKey !== undefined && rowKey !== prevRowKey) {
|
|
315
250
|
this.notify(prevRowKey, function (_ref19) {
|
|
316
251
|
var _ref20 = _slicedToArray(_ref19, 2),
|
|
317
|
-
|
|
318
|
-
|
|
252
|
+
cb = _ref20[1];
|
|
319
253
|
cb({
|
|
320
254
|
focused: 0
|
|
321
255
|
});
|
|
322
256
|
});
|
|
323
257
|
}
|
|
324
|
-
|
|
325
258
|
if (colKey !== prevColKey || rowKey !== prevRowKey) {
|
|
326
259
|
this.notify(rowKey, function (_ref21) {
|
|
327
260
|
var _ref22 = _slicedToArray(_ref21, 2),
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
261
|
+
key = _ref22[0],
|
|
262
|
+
cb = _ref22[1];
|
|
331
263
|
cb({
|
|
332
264
|
focused: key === colKey ? 2 : 1
|
|
333
265
|
});
|
|
334
266
|
});
|
|
335
267
|
}
|
|
336
|
-
|
|
337
268
|
this.focused = [rowKey, colKey];
|
|
338
269
|
}
|
|
339
270
|
}, {
|
|
@@ -351,21 +282,16 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
351
282
|
key: "listen",
|
|
352
283
|
value: function listen(rowKey, colKey, cb) {
|
|
353
284
|
var _this4 = this;
|
|
354
|
-
|
|
355
285
|
var observer = this.observers.get(rowKey);
|
|
356
|
-
|
|
357
286
|
if (observer === undefined) {
|
|
358
287
|
observer = new Map();
|
|
359
288
|
}
|
|
360
|
-
|
|
361
289
|
observer.set(colKey, cb);
|
|
362
290
|
this.observers.set(rowKey, observer);
|
|
363
291
|
return function () {
|
|
364
292
|
var ob = _this4.observers.get(rowKey);
|
|
365
|
-
|
|
366
293
|
if (ob !== undefined) {
|
|
367
294
|
ob.delete(colKey);
|
|
368
|
-
|
|
369
295
|
if (ob.size <= 0) {
|
|
370
296
|
_this4.observers.delete(rowKey);
|
|
371
297
|
}
|
|
@@ -376,12 +302,10 @@ export var FormStore = /*#__PURE__*/function () {
|
|
|
376
302
|
key: "notify",
|
|
377
303
|
value: function notify(rowKey, callback) {
|
|
378
304
|
var row = this.observers.get(rowKey);
|
|
379
|
-
|
|
380
305
|
if (row !== undefined) {
|
|
381
306
|
_toConsumableArray(row).forEach(callback);
|
|
382
307
|
}
|
|
383
308
|
}
|
|
384
309
|
}]);
|
|
385
|
-
|
|
386
310
|
return FormStore;
|
|
387
311
|
}();
|
package/es/Filter/index.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { ComponentOption, FilterProps } from './typings';
|
|
2
3
|
declare function Filter<T extends Record<string, any> = Record<string, any>>(props: FilterProps<T>): JSX.Element;
|
|
3
4
|
declare namespace Filter {
|
|
4
5
|
var setComponents: (items: ComponentOption[]) => void;
|
|
5
|
-
var setStorage: <T
|
|
6
|
+
var setStorage: <T extends {
|
|
7
|
+
title: string;
|
|
8
|
+
value: Record<string | number, any>;
|
|
9
|
+
}>(getData: (storageKey: string) => T[] | Promise<T[]>, setData: (storageKey: string, data: T[], action: {
|
|
10
|
+
type: "set" | "delete";
|
|
11
|
+
target: T;
|
|
12
|
+
}) => void | Promise<void>) => void;
|
|
6
13
|
var defaultProps: Partial<FilterProps<Record<string, any>>>;
|
|
7
14
|
}
|
|
8
15
|
export default Filter;
|