@epilot/spark-ui 0.32.0 → 0.32.2

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.
Files changed (113) hide show
  1. package/dist/{button-B_RNHEc7.d.ts → button-4QGaO78M.d.ts} +3 -3
  2. package/dist/{button-DBcEcIMk.d.cts → button-C-KeUy2j.d.cts} +3 -3
  3. package/dist/components/alert-dialog.d.cts +1 -1
  4. package/dist/components/alert-dialog.d.ts +1 -1
  5. package/dist/components/attachment.d.cts +2 -2
  6. package/dist/components/attachment.d.ts +2 -2
  7. package/dist/components/autocomplete.cjs +2 -9
  8. package/dist/components/autocomplete.cjs.map +1 -1
  9. package/dist/components/autocomplete.js +3 -10
  10. package/dist/components/autocomplete.js.map +1 -1
  11. package/dist/components/avatar.js +1 -1
  12. package/dist/components/badge.js +1 -1
  13. package/dist/components/bar-chart.cjs +1 -1
  14. package/dist/components/bar-chart.js +2 -2
  15. package/dist/components/bubble.d.cts +1 -1
  16. package/dist/components/bubble.d.ts +1 -1
  17. package/dist/components/button-group.js +1 -1
  18. package/dist/components/button.d.cts +1 -1
  19. package/dist/components/button.d.ts +1 -1
  20. package/dist/components/button.js +1 -1
  21. package/dist/components/calendar.js +1 -1
  22. package/dist/components/callout.d.cts +1 -1
  23. package/dist/components/callout.d.ts +1 -1
  24. package/dist/components/checkbox-card.cjs +9 -4
  25. package/dist/components/checkbox-card.cjs.map +1 -1
  26. package/dist/components/checkbox-card.js +9 -4
  27. package/dist/components/checkbox-card.js.map +1 -1
  28. package/dist/components/checkbox-group.js +1 -1
  29. package/dist/components/checkbox.js +1 -1
  30. package/dist/components/combobox.cjs +3 -2
  31. package/dist/components/combobox.cjs.map +1 -1
  32. package/dist/components/combobox.js +4 -3
  33. package/dist/components/combobox.js.map +1 -1
  34. package/dist/components/dropzone.d.cts +1 -1
  35. package/dist/components/dropzone.d.ts +1 -1
  36. package/dist/components/empty-state.d.cts +1 -1
  37. package/dist/components/empty-state.d.ts +1 -1
  38. package/dist/components/field.js +1 -1
  39. package/dist/components/icon.js +1 -1
  40. package/dist/components/image-carousel.d.cts +1 -1
  41. package/dist/components/image-carousel.d.ts +1 -1
  42. package/dist/components/image-carousel.js +1 -1
  43. package/dist/components/info-block.d.cts +1 -1
  44. package/dist/components/info-block.d.ts +1 -1
  45. package/dist/components/input-group.cjs +2 -2
  46. package/dist/components/input-group.cjs.map +1 -1
  47. package/dist/components/input-group.js +3 -3
  48. package/dist/components/input-group.js.map +1 -1
  49. package/dist/components/line-chart.cjs +3 -3
  50. package/dist/components/line-chart.js +4 -4
  51. package/dist/components/marker.d.cts +1 -1
  52. package/dist/components/marker.d.ts +1 -1
  53. package/dist/components/message-scroller.d.cts +1 -1
  54. package/dist/components/message-scroller.d.ts +1 -1
  55. package/dist/components/message-scroller.js +1 -1
  56. package/dist/components/page-header.d.cts +1 -1
  57. package/dist/components/page-header.d.ts +1 -1
  58. package/dist/components/pagination.d.cts +1 -1
  59. package/dist/components/pagination.d.ts +1 -1
  60. package/dist/components/period-tabs.d.cts +1 -1
  61. package/dist/components/period-tabs.d.ts +1 -1
  62. package/dist/components/pill.cjs +9 -27
  63. package/dist/components/pill.cjs.map +1 -1
  64. package/dist/components/pill.d.cts +9 -12
  65. package/dist/components/pill.d.ts +9 -12
  66. package/dist/components/pill.js +11 -29
  67. package/dist/components/pill.js.map +1 -1
  68. package/dist/components/power-history-chart.cjs +3 -3
  69. package/dist/components/power-history-chart.js +4 -4
  70. package/dist/components/power-network.js +1 -1
  71. package/dist/components/radio-card-group.cjs +9 -4
  72. package/dist/components/radio-card-group.cjs.map +1 -1
  73. package/dist/components/radio-card-group.js +9 -4
  74. package/dist/components/radio-card-group.js.map +1 -1
  75. package/dist/components/radio.js +1 -1
  76. package/dist/components/select.cjs +4 -3
  77. package/dist/components/select.cjs.map +1 -1
  78. package/dist/components/select.js +5 -4
  79. package/dist/components/select.js.map +1 -1
  80. package/dist/components/solar-forecast-chart.js +1 -1
  81. package/dist/components/spark-home.js +1 -1
  82. package/dist/components/switch-group.js +1 -1
  83. package/dist/components/switch.js +1 -1
  84. package/dist/components/tabs.js +1 -1
  85. package/dist/components/textarea.cjs +1 -1
  86. package/dist/components/textarea.cjs.map +1 -1
  87. package/dist/components/textarea.js +1 -1
  88. package/dist/components/textarea.js.map +1 -1
  89. package/dist/components/theme.js +1 -1
  90. package/dist/components/toggle-group.js +1 -1
  91. package/dist/components/toggle.d.cts +1 -1
  92. package/dist/components/toggle.d.ts +1 -1
  93. package/dist/components/toggle.js +1 -1
  94. package/dist/lib/date-field.cjs +6 -5
  95. package/dist/lib/date-field.cjs.map +1 -1
  96. package/dist/lib/date-field.d.cts +7 -1
  97. package/dist/lib/date-field.d.ts +7 -1
  98. package/dist/lib/date-field.js +7 -6
  99. package/dist/lib/date-field.js.map +1 -1
  100. package/dist/lib/input-box-variants.cjs +3 -1
  101. package/dist/lib/input-box-variants.cjs.map +1 -1
  102. package/dist/lib/input-box-variants.d.cts +2 -1
  103. package/dist/lib/input-box-variants.d.ts +2 -1
  104. package/dist/lib/input-box-variants.js +3 -2
  105. package/dist/lib/input-box-variants.js.map +1 -1
  106. package/dist/lib/mask-hint.cjs +1 -1
  107. package/dist/lib/mask-hint.cjs.map +1 -1
  108. package/dist/lib/mask-hint.js +1 -1
  109. package/dist/lib/mask-hint.js.map +1 -1
  110. package/dist/lib/toggle-group-context.d.cts +1 -1
  111. package/dist/lib/toggle-group-context.d.ts +1 -1
  112. package/dist/styles/theme.css +7 -1
  113. package/package.json +1 -1
@@ -1,22 +1,18 @@
1
1
  "use client";
2
2
  "use client";
3
- import { cn } from "../utils/cn.js";
4
3
  import { accentByColor } from "../lib/accent-colors.js";
4
+ import { cn } from "../utils/cn.js";
5
5
  import * as React$1 from "react";
6
- import { Close } from "@epilot/spark-icons";
7
6
  import { Button } from "@base-ui/react/button";
8
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { jsx } from "react/jsx-runtime";
9
8
  //#region src/components/pill.tsx
10
9
  const PillDisabledContext = React$1.createContext(false);
11
10
  /**
12
11
  * Like Badge, but interactive: `onClick` makes the whole pill a button
13
- * (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.
14
- * Both are optional -- with neither, it's a static label.
12
+ * (Enter/Space). Without it, it's a static label.
15
13
  */
16
- const Pill = React$1.forwardRef(function Pill({ className, children, styleVariant, color, disabled = false, onClick, onRemove, removeLabel, onKeyDown, ...props }, ref) {
14
+ const Pill = React$1.forwardRef(function Pill({ className, children, styleVariant, color, disabled = false, onClick, onKeyDown, ...props }, ref) {
17
15
  const clickable = !disabled && onClick !== void 0;
18
- const removable = !disabled && onRemove !== void 0;
19
- const focusable = clickable || removable;
20
16
  const hasLook = styleVariant !== void 0 || color !== void 0;
21
17
  const handleKeyDown = (event) => {
22
18
  onKeyDown?.(event);
@@ -24,46 +20,32 @@ const Pill = React$1.forwardRef(function Pill({ className, children, styleVarian
24
20
  if (event.key === " ") event.preventDefault();
25
21
  onClick?.(event);
26
22
  }
27
- if (removable && (event.key === "Delete" || event.key === "Backspace")) onRemove?.(event);
28
23
  };
29
24
  const interaction = {
30
25
  onKeyDown: handleKeyDown,
31
26
  ...clickable && {
32
27
  role: "button",
33
- onClick
34
- },
35
- ...focusable && { tabIndex: 0 }
28
+ onClick,
29
+ tabIndex: 0
30
+ }
36
31
  };
37
32
  return /* @__PURE__ */ jsx(PillDisabledContext.Provider, {
38
33
  value: disabled,
39
- children: /* @__PURE__ */ jsxs("span", {
34
+ children: /* @__PURE__ */ jsx("span", {
40
35
  "aria-disabled": disabled || void 0,
41
- "aria-keyshortcuts": removable ? "Delete" : void 0,
42
36
  "data-slot": "pill",
43
37
  "data-style": hasLook ? styleVariant ?? "soft" : void 0,
44
38
  "data-accent-color": color ? accentByColor[color] : void 0,
45
39
  ...interaction,
46
40
  ref,
47
- className: cn("inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none", "bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))", "shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]", focusable && "transition-colors motion-reduce:transition-none", clickable && "cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))", disabled && "pointer-events-none opacity-50", className),
41
+ className: cn("inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none", "bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))", "shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]", clickable && "transition-colors motion-reduce:transition-none", clickable && "cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))", disabled && "pointer-events-none opacity-50", className),
48
42
  ...props,
49
- children: [children, removable ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
50
- className: "sr-only",
51
- children: removeLabel
52
- }), /* @__PURE__ */ jsx("span", {
53
- "aria-hidden": "true",
54
- "data-slot": "pill-remove",
55
- onClick: (event) => {
56
- event.stopPropagation();
57
- onRemove?.(event);
58
- },
59
- className: "-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) motion-reduce:transition-none",
60
- children: /* @__PURE__ */ jsx(Close, { className: "[--spark-icon-size:14px]" })
61
- })] }) : null]
43
+ children
62
44
  })
63
45
  });
64
46
  });
65
47
  Pill.displayName = "Pill";
