@cloud-ru/ds-table 1.0.2 → 1.0.4-preview-bd263dc7.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.
Files changed (109) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +3 -3
  3. package/dist/cjs/components/Table/Table.js +12 -4
  4. package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.d.ts +2 -0
  5. package/dist/cjs/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.js +20 -3
  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/getColumnSettingsMode.d.ts +8 -0
  9. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.js +15 -0
  10. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/index.d.ts +1 -0
  11. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/index.js +1 -0
  12. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.js +3 -4
  13. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js +3 -15
  14. package/dist/cjs/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.js +4 -2
  15. package/dist/cjs/components/Table/hooks/useTableScroll.js +15 -1
  16. package/dist/cjs/components/Table/styles.module.css +19 -1
  17. package/dist/cjs/components/Table/utils/alignOverlayToHeader.d.ts +6 -0
  18. package/dist/cjs/components/Table/utils/alignOverlayToHeader.js +28 -0
  19. package/dist/cjs/components/Table/utils/index.d.ts +1 -0
  20. package/dist/cjs/components/Table/utils/index.js +1 -0
  21. package/dist/cjs/constants.d.ts +1 -1
  22. package/dist/cjs/constants.js +1 -1
  23. package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.d.ts +3 -1
  24. package/dist/cjs/helperComponents/Cells/BodyCell/BodyCell.js +9 -10
  25. package/dist/cjs/helperComponents/Cells/HeaderCell/HeaderCell.js +7 -6
  26. package/dist/cjs/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
  27. package/dist/cjs/helperComponents/Cells/styles.module.css +3 -0
  28. package/dist/cjs/helperComponents/Rows/BodyRow.js +1 -2
  29. package/dist/cjs/helperComponents/Rows/styles.module.css +4 -0
  30. package/dist/cjs/helperComponents/TableEmptyState/hooks.js +0 -1
  31. package/dist/cjs/helperComponents/TableEmptyState/styles.module.css +3 -1
  32. package/dist/cjs/hooks/index.d.ts +1 -0
  33. package/dist/cjs/hooks/index.js +1 -0
  34. package/dist/cjs/hooks/useCellSizes.d.ts +0 -1
  35. package/dist/cjs/hooks/useCellSizes.js +1 -4
  36. package/dist/cjs/hooks/useColumnDragTransform.d.ts +15 -0
  37. package/dist/cjs/hooks/useColumnDragTransform.js +38 -0
  38. package/dist/cjs/locale/index.d.ts +0 -4
  39. package/dist/cjs/locale/index.js +0 -2
  40. package/dist/cjs/style.css +29 -2
  41. package/dist/cjs/types.d.ts +1 -0
  42. package/dist/esm/components/Table/Table.js +15 -7
  43. package/dist/esm/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.d.ts +2 -0
  44. package/dist/esm/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.js +21 -4
  45. package/dist/esm/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.d.ts +2 -2
  46. package/dist/esm/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.js +2 -2
  47. package/dist/esm/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.d.ts +8 -0
  48. package/dist/esm/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.js +11 -0
  49. package/dist/esm/components/Table/hooks/useColumnSettings/utils/index.d.ts +1 -0
  50. package/dist/esm/components/Table/hooks/useColumnSettings/utils/index.js +1 -0
  51. package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.js +3 -4
  52. package/dist/esm/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.js +3 -15
  53. package/dist/esm/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.js +4 -2
  54. package/dist/esm/components/Table/hooks/useTableScroll.js +15 -1
  55. package/dist/esm/components/Table/styles.module.css +19 -1
  56. package/dist/esm/components/Table/utils/alignOverlayToHeader.d.ts +6 -0
  57. package/dist/esm/components/Table/utils/alignOverlayToHeader.js +24 -0
  58. package/dist/esm/components/Table/utils/index.d.ts +1 -0
  59. package/dist/esm/components/Table/utils/index.js +1 -0
  60. package/dist/esm/constants.d.ts +1 -1
  61. package/dist/esm/constants.js +1 -1
  62. package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.d.ts +3 -1
  63. package/dist/esm/helperComponents/Cells/BodyCell/BodyCell.js +10 -11
  64. package/dist/esm/helperComponents/Cells/HeaderCell/HeaderCell.js +7 -6
  65. package/dist/esm/helperComponents/Cells/HeaderCell/ResizeHandle.js +1 -1
  66. package/dist/esm/helperComponents/Cells/styles.module.css +3 -0
  67. package/dist/esm/helperComponents/Rows/BodyRow.js +1 -2
  68. package/dist/esm/helperComponents/Rows/styles.module.css +4 -0
  69. package/dist/esm/helperComponents/TableEmptyState/hooks.js +0 -1
  70. package/dist/esm/helperComponents/TableEmptyState/styles.module.css +3 -1
  71. package/dist/esm/hooks/index.d.ts +1 -0
  72. package/dist/esm/hooks/index.js +1 -0
  73. package/dist/esm/hooks/useCellSizes.d.ts +0 -1
  74. package/dist/esm/hooks/useCellSizes.js +1 -4
  75. package/dist/esm/hooks/useColumnDragTransform.d.ts +15 -0
  76. package/dist/esm/hooks/useColumnDragTransform.js +35 -0
  77. package/dist/esm/locale/index.d.ts +0 -4
  78. package/dist/esm/locale/index.js +0 -2
  79. package/dist/esm/style.css +29 -2
  80. package/dist/esm/types.d.ts +1 -0
  81. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  82. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  83. package/package.json +21 -20
  84. package/src/components/Table/Table.tsx +53 -26
  85. package/src/components/Table/hooks/useColumnOrderByDrag/useColumnOrderByDrag.ts +31 -7
  86. package/src/components/Table/hooks/useColumnSettings/utils/createColumnsSettingsOption.ts +2 -2
  87. package/src/components/Table/hooks/useColumnSettings/utils/getColumnSettingsMode.ts +18 -0
  88. package/src/components/Table/hooks/useColumnSettings/utils/index.ts +1 -0
  89. package/src/components/Table/hooks/useColumnSettings/utils/isColumnEnabledInitially.ts +3 -5
  90. package/src/components/Table/hooks/useColumnSettings/utils/isColumnVisibilityConfigurable.ts +3 -18
  91. package/src/components/Table/hooks/useColumnSettings/utils/isFilterableColumn.ts +4 -2
  92. package/src/components/Table/hooks/useTableScroll.ts +21 -1
  93. package/src/components/Table/styles.module.scss +23 -1
  94. package/src/components/Table/utils/alignOverlayToHeader.ts +36 -0
  95. package/src/components/Table/utils/index.ts +1 -0
  96. package/src/constants.ts +1 -1
  97. package/src/helperComponents/Cells/BodyCell/BodyCell.tsx +18 -15
  98. package/src/helperComponents/Cells/HeaderCell/HeaderCell.tsx +10 -7
  99. package/src/helperComponents/Cells/HeaderCell/ResizeHandle.tsx +1 -2
  100. package/src/helperComponents/Cells/styles.module.scss +11 -0
  101. package/src/helperComponents/Rows/BodyRow.tsx +9 -10
  102. package/src/helperComponents/Rows/styles.module.scss +5 -0
  103. package/src/helperComponents/TableEmptyState/hooks.ts +0 -1
  104. package/src/helperComponents/TableEmptyState/styles.module.scss +5 -1
  105. package/src/hooks/index.ts +1 -0
  106. package/src/hooks/useCellSizes.ts +1 -5
  107. package/src/hooks/useColumnDragTransform.ts +52 -0
  108. package/src/locale/index.ts +0 -2
  109. package/src/types.ts +3 -5
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.3 (2026-08-20)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **FF-8679:** default table column settings mode to defaultVisible ([0645dfb](https://github.com/cloud-ru-tech/snack-v2/commit/0645dfb7243538c0e7838392308e6804ef06dea7))
11
+ - **FF-8679:** move column drag to a portal preview and fix empty state ([f38d035](https://github.com/cloud-ru-tech/snack-v2/commit/f38d035ab5efb5a721e92be99fd5d76b093e1303))
12
+
6
13
  ## 1.0.2 (2026-08-20)
7
14
 
8
15
  **Note:** Version bump only for package @ds/table
package/README.md CHANGED
@@ -254,13 +254,13 @@ Bulk-бар в тулбаре (чекбокс «выбрать все» и сч
254
254
  - `enableDrag` — переупорядочивание колонок: перетаскивание заголовков в таблице и строк в меню настроек (через `onItemsReorder` у `@cloud-ru/ds-list`). Оба канала пишут в один и тот же `columnOrder`.
255
255
  - `enableSettingsMenu` — меню видимости колонок в тулбаре.
256
256
 
257
- Поведение колонки в меню задаётся на самой колонке через `columnSettings.mode` (ось `COLUMN_SETTINGS_MODE`):
257
+ Поведение колонки в меню задаётся на самой колонке через `columnSettings.mode` (ось `COLUMN_SETTINGS_MODE`), режим по умолчанию — `defaultVisible`:
258
258
 
259
259
  - `locked` — колонка есть в меню, но строка disabled (всегда видима, свитч нельзя выключить).
260
- - `defaultVisible` — в меню, по умолчанию включена.
260
+ - `defaultVisible` — в меню, по умолчанию включена. Так ведёт себя колонка без `columnSettings.mode`.
261
261
  - `defaultHidden` — в меню, по умолчанию выключена.
262
262
 
263
- `columnSettings.label` — название колонки в меню настроек. Колонки без `columnSettings` тоже показываются в меню (disabled, label из `header`); исключение — служебные `selection` / `rowActions`.
263
+ `columnSettings.label` — название колонки в меню настроек; без него берётся `header`. Служебные колонки (`selection` / `rowActions` / `status`) видимостью не управляются: первые две в меню не показываются, `status` — disabled.
264
264
 
265
265
  `savedState` сохраняет состояние таблицы в localStorage и query-параметрах: `id` обязан быть уникальным в рамках приложения; `resize` / `columnSettings` включают сохранение ширин и видимости колонок; `serializer` / `parser` / `filterQueryKey` настраивают сериализацию фильтров.
266
266
 
@@ -8,9 +8,11 @@ exports.Table = Table;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const core_1 = require("@dnd-kit/core");
10
10
  const adaptive_1 = require("@cloud-ru/ds-adaptive");
11
+ const drag_and_drop_1 = require("@cloud-ru/ds-drag-and-drop");
11
12
  const materials_1 = require("@cloud-ru/ds-materials");
12
13
  const theme_1 = require("@cloud-ru/ds-theme");
13
14
  const utils_1 = require("@cloud-ru/ds-utils");
15
+ const react_table_1 = require("@tanstack/react-table");
14
16
  const classnames_1 = __importDefault(require("classnames"));
15
17
  const react_1 = require("react");
16
18
  const constants_1 = require("../../constants");
@@ -105,7 +107,7 @@ function Table({ data, rowPinning = {
105
107
  onSortingChange([]);
106
108
  }
107
109
  }, [areColumnsSettingsEnabled, enabledColumns, hideableColumnIds, onSortingChange, sorting]);
108
- const { columnOrder, setColumnOrder, dndContextProps, enableColumnsOrderSortByDrag } = (0, hooks_1.useColumnOrderByDrag)({
110
+ const { columnOrder, setColumnOrder, dndContextProps, enableColumnsOrderSortByDrag, draggingColumnId } = (0, hooks_1.useColumnOrderByDrag)({
109
111
  tableColumns: allTableColumns,
110
112
  savedState,
111
113
  columnSettings: columnsSettingsProp,
@@ -264,6 +266,12 @@ function Table({ data, rowPinning = {
264
266
  // но скрывает при dataError. Загрузка и непустое тело — шапка всегда.
265
267
  const showTableHeader = showHeader &&
266
268
  (isLoadingState || centerRows.length > 0 || filteredTopRows.length > 0 || (isEmptyBody && !dataError));
269
+ const draggingHeader = draggingColumnId
270
+ ? table.getFlatHeaders().find(header => header.column.id === draggingColumnId)
271
+ : undefined;
272
+ // Копия колонки едет за курсором в портале: внутри скролла она растила бы его ширину
273
+ // и ныряла под закреплённые колонки.
274
+ const draggingColumnPreview = ((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: null, modifiers: [utils_3.alignOverlayToHeader], children: draggingHeader ? ((0, jsx_runtime_1.jsx)(drag_and_drop_1.DragPreview, { className: styles_module_scss_1.default.columnDragPreview, style: { width: `var(${constants_1.TABLE_COLUMN_CSS_VARS.size(draggingHeader.column.id)})` }, children: (0, react_table_1.flexRender)(draggingHeader.column.columnDef.header, draggingHeader.getContext()) })) : null }));
267
275
  const tableHeaderElement = showTableHeader ? ((0, jsx_runtime_1.jsx)(helperComponents_1.HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, suppressSticky: usePageStickyHeader })) : null;
268
276
  const tableRowsContent = ((0, jsx_runtime_1.jsx)(TableRowsBody_1.TableRowsBody, { filteredTopRows: filteredTopRows, centerRows: centerRows, rowVirtualizer: rowVirtualizer, columnOrder: columnOrder, rowAutoHeight: rowAutoHeight, onRowClick: onRowClick, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, rowSelectionAppearance: rowSelectionProp?.appearance, emptyState: tableEmptyState, showInfiniteLoadingTail: showInfiniteLoadingTail, loadingTableRows: loadingTableRows, loadMoreButton: loadMoreButtonNode }));
269
277
  const cardsContentBody = ((0, jsx_runtime_1.jsx)(TableCardsBody_1.TableCardsBody, { filteredTopRows: filteredTopRows, centerRows: centerRows, table: table, headlineId: headlineId, cardSelection: cardSelection, rowSelectionAppearance: rowSelectionProp?.appearance, suppressHeader: suppressHeader, onRowClick: onRowClick, renderCard: renderCard, cardsListProps: cardsListProps, emptyState: tableEmptyState, showInfiniteLoadingTail: showInfiniteLoadingTail, loadingTableRows: loadingTableRows, loadingTable: loadingTable, loadMoreButton: loadMoreButtonNode }));
@@ -300,8 +308,8 @@ function Table({ data, rowPinning = {
300
308
  const themeClassName = (0, theme_1.useThemeClassnames)({ density: isMobile ? 'comfort' : 'compact' });
301
309
  const controlsAcrylic = (0, react_1.useMemo)(() => (isStickyControls ? (0, helperComponents_1.getControlsAcrylicAttrs)(stickyControlsBackgroundPredefined) : null), [isStickyControls, stickyControlsBackgroundPredefined]);
302
310
  const scrollPaddingAbsolute = isStickyControls && !isCardsView;
303
- const tableScrollContent = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: (0, jsx_runtime_1.jsx)(contexts_1.CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: (0, jsx_runtime_1.jsx)(core_1.DndContext, { ...dndContextProps, children: tableScrollRows }) }) }));
304
- const tableContentWithProviders = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: (0, jsx_runtime_1.jsx)(contexts_1.CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: (0, jsx_runtime_1.jsx)(core_1.DndContext, { ...dndContextProps, children: tableBody }) }) }));
311
+ const tableScrollContent = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: (0, jsx_runtime_1.jsx)(contexts_1.CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: tableScrollRows }) }));
312
+ const tableContentWithProviders = ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.body, "data-empty-body": isEmptyBody || undefined, style: columnSizes.vars, children: (0, jsx_runtime_1.jsx)(contexts_1.CellAutoResizeContext.Provider, { value: { updateCellMap, removeCellFromMap }, children: tableBody }) }));
305
313
  let scrollContent = tableContentWithProviders;
