@arim-aisdc/public-components 2.0.8 → 2.0.9
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/dist/assets/iconfont/theme-dark/four/demo.css +539 -539
- package/dist/assets/iconfont/theme-dark/four/demo_index.html +306 -306
- package/dist/assets/iconfont/theme-dark/four/iconfont.css +37 -37
- package/dist/assets/iconfont/theme-dark/four/iconfont.json +44 -44
- package/dist/assets/images/data.empty-dark.svg +45 -0
- package/dist/components/SplitPane/splitPane.less +2 -2
- package/dist/components/TableMax/TableBody/Row.d.ts +0 -1
- package/dist/components/TableMax/TableBody/index.d.ts +2 -2
- package/dist/components/TableMax/TableBody/index.js +8 -12
- package/dist/components/TableMax/TableHeader/index.d.ts +1 -2
- package/dist/components/TableMax/TableHeader/index.js +15 -26
- package/dist/components/TableMax/TableHeader/utils.js +2 -2
- package/dist/components/TableMax/TableMax.js +188 -176
- package/dist/components/TableMax/components/ColumnEdit/index.less +1 -0
- package/dist/components/TableMax/tableMax.less +17 -4
- package/dist/components/TableMax/utils.d.ts +2 -1
- package/dist/components/TableMax/utils.js +25 -21
- package/package.json +102 -103
|
@@ -3,16 +3,15 @@ var _this = this;
|
|
|
3
3
|
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; }
|
|
4
4
|
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); } }
|
|
5
5
|
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); }); }; }
|
|
6
|
-
function
|
|
6
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
|
+
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."); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
10
|
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; }
|
|
8
11
|
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; }
|
|
9
12
|
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; }
|
|
10
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
14
|
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); }
|
|
12
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
15
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
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."); }
|
|
18
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); }
|
|
@@ -22,9 +21,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
22
21
|
import { MinusSquareOutlined, PlusSquareOutlined } from '@ant-design/icons';
|
|
23
22
|
import { getCoreRowModel, getExpandedRowModel, getFacetedUniqueValues, getFilteredRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
|
|
24
23
|
import { Button, Checkbox, Form, Pagination } from 'antd';
|
|
25
|
-
import { produce } from 'immer';
|
|
26
|
-
import { cloneDeep, debounce } from 'lodash';
|
|
27
24
|
import dayjs from 'dayjs';
|
|
25
|
+
import { cloneDeep, debounce } from 'lodash';
|
|
28
26
|
import React, { createContext, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
29
27
|
import { DndProvider } from 'react-dnd';
|
|
30
28
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
@@ -38,7 +36,8 @@ import ColumnSetting from "./components/ColumnSetting";
|
|
|
38
36
|
import customSortFns, { setDefaultSortFn } from "./components/ColumnSort/customSortFns";
|
|
39
37
|
import PaginationV2 from "./components/PaginationV2";
|
|
40
38
|
import "./tableMax.less";
|
|
41
|
-
import { getFormatFilters, getFormatSorting, getSizeInfo, operationColumnNoTooltips
|
|
39
|
+
import { getFormatFilters, getFormatSorting, getSizeInfo, operationColumnNoTooltips } from "./utils";
|
|
40
|
+
import { useUpdateEffect } from 'ahooks';
|
|
42
41
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
43
42
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
44
43
|
export var ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
@@ -49,8 +48,15 @@ export var ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
|
49
48
|
return ColumnType;
|
|
50
49
|
}({});
|
|
51
50
|
export var TableContext = /*#__PURE__*/createContext({});
|
|
51
|
+
var allColumnCount = 0;
|
|
52
|
+
var allColumnWidth = 0;
|
|
53
|
+
var visibleColumnsSizing = {};
|
|
54
|
+
var CACHE_MAX_AGE = 1 * 60 * 60 * 1000;
|
|
55
|
+
var getCurrentRouterName = function getCurrentRouterName() {
|
|
56
|
+
return window.location.pathname.slice(1);
|
|
57
|
+
};
|
|
52
58
|
var TableMax = function TableMax(_ref) {
|
|
53
|
-
var _JSON$parse, _tableContentRef$
|
|
59
|
+
var _JSON$parse, _tableContentRef$curr;
|
|
54
60
|
var tableId = _ref.tableId,
|
|
55
61
|
originColumns = _ref.columns,
|
|
56
62
|
_ref$datas = _ref.datas,
|
|
@@ -168,6 +174,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
168
174
|
tableTooltip = _ref$tooltip === void 0 ? true : _ref$tooltip,
|
|
169
175
|
_ref$showLessItems = _ref.showLessItems,
|
|
170
176
|
showLessItems = _ref$showLessItems === void 0 ? false : _ref$showLessItems;
|
|
177
|
+
var tableMaxRef = useRef(null);
|
|
171
178
|
var columns = useMemo(function () {
|
|
172
179
|
// 给columns配置默认的过滤函数,排序函数,操作列取消tooltip
|
|
173
180
|
return operationColumnNoTooltips(setDefaultSortFn(setDefaultFilterFn(cloneDeep(originColumns))));
|
|
@@ -187,7 +194,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
187
194
|
|
|
188
195
|
/**表格配置信息缓存 */
|
|
189
196
|
var currentUserId = userId || ((_JSON$parse = JSON.parse(localStorage.getItem('poi-permission') || '{}')) === null || _JSON$parse === void 0 || (_JSON$parse = _JSON$parse.currentUser) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.id);
|
|
190
|
-
var tableKey = "".concat(tableKeyPrefixCls, "-").concat(tableId, "-").concat(currentUserId);
|
|
197
|
+
var tableKey = "".concat(tableKeyPrefixCls, "-").concat(getCurrentRouterName(), "-").concat(tableId, "-").concat(currentUserId);
|
|
191
198
|
|
|
192
199
|
/**表格数据 */
|
|
193
200
|
var initColumnOrder = columns === null || columns === void 0 ? void 0 : columns.map(function (column) {
|
|
@@ -249,18 +256,17 @@ var TableMax = function TableMax(_ref) {
|
|
|
249
256
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
250
257
|
columnPinning = _useState18[0],
|
|
251
258
|
setColumnPinning = _useState18[1];
|
|
252
|
-
|
|
253
|
-
// const [columnSizes, setColumnSizes] = useState();
|
|
259
|
+
// 实际列宽(计算得出)
|
|
254
260
|
var _useState19 = useState({}),
|
|
255
261
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
256
262
|
columnSizing = _useState20[0],
|
|
257
263
|
setColumnSizing = _useState20[1];
|
|
264
|
+
// 初始化列宽(缓存合并column的size)
|
|
258
265
|
var _useState21 = useState({}),
|
|
259
266
|
_useState22 = _slicedToArray(_useState21, 2),
|
|
260
267
|
initColumnsSizing = _useState22[0],
|
|
261
268
|
setInitColumnsSizing = _useState22[1];
|
|
262
269
|
|
|
263
|
-
// const [visibleColumnSizes, setVisibleColumnSizes] = useState([]);
|
|
264
270
|
/**列筛选 */
|
|
265
271
|
var _useState23 = useState(defaultColumnFilters),
|
|
266
272
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
@@ -316,6 +322,64 @@ var TableMax = function TableMax(_ref) {
|
|
|
316
322
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
317
323
|
pinShadowVisible = _useState36[0],
|
|
318
324
|
setPinShadowVisible = _useState36[1];
|
|
325
|
+
var changeColumnSizingHandler = function changeColumnSizingHandler(columnsSizeMap, changedColumnKey) {
|
|
326
|
+
var _Object$keys$filter, _tableMaxRef$current, _tableMaxRef$current2;
|
|
327
|
+
// 列宽数量(存在宽度)
|
|
328
|
+
var hasColumnCount = ((_Object$keys$filter = Object.keys(columnsSizeMap).filter(function (item) {
|
|
329
|
+
return !!columnsSizeMap[item];
|
|
330
|
+
})) === null || _Object$keys$filter === void 0 ? void 0 : _Object$keys$filter.length) || 0;
|
|
331
|
+
// 列宽数量(不存在宽度)
|
|
332
|
+
var remainColumnCount = allColumnCount - hasColumnCount;
|
|
333
|
+
// 列宽之和
|
|
334
|
+
allColumnWidth = Object.keys(columnsSizeMap).reduce(function (totalWidth, currKey) {
|
|
335
|
+
// eslint-disable-next-line no-param-reassign
|
|
336
|
+
return totalWidth += Number(columnsSizeMap[currKey] || 0);
|
|
337
|
+
}, 0);
|
|
338
|
+
// 剩余容器宽度
|
|
339
|
+
var remainTableContainerWidth = ((_tableMaxRef$current = tableMaxRef.current) === null || _tableMaxRef$current === void 0 ? void 0 : _tableMaxRef$current.clientWidth) - allColumnWidth - 10;
|
|
340
|
+
// 列宽Map(增加空白宽度部分)
|
|
341
|
+
var newColumnSizeMap = _objectSpread({}, columnsSizeMap);
|
|
342
|
+
// 为不存在宽度的列设置列宽
|
|
343
|
+
if (remainColumnCount) {
|
|
344
|
+
// debugger
|
|
345
|
+
var defaultMinSize = 120;
|
|
346
|
+
var defaultMaxSize = 240;
|
|
347
|
+
var aveSize = Math.max(Math.min(remainTableContainerWidth / remainColumnCount, defaultMaxSize), defaultMinSize);
|
|
348
|
+
// 更新初始化列宽Map, 重新计算列宽之和
|
|
349
|
+
allColumnWidth = Object.keys(columnsSizeMap).reduce(function (totalWidth, currKey) {
|
|
350
|
+
newColumnSizeMap[currKey] = newColumnSizeMap[currKey] ? newColumnSizeMap[currKey] : aveSize;
|
|
351
|
+
// eslint-disable-next-line no-param-reassign
|
|
352
|
+
return totalWidth += Number(newColumnSizeMap[currKey] || 0);
|
|
353
|
+
}, 0);
|
|
354
|
+
}
|
|
355
|
+
remainTableContainerWidth = ((_tableMaxRef$current2 = tableMaxRef.current) === null || _tableMaxRef$current2 === void 0 ? void 0 : _tableMaxRef$current2.clientWidth) - allColumnWidth - 10;
|
|
356
|
+
if (remainTableContainerWidth > 0) {
|
|
357
|
+
var count = allColumnCount - (changedColumnKey ? 1 : 0) - (columnsSizeMap[ColumnType.Expander] ? 1 : 0) - (columnsSizeMap[ColumnType.Selection] ? 1 : 0);
|
|
358
|
+
if (count > 0) {
|
|
359
|
+
var aveRemainWidth = count <= 0 ? remainTableContainerWidth : remainTableContainerWidth / count;
|
|
360
|
+
// debugger
|
|
361
|
+
for (var _i = 0, _Object$keys = Object.keys(columnsSizeMap); _i < _Object$keys.length; _i++) {
|
|
362
|
+
var key = _Object$keys[_i];
|
|
363
|
+
if (key !== changedColumnKey && key !== ColumnType.Expander && key !== ColumnType.Selection) {
|
|
364
|
+
newColumnSizeMap[key] += aveRemainWidth;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return newColumnSizeMap;
|
|
370
|
+
};
|
|
371
|
+
var onColumnSizingChange = function onColumnSizingChange(data) {
|
|
372
|
+
var _localStorage$getItem, _Object$keys2;
|
|
373
|
+
var changedColumn = data === null || data === void 0 ? void 0 : data();
|
|
374
|
+
setInitColumnsSizing(_objectSpread(_objectSpread({}, initColumnsSizing), changedColumn));
|
|
375
|
+
visibleColumnsSizing = _objectSpread(_objectSpread({}, visibleColumnsSizing), changedColumn);
|
|
376
|
+
var cache = JSON.parse((_localStorage$getItem = localStorage.getItem(tableKey)) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : '{}');
|
|
377
|
+
localStorage.setItem(tableKey, JSON.stringify(_objectSpread(_objectSpread({}, cache), {}, {
|
|
378
|
+
columnSizing: _objectSpread(_objectSpread({}, cache.columnSizing), changedColumn),
|
|
379
|
+
editTime: new Date()
|
|
380
|
+
})));
|
|
381
|
+
setColumnSizing(changeColumnSizingHandler(visibleColumnsSizing, (_Object$keys2 = Object.keys(changedColumn)) === null || _Object$keys2 === void 0 ? void 0 : _Object$keys2[0]));
|
|
382
|
+
};
|
|
319
383
|
|
|
320
384
|
// table
|
|
321
385
|
var table = useReactTable({
|
|
@@ -352,8 +416,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
352
416
|
getFacetedUniqueValues: getFacetedUniqueValues(),
|
|
353
417
|
getFilteredRowModel: getFilteredRowModel(),
|
|
354
418
|
onGlobalFilterChange: setGlobalFilter,
|
|
355
|
-
onColumnSizingChange:
|
|
356
|
-
// setColumnSizing,
|
|
419
|
+
onColumnSizingChange: onColumnSizingChange,
|
|
357
420
|
manualPagination: true,
|
|
358
421
|
manualSorting: manualSorting,
|
|
359
422
|
manualFiltering: manualFiltering,
|
|
@@ -385,13 +448,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
385
448
|
tableContainerWidth = _useState38[0],
|
|
386
449
|
setTableContainerWidth = _useState38[1];
|
|
387
450
|
|
|
388
|
-
// 默认最后一个空白列一直存在,hasVerticalScrollBar一直为true, TODO: 优化
|
|
389
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
390
|
-
var _useState39 = useState(true),
|
|
391
|
-
_useState40 = _slicedToArray(_useState39, 2),
|
|
392
|
-
hasVerticalScrollBar = _useState40[0],
|
|
393
|
-
setHasVerticalScrollBar = _useState40[1];
|
|
394
|
-
|
|
395
451
|
// 暴露给外部的api
|
|
396
452
|
useImperativeHandle(refInstance, function () {
|
|
397
453
|
return {
|
|
@@ -428,8 +484,32 @@ var TableMax = function TableMax(_ref) {
|
|
|
428
484
|
|
|
429
485
|
/**根据缓存数据设置一些状态 */
|
|
430
486
|
var setColumnInfoFromCache = function setColumnInfoFromCache(tableColumns) {
|
|
431
|
-
var _localStorage$
|
|
432
|
-
var cache = JSON.parse((_localStorage$
|
|
487
|
+
var _localStorage$getItem2;
|
|
488
|
+
var cache = JSON.parse((_localStorage$getItem2 = localStorage.getItem(tableKey)) !== null && _localStorage$getItem2 !== void 0 ? _localStorage$getItem2 : '{}');
|
|
489
|
+
if (cache && cache !== null && cache !== void 0 && cache.editTime && +new Date() - cache.editTime > CACHE_MAX_AGE) {
|
|
490
|
+
//设置列宽
|
|
491
|
+
// 列宽总数、列宽Map
|
|
492
|
+
var _getSizeInfo = getSizeInfo(tableColumns),
|
|
493
|
+
_allCount = _getSizeInfo.allCount,
|
|
494
|
+
_columnSizeMap = _getSizeInfo.columnSizeMap;
|
|
495
|
+
// allColumnCount = allCount;
|
|
496
|
+
// 初始化列宽Map(合并column上设置的、缓存的)
|
|
497
|
+
var _initColumnsSizeMap = _objectSpread({}, _columnSizeMap);
|
|
498
|
+
setInitColumnsSizing(_initColumnsSizeMap);
|
|
499
|
+
var _visibleColumnsSizeMap = {};
|
|
500
|
+
var _notVisibleColumns = Object.keys(columnVisibleConfig).filter(function (key) {
|
|
501
|
+
return !columnVisibleConfig[key];
|
|
502
|
+
});
|
|
503
|
+
allColumnCount = _allCount - _notVisibleColumns.length;
|
|
504
|
+
Object.keys(_initColumnsSizeMap).map(function (key) {
|
|
505
|
+
if (!_notVisibleColumns.includes(key)) {
|
|
506
|
+
_visibleColumnsSizeMap[key] = _initColumnsSizeMap[key];
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
visibleColumnsSizing = _visibleColumnsSizeMap;
|
|
510
|
+
setColumnSizing(changeColumnSizingHandler(_visibleColumnsSizeMap));
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
433
513
|
var cacheColumnVisibility = cache.columnVisibility,
|
|
434
514
|
cacheColumnOrder = cache.columnOrder,
|
|
435
515
|
cacheColumnPinning = cache.columnPinning,
|
|
@@ -437,10 +517,30 @@ var TableMax = function TableMax(_ref) {
|
|
|
437
517
|
cacheColumnSorting = cache.columnSorting,
|
|
438
518
|
cacheEnableFilters = cache.enableFilters,
|
|
439
519
|
cacheColumnSizing = cache.columnSizing;
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
520
|
+
var newColumnVisibleConfig = _objectSpread(_objectSpread({}, columnVisibleConfig), cacheColumnVisibility);
|
|
521
|
+
setColumnVisibility(newColumnVisibleConfig);
|
|
522
|
+
|
|
523
|
+
//设置列宽
|
|
524
|
+
// 列宽总数、列宽Map
|
|
525
|
+
var _getSizeInfo2 = getSizeInfo(tableColumns),
|
|
526
|
+
allCount = _getSizeInfo2.allCount,
|
|
527
|
+
columnSizeMap = _getSizeInfo2.columnSizeMap;
|
|
528
|
+
// allColumnCount = allCount;
|
|
529
|
+
// 初始化列宽Map(合并column上设置的、缓存的)
|
|
530
|
+
var initColumnsSizeMap = _objectSpread(_objectSpread({}, columnSizeMap), cacheColumnSizing);
|
|
531
|
+
setInitColumnsSizing(initColumnsSizeMap);
|
|
532
|
+
var visibleColumnsSizeMap = {};
|
|
533
|
+
var notVisibleColumns = Object.keys(newColumnVisibleConfig).filter(function (key) {
|
|
534
|
+
return !newColumnVisibleConfig[key];
|
|
535
|
+
});
|
|
536
|
+
allColumnCount = allCount - notVisibleColumns.length;
|
|
537
|
+
Object.keys(initColumnsSizeMap).map(function (key) {
|
|
538
|
+
if (!notVisibleColumns.includes(key)) {
|
|
539
|
+
visibleColumnsSizeMap[key] = initColumnsSizeMap[key];
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
visibleColumnsSizing = visibleColumnsSizeMap;
|
|
543
|
+
setColumnSizing(changeColumnSizingHandler(visibleColumnsSizeMap));
|
|
444
544
|
|
|
445
545
|
// 筛选项缓存&排序缓存
|
|
446
546
|
var tableColumnIds = tableColumns === null || tableColumns === void 0 ? void 0 : tableColumns.map(function (column) {
|
|
@@ -476,17 +576,16 @@ var TableMax = function TableMax(_ref) {
|
|
|
476
576
|
}).length === 0) {
|
|
477
577
|
arr = cacheColumnOrder;
|
|
478
578
|
}
|
|
579
|
+
// debugger
|
|
479
580
|
setColumnOrder(arr);
|
|
480
581
|
};
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
var columnSizeInfo = useMemo(function () {
|
|
484
|
-
var _localStorage$getItem2, _table$getState;
|
|
582
|
+
var setColumnsByProps = useCallback(function () {
|
|
583
|
+
var extraColumns = [];
|
|
485
584
|
if (getRowCanExpand() && columns.findIndex(function (column) {
|
|
486
585
|
return column.id === 'expander';
|
|
487
586
|
}) === -1) {
|
|
488
|
-
|
|
489
|
-
id:
|
|
587
|
+
extraColumns.unshift({
|
|
588
|
+
id: ColumnType.Expander,
|
|
490
589
|
header: function header() {
|
|
491
590
|
return null;
|
|
492
591
|
},
|
|
@@ -510,7 +609,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
510
609
|
if (canSelection && columns.findIndex(function (column) {
|
|
511
610
|
return column.id === ColumnType.Selection;
|
|
512
611
|
}) === -1 && !selectionWithoutChecked) {
|
|
513
|
-
|
|
612
|
+
extraColumns.unshift({
|
|
514
613
|
id: ColumnType.Selection,
|
|
515
614
|
tooltip: false,
|
|
516
615
|
header: function header(_ref3) {
|
|
@@ -550,98 +649,43 @@ var TableMax = function TableMax(_ref) {
|
|
|
550
649
|
size: 40
|
|
551
650
|
});
|
|
552
651
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
652
|
+
return extraColumns;
|
|
653
|
+
}, [canSelection, selectionWithoutChecked, getRowCanExpand, columns]);
|
|
654
|
+
|
|
655
|
+
// 初始化列
|
|
656
|
+
useEffect(function () {
|
|
657
|
+
if (!tableMaxRef.current) return;
|
|
658
|
+
// 根据props,自动增加勾选列/展开列
|
|
659
|
+
var newColumns = setColumnsByProps().concat(columns);
|
|
660
|
+
setTableColumns(newColumns);
|
|
661
|
+
// 根据缓存进行列设置
|
|
662
|
+
setColumnInfoFromCache(newColumns);
|
|
663
|
+
// 判断是否存在列分组
|
|
559
664
|
setHasGroup(newColumns.findIndex(function (column) {
|
|
560
665
|
var _column$columns;
|
|
561
666
|
return (column === null || column === void 0 ? void 0 : column.columns) && ((_column$columns = column.columns) === null || _column$columns === void 0 ? void 0 : _column$columns.length) > 0;
|
|
562
667
|
}) > -1);
|
|
563
|
-
// setInitTableSizeColumns([...newColumns]);
|
|
564
|
-
setColumnInfoFromCache(newColumns);
|
|
565
|
-
setInitColumnsSizing(columnsSizeMap);
|
|
566
|
-
setColumnSizing(columnsSizeMap);
|
|
567
|
-
console.log('columnsSizeMap :>> ', columnsSizeMap);
|
|
568
|
-
setTableColumns(cloneDeep(newColumns));
|
|
569
|
-
return getSizeInfo(newColumns);
|
|
570
668
|
}, [columns]);
|
|
571
669
|
|
|
572
|
-
//
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
var allCount = columnSizeInfo.allCount,
|
|
583
|
-
hasSizeCount = columnSizeInfo.hasSizeCount,
|
|
584
|
-
columns = columnSizeInfo.columns,
|
|
585
|
-
hasSizeAllWidth = columnSizeInfo.hasSizeAllWidth;
|
|
586
|
-
//表格宽度,offsetWidth?下面监听里用的clientWidth
|
|
587
|
-
// 空白宽度
|
|
588
|
-
var remainWidth = (tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.clientWidth) - hasSizeAllWidth - 10 || 0;
|
|
589
|
-
// 没有配置宽度size的列的数量
|
|
590
|
-
var remainCount = allCount - hasSizeCount;
|
|
591
|
-
var aveSize;
|
|
592
|
-
if (remainWidth > 0 && remainCount) {
|
|
593
|
-
aveSize = Math.max(remainWidth / remainCount, defaultSize);
|
|
594
|
-
} else {
|
|
595
|
-
aveSize = undefined;
|
|
596
|
-
}
|
|
597
|
-
var _setRemainColumnsWidt = setRemainColumnsWidth(columns, aveSize),
|
|
598
|
-
newColumns = _setRemainColumnsWidt.columns,
|
|
599
|
-
columnsWidthMap = _setRemainColumnsWidt.columnsWidthMap;
|
|
600
|
-
// setInitTableSizeColumns(cloneDeep(newColumns));
|
|
601
|
-
setTableColumns(cloneDeep(newColumns));
|
|
602
|
-
setInitColumnsSizing(columnsWidthMap);
|
|
603
|
-
setColumnSizing(columnsWidthMap);
|
|
604
|
-
console.log('columnsSizeMap2 :>> ', columnsWidthMap);
|
|
605
|
-
}, [columnSizeInfo]);
|
|
606
|
-
|
|
607
|
-
// 添加 or 删除 空白列
|
|
608
|
-
useEffect(function () {
|
|
609
|
-
if ((tableColumns === null || tableColumns === void 0 ? void 0 : tableColumns.length) <= 0 || !tableContainerWidth) return;
|
|
610
|
-
var placeholderColumn = table.getAllColumns().some(function (item) {
|
|
611
|
-
return item.id === ColumnType.PlaceHolder;
|
|
612
|
-
}) ? table.getColumn(ColumnType.PlaceHolder) : null;
|
|
613
|
-
// let newColumns = initTableSizeColumns;
|
|
614
|
-
var scrollBarWidth = hasVerticalScrollBar ? 10 : 0;
|
|
615
|
-
var tableColumnsWidthWithoutEmpty = table.getTotalSize() - ((placeholderColumn === null || placeholderColumn === void 0 ? void 0 : placeholderColumn.getSize()) || 0);
|
|
616
|
-
var newEmptyColumnsWidth = tableContainerWidth - tableColumnsWidthWithoutEmpty - scrollBarWidth;
|
|
617
|
-
setTableColumns(produce(function (draft) {
|
|
618
|
-
if (!placeholderColumn) {
|
|
619
|
-
if (newEmptyColumnsWidth <= 0) return;
|
|
620
|
-
draft.push({
|
|
621
|
-
id: ColumnType.PlaceHolder,
|
|
622
|
-
size: newEmptyColumnsWidth,
|
|
623
|
-
accessorKey: null,
|
|
624
|
-
header: function header() {
|
|
625
|
-
return null;
|
|
626
|
-
},
|
|
627
|
-
tooltip: false
|
|
628
|
-
});
|
|
629
|
-
} else {
|
|
630
|
-
if (newEmptyColumnsWidth === (placeholderColumn === null || placeholderColumn === void 0 ? void 0 : placeholderColumn.getSize())) return;
|
|
631
|
-
draft.some(function (item, index) {
|
|
632
|
-
if (item.id === ColumnType.PlaceHolder) {
|
|
633
|
-
if (newEmptyColumnsWidth <= 0) {
|
|
634
|
-
draft.splice(index, 1);
|
|
635
|
-
} else {
|
|
636
|
-
item.size = newEmptyColumnsWidth;
|
|
637
|
-
}
|
|
638
|
-
return true;
|
|
639
|
-
}
|
|
640
|
-
return false;
|
|
641
|
-
});
|
|
670
|
+
// 列显示隐藏改变,修改初始化列宽Map
|
|
671
|
+
useUpdateEffect(function () {
|
|
672
|
+
var visibleColumnsSizeMap = {};
|
|
673
|
+
var notVisibleColumns = Object.keys(columnVisibleConfig).filter(function (key) {
|
|
674
|
+
return !columnVisibleConfig[key];
|
|
675
|
+
});
|
|
676
|
+
allColumnCount = table.getCenterVisibleLeafColumns().length;
|
|
677
|
+
Object.keys(initColumnsSizing).map(function (key) {
|
|
678
|
+
if (!notVisibleColumns.includes(key)) {
|
|
679
|
+
visibleColumnsSizeMap[key] = initColumnsSizing[key];
|
|
642
680
|
}
|
|
643
|
-
})
|
|
644
|
-
|
|
681
|
+
});
|
|
682
|
+
visibleColumnsSizing = visibleColumnsSizeMap;
|
|
683
|
+
}, [columnVisibleConfig]);
|
|
684
|
+
|
|
685
|
+
// 容器宽度改变,重新计算列宽
|
|
686
|
+
useUpdateEffect(function () {
|
|
687
|
+
changeColumnSizingHandler(changeColumnSizingHandler(visibleColumnsSizing));
|
|
688
|
+
}, [tableContainerWidth]);
|
|
645
689
|
var _rowSelectionChange = useCallback(debounce(function (rowOriginal, row) {
|
|
646
690
|
if (rowSelectionChange) {
|
|
647
691
|
rowSelectionChange(rowOriginal, row);
|
|
@@ -700,43 +744,19 @@ var TableMax = function TableMax(_ref) {
|
|
|
700
744
|
}, [JSON.stringify(sorting), canSorting, manualSorting]);
|
|
701
745
|
useEffect(function () {
|
|
702
746
|
var myObserver = new ResizeObserver(function (entries) {
|
|
703
|
-
var
|
|
704
|
-
|
|
705
|
-
try {
|
|
706
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
707
|
-
var entrie = _step.value;
|
|
708
|
-
//@ts-ignore
|
|
709
|
-
var clientWidth = entrie.target.clientWidth;
|
|
710
|
-
setTableContainerWidth(clientWidth);
|
|
711
|
-
}
|
|
712
|
-
} catch (err) {
|
|
713
|
-
_iterator.e(err);
|
|
714
|
-
} finally {
|
|
715
|
-
_iterator.f();
|
|
716
|
-
}
|
|
747
|
+
var _entries$0$contentRec;
|
|
748
|
+
setTableContainerWidth((_entries$0$contentRec = entries[0].contentRect) === null || _entries$0$contentRec === void 0 ? void 0 : _entries$0$contentRec.width);
|
|
717
749
|
});
|
|
718
|
-
|
|
719
|
-
var dom = document.getElementById("".concat(tableId, "-TableCore"));
|
|
720
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
721
|
-
dom && myObserver.observe(dom);
|
|
750
|
+
tableMaxRef.current && myObserver.observe(tableMaxRef.current);
|
|
722
751
|
// 移除监听
|
|
723
752
|
return function () {
|
|
724
|
-
myObserver.disconnect();
|
|
753
|
+
tableMaxRef.current && myObserver.disconnect();
|
|
725
754
|
};
|
|
726
755
|
}, [tableId]);
|
|
727
756
|
|
|
728
757
|
/**缓存table数据*/
|
|
729
758
|
useEffect(function () {
|
|
730
|
-
var _localStorage$getItem3;
|
|
731
759
|
var tableState = table.getState();
|
|
732
|
-
var cache = JSON.parse((_localStorage$getItem3 = localStorage.getItem(tableKey)) !== null && _localStorage$getItem3 !== void 0 ? _localStorage$getItem3 : '{}');
|
|
733
|
-
var cacheColumnSizing = cache.columnSizing;
|
|
734
|
-
var changedColumnsSizing = {};
|
|
735
|
-
Object.keys(initColumnsSizing).forEach(function (item) {
|
|
736
|
-
if (initColumnsSizing[item] !== tableState.columnSizing[item]) {
|
|
737
|
-
changedColumnsSizing[item] = tableState.columnSizing[item];
|
|
738
|
-
}
|
|
739
|
-
});
|
|
740
760
|
localStorage.setItem(tableKey, JSON.stringify({
|
|
741
761
|
columnVisibility: tableState.columnVisibility,
|
|
742
762
|
columnPinning: tableState.columnPinning,
|
|
@@ -744,14 +764,9 @@ var TableMax = function TableMax(_ref) {
|
|
|
744
764
|
columnFilters: tableState.columnFilters,
|
|
745
765
|
columnSorting: tableState.sorting,
|
|
746
766
|
enableFilters: enableFilters,
|
|
747
|
-
|
|
748
|
-
// columnSizes: tableState.columnSizes,
|
|
749
|
-
columnSizing: _objectSpread(_objectSpread({}, cacheColumnSizing), changedColumnsSizing)
|
|
767
|
+
editTime: new Date()
|
|
750
768
|
}));
|
|
751
|
-
}, [table.getState().columnVisibility, table.getState().columnPinning, table.getState().columnOrder, table.getState().columnFilters, table.getState().sorting, enableFilters
|
|
752
|
-
// @ts-ignore
|
|
753
|
-
// table.getState().columnSizes,
|
|
754
|
-
table.getState().columnSizing]);
|
|
769
|
+
}, [table.getState().columnVisibility, table.getState().columnPinning, table.getState().columnOrder, table.getState().columnFilters, table.getState().sorting, enableFilters]);
|
|
755
770
|
var reorderRow = useCallback(function (fromDatas, toDatas) {
|
|
756
771
|
var draggedRow = fromDatas.draggedRow,
|
|
757
772
|
isMultipleDrag = fromDatas.isMultipleDrag,
|
|
@@ -828,13 +843,13 @@ var TableMax = function TableMax(_ref) {
|
|
|
828
843
|
|
|
829
844
|
// 把row数据填充到表单
|
|
830
845
|
var setFormData = function setFormData(rowOriginal) {
|
|
831
|
-
var _Object$
|
|
846
|
+
var _Object$keys3;
|
|
832
847
|
var formData = {};
|
|
833
848
|
var columnsMap = {};
|
|
834
849
|
tableColumns === null || tableColumns === void 0 || tableColumns.forEach(function (col) {
|
|
835
850
|
columnsMap[col.accessorKey] = col;
|
|
836
851
|
});
|
|
837
|
-
(_Object$
|
|
852
|
+
(_Object$keys3 = Object.keys(rowOriginal)) === null || _Object$keys3 === void 0 || _Object$keys3.forEach(function (item) {
|
|
838
853
|
var _columnsMap$item, _columnsMap$item2;
|
|
839
854
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
840
855
|
((_columnsMap$item = columnsMap[item]) === null || _columnsMap$item === void 0 ? void 0 : _columnsMap$item.editComType) === InputType.DatePicker ? formData[item] = rowOriginal[item] ? dayjs(rowOriginal[item]) : null : (_columnsMap$item2 = columnsMap[item]) !== null && _columnsMap$item2 !== void 0 && _columnsMap$item2.shouldConvert ? formData[item] = columnsMap[item].shouldConvert(rowOriginal[item]) : formData[item] = rowOriginal[item];
|
|
@@ -959,7 +974,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
959
974
|
useEffect(function () {
|
|
960
975
|
// 表格宽度变化时(比如调整页面宽度大小),重新计算是否展示阴影
|
|
961
976
|
getPinShadowInfo();
|
|
962
|
-
}, [tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$
|
|
977
|
+
}, [tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.clientWidth, table.getState().columnSizing]);
|
|
963
978
|
var scrollHandler = useCallback(function (event) {
|
|
964
979
|
if (!event.currentTarget) return;
|
|
965
980
|
tableHeaderRef.current.scrollLeft = event.currentTarget.scrollLeft / event.currentTarget.scrollWidth * (tableHeaderRef === null || tableHeaderRef === void 0 ? void 0 : tableHeaderRef.current.scrollWidth);
|
|
@@ -987,7 +1002,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
987
1002
|
hasGroup: hasGroup,
|
|
988
1003
|
getHeaderCellProps: getHeaderCellProps,
|
|
989
1004
|
columnResizeMode: columnResizeMode,
|
|
990
|
-
hasVerticalScrollBar: hasVerticalScrollBar,
|
|
991
1005
|
shadowColumnInfo: shadowColumnInfo
|
|
992
1006
|
};
|
|
993
1007
|
var tableBodyProps = {
|
|
@@ -1034,7 +1048,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
1034
1048
|
datas: datas,
|
|
1035
1049
|
theme: theme,
|
|
1036
1050
|
dragBeforeStart: dragBeforeStart,
|
|
1037
|
-
hasVerticalScrollBar: hasVerticalScrollBar,
|
|
1038
1051
|
shadowColumnInfo: shadowColumnInfo,
|
|
1039
1052
|
getContextMenu: getContextMenu,
|
|
1040
1053
|
onClickContextMenu: onClickContextMenu,
|
|
@@ -1053,9 +1066,8 @@ var TableMax = function TableMax(_ref) {
|
|
|
1053
1066
|
width: "100%",
|
|
1054
1067
|
height: "".concat(autoHeight ? '100%' : '')
|
|
1055
1068
|
},
|
|
1056
|
-
id: "".concat(tableId, "-TableCore")
|
|
1057
|
-
|
|
1058
|
-
,
|
|
1069
|
+
id: "".concat(tableId, "-TableCore"),
|
|
1070
|
+
ref: tableMaxRef,
|
|
1059
1071
|
children: [renderOperate ? renderOperate : !renderOperateLeft && !renderOperateRight && !tableTitle && !canRefresh && !canEditting && !canDelete && !canSetting ? null : /*#__PURE__*/_jsxs("div", {
|
|
1060
1072
|
className: "table-max-header",
|
|
1061
1073
|
children: [renderOperateLeft ? !editingRowId ? renderOperateLeft : /*#__PURE__*/_jsx("span", {}) : /*#__PURE__*/_jsx("div", {
|
|
@@ -1132,24 +1144,24 @@ var TableMax = function TableMax(_ref) {
|
|
|
1132
1144
|
className: "table-max-content cus-table-max-content",
|
|
1133
1145
|
children: /*#__PURE__*/_jsxs("div", {
|
|
1134
1146
|
className: "table-center",
|
|
1135
|
-
ref: tableContentRef
|
|
1136
|
-
style:
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
+
ref: tableContentRef
|
|
1148
|
+
// style={{ maxHeight: !autoHeight ? defaultScrollY : 'fit-content' }}
|
|
1149
|
+
,
|
|
1150
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
1151
|
+
className: "table-header-wrapper",
|
|
1152
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
1153
|
+
ref: tableHeaderRef,
|
|
1154
|
+
className: "table-header",
|
|
1155
|
+
children: /*#__PURE__*/_jsx(TableHeader, _objectSpread({}, tableHeaderProps))
|
|
1156
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
1157
|
+
className: "table-header-scroll"
|
|
1158
|
+
})]
|
|
1147
1159
|
}), /*#__PURE__*/_jsx("div", {
|
|
1148
1160
|
ref: tableBodyRef,
|
|
1149
1161
|
className: "table-body",
|
|
1150
1162
|
onScroll: scrollHandler,
|
|
1151
1163
|
style: {
|
|
1152
|
-
width: ""
|
|
1164
|
+
width: "100%"
|
|
1153
1165
|
},
|
|
1154
1166
|
children: /*#__PURE__*/_jsx(TableBody, _objectSpread({}, tableBodyProps))
|
|
1155
1167
|
})]
|
|
@@ -100,15 +100,28 @@
|
|
|
100
100
|
overflow-y: hidden !important;
|
|
101
101
|
display: flex;
|
|
102
102
|
flex-direction: column;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
overflow: hidden;
|
|
103
|
+
.table-header-wrapper {
|
|
104
|
+
display: flex;
|
|
106
105
|
background: @tableColor2;
|
|
106
|
+
|
|
107
|
+
.table-header {
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
box-sizing: border-box;
|
|
110
|
+
height: fit-content;
|
|
111
|
+
flex: 1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.table-header-scroll {
|
|
115
|
+
width: 10px;
|
|
116
|
+
height: 100%;
|
|
117
|
+
}
|
|
107
118
|
}
|
|
108
119
|
|
|
120
|
+
|
|
121
|
+
|
|
109
122
|
.table-body {
|
|
110
123
|
flex: 1;
|
|
111
|
-
overflow:
|
|
124
|
+
overflow: scroll scroll;
|
|
112
125
|
// background: @tableColor2;
|
|
113
126
|
|
|
114
127
|
&::-webkit-scrollbar {
|
|
@@ -5,6 +5,7 @@ export declare const getSizeInfo: (columns: TableMaxColumnType[]) => {
|
|
|
5
5
|
hasSizeCount: number;
|
|
6
6
|
hasSizeAllWidth: number;
|
|
7
7
|
columns: TableMaxColumnType[];
|
|
8
|
+
columnSizeMap: {};
|
|
8
9
|
};
|
|
9
10
|
export declare function getTextWidth(text: string, fontSize: number): any;
|
|
10
11
|
export declare const setRemainColumnsWidth: (initColumns: TableMaxColumnType[], defaultSize?: number) => {
|
|
@@ -12,7 +13,7 @@ export declare const setRemainColumnsWidth: (initColumns: TableMaxColumnType[],
|
|
|
12
13
|
tableColumnsWidth: number;
|
|
13
14
|
columnsWidthMap: {};
|
|
14
15
|
};
|
|
15
|
-
export declare const setInitColumnsSize: (tableColumns: any, columnsMap: any) => {
|
|
16
|
+
export declare const setInitColumnsSize: (tableColumns: any, columnsMap: any, defaultSize?: number) => {
|
|
16
17
|
columnsSizeMap: {};
|
|
17
18
|
tableColumns: any;
|
|
18
19
|
};
|