@drivenets/design-system 0.17.0 → 0.18.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 (94) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/index.cjs +1727 -701
  3. package/dist/index.d.cts +115 -52
  4. package/dist/index.d.cts.map +1 -1
  5. package/dist/index.d.ts +115 -52
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +1729 -705
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.min.css +1 -1
  10. package/package.json +2 -2
  11. package/src/components/ds-alert-banner/ds-alert-banner-global.figma.ts +49 -0
  12. package/src/components/ds-alert-banner/ds-alert-banner.figma.ts +51 -0
  13. package/src/components/ds-autocomplete/ds-autocomplete.module.scss +15 -4
  14. package/src/components/ds-autocomplete/ds-autocomplete.tsx +10 -3
  15. package/src/components/ds-autocomplete/ds-autocomplete.types.ts +8 -0
  16. package/src/components/ds-button-v3/ds-button-v3.figma.ts +5 -3
  17. package/src/components/ds-button-v3/ds-button-v3.module.scss +84 -17
  18. package/src/components/ds-button-v3/ds-button-v3.tsx +2 -0
  19. package/src/components/ds-button-v3/ds-button-v3.types.ts +11 -2
  20. package/src/components/ds-button-v3/ds-button-v4.figma.ts +121 -0
  21. package/src/components/ds-comment-bubble/ds-comment-bubble.figma.ts +52 -0
  22. package/src/components/ds-comment-card/ds-comment-card.figma.ts +36 -0
  23. package/src/components/ds-comment-indicator/ds-comment-indicator.figma.ts +32 -0
  24. package/src/components/ds-comments-drawer/ds-comments-drawer.figma.ts +19 -0
  25. package/src/components/ds-select/ds-select.figma.ts +2 -1
  26. package/src/components/ds-select/ds-select.tsx +6 -1
  27. package/src/components/ds-select/ds-select.types.ts +2 -1
  28. package/src/components/ds-slider/ds-slider.figma.ts +29 -0
  29. package/src/components/ds-slider/ds-slider.module.scss +104 -0
  30. package/src/components/ds-slider/ds-slider.tsx +118 -0
  31. package/src/components/ds-slider/ds-slider.types.ts +102 -0
  32. package/src/components/ds-slider/ds-slider.utils.ts +14 -0
  33. package/src/components/ds-slider/index.ts +11 -0
  34. package/src/components/ds-smart-tabs/figma/ds-smart-tabs-tab.figma.ts +83 -0
  35. package/src/components/ds-smart-tabs/figma/ds-smart-tabs.figma.ts +23 -0
  36. package/src/components/ds-table/components/ds-table-group-header-cell/ds-table-group-header-cell.module.scss +5 -1
  37. package/src/components/ds-table/components/ds-table-group-header-cell/ds-table-group-header-cell.tsx +15 -3
  38. package/src/components/ds-table/components/ds-table-header/ds-table-header.module.scss +15 -1
  39. package/src/components/ds-table/components/ds-table-header/ds-table-header.tsx +29 -6
  40. package/src/components/ds-table/components/ds-table-resize-handle/ds-table-resize-handle.module.scss +23 -0
  41. package/src/components/ds-table/components/ds-table-resize-handle/ds-table-resize-handle.tsx +218 -0
  42. package/src/components/ds-table/components/ds-table-resize-handle/ds-table-resize-handle.types.ts +14 -0
  43. package/src/components/ds-table/components/ds-table-resize-handle/index.ts +1 -0
  44. package/src/components/ds-table/components/ds-table-resize-overlay/ds-table-resize-overlay.module.scss +18 -0
  45. package/src/components/ds-table/components/ds-table-resize-overlay/ds-table-resize-overlay.tsx +16 -0
  46. package/src/components/ds-table/components/ds-table-resize-overlay/ds-table-resize-overlay.types.ts +13 -0
  47. package/src/components/ds-table/components/ds-table-resize-overlay/index.ts +1 -0
  48. package/src/components/ds-table/components/ds-table-row/ds-table-row.module.scss +1 -1
  49. package/src/components/ds-table/components/ds-table-row/ds-table-row.tsx +9 -2
  50. package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.module.scss +2 -1
  51. package/src/components/ds-table/components/ds-table-row-virtualized/ds-table-row-virtualized.tsx +9 -2
  52. package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-checkbox.tsx +2 -2
  53. package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-date.tsx +2 -1
  54. package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-number.tsx +2 -1
  55. package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-select.tsx +2 -1
  56. package/src/components/ds-table/components/edit/cell-editors/ds-table-edit-cell-text.tsx +2 -1
  57. package/src/components/ds-table/components/edit/ds-table-editing-cell/ds-table-editing-cell.tsx +12 -3
  58. package/src/components/ds-table/context/ds-table-context.tsx +208 -0
  59. package/src/components/ds-table/ds-table-defaults.ts +42 -0
  60. package/src/components/ds-table/ds-table.module.scss +4 -1
  61. package/src/components/ds-table/ds-table.tsx +139 -214
  62. package/src/components/ds-table/ds-table.types.ts +53 -47
  63. package/src/components/ds-table/grouping/utils/column-group.ts +7 -5
  64. package/src/components/ds-table/hooks/use-cell-editor.ts +5 -1
  65. package/src/components/ds-table/hooks/use-column-resize.ts +385 -0
  66. package/src/components/ds-table/hooks/use-editing-state.ts +190 -0
  67. package/src/components/ds-table/index.ts +1 -0
  68. package/src/components/ds-table/styles/_variables.scss +2 -1
  69. package/src/components/ds-table/utils/column-size-meta.augmentation.ts +16 -0
  70. package/src/components/ds-table/utils/column-size.ts +213 -10
  71. package/src/components/ds-table/utils/column-size.unit.test.ts +213 -0
  72. package/src/components/ds-table/utils/constants.ts +28 -0
  73. package/src/components/ds-table/utils/frozen-body.ts +33 -0
  74. package/src/components/ds-table/utils/frozen-body.unit.test.ts +44 -0
  75. package/src/components/ds-table/utils/table-api.ts +42 -0
  76. package/src/components/ds-table/utils/table-api.unit.test.ts +82 -0
  77. package/src/components/ds-table/utils/table-columns.tsx +119 -0
  78. package/src/components/ds-table/utils/table-columns.unit.test.ts +199 -0
  79. package/src/components/ds-tag/ds-tag.figma.ts +51 -0
  80. package/src/components/ds-tag-filter/ds-tag-filter.figma.ts +16 -0
  81. package/src/components/ds-text-input/ds-input-field-v02.figma.ts +29 -4
  82. package/src/components/ds-text-input/ds-text-input.figma.ts +3 -2
  83. package/src/components/ds-text-input/ds-text-input.tsx +1 -0
  84. package/src/components/ds-text-input/ds-text-input.types.ts +1 -1
  85. package/src/components/ds-tree/ds-tree.figma.ts +54 -0
  86. package/src/components/ds-workspace-layout/ds-workspace-layout.figma.ts +99 -0
  87. package/src/components/ds-workspace-layout/ds-workspace-layout.module.scss +1 -8
  88. package/src/index.ts +1 -0
  89. package/src/styles/_gradients.scss +19 -0
  90. package/src/styles/_root.scss +39 -15
  91. package/src/styles/_typography.scss +1 -0
  92. package/src/styles/shared/_input.scss +10 -0
  93. package/src/styles/styles.scss +1 -0
  94. package/src/components/ds-table/context/ds-table-context.ts +0 -112
