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

57 lines 4.29 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.InputDropdown = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = __importDefault(require("react")); const stylesName_1 = require("../../constants/stylesName/stylesName"); const useMediaDevice_1 = require("../../hooks/useMediaDevice/useMediaDevice"); const useStyles_1 = require("../../hooks/useStyles/useStyles"); const errorBoundary_1 = require("../../provider/errorBoundary/errorBoundary"); const fallbackComponent_1 = require("../../provider/errorBoundary/fallbackComponent"); const input_1 = require("../input/types/input"); const inputType_1 = require("../input/types/inputType"); const useInputDropdown_1 = require("./hooks/useInputDropdown"); const inputDropdownStandAlone_1 = require("./inputDropdownStandAlone"); const DEFAULT_LIMIT = 4; const InputDropdownComponent = react_1.default.forwardRef(({ open = false, type = inputType_1.InputTypeType.TEXT, elementsToShow = DEFAULT_LIMIT, clearTextInputPopoverIconClick = true, internalErrorExecution = input_1.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 = (0, useStyles_1.useStyles)(stylesName_1.STYLES_NAME.INMPUT_DROPDOWN, variant, ctv); const device = (0, useMediaDevice_1.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, } = (0, useInputDropdown_1.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 ((0, jsx_runtime_1.jsx)(inputDropdownStandAlone_1.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) => ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { fallBackComponent: (0, jsx_runtime_1.jsx)(fallbackComponent_1.FallbackComponent, { children: (0, jsx_runtime_1.jsx)(inputDropdownStandAlone_1.InputDropdownStandAlone, { ...props, ref: ref }) }), children: (0, jsx_runtime_1.jsx)(InputDropdownComponent, { ...props, ref: ref }) })); const InputDropdown = react_1.default.forwardRef(InputDropdownBoundary); exports.InputDropdown = InputDropdown; //# sourceMappingURL=inputDropdown.js.map