@fluentui/react-northstar
Version:
A themable React component library.
106 lines (105 loc) • 3.75 kB
JavaScript
import _invoke from "lodash/invoke";
import { datepickerCalendarCellButtonBehavior } from '@fluentui/accessibility';
import { getElementType, useAccessibility, useStyles, useFluentContext, useTelemetry, useUnhandledProps, compose } from '@fluentui/react-bindings';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import { commonPropTypes } from '../../utils';
export var datepickerCalendarCellButtonClassName = 'ui-datepicker__calendarcellbutton';
/**
* A Datepicker cell is used to display calendar grid cell button.
*/
export var DatepickerCalendarCellButton = /*#__PURE__*/function () {
var DatepickerCalendarCellButton = compose(function (props, ref, composeOptions) {
var context = useFluentContext();
var _useTelemetry = useTelemetry(composeOptions.displayName, context.telemetry),
setStart = _useTelemetry.setStart,
setEnd = _useTelemetry.setEnd;
setStart();
var className = props.className,
design = props.design,
styles = props.styles,
variables = props.variables,
disabled = props.disabled,
selected = props.selected,
quiet = props.quiet,
today = props.today,
content = props.content;
var unhandledProps = useUnhandledProps(composeOptions.handledProps, props);
var ElementType = getElementType(props);
var getA11yProps = useAccessibility(props.accessibility, {
debugName: composeOptions.displayName,
actionHandlers: {
performClick: function performClick(e) {
// prevent Spacebar from scrolling
e.preventDefault();
handleClick(e);
}
},
mapPropsToBehavior: function mapPropsToBehavior() {
return {
selected: selected,
disabled: disabled,
quiet: quiet,
today: today
};
},
rtl: context.rtl
});
var _useStyles = useStyles(DatepickerCalendarCellButton.displayName, {
className: composeOptions.className,
mapPropsToStyles: function mapPropsToStyles() {
return {
disabled: disabled,
selected: selected,
quiet: quiet,
today: today
};
},
mapPropsToInlineStyles: function mapPropsToInlineStyles() {
return {
className: className,
design: design,
styles: styles,
variables: variables
};
},
rtl: context.rtl,
composeOptions: composeOptions,
unstable_props: props
}),
classes = _useStyles.classes;
var handleClick = function handleClick(e) {
if (disabled) {
e.preventDefault();
return;
}
_invoke(props, 'onClick', e, props);
};
var element = /*#__PURE__*/React.createElement(ElementType, getA11yProps('root', Object.assign({
className: classes.root,
onClick: handleClick,
ref: ref
}, unhandledProps)), content);
setEnd();
return element;
}, {
className: datepickerCalendarCellButtonClassName,
displayName: 'DatepickerCalendarCellButton',
handledProps: ['accessibility', 'as', 'className', 'content', 'design', 'disabled', 'onClick', 'selected', 'styles', 'variables', 'quiet', 'today']
});
DatepickerCalendarCellButton.propTypes = Object.assign({}, commonPropTypes.createCommon({
children: false
}), {
onClick: PropTypes.func,
disabled: PropTypes.bool,
selected: PropTypes.bool,
quiet: PropTypes.bool,
today: PropTypes.bool
});
DatepickerCalendarCellButton.defaultProps = {
accessibility: datepickerCalendarCellButtonBehavior,
as: 'button'
};
return DatepickerCalendarCellButton;
}();
//# sourceMappingURL=DatepickerCalendarCellButton.js.map