UNPKG

@geneui/components

Version:

The Gene UI components library designed for BI tools

76 lines (73 loc) 2.16 kB
import { _ as _extends } from '../_rollupPluginBabelHelpers-e8fb2e5c.js'; import React__default, { forwardRef, useState, useCallback } from 'react'; import PropTypes from 'prop-types'; import ExtendedInput from '../ExtendedInput/index.js'; import '../index-031ff73c.js'; import '../configs-00612ce0.js'; import '../index-a0e4e333.js'; import '../dateValidation-67caec66.js'; import '../_commonjsHelpers-24198af3.js'; import 'react-dom'; import '../hooks/useDeviceType.js'; import '../hooks/useWindowSize.js'; import '../hooks/useDebounce.js'; import '../useEllipsisDetection-4d997d5d.js'; import '../Icon/index.js'; import '../style-inject.es-746bb8ed.js'; import '../SuggestionList/index.js'; import '../hooks/useKeyDown.js'; import '../hooks/useClickOutside.js'; import '../config-1053d64d.js'; import '../Scrollbar/index.js'; import '../callAfterDelay-7272faca.js'; import '../index-6d7e99cd.js'; import '../tslib.es6-f211516f.js'; import '../GeneUIProvider/index.js'; const Search = /*#__PURE__*/forwardRef((_ref, ref) => { let { onChange, placeholder, defaultValue, className, ...restProps } = _ref; const [value, setValue] = useState(defaultValue); const handleChange = useCallback(e => { setValue(e.target.value); onChange && onChange(e, e.target.value); }, [onChange]); return /*#__PURE__*/React__default.createElement(ExtendedInput, _extends({ ref: ref, placeholder: placeholder, onChange: handleChange }, restProps, { value: value, type: "text", icon: "bc-icon-search", className: "search-holder ".concat(className) })); }); Search.propTypes = { /** * Fires an event when the value of the 'Search' input changes. * Expected function signature: (event: Event, value: string) => void. */ onChange: PropTypes.func, /** * Placeholder for search input */ placeholder: PropTypes.string, /** * Initial value of 'Search'. */ defaultValue: PropTypes.string, /** * External/additional className for component */ className: PropTypes.string }; Search.defaultProps = { placeholder: 'Search', className: '' }; export { Search as default };