UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

51 lines 3.71 kB
import { jsx as _jsx } from "react/jsx-runtime"; import React from 'react'; import { STYLES_NAME } from '../../constants/stylesName/stylesName'; import { useMediaDevice } from '../../hooks/useMediaDevice/useMediaDevice'; import { useStyles } from '../../hooks/useStyles/useStyles'; import { ErrorBoundary } from '../../provider/errorBoundary/errorBoundary'; import { FallbackComponent } from '../../provider/errorBoundary/fallbackComponent'; import { INTERNAL_ERROR_EXECUTION } from '../input/types/input'; import { InputTypeType } from '../input/types/inputType'; import { useInputDropdown } from './hooks/useInputDropdown'; import { InputDropdownStandAlone } from './inputDropdownStandAlone'; const DEFAULT_LIMIT = 4; const InputDropdownComponent = React.forwardRef(({ open = false, type = InputTypeType.TEXT, elementsToShow = DEFAULT_LIMIT, clearTextInputPopoverIconClick = true, internalErrorExecution = INTERNAL_ERROR_EXECUTION.ON_CHANGE_ON_BLUR, value, icon, disabled, error, optionList, informationAssociatedValue, variant, onClick, onInputPopoverIconClick, onBlur, onChange, onFocus, onOpenCloseOptions, name, ctv, ...props }, ref) => { const styles = useStyles(STYLES_NAME.INMPUT_DROPDOWN, variant, ctv); const device = useMediaDevice(); const hasIconAction = !!icon?.onClick || !!props.rightIcon?.onClick; const { openOptions, optionsFiltered, searchText, inputPopoverText, valueSearchSelected, handleChangeInputDropdown, handleClickInputDropdown, handleClickIconInputDropdown, handleInputPopoverIconClick, handleOpenOptions, handleValueSelected, handleInputKeyDown, handleInputBlur, state, ref: innerRef, listOptionsHeight, handleFocusInternal, handleInputPopoverChange, } = useInputDropdown({ internalErrorExecution, open, optionList, type, value, allowSearch: props.allowSearch, styles, onClick, onIconClick: icon?.onClick, onRightIconClick: props.rightIcon?.onClick, onInputPopoverIconClick, elementsToShow, disabled, error, informationAssociated: informationAssociatedValue?.content, ref, name, onBlur, onChange, onFocus, hasInputInSearchList: props.hasInputInSearchList, onOpenCloseOptions, clearTextInputPopoverIconClick, }); return (_jsx(InputDropdownStandAlone, { ...props, ref: innerRef, device: device, icon: { ...icon, onClick: hasIconAction ? handleClickIconInputDropdown : undefined }, informationAssociatedValue: informationAssociatedValue, inputPopoverValue: inputPopoverText, listOptionsHeight: listOptionsHeight, open: openOptions, optionList: optionsFiltered, rightIcon: { ...props.rightIcon, onClick: hasIconAction ? handleClickIconInputDropdown : undefined, }, searchText: searchText, state: state, styles: styles, type: type, value: valueSearchSelected, onBlur: handleInputBlur, onChange: handleChangeInputDropdown, onClick: handleClickInputDropdown, onFocus: handleFocusInternal, onInputPopoverChange: handleInputPopoverChange, onInputPopoverIconClick: handleInputPopoverIconClick, onKeyDown: handleInputKeyDown, onOpenOptions: handleOpenOptions, onValueSelected: handleValueSelected })); }); InputDropdownComponent.displayName = 'InputDropdownComponent'; const InputDropdownBoundary = (props, ref) => (_jsx(ErrorBoundary, { fallBackComponent: _jsx(FallbackComponent, { children: _jsx(InputDropdownStandAlone, { ...props, ref: ref }) }), children: _jsx(InputDropdownComponent, { ...props, ref: ref }) })); const InputDropdown = React.forwardRef(InputDropdownBoundary); export { InputDropdown }; //# sourceMappingURL=inputDropdown.js.map