@cloud-ru/ds-table 1.0.2-preview-cd0cd6fb.0 → 1.0.2

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.
Files changed (94) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +3 -3
  3. package/dist/cjs/components/Table/Table.js +4 -12
  4. package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.d.ts +0 -2
  5. package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.js +3 -20
  6. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.d.ts +2 -2
  7. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.js +2 -2
  8. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/index.d.ts +0 -1
  9. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/index.js +0 -1
  10. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.js +4 -3
  11. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js +15 -3
  12. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.js +2 -4
  13. package/dist/cjs/components/Table/hooks/useTableScroll.js +1 -15
  14. package/dist/cjs/components/Table/styles.module.css +1 -19
  15. package/dist/cjs/components/Table/utils/index.d.ts +0 -1
  16. package/dist/cjs/components/Table/utils/index.js +0 -1
  17. package/dist/cjs/constants.d.ts +1 -1
  18. package/dist/cjs/constants.js +1 -1
  19. package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.js +4 -4
  20. package/dist/cjs/helperComponents/Cells/HeaderCell/HeaderCell.js +6 -7
  21. package/dist/cjs/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
  22. package/dist/cjs/helperComponents/Cells/styles.module.css +0 -3
  23. package/dist/cjs/helperComponents/Rows/styles.module.css +0 -4
  24. package/dist/cjs/helperComponents/TableEmptyState/hooks.js +1 -0
  25. package/dist/cjs/helperComponents/TableEmptyState/styles.module.css +1 -3
  26. package/dist/cjs/hooks/useCellSizes.d.ts +1 -0
  27. package/dist/cjs/hooks/useCellSizes.js +4 -1
  28. package/dist/cjs/locale/index.d.ts +4 -0
  29. package/dist/cjs/locale/index.js +2 -0
  30. package/dist/cjs/style.css +2 -29
  31. package/dist/cjs/types.d.ts +0 -1
  32. package/dist/esm/components/Table/Table.js +7 -15
  33. package/dist/esm/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.d.ts +0 -2
  34. package/dist/esm/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.js +4 -21
  35. package/dist/esm/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.d.ts +2 -2
  36. package/dist/esm/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.js +2 -2
  37. package/dist/esm/components/Table/hooks/useColumnSettings/utils/index.d.ts +0 -1
  38. package/dist/esm/components/Table/hooks/useColumnSettings/utils/index.js +0 -1
  39. package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.js +4 -3
  40. package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js +15 -3
  41. package/dist/esm/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.js +2 -4
  42. package/dist/esm/components/Table/hooks/useTableScroll.js +1 -15
  43. package/dist/esm/components/Table/styles.module.css +1 -19
  44. package/dist/esm/components/Table/utils/index.d.ts +0 -1
  45. package/dist/esm/components/Table/utils/index.js +0 -1
  46. package/dist/esm/constants.d.ts +1 -1
  47. package/dist/esm/constants.js +1 -1
  48. package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.js +4 -4
  49. package/dist/esm/helperComponents/Cells/HeaderCell/HeaderCell.js +6 -7
  50. package/dist/esm/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
  51. package/dist/esm/helperComponents/Cells/styles.module.css +0 -3
  52. package/dist/esm/helperComponents/Rows/styles.module.css +0 -4
  53. package/dist/esm/helperComponents/TableEmptyState/hooks.js +1 -0
  54. package/dist/esm/helperComponents/TableEmptyState/styles.module.css +1 -3
  55. package/dist/esm/hooks/useCellSizes.d.ts +1 -0
  56. package/dist/esm/hooks/useCellSizes.js +4 -1
  57. package/dist/esm/locale/index.d.ts +4 -0
  58. package/dist/esm/locale/index.js +2 -0
  59. package/dist/esm/style.css +2 -29
  60. package/dist/esm/types.d.ts +0 -1
  61. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  62. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  63. package/package.json +20 -21
  64. package/src/components/Table/Table.tsx +26 -53
  65. package/src/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.ts +7 -31
  66. package/src/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.ts +2 -2
  67. package/src/components/Table/hooks/useColumnSettings/utils/index.ts +0 -1
  68. package/src/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.ts +5 -3
  69. package/src/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.ts +18 -3
  70. package/src/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.ts +2 -4
  71. package/src/components/Table/hooks/useTableScroll.ts +1 -21
  72. package/src/components/Table/styles.module.scss +1 -23
  73. package/src/components/Table/utils/index.ts +0 -1
  74. package/src/constants.ts +1 -1
  75. package/src/helperComponents/Cells/BodyCell/BodyCell.tsx +2 -5
  76. package/src/helperComponents/Cells/HeaderCell/HeaderCell.tsx +7 -10
  77. package/src/helperComponents/Cells/HeaderCell/ResizeHandle.tsx +2 -1
  78. package/src/helperComponents/Cells/styles.module.scss +0 -11
  79. package/src/helperComponents/Rows/styles.module.scss +0 -5
  80. package/src/helperComponents/TableEmptyState/hooks.ts +1 -0
  81. package/src/helperComponents/TableEmptyState/styles.module.scss +1 -5
  82. package/src/hooks/useCellSizes.ts +5 -1
  83. package/src/locale/index.ts +2 -0
  84. package/src/types.ts +5 -3
  85. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.d.ts +0 -8
  86. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.js +0 -15
  87. package/dist/cjs/components/Table/utils/alignOverlayToHeader.d.ts +0 -6
  88. package/dist/cjs/components/Table/utils/alignOverlayToHeader.js +0 -28
  89. package/dist/esm/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.d.ts +0 -8
  90. package/dist/esm/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.js +0 -11
  91. package/dist/esm/components/Table/utils/alignOverlayToHeader.d.ts +0 -6
  92. package/dist/esm/components/Table/utils/alignOverlayToHeader.js +0 -24
  93. package/src/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.ts +0 -18
  94. package/src/components/Table/utils/alignOverlayToHeader.ts +0 -36
