@carbon/react
Version:
React components for the Carbon Design System
97 lines (89 loc) • 3.13 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 Select = require('../Select/Select.js');
require('../Select/Select.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 FluidSelect = /*#__PURE__*/React__default["default"].forwardRef(function FluidSelect({
className,
children,
...other
}, ref) {
const prefix = usePrefix.usePrefix();
const classNames = cx__default["default"](`${prefix}--select--fluid`, className);
return /*#__PURE__*/React__default["default"].createElement(FormContext.FormContext.Provider, {
value: {
isFluid: true
}
}, /*#__PURE__*/React__default["default"].createElement(Select["default"], _rollupPluginBabelHelpers["extends"]({
ref: ref,
className: classNames
}, other), children));
});
FluidSelect.propTypes = {
/**
* Provide the contents of your Select
*/
children: PropTypes__default["default"].node,
/**
* Specify an optional className to be applied to the node containing the label and the select box
*/
className: PropTypes__default["default"].string,
/**
* Optionally provide the default value of the `<select>`
*/
defaultValue: PropTypes__default["default"].any,
/**
* Specify whether the control is disabled
*/
disabled: PropTypes__default["default"].bool,
/**
* Specify a custom `id` for the `<select>`
*/
id: PropTypes__default["default"].string.isRequired,
/**
* Specify if the currently value is invalid.
*/
invalid: PropTypes__default["default"].bool,
/**
* Message which is displayed if the value is invalid.
*/
invalidText: PropTypes__default["default"].node,
/**
* Provide label text to be read by screen readers when interacting with the
* control
*/
labelText: PropTypes__default["default"].node,
/**
* Provide an optional `onChange` hook that is called each time the value of
* the underlying `<input>` changes
*/
onChange: PropTypes__default["default"].func,
/**
* Specify whether the control is currently in warning state
*/
warn: PropTypes__default["default"].bool,
/**
* Provide the text that is displayed when the control is in warning state
*/
warnText: PropTypes__default["default"].node,
/**
* Whether or not the component is readonly
*/
readOnly: PropTypes__default["default"].bool
};
exports["default"] = FluidSelect;