@mortenbrudvik/waveui 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -2
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +4 -4
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.mjs +10 -10
- package/dist/components/data-display/InfoButton.cjs +1 -1
- package/dist/components/data-display/InfoButton.cjs.map +1 -1
- package/dist/components/data-display/InfoButton.mjs +12 -12
- package/dist/components/feedback/Toaster.cjs +1 -1
- package/dist/components/feedback/Toaster.cjs.map +1 -1
- package/dist/components/feedback/Toaster.mjs +235 -235
- package/dist/components/feedback/Toaster.mjs.map +1 -1
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.mjs +176 -175
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +188 -187
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +41 -40
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +89 -87
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/TagPicker.root.cjs +1 -1
- package/dist/components/input/TagPicker.root.cjs.map +1 -1
- package/dist/components/input/TagPicker.root.mjs +136 -135
- package/dist/components/input/TagPicker.root.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +156 -154
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +137 -127
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +4 -4
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +123 -123
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.cjs +1 -1
- package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.mjs +12 -12
- package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +173 -162
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +96 -91
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +47 -47
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +5 -5
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +1 -1
- package/dist/hooks/useDismiss.cjs.map +1 -1
- package/dist/hooks/useDismiss.mjs.map +1 -1
- package/dist/hooks/useFocusTrap.cjs.map +1 -1
- package/dist/hooks/useFocusTrap.mjs.map +1 -1
- package/dist/hooks/useFocusVisible.cjs +2 -0
- package/dist/hooks/useFocusVisible.cjs.map +1 -0
- package/dist/hooks/useFocusVisible.mjs +49 -0
- package/dist/hooks/useFocusVisible.mjs.map +1 -0
- package/dist/hooks/useFocusableGroup.cjs +2 -0
- package/dist/hooks/useFocusableGroup.cjs.map +1 -0
- package/dist/hooks/useFocusableGroup.mjs +70 -0
- package/dist/hooks/useFocusableGroup.mjs.map +1 -0
- package/dist/hooks/useModalLayer.cjs +1 -1
- package/dist/hooks/useModalLayer.cjs.map +1 -1
- package/dist/hooks/useModalLayer.mjs +4 -4
- package/dist/hooks/useModalOpen.cjs +2 -0
- package/dist/hooks/useModalOpen.cjs.map +1 -0
- package/dist/hooks/useModalOpen.mjs +14 -0
- package/dist/hooks/useModalOpen.mjs.map +1 -0
- package/dist/hooks/usePopupPosition.cjs +1 -1
- package/dist/hooks/usePopupPosition.cjs.map +1 -1
- package/dist/hooks/usePopupPosition.mjs +82 -53
- package/dist/hooks/usePopupPosition.mjs.map +1 -1
- package/dist/hooks/useResolvedTarget.cjs +2 -0
- package/dist/hooks/useResolvedTarget.cjs.map +1 -0
- package/dist/hooks/useResolvedTarget.mjs +37 -0
- package/dist/hooks/useResolvedTarget.mjs.map +1 -0
- package/dist/hooks/useRovingGrid.cjs +1 -1
- package/dist/hooks/useRovingGrid.cjs.map +1 -1
- package/dist/hooks/useRovingGrid.mjs +8 -57
- package/dist/hooks/useRovingGrid.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +142 -107
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +814 -18
- package/dist/index.d.ts +814 -18
- package/dist/index.mjs +120 -108
- package/dist/lib/layers.cjs +1 -1
- package/dist/lib/layers.cjs.map +1 -1
- package/dist/lib/layers.mjs +112 -109
- package/dist/lib/layers.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.mjs","names":["React","HISTORY_EDITS","matchesText","item","text","ComboboxRoot","valueProp","openProp","sizeProp","appearanceProp","freeformProp","queryProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","props","onOptionSelect","warnDeprecated","freeform","multiselect","freeformIgnored","warnOnce","queryIgnored","defaultQuery","field","useFieldContext","validates","required","readOnly","fieldProps","useFieldControl","invalidLook","isInvalidLook","useInputLook","value","setValue","useControllable","defaultValue","EMPTY_VALUES","next","values","toValues","single","interactive","disabled","openState","setOpen","defaultOpen","onOpenChange","open","query","setQuery","onQueryChange","editing","setEditing","freeformDraft","setFreeformDraft","draft","lock","setLock","lockedOpen","typedValue","setTypedValue","rootRef","inputRef","optionLabels","collectOptionLabels","children","filterText","listFilter","filter","editDraft","dropDraft","commitText","close","clearDraft","listbox","useListbox","updated","toggleValue","announceToggle","labels","details","added","onActiveOptionChange","labelOf","v","labelsText","shown","label","defaultSelectionLabel","showingLabels","optionLabel","inputText","expanded","noMatchesText","surfaceOpen","noMatches","useListboxPopup","rootMergedRef","useMergedRefs","ref","inputMergedRef","controlRef","setReference","resetValues","current","form","pointerFocusRef","handleMouseDown","isFocused","event","handleFocus","handleMouseUp","input","announcedEditRef","handledInputRef","handleUnchangedEdit","useEventCallback","record","inputType","selectionStart","selectionEnd","handleKeyDown","handleChange","announced","edit","range","replacedText","insertedText","handleExpandClick","handleClear","showExpand","showsExpandButton","expandIcon","showClear","clearable","listLabelledBy","size","appearance","cn","comboboxClassNames","className","PickerAnnouncer","placeholder","maxLength","composeEventHandlers","onKeyDown","onKeyUp","onFocus","onBlur","inputHeightClasses","inputPaddingClasses","inputTextClasses","inputAppearanceClasses","inputFocus","disabledStyles","pickerEndPadding","pickerIconButtonClasses","pickerButtonOffset","DismissIcon","pickerGlyphSize","PickerExpandButton","ListboxSurface","HiddenInput","ComboboxOption","Option","ComboboxOptionGroup","OptionGroup","Combobox"],"sources":["../../../src/components/input/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { comboboxClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { isFocused } from '../../lib/focus';\nimport { DismissIcon } from '../../lib/icons';\nimport type { Slot } from '../../lib/slot';\nimport {\n disabledStyles,\n focusRing,\n inputAppearanceClasses,\n inputFocus,\n inputHeightClasses,\n inputInvalid,\n inputPaddingClasses,\n inputTextClasses,\n} from '../../lib/styles';\nimport type { CoreSize, InputAppearance } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { collectOptionLabels, useListbox, type ListboxItem } from '../../hooks/useListbox';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { PickerExpandButton, showsExpandButton } from './Combobox.expand';\nimport { insertedText, replacedText } from './Combobox.text';\nimport { useInputLook } from './inputLook';\nimport { isInvalidLook } from './Input';\nimport { ListboxSurface, Option, OptionGroup, useListboxPopup } from './Option';\nimport { announceToggle, defaultSelectionLabel, PickerAnnouncer } from './pickerLabels';\nimport {\n pickerButtonOffset,\n pickerEndPadding,\n pickerGlyphSize,\n pickerIconButtonClasses,\n} from './pickerStyles';\nimport { EMPTY_VALUES, resetValues, toggleValue, toValues } from './pickerValues';\nimport type { RoutedHandlers } from './routedHandlers';\n\nexport { Option, OptionGroup } from './Option';\nexport type { OptionProps, OptionGroupProps } from './Option';\n\n/* ------------------------------------------------------------------ */\n/* Combobox */\n/* ------------------------------------------------------------------ */\n\n/**\n * The Combobox's built-in texts, for localization. Each member is optional and falls back to its\n * English default.\n */\nexport interface ComboboxLabels {\n /** Status text (announced, and shown in the popup) when the typed text matches no option.\n * @default 'No matches'\n */\n noMatches?: string;\n /** Name of the clear button (`clearable`).\n * @default 'Clear selection'\n */\n clear?: string;\n /** Name of the expand button at the end of the input.\n * @default 'Show options'\n */\n expand?: string;\n /**\n * The text of the selected labels the input shows with `multiselect` while no text is typed, in\n * selection order; values without an option are left out.\n * @default (labels) => labels.join(', ')\n */\n selection?: (labels: string[]) => string;\n /**\n * Announced when a `multiselect` toggle selects an option; `count` is the number of values\n * selected after the change.\n * @default (label, count) => `${label} added, ${count} selected`\n */\n added?: (label: string, count: number) => string;\n /**\n * Announced when a `multiselect` toggle deselects an option; `count` is the number of values\n * selected after the change.\n * @default (label, count) => `${label} removed, ${count} selected`\n */\n removed?: (label: string, count: number) => string;\n}\n\n/** Properties for the Combobox component. */\nexport interface ComboboxProps<M extends boolean = false> extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | RoutedHandlers\n> {\n /**\n * Several options can be selected (Fluent's `multiselect`): the value is an array, options show\n * a checkbox, Enter and a click toggle an option and keep the list open, and each toggle is\n * announced. While no text is typed the input shows the selected labels, selected whenever the\n * input gains focus or they return to it, so typing replaces them with text that filters the\n * options. Not available with `freeform`. A non-literal `multiselect={flag}` is a type error:\n * render two elements, one for each mode.\n * @default false\n */\n multiselect?: M;\n /**\n * Controlled selected value (`''` for none), or with `multiselect` the selected values (Fluent's\n * `selectedOptions`).\n */\n value?: M extends true ? readonly string[] : string;\n /**\n * Initial selected value for uncontrolled usage.\n * @default '' (`[]` with `multiselect`)\n */\n defaultValue?: M extends true ? readonly string[] : string;\n /**\n * Called with the new value when it changes: an option is selected (toggled with `multiselect`,\n * which passes a new array), or (with `freeform`) the text changes. Without `multiselect` it is\n * not called when the current option is selected again; with it, activating a selected option\n * deselects it, which is a change. Fluent's `onOptionSelect`, under WaveUI's value/onValueChange\n * naming.\n */\n onValueChange?: M extends true ? (value: string[]) => void : (value: string) => void;\n /**\n * Called on every option activation, also when the current option is selected again (every\n * toggle with `multiselect`; with `freeform`, every text change).\n * @deprecated Use `onValueChange`.\n */\n onOptionSelect?: (value: string) => void;\n /**\n * Controlled open state of the listbox. The list renders only in the browser: an open combobox\n * is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state for uncontrolled usage. A combobox that starts disabled or read-only\n * starts closed. The list renders only in the browser: it is closed in the server HTML and opens\n * once the combobox has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /** Called when the listbox opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Placeholder text shown when no value is selected; with `multiselect`, whenever the input shows\n * no selected labels (no value is selected, or no selected value has an option).\n */\n placeholder?: string;\n /**\n * Whether the combobox is disabled and non-interactive.\n * @default false\n */\n disabled?: boolean;\n /**\n * Size of the field: `small` (24px tall), `medium` (32px) or `large` (40px). Default: the\n * surrounding Field's `size`, else `WaveProvider inputDefaults.size`, else `'medium'`. The\n * listbox keeps its size.\n */\n size?: CoreSize;\n /**\n * Look of the field: `outline` (a full border), `underline` (a bottom stroke only),\n * `filled-darker` or `filled-lighter` (a fill without a visible stroke: give the field a visible\n * label). Default: `WaveProvider inputDefaults.appearance`, else `'outline'`.\n */\n appearance?: InputAppearance;\n /**\n * Whether the typed text is itself the value. Without it, typing only filters the options (the\n * first match becomes active, so Enter selects it) and the input shows the selected option's\n * label again when the listbox closes or loses focus. With it, the input shows typed text as\n * typed (also when it equals an option's value), a selected option's label, and a controlled\n * `value` as soon as the parent sets it (a parent that normalizes or rejects the text). Not\n * available with `multiselect` (a type error there): free text cannot be one of several values.\n * @default false\n */\n freeform?: M extends true ? never : boolean;\n /**\n * Whether an option matches the typed text (the query, or with `freeform` the typed value).\n * Called with every option that is not hidden (its `value`, `label` and `textValue`) and the\n * text whenever the text is not empty; an option it returns `false` for is filtered out. It may\n * keep options that do not contain the text: `filter={() => true}` with `query` and\n * `onQueryChange` leaves the matching to you (a server-side search that replaces the options),\n * and a filter that always keeps an option of your own gives a \"Create …\" entry. With a\n * server-side search, keep the selected option among the children, `hidden` while the results\n * leave it out: a value without an option shows no label (the \"Async search\" story does this).\n * @default a case-insensitive substring match on the option's `textValue`, else its `label`\n */\n filter?: (option: ListboxItem, query: string) => boolean;\n /**\n * Controlled query: the text typed since the last commit, which filters the options. A\n * non-empty query shows in the input (hidden while `disabled` or `readOnly`); `''` shows the\n * selected option's label (the selected labels with `multiselect`), except while the user edits\n * the text, so erased text stays empty. Not used with `freeform`, where the typed text is the\n * value.\n */\n query?: string;\n /**\n * Initial query for uncontrolled usage. A Combobox that starts disabled or read-only starts\n * without it (as it starts closed). Not used with `freeform`.\n * @default ''\n */\n defaultQuery?: string;\n /**\n * Called with the new query when it changes: as the user types, and with `''` when it resets (a\n * commit, a close, a blur, Escape, the clear button, a form reset, or `disabled` or `readOnly`\n * turned on while text is typed). A Combobox that mounts disabled or read-only reports nothing:\n * it keeps a controlled query, which shows once it unlocks. Never called with `freeform`.\n */\n onQueryChange?: (query: string) => void;\n /**\n * Called after the active (highlighted) option changes — opening, arrow keys, the pointer, a\n * filter change that moves it — and with `null` when the list closes. It reports what\n * `aria-activedescendant` points at, from an effect once the change commits. Fluent's\n * `onActiveOptionChange` reports neither the pointer (its options have no hover highlight) nor\n * the close.\n */\n onActiveOptionChange?: (value: string | null) => void;\n /**\n * Keeps disabled options in the arrow-key order (the first match highlighted while typing may\n * then be a disabled one too); they still cannot be selected (Enter and a click do nothing and\n * the list stays open). Unlike Fluent, which always keeps disabled options reachable, WaveUI\n * skips them by default.\n * @default false\n */\n disabledOptionsFocusable?: boolean;\n /**\n * Name of the value in form submissions (renders a hidden input; one per value with\n * `multiselect`).\n */\n name?: string;\n /** Id of the form the value belongs to, when the Combobox is outside it. */\n form?: string;\n /**\n * A value is required to submit the form (native constraint validation). Like a native readonly\n * input, a `readOnly` Combobox does not block submission.\n */\n required?: boolean;\n /**\n * The `autocomplete` attribute of the `<input role=\"combobox\">`. Browser autofill is off unless\n * you set it (for example `'on'`).\n * @default 'off'\n */\n autoComplete?: string;\n /**\n * The maximum length of the typed text (`maxlength` of the `<input role=\"combobox\">`). With\n * `multiselect` the input has no limit while it shows the selected labels, so the limit applies\n * to the typed query only.\n */\n maxLength?: number;\n /**\n * The value cannot be changed: the input is read-only and the listbox neither opens (click,\n * keyboard, a controlled `open`) nor commits; Escape is left to the page. Turning it (or\n * `disabled`) on while the listbox is open closes it (`onOpenChange(false)`).\n */\n readOnly?: boolean;\n /**\n * Shows a clear button while a value is selected (not while `readOnly`; while `disabled` it is\n * shown disabled, as in DatePicker and TimePicker). It clears the value\n * (`onValueChange('')`; every value with `multiselect`, `onValueChange([])`), drops typed text,\n * closes the list and moves focus to the input. It is a tab stop after the input.\n * @default false\n */\n clearable?: boolean;\n /**\n * The glyph of the expand button at the end of the input (default: a chevron). The button\n * opens and closes the list without moving focus out of the input and is not a tab stop\n * (Alt+ArrowDown opens the list from the keyboard). `null` or `undefined` keep the chevron;\n * `false`, or a value that renders nothing, hides the button. Decorative content rendered\n * inside the built-in button: a `<button>` or `Button` passed here is not nested (its children\n * become the glyph, with a development warning).\n */\n expandIcon?: Slot<'span'>;\n /**\n * The built-in texts (the \"No matches\" status, the names of the clear and expand buttons and,\n * with `multiselect`, the selected-labels text and the toggle announcements), for localization.\n * Unset members keep their English defaults.\n */\n labels?: ComboboxLabels;\n /**\n * Called when the `<input role=\"combobox\">` receives focus (the root keeps other handlers).\n * With `multiselect`, a focus while the input shows the selected labels then selects them;\n * `event.preventDefault()` skips that.\n */\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n /** Called when the `<input role=\"combobox\">` loses focus. */\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n /**\n * Called on a key press in the `<input role=\"combobox\">`, before the built-in listbox keys;\n * `event.preventDefault()` skips them.\n */\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Called when a key is released in the `<input role=\"combobox\">`. */\n onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Ref to the `<input role=\"combobox\">` (the focusable element). */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** The Combobox component's type: a multi-select signature, then the single-select one. */\nexport interface ComboboxComponent {\n (props: ComboboxProps<true> & { multiselect: true }): React.ReactNode;\n (props: ComboboxProps): React.ReactNode;\n displayName?: string;\n Option: typeof Option;\n OptionGroup: typeof OptionGroup;\n}\n\n/**\n * An edit a `beforeinput` event announced: its `inputType`, and the selection it replaces, recorded\n * before the edit changes it. `range` is `null` where the edit does not replace the selection: a\n * drop inserts at the drop point, and an undo or a redo restores earlier text.\n */\ninterface AnnouncedEdit {\n inputType: string;\n range: readonly [number, number] | null;\n}\n\n/** The edits that restore earlier text: D11 rule 3 applies to them (R17). */\nconst HISTORY_EDITS: ReadonlySet<string> = new Set(['historyUndo', 'historyRedo']);\n\n/**\n * How the control came to be locked (`disabled` or `readOnly`): not at all, by a change while\n * mounted, or since it mounted.\n */\ntype LockState = 'unlocked' | 'locked' | 'mounted-locked';\n\n/** The default `filter` (0.7's match): a case-insensitive substring of `textValue ?? label`. */\nfunction matchesText(item: ListboxItem, text: string): boolean {\n return (item.textValue ?? item.label).toLowerCase().includes(text.toLowerCase());\n}\n\nconst ComboboxRoot = (props: ComboboxProps<boolean>) => {\n const {\n multiselect = false,\n value: valueProp,\n defaultValue,\n onValueChange,\n onOptionSelect,\n open: openProp,\n defaultOpen,\n onOpenChange,\n placeholder,\n disabled = false,\n size: sizeProp,\n appearance: appearanceProp,\n freeform: freeformProp = false,\n filter,\n query: queryProp,\n defaultQuery,\n onQueryChange,\n onActiveOptionChange,\n disabledOptionsFocusable = false,\n name,\n form,\n required,\n autoComplete = 'off',\n autoCapitalize,\n autoCorrect,\n maxLength,\n readOnly,\n clearable = false,\n expandIcon,\n labels,\n inputMode,\n spellCheck,\n enterKeyHint,\n autoFocus,\n tabIndex,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n children,\n ref,\n ...rest\n } = props;\n\n if (onOptionSelect !== undefined) warnDeprecated('Combobox', 'onOptionSelect', 'onValueChange');\n\n // The multi-select signature has no `freeform` (D11); passed anyway from JavaScript, it is\n // ignored there, with a warning.\n const freeform = freeformProp && !multiselect;\n const freeformIgnored = freeformProp && multiselect;\n React.useEffect(() => {\n if (freeformIgnored) {\n warnOnce(\n 'Combobox:freeform-multiselect',\n 'Combobox: `freeform` is not available with `multiselect`: a multi-select Combobox ' +\n 'selects options only.',\n );\n }\n }, [freeformIgnored]);\n // With `freeform` the typed text is the value, so the query props are unused (D12).\n const queryIgnored = freeform && (queryProp !== undefined || defaultQuery !== undefined);\n React.useEffect(() => {\n if (queryIgnored) {\n warnOnce(\n 'Combobox:query-freeform',\n 'Combobox: `query` and `defaultQuery` are not used with `freeform`: the typed text is the ' +\n 'value (`value`, `onValueChange`).',\n );\n }\n }, [queryIgnored]);\n\n const field = useFieldContext();\n const isRequired = required ?? field?.required ?? false;\n const validates = isRequired && !readOnly;\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required matches\n // `isRequired`.\n 'aria-required': ariaRequired ?? required,\n });\n // The error look follows the resolved state: the consumer's `aria-invalid` or the Field's.\n const invalidLook = isInvalidLook(false, fieldProps['aria-invalid']);\n const { size, appearance } = useInputLook(sizeProp, appearanceProp);\n\n const [value, setValue] = useControllable<string | readonly string[]>(\n valueProp,\n defaultValue ?? (multiselect ? EMPTY_VALUES : ''),\n (next) => {\n // The two call signatures make `onValueChange` a union of incompatible functions from here:\n // the root itself is written against the wider, internal shape (D9).\n (onValueChange as ((value: string | string[]) => void) | undefined)?.(\n typeof next === 'string' ? next : [...next],\n );\n },\n );\n // The selected values, for the listbox and the multi-select paths: a single value is its own\n // one-element array, and a `value` passed as `null` from JavaScript (bypassing the type system)\n // is none rather than a crash, as 0.7 did for the single-select string.\n const values = toValues(value);\n // The single-select value as 0.7 read it.\n const single = multiselect ? '' : (value as string);\n\n const interactive = !disabled && !readOnly;\n // A combobox that starts disabled or read-only never shows its list, so it starts closed (no\n // close to report later).\n const [openState, setOpen] = useControllable(\n openProp,\n (defaultOpen ?? false) && interactive,\n onOpenChange,\n );\n const open = openState && interactive;\n // The query (D12): the text typed since the last commit, which filters the options, and\n // `editing`, set while the user edits it, so erased text stays empty instead of showing the\n // committed value. A Combobox that starts locked starts without a query, as it starts closed.\n // Freeform: the text is the value, so the query is unused (`onQueryChange` is never called)\n // and 0.7's draft follows the text instead.\n const [query, setQuery] = useControllable(\n freeform ? undefined : queryProp,\n interactive ? (defaultQuery ?? '') : '',\n freeform ? undefined : onQueryChange,\n );\n const [editing, setEditing] = React.useState(false);\n const [freeformDraft, setFreeformDraft] = React.useState<string | null>(null);\n // Text typed since the last commit, the filter; `null` shows the committed value's label\n // (input-pickers#7), or the selected labels with `multiselect`: the query while it is not empty\n // or the user edits it, and never while locked. Freeform: the input shows the value, and the\n // draft follows that text.\n const draft = freeform ? freeformDraft : interactive && (editing || query !== '') ? query : null;\n // Locking the control (readOnly/disabled) while typing drops the typed text, so the input shows\n // the committed value again: hidden during render above, the editing state and the freeform\n // draft dropped here (adjust-during-render pattern, C-HOOKS), and the query reset reported from\n // an effect, since `onQueryChange` never runs during render (D12). `lock` is how the control\n // came to be locked: `'locked'` by a change while mounted, whose reset is reported once, or\n // `'mounted-locked'` since it mounted, which reports nothing and keeps a controlled query,\n // hidden until the control unlocks (R20).\n const [lock, setLock] = React.useState<LockState>(interactive ? 'unlocked' : 'mounted-locked');\n if (interactive && lock !== 'unlocked') {\n setLock('unlocked');\n } else if (!interactive && lock === 'unlocked') {\n setLock('locked');\n setEditing(false);\n setFreeformDraft(null);\n }\n React.useEffect(() => {\n if (lock === 'locked') setQuery('');\n }, [lock, setQuery]);\n // Locking also closes the list itself, not only the derived `open`, so unlocking does not reopen\n // it without a user action. The close is reported through onOpenChange (a consumer callback from\n // an effect, C-HOOKS); a controlled `open` that stays true is still not shown while locked.\n const lockedOpen = !interactive && openState;\n React.useEffect(() => {\n if (lockedOpen) setOpen(false);\n }, [lockedOpen, setOpen]);\n\n // Freeform: the value the user typed last. While the value still equals it, the input shows it\n // as typed, even when it equals an option's value (not that option's label).\n const [typedValue, setTypedValue] = React.useState<string | null>(null);\n\n const rootRef = React.useRef<HTMLDivElement | null>(null);\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n\n const optionLabels = React.useMemo(() => collectOptionLabels(children), [children]);\n // useListbox's navigability predicate: `filter` (else the 0.7 match) bound to the typed text,\n // while there is any (D13).\n const filterText = draft ?? '';\n const listFilter = React.useMemo(\n () =>\n filterText ? (item: ListboxItem) => (filter ?? matchesText)(item, filterText) : undefined,\n [filterText, filter],\n );\n\n // 0.7's `setDraft(text)`: the typed text becomes `text` (the query, reported, while editing).\n const editDraft = (text: string) => {\n if (freeform) {\n setFreeformDraft(text);\n } else {\n setEditing(true);\n setQuery(text);\n }\n };\n // 0.7's `setDraft(null)`: the typed text is dropped, so the input shows the committed value\n // again (the query resets to `''`).\n const dropDraft = () => {\n if (freeform) {\n setFreeformDraft(null);\n } else {\n setEditing(false);\n setQuery('');\n }\n };\n\n const commitText = (text: string) => {\n setTypedValue(text);\n setValue(text);\n onOptionSelect?.(text);\n };\n\n const close = () => {\n setOpen(false);\n dropDraft();\n };\n\n // APG: Escape on a closed listbox clears the textbox. Freeform: the text is the value, so it is\n // cleared. Otherwise only a typed filter is dropped (the input shows the selected label again);\n // without one there is nothing to clear and Escape is left to the page.\n let clearDraft: (() => void) | undefined;\n if (freeform) {\n clearDraft = () => {\n setFreeformDraft(null);\n commitText('');\n };\n } else if (draft) {\n clearDraft = dropDraft;\n }\n\n const listbox = useListbox({\n open,\n onOpenChange: (next) => {\n if (next) setOpen(true);\n else close();\n },\n mode: 'editable',\n multiselect,\n disabledOptionsFocusable,\n selectedValues: values,\n onSelect: (next, details) => {\n if (!multiselect) {\n // 0.7 order: the value callback first, the deprecated one after.\n setValue(next);\n onOptionSelect?.(next);\n dropDraft();\n setTypedValue(null);\n return;\n }\n const { values: updated, added } = toggleValue(values, next);\n setValue(updated);\n onOptionSelect?.(next);\n // The toggled option's label: the item useListbox passed in `details` (its own result,\n // `listbox`, cannot be read from inside the options object passed to it), else the label\n // read from `children` before the option registered, else the raw value. Announces a\n // toggle the user made (D41): never a controlled change, a clear or a form reset, none of\n // which reach this callback.\n announceToggle(\n labels,\n details?.item.label ?? optionLabels.get(next) ?? next,\n added,\n updated.length,\n );\n // A toggle clears the query, so the labels show again, selected (R18); the list stays open\n // (D11).\n dropDraft();\n },\n filter: listFilter,\n // Typing a filter makes its first match active (like Fluent's Combobox), so Enter selects what\n // the list shows instead of submitting the form. Nothing is active on open or with the text\n // cleared. Freeform: the text is the value, so Enter keeps it unless the user moved to an\n // option.\n autoHighlight: !freeform && draft ? 'first' : false,\n onActiveValueChange: onActiveOptionChange,\n idPrefix: 'combobox-listbox',\n onClearDraft: clearDraft,\n });\n\n const labelOf = (v: string) => listbox.getItem(v)?.label ?? optionLabels.get(v);\n // Multi-select: the selected labels in selection order, values without an option left out\n // (D10), joined by `labels.selection`.\n let labelsText = '';\n if (multiselect) {\n const shown = values.map(labelOf).filter((label): label is string => label !== undefined);\n if (shown.length > 0) labelsText = (labels?.selection ?? defaultSelectionLabel)(shown);\n }\n // Multi-select: while no text is typed, the input shows the selected labels (D11); without any\n // (no value, or no selected value with an option) it shows its placeholder, as a Dropdown does.\n const showingLabels = multiselect && draft === null && labelsText !== '';\n\n // The input text. Multi-select: the typed query, else the selected labels. Freeform: the value\n // as typed while it is the value the user typed last, else the label of the option with that\n // value, else the value itself — so the text follows a controlled parent that normalizes or\n // rejects what was typed while the input still has focus. Otherwise: the typed filter, else the\n // selected option's label.\n const optionLabel = single ? labelOf(single) : undefined;\n let inputText: string;\n if (multiselect) inputText = draft ?? labelsText;\n else if (freeform) inputText = single === typedValue ? single : (optionLabel ?? single);\n else inputText = draft ?? optionLabel ?? '';\n // Freeform: the filter follows the text (adjust-during-render pattern, C-HOOKS; the text does not\n // depend on the filter, so this settles in one pass).\n if (freeform && freeformDraft !== null && freeformDraft !== inputText) {\n setFreeformDraft(inputText);\n }\n\n const expanded = open && listbox.items.length > 0;\n const noMatchesText = labels?.noMatches ?? 'No matches';\n // The popup shows the list, or \"No matches\" for a draft.\n const surfaceOpen = open && (expanded || !!draft);\n const noMatches = surfaceOpen && !expanded;\n const { layerId, setReference, surfaceRef, floatingProps } = useListboxPopup({\n open,\n surfaceOpen,\n onDismiss: close,\n rootRef,\n anchorRef: inputRef,\n });\n\n const rootMergedRef = useMergedRefs<HTMLDivElement>(rootRef, ref);\n const inputMergedRef = useMergedRefs<HTMLInputElement>(inputRef, controlRef, setReference);\n\n useFormReset(\n inputRef,\n () => {\n if (multiselect) {\n // Compared by content (C-FORMS), so a reset that keeps the same values reports nothing.\n setValue((current) => resetValues(current, defaultValue));\n } else {\n setValue(defaultValue ?? '');\n }\n dropDraft();\n setTypedValue(null);\n },\n form,\n );\n\n // D11 rule 1: focusing the input while it shows the labels (Tab, a click, a Field label) selects\n // them, so an edit of any kind replaces them natively, without the value being rewritten during\n // the edit. A pointer press sets the caret on its mouseup, which would drop that selection, so\n // the mouseup of the press that focused the input is prevented (only that one: a later press in\n // the focused input places the caret as usual). The ref is written in handlers only (C-HOOKS).\n const pointerFocusRef = React.useRef(false);\n const handleMouseDown = (event: React.MouseEvent<HTMLInputElement>) => {\n pointerFocusRef.current = showingLabels && !isFocused(event.currentTarget);\n };\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n if (showingLabels) event.currentTarget.select();\n };\n const handleMouseUp = (event: React.MouseEvent<HTMLInputElement>) => {\n if (!pointerFocusRef.current) return;\n pointerFocusRef.current = false;\n event.preventDefault();\n };\n // Rule 1 also holds whenever the labels return to the focused input (R18): a toggle, a close\n // from the keyboard, a controlled change or a form reset writes them with the caret at their\n // end, so they are selected again here. A press that moves the caret into them changes neither\n // dependency, so the caret stays and rule 2 takes what is typed there.\n React.useLayoutEffect(() => {\n const input = inputRef.current;\n if (showingLabels && input && isFocused(input)) input.select();\n }, [showingLabels, labelsText]);\n\n // Multi-select: the edit a `beforeinput` announced (the last moment before an edit of any kind,\n // with the selection it replaces still in place; React has no event for it), for the change\n // that follows.\n const announcedEditRef = React.useRef<AnnouncedEdit | null>(null);\n // Multi-select: an edit that leaves the text as it was (the labels replaced by the same text: a\n // one-letter label typed again, a paste of exactly the labels) changes no value, so React reports\n // no change for it, while a browser fires `input` for every edit. Typing the labels' text is a\n // query (R17), so this listener starts it; an undo or a redo keeps rule 3 (the labels show, with\n // no query). The event is remembered, so a change React does report for it is not handled twice.\n const handledInputRef = React.useRef<Event | null>(null);\n const handleUnchangedEdit = useEventCallback((event: Event) => {\n const input = event.currentTarget as HTMLInputElement;\n if (!showingLabels || input.value !== labelsText) return;\n announcedEditRef.current = null;\n if (HISTORY_EDITS.has((event as Partial<InputEvent>).inputType ?? '')) return;\n handledInputRef.current = event;\n editDraft(labelsText);\n if (!open) setOpen(true);\n });\n React.useEffect(() => {\n const input = inputRef.current;\n if (!multiselect || !input) return;\n const record = (event: InputEvent) => {\n const { inputType } = event;\n const { selectionStart, selectionEnd } = input;\n announcedEditRef.current = {\n inputType,\n range:\n inputType === 'insertFromDrop' ||\n HISTORY_EDITS.has(inputType) ||\n selectionStart === null ||\n selectionEnd === null\n ? null\n : [selectionStart, selectionEnd],\n };\n };\n input.addEventListener('beforeinput', record);\n input.addEventListener('input', handleUnchangedEdit);\n return () => {\n input.removeEventListener('beforeinput', record);\n input.removeEventListener('input', handleUnchangedEdit);\n };\n }, [multiselect, handleUnchangedEdit]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && open && !surfaceOpen && !event.nativeEvent.isComposing) {\n // Open with nothing shown (no options): close as a closed list would handle Escape — clear\n // the text if there is any, otherwise leave the key to an enclosing layer (overlays#1).\n close();\n if (clearDraft && event.currentTarget.value !== '') {\n event.preventDefault();\n clearDraft();\n }\n return;\n }\n listbox.onKeyDown(event);\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (event.nativeEvent === handledInputRef.current) return;\n const text = event.target.value;\n // The edit the last `beforeinput` announced, if this change is that edit. A change nothing\n // announced (autofill, an extension, a script) has none, and neither has one after an edit\n // that was announced and then not made (cancelled, or blocked).\n const announced = announcedEditRef.current;\n announcedEditRef.current = null;\n const edit =\n announced && announced.inputType === (event.nativeEvent as { inputType?: string }).inputType\n ? announced\n : null;\n if (!multiselect) {\n editDraft(text);\n } else if (text === labelsText && (edit === null || HISTORY_EDITS.has(edit.inputType))) {\n // D11 rule 3, for an undo or a redo (R17): text equal to the labels shows them again, with\n // no query. Any other edit that leaves their text, typed or pasted, is a query.\n dropDraft();\n } else if (showingLabels) {\n // D11 rule 2: the query is the text the edit inserted into the labels. With the selection\n // the edit replaced (all of the labels after a focus, rule 1), that is the text now in its\n // place, however much of it looks like the labels (R16); without one (a drop, an undo or a\n // redo, an edit the input did not announce), the new value without the part it shares with\n // the labels at its start and its end. Backspace and Delete leave an empty query and never\n // remove a value (rule 4).\n const range = edit?.range;\n editDraft(\n (range && replacedText(labelsText, text, range[0], range[1])) ??\n insertedText(labelsText, text),\n );\n } else {\n editDraft(text);\n }\n if (!open) setOpen(true);\n if (freeform) commitText(text);\n };\n\n // The expand button opens and closes the list like the input's own keys; focus stays in (or\n // returns to) the input.\n const handleExpandClick = () => {\n if (!interactive) return;\n if (open) close();\n else setOpen(true);\n inputRef.current?.focus();\n };\n\n // Clearing is not an option activation: the state is set directly, not through `commitText`\n // (which calls the deprecated `onOptionSelect` in freeform mode). The button disappears with the\n // value, so focus moves to the input explicitly (C-DISABLED).\n const handleClear = () => {\n setValue(multiselect ? EMPTY_VALUES : '');\n setTypedValue(null);\n dropDraft();\n setOpen(false);\n inputRef.current?.focus();\n };\n\n const showExpand = showsExpandButton(expandIcon);\n // Read-only comboboxes offer no clear action (the value cannot change).\n const showClear = clearable && (multiselect ? values.length > 0 : single !== '') && !readOnly;\n\n const listLabelledBy =\n fieldProps['aria-label'] === undefined\n ? (fieldProps['aria-labelledby'] ?? field?.labelId)\n : fieldProps['aria-labelledby'];\n\n return (\n <div\n data-size={size}\n data-appearance={appearance}\n {...rest}\n ref={rootMergedRef}\n className={cn(comboboxClassNames.root, 'relative inline-flex flex-col', className)}\n >\n {multiselect && <PickerAnnouncer />}\n <div className=\"relative flex items-center\">\n <input\n type=\"text\"\n autoComplete={autoComplete}\n {...fieldProps}\n {...listbox.getComboboxProps()}\n aria-expanded={expanded}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n ref={inputMergedRef}\n disabled={disabled}\n readOnly={readOnly}\n // Multi-select: the selected labels take the placeholder's place (D11).\n placeholder={multiselect && labelsText !== '' ? undefined : placeholder}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n // Multi-select: no limit while the labels show, so typing into them (the caret moved\n // there) is never blocked; the limit applies to the typed query only.\n maxLength={showingLabels ? undefined : maxLength}\n inputMode={inputMode}\n spellCheck={spellCheck}\n enterKeyHint={enterKeyHint}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n value={inputText}\n onChange={handleChange}\n onClick={() => {\n if (!open && interactive) setOpen(true);\n }}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n // Read-only: no listbox keys at all (they would open, commit or clear the value).\n onKeyDown={composeEventHandlers(onKeyDown, readOnly ? undefined : handleKeyDown)}\n onKeyUp={composeEventHandlers(onKeyUp, listbox.onKeyUp)}\n onFocus={composeEventHandlers(onFocus, handleFocus)}\n onBlur={composeEventHandlers(onBlur, dropDraft, {\n checkDefaultPrevented: false,\n })}\n className={cn(\n comboboxClassNames.input,\n inputHeightClasses[size],\n 'w-full',\n inputPaddingClasses[size],\n inputTextClasses[size],\n inputAppearanceClasses[appearance],\n 'text-foreground placeholder:text-muted-foreground',\n inputFocus,\n disabledStyles,\n invalidLook && inputInvalid,\n pickerEndPadding(Number(showClear) + Number(showExpand), size),\n )}\n />\n {showClear && (\n <button\n type=\"button\"\n aria-label={labels?.clear ?? 'Clear selection'}\n disabled={disabled}\n // Keeps focus in the input, so its blur does not act on a draft before the clear.\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleClear}\n className={cn(\n comboboxClassNames.clearButton,\n pickerIconButtonClasses(size, appearance),\n pickerButtonOffset(size, showExpand ? 2 : 1),\n focusRing,\n disabledStyles,\n )}\n >\n <DismissIcon size={pickerGlyphSize(size, 'icon')} />\n </button>\n )}\n {showExpand && (\n <PickerExpandButton\n component=\"Combobox\"\n expandIcon={expandIcon}\n label={labels?.expand ?? 'Show options'}\n expanded={expanded}\n listboxId={listbox.listboxId}\n disabled={disabled || !!readOnly}\n onToggle={handleExpandClick}\n size={size}\n appearance={appearance}\n className={comboboxClassNames.expandButton}\n iconClassName={comboboxClassNames.expandIcon}\n />\n )}\n </div>\n {/* Mounted before its text: a live region added together with its text is not announced by\n every screen reader. The row in the popup is the visible copy. */}\n <span role=\"status\" className=\"sr-only\">\n {noMatches && noMatchesText}\n </span>\n <ListboxSurface\n listbox={listbox}\n layerId={layerId}\n surfaceRef={surfaceRef}\n floatingProps={floatingProps}\n open={open}\n expanded={expanded}\n listClassName={comboboxClassNames.listbox}\n surfaceClassName={comboboxClassNames.surface}\n emptyContent={\n draft ? (\n <div\n aria-hidden=\"true\"\n className={cn(\n comboboxClassNames.emptyMessage,\n 'px-3 py-1.5 text-body-1 text-muted-foreground',\n )}\n >\n {noMatchesText}\n </div>\n ) : undefined\n }\n aria-label={fieldProps['aria-label']}\n aria-labelledby={listLabelledBy}\n >\n {children}\n </ListboxSurface>\n <HiddenInput\n name={name}\n form={form}\n disabled={disabled}\n value={multiselect ? values : single}\n type=\"text\"\n // Like a native readonly input, a read-only Combobox is barred from constraint validation\n // (the user could not fix it); its value is still submitted.\n required={validates}\n onInvalid={() => inputRef.current?.focus()}\n />\n </div>\n );\n};\nComboboxRoot.displayName = 'Combobox';\n\n/** Flat name of `Combobox.Option` for React Server Components. */\nexport const ComboboxOption = Option;\n/** Flat name of `Combobox.OptionGroup` for React Server Components. */\nexport const ComboboxOptionGroup = OptionGroup;\n\n/**\n * An editable combobox: a text input with a filterable listbox of `Option`s (APG combobox with\n * list autocomplete). Typing filters the options; ArrowDown/ArrowUp move the highlight\n * (`aria-activedescendant`), Enter selects, Escape closes. Without `freeform` the text is only a\n * filter: its first match becomes active while typing, and the input shows the selected option's\n * label again when the listbox closes. With `freeform` the text itself is the value. Text that\n * matches no option shows \"No matches\" (`labels.noMatches`), announced through a status region.\n * `filter` replaces the match (it may keep options that do not contain the text, for a server-side\n * search or a \"Create …\" entry), and `query`/`defaultQuery`/`onQueryChange` control the typed\n * text (not with `freeform`), which resets to `''` on a commit, a close, a blur, Escape, the clear\n * button and a form reset. The expand button at the end of the input (a chevron, see\n * `expandIcon`) opens and closes the list without taking focus from the input and is not a tab\n * stop; `clearable` adds a clear button, a tab stop after the input. Both sit with the input in a\n * wrapper `<div>` inside the root.\n *\n * `multiselect` turns the value into an array (Fluent's `selectedOptions`): options draw a\n * checkbox; Enter and a click toggle an option and keep the list open (Tab, Escape and\n * Alt+ArrowUp close without committing), and every toggle the user makes is announced\n * (`labels.added`/`labels.removed`, never for a controlled change, a clear or a form reset).\n * While no text is typed the input shows the selected labels in selection order\n * (`labels.selection`, values without an option left out) instead of the placeholder. Focusing\n * the input selects them, and so does their return to the focused input (a toggle, a close, a\n * form reset), so typing, pasting or composing text replaces them with a query that filters the\n * options; text inserted into them queries only what was inserted, an undo or a redo back to them\n * shows them again, and a toggle, a close or a blur clears the query. Backspace and Delete only\n * edit the text: the options, the clear button (which clears every value) and a form reset change\n * the value. `freeform` is not available with `multiselect`, and a non-literal\n * `multiselect={flag}` is a type error: render two elements, one for each mode.\n *\n * The `<input>` receives `id`, `aria-label`, `aria-labelledby`, `aria-describedby`,\n * `aria-invalid`, `aria-required`, `aria-errormessage`, `aria-details`, `tabIndex`, `autoFocus`,\n * `onFocus`/`onBlur`/`onKeyDown`/`onKeyUp` and the text input attributes `autoComplete`,\n * `autoCapitalize`, `autoCorrect`, `maxLength`, `inputMode`, `spellCheck` and `enterKeyHint`.\n * `ref`, `className`, `style`, other `aria-*` attributes and the remaining props stay on the root\n * `<div>`. Inside a `Field` the input is labelled and described by it. It shows the error look\n * whenever it ends up `aria-invalid` (its own `aria-invalid` or a `Field` error). With\n * `name`/`required` the value takes part in form submission (one hidden input per value with\n * `multiselect`), validation and reset (a `multiselect` reset is compared by content, so restoring\n * the same values reports nothing). The open listbox renders in a portal; while closed it stays\n * in the DOM, hidden.\n *\n * **Size and appearance**: `size` resolves from its own prop, then the surrounding `Field`'s\n * `size`, then `WaveProvider inputDefaults.size`, else `'medium'`; `appearance` from its own prop,\n * then `WaveProvider inputDefaults.appearance`, else `'outline'`; both render as `data-size` and\n * `data-appearance` on the root `<div>`. The listbox keeps its size.\n *\n * Sub-components: `Combobox.Option`, `Combobox.OptionGroup`. React Server Components import the\n * flat names `ComboboxOption` / `ComboboxOptionGroup` (dotted access needs a client file).\n */\nexport const Combobox = /* @__PURE__ */ Object.assign(ComboboxRoot, {\n Option,\n OptionGroup,\n}) as ComboboxComponent;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyTA,IAAMC,oBAAqC,IAAI,IAAI,CAAC,eAAe,aAAa,CAAC;AASjF,SAASC,GAAY,GAAmB,GAAuB;CAC7D,QAAQC,EAAK,aAAaA,EAAK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KAETN,KACC,kBAAC8B,IAAD;MACE,WAAU;MACE;MACZ,OAAOjF,GAAQ,UAAU;MACf;MACV,WAAWL,EAAQ;MACnB,UAAUhC,KAAY,CAAC,CAAChB;MACxB,UAAUsG;MACJ;MACM;MACZ,WAAWW,EAAmB;MAC9B,eAAeA,EAAmB;KACnC,CAAA;IAEA;;GAGL,kBAAC,QAAD;IAAM,MAAK;IAAS,WAAU;IAC3B,UAAA5C,MAAaF;GACV,CAAA;GACN,kBAACoE,IAAD;IACW;IACA;IACG;IACG;IACT;IACI;IACV,eAAetB,EAAmB;IAClC,kBAAkBA,EAAmB;IACrC,cACEpF,IACE,kBAAC,OAAD;KACE,eAAY;KACZ,WAAWmF,EACTC,EAAmB,cACnB,+CACF;KAEC,UAAA9C;IACE,CAAA,IACH,KAAA;IAEN,cAAYlE,EAAW;IACvB,mBAAiB4G;IAEhB;GACa,CAAA;GAChB,kBAAC2B,IAAD;IACQ;IACA;IACI;IACV,OAAOjJ,IAAcqB,IAASE;IAC9B,MAAK;IAGL,UAAUhB;IACV,iBAAiBsC,EAAS,SAAS,MAAM;GAC1C,CAAA;EACE;;AAET;AACA,EAAa,cAAc;AAG3B,IAAaqG,IAAiBC,GAEjBC,KAAsBC,GAmDtBC,IAA2B,uBAAO,OAAOzK,GAAc;CAClE;CACA;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"Combobox.mjs","names":["React","HISTORY_EDITS","matchesText","item","text","ComboboxRoot","valueProp","openProp","sizeProp","appearanceProp","freeformProp","queryProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","props","onOptionSelect","warnDeprecated","freeform","multiselect","freeformIgnored","warnOnce","queryIgnored","defaultQuery","field","useFieldContext","validates","required","readOnly","fieldProps","useFieldControl","invalidLook","isInvalidLook","useInputLook","value","setValue","useControllable","defaultValue","EMPTY_VALUES","next","values","toValues","single","interactive","disabled","openState","setOpen","defaultOpen","onOpenChange","open","query","setQuery","onQueryChange","editing","setEditing","freeformDraft","setFreeformDraft","draft","lock","setLock","lockedOpen","typedValue","setTypedValue","rootRef","inputRef","optionLabels","collectOptionLabels","children","filterText","listFilter","filter","editDraft","dropDraft","commitText","close","clearDraft","listbox","useListbox","updated","toggleValue","announceToggle","labels","details","added","onActiveOptionChange","labelOf","v","labelsText","shown","label","defaultSelectionLabel","showingLabels","optionLabel","inputText","expanded","noMatchesText","surfaceOpen","noMatches","useListboxPopup","rootMergedRef","useMergedRefs","ref","inputMergedRef","controlRef","setReference","resetValues","current","form","pointerFocusRef","handleMouseDown","isFocused","event","handleFocus","handleMouseUp","input","announcedEditRef","handledInputRef","handleUnchangedEdit","useEventCallback","record","inputType","selectionStart","selectionEnd","handleKeyDown","handleChange","announced","edit","range","replacedText","insertedText","handleExpandClick","handleClear","showExpand","showsExpandButton","expandIcon","showClear","clearable","listLabelledBy","size","appearance","cn","comboboxClassNames","className","PickerAnnouncer","placeholder","maxLength","composeEventHandlers","onKeyDown","onKeyUp","onFocus","onBlur","inputHeightClasses","inputPaddingClasses","inputTextClasses","inputAppearanceClasses","inputFocus","disabledStyles","pickerEndPadding","pickerIconButtonClasses","pickerButtonOffset","DismissIcon","pickerGlyphSize","PickerExpandButton","ListboxSurface","HiddenInput","ComboboxOption","Option","ComboboxOptionGroup","OptionGroup","Combobox"],"sources":["../../../src/components/input/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { comboboxClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { isFocused } from '../../lib/focus';\nimport { DismissIcon } from '../../lib/icons';\nimport type { Slot } from '../../lib/slot';\nimport {\n disabledStyles,\n focusRing,\n inputAppearanceClasses,\n inputFocus,\n inputHeightClasses,\n inputInvalid,\n inputPaddingClasses,\n inputTextClasses,\n} from '../../lib/styles';\nimport type { CoreSize, InputAppearance, PopupPositioningOptions } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { collectOptionLabels, useListbox, type ListboxItem } from '../../hooks/useListbox';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { PickerExpandButton, showsExpandButton } from './Combobox.expand';\nimport { insertedText, replacedText } from './Combobox.text';\nimport { useInputLook } from './inputLook';\nimport { isInvalidLook } from './Input';\nimport { ListboxSurface, Option, OptionGroup, useListboxPopup } from './Option';\nimport { announceToggle, defaultSelectionLabel, PickerAnnouncer } from './pickerLabels';\nimport {\n pickerButtonOffset,\n pickerEndPadding,\n pickerGlyphSize,\n pickerIconButtonClasses,\n} from './pickerStyles';\nimport { EMPTY_VALUES, resetValues, toggleValue, toValues } from './pickerValues';\nimport type { RoutedHandlers } from './routedHandlers';\n\nexport { Option, OptionGroup } from './Option';\nexport type { OptionProps, OptionGroupProps } from './Option';\n\n/* ------------------------------------------------------------------ */\n/* Combobox */\n/* ------------------------------------------------------------------ */\n\n/**\n * The Combobox's built-in texts, for localization. Each member is optional and falls back to its\n * English default.\n */\nexport interface ComboboxLabels {\n /** Status text (announced, and shown in the popup) when the typed text matches no option.\n * @default 'No matches'\n */\n noMatches?: string;\n /** Name of the clear button (`clearable`).\n * @default 'Clear selection'\n */\n clear?: string;\n /** Name of the expand button at the end of the input.\n * @default 'Show options'\n */\n expand?: string;\n /**\n * The text of the selected labels the input shows with `multiselect` while no text is typed, in\n * selection order; values without an option are left out.\n * @default (labels) => labels.join(', ')\n */\n selection?: (labels: string[]) => string;\n /**\n * Announced when a `multiselect` toggle selects an option; `count` is the number of values\n * selected after the change.\n * @default (label, count) => `${label} added, ${count} selected`\n */\n added?: (label: string, count: number) => string;\n /**\n * Announced when a `multiselect` toggle deselects an option; `count` is the number of values\n * selected after the change.\n * @default (label, count) => `${label} removed, ${count} selected`\n */\n removed?: (label: string, count: number) => string;\n}\n\n/** Properties for the Combobox component. */\nexport interface ComboboxProps<M extends boolean = false> extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | RoutedHandlers\n> {\n /**\n * Several options can be selected (Fluent's `multiselect`): the value is an array, options show\n * a checkbox, Enter and a click toggle an option and keep the list open, and each toggle is\n * announced. While no text is typed the input shows the selected labels, selected whenever the\n * input gains focus or they return to it, so typing replaces them with text that filters the\n * options. Not available with `freeform`. A non-literal `multiselect={flag}` is a type error:\n * render two elements, one for each mode.\n * @default false\n */\n multiselect?: M;\n /**\n * Controlled selected value (`''` for none), or with `multiselect` the selected values (Fluent's\n * `selectedOptions`).\n */\n value?: M extends true ? readonly string[] : string;\n /**\n * Initial selected value for uncontrolled usage.\n * @default '' (`[]` with `multiselect`)\n */\n defaultValue?: M extends true ? readonly string[] : string;\n /**\n * Called with the new value when it changes: an option is selected (toggled with `multiselect`,\n * which passes a new array), or (with `freeform`) the text changes. Without `multiselect` it is\n * not called when the current option is selected again; with it, activating a selected option\n * deselects it, which is a change. Fluent's `onOptionSelect`, under WaveUI's value/onValueChange\n * naming.\n */\n onValueChange?: M extends true ? (value: string[]) => void : (value: string) => void;\n /**\n * Called on every option activation, also when the current option is selected again (every\n * toggle with `multiselect`; with `freeform`, every text change).\n * @deprecated Use `onValueChange`.\n */\n onOptionSelect?: (value: string) => void;\n /**\n * Controlled open state of the listbox. The list renders only in the browser: an open combobox\n * is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state for uncontrolled usage. A combobox that starts disabled or read-only\n * starts closed. The list renders only in the browser: it is closed in the server HTML and opens\n * once the combobox has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /** Called when the listbox opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Placeholder text shown when no value is selected; with `multiselect`, whenever the input shows\n * no selected labels (no value is selected, or no selected value has an option).\n */\n placeholder?: string;\n /**\n * Whether the combobox is disabled and non-interactive.\n * @default false\n */\n disabled?: boolean;\n /**\n * Size of the field: `small` (24px tall), `medium` (32px) or `large` (40px). Default: the\n * surrounding Field's `size`, else `WaveProvider inputDefaults.size`, else `'medium'`. The\n * listbox keeps its size.\n */\n size?: CoreSize;\n /**\n * Advanced positioning of the popup (Fluent's `positioning`): `offset`, `fitViewport`,\n * `matchReferenceWidth` and `fallbackPlacements` (tried in order when the requested side has no\n * room). The popup opens below the field.\n * @default `{ matchReferenceWidth: true, fitViewport: true }`\n */\n positioning?: PopupPositioningOptions;\n /**\n * Look of the field: `outline` (a full border), `underline` (a bottom stroke only),\n * `filled-darker` or `filled-lighter` (a fill without a visible stroke: give the field a visible\n * label). Default: `WaveProvider inputDefaults.appearance`, else `'outline'`.\n */\n appearance?: InputAppearance;\n /**\n * Whether the typed text is itself the value. Without it, typing only filters the options (the\n * first match becomes active, so Enter selects it) and the input shows the selected option's\n * label again when the listbox closes or loses focus. With it, the input shows typed text as\n * typed (also when it equals an option's value), a selected option's label, and a controlled\n * `value` as soon as the parent sets it (a parent that normalizes or rejects the text). Not\n * available with `multiselect` (a type error there): free text cannot be one of several values.\n * @default false\n */\n freeform?: M extends true ? never : boolean;\n /**\n * Whether an option matches the typed text (the query, or with `freeform` the typed value).\n * Called with every option that is not hidden (its `value`, `label` and `textValue`) and the\n * text whenever the text is not empty; an option it returns `false` for is filtered out. It may\n * keep options that do not contain the text: `filter={() => true}` with `query` and\n * `onQueryChange` leaves the matching to you (a server-side search that replaces the options),\n * and a filter that always keeps an option of your own gives a \"Create …\" entry. With a\n * server-side search, keep the selected option among the children, `hidden` while the results\n * leave it out: a value without an option shows no label (the \"Async search\" story does this).\n * @default a case-insensitive substring match on the option's `textValue`, else its `label`\n */\n filter?: (option: ListboxItem, query: string) => boolean;\n /**\n * Controlled query: the text typed since the last commit, which filters the options. A\n * non-empty query shows in the input (hidden while `disabled` or `readOnly`); `''` shows the\n * selected option's label (the selected labels with `multiselect`), except while the user edits\n * the text, so erased text stays empty. Not used with `freeform`, where the typed text is the\n * value.\n */\n query?: string;\n /**\n * Initial query for uncontrolled usage. A Combobox that starts disabled or read-only starts\n * without it (as it starts closed). Not used with `freeform`.\n * @default ''\n */\n defaultQuery?: string;\n /**\n * Called with the new query when it changes: as the user types, and with `''` when it resets (a\n * commit, a close, a blur, Escape, the clear button, a form reset, or `disabled` or `readOnly`\n * turned on while text is typed). A Combobox that mounts disabled or read-only reports nothing:\n * it keeps a controlled query, which shows once it unlocks. Never called with `freeform`.\n */\n onQueryChange?: (query: string) => void;\n /**\n * Called after the active (highlighted) option changes — opening, arrow keys, the pointer, a\n * filter change that moves it — and with `null` when the list closes. It reports what\n * `aria-activedescendant` points at, from an effect once the change commits. Fluent's\n * `onActiveOptionChange` reports neither the pointer (its options have no hover highlight) nor\n * the close.\n */\n onActiveOptionChange?: (value: string | null) => void;\n /**\n * Keeps disabled options in the arrow-key order (the first match highlighted while typing may\n * then be a disabled one too); they still cannot be selected (Enter and a click do nothing and\n * the list stays open). Unlike Fluent, which always keeps disabled options reachable, WaveUI\n * skips them by default.\n * @default false\n */\n disabledOptionsFocusable?: boolean;\n /**\n * Name of the value in form submissions (renders a hidden input; one per value with\n * `multiselect`).\n */\n name?: string;\n /** Id of the form the value belongs to, when the Combobox is outside it. */\n form?: string;\n /**\n * A value is required to submit the form (native constraint validation). Like a native readonly\n * input, a `readOnly` Combobox does not block submission.\n */\n required?: boolean;\n /**\n * The `autocomplete` attribute of the `<input role=\"combobox\">`. Browser autofill is off unless\n * you set it (for example `'on'`).\n * @default 'off'\n */\n autoComplete?: string;\n /**\n * The maximum length of the typed text (`maxlength` of the `<input role=\"combobox\">`). With\n * `multiselect` the input has no limit while it shows the selected labels, so the limit applies\n * to the typed query only.\n */\n maxLength?: number;\n /**\n * The value cannot be changed: the input is read-only and the listbox neither opens (click,\n * keyboard, a controlled `open`) nor commits; Escape is left to the page. Turning it (or\n * `disabled`) on while the listbox is open closes it (`onOpenChange(false)`).\n */\n readOnly?: boolean;\n /**\n * Shows a clear button while a value is selected (not while `readOnly`; while `disabled` it is\n * shown disabled, as in DatePicker and TimePicker). It clears the value\n * (`onValueChange('')`; every value with `multiselect`, `onValueChange([])`), drops typed text,\n * closes the list and moves focus to the input. It is a tab stop after the input.\n * @default false\n */\n clearable?: boolean;\n /**\n * The glyph of the expand button at the end of the input (default: a chevron). The button\n * opens and closes the list without moving focus out of the input and is not a tab stop\n * (Alt+ArrowDown opens the list from the keyboard). `null` or `undefined` keep the chevron;\n * `false`, or a value that renders nothing, hides the button. Decorative content rendered\n * inside the built-in button: a `<button>` or `Button` passed here is not nested (its children\n * become the glyph, with a development warning).\n */\n expandIcon?: Slot<'span'>;\n /**\n * The built-in texts (the \"No matches\" status, the names of the clear and expand buttons and,\n * with `multiselect`, the selected-labels text and the toggle announcements), for localization.\n * Unset members keep their English defaults.\n */\n labels?: ComboboxLabels;\n /**\n * Called when the `<input role=\"combobox\">` receives focus (the root keeps other handlers).\n * With `multiselect`, a focus while the input shows the selected labels then selects them;\n * `event.preventDefault()` skips that.\n */\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n /** Called when the `<input role=\"combobox\">` loses focus. */\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n /**\n * Called on a key press in the `<input role=\"combobox\">`, before the built-in listbox keys;\n * `event.preventDefault()` skips them.\n */\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Called when a key is released in the `<input role=\"combobox\">`. */\n onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Ref to the `<input role=\"combobox\">` (the focusable element). */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** The Combobox component's type: a multi-select signature, then the single-select one. */\nexport interface ComboboxComponent {\n (props: ComboboxProps<true> & { multiselect: true }): React.ReactNode;\n (props: ComboboxProps): React.ReactNode;\n displayName?: string;\n Option: typeof Option;\n OptionGroup: typeof OptionGroup;\n}\n\n/**\n * An edit a `beforeinput` event announced: its `inputType`, and the selection it replaces, recorded\n * before the edit changes it. `range` is `null` where the edit does not replace the selection: a\n * drop inserts at the drop point, and an undo or a redo restores earlier text.\n */\ninterface AnnouncedEdit {\n inputType: string;\n range: readonly [number, number] | null;\n}\n\n/** The edits that restore earlier text: D11 rule 3 applies to them (R17). */\nconst HISTORY_EDITS: ReadonlySet<string> = new Set(['historyUndo', 'historyRedo']);\n\n/**\n * How the control came to be locked (`disabled` or `readOnly`): not at all, by a change while\n * mounted, or since it mounted.\n */\ntype LockState = 'unlocked' | 'locked' | 'mounted-locked';\n\n/** The default `filter` (0.7's match): a case-insensitive substring of `textValue ?? label`. */\nfunction matchesText(item: ListboxItem, text: string): boolean {\n return (item.textValue ?? item.label).toLowerCase().includes(text.toLowerCase());\n}\n\nconst ComboboxRoot = (props: ComboboxProps<boolean>) => {\n const {\n multiselect = false,\n value: valueProp,\n defaultValue,\n onValueChange,\n onOptionSelect,\n open: openProp,\n defaultOpen,\n onOpenChange,\n placeholder,\n disabled = false,\n size: sizeProp,\n positioning,\n appearance: appearanceProp,\n freeform: freeformProp = false,\n filter,\n query: queryProp,\n defaultQuery,\n onQueryChange,\n onActiveOptionChange,\n disabledOptionsFocusable = false,\n name,\n form,\n required,\n autoComplete = 'off',\n autoCapitalize,\n autoCorrect,\n maxLength,\n readOnly,\n clearable = false,\n expandIcon,\n labels,\n inputMode,\n spellCheck,\n enterKeyHint,\n autoFocus,\n tabIndex,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n children,\n ref,\n ...rest\n } = props;\n\n if (onOptionSelect !== undefined) warnDeprecated('Combobox', 'onOptionSelect', 'onValueChange');\n\n // The multi-select signature has no `freeform` (D11); passed anyway from JavaScript, it is\n // ignored there, with a warning.\n const freeform = freeformProp && !multiselect;\n const freeformIgnored = freeformProp && multiselect;\n React.useEffect(() => {\n if (freeformIgnored) {\n warnOnce(\n 'Combobox:freeform-multiselect',\n 'Combobox: `freeform` is not available with `multiselect`: a multi-select Combobox ' +\n 'selects options only.',\n );\n }\n }, [freeformIgnored]);\n // With `freeform` the typed text is the value, so the query props are unused (D12).\n const queryIgnored = freeform && (queryProp !== undefined || defaultQuery !== undefined);\n React.useEffect(() => {\n if (queryIgnored) {\n warnOnce(\n 'Combobox:query-freeform',\n 'Combobox: `query` and `defaultQuery` are not used with `freeform`: the typed text is the ' +\n 'value (`value`, `onValueChange`).',\n );\n }\n }, [queryIgnored]);\n\n const field = useFieldContext();\n const isRequired = required ?? field?.required ?? false;\n const validates = isRequired && !readOnly;\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required matches\n // `isRequired`.\n 'aria-required': ariaRequired ?? required,\n });\n // The error look follows the resolved state: the consumer's `aria-invalid` or the Field's.\n const invalidLook = isInvalidLook(false, fieldProps['aria-invalid']);\n const { size, appearance } = useInputLook(sizeProp, appearanceProp);\n\n const [value, setValue] = useControllable<string | readonly string[]>(\n valueProp,\n defaultValue ?? (multiselect ? EMPTY_VALUES : ''),\n (next) => {\n // The two call signatures make `onValueChange` a union of incompatible functions from here:\n // the root itself is written against the wider, internal shape (D9).\n (onValueChange as ((value: string | string[]) => void) | undefined)?.(\n typeof next === 'string' ? next : [...next],\n );\n },\n );\n // The selected values, for the listbox and the multi-select paths: a single value is its own\n // one-element array, and a `value` passed as `null` from JavaScript (bypassing the type system)\n // is none rather than a crash, as 0.7 did for the single-select string.\n const values = toValues(value);\n // The single-select value as 0.7 read it.\n const single = multiselect ? '' : (value as string);\n\n const interactive = !disabled && !readOnly;\n // A combobox that starts disabled or read-only never shows its list, so it starts closed (no\n // close to report later).\n const [openState, setOpen] = useControllable(\n openProp,\n (defaultOpen ?? false) && interactive,\n onOpenChange,\n );\n const open = openState && interactive;\n // The query (D12): the text typed since the last commit, which filters the options, and\n // `editing`, set while the user edits it, so erased text stays empty instead of showing the\n // committed value. A Combobox that starts locked starts without a query, as it starts closed.\n // Freeform: the text is the value, so the query is unused (`onQueryChange` is never called)\n // and 0.7's draft follows the text instead.\n const [query, setQuery] = useControllable(\n freeform ? undefined : queryProp,\n interactive ? (defaultQuery ?? '') : '',\n freeform ? undefined : onQueryChange,\n );\n const [editing, setEditing] = React.useState(false);\n const [freeformDraft, setFreeformDraft] = React.useState<string | null>(null);\n // Text typed since the last commit, the filter; `null` shows the committed value's label\n // (input-pickers#7), or the selected labels with `multiselect`: the query while it is not empty\n // or the user edits it, and never while locked. Freeform: the input shows the value, and the\n // draft follows that text.\n const draft = freeform ? freeformDraft : interactive && (editing || query !== '') ? query : null;\n // Locking the control (readOnly/disabled) while typing drops the typed text, so the input shows\n // the committed value again: hidden during render above, the editing state and the freeform\n // draft dropped here (adjust-during-render pattern, C-HOOKS), and the query reset reported from\n // an effect, since `onQueryChange` never runs during render (D12). `lock` is how the control\n // came to be locked: `'locked'` by a change while mounted, whose reset is reported once, or\n // `'mounted-locked'` since it mounted, which reports nothing and keeps a controlled query,\n // hidden until the control unlocks (R20).\n const [lock, setLock] = React.useState<LockState>(interactive ? 'unlocked' : 'mounted-locked');\n if (interactive && lock !== 'unlocked') {\n setLock('unlocked');\n } else if (!interactive && lock === 'unlocked') {\n setLock('locked');\n setEditing(false);\n setFreeformDraft(null);\n }\n React.useEffect(() => {\n if (lock === 'locked') setQuery('');\n }, [lock, setQuery]);\n // Locking also closes the list itself, not only the derived `open`, so unlocking does not reopen\n // it without a user action. The close is reported through onOpenChange (a consumer callback from\n // an effect, C-HOOKS); a controlled `open` that stays true is still not shown while locked.\n const lockedOpen = !interactive && openState;\n React.useEffect(() => {\n if (lockedOpen) setOpen(false);\n }, [lockedOpen, setOpen]);\n\n // Freeform: the value the user typed last. While the value still equals it, the input shows it\n // as typed, even when it equals an option's value (not that option's label).\n const [typedValue, setTypedValue] = React.useState<string | null>(null);\n\n const rootRef = React.useRef<HTMLDivElement | null>(null);\n const inputRef = React.useRef<HTMLInputElement | null>(null);\n\n const optionLabels = React.useMemo(() => collectOptionLabels(children), [children]);\n // useListbox's navigability predicate: `filter` (else the 0.7 match) bound to the typed text,\n // while there is any (D13).\n const filterText = draft ?? '';\n const listFilter = React.useMemo(\n () =>\n filterText ? (item: ListboxItem) => (filter ?? matchesText)(item, filterText) : undefined,\n [filterText, filter],\n );\n\n // 0.7's `setDraft(text)`: the typed text becomes `text` (the query, reported, while editing).\n const editDraft = (text: string) => {\n if (freeform) {\n setFreeformDraft(text);\n } else {\n setEditing(true);\n setQuery(text);\n }\n };\n // 0.7's `setDraft(null)`: the typed text is dropped, so the input shows the committed value\n // again (the query resets to `''`).\n const dropDraft = () => {\n if (freeform) {\n setFreeformDraft(null);\n } else {\n setEditing(false);\n setQuery('');\n }\n };\n\n const commitText = (text: string) => {\n setTypedValue(text);\n setValue(text);\n onOptionSelect?.(text);\n };\n\n const close = () => {\n setOpen(false);\n dropDraft();\n };\n\n // APG: Escape on a closed listbox clears the textbox. Freeform: the text is the value, so it is\n // cleared. Otherwise only a typed filter is dropped (the input shows the selected label again);\n // without one there is nothing to clear and Escape is left to the page.\n let clearDraft: (() => void) | undefined;\n if (freeform) {\n clearDraft = () => {\n setFreeformDraft(null);\n commitText('');\n };\n } else if (draft) {\n clearDraft = dropDraft;\n }\n\n const listbox = useListbox({\n open,\n onOpenChange: (next) => {\n if (next) setOpen(true);\n else close();\n },\n mode: 'editable',\n multiselect,\n disabledOptionsFocusable,\n selectedValues: values,\n onSelect: (next, details) => {\n if (!multiselect) {\n // 0.7 order: the value callback first, the deprecated one after.\n setValue(next);\n onOptionSelect?.(next);\n dropDraft();\n setTypedValue(null);\n return;\n }\n const { values: updated, added } = toggleValue(values, next);\n setValue(updated);\n onOptionSelect?.(next);\n // The toggled option's label: the item useListbox passed in `details` (its own result,\n // `listbox`, cannot be read from inside the options object passed to it), else the label\n // read from `children` before the option registered, else the raw value. Announces a\n // toggle the user made (D41): never a controlled change, a clear or a form reset, none of\n // which reach this callback.\n announceToggle(\n labels,\n details?.item.label ?? optionLabels.get(next) ?? next,\n added,\n updated.length,\n );\n // A toggle clears the query, so the labels show again, selected (R18); the list stays open\n // (D11).\n dropDraft();\n },\n filter: listFilter,\n // Typing a filter makes its first match active (like Fluent's Combobox), so Enter selects what\n // the list shows instead of submitting the form. Nothing is active on open or with the text\n // cleared. Freeform: the text is the value, so Enter keeps it unless the user moved to an\n // option.\n autoHighlight: !freeform && draft ? 'first' : false,\n onActiveValueChange: onActiveOptionChange,\n idPrefix: 'combobox-listbox',\n onClearDraft: clearDraft,\n });\n\n const labelOf = (v: string) => listbox.getItem(v)?.label ?? optionLabels.get(v);\n // Multi-select: the selected labels in selection order, values without an option left out\n // (D10), joined by `labels.selection`.\n let labelsText = '';\n if (multiselect) {\n const shown = values.map(labelOf).filter((label): label is string => label !== undefined);\n if (shown.length > 0) labelsText = (labels?.selection ?? defaultSelectionLabel)(shown);\n }\n // Multi-select: while no text is typed, the input shows the selected labels (D11); without any\n // (no value, or no selected value with an option) it shows its placeholder, as a Dropdown does.\n const showingLabels = multiselect && draft === null && labelsText !== '';\n\n // The input text. Multi-select: the typed query, else the selected labels. Freeform: the value\n // as typed while it is the value the user typed last, else the label of the option with that\n // value, else the value itself — so the text follows a controlled parent that normalizes or\n // rejects what was typed while the input still has focus. Otherwise: the typed filter, else the\n // selected option's label.\n const optionLabel = single ? labelOf(single) : undefined;\n let inputText: string;\n if (multiselect) inputText = draft ?? labelsText;\n else if (freeform) inputText = single === typedValue ? single : (optionLabel ?? single);\n else inputText = draft ?? optionLabel ?? '';\n // Freeform: the filter follows the text (adjust-during-render pattern, C-HOOKS; the text does not\n // depend on the filter, so this settles in one pass).\n if (freeform && freeformDraft !== null && freeformDraft !== inputText) {\n setFreeformDraft(inputText);\n }\n\n const expanded = open && listbox.items.length > 0;\n const noMatchesText = labels?.noMatches ?? 'No matches';\n // The popup shows the list, or \"No matches\" for a draft.\n const surfaceOpen = open && (expanded || !!draft);\n const noMatches = surfaceOpen && !expanded;\n const { layerId, setReference, surfaceRef, floatingProps } = useListboxPopup({\n positioning,\n open,\n surfaceOpen,\n onDismiss: close,\n rootRef,\n anchorRef: inputRef,\n });\n\n const rootMergedRef = useMergedRefs<HTMLDivElement>(rootRef, ref);\n const inputMergedRef = useMergedRefs<HTMLInputElement>(inputRef, controlRef, setReference);\n\n useFormReset(\n inputRef,\n () => {\n if (multiselect) {\n // Compared by content (C-FORMS), so a reset that keeps the same values reports nothing.\n setValue((current) => resetValues(current, defaultValue));\n } else {\n setValue(defaultValue ?? '');\n }\n dropDraft();\n setTypedValue(null);\n },\n form,\n );\n\n // D11 rule 1: focusing the input while it shows the labels (Tab, a click, a Field label) selects\n // them, so an edit of any kind replaces them natively, without the value being rewritten during\n // the edit. A pointer press sets the caret on its mouseup, which would drop that selection, so\n // the mouseup of the press that focused the input is prevented (only that one: a later press in\n // the focused input places the caret as usual). The ref is written in handlers only (C-HOOKS).\n const pointerFocusRef = React.useRef(false);\n const handleMouseDown = (event: React.MouseEvent<HTMLInputElement>) => {\n pointerFocusRef.current = showingLabels && !isFocused(event.currentTarget);\n };\n const handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {\n if (showingLabels) event.currentTarget.select();\n };\n const handleMouseUp = (event: React.MouseEvent<HTMLInputElement>) => {\n if (!pointerFocusRef.current) return;\n pointerFocusRef.current = false;\n event.preventDefault();\n };\n // Rule 1 also holds whenever the labels return to the focused input (R18): a toggle, a close\n // from the keyboard, a controlled change or a form reset writes them with the caret at their\n // end, so they are selected again here. A press that moves the caret into them changes neither\n // dependency, so the caret stays and rule 2 takes what is typed there.\n React.useLayoutEffect(() => {\n const input = inputRef.current;\n if (showingLabels && input && isFocused(input)) input.select();\n }, [showingLabels, labelsText]);\n\n // Multi-select: the edit a `beforeinput` announced (the last moment before an edit of any kind,\n // with the selection it replaces still in place; React has no event for it), for the change\n // that follows.\n const announcedEditRef = React.useRef<AnnouncedEdit | null>(null);\n // Multi-select: an edit that leaves the text as it was (the labels replaced by the same text: a\n // one-letter label typed again, a paste of exactly the labels) changes no value, so React reports\n // no change for it, while a browser fires `input` for every edit. Typing the labels' text is a\n // query (R17), so this listener starts it; an undo or a redo keeps rule 3 (the labels show, with\n // no query). The event is remembered, so a change React does report for it is not handled twice.\n const handledInputRef = React.useRef<Event | null>(null);\n const handleUnchangedEdit = useEventCallback((event: Event) => {\n const input = event.currentTarget as HTMLInputElement;\n if (!showingLabels || input.value !== labelsText) return;\n announcedEditRef.current = null;\n if (HISTORY_EDITS.has((event as Partial<InputEvent>).inputType ?? '')) return;\n handledInputRef.current = event;\n editDraft(labelsText);\n if (!open) setOpen(true);\n });\n React.useEffect(() => {\n const input = inputRef.current;\n if (!multiselect || !input) return;\n const record = (event: InputEvent) => {\n const { inputType } = event;\n const { selectionStart, selectionEnd } = input;\n announcedEditRef.current = {\n inputType,\n range:\n inputType === 'insertFromDrop' ||\n HISTORY_EDITS.has(inputType) ||\n selectionStart === null ||\n selectionEnd === null\n ? null\n : [selectionStart, selectionEnd],\n };\n };\n input.addEventListener('beforeinput', record);\n input.addEventListener('input', handleUnchangedEdit);\n return () => {\n input.removeEventListener('beforeinput', record);\n input.removeEventListener('input', handleUnchangedEdit);\n };\n }, [multiselect, handleUnchangedEdit]);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && open && !surfaceOpen && !event.nativeEvent.isComposing) {\n // Open with nothing shown (no options): close as a closed list would handle Escape — clear\n // the text if there is any, otherwise leave the key to an enclosing layer (overlays#1).\n close();\n if (clearDraft && event.currentTarget.value !== '') {\n event.preventDefault();\n clearDraft();\n }\n return;\n }\n listbox.onKeyDown(event);\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (event.nativeEvent === handledInputRef.current) return;\n const text = event.target.value;\n // The edit the last `beforeinput` announced, if this change is that edit. A change nothing\n // announced (autofill, an extension, a script) has none, and neither has one after an edit\n // that was announced and then not made (cancelled, or blocked).\n const announced = announcedEditRef.current;\n announcedEditRef.current = null;\n const edit =\n announced && announced.inputType === (event.nativeEvent as { inputType?: string }).inputType\n ? announced\n : null;\n if (!multiselect) {\n editDraft(text);\n } else if (text === labelsText && (edit === null || HISTORY_EDITS.has(edit.inputType))) {\n // D11 rule 3, for an undo or a redo (R17): text equal to the labels shows them again, with\n // no query. Any other edit that leaves their text, typed or pasted, is a query.\n dropDraft();\n } else if (showingLabels) {\n // D11 rule 2: the query is the text the edit inserted into the labels. With the selection\n // the edit replaced (all of the labels after a focus, rule 1), that is the text now in its\n // place, however much of it looks like the labels (R16); without one (a drop, an undo or a\n // redo, an edit the input did not announce), the new value without the part it shares with\n // the labels at its start and its end. Backspace and Delete leave an empty query and never\n // remove a value (rule 4).\n const range = edit?.range;\n editDraft(\n (range && replacedText(labelsText, text, range[0], range[1])) ??\n insertedText(labelsText, text),\n );\n } else {\n editDraft(text);\n }\n if (!open) setOpen(true);\n if (freeform) commitText(text);\n };\n\n // The expand button opens and closes the list like the input's own keys; focus stays in (or\n // returns to) the input.\n const handleExpandClick = () => {\n if (!interactive) return;\n if (open) close();\n else setOpen(true);\n inputRef.current?.focus();\n };\n\n // Clearing is not an option activation: the state is set directly, not through `commitText`\n // (which calls the deprecated `onOptionSelect` in freeform mode). The button disappears with the\n // value, so focus moves to the input explicitly (C-DISABLED).\n const handleClear = () => {\n setValue(multiselect ? EMPTY_VALUES : '');\n setTypedValue(null);\n dropDraft();\n setOpen(false);\n inputRef.current?.focus();\n };\n\n const showExpand = showsExpandButton(expandIcon);\n // Read-only comboboxes offer no clear action (the value cannot change).\n const showClear = clearable && (multiselect ? values.length > 0 : single !== '') && !readOnly;\n\n const listLabelledBy =\n fieldProps['aria-label'] === undefined\n ? (fieldProps['aria-labelledby'] ?? field?.labelId)\n : fieldProps['aria-labelledby'];\n\n return (\n <div\n data-size={size}\n data-appearance={appearance}\n {...rest}\n ref={rootMergedRef}\n className={cn(comboboxClassNames.root, 'relative inline-flex flex-col', className)}\n >\n {multiselect && <PickerAnnouncer />}\n <div className=\"relative flex items-center\">\n <input\n type=\"text\"\n autoComplete={autoComplete}\n {...fieldProps}\n {...listbox.getComboboxProps()}\n aria-expanded={expanded}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n ref={inputMergedRef}\n disabled={disabled}\n readOnly={readOnly}\n // Multi-select: the selected labels take the placeholder's place (D11).\n placeholder={multiselect && labelsText !== '' ? undefined : placeholder}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n // Multi-select: no limit while the labels show, so typing into them (the caret moved\n // there) is never blocked; the limit applies to the typed query only.\n maxLength={showingLabels ? undefined : maxLength}\n inputMode={inputMode}\n spellCheck={spellCheck}\n enterKeyHint={enterKeyHint}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n value={inputText}\n onChange={handleChange}\n onClick={() => {\n if (!open && interactive) setOpen(true);\n }}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n // Read-only: no listbox keys at all (they would open, commit or clear the value).\n onKeyDown={composeEventHandlers(onKeyDown, readOnly ? undefined : handleKeyDown)}\n onKeyUp={composeEventHandlers(onKeyUp, listbox.onKeyUp)}\n onFocus={composeEventHandlers(onFocus, handleFocus)}\n onBlur={composeEventHandlers(onBlur, dropDraft, {\n checkDefaultPrevented: false,\n })}\n className={cn(\n comboboxClassNames.input,\n inputHeightClasses[size],\n 'w-full',\n inputPaddingClasses[size],\n inputTextClasses[size],\n inputAppearanceClasses[appearance],\n 'text-foreground placeholder:text-muted-foreground',\n inputFocus,\n disabledStyles,\n invalidLook && inputInvalid,\n pickerEndPadding(Number(showClear) + Number(showExpand), size),\n )}\n />\n {showClear && (\n <button\n type=\"button\"\n aria-label={labels?.clear ?? 'Clear selection'}\n disabled={disabled}\n // Keeps focus in the input, so its blur does not act on a draft before the clear.\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleClear}\n className={cn(\n comboboxClassNames.clearButton,\n pickerIconButtonClasses(size, appearance),\n pickerButtonOffset(size, showExpand ? 2 : 1),\n focusRing,\n disabledStyles,\n )}\n >\n <DismissIcon size={pickerGlyphSize(size, 'icon')} />\n </button>\n )}\n {showExpand && (\n <PickerExpandButton\n component=\"Combobox\"\n expandIcon={expandIcon}\n label={labels?.expand ?? 'Show options'}\n expanded={expanded}\n listboxId={listbox.listboxId}\n disabled={disabled || !!readOnly}\n onToggle={handleExpandClick}\n size={size}\n appearance={appearance}\n className={comboboxClassNames.expandButton}\n iconClassName={comboboxClassNames.expandIcon}\n />\n )}\n </div>\n {/* Mounted before its text: a live region added together with its text is not announced by\n every screen reader. The row in the popup is the visible copy. */}\n <span role=\"status\" className=\"sr-only\">\n {noMatches && noMatchesText}\n </span>\n <ListboxSurface\n listbox={listbox}\n layerId={layerId}\n surfaceRef={surfaceRef}\n floatingProps={floatingProps}\n open={open}\n expanded={expanded}\n listClassName={comboboxClassNames.listbox}\n surfaceClassName={comboboxClassNames.surface}\n emptyContent={\n draft ? (\n <div\n aria-hidden=\"true\"\n className={cn(\n comboboxClassNames.emptyMessage,\n 'px-3 py-1.5 text-body-1 text-muted-foreground',\n )}\n >\n {noMatchesText}\n </div>\n ) : undefined\n }\n aria-label={fieldProps['aria-label']}\n aria-labelledby={listLabelledBy}\n >\n {children}\n </ListboxSurface>\n <HiddenInput\n name={name}\n form={form}\n disabled={disabled}\n value={multiselect ? values : single}\n type=\"text\"\n // Like a native readonly input, a read-only Combobox is barred from constraint validation\n // (the user could not fix it); its value is still submitted.\n required={validates}\n onInvalid={() => inputRef.current?.focus()}\n />\n </div>\n );\n};\nComboboxRoot.displayName = 'Combobox';\n\n/** Flat name of `Combobox.Option` for React Server Components. */\nexport const ComboboxOption = Option;\n/** Flat name of `Combobox.OptionGroup` for React Server Components. */\nexport const ComboboxOptionGroup = OptionGroup;\n\n/**\n * An editable combobox: a text input with a filterable listbox of `Option`s (APG combobox with\n * list autocomplete). Typing filters the options; ArrowDown/ArrowUp move the highlight\n * (`aria-activedescendant`), Enter selects, Escape closes. Without `freeform` the text is only a\n * filter: its first match becomes active while typing, and the input shows the selected option's\n * label again when the listbox closes. With `freeform` the text itself is the value. Text that\n * matches no option shows \"No matches\" (`labels.noMatches`), announced through a status region.\n * `filter` replaces the match (it may keep options that do not contain the text, for a server-side\n * search or a \"Create …\" entry), and `query`/`defaultQuery`/`onQueryChange` control the typed\n * text (not with `freeform`), which resets to `''` on a commit, a close, a blur, Escape, the clear\n * button and a form reset. The expand button at the end of the input (a chevron, see\n * `expandIcon`) opens and closes the list without taking focus from the input and is not a tab\n * stop; `clearable` adds a clear button, a tab stop after the input. Both sit with the input in a\n * wrapper `<div>` inside the root.\n *\n * `multiselect` turns the value into an array (Fluent's `selectedOptions`): options draw a\n * checkbox; Enter and a click toggle an option and keep the list open (Tab, Escape and\n * Alt+ArrowUp close without committing), and every toggle the user makes is announced\n * (`labels.added`/`labels.removed`, never for a controlled change, a clear or a form reset).\n * While no text is typed the input shows the selected labels in selection order\n * (`labels.selection`, values without an option left out) instead of the placeholder. Focusing\n * the input selects them, and so does their return to the focused input (a toggle, a close, a\n * form reset), so typing, pasting or composing text replaces them with a query that filters the\n * options; text inserted into them queries only what was inserted, an undo or a redo back to them\n * shows them again, and a toggle, a close or a blur clears the query. Backspace and Delete only\n * edit the text: the options, the clear button (which clears every value) and a form reset change\n * the value. `freeform` is not available with `multiselect`, and a non-literal\n * `multiselect={flag}` is a type error: render two elements, one for each mode.\n *\n * The `<input>` receives `id`, `aria-label`, `aria-labelledby`, `aria-describedby`,\n * `aria-invalid`, `aria-required`, `aria-errormessage`, `aria-details`, `tabIndex`, `autoFocus`,\n * `onFocus`/`onBlur`/`onKeyDown`/`onKeyUp` and the text input attributes `autoComplete`,\n * `autoCapitalize`, `autoCorrect`, `maxLength`, `inputMode`, `spellCheck` and `enterKeyHint`.\n * `ref`, `className`, `style`, other `aria-*` attributes and the remaining props stay on the root\n * `<div>`. Inside a `Field` the input is labelled and described by it. It shows the error look\n * whenever it ends up `aria-invalid` (its own `aria-invalid` or a `Field` error). With\n * `name`/`required` the value takes part in form submission (one hidden input per value with\n * `multiselect`), validation and reset (a `multiselect` reset is compared by content, so restoring\n * the same values reports nothing). The open listbox renders in a portal; while closed it stays\n * in the DOM, hidden.\n *\n * **Size and appearance**: `size` resolves from its own prop, then the surrounding `Field`'s\n * `size`, then `WaveProvider inputDefaults.size`, else `'medium'`; `appearance` from its own prop,\n * then `WaveProvider inputDefaults.appearance`, else `'outline'`; both render as `data-size` and\n * `data-appearance` on the root `<div>`. The listbox keeps its size.\n *\n * Sub-components: `Combobox.Option`, `Combobox.OptionGroup`. React Server Components import the\n * flat names `ComboboxOption` / `ComboboxOptionGroup` (dotted access needs a client file).\n */\nexport const Combobox = /* @__PURE__ */ Object.assign(ComboboxRoot, {\n Option,\n OptionGroup,\n}) as ComboboxComponent;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgUA,IAAMC,oBAAqC,IAAI,IAAI,CAAC,eAAe,aAAa,CAAC;AASjF,SAASC,GAAY,GAAmB,GAAuB;CAC7D,QAAQC,EAAK,aAAaA,EAAK,MAAA,CAAO,YAAY,CAAC,CAAC,SAASC,EAAK,YAAY,CAAC;AACjF;AAEA,IAAMC,KAAgB,MAAkC;CACtD,IAAM,EACJ,iBAAc,IACd,OAAOC,GACP,iBACA,mBACA,mBACA,MAAMC,IACN,iBACA,kBACA,iBACA,cAAW,IACX,MAAMC,IACN,iBACA,YAAYC,IACZ,UAAUC,IAAe,IACzB,YACA,OAAOC,IACP,kBACA,mBACA,0BACA,+BAA2B,IAC3B,UACA,UACA,cACA,mBAAe,OACf,oBACA,iBACA,e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IACG;IACG;IACT;IACI;IACV,eAAetB,EAAmB;IAClC,kBAAkBA,EAAmB;IACrC,cACEpF,IACE,kBAAC,OAAD;KACE,eAAY;KACZ,WAAWmF,EACTC,EAAmB,cACnB,+CACF;KAEC,UAAA9C;IACE,CAAA,IACH,KAAA;IAEN,cAAYlE,EAAW;IACvB,mBAAiB4G;IAEhB;GACa,CAAA;GAChB,kBAAC2B,IAAD;IACQ;IACA;IACI;IACV,OAAOjJ,IAAcqB,IAASE;IAC9B,MAAK;IAGL,UAAUhB;IACV,iBAAiBsC,EAAS,SAAS,MAAM;GAC1C,CAAA;EACE;;AAET;AACA,EAAa,cAAc;AAG3B,IAAaqG,IAAiBC,GAEjBC,KAAsBC,GAmDtBC,IAA2B,uBAAO,OAAOzK,GAAc;CAClE;CACA;AACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),ee=require("../../lib/composeEventHandlers.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../lib/date.cjs"),
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),ee=require("../../lib/composeEventHandlers.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../lib/date.cjs"),te=require("../../hooks/useControllable.cjs"),a=require("../../hooks/useId.cjs"),ne=require("../../lib/focus.cjs"),o=require("../../hooks/useMergedRefs.cjs"),re=require("../../hooks/useIsClient.cjs"),ie=require("../../lib/aria.cjs"),s=require("../../hooks/useFieldControl.cjs"),ae=require("../../hooks/usePopupPosition.cjs"),oe=require("../../hooks/useDismiss.cjs"),se=require("../../hooks/useFocusTrap.cjs"),ce=require("../../hooks/useRestoreFocus.cjs"),c=require("../../lib/styles.cjs"),le=require("../portal/Portal.cjs"),l=require("../../lib/icons.cjs"),ue=require("./inputLook.cjs"),de=require("./Input.cjs"),fe=require("../../hooks/useFormReset.cjs"),pe=require("../internal/HiddenInput.cjs"),u=require("./pickerStyles.cjs"),d=require("./dateUtils.cjs"),me=require("./Calendar.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("react/jsx-runtime"),he=require("react-dom");var ge=e=>e?`Enter a date in the format ${e}.`:`Enter a valid date.`,_e=(e,t)=>e!==void 0&&t!==void 0?`Enter a date between ${e} and ${t}.`:e===void 0?`Enter a date on or before ${t}.`:`Enter a date on or after ${e}.`,ve={header:r.datePickerClassNames.header,previousMonthButton:r.datePickerClassNames.previousMonthButton,heading:r.datePickerClassNames.heading,headingButton:r.datePickerClassNames.headingButton,nextMonthButton:r.datePickerClassNames.nextMonthButton,grid:r.datePickerClassNames.grid,weekday:r.datePickerClassNames.weekday,day:r.datePickerClassNames.day,month:r.datePickerClassNames.month,year:r.datePickerClassNames.year,weekNumberHeader:r.datePickerClassNames.weekNumberHeader,weekNumber:r.datePickerClassNames.weekNumber,markedDot:r.datePickerClassNames.markedDot,footer:r.datePickerClassNames.footer,todayButton:r.datePickerClassNames.todayButton,closeButton:r.datePickerClassNames.closeButton},m=e=>{let{value:m,defaultValue:ye,onValueChange:be,onChange:h,formatDate:g,parseDate:_,locale:v,minDate:y,maxDate:b,disabledDates:xe,placeholder:Se=`Select a date`,disabled:x=!1,size:Ce,positioning:we,appearance:Te,readOnly:S,clearable:Ee=!1,firstDayOfWeek:De=0,today:Oe,initialVisibleDate:ke,showMonthPicker:Ae,showWeekNumbers:je,firstWeekOfYear:Me,showGoToToday:Ne,showCloseButton:Pe=!1,markedDates:Fe,renderDay:Ie,dayLabel:Le,open:Re,defaultOpen:ze,onOpenChange:Be,onInvalidInput:Ve,labels:C,name:He,form:w,required:T,autoComplete:Ue=`off`,autoCapitalize:We,autoCorrect:Ge,enterKeyHint:Ke,inputMode:qe,spellCheck:Je,autoFocus:Ye,tabIndex:Xe,id:Ze,"aria-label":Qe,"aria-labelledby":$e,"aria-describedby":et,"aria-invalid":tt,"aria-required":nt,"aria-errormessage":rt,"aria-details":it,onFocus:at,onBlur:ot,onKeyDown:st,onKeyUp:ct,controlRef:lt,className:ut,ref:dt,...ft}=e;h!==void 0&&n.warnDeprecated(`DatePicker`,`onChange`,`onValueChange`);let{size:E,appearance:D}=ue.useInputLook(Ce,Te),O=g!==void 0,k=_!==void 0;f.useEffect(()=>{O&&!k&&n.warnOnce(`DatePicker:formatDate-without-parseDate`,"DatePicker: `formatDate` is set without `parseDate`. Typed dates are parsed with the default parser for `locale` (its numeric format or yyyy-mm-dd), which may not read your format; pass `parseDate` as the inverse of `formatDate`.")},[O,k]),f.useEffect(()=>{v!==void 0&&!d.isValidLocaleTag(v)&&n.warnOnce(`DatePicker:invalid-locale:${v}`,`DatePicker: \`locale\` "${v}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats and parses the dates instead, so the server and the browser may render different text.`)},[v]);let[A,pt]=te.useControllable(m,ye??null,e=>{be?.(e),h?.(e)}),j=!x&&!S,[M,N]=te.useControllable(Re,(ze??!1)&&j,Be),mt=re.useIsClient(),P=M&&j&&mt,F=Re!==void 0;f.useEffect(()=>{!j&&M&&!F&&N(!1)},[j,M,F,N]);let I=e=>g?g(e):d.formatDate(e,v),ht=e=>_?_(e):d.parseDate(e,v),[L,R]=f.useState(null),[z,B]=f.useState(null),[gt,_t]=f.useState(j);gt!==j&&(_t(j),j||(R(null),B(null)));let V=A?d.formatISODate(A):``,[vt,yt]=f.useState(V);vt!==V&&(yt(V),z!==null&&(R(null),B(null)));let H=e=>{let t=e?i.startOfDay(e):null;(t?i.isSameDay(t,A):A===null)||pt(t),R(null),B(null)},U=e=>{if(!e.trim())return H(null),!0;let t=ht(e),n=null;if(!t||Number.isNaN(t.getTime())?n=`unparseable`:d.isDateInRange(t,y,b)?xe?.(i.startOfDay(t))&&(n=`disabled`):n=`out-of-range`,n||!t){let t=n??`unparseable`;return B(t),Ve?.(e,t),!1}return H(t),!0},[W,G]=f.useState(!1);W&&!P&&G(!1);let K=f.useRef(null),q=f.useRef(null),J=f.useRef(null),Y=f.useRef(null),[bt,xt]=f.useState(null),St=o.useMergedRefs(lt,K),Ct=a.useId(`datepicker-dialog`),wt=a.useId(`datepicker-heading`),Tt=a.useId(`datepicker-error`),X=e=>{Y.current=e,N(!1)},{layerId:Z}=oe.useDismiss({open:P,onDismiss:(e,t)=>{let n=e===`outside-press`&&t.target instanceof Element?t.target.closest(ne.FOCUSABLE_SELECTOR):null;X(n??(W?K.current:null))},refs:[J,q],anchorRef:q,kind:`modal`}),{setReference:Et,setFloating:Dt,floatingProps:Ot}=ae.usePopupPosition({open:P,side:`bottom`,align:`start`,...ae.resolvePositioning(we,{})}),kt=o.useMergedRefs(J,xt,Dt);se.useFocusTrap(bt,{enabled:P,layerId:Z,initialFocus:()=>J.current?.querySelector(`[data-wave-calendar-grid] button[tabindex="0"]`)??null}),ce.useRestoreFocus({enabled:P,container:bt,triggerRef:q,finalFocusRef:Y,onlyIfFocusInside:!0}),f.useLayoutEffect(()=>{P&&(Y.current=null)},[P]);let At=s.useFieldContext(),jt=(T??At?.required??!1)&&!S,Mt=z!==null&&!At?.hasErrorMessage,Nt=s.useFieldControl({id:Ze,"aria-label":Qe,"aria-labelledby":$e,"aria-describedby":ie.joinIds(et,Mt?Tt:void 0),"aria-invalid":z!==null||tt,"aria-required":nt??T}),Pt=de.isInvalidLook(!1,Nt[`aria-invalid`]);fe.useFormReset(K,()=>H(ye??null),w);let Q=Ee&&!S&&A!==null,Ft=e=>{j&&(R(e.target.value),B(null))},It=ee.composeEventHandlers(st,e=>{j&&!e.nativeEvent.isComposing&&(e.key===`Enter`&&L!==null?(e.preventDefault(),U(L)):e.key===`Tab`&&!e.shiftKey&&Q&&L!==null&&!L.trim()?(0,he.flushSync)(()=>U(L)):e.key===`ArrowDown`&&e.altKey&&!P&&(e.preventDefault(),L!==null&&z===null&&U(L),G(!0),N(!0)))}),Lt=ee.composeEventHandlers(ot,()=>{j&&L!==null&&z===null&&U(L)}),Rt=()=>{j&&(Y.current=null,G(!1),N(!P))},zt=()=>{j&&(H(null),K.current?.focus())},Bt=e=>{e.preventDefault()},Vt=e=>{j&&(H(e),X(K.current))},Ht=()=>X(W?K.current:null),Ut=e=>{e.key!==`Escape`||e.defaultPrevented||e.nativeEvent.isComposing||(e.preventDefault(),Ht())},Wt=L??(A?I(A):``),$=``;return z===`unparseable`?$=(C?.invalidDate??ge)(k?void 0:d.getLocaleDateFormat(v).pattern):z===`out-of-range`&&(y||b)?$=(C?.outOfRange??_e)(y?I(i.startOfDay(y)):void 0,b?I(i.startOfDay(b)):void 0):z===`disabled`&&($=C?.unavailableDate??`This date is not available.`),(0,p.jsxs)(`div`,{"data-size":E,"data-appearance":D,...ft,ref:dt,className:t.cn(r.datePickerClassNames.root,`relative inline-flex flex-col`,ut),children:[(0,p.jsxs)(`div`,{ref:Et,className:`relative flex items-center`,children:[(0,p.jsx)(`input`,{ref:St,type:`text`,...Nt,"aria-errormessage":rt,"aria-details":it,value:Wt,onChange:Ft,onFocus:at,onBlur:Lt,onKeyDown:It,onKeyUp:ct,placeholder:Se,disabled:x,readOnly:S,autoComplete:Ue,autoCapitalize:We,autoCorrect:Ge,enterKeyHint:Ke,inputMode:qe,spellCheck:Je,autoFocus:Ye,tabIndex:Xe,className:t.cn(r.datePickerClassNames.input,c.inputHeightClasses[E],`w-full`,c.inputPaddingClasses[E],c.inputTextClasses[E],c.inputAppearanceClasses[D],`text-foreground placeholder:text-muted-foreground`,c.inputFocus,c.disabledStyles,Pt&&`border-destructive`,u.pickerEndPadding(Q?2:1,E))}),Q&&(0,p.jsx)(`button`,{type:`button`,"aria-label":C?.clear??`Clear date`,disabled:x,onMouseDown:Bt,onClick:zt,className:t.cn(r.datePickerClassNames.clearButton,u.pickerIconButtonClasses(E,D),u.pickerButtonOffset(E,2),`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,`disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`),children:(0,p.jsx)(l.DismissIcon,{size:u.pickerGlyphSize(E,`icon`)})}),(0,p.jsx)(`button`,{ref:q,type:`button`,"aria-label":C?.openCalendar??`Open calendar`,"aria-haspopup":`dialog`,"aria-expanded":P,"aria-controls":P?Ct:void 0,disabled:x||S,onClick:Rt,className:t.cn(r.datePickerClassNames.openCalendarButton,u.pickerIconButtonClasses(E,D),u.pickerButtonOffset(E,1),c.focusRing,c.disabledStyles),children:(0,p.jsx)(l.CalendarIcon,{size:u.pickerGlyphSize(E,`icon`)})})]}),Mt&&(0,p.jsx)(`p`,{id:Tt,role:`alert`,className:t.cn(r.datePickerClassNames.errorMessage,`mt-1 text-caption-1 text-error`),children:$}),(0,p.jsx)(pe.HiddenInput,{name:He,form:w,disabled:x,value:A?d.formatISODate(A):``,type:`text`,required:jt,onInvalid:()=>K.current?.focus()}),P&&(0,p.jsx)(le.Portal,{layerId:Z,children:(0,p.jsx)(`div`,{ref:kt,id:Ct,role:`dialog`,"aria-modal":`true`,"aria-labelledby":wt,...Ot,"data-state":`open`,onKeyDown:Ut,className:t.cn(r.datePickerClassNames.surface,`rounded-md border border-border bg-background p-3 text-foreground shadow-16`),children:(0,p.jsx)(me.CalendarView,{value:A,onPick:Vt,minDate:y,maxDate:b,disabledDates:xe,firstDayOfWeek:De,locale:v,today:Oe,initialVisibleDate:ke,showMonthPicker:Ae,showWeekNumbers:je,firstWeekOfYear:Me,showGoToToday:Ne,markedDates:Fe,renderDay:Ie,dayLabel:Le,onClose:Pe?Ht:void 0,closeLabel:C?.close,labels:C,headingAs:`h2`,headingId:wt,partClassNames:ve})})})]})};m.displayName=`DatePicker`,exports.DatePicker=m;
|
|
2
2
|
//# sourceMappingURL=DatePicker.cjs.map
|