Debian Codegraph @

node/@patternfly/react-core/dist/js/components/Page/PageSection.js

raw
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.PageSection = exports.PageSectionTypes = exports.PageSectionVariants = void 0;
4 const tslib_1 = require("tslib");
5 const jsx_runtime_1 = require("react/jsx-runtime");
6 const react_1 = require("react");
7 const page_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/Page/page"));
8 const react_styles_1 = require("@patternfly/react-styles");
9 const util_1 = require("../../helpers/util");
10 const PageContext_1 = require("./PageContext");
11 const PageBody_1 = require("./PageBody");
12 var PageSectionVariants;
13 (function (PageSectionVariants) {
14 PageSectionVariants["default"] = "default";
15 PageSectionVariants["secondary"] = "secondary";
16 })(PageSectionVariants || (exports.PageSectionVariants = PageSectionVariants = {}));
17 var PageSectionTypes;
18 (function (PageSectionTypes) {
19 PageSectionTypes["default"] = "default";
20 PageSectionTypes["subNav"] = "subnav";
21 PageSectionTypes["breadcrumb"] = "breadcrumb";
22 PageSectionTypes["tabs"] = "tabs";
23 PageSectionTypes["wizard"] = "wizard";
24 })(PageSectionTypes || (exports.PageSectionTypes = PageSectionTypes = {}));
25 const variantType = {
26 [PageSectionTypes.default]: page_1.default.pageMainSection,
27 [PageSectionTypes.subNav]: page_1.default.pageMainSubnav,
28 [PageSectionTypes.breadcrumb]: page_1.default.pageMainBreadcrumb,
29 [PageSectionTypes.tabs]: page_1.default.pageMainTabs,
30 [PageSectionTypes.wizard]: page_1.default.pageMainWizard
31 };
32 const variantStyle = {
33 [PageSectionVariants.default]: '',
34 [PageSectionVariants.secondary]: page_1.default.modifiers.secondary
35 };
36 const PageSection = (_a) => {
37 var { className = '', children, variant = 'default', type = 'default', padding, isFilled, isWidthLimited = false, isCenterAligned = false, stickyOnBreakpoint, stickyBase, isStickyStuck = false, hasShadowTop = false, hasShadowBottom = false, hasOverflowScroll = false, 'aria-label': ariaLabel, component = 'section', hasBodyWrapper = true, isPlain = false, isNoPlainOnGlass = false } = _a, props = tslib_1.__rest(_a, ["className", "children", "variant", "type", "padding", "isFilled", "isWidthLimited", "isCenterAligned", "stickyOnBreakpoint", "stickyBase", "isStickyStuck", "hasShadowTop", "hasShadowBottom", "hasOverflowScroll", 'aria-label', "component", "hasBodyWrapper", "isPlain", "isNoPlainOnGlass"]);
38 const { height, getVerticalBreakpoint } = (0, react_1.useContext)(PageContext_1.PageContext);
39 (0, react_1.useEffect)(() => {
40 if (hasOverflowScroll && !ariaLabel) {
41 /* eslint-disable no-console */
42 console.warn('PageSection: An accessible aria-label is required when hasOverflowScroll is set to true.');
43 }
44 }, [hasOverflowScroll, ariaLabel]);
45 const Component = component;
46 return ((0, jsx_runtime_1.jsx)(Component, Object.assign({}, props, { className: (0, react_styles_1.css)(variantType[type], (0, util_1.formatBreakpointMods)(padding, page_1.default), (0, util_1.formatBreakpointMods)(stickyOnBreakpoint, page_1.default, 'sticky-', getVerticalBreakpoint(height), true), stickyBase === 'top' && page_1.default.modifiers.stickyTopBase, stickyBase === 'bottom' && page_1.default.modifiers.stickyBottomBase, isStickyStuck && stickyBase === 'top' && page_1.default.modifiers.stickyTopStuck, isStickyStuck && stickyBase === 'bottom' && page_1.default.modifiers.stickyBottomStuck, type === PageSectionTypes.default && variantStyle[variant], isFilled === false && page_1.default.modifiers.noFill, isFilled === true && page_1.default.modifiers.fill, isWidthLimited && page_1.default.modifiers.limitWidth, isWidthLimited && isCenterAligned && type !== PageSectionTypes.subNav && page_1.default.modifiers.alignCenter, hasShadowTop && page_1.default.modifiers.shadowTop, hasShadowBottom && page_1.default.modifiers.shadowBottom, hasOverflowScroll && page_1.default.modifiers.overflowScroll, isPlain && page_1.default.modifiers.plain, isNoPlainOnGlass && page_1.default.modifiers.noPlainOnGlass, className) }, (hasOverflowScroll && { tabIndex: 0 }), { "aria-label": ariaLabel, children: hasBodyWrapper ? (0, jsx_runtime_1.jsx)(PageBody_1.PageBody, { children: children }) : children })));
47 };
48 exports.PageSection = PageSection;
49 exports.PageSection.displayName = 'PageSection';
50 //# sourceMappingURL=PageSection.js.map