@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/CHANGELOG.md +6 -0
- package/dist/index.cjs +177 -171
- package/dist/index.d.cts +93 -93
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +93 -93
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +177 -171
- package/dist/index.js.map +1 -1
- package/dist/index.min.css +1 -1
- package/package.json +14 -14
- package/src/components/ds-table/components/ds-table-body-virtualized/ds-table-body-virtualized.tsx +10 -5
- package/src/components/ds-table/components/ds-table-body-virtualized/ds-table-body-virtualized.types.ts +5 -3
- package/src/components/ds-table/components/ds-table-row/ds-table-row.tsx +5 -3
- package/src/components/ds-table/components/ds-table-row/ds-table-row.types.ts +4 -0
- package/src/components/ds-table/components/ds-table-row-selectable-cell/ds-table-row-selectable-cell.tsx +2 -1
- package/src/components/ds-table/components/ds-table-row-selectable-cell/ds-table-row-selectable-cell.types.ts +1 -0
- package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.tsx +5 -2
- package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.types.ts +4 -2
- package/src/components/ds-table/ds-table.tsx +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drivenets/design-system",
|
|
3
|
-
"version": "0.7.
|
|
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.
|
|
72
|
-
"@storybook/addon-docs": "^10.2.
|
|
73
|
-
"@storybook/addon-vitest": "^10.2.
|
|
74
|
-
"@storybook/builder-vite": "^10.2.
|
|
75
|
-
"@storybook/react-vite": "^10.2.
|
|
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
|
|
82
|
-
"@vitest/browser-playwright": "^4.0
|
|
83
|
-
"@vitest/coverage-v8": "^4.0
|
|
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.
|
|
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.
|
|
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": "^
|
|
106
|
-
"vitest": "^4.0
|
|
107
|
-
"vitest-browser-react": "^2.0
|
|
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"
|
package/src/components/ds-table/components/ds-table-body-virtualized/ds-table-body-virtualized.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type
|
|
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:
|
|
92
|
-
rowHeightsMapRef:
|
|
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?:
|
|
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
|
|
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:
|
|
6
|
-
emptyState?:
|
|
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' :
|
|
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 &&
|
|
99
|
+
{selectable && (
|
|
100
|
+
<DsTableRowSelectableCell row={row} isSelected={isSelected} className={styles.selectableCell} />
|
|
101
|
+
)}
|
|
100
102
|
{expandable && (
|
|
101
103
|
<DsTableRowExpandableCell
|
|
102
104
|
row={row}
|
|
@@ -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={
|
|
18
|
+
checked={isSelected}
|
|
18
19
|
disabled={!row.getCanSelect()}
|
|
19
20
|
onClick={(e) => {
|
|
20
21
|
e.stopPropagation();
|
package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.tsx
CHANGED
|
@@ -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' :
|
|
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 &&
|
|
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
|
-
|
|
7
|
-
|
|
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) =>
|
|
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>
|