@drivenets/design-system 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drivenets/design-system",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.cts",
@@ -68,25 +68,25 @@
68
68
  "@faker-js/faker": "^10.3.0",
69
69
  "@hookform/resolvers": "^5.2.2",
70
70
  "@rollup/plugin-babel": "^7.0.0",
71
- "@storybook/addon-a11y": "^10.2.16",
72
- "@storybook/addon-docs": "^10.2.16",
73
- "@storybook/addon-vitest": "^10.2.16",
74
- "@storybook/builder-vite": "^10.2.16",
75
- "@storybook/react-vite": "^10.2.16",
71
+ "@storybook/addon-a11y": "^10.2.19",
72
+ "@storybook/addon-docs": "^10.2.19",
73
+ "@storybook/addon-vitest": "^10.2.19",
74
+ "@storybook/builder-vite": "^10.2.19",
75
+ "@storybook/react-vite": "^10.2.19",
76
76
  "@tanstack/react-query": "^5.90.21",
77
77
  "@tanstack/react-router": "^1.166.2",
78
78
  "@types/eslint-plugin-jsx-a11y": "^6.10.1",
79
79
  "@types/react": "^19.2.14",
80
80
  "@types/react-dom": "^19.2.3",
81
- "@vitejs/plugin-react-swc": "^4.2.3",
82
- "@vitest/browser-playwright": "^4.0.18",
83
- "@vitest/coverage-v8": "^4.0.18",
81
+ "@vitejs/plugin-react": "^6.0.1",
82
+ "@vitest/browser-playwright": "^4.1.0",
83
+ "@vitest/coverage-v8": "^4.1.0",
84
84
  "babel-plugin-react-compiler": "^1.0.0",
85
85
  "eslint": "^10.0.1",
86
86
  "eslint-plugin-jsx-a11y": "^6.10.2",
87
87
  "eslint-plugin-react": "^7.37.5",
88
88
  "eslint-plugin-react-hooks": "^7.0.1",
89
- "eslint-plugin-storybook": "^10.2.16",
89
+ "eslint-plugin-storybook": "^10.2.19",
90
90
  "mockdate": "^3.0.5",
91
91
  "playwright": "^1.58.2",
92
92
  "postcss": "^8.5.8",
@@ -97,14 +97,14 @@
97
97
  "react-hook-form": "^7.71.2",
98
98
  "rollup-plugin-sass": "^1.15.3",
99
99
  "sass-embedded": "^1.97.3",
100
- "storybook": "^10.2.16",
100
+ "storybook": "^10.2.19",
101
101
  "tsdown": "^0.21.0",
102
102
  "typed-scss-modules": "^8.1.1",
103
103
  "typescript": "^5.9.3",
104
104
  "typescript-plugin-css-modules": "^5.2.0",
105
- "vite": "^7.3.1",
106
- "vitest": "^4.0.18",
107
- "vitest-browser-react": "^2.0.5",
105
+ "vite": "^8.0.0",
106
+ "vitest": "^4.1.0",
107
+ "vitest-browser-react": "^2.1.0",
108
108
  "zod": "^4.3.6",
109
109
  "@drivenets/eslint-plugin-internal": "0.0.0",
110
110
  "@drivenets/vite-plugin-design-system": "0.0.6"
@@ -1,6 +1,6 @@
1
- import { type Row } from '@tanstack/react-table';
1
+ import { useLayoutEffect, useRef, type RefObject, type ReactNode } from 'react';
2
+ import { type Row, type RowSelectionState } from '@tanstack/react-table';
2
3
  import { useVirtualizer, type Virtualizer } from '@tanstack/react-virtual';
3
- import { useLayoutEffect, useRef } from 'react';
4
4
  import styles from './ds-table-body-virtualized.module.scss';
5
5
  import { DsTableRowVirtualized } from '../ds-table-row-virtualized';
6
6
  import type { DsTableBodyVirtualizedProps } from './ds-table-body-virtualized.types';
