@drivenets/design-system 0.11.1 → 0.12.1

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 (49) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/index.cjs +778 -140
  3. package/dist/index.d.cts +268 -2
  4. package/dist/index.d.cts.map +1 -1
  5. package/dist/index.d.ts +268 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +774 -141
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.min.css +1 -1
  10. package/package.json +2 -1
  11. package/src/components/ds-autocomplete/ds-autocomplete.module.scss +1 -1
  12. package/src/components/ds-catalog-layout/catalog-layout-empty-illustration.tsx +57 -0
  13. package/src/components/ds-catalog-layout/ds-catalog-layout.context.ts +19 -0
  14. package/src/components/ds-catalog-layout/ds-catalog-layout.module.scss +167 -0
  15. package/src/components/ds-catalog-layout/ds-catalog-layout.tsx +130 -0
  16. package/src/components/ds-catalog-layout/ds-catalog-layout.types.ts +62 -0
  17. package/src/components/ds-catalog-layout/index.ts +9 -0
  18. package/src/components/ds-dropdown-menu/ds-dropdown-menu.module.scss +5 -0
  19. package/src/components/ds-key-value-pair/ds-key-value-pair.module.scss +0 -5
  20. package/src/components/ds-smart-tabs/ds-smart-tabs.module.scss +1 -0
  21. package/src/components/ds-status-badge/ds-status-badge.types.ts +15 -0
  22. package/src/components/ds-status-badge-v2/ds-status-badge-v2.module.scss +109 -0
  23. package/src/components/ds-status-badge-v2/ds-status-badge-v2.tsx +77 -0
  24. package/src/components/ds-status-badge-v2/ds-status-badge-v2.types.ts +79 -0
  25. package/src/components/ds-status-badge-v2/ds-status-badge-v2.unit.test.ts +25 -0
  26. package/src/components/ds-status-badge-v2/index.ts +13 -0
  27. package/src/components/ds-status-badge-v2/phase-config.ts +15 -0
  28. package/src/components/ds-table/components/ds-table-body-virtualized/ds-table-body-virtualized.tsx +16 -8
  29. package/src/components/ds-table/components/ds-table-body-virtualized/ds-table-body-virtualized.types.ts +61 -0
  30. package/src/components/ds-table/components/ds-table-body-virtualized/use-infinite-scroll.ts +54 -0
  31. package/src/components/ds-table/components/ds-table-header/ds-table-header.module.scss +4 -9
  32. package/src/components/ds-table/components/ds-table-header/ds-table-header.tsx +12 -26
  33. package/src/components/ds-table/components/ds-table-header-selectable-cell/ds-table-header-selectable-cell.tsx +22 -0
  34. package/src/components/ds-table/components/ds-table-header-selectable-cell/ds-table-header-selectable-cell.types.ts +9 -0
  35. package/src/components/ds-table/components/ds-table-header-selectable-cell/index.ts +2 -0
  36. package/src/components/ds-table/components/ds-table-row/ds-table-row.module.scss +4 -9
  37. package/src/components/ds-table/components/ds-table-row/ds-table-row.tsx +20 -15
  38. package/src/components/ds-table/components/ds-table-row-selectable-cell/ds-table-row-selectable-cell.tsx +9 -18
  39. package/src/components/ds-table/components/ds-table-row-selectable-cell/ds-table-row-selectable-cell.types.ts +2 -11
  40. package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.module.scss +3 -6
  41. package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.tsx +2 -6
  42. package/src/components/ds-table/ds-table.tsx +57 -17
  43. package/src/components/ds-table/ds-table.types.ts +27 -1
  44. package/src/components/ds-table/styles/_variables.scss +0 -1
  45. package/src/components/ds-table/styles/shared/ds-table-shared.module.scss +1 -0
  46. package/src/components/ds-table/utils/constants.ts +21 -0
  47. package/src/index.ts +2 -0
  48. package/src/styles/shared/_dropdown.scss +1 -1
  49. package/src/components/ds-table/components/ds-table-row-selectable-cell/ds-table-row-selectable-cell.module.scss +0 -6
@@ -1,26 +1,17 @@
1
1
  import type React from 'react';
