Debian Codegraph @

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

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