@carbon/react
Version:
React components for the Carbon Design System
105 lines (97 loc) • 3.6 kB
JavaScript
/**
* 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');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
const FluidSearch = /*#__PURE__*/React__default["default"].forwardRef(function FluidSearch({
className,
...other
}, ref) {
const prefix = usePrefix.usePrefix();
const classNames = cx__default["default"](`${prefix}--search--fluid`, className);
return /*#__PURE__*/React__default["default"].createElement(FormContext.FormContext.Provider, {
value: {
isFluid: true
}
}, /*#__PURE__*/React__default["default"].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__default["default"].string,
/**
* Specify an optional className to be applied to the container node
*/
className: PropTypes__default["default"].string,
/**
* Specify a label to be read by screen readers on the "close" button
*/
closeButtonLabelText: PropTypes__default["default"].string,
/**
* Optionally provide the default value of the `<input>`
*/
defaultValue: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number]),
/**
* Specify whether the `<input>` should be disabled
*/
disabled: PropTypes__default["default"].bool,
/**
* Specify a custom `id` for the input
*/
id: PropTypes__default["default"].string,
/**
* Provide the label text for the Search icon
*/
labelText: PropTypes__default["default"].node.isRequired,
/**
* Optional callback called when the search value changes.
*/
onChange: PropTypes__default["default"].func,
/**
* Optional callback called when the search value is cleared.
*/
onClear: PropTypes__default["default"].func,
/**
* Provide a handler that is invoked on the key down event for the input
*/
onKeyDown: PropTypes__default["default"].func,
/**
* Provide an optional placeholder text for the Search.
* Note: if the label and placeholder differ,
* VoiceOver on Mac will read both
*/
placeholder: PropTypes__default["default"].string,
/**
* Specify the role for the underlying `<input>`, defaults to `searchbox`
*/
role: PropTypes__default["default"].string,
/**
* Optional prop to specify the type of the `<input>`
*/
type: PropTypes__default["default"].string,
/**
* Specify the value of the `<input>`
*/
value: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].number])
};
exports["default"] = FluidSearch;