@dashforge/tw 0.1.0-beta → 0.2.0-beta
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/CHANGELOG.md +108 -0
- package/dist/index.d.ts +1 -82
- package/dist/index.esm.js +1563 -2
- package/dist/src/components/AspectRatio/AspectRatio.d.ts +36 -0
- package/dist/src/components/AspectRatio/AspectRatio.d.ts.map +1 -0
- package/dist/src/components/AspectRatio/aspectRatio.types.d.ts +50 -0
- package/dist/src/components/AspectRatio/aspectRatio.types.d.ts.map +1 -0
- package/dist/src/components/Box/Box.d.ts +36 -0
- package/dist/src/components/Box/Box.d.ts.map +1 -0
- package/dist/src/components/Box/box.types.d.ts +54 -0
- package/dist/src/components/Box/box.types.d.ts.map +1 -0
- package/dist/src/components/Box/box.variants.d.ts +402 -0
- package/dist/src/components/Box/box.variants.d.ts.map +1 -0
- package/dist/src/components/Container/Container.d.ts +35 -0
- package/dist/src/components/Container/Container.d.ts.map +1 -0
- package/dist/src/components/Container/container.types.d.ts +41 -0
- package/dist/src/components/Container/container.types.d.ts.map +1 -0
- package/dist/src/components/Container/container.variants.d.ts +93 -0
- package/dist/src/components/Container/container.variants.d.ts.map +1 -0
- package/dist/src/components/Divider/Divider.d.ts +50 -0
- package/dist/src/components/Divider/Divider.d.ts.map +1 -0
- package/dist/src/components/Divider/divider.types.d.ts +47 -0
- package/dist/src/components/Divider/divider.types.d.ts.map +1 -0
- package/dist/src/components/Divider/divider.variants.d.ts +129 -0
- package/dist/src/components/Divider/divider.variants.d.ts.map +1 -0
- package/dist/src/components/Grid/Grid.d.ts +32 -0
- package/dist/src/components/Grid/Grid.d.ts.map +1 -0
- package/dist/src/components/Grid/grid.types.d.ts +103 -0
- package/dist/src/components/Grid/grid.types.d.ts.map +1 -0
- package/dist/src/components/Grid/grid.variants.d.ts +453 -0
- package/dist/src/components/Grid/grid.variants.d.ts.map +1 -0
- package/dist/src/components/Stack/Stack.d.ts +24 -0
- package/dist/src/components/Stack/Stack.d.ts.map +1 -0
- package/dist/src/components/Stack/stack.types.d.ts +61 -0
- package/dist/src/components/Stack/stack.types.d.ts.map +1 -0
- package/dist/src/components/Stack/stack.variants.d.ts +163 -0
- package/dist/src/components/Stack/stack.variants.d.ts.map +1 -0
- package/dist/src/components/Typography/Typography.d.ts +42 -0
- package/dist/src/components/Typography/Typography.d.ts.map +1 -0
- package/dist/src/components/Typography/typography.types.d.ts +61 -0
- package/dist/src/components/Typography/typography.types.d.ts.map +1 -0
- package/dist/src/components/Typography/typography.variants.d.ts +167 -0
- package/dist/src/components/Typography/typography.variants.d.ts.map +1 -0
- package/dist/src/components/VisuallyHidden/VisuallyHidden.d.ts +42 -0
- package/dist/src/components/VisuallyHidden/VisuallyHidden.d.ts.map +1 -0
- package/dist/src/components/VisuallyHidden/visuallyHidden.types.d.ts +42 -0
- package/dist/src/components/VisuallyHidden/visuallyHidden.types.d.ts.map +1 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/AspectRatio/AspectRatio.test.tsx +173 -0
- package/src/components/AspectRatio/AspectRatio.tsx +73 -0
- package/src/components/AspectRatio/aspectRatio.types.ts +54 -0
- package/src/components/Box/Box.test.tsx +349 -0
- package/src/components/Box/Box.tsx +83 -0
- package/src/components/Box/box.types.ts +61 -0
- package/src/components/Box/box.variants.ts +211 -0
- package/src/components/Container/Container.test.tsx +209 -0
- package/src/components/Container/Container.tsx +74 -0
- package/src/components/Container/container.types.ts +45 -0
- package/src/components/Container/container.variants.ts +81 -0
- package/src/components/Divider/Divider.test.tsx +241 -0
- package/src/components/Divider/Divider.tsx +140 -0
- package/src/components/Divider/divider.types.ts +52 -0
- package/src/components/Divider/divider.variants.ts +115 -0
- package/src/components/Grid/Grid.test.tsx +321 -0
- package/src/components/Grid/Grid.tsx +148 -0
- package/src/components/Grid/grid.types.ts +112 -0
- package/src/components/Grid/grid.variants.ts +133 -0
- package/src/components/Stack/Stack.test.tsx +309 -0
- package/src/components/Stack/Stack.tsx +115 -0
- package/src/components/Stack/stack.types.ts +68 -0
- package/src/components/Stack/stack.variants.ts +80 -0
- package/src/components/Typography/Typography.test.tsx +230 -0
- package/src/components/Typography/Typography.tsx +112 -0
- package/src/components/Typography/typography.types.ts +65 -0
- package/src/components/Typography/typography.variants.ts +113 -0
- package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +86 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +59 -0
- package/src/components/VisuallyHidden/visuallyHidden.types.ts +45 -0
- package/src/index.ts +49 -0
- package/dist/components/AppShell/AppShell.d.ts +0 -32
- package/dist/components/AppShell/AppShell.d.ts.map +0 -1
- package/dist/components/AppShell/appShell.types.d.ts +0 -62
- package/dist/components/AppShell/appShell.types.d.ts.map +0 -1
- package/dist/components/AppShell/appShell.variants.d.ts +0 -65
- package/dist/components/AppShell/appShell.variants.d.ts.map +0 -1
- package/dist/components/Autocomplete/Autocomplete.d.ts +0 -32
- package/dist/components/Autocomplete/Autocomplete.d.ts.map +0 -1
- package/dist/components/Autocomplete/autocomplete.types.d.ts +0 -214
- package/dist/components/Autocomplete/autocomplete.types.d.ts.map +0 -1
- package/dist/components/Autocomplete/autocomplete.variants.d.ts +0 -214
- package/dist/components/Autocomplete/autocomplete.variants.d.ts.map +0 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +0 -23
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts.map +0 -1
- package/dist/components/Breadcrumbs/breadcrumbs.types.d.ts +0 -98
- package/dist/components/Breadcrumbs/breadcrumbs.types.d.ts.map +0 -1
- package/dist/components/Breadcrumbs/breadcrumbs.variants.d.ts +0 -85
- package/dist/components/Breadcrumbs/breadcrumbs.variants.d.ts.map +0 -1
- package/dist/components/Button/Button.d.ts +0 -44
- package/dist/components/Button/Button.d.ts.map +0 -1
- package/dist/components/Button/button.types.d.ts +0 -66
- package/dist/components/Button/button.types.d.ts.map +0 -1
- package/dist/components/Button/button.variants.d.ts +0 -104
- package/dist/components/Button/button.variants.d.ts.map +0 -1
- package/dist/components/Checkbox/Checkbox.d.ts +0 -31
- package/dist/components/Checkbox/Checkbox.d.ts.map +0 -1
- package/dist/components/Checkbox/checkbox.types.d.ts +0 -86
- package/dist/components/Checkbox/checkbox.types.d.ts.map +0 -1
- package/dist/components/Checkbox/checkbox.variants.d.ts +0 -109
- package/dist/components/Checkbox/checkbox.variants.d.ts.map +0 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts +0 -38
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts.map +0 -1
- package/dist/components/ConfirmDialog/confirmDialog.types.d.ts +0 -80
- package/dist/components/ConfirmDialog/confirmDialog.types.d.ts.map +0 -1
- package/dist/components/ConfirmDialog/confirmDialog.variants.d.ts +0 -90
- package/dist/components/ConfirmDialog/confirmDialog.variants.d.ts.map +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -49
- package/dist/components/DateTimePicker/DateTimePicker.d.ts.map +0 -1
- package/dist/components/DateTimePicker/dateTimePicker.types.d.ts +0 -95
- package/dist/components/DateTimePicker/dateTimePicker.types.d.ts.map +0 -1
- package/dist/components/DateTimePicker/dateTimePicker.variants.d.ts +0 -165
- package/dist/components/DateTimePicker/dateTimePicker.variants.d.ts.map +0 -1
- package/dist/components/LeftNav/LeftNav.d.ts +0 -34
- package/dist/components/LeftNav/LeftNav.d.ts.map +0 -1
- package/dist/components/LeftNav/leftNav.types.d.ts +0 -136
- package/dist/components/LeftNav/leftNav.types.d.ts.map +0 -1
- package/dist/components/LeftNav/leftNav.variants.d.ts +0 -143
- package/dist/components/LeftNav/leftNav.variants.d.ts.map +0 -1
- package/dist/components/NumberField/NumberField.d.ts +0 -18
- package/dist/components/NumberField/NumberField.d.ts.map +0 -1
- package/dist/components/NumberField/numberField.types.d.ts +0 -79
- package/dist/components/NumberField/numberField.types.d.ts.map +0 -1
- package/dist/components/NumberField/numberField.variants.d.ts +0 -169
- package/dist/components/NumberField/numberField.variants.d.ts.map +0 -1
- package/dist/components/OTPField/OTPField.d.ts +0 -25
- package/dist/components/OTPField/OTPField.d.ts.map +0 -1
- package/dist/components/OTPField/otpField.types.d.ts +0 -74
- package/dist/components/OTPField/otpField.types.d.ts.map +0 -1
- package/dist/components/OTPField/otpField.variants.d.ts +0 -105
- package/dist/components/OTPField/otpField.variants.d.ts.map +0 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +0 -35
- package/dist/components/RadioGroup/RadioGroup.d.ts.map +0 -1
- package/dist/components/RadioGroup/radioGroup.types.d.ts +0 -103
- package/dist/components/RadioGroup/radioGroup.types.d.ts.map +0 -1
- package/dist/components/RadioGroup/radioGroup.variants.d.ts +0 -166
- package/dist/components/RadioGroup/radioGroup.variants.d.ts.map +0 -1
- package/dist/components/Snackbar/Snackbar.d.ts +0 -37
- package/dist/components/Snackbar/Snackbar.d.ts.map +0 -1
- package/dist/components/Snackbar/snackbar.types.d.ts +0 -86
- package/dist/components/Snackbar/snackbar.types.d.ts.map +0 -1
- package/dist/components/Snackbar/snackbar.variants.d.ts +0 -153
- package/dist/components/Snackbar/snackbar.variants.d.ts.map +0 -1
- package/dist/components/Switch/Switch.d.ts +0 -15
- package/dist/components/Switch/Switch.d.ts.map +0 -1
- package/dist/components/Switch/switch.types.d.ts +0 -47
- package/dist/components/Switch/switch.types.d.ts.map +0 -1
- package/dist/components/Switch/switch.variants.d.ts +0 -105
- package/dist/components/Switch/switch.variants.d.ts.map +0 -1
- package/dist/components/TextField/TextField.d.ts +0 -25
- package/dist/components/TextField/TextField.d.ts.map +0 -1
- package/dist/components/TextField/textField.types.d.ts +0 -72
- package/dist/components/TextField/textField.types.d.ts.map +0 -1
- package/dist/components/TextField/textField.variants.d.ts +0 -160
- package/dist/components/TextField/textField.variants.d.ts.map +0 -1
- package/dist/components/Textarea/Textarea.d.ts +0 -16
- package/dist/components/Textarea/Textarea.d.ts.map +0 -1
- package/dist/components/Textarea/textarea.types.d.ts +0 -63
- package/dist/components/Textarea/textarea.types.d.ts.map +0 -1
- package/dist/components/Textarea/textarea.variants.d.ts +0 -197
- package/dist/components/Textarea/textarea.variants.d.ts.map +0 -1
- package/dist/components/TopBar/TopBar.d.ts +0 -33
- package/dist/components/TopBar/TopBar.d.ts.map +0 -1
- package/dist/components/TopBar/topBar.types.d.ts +0 -49
- package/dist/components/TopBar/topBar.types.d.ts.map +0 -1
- package/dist/components/TopBar/topBar.variants.d.ts +0 -79
- package/dist/components/TopBar/topBar.variants.d.ts.map +0 -1
- package/dist/components/_shared/resolveValidationState.d.ts +0 -42
- package/dist/components/_shared/resolveValidationState.d.ts.map +0 -1
- package/dist/hooks/useAccessState.d.ts +0 -37
- package/dist/hooks/useAccessState.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
- package/dist/utils/cn.d.ts +0 -26
- package/dist/utils/cn.d.ts.map +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { tv, type VariantProps } from 'tailwind-variants';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `gridVariants` — CSS Grid container + item, polymorphic in role.
|
|
5
|
+
*
|
|
6
|
+
* Architectural choice (planned with the user — F9 deep dive):
|
|
7
|
+
*
|
|
8
|
+
* Pattern is MUI Grid v2 from the API side (`<Grid container>` +
|
|
9
|
+
* `<Grid xs={6}>`), but engine is REAL CSS Grid under the hood
|
|
10
|
+
* (`display: grid` + `grid-template-columns: repeat(N, 1fr)` +
|
|
11
|
+
* `col-span-*`). MUI v2 uses flexbox + basis percentages — historical
|
|
12
|
+
* IE11 reasons. In 2026, CSS Grid is universally supported AND
|
|
13
|
+
* Tailwind ships `grid-cols-*` / `col-span-*` natively, so flexbox
|
|
14
|
+
* would be a downgrade.
|
|
15
|
+
*
|
|
16
|
+
* Two distinct shapes coexist in the same TV recipe:
|
|
17
|
+
*
|
|
18
|
+
* • container=true — display:grid + cols + gap + autoFlow
|
|
19
|
+
* • container=false — col-span at each breakpoint (xs/sm/md/lg/xl)
|
|
20
|
+
*
|
|
21
|
+
* The discriminated union lives in grid.types.ts (TypeScript-level);
|
|
22
|
+
* here the TV catalogue exposes every axis so the consumer's choice
|
|
23
|
+
* triggers the right classes regardless of which role the component
|
|
24
|
+
* is playing. Unused axes produce no classes (TV silently drops
|
|
25
|
+
* undefined variants), so a container Grid never accidentally emits
|
|
26
|
+
* `col-span-6` and an item Grid never accidentally emits `grid`.
|
|
27
|
+
*
|
|
28
|
+
* Mapping table size:
|
|
29
|
+
* • cols : 6 entries (12, 6, 4, 3, 2, 1)
|
|
30
|
+
* • autoFlow : 5 entries
|
|
31
|
+
* • span axes (5×14) : 70 entries (xs/sm/md/lg/xl × {1..12, auto, full})
|
|
32
|
+
* • gap / gapX / gapY : 33 entries (11 steps × 3 axes)
|
|
33
|
+
*
|
|
34
|
+
* Total: ~115 literal class names. All explicit, all Tailwind-scannable.
|
|
35
|
+
* Bundle CSS impact when fully exercised: ~3 KB gz (mostly the
|
|
36
|
+
* responsive col-span set).
|
|
37
|
+
*/
|
|
38
|
+
export const gridVariants = tv({
|
|
39
|
+
base: '',
|
|
40
|
+
|
|
41
|
+
variants: {
|
|
42
|
+
// ─── CONTAINER role ────────────────────────────────────────────────
|
|
43
|
+
container: { true: 'grid' },
|
|
44
|
+
|
|
45
|
+
cols: {
|
|
46
|
+
1: 'grid-cols-1',
|
|
47
|
+
2: 'grid-cols-2',
|
|
48
|
+
3: 'grid-cols-3',
|
|
49
|
+
4: 'grid-cols-4',
|
|
50
|
+
6: 'grid-cols-6',
|
|
51
|
+
12: 'grid-cols-12',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
autoFlow: {
|
|
55
|
+
row: 'grid-flow-row',
|
|
56
|
+
col: 'grid-flow-col',
|
|
57
|
+
dense: 'grid-flow-dense',
|
|
58
|
+
'row-dense':'grid-flow-row-dense',
|
|
59
|
+
'col-dense':'grid-flow-col-dense',
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
* Container gap — token-scale step. Same set as Box/Stack so muscle
|
|
64
|
+
* memory carries across primitives.
|
|
65
|
+
*/
|
|
66
|
+
spacing: {
|
|
67
|
+
0: 'gap-0', '0.5': 'gap-0.5', 1: 'gap-1', 2: 'gap-2', 3: 'gap-3',
|
|
68
|
+
4: 'gap-4', 6: 'gap-6', 8: 'gap-8', 12: 'gap-12', 16: 'gap-16',
|
|
69
|
+
24: 'gap-24',
|
|
70
|
+
},
|
|
71
|
+
spacingX: {
|
|
72
|
+
0: 'gap-x-0', '0.5': 'gap-x-0.5', 1: 'gap-x-1', 2: 'gap-x-2', 3: 'gap-x-3',
|
|
73
|
+
4: 'gap-x-4', 6: 'gap-x-6', 8: 'gap-x-8', 12: 'gap-x-12', 16: 'gap-x-16',
|
|
74
|
+
24: 'gap-x-24',
|
|
75
|
+
},
|
|
76
|
+
spacingY: {
|
|
77
|
+
0: 'gap-y-0', '0.5': 'gap-y-0.5', 1: 'gap-y-1', 2: 'gap-y-2', 3: 'gap-y-3',
|
|
78
|
+
4: 'gap-y-4', 6: 'gap-y-6', 8: 'gap-y-8', 12: 'gap-y-12', 16: 'gap-y-16',
|
|
79
|
+
24: 'gap-y-24',
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// ─── ITEM role — col-span at each breakpoint ──────────────────────
|
|
83
|
+
/*
|
|
84
|
+
* `xs` is the base breakpoint (no prefix) — Tailwind's mobile-first
|
|
85
|
+
* convention. `sm/md/lg/xl` cascade up from there.
|
|
86
|
+
*
|
|
87
|
+
* Special values:
|
|
88
|
+
* • 'auto' → col-auto (content-sized)
|
|
89
|
+
* • 'full' → col-span-full (span all columns regardless of count)
|
|
90
|
+
*/
|
|
91
|
+
xs: {
|
|
92
|
+
1: 'col-span-1', 2: 'col-span-2', 3: 'col-span-3', 4: 'col-span-4',
|
|
93
|
+
5: 'col-span-5', 6: 'col-span-6', 7: 'col-span-7', 8: 'col-span-8',
|
|
94
|
+
9: 'col-span-9', 10: 'col-span-10', 11: 'col-span-11', 12: 'col-span-12',
|
|
95
|
+
auto: 'col-auto', full: 'col-span-full',
|
|
96
|
+
},
|
|
97
|
+
sm: {
|
|
98
|
+
1: 'sm:col-span-1', 2: 'sm:col-span-2', 3: 'sm:col-span-3', 4: 'sm:col-span-4',
|
|
99
|
+
5: 'sm:col-span-5', 6: 'sm:col-span-6', 7: 'sm:col-span-7', 8: 'sm:col-span-8',
|
|
100
|
+
9: 'sm:col-span-9', 10: 'sm:col-span-10', 11: 'sm:col-span-11', 12: 'sm:col-span-12',
|
|
101
|
+
auto: 'sm:col-auto', full: 'sm:col-span-full',
|
|
102
|
+
},
|
|
103
|
+
md: {
|
|
104
|
+
1: 'md:col-span-1', 2: 'md:col-span-2', 3: 'md:col-span-3', 4: 'md:col-span-4',
|
|
105
|
+
5: 'md:col-span-5', 6: 'md:col-span-6', 7: 'md:col-span-7', 8: 'md:col-span-8',
|
|
106
|
+
9: 'md:col-span-9', 10: 'md:col-span-10', 11: 'md:col-span-11', 12: 'md:col-span-12',
|
|
107
|
+
auto: 'md:col-auto', full: 'md:col-span-full',
|
|
108
|
+
},
|
|
109
|
+
lg: {
|
|
110
|
+
1: 'lg:col-span-1', 2: 'lg:col-span-2', 3: 'lg:col-span-3', 4: 'lg:col-span-4',
|
|
111
|
+
5: 'lg:col-span-5', 6: 'lg:col-span-6', 7: 'lg:col-span-7', 8: 'lg:col-span-8',
|
|
112
|
+
9: 'lg:col-span-9', 10: 'lg:col-span-10', 11: 'lg:col-span-11', 12: 'lg:col-span-12',
|
|
113
|
+
auto: 'lg:col-auto', full: 'lg:col-span-full',
|
|
114
|
+
},
|
|
115
|
+
xl: {
|
|
116
|
+
1: 'xl:col-span-1', 2: 'xl:col-span-2', 3: 'xl:col-span-3', 4: 'xl:col-span-4',
|
|
117
|
+
5: 'xl:col-span-5', 6: 'xl:col-span-6', 7: 'xl:col-span-7', 8: 'xl:col-span-8',
|
|
118
|
+
9: 'xl:col-span-9', 10: 'xl:col-span-10', 11: 'xl:col-span-11', 12: 'xl:col-span-12',
|
|
119
|
+
auto: 'xl:col-auto', full: 'xl:col-span-full',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
* No `defaultVariants`. The default semantics are role-dependent:
|
|
125
|
+
* • container Grid defaults to cols=12 (set in Grid.tsx)
|
|
126
|
+
* • item Grid defaults to xs="full" — full-width until a breakpoint
|
|
127
|
+
* prop overrides (also set in Grid.tsx)
|
|
128
|
+
* Encoding these defaults at the TV level would emit them even when
|
|
129
|
+
* irrelevant (e.g. an item Grid never wants `grid grid-cols-12`).
|
|
130
|
+
*/
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
export type GridVariants = VariantProps<typeof gridVariants>;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { describe, it, expect } from 'vitest';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
import { Stack } from './Stack.js';
|
|
5
|
+
|
|
6
|
+
describe('<Stack>', () => {
|
|
7
|
+
// ─── Default rendering ──────────────────────────────────────────────
|
|
8
|
+
describe('default rendering', () => {
|
|
9
|
+
it('renders a <div> by default', () => {
|
|
10
|
+
const { container } = render(<Stack>x</Stack>);
|
|
11
|
+
expect(container.firstElementChild?.tagName).toBe('DIV');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('has flex + flex-col by default', () => {
|
|
15
|
+
const { container } = render(<Stack>x</Stack>);
|
|
16
|
+
const cls = container.firstElementChild?.className ?? '';
|
|
17
|
+
expect(cls).toContain('flex');
|
|
18
|
+
expect(cls).toContain('flex-col');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// ─── Direction ──────────────────────────────────────────────────────
|
|
23
|
+
describe('direction', () => {
|
|
24
|
+
it('row', () => {
|
|
25
|
+
const { container } = render(<Stack direction="row">x</Stack>);
|
|
26
|
+
expect(container.firstElementChild?.className).toContain('flex-row');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('row-reverse', () => {
|
|
30
|
+
const { container } = render(<Stack direction="row-reverse">x</Stack>);
|
|
31
|
+
expect(container.firstElementChild?.className).toContain('flex-row-reverse');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// ─── Align + justify ────────────────────────────────────────────────
|
|
36
|
+
describe('align + justify', () => {
|
|
37
|
+
it('align="center" + justify="between"', () => {
|
|
38
|
+
const { container } = render(
|
|
39
|
+
<Stack align="center" justify="between">x</Stack>,
|
|
40
|
+
);
|
|
41
|
+
const cls = container.firstElementChild?.className ?? '';
|
|
42
|
+
expect(cls).toContain('items-center');
|
|
43
|
+
expect(cls).toContain('justify-between');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('align="baseline"', () => {
|
|
47
|
+
const { container } = render(<Stack align="baseline">x</Stack>);
|
|
48
|
+
expect(container.firstElementChild?.className).toContain('items-baseline');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// ─── Gap + wrap + sizing ────────────────────────────────────────────
|
|
53
|
+
describe('gap + wrap + sizing', () => {
|
|
54
|
+
it('gap={4} emits gap-4', () => {
|
|
55
|
+
const { container } = render(<Stack gap={4}>x</Stack>);
|
|
56
|
+
expect(container.firstElementChild?.className).toContain('gap-4');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('gap={"0.5"} emits gap-0.5', () => {
|
|
60
|
+
const { container } = render(<Stack gap="0.5">x</Stack>);
|
|
61
|
+
expect(container.firstElementChild?.className).toContain('gap-0.5');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('wrap emits flex-wrap', () => {
|
|
65
|
+
const { container } = render(<Stack wrap>x</Stack>);
|
|
66
|
+
expect(container.firstElementChild?.className).toContain('flex-wrap');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('fullWidth + fullHeight', () => {
|
|
70
|
+
const { container } = render(<Stack fullWidth fullHeight>x</Stack>);
|
|
71
|
+
const cls = container.firstElementChild?.className ?? '';
|
|
72
|
+
expect(cls).toContain('w-full');
|
|
73
|
+
expect(cls).toContain('h-full');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// ─── Divider ─────────────────────────────────────────────────────────
|
|
78
|
+
describe('divider', () => {
|
|
79
|
+
it('inserts N-1 dividers between N children', () => {
|
|
80
|
+
const { container } = render(
|
|
81
|
+
<Stack divider={<hr data-testid="div" />}>
|
|
82
|
+
<span>a</span>
|
|
83
|
+
<span>b</span>
|
|
84
|
+
<span>c</span>
|
|
85
|
+
</Stack>,
|
|
86
|
+
);
|
|
87
|
+
// 3 children + 2 dividers
|
|
88
|
+
expect(container.firstElementChild?.children.length).toBe(5);
|
|
89
|
+
const dividers = container.querySelectorAll('[data-testid="div"]');
|
|
90
|
+
expect(dividers.length).toBe(2);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('does NOT insert dividers when there is only one child', () => {
|
|
94
|
+
const { container } = render(
|
|
95
|
+
<Stack divider={<hr data-testid="div" />}>
|
|
96
|
+
<span>only</span>
|
|
97
|
+
</Stack>,
|
|
98
|
+
);
|
|
99
|
+
expect(container.firstElementChild?.children.length).toBe(1);
|
|
100
|
+
expect(container.querySelectorAll('[data-testid="div"]').length).toBe(0);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('treats a Fragment as a single child for divider boundary counting', () => {
|
|
104
|
+
const { container } = render(
|
|
105
|
+
<Stack divider={<hr data-testid="div" />}>
|
|
106
|
+
<>
|
|
107
|
+
<span>a</span>
|
|
108
|
+
<span>b</span>
|
|
109
|
+
</>
|
|
110
|
+
<span>c</span>
|
|
111
|
+
</Stack>,
|
|
112
|
+
);
|
|
113
|
+
// React.Children.toArray does NOT recursively flatten fragments — it
|
|
114
|
+
// treats them as opaque single children. Documented behaviour: 2
|
|
115
|
+
// top-level children → 1 divider between them. If you need a divider
|
|
116
|
+
// BETWEEN the items inside the fragment, hoist them out of it.
|
|
117
|
+
expect(container.querySelectorAll('[data-testid="div"]').length).toBe(1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('renders string/number divider correctly', () => {
|
|
121
|
+
const { container } = render(
|
|
122
|
+
<Stack divider=" · ">
|
|
123
|
+
<span>a</span>
|
|
124
|
+
<span>b</span>
|
|
125
|
+
<span>c</span>
|
|
126
|
+
</Stack>,
|
|
127
|
+
);
|
|
128
|
+
expect(container.firstElementChild?.textContent).toBe('a · b · c');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('asChild silently ignores divider', () => {
|
|
132
|
+
const { container } = render(
|
|
133
|
+
<Stack asChild divider={<hr data-testid="div" />}>
|
|
134
|
+
<nav>
|
|
135
|
+
<a href="#">link</a>
|
|
136
|
+
</nav>
|
|
137
|
+
</Stack>,
|
|
138
|
+
);
|
|
139
|
+
// Slot wraps a single child — divider has nowhere to go
|
|
140
|
+
expect(container.firstElementChild?.tagName).toBe('NAV');
|
|
141
|
+
expect(container.querySelectorAll('[data-testid="div"]').length).toBe(0);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// ─── Override + sx ──────────────────────────────────────────────────
|
|
146
|
+
describe('override', () => {
|
|
147
|
+
it('sx wins over variant defaults', () => {
|
|
148
|
+
const { container } = render(
|
|
149
|
+
<Stack direction="row" sx="flex-col">x</Stack>,
|
|
150
|
+
);
|
|
151
|
+
const cls = container.firstElementChild?.className ?? '';
|
|
152
|
+
expect(cls).toContain('flex-col');
|
|
153
|
+
expect(cls).not.toContain('flex-row');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('sx can add utilities Stack does not expose (overflow)', () => {
|
|
157
|
+
const { container } = render(<Stack sx="overflow-x-auto">x</Stack>);
|
|
158
|
+
expect(container.firstElementChild?.className).toContain('overflow-x-auto');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// ─── Polymorphism ───────────────────────────────────────────────────
|
|
163
|
+
describe('polymorphism', () => {
|
|
164
|
+
it('as="nav" renders a <nav>', () => {
|
|
165
|
+
const { container } = render(<Stack as="nav">x</Stack>);
|
|
166
|
+
expect(container.firstElementChild?.tagName).toBe('NAV');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('asChild wins over as', () => {
|
|
170
|
+
const { container } = render(
|
|
171
|
+
<Stack as="nav" asChild>
|
|
172
|
+
<header>x</header>
|
|
173
|
+
</Stack>,
|
|
174
|
+
);
|
|
175
|
+
expect(container.firstElementChild?.tagName).toBe('HEADER');
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// ─── Pass-through ────────────────────────────────────────────────────
|
|
180
|
+
it('forwards data-* + aria-*', () => {
|
|
181
|
+
const { container } = render(
|
|
182
|
+
<Stack data-testid="s" aria-label="settings">x</Stack>,
|
|
183
|
+
);
|
|
184
|
+
const el = container.firstElementChild;
|
|
185
|
+
expect(el?.getAttribute('data-testid')).toBe('s');
|
|
186
|
+
expect(el?.getAttribute('aria-label')).toBe('settings');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// ─── F11-bis edge cases: divider with array / null / mixed children ─
|
|
190
|
+
describe('divider edge cases', () => {
|
|
191
|
+
it('children passed as an array still gets N-1 dividers', () => {
|
|
192
|
+
// Children.toArray handles arrays the same as iterated siblings —
|
|
193
|
+
// the divider count is items.length - 1 regardless of how the
|
|
194
|
+
// children were passed in.
|
|
195
|
+
const items = ['a', 'b', 'c', 'd'];
|
|
196
|
+
const { container } = render(
|
|
197
|
+
<Stack divider={<hr data-testid="div" />}>
|
|
198
|
+
{items.map((t) => <span key={t}>{t}</span>)}
|
|
199
|
+
</Stack>,
|
|
200
|
+
);
|
|
201
|
+
expect(container.querySelectorAll('[data-testid="div"]').length).toBe(3);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('null children are stripped before divider insertion', () => {
|
|
205
|
+
// React's Children.toArray filters out null/undefined/false before
|
|
206
|
+
// returning the flat array — so a conditional child collapses to
|
|
207
|
+
// nothing and dividers are sized to the remaining set.
|
|
208
|
+
const showB = false;
|
|
209
|
+
const { container } = render(
|
|
210
|
+
<Stack divider={<hr data-testid="div" />}>
|
|
211
|
+
<span>a</span>
|
|
212
|
+
{showB && <span>b</span>}
|
|
213
|
+
<span>c</span>
|
|
214
|
+
</Stack>,
|
|
215
|
+
);
|
|
216
|
+
// After stripping `false`: 2 effective children → 1 divider
|
|
217
|
+
expect(container.querySelectorAll('[data-testid="div"]').length).toBe(1);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('mixed text + element children — divider between EVERY pair', () => {
|
|
221
|
+
const { container } = render(
|
|
222
|
+
<Stack divider={<hr data-testid="div" />}>
|
|
223
|
+
{'plain string'}
|
|
224
|
+
<span>element child</span>
|
|
225
|
+
{42}
|
|
226
|
+
<span>last</span>
|
|
227
|
+
</Stack>,
|
|
228
|
+
);
|
|
229
|
+
// 4 effective children (Children.toArray wraps primitives) → 3 dividers
|
|
230
|
+
expect(container.querySelectorAll('[data-testid="div"]').length).toBe(3);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('nested Stack inside Stack with divider — inner Stack counts as 1 child', () => {
|
|
234
|
+
const { container } = render(
|
|
235
|
+
<Stack gap={2} divider={<hr data-testid="outer-div" />}>
|
|
236
|
+
<span>top</span>
|
|
237
|
+
<Stack gap={1} direction="row">
|
|
238
|
+
<span>nested-a</span>
|
|
239
|
+
<span>nested-b</span>
|
|
240
|
+
</Stack>
|
|
241
|
+
<span>bottom</span>
|
|
242
|
+
</Stack>,
|
|
243
|
+
);
|
|
244
|
+
// Outer has 3 effective children → 2 outer dividers
|
|
245
|
+
expect(container.querySelectorAll('[data-testid="outer-div"]').length).toBe(2);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('divider key is stable across re-renders (no key warning)', () => {
|
|
249
|
+
// Re-rendering with the same children + divider shouldn't produce
|
|
250
|
+
// React key warnings. We assert nothing throws + the structure is
|
|
251
|
+
// identical to a single render.
|
|
252
|
+
const { container, rerender } = render(
|
|
253
|
+
<Stack divider={<hr data-testid="d" />}>
|
|
254
|
+
<span>a</span>
|
|
255
|
+
<span>b</span>
|
|
256
|
+
</Stack>,
|
|
257
|
+
);
|
|
258
|
+
const firstRender = container.innerHTML;
|
|
259
|
+
rerender(
|
|
260
|
+
<Stack divider={<hr data-testid="d" />}>
|
|
261
|
+
<span>a</span>
|
|
262
|
+
<span>b</span>
|
|
263
|
+
</Stack>,
|
|
264
|
+
);
|
|
265
|
+
expect(container.innerHTML).toBe(firstRender);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// ─── F11-bis edge cases: gap value coverage ─────────────────────────
|
|
270
|
+
describe('gap — every token step', () => {
|
|
271
|
+
const GAPS = [0, '0.5', 1, 2, 3, 4, 6, 8, 12, 16, 24] as const;
|
|
272
|
+
it.each(GAPS)('gap=%s emits gap-%s', (g) => {
|
|
273
|
+
const { container } = render(<Stack gap={g}>x</Stack>);
|
|
274
|
+
expect(container.firstElementChild?.className).toContain(`gap-${g}`);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// ─── F11-bis edge cases: align / justify all values ─────────────────
|
|
279
|
+
describe('align + justify — all valid values', () => {
|
|
280
|
+
const ALIGNS = ['start', 'center', 'end', 'stretch', 'baseline'] as const;
|
|
281
|
+
const JUSTIFIES = ['start', 'center', 'end', 'between', 'around', 'evenly'] as const;
|
|
282
|
+
|
|
283
|
+
it.each(ALIGNS)('align="%s"', (v) => {
|
|
284
|
+
const { container } = render(<Stack align={v}>x</Stack>);
|
|
285
|
+
expect(container.firstElementChild?.className).toContain(`items-${v}`);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it.each(JUSTIFIES)('justify="%s"', (v) => {
|
|
289
|
+
const { container } = render(<Stack justify={v}>x</Stack>);
|
|
290
|
+
expect(container.firstElementChild?.className).toContain(`justify-${v}`);
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// ─── F11-bis edge cases: empty Stack ────────────────────────────────
|
|
295
|
+
describe('empty Stack', () => {
|
|
296
|
+
it('renders an empty div with flex classes', () => {
|
|
297
|
+
const { container } = render(<Stack gap={4} />);
|
|
298
|
+
const el = container.firstElementChild;
|
|
299
|
+
expect(el?.children.length).toBe(0);
|
|
300
|
+
expect(el?.className).toContain('flex');
|
|
301
|
+
expect(el?.className).toContain('gap-4');
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('empty Stack with divider does NOT render the divider', () => {
|
|
305
|
+
const { container } = render(<Stack divider={<hr data-testid="d" />} />);
|
|
306
|
+
expect(container.querySelectorAll('[data-testid="d"]').length).toBe(0);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
Fragment,
|
|
4
|
+
cloneElement,
|
|
5
|
+
forwardRef,
|
|
6
|
+
isValidElement,
|
|
7
|
+
type ElementType,
|
|
8
|
+
type ReactElement,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
12
|
+
import { cn } from '../../utils/cn.js';
|
|
13
|
+
import { stackVariants } from './stack.variants.js';
|
|
14
|
+
import type { StackProps } from './stack.types.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Walk the children, inserting `divider` BETWEEN every consecutive pair.
|
|
18
|
+
*
|
|
19
|
+
* Implementation notes:
|
|
20
|
+
* • `React.Children.toArray` assigns auto-keys but does NOT recursively
|
|
21
|
+
* flatten Fragments — it treats them as opaque single children. So
|
|
22
|
+
* `<Stack><><a/><b/></><c/></Stack>` is 2 boundaries (fragment + c),
|
|
23
|
+
* yielding ONE divider. Hoist items out of the fragment when you
|
|
24
|
+
* need a divider between them. Documented + asserted in the tests.
|
|
25
|
+
* • Dividers are wrapped in `<Fragment>` with a deterministic key
|
|
26
|
+
* derived from the boundary index — stable across re-renders so
|
|
27
|
+
* React reconciles correctly when children re-order.
|
|
28
|
+
* • If `divider` is a valid element, we `cloneElement` once per
|
|
29
|
+
* boundary (cheaper than re-rendering the JSX expression N-1 times).
|
|
30
|
+
* For string/number dividers we wrap in a span automatically.
|
|
31
|
+
*/
|
|
32
|
+
function interleaveDividers(children: ReactNode, divider: ReactNode): ReactNode[] {
|
|
33
|
+
const items = Children.toArray(children);
|
|
34
|
+
if (items.length <= 1) return items;
|
|
35
|
+
|
|
36
|
+
const result: ReactNode[] = [];
|
|
37
|
+
items.forEach((child, i) => {
|
|
38
|
+
result.push(child);
|
|
39
|
+
if (i < items.length - 1) {
|
|
40
|
+
const key = `df-stack-divider-${i}`;
|
|
41
|
+
if (isValidElement(divider)) {
|
|
42
|
+
result.push(cloneElement(divider as ReactElement<{ key?: string }>, { key }));
|
|
43
|
+
} else {
|
|
44
|
+
result.push(<Fragment key={key}>{divider}</Fragment>);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* `<Stack>` — flex container 1D, the layout primitive.
|
|
53
|
+
*
|
|
54
|
+
* This is the ONLY component in @dashforge/tw that does flex. Box
|
|
55
|
+
* doesn't, Grid does CSS Grid (not flex). The strict naming → engine
|
|
56
|
+
* mapping is the whole point: when you read `<Stack>` in a JSX tree,
|
|
57
|
+
* you instantly know it's flex. No `<Box display="flex" ...>` traps.
|
|
58
|
+
*
|
|
59
|
+
* Direction defaults to `'col'` (vertical stack) — the most common
|
|
60
|
+
* case for forms, sidebars, settings panels. Pass `direction="row"`
|
|
61
|
+
* for horizontal layouts (toolbars, button rows, breadcrumbs).
|
|
62
|
+
*
|
|
63
|
+
* The `divider` prop is the runtime-only piece: TV can't encode the
|
|
64
|
+
* "render this between each child" logic as a class, so we walk the
|
|
65
|
+
* children at render time. The walk is O(n); for n ≤ ~10 (typical
|
|
66
|
+
* Stack content) the cost is negligible. For very long Stacks (1000+
|
|
67
|
+
* items), prefer to render dividers as part of each child instead.
|
|
68
|
+
*
|
|
69
|
+
* When `asChild` is true, the divider prop is silently ignored — Slot
|
|
70
|
+
* requires a single child, and the N-1 insertion has nowhere to act.
|
|
71
|
+
*/
|
|
72
|
+
export const Stack = forwardRef<HTMLElement, StackProps>(
|
|
73
|
+
function Stack(props, ref) {
|
|
74
|
+
const {
|
|
75
|
+
direction,
|
|
76
|
+
align,
|
|
77
|
+
justify,
|
|
78
|
+
gap,
|
|
79
|
+
wrap,
|
|
80
|
+
fullWidth,
|
|
81
|
+
fullHeight,
|
|
82
|
+
divider,
|
|
83
|
+
as,
|
|
84
|
+
asChild = false,
|
|
85
|
+
sx,
|
|
86
|
+
children,
|
|
87
|
+
...rest
|
|
88
|
+
} = props;
|
|
89
|
+
|
|
90
|
+
const classes = cn(
|
|
91
|
+
stackVariants({ direction, align, justify, gap, wrap, fullWidth, fullHeight }),
|
|
92
|
+
sx,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
if (asChild) {
|
|
96
|
+
// Slot expects a single child; divider has no place here.
|
|
97
|
+
return (
|
|
98
|
+
<Slot ref={ref} className={classes} {...rest}>
|
|
99
|
+
{children as ReactElement}
|
|
100
|
+
</Slot>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const Tag = (as ?? 'div') as ElementType;
|
|
105
|
+
const content = divider != null ? interleaveDividers(children, divider) : children;
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<Tag ref={ref as never} className={classes} {...rest}>
|
|
109
|
+
{content}
|
|
110
|
+
</Tag>
|
|
111
|
+
);
|
|
112
|
+
},
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
Stack.displayName = 'Stack';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ElementType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { StackVariants } from './stack.variants.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props for `<Stack>` — flex container 1D, the layout primitive.
|
|
6
|
+
*
|
|
7
|
+
* Axes:
|
|
8
|
+
* • direction — flex-direction (default 'col')
|
|
9
|
+
* • align — items-* (cross-axis)
|
|
10
|
+
* • justify — justify-* (main-axis)
|
|
11
|
+
* • gap — token-scale spacing step
|
|
12
|
+
* • wrap — flex-wrap
|
|
13
|
+
* • fullWidth/fullHeight — w-full / h-full
|
|
14
|
+
* • divider — node rendered N-1 times between children
|
|
15
|
+
*
|
|
16
|
+
* Polymorphism:
|
|
17
|
+
* • as — override the HTML tag (default 'div')
|
|
18
|
+
* • asChild — render via Radix Slot onto the single child
|
|
19
|
+
*
|
|
20
|
+
* What Stack does NOT do (route to other primitives):
|
|
21
|
+
* • Surface chrome (border, bg, shadow) → wrap in <Box>
|
|
22
|
+
* • 2D layout (rows AND columns) → use <Grid>
|
|
23
|
+
* • Text styling → <Typography>
|
|
24
|
+
*/
|
|
25
|
+
export interface StackProps
|
|
26
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'className'>,
|
|
27
|
+
Pick<StackVariants,
|
|
28
|
+
'direction' | 'align' | 'justify' | 'gap' | 'wrap'
|
|
29
|
+
| 'fullWidth' | 'fullHeight'> {
|
|
30
|
+
/**
|
|
31
|
+
* Node rendered N-1 times BETWEEN children — mirror of MUI Stack's
|
|
32
|
+
* divider prop. Useful for visual separators (a `<hr>`, a thin
|
|
33
|
+
* `<Box variant="outlined" sx="h-px border-0 border-t">`, an
|
|
34
|
+
* `<svg>` glyph) that need to follow the flex direction.
|
|
35
|
+
*
|
|
36
|
+
* The node is cloned for each insertion via `cloneElement`; pass a
|
|
37
|
+
* stable element (not a function) for best React reconciliation.
|
|
38
|
+
* `React.Children.toArray` flattens fragments before the walk, so
|
|
39
|
+
* `<Stack divider={...}><><...></></Stack>` works as expected.
|
|
40
|
+
*/
|
|
41
|
+
divider?: ReactNode;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Override the rendered HTML tag. Defaults to `'div'`. Use when the
|
|
45
|
+
* Stack also has semantic meaning — `<Stack as="nav">` for a nav
|
|
46
|
+
* bar, `<Stack as="ul">` for a list (children become `<li>` via
|
|
47
|
+
* native HTML, not by us).
|
|
48
|
+
*
|
|
49
|
+
* Ignored when `asChild` is true.
|
|
50
|
+
*/
|
|
51
|
+
as?: ElementType;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Render via Radix `Slot` — the Stack styles paint onto the single
|
|
55
|
+
* React child instead of wrapping it. Mutually exclusive with `as`
|
|
56
|
+
* (when both are passed, `asChild` wins). The `divider` prop is
|
|
57
|
+
* ignored when `asChild` is true (the Slot pattern wraps a single
|
|
58
|
+
* node, so the N-1 insertion logic has no place to act).
|
|
59
|
+
*/
|
|
60
|
+
asChild?: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Utility classes appended to the variant chain. Resolved via
|
|
64
|
+
* `tailwind-merge` so the consumer's classes always win over the
|
|
65
|
+
* variant defaults.
|
|
66
|
+
*/
|
|
67
|
+
sx?: string;
|
|
68
|
+
}
|