bhd-components 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{6a77b797.esm.es5.development.js → 17d83214.esm.es5.development.js} +2 -1
- package/dist/table.esm.es5.development.js +58 -14
- package/dist/table.esm.es5.production.js +1 -1
- package/es2017/table/index.d.ts +10 -1
- package/es2017/table/index.js +46 -19
- package/es2017/table/{index/347/232/204/345/211/257/346/234/254.js → index22.js} +11 -40
- package/esm/table/index.d.ts +10 -1
- package/esm/table/index.js +48 -19
- package/esm/table/{index/347/232/204/345/211/257/346/234/254.js → index22.js} +11 -42
- package/package.json +1 -1
- /package/dist/{7fed7be7.esm.es5.production.js → 844d192b.esm.es5.production.js} +0 -0
- /package/es2017/table/{index/347/232/204/345/211/257/346/234/254.d.ts" → index22.d.ts} +0 -0
- /package/esm/table/{index/347/232/204/345/211/257/346/234/254.d.ts" → index22.d.ts} +0 -0
|
@@ -10611,6 +10611,7 @@ ConfigProvider.config = setGlobalConfig;
|
|
|
10611
10611
|
{
|
|
10612
10612
|
ConfigProvider.displayName = 'ConfigProvider';
|
|
10613
10613
|
}
|
|
10614
|
+
var ConfigProvider$1 = ConfigProvider;
|
|
10614
10615
|
|
|
10615
10616
|
var raf = function raf(callback) {
|
|
10616
10617
|
return +setTimeout(callback, 16);
|
|
@@ -21418,7 +21419,7 @@ function genPurePanel(Component, defaultPrefixCls, getDropdownCls) {
|
|
|
21418
21419
|
};
|
|
21419
21420
|
}
|
|
21420
21421
|
}, []);
|
|
21421
|
-
return /*#__PURE__*/React.createElement(ConfigProvider, {
|
|
21422
|
+
return /*#__PURE__*/React.createElement(ConfigProvider$1, {
|
|
21422
21423
|
theme: {
|
|
21423
21424
|
token: {
|
|
21424
21425
|
motionDurationFast: '0.01s',
|
|
@@ -2,7 +2,7 @@ import 'core-js/modules/es.array.map.js';
|
|
|
2
2
|
import 'core-js/modules/es.regexp.exec.js';
|
|
3
3
|
import 'core-js/modules/es.string.fixed.js';
|
|
4
4
|
import { useState, useRef, useEffect } from 'react';
|
|
5
|
-
import { j as jsx, T as Tooltip, a as Table$1 } from './
|
|
5
|
+
import { j as jsx, T as Tooltip, a as Table$1 } from './17d83214.esm.es5.development.js';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
7
|
import 'react-dom';
|
|
8
8
|
|
|
@@ -250,25 +250,48 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
250
250
|
}
|
|
251
251
|
var widthPercentage = /^\d+%$/;
|
|
252
252
|
var widthPx = /^\d+px$/;
|
|
253
|
+
/* 获取元素的宽度 */ var getElementPadding = function(node) {
|
|
254
|
+
var computedStyle = {};
|
|
255
|
+
if (window.getComputedStyle) {
|
|
256
|
+
computedStyle = getComputedStyle(node, null);
|
|
257
|
+
} else {
|
|
258
|
+
computedStyle = node.currentStyle; //兼容IE的写法
|
|
259
|
+
}
|
|
260
|
+
return parseFloat(computedStyle["padding-left"]) + parseFloat(computedStyle["padding-right"]);
|
|
261
|
+
};
|
|
262
|
+
//获取宽度
|
|
263
|
+
var getParentWidth = function(node) {
|
|
264
|
+
try {
|
|
265
|
+
while(node && node.nodeName !== "TD"){
|
|
266
|
+
node = node.parentElement;
|
|
267
|
+
}
|
|
268
|
+
var padding = getElementPadding(node);
|
|
269
|
+
return node.clientWidth - padding;
|
|
270
|
+
} catch (error) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
};
|
|
253
274
|
// const defaultWidthRang: widthRangType = [180, 240, 320]; //默认自适应的值 [最小值,最佳值,最大值]
|
|
254
275
|
//传入的参数为onCell==>需要进行函数合并
|
|
255
276
|
var Table = function(props) {
|
|
256
|
-
var
|
|
277
|
+
var tableRef = useRef(null);
|
|
278
|
+
var timerRef = useRef({
|
|
279
|
+
timer: null
|
|
280
|
+
});
|
|
257
281
|
var _props_defaultWidthRang = props.defaultWidthRang, defaultWidthRang = _props_defaultWidthRang === void 0 ? [
|
|
258
282
|
180,
|
|
259
283
|
240,
|
|
260
284
|
320
|
|
261
|
-
] : _props_defaultWidthRang;
|
|
285
|
+
] : _props_defaultWidthRang, _props_isFixedLeft = props.isFixedLeft, isFixedLeft = _props_isFixedLeft === void 0 ? true : _props_isFixedLeft, _props_isFixedRight = props.isFixedRight, isFixedRight = _props_isFixedRight === void 0 ? true : _props_isFixedRight;
|
|
262
286
|
var _useState = _slicedToArray(useState(props.columns || []), 2), columns = _useState[0], setColumns = _useState[1];
|
|
263
287
|
var _useState1 = _slicedToArray(useState(props.scroll || undefined), 2), scrollObject = _useState1[0], setScrollObject = _useState1[1];
|
|
264
288
|
var columnTootipClassName = props.columnTootipClassName, columnTootipColor = props.columnTootipColor;
|
|
265
289
|
var initColumns = function() {
|
|
266
|
-
var _initColumnsWidth = initColumnsWidth(props.columns,
|
|
290
|
+
var _initColumnsWidth = initColumnsWidth(props.columns, tableRef.current.offsetWidth), selfColumns = _initColumnsWidth.columns;
|
|
267
291
|
setColumns(selfColumns);
|
|
268
292
|
var obj = scrollObject ? scrollObject : {};
|
|
269
293
|
obj = _objectSpreadProps(_objectSpread({}, obj), {
|
|
270
|
-
|
|
271
|
-
x: ref.current.offsetWidth
|
|
294
|
+
x: tableRef.current.offsetWidth
|
|
272
295
|
});
|
|
273
296
|
setScrollObject(obj);
|
|
274
297
|
};
|
|
@@ -315,7 +338,9 @@ var Table = function(props) {
|
|
|
315
338
|
};
|
|
316
339
|
item.render = function(text) {
|
|
317
340
|
return /*#__PURE__*/ jsx(TextTootip$1, {
|
|
318
|
-
width:
|
|
341
|
+
width: function(e) {
|
|
342
|
+
return getParentWidth(e.target);
|
|
343
|
+
},
|
|
319
344
|
title: text,
|
|
320
345
|
trigger: "hover",
|
|
321
346
|
overlayClassName: columnTootipClassName || modules_63b47c51.columnTootipClassName,
|
|
@@ -344,6 +369,7 @@ var Table = function(props) {
|
|
|
344
369
|
}
|
|
345
370
|
return item;
|
|
346
371
|
});
|
|
372
|
+
// console.log("diffdiff",diff,tableWidth,minWidth,avgWidth,columns,autoNum)
|
|
347
373
|
columns = columns.map(function(item, index) {
|
|
348
374
|
//存在适应自适应列侯 多余宽度 则平均分配每一列(除最后一列)
|
|
349
375
|
if (avgWidth > 0 && index !== columns.length - 1) {
|
|
@@ -354,8 +380,11 @@ var Table = function(props) {
|
|
|
354
380
|
} else if (diff < 0) {
|
|
355
381
|
//宽度不足 自适应列取最佳宽度 并出现滚动条 且第一列 最后一列 固定
|
|
356
382
|
columns = columns.map(function(item, index) {
|
|
357
|
-
if (
|
|
358
|
-
item.fixed =
|
|
383
|
+
if (isFixedLeft && index === 0) {
|
|
384
|
+
item.fixed = "left";
|
|
385
|
+
}
|
|
386
|
+
if (isFixedRight && index === columns.length - 1) {
|
|
387
|
+
item.fixed = "right";
|
|
359
388
|
}
|
|
360
389
|
if (item.width === "auto") {
|
|
361
390
|
item.width = item.widthRang[1];
|
|
@@ -381,6 +410,7 @@ var Table = function(props) {
|
|
|
381
410
|
}, obj.style)
|
|
382
411
|
});
|
|
383
412
|
};
|
|
413
|
+
console.log("宽度宽度", item, item.width, item.widthRang);
|
|
384
414
|
return item;
|
|
385
415
|
});
|
|
386
416
|
return {
|
|
@@ -388,11 +418,18 @@ var Table = function(props) {
|
|
|
388
418
|
scrollWidth: scrollWidth
|
|
389
419
|
};
|
|
390
420
|
};
|
|
421
|
+
var onResize = function() {
|
|
422
|
+
clearTimeout(timerRef.current.timer);
|
|
423
|
+
timerRef.current.timer = setTimeout(function() {
|
|
424
|
+
initColumns();
|
|
425
|
+
}, 1000);
|
|
426
|
+
};
|
|
391
427
|
useEffect(function() {
|
|
392
428
|
initColumns();
|
|
393
|
-
|
|
429
|
+
window.addEventListener("resize", onResize);
|
|
394
430
|
return function() {
|
|
395
|
-
|
|
431
|
+
clearTimeout(timerRef.current.timer);
|
|
432
|
+
window.removeEventListener("resize", onResize);
|
|
396
433
|
};
|
|
397
434
|
}, [
|
|
398
435
|
props.columns
|
|
@@ -402,15 +439,22 @@ var Table = function(props) {
|
|
|
402
439
|
}, props), {
|
|
403
440
|
columns: columns,
|
|
404
441
|
scroll: scrollObject || {
|
|
405
|
-
x: "
|
|
442
|
+
x: "auto"
|
|
406
443
|
}
|
|
407
444
|
});
|
|
408
|
-
console.log("scrollObjectscrollObject", scrollObject, config);
|
|
409
445
|
return /*#__PURE__*/ jsx("div", {
|
|
410
446
|
className: modules_63b47c51.Table,
|
|
411
|
-
ref:
|
|
447
|
+
ref: tableRef,
|
|
412
448
|
children: /*#__PURE__*/ jsx(Table$1, _objectSpread({}, config))
|
|
413
449
|
});
|
|
414
450
|
};
|
|
451
|
+
// let BhdTable=Provider(Table)
|
|
452
|
+
Table.SELECTION_COLUMN = Table$1.SELECTION_COLUMN;
|
|
453
|
+
Table.EXPAND_COLUMN = Table$1.EXPAND_COLUMN;
|
|
454
|
+
Table.SELECTION_ALL = Table$1.SELECTION_ALL;
|
|
455
|
+
Table.SELECTION_INVERT = Table$1.SELECTION_INVERT;
|
|
456
|
+
Table.SELECTION_NONE = Table$1.SELECTION_NONE;
|
|
457
|
+
Table.Column = Table$1.Column;
|
|
458
|
+
Table.ColumnGroup = Table$1.ColumnGroup;
|
|
415
459
|
|
|
416
460
|
export { Table as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"core-js/modules/es.array.map.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.fixed.js";import{useState as t,useRef as e,useEffect as r}from"react";import{j as n,T as o,a as i}from"./
|
|
1
|
+
import"core-js/modules/es.array.map.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.fixed.js";import{useState as t,useRef as e,useEffect as r}from"react";import{j as n,T as o,a as i}from"./844d192b.esm.es5.production.js";import"react/jsx-runtime";import"react-dom";var l={Table:"index_module_Table__999e5203",columnTootipClassName:"index_module_columnTootipClassName__999e5203"};function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var a=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:14,r=0,n=document.createElement("div");return n.style.position="absolute",n.style.whiteSpace="nowrap",n.style.fontSize=e+"px",n.style.opacity="0",n.innerText=t,document.body.append(n),r=n.getBoundingClientRect().width,document.body.removeChild(n),r},c=function(e){var r,i,l,c=e.children,s=e.title,d=e.width,f=function(t){if(Array.isArray(t))return t}(r=t(!1))||function(t,e){var r,n,o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var i=[],l=!0,u=!1;try{for(o=o.call(t);!(l=(r=o.next()).done)&&(i.push(r.value),!e||i.length!==e);l=!0);}catch(t){u=!0,n=t}finally{try{l||null==o.return||o.return()}finally{if(u)throw n}}return i}}(r,2)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(t,e)}}(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=f[0],m=f[1];return n(o,(i=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){var n,o;n=t,o=r[e],e in n?Object.defineProperty(n,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[e]=o})}return t}({},e),l=l={open:p,children:n("span",{onMouseEnter:function(t){var e=0;(e="function"==typeof d?d(t):d)?m(!(a(s)<e)):m(!0)},onMouseLeave:function(){m(!1)},children:c})},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(l)):(function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r.push.apply(r,n)}return r})(Object(l)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(l,t))}),i))};function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function d(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){var n,o;n=t,o=r[e],e in n?Object.defineProperty(n,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[e]=o})}return t}function f(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):(function(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r.push.apply(r,n)}return r})(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}function p(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r,n,o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var i=[],l=!0,u=!1;try{for(o=o.call(t);!(l=(r=o.next()).done)&&(i.push(r.value),!e||i.length!==e);l=!0);}catch(t){u=!0,n=t}finally{try{l||null==o.return||o.return()}finally{if(u)throw n}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return s(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(t,e)}}(t,e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var m=/^\d+%$/,h=/^\d+px$/,y=function(t){var e={};return parseFloat((e=window.getComputedStyle?getComputedStyle(t,null):t.currentStyle)["padding-left"])+parseFloat(e["padding-right"])},w=function(t){try{for(;t&&"TD"!==t.nodeName;)t=t.parentElement;var e=y(t);return t.clientWidth-e}catch(t){return null}},b=function(o){var u=e(null),a=e({timer:null}),s=o.defaultWidthRang,y=void 0===s?[180,240,320]:s,b=o.isFixedLeft,g=void 0===b||b,O=o.isFixedRight,v=void 0===O||O,j=p(t(o.columns||[]),2),C=j[0],E=j[1],S=p(t(o.scroll||void 0),2),T=S[0],N=S[1],P=o.columnTootipClassName,x=o.columnTootipColor,L=function(){var t=_(o.columns,u.current.offsetWidth).columns;E(t);var e=T||{};N(e=f(d({},e),{x:u.current.offsetWidth}))},_=function(t,e){var r=0,o=0,i=0;t=t.map(function(t){return t.width=t.width||"auto",m.test(t.width)?t.width=parseFloat(t.width)>=100?"auto":e*t.width:"number"==typeof t.width?t.width=t.width:h.test(t.width)?t.width=parseFloat(t.width):t.width="auto","auto"===t.width?(r+=1,t.widthRang||(t.widthRang=y),o+=t.widthRang[0],i+=t.widthRang[1]):(o+=t.width,i+=t.width),t.onColumnCell||(t.onColumnCell=t.onCell||function(){return{}}),t.render||(t.ellipsis={showTitle:!1},t.render=function(t){return n(c,{width:function(t){return w(t.target)},title:t,trigger:"hover",overlayClassName:P||l.columnTootipClassName,color:x||"#FFF",children:n("span",{children:t})})}),t});var u=e-o;if(u>0){var a=0;t=(t=t.map(function(t){return"auto"===t.width&&(t.width=t.widthRang[0]+u/r,t.width>t.widthRang[2]&&(a+=t.width-t.widthRang[2],t.width=t.widthRang[2])),t})).map(function(e,r){return a>0&&r!==t.length-1&&(e.width+=a/t.length-1),e})}else t=u<0?t.map(function(e,r){return g&&0===r&&(e.fixed="left"),v&&r===t.length-1&&(e.fixed="right"),"auto"===e.width&&(e.width=e.widthRang[1]),e}):t.map(function(t){return"auto"===t.width&&(t.width=t.widthRang[0]),t});return t.map(function(t){return t.onCell=function(e,r){var n="function"==typeof t.onColumnCell?t.onColumnCell(e,r):{};return n.style=n.style?n.style:{},f(d({},n),{style:d({maxWidth:t.width+"px"},n.style)})},console.log("宽度宽度",t,t.width,t.widthRang),t}),{columns:t,scrollWidth:i}},A=function(){clearTimeout(a.current.timer),a.current.timer=setTimeout(function(){L()},1e3)};r(function(){return L(),window.addEventListener("resize",A),function(){clearTimeout(a.current.timer),window.removeEventListener("resize",A)}},[o.columns]);var I=f(d({bordered:!1},o),{columns:C,scroll:T||{x:"auto"}});return n("div",{className:l.Table,ref:u,children:n(i,d({},I))})};b.SELECTION_COLUMN=i.SELECTION_COLUMN,b.EXPAND_COLUMN=i.EXPAND_COLUMN,b.SELECTION_ALL=i.SELECTION_ALL,b.SELECTION_INVERT=i.SELECTION_INVERT,b.SELECTION_NONE=i.SELECTION_NONE,b.Column=i.Column,b.ColumnGroup=i.ColumnGroup;export{b as default};
|
package/es2017/table/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const Table:
|
|
2
|
+
declare const Table: {
|
|
3
|
+
(props: any): JSX.Element;
|
|
4
|
+
SELECTION_COLUMN: {};
|
|
5
|
+
EXPAND_COLUMN: {};
|
|
6
|
+
SELECTION_ALL: "SELECT_ALL";
|
|
7
|
+
SELECTION_INVERT: "SELECT_INVERT";
|
|
8
|
+
SELECTION_NONE: "SELECT_NONE";
|
|
9
|
+
Column: typeof import("antd/es/table/Column").default;
|
|
10
|
+
ColumnGroup: typeof import("antd/es/table/ColumnGroup").default;
|
|
11
|
+
};
|
|
3
12
|
export default Table;
|
package/es2017/table/index.js
CHANGED
|
@@ -8,25 +8,43 @@ import { Table as AntdTable } from "antd";
|
|
|
8
8
|
import TextTootip from "../textTootip";
|
|
9
9
|
const widthPercentage = /^\d+%$/;
|
|
10
10
|
const widthPx = /^\d+px$/;
|
|
11
|
+
/* 获取元素的宽度 */ const getElementPadding = (node)=>{
|
|
12
|
+
let computedStyle = {};
|
|
13
|
+
if (window.getComputedStyle) computedStyle = getComputedStyle(node, null);
|
|
14
|
+
else computedStyle = node.currentStyle; //兼容IE的写法
|
|
15
|
+
return parseFloat(computedStyle["padding-left"]) + parseFloat(computedStyle["padding-right"]);
|
|
16
|
+
};
|
|
17
|
+
//获取宽度
|
|
18
|
+
const getParentWidth = (node)=>{
|
|
19
|
+
try {
|
|
20
|
+
while(node && node.nodeName !== "TD")node = node.parentElement;
|
|
21
|
+
let padding = getElementPadding(node);
|
|
22
|
+
return node.clientWidth - padding;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
11
27
|
// const defaultWidthRang: widthRangType = [180, 240, 320]; //默认自适应的值 [最小值,最佳值,最大值]
|
|
12
28
|
//传入的参数为onCell==>需要进行函数合并
|
|
13
29
|
const Table = (props)=>{
|
|
14
|
-
const
|
|
30
|
+
const tableRef = useRef(null);
|
|
31
|
+
const timerRef = useRef({
|
|
32
|
+
timer: null
|
|
33
|
+
});
|
|
15
34
|
const { defaultWidthRang =[
|
|
16
35
|
180,
|
|
17
36
|
240,
|
|
18
37
|
320
|
|
19
|
-
] } = props;
|
|
38
|
+
] , isFixedLeft =true , isFixedRight =true } = props;
|
|
20
39
|
const [columns, setColumns] = useState(props.columns || []);
|
|
21
40
|
const [scrollObject, setScrollObject] = useState(props.scroll || undefined);
|
|
22
41
|
let { columnTootipClassName , columnTootipColor } = props;
|
|
23
42
|
const initColumns = ()=>{
|
|
24
|
-
let { columns: selfColumns
|
|
43
|
+
let { columns: selfColumns } = initColumnsWidth(props.columns, tableRef.current.offsetWidth);
|
|
25
44
|
setColumns(selfColumns);
|
|
26
45
|
let obj = scrollObject ? scrollObject : {};
|
|
27
46
|
obj = _object_spread_props(_object_spread({}, obj), {
|
|
28
|
-
|
|
29
|
-
x: ref.current.offsetWidth
|
|
47
|
+
x: tableRef.current.offsetWidth
|
|
30
48
|
});
|
|
31
49
|
setScrollObject(obj);
|
|
32
50
|
};
|
|
@@ -62,7 +80,7 @@ const Table = (props)=>{
|
|
|
62
80
|
};
|
|
63
81
|
item.render = (text)=>{
|
|
64
82
|
return /*#__PURE__*/ _jsx(TextTootip, {
|
|
65
|
-
width:
|
|
83
|
+
width: (e)=>getParentWidth(e.target),
|
|
66
84
|
title: text,
|
|
67
85
|
trigger: "hover",
|
|
68
86
|
overlayClassName: columnTootipClassName || styles.columnTootipClassName,
|
|
@@ -91,6 +109,7 @@ const Table = (props)=>{
|
|
|
91
109
|
}
|
|
92
110
|
return item;
|
|
93
111
|
});
|
|
112
|
+
// console.log("diffdiff",diff,tableWidth,minWidth,avgWidth,columns,autoNum)
|
|
94
113
|
columns = columns.map((item, index)=>{
|
|
95
114
|
//存在适应自适应列侯 多余宽度 则平均分配每一列(除最后一列)
|
|
96
115
|
if (avgWidth > 0 && index !== columns.length - 1) item.width += avgWidth / columns.length - 1;
|
|
@@ -98,7 +117,8 @@ const Table = (props)=>{
|
|
|
98
117
|
});
|
|
99
118
|
} else if (diff < 0) //宽度不足 自适应列取最佳宽度 并出现滚动条 且第一列 最后一列 固定
|
|
100
119
|
columns = columns.map((item, index)=>{
|
|
101
|
-
if (
|
|
120
|
+
if (isFixedLeft && index === 0) item.fixed = "left";
|
|
121
|
+
if (isFixedRight && index === columns.length - 1) item.fixed = "right";
|
|
102
122
|
if (item.width === "auto") item.width = item.widthRang[1];
|
|
103
123
|
return item;
|
|
104
124
|
});
|
|
@@ -117,6 +137,7 @@ const Table = (props)=>{
|
|
|
117
137
|
}, obj.style)
|
|
118
138
|
});
|
|
119
139
|
};
|
|
140
|
+
console.log("宽度宽度", item, item.width, item.widthRang);
|
|
120
141
|
return item;
|
|
121
142
|
});
|
|
122
143
|
return {
|
|
@@ -124,11 +145,18 @@ const Table = (props)=>{
|
|
|
124
145
|
scrollWidth
|
|
125
146
|
};
|
|
126
147
|
};
|
|
148
|
+
const onResize = ()=>{
|
|
149
|
+
clearTimeout(timerRef.current.timer);
|
|
150
|
+
timerRef.current.timer = setTimeout(()=>{
|
|
151
|
+
initColumns();
|
|
152
|
+
}, 1000);
|
|
153
|
+
};
|
|
127
154
|
useEffect(()=>{
|
|
128
155
|
initColumns();
|
|
129
|
-
|
|
156
|
+
window.addEventListener("resize", onResize);
|
|
130
157
|
return ()=>{
|
|
131
|
-
|
|
158
|
+
clearTimeout(timerRef.current.timer);
|
|
159
|
+
window.removeEventListener("resize", onResize);
|
|
132
160
|
};
|
|
133
161
|
}, [
|
|
134
162
|
props.columns
|
|
@@ -138,23 +166,22 @@ const Table = (props)=>{
|
|
|
138
166
|
}, props), {
|
|
139
167
|
columns,
|
|
140
168
|
scroll: scrollObject || {
|
|
141
|
-
x: "
|
|
169
|
+
x: "auto"
|
|
142
170
|
}
|
|
143
171
|
});
|
|
144
|
-
console.log("scrollObjectscrollObject", scrollObject, config);
|
|
145
172
|
return /*#__PURE__*/ _jsx("div", {
|
|
146
173
|
className: styles.Table,
|
|
147
|
-
ref:
|
|
174
|
+
ref: tableRef,
|
|
148
175
|
children: /*#__PURE__*/ _jsx(AntdTable, _object_spread({}, config))
|
|
149
176
|
});
|
|
150
177
|
};
|
|
151
178
|
// let BhdTable=Provider(Table)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
179
|
+
Table.SELECTION_COLUMN = AntdTable.SELECTION_COLUMN;
|
|
180
|
+
Table.EXPAND_COLUMN = AntdTable.EXPAND_COLUMN;
|
|
181
|
+
Table.SELECTION_ALL = AntdTable.SELECTION_ALL;
|
|
182
|
+
Table.SELECTION_INVERT = AntdTable.SELECTION_INVERT;
|
|
183
|
+
Table.SELECTION_NONE = AntdTable.SELECTION_NONE;
|
|
184
|
+
Table.Column = AntdTable.Column;
|
|
185
|
+
Table.ColumnGroup = AntdTable.ColumnGroup;
|
|
159
186
|
// Table.Summary = AntdTable.Summary;
|
|
160
187
|
export default Table;
|
|
@@ -8,43 +8,25 @@ import { Table as AntdTable } from "antd";
|
|
|
8
8
|
import TextTootip from "../textTootip";
|
|
9
9
|
const widthPercentage = /^\d+%$/;
|
|
10
10
|
const widthPx = /^\d+px$/;
|
|
11
|
-
/* 获取元素的宽度 */ const getElementPadding = (node)=>{
|
|
12
|
-
let computedStyle = {};
|
|
13
|
-
if (window.getComputedStyle) computedStyle = getComputedStyle(node, null);
|
|
14
|
-
else computedStyle = node.currentStyle; //兼容IE的写法
|
|
15
|
-
return parseFloat(computedStyle["padding-left"]) + parseFloat(computedStyle["padding-right"]);
|
|
16
|
-
};
|
|
17
|
-
//获取宽度
|
|
18
|
-
const getParentWidth = (node)=>{
|
|
19
|
-
try {
|
|
20
|
-
while(node && node.nodeName !== "TD")node = node.parentElement;
|
|
21
|
-
let padding = getElementPadding(node);
|
|
22
|
-
return node.clientWidth - padding;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
11
|
// const defaultWidthRang: widthRangType = [180, 240, 320]; //默认自适应的值 [最小值,最佳值,最大值]
|
|
28
12
|
//传入的参数为onCell==>需要进行函数合并
|
|
29
13
|
const Table = (props)=>{
|
|
30
|
-
const
|
|
31
|
-
const timerRef = useRef({
|
|
32
|
-
timer: null
|
|
33
|
-
});
|
|
14
|
+
const ref = useRef(null);
|
|
34
15
|
const { defaultWidthRang =[
|
|
35
16
|
180,
|
|
36
17
|
240,
|
|
37
18
|
320
|
|
38
|
-
]
|
|
19
|
+
] } = props;
|
|
39
20
|
const [columns, setColumns] = useState(props.columns || []);
|
|
40
21
|
const [scrollObject, setScrollObject] = useState(props.scroll || undefined);
|
|
41
22
|
let { columnTootipClassName , columnTootipColor } = props;
|
|
42
23
|
const initColumns = ()=>{
|
|
43
|
-
let { columns: selfColumns } = initColumnsWidth(props.columns,
|
|
24
|
+
let { columns: selfColumns , scrollWidth } = initColumnsWidth(props.columns, ref.current.offsetWidth);
|
|
44
25
|
setColumns(selfColumns);
|
|
45
26
|
let obj = scrollObject ? scrollObject : {};
|
|
46
27
|
obj = _object_spread_props(_object_spread({}, obj), {
|
|
47
|
-
x:
|
|
28
|
+
// x: scrollWidth,
|
|
29
|
+
x: ref.current.offsetWidth
|
|
48
30
|
});
|
|
49
31
|
setScrollObject(obj);
|
|
50
32
|
};
|
|
@@ -80,7 +62,7 @@ const Table = (props)=>{
|
|
|
80
62
|
};
|
|
81
63
|
item.render = (text)=>{
|
|
82
64
|
return /*#__PURE__*/ _jsx(TextTootip, {
|
|
83
|
-
width:
|
|
65
|
+
width: item.width,
|
|
84
66
|
title: text,
|
|
85
67
|
trigger: "hover",
|
|
86
68
|
overlayClassName: columnTootipClassName || styles.columnTootipClassName,
|
|
@@ -109,7 +91,6 @@ const Table = (props)=>{
|
|
|
109
91
|
}
|
|
110
92
|
return item;
|
|
111
93
|
});
|
|
112
|
-
console.log("diffdiff", diff, tableWidth, minWidth, avgWidth, columns, autoNum);
|
|
113
94
|
columns = columns.map((item, index)=>{
|
|
114
95
|
//存在适应自适应列侯 多余宽度 则平均分配每一列(除最后一列)
|
|
115
96
|
if (avgWidth > 0 && index !== columns.length - 1) item.width += avgWidth / columns.length - 1;
|
|
@@ -117,8 +98,7 @@ const Table = (props)=>{
|
|
|
117
98
|
});
|
|
118
99
|
} else if (diff < 0) //宽度不足 自适应列取最佳宽度 并出现滚动条 且第一列 最后一列 固定
|
|
119
100
|
columns = columns.map((item, index)=>{
|
|
120
|
-
if (
|
|
121
|
-
if (isFixedRight && index === columns.length - 1) item.fixed = "right";
|
|
101
|
+
if (index === 0 || index === columns.length - 1) item.fixed = index === 0 ? "left" : "right";
|
|
122
102
|
if (item.width === "auto") item.width = item.widthRang[1];
|
|
123
103
|
return item;
|
|
124
104
|
});
|
|
@@ -137,7 +117,6 @@ const Table = (props)=>{
|
|
|
137
117
|
}, obj.style)
|
|
138
118
|
});
|
|
139
119
|
};
|
|
140
|
-
console.log("宽度宽度", item, item.width, item.widthRang);
|
|
141
120
|
return item;
|
|
142
121
|
});
|
|
143
122
|
return {
|
|
@@ -145,34 +124,26 @@ const Table = (props)=>{
|
|
|
145
124
|
scrollWidth
|
|
146
125
|
};
|
|
147
126
|
};
|
|
148
|
-
const onResize = ()=>{
|
|
149
|
-
clearTimeout(timerRef.current.timer);
|
|
150
|
-
timerRef.current.timer = setTimeout(()=>{
|
|
151
|
-
initColumns();
|
|
152
|
-
}, 1000);
|
|
153
|
-
};
|
|
154
127
|
useEffect(()=>{
|
|
155
128
|
initColumns();
|
|
156
|
-
window.addEventListener("resize",
|
|
129
|
+
window.addEventListener("resize", initColumns);
|
|
157
130
|
return ()=>{
|
|
158
|
-
|
|
159
|
-
window.removeEventListener("resize", onResize);
|
|
131
|
+
window.removeEventListener("resize", initColumns);
|
|
160
132
|
};
|
|
161
133
|
}, [
|
|
162
134
|
props.columns
|
|
163
135
|
]);
|
|
164
|
-
console.log("宽度宽度", scrollObject);
|
|
165
136
|
let config = _object_spread_props(_object_spread({
|
|
166
137
|
bordered: false
|
|
167
138
|
}, props), {
|
|
168
139
|
columns,
|
|
169
140
|
scroll: scrollObject || {
|
|
170
|
-
x: "
|
|
141
|
+
x: "none"
|
|
171
142
|
}
|
|
172
143
|
});
|
|
173
144
|
return /*#__PURE__*/ _jsx("div", {
|
|
174
145
|
className: styles.Table,
|
|
175
|
-
ref:
|
|
146
|
+
ref: ref,
|
|
176
147
|
children: /*#__PURE__*/ _jsx(AntdTable, _object_spread({}, config))
|
|
177
148
|
});
|
|
178
149
|
};
|
package/esm/table/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
declare const Table:
|
|
2
|
+
declare const Table: {
|
|
3
|
+
(props: any): JSX.Element;
|
|
4
|
+
SELECTION_COLUMN: {};
|
|
5
|
+
EXPAND_COLUMN: {};
|
|
6
|
+
SELECTION_ALL: "SELECT_ALL";
|
|
7
|
+
SELECTION_INVERT: "SELECT_INVERT";
|
|
8
|
+
SELECTION_NONE: "SELECT_NONE";
|
|
9
|
+
Column: typeof import("antd/es/table/Column").default;
|
|
10
|
+
ColumnGroup: typeof import("antd/es/table/ColumnGroup").default;
|
|
11
|
+
};
|
|
3
12
|
export default Table;
|
package/esm/table/index.js
CHANGED
|
@@ -9,25 +9,43 @@ import { Table as AntdTable } from "antd";
|
|
|
9
9
|
import TextTootip from "../textTootip";
|
|
10
10
|
var widthPercentage = /^\d+%$/;
|
|
11
11
|
var widthPx = /^\d+px$/;
|
|
12
|
+
/* 获取元素的宽度 */ var getElementPadding = function(node) {
|
|
13
|
+
var computedStyle = {};
|
|
14
|
+
if (window.getComputedStyle) computedStyle = getComputedStyle(node, null);
|
|
15
|
+
else computedStyle = node.currentStyle; //兼容IE的写法
|
|
16
|
+
return parseFloat(computedStyle["padding-left"]) + parseFloat(computedStyle["padding-right"]);
|
|
17
|
+
};
|
|
18
|
+
//获取宽度
|
|
19
|
+
var getParentWidth = function(node) {
|
|
20
|
+
try {
|
|
21
|
+
while(node && node.nodeName !== "TD")node = node.parentElement;
|
|
22
|
+
var padding = getElementPadding(node);
|
|
23
|
+
return node.clientWidth - padding;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
12
28
|
// const defaultWidthRang: widthRangType = [180, 240, 320]; //默认自适应的值 [最小值,最佳值,最大值]
|
|
13
29
|
//传入的参数为onCell==>需要进行函数合并
|
|
14
30
|
var Table = function(props) {
|
|
15
|
-
var
|
|
31
|
+
var tableRef = useRef(null);
|
|
32
|
+
var timerRef = useRef({
|
|
33
|
+
timer: null
|
|
34
|
+
});
|
|
16
35
|
var _props_defaultWidthRang = props.defaultWidthRang, defaultWidthRang = _props_defaultWidthRang === void 0 ? [
|
|
17
36
|
180,
|
|
18
37
|
240,
|
|
19
38
|
320
|
|
20
|
-
] : _props_defaultWidthRang;
|
|
39
|
+
] : _props_defaultWidthRang, _props_isFixedLeft = props.isFixedLeft, isFixedLeft = _props_isFixedLeft === void 0 ? true : _props_isFixedLeft, _props_isFixedRight = props.isFixedRight, isFixedRight = _props_isFixedRight === void 0 ? true : _props_isFixedRight;
|
|
21
40
|
var _useState = _sliced_to_array(useState(props.columns || []), 2), columns = _useState[0], setColumns = _useState[1];
|
|
22
41
|
var _useState1 = _sliced_to_array(useState(props.scroll || undefined), 2), scrollObject = _useState1[0], setScrollObject = _useState1[1];
|
|
23
42
|
var columnTootipClassName = props.columnTootipClassName, columnTootipColor = props.columnTootipColor;
|
|
24
43
|
var initColumns = function() {
|
|
25
|
-
var _initColumnsWidth = initColumnsWidth(props.columns,
|
|
44
|
+
var _initColumnsWidth = initColumnsWidth(props.columns, tableRef.current.offsetWidth), selfColumns = _initColumnsWidth.columns;
|
|
26
45
|
setColumns(selfColumns);
|
|
27
46
|
var obj = scrollObject ? scrollObject : {};
|
|
28
47
|
obj = _object_spread_props(_object_spread({}, obj), {
|
|
29
|
-
|
|
30
|
-
x: ref.current.offsetWidth
|
|
48
|
+
x: tableRef.current.offsetWidth
|
|
31
49
|
});
|
|
32
50
|
setScrollObject(obj);
|
|
33
51
|
};
|
|
@@ -65,7 +83,9 @@ var Table = function(props) {
|
|
|
65
83
|
};
|
|
66
84
|
item.render = function(text) {
|
|
67
85
|
return /*#__PURE__*/ _jsx(TextTootip, {
|
|
68
|
-
width:
|
|
86
|
+
width: function(e) {
|
|
87
|
+
return getParentWidth(e.target);
|
|
88
|
+
},
|
|
69
89
|
title: text,
|
|
70
90
|
trigger: "hover",
|
|
71
91
|
overlayClassName: columnTootipClassName || styles.columnTootipClassName,
|
|
@@ -94,6 +114,7 @@ var Table = function(props) {
|
|
|
94
114
|
}
|
|
95
115
|
return item;
|
|
96
116
|
});
|
|
117
|
+
// console.log("diffdiff",diff,tableWidth,minWidth,avgWidth,columns,autoNum)
|
|
97
118
|
columns = columns.map(function(item, index) {
|
|
98
119
|
//存在适应自适应列侯 多余宽度 则平均分配每一列(除最后一列)
|
|
99
120
|
if (avgWidth > 0 && index !== columns.length - 1) item.width += avgWidth / columns.length - 1;
|
|
@@ -101,7 +122,8 @@ var Table = function(props) {
|
|
|
101
122
|
});
|
|
102
123
|
} else if (diff < 0) //宽度不足 自适应列取最佳宽度 并出现滚动条 且第一列 最后一列 固定
|
|
103
124
|
columns = columns.map(function(item, index) {
|
|
104
|
-
if (
|
|
125
|
+
if (isFixedLeft && index === 0) item.fixed = "left";
|
|
126
|
+
if (isFixedRight && index === columns.length - 1) item.fixed = "right";
|
|
105
127
|
if (item.width === "auto") item.width = item.widthRang[1];
|
|
106
128
|
return item;
|
|
107
129
|
});
|
|
@@ -120,6 +142,7 @@ var Table = function(props) {
|
|
|
120
142
|
}, obj.style)
|
|
121
143
|
});
|
|
122
144
|
};
|
|
145
|
+
console.log("宽度宽度", item, item.width, item.widthRang);
|
|
123
146
|
return item;
|
|
124
147
|
});
|
|
125
148
|
return {
|
|
@@ -127,11 +150,18 @@ var Table = function(props) {
|
|
|
127
150
|
scrollWidth: scrollWidth
|
|
128
151
|
};
|
|
129
152
|
};
|
|
153
|
+
var onResize = function() {
|
|
154
|
+
clearTimeout(timerRef.current.timer);
|
|
155
|
+
timerRef.current.timer = setTimeout(function() {
|
|
156
|
+
initColumns();
|
|
157
|
+
}, 1000);
|
|
158
|
+
};
|
|
130
159
|
useEffect(function() {
|
|
131
160
|
initColumns();
|
|
132
|
-
|
|
161
|
+
window.addEventListener("resize", onResize);
|
|
133
162
|
return function() {
|
|
134
|
-
|
|
163
|
+
clearTimeout(timerRef.current.timer);
|
|
164
|
+
window.removeEventListener("resize", onResize);
|
|
135
165
|
};
|
|
136
166
|
}, [
|
|
137
167
|
props.columns
|
|
@@ -141,23 +171,22 @@ var Table = function(props) {
|
|
|
141
171
|
}, props), {
|
|
142
172
|
columns: columns,
|
|
143
173
|
scroll: scrollObject || {
|
|
144
|
-
x: "
|
|
174
|
+
x: "auto"
|
|
145
175
|
}
|
|
146
176
|
});
|
|
147
|
-
console.log("scrollObjectscrollObject", scrollObject, config);
|
|
148
177
|
return /*#__PURE__*/ _jsx("div", {
|
|
149
178
|
className: styles.Table,
|
|
150
|
-
ref:
|
|
179
|
+
ref: tableRef,
|
|
151
180
|
children: /*#__PURE__*/ _jsx(AntdTable, _object_spread({}, config))
|
|
152
181
|
});
|
|
153
182
|
};
|
|
154
183
|
// let BhdTable=Provider(Table)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
184
|
+
Table.SELECTION_COLUMN = AntdTable.SELECTION_COLUMN;
|
|
185
|
+
Table.EXPAND_COLUMN = AntdTable.EXPAND_COLUMN;
|
|
186
|
+
Table.SELECTION_ALL = AntdTable.SELECTION_ALL;
|
|
187
|
+
Table.SELECTION_INVERT = AntdTable.SELECTION_INVERT;
|
|
188
|
+
Table.SELECTION_NONE = AntdTable.SELECTION_NONE;
|
|
189
|
+
Table.Column = AntdTable.Column;
|
|
190
|
+
Table.ColumnGroup = AntdTable.ColumnGroup;
|
|
162
191
|
// Table.Summary = AntdTable.Summary;
|
|
163
192
|
export default Table;
|
|
@@ -9,43 +9,25 @@ import { Table as AntdTable } from "antd";
|
|
|
9
9
|
import TextTootip from "../textTootip";
|
|
10
10
|
var widthPercentage = /^\d+%$/;
|
|
11
11
|
var widthPx = /^\d+px$/;
|
|
12
|
-
/* 获取元素的宽度 */ var getElementPadding = function(node) {
|
|
13
|
-
var computedStyle = {};
|
|
14
|
-
if (window.getComputedStyle) computedStyle = getComputedStyle(node, null);
|
|
15
|
-
else computedStyle = node.currentStyle; //兼容IE的写法
|
|
16
|
-
return parseFloat(computedStyle["padding-left"]) + parseFloat(computedStyle["padding-right"]);
|
|
17
|
-
};
|
|
18
|
-
//获取宽度
|
|
19
|
-
var getParentWidth = function(node) {
|
|
20
|
-
try {
|
|
21
|
-
while(node && node.nodeName !== "TD")node = node.parentElement;
|
|
22
|
-
var padding = getElementPadding(node);
|
|
23
|
-
return node.clientWidth - padding;
|
|
24
|
-
} catch (error) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
12
|
// const defaultWidthRang: widthRangType = [180, 240, 320]; //默认自适应的值 [最小值,最佳值,最大值]
|
|
29
13
|
//传入的参数为onCell==>需要进行函数合并
|
|
30
14
|
var Table = function(props) {
|
|
31
|
-
var
|
|
32
|
-
var timerRef = useRef({
|
|
33
|
-
timer: null
|
|
34
|
-
});
|
|
15
|
+
var ref = useRef(null);
|
|
35
16
|
var _props_defaultWidthRang = props.defaultWidthRang, defaultWidthRang = _props_defaultWidthRang === void 0 ? [
|
|
36
17
|
180,
|
|
37
18
|
240,
|
|
38
19
|
320
|
|
39
|
-
] : _props_defaultWidthRang
|
|
20
|
+
] : _props_defaultWidthRang;
|
|
40
21
|
var _useState = _sliced_to_array(useState(props.columns || []), 2), columns = _useState[0], setColumns = _useState[1];
|
|
41
22
|
var _useState1 = _sliced_to_array(useState(props.scroll || undefined), 2), scrollObject = _useState1[0], setScrollObject = _useState1[1];
|
|
42
23
|
var columnTootipClassName = props.columnTootipClassName, columnTootipColor = props.columnTootipColor;
|
|
43
24
|
var initColumns = function() {
|
|
44
|
-
var _initColumnsWidth = initColumnsWidth(props.columns,
|
|
25
|
+
var _initColumnsWidth = initColumnsWidth(props.columns, ref.current.offsetWidth), selfColumns = _initColumnsWidth.columns, scrollWidth = _initColumnsWidth.scrollWidth;
|
|
45
26
|
setColumns(selfColumns);
|
|
46
27
|
var obj = scrollObject ? scrollObject : {};
|
|
47
28
|
obj = _object_spread_props(_object_spread({}, obj), {
|
|
48
|
-
x:
|
|
29
|
+
// x: scrollWidth,
|
|
30
|
+
x: ref.current.offsetWidth
|
|
49
31
|
});
|
|
50
32
|
setScrollObject(obj);
|
|
51
33
|
};
|
|
@@ -83,9 +65,7 @@ var Table = function(props) {
|
|
|
83
65
|
};
|
|
84
66
|
item.render = function(text) {
|
|
85
67
|
return /*#__PURE__*/ _jsx(TextTootip, {
|
|
86
|
-
width:
|
|
87
|
-
return getParentWidth(e.target);
|
|
88
|
-
},
|
|
68
|
+
width: item.width,
|
|
89
69
|
title: text,
|
|
90
70
|
trigger: "hover",
|
|
91
71
|
overlayClassName: columnTootipClassName || styles.columnTootipClassName,
|
|
@@ -114,7 +94,6 @@ var Table = function(props) {
|
|
|
114
94
|
}
|
|
115
95
|
return item;
|
|
116
96
|
});
|
|
117
|
-
console.log("diffdiff", diff, tableWidth, minWidth, avgWidth, columns, autoNum);
|
|
118
97
|
columns = columns.map(function(item, index) {
|
|
119
98
|
//存在适应自适应列侯 多余宽度 则平均分配每一列(除最后一列)
|
|
120
99
|
if (avgWidth > 0 && index !== columns.length - 1) item.width += avgWidth / columns.length - 1;
|
|
@@ -122,8 +101,7 @@ var Table = function(props) {
|
|
|
122
101
|
});
|
|
123
102
|
} else if (diff < 0) //宽度不足 自适应列取最佳宽度 并出现滚动条 且第一列 最后一列 固定
|
|
124
103
|
columns = columns.map(function(item, index) {
|
|
125
|
-
if (
|
|
126
|
-
if (isFixedRight && index === columns.length - 1) item.fixed = "right";
|
|
104
|
+
if (index === 0 || index === columns.length - 1) item.fixed = index === 0 ? "left" : "right";
|
|
127
105
|
if (item.width === "auto") item.width = item.widthRang[1];
|
|
128
106
|
return item;
|
|
129
107
|
});
|
|
@@ -142,7 +120,6 @@ var Table = function(props) {
|
|
|
142
120
|
}, obj.style)
|
|
143
121
|
});
|
|
144
122
|
};
|
|
145
|
-
console.log("宽度宽度", item, item.width, item.widthRang);
|
|
146
123
|
return item;
|
|
147
124
|
});
|
|
148
125
|
return {
|
|
@@ -150,34 +127,26 @@ var Table = function(props) {
|
|
|
150
127
|
scrollWidth: scrollWidth
|
|
151
128
|
};
|
|
152
129
|
};
|
|
153
|
-
var onResize = function() {
|
|
154
|
-
clearTimeout(timerRef.current.timer);
|
|
155
|
-
timerRef.current.timer = setTimeout(function() {
|
|
156
|
-
initColumns();
|
|
157
|
-
}, 1000);
|
|
158
|
-
};
|
|
159
130
|
useEffect(function() {
|
|
160
131
|
initColumns();
|
|
161
|
-
window.addEventListener("resize",
|
|
132
|
+
window.addEventListener("resize", initColumns);
|
|
162
133
|
return function() {
|
|
163
|
-
|
|
164
|
-
window.removeEventListener("resize", onResize);
|
|
134
|
+
window.removeEventListener("resize", initColumns);
|
|
165
135
|
};
|
|
166
136
|
}, [
|
|
167
137
|
props.columns
|
|
168
138
|
]);
|
|
169
|
-
console.log("宽度宽度", scrollObject);
|
|
170
139
|
var config = _object_spread_props(_object_spread({
|
|
171
140
|
bordered: false
|
|
172
141
|
}, props), {
|
|
173
142
|
columns: columns,
|
|
174
143
|
scroll: scrollObject || {
|
|
175
|
-
x: "
|
|
144
|
+
x: "none"
|
|
176
145
|
}
|
|
177
146
|
});
|
|
178
147
|
return /*#__PURE__*/ _jsx("div", {
|
|
179
148
|
className: styles.Table,
|
|
180
|
-
ref:
|
|
149
|
+
ref: ref,
|
|
181
150
|
children: /*#__PURE__*/ _jsx(AntdTable, _object_spread({}, config))
|
|
182
151
|
});
|
|
183
152
|
};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|