306
314
  if (isMobile && isCardsView) {
307
315
  scrollContent = tableBody;
@@ -329,7 +337,7 @@ function Table({ data, rowPinning = {
329
337
  paginationChrome =
330
338
  isStickyControls && controlsAcrylic ? ((0, jsx_runtime_1.jsx)(TableChrome_1.TableChrome, { variant: 'footer', acrylic: controlsAcrylic, children: pagination })) : (pagination);
331
339
  }
332
- return ((0, jsx_runtime_1.jsx)("div", { ref: wrapperRef, className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className, themeClassName), "data-view": view, "data-layout-type": layoutType, "data-sticky-controls": isStickyControls || undefined, "data-with-toolbar": showToolbar || undefined, "data-empty-body": isEmptyBody || undefined, "data-fit-content": !resolvedFullWidth || undefined, ...(0, utils_1.extractSupportProps)(rest), children: (0, jsx_runtime_1.jsxs)(contexts_1.TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tableView, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.mobileToolbarMounts, children: [sortingToolbarSlot.mobileMount, columnsSettingsToolbarSlot.mobileMount] })) : null, (0, jsx_runtime_1.jsx)(TableScrollHost_1.TableScrollHost, { view: view, isMobile: isMobile, isCardsView: isCardsView, usePageStickyHeader: usePageStickyHeader, scrollOverflow: scrollOverflow, scrollPaddingAbsolute: scrollPaddingAbsolute, internalScrollRef: internalScrollRef, scrollRef: scrollRef, scrollContainerRef: scrollContainerRef, handleScrollInitialized: handleScrollInitialized, syncHeaderHorizontalScroll: syncHeaderHorizontalScroll, tableHeaderElement: tableHeaderElement, columnSizeVars: columnSizes.vars, children: scrollContent }), !isCardsView && outline ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
340
+ return ((0, jsx_runtime_1.jsx)("div", { ref: wrapperRef, className: (0, classnames_1.default)(styles_module_scss_1.default.wrapper, className, themeClassName), "data-view": view, "data-layout-type": layoutType, "data-sticky-controls": isStickyControls || undefined, "data-with-toolbar": showToolbar || undefined, "data-empty-body": isEmptyBody || undefined, "data-fit-content": !resolvedFullWidth || undefined, ...(0, utils_1.extractSupportProps)(rest), children: (0, jsx_runtime_1.jsxs)(contexts_1.TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tableView, children: [(0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.mobileToolbarMounts, children: [sortingToolbarSlot.mobileMount, columnsSettingsToolbarSlot.mobileMount] })) : null, (0, jsx_runtime_1.jsxs)(core_1.DndContext, { ...dndContextProps, children: [draggingColumnPreview, (0, jsx_runtime_1.jsx)(TableScrollHost_1.TableScrollHost, { view: view, isMobile: isMobile, isCardsView: isCardsView, usePageStickyHeader: usePageStickyHeader, scrollOverflow: scrollOverflow, scrollPaddingAbsolute: scrollPaddingAbsolute, internalScrollRef: internalScrollRef, scrollRef: scrollRef, scrollContainerRef: scrollContainerRef, handleScrollInitialized: handleScrollInitialized, syncHeaderHorizontalScroll: syncHeaderHorizontalScroll, tableHeaderElement: tableHeaderElement, columnSizeVars: columnSizes.vars, children: scrollContent })] }), !isCardsView && outline ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
333
341
  }
334
342
  Table.getStatusColumnDef = helperComponents_1.getStatusColumnDef;
335
343
  Table.statusAppearances = helperComponents_1.STATUS_APPEARANCE;
@@ -12,5 +12,7 @@ export declare function useColumnOrderByDrag<TData extends object>({ tableColumn
12
12
  setColumnOrder: Dispatch<SetStateAction<string[]>>;
13
13
  dndContextProps: DndContextProps;
14
14
  enableColumnsOrderSortByDrag: boolean;
15
+ /** Колонка под курсором прямо сейчас: по ней рендерится копия в портале. */
16
+ draggingColumnId?: string;
15
17
  };
16
18
  export {};
@@ -15,6 +15,7 @@ const draggingOptions = {
15
15
  };
16
16
  function useColumnOrderByDrag({ tableColumns, savedState, columnSettings, }) {
17
17
  const [columnOrder, setColumnOrderState] = (0, react_1.useState)(() => (0, prepareInitialState_1.prepareInitialState)(tableColumns, savedState));
18
+ const [draggingColumnId, setDraggingColumnId] = (0, react_1.useState)();
18
19
  (0, react_1.useEffect)(() => {
19
20
  setColumnOrderState(prev => {
20
21
  const currentIds = tableColumns
@@ -42,7 +43,14 @@ function useColumnOrderByDrag({ tableColumns, savedState, columnSettings, }) {
42
43
  }
43
44
  setColumnOrderState(updatedOrder);
44
45
  }, [columnOrder, savedState]);
46
+ const handleDragStart = (0, react_1.useCallback)(({ active }) => {
47
+ setDraggingColumnId(String(active.id));
48
+ }, []);
49
+ const handleDragCancel = (0, react_1.useCallback)(() => {
50
+ setDraggingColumnId(undefined);
51
+ }, []);
45
52
  const handleDragEnd = (0, react_1.useCallback)(({ active, over }) => {
53
+ setDraggingColumnId(undefined);
46
54
  if (!active || !over) {
47
55
  return;
48
56
  }
@@ -60,23 +68,32 @@ function useColumnOrderByDrag({ tableColumns, savedState, columnSettings, }) {
60
68
  return (0, sortable_1.arrayMove)(columnOrder, oldIndex, newIndex);
61
69
  });
62
70
  }, [columnOrder, setColumnOrder]);
63
- const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.MouseSensor, draggingOptions), (0, core_1.useSensor)(core_1.TouchSensor, {}), (0, core_1.useSensor)(core_1.KeyboardSensor, {}));
71
+ // `over` вне SortableContext сбрасывает transform'ы всей сортировки — колонка рывком
72
+ // возвращается на место. Держим `over` внутри колонок сортировки.
73
+ const collisionDetection = (0, react_1.useCallback)(args => (0, core_1.closestCenter)({
74
+ ...args,
75
+ droppableContainers: args.droppableContainers.filter(container => columnOrder.includes(String(container.id))),
76
+ }), [columnOrder]);
77
+ const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.MouseSensor, draggingOptions), (0, core_1.useSensor)(core_1.TouchSensor, {}));
64
78
  const enableColumnsOrderSortByDrag = Boolean(columnSettings?.enableDrag);
65
79
  const dndContextProps = (0, react_1.useMemo)(() => {
66
80
  if (!enableColumnsOrderSortByDrag) {
67
81
  return {};
68
82
  }
69
83
  return {
70
- collisionDetection: core_1.closestCenter,
84
+ collisionDetection,
71
85
  modifiers: [modifiers_1.restrictToHorizontalAxis],
86
+ onDragStart: handleDragStart,
87
+ onDragCancel: handleDragCancel,
72
88
  onDragEnd: handleDragEnd,
73
89
  sensors,
74
90
  };
75
- }, [enableColumnsOrderSortByDrag, handleDragEnd, sensors]);
91
+ }, [collisionDetection, enableColumnsOrderSortByDrag, handleDragCancel, handleDragEnd, handleDragStart, sensors]);
76
92
  return {
77
93
  columnOrder,
78
94
  setColumnOrder,
79
95
  dndContextProps,
80
96
  enableColumnsOrderSortByDrag,
97
+ draggingColumnId,
81
98
  };
82
99
  }
@@ -2,11 +2,11 @@ import { SimpleItem } from '@cloud-ru/ds-list';
2
2
  import { ColumnDefinition } from '../../../../../types';
3
3
  /**
4
4
  * Колонка попадает в меню настроек: есть id/accessorKey и это не selection/row-actions.
5
- * Включая `mode: locked` и колонки без `columnSettings` (они рендерятся disabled).
5
+ * Включая `mode: locked` (рендерится disabled).
6
6
  */
7
7
  export declare function isColumnsSettingsMenuItem<TData extends object>(colDef: ColumnDefinition<TData>): boolean;
8
8
  /**
9
- * Пункт меню настроек колонок. Неактивные (нет `columnSettings` / `mode: locked`) —
9
+ * Пункт меню настроек колонок. Неактивные (`mode: locked` и служебные колонки) —
10
10
  * `disabled` + всегда включённый switch (`checked: true`); драг при этом остаётся
11
11
  * доступным. Видимость через `enabledColumns` не управляется.
12
12
  */
@@ -10,7 +10,7 @@ const isFilterableColumn_1 = require("./isFilterableColumn");
10
10
  const SETTINGS_MENU_EXCLUDED_IDS = new Set([constants_1.DefaultColumns.Selection, constants_1.DefaultColumns.RowActions]);
11
11
  /**
12
12
  * Колонка попадает в меню настроек: есть id/accessorKey и это не selection/row-actions.
13
- * Включая `mode: locked` и колонки без `columnSettings` (они рендерятся disabled).
13
+ * Включая `mode: locked` (рендерится disabled).
14
14
  */
15
15
  function isColumnsSettingsMenuItem(colDef) {
16
16
  if (!('id' in colDef || 'accessorKey' in colDef)) {
@@ -31,7 +31,7 @@ function getColumnsSettingsOptionLabel(columnDefinition) {
31
31
  return (0, utils_1.getColumnIdentifier)(columnDefinition);
32
32
  }
33
33
  /**
34
- * Пункт меню настроек колонок. Неактивные (нет `columnSettings` / `mode: locked`) —
34
+ * Пункт меню настроек колонок. Неактивные (`mode: locked` и служебные колонки) —
35
35
  * `disabled` + всегда включённый switch (`checked: true`); драг при этом остаётся
36
36
  * доступным. Видимость через `enabledColumns` не управляется.
37
37
  */
@@ -0,0 +1,8 @@
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 {};
@@ -0,0 +1,15 @@
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,3 +1,4 @@
1
+ export * from './getColumnSettingsMode';
1
2
  export * from './isFilterableColumn';
2
3
  export * from './isColumnEnabledInitially';
3
4
  export * from './isColumnVisibilityConfigurable';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./getColumnSettingsMode"), exports);
17
18
  __exportStar(require("./isFilterableColumn"), exports);
18
19
  __exportStar(require("./isColumnEnabledInitially"), exports);
19
20
  __exportStar(require("./isColumnVisibilityConfigurable"), exports);
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isColumnEnabledInitially = isColumnEnabledInitially;
4
+ const constants_1 = require("../../../../../constants");
5
+ const getColumnSettingsMode_1 = require("./getColumnSettingsMode");
4
6
  /**
5
7
  * Проверка на то, должна ли колонка быть включена по умолчанию
6
8
  * @function isColumnEnabledInitially
7
9
  */
8
10
  function isColumnEnabledInitially(colDef) {
9
- if ('columnSettings' in colDef && colDef.columnSettings !== undefined) {
10
- return colDef.columnSettings?.mode !== 'defaultHidden';
11
- }
12
- return true;
11
+ return (0, getColumnSettingsMode_1.getColumnSettingsMode)(colDef) !== constants_1.COLUMN_SETTINGS_MODE.DefaultHidden;
13
12
  }
@@ -1,24 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isColumnVisibilityConfigurable = isColumnVisibilityConfigurable;
4
+ const constants_1 = require("../../../../../constants");
5
+ const getColumnSettingsMode_1 = require("./getColumnSettingsMode");
4
6
  /**
5
7
  * Проверка на то, должна ли колонка отображаться в настройках колонок
6
8
  * @function isColumnVisibilityConfigurable
7
9
  */
8
10
  function isColumnVisibilityConfigurable(colDef) {
9
- if ('columnSettings' in colDef && colDef.columnSettings !== undefined) {
10
- const { mode } = colDef.columnSettings;
11
- if (!mode) {
12
- return true;
13
- }
14
- switch (mode) {
15
- case 'locked':
16
- return false;
17
- case 'defaultVisible':
18
- case 'defaultHidden':
19
- default:
20
- return true;
21
- }
22
- }
23
- return true;
11
+ return (0, getColumnSettingsMode_1.getColumnSettingsMode)(colDef) !== constants_1.COLUMN_SETTINGS_MODE.Locked;
24
12
  }
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isFilterableColumn = isFilterableColumn;
4
+ const constants_1 = require("../../../../../constants");
5
+ const getColumnSettingsMode_1 = require("./getColumnSettingsMode");
4
6
  /**
5
7
  * Проверка на то, должна ли колонка отображаться в таблице
6
8
  * @function isFilterableColumn
7
9
  */
8
10
  function isFilterableColumn(colDef) {
9
11
  return (('id' in colDef || 'accessorKey' in colDef) &&
10
- 'columnSettings' in colDef &&
11
- colDef.columnSettings?.mode !== 'locked');
12
+ !(0, getColumnSettingsMode_1.isServiceColumn)(colDef) &&
13
+ (0, getColumnSettingsMode_1.getColumnSettingsMode)(colDef) !== constants_1.COLUMN_SETTINGS_MODE.Locked);
12
14
  }
@@ -34,7 +34,6 @@ function useTableScroll({ usePageStickyHeader, isStickyControls, stickyControlsO
34
34
  const wrapper = wrapperRef.current;
35
35
  if (!usePageStickyHeader) {
36
36
  wrapper?.style.removeProperty(constants_1.TABLE_CSS_VARS.headerScrollLeft);
37
- wrapper?.style.removeProperty(constants_1.TABLE_CSS_VARS.viewportWidth);
38
37
  return;
39
38
  }
40
39
  const viewport = internalScrollRef.current;
@@ -46,6 +45,21 @@ function useTableScroll({ usePageStickyHeader, isStickyControls, stickyControlsO
46
45
  observer.observe(viewport);
47
46
  return () => observer.disconnect();
48
47
  }, [usePageStickyHeader, isScrollReady, columnSizeVars, syncHeaderHorizontalScroll, view, isLoadingState]);
48
+ // Ширина вьюпорта нужна не только sticky-шапке: по ней центрируется пустое состояние.
49
+ (0, utils_1.useLayoutEffect)(() => {
50
+ const wrapper = wrapperRef.current;
51
+ const viewport = internalScrollRef.current;
52
+ if (!wrapper || !viewport) {
53
+ return;
54
+ }
55
+ const syncViewportWidth = () => {
56
+ wrapper.style.setProperty(constants_1.TABLE_CSS_VARS.viewportWidth, `${viewport.clientWidth}px`);
57
+ };
58
+ syncViewportWidth();
59
+ const observer = new ResizeObserver(syncViewportWidth);
60
+ observer.observe(viewport);
61
+ return () => observer.disconnect();
62
+ }, [isScrollReady, usePageStickyHeader, view, isCardsView, isLoadingState]);
49
63
  (0, utils_1.useLayoutEffect)(() => {
50
64
  if (!usePageStickyHeader || !showToolbar) {
51
65
  wrapperRef.current?.style.removeProperty(constants_1.TABLE_CSS_VARS.stickyToolbarOffset);
@@ -442,7 +442,8 @@
442
442
  flex:1 1 auto;
443
443
  flex-direction:column;
444
444
  width:100%;
445
- min-width:0;
445
+ min-width:-moz-max-content;
446
+ min-width:max-content;
446
447
  min-height:100%;
447
448
  }
448
449
 
@@ -575,4 +576,21 @@
575
576
  flex:1 1 auto;
576
577
  width:100%;
577
578
  max-width:100%;
579
+ }
580
+
581
+ .columnDragPreview{
582
+ display:flex;
583
+ align-items:center;
584
+ box-sizing:border-box;
585
+ height:var(--sn-table-anatomy-content-tableCell-minHeight, var(--sn-primitive-dimension-40, 40px));
586
+ padding:var(--sn-table-anatomy-content-tableHead-paddingTop, var(--sn-primitive-dimension-6, 6px)) var(--sn-table-anatomy-content-tableHead-paddingRight, var(--sn-primitive-dimension-12, 12px)) var(--sn-table-anatomy-content-tableHead-paddingBottom, var(--sn-primitive-dimension-6, 6px)) var(--sn-table-anatomy-content-tableHead-paddingLeft, var(--sn-primitive-dimension-12, 12px));
587
+ border-radius:var(--sn-table-anatomy-content-borderRadius, var(--sn-brand-anatomy-radius-table-m, var(--sn-primitive-dimension-4, 4px)));
588
+ color:var(--sn-theme-color-available-version-textTertiary, var(--sn-brand-color-text-version-tertiary, rgba(65, 66, 78, 0.5490196078)));
589
+ white-space:nowrap;
590
+ font-family:var(--sn-regular-body-m-fontFamily, var(--sn-brand-font-fontFamily-regular-body, var(--sn-primitive-fontFamily-brandA-sans, SB Sans Interface)));
591
+ font-weight:var(--sn-regular-body-m-fontWeight, var(--sn-theme-typography-fontWeight-regular-body-m, var(--sn-brand-font-fontWeight-light-regular-body-m, var(--sn-primitive-font-fontWeightValue-400, 400))));
592
+ line-height:var(--sn-regular-body-m-lineHeight, var(--sn-density-typography-roleBody-lineHeightM, var(--sn-primitive-font-lineHeight-by16, 24px)));
593
+ font-size:var(--sn-regular-body-m-fontSize, var(--sn-density-typography-roleBody-fontSizeM, var(--sn-primitive-font-fontSize-16, 16px)));
594
+ letter-spacing:var(--sn-regular-body-m-letterSpacing, var(--sn-primitive-font-letterSpacing-m, 0.1px));
595
+ paragraph-spacing:var(--sn-regular-body-m-paragraphSpacing, var(--sn-primitive-font-paragraphSpacing-byFontSize14, 7px));
578
596
  }
@@ -0,0 +1,6 @@
1
+ import { Modifier } from '@dnd-kit/core';
2
+ /**
3
+ * Копию тянет наверх к шапке: `useSortable` вызывают и ячейки тела с тем же id колонки,
4
+ * поэтому dnd-kit считает активным узлом последнюю из них и якорит оверлей по её строке.
5
+ */
6
+ export declare const alignOverlayToHeader: Modifier;
@@ -0,0 +1,28 @@
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,3 +1,4 @@
1
+ export * from './alignOverlayToHeader';
1
2
  export * from './columnSize';
2
3
  export * from './getColumnIdentifier';
3
4
  export * from './getColumnStyleVars';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./alignOverlayToHeader"), exports);
17
18
  __exportStar(require("./columnSize"), exports);
18
19
  __exportStar(require("./getColumnIdentifier"), exports);
19
20
  __exportStar(require("./getColumnStyleVars"), exports);
@@ -10,7 +10,7 @@ export declare const COLUMN_ALIGN: {
10
10
  export declare const COLUMN_SETTINGS_MODE: {
11
11
  /** В меню настроек `Switch` заблокирован, колонка всегда видима */
12
12
  readonly Locked: "locked";
13
- /** В меню, по умолчанию включена */
13
+ /** В меню, по умолчанию включена. Режим по умолчанию для любой колонки */
14
14
  readonly DefaultVisible: "defaultVisible";
15
15
  /** В меню, по умолчанию выключена */
16
16
  readonly DefaultHidden: "defaultHidden";
@@ -12,7 +12,7 @@ exports.COLUMN_ALIGN = {
12
12
  exports.COLUMN_SETTINGS_MODE = {
13
13
  /** В меню настроек `Switch` заблокирован, колонка всегда видима */
14
14
  Locked: 'locked',
15
- /** В меню, по умолчанию включена */
15
+ /** В меню, по умолчанию включена. Режим по умолчанию для любой колонки */
16
16
  DefaultVisible: 'defaultVisible',
17
17
  /** В меню, по умолчанию выключена */
18
18
  DefaultHidden: 'defaultHidden',
@@ -1,9 +1,11 @@
1
1
  import { Cell as TableCell } from '@tanstack/react-table';
2
+ import { ColumnOrder } from '../../../types';
2
3
  import { CellProps } from '../Cell';
3
4
  type BodyCellProps<TData> = Omit<CellProps, 'style' | 'children'> & {
4
5
  cell: TableCell<TData, unknown>;
5
6
  rowAutoHeight?: boolean;
6
7
  isDraggable?: boolean;
8
+ columnOrder?: ColumnOrder;
7
9
  };
8
- export declare function BodyCell<TData>({ isDraggable, ...props }: BodyCellProps<TData>): import("react/jsx-runtime").JSX.Element;
10
+ export declare function BodyCell<TData>({ isDraggable, columnOrder, ...props }: BodyCellProps<TData>): import("react/jsx-runtime").JSX.Element;
9
11
  export {};
@@ -5,29 +5,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BodyCell = BodyCell;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const sortable_1 = require("@dnd-kit/sortable");
9
8
  const react_table_1 = require("@tanstack/react-table");
10
9
  const classnames_1 = __importDefault(require("classnames"));
11
10
  const constants_1 = require("../../../constants");
12
11
  const hooks_1 = require("../../../hooks");
13
12
  const Cell_1 = require("../Cell");
14
13
  const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
15
- function BodyCellView({ cell, className, rowAutoHeight, style, setNodeRef, ...props }) {
14
+ function BodyCellView({ cell, className, rowAutoHeight, style, isDragging, ...props }) {
16
15
  const columnDef = cell.column.columnDef;
17
- return ((0, jsx_runtime_1.jsx)(Cell_1.Cell, { ...props, ref: setNodeRef, style: style, className: (0, classnames_1.default)(styles_module_scss_1.default.tableBodyCell, className, columnDef.cellClassName), "data-row-auto-height": rowAutoHeight || undefined, "data-align": columnDef.align, "data-no-padding": columnDef.noBodyCellPadding || undefined, "data-column-id": cell.column.id, "data-test-id": constants_1.TEST_IDS.bodyCell, children: (0, react_table_1.flexRender)(columnDef.cell, cell.getContext()) }));
16
+ return ((0, jsx_runtime_1.jsx)(Cell_1.Cell, { ...props, style: style, className: (0, classnames_1.default)(styles_module_scss_1.default.tableBodyCell, className, columnDef.cellClassName), "data-row-auto-height": rowAutoHeight || undefined, "data-align": columnDef.align, "data-no-padding": columnDef.noBodyCellPadding || undefined, "data-column-id": cell.column.id, "data-dragging": isDragging || undefined, "data-test-id": constants_1.TEST_IDS.bodyCell, children: (0, react_table_1.flexRender)(columnDef.cell, cell.getContext()) }));
18
17
  }
19
18
  function StaticBodyCell(props) {
20
19
  const style = (0, hooks_1.useCellSizes)(props.cell);
21
20
  return (0, jsx_runtime_1.jsx)(BodyCellView, { ...props, style: style });
22
21
  }
23
- function DraggableBodyCell(props) {
24
- const { setNodeRef, isDragging, transform } = (0, sortable_1.useSortable)({ id: props.cell.column.id });
25
- const style = (0, hooks_1.useCellSizes)(props.cell, { isDraggable: true, isDragging, transform });
26
- return (0, jsx_runtime_1.jsx)(BodyCellView, { ...props, style: style, setNodeRef: setNodeRef });
22
+ function DraggableBodyCell({ columnOrder, ...props }) {
23
+ const { transform, isDragging } = (0, hooks_1.useColumnDragTransform)(props.cell.column.id, columnOrder);
24
+ const style = (0, hooks_1.useCellSizes)(props.cell, { isDraggable: true, transform });
25
+ return (0, jsx_runtime_1.jsx)(BodyCellView, { ...props, style: style, isDragging: isDragging });
27
26
  }
28
- function BodyCell({ isDraggable, ...props }) {
29
- if (isDraggable) {
30
- return (0, jsx_runtime_1.jsx)(DraggableBodyCell, { ...props });
27
+ function BodyCell({ isDraggable, columnOrder, ...props }) {
28
+ if (isDraggable && columnOrder) {
29
+ return (0, jsx_runtime_1.jsx)(DraggableBodyCell, { ...props, columnOrder: columnOrder });
31
30
  }
32
31
  return (0, jsx_runtime_1.jsx)(StaticBodyCell, { ...props });
33
32
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HeaderCell = HeaderCell;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const sortable_1 = require("@dnd-kit/sortable");
9
+ const drag_and_drop_1 = require("@cloud-ru/ds-drag-and-drop");
9
10
  const truncate_string_1 = require("@cloud-ru/ds-truncate-string");
10
11
  const react_table_1 = require("@tanstack/react-table");
11
12
  const classnames_1 = __importDefault(require("classnames"));
@@ -26,8 +27,8 @@ function HeaderCell({ header, pinPosition, className, rowAutoHeight, isDraggable
26
27
  const columnSizingInfo = header.getContext().table.getState().columnSizingInfo;
27
28
  const isSomeColumnResizing = columnSizingInfo.isResizingColumn;
28
29
  const columnDef = header.column.columnDef;
29
- const { attributes, listeners, setNodeRef, isDragging, transform } = (0, sortable_1.useSortable)({ id: header.column.id });
30
- const style = (0, hooks_1.useCellSizes)(header, { isDraggable, isDragging, transform });
30
+ const { listeners, setNodeRef, isDragging, transform } = (0, sortable_1.useSortable)({ id: header.column.id });
31
+ const style = (0, hooks_1.useCellSizes)(header, { isDraggable, transform });
31
32
  const sortingHandler = (e) => {
32
33
  if (isSomeColumnResizing)
33
34
  return;
@@ -38,12 +39,12 @@ function HeaderCell({ header, pinPosition, className, rowAutoHeight, isDraggable
38
39
  if (!isDraggable || constants_1.DEFAULT_COLUMNS.includes(header.column.id)) {
39
40
  return {};
40
41
  }
41
- return { ...attributes, ...listeners };
42
- }, [attributes, header.column.id, isDraggable, listeners]);
43
- return ((0, jsx_runtime_1.jsxs)(Cell_1.Cell, { style: style, onClick: sortingHandler, "data-sortable": isSortable || undefined, "data-draggable": isDraggable || undefined, "data-no-padding": columnDef.noHeaderCellPadding || undefined, "data-no-offset": columnDef.noHeaderCellBorderOffset || undefined, "data-test-id": constants_1.TEST_IDS.headerCell, "data-header-id": header.id, "data-resizing": isResizing || undefined, "data-pin-position": pinPosition || undefined, "data-row-auto-height": rowAutoHeight || undefined, role: 'columnheader', className: (0, classnames_1.default)(styles_module_scss_1.default.tableHeaderCell, className, columnDef.headerClassName), ref: element => {
42
+ return listeners;
43
+ }, [header.column.id, isDraggable, listeners]);
44
+ return ((0, jsx_runtime_1.jsxs)(Cell_1.Cell, { style: style, onClick: sortingHandler, "data-sortable": isSortable || undefined, "data-draggable": isDraggable || undefined, "data-no-padding": columnDef.noHeaderCellPadding || undefined, "data-no-offset": columnDef.noHeaderCellBorderOffset || undefined, "data-test-id": constants_1.TEST_IDS.headerCell, "data-header-id": header.id, "data-resizing": isResizing || undefined, "data-dragging": (isDraggable && isDragging) || undefined, "data-pin-position": pinPosition || undefined, "data-row-auto-height": rowAutoHeight || undefined, role: 'columnheader', className: (0, classnames_1.default)(styles_module_scss_1.default.tableHeaderCell, className, columnDef.headerClassName), ref: element => {
44
45
  if (isDraggable) {
45
46
  setNodeRef(element);
46
47
  }
47
48
  cellRef.current = element;
48
- }, children: [(0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tableHeaderCellDragWrapper, "data-dragging": (isDraggable && isDragging) || undefined, ...draggableProps, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tableHeaderCellMain, "data-align": columnDef.headerAlign || undefined, children: [columnDef.header && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tableHeaderCellName, children: rowAutoHeight || typeof renderedHeader !== 'string' ? (renderedHeader) : ((0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: renderedHeader })) })), Boolean(sortIcon) && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tableHeaderIcon, "data-sort-direction": sortDirection, "data-test-id": constants_1.TEST_IDS.headerSortIndicator, children: sortIcon }))] }) }), Boolean(isResizable) && (0, jsx_runtime_1.jsx)(ResizeHandle_1.ResizeHandle, { header: header, cellRef: cellRef })] }));
49
+ }, children: [(0, jsx_runtime_1.jsx)(drag_and_drop_1.DragGhost, { dragging: isDraggable && isDragging, mode: drag_and_drop_1.DRAG_MODE.Dynamic, className: styles_module_scss_1.default.tableHeaderCellDragWrapper, ...draggableProps, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tableHeaderCellMain, "data-align": columnDef.headerAlign || undefined, children: [columnDef.header && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tableHeaderCellName, children: rowAutoHeight || typeof renderedHeader !== 'string' ? (renderedHeader) : ((0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: renderedHeader })) })), Boolean(sortIcon) && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tableHeaderIcon, "data-sort-direction": sortDirection, "data-test-id": constants_1.TEST_IDS.headerSortIndicator, children: sortIcon }))] }) }), Boolean(isResizable) && (0, jsx_runtime_1.jsx)(ResizeHandle_1.ResizeHandle, { header: header, cellRef: cellRef })] }));
49
50
  }