2
- import { TableCell } from '../core-table';
3
2
  import { DsCheckbox } from '../../../ds-checkbox';
4
3
  import stylesShared from '../../styles/shared/ds-table-shared.module.scss';
5
4
  import type { DsTableRowSelectableCellProps } from './ds-table-row-selectable-cell.types';
6
- import classnames from 'classnames';
7
- import styles from './ds-table-row-selectable-cell.module.scss';
8
5
 
9
- export const DsTableRowSelectableCell = <TData,>({
10
- row,
11
- isSelected,
12
- className,
13
- }: DsTableRowSelectableCellProps<TData>) => {
6
+ export const DsTableRowSelectableCell = <TData,>({ row }: DsTableRowSelectableCellProps<TData>) => {
14
7
  return (
15
- <TableCell className={classnames(styles.cell, className)}>
16
- <DsCheckbox
17
- className={stylesShared.checkboxContainer}
18
- checked={isSelected}
19
- disabled={!row.getCanSelect()}
20
- onCheckedChange={(checked) => row.toggleSelected(!!checked)}
21
- onClick={(e) => e.stopPropagation()}
22
- onDoubleClick={(e: React.MouseEvent) => e.stopPropagation()}
23
- />
24
- </TableCell>
8
+ <DsCheckbox
9
+ className={stylesShared.checkboxContainer}
10
+ checked={row.getIsSelected()}
11
+ disabled={!row.getCanSelect()}
12
+ onCheckedChange={(checked) => row.toggleSelected(!!checked)}
13
+ onClick={(e) => e.stopPropagation()}
14
+ onDoubleClick={(e: React.MouseEvent) => e.stopPropagation()}
15
+ />
25
16
  );
26
17
  };
@@ -2,17 +2,8 @@ import type { Row } from '@tanstack/react-table';
2
2
 
3
3
  export interface DsTableRowSelectableCellProps<TData> {
4
4
  /**
5
- * TanStack Table row model for the parent row. Used to toggle the row's
6
- * selection state when the checkbox is clicked.
5
+ * TanStack Table row model for the parent row. Used to read the row's
6
+ * selection state and toggle it when the checkbox is clicked.
7
7
  */
8
8
  row: Row<TData>;
9
- /**
10
- * Whether the parent row is currently selected. Drives the checkbox's
11
- * checked state.
12
- */
13
- isSelected: boolean;
14
- /**
15
- * Additional CSS class name applied to the cell element.
16
- */
17
- className?: string;
18
9
  }
@@ -52,19 +52,16 @@
52
52
  }
53
53
  }
54
54
 
