UNPKG

@carbon/react

Version:

React components for the Carbon Design System

80 lines (76 loc) 2.16 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 PropTypes from 'prop-types'; import cx from 'classnames'; import DatePicker from '../DatePicker/DatePicker.js'; import '../DatePicker/DatePicker.Skeleton.js'; import { usePrefix } from '../../internal/usePrefix.js'; import { FormContext } from '../FluidForm/FormContext.js'; import React from 'react'; const FluidDatePicker = /*#__PURE__*/React.forwardRef(function FluidDatePicker({ className, children, invalid, invalidText, readOnly, warn, warnText, ...other }, ref) { const prefix = usePrefix(); const classNames = cx(className, { [`${prefix}--date-picker--fluid`]: true, [`${prefix}--date-picker--fluid--invalid`]: invalid, [`${prefix}--date-picker--fluid--readonly`]: readOnly, [`${prefix}--date-picker--fluid--warn`]: warn }); return /*#__PURE__*/React.createElement(FormContext.Provider, { value: { isFluid: true } }, /*#__PURE__*/React.createElement(DatePicker, _extends({ invalid: invalid, invalidText: invalidText, readOnly: readOnly, warn: warn, warnText: warnText, className: classNames, ref: ref }, other), children)); }); FluidDatePicker.propTypes = { /** * The child node(s) */ children: PropTypes.node, /** * Specify an optional className to be applied to the outer FluidForm wrapper */ className: PropTypes.string, /** * Specify whether or not the control is invalid */ invalid: PropTypes.bool, /** * Provide the text that is displayed when the control is in error state */ invalidText: PropTypes.node, /** * Whether the input should be read-only */ readOnly: PropTypes.bool, /** * 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 }; export { FluidDatePicker as default };