@gears-frontx/ui-kit 0.4.0-alpha.5 → 0.4.0-alpha.7

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 (50) hide show
  1. package/dist/button.js +60 -57
  2. package/dist/button.js.map +1 -1
  3. package/dist/carousel.js.map +1 -1
  4. package/dist/chart.js +184 -122
  5. package/dist/chart.js.map +1 -1
  6. package/dist/chunks/button.BWdRnIvz.css +1 -0
  7. package/dist/chunks/combobox.CKhQGu5a.css +1 -0
  8. package/dist/chunks/pagination.CKDEuWt6.css +1 -0
  9. package/dist/chunks/spinner.CLQsj9Ky.css +1 -0
  10. package/dist/chunks/table.CMm41tvy.css +1 -0
  11. package/dist/combobox.js +135 -116
  12. package/dist/combobox.js.map +1 -1
  13. package/dist/components/button/button.d.ts +18 -5
  14. package/dist/components/button/button.d.ts.map +1 -1
  15. package/dist/components/carousel/carousel.d.ts +2 -2
  16. package/dist/components/carousel/carousel.d.ts.map +1 -1
  17. package/dist/components/chart/chart.d.ts +7 -6
  18. package/dist/components/chart/chart.d.ts.map +1 -1
  19. package/dist/components/combobox/combobox.d.ts +12 -1
  20. package/dist/components/combobox/combobox.d.ts.map +1 -1
  21. package/dist/components/pagination/pagination.d.ts +33 -2
  22. package/dist/components/pagination/pagination.d.ts.map +1 -1
  23. package/dist/components/pagination/public.d.ts +1 -1
  24. package/dist/components/pagination/public.d.ts.map +1 -1
  25. package/dist/components/sidebar/sidebar.d.ts +1 -1
  26. package/dist/components/sidebar/sidebar.d.ts.map +1 -1
  27. package/dist/components/spinner/spinner.d.ts +11 -1
  28. package/dist/components/spinner/spinner.d.ts.map +1 -1
  29. package/dist/components/table/table.d.ts +18 -2
  30. package/dist/components/table/table.d.ts.map +1 -1
  31. package/dist/docs/button.md +24 -4
  32. package/dist/docs/combobox.md +147 -0
  33. package/dist/docs/pagination.md +84 -5
  34. package/dist/docs/spinner.md +5 -1
  35. package/dist/docs/table.md +95 -11
  36. package/dist/index.js +198 -195
  37. package/dist/pagination.js +96 -52
  38. package/dist/pagination.js.map +1 -1
  39. package/dist/sidebar.js.map +1 -1
  40. package/dist/spinner.js +30 -27
  41. package/dist/spinner.js.map +1 -1
  42. package/dist/table.js +106 -97
  43. package/dist/table.js.map +1 -1
  44. package/llms.txt +27 -9
  45. package/package.json +1 -1
  46. package/dist/chunks/button.DgUTlW0_.css +0 -1
  47. package/dist/chunks/combobox.DZZ3tHP_.css +0 -1
  48. package/dist/chunks/pagination.bFb5us_w.css +0 -1
  49. package/dist/chunks/spinner.sH6x_1Uf.css +0 -1
  50. package/dist/chunks/table.DR2nFT0x.css +0 -1
@@ -56,8 +56,12 @@ give the wrapper itself a `max-height` through `containerClassName` or
56
56
  `overflow-y` around `<Table>` instead: a sticky header sticks to its nearest
57
57
  scrolling ancestor, which is Table's own wrapper since it already scrolls
58
58
  horizontally. Your outer div would scroll while the wrapper, with no height
59
- of its own, never does, so the collection view's header would scroll away
60
- with the rows.
59
+ of its own, never does, so a sticky header would scroll away with the rows.
60
+
61
+ To measure the wrapper or drive its scroll position (scroll a row into view,
62
+ read its `clientWidth`), pass `containerRef`: a ref object or a callback ref
63
+ to the wrapper `div`. `ref` itself still lands on the `<table>`, like every
64
+ other prop that is not a wrapper one.
61
65
 
62
66
  A focus stop should announce something: pass `label` to name the wrapper
