UNPKG

@fluentui/react-northstar

Version:
77 lines (75 loc) 4.03 kB
"use strict"; exports.__esModule = true; exports.gridClassName = exports.Grid = void 0; var _reactBindings = require("@fluentui/react-bindings"); var customPropTypes = _interopRequireWildcard(require("@fluentui/react-proptypes")); var PropTypes = _interopRequireWildcard(require("prop-types")); 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 gridClassName = 'ui-grid'; exports.gridClassName = gridClassName; /** * A Grid is a layout component that harmonizes negative space, by controlling both the row and column alignment. */ var Grid = /*#__PURE__*/React.forwardRef(function (props, ref) { var context = (0, _reactBindings.useFluentContext)(); var _useTelemetry = (0, _reactBindings.useTelemetry)(Grid.displayName, context.telemetry), setStart = _useTelemetry.setStart, setEnd = _useTelemetry.setEnd; setStart(); var accessibility = props.accessibility, children = props.children, className = props.className, columns = props.columns, content = props.content, design = props.design, rows = props.rows, styles = props.styles, variables = props.variables; var getA11yProps = (0, _reactBindings.useAccessibility)(accessibility, { debugName: Grid.displayName, rtl: context.rtl }); var _useStyles = (0, _reactBindings.useStyles)(Grid.displayName, { className: gridClassName, mapPropsToStyles: function mapPropsToStyles() { return { columns: columns, rows: rows }; }, mapPropsToInlineStyles: function mapPropsToInlineStyles() { return { className: className, design: design, styles: styles, variables: variables }; }, rtl: context.rtl }), classes = _useStyles.classes; var ElementType = (0, _reactBindings.getElementType)(props); var unhandledProps = (0, _reactBindings.useUnhandledProps)(Grid.handledProps, props); var element = getA11yProps.unstable_wrapWithFocusZone( /*#__PURE__*/React.createElement(ElementType, getA11yProps('root', Object.assign({ className: classes.root, ref: ref }, _utils.rtlTextContainer.getAttributes({ forElements: [children, content] }), unhandledProps)), (0, _utils.childrenExist)(children) ? children : content)); setEnd(); return element; }); exports.Grid = Grid; Grid.displayName = 'Grid'; Grid.propTypes = Object.assign({}, _utils.commonPropTypes.createCommon({ content: false }), { columns: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), content: customPropTypes.every([customPropTypes.disallow(['children']), PropTypes.oneOfType([PropTypes.arrayOf(customPropTypes.nodeContent), customPropTypes.nodeContent])]), rows: PropTypes.oneOfType([PropTypes.string, PropTypes.number]) }); Grid.handledProps = Object.keys(Grid.propTypes); //# sourceMappingURL=Grid.js.map