@@ -0,0 +1,208 @@
1
+ import { createContext, useContext, useMemo, type ReactNode, type RefObject } from 'react';
2
+ import type { DsDataTableProps, DsTableRowSize } from '../ds-table.types';
3
+ import type { DsTablePropsWithDefaults } from '../ds-table-defaults';
4
+ import type { DsTableResizeContextSlice } from '../hooks/use-column-resize';
5
+ import { useEditingState, type UseEditingStateResult } from '../hooks/use-editing-state';
6
+
7
+ /** Visual phase of the full-height column-resize divider. */
8
+ export type DsTableResizePhase = 'hover' | 'dragging';
9
+
10
+ export interface DsTableContextType<TData, TValue>
11
+ extends Partial<DsDataTableProps<TData, TValue>>, UseEditingStateResult<TData, TValue> {
12
+ /**
13
+ * Whether the table is virtualized
14
+ * @default false
15
+ */
16
+ virtualized?: boolean;
17
+ /**
18
+ * Row size variant
19
+ * @default 'medium'
20
+ */
21
+ rowSize: DsTableRowSize;
22
+ /**
23
+ * ID of the currently active row
24
+ */
25
+ activeRowId?: string | null;
26
+ /**
27
+ * Toggles the collapsed state of a column group by its id.
28
+ */
29
+ onToggleColumnGroup?: (groupId: string) => void;
30
+ /**
31
+ * Ref to the scroll container, used to anchor the full-height resize drag
32
+ * indicator and to measure boundary offsets while resizing.
33
+ */
34
+ resizeContainerRef?: RefObject<HTMLDivElement | null>;
35
+ /**
36
+ * True once every visible leaf has a `columnSizing` entry (snapshotted or
37
+ * user-resized), so cells should read widths from CSS variables.
38
+ */
39
+ resizeSizingReady?: boolean;
40
+ /**
41
+ * Reports hover on a resize handle. Pass the column id and boundary x-offset
42
+ * (relative to the scroll container), or `null` to clear.
43
+ */
44
+ onResizeHover?: (columnId: string | null, offset: number | null) => void;
45
+ /**
46
+ * Captures the cell right-edge offset at pointer-down so the overlay can
47
+ * follow `columnSizingInfo.deltaOffset` without extra context updates.
48
+ */
49
+ onResizeDragStart?: (offset: number) => void;
50
+ /**
51
+ * Restores snapshotted (or `columnDef.size`) widths for the given leaf ids.
52
+ */
53
+ onResizeReset?: (columnIds: string[]) => void;
54
+ /**
55
+ * Keyboard resize for a focused handle: signed px `delta` applied to the
56
+ * boundary header's column (leaf or group). Clamps and fires persist.
57
+ */
58
+ onResizeKeyboardNudge?: (columnId: string, delta: number) => void;
59
+ }
60
+
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+ const DsTableContext = createContext<DsTableContextType<any, any> | null>(null);
63
+
64
+ export const useDsTableContext = <TData, TValue>(): DsTableContextType<TData, TValue> => {
65
+ const context = useContext(DsTableContext);
66
+ if (!context) {
67
+ throw new Error('useDsTableContext must be used within DsTable');
68
+ }
69
+ return context as DsTableContextType<TData, TValue>;
70
+ };
71
+
72
+ interface DsTableContextProviderDerived {
73
+ grouping: {
74
+ collapsedColumnGroups: string[];
75
+ onToggleColumnGroup: (groupId: string) => void;
76
+ };
77
+ resize: DsTableResizeContextSlice;
78
+ }
79
+
80
+ export interface DsTableContextProviderProps<TData, TValue> {
81
+ tableProps: DsTablePropsWithDefaults<TData, TValue>;
82
+ derived: DsTableContextProviderDerived;
83
+ children: ReactNode;
84
+ }
85
+
86
+ /**
87
+ * Assembles {@link DsTableContext} from public table props plus derived grouping
88
+ * and resize slices. Owns inline-edit state. Picks context fields from
89
+ * `tableProps` and ignores the rest (`columns`, `data`, etc.).
90
+ */
91
+ export const DsTableContextProvider = <TData, TValue>({
92
+ tableProps,
93
+ derived,
94
+ children,
95
+ }: DsTableContextProviderProps<TData, TValue>) => {
96
+ const {
97
+ stickyHeader,
98
+ bordered,
99
+ fullWidth,
100
+ rowSize,
101
+ expandable,
102
+ selectable,
103
+ reorderable,
104
+ showSelectAllCheckbox,
105
+ loading,
106
+ onRowClick,
107
+ onRowDoubleClick,
108
+ primaryRowActions,
109
+ secondaryRowActions,
110
+ renderExpandedRow,
111
+ virtualized,
112
+ activeRowId,
113
+ locale,
114
+ onCellEdit,
115
+ onCellValidate,
116
+ } = tableProps;
117
+
118
+ const { collapsedColumnGroups, onToggleColumnGroup } = derived.grouping;
119
+ const {
120
+ resizableColumns,
121
+ resizeSizingReady,
122
+ resizeContainerRef,
123
+ onResizeHover,
124
+ onResizeDragStart,
125
+ onResizeReset,
126
+ onResizeKeyboardNudge,
127
+ } = derived.resize;
128
+
129
+ const { editing, beginEdit, setDraft, commit, cancel } = useEditingState<TData, TValue>(
130
+ onCellEdit,
131
+ onCellValidate,
132
+ );
133
+
134
+ const contextValue: DsTableContextType<TData, TValue> = useMemo(
135
+ () => ({
136
+ stickyHeader,
137
+ bordered,
138
+ fullWidth,
139
+ rowSize,
140
+ expandable,
141
+ selectable,
142
+ reorderable,
143
+ showSelectAllCheckbox,
144
+ loading,
145
+ onRowClick: loading ? undefined : onRowClick,
146
+ onRowDoubleClick: loading ? undefined : onRowDoubleClick,
147
+ primaryRowActions,
148
+ secondaryRowActions,
149
+ renderExpandedRow,
150
+ virtualized,
151
+ activeRowId,
152
+ collapsedColumnGroups,
153
+ onToggleColumnGroup,
154
+ locale,
155
+ onCellEdit,
156
+ resizableColumns,
157
+ resizeSizingReady,
158
+ resizeContainerRef,
159
+ onResizeHover,
160
+ onResizeDragStart,
161
+ onResizeReset,
162
+ onResizeKeyboardNudge,
163
+ editing,
164
+ beginEdit,
165
+ setDraft,
166
+ commit,
167
+ cancel,
168
+ }),
169
+ [
170
+ stickyHeader,
171
+ bordered,
172
+ fullWidth,
173
+ rowSize,
174
+ expandable,
175
+ selectable,
176
+ reorderable,
177
+ showSelectAllCheckbox,
178
+ loading,
179
+ onRowClick,
180
+ onRowDoubleClick,
181
+ primaryRowActions,
182
+ secondaryRowActions,
183
+ renderExpandedRow,
184
+ virtualized,
185
+ activeRowId,
186
+ collapsedColumnGroups,
187
+ onToggleColumnGroup,
188
+ locale,
189
+ onCellEdit,
190
+ resizableColumns,
191
+ resizeSizingReady,
192
+ resizeContainerRef,
193
+ onResizeHover,
194
+ onResizeDragStart,
195
+ onResizeReset,
196
+ onResizeKeyboardNudge,
197
+ editing,
198
+ beginEdit,
199
+ setDraft,
200
+ commit,
201
+ cancel,
202
+ ],
203
+ );
204
+
205
+ return <DsTableContext.Provider value={contextValue}>{children}</DsTableContext.Provider>;
206
+ };
207
+
208
+ DsTableContextProvider.displayName = 'DsTableContextProvider';
@@ -0,0 +1,42 @@
1
+ import type { DsDataTableProps } from './ds-table.types';
2
+
3
+ type DefaultedDsTableProp =
4
+ | 'virtualized'
5
+ | 'stickyHeader'
6
+ | 'bordered'
7
+ | 'fullWidth'
8
+ | 'rowSize'
9
+ | 'loading'
10
+ | 'expandable'
11
+ | 'selectable'
12
+ | 'showSelectAllCheckbox'
13
+ | 'primaryRowActions'
14
+ | 'actions'
15
+ | 'reorderable'
16
+ | 'resizableColumns';
17
+
18
+ export type DsTablePropsWithDefaults<TData, TValue> = DsDataTableProps<TData, TValue> &
19
+ Required<Pick<DsDataTableProps<TData, TValue>, DefaultedDsTableProp>>;
20
+
21
+ /**
22
+ * Applies the documented `DsTable` prop defaults. Call once at the table
23
+ * boundary so orchestration and context see the same resolved values.
24
+ */
25
+ export const applyDsTableDefaults = <TData, TValue>(
26
+ props: DsDataTableProps<TData, TValue>,
27
+ ): DsTablePropsWithDefaults<TData, TValue> => ({
28
+ ...props,
29
+ virtualized: props.virtualized ?? false,
30
+ stickyHeader: props.stickyHeader ?? true,
31
+ bordered: props.bordered ?? true,
32
+ fullWidth: props.fullWidth ?? true,
33
+ rowSize: props.rowSize ?? 'medium',
34
+ loading: props.loading ?? false,
35
+ expandable: props.expandable ?? false,
36
+ selectable: props.selectable ?? false,
37
+ showSelectAllCheckbox: props.showSelectAllCheckbox ?? true,
38
+ primaryRowActions: props.primaryRowActions ?? [],
39
+ actions: props.actions ?? [],
40
+ reorderable: props.reorderable ?? false,
41
+ resizableColumns: props.resizableColumns ?? false,
42
+ });
@@ -20,6 +20,7 @@ $bulk-actions-reserved-space: 80px;
20
20
  background: var(--background);
21
21
  display: flex;
22
22
  flex-direction: column;
23
+ height: 100%;
23
24
  max-height: 100%;
24
25
  overflow: hidden;
25
26
  }
@@ -34,6 +35,7 @@ $bulk-actions-reserved-space: 80px;
34
35
  }
35
36
 
36
37
  .dataTableContainer {
38
+ position: relative;
37
39
  flex: 1;
38
40
  min-height: 0;
39
41
  max-height: 100%;
@@ -65,6 +67,7 @@ $bulk-actions-reserved-space: 80px;
65
67
  tbody {
66
68
  display: block;
67
69
  overflow-y: auto;
70
+ overflow-x: hidden;
68
71
  flex: 1;
69
72
  min-height: 0;
70
73
  scrollbar-gutter: stable;
@@ -122,11 +125,11 @@ $bulk-actions-reserved-space: 80px;
122
125
 
123
126
  .virtualizedContainer {
124
127
  position: relative;
125
- height: vars.$virtualized-height;
126
128
  overflow-x: auto;
127
129
  overflow-y: hidden;
128
130
  display: flex;
129
131
  flex-direction: column;
132
+ flex: 1;
130
133
 
131
134
  @include scrollbars.scrollbar-on-hover;
132
135