UNPKG

@breakaway/react-core

Version:

This library provides a set of common React components for use with the PatternFly reference implementation.

23 lines 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PageGroup = void 0; const tslib_1 = require("tslib"); const React = tslib_1.__importStar(require("react")); const react_styles_1 = require("@breakaway/react-styles"); const page_1 = tslib_1.__importDefault(require("@breakaway/react-styles/css/components/Page/page")); const util_1 = require("../../helpers/util"); const PageContext_1 = require("./PageContext"); const PageGroup = (_a) => { var { className = '', children, sticky, stickyOnBreakpoint, hasShadowTop = false, hasShadowBottom = false, hasOverflowScroll = false, 'aria-label': ariaLabel } = _a, props = tslib_1.__rest(_a, ["className", "children", "sticky", "stickyOnBreakpoint", "hasShadowTop", "hasShadowBottom", "hasOverflowScroll", 'aria-label']); const { height, getVerticalBreakpoint } = React.useContext(PageContext_1.PageContext); React.useEffect(() => { if (hasOverflowScroll && !ariaLabel) { /* eslint-disable no-console */ console.warn('PageGroup: An accessible aria-label is required when hasOverflowScroll is set to true.'); } }, [hasOverflowScroll, ariaLabel]); return (React.createElement("div", Object.assign({}, props, { className: react_styles_1.css(page_1.default.pageMainGroup, util_1.formatBreakpointMods(stickyOnBreakpoint, page_1.default, 'sticky-', getVerticalBreakpoint(height), true), sticky === 'top' && page_1.default.modifiers.stickyTop, sticky === 'bottom' && page_1.default.modifiers.stickyBottom, hasShadowTop && page_1.default.modifiers.shadowTop, hasShadowBottom && page_1.default.modifiers.shadowBottom, hasOverflowScroll && page_1.default.modifiers.overflowScroll, className) }, (hasOverflowScroll && { tabIndex: 0 }), { "aria-label": ariaLabel }), children)); }; exports.PageGroup = PageGroup; exports.PageGroup.displayName = 'PageGroup'; //# sourceMappingURL=PageGroup.js.map