63
67
  (`role="region"` + `aria-label` — a bare `div`'s `aria-label` is ignored
@@ -67,8 +71,8 @@ non-focusable element while the focusable wrapper stays nameless).
67
71
  Without `label` the wrapper is roleless and nameless as before. Prefer
68
72
  passing it whenever the surrounding page doesn't make the table's purpose
69
73
  obvious the moment focus lands. Beyond `label`, the wrapper takes
70
- `containerClassName` and `containerStyle`, merged after its kit class; it
71
- isn't a separate export.
74
+ `containerClassName` and `containerStyle`, merged after its kit class, and
75
+ `containerRef`; it isn't a separate export.
72
76
 
73
77
  ## Semantics and accessibility
74
78
 
@@ -107,7 +111,7 @@ Taken from the Studio Data Table frame:
107
111
  | Cell inline padding | 16px | `--space-4` |
108
112
  | Row height (one line of text) | 40px | falls out of the padding (16 + 12 + 12); `--control-height-lg` is also pinned as a floor on `.tableCell` so an empty or sub-line cell cannot collapse the row — `height` on a table cell is a floor, not a cap |
109
113
  | Row height (row holding a 32px control) | 56px | falls out of the same padding (32 + 12 + 12) |
110
- | Row rule | 1px | `--border-width` `--border` |
114
+ | Row rule | 1px | `--border-width` `--border`, drawn under each cell (see "Sticky header") |
111
115
 
112
116
  The header is the one place the table leaves Inter: its column labels are
113
117
  mono by design, and that carries through to a header rendered as a button
@@ -174,8 +178,8 @@ other prop rather than driven by a kit-specific prop. Your own logic sets
174
178
  the attribute; the kit only paints it.
175
179
 
176
180
  A row is flat: transparent at rest, packed against its neighbours, with a
177
- single full-bleed 1px `--border` rule under it and no corner radius, ring,
178
- or fill of its own. Every state below is expressed as a full-bleed tint on
181
+ single full-bleed 1px `--border` rule under it (drawn by its cells, see
182
+ "Sticky header") and no corner radius, ring, or fill of its own. Every state below is expressed as a full-bleed tint on
179
183
  that shape — the drawn state language of the Studio Data Table:
180
184
 
181
185
  - `data-state="selected"` — a `--selection-subtle` tint, for a row the
@@ -186,10 +190,13 @@ that shape — the drawn state language of the Studio Data Table:
186
190
  viewer lacks access to.
187
191
  - Hover, and any row containing a descendant that is *currently*
188
192
  `aria-expanded="true"` (e.g. a row-level disclosure toggle, only while
189
- open — a collapsed toggle does not match) — a `--muted` tint, one step
190
- off both backdrops a table meets (`--surface` inside a card,
191
- `--background` bare on the page). A `data-state` tint outranks hover, so
192
- a selected row stays selected-colored under the pointer.
193
+ open — a collapsed toggle does not match) — a `--card-hover` tint, the
194
+ kit's hover step for a raised surface. It differs from both backdrops a
195
+ table meets (`--surface` inside a card, `--background` bare on the page) in
196
+ both themes; `--muted` would not, since the theme draws it equal to
197
+ `--background` in light and to every surface in dark. A `data-state` tint
198
+ outranks hover, so a selected row stays selected-colored under the
199
+ pointer.
193
200
 
194
201
  Because rows carry no fill at rest, the surface behind the table shows
195
202
  through them — put a `Table` on a `Card`, on `DataTable`'s own card, or on
@@ -200,6 +207,48 @@ the container's own bottom border or a footer bar's top border, and a
200
207
  second line there would double it. A `<tfoot>` after the body still gets
201
208
  its separator, since the body is then no longer the last section.
202
209
 
