@dbcdk/react-components 0.0.19 → 0.0.21

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 (46) hide show
  1. package/dist/components/button/Button.module.css +21 -10
  2. package/dist/components/chip/Chip.d.ts +3 -2
  3. package/dist/components/chip/Chip.js +2 -1
  4. package/dist/components/chip/Chip.module.css +107 -67
  5. package/dist/components/code-block/CodeBlock.js +28 -19
  6. package/dist/components/code-block/CodeBlock.module.css +69 -67
  7. package/dist/components/filter-field/FilterField.d.ts +2 -1
  8. package/dist/components/filter-field/FilterField.js +4 -9
  9. package/dist/components/filter-field/FilterField.module.css +203 -152
  10. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.d.ts +2 -3
  11. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.js +3 -5
  12. package/dist/components/filtering/chip-multi-toggle/ChipMultiToggle.module.css +13 -13
  13. package/dist/components/forms/input/Input.d.ts +1 -1
  14. package/dist/components/forms/input/Input.js +3 -9
  15. package/dist/components/forms/input/Input.module.css +106 -17
  16. package/dist/components/hyperlink/Hyperlink.module.css +14 -3
  17. package/dist/components/interval-select/IntervalSelect.js +2 -2
  18. package/dist/components/overlay/modal/Modal.d.ts +2 -1
  19. package/dist/components/overlay/modal/Modal.js +6 -6
  20. package/dist/components/overlay/modal/Modal.module.css +52 -19
  21. package/dist/components/popover/Popover.module.css +4 -1
  22. package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts +4 -2
  23. package/dist/components/segmented-progress-bar/SegmentedProgressBar.js +17 -19
  24. package/dist/components/segmented-progress-bar/SegmentedProgressBar.module.css +128 -20
  25. package/dist/components/sidebar/Sidebar.d.ts +2 -1
  26. package/dist/components/sidebar/Sidebar.js +2 -2
  27. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.d.ts +2 -3
  28. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +2 -4
  29. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +2 -1
  30. package/dist/components/table/Table.d.ts +6 -6
  31. package/dist/components/table/Table.js +153 -78
  32. package/dist/components/table/Table.module.css +335 -171
  33. package/dist/components/table/TanstackTable.d.ts +1 -1
  34. package/dist/components/table/TanstackTable.js +14 -12
  35. package/dist/components/table/table.utils.d.ts +1 -1
  36. package/dist/components/table/table.utils.js +2 -3
  37. package/dist/components/table/tanstackTable.utils.d.ts +9 -10
  38. package/dist/components/table/tanstackTable.utils.js +50 -30
  39. package/dist/hooks/useViewportFill.d.ts +6 -5
  40. package/dist/hooks/useViewportFill.js +43 -41
  41. package/dist/src/styles/styles.css +9 -3
  42. package/dist/styles/styles.css +9 -3
  43. package/dist/styles/themes/dbc/base.css +0 -3
  44. package/dist/styles/themes/dbc/dark.css +44 -12
  45. package/dist/styles/themes/dbc/light.css +33 -7
  46. package/package.json +1 -1
@@ -1,101 +1,276 @@
1
- /* Table.module.css (updated) */
2
-
3
- /* =========================
4
- Base table
5
- ========================= */
1
+ .fillViewportRoot {
2
+ display: flex;
3
+ position: relative;
4
+ block-size: 100%;
5
+ min-block-size: 0;
6
+ min-inline-size: 0;
7
+ overflow: hidden;
8
+ }
6
9
 
