@gears-frontx/ui-kit 0.3.0-alpha.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.
- package/LICENSE +201 -0
- package/NOTICE +49 -0
- package/README.md +75 -0
- package/dist/badge.d.ts +1 -0
- package/dist/badge.js +42 -0
- package/dist/badge.js.map +1 -0
- package/dist/button.d.ts +1 -0
- package/dist/button.js +73 -0
- package/dist/button.js.map +1 -0
- package/dist/card.d.ts +1 -0
- package/dist/card.js +54 -0
- package/dist/card.js.map +1 -0
- package/dist/checkbox.d.ts +1 -0
- package/dist/checkbox.js +46 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/chunks/badge.ej-3-Xs4.css +1 -0
- package/dist/chunks/button.CKfALaMe.css +1 -0
- package/dist/chunks/card.B0AcyAT1.css +1 -0
- package/dist/chunks/checkbox.Dd6YDr20.css +1 -0
- package/dist/chunks/dialog.D6LS2vnG.css +1 -0
- package/dist/chunks/dropdown-menu.DmDZc5gB.css +1 -0
- package/dist/chunks/field.BNZx8HfN.css +1 -0
- package/dist/chunks/input.CrRQ0OAn.css +1 -0
- package/dist/chunks/label.jrB9zD_G.css +1 -0
- package/dist/chunks/radio-group.1Y6B0lXt.css +1 -0
- package/dist/chunks/select.BmyP2S2q.css +1 -0
- package/dist/chunks/separator.DdRRkJW4.css +1 -0
- package/dist/chunks/skeleton.BhWSzPnI.css +1 -0
- package/dist/chunks/switch.B_ebMSxR.css +1 -0
- package/dist/chunks/table.r8ppNt1W.css +1 -0
- package/dist/chunks/tabs.DqJE9cX3.css +1 -0
- package/dist/chunks/textarea.BKWvs6fD.css +1 -0
- package/dist/chunks/toast.DMl31Mq4.css +1 -0
- package/dist/chunks/tooltip.apA3VWHJ.css +1 -0
- package/dist/components/badge/badge.d.ts +11 -0
- package/dist/components/badge/badge.d.ts.map +1 -0
- package/dist/components/badge/public.d.ts +2 -0
- package/dist/components/badge/public.d.ts.map +1 -0
- package/dist/components/button/button.d.ts +50 -0
- package/dist/components/button/button.d.ts.map +1 -0
- package/dist/components/button/public.d.ts +2 -0
- package/dist/components/button/public.d.ts.map +1 -0
- package/dist/components/card/card.d.ts +22 -0
- package/dist/components/card/card.d.ts.map +1 -0
- package/dist/components/card/public.d.ts +2 -0
- package/dist/components/card/public.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +6 -0
- package/dist/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/public.d.ts +2 -0
- package/dist/components/checkbox/public.d.ts.map +1 -0
- package/dist/components/dialog/dialog.d.ts +58 -0
- package/dist/components/dialog/dialog.d.ts.map +1 -0
- package/dist/components/dialog/public.d.ts +2 -0
- package/dist/components/dialog/public.d.ts.map +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +70 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu/public.d.ts +2 -0
- package/dist/components/dropdown-menu/public.d.ts.map +1 -0
- package/dist/components/field/field.d.ts +18 -0
- package/dist/components/field/field.d.ts.map +1 -0
- package/dist/components/field/public.d.ts +2 -0
- package/dist/components/field/public.d.ts.map +1 -0
- package/dist/components/input/input.d.ts +6 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/public.d.ts +2 -0
- package/dist/components/input/public.d.ts.map +1 -0
- package/dist/components/label/label.d.ts +4 -0
- package/dist/components/label/label.d.ts.map +1 -0
- package/dist/components/label/public.d.ts +2 -0
- package/dist/components/label/public.d.ts.map +1 -0
- package/dist/components/radio-group/public.d.ts +2 -0
- package/dist/components/radio-group/public.d.ts.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +11 -0
- package/dist/components/radio-group/radio-group.d.ts.map +1 -0
- package/dist/components/select/public.d.ts +2 -0
- package/dist/components/select/public.d.ts.map +1 -0
- package/dist/components/select/select.d.ts +61 -0
- package/dist/components/select/select.d.ts.map +1 -0
- package/dist/components/separator/public.d.ts +2 -0
- package/dist/components/separator/public.d.ts.map +1 -0
- package/dist/components/separator/separator.d.ts +6 -0
- package/dist/components/separator/separator.d.ts.map +1 -0
- package/dist/components/skeleton/public.d.ts +2 -0
- package/dist/components/skeleton/public.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +4 -0
- package/dist/components/skeleton/skeleton.d.ts.map +1 -0
- package/dist/components/switch/public.d.ts +2 -0
- package/dist/components/switch/public.d.ts.map +1 -0
- package/dist/components/switch/switch.d.ts +11 -0
- package/dist/components/switch/switch.d.ts.map +1 -0
- package/dist/components/table/public.d.ts +2 -0
- package/dist/components/table/public.d.ts.map +1 -0
- package/dist/components/table/table.d.ts +38 -0
- package/dist/components/table/table.d.ts.map +1 -0
- package/dist/components/tabs/public.d.ts +2 -0
- package/dist/components/tabs/public.d.ts.map +1 -0
- package/dist/components/tabs/tabs.d.ts +23 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -0
- package/dist/components/textarea/public.d.ts +2 -0
- package/dist/components/textarea/public.d.ts.map +1 -0
- package/dist/components/textarea/textarea.d.ts +4 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -0
- package/dist/components/toast/public.d.ts +2 -0
- package/dist/components/toast/public.d.ts.map +1 -0
- package/dist/components/toast/toast.d.ts +85 -0
- package/dist/components/toast/toast.d.ts.map +1 -0
- package/dist/components/tooltip/public.d.ts +2 -0
- package/dist/components/tooltip/public.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +41 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/dialog.d.ts +1 -0
- package/dist/dialog.js +84 -0
- package/dist/dialog.js.map +1 -0
- package/dist/docs/badge.md +82 -0
- package/dist/docs/button.md +102 -0
- package/dist/docs/card.md +131 -0
- package/dist/docs/checkbox.md +55 -0
- package/dist/docs/dialog.md +124 -0
- package/dist/docs/dropdown-menu.md +140 -0
- package/dist/docs/field.md +68 -0
- package/dist/docs/input.md +65 -0
- package/dist/docs/label.md +50 -0
- package/dist/docs/radio-group.md +59 -0
- package/dist/docs/select.md +99 -0
- package/dist/docs/separator.md +119 -0
- package/dist/docs/skeleton.md +143 -0
- package/dist/docs/switch.md +51 -0
- package/dist/docs/table.md +276 -0
- package/dist/docs/tabs.md +124 -0
- package/dist/docs/textarea.md +52 -0
- package/dist/docs/toast.md +153 -0
- package/dist/docs/tooltip.md +134 -0
- package/dist/dropdown-menu.d.ts +1 -0
- package/dist/dropdown-menu.js +183 -0
- package/dist/dropdown-menu.js.map +1 -0
- package/dist/field.d.ts +1 -0
- package/dist/field.js +28 -0
- package/dist/field.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/input.d.ts +1 -0
- package/dist/input.js +30 -0
- package/dist/input.js.map +1 -0
- package/dist/label.d.ts +1 -0
- package/dist/label.js +12 -0
- package/dist/label.js.map +1 -0
- package/dist/radio-group.d.ts +1 -0
- package/dist/radio-group.js +21 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/select.d.ts +1 -0
- package/dist/select.js +175 -0
- package/dist/select.js.map +1 -0
- package/dist/separator.d.ts +1 -0
- package/dist/separator.js +13 -0
- package/dist/separator.js.map +1 -0
- package/dist/skeleton.d.ts +1 -0
- package/dist/skeleton.js +12 -0
- package/dist/skeleton.js.map +1 -0
- package/dist/switch.d.ts +1 -0
- package/dist/switch.js +26 -0
- package/dist/switch.js.map +1 -0
- package/dist/table.d.ts +1 -0
- package/dist/table.js +64 -0
- package/dist/table.js.map +1 -0
- package/dist/tabs.d.ts +1 -0
- package/dist/tabs.js +41 -0
- package/dist/tabs.js.map +1 -0
- package/dist/textarea.d.ts +1 -0
- package/dist/textarea.js +13 -0
- package/dist/textarea.js.map +1 -0
- package/dist/theme.css +485 -0
- package/dist/toast.d.ts +1 -0
- package/dist/toast.js +193 -0
- package/dist/toast.js.map +1 -0
- package/dist/tooltip.d.ts +1 -0
- package/dist/tooltip.js +49 -0
- package/dist/tooltip.js.map +1 -0
- package/llms.txt +148 -0
- package/package.json +85 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# Table
|
|
2
|
+
|
|
3
|
+
Styled markup for a native HTML table — `<table>`/`<thead>`/`<tbody>`/
|
|
4
|
+
`<tfoot>`/`<tr>`/`<th>`/`<td>`/`<caption>`, one part per element. Table has
|
|
5
|
+
no Base UI primitive: every part is a plain styled native element, no open
|
|
6
|
+
state, no keyboard behavior of its own beyond what the browser already
|
|
7
|
+
gives a table. This is deliberately just markup — sorting, filtering,
|
|
8
|
+
pagination, virtualisation, and column definitions are all out of scope; a
|
|
9
|
+
composite `data-table` is a separate, not-yet-built component.
|
|
10
|
+
|
|
11
|
+
Composition: `Table` (root) → optional `TableCaption` → `TableHeader` (→
|
|
12
|
+
`TableRow` → `TableHead`) → `TableBody` (→ `TableRow` → `TableCell`) →
|
|
13
|
+
optional `TableFooter` (→ `TableRow` → `TableCell`). Every part except
|
|
14
|
+
`Table` itself is a passthrough over the matching native element's props —
|
|
15
|
+
no kit-specific props of its own.
|
|
16
|
+
|
|
17
|
+
## When to use
|
|
18
|
+
|
|
19
|
+
- Real tabular data: rows that share the same columns, where a screen
|
|
20
|
+
reader announcing "column 2 of 5, Status" on each cell is useful, and a
|
|
21
|
+
sighted user scanning a column vertically is a real interaction.
|
|
22
|
+
- As the markup layer under your own sorting/filtering/pagination logic —
|
|
23
|
+
Table gives you the styled elements; the behavior is yours to add.
|
|
24
|
+
|
|
25
|
+
## When not to use
|
|
26
|
+
|
|
27
|
+
- A single item's key/value details, or a summary card — use `Card`.
|
|
28
|
+
- Data you'd reach for a data grid library for (virtualised rows, resizable
|
|
29
|
+
columns, drag-to-reorder) — this kit has no such component yet; Table is
|
|
30
|
+
the markup you'd style underneath one if you build it yourself.
|
|
31
|
+
|
|
32
|
+
## The scroll wrapper
|
|
33
|
+
|
|
34
|
+
`Table` renders two elements: a wrapper `div` around the `<table>`, scrolling
|
|
35
|
+
horizontally when the table is wider than its container. This matches the
|
|
36
|
+
upstream source exactly, which takes the same view — a table that can
|
|
37
|
+
overflow needs *something* to scroll, and it's simpler for that to be
|
|
38
|
+
Table's own responsibility than to ask every consumer to remember to add a
|
|
39
|
+
wrapper.
|
|
40
|
+
|
|
41
|
+
That wrapper is also `tabIndex={0}`, which the source is not: a
|
|
42
|
+
horizontally-scrolling region with no keyboard-operable alternative to
|
|
43
|
+
dragging a scrollbar or swiping fails WCAG 2.1.1 (keyboard). With
|
|
44
|
+
`tabIndex={0}`, Tab reaches the region and the arrow keys scroll it, with a
|
|
45
|
+
focus ring around the whole table while it holds focus. This is
|
|
46
|
+
unconditional — every `Table` gets the tab stop, even one that never
|
|
47
|
+
actually overflows — rather than toggled on only once the content
|
|
48
|
+
overflows, which would need a `ResizeObserver` watching the container; that
|
|
49
|
+
kind of runtime behavior is exactly what this "primitive markup" component
|
|
50
|
+
intentionally does not have.
|
|
51
|
+
|
|
52
|
+
If you need a *vertical* scroll region too (capping a long table's height),
|
|
53
|
+
wrap your own `div` with `overflow-y` and a `max-height` around `<Table>` —
|
|
54
|
+
it composes cleanly, since your wrapper scrolls the vertical axis and
|
|
55
|
+
Table's own wrapper scrolls the horizontal one (see Examples).
|
|
56
|
+
|
|
57
|
+
A focus stop should announce something: pass `label` to name the wrapper
|
|
58
|
+
(`role="region"` + `aria-label` — a bare `div`'s `aria-label` is ignored
|
|
59
|
+
by the accessible-name algorithm without a role, which is also why
|
|
60
|
+
labelling your own outer `div` doesn't work: the name lands on a
|
|
61
|
+
non-focusable element while the focusable wrapper stays nameless).
|
|
62
|
+
Without `label` the wrapper is roleless and nameless as before. Prefer
|
|
63
|
+
passing it whenever the surrounding page doesn't make the table's purpose
|
|
64
|
+
obvious the moment focus lands. Beyond `label`, the wrapper takes no
|
|
65
|
+
props of its own — it isn't a separate export, so there's no `max-height`
|
|
66
|
+
you can pass it; for that, put your own `div` around `<Table>` (as above).
|
|
67
|
+
|
|
68
|
+
## Semantics and accessibility
|
|
69
|
+
|
|
70
|
+
Every part renders its literal matching native element — no `div` standing
|
|
71
|
+
in for a `tr`, no ARIA `role` patched onto anything — so the table keeps its
|
|
72
|
+
full implicit role structure (`table`/`rowgroup`/`row`/`columnheader`/`cell`)
|
|
73
|
+
for free, the same way a plain `<table>` you wrote by hand would. None of
|
|
74
|
+
the parts use `display: flex` or `display: grid` anywhere in their layout
|
|
75
|
+
(vertical centering is done with `vertical-align`, not a flex `align-items`)
|
|
76
|
+
— that matters because a `display` other than a table value on a
|
|
77
|
+
`tr`/`th`/`td` overrides its implicit role in most browsers, which would
|
|
78
|
+
silently turn a real table into an unlabeled pile of `div`-like boxes for
|
|
79
|
+
assistive tech.
|
|
80
|
+
|
|
81
|
+
`TableCaption` renders a real `<caption>`, which is the table's accessible
|
|
82
|
+
name/description regardless of where it's drawn on screen: `.table` sets
|
|
83
|
+
`caption-side: bottom`, so a `TableCaption` you place first in JSX (matching
|
|
84
|
+
the source's own convention) still paints below the rows, but it is exactly
|
|
85
|
+
as accessible there as `<caption>` always is — moving it visually doesn't
|
|
86
|
+
touch the accessibility tree.
|
|
87
|
+
|
|
88
|
+
The wrapper `div` around `<table>` carries no `role` of its own (see "The
|
|
89
|
+
scroll wrapper" above) — it does not stand between the table and its
|
|
90
|
+
implicit roles, since a plain ancestor `div` has no effect on a
|
|
91
|
+
descendant's own role.
|
|
92
|
+
|
|
93
|
+
## Column widths
|
|
94
|
+
|
|
95
|
+
There's no `width` prop — size a column the same way the upstream source's
|
|
96
|
+
own docs do, with a `className`/`style` width on `TableHead`/`TableCell`
|
|
97
|
+
(see Examples).
|
|
98
|
+
|
|
99
|
+
`TableHead`/`TableCell` declare `box-sizing: border-box` specifically so this
|
|
100
|
+
works: without it, the cell's own padding would add on top of the width you
|
|
101
|
+
set instead of being absorbed into it, and a `width: 100` cell would render
|
|
102
|
+
wider than 100.
|
|
103
|
+
|
|
104
|
+
## Row states
|
|
105
|
+
|
|
106
|
+
`TableRow` reads plain `data-*` attributes for its state, forwarded like any
|
|
107
|
+
other prop rather than driven by a kit-specific prop. Your own logic sets
|
|
108
|
+
the attribute; the kit only paints it. Every row renders as the Studio Data
|
|
109
|
+
Table's carded, ringed row unconditionally — the card shape (rounded
|
|
110
|
+
corners, 1px ring, raised fill) is the primitive itself, not a composition
|
|
111
|
+
layered on top of these hooks; the hooks below only change the ring's
|
|
112
|
+
color/width or lift the fill, they don't turn carding on:
|
|
113
|
+
|
|
114
|
+
- `data-state="selected"` — a 2px `--primary` ring on a `--card-hover`
|
|
115
|
+
fill, for a row the user has selected (e.g. via a leading checkbox
|
|
116
|
+
column).
|
|
117
|
+
- `data-state="stale"` — a 1px `--warning` ring, for a row whose data
|
|
118
|
+
needs attention (out-of-date sync, pending action).
|
|
119
|
+
- `data-state="restricted"` — a 1px `--danger` ring, for a row the
|
|
120
|
+
viewer lacks access to.
|
|
121
|
+
- Hover, and any row containing a descendant that is *currently*
|
|
122
|
+
`aria-expanded="true"` (e.g. a row-level disclosure toggle, only while
|
|
123
|
+
open — a collapsed toggle does not match) — the fill lifts to
|
|
124
|
+
`--card-hover`, an opaque surface one step up from the row's resting
|
|
125
|
+
`--surface-elevated` (not a translucent tint). A `data-state` ring holds
|
|
126
|
+
under hover; only the fill lifts.
|
|
127
|
+
|
|
128
|
+
The rings follow the Studio Data Table's drawn state language (colored
|
|
129
|
+
border, not a tinted surface); they are assembled from the row's cells,
|
|
130
|
+
so they only close into a rectangle when the row's cells are direct
|
|
131
|
+
children (`TableCell`/`TableHead` — the normal case).
|
|
132
|
+
|
|
133
|
+
## Props (kit level)
|
|
134
|
+
|
|
135
|
+
Two kit-specific props on `Table`: `label` (`string`) names the focusable
|
|
136
|
+
scroll wrapper with `role="region"` + `aria-label` (see above), and
|
|
137
|
+
`density` (`default` | `compact`) tightens cell padding for operational
|
|
138
|
+
views — purely cell metrics, not a data-table feature. Every other prop
|
|
139
|
+
is the matching native element's own (`ComponentProps<'table'>`,
|
|
140
|
+
`<'thead'>`, `<'tbody'>`, `<'tfoot'>`, `<'tr'>`, `<'th'>`, `<'td'>`,
|
|
141
|
+
`<'caption'>`), plus `className`, merged after the kit class on every
|
|
142
|
+
part.
|
|
143
|
+
|
|
144
|
+
## Examples
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import {
|
|
148
|
+
Table,
|
|
149
|
+
TableBody,
|
|
150
|
+
TableCaption,
|
|
151
|
+
TableCell,
|
|
152
|
+
TableFooter,
|
|
153
|
+
TableHead,
|
|
154
|
+
TableHeader,
|
|
155
|
+
TableRow,
|
|
156
|
+
} from '@gears-frontx/ui-kit';
|
|
157
|
+
|
|
158
|
+
<Table>
|
|
159
|
+
<TableCaption>A list of recent invoices.</TableCaption>
|
|
160
|
+
<TableHeader>
|
|
161
|
+
<TableRow>
|
|
162
|
+
<TableHead>Invoice</TableHead>
|
|
163
|
+
<TableHead>Status</TableHead>
|
|
164
|
+
<TableHead>Amount</TableHead>
|
|
165
|
+
</TableRow>
|
|
166
|
+
</TableHeader>
|
|
167
|
+
<TableBody>
|
|
168
|
+
<TableRow>
|
|
169
|
+
<TableCell>INV001</TableCell>
|
|
170
|
+
<TableCell>Paid</TableCell>
|
|
171
|
+
<TableCell>$250.00</TableCell>
|
|
172
|
+
</TableRow>
|
|
173
|
+
<TableRow data-state="selected">
|
|
174
|
+
<TableCell>INV002</TableCell>
|
|
175
|
+
<TableCell>Pending</TableCell>
|
|
176
|
+
<TableCell>$150.00</TableCell>
|
|
177
|
+
</TableRow>
|
|
178
|
+
</TableBody>
|
|
179
|
+
<TableFooter>
|
|
180
|
+
<TableRow>
|
|
181
|
+
<TableCell>Total</TableCell>
|
|
182
|
+
<TableCell />
|
|
183
|
+
<TableCell>$400.00</TableCell>
|
|
184
|
+
</TableRow>
|
|
185
|
+
</TableFooter>
|
|
186
|
+
</Table>;
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Sized columns, via `style`/`className` width on `TableHead`/`TableCell`
|
|
190
|
+
(see "Column widths" above for why `box-sizing: border-box` makes this
|
|
191
|
+
render at the width you set):
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@gears-frontx/ui-kit';
|
|
195
|
+
|
|
196
|
+
<Table>
|
|
197
|
+
<TableHeader>
|
|
198
|
+
<TableRow>
|
|
199
|
+
<TableHead style={{ width: 100 }}>Invoice</TableHead>
|
|
200
|
+
<TableHead>Status</TableHead>
|
|
201
|
+
</TableRow>
|
|
202
|
+
</TableHeader>
|
|
203
|
+
<TableBody>
|
|
204
|
+
<TableRow>
|
|
205
|
+
<TableCell style={{ width: 100 }}>INV001</TableCell>
|
|
206
|
+
<TableCell>Paid</TableCell>
|
|
207
|
+
</TableRow>
|
|
208
|
+
</TableBody>
|
|
209
|
+
</Table>;
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
A vertical scroll region, composed around `Table`'s own horizontal one (see
|
|
213
|
+
"The scroll wrapper" above):
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import { Table, TableBody, TableCell, TableRow } from '@gears-frontx/ui-kit';
|
|
217
|
+
|
|
218
|
+
<div style={{ maxHeight: '20rem', overflowY: 'auto' }}>
|
|
219
|
+
<Table>
|
|
220
|
+
<TableBody>
|
|
221
|
+
<TableRow>
|
|
222
|
+
<TableCell>Row 1</TableCell>
|
|
223
|
+
</TableRow>
|
|
224
|
+
</TableBody>
|
|
225
|
+
</Table>
|
|
226
|
+
</div>;
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
A row with a leading checkbox column, sized flush against the cell edge by
|
|
230
|
+
the source's own `:has([role=checkbox])` rule (built into `.tableHead`/
|
|
231
|
+
`.tableCell`, no extra class needed):
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
import { Checkbox, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@gears-frontx/ui-kit';
|
|
235
|
+
|
|
236
|
+
<Table>
|
|
237
|
+
<TableHeader>
|
|
238
|
+
<TableRow>
|
|
239
|
+
<TableHead>
|
|
240
|
+
<Checkbox aria-label="Select all" />
|
|
241
|
+
</TableHead>
|
|
242
|
+
<TableHead>Name</TableHead>
|
|
243
|
+
</TableRow>
|
|
244
|
+
</TableHeader>
|
|
245
|
+
<TableBody>
|
|
246
|
+
<TableRow>
|
|
247
|
+
<TableCell>
|
|
248
|
+
<Checkbox aria-label="Select row" />
|
|
249
|
+
</TableCell>
|
|
250
|
+
<TableCell>Acme Inc.</TableCell>
|
|
251
|
+
</TableRow>
|
|
252
|
+
</TableBody>
|
|
253
|
+
</Table>;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Anti-patterns
|
|
257
|
+
|
|
258
|
+
- Do not reach for `Table` for a single record's key/value pairs or a
|
|
259
|
+
summary — that's `Card`, not a one-row table.
|
|
260
|
+
- Do not expect sorting, filtering, pagination, row selection state, or
|
|
261
|
+
column definitions — none of that is here; this is markup only. Wire
|
|
262
|
+
your own logic and drive `data-state`/`aria-*` attributes yourself.
|
|
263
|
+
- Do not assume the scroll wrapper's `tabIndex={0}` announces anything to
|
|
264
|
+
screen readers on its own — it restores keyboard *operability* of the
|
|
265
|
+
scroll, not a spoken label; the table inside still carries its own
|
|
266
|
+
accessible name via `TableCaption` (or `aria-label`/`aria-labelledby` on
|
|
267
|
+
`Table` itself) exactly as it would without the wrapper.
|
|
268
|
+
- Do not add `display: flex`/`display: grid` to a `TableRow`/`TableHead`/
|
|
269
|
+
`TableCell` via `className` — that overrides the element's implicit
|
|
270
|
+
table role in most browsers, turning it into an unlabeled box for
|
|
271
|
+
assistive tech even though it still looks like a table row visually.
|
|
272
|
+
- Do not override `TableHead`/`TableCell`'s `box-sizing: border-box` back
|
|
273
|
+
to `content-box` via `className` — that's what makes a `width` set on
|
|
274
|
+
either one behave as documented in "Column widths" above; undoing it
|
|
275
|
+
reopens the same padding-inflates-past-width bug the source relies on
|
|
276
|
+
Tailwind's global preflight to avoid.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Tabs
|
|
2
|
+
|
|
3
|
+
Switch between panels that share the same screen space, one visible at a
|
|
4
|
+
time. Wraps the Base UI Tabs primitives (`Root`/`List`/`Tab`/`Panel` —
|
|
5
|
+
this kit renders them as `Tabs`/`TabsList`/`TabsTrigger`/`TabsContent` to
|
|
6
|
+
match the names generated code and shadcn docs expect); keyboard
|
|
7
|
+
navigation between tabs, `role="tablist"`/`role="tab"`/`role="tabpanel"`
|
|
8
|
+
wiring, and mounting only the active panel (by default) come from Base
|
|
9
|
+
UI. No portal — every part renders in place.
|
|
10
|
+
|
|
11
|
+
Composition: `Tabs` (root, holds the selected value) → `TabsList` (→ one
|
|
12
|
+
`TabsTrigger` per tab) → one `TabsContent` per tab, matched to its trigger
|
|
13
|
+
by `value`.
|
|
14
|
+
|
|
15
|
+
## When to use
|
|
16
|
+
|
|
17
|
+
- Grouping related views that don't need to be compared side by side —
|
|
18
|
+
settings sections, a form split into steps shown one at a time.
|
|
19
|
+
- Switching between differently-shaped content behind a shared header,
|
|
20
|
+
where only one need be visible or interactive at once.
|
|
21
|
+
|
|
22
|
+
## When not to use
|
|
23
|
+
|
|
24
|
+
- Sequential, gated steps with validation between them (a wizard) — tabs
|
|
25
|
+
imply free jumping between all of them; build a stepper instead.
|
|
26
|
+
- Content the user needs to compare at a glance — tabs hide every panel
|
|
27
|
+
but one.
|
|
28
|
+
- A small number of mutually exclusive actions, not content panels — use
|
|
29
|
+
`dropdown-menu` or a `button` group instead.
|
|
30
|
+
|
|
31
|
+
## Props (kit level)
|
|
32
|
+
|
|
33
|
+
`Tabs` (root):
|
|
34
|
+
|
|
35
|
+
| Prop | Type | Default |
|
|
36
|
+
|------|------|---------|
|
|
37
|
+
| `value` / `defaultValue` | controlled / uncontrolled selected tab | — (defaults to the first enabled tab; see Anti-patterns for an SSR caveat) |
|
|
38
|
+
| `onValueChange` | `(value, eventDetails) => void` | — |
|
|
39
|
+
| `orientation` | `horizontal` \| `vertical` | `horizontal` |
|
|
40
|
+
| `className` | `string` — merged after the kit class | — |
|
|
41
|
+
|
|
42
|
+
`TabsList`:
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Default |
|
|
45
|
+
|------|------|---------|
|
|
46
|
+
| `variant` | `default` \| `line` — `default` is a trackless list where the active tab gets its own raised background (`--surface-elevated`); `line` is a flat row where the active tab is marked by an underline instead. A bordered segmented-control look is NOT a Tabs variant — that styling belongs to the planned `toggle-group` component | `default` |
|
|
47
|
+
| `className` | `string` — merged after the kit class | — |
|
|
48
|
+
|
|
49
|
+
`TabsTrigger`: `value` (required, matches a `TabsContent`), `disabled`;
|
|
50
|
+
other props follow Base UI `Tabs.Tab`. Renders a native `<button>`.
|
|
51
|
+
|
|
52
|
+
`TabsContent`: `value` (required, matches a `TabsTrigger`), `keepMounted`
|
|
53
|
+
(keep the panel in the DOM while inactive instead of unmounting it —
|
|
54
|
+
`false` by default); other props follow Base UI `Tabs.Panel`.
|
|
55
|
+
|
|
56
|
+
Set `orientation="vertical"` on `Tabs` for a sidebar-style layout (list on
|
|
57
|
+
the side, panel beside it instead of below it) — every part reads its own
|
|
58
|
+
`data-orientation`, so no other prop changes.
|
|
59
|
+
|
|
60
|
+
## Examples
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@gears-frontx/ui-kit';
|
|
64
|
+
|
|
65
|
+
<Tabs defaultValue="account">
|
|
66
|
+
<TabsList>
|
|
67
|
+
<TabsTrigger value="account">Account</TabsTrigger>
|
|
68
|
+
<TabsTrigger value="password">Password</TabsTrigger>
|
|
69
|
+
</TabsList>
|
|
70
|
+
<TabsContent value="account">
|
|
71
|
+
<p>Update your account details here.</p>
|
|
72
|
+
</TabsContent>
|
|
73
|
+
<TabsContent value="password">
|
|
74
|
+
<p>Change your password here.</p>
|
|
75
|
+
</TabsContent>
|
|
76
|
+
</Tabs>;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
A flat, underlined list (`variant="line"`), vertical, sized to a sidebar:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@gears-frontx/ui-kit';
|
|
83
|
+
|
|
84
|
+
<Tabs defaultValue="general" orientation="vertical">
|
|
85
|
+
<TabsList variant="line">
|
|
86
|
+
<TabsTrigger value="general">General</TabsTrigger>
|
|
87
|
+
<TabsTrigger value="billing">Billing</TabsTrigger>
|
|
88
|
+
<TabsTrigger value="team" disabled>
|
|
89
|
+
Team (soon)
|
|
90
|
+
</TabsTrigger>
|
|
91
|
+
</TabsList>
|
|
92
|
+
<TabsContent value="general">
|
|
93
|
+
<p>General settings.</p>
|
|
94
|
+
</TabsContent>
|
|
95
|
+
<TabsContent value="billing">
|
|
96
|
+
<p>Billing settings.</p>
|
|
97
|
+
</TabsContent>
|
|
98
|
+
<TabsContent value="team">
|
|
99
|
+
<p>Team settings.</p>
|
|
100
|
+
</TabsContent>
|
|
101
|
+
</Tabs>;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Anti-patterns
|
|
105
|
+
|
|
106
|
+
- Do not give two `TabsTrigger`/`TabsContent` pairs the same `value` —
|
|
107
|
+
Base UI matches a panel to its tab by exact `value` equality, and a
|
|
108
|
+
duplicate leaves one panel unreachable.
|
|
109
|
+
- Do not rely on inactive panels keeping component state (scroll
|
|
110
|
+
position, uncommitted form input) unless you pass `keepMounted` — by
|
|
111
|
+
default an inactive panel unmounts, and remounts from scratch when
|
|
112
|
+
reselected.
|
|
113
|
+
- Do not reach for `variant="line"` expecting an animated highlight that
|
|
114
|
+
slides between tabs — the underline is a per-tab crossfade, not a
|
|
115
|
+
single element in motion.
|
|
116
|
+
- Do not omit `defaultValue`/`value` and leave the first `TabsTrigger`
|
|
117
|
+
disabled — Base UI falls back to the next enabled tab client-side, but
|
|
118
|
+
it can't do that during server-side rendering (it doesn't yet know
|
|
119
|
+
which tabs are disabled while pre-rendering), so the server- and
|
|
120
|
+
client-rendered output disagree. Set `defaultValue`/`value` explicitly
|
|
121
|
+
to an enabled tab's value whenever the first one might be disabled.
|
|
122
|
+
- Do not expect an icon placed inside a `TabsTrigger` to be auto-sized —
|
|
123
|
+
unlike some shadcn components, this kit has no `data-icon`/generic
|
|
124
|
+
`svg` sizing convention yet; size your own icon via `className`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Textarea
|
|
2
|
+
|
|
3
|
+
A multi-line text field. A styled native `<textarea>` — no primitive is
|
|
4
|
+
needed. Grows with its content in browsers that support `field-sizing`;
|
|
5
|
+
elsewhere it keeps the native resize handle.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Multi-line free text: descriptions, comments, messages.
|
|
10
|
+
- Inside a `Field` to get label association and validation display for
|
|
11
|
+
free — it registers with the surrounding Field like `Input` does.
|
|
12
|
+
|
|
13
|
+
## When not to use
|
|
14
|
+
|
|
15
|
+
- Single-line values — use `input`.
|
|
16
|
+
- Rich text — out of the kit's scope; bring an editor and style it with
|
|
17
|
+
theme tokens.
|
|
18
|
+
|
|
19
|
+
## Props (kit level)
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Default |
|
|
22
|
+
|------|------|---------|
|
|
23
|
+
| `className` | `string` — merged after the kit class | — |
|
|
24
|
+
|
|
25
|
+
All other props are native `<textarea>` props (`value`, `onChange`,
|
|
26
|
+
`placeholder`, `disabled`, `rows`, `aria-invalid`, ...) and are forwarded
|
|
27
|
+
as-is. `aria-invalid` switches the border and ring to the destructive color.
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { Textarea } from '@gears-frontx/ui-kit';
|
|
33
|
+
|
|
34
|
+
// Uncontrolled
|
|
35
|
+
<Textarea placeholder="Describe the issue…" />
|
|
36
|
+
|
|
37
|
+
// Controlled
|
|
38
|
+
<Textarea value={notes} onChange={(e) => setNotes(e.target.value)} />
|
|
39
|
+
|
|
40
|
+
// Fixed starting height via rows
|
|
41
|
+
<Textarea rows={6} defaultValue={draft} />
|
|
42
|
+
|
|
43
|
+
// Invalid state
|
|
44
|
+
<Textarea aria-invalid={true} defaultValue={tooLong} />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Anti-patterns
|
|
48
|
+
|
|
49
|
+
- Do not fix the height with inline styles — pass `rows` or set a
|
|
50
|
+
`max-height` in the consumer layout; the field sizes itself to content.
|
|
51
|
+
- Do not use it for single-line values just to get a bigger hit target —
|
|
52
|
+
use `input`; sizing belongs to layout.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
A brief, transient notification stacked bottom-right of the viewport.
|
|
4
|
+
Wraps Base UI's Toast primitives (`@base-ui/react/toast`), not sonner —
|
|
5
|
+
sonner would pull in `sonner` + `next-themes` as extra runtime
|
|
6
|
+
dependencies, breaking the kit's "behavior from Base UI, no extra deps"
|
|
7
|
+
architecture for one component. Unlike `Dialog`/`DropdownMenu`/
|
|
8
|
+
`Tooltip`, a toast isn't composed as JSX at the call site — it's fired
|
|
9
|
+
imperatively from anywhere in the app, the same call-anywhere ergonomics
|
|
10
|
+
sonner is known for, kept here through Base UI's own manager object
|
|
11
|
+
instead. Mount `Toaster` once, then call `toast.add({ ... })` to show
|
|
12
|
+
one.
|
|
13
|
+
|
|
14
|
+
Composition: mount `Toaster` once — internally it wraps Base UI's
|
|
15
|
+
Toast provider, portal, and viewport, and renders whatever toasts the
|
|
16
|
+
manager holds using the kit's own card layout (title, description,
|
|
17
|
+
type icon, optional action, close button); none of those internal
|
|
18
|
+
parts are exported. Call the shared `toast` manager's
|
|
19
|
+
`add`/`close`/`update`/`promise` to control what's shown; no manual
|
|
20
|
+
composition of individual toast parts.
|
|
21
|
+
|
|
22
|
+
## When to use
|
|
23
|
+
|
|
24
|
+
- Brief, non-blocking feedback about the result of an action the user
|
|
25
|
+
just took (saved, uploaded, undo available) that doesn't need to
|
|
26
|
+
interrupt them.
|
|
27
|
+
|
|
28
|
+
## When not to use
|
|
29
|
+
|
|
30
|
+
- Content the user must read or decide on before continuing — use
|
|
31
|
+
`dialog`.
|
|
32
|
+
- A persistent status that should stay visible until explicitly
|
|
33
|
+
dismissed by something other than a timeout or swipe — a toast times
|
|
34
|
+
out automatically by design.
|
|
35
|
+
- Essential information with no other channel — a toast can be missed
|
|
36
|
+
(auto-dismiss, easy to swipe away) and isn't a substitute for inline
|
|
37
|
+
validation or page content.
|
|
38
|
+
|
|
39
|
+
## Props (kit level)
|
|
40
|
+
|
|
41
|
+
`Toaster`: `timeout` (ms before a toast auto-dismisses, `0` disables it,
|
|
42
|
+
default `5000`), `limit` (max toasts shown at once, default `3`;
|
|
43
|
+
overflow toasts stay mounted with `data-limited` rather than being
|
|
44
|
+
removed, so they can reappear as space frees up), `toastManager`
|
|
45
|
+
(defaults to the shared `toast` manager below), `container` (DOM node to
|
|
46
|
+
portal the toast viewport into, default `<body>`), `closeLabel`
|
|
47
|
+
(accessible name for each toast's close (X) button, default
|
|
48
|
+
`'Close toast'`), `label` (accessible name for the toast region landmark,
|
|
49
|
+
default `'Notifications'`) — `closeLabel` and `label` are the two strings
|
|
50
|
+
a non-English app needs to replace, `children` — wrap the
|
|
51
|
+
app (or at least any subtree calling `useToastManager`) so it can reach
|
|
52
|
+
the manager via context; the toast viewport itself always portals
|
|
53
|
+
regardless of where `Toaster` sits in the tree.
|
|
54
|
+
|
|
55
|
+
`toast` — the shared manager. Call from anywhere, no hook or ancestor
|
|
56
|
+
required:
|
|
57
|
+
|
|
58
|
+
| Method | Use |
|
|
59
|
+
|--------|-----|
|
|
60
|
+
| `toast.add({ title, description?, type?, timeout?, actionProps? })` | Show a toast; returns its `id`. |
|
|
61
|
+
| `toast.close(id?)` | Dismiss one toast, or every toast if `id` is omitted. |
|
|
62
|
+
| `toast.update(id, { ... })` | Update a toast in place and refresh its timer. |
|
|
63
|
+
| `toast.promise(promise, { loading, success, error })` | One toast that morphs through loading → success/error. |
|
|
64
|
+
|
|
65
|
+
`type` drives the built-in icon: `success` \| `info` \| `warning` \|
|
|
66
|
+
`error` \| `loading` (spins, 4x slower under `prefers-reduced-motion:
|
|
67
|
+
reduce` rather than stopping — it's the only cue a `loading` toast is
|
|
68
|
+
still pending); omit it for no icon. `actionProps` (native
|
|
69
|
+
`<button>` props, e.g. `{ children: 'Undo', onClick }`) renders an
|
|
70
|
+
outline action button beside the close button; omit it and none
|
|
71
|
+
renders.
|
|
72
|
+
|
|
73
|
+
The card's own motion — the stacking/scale math, expand-on-hover, and
|
|
74
|
+
entry/exit/swipe slides — is suppressed under `prefers-reduced-motion:
|
|
75
|
+
reduce`; toasts snap straight to position instead of sliding or
|
|
76
|
+
resizing. Their opacity fades keep playing regardless — a fade isn't
|
|
77
|
+
motion in the sense the OS preference is asking to reduce.
|
|
78
|
+
|
|
79
|
+
`createToastManager()` / `useToastManager()` are re-exported for
|
|
80
|
+
advanced cases: `createToastManager()` makes an isolated manager
|
|
81
|
+
independent of the shared `toast` singleton (e.g. a second, differently
|
|
82
|
+
positioned `Toaster` scoped to one part of the app). `useToastManager()`
|
|
83
|
+
reads the live toast list and the same `add`/`close`/`update`/`promise`
|
|
84
|
+
bound to whichever manager the nearest `Toaster` ancestor uses — from a
|
|
85
|
+
component nested under `Toaster`, this is how you react to the toast
|
|
86
|
+
list itself (an unread-count badge, "N toasts pending") or call that
|
|
87
|
+
same manager without importing it directly. It is **not** a way to
|
|
88
|
+
render your own toast cards in place of `Toaster`: the kit doesn't
|
|
89
|
+
export the underlying Root/Content/Title/etc. parts.
|
|
90
|
+
|
|
91
|
+
Whether your own `@base-ui/react` shares this context depends on how it
|
|
92
|
+
resolves. `@base-ui/react` is a regular dependency of this package and
|
|
93
|
+
stays external in the build, so if your range is satisfied by the same
|
|
94
|
+
version your installer dedupes to one copy and the context is shared; if
|
|
95
|
+
you pin an incompatible version you get a second copy, and Base UI's
|
|
96
|
+
Toast context — like any React context — does not cross between the two.
|
|
97
|
+
|
|
98
|
+
`toast` is a module-scope singleton, which has three failure modes worth
|
|
99
|
+
knowing rather than debugging blind: it's safe under SSR (it holds no
|
|
100
|
+
toast state itself, only a listener registered by whichever `Toaster`
|
|
101
|
+
is mounted), but calling `toast.add(...)` before any `Toaster` has
|
|
102
|
+
mounted, or from code that resolved a different copy of this package
|
|
103
|
+
(e.g. a mixed CJS/ESM module graph), drops the toast silently — no
|
|
104
|
+
error, nothing queued, it just never appears. The third is the inverse:
|
|
105
|
+
mounting **two** `Toaster`s on the shared singleton (plausible in a
|
|
106
|
+
shell + MFE setup where each fragment mounts its own) renders every
|
|
107
|
+
toast twice, once per viewport. If a subtree genuinely needs its own
|
|
108
|
+
viewport, give it an isolated manager via `createToastManager()` and
|
|
109
|
+
pass that as its `Toaster`'s `toastManager`.
|
|
110
|
+
|
|
111
|
+
The viewport portals to `<body>` by default, so if your theme lives on a
|
|
112
|
+
subtree (`data-theme` on a section instead of `<html>`), pass that
|
|
113
|
+
section as `Toaster`'s `container` or toasts render with the root theme
|
|
114
|
+
— same contract as `Dialog`, `Select`, `DropdownMenu`, and `Tooltip`.
|
|
115
|
+
|
|
116
|
+
## Examples
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import type { ReactNode } from 'react';
|
|
120
|
+
import { Toaster, toast } from '@gears-frontx/ui-kit';
|
|
121
|
+
|
|
122
|
+
// Once, near the app root — wrap the app so any subtree can reach the
|
|
123
|
+
// manager via useToastManager; the shared `toast` singleton below works
|
|
124
|
+
// from anywhere in the tree regardless.
|
|
125
|
+
function Root({ children }: { children: ReactNode }) {
|
|
126
|
+
return <Toaster>{children}</Toaster>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// From anywhere else in the app:
|
|
130
|
+
toast.add({ title: 'Saved', description: 'Your changes have been saved.' });
|
|
131
|
+
toast.add({ type: 'error', title: 'Failed to save', description: 'Check your connection and retry.' });
|
|
132
|
+
toast.add({
|
|
133
|
+
title: 'File deleted',
|
|
134
|
+
actionProps: { children: 'Undo', onClick: handleUndo },
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
toast.promise(saveDraft(), {
|
|
138
|
+
loading: 'Saving…',
|
|
139
|
+
success: 'Saved',
|
|
140
|
+
error: (thrown) => (thrown instanceof Error ? thrown.message : 'Failed to save'),
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Anti-patterns
|
|
145
|
+
|
|
146
|
+
- Do not use `Toast` for a confirmation the user must act on before
|
|
147
|
+
continuing — a toast times out and can be swiped away; use `dialog`.
|
|
148
|
+
- Do not chain multiple unrelated pieces of information into one toast
|
|
149
|
+
— fire separate toasts, or use `update` to change one in place, rather
|
|
150
|
+
than growing a single toast's `description` into a paragraph.
|
|
151
|
+
- Do not rely on a toast as the only place an error is shown — it can be
|
|
152
|
+
missed; pair it with inline form/field errors where the user is
|
|
153
|
+
already looking.
|