@nswds/ui 5.5.4 → 5.7.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.
package/README.md CHANGED
@@ -64,12 +64,14 @@ If you do hit a conflict, a call-site override outranks both halves:
64
64
 
65
65
  ### Dark mode
66
66
 
67
- Toggle `class="dark"` or `data-theme="dark"` on a root element (for example with [`next-themes`](https://github.com/pacocoursey/next-themes)). Semantic tokens and `dark:` utilities both key off either marker, and both match the element carrying it as well as its descendants — so a scoped `<div class="dark">` darkens just that subtree.
67
+ Toggle `class="dark"` or `data-theme="dark"` on a **root element** (for example with [`next-themes`](https://github.com/pacocoursey/next-themes)). Semantic tokens and `dark:` utilities both key off either marker, and both match the element carrying it as well as its descendants.
68
68
 
69
69
  ```tsx
70
70
  <html lang='en' className='dark'>
71
71
  ```
72
72
 
73
+ **A scoped `<div class="dark">` gives you only a partial dark mode.** The semantic tokens are declared on `:root` in terms of mode-aware role tokens (`--primary: var(--action-default)`), and a `var()` is substituted where it is declared — so on a nested element the role token changes too late. The `dark:` utilities flip (those are compiled classes) while the semantic colours stay light. Put the marker on the root element.
74
+
73
75
  ### Icons
74
76
 
75
77
  Icons are tree-shakeable from the barrel, or importable individually:
@@ -147,15 +149,54 @@ import {
147
149
 
148
150
  ## Components
149
151
 
150
- AspectRatio, Badge, Button, ButtonLink, Callout, Card, Collapsible, Container, DescriptionList, Drawer, ExpandableSearch, Field, Footer, Header, HoverCard, Input, Label, LabeledSeparator, Link, LinkCard, Logo (NSW Government logo), MainNav, Masthead, OnThisPage, Popover, PushMenu, Resizable, ScrollArea, Section, Separator, Sheet, SideNav, SiteSearch, SkipLink, Slider, Spinner, StepIndicator, ThemeSwitcher, Toaster, Tooltip — plus the icon set under `@nswds/ui/icons`.
152
+ 62 components, plus 12 copy-and-adapt blocks on the registry channel. The complete catalogue —
153
+ with every export and a description per item — is in the
154
+ [component reference](https://github.com/digitalnsw/nswds-ui/blob/main/docs/reference-components.md).
155
+
156
+ **NSW-original** (no upstream equivalent — the reference is their only documentation):
157
+ Callout, Container, DescriptionList, ExpandableSearch, Footer, Header, LabeledSeparator, Link,
158
+ LinkCard, Logo, MainNav, Masthead, OnThisPage, PushMenu, Section, SideNav, SiteSearch, SkipLink,
159
+ StepIndicator, TabNav, ThemeSwitcher.
160
+
161
+ **Shadcn shapes on Base UI primitives, NSW-styled:**
162
+ Accordion, AspectRatio, Avatar, Badge, Breadcrumb, Button, ButtonGroup, Card, Carousel, Checkbox,
163
+ Collapsible, Combobox, DirectionProvider, Drawer, Field, HoverCard, Input, InputGroup, InputOTP,
164
+ Kbd, Label, NativeSelect, Pagination, Popover, Progress, RadioGroup, ResizablePanelGroup, ScrollArea, Select,
165
+ Separator, Sheet, Slider, Spinner, Switch, Table, Tabs, Textarea, Toaster, Toggle, ToggleGroup,
166
+ Tooltip.
151
167
 
152
- Hooks: `useChromeHeight`, which measures a sticky header and publishes its height as a CSS custom property, for `scroll-padding-top`, `MainNav`'s `--main-nav-top`, and `OnThisPage`'s scroll-spy offset.
168
+ Plus the icon set under `@nswds/ui/icons` and the brand marks under `@nswds/ui/icons/brands`.
153
169
 
154
- Every interactive component wraps a Base UI primitive, which provides focus management, keyboard navigation, and ARIA semantics. Each component also exports its `cva` variants function (for example `buttonVariants`) so you can extend styling.
170
+ Hooks: `useChromeHeight`, which measures a sticky header and publishes its height as a CSS custom
171
+ property, for `scroll-padding-top`, `MainNav`'s `--main-nav-top`, and `OnThisPage`'s scroll-spy
172
+ offset.
173
+
174
+ Every interactive component wraps a Base UI primitive, which provides focus management, keyboard
175
+ navigation, and ARIA semantics. Each component also exports its `cva` variants function (for
176
+ example `buttonVariants`) so you can extend styling.
155
177
 
156
178
  ## Theming
157
179
 
158
- Every visual property traces back to a CSS custom property token. Components reference semantic tokens (`--primary`, `--background`, `--border`, …), which resolve through the NSW masterbrand theme to the NSW primitive palette. To re-brand, override the semantic tokens in a scoped selector and toggle that class on your root element.
180
+ Every visual property traces back to a CSS custom property token, in four layers: Tailwind
181
+ utilities → shadcn semantic tokens (`--primary`, `--background`, `--border`) → NSW role tokens
182
+ (`--action-default`, `--text-default`) → the NSW primitive palette.
183
+
184
+ To re-brand, **override the masterbrand ramps at `:root`**, after importing the stylesheet:
185
+
186
+ ```css
187
+ :root {
188
+ --primary-800: oklch(0.29 0.12 150);
189
+ /* …the remaining steps of the ramp… */
190
+ }
191
+ ```
192
+
193
+ Supply the whole ramp — components draw on different steps for fills, borders and hover states.
194
+
195
+ > Overriding tokens in a **scoped** selector mostly does not work, because a `var()` is substituted
196
+ > where it is declared and every layer is declared at `:root`. In particular `Button`'s primary
197
+ > colour resolves to the masterbrand ramp (`--color-primary-800`), not to `--primary`. See
198
+ > [Theme and re-brand](https://github.com/digitalnsw/nswds-ui/blob/main/docs/howto-theme-and-rebrand.md)
199
+ > for the rule and the working escape hatch.
159
200
 
160
201
  ## Prefer the source in your repo?
161
202
 
@@ -5,6 +5,16 @@ declare function Breadcrumb({ className, ...props }: React.ComponentProps<'nav'>
5
5
  declare function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>): React.JSX.Element;
6
6
  declare function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>): React.JSX.Element;
7
7
  declare function BreadcrumbLink({ className, render, ...props }: useRender.ComponentProps<'a'>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
8
+ /**
9
+ * The current page's entry in the trail — plain text, not a link.
10
+ *
11
+ * Carries `aria-current='page'` and nothing else. The upstream shadcn version
12
+ * adds `role='link' aria-disabled='true'` to a `<span>` that has no `href` and
13
+ * no `tabIndex`, which makes AT announce "link, dimmed, current page" for
14
+ * something that is neither a link nor operable, and puts a hand-rolled ARIA
15
+ * role on an element that needs none. axe-core does not flag it, so it
16
+ * survives an a11y gate set to `error`; it is removed deliberately here.
17
+ */
8
18
  declare function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>): React.JSX.Element;
9
19
  declare function BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>): React.JSX.Element;
10
20
  declare function BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>): React.JSX.Element;
@@ -51,8 +51,6 @@ function BreadcrumbPage({ className, ...props }) {
51
51
  "span",
52
52
  {
53
53
  "data-slot": "breadcrumb-page",
54
- role: "link",
55
- "aria-disabled": "true",
56
54
  "aria-current": "page",
57
55
  className: cn("font-normal text-foreground", className),
58
56
  ...props
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/breadcrumb.tsx"],"names":[],"mappings":";;;;;;;AAQA,SAAS,UAAA,CAAW,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACxE,EAAA,uBAAO,GAAA,CAAC,KAAA,EAAA,EAAI,YAAA,EAAW,YAAA,EAAa,WAAA,EAAU,YAAA,EAAa,SAAA,EAAW,EAAA,CAAG,SAAS,CAAA,EAAI,GAAG,KAAA,EAAO,CAAA;AAClG;AAEA,SAAS,cAAA,CAAe,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,iBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,2FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,cAAA,CAAe,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,iBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,gCAAA,EAAkC,SAAS,CAAA;AAAA,MACxD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,eAAe,EAAE,SAAA,EAAW,MAAA,EAAQ,GAAG,OAAM,EAAkC;AACtF,EAAA,OAAO,SAAA,CAAU;AAAA,IACf,cAAA,EAAgB,GAAA;AAAA,IAChB,KAAA,EAAO,UA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,GAAG,KAAA;AAAA,MAEJ,8BAAC,aAAA,EAAA,EAAc;AAAA;AAAA,GACjB;AAEJ","file":"breadcrumb.js","sourcesContent":["import { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\n\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { IconMoreHoriz } from '../icons/more-horiz.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Breadcrumb({ className, ...props }: React.ComponentProps<'nav'>) {\n return <nav aria-label='breadcrumb' data-slot='breadcrumb' className={cn(className)} {...props} />\n}\n\nfunction BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {\n return (\n <ol\n data-slot='breadcrumb-list'\n className={cn(\n 'flex flex-wrap items-center gap-1.5 text-xs/relaxed wrap-break-word text-muted-foreground',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-slot='breadcrumb-item'\n className={cn('inline-flex items-center gap-1', className)}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbLink({ className, render, ...props }: useRender.ComponentProps<'a'>) {\n return useRender({\n defaultTagName: 'a',\n props: mergeProps<'a'>(\n {\n className: cn('transition-colors hover:text-foreground', className),\n },\n props,\n ),\n render,\n state: {\n slot: 'breadcrumb-link',\n },\n })\n}\n\nfunction BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-page'\n role='link'\n aria-disabled='true'\n aria-current='page'\n className={cn('font-normal text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-slot='breadcrumb-separator'\n role='presentation'\n aria-hidden='true'\n className={cn('[&>svg]:size-3.5', className)}\n {...props}\n >\n {children ?? <IconChevronRight className='rtl:rotate-180' />}\n </li>\n )\n}\n\nfunction BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-ellipsis'\n role='presentation'\n aria-hidden='true'\n className={cn('flex size-4 items-center justify-center [&>svg]:size-3.5', className)}\n {...props}\n >\n <IconMoreHoriz />\n </span>\n )\n}\n\nexport {\n Breadcrumb,\n BreadcrumbEllipsis,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n}\n"]}
1
+ {"version":3,"sources":["../../src/components/breadcrumb.tsx"],"names":[],"mappings":";;;;;;;AAQA,SAAS,UAAA,CAAW,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACxE,EAAA,uBAAO,GAAA,CAAC,KAAA,EAAA,EAAI,YAAA,EAAW,YAAA,EAAa,WAAA,EAAU,YAAA,EAAa,SAAA,EAAW,EAAA,CAAG,SAAS,CAAA,EAAI,GAAG,KAAA,EAAO,CAAA;AAClG;AAEA,SAAS,cAAA,CAAe,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,iBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,2FAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,cAAA,CAAe,EAAE,SAAA,EAAW,GAAG,OAAM,EAA+B;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,iBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,gCAAA,EAAkC,SAAS,CAAA;AAAA,MACxD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,eAAe,EAAE,SAAA,EAAW,MAAA,EAAQ,GAAG,OAAM,EAAkC;AACtF,EAAA,OAAO,SAAA,CAAU;AAAA,IACf,cAAA,EAAgB,GAAA;AAAA,IAChB,KAAA,EAAO,UAAA;AAAA,MACL;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EJ","file":"breadcrumb.js","sourcesContent":["import { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\n\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { IconMoreHoriz } from '../icons/more-horiz.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Breadcrumb({ className, ...props }: React.ComponentProps<'nav'>) {\n return <nav aria-label='breadcrumb' data-slot='breadcrumb' className={cn(className)} {...props} />\n}\n\nfunction BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {\n return (\n <ol\n data-slot='breadcrumb-list'\n className={cn(\n 'flex flex-wrap items-center gap-1.5 text-xs/relaxed wrap-break-word text-muted-foreground',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-slot='breadcrumb-item'\n className={cn('inline-flex items-center gap-1', className)}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbLink({ className, render, ...props }: useRender.ComponentProps<'a'>) {\n return useRender({\n defaultTagName: 'a',\n props: mergeProps<'a'>(\n {\n className: cn('transition-colors hover:text-foreground', className),\n },\n props,\n ),\n render,\n state: {\n slot: 'breadcrumb-link',\n },\n })\n}\n\n/**\n * The current page's entry in the trail — plain text, not a link.\n *\n * Carries `aria-current='page'` and nothing else. The upstream shadcn version\n * adds `role='link' aria-disabled='true'` to a `<span>` that has no `href` and\n * no `tabIndex`, which makes AT announce \"link, dimmed, current page\" for\n * something that is neither a link nor operable, and puts a hand-rolled ARIA\n * role on an element that needs none. axe-core does not flag it, so it\n * survives an a11y gate set to `error`; it is removed deliberately here.\n */\nfunction BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-page'\n aria-current='page'\n className={cn('font-normal text-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction BreadcrumbSeparator({ children, className, ...props }: React.ComponentProps<'li'>) {\n return (\n <li\n data-slot='breadcrumb-separator'\n role='presentation'\n aria-hidden='true'\n className={cn('[&>svg]:size-3.5', className)}\n {...props}\n >\n {children ?? <IconChevronRight className='rtl:rotate-180' />}\n </li>\n )\n}\n\nfunction BreadcrumbEllipsis({ className, ...props }: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot='breadcrumb-ellipsis'\n role='presentation'\n aria-hidden='true'\n className={cn('flex size-4 items-center justify-center [&>svg]:size-3.5', className)}\n {...props}\n >\n <IconMoreHoriz />\n </span>\n )\n}\n\nexport {\n Breadcrumb,\n BreadcrumbEllipsis,\n BreadcrumbItem,\n BreadcrumbLink,\n BreadcrumbList,\n BreadcrumbPage,\n BreadcrumbSeparator,\n}\n"]}
@@ -25,10 +25,22 @@ type CarouselContextProps = {
25
25
  canScrollNext: boolean;
26
26
  } & CarouselProps;
27
27
  declare function useCarousel(): CarouselContextProps;
28
- declare function Carousel({ orientation, opts, setApi, plugins, className, children, ...props }: React.ComponentProps<'div'> & CarouselProps): React.JSX.Element;
28
+ declare function Carousel({ orientation, opts, setApi, plugins, className, children, onKeyDown, ...props }: React.ComponentProps<'div'> & CarouselProps): React.JSX.Element;
29
29
  declare function CarouselContent({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
30
30
  declare function CarouselItem({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
31
- declare function CarouselPrevious({ className, variant, size, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
32
- declare function CarouselNext({ className, variant, size, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
31
+ declare function CarouselPrevious({ className, variant, size, label, children, ...props }: React.ComponentProps<typeof Button> & {
32
+ /**
33
+ * Screen-reader name for the control. Override to translate it — the
34
+ * control is icon-only, so this string is the only name AT ever hears.
35
+ */
36
+ label?: string;
37
+ }): React.JSX.Element;
38
+ declare function CarouselNext({ className, variant, size, label, children, ...props }: React.ComponentProps<typeof Button> & {
39
+ /**
40
+ * Screen-reader name for the control. Override to translate it — the
41
+ * control is icon-only, so this string is the only name AT ever hears.
42
+ */
43
+ label?: string;
44
+ }): React.JSX.Element;
33
45
 
34
46
  export { Carousel, type CarouselApi, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, useCarousel };
@@ -1,12 +1,76 @@
1
1
  "use client"
2
- import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { jsx } from 'react/jsx-runtime';
3
3
  import useEmblaCarousel from 'embla-carousel-react';
4
4
  import * as React from 'react';
5
5
  import { IconChevronLeft } from '../icons/chevron-left.js';
6
6
  import { IconChevronRight } from '../icons/chevron-right.js';
7
7
  import { cn } from '../lib/utils.js';
8
8
  import { Button } from './button.js';
9
+ import { useDirection } from './direction.js';
9
10
 
11
+ const ARROW_CONSUMING_ROLES = /* @__PURE__ */ new Set([
12
+ // 1 — consumed by the focused element
13
+ "combobox",
14
+ "scrollbar",
15
+ "searchbox",
16
+ // `separator` is the focusable window-splitter form, and it is not
17
+ // hypothetical here: this package's own ResizableHandle wraps
18
+ // react-resizable-panels, which renders role="separator" and handles all
19
+ // four arrows. A Resizable inside a slide loses its keyboard resizing
20
+ // without this entry.
21
+ "separator",
22
+ "slider",
23
+ "spinbutton",
24
+ "textbox",
25
+ // 2 — consumed by an ancestor composite
26
+ "application",
27
+ "grid",
28
+ "listbox",
29
+ "menu",
30
+ "menubar",
31
+ "radiogroup",
32
+ "tablist",
33
+ // `toolbar` matters more than it looks: its controls are usually plain
34
+ // buttons, which have no native arrow behaviour, so a toolbar can move focus
35
+ // WITHOUT calling preventDefault — meaning the defaultPrevented guard in the
36
+ // handler does not cover it and only this list can.
37
+ "toolbar",
38
+ "tree",
39
+ "treegrid",
40
+ // 3 — the descendant halves, for aria-owns associations
41
+ "columnheader",
42
+ "gridcell",
43
+ "menuitem",
44
+ "menuitemcheckbox",
45
+ "menuitemradio",
46
+ "option",
47
+ "radio",
48
+ "row",
49
+ "rowheader",
50
+ "tab",
51
+ "treeitem"
52
+ ]);
53
+ function ownsArrowKeys(target, boundary) {
54
+ let element = target;
55
+ while (element && element.nodeType === 1 && typeof element.getAttribute === "function") {
56
+ const tag = element.tagName;
57
+ if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") {
58
+ return true;
59
+ }
60
+ if (element.isContentEditable) {
61
+ return true;
62
+ }
63
+ const role = element.getAttribute("role");
64
+ if (role !== null && ARROW_CONSUMING_ROLES.has(role)) {
65
+ return true;
66
+ }
67
+ if (element === boundary) {
68
+ return false;
69
+ }
70
+ element = element.parentElement;
71
+ }
72
+ return false;
73
+ }
10
74
  const CarouselContext = React.createContext(null);
11
75
  function useCarousel() {
12
76
  const context = React.useContext(CarouselContext);
@@ -22,10 +86,14 @@ function Carousel({
22
86
  plugins,
23
87
  className,
24
88
  children,
89
+ onKeyDown,
25
90
  ...props
26
91
  }) {
92
+ const providerDirection = useDirection();
93
+ const direction = opts?.direction ?? providerDirection;
27
94
  const [carouselRef, api] = useEmblaCarousel(
28
95
  {
96
+ direction,
29
97
  ...opts,
30
98
  axis: orientation === "horizontal" ? "x" : "y"
31
99
  },
@@ -44,17 +112,27 @@ function Carousel({
44
112
  const scrollNext = React.useCallback(() => {
45
113
  api?.scrollNext();
46
114
  }, [api]);
115
+ const [previousKey, nextKey] = orientation === "vertical" ? ["ArrowUp", "ArrowDown"] : direction === "rtl" ? ["ArrowRight", "ArrowLeft"] : ["ArrowLeft", "ArrowRight"];
47
116
  const handleKeyDown = React.useCallback(
48
117
  (event) => {
49
- if (event.key === "ArrowLeft") {
118
+ onKeyDown?.(event);
119
+ if (event.defaultPrevented) {
120
+ return;
121
+ }
122
+ if (ownsArrowKeys(event.target, event.currentTarget)) {
123
+ return;
124
+ }
125
+ if (event.key === previousKey) {
50
126
  event.preventDefault();
127
+ event.stopPropagation();
51
128
  scrollPrev();
52
- } else if (event.key === "ArrowRight") {
129
+ } else if (event.key === nextKey) {
53
130
  event.preventDefault();
131
+ event.stopPropagation();
54
132
  scrollNext();
55
133
  }
56
134
  },
57
- [scrollPrev, scrollNext]
135
+ [onKeyDown, previousKey, nextKey, scrollPrev, scrollNext]
58
136
  );
59
137
  React.useEffect(() => {
60
138
  if (!api || !setApi) return;
@@ -66,7 +144,8 @@ function Carousel({
66
144
  api.on("reInit", onSelect);
67
145
  api.on("select", onSelect);
68
146
  return () => {
69
- api?.off("select", onSelect);
147
+ api.off("reInit", onSelect);
148
+ api.off("select", onSelect);
70
149
  };
71
150
  }, [api, onSelect]);
72
151
  return /* @__PURE__ */ jsx(
@@ -85,7 +164,7 @@ function Carousel({
85
164
  children: /* @__PURE__ */ jsx(
86
165
  "div",
87
166
  {
88
- onKeyDownCapture: handleKeyDown,
167
+ onKeyDown: handleKeyDown,
89
168
  className: cn("relative", className),
90
169
  role: "region",
91
170
  "aria-roledescription": "carousel",
@@ -124,17 +203,24 @@ function CarouselItem({ className, ...props }) {
124
203
  }
125
204
  );
126
205
  }
206
+ function usesDefaultContent(children) {
207
+ return children === void 0 || children === null;
208
+ }
127
209
  function CarouselPrevious({
128
210
  className,
129
211
  variant = "outline",
130
212
  size = "icon",
213
+ label = "Previous slide",
214
+ children,
131
215
  ...props
132
216
  }) {
133
217
  const { orientation, scrollPrev, canScrollPrev } = useCarousel();
134
- return /* @__PURE__ */ jsxs(
218
+ const usesDefaultIcon = usesDefaultContent(children);
219
+ return /* @__PURE__ */ jsx(
135
220
  Button,
136
221
  {
137
222
  "data-slot": "carousel-previous",
223
+ "aria-label": usesDefaultIcon ? label : void 0,
138
224
  variant,
139
225
  size,
140
226
  className: cn(
@@ -145,10 +231,7 @@ function CarouselPrevious({
145
231
  disabled: !canScrollPrev,
146
232
  onClick: scrollPrev,
147
233
  ...props,
148
- children: [
149
- /* @__PURE__ */ jsx(IconChevronLeft, { className: "rtl:rotate-180" }),
150
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Previous slide" })
151
- ]
234
+ children: usesDefaultIcon ? /* @__PURE__ */ jsx(IconChevronLeft, { className: "rtl:rotate-180" }) : children
152
235
  }
153
236
  );
154
237
  }
@@ -156,13 +239,17 @@ function CarouselNext({
156
239
  className,
157
240
  variant = "outline",
158
241
  size = "icon",
242
+ label = "Next slide",
243
+ children,
159
244
  ...props
160
245
  }) {
161
246
  const { orientation, scrollNext, canScrollNext } = useCarousel();
162
- return /* @__PURE__ */ jsxs(
247
+ const usesDefaultIcon = usesDefaultContent(children);
248
+ return /* @__PURE__ */ jsx(
163
249
  Button,
164
250
  {
165
251
  "data-slot": "carousel-next",
252
+ "aria-label": usesDefaultIcon ? label : void 0,
166
253
  variant,
167
254
  size,
168
255
  className: cn(
@@ -173,10 +260,7 @@ function CarouselNext({
173
260
  disabled: !canScrollNext,
174
261
  onClick: scrollNext,
175
262
  ...props,
176
- children: [
177
- /* @__PURE__ */ jsx(IconChevronRight, { className: "rtl:rotate-180" }),
178
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Next slide" })
179
- ]
263
+ children: usesDefaultIcon ? /* @__PURE__ */ jsx(IconChevronRight, { className: "rtl:rotate-180" }) : children
180
264
  }
181
265
  );
182
266
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/carousel.tsx"],"names":["api"],"mappings":";;;;;;;;AA+BA,MAAM,eAAA,GAAkB,KAAA,CAAM,aAAA,CAA2C,IAAI,CAAA;AAE7E,SAAS,WAAA,GAAc;AACrB,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,UAAA,CAAW,eAAe,CAAA;AAEhD,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,gDAAgD,CAAA;AAAA,EAClE;AAEA,EAAA,OAAO,OAAA;AACT;AAEA,SAAS,QAAA,CAAS;AAAA,EAChB,WAAA,GAAc,YAAA;AAAA,EACd,IAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAgD;AAC9C,EAAA,MAAM,CAAC,WAAA,EAAa,GAAG,CAAA,GAAI,gBAAA;AAAA,IACzB;AAAA,MACE,GAAG,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UAAU,CAAC,aAAA;AAAA,MACX,OAAA,EAAS,UAAA;AAAA,MACR,GAAG,KAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,eAAA,EAAA,EAAgB,WAAU,gBAAA,EAAiB,CAAA;AAAA,wBAC5C,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAU,QAAA,EAAA,gBAAA,EAAc;AAAA;AAAA;AAAA,GAC1C;AAEJ;AAEA,SAAS,YAAA,CAAa;AAAA,EACpB,SAAA;AAAA,EACA,OAAA,GAAU,SAAA;AAAA,EACV,IAAA,GAAO,MAAA;AAAA,EACP,GAAG;AACL,CAAA,EAAwC;AACtC,EAAA,MAAM,EAAE,WAAA,EAAa,UAAA,EAAY,aAAA,KAAkB,WAAA,EAAY;AAE/D,EAAA,uBACE,IAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,eAAA;AAAA,MACV,OAAA;AAAA,MACA,IAAA;AAAA,MACA,SAAA,EAAW,EAAA;AAAA,QACT,0CAAA;AAAA,QACA,WAAA,KAAgB,eACZ,2BAAA,GACA,qEAAA;AAAA,QACJ;AAAA,OACF;AAAA,MACA,UAAU,CAAC,aAAA;AAAA,MACX,OAAA,EAAS,UAAA;AAAA,MACR,GAAG,KAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,gBAAA,EAAA,EAAiB,WAAU,gBAAA,EAAiB,CAAA;AAAA,wBAC7C,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAU,QAAA,EAAA,YAAA,EAAU;AAAA;AAAA;AAAA,GACtC;AAEJ","file":"carousel.js","sourcesContent":["'use client'\n\nimport useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react'\nimport * as React from 'react'\n\nimport { IconChevronLeft } from '../icons/chevron-left.js'\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { cn } from '../lib/utils.js'\nimport { Button } from './button.js'\n\ntype CarouselApi = UseEmblaCarouselType[1]\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>\ntype CarouselOptions = UseCarouselParameters[0]\ntype CarouselPlugin = UseCarouselParameters[1]\n\ntype CarouselProps = {\n opts?: CarouselOptions\n plugins?: CarouselPlugin\n orientation?: 'horizontal' | 'vertical'\n setApi?: (api: CarouselApi) => void\n}\n\ntype CarouselContextProps = {\n carouselRef: ReturnType<typeof useEmblaCarousel>[0]\n api: ReturnType<typeof useEmblaCarousel>[1]\n scrollPrev: () => void\n scrollNext: () => void\n canScrollPrev: boolean\n canScrollNext: boolean\n} & CarouselProps\n\nconst CarouselContext = React.createContext<CarouselContextProps | null>(null)\n\nfunction useCarousel() {\n const context = React.useContext(CarouselContext)\n\n if (!context) {\n throw new Error('useCarousel must be used within a <Carousel />')\n }\n\n return context\n}\n\nfunction Carousel({\n orientation = 'horizontal',\n opts,\n setApi,\n plugins,\n className,\n children,\n ...props\n}: React.ComponentProps<'div'> & CarouselProps) {\n const [carouselRef, api] = useEmblaCarousel(\n {\n ...opts,\n axis: orientation === 'horizontal' ? 'x' : 'y',\n },\n plugins,\n )\n const [canScrollPrev, setCanScrollPrev] = React.useState(false)\n const [canScrollNext, setCanScrollNext] = React.useState(false)\n\n const onSelect = React.useCallback((api: CarouselApi) => {\n if (!api) return\n setCanScrollPrev(api.canScrollPrev())\n setCanScrollNext(api.canScrollNext())\n }, [])\n\n const scrollPrev = React.useCallback(() => {\n api?.scrollPrev()\n }, [api])\n\n const scrollNext = React.useCallback(() => {\n api?.scrollNext()\n }, [api])\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'ArrowLeft') {\n event.preventDefault()\n scrollPrev()\n } else if (event.key === 'ArrowRight') {\n event.preventDefault()\n scrollNext()\n }\n },\n [scrollPrev, scrollNext],\n )\n\n React.useEffect(() => {\n if (!api || !setApi) return\n setApi(api)\n }, [api, setApi])\n\n React.useEffect(() => {\n if (!api) return\n // Seed the button state from Embla on mount: the api only exists after\n // Embla has initialised (so its 'init'/'reInit' event has already fired\n // before we subscribe below), and without this the \"next\" control would\n // stay disabled until the first scroll. The one extra render is intended.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n onSelect(api)\n api.on('reInit', onSelect)\n api.on('select', onSelect)\n\n return () => {\n api?.off('select', onSelect)\n }\n }, [api, onSelect])\n\n return (\n <CarouselContext.Provider\n value={{\n carouselRef,\n api: api,\n opts,\n orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n }}\n >\n <div\n onKeyDownCapture={handleKeyDown}\n className={cn('relative', className)}\n role='region'\n aria-roledescription='carousel'\n data-slot='carousel'\n {...props}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n )\n}\n\nfunction CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {\n const { carouselRef, orientation } = useCarousel()\n\n return (\n <div ref={carouselRef} className='overflow-hidden' data-slot='carousel-content'>\n <div\n className={cn('flex', orientation === 'horizontal' ? '-ms-4' : '-mt-4 flex-col', className)}\n {...props}\n />\n </div>\n )\n}\n\nfunction CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {\n const { orientation } = useCarousel()\n\n return (\n <div\n role='group'\n aria-roledescription='slide'\n data-slot='carousel-item'\n className={cn(\n 'min-w-0 shrink-0 grow-0 basis-full',\n orientation === 'horizontal' ? 'ps-4' : 'pt-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction CarouselPrevious({\n className,\n variant = 'outline',\n size = 'icon',\n ...props\n}: React.ComponentProps<typeof Button>) {\n const { orientation, scrollPrev, canScrollPrev } = useCarousel()\n\n return (\n <Button\n data-slot='carousel-previous'\n variant={variant}\n size={size}\n className={cn(\n 'absolute touch-manipulation rounded-full',\n orientation === 'horizontal'\n ? 'inset-y-0 -start-12 my-auto'\n : 'start-1/2 -top-12 -translate-x-1/2 rotate-90 rtl:translate-x-1/2',\n className,\n )}\n disabled={!canScrollPrev}\n onClick={scrollPrev}\n {...props}\n >\n <IconChevronLeft className='rtl:rotate-180' />\n <span className='sr-only'>Previous slide</span>\n </Button>\n )\n}\n\nfunction CarouselNext({\n className,\n variant = 'outline',\n size = 'icon',\n ...props\n}: React.ComponentProps<typeof Button>) {\n const { orientation, scrollNext, canScrollNext } = useCarousel()\n\n return (\n <Button\n data-slot='carousel-next'\n variant={variant}\n size={size}\n className={cn(\n 'absolute touch-manipulation rounded-full',\n orientation === 'horizontal'\n ? 'inset-y-0 -end-12 my-auto'\n : 'start-1/2 -bottom-12 -translate-x-1/2 rotate-90 rtl:translate-x-1/2',\n className,\n )}\n disabled={!canScrollNext}\n onClick={scrollNext}\n {...props}\n >\n <IconChevronRight className='rtl:rotate-180' />\n <span className='sr-only'>Next slide</span>\n </Button>\n )\n}\n\nexport {\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n useCarousel,\n type CarouselApi,\n}\n"]}
1
+ {"version":3,"sources":["../../src/components/carousel.tsx"],"names":["api"],"mappings":";;;;;;;;;AAgDA,MAAM,qBAAA,uBAA4B,GAAA,CAAI;AAAA;AAAA,EAEpC,UAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA;AAAA,EAEA,aAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA;AAAA,EAEA,cAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;A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,CAAA,GAAK;AAAA;AAAA,GACtE;AAEJ;AAEA,SAAS,YAAA,CAAa;AAAA,EACpB,SAAA;AAAA,EACA,OAAA,GAAU,SAAA;AAAA,EACV,IAAA,GAAO,MAAA;AAAA,EACP,KAAA,GAAQ,YAAA;AAAA,EACR,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EAMG;AACD,EAAA,MAAM,EAAE,WAAA,EAAa,UAAA,EAAY,aAAA,KAAkB,WAAA,EAAY;AAE/D,EAAA,MAAM,eAAA,GAAkB,mBAAmB,QAAQ,CAAA;AAEnD,EAAA,uBACE,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,eAAA;AAAA,MAQV,YAAA,EAAY,kBAAkB,KAAA,GAAQ,MAAA;AAAA,MACtC,OAAA;AAAA,MACA,IAAA;AAAA,MACA,SAAA,EAAW,EAAA;AAAA,QACT,0CAAA;AAAA,QACA,WAAA,KAAgB,eACZ,2BAAA,GACA,qEAAA;AAAA,QACJ;AAAA,OACF;AAAA,MACA,UAAU,CAAC,aAAA;AAAA,MACX,OAAA,EAAS,UAAA;AAAA,MACR,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA,eAAA,mBAAkB,GAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,kBAAiB,CAAA,GAAK;AAAA;AAAA,GACvE;AAEJ","file":"carousel.js","sourcesContent":["'use client'\n\nimport useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react'\nimport * as React from 'react'\n\nimport { IconChevronLeft } from '../icons/chevron-left.js'\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { cn } from '../lib/utils.js'\nimport { Button } from './button.js'\nimport { useDirection } from './direction.js'\n\ntype CarouselApi = UseEmblaCarouselType[1]\ntype UseCarouselParameters = Parameters<typeof useEmblaCarousel>\ntype CarouselOptions = UseCarouselParameters[0]\ntype CarouselPlugin = UseCarouselParameters[1]\n\ntype CarouselProps = {\n opts?: CarouselOptions\n plugins?: CarouselPlugin\n orientation?: 'horizontal' | 'vertical'\n setApi?: (api: CarouselApi) => void\n}\n\ntype CarouselContextProps = {\n carouselRef: ReturnType<typeof useEmblaCarousel>[0]\n api: ReturnType<typeof useEmblaCarousel>[1]\n scrollPrev: () => void\n scrollNext: () => void\n canScrollPrev: boolean\n canScrollNext: boolean\n} & CarouselProps\n\n/**\n * Roles whose keyboard contract claims the arrow keys.\n *\n * Three groups, and the split matters for how they are matched:\n *\n * 1. Roles that consume arrows on the FOCUSED element itself — a caret or a\n * thumb lives there.\n * 2. COMPOSITE roles that consume arrows on behalf of a focused descendant.\n * Under a roving tabindex the focus sits on the `tab`/`option`/`menuitem`\n * while the contract lives on the container, so matching the event target's\n * own role alone misses every one of them. The ancestor walk in\n * `ownsArrowKeys` is what finds these.\n * 3. The descendant halves of those composites. Redundant with the walk when\n * the pair is nested in the DOM, but a composite may own its items through\n * `aria-owns` instead, and no ancestor walk can see that association.\n */\nconst ARROW_CONSUMING_ROLES = new Set([\n // 1 — consumed by the focused element\n 'combobox',\n 'scrollbar',\n 'searchbox',\n // `separator` is the focusable window-splitter form, and it is not\n // hypothetical here: this package's own ResizableHandle wraps\n // react-resizable-panels, which renders role=\"separator\" and handles all\n // four arrows. A Resizable inside a slide loses its keyboard resizing\n // without this entry.\n 'separator',\n 'slider',\n 'spinbutton',\n 'textbox',\n // 2 — consumed by an ancestor composite\n 'application',\n 'grid',\n 'listbox',\n 'menu',\n 'menubar',\n 'radiogroup',\n 'tablist',\n // `toolbar` matters more than it looks: its controls are usually plain\n // buttons, which have no native arrow behaviour, so a toolbar can move focus\n // WITHOUT calling preventDefault — meaning the defaultPrevented guard in the\n // handler does not cover it and only this list can.\n 'toolbar',\n 'tree',\n 'treegrid',\n // 3 — the descendant halves, for aria-owns associations\n 'columnheader',\n 'gridcell',\n 'menuitem',\n 'menuitemcheckbox',\n 'menuitemradio',\n 'option',\n 'radio',\n 'row',\n 'rowheader',\n 'tab',\n 'treeitem',\n])\n\n/**\n * Whether the event target owns the arrow keys itself.\n *\n * The carousel's key handler runs on the region, so without this test it would\n * act on arrows the user meant for a control INSIDE a slide — moving the\n * carousel instead of the caret in a text field, or the thumb on a slider.\n * Slides carrying form controls are ordinary (a filter row, a step in a form),\n * so this is the common case, not an exotic one.\n *\n * Native elements are matched by tag rather than by their implicit role,\n * because an `<input type='checkbox'>` reports no `role` attribute and its\n * implicit role is not readable from the DOM without a mapping table. Every\n * `<input>` is treated as arrow-consuming: the types that do not strictly need\n * arrows (checkbox, button) are still ones a user would not expect to scroll a\n * carousel from.\n */\nfunction ownsArrowKeys(target: EventTarget | null, boundary: EventTarget | null): boolean {\n // Walks ANCESTORS, not just the target. Every roving-tabindex composite\n // focuses a descendant — the `tab` inside the `tablist`, the `option` inside\n // the `listbox` — so testing only the focused element's own role misses the\n // entire class, and the carousel scrolls while the user is moving between\n // tabs. Stops at the carousel region so the walk cannot escape into the\n // consumer's page and match something unrelated.\n //\n // Duck-typed on nodeType rather than `instanceof Element`. `instanceof` is\n // per-realm: a carousel rendered into another document (a portal, a\n // popped-out window) would fail the check and fall through to `false`, and\n // false is the ANSWER THAT STEALS THE KEY — the exact bug this guard exists\n // to prevent. Getting it wrong should not depend on which realm the node\n // came from.\n let element = target as Element | null\n\n while (element && element.nodeType === 1 && typeof element.getAttribute === 'function') {\n const tag = element.tagName\n if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT') {\n return true\n }\n if ((element as HTMLElement).isContentEditable) {\n return true\n }\n const role = element.getAttribute('role')\n if (role !== null && ARROW_CONSUMING_ROLES.has(role)) {\n return true\n }\n // Tested first, then stopped on: the region itself gets the same checks as\n // anything else, but nothing above it does.\n if (element === boundary) {\n return false\n }\n element = element.parentElement\n }\n\n return false\n}\n\nconst CarouselContext = React.createContext<CarouselContextProps | null>(null)\n\nfunction useCarousel() {\n const context = React.useContext(CarouselContext)\n\n if (!context) {\n throw new Error('useCarousel must be used within a <Carousel />')\n }\n\n return context\n}\n\nfunction Carousel({\n orientation = 'horizontal',\n opts,\n setApi,\n plugins,\n className,\n children,\n onKeyDown,\n ...props\n}: React.ComponentProps<'div'> & CarouselProps) {\n // Read once, and used for BOTH halves of direction handling: embla's own\n // scroll axis and the arrow-key mapping below. Wiring only the keys (which\n // an earlier version of this file did) leaves the engine scrolling ltr while\n // the keyboard and the RTL flex layout both run the other way — the two\n // disagree on every press unless the consumer separately passes\n // `opts.direction`, which nothing documented or enforced.\n //\n // `direction` sits BEFORE the spread so an explicit `opts.direction` still\n // wins; a consumer who wants the engine mirrored independently of the\n // ambient DirectionProvider keeps that escape hatch.\n // `opts.direction` wins for the engine because it is spread later, so it has\n // to win for the KEYS too. Deriving both from one effective value is what\n // makes the escape hatch documented below actually safe: passing\n // `opts={{ direction: 'rtl' }}` under a default LTR provider previously ran\n // the engine RTL while mapping keys LTR, so the two halves disagreed on every\n // press — the same class of desync this comment claims to prevent.\n const providerDirection = useDirection()\n const direction = opts?.direction ?? providerDirection\n const [carouselRef, api] = useEmblaCarousel(\n {\n direction,\n ...opts,\n axis: orientation === 'horizontal' ? 'x' : 'y',\n },\n plugins,\n )\n const [canScrollPrev, setCanScrollPrev] = React.useState(false)\n const [canScrollNext, setCanScrollNext] = React.useState(false)\n\n const onSelect = React.useCallback((api: CarouselApi) => {\n if (!api) return\n setCanScrollPrev(api.canScrollPrev())\n setCanScrollNext(api.canScrollNext())\n }, [])\n\n const scrollPrev = React.useCallback(() => {\n api?.scrollPrev()\n }, [api])\n\n const scrollNext = React.useCallback(() => {\n api?.scrollNext()\n }, [api])\n\n // Which arrow key means \"previous\". A vertical carousel moves on the block\n // axis, and a horizontal one follows the reading direction — in RTL the\n // first slide sits on the RIGHT, so ArrowRight goes back. The rest of this\n // file is already direction-aware through logical properties (`-ms-4`,\n // `ps-4`, `-start-12`) and `rtl:` variants; keys have to agree with them or\n // the keyboard drives the carousel the opposite way to what is on screen.\n //\n // `useDirection` (read above, and also handed to embla) comes from the\n // nearest DirectionProvider. Consumers must ALSO set `dir` on a DOM ancestor\n // for the CSS half — see the note on DirectionProvider in\n // direction.stories.tsx.\n const [previousKey, nextKey] =\n orientation === 'vertical'\n ? (['ArrowUp', 'ArrowDown'] as const)\n : direction === 'rtl'\n ? (['ArrowRight', 'ArrowLeft'] as const)\n : (['ArrowLeft', 'ArrowRight'] as const)\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n // The consumer's handler runs FIRST, and is destructured out of `props`\n // rather than left to the trailing spread. The spread sits after\n // `onKeyDown` on the root element, so a consumer passing one used to\n // REPLACE this handler outright and silently switch off every arrow key\n // — on a component whose props type explicitly accepts `onKeyDown`.\n //\n // Running theirs first also gives them a working opt-out for free: the\n // defaultPrevented test below already covers it, so `preventDefault()`\n // in a consumer handler suppresses the carousel exactly as it does for a\n // widget inside a slide. Errors are deliberately not caught — a throwing\n // consumer handler should surface, as it would on a plain <div>.\n onKeyDown?.(event)\n\n // Somebody nearer the key already dealt with it. ownsArrowKeys below is a\n // list of the things we know consume arrows; this is the open-ended half,\n // covering any custom widget in a slide that handles its own keys and\n // says so the standard way.\n //\n // It also covers a nested carousel, because the inner one calls\n // preventDefault when it acts: by the time the event reaches an outer\n // carousel's handler this test is already true. Measured — removing this\n // OR the stopPropagation below leaves the Nested story passing, and\n // removing both fails it. The two overlap deliberately; see below.\n if (event.defaultPrevented) {\n return\n }\n // A control inside a slide gets its arrows untouched. See ownsArrowKeys.\n if (ownsArrowKeys(event.target, event.currentTarget)) {\n return\n }\n if (event.key === previousKey) {\n event.preventDefault()\n // Keeps the press from reaching ancestors at all. For an ancestor\n // CAROUSEL the defaultPrevented test above already handles it, so this\n // is not what fixes nesting on its own — it is here for ancestors that\n // are not carousels: a native keydown listener on a wrapper does not\n // consult defaultPrevented unless its author remembered to, and a key\n // this component has consumed should not also scroll someone's custom\n // shell.\n event.stopPropagation()\n scrollPrev()\n } else if (event.key === nextKey) {\n event.preventDefault()\n event.stopPropagation()\n scrollNext()\n }\n },\n [onKeyDown, previousKey, nextKey, scrollPrev, scrollNext],\n )\n\n React.useEffect(() => {\n if (!api || !setApi) return\n setApi(api)\n }, [api, setApi])\n\n React.useEffect(() => {\n if (!api) return\n // Seed the button state from Embla on mount: the api only exists after\n // Embla has initialised (so its 'init'/'reInit' event has already fired\n // before we subscribe below), and without this the \"next\" control would\n // stay disabled until the first scroll. The one extra render is intended.\n // eslint-disable-next-line react-hooks/set-state-in-effect\n onSelect(api)\n api.on('reInit', onSelect)\n api.on('select', onSelect)\n\n return () => {\n // BOTH subscriptions come off. Embla clears its own event store on\n // destroy, so leaving 'reInit' attached is harmless while the api lives\n // and dies with this component — but the moment `api` is recreated\n // (a plugin change, a remount) the previous instance keeps a live\n // handler, and the asymmetry reads as an oversight either way.\n api.off('reInit', onSelect)\n api.off('select', onSelect)\n }\n }, [api, onSelect])\n\n return (\n <CarouselContext.Provider\n value={{\n carouselRef,\n api: api,\n opts,\n orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),\n scrollPrev,\n scrollNext,\n canScrollPrev,\n canScrollNext,\n }}\n >\n <div\n // Bubble phase, not capture: a capture listener here runs BEFORE the\n // event reaches the focused descendant, so it would take the arrows\n // off an input in a slide no matter what that input wanted. Bubbling\n // lets the control handle (and, where it cares, preventDefault) first.\n //\n // Safe to sit before `{...props}` only because `onKeyDown` is\n // destructured out of props and composed inside handleKeyDown. Do not\n // \"simplify\" that away — the spread would silently win.\n onKeyDown={handleKeyDown}\n className={cn('relative', className)}\n role='region'\n aria-roledescription='carousel'\n data-slot='carousel'\n {...props}\n >\n {children}\n </div>\n </CarouselContext.Provider>\n )\n}\n\nfunction CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {\n const { carouselRef, orientation } = useCarousel()\n\n return (\n <div ref={carouselRef} className='overflow-hidden' data-slot='carousel-content'>\n <div\n className={cn('flex', orientation === 'horizontal' ? '-ms-4' : '-mt-4 flex-col', className)}\n {...props}\n />\n </div>\n )\n}\n\nfunction CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {\n const { orientation } = useCarousel()\n\n return (\n <div\n role='group'\n aria-roledescription='slide'\n data-slot='carousel-item'\n className={cn(\n 'min-w-0 shrink-0 grow-0 basis-full',\n orientation === 'horizontal' ? 'ps-4' : 'pt-4',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * Whether a control should render its own default icon — and therefore whether\n * it must supply its own accessible name.\n *\n * ONE test, because the fallback content and the `aria-label` have to agree\n * about what \"the consumer supplied content\" means, and they once did not:\n * `??` treats null and undefined alike while the label test named only\n * `undefined`, so `children={null}` — what `cond ? <Icon/> : null` yields —\n * rendered the default chevron with NO accessible name, on a control whose\n * only name is that label. Both call sites now derive from here, so they\n * cannot drift apart again.\n *\n * `children={false}` (from `{cond && <Icon/>}`) is deliberately excluded: that\n * consumer asked for no content, and substituting the default icon would be a\n * surprise. The resulting unnamed button is reported by Button's own dev-time\n * icon-only warning.\n */\nfunction usesDefaultContent(children: React.ReactNode): boolean {\n return children === undefined || children === null\n}\n\nfunction CarouselPrevious({\n className,\n variant = 'outline',\n size = 'icon',\n label = 'Previous slide',\n children,\n ...props\n}: React.ComponentProps<typeof Button> & {\n /**\n * Screen-reader name for the control. Override to translate it — the\n * control is icon-only, so this string is the only name AT ever hears.\n */\n label?: string\n}) {\n const { orientation, scrollPrev, canScrollPrev } = useCarousel()\n\n const usesDefaultIcon = usesDefaultContent(children)\n\n return (\n <Button\n data-slot='carousel-previous'\n // Named via aria-label rather than an sr-only child. Both give AT the\n // same name, but Button's dev-time icon-only warning only inspects\n // aria-label/aria-labelledby — with the sr-only span it fired on every\n // render of a control that was correctly named all along, which is the\n // fastest way to teach a team to ignore the warning. Set only when we\n // render the default icon: a consumer passing `children` supplies their\n // own content, and an aria-label would mask it.\n aria-label={usesDefaultIcon ? label : undefined}\n variant={variant}\n size={size}\n className={cn(\n 'absolute touch-manipulation rounded-full',\n orientation === 'horizontal'\n ? 'inset-y-0 -start-12 my-auto'\n : 'start-1/2 -top-12 -translate-x-1/2 rotate-90 rtl:translate-x-1/2',\n className,\n )}\n disabled={!canScrollPrev}\n onClick={scrollPrev}\n {...props}\n >\n {usesDefaultIcon ? <IconChevronLeft className='rtl:rotate-180' /> : children}\n </Button>\n )\n}\n\nfunction CarouselNext({\n className,\n variant = 'outline',\n size = 'icon',\n label = 'Next slide',\n children,\n ...props\n}: React.ComponentProps<typeof Button> & {\n /**\n * Screen-reader name for the control. Override to translate it — the\n * control is icon-only, so this string is the only name AT ever hears.\n */\n label?: string\n}) {\n const { orientation, scrollNext, canScrollNext } = useCarousel()\n\n const usesDefaultIcon = usesDefaultContent(children)\n\n return (\n <Button\n data-slot='carousel-next'\n // Named via aria-label rather than an sr-only child. Both give AT the\n // same name, but Button's dev-time icon-only warning only inspects\n // aria-label/aria-labelledby — with the sr-only span it fired on every\n // render of a control that was correctly named all along, which is the\n // fastest way to teach a team to ignore the warning. Set only when we\n // render the default icon: a consumer passing `children` supplies their\n // own content, and an aria-label would mask it.\n aria-label={usesDefaultIcon ? label : undefined}\n variant={variant}\n size={size}\n className={cn(\n 'absolute touch-manipulation rounded-full',\n orientation === 'horizontal'\n ? 'inset-y-0 -end-12 my-auto'\n : 'start-1/2 -bottom-12 -translate-x-1/2 rotate-90 rtl:translate-x-1/2',\n className,\n )}\n disabled={!canScrollNext}\n onClick={scrollNext}\n {...props}\n >\n {usesDefaultIcon ? <IconChevronRight className='rtl:rotate-180' /> : children}\n </Button>\n )\n}\n\nexport {\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n useCarousel,\n type CarouselApi,\n}\n"]}
@@ -17,8 +17,15 @@ declare function ComboboxCollection({ ...props }: Combobox$1.Collection.Props):
17
17
  declare function ComboboxEmpty({ className, ...props }: Combobox$1.Empty.Props): React.JSX.Element;
18
18
  declare function ComboboxSeparator({ className, ...props }: Combobox$1.Separator.Props): React.JSX.Element;
19
19
  declare function ComboboxChips({ className, ...props }: React.ComponentPropsWithRef<typeof Combobox$1.Chips> & Combobox$1.Chips.Props): React.JSX.Element;
20
- declare function ComboboxChip({ className, children, showRemove, ...props }: Combobox$1.Chip.Props & {
20
+ declare function ComboboxChip({ className, children, showRemove, removeLabel, ...props }: Combobox$1.Chip.Props & {
21
21
  showRemove?: boolean;
22
+ /**
23
+ * Screen-reader name for the chip's remove button. Override to translate it
24
+ * — the button is icon-only, so this string is the only name AT ever hears.
25
+ * Include the chip's own text where a bare "Remove" would be ambiguous in a
26
+ * list of chips.
27
+ */
28
+ removeLabel?: string;
22
29
  }): React.JSX.Element;
23
30
  declare function ComboboxChipsInput({ className, ...props }: Combobox$1.Input.Props): React.JSX.Element;
24
31
  declare function useComboboxAnchor(): React.RefObject<HTMLDivElement | null>;
@@ -196,6 +196,7 @@ function ComboboxChip({
196
196
  className,
197
197
  children,
198
198
  showRemove = true,
199
+ removeLabel = "Remove",
199
200
  ...props
200
201
  }) {
201
202
  return /* @__PURE__ */ jsxs(
@@ -213,7 +214,7 @@ function ComboboxChip({
213
214
  Combobox$1.ChipRemove,
214
215
  {
215
216
  render: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon" }),
216
- "aria-label": "Remove",
217
+ "aria-label": removeLabel,
217
218
  className: "-ms-1 opacity-50 hover:opacity-100",
218
219
  "data-slot": "combobox-chip-remove",
219
220
  children: /* @__PURE__ */ jsx(IconClose, { className: "pointer-events-none" })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/combobox.tsx"],"names":["ComboboxPrimitive"],"mappings":";;;;;;;;;;AAYA,MAAM,WAAWA,UAAA,CAAkB;AAEnC,SAAS,aAAA,CAAc,EAAE,GAAG,KAAA,EAAM,EAAkC;AAClE,EAAA,2BAAQA,UAAA,CAAkB,KAAA,EAAlB,EAAwB,WAAA,EAAU,gBAAA,EAAkB,GAAG,KAAA,EAAO,CAAA;AACxE;AAEA,SAAS,gBAAgB,EAAE,SAAA,EAAW,QAAA,EAAU,GAAG,OAAM,EAAoC;AAC3F,EAAA,uBACE,IAAA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B;AAAA,MACC,WAAA,EAAU,eAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,4UAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA,QAAA,QAAA;AAAA,QACA,UAAA,oBACC,GAAA;AAAA,UAACA,UAAA,CAAkB,UAAA;AAAA,UAAlB;AAAA,YACC,wBAAQ,GAAA,CAAC,MAAA,EAAA,EAAO,OAAA,EAAQ,OAAA,EAAQ,MAAK,MAAA,EAAO,CAAA;AAAA,YAC5C,YAAA,EAAW,QAAA;AAAA,YACX,SAAA,EAAU,oCAAA;AAAA,YACV,WAAA,EAAU,sBAAA;AAAA,YAEV,QAAA,kBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAU,qBAAA,EAAsB;AAAA;AAAA;AAC7C;AAAA;AAAA,GAEJ;AAEJ;AAEA,SAAS,kBAAA,CAAmB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AAClF,EAAA,uBACE,GAAA;AAAA,IAACA,UAAA,CAAkB,KAAA;AAAA,IAAlB;AAAA,MACC,WAAA,EAAU,qBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,8BAAA,EAAgC,SAAS,CAAA;AAAA,MACtD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,iBAAA,GAAoB;AAC3B,EAAA,OAAO,KAAA,CAAM,OAA8B,IAAI,CAAA;AACjD","file":"combobox.js","sourcesContent":["'use client'\n\nimport { Combobox as ComboboxPrimitive } from '@base-ui/react'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconClose } from '../icons/close.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { cn } from '../lib/utils.js'\nimport { Button } from './button.js'\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from './input-group.js'\n\nconst Combobox = ComboboxPrimitive.Root\n\nfunction ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {\n return <ComboboxPrimitive.Value data-slot='combobox-value' {...props} />\n}\n\nfunction ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {\n return (\n <ComboboxPrimitive.Trigger\n data-slot='combobox-trigger'\n aria-label='Show suggestions'\n className={cn(\"[&_svg:not([class*='size-'])]:size-3.5\", className)}\n {...props}\n >\n {children}\n <IconExpandMore className='pointer-events-none size-3.5 text-muted-foreground' />\n </ComboboxPrimitive.Trigger>\n )\n}\n\nfunction ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {\n return (\n <ComboboxPrimitive.Clear\n data-slot='combobox-clear'\n aria-label='Clear'\n render={<InputGroupButton variant='ghost' size='icon-xs' />}\n className={cn(className)}\n {...props}\n >\n <IconClose className='pointer-events-none' />\n </ComboboxPrimitive.Clear>\n )\n}\n\nfunction ComboboxInput({\n className,\n children,\n disabled = false,\n showTrigger = true,\n showClear = false,\n ...props\n}: ComboboxPrimitive.Input.Props & {\n showTrigger?: boolean\n showClear?: boolean\n}) {\n return (\n <InputGroup className={cn('w-auto', className)}>\n <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />\n <InputGroupAddon align='inline-end'>\n {showTrigger && (\n <InputGroupButton\n size='icon-xs'\n variant='ghost'\n render={<ComboboxTrigger />}\n data-slot='input-group-button'\n className='group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent'\n disabled={disabled}\n />\n )}\n {showClear && <ComboboxClear disabled={disabled} />}\n </InputGroupAddon>\n {children}\n </InputGroup>\n )\n}\n\nfunction ComboboxContent({\n className,\n side = 'bottom',\n sideOffset = 6,\n align = 'start',\n alignOffset = 0,\n anchor,\n ...props\n}: ComboboxPrimitive.Popup.Props &\n Pick<\n ComboboxPrimitive.Positioner.Props,\n 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'\n >) {\n return (\n <ComboboxPrimitive.Portal>\n <ComboboxPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n anchor={anchor}\n className='isolate z-50'\n >\n <ComboboxPrimitive.Popup\n data-slot='combobox-content'\n data-chips={!!anchor}\n className={cn(\n 'group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:bg-input/20 *:data-[slot=input-group]:shadow-none dark:bg-popover data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n className,\n )}\n {...props}\n />\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n )\n}\n\nfunction ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {\n return (\n <ComboboxPrimitive.List\n data-slot='combobox-list'\n className={cn(\n 'no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {\n return (\n <ComboboxPrimitive.Item\n data-slot='combobox-item'\n className={cn(\n \"relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-sm px-2 py-1 text-xs/relaxed outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n {children}\n <ComboboxPrimitive.ItemIndicator\n render={\n <span className='pointer-events-none absolute end-2 flex items-center justify-center' />\n }\n >\n <IconCheck className='pointer-events-none' />\n </ComboboxPrimitive.ItemIndicator>\n </ComboboxPrimitive.Item>\n )\n}\n\nfunction ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {\n return <ComboboxPrimitive.Group data-slot='combobox-group' className={cn(className)} {...props} />\n}\n\nfunction ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {\n return (\n <ComboboxPrimitive.GroupLabel\n data-slot='combobox-label'\n className={cn('px-2 py-1.5 text-xs text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {\n return <ComboboxPrimitive.Collection data-slot='combobox-collection' {...props} />\n}\n\nfunction ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {\n return (\n <ComboboxPrimitive.Empty\n data-slot='combobox-empty'\n className={cn(\n 'hidden w-full justify-center py-2 text-center text-xs/relaxed text-muted-foreground group-data-empty/combobox-content:flex',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {\n return (\n <ComboboxPrimitive.Separator\n data-slot='combobox-separator'\n className={cn('-mx-1 my-1 h-px bg-border/50', className)}\n {...props}\n />\n )\n}\n\nfunction ComboboxChips({\n className,\n ...props\n}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {\n return (\n <ComboboxPrimitive.Chips\n data-slot='combobox-chips'\n className={cn(\n 'flex min-h-7 flex-wrap items-center gap-1 rounded-sm border border-input bg-input/20 bg-clip-padding px-2 py-0.5 text-xs/relaxed transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30 has-aria-invalid:border-destructive has-aria-invalid:ring-2 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxChip({\n className,\n children,\n showRemove = true,\n ...props\n}: ComboboxPrimitive.Chip.Props & {\n showRemove?: boolean\n}) {\n return (\n <ComboboxPrimitive.Chip\n data-slot='combobox-chip'\n className={cn(\n 'flex h-[calc(--spacing(4.75))] w-fit items-center justify-center gap-1 rounded-[calc(var(--radius-sm)-2px)] bg-muted-foreground/10 px-1.5 text-xs/relaxed font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pe-0',\n className,\n )}\n {...props}\n >\n {children}\n {showRemove && (\n <ComboboxPrimitive.ChipRemove\n render={<Button variant='ghost' size='icon' />}\n aria-label='Remove'\n className='-ms-1 opacity-50 hover:opacity-100'\n data-slot='combobox-chip-remove'\n >\n <IconClose className='pointer-events-none' />\n </ComboboxPrimitive.ChipRemove>\n )}\n </ComboboxPrimitive.Chip>\n )\n}\n\nfunction ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props) {\n return (\n <ComboboxPrimitive.Input\n data-slot='combobox-chip-input'\n className={cn('min-w-16 flex-1 outline-none', className)}\n {...props}\n />\n )\n}\n\nfunction useComboboxAnchor() {\n return React.useRef<HTMLDivElement | null>(null)\n}\n\nexport {\n Combobox,\n ComboboxChip,\n ComboboxChips,\n ComboboxChipsInput,\n ComboboxCollection,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxGroup,\n ComboboxInput,\n ComboboxItem,\n ComboboxLabel,\n ComboboxList,\n ComboboxSeparator,\n ComboboxTrigger,\n ComboboxValue,\n useComboboxAnchor,\n}\n"]}
1
+ {"version":3,"sources":["../../src/components/combobox.tsx"],"names":["ComboboxPrimitive"],"mappings":";;;;;;;;;;AAYA,M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sourcesContent":["'use client'\n\nimport { Combobox as ComboboxPrimitive } from '@base-ui/react'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconClose } from '../icons/close.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { cn } from '../lib/utils.js'\nimport { Button } from './button.js'\nimport { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from './input-group.js'\n\nconst Combobox = ComboboxPrimitive.Root\n\nfunction ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {\n return <ComboboxPrimitive.Value data-slot='combobox-value' {...props} />\n}\n\nfunction ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {\n return (\n <ComboboxPrimitive.Trigger\n data-slot='combobox-trigger'\n aria-label='Show suggestions'\n className={cn(\"[&_svg:not([class*='size-'])]:size-3.5\", className)}\n {...props}\n >\n {children}\n <IconExpandMore className='pointer-events-none size-3.5 text-muted-foreground' />\n </ComboboxPrimitive.Trigger>\n )\n}\n\nfunction ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {\n return (\n <ComboboxPrimitive.Clear\n data-slot='combobox-clear'\n aria-label='Clear'\n render={<InputGroupButton variant='ghost' size='icon-xs' />}\n className={cn(className)}\n {...props}\n >\n <IconClose className='pointer-events-none' />\n </ComboboxPrimitive.Clear>\n )\n}\n\nfunction ComboboxInput({\n className,\n children,\n disabled = false,\n showTrigger = true,\n showClear = false,\n ...props\n}: ComboboxPrimitive.Input.Props & {\n showTrigger?: boolean\n showClear?: boolean\n}) {\n return (\n <InputGroup className={cn('w-auto', className)}>\n <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />\n <InputGroupAddon align='inline-end'>\n {showTrigger && (\n <InputGroupButton\n size='icon-xs'\n variant='ghost'\n render={<ComboboxTrigger />}\n data-slot='input-group-button'\n className='group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent'\n disabled={disabled}\n />\n )}\n {showClear && <ComboboxClear disabled={disabled} />}\n </InputGroupAddon>\n {children}\n </InputGroup>\n )\n}\n\nfunction ComboboxContent({\n className,\n side = 'bottom',\n sideOffset = 6,\n align = 'start',\n alignOffset = 0,\n anchor,\n ...props\n}: ComboboxPrimitive.Popup.Props &\n Pick<\n ComboboxPrimitive.Positioner.Props,\n 'side' | 'align' | 'sideOffset' | 'alignOffset' | 'anchor'\n >) {\n return (\n <ComboboxPrimitive.Portal>\n <ComboboxPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n anchor={anchor}\n className='isolate z-50'\n >\n <ComboboxPrimitive.Popup\n data-slot='combobox-content'\n data-chips={!!anchor}\n className={cn(\n 'group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-7 *:data-[slot=input-group]:border-none *:data-[slot=input-group]:bg-input/20 *:data-[slot=input-group]:shadow-none dark:bg-popover data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n className,\n )}\n {...props}\n />\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n )\n}\n\nfunction ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {\n return (\n <ComboboxPrimitive.List\n data-slot='combobox-list'\n className={cn(\n 'no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {\n return (\n <ComboboxPrimitive.Item\n data-slot='combobox-item'\n className={cn(\n \"relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-sm px-2 py-1 text-xs/relaxed outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n {children}\n <ComboboxPrimitive.ItemIndicator\n render={\n <span className='pointer-events-none absolute end-2 flex items-center justify-center' />\n }\n >\n <IconCheck className='pointer-events-none' />\n </ComboboxPrimitive.ItemIndicator>\n </ComboboxPrimitive.Item>\n )\n}\n\nfunction ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {\n return <ComboboxPrimitive.Group data-slot='combobox-group' className={cn(className)} {...props} />\n}\n\nfunction ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {\n return (\n <ComboboxPrimitive.GroupLabel\n data-slot='combobox-label'\n className={cn('px-2 py-1.5 text-xs text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {\n return <ComboboxPrimitive.Collection data-slot='combobox-collection' {...props} />\n}\n\nfunction ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {\n return (\n <ComboboxPrimitive.Empty\n data-slot='combobox-empty'\n className={cn(\n 'hidden w-full justify-center py-2 text-center text-xs/relaxed text-muted-foreground group-data-empty/combobox-content:flex',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {\n return (\n <ComboboxPrimitive.Separator\n data-slot='combobox-separator'\n className={cn('-mx-1 my-1 h-px bg-border/50', className)}\n {...props}\n />\n )\n}\n\nfunction ComboboxChips({\n className,\n ...props\n}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {\n return (\n <ComboboxPrimitive.Chips\n data-slot='combobox-chips'\n className={cn(\n 'flex min-h-7 flex-wrap items-center gap-1 rounded-sm border border-input bg-input/20 bg-clip-padding px-2 py-0.5 text-xs/relaxed transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/30 has-aria-invalid:border-destructive has-aria-invalid:ring-2 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxChip({\n className,\n children,\n showRemove = true,\n removeLabel = 'Remove',\n ...props\n}: ComboboxPrimitive.Chip.Props & {\n showRemove?: boolean\n /**\n * Screen-reader name for the chip's remove button. Override to translate it\n * — the button is icon-only, so this string is the only name AT ever hears.\n * Include the chip's own text where a bare \"Remove\" would be ambiguous in a\n * list of chips.\n */\n removeLabel?: string\n}) {\n return (\n <ComboboxPrimitive.Chip\n data-slot='combobox-chip'\n className={cn(\n 'flex h-[calc(--spacing(4.75))] w-fit items-center justify-center gap-1 rounded-[calc(var(--radius-sm)-2px)] bg-muted-foreground/10 px-1.5 text-xs/relaxed font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pe-0',\n className,\n )}\n {...props}\n >\n {children}\n {showRemove && (\n <ComboboxPrimitive.ChipRemove\n render={<Button variant='ghost' size='icon' />}\n aria-label={removeLabel}\n className='-ms-1 opacity-50 hover:opacity-100'\n data-slot='combobox-chip-remove'\n >\n <IconClose className='pointer-events-none' />\n </ComboboxPrimitive.ChipRemove>\n )}\n </ComboboxPrimitive.Chip>\n )\n}\n\nfunction ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props) {\n return (\n <ComboboxPrimitive.Input\n data-slot='combobox-chip-input'\n className={cn('min-w-16 flex-1 outline-none', className)}\n {...props}\n />\n )\n}\n\nfunction useComboboxAnchor() {\n return React.useRef<HTMLDivElement | null>(null)\n}\n\nexport {\n Combobox,\n ComboboxChip,\n ComboboxChips,\n ComboboxChipsInput,\n ComboboxCollection,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxGroup,\n ComboboxInput,\n ComboboxItem,\n ComboboxLabel,\n ComboboxList,\n ComboboxSeparator,\n ComboboxTrigger,\n ComboboxValue,\n useComboboxAnchor,\n}\n"]}
@@ -130,7 +130,10 @@ type MainNavProps = Omit<React__default.ComponentPropsWithoutRef<'nav'>, 'childr
130
130
  * shifts Base UI's trigger-anchored positioner back to the container's left
131
131
  * edge (measured at position time from the open trigger, so it is exact for
132
132
  * every trigger — this replaces the app source's panelMetrics state).
133
- * Assumes LTR; see the class comments.
133
+ * The offset is physical and correct in BOTH directions: Base UI passes
134
+ * `align` to floating-ui as a physical placement and only mirrors a logical
135
+ * `side`, so nothing about this anchoring flips under RTL. See the comment
136
+ * on `alignOffset`, and the RightToLeft story that pins it.
134
137
  * - `container`, `border`, `shadow`, `sticky` mirror the house chrome
135
138
  * components; the app's deprecated `showTopBorder`/`showBottomBorder` and
136
139
  * `responsive` props are not ported (use `border` and