UNPKG

@carbon/react

Version:

React components for the Carbon Design System

70 lines (66 loc) 1.9 kB
/** * 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. */ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js'; import { ChevronDown } from '@carbon/icons-react'; import cx from 'classnames'; import PropTypes from 'prop-types'; import React, { forwardRef } from 'react'; import { usePrefix } from '../../internal/usePrefix.js'; const frFn = forwardRef; const TimePickerSelect = frFn((props, ref) => { const { ['aria-label']: ariaLabel = 'open list of options', children, id, disabled = false, className, ...rest } = props; const prefix = 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", _extends({ "aria-label": ariaLabel, className: `${prefix}--select-input`, disabled: disabled, id: id, ref: ref }, rest), children), /*#__PURE__*/React.createElement(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 }; export { TimePickerSelect as default };