@42-central/ui-react 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/{chunk-OVT2KZHY.js → chunk-3KARNPW4.js} +3 -3
  2. package/dist/{chunk-OVT2KZHY.js.map → chunk-3KARNPW4.js.map} +1 -1
  3. package/dist/chunk-6B2GNPJP.js +43 -0
  4. package/dist/chunk-6B2GNPJP.js.map +1 -0
  5. package/dist/{chunk-E52Z2FKU.js → chunk-7BY5I2RB.js} +3 -3
  6. package/dist/{chunk-E52Z2FKU.js.map → chunk-7BY5I2RB.js.map} +1 -1
  7. package/dist/{chunk-X3YIHN2U.js → chunk-ASKQ6N5V.js} +3 -3
  8. package/dist/{chunk-X3YIHN2U.js.map → chunk-ASKQ6N5V.js.map} +1 -1
  9. package/dist/{chunk-6IRMKF5T.js → chunk-B4GNSSHU.js} +4 -4
  10. package/dist/{chunk-6IRMKF5T.js.map → chunk-B4GNSSHU.js.map} +1 -1
  11. package/dist/{chunk-BMEJBY6H.js → chunk-B5YHYI7E.js} +22 -27
  12. package/dist/chunk-B5YHYI7E.js.map +1 -0
  13. package/dist/{chunk-7OGZT7U2.js → chunk-G3AD3NJG.js} +3 -3
  14. package/dist/{chunk-7OGZT7U2.js.map → chunk-G3AD3NJG.js.map} +1 -1
  15. package/dist/{chunk-MNYY7UU2.js → chunk-GJFCIG34.js} +4 -4
  16. package/dist/{chunk-MNYY7UU2.js.map → chunk-GJFCIG34.js.map} +1 -1
  17. package/dist/{chunk-5H5YOPCF.js → chunk-I53TMAV2.js} +5 -5
  18. package/dist/{chunk-5H5YOPCF.js.map → chunk-I53TMAV2.js.map} +1 -1
  19. package/dist/{chunk-MCRTAUSZ.js → chunk-K3FZHYJL.js} +3 -3
  20. package/dist/{chunk-MCRTAUSZ.js.map → chunk-K3FZHYJL.js.map} +1 -1
  21. package/dist/{chunk-ZVECQBGG.js → chunk-KNGSO7A3.js} +41 -13
  22. package/dist/chunk-KNGSO7A3.js.map +1 -0
  23. package/dist/{chunk-4D2V4JE4.js → chunk-KYVXPSNW.js} +3 -3
  24. package/dist/{chunk-4D2V4JE4.js.map → chunk-KYVXPSNW.js.map} +1 -1
  25. package/dist/{chunk-L24N5EON.js → chunk-P7SH3XWY.js} +3 -3
  26. package/dist/{chunk-L24N5EON.js.map → chunk-P7SH3XWY.js.map} +1 -1
  27. package/dist/{chunk-LKFHUDEW.js → chunk-QVOBLRCM.js} +3 -3
  28. package/dist/{chunk-LKFHUDEW.js.map → chunk-QVOBLRCM.js.map} +1 -1
  29. package/dist/{chunk-SCXXJDKQ.js → chunk-SP6LCCTZ.js} +21 -28
  30. package/dist/chunk-SP6LCCTZ.js.map +1 -0
  31. package/dist/{chunk-Y2G47ARQ.js → chunk-TGGNSSOJ.js} +3 -3
  32. package/dist/{chunk-Y2G47ARQ.js.map → chunk-TGGNSSOJ.js.map} +1 -1
  33. package/dist/{chunk-D2QIPQ74.js → chunk-W3XX7BYT.js} +2 -2
  34. package/dist/chunk-W3XX7BYT.js.map +1 -0
  35. package/dist/{chunk-F374BNL4.js → chunk-YVTM2KRR.js} +12 -8
  36. package/dist/chunk-YVTM2KRR.js.map +1 -0
  37. package/dist/colors.css +328 -0
  38. package/dist/components/action-icon/action-icon.d.ts +6 -5
  39. package/dist/components/action-icon/action-icon.d.ts.map +1 -1
  40. package/dist/components/action-icon/index.js +3 -2
  41. package/dist/components/alert/index.js +2 -2
  42. package/dist/components/app-shell/index.js +5 -4
  43. package/dist/components/app-shell/index.js.map +1 -1
  44. package/dist/components/badge/badge.d.ts +1 -1
  45. package/dist/components/badge/badge.d.ts.map +1 -1
  46. package/dist/components/badge/index.js +2 -1
  47. package/dist/components/button/button.d.ts +11 -9
  48. package/dist/components/button/button.d.ts.map +1 -1
  49. package/dist/components/button/index.js +3 -2
  50. package/dist/components/button-multi-select/index.js +4 -3
  51. package/dist/components/button-multi-select/index.js.map +1 -1
  52. package/dist/components/button-select/index.js +4 -3
  53. package/dist/components/button-select/index.js.map +1 -1
  54. package/dist/components/calendar/index.js +4 -3
  55. package/dist/components/camera/index.js +6 -5
  56. package/dist/components/clipboard/index.js +3 -2
  57. package/dist/components/clipboard/index.js.map +1 -1
  58. package/dist/components/data-table/index.js +10 -9
  59. package/dist/components/data-table/index.js.map +1 -1
  60. package/dist/components/date-picker/index.js +7 -6
  61. package/dist/components/date-picker/index.js.map +1 -1
  62. package/dist/components/download-button/index.js +4 -3
  63. package/dist/components/drawer/index.js +5 -4
  64. package/dist/components/file-item/index.js +4 -3
  65. package/dist/components/file-preview/index.js +4 -3
  66. package/dist/components/file-preview/index.js.map +1 -1
  67. package/dist/components/file-trigger/index.js +4 -3
  68. package/dist/components/file-upload/index.js +4 -3
  69. package/dist/components/file-upload/index.js.map +1 -1
  70. package/dist/components/image-cropper/index.js +4 -3
  71. package/dist/components/lightbox/index.js +7 -6
  72. package/dist/components/lightbox/index.js.map +1 -1
  73. package/dist/components/modal/index.js +5 -4
  74. package/dist/components/notification/index.js +3 -3
  75. package/dist/components/overlays/index.js +7 -6
  76. package/dist/components/overlays/index.js.map +1 -1
  77. package/dist/components/photo-capture/index.js +8 -7
  78. package/dist/components/photo-capture/index.js.map +1 -1
  79. package/dist/components/schedule/index.js +4 -3
  80. package/dist/components/schedule/index.js.map +1 -1
  81. package/dist/components/spinner/index.js +1 -1
  82. package/dist/components/spinner/spinner.d.ts +1 -1
  83. package/dist/components/spinner/spinner.d.ts.map +1 -1
  84. package/dist/components/spotlight/index.js +5 -4
  85. package/dist/components/spotlight/index.js.map +1 -1
  86. package/dist/components/theme-icon/index.js +1 -1
  87. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -1
  88. package/dist/lib/button-colors.d.ts +25 -0
  89. package/dist/lib/button-colors.d.ts.map +1 -0
  90. package/package.json +1 -1
  91. package/src/colors.css +328 -0
  92. package/src/components/action-icon/action-icon.test.tsx +22 -0
  93. package/src/components/action-icon/action-icon.tsx +24 -28
  94. package/src/components/badge/badge.test.tsx +53 -10
  95. package/src/components/badge/badge.tsx +64 -11
  96. package/src/components/button/button.test.tsx +41 -5
  97. package/src/components/button/button.tsx +28 -33
  98. package/src/components/spinner/spinner.tsx +3 -3
  99. package/src/components/theme-icon/theme-icon.test.tsx +7 -0
  100. package/src/components/theme-icon/theme-icon.tsx +10 -6
  101. package/src/lib/button-colors.ts +55 -0
  102. package/dist/chunk-BMEJBY6H.js.map +0 -1
  103. package/dist/chunk-D2QIPQ74.js.map +0 -1
  104. package/dist/chunk-F374BNL4.js.map +0 -1
  105. package/dist/chunk-SCXXJDKQ.js.map +0 -1
  106. package/dist/chunk-ZVECQBGG.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/download-button/download-button.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,IAAM,oCAAA,GAA6E;AAAA,EACxF,KAAA,EAAO,UAAA;AAAA,EACP,OAAA,EAAS,0BAAA;AAAA,EACT,OAAO,CAAC,IAAA,KAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,uBAAA,CAAA,GAA4B;AAC9D;AAIA,IAAM,aAAA,GAA2D;AAAA,EAC/D,QAAA,kBAAU,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,UAAA,EAAY;AAC7C,CAAA;AAuBA,IAAM,YAAA,GACJ,2FAAA;AAGF,IAAM,OAAA,GAAU,CAAC,IAAA,EAAsB,MAAA,KAA+C;AACpF,EAAA,IAAI;AACF,IAAA,OAAO,QAAQ,OAAA,CAAQ,IAAA,CAAK,EAAE,MAAA,EAAQ,CAAC,CAAA;AAAA,EACzC,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,OAAA,CAAQ,OAAO,KAAK,CAAA;AAAA,EAC7B;AACF,CAAA;AAEO,IAAM,iBAAiB,CAAC;AAAA,EAC7B,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,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AAA;AAAA;AAAA;AAAA;AAAA,sBAIC,GAAA;AAAA,QAAC,GAAA,CAAI,MAAA;AAAA,QAAJ;AAAA,UACC,OAAA,EAAO,IAAA;AAAA,UACP,QAAA;AAAA,UACC,GAAG,KAAA,CAAM,EAAE,eAAA,EAAiB,UAAU,CAAA;AAAA,UACvC,SAAA;AAAA,UACC,GAAG,OAAA;AAAA,UAEH,QAAA,EAAA,kBAAA,CAAmB,QAAA,EAAU,CAAC,GAAA,KAAS,IAAA,mBAAO,GAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAO,CAAA,CAAE,OAAA,EAAS,CAAA,GAAK,GAAI;AAAA;AAAA;AACrF,wBAEA,IAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA;AAAA,QACA,WAAW,IAAA,mBAAO,GAAA,CAAC,WAAQ,KAAA,EAAO,IAAA,EAAM,IAAK,IAAA,CAAK,QAAA;AAAA,QAClD,OAAA;AAAA,QACA,QAAA;AAAA,QAEA,SAAA,EAAW,EAAA,CAAG,UAAA,EAAY,SAAS,CAAA;AAAA,QAClC,GAAG,OAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,QAAA,IAAY,CAAA,CAAE,KAAA;AAAA,UACd,wBAAQ,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAW,YAAE,OAAA,EAAQ;AAAA;AAAA;AAAA,KAChD;AAAA,oBAEF,GAAA,CAAC,MAAA,EAAA,EAAK,IAAA,EAAK,QAAA,EAAS,SAAA,EAAW,cAAc,YAAA,EAAW,iBAAA,EAAkB,WAAA,EAAU,QAAA,EACjF,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-6IRMKF5T.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react\"\nimport { Download } from \"lucide-react\"\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { props } from \"../../lib/props\"\nimport { saveFile } from \"../../lib/save-file\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * DownloadButton — a button that saves a file: a Blob you already have, a\n * URL, or whatever a function of yours resolves to (an authenticated fetch,\n * a presign call, a generated CSV). The kit makes no request itself.\n *\n * - **While a function's promise is pending** the button is busy: a\n * spinner, `aria-busy`, and re-clicks are ignored, so a double click\n * saves one file. It stays enabled and focused, unlike Button's\n * `loading`, which sets `disabled` and drops keyboard focus.\n * - **On failure**, a polite status region says so (`translations.error`)\n * and `onError` gets the error. Nothing is announced on success: the\n * browser's own download UI is the feedback.\n * - **Unmounting mid-fetch** aborts: the function's `signal` fires and\n * nothing is saved afterwards.\n * - Renders a kit `Button` by default. With `asChild`, only the behaviour\n * goes onto your element (an `ActionIcon` in a row's actions), and its\n * content is swapped for the spinner while busy.\n *\n * Built on `saveFile` (`lib/save-file.ts`) rather than Ark's\n * `DownloadTrigger`: Ark's trigger has no pending state, drops a rejected\n * promise, can't be aborted, and reads a string as the file's *contents*\n * rather than a URL.\n *\n * ```tsx\n * <DownloadButton\n * name=\"transcript.pdf\"\n * data={({ signal }) => api.get(`/transcripts/${id}`, { signal }).then((r) => r.blob())}\n * onError={() => notify.error(\"Couldn't download the transcript\")}\n * />\n * ```\n */\n\n/** What can be saved: a Blob (or File), or a URL. */\nexport type DownloadData = Blob | string\n\n/** Resolves the file on click. `signal` aborts when the button unmounts first. */\nexport type DownloadLoader = (context: {\n signal: AbortSignal\n}) => DownloadData | Promise<DownloadData>\n\n/** What `data` takes: the value itself, or a function that resolves it on click. */\nexport type DownloadSource = DownloadData | DownloadLoader\n\nexport type DownloadButtonTranslations = {\n /** The default label, when there are no `children`. @default \"Download\" */\n label?: string\n /** Added to the button's name while `data` is resolving. @default \"Preparing download…\" */\n loading?: string\n /** What the status region says when the download fails.\n * @default (name) => name ? `${name} couldn't be downloaded` : \"The download failed\" */\n error?: (name: string | undefined) => string\n}\n\nexport const DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS: Required<DownloadButtonTranslations> = {\n label: \"Download\",\n loading: \"Preparing download…\",\n error: (name) => (name ? `${name} couldn't be downloaded` : \"The download failed\"),\n}\n\nexport type DownloadButtonIconSlot = \"download\"\n\nconst DEFAULT_ICONS: Record<DownloadButtonIconSlot, ReactNode> = {\n download: <Download className={iconStroke} />,\n}\n\nexport type DownloadButtonProps = Omit<\n ButtonProps,\n \"type\" | \"name\" | \"loading\" | \"startSlot\" | \"onError\"\n> & {\n /** The file: a Blob, a URL, or a function resolving one on click (passed an abort `signal`). */\n data: DownloadSource\n /** The file name. Ignored by browsers for a cross-origin URL; see `saveFile`. */\n name?: string\n /** The MIME type, for a Blob without one. */\n type?: string\n /** Fires when `data` rejects or the save throws. */\n onError?: (error: unknown) => void\n /** Fires once the file has been handed to the browser. */\n onDone?: () => void\n translations?: DownloadButtonTranslations\n /** `download`, the leading icon. `null` renders none. Not shown under `asChild`. */\n icons?: IconMap<DownloadButtonIconSlot>\n}\n\n/** Tailwind's `sr-only`, fixed rather than absolute: it is rendered beside the\n * button, outside any box of ours, and a fixed box can't stretch a scroller. */\nconst statusRegion =\n \"fixed size-px -m-px p-0 overflow-hidden whitespace-nowrap border-0 [clip-path:inset(50%)]\"\n\n/** Calls the loader now, inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: DownloadLoader, signal: AbortSignal): Promise<DownloadData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nexport const DownloadButton = ({\n data,\n name,\n type,\n onError,\n onDone,\n translations,\n icons,\n asChild,\n children,\n testId,\n onClick,\n variant,\n size,\n color,\n endSlot,\n disabled,\n className,\n ...rest\n}: DownloadButtonProps) => {\n const t = { ...DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, ...translations }\n const icon = mergeIcons(DEFAULT_ICONS, icons)\n const [busy, setBusy] = useState(false)\n const [failure, setFailure] = useState(\"\")\n // The run in flight, if any: the re-click guard and the unmount abort. A\n // ref, so two clicks in one frame can't both read a stale `busy`.\n const running = useRef<AbortController | null>(null)\n\n useEffect(() => () => running.current?.abort(), [])\n\n const fail = (error: unknown) => {\n setFailure(t.error(name))\n onError?.(error)\n }\n\n // `onDone` sits outside the try, so a throw in the caller's own callback\n // isn't announced as a failed download.\n const save = (value: DownloadData) => {\n try {\n saveFile(value, name, { type })\n } catch (error) {\n return fail(error)\n }\n onDone?.()\n }\n\n const resolve = async (load: DownloadLoader) => {\n const controller = new AbortController()\n running.current = controller\n setBusy(true)\n const outcome = await started(load, controller.signal).then(\n (value) => ({ value }),\n (error: unknown) => ({ error }),\n )\n running.current = null\n // Unmounted meanwhile: nothing to save, and no state left to update.\n if (controller.signal.aborted) return\n setBusy(false)\n if (\"error\" in outcome) fail(outcome.error)\n else save(outcome.value)\n }\n\n // `onClick` runs first, so a caller can `preventDefault()` to stop the save\n // (a confirm step). A value is saved inside the click itself; a function's\n // promise is awaited, and the save follows when it settles.\n const download = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled || running.current) return\n // An `asChild` link would also follow its own href.\n event.preventDefault()\n setFailure(\"\")\n if (typeof data === \"function\") void resolve(data)\n else save(data)\n }\n\n const trigger = {\n \"data-scope\": \"download-button\",\n \"data-part\": \"trigger\",\n onClick: download,\n ...props({\n \"aria-busy\": busy,\n \"data-loading\": busy,\n \"data-testid\": testId,\n \"data-disabled\": disabled,\n }),\n ...rest,\n }\n\n return (\n <>\n {asChild ? (\n // Only behaviour is merged onto the child: Button's styling would\n // fight an ActionIcon's own. While busy the spinner stands in for the\n // child's content (its icon); its name stays the child's own label.\n <ark.button\n asChild\n disabled={disabled}\n {...props({ \"aria-disabled\": disabled })}\n className={className}\n {...trigger}\n >\n {withAsChildContent(children, (own) => (busy ? <Spinner label={t.loading} /> : own))}\n </ark.button>\n ) : (\n <Button\n variant={variant}\n size={size}\n color={color}\n startSlot={busy ? <Spinner label={null} /> : icon.download}\n endSlot={endSlot}\n disabled={disabled}\n // `relative` holds the sr-only loading text inside the button.\n className={cn(\"relative\", className)}\n {...trigger}\n >\n {children ?? t.label}\n {busy && <span className=\"sr-only\">{t.loading}</span>}\n </Button>\n )}\n <span role=\"status\" className={statusRegion} data-scope=\"download-button\" data-part=\"status\">\n {failure}\n </span>\n </>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/components/download-button/download-button.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAkEO,IAAM,oCAAA,GAA6E;AAAA,EACxF,KAAA,EAAO,UAAA;AAAA,EACP,OAAA,EAAS,0BAAA;AAAA,EACT,OAAO,CAAC,IAAA,KAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,uBAAA,CAAA,GAA4B;AAC9D;AAIA,IAAM,aAAA,GAA2D;AAAA,EAC/D,QAAA,kBAAU,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAW,UAAA,EAAY;AAC7C,CAAA;AAuBA,IAAM,YAAA,GACJ,2FAAA;AAGF,IAAM,OAAA,GAAU,CAAC,IAAA,EAAsB,MAAA,KAA+C;AACpF,EAAA,IAAI;AACF,IAAA,OAAO,QAAQ,OAAA,CAAQ,IAAA,CAAK,EAAE,MAAA,EAAQ,CAAC,CAAA;AAAA,EACzC,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,OAAA,CAAQ,OAAO,KAAK,CAAA;AAAA,EAC7B;AACF,CAAA;AAEO,IAAM,iBAAiB,CAAC;AAAA,EAC7B,IAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,O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EAAO,IAAA;AAAA,UACP,QAAA;AAAA,UACC,GAAG,KAAA,CAAM,EAAE,eAAA,EAAiB,UAAU,CAAA;AAAA,UACvC,SAAA;AAAA,UACC,GAAG,OAAA;AAAA,UAEH,QAAA,EAAA,kBAAA,CAAmB,QAAA,EAAU,CAAC,GAAA,KAAS,IAAA,mBAAO,GAAA,CAAC,OAAA,EAAA,EAAQ,KAAA,EAAO,CAAA,CAAE,OAAA,EAAS,CAAA,GAAK,GAAI;AAAA;AAAA;AACrF,wBAEA,IAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAA;AAAA,QACA,IAAA;AAAA,QACA,KAAA;AAAA,QACA,WAAW,IAAA,mBAAO,GAAA,CAAC,WAAQ,KAAA,EAAO,IAAA,EAAM,IAAK,IAAA,CAAK,QAAA;AAAA,QAClD,OAAA;AAAA,QACA,QAAA;AAAA,QAEA,SAAA,EAAW,EAAA,CAAG,UAAA,EAAY,SAAS,CAAA;AAAA,QAClC,GAAG,OAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,QAAA,IAAY,CAAA,CAAE,KAAA;AAAA,UACd,wBAAQ,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAW,YAAE,OAAA,EAAQ;AAAA;AAAA;AAAA,KAChD;AAAA,oBAEF,GAAA,CAAC,MAAA,EAAA,EAAK,IAAA,EAAK,QAAA,EAAS,SAAA,EAAW,cAAc,YAAA,EAAW,iBAAA,EAAkB,WAAA,EAAU,QAAA,EACjF,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ","file":"chunk-B4GNSSHU.js","sourcesContent":["\"use client\"\n\nimport { ark } from \"@ark-ui/react\"\nimport { Download } from \"lucide-react\"\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { type IconMap, iconStroke, mergeIcons } from \"../../lib/icons\"\nimport { props } from \"../../lib/props\"\nimport { saveFile } from \"../../lib/save-file\"\nimport { Button, type ButtonProps } from \"../button/button\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * DownloadButton — a button that saves a file: a Blob you already have, a\n * URL, or whatever a function of yours resolves to (an authenticated fetch,\n * a presign call, a generated CSV). The kit makes no request itself.\n *\n * - **While a function's promise is pending** the button is busy: a\n * spinner, `aria-busy`, and re-clicks are ignored, so a double click\n * saves one file. It stays enabled and focused, unlike Button's\n * `loading`, which sets `disabled` and drops keyboard focus.\n * - **On failure**, a polite status region says so (`translations.error`)\n * and `onError` gets the error. Nothing is announced on success: the\n * browser's own download UI is the feedback.\n * - **Unmounting mid-fetch** aborts: the function's `signal` fires and\n * nothing is saved afterwards.\n * - Renders a kit `Button` by default. With `asChild`, only the behaviour\n * goes onto your element (an `ActionIcon` in a row's actions), and its\n * content is swapped for the spinner while busy.\n *\n * Built on `saveFile` (`lib/save-file.ts`) rather than Ark's\n * `DownloadTrigger`: Ark's trigger has no pending state, drops a rejected\n * promise, can't be aborted, and reads a string as the file's *contents*\n * rather than a URL.\n *\n * ```tsx\n * <DownloadButton\n * name=\"transcript.pdf\"\n * data={({ signal }) => api.get(`/transcripts/${id}`, { signal }).then((r) => r.blob())}\n * onError={() => notify.error(\"Couldn't download the transcript\")}\n * />\n * ```\n */\n\n/** What can be saved: a Blob (or File), or a URL. */\nexport type DownloadData = Blob | string\n\n/** Resolves the file on click. `signal` aborts when the button unmounts first. */\nexport type DownloadLoader = (context: {\n signal: AbortSignal\n}) => DownloadData | Promise<DownloadData>\n\n/** What `data` takes: the value itself, or a function that resolves it on click. */\nexport type DownloadSource = DownloadData | DownloadLoader\n\nexport type DownloadButtonTranslations = {\n /** The default label, when there are no `children`. @default \"Download\" */\n label?: string\n /** Added to the button's name while `data` is resolving. @default \"Preparing download…\" */\n loading?: string\n /** What the status region says when the download fails.\n * @default (name) => name ? `${name} couldn't be downloaded` : \"The download failed\" */\n error?: (name: string | undefined) => string\n}\n\nexport const DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS: Required<DownloadButtonTranslations> = {\n label: \"Download\",\n loading: \"Preparing download…\",\n error: (name) => (name ? `${name} couldn't be downloaded` : \"The download failed\"),\n}\n\nexport type DownloadButtonIconSlot = \"download\"\n\nconst DEFAULT_ICONS: Record<DownloadButtonIconSlot, ReactNode> = {\n download: <Download className={iconStroke} />,\n}\n\nexport type DownloadButtonProps = Omit<\n ButtonProps,\n \"type\" | \"name\" | \"loading\" | \"startSlot\" | \"onError\"\n> & {\n /** The file: a Blob, a URL, or a function resolving one on click (passed an abort `signal`). */\n data: DownloadSource\n /** The file name. Ignored by browsers for a cross-origin URL; see `saveFile`. */\n name?: string\n /** The MIME type, for a Blob without one. */\n type?: string\n /** Fires when `data` rejects or the save throws. */\n onError?: (error: unknown) => void\n /** Fires once the file has been handed to the browser. */\n onDone?: () => void\n translations?: DownloadButtonTranslations\n /** `download`, the leading icon. `null` renders none. Not shown under `asChild`. */\n icons?: IconMap<DownloadButtonIconSlot>\n}\n\n/** Tailwind's `sr-only`, fixed rather than absolute: it is rendered beside the\n * button, outside any box of ours, and a fixed box can't stretch a scroller. */\nconst statusRegion =\n \"fixed size-px -m-px p-0 overflow-hidden whitespace-nowrap border-0 [clip-path:inset(50%)]\"\n\n/** Calls the loader now, inside the click, and treats a synchronous throw as a rejection. */\nconst started = (load: DownloadLoader, signal: AbortSignal): Promise<DownloadData> => {\n try {\n return Promise.resolve(load({ signal }))\n } catch (error) {\n return Promise.reject(error)\n }\n}\n\nexport const DownloadButton = ({\n data,\n name,\n type,\n onError,\n onDone,\n translations,\n icons,\n asChild,\n children,\n testId,\n onClick,\n variant,\n size,\n color,\n endSlot,\n disabled,\n className,\n ...rest\n}: DownloadButtonProps) => {\n const t = { ...DOWNLOAD_BUTTON_DEFAULT_TRANSLATIONS, ...translations }\n const icon = mergeIcons(DEFAULT_ICONS, icons)\n const [busy, setBusy] = useState(false)\n const [failure, setFailure] = useState(\"\")\n // The run in flight, if any: the re-click guard and the unmount abort. A\n // ref, so two clicks in one frame can't both read a stale `busy`.\n const running = useRef<AbortController | null>(null)\n\n useEffect(() => () => running.current?.abort(), [])\n\n const fail = (error: unknown) => {\n setFailure(t.error(name))\n onError?.(error)\n }\n\n // `onDone` sits outside the try, so a throw in the caller's own callback\n // isn't announced as a failed download.\n const save = (value: DownloadData) => {\n try {\n saveFile(value, name, { type })\n } catch (error) {\n return fail(error)\n }\n onDone?.()\n }\n\n const resolve = async (load: DownloadLoader) => {\n const controller = new AbortController()\n running.current = controller\n setBusy(true)\n const outcome = await started(load, controller.signal).then(\n (value) => ({ value }),\n (error: unknown) => ({ error }),\n )\n running.current = null\n // Unmounted meanwhile: nothing to save, and no state left to update.\n if (controller.signal.aborted) return\n setBusy(false)\n if (\"error\" in outcome) fail(outcome.error)\n else save(outcome.value)\n }\n\n // `onClick` runs first, so a caller can `preventDefault()` to stop the save\n // (a confirm step). A value is saved inside the click itself; a function's\n // promise is awaited, and the save follows when it settles.\n const download = (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (event.defaultPrevented || disabled || running.current) return\n // An `asChild` link would also follow its own href.\n event.preventDefault()\n setFailure(\"\")\n if (typeof data === \"function\") void resolve(data)\n else save(data)\n }\n\n const trigger = {\n \"data-scope\": \"download-button\",\n \"data-part\": \"trigger\",\n onClick: download,\n ...props({\n \"aria-busy\": busy,\n \"data-loading\": busy,\n \"data-testid\": testId,\n \"data-disabled\": disabled,\n }),\n ...rest,\n }\n\n return (\n <>\n {asChild ? (\n // Only behaviour is merged onto the child: Button's styling would\n // fight an ActionIcon's own. While busy the spinner stands in for the\n // child's content (its icon); its name stays the child's own label.\n <ark.button\n asChild\n disabled={disabled}\n {...props({ \"aria-disabled\": disabled })}\n className={className}\n {...trigger}\n >\n {withAsChildContent(children, (own) => (busy ? <Spinner label={t.loading} /> : own))}\n </ark.button>\n ) : (\n <Button\n variant={variant}\n size={size}\n color={color}\n startSlot={busy ? <Spinner label={null} /> : icon.download}\n endSlot={endSlot}\n disabled={disabled}\n // `relative` holds the sr-only loading text inside the button.\n className={cn(\"relative\", className)}\n {...trigger}\n >\n {children ?? t.label}\n {busy && <span className=\"sr-only\">{t.loading}</span>}\n </Button>\n )}\n <span role=\"status\" className={statusRegion} data-scope=\"download-button\" data-part=\"status\">\n {failure}\n </span>\n </>\n )\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { Spinner } from './chunk-D2QIPQ74.js';
1
+ import { buttonColorVariants } from './chunk-6B2GNPJP.js';
2
+ import { Spinner } from './chunk-W3XX7BYT.js';
2
3
  import { withAsChildContent } from './chunk-R5LYFTHA.js';
3
4
  import { props } from './chunk-WYCMIIRR.js';
4
5
  import { focusStyles } from './chunk-C6NVU4F7.js';
@@ -16,41 +17,35 @@ var actionIconVariants = cva(
16
17
  "rounded-action-icon border border-transparent",
17
18
  "transition-colors-radius",
18
19
  focusStyles(),
19
- "disabled:not-data-loading:pointer-events-none disabled:opacity-50",
20
- "data-disabled:pointer-events-none data-disabled:opacity-50",
20
+ "disabled:not-data-loading:pointer-events-none data-disabled:pointer-events-none",
21
21
  "not-data-loading:hover:cursor-pointer",
22
22
  "data-loading:cursor-progress data-loading:opacity-50",
23
- "[&_svg]:shrink-0 [&_svg]:pointer-events-none"
23
+ // Every svg rule is `[:where(&)_svg]`: zero class specificity, so a size
24
+ // class on the icon itself (`<Star className="size-5" />`) or a nested
25
+ // component's own svg rule wins whatever the CSS order. Lucide's `size`
26
+ // prop is only an HTML attribute and still loses. Same fix as Input (#427).
27
+ "[:where(&)_svg]:shrink-0 [:where(&)_svg]:pointer-events-none"
24
28
  ],
25
29
  {
26
30
  variants: {
27
31
  variant: {
28
- filled: [
29
- "bg-(--c-solid) text-(--c-on-solid)",
30
- "not-data-loading:hover:bg-(--c-solid-hover)"
31
- ],
32
- light: [
33
- "bg-(--c-soft) text-(--c-text) border-(--c-soft-hover)",
34
- "not-data-loading:hover:bg-(--c-soft-hover) not-data-loading:hover:border-(--c-solid)"
35
- ],
36
- // Button's outline edge (the colour at 35%), so the two read as one
37
- // stroke weight side by side in a toolbar.
38
- outline: [
39
- "bg-transparent text-(--c-text) border-(--c-solid)/35",
40
- "not-data-loading:hover:bg-(--c-soft)"
41
- ],
42
- subtle: ["bg-transparent text-(--c-text)", "not-data-loading:hover:bg-(--c-soft)"],
32
+ filled: buttonColorVariants.filled,
33
+ light: buttonColorVariants.light,
34
+ outline: buttonColorVariants.outline,
35
+ subtle: buttonColorVariants.subtle,
43
36
  default: [
44
37
  "bg-brand-950 text-white border-brand-800 not-data-loading:hover:bg-brand-800",
45
- "dark:bg-white dark:text-brand-950 dark:border-white/80 dark:not-data-loading:hover:bg-white/80"
38
+ "dark:bg-white dark:text-brand-950 dark:border-white/80 dark:not-data-loading:hover:bg-white/80",
39
+ // Not part of the Figma Button set, so it keeps the plain dim.
40
+ "disabled:opacity-50 data-disabled:opacity-50"
46
41
  ]
47
42
  },
48
43
  size: {
49
- xs: "h-7 text-xs [&_svg]:size-5",
50
- sm: "h-8 text-sm [&_svg]:size-5.5",
51
- md: "h-9 text-md [&_svg]:size-6",
52
- lg: "h-10 text-lg [&_svg]:size-7",
53
- xl: "h-12 text-xl [&_svg]:size-8"
44
+ xs: "h-7 text-xs [:where(&)_svg]:size-3",
45
+ sm: "h-8 text-sm [:where(&)_svg]:size-3.5",
46
+ md: "h-9 text-md [:where(&)_svg]:size-4",
47
+ lg: "h-10 text-lg [:where(&)_svg]:size-5",
48
+ xl: "h-12 text-xl [:where(&)_svg]:size-6"
54
49
  },
55
50
  radius: {
56
51
  xs: "rounded-xs",
@@ -113,5 +108,5 @@ var ActionIcon = ({
113
108
  };
114
109
 
115
110
  export { ActionIcon };
116
- //# sourceMappingURL=chunk-BMEJBY6H.js.map
117
- //# sourceMappingURL=chunk-BMEJBY6H.js.map
111
+ //# sourceMappingURL=chunk-B5YHYI7E.js.map
112
+ //# sourceMappingURL=chunk-B5YHYI7E.js.map
@@ -0,0 +1 @@
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AM,CAAA,GAEtB;AAAA;AAAA,GAEJ;AAEJ","file":"chunk-B5YHYI7E.js","sourcesContent":["\"use client\"\n\nimport { ark, type HTMLArkProps } from \"@ark-ui/react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { MouseEvent } from \"react\"\nimport { withAsChildContent } from \"../../lib/as-child\"\nimport { buttonColorVariants } from \"../../lib/button-colors\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { focusStyles } from \"../../lib/focus-styles\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { Spinner } from \"../spinner/spinner\"\n\n/**\n * ActionIcon — square, icon-only sibling of `Button`.\n *\n * Same (variant × color) model as `Button`:\n * - `variant` picks the shape (filled / light / outline / subtle / default)\n * - `color` picks the palette (brand / neutral / red / …)\n * - filled / light / outline / subtle share Button's colour classes\n * (`lib/button-colors.ts`, the `--btn-*` slots in `colors.css`): Figma's\n * ActionIcon is an instance of its Button set.\n *\n * What's specific to ActionIcon:\n * - Forced 1:1 aspect ratio.\n * - Own `radius` scale (incl. `full` for circular FABs / like-buttons).\n * - Wider size scale (xs..xl) than Button — toolbar density matters here.\n *\n * The accessible name MUST come from `aria-label` (or `aria-labelledby`); the\n * icon children are decoration.\n *\n * `asChild` renders the single child with ActionIcon's styling. Ark's\n * factory clones exactly one element, so `loading`'s spinner replaces\n * *that* element's own children (`withAsChildContent`, `lib/as-child.ts`)\n * rather than the element itself. The `onClick` guard (`preventWhileLoading`)\n * goes on the same clone, since `disabled` doesn't do anything on an\n * arbitrary `asChild` element (e.g. an `<a>`) — same reason the loading\n * `opacity-50` dimming and `pointer-events-none` blocking are keyed off `data-loading`\n * rather than `:disabled` (see `Button`'s note on this).\n */\nconst actionIconVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"aspect-square shrink-0 select-none\",\n \"font-medium uppercase tracking-wide\",\n \"no-underline\",\n \"rounded-action-icon border border-transparent\",\n \"transition-colors-radius\",\n focusStyles(),\n \"disabled:not-data-loading:pointer-events-none data-disabled:pointer-events-none\",\n \"not-data-loading:hover:cursor-pointer\",\n \"data-loading:cursor-progress data-loading:opacity-50\",\n // Every svg rule is `[:where(&)_svg]`: zero class specificity, so a size\n // class on the icon itself (`<Star className=\"size-5\" />`) or a nested\n // component's own svg rule wins whatever the CSS order. Lucide's `size`\n // prop is only an HTML attribute and still loses. Same fix as Input (#427).\n \"[:where(&)_svg]:shrink-0 [:where(&)_svg]:pointer-events-none\",\n ],\n {\n variants: {\n variant: {\n filled: buttonColorVariants.filled,\n light: buttonColorVariants.light,\n outline: buttonColorVariants.outline,\n subtle: buttonColorVariants.subtle,\n default: [\n \"bg-brand-950 text-white border-brand-800 not-data-loading:hover:bg-brand-800\",\n \"dark:bg-white dark:text-brand-950 dark:border-white/80 dark:not-data-loading:hover:bg-white/80\",\n // Not part of the Figma Button set, so it keeps the plain dim.\n \"disabled:opacity-50 data-disabled:opacity-50\",\n ],\n },\n size: {\n xs: \"h-7 text-xs [:where(&)_svg]:size-3\",\n sm: \"h-8 text-sm [:where(&)_svg]:size-3.5\",\n md: \"h-9 text-md [:where(&)_svg]:size-4\",\n lg: \"h-10 text-lg [:where(&)_svg]:size-5\",\n xl: \"h-12 text-xl [:where(&)_svg]:size-6\",\n },\n radius: {\n xs: \"rounded-xs\",\n sm: \"rounded-sm\",\n md: \"rounded-md\",\n lg: \"rounded-lg\",\n xl: \"rounded-xl\",\n full: \"rounded-full\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"md\",\n },\n },\n)\n\nexport type ActionIconVariant = NonNullable<VariantProps<typeof actionIconVariants>[\"variant\"]>\nexport type ActionIconSize = NonNullable<VariantProps<typeof actionIconVariants>[\"size\"]>\nexport type ActionIconRadius = NonNullable<VariantProps<typeof actionIconVariants>[\"radius\"]>\n\nexport type ActionIconProps = Omit<HTMLArkProps<\"button\">, \"color\"> &\n VariantProps<typeof actionIconVariants> &\n WithTestId & {\n /** Accent palette. Re-exported as `Color` from `@42/ui-react`. */\n color?: Color\n /**\n * Replace the icon with a spinner, mark the element as busy, and suppress\n * pointer interactions. Mirrors `Button`'s `loading`.\n */\n loading?: boolean\n }\n\n/** Mirrors `Button`'s `preventWhileLoading` — see the note there. */\nconst preventWhileLoading = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n}\n\nexport const ActionIcon = ({\n className,\n variant,\n size,\n radius,\n color,\n loading = false,\n children,\n disabled,\n type,\n asChild,\n testId,\n onClick,\n ...rest\n}: ActionIconProps) => {\n const resolvedDisabled = disabled || loading\n const resolvedOnClick = loading ? preventWhileLoading : onClick\n\n return (\n <ark.button\n asChild={asChild}\n type={asChild ? type : (type ?? \"button\")}\n disabled={resolvedDisabled}\n data-color={color}\n data-variant={variant ?? \"default\"}\n className={cn(actionIconVariants({ variant, size, radius }), className)}\n onClick={resolvedOnClick}\n {...props({\n \"aria-busy\": loading,\n \"aria-disabled\": resolvedDisabled,\n \"data-loading\": loading,\n \"data-testid\": testId,\n })}\n {...rest}\n >\n {asChild && loading ? (\n withAsChildContent(children, () => <Spinner label={null} />, {\n onClick: preventWhileLoading,\n })\n ) : loading ? (\n <Spinner label={null} />\n ) : (\n children\n )}\n </ark.button>\n )\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { buttonGroupVariants } from './chunk-PBSVX5DB.js';
2
2
  import { FieldShell, fieldA11yProps } from './chunk-X6DESK37.js';
3
- import { Button } from './chunk-SCXXJDKQ.js';
3
+ import { Button } from './chunk-SP6LCCTZ.js';
4
4
  import { useUncontrolled } from './chunk-PMUCGFY5.js';
5
5
  import { props } from './chunk-WYCMIIRR.js';
6
6
  import { cn } from './chunk-4ASNIDV7.js';
@@ -241,5 +241,5 @@ var ButtonSelectControl = ({
241
241
  };
242
242
 
243
243
  export { ButtonSelectControl, Context, Item, MultiRoot, Root };
244
- //# sourceMappingURL=chunk-7OGZT7U2.js.map
245
- //# sourceMappingURL=chunk-7OGZT7U2.js.map
244
+ //# sourceMappingURL=chunk-G3AD3NJG.js.map
245
+ //# sourceMappingURL=chunk-G3AD3NJG.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/button-select/button-select.tsx","../src/components/button-select/button-select-items.ts","../src/components/button-select/button-select-control.tsx"],"names":["Ark","props","jsx"],"mappings":";;;;;;;;;;;AAqDA,IAAM,2BAA2B,aAAA,CAAiC;AAAA,EAChE,OAAA,EAAS,OAAA;AAAA,EACT,eAAA,EAAiB,QAAA;AAAA,EACjB,IAAA,EAAM;AACR,CAAC,CAAA;AAYD,IAAM,WAAA,GACJ,yKAAA;AAyBF,IAAM,aAAa,CAAC,CAAA,EAAsB,CAAA,KACxC,CAAA,CAAE,WAAW,CAAA,CAAE,MAAA,IAAU,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,KAAM,CAAA,CAAE,CAAC,CAAC,CAAA;AAYvD,IAAM,iBAAA,GAAoB,CAAC,KAAA,KAAsC;AAC/D,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,KAAA,CAAM,aAAA,EAAe;AAC1C,EAAA,MAAM,QAAA,GAAW,MAAM,aAAA,CAAc,aAAA;AAAA,IACnC;AAAA,GACF;AACA,EAAA,IAAI,CAAC,QAAA,EAAU;AACf,EAAA,KAAA,CAAM,eAAA,EAAgB;AACtB,EAAA,QAAA,CAAS,KAAA,CAAM,EAAE,aAAA,EAAe,IAAA,EAAM,CAAA;AACxC,CAAA;AAWA,IAAM,eAAA,GAAkB,CAAC,IAAA,KAAkB,CAAC,KAAA,KAAyC;AACnF,EAAA,MAAM,OAAO,KAAA,CAAM,aAAA;AACnB,EAAA,IAAI,KAAK,GAAA,KAAQ,KAAA,IAAS,KAAK,YAAA,CAAa,kBAAkB,MAAM,YAAA,EAAc;AAClF,EAAA,IAAI,KAAA,CAAM,GAAA,KAAQ,WAAA,IAAe,KAAA,CAAM,QAAQ,YAAA,EAAc;AAC7D,EAAA,MAAM,QAAQ,KAAA,CAA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;AAAA,YACT,IAAA;AAAA,YACA,IAAA;AAAA,YACA,OAAA;AAAA,YACA,eAAA;AAAA,YACA,KAAA;AAAA,YACA,EAAA;AAAA,YACA,GAAA;AAAA,YACA,MAAA;AAAA,YACA,MAAA;AAAA,YACA,SAAA,EAAW,EAAA,CAAG,SAAA,EAAW,UAAA,EAAY,IAAI,CAAA;AAAA,YAExC,QAAA,EAAA,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,qBACVA,GAAAA;AAAA,cAAC,IAAA;AAAA,cAAA;AAAA,gBAEC,OAAO,IAAA,CAAK,KAAA;AAAA,gBACZ,UAAU,IAAA,CAAK,QAAA;AAAA,gBACf,OAAO,IAAA,CAAK,KAAA;AAAA,gBACZ,WAAW,IAAA,CAAK,SAAA;AAAA,gBAChB,SAAS,IAAA,CAAK,OAAA;AAAA,gBACd,cAAY,IAAA,CAAK,SAAA;AAAA,gBACjB,QAAQ,IAAA,CAAK,MAAA;AAAA,gBACb,WAAW,UAAA,EAAY,IAAA;AAAA,gBAEtB,QAAA,EAAA,UAAA,GACG,WAAW,IAAA,EAAM;AAAA,kBACf,QAAA,EAAU,KAAA,CAAM,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA;AAAA,kBACnC,QAAA,EAAU,OAAA,CAAQ,QAAQ,CAAA,IAAK,IAAA,CAAK;AAAA,iBACrC,IACD,IAAA,CAAK;AAAA,eAAA;AAAA,cAfJ,IAAA,CAAK;AAAA,aAiBb;AAAA;AAAA,SACH;AAAA,wBACAA,GAAAA,CAAC,YAAA,EAAA,EAAa,IAAA,EAAY,OAAc,QAAA,EAAoB;AAAA;AAAA;AAAA,GAC9D;AAEJ","file":"chunk-7OGZT7U2.js","sourcesContent":["\"use client\"\n\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { ToggleGroup as Ark, useToggleGroupContext } from \"@ark-ui/react/toggle-group\"\nimport {\n Children,\n cloneElement,\n createContext,\n type FocusEvent,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n useContext,\n} from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { useUncontrolled } from \"../../lib/use-uncontrolled\"\nimport { Button, type ButtonProps, type ButtonSize, type ButtonVariant } from \"../button/button\"\nimport { buttonGroupVariants } from \"../button-group/button-group\"\nimport { fieldA11yProps } from \"../field/field\"\n\n/**\n * ButtonSelect / ButtonMultiSelect — compound parts.\n *\n * A row (or column) of real `Button`s joined like `ButtonGroup`, on Ark UI's\n * ToggleGroup machine. Every item renders through `Button` itself and only its\n * `variant` changes with the selection: unselected items take `variant`, the\n * selected ones `selectedVariant`. So the item styling — every variant × color,\n * sizes, `startSlot`/`endSlot`, hover, focus ring — has exactly one source, and\n * the join (flattened inner corners, collapsed hairlines, the hover/focus z-lift\n * and the filled/subtle seams) comes from `buttonGroupVariants` rather than a copy.\n *\n * Unlike `SegmentGroup` there is no sliding pill: a pill can't follow several\n * selected items at once, and the same parts back both the single and the\n * multiple form. The machine provides the semantics — `radiogroup` / `radio` +\n * `aria-checked` for single, `group` + `aria-pressed` for multiple — plus roving\n * focus with arrow keys and Home/End.\n *\n * `variant`, `selectedVariant` and `size` travel through a small context set once\n * on `Root`, so they aren't repeated on every `Item` (the Tabs pattern). `color`\n * is a plain `data-color` on `Root`, so it cascades to every item as CSS custom\n * properties; an item's own `color` re-stamps it on that one button.\n */\n\ntype StyleContextValue = {\n variant: ButtonVariant\n selectedVariant: ButtonVariant\n size: ButtonSize\n}\n\nconst ButtonSelectStyleContext = createContext<StyleContextValue>({\n variant: \"light\",\n selectedVariant: \"filled\",\n size: \"md\",\n})\n\n/**\n * The invalid cue is a ring on the whole group rather than red item borders: the\n * borderless `filled` / `subtle` items have no border to recolor, and the group\n * seams out-specify a per-item border anyway. A `ring` (box-shadow) is used, not\n * an `outline`, because the machine writes `outline: none` inline on the root.\n * `w-fit` keeps that ring hugging the items: inside `Field`'s flex column the\n * root would otherwise stretch to the field's full width. Under `grow` the root\n * spans that width on purpose, so `w-full` overrides it and the ring spans the\n * row with it.\n */\nconst invalidRing =\n \"w-fit rounded-button data-invalid:ring-1 data-invalid:ring-red-500 data-invalid:ring-offset-2 data-invalid:ring-offset-brand-50 dark:data-invalid:ring-offset-brand-950\"\n\ntype BaseRootProps = Omit<\n Ark.RootProps,\n \"color\" | \"multiple\" | \"value\" | \"defaultValue\" | \"onValueChange\" | \"deselectable\" | \"onChange\"\n> &\n WithTestId & {\n /** Palette for every item, as a `data-color` on the group. */\n color?: Color\n /** Treatment of the unselected items. */\n variant?: ButtonVariant\n /** Treatment of the selected items. */\n selectedVariant?: ButtonVariant\n size?: ButtonSize\n /** Red invalid ring around the group. */\n invalid?: boolean\n /** Span the container and give every item an even share of it, like a tab\n * bar. Without it the group hugs its items. */\n grow?: boolean\n /** Lands on the group root, which forwards focus to its active item. Ark's\n * prop types carry no `ref`, so it is declared here. */\n ref?: Ref<HTMLDivElement>\n children?: ReactNode\n }\n\nconst sameValues = (a: readonly string[], b: readonly string[]) =>\n a.length === b.length && a.every((v, i) => v === b[i])\n\n/**\n * Tab entry for a single-choice group. Every item is `tabindex=-1` while focus is\n * outside, so Tab lands on the root, and zag then forwards focus to the *first*\n * item regardless of the selection. A radio group should land on the checked\n * radio instead, so in single mode the root's own focus is caught in the capture\n * phase and sent to the selected (enabled) item. `stopPropagation` there stops\n * the native event before React's bubble listener runs, which is what keeps\n * zag's `ROOT.FOCUS` (and its deferred focus-first) from firing. With nothing\n * selected, zag's own behaviour stands.\n */\nconst focusSelectedItem = (event: FocusEvent<HTMLDivElement>) => {\n if (event.target !== event.currentTarget) return\n const selected = event.currentTarget.querySelector<HTMLElement>(\n ':scope > [data-state=\"on\"]:not([disabled])',\n )\n if (!selected) return\n event.stopPropagation()\n selected.focus({ preventScroll: true })\n}\n\n/**\n * RTL arrow keys. zag's toggle-group reads `event.key` without passing `dir` to\n * `getEventKey` (its other machines do), so in a right-to-left locale ArrowLeft\n * moves focus visually *right*. In a horizontal RTL group the two keys are\n * caught in the capture phase, before zag's handler, and focus moves to the\n * visually adjacent enabled item instead; zag then picks up the new focus\n * through the item's own `onFocus`. `dir` is read off the root, where the\n * machine writes the locale's direction.\n */\nconst mirrorRtlArrows = (loop: boolean) => (event: KeyboardEvent<HTMLDivElement>) => {\n const root = event.currentTarget\n if (root.dir !== \"rtl\" || root.getAttribute(\"data-orientation\") !== \"horizontal\") return\n if (event.key !== \"ArrowLeft\" && event.key !== \"ArrowRight\") return\n const items = Array.from(\n root.querySelectorAll<HTMLElement>(':scope > [data-part=\"item\"]:not([disabled])'),\n )\n const index = items.indexOf(event.target as HTMLElement)\n if (index === -1) return\n event.preventDefault()\n event.stopPropagation()\n // Visually left is the next item in RTL, visually right the previous one.\n const step = event.key === \"ArrowLeft\" ? 1 : -1\n const next = loop\n ? items[(index + step + items.length) % items.length]\n : items[Math.min(Math.max(index + step, 0), items.length - 1)]\n next?.focus()\n}\n\n/** The shared root behind both `ButtonSelect.Root` and `ButtonMultiSelect.Root`. */\nexport const RootBase = ({\n multiple,\n value,\n defaultValue,\n onValueChange,\n deselectable,\n orientation = \"horizontal\",\n color,\n variant = \"light\",\n selectedVariant = \"filled\",\n size = \"md\",\n invalid,\n grow,\n loopFocus = true,\n className,\n testId,\n children,\n ...rest\n}: BaseRootProps & {\n multiple: boolean\n value?: string[]\n defaultValue?: string[]\n onValueChange?: (value: string[]) => void\n deselectable?: boolean\n}) => {\n const field = useFieldContext()\n // Owned here so a change can be compared with the current value: in a\n // non-deselectable single group the machine re-emits the same value when the\n // selected item is clicked again, and that is not a change.\n const [selected, setSelected] = useUncontrolled<string[]>({\n value,\n defaultValue,\n finalValue: [],\n onChange: onValueChange,\n })\n return (\n <ButtonSelectStyleContext.Provider value={{ variant, selectedVariant, size }}>\n <Ark.Root\n multiple={multiple}\n value={selected}\n onValueChange={(details) => {\n if (!sameValues(details.value, selected)) setSelected(details.value)\n }}\n deselectable={deselectable}\n orientation={orientation}\n loopFocus={loopFocus}\n onFocusCapture={multiple ? undefined : focusSelectedItem}\n onKeyDownCapture={mirrorRtlArrows(loopFocus)}\n data-color={color}\n {...props({ \"aria-invalid\": invalid, \"data-invalid\": invalid, \"data-testid\": testId })}\n {...fieldA11yProps(field)}\n className={cn(\n buttonGroupVariants({ orientation, grow }),\n invalidRing,\n grow && \"w-full\",\n className,\n )}\n {...rest}\n >\n {children}\n </Ark.Root>\n </ButtonSelectStyleContext.Provider>\n )\n}\n\nexport type ButtonSelectRootProps = BaseRootProps & {\n /** Controlled value. `null` clears the selection. */\n value?: string | null\n /** Uncontrolled initial value. */\n defaultValue?: string | null\n /** Fires with the newly selected value — `null` only when `deselectable`. */\n onChange?: (value: string | null) => void\n /** Clicking the selected item clears the selection. Off by default, so the\n * group behaves like a radio group. */\n deselectable?: boolean\n}\n\nconst toArray = (value: string | null | undefined) =>\n value === undefined ? undefined : value === null ? [] : [value]\n\n/** Single-choice root: one selected item at most. */\nexport const Root = ({\n value,\n defaultValue,\n onChange,\n deselectable = false,\n ...rest\n}: ButtonSelectRootProps) => (\n <RootBase\n multiple={false}\n value={toArray(value)}\n defaultValue={toArray(defaultValue)}\n onValueChange={(next) => onChange?.(next[0] ?? null)}\n deselectable={deselectable}\n {...rest}\n />\n)\n\nexport type ButtonMultiSelectRootProps = BaseRootProps & {\n /** Controlled value. */\n value?: string[]\n /** Uncontrolled initial value. */\n defaultValue?: string[]\n /** Fires with every selected value, in selection order. */\n onChange?: (value: string[]) => void\n}\n\n/** Multiple-choice root: each item toggles independently. */\nexport const MultiRoot = ({ onChange, ...rest }: ButtonMultiSelectRootProps) => (\n <RootBase multiple onValueChange={onChange} {...rest} />\n)\n\n/** The props `Item` hands a custom control under `asChild`. */\ntype SelectableControlProps = { variant?: ButtonVariant; size?: ButtonSize }\n\nexport type ButtonSelectItemProps =\n | (Omit<ButtonProps, \"value\" | \"variant\" | \"size\" | \"loading\" | \"asChild\"> & {\n /** The value this item selects. */\n value: string\n asChild?: false\n })\n | {\n /** The value this item selects. */\n value: string\n disabled?: boolean\n /**\n * Render your own variant-aware control instead of a `Button` — e.g. an\n * `ActionIcon` for an icon-only toolbar. The single child receives the\n * selection-driven `variant` and the group `size` (its own `size` wins),\n * plus the machine's item props.\n */\n asChild: true\n children: ReactElement<SelectableControlProps>\n }\n\n/**\n * One option, rendered as a `Button`. Its `variant` follows the selection (from\n * `Root`'s `variant` / `selectedVariant`); every other `Button` prop — `color`,\n * `startSlot`, `endSlot`, `aria-label` for an icon-only item, `testId` — passes\n * through. The machine's item props land on the button via Ark's `asChild`.\n *\n * With `asChild`, the single child is rendered in place of the `Button` and\n * cloned with the same `variant` / `size`, so any control speaking the kit's\n * variant × size vocabulary (`ActionIcon`, a consumer's own) can be an item.\n */\nexport const Item = (props: ButtonSelectItemProps) => {\n const { variant, selectedVariant, size } = useContext(ButtonSelectStyleContext)\n const { value, disabled } = props\n const { pressed } = useToggleGroupContext().getItemState({ value, disabled })\n const resolvedVariant = pressed ? selectedVariant : variant\n if (props.asChild) {\n const child = Children.only(props.children)\n return (\n <Ark.Item value={value} disabled={disabled} asChild>\n {cloneElement(child, { variant: resolvedVariant, size: child.props.size ?? size })}\n </Ark.Item>\n )\n }\n const { value: _value, disabled: _disabled, asChild: _asChild, ...rest } = props\n return (\n <Ark.Item value={value} disabled={disabled} asChild>\n <Button variant={resolvedVariant} size={size} {...rest} />\n </Ark.Item>\n )\n}\n\n/**\n * One hidden input per selected value, so a native `<form>` submit carries the\n * selection under `name`. Rendered *beside* the root, never inside it: the join\n * selectors target the root's children by `:first-child` / `:last-child`, which a\n * trailing input would throw off.\n */\nexport const HiddenInputs = ({\n name,\n value,\n disabled,\n}: {\n name?: string\n value: readonly string[]\n disabled?: boolean\n}) =>\n name == null\n ? null\n : value.map((v) => <input key={v} type=\"hidden\" name={name} value={v} disabled={disabled} />)\n\nexport const Context = Ark.Context\n","import type { ReactNode } from \"react\"\nimport type { Color } from \"../../lib/colors\"\n\n/**\n * One option of a data-driven `ButtonSelect` / `ButtonMultiSelect`: a bare\n * value-as-label string, or a labelled object. `payload` is arbitrary data the\n * machine ignores; it reaches `renderItem` typed off the `data` shape — the same\n * contract as `SegmentGroup` and `Select`.\n */\nexport type ButtonSelectItem<P = unknown> =\n | string\n | {\n value: string\n label?: ReactNode\n /** Content before the label, e.g. an icon (Button's `startSlot`). */\n startSlot?: ReactNode\n /** Content after the label (Button's `endSlot`). */\n endSlot?: ReactNode\n disabled?: boolean\n /** Overrides the group palette for this item. */\n color?: Color\n /** Accessible name — required when `label` is an icon only. */\n \"aria-label\"?: string\n /** Arbitrary extra data, surfaced to `renderItem`. */\n payload?: P\n /** `data-testid` on the rendered button. Defaults to `` `item-${value}` ``. */\n testId?: string\n }\n\n/** The `data` array both components are generic over. */\nexport type ButtonSelectData<P = unknown> = ReadonlyArray<ButtonSelectItem<P>>\n\n/** The value-string union of a `ButtonSelectData` shape; a `const` type\n * parameter narrows it to the literal union. */\nexport type ButtonSelectValue<Data extends ButtonSelectData> = ItemValue<Data[number]>\ntype ItemValue<E> = E extends string ? E : E extends { value: infer V extends string } ? V : never\n\n/** The `payload` type carried by a `ButtonSelectData` shape. */\nexport type ButtonSelectPayload<Data extends ButtonSelectData> = PayloadOf<Data[number]>\ntype PayloadOf<T> = T extends string ? never : T extends { payload?: infer P } ? P : never\n\n/** The item handed to `renderItem`, narrowed to the data's value and payload. */\nexport type RenderableButtonSelectItem<Data extends ButtonSelectData> = {\n value: ButtonSelectValue<Data>\n label: ReactNode\n disabled: boolean\n color: Color | undefined\n payload: ButtonSelectPayload<Data> | undefined\n}\n\n/** Live item state passed alongside the item to `renderItem`. */\nexport type ButtonSelectItemState = {\n selected: boolean\n disabled: boolean\n}\n\n/**\n * Render an item's label yourself. The item keeps its button, sizing, variant\n * and selection wiring; you fill its content. In an RSC tree the function must\n * live in a `\"use client\"` module.\n */\nexport type RenderButtonSelectItem<Data extends ButtonSelectData> = (\n item: RenderableButtonSelectItem<Data>,\n state: ButtonSelectItemState,\n) => ReactNode\n\n/** A fully resolved item — every field present (`label` falls back to `value`). */\nexport type NormalizedButtonSelectItem = {\n value: string\n label: ReactNode\n startSlot: ReactNode\n endSlot: ReactNode\n disabled: boolean\n color: Color | undefined\n ariaLabel: string | undefined\n payload: unknown\n testId: string\n}\n\nexport const normalizeButtonSelectItem = (item: ButtonSelectItem): NormalizedButtonSelectItem =>\n typeof item === \"string\"\n ? {\n value: item,\n label: item,\n startSlot: undefined,\n endSlot: undefined,\n disabled: false,\n color: undefined,\n ariaLabel: undefined,\n payload: undefined,\n testId: `item-${item}`,\n }\n : {\n value: item.value,\n label: item.label ?? item.value,\n startSlot: item.startSlot,\n endSlot: item.endSlot,\n disabled: item.disabled ?? false,\n color: item.color,\n ariaLabel: item[\"aria-label\"],\n payload: item.payload,\n testId: item.testId ?? `item-${item.value}`,\n }\n","\"use client\"\n\nimport type { FocusEvent, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport type { ButtonSize, ButtonVariant } from \"../button/button\"\nimport { type FieldProps, FieldShell } from \"../field/field\"\nimport { HiddenInputs, Item, RootBase } from \"./button-select\"\nimport {\n type ButtonSelectData,\n normalizeButtonSelectItem,\n type RenderButtonSelectItem,\n} from \"./button-select-items\"\n\ntype ButtonSelectClassNames = {\n field?: string\n /** The label element itself — e.g. `\"sr-only\"` to keep the accessible name\n * without showing it. */\n label?: string\n root?: string\n item?: string\n}\n\n/** Props shared by the data-driven `ButtonSelect` and `ButtonMultiSelect`. */\nexport type ButtonSelectBaseProps<Data extends ButtonSelectData> = Pick<\n FieldProps,\n \"label\" | \"description\" | \"error\" | \"required\"\n> &\n WithTestId & {\n /** Items: bare strings (`value === label`) or `{ value, label?, startSlot?, … }`. */\n data: Data\n /** Render each item's content yourself, with its typed `payload`. */\n renderItem?: RenderButtonSelectItem<Data>\n /** Lay the items in a row (default) or a column. */\n orientation?: \"horizontal\" | \"vertical\"\n /** Red invalid state, independent of (and OR'd with) `error`. */\n invalid?: boolean\n /** Span the container and give every item an even share of it, like a tab\n * bar. Without it the group hugs its items. */\n grow?: boolean\n /** Dims and blocks every item. */\n disabled?: boolean\n size?: ButtonSize\n /** Treatment of the unselected items. Defaults to `light`. */\n variant?: ButtonVariant\n /** Treatment of the selected items. Defaults to `filled`. */\n selectedVariant?: ButtonVariant\n color?: Color\n /** Renders a hidden input per selected value for native form submission. */\n name?: string\n /** Explicit id for the group root. */\n id?: string\n /** Lands on the group root, which forwards focus to its active item. */\n ref?: Ref<HTMLDivElement>\n /** Forwarded to the root; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n className?: string\n classNames?: ButtonSelectClassNames\n }\n\n/**\n * The rendering both data forms share: the `Field` wrapper, the group root, one\n * `Item` per entry and the hidden inputs. The public components only adapt their\n * value shape (`V | null` or `V[]`) onto the machine's `string[]`.\n */\nexport const ButtonSelectControl = ({\n multiple,\n deselectable,\n value,\n onValueChange,\n data,\n renderItem,\n orientation,\n invalid,\n grow,\n disabled,\n required,\n size = \"md\",\n variant,\n selectedVariant,\n color,\n name,\n id,\n ref,\n onBlur,\n label,\n description,\n error,\n className,\n classNames,\n testId,\n}: ButtonSelectBaseProps<ButtonSelectData> & {\n multiple: boolean\n deselectable?: boolean\n value: readonly string[]\n onValueChange: (value: string[]) => void\n}) => {\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = invalid || error != null\n const items = data.map(normalizeButtonSelectItem)\n\n return (\n <FieldShell\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={classNames?.field}\n classNames={{ label: classNames?.label }}\n >\n <RootBase\n multiple={multiple}\n deselectable={deselectable}\n value={[...value]}\n onValueChange={onValueChange}\n orientation={orientation}\n disabled={disabled}\n invalid={isInvalid}\n grow={grow}\n size={size}\n variant={variant}\n selectedVariant={selectedVariant}\n color={color}\n id={id}\n ref={ref}\n onBlur={onBlur}\n testId={testId}\n className={cn(className, classNames?.root)}\n >\n {items.map((item) => (\n <Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n color={item.color}\n startSlot={item.startSlot}\n endSlot={item.endSlot}\n aria-label={item.ariaLabel}\n testId={item.testId}\n className={classNames?.item}\n >\n {renderItem\n ? renderItem(item, {\n selected: value.includes(item.value),\n disabled: Boolean(disabled) || item.disabled,\n })\n : item.label}\n </Item>\n ))}\n </RootBase>\n <HiddenInputs name={name} value={value} disabled={disabled} />\n </FieldShell>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/components/button-select/button-select.tsx","../src/components/button-select/button-select-items.ts","../src/components/button-select/button-select-control.tsx"],"names":["Ark","props","jsx"],"mappings":";;;;;;;;;;;AAqDA,IAAM,2BAA2B,aAAA,CAAiC;AAAA,EAChE,OAAA,EAAS,OAAA;AAAA,EACT,eAAA,EAAiB,QAAA;AAAA,EACjB,IAAA,EAAM;AACR,CAAC,CAAA;AAYD,IAAM,WAAA,GACJ,yKAAA;AAyBF,IAAM,aAAa,CAAC,CAAA,EAAsB,CAAA,KACxC,CAAA,CAAE,WAAW,CAAA,CAAE,MAAA,IAAU,CAAA,CAAE,KAAA,CAAM,CAAC,CAAA,EAAG,CAAA,KAAM,CAAA,KAAM,CAAA,CAAE,CAAC,CAAC,CAAA;AAYvD,IAAM,iBAAA,GAAoB,CAAC,KAAA,KAAsC;AAC/D,EAAA,IAAI,KAAA,CAAM,MAAA,KAAW,KAAA,CAAM,aAAA,EAAe;AAC1C,EAAA,MAAM,QAAA,GAAW,MAAM,aAAA,CAAc,aAAA;AAAA,IACnC;AAAA,GACF;AACA,EAAA,IAAI,CAAC,QAAA,EAAU;AACf,EAAA,KAAA,CAAM,eAAA,EAAgB;AACtB,EAAA,QAAA,CAAS,KAAA,CAAM,EAAE,aAAA,EAAe,IAAA,EAAM,CAAA;AACxC,CAAA;AAWA,IAAM,eAAA,GAAk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GAAAA,CAAC,YAAA,EAAA,EAAa,IAAA,EAAY,OAAc,QAAA,EAAoB;AAAA;AAAA;AAAA,GAC9D;AAEJ","file":"chunk-G3AD3NJG.js","sourcesContent":["\"use client\"\n\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { ToggleGroup as Ark, useToggleGroupContext } from \"@ark-ui/react/toggle-group\"\nimport {\n Children,\n cloneElement,\n createContext,\n type FocusEvent,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n useContext,\n} from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { useUncontrolled } from \"../../lib/use-uncontrolled\"\nimport { Button, type ButtonProps, type ButtonSize, type ButtonVariant } from \"../button/button\"\nimport { buttonGroupVariants } from \"../button-group/button-group\"\nimport { fieldA11yProps } from \"../field/field\"\n\n/**\n * ButtonSelect / ButtonMultiSelect — compound parts.\n *\n * A row (or column) of real `Button`s joined like `ButtonGroup`, on Ark UI's\n * ToggleGroup machine. Every item renders through `Button` itself and only its\n * `variant` changes with the selection: unselected items take `variant`, the\n * selected ones `selectedVariant`. So the item styling — every variant × color,\n * sizes, `startSlot`/`endSlot`, hover, focus ring — has exactly one source, and\n * the join (flattened inner corners, collapsed hairlines, the hover/focus z-lift\n * and the filled/subtle seams) comes from `buttonGroupVariants` rather than a copy.\n *\n * Unlike `SegmentGroup` there is no sliding pill: a pill can't follow several\n * selected items at once, and the same parts back both the single and the\n * multiple form. The machine provides the semantics — `radiogroup` / `radio` +\n * `aria-checked` for single, `group` + `aria-pressed` for multiple — plus roving\n * focus with arrow keys and Home/End.\n *\n * `variant`, `selectedVariant` and `size` travel through a small context set once\n * on `Root`, so they aren't repeated on every `Item` (the Tabs pattern). `color`\n * is a plain `data-color` on `Root`, so it cascades to every item as CSS custom\n * properties; an item's own `color` re-stamps it on that one button.\n */\n\ntype StyleContextValue = {\n variant: ButtonVariant\n selectedVariant: ButtonVariant\n size: ButtonSize\n}\n\nconst ButtonSelectStyleContext = createContext<StyleContextValue>({\n variant: \"light\",\n selectedVariant: \"filled\",\n size: \"md\",\n})\n\n/**\n * The invalid cue is a ring on the whole group rather than red item borders: the\n * borderless `filled` / `subtle` items have no border to recolor, and the group\n * seams out-specify a per-item border anyway. A `ring` (box-shadow) is used, not\n * an `outline`, because the machine writes `outline: none` inline on the root.\n * `w-fit` keeps that ring hugging the items: inside `Field`'s flex column the\n * root would otherwise stretch to the field's full width. Under `grow` the root\n * spans that width on purpose, so `w-full` overrides it and the ring spans the\n * row with it.\n */\nconst invalidRing =\n \"w-fit rounded-button data-invalid:ring-1 data-invalid:ring-red-500 data-invalid:ring-offset-2 data-invalid:ring-offset-brand-50 dark:data-invalid:ring-offset-brand-950\"\n\ntype BaseRootProps = Omit<\n Ark.RootProps,\n \"color\" | \"multiple\" | \"value\" | \"defaultValue\" | \"onValueChange\" | \"deselectable\" | \"onChange\"\n> &\n WithTestId & {\n /** Palette for every item, as a `data-color` on the group. */\n color?: Color\n /** Treatment of the unselected items. */\n variant?: ButtonVariant\n /** Treatment of the selected items. */\n selectedVariant?: ButtonVariant\n size?: ButtonSize\n /** Red invalid ring around the group. */\n invalid?: boolean\n /** Span the container and give every item an even share of it, like a tab\n * bar. Without it the group hugs its items. */\n grow?: boolean\n /** Lands on the group root, which forwards focus to its active item. Ark's\n * prop types carry no `ref`, so it is declared here. */\n ref?: Ref<HTMLDivElement>\n children?: ReactNode\n }\n\nconst sameValues = (a: readonly string[], b: readonly string[]) =>\n a.length === b.length && a.every((v, i) => v === b[i])\n\n/**\n * Tab entry for a single-choice group. Every item is `tabindex=-1` while focus is\n * outside, so Tab lands on the root, and zag then forwards focus to the *first*\n * item regardless of the selection. A radio group should land on the checked\n * radio instead, so in single mode the root's own focus is caught in the capture\n * phase and sent to the selected (enabled) item. `stopPropagation` there stops\n * the native event before React's bubble listener runs, which is what keeps\n * zag's `ROOT.FOCUS` (and its deferred focus-first) from firing. With nothing\n * selected, zag's own behaviour stands.\n */\nconst focusSelectedItem = (event: FocusEvent<HTMLDivElement>) => {\n if (event.target !== event.currentTarget) return\n const selected = event.currentTarget.querySelector<HTMLElement>(\n ':scope > [data-state=\"on\"]:not([disabled])',\n )\n if (!selected) return\n event.stopPropagation()\n selected.focus({ preventScroll: true })\n}\n\n/**\n * RTL arrow keys. zag's toggle-group reads `event.key` without passing `dir` to\n * `getEventKey` (its other machines do), so in a right-to-left locale ArrowLeft\n * moves focus visually *right*. In a horizontal RTL group the two keys are\n * caught in the capture phase, before zag's handler, and focus moves to the\n * visually adjacent enabled item instead; zag then picks up the new focus\n * through the item's own `onFocus`. `dir` is read off the root, where the\n * machine writes the locale's direction.\n */\nconst mirrorRtlArrows = (loop: boolean) => (event: KeyboardEvent<HTMLDivElement>) => {\n const root = event.currentTarget\n if (root.dir !== \"rtl\" || root.getAttribute(\"data-orientation\") !== \"horizontal\") return\n if (event.key !== \"ArrowLeft\" && event.key !== \"ArrowRight\") return\n const items = Array.from(\n root.querySelectorAll<HTMLElement>(':scope > [data-part=\"item\"]:not([disabled])'),\n )\n const index = items.indexOf(event.target as HTMLElement)\n if (index === -1) return\n event.preventDefault()\n event.stopPropagation()\n // Visually left is the next item in RTL, visually right the previous one.\n const step = event.key === \"ArrowLeft\" ? 1 : -1\n const next = loop\n ? items[(index + step + items.length) % items.length]\n : items[Math.min(Math.max(index + step, 0), items.length - 1)]\n next?.focus()\n}\n\n/** The shared root behind both `ButtonSelect.Root` and `ButtonMultiSelect.Root`. */\nexport const RootBase = ({\n multiple,\n value,\n defaultValue,\n onValueChange,\n deselectable,\n orientation = \"horizontal\",\n color,\n variant = \"light\",\n selectedVariant = \"filled\",\n size = \"md\",\n invalid,\n grow,\n loopFocus = true,\n className,\n testId,\n children,\n ...rest\n}: BaseRootProps & {\n multiple: boolean\n value?: string[]\n defaultValue?: string[]\n onValueChange?: (value: string[]) => void\n deselectable?: boolean\n}) => {\n const field = useFieldContext()\n // Owned here so a change can be compared with the current value: in a\n // non-deselectable single group the machine re-emits the same value when the\n // selected item is clicked again, and that is not a change.\n const [selected, setSelected] = useUncontrolled<string[]>({\n value,\n defaultValue,\n finalValue: [],\n onChange: onValueChange,\n })\n return (\n <ButtonSelectStyleContext.Provider value={{ variant, selectedVariant, size }}>\n <Ark.Root\n multiple={multiple}\n value={selected}\n onValueChange={(details) => {\n if (!sameValues(details.value, selected)) setSelected(details.value)\n }}\n deselectable={deselectable}\n orientation={orientation}\n loopFocus={loopFocus}\n onFocusCapture={multiple ? undefined : focusSelectedItem}\n onKeyDownCapture={mirrorRtlArrows(loopFocus)}\n data-color={color}\n {...props({ \"aria-invalid\": invalid, \"data-invalid\": invalid, \"data-testid\": testId })}\n {...fieldA11yProps(field)}\n className={cn(\n buttonGroupVariants({ orientation, grow }),\n invalidRing,\n grow && \"w-full\",\n className,\n )}\n {...rest}\n >\n {children}\n </Ark.Root>\n </ButtonSelectStyleContext.Provider>\n )\n}\n\nexport type ButtonSelectRootProps = BaseRootProps & {\n /** Controlled value. `null` clears the selection. */\n value?: string | null\n /** Uncontrolled initial value. */\n defaultValue?: string | null\n /** Fires with the newly selected value — `null` only when `deselectable`. */\n onChange?: (value: string | null) => void\n /** Clicking the selected item clears the selection. Off by default, so the\n * group behaves like a radio group. */\n deselectable?: boolean\n}\n\nconst toArray = (value: string | null | undefined) =>\n value === undefined ? undefined : value === null ? [] : [value]\n\n/** Single-choice root: one selected item at most. */\nexport const Root = ({\n value,\n defaultValue,\n onChange,\n deselectable = false,\n ...rest\n}: ButtonSelectRootProps) => (\n <RootBase\n multiple={false}\n value={toArray(value)}\n defaultValue={toArray(defaultValue)}\n onValueChange={(next) => onChange?.(next[0] ?? null)}\n deselectable={deselectable}\n {...rest}\n />\n)\n\nexport type ButtonMultiSelectRootProps = BaseRootProps & {\n /** Controlled value. */\n value?: string[]\n /** Uncontrolled initial value. */\n defaultValue?: string[]\n /** Fires with every selected value, in selection order. */\n onChange?: (value: string[]) => void\n}\n\n/** Multiple-choice root: each item toggles independently. */\nexport const MultiRoot = ({ onChange, ...rest }: ButtonMultiSelectRootProps) => (\n <RootBase multiple onValueChange={onChange} {...rest} />\n)\n\n/** The props `Item` hands a custom control under `asChild`. */\ntype SelectableControlProps = { variant?: ButtonVariant; size?: ButtonSize }\n\nexport type ButtonSelectItemProps =\n | (Omit<ButtonProps, \"value\" | \"variant\" | \"size\" | \"loading\" | \"asChild\"> & {\n /** The value this item selects. */\n value: string\n asChild?: false\n })\n | {\n /** The value this item selects. */\n value: string\n disabled?: boolean\n /**\n * Render your own variant-aware control instead of a `Button` — e.g. an\n * `ActionIcon` for an icon-only toolbar. The single child receives the\n * selection-driven `variant` and the group `size` (its own `size` wins),\n * plus the machine's item props.\n */\n asChild: true\n children: ReactElement<SelectableControlProps>\n }\n\n/**\n * One option, rendered as a `Button`. Its `variant` follows the selection (from\n * `Root`'s `variant` / `selectedVariant`); every other `Button` prop — `color`,\n * `startSlot`, `endSlot`, `aria-label` for an icon-only item, `testId` — passes\n * through. The machine's item props land on the button via Ark's `asChild`.\n *\n * With `asChild`, the single child is rendered in place of the `Button` and\n * cloned with the same `variant` / `size`, so any control speaking the kit's\n * variant × size vocabulary (`ActionIcon`, a consumer's own) can be an item.\n */\nexport const Item = (props: ButtonSelectItemProps) => {\n const { variant, selectedVariant, size } = useContext(ButtonSelectStyleContext)\n const { value, disabled } = props\n const { pressed } = useToggleGroupContext().getItemState({ value, disabled })\n const resolvedVariant = pressed ? selectedVariant : variant\n if (props.asChild) {\n const child = Children.only(props.children)\n return (\n <Ark.Item value={value} disabled={disabled} asChild>\n {cloneElement(child, { variant: resolvedVariant, size: child.props.size ?? size })}\n </Ark.Item>\n )\n }\n const { value: _value, disabled: _disabled, asChild: _asChild, ...rest } = props\n return (\n <Ark.Item value={value} disabled={disabled} asChild>\n <Button variant={resolvedVariant} size={size} {...rest} />\n </Ark.Item>\n )\n}\n\n/**\n * One hidden input per selected value, so a native `<form>` submit carries the\n * selection under `name`. Rendered *beside* the root, never inside it: the join\n * selectors target the root's children by `:first-child` / `:last-child`, which a\n * trailing input would throw off.\n */\nexport const HiddenInputs = ({\n name,\n value,\n disabled,\n}: {\n name?: string\n value: readonly string[]\n disabled?: boolean\n}) =>\n name == null\n ? null\n : value.map((v) => <input key={v} type=\"hidden\" name={name} value={v} disabled={disabled} />)\n\nexport const Context = Ark.Context\n","import type { ReactNode } from \"react\"\nimport type { Color } from \"../../lib/colors\"\n\n/**\n * One option of a data-driven `ButtonSelect` / `ButtonMultiSelect`: a bare\n * value-as-label string, or a labelled object. `payload` is arbitrary data the\n * machine ignores; it reaches `renderItem` typed off the `data` shape — the same\n * contract as `SegmentGroup` and `Select`.\n */\nexport type ButtonSelectItem<P = unknown> =\n | string\n | {\n value: string\n label?: ReactNode\n /** Content before the label, e.g. an icon (Button's `startSlot`). */\n startSlot?: ReactNode\n /** Content after the label (Button's `endSlot`). */\n endSlot?: ReactNode\n disabled?: boolean\n /** Overrides the group palette for this item. */\n color?: Color\n /** Accessible name — required when `label` is an icon only. */\n \"aria-label\"?: string\n /** Arbitrary extra data, surfaced to `renderItem`. */\n payload?: P\n /** `data-testid` on the rendered button. Defaults to `` `item-${value}` ``. */\n testId?: string\n }\n\n/** The `data` array both components are generic over. */\nexport type ButtonSelectData<P = unknown> = ReadonlyArray<ButtonSelectItem<P>>\n\n/** The value-string union of a `ButtonSelectData` shape; a `const` type\n * parameter narrows it to the literal union. */\nexport type ButtonSelectValue<Data extends ButtonSelectData> = ItemValue<Data[number]>\ntype ItemValue<E> = E extends string ? E : E extends { value: infer V extends string } ? V : never\n\n/** The `payload` type carried by a `ButtonSelectData` shape. */\nexport type ButtonSelectPayload<Data extends ButtonSelectData> = PayloadOf<Data[number]>\ntype PayloadOf<T> = T extends string ? never : T extends { payload?: infer P } ? P : never\n\n/** The item handed to `renderItem`, narrowed to the data's value and payload. */\nexport type RenderableButtonSelectItem<Data extends ButtonSelectData> = {\n value: ButtonSelectValue<Data>\n label: ReactNode\n disabled: boolean\n color: Color | undefined\n payload: ButtonSelectPayload<Data> | undefined\n}\n\n/** Live item state passed alongside the item to `renderItem`. */\nexport type ButtonSelectItemState = {\n selected: boolean\n disabled: boolean\n}\n\n/**\n * Render an item's label yourself. The item keeps its button, sizing, variant\n * and selection wiring; you fill its content. In an RSC tree the function must\n * live in a `\"use client\"` module.\n */\nexport type RenderButtonSelectItem<Data extends ButtonSelectData> = (\n item: RenderableButtonSelectItem<Data>,\n state: ButtonSelectItemState,\n) => ReactNode\n\n/** A fully resolved item — every field present (`label` falls back to `value`). */\nexport type NormalizedButtonSelectItem = {\n value: string\n label: ReactNode\n startSlot: ReactNode\n endSlot: ReactNode\n disabled: boolean\n color: Color | undefined\n ariaLabel: string | undefined\n payload: unknown\n testId: string\n}\n\nexport const normalizeButtonSelectItem = (item: ButtonSelectItem): NormalizedButtonSelectItem =>\n typeof item === \"string\"\n ? {\n value: item,\n label: item,\n startSlot: undefined,\n endSlot: undefined,\n disabled: false,\n color: undefined,\n ariaLabel: undefined,\n payload: undefined,\n testId: `item-${item}`,\n }\n : {\n value: item.value,\n label: item.label ?? item.value,\n startSlot: item.startSlot,\n endSlot: item.endSlot,\n disabled: item.disabled ?? false,\n color: item.color,\n ariaLabel: item[\"aria-label\"],\n payload: item.payload,\n testId: item.testId ?? `item-${item.value}`,\n }\n","\"use client\"\n\nimport type { FocusEvent, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport type { ButtonSize, ButtonVariant } from \"../button/button\"\nimport { type FieldProps, FieldShell } from \"../field/field\"\nimport { HiddenInputs, Item, RootBase } from \"./button-select\"\nimport {\n type ButtonSelectData,\n normalizeButtonSelectItem,\n type RenderButtonSelectItem,\n} from \"./button-select-items\"\n\ntype ButtonSelectClassNames = {\n field?: string\n /** The label element itself — e.g. `\"sr-only\"` to keep the accessible name\n * without showing it. */\n label?: string\n root?: string\n item?: string\n}\n\n/** Props shared by the data-driven `ButtonSelect` and `ButtonMultiSelect`. */\nexport type ButtonSelectBaseProps<Data extends ButtonSelectData> = Pick<\n FieldProps,\n \"label\" | \"description\" | \"error\" | \"required\"\n> &\n WithTestId & {\n /** Items: bare strings (`value === label`) or `{ value, label?, startSlot?, … }`. */\n data: Data\n /** Render each item's content yourself, with its typed `payload`. */\n renderItem?: RenderButtonSelectItem<Data>\n /** Lay the items in a row (default) or a column. */\n orientation?: \"horizontal\" | \"vertical\"\n /** Red invalid state, independent of (and OR'd with) `error`. */\n invalid?: boolean\n /** Span the container and give every item an even share of it, like a tab\n * bar. Without it the group hugs its items. */\n grow?: boolean\n /** Dims and blocks every item. */\n disabled?: boolean\n size?: ButtonSize\n /** Treatment of the unselected items. Defaults to `light`. */\n variant?: ButtonVariant\n /** Treatment of the selected items. Defaults to `filled`. */\n selectedVariant?: ButtonVariant\n color?: Color\n /** Renders a hidden input per selected value for native form submission. */\n name?: string\n /** Explicit id for the group root. */\n id?: string\n /** Lands on the group root, which forwards focus to its active item. */\n ref?: Ref<HTMLDivElement>\n /** Forwarded to the root; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n className?: string\n classNames?: ButtonSelectClassNames\n }\n\n/**\n * The rendering both data forms share: the `Field` wrapper, the group root, one\n * `Item` per entry and the hidden inputs. The public components only adapt their\n * value shape (`V | null` or `V[]`) onto the machine's `string[]`.\n */\nexport const ButtonSelectControl = ({\n multiple,\n deselectable,\n value,\n onValueChange,\n data,\n renderItem,\n orientation,\n invalid,\n grow,\n disabled,\n required,\n size = \"md\",\n variant,\n selectedVariant,\n color,\n name,\n id,\n ref,\n onBlur,\n label,\n description,\n error,\n className,\n classNames,\n testId,\n}: ButtonSelectBaseProps<ButtonSelectData> & {\n multiple: boolean\n deselectable?: boolean\n value: readonly string[]\n onValueChange: (value: string[]) => void\n}) => {\n // Red state is driven independently of the `Field` error slot so a form\n // library can flip it from `fieldState.invalid` (see FormControlProps).\n const isInvalid = invalid || error != null\n const items = data.map(normalizeButtonSelectItem)\n\n return (\n <FieldShell\n label={label}\n description={description}\n error={error}\n required={required}\n disabled={disabled}\n size={size}\n className={classNames?.field}\n classNames={{ label: classNames?.label }}\n >\n <RootBase\n multiple={multiple}\n deselectable={deselectable}\n value={[...value]}\n onValueChange={onValueChange}\n orientation={orientation}\n disabled={disabled}\n invalid={isInvalid}\n grow={grow}\n size={size}\n variant={variant}\n selectedVariant={selectedVariant}\n color={color}\n id={id}\n ref={ref}\n onBlur={onBlur}\n testId={testId}\n className={cn(className, classNames?.root)}\n >\n {items.map((item) => (\n <Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n color={item.color}\n startSlot={item.startSlot}\n endSlot={item.endSlot}\n aria-label={item.ariaLabel}\n testId={item.testId}\n className={classNames?.item}\n >\n {renderItem\n ? renderItem(item, {\n selected: value.includes(item.value),\n disabled: Boolean(disabled) || item.disabled,\n })\n : item.label}\n </Item>\n ))}\n </RootBase>\n <HiddenInputs name={name} value={value} disabled={disabled} />\n </FieldShell>\n )\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { TimeRow, resolveHourCycle, timeRowMinWidth, toDisplayHour, fromDisplayHour, is12Hour, dayPeriodLabels } from './chunk-ULF5LOBS.js';
2
- import { CalendarBody, CalendarZoneSync, calendarGridWidth, hashArkValues, resolveCalendarTranslations } from './chunk-E52Z2FKU.js';
2
+ import { CalendarBody, CalendarZoneSync, calendarGridWidth, hashArkValues, resolveCalendarTranslations } from './chunk-7BY5I2RB.js';
3
3
  import { calendarValueToDate, dateToArkValue, fromArkValues, toArkValues } from './chunk-ZB5VMGKB.js';
4
4
  import { controlOpenProps } from './chunk-5FDOOG4J.js';
5
5
  import { inputSlot, inputControlClasses, shellGap, placeholderColor, inputShell } from './chunk-I4B3N3UX.js';
6
6
  import { FieldShell, fieldA11yProps } from './chunk-X6DESK37.js';
7
7
  import { capitalize } from './chunk-DHM4IG2O.js';
8
- import { Button } from './chunk-SCXXJDKQ.js';
8
+ import { Button } from './chunk-SP6LCCTZ.js';
9
9
  import { useMergedRefs } from './chunk-HBWV5EPU.js';
10
10
  import { useTimeZone, useLocale } from './chunk-IUK7OJXZ.js';
11
11
  import { Popover, popoverClearTrigger, popoverPanel } from './chunk-RKCUXOU2.js';
@@ -684,5 +684,5 @@ var DatePicker = Object.assign(DatePickerImpl, {
684
684
  });
685
685
 
686
686
  export { DatePicker, serializeDateValue };
687
- //# sourceMappingURL=chunk-MNYY7UU2.js.map
688
- //# sourceMappingURL=chunk-MNYY7UU2.js.map
687
+ //# sourceMappingURL=chunk-GJFCIG34.js.map
688
+ //# sourceMappingURL=chunk-GJFCIG34.js.map