UNPKG

@fluentui/react-northstar

Version:
96 lines (94 loc) 4.69 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports.accordionContentClassName = exports.AccordionContent = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _invoke2 = _interopRequireDefault(require("lodash/invoke")); var _accessibility = require("@fluentui/accessibility"); var PropTypes = _interopRequireWildcard(require("prop-types")); var React = _interopRequireWildcard(require("react")); var _utils = require("../../utils"); var _reactBindings = require("@fluentui/react-bindings"); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } var accordionContentClassName = 'ui-accordion__content'; exports.accordionContentClassName = accordionContentClassName; /** * An AccordionContent displays content hosted in an Accordion. */ var AccordionContent = /*#__PURE__*/React.forwardRef(function (props, ref) { var context = (0, _reactBindings.useFluentContext)(); var _useTelemetry = (0, _reactBindings.useTelemetry)(AccordionContent.displayName, context.telemetry), setStart = _useTelemetry.setStart, setEnd = _useTelemetry.setEnd; setStart(); var children = props.children, content = props.content, accordionTitleId = props.accordionTitleId, active = props.active, className = props.className, design = props.design, styles = props.styles, variables = props.variables; var ElementType = (0, _reactBindings.getElementType)(props); var unhandledProps = (0, _reactBindings.useUnhandledProps)(AccordionContent.handledProps, props); var getA11yProps = (0, _reactBindings.useAccessibility)(props.accessibility, { debugName: AccordionContent.displayName, mapPropsToBehavior: function mapPropsToBehavior() { return { accordionTitleId: accordionTitleId }; }, rtl: context.rtl }); var handleClick = function handleClick(e) { (0, _invoke2.default)(props, 'onClick', e, props); }; var _useStyles = (0, _reactBindings.useStyles)(AccordionContent.displayName, { className: accordionContentClassName, mapPropsToStyles: function mapPropsToStyles() { return { active: active }; }, mapPropsToInlineStyles: function mapPropsToInlineStyles() { return { className: className, design: design, styles: styles, variables: variables }; }, rtl: context.rtl }), classes = _useStyles.classes; var element = /*#__PURE__*/React.createElement(ElementType, (0, _extends2.default)({}, getA11yProps('root', Object.assign({ className: classes.root, onClick: handleClick, ref: ref }, unhandledProps)), _utils.rtlTextContainer.getAttributes({ forElements: [children, content] })), (0, _utils.childrenExist)(children) ? children : content); setEnd(); return element; }); exports.AccordionContent = AccordionContent; AccordionContent.displayName = 'AccordionContent'; AccordionContent.shorthandConfig = { mappedProp: 'content' }; AccordionContent.propTypes = Object.assign({}, _utils.commonPropTypes.createCommon(), { accordionTitleId: PropTypes.string, active: PropTypes.bool, onClick: PropTypes.func }); AccordionContent.defaultProps = { accessibility: _accessibility.accordionContentBehavior, as: 'div' }; AccordionContent.handledProps = Object.keys(AccordionContent.propTypes); AccordionContent.create = (0, _utils.createShorthandFactory)({ Component: AccordionContent, mappedProp: 'content' }); //# sourceMappingURL=AccordionContent.js.map