@bettercms-ai/kit 3.1.12 → 3.1.13

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/theme.css CHANGED
@@ -282,7 +282,7 @@
282
282
  box-shadow: 0 1px 2px rgb(16 16 16 / 0.04), 0 8px 24px -6px rgb(16 16 16 / 0.12);
283
283
  &:is(.dark *) {
284
284
  background-color: var(--kit-surface-raised);
285
- border-color: var(--kit-line-strong);
285
+ border-color: var(--kit-floating-line); /* 4B: keeps the V2 dark edge (#454548) now that line-strong is a 3:1 control boundary */
286
286
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.04), 0 12px 32px -8px oklch(0.12 0.01 286 / 0.5);
287
287
  }
288
288
  }
@@ -298,7 +298,7 @@
298
298
  box-shadow: 0 1px 2px rgb(16 16 16 / 0.05), 0 16px 40px -8px rgb(16 16 16 / 0.18);
299
299
  &:is(.dark *) {
300
300
  background-color: var(--kit-surface-raised);
301
- border-color: var(--kit-line-strong);
301
+ border-color: var(--kit-floating-line); /* 4B: keeps the V2 dark edge (#454548) now that line-strong is a 3:1 control boundary */
302
302
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.05), 0 16px 40px -8px oklch(0.12 0.01 286 / 0.58);
303
303
  }
304
304
  }
package/dist/tokens.css CHANGED
@@ -95,9 +95,9 @@
95
95
  --kit-fg-4: #707074;
96
96
  --kit-fg-inverse: #ffffff;
97
97
  --kit-line: #e5e5e5;
98
- --kit-line-strong: #dcdcdf;
98
+ --kit-line-strong: #8b8b8e; /* 4B: was V2 #dcdcdf (1.28:1); WCAG 1.4.11 control boundary */
99
99
  --kit-line-subtle: #f0f0f1;
100
- --kit-field-border: #cfcfd4;
100
+ --kit-field-border: #909095; /* 4B: was V2 #cfcfd4 (1.55:1) */
101
101
  --kit-focus-ring: #838383; /* V2 demo is #a3a3a3 — 2.1–2.5:1 on V2 surfaces fails WCAG 1.4.11; same neutral, darker */
102
102
  --kit-accent: #a354e9;
103
103
  --kit-accent-hover: #9140dc;
@@ -107,7 +107,7 @@
107
107
  --kit-accent-line: #e3ccf8;
108
108
  --kit-accent-fg: #6c3b97;
109
109
  --kit-accent-on: #ffffff;
110
- --kit-success: #3cba71;
110
+ --kit-success: #12a059; /* 4B: was V2 #3cba71 (2.32:1, white thumb 2.48:1) */
111
111
  --kit-success-soft: #dcfce7;
112
112
  --kit-success-softer: #eefef3;
113
113
  --kit-success-line: #c5ead4;
@@ -138,7 +138,7 @@
138
138
  --kit-field-bg: #ffffff;
139
139
  --kit-field-border-hover: #85858b;
140
140
  --kit-field-border-focus: #6a6a6f;
141
- --kit-switch-off: #dcdcdf;
141
+ --kit-switch-off: #8b8b8e; /* 4B: was V2 #dcdcdf (1.28:1) */
142
142
  --kit-control-thumb: #ffffff;
143
143
  --kit-swatch-ring: rgb(0 0 0 / 0.1);
144
144
  --kit-on-inverse-2: rgb(255 255 255 / 0.7);
@@ -200,7 +200,7 @@
200
200
  --kit-avatar-on: #ffffff;
201
201
  --kit-kbd: #f7f7f7;
202
202
  --kit-kbd-line: #e5e5e5;
203
- --kit-field-invalid: #dd868b;
203
+ --kit-field-invalid: #c87379; /* 4B: was V2 #dd868b (2.49:1) */
204
204
  --kit-emphasis-line: #6a6a6f;
205
205
  --kit-track: #ededed;
206
206
  --kit-track-line: #e2e2e2;
@@ -315,7 +315,7 @@
315
315
  --kit-fg-4: #9e9ea1;
316
316
  --kit-fg-inverse: #1b1b1e;
317
317
  --kit-line: #3a3a3d;
318
- --kit-line-strong: #454548;
318
+ --kit-line-strong: #79797d; /* 4B: was V2 #454548 (1.43:1) */
319
319
  --kit-line-subtle: #353538;
320
320
  --kit-field-border: #747477;
321
321
  --kit-focus-ring: #929295;
@@ -327,7 +327,7 @@
327
327
  --kit-accent-line: #5d4676;
328
328
  --kit-accent-fg: #d1b6f3;
329
329
  --kit-accent-on: #1e1628;
330
- --kit-success: #58b575;
330
+ --kit-success: #3a995b; /* 4B: was V2 #58b575 (light thumb 2.25:1) */
331
331
  --kit-success-soft: rgb(12 192 35 / 0.1);
332
332
  --kit-success-softer: #1e2820;
333
333
  --kit-success-line: #2c5f3c;
