@rainbow-oh/yee-c 0.10.0 → 0.12.0
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/cjs/Anchor/style/index.less +3 -3
- package/dist/cjs/Button/demo/icon.js +1 -1
- package/dist/cjs/Button/style/index.less +72 -52
- package/dist/cjs/DatePicker/style/mobile.less +1 -1
- package/dist/cjs/Descriptions/style/index.less +6 -6
- package/dist/cjs/FloatButton/style/index.less +2 -2
- package/dist/cjs/Form/style/index.less +21 -21
- package/dist/cjs/ImageViewer/style/index.less +13 -13
- package/dist/cjs/Input/style/index.less +1 -1
- package/dist/cjs/InputNumber/style/index.less +9 -9
- package/dist/cjs/Menu/style/index.less +1 -1
- package/dist/cjs/PickerPanel/style/index.less +5 -5
- package/dist/cjs/RangePicker/style/index.less +53 -52
- package/dist/cjs/Rate/style/index.less +1 -1
- package/dist/cjs/Search/style/index.less +10 -10
- package/dist/cjs/Segmented/style/index.less +2 -2
- package/dist/cjs/Selector/selector.js +1 -1
- package/dist/cjs/Selector/style/index.less +1 -1
- package/dist/cjs/Table/demo/resizable.d.ts +3 -0
- package/dist/cjs/Table/demo/resizable.js +143 -0
- package/dist/cjs/Table/hooks/useColumnResize.d.ts +30 -0
- package/dist/cjs/Table/hooks/useColumnResize.js +217 -0
- package/dist/cjs/Table/hooks/useColumns.d.ts +3 -1
- package/dist/cjs/Table/hooks/useColumns.js +14 -3
- package/dist/cjs/Table/interface.d.ts +49 -0
- package/dist/cjs/Table/style/index.less +43 -1
- package/dist/cjs/Table/table.js +62 -9
- package/dist/cjs/Table/theader/cell.js +46 -4
- package/dist/cjs/Table/util/index.d.ts +19 -1
- package/dist/cjs/Table/util/index.js +22 -0
- package/dist/cjs/Tabs/interface.d.ts +1 -1
- package/dist/cjs/Tabs/style/index.less +9 -9
- package/dist/cjs/Tabs/tab-header/index.js +5 -1
- package/dist/cjs/Tour/demo/indicators.js +1 -1
- package/dist/cjs/Tour/demo/placement.js +1 -1
- package/dist/cjs/Transfer/style/index.less +1 -1
- package/dist/cjs/Tree/style/index.less +3 -3
- package/dist/cjs/TreeSelect/style/index.less +1 -1
- package/dist/cjs/Upload/style/index.less +11 -12
- package/dist/cjs/WheelPicker/style/index.less +3 -3
- package/dist/cjs/locale/interface.d.ts +1 -0
- package/dist/cjs/locale/lang/en_US.js +2 -1
- package/dist/cjs/locale/lang/ja_JP.js +2 -1
- package/dist/cjs/locale/lang/zh_CN.js +2 -1
- package/dist/cjs/locale/lang/zh_TW.js +2 -1
- package/dist/cjs/message/style/index.less +4 -4
- package/dist/cjs/style/color.blue.css +254 -290
- package/dist/cjs/style/color.crimson.css +434 -471
- package/dist/cjs/style/color.css +736 -508
- package/dist/cjs/style/color.dark.css +464 -501
- package/dist/cjs/style/color.gemini.css +134 -0
- package/dist/cjs/style/color.green.css +459 -495
- package/dist/cjs/style/color.jam.css +463 -500
- package/dist/cjs/style/color.navy.css +466 -503
- package/dist/cjs/style/color.peach.css +464 -501
- package/dist/cjs/style/color.pine.css +462 -500
- package/dist/cjs/style/color.pitaya.css +465 -502
- package/dist/cjs/style/color.pumpkin.css +464 -501
- package/dist/cjs/style/color.ruby.css +466 -503
- package/dist/cjs/style/size.css +144 -2
- package/dist/cjs/style/themes.css +4999 -5268
- package/dist/cjs/style/variables.css +882 -512
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Anchor/style/index.less +3 -3
- package/dist/esm/Button/demo/icon.js +7 -4
- package/dist/esm/Button/style/index.less +72 -52
- package/dist/esm/DatePicker/style/mobile.less +1 -1
- package/dist/esm/Descriptions/style/index.less +6 -6
- package/dist/esm/FloatButton/style/index.less +2 -2
- package/dist/esm/Form/style/index.less +21 -21
- package/dist/esm/ImageViewer/style/index.less +13 -13
- package/dist/esm/Input/style/index.less +1 -1
- package/dist/esm/InputNumber/style/index.less +9 -9
- package/dist/esm/Menu/style/index.less +1 -1
- package/dist/esm/PickerPanel/style/index.less +5 -5
- package/dist/esm/RangePicker/style/index.less +53 -52
- package/dist/esm/Rate/style/index.less +1 -1
- package/dist/esm/Search/style/index.less +10 -10
- package/dist/esm/Segmented/style/index.less +2 -2
- package/dist/esm/Selector/selector.js +1 -1
- package/dist/esm/Selector/style/index.less +1 -1
- package/dist/esm/Table/demo/resizable.d.ts +3 -0
- package/dist/esm/Table/demo/resizable.js +110 -0
- package/dist/esm/Table/hooks/useColumnResize.d.ts +30 -0
- package/dist/esm/Table/hooks/useColumnResize.js +206 -0
- package/dist/esm/Table/hooks/useColumns.d.ts +3 -1
- package/dist/esm/Table/hooks/useColumns.js +9 -4
- package/dist/esm/Table/interface.d.ts +49 -0
- package/dist/esm/Table/style/index.less +43 -1
- package/dist/esm/Table/table.js +83 -13
- package/dist/esm/Table/theader/cell.js +38 -3
- package/dist/esm/Table/util/index.d.ts +19 -1
- package/dist/esm/Table/util/index.js +37 -0
- package/dist/esm/Tabs/interface.d.ts +1 -1
- package/dist/esm/Tabs/style/index.less +9 -9
- package/dist/esm/Tabs/tab-header/index.js +7 -2
- package/dist/esm/Tour/demo/indicators.js +1 -1
- package/dist/esm/Tour/demo/placement.js +1 -1
- package/dist/esm/Transfer/style/index.less +1 -1
- package/dist/esm/Tree/style/index.less +3 -3
- package/dist/esm/TreeSelect/style/index.less +1 -1
- package/dist/esm/Upload/style/index.less +11 -12
- package/dist/esm/WheelPicker/style/index.less +3 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/locale/interface.d.ts +1 -0
- package/dist/esm/locale/lang/en_US.js +2 -1
- package/dist/esm/locale/lang/ja_JP.js +2 -1
- package/dist/esm/locale/lang/zh_CN.js +2 -1
- package/dist/esm/locale/lang/zh_TW.js +2 -1
- package/dist/esm/message/style/index.less +4 -4
- package/dist/esm/style/color.blue.css +254 -290
- package/dist/esm/style/color.crimson.css +434 -471
- package/dist/esm/style/color.css +736 -508
- package/dist/esm/style/color.dark.css +464 -501
- package/dist/esm/style/color.gemini.css +134 -0
- package/dist/esm/style/color.green.css +459 -495
- package/dist/esm/style/color.jam.css +463 -500
- package/dist/esm/style/color.navy.css +466 -503
- package/dist/esm/style/color.peach.css +464 -501
- package/dist/esm/style/color.pine.css +462 -500
- package/dist/esm/style/color.pitaya.css +465 -502
- package/dist/esm/style/color.pumpkin.css +464 -501
- package/dist/esm/style/color.ruby.css +466 -503
- package/dist/esm/style/size.css +144 -2
- package/dist/esm/style/themes.css +4999 -5268
- package/dist/esm/style/variables.css +882 -512
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +80 -22
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +4 -2
- package/src/Anchor/style/index.less +3 -3
- package/src/Button/demo/icon.tsx +5 -3
- package/src/Button/style/index.less +72 -52
- package/src/DatePicker/style/mobile.less +1 -1
- package/src/Descriptions/style/index.less +6 -6
- package/src/FloatButton/style/index.less +2 -2
- package/src/Form/style/index.less +21 -21
- package/src/ImageViewer/style/index.less +13 -13
- package/src/Input/style/index.less +1 -1
- package/src/InputNumber/style/index.less +9 -9
- package/src/Menu/style/index.less +1 -1
- package/src/PickerPanel/style/index.less +5 -5
- package/src/RangePicker/style/index.less +53 -52
- package/src/Rate/style/index.less +1 -1
- package/src/Search/style/index.less +10 -10
- package/src/Segmented/style/index.less +2 -2
- package/src/Selector/selector.tsx +1 -1
- package/src/Selector/style/index.less +1 -1
- package/src/Table/demo/resizable.tsx +106 -0
- package/src/Table/hooks/useColumnResize.ts +224 -0
- package/src/Table/hooks/useColumns.ts +18 -3
- package/src/Table/index.en-US.md +7 -0
- package/src/Table/index.zh-CN.md +7 -0
- package/src/Table/interface.ts +52 -0
- package/src/Table/style/index.less +43 -1
- package/src/Table/table-resize.test.tsx +234 -0
- package/src/Table/table.tsx +90 -13
- package/src/Table/theader/cell.tsx +52 -2
- package/src/Table/util/index.ts +44 -1
- package/src/Tabs/interface.ts +1 -1
- package/src/Tabs/style/index.less +9 -9
- package/src/Tabs/tab-header/index.tsx +5 -1
- package/src/Tour/demo/indicators.tsx +2 -2
- package/src/Tour/demo/placement.tsx +1 -1
- package/src/Transfer/style/index.less +1 -1
- package/src/Tree/style/index.less +3 -3
- package/src/TreeSelect/style/index.less +1 -1
- package/src/Upload/style/index.less +11 -12
- package/src/WheelPicker/style/index.less +3 -3
- package/src/index.ts +1 -0
- package/src/locale/interface.ts +1 -0
- package/src/locale/lang/en_US.ts +1 -0
- package/src/locale/lang/ja_JP.ts +1 -0
- package/src/locale/lang/zh_CN.ts +1 -0
- package/src/locale/lang/zh_TW.ts +1 -0
- package/src/message/style/index.less +4 -4
- package/src/style/color.blue.css +254 -290
- package/src/style/color.crimson.css +434 -471
- package/src/style/color.css +736 -508
- package/src/style/color.dark.css +464 -501
- package/src/style/color.gemini.css +134 -0
- package/src/style/color.green.css +459 -495
- package/src/style/color.jam.css +463 -500
- package/src/style/color.navy.css +466 -503
- package/src/style/color.peach.css +464 -501
- package/src/style/color.pine.css +462 -500
- package/src/style/color.pitaya.css +465 -502
- package/src/style/color.pumpkin.css +464 -501
- package/src/style/color.ruby.css +466 -503
- package/src/style/size.css +144 -2
- package/src/version.ts +1 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
+
mod
|
|
43
|
+
));
|
|
44
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
+
|
|
46
|
+
// src/Table/hooks/useColumnResize.ts
|
|
47
|
+
var useColumnResize_exports = {};
|
|
48
|
+
__export(useColumnResize_exports, {
|
|
49
|
+
default: () => useColumnResize
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(useColumnResize_exports);
|
|
52
|
+
var React = __toESM(require("react"));
|
|
53
|
+
var import_useLatest = __toESM(require("../../hooks/useLatest"));
|
|
54
|
+
var DEFAULT_MIN_COLUMN_WIDTH = 40;
|
|
55
|
+
var KEYBOARD_STEP = 8;
|
|
56
|
+
var clampWidth = (width, column) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const min = Math.max((_a = column.minWidth) != null ? _a : DEFAULT_MIN_COLUMN_WIDTH, 0);
|
|
59
|
+
const max = column.maxWidth;
|
|
60
|
+
if (width < min)
|
|
61
|
+
return min;
|
|
62
|
+
if (max !== void 0 && width > max)
|
|
63
|
+
return max;
|
|
64
|
+
return Math.round(width);
|
|
65
|
+
};
|
|
66
|
+
function useColumnResize({
|
|
67
|
+
tableRef,
|
|
68
|
+
columnsRef,
|
|
69
|
+
onColumnResize,
|
|
70
|
+
onColumnResizeEnd
|
|
71
|
+
}) {
|
|
72
|
+
const [resizedWidths, setResizedWidths] = React.useState({});
|
|
73
|
+
const [resizingKey, setResizingKey] = React.useState(null);
|
|
74
|
+
const onColumnResizeRef = (0, import_useLatest.default)(onColumnResize);
|
|
75
|
+
const onColumnResizeEndRef = (0, import_useLatest.default)(onColumnResizeEnd);
|
|
76
|
+
const resizedWidthsRef = (0, import_useLatest.default)(resizedWidths);
|
|
77
|
+
const frameRef = React.useRef(0);
|
|
78
|
+
const teardownRef = React.useRef(null);
|
|
79
|
+
const snapshotWidths = React.useCallback(() => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
const columns = columnsRef.current || [];
|
|
82
|
+
const colElements = (_a = tableRef.current) == null ? void 0 : _a.querySelectorAll(
|
|
83
|
+
":scope > colgroup > col"
|
|
84
|
+
);
|
|
85
|
+
if (!colElements || colElements.length !== columns.length)
|
|
86
|
+
return null;
|
|
87
|
+
if (!columns.length)
|
|
88
|
+
return null;
|
|
89
|
+
const snapshot = {};
|
|
90
|
+
for (let index = 0; index < columns.length; index += 1) {
|
|
91
|
+
const key = (_b = columns[index]) == null ? void 0 : _b.resizeKey;
|
|
92
|
+
const width = Math.round(
|
|
93
|
+
colElements[index].getBoundingClientRect().width
|
|
94
|
+
);
|
|
95
|
+
if (!key || !Number.isFinite(width) || width <= 0)
|
|
96
|
+
return null;
|
|
97
|
+
snapshot[key] = width;
|
|
98
|
+
}
|
|
99
|
+
return snapshot;
|
|
100
|
+
}, [columnsRef, tableRef]);
|
|
101
|
+
const findColumn = React.useCallback(
|
|
102
|
+
(resizeKey) => (columnsRef.current || []).find(
|
|
103
|
+
(column) => column.resizeKey === resizeKey
|
|
104
|
+
),
|
|
105
|
+
[columnsRef]
|
|
106
|
+
);
|
|
107
|
+
const onResizeStart = React.useCallback(
|
|
108
|
+
(event, resizeKey) => {
|
|
109
|
+
if (event.button !== 0)
|
|
110
|
+
return;
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
const column = findColumn(resizeKey);
|
|
114
|
+
if (!column)
|
|
115
|
+
return;
|
|
116
|
+
const snapshot = snapshotWidths();
|
|
117
|
+
if (!snapshot)
|
|
118
|
+
return;
|
|
119
|
+
const startX = event.clientX;
|
|
120
|
+
const startWidth = snapshot[resizeKey];
|
|
121
|
+
let latestWidth = startWidth;
|
|
122
|
+
setResizingKey(resizeKey);
|
|
123
|
+
setResizedWidths(snapshot);
|
|
124
|
+
document.body.style.userSelect = "none";
|
|
125
|
+
document.body.style.cursor = "col-resize";
|
|
126
|
+
const applyWidth = (clientX) => {
|
|
127
|
+
var _a;
|
|
128
|
+
const next = clampWidth(startWidth + (clientX - startX), column);
|
|
129
|
+
if (next === latestWidth)
|
|
130
|
+
return;
|
|
131
|
+
latestWidth = next;
|
|
132
|
+
setResizedWidths((current) => __spreadProps(__spreadValues({}, current), { [resizeKey]: next }));
|
|
133
|
+
(_a = onColumnResizeRef.current) == null ? void 0 : _a.call(onColumnResizeRef, next, column);
|
|
134
|
+
};
|
|
135
|
+
const onPointerMove = (moveEvent) => {
|
|
136
|
+
const { clientX } = moveEvent;
|
|
137
|
+
if (frameRef.current)
|
|
138
|
+
cancelAnimationFrame(frameRef.current);
|
|
139
|
+
frameRef.current = requestAnimationFrame(() => {
|
|
140
|
+
frameRef.current = 0;
|
|
141
|
+
applyWidth(clientX);
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
const detachers = [];
|
|
145
|
+
const bind = (type, handler) => {
|
|
146
|
+
window.addEventListener(type, handler);
|
|
147
|
+
detachers.push(
|
|
148
|
+
() => window.removeEventListener(type, handler)
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
const teardown = () => {
|
|
152
|
+
if (frameRef.current) {
|
|
153
|
+
cancelAnimationFrame(frameRef.current);
|
|
154
|
+
frameRef.current = 0;
|
|
155
|
+
}
|
|
156
|
+
detachers.forEach((detach) => detach());
|
|
157
|
+
detachers.length = 0;
|
|
158
|
+
document.body.style.userSelect = "";
|
|
159
|
+
document.body.style.cursor = "";
|
|
160
|
+
teardownRef.current = null;
|
|
161
|
+
};
|
|
162
|
+
const stop = () => {
|
|
163
|
+
var _a;
|
|
164
|
+
teardown();
|
|
165
|
+
setResizingKey(null);
|
|
166
|
+
(_a = onColumnResizeEndRef.current) == null ? void 0 : _a.call(onColumnResizeEndRef, latestWidth, column);
|
|
167
|
+
};
|
|
168
|
+
teardownRef.current = teardown;
|
|
169
|
+
bind("pointermove", onPointerMove);
|
|
170
|
+
bind("pointerup", stop);
|
|
171
|
+
bind("pointercancel", stop);
|
|
172
|
+
},
|
|
173
|
+
[findColumn, snapshotWidths, onColumnResizeRef, onColumnResizeEndRef]
|
|
174
|
+
);
|
|
175
|
+
const onResizeStep = React.useCallback(
|
|
176
|
+
(resizeKey, direction) => {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
const column = findColumn(resizeKey);
|
|
179
|
+
if (!column)
|
|
180
|
+
return;
|
|
181
|
+
const base = resizedWidthsRef.current;
|
|
182
|
+
const snapshot = base[resizeKey] === void 0 ? snapshotWidths() : base;
|
|
183
|
+
if (!snapshot)
|
|
184
|
+
return;
|
|
185
|
+
const next = clampWidth(
|
|
186
|
+
snapshot[resizeKey] + direction * KEYBOARD_STEP,
|
|
187
|
+
column
|
|
188
|
+
);
|
|
189
|
+
if (next === snapshot[resizeKey])
|
|
190
|
+
return;
|
|
191
|
+
setResizedWidths(__spreadProps(__spreadValues({}, snapshot), { [resizeKey]: next }));
|
|
192
|
+
(_a = onColumnResizeRef.current) == null ? void 0 : _a.call(onColumnResizeRef, next, column);
|
|
193
|
+
(_b = onColumnResizeEndRef.current) == null ? void 0 : _b.call(onColumnResizeEndRef, next, column);
|
|
194
|
+
},
|
|
195
|
+
[
|
|
196
|
+
findColumn,
|
|
197
|
+
snapshotWidths,
|
|
198
|
+
resizedWidthsRef,
|
|
199
|
+
onColumnResizeRef,
|
|
200
|
+
onColumnResizeEndRef
|
|
201
|
+
]
|
|
202
|
+
);
|
|
203
|
+
const resetResizedWidths = React.useCallback(() => {
|
|
204
|
+
setResizedWidths((current) => Object.keys(current).length ? {} : current);
|
|
205
|
+
}, []);
|
|
206
|
+
React.useEffect(() => () => {
|
|
207
|
+
var _a;
|
|
208
|
+
return (_a = teardownRef.current) == null ? void 0 : _a.call(teardownRef);
|
|
209
|
+
}, []);
|
|
210
|
+
return {
|
|
211
|
+
resizedWidths,
|
|
212
|
+
resizingKey,
|
|
213
|
+
onResizeStart,
|
|
214
|
+
onResizeStep,
|
|
215
|
+
resetResizedWidths
|
|
216
|
+
};
|
|
217
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ColumnProps, ExpandableType, RowSelectionType, WrapedColumnProps } from '../interface';
|
|
3
|
-
export default function useColumns({ children, columns, rowSelection, expandable, measuredColumnWidths, }: {
|
|
3
|
+
export default function useColumns({ children, columns, rowSelection, expandable, measuredColumnWidths, resizable, resizedWidths, }: {
|
|
4
4
|
children?: React.ReactElement<ColumnProps> | React.ReactElement<ColumnProps>[];
|
|
5
5
|
columns: ColumnProps[];
|
|
6
6
|
rowSelection?: RowSelectionType;
|
|
7
7
|
expandable?: ExpandableType;
|
|
8
8
|
measuredColumnWidths?: number[];
|
|
9
|
+
resizable?: boolean;
|
|
10
|
+
resizedWidths?: Record<string, number>;
|
|
9
11
|
}): {
|
|
10
12
|
wrapedColumns: WrapedColumnProps[];
|
|
11
13
|
headerRows: import("../interface").HeaderCell[][];
|
|
@@ -64,7 +64,9 @@ function useColumns({
|
|
|
64
64
|
columns,
|
|
65
65
|
rowSelection,
|
|
66
66
|
expandable,
|
|
67
|
-
measuredColumnWidths
|
|
67
|
+
measuredColumnWidths,
|
|
68
|
+
resizable,
|
|
69
|
+
resizedWidths
|
|
68
70
|
}) {
|
|
69
71
|
const childColumns = (0, import_react.useMemo)(() => {
|
|
70
72
|
return children ? getColumnsFromChild(children) : null;
|
|
@@ -73,10 +75,19 @@ function useColumns({
|
|
|
73
75
|
const base = (0, import_deepClone.default)(childColumns || columns || []) || [];
|
|
74
76
|
const tree = (0, import_header.injectSelectionExpand)(base, rowSelection, expandable);
|
|
75
77
|
const leaves = (0, import_header.flattenLeafColumns)(tree);
|
|
76
|
-
const
|
|
78
|
+
const resized = (0, import_util.applyColumnResize)(leaves, resizable, resizedWidths);
|
|
79
|
+
const wraped = (0, import_util.handleColumns)(resized, measuredColumnWidths);
|
|
77
80
|
const rows = (0, import_header.parseHeaderRows)(tree, wraped);
|
|
78
81
|
return { wrapedColumns: wraped, headerRows: rows };
|
|
79
|
-
}, [
|
|
82
|
+
}, [
|
|
83
|
+
childColumns,
|
|
84
|
+
columns,
|
|
85
|
+
rowSelection,
|
|
86
|
+
expandable,
|
|
87
|
+
measuredColumnWidths,
|
|
88
|
+
resizable,
|
|
89
|
+
resizedWidths
|
|
90
|
+
]);
|
|
80
91
|
return {
|
|
81
92
|
wrapedColumns,
|
|
82
93
|
headerRows
|
|
@@ -67,6 +67,18 @@ export interface HeadCellProps extends Omit<WrapedColumnProps, 'title'> {
|
|
|
67
67
|
};
|
|
68
68
|
onSort?: (dataIndex: string, sorter: any) => void;
|
|
69
69
|
onInternalFilter?: (dataIndex: string, value: string) => void;
|
|
70
|
+
/**
|
|
71
|
+
* `resizeKey` of the column currently being dragged, if any
|
|
72
|
+
*/
|
|
73
|
+
resizingKey?: string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Begin a pointer driven column resize. Injected by Table when resizing is on.
|
|
76
|
+
*/
|
|
77
|
+
onResizeStart?: (event: React.PointerEvent<HTMLElement>, resizeKey: string) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Nudge a column width by `delta` px, for keyboard driven resizing
|
|
80
|
+
*/
|
|
81
|
+
onResizeStep?: (resizeKey: string, delta: number) => void;
|
|
70
82
|
/**
|
|
71
83
|
* Horizontal span, used for grouped header cells
|
|
72
84
|
*/
|
|
@@ -227,6 +239,20 @@ export interface ColumnProps {
|
|
|
227
239
|
* Set width
|
|
228
240
|
*/
|
|
229
241
|
width?: number | string;
|
|
242
|
+
/**
|
|
243
|
+
* Whether this column can be resized by dragging the right edge of its header
|
|
244
|
+
* cell. Falls back to the table level `resizable` when not set.
|
|
245
|
+
*/
|
|
246
|
+
resizable?: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Lower bound (in px) applied while resizing this column
|
|
249
|
+
* @default 40
|
|
250
|
+
*/
|
|
251
|
+
minWidth?: number;
|
|
252
|
+
/**
|
|
253
|
+
* Upper bound (in px) applied while resizing this column
|
|
254
|
+
*/
|
|
255
|
+
maxWidth?: number;
|
|
230
256
|
/**
|
|
231
257
|
* Set header display text
|
|
232
258
|
*/
|
|
@@ -261,6 +287,12 @@ export interface WrapedColumnProps extends ColumnProps, ExpandableType, Omit<Row
|
|
|
261
287
|
* Whether this is the first column fixed to the right
|
|
262
288
|
*/
|
|
263
289
|
isFixedRightFirst?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Stable identity of this leaf column, used as the key of the resized width
|
|
292
|
+
* map. Only assigned to leaf columns, so its presence also marks a column as
|
|
293
|
+
* a valid resize target (group header cells never carry one).
|
|
294
|
+
*/
|
|
295
|
+
resizeKey?: string;
|
|
264
296
|
}
|
|
265
297
|
/**
|
|
266
298
|
* A header cell resolved from the column tree, with computed span info for multi-level headers.
|
|
@@ -554,6 +586,23 @@ export interface TableProps extends FooterProps, Omit<HeaderProps, 'pageData'>,
|
|
|
554
586
|
* Set table layout
|
|
555
587
|
*/
|
|
556
588
|
tableLayout?: 'auto' | 'fixed';
|
|
589
|
+
/**
|
|
590
|
+
* Whether columns can be resized by dragging the right edge of their header
|
|
591
|
+
* cell. Individual columns can opt out with `column.resizable: false`.
|
|
592
|
+
*
|
|
593
|
+
* The first drag snapshots the rendered width of every column and switches the
|
|
594
|
+
* table to a px controlled `table-layout: fixed`, so column widths stay exactly
|
|
595
|
+
* where they are dragged instead of being redistributed by the browser.
|
|
596
|
+
*/
|
|
597
|
+
resizable?: boolean;
|
|
598
|
+
/**
|
|
599
|
+
* Fired on every width change while a column is being dragged
|
|
600
|
+
*/
|
|
601
|
+
onColumnResize?: (width: number, column: WrapedColumnProps) => void;
|
|
602
|
+
/**
|
|
603
|
+
* Fired once when a column resize interaction finishes
|
|
604
|
+
*/
|
|
605
|
+
onColumnResizeEnd?: (width: number, column: WrapedColumnProps) => void;
|
|
557
606
|
/**
|
|
558
607
|
* Whether to enable virtual list
|
|
559
608
|
*/
|
|
@@ -71,6 +71,48 @@
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// Sits inside the header cell's right padding so it never overlaps the sorter
|
|
75
|
+
// or filter controls, which are laid out against the content edge.
|
|
76
|
+
&-resize-handle {
|
|
77
|
+
position: absolute;
|
|
78
|
+
top: 0;
|
|
79
|
+
right: 0;
|
|
80
|
+
z-index: 2;
|
|
81
|
+
width: var(--yee-table-resize-handle-width);
|
|
82
|
+
height: 100%;
|
|
83
|
+
cursor: col-resize;
|
|
84
|
+
background-color: transparent;
|
|
85
|
+
touch-action: none;
|
|
86
|
+
user-select: none;
|
|
87
|
+
|
|
88
|
+
&::after {
|
|
89
|
+
position: absolute;
|
|
90
|
+
content: '';
|
|
91
|
+
top: 25%;
|
|
92
|
+
right: calc(var(--yee-table-resize-handle-width) / 2 - 1px);
|
|
93
|
+
width: 2px;
|
|
94
|
+
height: 50%;
|
|
95
|
+
background-color: transparent;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&:hover::after,
|
|
99
|
+
&:focus-visible::after,
|
|
100
|
+
&-active::after {
|
|
101
|
+
background-color: var(--yee-color-primary);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&:focus-visible {
|
|
105
|
+
outline: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// While dragging, the pointer leaves the handle constantly; keep the cursor and
|
|
110
|
+
// the selection lock consistent across the whole table.
|
|
111
|
+
&-resizing {
|
|
112
|
+
cursor: col-resize;
|
|
113
|
+
user-select: none;
|
|
114
|
+
}
|
|
115
|
+
|
|
74
116
|
&-filter {
|
|
75
117
|
max-height: var(--yee-table-filter-popup-height);
|
|
76
118
|
background-color: var(--yee-table-filter-list-bg-color);
|
|
@@ -158,7 +200,7 @@
|
|
|
158
200
|
margin-left: 4px;
|
|
159
201
|
|
|
160
202
|
.active {
|
|
161
|
-
color: var(--yee-primary
|
|
203
|
+
color: var(--yee-color-primary);
|
|
162
204
|
}
|
|
163
205
|
}
|
|
164
206
|
|
package/dist/cjs/Table/table.js
CHANGED
|
@@ -68,6 +68,7 @@ var import_Spin = __toESM(require("../Spin"));
|
|
|
68
68
|
var import_col_group = __toESM(require("./col-group"));
|
|
69
69
|
var import_footer = __toESM(require("./footer"));
|
|
70
70
|
var import_header = __toESM(require("./header"));
|
|
71
|
+
var import_useColumnResize = __toESM(require("./hooks/useColumnResize"));
|
|
71
72
|
var import_useColumns = __toESM(require("./hooks/useColumns"));
|
|
72
73
|
var import_useExpand = __toESM(require("./hooks/useExpand"));
|
|
73
74
|
var import_useSelection = __toESM(require("./hooks/useSelection"));
|
|
@@ -75,7 +76,6 @@ var import_tbody = __toESM(require("./tbody"));
|
|
|
75
76
|
var import_tfooter = __toESM(require("./tfooter"));
|
|
76
77
|
var import_theader = __toESM(require("./theader"));
|
|
77
78
|
var import_Config_Provider = require("../Config-Provider");
|
|
78
|
-
var import_useLatest = __toESM(require("../hooks/useLatest"));
|
|
79
79
|
var import_mergeContextToProps = __toESM(require("../utils/mergeContextToProps"));
|
|
80
80
|
var import_omit = __toESM(require("../utils/omit"));
|
|
81
81
|
var import_types = require("../utils/types");
|
|
@@ -97,6 +97,9 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
97
97
|
rowKey = "key",
|
|
98
98
|
bordered,
|
|
99
99
|
tableLayout,
|
|
100
|
+
resizable,
|
|
101
|
+
onColumnResize,
|
|
102
|
+
onColumnResizeEnd,
|
|
100
103
|
loading = false,
|
|
101
104
|
showHeader = true,
|
|
102
105
|
pagination: propPagination = true,
|
|
@@ -123,6 +126,9 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
123
126
|
"rowKey",
|
|
124
127
|
"bordered",
|
|
125
128
|
"tableLayout",
|
|
129
|
+
"resizable",
|
|
130
|
+
"onColumnResize",
|
|
131
|
+
"onColumnResizeEnd",
|
|
126
132
|
"loading",
|
|
127
133
|
"showHeader",
|
|
128
134
|
"pagination",
|
|
@@ -142,6 +148,22 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
142
148
|
]);
|
|
143
149
|
const dataAttrs = (0, import_types.pickDataAttrs)(rest);
|
|
144
150
|
const [measuredColumnWidths, setMeasuredColumnWidths] = import_react.default.useState();
|
|
151
|
+
const contentRef = (0, import_react.useRef)(null);
|
|
152
|
+
const tableRef = (0, import_react.useRef)(null);
|
|
153
|
+
const wrapedColumnsRef = (0, import_react.useRef)([]);
|
|
154
|
+
const {
|
|
155
|
+
resizedWidths,
|
|
156
|
+
resizingKey,
|
|
157
|
+
onResizeStart,
|
|
158
|
+
onResizeStep,
|
|
159
|
+
resetResizedWidths
|
|
160
|
+
} = (0, import_useColumnResize.default)({
|
|
161
|
+
tableRef,
|
|
162
|
+
columnsRef: wrapedColumnsRef,
|
|
163
|
+
onColumnResize,
|
|
164
|
+
onColumnResizeEnd
|
|
165
|
+
});
|
|
166
|
+
const hasResizeSnapshot = Object.keys(resizedWidths).length > 0;
|
|
145
167
|
const getRowKey = import_react.default.useCallback(
|
|
146
168
|
(record, key = rowKey) => {
|
|
147
169
|
return typeof key === "function" ? key(record) : record[key];
|
|
@@ -156,8 +178,31 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
156
178
|
columns: propColumns,
|
|
157
179
|
expandable,
|
|
158
180
|
rowSelection,
|
|
159
|
-
measuredColumnWidths
|
|
181
|
+
measuredColumnWidths: hasResizeSnapshot ? void 0 : measuredColumnWidths,
|
|
182
|
+
resizable,
|
|
183
|
+
resizedWidths
|
|
160
184
|
});
|
|
185
|
+
wrapedColumnsRef.current = wrapedColumns;
|
|
186
|
+
const resizeTotalWidth = (0, import_react.useMemo)(() => {
|
|
187
|
+
if (!wrapedColumns.length)
|
|
188
|
+
return void 0;
|
|
189
|
+
let total = 0;
|
|
190
|
+
for (const column of wrapedColumns) {
|
|
191
|
+
const width = column.resizeKey ? resizedWidths[column.resizeKey] : void 0;
|
|
192
|
+
if (!width || !Number.isFinite(width))
|
|
193
|
+
return void 0;
|
|
194
|
+
total += width;
|
|
195
|
+
}
|
|
196
|
+
return total;
|
|
197
|
+
}, [wrapedColumns, resizedWidths]);
|
|
198
|
+
const resizeActive = resizeTotalWidth !== void 0;
|
|
199
|
+
const resizeKeysSignature = (0, import_react.useMemo)(
|
|
200
|
+
() => wrapedColumns.map((column) => column.resizeKey).join("|"),
|
|
201
|
+
[wrapedColumns]
|
|
202
|
+
);
|
|
203
|
+
(0, import_react.useEffect)(() => {
|
|
204
|
+
resetResizedWidths();
|
|
205
|
+
}, [resizeKeysSignature, resetResizedWidths]);
|
|
161
206
|
const {
|
|
162
207
|
data: filteredData,
|
|
163
208
|
filterRecords,
|
|
@@ -215,8 +260,6 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
215
260
|
onChange: onSelectionChange
|
|
216
261
|
} = (0, import_useSelection.default)({ pageData, dataSource, getRowKey, rowSelection, allKeys });
|
|
217
262
|
const prevFilterRecordsRef = (0, import_react.useRef)(filterRecords);
|
|
218
|
-
const contentRef = (0, import_react.useRef)(null);
|
|
219
|
-
const tableRef = (0, import_react.useRef)(null);
|
|
220
263
|
const [horizontalScroll, setHorizontalScroll] = import_react.default.useState({
|
|
221
264
|
left: false,
|
|
222
265
|
right: false
|
|
@@ -244,7 +287,6 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
244
287
|
).join("|"),
|
|
245
288
|
[wrapedColumns]
|
|
246
289
|
);
|
|
247
|
-
const wrapedColumnsRef = (0, import_useLatest.default)(wrapedColumns);
|
|
248
290
|
const updateMeasuredColumnWidths = import_react.default.useCallback(() => {
|
|
249
291
|
var _a2;
|
|
250
292
|
const columns = wrapedColumnsRef.current;
|
|
@@ -345,7 +387,10 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
345
387
|
sorters,
|
|
346
388
|
onSort: handleSort,
|
|
347
389
|
onCheckAll,
|
|
348
|
-
onInternalFilter: onFilterInternal
|
|
390
|
+
onInternalFilter: onFilterInternal,
|
|
391
|
+
resizingKey,
|
|
392
|
+
onResizeStart,
|
|
393
|
+
onResizeStep
|
|
349
394
|
})
|
|
350
395
|
);
|
|
351
396
|
};
|
|
@@ -373,8 +418,12 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
373
418
|
const renderTable = () => {
|
|
374
419
|
const tableProps = {
|
|
375
420
|
style: __spreadProps(__spreadValues({}, styles == null ? void 0 : styles.table), {
|
|
376
|
-
|
|
377
|
-
|
|
421
|
+
// An explicit total width replaces both `width: 100%` and `scroll.x`:
|
|
422
|
+
// either of those would let the browser stretch the table and redistribute
|
|
423
|
+
// the extra space across the columns, undoing the drag.
|
|
424
|
+
minWidth: resizeActive ? void 0 : scroll == null ? void 0 : scroll.x,
|
|
425
|
+
width: resizeTotalWidth,
|
|
426
|
+
tableLayout: resizeActive ? "fixed" : (pageData == null ? void 0 : pageData.length) ? tableLayout : void 0
|
|
378
427
|
}),
|
|
379
428
|
className: (0, import_clsx.default)(
|
|
380
429
|
{ [`${prefixCls}-bordered`]: bordered },
|
|
@@ -434,7 +483,11 @@ var Table = import_react.default.forwardRef((baseprops, ref) => {
|
|
|
434
483
|
return /* @__PURE__ */ import_react.default.createElement(
|
|
435
484
|
"div",
|
|
436
485
|
__spreadValues({
|
|
437
|
-
className: (0, import_clsx.default)(
|
|
486
|
+
className: (0, import_clsx.default)(
|
|
487
|
+
`${prefixCls}-box`,
|
|
488
|
+
{ [`${prefixCls}-resizing`]: !!resizingKey },
|
|
489
|
+
className
|
|
490
|
+
),
|
|
438
491
|
style,
|
|
439
492
|
ref
|
|
440
493
|
}, dataAttrs),
|
|
@@ -89,9 +89,14 @@ var HeadCell = (props) => {
|
|
|
89
89
|
width,
|
|
90
90
|
colSpan,
|
|
91
91
|
rowSpan,
|
|
92
|
+
resizable,
|
|
93
|
+
resizeKey,
|
|
94
|
+
resizingKey,
|
|
92
95
|
onHeaderCell,
|
|
93
96
|
onSort,
|
|
94
|
-
onInternalFilter
|
|
97
|
+
onInternalFilter,
|
|
98
|
+
onResizeStart,
|
|
99
|
+
onResizeStep
|
|
95
100
|
} = _a, rest = __objRest(_a, [
|
|
96
101
|
"fixed",
|
|
97
102
|
"isFixedLeftLast",
|
|
@@ -112,9 +117,14 @@ var HeadCell = (props) => {
|
|
|
112
117
|
"width",
|
|
113
118
|
"colSpan",
|
|
114
119
|
"rowSpan",
|
|
120
|
+
"resizable",
|
|
121
|
+
"resizeKey",
|
|
122
|
+
"resizingKey",
|
|
115
123
|
"onHeaderCell",
|
|
116
124
|
"onSort",
|
|
117
|
-
"onInternalFilter"
|
|
125
|
+
"onInternalFilter",
|
|
126
|
+
"onResizeStart",
|
|
127
|
+
"onResizeStep"
|
|
118
128
|
]);
|
|
119
129
|
const { prefixCls } = (0, import_react.useContext)(import_table.TableCtx);
|
|
120
130
|
const { locale } = (0, import_locale.useLocale)();
|
|
@@ -208,6 +218,38 @@ var HeadCell = (props) => {
|
|
|
208
218
|
},
|
|
209
219
|
className
|
|
210
220
|
);
|
|
221
|
+
const showResizeHandle = !!(resizable && resizeKey && onResizeStart);
|
|
222
|
+
const isResizing = !!resizeKey && resizingKey === resizeKey;
|
|
223
|
+
const renderResizeHandle = () => {
|
|
224
|
+
if (!showResizeHandle)
|
|
225
|
+
return null;
|
|
226
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
227
|
+
"span",
|
|
228
|
+
{
|
|
229
|
+
role: "separator",
|
|
230
|
+
"aria-orientation": "vertical",
|
|
231
|
+
"aria-label": tableLocale.resizeColumn || "Drag to resize column",
|
|
232
|
+
tabIndex: 0,
|
|
233
|
+
className: (0, import_clsx.default)(`${prefixCls}-resize-handle`, {
|
|
234
|
+
[`${prefixCls}-resize-handle-active`]: isResizing
|
|
235
|
+
}),
|
|
236
|
+
onPointerDown: (event) => onResizeStart == null ? void 0 : onResizeStart(event, resizeKey),
|
|
237
|
+
onClick: (event) => {
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
event.stopPropagation();
|
|
240
|
+
},
|
|
241
|
+
onKeyDown: (event) => {
|
|
242
|
+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight")
|
|
243
|
+
return;
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
onResizeStep == null ? void 0 : onResizeStep(
|
|
246
|
+
resizeKey,
|
|
247
|
+
event.key === "ArrowLeft" ? -1 : 1
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
};
|
|
211
253
|
const getThProps = () => {
|
|
212
254
|
const styles2 = __spreadProps(__spreadValues({}, style), { width, maxWidth: width, textAlign: align });
|
|
213
255
|
const cellProps = onHeaderCell ? onHeaderCell(props) : {};
|
|
@@ -222,9 +264,9 @@ var HeadCell = (props) => {
|
|
|
222
264
|
const thProps = getThProps();
|
|
223
265
|
const renderCell = () => {
|
|
224
266
|
if (!filter && !sorter) {
|
|
225
|
-
return /* @__PURE__ */ import_react.default.createElement("th", __spreadValues({}, thProps), title);
|
|
267
|
+
return /* @__PURE__ */ import_react.default.createElement("th", __spreadValues({}, thProps), title, renderResizeHandle());
|
|
226
268
|
}
|
|
227
|
-
return /* @__PURE__ */ import_react.default.createElement("th", __spreadValues({}, thProps), renderCellWithAction());
|
|
269
|
+
return /* @__PURE__ */ import_react.default.createElement("th", __spreadValues({}, thProps), renderCellWithAction(), renderResizeHandle());
|
|
228
270
|
};
|
|
229
271
|
const cell = renderCell();
|
|
230
272
|
return cell;
|
|
@@ -1,2 +1,20 @@
|
|
|
1
|
-
import { WrapedColumnProps } from '../interface';
|
|
1
|
+
import { ColumnProps, WrapedColumnProps } from '../interface';
|
|
2
|
+
/**
|
|
3
|
+
* Stable identity for a leaf column, used to key its resized width.
|
|
4
|
+
*
|
|
5
|
+
* `key`/`dataIndex` survive re-ordering and data changes, so they are preferred.
|
|
6
|
+
* Columns declaring neither fall back to their position, which is the best that
|
|
7
|
+
* can be done without asking the caller for an id.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getColumnResizeKey(column: ColumnProps, index: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* Stamp every leaf column with its `resizeKey`, resolve whether it is resizable
|
|
12
|
+
* (column level setting wins over the table level one) and override `width` with
|
|
13
|
+
* the dragged value when there is one.
|
|
14
|
+
*
|
|
15
|
+
* This runs before `handleColumns` so that the colgroup, the header cells, the
|
|
16
|
+
* body cells and the sticky offsets of fixed columns all read the same width
|
|
17
|
+
* from a single place.
|
|
18
|
+
*/
|
|
19
|
+
export declare function applyColumnResize(columns: Array<WrapedColumnProps>, resizable?: boolean, resizedWidths?: Record<string, number>): WrapedColumnProps[];
|
|
2
20
|
export declare function handleColumns(columns: Array<WrapedColumnProps>, measuredColumnWidths?: number[]): WrapedColumnProps[];
|
|
@@ -36,9 +36,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
36
36
|
// src/Table/util/index.ts
|
|
37
37
|
var util_exports = {};
|
|
38
38
|
__export(util_exports, {
|
|
39
|
+
applyColumnResize: () => applyColumnResize,
|
|
40
|
+
getColumnResizeKey: () => getColumnResizeKey,
|
|
39
41
|
handleColumns: () => handleColumns
|
|
40
42
|
});
|
|
41
43
|
module.exports = __toCommonJS(util_exports);
|
|
44
|
+
function getColumnResizeKey(column, index) {
|
|
45
|
+
var _a;
|
|
46
|
+
const id = (_a = column.key) != null ? _a : column.dataIndex;
|
|
47
|
+
return id === void 0 || id === null || id === "" ? `index:${index}` : `id:${id}`;
|
|
48
|
+
}
|
|
49
|
+
function applyColumnResize(columns, resizable, resizedWidths) {
|
|
50
|
+
return columns.map((column, index) => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const resizeKey = getColumnResizeKey(column, index);
|
|
53
|
+
const resizedWidth = resizedWidths == null ? void 0 : resizedWidths[resizeKey];
|
|
54
|
+
const next = __spreadProps(__spreadValues({}, column), {
|
|
55
|
+
resizeKey,
|
|
56
|
+
resizable: (_b = (_a = column.resizable) != null ? _a : resizable) != null ? _b : false
|
|
57
|
+
});
|
|
58
|
+
if (Number.isFinite(resizedWidth) && resizedWidth > 0) {
|
|
59
|
+
next.width = resizedWidth;
|
|
60
|
+
}
|
|
61
|
+
return next;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
42
64
|
var getColumnWidth = (column, index, measuredColumnWidths) => {
|
|
43
65
|
const measuredWidth = measuredColumnWidths == null ? void 0 : measuredColumnWidths[index];
|
|
44
66
|
if (Number.isFinite(measuredWidth) && measuredWidth && measuredWidth > 0) {
|