@vvedantb/ui 0.59.4 → 0.61.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.
@@ -0,0 +1,317 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import * as React from "react";
3
+ import { Input } from "./input.js";
4
+ import { Label } from "./label.js";
5
+ import { useCn } from "./ui-config.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const FieldContext = /*#__PURE__*/React.createContext(null);
8
+ function useField(part) {
9
+ const value = React.useContext(FieldContext);
10
+ if (!value) {
11
+ throw new Error(`${part} must be used inside <Field>.`);
12
+ }
13
+ return value;
14
+ }
15
+ /**
16
+ * Stack for one labelled control. It generates the control `id` and the ids of
17
+ * the description and error, so `FieldLabel` (`htmlFor`) and `FieldControl`
18
+ * (`id`, `aria-describedby`) link up without any manual wiring.
19
+ *
20
+ * A plain `<Input />` does not need it. Use it when a field has a label, a
21
+ * hint or an error message.
22
+ */
23
+ const Field = /*#__PURE__*/React.forwardRef((t0, ref) => {
24
+ const $ = _c(20);
25
+ let className;
26
+ let controlId;
27
+ let props;
28
+ if ($[0] !== t0) {
29
+ ({
30
+ className,
31
+ controlId,
32
+ ...props
33
+ } = t0);
34
+ $[0] = t0;
35
+ $[1] = className;
36
+ $[2] = controlId;
37
+ $[3] = props;
38
+ } else {
39
+ className = $[1];
40
+ controlId = $[2];
41
+ props = $[3];
42
+ }
43
+ const merge = useCn();
44
+ const generated = React.useId();
45
+ const [hasDescription, setHasDescription] = React.useState(false);
46
+ const [hasError, setHasError] = React.useState(false);
47
+ const id = controlId ?? generated;
48
+ const t1 = `${id}-description`;
49
+ const t2 = `${id}-error`;
50
+ let t3;
51
+ if ($[4] !== hasDescription || $[5] !== hasError || $[6] !== id || $[7] !== t1 || $[8] !== t2) {
52
+ t3 = {
53
+ controlId: id,
54
+ descriptionId: t1,
55
+ errorId: t2,
56
+ hasDescription,
57
+ hasError,
58
+ setHasDescription,
59
+ setHasError
60
+ };
61
+ $[4] = hasDescription;
62
+ $[5] = hasError;
63
+ $[6] = id;
64
+ $[7] = t1;
65
+ $[8] = t2;
66
+ $[9] = t3;
67
+ } else {
68
+ t3 = $[9];
69
+ }
70
+ const context = t3;
71
+ let t4;
72
+ if ($[10] !== className || $[11] !== merge) {
73
+ t4 = merge("grid gap-2", className);
74
+ $[10] = className;
75
+ $[11] = merge;
76
+ $[12] = t4;
77
+ } else {
78
+ t4 = $[12];
79
+ }
80
+ let t5;
81
+ if ($[13] !== props || $[14] !== ref || $[15] !== t4) {
82
+ t5 = /*#__PURE__*/_jsx("div", {
83
+ ref: ref,
84
+ className: t4,
85
+ ...props
86
+ });
87
+ $[13] = props;
88
+ $[14] = ref;
89
+ $[15] = t4;
90
+ $[16] = t5;
91
+ } else {
92
+ t5 = $[16];
93
+ }
94
+ let t6;
95
+ if ($[17] !== context || $[18] !== t5) {
96
+ t6 = /*#__PURE__*/_jsx(FieldContext.Provider, {
97
+ value: context,
98
+ children: t5
99
+ });
100
+ $[17] = context;
101
+ $[18] = t5;
102
+ $[19] = t6;
103
+ } else {
104
+ t6 = $[19];
105
+ }
106
+ return t6;
107
+ });
108
+ Field.displayName = "Field";
109
+
110
+ /** `Label` with `htmlFor` set to the control id of the nearest `Field`. */
111
+ const FieldLabel = /*#__PURE__*/React.forwardRef((props, ref) => {
112
+ const $ = _c(4);
113
+ const {
114
+ controlId
115
+ } = useField("FieldLabel");
116
+ let t0;
117
+ if ($[0] !== controlId || $[1] !== props || $[2] !== ref) {
118
+ t0 = /*#__PURE__*/_jsx(Label, {
119
+ ref: ref,
120
+ htmlFor: controlId,
121
+ ...props
122
+ });
123
+ $[0] = controlId;
124
+ $[1] = props;
125
+ $[2] = ref;
126
+ $[3] = t0;
127
+ } else {
128
+ t0 = $[3];
129
+ }
130
+ return t0;
131
+ });
132
+ FieldLabel.displayName = "FieldLabel";
133
+
134
+ /**
135
+ * `Input` with the `id` of the nearest `Field`. `aria-describedby` lists the
136
+ * description and error ids that are rendered, and nothing when there are none.
137
+ * `aria-invalid` is set while a `FieldError` is rendered. Both merge with props
138
+ * you pass.
139
+ */
140
+ const FieldControl = /*#__PURE__*/React.forwardRef((t0, ref) => {
141
+ const $ = _c(14);
142
+ let describedBy;
143
+ let invalid;
144
+ let props;
145
+ if ($[0] !== t0) {
146
+ ({
147
+ "aria-describedby": describedBy,
148
+ "aria-invalid": invalid,
149
+ ...props
150
+ } = t0);
151
+ $[0] = t0;
152
+ $[1] = describedBy;
153
+ $[2] = invalid;
154
+ $[3] = props;
155
+ } else {
156
+ describedBy = $[1];
157
+ invalid = $[2];
158
+ props = $[3];
159
+ }
160
+ const field = useField("FieldControl");
161
+ const t1 = field.hasDescription ? field.descriptionId : undefined;
162
+ const t2 = field.hasError ? field.errorId : undefined;
163
+ let t3;
164
+ if ($[4] !== describedBy || $[5] !== t1 || $[6] !== t2) {
165
+ t3 = [describedBy, t1, t2].filter(Boolean);
166
+ $[4] = describedBy;
167
+ $[5] = t1;
168
+ $[6] = t2;
169
+ $[7] = t3;
170
+ } else {
171
+ t3 = $[7];
172
+ }
173
+ const ids = t3.join(" ");
174
+ const t4 = ids || undefined;
175
+ const t5 = invalid ?? (field.hasError ? true : undefined);
176
+ let t6;
177
+ if ($[8] !== field.controlId || $[9] !== props || $[10] !== ref || $[11] !== t4 || $[12] !== t5) {
178
+ t6 = /*#__PURE__*/_jsx(Input, {
179
+ ...props,
180
+ ref: ref,
181
+ id: field.controlId,
182
+ "aria-describedby": t4,
183
+ "aria-invalid": t5
184
+ });
185
+ $[8] = field.controlId;
186
+ $[9] = props;
187
+ $[10] = ref;
188
+ $[11] = t4;
189
+ $[12] = t5;
190
+ $[13] = t6;
191
+ } else {
192
+ t6 = $[13];
193
+ }
194
+ return t6;
195
+ });
196
+ FieldControl.displayName = "FieldControl";
197
+ function useRegister(set) {
198
+ const $ = _c(3);
199
+ let t0;
200
+ let t1;
201
+ if ($[0] !== set) {
202
+ t0 = () => {
203
+ set(true);
204
+ return () => set(false);
205
+ };
206
+ t1 = [set];
207
+ $[0] = set;
208
+ $[1] = t0;
209
+ $[2] = t1;
210
+ } else {
211
+ t0 = $[1];
212
+ t1 = $[2];
213
+ }
214
+ React.useLayoutEffect(t0, t1);
215
+ }
216
+
217
+ /** Muted hint under the control. Its id joins the control's `aria-describedby`. */
218
+ const FieldDescription = /*#__PURE__*/React.forwardRef((t0, ref) => {
219
+ const $ = _c(11);
220
+ let className;
221
+ let props;
222
+ if ($[0] !== t0) {
223
+ ({
224
+ className,
225
+ ...props
226
+ } = t0);
227
+ $[0] = t0;
228
+ $[1] = className;
229
+ $[2] = props;
230
+ } else {
231
+ className = $[1];
232
+ props = $[2];
233
+ }
234
+ const field = useField("FieldDescription");
235
+ const merge = useCn();
236
+ useRegister(field.setHasDescription);
237
+ const t1 = field.descriptionId;
238
+ let t2;
239
+ if ($[3] !== className || $[4] !== merge) {
240
+ t2 = merge("text-sm text-muted-foreground", className);
241
+ $[3] = className;
242
+ $[4] = merge;
243
+ $[5] = t2;
244
+ } else {
245
+ t2 = $[5];
246
+ }
247
+ let t3;
248
+ if ($[6] !== field.descriptionId || $[7] !== props || $[8] !== ref || $[9] !== t2) {
249
+ t3 = /*#__PURE__*/_jsx("p", {
250
+ ref: ref,
251
+ id: t1,
252
+ className: t2,
253
+ ...props
254
+ });
255
+ $[6] = field.descriptionId;
256
+ $[7] = props;
257
+ $[8] = ref;
258
+ $[9] = t2;
259
+ $[10] = t3;
260
+ } else {
261
+ t3 = $[10];
262
+ }
263
+ return t3;
264
+ });
265
+ FieldDescription.displayName = "FieldDescription";
266
+
267
+ /** Error message under the control. Its id joins the control's `aria-describedby`, and the control becomes `aria-invalid`. */
268
+ const FieldError = /*#__PURE__*/React.forwardRef((t0, ref) => {
269
+ const $ = _c(11);
270
+ let className;
271
+ let props;
272
+ if ($[0] !== t0) {
273
+ ({
274
+ className,
275
+ ...props
276
+ } = t0);
277
+ $[0] = t0;
278
+ $[1] = className;
279
+ $[2] = props;
280
+ } else {
281
+ className = $[1];
282
+ props = $[2];
283
+ }
284
+ const field = useField("FieldError");
285
+ const merge = useCn();
286
+ useRegister(field.setHasError);
287
+ const t1 = field.errorId;
288
+ let t2;
289
+ if ($[3] !== className || $[4] !== merge) {
290
+ t2 = merge("text-sm text-danger", className);
291
+ $[3] = className;
292
+ $[4] = merge;
293
+ $[5] = t2;
294
+ } else {
295
+ t2 = $[5];
296
+ }
297
+ let t3;
298
+ if ($[6] !== field.errorId || $[7] !== props || $[8] !== ref || $[9] !== t2) {
299
+ t3 = /*#__PURE__*/_jsx("p", {
300
+ ref: ref,
301
+ id: t1,
302
+ role: "alert",
303
+ className: t2,
304
+ ...props
305
+ });
306
+ $[6] = field.errorId;
307
+ $[7] = props;
308
+ $[8] = ref;
309
+ $[9] = t2;
310
+ $[10] = t3;
311
+ } else {
312
+ t3 = $[10];
313
+ }
314
+ return t3;
315
+ });
316
+ FieldError.displayName = "FieldError";
317
+ export { Field, FieldControl, FieldDescription, FieldError, FieldLabel };
@@ -13,6 +13,11 @@ const sizeClasses = {
13
13
  md: {
14
14
  input: "h-10 pl-9",
15
15
  icon: "left-3"
16
+ },
17
+ // Alias of `md`.
18
+ default: {
19
+ input: "h-10 pl-9",
20
+ icon: "left-3"
16
21
  }
17
22
  };
