@cloud-ru/ds-table 1.0.13-preview-06dc4823.0 → 1.0.13
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/CHANGELOG.md +7 -0
- package/dist/cjs/components/Table/hooks/useColumnSizes.js +13 -1
- package/dist/cjs/components/Table/utils/getTableViewportWidth.d.ts +2 -0
- package/dist/cjs/components/Table/utils/getTableViewportWidth.js +15 -0
- package/dist/cjs/components/Table/utils/index.d.ts +1 -0
- package/dist/cjs/components/Table/utils/index.js +1 -0
- package/dist/esm/components/Table/hooks/useColumnSizes.js +13 -1
- package/dist/esm/components/Table/utils/getTableViewportWidth.d.ts +2 -0
- package/dist/esm/components/Table/utils/getTableViewportWidth.js +12 -0
- package/dist/esm/components/Table/utils/index.d.ts +1 -0
- package/dist/esm/components/Table/utils/index.js +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/components/Table/hooks/useColumnSizes.ts +17 -1
- package/src/components/Table/utils/getTableViewportWidth.ts +16 -0
- package/src/components/Table/utils/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 1.0.13 (2026-09-01)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **FF-8947:** cap pinned column width so its resize handle stays reachable ([fa9370c](https://github.com/cloud-ru-tech/snack-v2/commit/fa9370c891823cf270676db504d6a4e3e0e7d441))
|
|
11
|
+
- **FF-8947:** fix table column resize handles ([3beba8e](https://github.com/cloud-ru-tech/snack-v2/commit/3beba8e4527e83cdbec04803d1fe3855a0aea563))
|
|
12
|
+
|
|
6
13
|
## 1.0.12 (2026-09-01)
|
|
7
14
|
|
|
8
15
|
**Note:** Version bump only for package @ds/table
|
|
@@ -10,6 +10,9 @@ const columnSize_1 = require("../utils/columnSize");
|
|
|
10
10
|
const getColumnIdentifier_1 = require("../utils/getColumnIdentifier");
|
|
11
11
|
const getColumnStyleVars_1 = require("../utils/getColumnStyleVars");
|
|
12
12
|
const getCurrentlyConfiguredHeaderWidth_1 = require("../utils/getCurrentlyConfiguredHeaderWidth");
|
|
13
|
+
const getTableViewportWidth_1 = require("../utils/getTableViewportWidth");
|
|
14
|
+
/** Закреплённая колонка не прокручивается: без запаса её ручка ресайза уезжает за край видимой области. */
|
|
15
|
+
const PINNED_COLUMN_VIEWPORT_RESERVE = 160;
|
|
13
16
|
function useColumnSizes({ table, headers, isLoadingState, savedState, }) {
|
|
14
17
|
const [measuredHeaderWidths, setMeasuredHeaderWidths] = (0, react_1.useState)({});
|
|
15
18
|
const isResizingColumn = table.getState().columnSizingInfo.isResizingColumn;
|
|
@@ -47,7 +50,16 @@ function useColumnSizes({ table, headers, isLoadingState, savedState, }) {
|
|
|
47
50
|
// замороженная колонка должна остаться фиксированной и после отпускания кнопки.
|
|
48
51
|
const hasAssignedSize = table.getState().columnSizing[header.id] !== undefined;
|
|
49
52
|
if (hasAssignedSize) {
|
|
50
|
-
|
|
53
|
+
let currentSize = header.getSize();
|
|
54
|
+
// `pinned` живёт в ColumnDefinition кита, а `_getColumnDefs` отдаёт тип tanstack.
|
|
55
|
+
const isPinned = Boolean(originalColDef?.pinned);
|
|
56
|
+
if (isPinned) {
|
|
57
|
+
const viewportWidth = (0, getTableViewportWidth_1.getTableViewportWidth)(header.id);
|
|
58
|
+
if (viewportWidth) {
|
|
59
|
+
const minSize = header.column.columnDef.minSize ?? 0;
|
|
60
|
+
currentSize = Math.min(currentSize, Math.max(minSize, viewportWidth - PINNED_COLUMN_VIEWPORT_RESERVE));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
51
63
|
realSizes[header.id] = currentSize;
|
|
52
64
|
size = `${currentSize}px`;
|
|
53
65
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTableViewportWidth = getTableViewportWidth;
|
|
4
|
+
const utils_1 = require("@cloud-ru/ds-utils");
|
|
5
|
+
const constants_1 = require("../../../constants");
|
|
6
|
+
/** Ширина видимой области таблицы из CSS-переменной обёртки (её пишет `useTableScroll`); 0 — замерить не удалось. */
|
|
7
|
+
function getTableViewportWidth(headerId) {
|
|
8
|
+
if ((0, utils_1.isBrowser)()) {
|
|
9
|
+
const cell = document.querySelector(`[data-header-id="${headerId}"]`);
|
|
10
|
+
if (cell) {
|
|
11
|
+
return Number.parseFloat(getComputedStyle(cell).getPropertyValue(constants_1.TABLE_CSS_VARS.viewportWidth)) || 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
@@ -3,6 +3,7 @@ export * from './columnSize';
|
|
|
3
3
|
export * from './getColumnIdentifier';
|
|
4
4
|
export * from './getColumnStyleVars';
|
|
5
5
|
export * from './getCurrentlyConfiguredHeaderWidth';
|
|
6
|
+
export * from './getTableViewportWidth';
|
|
6
7
|
export * from './getTableColumnsDefinitions';
|
|
7
8
|
export * from './sortColumnDefinitions';
|
|
8
9
|
export * from './isEveryArrayItemString';
|
|
@@ -19,6 +19,7 @@ __exportStar(require("./columnSize"), exports);
|
|
|
19
19
|
__exportStar(require("./getColumnIdentifier"), exports);
|
|
20
20
|
__exportStar(require("./getColumnStyleVars"), exports);
|
|
21
21
|
__exportStar(require("./getCurrentlyConfiguredHeaderWidth"), exports);
|
|
22
|
+
__exportStar(require("./getTableViewportWidth"), exports);
|
|
22
23
|
__exportStar(require("./getTableColumnsDefinitions"), exports);
|
|
23
24
|
__exportStar(require("./sortColumnDefinitions"), exports);
|
|
24
25
|
__exportStar(require("./isEveryArrayItemString"), exports);
|
|
@@ -7,6 +7,9 @@ import { getInitColumnSizeFromLocalStorage, saveStateToLocalStorage } from '../u
|
|
|
7
7
|
import { getColumnIdentifier } from '../utils/getColumnIdentifier.js';
|
|
8
8
|
import { getColumnStyleVars } from '../utils/getColumnStyleVars.js';
|
|
9
9
|
import { getCurrentlyConfiguredHeaderWidth } from '../utils/getCurrentlyConfiguredHeaderWidth.js';
|
|
10
|
+
import { getTableViewportWidth } from '../utils/getTableViewportWidth.js';
|
|
11
|
+
/** Закреплённая колонка не прокручивается: без запаса её ручка ресайза уезжает за край видимой области. */
|
|
12
|
+
const PINNED_COLUMN_VIEWPORT_RESERVE = 160;
|
|
10
13
|
export function useColumnSizes({ table, headers, isLoadingState, savedState, }) {
|
|
11
14
|
const [measuredHeaderWidths, setMeasuredHeaderWidths] = useState({});
|
|
12
15
|
const isResizingColumn = table.getState().columnSizingInfo.isResizingColumn;
|
|
@@ -44,7 +47,16 @@ export function useColumnSizes({ table, headers, isLoadingState, savedState, })
|
|
|
44
47
|
// замороженная колонка должна остаться фиксированной и после отпускания кнопки.
|
|
45
48
|
const hasAssignedSize = table.getState().columnSizing[header.id] !== undefined;
|
|
46
49
|
if (hasAssignedSize) {
|
|
47
|
-
|
|
50
|
+
let currentSize = header.getSize();
|
|
51
|
+
// `pinned` живёт в ColumnDefinition кита, а `_getColumnDefs` отдаёт тип tanstack.
|
|
52
|
+
const isPinned = Boolean(originalColDef?.pinned);
|
|
53
|
+
if (isPinned) {
|
|
54
|
+
const viewportWidth = getTableViewportWidth(header.id);
|
|
55
|
+
if (viewportWidth) {
|
|
56
|
+
const minSize = header.column.columnDef.minSize ?? 0;
|
|
57
|
+
currentSize = Math.min(currentSize, Math.max(minSize, viewportWidth - PINNED_COLUMN_VIEWPORT_RESERVE));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
48
60
|
realSizes[header.id] = currentSize;
|
|
49
61
|
size = `${currentSize}px`;
|
|
50
62
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isBrowser } from '@cloud-ru/ds-utils';
|
|
2
|
+
import { TABLE_CSS_VARS } from '../../../constants.js';
|
|
3
|
+
/** Ширина видимой области таблицы из CSS-переменной обёртки (её пишет `useTableScroll`); 0 — замерить не удалось. */
|
|
4
|
+
export function getTableViewportWidth(headerId) {
|
|
5
|
+
if (isBrowser()) {
|
|
6
|
+
const cell = document.querySelector(`[data-header-id="${headerId}"]`);
|
|
7
|
+
if (cell) {
|
|
8
|
+
return Number.parseFloat(getComputedStyle(cell).getPropertyValue(TABLE_CSS_VARS.viewportWidth)) || 0;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
@@ -3,6 +3,7 @@ export * from './columnSize.js';
|
|
|
3
3
|
export * from './getColumnIdentifier.js';
|
|
4
4
|
export * from './getColumnStyleVars.js';
|
|
5
5
|
export * from './getCurrentlyConfiguredHeaderWidth.js';
|
|
6
|
+
export * from './getTableViewportWidth.js';
|
|
6
7
|
export * from './getTableColumnsDefinitions.js';
|
|
7
8
|
export * from './sortColumnDefinitions.js';
|
|
8
9
|
export * from './isEveryArrayItemString.js';
|
|
@@ -3,6 +3,7 @@ export * from './columnSize.js';
|
|
|
3
3
|
export * from './getColumnIdentifier.js';
|
|
4
4
|
export * from './getColumnStyleVars.js';
|
|
5
5
|
export * from './getCurrentlyConfiguredHeaderWidth.js';
|
|
6
|
+
export * from './getTableViewportWidth.js';
|
|
6
7
|
export * from './getTableColumnsDefinitions.js';
|
|
7
8
|
export * from './sortColumnDefinitions.js';
|
|
8
9
|
export * from './isEveryArrayItemString.js';
|