55
- .cell,
56
- .selectableCell {
55
+ .cell {
57
56
  display: flex;
58
57
  align-items: center;
59
58
  @include typography.body-sm-reg;
60
59
  color: var(--font-main);
61
- }
62
-
63
- .cell {
64
60
  padding: 0 var(--standard);
65
61
  }
66
62
 
67
- .expandableCell {
63
+ .expandableCell,
64
+ .selectableCell {
68
65
  padding: 0;
69
66
  justify-content: center;
70
67
  }
@@ -3,10 +3,9 @@ import styles from './ds-table-row-virtualized.module.scss';
3
3
  import { useDsTableContext } from '../../context/ds-table-context';
4
4
  import { getColumnSizeStyle } from '../../utils/column-size';
5
5
  import { TableCell, TableRow } from '../core-table';
6
- import { DsTableRowSelectableCell } from '../ds-table-row-selectable-cell';
7
6
  import type { DsTableRowVirtualizedProps } from './ds-table-row-virtualized.types';
8
7
  import { DsTableCell } from '../ds-table-cell';
9
- import { EXPANDER_COLUMN_ID } from '../../utils/constants';
8
+ import { EXPANDER_COLUMN_ID, SELECT_COLUMN_ID } from '../../utils/constants';
10
9
 
11
10
  export const DsTableRowVirtualized = <TData,>({
12
11
  row,
@@ -18,7 +17,6 @@ export const DsTableRowVirtualized = <TData,>({
18
17
  isExpandedRowContent,
19
18
  }: DsTableRowVirtualizedProps<TData>) => {
20
19
  const {
21
- selectable,
22
20
  bordered,
23
21
  rowSize,
24
22
  activeRowId,
@@ -67,9 +65,6 @@ export const DsTableRowVirtualized = <TData,>({
67
65
  <TableCell>{renderExpandedRow?.(row.original)}</TableCell>
68
66
  ) : (
69
67
  <>
70
- {selectable && (
71
- <DsTableRowSelectableCell row={row} isSelected={isSelected} className={styles.selectableCell} />
72
- )}
73
68
  {row.getVisibleCells().map((cell, idx) => {
74
69
  const isLastColumn = idx === row.getVisibleCells().length - 1;
75
70
  const cellStyle = getColumnSizeStyle(cell.column.getSize(), true);
@@ -81,6 +76,7 @@ export const DsTableRowVirtualized = <TData,>({
81
76
  className={classnames(
82
77
  styles.cell,
83
78
  cell.column.id === EXPANDER_COLUMN_ID && styles.expandableCell,
79
+ cell.column.id === SELECT_COLUMN_ID && styles.selectableCell,
84
80
  )}
85
81
  >
86
82
  {isLastColumn ? (
@@ -20,10 +20,20 @@ import styles from './ds-table.module.scss';
20
20
  import type { DsDataTableProps, DsTableRowSize } from './ds-table.types';
21
21
  import { DsTableRow } from './components/ds-table-row';
22
22
  import { DsTableRowExpandableCell } from './components/ds-table-row-expandable-cell';
23
+ import { DsTableRowSelectableCell } from './components/ds-table-row-selectable-cell';
24
+ import { DsTableHeaderSelectableCell } from './components/ds-table-header-selectable-cell';
23
25
  import { useDragAndDrop } from './hooks/use-drag-and-drop';
24
26
  import { type DsTableContextType, DsTableContext } from './context/ds-table-context';
25
27
  import { DsTableBodyVirtualized } from './components/ds-table-body-virtualized';
26
- import { EMPTY_TABLE_STATE_TEXT, EXPANDER_COLUMN_ID, EXPANDER_COLUMN_WIDTH } from './utils/constants';
28
+ import {
29
+ EMPTY_TABLE_STATE_TEXT,
30
+ EXPANDER_COLUMN_ID,
31
+ EXPANDER_COLUMN_WIDTH,
32
+ REORDER_COLUMN_ID,
33
+ REORDER_COLUMN_WIDTH,
34
+ SELECT_COLUMN_ID,
35
+ SELECT_COLUMN_WIDTH,
36
+ } from './utils/constants';
27
37
 
28
38
  // Row size to pixel height mapping (matches CSS variables)
29
39
  const ROW_SIZE_HEIGHT_MAP: Record<DsTableRowSize, number> = {
@@ -66,6 +76,7 @@ const DsTable = <TData extends { id: string }, TValue>({
66
76
  columnVisibility: externalColumnVisibility,
67
77
  onColumnVisibilityChange,
68
78
  activeRowId,
79
+ infiniteScroll,
69
80
  }: DsDataTableProps<TData, TValue>) => {
70
81
  const [data, setData] = React.useState(tableData);
71
82
  const [sorting, setSorting] = React.useState<SortingState>([]);
@@ -125,22 +136,53 @@ const DsTable = <TData extends { id: string }, TValue>({
125
136
  onSelectionChange?.(newRowSelection);
126
137
  };
127
138
 
139
+ const hasExpanderColumn = !!expandable;
140
+ const hasSelectColumn = !!selectable;
141
+ const hasReorderColumn = reorderable && !virtualized;
142
+
128
143
  const columns = useMemo<ColumnDef<TData, TValue>[]>(() => {
129
- if (!expandable) {
130
- return columnsProp;
144
+ const augmentedColumns: ColumnDef<TData, TValue>[] = [...columnsProp];
145
+
146
+ if (hasSelectColumn) {
147
+ const selectColumn: ColumnDef<TData, TValue> = {
148
+ id: SELECT_COLUMN_ID,
149
+ size: SELECT_COLUMN_WIDTH,
150
+ enableSorting: false,
151
+ enableResizing: false,
152
+ header: ({ table }) => (showSelectAllCheckbox ? <DsTableHeaderSelectableCell table={table} /> : null),
153
+ cell: ({ row }) => <DsTableRowSelectableCell row={row} />,
154
+ };
155
+ augmentedColumns.unshift(selectColumn);
131
156
  }
132
157
 
133
- const expanderColumn: ColumnDef<TData, TValue> = {
134
- id: EXPANDER_COLUMN_ID,
135
- size: EXPANDER_COLUMN_WIDTH,
136
- enableSorting: false,
137
- enableResizing: false,
138
- header: () => null,
139
- cell: ({ row }) => (row.getCanExpand() ? <DsTableRowExpandableCell row={row} /> : null),
140
- };
158
+ if (hasExpanderColumn) {
159
+ const expanderColumn: ColumnDef<TData, TValue> = {
160
+ id: EXPANDER_COLUMN_ID,
161
+ size: EXPANDER_COLUMN_WIDTH,
162
+ enableSorting: false,
163
+ enableResizing: false,
164
+ header: () => null,
165
+ cell: ({ row }) => (row.getCanExpand() ? <DsTableRowExpandableCell row={row} /> : null),
166
+ };
167
+ augmentedColumns.unshift(expanderColumn);
168
+ }
141
169
 
142
- return [expanderColumn, ...columnsProp];
143
- }, [columnsProp, expandable]);
170
+ if (hasReorderColumn) {
171
+ // Cell is rendered inline by DsTableRow when it encounters REORDER_COLUMN_ID,
172
+ // since the drag handle needs row-level useSortable state.
173
+ const reorderColumn: ColumnDef<TData, TValue> = {
174
+ id: REORDER_COLUMN_ID,
175
+ size: REORDER_COLUMN_WIDTH,
176
+ enableSorting: false,
177
+ enableResizing: false,
178
+ header: 'Order',
179
+ cell: () => null,
180
+ };
181
+ augmentedColumns.unshift(reorderColumn);
182
+ }
183
+
184
+ return augmentedColumns;
185
+ }, [columnsProp, hasExpanderColumn, hasReorderColumn, hasSelectColumn, showSelectAllCheckbox]);
144
186
 
145
187
  const table = useReactTable({
146
188
  data: reorderable ? data : tableData,
@@ -212,10 +254,7 @@ const DsTable = <TData extends { id: string }, TValue>({
212
254
 
213
255
  const renderEmptyState = () => (
214
256
  <TableRow>
215
- <TableCell
216
- colSpan={columns.length + (selectable ? 1 : 0) + (reorderable ? 1 : 0)}
217
- className={styles.emptyState}
218
- >
257
+ <TableCell colSpan={columns.length} className={styles.emptyState}>
219
258
  {emptyState || EMPTY_TABLE_STATE_TEXT}
220
259
  </TableCell>
221
260
  </TableRow>
@@ -276,6 +315,7 @@ const DsTable = <TData extends { id: string }, TValue>({
276
315
  overscan={virtualizedOptions?.overscan}
277
316
  onScroll={onScroll}
278
317
  rowSelection={rowSelection}
318
+ infiniteScroll={infiniteScroll}
279
319
  />
280
320
  ) : (
281
321
  <TableBody>
@@ -8,7 +8,7 @@ import type {
8
8
  } from '@tanstack/react-table';
9
9
  import type { IconType } from '../ds-icon';
10
10
  import type { RowAction, SecondaryRowAction } from './components/ds-table-cell';
11
- import type { ScrollParams } from './components/ds-table-body-virtualized';
11
+ import type { InfiniteScrollConfig, ScrollParams } from './components/ds-table-body-virtualized';
12
12
 
13
13
  /**
14
14
  * Row size variants based on Figma design specifications
@@ -164,6 +164,8 @@ export interface DsTableApi<TData> {
164
164
  expandRows: (rowIds: string[]) => void;
165
165
  }
166
166
 
167
+ export type { InfiniteScrollConfig } from './components/ds-table-body-virtualized';
168
+
167
169
  /**
168
170
  * Represents a bulk action that can be performed on multiple selected rows
169
171
  */
@@ -357,6 +359,30 @@ export interface DsDataTableProps<TData, TValue> {
357
359
  */
358
360
  onScroll?: (params: ScrollParams) => void;
359
361
 
362
+ /**
363
+ * Configures infinite scroll for the virtualized table. The Table owns viewport/scroll
364
+ * detection and the auto-fill loop; the consumer owns fetching, pagination state,
365
+ * error handling, and retry.
366
+ *
367
+ * Only takes effect when `virtualized` is `true`. Passing this prop without
368
+ * `virtualized` is ignored.
369
+ *
370
+ * @example
371
+ * ```tsx
372
+ * <DsTable
373
+ * virtualized
374
+ * data={rows}
375
+ * columns={columns}
376
+ * infiniteScroll={{
377
+ * hasMore,
378
+ * isLoadingMore,
379
+ * onLoadMore: fetchNextPage,
380
+ * }}
381
+ * />
382
+ * ```
383
+ */
384
+ infiniteScroll?: InfiniteScrollConfig;
385
+
360
386
  /**
361
387
  * Actions to be shown in the bulk actions
362
388
  */
@@ -1,7 +1,6 @@
1
1
  $border-radius: 4px;
2
2
  $border-width: 1px;
3
3
  $virtualized-height: 600px;
4
- $select-column-width: 36px;
5
4
  $reorder-column-width: 60px;
6
5
  $container-margin-vertical: 1rem;
7
6
  $filter-input-gap: 0.5rem;
@@ -8,6 +8,7 @@
8
8
  width: fit-content;
9
9
  margin: auto;
10
10
  height: 100%;
11
+ vertical-align: middle;
11
12
  }
12
13
 
13
14
  .pageButtonIcon {
@@ -12,3 +12,24 @@ export const EXPANDER_COLUMN_ID = 'expander';
12
12
  * Width (in px) of the expander column.
13
13
  */
14
14
  export const EXPANDER_COLUMN_WIDTH = 36;
15
+
16
+ /**
17
+ * Column id used for the synthetic selection column injected when `selectable` is set.
18
+ */
19
+ export const SELECT_COLUMN_ID = 'select';
20
+
21
+ /**
22
+ * Width (in px) of the selection column.
23
+ */
24
+ export const SELECT_COLUMN_WIDTH = 36;
25
+
26
+ /**
27
+ * Column id used for the synthetic reorder column injected when `reorderable` is set
28
+ * (non-virtualized tables only).
29
+ */
30
+ export const REORDER_COLUMN_ID = 'reorder';
31
+
32
+ /**
33
+ * Width (in px) of the reorder column.
34
+ */
35
+ export const REORDER_COLUMN_WIDTH = 60;
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from './components/ds-breadcrumb';
6
6
  export * from './components/ds-button';
7
7
  export * from './components/ds-button-v3';
8
8
  export * from './components/ds-card';
9
+ export * from './components/ds-catalog-layout';
9
10
  export * from './components/ds-checkbox';
10
11
  export * from './components/ds-checkbox-group';
11
12
  export * from './components/ds-chip';
@@ -47,6 +48,7 @@ export * from './components/ds-spinner';
47
48
  export * from './components/ds-split-button';
48
49
  export * from './components/ds-stack';
49
50
  export * from './components/ds-status-badge';
51
+ export * from './components/ds-status-badge-v2';
50
52
  export * from './components/ds-stepper';
51
53
  export * from './components/ds-system-status';
52
54
  export * from './components/ds-table';
@@ -64,7 +64,7 @@ $dropdown-z-index: 9999;
64
64
  gap: 10px;
65
65
  color: var(--font-main);
66
66
  font-size: var(--body-font-size-sm);
67
- padding: var(--xs);
67
+ padding: var(--xs) var(--sm) var(--xs) var(--xs);
68
68
  border-radius: 2px;
69
69
  border-left: 2px solid transparent;
70
70
  cursor: pointer;
@@ -1,6 +0,0 @@
1
- @use '../../styles/variables' as vars;
2
-
3
- .cell {
4
- width: vars.$select-column-width;
5
- padding: 0;
6
- }