@carbon/react
Version:
React components for the Carbon Design System
80 lines (72 loc) • 2.52 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.
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var iconsReact = require('@carbon/icons-react');
var cx = require('classnames');
var PropTypes = require('prop-types');
var React = require('react');
var usePrefix = require('../../internal/usePrefix.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
const frFn = React.forwardRef;
const TimePickerSelect = frFn((props, ref) => {
const {
['aria-label']: ariaLabel = 'open list of options',
children,
id,
disabled = false,
className,
...rest
} = props;
const prefix = usePrefix.usePrefix();
const selectClasses = cx__default["default"]({
[`${prefix}--select`]: true,
[`${prefix}--time-picker__select`]: true,
...(className && {
[className]: true
})
});
return /*#__PURE__*/React__default["default"].createElement("div", {
className: selectClasses
}, /*#__PURE__*/React__default["default"].createElement("select", _rollupPluginBabelHelpers["extends"]({
"aria-label": ariaLabel,
className: `${prefix}--select-input`,
disabled: disabled,
id: id,
ref: ref
}, rest), children), /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronDown, {
className: `${prefix}--select__arrow`,
"aria-hidden": "true"
}));
});
TimePickerSelect.propTypes = {
/**
* Provide the contents of your TimePickerSelect
*/
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
};
exports["default"] = TimePickerSelect;