@cloud-ru/ds-table 1.0.7 → 1.0.8-preview-a198be91.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 (25) hide show
  1. package/README.md +6 -6
  2. package/dist/cjs/components/Table/Table.js +3 -3
  3. package/dist/cjs/components/Table/components/TableCardsBody/TableCardsBody.d.ts +1 -2
  4. package/dist/cjs/components/Table/components/TableCardsBody/TableCardsBody.js +2 -2
  5. package/dist/cjs/components/Table/components/TableRowsBody/TableRowsBody.d.ts +1 -2
  6. package/dist/cjs/components/Table/components/TableRowsBody/TableRowsBody.js +2 -2
  7. package/dist/cjs/presets/infiniteTable/toInfiniteTableProps.d.ts +9 -2
  8. package/dist/cjs/presets/infiniteTable/toInfiniteTableProps.js +1 -1
  9. package/dist/cjs/presets/infiniteTable/useInfiniteTableProps.js +1 -3
  10. package/dist/esm/components/Table/Table.js +3 -3
  11. package/dist/esm/components/Table/components/TableCardsBody/TableCardsBody.d.ts +1 -2
  12. package/dist/esm/components/Table/components/TableCardsBody/TableCardsBody.js +2 -2
  13. package/dist/esm/components/Table/components/TableRowsBody/TableRowsBody.d.ts +1 -2
  14. package/dist/esm/components/Table/components/TableRowsBody/TableRowsBody.js +2 -2
  15. package/dist/esm/presets/infiniteTable/toInfiniteTableProps.d.ts +9 -2
  16. package/dist/esm/presets/infiniteTable/toInfiniteTableProps.js +2 -2
  17. package/dist/esm/presets/infiniteTable/useInfiniteTableProps.js +1 -3
  18. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  19. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  20. package/package.json +21 -21
  21. package/src/components/Table/Table.tsx +1 -2
  22. package/src/components/Table/components/TableCardsBody/TableCardsBody.tsx +0 -3
  23. package/src/components/Table/components/TableRowsBody/TableRowsBody.tsx +0 -3
  24. package/src/presets/infiniteTable/toInfiniteTableProps.ts +10 -3
  25. package/src/presets/infiniteTable/useInfiniteTableProps.ts +1 -4
