@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
82 lines (78 loc) • 2.21 kB
JavaScript
/**
* MSKCC 2021, 2024
*/
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import PropTypes from 'prop-types';
import React__default from 'react';
import cx from 'classnames';
import Select from '../Select/Select.js';
import '../Select/Select.Skeleton.js';
import { usePrefix } from '../../internal/usePrefix.js';
import { FormContext } from '../FluidForm/FormContext.js';
const FluidSelect = /*#__PURE__*/React__default.forwardRef(function FluidSelect(_ref, ref) {
let {
className,
children,
...other
} = _ref;
const prefix = usePrefix();
const classNames = cx(`${prefix}--select--fluid`, className);
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
value: {
isFluid: true
}
}, /*#__PURE__*/React__default.createElement(Select, _extends({
ref: ref,
className: classNames
}, other), children));
});
FluidSelect.propTypes = {
/**
* Provide the contents of your Select
*/
children: PropTypes.node,
/**
* Specify an optional className to be applied to the node containing the label and the select box
*/
className: PropTypes.string,
/**
* Optionally provide the default value of the `<select>`
*/
defaultValue: PropTypes.any,
/**
* Specify whether the control is disabled
*/
disabled: PropTypes.bool,
/**
* Specify a custom `id` for the `<select>`
*/
id: PropTypes.string.isRequired,
/**
* Specify if the currently value is invalid.
*/
invalid: PropTypes.bool,
/**
* Message which is displayed if the value is invalid.
*/
invalidText: PropTypes.node,
/**
* Provide label text to be read by screen readers when interacting with the
* control
*/
labelText: PropTypes.node,
/**
* Provide an optional `onChange` hook that is called each time the value of
* the underlying `<input>` changes
*/
onChange: PropTypes.func,
/**
* Specify whether the control is currently in warning state
*/
warn: PropTypes.bool,
/**
* Provide the text that is displayed when the control is in warning state
*/
warnText: PropTypes.node
};
var FluidSelect$1 = FluidSelect;
export { FluidSelect$1 as default };