UNPKG

@carbon/react

Version:

React components for the Carbon Design System

100 lines (94 loc) 2.83 kB
/** * Copyright IBM Corp. 2016, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js'); var PropTypes = require('prop-types'); var React = require('react'); var cx = require('classnames'); var Search = require('../Search/Search.js'); require('../Search/Search.Skeleton.js'); var usePrefix = require('../../internal/usePrefix.js'); var FormContext = require('../FluidForm/FormContext.js'); const frFn = React.forwardRef; const FluidSearch = frFn(({ className, ...other }, ref) => { const prefix = usePrefix.usePrefix(); const classNames = cx(`${prefix}--search--fluid`, className); return /*#__PURE__*/React.createElement(FormContext.FormContext.Provider, { value: { isFluid: true } }, /*#__PURE__*/React.createElement(Search.default, _rollupPluginBabelHelpers.extends({ ref: ref, className: classNames }, other))); }); FluidSearch.propTypes = { /** * Specify an optional value for the `autocomplete` property on the underlying * `<input>`, defaults to "off" */ autoComplete: PropTypes.string, /** * Specify an optional className to be applied to the container node */ className: PropTypes.string, /** * Specify a label to be read by screen readers on the "close" button */ closeButtonLabelText: PropTypes.string, /** * Optionally provide the default value of the `<input>` */ defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** * Specify whether the `<input>` should be disabled */ disabled: PropTypes.bool, /** * Specify a custom `id` for the input */ id: PropTypes.string, /** * Provide the label text for the Search icon */ labelText: PropTypes.node.isRequired, /** * Optional callback called when the search value changes. */ onChange: PropTypes.func, /** * Optional callback called when the search value is cleared. */ onClear: PropTypes.func, /** * Provide a handler that is invoked on the key down event for the input */ onKeyDown: PropTypes.func, /** * Provide an optional placeholder text for the Search. * Note: if the label and placeholder differ, * VoiceOver on Mac will read both */ placeholder: PropTypes.string, /** * Specify the role for the underlying `<input>`, defaults to `searchbox` */ role: PropTypes.string, /** * Optional prop to specify the type of the `<input>` */ type: PropTypes.string, /** * Specify the value of the `<input>` */ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) }; exports.default = FluidSearch;