@ifhover/leaf-ui 0.16.0 → 0.16.1
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/dist/cjs/browser/modules/select/select.cjs +64 -39
- package/dist/cjs/browser/modules/select/select.cjs.map +1 -1
- package/dist/cjs/browser/modules/shared/selection-content.cjs +96 -17
- package/dist/cjs/browser/modules/shared/selection-content.cjs.map +1 -1
- package/dist/cjs/browser/modules/transfer/transfer.cjs +68 -20
- package/dist/cjs/browser/modules/transfer/transfer.cjs.map +1 -1
- package/dist/cjs/select/select.cjs +64 -39
- package/dist/cjs/select/select.cjs.map +1 -1
- package/dist/cjs/select/select.d.cts.map +1 -1
- package/dist/cjs/shared/selection-content.cjs +96 -17
- package/dist/cjs/shared/selection-content.cjs.map +1 -1
- package/dist/cjs/shared/selection-content.d.cts.map +1 -1
- package/dist/cjs/styles/card.css +1 -1
- package/dist/cjs/styles/colorpicker.css +1 -1
- package/dist/cjs/styles/components/card.css +1 -1
- package/dist/cjs/styles/components/tabs.css +1 -1
- package/dist/cjs/styles/daterangepicker.css +1 -1
- package/dist/cjs/styles/index.css +62 -74
- package/dist/cjs/styles/index.css.map +1 -1
- package/dist/cjs/styles/tabs.css +1 -1
- package/dist/cjs/transfer/transfer.cjs +68 -20
- package/dist/cjs/transfer/transfer.cjs.map +1 -1
- package/dist/cjs/transfer/transfer.d.cts.map +1 -1
- package/dist/esm/browser/modules/select/select.js +64 -39
- package/dist/esm/browser/modules/select/select.js.map +1 -1
- package/dist/esm/browser/modules/shared/selection-content.js +96 -17
- package/dist/esm/browser/modules/shared/selection-content.js.map +1 -1
- package/dist/esm/browser/modules/transfer/transfer.js +69 -21
- package/dist/esm/browser/modules/transfer/transfer.js.map +1 -1
- package/dist/esm/select/select.d.ts.map +1 -1
- package/dist/esm/select/select.js +64 -39
- package/dist/esm/select/select.js.map +1 -1
- package/dist/esm/shared/selection-content.d.ts.map +1 -1
- package/dist/esm/shared/selection-content.js +96 -17
- package/dist/esm/shared/selection-content.js.map +1 -1
- package/dist/esm/styles/card.css +1 -1
- package/dist/esm/styles/colorpicker.css +1 -1
- package/dist/esm/styles/components/card.css +1 -1
- package/dist/esm/styles/components/tabs.css +1 -1
- package/dist/esm/styles/daterangepicker.css +1 -1
- package/dist/esm/styles/index.css +62 -74
- package/dist/esm/styles/index.css.map +1 -1
- package/dist/esm/styles/tabs.css +1 -1
- package/dist/esm/transfer/transfer.d.ts.map +1 -1
- package/dist/esm/transfer/transfer.js +69 -21
- package/dist/esm/transfer/transfer.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select/select.js","sources":["../../../src/select/select.tsx"],"sourcesContent":["import { useVirtualizer } from '@tanstack/react-virtual';\nimport { Check, ChevronDown, LoaderCircle, Plus } from 'lucide-react';\nimport {\n type CSSProperties,\n forwardRef,\n type InputHTMLAttributes,\n type ReactNode,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { estimateControlHeight } from '../density';\nimport { useFormField } from '../form/form';\nimport { classes } from '../shared/classes';\nimport { ClearButton } from '../shared/clear-button';\nimport { FormValue, useFieldValue, useMergedRef } from '../shared/field';\nimport {\n FloatingPanel,\n type PopupOptions,\n useActiveOption,\n useFloatingDismiss,\n usePopupState,\n} from '../shared/floating';\nimport { FloatingFeedback } from '../shared/floating-feedback';\nimport { SelectionContent } from '../shared/selection-content';\nimport type { ControlSize, ControlStatus } from '../shared/types';\nimport { useFormattedText } from '../shared/use-formatted-text';\n\nexport interface SelectOption {\n value: string;\n label: ReactNode;\n disabled?: boolean;\n searchLabel?: string;\n}\nexport interface SelectOptionGroup {\n label: ReactNode;\n options: readonly SelectOption[];\n}\ninterface SelectBaseProps\n extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'type' | 'size' | 'value' | 'defaultValue' | 'onChange' | 'children' | 'multiple'\n >,\n PopupOptions {\n options: readonly (SelectOption | SelectOptionGroup)[];\n size?: ControlSize;\n status?: ControlStatus;\n allowClear?: boolean;\n showSearch?: boolean;\n filterOption?: boolean | ((query: string, option: SelectOption) => boolean);\n onSearch?: (query: string) => void;\n onOpenChange?: (open: boolean) => void;\n open?: boolean;\n defaultOpen?: boolean;\n inputReadOnly?: boolean;\n labelRender?: (option: SelectOption) => ReactNode;\n tagRender?: (option: SelectOption, remove: () => void) => ReactNode;\n popupRender?: (content: ReactNode) => ReactNode;\n onPopupScroll?: (event: React.UIEvent<HTMLDivElement>) => void;\n popupWidth?: number | string;\n popupMaxWidth?: number | string;\n popupClassName?: string;\n popupStyle?: CSSProperties;\n loading?: boolean;\n notFoundContent?: ReactNode;\n optionRender?: (option: SelectOption) => ReactNode;\n maxCount?: number;\n maxTagCount?: number | 'responsive';\n tagWrap?: boolean;\n allowCreate?: boolean;\n onCreate?: (option: SelectOption) => void;\n virtual?: boolean;\n listHeight?: number;\n optionHeight?: number;\n}\nexport type SelectProps = SelectBaseProps &\n (\n | {\n multiple?: false;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string, option?: SelectOption) => void;\n }\n | {\n multiple: true;\n value?: readonly string[];\n defaultValue?: readonly string[];\n onChange?: (value: string[], options: SelectOption[]) => void;\n }\n );\nconst empty: readonly string[] = [];\nconst searchText = (option: SelectOption) =>\n option.searchLabel ??\n (typeof option.label === 'string' || typeof option.label === 'number'\n ? String(option.label)\n : option.value);\n/** Internal rendering primitive; public Select defaults are resolved at its boundary. */\nexport const SelectControl = forwardRef<HTMLInputElement, SelectProps>(function SelectControl(\n props: SelectProps,\n forwardedRef,\n) {\n const {\n options: suppliedOptions,\n size = 'md',\n status: statusProp,\n placeholder,\n value,\n defaultValue,\n name,\n required: requiredProp,\n allowClear = false,\n form,\n className,\n style,\n disabled: disabledProp,\n id: idProp,\n onOpenChange,\n open: controlledOpen,\n defaultOpen,\n inputReadOnly,\n labelRender,\n tagRender,\n popupRender,\n onPopupScroll,\n onClick,\n onKeyDown,\n onBeforeInput,\n onCompositionStart,\n onPaste,\n onBlur,\n multiple = false,\n showSearch: searchProp = false,\n filterOption = true,\n onSearch,\n popupWidth = 'trigger',\n popupMaxWidth,\n popupClassName,\n popupStyle,\n popupPlacement,\n getPopupContainer,\n loading = false,\n notFoundContent,\n optionRender,\n maxCount,\n maxTagCount,\n tagWrap = true,\n allowCreate = false,\n onCreate,\n virtual: virtualProp,\n listHeight = 248,\n optionHeight: optionHeightProp,\n onChange: _onChange,\n ...inputProps\n } = props;\n const format = useFormattedText();\n const showSearch = searchProp || allowCreate;\n const [created, setCreated] = useState<SelectOption[]>([]);\n const baseOptions = useMemo(\n () => suppliedOptions.flatMap((entry) => ('options' in entry ? [...entry.options] : [entry])),\n [suppliedOptions],\n );\n const options = useMemo(\n () => [\n ...baseOptions,\n ...created.filter((entry) => !baseOptions.some((option) => option.value === entry.value)),\n ],\n [baseOptions, created],\n );\n const optionGroups = useMemo(\n () =>\n new Map(\n suppliedOptions.flatMap((entry) =>\n 'options' in entry\n ? entry.options.map((option) => [option.value, entry.label] as const)\n : [],\n ),\n ),\n [suppliedOptions],\n );\n const virtual = virtualProp ?? options.length > 100;\n const { messages, theme, density, direction: configuredDirection } = useLeafConfig();\n const optionHeight = optionHeightProp ?? Math.max(24, estimateControlHeight(theme, density));\n const field = useFormField();\n const disabled = disabledProp || field?.disabled;\n const required = requiredProp ?? field?.required;\n const status = statusProp ?? (field?.error ? 'error' : undefined);\n const root = useRef<HTMLDivElement>(null);\n const input = useRef<HTMLInputElement>(null);\n const panel = useRef<HTMLDivElement>(null);\n const merged = useMergedRef(input, forwardedRef);\n const panelId = `${useId()}-listbox`;\n const [selected, setSelected] = useFieldValue<string | readonly string[]>(\n value,\n defaultValue ?? (multiple ? empty : ''),\n input,\n form,\n );\n const values = typeof selected === 'string' ? (selected ? [selected] : []) : selected;\n const atLimit =\n multiple && maxCount !== undefined && values.length >= Math.max(0, Math.floor(maxCount));\n const unavailable = (option: SelectOption) =>\n option.disabled || (atLimit && !values.includes(option.value));\n const selectedCache = useRef(new Map<string, SelectOption>());\n const nextCache = new Map<string, SelectOption>();\n for (const key of values) {\n const record = options.find((option) => option.value === key) ?? selectedCache.current.get(key);\n if (record) nextCache.set(key, record);\n }\n selectedCache.current = nextCache;\n const selectedOptions = values.map((key) => nextCache.get(key) ?? { value: key, label: key });\n // null keeps the selected label in the native input until a search is edited.\n const [query, setQuery] = useState<string | null>(null);\n const searchQuery = query ?? '';\n const [open, setOpen] = usePopupState(\n disabled || inputProps.readOnly,\n onOpenChange,\n controlledOpen,\n defaultOpen,\n );\n const [highlighted, setHighlighted] = useState(-1);\n const matched =\n !searchQuery || !showSearch || filterOption === false\n ? options\n : options.filter((option) =>\n typeof filterOption === 'function'\n ? filterOption(searchQuery, option)\n : searchText(option).toLocaleLowerCase().includes(searchQuery.toLocaleLowerCase()),\n );\n const newValue = searchQuery.trim();\n const createOption =\n allowCreate &&\n newValue &&\n !options.some((option) => option.value === newValue || searchText(option) === newValue)\n ? { value: newValue, label: newValue }\n : null;\n const filtered = createOption ? [...matched, createOption] : matched;\n const rows = useMemo(() => {\n const entries: { key: string; option?: SelectOption; group?: ReactNode; index: number }[] = [];\n let previousGroup: ReactNode;\n filtered.forEach((option, index) => {\n const group = optionGroups.get(option.value);\n if (group !== undefined && group !== previousGroup)\n entries.push({ key: `group-${option.value}`, group, index: -1 });\n entries.push({ key: option.value, option, index });\n previousGroup = group;\n });\n return entries;\n }, [filtered, optionGroups]);\n const virtualizer = useVirtualizer({\n count: rows.length,\n getScrollElement: () => panel.current,\n estimateSize: () => Math.max(24, optionHeight),\n overscan: 5,\n getItemKey: (index) => rows[index]?.key ?? index,\n enabled: open && virtual,\n initialRect: { height: listHeight, width: 240 },\n });\n useEffect(() => {\n if (open && virtual && highlighted >= 0) {\n const index = rows.findIndex((row) => row.index === highlighted);\n if (index >= 0) virtualizer.scrollToIndex(index, { align: 'auto' });\n }\n }, [open, virtual, highlighted, rows, virtualizer]);\n const updateQuery = (next: string) => {\n setQuery(next);\n onSearch?.(next);\n };\n const close = () => {\n setOpen(false);\n setQuery(null);\n if (searchQuery) onSearch?.('');\n };\n useFloatingDismiss(open, close, input, panel, root);\n useActiveOption(open, highlighted >= 0 ? `${panelId}-${highlighted}` : undefined, panel);\n useEffect(() => {\n if (!open) setQuery(null);\n }, [open]);\n const change = (next: readonly string[]) => {\n if (disabled || inputProps.readOnly) return;\n setSelected(multiple ? next : (next[0] ?? ''));\n if (props.multiple)\n props.onChange?.(\n [...next],\n [\n ...selectedOptions,\n ...options.filter((option) => !values.includes(option.value)),\n ...(createOption ? [createOption] : []),\n ].filter((option) => next.includes(option.value)),\n );\n else\n props.onChange?.(\n next[0] ?? '',\n [...options, ...(createOption ? [createOption] : [])].find(\n (option) => option.value === next[0],\n ),\n );\n };\n const selectionIndex = () =>\n filtered.findIndex((option) => values.includes(option.value) && !unavailable(option));\n const openMenu = () => {\n if (disabled || inputProps.readOnly) return;\n const active = filtered.findIndex(\n (option) => values.includes(option.value) && !unavailable(option),\n );\n setHighlighted(active >= 0 ? active : filtered.findIndex((option) => !unavailable(option)));\n setOpen(true);\n };\n const restoreSelectionHighlight = () =>\n setHighlighted((previous) => (previous === selectionIndex() ? previous : selectionIndex()));\n const beginSearch = () => {\n if (!showSearch || disabled || inputProps.readOnly || inputReadOnly) return;\n if (!multiple && query === null) input.current?.select();\n if (!open) openMenu();\n };\n const selectOption = (option: SelectOption) => {\n if (unavailable(option) || inputProps.readOnly) return;\n if (createOption && option.value === createOption.value) {\n setCreated((previous) => [...previous, option]);\n onCreate?.(option);\n }\n change(\n multiple\n ? values.includes(option.value)\n ? values.filter((value) => value !== option.value)\n : [...values, option.value]\n : [option.value],\n );\n if (multiple) updateQuery('');\n else close();\n input.current?.focus();\n };\n const move = (direction: number) => {\n if (!filtered.length) return;\n let next = highlighted < 0 ? (direction > 0 ? -1 : filtered.length) : highlighted;\n for (let i = 0; i < filtered.length; i++) {\n next = (next + direction + filtered.length) % filtered.length;\n const candidate = filtered[next];\n if (candidate && !unavailable(candidate)) {\n setHighlighted(next);\n break;\n }\n }\n };\n const renderOption = (option: SelectOption, index: number) => (\n <button\n key={option.value}\n id={`${panelId}-${index}`}\n aria-posinset={index + 1}\n aria-setsize={filtered.length}\n type=\"button\"\n role=\"option\"\n aria-selected={values.includes(option.value)}\n aria-disabled={option.disabled || (atLimit && !values.includes(option.value)) || undefined}\n data-highlighted={highlighted === index || undefined}\n className=\"leaf-floating__option\"\n disabled={option.disabled || (atLimit && !values.includes(option.value))}\n tabIndex={-1}\n onMouseEnter={() => {\n if (!unavailable(option)) setHighlighted(index);\n }}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => selectOption(option)}\n >\n <span className=\"leaf-floating__option-label\">\n {createOption?.value === option.value ? (\n <>\n <Plus size={14} aria-hidden=\"true\" />{' '}\n {format('select.create', {\n label: typeof option.label === 'string' ? option.label : option.value,\n })}\n </>\n ) : optionRender ? (\n optionRender(option)\n ) : (\n option.label\n )}\n </span>\n <Check size={15} aria-hidden=\"true\" className=\"leaf-select__check\" />\n </button>\n );\n const displayLabel = selectedOptions[0]\n ? (labelRender?.(selectedOptions[0]) ?? selectedOptions[0].label)\n : undefined;\n const textLabel =\n typeof displayLabel === 'string' || typeof displayLabel === 'number'\n ? String(displayLabel)\n : '';\n const inputValue = multiple ? searchQuery : showSearch && open ? (query ?? textLabel) : textLabel;\n const clearable = allowClear && values.length > 0 && !disabled && !inputProps.readOnly;\n const controlOptionHeight =\n optionHeightProp === undefined\n ? 'var(--leaf-current-control-height, 34px)'\n : `${Math.max(24, optionHeightProp)}px`;\n const listboxProps = {\n id: panelId,\n role: 'listbox' as const,\n 'aria-busy': loading || undefined,\n 'aria-label': inputProps['aria-label'] ?? messages.select.placeholder,\n 'aria-multiselectable': multiple || undefined,\n };\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: Pointer events on padding forward to the keyboard-accessible combobox input.\n // biome-ignore lint/a11y/useKeyWithClickEvents: The combobox input owns all keyboard interaction; this wrapper only extends its hit area.\n <div\n ref={root}\n className={classes(\n 'leaf-select',\n `leaf-select--${size}`,\n multiple && 'leaf-select--multiple',\n className,\n )}\n style={style}\n dir={props.dir ?? configuredDirection}\n data-status={status}\n data-disabled={disabled ? '' : undefined}\n data-open={open ? '' : undefined}\n data-clearable={clearable ? '' : undefined}\n data-searchable={showSearch ? '' : undefined}\n onMouseDown={(event) => {\n if (\n !disabled &&\n event.target instanceof Element &&\n !event.target.closest('input, button, a')\n )\n event.preventDefault();\n }}\n onClick={(event) => {\n if (\n !disabled &&\n event.target instanceof Element &&\n root.current?.contains(event.target) &&\n !event.target.closest('input, button, a')\n ) {\n input.current?.focus();\n input.current?.click();\n }\n }}\n >\n <SelectionContent\n className=\"leaf-select__content\"\n tagClassName=\"leaf-select__tag\"\n tagWrap={tagWrap}\n maxTagCount={maxTagCount}\n searchable={showSearch && !inputProps.readOnly && !inputReadOnly}\n query={searchQuery}\n removeLabel={messages.common.remove}\n items={\n multiple\n ? selectedOptions.map((option) => {\n const remove = () => {\n if (disabled || inputProps.readOnly || option.disabled) return;\n change(values.filter((item) => item !== option.value));\n input.current?.focus();\n };\n return {\n key: option.value,\n label: option.label,\n text: searchText(option),\n remove:\n !disabled && !inputProps.readOnly && !option.disabled ? remove : undefined,\n render: tagRender?.(option, remove),\n };\n })\n : undefined\n }\n >\n <span className=\"leaf-select__input-wrap\">\n {!multiple &&\n !textLabel &&\n displayLabel != null &&\n (!showSearch || !open || query === null) && (\n <span className=\"leaf-select__value\">{displayLabel}</span>\n )}\n <input\n {...inputProps}\n ref={merged}\n id={idProp ?? field?.id}\n form={form}\n type=\"text\"\n className=\"leaf-select__input\"\n disabled={disabled}\n readOnly={!showSearch || inputProps.readOnly || inputReadOnly}\n value={inputValue}\n placeholder={values.length ? '' : (placeholder ?? messages.select.placeholder)}\n autoComplete=\"off\"\n role=\"combobox\"\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-controls={panelId}\n aria-autocomplete={showSearch ? 'list' : undefined}\n aria-activedescendant={\n open && filtered[highlighted] ? `${panelId}-${highlighted}` : undefined\n }\n aria-required={required || undefined}\n aria-invalid={status === 'error' ? true : inputProps['aria-invalid']}\n aria-describedby={\n [inputProps['aria-describedby'], field?.descriptionId].filter(Boolean).join(' ') ||\n undefined\n }\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n if (open && !showSearch) close();\n else if (!open) openMenu();\n }\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (\n !event.defaultPrevented &&\n !root.current?.contains(event.relatedTarget) &&\n !panel.current?.contains(event.relatedTarget)\n )\n close();\n }}\n onChange={(event) => {\n if (!open) openMenu();\n updateQuery(event.target.value);\n setHighlighted(-1);\n }}\n onBeforeInput={(event) => {\n onBeforeInput?.(event);\n if (!event.defaultPrevented) beginSearch();\n }}\n onCompositionStart={(event) => {\n onCompositionStart?.(event);\n if (!event.defaultPrevented) beginSearch();\n }}\n onPaste={(event) => {\n onPaste?.(event);\n if (!event.defaultPrevented) beginSearch();\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || event.nativeEvent.isComposing) return;\n if (\n !event.ctrlKey &&\n !event.metaKey &&\n !event.altKey &&\n (event.key.length === 1 || event.key === 'Backspace' || event.key === 'Delete')\n )\n beginSearch();\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n if (!open) openMenu();\n else move(event.key === 'ArrowDown' ? 1 : -1);\n } else if ((event.key === 'Home' || event.key === 'End') && open && !showSearch) {\n event.preventDefault();\n const candidates = filtered\n .map((option, index) => ({ option, index }))\n .filter(({ option }) => !unavailable(option));\n setHighlighted(\n (event.key === 'Home' ? candidates[0] : candidates.at(-1))?.index ?? -1,\n );\n } else if (event.key === 'Enter' || (event.key === ' ' && !showSearch)) {\n event.preventDefault();\n if (!open) openMenu();\n else {\n const option =\n filtered[highlighted] ?? filtered.find((option) => !unavailable(option));\n if (option) selectOption(option);\n }\n } else if (event.key === 'Escape' && open) {\n event.preventDefault();\n event.stopPropagation();\n close();\n } else if (event.key === 'Tab' && open) close();\n else if (\n event.key === 'Backspace' &&\n multiple &&\n !searchQuery &&\n !inputProps.readOnly\n ) {\n const last = [...values]\n .reverse()\n .find((value) => !options.find((option) => option.value === value)?.disabled);\n if (last) {\n event.preventDefault();\n change(values.filter((value) => value !== last));\n }\n }\n }}\n />\n </span>\n </SelectionContent>\n <button\n type=\"button\"\n className=\"leaf-select__arrow\"\n tabIndex={-1}\n disabled={disabled}\n aria-label={messages.select.placeholder}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n if (open) close();\n else openMenu();\n input.current?.focus();\n }}\n >\n {loading ? (\n <LoaderCircle className=\"leaf-select__spinner\" size={16} aria-hidden=\"true\" />\n ) : (\n <ChevronDown size={16} aria-hidden=\"true\" />\n )}\n </button>\n {clearable && (\n <ClearButton\n label={messages.select.clear}\n beforeArrow\n onClear={() => {\n change(empty);\n close();\n input.current?.focus();\n }}\n />\n )}\n <FormValue\n name={multiple ? undefined : name}\n form={form}\n value={multiple ? values.join(',') : (values[0] ?? '')}\n disabled={disabled}\n required={required}\n triggerRef={input}\n />\n {multiple &&\n values.map((value) => (\n <input\n key={value}\n type=\"hidden\"\n name={name}\n form={form}\n value={value}\n disabled={disabled}\n />\n ))}\n <FloatingPanel\n resetSurfaceGeometry\n open={open}\n placement={popupPlacement}\n container={getPopupContainer}\n triggerRef={root}\n panelRef={panel}\n matchWidth={popupWidth === 'trigger'}\n width={\n popupWidth === 'trigger' ? undefined : popupWidth === 'auto' ? 'max-content' : popupWidth\n }\n maxWidth={popupMaxWidth}\n {...(filtered.length ? listboxProps : {})}\n className={classes('leaf-floating', 'leaf-select__panel', popupClassName)}\n data-hover-motion=\"\"\n onMouseLeave={restoreSelectionHighlight}\n style={\n {\n maxHeight: listHeight,\n '--leaf-select-option-height': controlOptionHeight,\n ...popupStyle,\n } as CSSProperties\n }\n onScroll={onPopupScroll}\n >\n {/* Feedback is announced beside an empty listbox, never as a selectable option. */}\n {!filtered.length && <div {...listboxProps} />}\n {(popupRender ?? ((content: ReactNode) => content))(\n loading && !filtered.length ? (\n <FloatingFeedback loading>{messages.common.loading}</FloatingFeedback>\n ) : filtered.length ? (\n virtual ? (\n <div\n style={{\n height: virtualizer.getTotalSize(),\n position: 'relative',\n minWidth: '100%',\n }}\n >\n {virtualizer.getVirtualItems().map((item) => {\n const row = rows[item.index];\n if (!row) return null;\n return (\n <div\n key={row.key}\n ref={virtualizer.measureElement}\n data-index={item.index}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n transform: `translateY(${item.start}px)`,\n }}\n >\n {row.option ? (\n renderOption(row.option, row.index)\n ) : (\n <div className=\"leaf-select__group\">{row.group}</div>\n )}\n </div>\n );\n })}\n </div>\n ) : (\n rows.map((row) =>\n row.option ? (\n renderOption(row.option, row.index)\n ) : (\n <div key={row.key} className=\"leaf-select__group\">\n {row.group}\n </div>\n ),\n )\n )\n ) : (\n <FloatingFeedback>{notFoundContent ?? messages.select.empty}</FloatingFeedback>\n ),\n )}\n </FloatingPanel>\n </div>\n );\n});\nSelectControl.displayName = 'SelectControl';\n\nexport const Select = forwardRef<HTMLInputElement, SelectProps>(function Select(rawProps, ref) {\n const props = useComponentProps('Select', rawProps);\n return <SelectControl {...props} ref={ref} />;\n});\nSelect.displayName = 'Select';\n"],"names":["empty","searchText","option","String","SelectControl","forwardRef","props","forwardedRef","suppliedOptions","size","statusProp","placeholder","value","defaultValue","name","requiredProp","allowClear","form","className","style","disabledProp","idProp","onOpenChange","controlledOpen","defaultOpen","inputReadOnly","labelRender","tagRender","popupRender","onPopupScroll","onClick","onKeyDown","onBeforeInput","onCompositionStart","onPaste","onBlur","multiple","searchProp","filterOption","onSearch","popupWidth","popupMaxWidth","popupClassName","popupStyle","popupPlacement","getPopupContainer","loading","notFoundContent","optionRender","maxCount","maxTagCount","tagWrap","allowCreate","onCreate","virtualProp","listHeight","optionHeightProp","_onChange","inputProps","format","useFormattedText","showSearch","created","setCreated","useState","baseOptions","useMemo","entry","options","optionGroups","Map","virtual","messages","theme","density","configuredDirection","useLeafConfig","optionHeight","Math","estimateControlHeight","field","useFormField","disabled","required","status","undefined","root","useRef","input","panel","merged","useMergedRef","panelId","useId","selected","setSelected","useFieldValue","values","atLimit","unavailable","selectedCache","nextCache","key","record","selectedOptions","query","setQuery","searchQuery","open","setOpen","usePopupState","highlighted","setHighlighted","matched","newValue","createOption","filtered","rows","entries","previousGroup","index","group","virtualizer","useVirtualizer","useEffect","row","updateQuery","next","close","useFloatingDismiss","useActiveOption","change","selectionIndex","openMenu","active","restoreSelectionHighlight","previous","beginSearch","selectOption","move","direction","i","candidate","renderOption","event","Plus","Check","displayLabel","textLabel","inputValue","clearable","controlOptionHeight","listboxProps","classes","Element","SelectionContent","remove","item","Boolean","candidates","last","LoaderCircle","ChevronDown","ClearButton","FormValue","FloatingPanel","content","FloatingFeedback","Select","rawProps","ref","useComponentProps"],"mappings":";;;;;;;;;;;;;;;;AA8FA,MAAMA,QAA2B,EAAE;AACnC,MAAMC,aAAa,CAACC,SAClBA,OAAO,WAAW,IACjB,CAAwB,YAAxB,OAAOA,OAAO,KAAK,IAAiB,AAAwB,YAAxB,OAAOA,OAAO,KAAK,GACpDC,OAAOD,OAAO,KAAK,IACnBA,OAAO,KAAI;AAEV,MAAME,uBAAgB,WAAHA,GAAGC,WAA0C,SACrEC,KAAkB,EAClBC,YAAY;IAEZ,MAAM,EACJ,SAASC,eAAe,EACxBC,OAAO,IAAI,EACX,QAAQC,UAAU,EAClBC,WAAW,EACXC,KAAK,EACLC,YAAY,EACZC,IAAI,EACJ,UAAUC,YAAY,EACtBC,aAAa,KAAK,EAClBC,IAAI,EACJC,SAAS,EACTC,KAAK,EACL,UAAUC,YAAY,EACtB,IAAIC,MAAM,EACVC,YAAY,EACZ,MAAMC,cAAc,EACpBC,WAAW,EACXC,aAAa,EACbC,WA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gCACtB,OAAO;oCACL,UAAU;oCACV,KAAK;oCACL,MAAM;oCACN,OAAO;oCACP,WAAW,CAAC,WAAW,EAAEA,KAAK,KAAK,CAAC,GAAG,CAAC;gCAC1C;0CAEChC,IAAI,MAAM,GACTkB,aAAalB,IAAI,MAAM,EAAEA,IAAI,KAAK,kBAElC,IAAC;oCAAI,WAAU;8CAAsBA,IAAI,KAAK;;+BAd3CA,IAAI,GAAG;wBAkBlB;yBAGFR,KAAK,GAAG,CAAC,CAACQ,MACRA,IAAI,MAAM,GACRkB,aAAalB,IAAI,MAAM,EAAEA,IAAI,KAAK,kBAElC,IAAC;4BAAkB,WAAU;sCAC1BA,IAAI,KAAK;2BADFA,IAAI,GAAG,mBAOvB,IAAC0C,kBAAgBA;kCAAExH,mBAAmByB,SAAS,MAAM,CAAC,KAAK;;;;;;AAMvE;AACApE,qBAAc,WAAW,GAAG;AAErB,MAAMoK,gBAAS,WAAHA,GAAGnK,WAA0C,SAAgBoK,QAAQ,EAAEC,GAAG;IAC3F,MAAMpK,QAAQqK,kBAAkB,UAAUF;IAC1C,OAAO,WAAP,GAAO,IAACrK,sBAAaA;QAAE,GAAGE,KAAK;QAAE,KAAKoK;;AACxC;AACAF,cAAO,WAAW,GAAG"}
|
|
1
|
+
{"version":3,"file":"select/select.js","sources":["../../../src/select/select.tsx"],"sourcesContent":["import { useVirtualizer } from '@tanstack/react-virtual';\nimport { Check, ChevronDown, LoaderCircle, Plus } from 'lucide-react';\nimport {\n type CSSProperties,\n forwardRef,\n type InputHTMLAttributes,\n type ReactNode,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { estimateControlHeight } from '../density';\nimport { useFormField } from '../form/form';\nimport { classes } from '../shared/classes';\nimport { ClearButton } from '../shared/clear-button';\nimport { FormValue, useFieldValue, useMergedRef } from '../shared/field';\nimport {\n FloatingPanel,\n type PopupOptions,\n useActiveOption,\n useFloatingDismiss,\n usePopupState,\n} from '../shared/floating';\nimport { FloatingFeedback } from '../shared/floating-feedback';\nimport { SelectionContent } from '../shared/selection-content';\nimport type { ControlSize, ControlStatus } from '../shared/types';\nimport { useFormattedText } from '../shared/use-formatted-text';\n\nexport interface SelectOption {\n value: string;\n label: ReactNode;\n disabled?: boolean;\n searchLabel?: string;\n}\nexport interface SelectOptionGroup {\n label: ReactNode;\n options: readonly SelectOption[];\n}\ninterface SelectBaseProps\n extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'type' | 'size' | 'value' | 'defaultValue' | 'onChange' | 'children' | 'multiple'\n >,\n PopupOptions {\n options: readonly (SelectOption | SelectOptionGroup)[];\n size?: ControlSize;\n status?: ControlStatus;\n allowClear?: boolean;\n showSearch?: boolean;\n filterOption?: boolean | ((query: string, option: SelectOption) => boolean);\n onSearch?: (query: string) => void;\n onOpenChange?: (open: boolean) => void;\n open?: boolean;\n defaultOpen?: boolean;\n inputReadOnly?: boolean;\n labelRender?: (option: SelectOption) => ReactNode;\n tagRender?: (option: SelectOption, remove: () => void) => ReactNode;\n popupRender?: (content: ReactNode) => ReactNode;\n onPopupScroll?: (event: React.UIEvent<HTMLDivElement>) => void;\n popupWidth?: number | string;\n popupMaxWidth?: number | string;\n popupClassName?: string;\n popupStyle?: CSSProperties;\n loading?: boolean;\n notFoundContent?: ReactNode;\n optionRender?: (option: SelectOption) => ReactNode;\n maxCount?: number;\n maxTagCount?: number | 'responsive';\n tagWrap?: boolean;\n allowCreate?: boolean;\n onCreate?: (option: SelectOption) => void;\n virtual?: boolean;\n listHeight?: number;\n optionHeight?: number;\n}\nexport type SelectProps = SelectBaseProps &\n (\n | {\n multiple?: false;\n value?: string;\n defaultValue?: string;\n onChange?: (value: string, option?: SelectOption) => void;\n }\n | {\n multiple: true;\n value?: readonly string[];\n defaultValue?: readonly string[];\n onChange?: (value: string[], options: SelectOption[]) => void;\n }\n );\nconst empty: readonly string[] = [];\nconst searchText = (option: SelectOption) =>\n option.searchLabel ??\n (typeof option.label === 'string' || typeof option.label === 'number'\n ? String(option.label)\n : option.value);\n/** Internal rendering primitive; public Select defaults are resolved at its boundary. */\nexport const SelectControl = forwardRef<HTMLInputElement, SelectProps>(function SelectControl(\n props: SelectProps,\n forwardedRef,\n) {\n const {\n options: suppliedOptions,\n size = 'md',\n status: statusProp,\n placeholder,\n value,\n defaultValue,\n name,\n required: requiredProp,\n allowClear = false,\n form,\n className,\n style,\n disabled: disabledProp,\n id: idProp,\n onOpenChange,\n open: controlledOpen,\n defaultOpen,\n inputReadOnly,\n labelRender,\n tagRender,\n popupRender,\n onPopupScroll,\n onClick,\n onKeyDown,\n onBeforeInput,\n onCompositionStart,\n onPaste,\n onBlur,\n multiple = false,\n showSearch: searchProp = false,\n filterOption = true,\n onSearch,\n popupWidth = 'trigger',\n popupMaxWidth,\n popupClassName,\n popupStyle,\n popupPlacement,\n getPopupContainer,\n loading = false,\n notFoundContent,\n optionRender,\n maxCount,\n maxTagCount,\n tagWrap = true,\n allowCreate = false,\n onCreate,\n virtual: virtualProp,\n listHeight = 248,\n optionHeight: optionHeightProp,\n onChange: _onChange,\n ...inputProps\n } = props;\n const format = useFormattedText();\n const showSearch = searchProp || allowCreate;\n const [created, setCreated] = useState<SelectOption[]>([]);\n const baseOptions = useMemo(\n () => suppliedOptions.flatMap((entry) => ('options' in entry ? [...entry.options] : [entry])),\n [suppliedOptions],\n );\n const options = useMemo(() => {\n if (!created.length) return baseOptions;\n const baseValues = new Set(baseOptions.map((option) => option.value));\n return [...baseOptions, ...created.filter((entry) => !baseValues.has(entry.value))];\n }, [baseOptions, created]);\n const optionIndex = useMemo(() => {\n const index = new Map<string, SelectOption>();\n // Match the first option, as the previous Array.find lookup did.\n for (const option of options) if (!index.has(option.value)) index.set(option.value, option);\n return index;\n }, [options]);\n const optionGroups = useMemo(\n () =>\n new Map(\n suppliedOptions.flatMap((entry) =>\n 'options' in entry\n ? entry.options.map((option) => [option.value, entry.label] as const)\n : [],\n ),\n ),\n [suppliedOptions],\n );\n const virtual = virtualProp ?? options.length > 100;\n const { messages, theme, density, direction: configuredDirection } = useLeafConfig();\n const optionHeight = optionHeightProp ?? Math.max(24, estimateControlHeight(theme, density));\n const field = useFormField();\n const disabled = disabledProp || field?.disabled;\n const required = requiredProp ?? field?.required;\n const status = statusProp ?? (field?.error ? 'error' : undefined);\n const root = useRef<HTMLDivElement>(null);\n const input = useRef<HTMLInputElement>(null);\n const panel = useRef<HTMLDivElement>(null);\n const merged = useMergedRef(input, forwardedRef);\n const panelId = `${useId()}-listbox`;\n const [selected, setSelected] = useFieldValue<string | readonly string[]>(\n value,\n defaultValue ?? (multiple ? empty : ''),\n input,\n form,\n );\n const values = useMemo(\n () => (typeof selected === 'string' ? (selected ? [selected] : []) : selected),\n [selected],\n );\n const selectedValues = useMemo(() => new Set(values), [values]);\n const atLimit =\n multiple && maxCount !== undefined && values.length >= Math.max(0, Math.floor(maxCount));\n const unavailable = (option: SelectOption) =>\n option.disabled || (atLimit && !selectedValues.has(option.value));\n const selectedCache = useRef(new Map<string, SelectOption>());\n const nextCache = new Map<string, SelectOption>();\n for (const key of values) {\n const record = optionIndex.get(key) ?? selectedCache.current.get(key);\n if (record) nextCache.set(key, record);\n }\n selectedCache.current = nextCache;\n const selectedOptions = values.map((key) => nextCache.get(key) ?? { value: key, label: key });\n // null keeps the selected label in the native input until a search is edited.\n const [query, setQuery] = useState<string | null>(null);\n const searchQuery = query ?? '';\n const [open, setOpen] = usePopupState(\n disabled || inputProps.readOnly,\n onOpenChange,\n controlledOpen,\n defaultOpen,\n );\n const [highlighted, setHighlighted] = useState(-1);\n const { createOption, filtered } = useMemo(() => {\n const normalizedQuery = searchQuery.toLocaleLowerCase();\n const matched =\n !searchQuery || !showSearch || filterOption === false\n ? options\n : options.filter((option) =>\n typeof filterOption === 'function'\n ? filterOption(searchQuery, option)\n : searchText(option).toLocaleLowerCase().includes(normalizedQuery),\n );\n const newValue = searchQuery.trim();\n const createOption =\n allowCreate &&\n newValue &&\n !options.some((option) => option.value === newValue || searchText(option) === newValue)\n ? { value: newValue, label: newValue }\n : null;\n return { createOption, filtered: createOption ? [...matched, createOption] : matched };\n }, [options, searchQuery, showSearch, filterOption, allowCreate]);\n const rows = useMemo(() => {\n const entries: { key: string; option?: SelectOption; group?: ReactNode; index: number }[] = [];\n let previousGroup: ReactNode;\n filtered.forEach((option, index) => {\n const group = optionGroups.get(option.value);\n if (group !== undefined && group !== previousGroup)\n entries.push({ key: `group-${option.value}`, group, index: -1 });\n entries.push({ key: option.value, option, index });\n previousGroup = group;\n });\n return entries;\n }, [filtered, optionGroups]);\n const virtualizer = useVirtualizer({\n count: rows.length,\n getScrollElement: () => panel.current,\n estimateSize: () => Math.max(24, optionHeight),\n overscan: 5,\n getItemKey: (index) => rows[index]?.key ?? index,\n enabled: open && virtual,\n initialRect: { height: listHeight, width: 240 },\n });\n useEffect(() => {\n if (open && virtual && highlighted >= 0) {\n const index = rows.findIndex((row) => row.index === highlighted);\n if (index >= 0) virtualizer.scrollToIndex(index, { align: 'auto' });\n }\n }, [open, virtual, highlighted, rows, virtualizer]);\n const updateQuery = (next: string) => {\n setQuery(next);\n onSearch?.(next);\n };\n const close = () => {\n setOpen(false);\n setQuery(null);\n if (searchQuery) onSearch?.('');\n };\n useFloatingDismiss(open, close, input, panel, root);\n useActiveOption(open, highlighted >= 0 ? `${panelId}-${highlighted}` : undefined, panel);\n useEffect(() => {\n if (!open) setQuery(null);\n }, [open]);\n const change = (next: readonly string[]) => {\n if (disabled || inputProps.readOnly) return;\n setSelected(multiple ? next : (next[0] ?? ''));\n if (props.multiple) {\n const nextValues = new Set(next);\n props.onChange?.(\n [...next],\n [\n ...selectedOptions,\n ...options.filter((option) => !selectedValues.has(option.value)),\n ...(createOption ? [createOption] : []),\n ].filter((option) => nextValues.has(option.value)),\n );\n } else\n props.onChange?.(\n next[0] ?? '',\n next[0] === undefined\n ? undefined\n : (optionIndex.get(next[0]) ??\n (createOption?.value === next[0] ? createOption : undefined)),\n );\n };\n const selectionIndex = () =>\n filtered.findIndex((option) => selectedValues.has(option.value) && !unavailable(option));\n const openMenu = () => {\n if (disabled || inputProps.readOnly) return;\n const active = filtered.findIndex(\n (option) => selectedValues.has(option.value) && !unavailable(option),\n );\n setHighlighted(active >= 0 ? active : filtered.findIndex((option) => !unavailable(option)));\n setOpen(true);\n };\n const restoreSelectionHighlight = () =>\n setHighlighted((previous) => (previous === selectionIndex() ? previous : selectionIndex()));\n const beginSearch = () => {\n if (!showSearch || disabled || inputProps.readOnly || inputReadOnly) return;\n if (!multiple && query === null) input.current?.select();\n if (!open) openMenu();\n };\n const selectOption = (option: SelectOption) => {\n if (unavailable(option) || inputProps.readOnly) return;\n if (createOption && option.value === createOption.value) {\n setCreated((previous) => [...previous, option]);\n onCreate?.(option);\n }\n change(\n multiple\n ? selectedValues.has(option.value)\n ? values.filter((value) => value !== option.value)\n : [...values, option.value]\n : [option.value],\n );\n if (multiple) updateQuery('');\n else close();\n input.current?.focus();\n };\n const move = (direction: number) => {\n if (!filtered.length) return;\n let next = highlighted < 0 ? (direction > 0 ? -1 : filtered.length) : highlighted;\n for (let i = 0; i < filtered.length; i++) {\n next = (next + direction + filtered.length) % filtered.length;\n const candidate = filtered[next];\n if (candidate && !unavailable(candidate)) {\n setHighlighted(next);\n break;\n }\n }\n };\n const renderOption = (option: SelectOption, index: number) => (\n <button\n key={option.value}\n id={`${panelId}-${index}`}\n aria-posinset={index + 1}\n aria-setsize={filtered.length}\n type=\"button\"\n role=\"option\"\n aria-selected={selectedValues.has(option.value)}\n aria-disabled={unavailable(option) || undefined}\n data-highlighted={highlighted === index || undefined}\n className=\"leaf-floating__option\"\n disabled={unavailable(option)}\n tabIndex={-1}\n onMouseEnter={() => {\n if (!unavailable(option)) setHighlighted(index);\n }}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => selectOption(option)}\n >\n <span className=\"leaf-floating__option-label\">\n {createOption?.value === option.value ? (\n <>\n <Plus size={14} aria-hidden=\"true\" />{' '}\n {format('select.create', {\n label: typeof option.label === 'string' ? option.label : option.value,\n })}\n </>\n ) : optionRender ? (\n optionRender(option)\n ) : (\n option.label\n )}\n </span>\n <Check size={15} aria-hidden=\"true\" className=\"leaf-select__check\" />\n </button>\n );\n const displayLabel = selectedOptions[0]\n ? (labelRender?.(selectedOptions[0]) ?? selectedOptions[0].label)\n : undefined;\n const textLabel =\n typeof displayLabel === 'string' || typeof displayLabel === 'number'\n ? String(displayLabel)\n : '';\n const inputValue = multiple ? searchQuery : showSearch && open ? (query ?? textLabel) : textLabel;\n const clearable = allowClear && values.length > 0 && !disabled && !inputProps.readOnly;\n const controlOptionHeight =\n optionHeightProp === undefined\n ? 'var(--leaf-current-control-height, 34px)'\n : `${Math.max(24, optionHeightProp)}px`;\n const listboxProps = {\n id: panelId,\n role: 'listbox' as const,\n 'aria-busy': loading || undefined,\n 'aria-label': inputProps['aria-label'] ?? messages.select.placeholder,\n 'aria-multiselectable': multiple || undefined,\n };\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: Pointer events on padding forward to the keyboard-accessible combobox input.\n // biome-ignore lint/a11y/useKeyWithClickEvents: The combobox input owns all keyboard interaction; this wrapper only extends its hit area.\n <div\n ref={root}\n className={classes(\n 'leaf-select',\n `leaf-select--${size}`,\n multiple && 'leaf-select--multiple',\n className,\n )}\n style={style}\n dir={props.dir ?? configuredDirection}\n data-status={status}\n data-disabled={disabled ? '' : undefined}\n data-open={open ? '' : undefined}\n data-clearable={clearable ? '' : undefined}\n data-searchable={showSearch ? '' : undefined}\n onMouseDown={(event) => {\n if (\n !disabled &&\n event.target instanceof Element &&\n !event.target.closest('input, button, a')\n )\n event.preventDefault();\n }}\n onClick={(event) => {\n if (\n !disabled &&\n event.target instanceof Element &&\n root.current?.contains(event.target) &&\n !event.target.closest('input, button, a')\n ) {\n input.current?.focus();\n input.current?.click();\n }\n }}\n >\n <SelectionContent\n className=\"leaf-select__content\"\n tagClassName=\"leaf-select__tag\"\n tagWrap={tagWrap}\n maxTagCount={maxTagCount}\n searchable={showSearch && !inputProps.readOnly && !inputReadOnly}\n query={searchQuery}\n removeLabel={messages.common.remove}\n items={\n multiple\n ? selectedOptions.map((option) => {\n const remove = () => {\n if (disabled || inputProps.readOnly || option.disabled) return;\n change(values.filter((item) => item !== option.value));\n input.current?.focus();\n };\n return {\n key: option.value,\n label: option.label,\n text: searchText(option),\n remove:\n !disabled && !inputProps.readOnly && !option.disabled ? remove : undefined,\n render: tagRender?.(option, remove),\n };\n })\n : undefined\n }\n >\n <span className=\"leaf-select__input-wrap\">\n {!multiple &&\n !textLabel &&\n displayLabel != null &&\n (!showSearch || !open || query === null) && (\n <span className=\"leaf-select__value\">{displayLabel}</span>\n )}\n <input\n {...inputProps}\n ref={merged}\n id={idProp ?? field?.id}\n form={form}\n type=\"text\"\n className=\"leaf-select__input\"\n disabled={disabled}\n readOnly={!showSearch || inputProps.readOnly || inputReadOnly}\n value={inputValue}\n placeholder={values.length ? '' : (placeholder ?? messages.select.placeholder)}\n autoComplete=\"off\"\n role=\"combobox\"\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-controls={panelId}\n aria-autocomplete={showSearch ? 'list' : undefined}\n aria-activedescendant={\n open && filtered[highlighted] ? `${panelId}-${highlighted}` : undefined\n }\n aria-required={required || undefined}\n aria-invalid={status === 'error' ? true : inputProps['aria-invalid']}\n aria-describedby={\n [inputProps['aria-describedby'], field?.descriptionId].filter(Boolean).join(' ') ||\n undefined\n }\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n if (open && !showSearch) close();\n else if (!open) openMenu();\n }\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (\n !event.defaultPrevented &&\n !root.current?.contains(event.relatedTarget) &&\n !panel.current?.contains(event.relatedTarget)\n )\n close();\n }}\n onChange={(event) => {\n if (!open) openMenu();\n updateQuery(event.target.value);\n setHighlighted(-1);\n }}\n onBeforeInput={(event) => {\n onBeforeInput?.(event);\n if (!event.defaultPrevented) beginSearch();\n }}\n onCompositionStart={(event) => {\n onCompositionStart?.(event);\n if (!event.defaultPrevented) beginSearch();\n }}\n onPaste={(event) => {\n onPaste?.(event);\n if (!event.defaultPrevented) beginSearch();\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || event.nativeEvent.isComposing) return;\n if (\n !event.ctrlKey &&\n !event.metaKey &&\n !event.altKey &&\n (event.key.length === 1 || event.key === 'Backspace' || event.key === 'Delete')\n )\n beginSearch();\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n if (!open) openMenu();\n else move(event.key === 'ArrowDown' ? 1 : -1);\n } else if ((event.key === 'Home' || event.key === 'End') && open && !showSearch) {\n event.preventDefault();\n const candidates = filtered\n .map((option, index) => ({ option, index }))\n .filter(({ option }) => !unavailable(option));\n setHighlighted(\n (event.key === 'Home' ? candidates[0] : candidates.at(-1))?.index ?? -1,\n );\n } else if (event.key === 'Enter' || (event.key === ' ' && !showSearch)) {\n event.preventDefault();\n if (!open) openMenu();\n else {\n const option =\n filtered[highlighted] ?? filtered.find((option) => !unavailable(option));\n if (option) selectOption(option);\n }\n } else if (event.key === 'Escape' && open) {\n event.preventDefault();\n event.stopPropagation();\n close();\n } else if (event.key === 'Tab' && open) close();\n else if (\n event.key === 'Backspace' &&\n multiple &&\n !searchQuery &&\n !inputProps.readOnly\n ) {\n const last = [...values]\n .reverse()\n .find((value) => !optionIndex.get(value)?.disabled);\n if (last) {\n event.preventDefault();\n change(values.filter((value) => value !== last));\n }\n }\n }}\n />\n </span>\n </SelectionContent>\n <button\n type=\"button\"\n className=\"leaf-select__arrow\"\n tabIndex={-1}\n disabled={disabled}\n aria-label={messages.select.placeholder}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => {\n if (open) close();\n else openMenu();\n input.current?.focus();\n }}\n >\n {loading ? (\n <LoaderCircle className=\"leaf-select__spinner\" size={16} aria-hidden=\"true\" />\n ) : (\n <ChevronDown size={16} aria-hidden=\"true\" />\n )}\n </button>\n {clearable && (\n <ClearButton\n label={messages.select.clear}\n beforeArrow\n onClear={() => {\n change(empty);\n close();\n input.current?.focus();\n }}\n />\n )}\n <FormValue\n name={multiple ? undefined : name}\n form={form}\n value={multiple ? values.join(',') : (values[0] ?? '')}\n disabled={disabled}\n required={required}\n triggerRef={input}\n />\n {multiple &&\n values.map((value) => (\n <input\n key={value}\n type=\"hidden\"\n name={name}\n form={form}\n value={value}\n disabled={disabled}\n />\n ))}\n <FloatingPanel\n resetSurfaceGeometry\n open={open}\n placement={popupPlacement}\n container={getPopupContainer}\n triggerRef={root}\n panelRef={panel}\n matchWidth={popupWidth === 'trigger'}\n width={\n popupWidth === 'trigger' ? undefined : popupWidth === 'auto' ? 'max-content' : popupWidth\n }\n maxWidth={popupMaxWidth}\n {...(filtered.length ? listboxProps : {})}\n className={classes('leaf-floating', 'leaf-select__panel', popupClassName)}\n data-hover-motion=\"\"\n onMouseLeave={restoreSelectionHighlight}\n style={\n {\n maxHeight: listHeight,\n '--leaf-select-option-height': controlOptionHeight,\n ...popupStyle,\n } as CSSProperties\n }\n onScroll={onPopupScroll}\n >\n {/* Feedback is announced beside an empty listbox, never as a selectable option. */}\n {!filtered.length && <div {...listboxProps} />}\n {(popupRender ?? ((content: ReactNode) => content))(\n loading && !filtered.length ? (\n <FloatingFeedback loading>{messages.common.loading}</FloatingFeedback>\n ) : filtered.length ? (\n virtual ? (\n <div\n style={{\n height: virtualizer.getTotalSize(),\n position: 'relative',\n minWidth: '100%',\n }}\n >\n {virtualizer.getVirtualItems().map((item) => {\n const row = rows[item.index];\n if (!row) return null;\n return (\n <div\n key={row.key}\n ref={virtualizer.measureElement}\n data-index={item.index}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n transform: `translateY(${item.start}px)`,\n }}\n >\n {row.option ? (\n renderOption(row.option, row.index)\n ) : (\n <div className=\"leaf-select__group\">{row.group}</div>\n )}\n </div>\n );\n })}\n </div>\n ) : (\n rows.map((row) =>\n row.option ? (\n renderOption(row.option, row.index)\n ) : (\n <div key={row.key} className=\"leaf-select__group\">\n {row.group}\n </div>\n ),\n )\n )\n ) : (\n <FloatingFeedback>{notFoundContent ?? messages.select.empty}</FloatingFeedback>\n ),\n )}\n </FloatingPanel>\n </div>\n );\n});\nSelectControl.displayName = 'SelectControl';\n\nexport const Select = forwardRef<HTMLInputElement, SelectProps>(function Select(rawProps, ref) {\n const props = useComponentProps('Select', rawProps);\n return <SelectControl {...props} ref={ref} />;\n});\nSelect.displayName = 'Select';\n"],"names":["empty","searchText","option","String","SelectControl","forwardRef","props","forwardedRef","suppliedOptions","size","statusProp","placeholder","value","defaultValue","name","requiredProp","allowClear","form","className","style","disabledProp","idProp","onOpenChange","controlledOpen","defaultOpen","inputReadOnly","labelRender","tagRender","popupRender","onPopupScroll","onClick","onKeyDown","onBeforeInput","onCompositionStart","onPaste","onBlur","multiple","searchProp","filterOption","onSearch","popupWidth","popupMaxWidth","popupClassName","popupStyle","popupPlacement","getPopupContainer","loading","notFoundContent","optionRender","maxCount","maxTagCount","tagWrap","allowCreate","onCreate","virtualProp","listHeight","optionHeightProp","_onChange","inputProps","format","useFormattedText","showSearch","created","setCreated","useState","baseOptions","useMemo","entry","options","baseValues","Set","optionIndex","index","Map","optionGroups","virtual","messages","theme","density","configuredDirection","useLeafConfig","optionHeight","Math","estimateControlHeight","field","useFormField","disabled","required","status","undefined","root","useRef","input","panel","merged","useMergedRef","panelId","useId","selected","setSelected","useFieldValue","values","selectedValues","atLimit","unavailable","selectedCache","nextCache","key","record","selectedOptions","query","setQuery","searchQuery","open","setOpen","usePopupState","highlighted","setHighlighted","createOption","filtered","normalizedQuery","matched","newValue","rows","entries","previousGroup","group","virtualizer","useVirtualizer","useEffect","row","updateQuery","next","close","useFloatingDismiss","useActiveOption","change","nextValues","selectionIndex","openMenu","active","restoreSelectionHighlight","previous","beginSearch","selectOption","move","direction","i","candidate","renderOption","event","Plus","Check","displayLabel","textLabel","inputValue","clearable","controlOptionHeight","listboxProps","classes","Element","SelectionContent","remove","item","Boolean","candidates","last","LoaderCircle","ChevronDown","ClearButton","FormValue","FloatingPanel","content","FloatingFeedback","Select","rawProps","ref","useComponentProps"],"mappings":";;;;;;;;;;;;;;;;AA8FA,MAAMA,QAA2B,EAAE;AACnC,MAAMC,aAAa,CAACC,SAClBA,OAAO,WAAW,IACjB,CAAwB,YAAxB,OAAOA,OAAO,KAAK,IAAiB,AAAwB,YAAxB,OAAOA,OAAO,KAAK,GACpDC,OAAOD,OAAO,KAAK,IACnBA,OAAO,KAAI;AAEV,MAAME,uBAAgB,WAAHA,GAAGC,WAA0C,SACrEC,KAAkB,EAClBC,YAAY;IAEZ,MAAM,EACJ,SAASC,eAAe,EACxBC,OAAO,IAAI,EACX,QAAQC,UAAU,EAClBC,WAAW,EACXC,KAAK,EACLC,YAAY,EACZC,IAAI,EACJ,UAAUC,YAAY,EACtBC,aAAa,KAAK,EAClBC,IAAI,EACJC,SAAS,EACTC,KAAK,EACL,UAAUC,YAAY,EACtB,IAAIC,MAAM,EACVC,YAAY,EACZ,MAAMC,cAAc,EACpBC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,OAAO,EACPC,SAAS,EACTC,aAAa,EACbC,kBAAkB,EAClBC,OAAO,EACPC,MAAM,EACNC,WAAW,KAAK,EAChB,YAAYC,aAAa,KAAK,EAC9BC,eAAe,IAAI,EACnBC,QAAQ,EACRC,aAAa,SAAS,EACtBC,aAAa,EACbC,cAAc,EACdC,UAAU,EACVC,cAAc,EACdC,iBAAiB,EACjBC,UAAU,KAAK,EACfC,eAAe,EACfC,YAAY,EACZC,QAAQ,EACRC,WAAW,EACXC,UAAU,IAAI,EACdC,cAAc,KAAK,EACnBC,QAAQ,EACR,SAASC,WAAW,EACpBC,aAAa,GAAG,EAChB,cAAcC,gBAAgB,EAC9B,UAAUC,SAAS,EACnB,GAAGC,YACJ,G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K;gCACtB,OAAO;oCACL,UAAU;oCACV,KAAK;oCACL,MAAM;oCACN,OAAO;oCACP,WAAW,CAAC,WAAW,EAAEA,KAAK,KAAK,CAAC,GAAG,CAAC;gCAC1C;0CAECjC,IAAI,MAAM,GACTmB,aAAanB,IAAI,MAAM,EAAEA,IAAI,KAAK,kBAElC,IAAC;oCAAI,WAAU;8CAAsBA,IAAI,KAAK;;+BAd3CA,IAAI,GAAG;wBAkBlB;yBAGFP,KAAK,GAAG,CAAC,CAACO,MACRA,IAAI,MAAM,GACRmB,aAAanB,IAAI,MAAM,EAAEA,IAAI,KAAK,kBAElC,IAAC;4BAAkB,WAAU;sCAC1BA,IAAI,KAAK;2BADFA,IAAI,GAAG,mBAOvB,IAAC2C,kBAAgBA;kCAAE9H,mBAAmB6B,SAAS,MAAM,CAAC,KAAK;;;;;;AAMvE;AACAxE,qBAAc,WAAW,GAAG;AAErB,MAAM0K,gBAAS,WAAHA,GAAGzK,WAA0C,SAAgB0K,QAAQ,EAAEC,GAAG;IAC3F,MAAM1K,QAAQ2K,kBAAkB,UAAUF;IAC1C,OAAO,WAAP,GAAO,IAAC3K,sBAAaA;QAAE,GAAGE,KAAK;QAAE,KAAK0K;;AACxC;AACAF,cAAO,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection-content.d.ts","sourceRoot":"","sources":["../../../src/shared/selection-content.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"selection-content.d.ts","sourceRoot":"","sources":["../../../src/shared/selection-content.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAQf,UAAU,aAAa;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,OAAc,EACd,WAAW,EACX,UAAkB,EAClB,KAAU,EACV,WAAW,GACZ,EAAE;IACD,KAAK,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,+BA6PA"}
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { X } from "lucide-react";
|
|
4
4
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
+
import { useLeafConfig } from "../config-provider/context.js";
|
|
5
6
|
import { classes } from "./classes.js";
|
|
6
7
|
import { inertProps } from "./inert.js";
|
|
7
8
|
import { useListMotion } from "./motion.js";
|
|
8
9
|
const useBrowserLayoutEffect = "u" < typeof window ? useEffect : useLayoutEffect;
|
|
9
10
|
function SelectionContent({ items, children, className, tagClassName, tagWrap = true, maxTagCount, searchable = false, query = '', removeLabel }) {
|
|
10
11
|
const root = useRef(null);
|
|
12
|
+
const { theme, density } = useLeafConfig();
|
|
11
13
|
const count = items?.length ?? 0;
|
|
12
14
|
const limit = 'number' == typeof maxTagCount ? Math.max(0, Math.floor(maxTagCount)) : count;
|
|
13
15
|
const singleLine = void 0 !== items && (!tagWrap || 'responsive' === maxTagCount);
|
|
@@ -18,40 +20,76 @@ function SelectionContent({ items, children, className, tagClassName, tagWrap =
|
|
|
18
20
|
});
|
|
19
21
|
const visibleCount = Math.min(count, limit, singleLine ? layout.count : count);
|
|
20
22
|
const hiddenItems = items?.slice(visibleCount) ?? [];
|
|
23
|
+
const widths = useRef(new Map());
|
|
24
|
+
const tags = useRef([]);
|
|
25
|
+
const resizeObserver = useRef(null);
|
|
26
|
+
const mutationObserver = useRef(null);
|
|
27
|
+
const frame = useRef(null);
|
|
28
|
+
const invalidateContent = useRef((records)=>{
|
|
29
|
+
let changed = false;
|
|
30
|
+
for (const record of records){
|
|
31
|
+
const target = record.target instanceof Element ? record.target : record.target.parentElement;
|
|
32
|
+
const tag = target?.closest('[data-selection-item]');
|
|
33
|
+
if (tag && root.current?.contains(tag)) {
|
|
34
|
+
if ('attributes' === record.type && record.target === tag && ('hidden' === record.attributeName || 'inert' === record.attributeName)) continue;
|
|
35
|
+
widths.current.delete(tag);
|
|
36
|
+
} else if ('attributes' === record.type && record.target === root.current) {
|
|
37
|
+
if ('class' !== record.attributeName) continue;
|
|
38
|
+
widths.current.clear();
|
|
39
|
+
}
|
|
40
|
+
changed = true;
|
|
41
|
+
}
|
|
42
|
+
return changed;
|
|
43
|
+
});
|
|
21
44
|
const measure = useRef(()=>{});
|
|
22
45
|
measure.current = ()=>{
|
|
46
|
+
if (null !== frame.current) cancelAnimationFrame(frame.current);
|
|
47
|
+
frame.current = null;
|
|
48
|
+
invalidateContent.current(mutationObserver.current?.takeRecords() ?? []);
|
|
23
49
|
const element = root.current;
|
|
24
50
|
if (!singleLine || !element?.clientWidth) return;
|
|
25
51
|
const width = element.clientWidth;
|
|
26
52
|
const gap = Number.parseFloat(getComputedStyle(element).columnGap) || 0;
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
const nextTags = Array.from(element.querySelectorAll('[data-selection-item]'));
|
|
54
|
+
const retained = new Set(nextTags);
|
|
55
|
+
for (const tag of tags.current)if (!retained.has(tag)) {
|
|
56
|
+
resizeObserver.current?.unobserve(tag);
|
|
57
|
+
widths.current.delete(tag);
|
|
58
|
+
}
|
|
59
|
+
const previous = new Set(tags.current);
|
|
60
|
+
for (const tag of nextTags)if (!previous.has(tag)) resizeObserver.current?.observe(tag);
|
|
61
|
+
tags.current = nextTags;
|
|
62
|
+
const missing = nextTags.filter((tag)=>!widths.current.has(tag));
|
|
63
|
+
if (missing.length) {
|
|
64
|
+
const hiddenTags = missing.filter((tag)=>tag.hidden);
|
|
65
|
+
element.dataset.measuring = '';
|
|
66
|
+
for (const tag of hiddenTags)tag.hidden = false;
|
|
67
|
+
for (const tag of missing)widths.current.set(tag, tag.getBoundingClientRect().width);
|
|
68
|
+
for (const tag of hiddenTags)tag.hidden = true;
|
|
69
|
+
delete element.dataset.measuring;
|
|
70
|
+
}
|
|
71
|
+
const tagWidths = nextTags.map((tag)=>widths.current.get(tag) ?? 0);
|
|
32
72
|
const overflowWidth = element.querySelector('[data-selection-counter]')?.getBoundingClientRect().width ?? 0;
|
|
33
73
|
const queryWidth = element.querySelector('[data-selection-query]')?.getBoundingClientRect().width ?? 0;
|
|
34
|
-
for (const tag of hiddenTags)tag.hidden = true;
|
|
35
|
-
delete element.dataset.measuring;
|
|
36
74
|
const inputWidth = children ? Math.min(Math.max(0, width - (count ? overflowWidth + gap : 0)), searchable ? query ? Math.max(48, queryWidth + 12) : 24 : 1) : 0;
|
|
37
75
|
const budget = Math.max(0, width - inputWidth - (children && count ? gap : 0));
|
|
38
|
-
const totalWidth =
|
|
76
|
+
const totalWidth = tagWidths.reduce((sum, value)=>sum + value, 0) + Math.max(0, count - 1) * gap;
|
|
39
77
|
let nextCount = 0;
|
|
40
78
|
let firstWidth = 0;
|
|
41
79
|
if (count <= limit && totalWidth <= budget) nextCount = count;
|
|
42
|
-
else if (1 === count && limit > 0 && budget >= Math.min(
|
|
80
|
+
else if (1 === count && limit > 0 && budget >= Math.min(tagWidths[0] ?? 0, 48)) {
|
|
43
81
|
nextCount = 1;
|
|
44
82
|
firstWidth = budget;
|
|
45
83
|
} else {
|
|
46
84
|
const tagBudget = Math.max(0, budget - overflowWidth - gap);
|
|
47
85
|
let used = 0;
|
|
48
|
-
for (const tagWidth of
|
|
86
|
+
for (const tagWidth of tagWidths.slice(0, Math.min(limit, count - 1))){
|
|
49
87
|
const next = used + (nextCount ? gap : 0) + tagWidth;
|
|
50
88
|
if (next > tagBudget) break;
|
|
51
89
|
used = next;
|
|
52
90
|
nextCount++;
|
|
53
91
|
}
|
|
54
|
-
if (!nextCount && limit > 0 && count > 1 && tagBudget >= Math.min(
|
|
92
|
+
if (!nextCount && limit > 0 && count > 1 && tagBudget >= Math.min(tagWidths[0] ?? 0, 48)) {
|
|
55
93
|
nextCount = 1;
|
|
56
94
|
firstWidth = tagBudget;
|
|
57
95
|
}
|
|
@@ -62,23 +100,64 @@ function SelectionContent({ items, children, className, tagClassName, tagWrap =
|
|
|
62
100
|
inputWidth
|
|
63
101
|
});
|
|
64
102
|
};
|
|
103
|
+
useBrowserLayoutEffect(()=>{
|
|
104
|
+
widths.current.clear();
|
|
105
|
+
}, [
|
|
106
|
+
theme,
|
|
107
|
+
density,
|
|
108
|
+
className,
|
|
109
|
+
tagClassName,
|
|
110
|
+
singleLine
|
|
111
|
+
]);
|
|
65
112
|
useBrowserLayoutEffect(()=>measure.current());
|
|
66
|
-
|
|
113
|
+
useBrowserLayoutEffect(()=>{
|
|
67
114
|
if (!singleLine || !root.current) return;
|
|
68
|
-
const
|
|
69
|
-
|
|
115
|
+
const schedule = ()=>{
|
|
116
|
+
if (null === frame.current) frame.current = requestAnimationFrame(()=>measure.current());
|
|
117
|
+
};
|
|
118
|
+
const update = ()=>{
|
|
119
|
+
widths.current.clear();
|
|
120
|
+
schedule();
|
|
121
|
+
};
|
|
122
|
+
const delivered = new WeakSet();
|
|
123
|
+
const observer = "u" < typeof ResizeObserver ? null : new ResizeObserver((entries)=>{
|
|
124
|
+
for (const entry of entries){
|
|
125
|
+
if (delivered.has(entry.target)) if (entry.target instanceof HTMLElement && entry.target.hasAttribute('data-selection-item')) {
|
|
126
|
+
if (!entry.target.hidden) widths.current.delete(entry.target);
|
|
127
|
+
} else widths.current.clear();
|
|
128
|
+
delivered.add(entry.target);
|
|
129
|
+
}
|
|
130
|
+
schedule();
|
|
131
|
+
});
|
|
132
|
+
resizeObserver.current = observer;
|
|
70
133
|
observer?.observe(root.current);
|
|
71
|
-
for (const tag of
|
|
134
|
+
for (const tag of tags.current)observer?.observe(tag);
|
|
135
|
+
const counter = root.current.querySelector('[data-selection-counter]');
|
|
136
|
+
if (counter) observer?.observe(counter);
|
|
137
|
+
const mutations = "u" < typeof MutationObserver ? null : new MutationObserver((records)=>{
|
|
138
|
+
if (invalidateContent.current(records)) schedule();
|
|
139
|
+
});
|
|
140
|
+
mutationObserver.current = mutations;
|
|
141
|
+
mutations?.observe(root.current, {
|
|
142
|
+
subtree: true,
|
|
143
|
+
childList: true,
|
|
144
|
+
characterData: true,
|
|
145
|
+
attributes: true
|
|
146
|
+
});
|
|
72
147
|
window.addEventListener('resize', update);
|
|
73
148
|
document.fonts?.addEventListener('loadingdone', update);
|
|
74
149
|
return ()=>{
|
|
150
|
+
if (null !== frame.current) cancelAnimationFrame(frame.current);
|
|
151
|
+
frame.current = null;
|
|
75
152
|
observer?.disconnect();
|
|
153
|
+
mutations?.disconnect();
|
|
154
|
+
resizeObserver.current = null;
|
|
155
|
+
mutationObserver.current = null;
|
|
76
156
|
window.removeEventListener('resize', update);
|
|
77
157
|
document.fonts?.removeEventListener('loadingdone', update);
|
|
78
158
|
};
|
|
79
159
|
}, [
|
|
80
|
-
singleLine
|
|
81
|
-
count
|
|
160
|
+
singleLine
|
|
82
161
|
]);
|
|
83
162
|
useListMotion(root, JSON.stringify(items?.slice(0, visibleCount).map((item)=>item.key)), '.leaf-selection__tag[data-motion-key]:not([hidden])', singleLine ? visibleCount : false);
|
|
84
163
|
return /*#__PURE__*/ jsxs("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared/selection-content.js","sources":["../../../src/shared/selection-content.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport {\n type CSSProperties,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { classes } from './classes';\nimport { inertProps } from './inert';\nimport { useListMotion } from './motion';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface SelectionItem {\n key: string;\n label: ReactNode;\n text: string;\n remove?: () => void;\n render?: ReactNode;\n}\n\n/** Shared selected-value layout. Measure the real tags, without mounting custom renderers twice. */\nexport function SelectionContent({\n items,\n children,\n className,\n tagClassName,\n tagWrap = true,\n maxTagCount,\n searchable = false,\n query = '',\n removeLabel,\n}: {\n items?: readonly SelectionItem[];\n children?: ReactNode;\n className?: string;\n tagClassName?: string;\n tagWrap?: boolean;\n maxTagCount?: number | 'responsive';\n searchable?: boolean;\n query?: string;\n removeLabel?: string;\n}) {\n const root = useRef<HTMLSpanElement>(null);\n const count = items?.length ?? 0;\n const limit = typeof maxTagCount === 'number' ? Math.max(0, Math.floor(maxTagCount)) : count;\n const singleLine = items !== undefined && (!tagWrap || maxTagCount === 'responsive');\n const [layout, setLayout] = useState({ count, firstWidth: 0, inputWidth: 0 });\n const visibleCount = Math.min(count, limit, singleLine ? layout.count : count);\n const hiddenItems = items?.slice(visibleCount) ?? [];\n const measure = useRef(() => {});\n measure.current = () => {\n const element = root.current;\n if (!singleLine || !element?.clientWidth) return;\n const width = element.clientWidth;\n const gap = Number.parseFloat(getComputedStyle(element).columnGap) || 0;\n // All writes precede the reads. The temporary measurement is restored before paint.\n const tags = Array.from(element.querySelectorAll<HTMLElement>('[data-selection-item]'));\n const hiddenTags = tags.filter((tag) => tag.hidden);\n element.dataset.measuring = '';\n // Normalize/utility styles often enforce [hidden] with !important. Temporarily\n // remove the attribute itself instead of relying on a CSS override.\n for (const tag of hiddenTags) tag.hidden = false;\n const widths = tags.map((tag) => tag.getBoundingClientRect().width);\n const overflowWidth =\n element.querySelector<HTMLElement>('[data-selection-counter]')?.getBoundingClientRect()\n .width ?? 0;\n const queryWidth =\n element.querySelector<HTMLElement>('[data-selection-query]')?.getBoundingClientRect().width ??\n 0;\n for (const tag of hiddenTags) tag.hidden = true;\n delete element.dataset.measuring;\n const inputWidth = children\n ? Math.min(\n Math.max(0, width - (count ? overflowWidth + gap : 0)),\n searchable ? (query ? Math.max(48, queryWidth + 12) : 24) : 1,\n )\n : 0;\n const budget = Math.max(0, width - inputWidth - (children && count ? gap : 0));\n const totalWidth = widths.reduce((sum, value) => sum + value, 0) + Math.max(0, count - 1) * gap;\n let nextCount = 0;\n let firstWidth = 0;\n if (count <= limit && totalWidth <= budget) nextCount = count;\n else if (count === 1 && limit > 0 && budget >= Math.min(widths[0] ?? 0, 48)) {\n nextCount = 1;\n firstWidth = budget;\n } else {\n const tagBudget = Math.max(0, budget - overflowWidth - gap);\n let used = 0;\n for (const tagWidth of widths.slice(0, Math.min(limit, count - 1))) {\n const next = used + (nextCount ? gap : 0) + tagWidth;\n if (next > tagBudget) break;\n used = next;\n nextCount++;\n }\n // Keep the first long label useful, while preserving the remove button and +N.\n if (!nextCount && limit > 0 && count > 1 && tagBudget >= Math.min(widths[0] ?? 0, 48)) {\n nextCount = 1;\n firstWidth = tagBudget;\n }\n }\n setLayout((previous) =>\n previous.count === nextCount &&\n previous.firstWidth === firstWidth &&\n previous.inputWidth === inputWidth\n ? previous\n : { count: nextCount, firstWidth, inputWidth },\n );\n };\n useBrowserLayoutEffect(() => measure.current());\n // biome-ignore lint/correctness/useExhaustiveDependencies: Observe the new tag elements after selection changes.\n useEffect(() => {\n if (!singleLine || !root.current) return;\n const update = () => measure.current();\n const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(update);\n observer?.observe(root.current);\n for (const tag of root.current.querySelectorAll('[data-selection-item]'))\n observer?.observe(tag);\n window.addEventListener('resize', update);\n document.fonts?.addEventListener('loadingdone', update);\n return () => {\n observer?.disconnect();\n window.removeEventListener('resize', update);\n document.fonts?.removeEventListener('loadingdone', update);\n };\n }, [singleLine, count]);\n useListMotion(\n root,\n JSON.stringify(items?.slice(0, visibleCount).map((item) => item.key)),\n '.leaf-selection__tag[data-motion-key]:not([hidden])',\n singleLine ? visibleCount : false,\n );\n return (\n <span\n ref={root}\n className={classes('leaf-selection', className)}\n data-multiple={items !== undefined || undefined}\n data-single-line={singleLine || undefined}\n style={\n singleLine\n ? ({\n '--leaf-selection-first-width': layout.firstWidth\n ? `${layout.firstWidth}px`\n : undefined,\n '--leaf-selection-input-width': `${layout.inputWidth}px`,\n } as CSSProperties)\n : undefined\n }\n >\n {items?.slice(0, singleLine ? count : visibleCount).map((item, index) => (\n <span\n className={classes('leaf-selection__tag', tagClassName)}\n key={item.key}\n data-selection-item=\"\"\n data-motion-key={item.key}\n data-custom={item.render != null || undefined}\n hidden={index >= visibleCount}\n {...inertProps(index >= visibleCount)}\n title={item.text}\n >\n {item.render ?? (\n <>\n <span>{item.label}</span>\n {item.remove && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={`${removeLabel} ${item.text}`}\n onMouseDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.stopPropagation();\n item.remove?.();\n }}\n >\n <X size={12} aria-hidden=\"true\" />\n </button>\n )}\n </>\n )}\n </span>\n ))}\n {hiddenItems.length > 0 && (\n <span\n className={classes('leaf-selection__tag', tagClassName)}\n title={hiddenItems.map((item) => item.text).join(', ')}\n data-selection-overflow=\"\"\n >\n +{hiddenItems.length}\n <span className=\"leaf-selection__sr\">\n {hiddenItems.map((item) => item.text).join(', ')}\n </span>\n </span>\n )}\n {children && <span className=\"leaf-selection__input\">{children}</span>}\n {singleLine && (\n <span className=\"leaf-selection__measure\" aria-hidden=\"true\">\n <span className={classes('leaf-selection__tag', tagClassName)} data-selection-counter=\"\">\n +{count}\n </span>\n <span data-selection-query=\"\">{query}</span>\n </span>\n )}\n </span>\n );\n}\n"],"names":["useBrowserLayoutEffect","window","useEffect","useLayoutEffect","SelectionContent","items","children","className","tagClassName","tagWrap","maxTagCount","searchable","query","removeLabel","root","useRef","count","limit","Math","singleLine","undefined","layout","setLayout","useState","visibleCount","hiddenItems","measure","element","width","gap","Number","getComputedStyle","tags","Array","hiddenTags","tag","widths","overflowWidth","queryWidth","inputWidth","budget","totalWidth","sum","value","nextCount","firstWidth","tagBudget","used","tagWidth","next","previous","update","observer","ResizeObserver","document","useListMotion","JSON","item","classes","index","inertProps","event","X"],"mappings":";;;;;;;AAaA,MAAMA,yBAAyB,AAAkB,MAAlB,OAAOC,SAAyBC,YAAYC;AAWpE,SAASC,iBAAiB,EAC/BC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,UAAU,IAAI,EACdC,WAAW,EACXC,aAAa,KAAK,EAClBC,QAAQ,EAAE,EACVC,WAAW,EAWZ;IACC,MAAMC,OAAOC,OAAwB;IACrC,MAAMC,QAAQX,OAAO,UAAU;IAC/B,MAAMY,QAAQ,AAAuB,YAAvB,OAAOP,cAA2BQ,KAAK,GAAG,CAAC,GAAGA,KAAK,KAAK,CAACR,gBAAgBM;IACvF,MAAMG,aAAad,AAAUe,WAAVf,SAAwB,EAACI,WAAWC,AAAgB,iBAAhBA,WAA2B;IAClF,MAAM,CAACW,QAAQC,UAAU,GAAGC,SAAS;QAAEP;QAAO,YAAY;QAAG,YAAY;IAAE;IAC3E,MAAMQ,eAAeN,KAAK,GAAG,CAACF,OAAOC,OAAOE,aAAaE,OAAO,KAAK,GAAGL;IACxE,MAAMS,cAAcpB,OAAO,MAAMmB,iBAAiB,EAAE;IACpD,MAAME,UAAUX,OAAO,KAAO;IAC9BW,QAAQ,OAAO,GAAG;QAChB,MAAMC,UAAUb,KAAK,OAAO;QAC5B,IAAI,CAACK,cAAc,CAACQ,SAAS,aAAa;QAC1C,MAAMC,QAAQD,QAAQ,WAAW;QACjC,MAAME,MAAMC,OAAO,UAAU,CAACC,iBAAiBJ,SAAS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C,OAASA,KAAK,IAAI,EAAE,IAAI,CAAC;;;;YAIhDnD,YAAY,WAAZA,GAAY,IAAC;gBAAK,WAAU;0BAAyBA;;YACrDa,cAAc,WAAdA,GACC,KAAC;gBAAK,WAAU;gBAA0B,eAAY;;kCACpD,KAAC;wBAAK,WAAWuC,QAAQ,uBAAuBlD;wBAAe,0BAAuB;;4BAAG;4BACrFQ;;;kCAEJ,IAAC;wBAAK,wBAAqB;kCAAIJ;;;;;;AAKzC"}
|
|
1
|
+
{"version":3,"file":"shared/selection-content.js","sources":["../../../src/shared/selection-content.tsx"],"sourcesContent":["import { X } from 'lucide-react';\nimport {\n type CSSProperties,\n type ReactNode,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { useLeafConfig } from '../config-provider/context';\nimport { classes } from './classes';\nimport { inertProps } from './inert';\nimport { useListMotion } from './motion';\n\nconst useBrowserLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface SelectionItem {\n key: string;\n label: ReactNode;\n text: string;\n remove?: () => void;\n render?: ReactNode;\n}\n\n/** Shared selected-value layout. Measure the real tags, without mounting custom renderers twice. */\nexport function SelectionContent({\n items,\n children,\n className,\n tagClassName,\n tagWrap = true,\n maxTagCount,\n searchable = false,\n query = '',\n removeLabel,\n}: {\n items?: readonly SelectionItem[];\n children?: ReactNode;\n className?: string;\n tagClassName?: string;\n tagWrap?: boolean;\n maxTagCount?: number | 'responsive';\n searchable?: boolean;\n query?: string;\n removeLabel?: string;\n}) {\n const root = useRef<HTMLSpanElement>(null);\n const { theme, density } = useLeafConfig();\n const count = items?.length ?? 0;\n const limit = typeof maxTagCount === 'number' ? Math.max(0, Math.floor(maxTagCount)) : count;\n const singleLine = items !== undefined && (!tagWrap || maxTagCount === 'responsive');\n const [layout, setLayout] = useState({ count, firstWidth: 0, inputWidth: 0 });\n const visibleCount = Math.min(count, limit, singleLine ? layout.count : count);\n const hiddenItems = items?.slice(visibleCount) ?? [];\n const widths = useRef(new Map<HTMLElement, number>());\n const tags = useRef<HTMLElement[]>([]);\n const resizeObserver = useRef<ResizeObserver | null>(null);\n const mutationObserver = useRef<MutationObserver | null>(null);\n const frame = useRef<number | null>(null);\n const invalidateContent = useRef((records: MutationRecord[]) => {\n let changed = false;\n for (const record of records) {\n const target = record.target instanceof Element ? record.target : record.target.parentElement;\n const tag = target?.closest<HTMLElement>('[data-selection-item]');\n if (tag && root.current?.contains(tag)) {\n // Showing tags to measure them, and folding them afterwards, do not change their content.\n if (\n record.type === 'attributes' &&\n record.target === tag &&\n (record.attributeName === 'hidden' || record.attributeName === 'inert')\n )\n continue;\n widths.current.delete(tag);\n } else if (record.type === 'attributes' && record.target === root.current) {\n if (record.attributeName !== 'class') continue;\n widths.current.clear();\n }\n changed = true;\n }\n return changed;\n });\n const measure = useRef(() => {});\n measure.current = () => {\n if (frame.current !== null) cancelAnimationFrame(frame.current);\n frame.current = null;\n invalidateContent.current(mutationObserver.current?.takeRecords() ?? []);\n const element = root.current;\n if (!singleLine || !element?.clientWidth) return;\n const width = element.clientWidth;\n const gap = Number.parseFloat(getComputedStyle(element).columnGap) || 0;\n const nextTags = Array.from(element.querySelectorAll<HTMLElement>('[data-selection-item]'));\n const retained = new Set(nextTags);\n for (const tag of tags.current) {\n if (retained.has(tag)) continue;\n resizeObserver.current?.unobserve(tag);\n widths.current.delete(tag);\n }\n const previous = new Set(tags.current);\n for (const tag of nextTags) if (!previous.has(tag)) resizeObserver.current?.observe(tag);\n tags.current = nextTags;\n const missing = nextTags.filter((tag) => !widths.current.has(tag));\n if (missing.length) {\n // Measure only new/invalidated content, on the real nodes, before paint.\n const hiddenTags = missing.filter((tag) => tag.hidden);\n element.dataset.measuring = '';\n for (const tag of hiddenTags) tag.hidden = false;\n for (const tag of missing) widths.current.set(tag, tag.getBoundingClientRect().width);\n for (const tag of hiddenTags) tag.hidden = true;\n delete element.dataset.measuring;\n }\n const tagWidths = nextTags.map((tag) => widths.current.get(tag) ?? 0);\n const overflowWidth =\n element.querySelector<HTMLElement>('[data-selection-counter]')?.getBoundingClientRect()\n .width ?? 0;\n const queryWidth =\n element.querySelector<HTMLElement>('[data-selection-query]')?.getBoundingClientRect().width ??\n 0;\n const inputWidth = children\n ? Math.min(\n Math.max(0, width - (count ? overflowWidth + gap : 0)),\n searchable ? (query ? Math.max(48, queryWidth + 12) : 24) : 1,\n )\n : 0;\n const budget = Math.max(0, width - inputWidth - (children && count ? gap : 0));\n const totalWidth =\n tagWidths.reduce((sum, value) => sum + value, 0) + Math.max(0, count - 1) * gap;\n let nextCount = 0;\n let firstWidth = 0;\n if (count <= limit && totalWidth <= budget) nextCount = count;\n else if (count === 1 && limit > 0 && budget >= Math.min(tagWidths[0] ?? 0, 48)) {\n nextCount = 1;\n firstWidth = budget;\n } else {\n const tagBudget = Math.max(0, budget - overflowWidth - gap);\n let used = 0;\n for (const tagWidth of tagWidths.slice(0, Math.min(limit, count - 1))) {\n const next = used + (nextCount ? gap : 0) + tagWidth;\n if (next > tagBudget) break;\n used = next;\n nextCount++;\n }\n // Keep the first long label useful, while preserving the remove button and +N.\n if (!nextCount && limit > 0 && count > 1 && tagBudget >= Math.min(tagWidths[0] ?? 0, 48)) {\n nextCount = 1;\n firstWidth = tagBudget;\n }\n }\n setLayout((previous) =>\n previous.count === nextCount &&\n previous.firstWidth === firstWidth &&\n previous.inputWidth === inputWidth\n ? previous\n : { count: nextCount, firstWidth, inputWidth },\n );\n };\n useBrowserLayoutEffect(() => {\n widths.current.clear();\n }, [theme, density, className, tagClassName, singleLine]);\n useBrowserLayoutEffect(() => measure.current());\n useBrowserLayoutEffect(() => {\n if (!singleLine || !root.current) return;\n const schedule = () => {\n if (frame.current === null) frame.current = requestAnimationFrame(() => measure.current());\n };\n const update = () => {\n widths.current.clear();\n schedule();\n };\n // Initial delivery only checks layout; later size changes also invalidate widths.\n const delivered = new WeakSet<Element>();\n const observer =\n typeof ResizeObserver === 'undefined'\n ? null\n : new ResizeObserver((entries) => {\n for (const entry of entries) {\n if (delivered.has(entry.target)) {\n if (\n entry.target instanceof HTMLElement &&\n entry.target.hasAttribute('data-selection-item')\n ) {\n // Folding a tag does not invalidate its natural width. A resized\n // visible tag only invalidates itself, not every hidden selection.\n if (!entry.target.hidden) widths.current.delete(entry.target);\n } else widths.current.clear();\n }\n delivered.add(entry.target);\n }\n schedule();\n });\n resizeObserver.current = observer;\n observer?.observe(root.current);\n for (const tag of tags.current) observer?.observe(tag);\n const counter = root.current.querySelector('[data-selection-counter]');\n if (counter) observer?.observe(counter);\n const mutations =\n typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver((records) => {\n if (invalidateContent.current(records)) schedule();\n });\n mutationObserver.current = mutations;\n mutations?.observe(root.current, {\n subtree: true,\n childList: true,\n characterData: true,\n attributes: true,\n });\n window.addEventListener('resize', update);\n document.fonts?.addEventListener('loadingdone', update);\n return () => {\n if (frame.current !== null) cancelAnimationFrame(frame.current);\n frame.current = null;\n observer?.disconnect();\n mutations?.disconnect();\n resizeObserver.current = null;\n mutationObserver.current = null;\n window.removeEventListener('resize', update);\n document.fonts?.removeEventListener('loadingdone', update);\n };\n }, [singleLine]);\n useListMotion(\n root,\n JSON.stringify(items?.slice(0, visibleCount).map((item) => item.key)),\n '.leaf-selection__tag[data-motion-key]:not([hidden])',\n singleLine ? visibleCount : false,\n );\n return (\n <span\n ref={root}\n className={classes('leaf-selection', className)}\n data-multiple={items !== undefined || undefined}\n data-single-line={singleLine || undefined}\n style={\n singleLine\n ? ({\n '--leaf-selection-first-width': layout.firstWidth\n ? `${layout.firstWidth}px`\n : undefined,\n '--leaf-selection-input-width': `${layout.inputWidth}px`,\n } as CSSProperties)\n : undefined\n }\n >\n {items?.slice(0, singleLine ? count : visibleCount).map((item, index) => (\n <span\n className={classes('leaf-selection__tag', tagClassName)}\n key={item.key}\n data-selection-item=\"\"\n data-motion-key={item.key}\n data-custom={item.render != null || undefined}\n hidden={index >= visibleCount}\n {...inertProps(index >= visibleCount)}\n title={item.text}\n >\n {item.render ?? (\n <>\n <span>{item.label}</span>\n {item.remove && (\n <button\n type=\"button\"\n tabIndex={-1}\n aria-label={`${removeLabel} ${item.text}`}\n onMouseDown={(event) => event.preventDefault()}\n onClick={(event) => {\n event.stopPropagation();\n item.remove?.();\n }}\n >\n <X size={12} aria-hidden=\"true\" />\n </button>\n )}\n </>\n )}\n </span>\n ))}\n {hiddenItems.length > 0 && (\n <span\n className={classes('leaf-selection__tag', tagClassName)}\n title={hiddenItems.map((item) => item.text).join(', ')}\n data-selection-overflow=\"\"\n >\n +{hiddenItems.length}\n <span className=\"leaf-selection__sr\">\n {hiddenItems.map((item) => item.text).join(', ')}\n </span>\n </span>\n )}\n {children && <span className=\"leaf-selection__input\">{children}</span>}\n {singleLine && (\n <span className=\"leaf-selection__measure\" aria-hidden=\"true\">\n <span className={classes('leaf-selection__tag', tagClassName)} data-selection-counter=\"\">\n +{count}\n </span>\n <span data-selection-query=\"\">{query}</span>\n </span>\n )}\n </span>\n );\n}\n"],"names":["useBrowserLayoutEffect","window","useEffect","useLayoutEffect","SelectionContent","items","children","className","tagClassName","tagWrap","maxTagCount","searchable","query","removeLabel","root","useRef","theme","density","useLeafConfig","count","limit","Math","singleLine","undefined","layout","setLayout","useState","visibleCount","hiddenItems","widths","Map","tags","resizeObserver","mutationObserver","frame","invalidateContent","records","changed","record","target","Element","tag","measure","cancelAnimationFrame","element","width","gap","Number","getComputedStyle","nextTags","Array","retained","Set","previous","missing","hiddenTags","tagWidths","overflowWidth","queryWidth","inputWidth","budget","totalWidth","sum","value","nextCount","firstWidth","tagBudget","used","tagWidth","next","schedule","requestAnimationFrame","update","delivered","WeakSet","observer","ResizeObserver","entries","entry","HTMLElement","counter","mutations","MutationObserver","document","useListMotion","JSON","item","classes","index","inertProps","event","X"],"mappings":";;;;;;;;AAcA,MAAMA,yBAAyB,AAAkB,MAAlB,OAAOC,SAAyBC,YAAYC;AAWpE,SAASC,iBAAiB,EAC/BC,KAAK,EACLC,QAAQ,EACRC,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