@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/Filter/index.js
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
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; }
|
|
1
3
|
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); } }
|
|
2
|
-
|
|
3
4
|
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); }); }; }
|
|
4
|
-
|
|
5
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
|
|
7
6
|
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."); }
|
|
8
|
-
|
|
9
7
|
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; }
|
|
10
|
-
|
|
11
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
9
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
-
|
|
15
10
|
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."); }
|
|
16
|
-
|
|
17
11
|
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); }
|
|
18
|
-
|
|
19
12
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
20
|
-
|
|
21
13
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
22
|
-
|
|
23
14
|
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; }
|
|
24
|
-
|
|
25
15
|
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; }
|
|
26
|
-
|
|
27
16
|
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; }
|
|
28
|
-
|
|
29
17
|
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; }
|
|
30
|
-
|
|
31
18
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
32
19
|
import ResizeObserver from 'rc-resize-observer';
|
|
33
20
|
import { Button, Checkbox, Form, Input, Popover, Space, Modal, message, Select, Empty, InputNumber } from 'antd';
|
|
@@ -70,23 +57,17 @@ var components = [{
|
|
|
70
57
|
}, item.extraProps));
|
|
71
58
|
}
|
|
72
59
|
}];
|
|
73
|
-
|
|
74
60
|
var getStorageData = function getData(storageKey) {
|
|
75
61
|
var data = localStorage.getItem("filter-storage-".concat(storageKey));
|
|
76
|
-
|
|
77
62
|
if (data) {
|
|
78
63
|
return JSON.parse(data);
|
|
79
64
|
}
|
|
80
|
-
|
|
81
65
|
return null;
|
|
82
66
|
};
|
|
83
|
-
|
|
84
|
-
var setStorageData = function setData(storageKey, data) {
|
|
67
|
+
var setStorageData = function setData(storageKey, data, item) {
|
|
85
68
|
localStorage.setItem("filter-storage-".concat(storageKey), JSON.stringify(data));
|
|
86
69
|
};
|
|
87
|
-
|
|
88
70
|
var DEFAULT_TAB_TITLE = '默认';
|
|
89
|
-
|
|
90
71
|
function setComponents(items) {
|
|
91
72
|
var compMap = new Map(components.map(function (item) {
|
|
92
73
|
return [item.type, item];
|
|
@@ -96,24 +77,22 @@ function setComponents(items) {
|
|
|
96
77
|
});
|
|
97
78
|
components = _toConsumableArray(compMap.values());
|
|
98
79
|
}
|
|
99
|
-
|
|
100
80
|
function setStorage(getData, setData) {
|
|
101
81
|
getStorageData = getData;
|
|
102
82
|
setStorageData = setData;
|
|
103
83
|
}
|
|
104
|
-
|
|
105
84
|
function Filter(props) {
|
|
106
85
|
var data = props.data,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
86
|
+
defaultValueProp = props.defaultValue,
|
|
87
|
+
onChange = props.onChange,
|
|
88
|
+
value = props.value,
|
|
89
|
+
defaultActiveKeys = props.defaultActiveKeys,
|
|
90
|
+
storageKey = props.storageKey,
|
|
91
|
+
onValuesChange = props.onValuesChange,
|
|
92
|
+
style = props.style,
|
|
93
|
+
simple = props.simple,
|
|
94
|
+
_props$defaultCollaps = props.defaultCollapsed,
|
|
95
|
+
defaultCollapsed = _props$defaultCollaps === void 0 ? true : _props$defaultCollaps;
|
|
117
96
|
var prefixCls = "".concat(PREFIX_CLS, "-filter");
|
|
118
97
|
var defaultValue = useMemo(function () {
|
|
119
98
|
return defaultValueProp || value;
|
|
@@ -122,7 +101,6 @@ function Filter(props) {
|
|
|
122
101
|
if (defaultActiveKeys) {
|
|
123
102
|
return new Set(defaultActiveKeys);
|
|
124
103
|
}
|
|
125
|
-
|
|
126
104
|
return new Set(data.map(function (item) {
|
|
127
105
|
return item.key;
|
|
128
106
|
}));
|
|
@@ -132,141 +110,120 @@ function Filter(props) {
|
|
|
132
110
|
return [item.type, item];
|
|
133
111
|
}));
|
|
134
112
|
}, []);
|
|
135
|
-
|
|
136
113
|
var _useState = useState(defaultKeys),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
114
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
115
|
+
activeKeys = _useState2[0],
|
|
116
|
+
setActiveKeys = _useState2[1];
|
|
141
117
|
var _useState3 = useState(''),
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
118
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
119
|
+
keywords = _useState4[0],
|
|
120
|
+
setKeywords = _useState4[1];
|
|
146
121
|
var _useState5 = useState([{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
122
|
+
title: DEFAULT_TAB_TITLE,
|
|
123
|
+
value: defaultValue || value
|
|
124
|
+
}]),
|
|
125
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
126
|
+
tabs = _useState6[0],
|
|
127
|
+
setTabs = _useState6[1];
|
|
154
128
|
var _useState7 = useState(0),
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
129
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
130
|
+
active = _useState8[0],
|
|
131
|
+
setActive = _useState8[1];
|
|
159
132
|
var _useState9 = useState(false),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
133
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
134
|
+
showModal = _useState10[0],
|
|
135
|
+
setShowModal = _useState10[1];
|
|
164
136
|
var _Form$useForm = Form.useForm(),
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
137
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
138
|
+
modalForm = _Form$useForm2[0];
|
|
168
139
|
var _Form$useForm3 = Form.useForm(),
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
140
|
+
_Form$useForm4 = _slicedToArray(_Form$useForm3, 1),
|
|
141
|
+
form = _Form$useForm4[0];
|
|
172
142
|
var _useState11 = useState(0),
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
143
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
144
|
+
width = _useState12[0],
|
|
145
|
+
setWidth = _useState12[1];
|
|
177
146
|
var _useState13 = useState(defaultCollapsed),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
147
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
148
|
+
collapsed = _useState14[0],
|
|
149
|
+
setCollapsed = _useState14[1];
|
|
182
150
|
var _useRequest = useRequest(function () {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return getStorageData(storageKey);
|
|
188
|
-
}, {
|
|
189
|
-
loadingState: false,
|
|
190
|
-
onSuccess: function onSuccess(res) {
|
|
191
|
-
if (res !== null) {
|
|
192
|
-
setTabs(function (prev) {
|
|
193
|
-
return [prev[0]].concat(_toConsumableArray(res));
|
|
194
|
-
});
|
|
151
|
+
if (!storageKey) {
|
|
152
|
+
return null;
|
|
195
153
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
154
|
+
return getStorageData(storageKey);
|
|
155
|
+
}, {
|
|
156
|
+
loadingState: false,
|
|
157
|
+
onSuccess: function onSuccess(res) {
|
|
158
|
+
if (res !== null) {
|
|
159
|
+
setTabs(function (prev) {
|
|
160
|
+
return [prev[0]].concat(_toConsumableArray(res));
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
init = _useRequest.run;
|
|
200
166
|
useEffect(function () {
|
|
201
167
|
init();
|
|
202
168
|
}, []);
|
|
203
169
|
useEffect(function () {
|
|
204
|
-
if (
|
|
170
|
+
if (value) {
|
|
205
171
|
form.setFieldsValue(value);
|
|
206
172
|
}
|
|
207
173
|
}, [value]);
|
|
208
174
|
var handleChangeKeywords = useDebounce(setKeywords, 300);
|
|
209
|
-
|
|
210
175
|
var toggleModal = function toggleModal() {
|
|
211
176
|
setShowModal(function (prev) {
|
|
212
177
|
return !prev;
|
|
213
178
|
});
|
|
214
179
|
};
|
|
215
|
-
|
|
216
180
|
var handleValuesChange = function handleValuesChange(changedValues, allValues) {
|
|
217
181
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(changedValues, allValues, form);
|
|
218
182
|
};
|
|
219
|
-
|
|
220
183
|
var handleSave = function handleSave(_ref) {
|
|
221
184
|
var title = _ref.name;
|
|
222
185
|
var index = tabs.findIndex(function (item) {
|
|
223
186
|
return item.title === title;
|
|
224
187
|
});
|
|
225
|
-
|
|
226
188
|
var next = _toConsumableArray(tabs);
|
|
227
|
-
|
|
228
189
|
var tab = {
|
|
229
190
|
title: title,
|
|
230
|
-
value:
|
|
191
|
+
value: form.getFieldsValue()
|
|
231
192
|
};
|
|
232
|
-
|
|
233
193
|
if (index >= 0) {
|
|
234
|
-
next[index] = tab;
|
|
194
|
+
next[index] = _objectSpread(_objectSpread({}, next[index]), tab);
|
|
235
195
|
} else {
|
|
236
196
|
index = next.length;
|
|
237
197
|
next.push(tab);
|
|
238
198
|
}
|
|
239
|
-
|
|
240
199
|
if (!!storageKey) {
|
|
241
|
-
setStorageData(storageKey, next.slice(1)
|
|
200
|
+
setStorageData(storageKey, next.slice(1), {
|
|
201
|
+
type: 'set',
|
|
202
|
+
target: next[index]
|
|
203
|
+
});
|
|
242
204
|
}
|
|
243
|
-
|
|
244
205
|
setTabs(next);
|
|
245
206
|
setActive(index);
|
|
246
207
|
setShowModal(false);
|
|
247
208
|
};
|
|
248
|
-
|
|
249
209
|
var handleOk = /*#__PURE__*/function () {
|
|
250
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/
|
|
210
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
251
211
|
var values;
|
|
252
|
-
return
|
|
212
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
253
213
|
while (1) {
|
|
254
214
|
switch (_context.prev = _context.next) {
|
|
255
215
|
case 0:
|
|
256
216
|
_context.prev = 0;
|
|
257
217
|
_context.next = 3;
|
|
258
218
|
return modalForm.validateFields();
|
|
259
|
-
|
|
260
219
|
case 3:
|
|
261
220
|
values = _context.sent;
|
|
262
221
|
handleSave(values);
|
|
263
222
|
_context.next = 9;
|
|
264
223
|
break;
|
|
265
|
-
|
|
266
224
|
case 7:
|
|
267
225
|
_context.prev = 7;
|
|
268
226
|
_context.t0 = _context["catch"](0);
|
|
269
|
-
|
|
270
227
|
case 9:
|
|
271
228
|
case "end":
|
|
272
229
|
return _context.stop();
|
|
@@ -274,68 +231,56 @@ function Filter(props) {
|
|
|
274
231
|
}
|
|
275
232
|
}, _callee, null, [[0, 7]]);
|
|
276
233
|
}));
|
|
277
|
-
|
|
278
234
|
return function handleOk() {
|
|
279
235
|
return _ref2.apply(this, arguments);
|
|
280
236
|
};
|
|
281
237
|
}();
|
|
282
|
-
|
|
283
|
-
var handleReset = function handleReset() {
|
|
284
|
-
form.resetFields();
|
|
285
|
-
|
|
286
|
-
if (onChange) {
|
|
287
|
-
onChange(form.getFieldsValue(true));
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
|
|
291
238
|
var handleAddTab = function handleAddTab() {
|
|
292
239
|
if (tabs.length > 6) {
|
|
293
240
|
message.warning('查询方案总数不可超过6个');
|
|
294
241
|
return;
|
|
295
242
|
}
|
|
296
|
-
|
|
297
243
|
modalForm.setFieldsValue({
|
|
298
244
|
name: active === 0 ? '' : tabs[active].title
|
|
299
245
|
});
|
|
300
246
|
toggleModal();
|
|
301
247
|
};
|
|
302
|
-
|
|
303
248
|
var handleDelete = function handleDelete() {
|
|
304
249
|
if (active === 0) {
|
|
305
250
|
message.warning('不允许删除默认');
|
|
306
251
|
return;
|
|
307
252
|
}
|
|
308
|
-
|
|
253
|
+
var tab = tabs[active];
|
|
309
254
|
Modal.confirm({
|
|
310
255
|
title: '提示',
|
|
311
|
-
content: "\u786E\u8BA4\u5220\u9664".concat(
|
|
256
|
+
content: "\u786E\u8BA4\u5220\u9664".concat(tab.title, "\uFF1F"),
|
|
312
257
|
maskClosable: true,
|
|
313
258
|
width: 300,
|
|
314
259
|
onOk: function onOk() {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
next.splice(active, 1);
|
|
320
|
-
return next;
|
|
321
|
-
});
|
|
322
|
-
setActive(active - 1);
|
|
323
|
-
|
|
260
|
+
var index = active - 1;
|
|
261
|
+
var next = _toConsumableArray(tabs);
|
|
262
|
+
form.setFieldsValue(next[index].value);
|
|
263
|
+
next.splice(active, 1);
|
|
324
264
|
if (!!storageKey) {
|
|
325
|
-
setStorageData(storageKey,
|
|
326
|
-
|
|
327
|
-
|
|
265
|
+
setStorageData(storageKey, next.slice(1), {
|
|
266
|
+
type: 'delete',
|
|
267
|
+
target: tab
|
|
268
|
+
});
|
|
328
269
|
}
|
|
270
|
+
setTabs(next);
|
|
271
|
+
setActive(index);
|
|
329
272
|
}
|
|
330
273
|
});
|
|
331
274
|
};
|
|
332
|
-
|
|
333
275
|
var handleFinish = function handleFinish(val) {
|
|
334
276
|
if (onChange) {
|
|
335
277
|
onChange(_objectSpread(_objectSpread({}, value), val));
|
|
336
278
|
}
|
|
337
279
|
};
|
|
338
|
-
|
|
280
|
+
var handleReset = function handleReset() {
|
|
281
|
+
form.resetFields();
|
|
282
|
+
handleFinish(form.getFieldsValue());
|
|
283
|
+
};
|
|
339
284
|
var handleTabChange = function handleTabChange(index) {
|
|
340
285
|
if (index !== active) {
|
|
341
286
|
setActive(index);
|
|
@@ -343,31 +288,25 @@ function Filter(props) {
|
|
|
343
288
|
handleFinish(form.getFieldsValue());
|
|
344
289
|
}
|
|
345
290
|
};
|
|
346
|
-
|
|
347
291
|
var handleActiveKey = function handleActiveKey(key, value) {
|
|
348
292
|
setActiveKeys(function (prev) {
|
|
349
293
|
var next = new Set(prev);
|
|
350
|
-
|
|
351
294
|
if (value) {
|
|
352
295
|
next.add(key);
|
|
353
296
|
} else {
|
|
354
297
|
next.delete(key);
|
|
355
298
|
}
|
|
356
|
-
|
|
357
299
|
return next;
|
|
358
300
|
});
|
|
359
301
|
};
|
|
360
|
-
|
|
361
302
|
var items = useMemo(function () {
|
|
362
303
|
if (keywords) {
|
|
363
304
|
return data.filter(function (item) {
|
|
364
305
|
return item.label ? item.label.includes(keywords) : true;
|
|
365
306
|
});
|
|
366
307
|
}
|
|
367
|
-
|
|
368
308
|
return data;
|
|
369
309
|
}, [keywords, data]);
|
|
370
|
-
|
|
371
310
|
var getColStyle = function getColStyle() {
|
|
372
311
|
var colSpan = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
373
312
|
return {
|
|
@@ -375,56 +314,44 @@ function Filter(props) {
|
|
|
375
314
|
padding: '0 8px'
|
|
376
315
|
};
|
|
377
316
|
};
|
|
378
|
-
|
|
379
317
|
var _useMemo = useMemo(function () {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
318
|
+
var getSet = function getSet(items) {
|
|
319
|
+
return new Set(items.map(function (item) {
|
|
320
|
+
return item.key;
|
|
321
|
+
}));
|
|
322
|
+
};
|
|
323
|
+
var result = data.filter(function (item) {
|
|
324
|
+
if (activeKeys.has(item.key)) {
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
});
|
|
329
|
+
if (!width) {
|
|
330
|
+
return [getSet(result), false];
|
|
389
331
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
var _compMap$get;
|
|
405
|
-
|
|
406
|
-
var item = result[i];
|
|
407
|
-
var itemWidth = getColStyle(item.colSpan || (item.type ? (_compMap$get = compMap.get(item.type)) === null || _compMap$get === void 0 ? void 0 : _compMap$get.colSpan : 1)).width;
|
|
408
|
-
size += itemWidth;
|
|
409
|
-
|
|
410
|
-
if (size > width - btnsWidth) {
|
|
411
|
-
btnsVisible = true;
|
|
412
|
-
break;
|
|
332
|
+
var btnsWidth = simple ? 208 : 248;
|
|
333
|
+
var btnsVisible = false;
|
|
334
|
+
var size = 0;
|
|
335
|
+
var end = 0;
|
|
336
|
+
for (var i = 0; i < result.length; i++) {
|
|
337
|
+
var _compMap$get;
|
|
338
|
+
var item = result[i];
|
|
339
|
+
var itemWidth = getColStyle(item.colSpan || (item.type ? (_compMap$get = compMap.get(item.type)) === null || _compMap$get === void 0 ? void 0 : _compMap$get.colSpan : 1)).width;
|
|
340
|
+
size += itemWidth;
|
|
341
|
+
if (size > width - btnsWidth) {
|
|
342
|
+
btnsVisible = true;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
end = i;
|
|
413
346
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
return [getSet(result.slice(0, end + 1)), btnsVisible];
|
|
423
|
-
}, [data, width, collapsed, simple, activeKeys]),
|
|
424
|
-
_useMemo2 = _slicedToArray(_useMemo, 2),
|
|
425
|
-
cols = _useMemo2[0],
|
|
426
|
-
showCollapse = _useMemo2[1];
|
|
427
|
-
|
|
347
|
+
if (!collapsed) {
|
|
348
|
+
return [getSet(result), btnsVisible];
|
|
349
|
+
}
|
|
350
|
+
return [getSet(result.slice(0, end + 1)), btnsVisible];
|
|
351
|
+
}, [data, width, collapsed, simple, activeKeys]),
|
|
352
|
+
_useMemo2 = _slicedToArray(_useMemo, 2),
|
|
353
|
+
cols = _useMemo2[0],
|
|
354
|
+
showCollapse = _useMemo2[1];
|
|
428
355
|
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
429
356
|
onResize: function onResize(size) {
|
|
430
357
|
if (size.width) {
|
|
@@ -436,7 +363,7 @@ function Filter(props) {
|
|
|
436
363
|
style: style
|
|
437
364
|
}, /*#__PURE__*/React.createElement(Modal, {
|
|
438
365
|
destroyOnClose: true,
|
|
439
|
-
|
|
366
|
+
open: showModal,
|
|
440
367
|
onCancel: toggleModal,
|
|
441
368
|
onOk: handleOk,
|
|
442
369
|
title: "\u4FDD\u5B58\u65B9\u6848",
|
|
@@ -474,7 +401,6 @@ function Filter(props) {
|
|
|
474
401
|
var className = classNames("".concat(prefixCls, "-form-item"), {
|
|
475
402
|
hidden: !cols.has(item.key) ? true : false
|
|
476
403
|
});
|
|
477
|
-
|
|
478
404
|
if (item.renderFormItem) {
|
|
479
405
|
return /*#__PURE__*/React.createElement("div", {
|
|
480
406
|
style: getColStyle(item.colSpan),
|
|
@@ -482,24 +408,21 @@ function Filter(props) {
|
|
|
482
408
|
key: item.key
|
|
483
409
|
}, item.renderFormItem(form));
|
|
484
410
|
}
|
|
485
|
-
|
|
486
411
|
if (!item.type) {
|
|
487
412
|
return null;
|
|
488
413
|
}
|
|
489
|
-
|
|
490
414
|
var target = compMap.get(item.type);
|
|
491
|
-
|
|
492
415
|
if (target === undefined) {
|
|
493
416
|
return null;
|
|
494
417
|
}
|
|
495
|
-
|
|
496
418
|
return /*#__PURE__*/React.createElement("div", {
|
|
497
419
|
style: getColStyle(item.colSpan || target.colSpan),
|
|
498
420
|
className: className,
|
|
499
421
|
key: item.key
|
|
500
422
|
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
501
423
|
name: item.key,
|
|
502
|
-
label: item.hideLabel ? undefined : item.label
|
|
424
|
+
label: item.hideLabel ? undefined : item.label,
|
|
425
|
+
initialValue: item.initialValue
|
|
503
426
|
}, target.render(item)));
|
|
504
427
|
}), /*#__PURE__*/React.createElement("div", {
|
|
505
428
|
className: "".concat(prefixCls, "-btns")
|
|
@@ -618,7 +541,6 @@ function Filter(props) {
|
|
|
618
541
|
mask: "url(#filter-down-mask)"
|
|
619
542
|
}))))))))));
|
|
620
543
|
}
|
|
621
|
-
|
|
622
544
|
Filter.setComponents = setComponents;
|
|
623
545
|
Filter.setStorage = setStorage;
|
|
624
546
|
Filter.defaultProps = {};
|
package/es/Filter/typings.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export interface FilterItemType<T = any> {
|
|
|
9
9
|
hideLabel?: boolean;
|
|
10
10
|
extraProps?: Record<string, any>;
|
|
11
11
|
renderFormItem?: (form: FormInstance<T>) => ReactElement;
|
|
12
|
+
initialValue?: any;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export interface FilterProps<T extends Record<string, any> = Record<string, any>> {
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
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; }
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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; }
|
|
6
|
-
|
|
7
4
|
import React, { useContext, useMemo } from 'react';
|
|
8
5
|
import { FormContext } from 'antd/es/form/context';
|
|
9
6
|
import { PREFIX_CLS } from '../constants';
|
|
10
|
-
|
|
11
7
|
function FormHorizontal(props) {
|
|
12
8
|
var prefixCls = PREFIX_CLS;
|
|
13
9
|
var context = useContext(FormContext);
|
|
@@ -31,5 +27,4 @@ function FormHorizontal(props) {
|
|
|
31
27
|
className: "".concat(prefixCls, "-form-horzontal")
|
|
32
28
|
}, props)));
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
export default FormHorizontal;
|