package/README.md CHANGED
@@ -1945,7 +1945,7 @@ export function TreeTableWithSelection() {
1945
1945
  #### Подгрузка при скролле
1946
1946
 
1947
1947
  ```tsx
1948
- import { InfiniteTable, SimpleColumnDef } from '@cloud-ru/ds-table';
1948
+ import { defineColumns, InfiniteTable, SimpleColumnDef } from '@cloud-ru/ds-table';
1949
1949
  import { useCallback, useState } from 'react';
1950
1950
 
1951
1951
  type User = {
@@ -1987,7 +1987,7 @@ export function InfiniteTableBasic() {
1987
1987
  <div style={{ display: 'grid', gridTemplateRows: 'minmax(0, 1fr)', height: 360 }}>
1988
1988
  <InfiniteTable
1989
1989
  data={items}
1990
- columns={columns}
1990
+ columns={defineColumns(columns)}
1991
1991
  getRowId={user => user.id}
1992
1992
  loading={loading}
1993
1993
  hasMore={hasMore}
@@ -2002,7 +2002,7 @@ export function InfiniteTableBasic() {
2002
2002
  #### Через хук useInfiniteTableProps
2003
2003
 
2004
2004
  ```tsx
2005
- import { SimpleColumnDef, Table, useInfiniteTableProps } from '@cloud-ru/ds-table';
2005
+ import { defineColumns, SimpleColumnDef, Table, useInfiniteTableProps } from '@cloud-ru/ds-table';
2006
2006
  import { useCallback, useState } from 'react';
2007
2007
 
2008
2008
  type User = { id: string; name: string; email: string };
@@ -2035,7 +2035,7 @@ export function InfiniteTableWithHook() {
2035
2035
 
2036
2036
  const tableProps = useInfiniteTableProps({
2037
2037
  data: items,
2038
- columns,
2038
+ columns: defineColumns(columns),
2039
2039
  getRowId: user => user.id,
2040
2040
  loading,
2041
2041
  hasMore,
@@ -2053,7 +2053,7 @@ export function InfiniteTableWithHook() {
2053
2053
  #### Без подгрузки (hasMore: false)
2054
2054
 
2055
2055
  ```tsx
2056
- import { InfiniteTable, SimpleColumnDef } from '@cloud-ru/ds-table';
2056
+ import { defineColumns, InfiniteTable, SimpleColumnDef } from '@cloud-ru/ds-table';
2057
2057
 
2058
2058
  type User = { id: string; name: string; email: string };
2059
2059
 
@@ -2070,7 +2070,7 @@ const columns: SimpleColumnDef<User>[] = [
2070
2070
  export function InfiniteTableStatic() {
2071
2071
  return (
2072
2072
  <div style={{ display: 'grid', gridTemplateRows: 'minmax(0, 1fr)', height: 280 }}>
2073
- <InfiniteTable data={USERS} columns={columns} getRowId={user => user.id} hasMore={false} outline />
2073
+ <InfiniteTable data={USERS} columns={defineColumns(columns)} getRowId={user => user.id} hasMore={false} outline />
2074
2074
  </div>
2075
2075
  );
2076
2076
  }
@@ -273,8 +273,8 @@ function Table({ data, rowPinning = {
273
273
  // и ныряла под закреплённые колонки.
274
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 }));
275
275
  const tableHeaderElement = showTableHeader ? ((0, jsx_runtime_1.jsx)(helperComponents_1.HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, suppressSticky: usePageStickyHeader })) : null;
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 }));
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 }));
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 }));
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 }));
278
278
  const tableContentBody = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!usePageStickyHeader ? tableHeaderElement : null, tableRowsContent] }));
279
279
  let tableBody = tableContentBody;
280
280
  let tableScrollRows = tableRowsContent;
@@ -337,7 +337,7 @@ function Table({ data, rowPinning = {
337
337
  paginationChrome =
338
338
  isStickyControls && controlsAcrylic ? ((0, jsx_runtime_1.jsx)(TableChrome_1.TableChrome, { variant: 'footer', acrylic: controlsAcrylic, children: pagination })) : (pagination);
339
339
  }
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] })] }) }));
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 })] }), loadMoreButtonNode, !isCardsView && outline ? (0, jsx_runtime_1.jsx)("span", { className: styles_module_scss_1.default.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
341
341
  }
342
342
  Table.getStatusColumnDef = helperComponents_1.getStatusColumnDef;
343
343
  Table.statusAppearances = helperComponents_1.STATUS_APPEARANCE;
@@ -21,9 +21,8 @@ type TableCardsBodyProps<TData extends object> = {
21
21
  showInfiniteLoadingTail: boolean;
22
22
  loadingTableRows: Row<TData>[];
23
23
  loadingTable: Table<TData>;
24
- loadMoreButton?: ReactNode;
25
24
  };
26
- export declare function TableCardsBody<TData extends object>({ filteredTopRows, centerRows, table, headlineId, cardSelection, rowSelectionAppearance, suppressHeader, onRowClick, renderCard, cardsListProps, emptyState, showInfiniteLoadingTail, loadingTableRows, loadingTable, loadMoreButton, }: TableCardsBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
25
+ export declare function TableCardsBody<TData extends object>({ filteredTopRows, centerRows, table, headlineId, cardSelection, rowSelectionAppearance, suppressHeader, onRowClick, renderCard, cardsListProps, emptyState, showInfiniteLoadingTail, loadingTableRows, loadingTable, }: TableCardsBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
27
26
  export declare function getCardsListProps({ isMobile, cardMinWidth, cardColumns, }: {
28
27
  isMobile: boolean;
29
28
  cardMinWidth?: number;
@@ -13,12 +13,12 @@ const constants_1 = require("../../../../constants");
13
13
  const helperComponents_1 = require("../../../../helperComponents");
14
14
  const types_1 = require("../../../types");
15
15
  const styles_module_scss_1 = __importDefault(require('../../styles.module.css'));
16
- function TableCardsBody({ filteredTopRows, centerRows, table, headlineId, cardSelection, rowSelectionAppearance, suppressHeader, onRowClick, renderCard, cardsListProps, emptyState, showInfiniteLoadingTail, loadingTableRows, loadingTable, loadMoreButton, }) {
16
+ function TableCardsBody({ filteredTopRows, centerRows, table, headlineId, cardSelection, rowSelectionAppearance, suppressHeader, onRowClick, renderCard, cardsListProps, emptyState, showInfiniteLoadingTail, loadingTableRows, loadingTable, }) {
17
17
  const renderContentCard = (row, selectionAppearance) => {
18
18
  const defaultRender = ((0, jsx_runtime_1.jsx)(helperComponents_1.TableCard, { headlineId: headlineId, row: row, table: table, selection: cardSelection, selectionAppearance: selectionAppearance, suppressHeader: suppressHeader, onRowClick: onRowClick }));
19
19
  return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: renderCard ? renderCard({ row, table, defaultRender }) : defaultRender }, row.id);
20
20
  };
21
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { ...cardsListProps, children: [filteredTopRows.map(row => renderContentCard(row, types_1.RowAppearance.HideToggler)), centerRows.map(row => renderContentCard(row, rowSelectionAppearance))] }), showInfiniteLoadingTail ? ((0, jsx_runtime_1.jsx)(skeleton_1.SkeletonContextProvider, { loading: true, children: (0, jsx_runtime_1.jsx)("div", { ...cardsListProps, children: loadingTableRows.slice(0, 3).map(row => ((0, jsx_runtime_1.jsx)(helperComponents_1.TableCard, { headlineId: headlineId, row: row, table: loadingTable, selection: 'none', suppressHeader: suppressHeader }, row.id))) }) })) : null, loadMoreButton, emptyState] }));
21
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { ...cardsListProps, children: [filteredTopRows.map(row => renderContentCard(row, types_1.RowAppearance.HideToggler)), centerRows.map(row => renderContentCard(row, rowSelectionAppearance))] }), showInfiniteLoadingTail ? ((0, jsx_runtime_1.jsx)(skeleton_1.SkeletonContextProvider, { loading: true, children: (0, jsx_runtime_1.jsx)("div", { ...cardsListProps, children: loadingTableRows.slice(0, 3).map(row => ((0, jsx_runtime_1.jsx)(helperComponents_1.TableCard, { headlineId: headlineId, row: row, table: loadingTable, selection: 'none', suppressHeader: suppressHeader }, row.id))) }) })) : null, emptyState] }));
22
22
  }
23
23
  function getCardsListProps({ isMobile, cardMinWidth, cardColumns, }) {
24
24
  const cardsGridProps = {
@@ -15,7 +15,6 @@ type TableRowsBodyProps<TData extends object> = {
15
15
  emptyState: ReactNode;
16
16
  showInfiniteLoadingTail: boolean;
17
17
  loadingTableRows: Row<TData>[];
18
- loadMoreButton?: ReactNode;
19
18
  };
20
- export declare function TableRowsBody<TData extends object>({ filteredTopRows, centerRows, rowVirtualizer, columnOrder, rowAutoHeight, onRowClick, enableColumnsOrderSortByDrag, rowSelectionAppearance, emptyState, showInfiniteLoadingTail, loadingTableRows, loadMoreButton, }: TableRowsBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
19
+ export declare function TableRowsBody<TData extends object>({ filteredTopRows, centerRows, rowVirtualizer, columnOrder, rowAutoHeight, onRowClick, enableColumnsOrderSortByDrag, rowSelectionAppearance, emptyState, showInfiniteLoadingTail, loadingTableRows, }: TableRowsBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
21
20
  export {};
@@ -10,12 +10,12 @@ const constants_1 = require("../../../../constants");
10
10
  const helperComponents_1 = require("../../../../helperComponents");
11
11
  const types_1 = require("../../../types");
12
12
  const styles_module_scss_1 = __importDefault(require('../../styles.module.css'));
13
- function TableRowsBody({ filteredTopRows, centerRows, rowVirtualizer, columnOrder, rowAutoHeight, onRowClick, enableColumnsOrderSortByDrag, rowSelectionAppearance, emptyState, showInfiniteLoadingTail, loadingTableRows, loadMoreButton, }) {
13
+ function TableRowsBody({ filteredTopRows, centerRows, rowVirtualizer, columnOrder, rowAutoHeight, onRowClick, enableColumnsOrderSortByDrag, rowSelectionAppearance, emptyState, showInfiniteLoadingTail, loadingTableRows, }) {
14
14
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [filteredTopRows.length ? ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.topRowWrapper, children: filteredTopRows.map(row => ((0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: types_1.RowAppearance.HideToggler }, row.id))) })) : null, rowVirtualizer ? ((0, jsx_runtime_1.jsx)("div", { style: {
15
15
  position: 'relative',
16
16
  height: `${rowVirtualizer.getTotalSize()}px`,
17
17
  }, children: rowVirtualizer.getVirtualItems().map(virtualRow => {
18
18
  const row = centerRows[virtualRow.index];
19
19
  return ((0, jsx_runtime_1.jsx)("div", { ref: rowVirtualizer.measureElement, "data-index": virtualRow.index, className: styles_module_scss_1.default.virtualRow, style: { [constants_1.TABLE_CSS_VARS.virtualRowStart]: `${virtualRow.start}px` }, children: (0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }) }, row.id));
20
- }) })) : (centerRows.map(row => ((0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }, row.id)))), showInfiniteLoadingTail ? ((0, jsx_runtime_1.jsx)(skeleton_1.SkeletonContextProvider, { loading: true, children: loadingTableRows.slice(0, 3).map(row => ((0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, { row: row, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }, row.id))) })) : null, loadMoreButton, emptyState] }));
20
+ }) })) : (centerRows.map(row => ((0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }, row.id)))), showInfiniteLoadingTail ? ((0, jsx_runtime_1.jsx)(skeleton_1.SkeletonContextProvider, { loading: true, children: loadingTableRows.slice(0, 3).map(row => ((0, jsx_runtime_1.jsx)(helperComponents_1.BodyRow, { row: row, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }, row.id))) })) : null, emptyState] }));
21
21
  }
@@ -1,10 +1,17 @@
1
1
  import { Ref } from 'react';
2
- import { CardViewInput, SimpleColumnDef } from '../../columnUtils';
2
+ import { CardViewInput } from '../../columnUtils';
3
3
  import { InfiniteTableProps } from '../../components/types';
4
+ import { ColumnDefinition } from '../../types';
4
5
  /** Входные пропсы `InfiniteTable` / `useInfiniteTableProps` */
5
6
  export type InfiniteTableInput<TData extends object> = CardViewInput<TData> & {
6
7
  data: TData[];
7
- columns: SimpleColumnDef<TData>[];
8
+ /**
9
+ * Определения колонок в стандартном виде — том же, что у `Table.columnDefinitions`.
10
+ * Упрощённое описание здесь не используется: у таблиц с бесконечной подгрузкой колонки
11
+ * обычно не выражаются им (спред `getStatusColumnDef`, собственный `cell`, `id` не совпадающий
12
+ * с `accessorKey`), а `defineColumns` остаётся доступен отдельно, если он всё же нужен.
13
+ */
14
+ columns: ColumnDefinition<TData>[];
8
15
  getRowId?: (row: TData) => string;
9
16
  } & Omit<InfiniteTableProps<TData>, 'data' | 'columnDefinitions' | 'getRowId' | 'headlineId' | 'infiniteLoading' | 'scrollRef'>;
10
17
  /** Маппинг упрощённых пропсов в `InfiniteTableProps` для `Table` */
@@ -10,7 +10,7 @@ function toInfiniteTableProps(input, scrollRef) {
10
10
  ...rest,
11
11
  ...(0, columnUtils_1.mapCardViewProps)({ headlineKey, defaultView, view, onViewChange, renderCard }),
12
12
  data,
13
- columnDefinitions: (0, columnUtils_1.defineColumns)(columns),
13
+ columnDefinitions: columns,
14
14
  infiniteLoading: true,
15
15
  outline: outline ?? true,
16
16
  enableRowVirtualization: enableRowVirtualization ?? true,
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useInfiniteTableProps = useInfiniteTableProps;
4
4
  const react_1 = require("react");
5
- const columnUtils_1 = require("../../columnUtils");
6
5
  const wrapGetRowId_1 = require("../wrapGetRowId");
7
6
  const toInfiniteTableProps_1 = require("./toInfiniteTableProps");
8
7
  const useInfiniteScrollRef_1 = require("./useInfiniteScrollRef");
@@ -16,11 +15,10 @@ function useInfiniteTableProps(input) {
16
15
  dataLength: input.data.length,
17
16
  });
18
17
  const { columns, getRowId } = input;
19
- const columnDefinitions = (0, react_1.useMemo)(() => (0, columnUtils_1.defineColumns)(columns), [columns]);
20
18
  const wrappedGetRowId = (0, react_1.useMemo)(() => (0, wrapGetRowId_1.wrapGetRowId)(getRowId), [getRowId]);
21
19
  return {
22
20
  ...(0, toInfiniteTableProps_1.toInfiniteTableProps)(input, isButtonMode ? null : scrollRef),
23
- columnDefinitions,
21
+ columnDefinitions: columns,
24
22
  getRowId: wrappedGetRowId,
25
23
  };
26
24
  }
@@ -266,8 +266,8 @@ export function Table({ data, rowPinning = {
266
266
  // и ныряла под закреплённые колонки.
267
267
  const draggingColumnPreview = (_jsx(DragOverlay, { dropAnimation: null, modifiers: [alignOverlayToHeader], children: draggingHeader ? (_jsx(DragPreview, { className: styles.columnDragPreview, style: { width: `var(${TABLE_COLUMN_CSS_VARS.size(draggingHeader.column.id)})` }, children: flexRender(draggingHeader.column.columnDef.header, draggingHeader.getContext()) })) : null }));
268
268
  const tableHeaderElement = showTableHeader ? (_jsx(HeaderRow, { rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, suppressSticky: usePageStickyHeader })) : null;
269
- const tableRowsContent = (_jsx(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 }));
270
- const cardsContentBody = (_jsx(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 }));
269
+ const tableRowsContent = (_jsx(TableRowsBody, { filteredTopRows: filteredTopRows, centerRows: centerRows, rowVirtualizer: rowVirtualizer, columnOrder: columnOrder, rowAutoHeight: rowAutoHeight, onRowClick: onRowClick, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, rowSelectionAppearance: rowSelectionProp?.appearance, emptyState: tableEmptyState, showInfiniteLoadingTail: showInfiniteLoadingTail, loadingTableRows: loadingTableRows }));
270
+ const cardsContentBody = (_jsx(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 }));
271
271
  const tableContentBody = (_jsxs(_Fragment, { children: [!usePageStickyHeader ? tableHeaderElement : null, tableRowsContent] }));
272
272
  let tableBody = tableContentBody;
273
273
  let tableScrollRows = tableRowsContent;
@@ -330,7 +330,7 @@ export function Table({ data, rowPinning = {
330
330
  paginationChrome =
331
331
  isStickyControls && controlsAcrylic ? (_jsx(TableChrome, { variant: 'footer', acrylic: controlsAcrylic, children: pagination })) : (pagination);
332
332
  }
333
- return (_jsx("div", { ref: wrapperRef, className: cn(styles.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, ...extractSupportProps(rest), children: _jsxs(TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, _jsxs("div", { className: styles.tableView, children: [_jsxs("div", { className: styles.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? _jsx("span", { className: styles.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? (_jsxs("div", { className: styles.mobileToolbarMounts, children: [sortingToolbarSlot.mobileMount, columnsSettingsToolbarSlot.mobileMount] })) : null, _jsxs(DndContext, { ...dndContextProps, children: [draggingColumnPreview, _jsx(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 ? _jsx("span", { className: styles.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
333
+ return (_jsx("div", { ref: wrapperRef, className: cn(styles.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, ...extractSupportProps(rest), children: _jsxs(TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, _jsxs("div", { className: styles.tableView, children: [_jsxs("div", { className: styles.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? _jsx("span", { className: styles.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? (_jsxs("div", { className: styles.mobileToolbarMounts, children: [sortingToolbarSlot.mobileMount, columnsSettingsToolbarSlot.mobileMount] })) : null, _jsxs(DndContext, { ...dndContextProps, children: [draggingColumnPreview, _jsx(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 })] }), loadMoreButtonNode, !isCardsView && outline ? _jsx("span", { className: styles.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
334
334
  }
335
335
  Table.getStatusColumnDef = getStatusColumnDef;
336
336
  Table.statusAppearances = STATUS_APPEARANCE;
@@ -21,9 +21,8 @@ type TableCardsBodyProps<TData extends object> = {
21
21
  showInfiniteLoadingTail: boolean;
22
22
  loadingTableRows: Row<TData>[];
23
23
  loadingTable: Table<TData>;
24
- loadMoreButton?: ReactNode;
25
24
  };
26
- export declare function TableCardsBody<TData extends object>({ filteredTopRows, centerRows, table, headlineId, cardSelection, rowSelectionAppearance, suppressHeader, onRowClick, renderCard, cardsListProps, emptyState, showInfiniteLoadingTail, loadingTableRows, loadingTable, loadMoreButton, }: TableCardsBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
25
+ export declare function TableCardsBody<TData extends object>({ filteredTopRows, centerRows, table, headlineId, cardSelection, rowSelectionAppearance, suppressHeader, onRowClick, renderCard, cardsListProps, emptyState, showInfiniteLoadingTail, loadingTableRows, loadingTable, }: TableCardsBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
27
26
  export declare function getCardsListProps({ isMobile, cardMinWidth, cardColumns, }: {
28
27
  isMobile: boolean;
29
28
  cardMinWidth?: number;
@@ -5,12 +5,12 @@ import { TABLE_CSS_VARS } from '../../../../constants.js';
5
5
  import { TableCard } from '../../../../helperComponents/index.js';
6
6
  import { RowAppearance } from '../../../types.js';
7
7
  import styles from '../../styles.module.css';
8
- export function TableCardsBody({ filteredTopRows, centerRows, table, headlineId, cardSelection, rowSelectionAppearance, suppressHeader, onRowClick, renderCard, cardsListProps, emptyState, showInfiniteLoadingTail, loadingTableRows, loadingTable, loadMoreButton, }) {
8
+ export function TableCardsBody({ filteredTopRows, centerRows, table, headlineId, cardSelection, rowSelectionAppearance, suppressHeader, onRowClick, renderCard, cardsListProps, emptyState, showInfiniteLoadingTail, loadingTableRows, loadingTable, }) {
9
9
  const renderContentCard = (row, selectionAppearance) => {
10
10
  const defaultRender = (_jsx(TableCard, { headlineId: headlineId, row: row, table: table, selection: cardSelection, selectionAppearance: selectionAppearance, suppressHeader: suppressHeader, onRowClick: onRowClick }));
11
11
  return _jsx(Fragment, { children: renderCard ? renderCard({ row, table, defaultRender }) : defaultRender }, row.id);
12
12
  };
13
- return (_jsxs(_Fragment, { children: [_jsxs("div", { ...cardsListProps, children: [filteredTopRows.map(row => renderContentCard(row, RowAppearance.HideToggler)), centerRows.map(row => renderContentCard(row, rowSelectionAppearance))] }), showInfiniteLoadingTail ? (_jsx(SkeletonContextProvider, { loading: true, children: _jsx("div", { ...cardsListProps, children: loadingTableRows.slice(0, 3).map(row => (_jsx(TableCard, { headlineId: headlineId, row: row, table: loadingTable, selection: 'none', suppressHeader: suppressHeader }, row.id))) }) })) : null, loadMoreButton, emptyState] }));
13
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { ...cardsListProps, children: [filteredTopRows.map(row => renderContentCard(row, RowAppearance.HideToggler)), centerRows.map(row => renderContentCard(row, rowSelectionAppearance))] }), showInfiniteLoadingTail ? (_jsx(SkeletonContextProvider, { loading: true, children: _jsx("div", { ...cardsListProps, children: loadingTableRows.slice(0, 3).map(row => (_jsx(TableCard, { headlineId: headlineId, row: row, table: loadingTable, selection: 'none', suppressHeader: suppressHeader }, row.id))) }) })) : null, emptyState] }));
14
14
  }
15
15
  export function getCardsListProps({ isMobile, cardMinWidth, cardColumns, }) {
16
16
  const cardsGridProps = {
@@ -15,7 +15,6 @@ type TableRowsBodyProps<TData extends object> = {
15
15
  emptyState: ReactNode;
16
16
  showInfiniteLoadingTail: boolean;
17
17
  loadingTableRows: Row<TData>[];
18
- loadMoreButton?: ReactNode;
19
18
  };
20
- export declare function TableRowsBody<TData extends object>({ filteredTopRows, centerRows, rowVirtualizer, columnOrder, rowAutoHeight, onRowClick, enableColumnsOrderSortByDrag, rowSelectionAppearance, emptyState, showInfiniteLoadingTail, loadingTableRows, loadMoreButton, }: TableRowsBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
19
+ export declare function TableRowsBody<TData extends object>({ filteredTopRows, centerRows, rowVirtualizer, columnOrder, rowAutoHeight, onRowClick, enableColumnsOrderSortByDrag, rowSelectionAppearance, emptyState, showInfiniteLoadingTail, loadingTableRows, }: TableRowsBodyProps<TData>): import("react/jsx-runtime").JSX.Element;
21
20
  export {};
@@ -4,12 +4,12 @@ import { TABLE_CSS_VARS } from '../../../../constants.js';
4
4
  import { BodyRow } from '../../../../helperComponents/index.js';
5
5
  import { RowAppearance } from '../../../types.js';
6
6
  import styles from '../../styles.module.css';
7
- export function TableRowsBody({ filteredTopRows, centerRows, rowVirtualizer, columnOrder, rowAutoHeight, onRowClick, enableColumnsOrderSortByDrag, rowSelectionAppearance, emptyState, showInfiniteLoadingTail, loadingTableRows, loadMoreButton, }) {
7
+ export function TableRowsBody({ filteredTopRows, centerRows, rowVirtualizer, columnOrder, rowAutoHeight, onRowClick, enableColumnsOrderSortByDrag, rowSelectionAppearance, emptyState, showInfiniteLoadingTail, loadingTableRows, }) {
8
8
  return (_jsxs(_Fragment, { children: [filteredTopRows.length ? (_jsx("div", { className: styles.topRowWrapper, children: filteredTopRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: RowAppearance.HideToggler }, row.id))) })) : null, rowVirtualizer ? (_jsx("div", { style: {
9
9
  position: 'relative',
10
10
  height: `${rowVirtualizer.getTotalSize()}px`,
11
11
  }, children: rowVirtualizer.getVirtualItems().map(virtualRow => {
12
12
  const row = centerRows[virtualRow.index];
13
13
  return (_jsx("div", { ref: rowVirtualizer.measureElement, "data-index": virtualRow.index, className: styles.virtualRow, style: { [TABLE_CSS_VARS.virtualRowStart]: `${virtualRow.start}px` }, children: _jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }) }, row.id));
14
- }) })) : (centerRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }, row.id)))), showInfiniteLoadingTail ? (_jsx(SkeletonContextProvider, { loading: true, children: loadingTableRows.slice(0, 3).map(row => (_jsx(BodyRow, { row: row, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }, row.id))) })) : null, loadMoreButton, emptyState] }));
14
+ }) })) : (centerRows.map(row => (_jsx(BodyRow, { row: row, onRowClick: onRowClick, rowAutoHeight: rowAutoHeight, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }, row.id)))), showInfiniteLoadingTail ? (_jsx(SkeletonContextProvider, { loading: true, children: loadingTableRows.slice(0, 3).map(row => (_jsx(BodyRow, { row: row, columnOrder: columnOrder, enableColumnsOrderSortByDrag: enableColumnsOrderSortByDrag, disabledRowAppearance: rowSelectionAppearance }, row.id))) })) : null, emptyState] }));
15
15
  }
@@ -1,10 +1,17 @@
1
1
  import { Ref } from 'react';
2
- import { CardViewInput, SimpleColumnDef } from '../../columnUtils/index.js';
2
+ import { CardViewInput } from '../../columnUtils/index.js';
3
3
  import { InfiniteTableProps } from '../../components/types.js';
4
+ import { ColumnDefinition } from '../../types.js';
4
5
  /** Входные пропсы `InfiniteTable` / `useInfiniteTableProps` */
5
6
  export type InfiniteTableInput<TData extends object> = CardViewInput<TData> & {
6
7
  data: TData[];
7
- columns: SimpleColumnDef<TData>[];
8
+ /**
9
+ * Определения колонок в стандартном виде — том же, что у `Table.columnDefinitions`.
10
+ * Упрощённое описание здесь не используется: у таблиц с бесконечной подгрузкой колонки
11
+ * обычно не выражаются им (спред `getStatusColumnDef`, собственный `cell`, `id` не совпадающий
12
+ * с `accessorKey`), а `defineColumns` остаётся доступен отдельно, если он всё же нужен.
13
+ */
14
+ columns: ColumnDefinition<TData>[];
8
15
  getRowId?: (row: TData) => string;
9
16
  } & Omit<InfiniteTableProps<TData>, 'data' | 'columnDefinitions' | 'getRowId' | 'headlineId' | 'infiniteLoading' | 'scrollRef'>;
10
17
  /** Маппинг упрощённых пропсов в `InfiniteTableProps` для `Table` */
@@ -1,4 +1,4 @@
1
- import { defineColumns, mapCardViewProps } from '../../columnUtils/index.js';
1
+ import { mapCardViewProps } from '../../columnUtils/index.js';
2
2
  import { wrapGetRowId } from '../wrapGetRowId.js';
3
3
  /** Маппинг упрощённых пропсов в `InfiniteTableProps` для `Table` */
4
4
  export function toInfiniteTableProps(input, scrollRef) {
@@ -7,7 +7,7 @@ export function toInfiniteTableProps(input, scrollRef) {
7
7
  ...rest,
8
8
  ...mapCardViewProps({ headlineKey, defaultView, view, onViewChange, renderCard }),
9
9
  data,
10
- columnDefinitions: defineColumns(columns),
10
+ columnDefinitions: columns,
11
11
  infiniteLoading: true,
12
12
  outline: outline ?? true,
13
13
  enableRowVirtualization: enableRowVirtualization ?? true,
@@ -1,5 +1,4 @@
1
1
  import { useMemo } from 'react';
2
- import { defineColumns } from '../../columnUtils/index.js';
3
2
  import { wrapGetRowId } from '../wrapGetRowId.js';
4
3
  import { toInfiniteTableProps } from './toInfiniteTableProps.js';
5
4
  import { useInfiniteScrollRef } from './useInfiniteScrollRef.js';
@@ -13,11 +12,10 @@ export function useInfiniteTableProps(input) {
13
12
  dataLength: input.data.length,
14
13
  });
15
14
  const { columns, getRowId } = input;
16
- const columnDefinitions = useMemo(() => defineColumns(columns), [columns]);
17
15
  const wrappedGetRowId = useMemo(() => wrapGetRowId(getRowId), [getRowId]);
18
16
  return {
19
17
  ...toInfiniteTableProps(input, isButtonMode ? null : scrollRef),
20
- columnDefinitions,
18
+ columnDefinitions: columns,
21
19
  getRowId: wrappedGetRowId,
22
20
  };
23
21
  }