@behavioral-agentic-design-system/core 0.22.0 → 0.24.0

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.
@@ -3,6 +3,7 @@
3
3
  import * as React from "react"
4
4
 
5
5
  import { cn } from "../../lib/utils"
6
+ import { Button } from "./button"
6
7
 
7
8
  type SubmitMode = "blur" | "enter" | "both"
8
9
 
@@ -10,6 +11,7 @@ interface EditableContextValue {
10
11
  editing: boolean
11
12
  value: string
12
13
  inputRef: React.RefObject<HTMLInputElement | null>
14
+ previewRef: React.RefObject<HTMLDivElement | null>
13
15
  startEditing: () => void
14
16
  cancelEditing: () => void
15
17
  submitEditing: () => void
@@ -35,6 +37,12 @@ interface EditableProps {
35
37
  disabled?: boolean
36
38
  placeholder?: string
37
39
  submitMode?: SubmitMode
40
+ /**
41
+ * Accessible name for the edit-mode input (e.g. "Project name"). Falls back
42
+ * to `placeholder` — pass a real label whenever the placeholder is the
43
+ * generic "Click to edit", or screen readers announce a nameless textbox.
44
+ */
45
+ label?: string
38
46
  children: React.ReactNode
39
47
  className?: string
40
48
  }
@@ -48,6 +56,7 @@ function Editable({
48
56
  disabled = false,
49
57
  placeholder = "Click to edit",
50
58
  submitMode = "blur",
59
+ label,
51
60
  children,
52
61
  className,
53
62
  }: EditableProps) {
@@ -55,6 +64,8 @@ function Editable({
55
64
  const [editing, setEditing] = React.useState(false)
56
65
  const [draft, setDraft] = React.useState(defaultValue)
57
66
  const inputRef = React.useRef<HTMLInputElement>(null)
67
+ const previewRef = React.useRef<HTMLDivElement>(null)
68
+ const rootRef = React.useRef<HTMLDivElement>(null)
58
69
 
59
70
  const isControlled = valueProp !== undefined
60
71
  const value = isControlled ? valueProp : internalValue
@@ -68,6 +79,17 @@ function Editable({
68
79
  queueMicrotask(() => inputRef.current?.focus())
69
80
  }, [disabled, value, onEditStart])
70
81
 
82
+ // When edit mode ends, DOM focus may still sit on the now aria-hidden,
83
+ // opacity-0 input (Escape/Enter don't blur) or on a Save/Cancel button that
84
+ // is about to unmount — both strand keyboard focus on nothing. Return focus
85
+ // to the preview, but ONLY if focus is still inside this Editable: a
86
+ // blur-submit triggered by clicking elsewhere must not steal focus back.
87
+ const restoreFocusToPreview = React.useCallback(() => {
88
+ const hadFocusInside = rootRef.current?.contains(document.activeElement)
89
+ if (!hadFocusInside) return
90
+ queueMicrotask(() => previewRef.current?.focus())
91
+ }, [])
92
+
71
93
  const submitEditing = React.useCallback(() => {
72
94
  if (!editing) return
73
95
  const trimmed = draft.trim()
@@ -75,13 +97,15 @@ function Editable({
75
97
  if (!isControlled) setInternalValue(committed)
76
98
  onValueChange?.(committed)
77
99
  onEditEnd?.(committed)
100
+ restoreFocusToPreview()
78
101
  setEditing(false)
79
- }, [editing, draft, value, isControlled, onValueChange, onEditEnd])
102
+ }, [editing, draft, value, isControlled, onValueChange, onEditEnd, restoreFocusToPreview])
80
103
 
81
104
  const cancelEditing = React.useCallback(() => {
82
105
  setDraft(value)
106
+ restoreFocusToPreview()
83
107
  setEditing(false)
84
- }, [value])
108
+ }, [value, restoreFocusToPreview])
85
109
 
86
110
  return (
87
111
  <EditableContext.Provider
@@ -89,6 +113,7 @@ function Editable({
89
113
  editing,
90
114
  value,
91
115
  inputRef,
116
+ previewRef,
92
117
  startEditing,
93
118
  cancelEditing,
94
119
  submitEditing,
@@ -98,6 +123,7 @@ function Editable({
98
123
  }}
99
124
  >
100
125
  <div
126
+ ref={rootRef}
101
127
  data-slot="editable"
102
128
  data-editing={editing || undefined}
103
129
  data-disabled={disabled || undefined}
@@ -108,6 +134,7 @@ function Editable({
108
134
  <input
109
135
  ref={inputRef}
110
136
  type="text"
137
+ aria-label={label ?? placeholder}
111
138
  aria-hidden={!editing}
112
139
  tabIndex={editing ? 0 : -1}
113
140
  value={draft}
@@ -131,9 +158,18 @@ function Editable({
131
158
  }
132
159
  }}
133
160
  className={cn(
134
- "absolute inset-0 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground outline-none",
161
+ // Overlay ONLY the preview area (top of the root), not inset-0 — the root
162
+ // also holds EditableControl (Save/Cancel), and inset-0 stretched the input
163
+ // over those controls, hiding them and ballooning the box. min-h-11 + py-2
164
+ // matches the preview's box so the text doesn't jump on the edit crossfade.
165
+ "absolute inset-x-0 top-0 min-h-11 w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground outline-none",
135
166
  "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
136
- "disabled:cursor-not-allowed disabled:opacity-50",
167
+ // The overlay input is only ever visible while editing. A disabled
168
+ // Editable can never enter edit mode, so it must NOT get disabled:opacity-50
169
+ // here — that variant beat the opacity-0 below and un-hid the input at
170
+ // 50%, ghosting it over the (also-50%) preview. Dimming when disabled is
171
+ // the preview's job.
172
+ "disabled:cursor-not-allowed",
137
173
  !editing && "pointer-events-none opacity-0"
138
174
  )}
139
175
  style={{
@@ -153,15 +189,20 @@ interface EditablePreviewProps extends React.HTMLAttributes<HTMLDivElement> {
153
189
  }
154
190
 
155
191
  function EditablePreview({ className, ...props }: EditablePreviewProps) {
156
- const { editing, value, placeholder, startEditing, disabled } =
192
+ const { editing, value, placeholder, startEditing, disabled, previewRef } =
157
193
  useEditableContext()
158
194
 
159
195
  return (
160
196
  <div
197
+ ref={previewRef}
161
198
  data-slot="editable-preview"
162
199
  role="button"
163
200
  tabIndex={disabled ? -1 : 0}
164
201
  aria-label={`Edit: ${value || placeholder}`}
202
+ // Marks the control disabled for assistive tech AND tells axe to exempt the
203
+ // dimmed (opacity-50) label from the contrast check — disabled controls are
204
+ // WCAG-exempt, but without aria-disabled axe can't know this div is one.
205
+ aria-disabled={disabled || undefined}
165
206
  onClick={() => !disabled && startEditing()}
166
207
  onKeyDown={(e) => {
167
208
  if ((e.key === "Enter" || e.key === " ") && !disabled) {
@@ -219,7 +260,7 @@ function EditableControl({ className, ...props }: EditableControlProps) {
219
260
  return (
220
261
  <div
221
262
  data-slot="editable-control"
222
- className={cn("flex items-center gap-1 pt-1", className)}
263
+ className={cn("flex items-center gap-2 pt-2.5", className)}
223
264
  {...props}
224
265
  />
225
266
  )
@@ -233,20 +274,16 @@ interface EditableSubmitProps
233
274
  function EditableSubmit({ className, children, ...props }: EditableSubmitProps) {
234
275
  const { submitEditing } = useEditableContext()
235
276
  return (
236
- // allow-text-xs-cta — inline editable chip; full min-h-11 CTA is a separate affordance
237
- <button
277
+ <Button
238
278
  type="button"
239
279
  data-slot="editable-submit"
280
+ size="default"
240
281
  onClick={submitEditing}
241
- className={cn(
242
- "inline-flex min-h-7 items-center rounded-md bg-primary px-2 text-sm font-medium text-primary-foreground",
243
- "hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
244
- className
245
- )}
282
+ className={className}
246
283
  {...props}
247
284
  >
248
285
  {children ?? "Save"}
249
- </button>
286
+ </Button>
250
287
  )
251
288
  }
252
289
 
@@ -262,25 +299,17 @@ function EditableCancel({
262
299
  }: EditableCancelProps) {
263
300
  const { cancelEditing } = useEditableContext()
264
301
  return (
265
- // allow-text-xs-cta — inline editable chip; full min-h-11 CTA is a separate affordance
266
- <button
302
+ <Button
267
303
  type="button"
268
304
  data-slot="editable-cancel"
305
+ variant="ghost"
306
+ size="default"
269
307
  onClick={cancelEditing}
270
- className={cn(
271
- "inline-flex min-h-7 items-center rounded-md px-2 text-sm font-medium text-muted-foreground",
272
- "hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
273
- className
274
- )}
275
- style={{
276
- transitionProperty: "background-color, color",
277
- transitionDuration: "var(--duration-fast)",
278
- transitionTimingFunction: "var(--ease-out)",
279
- }}
308
+ className={className}
280
309
  {...props}
281
310
  >
282
311
  {children ?? "Cancel"}
283
- </button>
312
+ </Button>
284
313
  )
285
314
  }
286
315
 
@@ -0,0 +1,244 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+
6
+ import { cn } from "../../lib/utils";
7
+
8
+ /**
9
+ * Semantic grouping for related form controls. Renders a native
10
+ * <fieldset> + <legend>, so the group gets a real accessible name (announced
11
+ * when focus enters any nested control) and, critically, native
12
+ * <fieldset disabled> cascade-disables EVERY control inside it, something a
13
+ * <div> group (FieldGroup) cannot do.
14
+ *
15
+ * Use Fieldset when several controls answer one question: a RadioGroup of
16
+ * plan tiers, a set of notification checkboxes, an address block. Use Field
17
+ * for a single labelled input, and FieldGroup for pure column/row layout of
18
+ * unrelated fields.
19
+ *
20
+ * <Fieldset invalid={!!error}>
21
+ * <FieldsetLegend>Notification preferences</FieldsetLegend>
22
+ * <FieldsetHelper>Choose how we reach you.</FieldsetHelper>
23
+ * ...controls...
24
+ * <FieldsetError>{error}</FieldsetError>
25
+ * </Fieldset>
26
+ *
27
+ * Place <FieldsetLegend> FIRST, because the browser requires <legend> to be the
28
+ * fieldset's first child to render and be announced correctly.
29
+ */
30
+
31
+ type FieldsetContextValue = {
32
+ helperId: string;
33
+ errorId: string;
34
+ invalid: boolean;
35
+ disabled: boolean;
36
+ registerHelper: (present: boolean) => void;
37
+ registerError: (present: boolean) => void;
38
+ };
39
+
40
+ const FieldsetContext = React.createContext<FieldsetContextValue | null>(null);
41
+
42
+ function useFieldsetContext() {
43
+ const ctx = React.useContext(FieldsetContext);
44
+ if (!ctx) {
45
+ throw new Error(
46
+ "Fieldset subcomponents must be rendered inside a <Fieldset> parent.",
47
+ );
48
+ }
49
+ return ctx;
50
+ }
51
+
52
+ const fieldsetVariants = cva(
53
+ // Column flow so legend → helper → controls → error stack with rhythm.
54
+ // transition-[color,box-shadow] animates the invalid border shift; the
55
+ // duration/ease come from tokens via the inline style below (Tailwind v4 has
56
+ // no --duration-* namespace, so the class form would silently no-op).
57
+ "flex min-w-0 flex-col transition-[color,box-shadow]",
58
+ {
59
+ variants: {
60
+ variant: {
61
+ default: "rounded-lg border border-border bg-transparent",
62
+ unstyled: "border-0 p-0",
63
+ },
64
+ size: {
65
+ sm: "gap-2",
66
+ default: "gap-3",
67
+ lg: "gap-4",
68
+ },
69
+ },
70
+ compoundVariants: [
71
+ { variant: "default", size: "sm", className: "p-4" },
72
+ { variant: "default", size: "default", className: "p-5" },
73
+ { variant: "default", size: "lg", className: "p-6" },
74
+ ],
75
+ defaultVariants: { variant: "default", size: "default" },
76
+ },
77
+ );
78
+
79
+ export interface FieldsetProps
80
+ extends Omit<React.ComponentProps<"fieldset">, "disabled">,
81
+ VariantProps<typeof fieldsetVariants> {
82
+ /**
83
+ * Native cascade-disable: disables the fieldset AND every form control
84
+ * nested inside it, no per-control wiring needed.
85
+ */
86
+ disabled?: boolean;
87
+ /** Paints the destructive border/legend and switches aria-describedby to the error. */
88
+ invalid?: boolean;
89
+ }
90
+
91
+ function Fieldset({
92
+ className,
93
+ variant,
94
+ size,
95
+ disabled = false,
96
+ invalid = false,
97
+ style,
98
+ children,
99
+ ...props
100
+ }: FieldsetProps) {
101
+ const reactId = React.useId();
102
+ const helperId = `fieldset-${reactId}-helper`;
103
+ const errorId = `fieldset-${reactId}-error`;
104
+
105
+ const [hasHelper, setHasHelper] = React.useState(false);
106
+ const [hasError, setHasError] = React.useState(false);
107
+
108
+ const ctx = React.useMemo<FieldsetContextValue>(
109
+ () => ({
110
+ helperId,
111
+ errorId,
112
+ invalid,
113
+ disabled,
114
+ registerHelper: setHasHelper,
115
+ registerError: setHasError,
116
+ }),
117
+ [helperId, errorId, invalid, disabled],
118
+ );
119
+
120
+ // Only reference ids that are actually in the DOM, so aria-describedby never
121
+ // dangles (axe aria-valid-attr-value). When invalid, the error replaces the
122
+ // helper both visually and for screen readers.
123
+ const describedBy = invalid
124
+ ? hasError
125
+ ? errorId
126
+ : undefined
127
+ : hasHelper
128
+ ? helperId
129
+ : undefined;
130
+
131
+ return (
132
+ <FieldsetContext.Provider value={ctx}>
133
+ <fieldset
134
+ data-slot="fieldset"
135
+ data-invalid={invalid || undefined}
136
+ data-disabled={disabled || undefined}
137
+ disabled={disabled}
138
+ aria-describedby={describedBy}
139
+ className={cn(
140
+ "group",
141
+ fieldsetVariants({ variant, size }),
142
+ invalid && variant === "default" && "border-destructive",
143
+ className,
144
+ )}
145
+ style={{
146
+ transitionDuration: "var(--duration-base)",
147
+ transitionTimingFunction: "var(--ease-out)",
148
+ ...style,
149
+ }}
150
+ {...props}
151
+ >
152
+ {children}
153
+ </fieldset>
154
+ </FieldsetContext.Provider>
155
+ );
156
+ }
157
+
158
+ /** The group's accessible name. Render as the FIRST child of Fieldset. */
159
+ function FieldsetLegend({
160
+ className,
161
+ ...props
162
+ }: React.ComponentProps<"legend">) {
163
+ const { invalid } = useFieldsetContext();
164
+ return (
165
+ <legend
166
+ data-slot="fieldset-legend"
167
+ className={cn(
168
+ // float-left (not float-none!) is what opts a <legend> OUT of the
169
+ // browser's native "rendered legend" placement — with float:none the
170
+ // legend is drawn straddling the fieldset's top border (HTML rendering
171
+ // spec), which strikes the border line through the title and notches
172
+ // the top edge (shipped broken 2026-07-04, caught by Sir on prod).
173
+ // Inside the flex fieldset the float is then inert and the legend lays
174
+ // out as a normal first flex item; w-full keeps it on its own row.
175
+ "float-left w-full text-sm font-semibold text-foreground",
176
+ "group-data-[disabled]:text-muted-foreground",
177
+ invalid && "text-destructive",
178
+ className,
179
+ )}
180
+ {...props}
181
+ />
182
+ );
183
+ }
184
+
185
+ /** Group-level description, wired to the fieldset via aria-describedby. */
186
+ function FieldsetHelper({ className, ...props }: React.ComponentProps<"p">) {
187
+ const { helperId, invalid, registerHelper } = useFieldsetContext();
188
+
189
+ React.useEffect(() => {
190
+ registerHelper(true);
191
+ return () => registerHelper(false);
192
+ }, [registerHelper]);
193
+
194
+ return (
195
+ <p
196
+ data-slot="fieldset-helper"
197
+ id={helperId}
198
+ // Hidden when invalid so the error (below) is the single announced
199
+ // description, matching Field's helper/error handoff.
200
+ className={cn(
201
+ "-mt-1 text-sm text-muted-foreground",
202
+ invalid && "hidden",
203
+ className,
204
+ )}
205
+ {...props}
206
+ />
207
+ );
208
+ }
209
+
210
+ /** Group-level error. Renders only when the Fieldset is invalid and has content. */
211
+ function FieldsetError({
212
+ className,
213
+ children,
214
+ ...props
215
+ }: React.ComponentProps<"p">) {
216
+ const { errorId, invalid, registerError } = useFieldsetContext();
217
+ const shown = invalid && !!children;
218
+
219
+ React.useEffect(() => {
220
+ registerError(shown);
221
+ return () => registerError(false);
222
+ }, [registerError, shown]);
223
+
224
+ if (!shown) return null;
225
+ return (
226
+ <p
227
+ data-slot="fieldset-error"
228
+ id={errorId}
229
+ role="alert"
230
+ className={cn("text-sm font-medium text-destructive", className)}
231
+ {...props}
232
+ >
233
+ {children}
234
+ </p>
235
+ );
236
+ }
237
+
238
+ export {
239
+ Fieldset,
240
+ FieldsetLegend,
241
+ FieldsetHelper,
242
+ FieldsetError,
243
+ fieldsetVariants,
244
+ };
@@ -19,11 +19,14 @@ export * from "./collapsible";
19
19
  export * from "./color-picker";
20
20
  export * from "./command";
21
21
  export * from "./context-menu";
22
+ export * from "./data-list";
22
23
  export * from "./dialog";
23
24
  export * from "./dropdown-menu";
25
+ export * from "./fieldset";
24
26
  export * from "./file-upload";
25
27
  export * from "./hover-card";
26
28
  export * from "./input";
29
+ export * from "./input-group";
27
30
  export * from "./kbd";
28
31
  export * from "./label";
29
32
  export * from "./menubar";
@@ -60,3 +63,4 @@ export * from "./toolbar";
60
63
  export * from "./tooltip";
61
64
  export * from "./tree-view";
62
65
  export * from "./editable";
66
+ export * from "./qr-code";
@@ -0,0 +1,204 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+
6
+ import { cn } from "../../lib/utils";
7
+ import { Button } from "./button";
8
+
9
+ // ─── Variants ─────────────────────────────────────────────────────────────────
10
+ //
11
+ // The group is the ring owner. The hosted <input> is borderless + outline-none
12
+ // so there is exactly ONE focus indicator (the container's focus-within ring),
13
+ // which keeps it high-contrast-mode safe. Same container-owns-ring contract as
14
+ // PasswordInput, generalized to arbitrary leading/trailing addons.
15
+
16
+ const inputGroupVariants = cva(
17
+ [
18
+ "flex items-center overflow-hidden",
19
+ "rounded-md border border-input bg-transparent shadow-xs",
20
+ "transition-[color,box-shadow]",
21
+ "focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50",
22
+ // Scope disabled styling to the hosted INPUT — has-[:disabled] matched any
23
+ // descendant, so an inline CopyButton disabling itself during its 2s
24
+ // "Copied!" window faded the whole group to 50% (found 2026-07-06).
25
+ "has-[input:disabled]:pointer-events-none has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50",
26
+ "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
27
+ ],
28
+ {
29
+ variants: {
30
+ size: {
31
+ sm: "h-8 text-sm",
32
+ default: "h-9 text-base md:text-sm",
33
+ lg: "h-10 text-base",
34
+ xl: "h-11 text-base",
35
+ "2xl": "h-12 text-lg",
36
+ },
37
+ },
38
+ defaultVariants: { size: "default" },
39
+ }
40
+ );
41
+
42
+ type InputGroupSize = NonNullable<VariantProps<typeof inputGroupVariants>["size"]>;
43
+
44
+ const InputGroupSizeContext = React.createContext<InputGroupSize>("default");
45
+
46
+ // Per-size padding for the hosted input and the flanking addons, so the group
47
+ // reads with the same internal rhythm as a standalone Input at each size.
48
+ const inputPaddingBySize: Record<InputGroupSize, string> = {
49
+ sm: "px-2.5 py-1",
50
+ default: "px-3 py-1",
51
+ lg: "px-4 py-2",
52
+ xl: "px-4 py-2",
53
+ "2xl": "px-5 py-2.5",
54
+ };
55
+
56
+ const addonPaddingBySize: Record<InputGroupSize, string> = {
57
+ sm: "px-2.5",
58
+ default: "px-3",
59
+ lg: "px-3.5",
60
+ xl: "px-3.5",
61
+ "2xl": "px-4",
62
+ };
63
+
64
+ // ─── Root ─────────────────────────────────────────────────────────────────────
65
+
66
+ export interface InputGroupProps
67
+ extends React.ComponentProps<"div">,
68
+ VariantProps<typeof inputGroupVariants> {}
69
+
70
+ function InputGroup({
71
+ className,
72
+ size,
73
+ "aria-invalid": ariaInvalid,
74
+ ...props
75
+ }: InputGroupProps) {
76
+ const resolvedSize: InputGroupSize = size ?? "default";
77
+ return (
78
+ <InputGroupSizeContext.Provider value={resolvedSize}>
79
+ <div
80
+ role="group"
81
+ data-slot="input-group"
82
+ aria-invalid={ariaInvalid}
83
+ className={cn(inputGroupVariants({ size, className }))}
84
+ {...props}
85
+ />
86
+ </InputGroupSizeContext.Provider>
87
+ );
88
+ }
89
+
90
+ // ─── Input ────────────────────────────────────────────────────────────────────
91
+
92
+ function InputGroupInput({
93
+ className,
94
+ type,
95
+ ...props
96
+ }: React.ComponentProps<"input">) {
97
+ const size = React.useContext(InputGroupSizeContext);
98
+ return (
99
+ <input
100
+ type={type}
101
+ data-slot="input-group-input"
102
+ className={cn(
103
+ "min-w-0 flex-1 bg-transparent outline-none",
104
+ "placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground",
105
+ "disabled:cursor-not-allowed dark:bg-input/30",
106
+ inputPaddingBySize[size],
107
+ // Collapse the doubled inner edge next to an addon: the addon already
108
+ // carries the group's horizontal rhythm (its outer padding), so the
109
+ // input's full padding on the shared edge reads as a floating gap
110
+ // ("https:// value" — Sir, 2026-07-06). 6px keeps a text prefix
111
+ // reading continuous with the value while an icon addon still breathes.
112
+ "[[data-slot=input-group-addon][data-align=inline-start]+&]:ps-1.5",
113
+ "[&:has(+[data-slot=input-group-addon][data-align=inline-end])]:pe-1.5",
114
+ className
115
+ )}
116
+ {...props}
117
+ />
118
+ );
119
+ }
120
+
121
+ // ─── Addon ────────────────────────────────────────────────────────────────────
122
+ //
123
+ // A non-interactive slot for icons or text pinned to the start/end of the group.
124
+ // It sits as a SIBLING of the input (never wrapping it), so no interactive child
125
+ // it may hold ever nests inside another interactive element (axe nested-interactive).
126
+
127
+ export interface InputGroupAddonProps extends React.ComponentProps<"div"> {
128
+ /** Which edge of the group the addon sits on. */
129
+ align?: "inline-start" | "inline-end";
130
+ }
131
+
132
+ function InputGroupAddon({
133
+ className,
134
+ align = "inline-start",
135
+ ...props
136
+ }: InputGroupAddonProps) {
137
+ const size = React.useContext(InputGroupSizeContext);
138
+ return (
139
+ <div
140
+ data-slot="input-group-addon"
141
+ data-align={align}
142
+ className={cn(
143
+ "flex shrink-0 items-center gap-1.5 text-muted-foreground",
144
+ "[&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:stroke-[1.5]",
145
+ addonPaddingBySize[size],
146
+ align === "inline-start" ? "pr-0" : "pl-0",
147
+ className
148
+ )}
149
+ {...props}
150
+ />
151
+ );
152
+ }
153
+
154
+ // ─── Text ─────────────────────────────────────────────────────────────────────
155
+ //
156
+ // A prefix/suffix label (currency symbol, unit, protocol). Presentation only —
157
+ // aria-hidden so screen readers rely on the field's own label, not the ornament.
158
+
159
+ function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {
160
+ return (
161
+ <span
162
+ data-slot="input-group-text"
163
+ aria-hidden
164
+ className={cn("select-none whitespace-nowrap text-muted-foreground", className)}
165
+ {...props}
166
+ />
167
+ );
168
+ }
169
+
170
+ // ─── Button ───────────────────────────────────────────────────────────────────
171
+ //
172
+ // An inline action (Copy, Send, Search). Wraps the Button primitive so it
173
+ // inherits the system's token-driven hover/focus motion. Renders as a sibling
174
+ // of the input — never a parent of it.
175
+
176
+ export type InputGroupButtonProps = React.ComponentProps<typeof Button>;
177
+
178
+ function InputGroupButton({
179
+ className,
180
+ variant = "ghost",
181
+ size = "sm",
182
+ type = "button",
183
+ ...props
184
+ }: InputGroupButtonProps) {
185
+ return (
186
+ <Button
187
+ data-slot="input-group-button"
188
+ type={type}
189
+ variant={variant}
190
+ size={size}
191
+ className={cn("h-full shrink-0 rounded-none", className)}
192
+ {...props}
193
+ />
194
+ );
195
+ }
196
+
197
+ export {
198
+ InputGroup,
199
+ InputGroupInput,
200
+ InputGroupAddon,
201
+ InputGroupText,
202
+ InputGroupButton,
203
+ inputGroupVariants,
204
+ };