@carbon/react
Version:
React components for the Carbon Design System
84 lines (78 loc) • 2.3 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.
*/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
var PropTypes = require('prop-types');
var cx = require('classnames');
var DatePicker = require('../DatePicker/DatePicker.js');
require('../DatePicker/DatePicker.Skeleton.js');
var usePrefix = require('../../internal/usePrefix.js');
var FormContext = require('../FluidForm/FormContext.js');
var React = require('react');
const FluidDatePicker = /*#__PURE__*/React.forwardRef(function FluidDatePicker({
className,
children,
invalid,
invalidText,
readOnly,
warn,
warnText,
...other
}, ref) {
const prefix = usePrefix.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.FormContext.Provider, {
value: {
isFluid: true
}
}, /*#__PURE__*/React.createElement(DatePicker.default, _rollupPluginBabelHelpers.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
};
exports.default = FluidDatePicker;