@carbon/react
Version:
React components for the Carbon Design System
74 lines (68 loc) • 2.02 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');
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({
[`${prefix}--select`]: true,
[`${prefix}--time-picker__select`]: true,
...(className && {
[className]: true
})
});
return /*#__PURE__*/React.createElement("div", {
className: selectClasses
}, /*#__PURE__*/React.createElement("select", _rollupPluginBabelHelpers.extends({
"aria-label": ariaLabel,
className: `${prefix}--select-input`,
disabled: disabled,
id: id,
ref: ref
}, rest), children), /*#__PURE__*/React.createElement(iconsReact.ChevronDown, {
className: `${prefix}--select__arrow`,
"aria-hidden": "true"
}));
});
TimePickerSelect.propTypes = {
/**
* Provide the contents of your TimePickerSelect
*/
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
};
exports.default = TimePickerSelect;