@nswds/ui 6.1.0 → 7.0.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/dist/components/badge.d.ts +1 -1
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.js +9 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/header.d.ts +1 -1
- package/dist/components/input-group.d.ts +25 -1
- package/dist/components/input-group.js +449 -20
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/link.d.ts +1 -1
- package/dist/components/masthead.d.ts +1 -1
- package/dist/components/skip-link.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,114 @@ function InputGroup({ className, ...props }) {
|
|
|
13
13
|
"data-slot": "input-group",
|
|
14
14
|
role: "group",
|
|
15
15
|
className: cn(
|
|
16
|
-
|
|
16
|
+
// No `outline-none` here: it sets `--tw-outline-style: none` on this
|
|
17
|
+
// element, which then suppresses the focus outline below (which reads
|
|
18
|
+
// `outline-style: var(--tw-outline-style)`).
|
|
19
|
+
"group/input-group relative flex h-12 w-full min-w-0 items-stretch rounded-sm motion-safe:transition-colors",
|
|
20
|
+
// Every colour routes through the --input-* semantic tokens (layer 3,
|
|
21
|
+
// theme.css / the registry theme item) — the same set Input uses, so a
|
|
22
|
+
// group and a bare input are the same control. The role tokens behind
|
|
23
|
+
// them are mode-aware, so there are no dark: variants here.
|
|
24
|
+
"border border-(--input-border) bg-(--input-surface)",
|
|
25
|
+
// Hover — owned by the wrapper so the whole control reacts, addons
|
|
26
|
+
// included, rather than just the inner control's box.
|
|
27
|
+
//
|
|
28
|
+
// Known nuance, deliberately NOT fixed here: hovering an embedded
|
|
29
|
+
// button also paints this surface, so the 464px field greys behind a
|
|
30
|
+
// control the pointer is only 85px inside. Suppressing it with
|
|
31
|
+
// `has-[button:hover]:bg-(--input-surface)` works for the button, but
|
|
32
|
+
// measurably breaks the ordinary field hover on any group holding a
|
|
33
|
+
// button — Chromium stops re-evaluating the plain `:hover` rule on a
|
|
34
|
+
// subject that also carries a `:has(…:hover)` rule, so the field hover
|
|
35
|
+
// silently stopped painting at all. Losing the common interaction to
|
|
36
|
+
// sharpen the rare one is the wrong trade. Revisit if the group ever
|
|
37
|
+
// gains a wrapper that can own hover without `:has()`.
|
|
38
|
+
"hover:bg-(--input-surface-hover)",
|
|
39
|
+
// ...but a disabled group must not react at all. A standalone Input
|
|
40
|
+
// cannot: `disabled:pointer-events-none` means `:hover` never matches
|
|
41
|
+
// it. This wrapper is a plain div, and `pointer-events` on the CONTROL
|
|
42
|
+
// does not stop its ancestor being hovered, so without this line a dead
|
|
43
|
+
// field painted the full enabled hover surface — measured with a real
|
|
44
|
+
// pointer at `--input-surface-hover`, identical to an enabled group.
|
|
45
|
+
// `pointer-events-none` on the wrapper is not the fix: it would also
|
|
46
|
+
// kill an enabled action sitting inside a disabled-field group.
|
|
47
|
+
//
|
|
48
|
+
// Mirrored for `data-disabled`, the manual escape hatch the addon also
|
|
49
|
+
// honours. Every wrapper rule keyed on a disabled control needs its
|
|
50
|
+
// twin so the hook consistently styles the chrome — previously the
|
|
51
|
+
// addon's hairline faded and its cursor changed while this border and
|
|
52
|
+
// hover surface stayed fully live.
|
|
53
|
+
"has-[[data-slot=input-group-control]:disabled]:hover:bg-(--input-surface)",
|
|
54
|
+
"data-[disabled=true]:hover:bg-(--input-surface)",
|
|
55
|
+
// Disabled — the group fades its own CHROME: this border, plus the
|
|
56
|
+
// addon's hairline and cursor. Every child owns its own state, and
|
|
57
|
+
// nothing in this component puts `opacity` on an ancestor.
|
|
58
|
+
//
|
|
59
|
+
// The wrapper-opacity version of this shipped briefly and was wrong:
|
|
60
|
+
// ancestor opacity composites the whole subtree and a child cannot opt
|
|
61
|
+
// out of it, so an ENABLED action beside a disabled field rendered at
|
|
62
|
+
// 50% — measured white-on-navy at 3.12:1, under the 4.5:1 floor, on a
|
|
63
|
+
// button that was still clickable. A control that looks disabled and
|
|
64
|
+
// isn't is worse than the chrome bug it replaced. It also forced
|
|
65
|
+
// `opacity-100` neutralisers onto four children to stop 0.5 x 0.5
|
|
66
|
+
// compounding, and those only worked for natively `:disabled` targets.
|
|
67
|
+
// Fading the chrome directly needs no neutralisers and cannot compound.
|
|
68
|
+
//
|
|
69
|
+
// `not-has-[…aria-invalid…]` is load-bearing, not belt-and-braces. This
|
|
70
|
+
// rule and the aria-invalid border rule below both set `border-color`
|
|
71
|
+
// at identical specificity — `:has()` takes its most specific argument,
|
|
72
|
+
// so `:has([data-slot=input-group-control]:disabled)` (attribute +
|
|
73
|
+
// pseudo-class) and `:has([data-slot][aria-invalid=true])` (two
|
|
74
|
+
// attributes) are both (0,2,0), plus one class each. Without the
|
|
75
|
+
// exclusion only emission order separates them, and this package's
|
|
76
|
+
// classes can be re-emitted after ours by a consuming app's own
|
|
77
|
+
// Tailwind build — the two-build hazard check:cascade exists for, which
|
|
78
|
+
// it cannot catch here because it only flags conditional at-rule pairs.
|
|
79
|
+
// A field that fails validation and is then disabled during submit hits
|
|
80
|
+
// exactly this: the faded grey would erase the error border. Making the
|
|
81
|
+
// two mutually exclusive decides it by MATCHING instead of by order.
|
|
82
|
+
// The `data-disabled` twin below carries the same exclusion, for the
|
|
83
|
+
// same reason: an error border must outlive either disabled path.
|
|
84
|
+
"has-[[data-slot=input-group-control]:disabled]:not-has-[[data-slot][aria-invalid=true]]:border-(--input-border)/50",
|
|
85
|
+
"data-[disabled=true]:not-has-[[data-slot][aria-invalid=true]]:border-(--input-border)/50",
|
|
86
|
+
// Focus — the group draws one outline for whichever control is focused;
|
|
87
|
+
// InputGroupInput / InputGroupTextarea suppress their own. Offset and
|
|
88
|
+
// colour are unconditional because neither renders anything until
|
|
89
|
+
// `outline-2` supplies an outline-style, and keeping them off the
|
|
90
|
+
// has-[] variant leaves the invalid colour below a plain specificity
|
|
91
|
+
// win instead of a source-order tie between two has-[] rules.
|
|
92
|
+
"outline-offset-2 outline-(--input-ring)",
|
|
93
|
+
"has-[[data-slot=input-group-control]:focus-visible]:outline-2",
|
|
94
|
+
// Invalid — 2px danger border, danger hover surface and danger focus
|
|
95
|
+
// outline, mirroring Input's aria-invalid treatment. Each rule carries
|
|
96
|
+
// the has-[] selector, so it outranks its unqualified counterpart on
|
|
97
|
+
// specificity rather than on emission order.
|
|
98
|
+
"has-[[data-slot][aria-invalid=true]]:border-2 has-[[data-slot][aria-invalid=true]]:border-(--input-invalid-border)",
|
|
99
|
+
"has-[[data-slot][aria-invalid=true]]:outline-(--input-invalid-ring)",
|
|
100
|
+
// Excluded when the control is disabled, for the same reason the border
|
|
101
|
+
// rule above is: this and the disabled hover rule both compute to
|
|
102
|
+
// (0,4,0) — class + `:has()` + `:hover` on each — so a tie decided by
|
|
103
|
+
// emission order would let an invalid AND disabled field paint the
|
|
104
|
+
// danger hover surface. Mutually exclusive selectors decide it by
|
|
105
|
+
// MATCHING, and disabled is the one that should win: a dead control
|
|
106
|
+
// gives no hover feedback whatever its validation state. BOTH disabled
|
|
107
|
+
// paths are excluded — the hover rules are (0,3,0) for `data-disabled`
|
|
108
|
+
// against this rule's (0,6,0), so excluding only the control-disabled
|
|
109
|
+
// one would have let an invalid group flagged via the hatch keep
|
|
110
|
+
// painting the danger hover surface.
|
|
111
|
+
"has-[[data-slot][aria-invalid=true]]:not-has-[[data-slot=input-group-control]:disabled]:not-data-[disabled=true]:hover:bg-(--input-invalid-surface-hover)",
|
|
112
|
+
// An InputGroupAction sits flush to the trailing edge with square
|
|
113
|
+
// corners, so the group clips it to its own radius — cheaper and
|
|
114
|
+
// RTL-correct next to per-corner arithmetic on the action. Scoped to
|
|
115
|
+
// groups that actually hold one: a bare `overflow-hidden` would clip
|
|
116
|
+
// DESCENDANT outlines, and InputGroupButton's focus ring sits 2px
|
|
117
|
+
// outside itself, so every Combobox chevron would lose its ring.
|
|
118
|
+
"has-[[data-slot=input-group-action]]:overflow-hidden",
|
|
119
|
+
// Block-aligned addons stack the group and let it grow to fit
|
|
120
|
+
"has-data-[align=block-end]:rounded-sm has-data-[align=block-start]:rounded-sm has-[textarea]:rounded-sm",
|
|
121
|
+
"has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto",
|
|
122
|
+
// Addon-driven padding on the inner input
|
|
123
|
+
"has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3",
|
|
17
124
|
className
|
|
18
125
|
),
|
|
19
126
|
...props
|
|
@@ -21,14 +128,111 @@ function InputGroup({ className, ...props }) {
|
|
|
21
128
|
);
|
|
22
129
|
}
|
|
23
130
|
const inputGroupAddonVariants = cva(
|
|
24
|
-
|
|
131
|
+
// `--input-placeholder` is the input token set's de-emphasised-text role, and
|
|
132
|
+
// an icon or text affix is exactly that — so addons restyle with the input
|
|
133
|
+
// rather than drifting from it. Mode-aware, hence no dark: variants.
|
|
134
|
+
//
|
|
135
|
+
// Type and glyphs are sized off the control's own `text-base`, not off the
|
|
136
|
+
// box. An affix sits on the same line as the value, so 16px is the floor —
|
|
137
|
+
// the old `text-xs/relaxed` (12px) and 10px kbd were scaled for the 28px
|
|
138
|
+
// group this component used to be and read as fine print beside 16px input
|
|
139
|
+
// text. Glyphs are `size-5` (20px), 1.25x the label, the same reasoning
|
|
140
|
+
// button.tsx documents for a label glyph.
|
|
141
|
+
// An addon holding an InputGroupAction yields its own padding on that edge so
|
|
142
|
+
// the action reaches the group's inner border, and takes a 48px floor so the
|
|
143
|
+
// row still has height once the padding is gone (the affix text centres in
|
|
144
|
+
// it via `items-center`). Each override carries the has-[] selector, so it
|
|
145
|
+
// outranks the base padding on specificity rather than on emission order.
|
|
146
|
+
// Disabled: the addon fades its own HAIRLINE and swaps its cursor, and never
|
|
147
|
+
// touches `opacity`. This is the whole point, so it is worth stating plainly:
|
|
148
|
+
// the addon is an ANCESTOR of every inline button (InputGroupButton always sits
|
|
149
|
+
// in one, and a block-end InputGroupAction does too). `opacity` on this
|
|
150
|
+
// element therefore composites those buttons, and a child cannot opt out of
|
|
151
|
+
// an ancestor's opacity. Measured with `opacity-50` here: an ENABLED button
|
|
152
|
+
// beside a disabled field rendered at effective 0.5 while still clickable,
|
|
153
|
+
// and a disabled one multiplied with Button's own `data-disabled:opacity-50`
|
|
154
|
+
// to 0.25 — which is exactly the Combobox shape, since ComboboxInput passes
|
|
155
|
+
// `disabled` to the control and to the trigger and clear buttons at once.
|
|
156
|
+
// Fading only what this element itself paints leaves every descendant
|
|
157
|
+
// untouched and cannot compound.
|
|
158
|
+
//
|
|
159
|
+
// The affix CONTENT is deliberately not faded — only the hairline is. Two
|
|
160
|
+
// attempts to fade it were both wrong and are worth recording so neither is
|
|
161
|
+
// retried. A faded `color` on the addon never reaches InputGroupText, which
|
|
162
|
+
// sets its own `color` and so stayed lit beside a faded glyph. Expressing the
|
|
163
|
+
// same fade as `opacity` on the children fixed that, but the a11y gate
|
|
164
|
+
// rejects both: axe measures the affix label at 2.43:1 and cannot tell it
|
|
165
|
+
// belongs to a disabled control, because the span carries no disabled state
|
|
166
|
+
// of its own and the addon is a sibling of the control, not its ancestor.
|
|
167
|
+
//
|
|
168
|
+
// Leaving it legible is also the better answer. An affix is an adornment —
|
|
169
|
+
// "AUD", "Markdown supported" — closer to a label than to the control, and a
|
|
170
|
+
// label beside a disabled input does not fade either. The disabled signal is
|
|
171
|
+
// carried by the wrapper's border, this hairline, `cursor-not-allowed`, and
|
|
172
|
+
// the control's own fade, which is four cues without making information
|
|
173
|
+
// harder to read. Fading it would need `aria-disabled` plumbed onto a
|
|
174
|
+
// presentational div to keep axe honest, for a worse result.
|
|
175
|
+
//
|
|
176
|
+
// Background is likewise NOT faded: `--surface-sunken` measures 1.1:1 against
|
|
177
|
+
// the field, so 50% of it is imperceptible, and an `inline-end` addon has no
|
|
178
|
+
// background at all — a base-level `bg` fade would ADD a grey panel.
|
|
179
|
+
//
|
|
180
|
+
// Both conditions get the same paint. `data-disabled` on the group is a
|
|
181
|
+
// manual escape hatch nothing in this component sets, but it had the same
|
|
182
|
+
// ancestor-opacity defect, so it is converted rather than left as a landmine.
|
|
183
|
+
//
|
|
184
|
+
// The affix also advertises a text caret, because clicking it focuses the
|
|
185
|
+
// control. Over a disabled control that is a lie, so it takes the same
|
|
186
|
+
// `cursor-not-allowed` the control itself does.
|
|
187
|
+
"flex cursor-text items-center justify-center gap-1 text-base text-(--input-placeholder) select-none group-has-[[data-slot=input-group-control]:disabled]/input-group:cursor-not-allowed group-has-[[data-slot=input-group-control]:disabled]/input-group:border-(--input-border)/50 group-data-[disabled=true]/input-group:cursor-not-allowed group-data-[disabled=true]/input-group:border-(--input-border)/50 has-[[data-slot=input-group-action]]:min-h-12 has-[[data-slot=input-group-action]]:py-0 **:data-[slot=kbd]:rounded-[calc(var(--radius-sm)-2px)] **:data-[slot=kbd]:bg-(--input-placeholder)/10 **:data-[slot=kbd]:px-1 [&>svg:not([class*='size-'])]:size-5",
|
|
25
188
|
{
|
|
26
189
|
variants: {
|
|
27
190
|
align: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
191
|
+
// No negative nudge for buttons. `me-[-0.275rem]` was tuned to cancel a
|
|
192
|
+
// 20px `px-1` button in the 28px group this component used to be; at
|
|
193
|
+
// 32px and `px-3` it under-compensates and left the inline button 3.6px
|
|
194
|
+
// off the group's inner edge while the block-end row sat at 8px. Every
|
|
195
|
+
// inset is now that same 8px, so affixes, buttons and footer rows all
|
|
196
|
+
// land on one grid. The kbd nudge stays — a kbd chip is small enough
|
|
197
|
+
// that the optical correction still reads.
|
|
198
|
+
// ONE hairline colour for the whole control: `--input-border`, the same
|
|
199
|
+
// token the group's own edge uses. The mockup drew internal dividers in
|
|
200
|
+
// the lighter `--border-default`, but mixing the two put a #dcdfe0
|
|
201
|
+
// divider beside a #888f92 seam and outer edge, which reads as the
|
|
202
|
+
// junctions being heavier rather than as a hierarchy. It also fixes
|
|
203
|
+
// dark mode: `--border-default` measures 1.12:1 on the dark surface,
|
|
204
|
+
// under the 3:1 floor for a boundary that has to identify a control.
|
|
205
|
+
//
|
|
206
|
+
// The leading affix is a CELL, not floating text: a recessed fill, a
|
|
207
|
+
// hairline on its inner edge, and the group's full height. This is what
|
|
208
|
+
// makes the trailing action read as its mirror — the approved design's
|
|
209
|
+
// words were "the trailing cell mirrors the leading AUD cell exactly".
|
|
210
|
+
// 16px padding matches the value's own, so affix and value sit on one
|
|
211
|
+
// rhythm.
|
|
212
|
+
// Weight lives per align, not in the base: the design sets the inline
|
|
213
|
+
// affix at 600 (`.affix`) but the block row's hint at 300
|
|
214
|
+
// (`.foot .hint`). A base `font-semibold` made "Markdown supported"
|
|
215
|
+
// read as a label at the same weight as the AUD affix.
|
|
216
|
+
//
|
|
217
|
+
// No kbd nudge here any more. `ms-[-0.275rem]` was harmless while this
|
|
218
|
+
// addon was transparent text; now that it paints a fill, a border-inline
|
|
219
|
+
// -end and a rounded start corner, a negative start margin drags the
|
|
220
|
+
// whole cell out past the group's own border.
|
|
221
|
+
"inline-start": "order-first rounded-s-[calc(var(--radius-sm)-1px)] border-e border-(--input-border) bg-(--surface-sunken) px-4 font-semibold has-[[data-slot=input-group-action]]:ms-0 has-[[data-slot=input-group-action]]:items-stretch has-[[data-slot=input-group-action]]:p-0",
|
|
222
|
+
"inline-end": "order-last px-2 font-semibold has-[[data-slot=input-group-action]]:me-0 has-[[data-slot=input-group-action]]:items-stretch has-[[data-slot=input-group-action]]:p-0 has-[>kbd]:me-[-0.275rem]",
|
|
223
|
+
// Block addons are chrome, not content, so they carry the boundary the
|
|
224
|
+
// Hairline Rule asks for and sit on the recessed surface. Without both
|
|
225
|
+
// the row floats in the writing area with nothing dividing it.
|
|
226
|
+
//
|
|
227
|
+
// `--surface-sunken`, NOT `--background-subtle`: the latter resolves to
|
|
228
|
+
// the same value as `--surface-default` in dark, so the tint vanishes
|
|
229
|
+
// there. Sunken differs from the group's surface in BOTH modes.
|
|
230
|
+
//
|
|
231
|
+
// The corners are rounded rather than clipped by the group: a group-level
|
|
232
|
+
// `overflow-hidden` would cut off the focus ring of any button inside
|
|
233
|
+
// the row, since Button rings 2px outside itself.
|
|
234
|
+
"block-start": "order-first min-h-12 w-full justify-start rounded-t-[calc(var(--radius-sm)-1px)] border-b border-(--input-border) bg-(--surface-sunken) px-4 font-light has-[[data-slot=input-group-action]]:items-stretch has-[[data-slot=input-group-action]]:pe-0",
|
|
235
|
+
"block-end": "order-last min-h-12 w-full justify-start rounded-b-[calc(var(--radius-sm)-1px)] border-t border-(--input-border) bg-(--surface-sunken) px-4 font-light has-[[data-slot=input-group-action]]:items-stretch has-[[data-slot=input-group-action]]:pe-0"
|
|
32
236
|
}
|
|
33
237
|
},
|
|
34
238
|
defaultVariants: {
|
|
@@ -59,14 +263,51 @@ function InputGroupAddon({
|
|
|
59
263
|
);
|
|
60
264
|
}
|
|
61
265
|
const inputGroupButtonVariants = cva(
|
|
62
|
-
|
|
266
|
+
[
|
|
267
|
+
// No font-size here: Button already sets `text-base/7`, and the
|
|
268
|
+
// `text-xs/relaxed` this used to carry shrank its label to 12px.
|
|
269
|
+
// `before:shadow-none`, NOT `shadow-none`. Button paints its drop shadow on
|
|
270
|
+
// the `::before` fill layer (`before:shadow-sm` in the soft and solid
|
|
271
|
+
// variants), never on the button box — so `shadow-none` was doubly dead:
|
|
272
|
+
// wrong element, and a different tailwind-merge key, so both classes
|
|
273
|
+
// survived and the shadow rendered. Measured: `::before` box-shadow was
|
|
274
|
+
// `rgba(0,0,0,.1) 0 1px 3px`, a cast shadow inside flat hairline chrome.
|
|
275
|
+
"flex items-center gap-2 rounded-sm before:shadow-none",
|
|
276
|
+
// Every size below was inert until this line. Button pins
|
|
277
|
+
// `min-h-(--btn-h)` — 52px at the default step, 60px below `sm` — which
|
|
278
|
+
// outranks a plain `h-*` because they are different properties, so an
|
|
279
|
+
// `xs` button rendered at full size and inflated the row it sat in.
|
|
280
|
+
"min-h-0",
|
|
281
|
+
// Button's padding is a RESPONSIVE pair (`py-[…] sm:py-[…]`), and a media
|
|
282
|
+
// query adds no specificity, so an unprefixed override loses to the `sm:`
|
|
283
|
+
// rule on emission order. Restating both halves (`py-0 sm:py-0`) fixes the
|
|
284
|
+
// render but pairs a bare utility with a conditional one on the same
|
|
285
|
+
// property — check:cascade rejects that, and rightly: a consumer whose own
|
|
286
|
+
// build emits `.py-0` can have their copy land last on our element.
|
|
287
|
+
//
|
|
288
|
+
// `data-size` is always set by InputGroupButton, so an attribute selector
|
|
289
|
+
// is 0,2,0 against the media rule's 0,1,0 and wins at every width, with no
|
|
290
|
+
// second rule to order against.
|
|
291
|
+
"data-[size]:py-0",
|
|
292
|
+
// Same reason as InputGroupAction: zeroing Button's padding exposes its
|
|
293
|
+
// `items-baseline` base, which no longer centres the label.
|
|
294
|
+
"items-center"
|
|
295
|
+
// No disabled-opacity handling here on purpose. Button's own
|
|
296
|
+
// `data-disabled:opacity-50` is the whole treatment: this button always
|
|
297
|
+
// renders inside an addon, and the addon fades its own paint rather than
|
|
298
|
+
// its opacity, so there is no ancestor fade to compound with and nothing
|
|
299
|
+
// to neutralise.
|
|
300
|
+
],
|
|
63
301
|
{
|
|
64
302
|
variants: {
|
|
303
|
+
// Heights are capped at 32px: the addon pads 8px top and bottom inside a
|
|
304
|
+
// 48px group, so anything taller re-inflates the row it is meant to sit
|
|
305
|
+
// inside. `sm` buys horizontal room rather than height for that reason.
|
|
65
306
|
size: {
|
|
66
|
-
xs: "h-
|
|
67
|
-
sm: "gap-1",
|
|
68
|
-
"icon-xs": "size-
|
|
69
|
-
"icon-sm": "size-
|
|
307
|
+
xs: "h-8 gap-1 data-[size=xs]:px-3 [&>svg:not([class*='size-'])]:size-5",
|
|
308
|
+
sm: "h-8 gap-1 data-[size=sm]:px-4 [&>svg:not([class*='size-'])]:size-5",
|
|
309
|
+
"icon-xs": "size-7 data-[size=icon-xs]:px-0",
|
|
310
|
+
"icon-sm": "size-8 data-[size=icon-sm]:px-0"
|
|
70
311
|
}
|
|
71
312
|
},
|
|
72
313
|
defaultVariants: {
|
|
@@ -77,7 +318,7 @@ const inputGroupButtonVariants = cva(
|
|
|
77
318
|
function InputGroupButton({
|
|
78
319
|
className,
|
|
79
320
|
type = "button",
|
|
80
|
-
variant = "
|
|
321
|
+
variant = "soft",
|
|
81
322
|
size = "xs",
|
|
82
323
|
...props
|
|
83
324
|
}) {
|
|
@@ -85,6 +326,7 @@ function InputGroupButton({
|
|
|
85
326
|
Button,
|
|
86
327
|
{
|
|
87
328
|
type,
|
|
329
|
+
"data-slot": "input-group-button",
|
|
88
330
|
"data-size": size,
|
|
89
331
|
variant,
|
|
90
332
|
className: cn(inputGroupButtonVariants({ size }), className),
|
|
@@ -92,12 +334,158 @@ function InputGroupButton({
|
|
|
92
334
|
}
|
|
93
335
|
);
|
|
94
336
|
}
|
|
337
|
+
const inputGroupActionVariants = cva(
|
|
338
|
+
[
|
|
339
|
+
// Fills the group's height and sits flush against its trailing edge — one
|
|
340
|
+
// block, not a button floating in addon padding. Button pins
|
|
341
|
+
// `min-h-(--btn-h)` (52px at the default step, 60px below `sm`), which a
|
|
342
|
+
// 48px group cannot hold, so `self-stretch` sizes the segment off the group
|
|
343
|
+
// and `min-h-0` clears the floor.
|
|
344
|
+
//
|
|
345
|
+
// `min-h-0`, NOT `[--btn-h:0px]`: the size step publishes its height through
|
|
346
|
+
// a RESPONSIVE pair (`[--btn-h:…] sm:[--btn-h:…]`), and a media query adds
|
|
347
|
+
// no specificity, so an unprefixed custom-property override loses to the
|
|
348
|
+
// `sm:` rule on emission order alone. Overriding the property itself lands
|
|
349
|
+
// in tailwind-merge's `min-h` group and drops Button's utility outright.
|
|
350
|
+
"h-auto min-h-0 self-stretch",
|
|
351
|
+
// Square: the group re-rounds the one outer corner by clipping (see
|
|
352
|
+
// `has-[[data-slot=input-group-action]]:overflow-hidden` on InputGroup), so
|
|
353
|
+
// there is no corner arithmetic here. The `before`/`after` fill layers are
|
|
354
|
+
// squared too — left at `calc(var(--radius-sm)-1px)` they notch the flush
|
|
355
|
+
// edges.
|
|
356
|
+
"rounded-none before:rounded-none after:rounded-none dark:after:rounded-none",
|
|
357
|
+
// Flush against the value: no optical border, and no shadow — a `shadow-sm`
|
|
358
|
+
// whisper belongs under a button sitting on the page, not one inset into a
|
|
359
|
+
// control. Padding is restated for both breakpoints because Button's is a
|
|
360
|
+
// responsive pair (see the min-h note above).
|
|
361
|
+
// Padding is keyed on `data-slot` rather than restated at both breakpoints:
|
|
362
|
+
// Button's own padding is a responsive pair, and a bare-plus-conditional
|
|
363
|
+
// override of the same property is what check:cascade forbids. The
|
|
364
|
+
// attribute selector is 0,2,0 and wins at every width on specificity.
|
|
365
|
+
"border-0 before:shadow-none data-[slot=input-group-action]:px-5 data-[slot=input-group-action]:py-0",
|
|
366
|
+
// The seam colour is owned here, for both modes, in the ALL-SIDES form.
|
|
367
|
+
// Button's ghost/soft/solid each set `dark:border-white/5`, which is a
|
|
368
|
+
// border-color shorthand — an inline-start longhand would only beat it by
|
|
369
|
+
// emission order, and white at 5% measures 1.12:1 on the dark surface, so
|
|
370
|
+
// the seam vanished there. Matching the shorthand puts both in one
|
|
371
|
+
// tailwind-merge group and drops Button's outright. Width stays 0 except
|
|
372
|
+
// where a variant below asks for it, so only that one edge paints.
|
|
373
|
+
"border-(--input-border) dark:border-(--input-border)",
|
|
374
|
+
// Focus draws INSIDE the segment: Button's default `outline-offset-2` puts
|
|
375
|
+
// the ring on the page, which the clipping group cuts off.
|
|
376
|
+
// `items-center`, because Button's base is `items-baseline`. Baseline
|
|
377
|
+
// alignment only looks centred while Button's own vertical padding
|
|
378
|
+
// balances the line box; with `py-0` and a stretched box it parked the
|
|
379
|
+
// label 9px above centre in a 46px segment. Measured, not eyeballed.
|
|
380
|
+
// The focus ring is stated in full here rather than inherited. Button
|
|
381
|
+
// publishes it as four classes (`focus:outline`, `focus:outline-2`,
|
|
382
|
+
// `focus:outline-offset-2`, `focus:outline-(--btn-bg)`); overriding only the
|
|
383
|
+
// offset left the rendered ring at the browser default — measured
|
|
384
|
+
// `solid 1.5px offset 0px`, not the designed 2px inset. Restating width and
|
|
385
|
+
// offset makes the treatment independent of what tailwind-merge does to
|
|
386
|
+
// Button's copies.
|
|
387
|
+
//
|
|
388
|
+
// Colour is `--input-ring`, the token the GROUP rings itself with, so a
|
|
389
|
+
// focused segment matches the control it sits in instead of borrowing the
|
|
390
|
+
// button system's brand ink. iterate-1.css:
|
|
391
|
+
// `.it .act:focus-visible { outline: 2px solid var(--input-ring); outline-offset: -2px }`.
|
|
392
|
+
"items-center font-semibold focus:outline-2 focus:-outline-offset-2 focus:outline-(--input-ring)"
|
|
393
|
+
// Button's own `data-disabled:opacity-50` is left as the entire disabled
|
|
394
|
+
// treatment, for both placements: flush against the group's edge, and
|
|
395
|
+
// nested in a block-end addon. Neither ancestor fades its opacity, so an
|
|
396
|
+
// Apply that waits for a valid value dims on its own while the live field
|
|
397
|
+
// beside it stays at full strength.
|
|
398
|
+
],
|
|
399
|
+
{
|
|
400
|
+
variants: {
|
|
401
|
+
// Three fills, mapped onto Button's own variants so hover, active and
|
|
402
|
+
// dark-mode handling come from the button system rather than being
|
|
403
|
+
// restated here. `open` and `subtle` have little or no fill contrast
|
|
404
|
+
// against the input surface, so both carry a leading hairline to read as
|
|
405
|
+
// a distinct cell; `solid` needs one only in dark (see below).
|
|
406
|
+
variant: {
|
|
407
|
+
// `open` and `subtle` have no usable fill contrast against the input
|
|
408
|
+
// surface (1:1 and 1.69:1 measured in dark), so both are bounded by a
|
|
409
|
+
// leading hairline in every mode. Colour comes from the base above.
|
|
410
|
+
// The seam is keyed on `data-variant-action` (stamped below) so it beats
|
|
411
|
+
// `border-0` on SPECIFICITY (0,2,0 vs 0,1,0). As a bare `border-s` it
|
|
412
|
+
// did not: tailwind-merge keeps BOTH `border-0` and `border-s` (verified
|
|
413
|
+
// — `border-w-s` invalidates nothing), `border-width:0` expands to the
|
|
414
|
+
// physical longhands and collides with `border-inline-start-width` at
|
|
415
|
+
// equal specificity, so only emission order separated them. Ours wins
|
|
416
|
+
// today by 199 bytes in dist/styles.css; a consuming app that emits its
|
|
417
|
+
// own `.border-0` after ours would reset the seam to 0 and `open` would
|
|
418
|
+
// lose the only thing delineating it. check:cascade cannot catch this —
|
|
419
|
+
// it only flags conditional at-rule pairs.
|
|
420
|
+
open: "bg-transparent data-[variant-action=open]:border-s",
|
|
421
|
+
// `--btn-bg` (the button's own ink) for the ring, NOT the group's
|
|
422
|
+
// `--input-ring`. The base picks `--input-ring` so a focused segment
|
|
423
|
+
// matches the control it sits in, which holds for `open` — measured
|
|
424
|
+
// 3.29:1 against the field surface showing through. On `subtle` the
|
|
425
|
+
// ring lands on the tinted fill instead and measures 2.70:1, under the
|
|
426
|
+
// 3:1 non-text floor of WCAG 1.4.11. The ink reads 14.37:1 there and
|
|
427
|
+
// satisfies the Derived State Rule, which wants focus derived from the
|
|
428
|
+
// one ink variable rather than independently chosen.
|
|
429
|
+
subtle: "focus:outline-(--btn-bg) data-[variant-action=subtle]:border-s",
|
|
430
|
+
// Button rings in `--btn-bg`, which for a solid button IS the fill, so
|
|
431
|
+
// the inset ring above would be navy-on-navy. `--btn-text` is the label
|
|
432
|
+
// colour: 14.37:1 on the fill in both modes.
|
|
433
|
+
//
|
|
434
|
+
// The dark seam is not decoration. Button's `primary` reads the
|
|
435
|
+
// masterbrand ramp (--color-primary-800, Blue 01), which is
|
|
436
|
+
// theme-invariant, so on the dark group surface the fill measures
|
|
437
|
+
// 1.32:1 — under the 3:1 floor for identifying a UI component. The
|
|
438
|
+
// other three edges are bounded by the group's own border; this
|
|
439
|
+
// continues that hairline inward. Light needs none at 15.26:1, and a
|
|
440
|
+
// grey seam there would read as a gap.
|
|
441
|
+
solid: "focus:outline-(--btn-text) data-[variant-action=solid]:dark:border-s"
|
|
442
|
+
}
|
|
443
|
+
},
|
|
444
|
+
defaultVariants: {
|
|
445
|
+
variant: "solid"
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
const inputGroupActionButtonVariant = {
|
|
450
|
+
open: "ghost",
|
|
451
|
+
subtle: "soft",
|
|
452
|
+
solid: "solid"
|
|
453
|
+
};
|
|
454
|
+
function InputGroupAction({
|
|
455
|
+
className,
|
|
456
|
+
type = "button",
|
|
457
|
+
variant = "solid",
|
|
458
|
+
...props
|
|
459
|
+
}) {
|
|
460
|
+
return /* @__PURE__ */ jsx(
|
|
461
|
+
Button,
|
|
462
|
+
{
|
|
463
|
+
type,
|
|
464
|
+
"data-slot": "input-group-action",
|
|
465
|
+
"data-variant-action": variant,
|
|
466
|
+
variant: inputGroupActionButtonVariant[variant ?? "solid"],
|
|
467
|
+
className: cn(inputGroupActionVariants({ variant }), className),
|
|
468
|
+
...props
|
|
469
|
+
}
|
|
470
|
+
);
|
|
471
|
+
}
|
|
95
472
|
function InputGroupText({ className, ...props }) {
|
|
96
473
|
return /* @__PURE__ */ jsx(
|
|
97
474
|
"span",
|
|
98
475
|
{
|
|
99
476
|
className: cn(
|
|
100
|
-
|
|
477
|
+
// Matches the addon it sits in: 16px type, `--input-placeholder` ink,
|
|
478
|
+
// and a nested glyph the same size as one beside it.
|
|
479
|
+
//
|
|
480
|
+
// No disabled rule here, and none on the addon either: affix content
|
|
481
|
+
// stays at full contrast in a disabled group. Do not add one. Two
|
|
482
|
+
// attempts are recorded on inputGroupAddonVariants — a faded `color` on
|
|
483
|
+
// the addon never reaches this span, because setting `color` here
|
|
484
|
+
// overrides the inherited one for its own subtree; and expressing the
|
|
485
|
+
// same fade as `opacity` on the addon's children fixed that but failed
|
|
486
|
+
// the a11y gate, which measures this label at 2.43:1 and cannot tell it
|
|
487
|
+
// belongs to a disabled control. The disabled signal lives on chrome.
|
|
488
|
+
"flex items-center gap-2 text-base text-(--input-placeholder) [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-5",
|
|
101
489
|
className
|
|
102
490
|
),
|
|
103
491
|
...props
|
|
@@ -110,10 +498,28 @@ function InputGroupInput({ className, ...props }) {
|
|
|
110
498
|
{
|
|
111
499
|
"data-slot": "input-group-control",
|
|
112
500
|
className: cn(
|
|
113
|
-
//
|
|
114
|
-
// own
|
|
115
|
-
//
|
|
116
|
-
|
|
501
|
+
// The group owns the box, so fill its height (Input is `h-12` on its
|
|
502
|
+
// own) and drop the border, surface and radius to let the group's
|
|
503
|
+
// chrome show through.
|
|
504
|
+
//
|
|
505
|
+
// The hover surfaces must be neutralised too, even though the group
|
|
506
|
+
// paints the identical token: this control is `rounded-none` and
|
|
507
|
+
// `flex-1`, so with no inline-end addon its right edge lands 1px
|
|
508
|
+
// inside the group's border and its SQUARE corner fills the group's
|
|
509
|
+
// `rounded-sm` corner notch. Same colour, wrong shape — the group's
|
|
510
|
+
// own paint is clipped to its radius, the control's is not. Letting
|
|
511
|
+
// only the group paint keeps the corners round in both the default
|
|
512
|
+
// and the aria-invalid state (where the notch is 2px, not 1px).
|
|
513
|
+
//
|
|
514
|
+
// `outline-0` / `border-0` rather than `outline-none` / `border-none`:
|
|
515
|
+
// tailwind-merge treats those as the same group as Input's
|
|
516
|
+
// `focus-visible:outline-2` / `aria-invalid:border-2` and drops them
|
|
517
|
+
// from the class string outright, so there is never a pair of
|
|
518
|
+
// same-specificity rules whose winner depends on stylesheet order.
|
|
519
|
+
// Input's own `disabled:opacity-50` is deliberately left intact: the
|
|
520
|
+
// group fades only its own chrome, so this control owns its disabled
|
|
521
|
+
// appearance exactly as a bare Input does, and nothing compounds.
|
|
522
|
+
"h-full flex-1 rounded-none border-0 bg-transparent hover:bg-transparent focus-visible:outline-0 aria-invalid:border-0 aria-invalid:hover:bg-transparent",
|
|
117
523
|
className
|
|
118
524
|
),
|
|
119
525
|
...props
|
|
@@ -126,8 +532,31 @@ function InputGroupTextarea({ className, ...props }) {
|
|
|
126
532
|
{
|
|
127
533
|
"data-slot": "input-group-control",
|
|
128
534
|
className: cn(
|
|
129
|
-
//
|
|
130
|
-
|
|
535
|
+
// Identical contract to InputGroupInput, because Textarea is now
|
|
536
|
+
// Input's twin: same `--input-*` tokens, same outline focus treatment,
|
|
537
|
+
// same `aria-invalid:border-2`. The group owns all three, so the same
|
|
538
|
+
// three neutralisers apply, for the same tailwind-merge reason
|
|
539
|
+
// (`outline-0` / `border-0` land in Button's own conflict groups and
|
|
540
|
+
// drop its utilities from the class string rather than racing them).
|
|
541
|
+
// Textarea's own `disabled:opacity-50` is left intact, as in
|
|
542
|
+
// InputGroupInput — the group fades only its chrome.
|
|
543
|
+
//
|
|
544
|
+
// The two `hover:bg-transparent` neutralisers are here for the reason
|
|
545
|
+
// InputGroupInput documents above, and were missing: `bg-transparent`
|
|
546
|
+
// and `hover:bg-*` are different tailwind-merge keys, so Textarea's own
|
|
547
|
+
// `hover:bg-(--input-surface-hover)` survived on the element and
|
|
548
|
+
// outranks the flat `bg-transparent` on specificity. This box is
|
|
549
|
+
// `rounded-none` inside the group's `rounded-sm`, and the group only
|
|
550
|
+
// clips when it holds an action — so a hover surface painted by the
|
|
551
|
+
// control itself can square off the group's corner notch, which is the
|
|
552
|
+
// artefact the input's copies exist to prevent. Restores the "identical
|
|
553
|
+
// contract to InputGroupInput" this comment claims.
|
|
554
|
+
"flex-1 rounded-none border-0 bg-transparent hover:bg-transparent focus-visible:outline-0 aria-invalid:border-0 aria-invalid:hover:bg-transparent",
|
|
555
|
+
// Only the vertical padding differs from Textarea's own: the design's
|
|
556
|
+
// writing surface is `12px 16px`, and Textarea ships `py-2`. Its
|
|
557
|
+
// `min-h-24` (96px) and `px-4` already match the design, so restating
|
|
558
|
+
// them here would be dead weight.
|
|
559
|
+
"py-3",
|
|
131
560
|
className
|
|
132
561
|
),
|
|
133
562
|
...props
|
|
@@ -135,6 +564,6 @@ function InputGroupTextarea({ className, ...props }) {
|
|
|
135
564
|
);
|
|
136
565
|
}
|
|
137
566
|
|
|
138
|
-
export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea };
|
|
567
|
+
export { InputGroup, InputGroupAction, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, inputGroupActionVariants };
|
|
139
568
|
//# sourceMappingURL=input-group.js.map
|
|
140
569
|
//# sourceMappingURL=input-group.js.map
|