210
+ ## Sticky header
211
+
212
+ `stickyHeader` pins the header cells to the top of the scroll wrapper, so the
213
+ rows scroll beneath them on an opaque `--card` fill. It needs a bounded
214
+ wrapper height to have anything to scroll within (`containerClassName` or
215
+ `containerStyle`, as above). It is independent of `variant`: it brings none
216
+ of the collection view's fixed layout, minimum width or row height, only the
217
+ pinning, and works with `density` too.
218
+
219
+ It is built for ONE header row: every header cell takes `top: 0`, so a
220
+ second `TableRow` of `TableHead` cells would slide under the first rather than
221
+ stack beneath it.
222
+
223
+ In the default variant only the cells of `TableHeader` pin. A `TableHead` in a
224
+ body row (a row header, `scope="row"`) looks the same but scrolls away with its
225
+ row: pinned, it would sit over the column header. The collection variant is not
226
+ covered by this: its own rule still pins every `TableHead`, body-row headings
227
+ included, so avoid a `TableHead` in a body row under `variant="collection"` (a
228
+ known gap).
229
+
230
+ To change the fill, set `--table-header-fill` on the table (through
231
+ `className`) or on an ancestor. The kit reads it with `--card` as the
232
+ fallback and declares it nowhere itself, so a plain class is enough: no
233
+ selector has to outrank the kit's. It applies to `stickyHeader`; the
234
+ `collection` variant keeps its own header fill, also when both are set, so the
235
+ hook does not reach it.
236
+
237
+ ```css
238
+ .invoices { --table-header-fill: var(--surface-elevated); }
239
+ ```
240
+
241
+ It also switches the table from collapsed to separated borders (with no
242
+ spacing). In the collapsed model a border belongs to the table's grid, not
243
+ to the cell, so the rule under a pinned header would stay behind and scroll
244
+ away with the rows; in the separated model it travels with the cell. That is
245
+ why the 1px rule between rows is drawn under each header and body cell
246
+ rather than by the row: a row's own border is ignored once the borders are
247
+ separated, while under the collapsed model the cell rules merge into the
248
+ same single line a row border drew. The look is unchanged either way. A
249
+ border you put on a `TableRow` yourself is not the kit's rule, and is
250
+ ignored by a `stickyHeader` table.
251
+
203
252
  ## Props (kit level)
204
253
 
205
254
  `Table`:
@@ -211,6 +260,8 @@ its separator, since the body is then no longer the last section.
211
260
  | `variant` | `'default'` \| `'collection'` - collection is the fixed-layout view with a sticky 40 px header and 64 px rows | `'default'` |
212
261
  | `containerClassName` | `string` - className for the scroll wrapper; give it a `max-height` to scroll the rows under a sticky header | - |
213
262
  | `containerStyle` | `CSSProperties` - inline style for the same wrapper, e.g. `{ maxHeight: 320 }` | - |
263
+ | `containerRef` | `Ref<HTMLDivElement>` - ref to the scroll wrapper, not the `<table>` (`ref` still lands on the table) | - |
264
+ | `stickyHeader` | `boolean` - pins the `TableHeader` cells (in the default variant; the collection variant pins every `TableHead`) to the top of the scroll wrapper on an opaque fill; needs a bounded wrapper height, and is independent of `variant` | `false` |
214
265
 
215
266
  `TableHead`:
216
267
 
@@ -335,6 +386,39 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@
335
386
  </Table>;
336
387
  ```
337
388
 
389
+ A pinned header that works without the collection view, with the scroll
390
+ wrapper reachable through a ref:
391
+
392
+ ```tsx
393
+ import { useRef } from 'react';
394
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@gears-frontx/ui-kit';
395
+
396
+ function Invoices({ rows }: { rows: string[] }) {
397
+ const containerRef = useRef<HTMLDivElement>(null);
398
+ return (
399
+ <>
400
+ <button type="button" onClick={() => containerRef.current?.scrollTo({ top: 0 })}>
401
+ Back to top
402
+ </button>
403
+ <Table stickyHeader containerRef={containerRef} containerStyle={{ maxHeight: '20rem' }}>
404
+ <TableHeader>
405
+ <TableRow>
406
+ <TableHead>Invoice</TableHead>
407
+ </TableRow>
408
+ </TableHeader>
409
+ <TableBody>
410
+ {rows.map((id) => (
411
+ <TableRow key={id}>
412
+ <TableCell>{id}</TableCell>
413
+ </TableRow>
414
+ ))}
415
+ </TableBody>
416
+ </Table>
417
+ </>
418
+ );
419
+ }
420
+ ```
421
+
338
422
  A row with a leading checkbox column, sized flush against the cell edge by
339
423
  the source's own `:has([role=checkbox])` rule (built into `.tableHead`/
340
424
  `.tableCell`, no extra class needed):