@manakind/ui-core 0.28.1 → 0.30.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 (78) hide show
  1. package/README.md +7 -3
  2. package/dist/accordion/accordion.css +89 -0
  3. package/dist/accordion/accordion.css.d.ts +2 -0
  4. package/dist/accordion/accordion.d.ts +79 -0
  5. package/dist/accordion/accordion.d.ts.map +1 -0
  6. package/dist/accordion/accordion.js +44 -0
  7. package/dist/accordion/accordion.js.map +1 -0
  8. package/dist/accordion/index.d.ts +2 -0
  9. package/dist/accordion/index.d.ts.map +1 -0
  10. package/dist/accordion/index.js +2 -0
  11. package/dist/accordion/index.js.map +1 -0
  12. package/dist/button/button.css +7 -1
  13. package/dist/button/button.d.ts +5 -3
  14. package/dist/button/button.d.ts.map +1 -1
  15. package/dist/button/button.js +7 -4
  16. package/dist/button/button.js.map +1 -1
  17. package/dist/button/icon-button.d.ts +4 -2
  18. package/dist/button/icon-button.d.ts.map +1 -1
  19. package/dist/button/icon-button.js +5 -2
  20. package/dist/button/icon-button.js.map +1 -1
  21. package/dist/button/loading-interaction.d.ts +6 -0
  22. package/dist/button/loading-interaction.d.ts.map +1 -0
  23. package/dist/button/loading-interaction.js +26 -0
  24. package/dist/button/loading-interaction.js.map +1 -0
  25. package/dist/calendar/calendar.d.ts +3 -4
  26. package/dist/calendar/calendar.d.ts.map +1 -1
  27. package/dist/calendar/calendar.js +5 -2
  28. package/dist/calendar/calendar.js.map +1 -1
  29. package/dist/checkbox/checkbox.d.ts +2 -4
  30. package/dist/checkbox/checkbox.d.ts.map +1 -1
  31. package/dist/checkbox/checkbox.js +4 -2
  32. package/dist/checkbox/checkbox.js.map +1 -1
  33. package/dist/combobox/combobox.d.ts +3 -3
  34. package/dist/combobox/combobox.d.ts.map +1 -1
  35. package/dist/combobox/combobox.js +5 -2
  36. package/dist/combobox/combobox.js.map +1 -1
  37. package/dist/dialog/dialog.d.ts +3 -4
  38. package/dist/dialog/dialog.d.ts.map +1 -1
  39. package/dist/dialog/dialog.js +4 -2
  40. package/dist/dialog/dialog.js.map +1 -1
  41. package/dist/fallback-glyphs.js +3 -3
  42. package/dist/fallback-glyphs.js.map +1 -1
  43. package/dist/icon-defaults.d.ts +45 -0
  44. package/dist/icon-defaults.d.ts.map +1 -0
  45. package/dist/icon-defaults.js +43 -0
  46. package/dist/icon-defaults.js.map +1 -0
  47. package/dist/index.d.ts +3 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +3 -0
  50. package/dist/index.js.map +1 -1
  51. package/dist/menu/action-menu.d.ts +3 -3
  52. package/dist/menu/action-menu.d.ts.map +1 -1
  53. package/dist/menu/action-menu.js +4 -2
  54. package/dist/menu/action-menu.js.map +1 -1
  55. package/dist/menu/menu.d.ts +5 -7
  56. package/dist/menu/menu.d.ts.map +1 -1
  57. package/dist/menu/menu.js +7 -3
  58. package/dist/menu/menu.js.map +1 -1
  59. package/dist/radio-group/index.d.ts +2 -0
  60. package/dist/radio-group/index.d.ts.map +1 -0
  61. package/dist/radio-group/index.js +2 -0
  62. package/dist/radio-group/index.js.map +1 -0
  63. package/dist/radio-group/radio-group.css +70 -0
  64. package/dist/radio-group/radio-group.css.d.ts +2 -0
  65. package/dist/radio-group/radio-group.d.ts +74 -0
  66. package/dist/radio-group/radio-group.d.ts.map +1 -0
  67. package/dist/radio-group/radio-group.js +57 -0
  68. package/dist/radio-group/radio-group.js.map +1 -0
  69. package/dist/select/select.d.ts +3 -3
  70. package/dist/select/select.d.ts.map +1 -1
  71. package/dist/select/select.js +5 -2
  72. package/dist/select/select.js.map +1 -1
  73. package/dist/sticky/sticky.css +13 -1
  74. package/dist/sticky/sticky.d.ts +8 -2
  75. package/dist/sticky/sticky.d.ts.map +1 -1
  76. package/dist/sticky/sticky.js +3 -3
  77. package/dist/sticky/sticky.js.map +1 -1
  78. package/package.json +18 -2
@@ -5,7 +5,7 @@ import { useEffect, useRef, useState } from 'react';
5
5
  import './calendar.css';
6
6
  import { IconButton } from '../button/icon-button';
7
7
  import { cx } from '../cx';
8
- import { ChevronLeft, ChevronRight } from '../fallback-glyphs';
8
+ import { useIconDefaults } from '../icon-defaults';
9
9
  import { parseIsoDate } from '../iso-date';
10
10
  const parseIso = (iso, prop) => parseIsoDate(iso, `Calendar: ${prop}`);
11
11
  const parseOptional = (iso, prop) => iso === undefined ? undefined : parseIso(iso, prop);