18
23
  const variantClasses = {
@@ -6,6 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  const sizeClasses = {
7
7
  sm: "size-4",
8
8
  md: "size-6",
9
+ default: "size-6",
9
10
  lg: "size-8"
10
11
  };
11
12
 
@@ -396,7 +397,7 @@ function RingSpinner(t0) {
396
397
  t3 = /*#__PURE__*/_jsx("path", {
397
398
  className: "opacity-75",
398
399
  fill: "currentColor",
399
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c3.042 1.135 5.824 3 7.938l3-2.647z"
400
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
400
401
  });
401
402
  $[6] = t2;
402
403
  $[7] = t3;
@@ -298,7 +298,9 @@ const TabsContent = /*#__PURE__*/React.forwardRef((t0, ref) => {
298
298
  return t3;
299
299
  });
300
300
  TabsContent.displayName = TabsPrimitive.Content.displayName;
301
- const tabsBarVariants = cva("flex shrink-0 flex-wrap items-center gap-2 border-b border-border", {
301
+
302
+ /** The class recipe of `TabsBar`. Ignores `UiConfig.Tabs` overrides. */
303
+ export const tabsBarVariants = cva("flex shrink-0 flex-wrap items-center gap-2 border-b border-border", {
302
304
  variants: {
303
305
  size: {
304
306
  default: "px-3 py-2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.59.4",
3
+ "version": "0.61.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared React 19 UI for web apps: one main JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), third-party brand logos (also @vvedantb/ui/logos), motion-driven animated SVG icons (@vvedantb/ui/icons/animated), a client entry without @vvedantb/server, convex or Clerk for Chrome extensions, design-token CSS, shared Tailwind v4 CSS, a Tailwind preset and packaged Instrument Sans fonts.",
6
6
  "type": "module",
@@ -208,7 +208,7 @@
208
208
  "streamdown": "^2.7.1",
209
209
  "tailwind-merge": "^2.6.0",
210
210
  "tailwindcss": "4.3.3",
211
- "typescript": "^5.9.0",
211
+ "typescript": "7.0.2",
212
212
  "use-stick-to-bottom": "^1.1.0",
213
213
  "vaul": "^1.1.0",
214
214
  "vitest": "^3.2.0",
@@ -245,7 +245,7 @@
245
245
  "scripts": {
246
246
  "check:client-graph": "node scripts/check-client-graph.mjs",
247
247
  "check:tokens": "node tokens/scripts/check-component-tokens.mjs",
248
- "build": "node scripts/build-dist.mjs && node tokens/scripts/check-exports.mjs && node tokens/scripts/check-component-tokens.mjs && tsc -p tsconfig.json",
248
+ "build": "node scripts/build-dist.mjs && node tokens/scripts/check-exports.mjs && node tokens/scripts/check-component-tokens.mjs && tsrs -p tsconfig.json",
249
249
  "typecheck": "tsrs --noEmit --fast -p tsconfig.json && tsrs --noEmit --fast -p tsconfig.consumer.json && tsrs --noEmit --fast -p tsconfig.consumer-speech.json && tsrs --noEmit --fast -p tokens/tsconfig.json",
250
250
  "test": "node tokens/scripts/check-component-tokens.mjs && vitest run && node --test tokens/test/*.test.mjs app/tests-node/*.test.mjs",
251
251
  "verify": "node tokens/scripts/check-component-tokens.mjs && node tokens/verify/run.mjs",
@@ -1,5 +1,5 @@
1
1
  import { useState, type ComponentPropsWithoutRef, type ReactNode } from "react";
2
- import { IconLogout, IconMoon, IconSun } from "@tabler/icons-react";
2
+ import { IconCircleHalf, IconLogout, IconMoon, IconSun } from "@tabler/icons-react";
3
3
  import { ConfirmSkipHint, skipConfirmTitle } from "../../app/src/confirm/ConfirmSkipHint";
4
4
  import { useRequestConfirm } from "../../app/src/confirm/useRequestConfirm";
5
5
  import { Button, type ButtonProps } from "../../src/ui/button";
@@ -51,8 +51,12 @@ export type SidebarAccountMenuProps = {
51
51
  >;
52
52
  /** Menu items after the label and separator. */
53
53
  children?: ReactNode;
54
- /** Adds a "Light mode" / "Dark mode" item after `children`. */
55
- themeToggle?: { isDark: boolean; onToggle: () => void };
54
+ /**
55
+ * Adds a theme item after `children`. With `isDark` it names the other of
56
+ * light and dark. With `theme` it names the next theme in the cycle light,
57
+ * neutral, dark (system counts as light), and `onToggle` must move to it.
58
+ */
59
+ themeToggle?: { isDark: boolean; onToggle: () => void } | { theme: string | undefined; onToggle: () => void };
56
60
  /**
57
61
  * Adds a separator and a danger "Sign out" item last. Selecting it opens
58
62
  * `SignOutDialog` (Alt-click skips it, with `ConfirmSkipHint`). The menu owns
@@ -114,12 +118,7 @@ export function SidebarAccountMenu({
114
118
  <AccountLabel userName={name} email={email} imageUrl={imageUrl} stacked={stackedLabel} />
115
119
  <AccountSeparator />
116
120
  {children}
117
- {themeToggle ? (
118
- <DropdownMenuItem onSelect={() => themeToggle.onToggle()}>
119
- {themeToggle.isDark ? <IconSun size={itemIconSize} /> : <IconMoon size={itemIconSize} />}
120
- {themeToggle.isDark ? "Light mode" : "Dark mode"}
121
- </DropdownMenuItem>
122
- ) : null}
121
+ {themeToggle ? <ThemeItem toggle={themeToggle} iconSize={itemIconSize} /> : null}
123
122
  {signOut ? (
124
123
  <>
125
124
  <DropdownMenuSeparator />
@@ -331,3 +330,29 @@ export type SidebarAccountMenuPlaceholderProps = { className?: string };
331
330
  export function SidebarAccountMenuPlaceholder({ className }: SidebarAccountMenuPlaceholderProps) {
332
331
  return <div className={cn("size-11 rounded-lg bg-surface-tertiary md:size-10", className)} />;
333
332
  }
333
+
334
+ type NextTheme = "light" | "neutral" | "dark";
335
+
336
+ /** The theme the menu item moves to: light, then neutral, then dark, then light. */
337
+ export function nextThemeInCycle(theme: string | undefined): NextTheme {
338
+ if (theme === "dark") return "light";
339
+ if (theme === "neutral") return "dark";
340
+ return "neutral";
341
+ }
342
+
343
+ const THEME_ITEM = {
344
+ light: { label: "Light mode", Icon: IconSun },
345
+ neutral: { label: "Neutral mode", Icon: IconCircleHalf },
346
+ dark: { label: "Dark mode", Icon: IconMoon },
347
+ };
348
+
349
+ function ThemeItem({ toggle, iconSize }: { toggle: NonNullable<SidebarAccountMenuProps["themeToggle"]>; iconSize?: number }) {
350
+ const next: NextTheme = "theme" in toggle ? nextThemeInCycle(toggle.theme) : toggle.isDark ? "light" : "dark";
351
+ const { label, Icon } = THEME_ITEM[next];
352
+ return (
353
+ <DropdownMenuItem onSelect={() => toggle.onToggle()}>
354
+ <Icon size={iconSize} />
355
+ {label}
356
+ </DropdownMenuItem>
357
+ );
358
+ }
@@ -55,7 +55,7 @@ export { SidebarIconTooltip } from "./SidebarIconTooltip.js";
55
55
  export type { SidebarIconTooltipProps } from "./SidebarIconTooltip.js";
56
56
  export { SidebarPanel } from "./SidebarPanel.js";
57
57
  export type { SidebarPanelProps } from "./SidebarPanel.js";
58
- export { SidebarAccountMenu, SidebarAccountMenuPlaceholder } from "./SidebarAccountMenu.js";
58
+ export { SidebarAccountMenu, SidebarAccountMenuPlaceholder, nextThemeInCycle } from "./SidebarAccountMenu.js";
59
59
  export type {
60
60
  SidebarAccountMenuProps,
61
61
  SidebarAccountMenuPlaceholderProps,
package/src/client.ts CHANGED
@@ -82,6 +82,7 @@ export * from "./ui/alert-dialog";
82
82
  export * from "./ui/confirm-dialog";
83
83
  export * from "./ui/dropdown-menu";
84
84
  export * from "./ui/empty-state";
85
+ export * from "./ui/field";
85
86
  export * from "./ui/hover-card";
86
87
  export * from "./ui/input";
87
88
  export * from "./ui/label";
@@ -280,7 +281,7 @@ export { SidebarIconTooltip } from "../shell/src/SidebarIconTooltip";
280
281
  export type { SidebarIconTooltipProps } from "../shell/src/SidebarIconTooltip";
281
282
  export { SidebarPanel } from "../shell/src/SidebarPanel";
282
283
  export type { SidebarPanelProps } from "../shell/src/SidebarPanel";
283
- export { SidebarAccountMenu, SidebarAccountMenuPlaceholder } from "../shell/src/SidebarAccountMenu";
284
+ export { SidebarAccountMenu, SidebarAccountMenuPlaceholder, nextThemeInCycle } from "../shell/src/SidebarAccountMenu";
284
285
  export type {
285
286
  SidebarAccountMenuProps,
286
287
  SidebarAccountMenuPlaceholderProps,
@@ -420,6 +421,7 @@ export { SettingsSection, type SettingsSectionConfig } from "../app/src/settings
420
421
  export { SettingsField } from "../app/src/settings/SettingsField";
421
422
  export { SettingsStack } from "../app/src/settings/SettingsStack";
422
423
  export { SettingsToggleRow } from "../app/src/settings/SettingsToggleRow";
424
+ export { THEME_MODES, ThemeModePicker, type ThemeMode, type ThemeModePickerProps } from "../app/src/settings/ThemeModePicker";
423
425
  export { SettingsEmptyState, type SettingsEmptyStateConfig } from "../app/src/settings/SettingsEmptyState";
424
426
  export {
425
427
  DefaultSettingsLayout,
package/src/index.ts CHANGED
@@ -78,6 +78,7 @@ export * from "./ui/alert-dialog";
78
78
  export * from "./ui/confirm-dialog";
79
79
  export * from "./ui/dropdown-menu";
80
80
  export * from "./ui/empty-state";
81
+ export * from "./ui/field";
81
82
  export * from "./ui/hover-card";
82
83
  export * from "./ui/input";
83
84
  export * from "./ui/label";
@@ -281,7 +282,7 @@ export { SidebarIconTooltip } from "../shell/src/SidebarIconTooltip";
281
282
  export type { SidebarIconTooltipProps } from "../shell/src/SidebarIconTooltip";
282
283
  export { SidebarPanel } from "../shell/src/SidebarPanel";
283
284
  export type { SidebarPanelProps } from "../shell/src/SidebarPanel";
284
- export { SidebarAccountMenu, SidebarAccountMenuPlaceholder } from "../shell/src/SidebarAccountMenu";
285
+ export { SidebarAccountMenu, SidebarAccountMenuPlaceholder, nextThemeInCycle } from "../shell/src/SidebarAccountMenu";
285
286
  export type {
286
287
  SidebarAccountMenuProps,
287
288
  SidebarAccountMenuPlaceholderProps,
@@ -16,4 +16,4 @@ exports[`InputGroupAlt markup > input className and props 1`] = `"<div data-inpu
16
16
 
17
17
  exports[`InputGroupAlt markup > input with every addon align and button size 1`] = `"<div data-input-group="" class="flex h-10 flex-wrap rounded-field border border-border bg-field-background text-sm transition-[border-color,box-shadow] duration-200 ease-smooth has-[textarea]:h-auto has-data-[slot=input-group-control]:h-auto has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-focus-visible:outline-hidden has-focus-visible:border-focus-border has-focus-visible:ring-1 has-focus-visible:ring-focus-ring"><div class="flex items-center flex-row ps-3"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="tabler-icon tabler-icon-search"><path d="M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"></path><path d="M21 21l-6 -6"></path></svg></div><div data-align="inline-start" class="flex items-center flex-row ps-3"><span class="flex items-center text-sm text-muted-foreground/95">https://</span></div><input class="flex w-full max-sm:min-w-0 border-border text-base sm:pointer-fine:text-sm transition-[border-color,box-shadow,background-color] duration-200 ease-smooth file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-field-placeholder disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-hidden focus-visible:border-focus-border focus-visible:ring-focus-ring h-full flex-1 rounded-none border-0 bg-transparent px-3 py-2 shadow-none focus-visible:border-0 focus-visible:ring-0" placeholder="Search"><div data-align="inline-end" class="flex items-center flex-row pe-3"><button class="inline-flex items-center justify-center gap-2 whitespace-nowrap font-medium tracking-normal transition-[transform,background-color,box-shadow,opacity,border-color] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 active:scale-[0.96] active:duration-[var(--motion-fast,150ms)] [&amp;_svg]:pointer-events-none [&amp;_svg:not([class*='size-'])]:size-4 [&amp;_svg]:shrink-0 text-muted-foreground hover:bg-surface-tertiary hover:text-foreground py-2 shrink-0 shadow-none h-7 rounded-lg px-2 text-xs">Go</button><button class="inline-flex items-center justify-center gap-2 whitespace-nowrap font-medium tracking-normal transition-[transform,background-color,box-shadow,opacity,border-color] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 active:scale-[0.96] active:duration-[var(--motion-fast,150ms)] [&amp;_svg]:pointer-events-none [&amp;_svg:not([class*='size-'])]:size-4 [&amp;_svg]:shrink-0 text-muted-foreground hover:bg-surface-tertiary hover:text-foreground py-2 shrink-0 shadow-none h-8 rounded-lg px-2.5 text-xs">Small</button><button class="inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium tracking-normal transition-[transform,background-color,box-shadow,opacity,border-color] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 active:scale-[0.96] active:duration-[var(--motion-fast,150ms)] [&amp;_svg]:pointer-events-none [&amp;_svg:not([class*='size-'])]:size-4 [&amp;_svg]:shrink-0 text-muted-foreground hover:bg-surface-tertiary hover:text-foreground px-4 py-2 shrink-0 shadow-none h-7 w-7 rounded-lg" aria-label="A"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="tabler-icon tabler-icon-search"><path d="M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"></path><path d="M21 21l-6 -6"></path></svg></button><button class="inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium tracking-normal transition-[transform,background-color,box-shadow,opacity,border-color] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 active:scale-[0.96] active:duration-[var(--motion-fast,150ms)] [&amp;_svg]:pointer-events-none [&amp;_svg:not([class*='size-'])]:size-4 [&amp;_svg]:shrink-0 bg-primary text-primary-foreground hover:-translate-y-0.5 hover:opacity-90 px-4 py-2 shrink-0 shadow-none h-8 w-8 rounded-lg" type="submit" aria-label="B"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="tabler-icon tabler-icon-search"><path d="M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"></path><path d="M21 21l-6 -6"></path></svg></button></div></div>"`;
18
18
 
19
- exports[`InputGroupAlt markup > textarea with block addons, error and classNames 1`] = `"<div data-input-group="" class="flex h-10 flex-wrap rounded-field border bg-field-background text-sm transition-[border-color,box-shadow] duration-200 ease-smooth has-[textarea]:h-auto has-data-[slot=input-group-control]:h-auto has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-focus-visible:outline-hidden has-focus-visible:ring-1 border-danger-border has-focus-visible:border-danger has-focus-visible:ring-danger-ring root-x" id="g"><div data-align="block-start" class="flex items-center w-full flex-row border-b border-separator px-3 py-2 addon-x"><span class="flex items-center text-sm text-x">Title</span></div><textarea class="flex min-h-20 w-full max-sm:min-w-0 border-border text-base sm:pointer-fine:text-sm placeholder:text-field-placeholder disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-hidden focus-visible:border-focus-border focus-visible:ring-focus-ring flex-1 resize-none rounded-none border-0 bg-transparent px-3 py-2.5 shadow-none focus-visible:border-0 focus-visible:ring-0 field-sizing-content ta-x" rows="2">v</textarea><div data-align="block-end" class="flex items-center w-full flex-row px-3 py-2"><button class="inline-flex items-center justify-center gap-2 whitespace-nowrap font-medium tracking-normal transition-[transform,background-color,box-shadow,opacity,border-color] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 active:scale-[0.96] active:duration-[var(--motion-fast,150ms)] [&amp;_svg]:pointer-events-none [&amp;_svg:not([class*='size-'])]:size-4 [&amp;_svg]:shrink-0 text-muted-foreground hover:bg-surface-tertiary hover:text-foreground py-2 shrink-0 shadow-none h-7 rounded-lg px-2 text-xs btn-x" disabled="" data-loading="true"><svg class="h-4 w-4 animate-spin" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>Send</button></div></div>"`;
19
+ exports[`InputGroupAlt markup > textarea with block addons, error and classNames 1`] = `"<div data-input-group="" class="flex h-10 flex-wrap rounded-field border bg-field-background text-sm transition-[border-color,box-shadow] duration-200 ease-smooth has-[textarea]:h-auto has-data-[slot=input-group-control]:h-auto has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-focus-visible:outline-hidden has-focus-visible:ring-1 border-danger-border has-focus-visible:border-danger has-focus-visible:ring-danger-ring root-x" id="g"><div data-align="block-start" class="flex items-center w-full flex-row border-b border-separator px-3 py-2 addon-x"><span class="flex items-center text-sm text-x">Title</span></div><textarea class="flex min-h-20 w-full max-sm:min-w-0 border-border text-base sm:pointer-fine:text-sm placeholder:text-field-placeholder disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-hidden focus-visible:border-focus-border focus-visible:ring-focus-ring flex-1 resize-none rounded-none border-0 bg-transparent px-3 py-2.5 shadow-none focus-visible:border-0 focus-visible:ring-0 field-sizing-content ta-x" rows="2">v</textarea><div data-align="block-end" class="flex items-center w-full flex-row px-3 py-2"><button class="inline-flex items-center justify-center gap-2 whitespace-nowrap font-medium tracking-normal transition-[transform,background-color,box-shadow,opacity,border-color] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 active:scale-[0.96] active:duration-[var(--motion-fast,150ms)] [&amp;_svg]:pointer-events-none [&amp;_svg:not([class*='size-'])]:size-4 [&amp;_svg]:shrink-0 text-muted-foreground hover:bg-surface-tertiary hover:text-foreground py-2 shrink-0 shadow-none h-7 rounded-lg px-2 text-xs btn-x" disabled="" data-loading="true"><svg class="h-4 w-4 animate-spin" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>Send</button></div></div>"`;
package/src/ui/badge.tsx CHANGED
@@ -15,7 +15,8 @@ const badgeVariantClasses = {
15
15
  warning: "border-warning/25 bg-warning/12 text-warning",
16
16
  };
17
17
 
18
- const badgeVariants = cva(badgeBaseClasses, {
18
+ /** The class recipe of `Badge`. Ignores `UiConfig.Badge` overrides. */
19
+ export const badgeVariants = cva(badgeBaseClasses, {
19
20
  variants: {
20
21
  variant: badgeVariantClasses,
21
22
  },
package/src/ui/button.tsx CHANGED
@@ -10,15 +10,30 @@ const ghostClass =
10
10
  const buttonBaseClasses =
11
11
  "inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium tracking-normal transition-[transform,background-color,box-shadow,opacity,border-color] duration-200 ease-smooth focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 active:scale-[0.96] active:duration-[var(--motion-fast,150ms)] [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0";
12
12
 
13
+ const defaultVariantClass =
14
+ "bg-primary text-primary-foreground hover:-translate-y-0.5 hover:opacity-90";
15
+ const destructiveVariantClass =
16
+ "bg-[oklch(47.2%_0.195_25.7)] text-white hover:bg-[oklch(42.5%_0.185_25.7)]";
17
+
18
+ /**
19
+ * Variant hierarchy:
20
+ * - `primary` (alias of `default`): the one main action.
21
+ * - `secondary`: an alternative action.
22
+ * - `tertiary` (alias of `ghost`): a dismissive action.
23
+ * - `destructive` (alias `danger`): a destructive action.
24
+ * - `success`, `warning`: status.
25
+ * - `outline`, `link`, `flat`: visual treatments with no fixed role.
26
+ */
13
27
  const buttonVariantClasses = {
14
- default:
15
- "bg-primary text-primary-foreground hover:-translate-y-0.5 hover:opacity-90",
16
- destructive:
17
- "bg-[oklch(47.2%_0.195_25.7)] text-white hover:bg-[oklch(42.5%_0.185_25.7)]",
28
+ default: defaultVariantClass,
29
+ primary: defaultVariantClass,
30
+ destructive: destructiveVariantClass,
31
+ danger: destructiveVariantClass,
18
32
  outline:
19
33
  "border border-border bg-transparent text-foreground hover:bg-default",
20
34
  secondary: "bg-default text-default-foreground hover:bg-default/78",
21
35
  ghost: ghostClass,
36
+ tertiary: ghostClass,
22
37
  link: "text-primary underline-offset-4 hover:underline active:scale-100",
23
38
  // Ghost plus an override; tailwind-merge drops the clashing ghost classes.
24
39
  flat: `${ghostClass} bg-transparent text-muted hover:bg-surface-tertiary hover:text-foreground`, // check-tokens-allow: text-muted
@@ -29,6 +44,8 @@ const buttonVariantClasses = {
29
44
  // No radius here: `shape` sets it.
30
45
  const buttonSizeClasses = {
31
46
  default: "h-10 px-4 py-2",
47
+ // Alias of `default`, for the canonical sm / md / lg scale.
48
+ md: "h-10 px-4 py-2",
32
49
  xs: "h-7 px-2 text-xs hit-target [&_svg:not([class*='size-'])]:size-3.5",
33
50
  sm: "h-8 px-3 text-xs max-sm:hit-target",
34
51
  lg: "h-11 px-6",
@@ -44,15 +61,22 @@ const buttonShapeClasses = {
44
61
  rounded: "rounded-lg",
45
62
  };
46
63
 
47
- type ButtonVariant = keyof typeof buttonVariantClasses;
48
- type ButtonSize = keyof typeof buttonSizeClasses;
49
- type ButtonShape = keyof typeof buttonShapeClasses;
64
+ /** `primary`, `tertiary` and `danger` alias `default`, `ghost` and `destructive`. */
65
+ export type ButtonVariant = keyof typeof buttonVariantClasses;
66
+ /** `md` aliases `default` (`h-10`). */
67
+ export type ButtonSize = keyof typeof buttonSizeClasses;
68
+ export type ButtonShape = keyof typeof buttonShapeClasses;
50
69
 
51
70
  // `rounded` keeps the smaller radius the two 28px sizes had.
52
71
  const roundedSmallSizes: ButtonSize[] = ["xs", "icon-xs"];
53
72
  const roundedSmallClass = "rounded-md";
54
73
 
55
- const buttonVariants = cva(buttonBaseClasses, {
74
+ /**
75
+ * The class recipe of `Button`, for links and other elements that should look
76
+ * like one: `<a className={buttonVariants({ variant: "default" })}>`. It
77
+ * ignores `UiConfig.Button` overrides; only the `Button` component applies those.
78
+ */
79
+ export const buttonVariants = cva(buttonBaseClasses, {
56
80
  variants: {
57
81
  variant: buttonVariantClasses,
58
82
  size: buttonSizeClasses,
@@ -89,6 +113,15 @@ export interface ButtonProps
89
113
  extends
90
114
  React.ButtonHTMLAttributes<HTMLButtonElement>,
91
115
  VariantProps<typeof buttonVariants> {
116
+ /**
117
+ * `primary` (alias of `default`) is the one main action; `secondary` an
118
+ * alternative; `tertiary` (alias of `ghost`) a dismissive one; `destructive`
119
+ * (alias `danger`) a destructive one; `success` and `warning` show status;
120
+ * `outline`, `link` and `flat` are visual. Default `"default"`.
121
+ */
122
+ variant?: ButtonVariant | null;
123
+ /** `md` is an alias of `default`. Default `"default"`. */
124
+ size?: ButtonSize | null;
92
125
  asChild?: boolean;
93
126
  /** Rendered before the children. Ignored with `asChild`. */
94
127
  startContent?: React.ReactNode;
@@ -19,6 +19,11 @@ import {
19
19
  import { Input } from "./input";
20
20
  import { useUiConfig } from "./ui-config";
21
21
 
22
+ /**
23
+ * Width caps, not a size scale. `"default"` keeps the dialog's own width;
24
+ * `"sm"` and `"md"` cap the content at `sm:max-w-96` from the `sm` breakpoint.
25
+ * They also change the padding and type of the parts (see each part).
26
+ */
22
27
  export type ConfirmDialogSize = "default" | "sm" | "md";
23
28
 
24
29
  /**
@@ -67,7 +72,7 @@ export function useConfirmDialog(): ConfirmDialogContextValue {
67
72
  }
68
73
 
69
74
  export type ConfirmDialogRootProps = React.ComponentProps<typeof Dialog> & {
70
- /** Layout slot for the other parts. Default `"default"`. */
75
+ /** Layout slot for the other parts. A width cap (`"sm"` and `"md"`: `sm:max-w-96`), not a size scale. Default `"default"`. */
71
76
  size?: ConfirmDialogSize;
72
77
  /** Blocking alert dialog: no outside dismiss, no close button, Cancel focused. Default `size === "default"`. */
73
78
  alert?: boolean;
@@ -47,6 +47,9 @@ export type ConfirmDialogProps = Omit<
47
47
  * button close it). Confirm does not close it; the caller controls `open`.
48
48
  * `"md"`: dismissible dialog like `"sm"`, with a header, description and
49
49
  * footer in separate sections and default-size buttons.
50
+ *
51
+ * The sizes are width caps: `"sm"` and `"md"` cap the content at
52
+ * `sm:max-w-96`; `"default"` keeps the dialog width.
50
53
  */
51
54
  size?: "default" | "sm" | "md";
52
55
  };