66
- /** A button inside a static `Pill` (no `onClick`, no `onRemove`); it is disabled with the pill. */
48
+ /** A button inside a static `Pill` (no `onClick`); it is disabled with the pill. */
67
49
  const PillButton = React$1.forwardRef(function PillButton({ className, disabled, ...props }, ref) {
68
50
  const pillDisabled = React$1.useContext(PillDisabledContext);
69
51
  return /* @__PURE__ */ jsx(Button, {
@@ -1 +1 @@
1
- {"version":3,"file":"pill.js","names":["React","ButtonPrimitive"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { Close } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillOnRemoveProps =\n | { onRemove?: undefined; removeLabel?: string }\n | {\n /** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */\n onRemove: (event: React.SyntheticEvent) => void\n /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */\n removeLabel: string\n }\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> &\n PillOnRemoveProps & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n }\n\nconst PillDisabledContext = React.createContext(false)\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.\n * Both are optional -- with neither, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onRemove,\n removeLabel,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const removable = !disabled && onRemove !== undefined\n const focusable = clickable || removable\n const hasLook = styleVariant !== undefined || color !== undefined\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (clickable && (event.key === 'Enter' || event.key === ' ')) {\n if (event.key === ' ') event.preventDefault()\n onClick?.(event)\n }\n if (removable && (event.key === 'Delete' || event.key === 'Backspace')) {\n onRemove?.(event)\n }\n }\n\n // button role and click handler travel together, so a clickable pill always\n // answers Enter/Space; a removable-only pill stays generic and answers Delete\n const interaction = {\n onKeyDown: handleKeyDown,\n ...(clickable && { role: 'button' as const, onClick }),\n ...(focusable && { tabIndex: 0 }),\n }\n\n return (\n <PillDisabledContext.Provider value={disabled}>\n <span\n aria-disabled={disabled || undefined}\n aria-keyshortcuts={removable ? 'Delete' : undefined}\n data-slot=\"pill\"\n data-style={hasLook ? (styleVariant ?? 'soft') : undefined}\n data-accent-color={color ? accentByColor[color] : undefined}\n {...interaction}\n ref={ref}\n className={cn(\n 'inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none',\n 'bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))',\n 'shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]',\n focusable && 'transition-colors motion-reduce:transition-none',\n clickable &&\n 'cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...props}\n >\n {children}\n {removable ? (\n <>\n {/* aria-hidden hides the glyph itself; this carries removeLabel into the pill's own accessible name */}\n <span className=\"sr-only\">{removeLabel}</span>\n <span\n aria-hidden=\"true\"\n data-slot=\"pill-remove\"\n onClick={(event) => {\n event.stopPropagation()\n onRemove?.(event)\n }}\n className=\"-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) motion-reduce:transition-none\"\n >\n <Close className=\"[--spark-icon-size:14px]\" />\n </span>\n </>\n ) : null}\n </span>\n </PillDisabledContext.Provider>\n )\n})\n\nPill.displayName = 'Pill'\n\ntype PillButtonProps = Omit<\n React.ComponentProps<typeof ButtonPrimitive>,\n 'ref' | 'className' | 'aria-label'\n> & {\n className?: string\n /** Names the button; the icon inside is decorative. */\n 'aria-label': string\n}\n\n/** A button inside a static `Pill` (no `onClick`, no `onRemove`); it is disabled with the pill. */\nconst PillButton = React.forwardRef<HTMLButtonElement, PillButtonProps>(\n function PillButton({ className, disabled, ...props }, ref) {\n const pillDisabled = React.useContext(PillDisabledContext)\n return (\n <ButtonPrimitive\n ref={ref}\n data-slot=\"pill-button\"\n disabled={disabled ?? pillDisabled}\n // fixed 24px target at any scaling; the ring takes the pill's ink, which reads on its fill\n className={cn(\n '-mr-2 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) focus-visible:outline-current motion-reduce:transition-none',\n className,\n )}\n {...props}\n />\n )\n },\n)\n\nPillButton.displayName = 'PillButton'\n\nexport { Pill, PillButton }\nexport type { PillButtonProps, PillProps }\n"],"mappings":";;;;;;;;;AA2BA,MAAM,sBAAsBA,QAAM,cAAc,KAAK;;;;;;AAOrD,MAAM,OAAOA,QAAM,WAAuC,SAAS,KACjE,EACE,WACA,UACA,cACA,OACA,WAAW,OACX,SACA,UACA,aACA,WACA,GAAG,SAEL,KACA;CACA,MAAM,YAAY,CAAC,YAAY,YAAY,KAAA;CAC3C,MAAM,YAAY,CAAC,YAAY,aAAa,KAAA;CAC5C,MAAM,YAAY,aAAa;CAC/B,MAAM,UAAU,iBAAiB,KAAA,KAAa,UAAU,KAAA;CAExD,MAAM,iBAAiB,UAAgD;EACrE,YAAY,KAAK;EACjB,IAAI,cAAc,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;GAC7D,IAAI,MAAM,QAAQ,KAAK,MAAM,eAAe;GAC5C,UAAU,KAAK;EACjB;EACA,IAAI,cAAc,MAAM,QAAQ,YAAY,MAAM,QAAQ,cACxD,WAAW,KAAK;CAEpB;CAIA,MAAM,cAAc;EAClB,WAAW;EACX,GAAI,aAAa;GAAE,MAAM;GAAmB;EAAQ;EACpD,GAAI,aAAa,EAAE,UAAU,EAAE;CACjC;CAEA,OACE,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;YACnC,qBAAC,QAAD;GACE,iBAAe,YAAY,KAAA;GAC3B,qBAAmB,YAAY,WAAW,KAAA;GAC1C,aAAU;GACV,cAAY,UAAW,gBAAgB,SAAU,KAAA;GACjD,qBAAmB,QAAQ,cAAc,SAAS,KAAA;GAClD,GAAI;GACC;GACL,WAAW,GACT,0FACA,4GACA,kGACA,aAAa,mDACb,aACE,sEACF,YAAY,kCACZ,SACF;GACA,GAAI;aAlBN,CAoBG,UACA,YACC,qBAAA,UAAA,EAAA,UAAA,CAEE,oBAAC,QAAD;IAAM,WAAU;cAAW;GAAkB,CAAA,GAC7C,oBAAC,QAAD;IACE,eAAY;IACZ,aAAU;IACV,UAAU,UAAU;KAClB,MAAM,gBAAgB;KACtB,WAAW,KAAK;IAClB;IACA,WAAU;cAEV,oBAAC,OAAD,EAAO,WAAU,2BAA4B,CAAA;GACzC,CAAA,CACN,EAAA,CAAA,IACA,IACA;;CACsB,CAAA;AAElC,CAAC;AAED,KAAK,cAAc;;AAYnB,MAAM,aAAaA,QAAM,WACvB,SAAS,WAAW,EAAE,WAAW,UAAU,GAAG,SAAS,KAAK;CAC1D,MAAM,eAAeA,QAAM,WAAW,mBAAmB;CACzD,OACE,oBAACC,QAAD;EACO;EACL,aAAU;EACV,UAAU,YAAY;EAEtB,WAAW,GACT,oOACA,SACF;EACA,GAAI;CACL,CAAA;AAEL,CACF;AAEA,WAAW,cAAc"}
1
+ {"version":3,"file":"pill.js","names":["React","ButtonPrimitive"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n}\n\nconst PillDisabledContext = React.createContext(false)\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space). Without it, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const hasLook = styleVariant !== undefined || color !== undefined\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (clickable && (event.key === 'Enter' || event.key === ' ')) {\n if (event.key === ' ') event.preventDefault()\n onClick?.(event)\n }\n }\n\n const interaction = {\n onKeyDown: handleKeyDown,\n ...(clickable && { role: 'button' as const, onClick, tabIndex: 0 }),\n }\n\n return (\n <PillDisabledContext.Provider value={disabled}>\n <span\n aria-disabled={disabled || undefined}\n data-slot=\"pill\"\n data-style={hasLook ? (styleVariant ?? 'soft') : undefined}\n data-accent-color={color ? accentByColor[color] : undefined}\n {...interaction}\n ref={ref}\n className={cn(\n 'inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none',\n 'bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--spark-badge-fg,var(--neutral-a11)))',\n 'shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]',\n clickable && 'transition-colors motion-reduce:transition-none',\n clickable &&\n 'cursor-pointer hover:bg-(--spark-style-bg-hover,var(--neutral-a4))',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...props}\n >\n {children}\n </span>\n </PillDisabledContext.Provider>\n )\n})\n\nPill.displayName = 'Pill'\n\ntype PillButtonProps = Omit<\n React.ComponentProps<typeof ButtonPrimitive>,\n 'ref' | 'className' | 'aria-label'\n> & {\n className?: string\n /** Names the button; the icon inside is decorative. */\n 'aria-label': string\n}\n\n/** A button inside a static `Pill` (no `onClick`); it is disabled with the pill. */\nconst PillButton = React.forwardRef<HTMLButtonElement, PillButtonProps>(\n function PillButton({ className, disabled, ...props }, ref) {\n const pillDisabled = React.useContext(PillDisabledContext)\n return (\n <ButtonPrimitive\n ref={ref}\n data-slot=\"pill-button\"\n disabled={disabled ?? pillDisabled}\n // fixed 24px target at any scaling; the ring takes the pill's ink, which reads on its fill\n className={cn(\n '-mr-2 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover,var(--neutral-a4)) focus-visible:outline-current motion-reduce:transition-none',\n className,\n )}\n {...props}\n />\n )\n },\n)\n\nPillButton.displayName = 'PillButton'\n\nexport { Pill, PillButton }\nexport type { PillButtonProps, PillProps }\n"],"mappings":";;;;;;;;AAgBA,MAAM,sBAAsBA,QAAM,cAAc,KAAK;;;;;AAMrD,MAAM,OAAOA,QAAM,WAAuC,SAAS,KACjE,EACE,WACA,UACA,cACA,OACA,WAAW,OACX,SACA,WACA,GAAG,SAEL,KACA;CACA,MAAM,YAAY,CAAC,YAAY,YAAY,KAAA;CAC3C,MAAM,UAAU,iBAAiB,KAAA,KAAa,UAAU,KAAA;CAExD,MAAM,iBAAiB,UAAgD;EACrE,YAAY,KAAK;EACjB,IAAI,cAAc,MAAM,QAAQ,WAAW,MAAM,QAAQ,MAAM;GAC7D,IAAI,MAAM,QAAQ,KAAK,MAAM,eAAe;GAC5C,UAAU,KAAK;EACjB;CACF;CAEA,MAAM,cAAc;EAClB,WAAW;EACX,GAAI,aAAa;GAAE,MAAM;GAAmB;GAAS,UAAU;EAAE;CACnE;CAEA,OACE,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;YACnC,oBAAC,QAAD;GACE,iBAAe,YAAY,KAAA;GAC3B,aAAU;GACV,cAAY,UAAW,gBAAgB,SAAU,KAAA;GACjD,qBAAmB,QAAQ,cAAc,SAAS,KAAA;GAClD,GAAI;GACC;GACL,WAAW,GACT,0FACA,4GACA,kGACA,aAAa,mDACb,aACE,sEACF,YAAY,kCACZ,SACF;GACA,GAAI;GAEH;EACG,CAAA;CACsB,CAAA;AAElC,CAAC;AAED,KAAK,cAAc;;AAYnB,MAAM,aAAaA,QAAM,WACvB,SAAS,WAAW,EAAE,WAAW,UAAU,GAAG,SAAS,KAAK;CAC1D,MAAM,eAAeA,QAAM,WAAW,mBAAmB;CACzD,OACE,oBAACC,QAAD;EACO;EACL,aAAU;EACV,UAAU,YAAY;EAEtB,WAAW,GACT,oOACA,SACF;EACA,GAAI;CACL,CAAA;AAEL,CACF;AAEA,WAAW,cAAc"}
@@ -1,15 +1,15 @@
1
1
  "use client";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const require_chunk = require("../chunk-DY84GLCh.cjs");
4
+ const require_hooks_use_chart_zoom = require("../hooks/use-chart-zoom.cjs");
5
+ const require_hooks_use_reduced_motion = require("../hooks/use-reduced-motion.cjs");
4
6
  require("../utils/chars.cjs");
5
7
  const require_utils_format = require("../utils/format.cjs");
6
8
  const require_utils_chart_scale = require("../utils/chart-scale.cjs");
7
- const require_utils_chart_time_ticks = require("../utils/chart-time-ticks.cjs");
8
- const require_hooks_use_chart_zoom = require("../hooks/use-chart-zoom.cjs");
9
- const require_hooks_use_reduced_motion = require("../hooks/use-reduced-motion.cjs");
10
9
  const require_components_chart = require("./chart.cjs");
11
10
  const require_components_series_legend = require("./series-legend.cjs");
12
11
  const require_components_typography = require("./typography.cjs");
12
+ const require_utils_chart_time_ticks = require("../utils/chart-time-ticks.cjs");
13
13
  let react = require("react");
14
14
  react = require_chunk.__toESM(react);
15
15
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -1,14 +1,14 @@
1
1
  "use client";
2
+ import { useAnimatedChartDomain, useChartZoom } from "../hooks/use-chart-zoom.js";
3
+ import { useReducedMotion } from "../hooks/use-reduced-motion.js";
4
+ import { cn } from "../utils/cn.js";
2
5
  import "../utils/chars.js";
3
6
  import { twoDecimalFormat } from "../utils/format.js";
4
7
  import { buildYAxisScale, formatYAxisTick, measureYAxisGutter } from "../utils/chart-scale.js";
5
- import { buildTimeTicks } from "../utils/chart-time-ticks.js";
6
- import { cn } from "../utils/cn.js";
7
- import { useAnimatedChartDomain, useChartZoom } from "../hooks/use-chart-zoom.js";
8
- import { useReducedMotion } from "../hooks/use-reduced-motion.js";
9
8
  import { ChartTooltipCard, ChartZoomResetButton, clampTooltipPosition, useMeasuredSize } from "./chart.js";
10
9
  import { SeriesLegend } from "./series-legend.js";
11
10
  import { SectionTitle } from "./typography.js";
11
+ import { buildTimeTicks } from "../utils/chart-time-ticks.js";
12
12
  import * as React$1 from "react";
13
13
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
14
14
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { cn } from "../utils/cn.js";
3
2
  import { useReducedMotion } from "../hooks/use-reduced-motion.js";
3
+ import { cn } from "../utils/cn.js";
4
4
  import { Skeleton } from "./skeleton.js";
5
5
  import { SectionTitle } from "./typography.js";
6
6
  import NumberFlow from "./number-flow.js";
@@ -46,7 +46,7 @@ function usePartId(idProp, register) {
46
46
  * A card that holds a radio of its `RadioCardGroup`. The whole card picks it,
47
47
  * but buttons, links and inputs inside keep working, so a card can carry rich content.
48
48
  */
49
- const RadioCard = react.forwardRef(({ className, children, onClick, value, disabled, readOnly, required, inputRef, id, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }, ref) => {
49
+ const RadioCard = react.forwardRef(({ className, children, onClick, value, disabled, readOnly, required, inputRef, id, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, ...props }, ref) => {
50
50
  const cardId = react.useId();
51
51
  const [labelId, setLabelId] = react.useState();
52
52
  const [descriptionId, setDescriptionId] = react.useState();
@@ -59,7 +59,9 @@ const RadioCard = react.forwardRef(({ className, children, onClick, value, disab
59
59
  inputRef,
60
60
  id,
61
61
  "aria-labelledby": ariaLabelledBy,
62
- "aria-describedby": ariaDescribedBy
62
+ "aria-describedby": ariaDescribedBy,
63
+ "aria-invalid": ariaInvalid,
64
+ "aria-required": ariaRequired
63
65
  }), [
64
66
  value,
65
67
  disabled,
@@ -68,7 +70,9 @@ const RadioCard = react.forwardRef(({ className, children, onClick, value, disab
68
70
  inputRef,
69
71
  id,
70
72
  ariaLabelledBy,
71
- ariaDescribedBy
73
+ ariaDescribedBy,
74
+ ariaInvalid,
75
+ ariaRequired
72
76
  ]);
73
77
  const context = react.useMemo(() => ({
74
78
  control,
@@ -107,12 +111,13 @@ RadioCard.displayName = "RadioCard";
107
111
  /** The radio itself, with the card's state props and its label and description. */
108
112
  const RadioCardControl = react.forwardRef(({ className, children, ...props }, ref) => {
109
113
  const context = react.useContext(RadioCardContext);
110
- const control = context?.control ?? { value: void 0 };
114
+ const { id, ...control } = context?.control ?? { value: void 0 };
111
115
  const describedBy = [control["aria-describedby"], context?.descriptionId].filter(Boolean).join(" ");
112
116
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_radio.Radio.Root, {
113
117
  ref,
114
118
  "data-slot": "radio-card-control",
115
119
  nativeButton: false,
120
+ render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { id }),
116
121
  ...control,
117
122
  "aria-labelledby": control["aria-labelledby"] ?? context?.labelId ?? context?.cardId,
118
123
  "aria-describedby": describedBy || void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"radio-card-group.cjs","names":["React","useFieldSetInvalid","RadioGroupPrimitive","RadioPrimitive"],"sources":["../../src/components/radio-card-group.tsx"],"sourcesContent":["'use client'\n\n// the control inside owns the keyboard; the card only forwards pointer clicks to it\n/* oxlint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */\n\nimport { Radio as RadioPrimitive } from '@base-ui/react/radio'\nimport { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'\nimport * as React from 'react'\nimport { forwardClickToControl } from '../lib/card-control'\nimport { cn } from '../utils/cn'\nimport { useFieldSetInvalid } from './field'\n\ntype RadioCardGroupProps = Omit<\n RadioGroupPrimitive.Props<string | null>,\n 'style' | 'value' | 'defaultValue' | 'onValueChange'\n> & {\n value?: string | null\n defaultValue?: string | null\n onValueChange?: (\n value: string,\n eventDetails: RadioGroupPrimitive.ChangeEventDetails,\n ) => void\n /** How many `--spark-layout-gap` units apart each card sits. */\n gap?: number\n style?: React.CSSProperties\n}\n\nconst RadioCardGroup = React.forwardRef<HTMLDivElement, RadioCardGroupProps>(\n ({ gap = 2, className, style, onValueChange, ...props }, ref) => {\n const invalid = useFieldSetInvalid()\n return (\n <RadioGroupPrimitive<string | null>\n ref={ref}\n onValueChange={\n onValueChange as RadioGroupPrimitive.Props<\n string | null\n >['onValueChange']\n }\n data-slot=\"radio-card-group\"\n aria-disabled={props.disabled || undefined}\n data-invalid={invalid}\n className={cn(\n 'group/radio-card-group flex flex-col gap-[calc(var(--spark-layout-gap)*var(--radio-card-group-gap-steps,2))]',\n className,\n )}\n style={\n {\n '--radio-card-group-gap-steps': gap,\n ...style,\n } as React.CSSProperties\n }\n {...props}\n />\n )\n },\n)\n\nRadioCardGroup.displayName = 'RadioCardGroup'\n\ntype ControlProps = Omit<\n React.ComponentProps<typeof RadioPrimitive.Root>,\n 'className' | 'style' | 'children' | 'render' | 'nativeButton'\n>\n\ninterface RadioCardContextValue {\n control: ControlProps\n cardId: string\n labelId: string | undefined\n descriptionId: string | undefined\n setLabelId: (id: string | undefined) => void\n setDescriptionId: (id: string | undefined) => void\n setHasIndicator: (has: boolean) => void\n}\n\nconst RadioCardContext = React.createContext<RadioCardContextValue | null>(null)\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nfunction usePartId(\n idProp: string | undefined,\n register: 'setLabelId' | 'setDescriptionId',\n) {\n const context = React.useContext(RadioCardContext)\n const generatedId = React.useId()\n const id = idProp ?? generatedId\n const setId = context?.[register]\n useIsomorphicLayoutEffect(() => {\n if (!setId) return undefined\n setId(id)\n return () => setId(undefined)\n }, [setId, id])\n return id\n}\n\n/** The card's state props (`value`, `disabled`, …) go to the radio inside it. */\ntype RadioCardProps = Omit<React.ComponentProps<'div'>, 'defaultValue'> &\n ControlProps\n\n/**\n * A card that holds a radio of its `RadioCardGroup`. The whole card picks it,\n * but buttons, links and inputs inside keep working, so a card can carry rich content.\n */\nconst RadioCard = React.forwardRef<HTMLDivElement, RadioCardProps>(\n (\n {\n className,\n children,\n onClick,\n // radio props, handed to the control through the context\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n ) => {\n const cardId = React.useId()\n const [labelId, setLabelId] = React.useState<string>()\n const [descriptionId, setDescriptionId] = React.useState<string>()\n const [hasIndicator, setHasIndicator] = React.useState(false)\n const control = React.useMemo<ControlProps>(\n () => ({\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n }),\n [\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n ariaLabelledBy,\n ariaDescribedBy,\n ],\n )\n const context = React.useMemo(\n () => ({\n control,\n cardId,\n labelId,\n descriptionId,\n setLabelId,\n setDescriptionId,\n setHasIndicator,\n }),\n [control, cardId, labelId, descriptionId],\n )\n\n return (\n <RadioCardContext.Provider value={context}>\n <div\n ref={ref}\n data-slot=\"radio-card\"\n id={cardId}\n // mirrored for assistive tech and for axe, which exempts disabled text from contrast\n aria-disabled={disabled || undefined}\n data-disabled={disabled || undefined}\n data-indicator={hasIndicator || undefined}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented)\n forwardClickToControl(event, '[data-slot=radio-card-control]')\n }}\n className={cn(\n 'group/radio-card grid min-h-12 w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-start gap-x-3 rounded-lg border border-transparent bg-base-gray-soft px-4 py-2.75 text-start text-base font-medium text-gray transition-colors motion-reduce:transition-none',\n 'not-has-[[data-slot=radio-card-control][data-checked]]:not-has-[[data-slot=radio-card-control][data-disabled]]:hover:bg-gray-a3',\n 'has-[[data-slot=radio-card-control][data-checked]]:border-primary has-[[data-slot=radio-card-control][data-checked]]:bg-primary-soft-hover has-[[data-slot=radio-card-control][data-checked]]:text-accent has-[[data-slot=radio-card-control][data-checked]]:inset-ring has-[[data-slot=radio-card-control][data-checked]]:inset-ring-primary',\n 'has-[[data-slot=radio-card-control][data-disabled]]:cursor-not-allowed has-[[data-slot=radio-card-control][data-disabled]]:opacity-50',\n // the ring draws on the card; the control inside carries the focus\n 'has-[[data-slot=radio-card-control]:focus-visible]:focus-outline',\n 'group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:bg-base-error-soft group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:text-error group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:not-has-[[data-slot=radio-card-control][data-disabled]]:hover:bg-error-soft-hover group-data-[invalid=true]/radio-card-group:has-[[data-slot=radio-card-control]:focus-visible]:outline-(--color-error-active)',\n '[&>:not([data-slot^=radio-card-])]:col-span-2 [&>:not([data-slot^=radio-card-])]:mt-3',\n // without an indicator part the label starts at the card's edge\n 'not-data-indicator:[&>[data-slot^=radio-card-]]:col-start-1',\n className,\n )}\n {...props}\n >\n {!hasIndicator && <RadioCardControl className=\"sr-only\" />}\n {children}\n </div>\n </RadioCardContext.Provider>\n )\n },\n)\n\nRadioCard.displayName = 'RadioCard'\n\ntype RadioCardControlProps = Omit<\n React.ComponentProps<typeof RadioPrimitive.Root>,\n keyof ControlProps | 'render' | 'nativeButton'\n>\n\n/** The radio itself, with the card's state props and its label and description. */\nconst RadioCardControl = React.forwardRef<HTMLElement, RadioCardControlProps>(\n ({ className, children, ...props }, ref) => {\n const context = React.useContext(RadioCardContext)\n const control = context?.control ?? { value: undefined }\n const describedBy = [control['aria-describedby'], context?.descriptionId]\n .filter(Boolean)\n .join(' ')\n return (\n <RadioPrimitive.Root\n ref={ref}\n data-slot=\"radio-card-control\"\n nativeButton={false}\n {...control}\n aria-labelledby={\n control['aria-labelledby'] ?? context?.labelId ?? context?.cardId\n }\n aria-describedby={describedBy || undefined}\n className={cn('focus-visible:outline-hidden', className)}\n {...props}\n >\n {children}\n </RadioPrimitive.Root>\n )\n },\n)\n\nRadioCardControl.displayName = 'RadioCardControl'\n\ntype RadioCardIndicatorProps = RadioCardControlProps\n\n/** The visible dot. Leave it out and the card still picks, with no dot drawn. */\nfunction RadioCardIndicator({ className, ...props }: RadioCardIndicatorProps) {\n const setHasIndicator = React.useContext(RadioCardContext)?.setHasIndicator\n useIsomorphicLayoutEffect(() => {\n if (!setHasIndicator) return undefined\n setHasIndicator(true)\n return () => setHasIndicator(false)\n }, [setHasIndicator])\n return (\n <RadioCardControl\n className={cn(\n // fixed 24px so the target holds at any text scaling (2.5.8)\n 'col-start-1 row-start-1 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full border-2 p-0 transition-colors motion-reduce:transition-none',\n 'border-(--spark-style-idle-border,var(--color-accent-ui)) bg-base-accent-soft',\n 'data-checked:border-(--spark-radio-ring,var(--spark-9)) data-disabled:cursor-not-allowed',\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator\n data-slot=\"radio-card-indicator\"\n className=\"flex items-center justify-center\"\n >\n <span className=\"size-[14px] rounded-full bg-(--spark-radio-dot,var(--spark-9)) motion-safe:animate-dot-pop\" />\n </RadioPrimitive.Indicator>\n </RadioCardControl>\n )\n}\n\ntype RadioCardLabelProps = React.ComponentProps<'span'>\n\nfunction RadioCardLabel({ id, className, ...props }: RadioCardLabelProps) {\n return (\n <span\n data-slot=\"radio-card-label\"\n id={usePartId(id, 'setLabelId')}\n className={cn('col-start-2 row-start-1 min-w-0', className)}\n {...props}\n />\n )\n}\n\ntype RadioCardDescriptionProps = React.ComponentProps<'span'>\n\nfunction RadioCardDescription({\n id,\n className,\n ...props\n}: RadioCardDescriptionProps) {\n return (\n <span\n data-slot=\"radio-card-description\"\n id={usePartId(id, 'setDescriptionId')}\n className={cn(\n 'col-start-2 mt-0.5 min-w-0 text-sm font-normal text-gray-light',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n RadioCard,\n RadioCardDescription,\n RadioCardGroup,\n RadioCardIndicator,\n RadioCardLabel,\n}\nexport type {\n RadioCardDescriptionProps,\n RadioCardGroupProps,\n RadioCardIndicatorProps,\n RadioCardLabelProps,\n RadioCardProps,\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAM,iBAAiBA,MAAM,YAC1B,EAAE,MAAM,GAAG,WAAW,OAAO,eAAe,GAAG,SAAS,QAAQ;CAC/D,MAAM,UAAUC,yBAAAA,mBAAmB;CACnC,OACE,iBAAA,GAAA,kBAAA,KAACC,2BAAAA,YAAD;EACO;EAEH;EAIF,aAAU;EACV,iBAAe,MAAM,YAAY,KAAA;EACjC,gBAAc;EACd,YAAA,GAAA,GAAA,IACE,gHACA,SACF;EACA,OACE;GACE,gCAAgC;GAChC,GAAG;EACL;EAEF,GAAI;CACL,CAAA;AAEL,CACF;AAEA,eAAe,cAAc;AAiB7B,MAAM,mBAAmBF,MAAM,cAA4C,IAAI;AAE/E,MAAM,4BACJ,OAAO,WAAW,cAAcA,MAAM,YAAYA,MAAM;AAE1D,SAAS,UACP,QACA,UACA;CACA,MAAM,UAAUA,MAAM,WAAW,gBAAgB;CACjD,MAAM,cAAcA,MAAM,MAAM;CAChC,MAAM,KAAK,UAAU;CACrB,MAAM,QAAQ,UAAU;CACxB,gCAAgC;EAC9B,IAAI,CAAC,OAAO,OAAO,KAAA;EACnB,MAAM,EAAE;EACR,aAAa,MAAM,KAAA,CAAS;CAC9B,GAAG,CAAC,OAAO,EAAE,CAAC;CACd,OAAO;AACT;;;;;AAUA,MAAM,YAAYA,MAAM,YAEpB,EACE,WACA,UACA,SAEA,OACA,UACA,UACA,UACA,UACA,IACA,mBAAmB,gBACnB,oBAAoB,iBACpB,GAAG,SAEL,QACG;CACH,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":["React","useFieldSetInvalid","RadioGroupPrimitive","RadioPrimitive"],"sources":["../../src/components/radio-card-group.tsx"],"sourcesContent":["'use client'\n\n// the control inside owns the keyboard; the card only forwards pointer clicks to it\n/* oxlint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */\n\nimport { Radio as RadioPrimitive } from '@base-ui/react/radio'\nimport { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'\nimport * as React from 'react'\nimport { forwardClickToControl } from '../lib/card-control'\nimport { cn } from '../utils/cn'\nimport { useFieldSetInvalid } from './field'\n\ntype RadioCardGroupProps = Omit<\n RadioGroupPrimitive.Props<string | null>,\n 'style' | 'value' | 'defaultValue' | 'onValueChange'\n> & {\n value?: string | null\n defaultValue?: string | null\n onValueChange?: (\n value: string,\n eventDetails: RadioGroupPrimitive.ChangeEventDetails,\n ) => void\n /** How many `--spark-layout-gap` units apart each card sits. */\n gap?: number\n style?: React.CSSProperties\n}\n\nconst RadioCardGroup = React.forwardRef<HTMLDivElement, RadioCardGroupProps>(\n ({ gap = 2, className, style, onValueChange, ...props }, ref) => {\n const invalid = useFieldSetInvalid()\n return (\n <RadioGroupPrimitive<string | null>\n ref={ref}\n onValueChange={\n onValueChange as RadioGroupPrimitive.Props<\n string | null\n >['onValueChange']\n }\n data-slot=\"radio-card-group\"\n aria-disabled={props.disabled || undefined}\n data-invalid={invalid}\n className={cn(\n 'group/radio-card-group flex flex-col gap-[calc(var(--spark-layout-gap)*var(--radio-card-group-gap-steps,2))]',\n className,\n )}\n style={\n {\n '--radio-card-group-gap-steps': gap,\n ...style,\n } as React.CSSProperties\n }\n {...props}\n />\n )\n },\n)\n\nRadioCardGroup.displayName = 'RadioCardGroup'\n\ntype ControlProps = Omit<\n React.ComponentProps<typeof RadioPrimitive.Root>,\n 'className' | 'style' | 'children' | 'render' | 'nativeButton'\n>\n\ninterface RadioCardContextValue {\n control: ControlProps\n cardId: string\n labelId: string | undefined\n descriptionId: string | undefined\n setLabelId: (id: string | undefined) => void\n setDescriptionId: (id: string | undefined) => void\n setHasIndicator: (has: boolean) => void\n}\n\nconst RadioCardContext = React.createContext<RadioCardContextValue | null>(null)\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nfunction usePartId(\n idProp: string | undefined,\n register: 'setLabelId' | 'setDescriptionId',\n) {\n const context = React.useContext(RadioCardContext)\n const generatedId = React.useId()\n const id = idProp ?? generatedId\n const setId = context?.[register]\n useIsomorphicLayoutEffect(() => {\n if (!setId) return undefined\n setId(id)\n return () => setId(undefined)\n }, [setId, id])\n return id\n}\n\n/** The card's state props (`value`, `disabled`, …) go to the radio inside it. */\ntype RadioCardProps = Omit<React.ComponentProps<'div'>, 'defaultValue'> &\n ControlProps\n\n/**\n * A card that holds a radio of its `RadioCardGroup`. The whole card picks it,\n * but buttons, links and inputs inside keep working, so a card can carry rich content.\n */\nconst RadioCard = React.forwardRef<HTMLDivElement, RadioCardProps>(\n (\n {\n className,\n children,\n onClick,\n // radio props, handed to the control through the context\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n ...props\n },\n ref,\n ) => {\n const cardId = React.useId()\n const [labelId, setLabelId] = React.useState<string>()\n const [descriptionId, setDescriptionId] = React.useState<string>()\n const [hasIndicator, setHasIndicator] = React.useState(false)\n const control = React.useMemo<ControlProps>(\n () => ({\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n }),\n [\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaInvalid,\n ariaRequired,\n ],\n )\n const context = React.useMemo(\n () => ({\n control,\n cardId,\n labelId,\n descriptionId,\n setLabelId,\n setDescriptionId,\n setHasIndicator,\n }),\n [control, cardId, labelId, descriptionId],\n )\n\n return (\n <RadioCardContext.Provider value={context}>\n <div\n ref={ref}\n data-slot=\"radio-card\"\n id={cardId}\n // mirrored for assistive tech and for axe, which exempts disabled text from contrast\n aria-disabled={disabled || undefined}\n data-disabled={disabled || undefined}\n data-indicator={hasIndicator || undefined}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented)\n forwardClickToControl(event, '[data-slot=radio-card-control]')\n }}\n className={cn(\n 'group/radio-card grid min-h-12 w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-start gap-x-3 rounded-lg border border-transparent bg-base-gray-soft px-4 py-2.75 text-start text-base font-medium text-gray transition-colors motion-reduce:transition-none',\n 'not-has-[[data-slot=radio-card-control][data-checked]]:not-has-[[data-slot=radio-card-control][data-disabled]]:hover:bg-gray-a3',\n 'has-[[data-slot=radio-card-control][data-checked]]:border-primary has-[[data-slot=radio-card-control][data-checked]]:bg-primary-soft-hover has-[[data-slot=radio-card-control][data-checked]]:text-accent has-[[data-slot=radio-card-control][data-checked]]:inset-ring has-[[data-slot=radio-card-control][data-checked]]:inset-ring-primary',\n 'has-[[data-slot=radio-card-control][data-disabled]]:cursor-not-allowed has-[[data-slot=radio-card-control][data-disabled]]:opacity-50',\n // the ring draws on the card; the control inside carries the focus\n 'has-[[data-slot=radio-card-control]:focus-visible]:focus-outline',\n 'group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:bg-base-error-soft group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:text-error group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:not-has-[[data-slot=radio-card-control][data-disabled]]:hover:bg-error-soft-hover group-data-[invalid=true]/radio-card-group:has-[[data-slot=radio-card-control]:focus-visible]:outline-(--color-error-active)',\n '[&>:not([data-slot^=radio-card-])]:col-span-2 [&>:not([data-slot^=radio-card-])]:mt-3',\n // without an indicator part the label starts at the card's edge\n 'not-data-indicator:[&>[data-slot^=radio-card-]]:col-start-1',\n className,\n )}\n {...props}\n >\n {!hasIndicator && <RadioCardControl className=\"sr-only\" />}\n {children}\n </div>\n </RadioCardContext.Provider>\n )\n },\n)\n\nRadioCard.displayName = 'RadioCard'\n\ntype RadioCardControlProps = Omit<\n React.ComponentProps<typeof RadioPrimitive.Root>,\n keyof ControlProps | 'render' | 'nativeButton'\n>\n\n/** The radio itself, with the card's state props and its label and description. */\nconst RadioCardControl = React.forwardRef<HTMLElement, RadioCardControlProps>(\n ({ className, children, ...props }, ref) => {\n const context = React.useContext(RadioCardContext)\n const { id, ...control } = context?.control ?? { value: undefined }\n const describedBy = [control['aria-describedby'], context?.descriptionId]\n .filter(Boolean)\n .join(' ')\n return (\n <RadioPrimitive.Root\n ref={ref}\n data-slot=\"radio-card-control\"\n nativeButton={false}\n // on a non-native control Base UI puts `id` on its hidden input; the card's id names the control\n render={<span id={id} />}\n {...control}\n aria-labelledby={\n control['aria-labelledby'] ?? context?.labelId ?? context?.cardId\n }\n aria-describedby={describedBy || undefined}\n className={cn('focus-visible:outline-hidden', className)}\n {...props}\n >\n {children}\n </RadioPrimitive.Root>\n )\n },\n)\n\nRadioCardControl.displayName = 'RadioCardControl'\n\ntype RadioCardIndicatorProps = RadioCardControlProps\n\n/** The visible dot. Leave it out and the card still picks, with no dot drawn. */\nfunction RadioCardIndicator({ className, ...props }: RadioCardIndicatorProps) {\n const setHasIndicator = React.useContext(RadioCardContext)?.setHasIndicator\n useIsomorphicLayoutEffect(() => {\n if (!setHasIndicator) return undefined\n setHasIndicator(true)\n return () => setHasIndicator(false)\n }, [setHasIndicator])\n return (\n <RadioCardControl\n className={cn(\n // fixed 24px so the target holds at any text scaling (2.5.8)\n 'col-start-1 row-start-1 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full border-2 p-0 transition-colors motion-reduce:transition-none',\n 'border-(--spark-style-idle-border,var(--color-accent-ui)) bg-base-accent-soft',\n 'data-checked:border-(--spark-radio-ring,var(--spark-9)) data-disabled:cursor-not-allowed',\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator\n data-slot=\"radio-card-indicator\"\n className=\"flex items-center justify-center\"\n >\n <span className=\"size-[14px] rounded-full bg-(--spark-radio-dot,var(--spark-9)) motion-safe:animate-dot-pop\" />\n </RadioPrimitive.Indicator>\n </RadioCardControl>\n )\n}\n\ntype RadioCardLabelProps = React.ComponentProps<'span'>\n\nfunction RadioCardLabel({ id, className, ...props }: RadioCardLabelProps) {\n return (\n <span\n data-slot=\"radio-card-label\"\n id={usePartId(id, 'setLabelId')}\n className={cn('col-start-2 row-start-1 min-w-0', className)}\n {...props}\n />\n )\n}\n\ntype RadioCardDescriptionProps = React.ComponentProps<'span'>\n\nfunction RadioCardDescription({\n id,\n className,\n ...props\n}: RadioCardDescriptionProps) {\n return (\n <span\n data-slot=\"radio-card-description\"\n id={usePartId(id, 'setDescriptionId')}\n className={cn(\n 'col-start-2 mt-0.5 min-w-0 text-sm font-normal text-gray-light',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n RadioCard,\n RadioCardDescription,\n RadioCardGroup,\n RadioCardIndicator,\n RadioCardLabel,\n}\nexport type {\n RadioCardDescriptionProps,\n RadioCardGroupProps,\n RadioCardIndicatorProps,\n RadioCardLabelProps,\n RadioCardProps,\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,MAAM,iBAAiBA,MAAM,YAC1B,EAAE,MAAM,GAAG,WAAW,OAAO,eAAe,GAAG,SAAS,QAAQ;CAC/D,MAAM,UAAUC,yBAAAA,mBAAmB;CACnC,OACE,iBAAA,GAAA,kBAAA,KAACC,2BAAAA,YAAD;EACO;EAEH;EAIF,aAAU;EACV,iBAAe,MAAM,YAAY,KAAA;EACjC,gBAAc;EACd,YAAA,GAAA,GAAA,IACE,gHACA,SACF;EACA,OACE;GACE,gCAAgC;GAChC,GAAG;EACL;EAEF,GAAI;CACL,CA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ACpB,OACE,iBAAA,GAAA,kBAAA,KAAC,kBAAD;EACE,YAAA,GAAA,GAAA,IAEE,iLACA,iFACA,4FACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACG,qBAAAA,MAAe,WAAhB;GACE,aAAU;GACV,WAAU;aAEV,iBAAA,GAAA,kBAAA,KAAC,QAAD,EAAM,WAAU,6FAA8F,CAAA;EACtF,CAAA;CACV,CAAA;AAEtB;AAIA,SAAS,eAAe,EAAE,IAAI,WAAW,GAAG,SAA8B;CACxE,OACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EACE,aAAU;EACV,IAAI,UAAU,IAAI,YAAY;EAC9B,YAAA,GAAA,GAAA,IAAc,mCAAmC,SAAS;EAC1D,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,qBAAqB,EAC5B,IACA,WACA,GAAG,SACyB;CAC5B,OACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EACE,aAAU;EACV,IAAI,UAAU,IAAI,kBAAkB;EACpC,YAAA,GAAA,GAAA,IACE,kEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
@@ -43,7 +43,7 @@ function usePartId(idProp, register) {
43
43
  * A card that holds a radio of its `RadioCardGroup`. The whole card picks it,
44
44
  * but buttons, links and inputs inside keep working, so a card can carry rich content.
45
45
  */
46
- const RadioCard = React$1.forwardRef(({ className, children, onClick, value, disabled, readOnly, required, inputRef, id, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...props }, ref) => {
46
+ const RadioCard = React$1.forwardRef(({ className, children, onClick, value, disabled, readOnly, required, inputRef, id, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-required": ariaRequired, ...props }, ref) => {
47
47
  const cardId = React$1.useId();
48
48
  const [labelId, setLabelId] = React$1.useState();
49
49
  const [descriptionId, setDescriptionId] = React$1.useState();
@@ -56,7 +56,9 @@ const RadioCard = React$1.forwardRef(({ className, children, onClick, value, dis
56
56
  inputRef,
57
57
  id,
58
58
  "aria-labelledby": ariaLabelledBy,
59
- "aria-describedby": ariaDescribedBy
59
+ "aria-describedby": ariaDescribedBy,
60
+ "aria-invalid": ariaInvalid,
61
+ "aria-required": ariaRequired
60
62
  }), [
61
63
  value,
62
64
  disabled,
@@ -65,7 +67,9 @@ const RadioCard = React$1.forwardRef(({ className, children, onClick, value, dis
65
67
  inputRef,
66
68
  id,
67
69
  ariaLabelledBy,
68
- ariaDescribedBy
70
+ ariaDescribedBy,
71
+ ariaInvalid,
72
+ ariaRequired
69
73
  ]);
70
74
  const context = React$1.useMemo(() => ({
71
75
  control,
@@ -104,12 +108,13 @@ RadioCard.displayName = "RadioCard";
104
108
  /** The radio itself, with the card's state props and its label and description. */
105
109
  const RadioCardControl = React$1.forwardRef(({ className, children, ...props }, ref) => {
106
110
  const context = React$1.useContext(RadioCardContext);
107
- const control = context?.control ?? { value: void 0 };
111
+ const { id, ...control } = context?.control ?? { value: void 0 };
108
112
  const describedBy = [control["aria-describedby"], context?.descriptionId].filter(Boolean).join(" ");
109
113
  return /* @__PURE__ */ jsx(Radio.Root, {
110
114
  ref,
111
115
  "data-slot": "radio-card-control",
112
116
  nativeButton: false,
117
+ render: /* @__PURE__ */ jsx("span", { id }),
113
118
  ...control,
114
119
  "aria-labelledby": control["aria-labelledby"] ?? context?.labelId ?? context?.cardId,
115
120
  "aria-describedby": describedBy || void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"radio-card-group.js","names":["React","RadioGroupPrimitive","RadioPrimitive"],"sources":["../../src/components/radio-card-group.tsx"],"sourcesContent":["'use client'\n\n// the control inside owns the keyboard; the card only forwards pointer clicks to it\n/* oxlint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */\n\nimport { Radio as RadioPrimitive } from '@base-ui/react/radio'\nimport { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'\nimport * as React from 'react'\nimport { forwardClickToControl } from '../lib/card-control'\nimport { cn } from '../utils/cn'\nimport { useFieldSetInvalid } from './field'\n\ntype RadioCardGroupProps = Omit<\n RadioGroupPrimitive.Props<string | null>,\n 'style' | 'value' | 'defaultValue' | 'onValueChange'\n> & {\n value?: string | null\n defaultValue?: string | null\n onValueChange?: (\n value: string,\n eventDetails: RadioGroupPrimitive.ChangeEventDetails,\n ) => void\n /** How many `--spark-layout-gap` units apart each card sits. */\n gap?: number\n style?: React.CSSProperties\n}\n\nconst RadioCardGroup = React.forwardRef<HTMLDivElement, RadioCardGroupProps>(\n ({ gap = 2, className, style, onValueChange, ...props }, ref) => {\n const invalid = useFieldSetInvalid()\n return (\n <RadioGroupPrimitive<string | null>\n ref={ref}\n onValueChange={\n onValueChange as RadioGroupPrimitive.Props<\n string | null\n >['onValueChange']\n }\n data-slot=\"radio-card-group\"\n aria-disabled={props.disabled || undefined}\n data-invalid={invalid}\n className={cn(\n 'group/radio-card-group flex flex-col gap-[calc(var(--spark-layout-gap)*var(--radio-card-group-gap-steps,2))]',\n className,\n )}\n style={\n {\n '--radio-card-group-gap-steps': gap,\n ...style,\n } as React.CSSProperties\n }\n {...props}\n />\n )\n },\n)\n\nRadioCardGroup.displayName = 'RadioCardGroup'\n\ntype ControlProps = Omit<\n React.ComponentProps<typeof RadioPrimitive.Root>,\n 'className' | 'style' | 'children' | 'render' | 'nativeButton'\n>\n\ninterface RadioCardContextValue {\n control: ControlProps\n cardId: string\n labelId: string | undefined\n descriptionId: string | undefined\n setLabelId: (id: string | undefined) => void\n setDescriptionId: (id: string | undefined) => void\n setHasIndicator: (has: boolean) => void\n}\n\nconst RadioCardContext = React.createContext<RadioCardContextValue | null>(null)\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nfunction usePartId(\n idProp: string | undefined,\n register: 'setLabelId' | 'setDescriptionId',\n) {\n const context = React.useContext(RadioCardContext)\n const generatedId = React.useId()\n const id = idProp ?? generatedId\n const setId = context?.[register]\n useIsomorphicLayoutEffect(() => {\n if (!setId) return undefined\n setId(id)\n return () => setId(undefined)\n }, [setId, id])\n return id\n}\n\n/** The card's state props (`value`, `disabled`, …) go to the radio inside it. */\ntype RadioCardProps = Omit<React.ComponentProps<'div'>, 'defaultValue'> &\n ControlProps\n\n/**\n * A card that holds a radio of its `RadioCardGroup`. The whole card picks it,\n * but buttons, links and inputs inside keep working, so a card can carry rich content.\n */\nconst RadioCard = React.forwardRef<HTMLDivElement, RadioCardProps>(\n (\n {\n className,\n children,\n onClick,\n // radio props, handed to the control through the context\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n ) => {\n const cardId = React.useId()\n const [labelId, setLabelId] = React.useState<string>()\n const [descriptionId, setDescriptionId] = React.useState<string>()\n const [hasIndicator, setHasIndicator] = React.useState(false)\n const control = React.useMemo<ControlProps>(\n () => ({\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n }),\n [\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n ariaLabelledBy,\n ariaDescribedBy,\n ],\n )\n const context = React.useMemo(\n () => ({\n control,\n cardId,\n labelId,\n descriptionId,\n setLabelId,\n setDescriptionId,\n setHasIndicator,\n }),\n [control, cardId, labelId, descriptionId],\n )\n\n return (\n <RadioCardContext.Provider value={context}>\n <div\n ref={ref}\n data-slot=\"radio-card\"\n id={cardId}\n // mirrored for assistive tech and for axe, which exempts disabled text from contrast\n aria-disabled={disabled || undefined}\n data-disabled={disabled || undefined}\n data-indicator={hasIndicator || undefined}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented)\n forwardClickToControl(event, '[data-slot=radio-card-control]')\n }}\n className={cn(\n 'group/radio-card grid min-h-12 w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-start gap-x-3 rounded-lg border border-transparent bg-base-gray-soft px-4 py-2.75 text-start text-base font-medium text-gray transition-colors motion-reduce:transition-none',\n 'not-has-[[data-slot=radio-card-control][data-checked]]:not-has-[[data-slot=radio-card-control][data-disabled]]:hover:bg-gray-a3',\n 'has-[[data-slot=radio-card-control][data-checked]]:border-primary has-[[data-slot=radio-card-control][data-checked]]:bg-primary-soft-hover has-[[data-slot=radio-card-control][data-checked]]:text-accent has-[[data-slot=radio-card-control][data-checked]]:inset-ring has-[[data-slot=radio-card-control][data-checked]]:inset-ring-primary',\n 'has-[[data-slot=radio-card-control][data-disabled]]:cursor-not-allowed has-[[data-slot=radio-card-control][data-disabled]]:opacity-50',\n // the ring draws on the card; the control inside carries the focus\n 'has-[[data-slot=radio-card-control]:focus-visible]:focus-outline',\n 'group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:bg-base-error-soft group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:text-error group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:not-has-[[data-slot=radio-card-control][data-disabled]]:hover:bg-error-soft-hover group-data-[invalid=true]/radio-card-group:has-[[data-slot=radio-card-control]:focus-visible]:outline-(--color-error-active)',\n '[&>:not([data-slot^=radio-card-])]:col-span-2 [&>:not([data-slot^=radio-card-])]:mt-3',\n // without an indicator part the label starts at the card's edge\n 'not-data-indicator:[&>[data-slot^=radio-card-]]:col-start-1',\n className,\n )}\n {...props}\n >\n {!hasIndicator && <RadioCardControl className=\"sr-only\" />}\n {children}\n </div>\n </RadioCardContext.Provider>\n )\n },\n)\n\nRadioCard.displayName = 'RadioCard'\n\ntype RadioCardControlProps = Omit<\n React.ComponentProps<typeof RadioPrimitive.Root>,\n keyof ControlProps | 'render' | 'nativeButton'\n>\n\n/** The radio itself, with the card's state props and its label and description. */\nconst RadioCardControl = React.forwardRef<HTMLElement, RadioCardControlProps>(\n ({ className, children, ...props }, ref) => {\n const context = React.useContext(RadioCardContext)\n const control = context?.control ?? { value: undefined }\n const describedBy = [control['aria-describedby'], context?.descriptionId]\n .filter(Boolean)\n .join(' ')\n return (\n <RadioPrimitive.Root\n ref={ref}\n data-slot=\"radio-card-control\"\n nativeButton={false}\n {...control}\n aria-labelledby={\n control['aria-labelledby'] ?? context?.labelId ?? context?.cardId\n }\n aria-describedby={describedBy || undefined}\n className={cn('focus-visible:outline-hidden', className)}\n {...props}\n >\n {children}\n </RadioPrimitive.Root>\n )\n },\n)\n\nRadioCardControl.displayName = 'RadioCardControl'\n\ntype RadioCardIndicatorProps = RadioCardControlProps\n\n/** The visible dot. Leave it out and the card still picks, with no dot drawn. */\nfunction RadioCardIndicator({ className, ...props }: RadioCardIndicatorProps) {\n const setHasIndicator = React.useContext(RadioCardContext)?.setHasIndicator\n useIsomorphicLayoutEffect(() => {\n if (!setHasIndicator) return undefined\n setHasIndicator(true)\n return () => setHasIndicator(false)\n }, [setHasIndicator])\n return (\n <RadioCardControl\n className={cn(\n // fixed 24px so the target holds at any text scaling (2.5.8)\n 'col-start-1 row-start-1 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full border-2 p-0 transition-colors motion-reduce:transition-none',\n 'border-(--spark-style-idle-border,var(--color-accent-ui)) bg-base-accent-soft',\n 'data-checked:border-(--spark-radio-ring,var(--spark-9)) data-disabled:cursor-not-allowed',\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator\n data-slot=\"radio-card-indicator\"\n className=\"flex items-center justify-center\"\n >\n <span className=\"size-[14px] rounded-full bg-(--spark-radio-dot,var(--spark-9)) motion-safe:animate-dot-pop\" />\n </RadioPrimitive.Indicator>\n </RadioCardControl>\n )\n}\n\ntype RadioCardLabelProps = React.ComponentProps<'span'>\n\nfunction RadioCardLabel({ id, className, ...props }: RadioCardLabelProps) {\n return (\n <span\n data-slot=\"radio-card-label\"\n id={usePartId(id, 'setLabelId')}\n className={cn('col-start-2 row-start-1 min-w-0', className)}\n {...props}\n />\n )\n}\n\ntype RadioCardDescriptionProps = React.ComponentProps<'span'>\n\nfunction RadioCardDescription({\n id,\n className,\n ...props\n}: RadioCardDescriptionProps) {\n return (\n <span\n data-slot=\"radio-card-description\"\n id={usePartId(id, 'setDescriptionId')}\n className={cn(\n 'col-start-2 mt-0.5 min-w-0 text-sm font-normal text-gray-light',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n RadioCard,\n RadioCardDescription,\n RadioCardGroup,\n RadioCardIndicator,\n RadioCardLabel,\n}\nexport type {\n RadioCardDescriptionProps,\n RadioCardGroupProps,\n RadioCardIndicatorProps,\n RadioCardLabelProps,\n RadioCardProps,\n}\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,iBAAiBA,QAAM,YAC1B,EAAE,MAAM,GAAG,WAAW,OAAO,eAAe,GAAG,SAAS,QAAQ;CAC/D,MAAM,UAAU,mBAAmB;CACnC,OACE,oBAACC,YAAD;EACO;EAEH;EAIF,aAAU;EACV,iBAAe,MAAM,YAAY,KAAA;EACjC,gBAAc;EACd,WAAW,GACT,gHACA,SACF;EACA,OACE;GACE,gCAAgC;GAChC,GAAG;EACL;EAEF,GAAI;CACL,CAAA;AAEL,CACF;AAEA,eAAe,cAAc;AAiB7B,MAAM,mBAAmBD,QAAM,cAA4C,IAAI;AAE/E,MAAM,4BACJ,OAAO,WAAW,cAAcA,QAAM,YAAYA,QAAM;AAE1D,SAAS,UACP,QACA,UACA;CACA,MAAM,UAAUA,QAAM,WAAW,gBAAgB;CACjD,MAAM,cAAcA,QAAM,MAAM;CAChC,MAAM,KAAK,UAAU;CACrB,MAAM,QAAQ,UAAU;CACxB,gCAAgC;EAC9B,IAAI,CAAC,OAAO,OAAO,KAAA;EACnB,MAAM,EAAE;EACR,aAAa,MAAM,KAAA,CAAS;CAC9B,GAAG,CAAC,OAAO,EAAE,CAAC;CACd,OAAO;AACT;;;;;AAUA,MAAM,YAAYA,QAAM,YAEpB,EACE,WACA,UACA,SAEA,OACA,UACA,UACA,UACA,UACA,IACA,mBAAmB,gBACnB,oBAA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U;EACV,cAAc;EACd,GAAI;EACJ,mBACE,QAAQ,sBAAsB,SAAS,WAAW,SAAS;EAE7D,oBAAkB,eAAe,KAAA;EACjC,WAAW,GAAG,gCAAgC,SAAS;EACvD,GAAI;EAEH;CACkB,CAAA;AAEzB,CACF;AAEA,iBAAiB,cAAc;;AAK/B,SAAS,mBAAmB,EAAE,WAAW,GAAG,SAAkC;CAC5E,MAAM,kBAAkBF,QAAM,WAAW,gBAAgB,GAAG;CAC5D,gCAAgC;EAC9B,IAAI,CAAC,iBAAiB,OAAO,KAAA;EAC7B,gBAAgB,IAAI;EACpB,aAAa,gBAAgB,KAAK;CACpC,GAAG,CAAC,eAAe,CAAC;CACpB,OACE,oBAAC,kBAAD;EACE,WAAW,GAET,iLACA,iFACA,4FACA,SACF;EACA,GAAI;YAEJ,oBAACE,MAAe,WAAhB;GACE,aAAU;GACV,WAAU;aAEV,oBAAC,QAAD,EAAM,WAAU,6FAA8F,CAAA;EACtF,CAAA;CACV,CAAA;AAEtB;AAIA,SAAS,eAAe,EAAE,IAAI,WAAW,GAAG,SAA8B;CACxE,OACE,oBAAC,QAAD;EACE,aAAU;EACV,IAAI,UAAU,IAAI,YAAY;EAC9B,WAAW,GAAG,mCAAmC,SAAS;EAC1D,GAAI;CACL,CAAA;AAEL;AAIA,SAAS,qBAAqB,EAC5B,IACA,WACA,GAAG,SACyB;CAC5B,OACE,oBAAC,QAAD;EACE,aAAU;EACV,IAAI,UAAU,IAAI,kBAAkB;EACpC,WAAW,GACT,kEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
1
+ {"version":3,"file":"radio-card-group.js","names":["React","RadioGroupPrimitive","RadioPrimitive"],"sources":["../../src/components/radio-card-group.tsx"],"sourcesContent":["'use client'\n\n// the control inside owns the keyboard; the card only forwards pointer clicks to it\n/* oxlint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */\n\nimport { Radio as RadioPrimitive } from '@base-ui/react/radio'\nimport { RadioGroup as RadioGroupPrimitive } from '@base-ui/react/radio-group'\nimport * as React from 'react'\nimport { forwardClickToControl } from '../lib/card-control'\nimport { cn } from '../utils/cn'\nimport { useFieldSetInvalid } from './field'\n\ntype RadioCardGroupProps = Omit<\n RadioGroupPrimitive.Props<string | null>,\n 'style' | 'value' | 'defaultValue' | 'onValueChange'\n> & {\n value?: string | null\n defaultValue?: string | null\n onValueChange?: (\n value: string,\n eventDetails: RadioGroupPrimitive.ChangeEventDetails,\n ) => void\n /** How many `--spark-layout-gap` units apart each card sits. */\n gap?: number\n style?: React.CSSProperties\n}\n\nconst RadioCardGroup = React.forwardRef<HTMLDivElement, RadioCardGroupProps>(\n ({ gap = 2, className, style, onValueChange, ...props }, ref) => {\n const invalid = useFieldSetInvalid()\n return (\n <RadioGroupPrimitive<string | null>\n ref={ref}\n onValueChange={\n onValueChange as RadioGroupPrimitive.Props<\n string | null\n >['onValueChange']\n }\n data-slot=\"radio-card-group\"\n aria-disabled={props.disabled || undefined}\n data-invalid={invalid}\n className={cn(\n 'group/radio-card-group flex flex-col gap-[calc(var(--spark-layout-gap)*var(--radio-card-group-gap-steps,2))]',\n className,\n )}\n style={\n {\n '--radio-card-group-gap-steps': gap,\n ...style,\n } as React.CSSProperties\n }\n {...props}\n />\n )\n },\n)\n\nRadioCardGroup.displayName = 'RadioCardGroup'\n\ntype ControlProps = Omit<\n React.ComponentProps<typeof RadioPrimitive.Root>,\n 'className' | 'style' | 'children' | 'render' | 'nativeButton'\n>\n\ninterface RadioCardContextValue {\n control: ControlProps\n cardId: string\n labelId: string | undefined\n descriptionId: string | undefined\n setLabelId: (id: string | undefined) => void\n setDescriptionId: (id: string | undefined) => void\n setHasIndicator: (has: boolean) => void\n}\n\nconst RadioCardContext = React.createContext<RadioCardContextValue | null>(null)\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nfunction usePartId(\n idProp: string | undefined,\n register: 'setLabelId' | 'setDescriptionId',\n) {\n const context = React.useContext(RadioCardContext)\n const generatedId = React.useId()\n const id = idProp ?? generatedId\n const setId = context?.[register]\n useIsomorphicLayoutEffect(() => {\n if (!setId) return undefined\n setId(id)\n return () => setId(undefined)\n }, [setId, id])\n return id\n}\n\n/** The card's state props (`value`, `disabled`, …) go to the radio inside it. */\ntype RadioCardProps = Omit<React.ComponentProps<'div'>, 'defaultValue'> &\n ControlProps\n\n/**\n * A card that holds a radio of its `RadioCardGroup`. The whole card picks it,\n * but buttons, links and inputs inside keep working, so a card can carry rich content.\n */\nconst RadioCard = React.forwardRef<HTMLDivElement, RadioCardProps>(\n (\n {\n className,\n children,\n onClick,\n // radio props, handed to the control through the context\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n ...props\n },\n ref,\n ) => {\n const cardId = React.useId()\n const [labelId, setLabelId] = React.useState<string>()\n const [descriptionId, setDescriptionId] = React.useState<string>()\n const [hasIndicator, setHasIndicator] = React.useState(false)\n const control = React.useMemo<ControlProps>(\n () => ({\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n }),\n [\n value,\n disabled,\n readOnly,\n required,\n inputRef,\n id,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaInvalid,\n ariaRequired,\n ],\n )\n const context = React.useMemo(\n () => ({\n control,\n cardId,\n labelId,\n descriptionId,\n setLabelId,\n setDescriptionId,\n setHasIndicator,\n }),\n [control, cardId, labelId, descriptionId],\n )\n\n return (\n <RadioCardContext.Provider value={context}>\n <div\n ref={ref}\n data-slot=\"radio-card\"\n id={cardId}\n // mirrored for assistive tech and for axe, which exempts disabled text from contrast\n aria-disabled={disabled || undefined}\n data-disabled={disabled || undefined}\n data-indicator={hasIndicator || undefined}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented)\n forwardClickToControl(event, '[data-slot=radio-card-control]')\n }}\n className={cn(\n 'group/radio-card grid min-h-12 w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-start gap-x-3 rounded-lg border border-transparent bg-base-gray-soft px-4 py-2.75 text-start text-base font-medium text-gray transition-colors motion-reduce:transition-none',\n 'not-has-[[data-slot=radio-card-control][data-checked]]:not-has-[[data-slot=radio-card-control][data-disabled]]:hover:bg-gray-a3',\n 'has-[[data-slot=radio-card-control][data-checked]]:border-primary has-[[data-slot=radio-card-control][data-checked]]:bg-primary-soft-hover has-[[data-slot=radio-card-control][data-checked]]:text-accent has-[[data-slot=radio-card-control][data-checked]]:inset-ring has-[[data-slot=radio-card-control][data-checked]]:inset-ring-primary',\n 'has-[[data-slot=radio-card-control][data-disabled]]:cursor-not-allowed has-[[data-slot=radio-card-control][data-disabled]]:opacity-50',\n // the ring draws on the card; the control inside carries the focus\n 'has-[[data-slot=radio-card-control]:focus-visible]:focus-outline',\n 'group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:bg-base-error-soft group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:text-error group-data-[invalid=true]/radio-card-group:not-has-[[data-slot=radio-card-control][data-checked]]:not-has-[[data-slot=radio-card-control][data-disabled]]:hover:bg-error-soft-hover group-data-[invalid=true]/radio-card-group:has-[[data-slot=radio-card-control]:focus-visible]:outline-(--color-error-active)',\n '[&>:not([data-slot^=radio-card-])]:col-span-2 [&>:not([data-slot^=radio-card-])]:mt-3',\n // without an indicator part the label starts at the card's edge\n 'not-data-indicator:[&>[data-slot^=radio-card-]]:col-start-1',\n className,\n )}\n {...props}\n >\n {!hasIndicator && <RadioCardControl className=\"sr-only\" />}\n {children}\n </div>\n </RadioCardContext.Provider>\n )\n },\n)\n\nRadioCard.displayName = 'RadioCard'\n\ntype RadioCardControlProps = Omit<\n React.ComponentProps<typeof RadioPrimitive.Root>,\n keyof ControlProps | 'render' | 'nativeButton'\n>\n\n/** The radio itself, with the card's state props and its label and description. */\nconst RadioCardControl = React.forwardRef<HTMLElement, RadioCardControlProps>(\n ({ className, children, ...props }, ref) => {\n const context = React.useContext(RadioCardContext)\n const { id, ...control } = context?.control ?? { value: undefined }\n const describedBy = [control['aria-describedby'], context?.descriptionId]\n .filter(Boolean)\n .join(' ')\n return (\n <RadioPrimitive.Root\n ref={ref}\n data-slot=\"radio-card-control\"\n nativeButton={false}\n // on a non-native control Base UI puts `id` on its hidden input; the card's id names the control\n render={<span id={id} />}\n {...control}\n aria-labelledby={\n control['aria-labelledby'] ?? context?.labelId ?? context?.cardId\n }\n aria-describedby={describedBy || undefined}\n className={cn('focus-visible:outline-hidden', className)}\n {...props}\n >\n {children}\n </RadioPrimitive.Root>\n )\n },\n)\n\nRadioCardControl.displayName = 'RadioCardControl'\n\ntype RadioCardIndicatorProps = RadioCardControlProps\n\n/** The visible dot. Leave it out and the card still picks, with no dot drawn. */\nfunction RadioCardIndicator({ className, ...props }: RadioCardIndicatorProps) {\n const setHasIndicator = React.useContext(RadioCardContext)?.setHasIndicator\n useIsomorphicLayoutEffect(() => {\n if (!setHasIndicator) return undefined\n setHasIndicator(true)\n return () => setHasIndicator(false)\n }, [setHasIndicator])\n return (\n <RadioCardControl\n className={cn(\n // fixed 24px so the target holds at any text scaling (2.5.8)\n 'col-start-1 row-start-1 inline-flex size-[24px] shrink-0 cursor-pointer items-center justify-center rounded-full border-2 p-0 transition-colors motion-reduce:transition-none',\n 'border-(--spark-style-idle-border,var(--color-accent-ui)) bg-base-accent-soft',\n 'data-checked:border-(--spark-radio-ring,var(--spark-9)) data-disabled:cursor-not-allowed',\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator\n data-slot=\"radio-card-indicator\"\n className=\"flex items-center justify-center\"\n >\n <span className=\"size-[14px] rounded-full bg-(--spark-radio-dot,var(--spark-9)) motion-safe:animate-dot-pop\" />\n </RadioPrimitive.Indicator>\n </RadioCardControl>\n )\n}\n\ntype RadioCardLabelProps = React.ComponentProps<'span'>\n\nfunction RadioCardLabel({ id, className, ...props }: RadioCardLabelProps) {\n return (\n <span\n data-slot=\"radio-card-label\"\n id={usePartId(id, 'setLabelId')}\n className={cn('col-start-2 row-start-1 min-w-0', className)}\n {...props}\n />\n )\n}\n\ntype RadioCardDescriptionProps = React.ComponentProps<'span'>\n\nfunction RadioCardDescription({\n id,\n className,\n ...props\n}: RadioCardDescriptionProps) {\n return (\n <span\n data-slot=\"radio-card-description\"\n id={usePartId(id, 'setDescriptionId')}\n className={cn(\n 'col-start-2 mt-0.5 min-w-0 text-sm font-normal text-gray-light',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n RadioCard,\n RadioCardDescription,\n RadioCardGroup,\n RadioCardIndicator,\n RadioCardLabel,\n}\nexport type {\n RadioCardDescriptionProps,\n RadioCardGroupProps,\n RadioCardIndicatorProps,\n RadioCardLabelProps,\n RadioCardProps,\n}\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,iBAAiBA,QAAM,YAC1B,EAAE,MAAM,GAAG,WAAW,OAAO,eAAe,GAAG,SAAS,QAAQ;CAC/D,MAAM,UAAU,mBAAmB;CACnC,OACE,oBAACC,YAAD;EACO;EAEH;EAIF,aAAU;EACV,iBAAe,MAAM,YAAY,KAAA;EACjC,gBAAc;EACd,WAAW,GACT,gHACA,SACF;EACA,OACE;GACE,gCAAgC;GAChC,GAAG;EACL;EAEF,GAAI;CACL,CAAA;AAEL,CACF;AAEA,eAAe,cAAc;AAiB7B,MAAM,mBAAmBD,QAAM,cAA4C,IAAI;AAE/E,MAAM,4BACJ,OAAO,WAAW,cAAcA,QAAM,YAAYA,QAAM;AAE1D,SAAS,UACP,QACA,UACA;CACA,MAAM,UAAUA,QAAM,WAAW,gBAAgB;CACjD,MAAM,cAAcA,QAAM,MAAM;CAChC,MAAM,KAAK,UAAU;CACrB,MAAM,QAAQ,UAAU;CACxB,gCAAgC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,OACE,oBAAC,QAAD;EACE,aAAU;EACV,IAAI,UAAU,IAAI,kBAAkB;EACpC,WAAW,GACT,kEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { cn } from "../utils/cn.js";
3
2
  import { accentByColor } from "../lib/accent-colors.js";
3
+ import { cn } from "../utils/cn.js";
4
4
  import { useFieldSetInvalid } from "./field.js";
5
5
  import { selectionListClasses } from "../lib/selection-list.js";
6
6
  import "react";
@@ -28,7 +28,7 @@ function SelectValue({ ...props }) {
28
28
  }
29
29
  const TRIGGER_BASE = "relative flex items-center justify-between gap-1.5 rounded-md px-3 text-base whitespace-nowrap text-gray transition-colors select-none data-placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:data-placeholder:text-gray-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4";
30
30
  const TRIGGER_SIZE = {
31
- default: "h-11 min-h-[2.75rem]",
31
+ default: "h-11",
32
32
  sm: "my-1 h-9 before:absolute before:inset-x-0 before:top-1/2 before:min-h-[2.75rem] before:-translate-y-1/2 before:content-['']"
33
33
  };
34
34
  function labelledByField(field, ariaLabel, ariaLabelledBy) {
@@ -50,7 +50,7 @@ function SelectTrigger({ className, size = "default", variant, id: idProp, child
50
50
  "data-floating-control": floating || void 0,
51
51
  "data-size": size,
52
52
  id,
53
- className: (0, cn.cn)(TRIGGER_BASE, field ? "w-full" : "w-fit", !isGhost && TRIGGER_SIZE[size], require_lib_input_box_variants.boxChrome[isGhost ? "ghost" : inputStyle][inputColor], inset && "focus-visible:outline-hidden", floating && (0, cn.cn)(require_lib_input_box_variants.floatingChrome(inputStyle), inputStyle !== "outlined" && "[&_[data-slot=select-chevron]]:-translate-y-2", "data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder"), className),
53
+ className: (0, cn.cn)(TRIGGER_BASE, field ? "w-full" : "w-fit", !isGhost && TRIGGER_SIZE[size], require_lib_input_box_variants.boxChrome[isGhost ? "ghost" : inputStyle][inputColor], inset && "focus-visible:outline-hidden", floating && (0, cn.cn)(require_lib_input_box_variants.floatingChrome(inputStyle), inputStyle !== "outlined" && "[&_[data-slot=select-chevron]]:-translate-y-2 [&_[data-slot=select-chevron]]:transition-[translate] [&_[data-slot=select-chevron]]:duration-200 [&_[data-slot=select-chevron]]:ease-[cubic-bezier(0,0,0.2,1)] motion-reduce:[&_[data-slot=select-chevron]]:transition-none field-floated:[&_[data-slot=select-chevron]]:translate-y-0 field-unlabeled:[&_[data-slot=select-chevron]]:translate-y-0", "data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder field-unlabeled:data-placeholder:text-gray-placeholder"), className),
54
54
  "aria-invalid": ariaInvalid,
55
55
  "aria-labelledby": ariaLabelledBy,
56
56
  ...props,
@@ -71,10 +71,11 @@ function SelectTriggerGroup({ className, ...props }) {
71
71
  });
72
72
  }
73
73
  function SelectClear({ className, children, onClick, ...props }) {
74
+ const field = require_components_field.useFieldContext();
74
75
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
75
76
  "data-slot": "select-clear",
76
77
  type: "button",
77
- className: (0, cn.cn)(CLEAR_BUTTON, "absolute right-8", className),
78
+ className: (0, cn.cn)(CLEAR_BUTTON, "absolute right-8", field?.labelPosition === "floating" && field.inputStyle !== "outlined" && "transition-[color,translate] duration-200 ease-[cubic-bezier(0,0,0.2,1)] field-floated:translate-y-2 motion-reduce:transition-none", className),
78
79
  onClick: (event) => {
79
80
  onClick?.(event);
80
81
  event.currentTarget.closest("[data-slot=\"select-trigger-group\"]")?.querySelector("[data-slot=\"select-trigger\"]")?.focus();
@@ -1 +1 @@
1
- {"version":3,"file":"select.cjs","names":["SelectPrimitive","useFieldControl","boxChrome","floatingChrome","KeyboardArrowDown","Close","PortalTheme","Check"],"sources":["../../src/components/select.tsx"],"sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { Check, Close, KeyboardArrowDown } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { boxChrome, floatingChrome } from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { useFieldControl } from './field'\nimport { PortalTheme } from './theme'\n\n// bare re-export: Root renders no element and its props are generic over Value\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return (\n <SelectPrimitive.Group\n data-slot=\"select-group\"\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nconst TRIGGER_BASE =\n 'relative flex items-center justify-between gap-1.5 rounded-md px-3 text-base whitespace-nowrap text-gray transition-colors select-none data-placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:data-placeholder:text-gray-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4'\n\n// box-chrome sizing only — a ghost/inset trigger sizes via boxChrome.ghost's\n// GHOST_UNDERLINE (h-10), matching Input's underline row exactly (no competing\n// height utility). `min-h-[2.75rem]` is a literal, non-knob-scaled WCAG 2.5.5\n// floor; `sm` stays visually compact but restores the floor via an invisible\n// `before:` hit overlay rather than growing the box, with `my-1` to keep that\n// overlay out of an ancestor scroller's overflow.\nconst TRIGGER_SIZE = {\n default: 'h-11 min-h-[2.75rem]',\n sm: \"my-1 h-9 before:absolute before:inset-x-0 before:top-1/2 before:min-h-[2.75rem] before:-translate-y-1/2 before:content-['']\",\n} as const\n\n// a combobox takes no name from label[for] in every engine, so name it from the FieldLabel\nfunction labelledByField(\n field: ReturnType<typeof useFieldControl>['field'],\n ariaLabel: string | undefined,\n ariaLabelledBy: string | undefined,\n) {\n if (ariaLabelledBy || ariaLabel || !field?.hasLabel) return ariaLabelledBy\n return field.labelId\n}\n\nfunction SelectTrigger({\n className,\n size = 'default',\n variant,\n id: idProp,\n children,\n 'aria-describedby': ariaDescribedByProp,\n 'aria-labelledby': ariaLabelledByProp,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: 'sm' | 'default'\n // input-style override; falls back to Field / <Theme>, then soft (like Input)\n variant?: SparkInputStyle\n}) {\n const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } =\n useFieldControl({\n id: idProp,\n ariaDescribedBy: ariaDescribedByProp,\n variant,\n })\n // inside an inset field the shell is the box, so the trigger goes bare\n // (underline row), matching Input's inset chrome; an explicit variant keeps\n // the box even inside an inset field (mirrors Input)\n const inset = !variant && field?.labelPosition === 'inset'\n const isGhost = inputStyle === 'ghost' || inset\n const floating = !variant && field?.labelPosition === 'floating'\n const ariaLabelledBy = labelledByField(\n field,\n props['aria-label'],\n ariaLabelledByProp,\n )\n\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-floating-control={floating || undefined}\n data-size={size}\n id={id}\n className={cn(\n TRIGGER_BASE,\n // fills the field shell like an Input; sizes to content when standalone\n field ? 'w-full' : 'w-fit',\n !isGhost && TRIGGER_SIZE[size],\n boxChrome[isGhost ? 'ghost' : inputStyle][inputColor],\n inset && 'focus-visible:outline-hidden',\n floating &&\n cn(\n floatingChrome(inputStyle),\n inputStyle !== 'outlined' &&\n '[&_[data-slot=select-chevron]]:-translate-y-2',\n 'data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder',\n ),\n className,\n )}\n aria-invalid={ariaInvalid}\n aria-labelledby={ariaLabelledBy}\n {...props}\n aria-describedby={ariaDescribedBy}\n >\n {children}\n <SelectPrimitive.Icon\n className=\"pointer-events-none flex text-gray-light\"\n data-slot=\"select-chevron\"\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\n// px floor: axe target-size flags it below 24px at small scalings because it overlays\n// the trigger; autocomplete.tsx ICON_BUTTON sits in flow and does not need one\nconst CLEAR_BUTTON =\n \"relative inline-flex size-6 min-h-[24px] min-w-[24px] shrink-0 items-center justify-center rounded-sm p-0 text-gray-light transition-colors hover:text-gray disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n\n// wraps SelectTrigger since Base UI ships no Select.Clear and the trigger is a\n// native <button> — the clear sits beside it, not nested inside it\nfunction SelectTriggerGroup({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"select-trigger-group\"\n className={cn(\n 'relative inline-flex w-fit items-center [&_[data-slot=select-chevron]]:absolute [&_[data-slot=select-chevron]]:right-3 has-[[data-slot=select-trigger][data-disabled]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-placeholder]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-readonly]]:[&_[data-slot=select-clear]]:hidden [&_[data-slot=select-trigger]]:pr-[calc(--spacing(8)+max(--spacing(6),24px))]',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectClear({\n className,\n children,\n onClick,\n ...props\n}: React.ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"select-clear\"\n type=\"button\"\n className={cn(CLEAR_BUTTON, 'absolute right-8', className)}\n onClick={(event) => {\n onClick?.(event)\n // clearing hides this button (data-placeholder returns), so keyboard\n // focus would otherwise drop to <body> — return it to the trigger\n event.currentTarget\n .closest('[data-slot=\"select-trigger-group\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"select-trigger\"]')\n ?.focus()\n }}\n {...props}\n >\n {children ?? <Close aria-hidden className=\"[--spark-icon-size:14px]\" />}\n </button>\n )\n}\n\ntype SelectContentProps = React.ComponentProps<typeof SelectPrimitive.Popup> &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n > &\n Pick<SelectPrimitive.Portal.Props, 'container'>\n\nfunction SelectContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n // drop the menu below the trigger (left-aligned) like a conventional form\n // dropdown; the native-<select>-style overlay (Base UI's inherited default)\n // shifts the popup to align item text with trigger text, exposing a sliver of\n // the trigger's fill at the edge. Opt back in per instance if you want it.\n alignItemWithTrigger = false,\n container,\n ...props\n}: SelectContentProps) {\n return (\n <SelectPrimitive.Portal container={container}>\n <PortalTheme>\n <SelectPrimitive.Positioner\n align={align}\n alignItemWithTrigger={alignItemWithTrigger}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className=\"isolate z-50\"\n >\n <SelectPrimitive.Popup\n data-slot=\"select-content\"\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n // match the trigger's width (never narrower) so the drop-below menu\n // lines up under it; --anchor-width is the trigger width, floored at\n // 9rem for very narrow triggers\n 'relative isolate max-h-(--available-height) min-w-[max(9rem,var(--anchor-width))] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-gray-a1 bg-gray-1 text-gray-a12 shadow-lg dark:bg-gray-3 [[data-high-contrast]_&]:border-gray-a11',\n 'transition-[opacity,scale,translate] duration-100 ease-enter data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none',\n 'data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2',\n 'data-[align-trigger=true]:transition-none',\n className,\n )}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalTheme>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot=\"select-label\"\n className={cn(\n 'px-1.5 py-1 text-xs text-gray-light [[data-high-contrast]_&]:text-gray-a12',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm py-1.5 pr-8 pl-1.5 text-sm text-gray outline-hidden transition-colors select-none touch-target-row data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-gray-a3 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2',\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute right-2 flex size-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"[--spark-icon-size:11px]\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\n// plain div, not Select.Separator: role=\"separator\" isn't a permitted child of a\n// listbox (aria-required-children), and the divider is decorative — the groups\n// carry the semantics. Hidden from assistive tech.\nfunction SelectSeparator({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"select-separator\"\n className={cn(\n 'pointer-events-none -mx-1 my-1 h-px bg-gray-a3 [[data-high-contrast]_&]:bg-gray-a6',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot=\"select-scroll-up-button\"\n className={cn(\n 'top-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"rotate-180 [--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot=\"select-scroll-down-button\"\n className={cn(\n 'bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectClear,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectTriggerGroup,\n SelectValue,\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,SAASA,sBAAAA,OAAgB;AAE/B,SAAS,YAAY,EACnB,WACA,GAAG,SACkD;CACrD,OACE,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,OAAjB;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IAAc,mBAAmB,SAAS;EAC1C,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,YAAY,EACnB,GAAG,SACkD;CACrD,OAAO,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAA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AA,IACE,yIACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACI,oBAAAA,mBAAD,EAAmB,WAAU,2BAA4B,CAAA;CAC1B,CAAA;AAErC"}
1
+ {"version":3,"file":"select.cjs","names":["SelectPrimitive","useFieldControl","boxChrome","floatingChrome","KeyboardArrowDown","useFieldContext","Close","PortalTheme","Check"],"sources":["../../src/components/select.tsx"],"sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { Check, Close, KeyboardArrowDown } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport {\n boxChrome,\n FLOATING_BUTTON_SHIFT,\n floatingChrome,\n} from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { useFieldContext, useFieldControl } from './field'\nimport { PortalTheme } from './theme'\n\n// bare re-export: Root renders no element and its props are generic over Value\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return (\n <SelectPrimitive.Group\n data-slot=\"select-group\"\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nconst TRIGGER_BASE =\n 'relative flex items-center justify-between gap-1.5 rounded-md px-3 text-base whitespace-nowrap text-gray transition-colors select-none data-placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:data-placeholder:text-gray-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4'\n\n// box-chrome sizing only — a ghost/inset trigger sizes via boxChrome.ghost's\n// GHOST_UNDERLINE (h-10), matching Input's underline row exactly (no competing\n// height utility). `default` scales with the theme like Input; `sm` stays\n// visually compact but keeps a 44px hit area via an invisible `before:`\n// overlay rather than growing the box, with `my-1` to keep that overlay out of\n// an ancestor scroller's overflow.\nconst TRIGGER_SIZE = {\n default: 'h-11',\n sm: \"my-1 h-9 before:absolute before:inset-x-0 before:top-1/2 before:min-h-[2.75rem] before:-translate-y-1/2 before:content-['']\",\n} as const\n\n// a combobox takes no name from label[for] in every engine, so name it from the FieldLabel\nfunction labelledByField(\n field: ReturnType<typeof useFieldControl>['field'],\n ariaLabel: string | undefined,\n ariaLabelledBy: string | undefined,\n) {\n if (ariaLabelledBy || ariaLabel || !field?.hasLabel) return ariaLabelledBy\n return field.labelId\n}\n\nfunction SelectTrigger({\n className,\n size = 'default',\n variant,\n id: idProp,\n children,\n 'aria-describedby': ariaDescribedByProp,\n 'aria-labelledby': ariaLabelledByProp,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: 'sm' | 'default'\n // input-style override; falls back to Field / <Theme>, then soft (like Input)\n variant?: SparkInputStyle\n}) {\n const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } =\n useFieldControl({\n id: idProp,\n ariaDescribedBy: ariaDescribedByProp,\n variant,\n })\n // inside an inset field the shell is the box, so the trigger goes bare\n // (underline row), matching Input's inset chrome; an explicit variant keeps\n // the box even inside an inset field (mirrors Input)\n const inset = !variant && field?.labelPosition === 'inset'\n const isGhost = inputStyle === 'ghost' || inset\n const floating = !variant && field?.labelPosition === 'floating'\n const ariaLabelledBy = labelledByField(\n field,\n props['aria-label'],\n ariaLabelledByProp,\n )\n\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-floating-control={floating || undefined}\n data-size={size}\n id={id}\n className={cn(\n TRIGGER_BASE,\n // fills the field shell like an Input; sizes to content when standalone\n field ? 'w-full' : 'w-fit',\n !isGhost && TRIGGER_SIZE[size],\n boxChrome[isGhost ? 'ghost' : inputStyle][inputColor],\n inset && 'focus-visible:outline-hidden',\n floating &&\n cn(\n floatingChrome(inputStyle),\n inputStyle !== 'outlined' &&\n '[&_[data-slot=select-chevron]]:-translate-y-2 [&_[data-slot=select-chevron]]:transition-[translate] [&_[data-slot=select-chevron]]:duration-200 [&_[data-slot=select-chevron]]:ease-[cubic-bezier(0,0,0.2,1)] motion-reduce:[&_[data-slot=select-chevron]]:transition-none field-floated:[&_[data-slot=select-chevron]]:translate-y-0 field-unlabeled:[&_[data-slot=select-chevron]]:translate-y-0',\n 'data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder field-unlabeled:data-placeholder:text-gray-placeholder',\n ),\n className,\n )}\n aria-invalid={ariaInvalid}\n aria-labelledby={ariaLabelledBy}\n {...props}\n aria-describedby={ariaDescribedBy}\n >\n {children}\n <SelectPrimitive.Icon\n className=\"pointer-events-none flex text-gray-light\"\n data-slot=\"select-chevron\"\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\n// px floor: axe target-size flags it below 24px at small scalings because it overlays\n// the trigger; autocomplete.tsx ICON_BUTTON sits in flow and does not need one\nconst CLEAR_BUTTON =\n \"relative inline-flex size-6 min-h-[24px] min-w-[24px] shrink-0 items-center justify-center rounded-sm p-0 text-gray-light transition-colors hover:text-gray disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n\n// wraps SelectTrigger since Base UI ships no Select.Clear and the trigger is a\n// native <button> — the clear sits beside it, not nested inside it\nfunction SelectTriggerGroup({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"select-trigger-group\"\n className={cn(\n 'relative inline-flex w-fit items-center [&_[data-slot=select-chevron]]:absolute [&_[data-slot=select-chevron]]:right-3 has-[[data-slot=select-trigger][data-disabled]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-placeholder]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-readonly]]:[&_[data-slot=select-clear]]:hidden [&_[data-slot=select-trigger]]:pr-[calc(--spacing(8)+max(--spacing(6),24px))]',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectClear({\n className,\n children,\n onClick,\n ...props\n}: React.ComponentProps<'button'>) {\n const field = useFieldContext()\n return (\n <button\n data-slot=\"select-clear\"\n type=\"button\"\n className={cn(\n CLEAR_BUTTON,\n 'absolute right-8',\n field?.labelPosition === 'floating' &&\n field.inputStyle !== 'outlined' &&\n FLOATING_BUTTON_SHIFT,\n className,\n )}\n onClick={(event) => {\n onClick?.(event)\n // clearing hides this button (data-placeholder returns), so keyboard\n // focus would otherwise drop to <body> — return it to the trigger\n event.currentTarget\n .closest('[data-slot=\"select-trigger-group\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"select-trigger\"]')\n ?.focus()\n }}\n {...props}\n >\n {children ?? <Close aria-hidden className=\"[--spark-icon-size:14px]\" />}\n </button>\n )\n}\n\ntype SelectContentProps = React.ComponentProps<typeof SelectPrimitive.Popup> &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n > &\n Pick<SelectPrimitive.Portal.Props, 'container'>\n\nfunction SelectContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n // drop the menu below the trigger (left-aligned) like a conventional form\n // dropdown; the native-<select>-style overlay (Base UI's inherited default)\n // shifts the popup to align item text with trigger text, exposing a sliver of\n // the trigger's fill at the edge. Opt back in per instance if you want it.\n alignItemWithTrigger = false,\n container,\n ...props\n}: SelectContentProps) {\n return (\n <SelectPrimitive.Portal container={container}>\n <PortalTheme>\n <SelectPrimitive.Positioner\n align={align}\n alignItemWithTrigger={alignItemWithTrigger}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className=\"isolate z-50\"\n >\n <SelectPrimitive.Popup\n data-slot=\"select-content\"\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n // match the trigger's width (never narrower) so the drop-below menu\n // lines up under it; --anchor-width is the trigger width, floored at\n // 9rem for very narrow triggers\n 'relative isolate max-h-(--available-height) min-w-[max(9rem,var(--anchor-width))] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-gray-a1 bg-gray-1 text-gray-a12 shadow-lg dark:bg-gray-3 [[data-high-contrast]_&]:border-gray-a11',\n 'transition-[opacity,scale,translate] duration-100 ease-enter data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none',\n 'data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2',\n 'data-[align-trigger=true]:transition-none',\n className,\n )}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalTheme>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot=\"select-label\"\n className={cn(\n 'px-1.5 py-1 text-xs text-gray-light [[data-high-contrast]_&]:text-gray-a12',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm py-1.5 pr-8 pl-1.5 text-sm text-gray outline-hidden transition-colors select-none touch-target-row data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-gray-a3 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2',\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute right-2 flex size-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"[--spark-icon-size:11px]\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\n// plain div, not Select.Separator: role=\"separator\" isn't a permitted child of a\n// listbox (aria-required-children), and the divider is decorative — the groups\n// carry the semantics. Hidden from assistive tech.\nfunction SelectSeparator({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"select-separator\"\n className={cn(\n 'pointer-events-none -mx-1 my-1 h-px bg-gray-a3 [[data-high-contrast]_&]:bg-gray-a6',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot=\"select-scroll-up-button\"\n className={cn(\n 'top-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"rotate-180 [--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot=\"select-scroll-down-button\"\n className={cn(\n 'bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectClear,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectTriggerGroup,\n SelectValue,\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,SAASA,sBAAAA,OAAgB;AAE/B,SAAS,YAAY,EACnB,WACA,GAAG,SACkD;CACrD,OACE,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,OAAjB;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IAAc,mBAAmB,SAAS;EAC1C,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,YAAY,EACnB,GAAG,SACkD;CACrD,OAAO,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,OAAjB;EAAuB,aAAU;EAAe,GAAI;CAAQ,CAAA;AACrE;AAEA,MAAM,eACJ;AAQF,MAAM,eAAe;CACnB,SAAS;CACT,IAAI;AACN;AAGA,SAAS,gBACP,OACA,WACA,gBACA;CACA,IAAI,kBAAkB,aAAa,CAAC,OAAO,UAAU,OAAO;CAC5D,OAAO,MAAM;AACf;AAEA,SAAS,cAAc,EACrB,WACA,OAAO,WACP,SACA,IAAI,QACJ,UACA,oBAAoB,qBACpB,mBAAmB,oBACnB,GAAG,SAKF;CACD,MAAM,EAAE,OAAO,IAAI,iBAAiB,aAAa,YAAY,eAC3DC,yBAAAA,gBAAgB;EACd,IAAI;EACJ,iBAAiB;EACjB;CACF,CAAC;CAIH,MAAM,QAAQ,CAAC,WAAW,OAAO,kBAAkB;CACnD,MAAM,UAAU,eAAe,WAAW;CAC1C,MAAM,WAAW,CAAC,WAAW,OAAO,kBAAkB;CACtD,MAAM,iBAAiB,gBACrB,OACA,MAAM,eACN,kBACF;CAEA,OACE,iBAAA,GAAA,kBAAA,MAACD,sBAAAA,OAAgB,SAAjB;EACE,aAAU;EACV,yBAAuB,YAAY,KAAA;EACnC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;AAE1B;AAKA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAsC;CAC7E,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,eAAY;EACZ,aAAU;EACV,YAAA,GAAA,GAAA,IACE,sFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,qBAAqB,EAC5B,WACA,GAAG,SAC0D;CAC7D,OACE,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,eAAjB;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IACE,sIACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACI,oBAAAA,mBAAD,EAAmB,WAAU,sCAAuC,CAAA;CACvC,CAAA;AAEnC;AAEA,SAAS,uBAAuB,EAC9B,WACA,GAAG,SAC4D;CAC/D,OACE,iBAAA,GAAA,kBAAA,KAACJ,sBAAAA,OAAgB,iBAAjB;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IACE,yIACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACI,oBAAAA,mBAAD,EAAmB,WAAU,2BAA4B,CAAA;CAC1B,CAAA;AAErC"}
@@ -3,7 +3,7 @@
3
3
  import { cn } from "../utils/cn.js";
4
4
  import { PortalTheme } from "./theme.js";
5
5
  import { boxChrome, floatingChrome } from "../lib/input-box-variants.js";
6
- import { useFieldControl } from "./field.js";
6
+ import { useFieldContext, useFieldControl } from "./field.js";
7
7
  import "react";
8
8
  import { Check, Close, KeyboardArrowDown } from "@epilot/spark-icons";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -25,7 +25,7 @@ function SelectValue({ ...props }) {
25
25
  }
26
26
  const TRIGGER_BASE = "relative flex items-center justify-between gap-1.5 rounded-md px-3 text-base whitespace-nowrap text-gray transition-colors select-none data-placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:data-placeholder:text-gray-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4";
27
27
  const TRIGGER_SIZE = {
28
- default: "h-11 min-h-[2.75rem]",
28
+ default: "h-11",
29
29
  sm: "my-1 h-9 before:absolute before:inset-x-0 before:top-1/2 before:min-h-[2.75rem] before:-translate-y-1/2 before:content-['']"
30
30
  };
31
31
  function labelledByField(field, ariaLabel, ariaLabelledBy) {
@@ -47,7 +47,7 @@ function SelectTrigger({ className, size = "default", variant, id: idProp, child
47
47
  "data-floating-control": floating || void 0,
48
48
  "data-size": size,
49
49
  id,
50
- className: cn(TRIGGER_BASE, field ? "w-full" : "w-fit", !isGhost && TRIGGER_SIZE[size], boxChrome[isGhost ? "ghost" : inputStyle][inputColor], inset && "focus-visible:outline-hidden", floating && cn(floatingChrome(inputStyle), inputStyle !== "outlined" && "[&_[data-slot=select-chevron]]:-translate-y-2", "data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder"), className),
50
+ className: cn(TRIGGER_BASE, field ? "w-full" : "w-fit", !isGhost && TRIGGER_SIZE[size], boxChrome[isGhost ? "ghost" : inputStyle][inputColor], inset && "focus-visible:outline-hidden", floating && cn(floatingChrome(inputStyle), inputStyle !== "outlined" && "[&_[data-slot=select-chevron]]:-translate-y-2 [&_[data-slot=select-chevron]]:transition-[translate] [&_[data-slot=select-chevron]]:duration-200 [&_[data-slot=select-chevron]]:ease-[cubic-bezier(0,0,0.2,1)] motion-reduce:[&_[data-slot=select-chevron]]:transition-none field-floated:[&_[data-slot=select-chevron]]:translate-y-0 field-unlabeled:[&_[data-slot=select-chevron]]:translate-y-0", "data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder field-unlabeled:data-placeholder:text-gray-placeholder"), className),
51
51
  "aria-invalid": ariaInvalid,
52
52
  "aria-labelledby": ariaLabelledBy,
53
53
  ...props,
@@ -68,10 +68,11 @@ function SelectTriggerGroup({ className, ...props }) {
68
68
  });
69
69
  }
70
70
  function SelectClear({ className, children, onClick, ...props }) {
71
+ const field = useFieldContext();
71
72
  return /* @__PURE__ */ jsx("button", {
72
73
  "data-slot": "select-clear",
73
74
  type: "button",
74
- className: cn(CLEAR_BUTTON, "absolute right-8", className),
75
+ className: cn(CLEAR_BUTTON, "absolute right-8", field?.labelPosition === "floating" && field.inputStyle !== "outlined" && "transition-[color,translate] duration-200 ease-[cubic-bezier(0,0,0.2,1)] field-floated:translate-y-2 motion-reduce:transition-none", className),
75
76
  onClick: (event) => {
76
77
  onClick?.(event);
77
78
  event.currentTarget.closest("[data-slot=\"select-trigger-group\"]")?.querySelector("[data-slot=\"select-trigger\"]")?.focus();