@@ -80,7 +80,10 @@ function useFocusedDay(chosen, fallback) {
80
80
  * <Calendar aria-label="Scheduled day" value={day} onValueChange={setDay} autoFocus />
81
81
  * ```
82
82
  */
83
- export function Calendar({ 'aria-label': ariaLabel, locale = 'en-GB', startOfWeek, min, max, defaultMonth, autoFocus = false, disabled, readOnly, previousIcon = ChevronLeft, nextIcon = ChevronRight, className, ...selection }) {
83
+ export function Calendar({ 'aria-label': ariaLabel, locale = 'en-GB', startOfWeek, min, max, defaultMonth, autoFocus = false, disabled, readOnly, previousIcon: previousIconProp, nextIcon: nextIconProp, className, ...selection }) {
84
+ const icons = useIconDefaults();
85
+ const previousIcon = previousIconProp ?? icons.chevronLeft;
86
+ const nextIcon = nextIconProp ?? icons.chevronRight;
84
87
  const rootRef = useRef(null);
85
88
  const controlledDates = toDateValues(selection, 'value');
86
89
  const initialDates = toDateValues(selection, 'defaultValue');
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../src/calendar/calendar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,IAAI,aAAa,EAAkB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OA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T,IAAI,EAAE,QAAQ,gBACH,YAAY,GACvB,GACwB,IACF,EAC5B,MAAC,aAAa,CAAC,KAAK,IAAC,SAAS,EAAC,oBAAoB,aACjD,KAAC,aAAa,CAAC,SAAS,cACtB,KAAC,aAAa,CAAC,QAAQ,cACpB,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAC7B,KAAC,aAAa,CAAC,WAAW,IAExB,SAAS,EAAC,sBAAsB,YAE/B,OAAO,CAAC,KAAK,IAHT,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAIH,CAC7B,CAAC,GACqB,GACD,EAC1B,KAAC,aAAa,CAAC,SAAS,cACrB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACvB,KAAC,aAAa,CAAC,QAAQ,cACpB,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjB,KAAC,aAAa,CAAC,SAAS,IAEtB,KAAK,EAAE,GAAG,EACV,SAAS,EAAC,mBAAmB,YAE7B,KAAC,aAAa,CAAC,gBAAgB,IAAC,SAAS,EAAC,kBAAkB,YAC1D,eAAM,SAAS,EAAC,uBAAuB,YAAE,GAAG,CAAC,GAAG,GAAQ,GACzB,IAN5B,GAAG,CAAC,QAAQ,EAAE,CAOK,CAC3B,CAAC,IAXyB,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAYvB,CAC1B,CAAC,GACsB,IACN,IACrB,CACJ,GACqB,GACL,GACC,GACL,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import { DatePicker as ArkDatePicker, type DateValue } from '@ark-ui/react/date-picker';\nimport { getLocalTimeZone, today } from '@internationalized/date';\nimport { useEffect, useRef, useState } from 'react';\nimport './calendar.css';\nimport { IconButton } from '../button/icon-button';\nimport { cx } from '../cx';\nimport { ChevronLeft, ChevronRight } from '../fallback-glyphs';\nimport type { IconSource } from '../icon/icon';\nimport { parseIsoDate } from '../iso-date';\n\n/**\n * A stretch of days. Both ends are ISO calendar dates, `YYYY-MM-DD`; `end`\n * is `null` while only the first day is chosen.\n */\nexport interface CalendarRange {\n start: string;\n end: string | null;\n}\n\n/** A day of the week as `Date#getDay()` counts them: 0 is Sunday, 1 is Monday. */\nexport type CalendarWeekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\ninterface CalendarCommonProps {\n /**\n * The calendar's name, saying which day is being chosen: \"Scheduled day\",\n * \"Target date\". A calendar has no label of its own, and the month heading\n * changes as the user pages.\n */\n 'aria-label': string;\n /**\n * BCP 47 tag that decides the month and weekday names and, unless\n * `startOfWeek` says otherwise, the first day of the week. Defaults to\n * `en-GB`: English names, Monday first. The products' own date format is\n * not involved; the grid shows day numbers only.\n */\n locale?: string;\n /** The first column, `0` for Sunday through `6` for Saturday. Defaults to the locale's. */\n startOfWeek?: CalendarWeekday;\n /**\n * The earliest day that can be chosen, `YYYY-MM-DD`. Earlier days are\n * shown but cannot be chosen; a value outside the window is still shown\n * as the value.\n */\n min?: string;\n /** The latest day that can be chosen, `YYYY-MM-DD`. */\n max?: string;\n /**\n * Any day of the month shown first when nothing is chosen yet,\n * `YYYY-MM-DD`. Defaults to the month of the chosen day, else this month.\n */\n defaultMonth?: string;\n /**\n * Moves focus to the chosen day (else the first day shown by\n * `defaultMonth`, else today) once the calendar is in the page. For a calendar opened in a popover, so\n * the arrow keys work at once and a screen reader lands on a day.\n */\n autoFocus?: boolean;\n /** Dims the calendar; nothing in it can be focused or chosen. */\n disabled?: boolean;\n /** Shows the days and the choice, pages freely, but lets nothing be chosen. */\n readOnly?: boolean;\n /**\n * Glyph for the \"previous month\" button. Defaults to a plain built-in\n * chevron so `@manakind/ui-core` renders on its own; products pass their\n * own icon set.\n */\n previousIcon?: IconSource;\n /** Glyph for the \"next month\" button. Same defaulting rule as {@link CalendarCommonProps.previousIcon}. */\n nextIcon?: IconSource;\n /** Extra class names appended after `ds-calendar`. */\n className?: string;\n}\n\ninterface CalendarSingleProps {\n /** One day at a time. The default. */\n selectionMode?: 'single';\n /** The chosen day, `YYYY-MM-DD`, or `null` for none. Leave undefined to let the calendar own it. */\n value?: string | null;\n /** The day chosen at first when uncontrolled, or `null` for none. */\n defaultValue?: string | null;\n /**\n * Fired with the ISO date of the day the user chose. Choosing the chosen\n * day again fires nothing, and the calendar never clears: a product that\n * lets the user unschedule does it with a control of its own.\n */\n onValueChange?: (value: string) => void;\n}\n\ninterface CalendarRangeProps {\n /**\n * A first and a last day. The first click chooses the first day and fires\n * with `end: null`; the second click chooses the last day, in either\n * order, and fires with both; a third click starts a new range.\n */\n selectionMode: 'range';\n /** The chosen range, or `null` for none. Leave undefined to let the calendar own it. */\n value?: CalendarRange | null;\n /** The range chosen at first when uncontrolled, or `null` for none. */\n defaultValue?: CalendarRange | null;\n /** Fired with the range so far: `end` is `null` after the first click of a new range. */\n onValueChange?: (value: CalendarRange) => void;\n}\n\ntype CalendarSelection = CalendarSingleProps | CalendarRangeProps;\n\nexport type CalendarProps = CalendarCommonProps & CalendarSelection;\n\nconst parseIso = (iso: string, prop: string): DateValue => parseIsoDate(iso, `Calendar: ${prop}`);\n\nconst parseOptional = (iso: string | undefined, prop: string): DateValue | undefined =>\n iso === undefined ? undefined : parseIso(iso, prop);\n\n/*\n * Zag keeps every selection as a list of dates: one for a day, up to two\n * for a range. The product's typed shape is folded into that list on the\n * way in and rebuilt on the way out.\n */\nfunction toDateValues(\n selection: CalendarSelection,\n prop: 'value' | 'defaultValue',\n): DateValue[] | undefined {\n const given = selection[prop];\n if (given === undefined) return undefined;\n if (given === null) return [];\n if (typeof given === 'string') return [parseIso(given, prop)];\n const dates = [parseIso(given.start, `${prop}.start`)];\n if (given.end !== null) dates.push(parseIso(given.end, `${prop}.end`));\n return dates;\n}\n\n/*\n * Zag's list can be sparse: a range cleared from outside between its two\n * clicks keeps Zag waiting for an end date, and the next click lands at\n * index 1 of an empty list. The dates that are there are the selection.\n */\nfunction report(selection: CalendarSelection, dates: DateValue[]): void {\n const [start, end] = dates.filter((date) => date !== undefined);\n if (!start) return;\n if (selection.selectionMode === 'range') {\n selection.onValueChange?.({ start: start.toString(), end: end?.toString() ?? null });\n return;\n }\n selection.onValueChange?.(start.toString());\n}\n\n/*\n * The day Zag's keyboard focus and the shown month follow. Zag moves it on\n * its own events only, so a value the parent changes to another month\n * would leave the grid on the old one: the calendar owns it, and moves it\n * to the chosen day whenever the parent chooses a new one.\n */\nfunction useFocusedDay(chosen: DateValue | undefined, fallback: DateValue | undefined) {\n const chosenKey = chosen?.toString();\n const [focused, setFocused] = useState(() => ({\n key: chosenKey,\n day: chosen ?? fallback ?? today(getLocalTimeZone()),\n }));\n if (chosenKey !== focused.key) {\n setFocused({ key: chosenKey, day: chosen ?? focused.day });\n }\n const setDay = (day: DateValue) => setFocused((state) => ({ ...state, day }));\n return [focused.day, setDay] as const;\n}\n\n/**\n * A month of days to choose from, built on Ark UI's DatePicker.\n *\n * The grid shows one month at a time with the weekdays across the top and\n * a button pair to turn the page; the days of the neighbouring months fill\n * the first and last rows, and every month has six rows, so the calendar\n * keeps its height as the user pages. One day is chosen at a time, or a\n * first and a last day with `selectionMode=\"range\"`. The value in and out is\n * an ISO calendar date, `YYYY-MM-DD`, as `DateInput` gives: a string a form\n * library and a database both keep as is, with no time zone to get wrong.\n *\n * It is the grid alone. A product puts it in a `Popover` behind a button\n * that shows the choice, or in the page, and gives it `aria-label`; the\n * labels the grid speaks (\"Choose Wednesday 12 June 2024\", \"Previous month\")\n * are English, as Ark's are.\n *\n * ```tsx\n * <Calendar aria-label=\"Scheduled day\" value={day} onValueChange={setDay} autoFocus />\n * ```\n */\nexport function Calendar({\n 'aria-label': ariaLabel,\n locale = 'en-GB',\n startOfWeek,\n min,\n max,\n defaultMonth,\n autoFocus = false,\n disabled,\n readOnly,\n previousIcon = ChevronLeft,\n nextIcon = ChevronRight,\n className,\n ...selection\n}: CalendarProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n const controlledDates = toDateValues(selection, 'value');\n const initialDates = toDateValues(selection, 'defaultValue');\n const [focusedDay, setFocusedDay] = useFocusedDay(\n controlledDates?.[0] ?? initialDates?.[0],\n parseOptional(defaultMonth, 'defaultMonth'),\n );\n const minDate = parseOptional(min, 'min');\n const maxDate = parseOptional(max, 'max');\n\n /*\n * Passed as unavailable days rather than Zag's own `min`/`max`, which clamp\n * a value outside them to the nearest allowed day and show that day as\n * chosen while the parent holds another. Unavailable days are disabled and\n * cannot be chosen, and a value outside the window stays the value.\n */\n const isOutsideWindow = (date: DateValue) =>\n (minDate !== undefined && date.compare(minDate) < 0) ||\n (maxDate !== undefined && date.compare(maxDate) > 0);\n\n /*\n * Zag gives the focused day `tabindex=\"0\"` and every other day `-1`; the\n * one day in the tab order is the one to land on. An effect, because the\n * focus is the browser's.\n */\n useEffect(() => {\n if (!autoFocus) return;\n rootRef.current\n ?.querySelector<HTMLElement>('[data-part=\"table-cell-trigger\"][tabindex=\"0\"]')\n ?.focus({ preventScroll: true });\n }, [autoFocus]);\n\n return (\n <ArkDatePicker.Root\n ref={rootRef}\n className={cx('ds-calendar', className)}\n inline\n closeOnSelect={false}\n fixedWeeks\n outsideDaySelectable\n selectionMode={selection.selectionMode ?? 'single'}\n value={controlledDates}\n defaultValue={initialDates}\n onValueChange={(details) => report(selection, details.value)}\n focusedValue={focusedDay}\n onFocusChange={(details) => setFocusedDay(details.focusedValue)}\n isDateUnavailable={minDate || maxDate ? isOutsideWindow : undefined}\n locale={locale}\n timeZone={getLocalTimeZone()}\n startOfWeek={startOfWeek}\n disabled={disabled}\n readOnly={readOnly}\n >\n <ArkDatePicker.Content\n className=\"ds-calendar__content\"\n aria-label={ariaLabel}\n aria-disabled={disabled || undefined}\n >\n <ArkDatePicker.View view=\"day\">\n <ArkDatePicker.Context>\n {(api) => (\n <>\n <ArkDatePicker.ViewControl className=\"ds-calendar__header\">\n <ArkDatePicker.PrevTrigger asChild>\n <IconButton\n variant=\"tertiary\"\n size=\"sm\"\n icon={previousIcon}\n aria-label=\"Previous month\"\n />\n </ArkDatePicker.PrevTrigger>\n <ArkDatePicker.RangeText className=\"ds-calendar__heading\" aria-live=\"polite\" />\n <ArkDatePicker.NextTrigger asChild>\n <IconButton\n variant=\"tertiary\"\n size=\"sm\"\n icon={nextIcon}\n aria-label=\"Next month\"\n />\n </ArkDatePicker.NextTrigger>\n </ArkDatePicker.ViewControl>\n <ArkDatePicker.Table className=\"ds-calendar__table\">\n <ArkDatePicker.TableHead>\n <ArkDatePicker.TableRow>\n {api.weekDays.map((weekDay) => (\n <ArkDatePicker.TableHeader\n key={weekDay.value.toString()}\n className=\"ds-calendar__weekday\"\n >\n {weekDay.short}\n </ArkDatePicker.TableHeader>\n ))}\n </ArkDatePicker.TableRow>\n </ArkDatePicker.TableHead>\n <ArkDatePicker.TableBody>\n {api.weeks.map((week) => (\n <ArkDatePicker.TableRow key={week[0]?.toString()}>\n {week.map((day) => (\n <ArkDatePicker.TableCell\n key={day.toString()}\n value={day}\n className=\"ds-calendar__cell\"\n >\n <ArkDatePicker.TableCellTrigger className=\"ds-calendar__day\">\n <span className=\"ds-calendar__day-fill\">{day.day}</span>\n </ArkDatePicker.TableCellTrigger>\n </ArkDatePicker.TableCell>\n ))}\n </ArkDatePicker.TableRow>\n ))}\n </ArkDatePicker.TableBody>\n </ArkDatePicker.Table>\n </>\n )}\n </ArkDatePicker.Context>\n </ArkDatePicker.View>\n </ArkDatePicker.Content>\n </ArkDatePicker.Root>\n );\n}\n"]}
1
+ {"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../src/calendar/calendar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,IAAI,aAAa,EAAkB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,gBAAgB,CAAC;A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ACL,CACtB,CAAC;AACJ,CAAC","sourcesContent":["import { DatePicker as ArkDatePicker, type DateValue } from '@ark-ui/react/date-picker';\nimport { getLocalTimeZone, today } from '@internationalized/date';\nimport { useEffect, useRef, useState } from 'react';\nimport './calendar.css';\nimport { IconButton } from '../button/icon-button';\nimport { cx } from '../cx';\nimport type { IconSource } from '../icon/icon';\nimport { useIconDefaults } from '../icon-defaults';\nimport { parseIsoDate } from '../iso-date';\n\n/**\n * A stretch of days. Both ends are ISO calendar dates, `YYYY-MM-DD`; `end`\n * is `null` while only the first day is chosen.\n */\nexport interface CalendarRange {\n start: string;\n end: string | null;\n}\n\n/** A day of the week as `Date#getDay()` counts them: 0 is Sunday, 1 is Monday. */\nexport type CalendarWeekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\ninterface CalendarCommonProps {\n /**\n * The calendar's name, saying which day is being chosen: \"Scheduled day\",\n * \"Target date\". A calendar has no label of its own, and the month heading\n * changes as the user pages.\n */\n 'aria-label': string;\n /**\n * BCP 47 tag that decides the month and weekday names and, unless\n * `startOfWeek` says otherwise, the first day of the week. Defaults to\n * `en-GB`: English names, Monday first. The products' own date format is\n * not involved; the grid shows day numbers only.\n */\n locale?: string;\n /** The first column, `0` for Sunday through `6` for Saturday. Defaults to the locale's. */\n startOfWeek?: CalendarWeekday;\n /**\n * The earliest day that can be chosen, `YYYY-MM-DD`. Earlier days are\n * shown but cannot be chosen; a value outside the window is still shown\n * as the value.\n */\n min?: string;\n /** The latest day that can be chosen, `YYYY-MM-DD`. */\n max?: string;\n /**\n * Any day of the month shown first when nothing is chosen yet,\n * `YYYY-MM-DD`. Defaults to the month of the chosen day, else this month.\n */\n defaultMonth?: string;\n /**\n * Moves focus to the chosen day (else the first day shown by\n * `defaultMonth`, else today) once the calendar is in the page. For a calendar opened in a popover, so\n * the arrow keys work at once and a screen reader lands on a day.\n */\n autoFocus?: boolean;\n /** Dims the calendar; nothing in it can be focused or chosen. */\n disabled?: boolean;\n /** Shows the days and the choice, pages freely, but lets nothing be chosen. */\n readOnly?: boolean;\n /**\n * Glyph for the \"previous month\" button. Defaults to the\n * `IconDefaultsProvider`'s `chevronLeft`, or a plain built-in one.\n */\n previousIcon?: IconSource;\n /** Glyph for the \"next month\" button. Same defaulting rule as {@link CalendarCommonProps.previousIcon}. */\n nextIcon?: IconSource;\n /** Extra class names appended after `ds-calendar`. */\n className?: string;\n}\n\ninterface CalendarSingleProps {\n /** One day at a time. The default. */\n selectionMode?: 'single';\n /** The chosen day, `YYYY-MM-DD`, or `null` for none. Leave undefined to let the calendar own it. */\n value?: string | null;\n /** The day chosen at first when uncontrolled, or `null` for none. */\n defaultValue?: string | null;\n /**\n * Fired with the ISO date of the day the user chose. Choosing the chosen\n * day again fires nothing, and the calendar never clears: a product that\n * lets the user unschedule does it with a control of its own.\n */\n onValueChange?: (value: string) => void;\n}\n\ninterface CalendarRangeProps {\n /**\n * A first and a last day. The first click chooses the first day and fires\n * with `end: null`; the second click chooses the last day, in either\n * order, and fires with both; a third click starts a new range.\n */\n selectionMode: 'range';\n /** The chosen range, or `null` for none. Leave undefined to let the calendar own it. */\n value?: CalendarRange | null;\n /** The range chosen at first when uncontrolled, or `null` for none. */\n defaultValue?: CalendarRange | null;\n /** Fired with the range so far: `end` is `null` after the first click of a new range. */\n onValueChange?: (value: CalendarRange) => void;\n}\n\ntype CalendarSelection = CalendarSingleProps | CalendarRangeProps;\n\nexport type CalendarProps = CalendarCommonProps & CalendarSelection;\n\nconst parseIso = (iso: string, prop: string): DateValue => parseIsoDate(iso, `Calendar: ${prop}`);\n\nconst parseOptional = (iso: string | undefined, prop: string): DateValue | undefined =>\n iso === undefined ? undefined : parseIso(iso, prop);\n\n/*\n * Zag keeps every selection as a list of dates: one for a day, up to two\n * for a range. The product's typed shape is folded into that list on the\n * way in and rebuilt on the way out.\n */\nfunction toDateValues(\n selection: CalendarSelection,\n prop: 'value' | 'defaultValue',\n): DateValue[] | undefined {\n const given = selection[prop];\n if (given === undefined) return undefined;\n if (given === null) return [];\n if (typeof given === 'string') return [parseIso(given, prop)];\n const dates = [parseIso(given.start, `${prop}.start`)];\n if (given.end !== null) dates.push(parseIso(given.end, `${prop}.end`));\n return dates;\n}\n\n/*\n * Zag's list can be sparse: a range cleared from outside between its two\n * clicks keeps Zag waiting for an end date, and the next click lands at\n * index 1 of an empty list. The dates that are there are the selection.\n */\nfunction report(selection: CalendarSelection, dates: DateValue[]): void {\n const [start, end] = dates.filter((date) => date !== undefined);\n if (!start) return;\n if (selection.selectionMode === 'range') {\n selection.onValueChange?.({ start: start.toString(), end: end?.toString() ?? null });\n return;\n }\n selection.onValueChange?.(start.toString());\n}\n\n/*\n * The day Zag's keyboard focus and the shown month follow. Zag moves it on\n * its own events only, so a value the parent changes to another month\n * would leave the grid on the old one: the calendar owns it, and moves it\n * to the chosen day whenever the parent chooses a new one.\n */\nfunction useFocusedDay(chosen: DateValue | undefined, fallback: DateValue | undefined) {\n const chosenKey = chosen?.toString();\n const [focused, setFocused] = useState(() => ({\n key: chosenKey,\n day: chosen ?? fallback ?? today(getLocalTimeZone()),\n }));\n if (chosenKey !== focused.key) {\n setFocused({ key: chosenKey, day: chosen ?? focused.day });\n }\n const setDay = (day: DateValue) => setFocused((state) => ({ ...state, day }));\n return [focused.day, setDay] as const;\n}\n\n/**\n * A month of days to choose from, built on Ark UI's DatePicker.\n *\n * The grid shows one month at a time with the weekdays across the top and\n * a button pair to turn the page; the days of the neighbouring months fill\n * the first and last rows, and every month has six rows, so the calendar\n * keeps its height as the user pages. One day is chosen at a time, or a\n * first and a last day with `selectionMode=\"range\"`. The value in and out is\n * an ISO calendar date, `YYYY-MM-DD`, as `DateInput` gives: a string a form\n * library and a database both keep as is, with no time zone to get wrong.\n *\n * It is the grid alone. A product puts it in a `Popover` behind a button\n * that shows the choice, or in the page, and gives it `aria-label`; the\n * labels the grid speaks (\"Choose Wednesday 12 June 2024\", \"Previous month\")\n * are English, as Ark's are.\n *\n * ```tsx\n * <Calendar aria-label=\"Scheduled day\" value={day} onValueChange={setDay} autoFocus />\n * ```\n */\nexport function Calendar({\n 'aria-label': ariaLabel,\n locale = 'en-GB',\n startOfWeek,\n min,\n max,\n defaultMonth,\n autoFocus = false,\n disabled,\n readOnly,\n previousIcon: previousIconProp,\n nextIcon: nextIconProp,\n className,\n ...selection\n}: CalendarProps) {\n const icons = useIconDefaults();\n const previousIcon = previousIconProp ?? icons.chevronLeft;\n const nextIcon = nextIconProp ?? icons.chevronRight;\n const rootRef = useRef<HTMLDivElement>(null);\n const controlledDates = toDateValues(selection, 'value');\n const initialDates = toDateValues(selection, 'defaultValue');\n const [focusedDay, setFocusedDay] = useFocusedDay(\n controlledDates?.[0] ?? initialDates?.[0],\n parseOptional(defaultMonth, 'defaultMonth'),\n );\n const minDate = parseOptional(min, 'min');\n const maxDate = parseOptional(max, 'max');\n\n /*\n * Passed as unavailable days rather than Zag's own `min`/`max`, which clamp\n * a value outside them to the nearest allowed day and show that day as\n * chosen while the parent holds another. Unavailable days are disabled and\n * cannot be chosen, and a value outside the window stays the value.\n */\n const isOutsideWindow = (date: DateValue) =>\n (minDate !== undefined && date.compare(minDate) < 0) ||\n (maxDate !== undefined && date.compare(maxDate) > 0);\n\n /*\n * Zag gives the focused day `tabindex=\"0\"` and every other day `-1`; the\n * one day in the tab order is the one to land on. An effect, because the\n * focus is the browser's.\n */\n useEffect(() => {\n if (!autoFocus) return;\n rootRef.current\n ?.querySelector<HTMLElement>('[data-part=\"table-cell-trigger\"][tabindex=\"0\"]')\n ?.focus({ preventScroll: true });\n }, [autoFocus]);\n\n return (\n <ArkDatePicker.Root\n ref={rootRef}\n className={cx('ds-calendar', className)}\n inline\n closeOnSelect={false}\n fixedWeeks\n outsideDaySelectable\n selectionMode={selection.selectionMode ?? 'single'}\n value={controlledDates}\n defaultValue={initialDates}\n onValueChange={(details) => report(selection, details.value)}\n focusedValue={focusedDay}\n onFocusChange={(details) => setFocusedDay(details.focusedValue)}\n isDateUnavailable={minDate || maxDate ? isOutsideWindow : undefined}\n locale={locale}\n timeZone={getLocalTimeZone()}\n startOfWeek={startOfWeek}\n disabled={disabled}\n readOnly={readOnly}\n >\n <ArkDatePicker.Content\n className=\"ds-calendar__content\"\n aria-label={ariaLabel}\n aria-disabled={disabled || undefined}\n >\n <ArkDatePicker.View view=\"day\">\n <ArkDatePicker.Context>\n {(api) => (\n <>\n <ArkDatePicker.ViewControl className=\"ds-calendar__header\">\n <ArkDatePicker.PrevTrigger asChild>\n <IconButton\n variant=\"tertiary\"\n size=\"sm\"\n icon={previousIcon}\n aria-label=\"Previous month\"\n />\n </ArkDatePicker.PrevTrigger>\n <ArkDatePicker.RangeText className=\"ds-calendar__heading\" aria-live=\"polite\" />\n <ArkDatePicker.NextTrigger asChild>\n <IconButton\n variant=\"tertiary\"\n size=\"sm\"\n icon={nextIcon}\n aria-label=\"Next month\"\n />\n </ArkDatePicker.NextTrigger>\n </ArkDatePicker.ViewControl>\n <ArkDatePicker.Table className=\"ds-calendar__table\">\n <ArkDatePicker.TableHead>\n <ArkDatePicker.TableRow>\n {api.weekDays.map((weekDay) => (\n <ArkDatePicker.TableHeader\n key={weekDay.value.toString()}\n className=\"ds-calendar__weekday\"\n >\n {weekDay.short}\n </ArkDatePicker.TableHeader>\n ))}\n </ArkDatePicker.TableRow>\n </ArkDatePicker.TableHead>\n <ArkDatePicker.TableBody>\n {api.weeks.map((week) => (\n <ArkDatePicker.TableRow key={week[0]?.toString()}>\n {week.map((day) => (\n <ArkDatePicker.TableCell\n key={day.toString()}\n value={day}\n className=\"ds-calendar__cell\"\n >\n <ArkDatePicker.TableCellTrigger className=\"ds-calendar__day\">\n <span className=\"ds-calendar__day-fill\">{day.day}</span>\n </ArkDatePicker.TableCellTrigger>\n </ArkDatePicker.TableCell>\n ))}\n </ArkDatePicker.TableRow>\n ))}\n </ArkDatePicker.TableBody>\n </ArkDatePicker.Table>\n </>\n )}\n </ArkDatePicker.Context>\n </ArkDatePicker.View>\n </ArkDatePicker.Content>\n </ArkDatePicker.Root>\n );\n}\n"]}
@@ -51,9 +51,7 @@ export type CheckboxProps = CheckboxName & {
51
51
  /**
52
52
  * Glyph shown in the box while checked.
53
53
  *
54
- * Defaults to a plain built-in check so `@manakind/ui-core` installs and
55
- * renders on its own. Products override it with their own icon set, as
56
- * they do Select's `itemIndicator`.
54
+ * Defaults to the `IconDefaultsProvider`'s `check`, or a plain built-in one.
57
55
  */
58
56
  indicator?: IconSource;
59
57
  /** Extra class names appended after the `ds-checkbox` modifiers. */
@@ -76,6 +74,6 @@ export type CheckboxProps = CheckboxName & {
76
74
  * `Switch`; a choice between values of which exactly one applies is a
77
75
  * `Select`.
78
76
  */
79
- export declare function Checkbox({ label, checked, defaultChecked, onCheckedChange, size, disabled, invalid, readOnly, required, name, value, indicator, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
77
+ export declare function Checkbox({ label, checked, defaultChecked, onCheckedChange, size, disabled, invalid, readOnly, required, name, value, indicator: indicatorProp, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }: CheckboxProps): import("react/jsx-runtime").JSX.Element;
80
78
  export {};
81
79
  //# sourceMappingURL=checkbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/checkbox/checkbox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AACtD,OAAO,gBAAgB,CAAC;AAGxB,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C;;;;GAIG;AACH,KAAK,YAAY,GACb;IACE,0DAA0D;IAC1D,KAAK,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACD;IACE,KAAK,CAAC,EAAE,SAAS,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,EACd,eAAe,EACf,IAAW,EACX,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,SAAS,EAAE,aAAa,EACxB,SAAS,EACT,YAAY,EAAE,SAAS,EACvB,kBAAkB,EAAE,eAAe,GACpC,EAAE,aAAa,2CAkEf"}
@@ -3,8 +3,8 @@ import { Checkbox as ArkCheckbox } from '@ark-ui/react/checkbox';
3
3
  import { useId, useRef } from 'react';
4
4
  import './checkbox.css';
5
5
  import { cx } from '../cx';
6
- import { Check } from '../fallback-glyphs';
7
6
  import { Icon } from '../icon/icon';
7
+ import { useIconDefaults } from '../icon-defaults';
8
8
  /**
9
9
  * A choice that is saved with the form, built on Ark UI's Checkbox.
10
10
  *
@@ -22,7 +22,9 @@ import { Icon } from '../icon/icon';
22
22
  * `Switch`; a choice between values of which exactly one applies is a
23
23
  * `Select`.
24
24
  */
25
- export function Checkbox({ label, checked, defaultChecked, onCheckedChange, size = 'md', disabled, invalid, readOnly, required, name, value, indicator = Check, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }) {
25
+ export function Checkbox({ label, checked, defaultChecked, onCheckedChange, size = 'md', disabled, invalid, readOnly, required, name, value, indicator: indicatorProp, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, }) {
26
+ const icons = useIconDefaults();
27
+ const indicator = indicatorProp ?? icons.check;
26
28
  const inputRef = useRef(null);
27
29
  /*
28
30
  * Zag always names the hidden input by its label part's id, which would
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../src/checkbox/checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAkB,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EA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,EACV,KAAK,EAAE,KAAK,aAEZ,KAAC,WAAW,CAAC,OAAO,IAAC,SAAS,EAAC,sBAAsB,YACnD,KAAC,WAAW,CAAC,SAAS,IAAC,SAAS,EAAC,wBAAwB,YACvD,KAAC,IAAI,IAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,SAAG,GAC1B,GACJ,EACrB,KAAK;gBACJ,CAAC,SAAS,CAAC,CAAC,CAAC,CACX,eAAM,SAAS,EAAC,oBAAoB,YAAE,KAAK,GAAQ,CACpD,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,CAAC,KAAK,IAAC,SAAS,EAAC,oBAAoB,YAAE,KAAK,GAAqB,CAC9E,CAAC,EACJ,KAAC,WAAW,CAAC,WAAW,IACtB,GAAG,EAAE,QAAQ,gBACD,SAAS,sBACH,eAAe,mBAClB,QAAQ,IAAI,SAAS,GACpC,IACe,CACpB,CAAC;AACJ,CAAC","sourcesContent":["import { Checkbox as ArkCheckbox } from '@ark-ui/react/checkbox';\nimport { type ReactNode, useId, useRef } from 'react';\nimport './checkbox.css';\nimport { cx } from '../cx';\nimport { Check } from '../fallback-glyphs';\nimport { Icon, type IconSource } from '../icon/icon';\n\nexport type CheckboxSize = 'sm' | 'md' | 'lg';\n\n/**\n * A checkbox has to have a name. A visible `label` is the one to reach for:\n * the whole label is the click target. Expressed as a union so an unnamed\n * checkbox is a compile error rather than an axe finding, as `Switch` does.\n */\ntype CheckboxName =\n | {\n /** Visible label. The whole label is the click target. */\n label: ReactNode;\n /**\n * A different accessible name when the visible label alone would not\n * say what the control is. Keep the visible words in it, so a voice\n * user can still say what they see.\n */\n 'aria-label'?: string;\n }\n | {\n label?: undefined;\n /** Accessible name when no visible label fits, such as a row whose text already says what the checkbox is. */\n 'aria-label': string;\n };\n\nexport type CheckboxProps = CheckboxName & {\n /** Controlled checked state. Leave undefined to let the component own it. */\n checked?: boolean;\n /** Initial state when uncontrolled. */\n defaultChecked?: boolean;\n /** Fired with the new state whenever the user toggles the checkbox. */\n onCheckedChange?: (checked: boolean) => void;\n /** Control size and label type scale. */\n size?: CheckboxSize;\n /** Disable the control. It keeps its state and stops responding. */\n disabled?: boolean;\n /**\n * Marks the control invalid for assistive tech and styling (`data-invalid`).\n * Pair it with a message the control points at through `aria-describedby`;\n * a red border alone is not an accessible error.\n */\n invalid?: boolean;\n /** Id of the element that describes the control, such as an error message. */\n 'aria-describedby'?: string;\n /** Show the state without letting the user change it. */\n readOnly?: boolean;\n /** Marks the hidden input required for native form validation. */\n required?: boolean;\n /** Name for native form participation. */\n name?: string;\n /** Value submitted under `name` while checked. Defaults to `on`. */\n value?: string;\n /**\n * Glyph shown in the box while checked.\n *\n * Defaults to a plain built-in check so `@manakind/ui-core` installs and\n * renders on its own. Products override it with their own icon set, as\n * they do Select's `itemIndicator`.\n */\n indicator?: IconSource;\n /** Extra class names appended after the `ds-checkbox` modifiers. */\n className?: string;\n};\n\n/**\n * A choice that is saved with the form, built on Ark UI's Checkbox.\n *\n * Ark owns the behaviour: a hidden checkbox carries the state, the root is\n * the `<label>` that names it, and Space and pointer toggling come for free.\n * This wrapper contributes `ds-` classes, the `--ds-checkbox-*` bindings, a\n * flat prop API, and the check glyph.\n *\n * ```tsx\n * <Checkbox label=\"Health\" checked={chosen} onCheckedChange={setChosen} />\n * ```\n *\n * A checkbox is for a choice that is submitted later, alone or as one of\n * several that can all be on. A setting that takes effect at once is a\n * `Switch`; a choice between values of which exactly one applies is a\n * `Select`.\n */\nexport function Checkbox({\n label,\n checked,\n defaultChecked,\n onCheckedChange,\n size = 'md',\n disabled,\n invalid,\n readOnly,\n required,\n name,\n value,\n indicator = Check,\n className,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n}: CheckboxProps) {\n const inputRef = useRef<HTMLInputElement>(null);\n\n /*\n * Zag always names the hidden input by its label part's id, which would\n * outrank an `aria-label`. With both given, the visible label is plain\n * text instead, so that id resolves to nothing and the `aria-label` wins;\n * the root is still the `<label>`, so the text stays the click target.\n */\n\n /*\n * Ark hands a checkbox inside a Field the field's control and label ids,\n * so two checkboxes in one field would share an id and both be named by\n * the field's label. A checkbox names itself, so it keeps its own ids and\n * takes only the states from a field around it.\n */\n const ownId = useId();\n const ids = { hiddenInput: `${ownId}:input`, label: `${ownId}:label` };\n\n /*\n * Ark renders the hidden input uncontrolled and syncs it only when its own\n * state changes, so a controlled parent that declines a toggle would leave\n * the native input flipped while the box shows the old state. Restoring\n * the parent's value after Ark has read the input keeps the two agreeing,\n * as Switch does.\n */\n const handleCheckedChange = (details: { checked: boolean | 'indeterminate' }) => {\n onCheckedChange?.(details.checked === true);\n if (checked !== undefined && inputRef.current) inputRef.current.checked = checked;\n };\n\n return (\n <ArkCheckbox.Root\n ids={ids}\n className={cx('ds-checkbox', `ds-checkbox--${size}`, className)}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={handleCheckedChange}\n disabled={disabled}\n invalid={invalid}\n readOnly={readOnly}\n required={required}\n name={name}\n value={value}\n >\n <ArkCheckbox.Control className=\"ds-checkbox__control\">\n <ArkCheckbox.Indicator className=\"ds-checkbox__indicator\">\n <Icon source={indicator} size=\"sm\" decorative />\n </ArkCheckbox.Indicator>\n </ArkCheckbox.Control>\n {label &&\n (ariaLabel ? (\n <span className=\"ds-checkbox__label\">{label}</span>\n ) : (\n <ArkCheckbox.Label className=\"ds-checkbox__label\">{label}</ArkCheckbox.Label>\n ))}\n <ArkCheckbox.HiddenInput\n ref={inputRef}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n aria-readonly={readOnly || undefined}\n />\n </ArkCheckbox.Root>\n );\n}\n"]}
1
+ {"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../src/checkbox/checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAkB,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtD,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AE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,mBAAmB,EACpC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,aAEZ,KAAC,WAAW,CAAC,OAAO,IAAC,SAAS,EAAC,sBAAsB,YACnD,KAAC,WAAW,CAAC,SAAS,IAAC,SAAS,EAAC,wBAAwB,YACvD,KAAC,IAAI,IAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,SAAG,GAC1B,GACJ,EACrB,KAAK;gBACJ,CAAC,SAAS,CAAC,CAAC,CAAC,CACX,eAAM,SAAS,EAAC,oBAAoB,YAAE,KAAK,GAAQ,CACpD,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,CAAC,KAAK,IAAC,SAAS,EAAC,oBAAoB,YAAE,KAAK,GAAqB,CAC9E,CAAC,EACJ,KAAC,WAAW,CAAC,WAAW,IACtB,GAAG,EAAE,QAAQ,gBACD,SAAS,sBACH,eAAe,mBAClB,QAAQ,IAAI,SAAS,GACpC,IACe,CACpB,CAAC;AACJ,CAAC","sourcesContent":["import { Checkbox as ArkCheckbox } from '@ark-ui/react/checkbox';\nimport { type ReactNode, useId, useRef } from 'react';\nimport './checkbox.css';\nimport { cx } from '../cx';\nimport { Icon, type IconSource } from '../icon/icon';\nimport { useIconDefaults } from '../icon-defaults';\n\nexport type CheckboxSize = 'sm' | 'md' | 'lg';\n\n/**\n * A checkbox has to have a name. A visible `label` is the one to reach for:\n * the whole label is the click target. Expressed as a union so an unnamed\n * checkbox is a compile error rather than an axe finding, as `Switch` does.\n */\ntype CheckboxName =\n | {\n /** Visible label. The whole label is the click target. */\n label: ReactNode;\n /**\n * A different accessible name when the visible label alone would not\n * say what the control is. Keep the visible words in it, so a voice\n * user can still say what they see.\n */\n 'aria-label'?: string;\n }\n | {\n label?: undefined;\n /** Accessible name when no visible label fits, such as a row whose text already says what the checkbox is. */\n 'aria-label': string;\n };\n\nexport type CheckboxProps = CheckboxName & {\n /** Controlled checked state. Leave undefined to let the component own it. */\n checked?: boolean;\n /** Initial state when uncontrolled. */\n defaultChecked?: boolean;\n /** Fired with the new state whenever the user toggles the checkbox. */\n onCheckedChange?: (checked: boolean) => void;\n /** Control size and label type scale. */\n size?: CheckboxSize;\n /** Disable the control. It keeps its state and stops responding. */\n disabled?: boolean;\n /**\n * Marks the control invalid for assistive tech and styling (`data-invalid`).\n * Pair it with a message the control points at through `aria-describedby`;\n * a red border alone is not an accessible error.\n */\n invalid?: boolean;\n /** Id of the element that describes the control, such as an error message. */\n 'aria-describedby'?: string;\n /** Show the state without letting the user change it. */\n readOnly?: boolean;\n /** Marks the hidden input required for native form validation. */\n required?: boolean;\n /** Name for native form participation. */\n name?: string;\n /** Value submitted under `name` while checked. Defaults to `on`. */\n value?: string;\n /**\n * Glyph shown in the box while checked.\n *\n * Defaults to the `IconDefaultsProvider`'s `check`, or a plain built-in one.\n */\n indicator?: IconSource;\n /** Extra class names appended after the `ds-checkbox` modifiers. */\n className?: string;\n};\n\n/**\n * A choice that is saved with the form, built on Ark UI's Checkbox.\n *\n * Ark owns the behaviour: a hidden checkbox carries the state, the root is\n * the `<label>` that names it, and Space and pointer toggling come for free.\n * This wrapper contributes `ds-` classes, the `--ds-checkbox-*` bindings, a\n * flat prop API, and the check glyph.\n *\n * ```tsx\n * <Checkbox label=\"Health\" checked={chosen} onCheckedChange={setChosen} />\n * ```\n *\n * A checkbox is for a choice that is submitted later, alone or as one of\n * several that can all be on. A setting that takes effect at once is a\n * `Switch`; a choice between values of which exactly one applies is a\n * `Select`.\n */\nexport function Checkbox({\n label,\n checked,\n defaultChecked,\n onCheckedChange,\n size = 'md',\n disabled,\n invalid,\n readOnly,\n required,\n name,\n value,\n indicator: indicatorProp,\n className,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n}: CheckboxProps) {\n const icons = useIconDefaults();\n const indicator = indicatorProp ?? icons.check;\n const inputRef = useRef<HTMLInputElement>(null);\n\n /*\n * Zag always names the hidden input by its label part's id, which would\n * outrank an `aria-label`. With both given, the visible label is plain\n * text instead, so that id resolves to nothing and the `aria-label` wins;\n * the root is still the `<label>`, so the text stays the click target.\n */\n\n /*\n * Ark hands a checkbox inside a Field the field's control and label ids,\n * so two checkboxes in one field would share an id and both be named by\n * the field's label. A checkbox names itself, so it keeps its own ids and\n * takes only the states from a field around it.\n */\n const ownId = useId();\n const ids = { hiddenInput: `${ownId}:input`, label: `${ownId}:label` };\n\n /*\n * Ark renders the hidden input uncontrolled and syncs it only when its own\n * state changes, so a controlled parent that declines a toggle would leave\n * the native input flipped while the box shows the old state. Restoring\n * the parent's value after Ark has read the input keeps the two agreeing,\n * as Switch does.\n */\n const handleCheckedChange = (details: { checked: boolean | 'indeterminate' }) => {\n onCheckedChange?.(details.checked === true);\n if (checked !== undefined && inputRef.current) inputRef.current.checked = checked;\n };\n\n return (\n <ArkCheckbox.Root\n ids={ids}\n className={cx('ds-checkbox', `ds-checkbox--${size}`, className)}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={handleCheckedChange}\n disabled={disabled}\n invalid={invalid}\n readOnly={readOnly}\n required={required}\n name={name}\n value={value}\n >\n <ArkCheckbox.Control className=\"ds-checkbox__control\">\n <ArkCheckbox.Indicator className=\"ds-checkbox__indicator\">\n <Icon source={indicator} size=\"sm\" decorative />\n </ArkCheckbox.Indicator>\n </ArkCheckbox.Control>\n {label &&\n (ariaLabel ? (\n <span className=\"ds-checkbox__label\">{label}</span>\n ) : (\n <ArkCheckbox.Label className=\"ds-checkbox__label\">{label}</ArkCheckbox.Label>\n ))}\n <ArkCheckbox.HiddenInput\n ref={inputRef}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n aria-readonly={readOnly || undefined}\n />\n </ArkCheckbox.Root>\n );\n}\n"]}
@@ -93,9 +93,9 @@ export interface ComboboxProps {
93
93
  status?: ReactNode;
94
94
  /** Adds the facet column, with its pins. The list becomes a grid. */
95
95
  facets?: ComboboxFacets;
96
- /** Glyph of a row's pin. Defaults to the inlined fallback pin. */
96
+ /** Glyph of a row's pin. Defaults to the `IconDefaultsProvider`'s `pin`. */
97
97
  pinIcon?: IconSource;
98
- /** Glyph of the pinned chip's remove button. Defaults to the inlined fallback cross. */
98
+ /** Glyph of the pinned chip's remove button. Defaults to the `IconDefaultsProvider`'s `cross`. */
99
99
  removeIcon?: IconSource;
100
100
  /** Control height and type scale. */
101
101
  size?: ComboboxSize;
@@ -152,5 +152,5 @@ export interface ComboboxProps {
152
152
  * The field reads the `--ds-input-*` keys and the list the `--ds-select-*`
153
153
  * keys, so it reads as one family with `Input` and `Select`.
154
154
  */
155
- export declare function Combobox({ items, inputValue, onInputValueChange, onSelect, label, 'aria-label': ariaLabel, placeholder, emptyText, toolbar, status, facets, pinIcon, removeIcon, size, disabled, invalid, className, inputRef, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
155
+ export declare function Combobox({ items, inputValue, onInputValueChange, onSelect, label, 'aria-label': ariaLabel, placeholder, emptyText, toolbar, status, facets, pinIcon: pinIconProp, removeIcon: removeIconProp, size, disabled, invalid, className, inputRef, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
156
156
  //# sourceMappingURL=combobox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/combobox/combobox.tsx"],"names":[],"mappings":"AAGA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,GAAG,EAST,MAAM,OAAO,CAAC;AAKf,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,wCAAwC,CAAC;AAChD,OAAO,gBAAgB,CAAC;AAExB,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,sFAAsF;AACtF,MAAM,WAAW,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,SAAS,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,qEAAqE;IACrE,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,kGAAkG;IAClG,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,qCAAqC;IACrC,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gGAAgG;IAChG,QAAQ,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAClC;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,KAAK,EACL,YAAY,EAAE,SAAS,EACvB,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,MAAM,EACN,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,cAAc,EAC1B,IAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,QAAQ,GACT,EAAE,aAAa,2CAkVf"}
@@ -5,9 +5,9 @@ import { getTabbableEdges, getTabbables, isComposingEvent } from '@zag-js/dom-qu
5
5
  import { useCallback, useContext, useEffect, useId, useMemo, useRef, useState, } from 'react';
6
6
  import { flushSync } from 'react-dom';
7
7
  import { cx } from '../cx';
8
- import { Cross, Pin } from '../fallback-glyphs';
9
8
  import { groupItems } from '../group-items';
10
9
  import { Icon } from '../icon/icon';
10
+ import { useIconDefaults } from '../icon-defaults';
11
11
  import { PortalContainerContext } from '../portal-container';
12
12
  import { Tooltip } from '../tooltip/tooltip';
13
13
  import '../visually-hidden/visually-hidden.css';
@@ -58,7 +58,10 @@ const HEADER_CONTROLS = 'button, input, label, a[href], [tabindex]:not([tabindex
58
58
  * The field reads the `--ds-input-*` keys and the list the `--ds-select-*`
59
59
  * keys, so it reads as one family with `Input` and `Select`.
60
60
  */
61
- export function Combobox({ items, inputValue, onInputValueChange, onSelect, label, 'aria-label': ariaLabel, placeholder, emptyText, toolbar, status, facets, pinIcon = Pin, removeIcon = Cross, size = 'md', disabled, invalid, className, inputRef, }) {
61
+ export function Combobox({ items, inputValue, onInputValueChange, onSelect, label, 'aria-label': ariaLabel, placeholder, emptyText, toolbar, status, facets, pinIcon: pinIconProp, removeIcon: removeIconProp, size = 'md', disabled, invalid, className, inputRef, }) {
62
+ const icons = useIconDefaults();
63
+ const pinIcon = pinIconProp ?? icons.pin;
64
+ const removeIcon = removeIconProp ?? icons.cross;
62
65
  const id = useId();
63
66
  const inputId = `${id}-input`;
64
67
  const labelId = `${id}-label`;
@@ -1 +1 @@
1
- {"version":3,"file":"combobox.js","sourceRoot":"","sources":["../../src/combobox/combobox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAQL,WAAW,EACX,UAAU,EACV,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,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,IAAI,IAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,SAAG,GAC1C,GACD,IACL,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { Popover as ArkPopover } from '@ark-ui/react/popover';\nimport { Portal } from '@ark-ui/react/portal';\nimport { getTabbableEdges, getTabbables, isComposingEvent } from '@zag-js/dom-query';\nimport {\n type ChangeEvent,\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n type Ref,\n type TdHTMLAttributes,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { flushSync } from 'react-dom';\nimport { cx } from '../cx';\nimport { Cross, Pin } from '../fallback-glyphs';\nimport { groupItems } from '../group-items';\nimport { Icon, type IconSource } from '../icon/icon';\nimport { PortalContainerContext } from '../portal-container';\nimport { Tooltip } from '../tooltip/tooltip';\nimport '../visually-hidden/visually-hidden.css';\nimport './combobox.css';\n\nexport type ComboboxSize = 'sm' | 'md' | 'lg';\n\n/** What an option belongs to, shown in a second column: its category, its project. */\nexport interface ComboboxFacet {\n /** Stable value reported when the facet is pinned. */\n value: string;\n /** Text in the facet column, and in the pinned chip. */\n label: string;\n /** Decorative mark before the label, such as the category's icon. */\n icon?: ReactNode;\n}\n\nexport interface ComboboxItem {\n /** Stable value reported by `onSelect`. */\n value: string;\n /** Option text, also what screen readers use. */\n label: string;\n /** Optional secondary line under the label, shown muted. */\n description?: string;\n /** Individually disable this option without removing it. */\n disabled?: boolean;\n /**\n * The group the option is listed under, by its heading. Options sharing a\n * group are listed together under it, groups in the order they first\n * appear; options without one (or with an empty name) are listed before\n * any group.\n */\n group?: string;\n /** What the option belongs to, shown in the facet column when `facets` is set. */\n facet?: ComboboxFacet;\n}\n\n/**\n * A second column naming what each option belongs to, with a pin that\n * narrows the list to it.\n */\nexport interface ComboboxFacets {\n /** Heading of the option column, for assistive tech: \"Action\". */\n itemLabel: string;\n /** Heading of the facet column, for assistive tech: \"Category\". */\n label: string;\n /** The facet the list is narrowed to, shown as a removable chip in the status line. */\n pinned?: ComboboxFacet | null;\n /**\n * Pins a row's facet, or unpins it with `null` (its pin pressed again, the\n * chip's remove button, or Backspace in the empty field). The caller does\n * the narrowing. Without it, the facet column shows no pins.\n */\n onPinnedChange?: (facet: ComboboxFacet | null) => void;\n}\n\nexport interface ComboboxProps {\n /**\n * Suggestions for the current text.\n *\n * The caller filters, sorts and groups them; the component does not. What\n * counts as a match (a prefix, a substring, a category's name, anything\n * not already chosen) is the product's call, and the list it passes is the\n * list that shows.\n */\n items: ComboboxItem[];\n /** Controlled text in the input. */\n inputValue: string;\n /** Fired with the new text on every keystroke, and with `''` after a choice. */\n onInputValueChange: (value: string) => void;\n /**\n * A suggestion was chosen. The input then clears (`onInputValueChange('')`)\n * and the field holds no value: this is the \"add to a list\" pattern. A\n * field that keeps its choice is a `Select`.\n */\n onSelect: (value: string) => void;\n /**\n * Visible label. Strongly preferred over `aria-label` — a visible label\n * helps everyone, not only screen reader users.\n */\n label?: ReactNode;\n /** Accessible name when no visible `label` is supplied. */\n 'aria-label'?: string;\n /** Text shown in the empty input. */\n placeholder?: string;\n /** Shown in the open list when `items` is empty. */\n emptyText?: ReactNode;\n /**\n * Controls at the top of the open list that change what it shows: a\n * `Switch`, a small `SegmentGroup`. One row of them, so the options stay\n * in view; Tab moves into them from the field.\n */\n toolbar?: ReactNode;\n /**\n * One line under the toolbar saying what the list shows, such as \"Showing\n * all actions in Health\". Announced politely as it changes.\n */\n status?: ReactNode;\n /** Adds the facet column, with its pins. The list becomes a grid. */\n facets?: ComboboxFacets;\n /** Glyph of a row's pin. Defaults to the inlined fallback pin. */\n pinIcon?: IconSource;\n /** Glyph of the pinned chip's remove button. Defaults to the inlined fallback cross. */\n removeIcon?: IconSource;\n /** Control height and type scale. */\n size?: ComboboxSize;\n /** Disable the whole control. */\n disabled?: boolean;\n /** Marks the field invalid for assistive tech and styling. */\n invalid?: boolean;\n /** Extra class names appended after `ds-combobox` modifiers. */\n className?: string;\n /** The text input, for moving focus back to the field, e.g. after removing an item it added. */\n inputRef?: Ref<HTMLInputElement>;\n}\n\ntype Cell = 'item' | 'facet';\n\ninterface Active {\n value: string;\n cell: Cell;\n}\n\n// The header's own controls, which a press may focus.\nconst HEADER_CONTROLS = 'button, input, label, a[href], [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * A text input that suggests options as you type, with optional controls at\n * the top of the open list.\n *\n * Choosing a suggestion reports it through `onSelect` and empties the input,\n * so the field is ready for the next one: the control for adding items to a\n * list one at a time. It never holds a selection itself; the caller keeps\n * the list. For a field that keeps one choice, use `Select`.\n *\n * The open list can carry what narrows it, so nothing sits outside the\n * field: a `toolbar` row of switches or a segment group, a `status` line\n * saying what is shown, and with `facets` a second column naming what each\n * option belongs to, whose pin narrows the list to it.\n *\n * ```tsx\n * <Combobox\n * label=\"Add actions\"\n * items={matches}\n * inputValue={query}\n * onInputValueChange={setQuery}\n * onSelect={(value) => setPicked((list) => [...list, value])}\n * toolbar={<Switch size=\"sm\" label=\"Include categories\" checked={…} onCheckedChange={…} />}\n * status={`Showing all actions that contain “${query}”`}\n * facets={{ itemLabel: 'Action', label: 'Category', pinned, onPinnedChange: setPinned }}\n * />\n * ```\n *\n * The field is the APG editable combobox. Focus stays in the input, and the\n * active option is `aria-activedescendant`. Typing highlights the first\n * option, so Enter takes it, and Up and Down walk the options in their drawn\n * order. With `facets` the popup is a grid instead of a listbox: Right, at\n * the end of the text, moves onto the row's pin and Enter then pins it, and\n * Left moves back. Tab moves from the field into the toolbar and the chip,\n * and on out to the next field.\n *\n * The popup is an Ark Popover anchored to the field, so it takes part in\n * the dismiss stack. Escape closes it before a `Dialog` around it, and a\n * click outside closes it. Its wrapper drops the Popover's dialog role, so\n * the listbox or grid inside is the popup assistive tech meets. It portals\n * like `Select`'s list: into `<body>`, or into the panel of the ui-core\n * `Dialog` it opens in, at `z-index: 60`.\n * The field reads the `--ds-input-*` keys and the list the `--ds-select-*`\n * keys, so it reads as one family with `Input` and `Select`.\n */\nexport function Combobox({\n items,\n inputValue,\n onInputValueChange,\n onSelect,\n label,\n 'aria-label': ariaLabel,\n placeholder,\n emptyText,\n toolbar,\n status,\n facets,\n pinIcon = Pin,\n removeIcon = Cross,\n size = 'md',\n disabled,\n invalid,\n className,\n inputRef,\n}: ComboboxProps) {\n const id = useId();\n const inputId = `${id}-input`;\n const labelId = `${id}-label`;\n const listId = `${id}-list`;\n const statusId = `${id}-status`;\n const rowId = (index: number) => `${id}-row-${index}`;\n const cellId = (index: number, cell: Cell) => `${id}-cell-${index}-${cell}`;\n\n const rootRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const inputEl = useRef<HTMLInputElement | null>(null);\n const portalContainer = useContext(PortalContainerContext);\n\n const [open, setOpen] = useState(false);\n const [chosen, setChosen] = useState<Active | null>(null);\n const isOpen = open && !disabled;\n const isGrid = facets !== undefined;\n const pinned = facets?.pinned ?? null;\n const canPin = (item: ComboboxItem) => Boolean(facets?.onPinnedChange && item.facet);\n\n const groups = useMemo(() => groupItems(items), [items]);\n const ordered = useMemo(() => groups.flatMap((group) => group.items), [groups]);\n const navigable = useMemo(() => ordered.filter((item) => !item.disabled), [ordered]);\n\n const chosenItem = chosen && navigable.find((item) => item.value === chosen.value);\n const active: Active | null = chosenItem\n ? {\n value: chosenItem.value,\n cell: chosen?.cell === 'facet' && canPin(chosenItem) ? 'facet' : 'item',\n }\n : inputValue !== '' && navigable[0]\n ? { value: navigable[0].value, cell: 'item' }\n : null;\n const activeIndex = active ? ordered.findIndex((item) => item.value === active.value) : -1;\n const activeDescendant =\n isOpen && active && activeIndex >= 0\n ? isGrid\n ? cellId(activeIndex, active.cell)\n : rowId(activeIndex)\n : undefined;\n\n const setInputRef = useCallback(\n (element: HTMLInputElement | null) => {\n inputEl.current = element;\n if (typeof inputRef === 'function') inputRef(element);\n else if (inputRef) inputRef.current = element;\n },\n [inputRef],\n );\n\n /*\n * The popup portals out of the field, so the browser's Tab order would\n * skip it. While it is open, Tab from the field moves into its header's\n * controls, Tab from the last one moves on to whatever follows the field,\n * and Shift+Tab walks back the same way. Only the header counts, as the\n * pins are reached with the arrows; with no header control, Tab is the\n * browser's. A window listener, so it lives in an effect, and so it runs\n * ahead of a Dialog's focus trap: the popup is the end of the dialog's\n * panel, and the trap would wrap Tab from its last control to the\n * dialog's first.\n */\n useEffect(() => {\n if (!isOpen) return;\n const handleTab = (event: globalThis.KeyboardEvent) => {\n const header = headerRef.current;\n const content = contentRef.current;\n const field = inputEl.current;\n if (event.key !== 'Tab' || !header || !content || !field) return;\n const [first, last] = getTabbableEdges(header);\n if (!first || !last) return;\n const scope = field.closest<HTMLElement>('[aria-modal=\"true\"]') ?? field.ownerDocument.body;\n const tabbables = getTabbables(scope);\n const after = tabbables\n .slice(tabbables.indexOf(field) + 1)\n .find((element) => !content.contains(element));\n const current = field.ownerDocument.activeElement;\n let target: HTMLElement | undefined;\n if (event.shiftKey) target = current === first ? field : current === after ? last : undefined;\n else target = current === field ? first : current === last ? after : undefined;\n if (!target) return;\n event.preventDefault();\n if (target === after) event.stopPropagation();\n target.focus({ preventScroll: true });\n };\n window.addEventListener('keydown', handleTab, true);\n return () => window.removeEventListener('keydown', handleTab, true);\n }, [isOpen]);\n\n const activate = (next: Active | null) => {\n flushSync(() => setChosen(next));\n if (!next) return;\n const index = ordered.findIndex((item) => item.value === next.value);\n document.getElementById(rowId(index))?.scrollIntoView?.({ block: 'nearest' });\n };\n\n const move = (step: 1 | -1) => {\n if (navigable.length === 0) return;\n const from = active ? navigable.findIndex((item) => item.value === active.value) : -1;\n const to =\n from === -1\n ? step === 1\n ? 0\n : navigable.length - 1\n : (from + step + navigable.length) % navigable.length;\n const item = navigable[to];\n activate({\n value: item.value,\n cell: active?.cell === 'facet' && canPin(item) ? 'facet' : 'item',\n });\n };\n\n const focusFieldFromPopup = () => {\n if (contentRef.current?.contains(document.activeElement)) inputEl.current?.focus();\n };\n\n const handleOpenChange = (details: { open: boolean }) => {\n setOpen(details.open);\n if (!details.open) setChosen(null);\n };\n\n const choose = (item: ComboboxItem) => {\n if (item.disabled) return;\n focusFieldFromPopup();\n onSelect(item.value);\n onInputValueChange('');\n setChosen(null);\n setOpen(false);\n };\n\n const togglePin = (facet: ComboboxFacet) => {\n facets?.onPinnedChange?.(pinned?.value === facet.value ? null : facet);\n setChosen(null);\n };\n\n const unpin = () => {\n facets?.onPinnedChange?.(null);\n inputEl.current?.focus();\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setChosen(null);\n setOpen(true);\n onInputValueChange(event.target.value);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (isComposingEvent(event) || event.ctrlKey || event.shiftKey) return;\n const input = event.currentTarget;\n const activeItem = activeIndex >= 0 ? ordered[activeIndex] : undefined;\n const caretAtEnd =\n input.selectionStart === input.value.length && input.selectionEnd === input.value.length;\n\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n if (!isOpen) setOpen(true);\n move(event.key === 'ArrowDown' ? 1 : -1);\n } else if (event.key === 'ArrowRight' && isOpen && activeItem && active?.cell === 'item') {\n if (isGrid && canPin(activeItem) && caretAtEnd) {\n event.preventDefault();\n activate({ value: activeItem.value, cell: 'facet' });\n }\n } else if (event.key === 'ArrowLeft' && isOpen && activeItem && active?.cell === 'facet') {\n event.preventDefault();\n activate({ value: activeItem.value, cell: 'item' });\n } else if (event.key === 'Enter' && isOpen && activeItem) {\n event.preventDefault();\n if (active?.cell === 'facet' && activeItem.facet) togglePin(activeItem.facet);\n else choose(activeItem);\n } else if (event.key === 'Backspace' && input.value === '' && pinned) {\n facets?.onPinnedChange?.(null);\n }\n };\n\n const rowIndexOf = (target: EventTarget) => {\n const row = (target as Element).closest<HTMLElement>('[data-index]');\n return row ? Number(row.dataset.index) : -1;\n };\n\n const handleListClick = (event: MouseEvent) => {\n const item = ordered[rowIndexOf(event.target)];\n if (!item) return;\n if ((event.target as Element).closest('[data-pin]') && item.facet) togglePin(item.facet);\n else choose(item);\n };\n\n const handleListPointerMove = (event: PointerEvent) => {\n const item = ordered[rowIndexOf(event.target)];\n if (item && !item.disabled && item.value !== active?.value) {\n setChosen({ value: item.value, cell: 'item' });\n }\n };\n\n const listName = label ? { 'aria-labelledby': labelId } : { 'aria-label': ariaLabel };\n const hasStatus = status !== undefined || pinned !== null;\n const hasHeader = toolbar !== undefined || hasStatus;\n const isEmpty = items.length === 0 && emptyText !== undefined;\n\n const rowOf = (item: ComboboxItem): RowModel => {\n const index = ordered.indexOf(item);\n const isActive = isOpen && index === activeIndex;\n return {\n item,\n index,\n rowId: rowId(index),\n itemCellId: cellId(index, 'item'),\n facetCellId: cellId(index, 'facet'),\n highlighted: isActive,\n pinnable: canPin(item),\n pinned: pinned !== null && pinned.value === item.facet?.value,\n pinActive: isActive && active?.cell === 'facet',\n };\n };\n const sections: Section[] = groups.map((group, groupIndex) => ({\n label: group.label,\n headingId: `${id}-group-${groupIndex}`,\n rows: group.items.map(rowOf),\n }));\n\n /*\n * Mouse input never takes focus from the field, so typing carries on: a\n * press on a row, a pin or the header's background is cancelled. Only the\n * header's own controls (a switch, a segment, the chip's remove button)\n * take focus, as they would anywhere.\n */\n const handleContentMouseDown = (event: MouseEvent) => {\n const target = event.target as Element;\n if (target.closest('.ds-combobox__list') || !target.closest(HEADER_CONTROLS)) {\n event.preventDefault();\n }\n };\n\n return (\n <ArkPopover.Root\n open={isOpen}\n onOpenChange={handleOpenChange}\n lazyMount\n unmountOnExit\n autoFocus={false}\n restoreFocus={false}\n portalled={false}\n persistentElements={[() => rootRef.current]}\n onEscapeKeyDown={focusFieldFromPopup}\n positioning={{ placement: 'bottom-start', sameWidth: true }}\n >\n <div ref={rootRef} className={cx('ds-combobox', `ds-combobox--${size}`, className)}>\n {label && (\n <label\n id={labelId}\n htmlFor={inputId}\n className=\"ds-combobox__label\"\n data-disabled={disabled ? '' : undefined}\n >\n {label}\n </label>\n )}\n <ArkPopover.Anchor className=\"ds-combobox__control\">\n <input\n ref={setInputRef}\n id={inputId}\n type=\"text\"\n role=\"combobox\"\n className=\"ds-combobox__input\"\n value={inputValue}\n placeholder={placeholder}\n aria-label={label ? undefined : ariaLabel}\n aria-autocomplete=\"list\"\n aria-haspopup={isGrid ? 'grid' : 'listbox'}\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-activedescendant={activeDescendant}\n aria-describedby={isOpen && hasStatus ? statusId : undefined}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? '' : undefined}\n disabled={disabled}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"none\"\n spellCheck={false}\n onChange={handleChange}\n onClick={() => setOpen(true)}\n onKeyDown={handleKeyDown}\n />\n </ArkPopover.Anchor>\n </div>\n\n <Portal container={portalContainer}>\n <ArkPopover.Positioner>\n <ArkPopover.Content\n ref={contentRef}\n role=\"presentation\"\n className=\"ds-combobox__content\"\n onMouseDown={handleContentMouseDown}\n onClick={handleListClick}\n onPointerMove={handleListPointerMove}\n >\n {hasHeader && (\n <div ref={headerRef} className=\"ds-combobox__header\">\n {toolbar && <div className=\"ds-combobox__toolbar\">{toolbar}</div>}\n {hasStatus && (\n <p id={statusId} role=\"status\" className=\"ds-combobox__status\">\n {status}\n {pinned && (\n <>\n {' '}\n <PinnedChip facet={pinned} removeIcon={removeIcon} onRemove={unpin} />\n </>\n )}\n </p>\n )}\n </div>\n )}\n {facets ? (\n <GridList\n id={listId}\n name={listName}\n facets={facets}\n sections={sections}\n emptyText={isEmpty ? emptyText : undefined}\n pinIcon={pinIcon}\n />\n ) : (\n <ListboxList\n id={listId}\n name={listName}\n sections={sections}\n emptyText={isEmpty ? emptyText : undefined}\n />\n )}\n </ArkPopover.Content>\n </ArkPopover.Positioner>\n </Portal>\n </ArkPopover.Root>\n );\n}\n\ninterface RowModel {\n item: ComboboxItem;\n index: number;\n rowId: string;\n itemCellId: string;\n facetCellId: string;\n highlighted: boolean;\n pinnable: boolean;\n pinned: boolean;\n pinActive: boolean;\n}\n\ninterface Section {\n label?: string;\n headingId: string;\n rows: RowModel[];\n}\n\ninterface ListProps {\n id: string;\n name: { 'aria-labelledby': string } | { 'aria-label': string | undefined };\n sections: Section[];\n emptyText: ReactNode;\n}\n\nconst rowState = (row: RowModel) => ({\n 'data-index': row.index,\n 'data-highlighted': row.highlighted ? '' : undefined,\n 'data-disabled': row.item.disabled ? '' : undefined,\n});\n\nfunction ItemText({ item }: { item: ComboboxItem }) {\n return (\n <>\n <span className=\"ds-combobox__item-label\">{item.label}</span>\n {item.description && (\n <>\n {' '}\n <span className=\"ds-combobox__item-description\">{item.description}</span>\n </>\n )}\n </>\n );\n}\n\n/*\n * The listbox's options and groups take their roles on plain elements: the\n * field keeps focus and points at an option with aria-activedescendant, so\n * none of them is focusable, and HTML has no element for an option outside\n * a native select. The lint rules asking for focusable or native elements\n * are therefore suppressed here, and only here.\n */\nfunction ListboxList({ id, name, sections, emptyText }: ListProps) {\n const option = (row: RowModel) => (\n // biome-ignore lint/a11y/useFocusableInteractive: reached through aria-activedescendant from the field, never by focus\n <div\n key={row.item.value}\n id={row.rowId}\n role=\"option\"\n aria-selected=\"false\"\n aria-disabled={row.item.disabled}\n className=\"ds-combobox__item\"\n {...rowState(row)}\n >\n <ItemText item={row.item} />\n </div>\n );\n return (\n <div id={id} role=\"listbox\" className=\"ds-combobox__list\" {...name}>\n {sections.map((section) =>\n section.label === undefined ? (\n section.rows.map(option)\n ) : (\n // biome-ignore lint/a11y/useSemanticElements: a fieldset is a form group, not a group of options\n <div\n key={section.label}\n role=\"group\"\n aria-labelledby={section.headingId}\n className=\"ds-combobox__group\"\n >\n <div id={section.headingId} className=\"ds-combobox__group-label\">\n {section.label}\n </div>\n {section.rows.map(option)}\n </div>\n ),\n )}\n {emptyText !== undefined && (\n // biome-ignore lint/a11y/useFocusableInteractive: a disabled option the keyboard never lands on\n <div\n role=\"option\"\n aria-disabled=\"true\"\n aria-selected=\"false\"\n className=\"ds-combobox__empty\"\n >\n {emptyText}\n </div>\n )}\n </div>\n );\n}\n\ninterface GridListProps extends ListProps {\n facets: ComboboxFacets;\n pinIcon: IconSource;\n}\n\n/*\n * A table in the grid role: its rows and cells line up in two columns by\n * themselves, and a group of rows is a `tbody` named by its heading row.\n * The keyboard skips heading rows, as it skips a listbox's group labels.\n */\nfunction GridList({ id, name, facets, sections, emptyText, pinIcon }: GridListProps) {\n const row = (model: RowModel) => <GridRow key={model.item.value} row={model} pinIcon={pinIcon} />;\n return (\n // biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: a table in the grid role is the APG grid pattern; its cells line up by themselves\n <table id={id} role=\"grid\" className=\"ds-combobox__list ds-combobox__list--grid\" {...name}>\n <thead className=\"ds-visually-hidden\">\n <tr>\n <th scope=\"col\">{facets.itemLabel}</th>\n <th scope=\"col\">{facets.label}</th>\n </tr>\n </thead>\n {sections.map((section) =>\n section.label === undefined ? (\n <tbody key=\"ungrouped\">{section.rows.map(row)}</tbody>\n ) : (\n <tbody\n key={section.label}\n aria-labelledby={section.headingId}\n className=\"ds-combobox__group\"\n >\n <tr>\n <th\n id={section.headingId}\n colSpan={2}\n scope=\"colgroup\"\n className=\"ds-combobox__group-label\"\n >\n {section.label}\n </th>\n </tr>\n {section.rows.map(row)}\n </tbody>\n ),\n )}\n {emptyText !== undefined && (\n <tbody>\n <tr>\n <GridCell colSpan={2} aria-disabled=\"true\" className=\"ds-combobox__empty\">\n {emptyText}\n </GridCell>\n </tr>\n </tbody>\n )}\n </table>\n );\n}\n\n/*\n * A cell of the grid, named so explicitly: a `td` in a grid table is a\n * gridcell to browsers, but not to every tool, and the field keeps focus\n * and points at the cell with aria-activedescendant, so it is not focusable.\n */\nfunction GridCell(props: TdHTMLAttributes<HTMLTableCellElement>) {\n // biome-ignore lint/a11y/useFocusableInteractive: reached through aria-activedescendant from the field, never by focus\n // biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: a td in a grid table is a gridcell; named so for every tool\n return <td role=\"gridcell\" {...props} />;\n}\n\nfunction GridRow({ row, pinIcon }: { row: RowModel; pinIcon: IconSource }) {\n const { item } = row;\n return (\n <tr id={row.rowId} className=\"ds-combobox__item\" {...rowState(row)}>\n <GridCell id={row.itemCellId} className=\"ds-combobox__cell\" aria-disabled={item.disabled}>\n <ItemText item={item} />\n </GridCell>\n <GridCell id={row.facetCellId} className=\"ds-combobox__facet\">\n {item.facet && <FacetCell facet={item.facet} row={row} pinIcon={pinIcon} />}\n </GridCell>\n </tr>\n );\n}\n\nfunction FacetCell({\n facet,\n row,\n pinIcon,\n}: {\n facet: ComboboxFacet;\n row: RowModel;\n pinIcon: IconSource;\n}) {\n return (\n <span className=\"ds-combobox__facet-content\">\n {facet.icon}\n <span className=\"ds-combobox__facet-label\">{facet.label}</span>\n {row.pinnable && (\n <Tooltip content={`Filter by ${facet.label}`} kind=\"label\">\n <button\n type=\"button\"\n tabIndex={-1}\n className=\"ds-combobox__pin\"\n aria-label={`Filter by ${facet.label}`}\n aria-pressed={row.pinned}\n data-pin=\"\"\n data-active={row.pinActive ? '' : undefined}\n >\n <Icon source={pinIcon} size=\"sm\" decorative />\n </button>\n </Tooltip>\n )}\n </span>\n );\n}\n\ninterface PinnedChipProps {\n facet: ComboboxFacet;\n removeIcon: IconSource;\n onRemove: () => void;\n}\n\nfunction PinnedChip({ facet, removeIcon, onRemove }: PinnedChipProps) {\n return (\n <span className=\"ds-combobox__chip\">\n {facet.icon}\n <span>{facet.label}</span>\n <Tooltip content=\"Stop filtering\" kind=\"label\">\n <button\n type=\"button\"\n className=\"ds-combobox__chip-remove\"\n aria-label={`Stop filtering by ${facet.label}`}\n onClick={onRemove}\n >\n <Icon source={removeIcon} size=\"sm\" decorative />\n </button>\n </Tooltip>\n </span>\n );\n}\n"]}
1
+ {"version":3,"file":"combobox.js","sourceRoot":"","sources":["../../src/combobox/combobox.tsx"],"names":[],"mappings":";AAA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AAS,EAAC,kBAAkB,gBAChB,aAAa,KAAK,CAAC,KAAK,EAAE,kBACxB,GAAG,CAAC,MAAM,cACf,EAAE,iBACE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,YAE3C,KAAC,IAAI,IAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,SAAG,GACvC,GACD,CACX,IACI,CACR,CAAC;AACJ,CAAC;AAQD,SAAS,UAAU,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAmB;IAClE,OAAO,CACL,gBAAM,SAAS,EAAC,mBAAmB,aAChC,KAAK,CAAC,IAAI,EACX,yBAAO,KAAK,CAAC,KAAK,GAAQ,EAC1B,KAAC,OAAO,IAAC,OAAO,EAAC,gBAAgB,EAAC,IAAI,EAAC,OAAO,YAC5C,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,0BAA0B,gBACxB,qBAAqB,KAAK,CAAC,KAAK,EAAE,EAC9C,OAAO,EAAE,QAAQ,YAEjB,KAAC,IAAI,IAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAC,IAAI,EAAC,UAAU,SAAG,GAC1C,GACD,IACL,CACR,CAAC;AACJ,CAAC","sourcesContent":["import { Popover as ArkPopover } from '@ark-ui/react/popover';\nimport { Portal } from '@ark-ui/react/portal';\nimport { getTabbableEdges, getTabbables, isComposingEvent } from '@zag-js/dom-query';\nimport {\n type ChangeEvent,\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n type Ref,\n type TdHTMLAttributes,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { flushSync } from 'react-dom';\nimport { cx } from '../cx';\nimport { groupItems } from '../group-items';\nimport { Icon, type IconSource } from '../icon/icon';\nimport { useIconDefaults } from '../icon-defaults';\nimport { PortalContainerContext } from '../portal-container';\nimport { Tooltip } from '../tooltip/tooltip';\nimport '../visually-hidden/visually-hidden.css';\nimport './combobox.css';\n\nexport type ComboboxSize = 'sm' | 'md' | 'lg';\n\n/** What an option belongs to, shown in a second column: its category, its project. */\nexport interface ComboboxFacet {\n /** Stable value reported when the facet is pinned. */\n value: string;\n /** Text in the facet column, and in the pinned chip. */\n label: string;\n /** Decorative mark before the label, such as the category's icon. */\n icon?: ReactNode;\n}\n\nexport interface ComboboxItem {\n /** Stable value reported by `onSelect`. */\n value: string;\n /** Option text, also what screen readers use. */\n label: string;\n /** Optional secondary line under the label, shown muted. */\n description?: string;\n /** Individually disable this option without removing it. */\n disabled?: boolean;\n /**\n * The group the option is listed under, by its heading. Options sharing a\n * group are listed together under it, groups in the order they first\n * appear; options without one (or with an empty name) are listed before\n * any group.\n */\n group?: string;\n /** What the option belongs to, shown in the facet column when `facets` is set. */\n facet?: ComboboxFacet;\n}\n\n/**\n * A second column naming what each option belongs to, with a pin that\n * narrows the list to it.\n */\nexport interface ComboboxFacets {\n /** Heading of the option column, for assistive tech: \"Action\". */\n itemLabel: string;\n /** Heading of the facet column, for assistive tech: \"Category\". */\n label: string;\n /** The facet the list is narrowed to, shown as a removable chip in the status line. */\n pinned?: ComboboxFacet | null;\n /**\n * Pins a row's facet, or unpins it with `null` (its pin pressed again, the\n * chip's remove button, or Backspace in the empty field). The caller does\n * the narrowing. Without it, the facet column shows no pins.\n */\n onPinnedChange?: (facet: ComboboxFacet | null) => void;\n}\n\nexport interface ComboboxProps {\n /**\n * Suggestions for the current text.\n *\n * The caller filters, sorts and groups them; the component does not. What\n * counts as a match (a prefix, a substring, a category's name, anything\n * not already chosen) is the product's call, and the list it passes is the\n * list that shows.\n */\n items: ComboboxItem[];\n /** Controlled text in the input. */\n inputValue: string;\n /** Fired with the new text on every keystroke, and with `''` after a choice. */\n onInputValueChange: (value: string) => void;\n /**\n * A suggestion was chosen. The input then clears (`onInputValueChange('')`)\n * and the field holds no value: this is the \"add to a list\" pattern. A\n * field that keeps its choice is a `Select`.\n */\n onSelect: (value: string) => void;\n /**\n * Visible label. Strongly preferred over `aria-label` — a visible label\n * helps everyone, not only screen reader users.\n */\n label?: ReactNode;\n /** Accessible name when no visible `label` is supplied. */\n 'aria-label'?: string;\n /** Text shown in the empty input. */\n placeholder?: string;\n /** Shown in the open list when `items` is empty. */\n emptyText?: ReactNode;\n /**\n * Controls at the top of the open list that change what it shows: a\n * `Switch`, a small `SegmentGroup`. One row of them, so the options stay\n * in view; Tab moves into them from the field.\n */\n toolbar?: ReactNode;\n /**\n * One line under the toolbar saying what the list shows, such as \"Showing\n * all actions in Health\". Announced politely as it changes.\n */\n status?: ReactNode;\n /** Adds the facet column, with its pins. The list becomes a grid. */\n facets?: ComboboxFacets;\n /** Glyph of a row's pin. Defaults to the `IconDefaultsProvider`'s `pin`. */\n pinIcon?: IconSource;\n /** Glyph of the pinned chip's remove button. Defaults to the `IconDefaultsProvider`'s `cross`. */\n removeIcon?: IconSource;\n /** Control height and type scale. */\n size?: ComboboxSize;\n /** Disable the whole control. */\n disabled?: boolean;\n /** Marks the field invalid for assistive tech and styling. */\n invalid?: boolean;\n /** Extra class names appended after `ds-combobox` modifiers. */\n className?: string;\n /** The text input, for moving focus back to the field, e.g. after removing an item it added. */\n inputRef?: Ref<HTMLInputElement>;\n}\n\ntype Cell = 'item' | 'facet';\n\ninterface Active {\n value: string;\n cell: Cell;\n}\n\n// The header's own controls, which a press may focus.\nconst HEADER_CONTROLS = 'button, input, label, a[href], [tabindex]:not([tabindex=\"-1\"])';\n\n/**\n * A text input that suggests options as you type, with optional controls at\n * the top of the open list.\n *\n * Choosing a suggestion reports it through `onSelect` and empties the input,\n * so the field is ready for the next one: the control for adding items to a\n * list one at a time. It never holds a selection itself; the caller keeps\n * the list. For a field that keeps one choice, use `Select`.\n *\n * The open list can carry what narrows it, so nothing sits outside the\n * field: a `toolbar` row of switches or a segment group, a `status` line\n * saying what is shown, and with `facets` a second column naming what each\n * option belongs to, whose pin narrows the list to it.\n *\n * ```tsx\n * <Combobox\n * label=\"Add actions\"\n * items={matches}\n * inputValue={query}\n * onInputValueChange={setQuery}\n * onSelect={(value) => setPicked((list) => [...list, value])}\n * toolbar={<Switch size=\"sm\" label=\"Include categories\" checked={…} onCheckedChange={…} />}\n * status={`Showing all actions that contain “${query}”`}\n * facets={{ itemLabel: 'Action', label: 'Category', pinned, onPinnedChange: setPinned }}\n * />\n * ```\n *\n * The field is the APG editable combobox. Focus stays in the input, and the\n * active option is `aria-activedescendant`. Typing highlights the first\n * option, so Enter takes it, and Up and Down walk the options in their drawn\n * order. With `facets` the popup is a grid instead of a listbox: Right, at\n * the end of the text, moves onto the row's pin and Enter then pins it, and\n * Left moves back. Tab moves from the field into the toolbar and the chip,\n * and on out to the next field.\n *\n * The popup is an Ark Popover anchored to the field, so it takes part in\n * the dismiss stack. Escape closes it before a `Dialog` around it, and a\n * click outside closes it. Its wrapper drops the Popover's dialog role, so\n * the listbox or grid inside is the popup assistive tech meets. It portals\n * like `Select`'s list: into `<body>`, or into the panel of the ui-core\n * `Dialog` it opens in, at `z-index: 60`.\n * The field reads the `--ds-input-*` keys and the list the `--ds-select-*`\n * keys, so it reads as one family with `Input` and `Select`.\n */\nexport function Combobox({\n items,\n inputValue,\n onInputValueChange,\n onSelect,\n label,\n 'aria-label': ariaLabel,\n placeholder,\n emptyText,\n toolbar,\n status,\n facets,\n pinIcon: pinIconProp,\n removeIcon: removeIconProp,\n size = 'md',\n disabled,\n invalid,\n className,\n inputRef,\n}: ComboboxProps) {\n const icons = useIconDefaults();\n const pinIcon = pinIconProp ?? icons.pin;\n const removeIcon = removeIconProp ?? icons.cross;\n const id = useId();\n const inputId = `${id}-input`;\n const labelId = `${id}-label`;\n const listId = `${id}-list`;\n const statusId = `${id}-status`;\n const rowId = (index: number) => `${id}-row-${index}`;\n const cellId = (index: number, cell: Cell) => `${id}-cell-${index}-${cell}`;\n\n const rootRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const inputEl = useRef<HTMLInputElement | null>(null);\n const portalContainer = useContext(PortalContainerContext);\n\n const [open, setOpen] = useState(false);\n const [chosen, setChosen] = useState<Active | null>(null);\n const isOpen = open && !disabled;\n const isGrid = facets !== undefined;\n const pinned = facets?.pinned ?? null;\n const canPin = (item: ComboboxItem) => Boolean(facets?.onPinnedChange && item.facet);\n\n const groups = useMemo(() => groupItems(items), [items]);\n const ordered = useMemo(() => groups.flatMap((group) => group.items), [groups]);\n const navigable = useMemo(() => ordered.filter((item) => !item.disabled), [ordered]);\n\n const chosenItem = chosen && navigable.find((item) => item.value === chosen.value);\n const active: Active | null = chosenItem\n ? {\n value: chosenItem.value,\n cell: chosen?.cell === 'facet' && canPin(chosenItem) ? 'facet' : 'item',\n }\n : inputValue !== '' && navigable[0]\n ? { value: navigable[0].value, cell: 'item' }\n : null;\n const activeIndex = active ? ordered.findIndex((item) => item.value === active.value) : -1;\n const activeDescendant =\n isOpen && active && activeIndex >= 0\n ? isGrid\n ? cellId(activeIndex, active.cell)\n : rowId(activeIndex)\n : undefined;\n\n const setInputRef = useCallback(\n (element: HTMLInputElement | null) => {\n inputEl.current = element;\n if (typeof inputRef === 'function') inputRef(element);\n else if (inputRef) inputRef.current = element;\n },\n [inputRef],\n );\n\n /*\n * The popup portals out of the field, so the browser's Tab order would\n * skip it. While it is open, Tab from the field moves into its header's\n * controls, Tab from the last one moves on to whatever follows the field,\n * and Shift+Tab walks back the same way. Only the header counts, as the\n * pins are reached with the arrows; with no header control, Tab is the\n * browser's. A window listener, so it lives in an effect, and so it runs\n * ahead of a Dialog's focus trap: the popup is the end of the dialog's\n * panel, and the trap would wrap Tab from its last control to the\n * dialog's first.\n */\n useEffect(() => {\n if (!isOpen) return;\n const handleTab = (event: globalThis.KeyboardEvent) => {\n const header = headerRef.current;\n const content = contentRef.current;\n const field = inputEl.current;\n if (event.key !== 'Tab' || !header || !content || !field) return;\n const [first, last] = getTabbableEdges(header);\n if (!first || !last) return;\n const scope = field.closest<HTMLElement>('[aria-modal=\"true\"]') ?? field.ownerDocument.body;\n const tabbables = getTabbables(scope);\n const after = tabbables\n .slice(tabbables.indexOf(field) + 1)\n .find((element) => !content.contains(element));\n const current = field.ownerDocument.activeElement;\n let target: HTMLElement | undefined;\n if (event.shiftKey) target = current === first ? field : current === after ? last : undefined;\n else target = current === field ? first : current === last ? after : undefined;\n if (!target) return;\n event.preventDefault();\n if (target === after) event.stopPropagation();\n target.focus({ preventScroll: true });\n };\n window.addEventListener('keydown', handleTab, true);\n return () => window.removeEventListener('keydown', handleTab, true);\n }, [isOpen]);\n\n const activate = (next: Active | null) => {\n flushSync(() => setChosen(next));\n if (!next) return;\n const index = ordered.findIndex((item) => item.value === next.value);\n document.getElementById(rowId(index))?.scrollIntoView?.({ block: 'nearest' });\n };\n\n const move = (step: 1 | -1) => {\n if (navigable.length === 0) return;\n const from = active ? navigable.findIndex((item) => item.value === active.value) : -1;\n const to =\n from === -1\n ? step === 1\n ? 0\n : navigable.length - 1\n : (from + step + navigable.length) % navigable.length;\n const item = navigable[to];\n activate({\n value: item.value,\n cell: active?.cell === 'facet' && canPin(item) ? 'facet' : 'item',\n });\n };\n\n const focusFieldFromPopup = () => {\n if (contentRef.current?.contains(document.activeElement)) inputEl.current?.focus();\n };\n\n const handleOpenChange = (details: { open: boolean }) => {\n setOpen(details.open);\n if (!details.open) setChosen(null);\n };\n\n const choose = (item: ComboboxItem) => {\n if (item.disabled) return;\n focusFieldFromPopup();\n onSelect(item.value);\n onInputValueChange('');\n setChosen(null);\n setOpen(false);\n };\n\n const togglePin = (facet: ComboboxFacet) => {\n facets?.onPinnedChange?.(pinned?.value === facet.value ? null : facet);\n setChosen(null);\n };\n\n const unpin = () => {\n facets?.onPinnedChange?.(null);\n inputEl.current?.focus();\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n setChosen(null);\n setOpen(true);\n onInputValueChange(event.target.value);\n };\n\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (isComposingEvent(event) || event.ctrlKey || event.shiftKey) return;\n const input = event.currentTarget;\n const activeItem = activeIndex >= 0 ? ordered[activeIndex] : undefined;\n const caretAtEnd =\n input.selectionStart === input.value.length && input.selectionEnd === input.value.length;\n\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n if (!isOpen) setOpen(true);\n move(event.key === 'ArrowDown' ? 1 : -1);\n } else if (event.key === 'ArrowRight' && isOpen && activeItem && active?.cell === 'item') {\n if (isGrid && canPin(activeItem) && caretAtEnd) {\n event.preventDefault();\n activate({ value: activeItem.value, cell: 'facet' });\n }\n } else if (event.key === 'ArrowLeft' && isOpen && activeItem && active?.cell === 'facet') {\n event.preventDefault();\n activate({ value: activeItem.value, cell: 'item' });\n } else if (event.key === 'Enter' && isOpen && activeItem) {\n event.preventDefault();\n if (active?.cell === 'facet' && activeItem.facet) togglePin(activeItem.facet);\n else choose(activeItem);\n } else if (event.key === 'Backspace' && input.value === '' && pinned) {\n facets?.onPinnedChange?.(null);\n }\n };\n\n const rowIndexOf = (target: EventTarget) => {\n const row = (target as Element).closest<HTMLElement>('[data-index]');\n return row ? Number(row.dataset.index) : -1;\n };\n\n const handleListClick = (event: MouseEvent) => {\n const item = ordered[rowIndexOf(event.target)];\n if (!item) return;\n if ((event.target as Element).closest('[data-pin]') && item.facet) togglePin(item.facet);\n else choose(item);\n };\n\n const handleListPointerMove = (event: PointerEvent) => {\n const item = ordered[rowIndexOf(event.target)];\n if (item && !item.disabled && item.value !== active?.value) {\n setChosen({ value: item.value, cell: 'item' });\n }\n };\n\n const listName = label ? { 'aria-labelledby': labelId } : { 'aria-label': ariaLabel };\n const hasStatus = status !== undefined || pinned !== null;\n const hasHeader = toolbar !== undefined || hasStatus;\n const isEmpty = items.length === 0 && emptyText !== undefined;\n\n const rowOf = (item: ComboboxItem): RowModel => {\n const index = ordered.indexOf(item);\n const isActive = isOpen && index === activeIndex;\n return {\n item,\n index,\n rowId: rowId(index),\n itemCellId: cellId(index, 'item'),\n facetCellId: cellId(index, 'facet'),\n highlighted: isActive,\n pinnable: canPin(item),\n pinned: pinned !== null && pinned.value === item.facet?.value,\n pinActive: isActive && active?.cell === 'facet',\n };\n };\n const sections: Section[] = groups.map((group, groupIndex) => ({\n label: group.label,\n headingId: `${id}-group-${groupIndex}`,\n rows: group.items.map(rowOf),\n }));\n\n /*\n * Mouse input never takes focus from the field, so typing carries on: a\n * press on a row, a pin or the header's background is cancelled. Only the\n * header's own controls (a switch, a segment, the chip's remove button)\n * take focus, as they would anywhere.\n */\n const handleContentMouseDown = (event: MouseEvent) => {\n const target = event.target as Element;\n if (target.closest('.ds-combobox__list') || !target.closest(HEADER_CONTROLS)) {\n event.preventDefault();\n }\n };\n\n return (\n <ArkPopover.Root\n open={isOpen}\n onOpenChange={handleOpenChange}\n lazyMount\n unmountOnExit\n autoFocus={false}\n restoreFocus={false}\n portalled={false}\n persistentElements={[() => rootRef.current]}\n onEscapeKeyDown={focusFieldFromPopup}\n positioning={{ placement: 'bottom-start', sameWidth: true }}\n >\n <div ref={rootRef} className={cx('ds-combobox', `ds-combobox--${size}`, className)}>\n {label && (\n <label\n id={labelId}\n htmlFor={inputId}\n className=\"ds-combobox__label\"\n data-disabled={disabled ? '' : undefined}\n >\n {label}\n </label>\n )}\n <ArkPopover.Anchor className=\"ds-combobox__control\">\n <input\n ref={setInputRef}\n id={inputId}\n type=\"text\"\n role=\"combobox\"\n className=\"ds-combobox__input\"\n value={inputValue}\n placeholder={placeholder}\n aria-label={label ? undefined : ariaLabel}\n aria-autocomplete=\"list\"\n aria-haspopup={isGrid ? 'grid' : 'listbox'}\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-activedescendant={activeDescendant}\n aria-describedby={isOpen && hasStatus ? statusId : undefined}\n aria-invalid={invalid || undefined}\n data-invalid={invalid ? '' : undefined}\n disabled={disabled}\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"none\"\n spellCheck={false}\n onChange={handleChange}\n onClick={() => setOpen(true)}\n onKeyDown={handleKeyDown}\n />\n </ArkPopover.Anchor>\n </div>\n\n <Portal container={portalContainer}>\n <ArkPopover.Positioner>\n <ArkPopover.Content\n ref={contentRef}\n role=\"presentation\"\n className=\"ds-combobox__content\"\n onMouseDown={handleContentMouseDown}\n onClick={handleListClick}\n onPointerMove={handleListPointerMove}\n >\n {hasHeader && (\n <div ref={headerRef} className=\"ds-combobox__header\">\n {toolbar && <div className=\"ds-combobox__toolbar\">{toolbar}</div>}\n {hasStatus && (\n <p id={statusId} role=\"status\" className=\"ds-combobox__status\">\n {status}\n {pinned && (\n <>\n {' '}\n <PinnedChip facet={pinned} removeIcon={removeIcon} onRemove={unpin} />\n </>\n )}\n </p>\n )}\n </div>\n )}\n {facets ? (\n <GridList\n id={listId}\n name={listName}\n facets={facets}\n sections={sections}\n emptyText={isEmpty ? emptyText : undefined}\n pinIcon={pinIcon}\n />\n ) : (\n <ListboxList\n id={listId}\n name={listName}\n sections={sections}\n emptyText={isEmpty ? emptyText : undefined}\n />\n )}\n </ArkPopover.Content>\n </ArkPopover.Positioner>\n </Portal>\n </ArkPopover.Root>\n );\n}\n\ninterface RowModel {\n item: ComboboxItem;\n index: number;\n rowId: string;\n itemCellId: string;\n facetCellId: string;\n highlighted: boolean;\n pinnable: boolean;\n pinned: boolean;\n pinActive: boolean;\n}\n\ninterface Section {\n label?: string;\n headingId: string;\n rows: RowModel[];\n}\n\ninterface ListProps {\n id: string;\n name: { 'aria-labelledby': string } | { 'aria-label': string | undefined };\n sections: Section[];\n emptyText: ReactNode;\n}\n\nconst rowState = (row: RowModel) => ({\n 'data-index': row.index,\n 'data-highlighted': row.highlighted ? '' : undefined,\n 'data-disabled': row.item.disabled ? '' : undefined,\n});\n\nfunction ItemText({ item }: { item: ComboboxItem }) {\n return (\n <>\n <span className=\"ds-combobox__item-label\">{item.label}</span>\n {item.description && (\n <>\n {' '}\n <span className=\"ds-combobox__item-description\">{item.description}</span>\n </>\n )}\n </>\n );\n}\n\n/*\n * The listbox's options and groups take their roles on plain elements: the\n * field keeps focus and points at an option with aria-activedescendant, so\n * none of them is focusable, and HTML has no element for an option outside\n * a native select. The lint rules asking for focusable or native elements\n * are therefore suppressed here, and only here.\n */\nfunction ListboxList({ id, name, sections, emptyText }: ListProps) {\n const option = (row: RowModel) => (\n // biome-ignore lint/a11y/useFocusableInteractive: reached through aria-activedescendant from the field, never by focus\n <div\n key={row.item.value}\n id={row.rowId}\n role=\"option\"\n aria-selected=\"false\"\n aria-disabled={row.item.disabled}\n className=\"ds-combobox__item\"\n {...rowState(row)}\n >\n <ItemText item={row.item} />\n </div>\n );\n return (\n <div id={id} role=\"listbox\" className=\"ds-combobox__list\" {...name}>\n {sections.map((section) =>\n section.label === undefined ? (\n section.rows.map(option)\n ) : (\n // biome-ignore lint/a11y/useSemanticElements: a fieldset is a form group, not a group of options\n <div\n key={section.label}\n role=\"group\"\n aria-labelledby={section.headingId}\n className=\"ds-combobox__group\"\n >\n <div id={section.headingId} className=\"ds-combobox__group-label\">\n {section.label}\n </div>\n {section.rows.map(option)}\n </div>\n ),\n )}\n {emptyText !== undefined && (\n // biome-ignore lint/a11y/useFocusableInteractive: a disabled option the keyboard never lands on\n <div\n role=\"option\"\n aria-disabled=\"true\"\n aria-selected=\"false\"\n className=\"ds-combobox__empty\"\n >\n {emptyText}\n </div>\n )}\n </div>\n );\n}\n\ninterface GridListProps extends ListProps {\n facets: ComboboxFacets;\n pinIcon: IconSource;\n}\n\n/*\n * A table in the grid role: its rows and cells line up in two columns by\n * themselves, and a group of rows is a `tbody` named by its heading row.\n * The keyboard skips heading rows, as it skips a listbox's group labels.\n */\nfunction GridList({ id, name, facets, sections, emptyText, pinIcon }: GridListProps) {\n const row = (model: RowModel) => <GridRow key={model.item.value} row={model} pinIcon={pinIcon} />;\n return (\n // biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: a table in the grid role is the APG grid pattern; its cells line up by themselves\n <table id={id} role=\"grid\" className=\"ds-combobox__list ds-combobox__list--grid\" {...name}>\n <thead className=\"ds-visually-hidden\">\n <tr>\n <th scope=\"col\">{facets.itemLabel}</th>\n <th scope=\"col\">{facets.label}</th>\n </tr>\n </thead>\n {sections.map((section) =>\n section.label === undefined ? (\n <tbody key=\"ungrouped\">{section.rows.map(row)}</tbody>\n ) : (\n <tbody\n key={section.label}\n aria-labelledby={section.headingId}\n className=\"ds-combobox__group\"\n >\n <tr>\n <th\n id={section.headingId}\n colSpan={2}\n scope=\"colgroup\"\n className=\"ds-combobox__group-label\"\n >\n {section.label}\n </th>\n </tr>\n {section.rows.map(row)}\n </tbody>\n ),\n )}\n {emptyText !== undefined && (\n <tbody>\n <tr>\n <GridCell colSpan={2} aria-disabled=\"true\" className=\"ds-combobox__empty\">\n {emptyText}\n </GridCell>\n </tr>\n </tbody>\n )}\n </table>\n );\n}\n\n/*\n * A cell of the grid, named so explicitly: a `td` in a grid table is a\n * gridcell to browsers, but not to every tool, and the field keeps focus\n * and points at the cell with aria-activedescendant, so it is not focusable.\n */\nfunction GridCell(props: TdHTMLAttributes<HTMLTableCellElement>) {\n // biome-ignore lint/a11y/useFocusableInteractive: reached through aria-activedescendant from the field, never by focus\n // biome-ignore lint/a11y/noNoninteractiveElementToInteractiveRole: a td in a grid table is a gridcell; named so for every tool\n return <td role=\"gridcell\" {...props} />;\n}\n\nfunction GridRow({ row, pinIcon }: { row: RowModel; pinIcon: IconSource }) {\n const { item } = row;\n return (\n <tr id={row.rowId} className=\"ds-combobox__item\" {...rowState(row)}>\n <GridCell id={row.itemCellId} className=\"ds-combobox__cell\" aria-disabled={item.disabled}>\n <ItemText item={item} />\n </GridCell>\n <GridCell id={row.facetCellId} className=\"ds-combobox__facet\">\n {item.facet && <FacetCell facet={item.facet} row={row} pinIcon={pinIcon} />}\n </GridCell>\n </tr>\n );\n}\n\nfunction FacetCell({\n facet,\n row,\n pinIcon,\n}: {\n facet: ComboboxFacet;\n row: RowModel;\n pinIcon: IconSource;\n}) {\n return (\n <span className=\"ds-combobox__facet-content\">\n {facet.icon}\n <span className=\"ds-combobox__facet-label\">{facet.label}</span>\n {row.pinnable && (\n <Tooltip content={`Filter by ${facet.label}`} kind=\"label\">\n <button\n type=\"button\"\n tabIndex={-1}\n className=\"ds-combobox__pin\"\n aria-label={`Filter by ${facet.label}`}\n aria-pressed={row.pinned}\n data-pin=\"\"\n data-active={row.pinActive ? '' : undefined}\n >\n <Icon source={pinIcon} size=\"sm\" decorative />\n </button>\n </Tooltip>\n )}\n </span>\n );\n}\n\ninterface PinnedChipProps {\n facet: ComboboxFacet;\n removeIcon: IconSource;\n onRemove: () => void;\n}\n\nfunction PinnedChip({ facet, removeIcon, onRemove }: PinnedChipProps) {\n return (\n <span className=\"ds-combobox__chip\">\n {facet.icon}\n <span>{facet.label}</span>\n <Tooltip content=\"Stop filtering\" kind=\"label\">\n <button\n type=\"button\"\n className=\"ds-combobox__chip-remove\"\n aria-label={`Stop filtering by ${facet.label}`}\n onClick={onRemove}\n >\n <Icon source={removeIcon} size=\"sm\" decorative />\n </button>\n </Tooltip>\n </span>\n );\n}\n"]}
@@ -74,9 +74,8 @@ export interface DialogProps {
74
74
  /** Accessible name of the close button. Translate it with the rest of the UI. */
75
75
  closeLabel?: string;
76
76
  /**
77
- * Glyph for the close button. Defaults to a plain built-in cross so
78
- * `@manakind/ui-core` renders on its own; products pass their own icon set,
79
- * as they do for Select's indicators.
77
+ * Glyph for the close button. Defaults to the `IconDefaultsProvider`'s
78
+ * `cross`, or a plain built-in one.
80
79
  */
81
80
  closeIcon?: IconSource;
82
81
  /**
@@ -139,5 +138,5 @@ export interface DialogProps {
139
138
  * dialog portals into its panel (see `PortalContainerContext`) and opens at
140
139
  * 60, above it. Nothing is mounted while the dialog is closed.
141
140
  */
142
- export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, finalFocusRef, closeLabel, closeIcon, size, presentation, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
141
+ export declare function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role, initialFocusRef, finalFocusRef, closeLabel, closeIcon: closeIconProp, size, presentation, className, }: DialogProps): import("react/jsx-runtime").JSX.Element;
143
142
  //# sourceMappingURL=dialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/dialog/dialog.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,cAAc,CAAC;AAItB,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;AAElD,gGAAgG;AAChG,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAErC,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,uDAAuD;IACvD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD;;;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AQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,uDAAuD;IACvD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4CAA4C;IAC5C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD;;;;;;;;;;;OAWG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC9C,iFAAiF;IACjF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,IAAe,EACf,eAAe,EACf,aAAa,EACb,UAAoB,EACpB,SAAS,EAAE,aAAa,EACxB,IAAW,EACX,YAAsB,EACtB,SAAS,GACV,EAAE,WAAW,2CAgHb"}
@@ -8,7 +8,7 @@ import { PortalContainerContext } from '../portal-container';
8
8
  import { SidePanelSlotContext } from '../side-panel-layout/side-panel-context';
9
9
  import './dialog.css';
10
10
  import { cx } from '../cx';
11
- import { Cross } from '../fallback-glyphs';
11
+ import { useIconDefaults } from '../icon-defaults';
12
12
  /**
13
13
  * A modal dialog: a raised panel over a dimmed page, built on Ark UI.
14
14
  *
@@ -44,7 +44,9 @@ import { Cross } from '../fallback-glyphs';
44
44
  * dialog portals into its panel (see `PortalContainerContext`) and opens at
45
45
  * 60, above it. Nothing is mounted while the dialog is closed.
46
46
  */
47
- export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, finalFocusRef, closeLabel = 'Close', closeIcon = Cross, size = 'md', presentation = 'modal', className, }) {
47
+ export function Dialog({ title, description, children, actions, trigger, open, defaultOpen, onOpenChange, role = 'dialog', initialFocusRef, finalFocusRef, closeLabel = 'Close', closeIcon: closeIconProp, size = 'md', presentation = 'modal', className, }) {
48
+ const icons = useIconDefaults();
49
+ const closeIcon = closeIconProp ?? icons.cross;
48
50
  const dismissible = role === 'dialog';
49
51
  const slot = useContext(SidePanelSlotContext);
50
52
  const side = presentation === 'side' && dismissible && slot ? slot : undefined;