@@ -6,6 +6,7 @@ import { TABLE_COLUMN_CSS_VARS } from '../constants';
6
6
 
7
7
  type CellSizesOptions = {
8
8
  isDraggable?: boolean;
9
+ isDragging?: boolean;
9
10
  transform?: Transform | null;
10
11
  };
11
12
 
@@ -14,6 +15,7 @@ export function useCellSizes<TData>(
14
15
  options?: CellSizesOptions,
15
16
  ): CSSProperties {
16
17
  const column = element.column;
18
+ const isDragging = options?.isDragging ?? false;
17
19
  const transform = options?.transform ?? null;
18
20
 
19
21
  const minWidth = column.columnDef.minSize;
@@ -31,8 +33,10 @@ export function useCellSizes<TData>(
31
33
  };
32
34
 
33
35
  if (options?.isDraggable) {
36
+ styles.opacity = isDragging ? 0.8 : 1;
34
37
  styles.position = 'relative';
35
38
  styles.transform = CSS.Translate.toString(transform);
39
+ styles.zIndex = isDragging ? 1 : undefined;
36
40
 
37
41
  if (isHeaderCell) {
38
42
  styles.whiteSpace = 'nowrap';
@@ -40,5 +44,5 @@ export function useCellSizes<TData>(
40
44
  }
41
45
 
42
46
  return styles;
43
- }, [options?.isDraggable, flexShrink, isHeaderCell, maxWidth, minWidth, transform, width]);
47
+ }, [options?.isDraggable, flexShrink, isDragging, isHeaderCell, maxWidth, minWidth, transform, width]);
44
48
  }
