@patternfly/react-core 6.2.1-prerelease.9 → 6.2.2
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 +11 -13
- 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/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/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/Divider/Divider.d.ts +0 -2
- package/dist/esm/components/Divider/Divider.d.ts.map +1 -1
- package/dist/esm/components/Divider/Divider.js +2 -2
- package/dist/esm/components/Divider/Divider.js.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.d.ts +1 -1
- package/dist/esm/components/ExpandableSection/ExpandableSectionToggle.d.ts.map +1 -1
- package/dist/esm/components/Form/FormFieldGroup.d.ts +1 -1
- package/dist/esm/components/Form/FormFieldGroup.d.ts.map +1 -1
- package/dist/esm/components/Form/FormFieldGroupExpandable.d.ts +1 -1
- package/dist/esm/components/Form/FormFieldGroupExpandable.d.ts.map +1 -1
- package/dist/esm/components/Form/InternalFormFieldGroup.d.ts +1 -1
- package/dist/esm/components/Form/InternalFormFieldGroup.d.ts.map +1 -1
- package/dist/esm/components/List/List.d.ts.map +1 -1
- package/dist/esm/components/List/List.js +2 -2
- package/dist/esm/components/List/List.js.map +1 -1
- package/dist/esm/components/List/ListItem.d.ts +2 -4
- package/dist/esm/components/List/ListItem.d.ts.map +1 -1
- package/dist/esm/components/List/ListItem.js +2 -2
- package/dist/esm/components/List/ListItem.js.map +1 -1
- package/dist/esm/components/Nav/Nav.d.ts +1 -1
- package/dist/esm/components/Nav/Nav.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavItemSeparator.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavItemSeparator.js +2 -2
- package/dist/esm/components/Nav/NavItemSeparator.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.d.ts +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.js +3 -4
- package/dist/esm/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/esm/components/Truncate/Truncate.d.ts +1 -11
- package/dist/esm/components/Truncate/Truncate.d.ts.map +1 -1
- package/dist/esm/components/Truncate/Truncate.js +6 -43
- package/dist/esm/components/Truncate/Truncate.js.map +1 -1
- package/dist/esm/components/Wizard/WizardNavInternal.js.map +1 -1
- package/dist/js/components/Divider/Divider.d.ts +0 -2
- package/dist/js/components/Divider/Divider.d.ts.map +1 -1
- package/dist/js/components/Divider/Divider.js +2 -2
- package/dist/js/components/Divider/Divider.js.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSection.d.ts +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.d.ts +1 -1
- package/dist/js/components/ExpandableSection/ExpandableSectionToggle.d.ts.map +1 -1
- package/dist/js/components/Form/FormFieldGroup.d.ts +1 -1
- package/dist/js/components/Form/FormFieldGroup.d.ts.map +1 -1
- package/dist/js/components/Form/FormFieldGroupExpandable.d.ts +1 -1
- package/dist/js/components/Form/FormFieldGroupExpandable.d.ts.map +1 -1
- package/dist/js/components/Form/InternalFormFieldGroup.d.ts +1 -1
- package/dist/js/components/Form/InternalFormFieldGroup.d.ts.map +1 -1
- package/dist/js/components/List/List.d.ts.map +1 -1
- package/dist/js/components/List/List.js +2 -2
- package/dist/js/components/List/List.js.map +1 -1
- package/dist/js/components/List/ListItem.d.ts +2 -4
- package/dist/js/components/List/ListItem.d.ts.map +1 -1
- package/dist/js/components/List/ListItem.js +2 -2
- package/dist/js/components/List/ListItem.js.map +1 -1
- package/dist/js/components/Nav/Nav.d.ts +1 -1
- package/dist/js/components/Nav/Nav.d.ts.map +1 -1
- package/dist/js/components/Nav/NavItemSeparator.d.ts.map +1 -1
- package/dist/js/components/Nav/NavItemSeparator.js +2 -2
- package/dist/js/components/Nav/NavItemSeparator.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.d.ts +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.js +3 -4
- package/dist/js/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/js/components/Truncate/Truncate.d.ts +1 -11
- package/dist/js/components/Truncate/Truncate.d.ts.map +1 -1
- package/dist/js/components/Truncate/Truncate.js +5 -42
- package/dist/js/components/Truncate/Truncate.js.map +1 -1
- package/dist/js/components/Wizard/WizardNavInternal.js.map +1 -1
- package/dist/umd/assets/{output-Dz39wdRo.css → output-AyA9e2xy.css} +14502 -14589
- 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 +8 -8
- package/src/components/Alert/examples/Alert.md +3 -0
- package/src/components/DescriptionList/examples/DescriptionListAutoFitBasic.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListAutoFitMinWidthModified.tsx +1 -5
- package/src/components/DescriptionList/examples/DescriptionListAutoFitMinWidthResponsive.tsx +1 -5
- package/src/components/DescriptionList/examples/DescriptionListBasic.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListColumnFill.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListCompact.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListCompactHorizontal.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListDefaultAutoColumn.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListDefaultInlineGrid.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListDefaultResponsiveColumns.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListDefaultThreeColLg.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListDefaultTwoCol.tsx +0 -1
- package/src/components/DescriptionList/examples/DescriptionListDisplaySizeAndCardHorizontalTermWidth.tsx +1 -7
- package/src/components/DescriptionList/examples/DescriptionListDisplaySizeAndCardThreeColumn.tsx +1 -5
- package/src/components/DescriptionList/examples/DescriptionListFluidHorizontal.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListHorizontal.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListHorizontalAutoColumn.tsx +1 -6
- package/src/components/DescriptionList/examples/DescriptionListHorizontalCustomTermWidth.tsx +0 -1
- package/src/components/DescriptionList/examples/DescriptionListHorizontalResponsiveColumns.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListHorizontalThreeColLg.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListHorizontalTwoCol.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListIconsOnTerms.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListResponsiveHoriVertGroup.tsx +0 -1
- package/src/components/DescriptionList/examples/DescriptionListWithCard.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySize.tsx +1 -1
- package/src/components/DescriptionList/examples/DescriptionListWithLargeDisplaySizeAndCard.tsx +1 -5
- package/src/components/DescriptionList/examples/DescriptionListWithTermHelpText.tsx +1 -1
- package/src/components/Divider/Divider.tsx +1 -4
- package/src/components/Divider/__tests__/Divider.test.tsx +0 -10
- package/src/components/DualListSelector/examples/DualListSelectorBasicSearch.tsx +0 -1
- package/src/components/DualListSelector/examples/DualListSelectorComplexOptionsActions.tsx +0 -1
- package/src/components/DualListSelector/examples/DualListSelectorTree.tsx +0 -1
- package/src/components/ExpandableSection/ExpandableSection.tsx +1 -1
- package/src/components/ExpandableSection/ExpandableSectionToggle.tsx +1 -1
- package/src/components/Form/FormFieldGroup.tsx +1 -1
- package/src/components/Form/FormFieldGroupExpandable.tsx +1 -1
- package/src/components/Form/InternalFormFieldGroup.tsx +1 -1
- package/src/components/List/List.tsx +0 -3
- package/src/components/List/ListItem.tsx +4 -7
- package/src/components/List/__tests__/Generated/ListItem.test.tsx +12 -0
- package/src/components/List/__tests__/Generated/__snapshots__/ListItem.test.tsx.snap +13 -0
- package/src/components/List/__tests__/List.test.tsx +101 -97
- package/src/components/List/__tests__/__snapshots__/List.test.tsx.snap +261 -4
- package/src/components/Nav/Nav.tsx +1 -1
- package/src/components/Nav/NavItemSeparator.tsx +1 -2
- package/src/components/Progress/examples/ProgressTitleOutsideOfProgressBar.tsx +1 -1
- package/src/components/SearchInput/examples/SearchInputAdvanced.tsx +0 -1
- package/src/components/SearchInput/examples/SearchInputBasic.tsx +0 -1
- package/src/components/SearchInput/examples/SearchInputFocusSearch.tsx +1 -7
- package/src/components/SearchInput/examples/SearchInputWithExpandable.tsx +0 -1
- package/src/components/SearchInput/examples/SearchInputWithNavigableOptions.tsx +0 -1
- package/src/components/SearchInput/examples/SearchInputWithResultCount.tsx +0 -1
- package/src/components/SearchInput/examples/SearchInputWithSubmitButton.tsx +0 -1
- package/src/components/Tabs/Tabs.tsx +1 -3
- package/src/components/Toolbar/ToolbarGroup.tsx +1 -1
- package/src/components/Toolbar/ToolbarItem.tsx +1 -11
- package/src/components/Truncate/Truncate.tsx +22 -109
- package/src/components/Truncate/__tests__/Truncate.test.tsx +2 -70
- package/src/components/Truncate/__tests__/__snapshots__/Truncate.test.tsx.snap +0 -37
- package/src/components/Truncate/examples/Truncate.md +36 -32
- package/src/components/Wizard/WizardNavInternal.tsx +1 -1
- package/src/components/Wizard/examples/WizardGetCurrentStep.tsx +1 -1
- package/src/demos/DescriptionList/examples/DescriptionListBasic.tsx +1 -1
- package/src/demos/DescriptionList/examples/DescriptionListInDrawer.tsx +1 -1
- package/src/demos/SearchInput/SearchInput.md +0 -2
- package/src/demos/examples/Card/CardDetails.tsx +2 -2
- package/src/demos/examples/Card/CardEventsView.tsx +1 -1
- package/src/demos/examples/Card/CardLogView.tsx +1 -1
- package/src/demos/examples/Card/CardStatusTabbed.tsx +3 -3
- package/src/components/List/__tests__/ListItem.test.tsx +0 -51
- package/src/components/List/__tests__/__snapshots__/ListItem.test.tsx.snap +0 -34
- package/src/components/Truncate/examples/TruncateCustomTooltipPosition.tsx +0 -10
- package/src/components/Truncate/examples/TruncateDefault.tsx +0 -7
- package/src/components/Truncate/examples/TruncateMaxChars.tsx +0 -27
- package/src/components/Truncate/examples/TruncateMiddle.tsx +0 -11
- package/src/components/Truncate/examples/TruncateStart.tsx +0 -7
|
@@ -22,18 +22,8 @@ export interface TruncateProps extends React.HTMLProps<HTMLSpanElement> {
|
|
|
22
22
|
className?: string;
|
|
23
23
|
/** Text to truncate */
|
|
24
24
|
content: string;
|
|
25
|
-
/** The number of characters displayed in the second half of
|
|
26
|
-
* the maxCharsDisplayed prop.
|
|
27
|
-
*/
|
|
25
|
+
/** The number of characters displayed in the second half of the truncation */
|
|
28
26
|
trailingNumChars?: number;
|
|
29
|
-
/** The maximum number of characters to display before truncating. This will always truncate content
|
|
30
|
-
* when its length exceeds the value passed to this prop, and container width/resizing will not affect truncation.
|
|
31
|
-
*/
|
|
32
|
-
maxCharsDisplayed?: number;
|
|
33
|
-
/** The content to use to signify omission of characters when using the maxCharsDisplayed prop.
|
|
34
|
-
* By default this will render an ellipsis.
|
|
35
|
-
*/
|
|
36
|
-
omissionContent?: string;
|
|
37
27
|
/** Where the text will be truncated */
|
|
38
28
|
position?: 'start' | 'middle' | 'end';
|
|
39
29
|
/** Tooltip position */
|
|
@@ -59,15 +49,13 @@ export interface TruncateProps extends React.HTMLProps<HTMLSpanElement> {
|
|
|
59
49
|
refToGetParent?: React.RefObject<any>;
|
|
60
50
|
}
|
|
61
51
|
|
|
62
|
-
const
|
|
52
|
+
const sliceContent = (str: string, slice: number) => [str.slice(0, str.length - slice), str.slice(-slice)];
|
|
63
53
|
|
|
64
54
|
export const Truncate: React.FunctionComponent<TruncateProps> = ({
|
|
65
55
|
className,
|
|
66
56
|
position = 'end',
|
|
67
57
|
tooltipPosition = 'top',
|
|
68
58
|
trailingNumChars = 7,
|
|
69
|
-
maxCharsDisplayed,
|
|
70
|
-
omissionContent = '\u2026',
|
|
71
59
|
content,
|
|
72
60
|
refToGetParent,
|
|
73
61
|
...props
|
|
@@ -75,17 +63,11 @@ export const Truncate: React.FunctionComponent<TruncateProps> = ({
|
|
|
75
63
|
const [isTruncated, setIsTruncated] = useState(true);
|
|
76
64
|
const [parentElement, setParentElement] = useState<HTMLElement>(null);
|
|
77
65
|
const [textElement, setTextElement] = useState<HTMLElement>(null);
|
|
78
|
-
const [shouldRenderByMaxChars, setShouldRenderByMaxChars] = useState(maxCharsDisplayed > 0);
|
|
79
66
|
|
|
80
67
|
const textRef = useRef<HTMLElement>(null);
|
|
81
68
|
const subParentRef = useRef<HTMLDivElement>(null);
|
|
82
69
|
const observer = useRef(null);
|
|
83
70
|
|
|
84
|
-
if (maxCharsDisplayed <= 0) {
|
|
85
|
-
// eslint-disable-next-line no-console
|
|
86
|
-
console.warn('Truncate: the maxCharsDisplayed must be greater than 0, otherwise no content will be visible.');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
71
|
const getActualWidth = (element: Element) => {
|
|
90
72
|
const computedStyle = getComputedStyle(element);
|
|
91
73
|
|
|
@@ -118,7 +100,7 @@ export const Truncate: React.FunctionComponent<TruncateProps> = ({
|
|
|
118
100
|
}, [textRef, subParentRef, textElement, parentElement]);
|
|
119
101
|
|
|
120
102
|
useEffect(() => {
|
|
121
|
-
if (textElement && parentElement && !observer.current
|
|
103
|
+
if (textElement && parentElement && !observer.current) {
|
|
122
104
|
const totalTextWidth = calculateTotalTextWidth(textElement, trailingNumChars, content);
|
|
123
105
|
const textWidth = position === 'middle' ? totalTextWidth : textElement.scrollWidth;
|
|
124
106
|
|
|
@@ -133,100 +115,31 @@ export const Truncate: React.FunctionComponent<TruncateProps> = ({
|
|
|
133
115
|
observer();
|
|
134
116
|
};
|
|
135
117
|
}
|
|
136
|
-
}, [textElement, parentElement, trailingNumChars, content, position
|
|
118
|
+
}, [textElement, parentElement, trailingNumChars, content, position]);
|
|
137
119
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<>
|
|
152
|
-
<span ref={textRef} className={truncateStyles[position]}>
|
|
153
|
-
{content}
|
|
154
|
-
{position === TruncatePosition.start && <Fragment>‎</Fragment>}
|
|
120
|
+
const truncateBody = (
|
|
121
|
+
<span ref={subParentRef} className={css(styles.truncate, className)} {...props}>
|
|
122
|
+
{(position === TruncatePosition.end || position === TruncatePosition.start) && (
|
|
123
|
+
<span ref={textRef} className={truncateStyles[position]}>
|
|
124
|
+
{content}
|
|
125
|
+
{position === TruncatePosition.start && <Fragment>‎</Fragment>}
|
|
126
|
+
</span>
|
|
127
|
+
)}
|
|
128
|
+
{position === TruncatePosition.middle && content.length - trailingNumChars > minWidthCharacters && (
|
|
129
|
+
<Fragment>
|
|
130
|
+
<span ref={textRef} className={styles.truncateStart}>
|
|
131
|
+
{sliceContent(content, trailingNumChars)[0]}
|
|
155
132
|
</span>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const shouldSliceContent = content.length - trailingNumChars > minWidthCharacters;
|
|
161
|
-
return (
|
|
162
|
-
<>
|
|
133
|
+
<span className={styles.truncateEnd}>{sliceContent(content, trailingNumChars)[1]}</span>
|
|
134
|
+
</Fragment>
|
|
135
|
+
)}
|
|
136
|
+
{position === TruncatePosition.middle && content.length - trailingNumChars <= minWidthCharacters && (
|
|
163
137
|
<Fragment>
|
|
164
138
|
<span ref={textRef} className={styles.truncateStart}>
|
|
165
|
-
{
|
|
139
|
+
{content}
|
|
166
140
|
</span>
|
|
167
|
-
{shouldSliceContent && (
|
|
168
|
-
<span className={styles.truncateEnd}>{sliceTrailingContent(content, trailingNumChars)[1]}</span>
|
|
169
|
-
)}
|
|
170
141
|
</Fragment>
|
|
171
|
-
|
|
172
|
-
);
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const renderMaxDisplayContent = () => {
|
|
176
|
-
const renderVisibleContent = (contentToRender: string) => (
|
|
177
|
-
<span className={`${styles.truncate}__text`}>{contentToRender}</span>
|
|
178
|
-
);
|
|
179
|
-
if (!isTruncated) {
|
|
180
|
-
return renderVisibleContent(content);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const omissionElement = (
|
|
184
|
-
<span className={`${styles.truncate}__omission`} aria-hidden="true">
|
|
185
|
-
{omissionContent}
|
|
186
|
-
</span>
|
|
187
|
-
);
|
|
188
|
-
const renderVisuallyHiddenContent = (contentToHide: string) => (
|
|
189
|
-
<span className="pf-v6-screen-reader">{contentToHide}</span>
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
if (position === TruncatePosition.start) {
|
|
193
|
-
return (
|
|
194
|
-
<>
|
|
195
|
-
{renderVisuallyHiddenContent(content.slice(0, maxCharsDisplayed * -1))}
|
|
196
|
-
{omissionElement}
|
|
197
|
-
{renderVisibleContent(content.slice(maxCharsDisplayed * -1))}
|
|
198
|
-
</>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
if (position === TruncatePosition.end) {
|
|
202
|
-
return (
|
|
203
|
-
<>
|
|
204
|
-
{renderVisibleContent(content.slice(0, maxCharsDisplayed))}
|
|
205
|
-
{omissionElement}
|
|
206
|
-
{renderVisuallyHiddenContent(content.slice(maxCharsDisplayed))}
|
|
207
|
-
</>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const trueMiddleStart = Math.floor(maxCharsDisplayed / 2);
|
|
212
|
-
const trueMiddleEnd = Math.ceil(maxCharsDisplayed / 2) * -1;
|
|
213
|
-
return (
|
|
214
|
-
<>
|
|
215
|
-
{renderVisibleContent(content.slice(0, trueMiddleStart))}
|
|
216
|
-
{omissionElement}
|
|
217
|
-
{renderVisuallyHiddenContent(content.slice(trueMiddleStart, trueMiddleEnd))}
|
|
218
|
-
{renderVisibleContent(content.slice(trueMiddleEnd))}
|
|
219
|
-
</>
|
|
220
|
-
);
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const truncateBody = (
|
|
224
|
-
<span
|
|
225
|
-
ref={subParentRef}
|
|
226
|
-
className={css(styles.truncate, shouldRenderByMaxChars && styles.modifiers.fixed, className)}
|
|
227
|
-
{...props}
|
|
228
|
-
>
|
|
229
|
-
{!shouldRenderByMaxChars ? renderResizeObserverContent() : renderMaxDisplayContent()}
|
|
142
|
+
)}
|
|
230
143
|
</span>
|
|
231
144
|
);
|
|
232
145
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { render, screen
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import { Truncate } from '../Truncate';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Truncate/truncate';
|
|
4
4
|
import '@testing-library/jest-dom';
|
|
@@ -24,7 +24,7 @@ test(`renders with class ${styles.truncate}`, () => {
|
|
|
24
24
|
|
|
25
25
|
const test = screen.getByLabelText('test-id');
|
|
26
26
|
|
|
27
|
-
expect(test).toHaveClass(styles.truncate
|
|
27
|
+
expect(test).toHaveClass(styles.truncate);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
test('renders with custom class name passed via prop', () => {
|
|
@@ -148,71 +148,3 @@ test('renders with inherited element props spread to the component', () => {
|
|
|
148
148
|
|
|
149
149
|
expect(screen.getByTestId('test-id')).toHaveAccessibleName('labelling-id');
|
|
150
150
|
});
|
|
151
|
-
|
|
152
|
-
describe('Truncation with maxCharsDisplayed', () => {
|
|
153
|
-
test(`Does not render with class ${styles.modifiers.fixed} when maxCharsDisplayed is 0`, () => {
|
|
154
|
-
render(<Truncate maxCharsDisplayed={0} data-testid="truncate-component" content="Test content" />);
|
|
155
|
-
|
|
156
|
-
expect(screen.getByTestId('truncate-component')).not.toHaveClass(styles.modifiers.fixed);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test(`Renders with class ${styles.modifiers.fixed} when maxCharsDisplayed is greater than 0`, () => {
|
|
160
|
-
render(<Truncate maxCharsDisplayed={1} data-testid="truncate-component" content="Test content" />);
|
|
161
|
-
|
|
162
|
-
expect(screen.getByTestId('truncate-component')).toHaveClass(styles.modifiers.fixed);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
test('Renders with hidden truncated content at end by default when maxCharsDisplayed is passed', () => {
|
|
166
|
-
render(<Truncate content="Default end position content truncated" maxCharsDisplayed={6} />);
|
|
167
|
-
|
|
168
|
-
expect(screen.getByText('Defaul')).toHaveClass(`${styles.truncate}__text`, { exact: true });
|
|
169
|
-
expect(screen.getByText('t end position content truncated')).toHaveClass('pf-v6-screen-reader');
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
test('Renders with hidden truncated content at middle position when maxCharsDisplayed is passed and position="middle"', () => {
|
|
173
|
-
render(<Truncate position="middle" content="Middle position contents being truncated" maxCharsDisplayed={10} />);
|
|
174
|
-
|
|
175
|
-
expect(screen.getByText('Middl')).toHaveClass(`${styles.truncate}__text`, { exact: true });
|
|
176
|
-
expect(screen.getByText('e position contents being trun')).toHaveClass('pf-v6-screen-reader');
|
|
177
|
-
expect(screen.getByText('cated')).toHaveClass(`${styles.truncate}__text`, { exact: true });
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
test('Renders with hidden truncated content at start when maxCharsDisplayed is passed and position="start"', () => {
|
|
181
|
-
render(<Truncate position="start" content="Start position content truncated" maxCharsDisplayed={6} />);
|
|
182
|
-
|
|
183
|
-
expect(screen.getByText('Start position content tru')).toHaveClass('pf-v6-screen-reader');
|
|
184
|
-
expect(screen.getByText('ncated')).toHaveClass(`${styles.truncate}__text`, { exact: true });
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
test('Renders full content when maxCharsDisplayed exceeds the length of the content', () => {
|
|
188
|
-
render(<Truncate content="This full content is rendered" maxCharsDisplayed={90} />);
|
|
189
|
-
|
|
190
|
-
expect(screen.getByText('This full content is rendered')).toHaveClass(`${styles.truncate}__text`, { exact: true });
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
test('Renders ellipsis as omission content by default', () => {
|
|
194
|
-
render(<Truncate content="Test truncation content" maxCharsDisplayed={5} />);
|
|
195
|
-
|
|
196
|
-
expect(screen.getByText('\u2026')).toHaveClass(`${styles.truncate}__omission`, { exact: true });
|
|
197
|
-
expect(screen.getByText('\u2026')).toHaveAttribute('aria-hidden', 'true');
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test('Renders custom omission content when omissionContent is passed', () => {
|
|
201
|
-
render(<Truncate omissionContent="---" content="Test truncation content" maxCharsDisplayed={5} />);
|
|
202
|
-
|
|
203
|
-
expect(screen.getByText('---')).toHaveClass(`${styles.truncate}__omission`, { exact: true });
|
|
204
|
-
expect(screen.getByText('---')).toHaveAttribute('aria-hidden', 'true');
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
test('Does not render omission content when maxCharsDisplayed exceeds the length of the content ', () => {
|
|
208
|
-
render(<Truncate content="Test truncation content" maxCharsDisplayed={99} />);
|
|
209
|
-
|
|
210
|
-
expect(screen.queryByText('\u2026')).not.toBeInTheDocument();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
test('Matches snapshot with default position', () => {
|
|
214
|
-
const { asFragment } = render(<Truncate content="Test truncation content" maxCharsDisplayed={3} />);
|
|
215
|
-
|
|
216
|
-
expect(asFragment()).toMatchSnapshot();
|
|
217
|
-
});
|
|
218
|
-
});
|
|
@@ -1,42 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Truncation with maxCharsDisplayed Matches snapshot with default position 1`] = `
|
|
4
|
-
<DocumentFragment>
|
|
5
|
-
<div
|
|
6
|
-
data-testid="Tooltip-mock"
|
|
7
|
-
>
|
|
8
|
-
<div
|
|
9
|
-
data-testid="Tooltip-mock-content-container"
|
|
10
|
-
>
|
|
11
|
-
Test Test truncation content
|
|
12
|
-
</div>
|
|
13
|
-
<p>
|
|
14
|
-
position: top
|
|
15
|
-
</p>
|
|
16
|
-
<span
|
|
17
|
-
class="pf-v6-c-truncate pf-m-fixed"
|
|
18
|
-
>
|
|
19
|
-
<span
|
|
20
|
-
class="pf-v6-c-truncate__text"
|
|
21
|
-
>
|
|
22
|
-
Tes
|
|
23
|
-
</span>
|
|
24
|
-
<span
|
|
25
|
-
aria-hidden="true"
|
|
26
|
-
class="pf-v6-c-truncate__omission"
|
|
27
|
-
>
|
|
28
|
-
…
|
|
29
|
-
</span>
|
|
30
|
-
<span
|
|
31
|
-
class="pf-v6-screen-reader"
|
|
32
|
-
>
|
|
33
|
-
t truncation content
|
|
34
|
-
</span>
|
|
35
|
-
</span>
|
|
36
|
-
</div>
|
|
37
|
-
</DocumentFragment>
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
3
|
exports[`renders default truncation 1`] = `
|
|
41
4
|
<DocumentFragment>
|
|
42
5
|
<div
|
|
@@ -9,46 +9,50 @@ import './TruncateExamples.css';
|
|
|
9
9
|
|
|
10
10
|
## Examples
|
|
11
11
|
|
|
12
|
-
The default behavior of the `Truncate` component is to truncate based on whether the content can fit within the width of its parent container, and to prevent text from wrapping. The following examples that use this default behavior render the `<Truncate>` component inside a resizable container, allowing you to see how the parent container width affects the truncation.
|
|
13
|
-
|
|
14
12
|
### Default
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
```js
|
|
14
|
+
import { Truncate } from '@patternfly/react-core';
|
|
15
|
+
|
|
16
|
+
<div className="truncate-example-resize">
|
|
17
|
+
<Truncate
|
|
18
|
+
content={'Vestibulum interdum risus et enim faucibus, sit amet molestie est accumsan.'}
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
### Middle
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
```js
|
|
25
|
+
import { Truncate } from '@patternfly/react-core';
|
|
26
|
+
|
|
27
|
+
<div className="truncate-example-resize">
|
|
28
|
+
<Truncate
|
|
29
|
+
content={'redhat_logo_black_and_white_reversed_simple_with_fedora_container.zip'}
|
|
30
|
+
trailingNumChars={10}
|
|
31
|
+
position={'middle'}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
28
34
|
```
|
|
29
35
|
|
|
30
36
|
### Start
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
```js
|
|
38
|
+
import { Truncate } from '@patternfly/react-core';
|
|
39
|
+
|
|
40
|
+
<div className="truncate-example-resize">
|
|
41
|
+
<Truncate
|
|
42
|
+
content={'Vestibulum interdum risus et enim faucibus, sit amet molestie est accumsan.'}
|
|
43
|
+
position={'start'}
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
36
46
|
```
|
|
37
47
|
|
|
38
|
-
###
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```ts file="./TruncateCustomTooltipPosition.tsx"
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Based on max characters
|
|
47
|
-
|
|
48
|
-
Rather than observing container width, you can have truncation be based on a maximum amount of characters that should always be displayed via the `maxCharsDisplayed` property. While the content's parent container width will not have an affect on whether truncation occurs, it will affect whether the content wraps. This property must be set to a value larger than `0`, otherwise the component will fall back to observing container width.
|
|
49
|
-
|
|
50
|
-
Truncating based on a maximum amount of characters will truncate the content at the end by default. When the `position` property is set to "middle", the truncation will split the content as evenly as possible, providing a more "true middle" truncation.
|
|
51
|
-
|
|
52
|
-
```ts file="./TruncateMaxChars.tsx"
|
|
48
|
+
### Default with tooltip at the bottom
|
|
49
|
+
```js
|
|
50
|
+
import { Truncate } from '@patternfly/react-core';
|
|
53
51
|
|
|
52
|
+
<div className="truncate-example-resize">
|
|
53
|
+
<Truncate
|
|
54
|
+
content={'Vestibulum interdum risus et enim faucibus, sit amet molestie est accumsan.'}
|
|
55
|
+
tooltipPosition={'bottom'}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
54
58
|
```
|
|
@@ -96,7 +96,7 @@ export const WizardNavInternal = ({
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
const hasEnabledChildren = Children.toArray(subNavItems).some(
|
|
99
|
-
(child) => isValidElement(child) && !
|
|
99
|
+
(child) => isValidElement(child) && !child.props.isDisabled
|
|
100
100
|
);
|
|
101
101
|
|
|
102
102
|
if (!isProgressive || (isProgressive && step.index <= activeStep.index)) {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@patternfly/react-core';
|
|
11
11
|
|
|
12
12
|
const CurrentStepDescriptionList = ({ currentStep }: { currentStep: WizardStepType | undefined }) => (
|
|
13
|
-
<DescriptionList isHorizontal isCompact
|
|
13
|
+
<DescriptionList isHorizontal isCompact>
|
|
14
14
|
<DescriptionListGroup>
|
|
15
15
|
<DescriptionListTerm>Index</DescriptionListTerm>
|
|
16
16
|
<DescriptionListDescription>{currentStep?.index}</DescriptionListDescription>
|
|
@@ -33,7 +33,7 @@ export const DescriptionListBasic: React.FunctionComponent = () => (
|
|
|
33
33
|
</CardHeader>
|
|
34
34
|
<Divider />
|
|
35
35
|
<CardBody>
|
|
36
|
-
<DescriptionList isAutoFit
|
|
36
|
+
<DescriptionList isAutoFit>
|
|
37
37
|
<DescriptionListGroup>
|
|
38
38
|
<DescriptionListTerm>Name</DescriptionListTerm>
|
|
39
39
|
<DescriptionListDescription>mary-test</DescriptionListDescription>
|
|
@@ -51,7 +51,7 @@ export const DescriptionListInDrawer: React.FunctionComponent = () => {
|
|
|
51
51
|
</DrawerActions>
|
|
52
52
|
</DrawerHead>
|
|
53
53
|
<DrawerPanelBody>
|
|
54
|
-
<DescriptionList isFillColumns columnModifier={{ default: '2Col', lg: '2Col' }}
|
|
54
|
+
<DescriptionList isFillColumns columnModifier={{ default: '2Col', lg: '2Col' }}>
|
|
55
55
|
<DescriptionListGroup>
|
|
56
56
|
<DescriptionListTerm>Name</DescriptionListTerm>
|
|
57
57
|
<DescriptionListDescription>test</DescriptionListDescription>
|
|
@@ -172,7 +172,6 @@ SearchAutocomplete = () => {
|
|
|
172
172
|
ref={searchInputRef}
|
|
173
173
|
hint={hint}
|
|
174
174
|
id="autocomplete-search"
|
|
175
|
-
aria-label='Search with autocomplete'
|
|
176
175
|
/>
|
|
177
176
|
);
|
|
178
177
|
|
|
@@ -402,7 +401,6 @@ AdvancedComposableSearchInput = () => {
|
|
|
402
401
|
onSearch={onSubmit}
|
|
403
402
|
ref={searchInputRef}
|
|
404
403
|
id="custom-advanced-search"
|
|
405
|
-
aria-label='Composable advanced search'
|
|
406
404
|
/>
|
|
407
405
|
);
|
|
408
406
|
|
|
@@ -23,7 +23,7 @@ export const CardDetailsDemo: React.FunctionComponent = () => (
|
|
|
23
23
|
</Title>
|
|
24
24
|
</CardTitle>
|
|
25
25
|
<CardBody>
|
|
26
|
-
<DescriptionList
|
|
26
|
+
<DescriptionList>
|
|
27
27
|
<DescriptionListGroup>
|
|
28
28
|
<DescriptionListTerm>Cluster API Address</DescriptionListTerm>
|
|
29
29
|
<DescriptionListDescription>
|
|
@@ -60,7 +60,7 @@ export const CardDetailsDemo: React.FunctionComponent = () => (
|
|
|
60
60
|
</Title>
|
|
61
61
|
</CardTitle>
|
|
62
62
|
<CardBody>
|
|
63
|
-
<DescriptionList
|
|
63
|
+
<DescriptionList>
|
|
64
64
|
<DescriptionListGroup>
|
|
65
65
|
<DescriptionListTerm>Cluster API Address</DescriptionListTerm>
|
|
66
66
|
<DescriptionListDescription>
|
|
@@ -72,7 +72,7 @@ export const CardEventsView: React.FunctionComponent = () => {
|
|
|
72
72
|
</CardTitle>
|
|
73
73
|
</CardHeader>
|
|
74
74
|
<CardBody>
|
|
75
|
-
<DescriptionList
|
|
75
|
+
<DescriptionList>
|
|
76
76
|
<DescriptionListGroup>
|
|
77
77
|
<DescriptionListTerm>
|
|
78
78
|
<Flex flexWrap={{ default: 'nowrap' }}>
|
|
@@ -71,7 +71,7 @@ export const CardLogView: React.FunctionComponent = () => {
|
|
|
71
71
|
</CardTitle>
|
|
72
72
|
</CardHeader>
|
|
73
73
|
<CardBody>
|
|
74
|
-
<DescriptionList
|
|
74
|
+
<DescriptionList>
|
|
75
75
|
<DescriptionListGroup>
|
|
76
76
|
<DescriptionListTerm>Readiness probe failed</DescriptionListTerm>
|
|
77
77
|
<DescriptionListDescription>
|
|
@@ -68,8 +68,8 @@ export const CardStatusTabbed: React.FunctionComponent = () => {
|
|
|
68
68
|
setActiveTabKey(Number(tabIndex));
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
const tabContent = (
|
|
72
|
-
<DescriptionList isHorizontal columnModifier={{ lg: '2Col' }}
|
|
71
|
+
const tabContent = (
|
|
72
|
+
<DescriptionList isHorizontal columnModifier={{ lg: '2Col' }}>
|
|
73
73
|
{descriptionListData.map(({ status, resourceName, detail, icon }, index) => (
|
|
74
74
|
<DescriptionListGroup key={index}>
|
|
75
75
|
<DescriptionListTerm>
|
|
@@ -120,7 +120,7 @@ export const CardStatusTabbed: React.FunctionComponent = () => {
|
|
|
120
120
|
activeKey={activeTabKey}
|
|
121
121
|
hidden={tabIndex !== activeTabKey}
|
|
122
122
|
>
|
|
123
|
-
{tabContent
|
|
123
|
+
{tabContent}
|
|
124
124
|
</TabContent>
|
|
125
125
|
))}
|
|
126
126
|
</CardBody>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import { ListItem } from '../ListItem';
|
|
3
|
-
import styles from '@patternfly/react-styles/css/components/List/list';
|
|
4
|
-
|
|
5
|
-
test('Renders with children', () => {
|
|
6
|
-
render(<ListItem>List item content</ListItem>);
|
|
7
|
-
|
|
8
|
-
expect(screen.getByRole('listitem')).toHaveTextContent('List item content');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test(`Does not render with a class by default`, () => {
|
|
12
|
-
render(<ListItem>List item content</ListItem>);
|
|
13
|
-
|
|
14
|
-
expect(screen.getByRole('listitem')).not.toHaveClass();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test(`Renders with custom class when className is passed`, () => {
|
|
18
|
-
render(<ListItem className="test-class">List item content</ListItem>);
|
|
19
|
-
|
|
20
|
-
expect(screen.getByRole('listitem')).toHaveClass('test-class', { exact: true });
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test(`Renders with icon content when icon prop is passed`, () => {
|
|
24
|
-
render(<ListItem icon={<div>Icon content</div>}>List item content</ListItem>);
|
|
25
|
-
|
|
26
|
-
expect(screen.getByRole('listitem')).toContainHTML('<div>Icon content</div>');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test(`Renders with class ${styles.listItem} when icon prop is passed`, () => {
|
|
30
|
-
render(<ListItem icon={<div>Icon content</div>}>List item content</ListItem>);
|
|
31
|
-
|
|
32
|
-
expect(screen.getByRole('listitem')).toHaveClass(styles.listItem, { exact: true });
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test(`Spreads additional props when passed`, () => {
|
|
36
|
-
render(<ListItem id="test-ID">List item content</ListItem>);
|
|
37
|
-
|
|
38
|
-
expect(screen.getByRole('listitem')).toHaveAttribute('id', 'test-ID');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('Matches snapshot without icon', () => {
|
|
42
|
-
const { asFragment } = render(<ListItem>List item content</ListItem>);
|
|
43
|
-
|
|
44
|
-
expect(asFragment()).toMatchSnapshot();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('Matches snapshot with icon', () => {
|
|
48
|
-
const { asFragment } = render(<ListItem icon={<div>Icon content</div>}>List item content</ListItem>);
|
|
49
|
-
|
|
50
|
-
expect(asFragment()).toMatchSnapshot();
|
|
51
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Matches snapshot with icon 1`] = `
|
|
4
|
-
<DocumentFragment>
|
|
5
|
-
<li
|
|
6
|
-
class="pf-v6-c-list__item"
|
|
7
|
-
>
|
|
8
|
-
<span
|
|
9
|
-
class="pf-v6-c-list__item-icon"
|
|
10
|
-
>
|
|
11
|
-
<div>
|
|
12
|
-
Icon content
|
|
13
|
-
</div>
|
|
14
|
-
</span>
|
|
15
|
-
<span
|
|
16
|
-
class="pf-v6-c-list__item-text"
|
|
17
|
-
>
|
|
18
|
-
List item content
|
|
19
|
-
</span>
|
|
20
|
-
</li>
|
|
21
|
-
</DocumentFragment>
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
exports[`Matches snapshot without icon 1`] = `
|
|
25
|
-
<DocumentFragment>
|
|
26
|
-
<li
|
|
27
|
-
class=""
|
|
28
|
-
>
|
|
29
|
-
<span>
|
|
30
|
-
List item content
|
|
31
|
-
</span>
|
|
32
|
-
</li>
|
|
33
|
-
</DocumentFragment>
|
|
34
|
-
`;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Truncate } from '@patternfly/react-core';
|
|
2
|
-
|
|
3
|
-
export const TruncateCustomTooltipPosition: React.FunctionComponent = () => (
|
|
4
|
-
<div className="truncate-example-resize">
|
|
5
|
-
<Truncate
|
|
6
|
-
content={'redhat_logo_black_and_white_reversed_simple_with_fedora_container.zip'}
|
|
7
|
-
tooltipPosition={'bottom'}
|
|
8
|
-
/>
|
|
9
|
-
</div>
|
|
10
|
-
);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Truncate } from '@patternfly/react-core';
|
|
2
|
-
|
|
3
|
-
export const TruncateDefault: React.FunctionComponent = () => (
|
|
4
|
-
<div className="truncate-example-resize">
|
|
5
|
-
<Truncate content={'redhat_logo_black_and_white_reversed_simple_with_fedora_container.zip'} />
|
|
6
|
-
</div>
|
|
7
|
-
);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Truncate, TruncatePosition } from '@patternfly/react-core';
|
|
2
|
-
|
|
3
|
-
export const TruncateMaxChars: React.FunctionComponent = () => (
|
|
4
|
-
<>
|
|
5
|
-
<div>Truncated at end position:</div>
|
|
6
|
-
<Truncate
|
|
7
|
-
maxCharsDisplayed={15}
|
|
8
|
-
content={'redhat_logo_black_and_white_reversed_simple_with_fedora_container.zip'}
|
|
9
|
-
/>
|
|
10
|
-
<br />
|
|
11
|
-
<br />
|
|
12
|
-
<div>Truncated at middle position:</div>
|
|
13
|
-
<Truncate
|
|
14
|
-
maxCharsDisplayed={15}
|
|
15
|
-
position={TruncatePosition.middle}
|
|
16
|
-
content={'redhat_logo_black_and_white_reversed_simple_with_fedora_container.zip'}
|
|
17
|
-
/>
|
|
18
|
-
<br />
|
|
19
|
-
<br />
|
|
20
|
-
<div>Truncated at start position:</div>
|
|
21
|
-
<Truncate
|
|
22
|
-
maxCharsDisplayed={15}
|
|
23
|
-
position={TruncatePosition.start}
|
|
24
|
-
content={'redhat_logo_black_and_white_reversed_simple_with_fedora_container.zip'}
|
|
25
|
-
/>
|
|
26
|
-
</>
|
|
27
|
-
);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Truncate } from '@patternfly/react-core';
|
|
2
|
-
|
|
3
|
-
export const TruncateMiddle: React.FunctionComponent = () => (
|
|
4
|
-
<div className="truncate-example-resize">
|
|
5
|
-
<Truncate
|
|
6
|
-
content={'redhat_logo_black_and_white_reversed_simple_with_fedora_container.zip'}
|
|
7
|
-
trailingNumChars={10}
|
|
8
|
-
position={'middle'}
|
|
9
|
-
/>
|
|
10
|
-
</div>
|
|
11
|
-
);
|