@42-central/ui-react 0.28.0 → 0.29.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 (108) hide show
  1. package/dist/{chunk-I53TMAV2.js → chunk-2RQLPN4U.js} +3 -3
  2. package/dist/{chunk-I53TMAV2.js.map → chunk-2RQLPN4U.js.map} +1 -1
  3. package/dist/{chunk-SOUDKESO.js → chunk-37HYN7PC.js} +3 -3
  4. package/dist/{chunk-SOUDKESO.js.map → chunk-37HYN7PC.js.map} +1 -1
  5. package/dist/{chunk-TGGNSSOJ.js → chunk-5EOMSWNO.js} +4 -4
  6. package/dist/{chunk-TGGNSSOJ.js.map → chunk-5EOMSWNO.js.map} +1 -1
  7. package/dist/{chunk-K3FZHYJL.js → chunk-7FPSQBWB.js} +3 -3
  8. package/dist/{chunk-K3FZHYJL.js.map → chunk-7FPSQBWB.js.map} +1 -1
  9. package/dist/{chunk-WERJ44ZN.js → chunk-DTFSCR3U.js} +3 -3
  10. package/dist/{chunk-WERJ44ZN.js.map → chunk-DTFSCR3U.js.map} +1 -1
  11. package/dist/{chunk-PFZMB3US.js → chunk-FQJNQW3G.js} +3 -3
  12. package/dist/{chunk-PFZMB3US.js.map → chunk-FQJNQW3G.js.map} +1 -1
  13. package/dist/{chunk-ASKQ6N5V.js → chunk-FSPS7TVD.js} +4 -4
  14. package/dist/{chunk-ASKQ6N5V.js.map → chunk-FSPS7TVD.js.map} +1 -1
  15. package/dist/{chunk-GJFCIG34.js → chunk-GEZYGBXY.js} +5 -5
  16. package/dist/{chunk-GJFCIG34.js.map → chunk-GEZYGBXY.js.map} +1 -1
  17. package/dist/{chunk-ULF5LOBS.js → chunk-HMNXNKDA.js} +3 -3
  18. package/dist/{chunk-ULF5LOBS.js.map → chunk-HMNXNKDA.js.map} +1 -1
  19. package/dist/{chunk-NF2PBGD3.js → chunk-IANYMDKH.js} +3 -3
  20. package/dist/{chunk-NF2PBGD3.js.map → chunk-IANYMDKH.js.map} +1 -1
  21. package/dist/{chunk-QEMXXQQO.js → chunk-JKFPRQB2.js} +3 -3
  22. package/dist/{chunk-QEMXXQQO.js.map → chunk-JKFPRQB2.js.map} +1 -1
  23. package/dist/{chunk-P7SH3XWY.js → chunk-MQHD3EJE.js} +3 -3
  24. package/dist/{chunk-P7SH3XWY.js.map → chunk-MQHD3EJE.js.map} +1 -1
  25. package/dist/{chunk-IUK7OJXZ.js → chunk-OBSZ4NE2.js} +5 -4
  26. package/dist/chunk-OBSZ4NE2.js.map +1 -0
  27. package/dist/{chunk-DJ72KP32.js → chunk-OXR7BXZA.js} +3 -3
  28. package/dist/{chunk-DJ72KP32.js.map → chunk-OXR7BXZA.js.map} +1 -1
  29. package/dist/{chunk-LIZWCWED.js → chunk-PQZSTI3R.js} +3 -3
  30. package/dist/{chunk-LIZWCWED.js.map → chunk-PQZSTI3R.js.map} +1 -1
  31. package/dist/{chunk-7BY5I2RB.js → chunk-S5CQRCTF.js} +4 -4
  32. package/dist/{chunk-7BY5I2RB.js.map → chunk-S5CQRCTF.js.map} +1 -1
  33. package/dist/{chunk-BGDVUC3B.js → chunk-TUP7WXQE.js} +3 -3
  34. package/dist/{chunk-BGDVUC3B.js.map → chunk-TUP7WXQE.js.map} +1 -1
  35. package/dist/{chunk-KYVXPSNW.js → chunk-V2QZG4IT.js} +3 -3
  36. package/dist/{chunk-KYVXPSNW.js.map → chunk-V2QZG4IT.js.map} +1 -1
  37. package/dist/components/alert/index.js +1 -1
  38. package/dist/components/ambient-background/index.js +1 -1
  39. package/dist/components/app-shell/index.js +3 -3
  40. package/dist/components/avatar/index.js +2 -2
  41. package/dist/components/calendar/index.js +3 -3
  42. package/dist/components/calendar-heatmap/index.js +2 -2
  43. package/dist/components/camera/index.js +3 -3
  44. package/dist/components/carousel/index.js +2 -2
  45. package/dist/components/code-block/index.js +1 -1
  46. package/dist/components/code-block/static.js.map +1 -1
  47. package/dist/components/compare/index.js +2 -2
  48. package/dist/components/data-table/index.js +10 -10
  49. package/dist/components/date-picker/index.js +7 -7
  50. package/dist/components/drawer/index.js +3 -3
  51. package/dist/components/file-item/index.js +4 -4
  52. package/dist/components/file-preview/index.js +3 -3
  53. package/dist/components/file-upload/index.js +4 -4
  54. package/dist/components/gallery/index.js +2 -2
  55. package/dist/components/image-cropper/index.js +4 -4
  56. package/dist/components/indicator/index.js +1 -1
  57. package/dist/components/kbd/index.js +3 -3
  58. package/dist/components/lightbox/index.js +4 -4
  59. package/dist/components/menu/index.js +2 -2
  60. package/dist/components/modal/index.js +3 -3
  61. package/dist/components/multi-select/index.js +3 -3
  62. package/dist/components/overlays/index.js +4 -4
  63. package/dist/components/password-input/index.js +1 -1
  64. package/dist/components/phone-input/flag.d.ts +9 -0
  65. package/dist/components/phone-input/flag.d.ts.map +1 -0
  66. package/dist/components/phone-input/index.d.ts +4 -0
  67. package/dist/components/phone-input/index.d.ts.map +1 -0
  68. package/dist/components/phone-input/index.js +503 -0
  69. package/dist/components/phone-input/index.js.map +1 -0
  70. package/dist/components/phone-input/phone-input.d.ts +125 -0
  71. package/dist/components/phone-input/phone-input.d.ts.map +1 -0
  72. package/dist/components/phone-input/phone.d.ts +117 -0
  73. package/dist/components/phone-input/phone.d.ts.map +1 -0
  74. package/dist/components/photo-capture/index.js +5 -5
  75. package/dist/components/pills-input/index.js +3 -3
  76. package/dist/components/schedule/index.js +3 -3
  77. package/dist/components/segment-group/index.js +3 -3
  78. package/dist/components/spotlight/index.js +5 -5
  79. package/dist/components/tabs/index.js +3 -3
  80. package/dist/components/tags-input/index.js +3 -3
  81. package/dist/components/time-input/index.js +4 -4
  82. package/dist/components/timeline/index.d.ts +1 -1
  83. package/dist/components/timeline/index.d.ts.map +1 -1
  84. package/dist/components/timeline/index.js +40 -11
  85. package/dist/components/timeline/index.js.map +1 -1
  86. package/dist/components/timeline/timeline.d.ts +8 -3
  87. package/dist/components/timeline/timeline.d.ts.map +1 -1
  88. package/dist/components/tree-multi-select/index.js +3 -3
  89. package/dist/index.js +4 -4
  90. package/dist/lib/dev-warn.d.ts +1 -0
  91. package/dist/lib/dev-warn.d.ts.map +1 -1
  92. package/dist/lib/intl.d.ts +5 -0
  93. package/dist/lib/intl.d.ts.map +1 -1
  94. package/package.json +3 -1
  95. package/src/as-child.contract.test.tsx +2 -0
  96. package/src/components/phone-input/flag.tsx +86 -0
  97. package/src/components/phone-input/index.ts +14 -0
  98. package/src/components/phone-input/phone-input.test.tsx +285 -0
  99. package/src/components/phone-input/phone-input.tsx +527 -0
  100. package/src/components/phone-input/phone.test.ts +187 -0
  101. package/src/components/phone-input/phone.ts +298 -0
  102. package/src/components/timeline/index.ts +1 -0
  103. package/src/components/timeline/timeline.test.tsx +105 -4
  104. package/src/components/timeline/timeline.tsx +46 -11
  105. package/src/lib/dev-warn.ts +1 -1
  106. package/src/lib/intl-direction.test.tsx +23 -0
  107. package/src/lib/intl.tsx +8 -2
  108. package/dist/chunk-IUK7OJXZ.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/segment-group/segment-group.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;AAsEA,IAAM,OAAA,GAAU,GAAA;AAAA,EACd;AAAA,IACE,aAAA;AAAA,IACA,wEAAA;AAAA,IACA,kBAAA,CAAmB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKnB,8FAAA;AAAA,IACA,mBAAA;AAAA,IACA,2DAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,MAAA,EAAQ,0CAAA;AAAA,QACR,KAAA,EAAO,sCAAA;AAAA,QACP,OAAA,EAAS,sCAAA;AAAA,QACT,MAAA,EAAQ,sCAAA;AAAA,QACR,OAAA,EAAS;AAAA,OACX;AAAA,MACA,IAAA,EAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI,iDAAA;AAAA,QACJ,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cAAA,CAAI,WAAA,EAAJ,EACE,QAAA,EAAA,CAAC,GAAA,KACA,WAAW,IAAA,EAA4C;AAAA,wBACrD,SAAS,GAAA,CAAI,OAAA;AAAA,wBACb,UAAU,GAAA,CAAI;AAAA,uBACf,CAAA,EAEL,CAAA,GAEA,IAAA,CAAK;AAAA;AAAA,mBAET;AAAA,kCACA,GAAA,CAACA,cAAA,CAAI,WAAA,EAAJ,EAAgB,CAAA;AAAA,kCACjB,GAAA,CAACA,cAAA,CAAI,eAAA,EAAJ,EAAoB;AAAA;AAAA,eAAA;AAAA,cA1BhB,IAAA,CAAK;AAAA,aA4Bb;AAAA;AAAA,SAAA;AAAA,QA/EI;AAAA;AAgFP;AAAA,GACF;AAEJ","file":"chunk-NF2PBGD3.js","sourcesContent":["\"use client\"\n\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { SegmentGroup as Ark } from \"@ark-ui/react/segment-group\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { FocusEvent, ReactNode, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { useDirectionCheck } from \"../../lib/intl\"\nimport { useMergedRefs } from \"../../lib/merge-refs\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport { useUncontrolled } from \"../../lib/use-uncontrolled\"\nimport { type FieldProps, FieldShell, fieldA11yProps } from \"../field/field\"\n\n/**\n * SegmentGroup — a segmented single-choice control on Ark UI's SegmentGroup\n * machine (the radio-group model under the hood). It renders a row (or column)\n * of mutually exclusive segments with a sliding pill that animates to the\n * selected item. Use it as a compact, always-visible alternative to a `Select`\n * when the option set is small (2–5 items): view toggles, filters, billing\n * cadence, and the like.\n *\n * - Value is a single `string | null`; `onChange` hands it to you directly,\n * matching the kit's value-based `FormControlProps` contract.\n * - `data` accepts bare strings (`value === label`) or\n * `{ value, label?, disabled?, color?, payload? }` objects, mixed freely.\n * The component is generic over `data` (a `const` type parameter), so\n * `value` / `onChange` narrow to the literal value union and an item's\n * `payload` flows—typed—into `renderItem` (the same contract as `Select`).\n * - Label / description / error / required come from the built-in `Field`\n * wrapper, so a `SegmentGroup` is accessible and complete on its own.\n * - `name` renders a hidden radio input per item, so the selected value rides\n * a native `<form>` submission.\n *\n * `variant` mirrors the `Button` family (`filled` / `light` / `outline` /\n * `subtle` / `default`): the tray, the sliding pill, and the checked label all\n * adopt the variant's treatment off the shared `--c-*` slots. Palette rides on\n * `data-color`, so every kit color tints for free, `default` included — its pill\n * falls back to solid black/white with no color set, because `:root` defines\n * `--c-solid`/`--c-on-solid` as black/white (white/brand-950 under dark). A\n * per-item `color` overrides the group palette for whichever segment is\n * selected: it re-stamps `data-color` on that item and on the pill, so both\n * the fill and the checked label resolve from the same block.\n *\n * The moving pill is the Ark `Indicator`: Ark positions it absolutely via the\n * CSS vars `--left` / `--top` / `--width` / `--height` (the selected segment's\n * measured rect), so it sits *behind* the labels (`z-0`). Ark only re-measures\n * that rect on mount and on value change — not when `orientation` flips — so we\n * remount the root with `key={orientation}` to force a fresh measure on the new\n * axis. The value is held in `useUncontrolled` so the selection survives that\n * remount.\n */\n\n/**\n * Per-segment label: size sets the padding / text, `variant` sets the *checked*\n * text color so it reads against that variant's pill. The unchecked color is a\n * neutral gray applied at the call site.\n *\n * The checked label must come from the same source as the pill under it.\n * `default` and `filled` both paint `bg-(--c-solid)`, so both take\n * `--c-on-solid` — which resolves per-item, since each `ItemText` carries its\n * own `data-color`. Pairing a hard-coded neutral foreground with a `--c-solid`\n * fill is what broke `default` at any group `color` (#140): the pill moved with\n * the palette and the label stayed put, reaching 3.27:1 on brand. There is\n * deliberately no hover shift on the checked label — `Button`'s `filled` moves\n * only the background and keeps `--c-on-solid`, and no `--c-on-solid-hover`\n * slot exists in `colors.css`.\n */\nconst segItem = cva(\n [\n \"font-medium\",\n \"cursor-pointer rounded-input text-center whitespace-nowrap select-none\",\n TEXT_COLOR_CLASSES.secondary,\n // Only unchecked segments get the hover lift, as in Tabs. An\n // unscoped `hover:` ties on specificity with the checked foreground and\n // won on source order in dark theme, washing the checked label to\n // near-white over a colored pill.\n \"not-data-[state=checked]:hover:text-brand-950 dark:not-data-[state=checked]:hover:text-white\",\n \"transition-colors\",\n \"data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n \"group-data-invalid:text-red-900 dark:group-data-invalid:text-red-500\",\n ],\n {\n variants: {\n variant: {\n filled: \"data-[state=checked]:text-(--c-on-solid)\",\n light: \"data-[state=checked]:text-(--c-text)\",\n outline: \"data-[state=checked]:text-(--c-text)\",\n subtle: \"data-[state=checked]:text-(--c-text)\",\n default: \"data-[state=checked]:text-(--c-on-solid)\",\n },\n size: {\n // No vertical padding of its own — the tray's `min-h` (below) sets the\n // box height and this item stretches to fill it (the tray's default\n // `align-items: stretch` propagates all the way down), so the label\n // just needs to center itself inside that taller box. This matches an\n // `Input` / `NumberInput`'s exact box height at the same size.\n xs: \"flex items-center justify-center px-1 text-xs\",\n sm: \"flex items-center justify-center px-1.5 text-sm\",\n md: \"flex items-center justify-center px-2 text-md\",\n lg: \"flex items-center justify-center px-3 text-lg\",\n xl: \"flex items-center justify-center px-4 text-xl\",\n },\n // Fill the (grown) segment so the label centers across its whole share.\n grow: { true: \"w-full\" },\n },\n defaultVariants: { variant: \"default\", size: \"md\" },\n },\n)\n\n/**\n * Per-segment wrapper. Beyond positioning the label above the pill (`z-1`), it\n * draws a hairline separator in the gap to its leading edge (a `::before`) so\n * inactive neighbours read as divided. That rule fades out next to the active\n * pill — on the checked segment and the one right after it — and is suppressed\n * before the first segment (the indicator is child 1, so the first segment is\n * `:nth-child(2)`). It flips from a vertical rule to a horizontal one when the\n * group is laid out vertically.\n */\nconst segItemWrap = cva(\n [\n \"relative z-1 inline-flex\",\n \"before:absolute before:rounded-full before:bg-brand-900/30 dark:before:bg-white/35\",\n \"group-data-invalid:before:bg-red-500/30\",\n \"before:transition-opacity before:duration-200\",\n // Horizontal: a vertical rule centered on the leading edge, sitting in the gap. Logical\n // (`start`, `-ms-[0.5px]` to center the 1px rule), so under `dir=\"rtl\"` the rule still lands\n // between a segment and the one before it instead of on the far side.\n \"before:top-1/2 before:start-0 before:-ms-[0.5px] before:h-1/2 before:w-px before:-translate-y-1/2\",\n // Vertical: a horizontal rule centered on the top edge instead (`start-1/4` + `w-1/2` is\n // centered in either direction).\n \"in-data-[orientation=vertical]:before:top-0 in-data-[orientation=vertical]:before:start-1/4 in-data-[orientation=vertical]:before:ms-0 in-data-[orientation=vertical]:before:h-px in-data-[orientation=vertical]:before:w-1/2\",\n // No separator before the first segment, or flanking the active pill.\n \"nth-2:before:hidden\",\n \"data-[state=checked]:before:opacity-0 data-[state=checked]:[&+*]:before:opacity-0\",\n ],\n {\n variants: {\n // An even share of the tray per segment, like a tab bar.\n grow: { true: \"flex-1\" },\n },\n },\n)\n\n/**\n * The sliding pill, mirroring each `Button` surface. Its slide + color transition\n * is driven by Ark (see the `--transition-*` overrides on the element); `default`\n * follows `--c-solid` like every other variant, which falls back to solid\n * black/white with no `data-color` set. Filled/soft-fill pills (`filled`, `light`,\n * `default`) use a tighter `rounded-xxs` than the tray's own `rounded-input`, for a\n * nested-corner look inside the tray's padding; bordered/transparent pills\n * (`outline`, `subtle`) keep `rounded-input`.\n */\nconst segIndicator = cva(\n [\n \"z-0\",\n // The slide's duration, read by the inline `transition-duration` (see the\n // pill below); reduced motion zeroes it, so the pill jumps instead.\n \"[--indicator-duration:var(--duration-normal)] motion-reduce:[--indicator-duration:0s]\",\n ],\n {\n variants: {\n variant: {\n filled: \"bg-(--c-solid) rounded-xxs\",\n light: \"bg-(--c-soft) border border-(--c-soft-hover) rounded-xxs\",\n outline: \"bg-transparent border border-(--c-solid) rounded-input\",\n subtle: \"bg-(--c-soft-hover) rounded-input\",\n default: \"bg-(--c-solid) rounded-xxs\",\n },\n },\n defaultVariants: { variant: \"default\" },\n },\n)\n\n/**\n * The tray. Mirrors the `Button` variants: `filled` is a borderless neutral fill\n * so the colored pill pops (the kit's quiet `bg-black/3 dark:bg-white/4`; light\n * mode darkens because a bare `bg-white/4` vanishes on a near-white page), `light` / `default` frame the pill with the same\n * translucent surface as `Input`'s own `default` shell (`bg-white/4` + the\n * hairline `border-brand-900/20 dark:border-white/15`) rather than an opaque\n * gray step, so the tray reads correctly on any host background, `subtle` /\n * `outline` are chromeless.\n */\nconst segTray = cva(\n [\n \"relative inline-flex rounded-input border p-0.5 transition-colors max-w-fit group\",\n \"data-[orientation=vertical]:flex-col\",\n \"data-disabled:cursor-not-allowed data-disabled:opacity-60\",\n // Focus halo + accent border, driven by the active palette's `--c-solid`. Keyed\n // off Zag's `data-focus-visible` (set only when the focus came from the keyboard,\n // never a mouse click) via `:has()`, so the ring stays off when you click a segment.\n //\n // Deliberately NOT `focusStyles`. This is the *shell* idiom, not the ring\n // idiom: an accent border plus a soft `/15` halo on a wrapper whose focus\n // lives on a descendant, with a red invalid twin on the identical selector.\n // That is `input.tsx`'s `shellChrome`, not `Button`'s ring — folding it into\n // `focusStyles` would make that helper grow an alpha, a border half and a\n // concept of invalid, for one call site. The two shells are worth sharing\n // with each other instead; see the follow-up issue.\n \"has-data-focus-visible:border-(--c-solid) has-data-focus-visible:ring-2 has-data-focus-visible:ring-(--c-solid)/15\",\n // Invalid wins over the palette: red border + red halo.\n \"data-invalid:border-red-500 data-invalid:has-data-focus-visible:border-red-500 data-invalid:has-data-focus-visible:ring-red-500/15\",\n // Disabled affordances on the shell.\n ],\n {\n variants: {\n variant: {\n filled: [\"bg-black/3 dark:bg-white/4\", \"border-transparent\"],\n light: [\"bg-white/4\", \"border-brand-900/20 dark:border-white/15\"],\n outline: [\"bg-transparent border-transparent\"],\n subtle: [\"bg-transparent border-transparent\"],\n default: [\"bg-white/4\", \"border-brand-900/20 dark:border-white/15\"],\n },\n size: {\n // The exact `min-h` `inputShell` (input.tsx) uses at the same size —\n // so a `SegmentGroup` sits flush with an `Input` / `NumberInput` of\n // the same size in a row (see `TimeRow`, which composes both).\n xs: \"gap-0 min-h-7\",\n sm: \"gap-0 min-h-8\",\n md: \"gap-0 min-h-9\",\n lg: \"gap-0 min-h-10\",\n xl: \"gap-0 min-h-12\",\n },\n // Span the container instead of hugging the labels.\n grow: { true: \"flex w-full max-w-none\" },\n },\n defaultVariants: { variant: \"default\" },\n },\n)\n\nexport type SegmentGroupSize = NonNullable<VariantProps<typeof segItem>[\"size\"]>\nexport type SegmentGroupVariant = VariantProps<typeof segTray>[\"variant\"]\n\n/**\n * A single segment: a bare value-as-label string, or a labelled object. Objects\n * may carry a `payload` of arbitrary data (the machine ignores it; it flows\n * through to `renderItem`, typed off the `data` shape — the same contract as\n * `Select`'s `SelectItem`).\n */\nexport type SegmentGroupItem<P = unknown> =\n | string\n | {\n value: string\n label?: ReactNode\n disabled?: boolean\n /** Overrides the group palette for the pill + label when this item is selected. */\n color?: Color\n /** Arbitrary extra data, surfaced to `renderItem`. */\n payload?: P\n /** `data-testid` on the rendered segment. Defaults to `` `item-${value}` ``. */\n testId?: string\n }\n\n/** The `data` array the component is generic over. */\nexport type SegmentGroupData<P = unknown> = ReadonlyArray<SegmentGroupItem<P>>\n\n/**\n * Extract the value-string union from a `SegmentGroupData` shape — bare strings\n * and item `.value`s both contribute. A `const` type parameter narrows it to the\n * literal union, so `value` / `onChange` are typed off the data (like `Select`).\n */\nexport type SegmentGroupValue<Data extends SegmentGroupData> = ItemValue<Data[number]>\ntype ItemValue<E> = E extends string ? E : E extends { value: infer V extends string } ? V : never\n\n/**\n * Extract the `payload` type carried by a `SegmentGroupData` shape, read\n * structurally off the data's `payload` property. Bare strings contribute\n * `never`; a homogeneous payload resolves precisely, a mixed one to the union.\n */\nexport type SegmentGroupPayload<Data extends SegmentGroupData> = PayloadOf<Data[number]>\ntype PayloadOf<T> = T extends string ? never : T extends { payload?: infer P } ? P : never\n\n/**\n * The segment handed to `renderItem`: `value` narrowed to the data's value union\n * and `payload` to the data's payload type, so a `const`-typed `data` yields\n * literal values and a precise payload in the callback.\n */\nexport type RenderableSegment<Data extends SegmentGroupData> = {\n value: SegmentGroupValue<Data>\n label: ReactNode\n disabled: boolean\n color: Color | undefined\n payload: SegmentGroupPayload<Data> | undefined\n}\n\n/** Live segment state passed alongside the item to `renderItem`. */\nexport type SegmentRenderState = {\n checked: boolean\n disabled: boolean\n}\n\n/**\n * Render a segment's label content yourself. Receives the (value-narrowed) item —\n * including its typed `payload` — and its live `{ checked, disabled }` state. The\n * segment keeps its sizing, pill, and selection wiring; you fill the label. In an\n * RSC tree the function must live in a `\"use client\"` module so the boundary\n * serializes it as a client reference.\n */\nexport type RenderSegment<Data extends SegmentGroupData> = (\n item: RenderableSegment<Data>,\n state: SegmentRenderState,\n) => ReactNode\n\ntype SegmentGroupClassNames = {\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 indicator?: string\n item?: string\n itemText?: string\n}\n\nexport type SegmentGroupProps<Data extends SegmentGroupData = SegmentGroupData> = Pick<\n FieldProps,\n \"label\" | \"description\" | \"error\" | \"required\"\n> &\n WithTestId & {\n /** Segments: bare strings (`value === label`) or `{ value, label?, disabled?, color?, payload? }`. */\n data: Data\n /** Controlled value. `null` clears the selection. */\n value?: SegmentGroupValue<Data> | null\n /** Uncontrolled initial value. */\n defaultValue?: SegmentGroupValue<Data> | null\n /** Fires with the selected value. */\n onChange?: (value: SegmentGroupValue<Data>) => void\n /** Render each segment's label content yourself, with its typed `payload`. */\n renderItem?: RenderSegment<Data>\n /** Lay the segments 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 /** Dims and blocks interaction. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits. */\n readOnly?: boolean\n /** `xs`–`xl` match the exact box height of an `Input` / `NumberInput` at\n * that size, so a `SegmentGroup` composes flush inline next to one (see\n * `TimeInput`'s AM/PM toggle). */\n size?: SegmentGroupSize\n variant?: SegmentGroupVariant\n color?: Color\n /** Span the container and give every segment an even share of it, like a\n * tab bar. Without it the group hugs its labels. */\n grow?: boolean\n /** Wires the hidden radio inputs into native form submission. */\n name?: string\n /** Explicit id for label association. */\n id?: string\n /** Lands on the root for focus-on-error. */\n ref?: Ref<HTMLDivElement>\n /** Forwarded to the root; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n className?: string\n classNames?: SegmentGroupClassNames\n }\n\n/** A fully resolved segment — every field present (`label` falls back to `value`). */\ntype NormalizedItem = {\n value: string\n label: ReactNode\n disabled: boolean\n color: Color | undefined\n payload: unknown\n testId: string\n}\n\n/** Normalize a bare string / object into the resolved `NormalizedItem` form. */\nconst normalizeItem = (item: SegmentGroupItem): NormalizedItem =>\n typeof item === \"string\"\n ? {\n value: item,\n label: item,\n disabled: false,\n color: undefined,\n payload: undefined,\n testId: `item-${item}`,\n }\n : {\n value: item.value,\n label: item.label ?? item.value,\n disabled: item.disabled ?? false,\n color: item.color,\n payload: item.payload,\n testId: item.testId ?? `item-${item.value}`,\n }\n\n/**\n * The real `role=\"radiogroup\"` root (and, through it, each item's hidden\n * radio input), split out so it reads the `Field` context from *inside* the\n * wrapping `FieldShell` — `SegmentGroup` itself renders that shell, so\n * calling `useFieldContext()` at its own top level would run too early.\n * Takes plain `string` values rather than the outer component's `Data`-typed\n * union: it only forwards them, so no generic type parameter is needed here.\n */\nconst SegmentGroupRoot = ({\n value,\n onValueChange,\n disabled,\n readOnly,\n required,\n invalid,\n orientation,\n name,\n id,\n ref,\n onBlur,\n color,\n className,\n testId,\n children,\n}: {\n value: string | null\n onValueChange: (value: string | null) => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n invalid: boolean\n orientation: \"horizontal\" | \"vertical\"\n name?: string\n id?: string\n ref?: Ref<HTMLDivElement>\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n color?: Color\n className?: string\n children: ReactNode\n} & WithTestId) => {\n const field = useFieldContext()\n const checkDirection = useDirectionCheck()\n const rootRef = useMergedRefs(ref, checkDirection)\n return (\n <Ark.Root\n value={value}\n onValueChange={(d) => onValueChange(d.value)}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n invalid={invalid}\n orientation={orientation}\n name={name}\n id={id}\n ref={rootRef}\n onBlur={onBlur}\n data-color={color}\n {...props({ \"data-invalid\": invalid, \"data-testid\": testId })}\n {...fieldA11yProps(field)}\n className={className}\n >\n {children}\n </Ark.Root>\n )\n}\n\nexport const SegmentGroup = <const Data extends SegmentGroupData = SegmentGroupData>({\n data,\n value,\n defaultValue,\n onChange,\n renderItem,\n orientation = \"horizontal\",\n invalid,\n disabled,\n readOnly,\n required,\n size = \"md\",\n variant = \"default\",\n color,\n grow,\n name,\n id,\n ref,\n onBlur,\n label,\n description,\n error,\n className,\n classNames,\n testId,\n}: SegmentGroupProps<Data>) => {\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\n // Own the value so the pill can read which item is selected (per-item color)\n // and so the `key={orientation}` remount below preserves the selection.\n const [selectedValue, setSelectedValue] = useUncontrolled<SegmentGroupValue<Data> | null>({\n value,\n defaultValue,\n finalValue: null,\n onChange: (v) => v != null && onChange?.(v),\n })\n\n const normalized = (data as SegmentGroupData).map(normalizeItem)\n const selected = normalized.find((item) => item.value === selectedValue)\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 // A radio group: nothing carries the label's `for` id; the root's `aria-labelledby` names it.\n composite\n >\n {/* `key={orientation}` remounts the root on an axis flip so Ark re-measures\n the indicator rect for the new layout (it only measures on mount + value\n change). `useUncontrolled` keeps the selection across that remount. */}\n <SegmentGroupRoot\n key={orientation}\n value={selectedValue}\n // Ark's value is typed by the collection (`string`); the runtime value\n // always originates from `data`, so narrow it back to the caller's union.\n onValueChange={(v) => setSelectedValue(v as SegmentGroupValue<Data> | null)}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n invalid={isInvalid}\n orientation={orientation}\n name={name}\n id={id}\n ref={ref}\n onBlur={onBlur}\n color={color}\n testId={testId}\n className={cn(segTray({ variant, size, grow }), className, classNames?.root)}\n >\n {/* The sliding pill. Ark sets `position: absolute` + `--left`/`--top`/\n `--width`/`--height` (the selected segment's rect) inline, so it\n sits behind the labels (`z-0`). It adopts the selected item's `color`\n (falling back to the group `color`), which is the same `data-color`\n that item's own label carries — so the fill and the `--c-on-solid`\n text on top of it always resolve from one block.\n\n We drive the slide ourselves rather than via Ark's gated transition.\n Ark sets `transition-property: none` whenever its `animateIndicator`\n flag is false — including the instant it receives the `transitionend`\n of ANY animated property. With several properties of differing\n end-times (a `left` redirected by an interrupting click vs. a color or\n width that already settled), that early end would null the transition\n and snap the pill mid-slide. Overriding the real `transition-*` props\n (our `style` wins via Ark's `mergeProps`) keeps the transition always\n on, so the flag is irrelevant and interruptions re-target smoothly. The\n first paint stays instant because Ark renders the pill `hidden` until\n its rect is measured, and `display:none` can't transition. The\n duration comes from `--indicator-duration` (set by a class) rather\n than an inline value, so reduced motion can zero it. */}\n <Ark.Indicator\n style={{\n width: \"var(--width)\",\n height: \"var(--height)\",\n transitionProperty: \"left, top, width, height, background-color, border-color\",\n transitionDuration: \"var(--indicator-duration)\",\n transitionTimingFunction: \"var(--ease-emphasized)\",\n }}\n {...props({ \"data-color\": selected?.color ?? color })}\n className={cn(segIndicator({ variant }), classNames?.indicator)}\n />\n {normalized.map((item) => (\n <Ark.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n data-testid={item.testId}\n className={cn(segItemWrap({ grow }), classNames?.item)}\n >\n <Ark.ItemText\n data-color={item.color}\n className={cn(segItem({ size, variant, grow }), classNames?.itemText)}\n >\n {/* `renderItem` owns the label content (with the item's typed payload);\n the ItemText keeps its sizing, checked color, and pill wiring. */}\n {renderItem ? (\n <Ark.ItemContext>\n {(ctx) =>\n renderItem(item as unknown as RenderableSegment<Data>, {\n checked: ctx.checked,\n disabled: ctx.disabled,\n })\n }\n </Ark.ItemContext>\n ) : (\n item.label\n )}\n </Ark.ItemText>\n <Ark.ItemControl />\n <Ark.ItemHiddenInput />\n </Ark.Item>\n ))}\n </SegmentGroupRoot>\n </FieldShell>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/components/segment-group/segment-group.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;AAsEA,IAAM,OAAA,GAAU,GAAA;AAAA,EACd;AAAA,IACE,aAAA;AAAA,IACA,wEAAA;AAAA,IACA,kBAAA,CAAmB,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKnB,8FAAA;AAAA,IACA,mBAAA;AAAA,IACA,2DAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,MAAA,EAAQ,0CAAA;AAAA,QACR,KAAA,EAAO,sCAAA;AAAA,QACP,OAAA,EAAS,sCAAA;AAAA,QACT,MAAA,EAAQ,sCAAA;AAAA,QACR,OAAA,EAAS;AAAA,OACX;AAAA,MACA,IAAA,EAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI,iDAAA;AAAA,QACJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI,+CAAA;AAAA,QACJ,EAAA,EAAI;AAAA,OACN;AAAA;AAAA,MAEA,IAAA,EAAM,EAAE,IAAA,EAAM,QAAA;AAAS,KACzB;AAAA,IACA,eAAA,EAAiB,EAAE,OAAA,EAAS,SAAA,EAAW,MAAM,IAAA;AAAK;AAEtD,CAAA;AAWA,IAAM,WAAA,GAAc,GAAA;AAAA,EAClB;AAAA,IACE,0BAAA;AAAA,IACA,oFAAA;AAAA,IACA,yCAAA;AAAA,IACA,+CAAA;AAAA;AAAA;AAAA;AAAA,IAIA,mGAAA;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b;AAAA;AAAA,SAAA;AAAA,QA/EI;AAAA;AAgFP;AAAA,GACF;AAEJ","file":"chunk-IANYMDKH.js","sourcesContent":["\"use client\"\n\nimport { useFieldContext } from \"@ark-ui/react/field\"\nimport { SegmentGroup as Ark } from \"@ark-ui/react/segment-group\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport type { FocusEvent, ReactNode, Ref } from \"react\"\nimport { cn } from \"../../lib/cn\"\nimport type { Color } from \"../../lib/colors\"\nimport { useDirectionCheck } from \"../../lib/intl\"\nimport { useMergedRefs } from \"../../lib/merge-refs\"\nimport { props } from \"../../lib/props\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport { useUncontrolled } from \"../../lib/use-uncontrolled\"\nimport { type FieldProps, FieldShell, fieldA11yProps } from \"../field/field\"\n\n/**\n * SegmentGroup — a segmented single-choice control on Ark UI's SegmentGroup\n * machine (the radio-group model under the hood). It renders a row (or column)\n * of mutually exclusive segments with a sliding pill that animates to the\n * selected item. Use it as a compact, always-visible alternative to a `Select`\n * when the option set is small (2–5 items): view toggles, filters, billing\n * cadence, and the like.\n *\n * - Value is a single `string | null`; `onChange` hands it to you directly,\n * matching the kit's value-based `FormControlProps` contract.\n * - `data` accepts bare strings (`value === label`) or\n * `{ value, label?, disabled?, color?, payload? }` objects, mixed freely.\n * The component is generic over `data` (a `const` type parameter), so\n * `value` / `onChange` narrow to the literal value union and an item's\n * `payload` flows—typed—into `renderItem` (the same contract as `Select`).\n * - Label / description / error / required come from the built-in `Field`\n * wrapper, so a `SegmentGroup` is accessible and complete on its own.\n * - `name` renders a hidden radio input per item, so the selected value rides\n * a native `<form>` submission.\n *\n * `variant` mirrors the `Button` family (`filled` / `light` / `outline` /\n * `subtle` / `default`): the tray, the sliding pill, and the checked label all\n * adopt the variant's treatment off the shared `--c-*` slots. Palette rides on\n * `data-color`, so every kit color tints for free, `default` included — its pill\n * falls back to solid black/white with no color set, because `:root` defines\n * `--c-solid`/`--c-on-solid` as black/white (white/brand-950 under dark). A\n * per-item `color` overrides the group palette for whichever segment is\n * selected: it re-stamps `data-color` on that item and on the pill, so both\n * the fill and the checked label resolve from the same block.\n *\n * The moving pill is the Ark `Indicator`: Ark positions it absolutely via the\n * CSS vars `--left` / `--top` / `--width` / `--height` (the selected segment's\n * measured rect), so it sits *behind* the labels (`z-0`). Ark only re-measures\n * that rect on mount and on value change — not when `orientation` flips — so we\n * remount the root with `key={orientation}` to force a fresh measure on the new\n * axis. The value is held in `useUncontrolled` so the selection survives that\n * remount.\n */\n\n/**\n * Per-segment label: size sets the padding / text, `variant` sets the *checked*\n * text color so it reads against that variant's pill. The unchecked color is a\n * neutral gray applied at the call site.\n *\n * The checked label must come from the same source as the pill under it.\n * `default` and `filled` both paint `bg-(--c-solid)`, so both take\n * `--c-on-solid` — which resolves per-item, since each `ItemText` carries its\n * own `data-color`. Pairing a hard-coded neutral foreground with a `--c-solid`\n * fill is what broke `default` at any group `color` (#140): the pill moved with\n * the palette and the label stayed put, reaching 3.27:1 on brand. There is\n * deliberately no hover shift on the checked label — `Button`'s `filled` moves\n * only the background and keeps `--c-on-solid`, and no `--c-on-solid-hover`\n * slot exists in `colors.css`.\n */\nconst segItem = cva(\n [\n \"font-medium\",\n \"cursor-pointer rounded-input text-center whitespace-nowrap select-none\",\n TEXT_COLOR_CLASSES.secondary,\n // Only unchecked segments get the hover lift, as in Tabs. An\n // unscoped `hover:` ties on specificity with the checked foreground and\n // won on source order in dark theme, washing the checked label to\n // near-white over a colored pill.\n \"not-data-[state=checked]:hover:text-brand-950 dark:not-data-[state=checked]:hover:text-white\",\n \"transition-colors\",\n \"data-disabled:cursor-not-allowed data-disabled:opacity-50\",\n \"group-data-invalid:text-red-900 dark:group-data-invalid:text-red-500\",\n ],\n {\n variants: {\n variant: {\n filled: \"data-[state=checked]:text-(--c-on-solid)\",\n light: \"data-[state=checked]:text-(--c-text)\",\n outline: \"data-[state=checked]:text-(--c-text)\",\n subtle: \"data-[state=checked]:text-(--c-text)\",\n default: \"data-[state=checked]:text-(--c-on-solid)\",\n },\n size: {\n // No vertical padding of its own — the tray's `min-h` (below) sets the\n // box height and this item stretches to fill it (the tray's default\n // `align-items: stretch` propagates all the way down), so the label\n // just needs to center itself inside that taller box. This matches an\n // `Input` / `NumberInput`'s exact box height at the same size.\n xs: \"flex items-center justify-center px-1 text-xs\",\n sm: \"flex items-center justify-center px-1.5 text-sm\",\n md: \"flex items-center justify-center px-2 text-md\",\n lg: \"flex items-center justify-center px-3 text-lg\",\n xl: \"flex items-center justify-center px-4 text-xl\",\n },\n // Fill the (grown) segment so the label centers across its whole share.\n grow: { true: \"w-full\" },\n },\n defaultVariants: { variant: \"default\", size: \"md\" },\n },\n)\n\n/**\n * Per-segment wrapper. Beyond positioning the label above the pill (`z-1`), it\n * draws a hairline separator in the gap to its leading edge (a `::before`) so\n * inactive neighbours read as divided. That rule fades out next to the active\n * pill — on the checked segment and the one right after it — and is suppressed\n * before the first segment (the indicator is child 1, so the first segment is\n * `:nth-child(2)`). It flips from a vertical rule to a horizontal one when the\n * group is laid out vertically.\n */\nconst segItemWrap = cva(\n [\n \"relative z-1 inline-flex\",\n \"before:absolute before:rounded-full before:bg-brand-900/30 dark:before:bg-white/35\",\n \"group-data-invalid:before:bg-red-500/30\",\n \"before:transition-opacity before:duration-200\",\n // Horizontal: a vertical rule centered on the leading edge, sitting in the gap. Logical\n // (`start`, `-ms-[0.5px]` to center the 1px rule), so under `dir=\"rtl\"` the rule still lands\n // between a segment and the one before it instead of on the far side.\n \"before:top-1/2 before:start-0 before:-ms-[0.5px] before:h-1/2 before:w-px before:-translate-y-1/2\",\n // Vertical: a horizontal rule centered on the top edge instead (`start-1/4` + `w-1/2` is\n // centered in either direction).\n \"in-data-[orientation=vertical]:before:top-0 in-data-[orientation=vertical]:before:start-1/4 in-data-[orientation=vertical]:before:ms-0 in-data-[orientation=vertical]:before:h-px in-data-[orientation=vertical]:before:w-1/2\",\n // No separator before the first segment, or flanking the active pill.\n \"nth-2:before:hidden\",\n \"data-[state=checked]:before:opacity-0 data-[state=checked]:[&+*]:before:opacity-0\",\n ],\n {\n variants: {\n // An even share of the tray per segment, like a tab bar.\n grow: { true: \"flex-1\" },\n },\n },\n)\n\n/**\n * The sliding pill, mirroring each `Button` surface. Its slide + color transition\n * is driven by Ark (see the `--transition-*` overrides on the element); `default`\n * follows `--c-solid` like every other variant, which falls back to solid\n * black/white with no `data-color` set. Filled/soft-fill pills (`filled`, `light`,\n * `default`) use a tighter `rounded-xxs` than the tray's own `rounded-input`, for a\n * nested-corner look inside the tray's padding; bordered/transparent pills\n * (`outline`, `subtle`) keep `rounded-input`.\n */\nconst segIndicator = cva(\n [\n \"z-0\",\n // The slide's duration, read by the inline `transition-duration` (see the\n // pill below); reduced motion zeroes it, so the pill jumps instead.\n \"[--indicator-duration:var(--duration-normal)] motion-reduce:[--indicator-duration:0s]\",\n ],\n {\n variants: {\n variant: {\n filled: \"bg-(--c-solid) rounded-xxs\",\n light: \"bg-(--c-soft) border border-(--c-soft-hover) rounded-xxs\",\n outline: \"bg-transparent border border-(--c-solid) rounded-input\",\n subtle: \"bg-(--c-soft-hover) rounded-input\",\n default: \"bg-(--c-solid) rounded-xxs\",\n },\n },\n defaultVariants: { variant: \"default\" },\n },\n)\n\n/**\n * The tray. Mirrors the `Button` variants: `filled` is a borderless neutral fill\n * so the colored pill pops (the kit's quiet `bg-black/3 dark:bg-white/4`; light\n * mode darkens because a bare `bg-white/4` vanishes on a near-white page), `light` / `default` frame the pill with the same\n * translucent surface as `Input`'s own `default` shell (`bg-white/4` + the\n * hairline `border-brand-900/20 dark:border-white/15`) rather than an opaque\n * gray step, so the tray reads correctly on any host background, `subtle` /\n * `outline` are chromeless.\n */\nconst segTray = cva(\n [\n \"relative inline-flex rounded-input border p-0.5 transition-colors max-w-fit group\",\n \"data-[orientation=vertical]:flex-col\",\n \"data-disabled:cursor-not-allowed data-disabled:opacity-60\",\n // Focus halo + accent border, driven by the active palette's `--c-solid`. Keyed\n // off Zag's `data-focus-visible` (set only when the focus came from the keyboard,\n // never a mouse click) via `:has()`, so the ring stays off when you click a segment.\n //\n // Deliberately NOT `focusStyles`. This is the *shell* idiom, not the ring\n // idiom: an accent border plus a soft `/15` halo on a wrapper whose focus\n // lives on a descendant, with a red invalid twin on the identical selector.\n // That is `input.tsx`'s `shellChrome`, not `Button`'s ring — folding it into\n // `focusStyles` would make that helper grow an alpha, a border half and a\n // concept of invalid, for one call site. The two shells are worth sharing\n // with each other instead; see the follow-up issue.\n \"has-data-focus-visible:border-(--c-solid) has-data-focus-visible:ring-2 has-data-focus-visible:ring-(--c-solid)/15\",\n // Invalid wins over the palette: red border + red halo.\n \"data-invalid:border-red-500 data-invalid:has-data-focus-visible:border-red-500 data-invalid:has-data-focus-visible:ring-red-500/15\",\n // Disabled affordances on the shell.\n ],\n {\n variants: {\n variant: {\n filled: [\"bg-black/3 dark:bg-white/4\", \"border-transparent\"],\n light: [\"bg-white/4\", \"border-brand-900/20 dark:border-white/15\"],\n outline: [\"bg-transparent border-transparent\"],\n subtle: [\"bg-transparent border-transparent\"],\n default: [\"bg-white/4\", \"border-brand-900/20 dark:border-white/15\"],\n },\n size: {\n // The exact `min-h` `inputShell` (input.tsx) uses at the same size —\n // so a `SegmentGroup` sits flush with an `Input` / `NumberInput` of\n // the same size in a row (see `TimeRow`, which composes both).\n xs: \"gap-0 min-h-7\",\n sm: \"gap-0 min-h-8\",\n md: \"gap-0 min-h-9\",\n lg: \"gap-0 min-h-10\",\n xl: \"gap-0 min-h-12\",\n },\n // Span the container instead of hugging the labels.\n grow: { true: \"flex w-full max-w-none\" },\n },\n defaultVariants: { variant: \"default\" },\n },\n)\n\nexport type SegmentGroupSize = NonNullable<VariantProps<typeof segItem>[\"size\"]>\nexport type SegmentGroupVariant = VariantProps<typeof segTray>[\"variant\"]\n\n/**\n * A single segment: a bare value-as-label string, or a labelled object. Objects\n * may carry a `payload` of arbitrary data (the machine ignores it; it flows\n * through to `renderItem`, typed off the `data` shape — the same contract as\n * `Select`'s `SelectItem`).\n */\nexport type SegmentGroupItem<P = unknown> =\n | string\n | {\n value: string\n label?: ReactNode\n disabled?: boolean\n /** Overrides the group palette for the pill + label when this item is selected. */\n color?: Color\n /** Arbitrary extra data, surfaced to `renderItem`. */\n payload?: P\n /** `data-testid` on the rendered segment. Defaults to `` `item-${value}` ``. */\n testId?: string\n }\n\n/** The `data` array the component is generic over. */\nexport type SegmentGroupData<P = unknown> = ReadonlyArray<SegmentGroupItem<P>>\n\n/**\n * Extract the value-string union from a `SegmentGroupData` shape — bare strings\n * and item `.value`s both contribute. A `const` type parameter narrows it to the\n * literal union, so `value` / `onChange` are typed off the data (like `Select`).\n */\nexport type SegmentGroupValue<Data extends SegmentGroupData> = ItemValue<Data[number]>\ntype ItemValue<E> = E extends string ? E : E extends { value: infer V extends string } ? V : never\n\n/**\n * Extract the `payload` type carried by a `SegmentGroupData` shape, read\n * structurally off the data's `payload` property. Bare strings contribute\n * `never`; a homogeneous payload resolves precisely, a mixed one to the union.\n */\nexport type SegmentGroupPayload<Data extends SegmentGroupData> = PayloadOf<Data[number]>\ntype PayloadOf<T> = T extends string ? never : T extends { payload?: infer P } ? P : never\n\n/**\n * The segment handed to `renderItem`: `value` narrowed to the data's value union\n * and `payload` to the data's payload type, so a `const`-typed `data` yields\n * literal values and a precise payload in the callback.\n */\nexport type RenderableSegment<Data extends SegmentGroupData> = {\n value: SegmentGroupValue<Data>\n label: ReactNode\n disabled: boolean\n color: Color | undefined\n payload: SegmentGroupPayload<Data> | undefined\n}\n\n/** Live segment state passed alongside the item to `renderItem`. */\nexport type SegmentRenderState = {\n checked: boolean\n disabled: boolean\n}\n\n/**\n * Render a segment's label content yourself. Receives the (value-narrowed) item —\n * including its typed `payload` — and its live `{ checked, disabled }` state. The\n * segment keeps its sizing, pill, and selection wiring; you fill the label. In an\n * RSC tree the function must live in a `\"use client\"` module so the boundary\n * serializes it as a client reference.\n */\nexport type RenderSegment<Data extends SegmentGroupData> = (\n item: RenderableSegment<Data>,\n state: SegmentRenderState,\n) => ReactNode\n\ntype SegmentGroupClassNames = {\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 indicator?: string\n item?: string\n itemText?: string\n}\n\nexport type SegmentGroupProps<Data extends SegmentGroupData = SegmentGroupData> = Pick<\n FieldProps,\n \"label\" | \"description\" | \"error\" | \"required\"\n> &\n WithTestId & {\n /** Segments: bare strings (`value === label`) or `{ value, label?, disabled?, color?, payload? }`. */\n data: Data\n /** Controlled value. `null` clears the selection. */\n value?: SegmentGroupValue<Data> | null\n /** Uncontrolled initial value. */\n defaultValue?: SegmentGroupValue<Data> | null\n /** Fires with the selected value. */\n onChange?: (value: SegmentGroupValue<Data>) => void\n /** Render each segment's label content yourself, with its typed `payload`. */\n renderItem?: RenderSegment<Data>\n /** Lay the segments 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 /** Dims and blocks interaction. */\n disabled?: boolean\n /** Keeps full contrast but blocks edits. */\n readOnly?: boolean\n /** `xs`–`xl` match the exact box height of an `Input` / `NumberInput` at\n * that size, so a `SegmentGroup` composes flush inline next to one (see\n * `TimeInput`'s AM/PM toggle). */\n size?: SegmentGroupSize\n variant?: SegmentGroupVariant\n color?: Color\n /** Span the container and give every segment an even share of it, like a\n * tab bar. Without it the group hugs its labels. */\n grow?: boolean\n /** Wires the hidden radio inputs into native form submission. */\n name?: string\n /** Explicit id for label association. */\n id?: string\n /** Lands on the root for focus-on-error. */\n ref?: Ref<HTMLDivElement>\n /** Forwarded to the root; drives touched/blurred validation. */\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n className?: string\n classNames?: SegmentGroupClassNames\n }\n\n/** A fully resolved segment — every field present (`label` falls back to `value`). */\ntype NormalizedItem = {\n value: string\n label: ReactNode\n disabled: boolean\n color: Color | undefined\n payload: unknown\n testId: string\n}\n\n/** Normalize a bare string / object into the resolved `NormalizedItem` form. */\nconst normalizeItem = (item: SegmentGroupItem): NormalizedItem =>\n typeof item === \"string\"\n ? {\n value: item,\n label: item,\n disabled: false,\n color: undefined,\n payload: undefined,\n testId: `item-${item}`,\n }\n : {\n value: item.value,\n label: item.label ?? item.value,\n disabled: item.disabled ?? false,\n color: item.color,\n payload: item.payload,\n testId: item.testId ?? `item-${item.value}`,\n }\n\n/**\n * The real `role=\"radiogroup\"` root (and, through it, each item's hidden\n * radio input), split out so it reads the `Field` context from *inside* the\n * wrapping `FieldShell` — `SegmentGroup` itself renders that shell, so\n * calling `useFieldContext()` at its own top level would run too early.\n * Takes plain `string` values rather than the outer component's `Data`-typed\n * union: it only forwards them, so no generic type parameter is needed here.\n */\nconst SegmentGroupRoot = ({\n value,\n onValueChange,\n disabled,\n readOnly,\n required,\n invalid,\n orientation,\n name,\n id,\n ref,\n onBlur,\n color,\n className,\n testId,\n children,\n}: {\n value: string | null\n onValueChange: (value: string | null) => void\n disabled?: boolean\n readOnly?: boolean\n required?: boolean\n invalid: boolean\n orientation: \"horizontal\" | \"vertical\"\n name?: string\n id?: string\n ref?: Ref<HTMLDivElement>\n onBlur?: (event: FocusEvent<HTMLDivElement>) => void\n color?: Color\n className?: string\n children: ReactNode\n} & WithTestId) => {\n const field = useFieldContext()\n const checkDirection = useDirectionCheck()\n const rootRef = useMergedRefs(ref, checkDirection)\n return (\n <Ark.Root\n value={value}\n onValueChange={(d) => onValueChange(d.value)}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n invalid={invalid}\n orientation={orientation}\n name={name}\n id={id}\n ref={rootRef}\n onBlur={onBlur}\n data-color={color}\n {...props({ \"data-invalid\": invalid, \"data-testid\": testId })}\n {...fieldA11yProps(field)}\n className={className}\n >\n {children}\n </Ark.Root>\n )\n}\n\nexport const SegmentGroup = <const Data extends SegmentGroupData = SegmentGroupData>({\n data,\n value,\n defaultValue,\n onChange,\n renderItem,\n orientation = \"horizontal\",\n invalid,\n disabled,\n readOnly,\n required,\n size = \"md\",\n variant = \"default\",\n color,\n grow,\n name,\n id,\n ref,\n onBlur,\n label,\n description,\n error,\n className,\n classNames,\n testId,\n}: SegmentGroupProps<Data>) => {\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\n // Own the value so the pill can read which item is selected (per-item color)\n // and so the `key={orientation}` remount below preserves the selection.\n const [selectedValue, setSelectedValue] = useUncontrolled<SegmentGroupValue<Data> | null>({\n value,\n defaultValue,\n finalValue: null,\n onChange: (v) => v != null && onChange?.(v),\n })\n\n const normalized = (data as SegmentGroupData).map(normalizeItem)\n const selected = normalized.find((item) => item.value === selectedValue)\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 // A radio group: nothing carries the label's `for` id; the root's `aria-labelledby` names it.\n composite\n >\n {/* `key={orientation}` remounts the root on an axis flip so Ark re-measures\n the indicator rect for the new layout (it only measures on mount + value\n change). `useUncontrolled` keeps the selection across that remount. */}\n <SegmentGroupRoot\n key={orientation}\n value={selectedValue}\n // Ark's value is typed by the collection (`string`); the runtime value\n // always originates from `data`, so narrow it back to the caller's union.\n onValueChange={(v) => setSelectedValue(v as SegmentGroupValue<Data> | null)}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n invalid={isInvalid}\n orientation={orientation}\n name={name}\n id={id}\n ref={ref}\n onBlur={onBlur}\n color={color}\n testId={testId}\n className={cn(segTray({ variant, size, grow }), className, classNames?.root)}\n >\n {/* The sliding pill. Ark sets `position: absolute` + `--left`/`--top`/\n `--width`/`--height` (the selected segment's rect) inline, so it\n sits behind the labels (`z-0`). It adopts the selected item's `color`\n (falling back to the group `color`), which is the same `data-color`\n that item's own label carries — so the fill and the `--c-on-solid`\n text on top of it always resolve from one block.\n\n We drive the slide ourselves rather than via Ark's gated transition.\n Ark sets `transition-property: none` whenever its `animateIndicator`\n flag is false — including the instant it receives the `transitionend`\n of ANY animated property. With several properties of differing\n end-times (a `left` redirected by an interrupting click vs. a color or\n width that already settled), that early end would null the transition\n and snap the pill mid-slide. Overriding the real `transition-*` props\n (our `style` wins via Ark's `mergeProps`) keeps the transition always\n on, so the flag is irrelevant and interruptions re-target smoothly. The\n first paint stays instant because Ark renders the pill `hidden` until\n its rect is measured, and `display:none` can't transition. The\n duration comes from `--indicator-duration` (set by a class) rather\n than an inline value, so reduced motion can zero it. */}\n <Ark.Indicator\n style={{\n width: \"var(--width)\",\n height: \"var(--height)\",\n transitionProperty: \"left, top, width, height, background-color, border-color\",\n transitionDuration: \"var(--indicator-duration)\",\n transitionTimingFunction: \"var(--ease-emphasized)\",\n }}\n {...props({ \"data-color\": selected?.color ?? color })}\n className={cn(segIndicator({ variant }), classNames?.indicator)}\n />\n {normalized.map((item) => (\n <Ark.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n data-testid={item.testId}\n className={cn(segItemWrap({ grow }), classNames?.item)}\n >\n <Ark.ItemText\n data-color={item.color}\n className={cn(segItem({ size, variant, grow }), classNames?.itemText)}\n >\n {/* `renderItem` owns the label content (with the item's typed payload);\n the ItemText keeps its sizing, checked color, and pill wiring. */}\n {renderItem ? (\n <Ark.ItemContext>\n {(ctx) =>\n renderItem(item as unknown as RenderableSegment<Data>, {\n checked: ctx.checked,\n disabled: ctx.disabled,\n })\n }\n </Ark.ItemContext>\n ) : (\n item.label\n )}\n </Ark.ItemText>\n <Ark.ItemControl />\n <Ark.ItemHiddenInput />\n </Ark.Item>\n ))}\n </SegmentGroupRoot>\n </FieldShell>\n )\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { useLayerCovered } from './chunk-HWBFRDX7.js';
2
- import { devWarn } from './chunk-LIZWCWED.js';
2
+ import { devWarn } from './chunk-PQZSTI3R.js';
3
3
  import { ArrowRight, ArrowLeft, ArrowDown, ArrowUp, ArrowRightToLine, Delete, CornerDownLeft, ArrowBigUp, Option, ChevronUp, Command } from 'lucide-react';
4
4
  import { useEffectEvent, useEffect, useSyncExternalStore } from 'react';
5
5
 
@@ -213,5 +213,5 @@ var noSubscription = () => () => {
213
213
  var useApplePlatform = () => useSyncExternalStore(noSubscription, isApplePlatform, () => false);
214
214
 
215
215
  export { KBD_DEFAULT_TRANSLATIONS, formatHotkey, hotkeyCaps, hotkeyKeys, isApplePlatform, matchHotkey, useApplePlatform, useHotkey };
216
- //# sourceMappingURL=chunk-QEMXXQQO.js.map
217
- //# sourceMappingURL=chunk-QEMXXQQO.js.map
216
+ //# sourceMappingURL=chunk-JKFPRQB2.js.map
217
+ //# sourceMappingURL=chunk-JKFPRQB2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/lib/use-hotkey.ts"],"names":[],"mappings":";;;;;AAsCA,IAAM,QAAA,GAAoD;AAAA,EACxD,GAAA,EAAK,KAAA;AAAA,EACL,IAAA,EAAM,MAAA;AAAA,EACN,GAAA,EAAK,MAAA;AAAA,EACL,OAAA,EAAS,MAAA;AAAA,EACT,IAAA,EAAM,MAAA;AAAA,EACN,OAAA,EAAS,MAAA;AAAA,EACT,GAAA,EAAK,KAAA;AAAA,EACL,MAAA,EAAQ,KAAA;AAAA,EACR,KAAA,EAAO;AACT,CAAA;AAGA,IAAM,YAAA,GAAgD;AAAA,EACpD,IAAA,EAAM,MAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,GAAA,EAAK,KAAA;AAAA,EACL,KAAA,EAAO;AACT,CAAA;AAGO,IAAM,kBAAkB,MAAe;AAC5C,EAAA,IAAI,OAAO,SAAA,KAAc,WAAA,EAAa,OAAO,KAAA;AAC7C,EAAA,MAAM,GAAA,GAA6D,SAAA;AACnE,EAAA,OAAO,wBAAwB,IAAA,CAAK,GAAA,CAAI,eAAe,QAAA,IAAY,GAAA,CAAI,YAAY,EAAE,CAAA;AACvF;AAaA,IAAM,eAAA,GAAkB,CAA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AAC7B,MAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,IACf,CAAA;AACA,IAAA,MAAA,CAAO,gBAAA,CAAiB,MAAM,KAAK,CAAA;AACnC,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,QAAA,CAAS,gBAAA,CAAiB,eAAe,aAAa,CAAA;AACtD,MAAA,QAAA,CAAS,gBAAA,CAAiB,cAAc,YAAY,CAAA;AAAA,IACtD;AACA,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,MAAM,KAAK,CAAA;AACtC,MAAA,QAAA,CAAS,mBAAA,CAAoB,eAAe,aAAa,CAAA;AACzD,MAAA,QAAA,CAAS,mBAAA,CAAoB,cAAc,YAAY,CAAA;AAAA,IACzD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,SAAA,EAAW,MAAA,EAAQ,KAAA,EAAO,OAAO,KAAA,EAAO,MAAA,EAAQ,IAAA,EAAM,OAAO,CAAC,CAAA;AACpE;AAEA,IAAM,cAAA,GAAiB,MAAM,MAAM;AAAC,CAAA;AAM7B,IAAM,mBAAmB,MAC9B,oBAAA,CAAqB,cAAA,EAAgB,eAAA,EAAiB,MAAM,KAAK","file":"chunk-QEMXXQQO.js","sourcesContent":["\"use client\"\n\nimport {\n ArrowBigUp,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowRightToLine,\n ArrowUp,\n ChevronUp,\n Command,\n CornerDownLeft,\n Delete,\n type LucideIcon,\n Option,\n} from \"lucide-react\"\nimport { type RefObject, useEffect, useEffectEvent, useSyncExternalStore } from \"react\"\nimport { devWarn } from \"./dev-warn\"\nimport { useLayerCovered } from \"./overlay-layer\"\n\n/**\n * A small, platform-aware keyboard shortcut matcher: `\"mod+k\"`, `\"shift+mod+p\"`,\n * `\"alt+/\"`.\n *\n * - `mod` is ⌘ on Apple platforms and Ctrl elsewhere, the usual convention for\n * app shortcuts. `meta` / `cmd` and `ctrl` name one key explicitly.\n * - The last part is the key, compared case-insensitively with `event.key`, so\n * it follows the user's keyboard layout. The space bar is `space`. Modifiers must match exactly:\n * `mod+k` doesn't fire on ⌘⇧K.\n * - The key can be a modifier itself (`\"alt\"`, for hold-to-peek): its own flag\n * is then ignored, since pressing ⌥ sets `altKey` and releasing it clears it.\n * - An event fired while an IME is composing is ignored.\n * - A part that names no modifier (`\"ctl+k\"`) makes the hotkey match nothing,\n * rather than silently dropping it and firing on a bare `k`.\n */\n\ntype Modifiers = { meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }\n\nconst MODIFIER: Record<string, keyof Modifiers | \"mod\"> = {\n mod: \"mod\",\n meta: \"meta\",\n cmd: \"meta\",\n command: \"meta\",\n ctrl: \"ctrl\",\n control: \"ctrl\",\n alt: \"alt\",\n option: \"alt\",\n shift: \"shift\",\n}\n\n/** A modifier as the key itself, spelled the way `event.key` spells it. */\nconst MODIFIER_KEY: Record<keyof Modifiers, string> = {\n meta: \"meta\",\n ctrl: \"control\",\n alt: \"alt\",\n shift: \"shift\",\n}\n\n/** Whether the user agent is an Apple platform (macOS, iOS, iPadOS): `mod` is ⌘ there. */\nexport const isApplePlatform = (): boolean => {\n if (typeof navigator === \"undefined\") return false\n const nav: Navigator & { userAgentData?: { platform?: string } } = navigator\n return /mac|iphone|ipad|ipod/i.test(nav.userAgentData?.platform ?? nav.platform ?? \"\")\n}\n\nexport type ParsedHotkey = Modifiers & {\n key: string\n /** Modifier parts that name no known modifier — a typo like `ctl`. */\n unknown: string[]\n}\n\ntype HotkeyEvent = Pick<\n KeyboardEvent,\n \"key\" | \"metaKey\" | \"ctrlKey\" | \"altKey\" | \"shiftKey\" | \"isComposing\"\n>\n\nconst resolveModifier = (part: string, apple: boolean): keyof Modifiers | undefined => {\n const modifier = MODIFIER[part]\n return modifier === \"mod\" ? (apple ? \"meta\" : \"ctrl\") : modifier\n}\n\n/** Parse a hotkey once: its key and the exact modifiers it needs. */\nexport const parseHotkey = (hotkey: string, apple = isApplePlatform()): ParsedHotkey => {\n const parts = hotkey\n .toLowerCase()\n .split(\"+\")\n .map((part) => part.trim())\n // A trailing \"+\" names the plus key itself: \"mod++\".\n const last = hotkey.endsWith(\"+\") ? \"+\" : (parts.at(-1) ?? \"\")\n const named = parts.slice(0, hotkey.endsWith(\"+\") ? -2 : -1)\n // A modifier as the key (`\"alt\"`, `\"mod\"`) is spelled as `event.key` has it.\n const self = resolveModifier(last, apple)\n const modifiers = named.map((part) => resolveModifier(part, apple))\n return {\n key: self ? MODIFIER_KEY[self] : last,\n meta: modifiers.includes(\"meta\"),\n ctrl: modifiers.includes(\"ctrl\"),\n alt: modifiers.includes(\"alt\"),\n shift: modifiers.includes(\"shift\"),\n unknown: named.filter((part) => MODIFIER[part] === undefined),\n }\n}\n\n/** Whether `event` is the already-parsed hotkey. */\nconst matchParsed = (parsed: ParsedHotkey, event: HotkeyEvent): boolean => {\n // `event.key` is a literal \" \" for the space bar, which a hotkey spells `space`.\n const key = event.key === \" \" ? \"space\" : event.key.toLowerCase()\n // Pressing a modifier sets its own flag (and releasing it clears it), so a\n // modifier that is the key itself is checked by `key` alone.\n const flag = (modifier: keyof Modifiers, pressed: boolean) =>\n key === MODIFIER_KEY[modifier] || pressed === parsed[modifier]\n return (\n !event.isComposing &&\n parsed.unknown.length === 0 &&\n key === parsed.key &&\n flag(\"meta\", event.metaKey) &&\n flag(\"ctrl\", event.ctrlKey) &&\n flag(\"alt\", event.altKey) &&\n flag(\"shift\", event.shiftKey)\n )\n}\n\n/** Whether `event` is `hotkey`. See the module doc for the rules. */\nexport const matchHotkey = (\n hotkey: string,\n event: HotkeyEvent,\n apple = isApplePlatform(),\n): boolean => matchParsed(parseHotkey(hotkey, apple), event)\n\n/**\n * The words a key cap reads as, keyed by the English string each replaces:\n * the word a cap shows (`ctrl`, `escape`) or the name it is spoken by (`command`,\n * `up`). Apple and the other platforms name some keys differently, so each\n * spelling has its own key: `return` / `enter`, `option` / `alt`, `delete`\n * (⌫ on a Mac) / `backspace`. `KEY_LABEL` says which key uses which; these\n * only replace the strings. `Intl` has no display names for keys, so these are\n * plain translations, English by default (`KBD_DEFAULT_TRANSLATIONS`).\n */\nexport type KbdTranslations = {\n /** ⌘, spoken on Apple. */\n command: string\n /** The Meta (Windows) key's word, off Apple. */\n meta: string\n /** ⌃, spoken on Apple. */\n control: string\n /** Ctrl's word, off Apple. \"Strg\" on a German keyboard. */\n ctrl: string\n /** ⌥, spoken on Apple. */\n option: string\n /** Alt's word, off Apple. */\n alt: string\n /** ⇧, spoken on every platform. */\n shift: string\n /** ↵, spoken on Apple. */\n return: string\n /** ↵, spoken off Apple. \"Entrée\" in French. */\n enter: string\n /** ⌫, spoken on Apple. */\n delete: string\n /** ⌫'s word, off Apple. \"Rücktaste\" in German, \"Retour arrière\" in French. */\n backspace: string\n /** ⌦, spoken on Apple. */\n forwardDelete: string\n /** ⌦'s word, off Apple. \"Suppr\" on a French keyboard, \"Entf\" on a German one. */\n del: string\n /** ⇥, spoken on every platform. */\n tab: string\n /** The arrows, spoken on every platform. */\n up: string\n down: string\n left: string\n right: string\n /** Esc's word, on every platform. \"Échap\" on a French keyboard. */\n escape: string\n /** The space bar's word, on every platform. */\n space: string\n /** Page Up and Page Down's words, on every platform. */\n pageUp: string\n pageDown: string\n}\n\n/** The English key words: what `<Kbd hotkey>`, `hotkeyKeys` and `formatHotkey`\n * read as without `translations`, and the base a partial override is merged onto. */\nexport const KBD_DEFAULT_TRANSLATIONS = {\n command: \"Command\",\n meta: \"Meta\",\n control: \"Control\",\n ctrl: \"Ctrl\",\n option: \"Option\",\n alt: \"Alt\",\n shift: \"Shift\",\n return: \"Return\",\n enter: \"Enter\",\n delete: \"Delete\",\n backspace: \"Backspace\",\n forwardDelete: \"Forward Delete\",\n del: \"Del\",\n tab: \"Tab\",\n up: \"Up Arrow\",\n down: \"Down Arrow\",\n left: \"Left Arrow\",\n right: \"Right Arrow\",\n escape: \"Esc\",\n space: \"Space\",\n pageUp: \"PgUp\",\n pageDown: \"PgDn\",\n} as const satisfies KbdTranslations\n\ntype KeyWord = keyof KbdTranslations\n\n/**\n * How a key reads on a key cap. One entry per key that doesn't read as typed:\n *\n * - `glyph`: the symbol Apple writes (⌘, ⇧, ↵), spoken there as `name` (a\n * bare `⌘` has no reliable spoken form).\n * - `text`: the word Windows and Linux write (`Ctrl`, `Shift`, `Enter`),\n * spoken there as itself.\n * - `icon`: what a `<Kbd>` cap draws for the key on every platform, so\n * Shift is the same arrow on a Mac and on a PC.\n * - `appleIcon`: an icon drawn on Apple only: the symbols only Apple uses\n * (⌘ ⌥ ⌃), and ⌫. Elsewhere those keys stay words: there is no honest icon\n * for Ctrl, Alt or the Windows key, and ⌫ reads as the Left Arrow there,\n * where the keyboard prints \"Backspace\".\n *\n * `text` and `name` are `KbdTranslations` keys, so a translation replaces the\n * word and never the key data. Apple platforms take the glyph and fall back to\n * the text; elsewhere it is the reverse, so a key with only a glyph (the\n * arrows) is a symbol everywhere and one with only a text (`Esc`) is a word\n * everywhere. Anything not listed is shown as typed, its first letter\n * upper-cased.\n */\ntype KeyLabel = {\n glyph?: string\n text?: KeyWord\n icon?: LucideIcon\n appleIcon?: LucideIcon\n name?: KeyWord\n}\n\nconst KEY_LABEL: Record<string, KeyLabel> = {\n meta: { glyph: \"⌘\", appleIcon: Command, name: \"command\", text: \"meta\" },\n control: { glyph: \"⌃\", appleIcon: ChevronUp, name: \"control\", text: \"ctrl\" },\n alt: { glyph: \"⌥\", appleIcon: Option, name: \"option\", text: \"alt\" },\n shift: { glyph: \"⇧\", icon: ArrowBigUp, name: \"shift\", text: \"shift\" },\n enter: { glyph: \"↵\", icon: CornerDownLeft, name: \"return\", text: \"enter\" },\n // An icon on Apple only: elsewhere ⌫ reads as ← (the Left Arrow), and the key\n // is printed \"Backspace\" on those keyboards.\n backspace: { glyph: \"⌫\", appleIcon: Delete, name: \"delete\", text: \"backspace\" },\n delete: { glyph: \"⌦\", name: \"forwardDelete\", text: \"del\" },\n tab: { glyph: \"⇥\", icon: ArrowRightToLine, name: \"tab\", text: \"tab\" },\n arrowup: { glyph: \"↑\", icon: ArrowUp, name: \"up\" },\n arrowdown: { glyph: \"↓\", icon: ArrowDown, name: \"down\" },\n arrowleft: { glyph: \"←\", icon: ArrowLeft, name: \"left\" },\n arrowright: { glyph: \"→\", icon: ArrowRight, name: \"right\" },\n // macOS menus spell these out too.\n escape: { text: \"escape\" },\n esc: { text: \"escape\" },\n space: { text: \"space\" },\n pageup: { text: \"pageUp\" },\n pagedown: { text: \"pageDown\" },\n}\n\n/** Apple's order for modifier glyphs (⌃⌥⇧⌘), used on every platform. */\nconst MODIFIER_ORDER: (keyof Modifiers)[] = [\"ctrl\", \"alt\", \"shift\", \"meta\"]\n\n/**\n * One key cap of a hotkey: the text it reads as (`label`), and, when the\n * key is drawn rather than written, the `icon` to draw (none for a glyph\n * with no icon, like ⌦) and the `name` to speak.\n * `id` tells caps apart (`\"ctrl\"`, `\"shift\"`, …, `\"key\"` for the last).\n */\nexport type HotkeyCap = { id: string; label: string; icon?: LucideIcon; name?: string }\n\nconst keyCap = (\n id: string,\n key: string,\n apple: boolean,\n translations: Partial<KbdTranslations> | undefined,\n): HotkeyCap => {\n const entry = KEY_LABEL[key]\n // Merged per key; a key set to `undefined` keeps its English word.\n const word = (of?: KeyWord) => of && (translations?.[of] ?? KBD_DEFAULT_TRANSLATIONS[of])\n const text = word(entry?.text)\n const spoken = word(entry?.name)\n const label =\n (apple ? (entry?.glyph ?? text) : (text ?? entry?.glyph)) ??\n key.charAt(0).toUpperCase() + key.slice(1)\n const icon = apple ? (entry?.appleIcon ?? entry?.icon) : entry?.icon\n // Spoken the platform's way: Apple's key names there (\"Return\"), the\n // word elsewhere (\"Enter\"), the arrows' names on both.\n const name = apple ? spoken : (text ?? spoken)\n // An icon, or Apple's glyph where it has none (⌦), is drawn and spoken by\n // name; a word reads as itself.\n const drawn = icon !== undefined || (label === entry?.glyph && apple)\n return drawn && name ? { id, label, name, ...(icon && { icon }) } : { id, label }\n}\n\n/**\n * The caps of a hotkey, modifiers first in Apple's order. What `<Kbd hotkey>`\n * renders; `hotkeyKeys` is its text. `translations` replaces the English key\n * words per key (see `KbdTranslations`).\n */\nexport const hotkeyCaps = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): HotkeyCap[] => {\n const parsed = parseHotkey(hotkey, apple)\n return [\n ...MODIFIER_ORDER.filter((modifier) => parsed[modifier]).map((modifier) =>\n keyCap(modifier, MODIFIER_KEY[modifier], apple, translations),\n ),\n keyCap(\"key\", parsed.key, apple, translations),\n ]\n}\n\n/**\n * The keys of a hotkey, one label per key cap, the way the platform writes\n * them: `\"mod+k\"` is `[\"⌘\", \"K\"]` on Apple platforms and `[\"Ctrl\", \"K\"]`\n * elsewhere, `\"shift+mod+p\"` is `[\"⇧\", \"⌘\", \"P\"]` / `[\"Ctrl\", \"Shift\", \"P\"]`.\n * Modifiers come in Apple's order (⌃⌥⇧⌘) whatever order the string names\n * them in. Render one `<kbd>` per label, or let `<Kbd hotkey>` do it.\n *\n * `apple` defaults to the current platform, which a server can't know: while\n * rendering, pass `useApplePlatform()` so the server markup and the first\n * client render agree. `translations` is `<Kbd>`'s, so the text and the caps\n * read the same: `{ ctrl: \"Strg\" }` gives `[\"Strg\", \"K\"]`.\n */\nexport const hotkeyKeys = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): string[] => hotkeyCaps(hotkey, apple, translations).map((cap) => cap.label)\n\n/**\n * The label for a hotkey as one string, for plain-text places (a `title`, a\n * tooltip, a menu's text): `hotkeyKeys` joined, the Apple way with no space\n * (`⌘K`, `⇧⌘P`) and with a space elsewhere (`Ctrl K`, `Ctrl Shift P`).\n * On screen, prefer `<Kbd hotkey>`, which draws one cap per key.\n *\n * `apple` defaults to the current platform, which a server can't know: while\n * rendering, pass `useApplePlatform()` so the server markup and the first\n * client render agree. `translations` is `<Kbd>`'s (`{ ctrl: \"Strg\" }` gives\n * `Strg K`).\n */\nexport const formatHotkey = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): string => hotkeyKeys(hotkey, apple, translations).join(apple ? \"\" : \" \")\n\n/** Input types where keys are commands, not text. */\nconst NON_TEXT_INPUTS = [\n \"checkbox\",\n \"radio\",\n \"range\",\n \"button\",\n \"submit\",\n \"reset\",\n \"color\",\n \"file\",\n \"image\",\n \"hidden\",\n]\n\n/** Where a keystroke types text rather than issuing a command: a text-like\n * `input`, a `textarea`, or a `contenteditable`. Not a checkbox, radio,\n * slider or file input, nor a `select` or a button: keys there are commands. */\nconst TEXT_FIELD = [\n \"textarea\",\n '[contenteditable]:not([contenteditable=\"false\"])',\n `input${NON_TEXT_INPUTS.map((type) => `:not([type=\"${type}\"])`).join(\"\")}`,\n].join(\", \")\n\nconst inTextField = (target: EventTarget | null): boolean =>\n target instanceof Element && target.closest(TEXT_FIELD) !== null\n\ntype Inputs = \"allow\" | \"ignore\" | \"only\"\n\n/** Whether `inputs` lets an event through, given whether it came from a text field. */\nconst INPUTS: Record<Inputs, (typing: boolean) => boolean> = {\n allow: () => true,\n ignore: (typing) => !typing,\n only: (typing) => typing,\n}\n\n/** The boolean form, kept from before the three modes. */\nconst LEGACY_INPUTS: Record<\"true\" | \"false\", Inputs> = { true: \"allow\", false: \"ignore\" }\n\n/** Can't type a character: it holds ⌘/Ctrl/Alt, or is a modifier itself. */\nconst chorded = (hotkey: ParsedHotkey): boolean =>\n hotkey.meta || hotkey.ctrl || hotkey.alt || Object.values(MODIFIER_KEY).includes(hotkey.key)\n\n/** The mode `inputs` resolves to for one hotkey. */\nconst inputMode = (inputs: HotkeyOptions[\"inputs\"], hotkey: ParsedHotkey): Inputs =>\n typeof inputs === \"boolean\"\n ? LEGACY_INPUTS[`${inputs}`]\n : (inputs ?? (chorded(hotkey) ? \"allow\" : \"ignore\"))\n\n/** A scope that can't take part right now: inert (a closed Collapse) or\n * hidden (an inactive Tabs panel), itself or through an ancestor. */\nconst unavailable = (scope: Element): boolean => scope.closest(\"[inert], [hidden]\") !== null\n\n/** The default `when`: skip what a component already handled. */\nconst unhandled = (event: KeyboardEvent): boolean => !event.defaultPrevented\n\nexport type HotkeyOptions = {\n /**\n * Whether the hotkey fires while typing in a text field (a text `input`,\n * `textarea` or `contenteditable`; buttons, sliders, checkboxes and selects\n * are not text fields):\n *\n * - `\"allow\"` (or `true`): anywhere, e.g. ⌘K.\n * - `\"ignore\"` (or `false`): not while typing, e.g. `/` or `?`, which would\n * otherwise swallow the character being typed (WCAG 2.1.4).\n * - `\"only\"`: only while typing, e.g. ⌘↵ to submit, Esc to clear.\n *\n * Defaults to `\"allow\"` for a hotkey holding ⌘/Ctrl/Alt (or a bare\n * modifier), which typing can't produce, and `\"ignore\"` for a bare key or a\n * `shift+` one, which would type a character. With an array, each hotkey\n * gets its own default.\n */\n inputs?: Inputs | boolean\n /** Fire only while focus is inside this element. A scope that is `inert`\n * or `hidden` (or inside one) counts as outside. */\n scope?: RefObject<Element | null>\n /** With `scope`: the pointer resting on the scope counts as being inside\n * it, no focus needed (hover a row, press `e` to archive it).\n * @default false */\n hover?: boolean\n /**\n * Yield while an overlay (Modal, Drawer, Popover, a picker's list) is open\n * above the component that bound the hotkey. A page's `j`/`k` go quiet\n * under a Modal; a Modal's own hotkey fires while it is on top and goes\n * quiet when something opens from it. Pass `false` for a hotkey that must\n * also reach the overlay it opened, like a toggle (Spotlight's ⌘K).\n * @default true\n */\n layer?: boolean\n /**\n * Also fire on the keydowns a held key auto-repeats. Off by default: a held\n * key firing an action thirty times a second (toggling fullscreen, opening\n * and closing a panel, deleting rows) is the costly surprise, while the\n * hotkeys that want it (`j`/`k` to move through a list) are few and opt in\n * with one word. A skipped repeat still has its default prevented, so a\n * held ⌘S doesn't fall through to the browser's Save dialog.\n * @default false\n */\n repeat?: boolean\n /** Fire on `keydown`, or on `keyup` for hold-and-release: a `keydown` and a\n * `keyup` hotkey on `\"alt\"` show hints while ⌥ is held.\n * @default \"keydown\" */\n event?: \"keydown\" | \"keyup\"\n /**\n * The last word on whether a matched event fires, after every option above.\n * Covers what they don't, such as yielding to a focused button or slider.\n *\n * It replaces the default, which skips an event a component already\n * handled (`event.defaultPrevented`: Select's ↵, zag's Esc). Keep that\n * check in yours unless the hotkey should run even then:\n *\n * when: (event) => !event.defaultPrevented && !isSlider(event.target)\n * when: () => true // also fire on handled events\n */\n when?: (event: KeyboardEvent) => boolean\n}\n\n/**\n * Call `handler` when one of `keys` is pressed. `false` (or `undefined`) binds\n * nothing. The matched event's default is prevented, so the browser's own\n * shortcut on the same keys doesn't also run.\n *\n * By default it fires anywhere in the document, except: in a text field for a\n * bare-key hotkey (`/`, `?`; a ⌘/Ctrl/Alt one fires there too), while an\n * overlay is open above the component that bound it, on a held key's\n * repeats, or on an event a component already handled. The options narrow or\n * widen that; see `HotkeyOptions`. A hotkey with an unknown modifier binds\n * nothing and warns in development.\n *\n * useHotkey(\"mod+k\", () => spotlight.toggle(), { layer: false })\n * useHotkey(\"/\", () => search.focus(), { inputs: \"ignore\" })\n * useHotkey([\"j\", \"arrowdown\"], next, { scope: list, repeat: true })\n */\nexport function useHotkey(\n keys: string | string[] | false | undefined,\n handler: (event: KeyboardEvent) => void,\n {\n inputs,\n scope,\n hover = false,\n layer = true,\n repeat = false,\n event: type = \"keydown\",\n when = unhandled,\n }: HotkeyOptions = {},\n): void {\n const onMatch = useEffectEvent(handler)\n const allowed = useEffectEvent(when)\n const covered = useLayerCovered()\n // One string for the deps, so an inline array doesn't rebind every render.\n // A newline can't be part of a hotkey.\n const signature = keys ? [keys].flat().join(\"\\n\") : \"\"\n useEffect(() => {\n if (!signature) return\n const hotkeys = signature.split(\"\\n\")\n const parsed = hotkeys.map((hotkey) => parseHotkey(hotkey))\n const unknown = parsed.flatMap((hotkey) => hotkey.unknown)\n if (unknown.length > 0) {\n devWarn(\n `useHotkey(\"${hotkeys.join('\", \"')}\"): unknown modifier ${unknown.map((part) => `\"${part}\"`).join(\", \")}, so nothing is bound. Use mod, meta (cmd, command), ctrl (control), alt (option) or shift, joined with \"+\", the key last: \"mod+shift+k\".`,\n )\n return\n }\n // The element under the pointer, for `hover`.\n let pointed: EventTarget | null = null\n const onPointerOver = (event: PointerEvent) => {\n pointed = event.target\n }\n const onPointerOut = (event: PointerEvent) => {\n // Out of the window: nothing is hovered any more.\n if (event.relatedTarget === null) pointed = null\n }\n const inScope = (event: KeyboardEvent): boolean => {\n if (!scope) return true\n const element = scope.current\n if (!element || unavailable(element)) return false\n const inside = (target: EventTarget | null) =>\n target instanceof Node && element.contains(target)\n return inside(event.target) || (hover && inside(pointed))\n }\n const onKey = (event: KeyboardEvent) => {\n const matched = parsed.find((hotkey) => matchParsed(hotkey, event))\n if (!matched) return\n if (layer && covered()) return\n if (!INPUTS[inputMode(inputs, matched)](inTextField(event.target))) return\n if (!inScope(event)) return\n if (!allowed(event)) return\n event.preventDefault()\n if (event.repeat && !repeat) return\n onMatch(event)\n }\n window.addEventListener(type, onKey)\n if (hover) {\n document.addEventListener(\"pointerover\", onPointerOver)\n document.addEventListener(\"pointerout\", onPointerOut)\n }\n return () => {\n window.removeEventListener(type, onKey)\n document.removeEventListener(\"pointerover\", onPointerOver)\n document.removeEventListener(\"pointerout\", onPointerOut)\n }\n }, [signature, inputs, scope, hover, layer, repeat, type, covered])\n}\n\nconst noSubscription = () => () => {}\n\n/**\n * Whether `mod` is ⌘ for this user, to label a shortcut hint (`⌘` vs `Ctrl`).\n * `false` during SSR and hydration, so the markup can't mismatch.\n */\nexport const useApplePlatform = (): boolean =>\n useSyncExternalStore(noSubscription, isApplePlatform, () => false)\n"]}
1
+ {"version":3,"sources":["../src/lib/use-hotkey.ts"],"names":[],"mappings":";;;;;AAsCA,IAAM,QAAA,GAAoD;AAAA,EACxD,GAAA,EAAK,KAAA;AAAA,EACL,IAAA,EAAM,MAAA;AAAA,EACN,GAAA,EAAK,MAAA;AAAA,EACL,OAAA,EAAS,MAAA;AAAA,EACT,IAAA,EAAM,MAAA;AAAA,EACN,OAAA,EAAS,MAAA;A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AAK","file":"chunk-JKFPRQB2.js","sourcesContent":["\"use client\"\n\nimport {\n ArrowBigUp,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowRightToLine,\n ArrowUp,\n ChevronUp,\n Command,\n CornerDownLeft,\n Delete,\n type LucideIcon,\n Option,\n} from \"lucide-react\"\nimport { type RefObject, useEffect, useEffectEvent, useSyncExternalStore } from \"react\"\nimport { devWarn } from \"./dev-warn\"\nimport { useLayerCovered } from \"./overlay-layer\"\n\n/**\n * A small, platform-aware keyboard shortcut matcher: `\"mod+k\"`, `\"shift+mod+p\"`,\n * `\"alt+/\"`.\n *\n * - `mod` is ⌘ on Apple platforms and Ctrl elsewhere, the usual convention for\n * app shortcuts. `meta` / `cmd` and `ctrl` name one key explicitly.\n * - The last part is the key, compared case-insensitively with `event.key`, so\n * it follows the user's keyboard layout. The space bar is `space`. Modifiers must match exactly:\n * `mod+k` doesn't fire on ⌘⇧K.\n * - The key can be a modifier itself (`\"alt\"`, for hold-to-peek): its own flag\n * is then ignored, since pressing ⌥ sets `altKey` and releasing it clears it.\n * - An event fired while an IME is composing is ignored.\n * - A part that names no modifier (`\"ctl+k\"`) makes the hotkey match nothing,\n * rather than silently dropping it and firing on a bare `k`.\n */\n\ntype Modifiers = { meta: boolean; ctrl: boolean; alt: boolean; shift: boolean }\n\nconst MODIFIER: Record<string, keyof Modifiers | \"mod\"> = {\n mod: \"mod\",\n meta: \"meta\",\n cmd: \"meta\",\n command: \"meta\",\n ctrl: \"ctrl\",\n control: \"ctrl\",\n alt: \"alt\",\n option: \"alt\",\n shift: \"shift\",\n}\n\n/** A modifier as the key itself, spelled the way `event.key` spells it. */\nconst MODIFIER_KEY: Record<keyof Modifiers, string> = {\n meta: \"meta\",\n ctrl: \"control\",\n alt: \"alt\",\n shift: \"shift\",\n}\n\n/** Whether the user agent is an Apple platform (macOS, iOS, iPadOS): `mod` is ⌘ there. */\nexport const isApplePlatform = (): boolean => {\n if (typeof navigator === \"undefined\") return false\n const nav: Navigator & { userAgentData?: { platform?: string } } = navigator\n return /mac|iphone|ipad|ipod/i.test(nav.userAgentData?.platform ?? nav.platform ?? \"\")\n}\n\nexport type ParsedHotkey = Modifiers & {\n key: string\n /** Modifier parts that name no known modifier — a typo like `ctl`. */\n unknown: string[]\n}\n\ntype HotkeyEvent = Pick<\n KeyboardEvent,\n \"key\" | \"metaKey\" | \"ctrlKey\" | \"altKey\" | \"shiftKey\" | \"isComposing\"\n>\n\nconst resolveModifier = (part: string, apple: boolean): keyof Modifiers | undefined => {\n const modifier = MODIFIER[part]\n return modifier === \"mod\" ? (apple ? \"meta\" : \"ctrl\") : modifier\n}\n\n/** Parse a hotkey once: its key and the exact modifiers it needs. */\nexport const parseHotkey = (hotkey: string, apple = isApplePlatform()): ParsedHotkey => {\n const parts = hotkey\n .toLowerCase()\n .split(\"+\")\n .map((part) => part.trim())\n // A trailing \"+\" names the plus key itself: \"mod++\".\n const last = hotkey.endsWith(\"+\") ? \"+\" : (parts.at(-1) ?? \"\")\n const named = parts.slice(0, hotkey.endsWith(\"+\") ? -2 : -1)\n // A modifier as the key (`\"alt\"`, `\"mod\"`) is spelled as `event.key` has it.\n const self = resolveModifier(last, apple)\n const modifiers = named.map((part) => resolveModifier(part, apple))\n return {\n key: self ? MODIFIER_KEY[self] : last,\n meta: modifiers.includes(\"meta\"),\n ctrl: modifiers.includes(\"ctrl\"),\n alt: modifiers.includes(\"alt\"),\n shift: modifiers.includes(\"shift\"),\n unknown: named.filter((part) => MODIFIER[part] === undefined),\n }\n}\n\n/** Whether `event` is the already-parsed hotkey. */\nconst matchParsed = (parsed: ParsedHotkey, event: HotkeyEvent): boolean => {\n // `event.key` is a literal \" \" for the space bar, which a hotkey spells `space`.\n const key = event.key === \" \" ? \"space\" : event.key.toLowerCase()\n // Pressing a modifier sets its own flag (and releasing it clears it), so a\n // modifier that is the key itself is checked by `key` alone.\n const flag = (modifier: keyof Modifiers, pressed: boolean) =>\n key === MODIFIER_KEY[modifier] || pressed === parsed[modifier]\n return (\n !event.isComposing &&\n parsed.unknown.length === 0 &&\n key === parsed.key &&\n flag(\"meta\", event.metaKey) &&\n flag(\"ctrl\", event.ctrlKey) &&\n flag(\"alt\", event.altKey) &&\n flag(\"shift\", event.shiftKey)\n )\n}\n\n/** Whether `event` is `hotkey`. See the module doc for the rules. */\nexport const matchHotkey = (\n hotkey: string,\n event: HotkeyEvent,\n apple = isApplePlatform(),\n): boolean => matchParsed(parseHotkey(hotkey, apple), event)\n\n/**\n * The words a key cap reads as, keyed by the English string each replaces:\n * the word a cap shows (`ctrl`, `escape`) or the name it is spoken by (`command`,\n * `up`). Apple and the other platforms name some keys differently, so each\n * spelling has its own key: `return` / `enter`, `option` / `alt`, `delete`\n * (⌫ on a Mac) / `backspace`. `KEY_LABEL` says which key uses which; these\n * only replace the strings. `Intl` has no display names for keys, so these are\n * plain translations, English by default (`KBD_DEFAULT_TRANSLATIONS`).\n */\nexport type KbdTranslations = {\n /** ⌘, spoken on Apple. */\n command: string\n /** The Meta (Windows) key's word, off Apple. */\n meta: string\n /** ⌃, spoken on Apple. */\n control: string\n /** Ctrl's word, off Apple. \"Strg\" on a German keyboard. */\n ctrl: string\n /** ⌥, spoken on Apple. */\n option: string\n /** Alt's word, off Apple. */\n alt: string\n /** ⇧, spoken on every platform. */\n shift: string\n /** ↵, spoken on Apple. */\n return: string\n /** ↵, spoken off Apple. \"Entrée\" in French. */\n enter: string\n /** ⌫, spoken on Apple. */\n delete: string\n /** ⌫'s word, off Apple. \"Rücktaste\" in German, \"Retour arrière\" in French. */\n backspace: string\n /** ⌦, spoken on Apple. */\n forwardDelete: string\n /** ⌦'s word, off Apple. \"Suppr\" on a French keyboard, \"Entf\" on a German one. */\n del: string\n /** ⇥, spoken on every platform. */\n tab: string\n /** The arrows, spoken on every platform. */\n up: string\n down: string\n left: string\n right: string\n /** Esc's word, on every platform. \"Échap\" on a French keyboard. */\n escape: string\n /** The space bar's word, on every platform. */\n space: string\n /** Page Up and Page Down's words, on every platform. */\n pageUp: string\n pageDown: string\n}\n\n/** The English key words: what `<Kbd hotkey>`, `hotkeyKeys` and `formatHotkey`\n * read as without `translations`, and the base a partial override is merged onto. */\nexport const KBD_DEFAULT_TRANSLATIONS = {\n command: \"Command\",\n meta: \"Meta\",\n control: \"Control\",\n ctrl: \"Ctrl\",\n option: \"Option\",\n alt: \"Alt\",\n shift: \"Shift\",\n return: \"Return\",\n enter: \"Enter\",\n delete: \"Delete\",\n backspace: \"Backspace\",\n forwardDelete: \"Forward Delete\",\n del: \"Del\",\n tab: \"Tab\",\n up: \"Up Arrow\",\n down: \"Down Arrow\",\n left: \"Left Arrow\",\n right: \"Right Arrow\",\n escape: \"Esc\",\n space: \"Space\",\n pageUp: \"PgUp\",\n pageDown: \"PgDn\",\n} as const satisfies KbdTranslations\n\ntype KeyWord = keyof KbdTranslations\n\n/**\n * How a key reads on a key cap. One entry per key that doesn't read as typed:\n *\n * - `glyph`: the symbol Apple writes (⌘, ⇧, ↵), spoken there as `name` (a\n * bare `⌘` has no reliable spoken form).\n * - `text`: the word Windows and Linux write (`Ctrl`, `Shift`, `Enter`),\n * spoken there as itself.\n * - `icon`: what a `<Kbd>` cap draws for the key on every platform, so\n * Shift is the same arrow on a Mac and on a PC.\n * - `appleIcon`: an icon drawn on Apple only: the symbols only Apple uses\n * (⌘ ⌥ ⌃), and ⌫. Elsewhere those keys stay words: there is no honest icon\n * for Ctrl, Alt or the Windows key, and ⌫ reads as the Left Arrow there,\n * where the keyboard prints \"Backspace\".\n *\n * `text` and `name` are `KbdTranslations` keys, so a translation replaces the\n * word and never the key data. Apple platforms take the glyph and fall back to\n * the text; elsewhere it is the reverse, so a key with only a glyph (the\n * arrows) is a symbol everywhere and one with only a text (`Esc`) is a word\n * everywhere. Anything not listed is shown as typed, its first letter\n * upper-cased.\n */\ntype KeyLabel = {\n glyph?: string\n text?: KeyWord\n icon?: LucideIcon\n appleIcon?: LucideIcon\n name?: KeyWord\n}\n\nconst KEY_LABEL: Record<string, KeyLabel> = {\n meta: { glyph: \"⌘\", appleIcon: Command, name: \"command\", text: \"meta\" },\n control: { glyph: \"⌃\", appleIcon: ChevronUp, name: \"control\", text: \"ctrl\" },\n alt: { glyph: \"⌥\", appleIcon: Option, name: \"option\", text: \"alt\" },\n shift: { glyph: \"⇧\", icon: ArrowBigUp, name: \"shift\", text: \"shift\" },\n enter: { glyph: \"↵\", icon: CornerDownLeft, name: \"return\", text: \"enter\" },\n // An icon on Apple only: elsewhere ⌫ reads as ← (the Left Arrow), and the key\n // is printed \"Backspace\" on those keyboards.\n backspace: { glyph: \"⌫\", appleIcon: Delete, name: \"delete\", text: \"backspace\" },\n delete: { glyph: \"⌦\", name: \"forwardDelete\", text: \"del\" },\n tab: { glyph: \"⇥\", icon: ArrowRightToLine, name: \"tab\", text: \"tab\" },\n arrowup: { glyph: \"↑\", icon: ArrowUp, name: \"up\" },\n arrowdown: { glyph: \"↓\", icon: ArrowDown, name: \"down\" },\n arrowleft: { glyph: \"←\", icon: ArrowLeft, name: \"left\" },\n arrowright: { glyph: \"→\", icon: ArrowRight, name: \"right\" },\n // macOS menus spell these out too.\n escape: { text: \"escape\" },\n esc: { text: \"escape\" },\n space: { text: \"space\" },\n pageup: { text: \"pageUp\" },\n pagedown: { text: \"pageDown\" },\n}\n\n/** Apple's order for modifier glyphs (⌃⌥⇧⌘), used on every platform. */\nconst MODIFIER_ORDER: (keyof Modifiers)[] = [\"ctrl\", \"alt\", \"shift\", \"meta\"]\n\n/**\n * One key cap of a hotkey: the text it reads as (`label`), and, when the\n * key is drawn rather than written, the `icon` to draw (none for a glyph\n * with no icon, like ⌦) and the `name` to speak.\n * `id` tells caps apart (`\"ctrl\"`, `\"shift\"`, …, `\"key\"` for the last).\n */\nexport type HotkeyCap = { id: string; label: string; icon?: LucideIcon; name?: string }\n\nconst keyCap = (\n id: string,\n key: string,\n apple: boolean,\n translations: Partial<KbdTranslations> | undefined,\n): HotkeyCap => {\n const entry = KEY_LABEL[key]\n // Merged per key; a key set to `undefined` keeps its English word.\n const word = (of?: KeyWord) => of && (translations?.[of] ?? KBD_DEFAULT_TRANSLATIONS[of])\n const text = word(entry?.text)\n const spoken = word(entry?.name)\n const label =\n (apple ? (entry?.glyph ?? text) : (text ?? entry?.glyph)) ??\n key.charAt(0).toUpperCase() + key.slice(1)\n const icon = apple ? (entry?.appleIcon ?? entry?.icon) : entry?.icon\n // Spoken the platform's way: Apple's key names there (\"Return\"), the\n // word elsewhere (\"Enter\"), the arrows' names on both.\n const name = apple ? spoken : (text ?? spoken)\n // An icon, or Apple's glyph where it has none (⌦), is drawn and spoken by\n // name; a word reads as itself.\n const drawn = icon !== undefined || (label === entry?.glyph && apple)\n return drawn && name ? { id, label, name, ...(icon && { icon }) } : { id, label }\n}\n\n/**\n * The caps of a hotkey, modifiers first in Apple's order. What `<Kbd hotkey>`\n * renders; `hotkeyKeys` is its text. `translations` replaces the English key\n * words per key (see `KbdTranslations`).\n */\nexport const hotkeyCaps = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): HotkeyCap[] => {\n const parsed = parseHotkey(hotkey, apple)\n return [\n ...MODIFIER_ORDER.filter((modifier) => parsed[modifier]).map((modifier) =>\n keyCap(modifier, MODIFIER_KEY[modifier], apple, translations),\n ),\n keyCap(\"key\", parsed.key, apple, translations),\n ]\n}\n\n/**\n * The keys of a hotkey, one label per key cap, the way the platform writes\n * them: `\"mod+k\"` is `[\"⌘\", \"K\"]` on Apple platforms and `[\"Ctrl\", \"K\"]`\n * elsewhere, `\"shift+mod+p\"` is `[\"⇧\", \"⌘\", \"P\"]` / `[\"Ctrl\", \"Shift\", \"P\"]`.\n * Modifiers come in Apple's order (⌃⌥⇧⌘) whatever order the string names\n * them in. Render one `<kbd>` per label, or let `<Kbd hotkey>` do it.\n *\n * `apple` defaults to the current platform, which a server can't know: while\n * rendering, pass `useApplePlatform()` so the server markup and the first\n * client render agree. `translations` is `<Kbd>`'s, so the text and the caps\n * read the same: `{ ctrl: \"Strg\" }` gives `[\"Strg\", \"K\"]`.\n */\nexport const hotkeyKeys = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): string[] => hotkeyCaps(hotkey, apple, translations).map((cap) => cap.label)\n\n/**\n * The label for a hotkey as one string, for plain-text places (a `title`, a\n * tooltip, a menu's text): `hotkeyKeys` joined, the Apple way with no space\n * (`⌘K`, `⇧⌘P`) and with a space elsewhere (`Ctrl K`, `Ctrl Shift P`).\n * On screen, prefer `<Kbd hotkey>`, which draws one cap per key.\n *\n * `apple` defaults to the current platform, which a server can't know: while\n * rendering, pass `useApplePlatform()` so the server markup and the first\n * client render agree. `translations` is `<Kbd>`'s (`{ ctrl: \"Strg\" }` gives\n * `Strg K`).\n */\nexport const formatHotkey = (\n hotkey: string,\n apple = isApplePlatform(),\n translations?: Partial<KbdTranslations>,\n): string => hotkeyKeys(hotkey, apple, translations).join(apple ? \"\" : \" \")\n\n/** Input types where keys are commands, not text. */\nconst NON_TEXT_INPUTS = [\n \"checkbox\",\n \"radio\",\n \"range\",\n \"button\",\n \"submit\",\n \"reset\",\n \"color\",\n \"file\",\n \"image\",\n \"hidden\",\n]\n\n/** Where a keystroke types text rather than issuing a command: a text-like\n * `input`, a `textarea`, or a `contenteditable`. Not a checkbox, radio,\n * slider or file input, nor a `select` or a button: keys there are commands. */\nconst TEXT_FIELD = [\n \"textarea\",\n '[contenteditable]:not([contenteditable=\"false\"])',\n `input${NON_TEXT_INPUTS.map((type) => `:not([type=\"${type}\"])`).join(\"\")}`,\n].join(\", \")\n\nconst inTextField = (target: EventTarget | null): boolean =>\n target instanceof Element && target.closest(TEXT_FIELD) !== null\n\ntype Inputs = \"allow\" | \"ignore\" | \"only\"\n\n/** Whether `inputs` lets an event through, given whether it came from a text field. */\nconst INPUTS: Record<Inputs, (typing: boolean) => boolean> = {\n allow: () => true,\n ignore: (typing) => !typing,\n only: (typing) => typing,\n}\n\n/** The boolean form, kept from before the three modes. */\nconst LEGACY_INPUTS: Record<\"true\" | \"false\", Inputs> = { true: \"allow\", false: \"ignore\" }\n\n/** Can't type a character: it holds ⌘/Ctrl/Alt, or is a modifier itself. */\nconst chorded = (hotkey: ParsedHotkey): boolean =>\n hotkey.meta || hotkey.ctrl || hotkey.alt || Object.values(MODIFIER_KEY).includes(hotkey.key)\n\n/** The mode `inputs` resolves to for one hotkey. */\nconst inputMode = (inputs: HotkeyOptions[\"inputs\"], hotkey: ParsedHotkey): Inputs =>\n typeof inputs === \"boolean\"\n ? LEGACY_INPUTS[`${inputs}`]\n : (inputs ?? (chorded(hotkey) ? \"allow\" : \"ignore\"))\n\n/** A scope that can't take part right now: inert (a closed Collapse) or\n * hidden (an inactive Tabs panel), itself or through an ancestor. */\nconst unavailable = (scope: Element): boolean => scope.closest(\"[inert], [hidden]\") !== null\n\n/** The default `when`: skip what a component already handled. */\nconst unhandled = (event: KeyboardEvent): boolean => !event.defaultPrevented\n\nexport type HotkeyOptions = {\n /**\n * Whether the hotkey fires while typing in a text field (a text `input`,\n * `textarea` or `contenteditable`; buttons, sliders, checkboxes and selects\n * are not text fields):\n *\n * - `\"allow\"` (or `true`): anywhere, e.g. ⌘K.\n * - `\"ignore\"` (or `false`): not while typing, e.g. `/` or `?`, which would\n * otherwise swallow the character being typed (WCAG 2.1.4).\n * - `\"only\"`: only while typing, e.g. ⌘↵ to submit, Esc to clear.\n *\n * Defaults to `\"allow\"` for a hotkey holding ⌘/Ctrl/Alt (or a bare\n * modifier), which typing can't produce, and `\"ignore\"` for a bare key or a\n * `shift+` one, which would type a character. With an array, each hotkey\n * gets its own default.\n */\n inputs?: Inputs | boolean\n /** Fire only while focus is inside this element. A scope that is `inert`\n * or `hidden` (or inside one) counts as outside. */\n scope?: RefObject<Element | null>\n /** With `scope`: the pointer resting on the scope counts as being inside\n * it, no focus needed (hover a row, press `e` to archive it).\n * @default false */\n hover?: boolean\n /**\n * Yield while an overlay (Modal, Drawer, Popover, a picker's list) is open\n * above the component that bound the hotkey. A page's `j`/`k` go quiet\n * under a Modal; a Modal's own hotkey fires while it is on top and goes\n * quiet when something opens from it. Pass `false` for a hotkey that must\n * also reach the overlay it opened, like a toggle (Spotlight's ⌘K).\n * @default true\n */\n layer?: boolean\n /**\n * Also fire on the keydowns a held key auto-repeats. Off by default: a held\n * key firing an action thirty times a second (toggling fullscreen, opening\n * and closing a panel, deleting rows) is the costly surprise, while the\n * hotkeys that want it (`j`/`k` to move through a list) are few and opt in\n * with one word. A skipped repeat still has its default prevented, so a\n * held ⌘S doesn't fall through to the browser's Save dialog.\n * @default false\n */\n repeat?: boolean\n /** Fire on `keydown`, or on `keyup` for hold-and-release: a `keydown` and a\n * `keyup` hotkey on `\"alt\"` show hints while ⌥ is held.\n * @default \"keydown\" */\n event?: \"keydown\" | \"keyup\"\n /**\n * The last word on whether a matched event fires, after every option above.\n * Covers what they don't, such as yielding to a focused button or slider.\n *\n * It replaces the default, which skips an event a component already\n * handled (`event.defaultPrevented`: Select's ↵, zag's Esc). Keep that\n * check in yours unless the hotkey should run even then:\n *\n * when: (event) => !event.defaultPrevented && !isSlider(event.target)\n * when: () => true // also fire on handled events\n */\n when?: (event: KeyboardEvent) => boolean\n}\n\n/**\n * Call `handler` when one of `keys` is pressed. `false` (or `undefined`) binds\n * nothing. The matched event's default is prevented, so the browser's own\n * shortcut on the same keys doesn't also run.\n *\n * By default it fires anywhere in the document, except: in a text field for a\n * bare-key hotkey (`/`, `?`; a ⌘/Ctrl/Alt one fires there too), while an\n * overlay is open above the component that bound it, on a held key's\n * repeats, or on an event a component already handled. The options narrow or\n * widen that; see `HotkeyOptions`. A hotkey with an unknown modifier binds\n * nothing and warns in development.\n *\n * useHotkey(\"mod+k\", () => spotlight.toggle(), { layer: false })\n * useHotkey(\"/\", () => search.focus(), { inputs: \"ignore\" })\n * useHotkey([\"j\", \"arrowdown\"], next, { scope: list, repeat: true })\n */\nexport function useHotkey(\n keys: string | string[] | false | undefined,\n handler: (event: KeyboardEvent) => void,\n {\n inputs,\n scope,\n hover = false,\n layer = true,\n repeat = false,\n event: type = \"keydown\",\n when = unhandled,\n }: HotkeyOptions = {},\n): void {\n const onMatch = useEffectEvent(handler)\n const allowed = useEffectEvent(when)\n const covered = useLayerCovered()\n // One string for the deps, so an inline array doesn't rebind every render.\n // A newline can't be part of a hotkey.\n const signature = keys ? [keys].flat().join(\"\\n\") : \"\"\n useEffect(() => {\n if (!signature) return\n const hotkeys = signature.split(\"\\n\")\n const parsed = hotkeys.map((hotkey) => parseHotkey(hotkey))\n const unknown = parsed.flatMap((hotkey) => hotkey.unknown)\n if (unknown.length > 0) {\n devWarn(\n `useHotkey(\"${hotkeys.join('\", \"')}\"): unknown modifier ${unknown.map((part) => `\"${part}\"`).join(\", \")}, so nothing is bound. Use mod, meta (cmd, command), ctrl (control), alt (option) or shift, joined with \"+\", the key last: \"mod+shift+k\".`,\n )\n return\n }\n // The element under the pointer, for `hover`.\n let pointed: EventTarget | null = null\n const onPointerOver = (event: PointerEvent) => {\n pointed = event.target\n }\n const onPointerOut = (event: PointerEvent) => {\n // Out of the window: nothing is hovered any more.\n if (event.relatedTarget === null) pointed = null\n }\n const inScope = (event: KeyboardEvent): boolean => {\n if (!scope) return true\n const element = scope.current\n if (!element || unavailable(element)) return false\n const inside = (target: EventTarget | null) =>\n target instanceof Node && element.contains(target)\n return inside(event.target) || (hover && inside(pointed))\n }\n const onKey = (event: KeyboardEvent) => {\n const matched = parsed.find((hotkey) => matchParsed(hotkey, event))\n if (!matched) return\n if (layer && covered()) return\n if (!INPUTS[inputMode(inputs, matched)](inTextField(event.target))) return\n if (!inScope(event)) return\n if (!allowed(event)) return\n event.preventDefault()\n if (event.repeat && !repeat) return\n onMatch(event)\n }\n window.addEventListener(type, onKey)\n if (hover) {\n document.addEventListener(\"pointerover\", onPointerOver)\n document.addEventListener(\"pointerout\", onPointerOut)\n }\n return () => {\n window.removeEventListener(type, onKey)\n document.removeEventListener(\"pointerover\", onPointerOver)\n document.removeEventListener(\"pointerout\", onPointerOut)\n }\n }, [signature, inputs, scope, hover, layer, repeat, type, covered])\n}\n\nconst noSubscription = () => () => {}\n\n/**\n * Whether `mod` is ⌘ for this user, to label a shortcut hint (`⌘` vs `Ctrl`).\n * `false` during SSR and hydration, so the markup can't mismatch.\n */\nexport const useApplePlatform = (): boolean =>\n useSyncExternalStore(noSubscription, isApplePlatform, () => false)\n"]}
@@ -1,4 +1,4 @@
1
- import { createDialogParts, DIALOG_PADDING, useDialogNameCheck, DialogRootProviders } from './chunk-KYVXPSNW.js';
1
+ import { createDialogParts, DIALOG_PADDING, useDialogNameCheck, DialogRootProviders } from './chunk-V2QZG4IT.js';
2
2
  import { useLayerGuard, NestedLayer } from './chunk-HWBFRDX7.js';
3
3
  import { OverlayContainerProvider } from './chunk-SLUOF7XW.js';
4
4
  import { props } from './chunk-WYCMIIRR.js';
@@ -305,5 +305,5 @@ var Drawer = Object.assign(DrawerComponent, {
305
305
  });
306
306
 
307
307
  export { Drawer };
308
- //# sourceMappingURL=chunk-P7SH3XWY.js.map
309
- //# sourceMappingURL=chunk-P7SH3XWY.js.map
308
+ //# sourceMappingURL=chunk-MQHD3EJE.js.map
309
+ //# sourceMappingURL=chunk-MQHD3EJE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/drawer/drawer.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;AAiDA,IAAM,kBAAA,GAAqB;AAAA,EACzB,KAAA,EAAO,OAAA;AAAA,EACP,GAAA,EAAK,KAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,MAAA,EAAQ;AACV,CAAA;AAGA,IAAM,sBAAA,GAAyB,cAA+B,KAAK,CAAA;AAEnE,IAAM,iBAAiB,GAAA,CAAI;AAAA,EACzB,8HAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,gBAAA,GAAmB,GAAA;AAAA,EACvB,oFAAA;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,SAAA,EAAW;AAAA,Q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EC;AAAA;AAAA;AACH;AAAA;AAAA,SACF,EACF;AAAA,OAAA,EACF;AAAA;AAAA,GACF;AAEJ,CAAA;AAEO,IAAM,MAAA,GAAS,MAAA,CAAO,MAAA,CAAO,eAAA,EAAiB;AAAA,EACnD,IAAA,EAAM,UAAA;AAAA,EACN,OAAA,EAAS,aAAA;AAAA,EACT,OAAA,EAAS,aAAA;AAAA,EACT,QAAA,EAAU,cAAA;AAAA,EACV,UAAA,EAAY,gBAAA;AAAA,EACZ,OAAA,EAAS,aAAA;AAAA,EACT,KAAA,EAAO,WAAA;AAAA,EACP,WAAA,EAAa,iBAAA;AAAA,EACb,YAAA,EAAc,kBAAA;AAAA,EACd,OAAA,EAAS,aAAA;AAAA,EACT,MAAA,EAAQ,YAAA;AAAA,EACR,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ;AACV,CAAC","file":"chunk-P7SH3XWY.js","sourcesContent":["\"use client\"\n\nimport { Drawer as Ark } from \"@ark-ui/react/drawer\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type ReactNode,\n useContext,\n useRef,\n} from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { OverlayContainerProvider } from \"../../lib/overlay-container\"\nimport { NestedLayer, useLayerGuard } from \"../../lib/overlay-layer\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport {\n createDialogParts,\n DIALOG_PADDING,\n type DialogCloseTriggerProps,\n type DialogIconSlot,\n type DialogIcons,\n DialogRootProviders,\n type DialogSectionProps,\n useDialogNameCheck,\n} from \"../overlays/dialog-parts\"\n\n/**\n * Drawer — edge-anchored panel on top of Ark UI's Drawer state machine. Ark\n * owns swipe-to-dismiss, snap points, focus-trap, scroll-lock and the\n * `data-state=\"open|closed\"` attribute; this wrapper adds an RTL-aware\n * `placement` (Ark has none). It is set once, on `Drawer.Root`, which derives\n * Ark's logical `swipeDirection` from it and shares it with the parts through\n * context; the positioner and content write it as `data-placement`. The slide\n * animation and the docked border are pure CSS keyed on `[data-placement]`\n * (see `theme.css`), so `start`/`end` flip automatically under `dir=\"rtl\"`.\n *\n * Mirrors `Modal`'s dual API: high-level `<Drawer open placement size … >` plus\n * low-level parts (`Drawer.Root`, `Drawer.Content`, …). Padding flows through\n * the `--drawer-px` CSS var.\n */\n\nexport type DrawerPlacement = \"start\" | \"end\" | \"top\" | \"bottom\"\n\n/** placement → Ark logical swipe axis (RTL handled by Ark for start/end). */\nconst PLACEMENT_TO_SWIPE = {\n start: \"start\",\n end: \"end\",\n top: \"up\",\n bottom: \"down\",\n} as const\n\n/** The root's placement, so the parts dock themselves without repeating it. */\nconst DrawerPlacementContext = createContext<DrawerPlacement>(\"end\")\n\nconst drawerBackdrop = cva([\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] bg-black/50 backdrop-blur-lg pointer-events-auto select-none\",\n \"data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out\",\n])\n\nconst drawerPositioner = cva(\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] flex overflow-clip\",\n {\n variants: {\n placement: {\n start: \"items-stretch justify-start\",\n end: \"items-stretch justify-end\",\n top: \"items-start justify-stretch\",\n bottom: \"items-end justify-stretch\",\n },\n },\n defaultVariants: { placement: \"end\" },\n },\n)\n\nexport type DrawerPositionerProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Positioner>> &\n WithTestId\n\n/** Docks itself to the root's `placement`. Publishes itself as the portal\n * target for any overlay opened inside the drawer, so a Menu/Select/DatePicker\n * in a drawer body stays above the panel instead of behind it. See\n * `lib/overlay-container.tsx`. */\nconst DrawerPositioner = ({\n className,\n children,\n testId,\n asChild: _asChild,\n ...rest\n}: DrawerPositionerProps) => {\n const placement = useContext(DrawerPlacementContext)\n const positioner = useRef<HTMLDivElement>(null)\n return (\n <Ark.Positioner\n ref={positioner}\n className={cn(drawerPositioner({ placement }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n data-placement={placement}\n >\n <OverlayContainerProvider value={positioner}>{children}</OverlayContainerProvider>\n </Ark.Positioner>\n )\n}\n\nconst drawerContent = cva(\n [\n \"relative flex flex-col overflow-hidden\",\n \"bg-brand-50 text-brand-950 shadow-2xl\",\n \"dark:bg-brand-950 dark:text-white\",\n \"focus:outline-none\",\n // border on the docked edge only — keyed by data-placement in theme.css\n \"data-[placement=start]:border-e data-[placement=end]:border-s\",\n \"data-[placement=top]:border-b data-[placement=bottom]:border-t\",\n \"border-brand-900/20 dark:border-white/15\",\n \"data-[state=open]:animate-drawer-in data-[state=closed]:animate-drawer-out\",\n ],\n {\n variants: {\n // Internal: Content reads it from the root's context.\n placement: {\n start: \"h-full max-w-[90vw]\",\n end: \"h-full max-w-[90vw]\",\n top: \"w-full max-h-[90dvh]\",\n bottom: \"w-full max-h-[90dvh]\",\n },\n // Width for inline placements, height for block ones: see compoundVariants.\n size: { xs: \"\", sm: \"\", md: \"\", lg: \"\", xl: \"\" },\n // Only the two corners away from the docked edge round: see compoundVariants.\n radius: { none: \"\", sm: \"\", md: \"\", lg: \"\", xl: \"\" },\n },\n compoundVariants: [\n { placement: [\"start\", \"end\"], size: \"xs\", class: \"w-[18rem]\" },\n { placement: [\"start\", \"end\"], size: \"sm\", class: \"w-[22rem]\" },\n { placement: [\"start\", \"end\"], size: \"md\", class: \"w-[28rem]\" },\n { placement: [\"start\", \"end\"], size: \"lg\", class: \"w-[34rem]\" },\n { placement: [\"start\", \"end\"], size: \"xl\", class: \"w-[42rem]\" },\n { placement: [\"top\", \"bottom\"], size: \"xs\", class: \"h-[30dvh]\" },\n { placement: [\"top\", \"bottom\"], size: \"sm\", class: \"h-[40dvh]\" },\n { placement: [\"top\", \"bottom\"], size: \"md\", class: \"h-[55dvh]\" },\n { placement: [\"top\", \"bottom\"], size: \"lg\", class: \"h-[70dvh]\" },\n { placement: [\"top\", \"bottom\"], size: \"xl\", class: \"h-[85dvh]\" },\n // Logical corners, so `start`/`end` mirror under RTL with the panel.\n { placement: \"start\", radius: \"sm\", class: \"rounded-e-sm\" },\n { placement: \"start\", radius: \"md\", class: \"rounded-e-md\" },\n { placement: \"start\", radius: \"lg\", class: \"rounded-e-xl\" },\n { placement: \"start\", radius: \"xl\", class: \"rounded-e-2xl\" },\n { placement: \"end\", radius: \"sm\", class: \"rounded-s-sm\" },\n { placement: \"end\", radius: \"md\", class: \"rounded-s-md\" },\n { placement: \"end\", radius: \"lg\", class: \"rounded-s-xl\" },\n { placement: \"end\", radius: \"xl\", class: \"rounded-s-2xl\" },\n { placement: \"top\", radius: \"sm\", class: \"rounded-b-sm\" },\n { placement: \"top\", radius: \"md\", class: \"rounded-b-md\" },\n { placement: \"top\", radius: \"lg\", class: \"rounded-b-xl\" },\n { placement: \"top\", radius: \"xl\", class: \"rounded-b-2xl\" },\n { placement: \"bottom\", radius: \"sm\", class: \"rounded-t-sm\" },\n { placement: \"bottom\", radius: \"md\", class: \"rounded-t-md\" },\n { placement: \"bottom\", radius: \"lg\", class: \"rounded-t-xl\" },\n { placement: \"bottom\", radius: \"xl\", class: \"rounded-t-2xl\" },\n ],\n defaultVariants: { placement: \"end\", size: \"md\", radius: \"none\" },\n },\n)\n\n// ---------------------------------------------------------------------------\n// Low-level parts\n// ---------------------------------------------------------------------------\n\nexport type DrawerIconSlot = DialogIconSlot\nexport type DrawerIcons = DialogIcons\n\nexport type DrawerRootProps = ComponentPropsWithoutRef<typeof Ark.Root> & {\n /** RTL-aware docking edge, shared with `Drawer.Positioner` and `Drawer.Content`. Also\n * sets Ark's `swipeDirection`, unless you pass one. @default \"end\" */\n placement?: DrawerPlacement\n /** Replaces the default icons: `close`. `Drawer.CloseTrigger`'s `children` win over it. */\n icons?: DrawerIcons\n}\n\n/** Ark's root, plus the nested-layer guard: while a picker opened inside the\n * drawer is open, an outside click closes the picker only, not the drawer\n * under it. It is also a layer of its own while open, so a hotkey on the page\n * (or in an enclosing overlay) yields to it. See `lib/overlay-layer.tsx`. */\nconst DrawerRoot = ({\n placement = \"end\",\n swipeDirection,\n onPointerDownOutside,\n icons,\n children,\n ...rest\n}: DrawerRootProps) => {\n const guard = useLayerGuard(onPointerDownOutside)\n return (\n <Ark.Root\n swipeDirection={swipeDirection ?? PLACEMENT_TO_SWIPE[placement]}\n onPointerDownOutside={guard.onPointerDownOutside}\n {...rest}\n >\n {/* A layer itself, registered with whatever it opened from (the page,\n or an enclosing overlay), so what's under it knows it's covered. */}\n <Ark.Context>{(api) => <NestedLayer open={api.open} modal />}</Ark.Context>\n <DrawerPlacementContext value={placement}>\n <DialogRootProviders icons={icons} layers={guard.layers}>\n {children}\n </DialogRootProviders>\n </DrawerPlacementContext>\n </Ark.Root>\n )\n}\nconst DrawerTrigger = Ark.Trigger\nconst DrawerContext = Ark.Context\n\nexport type DrawerBackdropProps = ComponentPropsWithoutRef<typeof Ark.Backdrop> & WithTestId\n\nconst DrawerBackdrop = ({ className, testId, ...rest }: DrawerBackdropProps) => (\n <Ark.Backdrop\n className={cn(drawerBackdrop(), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type DrawerTitleProps = ComponentPropsWithoutRef<typeof Ark.Title> & WithTestId\n\nconst DrawerTitle = ({ className, testId, ...rest }: DrawerTitleProps) => (\n <Ark.Title\n className={cn(\"text-xl font-semibold leading-tight\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type DrawerDescriptionProps = ComponentPropsWithoutRef<typeof Ark.Description> & WithTestId\n\nconst DrawerDescription = ({ className, testId, ...rest }: DrawerDescriptionProps) => (\n <Ark.Description\n className={cn(\"text-sm\", TEXT_COLOR_CLASSES.muted, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type DrawerSize = NonNullable<VariantProps<typeof drawerContent>[\"size\"]>\nexport type DrawerRadius = NonNullable<VariantProps<typeof drawerContent>[\"radius\"]>\n\nexport type DrawerContentProps = ComponentPropsWithoutRef<typeof Ark.Content> &\n WithTestId & {\n /** Width for `start`/`end` drawers, height for `top`/`bottom` ones. @default \"md\" */\n size?: DrawerSize\n /** Rounds the two corners away from the docked edge. @default \"none\" */\n radius?: DrawerRadius\n }\n\n/** The panel. It sizes and rounds itself for the root's `placement`, and writes\n * it as `data-placement`, which the slide animation and the docked border key on. */\nconst DrawerContent = ({ className, size, radius, testId, ...rest }: DrawerContentProps) => {\n const placement = useContext(DrawerPlacementContext)\n const nameCheck = useDialogNameCheck(\"Drawer\")\n return (\n <Ark.Content\n ref={nameCheck}\n className={cn(drawerContent({ placement, size, radius }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n data-placement={placement}\n />\n )\n}\n\nexport type DrawerCloseTriggerProps = DialogCloseTriggerProps\nexport type DrawerHeaderProps = DialogSectionProps\nexport type DrawerBodyProps = DialogSectionProps\nexport type DrawerFooterProps = DialogSectionProps\n\nconst {\n CloseTrigger: DrawerCloseTrigger,\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n} = createDialogParts(\"drawer\", Ark.CloseTrigger)\n\nexport type DrawerGrabberProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Grabber>> &\n WithTestId\n\nconst DrawerGrabber = ({ className, testId, asChild: _asChild, ...rest }: DrawerGrabberProps) => (\n <Ark.Grabber\n className={cn(\n \"flex shrink-0 cursor-grab touch-none items-center justify-center py-2\",\n className,\n )}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <Ark.GrabberIndicator className=\"h-1.5 w-20 rounded-full bg-brand-900/10 dark:bg-white/16\" />\n </Ark.Grabber>\n)\n\n// ---------------------------------------------------------------------------\n// High-level props-driven Drawer\n// ---------------------------------------------------------------------------\n\ntype ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>\n\nexport type DrawerClassNames = Partial<\n Record<\n | \"backdrop\"\n | \"positioner\"\n | \"content\"\n | \"header\"\n | \"title\"\n | \"description\"\n | \"body\"\n | \"grabber\"\n | \"closeButton\",\n string\n >\n>\n\nexport type DrawerProps = Omit<\n ArkRootProps,\n \"open\" | \"defaultOpen\" | \"onOpenChange\" | \"children\" | \"swipeDirection\" | \"role\"\n> &\n WithTestId & {\n /** Controlled open state. */\n open?: boolean\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean\n /** Fires with the next open state. Flattened from Ark's `{ open }`. */\n onOpenChange?: (open: boolean) => void\n /** Fires on close (any source) — Escape, backdrop click, swipe, or a controlled `onOpenChange`. */\n onClose?: () => void\n /** RTL-aware docking edge. @default \"end\" */\n placement?: DrawerPlacement\n /** Width for `start`/`end` drawers, height for `top`/`bottom` ones. @default \"md\" */\n size?: DrawerSize\n /** Rounds the two corners away from the docked edge. @default \"none\" */\n radius?: DrawerRadius\n /** Header title; also the drawer's accessible name. */\n title?: ReactNode\n description?: ReactNode\n /** Accessible name for a drawer without a `title` (a navigation panel, say). */\n \"aria-label\"?: string\n /** Id of an element inside the drawer that names it, when there is no `title`. */\n \"aria-labelledby\"?: string\n /** Render the default close button in the header. @default true */\n withCloseButton?: boolean\n /** Show the drag grabber handle. @default false */\n withGrabber?: boolean\n /**\n * Render the dimming backdrop. Set `false` when an ancestor (e.g. the modals\n * manager) draws a single shared backdrop for the whole overlay stack.\n * @default true\n */\n withBackdrop?: boolean\n /** Inner padding token; sets `--drawer-px`. @default \"md\" */\n padding?: Size\n closeOnEscape?: boolean\n /** Close on a click outside the drawer. @default true, false for an `alertdialog` */\n closeOnInteractOutside?: boolean\n /** Use `alertdialog` semantics (confirm flows). @default \"dialog\" */\n role?: \"dialog\" | \"alertdialog\"\n /** Fires after the exit animation completes — the manager unmounts on this. */\n onExitComplete?: () => void\n /** Portal target. Defaults to `document.body`. */\n container?: HTMLElement | null\n children?: ReactNode\n className?: string\n classNames?: DrawerClassNames\n /** Overrides the default close button's accessible name (`closeTriggerLabel`, default\n * `\"Close\"`). The compound `DrawerCloseTrigger` part takes a plain `aria-label` instead. */\n translations?: DrawerTranslations\n /** Replaces the default icons: `close`, the header's close button. */\n icons?: DrawerIcons\n }\n\n/** The ready-made drawer's wording — `closeTriggerLabel` follows Ark's naming for the\n * same control. */\nexport type DrawerTranslations = { closeTriggerLabel?: string }\n\nconst DrawerComponent = ({\n open,\n defaultOpen,\n onOpenChange,\n onClose,\n placement = \"end\",\n size,\n radius,\n title,\n description,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n withCloseButton = true,\n withGrabber = false,\n withBackdrop = true,\n padding = \"md\",\n closeOnEscape,\n closeOnInteractOutside,\n role,\n onExitComplete,\n container,\n children,\n className,\n classNames,\n testId,\n translations,\n icons,\n ...rest\n}: DrawerProps) => {\n const hasHeader = title != null || description != null || withCloseButton\n\n return (\n <DrawerRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={({ open: next }) => {\n onOpenChange?.(next)\n if (!next) onClose?.()\n }}\n placement={placement}\n closeOnEscape={closeOnEscape}\n // Spelled out to match Modal, whose Ark dialog derives this default from\n // `modal` (so the overlays manager's `withBackdrop={false}` would stop\n // outside clicks there). Ark's drawer defaults it to `true` for every role\n // instead, so here the one behaviour this changes is the `alertdialog`:\n // it stays sticky, as on Modal, unless the caller opts in explicitly.\n closeOnInteractOutside={closeOnInteractOutside ?? role !== \"alertdialog\"}\n role={role}\n // Unmount the whole content tree (incl. the `fixed inset-0` positioner)\n // on close — otherwise the positioner lingers as a transparent overlay\n // that swallows page clicks. `lazyMount` keeps it out of the DOM until\n // first open.\n lazyMount\n unmountOnExit\n modal={withBackdrop}\n onExitComplete={onExitComplete}\n icons={icons}\n {...rest}\n >\n <Portal container={container ? { current: container } : undefined}>\n {withBackdrop && <DrawerBackdrop className={classNames?.backdrop} />}\n <DrawerPositioner className={classNames?.positioner}>\n <DrawerContent\n size={size}\n radius={radius}\n style={{ [\"--drawer-px\" as string]: DIALOG_PADDING[padding] }}\n className={cn(className, classNames?.content)}\n testId={testId}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n >\n {withGrabber && <DrawerGrabber className={classNames?.grabber} />}\n {hasHeader && (\n <DrawerHeader className={classNames?.header}>\n <div className=\"flex flex-col gap-1\">\n {title != null && (\n <DrawerTitle className={classNames?.title}>{title}</DrawerTitle>\n )}\n {description != null && (\n <DrawerDescription className={classNames?.description}>\n {description}\n </DrawerDescription>\n )}\n </div>\n {withCloseButton && (\n <DrawerCloseTrigger\n aria-label={translations?.closeTriggerLabel}\n className={classNames?.closeButton}\n />\n )}\n </DrawerHeader>\n )}\n <DrawerBody\n className={cn(\n !hasHeader && !withGrabber && \"pt-(--drawer-px,1.25rem)\",\n \"pb-(--drawer-px,1.25rem)\",\n classNames?.body,\n )}\n >\n {children}\n </DrawerBody>\n </DrawerContent>\n </DrawerPositioner>\n </Portal>\n </DrawerRoot>\n )\n}\n\nexport const Drawer = Object.assign(DrawerComponent, {\n Root: DrawerRoot,\n Trigger: DrawerTrigger,\n Context: DrawerContext,\n Backdrop: DrawerBackdrop,\n Positioner: DrawerPositioner,\n Content: DrawerContent,\n Title: DrawerTitle,\n Description: DrawerDescription,\n CloseTrigger: DrawerCloseTrigger,\n Grabber: DrawerGrabber,\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n})\n"]}
1
+ {"version":3,"sources":["../src/components/drawer/drawer.tsx"],"names":["Ark"],"mappings":";;;;;;;;;;;;AAiDA,IAAM,kBAAA,GAAqB;AAAA,EACzB,KAAA,EAAO,OAAA;AAAA,EACP,GAAA,EAAK,KAAA;AAAA,EACL,GAAA,EAAK,IAAA;AAAA,EACL,MAAA,EAAQ;AACV,CAAA;AAGA,IAAM,sBAAA,GAAyB,cAA+B,KAAK,CAAA;AAEnE,IAAM,iBAAiB,GAAA,CAAI;AAAA,EACzB,8HAAA;AAAA,EACA;AACF,CAAC,CAAA;AAED,IAAM,gBAAA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AAa,CAAC,WAAA,IAAe,0BAAA;AAAA,oBAC9B,0BAAA;AAAA,oBACA,UAAA,EAAY;AAAA,mBACd;AAAA,kBAEC;AAAA;AAAA;AACH;AAAA;AAAA,SACF,EACF;AAAA,OAAA,EACF;AAAA;AAAA,GACF;AAEJ,CAAA;AAEO,IAAM,MAAA,GAAS,MAAA,CAAO,MAAA,CAAO,eAAA,EAAiB;AAAA,EACnD,IAAA,EAAM,UAAA;AAAA,EACN,OAAA,EAAS,aAAA;AAAA,EACT,OAAA,EAAS,aAAA;AAAA,EACT,QAAA,EAAU,cAAA;AAAA,EACV,UAAA,EAAY,gBAAA;AAAA,EACZ,OAAA,EAAS,aAAA;AAAA,EACT,KAAA,EAAO,WAAA;AAAA,EACP,WAAA,EAAa,iBAAA;AAAA,EACb,YAAA,EAAc,kBAAA;AAAA,EACd,OAAA,EAAS,aAAA;AAAA,EACT,MAAA,EAAQ,YAAA;AAAA,EACR,IAAA,EAAM,UAAA;AAAA,EACN,MAAA,EAAQ;AACV,CAAC","file":"chunk-MQHD3EJE.js","sourcesContent":["\"use client\"\n\nimport { Drawer as Ark } from \"@ark-ui/react/drawer\"\nimport { Portal } from \"@ark-ui/react/portal\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport {\n type ComponentPropsWithoutRef,\n createContext,\n type ReactNode,\n useContext,\n useRef,\n} from \"react\"\nimport type { NoAsChild } from \"../../lib/as-child\"\nimport { cn } from \"../../lib/cn\"\nimport { OverlayContainerProvider } from \"../../lib/overlay-container\"\nimport { NestedLayer, useLayerGuard } from \"../../lib/overlay-layer\"\nimport { props } from \"../../lib/props\"\nimport type { Size } from \"../../lib/sizes\"\nimport type { WithTestId } from \"../../lib/test-id\"\nimport { TEXT_COLOR_CLASSES } from \"../../lib/typography-size\"\nimport {\n createDialogParts,\n DIALOG_PADDING,\n type DialogCloseTriggerProps,\n type DialogIconSlot,\n type DialogIcons,\n DialogRootProviders,\n type DialogSectionProps,\n useDialogNameCheck,\n} from \"../overlays/dialog-parts\"\n\n/**\n * Drawer — edge-anchored panel on top of Ark UI's Drawer state machine. Ark\n * owns swipe-to-dismiss, snap points, focus-trap, scroll-lock and the\n * `data-state=\"open|closed\"` attribute; this wrapper adds an RTL-aware\n * `placement` (Ark has none). It is set once, on `Drawer.Root`, which derives\n * Ark's logical `swipeDirection` from it and shares it with the parts through\n * context; the positioner and content write it as `data-placement`. The slide\n * animation and the docked border are pure CSS keyed on `[data-placement]`\n * (see `theme.css`), so `start`/`end` flip automatically under `dir=\"rtl\"`.\n *\n * Mirrors `Modal`'s dual API: high-level `<Drawer open placement size … >` plus\n * low-level parts (`Drawer.Root`, `Drawer.Content`, …). Padding flows through\n * the `--drawer-px` CSS var.\n */\n\nexport type DrawerPlacement = \"start\" | \"end\" | \"top\" | \"bottom\"\n\n/** placement → Ark logical swipe axis (RTL handled by Ark for start/end). */\nconst PLACEMENT_TO_SWIPE = {\n start: \"start\",\n end: \"end\",\n top: \"up\",\n bottom: \"down\",\n} as const\n\n/** The root's placement, so the parts dock themselves without repeating it. */\nconst DrawerPlacementContext = createContext<DrawerPlacement>(\"end\")\n\nconst drawerBackdrop = cva([\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] bg-black/50 backdrop-blur-lg pointer-events-auto select-none\",\n \"data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out\",\n])\n\nconst drawerPositioner = cva(\n \"fixed inset-0 z-[calc(var(--modal-z,150)+var(--layer-index,0))] flex overflow-clip\",\n {\n variants: {\n placement: {\n start: \"items-stretch justify-start\",\n end: \"items-stretch justify-end\",\n top: \"items-start justify-stretch\",\n bottom: \"items-end justify-stretch\",\n },\n },\n defaultVariants: { placement: \"end\" },\n },\n)\n\nexport type DrawerPositionerProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Positioner>> &\n WithTestId\n\n/** Docks itself to the root's `placement`. Publishes itself as the portal\n * target for any overlay opened inside the drawer, so a Menu/Select/DatePicker\n * in a drawer body stays above the panel instead of behind it. See\n * `lib/overlay-container.tsx`. */\nconst DrawerPositioner = ({\n className,\n children,\n testId,\n asChild: _asChild,\n ...rest\n}: DrawerPositionerProps) => {\n const placement = useContext(DrawerPlacementContext)\n const positioner = useRef<HTMLDivElement>(null)\n return (\n <Ark.Positioner\n ref={positioner}\n className={cn(drawerPositioner({ placement }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n data-placement={placement}\n >\n <OverlayContainerProvider value={positioner}>{children}</OverlayContainerProvider>\n </Ark.Positioner>\n )\n}\n\nconst drawerContent = cva(\n [\n \"relative flex flex-col overflow-hidden\",\n \"bg-brand-50 text-brand-950 shadow-2xl\",\n \"dark:bg-brand-950 dark:text-white\",\n \"focus:outline-none\",\n // border on the docked edge only — keyed by data-placement in theme.css\n \"data-[placement=start]:border-e data-[placement=end]:border-s\",\n \"data-[placement=top]:border-b data-[placement=bottom]:border-t\",\n \"border-brand-900/20 dark:border-white/15\",\n \"data-[state=open]:animate-drawer-in data-[state=closed]:animate-drawer-out\",\n ],\n {\n variants: {\n // Internal: Content reads it from the root's context.\n placement: {\n start: \"h-full max-w-[90vw]\",\n end: \"h-full max-w-[90vw]\",\n top: \"w-full max-h-[90dvh]\",\n bottom: \"w-full max-h-[90dvh]\",\n },\n // Width for inline placements, height for block ones: see compoundVariants.\n size: { xs: \"\", sm: \"\", md: \"\", lg: \"\", xl: \"\" },\n // Only the two corners away from the docked edge round: see compoundVariants.\n radius: { none: \"\", sm: \"\", md: \"\", lg: \"\", xl: \"\" },\n },\n compoundVariants: [\n { placement: [\"start\", \"end\"], size: \"xs\", class: \"w-[18rem]\" },\n { placement: [\"start\", \"end\"], size: \"sm\", class: \"w-[22rem]\" },\n { placement: [\"start\", \"end\"], size: \"md\", class: \"w-[28rem]\" },\n { placement: [\"start\", \"end\"], size: \"lg\", class: \"w-[34rem]\" },\n { placement: [\"start\", \"end\"], size: \"xl\", class: \"w-[42rem]\" },\n { placement: [\"top\", \"bottom\"], size: \"xs\", class: \"h-[30dvh]\" },\n { placement: [\"top\", \"bottom\"], size: \"sm\", class: \"h-[40dvh]\" },\n { placement: [\"top\", \"bottom\"], size: \"md\", class: \"h-[55dvh]\" },\n { placement: [\"top\", \"bottom\"], size: \"lg\", class: \"h-[70dvh]\" },\n { placement: [\"top\", \"bottom\"], size: \"xl\", class: \"h-[85dvh]\" },\n // Logical corners, so `start`/`end` mirror under RTL with the panel.\n { placement: \"start\", radius: \"sm\", class: \"rounded-e-sm\" },\n { placement: \"start\", radius: \"md\", class: \"rounded-e-md\" },\n { placement: \"start\", radius: \"lg\", class: \"rounded-e-xl\" },\n { placement: \"start\", radius: \"xl\", class: \"rounded-e-2xl\" },\n { placement: \"end\", radius: \"sm\", class: \"rounded-s-sm\" },\n { placement: \"end\", radius: \"md\", class: \"rounded-s-md\" },\n { placement: \"end\", radius: \"lg\", class: \"rounded-s-xl\" },\n { placement: \"end\", radius: \"xl\", class: \"rounded-s-2xl\" },\n { placement: \"top\", radius: \"sm\", class: \"rounded-b-sm\" },\n { placement: \"top\", radius: \"md\", class: \"rounded-b-md\" },\n { placement: \"top\", radius: \"lg\", class: \"rounded-b-xl\" },\n { placement: \"top\", radius: \"xl\", class: \"rounded-b-2xl\" },\n { placement: \"bottom\", radius: \"sm\", class: \"rounded-t-sm\" },\n { placement: \"bottom\", radius: \"md\", class: \"rounded-t-md\" },\n { placement: \"bottom\", radius: \"lg\", class: \"rounded-t-xl\" },\n { placement: \"bottom\", radius: \"xl\", class: \"rounded-t-2xl\" },\n ],\n defaultVariants: { placement: \"end\", size: \"md\", radius: \"none\" },\n },\n)\n\n// ---------------------------------------------------------------------------\n// Low-level parts\n// ---------------------------------------------------------------------------\n\nexport type DrawerIconSlot = DialogIconSlot\nexport type DrawerIcons = DialogIcons\n\nexport type DrawerRootProps = ComponentPropsWithoutRef<typeof Ark.Root> & {\n /** RTL-aware docking edge, shared with `Drawer.Positioner` and `Drawer.Content`. Also\n * sets Ark's `swipeDirection`, unless you pass one. @default \"end\" */\n placement?: DrawerPlacement\n /** Replaces the default icons: `close`. `Drawer.CloseTrigger`'s `children` win over it. */\n icons?: DrawerIcons\n}\n\n/** Ark's root, plus the nested-layer guard: while a picker opened inside the\n * drawer is open, an outside click closes the picker only, not the drawer\n * under it. It is also a layer of its own while open, so a hotkey on the page\n * (or in an enclosing overlay) yields to it. See `lib/overlay-layer.tsx`. */\nconst DrawerRoot = ({\n placement = \"end\",\n swipeDirection,\n onPointerDownOutside,\n icons,\n children,\n ...rest\n}: DrawerRootProps) => {\n const guard = useLayerGuard(onPointerDownOutside)\n return (\n <Ark.Root\n swipeDirection={swipeDirection ?? PLACEMENT_TO_SWIPE[placement]}\n onPointerDownOutside={guard.onPointerDownOutside}\n {...rest}\n >\n {/* A layer itself, registered with whatever it opened from (the page,\n or an enclosing overlay), so what's under it knows it's covered. */}\n <Ark.Context>{(api) => <NestedLayer open={api.open} modal />}</Ark.Context>\n <DrawerPlacementContext value={placement}>\n <DialogRootProviders icons={icons} layers={guard.layers}>\n {children}\n </DialogRootProviders>\n </DrawerPlacementContext>\n </Ark.Root>\n )\n}\nconst DrawerTrigger = Ark.Trigger\nconst DrawerContext = Ark.Context\n\nexport type DrawerBackdropProps = ComponentPropsWithoutRef<typeof Ark.Backdrop> & WithTestId\n\nconst DrawerBackdrop = ({ className, testId, ...rest }: DrawerBackdropProps) => (\n <Ark.Backdrop\n className={cn(drawerBackdrop(), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type DrawerTitleProps = ComponentPropsWithoutRef<typeof Ark.Title> & WithTestId\n\nconst DrawerTitle = ({ className, testId, ...rest }: DrawerTitleProps) => (\n <Ark.Title\n className={cn(\"text-xl font-semibold leading-tight\", className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type DrawerDescriptionProps = ComponentPropsWithoutRef<typeof Ark.Description> & WithTestId\n\nconst DrawerDescription = ({ className, testId, ...rest }: DrawerDescriptionProps) => (\n <Ark.Description\n className={cn(\"text-sm\", TEXT_COLOR_CLASSES.muted, className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n />\n)\n\nexport type DrawerSize = NonNullable<VariantProps<typeof drawerContent>[\"size\"]>\nexport type DrawerRadius = NonNullable<VariantProps<typeof drawerContent>[\"radius\"]>\n\nexport type DrawerContentProps = ComponentPropsWithoutRef<typeof Ark.Content> &\n WithTestId & {\n /** Width for `start`/`end` drawers, height for `top`/`bottom` ones. @default \"md\" */\n size?: DrawerSize\n /** Rounds the two corners away from the docked edge. @default \"none\" */\n radius?: DrawerRadius\n }\n\n/** The panel. It sizes and rounds itself for the root's `placement`, and writes\n * it as `data-placement`, which the slide animation and the docked border key on. */\nconst DrawerContent = ({ className, size, radius, testId, ...rest }: DrawerContentProps) => {\n const placement = useContext(DrawerPlacementContext)\n const nameCheck = useDialogNameCheck(\"Drawer\")\n return (\n <Ark.Content\n ref={nameCheck}\n className={cn(drawerContent({ placement, size, radius }), className)}\n {...props({ \"data-testid\": testId })}\n {...rest}\n data-placement={placement}\n />\n )\n}\n\nexport type DrawerCloseTriggerProps = DialogCloseTriggerProps\nexport type DrawerHeaderProps = DialogSectionProps\nexport type DrawerBodyProps = DialogSectionProps\nexport type DrawerFooterProps = DialogSectionProps\n\nconst {\n CloseTrigger: DrawerCloseTrigger,\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n} = createDialogParts(\"drawer\", Ark.CloseTrigger)\n\nexport type DrawerGrabberProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Grabber>> &\n WithTestId\n\nconst DrawerGrabber = ({ className, testId, asChild: _asChild, ...rest }: DrawerGrabberProps) => (\n <Ark.Grabber\n className={cn(\n \"flex shrink-0 cursor-grab touch-none items-center justify-center py-2\",\n className,\n )}\n {...props({ \"data-testid\": testId })}\n {...rest}\n >\n <Ark.GrabberIndicator className=\"h-1.5 w-20 rounded-full bg-brand-900/10 dark:bg-white/16\" />\n </Ark.Grabber>\n)\n\n// ---------------------------------------------------------------------------\n// High-level props-driven Drawer\n// ---------------------------------------------------------------------------\n\ntype ArkRootProps = ComponentPropsWithoutRef<typeof Ark.Root>\n\nexport type DrawerClassNames = Partial<\n Record<\n | \"backdrop\"\n | \"positioner\"\n | \"content\"\n | \"header\"\n | \"title\"\n | \"description\"\n | \"body\"\n | \"grabber\"\n | \"closeButton\",\n string\n >\n>\n\nexport type DrawerProps = Omit<\n ArkRootProps,\n \"open\" | \"defaultOpen\" | \"onOpenChange\" | \"children\" | \"swipeDirection\" | \"role\"\n> &\n WithTestId & {\n /** Controlled open state. */\n open?: boolean\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean\n /** Fires with the next open state. Flattened from Ark's `{ open }`. */\n onOpenChange?: (open: boolean) => void\n /** Fires on close (any source) — Escape, backdrop click, swipe, or a controlled `onOpenChange`. */\n onClose?: () => void\n /** RTL-aware docking edge. @default \"end\" */\n placement?: DrawerPlacement\n /** Width for `start`/`end` drawers, height for `top`/`bottom` ones. @default \"md\" */\n size?: DrawerSize\n /** Rounds the two corners away from the docked edge. @default \"none\" */\n radius?: DrawerRadius\n /** Header title; also the drawer's accessible name. */\n title?: ReactNode\n description?: ReactNode\n /** Accessible name for a drawer without a `title` (a navigation panel, say). */\n \"aria-label\"?: string\n /** Id of an element inside the drawer that names it, when there is no `title`. */\n \"aria-labelledby\"?: string\n /** Render the default close button in the header. @default true */\n withCloseButton?: boolean\n /** Show the drag grabber handle. @default false */\n withGrabber?: boolean\n /**\n * Render the dimming backdrop. Set `false` when an ancestor (e.g. the modals\n * manager) draws a single shared backdrop for the whole overlay stack.\n * @default true\n */\n withBackdrop?: boolean\n /** Inner padding token; sets `--drawer-px`. @default \"md\" */\n padding?: Size\n closeOnEscape?: boolean\n /** Close on a click outside the drawer. @default true, false for an `alertdialog` */\n closeOnInteractOutside?: boolean\n /** Use `alertdialog` semantics (confirm flows). @default \"dialog\" */\n role?: \"dialog\" | \"alertdialog\"\n /** Fires after the exit animation completes — the manager unmounts on this. */\n onExitComplete?: () => void\n /** Portal target. Defaults to `document.body`. */\n container?: HTMLElement | null\n children?: ReactNode\n className?: string\n classNames?: DrawerClassNames\n /** Overrides the default close button's accessible name (`closeTriggerLabel`, default\n * `\"Close\"`). The compound `DrawerCloseTrigger` part takes a plain `aria-label` instead. */\n translations?: DrawerTranslations\n /** Replaces the default icons: `close`, the header's close button. */\n icons?: DrawerIcons\n }\n\n/** The ready-made drawer's wording — `closeTriggerLabel` follows Ark's naming for the\n * same control. */\nexport type DrawerTranslations = { closeTriggerLabel?: string }\n\nconst DrawerComponent = ({\n open,\n defaultOpen,\n onOpenChange,\n onClose,\n placement = \"end\",\n size,\n radius,\n title,\n description,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n withCloseButton = true,\n withGrabber = false,\n withBackdrop = true,\n padding = \"md\",\n closeOnEscape,\n closeOnInteractOutside,\n role,\n onExitComplete,\n container,\n children,\n className,\n classNames,\n testId,\n translations,\n icons,\n ...rest\n}: DrawerProps) => {\n const hasHeader = title != null || description != null || withCloseButton\n\n return (\n <DrawerRoot\n open={open}\n defaultOpen={defaultOpen}\n onOpenChange={({ open: next }) => {\n onOpenChange?.(next)\n if (!next) onClose?.()\n }}\n placement={placement}\n closeOnEscape={closeOnEscape}\n // Spelled out to match Modal, whose Ark dialog derives this default from\n // `modal` (so the overlays manager's `withBackdrop={false}` would stop\n // outside clicks there). Ark's drawer defaults it to `true` for every role\n // instead, so here the one behaviour this changes is the `alertdialog`:\n // it stays sticky, as on Modal, unless the caller opts in explicitly.\n closeOnInteractOutside={closeOnInteractOutside ?? role !== \"alertdialog\"}\n role={role}\n // Unmount the whole content tree (incl. the `fixed inset-0` positioner)\n // on close — otherwise the positioner lingers as a transparent overlay\n // that swallows page clicks. `lazyMount` keeps it out of the DOM until\n // first open.\n lazyMount\n unmountOnExit\n modal={withBackdrop}\n onExitComplete={onExitComplete}\n icons={icons}\n {...rest}\n >\n <Portal container={container ? { current: container } : undefined}>\n {withBackdrop && <DrawerBackdrop className={classNames?.backdrop} />}\n <DrawerPositioner className={classNames?.positioner}>\n <DrawerContent\n size={size}\n radius={radius}\n style={{ [\"--drawer-px\" as string]: DIALOG_PADDING[padding] }}\n className={cn(className, classNames?.content)}\n testId={testId}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n >\n {withGrabber && <DrawerGrabber className={classNames?.grabber} />}\n {hasHeader && (\n <DrawerHeader className={classNames?.header}>\n <div className=\"flex flex-col gap-1\">\n {title != null && (\n <DrawerTitle className={classNames?.title}>{title}</DrawerTitle>\n )}\n {description != null && (\n <DrawerDescription className={classNames?.description}>\n {description}\n </DrawerDescription>\n )}\n </div>\n {withCloseButton && (\n <DrawerCloseTrigger\n aria-label={translations?.closeTriggerLabel}\n className={classNames?.closeButton}\n />\n )}\n </DrawerHeader>\n )}\n <DrawerBody\n className={cn(\n !hasHeader && !withGrabber && \"pt-(--drawer-px,1.25rem)\",\n \"pb-(--drawer-px,1.25rem)\",\n classNames?.body,\n )}\n >\n {children}\n </DrawerBody>\n </DrawerContent>\n </DrawerPositioner>\n </Portal>\n </DrawerRoot>\n )\n}\n\nexport const Drawer = Object.assign(DrawerComponent, {\n Root: DrawerRoot,\n Trigger: DrawerTrigger,\n Context: DrawerContext,\n Backdrop: DrawerBackdrop,\n Positioner: DrawerPositioner,\n Content: DrawerContent,\n Title: DrawerTitle,\n Description: DrawerDescription,\n CloseTrigger: DrawerCloseTrigger,\n Grabber: DrawerGrabber,\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n})\n"]}
@@ -1,4 +1,4 @@
1
- import { devWarn } from './chunk-LIZWCWED.js';
1
+ import { isProduction, devWarn } from './chunk-PQZSTI3R.js';
2
2
  import { useLocaleContext, LocaleProvider } from '@ark-ui/react/locale';
3
3
  import { getLocalTimeZone } from '@internationalized/date';
4
4
  import { createContext, useSyncExternalStore, useContext, useCallback } from 'react';
@@ -54,8 +54,9 @@ var useDirectionCheck = () => {
54
54
  const { dir } = useLocaleContext();
55
55
  return useCallback(
56
56
  (node) => {
57
+ if (isProduction() || warnedDirection) return;
57
58
  const parent = node?.parentElement;
58
- if (warnedDirection || !parent) return;
59
+ if (!parent) return;
59
60
  const inherited = getComputedStyle(parent).direction;
60
61
  if (inherited === dir) return;
61
62
  warnedDirection = true;
@@ -73,5 +74,5 @@ var IntlProvider = ({ locale, timeZone, children }) => {
73
74
  };
74
75
 
75
76
  export { DEFAULT_LOCALE, DEFAULT_TIME_ZONE, IntlProvider, useDirectionCheck, useLocale, useTimeZone };
76
- //# sourceMappingURL=chunk-IUK7OJXZ.js.map
77
- //# sourceMappingURL=chunk-IUK7OJXZ.js.map
77
+ //# sourceMappingURL=chunk-OBSZ4NE2.js.map
78
+ //# sourceMappingURL=chunk-OBSZ4NE2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/intl.tsx"],"names":[],"mappings":";;;;;;AAiCA,IAAM,IAAA,GAAO,MAAA;AAQN,IAAM,cAAA,GAAiB;AAQvB,IAAM,iBAAA,GAAoB;AAcjC,SAAS,oBAAoB,aAAA,EAA2B;AACtD,EAAA,MAAA,CAAO,gBAAA,CAAiB,kBAAkB,aAAa,CAAA;AACvD,EAAA,OAAO,MAAM,MAAA,CAAO,mBAAA,CAAoB,gBAAA,EAAkB,aAAa,CAAA;AACzE;AAEA,SAAS,mBAAA,GAAsB;AAC7B,EAAA,OAAO,UAAU,QAAA,IAAY,cAAA;AAC/B;AAEA,SAAS,yBAAA,GAA4B;AACnC,EAAA,OAAO,cAAA;AACT;AAKA,IAAM,0BAA0B,MAAM;AAAC,CAAA;AAEvC,SAAS,mBAAA,GAAsB;AAC7B,EAAA,OAAO,uBAAA;AACT;AAEA,SAAS,mBAAA,GAAsB;AAI7B,EAAA,OAAO,kBAAiB,IAAK,iBAAA;AAC/B;AAEA,SAAS,yBAAA,GAA4B;AACnC,EAAA,OAAO,iBAAA;AACT;AAEA,IAAM,eAAA,GAAkB,cAAkC,MAAS,CAAA;AAU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IAAM,eAAe,CAAC,EAAE,MAAA,EAAQ,QAAA,EAAU,UAAS,KAAyB;AACjF,EAAA,MAAM,cAAA,GAAiB,UAAU,MAAM,CAAA;AACvC,EAAA,MAAM,gBAAA,GAAmB,YAAY,QAAQ,CAAA;AAE7C,EAAA,uBACE,GAAA,CAAC,cAAA,EAAA,EAAe,MAAA,EAAQ,cAAA,EACtB,QAAA,kBAAA,GAAA,CAAC,eAAA,CAAgB,QAAA,EAAhB,EAAyB,KAAA,EAAO,gBAAA,EAAmB,QAAA,EAAS,CAAA,EAC/D,CAAA;AAEJ","file":"chunk-OBSZ4NE2.js","sourcesContent":["\"use client\"\n\nimport { LocaleProvider, useLocaleContext } from \"@ark-ui/react/locale\"\nimport { getLocalTimeZone } from \"@internationalized/date\"\nimport { createContext, type ReactNode, useCallback, useContext, useSyncExternalStore } from \"react\"\nimport { devWarn, isProduction } from \"./dev-warn\"\n\n/**\n * The one seam where \"which locale\" and \"which time zone\" are decided.\n *\n * Every `Intl` constructor takes a locale as its first argument and a `timeZone` as an option,\n * and both have a runtime default — `Intl.DateTimeFormat()` resolves to Node's `en-US` on a\n * server and to the visitor's locale in a browser; `getLocalTimeZone()` resolves to the server's\n * zone (UTC on most hosts) and to the visitor's. Reading either implicitly therefore makes the\n * rendered output a property of *where the code ran*, which is a hydration mismatch waiting for\n * the first visitor configured differently from the build server. So nothing in this kit reads\n * them implicitly: components resolve both through the hooks below, and the value they get is\n * either something the app stated or a documented constant.\n *\n * Locale and time zone stay **fully independent** — separate prop, separate hook, separate\n * per-instance override, no coupling. They share only this module and `IntlProvider`'s single\n * mount point, because the resolution mechanism is the whole of the fix and writing it twice is\n * how the two would drift apart.\n *\n * Locale deliberately needs no context of its own: `IntlProvider` renders Ark's own\n * `LocaleProvider`, so Ark's state machines (`Calendar`, `DatePicker`, `NumberInput`,\n * `FileUpload`) and this kit's own formatting can only ever read one value — and `dir`/RTL comes\n * along for free for the components already reading `useLocaleContext().dir` (`menu.tsx`,\n * `tooltip.tsx`, `hover-card.tsx`). An app that mounts Ark's `LocaleProvider` directly still\n * works. Only the time zone needs a new context, since Ark has no equivalent.\n */\n\n/** Follow the host runtime. Accepted anywhere a locale or zone is: provider, or a single prop. */\nconst AUTO = \"auto\"\n\n/**\n * The locale used when nothing configures one, and what `\"auto\"` reports during SSR and the\n * hydration render. Pinned to the same tag as Ark's own `useLocaleContext()` default so the two\n * halves of a `Calendar` — Ark's machine and this kit's formatting around it — cannot disagree,\n * the same \"one constant, two readers\" reasoning `lib/theme.ts` uses for the theme storage key.\n */\nexport const DEFAULT_LOCALE = \"en-US\"\n\n/**\n * What `timeZone=\"auto\"` reports during SSR and the hydration render, before the host zone is\n * readable. Note this is *not* the default for the `timeZone` prop itself — that is `\"auto\"`\n * (see `useTimeZone`), because a wrong zone is wrong data rather than merely an unfamiliar\n * format. UTC is the one zone every runtime agrees on.\n */\nexport const DEFAULT_TIME_ZONE = \"UTC\"\n\n// `\"auto\"` is resolved through `useSyncExternalStore` with a fixed `getServerSnapshot`, the same\n// shape (and for the same reason) as `use-media-query.ts`, `use-local-storage.ts` and\n// `use-now.ts`: the server and the first client render are handed a value that cannot differ, so\n// hydration always matches, and React swaps in the real one immediately afterwards. A plain\n// `useEffect` would work too, but this way the fallback is declared once next to the real read\n// instead of living in a `useState` initializer somewhere else.\n//\n// Caveat worth knowing before reaching for `\"auto\"` under SSR, carried over from `use-theme.ts`:\n// React does not specify that the post-hydration correction lands before the browser paints, and\n// empirically it does not reliably, so the default value can be visible for a frame. That is the\n// accepted cost of opting in, and precisely why `locale` does not default to `\"auto\"`.\n\nfunction subscribeToLanguage(onStoreChange: () => void) {\n window.addEventListener(\"languagechange\", onStoreChange)\n return () => window.removeEventListener(\"languagechange\", onStoreChange)\n}\n\nfunction getLanguageSnapshot() {\n return navigator.language || DEFAULT_LOCALE\n}\n\nfunction getLanguageServerSnapshot() {\n return DEFAULT_LOCALE\n}\n\n// The host zone has no change event to listen for — a machine moving zone mid-session re-resolves\n// on the next render at worst. `subscribe` still has to return an unsubscribe function, and it\n// has to be a stable reference or `useSyncExternalStore` resubscribes on every render.\nconst unsubscribeFromTimeZone = () => {}\n\nfunction subscribeToTimeZone() {\n return unsubscribeFromTimeZone\n}\n\nfunction getTimeZoneSnapshot() {\n // `getLocalTimeZone()` is `Intl.DateTimeFormat().resolvedOptions().timeZone` behind a cache.\n // This is the only call to it left in the kit, which is the point: one reader of the ambient\n // zone, wrapped in the hydration-safe store, instead of ~13 scattered prop defaults.\n return getLocalTimeZone() || DEFAULT_TIME_ZONE\n}\n\nfunction getTimeZoneServerSnapshot() {\n return DEFAULT_TIME_ZONE\n}\n\nconst TimeZoneContext = createContext<string | undefined>(undefined)\n\n/**\n * The active locale as a concrete BCP-47 tag, never `\"auto\"` and never `undefined`.\n *\n * `override` is the component's own `locale` prop, so precedence reads\n * **prop → provider → `DEFAULT_LOCALE`** — the same shape as `useLinkComponent`.\n *\n * const locale = useLocale(props.locale)\n */\nexport const useLocale = (override?: \"auto\" | (string & {})): string => {\n const { locale: provided } = useLocaleContext()\n const requested = override ?? provided\n const hostLocale = useSyncExternalStore(\n subscribeToLanguage,\n getLanguageSnapshot,\n getLanguageServerSnapshot,\n )\n return requested === AUTO ? hostLocale : requested\n}\n\n/**\n * The active time zone as a concrete IANA name, never `\"auto\"` and never `undefined`.\n *\n * `override` is the component's own `timeZone` prop, so precedence reads\n * **prop → provider → `\"auto\"`**. The default is `\"auto\"` rather than a fixed zone because a\n * wrong zone shows wrong times, not merely an unfamiliar format — and `\"auto\"` costs a\n * client-only app nothing, since `getServerSnapshot` never runs there and the first render is\n * already the true zone.\n *\n * const timeZone = useTimeZone(props.timeZone)\n */\nexport const useTimeZone = (override?: \"auto\" | (string & {})): string => {\n const provided = useContext(TimeZoneContext)\n const requested = override ?? provided ?? AUTO\n const hostTimeZone = useSyncExternalStore(\n subscribeToTimeZone,\n getTimeZoneSnapshot,\n getTimeZoneServerSnapshot,\n )\n return requested === AUTO ? hostTimeZone : requested\n}\n\n// One warning per page, however many components run the check: the fix is a single provider at\n// the app root, so repeating the message per Tabs would only bury it.\nlet warnedDirection = false\n\n/**\n * Dev-only guard for the one RTL setup that silently breaks: direction stated on the DOM\n * (`<html dir=\"rtl\">`, or an ancestor) while no locale says so. Ark derives `dir` from the\n * locale alone and stamps it on every part, so its parts render `ltr` inside an `rtl` page —\n * and its arrow-key handling runs `ltr` too, which is why the kit can't simply let the parts\n * inherit from the DOM: the direction has to be known in JS, i.e. come from `IntlProvider`.\n *\n * Returns a callback ref for an Ark root. It reads the **parent**'s direction, since the root\n * itself carries Ark's stamped `dir`. Runs on attach, so SSR and hydration never see it.\n *\n * The whole check is dev-only, not just the warning: `getComputedStyle` forces a style recalc\n * while React is committing, and in a correctly set-up app the directions match, so nothing would\n * ever stop it repeating on every Ark root mounted (#462). In a production build the gate reduces\n * to `if (true) return` and the minifier drops the read.\n */\nexport const useDirectionCheck = () => {\n const { dir } = useLocaleContext()\n return useCallback(\n (node: HTMLElement | null) => {\n if (isProduction() || warnedDirection) return\n const parent = node?.parentElement\n if (!parent) return\n // Computed rather than `closest(\"[dir]\")`, so a CSS-only `direction: rtl` counts too.\n const inherited = getComputedStyle(parent).direction\n if (inherited === dir) return\n warnedDirection = true\n devWarn(\n `[@42/ui-react] This page is dir=\"${inherited}\", but the locale resolves to dir=\"${dir}\", so Ark-backed parts (Tabs, SegmentGroup, Menu…) render and navigate ${dir}. Direction comes from the locale: wrap the app in <IntlProvider locale=\"…\"> with a matching locale. See \"Text direction\" in the Internationalization docs.`,\n )\n },\n [dir],\n )\n}\n\nexport type IntlProviderProps = {\n /** A BCP-47 tag (`\"fr-FR\"`), or `\"auto\"` to follow the browser. Inherited from an outer\n * `IntlProvider` when omitted, and `\"en-US\"` when there is none. */\n locale?: \"auto\" | (string & {})\n /** An IANA zone (`\"Europe/Paris\"`), or `\"auto\"` to follow the host. Inherited from an outer\n * `IntlProvider` when omitted, and `\"auto\"` when there is none. @default \"auto\" */\n timeZone?: \"auto\" | (string & {})\n children?: ReactNode\n}\n\n/**\n * Wrap the app once to state how it formats dates, times and numbers:\n * `<IntlProvider locale=\"fr-FR\" timeZone=\"Europe/Paris\"><App /></IntlProvider>`.\n *\n * Both props are optional and independent — setting only `timeZone` leaves the locale alone, and\n * a nested provider inherits whichever value it doesn't set, so a section can override one\n * without restating the other.\n *\n * It resolves both values and publishes the results, so `\"auto\"` is subscribed to once here\n * rather than once per component, and everything downstream — Ark's machines included — reads a\n * concrete tag and zone.\n *\n * Text direction follows the locale: `locale=\"ar\"` makes every Ark part `rtl`. `<html dir=\"rtl\">`\n * alone never reaches Ark, which is what `useDirectionCheck` warns about in development.\n *\n * This provider carries the inputs to `Intl`, and nothing else. Translated microcopy stays on\n * each component's own `translations` prop by design (`code-style.md`); there is deliberately no\n * message context here.\n */\nexport const IntlProvider = ({ locale, timeZone, children }: IntlProviderProps) => {\n const resolvedLocale = useLocale(locale)\n const resolvedTimeZone = useTimeZone(timeZone)\n\n return (\n <LocaleProvider locale={resolvedLocale}>\n <TimeZoneContext.Provider value={resolvedTimeZone}>{children}</TimeZoneContext.Provider>\n </LocaleProvider>\n )\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { useApplePlatform, hotkeyCaps } from './chunk-QEMXXQQO.js';
1
+ import { useApplePlatform, hotkeyCaps } from './chunk-JKFPRQB2.js';
2
2
  import { composeChildren } from './chunk-R5LYFTHA.js';
3
3
  import { props } from './chunk-WYCMIIRR.js';
4
4
  import { focusStyles } from './chunk-C6NVU4F7.js';
@@ -145,5 +145,5 @@ var Kbd = (allProps) => {
145
145
  };
146
146
 
147
147
  export { Kbd };
148
- //# sourceMappingURL=chunk-DJ72KP32.js.map
149
- //# sourceMappingURL=chunk-DJ72KP32.js.map
148
+ //# sourceMappingURL=chunk-OXR7BXZA.js.map
149
+ //# sourceMappingURL=chunk-OXR7BXZA.js.map