UNPKG

@fluentui/react-northstar

Version:
70 lines (67 loc) 3.63 kB
"use strict"; exports.__esModule = true; exports.boxClassName = exports.Box = void 0; var _reactBindings = require("@fluentui/react-bindings"); var React = _interopRequireWildcard(require("react")); var _utils = require("../../utils"); 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 boxClassName = 'ui-box'; /** * A Box is a basic component, commonly used for slots in other Fluent UI components. * By default it just renders a `div`. */ exports.boxClassName = boxClassName; var Box = (0, _reactBindings.compose)(function (props, ref, composeOptions) { var context = (0, _reactBindings.useFluentContext)(); var _useTelemetry = (0, _reactBindings.useTelemetry)(composeOptions.displayName, context.telemetry), setStart = _useTelemetry.setStart, setEnd = _useTelemetry.setEnd; setStart(); var accessibility = props.accessibility, className = props.className, design = props.design, styles = props.styles, variables = props.variables, children = props.children, content = props.content; var getA11yProps = (0, _reactBindings.useAccessibility)(accessibility, { debugName: composeOptions.displayName, rtl: context.rtl }); var _useStyles = (0, _reactBindings.useStyles)(composeOptions.displayName, { className: composeOptions.className, composeOptions: composeOptions, mapPropsToInlineStyles: function mapPropsToInlineStyles() { return { className: className, design: design, styles: styles, variables: variables }; }, rtl: context.rtl, unstable_props: props }), classes = _useStyles.classes; var unhandledProps = (0, _reactBindings.useUnhandledProps)(composeOptions.handledProps, props); var ElementType = (0, _reactBindings.getElementType)(props); var result = getA11yProps.unstable_wrapWithFocusZone( /*#__PURE__*/React.createElement(ElementType, getA11yProps('root', Object.assign({}, _utils.rtlTextContainer.getAttributes({ forElements: [children, content] }), { className: classes.root, ref: ref }, unhandledProps)), (0, _utils.childrenExist)(children) ? children : content)); setEnd(); return result; }, { className: boxClassName, displayName: 'Box', handledProps: ['accessibility', 'as', 'className', 'children', 'content', 'design', 'styles', 'variables'] }); exports.Box = Box; Box.propTypes = _utils.commonPropTypes.createCommon(); Box.create = (0, _utils.createShorthandFactory)({ Component: Box }); //# sourceMappingURL=Box.js.map