@@ -37,5 +37,5 @@ function ResizeHandle({ header, cellRef }) {
37
37
  resizeHandler(event);
38
38
  };
39
39
  const offset = isResizing ? getResizeIndicatorOffset({ header, cellRef }) : 0;
40
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { role: 'button', tabIndex: 0, className: (0, classnames_1.default)(styles_module_scss_1.default.tableHeaderIcon, styles_module_scss_1.default.tableHeaderResizeHandle), "data-resizing": isResizing || undefined, onMouseDown: handleMouseDown, onTouchStart: resizeHandler, onMouseUp: helpers_1.stopEventPropagation }), isResizing && ((0, jsx_runtime_1.jsx)("div", { "data-test-id": constants_1.TEST_IDS.headerResizeHandleMovingPart, className: styles_module_scss_1.default.tableHeaderResizeIndicator, style: { '--offset': `${offset}px` } }))] }));
40
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { "aria-hidden": true, className: (0, classnames_1.default)(styles_module_scss_1.default.tableHeaderIcon, styles_module_scss_1.default.tableHeaderResizeHandle), "data-resizing": isResizing || undefined, onMouseDown: handleMouseDown, onTouchStart: resizeHandler, onMouseUp: helpers_1.stopEventPropagation }), isResizing && ((0, jsx_runtime_1.jsx)("div", { "data-test-id": constants_1.TEST_IDS.headerResizeHandleMovingPart, className: styles_module_scss_1.default.tableHeaderResizeIndicator, style: { '--offset': `${offset}px` } }))] }));
41
41
  }