7
- .table {
10
+ .inlineRoot {
11
+ display: flex;
12
+ flex-direction: column;
13
+ min-block-size: 0;
14
+ min-inline-size: 0;
8
15
  inline-size: 100%;
9
16
  max-inline-size: 100%;
17
+ position: relative;
18
+ }
19
+
20
+ .toolbarSlot {
21
+ margin-bottom: 12px;
22
+ flex: 0 0 auto;
23
+ }
24
+
25
+ .tableViewport {
26
+ flex: 1 1 auto;
27
+ min-block-size: 0;
28
+ min-inline-size: 0;
29
+ display: flex;
30
+ flex-direction: column;
31
+ overflow: hidden;
32
+ }
33
+
34
+ .paginationSlot {
35
+ flex: 0 0 auto;
10
36
  overflow: visible;
11
- border-collapse: collapse;
12
- font-family: var(--font-family);
13
- font-size: var(--font-size-sm);
14
- color: var(--color-fg-default);
15
- background: var(--color-bg-surface);
16
- table-layout: fixed;
37
+ margin-top: auto;
17
38
  }
18
39
 
19
- .tableScroll {
20
- position: relative;
21
- overflow: auto;
22
- max-inline-size: 100%;
23
- -webkit-overflow-scrolling: touch;
40
+ .paginationSlot:not(.paginationSlotTop) {
41
+ padding-top: var(--spacing-sm);
24
42
  }
25
43
 
26
- /* =========================
27
- Header
28
- ========================= */
44
+ .paginationSlot.paginationSlotTop {
45
+ padding-bottom: var(--spacing-sm);
46
+ }
29
47
 
30
- .table thead {
48
+ .tableRoot {
49
+ display: flex;
50
+ flex-direction: column;
51
+ flex: 1 1 auto;
52
+ min-block-size: 0;
53
+ min-inline-size: 0;
54
+ inline-size: 100%;
55
+ max-inline-size: 100%;
56
+ font-family: var(--font-family);
57
+ font-size: var(--font-size-sm);
58
+ color: var(--table-cell-fg);
59
+ background: var(--table-row-bg);
60
+ overflow: auto;
61
+ }
62
+
63
+ .header {
31
64
  position: sticky;
32
65
  top: 0;
33
66
  z-index: 10;
34
- background-color: var(--color-bg-surface);
67
+ background-color: var(--table-header-bg);
68
+ border-block-end: 1px solid var(--table-border-header);
69
+ margin-bottom: 0;
70
+ flex: 0 0 auto;
35
71
  }
36
72
 
37
- .table.primary thead {
38
- box-shadow: var(--shadow-md);
73
+ .bodyScroll {
74
+ flex: 1 1 auto;
75
+ min-block-size: 0;
76
+ min-inline-size: 0;
77
+ max-inline-size: 100%;
78
+ -webkit-overflow-scrolling: touch;
39
79
  }
40
80
 
41
- .table .th {
42
- position: relative;
81
+ .emptyStateSlot {
82
+ display: grid;
83
+ place-items: center;
84
+ min-block-size: 100%;
85
+ padding: var(--spacing-lg);
86
+ }
43
87
 
44
- padding-block: var(--spacing-xs);
45
- padding-inline: var(--spacing-sm);
88
+ .headerRow,
89
+ .row {
90
+ position: relative;
91
+ display: grid;
92
+ grid-template-columns: var(--grid-template);
93
+ align-items: stretch;
94
+ inline-size: 100%;
95
+ min-inline-size: 0;
96
+ }
46
97
 
47
- text-align: left;
48
- vertical-align: middle;
98
+ .body {
99
+ min-block-size: 0;
100
+ }
49
101
 
50
- background: inherit;
102
+ .body::before {
103
+ display: none;
104
+ }
51
105
 
52
- /* Typography */
106
+ .headerCell {
107
+ display: flex;
108
+ align-items: center;
109
+ position: relative;
110
+ min-block-size: 44px;
111
+ padding-block: var(--spacing-xxs);
112
+ padding-inline: var(--spacing-sm);
53
113
  font-size: var(--font-size-xs);
54
- font-weight: var(--font-weight-normal);
114
+ font-weight: var(--font-weight-medium);
55
115
  letter-spacing: var(--letter-spacing-wide);
56
116
  text-transform: uppercase;
117
+ color: var(--table-header-fg);
118
+ white-space: nowrap;
119
+ overflow: hidden;
120
+ text-overflow: ellipsis;
121
+ min-width: 0;
122
+ }
57
123
 
58
- color: var(--color-fg-subtle);
124
+ .sm .headerCell {
125
+ min-block-size: 40px;
126
+ padding-block: var(--spacing-xxs);
127
+ padding-inline: var(--spacing-sm);
128
+ }
59
129
 
60
- /* Truncation */
61
- white-space: nowrap;
130
+ .row {
131
+ background: var(--table-row-bg);
132
+ transition:
133
+ background-color 140ms ease,
134
+ box-shadow 140ms ease;
135
+ }
136
+
137
+ .row::after {
138
+ content: '';
139
+ position: absolute;
140
+ inset: 0;
141
+ pointer-events: none;
142
+ z-index: 4;
143
+ opacity: 0;
144
+ box-shadow: inset 0 0 0 2px var(--color-brand);
145
+ transition: opacity 140ms ease;
146
+ }
147
+
148
+ .row:focus-within {
149
+ outline: none;
150
+ }
151
+
152
+ .row:focus-within::after {
153
+ opacity: 1;
154
+ }
155
+
156
+ .cell {
157
+ position: relative;
158
+ min-block-size: var(--component-size-md);
159
+ padding-block: 6px;
160
+ padding-inline: var(--spacing-sm);
161
+ border-block-end: 1px solid var(--table-border-subtle);
162
+ text-align: start;
163
+ vertical-align: top;
164
+ min-width: 0;
62
165
  overflow: hidden;
63
166
  text-overflow: ellipsis;
167
+ }
64
168
 
65
- /* Width control */
169
+ .sm .cell {
170
+ min-block-size: var(--component-size-sm);
171
+ padding-block: 6px;
172
+ padding-inline: var(--spacing-sm);
173
+ font-size: var(--font-size-xs);
174
+ line-height: var(--line-height-normal);
175
+ }
176
+
177
+ .headerCell[data-align='right'],
178
+ .cell[data-align='right'] {
179
+ text-align: end;
180
+ font-variant-numeric: tabular-nums;
181
+ }
182
+
183
+ .headerCell[data-align='center'],
184
+ .cell[data-align='center'] {
185
+ text-align: center;
186
+ }
187
+
188
+ .selectionCell {
189
+ padding-block: inherit !important;
190
+ padding-inline: 0 !important;
191
+ overflow: visible !important;
192
+ display: flex;
193
+ align-items: center;
194
+ justify-content: flex-start;
66
195
  min-width: 0;
67
196
  }
68
197
 
69
- /* Small variant: header padding */
70
- .table.sm .th {
71
- padding-inline: var(--spacing-md);
198
+ .clickableRow {
199
+ cursor: pointer;
200
+ }
201
+
202
+ .clickableRow:hover {
203
+ background-color: var(--table-row-bg-hover);
204
+ }
205
+
206
+ .selectedRow {
207
+ background-color: var(--table-row-bg-selected);
208
+ }
209
+
210
+ .selectedRow:hover {
211
+ background-color: var(--table-row-bg-selected-hover);
212
+ }
213
+
214
+ .striped .row:nth-child(even):not(.selectedRow):not(:hover) {
215
+ background-color: var(--table-row-bg-alt);
72
216
  }
73
217
 
74
- /* Header layout */
75
- .th > .thInner {
218
+ .nowrap {
219
+ white-space: nowrap;
220
+ }
221
+
222
+ .allowWrap {
223
+ white-space: normal;
224
+ overflow-wrap: break-word;
225
+ word-break: normal;
226
+ }
227
+
228
+ .thInner {
76
229
  display: flex;
77
230
  align-items: center;
78
231
  inline-size: 100%;
232
+ min-width: 0;
233
+ }
234
+
235
+ .thInnerRight {
236
+ justify-content: flex-end;
237
+ }
238
+
239
+ .thInnerCenter {
240
+ justify-content: center;
241
+ }
242
+
243
+ .thMain {
244
+ flex: 1 1 auto;
245
+ min-width: 0;
246
+ display: flex;
247
+ align-items: center;
248
+ justify-content: flex-start;
249
+ }
250
+
251
+ .thMainRight {
252
+ justify-content: flex-end;
253
+ }
254
+
255
+ .thMainCenter {
256
+ justify-content: center;
79
257
  }
80
258
 
81
- /* Sort button (full width click target, but content aligns via modifiers) */
82
259
  .thButton {
83
260
  all: unset;
84
- display: flex;
261
+ display: inline-flex;
85
262
  align-items: center;
86
- gap: var(--spacing-xxs);
87
- inline-size: 100%;
263
+ gap: 4px;
264
+ min-width: 0;
265
+ max-inline-size: 100%;
88
266
  cursor: pointer;
89
267
  user-select: none;
90
268
  border-radius: var(--border-radius-default);
91
269
  padding-block: 2px;
92
270
  padding-inline: 2px;
93
-
94
- /* default */
95
271
  justify-content: flex-start;
96
272
  }
97
273
 
98
- /* IMPORTANT: use consistent PascalCase suffixes */
99
274
  .thButtonRight {
100
275
  justify-content: flex-end;
101
276
  }
@@ -104,7 +279,6 @@
104
279
  justify-content: center;
105
280
  }
106
281
 
107
- /* Label should NOT grow to fill space (it breaks alignment) */
108
282
  .thLabel {
109
283
  overflow: hidden;
110
284
  text-overflow: ellipsis;
@@ -113,24 +287,38 @@
113
287
  min-width: 0;
114
288
  }
115
289
 
116
- /* Match label text alignment to column alignment */
117
290
  .thLabelRight {
118
291
  text-align: right;
292
+ width: 100%;
119
293
  }
120
294
 
121
295
  .thLabelCenter {
122
296
  text-align: center;
297
+ width: 100%;
123
298
  }
124
299
 
125
- .thExtras {
126
- display: inline-flex;
300
+ .thOverlayExtras {
301
+ position: absolute;
302
+ inset-block: 0;
303
+ inset-inline-end: 0;
304
+ display: flex;
127
305
  align-items: center;
306
+ justify-content: center;
307
+ min-width: 0;
308
+ pointer-events: none;
309
+ z-index: 5;
310
+ }
311
+
312
+ .thOverlayExtras > * {
313
+ pointer-events: auto;
128
314
  }
129
315
 
130
316
  .sortIndicator {
131
317
  display: inline-flex;
132
318
  flex: 0 0 auto;
133
319
  align-items: center;
320
+ color: var(--color-fg-subtle);
321
+ opacity: 0.9;
134
322
  }
135
323
 
136
324
  .sortIndicator svg {
@@ -138,166 +326,142 @@
138
326
  block-size: var(--icon-size-sm);
139
327
  }
140
328
 
141
- /* =========================
142
- Body + cells
143
- ========================= */
144
-
145
- .tBody::before {
146
- content: '';
147
- height: var(--spacing-xs);
329
+ .cellContent {
148
330
  display: block;
331
+ inline-size: 100%;
332
+ min-width: 0;
333
+ max-inline-size: 100%;
149
334
  }
150
335
 
151
- .tBody tr td {
152
- position: relative;
153
- padding-block: var(--spacing-xs);
154
- padding-inline: var(--spacing-sm);
155
-
156
- border-block-end: var(--border-width-thin) solid var(--color-border-default);
157
-
158
- text-align: start;
159
- vertical-align: top;
160
-
161
- overflow-wrap: break-word;
162
- word-break: normal;
163
- }
164
-
165
- /* Small variant applies to all cells by default */
166
- .table.sm .tBody tr td {
167
- padding-block: var(--spacing-xxs);
168
- padding-inline: var(--spacing-md);
169
- font-size: var(--font-size-xs);
170
- line-height: var(--line-height-normal);
336
+ .cellContent > * {
337
+ min-width: 0;
338
+ max-inline-size: 100%;
171
339
  }
172
340
 
173
- /* =========================
174
- Selection column
175
- ========================= */
176
-
177
- .tBody tr td.selectionCell,
178
- .table .tBody tr td.selectionCell,
179
- .table td.selectionCell {
180
- padding-inline: var(--spacing-xxs);
341
+ .cellValueEllipsis {
342
+ display: block;
343
+ inline-size: 100%;
344
+ min-width: 0;
345
+ max-inline-size: 100%;
346
+ white-space: nowrap;
347
+ overflow: hidden;
348
+ text-overflow: ellipsis;
181
349
  }
182
350
 
183
- .table .th.selectionCell,
184
- .table th.selectionCell,
185
- th.selectionCell {
186
- width: 34px !important;
351
+ .allowWrap .cellContent {
352
+ white-space: normal;
353
+ overflow-wrap: break-word;
354
+ word-break: normal;
187
355
  }
188
356
 
189
- /* Override the .table.sm .tBody tr td padding-inline */
190
- .table.sm .tBody tr td.selectionCell,
191
- .table.table.sm .tBody tr td.selectionCell {
192
- padding-inline: var(--spacing-xxs);
357
+ .severityTable {
358
+ --row-rail-width: 4px;
359
+ --row-rail-gap: 10px;
360
+ --row-rail-offset: calc(var(--row-rail-width) + var(--row-rail-gap));
361
+ --row-rail-inset-block: 1px;
362
+ --row-rail-radius: 0 2px 2px 0;
193
363
  }
194
364
 
195
- .table.severityTable .tBody tr td:first-child {
196
- padding-inline-start: var(--spacing-md);
197
- }
198
- .table.severityTable .tBody tr td.selectionCell,
199
- .table.severityTable td.selectionCell,
200
- .table.severityTable .th.selectionCell,
201
- .table.severityTable th.selectionCell {
202
- padding-inline: var(--spacing-xxs);
365
+ .severityTable .headerRow .selectionCell,
366
+ .severityTable .row .selectionCell {
367
+ padding-inline-start: var(--row-rail-offset) !important;
203
368
  }
204
369
 
205
- .table.sm.severityTable .tBody tr td.selectionCell,
206
- .table.table.sm.severityTable .tBody tr td.selectionCell,
207
- .table.sm.severityTable .th.selectionCell,
208
- .table.table.sm.severityTable .th.selectionCell,
209
- .table.sm.severityTable th.selectionCell {
210
- padding-inline: var(--spacing-xxs);
211
- padding-inline-start: 14px;
370
+ .severityTable .row.severity {
371
+ --row-severity-color: transparent;
372
+ --row-severity-bg: transparent;
373
+ --row-severity-bg-hover: transparent;
374
+ background-color: var(--row-severity-bg);
212
375
  }
213
376
 
214
- /* =========================
215
- Rows (interaction + states)
216
- ========================= */
217
-
218
- .clickableRow {
219
- cursor: pointer;
377
+ .severityTable .row.severity::before {
378
+ content: '';
379
+ position: absolute;
380
+ inset-inline-start: 0;
381
+ inset-block-start: var(--row-rail-inset-block);
382
+ inset-block-end: var(--row-rail-inset-block);
383
+ inline-size: var(--row-rail-width);
384
+ background-color: var(--row-severity-color);
385
+ border-radius: var(--row-rail-radius);
386
+ z-index: 2;
387
+ pointer-events: none;
388
+ opacity: 0.95;
389
+ transition:
390
+ inline-size 140ms ease,
391
+ opacity 140ms ease,
392
+ filter 140ms ease;
220
393
  }
221
394
 
222
- .clickableRow:hover {
223
- background-color: var(--color-bg-contextual);
395
+ .severityTable .row.severity > * {
396
+ position: relative;
397
+ z-index: 3;
224
398
  }
225
399
 
226
- .selectedRow {
227
- background-color: var(--color-bg-selected);
400
+ .severityTable .row.severity.clickableRow:hover::before,
401
+ .severityTable .row.severity:hover::before {
402
+ opacity: 1;
403
+ filter: saturate(1.08);
228
404
  }
229
405
 
230
- .selectedRow:hover {
231
- background-color: var(--color-bg-selected-hover);
406
+ .severityTable .row.severity.clickableRow:hover,
407
+ .severityTable .row.severity:hover {
408
+ background-color: var(--row-severity-bg-hover);
232
409
  }
233
410
 
234
- .tr--hover:hover {
235
- background-color: var(--color-bg-contextual);
411
+ .severityTable .row.severity.selectedRow {
412
+ background-color: var(--table-row-bg-selected);
236
413
  }
237
414
 
238
- .striped tr:nth-child(even):not(.selectedRow):not(:hover) {
239
- background-color: var(--color-bg-surface-subtle);
415
+ .severityTable .row.severity.selectedRow:hover {
416
+ background-color: var(--table-row-bg-selected-hover);
240
417
  }
241
418
 
242
- /* Focus ring (fix selector: .tBody, not .tbody) */
243
- .table .tBody tr:focus-within {
244
- outline: none;
245
- box-shadow:
246
- inset 2px 0 0 var(--color-brand),
247
- inset -2px 0 0 var(--color-brand),
248
- inset 0 2px 0 var(--color-brand),
249
- inset 0 -2px 0 var(--color-brand);
419
+ .severityTable .row.severity:focus-within::before {
420
+ inline-size: 6px;
421
+ opacity: 1;
250
422
  }
251
423
 
252
- /* =========================
253
- Content utilities
254
- ========================= */
255
-
256
- .nowrap {
257
- white-space: nowrap;
258
- overflow: hidden;
259
- text-overflow: ellipsis;
424
+ .striped .severityTable .row.severity:nth-child(even):not(.selectedRow):not(:hover) {
425
+ background-image:
426
+ linear-gradient(var(--row-severity-bg), var(--row-severity-bg)),
427
+ linear-gradient(var(--table-row-bg-alt), var(--table-row-bg-alt));
428
+ background-blend-mode: normal;
260
429
  }
261
430
 
262
- .allowWrap {
263
- word-break: break-all !important;
264
- overflow-wrap: anywhere !important;
431
+ .severityTable .row.severityFailed::before {
432
+ box-shadow: 1px 0 0 color-mix(in srgb, var(--row-severity-color) 20%, transparent);
265
433
  }
266
434
 
267
- .td--numeric {
268
- text-align: end;
435
+ .sm .severityTable {
436
+ --row-rail-width: 4px;
437
+ --row-rail-gap: 8px;
438
+ --row-rail-inset-block: 1px;
269
439
  }
270
440
 
271
- .td--muted {
272
- color: var(--color-fg-muted);
441
+ .dividerLeft {
442
+ position: relative;
273
443
  }
274
444
 
275
- .td .error {
276
- color: var(--color-danger);
445
+ .dividerLeft::before {
446
+ content: '';
447
+ position: absolute;
448
+ left: 0;
449
+ top: 8px;
450
+ bottom: 8px;
451
+ width: 1px;
452
+ background: var(--table-divider);
277
453
  }
278
454
 
279
- /* =========================
280
- Severity rail
281
- ========================= */
282
-
283
- .tBody tr.severity td:first-child {
455
+ .dividerRight {
284
456
  position: relative;
285
457
  }
286
458
 
287
- .table.severityTable .tBody tr.severity td:first-child::before {
459
+ .dividerRight::after {
288
460
  content: '';
289
461
  position: absolute;
290
- left: 2px;
291
- top: 1px;
292
- bottom: 1px;
293
- width: 3px;
294
- background-color: var(--row-severity-color);
295
- border-radius: 1px;
296
-
297
- z-index: 0;
298
- }
299
-
300
- .table.severityTable .tBody tr.severity td:first-child > * {
301
- position: relative;
302
- z-index: 1;
462
+ right: 0;
463
+ top: 8px;
464
+ bottom: 8px;
465
+ width: 1px;
466
+ background: var(--table-divider);
303
467
  }
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import { type TableProps, type TableVariant } from './Table';
4
4
  import { ViewMode } from '../../hooks/useTableSettings';
5
5
  type Filterable<T> = Array<keyof T>;
6
- export type TanstackTableProps<T extends Record<string, any>> = Omit<TableProps<T>, 'columns' | 'onSortChange' | 'sortById' | 'sortDirection' | 'headerBelowRow' | 'headerExtras' | 'columnStyles' | 'toolbar'> & {
6
+ export type TanstackTableProps<T extends Record<string, any>> = Omit<TableProps<T>, 'columns' | 'onSortChange' | 'sortById' | 'sortDirection' | 'headerExtras' | 'gridTemplateColumns' | 'toolbar'> & {
7
7
  columns: ReadonlyArray<ColumnDef<T, any>>;
8
8
  filterable?: Filterable<T>;
9
9
  sorting?: SortingState;
@@ -4,9 +4,9 @@ import { useReactTable, getCoreRowModel, getSortedRowModel, getFilteredRowModel,
4
4
  import * as React from 'react';
5
5
  import ColumnResizer from './components/column-resizer/ColumnResizer';
6
6
  import { Table } from './Table';
7
- import { buildColumnVisibilityFromVisibleIds, mapDefsToColumnItems, sortingEqual, getSortPropsFromSorting, buildColumnStyles, columnItemsToIdSet, } from './tanstackTable.utils';
7
+ import { buildColumnVisibilityFromVisibleIds, mapDefsToColumnItems, sortingEqual, getSortPropsFromSorting, columnItemsToIdSet, buildDistributedGridTemplateColumns, } from './tanstackTable.utils';
8
8
  export function TanstackTable(props) {
9
- const { data, dataKey, columns, filterable = [], sorting: controlledSorting, onSortingChange, optimisticSortingUi = true, visibleColumnIds, manualSorting, ...tableProps } = props;
9
+ const { data, dataKey, columns, sorting: controlledSorting, onSortingChange, optimisticSortingUi = true, visibleColumnIds, manualSorting, selectedRows, onRowSelect, ...tableProps } = props;
10
10
  const isControlledSorting = controlledSorting != null;
11
11
  const [uiSorting, setUiSorting] = React.useState(controlledSorting !== null && controlledSorting !== void 0 ? controlledSorting : []);
12
12
  React.useEffect(() => {
@@ -46,26 +46,17 @@ export function TanstackTable(props) {
46
46
  enableResizing: true,
47
47
  minSize: 80,
48
48
  size: 180,
49
- maxSize: 300,
50
49
  },
51
50
  });
52
51
  const columnItems = React.useMemo(() => mapDefsToColumnItems(columns, columnVisibility), [columns, columnVisibility]);
53
52
  const allowedIds = React.useMemo(() => columnItemsToIdSet(columnItems), [columnItems]);
54
53
  const visibleData = table.getRowModel().rows.map(r => r.original);
55
54
  const { sortById, sortDirection } = getSortPropsFromSorting(uiSorting);
56
- const columnStyles = React.useMemo(() => {
57
- const leafCols = table.getAllLeafColumns();
58
- return buildColumnStyles(leafCols, allowedIds, { minWidth: 80, maxWidth: 800 });
59
- }, [table, columnSizing, allowedIds]);
60
55
  const handleSortChange = React.useCallback((column, direction) => {
61
- // Translate Table's direction -> TanStack SortingState
62
56
  const next = direction == null ? [] : [{ id: column.id, desc: direction === 'desc' }];
63
- // Mirror TanStack's onSortingChange behavior
64
57
  if (optimisticSortingUi)
65
58
  setUiSorting(next);
66
59
  onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange(next);
67
- // If you are doing server-side sorting, you likely also want:
68
- // table.resetPageIndex?.() or external pagination reset (depends on your setup)
69
60
  }, [optimisticSortingUi, onSortingChange]);
70
61
  const headerExtras = React.useCallback(({ index }) => {
71
62
  var _a, _b, _c, _d;
@@ -80,5 +71,16 @@ export function TanstackTable(props) {
80
71
  return null;
81
72
  return _jsx(ColumnResizer, { id: header.column.id, handler: handler });
82
73
  }, [table]);
83
- return (_jsx(Table, { ...tableProps, onSortChange: handleSortChange, dataKey: dataKey, data: visibleData, columns: columnItems, sortById: sortById, sortDirection: sortDirection, columnStyles: columnStyles, headerExtras: headerExtras }));
74
+ const hasSelection = Boolean(selectedRows && onRowSelect && dataKey);
75
+ const gridTemplateColumns = React.useMemo(() => {
76
+ return buildDistributedGridTemplateColumns({
77
+ table,
78
+ allowedIds,
79
+ hasSelection,
80
+ selectionPx: 36,
81
+ defaultMinPx: 80,
82
+ columnSizing,
83
+ });
84
+ }, [table, allowedIds, hasSelection, columnSizing]);
85
+ return (_jsx(Table, { ...tableProps, onSortChange: handleSortChange, dataKey: dataKey, data: visibleData, columns: columnItems, sortById: sortById, sortDirection: sortDirection, gridTemplateColumns: gridTemplateColumns, headerExtras: headerExtras, selectedRows: selectedRows, onRowSelect: onRowSelect }));
84
86
  }