@@ -14,6 +14,7 @@ export const DsTableBodyVirtualized = <TData,>({
14
14
  estimateSize,
15
15
  overscan,
16
16
  onScroll,
17
+ rowSelection,
17
18
  }: DsTableBodyVirtualizedProps<TData>) => {
18
19
  const rowsMapRef = useRef<Map<string, HTMLTableRowElement>>(new Map());
19
20
  const rowHeightsMapRef = useRef<Map<string, number>>(new Map());
@@ -82,19 +83,21 @@ export const DsTableBodyVirtualized = <TData,>({
82
83
  rowVirtualizer={rowVirtualizer}
83
84
  rowsAndExpandedRowContent={rowsAndExpandedRowContent}
84
85
  emptyState={emptyState}
86
+ rowSelection={rowSelection}
85
87
  />
86
88
  );
87
89
  };
88
90
 
89
91
  interface DsTableBodyProps<TData> {
90
92
  rowVirtualizer: Virtualizer<HTMLDivElement, HTMLTableRowElement>;
91
- rowsMapRef: React.RefObject<Map<string, HTMLTableRowElement>>;
92
- rowHeightsMapRef: React.RefObject<Map<string, number>>;
93
+ rowsMapRef: RefObject<Map<string, HTMLTableRowElement>>;
94
+ rowHeightsMapRef: RefObject<Map<string, number>>;
93
95
  rowsAndExpandedRowContent: {
94
96
  row: Row<TData>;
95
97
  isExpandedRowContent?: boolean;
96
98
  }[];
97
- emptyState?: React.ReactNode;
99
+ emptyState?: ReactNode;
100
+ rowSelection: RowSelectionState;
98
101
  }
99
102
 
100
103
  function DsTableBody<TData>({
@@ -103,6 +106,7 @@ function DsTableBody<TData>({
103
106
  rowHeightsMapRef,
104
107
  rowsAndExpandedRowContent,
105
108
  emptyState,
109
+ rowSelection,
106
110
  }: DsTableBodyProps<TData>) {
107
111
  const virtualRows = rowVirtualizer.getVirtualItems();
108
112
 
@@ -124,6 +128,7 @@ function DsTableBody<TData>({
124
128
  <DsTableRowVirtualized
125
129
  key={virtualRow.key}
126
130
  row={row.row}
131
+ isSelected={!!rowSelection[row.row.id]}
127
132
  isExpandedRowContent={row.isExpandedRowContent}
128
133
  rowsMapRef={rowsMapRef}
129
134
  rowHeightsMapRef={rowHeightsMapRef}
@@ -1,12 +1,14 @@
1
- import type { Table } from '@tanstack/react-table';
1
+ import { type RefObject, type ReactNode } from 'react';
2
+ import { type RowSelectionState, type Table } from '@tanstack/react-table';
2
3
 
3
4
  export interface DsTableBodyVirtualizedProps<TData> {
4
5
  table: Table<TData>;
5
- tableContainerRef: React.RefObject<HTMLDivElement | null>;
6
- emptyState?: React.ReactNode;
6
+ tableContainerRef: RefObject<HTMLDivElement | null>;
7
+ emptyState?: ReactNode;
7
8
  estimateSize: number;
8
9
  overscan?: number;
9
10
  onScroll?: (params: ScrollParams) => void;
11
+ rowSelection: RowSelectionState;
10
12
  }
11
13
 
12
14
  /**
@@ -38,7 +38,7 @@ const DsRowDragHandle = ({ isDragging, attributes, listeners }: DsRowDragHandleP
38
38
  );
39
39
  };
40
40
 
41
- const DsTableRow = <TData,>({ ref, row }: DsTableRowProps<TData>) => {
41
+ const DsTableRow = <TData,>({ ref, row, isSelected }: DsTableRowProps<TData>) => {
42
42
  const {
43
43
  expandable,
44
44
  selectable,
@@ -80,7 +80,7 @@ const DsTableRow = <TData,>({ ref, row }: DsTableRowProps<TData>) => {
80
80
  <>
81
81
  <TableRow
82
82
  ref={mergeRefs(reorderable ? setNodeRef : null, ref)}
83
- data-state={isActive ? 'active' : row.getIsSelected() ? 'selected' : undefined}
83
+ data-state={isActive ? 'active' : isSelected ? 'selected' : undefined}
84
84
  className={classnames(
85
85
  styles.tableRow,
86
86
  {
@@ -96,7 +96,9 @@ const DsTableRow = <TData,>({ ref, row }: DsTableRowProps<TData>) => {
96
96
  onClick={() => onRowClick?.(row.original)}
97
97
  onDoubleClick={() => onRowDoubleClick?.(row.original)}
98
98
  >
99
- {selectable && <DsTableRowSelectableCell row={row} className={styles.selectableCell} />}
99
+ {selectable && (
100
+ <DsTableRowSelectableCell row={row} isSelected={isSelected} className={styles.selectableCell} />
101
+ )}
100
102
  {expandable && (
101
103
  <DsTableRowExpandableCell
102
104
  row={row}
@@ -13,4 +13,8 @@ export interface DsTableRowProps<TData> {
13
13
  * The row data from the table
14
14
  */
15
15
  row: Row<TData>;
16
+ /**
17
+ * Indicates whether a row is currently selected.
18
+ */
19
+ isSelected: boolean;
16
20
  }
@@ -8,13 +8,14 @@ import styles from './ds-table-row-selectable-cell.module.scss';
8
8
 
9
9
  export const DsTableRowSelectableCell = <TData,>({
10
10
  row,
11
+ isSelected,
11
12
  className,
12
13
  }: DsTableRowSelectableCellProps<TData>) => {
13
14
  return (
14
15
  <TableCell className={classnames(styles.cell, className)}>
15
16
  <DsCheckbox
16
17
  className={stylesShared.checkboxContainer}
17
- checked={row.getIsSelected()}
18
+ checked={isSelected}
18
19
  disabled={!row.getCanSelect()}
19
20
  onClick={(e) => {
20
21
  e.stopPropagation();
@@ -2,5 +2,6 @@ import type { Row } from '@tanstack/react-table';
2
2
 
3
3
  export interface DsTableRowSelectableCellProps<TData> {
4
4
  row: Row<TData>;
5
+ isSelected: boolean;
5
6
  className?: string;
6
7
  }
@@ -10,6 +10,7 @@ import { DsTableCell } from '../ds-table-cell';
10
10
 
11
11
  export const DsTableRowVirtualized = <TData,>({
12
12
  row,
13
+ isSelected,
13
14
  rowsMapRef,
14
15
  rowHeightsMapRef,
15
16
  rowVirtualizer,
@@ -47,7 +48,7 @@ export const DsTableRowVirtualized = <TData,>({
47
48
  rowsMapRef.current.delete(key);
48
49
  }
49
50
  }}
50
- data-state={isActive ? 'active' : row.getIsSelected() ? 'selected' : undefined}
51
+ data-state={isActive ? 'active' : isSelected ? 'selected' : undefined}
51
52
  className={classnames(
52
53
  styles.row,
53
54
  {
@@ -67,7 +68,9 @@ export const DsTableRowVirtualized = <TData,>({
67
68
  <TableCell>{renderExpandedRow?.(row.original)}</TableCell>
68
69
  ) : (
69
70
  <>
70
- {selectable && <DsTableRowSelectableCell row={row} className={styles.selectableCell} />}
71
+ {selectable && (
72
+ <DsTableRowSelectableCell row={row} isSelected={isSelected} className={styles.selectableCell} />
73
+ )}
71
74
  {expandable && <DsTableRowExpandableCell row={row} className={styles.expandableCell} />}
72
75
  {row.getVisibleCells().map((cell, idx) => {
73
76
  const isLastColumn = idx === row.getVisibleCells().length - 1;
@@ -1,10 +1,12 @@
1
+ import { type RefObject } from 'react';
1
2
  import { type Row } from '@tanstack/react-table';
2
3
  import { type VirtualItem, type Virtualizer } from '@tanstack/react-virtual';
3
4
 
4
5
  export interface DsTableRowVirtualizedProps<TData> {
5
6
  row: Row<TData>;
6
- rowsMapRef: React.RefObject<Map<string, HTMLTableRowElement>>;
7
- rowHeightsMapRef: React.RefObject<Map<string, number>>;
7
+ isSelected: boolean;
8
+ rowsMapRef: RefObject<Map<string, HTMLTableRowElement>>;
9
+ rowHeightsMapRef: RefObject<Map<string, number>>;
8
10
  rowVirtualizer: Virtualizer<HTMLDivElement, HTMLTableRowElement>;
9
11
  virtualRow: VirtualItem;
10
12
  isExpandedRowContent?: boolean;
@@ -250,12 +250,15 @@ const DsTable = <TData extends { id: string }, TValue>({
250
250
  estimateSize={virtualizedOptions?.estimateSize || ROW_SIZE_HEIGHT_MAP[rowSize]}
251
251
  overscan={virtualizedOptions?.overscan}
252
252
  onScroll={onScroll}
253
+ rowSelection={rowSelection}
253
254
  />
254
255
  ) : (
255
256
  <TableBody>
256
257
  <SortableWrapper>
257
258
  {rows.length
258
- ? rows.map((row) => <DsTableRow key={row.id} row={row} />)
259
+ ? rows.map((row) => (
260
+ <DsTableRow key={row.id} row={row} isSelected={!!rowSelection[row.id]} />
261
+ ))
259
262
  : renderEmptyState()}
260
263
  </SortableWrapper>
261
264
  </TableBody>