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

63 lines 5.06 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.InputSearch = 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 options_1 = require("./helpers/options"); const useInputSearch_1 = require("./hooks/useInputSearch"); const inputSearchStandAlone_1 = require("./inputSearchStandAlone"); const DEFAULT_LIMIT = 4; const InputSearchComponent = react_1.default.forwardRef(({ open = false, type = inputType_1.InputTypeType.TEXT, elementsToShow = DEFAULT_LIMIT, hasResultTextWrittenByUser = true, disableErrorInvalidOption = false, clearTextInputPopoverIconClick = true, highlightedOption = '', internalErrorExecution = input_1.INTERNAL_ERROR_EXECUTION.ON_CHANGE_ON_BLUR, value, disabled, error, optionList, informationAssociatedValue, variant, maxLength, regex, onClick, onInputPopoverIconClick, onInputPopoverEnterKeyDown, onBlur, onChange, onFocus, onKeyDown, onPopoverOpen, onOptionClick, onInternalErrors, executeInternalOpenOptions, ctv, blockBackPopover = false, searchFilterConfig, caseSensitive, ...props }, ref) => { const styles = (0, useStyles_1.useStyles)(stylesName_1.STYLES_NAME.INPUT_SEARCH, variant, ctv); const device = (0, useMediaDevice_1.useMediaDevice)(); const { openOptions, optionsFiltered, searchText, inputPopoverText, showHighlightedOption, handleChangeInputSearch, handleClickInputSearch, handleIconClick, handleRightIconClick, handleInputPopoverIconClick, handleOpenOptions, handleValueSelected, handleInputKeyDown, state, ref: innerRef, listOptionsHeight, handleBlurInternal, handleFocusInternal, handleInputPopoverChange, handleInputPopoverKeyDown, handleOptionsListKeyDown, } = (0, useInputSearch_1.useInputSearch)({ internalErrorExecution, open, type, options: optionList, value, styles, maxLength, regex, onClick, onIconClick: props.icon?.onClick, onRightIconClick: props.rightIcon?.onClick, executeInternalOpenOptions, onInputPopoverIconClick, onInputPopoverEnterKeyDown, elementsToShow, disabled, error, informationAssociated: informationAssociatedValue?.content, ref, hasResultTextWrittenByUser, disableErrorInvalidOption, highlightedOption, clearTextInputPopoverIconClick, onBlur, onChange, onFocus, onKeyDown, onPopoverOpen, onOptionClick, onInternalErrors, searchFilterConfig, caseSensitive, }); return ((0, jsx_runtime_1.jsx)(inputSearchStandAlone_1.InputSearchStandAlone, { ...props, ref: innerRef, blockBackPopover: blockBackPopover, caseSensitive: caseSensitive, device: device, error: error, hasHighlightedOption: showHighlightedOption, hasResultTextWrittenByUser: hasResultTextWrittenByUser, highlightedOption: highlightedOption, icon: { ...props.icon, onClick: handleIconClick }, informationAssociatedValue: informationAssociatedValue, initialOptionsLength: (0, options_1.getLength)(optionList), inputPopoverValue: inputPopoverText, listOptionsHeight: listOptionsHeight, maxLength: maxLength, open: openOptions, optionList: optionsFiltered, regex: regex, rightIcon: { ...props.rightIcon, onClick: handleRightIconClick }, searchText: searchText, state: state, styles: styles, type: type, value: searchText, onBlur: handleBlurInternal, onChange: handleChangeInputSearch, onClick: handleClickInputSearch, onFocus: handleFocusInternal, onInputPopoverChange: handleInputPopoverChange, onInputPopoverIconClick: handleInputPopoverIconClick, onInputPopoverKeyDown: handleInputPopoverKeyDown, onKeyDown: handleInputKeyDown, onOpenOptions: handleOpenOptions, onOptionsListKeyDown: handleOptionsListKeyDown, onValueSelected: handleValueSelected })); }); InputSearchComponent.displayName = 'InputSearchComponent'; const InputSearchBoundary = (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)(inputSearchStandAlone_1.InputSearchStandAlone, { ...props, ref: ref }) }), children: (0, jsx_runtime_1.jsx)(InputSearchComponent, { ...props, ref: ref }) })); const InputSearch = react_1.default.forwardRef(InputSearchBoundary); exports.InputSearch = InputSearch; //# sourceMappingURL=inputSearch.js.map