@@ -15,6 +15,7 @@ const TABLE_MESSAGES = defineMessages({
15
15
  },
16
16
  noData: {
17
17
  title: 'No data',
18
+ content: 'Try refreshing the page',
18
19
  },
19
20
  noResults: {
20
21
  title: 'Nothing found',
@@ -39,6 +40,7 @@ const TABLE_MESSAGES = defineMessages({
39
40
  },
40
41
  noData: {
41
42
  title: 'Нет данных',
43
+ content: 'Обновите страницу',
42
44
  },
43
45
  noResults: {
44
46
  title: 'Ничего не найдено',
package/src/types.ts CHANGED
@@ -69,7 +69,6 @@ type FilterableProps = {
69
69
  columnSettings?: {
70
70
  /** Название колонки в настройках таблицы */
71
71
  label?: string;
72
- /** Поведение колонки в меню настроек. По умолчанию `defaultVisible` */
73
72
  mode?: ColumnSettingsMode;
74
73
  };
75
74
  } & ({ id: string } | { accessorKey: string });
@@ -78,10 +77,13 @@ type FilterableNormalColumnDefinition<TData> = NormalColumnDefinition<TData> & F
78
77
  type FilterablePinnedColumnDefinition<TData> = PinnedColumnDefinition<TData> & FilterableProps;
79
78
 
80
79
  export type FilterableColumnDefinition<TData> =
81
- FilterableNormalColumnDefinition<TData> | FilterablePinnedColumnDefinition<TData>;
80
+ | FilterableNormalColumnDefinition<TData>
81
+ | FilterablePinnedColumnDefinition<TData>;
82
82
 
83
83
  export type ColumnDefinition<TData> =
84
- NormalColumnDefinition<TData> | PinnedColumnDefinition<TData> | FilterableColumnDefinition<TData>;
84
+ | NormalColumnDefinition<TData>
85
+ | PinnedColumnDefinition<TData>
86
+ | FilterableColumnDefinition<TData>;
85
87
 
86
88
  export type ColumnOrder = string[];
87
89
 
@@ -1,8 +0,0 @@
1
- import { COLUMN_SETTINGS_MODE } from '../../../../../constants';
2
- import { ColumnDefinition } from '../../../../../types';
3
- type ColumnSettingsMode = (typeof COLUMN_SETTINGS_MODE)[keyof typeof COLUMN_SETTINGS_MODE];
4
- /** Служебные колонки (`selection` / `rowActions` / `status`) видимостью не управляются. */
5
- export declare function isServiceColumn<TData extends object>(colDef: ColumnDefinition<TData>): boolean;
6
- /** Режим колонки в меню настроек; без `columnSettings.mode` — `defaultVisible`. */
7
- export declare function getColumnSettingsMode<TData extends object>(colDef: ColumnDefinition<TData>): ColumnSettingsMode;
8
- export {};
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isServiceColumn = isServiceColumn;
4
- exports.getColumnSettingsMode = getColumnSettingsMode;
5
- const constants_1 = require("../../../../../constants");
6
- /** Служебные колонки (`selection` / `rowActions` / `status`) видимостью не управляются. */
7
- function isServiceColumn(colDef) {
8
- const id = 'id' in colDef ? colDef.id : undefined;
9
- return Boolean(id) && constants_1.DEFAULT_COLUMNS.includes(String(id));
10
- }
11
- /** Режим колонки в меню настроек; без `columnSettings.mode` — `defaultVisible`. */
12
- function getColumnSettingsMode(colDef) {
13
- const mode = 'columnSettings' in colDef ? colDef.columnSettings?.mode : undefined;
14
- return mode ?? constants_1.COLUMN_SETTINGS_MODE.DefaultVisible;
15
- }
@@ -1,6 +0,0 @@
1
- import { Modifier } from '@dnd-kit/core';
2
- /**
3
- * Копию тянет наверх к шапке: `useSortable` вызывают и ячейки тела с тем же id колонки,
4
- * поэтому dnd-kit считает активным узлом последнюю из них и якорит оверлей по её строке.
5
- */
6
- export declare const alignOverlayToHeader: Modifier;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.alignOverlayToHeader = void 0;
4
- const utils_1 = require("@cloud-ru/ds-utils");
5
- const constants_1 = require("../../../constants");
6
- function getHeaderCellTop(columnId) {
7
- if ((0, utils_1.isBrowser)()) {
8
- const headerCell = document.querySelector(`[data-test-id="${constants_1.TEST_IDS.headerCell}"][data-header-id="${CSS.escape(columnId)}"]`);
9
- return headerCell?.getBoundingClientRect().top;
10
- }
11
- return undefined;
12
- }
13
- /**
14
- * Копию тянет наверх к шапке: `useSortable` вызывают и ячейки тела с тем же id колонки,
15
- * поэтому dnd-kit считает активным узлом последнюю из них и якорит оверлей по её строке.
16
- */
17
- const alignOverlayToHeader = ({ transform, active, activeNodeRect }) => {
18
- const columnId = active?.id;
19
- if (!columnId || !activeNodeRect) {
20
- return transform;
21
- }
22
- const headerTop = getHeaderCellTop(String(columnId));
23
- if (headerTop === undefined) {
24
- return transform;
25
- }
26
- return { ...transform, y: transform.y + headerTop - activeNodeRect.top };
27
- };
28
- exports.alignOverlayToHeader = alignOverlayToHeader;
@@ -1,8 +0,0 @@
1
- import { COLUMN_SETTINGS_MODE } from '../../../../../constants.js';
2
- import { ColumnDefinition } from '../../../../../types.js';
3
- type ColumnSettingsMode = (typeof COLUMN_SETTINGS_MODE)[keyof typeof COLUMN_SETTINGS_MODE];
4
- /** Служебные колонки (`selection` / `rowActions` / `status`) видимостью не управляются. */
5
- export declare function isServiceColumn<TData extends object>(colDef: ColumnDefinition<TData>): boolean;
6
- /** Режим колонки в меню настроек; без `columnSettings.mode` — `defaultVisible`. */
7
- export declare function getColumnSettingsMode<TData extends object>(colDef: ColumnDefinition<TData>): ColumnSettingsMode;
8
- export {};
@@ -1,11 +0,0 @@
1
- import { COLUMN_SETTINGS_MODE, DEFAULT_COLUMNS } from '../../../../../constants.js';
2
- /** Служебные колонки (`selection` / `rowActions` / `status`) видимостью не управляются. */
3
- export function isServiceColumn(colDef) {
4
- const id = 'id' in colDef ? colDef.id : undefined;
5
- return Boolean(id) && DEFAULT_COLUMNS.includes(String(id));
6
- }
7
- /** Режим колонки в меню настроек; без `columnSettings.mode` — `defaultVisible`. */
8
- export function getColumnSettingsMode(colDef) {
9
- const mode = 'columnSettings' in colDef ? colDef.columnSettings?.mode : undefined;
10
- return mode ?? COLUMN_SETTINGS_MODE.DefaultVisible;
11
- }
@@ -1,6 +0,0 @@
1
- import { Modifier } from '@dnd-kit/core';
2
- /**
3
- * Копию тянет наверх к шапке: `useSortable` вызывают и ячейки тела с тем же id колонки,
4
- * поэтому dnd-kit считает активным узлом последнюю из них и якорит оверлей по её строке.
5
- */
6
- export declare const alignOverlayToHeader: Modifier;
@@ -1,24 +0,0 @@
1
- import { isBrowser } from '@cloud-ru/ds-utils';
2
- import { TEST_IDS } from '../../../constants.js';
3
- function getHeaderCellTop(columnId) {
4
- if (isBrowser()) {
5
- const headerCell = document.querySelector(`[data-test-id="${TEST_IDS.headerCell}"][data-header-id="${CSS.escape(columnId)}"]`);
6
- return headerCell?.getBoundingClientRect().top;
7
- }
8
- return undefined;
9
- }
10
- /**
11
- * Копию тянет наверх к шапке: `useSortable` вызывают и ячейки тела с тем же id колонки,
12
- * поэтому dnd-kit считает активным узлом последнюю из них и якорит оверлей по её строке.
13
- */
14
- export const alignOverlayToHeader = ({ transform, active, activeNodeRect }) => {
15
- const columnId = active?.id;
16
- if (!columnId || !activeNodeRect) {
17
- return transform;
18
- }
19
- const headerTop = getHeaderCellTop(String(columnId));
20
- if (headerTop === undefined) {
21
- return transform;
22
- }
23
- return { ...transform, y: transform.y + headerTop - activeNodeRect.top };
24
- };
@@ -1,18 +0,0 @@
1
- import { COLUMN_SETTINGS_MODE, DEFAULT_COLUMNS } from '../../../../../constants';
2
- import { ColumnDefinition } from '../../../../../types';
3
-
4
- type ColumnSettingsMode = (typeof COLUMN_SETTINGS_MODE)[keyof typeof COLUMN_SETTINGS_MODE];
5
-
6
- /** Служебные колонки (`selection` / `rowActions` / `status`) видимостью не управляются. */
7
- export function isServiceColumn<TData extends object>(colDef: ColumnDefinition<TData>): boolean {
8
- const id = 'id' in colDef ? colDef.id : undefined;
9
-
10
- return Boolean(id) && (DEFAULT_COLUMNS as string[]).includes(String(id));
11
- }
12
-
13
- /** Режим колонки в меню настроек; без `columnSettings.mode` — `defaultVisible`. */
14
- export function getColumnSettingsMode<TData extends object>(colDef: ColumnDefinition<TData>): ColumnSettingsMode {
15
- const mode = 'columnSettings' in colDef ? colDef.columnSettings?.mode : undefined;
16
-
17
- return mode ?? COLUMN_SETTINGS_MODE.DefaultVisible;
18
- }
@@ -1,36 +0,0 @@
1
- import { Modifier } from '@dnd-kit/core';
2
- import { isBrowser } from '@cloud-ru/ds-utils';
3
-
4
- import { TEST_IDS } from '../../../constants';
5
-
6
- function getHeaderCellTop(columnId: string): number | undefined {
7
- if (isBrowser()) {
8
- const headerCell = document.querySelector(
9
- `[data-test-id="${TEST_IDS.headerCell}"][data-header-id="${CSS.escape(columnId)}"]`,
10
- );
11
-
12
- return headerCell?.getBoundingClientRect().top;
13
- }
14
-
15
- return undefined;
16
- }
17
-
18
- /**
19
- * Копию тянет наверх к шапке: `useSortable` вызывают и ячейки тела с тем же id колонки,
20
- * поэтому dnd-kit считает активным узлом последнюю из них и якорит оверлей по её строке.
21
- */
22
- export const alignOverlayToHeader: Modifier = ({ transform, active, activeNodeRect }) => {
23
- const columnId = active?.id;
24
-
25
- if (!columnId || !activeNodeRect) {
26
- return transform;
27
- }
28
-
29
- const headerTop = getHeaderCellTop(String(columnId));
30
-
31
- if (headerTop === undefined) {
32
- return transform;
33
- }
34
-
35
- return { ...transform, y: transform.y + headerTop - activeNodeRect.top };
36
- };