@@ -102,7 +102,7 @@ function ChoiceCard({ selected, onSelect, icon, title, description, badge, class
102
102
  function ChoiceList({ className, children, ...props }) {
103
103
  return /* @__PURE__ */ jsx("div", {
104
104
  role: "group",
105
- className: cn("flex flex-col divide-y divide-kit-line-subtle overflow-hidden rounded-kit-lg border border-kit-line", "[&>*]:rounded-none [&>*]:border-0 [&>*]:shadow-none [&>*]:hover:shadow-none [&>*]:hover:bg-kit-hover [&>[aria-pressed=true]]:bg-kit-selected [&>[aria-pressed=true]]:shadow-none", className),
105
+ className: cn("flex flex-col divide-y divide-kit-line-subtle overflow-hidden rounded-kit-lg border border-kit-line-strong", "[&>*]:rounded-none [&>*]:border-0 [&>*]:shadow-none [&>*]:hover:shadow-none [&>*]:hover:bg-kit-hover [&>[aria-pressed=true]]:bg-kit-selected [&>[aria-pressed=true]]:shadow-none", className),
106
106
  ...props,
107
107
  children
108
108
  });
@@ -204,7 +204,7 @@ function Segmented({ value, onChange, items, size = "md", className, layoutId, i
204
204
  role: "radiogroup",
205
205
  "aria-label": ariaLabel,
206
206
  "data-segmented": true,
207
- className: cn("inline-flex items-center gap-[2px] rounded-kit-md border border-kit-line bg-kit-field-bg p-[2px]", className),
207
+ className: cn("inline-flex items-center gap-[2px] rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-[2px]", className),
208
208
  children: items.map((it, i) => {
209
209
  const active = it.value === value;
210
210
  const sm = size === "sm";
@@ -225,7 +225,7 @@ function Segmented({ value, onChange, items, size = "md", className, layoutId, i
225
225
  layoutId: layoutId ?? `seg-${id}`,
226
226
  transition: pillTransition,
227
227
  "data-seg-indicator": "",
228
- className: "absolute inset-0 rounded-kit-sm bg-kit-selected"
228
+ className: "absolute inset-0 rounded-kit-sm bg-kit-selected ring-1 ring-inset ring-kit-line-strong"
229
229
  }) : null, /* @__PURE__ */ jsxs("span", {
230
230
  className: cn("relative z-[1] inline-flex items-center", !collapseInactive && "gap-1.5"),
231
231
  children: [
@@ -286,7 +286,7 @@ function ToggleGroup({ className, ...props }) {
286
286
  return /* @__PURE__ */ jsx(ToggleGroupSingle.Provider, {
287
287
  value: single,
288
288
  children: /* @__PURE__ */ jsx(ToggleGroup$1, {
289
- className: cn("inline-flex items-center gap-px rounded-kit-md border border-kit-line bg-kit-field-bg p-[2px]", className),
289
+ className: cn("inline-flex items-center gap-px rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-[2px]", className),
290
290
  ...single ? { role: "radiogroup" } : {},
291
291
  ...props
292
292
  })
@@ -301,7 +301,7 @@ function ToggleItem({ className, ...props }) {
301
301
  "aria-checked": state.pressed,
302
302
  "aria-pressed": void 0
303
303
  }) } : {},
304
- className: cn("inline-flex h-6 min-w-6 items-center justify-center gap-1 rounded-kit-sm px-1.5 text-kit-xs font-medium text-kit-fg-3 transition-colors hover:bg-kit-hover hover:text-kit-fg data-[pressed]:bg-kit-selected data-[pressed]:text-kit-fg [&_svg]:size-3.5", className),
304
+ className: cn("inline-flex h-6 min-w-6 items-center justify-center gap-1 rounded-kit-sm px-1.5 text-kit-xs font-medium text-kit-fg-3 transition-colors hover:bg-kit-hover hover:text-kit-fg data-[pressed]:bg-kit-selected data-[pressed]:ring-1 data-[pressed]:ring-inset data-[pressed]:ring-kit-line-strong data-[pressed]:text-kit-fg [&_svg]:size-3.5", className),
305
305
  ...props
306
306
  });
307
307
  }
@@ -1 +1 @@
1
- {"version":3,"file":"controls.js","names":[],"sources":["../../src/ui/controls.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\";\nimport { Checkbox as CheckboxPrimitive } from \"@base-ui/react/checkbox\";\nimport { RadioGroup as RadioGroupPrimitive } from \"@base-ui/react/radio-group\";\nimport { Radio as RadioPrimitive } from \"@base-ui/react/radio\";\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\";\nimport { Slider as SliderPrimitive } from \"@base-ui/react/slider\";\nimport { ToggleGroup as ToggleGroupPrimitive } from \"@base-ui/react/toggle-group\";\nimport { Toggle as TogglePrimitive } from \"@base-ui/react/toggle\";\nimport { Progress as ProgressPrimitive } from \"@base-ui/react/progress\";\nimport { IconCheck, IconMinus } from \"@tabler/icons-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { cn } from \"../lib/cn\";\nimport { useFieldLabelledBy, useLabelFor } from \"./field-context\";\nimport { TooltipScope } from \"./button\";\nimport { useShortcutHints } from \"./shortcut-hint\";\nimport { TooltipLayer, TooltipRoot } from \"./tooltip-root\";\n\n/* Underlines and selected pills share one spring (DESIGN.md 3.6). */\nconst PILL_SPRING = { type: \"spring\", stiffness: 520, damping: 42 } as const;\n\n/* ── Switch ─────────────────────────────────────────────────────────────── */\nexport function Switch({\n className,\n size = \"md\",\n ...props\n}: SwitchPrimitive.Root.Props & { size?: \"sm\" | \"md\" }) {\n const sm = size === \"sm\";\n const labelledBy = useFieldLabelledBy();\n const labelFor = useLabelFor(props.id);\n return (\n <SwitchPrimitive.Root\n className={cn(\n \"group relative inline-flex shrink-0 items-center rounded-full bg-kit-switch-off transition-colors duration-200 data-[checked]:bg-kit-success data-[disabled]:opacity-40\",\n sm ? \"h-4 w-7\" : \"h-5 w-9\",\n className,\n )}\n aria-labelledby={props[\"aria-labelledby\"] ?? (props[\"aria-label\"] ? undefined : (labelFor ?? (props.id ? undefined : labelledBy)))}\n {...props}\n >\n <SwitchPrimitive.Thumb\n className={cn(\n \"pointer-events-none block rounded-full bg-kit-control-thumb shadow-kit-sm transition-transform duration-200 ease-[var(--kit-ease-spring)]\",\n sm ? \"size-3 translate-x-0.5 data-[checked]:translate-x-[14px]\" : \"size-4 translate-x-0.5 data-[checked]:translate-x-[18px]\",\n )}\n />\n </SwitchPrimitive.Root>\n );\n}\n\n/* ── Checkbox ───────────────────────────────────────────────────────────── */\n/** `checked` keeps V2's tri-state value: true, false or \"indeterminate\". */\nexport function Checkbox({\n className,\n checked,\n ...props\n}: Omit<CheckboxPrimitive.Root.Props, \"checked\" | \"indeterminate\"> & { checked?: boolean | \"indeterminate\" }) {\n const indeterminate = checked === \"indeterminate\";\n const labelFor = useLabelFor(props.id);\n return (\n <CheckboxPrimitive.Root\n aria-labelledby={props[\"aria-labelledby\"] ?? (props[\"aria-label\"] ? undefined : labelFor)}\n className={cn(\n \"peer flex size-4 shrink-0 items-center justify-center rounded-kit-sm border border-kit-line-strong bg-kit-control-bg shadow-kit-xs transition-colors hover:border-[var(--kit-emphasis-line)] data-[checked]:border-kit-inverse data-[checked]:bg-kit-inverse data-[indeterminate]:border-kit-inverse data-[indeterminate]:bg-kit-inverse\",\n className,\n )}\n checked={checked === undefined ? undefined : checked === true}\n indeterminate={indeterminate}\n {...props}\n >\n <CheckboxPrimitive.Indicator className=\"text-kit-fg-inverse\">\n {indeterminate ? <IconMinus className=\"size-3\" stroke={3} /> : <IconCheck className=\"size-3\" stroke={3} />}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n\n/* ── Radio ──────────────────────────────────────────────────────────────── */\nexport const RadioGroup = RadioGroupPrimitive;\nexport function Radio({ className, ...props }: RadioPrimitive.Root.Props) {\n return (\n <RadioPrimitive.Root\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center rounded-full border border-kit-line-strong bg-kit-control-bg shadow-kit-xs transition-colors hover:border-[var(--kit-emphasis-line)] data-[checked]:border-kit-accent\",\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator className=\"block size-2 rounded-full bg-kit-accent\" />\n </RadioPrimitive.Root>\n );\n}\n\n/** Large selectable card used for choices (plans, project kinds, roles). */\nexport function ChoiceCard({\n selected,\n onSelect,\n icon,\n title,\n description,\n badge,\n className,\n children,\n}: {\n selected: boolean;\n onSelect: () => void;\n icon?: React.ReactNode;\n title: React.ReactNode;\n description?: React.ReactNode;\n badge?: React.ReactNode;\n className?: string;\n children?: React.ReactNode;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={selected}\n className={cn(\n \"focus-inset group relative flex w-full flex-col gap-1.5 rounded-kit-lg border bg-kit-control-bg px-3 py-2.5 text-left transition-[border-color,box-shadow,background-color] duration-150\", // inset: option cards often sit in a clipped, gapless list\n selected\n ? \"border-[var(--kit-emphasis-line)] shadow-kit-ring-field\"\n : \"border-kit-line hover:border-kit-line-strong hover:shadow-kit-sm\",\n className,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {icon ? (\n <span className={cn(\"mt-0.5 flex shrink-0 items-center justify-center text-kit-fg-2 [&_svg]:size-4\", selected && \"text-kit-fg\")}>\n {icon}\n </span>\n ) : null}\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2 text-kit-sm font-medium text-kit-fg\">\n {title}\n {badge}\n </div>\n {description ? <p className=\"mt-0.5 text-[13px] leading-[18px] text-kit-fg-2\">{description}</p> : null}\n </div>\n <span\n className={cn(\n \"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors\",\n selected ? \"border-kit-inverse bg-kit-inverse text-kit-fg-inverse\" : \"border-kit-line-strong\",\n )}\n >\n {selected ? <IconCheck className=\"size-2.5\" stroke={3.5} /> : null}\n </span>\n </div>\n {children}\n </button>\n );\n}\n\n/** D15: 2–4 choices → one hairline list of compact rows. Wrap <ChoiceCard>s in it; they lose their own card chrome. */\nexport function ChoiceList({ className, children, ...props }: React.HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n role=\"group\"\n className={cn(\n \"flex flex-col divide-y divide-kit-line-subtle overflow-hidden rounded-kit-lg border border-kit-line\",\n \"[&>*]:rounded-none [&>*]:border-0 [&>*]:shadow-none [&>*]:hover:shadow-none [&>*]:hover:bg-kit-hover [&>[aria-pressed=true]]:bg-kit-selected [&>[aria-pressed=true]]:shadow-none\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n}\n\n/* ── Slider ─────────────────────────────────────────────────────────────── */\nexport function Slider({\n className,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n label,\n ...props\n}: Omit<SliderPrimitive.Root.Props<number | readonly number[]>, \"className\"> & {\n className?: string;\n /** accessible name for the thumb(s) */\n label?: string;\n}) {\n const name = ariaLabel ?? label;\n const v = props.value ?? props.defaultValue ?? [0];\n const thumbs = Array.isArray(v) ? v.length : 1;\n return (\n <SliderPrimitive.Root className={cn(\"w-full\", className)} {...props}>\n <SliderPrimitive.Control className=\"relative flex h-5 w-full touch-none select-none items-center\">\n {/* Figma §4.3 slider: 4px track, --fg-2 fill, 12px light thumb with a border (control-thumb lifts off the dark track) */}\n <SliderPrimitive.Track className=\"relative h-1 w-full grow overflow-hidden rounded-full bg-[var(--kit-track-line)]\">\n <SliderPrimitive.Indicator className=\"absolute h-full bg-kit-fg-2\" />\n </SliderPrimitive.Track>\n {Array.from({ length: thumbs }, (_, i) => (\n <SliderPrimitive.Thumb\n key={i}\n index={thumbs > 1 ? i : undefined}\n getAriaLabel={name ? () => name : undefined}\n aria-labelledby={name ? undefined : ariaLabelledby}\n className=\"block size-3 rounded-full border border-kit-line-strong bg-kit-control-thumb shadow-kit-md transition-transform hover:scale-110 has-[:focus-visible]:scale-110 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-kit-focus-ring has-[:focus-visible]:[outline-style:solid]\"\n />\n ))}\n </SliderPrimitive.Control>\n </SliderPrimitive.Root>\n );\n}\n\n/* V2's overlay <Tooltip> (side bottom, 350ms) for collapsed and icon-only segments, built on the shared ink layer. */\nfunction SegmentTooltip({ content, shortcut, children }: { content: React.ReactNode; shortcut?: string; children: React.ReactElement }) {\n const hints = useShortcutHints();\n return (\n <TooltipScope.Provider value>\n <TooltipRoot>\n <TooltipPrimitive.Trigger delay={350} render={children} />\n <TooltipLayer side=\"bottom\">\n <span className=\"line-clamp-[8] min-w-0 whitespace-normal [overflow-wrap:anywhere]\">{content}</span>\n {shortcut && hints ? (\n <kbd data-hint=\"shortcuts\" className=\"mt-px shrink-0 rounded-kit-sm bg-kit-ink-active px-1 font-kit-sans text-kit-2xs\">\n {shortcut}\n </kbd>\n ) : null}\n </TooltipLayer>\n </TooltipRoot>\n </TooltipScope.Provider>\n );\n}\n\n/* ── Segmented ───────────────────────────────────────────────────────────\n Two deliberate looks (founder: no \"AI-sloppy\" grey pills with counts inside):\n • variant=\"tabs\" (opt-in) — quiet text tabs, muted tabular count, 1.5px animated underline.\n Use for filters, view sections, panel tabs.\n • variant=\"toggle\" (default) — slim hairline-bordered control, subtle selected fill, no shadow.\n Use for binary/ternary switches: list|grid, light|dark, desktop|tablet|mobile.\n Pass `count` on items instead of baking numbers into labels. */\nexport type SegmentedItem<T extends string> = {\n value: T;\n label: React.ReactNode;\n icon?: React.ReactNode;\n disabled?: boolean;\n count?: number;\n tooltip?: React.ReactNode;\n shortcut?: string;\n name?: string;\n};\n\nexport function Segmented<T extends string>({\n value,\n onChange,\n items,\n size = \"md\",\n className,\n layoutId,\n iconOnly,\n collapseInactive,\n variant,\n bordered,\n \"aria-label\": ariaLabel,\n}: {\n \"aria-label\"?: string;\n value: T;\n onChange: (v: T) => void;\n items: SegmentedItem<T>[];\n /** Toggle variant: only the selected item shows its label; the others collapse to icon + tooltip. */\n collapseInactive?: boolean;\n size?: \"sm\" | \"md\";\n className?: string;\n layoutId?: string;\n iconOnly?: boolean;\n variant?: \"tabs\" | \"toggle\";\n /** tabs only: draw a hairline under the whole tab row */\n bordered?: boolean;\n}) {\n const id = React.useId();\n const v = variant ?? \"toggle\";\n const reduceMotion = useReducedMotion();\n const pillTransition = reduceMotion ? { duration: 0 } : PILL_SPRING;\n const onKey = (e: React.KeyboardEvent, i: number) => {\n const enabled = items.filter((x) => !x.disabled);\n const idx = enabled.findIndex((x) => x.value === items[i].value);\n const fwd = e.key === \"ArrowRight\" || e.key === \"ArrowDown\";\n const back = e.key === \"ArrowLeft\" || e.key === \"ArrowUp\";\n const next = fwd\n ? enabled[(idx + 1) % enabled.length]\n : back\n ? enabled[(idx - 1 + enabled.length) % enabled.length]\n : e.key === \"Home\"\n ? enabled[0]\n : e.key === \"End\"\n ? enabled[enabled.length - 1]\n : null;\n if (next) {\n e.preventDefault();\n onChange(next.value);\n // roving tabindex: keep keyboard focus on the newly selected item\n const group = (e.currentTarget as HTMLElement).closest(\"[data-segmented]\");\n requestAnimationFrame(() => group?.querySelector<HTMLElement>(`[data-seg-value=\"${CSS.escape(next.value)}\"]`)?.focus());\n }\n };\n\n if (v === \"tabs\") {\n return (\n <div role=\"tablist\" aria-label={ariaLabel} data-segmented className={cn(\"inline-flex items-center gap-5\", bordered && \"border-b border-kit-line\", className)}>\n {items.map((it, i) => {\n const active = it.value === value;\n return (\n <button\n key={it.value}\n role=\"tab\"\n type=\"button\"\n data-seg-value={it.value}\n aria-selected={active}\n tabIndex={active ? 0 : -1}\n disabled={it.disabled}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onChange(it.value)}\n className={cn(\n \"group relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap font-medium tracking-[-0.01em] transition-colors duration-150 disabled:opacity-40 [&_svg]:size-4\",\n size === \"sm\" ? \"h-7 text-kit-xs [&_svg]:size-3.5\" : \"h-8 text-kit-sm\",\n active ? \"text-kit-fg\" : \"text-kit-fg-3 hover:text-kit-fg-2\",\n )}\n >\n {it.icon}\n {iconOnly ? null : it.label}\n {typeof it.count === \"number\" ? (\n <span className={cn(\"text-kit-xs font-normal tabular-nums\", active ? \"text-kit-fg-2\" : \"text-kit-fg-4\")}>{it.count}</span>\n ) : null}\n {active ? (\n <motion.span\n layoutId={layoutId ?? `tab-${id}`}\n transition={pillTransition}\n data-seg-indicator=\"\"\n className={cn(\"absolute inset-x-0 h-[1.5px] rounded-full bg-kit-fg\", bordered ? \"-bottom-px\" : \"bottom-0\")}\n />\n ) : null}\n </button>\n );\n })}\n </div>\n );\n }\n\n return (\n /* Toggle metrics (D29, founder): container 1px border + 2px padding, 2px between items, pill radius = container (6) − 2.\n md items are 28px tall and icon-only items exactly 28×28; sm items 24px. Collapsing items keep the icon at the same\n inset in both states (6px md / 5px sm) — only the label wrapper animates its width, with the icon→label gap inside it. */\n <div role=\"radiogroup\" aria-label={ariaLabel} data-segmented className={cn(\"inline-flex items-center gap-[2px] rounded-kit-md border border-kit-line bg-kit-field-bg p-[2px]\", className)}>\n {items.map((it, i) => {\n const active = it.value === value;\n const sm = size === \"sm\";\n const hasLabel = !iconOnly && it.label !== \"\" && it.label != null;\n const showLabel = hasLabel && (!collapseInactive || active);\n const btn = (\n <button\n key={it.value}\n role=\"radio\"\n type=\"button\"\n data-seg-value={it.value}\n aria-checked={active}\n aria-label={iconOnly && typeof it.label === \"string\" ? it.label : collapseInactive ? it.name : undefined}\n tabIndex={active ? 0 : -1}\n disabled={it.disabled}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onChange(it.value)}\n className={cn(\n \"relative inline-flex shrink-0 items-center justify-center whitespace-nowrap rounded-kit-sm font-medium transition-[color,background-color,padding] duration-150 disabled:opacity-40 [&_svg]:size-4 [&_svg]:shrink-0\",\n sm ? \"h-6 text-kit-xs [&_svg]:size-3.5\" : \"h-7 text-kit-sm\",\n iconOnly || !hasLabel\n ? sm ? \"w-6 px-0\" : \"w-7 px-0\"\n : collapseInactive\n ? sm ? (active ? \"pl-[5px] pr-2\" : \"px-[5px]\") : active ? \"pl-1.5 pr-2.5\" : \"px-1.5\"\n : sm ? \"px-2\" : \"px-2.5\",\n active ? \"text-kit-fg\" : \"text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\",\n )}\n >\n {active ? (\n <motion.span\n layoutId={layoutId ?? `seg-${id}`}\n transition={pillTransition}\n data-seg-indicator=\"\"\n className=\"absolute inset-0 rounded-kit-sm bg-kit-selected\"\n />\n ) : null}\n <span className={cn(\"relative z-[1] inline-flex items-center\", !collapseInactive && \"gap-1.5\")}>\n {it.icon}\n {!hasLabel ? null : collapseInactive ? (\n <AnimatePresence initial={false}>\n {showLabel ? (\n <motion.span\n key=\"label\"\n initial={{ width: 0, opacity: 0 }}\n animate={{ width: \"auto\", opacity: 1 }}\n exit={{ width: 0, opacity: 0 }}\n transition={reduceMotion ? { duration: 0 } : { duration: 0.18, ease: [0.2, 0, 0, 1] }}\n className=\"inline-flex overflow-hidden\"\n >\n <span className={sm ? \"pl-1\" : \"pl-1.5\"}>{it.label}</span>\n </motion.span>\n ) : null}\n </AnimatePresence>\n ) : (\n it.label\n )}\n {typeof it.count === \"number\" ? <span className=\"text-kit-xs font-normal tabular-nums text-kit-fg-3\">{it.count}</span> : null}\n </span>\n </button>\n );\n if (collapseInactive && it.tooltip)\n return (\n <SegmentTooltip key={it.value} content={it.tooltip} shortcut={it.shortcut}>\n {btn}\n </SegmentTooltip>\n );\n return iconOnly && typeof it.label === \"string\" ? (\n <SegmentTooltip key={it.value} content={it.label}>\n {btn}\n </SegmentTooltip>\n ) : (\n btn\n );\n })}\n </div>\n );\n}\n\n/* ── Toggle group (toolbar style) ───────────────────────────────────────\n One choice (the default) is a radio group in WAI-ARIA: role=\"radiogroup\" with role=\"radio\" + aria-checked items, as\n V2's Radix ToggleGroup type=\"single\" renders. `multiple` keeps group + aria-pressed (independent toggles). The arrow\n keys rove the items either way (Base UI's composite). */\nconst ToggleGroupSingle = React.createContext(false);\nexport function ToggleGroup({ className, ...props }: Omit<ToggleGroupPrimitive.Props, \"className\"> & { className?: string }) {\n const single = !props.multiple;\n return (\n <ToggleGroupSingle.Provider value={single}>\n <ToggleGroupPrimitive\n className={cn(\"inline-flex items-center gap-px rounded-kit-md border border-kit-line bg-kit-field-bg p-[2px]\", className)}\n {...(single ? { role: \"radiogroup\" } : {})}\n {...props}\n />\n </ToggleGroupSingle.Provider>\n );\n}\nexport function ToggleItem({ className, ...props }: Omit<TogglePrimitive.Props, \"className\"> & { className?: string }) {\n const single = React.useContext(ToggleGroupSingle);\n return (\n <TogglePrimitive\n {...(single\n ? { render: (p: React.ComponentProps<\"button\">, state: { pressed: boolean }) => <button {...p} role=\"radio\" aria-checked={state.pressed} aria-pressed={undefined} /> }\n : {})}\n className={cn(\n \"inline-flex h-6 min-w-6 items-center justify-center gap-1 rounded-kit-sm px-1.5 text-kit-xs font-medium text-kit-fg-3 transition-colors hover:bg-kit-hover hover:text-kit-fg data-[pressed]:bg-kit-selected data-[pressed]:text-kit-fg [&_svg]:size-3.5\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/* ── Progress ──────────────────────────────────────────────────────────── */\nconst progressTones = {\n success: \"bg-kit-success\",\n accent: \"bg-kit-accent\",\n warning: \"bg-kit-warning\",\n danger: \"bg-kit-danger\",\n // --bar-fill: ink in light, a quiet grey in dark (no near-white glare on a dark track)\n ink: \"bg-[var(--kit-bar-fill)]\",\n brand: \"bg-[var(--kit-bar-fill)]\",\n};\nexport function Progress({\n value,\n className,\n tone = \"success\",\n size = \"md\",\n label = \"Progress\",\n}: {\n value: number;\n className?: string;\n /** accessible name, e.g. \"AI credits used\" */\n label?: string;\n tone?: keyof typeof progressTones;\n size?: \"sm\" | \"md\";\n}) {\n const pct = Math.min(100, Math.max(0, value));\n return (\n <ProgressPrimitive.Root\n value={pct}\n aria-label={label}\n className={cn(\n \"relative w-full overflow-hidden rounded-full bg-[var(--kit-track)]\",\n size === \"sm\" ? \"h-1\" : \"h-1.5\",\n className,\n )}\n >\n <ProgressPrimitive.Indicator\n className={cn(\"h-full rounded-full transition-[width] duration-500 ease-[var(--kit-ease-out-soft)]\", progressTones[tone])}\n style={{ width: `${pct}%` }}\n />\n </ProgressPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,IAAM,cAAc;CAAE,MAAM;CAAU,WAAW;CAAK,SAAS;AAAG;AAGlE,SAAgB,OAAO,EACrB,WACA,OAAO,MACP,GAAG,SACmD;CACtD,MAAM,KAAK,SAAS;CACpB,MAAM,aAAa,mBAAmB;CACtC,MAAM,WAAW,YAAY,MAAM,EAAE;CACrC,OACE,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;EACE,OAAO;EACP,cAAY;EACZ,WAAW,GACT,sEACA,SAAS,OAAO,QAAQ,SACxB,SACF;EAEA,UAAA,oBAAC,WAAkB,WAAnB;GACE,WAAW,GAAG,uFAAuF,cAAc,KAAK;GACxH,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG;EAC3B,CAAA;CACqB,CAAA;AAE5B"}
1
+ {"version":3,"file":"controls.js","names":[],"sources":["../../src/ui/controls.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\";\nimport { Checkbox as CheckboxPrimitive } from \"@base-ui/react/checkbox\";\nimport { RadioGroup as RadioGroupPrimitive } from \"@base-ui/react/radio-group\";\nimport { Radio as RadioPrimitive } from \"@base-ui/react/radio\";\nimport { Tooltip as TooltipPrimitive } from \"@base-ui/react/tooltip\";\nimport { Slider as SliderPrimitive } from \"@base-ui/react/slider\";\nimport { ToggleGroup as ToggleGroupPrimitive } from \"@base-ui/react/toggle-group\";\nimport { Toggle as TogglePrimitive } from \"@base-ui/react/toggle\";\nimport { Progress as ProgressPrimitive } from \"@base-ui/react/progress\";\nimport { IconCheck, IconMinus } from \"@tabler/icons-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { cn } from \"../lib/cn\";\nimport { useFieldLabelledBy, useLabelFor } from \"./field-context\";\nimport { TooltipScope } from \"./button\";\nimport { useShortcutHints } from \"./shortcut-hint\";\nimport { TooltipLayer, TooltipRoot } from \"./tooltip-root\";\n\n/* Underlines and selected pills share one spring (DESIGN.md 3.6). */\nconst PILL_SPRING = { type: \"spring\", stiffness: 520, damping: 42 } as const;\n\n/* ── Switch ─────────────────────────────────────────────────────────────── */\nexport function Switch({\n className,\n size = \"md\",\n ...props\n}: SwitchPrimitive.Root.Props & { size?: \"sm\" | \"md\" }) {\n const sm = size === \"sm\";\n const labelledBy = useFieldLabelledBy();\n const labelFor = useLabelFor(props.id);\n return (\n <SwitchPrimitive.Root\n className={cn(\n \"group relative inline-flex shrink-0 items-center rounded-full bg-kit-switch-off transition-colors duration-200 data-[checked]:bg-kit-success data-[disabled]:opacity-40\",\n sm ? \"h-4 w-7\" : \"h-5 w-9\",\n className,\n )}\n aria-labelledby={props[\"aria-labelledby\"] ?? (props[\"aria-label\"] ? undefined : (labelFor ?? (props.id ? undefined : labelledBy)))}\n {...props}\n >\n <SwitchPrimitive.Thumb\n className={cn(\n \"pointer-events-none block rounded-full bg-kit-control-thumb shadow-kit-sm transition-transform duration-200 ease-[var(--kit-ease-spring)]\",\n sm ? \"size-3 translate-x-0.5 data-[checked]:translate-x-[14px]\" : \"size-4 translate-x-0.5 data-[checked]:translate-x-[18px]\",\n )}\n />\n </SwitchPrimitive.Root>\n );\n}\n\n/* ── Checkbox ───────────────────────────────────────────────────────────── */\n/** `checked` keeps V2's tri-state value: true, false or \"indeterminate\". */\nexport function Checkbox({\n className,\n checked,\n ...props\n}: Omit<CheckboxPrimitive.Root.Props, \"checked\" | \"indeterminate\"> & { checked?: boolean | \"indeterminate\" }) {\n const indeterminate = checked === \"indeterminate\";\n const labelFor = useLabelFor(props.id);\n return (\n <CheckboxPrimitive.Root\n aria-labelledby={props[\"aria-labelledby\"] ?? (props[\"aria-label\"] ? undefined : labelFor)}\n className={cn(\n \"peer flex size-4 shrink-0 items-center justify-center rounded-kit-sm border border-kit-line-strong bg-kit-control-bg shadow-kit-xs transition-colors hover:border-[var(--kit-emphasis-line)] data-[checked]:border-kit-inverse data-[checked]:bg-kit-inverse data-[indeterminate]:border-kit-inverse data-[indeterminate]:bg-kit-inverse\",\n className,\n )}\n checked={checked === undefined ? undefined : checked === true}\n indeterminate={indeterminate}\n {...props}\n >\n <CheckboxPrimitive.Indicator className=\"text-kit-fg-inverse\">\n {indeterminate ? <IconMinus className=\"size-3\" stroke={3} /> : <IconCheck className=\"size-3\" stroke={3} />}\n </CheckboxPrimitive.Indicator>\n </CheckboxPrimitive.Root>\n );\n}\n\n/* ── Radio ──────────────────────────────────────────────────────────────── */\nexport const RadioGroup = RadioGroupPrimitive;\nexport function Radio({ className, ...props }: RadioPrimitive.Root.Props) {\n return (\n <RadioPrimitive.Root\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center rounded-full border border-kit-line-strong bg-kit-control-bg shadow-kit-xs transition-colors hover:border-[var(--kit-emphasis-line)] data-[checked]:border-kit-accent\",\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator className=\"block size-2 rounded-full bg-kit-accent\" />\n </RadioPrimitive.Root>\n );\n}\n\n/** Large selectable card used for choices (plans, project kinds, roles). */\nexport function ChoiceCard({\n selected,\n onSelect,\n icon,\n title,\n description,\n badge,\n className,\n children,\n}: {\n selected: boolean;\n onSelect: () => void;\n icon?: React.ReactNode;\n title: React.ReactNode;\n description?: React.ReactNode;\n badge?: React.ReactNode;\n className?: string;\n children?: React.ReactNode;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={selected}\n className={cn(\n \"focus-inset group relative flex w-full flex-col gap-1.5 rounded-kit-lg border bg-kit-control-bg px-3 py-2.5 text-left transition-[border-color,box-shadow,background-color] duration-150\", // inset: option cards often sit in a clipped, gapless list\n selected\n ? \"border-[var(--kit-emphasis-line)] shadow-kit-ring-field\"\n : \"border-kit-line hover:border-kit-line-strong hover:shadow-kit-sm\",\n className,\n )}\n >\n <div className=\"flex items-start gap-3\">\n {icon ? (\n <span className={cn(\"mt-0.5 flex shrink-0 items-center justify-center text-kit-fg-2 [&_svg]:size-4\", selected && \"text-kit-fg\")}>\n {icon}\n </span>\n ) : null}\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-center gap-2 text-kit-sm font-medium text-kit-fg\">\n {title}\n {badge}\n </div>\n {description ? <p className=\"mt-0.5 text-[13px] leading-[18px] text-kit-fg-2\">{description}</p> : null}\n </div>\n <span\n className={cn(\n \"mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors\",\n selected ? \"border-kit-inverse bg-kit-inverse text-kit-fg-inverse\" : \"border-kit-line-strong\",\n )}\n >\n {selected ? <IconCheck className=\"size-2.5\" stroke={3.5} /> : null}\n </span>\n </div>\n {children}\n </button>\n );\n}\n\n/** D15: 2–4 choices → one hairline list of compact rows. Wrap <ChoiceCard>s in it; they lose their own card chrome. */\nexport function ChoiceList({ className, children, ...props }: React.HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n role=\"group\"\n className={cn(\n \"flex flex-col divide-y divide-kit-line-subtle overflow-hidden rounded-kit-lg border border-kit-line-strong\",\n \"[&>*]:rounded-none [&>*]:border-0 [&>*]:shadow-none [&>*]:hover:shadow-none [&>*]:hover:bg-kit-hover [&>[aria-pressed=true]]:bg-kit-selected [&>[aria-pressed=true]]:shadow-none\",\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n}\n\n/* ── Slider ─────────────────────────────────────────────────────────────── */\nexport function Slider({\n className,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n label,\n ...props\n}: Omit<SliderPrimitive.Root.Props<number | readonly number[]>, \"className\"> & {\n className?: string;\n /** accessible name for the thumb(s) */\n label?: string;\n}) {\n const name = ariaLabel ?? label;\n const v = props.value ?? props.defaultValue ?? [0];\n const thumbs = Array.isArray(v) ? v.length : 1;\n return (\n <SliderPrimitive.Root className={cn(\"w-full\", className)} {...props}>\n <SliderPrimitive.Control className=\"relative flex h-5 w-full touch-none select-none items-center\">\n {/* Figma §4.3 slider: 4px track, --fg-2 fill, 12px light thumb with a border (control-thumb lifts off the dark track) */}\n <SliderPrimitive.Track className=\"relative h-1 w-full grow overflow-hidden rounded-full bg-[var(--kit-track-line)]\">\n <SliderPrimitive.Indicator className=\"absolute h-full bg-kit-fg-2\" />\n </SliderPrimitive.Track>\n {Array.from({ length: thumbs }, (_, i) => (\n <SliderPrimitive.Thumb\n key={i}\n index={thumbs > 1 ? i : undefined}\n getAriaLabel={name ? () => name : undefined}\n aria-labelledby={name ? undefined : ariaLabelledby}\n className=\"block size-3 rounded-full border border-kit-line-strong bg-kit-control-thumb shadow-kit-md transition-transform hover:scale-110 has-[:focus-visible]:scale-110 has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-kit-focus-ring has-[:focus-visible]:[outline-style:solid]\"\n />\n ))}\n </SliderPrimitive.Control>\n </SliderPrimitive.Root>\n );\n}\n\n/* V2's overlay <Tooltip> (side bottom, 350ms) for collapsed and icon-only segments, built on the shared ink layer. */\nfunction SegmentTooltip({ content, shortcut, children }: { content: React.ReactNode; shortcut?: string; children: React.ReactElement }) {\n const hints = useShortcutHints();\n return (\n <TooltipScope.Provider value>\n <TooltipRoot>\n <TooltipPrimitive.Trigger delay={350} render={children} />\n <TooltipLayer side=\"bottom\">\n <span className=\"line-clamp-[8] min-w-0 whitespace-normal [overflow-wrap:anywhere]\">{content}</span>\n {shortcut && hints ? (\n <kbd data-hint=\"shortcuts\" className=\"mt-px shrink-0 rounded-kit-sm bg-kit-ink-active px-1 font-kit-sans text-kit-2xs\">\n {shortcut}\n </kbd>\n ) : null}\n </TooltipLayer>\n </TooltipRoot>\n </TooltipScope.Provider>\n );\n}\n\n/* ── Segmented ───────────────────────────────────────────────────────────\n Two deliberate looks (founder: no \"AI-sloppy\" grey pills with counts inside):\n • variant=\"tabs\" (opt-in) — quiet text tabs, muted tabular count, 1.5px animated underline.\n Use for filters, view sections, panel tabs.\n • variant=\"toggle\" (default) — slim hairline-bordered control, subtle selected fill, no shadow.\n Use for binary/ternary switches: list|grid, light|dark, desktop|tablet|mobile.\n Pass `count` on items instead of baking numbers into labels. */\nexport type SegmentedItem<T extends string> = {\n value: T;\n label: React.ReactNode;\n icon?: React.ReactNode;\n disabled?: boolean;\n count?: number;\n tooltip?: React.ReactNode;\n shortcut?: string;\n name?: string;\n};\n\nexport function Segmented<T extends string>({\n value,\n onChange,\n items,\n size = \"md\",\n className,\n layoutId,\n iconOnly,\n collapseInactive,\n variant,\n bordered,\n \"aria-label\": ariaLabel,\n}: {\n \"aria-label\"?: string;\n value: T;\n onChange: (v: T) => void;\n items: SegmentedItem<T>[];\n /** Toggle variant: only the selected item shows its label; the others collapse to icon + tooltip. */\n collapseInactive?: boolean;\n size?: \"sm\" | \"md\";\n className?: string;\n layoutId?: string;\n iconOnly?: boolean;\n variant?: \"tabs\" | \"toggle\";\n /** tabs only: draw a hairline under the whole tab row */\n bordered?: boolean;\n}) {\n const id = React.useId();\n const v = variant ?? \"toggle\";\n const reduceMotion = useReducedMotion();\n const pillTransition = reduceMotion ? { duration: 0 } : PILL_SPRING;\n const onKey = (e: React.KeyboardEvent, i: number) => {\n const enabled = items.filter((x) => !x.disabled);\n const idx = enabled.findIndex((x) => x.value === items[i].value);\n const fwd = e.key === \"ArrowRight\" || e.key === \"ArrowDown\";\n const back = e.key === \"ArrowLeft\" || e.key === \"ArrowUp\";\n const next = fwd\n ? enabled[(idx + 1) % enabled.length]\n : back\n ? enabled[(idx - 1 + enabled.length) % enabled.length]\n : e.key === \"Home\"\n ? enabled[0]\n : e.key === \"End\"\n ? enabled[enabled.length - 1]\n : null;\n if (next) {\n e.preventDefault();\n onChange(next.value);\n // roving tabindex: keep keyboard focus on the newly selected item\n const group = (e.currentTarget as HTMLElement).closest(\"[data-segmented]\");\n requestAnimationFrame(() => group?.querySelector<HTMLElement>(`[data-seg-value=\"${CSS.escape(next.value)}\"]`)?.focus());\n }\n };\n\n if (v === \"tabs\") {\n return (\n <div role=\"tablist\" aria-label={ariaLabel} data-segmented className={cn(\"inline-flex items-center gap-5\", bordered && \"border-b border-kit-line\", className)}>\n {items.map((it, i) => {\n const active = it.value === value;\n return (\n <button\n key={it.value}\n role=\"tab\"\n type=\"button\"\n data-seg-value={it.value}\n aria-selected={active}\n tabIndex={active ? 0 : -1}\n disabled={it.disabled}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onChange(it.value)}\n className={cn(\n \"group relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap font-medium tracking-[-0.01em] transition-colors duration-150 disabled:opacity-40 [&_svg]:size-4\",\n size === \"sm\" ? \"h-7 text-kit-xs [&_svg]:size-3.5\" : \"h-8 text-kit-sm\",\n active ? \"text-kit-fg\" : \"text-kit-fg-3 hover:text-kit-fg-2\",\n )}\n >\n {it.icon}\n {iconOnly ? null : it.label}\n {typeof it.count === \"number\" ? (\n <span className={cn(\"text-kit-xs font-normal tabular-nums\", active ? \"text-kit-fg-2\" : \"text-kit-fg-4\")}>{it.count}</span>\n ) : null}\n {active ? (\n <motion.span\n layoutId={layoutId ?? `tab-${id}`}\n transition={pillTransition}\n data-seg-indicator=\"\"\n className={cn(\"absolute inset-x-0 h-[1.5px] rounded-full bg-kit-fg\", bordered ? \"-bottom-px\" : \"bottom-0\")}\n />\n ) : null}\n </button>\n );\n })}\n </div>\n );\n }\n\n return (\n /* Toggle metrics (D29, founder): container 1px border + 2px padding, 2px between items, pill radius = container (6) − 2.\n md items are 28px tall and icon-only items exactly 28×28; sm items 24px. Collapsing items keep the icon at the same\n inset in both states (6px md / 5px sm) — only the label wrapper animates its width, with the icon→label gap inside it. */\n <div role=\"radiogroup\" aria-label={ariaLabel} data-segmented className={cn(\"inline-flex items-center gap-[2px] rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-[2px]\", className)}>\n {items.map((it, i) => {\n const active = it.value === value;\n const sm = size === \"sm\";\n const hasLabel = !iconOnly && it.label !== \"\" && it.label != null;\n const showLabel = hasLabel && (!collapseInactive || active);\n const btn = (\n <button\n key={it.value}\n role=\"radio\"\n type=\"button\"\n data-seg-value={it.value}\n aria-checked={active}\n aria-label={iconOnly && typeof it.label === \"string\" ? it.label : collapseInactive ? it.name : undefined}\n tabIndex={active ? 0 : -1}\n disabled={it.disabled}\n onKeyDown={(e) => onKey(e, i)}\n onClick={() => onChange(it.value)}\n className={cn(\n \"relative inline-flex shrink-0 items-center justify-center whitespace-nowrap rounded-kit-sm font-medium transition-[color,background-color,padding] duration-150 disabled:opacity-40 [&_svg]:size-4 [&_svg]:shrink-0\",\n sm ? \"h-6 text-kit-xs [&_svg]:size-3.5\" : \"h-7 text-kit-sm\",\n iconOnly || !hasLabel\n ? sm ? \"w-6 px-0\" : \"w-7 px-0\"\n : collapseInactive\n ? sm ? (active ? \"pl-[5px] pr-2\" : \"px-[5px]\") : active ? \"pl-1.5 pr-2.5\" : \"px-1.5\"\n : sm ? \"px-2\" : \"px-2.5\",\n active ? \"text-kit-fg\" : \"text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg\",\n )}\n >\n {active ? (\n <motion.span\n layoutId={layoutId ?? `seg-${id}`}\n transition={pillTransition}\n data-seg-indicator=\"\"\n className=\"absolute inset-0 rounded-kit-sm bg-kit-selected ring-1 ring-inset ring-kit-line-strong\"\n />\n ) : null}\n <span className={cn(\"relative z-[1] inline-flex items-center\", !collapseInactive && \"gap-1.5\")}>\n {it.icon}\n {!hasLabel ? null : collapseInactive ? (\n <AnimatePresence initial={false}>\n {showLabel ? (\n <motion.span\n key=\"label\"\n initial={{ width: 0, opacity: 0 }}\n animate={{ width: \"auto\", opacity: 1 }}\n exit={{ width: 0, opacity: 0 }}\n transition={reduceMotion ? { duration: 0 } : { duration: 0.18, ease: [0.2, 0, 0, 1] }}\n className=\"inline-flex overflow-hidden\"\n >\n <span className={sm ? \"pl-1\" : \"pl-1.5\"}>{it.label}</span>\n </motion.span>\n ) : null}\n </AnimatePresence>\n ) : (\n it.label\n )}\n {typeof it.count === \"number\" ? <span className=\"text-kit-xs font-normal tabular-nums text-kit-fg-3\">{it.count}</span> : null}\n </span>\n </button>\n );\n if (collapseInactive && it.tooltip)\n return (\n <SegmentTooltip key={it.value} content={it.tooltip} shortcut={it.shortcut}>\n {btn}\n </SegmentTooltip>\n );\n return iconOnly && typeof it.label === \"string\" ? (\n <SegmentTooltip key={it.value} content={it.label}>\n {btn}\n </SegmentTooltip>\n ) : (\n btn\n );\n })}\n </div>\n );\n}\n\n/* ── Toggle group (toolbar style) ───────────────────────────────────────\n One choice (the default) is a radio group in WAI-ARIA: role=\"radiogroup\" with role=\"radio\" + aria-checked items, as\n V2's Radix ToggleGroup type=\"single\" renders. `multiple` keeps group + aria-pressed (independent toggles). The arrow\n keys rove the items either way (Base UI's composite). */\nconst ToggleGroupSingle = React.createContext(false);\nexport function ToggleGroup({ className, ...props }: Omit<ToggleGroupPrimitive.Props, \"className\"> & { className?: string }) {\n const single = !props.multiple;\n return (\n <ToggleGroupSingle.Provider value={single}>\n <ToggleGroupPrimitive\n className={cn(\"inline-flex items-center gap-px rounded-kit-md border border-kit-line-strong bg-kit-field-bg p-[2px]\", className)}\n {...(single ? { role: \"radiogroup\" } : {})}\n {...props}\n />\n </ToggleGroupSingle.Provider>\n );\n}\nexport function ToggleItem({ className, ...props }: Omit<TogglePrimitive.Props, \"className\"> & { className?: string }) {\n const single = React.useContext(ToggleGroupSingle);\n return (\n <TogglePrimitive\n {...(single\n ? { render: (p: React.ComponentProps<\"button\">, state: { pressed: boolean }) => <button {...p} role=\"radio\" aria-checked={state.pressed} aria-pressed={undefined} /> }\n : {})}\n className={cn(\n \"inline-flex h-6 min-w-6 items-center justify-center gap-1 rounded-kit-sm px-1.5 text-kit-xs font-medium text-kit-fg-3 transition-colors hover:bg-kit-hover hover:text-kit-fg data-[pressed]:bg-kit-selected data-[pressed]:ring-1 data-[pressed]:ring-inset data-[pressed]:ring-kit-line-strong data-[pressed]:text-kit-fg [&_svg]:size-3.5\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/* ── Progress ──────────────────────────────────────────────────────────── */\nconst progressTones = {\n success: \"bg-kit-success\",\n accent: \"bg-kit-accent\",\n warning: \"bg-kit-warning\",\n danger: \"bg-kit-danger\",\n // --bar-fill: ink in light, a quiet grey in dark (no near-white glare on a dark track)\n ink: \"bg-[var(--kit-bar-fill)]\",\n brand: \"bg-[var(--kit-bar-fill)]\",\n};\nexport function Progress({\n value,\n className,\n tone = \"success\",\n size = \"md\",\n label = \"Progress\",\n}: {\n value: number;\n className?: string;\n /** accessible name, e.g. \"AI credits used\" */\n label?: string;\n tone?: keyof typeof progressTones;\n size?: \"sm\" | \"md\";\n}) {\n const pct = Math.min(100, Math.max(0, value));\n return (\n <ProgressPrimitive.Root\n value={pct}\n aria-label={label}\n className={cn(\n \"relative w-full overflow-hidden rounded-full bg-[var(--kit-track)]\",\n size === \"sm\" ? \"h-1\" : \"h-1.5\",\n className,\n )}\n >\n <ProgressPrimitive.Indicator\n className={cn(\"h-full rounded-full transition-[width] duration-500 ease-[var(--kit-ease-out-soft)]\", progressTones[tone])}\n style={{ width: `${pct}%` }}\n />\n </ProgressPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,IAAM,cAAc;CAAE,MAAM;CAAU,WAAW;CAAK,SAAS;AAAG;AAGlE,SAAgB,OAAO,EACrB,WACA,OAAO,MACP,GAAG,SACmD;CACtD,MAAM,KAAK,SAAS;CACpB,MAAM,aAAa,mBAAmB;CACtC,MAAM,WAAW,YAAY,MAAM,EAAE;CACrC,OACE,oBAAC,SAAgB,MAAjB;EACE,WAAW,GACT,2KACA,KAAK,YAAY,WACjB,SACF;EACA,mBAAiB,MAAM,uBAAuB,MAAM,gBAAgB,KAAA,IAAa,aAAa,MAAM,KAAK,KAAA,IAAY;EACrH,GAAI;EAEJ,UAAA,oBAAC,SAAgB,OAAjB,EACE,WAAW,GACT,6IACA,KAAK,6DAA6D,0DACpE,EACD,CAAA;CACmB,CAAA;AAE1B;;AAIA,SAAgB,SAAS,EACvB,WACA,SACA,GAAG,SACyG;CAC5G,MAAM,gBAAgB,YAAY;CAClC,MAAM,WAAW,YAAY,MAAM,EAAE;CACrC,OACE,oBAAC,WAAkB,MAAnB;EACE,mBAAiB,MAAM,uBAAuB,MAAM,gBAAgB,KAAA,IAAY;EAChF,WAAW,GACT,4UACA,SACF;EACA,SAAS,YAAY,KAAA,IAAY,KAAA,IAAY,YAAY;EAC1C;EACf,GAAI;EAEJ,UAAA,oBAAC,WAAkB,WAAnB;GAA6B,WAAU;GACpC,UAAA,gBAAgB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AAI;EACL,CAAA;CACyB,CAAA;AAEhC;AACA,SAAgB,WAAW,EAAE,WAAW,GAAG,SAA4E;CACrH,MAAM,SAAS,MAAM,WAAW,iBAAiB;CACjD,OACE,oBAAC,QAAD;EACE,GAAK,SACD,EAAE,SAAS,GAAmC,UAAgC,oBAAC,UAAD;GAAQ,GAAI;GAAG,MAAK;GAAQ,gBAAc,MAAM;GAAS,gBAAc,KAAA;EAAY,CAAA,EAAE,IACnK,CAAC;EACL,WAAW,GACT,+UACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAGA,IAAM,gBAAgB;CACpB,SAAS;CACT,QAAQ;CACR,SAAS;CACT,QAAQ;CAER,KAAK;CACL,OAAO;AACT;AACA,SAAgB,SAAS,EACvB,OACA,WACA,OAAO,WACP,OAAO,MACP,QAAQ,cAQP;CACD,MAAM,MAAM,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,CAAC;CAC5C,OACE,oBAAC,WAAkB,MAAnB;EACE,OAAO;EACP,cAAY;EACZ,WAAW,GACT,sEACA,SAAS,OAAO,QAAQ,SACxB,SACF;EAEA,UAAA,oBAAC,WAAkB,WAAnB;GACE,WAAW,GAAG,uFAAuF,cAAc,KAAK;GACxH,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG;EAC3B,CAAA;CACqB,CAAA;AAE5B"}
package/dist/ui/toast.js CHANGED
@@ -67,7 +67,7 @@ var TYPE_ICON = {
67
67
  loading: /* @__PURE__ */ jsx(Spinner, { size: "md" })
68
68
  };
69
69
  var VIEWPORT = "fixed bottom-[var(--toast-offset-bottom,16px)] right-4 z-[var(--kit-z-toast)] w-[356px] outline-none max-[600px]:left-4 max-[600px]:w-auto";
70
- var ROOT = cn("[--gap:8px] [--scale:calc(1-var(--toast-index)*0.05)] [--height:var(--toast-frontmost-height,var(--toast-height))]", "[--offset-y:calc(var(--toast-offset-y)*-1+var(--toast-index)*var(--gap)*-1+var(--toast-swipe-movement-y))]", "absolute bottom-0 right-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom select-none", "h-[var(--height)] [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-var(--toast-index)*var(--gap)))_scale(var(--scale))]", "data-[expanded]:h-[var(--toast-height)] data-[expanded]:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]", "data-[starting-style]:opacity-0 data-[starting-style]:[transform:translateY(100%)]", "data-[ending-style]:opacity-0 data-[limited]:opacity-0", "[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(100%)]", "data-[ending-style]:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+100%))]", "data-[ending-style]:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+100%))_translateY(var(--offset-y))]", "[transition:transform_400ms_ease,opacity_400ms,height_400ms,box-shadow_200ms]", "after:absolute after:left-0 after:top-full after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']", "flex items-center rounded-kit-xl border border-kit-tray-line bg-kit-surface-raised bg-clip-padding p-4 font-sans text-kit-sm text-kit-fg shadow-[0_4px_12px_rgba(0,0,0,0.1)] [.dark_&]:border-kit-line-strong");
70
+ var ROOT = cn("[--gap:8px] [--scale:calc(1-var(--toast-index)*0.05)] [--height:var(--toast-frontmost-height,var(--toast-height))]", "[--offset-y:calc(var(--toast-offset-y)*-1+var(--toast-index)*var(--gap)*-1+var(--toast-swipe-movement-y))]", "absolute bottom-0 right-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom select-none", "h-[var(--height)] [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-var(--toast-index)*var(--gap)))_scale(var(--scale))]", "data-[expanded]:h-[var(--toast-height)] data-[expanded]:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]", "data-[starting-style]:opacity-0 data-[starting-style]:[transform:translateY(100%)]", "data-[ending-style]:opacity-0 data-[limited]:opacity-0", "[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(100%)]", "data-[ending-style]:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+100%))]", "data-[ending-style]:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+100%))_translateY(var(--offset-y))]", "[transition:transform_400ms_ease,opacity_400ms,height_400ms,box-shadow_200ms]", "after:absolute after:left-0 after:top-full after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']", "flex items-center rounded-kit-xl border border-kit-tray-line bg-kit-surface-raised bg-clip-padding p-4 font-sans text-kit-sm text-kit-fg shadow-[0_4px_12px_rgba(0,0,0,0.1)] [.dark_&]:border-kit-floating-line");
71
71
  var CONTENT = "flex min-w-0 flex-1 items-center gap-1.5 transition-opacity duration-[400ms] data-[behind]:opacity-0 data-[expanded]:opacity-100";
72
72
  var ACTION = "ml-auto inline-flex h-6 shrink-0 cursor-pointer items-center rounded-kit-md bg-kit-inverse px-2 text-kit-xs font-medium text-kit-fg-inverse hover:bg-kit-inverse-hover [transition:opacity_400ms,box-shadow_200ms,background-color_150ms]";
73
73
  function KitToastItem({ toast }) {
@@ -1 +1 @@
1
- {"version":3,"file":"toast.js","names":[],"sources":["../../src/ui/toast.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Toast } from \"@base-ui/react/toast\";\nimport type { KitToast, KitToastOptions } from \"../context\";\nimport { cn } from \"../lib/cn\";\nimport { Spinner } from \"./spinner\";\nimport { KIT_SCOPE } from \"./surfaces\";\n\n/* ── Toast ───────────────────────────────────────────────────────────────\n V2's toaster (app/root.tsx:24-46: sonner bottom-right, 16px offsets, gap 8, the --toast-offset-bottom lift an\n ActionTray with clearToasts writes) rebuilt on Base UI Toast. kit-ports-spec.md §4.\n Kit code never mounts this on its own: it calls KitServices.toast. A host without a toaster of its own mounts\n <KitToaster /> once and passes `toast: kitToast`; a host with one (the dashboard's sonner) keeps it, so nothing\n renders twice.\n The success / error / warning / info glyphs are sonner's own SVG paths (sonner 2.0.8 dist/index.mjs:43-90), copied\n verbatim. sonner is MIT licensed, Copyright (c) 2023 Emil Kowalski (https://github.com/emilkowalski/sonner). */\n\nexport const kitToastManager = Toast.createToastManager();\n\ntype ToastType = \"default\" | \"success\" | \"error\" | \"warning\" | \"info\" | \"loading\";\nlet seq = 0;\n\nfunction add(type: ToastType, message: string, opts: KitToastOptions = {}): string {\n const id = `kit-toast-${++seq}`;\n const { action } = opts;\n return kitToastManager.add({\n id,\n type,\n title: message,\n description: opts.description,\n timeout: opts.duration,\n priority: type === \"error\" ? \"high\" : \"low\",\n data: { icon: opts.icon },\n // sonner closes the toast when its action runs; so does this\n actionProps: action ? { children: action.label, onClick: () => (action.onClick(), kitToastManager.close(id)) } : undefined,\n });\n}\n\n/** KitServices.toast backed by kitToastManager, plus V2's other sonner calls. */\nexport const kitToast: KitToast & {\n error: (message: string, opts?: KitToastOptions) => void;\n warning: (message: string, opts?: KitToastOptions) => void;\n info: (message: string, opts?: KitToastOptions) => void;\n /** stays until dismissed or updated; returns its id */\n loading: (message: string, opts?: KitToastOptions) => string;\n dismiss: (id?: string) => void;\n} = Object.assign((message: string, opts?: KitToastOptions) => void add(\"default\", message, opts), {\n success: (message: string, opts?: KitToastOptions) => void add(\"success\", message, opts),\n error: (message: string, opts?: KitToastOptions) => void add(\"error\", message, opts),\n warning: (message: string, opts?: KitToastOptions) => void add(\"warning\", message, opts),\n info: (message: string, opts?: KitToastOptions) => void add(\"info\", message, opts),\n loading: (message: string, opts?: KitToastOptions) => add(\"loading\", message, opts),\n dismiss: (id?: string) => kitToastManager.close(id),\n});\n\n/* sonner's type glyphs, drawn in the toast's text colour (V2 runs without richColors), at the 16px icon slot */\nfunction SonnerGlyph({ viewBox, d }: { viewBox: string; d: string }) {\n return (\n <svg viewBox={viewBox} fill=\"currentColor\" width=\"16\" height=\"16\" data-toast-glyph=\"\">\n <path fillRule=\"evenodd\" d={d} clipRule=\"evenodd\" />\n </svg>\n );\n}\nconst TYPE_ICON: Partial<Record<string, React.ReactNode>> = {\n success: (\n <SonnerGlyph\n viewBox=\"0 0 20 20\"\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\"\n />\n ),\n warning: (\n <SonnerGlyph\n viewBox=\"0 0 24 24\"\n d=\"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z\"\n />\n ),\n info: (\n <SonnerGlyph\n viewBox=\"0 0 20 20\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z\"\n />\n ),\n error: (\n <SonnerGlyph\n viewBox=\"0 0 20 20\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\"\n />\n ),\n loading: <Spinner size=\"md\" />,\n};\n\n/* Viewport: bottom-right, 16px from the edges; the bottom offset follows an ActionTray's --toast-offset-bottom lift.\n Under 600px it spans the width less 16px a side (sonner's mobile layout). */\nconst VIEWPORT =\n \"fixed bottom-[var(--toast-offset-bottom,16px)] right-4 z-[var(--kit-z-toast)] w-[356px] outline-none max-[600px]:left-4 max-[600px]:w-auto\";\n\n/* sonner's motion in Base UI's stacked-toast variables: 400ms transform/opacity/height; enter and exit 100% down;\n collapsed, each toast behind the front lifts gap × index, shrinks 5% per index and takes the front toast's height;\n hovered or focused, the stack opens to full heights 8px apart. Reduced motion collapses it (kit base rule). */\nconst ROOT = cn(\n \"[--gap:8px] [--scale:calc(1-var(--toast-index)*0.05)] [--height:var(--toast-frontmost-height,var(--toast-height))]\",\n \"[--offset-y:calc(var(--toast-offset-y)*-1+var(--toast-index)*var(--gap)*-1+var(--toast-swipe-movement-y))]\",\n \"absolute bottom-0 right-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom select-none\",\n \"h-[var(--height)] [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-var(--toast-index)*var(--gap)))_scale(var(--scale))]\",\n \"data-[expanded]:h-[var(--toast-height)] data-[expanded]:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]\",\n \"data-[starting-style]:opacity-0 data-[starting-style]:[transform:translateY(100%)]\",\n \"data-[ending-style]:opacity-0 data-[limited]:opacity-0\",\n \"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(100%)]\",\n \"data-[ending-style]:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+100%))]\",\n \"data-[ending-style]:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+100%))_translateY(var(--offset-y))]\",\n \"[transition:transform_400ms_ease,opacity_400ms,height_400ms,box-shadow_200ms]\",\n // the hover bridge between stacked toasts, so the stack stays open while the pointer crosses a gap\n \"after:absolute after:left-0 after:top-full after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']\",\n // V2's effective look: --surface-raised, tray-line edge (line-strong in dark), 12px radius, sonner's own shadow\n \"flex items-center rounded-kit-xl border border-kit-tray-line bg-kit-surface-raised bg-clip-padding p-4 font-sans text-kit-sm text-kit-fg shadow-[0_4px_12px_rgba(0,0,0,0.1)] [.dark_&]:border-kit-line-strong\",\n);\n/* the toasts behind the front hide their content while the stack is collapsed (sonner data-front=false > * opacity 0) */\nconst CONTENT = \"flex min-w-0 flex-1 items-center gap-1.5 transition-opacity duration-[400ms] data-[behind]:opacity-0 data-[expanded]:opacity-100\";\nconst ACTION =\n \"ml-auto inline-flex h-6 shrink-0 cursor-pointer items-center rounded-kit-md bg-kit-inverse px-2 text-kit-xs font-medium text-kit-fg-inverse hover:bg-kit-inverse-hover [transition:opacity_400ms,box-shadow_200ms,background-color_150ms]\";\n\nfunction KitToastItem({ toast }: { toast: Toast.Root.ToastObject }) {\n const icon = (toast.data as { icon?: React.ReactNode } | undefined)?.icon ?? TYPE_ICON[toast.type ?? \"\"];\n return (\n <Toast.Root toast={toast} className={ROOT}>\n <Toast.Content className={CONTENT}>\n {icon ? (\n <span aria-hidden className=\"flex size-4 shrink-0 items-center [&_svg]:size-4\">\n {icon}\n </span>\n ) : null}\n <div className=\"min-w-0 flex-1\">\n <Toast.Title className=\"font-medium leading-[1.5]\" />\n {toast.description ? <Toast.Description className=\"leading-[1.4] text-kit-fg-2\" /> : null}\n </div>\n {toast.actionProps ? <Toast.Action className={ACTION} /> : null}\n </Toast.Content>\n </Toast.Root>\n );\n}\n\nfunction KitToastList() {\n const { toasts } = Toast.useToastManager();\n return toasts.map((t) => <KitToastItem key={t.id} toast={t} />);\n}\n\nexport interface KitToasterProps {\n /** toasts kept on screen (sonner visibleToasts) */\n limit?: number;\n /** ms before a toast closes; a toast's own `duration` wins; loading toasts stay */\n timeout?: number;\n className?: string;\n}\n\n/** Mount once per document, at the root. Its layer carries KIT_SCOPE (a portal sits outside every kit island). */\nexport function KitToaster({ limit = 3, timeout = 4000, className }: KitToasterProps) {\n return (\n <Toast.Provider toastManager={kitToastManager} limit={limit} timeout={timeout}>\n <Toast.Portal>\n <Toast.Viewport {...KIT_SCOPE} className={cn(VIEWPORT, className)}>\n <KitToastList />\n </Toast.Viewport>\n </Toast.Portal>\n </Toast.Provider>\n );\n}\n"],"mappings":";;;;;;;AAgBA,IAAa,kBAAkB,MAAM,mBA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A;AAEpB"}
1
+ {"version":3,"file":"toast.js","names":[],"sources":["../../src/ui/toast.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Toast } from \"@base-ui/react/toast\";\nimport type { KitToast, KitToastOptions } from \"../context\";\nimport { cn } from \"../lib/cn\";\nimport { Spinner } from \"./spinner\";\nimport { KIT_SCOPE } from \"./surfaces\";\n\n/* ── Toast ───────────────────────────────────────────────────────────────\n V2's toaster (app/root.tsx:24-46: sonner bottom-right, 16px offsets, gap 8, the --toast-offset-bottom lift an\n ActionTray with clearToasts writes) rebuilt on Base UI Toast. kit-ports-spec.md §4.\n Kit code never mounts this on its own: it calls KitServices.toast. A host without a toaster of its own mounts\n <KitToaster /> once and passes `toast: kitToast`; a host with one (the dashboard's sonner) keeps it, so nothing\n renders twice.\n The success / error / warning / info glyphs are sonner's own SVG paths (sonner 2.0.8 dist/index.mjs:43-90), copied\n verbatim. sonner is MIT licensed, Copyright (c) 2023 Emil Kowalski (https://github.com/emilkowalski/sonner). */\n\nexport const kitToastManager = Toast.createToastManager();\n\ntype ToastType = \"default\" | \"success\" | \"error\" | \"warning\" | \"info\" | \"loading\";\nlet seq = 0;\n\nfunction add(type: ToastType, message: string, opts: KitToastOptions = {}): string {\n const id = `kit-toast-${++seq}`;\n const { action } = opts;\n return kitToastManager.add({\n id,\n type,\n title: message,\n description: opts.description,\n timeout: opts.duration,\n priority: type === \"error\" ? \"high\" : \"low\",\n data: { icon: opts.icon },\n // sonner closes the toast when its action runs; so does this\n actionProps: action ? { children: action.label, onClick: () => (action.onClick(), kitToastManager.close(id)) } : undefined,\n });\n}\n\n/** KitServices.toast backed by kitToastManager, plus V2's other sonner calls. */\nexport const kitToast: KitToast & {\n error: (message: string, opts?: KitToastOptions) => void;\n warning: (message: string, opts?: KitToastOptions) => void;\n info: (message: string, opts?: KitToastOptions) => void;\n /** stays until dismissed or updated; returns its id */\n loading: (message: string, opts?: KitToastOptions) => string;\n dismiss: (id?: string) => void;\n} = Object.assign((message: string, opts?: KitToastOptions) => void add(\"default\", message, opts), {\n success: (message: string, opts?: KitToastOptions) => void add(\"success\", message, opts),\n error: (message: string, opts?: KitToastOptions) => void add(\"error\", message, opts),\n warning: (message: string, opts?: KitToastOptions) => void add(\"warning\", message, opts),\n info: (message: string, opts?: KitToastOptions) => void add(\"info\", message, opts),\n loading: (message: string, opts?: KitToastOptions) => add(\"loading\", message, opts),\n dismiss: (id?: string) => kitToastManager.close(id),\n});\n\n/* sonner's type glyphs, drawn in the toast's text colour (V2 runs without richColors), at the 16px icon slot */\nfunction SonnerGlyph({ viewBox, d }: { viewBox: string; d: string }) {\n return (\n <svg viewBox={viewBox} fill=\"currentColor\" width=\"16\" height=\"16\" data-toast-glyph=\"\">\n <path fillRule=\"evenodd\" d={d} clipRule=\"evenodd\" />\n </svg>\n );\n}\nconst TYPE_ICON: Partial<Record<string, React.ReactNode>> = {\n success: (\n <SonnerGlyph\n viewBox=\"0 0 20 20\"\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z\"\n />\n ),\n warning: (\n <SonnerGlyph\n viewBox=\"0 0 24 24\"\n d=\"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z\"\n />\n ),\n info: (\n <SonnerGlyph\n viewBox=\"0 0 20 20\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z\"\n />\n ),\n error: (\n <SonnerGlyph\n viewBox=\"0 0 20 20\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z\"\n />\n ),\n loading: <Spinner size=\"md\" />,\n};\n\n/* Viewport: bottom-right, 16px from the edges; the bottom offset follows an ActionTray's --toast-offset-bottom lift.\n Under 600px it spans the width less 16px a side (sonner's mobile layout). */\nconst VIEWPORT =\n \"fixed bottom-[var(--toast-offset-bottom,16px)] right-4 z-[var(--kit-z-toast)] w-[356px] outline-none max-[600px]:left-4 max-[600px]:w-auto\";\n\n/* sonner's motion in Base UI's stacked-toast variables: 400ms transform/opacity/height; enter and exit 100% down;\n collapsed, each toast behind the front lifts gap × index, shrinks 5% per index and takes the front toast's height;\n hovered or focused, the stack opens to full heights 8px apart. Reduced motion collapses it (kit base rule). */\nconst ROOT = cn(\n \"[--gap:8px] [--scale:calc(1-var(--toast-index)*0.05)] [--height:var(--toast-frontmost-height,var(--toast-height))]\",\n \"[--offset-y:calc(var(--toast-offset-y)*-1+var(--toast-index)*var(--gap)*-1+var(--toast-swipe-movement-y))]\",\n \"absolute bottom-0 right-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom select-none\",\n \"h-[var(--height)] [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-var(--toast-index)*var(--gap)))_scale(var(--scale))]\",\n \"data-[expanded]:h-[var(--toast-height)] data-[expanded]:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]\",\n \"data-[starting-style]:opacity-0 data-[starting-style]:[transform:translateY(100%)]\",\n \"data-[ending-style]:opacity-0 data-[limited]:opacity-0\",\n \"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(100%)]\",\n \"data-[ending-style]:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+100%))]\",\n \"data-[ending-style]:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+100%))_translateY(var(--offset-y))]\",\n \"[transition:transform_400ms_ease,opacity_400ms,height_400ms,box-shadow_200ms]\",\n // the hover bridge between stacked toasts, so the stack stays open while the pointer crosses a gap\n \"after:absolute after:left-0 after:top-full after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']\",\n // V2's effective look: --surface-raised, tray-line edge (line-strong in dark), 12px radius, sonner's own shadow\n \"flex items-center rounded-kit-xl border border-kit-tray-line bg-kit-surface-raised bg-clip-padding p-4 font-sans text-kit-sm text-kit-fg shadow-[0_4px_12px_rgba(0,0,0,0.1)] [.dark_&]:border-kit-floating-line\",\n);\n/* the toasts behind the front hide their content while the stack is collapsed (sonner data-front=false > * opacity 0) */\nconst CONTENT = \"flex min-w-0 flex-1 items-center gap-1.5 transition-opacity duration-[400ms] data-[behind]:opacity-0 data-[expanded]:opacity-100\";\nconst ACTION =\n \"ml-auto inline-flex h-6 shrink-0 cursor-pointer items-center rounded-kit-md bg-kit-inverse px-2 text-kit-xs font-medium text-kit-fg-inverse hover:bg-kit-inverse-hover [transition:opacity_400ms,box-shadow_200ms,background-color_150ms]\";\n\nfunction KitToastItem({ toast }: { toast: Toast.Root.ToastObject }) {\n const icon = (toast.data as { icon?: React.ReactNode } | undefined)?.icon ?? TYPE_ICON[toast.type ?? \"\"];\n return (\n <Toast.Root toast={toast} className={ROOT}>\n <Toast.Content className={CONTENT}>\n {icon ? (\n <span aria-hidden className=\"flex size-4 shrink-0 items-center [&_svg]:size-4\">\n {icon}\n </span>\n ) : null}\n <div className=\"min-w-0 flex-1\">\n <Toast.Title className=\"font-medium leading-[1.5]\" />\n {toast.description ? <Toast.Description className=\"leading-[1.4] text-kit-fg-2\" /> : null}\n </div>\n {toast.actionProps ? <Toast.Action className={ACTION} /> : null}\n </Toast.Content>\n </Toast.Root>\n );\n}\n\nfunction KitToastList() {\n const { toasts } = Toast.useToastManager();\n return toasts.map((t) => <KitToastItem key={t.id} toast={t} />);\n}\n\nexport interface KitToasterProps {\n /** toasts kept on screen (sonner visibleToasts) */\n limit?: number;\n /** ms before a toast closes; a toast's own `duration` wins; loading toasts stay */\n timeout?: number;\n className?: string;\n}\n\n/** Mount once per document, at the root. Its layer carries KIT_SCOPE (a portal sits outside every kit island). */\nexport function KitToaster({ limit = 3, timeout = 4000, className }: KitToasterProps) {\n return (\n <Toast.Provider toastManager={kitToastManager} limit={limit} timeout={timeout}>\n <Toast.Portal>\n <Toast.Viewport {...KIT_SCOPE} className={cn(VIEWPORT, className)}>\n <KitToastList />\n </Toast.Viewport>\n </Toast.Portal>\n </Toast.Provider>\n );\n}\n"],"mappings":";;;;;;;AAgBA,IAAa,kBAAkB,MAAM,mBAAmB;AAGxD,IAAI,MAAM;AAEV,SAAS,IAAI,MAAiB,SAAiB,OAAwB,CAAC,GAAW;CACjF,MAAM,KAAK,aAAa,EAAE;CAC1B,MAAM,EAAE,WAAW;CACnB,OAAO,gBAAgB,IAAI;EACzB;EACA;EACA,OAAO;EACP,aAAa,KAAK;EAClB,SAAS,KAAK;EACd,UAAU,SAAS,UAAU,SAAS;EACtC,MAAM,EAAE,MAAM,KAAK,KAAK;EAExB,aAAa,SAAS;GAAE,UAAU,OAAO;GAAO,gBAAgB,OAAO,QAAQ,GAAG,gBAAgB,MAAM,EAAE;EAAG,IAAI,KAAA;CACnH,CAAC;AACH;;AAGA,IAAa,WAOT,OAAO,QAAQ,SAAiB,SAA2B,KAAK,IAAI,WAAW,SAAS,IAAI,GAAG;CACjG,UAAU,SAAiB,SAA2B,KAAK,IAAI,WAAW,SAAS,IAAI;CACvF,QAAQ,SAAiB,SAA2B,KAAK,IAAI,SAAS,SAAS,IAAI;CACnF,UAAU,SAAiB,SAA2B,KAAK,IAAI,WAAW,SAAS,IAAI;CACvF,OAAO,SAAiB,SAA2B,KAAK,IAAI,QAAQ,SAAS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cAAc,oBAAC,MAAM,QAAP,EAAc,WAAW,OAAS,CAAA,IAAI;GAC9C;;CACL,CAAA;AAEhB;AAEA,SAAS,eAAe;CACtB,MAAM,EAAE,WAAW,MAAM,gBAAgB;CACzC,OAAO,OAAO,KAAK,MAAM,oBAAC,cAAD,EAAyB,OAAO,EAAI,GAAjB,EAAE,EAAe,CAAC;AAChE;;AAWA,SAAgB,WAAW,EAAE,QAAQ,GAAG,UAAU,KAAM,aAA8B;CACpF,OACE,oBAAC,MAAM,UAAP;EAAgB,cAAc;EAAwB;EAAgB;EACpE,UAAA,oBAAC,MAAM,QAAP,EAAA,UACE,oBAAC,MAAM,UAAP;GAAgB,GAAI;GAAW,WAAW,GAAG,UAAU,SAAS;GAC9D,UAAA,oBAAC,cAAD,CAAe,CAAA;EACD,CAAA,EACJ,CAAA;CACA,CAAA;AAEpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bettercms-ai/kit",
3
- "version": "3.1.12",
3
+ "version": "3.1.13",
4
4
  "description": "The BetterCMS V2 Block Kit: schema language, form engine, controls and design tokens.",
5
5
  "license": "MIT",
6
6
  "type": "module",