@patternfly/react-core 6.5.0-prerelease.1 → 6.5.0-prerelease.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/Compass/package.json +1 -1
- package/dist/dynamic/components/Content/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/Chip/package.json +1 -1
- package/dist/dynamic/deprecated/components/DragDrop/package.json +1 -1
- package/dist/dynamic/deprecated/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Modal/package.json +1 -1
- package/dist/dynamic/deprecated/components/Tile/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/AnimationsProvider/AnimationsProvider/package.json +1 -1
- package/dist/dynamic/helpers/AnimationsProvider/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/styles/package.json +1 -1
- package/dist/esm/components/Card/CardSubtitle.d.ts +9 -0
- package/dist/esm/components/Card/CardSubtitle.d.ts.map +1 -0
- package/dist/esm/components/Card/CardSubtitle.js +10 -0
- package/dist/esm/components/Card/CardSubtitle.js.map +1 -0
- package/dist/esm/components/Card/CardTitle.d.ts +2 -0
- package/dist/esm/components/Card/CardTitle.d.ts.map +1 -1
- package/dist/esm/components/Card/CardTitle.js +5 -3
- package/dist/esm/components/Card/CardTitle.js.map +1 -1
- package/dist/esm/components/Compass/Compass.d.ts.map +1 -1
- package/dist/esm/components/Compass/Compass.js +2 -2
- package/dist/esm/components/Compass/Compass.js.map +1 -1
- package/dist/esm/components/DataList/DataList.d.ts +2 -0
- package/dist/esm/components/DataList/DataList.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataList.js +2 -2
- package/dist/esm/components/DataList/DataList.js.map +1 -1
- package/dist/esm/components/Drawer/Drawer.d.ts +2 -0
- package/dist/esm/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/esm/components/Drawer/Drawer.js +2 -2
- package/dist/esm/components/Drawer/Drawer.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerPanelContent.d.ts +2 -0
- package/dist/esm/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerPanelContent.js +2 -2
- package/dist/esm/components/Drawer/DrawerPanelContent.js.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts +9 -2
- package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSection.js +5 -3
- package/dist/esm/components/ExpandableSection/ExpandableSection.js.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.d.ts +5 -0
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.d.ts.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.js +3 -2
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.js.map +1 -1
- package/dist/esm/components/Page/Page.d.ts.map +1 -1
- package/dist/esm/components/Page/Page.js +1 -0
- package/dist/esm/components/Page/Page.js.map +1 -1
- package/dist/esm/components/Page/PageContext.d.ts +1 -0
- package/dist/esm/components/Page/PageContext.d.ts.map +1 -1
- package/dist/esm/components/Page/PageContext.js +1 -0
- package/dist/esm/components/Page/PageContext.js.map +1 -1
- package/dist/esm/components/Page/PageSidebar.js +2 -2
- package/dist/esm/components/Page/PageSidebar.js.map +1 -1
- package/dist/esm/components/Progress/Progress.d.ts +2 -0
- package/dist/esm/components/Progress/Progress.d.ts.map +1 -1
- package/dist/esm/components/Progress/Progress.js +2 -2
- package/dist/esm/components/Progress/Progress.js.map +1 -1
- package/dist/esm/components/Progress/ProgressContainer.d.ts +2 -0
- package/dist/esm/components/Progress/ProgressContainer.d.ts.map +1 -1
- package/dist/esm/components/Progress/ProgressContainer.js +2 -2
- package/dist/esm/components/Progress/ProgressContainer.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +2 -2
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/Truncate/Truncate.d.ts.map +1 -1
- package/dist/esm/components/Truncate/Truncate.js +5 -4
- package/dist/esm/components/Truncate/Truncate.js.map +1 -1
- package/dist/js/components/Card/CardSubtitle.d.ts +9 -0
- package/dist/js/components/Card/CardSubtitle.d.ts.map +1 -0
- package/dist/js/components/Card/CardSubtitle.js +14 -0
- package/dist/js/components/Card/CardSubtitle.js.map +1 -0
- package/dist/js/components/Card/CardTitle.d.ts +2 -0
- package/dist/js/components/Card/CardTitle.d.ts.map +1 -1
- package/dist/js/components/Card/CardTitle.js +4 -2
- package/dist/js/components/Card/CardTitle.js.map +1 -1
- package/dist/js/components/Compass/Compass.d.ts.map +1 -1
- package/dist/js/components/Compass/Compass.js +1 -1
- package/dist/js/components/Compass/Compass.js.map +1 -1
- package/dist/js/components/DataList/DataList.d.ts +2 -0
- package/dist/js/components/DataList/DataList.d.ts.map +1 -1
- package/dist/js/components/DataList/DataList.js +2 -2
- package/dist/js/components/DataList/DataList.js.map +1 -1
- package/dist/js/components/Drawer/Drawer.d.ts +2 -0
- package/dist/js/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/js/components/Drawer/Drawer.js +2 -2
- package/dist/js/components/Drawer/Drawer.js.map +1 -1
- package/dist/js/components/Drawer/DrawerPanelContent.d.ts +2 -0
- package/dist/js/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerPanelContent.js +2 -2
- package/dist/js/components/Drawer/DrawerPanelContent.js.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSection.d.ts +9 -2
- package/dist/js/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSection.js +5 -3
- package/dist/js/components/ExpandableSection/ExpandableSection.js.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.d.ts +5 -0
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.d.ts.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.js +3 -2
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.js.map +1 -1
- package/dist/js/components/Page/Page.d.ts.map +1 -1
- package/dist/js/components/Page/Page.js +1 -0
- package/dist/js/components/Page/Page.js.map +1 -1
- package/dist/js/components/Page/PageContext.d.ts +1 -0
- package/dist/js/components/Page/PageContext.d.ts.map +1 -1
- package/dist/js/components/Page/PageContext.js +1 -0
- package/dist/js/components/Page/PageContext.js.map +1 -1
- package/dist/js/components/Page/PageSidebar.js +2 -2
- package/dist/js/components/Page/PageSidebar.js.map +1 -1
- package/dist/js/components/Progress/Progress.d.ts +2 -0
- package/dist/js/components/Progress/Progress.d.ts.map +1 -1
- package/dist/js/components/Progress/Progress.js +2 -2
- package/dist/js/components/Progress/Progress.js.map +1 -1
- package/dist/js/components/Progress/ProgressContainer.d.ts +2 -0
- package/dist/js/components/Progress/ProgressContainer.d.ts.map +1 -1
- package/dist/js/components/Progress/ProgressContainer.js +2 -2
- package/dist/js/components/Progress/ProgressContainer.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +2 -2
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/components/Truncate/Truncate.d.ts.map +1 -1
- package/dist/js/components/Truncate/Truncate.js +5 -4
- package/dist/js/components/Truncate/Truncate.js.map +1 -1
- package/dist/styles/base-no-reset.css +46 -0
- package/dist/styles/base.css +53 -0
- package/dist/umd/assets/{output-COsUhzfR.css → output-4DDCBaXc.css} +21206 -21163
- package/dist/umd/react-core.min.js +3 -3
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +6 -6
- package/src/components/Card/CardSubtitle.tsx +20 -0
- package/src/components/Card/CardTitle.tsx +6 -0
- package/src/components/Card/__tests__/CardSubtitle.test.tsx +48 -0
- package/src/components/Card/__tests__/CardTitle.test.tsx +27 -17
- package/src/components/Card/__tests__/__snapshots__/CardSubtitle.test.tsx.snap +21 -0
- package/src/components/Card/__tests__/__snapshots__/CardTitle.test.tsx.snap +1 -1
- package/src/components/Card/examples/Card.md +16 -1
- package/src/components/Card/examples/CardSubtitle.tsx +9 -0
- package/src/components/Card/examples/CardSubtitleActions.tsx +107 -0
- package/src/components/ClipboardCopy/__tests__/ClipboardCopyTruncateIntegration.test.tsx +32 -0
- package/src/components/Compass/Compass.tsx +4 -2
- package/src/components/Compass/__tests__/__snapshots__/Compass.test.tsx.snap +32 -28
- package/src/components/Compass/examples/Compass.md +10 -1
- package/src/components/Compass/examples/CompassDemo.tsx +6 -6
- package/src/components/DataList/DataList.tsx +4 -0
- package/src/components/DataList/__tests__/DataList.test.tsx +6 -0
- package/src/components/DataList/examples/DataList.md +6 -0
- package/src/components/DataList/examples/DataListPlain.tsx +32 -0
- package/src/components/Drawer/Drawer.tsx +4 -0
- package/src/components/Drawer/DrawerPanelContent.tsx +4 -0
- package/src/components/Drawer/__tests__/Drawer.test.tsx +26 -1
- package/src/components/Drawer/__tests__/DrawerPanelContent.test.tsx +10 -0
- package/src/components/Drawer/examples/Drawer.md +13 -0
- package/src/components/Drawer/examples/DrawerBasicPill.tsx +57 -0
- package/src/components/Drawer/examples/DrawerPillInline.tsx +57 -0
- package/src/components/ExpandableSection/ExpandableSection.tsx +17 -5
- package/src/components/ExpandableSection/ExpandableSectionToggle.tsx +48 -38
- package/src/components/ExpandableSection/__tests__/ExpandableSection.test.tsx +63 -0
- package/src/components/ExpandableSection/__tests__/ExpandableSectionToggle.test.tsx +28 -0
- package/src/components/ExpandableSection/examples/ExpandableSection.md +16 -0
- package/src/components/ExpandableSection/examples/ExpandableSectionCustomToggle.tsx +31 -16
- package/src/components/ExpandableSection/examples/ExpandableSectionUncontrolledDynamicToggleFunction.tsx +13 -0
- package/src/components/ExpandableSection/examples/ExpandableSectionWithHeading.tsx +89 -0
- package/src/components/Page/Page.tsx +1 -0
- package/src/components/Page/PageContext.tsx +2 -0
- package/src/components/Page/PageSidebar.tsx +2 -2
- package/src/components/Page/__tests__/Generated/__snapshots__/PageSidebar.test.tsx.snap +1 -1
- package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +12 -12
- package/src/components/Progress/Progress.tsx +4 -0
- package/src/components/Progress/ProgressContainer.tsx +5 -2
- package/src/components/Progress/__tests__/Generated/ProgressContainer.test.tsx +1 -0
- package/src/components/Progress/__tests__/Progress.test.tsx +32 -0
- package/src/components/Progress/examples/Progress.md +2 -14
- package/src/components/Progress/examples/ProgressInteractiveFailure.tsx +55 -0
- package/src/components/Tabs/Tabs.tsx +2 -2
- package/src/components/Tabs/__tests__/Tabs.test.tsx +60 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +13 -13
- package/src/components/Tabs/examples/Tabs.md +8 -0
- package/src/components/Tabs/examples/TabsSiteNav.tsx +40 -0
- package/src/components/Truncate/Truncate.tsx +5 -4
- package/src/components/Truncate/__tests__/Truncate.test.tsx +21 -3
- package/src/components/Truncate/__tests__/__snapshots__/Truncate.test.tsx.snap +3 -9
- package/src/components/Progress/examples/ProgressFailureWithoutMeasure.tsx +0 -5
- package/src/components/Progress/examples/ProgressInsideSuccess.tsx +0 -10
- package/src/components/Progress/examples/ProgressOutsideFailure.tsx +0 -10
|
@@ -17,6 +17,8 @@ export interface DrawerProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
17
17
|
isExpanded?: boolean;
|
|
18
18
|
/** Indicates if the content element and panel element are displayed side by side. */
|
|
19
19
|
isInline?: boolean;
|
|
20
|
+
/** @beta Indicates if the drawer will have pill styles */
|
|
21
|
+
isPill?: boolean;
|
|
20
22
|
/** Indicates if the drawer will always show both content and panel. */
|
|
21
23
|
isStatic?: boolean;
|
|
22
24
|
/** Position of the drawer panel. left and right are deprecated, use start and end instead. */
|
|
@@ -50,6 +52,7 @@ export const Drawer: React.FunctionComponent<DrawerProps> = ({
|
|
|
50
52
|
children,
|
|
51
53
|
isExpanded = false,
|
|
52
54
|
isInline = false,
|
|
55
|
+
isPill = false,
|
|
53
56
|
isStatic = false,
|
|
54
57
|
position = 'end',
|
|
55
58
|
onExpand = () => {},
|
|
@@ -65,6 +68,7 @@ export const Drawer: React.FunctionComponent<DrawerProps> = ({
|
|
|
65
68
|
styles.drawer,
|
|
66
69
|
isExpanded && styles.modifiers.expanded,
|
|
67
70
|
isInline && styles.modifiers.inline,
|
|
71
|
+
isPill && styles.modifiers.pill,
|
|
68
72
|
isStatic && styles.modifiers.static,
|
|
69
73
|
(position === 'left' || position === 'start') && styles.modifiers.panelLeft,
|
|
70
74
|
position === 'bottom' && styles.modifiers.panelBottom,
|
|
@@ -35,6 +35,8 @@ export interface DrawerPanelContentProps extends Omit<React.HTMLProps<HTMLDivEle
|
|
|
35
35
|
hasNoBorder?: boolean;
|
|
36
36
|
/** Flag indicating that the drawer panel should be resizable. */
|
|
37
37
|
isResizable?: boolean;
|
|
38
|
+
/** @beta Flag indicating that the drawer panel should disable glass styles. This prop is intended to work with isPill drawers. */
|
|
39
|
+
hasNoGlass?: boolean;
|
|
38
40
|
/** Callback for resize end. */
|
|
39
41
|
onResize?: (event: MouseEvent | TouchEvent | React.KeyboardEvent, width: number, id: string) => void;
|
|
40
42
|
/** The minimum size of a drawer. */
|
|
@@ -68,6 +70,7 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
|
|
|
68
70
|
children,
|
|
69
71
|
hasNoBorder = false,
|
|
70
72
|
isResizable = false,
|
|
73
|
+
hasNoGlass = false,
|
|
71
74
|
onResize,
|
|
72
75
|
minSize,
|
|
73
76
|
defaultSize,
|
|
@@ -364,6 +367,7 @@ export const DrawerPanelContent: React.FunctionComponent<DrawerPanelContentProps
|
|
|
364
367
|
className={css(
|
|
365
368
|
styles.drawerPanel,
|
|
366
369
|
isResizable && styles.modifiers.resizable,
|
|
370
|
+
hasNoGlass && styles.modifiers.noGlass,
|
|
367
371
|
hasNoBorder && styles.modifiers.noBorder,
|
|
368
372
|
formatBreakpointMods(widths, styles),
|
|
369
373
|
colorVariant === DrawerColorVariant.noBackground && styles.modifiers.noBackground,
|
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
DrawerPanelContent,
|
|
11
11
|
DrawerColorVariant
|
|
12
12
|
} from '../';
|
|
13
|
-
import { render } from '@testing-library/react';
|
|
13
|
+
import { screen, render } from '@testing-library/react';
|
|
14
14
|
import userEvent from '@testing-library/user-event';
|
|
15
15
|
import { KeyTypes } from '../../../helpers';
|
|
16
|
+
import styles from '@patternfly/react-styles/css/components/Drawer/drawer';
|
|
16
17
|
|
|
17
18
|
jest.mock('../../../helpers/GenerateId/GenerateId');
|
|
18
19
|
|
|
@@ -162,3 +163,27 @@ test('Resizeable DrawerPanelContent can be wrapped in a context without causing
|
|
|
162
163
|
|
|
163
164
|
expect(consoleError).not.toHaveBeenCalled();
|
|
164
165
|
});
|
|
166
|
+
|
|
167
|
+
test(`Renders with ${styles.modifiers.pill} class when specified`, () => {
|
|
168
|
+
const panelContent = (
|
|
169
|
+
<DrawerPanelContent>
|
|
170
|
+
<DrawerHead>
|
|
171
|
+
<span>drawer-panel</span>
|
|
172
|
+
<DrawerActions>
|
|
173
|
+
<DrawerCloseButton />
|
|
174
|
+
</DrawerActions>
|
|
175
|
+
</DrawerHead>
|
|
176
|
+
<DrawerPanelBody>drawer-panel</DrawerPanelBody>
|
|
177
|
+
</DrawerPanelContent>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
render(
|
|
181
|
+
<Drawer data-testid="drawer" isExpanded={true} position="left" isPill>
|
|
182
|
+
<DrawerContent panelContent={panelContent}>
|
|
183
|
+
<DrawerContentBody>Drawer content text</DrawerContentBody>
|
|
184
|
+
</DrawerContent>
|
|
185
|
+
</Drawer>
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(screen.getByTestId('drawer')).toHaveClass(styles.modifiers.pill);
|
|
189
|
+
});
|
|
@@ -158,3 +158,13 @@ test('Style prop overrides boundaryCssVars', () => {
|
|
|
158
158
|
'--pf-v6-c-drawer__panel--md--FlexBasis--max': '500px'
|
|
159
159
|
});
|
|
160
160
|
});
|
|
161
|
+
|
|
162
|
+
test(`Renders with class ${styles.modifiers.noGlass} when isPill is true`, () => {
|
|
163
|
+
render(
|
|
164
|
+
<Drawer isExpanded isPill>
|
|
165
|
+
<DrawerPanelContent hasNoGlass>Drawer panel content</DrawerPanelContent>
|
|
166
|
+
</Drawer>
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
expect(screen.getByText('Drawer panel content')).toHaveClass(styles.modifiers.noGlass);
|
|
170
|
+
});
|
|
@@ -17,6 +17,7 @@ propComponents:
|
|
|
17
17
|
]
|
|
18
18
|
section: components
|
|
19
19
|
---
|
|
20
|
+
|
|
20
21
|
import { Fragment, useRef, useState } from 'react';
|
|
21
22
|
import accessibility from '@patternfly/react-styles/css/utilities/Accessibility/accessibility';
|
|
22
23
|
|
|
@@ -143,3 +144,15 @@ To customize which element receives focus when the drawer panel expands, use the
|
|
|
143
144
|
```ts file="./DrawerFocusTrap.tsx"
|
|
144
145
|
|
|
145
146
|
```
|
|
147
|
+
|
|
148
|
+
### Pill
|
|
149
|
+
|
|
150
|
+
```ts file="./DrawerBasicPill.tsx"
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Pill inline
|
|
155
|
+
|
|
156
|
+
```ts file="./DrawerPillInline.tsx"
|
|
157
|
+
|
|
158
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Fragment, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Drawer,
|
|
4
|
+
DrawerPanelContent,
|
|
5
|
+
DrawerContent,
|
|
6
|
+
DrawerContentBody,
|
|
7
|
+
DrawerHead,
|
|
8
|
+
DrawerActions,
|
|
9
|
+
DrawerCloseButton,
|
|
10
|
+
Button
|
|
11
|
+
} from '@patternfly/react-core';
|
|
12
|
+
|
|
13
|
+
export const DrawerBasicPill: React.FunctionComponent = () => {
|
|
14
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
15
|
+
const drawerRef = useRef<HTMLDivElement>(undefined);
|
|
16
|
+
|
|
17
|
+
const onExpand = () => {
|
|
18
|
+
drawerRef.current && drawerRef.current.focus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const onClick = () => {
|
|
22
|
+
setIsExpanded(!isExpanded);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const onCloseClick = () => {
|
|
26
|
+
setIsExpanded(false);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const panelContent = (
|
|
30
|
+
<DrawerPanelContent>
|
|
31
|
+
<DrawerHead>
|
|
32
|
+
<span tabIndex={isExpanded ? 0 : -1} ref={drawerRef}>
|
|
33
|
+
Drawer panel header
|
|
34
|
+
</span>
|
|
35
|
+
<DrawerActions>
|
|
36
|
+
<DrawerCloseButton onClick={onCloseClick} />
|
|
37
|
+
</DrawerActions>
|
|
38
|
+
</DrawerHead>
|
|
39
|
+
</DrawerPanelContent>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const drawerContent =
|
|
43
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Fragment>
|
|
47
|
+
<Button aria-expanded={isExpanded} onClick={onClick}>
|
|
48
|
+
Toggle drawer
|
|
49
|
+
</Button>
|
|
50
|
+
<Drawer isExpanded={isExpanded} isPill onExpand={onExpand}>
|
|
51
|
+
<DrawerContent panelContent={panelContent}>
|
|
52
|
+
<DrawerContentBody>{drawerContent}</DrawerContentBody>
|
|
53
|
+
</DrawerContent>
|
|
54
|
+
</Drawer>
|
|
55
|
+
</Fragment>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Fragment, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Drawer,
|
|
4
|
+
DrawerPanelContent,
|
|
5
|
+
DrawerContent,
|
|
6
|
+
DrawerContentBody,
|
|
7
|
+
DrawerHead,
|
|
8
|
+
DrawerActions,
|
|
9
|
+
DrawerCloseButton,
|
|
10
|
+
Button
|
|
11
|
+
} from '@patternfly/react-core';
|
|
12
|
+
|
|
13
|
+
export const DrawerBasicPill: React.FunctionComponent = () => {
|
|
14
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
15
|
+
const drawerRef = useRef<HTMLDivElement>(undefined);
|
|
16
|
+
|
|
17
|
+
const onExpand = () => {
|
|
18
|
+
drawerRef.current && drawerRef.current.focus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const onClick = () => {
|
|
22
|
+
setIsExpanded(!isExpanded);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const onCloseClick = () => {
|
|
26
|
+
setIsExpanded(false);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const panelContent = (
|
|
30
|
+
<DrawerPanelContent>
|
|
31
|
+
<DrawerHead>
|
|
32
|
+
<span tabIndex={isExpanded ? 0 : -1} ref={drawerRef}>
|
|
33
|
+
Drawer panel header
|
|
34
|
+
</span>
|
|
35
|
+
<DrawerActions>
|
|
36
|
+
<DrawerCloseButton onClick={onCloseClick} />
|
|
37
|
+
</DrawerActions>
|
|
38
|
+
</DrawerHead>
|
|
39
|
+
</DrawerPanelContent>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const drawerContent =
|
|
43
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Fragment>
|
|
47
|
+
<Button aria-expanded={isExpanded} onClick={onClick}>
|
|
48
|
+
Toggle drawer
|
|
49
|
+
</Button>
|
|
50
|
+
<Drawer isExpanded={isExpanded} isPill isInline onExpand={onExpand}>
|
|
51
|
+
<DrawerContent panelContent={panelContent}>
|
|
52
|
+
<DrawerContentBody>{drawerContent}</DrawerContentBody>
|
|
53
|
+
</DrawerContent>
|
|
54
|
+
</Drawer>
|
|
55
|
+
</Fragment>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -44,8 +44,10 @@ export interface ExpandableSectionProps extends Omit<React.HTMLProps<HTMLDivElem
|
|
|
44
44
|
* use the onToggle property of the expandable section toggle sub-component.
|
|
45
45
|
*/
|
|
46
46
|
onToggle?: (event: React.MouseEvent, isExpanded: boolean) => void;
|
|
47
|
-
/** React node that appears in the attached toggle in place of the toggleText property.
|
|
48
|
-
|
|
47
|
+
/** React node that appears in the attached toggle in place of the toggleText property.
|
|
48
|
+
* Can also be a function that receives the expanded state and returns a React node.
|
|
49
|
+
*/
|
|
50
|
+
toggleContent?: React.ReactNode | ((isExpanded: boolean) => React.ReactNode);
|
|
49
51
|
/** Text that appears in the attached toggle. */
|
|
50
52
|
toggleText?: string;
|
|
51
53
|
/** Text that appears in the attached toggle when collapsed (will override toggleText if
|
|
@@ -72,6 +74,11 @@ export interface ExpandableSectionProps extends Omit<React.HTMLProps<HTMLDivElem
|
|
|
72
74
|
* animation will not occur.
|
|
73
75
|
*/
|
|
74
76
|
direction?: 'up' | 'down';
|
|
77
|
+
/** The HTML element to use for the toggle wrapper. Can be 'div' (default) or any heading level.
|
|
78
|
+
* When using heading elements, the button will be rendered inside the heading for proper semantics.
|
|
79
|
+
* This is useful when the toggle text should function as a heading in the document structure.
|
|
80
|
+
*/
|
|
81
|
+
toggleWrapper?: 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
interface ExpandableSectionState {
|
|
@@ -216,6 +223,7 @@ class ExpandableSection extends Component<ExpandableSectionProps, ExpandableSect
|
|
|
216
223
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
217
224
|
truncateMaxLines,
|
|
218
225
|
direction,
|
|
226
|
+
toggleWrapper = 'div',
|
|
219
227
|
...props
|
|
220
228
|
} = this.props;
|
|
221
229
|
|
|
@@ -246,8 +254,12 @@ class ExpandableSection extends Component<ExpandableSectionProps, ExpandableSect
|
|
|
246
254
|
propOrStateIsExpanded
|
|
247
255
|
);
|
|
248
256
|
|
|
257
|
+
const computedToggleContent =
|
|
258
|
+
typeof toggleContent === 'function' ? toggleContent(propOrStateIsExpanded) : toggleContent;
|
|
259
|
+
const ToggleWrapper = toggleWrapper as any;
|
|
260
|
+
|
|
249
261
|
const expandableToggle = !isDetached && (
|
|
250
|
-
<
|
|
262
|
+
<ToggleWrapper className={`${styles.expandableSection}__toggle`}>
|
|
251
263
|
<Button
|
|
252
264
|
variant="link"
|
|
253
265
|
{...(variant === ExpandableSectionVariant.truncate && { isInline: true })}
|
|
@@ -265,9 +277,9 @@ class ExpandableSection extends Component<ExpandableSectionProps, ExpandableSect
|
|
|
265
277
|
aria-label={toggleAriaLabel}
|
|
266
278
|
aria-labelledby={toggleAriaLabelledBy}
|
|
267
279
|
>
|
|
268
|
-
{
|
|
280
|
+
{computedToggleContent || computedToggleText}
|
|
269
281
|
</Button>
|
|
270
|
-
</
|
|
282
|
+
</ToggleWrapper>
|
|
271
283
|
);
|
|
272
284
|
|
|
273
285
|
return (
|
|
@@ -34,6 +34,11 @@ export interface ExpandableSectionToggleProps extends Omit<React.HTMLProps<HTMLD
|
|
|
34
34
|
toggleAriaLabel?: string;
|
|
35
35
|
/** Accessible name via space delimtted list of IDs for the expandable section toggle. */
|
|
36
36
|
toggleAriaLabelledBy?: string;
|
|
37
|
+
/** The HTML element to use for the toggle wrapper. Can be 'div' (default) or any heading level.
|
|
38
|
+
* When using heading elements, the button will be rendered inside the heading for proper semantics.
|
|
39
|
+
* This is useful when the toggle text should function as a heading in the document structure.
|
|
40
|
+
*/
|
|
41
|
+
toggleWrapper?: 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
export const ExpandableSectionToggle: React.FunctionComponent<ExpandableSectionToggleProps> = ({
|
|
@@ -48,45 +53,50 @@ export const ExpandableSectionToggle: React.FunctionComponent<ExpandableSectionT
|
|
|
48
53
|
isDetached,
|
|
49
54
|
toggleAriaLabel,
|
|
50
55
|
toggleAriaLabelledBy,
|
|
56
|
+
toggleWrapper = 'div',
|
|
51
57
|
...props
|
|
52
|
-
}: ExpandableSectionToggleProps) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
58
|
+
}: ExpandableSectionToggleProps) => {
|
|
59
|
+
const ToggleWrapper = toggleWrapper as any;
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
className={css(
|
|
64
|
+
styles.expandableSection,
|
|
65
|
+
isExpanded && styles.modifiers.expanded,
|
|
66
|
+
hasTruncatedContent && styles.modifiers.truncate,
|
|
67
|
+
isDetached && 'pf-m-detached',
|
|
68
|
+
className
|
|
69
|
+
)}
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
<ToggleWrapper className={`${styles.expandableSection}__toggle`}>
|
|
73
|
+
<Button
|
|
74
|
+
variant="link"
|
|
75
|
+
{...(hasTruncatedContent && { isInline: true })}
|
|
76
|
+
aria-expanded={isExpanded}
|
|
77
|
+
aria-controls={contentId}
|
|
78
|
+
onClick={() => onToggle(!isExpanded)}
|
|
79
|
+
id={toggleId}
|
|
80
|
+
{...(!hasTruncatedContent && {
|
|
81
|
+
icon: (
|
|
82
|
+
<span
|
|
83
|
+
className={css(
|
|
84
|
+
styles.expandableSectionToggleIcon,
|
|
85
|
+
isExpanded && direction === 'up' && styles.modifiers.expandTop // TODO: next breaking change move this class to the outer styles.expandableSection wrapper
|
|
86
|
+
)}
|
|
87
|
+
>
|
|
88
|
+
<AngleRightIcon />
|
|
89
|
+
</span>
|
|
90
|
+
)
|
|
91
|
+
})}
|
|
92
|
+
aria-label={toggleAriaLabel}
|
|
93
|
+
aria-labelledby={toggleAriaLabelledBy}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</Button>
|
|
97
|
+
</ToggleWrapper>
|
|
88
98
|
</div>
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
);
|
|
100
|
+
};
|
|
91
101
|
|
|
92
102
|
ExpandableSectionToggle.displayName = 'ExpandableSectionToggle';
|
|
@@ -208,3 +208,66 @@ test('Renders with aria-labelledby when toggleAriaLabelledBy is passed', () => {
|
|
|
208
208
|
|
|
209
209
|
expect(screen.getByRole('button')).toHaveAccessibleName('Test label');
|
|
210
210
|
});
|
|
211
|
+
|
|
212
|
+
test('Renders toggleContent as a function in uncontrolled mode (collapsed)', () => {
|
|
213
|
+
render(
|
|
214
|
+
<ExpandableSection toggleContent={(isExpanded) => (isExpanded ? 'Hide details' : 'Show details')}>
|
|
215
|
+
Test content
|
|
216
|
+
</ExpandableSection>
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
expect(screen.getByRole('button', { name: 'Show details' })).toBeInTheDocument();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test('Renders toggleContent as a function in uncontrolled mode (expanded after click)', async () => {
|
|
223
|
+
const user = userEvent.setup();
|
|
224
|
+
|
|
225
|
+
render(
|
|
226
|
+
<ExpandableSection toggleContent={(isExpanded) => (isExpanded ? 'Hide details' : 'Show details')}>
|
|
227
|
+
Test content
|
|
228
|
+
</ExpandableSection>
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const button = screen.getByRole('button', { name: 'Show details' });
|
|
232
|
+
await user.click(button);
|
|
233
|
+
|
|
234
|
+
expect(screen.getByRole('button', { name: 'Hide details' })).toBeInTheDocument();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test('Renders toggleContent as a function in controlled mode', () => {
|
|
238
|
+
render(
|
|
239
|
+
<ExpandableSection isExpanded={true} toggleContent={(isExpanded) => (isExpanded ? 'Collapse' : 'Expand')}>
|
|
240
|
+
Test content
|
|
241
|
+
</ExpandableSection>
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
expect(screen.getByRole('button', { name: 'Collapse' })).toBeInTheDocument();
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test('Renders with default div wrapper when toggleWrapper is not specified', () => {
|
|
248
|
+
render(<ExpandableSection data-testid="test-id">Test content</ExpandableSection>);
|
|
249
|
+
|
|
250
|
+
const toggle = screen.getByRole('button').parentElement;
|
|
251
|
+
expect(toggle?.tagName).toBe('DIV');
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test('Renders with h2 wrapper when toggleWrapper="h2"', () => {
|
|
255
|
+
render(
|
|
256
|
+
<ExpandableSection data-testid="test-id" toggleWrapper="h2">
|
|
257
|
+
Test content
|
|
258
|
+
</ExpandableSection>
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
expect(screen.getByRole('heading', { level: 2 })).toBeInTheDocument();
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
test('Renders with div wrapper when toggleWrapper="div"', () => {
|
|
265
|
+
render(
|
|
266
|
+
<ExpandableSection data-testid="test-id" toggleWrapper="div">
|
|
267
|
+
Test content
|
|
268
|
+
</ExpandableSection>
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const toggle = screen.getByRole('button').parentElement;
|
|
272
|
+
expect(toggle?.tagName).toBe('DIV');
|
|
273
|
+
});
|
|
@@ -47,3 +47,31 @@ test('Renders with aria-labelledby when toggleAriaLabelledBy is passed', () => {
|
|
|
47
47
|
|
|
48
48
|
expect(screen.getByRole('button')).toHaveAccessibleName('Test label');
|
|
49
49
|
});
|
|
50
|
+
|
|
51
|
+
test('Renders with default div wrapper when toggleWrapper is not specified', () => {
|
|
52
|
+
render(<ExpandableSectionToggle data-testid="test-id">Toggle test</ExpandableSectionToggle>);
|
|
53
|
+
|
|
54
|
+
const toggle = screen.getByRole('button').parentElement;
|
|
55
|
+
expect(toggle?.tagName).toBe('DIV');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('Renders with h2 wrapper when toggleWrapper="h2"', () => {
|
|
59
|
+
render(
|
|
60
|
+
<ExpandableSectionToggle data-testid="test-id" toggleWrapper="h2">
|
|
61
|
+
Toggle test
|
|
62
|
+
</ExpandableSectionToggle>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(screen.getByRole('heading', { level: 2 })).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('Renders with div wrapper when toggleWrapper="div"', () => {
|
|
69
|
+
render(
|
|
70
|
+
<ExpandableSectionToggle data-testid="test-id" toggleWrapper="div">
|
|
71
|
+
Toggle test
|
|
72
|
+
</ExpandableSectionToggle>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const toggle = screen.getByRole('button').parentElement;
|
|
76
|
+
expect(toggle?.tagName).toBe('DIV');
|
|
77
|
+
});
|
|
@@ -28,6 +28,14 @@ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle
|
|
|
28
28
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
### Uncontrolled with dynamic toggle content (function)
|
|
32
|
+
|
|
33
|
+
Use `toggleContent` as a function to dynamically render different content based on the expanded state without managing state yourself.
|
|
34
|
+
|
|
35
|
+
```ts file="ExpandableSectionUncontrolledDynamicToggleFunction.tsx"
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
|
|
31
39
|
### Detached
|
|
32
40
|
|
|
33
41
|
When passing the `isDetached` property into `<ExpandableSection>`, you must also manually pass in the same `toggleId` and `contentId` properties to both `<ExpandableSection>` and `<ExpandableSectionToggle>`. This will link the content to the toggle via ARIA attributes.
|
|
@@ -62,6 +70,14 @@ By using the `toggleContent` prop, you can pass in content other than a simple s
|
|
|
62
70
|
|
|
63
71
|
```
|
|
64
72
|
|
|
73
|
+
### With heading semantics
|
|
74
|
+
|
|
75
|
+
When the toggle text should function as a heading in the document structure, use the `toggleWrapper` prop to specify a heading element (h1-h6). This ensures proper semantic structure for screen readers and other assistive technologies. The component automatically uses a native button element when heading wrappers are used, allowing the heading styles to display properly.
|
|
76
|
+
|
|
77
|
+
```ts file="ExpandableSectionWithHeading.tsx"
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
|
|
65
81
|
### Truncate expansion
|
|
66
82
|
|
|
67
83
|
By passing in `variant="truncate"`, the expandable content will be visible up to a maximum number of lines before being truncated, with the toggle revealing or hiding the truncated content. By default the expandable content will truncate after 3 lines, and this can be customized by also passing in the `truncateMaxLines` prop.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { ExpandableSection, Badge } from '@patternfly/react-core';
|
|
2
|
+
import { ExpandableSection, Badge, Stack, StackItem } from '@patternfly/react-core';
|
|
3
3
|
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
4
4
|
|
|
5
5
|
export const ExpandableSectionCustomToggle: React.FunctionComponent = () => {
|
|
@@ -10,20 +10,35 @@ export const ExpandableSectionCustomToggle: React.FunctionComponent = () => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
<Stack hasGutter>
|
|
14
|
+
<StackItem>
|
|
15
|
+
<h3>Custom Toggle Content</h3>
|
|
16
|
+
<p>You can use custom content such as icons and badges in the toggle:</p>
|
|
17
|
+
<ExpandableSection
|
|
18
|
+
toggleContent={
|
|
19
|
+
<div>
|
|
20
|
+
<span>You can also use icons </span>
|
|
21
|
+
<CheckCircleIcon />
|
|
22
|
+
<span> or badges </span>
|
|
23
|
+
<Badge isRead={true}>4</Badge>
|
|
24
|
+
<span> !</span>
|
|
25
|
+
</div>
|
|
26
|
+
}
|
|
27
|
+
onToggle={onToggle}
|
|
28
|
+
isExpanded={isExpanded}
|
|
29
|
+
>
|
|
30
|
+
This content is visible only when the component is expanded.
|
|
31
|
+
</ExpandableSection>
|
|
32
|
+
</StackItem>
|
|
33
|
+
|
|
34
|
+
<StackItem>
|
|
35
|
+
<h3>Accessibility Note</h3>
|
|
36
|
+
<p>
|
|
37
|
+
<strong>Important:</strong> If you need the toggle text to function as a heading in the document structure, do
|
|
38
|
+
NOT put heading elements (h1-h6) inside the <code>toggleContent</code> prop, as this creates invalid HTML
|
|
39
|
+
structure. Instead, use the <code>toggleWrapper</code> prop.
|
|
40
|
+
</p>
|
|
41
|
+
</StackItem>
|
|
42
|
+
</Stack>
|
|
28
43
|
);
|
|
29
44
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExpandableSection } from '@patternfly/react-core';
|
|
2
|
+
|
|
3
|
+
export const ExpandableSectionUncontrolledDynamicToggleFunction: React.FunctionComponent = () => (
|
|
4
|
+
<ExpandableSection
|
|
5
|
+
toggleContent={(isExpanded) =>
|
|
6
|
+
isExpanded
|
|
7
|
+
? 'Show less uncontrolled dynamic toggle example content'
|
|
8
|
+
: 'Show more uncontrolled dynamic toggle example content'
|
|
9
|
+
}
|
|
10
|
+
>
|
|
11
|
+
This content is visible only when the component is expanded.
|
|
12
|
+
</ExpandableSection>
|
|
13
|
+
);
|