@foxford/ui 2.79.0 → 2.80.0-beta-d262988-20250924
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/components/Dropdown/Dropdown.js +1 -1
- package/components/Dropdown/Dropdown.js.map +1 -1
- package/components/Dropdown/Dropdown.mjs +1 -1
- package/components/Dropdown/Dropdown.mjs.map +1 -1
- package/components/Dropdown/DropdownMenu.js +1 -1
- package/components/Dropdown/DropdownMenu.js.map +1 -1
- package/components/Dropdown/DropdownMenu.mjs +1 -1
- package/components/Dropdown/DropdownMenu.mjs.map +1 -1
- package/components/Dropdown/constants.js +1 -1
- package/components/Dropdown/constants.js.map +1 -1
- package/components/Dropdown/constants.mjs +1 -1
- package/components/Dropdown/constants.mjs.map +1 -1
- package/components/Dropdown/sizes.js +2 -0
- package/components/Dropdown/sizes.js.map +1 -0
- package/components/Dropdown/sizes.mjs +2 -0
- package/components/Dropdown/sizes.mjs.map +1 -0
- package/components/Dropdown/style.js.map +1 -1
- package/components/Dropdown/style.mjs.map +1 -1
- package/dts/index.d.ts +448 -237
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.mjs","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useState, useRef, useEffect, useLayoutEffect, useMemo, useCallback } from 'react'\nimport { nanoid } from 'nanoid'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useScrollMonitor } from 'hooks/useScrollMonitor'\nimport { focusFirstFocusable, focusLastFocusable } from 'shared/utils/dom'\nimport { createDebouncedCallback } from 'shared/utils/misc'\nimport { keyboardKeys } from 'shared/constants'\nimport type { Nullable } from 'shared/types'\nimport { FormInput } from 'components/FormInput'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { MenuList } from 'components/MenuList'\nimport { MenuDivider } from 'components/MenuDivider'\nimport { ListItem } from 'components/ListItem'\nimport { InputCheckbox } from 'components/InputCheckbox'\nimport { Chip } from 'components/Chip'\nimport { IconButton } from 'components/IconButton'\nimport type { IconProps } from 'components/Icon'\nimport { DropdownMenu } from './DropdownMenu'\nimport { useFilteredOptions, useLoadedOptions } from './hooks'\nimport { SIZES, SIZES_CHECKBOX, SIZES_ICON } from './constants'\nimport { getDropdownInputText, getDropdownSelectedOption, groupDropdownOptions } from './utils'\nimport * as Styled from './style'\nimport type { DropdownProps, DropdownOption } from './types'\n\nconst COMPONENT_NAME = 'Dropdown'\n\n/**\n *\n * Компонент поддерживает все атрибуты \\<div\\> элемента.\n *\n * Можно передать \"ref\", который будет ассоциирован с рутовым элементом.\n *\n * Поддерживаются пропсы определения размеров и внешних отступов в зависимости от ширины вьюпорта.\n *\n * Полный интерфейс можно посмотреть [тут](https://github.com/foxford/ui/blob/master/packages/ui/src/components/Dropdown/types.ts).\n */\nconst Dropdown: React.ForwardRefExoticComponent<DropdownProps> = withMergedProps<DropdownProps, HTMLDivElement>(\n forwardRef<HTMLDivElement, MergedProps<DropdownProps>>((props, ref) => {\n const {\n size = 'm',\n name = 'fox-dropdown',\n labelPosition = 'dynamic',\n searchable = true,\n primary = true,\n optionsMultiToggle = true,\n iconProps = {},\n menuProps = {},\n loadingIconProps = {},\n optionsEmptyIconProps = {},\n loading,\n autoFocus,\n disableAutoScrollToSelectedOption,\n closeMenuOnScroll,\n scrollMonitorTarget,\n contrast,\n selectedOption,\n defaultSelectedOption,\n icon,\n inputMode,\n loadingMessage,\n loadingIcon,\n maxLength,\n multiple,\n clearable,\n onChangeInput,\n onCloseMenu,\n onOpenMenu,\n onSelectOption,\n options,\n loadOptions,\n groupSelectedOptions,\n optionsMultiToggleCaption,\n optionsEmptyMessage,\n optionsEmptyIcon,\n palette,\n placeholder,\n readOnly,\n required,\n status,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n form,\n ...rootProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const iconBaseProps: IconProps = {\n sizes: SIZES_ICON,\n color: rootProps.disabled ? 'content-disabled' : 'content-onmain-tertiary',\n }\n\n const formInputLabelId = useMemo(() => rootProps.id ?? `${name}-${nanoid()}`, [name, rootProps.id])\n const inputLabelId = useMemo(() => nanoid(), [])\n const menuListId = useMemo(() => nanoid(), [])\n\n const [filteredOptions, getFilteredOptions] = useFilteredOptions({\n options,\n })\n\n const [loadedOptions, optionsLoading, getLoadedOptions] = useLoadedOptions({\n loadOptions,\n options,\n })\n\n const [dropdownSelectedOption, setDropdownSelectedOption] = useState<DropdownOption[]>(() =>\n getDropdownSelectedOption(selectedOption !== undefined ? selectedOption : defaultSelectedOption, multiple)\n )\n\n const [inputText, setInputText] = useState<string>(() => getDropdownInputText(dropdownSelectedOption, multiple))\n\n const [focusWithin, setFocusWithin] = useState<boolean>(false)\n\n const [menuOpenRequest, setMenuOpenRequest] = useState<boolean>(false)\n\n const menuOptions: DropdownOption[] = loadOptions ? loadedOptions : filteredOptions\n const menuOptionsLoading = loadOptions ? (loading ?? optionsLoading) : loading\n\n const menuOptionsGroups: ReturnType<typeof groupDropdownOptions> = useMemo(\n () => (multiple ? groupDropdownOptions(menuOptions, dropdownSelectedOption) : [[], []]),\n [multiple, menuOptions, dropdownSelectedOption]\n )\n\n const menuOpen = menuOpenRequest && !rootProps.disabled\n\n const inputRequired = required && dropdownSelectedOption.length === 0\n const inputActive = Boolean(menuOpen || inputText || focusWithin)\n\n const multiToggleChecked = menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length === 0\n const multiToggleIndeterminate = menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length > 0\n\n const inputRef = useRef<HTMLInputElement>(null)\n const [menuRef, setMenuRef] = useState<Nullable<HTMLElement>>(null)\n const menuListRef = useRef<HTMLUListElement>(null)\n const selectedOptionRef = useRef<HTMLElement>(null)\n const menuOpenPrevRef = useRef<boolean>(menuOpen)\n\n const updateInputText = useCallback(\n (inputTextValue: string) => {\n setInputText(inputTextValue)\n\n if (onChangeInput) {\n onChangeInput(inputTextValue)\n }\n },\n [onChangeInput]\n )\n\n const updateOptions = useCallback(\n (inputTextValue: string) => {\n if (loadOptions) {\n getLoadedOptions(inputTextValue)\n } else {\n getFilteredOptions(inputTextValue)\n }\n },\n [loadOptions, getLoadedOptions, getFilteredOptions]\n )\n\n const updateOptionsDebounced = useMemo(() => {\n return createDebouncedCallback(updateOptions, 150)\n }, [updateOptions])\n\n const preventBlur = (evt: React.PointerEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (\n evt.target !== inputRef.current &&\n evt.target instanceof Node &&\n (evt.currentTarget.contains(evt.target) ||\n (menuProps.renderInPortal && menuOpen && menuRef && menuRef.contains(evt.target)))\n ) {\n evt.preventDefault()\n }\n }\n\n useScrollMonitor({\n target: scrollMonitorTarget,\n onScrollStart: () => {\n if (closeMenuOnScroll && menuOpen) {\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n },\n })\n\n useLayoutEffect(() => {\n if (selectedOption === undefined) return\n\n if (!multiple && !menuOpen) {\n updateInputText(getDropdownInputText(selectedOption))\n }\n setDropdownSelectedOption(getDropdownSelectedOption(selectedOption, multiple))\n }, [multiple, selectedOption, menuOpen, updateInputText])\n\n useEffect(() => {\n if (menuOpen === menuOpenPrevRef.current) return\n\n if (menuOpen && onOpenMenu) onOpenMenu()\n if (!menuOpen && onCloseMenu) onCloseMenu()\n\n menuOpenPrevRef.current = menuOpen\n }, [menuOpen, onCloseMenu, onOpenMenu])\n\n useEffect(() => {\n if (\n !multiple &&\n !disableAutoScrollToSelectedOption &&\n menuOpen &&\n !menuOptionsLoading &&\n inputText.length === 0 &&\n menuRef &&\n selectedOptionRef.current\n ) {\n const menuRect = menuRef.getBoundingClientRect()\n const selectedOptionRect = selectedOptionRef.current.getBoundingClientRect()\n\n if (selectedOptionRect.top < menuRect.top || selectedOptionRect.bottom > menuRect.bottom) {\n setTimeout(() => {\n if (menuRef && selectedOptionRef.current) {\n menuRef.scrollTo(0, selectedOptionRef.current.offsetTop)\n }\n }, 0)\n }\n }\n }, [multiple, disableAutoScrollToSelectedOption, menuOpen, menuOptionsLoading, inputText, menuRef])\n\n return (\n <FormInputLabel\n {...rootProps}\n {...sizeProps}\n ref={ref}\n id={formInputLabelId}\n labelId={inputLabelId}\n labelPosition={labelPosition}\n active={inputActive}\n onColored={contrast}\n primary={primary}\n error={status === 'error'}\n success={status === 'success'}\n focus={focusWithin}\n icon={[icon, <Styled.ChevronIcon key='chevron' up={menuOpen} />]}\n iconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...iconProps,\n }}\n palette={{\n color: rootProps.disabled ? palette.labelColorDisabled : palette.labelColor,\n backgroundColor: rootProps.disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: rootProps.disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: rootProps.disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n onClick={(evt) => {\n if (rootProps.onClick) rootProps.onClick(evt)\n\n if (rootProps.disabled) return\n\n inputRef.current?.focus()\n\n if (!menuOpen) {\n setMenuOpenRequest(true)\n\n updateOptions('')\n if (searchable) {\n updateInputText('')\n }\n } else if (menuRef && evt.target instanceof Node && !menuRef.contains(evt.target)) {\n setMenuOpenRequest(false)\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n }\n }}\n onPointerDown={(evt) => {\n if (rootProps.onPointerDown) rootProps.onPointerDown(evt)\n\n preventBlur(evt)\n }}\n onMouseDown={(evt) => {\n if (rootProps.onMouseDown) rootProps.onMouseDown(evt)\n\n if (!window.PointerEvent) preventBlur(evt)\n }}\n onFocus={(evt) => {\n if (rootProps.onFocus) rootProps.onFocus(evt)\n\n setFocusWithin(true)\n\n if (inputRef.current && evt.target === inputRef.current && searchable && !multiple && !menuOpen) {\n updateInputText('')\n }\n }}\n onBlur={(evt) => {\n if (rootProps.onBlur) rootProps.onBlur(evt)\n\n if (\n evt.currentTarget.contains(evt.relatedTarget) ||\n (menuProps.renderInPortal && menuOpen && menuRef && menuRef.contains(evt.relatedTarget))\n ) {\n return\n }\n\n setFocusWithin(false)\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }}\n input={\n <>\n {inputRequired && !searchable && !readOnly ? (\n <Styled.InputMimic\n required\n type='text'\n inputMode='none'\n form={form}\n tabIndex={-1}\n onFocus={() => {\n inputRef.current?.focus()\n }}\n />\n ) : null}\n <FormInput\n ref={inputRef}\n role='combobox'\n aria-controls={menuListId}\n aria-expanded={menuOpen}\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n type='text'\n autoComplete='off'\n autoCapitalize='off'\n autoCorrect='off'\n spellCheck='false'\n form={form}\n autoFocus={autoFocus}\n inputMode={searchable ? inputMode : 'none'}\n maxLength={maxLength}\n placeholder={placeholder}\n readOnly={readOnly || !searchable}\n required={inputRequired}\n disabled={rootProps.disabled}\n value={inputText}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n onClick={(evt) => {\n if (menuOpen && evt.currentTarget.selectionStart !== evt.currentTarget.selectionEnd) {\n evt.stopPropagation()\n }\n }}\n onChange={(evt) => {\n const inputValue = evt.currentTarget.value\n\n updateInputText(inputValue)\n updateOptionsDebounced(inputValue)\n setMenuOpenRequest(true)\n }}\n onKeyDown={(evt) => {\n if (keyboardKeys.Enter.validate(evt.key)) {\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Space.validate(evt.key) && (!menuOpen || evt.currentTarget.selectionStart === 0)) {\n evt.preventDefault()\n\n if (!menuOpen) {\n updateOptions('')\n if (searchable) {\n updateInputText('')\n }\n }\n\n setMenuOpenRequest((prev) => !prev)\n }\n\n if (keyboardKeys.Esc.validate(evt.key)) {\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Tab.validate(evt.key) && menuOpen) {\n evt.preventDefault()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.ArrowDown.validate(evt.key) && menuOpen && menuListRef.current) {\n evt.preventDefault()\n\n if (!multiple && selectedOptionRef.current) {\n const menuItems = [...menuListRef.current.children]\n\n const idx = menuItems.findIndex((item) => item.contains(selectedOptionRef.current as Node))\n\n const focusTarget = menuItems[idx + 1] ?? menuItems[0]\n\n if (focusTarget instanceof HTMLElement) {\n focusFirstFocusable(focusTarget)\n }\n } else {\n focusFirstFocusable(menuListRef.current)\n }\n }\n\n if (keyboardKeys.ArrowUp.validate(evt.key) && menuOpen && menuListRef.current) {\n evt.preventDefault()\n\n if (!multiple && selectedOptionRef.current) {\n const menuItems = [...menuListRef.current.children]\n\n const idx = menuItems.findIndex((item) => item.contains(selectedOptionRef.current as Node))\n\n const focusTarget = menuItems[idx - 1] ?? menuItems[menuItems.length - 1]\n\n if (focusTarget instanceof HTMLElement) {\n focusFirstFocusable(focusTarget)\n }\n } else {\n focusLastFocusable(menuListRef.current)\n }\n }\n }}\n />\n {dropdownSelectedOption.map((item) => (\n <input\n key={item.value}\n type='hidden'\n name={name}\n value={item.value}\n form={form}\n disabled={rootProps.disabled}\n />\n ))}\n </>\n }\n addon={\n <>\n {multiple && dropdownSelectedOption.length > 0 ? (\n <Chip\n size='xs'\n active\n black\n marginLeft={12}\n disabled={rootProps.disabled}\n cursor={rootProps.disabled ? 'not-allowed' : undefined}\n text={dropdownSelectedOption.length}\n textProps={{\n appearance: 'caption',\n size: 'xs',\n }}\n palette={\n rootProps.disabled\n ? {\n color: 'content-disabled',\n colorHover: 'content-disabled',\n backgroundColor: 'bg-disabled-small',\n backgroundColorHover: 'bg-disabled-small',\n }\n : undefined\n }\n onPointerDown={(evt) => {\n evt.preventDefault()\n }}\n onMouseDown={(evt) => {\n if (!window.PointerEvent) evt.preventDefault()\n }}\n discardButtonProps={{\n square: true,\n contrast: !rootProps.disabled,\n onClick: (evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption([])\n\n inputRef.current?.focus()\n updateInputText('')\n updateOptions('')\n setMenuOpenRequest(true)\n }\n },\n }}\n />\n ) : null}\n {!multiple && clearable && dropdownSelectedOption.length > 0 ? (\n <IconButton\n icon='close'\n size='l'\n square\n marginLeft={12}\n disabled={rootProps.disabled}\n onClick={(evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption(null)\n\n inputRef.current?.focus()\n updateInputText('')\n updateOptions('')\n setMenuOpenRequest(true)\n }\n }}\n />\n ) : null}\n </>\n }\n dropdown={\n <DropdownMenu\n {...menuProps}\n setRef={setMenuRef}\n open={menuOpen}\n popperReferenceId={formInputLabelId}\n secondary={!contrast}\n elevated={contrast}\n disableAutoFocus\n palette={{\n backgroundColor: palette.menuBackgroundColor,\n borderColor: palette.menuBorderColor,\n }}\n empty={menuOptions.length === 0}\n loading={menuOptionsLoading}\n loadingMessage={loadingMessage}\n loadingIcon={loadingIcon}\n loadingIconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...loadingIconProps,\n }}\n emptyMessage={optionsEmptyMessage}\n emptyIcon={optionsEmptyIcon}\n emptyIconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...optionsEmptyIconProps,\n }}\n onKeyDown={(evt) => {\n if (keyboardKeys.Tab.validate(evt.key)) {\n evt.preventDefault()\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Enter.validate(evt.key)) {\n inputRef.current?.focus()\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Esc.validate(evt.key)) {\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Backspace.validate(evt.key) && !readOnly && (multiple || (!multiple && clearable))) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption(multiple ? [] : null)\n\n updateInputText('')\n updateOptions('')\n }\n }}\n >\n {multiple ? (\n <MenuList\n ref={menuListRef}\n id={menuListId}\n role='listbox'\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n aria-multiselectable\n >\n {inputText.length === 0 ? (\n <>\n {optionsMultiToggle ? (\n <ListItem\n {...sizeProps}\n text={optionsMultiToggleCaption}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n name={name}\n checked={multiToggleChecked}\n indeterminate={multiToggleIndeterminate}\n error={Boolean((multiToggleChecked || multiToggleIndeterminate) && status === 'error')}\n success={Boolean((multiToggleChecked || multiToggleIndeterminate) && status === 'success')}\n onChange={() => {\n if (!readOnly) {\n const update = multiToggleChecked || multiToggleIndeterminate ? [] : [...menuOptions]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n ) : null}\n {optionsMultiToggle ? <MenuDivider /> : null}\n {groupSelectedOptions\n ? menuOptionsGroups[0].map((option) => {\n const optionStatus = option.status ?? status\n const optionErrorStatus = optionStatus === 'error'\n const optionSuccessStatus = optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n active\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n inputRef.current?.focus()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected\n name={name}\n value={option.value}\n checked\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = dropdownSelectedOption.filter(\n (item) => item.value !== evt.currentTarget.value\n )\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })\n : null}\n {groupSelectedOptions && menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length > 0 ? (\n <MenuDivider />\n ) : null}\n {groupSelectedOptions\n ? menuOptionsGroups[1].map((option) => (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n inputRef.current?.focus()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={false}\n name={name}\n value={option.value}\n checked={false}\n onChange={() => {\n if (!readOnly) {\n const update = [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n ))\n : null}\n {!groupSelectedOptions &&\n menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n const optionStatus = option.status ?? status\n const optionErrorStatus = selected && optionStatus === 'error'\n const optionSuccessStatus = selected && optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled}\n active={selected}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={selected}\n name={name}\n value={option.value}\n checked={selected}\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = selected\n ? dropdownSelectedOption.filter((item) => item.value !== evt.currentTarget.value)\n : [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })}\n </>\n ) : (\n <>\n {menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n const optionStatus = option.status ?? status\n const optionErrorStatus = selected && optionStatus === 'error'\n const optionSuccessStatus = selected && optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled}\n active={selected}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={selected}\n name={name}\n value={option.value}\n checked={selected}\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = selected\n ? dropdownSelectedOption.filter((item) => item.value !== evt.currentTarget.value)\n : [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })}\n </>\n )}\n </MenuList>\n ) : (\n <MenuList\n ref={menuListRef}\n id={menuListId}\n role='listbox'\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n >\n {menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n return (\n <ListItem\n {...sizeProps}\n role='option'\n aria-selected={selected}\n ref={selected ? selectedOptionRef : undefined}\n key={option.value}\n text={option.text}\n active={selected}\n danger={Boolean(selected && status === 'error')}\n success={Boolean(selected && status === 'success')}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n const update = { ...option }\n\n if (selectedOption === undefined) {\n updateInputText(getDropdownInputText(update))\n setDropdownSelectedOption(getDropdownSelectedOption(update))\n }\n\n if (onSelectOption) onSelectOption(update)\n\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n }}\n />\n )\n })}\n </MenuList>\n )}\n </DropdownMenu>\n }\n />\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { Dropdown, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Dropdown","withMergedProps","forwardRef","props","ref","size","name","labelPosition","searchable","primary","optionsMultiToggle","iconProps","menuProps","loadingIconProps","optionsEmptyIconProps","loading","autoFocus","disableAutoScrollToSelectedOption","closeMenuOnScroll","scrollMonitorTarget","contrast","selectedOption","defaultSelectedOption","icon","inputMode","loadingMessage","loadingIcon","maxLength","multiple","clearable","onChangeInput","onCloseMenu","onOpenMenu","onSelectOption","options","loadOptions","groupSelectedOptions","optionsMultiToggleCaption","optionsEmptyMessage","optionsEmptyIcon","palette","placeholder","readOnly","required","status","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","form","rootProps","sizeProps","iconBaseProps","sizes","SIZES_ICON","color","disabled","formInputLabelId","useMemo","id","nanoid","inputLabelId","menuListId","filteredOptions","getFilteredOptions","useFilteredOptions","loadedOptions","optionsLoading","getLoadedOptions","useLoadedOptions","dropdownSelectedOption","setDropdownSelectedOption","useState","getDropdownSelectedOption","undefined","inputText","setInputText","getDropdownInputText","focusWithin","setFocusWithin","menuOpenRequest","setMenuOpenRequest","menuOptions","menuOptionsLoading","menuOptionsGroups","groupDropdownOptions","menuOpen","inputRequired","length","inputActive","Boolean","multiToggleChecked","multiToggleIndeterminate","inputRef","useRef","menuRef","setMenuRef","menuListRef","selectedOptionRef","menuOpenPrevRef","updateInputText","useCallback","inputTextValue","updateOptions","updateOptionsDebounced","createDebouncedCallback","preventBlur","evt","target","current","Node","currentTarget","contains","renderInPortal","preventDefault","useScrollMonitor","onScrollStart","focus","useLayoutEffect","useEffect","menuRect","getBoundingClientRect","selectedOptionRect","top","bottom","setTimeout","scrollTo","offsetTop","_jsx","FormInputLabel","labelId","active","onColored","error","success","Styled","up","labelColorDisabled","labelColor","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","onPointerDown","onMouseDown","window","PointerEvent","onFocus","onBlur","relatedTarget","input","_jsxs","_Fragment","children","type","tabIndex","FormInput","role","label","autoComplete","autoCapitalize","autoCorrect","spellCheck","value","colorDisabled","placeholderColor","placeholderColorDisabled","selectionStart","selectionEnd","stopPropagation","onChange","inputValue","onKeyDown","keyboardKeys","Enter","validate","key","Space","prev","Esc","Tab","ArrowDown","menuItems","idx","findIndex","item","focusTarget","HTMLElement","focusFirstFocusable","ArrowUp","focusLastFocusable","map","addon","Chip","black","marginLeft","cursor","text","textProps","appearance","colorHover","discardButtonProps","square","IconButton","dropdown","DropdownMenu","setRef","open","popperReferenceId","secondary","elevated","disableAutoFocus","menuBackgroundColor","menuBorderColor","empty","emptyMessage","emptyIcon","emptyIconProps","Backspace","MenuList","ListItem","borderRadius","ellipsis","wordBreak","control","InputCheckbox","SIZES_CHECKBOX","checked","indeterminate","update","MenuDivider","option","optionStatus","optionErrorStatus","optionSuccessStatus","_createElement","danger","filter","selected","SIZES","displayName"],"mappings":"ysCAyBMA,MAAAA,eAAiB,WAYjBC,MAAAA,SAA2DC,gBAC/DC,YAAuD,CAACC,EAAOC,KAC7D,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,eAAcC,cACrBA,EAAgB,UAASC,WACzBA,GAAa,EAAIC,QACjBA,GAAU,EAAIC,mBACdA,GAAqB,EAAIC,UACzBA,EAAY,CAAE,EAAAC,UACdA,EAAY,CAAE,EAAAC,iBACdA,EAAmB,CAAE,EAAAC,sBACrBA,EAAwB,CAAE,EAAAC,QAC1BA,EAAOC,UAC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A0BgK,GAGxBxM,GAAgBA,EAAewM,EACrC,MAIN,OAOH,CACPrO,IAAK+F,GACLtC,GAAIG,GACJiG,KAAK,UACL,kBAAiB7G,EAAU8G,MAAQnG,OAAea,EAAUiF,SAE3DzE,GAAY+G,KAAKwC,IAChB,MAAMO,EAAW1K,GAAuBoH,WAAWC,GAASA,EAAKtB,QAAUoE,EAAOpE,WAAY,EAE9F,OACEwE,cAACf,SAAQ,IACH3K,EACJ4G,KAAK,SACL,gBAAeiF,EACf9O,IAAK8O,EAAW9I,QAAoBxB,EACpCwG,IAAKuD,EAAOpE,MACZkC,KAAMkC,EAAOlC,KACbpE,OAAQ6G,EACRF,OAAQpJ,QAAQsJ,GAAYtM,IAAW,SACvC4F,QAAS5C,QAAQsJ,GAAYtM,IAAW,WACxCc,SAAUN,EAAUM,SACpBuK,aAAc,EACdC,UAAU,EACVxB,UAAW,CAAEyB,UAAW,cACxBjF,QAAUrC,IAGR,GAFAA,EAAIgE,mBAECnI,EAAU,CACb,MAAM+L,EAAS,IAAKE,GAEhBtN,SAAmBuD,IACrB0B,GAAgBvB,qBAAqB0J,IACrChK,GAA0BE,0BAA0B8J,KAGlDxM,GAAgBA,EAAewM,GAEnC1I,GAASgB,SAASQ,QAClBpC,IAAmB,EACrB,IAEF,SAOd,IAGN,CACE5B,MAAO4L,MACPC,YA91BmB"}
|
|
1
|
+
{"version":3,"file":"Dropdown.mjs","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import { forwardRef, useState, useRef, useEffect, useLayoutEffect, useMemo, useCallback } from 'react'\nimport { nanoid } from 'nanoid'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport type { MergedProps } from 'hocs/withMergedProps'\nimport { useScrollMonitor } from 'hooks/useScrollMonitor'\nimport { focusFirstFocusable, focusLastFocusable } from 'shared/utils/dom'\nimport { createDebouncedCallback } from 'shared/utils/misc'\nimport { keyboardKeys } from 'shared/constants'\nimport type { Nullable } from 'shared/types'\nimport { FormInput } from 'components/FormInput'\nimport { FormInputLabel } from 'components/FormInputLabel'\nimport { MenuList } from 'components/MenuList'\nimport { MenuDivider } from 'components/MenuDivider'\nimport { ListItem } from 'components/ListItem'\nimport { InputCheckbox } from 'components/InputCheckbox'\nimport { Chip } from 'components/Chip'\nimport { IconButton } from 'components/IconButton'\nimport type { IconProps } from 'components/Icon'\nimport { DropdownMenu } from './DropdownMenu'\nimport { useFilteredOptions, useLoadedOptions } from './hooks'\nimport { SIZES, SIZES_CHECKBOX, SIZES_ICON } from './sizes'\nimport { getDropdownInputText, getDropdownSelectedOption, groupDropdownOptions } from './utils'\nimport * as Styled from './style'\nimport type { DropdownProps, DropdownOption } from './types'\n\nconst COMPONENT_NAME = 'Dropdown'\n\n/**\n *\n * Компонент для выбора одной или нескольких опций из числа доступных.\n *\n * Поддерживается \"ref\" и все нативные атрибуты \\<div\\> элемента.\n */\nconst Dropdown: React.ForwardRefExoticComponent<DropdownProps> = withMergedProps<DropdownProps, HTMLDivElement>(\n forwardRef<HTMLDivElement, MergedProps<DropdownProps>>((props, ref) => {\n const {\n size = 'm',\n name = 'fox-dropdown',\n labelPosition = 'dynamic',\n searchable = true,\n primary = true,\n optionsMultiToggle = true,\n iconProps = {},\n menuProps = {},\n loadingIconProps = {},\n optionsEmptyIconProps = {},\n loading,\n autoFocus,\n disableAutoScrollToSelectedOption,\n closeMenuOnScroll,\n scrollMonitorTarget,\n contrast,\n selectedOption,\n defaultSelectedOption,\n icon,\n inputMode,\n loadingMessage,\n loadingIcon,\n maxLength,\n multiple,\n clearable,\n onChangeInput,\n onCloseMenu,\n onOpenMenu,\n onSelectOption,\n options,\n loadOptions,\n groupSelectedOptions,\n optionsMultiToggleCaption,\n optionsEmptyMessage,\n optionsEmptyIcon,\n palette,\n placeholder,\n readOnly,\n required,\n status,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n form,\n ...rootProps\n } = props\n\n const sizeProps = {\n size,\n sizeXXS,\n sizeXS,\n sizeS,\n sizeM,\n sizeL,\n sizeXL,\n }\n\n const iconBaseProps: IconProps = {\n sizes: SIZES_ICON,\n color: rootProps.disabled ? 'content-disabled' : 'content-onmain-tertiary',\n }\n\n const formInputLabelId = useMemo(() => rootProps.id ?? `${name}-${nanoid()}`, [name, rootProps.id])\n const inputLabelId = useMemo(() => nanoid(), [])\n const menuListId = useMemo(() => nanoid(), [])\n\n const [filteredOptions, getFilteredOptions] = useFilteredOptions({\n options,\n })\n\n const [loadedOptions, optionsLoading, getLoadedOptions] = useLoadedOptions({\n loadOptions,\n options,\n })\n\n const [dropdownSelectedOption, setDropdownSelectedOption] = useState<DropdownOption[]>(() =>\n getDropdownSelectedOption(selectedOption !== undefined ? selectedOption : defaultSelectedOption, multiple)\n )\n\n const [inputText, setInputText] = useState<string>(() => getDropdownInputText(dropdownSelectedOption, multiple))\n\n const [focusWithin, setFocusWithin] = useState<boolean>(false)\n\n const [menuOpenRequest, setMenuOpenRequest] = useState<boolean>(false)\n\n const menuOptions: DropdownOption[] = loadOptions ? loadedOptions : filteredOptions\n const menuOptionsLoading = loadOptions ? (loading ?? optionsLoading) : loading\n\n const menuOptionsGroups: ReturnType<typeof groupDropdownOptions> = useMemo(\n () => (multiple ? groupDropdownOptions(menuOptions, dropdownSelectedOption) : [[], []]),\n [multiple, menuOptions, dropdownSelectedOption]\n )\n\n const menuOpen = menuOpenRequest && !rootProps.disabled\n\n const inputRequired = required && dropdownSelectedOption.length === 0\n const inputActive = Boolean(menuOpen || inputText || focusWithin)\n\n const multiToggleChecked = menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length === 0\n const multiToggleIndeterminate = menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length > 0\n\n const inputRef = useRef<HTMLInputElement>(null)\n const [menuRef, setMenuRef] = useState<Nullable<HTMLElement>>(null)\n const menuListRef = useRef<HTMLUListElement>(null)\n const selectedOptionRef = useRef<HTMLElement>(null)\n const menuOpenPrevRef = useRef<boolean>(menuOpen)\n\n const updateInputText = useCallback(\n (inputTextValue: string) => {\n setInputText(inputTextValue)\n\n if (onChangeInput) {\n onChangeInput(inputTextValue)\n }\n },\n [onChangeInput]\n )\n\n const updateOptions = useCallback(\n (inputTextValue: string) => {\n if (loadOptions) {\n getLoadedOptions(inputTextValue)\n } else {\n getFilteredOptions(inputTextValue)\n }\n },\n [loadOptions, getLoadedOptions, getFilteredOptions]\n )\n\n const updateOptionsDebounced = useMemo(() => {\n return createDebouncedCallback(updateOptions, 150)\n }, [updateOptions])\n\n const preventBlur = (evt: React.PointerEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement, MouseEvent>) => {\n if (\n evt.target !== inputRef.current &&\n evt.target instanceof Node &&\n (evt.currentTarget.contains(evt.target) ||\n (menuProps.renderInPortal && menuOpen && menuRef && menuRef.contains(evt.target)))\n ) {\n evt.preventDefault()\n }\n }\n\n useScrollMonitor({\n target: scrollMonitorTarget,\n onScrollStart: () => {\n if (closeMenuOnScroll && menuOpen) {\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n },\n })\n\n useLayoutEffect(() => {\n if (selectedOption === undefined) return\n\n if (!multiple && !menuOpen) {\n updateInputText(getDropdownInputText(selectedOption))\n }\n setDropdownSelectedOption(getDropdownSelectedOption(selectedOption, multiple))\n }, [multiple, selectedOption, menuOpen, updateInputText])\n\n useEffect(() => {\n if (menuOpen === menuOpenPrevRef.current) return\n\n if (menuOpen && onOpenMenu) onOpenMenu()\n if (!menuOpen && onCloseMenu) onCloseMenu()\n\n menuOpenPrevRef.current = menuOpen\n }, [menuOpen, onCloseMenu, onOpenMenu])\n\n useEffect(() => {\n if (\n !multiple &&\n !disableAutoScrollToSelectedOption &&\n menuOpen &&\n !menuOptionsLoading &&\n inputText.length === 0 &&\n menuRef &&\n selectedOptionRef.current\n ) {\n const menuRect = menuRef.getBoundingClientRect()\n const selectedOptionRect = selectedOptionRef.current.getBoundingClientRect()\n\n if (selectedOptionRect.top < menuRect.top || selectedOptionRect.bottom > menuRect.bottom) {\n setTimeout(() => {\n if (menuRef && selectedOptionRef.current) {\n menuRef.scrollTo(0, selectedOptionRef.current.offsetTop)\n }\n }, 0)\n }\n }\n }, [multiple, disableAutoScrollToSelectedOption, menuOpen, menuOptionsLoading, inputText, menuRef])\n\n return (\n <FormInputLabel\n {...rootProps}\n {...sizeProps}\n ref={ref}\n id={formInputLabelId}\n labelId={inputLabelId}\n labelPosition={labelPosition}\n active={inputActive}\n onColored={contrast}\n primary={primary}\n error={status === 'error'}\n success={status === 'success'}\n focus={focusWithin}\n icon={[icon, <Styled.ChevronIcon key='chevron' up={menuOpen} />]}\n iconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...iconProps,\n }}\n palette={{\n color: rootProps.disabled ? palette.labelColorDisabled : palette.labelColor,\n backgroundColor: rootProps.disabled ? palette.backgroundColorDisabled : palette.backgroundColor,\n backgroundColorHover: rootProps.disabled ? palette.backgroundColorDisabled : palette.backgroundColorHover,\n borderColor: rootProps.disabled ? palette.borderColorDisabled : palette.borderColor,\n }}\n onClick={(evt) => {\n if (rootProps.onClick) rootProps.onClick(evt)\n\n if (rootProps.disabled) return\n\n inputRef.current?.focus()\n\n if (!menuOpen) {\n setMenuOpenRequest(true)\n\n updateOptions('')\n if (searchable) {\n updateInputText('')\n }\n } else if (menuRef && evt.target instanceof Node && !menuRef.contains(evt.target)) {\n setMenuOpenRequest(false)\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n }\n }}\n onPointerDown={(evt) => {\n if (rootProps.onPointerDown) rootProps.onPointerDown(evt)\n\n preventBlur(evt)\n }}\n onMouseDown={(evt) => {\n if (rootProps.onMouseDown) rootProps.onMouseDown(evt)\n\n if (!window.PointerEvent) preventBlur(evt)\n }}\n onFocus={(evt) => {\n if (rootProps.onFocus) rootProps.onFocus(evt)\n\n setFocusWithin(true)\n\n if (inputRef.current && evt.target === inputRef.current && searchable && !multiple && !menuOpen) {\n updateInputText('')\n }\n }}\n onBlur={(evt) => {\n if (rootProps.onBlur) rootProps.onBlur(evt)\n\n if (\n evt.currentTarget.contains(evt.relatedTarget) ||\n (menuProps.renderInPortal && menuOpen && menuRef && menuRef.contains(evt.relatedTarget))\n ) {\n return\n }\n\n setFocusWithin(false)\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }}\n input={\n <>\n {inputRequired && !searchable && !readOnly ? (\n <Styled.InputMimic\n required\n type='text'\n inputMode='none'\n form={form}\n tabIndex={-1}\n onFocus={() => {\n inputRef.current?.focus()\n }}\n />\n ) : null}\n <FormInput\n ref={inputRef}\n role='combobox'\n aria-controls={menuListId}\n aria-expanded={menuOpen}\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n type='text'\n autoComplete='off'\n autoCapitalize='off'\n autoCorrect='off'\n spellCheck='false'\n form={form}\n autoFocus={autoFocus}\n inputMode={searchable ? inputMode : 'none'}\n maxLength={maxLength}\n placeholder={placeholder}\n readOnly={readOnly || !searchable}\n required={inputRequired}\n disabled={rootProps.disabled}\n value={inputText}\n palette={{\n color: palette.color,\n colorDisabled: palette.colorDisabled,\n placeholderColor: palette.placeholderColor,\n placeholderColorDisabled: palette.placeholderColorDisabled,\n }}\n onClick={(evt) => {\n if (menuOpen && evt.currentTarget.selectionStart !== evt.currentTarget.selectionEnd) {\n evt.stopPropagation()\n }\n }}\n onChange={(evt) => {\n const inputValue = evt.currentTarget.value\n\n updateInputText(inputValue)\n updateOptionsDebounced(inputValue)\n setMenuOpenRequest(true)\n }}\n onKeyDown={(evt) => {\n if (keyboardKeys.Enter.validate(evt.key)) {\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Space.validate(evt.key) && (!menuOpen || evt.currentTarget.selectionStart === 0)) {\n evt.preventDefault()\n\n if (!menuOpen) {\n updateOptions('')\n if (searchable) {\n updateInputText('')\n }\n }\n\n setMenuOpenRequest((prev) => !prev)\n }\n\n if (keyboardKeys.Esc.validate(evt.key)) {\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Tab.validate(evt.key) && menuOpen) {\n evt.preventDefault()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.ArrowDown.validate(evt.key) && menuOpen && menuListRef.current) {\n evt.preventDefault()\n\n if (!multiple && selectedOptionRef.current) {\n const menuItems = [...menuListRef.current.children]\n\n const idx = menuItems.findIndex((item) => item.contains(selectedOptionRef.current as Node))\n\n const focusTarget = menuItems[idx + 1] ?? menuItems[0]\n\n if (focusTarget instanceof HTMLElement) {\n focusFirstFocusable(focusTarget)\n }\n } else {\n focusFirstFocusable(menuListRef.current)\n }\n }\n\n if (keyboardKeys.ArrowUp.validate(evt.key) && menuOpen && menuListRef.current) {\n evt.preventDefault()\n\n if (!multiple && selectedOptionRef.current) {\n const menuItems = [...menuListRef.current.children]\n\n const idx = menuItems.findIndex((item) => item.contains(selectedOptionRef.current as Node))\n\n const focusTarget = menuItems[idx - 1] ?? menuItems[menuItems.length - 1]\n\n if (focusTarget instanceof HTMLElement) {\n focusFirstFocusable(focusTarget)\n }\n } else {\n focusLastFocusable(menuListRef.current)\n }\n }\n }}\n />\n {dropdownSelectedOption.map((option) => (\n <input\n key={option.value}\n type='hidden'\n name={name}\n value={option.value}\n form={form}\n disabled={rootProps.disabled || option.disabled}\n />\n ))}\n </>\n }\n addon={\n <>\n {multiple && dropdownSelectedOption.length > 0 ? (\n <Chip\n size='xs'\n active\n black\n marginLeft={12}\n disabled={rootProps.disabled}\n cursor={rootProps.disabled ? 'not-allowed' : undefined}\n text={dropdownSelectedOption.length}\n textProps={{\n appearance: 'caption',\n size: 'xs',\n }}\n palette={\n rootProps.disabled\n ? {\n color: 'content-disabled',\n colorHover: 'content-disabled',\n backgroundColor: 'bg-disabled-small',\n backgroundColorHover: 'bg-disabled-small',\n }\n : undefined\n }\n onPointerDown={(evt) => {\n evt.preventDefault()\n }}\n onMouseDown={(evt) => {\n if (!window.PointerEvent) evt.preventDefault()\n }}\n discardButtonProps={{\n square: true,\n contrast: !rootProps.disabled,\n onClick: (evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption([])\n\n inputRef.current?.focus()\n updateInputText('')\n updateOptions('')\n setMenuOpenRequest(true)\n }\n },\n }}\n />\n ) : null}\n {!multiple && clearable && dropdownSelectedOption.length > 0 ? (\n <IconButton\n icon='close'\n size='l'\n square\n marginLeft={12}\n disabled={rootProps.disabled}\n onClick={(evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption(null)\n\n inputRef.current?.focus()\n updateInputText('')\n updateOptions('')\n setMenuOpenRequest(true)\n }\n }}\n />\n ) : null}\n </>\n }\n dropdown={\n <DropdownMenu\n {...menuProps}\n setRef={setMenuRef}\n open={menuOpen}\n popperReferenceId={formInputLabelId}\n secondary={!contrast}\n elevated={contrast}\n disableAutoFocus\n palette={{\n backgroundColor: palette.menuBackgroundColor,\n borderColor: palette.menuBorderColor,\n }}\n empty={menuOptions.length === 0}\n loading={menuOptionsLoading}\n loadingMessage={loadingMessage}\n loadingIcon={loadingIcon}\n loadingIconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...loadingIconProps,\n }}\n emptyMessage={optionsEmptyMessage}\n emptyIcon={optionsEmptyIcon}\n emptyIconProps={{\n ...sizeProps,\n ...iconBaseProps,\n ...optionsEmptyIconProps,\n }}\n onKeyDown={(evt) => {\n if (keyboardKeys.Tab.validate(evt.key)) {\n evt.preventDefault()\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Enter.validate(evt.key)) {\n inputRef.current?.focus()\n updateInputText(getDropdownInputText(dropdownSelectedOption, multiple))\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Esc.validate(evt.key)) {\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n\n if (keyboardKeys.Backspace.validate(evt.key) && !readOnly && (multiple || (!multiple && clearable))) {\n if (selectedOption === undefined) {\n setDropdownSelectedOption([])\n }\n\n if (onSelectOption) onSelectOption(multiple ? [] : null)\n\n updateInputText('')\n updateOptions('')\n }\n }}\n >\n {multiple ? (\n <MenuList\n ref={menuListRef}\n id={menuListId}\n role='listbox'\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n aria-multiselectable\n >\n {inputText.length === 0 ? (\n <>\n {optionsMultiToggle ? (\n <ListItem\n {...sizeProps}\n text={optionsMultiToggleCaption}\n disabled={rootProps.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n name={name}\n checked={multiToggleChecked}\n indeterminate={multiToggleIndeterminate}\n error={Boolean((multiToggleChecked || multiToggleIndeterminate) && status === 'error')}\n success={Boolean((multiToggleChecked || multiToggleIndeterminate) && status === 'success')}\n onChange={() => {\n if (!readOnly) {\n const update =\n multiToggleChecked || multiToggleIndeterminate\n ? dropdownSelectedOption.filter((option) => option.disabled)\n : menuOptions.filter((option) => !option.disabled)\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n ) : null}\n {optionsMultiToggle ? <MenuDivider /> : null}\n {groupSelectedOptions\n ? menuOptionsGroups[0].map((option) => {\n const optionStatus = option.status ?? status\n const optionErrorStatus = optionStatus === 'error'\n const optionSuccessStatus = optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n active\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled || option.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n inputRef.current?.focus()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected\n name={name}\n value={option.value}\n checked\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = dropdownSelectedOption.filter(\n (item) => item.value !== evt.currentTarget.value\n )\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })\n : null}\n {groupSelectedOptions && menuOptionsGroups[0].length > 0 && menuOptionsGroups[1].length > 0 ? (\n <MenuDivider />\n ) : null}\n {groupSelectedOptions\n ? menuOptionsGroups[1].map((option) => (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n disabled={rootProps.disabled || option.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n inputRef.current?.focus()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={false}\n name={name}\n value={option.value}\n checked={false}\n onChange={() => {\n if (!readOnly) {\n const update = [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n ))\n : null}\n {!groupSelectedOptions &&\n menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n const optionStatus = option.status ?? status\n const optionErrorStatus = selected && optionStatus === 'error'\n const optionSuccessStatus = selected && optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled || option.disabled}\n active={selected}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={selected}\n name={name}\n value={option.value}\n checked={selected}\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = selected\n ? dropdownSelectedOption.filter((item) => item.value !== evt.currentTarget.value)\n : [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })}\n </>\n ) : (\n <>\n {menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n const optionStatus = option.status ?? status\n const optionErrorStatus = selected && optionStatus === 'error'\n const optionSuccessStatus = selected && optionStatus === 'success'\n\n return (\n <ListItem\n {...sizeProps}\n key={option.value}\n text={option.text}\n danger={optionErrorStatus}\n success={optionSuccessStatus}\n disabled={rootProps.disabled || option.disabled}\n active={selected}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n }}\n control={\n <InputCheckbox\n sizes={SIZES_CHECKBOX}\n form='none'\n role='option'\n aria-selected={selected}\n name={name}\n value={option.value}\n checked={selected}\n error={optionErrorStatus}\n success={optionSuccessStatus}\n onChange={(evt) => {\n if (!readOnly) {\n const update = selected\n ? dropdownSelectedOption.filter((item) => item.value !== evt.currentTarget.value)\n : [...dropdownSelectedOption, option]\n\n if (selectedOption === undefined) {\n setDropdownSelectedOption(update)\n }\n\n if (onSelectOption) onSelectOption(update)\n }\n }}\n />\n }\n />\n )\n })}\n </>\n )}\n </MenuList>\n ) : (\n <MenuList\n ref={menuListRef}\n id={menuListId}\n role='listbox'\n aria-labelledby={rootProps.label ? inputLabelId : undefined}\n >\n {menuOptions.map((option) => {\n const selected = dropdownSelectedOption.findIndex((item) => item.value === option.value) !== -1\n\n return (\n <ListItem\n {...sizeProps}\n role='option'\n aria-selected={selected}\n ref={selected ? selectedOptionRef : undefined}\n key={option.value}\n text={option.text}\n active={selected}\n danger={Boolean(selected && status === 'error')}\n success={Boolean(selected && status === 'success')}\n disabled={rootProps.disabled || option.disabled}\n borderRadius={8}\n ellipsis={false}\n textProps={{ wordBreak: 'break-word' }}\n onClick={(evt) => {\n evt.stopPropagation()\n\n if (!readOnly) {\n const update = { ...option }\n\n if (selectedOption === undefined) {\n updateInputText(getDropdownInputText(update))\n setDropdownSelectedOption(getDropdownSelectedOption(update))\n }\n\n if (onSelectOption) onSelectOption(update)\n\n inputRef.current?.focus()\n setMenuOpenRequest(false)\n }\n }}\n />\n )\n })}\n </MenuList>\n )}\n </DropdownMenu>\n }\n />\n )\n }),\n {\n sizes: SIZES,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { Dropdown, COMPONENT_NAME }\n"],"names":["COMPONENT_NAME","Dropdown","withMergedProps","forwardRef","props","ref","size","name","labelPosition","searchable","primary","optionsMultiToggle","iconProps","menuProps","loadingIconProps","optionsEmptyIconProps","loading","autoFocus","disableAutoScrollToSelectedOption","closeMenuOnScroll","scrollMonitorTarget","contrast","selectedOption","defaultSelectedOption","icon","inputMode","loadingMessage","loadingIcon","maxLength","multiple","clearable","onChangeInput","onCloseMenu","onOpenMenu","onSelectOption","options","loadOptions","groupSelectedOptions","optionsMultiToggleCaption","optionsEmptyMessage","optionsEmptyIcon","palette","placeholder","readOnly","required","status","sizeXXS","sizeXS","sizeS","sizeM","sizeL","sizeXL","form","rootProps","sizeProps","iconBaseProps","sizes","SIZES_ICON","color","disabled","formInputLabelId","useMemo","id","nanoid","inputLabelId","menuListId","filteredOptions","getFilteredOptions","useFilteredOptions","loadedOptions","optionsLoading","getLoadedOptions","useLoadedOptions","dropdownSelectedOption","setDropdownSelectedOption","useState","getDropdownSelectedOption","undefined","inputText","setInputText","getDropdownInputText","focusWithin","setFocusWithin","menuOpenRequest","setMenuOpenRequest","menuOptions","menuOptionsLoading","menuOptionsGroups","groupDropdownOptions","menuOpen","inputRequired","length","inputActive","Boolean","multiToggleChecked","multiToggleIndeterminate","inputRef","useRef","menuRef","setMenuRef","menuListRef","selectedOptionRef","menuOpenPrevRef","updateInputText","useCallback","inputTextValue","updateOptions","updateOptionsDebounced","createDebouncedCallback","preventBlur","evt","target","current","Node","currentTarget","contains","renderInPortal","preventDefault","useScrollMonitor","onScrollStart","focus","useLayoutEffect","useEffect","menuRect","getBoundingClientRect","selectedOptionRect","top","bottom","setTimeout","scrollTo","offsetTop","_jsx","FormInputLabel","labelId","active","onColored","error","success","Styled","up","labelColorDisabled","labelColor","backgroundColor","backgroundColorDisabled","backgroundColorHover","borderColor","borderColorDisabled","onClick","onPointerDown","onMouseDown","window","PointerEvent","onFocus","onBlur","relatedTarget","input","_jsxs","_Fragment","children","type","tabIndex","FormInput","role","label","autoComplete","autoCapitalize","autoCorrect","spellCheck","value","colorDisabled","placeholderColor","placeholderColorDisabled","selectionStart","selectionEnd","stopPropagation","onChange","inputValue","onKeyDown","keyboardKeys","Enter","validate","key","Space","prev","Esc","Tab","ArrowDown","menuItems","idx","findIndex","item","focusTarget","HTMLElement","focusFirstFocusable","ArrowUp","focusLastFocusable","map","option","addon","Chip","black","marginLeft","cursor","text","textProps","appearance","colorHover","discardButtonProps","square","IconButton","dropdown","DropdownMenu","setRef","open","popperReferenceId","secondary","elevated","disableAutoFocus","menuBackgroundColor","menuBorderColor","empty","emptyMessage","emptyIcon","emptyIconProps","Backspace","MenuList","ListItem","borderRadius","ellipsis","wordBreak","control","InputCheckbox","SIZES_CHECKBOX","checked","indeterminate","update","filter","MenuDivider","optionStatus","optionErrorStatus","optionSuccessStatus","_createElement","danger","selected","SIZES","displayName"],"mappings":"qsCAyBMA,MAAAA,eAAiB,WAQjBC,MAAAA,SAA2DC,gBAC/DC,YAAuD,CAACC,EAAOC,KAC7D,MAAMC,KACJA,EAAO,IAAGC,KACVA,EAAO,eAAcC,cACrBA,EAAgB,UAASC,WACzBA,GAAa,EAAIC,QACjBA,GAAU,EAAIC,mBACdA,GAAqB,EAAIC,UACzBA,EAAY,CAAE,EAAAC,UACdA,EAAY,CAAE,E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AMA,EACNiK,MAAO6B,EAAO7B,MACdiE,QAASU,EACT3G,MAAOuG,EACPtG,QAASuG,EACTjE,SAAWjE,IACT,IAAKnE,EAAU,CACb,MAAMgM,EAASQ,EACX1K,GAAuBmK,QAAQ9C,GAASA,EAAKtB,QAAU1D,EAAII,cAAcsD,QACzE,IAAI/F,GAAwB4H,GAE5B/K,SAAmBuD,GACrBH,GAA0BiK,GAGxBzM,GAAgBA,EAAeyM,EACrC,MAIN,OAOH,CACPtO,IAAK+F,GACLtC,GAAIG,GACJiG,KAAK,UACL,kBAAiB7G,EAAU8G,MAAQnG,OAAea,EAAUiF,SAE3DzE,GAAY+G,KAAKC,IAChB,MAAM8C,EAAW1K,GAAuBoH,WAAWC,GAASA,EAAKtB,QAAU6B,EAAO7B,WAAY,EAE9F,OACEyE,cAACf,SAAQ,IACH5K,EACJ4G,KAAK,SACL,gBAAeiF,EACf9O,IAAK8O,EAAW9I,QAAoBxB,EACpCwG,IAAKgB,EAAO7B,MACZmC,KAAMN,EAAOM,KACbrE,OAAQ6G,EACRD,OAAQrJ,QAAQsJ,GAAYtM,IAAW,SACvC4F,QAAS5C,QAAQsJ,GAAYtM,IAAW,WACxCc,SAAUN,EAAUM,UAAY0I,EAAO1I,SACvCwK,aAAc,EACdC,UAAU,EACVxB,UAAW,CAAEyB,UAAW,cACxBlF,QAAUrC,IAGR,GAFAA,EAAIgE,mBAECnI,EAAU,CACb,MAAMgM,EAAS,IAAKtC,GAEhB/K,SAAmBuD,IACrB0B,GAAgBvB,qBAAqB2J,IACrCjK,GAA0BE,0BAA0B+J,KAGlDzM,GAAgBA,EAAeyM,GAEnC3I,GAASgB,SAASQ,QAClBpC,IAAmB,EACrB,IAEF,SAOd,IAGN,CACE5B,MAAO4L,MACPC,YA71BmB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var React=require('react');var Floater=require('react-floater');var withMergedProps=require('../../hocs/withMergedProps.js');var DropdownMenuNoOptions=require('./DropdownMenuNoOptions.js');var
|
|
1
|
+
'use strict';var React=require('react');var Floater=require('react-floater');var withMergedProps=require('../../hocs/withMergedProps.js');var DropdownMenuNoOptions=require('./DropdownMenuNoOptions.js');var sizes=require('./sizes.js');var jsxRuntime=require('react/jsx-runtime');var MenuComponent=require('../MenuComponent/MenuComponent.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Floater__default=_interopDefault(Floater);const DropdownMenu=withMergedProps.withMergedProps((e=>{const{size:t="fluid",open:o,loading:n,loadingMessage:r,loadingIcon:s,loadingIconProps:p,emptyMessage:a,emptyIcon:l,emptyIconProps:i,empty:u,children:c,renderInPortal:d,popperReferenceId:m,expanseDirectionLeft:f,setRef:y,zIndex:M,...h}=e;const w={loading:n,loadingMessage:r,loadingIcon:s,loadingIconProps:p,emptyMessage:a,emptyIcon:l,emptyIconProps:i};const x=u||n;const[g,D]=React.useState(null);const[R,j]=React.useState({});const b=React.useRef(null);return React.useLayoutEffect((()=>{let e=null;return d&&document.body?(e=document.createElement('div'),e.dataset.popperDropdownPortal='true',e.style.position='relative',document.body.appendChild(e),D(e)):D(null),()=>{e&&document.body&&document.body.contains(e)&&e.childElementCount===0&&e.remove()}}),[d]),React.useLayoutEffect((()=>{j((e=>({...e,left:f?'auto':0,right:f?0:'auto'})))}),[f]),d?g?jsxRuntime.jsx(Floater__default.default,{open:o,placement:"bottom",offset:8,hideArrow:!0,portalElement:g,target:`#${m}`,styles:{options:{zIndex:M},floater:{width:'100%',filter:'none',opacity:1,transitionDuration:'10ms'}},modifiers:{removeFloaterRoles:{name:'removeFloaterRoles',enabled:!0,phase:'beforeWrite',effect:({state:e})=>{if(e.elements.popper instanceof HTMLElement){const t=e.elements.popper.querySelector('[role="tooltip"]');t&&t.removeAttribute('role')}}},syncDimensions:{name:'syncDimensions',enabled:!0,phase:'beforeWrite',requires:['computeStyles'],fn:({state:e})=>{e.styles.popper.width=`${e.rects.reference.width}px`},effect:({state:e})=>{if(e.elements.popper instanceof HTMLElement&&e.elements.reference instanceof HTMLElement){e.elements.popper.style.display='flex',e.elements.popper.style.width=`${e.elements.reference.offsetWidth}px`;const t=e.elements.popper.querySelector('[data-popper-dropdown]');t&&(e.elements.popper.style.height=`${t.offsetHeight}px`)}}},syncPlacement:{name:'syncPlacement',enabled:!0,phase:'afterWrite',requires:['computeStyles'],fn:({state:e})=>{b.current!==null&&b.current===e.placement||j((t=>({...t,top:e.placement==='bottom'?0:'auto',bottom:e.placement==='top'?0:'auto'}))),b.current=e.placement}}},component:()=>jsxRuntime.jsx(MenuComponent.MenuComponent,{...h,size:t,ref:y,"data-popper-dropdown":!0,style:{...R,position:'absolute'},children:x?jsxRuntime.jsx(DropdownMenuNoOptions.DropdownMenuNoOptions,{...w}):c})}):null:o?jsxRuntime.jsx(MenuComponent.MenuComponent,{...h,size:t,ref:y,style:{...R,position:'absolute',top:0,zIndex:M},children:x?jsxRuntime.jsx(DropdownMenuNoOptions.DropdownMenuNoOptions,{...w}):c}):null}),{sizes:sizes.SIZES_MENU,displayName:'DropdownMenu'});exports.DropdownMenu=DropdownMenu;
|
|
2
2
|
//# sourceMappingURL=DropdownMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.js","sources":["../../../../src/components/Dropdown/DropdownMenu.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport { useState, useRef, useLayoutEffect } from 'react'\nimport Floater from 'react-floater'\nimport type { CSSProperties } from 'react'\nimport type { Placement } from 'react-floater'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { MenuComponent } from 'components/MenuComponent'\nimport type { Nullable } from 'shared/types'\nimport { DropdownMenuNoOptions } from './DropdownMenuNoOptions'\nimport { SIZES_MENU } from './constants'\nimport type { DropdownMenuProps } from './types'\n\nconst COMPONENT_NAME = 'DropdownMenu'\n\nconst DropdownMenu: React.ForwardRefExoticComponent<DropdownMenuProps> = withMergedProps<\n DropdownMenuProps,\n HTMLDivElement\n>(\n (props) => {\n const {\n size = 'fluid',\n open,\n loading,\n loadingMessage,\n loadingIcon,\n loadingIconProps,\n emptyMessage,\n emptyIcon,\n emptyIconProps,\n empty,\n children,\n renderInPortal,\n popperReferenceId,\n expanseDirectionLeft,\n setRef,\n zIndex,\n ...restProps\n } = props\n\n const noOptionsMenuProps = {\n loading,\n loadingMessage,\n loadingIcon,\n loadingIconProps,\n emptyMessage,\n emptyIcon,\n emptyIconProps,\n }\n\n const renderNoOptionsMenu = empty || loading\n\n const [portal, setPortal] = useState<Nullable<HTMLElement>>(null)\n const [offset, setOffset] = useState<Pick<CSSProperties, 'top' | 'right' | 'bottom' | 'left'>>({})\n\n const placement = useRef<Nullable<Placement>>(null)\n\n useLayoutEffect(() => {\n let portalElement: Nullable<HTMLElement> = null\n\n if (renderInPortal && document.body) {\n portalElement = document.createElement('div')\n\n portalElement.dataset.popperDropdownPortal = 'true'\n portalElement.style.position = 'relative'\n\n document.body.appendChild(portalElement)\n\n setPortal(portalElement)\n } else {\n setPortal(null)\n }\n\n return () => {\n if (\n portalElement &&\n document.body &&\n document.body.contains(portalElement) &&\n portalElement.childElementCount === 0\n ) {\n portalElement.remove()\n }\n }\n }, [renderInPortal])\n\n useLayoutEffect(() => {\n setOffset((prev) => ({\n ...prev,\n left: expanseDirectionLeft ? 'auto' : 0,\n right: expanseDirectionLeft ? 0 : 'auto',\n }))\n }, [expanseDirectionLeft])\n\n if (renderInPortal) {\n if (!portal) {\n return null\n }\n\n return (\n <Floater\n open={open}\n placement='bottom'\n offset={8}\n hideArrow\n portalElement={portal}\n target={`#${popperReferenceId}`}\n styles={{\n options: {\n zIndex,\n },\n floater: {\n width: '100%',\n filter: 'none',\n opacity: 1,\n transitionDuration: '10ms',\n },\n }}\n modifiers={{\n // @ts-ignore\n removeFloaterRoles: {\n name: 'removeFloaterRoles',\n enabled: true,\n phase: 'beforeWrite',\n // @ts-ignore\n effect: ({ state }) => {\n if (state.elements.popper instanceof HTMLElement) {\n const floaterElement = state.elements.popper.querySelector('[role=\"tooltip\"]')\n if (floaterElement) {\n floaterElement.removeAttribute('role')\n }\n }\n },\n },\n syncDimensions: {\n name: 'syncDimensions',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['computeStyles'],\n // @ts-ignore\n fn: ({ state }) => {\n state.styles.popper.width = `${state.rects.reference.width}px`\n },\n // @ts-ignore\n effect: ({ state }) => {\n if (state.elements.popper instanceof HTMLElement && state.elements.reference instanceof HTMLElement) {\n state.elements.popper.style.display = 'flex'\n state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px`\n\n const menuElement = state.elements.popper.querySelector('[data-popper-dropdown]')\n if (menuElement) {\n state.elements.popper.style.height = `${menuElement.offsetHeight}px`\n }\n }\n },\n },\n // @ts-ignore\n syncPlacement: {\n name: 'syncPlacement',\n enabled: true,\n phase: 'afterWrite',\n requires: ['computeStyles'],\n // @ts-ignore\n fn: ({ state }) => {\n if (placement.current === null || placement.current !== state.placement) {\n setOffset((prev) => ({\n ...prev,\n top: state.placement === 'bottom' ? 0 : 'auto',\n bottom: state.placement === 'top' ? 0 : 'auto',\n }))\n }\n\n placement.current = state.placement\n },\n },\n }}\n component={() => (\n <MenuComponent\n {...restProps}\n size={size}\n ref={setRef}\n data-popper-dropdown\n style={{\n ...offset,\n position: 'absolute',\n }}\n >\n {renderNoOptionsMenu ? <DropdownMenuNoOptions {...noOptionsMenuProps} /> : children}\n </MenuComponent>\n )}\n />\n )\n }\n\n if (!open) {\n return null\n }\n\n return (\n <MenuComponent\n {...restProps}\n size={size}\n ref={setRef}\n style={{\n ...offset,\n position: 'absolute',\n top: 0,\n zIndex,\n }}\n >\n {renderNoOptionsMenu ? <DropdownMenuNoOptions {...noOptionsMenuProps} /> : children}\n </MenuComponent>\n )\n },\n {\n sizes: SIZES_MENU,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { DropdownMenu }\n"],"names":["DropdownMenu","withMergedProps","props","size","open","loading","loadingMessage","loadingIcon","loadingIconProps","emptyMessage","emptyIcon","emptyIconProps","empty","children","renderInPortal","popperReferenceId","expanseDirectionLeft","setRef","zIndex","restProps","noOptionsMenuProps","renderNoOptionsMenu","portal","setPortal","useState","offset","setOffset","placement","useRef","useLayoutEffect","portalElement","document","body","createElement","dataset","popperDropdownPortal","style","position","appendChild","contains","childElementCount","remove","prev","left","right","_jsx","Floater","hideArrow","target","styles","options","floater","width","filter","opacity","transitionDuration","modifiers","removeFloaterRoles","name","enabled","phase","effect","state","elements","popper","HTMLElement","floaterElement","querySelector","removeAttribute","syncDimensions","requires","fn","rects","reference","display","offsetWidth","menuElement","height","offsetHeight","syncPlacement","current","top","bottom","component","jsx","MenuComponent","ref","DropdownMenuNoOptions","sizes","SIZES_MENU","displayName"],"mappings":"4cAcA,MAAMA,aAAmEC,gBAAeA,iBAIrFC,IACC,MAAMC,KACJA,EAAO,QAAOC,KACdA,EAAIC,QACJA,EAAOC,eACPA,EAAcC,YACdA,EAAWC,iBACXA,EAAgBC,aAChBA,EAAYC,UACZA,EAASC,eACTA,EAAcC,MACdA,EAAKC,SACLA,EAAQC,eACRA,EAAcC,kBACdA,EAAiBC,qBACjBA,EAAoBC,OACpBA,EAAMC,OACNA,KACGC,GACDjB,EAEJ,MAAMkB,EAAqB,CACzBf,UACAC,iBACAC,cACAC,mBACAC,eACAC,YACAC,kBAGF,MAAMU,EAAsBT,GAASP,EAErC,MAAOiB,EAAQC,GAAaC,MAAQA,SAAwB,MAC5D,MAAOC,EAAQC,GAAaF,MAAQA,SAA2D,CAAE,GAEjG,MAAMG,EAAYC,aAA4B,MAsC9C,OApCAC,MAAAA,iBAAgB,KACd,IAAIC,EAAuC,KAe3C,OAbIhB,GAAkBiB,SAASC,MAC7BF,EAAgBC,SAASE,cAAc,OAEvCH,EAAcI,QAAQC,qBAAuB,OAC7CL,EAAcM,MAAMC,SAAW,WAE/BN,SAASC,KAAKM,YAAYR,GAE1BP,EAAUO,IAEVP,EAAU,MAGL,KAEHO,GACAC,SAASC,MACTD,SAASC,KAAKO,SAAST,I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,YACDnC,EAAUqD,UAAY,MAAQrD,EAAUqD,UAAYlB,EAAMnC,WAC5DD,GAAWgB,IAAU,IAChBA,EACHuC,IAAKnB,EAAMnC,YAAc,SAAW,EAAI,OACxCuD,OAAQpB,EAAMnC,YAAc,MAAQ,EAAI,WAI5CA,EAAUqD,QAAUlB,EAAMnC,SAAS,IAIzCwD,UAAWA,IACTtC,WAAAuC,IAACC,4BAAa,IACRlE,EACJhB,KAAMA,EACNmF,IAAKrE,EACL,wBAAoB,EACpBmB,MAAO,IACFX,EACHY,SAAU,YACVxB,SAEDQ,EAAsBwB,WAAAuC,IAACG,4CAAqB,IAAKnE,IAAyBP,MA3F1E,KAkGNT,EAKHyC,WAAAA,IAACwC,cAAAA,cAAa,IACRlE,EACJhB,KAAMA,EACNmF,IAAKrE,EACLmB,MAAO,IACFX,EACHY,SAAU,WACV4C,IAAK,EACL/D,UACAL,SAEDQ,EAAsBwB,WAAAuC,IAACG,4CAAqB,IAAKnE,IAAyBP,IAftE,IAgBS,GAGpB,CACE2E,MAAOC,UAAUA,WACjBC,YA1MmB"}
|
|
1
|
+
{"version":3,"file":"DropdownMenu.js","sources":["../../../../src/components/Dropdown/DropdownMenu.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport { useState, useRef, useLayoutEffect } from 'react'\nimport Floater from 'react-floater'\nimport type { CSSProperties } from 'react'\nimport type { Placement } from 'react-floater'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { MenuComponent } from 'components/MenuComponent'\nimport type { Nullable } from 'shared/types'\nimport { DropdownMenuNoOptions } from './DropdownMenuNoOptions'\nimport { SIZES_MENU } from './sizes'\nimport type { DropdownMenuProps } from './types'\n\nconst COMPONENT_NAME = 'DropdownMenu'\n\nconst DropdownMenu: React.ForwardRefExoticComponent<DropdownMenuProps> = withMergedProps<\n DropdownMenuProps,\n HTMLDivElement\n>(\n (props) => {\n const {\n size = 'fluid',\n open,\n loading,\n loadingMessage,\n loadingIcon,\n loadingIconProps,\n emptyMessage,\n emptyIcon,\n emptyIconProps,\n empty,\n children,\n renderInPortal,\n popperReferenceId,\n expanseDirectionLeft,\n setRef,\n zIndex,\n ...restProps\n } = props\n\n const noOptionsMenuProps = {\n loading,\n loadingMessage,\n loadingIcon,\n loadingIconProps,\n emptyMessage,\n emptyIcon,\n emptyIconProps,\n }\n\n const renderNoOptionsMenu = empty || loading\n\n const [portal, setPortal] = useState<Nullable<HTMLElement>>(null)\n const [offset, setOffset] = useState<Pick<CSSProperties, 'top' | 'right' | 'bottom' | 'left'>>({})\n\n const placement = useRef<Nullable<Placement>>(null)\n\n useLayoutEffect(() => {\n let portalElement: Nullable<HTMLElement> = null\n\n if (renderInPortal && document.body) {\n portalElement = document.createElement('div')\n\n portalElement.dataset.popperDropdownPortal = 'true'\n portalElement.style.position = 'relative'\n\n document.body.appendChild(portalElement)\n\n setPortal(portalElement)\n } else {\n setPortal(null)\n }\n\n return () => {\n if (\n portalElement &&\n document.body &&\n document.body.contains(portalElement) &&\n portalElement.childElementCount === 0\n ) {\n portalElement.remove()\n }\n }\n }, [renderInPortal])\n\n useLayoutEffect(() => {\n setOffset((prev) => ({\n ...prev,\n left: expanseDirectionLeft ? 'auto' : 0,\n right: expanseDirectionLeft ? 0 : 'auto',\n }))\n }, [expanseDirectionLeft])\n\n if (renderInPortal) {\n if (!portal) {\n return null\n }\n\n return (\n <Floater\n open={open}\n placement='bottom'\n offset={8}\n hideArrow\n portalElement={portal}\n target={`#${popperReferenceId}`}\n styles={{\n options: {\n zIndex,\n },\n floater: {\n width: '100%',\n filter: 'none',\n opacity: 1,\n transitionDuration: '10ms',\n },\n }}\n modifiers={{\n // @ts-ignore\n removeFloaterRoles: {\n name: 'removeFloaterRoles',\n enabled: true,\n phase: 'beforeWrite',\n // @ts-ignore\n effect: ({ state }) => {\n if (state.elements.popper instanceof HTMLElement) {\n const floaterElement = state.elements.popper.querySelector('[role=\"tooltip\"]')\n if (floaterElement) {\n floaterElement.removeAttribute('role')\n }\n }\n },\n },\n syncDimensions: {\n name: 'syncDimensions',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['computeStyles'],\n // @ts-ignore\n fn: ({ state }) => {\n state.styles.popper.width = `${state.rects.reference.width}px`\n },\n // @ts-ignore\n effect: ({ state }) => {\n if (state.elements.popper instanceof HTMLElement && state.elements.reference instanceof HTMLElement) {\n state.elements.popper.style.display = 'flex'\n state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px`\n\n const menuElement = state.elements.popper.querySelector('[data-popper-dropdown]')\n if (menuElement) {\n state.elements.popper.style.height = `${menuElement.offsetHeight}px`\n }\n }\n },\n },\n // @ts-ignore\n syncPlacement: {\n name: 'syncPlacement',\n enabled: true,\n phase: 'afterWrite',\n requires: ['computeStyles'],\n // @ts-ignore\n fn: ({ state }) => {\n if (placement.current === null || placement.current !== state.placement) {\n setOffset((prev) => ({\n ...prev,\n top: state.placement === 'bottom' ? 0 : 'auto',\n bottom: state.placement === 'top' ? 0 : 'auto',\n }))\n }\n\n placement.current = state.placement\n },\n },\n }}\n component={() => (\n <MenuComponent\n {...restProps}\n size={size}\n ref={setRef}\n data-popper-dropdown\n style={{\n ...offset,\n position: 'absolute',\n }}\n >\n {renderNoOptionsMenu ? <DropdownMenuNoOptions {...noOptionsMenuProps} /> : children}\n </MenuComponent>\n )}\n />\n )\n }\n\n if (!open) {\n return null\n }\n\n return (\n <MenuComponent\n {...restProps}\n size={size}\n ref={setRef}\n style={{\n ...offset,\n position: 'absolute',\n top: 0,\n zIndex,\n }}\n >\n {renderNoOptionsMenu ? <DropdownMenuNoOptions {...noOptionsMenuProps} /> : children}\n </MenuComponent>\n )\n },\n {\n sizes: SIZES_MENU,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { DropdownMenu }\n"],"names":["DropdownMenu","withMergedProps","props","size","open","loading","loadingMessage","loadingIcon","loadingIconProps","emptyMessage","emptyIcon","emptyIconProps","empty","children","renderInPortal","popperReferenceId","expanseDirectionLeft","setRef","zIndex","restProps","noOptionsMenuProps","renderNoOptionsMenu","portal","setPortal","useState","offset","setOffset","placement","useRef","useLayoutEffect","portalElement","document","body","createElement","dataset","popperDropdownPortal","style","position","appendChild","contains","childElementCount","remove","prev","left","right","_jsx","Floater","hideArrow","target","styles","options","floater","width","filter","opacity","transitionDuration","modifiers","removeFloaterRoles","name","enabled","phase","effect","state","elements","popper","HTMLElement","floaterElement","querySelector","removeAttribute","syncDimensions","requires","fn","rects","reference","display","offsetWidth","menuElement","height","offsetHeight","syncPlacement","current","top","bottom","component","jsx","MenuComponent","ref","DropdownMenuNoOptions","sizes","SIZES_MENU","displayName"],"mappings":"ocAcA,MAAMA,aAAmEC,gBAAeA,iBAIrFC,IACC,MAAMC,KACJA,EAAO,QAAOC,KACdA,EAAIC,QACJA,EAAOC,eACPA,EAAcC,YACdA,EAAWC,iBACXA,EAAgBC,aAChBA,EAAYC,UACZA,EAASC,eACTA,EAAcC,MACdA,EAAKC,SACLA,EAAQC,eACRA,EAAcC,kBACdA,EAAiBC,qBACjBA,EAAoBC,OACpBA,EAAMC,OACNA,KACGC,GACDjB,EAEJ,MAAMkB,EAAqB,CACzBf,UACAC,iBACAC,cACAC,mBACAC,eACAC,YACAC,kBAGF,MAAMU,EAAsBT,GAASP,EAErC,MAAOiB,EAAQC,GAAaC,MAAQA,SAAwB,MAC5D,MAAOC,EAAQC,GAAaF,MAAQA,SAA2D,CAAE,GAEjG,MAAMG,EAAYC,aAA4B,MAsC9C,OApCAC,MAAAA,iBAAgB,KACd,IAAIC,EAAuC,KAe3C,OAbIhB,GAAkBiB,SAASC,MAC7BF,EAAgBC,SAASE,cAAc,OAEvCH,EAAcI,QAAQC,qBAAuB,OAC7CL,EAAcM,MAAMC,SAAW,WAE/BN,SAASC,KAAKM,YAAYR,GAE1BP,EAAUO,IAEVP,EAAU,MAGL,KAEHO,GACAC,SAASC,MACTD,SAASC,KAAKO,SAAST,IACvBA,EAAcU,oBAAsB,GAEpCV,EAAcW,QAChB,CACD,G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AAMnC,WAC5DD,GAAWgB,IAAU,IAChBA,EACHuC,IAAKnB,EAAMnC,YAAc,SAAW,EAAI,OACxCuD,OAAQpB,EAAMnC,YAAc,MAAQ,EAAI,WAI5CA,EAAUqD,QAAUlB,EAAMnC,SAAS,IAIzCwD,UAAWA,IACTtC,WAAAuC,IAACC,4BAAa,IACRlE,EACJhB,KAAMA,EACNmF,IAAKrE,EACL,wBAAoB,EACpBmB,MAAO,IACFX,EACHY,SAAU,YACVxB,SAEDQ,EAAsBwB,WAAAuC,IAACG,4CAAqB,IAAKnE,IAAyBP,MA3F1E,KAkGNT,EAKHyC,WAAAA,IAACwC,cAAAA,cAAa,IACRlE,EACJhB,KAAMA,EACNmF,IAAKrE,EACLmB,MAAO,IACFX,EACHY,SAAU,WACV4C,IAAK,EACL/D,UACAL,SAEDQ,EAAsBwB,WAAAuC,IAACG,4CAAqB,IAAKnE,IAAyBP,IAftE,IAgBS,GAGpB,CACE2E,MAAOC,MAAUA,WACjBC,YA1MmB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState,useRef,useLayoutEffect}from'react';import Floater from'react-floater';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{DropdownMenuNoOptions}from'./DropdownMenuNoOptions.mjs';import{SIZES_MENU}from'./
|
|
1
|
+
import{useState,useRef,useLayoutEffect}from'react';import Floater from'react-floater';import{withMergedProps}from'../../hocs/withMergedProps.mjs';import{DropdownMenuNoOptions}from'./DropdownMenuNoOptions.mjs';import{SIZES_MENU}from'./sizes.mjs';import{jsx}from'react/jsx-runtime';import{MenuComponent}from'../MenuComponent/MenuComponent.mjs';const DropdownMenu=withMergedProps((e=>{const{size:t="fluid",open:o,loading:n,loadingMessage:r,loadingIcon:s,loadingIconProps:p,emptyMessage:l,emptyIcon:i,emptyIconProps:a,empty:m,children:c,renderInPortal:d,popperReferenceId:u,expanseDirectionLeft:f,setRef:y,zIndex:M,...h}=e;const g={loading:n,loadingMessage:r,loadingIcon:s,loadingIconProps:p,emptyMessage:l,emptyIcon:i,emptyIconProps:a};const w=m||n;const[x,b]=useState(null);const[I,E]=useState({});const D=useRef(null);return useLayoutEffect((()=>{let e=null;return d&&document.body?(e=document.createElement('div'),e.dataset.popperDropdownPortal='true',e.style.position='relative',document.body.appendChild(e),b(e)):b(null),()=>{e&&document.body&&document.body.contains(e)&&e.childElementCount===0&&e.remove()}}),[d]),useLayoutEffect((()=>{E((e=>({...e,left:f?'auto':0,right:f?0:'auto'})))}),[f]),d?x?jsx(Floater,{open:o,placement:"bottom",offset:8,hideArrow:!0,portalElement:x,target:`#${u}`,styles:{options:{zIndex:M},floater:{width:'100%',filter:'none',opacity:1,transitionDuration:'10ms'}},modifiers:{removeFloaterRoles:{name:'removeFloaterRoles',enabled:!0,phase:'beforeWrite',effect:({state:e})=>{if(e.elements.popper instanceof HTMLElement){const t=e.elements.popper.querySelector('[role="tooltip"]');t&&t.removeAttribute('role')}}},syncDimensions:{name:'syncDimensions',enabled:!0,phase:'beforeWrite',requires:['computeStyles'],fn:({state:e})=>{e.styles.popper.width=`${e.rects.reference.width}px`},effect:({state:e})=>{if(e.elements.popper instanceof HTMLElement&&e.elements.reference instanceof HTMLElement){e.elements.popper.style.display='flex',e.elements.popper.style.width=`${e.elements.reference.offsetWidth}px`;const t=e.elements.popper.querySelector('[data-popper-dropdown]');t&&(e.elements.popper.style.height=`${t.offsetHeight}px`)}}},syncPlacement:{name:'syncPlacement',enabled:!0,phase:'afterWrite',requires:['computeStyles'],fn:({state:e})=>{D.current!==null&&D.current===e.placement||E((t=>({...t,top:e.placement==='bottom'?0:'auto',bottom:e.placement==='top'?0:'auto'}))),D.current=e.placement}}},component:()=>jsx(MenuComponent,{...h,size:t,ref:y,"data-popper-dropdown":!0,style:{...I,position:'absolute'},children:w?jsx(DropdownMenuNoOptions,{...g}):c})}):null:o?jsx(MenuComponent,{...h,size:t,ref:y,style:{...I,position:'absolute',top:0,zIndex:M},children:w?jsx(DropdownMenuNoOptions,{...g}):c}):null}),{sizes:SIZES_MENU,displayName:'DropdownMenu'});export{DropdownMenu};
|
|
2
2
|
//# sourceMappingURL=DropdownMenu.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.mjs","sources":["../../../../src/components/Dropdown/DropdownMenu.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport { useState, useRef, useLayoutEffect } from 'react'\nimport Floater from 'react-floater'\nimport type { CSSProperties } from 'react'\nimport type { Placement } from 'react-floater'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { MenuComponent } from 'components/MenuComponent'\nimport type { Nullable } from 'shared/types'\nimport { DropdownMenuNoOptions } from './DropdownMenuNoOptions'\nimport { SIZES_MENU } from './
|
|
1
|
+
{"version":3,"file":"DropdownMenu.mjs","sources":["../../../../src/components/Dropdown/DropdownMenu.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport { useState, useRef, useLayoutEffect } from 'react'\nimport Floater from 'react-floater'\nimport type { CSSProperties } from 'react'\nimport type { Placement } from 'react-floater'\nimport { withMergedProps } from 'hocs/withMergedProps'\nimport { MenuComponent } from 'components/MenuComponent'\nimport type { Nullable } from 'shared/types'\nimport { DropdownMenuNoOptions } from './DropdownMenuNoOptions'\nimport { SIZES_MENU } from './sizes'\nimport type { DropdownMenuProps } from './types'\n\nconst COMPONENT_NAME = 'DropdownMenu'\n\nconst DropdownMenu: React.ForwardRefExoticComponent<DropdownMenuProps> = withMergedProps<\n DropdownMenuProps,\n HTMLDivElement\n>(\n (props) => {\n const {\n size = 'fluid',\n open,\n loading,\n loadingMessage,\n loadingIcon,\n loadingIconProps,\n emptyMessage,\n emptyIcon,\n emptyIconProps,\n empty,\n children,\n renderInPortal,\n popperReferenceId,\n expanseDirectionLeft,\n setRef,\n zIndex,\n ...restProps\n } = props\n\n const noOptionsMenuProps = {\n loading,\n loadingMessage,\n loadingIcon,\n loadingIconProps,\n emptyMessage,\n emptyIcon,\n emptyIconProps,\n }\n\n const renderNoOptionsMenu = empty || loading\n\n const [portal, setPortal] = useState<Nullable<HTMLElement>>(null)\n const [offset, setOffset] = useState<Pick<CSSProperties, 'top' | 'right' | 'bottom' | 'left'>>({})\n\n const placement = useRef<Nullable<Placement>>(null)\n\n useLayoutEffect(() => {\n let portalElement: Nullable<HTMLElement> = null\n\n if (renderInPortal && document.body) {\n portalElement = document.createElement('div')\n\n portalElement.dataset.popperDropdownPortal = 'true'\n portalElement.style.position = 'relative'\n\n document.body.appendChild(portalElement)\n\n setPortal(portalElement)\n } else {\n setPortal(null)\n }\n\n return () => {\n if (\n portalElement &&\n document.body &&\n document.body.contains(portalElement) &&\n portalElement.childElementCount === 0\n ) {\n portalElement.remove()\n }\n }\n }, [renderInPortal])\n\n useLayoutEffect(() => {\n setOffset((prev) => ({\n ...prev,\n left: expanseDirectionLeft ? 'auto' : 0,\n right: expanseDirectionLeft ? 0 : 'auto',\n }))\n }, [expanseDirectionLeft])\n\n if (renderInPortal) {\n if (!portal) {\n return null\n }\n\n return (\n <Floater\n open={open}\n placement='bottom'\n offset={8}\n hideArrow\n portalElement={portal}\n target={`#${popperReferenceId}`}\n styles={{\n options: {\n zIndex,\n },\n floater: {\n width: '100%',\n filter: 'none',\n opacity: 1,\n transitionDuration: '10ms',\n },\n }}\n modifiers={{\n // @ts-ignore\n removeFloaterRoles: {\n name: 'removeFloaterRoles',\n enabled: true,\n phase: 'beforeWrite',\n // @ts-ignore\n effect: ({ state }) => {\n if (state.elements.popper instanceof HTMLElement) {\n const floaterElement = state.elements.popper.querySelector('[role=\"tooltip\"]')\n if (floaterElement) {\n floaterElement.removeAttribute('role')\n }\n }\n },\n },\n syncDimensions: {\n name: 'syncDimensions',\n enabled: true,\n phase: 'beforeWrite',\n requires: ['computeStyles'],\n // @ts-ignore\n fn: ({ state }) => {\n state.styles.popper.width = `${state.rects.reference.width}px`\n },\n // @ts-ignore\n effect: ({ state }) => {\n if (state.elements.popper instanceof HTMLElement && state.elements.reference instanceof HTMLElement) {\n state.elements.popper.style.display = 'flex'\n state.elements.popper.style.width = `${state.elements.reference.offsetWidth}px`\n\n const menuElement = state.elements.popper.querySelector('[data-popper-dropdown]')\n if (menuElement) {\n state.elements.popper.style.height = `${menuElement.offsetHeight}px`\n }\n }\n },\n },\n // @ts-ignore\n syncPlacement: {\n name: 'syncPlacement',\n enabled: true,\n phase: 'afterWrite',\n requires: ['computeStyles'],\n // @ts-ignore\n fn: ({ state }) => {\n if (placement.current === null || placement.current !== state.placement) {\n setOffset((prev) => ({\n ...prev,\n top: state.placement === 'bottom' ? 0 : 'auto',\n bottom: state.placement === 'top' ? 0 : 'auto',\n }))\n }\n\n placement.current = state.placement\n },\n },\n }}\n component={() => (\n <MenuComponent\n {...restProps}\n size={size}\n ref={setRef}\n data-popper-dropdown\n style={{\n ...offset,\n position: 'absolute',\n }}\n >\n {renderNoOptionsMenu ? <DropdownMenuNoOptions {...noOptionsMenuProps} /> : children}\n </MenuComponent>\n )}\n />\n )\n }\n\n if (!open) {\n return null\n }\n\n return (\n <MenuComponent\n {...restProps}\n size={size}\n ref={setRef}\n style={{\n ...offset,\n position: 'absolute',\n top: 0,\n zIndex,\n }}\n >\n {renderNoOptionsMenu ? <DropdownMenuNoOptions {...noOptionsMenuProps} /> : children}\n </MenuComponent>\n )\n },\n {\n sizes: SIZES_MENU,\n displayName: COMPONENT_NAME,\n }\n)\n\nexport { DropdownMenu }\n"],"names":["DropdownMenu","withMergedProps","props","size","open","loading","loadingMessage","loadingIcon","loadingIconProps","emptyMessage","emptyIcon","emptyIconProps","empty","children","renderInPortal","popperReferenceId","expanseDirectionLeft","setRef","zIndex","restProps","noOptionsMenuProps","renderNoOptionsMenu","portal","setPortal","useState","offset","setOffset","placement","useRef","useLayoutEffect","portalElement","document","body","createElement","dataset","popperDropdownPortal","style","position","appendChild","contains","childElementCount","remove","prev","left","right","_jsx","Floater","hideArrow","target","styles","options","floater","width","filter","opacity","transitionDuration","modifiers","removeFloaterRoles","name","enabled","phase","effect","state","elements","popper","HTMLElement","floaterElement","querySelector","removeAttribute","syncDimensions","requires","fn","rects","reference","display","offsetWidth","menuElement","height","offsetHeight","syncPlacement","current","top","bottom","component","MenuComponent","ref","DropdownMenuNoOptions","sizes","SIZES_MENU","displayName"],"mappings":"sVAcA,MAAMA,aAAmEC,iBAItEC,IACC,MAAMC,KACJA,EAAO,QAAOC,KACdA,EAAIC,QACJA,EAAOC,eACPA,EAAcC,YACdA,EAAWC,iBACXA,EAAgBC,aAChBA,EAAYC,UACZA,EAASC,eACTA,EAAcC,MACdA,EAAKC,SACLA,EAAQC,eACRA,EAAcC,kBACdA,EAAiBC,qBACjBA,EAAoBC,OACpBA,EAAMC,OACNA,KACGC,GACDjB,EAEJ,MAAMkB,EAAqB,CACzBf,UACAC,iBACAC,cACAC,mBACAC,eACAC,YACAC,kBAGF,MAAMU,EAAsBT,GAASP,EAErC,MAAOiB,EAAQC,GAAaC,SAAgC,MAC5D,MAAOC,EAAQC,GAAaF,SAAmE,CAAE,GAEjG,MAAMG,EAAYC,OAA4B,MAsC9C,OApCAC,iBAAgB,KACd,IAAIC,EAAuC,KAe3C,OAbIhB,GAAkBiB,SAASC,MAC7BF,EAAgBC,SAASE,cAAc,OAEvCH,EAAcI,QAAQC,qBAAuB,OAC7CL,EAAcM,MAAMC,SAAW,WAE/BN,SAASC,KAAKM,YAAYR,GAE1BP,EAAUO,IAEVP,EAAU,MAGL,KAEHO,GACAC,SAASC,MACTD,SAASC,KAAKO,SAAST,IACvBA,EAAcU,oBAAsB,GAEpCV,EAAcW,QAChB,CACD,GACA,CAAC3B,IAEJe,iBAAgB,KACdH,GAAWgB,IAAU,IAChBA,EACHC,KAAM3B,EAAuB,OAAS,EACtC4B,MAAO5B,EAAuB,EAAI,UACjC,GACF,CAACA,IAEAF,EACGQ,EAKHuB,IAACC,QAAO,CACN1C,KAAMA,EACNuB,UAAU,SACVF,OAAQ,EACRsB,WAAS,EACTjB,cAAeR,EACf0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AAO,IACFX,EACHY,SAAU,YACVxB,SAEDQ,EAAsBwB,IAACyC,sBAAqB,IAAKlE,IAAyBP,MA3F1E,KAkGNT,EAKHyC,IAACuC,cAAa,IACRjE,EACJhB,KAAMA,EACNkF,IAAKpE,EACLmB,MAAO,IACFX,EACHY,SAAU,WACV4C,IAAK,EACL/D,UACAL,SAEDQ,EAAsBwB,IAACyC,sBAAqB,IAAKlE,IAAyBP,IAftE,IAgBS,GAGpB,CACE0E,MAAOC,WACPC,YA1MmB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use strict';exports.FuseSearchKeys={text:'text',label:'label',tags:'tags'};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/components/Dropdown/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/Dropdown/constants.ts"],"sourcesContent":["export const FuseSearchKeys = {\n text: 'text',\n label: 'label',\n tags: 'tags',\n} as const\n"],"names":["text","label","tags"],"mappings":"oCAA8B,CAC5BA,KAAM,OACNC,MAAO,QACPC,KAAM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const FuseSearchKeys={text:'text',label:'label',tags:'tags'};export{FuseSearchKeys};
|
|
2
2
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sources":["../../../../src/components/Dropdown/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../../../src/components/Dropdown/constants.ts"],"sourcesContent":["export const FuseSearchKeys = {\n text: 'text',\n label: 'label',\n tags: 'tags',\n} as const\n"],"names":["FuseSearchKeys","text","label","tags"],"mappings":"AAAO,MAAMA,eAAiB,CAC5BC,KAAM,OACNC,MAAO,QACPC,KAAM"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var constants=require('../FormInputLabel/constants.js');var constants$1=require('../InputCheckbox/constants.js');const SIZES_CHECKBOX={l:constants$1.SIZES.m,m:constants$1.SIZES.s,s:constants$1.SIZES.xs};exports.SIZES={l:constants.SIZES.l,m:constants.SIZES.m,s:constants.SIZES.s},exports.SIZES_CHECKBOX=SIZES_CHECKBOX,exports.SIZES_ICON={l:{fontSize:24},m:{fontSize:24},s:{fontSize:20}},exports.SIZES_MENU={l:{width:560,minWidth:'auto',maxWidth:'none'},m:{width:480,minWidth:'auto',maxWidth:'none'},s:{width:280,minWidth:'auto',maxWidth:'none'},fluid:{width:'100%',minWidth:'auto',maxWidth:'none'}};
|
|
2
|
+
//# sourceMappingURL=sizes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sizes.js","sources":["../../../../src/components/Dropdown/sizes.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\nimport { SIZES as SIZES_FORM_INPUT_LABEL } from 'components/FormInputLabel'\nimport { SIZES as SIZES_INPUT_CHECKBOX } from 'components/InputCheckbox'\nimport type { MenuComponentSize } from 'components/MenuComponent'\nimport type { Size } from './types'\n\nexport const SIZES: Record<Size, CSSProperties> = {\n l: SIZES_FORM_INPUT_LABEL.l,\n m: SIZES_FORM_INPUT_LABEL.m,\n s: SIZES_FORM_INPUT_LABEL.s,\n}\n\nexport const SIZES_CHECKBOX: Record<Size, CSSProperties> = {\n l: SIZES_INPUT_CHECKBOX.m,\n m: SIZES_INPUT_CHECKBOX.s,\n s: SIZES_INPUT_CHECKBOX.xs,\n}\n\nexport const SIZES_MENU: Record<MenuComponentSize, CSSProperties> = {\n l: {\n width: 560,\n minWidth: 'auto',\n maxWidth: 'none',\n },\n m: {\n width: 480,\n minWidth: 'auto',\n maxWidth: 'none',\n },\n s: {\n width: 280,\n minWidth: 'auto',\n maxWidth: 'none',\n },\n fluid: {\n width: '100%',\n minWidth: 'auto',\n maxWidth: 'none',\n },\n}\n\nexport const SIZES_ICON: Record<Size, CSSProperties> = {\n l: { fontSize: 24 },\n m: { fontSize: 24 },\n s: { fontSize: 20 },\n}\n"],"names":["SIZES_CHECKBOX","l","SIZES_INPUT_CHECKBOX","SIZES","m","s","xs","SIZES_FORM_INPUT_LABEL","fontSize","width","minWidth","maxWidth","fluid"],"mappings":"8HAYO,MAAMA,eAA8C,CACzDC,EAAGC,YAAoBC,MAACC,EACxBA,EAAGF,YAAoBC,MAACE,EACxBA,EAAGH,YAAoBC,MAACG,kBATwB,CAChDL,EAAGM,UAAsBJ,MAACF,EAC1BG,EAAGG,UAAsBJ,MAACC,EAC1BC,EAAGE,UAAsBJ,MAACE,4DAgC2B,CACrDJ,EAAG,CAAEO,SAAU,IACfJ,EAAG,CAAEI,SAAU,IACfH,EAAG,CAAEG,SAAU,wBA1BmD,CAClEP,EAAG,CACDQ,MAAO,IACPC,SAAU,OACVC,SAAU,QAEZP,EAAG,CACDK,MAAO,IACPC,SAAU,OACVC,SAAU,QAEZN,EAAG,CACDI,MAAO,IACPC,SAAU,OACVC,SAAU,QAEZC,MAAO,CACLH,MAAO,OACPC,SAAU,OACVC,SAAU"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{SIZES as SIZES$1}from'../FormInputLabel/constants.mjs';import{SIZES as SIZES$2}from'../InputCheckbox/constants.mjs';const SIZES={l:SIZES$1.l,m:SIZES$1.m,s:SIZES$1.s};const SIZES_CHECKBOX={l:SIZES$2.m,m:SIZES$2.s,s:SIZES$2.xs};const SIZES_MENU={l:{width:560,minWidth:'auto',maxWidth:'none'},m:{width:480,minWidth:'auto',maxWidth:'none'},s:{width:280,minWidth:'auto',maxWidth:'none'},fluid:{width:'100%',minWidth:'auto',maxWidth:'none'}};const SIZES_ICON={l:{fontSize:24},m:{fontSize:24},s:{fontSize:20}};export{SIZES,SIZES_CHECKBOX,SIZES_ICON,SIZES_MENU};
|
|
2
|
+
//# sourceMappingURL=sizes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sizes.mjs","sources":["../../../../src/components/Dropdown/sizes.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\nimport { SIZES as SIZES_FORM_INPUT_LABEL } from 'components/FormInputLabel'\nimport { SIZES as SIZES_INPUT_CHECKBOX } from 'components/InputCheckbox'\nimport type { MenuComponentSize } from 'components/MenuComponent'\nimport type { Size } from './types'\n\nexport const SIZES: Record<Size, CSSProperties> = {\n l: SIZES_FORM_INPUT_LABEL.l,\n m: SIZES_FORM_INPUT_LABEL.m,\n s: SIZES_FORM_INPUT_LABEL.s,\n}\n\nexport const SIZES_CHECKBOX: Record<Size, CSSProperties> = {\n l: SIZES_INPUT_CHECKBOX.m,\n m: SIZES_INPUT_CHECKBOX.s,\n s: SIZES_INPUT_CHECKBOX.xs,\n}\n\nexport const SIZES_MENU: Record<MenuComponentSize, CSSProperties> = {\n l: {\n width: 560,\n minWidth: 'auto',\n maxWidth: 'none',\n },\n m: {\n width: 480,\n minWidth: 'auto',\n maxWidth: 'none',\n },\n s: {\n width: 280,\n minWidth: 'auto',\n maxWidth: 'none',\n },\n fluid: {\n width: '100%',\n minWidth: 'auto',\n maxWidth: 'none',\n },\n}\n\nexport const SIZES_ICON: Record<Size, CSSProperties> = {\n l: { fontSize: 24 },\n m: { fontSize: 24 },\n s: { fontSize: 20 },\n}\n"],"names":["SIZES","l","SIZES_FORM_INPUT_LABEL","m","s","SIZES_CHECKBOX","SIZES_INPUT_CHECKBOX","xs","SIZES_MENU","width","minWidth","maxWidth","fluid","SIZES_ICON","fontSize"],"mappings":"2HAMO,MAAMA,MAAqC,CAChDC,EAAGC,QAAuBD,EAC1BE,EAAGD,QAAuBC,EAC1BC,EAAGF,QAAuBE,GAGrB,MAAMC,eAA8C,CACzDJ,EAAGK,QAAqBH,EACxBA,EAAGG,QAAqBF,EACxBA,EAAGE,QAAqBC,IAGnB,MAAMC,WAAuD,CAClEP,EAAG,CACDQ,MAAO,IACPC,SAAU,OACVC,SAAU,QAEZR,EAAG,CACDM,MAAO,IACPC,SAAU,OACVC,SAAU,QAEZP,EAAG,CACDK,MAAO,IACPC,SAAU,OACVC,SAAU,QAEZC,MAAO,CACLH,MAAO,OACPC,SAAU,OACVC,SAAU,SAIP,MAAME,WAA0C,CACrDZ,EAAG,CAAEa,SAAU,IACfX,EAAG,CAAEW,SAAU,IACfV,EAAG,CAAEU,SAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sources":["../../../../src/components/Dropdown/style.ts"],"sourcesContent":["import styled, { keyframes } from 'styled-components'\nimport { LoaderFill, ChevronDown } from '@foxford/icon-pack'\
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../../src/components/Dropdown/style.ts"],"sourcesContent":["import styled, { keyframes } from 'styled-components'\nimport { LoaderFill, ChevronDown } from '@foxford/icon-pack'\n\nconst spinAnimation = keyframes`\n 100% {\n transform: rotate(360deg);\n }\n`\n\nexport const IconContainer = styled.div`\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 12px 0;\n`\n\nexport const ChevronIcon = styled(ChevronDown).withConfig<{ up: boolean }>({\n shouldForwardProp: (propKey) => propKey !== 'up',\n})`\n ${(props) => `\n transition-property: transform;\n transition-duration: 250ms;\n transform-origin: center;\n transform: rotate(${props.up ? 180 : 0}deg);\n `}\n`\n\nexport const LoadingIconAnimated = styled(LoaderFill)`\n transform-origin: center;\n animation: ${spinAnimation} 1600ms infinite linear;\n`\n\nexport const InputMimic = styled.input`\n box-sizing: border-box;\n position: absolute;\n top: 0;\n left: 0;\n appearance: none;\n border: none;\n padding: 0;\n margin: 0;\n background-color: transparent;\n width: 100%;\n height: 100%;\n opacity: 0;\n &:focus {\n outline: none;\n }\n`\n"],"names":["spinAnimation","keyframes","IconContainer","styled","div","withConfig","displayName","componentId","ChevronIcon","default","ChevronDown","shouldForwardProp","propKey","props","up","LoadingIconAnimated","LoaderFill","InputMimic","input"],"mappings":"6MAGA,MAAMA,cAAgBC,OAASA,UAI9B,CAAA,0CAEYC,cAAgBC,gBAAAA,QAAOC,IAAGC,WAAA,CAAAC,YAAA,0BAAAC,YAAA,mBAAVJ,CAM5B,CAAA,gGAEM,MAAMK,YAAcL,gBAAMM,QAACC,sBAAaL,WAA4B,CACzEM,kBAAoBC,GAAYA,IAAY,OAC5CP,WAAA,CAAAC,YAAA,wBAAAC,YAAA,mBAFyBJ,CAEzB,CAAA,GAAA,KACGU,GAAU,gIAISA,EAAMC,GAAK,IAAM,eAIlC,MAAMC,oBAAsBZ,gBAAMM,QAACO,qBAAWX,WAAA,CAAAC,YAAA,gCAAAC,YAAA,mBAAlBJ,CAAkB,CAAA,qCAAA,4BAEtCH,qBAGFiB,WAAad,gBAAAA,QAAOe,MAAKb,WAAA,CAAAC,YAAA,uBAAAC,YAAA,mBAAZJ,CAgBzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","sources":["../../../../src/components/Dropdown/style.ts"],"sourcesContent":["import styled, { keyframes } from 'styled-components'\nimport { LoaderFill, ChevronDown } from '@foxford/icon-pack'\
|
|
1
|
+
{"version":3,"file":"style.mjs","sources":["../../../../src/components/Dropdown/style.ts"],"sourcesContent":["import styled, { keyframes } from 'styled-components'\nimport { LoaderFill, ChevronDown } from '@foxford/icon-pack'\n\nconst spinAnimation = keyframes`\n 100% {\n transform: rotate(360deg);\n }\n`\n\nexport const IconContainer = styled.div`\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 12px 0;\n`\n\nexport const ChevronIcon = styled(ChevronDown).withConfig<{ up: boolean }>({\n shouldForwardProp: (propKey) => propKey !== 'up',\n})`\n ${(props) => `\n transition-property: transform;\n transition-duration: 250ms;\n transform-origin: center;\n transform: rotate(${props.up ? 180 : 0}deg);\n `}\n`\n\nexport const LoadingIconAnimated = styled(LoaderFill)`\n transform-origin: center;\n animation: ${spinAnimation} 1600ms infinite linear;\n`\n\nexport const InputMimic = styled.input`\n box-sizing: border-box;\n position: absolute;\n top: 0;\n left: 0;\n appearance: none;\n border: none;\n padding: 0;\n margin: 0;\n background-color: transparent;\n width: 100%;\n height: 100%;\n opacity: 0;\n &:focus {\n outline: none;\n }\n`\n"],"names":["spinAnimation","keyframes","IconContainer","styled","div","withConfig","displayName","componentId","ChevronIcon","ChevronDown","shouldForwardProp","propKey","props","up","LoadingIconAnimated","LoaderFill","InputMimic","input"],"mappings":"wGAGA,MAAMA,cAAgBC,UAIrB,CAAA,0CAEYC,cAAgBC,OAAOC,IAAGC,WAAA,CAAAC,YAAA,0BAAAC,YAAA,mBAAVJ,CAM5B,CAAA,gGAEM,MAAMK,YAAcL,OAAOM,aAAaJ,WAA4B,CACzEK,kBAAoBC,GAAYA,IAAY,OAC5CN,WAAA,CAAAC,YAAA,wBAAAC,YAAA,mBAFyBJ,CAEzB,CAAA,GAAA,KACGS,GAAU,gIAISA,EAAMC,GAAK,IAAM,eAIlC,MAAMC,oBAAsBX,OAAOY,YAAWV,WAAA,CAAAC,YAAA,gCAAAC,YAAA,mBAAlBJ,CAAkB,CAAA,qCAAA,4BAEtCH,qBAGFgB,WAAab,OAAOc,MAAKZ,WAAA,CAAAC,YAAA,uBAAAC,YAAA,mBAAZJ,CAgBzB,CAAA"}
|