@sanity/ui 4.4.0 → 4.4.2
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/{arrow-B8L6YB-v.js → arrow-A3jQ7LS0.js} +2 -2
- package/dist/{arrow-B8L6YB-v.js.map → arrow-A3jQ7LS0.js.map} +1 -1
- package/dist/autocomplete.d.ts +5 -1
- package/dist/autocomplete.d.ts.map +1 -1
- package/dist/autocomplete.js +93 -103
- package/dist/autocomplete.js.map +1 -1
- package/dist/breadcrumbs.js +1 -1
- package/dist/{getElementRef-Jw7gY0eV.js → getElementRef-BLVMlHTn.js} +78 -3
- package/dist/getElementRef-BLVMlHTn.js.map +1 -0
- package/dist/{hotkeys-sG9yO97K.js → hotkeys-Caqg1W-_.js} +2 -2
- package/dist/{hotkeys-sG9yO97K.js.map → hotkeys-Caqg1W-_.js.map} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -21
- package/dist/index.js.map +1 -1
- package/dist/menu.d.ts +5 -0
- package/dist/menu.d.ts.map +1 -1
- package/dist/menu.js +165 -168
- package/dist/menu.js.map +1 -1
- package/dist/{popover-C72hePrK.js → popover-CEDyHcBi.js} +141 -144
- package/dist/popover-CEDyHcBi.js.map +1 -0
- package/dist/popover-HDVgZg5e.d.ts.map +1 -1
- package/dist/popover.js +1 -2
- package/dist/tooltip.js +70 -82
- package/dist/tooltip.js.map +1 -1
- package/package.json +8 -8
- package/dist/getElementRef-Jw7gY0eV.js.map +0 -1
- package/dist/popover-C72hePrK.js.map +0 -1
package/dist/autocomplete.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.js","names":["() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }","useCallback(() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }, [onSelect, value])","(event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n }","useCallback(\n (event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n },\n [handleClick],\n )","<li\n aria-selected={selected}\n data-ui=\"AutocompleteOption\"\n id={id}\n // oxlint-disable-next-line no-noninteractive-element-to-interactive-role, prefer-tag-over-role\n role=\"option\"\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {children}\n </li>","_c","border = true","fontSize = 2","listBox = EMPTY_RECORD","paddingProp = 3","popover = EMPTY_RECORD","radius = 2","renderValue = DEFAULT_RENDER_VALUE","{\n activeValue: valueProp || null,\n focused: false,\n listFocused: false,\n query: null,\n value: valueProp || null,\n }","valueProp || null","({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n )","{value}: BaseAutocompleteOption","value","useCallback(\n ({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n ),\n [fontSize, paddingProp],\n )","() => inputElement","[inputElement]","value !== null ? options.find((o) => o.value === value) : undefined","useMemo(\n () => (value !== null ? options.find((o) => o.value === value) : undefined),\n [options, value],\n )","options.filter((option) => (query ? filterOption(query, option) : true))","(option) => (query ? filterOption(query, option) : true)","useMemo(\n () => options.filter((option) => (query ? filterOption(query, option) : true)),\n [filterOption, options, query],\n )","(event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n }","useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n },\n [onBlur, onQueryChange, relatedElements],\n )","(event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }","event","listFocused","useCallback((event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }, [])","(v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n\n valueRef.current = v\n\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n }","useCallback(\n (v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n\n valueRef.current = v\n\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n },\n [onChange, onSelect, onQueryChange],\n )","(event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n }","o","activeOption","activeIndex","nextActiveOption","useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n },\n [activeValue, filteredOptions, filteredOptionsLen, onQueryChange],\n )","(event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n }","useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n },\n [onQueryChange],\n )","() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }","useCallback(() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }, [currentOption, renderValue, value])","(event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n }","useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n },\n [focused, onFocus, openOnFocus, dispatchOpen],\n )","() => {\n popoverMouseWithinRef.current = true\n }","useCallback(() => {\n popoverMouseWithinRef.current = true\n }, [])","() => {\n popoverMouseWithinRef.current = false\n }","useCallback(() => {\n popoverMouseWithinRef.current = false\n }, [])","() => {\n dispatch({type: 'root/clear'})\n valueRef.current = ''\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }","useCallback(() => {\n dispatch({type: 'root/clear'})\n valueRef.current = ''\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }, [onChange, onQueryChange])","() => {\n dispatch({type: 'input/focus'})\n }","useCallback(() => {\n dispatch({type: 'input/focus'})\n }, [])","() => {\n // If `valueProp` changed\n if (valueProp !== valuePropRef.current) {\n valuePropRef.current = valueProp\n\n if (valueProp !== undefined) {\n dispatch({type: 'value/change', value: valueProp})\n valueRef.current = valueProp\n }\n\n return\n }\n\n // If `valueProp` is not equal to `value`\n if (valueProp !== valueRef.current) {\n valueRef.current = valueProp || null\n\n dispatch({type: 'value/change', value: valueProp || null})\n }\n }","[valueProp]","() => {\n if (!focused && valueRef.current) {\n dispatch({type: 'root/setActiveValue', value: valueRef.current})\n }\n }","[focused]","() => {\n const listElement = listBoxElementRef.current\n\n if (!listElement) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n\n if (activeOption) {\n const activeIndex = filteredOptions.indexOf(activeOption)\n // oxlint-disable-next-line no-unsafe-type-assertion\n const activeItemElement = listElement.childNodes[activeIndex] as HTMLLIElement | undefined\n\n if (activeItemElement) {\n if (_hasFocus(activeItemElement)) {\n // already focused\n return\n }\n\n focusFirstDescendant(activeItemElement)\n }\n }\n }","[activeValue, filteredOptions]","useMemo(() => {\n if (!loading && !disabled && value) {\n return {\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }\n }\n\n return undefined\n }, [disabled, handleClearButtonFocus, loading, value])","{\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }","(v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n }","(v) => Math.max(v - 1, 0)","(event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n }","openButtonProps.onClick","useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n },\n [openButtonProps, dispatchOpen],\n )","!disabled && !readOnly && openButton ? (\n <Box aria-hidden={expanded} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={expanded}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined","useMemo(\n () =>\n !disabled && !readOnly && openButton ? (\n <Box aria-hidden={expanded} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={expanded}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined,\n [\n disabled,\n expanded,\n fontSize,\n handleOpenClick,\n openButton,\n openButtonBoxPadding,\n openButtonPadding,\n openButtonProps,\n readOnly,\n ],\n )","useMemo(() => {\n if (query === null) {\n if (value !== null) {\n return renderValue(value, currentOption)\n }\n\n return ''\n }\n\n return query\n }, [currentOption, query, renderValue, value])","renderValue(value, currentOption)","(event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n }","useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n },\n [listFocused],\n )","useMemo(() => {\n if (filteredOptions.length === 0) return null\n\n return (\n <Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>\n )\n }, [\n activeValue,\n currentOption,\n filteredOptions,\n handleOptionSelect,\n handleListBoxKeyDown,\n id,\n listBox,\n listBoxId,\n listFocused,\n loading,\n renderOption,\n ])","clsx(autocompleteListBox, listBox?.className)","listBox?.className","filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })","(option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n }","option","<Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>","<Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>","useMemo(() => {\n if (renderPopover) {\n return (\n <RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />\n )\n }\n\n if (filteredOptionsLen === 0) {\n return null\n }\n\n return (\n <Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />\n )\n }, [\n content,\n expanded,\n filteredOptionsLen,\n handlePopoverMouseEnter,\n handlePopoverMouseLeave,\n inputElement,\n popover,\n radius,\n renderPopover,\n ])","<RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />","!expanded","<Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />","loading && <SpinnerIcon className={spinnerIcon} />","<TextInput\n {...restProps}\n aria-activedescendant={activeItemId}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />","suffix || openButtonNode","<div\n className={autocomplete}\n data-ui=\"Autocomplete\"\n onBlur={handleRootBlur}\n onFocus={handleRootFocus}\n onKeyDown={handleRootKeyDown}\n ref={rootElementRef}\n >\n <TextInput\n {...restProps}\n aria-activedescendant={activeItemId}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />\n {results}\n </div>","v","_c","defaultRenderOption","\"onFocus\""],"sources":["../src/core/components/autocomplete/autocompleteOption.tsx","../src/core/components/autocomplete/autocompleteReducer.ts","../src/core/components/autocomplete/constants.ts","../src/core/components/autocomplete/autocomplete.css.ts","../src/core/components/autocomplete/autocomplete.tsx"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {_isEnterToClickElement} from '../../helpers/element'\n\nexport interface AutocompleteOptionProps {\n children: React.ReactNode\n id: string\n onSelect: (v: string) => void\n selected: boolean\n value: string\n}\n\nexport function AutocompleteOption(props: AutocompleteOptionProps): React.JSX.Element {\n const {children, id, onSelect, selected, value} = props\n\n const handleClick = useCallback(() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }, [onSelect, value])\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n },\n [handleClick],\n )\n\n return (\n <li\n aria-selected={selected}\n data-ui=\"AutocompleteOption\"\n id={id}\n // oxlint-disable-next-line no-noninteractive-element-to-interactive-role, prefer-tag-over-role\n role=\"option\"\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {children}\n </li>\n )\n}\n","import {AutocompleteMsg, AutocompleteState} from './types'\n\n/**\n * @internal\n */\nexport function autocompleteReducer(\n state: AutocompleteState,\n msg: AutocompleteMsg,\n): AutocompleteState {\n if (msg.type === 'input/change') {\n return {...state, activeValue: null, focused: true, query: msg.query}\n }\n\n if (msg.type === 'input/focus') {\n return {...state, focused: true}\n }\n\n if (msg.type === 'root/blur') {\n return {...state, focused: false, query: null}\n }\n\n if (msg.type === 'root/clear') {\n return {...state, activeValue: null, query: null, value: null}\n }\n\n if (msg.type === 'root/escape') {\n return {...state, focused: false, query: null}\n }\n\n if (msg.type === 'root/open') {\n return {...state, query: state.query ?? msg.query}\n }\n\n if (msg.type === 'root/setActiveValue') {\n return {...state, activeValue: msg.value, listFocused: msg.listFocused || state.listFocused}\n }\n\n if (msg.type === 'root/setListFocused') {\n return {...state, listFocused: msg.listFocused}\n }\n\n if (msg.type === 'value/change') {\n return {...state, activeValue: msg.value, query: null, value: msg.value}\n }\n\n return state\n}\n","import {Placement} from '../../types/placement'\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [\n 'Control',\n 'Shift',\n 'Alt',\n 'Enter',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n 'Meta',\n 'Tab',\n 'CapsLock',\n]\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_POPOVER_PLACEMENT: Placement = 'bottom-start'\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS: Placement[] = ['bottom-start', 'top-start']\n","import {globalStyle, style} from '@vanilla-extract/css'\n\nexport const autocomplete = style({\n lineHeight: 0,\n})\n\nexport const autocompleteListBox = style({})\n\nglobalStyle(`${autocompleteListBox} > ul`, {\n listStyle: 'none',\n padding: 0,\n margin: 0,\n})\n","import {ChevronDownIcon} from '@sanity/icons/ChevronDown'\nimport {SpinnerIcon} from '@sanity/icons/Spinner'\nimport {clsx} from 'clsx/lite'\nimport {\n ChangeEvent,\n cloneElement,\n ElementType,\n FocusEvent,\n HTMLProps,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n Ref,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from 'react'\n\nimport {EMPTY_ARRAY, EMPTY_RECORD} from '../../constants'\nimport {_raf} from '../../helpers/animation'\nimport {_hasFocus, focusFirstDescendant} from '../../helpers/focus'\nimport {Box, BoxProps} from '../../primitives/box/box'\nimport {Button} from '../../primitives/button/button'\nimport {Card} from '../../primitives/card/card'\nimport {Popover, PopoverProps} from '../../primitives/popover/popover'\nimport {Stack} from '../../primitives/stack/stack'\nimport {Text} from '../../primitives/text/text'\nimport {TextInput} from '../../primitives/textInput/textInput'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {Radius} from '../../types/radius'\nimport {AutocompleteOption} from './autocompleteOption'\nimport {autocompleteReducer} from './autocompleteReducer'\nimport {\n AUTOCOMPLETE_LISTBOX_IGNORE_KEYS,\n AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS,\n AUTOCOMPLETE_POPOVER_PLACEMENT,\n} from './constants'\nimport {AutocompleteOpenButtonProps, BaseAutocompleteOption} from './types'\n\nimport {spinnerIcon} from '../../primitives/spinner/spinner.css'\nimport {autocomplete, autocompleteListBox} from './autocomplete.css'\n\n/**\n * @public\n */\nexport interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseAutocompleteOption> {\n border?: boolean\n customValidity?: string\n filterOption?: (query: string, option: Option) => boolean\n fontSize?: number | number[]\n // oxlint-disable-next-line no-redundant-type-constituents\n icon?: ElementType | ReactNode\n id: string\n /** @beta */\n listBox?: BoxProps\n loading?: boolean\n onChange?: (value: string) => void\n onQueryChange?: (query: string | null) => void\n onSelect?: (value: string) => void\n /** @beta */\n openButton?: boolean | AutocompleteOpenButtonProps\n /** @beta */\n openOnFocus?: boolean\n /** The options to render. */\n options?: Option[]\n padding?: number | number[]\n popover?: Omit<PopoverProps, 'content' | 'onMouseEnter' | 'onMouseLeave' | 'open'> &\n Omit<HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'ref' | 'width'>\n prefix?: ReactNode\n radius?: Radius | Radius[]\n /** @beta */\n relatedElements?: HTMLElement[]\n /** The callback function for rendering each option. */\n renderOption?: (option: Option) => React.JSX.Element\n /** @beta */\n renderPopover?: (\n props: {\n content: React.JSX.Element | null\n hidden: boolean\n inputElement: HTMLInputElement | null\n onMouseEnter: () => void\n onMouseLeave: () => void\n },\n ref: Ref<HTMLDivElement>,\n ) => ReactNode\n renderValue?: (value: string, option?: Option) => string\n suffix?: ReactNode\n /** The current value. */\n value?: string\n}\n\nconst DEFAULT_RENDER_VALUE = (value: string, option?: BaseAutocompleteOption) =>\n option ? option.value : value\n\nconst DEFAULT_FILTER_OPTION = (query: string, option: BaseAutocompleteOption) =>\n option.value.toLowerCase().indexOf(query.toLowerCase()) > -1\n\n/**\n * The Autocomplete component is typically used for search components.\n * It consists of a text input for writing a query, and properties for rendering suggestions.\n *\n * @public\n */\nexport function Autocomplete<Option extends BaseAutocompleteOption>(\n props: AutocompleteProps<Option> &\n Omit<\n HTMLProps<HTMLInputElement>,\n | 'aria-activedescendant'\n | 'aria-autocomplete'\n | 'aria-expanded'\n | 'aria-owns'\n | 'as'\n | 'autoCapitalize'\n | 'autoComplete'\n | 'autoCorrect'\n | 'id'\n | 'inputMode'\n | 'onChange'\n | 'onSelect'\n | 'popover'\n | 'prefix'\n | 'role'\n | 'spellCheck'\n | 'type'\n | 'value'\n >,\n) {\n const {\n border = true,\n customValidity,\n disabled,\n filterOption: filterOptionProp,\n fontSize = 2,\n icon,\n id,\n listBox = EMPTY_RECORD,\n loading,\n onBlur,\n onChange,\n onFocus,\n onQueryChange,\n onSelect,\n openButton,\n openOnFocus,\n options: optionsProp,\n padding: paddingProp = 3,\n popover = EMPTY_RECORD,\n prefix,\n radius = 2,\n readOnly,\n ref: forwardedRef,\n relatedElements,\n renderOption: renderOptionProp,\n renderPopover,\n renderValue = DEFAULT_RENDER_VALUE,\n suffix,\n value: valueProp,\n ...restProps\n } = props\n\n const [state, dispatch] = useReducer(autocompleteReducer, {\n activeValue: valueProp || null,\n focused: false,\n listFocused: false,\n query: null,\n value: valueProp || null,\n })\n\n const {activeValue, focused, listFocused, query, value} = state\n\n const defaultRenderOption = useCallback(\n ({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n ),\n [fontSize, paddingProp],\n )\n\n const renderOption =\n typeof renderOptionProp === 'function' ? renderOptionProp : defaultRenderOption\n\n const filterOption =\n typeof filterOptionProp === 'function' ? filterOptionProp : DEFAULT_FILTER_OPTION\n\n // Element refs\n const rootElementRef = useRef<HTMLDivElement | null>(null)\n const resultsPopoverElementRef = useRef<HTMLDivElement | null>(null)\n const inputElementRef = useRef<HTMLInputElement | null>(null)\n const listBoxElementRef = useRef<HTMLUListElement | null>(null)\n // Element refs that need to be accessed during render\n const [inputElement, setInputElement] = useState<HTMLInputElement | null>(null)\n\n // Value refs\n const listFocusedRef = useRef(false)\n const valueRef = useRef(value)\n const valuePropRef = useRef(valueProp)\n const popoverMouseWithinRef = useRef(false)\n\n // Forward inputElement state to inputElementRef\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n inputElementRef,\n () => inputElement,\n [inputElement],\n )\n // Forward inputElement to parent\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n forwardedRef,\n () => inputElement,\n [inputElement],\n )\n\n const listBoxId = `${id}-listbox`\n const options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY\n const padding = _getArrayProp(paddingProp)\n const currentOption = useMemo(\n () => (value !== null ? options.find((o) => o.value === value) : undefined),\n [options, value],\n )\n const filteredOptions = useMemo(\n () => options.filter((option) => (query ? filterOption(query, option) : true)),\n [filterOption, options, query],\n )\n const filteredOptionsLen = filteredOptions.length\n const activeItemId = activeValue ? `${id}-option-${activeValue}` : undefined\n const expanded = (query !== null && loading) || (focused && query !== null)\n\n const handleRootBlur = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n },\n [onBlur, onQueryChange, relatedElements],\n )\n\n const handleRootFocus = useCallback((event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }, [])\n\n const handleOptionSelect = useCallback(\n (v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n\n valueRef.current = v\n\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n },\n [onChange, onSelect, onQueryChange],\n )\n\n const handleRootKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n },\n [activeValue, filteredOptions, filteredOptionsLen, onQueryChange],\n )\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n },\n [onQueryChange],\n )\n\n const dispatchOpen = useCallback(() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }, [currentOption, renderValue, value])\n\n const handleInputFocus = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n },\n [focused, onFocus, openOnFocus, dispatchOpen],\n )\n\n const handlePopoverMouseEnter = useCallback(() => {\n popoverMouseWithinRef.current = true\n }, [])\n\n const handlePopoverMouseLeave = useCallback(() => {\n popoverMouseWithinRef.current = false\n }, [])\n\n const handleClearButtonClick = useCallback(() => {\n dispatch({type: 'root/clear'})\n valueRef.current = ''\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }, [onChange, onQueryChange])\n\n const handleClearButtonFocus = useCallback(() => {\n dispatch({type: 'input/focus'})\n }, [])\n\n // Change the value when `value` prop changes\n useEffect(() => {\n // If `valueProp` changed\n if (valueProp !== valuePropRef.current) {\n valuePropRef.current = valueProp\n\n if (valueProp !== undefined) {\n dispatch({type: 'value/change', value: valueProp})\n valueRef.current = valueProp\n }\n\n return\n }\n\n // If `valueProp` is not equal to `value`\n if (valueProp !== valueRef.current) {\n valueRef.current = valueProp || null\n\n dispatch({type: 'value/change', value: valueProp || null})\n }\n }, [valueProp])\n\n // Reset active item when closing\n useEffect(() => {\n if (!focused && valueRef.current) {\n dispatch({type: 'root/setActiveValue', value: valueRef.current})\n }\n }, [focused])\n\n // Focus the selected item\n useEffect(() => {\n const listElement = listBoxElementRef.current\n\n if (!listElement) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n\n if (activeOption) {\n const activeIndex = filteredOptions.indexOf(activeOption)\n // oxlint-disable-next-line no-unsafe-type-assertion\n const activeItemElement = listElement.childNodes[activeIndex] as HTMLLIElement | undefined\n\n if (activeItemElement) {\n if (_hasFocus(activeItemElement)) {\n // already focused\n return\n }\n\n focusFirstDescendant(activeItemElement)\n }\n }\n }, [activeValue, filteredOptions])\n\n const clearButton = useMemo(() => {\n if (!loading && !disabled && value) {\n return {\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }\n }\n\n return undefined\n }, [disabled, handleClearButtonFocus, loading, value])\n\n const openButtonBoxPadding = padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n })\n const openButtonPadding = padding.map((v) => Math.max(v - 1, 0))\n const openButtonProps: AutocompleteOpenButtonProps =\n typeof openButton === 'object' ? openButton : EMPTY_RECORD\n\n const handleOpenClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n },\n [openButtonProps, dispatchOpen],\n )\n\n const openButtonNode = useMemo(\n () =>\n !disabled && !readOnly && openButton ? (\n <Box aria-hidden={expanded} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={expanded}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined,\n [\n disabled,\n expanded,\n fontSize,\n handleOpenClick,\n openButton,\n openButtonBoxPadding,\n openButtonPadding,\n openButtonProps,\n readOnly,\n ],\n )\n\n const inputValue = useMemo(() => {\n if (query === null) {\n if (value !== null) {\n return renderValue(value, currentOption)\n }\n\n return ''\n }\n\n return query\n }, [currentOption, query, renderValue, value])\n\n const handleListBoxKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n },\n [listFocused],\n )\n\n const content = useMemo(() => {\n if (filteredOptions.length === 0) return null\n\n return (\n <Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>\n )\n }, [\n activeValue,\n currentOption,\n filteredOptions,\n handleOptionSelect,\n handleListBoxKeyDown,\n id,\n listBox,\n listBoxId,\n listFocused,\n loading,\n renderOption,\n ])\n\n const results = useMemo(() => {\n if (renderPopover) {\n return (\n <RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />\n )\n }\n\n if (filteredOptionsLen === 0) {\n return null\n }\n\n return (\n <Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />\n )\n }, [\n content,\n expanded,\n filteredOptionsLen,\n handlePopoverMouseEnter,\n handlePopoverMouseLeave,\n inputElement,\n popover,\n radius,\n renderPopover,\n ])\n\n return (\n // The handlers only observe focus and key events bubbling from the input and\n // list box, which carry the roles; the wrapper itself is not interactive.\n // oxlint-disable-next-line no-static-element-interactions\n <div\n className={autocomplete}\n data-ui=\"Autocomplete\"\n onBlur={handleRootBlur}\n onFocus={handleRootFocus}\n onKeyDown={handleRootKeyDown}\n ref={rootElementRef}\n >\n <TextInput\n {...restProps}\n aria-activedescendant={activeItemId}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />\n {results}\n </div>\n )\n}\n\nfunction RenderPopover({\n renderPopover,\n content,\n hidden,\n inputElement,\n onMouseEnter,\n onMouseLeave,\n resultsPopoverElementRef,\n}: {\n renderPopover: Exclude<AutocompleteProps['renderPopover'], undefined>\n resultsPopoverElementRef: Parameters<Exclude<AutocompleteProps['renderPopover'], undefined>>[1]\n} & Parameters<Exclude<AutocompleteProps['renderPopover'], undefined>>[0]) {\n return renderPopover(\n {\n content,\n hidden,\n inputElement,\n onMouseEnter,\n onMouseLeave,\n },\n resultsPopoverElementRef,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAgB,mBAAmB,OAAmD;gBAC9E,EAAC,UAAU,IAAI,UAAU,UAAU,UAAS,OAElBA;CAI5B,AAAA,EAAA,OAAA,YAAA,EAAA,OAAS,SAJmB,WAAM;EAGpC,iBAAiB;GACf,SAAS,KAAK;EAChB,GAAG,CAAC;CACN,GAFI,EAAA,KAAA,UAAS,EAAA,KAAA;CAJb,IAAM,cAAcC,IASlBC;CAEI,AAAA,EAAA,OAAA,2BAFJ,MAAC,UAA8C;EAC7C,AAAI,MAAM,QAAQ,WAAW,CAAC,uBAAuB,MAAM,aAAa,KACtE,YAAY;CAEhB,GAFI,EAAA,KAAA;CAHN,IAAM,gBAAgBC,IAUpBC;CADF,OAUK,EAAA,OAAA,YAAA,EAAA,OAHQ,eAAA,EAAA,OACE,iBAAA,EAAA,OAJP,MAAA,EAAA,OAFW,YADjB,KAAA,oBAAC,MAAD;EACE,iBAAe;EACf,WAAQ;EACJ;EAEJ,MAAK;EACL,SAAS;EACT,WAAW;EAEV;CACC,CAAA,GADD,EAAA,KAAA,UAHQ,EAAA,KAAA,aACE,EAAA,KAAA,eAJP,EAAA,KAAA,IAFW,EAAA,KAAA,oCADjBA;AAYJ;;;;ACxCA,SAAgB,oBACd,OACA,KACmB;CAqCnB,OApCI,IAAI,SAAS,iBACR;EAAC,GAAG;EAAO,aAAa;EAAM,SAAS;EAAM,OAAO,IAAI;CAAK,IAGlE,IAAI,SAAS,gBACR;EAAC,GAAG;EAAO,SAAS;CAAI,IAG7B,IAAI,SAAS,cACR;EAAC,GAAG;EAAO,SAAS;EAAO,OAAO;CAAI,IAG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AAA,IAcG,EAAA,OAAA,YAzBI,EAAA,OAAA,WAgBF,EAAA,OAAA,SACD,EAAA,OAAA,QACA,EAAA,OAAA,QACE,EAAA,OAAA,UAvBN,EAAA,OAAA,WAcOF,EAAAA,OAAAA,KAcHE,EAAAA,OAAAA;CArCZC,IAAAA;CAJF,OAOY,EAAA,SAAA,kBAAA,EAAA,SACC,mBAAA,EAAA,SACE,qBAAA,EAAA,SAmCV,WAAA,EAAA,SAhCDF,OARF,MAAA,qBAAC,OAAD;EACE,WAAW;EACX,WAAQ;EACR,QAAQ;EACR,SAAS;EACT,WAAW;EACX,KAAK;EANP,UAAA,CAQEA,KAgCC,OACE;KAtCK,EAAA,OAAA,gBACC,EAAA,OAAA,iBACE,EAAA,OAAA,mBAmCV,EAAA,OAAA,SAhCDA,EAAAA,OAAAA,mCARFE;AA2CJ;AA9NwC,SAAA,OAAC,KAAA;CAAM,OAAA,KAAK,IAAIC,MAAI,GAAG,CAAC;;AAPrB,SAAA,MAAC,KAAM;CAK9C,OAJIA,QAAM,IAAU,IAChBA,QAAM,KACNA,QAAM,IAAU,IAEbA,MAAI;AACb;AAiOF,SAAS,cAAc,EACrB,eACA,SACA,QACA,cACA,cACA,cACA,4BAIyE;CACzE,OAAO,cACL;EACE;EACA;EACA;EACA;EACA;CACF,GACA,wBACF;AACF"}
|
|
1
|
+
{"version":3,"file":"autocomplete.js","names":["() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }","useCallback(() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }, [onSelect, value])","(event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n }","useCallback(\n (event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n },\n [handleClick],\n )","<li\n aria-selected={selected}\n data-ui=\"AutocompleteOption\"\n id={id}\n // oxlint-disable-next-line no-noninteractive-element-to-interactive-role, prefer-tag-over-role\n role=\"option\"\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {children}\n </li>","_c","border = true","fontSize = 2","listBox = EMPTY_RECORD","paddingProp = 3","popover = EMPTY_RECORD","radius = 2","renderValue = DEFAULT_RENDER_VALUE","{\n activeValue: valueProp || null,\n focused: false,\n listFocused: false,\n query: null,\n value: valueProp || null,\n }","valueProp || null","({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n )","{value}: BaseAutocompleteOption","value","useCallback(\n ({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n ),\n [fontSize, paddingProp],\n )","() => inputElement","[inputElement]","value !== null ? options.find((o) => o.value === value) : undefined","useMemo(\n () => (value !== null ? options.find((o) => o.value === value) : undefined),\n [options, value],\n )","options.filter((option) => (query ? filterOption(query, option) : true))","(option) => (query ? filterOption(query, option) : true)","useMemo(\n () => options.filter((option) => (query ? filterOption(query, option) : true)),\n [filterOption, options, query],\n )","(event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n }","useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n },\n [onBlur, onQueryChange, relatedElements],\n )","(event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }","event","listFocused","useCallback((event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }, [])","(v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n }","useCallback(\n (v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n },\n [onChange, onSelect, onQueryChange],\n )","(event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n }","o","activeOption","activeIndex","nextActiveOption","useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n },\n [activeValue, filteredOptions, filteredOptionsLen, onQueryChange],\n )","(event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n }","useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n },\n [onQueryChange],\n )","() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }","useCallback(() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }, [currentOption, renderValue, value])","(event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n }","useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n },\n [focused, onFocus, openOnFocus, dispatchOpen],\n )","() => {\n popoverMouseWithinRef.current = true\n }","useCallback(() => {\n popoverMouseWithinRef.current = true\n }, [])","() => {\n popoverMouseWithinRef.current = false\n }","useCallback(() => {\n popoverMouseWithinRef.current = false\n }, [])","() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }","useCallback(() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }, [onChange, onQueryChange])","() => {\n dispatch({type: 'input/focus'})\n }","useCallback(() => {\n dispatch({type: 'input/focus'})\n }, [])","() => {\n const listElement = listBoxElementRef.current\n\n if (!listFocused || !listElement) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n\n if (activeOption) {\n const activeIndex = filteredOptions.indexOf(activeOption)\n // oxlint-disable-next-line no-unsafe-type-assertion\n const activeItemElement = listElement.childNodes[activeIndex] as HTMLLIElement | undefined\n\n if (activeItemElement) {\n if (_hasFocus(activeItemElement)) {\n // already focused\n return\n }\n\n focusFirstDescendant(activeItemElement)\n }\n }\n }","() => {\n if (expanded) focusActiveOption()\n }","[activeValue, expanded, filteredOptions]","useMemo(() => {\n if (!loading && !disabled && value) {\n return {\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }\n }\n\n return undefined\n }, [disabled, handleClearButtonFocus, loading, value])","{\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }","(v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n }","(v) => Math.max(v - 1, 0)","(event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n }","openButtonProps.onClick","useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n },\n [openButtonProps, dispatchOpen],\n )","!disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined","useMemo(\n () =>\n !disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined,\n [\n disabled,\n fontSize,\n handleOpenClick,\n openButton,\n openButtonBoxPadding,\n openButtonPadding,\n openButtonProps,\n querying,\n readOnly,\n ],\n )","useMemo(() => {\n if (query === null) {\n if (value !== null) {\n return renderValue(value, currentOption)\n }\n\n return ''\n }\n\n return query\n }, [currentOption, query, renderValue, value])","renderValue(value, currentOption)","(event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n }","useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n },\n [listFocused],\n )","useMemo(() => {\n if (filteredOptions.length === 0) return null\n\n return (\n <Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>\n )\n }, [\n activeValue,\n currentOption,\n filteredOptions,\n handleOptionSelect,\n handleListBoxKeyDown,\n id,\n listBox,\n listBoxId,\n listFocused,\n loading,\n renderOption,\n ])","clsx(autocompleteListBox, listBox?.className)","listBox?.className","filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })","(option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n }","option","<Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>","<Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>","useMemo(() => {\n if (renderPopover) {\n return (\n <RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />\n )\n }\n\n if (filteredOptionsLen === 0) {\n return null\n }\n\n return (\n <Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />\n )\n }, [\n content,\n expanded,\n filteredOptionsLen,\n handlePopoverMouseEnter,\n handlePopoverMouseLeave,\n inputElement,\n popover,\n radius,\n renderPopover,\n ])","<RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />","!expanded","<Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />","loading && <SpinnerIcon className={spinnerIcon} />","<TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />","expanded ? activeItemId : undefined","suffix || openButtonNode","<div\n className={autocomplete}\n data-ui=\"Autocomplete\"\n onBlur={handleRootBlur}\n onFocus={handleRootFocus}\n onKeyDown={handleRootKeyDown}\n ref={rootElementRef}\n >\n <TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />\n {results}\n </div>","v","_c","defaultRenderOption","\"onFocus\""],"sources":["../src/core/components/autocomplete/autocompleteOption.tsx","../src/core/components/autocomplete/autocompleteReducer.ts","../src/core/components/autocomplete/constants.ts","../src/core/components/autocomplete/autocomplete.css.ts","../src/core/components/autocomplete/autocomplete.tsx"],"sourcesContent":["import {useCallback} from 'react'\n\nimport {_isEnterToClickElement} from '../../helpers/element'\n\nexport interface AutocompleteOptionProps {\n children: React.ReactNode\n id: string\n onSelect: (v: string) => void\n selected: boolean\n value: string\n}\n\nexport function AutocompleteOption(props: AutocompleteOptionProps): React.JSX.Element {\n const {children, id, onSelect, selected, value} = props\n\n const handleClick = useCallback(() => {\n // Calling the `onSelect` in a timeout is a fix to\n // allow the `click` event to propagate in some cases\n setTimeout(() => {\n onSelect(value)\n }, 0)\n }, [onSelect, value])\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLLIElement>) => {\n if (event.key === 'Enter' && !_isEnterToClickElement(event.currentTarget)) {\n handleClick()\n }\n },\n [handleClick],\n )\n\n return (\n <li\n aria-selected={selected}\n data-ui=\"AutocompleteOption\"\n id={id}\n // oxlint-disable-next-line no-noninteractive-element-to-interactive-role, prefer-tag-over-role\n role=\"option\"\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {children}\n </li>\n )\n}\n","import {AutocompleteMsg, AutocompleteState} from './types'\n\n/**\n * @internal\n */\nexport function autocompleteReducer(\n state: AutocompleteState,\n msg: AutocompleteMsg,\n): AutocompleteState {\n if (msg.type === 'input/change') {\n return {...state, activeValue: null, focused: true, query: msg.query}\n }\n\n if (msg.type === 'input/focus') {\n return {...state, focused: true}\n }\n\n // Closing puts the active option back on the value. It also ends keyboard navigation in the list,\n // which an arrow key can start before the list shows, with no focus event to end it.\n if (msg.type === 'root/blur' || msg.type === 'root/escape') {\n return {\n ...state,\n activeValue: state.value || state.activeValue,\n focused: false,\n listFocused: false,\n query: null,\n }\n }\n\n if (msg.type === 'root/clear') {\n return {...state, activeValue: null, query: null, value: null}\n }\n\n if (msg.type === 'root/open') {\n return {...state, query: state.query ?? msg.query}\n }\n\n if (msg.type === 'root/setActiveValue') {\n return {...state, activeValue: msg.value, listFocused: msg.listFocused || state.listFocused}\n }\n\n if (msg.type === 'root/setListFocused') {\n return {...state, listFocused: msg.listFocused}\n }\n\n if (msg.type === 'value/change') {\n return {...state, activeValue: msg.value, query: null, value: msg.value}\n }\n\n return state\n}\n","import {Placement} from '../../types/placement'\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_LISTBOX_IGNORE_KEYS = [\n 'Control',\n 'Shift',\n 'Alt',\n 'Enter',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n 'Meta',\n 'Tab',\n 'CapsLock',\n]\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_POPOVER_PLACEMENT: Placement = 'bottom-start'\n\n/**\n * @internal\n */\nexport const AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS: Placement[] = ['bottom-start', 'top-start']\n","import {globalStyle, style} from '@vanilla-extract/css'\n\nexport const autocomplete = style({\n lineHeight: 0,\n})\n\nexport const autocompleteListBox = style({})\n\nglobalStyle(`${autocompleteListBox} > ul`, {\n listStyle: 'none',\n padding: 0,\n margin: 0,\n})\n","import {ChevronDownIcon} from '@sanity/icons/ChevronDown'\nimport {SpinnerIcon} from '@sanity/icons/Spinner'\nimport {clsx} from 'clsx/lite'\nimport {\n ChangeEvent,\n cloneElement,\n ElementType,\n FocusEvent,\n HTMLProps,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n Ref,\n useCallback,\n useDeferredValue,\n useEffect,\n useImperativeHandle,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once https://github.com/facebook/react/issues/34818\n// is fixed in the lowest React version we support (consumers may wrap `Autocomplete` in `memo`)\nimport {useEffectEvent} from 'use-effect-event'\n\nimport {EMPTY_ARRAY, EMPTY_RECORD} from '../../constants'\nimport {_raf} from '../../helpers/animation'\nimport {_hasFocus, focusFirstDescendant} from '../../helpers/focus'\nimport {Box, BoxProps} from '../../primitives/box/box'\nimport {Button} from '../../primitives/button/button'\nimport {Card} from '../../primitives/card/card'\nimport {Popover, PopoverProps} from '../../primitives/popover/popover'\nimport {Stack} from '../../primitives/stack/stack'\nimport {Text} from '../../primitives/text/text'\nimport {TextInput} from '../../primitives/textInput/textInput'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {Radius} from '../../types/radius'\nimport {AutocompleteOption} from './autocompleteOption'\nimport {autocompleteReducer} from './autocompleteReducer'\nimport {\n AUTOCOMPLETE_LISTBOX_IGNORE_KEYS,\n AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS,\n AUTOCOMPLETE_POPOVER_PLACEMENT,\n} from './constants'\nimport {AutocompleteOpenButtonProps, BaseAutocompleteOption} from './types'\n\nimport {spinnerIcon} from '../../primitives/spinner/spinner.css'\nimport {autocomplete, autocompleteListBox} from './autocomplete.css'\n\n/**\n * @public\n */\nexport interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseAutocompleteOption> {\n border?: boolean\n customValidity?: string\n filterOption?: (query: string, option: Option) => boolean\n fontSize?: number | number[]\n // oxlint-disable-next-line no-redundant-type-constituents\n icon?: ElementType | ReactNode\n id: string\n /** @beta */\n listBox?: BoxProps\n loading?: boolean\n onChange?: (value: string) => void\n onQueryChange?: (query: string | null) => void\n onSelect?: (value: string) => void\n /** @beta */\n openButton?: boolean | AutocompleteOpenButtonProps\n /** @beta */\n openOnFocus?: boolean\n /** The options to render. */\n options?: Option[]\n padding?: number | number[]\n popover?: Omit<PopoverProps, 'content' | 'onMouseEnter' | 'onMouseLeave' | 'open'> &\n Omit<HTMLProps<HTMLDivElement>, 'as' | 'children' | 'content' | 'ref' | 'width'>\n prefix?: ReactNode\n radius?: Radius | Radius[]\n /** @beta */\n relatedElements?: HTMLElement[]\n /** The callback function for rendering each option. */\n renderOption?: (option: Option) => React.JSX.Element\n /** @beta */\n renderPopover?: (\n props: {\n content: React.JSX.Element | null\n hidden: boolean\n inputElement: HTMLInputElement | null\n onMouseEnter: () => void\n onMouseLeave: () => void\n },\n ref: Ref<HTMLDivElement>,\n ) => ReactNode\n renderValue?: (value: string, option?: Option) => string\n suffix?: ReactNode\n /**\n * The current value. A changed `value` replaces the value shown and drops a pending query,\n * unless it equals the value shown (a parent echoing `onChange`). A selection or clear shows\n * until `value` changes, and changing `value` to `undefined` keeps the value shown.\n */\n value?: string\n}\n\nconst DEFAULT_RENDER_VALUE = (value: string, option?: BaseAutocompleteOption) =>\n option ? option.value : value\n\nconst DEFAULT_FILTER_OPTION = (query: string, option: BaseAutocompleteOption) =>\n option.value.toLowerCase().indexOf(query.toLowerCase()) > -1\n\n/**\n * The Autocomplete component is typically used for search components.\n * It consists of a text input for writing a query, and properties for rendering suggestions.\n *\n * @public\n */\nexport function Autocomplete<Option extends BaseAutocompleteOption>(\n props: AutocompleteProps<Option> &\n Omit<\n HTMLProps<HTMLInputElement>,\n | 'aria-activedescendant'\n | 'aria-autocomplete'\n | 'aria-expanded'\n | 'aria-owns'\n | 'as'\n | 'autoCapitalize'\n | 'autoComplete'\n | 'autoCorrect'\n | 'id'\n | 'inputMode'\n | 'onChange'\n | 'onSelect'\n | 'popover'\n | 'prefix'\n | 'role'\n | 'spellCheck'\n | 'type'\n | 'value'\n >,\n) {\n const {\n border = true,\n customValidity,\n disabled,\n filterOption: filterOptionProp,\n fontSize = 2,\n icon,\n id,\n listBox = EMPTY_RECORD,\n loading,\n onBlur,\n onChange,\n onFocus,\n onQueryChange,\n onSelect,\n openButton,\n openOnFocus,\n options: optionsProp,\n padding: paddingProp = 3,\n popover = EMPTY_RECORD,\n prefix,\n radius = 2,\n readOnly,\n ref: forwardedRef,\n relatedElements,\n renderOption: renderOptionProp,\n renderPopover,\n renderValue = DEFAULT_RENDER_VALUE,\n suffix,\n value: valueProp,\n ...restProps\n } = props\n\n const [state, dispatch] = useReducer(autocompleteReducer, {\n activeValue: valueProp || null,\n focused: false,\n listFocused: false,\n query: null,\n value: valueProp || null,\n })\n\n const {activeValue, focused, listFocused, query, value} = state\n\n // https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes\n const [prevValueProp, setPrevValueProp] = useState(valueProp)\n\n if (valueProp !== prevValueProp) {\n setPrevValueProp(valueProp)\n // A clear stores `null` and reports `''`\n if (valueProp !== undefined && (valueProp || null) !== value) {\n dispatch({type: 'value/change', value: valueProp})\n }\n }\n\n const defaultRenderOption = useCallback(\n ({value}: BaseAutocompleteOption) => (\n <Card data-as=\"button\" padding={paddingProp} radius={2} tone=\"inherit\">\n <Text size={fontSize} textOverflow=\"ellipsis\">\n {value}\n </Text>\n </Card>\n ),\n [fontSize, paddingProp],\n )\n\n const renderOption =\n typeof renderOptionProp === 'function' ? renderOptionProp : defaultRenderOption\n\n const filterOption =\n typeof filterOptionProp === 'function' ? filterOptionProp : DEFAULT_FILTER_OPTION\n\n // Element refs\n const rootElementRef = useRef<HTMLDivElement | null>(null)\n const resultsPopoverElementRef = useRef<HTMLDivElement | null>(null)\n const inputElementRef = useRef<HTMLInputElement | null>(null)\n const listBoxElementRef = useRef<HTMLUListElement | null>(null)\n // Element refs that need to be accessed during render\n const [inputElement, setInputElement] = useState<HTMLInputElement | null>(null)\n\n // Value refs\n const listFocusedRef = useRef(false)\n const popoverMouseWithinRef = useRef(false)\n\n // Forward inputElement state to inputElementRef\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n inputElementRef,\n () => inputElement,\n [inputElement],\n )\n // Forward inputElement to parent\n useImperativeHandle<HTMLInputElement | null, HTMLInputElement | null>(\n forwardedRef,\n () => inputElement,\n [inputElement],\n )\n\n const listBoxId = `${id}-listbox`\n const options = Array.isArray(optionsProp) ? optionsProp : EMPTY_ARRAY\n const padding = _getArrayProp(paddingProp)\n const currentOption = useMemo(\n () => (value !== null ? options.find((o) => o.value === value) : undefined),\n [options, value],\n )\n const filteredOptions = useMemo(\n () => options.filter((option) => (query ? filterOption(query, option) : true)),\n [filterOption, options, query],\n )\n const filteredOptionsLen = filteredOptions.length\n const activeItemId = activeValue ? `${id}-option-${activeValue}` : undefined\n const querying = (query !== null && loading) || (focused && query !== null)\n // The list opens in a deferred render, so the keystroke, focus or click that opens it paints\n // first, and closes in the same render as the state that closes it. Dispatching the open in a\n // transition instead would drop a render-phase `value` sync while the transition is pending.\n const deferredQuerying = useDeferredValue(querying)\n const expanded = querying && deferredQuerying\n\n const handleRootBlur = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n setTimeout(() => {\n // NOTE: This is a workaround for a bug that may happen in Chrome (clicking the scrollbar\n // closes the results in certain situations):\n // - Do not handle blur if the mouse is within the popover\n if (popoverMouseWithinRef.current) {\n return\n }\n\n const elements: HTMLElement[] = (relatedElements || []).concat(\n rootElementRef.current ? [rootElementRef.current] : [],\n resultsPopoverElementRef.current ? [resultsPopoverElementRef.current] : [],\n )\n\n let focusInside = false\n\n if (document.activeElement) {\n for (const e of elements) {\n if (e === document.activeElement || e.contains(document.activeElement)) {\n focusInside = true\n break\n }\n }\n }\n\n // oxlint-disable-next-line no-unnecessary-boolean-literal-compare\n if (focusInside === false) {\n dispatch({type: 'root/blur'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n if (onBlur) onBlur(event)\n }\n }, 0)\n },\n [onBlur, onQueryChange, relatedElements],\n )\n\n const handleRootFocus = useCallback((event: FocusEvent<HTMLDivElement>) => {\n const listBoxElement = listBoxElementRef.current\n const focusedElement = event.target instanceof HTMLElement ? event.target : null\n const listFocused = listBoxElement?.contains(focusedElement) || false\n\n if (listFocused !== listFocusedRef.current) {\n listFocusedRef.current = listFocused\n\n dispatch({type: 'root/setListFocused', listFocused})\n }\n }, [])\n\n const handleOptionSelect = useCallback(\n (v: string) => {\n dispatch({type: 'value/change', value: v})\n\n popoverMouseWithinRef.current = false\n\n if (onSelect) onSelect(v)\n if (onChange) onChange(v)\n if (onQueryChange) onQueryChange(null)\n\n inputElementRef.current?.focus()\n },\n [onChange, onSelect, onQueryChange],\n )\n\n const handleRootKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption = filteredOptions[(activeIndex + 1) % filteredOptionsLen]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault()\n\n if (!filteredOptionsLen) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n const activeIndex = activeOption ? filteredOptions.indexOf(activeOption) : -1\n const nextActiveOption =\n filteredOptions[\n activeIndex === -1\n ? filteredOptionsLen - 1\n : (filteredOptionsLen + activeIndex - 1) % filteredOptionsLen\n ]\n\n if (nextActiveOption) {\n dispatch({type: 'root/setActiveValue', value: nextActiveOption.value, listFocused: true})\n }\n\n return\n }\n\n if (event.key === 'Escape') {\n dispatch({type: 'root/escape'})\n popoverMouseWithinRef.current = false\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n\n return\n }\n\n // oxlint-disable-next-line no-unsafe-type-assertion\n const target = event.target as Node\n const listEl = listBoxElementRef.current\n\n if (\n (listEl === target || listEl?.contains(target)) &&\n !AUTOCOMPLETE_LISTBOX_IGNORE_KEYS.includes(event.key)\n ) {\n inputElementRef.current?.focus()\n\n return\n }\n },\n [activeValue, filteredOptions, filteredOptionsLen, onQueryChange],\n )\n\n const handleInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const nextQuery = event.currentTarget.value\n\n dispatch({type: 'input/change', query: nextQuery})\n\n if (onQueryChange) onQueryChange(nextQuery)\n },\n [onQueryChange],\n )\n\n const dispatchOpen = useCallback(() => {\n dispatch({\n type: 'root/open',\n query: value ? renderValue(value, currentOption) : '',\n })\n }, [currentOption, renderValue, value])\n\n const handleInputFocus = useCallback(\n (event: FocusEvent<HTMLInputElement>) => {\n if (!focused) {\n dispatch({type: 'input/focus'})\n\n if (onFocus) onFocus(event)\n if (openOnFocus) dispatchOpen()\n }\n },\n [focused, onFocus, openOnFocus, dispatchOpen],\n )\n\n const handlePopoverMouseEnter = useCallback(() => {\n popoverMouseWithinRef.current = true\n }, [])\n\n const handlePopoverMouseLeave = useCallback(() => {\n popoverMouseWithinRef.current = false\n }, [])\n\n const handleClearButtonClick = useCallback(() => {\n dispatch({type: 'root/clear'})\n if (onChange) onChange('')\n if (onQueryChange) onQueryChange(null)\n inputElementRef.current?.focus()\n }, [onChange, onQueryChange])\n\n const handleClearButtonFocus = useCallback(() => {\n dispatch({type: 'input/focus'})\n }, [])\n\n // Focus the active option, but only while the keyboard is in the list: opening the list leaves\n // focus in the input even when the option is focusable (a link or button). An effect event, so\n // focus entering the list on a click does not re-run it and scroll the clicked option away.\n const focusActiveOption = useEffectEvent(() => {\n const listElement = listBoxElementRef.current\n\n if (!listFocused || !listElement) return\n\n const activeOption = filteredOptions.find((o) => o.value === activeValue)\n\n if (activeOption) {\n const activeIndex = filteredOptions.indexOf(activeOption)\n // oxlint-disable-next-line no-unsafe-type-assertion\n const activeItemElement = listElement.childNodes[activeIndex] as HTMLLIElement | undefined\n\n if (activeItemElement) {\n if (_hasFocus(activeItemElement)) {\n // already focused\n return\n }\n\n focusFirstDescendant(activeItemElement)\n }\n }\n })\n\n // Also runs when the deferred render shows the list, for an arrow key pressed before it did\n useEffect(() => {\n if (expanded) focusActiveOption()\n }, [activeValue, expanded, filteredOptions])\n\n const clearButton = useMemo(() => {\n if (!loading && !disabled && value) {\n return {\n 'aria-label': 'Clear',\n 'onFocus': handleClearButtonFocus,\n }\n }\n\n return undefined\n }, [disabled, handleClearButtonFocus, loading, value])\n\n const openButtonBoxPadding = padding.map((v) => {\n if (v === 0) return 0\n if (v === 1) return 1\n if (v === 2) return 1\n\n return v - 2\n })\n const openButtonPadding = padding.map((v) => Math.max(v - 1, 0))\n const openButtonProps: AutocompleteOpenButtonProps =\n typeof openButton === 'object' ? openButton : EMPTY_RECORD\n\n const handleOpenClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n dispatchOpen()\n\n if (openButtonProps.onClick) openButtonProps.onClick(event)\n\n _raf(() => inputElementRef.current?.focus())\n },\n [openButtonProps, dispatchOpen],\n )\n\n const openButtonNode = useMemo(\n () =>\n !disabled && !readOnly && openButton ? (\n <Box aria-hidden={querying} padding={openButtonBoxPadding}>\n <Button\n aria-label=\"Open\"\n disabled={querying}\n fontSize={fontSize}\n icon={ChevronDownIcon}\n mode=\"bleed\"\n padding={openButtonPadding}\n {...openButtonProps}\n onClick={handleOpenClick}\n />\n </Box>\n ) : undefined,\n [\n disabled,\n fontSize,\n handleOpenClick,\n openButton,\n openButtonBoxPadding,\n openButtonPadding,\n openButtonProps,\n querying,\n readOnly,\n ],\n )\n\n const inputValue = useMemo(() => {\n if (query === null) {\n if (value !== null) {\n return renderValue(value, currentOption)\n }\n\n return ''\n }\n\n return query\n }, [currentOption, query, renderValue, value])\n\n const handleListBoxKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n // If the focus is currently in the list, move focus to the input element\n if (event.key === 'Tab') {\n if (listFocused) inputElementRef.current?.focus()\n }\n },\n [listFocused],\n )\n\n const content = useMemo(() => {\n if (filteredOptions.length === 0) return null\n\n return (\n <Box\n data-ui=\"AutoComplete__results\"\n onKeyDown={handleListBoxKeyDown}\n padding={1}\n {...listBox}\n className={clsx(autocompleteListBox, listBox?.className)}\n tabIndex={-1}\n >\n <Stack\n as=\"ul\"\n aria-multiselectable={false}\n data-ui=\"AutoComplete__resultsList\"\n id={listBoxId}\n ref={listBoxElementRef}\n // oxlint-disable-next-line prefer-tag-over-role\n role=\"listbox\"\n gap={1}\n >\n {filteredOptions.map((option) => {\n const active =\n activeValue !== null ? option.value === activeValue : currentOption === option\n\n return (\n <AutocompleteOption\n key={option.value}\n id={`${id}-option-${option.value}`}\n onSelect={handleOptionSelect}\n selected={active}\n value={option.value}\n >\n {cloneElement(renderOption(option), {\n disabled: loading,\n selected: active,\n tabIndex: listFocused && active ? 0 : -1,\n })}\n </AutocompleteOption>\n )\n })}\n </Stack>\n </Box>\n )\n }, [\n activeValue,\n currentOption,\n filteredOptions,\n handleOptionSelect,\n handleListBoxKeyDown,\n id,\n listBox,\n listBoxId,\n listFocused,\n loading,\n renderOption,\n ])\n\n const results = useMemo(() => {\n if (renderPopover) {\n return (\n <RenderPopover\n content={content}\n hidden={!expanded}\n inputElement={inputElement}\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n resultsPopoverElementRef={resultsPopoverElementRef}\n renderPopover={renderPopover}\n />\n )\n }\n\n if (filteredOptionsLen === 0) {\n return null\n }\n\n return (\n <Popover\n arrow={false}\n constrainSize\n content={content}\n fallbackPlacements={AUTOCOMPLETE_POPOVER_FALLBACK_PLACEMENTS}\n matchReferenceWidth\n onMouseEnter={handlePopoverMouseEnter}\n onMouseLeave={handlePopoverMouseLeave}\n open={expanded}\n overflow=\"auto\"\n placement={AUTOCOMPLETE_POPOVER_PLACEMENT}\n portal\n radius={radius}\n ref={resultsPopoverElementRef}\n referenceElement={inputElement}\n {...popover}\n />\n )\n }, [\n content,\n expanded,\n filteredOptionsLen,\n handlePopoverMouseEnter,\n handlePopoverMouseLeave,\n inputElement,\n popover,\n radius,\n renderPopover,\n ])\n\n return (\n // The handlers only observe focus and key events bubbling from the input and\n // list box, which carry the roles; the wrapper itself is not interactive.\n // oxlint-disable-next-line no-static-element-interactions\n <div\n className={autocomplete}\n data-ui=\"Autocomplete\"\n onBlur={handleRootBlur}\n onFocus={handleRootFocus}\n onKeyDown={handleRootKeyDown}\n ref={rootElementRef}\n >\n <TextInput\n {...restProps}\n aria-activedescendant={expanded ? activeItemId : undefined}\n aria-autocomplete=\"list\"\n aria-expanded={expanded}\n aria-owns={listBoxId}\n autoCapitalize=\"off\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n border={border}\n clearButton={clearButton}\n customValidity={customValidity}\n disabled={disabled}\n fontSize={fontSize}\n icon={icon}\n iconRight={loading && <SpinnerIcon className={spinnerIcon} />}\n id={id}\n inputMode=\"search\"\n onChange={handleInputChange}\n onClear={handleClearButtonClick}\n onFocus={handleInputFocus}\n padding={padding}\n prefix={prefix}\n radius={radius}\n readOnly={readOnly}\n ref={setInputElement}\n // oxlint-disable-next-line prefer-tag-over-role, role-has-required-aria-props\n role=\"combobox\"\n spellCheck={false}\n suffix={suffix || openButtonNode}\n value={inputValue}\n />\n {results}\n </div>\n )\n}\n\nfunction RenderPopover({\n renderPopover,\n content,\n hidden,\n inputElement,\n onMouseEnter,\n onMouseLeave,\n resultsPopoverElementRef,\n}: {\n renderPopover: Exclude<AutocompleteProps['renderPopover'], undefined>\n resultsPopoverElementRef: Parameters<Exclude<AutocompleteProps['renderPopover'], undefined>>[1]\n} & Parameters<Exclude<AutocompleteProps['renderPopover'], undefined>>[0]) {\n return renderPopover(\n {\n content,\n hidden,\n inputElement,\n onMouseEnter,\n onMouseLeave,\n },\n resultsPopoverElementRef,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAgB,mBAAmB,OAAmD;gBAC9E,EAAC,UAAU,IAAI,UAAU,UAAU,UAAS,OAElBA;CAI5B,AAAA,EAAA,OAAA,YAAA,EAAA,OAAS,SAJmB,WAAM;EAGpC,iBAAiB;GACf,SAAS,KAAK;EAChB,GAAG,CAAC;CACN,GAFI,EAAA,KAAA,UAAS,EAAA,KAAA;CAJb,IAAM,cAAcC,IASlBC;CAEI,AAAA,EAAA,OAAA,2BAFJ,MAAC,UAA8C;EAC7C,AAAI,MAAM,QAAQ,WAAW,CAAC,uBAAuB,MAAM,aAAa,KACtE,YAAY;CAEhB,GAFI,EAAA,KAAA;CAHN,IAAM,gBAAgBC,IAUpBC;CADF,OAUK,EAAA,OAAA,YAAA,EAAA,OAHQ,eAAA,EAAA,OACE,iBAAA,EAAA,OAJP,MAAA,EAAA,OAFW,YADjB,KAAA,oBAAC,MAAD;EACE,iBAAe;EACf,WAAQ;EACJ;EAEJ,MAAK;EACL,SAAS;EACT,WAAW;EAEV;CACC,CAAA,GADD,EAAA,KAAA,UAHQ,EAAA,KAAA,aACE,EAAA,KAAA,eAJP,EAAA,KAAA,IAFW,EAAA,KAAA,oCADjBA;AAYJ;;;;ACxCA,SAAgB,oBACd,OACA,KACmB;CAyCnB,OAxCI,IAAI,SAAS,iBACR;EAAC,GAAG;EAAO,aAAa;EAAM,SAAS;EAAM,OAAO,IAAI;CAAK,IAGlE,IAAI,SAAS,gBACR;EAAC,GAAG;EAAO,SAAS;CAAI,IAK7B,IAAI,SAAS,eAAe,IAAI,SAAS,gBACpC;EACL,GAAG;EACH,aAAa,MAAM,SAAS,MAAM;EAClC,SAAS;EACT,aAAa;EACb,OAAO;CACT,IAGE,IAA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,IAAAA;CAJF,OAOY,EAAA,SAAA,kBAAA,EAAA,SACC,mBAAA,EAAA,SACE,qBAAA,EAAA,SAmCV,WAAA,EAAA,SAhCDH,OARF,MAAA,qBAAC,OAAD;EACE,WAAW;EACX,WAAQ;EACR,QAAQ;EACR,SAAS;EACT,WAAW;EACX,KAAK;EANP,UAAA,CAQEA,KAgCC,OACE;KAtCK,EAAA,OAAA,gBACC,EAAA,OAAA,iBACE,EAAA,OAAA,mBAmCV,EAAA,OAAA,SAhCDA,EAAAA,OAAAA,mCARFG;AA2CJ;AA9NwC,SAAA,OAAC,KAAA;CAAM,OAAA,KAAK,IAAIC,MAAI,GAAG,CAAC;;AAPrB,SAAA,MAAC,KAAM;CAK9C,OAJIA,QAAM,IAAU,IAChBA,QAAM,KACNA,QAAM,IAAU,IAEbA,MAAI;AACb;AAiOF,SAAS,cAAc,EACrB,eACA,SACA,QACA,cACA,cACA,cACA,4BAIyE;CACzE,OAAO,cACL;EACE;EACA;EACA;EACA;EACA;CACF,GACA,wBACF;AACF"}
|
package/dist/breadcrumbs.js
CHANGED
|
@@ -3,7 +3,7 @@ import { n as _getArrayProp } from "./helpers-XThPpWje.js";
|
|
|
3
3
|
import { y as Box } from "./useLayer-B0i19TTM.js";
|
|
4
4
|
import { n as Text, t as Stack } from "./stack-Cv-WM-7p.js";
|
|
5
5
|
import { t as Button } from "./button-dhq4ViVg.js";
|
|
6
|
-
import { t as Popover } from "./popover-
|
|
6
|
+
import { t as Popover } from "./popover-CEDyHcBi.js";
|
|
7
7
|
import { t as useClickOutsideEvent } from "./useClickOutsideEvent-CC1zgOmv.js";
|
|
8
8
|
import { c } from "react/compiler-runtime";
|
|
9
9
|
import { clsx } from "clsx/lite";
|
|
@@ -1,8 +1,83 @@
|
|
|
1
1
|
import { c } from "react/compiler-runtime";
|
|
2
|
-
import { Activity, useState } from "react";
|
|
2
|
+
import { Activity, useInsertionEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { PresenceChild, invariant } from "motion/react";
|
|
5
5
|
/**
|
|
6
|
+
* A ref that always holds the latest `value`, updated before any layout effect of the same commit
|
|
7
|
+
* runs (the same mechanism `use-effect-event` uses), for callbacks that run outside render.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
function useLatestRef(value) {
|
|
12
|
+
let $ = c(3), ref = useRef(value), t0, t1;
|
|
13
|
+
return $[0] === value ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
|
|
14
|
+
ref.current = value;
|
|
15
|
+
}, t1 = [value], $[0] = value, $[1] = t0, $[2] = t1), useInsertionEffect(t0, t1), ref;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Attaches `value` to `ref` the way React attaches an element's `ref` prop, and returns the
|
|
19
|
+
* function that detaches it: the cleanup a callback ref returned, or else a call with `null`.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
function attachRef(ref, value) {
|
|
24
|
+
if (!ref) return noop;
|
|
25
|
+
if (typeof ref == "function") {
|
|
26
|
+
let cleanup = ref(value);
|
|
27
|
+
return typeof cleanup == "function" ? cleanup : () => ref(null);
|
|
28
|
+
}
|
|
29
|
+
return ref.current = value, () => {
|
|
30
|
+
ref.current = null;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function noop() {}
|
|
34
|
+
/**
|
|
35
|
+
* Keeps the element of the child that `Tooltip` and `Popover` clone in a ref rather than in state.
|
|
36
|
+
* A ref callback runs in the commit phase, where a state update is scheduled at Immediate priority:
|
|
37
|
+
* inside a `<ViewTransition>` such an update holds up the animation, and makes React skip the
|
|
38
|
+
* transition if sync work is flushed while the browser prepares it. Floating UI is handed the
|
|
39
|
+
* element as the floating element mounts, or right away when it is replaced while shown.
|
|
40
|
+
*
|
|
41
|
+
* The child's own `ref` is attached to the element too. A change of that ref alone (an inline
|
|
42
|
+
* callback ref) is applied from a layout effect, so that `setReference` keeps its identity and a
|
|
43
|
+
* re-render does not detach the element from Floating UI and `onAttach`.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
function useReferenceElement(refs, childRef, onAttach) {
|
|
48
|
+
let $ = c(12), referenceRef = useRef(null), attachmentRef = useRef(null), childRefRef = useLatestRef(childRef), t0;
|
|
49
|
+
$[0] !== childRefRef || $[1] !== onAttach || $[2] !== refs ? (t0 = (node) => {
|
|
50
|
+
referenceRef.current = node, refs.floating.current && refs.setReference(node);
|
|
51
|
+
let detach = onAttach?.(node);
|
|
52
|
+
return syncChildRef(attachmentRef, childRefRef.current, node), () => {
|
|
53
|
+
syncChildRef(attachmentRef, void 0, null), detach?.(), referenceRef.current = null, refs.floating.current && refs.setReference(null);
|
|
54
|
+
};
|
|
55
|
+
}, $[0] = childRefRef, $[1] = onAttach, $[2] = refs, $[3] = t0) : t0 = $[3];
|
|
56
|
+
let setReference = t0, t1, t2;
|
|
57
|
+
$[4] === childRef ? (t1 = $[5], t2 = $[6]) : (t1 = () => {
|
|
58
|
+
syncChildRef(attachmentRef, childRef, referenceRef.current);
|
|
59
|
+
}, t2 = [childRef], $[4] = childRef, $[5] = t1, $[6] = t2), useLayoutEffect(t1, t2);
|
|
60
|
+
let t3;
|
|
61
|
+
$[7] === refs ? t3 = $[8] : (t3 = () => {
|
|
62
|
+
referenceRef.current && refs.setReference(referenceRef.current);
|
|
63
|
+
}, $[7] = refs, $[8] = t3);
|
|
64
|
+
let handOverReference = t3, t4;
|
|
65
|
+
return $[9] !== handOverReference || $[10] !== setReference ? (t4 = {
|
|
66
|
+
handOverReference,
|
|
67
|
+
referenceRef,
|
|
68
|
+
setReference
|
|
69
|
+
}, $[9] = handOverReference, $[10] = setReference, $[11] = t4) : t4 = $[11], t4;
|
|
70
|
+
}
|
|
71
|
+
/** Attaches `ref` to `node` unless it is attached already, detaching whatever else was */
|
|
72
|
+
function syncChildRef(attachmentRef, ref, node) {
|
|
73
|
+
let attachment = attachmentRef.current;
|
|
74
|
+
attachment && attachment.ref === ref && attachment.node === node || (attachmentRef.current = null, attachment?.detach(), ref && node && (attachmentRef.current = {
|
|
75
|
+
detach: attachRef(ref, node),
|
|
76
|
+
node,
|
|
77
|
+
ref
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
6
81
|
* Custom floating-ui middleware which calculates transform-origin X + Y offsets
|
|
7
82
|
* based on the current floating rect's dimensions and shift offset.
|
|
8
83
|
*
|
|
@@ -97,6 +172,6 @@ function getElementRef(element) {
|
|
|
97
172
|
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
98
173
|
return mayWarn ? element.ref : (getter = Object.getOwnPropertyDescriptor(element, "ref")?.get, mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning, mayWarn ? element.props.ref : element.props.ref || element.ref);
|
|
99
174
|
}
|
|
100
|
-
export { origin as i, AnimateActivity as n, getTransformOrigin as r, getElementRef as t };
|
|
175
|
+
export { useReferenceElement as a, origin as i, AnimateActivity as n, attachRef as o, getTransformOrigin as r, useLatestRef as s, getElementRef as t };
|
|
101
176
|
|
|
102
|
-
//# sourceMappingURL=getElementRef-
|
|
177
|
+
//# sourceMappingURL=getElementRef-BLVMlHTn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getElementRef-BLVMlHTn.js","names":["() => {\n ref.current = value\n }","[value]","_c","(node: HTMLElement) => {\n referenceRef.current = node\n if (refs.floating.current) refs.setReference(node)\n const detach = onAttach?.(node)\n syncChildRef(attachmentRef, childRefRef.current, node)\n\n return () => {\n syncChildRef(attachmentRef, undefined, null)\n detach?.()\n referenceRef.current = null\n if (refs.floating.current) refs.setReference(null)\n }\n }","childRefRef.current","refs.floating.current","useCallback(\n (node: HTMLElement) => {\n referenceRef.current = node\n if (refs.floating.current) refs.setReference(node)\n const detach = onAttach?.(node)\n syncChildRef(attachmentRef, childRefRef.current, node)\n\n return () => {\n syncChildRef(attachmentRef, undefined, null)\n detach?.()\n referenceRef.current = null\n if (refs.floating.current) refs.setReference(null)\n }\n },\n [childRefRef, onAttach, refs],\n )","() => {\n syncChildRef(attachmentRef, childRef, referenceRef.current)\n }","[childRef]","() => {\n // Never `null`: that would replace `Popover`'s `referenceElement` option in `refs.reference`\n if (referenceRef.current) refs.setReference(referenceRef.current)\n }","useCallback(() => {\n // Never `null`: that would replace `Popover`'s `referenceElement` option in `refs.reference`\n if (referenceRef.current) refs.setReference(referenceRef.current)\n }, [refs])","{handOverReference, referenceRef, setReference}","_c","{mode: modeFromProps, layoutMode, children}: AnimateActivityProps","() => setMode('hidden')","<PresenceChild\n isPresent={isPresent}\n onExitComplete={!isPresent ? onExitComplete : undefined}\n presenceAffectsLayout={false}\n mode={layoutMode === 'pop' ? 'popLayout' : 'sync'}\n >\n {/* oxlint-disable-next-line no-unsafe-type-assertion -- PresenceChild expects a single ReactElement */}\n {children as any}\n </PresenceChild>","!isPresent ? onExitComplete : undefined","layoutMode === 'pop' ? 'popLayout' : 'sync'","children as any","<Activity mode={mode}>\n <PresenceChild\n isPresent={isPresent}\n onExitComplete={!isPresent ? onExitComplete : undefined}\n presenceAffectsLayout={false}\n mode={layoutMode === 'pop' ? 'popLayout' : 'sync'}\n >\n {/* oxlint-disable-next-line no-unsafe-type-assertion -- PresenceChild expects a single ReactElement */}\n {children as any}\n </PresenceChild>\n </Activity>","_c"],"sources":["../src/core/hooks/useLatestRef.ts","../src/core/utils/attachRef.ts","../src/core/hooks/useReferenceElement.ts","../src/core/middleware/origin.ts","../src/core/utils/animateActivity.tsx","../src/core/utils/getElementRef.ts"],"sourcesContent":["import {useInsertionEffect, useRef} from 'react'\n\n/**\n * A ref that always holds the latest `value`, updated before any layout effect of the same commit\n * runs (the same mechanism `use-effect-event` uses), for callbacks that run outside render.\n *\n * @internal\n */\nexport function useLatestRef<T>(value: T): React.RefObject<T> {\n const ref = useRef(value)\n\n useInsertionEffect(() => {\n ref.current = value\n }, [value])\n\n return ref\n}\n","/**\n * Attaches `value` to `ref` the way React attaches an element's `ref` prop, and returns the\n * function that detaches it: the cleanup a callback ref returned, or else a call with `null`.\n *\n * @internal\n */\nexport function attachRef<T>(ref: React.Ref<T> | undefined, value: T): () => void {\n if (!ref) return noop\n\n if (typeof ref === 'function') {\n const cleanup = ref(value)\n\n return typeof cleanup === 'function' ? cleanup : () => ref(null)\n }\n\n ref.current = value\n\n return () => {\n ref.current = null\n }\n}\n\nfunction noop() {}\n","import {useCallback, useLayoutEffect, useRef} from 'react'\n\nimport {attachRef} from '../utils/attachRef'\nimport {useLatestRef} from './useLatestRef'\n\n/** The part of Floating UI's `refs` used here, whichever reference element type it was given */\ninterface FloatingRefs {\n floating: React.RefObject<Element | null>\n setReference: (node: HTMLElement | null) => void\n}\n\ninterface ChildRefAttachment {\n detach: () => void\n node: HTMLElement\n ref: React.Ref<HTMLElement>\n}\n\n/**\n * Keeps the element of the child that `Tooltip` and `Popover` clone in a ref rather than in state.\n * A ref callback runs in the commit phase, where a state update is scheduled at Immediate priority:\n * inside a `<ViewTransition>` such an update holds up the animation, and makes React skip the\n * transition if sync work is flushed while the browser prepares it. Floating UI is handed the\n * element as the floating element mounts, or right away when it is replaced while shown.\n *\n * The child's own `ref` is attached to the element too. A change of that ref alone (an inline\n * callback ref) is applied from a layout effect, so that `setReference` keeps its identity and a\n * re-render does not detach the element from Floating UI and `onAttach`.\n *\n * @internal\n */\nexport function useReferenceElement(\n refs: FloatingRefs,\n childRef: React.Ref<HTMLElement> | undefined,\n onAttach?: (node: HTMLElement) => () => void,\n): {\n handOverReference: () => void\n referenceRef: React.RefObject<HTMLElement | null>\n setReference: React.RefCallback<HTMLElement>\n} {\n const referenceRef = useRef<HTMLElement | null>(null)\n const attachmentRef = useRef<ChildRefAttachment | null>(null)\n const childRefRef = useLatestRef(childRef)\n\n const setReference = useCallback(\n (node: HTMLElement) => {\n referenceRef.current = node\n if (refs.floating.current) refs.setReference(node)\n const detach = onAttach?.(node)\n syncChildRef(attachmentRef, childRefRef.current, node)\n\n return () => {\n syncChildRef(attachmentRef, undefined, null)\n detach?.()\n referenceRef.current = null\n if (refs.floating.current) refs.setReference(null)\n }\n },\n [childRefRef, onAttach, refs],\n )\n\n useLayoutEffect(() => {\n syncChildRef(attachmentRef, childRef, referenceRef.current)\n }, [childRef])\n\n const handOverReference = useCallback(() => {\n // Never `null`: that would replace `Popover`'s `referenceElement` option in `refs.reference`\n if (referenceRef.current) refs.setReference(referenceRef.current)\n }, [refs])\n\n return {handOverReference, referenceRef, setReference}\n}\n\n/** Attaches `ref` to `node` unless it is attached already, detaching whatever else was */\nfunction syncChildRef(\n attachmentRef: React.RefObject<ChildRefAttachment | null>,\n ref: React.Ref<HTMLElement> | undefined,\n node: HTMLElement | null,\n) {\n const attachment = attachmentRef.current\n\n if (attachment && attachment.ref === ref && attachment.node === node) return\n\n attachmentRef.current = null\n attachment?.detach()\n\n if (ref && node) attachmentRef.current = {detach: attachRef(ref, node), node, ref}\n}\n","import {Middleware} from '@floating-ui/react-dom'\n\n/**\n * Custom floating-ui middleware which calculates transform-origin X + Y offsets\n * based on the current floating rect's dimensions and shift offset.\n *\n * Scaling popovers with these transform-origin offsets will give the effect of\n * popvers slightly 'growing' from the origin/reference element.\n *\n * This middleware must be applied after both `@sanity/ui/size` and `shift` middlewares.\n */\nexport const origin: Middleware = {\n name: '@sanity/ui/origin',\n fn({middlewareData, placement, rects}) {\n const [side] = placement.split('-')\n\n const floatingWidth = rects.floating.width\n const floatingHeight = rects.floating.height\n\n const shiftX = middlewareData.shift?.x || 0\n const shiftY = middlewareData.shift?.y || 0\n\n if (floatingWidth <= 0 || floatingHeight <= 0) {\n return {}\n }\n\n const isVerticalPlacement = ['bottom', 'top'].includes(side)\n\n const {originX, originY}: {originX: number; originY: number} = isVerticalPlacement\n ? {\n originX: clamp(0.5 - shiftX / floatingWidth, 0, 1),\n originY: side === 'bottom' ? 0 : 1,\n }\n : {\n originX: side === 'left' ? 1 : 0,\n originY: clamp(0.5 - shiftY / floatingHeight, 0, 1),\n }\n\n return {\n data: {originX, originY},\n }\n },\n}\n\n/**\n * Converts the `origin` middleware data into a plain `transform-origin` CSS value.\n *\n * The value is intentionally applied as a regular CSS property rather than motion's\n * `originX`/`originY` style keys: motion turns those into motion values that it resets to\n * their initial (unpositioned, `undefined`) state whenever the element re-mounts, which is\n * what happens every time an `Activity`-hidden popover or tooltip is shown again.\n */\nexport function getTransformOrigin(originX?: number, originY?: number): string | undefined {\n if (originX === undefined || originY === undefined) return undefined\n\n return `${originX * 100}% ${originY * 100}%`\n}\n\nfunction clamp(num: number, min: number, max: number) {\n return Math.min(Math.max(num, min), max)\n}\n","/**\n * MIT License\n *\n * Copyright (c) 2024 Motion One\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport {invariant, PresenceChild} from 'motion/react'\nimport {Activity, useState} from 'react'\n\ninterface AnimateActivityProps {\n mode: 'visible' | 'hidden'\n layoutMode: 'default' | 'pop'\n children: React.ReactNode\n}\n\n/**\n * Animated version of React's `Activity` that defers `mode=\"hidden\"` until\n * child exit animations have finished.\n *\n * @internal\n */\nexport function AnimateActivity({mode: modeFromProps, layoutMode, children}: AnimateActivityProps) {\n /**\n * This is the mode that we'll render.\n */\n const [mode, setMode] = useState(modeFromProps)\n\n /**\n * This is the goal state as defined by props.\n */\n const isPresent = modeFromProps === 'visible'\n\n /**\n * Immediately switch to mode=\"visible\" when the user\n * changes the mode prop.\n */\n if (isPresent && mode !== 'visible') {\n setMode('visible')\n return null\n }\n\n /**\n * Set mode to \"hidden\" only when the exit animation is complete.\n */\n const onExitComplete = () => setMode('hidden')\n\n invariant(Boolean(Activity), 'Activity component not found - upgrade to React 19.2.0 or higher')\n\n return (\n <Activity mode={mode}>\n <PresenceChild\n isPresent={isPresent}\n onExitComplete={!isPresent ? onExitComplete : undefined}\n presenceAffectsLayout={false}\n mode={layoutMode === 'pop' ? 'popLayout' : 'sync'}\n >\n {/* oxlint-disable-next-line no-unsafe-type-assertion -- PresenceChild expects a single ReactElement */}\n {children as any}\n </PresenceChild>\n </Activity>\n )\n}\n","// Based on https://github.com/radix-ui/primitives/blob/0bade6a704e5821b90a6da0f3d8cfa8a7711127d/packages/react/slot/src/Slot.tsx#L128-L150\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nexport function getElementRef<T = unknown>(element: React.ReactElement): React.Ref<T> | undefined {\n // React <=18 in DEV\n // oxlint-disable-next-line unbound-method\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning\n\n if (mayWarn) {\n // oxlint-disable-next-line no-unsafe-type-assertion\n return (element as {ref?: React.Ref<T>}).ref\n }\n\n // React 19 in DEV\n // oxlint-disable-next-line unbound-method\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning\n\n if (mayWarn) {\n // oxlint-disable-next-line no-unsafe-type-assertion\n return (element.props as {ref?: React.Ref<T>}).ref\n }\n\n // Not DEV\n // oxlint-disable-next-line no-unsafe-type-assertion\n return (element.props as {ref?: React.Ref<T>}).ref || (element as {ref?: React.Ref<T>}).ref\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,aAAgB,OAA8B;eACtD,MAAM,OAAO,KAAK,GAELA,IAEhBC;CAEH,OAHgB,EAAA,OAAA,kCADG,WAAM;EACvB,IAAI,UAAU;CAChB,GAAG,KAAA,CAAC,KAAK,GADO,EAAA,KAAA,8BADhB,mBAAmBD,IAEhBC,EAAO,GAEH;AACT;;;;;;;ACVA,SAAgB,UAAa,KAA+B,OAAsB;CAChF,IAAI,CAAC,KAAK,OAAO;CAEjB,IAAI,OAAO,OAAQ,YAAY;EAC7B,IAAM,UAAU,IAAI,KAAK;EAEzB,OAAO,OAAO,WAAY,aAAa,gBAAgB,IAAI,IAAI;CACjE;CAIA,OAFA,IAAI,UAAU,aAED;EACX,IAAI,UAAU;CAChB;AACF;AAEA,SAAS,OAAO,CAAC;;;;;;;;;;;;;;ACQjB,SAAgB,oBACd,MACA,UACA,UAKA;gBACM,eAAe,OAA2B,IAAI,GAC9C,gBAAgB,OAAkC,IAAI,GACtD,cAAc,aAAa,QAAQ,GAGvCE;CAI8BC,AAAAA,EAAAA,OAAAA,eAAAA,EAAAA,OADb,YAAA,EAAA,OADXC,QAFN,MAAC,SAAsB;EAErB,AADA,aAAa,UAAU,MACnB,KAAK,SAAS,WAAS,KAAK,aAAa,IAAI;EACjD,IAAM,SAAS,WAAW,IAAI;EAG9B,OAFA,aAAa,eAAe,YAAY,SAAS,IAAI,SAExC;GAIX,AAHA,aAAa,eAAe,KAAA,GAAW,IAAI,GAC3C,SAAS,GACT,aAAa,UAAU,MACnB,KAAK,SAAS,WAAS,KAAK,aAAa,IAAI;EAC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J;ACzEA,SAAgB,cAA2B,SAAuD;CAGhG,IAAI,SAAS,OAAO,yBAAyB,QAAQ,OAAO,KAAK,CAAC,EAAE,KAChE,UAAU,UAAU,oBAAoB,UAAU,OAAO;CAmB7D,OAjBI,UAEM,QAAiC,OAK3C,SAAS,OAAO,yBAAyB,SAAS,KAAK,CAAC,EAAE,KAC1D,UAAU,UAAU,oBAAoB,UAAU,OAAO,gBAErD,UAEM,QAAQ,MAA+B,MAKzC,QAAQ,MAA+B,OAAQ,QAAiC;AAC1F"}
|
|
@@ -5,9 +5,9 @@ import { n as Text } from "./stack-Cv-WM-7p.js";
|
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import { clsx } from "clsx/lite";
|
|
7
7
|
import { Children, useEffect } from "react";
|
|
8
|
+
import { useEffectEvent } from "use-effect-event";
|
|
8
9
|
import { css, styled } from "styled-components";
|
|
9
10
|
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
10
|
-
import { useEffectEvent } from "use-effect-event";
|
|
11
11
|
/**
|
|
12
12
|
* Adds global keydown event listener to the window.
|
|
13
13
|
*
|
|
@@ -165,4 +165,4 @@ function Hotkeys(props) {
|
|
|
165
165
|
}
|
|
166
166
|
export { useGlobalKeyDown as i, KBD as n, Inline as r, Hotkeys as t };
|
|
167
167
|
|
|
168
|
-
//# sourceMappingURL=hotkeys-
|
|
168
|
+
//# sourceMappingURL=hotkeys-Caqg1W-_.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys-sG9yO97K.js","names":["(event: KeyboardEvent) => onKeyDown(event)","() => {\n const handler = (event: KeyboardEvent) => handleKeyDown(event)\n\n window.addEventListener('keydown', handler, options)\n\n return () => window.removeEventListener('keydown', handler, options)\n }","event","[options]","_c","Children.map(childrenProp, (child) => child && <div>{child}</div>)","(child) => child && <div>{child}</div>","useMemo(\n () => Children.map(childrenProp, (child) => child && <div>{child}</div>),\n [childrenProp],\n )","_getArrayProp(gap)","<StyledInline\n data-ui=\"Inline\"\n {...restProps}\n $space={_getArrayProp(gap)}\n forwardedAs={as}\n ref={ref}\n >\n {children}\n </StyledInline>","_c","fontSize = 0","padding = 1","radius = 2","_getArrayProp(radius)","<Text as=\"span\" size={fontSize} weight=\"semibold\">\n {children}\n </Text>","<Box as=\"span\" padding={padding}>\n <Text as=\"span\" size={fontSize} weight=\"semibold\">\n {children}\n </Text>\n </Box>","<StyledKBD data-ui=\"KBD\" {...restProps} $radius={_getArrayProp(radius)} ref={ref}>\n <Box as=\"span\" padding={padding}>\n <Text as=\"span\" size={fontSize} weight=\"semibold\">\n {children}\n </Text>\n </Box>\n </StyledKBD>","_c","gap = 0.5","_getArrayProp(gap)","<></>","clsx(hotkeys, className)","keys.map((key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n ))","(key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n )","<Inline as=\"span\" gap={spacing}>\n {keys.map((key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n ))}\n </Inline>","<kbd className={clsx(hotkeys, className)} data-ui=\"Hotkeys\" ref={ref} {...restProps}>\n <Inline as=\"span\" gap={spacing}>\n {keys.map((key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n ))}\n </Inline>\n </kbd>","_c","_Fragment","\"lineHeight\"","\"margin\""],"sources":["../src/core/hooks/useGlobalKeyDown.ts","../src/core/primitives/inline/styles.ts","../src/core/primitives/inline/inline.tsx","../src/core/primitives/kbd/kbd.tsx","../src/core/components/hotkeys/hotkeys.css.ts","../src/core/components/hotkeys/hotkeys.tsx"],"sourcesContent":["import {useEffect} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once\n// https://github.com/facebook/react/issues/34818 is fixed in the lowest React\n// version we support: on React 19.2 the native hook never sees values past\n// the first render when the calling component is wrapped in `forwardRef` or\n// `memo`. This public hook runs in the fiber of whatever component calls it\n// (consumers may call it from `forwardRef` or `memo` components).\nimport {useEffectEvent} from 'use-effect-event'\n\n/**\n * Adds global keydown event listener to the window.\n *\n * @param onKeyDown - The function to call when a keydown event is triggered.\n * @param options - The options to pass to the addEventListener function (example, capture: true)\n * @beta\n */\nexport function useGlobalKeyDown(\n onKeyDown: (event: KeyboardEvent) => void,\n options?: AddEventListenerOptions,\n): void {\n const handleKeyDown = useEffectEvent((event: KeyboardEvent) => onKeyDown(event))\n\n useEffect(() => {\n const handler = (event: KeyboardEvent) => handleKeyDown(event)\n\n window.addEventListener('keydown', handler, options)\n\n return () => window.removeEventListener('keydown', handler, options)\n }, [options])\n}\n","import {CSSObject} from '../../../theme/system/css'\nimport {getTheme_v2} from '../../../theme/versioning/getTheme_v2'\nimport {_responsive, rem} from '../../styles/helpers'\nimport {ThemeProps} from '../../styles/types'\nimport {ResponsiveInlineSpaceStyleProps} from './types'\n\nexport function inlineBaseStyle(): CSSObject {\n return {\n 'lineHeight': '0',\n\n '&&:not([hidden])': {\n display: 'block',\n },\n\n '& > div': {\n display: 'inline-block',\n verticalAlign: 'middle',\n },\n }\n}\n\nexport function inlineSpaceStyle(props: ResponsiveInlineSpaceStyleProps & ThemeProps): CSSObject[] {\n const {media, space} = getTheme_v2(props.theme)\n\n return _responsive(media, props.$space, (spaceIndex) => {\n const _space = rem(spaceIndex === 0.5 ? space[1] / 2 : space[spaceIndex])\n\n return {\n 'margin': `-${_space} 0 0 -${_space}`,\n '& > div': {padding: `${_space} 0 0 ${_space}`},\n }\n })\n}\n","import {Children, useMemo} from 'react'\nimport {styled} from 'styled-components'\n\nimport {_getArrayProp} from '../../styles/helpers'\nimport {ElementType, Props} from '../../types/component'\nimport {Box, BoxOwnProps} from '../box/box'\nimport {inlineBaseStyle, inlineSpaceStyle} from './styles'\nimport {ResponsiveInlineSpaceStyleProps} from './types'\n\n/**\n * @public\n */\nexport interface InlineOwnProps extends Omit<BoxOwnProps, 'display'> {\n /**\n * @deprecated Use `gap` instead.\n */\n space?: never\n /** The spacing between children. */\n gap?: number | number[]\n}\n\n/**\n * @public\n */\nexport type InlineProps<E extends ElementType = 'div'> = Props<InlineOwnProps, E>\n\nconst StyledInline = styled(Box)<ResponsiveInlineSpaceStyleProps>(inlineBaseStyle, inlineSpaceStyle)\n\nfunction InlineComponent(\n props: InlineOwnProps & {as?: ElementType} & React.HTMLProps<HTMLDivElement>,\n) {\n const {as, children: childrenProp, gap, ref, ...restProps} = props\n\n const children = useMemo(\n () => Children.map(childrenProp, (child) => child && <div>{child}</div>),\n [childrenProp],\n )\n\n return (\n <StyledInline\n data-ui=\"Inline\"\n {...restProps}\n $space={_getArrayProp(gap)}\n forwardedAs={as}\n ref={ref}\n >\n {children}\n </StyledInline>\n )\n}\n\n/**\n * The `Inline` component is a layout utility for aligning and spacing items horizontally.\n *\n * @public\n */\n// oxlint-disable-next-line no-unsafe-type-assertion\nexport const Inline = InlineComponent as unknown as <E extends ElementType = 'div'>(\n props: InlineProps<E>,\n) => React.JSX.Element\n","import {css, styled} from 'styled-components'\n\nimport {_getArrayProp} from '../../styles/helpers'\nimport {responsiveRadiusStyle} from '../../styles/radius/radiusStyle'\nimport {ResponsiveRadiusStyleProps} from '../../styles/radius/types'\nimport {ElementType, Props} from '../../types/component'\nimport {Radius} from '../../types/radius'\nimport {Box} from '../box/box'\nimport {Text} from '../text/text'\n\n/**\n * @public\n */\nexport interface KBDOwnProps {\n fontSize?: number | number[]\n padding?: number | number[]\n radius?: Radius | Radius[]\n}\n\n/**\n * @public\n */\nexport type KBDProps<E extends ElementType = 'kbd'> = Props<KBDOwnProps, E>\n\nfunction kbdStyle() {\n return css`\n --card-bg-color: var(--card-kbd-bg-color);\n --card-border-color: var(--card-kbd-border-color);\n --card-fg-color: var(--card-kbd-fg-color);\n\n box-shadow: inset 0 0 0 1px var(--card-border-color);\n background: var(--card-bg-color);\n font: inherit;\n\n vertical-align: top;\n\n &:not([hidden]) {\n display: inline-block;\n }\n `\n}\n\nconst StyledKBD = styled.kbd<ResponsiveRadiusStyleProps>(responsiveRadiusStyle, kbdStyle)\n\nfunction KBDComponent(\n props: KBDOwnProps & {as?: ElementType} & Omit<React.HTMLProps<HTMLElement>, 'as' | 'size'>,\n) {\n const {children, fontSize = 0, padding = 1, radius = 2, ref, ...restProps} = props\n\n return (\n <StyledKBD data-ui=\"KBD\" {...restProps} $radius={_getArrayProp(radius)} ref={ref}>\n <Box as=\"span\" padding={padding}>\n <Text as=\"span\" size={fontSize} weight=\"semibold\">\n {children}\n </Text>\n </Box>\n </StyledKBD>\n )\n}\n\n/**\n * Used to define some text as keyboard input.\n *\n * @public\n */\nexport const KBD: <E extends ElementType = 'kbd'>(props: KBDProps<E>) => React.JSX.Element =\n KBDComponent\n","import {style} from '@vanilla-extract/css'\n\nexport const hotkeys = style({\n font: 'inherit',\n padding: '1px',\n selectors: {\n '&:not([hidden])': {\n display: 'block',\n },\n },\n})\n","import {clsx} from 'clsx/lite'\nimport {styled} from 'styled-components'\n\nimport {Inline} from '../../primitives/inline/inline'\nimport {KBD} from '../../primitives/kbd/kbd'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {Radius} from '../../types/radius'\n\nimport {hotkeys} from './hotkeys.css'\n\n/**\n * @public\n */\nexport interface HotkeysProps {\n fontSize?: number | number[]\n gap?: number | number[]\n padding?: number | number[]\n radius?: Radius | Radius[]\n /**\n * @deprecated Use `gap` instead.\n */\n space?: never\n keys?: string[]\n}\n\n// Stays on styled-components: `display: block` must beat KBD's runtime\n// `display: inline-block` at equal specificity, which needs both rules in the\n// runtime stylesheet.\nconst Key = styled(KBD)`\n &:not([hidden]) {\n display: block;\n }\n`\n\n/**\n * Represent hotkeys (a keyboard combination) with semantic `<kbd>` elements.\n *\n * @public\n */\nexport function Hotkeys(props: HotkeysProps & Omit<React.HTMLProps<HTMLElement>, 'as' | 'size'>) {\n const {className, fontSize, gap = 0.5, keys, padding, radius, ref, ...restProps} = props\n const spacing = _getArrayProp(gap)\n\n if (!keys || keys.length === 0) {\n return <></>\n }\n\n return (\n <kbd className={clsx(hotkeys, className)} data-ui=\"Hotkeys\" ref={ref} {...restProps}>\n <Inline as=\"span\" gap={spacing}>\n {keys.map((key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n ))}\n </Inline>\n </kbd>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAgB,iBACd,WACA,SACM;eAC+BA;CAA0B,AAAA,EAAA,OAAA,yBAA1B,MAAC,UAAyB,UAAU,KAAK,GAAf,EAAA,KAAA;CAA/D,IAAM,gBAAgB,eAAeA,EAA0C,GAErEC;CACkC,AAAA,EAAA,OAAA,iBAAA,EAAA,OAEE,WAHpC,WAAM;EACd,IAAM,WAAW,YAAyB,cAAcC,OAAK;EAI7D,OAFA,OAAO,iBAAiB,WAAW,SAAS,OAAO,SAEtC,OAAO,oBAAoB,WAAW,SAAS,OAAO;CACrE,GAL4C,EAAA,KAAA,eAEE,EAAA,KAAA;CAG3CC,IAAAA;CANH,AAMI,EAAA,OAAA,uBAAD,KAAA,CAAC,OAAO,GAAP,EAAA,KAAA,qBANJ,UAAUF,IAMPE,EAAS;AACd;ACvBA,SAAgB,kBAA6B;CAC3C,OAAO;EACL0B,YAAc;EAEd,oBAAoB,EAClB,SAAS,QACX;EAEA,WAAW;GACT,SAAS;GACT,eAAe;EACjB;CACF;AACF;AAEA,SAAgB,iBAAiB,OAAkE;CACjG,IAAM,EAAC,OAAO,UAAS,YAAY,MAAM,KAAK;CAE9C,OAAO,YAAY,OAAO,MAAM,SAAS,eAAe;EACtD,IAAM,SAAS,IAAI,eAAe,KAAM,MAAM,KAAK,IAAI,MAAM,WAAW;EAExE,OAAO;GACLC,QAAU,IAAI,OAAO,Q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,CAAC,QAAQ,KAAK,WAAW,GAAG;EACvBC,IAAAA;EAAP,4DAAW,KAAA,oBAAAO,YAAA,CAAA,CAAA,6BAAJP;CACT;CAGkBC,IAAAA;CAAc,AAAA,EAAA,QAAA,0BAAd,KAAA,KAAK,SAAS,SAAS,GAAT,EAAA,MAAA;CAEzBC,IAAAA;CAEwB,IAAA,EAAA,QAAA,YAAA,EAAA,QAFxB,QAAA,EAAA,QAE2C,WAAA,EAAA,QAAiB,QAAA;EAFnDC,IAAAA;EAEe,EAAA,QAAA,YAAA,EAAA,QAAmB,WAAA,EAAA,QAAiB,UAFnD,MAAC,KAAK,MAEd,oBAAC,KAAD;GAAuB;GAAmB;GAAiB;GACxD,UAAA;EACE,GAFK,CAEL,GAFkB,EAAA,MAAA,UAAmB,EAAA,MAAA,SAAiB,EAAA,MAAA,kCAF5D,KAAA,KAAK,IAAIA,EAKT,GAHwB,EAAA,MAAA,UAFxB,EAAA,MAAA,MAE2C,EAAA,MAAA,SAAiB,EAAA,MAAA;;CAH/DC,IAAAA;CAAuB,AAAA,EAAA,QAAA,WAAA,EAAA,QACpBF,MADH,KAAA,oBAAC,QAAD;EAAQ,IAAG;EAAO,KAAK;EACpBA,UAAAA;CAMK,CAAA,GAPe,EAAA,MAAA,SACpBA,EAAAA,MAAAA;CAFLG,IAAAA;CADF,OACmE,EAAA,QAAA,OAAA,EAAA,QAAS,aAAA,EAAA,QAA1DJ,MAAAA,EAAAA,QACdG,MADF,KAAA,oBAAC,OAAD;EAAK,WAAWH;EAA0B,WAAQ;EAAe;EAAK,GAAI;EACxEG,UAAAA;CAQG,CAAA,GAT4D,EAAA,MAAA,KAAS,EAAA,MAAA,WAA1DH,EAAAA,MAAAA,IACdG,EAAAA,MAAAA,8BADFC;AAWJ"}
|
|
1
|
+
{"version":3,"file":"hotkeys-Caqg1W-_.js","names":["(event: KeyboardEvent) => onKeyDown(event)","() => {\n const handler = (event: KeyboardEvent) => handleKeyDown(event)\n\n window.addEventListener('keydown', handler, options)\n\n return () => window.removeEventListener('keydown', handler, options)\n }","event","[options]","_c","Children.map(childrenProp, (child) => child && <div>{child}</div>)","(child) => child && <div>{child}</div>","useMemo(\n () => Children.map(childrenProp, (child) => child && <div>{child}</div>),\n [childrenProp],\n )","_getArrayProp(gap)","<StyledInline\n data-ui=\"Inline\"\n {...restProps}\n $space={_getArrayProp(gap)}\n forwardedAs={as}\n ref={ref}\n >\n {children}\n </StyledInline>","_c","fontSize = 0","padding = 1","radius = 2","_getArrayProp(radius)","<Text as=\"span\" size={fontSize} weight=\"semibold\">\n {children}\n </Text>","<Box as=\"span\" padding={padding}>\n <Text as=\"span\" size={fontSize} weight=\"semibold\">\n {children}\n </Text>\n </Box>","<StyledKBD data-ui=\"KBD\" {...restProps} $radius={_getArrayProp(radius)} ref={ref}>\n <Box as=\"span\" padding={padding}>\n <Text as=\"span\" size={fontSize} weight=\"semibold\">\n {children}\n </Text>\n </Box>\n </StyledKBD>","_c","gap = 0.5","_getArrayProp(gap)","<></>","clsx(hotkeys, className)","keys.map((key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n ))","(key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n )","<Inline as=\"span\" gap={spacing}>\n {keys.map((key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n ))}\n </Inline>","<kbd className={clsx(hotkeys, className)} data-ui=\"Hotkeys\" ref={ref} {...restProps}>\n <Inline as=\"span\" gap={spacing}>\n {keys.map((key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n ))}\n </Inline>\n </kbd>","_c","_Fragment","\"lineHeight\"","\"margin\""],"sources":["../src/core/hooks/useGlobalKeyDown.ts","../src/core/primitives/inline/styles.ts","../src/core/primitives/inline/inline.tsx","../src/core/primitives/kbd/kbd.tsx","../src/core/components/hotkeys/hotkeys.css.ts","../src/core/components/hotkeys/hotkeys.tsx"],"sourcesContent":["import {useEffect} from 'react'\n// TODO: switch to `useEffectEvent` from `react` once\n// https://github.com/facebook/react/issues/34818 is fixed in the lowest React\n// version we support: on React 19.2 the native hook never sees values past\n// the first render when the calling component is wrapped in `forwardRef` or\n// `memo`. This public hook runs in the fiber of whatever component calls it\n// (consumers may call it from `forwardRef` or `memo` components).\nimport {useEffectEvent} from 'use-effect-event'\n\n/**\n * Adds global keydown event listener to the window.\n *\n * @param onKeyDown - The function to call when a keydown event is triggered.\n * @param options - The options to pass to the addEventListener function (example, capture: true)\n * @beta\n */\nexport function useGlobalKeyDown(\n onKeyDown: (event: KeyboardEvent) => void,\n options?: AddEventListenerOptions,\n): void {\n const handleKeyDown = useEffectEvent((event: KeyboardEvent) => onKeyDown(event))\n\n useEffect(() => {\n const handler = (event: KeyboardEvent) => handleKeyDown(event)\n\n window.addEventListener('keydown', handler, options)\n\n return () => window.removeEventListener('keydown', handler, options)\n }, [options])\n}\n","import {CSSObject} from '../../../theme/system/css'\nimport {getTheme_v2} from '../../../theme/versioning/getTheme_v2'\nimport {_responsive, rem} from '../../styles/helpers'\nimport {ThemeProps} from '../../styles/types'\nimport {ResponsiveInlineSpaceStyleProps} from './types'\n\nexport function inlineBaseStyle(): CSSObject {\n return {\n 'lineHeight': '0',\n\n '&&:not([hidden])': {\n display: 'block',\n },\n\n '& > div': {\n display: 'inline-block',\n verticalAlign: 'middle',\n },\n }\n}\n\nexport function inlineSpaceStyle(props: ResponsiveInlineSpaceStyleProps & ThemeProps): CSSObject[] {\n const {media, space} = getTheme_v2(props.theme)\n\n return _responsive(media, props.$space, (spaceIndex) => {\n const _space = rem(spaceIndex === 0.5 ? space[1] / 2 : space[spaceIndex])\n\n return {\n 'margin': `-${_space} 0 0 -${_space}`,\n '& > div': {padding: `${_space} 0 0 ${_space}`},\n }\n })\n}\n","import {Children, useMemo} from 'react'\nimport {styled} from 'styled-components'\n\nimport {_getArrayProp} from '../../styles/helpers'\nimport {ElementType, Props} from '../../types/component'\nimport {Box, BoxOwnProps} from '../box/box'\nimport {inlineBaseStyle, inlineSpaceStyle} from './styles'\nimport {ResponsiveInlineSpaceStyleProps} from './types'\n\n/**\n * @public\n */\nexport interface InlineOwnProps extends Omit<BoxOwnProps, 'display'> {\n /**\n * @deprecated Use `gap` instead.\n */\n space?: never\n /** The spacing between children. */\n gap?: number | number[]\n}\n\n/**\n * @public\n */\nexport type InlineProps<E extends ElementType = 'div'> = Props<InlineOwnProps, E>\n\nconst StyledInline = styled(Box)<ResponsiveInlineSpaceStyleProps>(inlineBaseStyle, inlineSpaceStyle)\n\nfunction InlineComponent(\n props: InlineOwnProps & {as?: ElementType} & React.HTMLProps<HTMLDivElement>,\n) {\n const {as, children: childrenProp, gap, ref, ...restProps} = props\n\n const children = useMemo(\n () => Children.map(childrenProp, (child) => child && <div>{child}</div>),\n [childrenProp],\n )\n\n return (\n <StyledInline\n data-ui=\"Inline\"\n {...restProps}\n $space={_getArrayProp(gap)}\n forwardedAs={as}\n ref={ref}\n >\n {children}\n </StyledInline>\n )\n}\n\n/**\n * The `Inline` component is a layout utility for aligning and spacing items horizontally.\n *\n * @public\n */\n// oxlint-disable-next-line no-unsafe-type-assertion\nexport const Inline = InlineComponent as unknown as <E extends ElementType = 'div'>(\n props: InlineProps<E>,\n) => React.JSX.Element\n","import {css, styled} from 'styled-components'\n\nimport {_getArrayProp} from '../../styles/helpers'\nimport {responsiveRadiusStyle} from '../../styles/radius/radiusStyle'\nimport {ResponsiveRadiusStyleProps} from '../../styles/radius/types'\nimport {ElementType, Props} from '../../types/component'\nimport {Radius} from '../../types/radius'\nimport {Box} from '../box/box'\nimport {Text} from '../text/text'\n\n/**\n * @public\n */\nexport interface KBDOwnProps {\n fontSize?: number | number[]\n padding?: number | number[]\n radius?: Radius | Radius[]\n}\n\n/**\n * @public\n */\nexport type KBDProps<E extends ElementType = 'kbd'> = Props<KBDOwnProps, E>\n\nfunction kbdStyle() {\n return css`\n --card-bg-color: var(--card-kbd-bg-color);\n --card-border-color: var(--card-kbd-border-color);\n --card-fg-color: var(--card-kbd-fg-color);\n\n box-shadow: inset 0 0 0 1px var(--card-border-color);\n background: var(--card-bg-color);\n font: inherit;\n\n vertical-align: top;\n\n &:not([hidden]) {\n display: inline-block;\n }\n `\n}\n\nconst StyledKBD = styled.kbd<ResponsiveRadiusStyleProps>(responsiveRadiusStyle, kbdStyle)\n\nfunction KBDComponent(\n props: KBDOwnProps & {as?: ElementType} & Omit<React.HTMLProps<HTMLElement>, 'as' | 'size'>,\n) {\n const {children, fontSize = 0, padding = 1, radius = 2, ref, ...restProps} = props\n\n return (\n <StyledKBD data-ui=\"KBD\" {...restProps} $radius={_getArrayProp(radius)} ref={ref}>\n <Box as=\"span\" padding={padding}>\n <Text as=\"span\" size={fontSize} weight=\"semibold\">\n {children}\n </Text>\n </Box>\n </StyledKBD>\n )\n}\n\n/**\n * Used to define some text as keyboard input.\n *\n * @public\n */\nexport const KBD: <E extends ElementType = 'kbd'>(props: KBDProps<E>) => React.JSX.Element =\n KBDComponent\n","import {style} from '@vanilla-extract/css'\n\nexport const hotkeys = style({\n font: 'inherit',\n padding: '1px',\n selectors: {\n '&:not([hidden])': {\n display: 'block',\n },\n },\n})\n","import {clsx} from 'clsx/lite'\nimport {styled} from 'styled-components'\n\nimport {Inline} from '../../primitives/inline/inline'\nimport {KBD} from '../../primitives/kbd/kbd'\nimport {_getArrayProp} from '../../styles/helpers'\nimport {Radius} from '../../types/radius'\n\nimport {hotkeys} from './hotkeys.css'\n\n/**\n * @public\n */\nexport interface HotkeysProps {\n fontSize?: number | number[]\n gap?: number | number[]\n padding?: number | number[]\n radius?: Radius | Radius[]\n /**\n * @deprecated Use `gap` instead.\n */\n space?: never\n keys?: string[]\n}\n\n// Stays on styled-components: `display: block` must beat KBD's runtime\n// `display: inline-block` at equal specificity, which needs both rules in the\n// runtime stylesheet.\nconst Key = styled(KBD)`\n &:not([hidden]) {\n display: block;\n }\n`\n\n/**\n * Represent hotkeys (a keyboard combination) with semantic `<kbd>` elements.\n *\n * @public\n */\nexport function Hotkeys(props: HotkeysProps & Omit<React.HTMLProps<HTMLElement>, 'as' | 'size'>) {\n const {className, fontSize, gap = 0.5, keys, padding, radius, ref, ...restProps} = props\n const spacing = _getArrayProp(gap)\n\n if (!keys || keys.length === 0) {\n return <></>\n }\n\n return (\n <kbd className={clsx(hotkeys, className)} data-ui=\"Hotkeys\" ref={ref} {...restProps}>\n <Inline as=\"span\" gap={spacing}>\n {keys.map((key, i) => (\n // oxlint-disable-next-line no-array-index-key\n <Key key={i} fontSize={fontSize} padding={padding} radius={radius}>\n {key}\n </Key>\n ))}\n </Inline>\n </kbd>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAgB,iBACd,WACA,SACM;eAC+BA;CAA0B,AAAA,EAAA,OAAA,yBAA1B,MAAC,UAAyB,UAAU,KAAK,GAAf,EAAA,KAAA;CAA/D,IAAM,gBAAgB,eAAeA,EAA0C,GAErEC;CACkC,AAAA,EAAA,OAAA,iBAAA,EAAA,OAEE,WAHpC,WAAM;EACd,IAAM,WAAW,YAAyB,cAAcC,OAAK;EAI7D,OAFA,OAAO,iBAAiB,WAAW,SAAS,OAAO,SAEtC,OAAO,oBAAoB,WAAW,SAAS,OAAO;CACrE,GAL4C,EAAA,KAAA,eAEE,EAAA,KAAA;CAG3CC,IAAAA;CANH,AAMI,EAAA,OAAA,uBAAD,KAAA,CAAC,OAAO,GAAP,EAAA,KAAA,qBANJ,UAAUF,IAMPE,EAAS;AACd;ACvBA,SAAgB,kBAA6B;CAC3C,OAAO;EACL0B,YAAc;EAEd,oBAAoB,EAClB,SAAS,QACX;EAEA,WAAW;GACT,SAAS;GACT,eAAe;EACjB;CACF;AACF;AAEA,SAAgB,iBAAiB,OAAkE;CACjG,IAAM,EAAC,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AAA,IACdG,EAAAA,MAAAA,8BADFC;AAWJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1086,6 +1086,7 @@ interface TextAreaProps extends ResponsiveRadiusProps {
|
|
|
1086
1086
|
/**
|
|
1087
1087
|
* A multiline text input.
|
|
1088
1088
|
*
|
|
1089
|
+
|
|
1089
1090
|
* @public
|
|
1090
1091
|
*/
|
|
1091
1092
|
export declare function TextArea(props: TextAreaProps & Omit<React.HTMLProps<HTMLTextAreaElement>, 'as'>): import("react").JSX.Element;
|