@@ -10,4 +10,7 @@
10
10
  box-sizing:border-box;
11
11
  width:100%;
12
12
  background-color:transparent;
13
+ }
14
+ .tableCell[data-dragging]{
15
+ box-shadow:inset var(--sn-table-anatomy-content-tableLine-background-interaction-borderVerticalWidth, var(--sn-primitive-strokeWeight-strokeRegular, 1px)) 0 0 0 var(--sn-theme-color-available-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-default-borderColor, rgba(159, 166, 198, 0.3019607843))), inset calc(-1 * var(--sn-table-anatomy-content-tableLine-background-interaction-borderVerticalWidth, var(--sn-primitive-strokeWeight-strokeRegular, 1px))) 0 0 0 var(--sn-theme-color-available-borderColor, var(--sn-brand-color-state-neutralBorder-forLightMode-default-borderColor, rgba(159, 166, 198, 0.3019607843)));
13
16
  }
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BodyRow = BodyRow;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const sortable_1 = require("@dnd-kit/sortable");
9
8
  const react_1 = require("react");
10
9
  const components_1 = require("../../components");
11
10
  const constants_1 = require("../../constants");
@@ -33,5 +32,5 @@ function BodyRow({ row, onRowClick, rowAutoHeight, columnOrder, enableColumnsOrd
33
32
  };
34
33
  const isSelected = row.getIsSelected() || (row.getIsSomeSelected() && !row.getCanMultiSelect() && !row.getIsExpanded());
35
34
  const rowBackgroundColor = getRowBackgroundColor?.(row.original);
36
- return ((0, jsx_runtime_1.jsx)(contexts_1.RowContext.Provider, { value: { dropListOpened, setDropListOpen, disabledRowAppearance }, children: (0, jsx_runtime_1.jsxs)(Row_1.Row, { onClick: handleRowClick, clickable: Boolean(onRowClick) && !(disabled && disabledRowAppearance === components_1.RowAppearance.Disabled), "data-clickable": Boolean(onRowClick) || undefined, "data-disabled": disabled || undefined, "data-row-appearance": disabled ? disabledRowAppearance : undefined, "data-selected": isSelected || undefined, "data-actions-opened": dropListOpened || undefined, "data-test-id": constants_1.TEST_IDS.bodyRow, "data-row-id": row.id, "data-row-bg-appearance": rowBackgroundColor && !disabled && !isSelected ? rowBackgroundColor : undefined, className: styles_module_scss_1.default.bodyRow, rowAutoHeight: rowAutoHeight, children: [leftPinned && ((0, jsx_runtime_1.jsx)(PinnedCells_1.PinnedCells, { position: constants_1.COLUMN_PIN_POSITION.Left, children: leftPinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight }, cell.id))) })), columnVirtualPadding && columnVirtualPadding.left > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": true, style: { width: columnVirtualPadding.left, flexShrink: 0 } })), enableColumnsOrderSortByDrag ? ((0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: columnOrder, strategy: sortable_1.horizontalListSortingStrategy, children: unpinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: true }, cell.id))) })) : (unpinned.map(cell => (0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight }, cell.id))), columnVirtualPadding && columnVirtualPadding.right > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": true, style: { width: columnVirtualPadding.right, flexShrink: 0 } })), rightPinned && ((0, jsx_runtime_1.jsx)(PinnedCells_1.PinnedCells, { position: constants_1.COLUMN_PIN_POSITION.Right, children: rightPinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: enableColumnsOrderSortByDrag }, cell.id))) }))] }) }));
35
+ return ((0, jsx_runtime_1.jsx)(contexts_1.RowContext.Provider, { value: { dropListOpened, setDropListOpen, disabledRowAppearance }, children: (0, jsx_runtime_1.jsxs)(Row_1.Row, { onClick: handleRowClick, clickable: Boolean(onRowClick) && !(disabled && disabledRowAppearance === components_1.RowAppearance.Disabled), "data-clickable": Boolean(onRowClick) || undefined, "data-disabled": disabled || undefined, "data-row-appearance": disabled ? disabledRowAppearance : undefined, "data-selected": isSelected || undefined, "data-actions-opened": dropListOpened || undefined, "data-test-id": constants_1.TEST_IDS.bodyRow, "data-row-id": row.id, "data-row-bg-appearance": rowBackgroundColor && !disabled && !isSelected ? rowBackgroundColor : undefined, className: styles_module_scss_1.default.bodyRow, rowAutoHeight: rowAutoHeight, children: [leftPinned && ((0, jsx_runtime_1.jsx)(PinnedCells_1.PinnedCells, { position: constants_1.COLUMN_PIN_POSITION.Left, children: leftPinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight }, cell.id))) })), columnVirtualPadding && columnVirtualPadding.left > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": true, style: { width: columnVirtualPadding.left, flexShrink: 0 } })), unpinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: enableColumnsOrderSortByDrag, columnOrder: columnOrder }, cell.id))), columnVirtualPadding && columnVirtualPadding.right > 0 && ((0, jsx_runtime_1.jsx)("div", { "aria-hidden": true, style: { width: columnVirtualPadding.right, flexShrink: 0 } })), rightPinned && ((0, jsx_runtime_1.jsx)(PinnedCells_1.PinnedCells, { position: constants_1.COLUMN_PIN_POSITION.Right, children: rightPinned.map(cell => ((0, jsx_runtime_1.jsx)(Cells_1.BodyCell, { cell: cell, rowAutoHeight: rowAutoHeight, isDraggable: enableColumnsOrderSortByDrag }, cell.id))) }))] }) }));
37
36
  }
@@ -43,6 +43,10 @@
43
43
  width:var(--sn-table-anatomy-content-tableLine-background-interaction-borderVerticalWidth, var(--sn-primitive-strokeWeight-strokeRegular, 1px));
44
44
  }
45
45
 
46
+ .tableHeader .rowPinnedCells::after{
47
+ bottom:0;
48
+ }
49
+
46
50
  .rowPinnedCells[data-position=left]{
47
51
  left:0;
48
52
  }
@@ -10,7 +10,6 @@ function useEmptyState({ noDataState: noDataStateProp, noResultsState: noResults
10
10
  const noDataState = {
11
11
  icon: { icon: system_1.SearchSVG, appearance: 'neutral', background: true },
12
12
  title: t('noData.title'),
13
- content: t('noData.content'),
14
13
  ...noDataStateProp,
15
14
  };
16
15
  const noResultsState = {