@travel-match/ui 0.1.0 → 0.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"Select.cjs","names":["useFieldIds","useState","useRef","UpArrowIcon","DownArrowIcon","SelectedItem","Popover","cn","FormField","_Fragment","SearchIcon","OptionList","Option","require_runtime","require_DownArrowIcon","require_SearchIcon","require_UpArrowIcon","require_cn","require_Field","require_OptionList","require_SelectedItem","react","react_jsx_runtime","_radix_ui_react_popover","toArray","value","asText","node","optionText","option","matches","text","query","isPrintable","event","defaultRemoveLabel","Select","invalidProp","openProp","ariaDescribedBy","ariaLabelledBy","props","ids","id","error","helperText","listId","optionId","index","internalOpen","setInternalOpen","defaultOpen","internalValue","setInternalValue","defaultValue","setQuery","activeValue","setActiveValue","searchRef","keepFocusOnClose","typed","isOpen","disabled","selectedValues","selectedOptions","options","selected","invalid","needle","searchable","visible","enabled","activeOption","activeId","setOpen","next","candidates","initial","focus","onOpenChange","emit","notify","onValueChange","multiple","toggle","optionValue","commit","move","current","to","typeAhead","state","char","repeated","letter","term","from","match","handleListKeys","source","handleTriggerKeyDown","onKeyDown","search","single","hasChips","Chevron","control","size","removeLabel","label","required","onKeyUp","startIcon","renderValue","placeholder","className","fullWidth","panelAnchor","name","portalContainer","panelClassName","searchPlaceholder","checkmark","emptyText"],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport {\n forwardRef,\n useEffect,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type KeyboardEvent,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { DownArrowIcon, SearchIcon, UpArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport { FormField, useFieldIds, type FieldSize, type FormFieldProps } from '../Field';\nimport { Option, OptionList } from '../OptionList';\nimport { SelectedItem } from './SelectedItem';\nimport './Select.css';\n\nexport interface SelectOption {\n /** What `value` / `onValueChange` carry and what a form submits. */\n value: string;\n /** Text in the list and in the field, e.g. \"Armenia\", \"EN\", \"AMD\". */\n label: ReactNode;\n /** Regular-weight text after the label in the list only, e.g. \"English\" after \"EN\". */\n detail?: ReactNode;\n /** Small second line in the list (Figma \"Caption\"). */\n description?: ReactNode;\n /** Icon or flag before the label in the list (Figma \"Icon\"). */\n icon?: ReactNode;\n /** The option is shown but cannot be chosen. */\n disabled?: boolean;\n /** Plain text for type-ahead, search and the remove button when `label` is not a string. */\n textValue?: string;\n}\n\ntype TriggerProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange' | 'children' | 'type' | 'name' | 'role'>;\n\ninterface SelectBaseProps extends FormFieldProps, TriggerProps {\n /** The options, in display order. */\n options: SelectOption[];\n /** Shown in the field while nothing is selected. */\n placeholder?: ReactNode;\n /** Figma \"Size\": `lg` 52px · `md` 46px (default) · `sm` 42px. */\n size?: FieldSize;\n /** Adds hidden inputs so the value is submitted with a native form (one per value when `multiple`). */\n name?: string;\n /** Invalid look without a message of its own — for composite fields that show one message for several controls. */\n invalid?: boolean;\n /** Adds a search box above the list (Figma \"Type=Currency, State=Open\"); typing filters by label, detail and description. */\n searchable?: boolean;\n /** Placeholder and accessible name of the search box. */\n searchPlaceholder?: string;\n /** Shown instead of the list when the search matches nothing. */\n emptyText?: ReactNode;\n /** Icon in front of the value, e.g. `<LanguageIcon />`. */\n startIcon?: ReactNode;\n /** Custom content for the selected option in the field (single select), e.g. flag + dial code. Defaults to its `label`. */\n renderValue?: (option: SelectOption) => ReactNode;\n /** Shows the check mark on the selected option (Figma \"Done\"). Ignored when `multiple`, which uses checkboxes. */\n checkmark?: boolean;\n /** `false` makes the field hug its content (Figma \"Both-icon-drop-down\", \"Language\", \"Type=Currency\"); the list is then as wide as its options. */\n fullWidth?: boolean;\n /** How the list lines up with the field. */\n align?: 'start' | 'center' | 'end';\n /** Whether the list is open (controlled; Figma \"State=Clicked\" / \"Open\"). */\n open?: boolean;\n /** Opens the list initially (uncontrolled). */\n defaultOpen?: boolean;\n /** Called when the list opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /** Element the list is rendered into (default `document.body`). Set it when the theme is scoped to a container. */\n portalContainer?: HTMLElement | null;\n /** Element the list aligns to and takes its width from, when that is not the field itself (e.g. a whole phone-number row). */\n panelAnchor?: RefObject<HTMLElement | null>;\n /** Class for the list panel, which is rendered in a portal outside the root. */\n panelClassName?: string;\n /** Accessible name of a chip's × button (`multiple`), given the option's text. */\n removeLabel?: (optionText: string) => string;\n}\n\nexport interface SelectSingleProps extends SelectBaseProps {\n /** `true` turns the field into a multi-select (Figma \"Type=Checkbox\"): checkboxes in the list, removable chips in the field. */\n multiple?: false;\n /** Selected option value (controlled); `null` or `''` for none. */\n value?: string | null;\n /** Initially selected value (uncontrolled). */\n defaultValue?: string | null;\n /** Called with the chosen option's value. */\n onValueChange?: (value: string) => void;\n}\n\nexport interface SelectMultipleProps extends SelectBaseProps {\n multiple: true;\n /** Selected option values (controlled). */\n value?: string[];\n /** Initially selected values (uncontrolled). */\n defaultValue?: string[];\n /** Called with all selected values after one is added or removed. */\n onValueChange?: (value: string[]) => void;\n}\n\nexport type SelectProps = SelectSingleProps | SelectMultipleProps;\n\nconst toArray = (value: string | string[] | null | undefined): string[] => (Array.isArray(value) ? value : value == null || value === '' ? [] : [value]);\nconst asText = (node: ReactNode): string => (typeof node === 'string' || typeof node === 'number' ? String(node) : '');\nconst optionText = (option: SelectOption): string => option.textValue ?? (asText(option.label) || option.value);\nconst matches = (option: SelectOption, query: string): boolean =>\n [optionText(option), asText(option.detail), asText(option.description)].some((text) => text.toLowerCase().includes(query));\nconst isPrintable = (event: KeyboardEvent): boolean => event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;\nconst defaultRemoveLabel = (optionText: string) => `Remove ${optionText}`;\n\ntype InitialFocus = 'selected' | 'first' | 'last' | 'none';\n\n/**\n * Figma component set \"Drop down inputs\" (Type=Select · Checkbox, and the base of Language · Phone · Currency):\n * a field that opens a list of options. Keyboard support follows the WAI-ARIA select-only combobox pattern.\n * The ref and any extra props go to the trigger `<button role=\"combobox\">`; `className` goes to the root.\n */\nexport const Select = /* @__PURE__ */ forwardRef<HTMLButtonElement, SelectProps>(function Select(\n {\n label,\n helperText,\n error,\n required,\n optional,\n size = 'md',\n options,\n placeholder = 'Select option',\n name,\n invalid: invalidProp,\n searchable = false,\n searchPlaceholder = 'Search',\n emptyText = 'No results',\n startIcon,\n renderValue,\n checkmark = true,\n fullWidth = true,\n align = 'start',\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n portalContainer,\n panelAnchor,\n panelClassName,\n removeLabel = defaultRemoveLabel,\n multiple = false,\n value,\n defaultValue,\n onValueChange,\n disabled = false,\n id,\n className,\n style,\n onKeyDown,\n onKeyUp,\n 'aria-describedby': ariaDescribedBy,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n },\n ref,\n) {\n const ids = useFieldIds(id, Boolean(error || helperText));\n const listId = `${ids.controlId}-list`;\n const optionId = (index: number) => `${ids.controlId}-option-${index}`;\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [internalValue, setInternalValue] = useState<string[]>(() => toArray(defaultValue));\n const [query, setQuery] = useState('');\n const [activeValue, setActiveValue] = useState<string | null>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n const keepFocusOnClose = useRef(false);\n const typed = useRef({ text: '', timer: 0 });\n\n const isOpen = (openProp ?? internalOpen) && !disabled;\n const selectedValues = value !== undefined ? toArray(value) : internalValue;\n const selectedOptions = selectedValues.map((selected) => options.find((option) => option.value === selected)).filter((option) => option !== undefined);\n const invalid = Boolean(error) || Boolean(invalidProp);\n\n const needle = searchable ? query.trim().toLowerCase() : '';\n const visible = needle ? options.filter((option) => matches(option, needle)) : options;\n const enabled = visible.filter((option) => !option.disabled);\n const activeOption = enabled.find((option) => option.value === activeValue);\n const activeId = activeOption ? optionId(options.indexOf(activeOption)) : undefined;\n\n useEffect(() => {\n if (isOpen && activeId) document.getElementById(activeId)?.scrollIntoView?.({ block: 'nearest' });\n }, [isOpen, activeId]);\n\n useEffect(() => () => window.clearTimeout(typed.current.timer), []);\n\n const setOpen = (next: boolean, focus: InitialFocus = 'none') => {\n if (next) {\n const candidates = options.filter((option) => !option.disabled);\n const selected = candidates.find((option) => selectedValues.includes(option.value));\n const initial = focus === 'none' ? undefined : focus === 'last' ? candidates[candidates.length - 1] : focus === 'first' ? candidates[0] : (selected ?? candidates[0]);\n setQuery('');\n setActiveValue(initial?.value ?? null);\n }\n if (openProp === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n const emit = (next: string[]) => {\n if (value === undefined) setInternalValue(next);\n const notify = onValueChange as ((next: string | string[]) => void) | undefined;\n if (multiple) notify?.(next);\n else if (next[0] !== undefined) notify?.(next[0]);\n };\n\n const toggle = (optionValue: string) =>\n emit(selectedValues.includes(optionValue) ? selectedValues.filter((selected) => selected !== optionValue) : [...selectedValues, optionValue]);\n\n const commit = (option: SelectOption) => {\n if (option.disabled) return;\n if (multiple) {\n toggle(option.value);\n setActiveValue(option.value);\n return;\n }\n if (selectedValues[0] !== option.value) emit([option.value]);\n setOpen(false);\n };\n\n const move = (to: 1 | -1 | 'first' | 'last') => {\n if (enabled.length === 0) return;\n const current = activeOption ? enabled.indexOf(activeOption) : -1;\n let next: number;\n if (to === 'first') next = 0;\n else if (to === 'last') next = enabled.length - 1;\n else if (current === -1) {\n // Opened with the pointer: start from the selected option, like a native select.\n const selected = enabled.findIndex((option) => selectedValues.includes(option.value));\n next = selected !== -1 ? selected : to === 1 ? 0 : enabled.length - 1;\n } else next = Math.min(enabled.length - 1, Math.max(0, current + to));\n setActiveValue(enabled[next].value);\n };\n\n /** Type-ahead: the typed characters jump to the next option starting with them; repeating one letter cycles. */\n const typeAhead = (char: string) => {\n const state = typed.current;\n window.clearTimeout(state.timer);\n state.text += char.toLowerCase();\n state.timer = window.setTimeout(() => (state.text = ''), 500);\n const candidates = options.filter((option) => !option.disabled);\n const current = candidates.findIndex((option) => option.value === activeValue);\n const repeated = state.text.split('').every((letter) => letter === state.text[0]);\n const term = repeated ? state.text[0] : state.text;\n const from = repeated || state.text.length === 1 ? current + 1 : Math.max(current, 0);\n const ordered = [...candidates.slice(from), ...candidates.slice(0, from)];\n const match = ordered.find((option) => optionText(option).toLowerCase().startsWith(term));\n if (match) setActiveValue(match.value);\n };\n\n const handleListKeys = (event: KeyboardEvent<HTMLElement>, source: 'trigger' | 'search') => {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n move(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n if (event.altKey) setOpen(false);\n else move(-1);\n break;\n case 'Home':\n case 'End':\n // In the search box these keys move the caret.\n if (source === 'trigger') {\n event.preventDefault();\n move(event.key === 'Home' ? 'first' : 'last');\n }\n break;\n case 'Enter':\n event.preventDefault();\n if (activeOption) commit(activeOption);\n break;\n case 'Tab':\n if (source === 'search') {\n // The panel lives in a portal at the end of the document: go back to the field instead of tabbing out of the page.\n event.preventDefault();\n } else keepFocusOnClose.current = true;\n setOpen(false);\n break;\n default:\n }\n };\n\n const handleTriggerKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (!isOpen) {\n if (['ArrowDown', 'ArrowUp', 'Enter', ' ', 'Home', 'End'].includes(event.key)) {\n event.preventDefault();\n setOpen(true, event.key === 'Home' ? 'first' : event.key === 'End' ? 'last' : 'selected');\n } else if (isPrintable(event)) {\n event.preventDefault();\n setOpen(true);\n if (searchable) search(event.key);\n else typeAhead(event.key);\n }\n return;\n }\n if (event.key === ' ') {\n event.preventDefault();\n // A space while typing ahead belongs to the search text (\"New York\").\n if (typed.current.text) typeAhead(' ');\n else if (activeOption) commit(activeOption);\n } else if (isPrintable(event) && !searchable) {\n event.preventDefault();\n typeAhead(event.key);\n } else handleListKeys(event, 'trigger');\n };\n\n /** Filters the list and puts the keyboard on the first match. */\n const search = (next: string) => {\n const term = next.trim().toLowerCase();\n setQuery(next);\n setActiveValue(options.find((option) => !option.disabled && (!term || matches(option, term)))?.value ?? null);\n };\n\n const single = !multiple ? selectedOptions[0] : undefined;\n const hasChips = multiple && selectedOptions.length > 0;\n const Chevron = isOpen ? UpArrowIcon : DownArrowIcon;\n\n const control = (\n <div\n className=\"tm-field tm-select__control\"\n data-size={size}\n data-tm-icon-size={size}\n data-invalid={invalid ? '' : undefined}\n data-disabled={disabled ? '' : undefined}\n data-focus={isOpen ? '' : undefined}\n data-has-chips={hasChips ? '' : undefined}\n >\n {hasChips ? (\n <span className=\"tm-select__chips\">\n {selectedOptions.map((option) => (\n <SelectedItem\n key={option.value}\n size={size}\n disabled={disabled}\n removeLabel={removeLabel(optionText(option))}\n onRemove={() => toggle(option.value)}\n >\n {option.label}\n </SelectedItem>\n ))}\n </span>\n ) : null}\n <Popover.Trigger asChild>\n <button\n ref={ref}\n type=\"button\"\n id={ids.controlId}\n className=\"tm-select__trigger\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-activedescendant={isOpen && !searchable ? activeId : undefined}\n aria-labelledby={ariaLabelledBy ?? (label ? ids.labelId : undefined)}\n aria-describedby={cn(ariaDescribedBy, ids.messageId) || undefined}\n aria-invalid={invalid || undefined}\n aria-required={required || undefined}\n disabled={disabled}\n onKeyDown={handleTriggerKeyDown}\n onKeyUp={(event) => {\n onKeyUp?.(event);\n // Firefox clicks a button on Space keyup; the keydown handler has already acted on it.\n if (event.key === ' ') event.preventDefault();\n }}\n {...props}\n >\n {startIcon}\n {single ? (\n <span className=\"tm-select__value\">{renderValue ? renderValue(single) : single.label}</span>\n ) : hasChips ? (\n // The chips sit outside the button; this keeps the selection in the combobox's own text for assistive technology.\n <span className=\"tm-select__value tm-select__value--hidden\">{selectedOptions.map(optionText).join(', ')}</span>\n ) : (\n <span className=\"tm-select__value\" data-placeholder=\"\">\n {placeholder}\n </span>\n )}\n <Chevron className=\"tm-select__chevron\" />\n </button>\n </Popover.Trigger>\n </div>\n );\n\n return (\n <Popover.Root open={isOpen} onOpenChange={(next) => setOpen(next)}>\n <FormField\n ids={ids}\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n optional={optional}\n size={size}\n className={cn('tm-select', className)}\n style={style}\n data-full-width={fullWidth ? '' : undefined}\n >\n {panelAnchor ? (\n <>\n <Popover.Anchor virtualRef={panelAnchor as RefObject<HTMLElement>} />\n {control}\n </>\n ) : (\n <Popover.Anchor asChild>{control}</Popover.Anchor>\n )}\n {name\n ? (multiple ? selectedValues : [selectedValues[0] ?? '']).map((selected) => (\n <input key={selected} type=\"hidden\" name={name} value={selected} disabled={disabled} />\n ))\n : null}\n </FormField>\n <Popover.Portal container={portalContainer}>\n <Popover.Content\n // The combobox owns the listbox directly; the popover wrapper is only a surface.\n role=\"presentation\"\n className={cn('tm-option-panel tm-select__panel', panelClassName)}\n data-size={size}\n data-fit={fullWidth ? 'field' : 'content'}\n align={align}\n sideOffset={8}\n collisionPadding={8}\n onOpenAutoFocus={(event) => {\n // Select-only combobox: focus stays on the field (or moves to the search box) and the active option is announced through aria-activedescendant.\n event.preventDefault();\n searchRef.current?.focus();\n }}\n onCloseAutoFocus={(event) => {\n if (keepFocusOnClose.current) event.preventDefault();\n keepFocusOnClose.current = false;\n }}\n >\n {searchable ? (\n <div className=\"tm-select__search\">\n <SearchIcon size=\"sm\" />\n <input\n ref={searchRef}\n className=\"tm-select__search-input\"\n type=\"text\"\n role=\"combobox\"\n aria-label={searchPlaceholder}\n aria-expanded=\"true\"\n aria-controls={listId}\n aria-autocomplete=\"list\"\n aria-activedescendant={activeId}\n autoComplete=\"off\"\n spellCheck={false}\n placeholder={searchPlaceholder}\n value={query}\n onChange={(event) => search(event.target.value)}\n onKeyDown={(event) => handleListKeys(event, 'search')}\n />\n </div>\n ) : null}\n <OptionList\n id={listId}\n size={size}\n multiple={multiple}\n surface={false}\n aria-labelledby={ariaLabelledBy ?? (label ? ids.labelId : undefined)}\n aria-label={ariaLabelledBy || label ? undefined : props['aria-label']}\n // Keeps focus on the field (or the search box) while the pointer picks an option.\n onMouseDown={(event) => event.preventDefault()}\n >\n {visible.map((option) => (\n <Option\n key={option.value}\n id={optionId(options.indexOf(option))}\n selected={selectedValues.includes(option.value)}\n active={option === activeOption}\n disabled={option.disabled}\n icon={option.icon}\n detail={option.detail}\n description={option.description}\n indicator={multiple ? 'checkbox' : checkmark ? 'check' : 'none'}\n onClick={() => commit(option)}\n >\n {option.label}\n </Option>\n ))}\n </OptionList>\n {visible.length === 0 ? (\n <p className=\"tm-select__empty\" role=\"status\">\n {emptyText}\n </p>\n ) : null}\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n});\n"],"mappings":"A,ifAuGA,IAAMwB,EAAW,GAA2D,MAAM,QAAQC,CAAK,EAAIA,EAAQA,GAAS,MAAQA,IAAU,GAAK,CAAC,EAAI,CAACA,CAAK,EAChJC,EAAU,GAA6B,OAAOC,GAAS,UAAY,OAAOA,GAAS,SAAW,OAAOA,CAAI,EAAI,GAC7GC,EAAc,GAAiCC,EAAO,YAAcH,EAAOG,EAAO,KAAK,GAAKA,EAAO,OACnGC,GAAW,EAAsB,IACrC,CAACF,EAAWC,CAAM,EAAGH,EAAOG,EAAO,MAAM,EAAGH,EAAOG,EAAO,WAAW,CAAC,CAAC,CAAC,KAAM,GAASE,EAAK,YAAY,CAAC,CAAC,SAASC,CAAK,CAAC,EACrHC,EAAe,GAAkCC,EAAM,IAAI,SAAW,GAAK,CAACA,EAAM,SAAW,CAACA,EAAM,SAAW,CAACA,EAAM,OACtHC,GAAsB,GAAuB,UAAUP,IAShDQ,GAAyB,EAAAf,EAAA,WAAA,CAA2C,SAC/E,CACE,QACA,aACA,QACA,WACA,YACA,OAAO,KACP,UACA,eAAc,gBACd,OACA,QAASgB,GACT,aAAa,GACb,qBAAoB,SACpB,aAAY,aACZ,aACA,cACA,aAAY,GACZ,YAAY,GACZ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AhD,EAAA,IAAA,CAACV,EAAAA,OAAD,CAEE,GAAImC,GAASkB,EAAQ,QAAQpC,CAAM,CAAC,EACpC,SAAUkC,EAAe,SAASlC,EAAO,KAAK,EAC9C,OAAQA,IAAW2C,EACnB,SAAU3C,EAAO,SACjB,KAAMA,EAAO,KACb,OAAQA,EAAO,OACf,YAAaA,EAAO,YACpB,UAAWsD,EAAW,WAAauC,GAAY,QAAU,OACzD,YAAepC,EAAOzD,CAAM,EAE3B,SAAAA,EAAO,KACF,EAZDA,EAAO,KAYN,CACT,CACS,CAAA,EACXyC,EAAQ,SAAW,GAClB,EAAAhD,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,mBAAmB,KAAK,SAClC,SAAAqG,EACA,CAAA,EACD,IACW,C,EACH,CAAA,CACJ,C,EAElB,CAAC,E"}
1
+ {"version":3,"file":"Select.cjs","names":["useFieldIds","useState","useRef","useMemo","UpArrowIcon","DownArrowIcon","SelectedItem","Popover","cn","FormField","_Fragment","SearchIcon","OptionList","Option","require_runtime","require_DownArrowIcon","require_SearchIcon","require_UpArrowIcon","require_cn","require_Field","require_OptionList","require_SelectedItem","react","react_jsx_runtime","_radix_ui_react_popover","toArray","value","asText","node","optionText","option","matches","text","query","isPrintable","event","defaultRemoveLabel","Select","invalidProp","openProp","ariaDescribedBy","ariaLabelledBy","props","ids","id","error","helperText","listId","optionId","index","internalOpen","setInternalOpen","defaultOpen","internalValue","setInternalValue","defaultValue","setQuery","activeValue","setActiveValue","searchRef","keepFocusOnClose","typed","isOpen","disabled","anchorVersion","setAnchorVersion","panelAnchor","version","virtualAnchor","selectedValues","selectedOptions","options","selected","invalid","needle","searchable","visible","enabled","activeOption","activeId","setOpen","next","candidates","initial","focus","onOpenChange","emit","notify","onValueChange","multiple","toggle","optionValue","commit","move","current","to","typeAhead","state","char","repeated","letter","term","from","match","handleListKeys","source","handleTriggerKeyDown","onKeyDown","search","single","hasChips","Chevron","control","size","removeLabel","label","required","onKeyUp","startIcon","renderValue","placeholder","className","fullWidth","name","portalContainer","panelClassName","searchPlaceholder","checkmark","emptyText"],"sources":["../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as Popover from '@radix-ui/react-popover';\nimport {\n forwardRef,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type KeyboardEvent,\n type ReactNode,\n type RefObject,\n} from 'react';\nimport { DownArrowIcon, SearchIcon, UpArrowIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport { FormField, useFieldIds, type FieldSize, type FormFieldProps } from '../Field';\nimport { Option, OptionList } from '../OptionList';\nimport { SelectedItem } from './SelectedItem';\nimport './Select.css';\n\nexport interface SelectOption {\n /** What `value` / `onValueChange` carry and what a form submits. */\n value: string;\n /** Text in the list and in the field, e.g. \"Armenia\", \"EN\", \"AMD\". */\n label: ReactNode;\n /** Regular-weight text after the label in the list only, e.g. \"English\" after \"EN\". */\n detail?: ReactNode;\n /** Small second line in the list (Figma \"Caption\"). */\n description?: ReactNode;\n /** Icon or flag before the label in the list (Figma \"Icon\"). */\n icon?: ReactNode;\n /** The option is shown but cannot be chosen. */\n disabled?: boolean;\n /** Plain text for type-ahead, search and the remove button when `label` is not a string. */\n textValue?: string;\n}\n\ntype TriggerProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange' | 'children' | 'type' | 'name' | 'role'>;\n\ninterface SelectBaseProps extends FormFieldProps, TriggerProps {\n /** The options, in display order. */\n options: SelectOption[];\n /** Shown in the field while nothing is selected. */\n placeholder?: ReactNode;\n /** Figma \"Size\": `lg` 52px · `md` 46px (default) · `sm` 42px. */\n size?: FieldSize;\n /** Adds hidden inputs so the value is submitted with a native form (one per value when `multiple`). */\n name?: string;\n /** Invalid look without a message of its own — for composite fields that show one message for several controls. */\n invalid?: boolean;\n /** Adds a search box above the list (Figma \"Type=Currency, State=Open\"); typing filters by label, detail and description. */\n searchable?: boolean;\n /** Placeholder and accessible name of the search box. */\n searchPlaceholder?: string;\n /** Shown instead of the list when the search matches nothing. */\n emptyText?: ReactNode;\n /** Icon in front of the value, e.g. `<LanguageIcon />`. */\n startIcon?: ReactNode;\n /** Custom content for the selected option in the field (single select), e.g. flag + dial code. Defaults to its `label`. */\n renderValue?: (option: SelectOption) => ReactNode;\n /** Shows the check mark on the selected option (Figma \"Done\"). Ignored when `multiple`, which uses checkboxes. */\n checkmark?: boolean;\n /** `false` makes the field hug its content (Figma \"Both-icon-drop-down\", \"Language\", \"Type=Currency\"); the list is then as wide as its options. */\n fullWidth?: boolean;\n /** How the list lines up with the field. */\n align?: 'start' | 'center' | 'end';\n /** Whether the list is open (controlled; Figma \"State=Clicked\" / \"Open\"). */\n open?: boolean;\n /** Opens the list initially (uncontrolled). */\n defaultOpen?: boolean;\n /** Called when the list opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /** Element the list is rendered into (default `document.body`). Set it when the theme is scoped to a container. */\n portalContainer?: HTMLElement | null;\n /** Element the list aligns to and takes its width from, when that is not the field itself (e.g. a whole phone-number row). */\n panelAnchor?: RefObject<HTMLElement | null>;\n /** Class for the list panel, which is rendered in a portal outside the root. */\n panelClassName?: string;\n /** Accessible name of a chip's × button (`multiple`), given the option's text. */\n removeLabel?: (optionText: string) => string;\n}\n\nexport interface SelectSingleProps extends SelectBaseProps {\n /** `true` turns the field into a multi-select (Figma \"Type=Checkbox\"): checkboxes in the list, removable chips in the field. */\n multiple?: false;\n /** Selected option value (controlled); `null` or `''` for none. */\n value?: string | null;\n /** Initially selected value (uncontrolled). */\n defaultValue?: string | null;\n /** Called with the chosen option's value. */\n onValueChange?: (value: string) => void;\n}\n\nexport interface SelectMultipleProps extends SelectBaseProps {\n multiple: true;\n /** Selected option values (controlled). */\n value?: string[];\n /** Initially selected values (uncontrolled). */\n defaultValue?: string[];\n /** Called with all selected values after one is added or removed. */\n onValueChange?: (value: string[]) => void;\n}\n\nexport type SelectProps = SelectSingleProps | SelectMultipleProps;\n\nconst toArray = (value: string | string[] | null | undefined): string[] => (Array.isArray(value) ? value : value == null || value === '' ? [] : [value]);\nconst asText = (node: ReactNode): string => (typeof node === 'string' || typeof node === 'number' ? String(node) : '');\nconst optionText = (option: SelectOption): string => option.textValue ?? (asText(option.label) || option.value);\nconst matches = (option: SelectOption, query: string): boolean =>\n [optionText(option), asText(option.detail), asText(option.description)].some((text) => text.toLowerCase().includes(query));\nconst isPrintable = (event: KeyboardEvent): boolean => event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;\nconst defaultRemoveLabel = (optionText: string) => `Remove ${optionText}`;\n\ntype InitialFocus = 'selected' | 'first' | 'last' | 'none';\n\n/**\n * Figma component set \"Drop down inputs\" (Type=Select · Checkbox, and the base of Language · Phone · Currency):\n * a field that opens a list of options. Keyboard support follows the WAI-ARIA select-only combobox pattern.\n * The ref and any extra props go to the trigger `<button role=\"combobox\">`; `className` goes to the root.\n */\nexport const Select = /* @__PURE__ */ forwardRef<HTMLButtonElement, SelectProps>(function Select(\n {\n label,\n helperText,\n error,\n required,\n optional,\n size = 'md',\n options,\n placeholder = 'Select option',\n name,\n invalid: invalidProp,\n searchable = false,\n searchPlaceholder = 'Search',\n emptyText = 'No results',\n startIcon,\n renderValue,\n checkmark = true,\n fullWidth = true,\n align = 'start',\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n portalContainer,\n panelAnchor,\n panelClassName,\n removeLabel = defaultRemoveLabel,\n multiple = false,\n value,\n defaultValue,\n onValueChange,\n disabled = false,\n id,\n className,\n style,\n onKeyDown,\n onKeyUp,\n 'aria-describedby': ariaDescribedBy,\n 'aria-labelledby': ariaLabelledBy,\n ...props\n },\n ref,\n) {\n const ids = useFieldIds(id, Boolean(error || helperText));\n const listId = `${ids.controlId}-list`;\n const optionId = (index: number) => `${ids.controlId}-option-${index}`;\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const [internalValue, setInternalValue] = useState<string[]>(() => toArray(defaultValue));\n const [query, setQuery] = useState('');\n const [activeValue, setActiveValue] = useState<string | null>(null);\n const searchRef = useRef<HTMLInputElement>(null);\n const keepFocusOnClose = useRef(false);\n const typed = useRef({ text: '', timer: 0 });\n\n const isOpen = (openProp ?? internalOpen) && !disabled;\n\n // `panelAnchor`: the list is positioned against a \"virtual\" element that measures the anchor each time it is asked.\n // Radix registers a virtual anchor only when its object changes, and it can end up holding the trigger instead:\n // on mount the trigger briefly registers itself as the anchor and is then replaced by a new button, which leaves\n // a removed element (measured as 0 × 0 at the top left of the page, so the list opened there; seen with React\n // Strict Mode and server rendering). A fresh object after mount and whenever the list opens or closes makes Radix\n // take the right anchor again.\n const [anchorVersion, setAnchorVersion] = useState(0);\n useEffect(() => {\n if (panelAnchor) setAnchorVersion((version) => version + 1);\n }, [panelAnchor, isOpen]);\n const virtualAnchor = useMemo(\n () => ({\n current: {\n getBoundingClientRect: () => panelAnchor?.current?.getBoundingClientRect() ?? new DOMRect(),\n // lets the positioning follow the anchor's scrolling ancestors\n contextElement: panelAnchor?.current ?? undefined,\n },\n }),\n // anchorVersion is listed on purpose: a new object per version\n [panelAnchor, anchorVersion],\n );\n const selectedValues = value !== undefined ? toArray(value) : internalValue;\n const selectedOptions = selectedValues.map((selected) => options.find((option) => option.value === selected)).filter((option) => option !== undefined);\n const invalid = Boolean(error) || Boolean(invalidProp);\n\n const needle = searchable ? query.trim().toLowerCase() : '';\n const visible = needle ? options.filter((option) => matches(option, needle)) : options;\n const enabled = visible.filter((option) => !option.disabled);\n const activeOption = enabled.find((option) => option.value === activeValue);\n const activeId = activeOption ? optionId(options.indexOf(activeOption)) : undefined;\n\n useEffect(() => {\n if (isOpen && activeId) document.getElementById(activeId)?.scrollIntoView?.({ block: 'nearest' });\n }, [isOpen, activeId]);\n\n useEffect(() => () => window.clearTimeout(typed.current.timer), []);\n\n const setOpen = (next: boolean, focus: InitialFocus = 'none') => {\n if (next) {\n const candidates = options.filter((option) => !option.disabled);\n const selected = candidates.find((option) => selectedValues.includes(option.value));\n const initial = focus === 'none' ? undefined : focus === 'last' ? candidates[candidates.length - 1] : focus === 'first' ? candidates[0] : (selected ?? candidates[0]);\n setQuery('');\n setActiveValue(initial?.value ?? null);\n }\n if (openProp === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n const emit = (next: string[]) => {\n if (value === undefined) setInternalValue(next);\n const notify = onValueChange as ((next: string | string[]) => void) | undefined;\n if (multiple) notify?.(next);\n else if (next[0] !== undefined) notify?.(next[0]);\n };\n\n const toggle = (optionValue: string) =>\n emit(selectedValues.includes(optionValue) ? selectedValues.filter((selected) => selected !== optionValue) : [...selectedValues, optionValue]);\n\n const commit = (option: SelectOption) => {\n if (option.disabled) return;\n if (multiple) {\n toggle(option.value);\n setActiveValue(option.value);\n return;\n }\n if (selectedValues[0] !== option.value) emit([option.value]);\n setOpen(false);\n };\n\n const move = (to: 1 | -1 | 'first' | 'last') => {\n if (enabled.length === 0) return;\n const current = activeOption ? enabled.indexOf(activeOption) : -1;\n let next: number;\n if (to === 'first') next = 0;\n else if (to === 'last') next = enabled.length - 1;\n else if (current === -1) {\n // Opened with the pointer: start from the selected option, like a native select.\n const selected = enabled.findIndex((option) => selectedValues.includes(option.value));\n next = selected !== -1 ? selected : to === 1 ? 0 : enabled.length - 1;\n } else next = Math.min(enabled.length - 1, Math.max(0, current + to));\n setActiveValue(enabled[next].value);\n };\n\n /** Type-ahead: the typed characters jump to the next option starting with them; repeating one letter cycles. */\n const typeAhead = (char: string) => {\n const state = typed.current;\n window.clearTimeout(state.timer);\n state.text += char.toLowerCase();\n state.timer = window.setTimeout(() => (state.text = ''), 500);\n const candidates = options.filter((option) => !option.disabled);\n const current = candidates.findIndex((option) => option.value === activeValue);\n const repeated = state.text.split('').every((letter) => letter === state.text[0]);\n const term = repeated ? state.text[0] : state.text;\n const from = repeated || state.text.length === 1 ? current + 1 : Math.max(current, 0);\n const ordered = [...candidates.slice(from), ...candidates.slice(0, from)];\n const match = ordered.find((option) => optionText(option).toLowerCase().startsWith(term));\n if (match) setActiveValue(match.value);\n };\n\n const handleListKeys = (event: KeyboardEvent<HTMLElement>, source: 'trigger' | 'search') => {\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n move(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n if (event.altKey) setOpen(false);\n else move(-1);\n break;\n case 'Home':\n case 'End':\n // In the search box these keys move the caret.\n if (source === 'trigger') {\n event.preventDefault();\n move(event.key === 'Home' ? 'first' : 'last');\n }\n break;\n case 'Enter':\n event.preventDefault();\n if (activeOption) commit(activeOption);\n break;\n case 'Tab':\n if (source === 'search') {\n // The panel lives in a portal at the end of the document: go back to the field instead of tabbing out of the page.\n event.preventDefault();\n } else keepFocusOnClose.current = true;\n setOpen(false);\n break;\n default:\n }\n };\n\n const handleTriggerKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n if (!isOpen) {\n if (['ArrowDown', 'ArrowUp', 'Enter', ' ', 'Home', 'End'].includes(event.key)) {\n event.preventDefault();\n setOpen(true, event.key === 'Home' ? 'first' : event.key === 'End' ? 'last' : 'selected');\n } else if (isPrintable(event)) {\n event.preventDefault();\n setOpen(true);\n if (searchable) search(event.key);\n else typeAhead(event.key);\n }\n return;\n }\n if (event.key === ' ') {\n event.preventDefault();\n // A space while typing ahead belongs to the search text (\"New York\").\n if (typed.current.text) typeAhead(' ');\n else if (activeOption) commit(activeOption);\n } else if (isPrintable(event) && !searchable) {\n event.preventDefault();\n typeAhead(event.key);\n } else handleListKeys(event, 'trigger');\n };\n\n /** Filters the list and puts the keyboard on the first match. */\n const search = (next: string) => {\n const term = next.trim().toLowerCase();\n setQuery(next);\n setActiveValue(options.find((option) => !option.disabled && (!term || matches(option, term)))?.value ?? null);\n };\n\n const single = !multiple ? selectedOptions[0] : undefined;\n const hasChips = multiple && selectedOptions.length > 0;\n const Chevron = isOpen ? UpArrowIcon : DownArrowIcon;\n\n const control = (\n <div\n className=\"tm-field tm-select__control\"\n data-size={size}\n data-tm-icon-size={size}\n data-invalid={invalid ? '' : undefined}\n data-disabled={disabled ? '' : undefined}\n data-focus={isOpen ? '' : undefined}\n data-has-chips={hasChips ? '' : undefined}\n >\n {hasChips ? (\n <span className=\"tm-select__chips\">\n {selectedOptions.map((option) => (\n <SelectedItem\n key={option.value}\n size={size}\n disabled={disabled}\n removeLabel={removeLabel(optionText(option))}\n onRemove={() => toggle(option.value)}\n >\n {option.label}\n </SelectedItem>\n ))}\n </span>\n ) : null}\n <Popover.Trigger asChild>\n <button\n ref={ref}\n type=\"button\"\n id={ids.controlId}\n className=\"tm-select__trigger\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-activedescendant={isOpen && !searchable ? activeId : undefined}\n aria-labelledby={ariaLabelledBy ?? (label ? ids.labelId : undefined)}\n aria-describedby={cn(ariaDescribedBy, ids.messageId) || undefined}\n aria-invalid={invalid || undefined}\n aria-required={required || undefined}\n disabled={disabled}\n onKeyDown={handleTriggerKeyDown}\n onKeyUp={(event) => {\n onKeyUp?.(event);\n // Firefox clicks a button on Space keyup; the keydown handler has already acted on it.\n if (event.key === ' ') event.preventDefault();\n }}\n {...props}\n >\n {startIcon}\n {single ? (\n <span className=\"tm-select__value\">{renderValue ? renderValue(single) : single.label}</span>\n ) : hasChips ? (\n // The chips sit outside the button; this keeps the selection in the combobox's own text for assistive technology.\n <span className=\"tm-select__value tm-select__value--hidden\">{selectedOptions.map(optionText).join(', ')}</span>\n ) : (\n <span className=\"tm-select__value\" data-placeholder=\"\">\n {placeholder}\n </span>\n )}\n <Chevron className=\"tm-select__chevron\" />\n </button>\n </Popover.Trigger>\n </div>\n );\n\n return (\n <Popover.Root open={isOpen} onOpenChange={(next) => setOpen(next)}>\n <FormField\n ids={ids}\n label={label}\n helperText={helperText}\n error={error}\n required={required}\n optional={optional}\n size={size}\n className={cn('tm-select', className)}\n style={style}\n data-full-width={fullWidth ? '' : undefined}\n >\n {panelAnchor ? (\n <>\n <Popover.Anchor virtualRef={virtualAnchor} />\n {control}\n </>\n ) : (\n <Popover.Anchor asChild>{control}</Popover.Anchor>\n )}\n {name\n ? (multiple ? selectedValues : [selectedValues[0] ?? '']).map((selected) => (\n <input key={selected} type=\"hidden\" name={name} value={selected} disabled={disabled} />\n ))\n : null}\n </FormField>\n <Popover.Portal container={portalContainer}>\n <Popover.Content\n // The combobox owns the listbox directly; the popover wrapper is only a surface.\n role=\"presentation\"\n className={cn('tm-option-panel tm-select__panel', panelClassName)}\n data-size={size}\n data-fit={fullWidth ? 'field' : 'content'}\n align={align}\n sideOffset={8}\n collisionPadding={8}\n onOpenAutoFocus={(event) => {\n // Select-only combobox: focus stays on the field (or moves to the search box) and the active option is announced through aria-activedescendant.\n event.preventDefault();\n searchRef.current?.focus();\n }}\n onCloseAutoFocus={(event) => {\n if (keepFocusOnClose.current) event.preventDefault();\n keepFocusOnClose.current = false;\n }}\n >\n {searchable ? (\n <div className=\"tm-select__search\">\n <SearchIcon size=\"sm\" />\n <input\n ref={searchRef}\n className=\"tm-select__search-input\"\n type=\"text\"\n role=\"combobox\"\n aria-label={searchPlaceholder}\n aria-expanded=\"true\"\n aria-controls={listId}\n aria-autocomplete=\"list\"\n aria-activedescendant={activeId}\n autoComplete=\"off\"\n spellCheck={false}\n placeholder={searchPlaceholder}\n value={query}\n onChange={(event) => search(event.target.value)}\n onKeyDown={(event) => handleListKeys(event, 'search')}\n />\n </div>\n ) : null}\n <OptionList\n id={listId}\n size={size}\n multiple={multiple}\n surface={false}\n aria-labelledby={ariaLabelledBy ?? (label ? ids.labelId : undefined)}\n aria-label={ariaLabelledBy || label ? undefined : props['aria-label']}\n // Keeps focus on the field (or the search box) while the pointer picks an option.\n onMouseDown={(event) => event.preventDefault()}\n >\n {visible.map((option) => (\n <Option\n key={option.value}\n id={optionId(options.indexOf(option))}\n selected={selectedValues.includes(option.value)}\n active={option === activeOption}\n disabled={option.disabled}\n icon={option.icon}\n detail={option.detail}\n description={option.description}\n indicator={multiple ? 'checkbox' : checkmark ? 'check' : 'none'}\n onClick={() => commit(option)}\n >\n {option.label}\n </Option>\n ))}\n </OptionList>\n {visible.length === 0 ? (\n <p className=\"tm-select__empty\" role=\"status\">\n {emptyText}\n </p>\n ) : null}\n </Popover.Content>\n </Popover.Portal>\n </Popover.Root>\n );\n});\n"],"mappings":"A,ifAwGA,IAAMyB,EAAW,GAA2D,MAAM,QAAQC,CAAK,EAAIA,EAAQA,GAAS,MAAQA,IAAU,GAAK,CAAC,EAAI,CAACA,CAAK,EAChJC,EAAU,GAA6B,OAAOC,GAAS,UAAY,OAAOA,GAAS,SAAW,OAAOA,CAAI,EAAI,GAC7GC,EAAc,GAAiCC,EAAO,YAAcH,EAAOG,EAAO,KAAK,GAAKA,EAAO,OACnGC,GAAW,EAAsB,IACrC,CAACF,EAAWC,CAAM,EAAGH,EAAOG,EAAO,MAAM,EAAGH,EAAOG,EAAO,WAAW,CAAC,CAAC,CAAC,KAAM,GAASE,EAAK,YAAY,CAAC,CAAC,SAASC,CAAK,CAAC,EACrHC,EAAe,GAAkCC,EAAM,IAAI,SAAW,GAAK,CAACA,EAAM,SAAW,CAACA,EAAM,SAAW,CAACA,EAAM,OACtHC,GAAsB,GAAuB,UAAUP,IAShDQ,GAAyB,EAAAf,EAAA,WAAA,CAA2C,SAC/E,CACE,QACA,aACA,QACA,WACA,YACA,OAAO,KACP,UACA,eAAc,gBACd,OACA,QAASgB,GACT,aAAa,GACb,oBAAoB,SACpB,aAAY,aACZ,aACA,cACA,aAAY,GACZ,YAAY,GACZ,SAAQ,QACR,KAAMC,GACN,eAAc,GACd,gBACA,mBACA,cACA,kBACA,eAAcH,GACd,WAAW,GACX,QACA,gBACA,iBACA,WAAW,GACX,MACA,aACA,SACA,aACA,WACA,mBAAoBI,GACpB,kBAAmBC,EACnB,GAAGC,GAEL,GACA,CACA,IAAMC,EAAM3C,EAAAA,YAAY4C,GAAI,GAAQC,GAASC,EAAW,EAClDC,EAAS,GAAGJ,EA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AAYF,GAAkB0E,EAAQ,IAAA,GAAYzE,EAAM,cAExD,YAAc,GAAUP,EAAM,eAAe,EAE5C,SAAAyC,EAAQ,IAAK,IACZ,EAAArD,EAAA,IAAA,CAACV,EAAAA,OAAD,CAEE,GAAImC,GAASuB,EAAQ,QAAQzC,CAAM,CAAC,EACpC,SAAUuC,EAAe,SAASvC,EAAO,KAAK,EAC9C,OAAQA,IAAWgD,EACnB,SAAUhD,EAAO,SACjB,KAAMA,EAAO,KACb,OAAQA,EAAO,OACf,YAAaA,EAAO,YACpB,UAAW2D,EAAW,WAAasC,GAAY,QAAU,OACzD,YAAenC,EAAO9D,CAAM,EAE3B,SAAAA,EAAO,KACF,EAZDA,EAAO,KAYN,CACT,CACS,CAAA,EACX8C,EAAQ,SAAW,GAClB,EAAArD,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,mBAAmB,KAAK,SAClC,SAAAyG,EACA,CAAA,EACD,IACW,C,EACH,CAAA,CACJ,C,EAElB,CAAC,E"}
@@ -7,93 +7,100 @@ import { FormField as i, useFieldIds as a } from "../Field/Field.js";
7
7
  import { Option as o, OptionList as s } from "../OptionList/OptionList.js";
8
8
  import { SelectedItem as ee } from "./SelectedItem.js";
9
9
  /* empty css */
10
- import { forwardRef as c, useEffect as l, useRef as u, useState as d } from "react";
11
- import { Fragment as te, jsx as f, jsxs as p } from "react/jsx-runtime";
10
+ import { forwardRef as c, useEffect as l, useMemo as te, useRef as u, useState as d } from "react";
11
+ import { Fragment as ne, jsx as f, jsxs as p } from "react/jsx-runtime";
12
12
  import * as m from "@radix-ui/react-popover";
13
13
  // src/components/Select/Select.tsx
14
- var ne = (e) => Array.isArray(e) ? e : e == null || e === "" ? [] : [e], h = (e) => typeof e == "string" || typeof e == "number" ? String(e) : "", g = (e) => e.textValue ?? (h(e.label) || e.value), _ = (e, t) => [
15
- g(e),
16
- h(e.detail),
17
- h(e.description)
18
- ].some((e) => e.toLowerCase().includes(t)), v = (e) => e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey, re = (e) => `Remove ${e}`, y = /* @__PURE__ */ c(function({ label: c, helperText: h, error: y, required: b, optional: ie, size: x = "md", options: S, placeholder: ae = "Select option", name: oe, invalid: se, searchable: C = !1, searchPlaceholder: ce = "Search", emptyText: le = "No results", startIcon: ue, renderValue: de, checkmark: fe = !0, fullWidth: pe = !0, align: me = "start", open: he, defaultOpen: ge = !1, onOpenChange: _e, portalContainer: ve, panelAnchor: w, panelClassName: ye, removeLabel: be = re, multiple: T = !1, value: E, defaultValue: xe, onValueChange: Se, disabled: D = !1, id: Ce, className: we, style: Te, onKeyDown: Ee, onKeyUp: De, "aria-describedby": Oe, "aria-labelledby": O, ...k }, ke) {
19
- let A = a(Ce, !!(y || h)), j = `${A.controlId}-list`, M = (e) => `${A.controlId}-option-${e}`, [Ae, je] = d(ge), [Me, Ne] = d(() => ne(xe)), [N, P] = d(""), [F, I] = d(null), L = u(null), R = u(!1), z = u({
14
+ var h = (e) => Array.isArray(e) ? e : e == null || e === "" ? [] : [e], g = (e) => typeof e == "string" || typeof e == "number" ? String(e) : "", _ = (e) => e.textValue ?? (g(e.label) || e.value), v = (e, t) => [
15
+ _(e),
16
+ g(e.detail),
17
+ g(e.description)
18
+ ].some((e) => e.toLowerCase().includes(t)), y = (e) => e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey, re = (e) => `Remove ${e}`, b = /* @__PURE__ */ c(function({ label: c, helperText: g, error: b, required: ie, optional: ae, size: x = "md", options: S, placeholder: oe = "Select option", name: C, invalid: se, searchable: w = !1, searchPlaceholder: T = "Search", emptyText: ce = "No results", startIcon: le, renderValue: ue, checkmark: de = !0, fullWidth: fe = !0, align: pe = "start", open: me, defaultOpen: he = !1, onOpenChange: ge, portalContainer: _e, panelAnchor: E, panelClassName: ve, removeLabel: ye = re, multiple: D = !1, value: O, defaultValue: be, onValueChange: xe, disabled: k = !1, id: Se, className: Ce, style: we, onKeyDown: Te, onKeyUp: Ee, "aria-describedby": De, "aria-labelledby": A, ...Oe }, ke) {
19
+ let j = a(Se, !!(b || g)), M = `${j.controlId}-list`, Ae = (e) => `${j.controlId}-option-${e}`, [je, Me] = d(he), [Ne, Pe] = d(() => h(be)), [Fe, N] = d(""), [P, F] = d(null), I = u(null), L = u(!1), R = u({
20
20
  text: "",
21
21
  timer: 0
22
- }), B = (he ?? Ae) && !D, V = E === void 0 ? Me : ne(E), H = V.map((e) => S.find((t) => t.value === e)).filter((e) => e !== void 0), Pe = !!y || !!se, Fe = C ? N.trim().toLowerCase() : "", U = Fe ? S.filter((e) => _(e, Fe)) : S, W = U.filter((e) => !e.disabled), G = W.find((e) => e.value === F), K = G ? M(S.indexOf(G)) : void 0;
22
+ }), z = (me ?? je) && !k, [Ie, Le] = d(0);
23
23
  l(() => {
24
- B && K && document.getElementById(K)?.scrollIntoView?.({ block: "nearest" });
25
- }, [B, K]), l(() => () => window.clearTimeout(z.current.timer), []);
26
- let q = (e, t = "none") => {
24
+ E && Le((e) => e + 1);
25
+ }, [E, z]);
26
+ let Re = te(() => ({ current: {
27
+ getBoundingClientRect: () => E?.current?.getBoundingClientRect() ?? new DOMRect(),
28
+ contextElement: E?.current ?? void 0
29
+ } }), [E, Ie]), B = O === void 0 ? Ne : h(O), V = B.map((e) => S.find((t) => t.value === e)).filter((e) => e !== void 0), H = !!b || !!se, U = w ? Fe.trim().toLowerCase() : "", W = U ? S.filter((e) => v(e, U)) : S, G = W.filter((e) => !e.disabled), K = G.find((e) => e.value === P), q = K ? Ae(S.indexOf(K)) : void 0;
30
+ l(() => {
31
+ z && q && document.getElementById(q)?.scrollIntoView?.({ block: "nearest" });
32
+ }, [z, q]), l(() => () => window.clearTimeout(R.current.timer), []);
33
+ let J = (e, t = "none") => {
27
34
  if (e) {
28
- let e = S.filter((e) => !e.disabled), n = e.find((e) => V.includes(e.value)), r = t === "none" ? void 0 : t === "last" ? e[e.length - 1] : t === "first" ? e[0] : n ?? e[0];
29
- P(""), I(r?.value ?? null);
35
+ let e = S.filter((e) => !e.disabled), n = e.find((e) => B.includes(e.value)), r = t === "none" ? void 0 : t === "last" ? e[e.length - 1] : t === "first" ? e[0] : n ?? e[0];
36
+ N(""), F(r?.value ?? null);
30
37
  }
31
- he === void 0 && je(e), _e?.(e);
32
- }, Ie = (e) => {
33
- E === void 0 && Ne(e);
34
- let t = Se;
35
- T ? t?.(e) : e[0] !== void 0 && t?.(e[0]);
36
- }, Le = (e) => Ie(V.includes(e) ? V.filter((t) => t !== e) : [...V, e]), J = (e) => {
37
- e.disabled || (T ? (Le(e.value), I(e.value)) : (V[0] !== e.value && Ie([e.value]), q(!1)));
38
- }, Y = (e) => {
39
- if (W.length === 0) return;
40
- let t = G ? W.indexOf(G) : -1, n;
38
+ me === void 0 && Me(e), ge?.(e);
39
+ }, ze = (e) => {
40
+ O === void 0 && Pe(e);
41
+ let t = xe;
42
+ D ? t?.(e) : e[0] !== void 0 && t?.(e[0]);
43
+ }, Be = (e) => ze(B.includes(e) ? B.filter((t) => t !== e) : [...B, e]), Y = (e) => {
44
+ e.disabled || (D ? (Be(e.value), F(e.value)) : (B[0] !== e.value && ze([e.value]), J(!1)));
45
+ }, X = (e) => {
46
+ if (G.length === 0) return;
47
+ let t = K ? G.indexOf(K) : -1, n;
41
48
  if (e === "first") n = 0;
42
- else if (e === "last") n = W.length - 1;
49
+ else if (e === "last") n = G.length - 1;
43
50
  else if (t === -1) {
44
- let t = W.findIndex((e) => V.includes(e.value));
45
- n = t === -1 ? e === 1 ? 0 : W.length - 1 : t;
46
- } else n = Math.min(W.length - 1, Math.max(0, t + e));
47
- I(W[n].value);
48
- }, X = (e) => {
49
- let t = z.current;
51
+ let t = G.findIndex((e) => B.includes(e.value));
52
+ n = t === -1 ? e === 1 ? 0 : G.length - 1 : t;
53
+ } else n = Math.min(G.length - 1, Math.max(0, t + e));
54
+ F(G[n].value);
55
+ }, Z = (e) => {
56
+ let t = R.current;
50
57
  window.clearTimeout(t.timer), t.text += e.toLowerCase(), t.timer = window.setTimeout(() => t.text = "", 500);
51
- let n = S.filter((e) => !e.disabled), r = n.findIndex((e) => e.value === F), i = t.text.split("").every((e) => e === t.text[0]), a = i ? t.text[0] : t.text, o = i || t.text.length === 1 ? r + 1 : Math.max(r, 0), s = [...n.slice(o), ...n.slice(0, o)].find((e) => g(e).toLowerCase().startsWith(a));
52
- s && I(s.value);
53
- }, Re = (e, t) => {
58
+ let n = S.filter((e) => !e.disabled), r = n.findIndex((e) => e.value === P), i = t.text.split("").every((e) => e === t.text[0]), a = i ? t.text[0] : t.text, o = i || t.text.length === 1 ? r + 1 : Math.max(r, 0), s = [...n.slice(o), ...n.slice(0, o)].find((e) => _(e).toLowerCase().startsWith(a));
59
+ s && F(s.value);
60
+ }, Ve = (e, t) => {
54
61
  switch (e.key) {
55
62
  case "ArrowDown":
56
- e.preventDefault(), Y(1);
63
+ e.preventDefault(), X(1);
57
64
  break;
58
65
  case "ArrowUp":
59
- e.preventDefault(), e.altKey ? q(!1) : Y(-1);
66
+ e.preventDefault(), e.altKey ? J(!1) : X(-1);
60
67
  break;
61
68
  case "Home":
62
69
  case "End":
63
- t === "trigger" && (e.preventDefault(), Y(e.key === "Home" ? "first" : "last"));
70
+ t === "trigger" && (e.preventDefault(), X(e.key === "Home" ? "first" : "last"));
64
71
  break;
65
72
  case "Enter":
66
- e.preventDefault(), G && J(G);
73
+ e.preventDefault(), K && Y(K);
67
74
  break;
68
- case "Tab": t === "search" ? e.preventDefault() : R.current = !0, q(!1);
75
+ case "Tab": t === "search" ? e.preventDefault() : L.current = !0, J(!1);
69
76
  }
70
- }, ze = (e) => {
71
- Ee?.(e), e.defaultPrevented || (B ? e.key === " " ? (e.preventDefault(), z.current.text ? X(" ") : G && J(G)) : v(e) && !C ? (e.preventDefault(), X(e.key)) : Re(e, "trigger") : [
77
+ }, He = (e) => {
78
+ Te?.(e), e.defaultPrevented || (z ? e.key === " " ? (e.preventDefault(), R.current.text ? Z(" ") : K && Y(K)) : y(e) && !w ? (e.preventDefault(), Z(e.key)) : Ve(e, "trigger") : [
72
79
  "ArrowDown",
73
80
  "ArrowUp",
74
81
  "Enter",
75
82
  " ",
76
83
  "Home",
77
84
  "End"
78
- ].includes(e.key) ? (e.preventDefault(), q(!0, e.key === "Home" ? "first" : e.key === "End" ? "last" : "selected")) : v(e) && (e.preventDefault(), q(!0), C ? Z(e.key) : X(e.key)));
79
- }, Z = (e) => {
85
+ ].includes(e.key) ? (e.preventDefault(), J(!0, e.key === "Home" ? "first" : e.key === "End" ? "last" : "selected")) : y(e) && (e.preventDefault(), J(!0), w ? Ue(e.key) : Z(e.key)));
86
+ }, Ue = (e) => {
80
87
  let t = e.trim().toLowerCase();
81
- P(e), I(S.find((e) => !e.disabled && (!t || _(e, t)))?.value ?? null);
82
- }, Q = T ? void 0 : H[0], $ = T && H.length > 0, Be = B ? n : e, Ve = /* @__PURE__ */ p("div", {
88
+ N(e), F(S.find((e) => !e.disabled && (!t || v(e, t)))?.value ?? null);
89
+ }, Q = D ? void 0 : V[0], $ = D && V.length > 0, We = z ? n : e, Ge = /* @__PURE__ */ p("div", {
83
90
  className: "tm-field tm-select__control",
84
91
  "data-size": x,
85
92
  "data-tm-icon-size": x,
86
- "data-invalid": Pe ? "" : void 0,
87
- "data-disabled": D ? "" : void 0,
88
- "data-focus": B ? "" : void 0,
93
+ "data-invalid": H ? "" : void 0,
94
+ "data-disabled": k ? "" : void 0,
95
+ "data-focus": z ? "" : void 0,
89
96
  "data-has-chips": $ ? "" : void 0,
90
97
  children: [$ ? /* @__PURE__ */ f("span", {
91
98
  className: "tm-select__chips",
92
- children: H.map((e) => /* @__PURE__ */ f(ee, {
99
+ children: V.map((e) => /* @__PURE__ */ f(ee, {
93
100
  size: x,
94
- disabled: D,
95
- removeLabel: be(g(e)),
96
- onRemove: () => Le(e.value),
101
+ disabled: k,
102
+ removeLabel: ye(_(e)),
103
+ onRemove: () => Be(e.value),
97
104
  children: e.label
98
105
  }, e.value))
99
106
  }) : null, /* @__PURE__ */ f(m.Trigger, {
@@ -101,132 +108,132 @@ var ne = (e) => Array.isArray(e) ? e : e == null || e === "" ? [] : [e], h = (e)
101
108
  children: /* @__PURE__ */ p("button", {
102
109
  ref: ke,
103
110
  type: "button",
104
- id: A.controlId,
111
+ id: j.controlId,
105
112
  className: "tm-select__trigger",
106
113
  role: "combobox",
107
114
  "aria-haspopup": "listbox",
108
- "aria-expanded": B,
109
- "aria-controls": B ? j : void 0,
110
- "aria-activedescendant": B && !C ? K : void 0,
111
- "aria-labelledby": O ?? (c ? A.labelId : void 0),
112
- "aria-describedby": r(Oe, A.messageId) || void 0,
113
- "aria-invalid": Pe || void 0,
114
- "aria-required": b || void 0,
115
- disabled: D,
116
- onKeyDown: ze,
115
+ "aria-expanded": z,
116
+ "aria-controls": z ? M : void 0,
117
+ "aria-activedescendant": z && !w ? q : void 0,
118
+ "aria-labelledby": A ?? (c ? j.labelId : void 0),
119
+ "aria-describedby": r(De, j.messageId) || void 0,
120
+ "aria-invalid": H || void 0,
121
+ "aria-required": ie || void 0,
122
+ disabled: k,
123
+ onKeyDown: He,
117
124
  onKeyUp: (e) => {
118
- De?.(e), e.key === " " && e.preventDefault();
125
+ Ee?.(e), e.key === " " && e.preventDefault();
119
126
  },
120
- ...k,
127
+ ...Oe,
121
128
  children: [
122
- ue,
129
+ le,
123
130
  Q ? /* @__PURE__ */ f("span", {
124
131
  className: "tm-select__value",
125
- children: de ? de(Q) : Q.label
132
+ children: ue ? ue(Q) : Q.label
126
133
  }) : $ ? /* @__PURE__ */ f("span", {
127
134
  className: "tm-select__value tm-select__value--hidden",
128
- children: H.map(g).join(", ")
135
+ children: V.map(_).join(", ")
129
136
  }) : /* @__PURE__ */ f("span", {
130
137
  className: "tm-select__value",
131
138
  "data-placeholder": "",
132
- children: ae
139
+ children: oe
133
140
  }),
134
- /* @__PURE__ */ f(Be, { className: "tm-select__chevron" })
141
+ /* @__PURE__ */ f(We, { className: "tm-select__chevron" })
135
142
  ]
136
143
  })
137
144
  })]
138
145
  });
139
146
  return /* @__PURE__ */ p(m.Root, {
140
- open: B,
141
- onOpenChange: (e) => q(e),
147
+ open: z,
148
+ onOpenChange: (e) => J(e),
142
149
  children: [/* @__PURE__ */ p(i, {
143
- ids: A,
150
+ ids: j,
144
151
  label: c,
145
- helperText: h,
146
- error: y,
147
- required: b,
148
- optional: ie,
152
+ helperText: g,
153
+ error: b,
154
+ required: ie,
155
+ optional: ae,
149
156
  size: x,
150
- className: r("tm-select", we),
151
- style: Te,
152
- "data-full-width": pe ? "" : void 0,
153
- children: [w ? /* @__PURE__ */ p(te, { children: [/* @__PURE__ */ f(m.Anchor, { virtualRef: w }), Ve] }) : /* @__PURE__ */ f(m.Anchor, {
157
+ className: r("tm-select", Ce),
158
+ style: we,
159
+ "data-full-width": fe ? "" : void 0,
160
+ children: [E ? /* @__PURE__ */ p(ne, { children: [/* @__PURE__ */ f(m.Anchor, { virtualRef: Re }), Ge] }) : /* @__PURE__ */ f(m.Anchor, {
154
161
  asChild: !0,
155
- children: Ve
156
- }), oe ? (T ? V : [V[0] ?? ""]).map((e) => /* @__PURE__ */ f("input", {
162
+ children: Ge
163
+ }), C ? (D ? B : [B[0] ?? ""]).map((e) => /* @__PURE__ */ f("input", {
157
164
  type: "hidden",
158
- name: oe,
165
+ name: C,
159
166
  value: e,
160
- disabled: D
167
+ disabled: k
161
168
  }, e)) : null]
162
169
  }), /* @__PURE__ */ f(m.Portal, {
163
- container: ve,
170
+ container: _e,
164
171
  children: /* @__PURE__ */ p(m.Content, {
165
172
  role: "presentation",
166
- className: r("tm-option-panel tm-select__panel", ye),
173
+ className: r("tm-option-panel tm-select__panel", ve),
167
174
  "data-size": x,
168
- "data-fit": pe ? "field" : "content",
169
- align: me,
175
+ "data-fit": fe ? "field" : "content",
176
+ align: pe,
170
177
  sideOffset: 8,
171
178
  collisionPadding: 8,
172
179
  onOpenAutoFocus: (e) => {
173
- e.preventDefault(), L.current?.focus();
180
+ e.preventDefault(), I.current?.focus();
174
181
  },
175
182
  onCloseAutoFocus: (e) => {
176
- R.current && e.preventDefault(), R.current = !1;
183
+ L.current && e.preventDefault(), L.current = !1;
177
184
  },
178
185
  children: [
179
- C ? /* @__PURE__ */ p("div", {
186
+ w ? /* @__PURE__ */ p("div", {
180
187
  className: "tm-select__search",
181
188
  children: [/* @__PURE__ */ f(t, { size: "sm" }), /* @__PURE__ */ f("input", {
182
- ref: L,
189
+ ref: I,
183
190
  className: "tm-select__search-input",
184
191
  type: "text",
185
192
  role: "combobox",
186
- "aria-label": ce,
193
+ "aria-label": T,
187
194
  "aria-expanded": "true",
188
- "aria-controls": j,
195
+ "aria-controls": M,
189
196
  "aria-autocomplete": "list",
190
- "aria-activedescendant": K,
197
+ "aria-activedescendant": q,
191
198
  autoComplete: "off",
192
199
  spellCheck: !1,
193
- placeholder: ce,
194
- value: N,
195
- onChange: (e) => Z(e.target.value),
196
- onKeyDown: (e) => Re(e, "search")
200
+ placeholder: T,
201
+ value: Fe,
202
+ onChange: (e) => Ue(e.target.value),
203
+ onKeyDown: (e) => Ve(e, "search")
197
204
  })]
198
205
  }) : null,
199
206
  /* @__PURE__ */ f(s, {
200
- id: j,
207
+ id: M,
201
208
  size: x,
202
- multiple: T,
209
+ multiple: D,
203
210
  surface: !1,
204
- "aria-labelledby": O ?? (c ? A.labelId : void 0),
205
- "aria-label": O || c ? void 0 : k["aria-label"],
211
+ "aria-labelledby": A ?? (c ? j.labelId : void 0),
212
+ "aria-label": A || c ? void 0 : Oe["aria-label"],
206
213
  onMouseDown: (e) => e.preventDefault(),
207
- children: U.map((e) => /* @__PURE__ */ f(o, {
208
- id: M(S.indexOf(e)),
209
- selected: V.includes(e.value),
210
- active: e === G,
214
+ children: W.map((e) => /* @__PURE__ */ f(o, {
215
+ id: Ae(S.indexOf(e)),
216
+ selected: B.includes(e.value),
217
+ active: e === K,
211
218
  disabled: e.disabled,
212
219
  icon: e.icon,
213
220
  detail: e.detail,
214
221
  description: e.description,
215
- indicator: T ? "checkbox" : fe ? "check" : "none",
216
- onClick: () => J(e),
222
+ indicator: D ? "checkbox" : de ? "check" : "none",
223
+ onClick: () => Y(e),
217
224
  children: e.label
218
225
  }, e.value))
219
226
  }),
220
- U.length === 0 ? /* @__PURE__ */ f("p", {
227
+ W.length === 0 ? /* @__PURE__ */ f("p", {
221
228
  className: "tm-select__empty",
222
229
  role: "status",
223
- children: le
230
+ children: ce
224
231
  }) : null
225
232
  ]
226
233
  })
227
234
  })]
228
235
  });
229
236
  });
230
- export { y as Select };
237
+ export { b as Select };
231
238
 
232
239
  //# sourceMappingURL=Select.js.map