@patternfly/react-core 6.0.0-alpha.50 → 6.0.0-alpha.52
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 +334 -0
- package/README.md +1 -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/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/Text/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/Tile/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/ApplicationLauncher/package.json +1 -1
- package/dist/dynamic/deprecated/components/Chip/package.json +1 -1
- package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/DragDrop/package.json +1 -1
- package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
- package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
- package/dist/dynamic/deprecated/components/Select/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/favorites/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/next/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/next/components/Modal/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/dynamic/styles/package.json +1 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.js +30 -12
- package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts +3 -3
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.js +10 -2
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.d.ts +4 -0
- package/dist/esm/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js +6 -5
- package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/Label/Label.d.ts +2 -0
- package/dist/esm/components/Label/Label.d.ts.map +1 -1
- package/dist/esm/components/Label/Label.js +9 -15
- package/dist/esm/components/Label/Label.js.map +1 -1
- package/dist/esm/components/Menu/Menu.d.ts.map +1 -1
- package/dist/esm/components/Menu/Menu.js +5 -1
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/Menu/MenuContainer.js +2 -2
- package/dist/esm/components/Menu/MenuContainer.js.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.d.ts +11 -3
- package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js +29 -3
- package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggleCheckbox.js +2 -2
- package/dist/esm/components/MenuToggle/MenuToggleCheckbox.js.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.js +2 -4
- package/dist/esm/components/Pagination/PaginationOptionsMenu.js.map +1 -1
- package/dist/esm/components/Select/Select.js +2 -2
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/TextArea/TextArea.d.ts +0 -4
- package/dist/esm/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/esm/components/TextArea/TextArea.js.map +1 -1
- package/dist/esm/components/ToggleGroup/ToggleGroupItem.d.ts +2 -0
- package/dist/esm/components/ToggleGroup/ToggleGroupItem.d.ts.map +1 -1
- package/dist/esm/components/ToggleGroup/ToggleGroupItem.js +5 -3
- package/dist/esm/components/ToggleGroup/ToggleGroupItem.js.map +1 -1
- package/dist/esm/helpers/GenerateId/GenerateId.d.ts +5 -1
- package/dist/esm/helpers/GenerateId/GenerateId.d.ts.map +1 -1
- package/dist/esm/helpers/GenerateId/GenerateId.js +14 -2
- package/dist/esm/helpers/GenerateId/GenerateId.js.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.js +30 -12
- package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts +3 -3
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.js +10 -2
- package/dist/js/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.d.ts +4 -0
- package/dist/js/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.js +6 -5
- package/dist/js/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/js/components/Label/Label.d.ts +2 -0
- package/dist/js/components/Label/Label.d.ts.map +1 -1
- package/dist/js/components/Label/Label.js +9 -15
- package/dist/js/components/Label/Label.js.map +1 -1
- package/dist/js/components/Menu/Menu.d.ts.map +1 -1
- package/dist/js/components/Menu/Menu.js +5 -1
- package/dist/js/components/Menu/Menu.js.map +1 -1
- package/dist/js/components/Menu/MenuContainer.js +2 -2
- package/dist/js/components/Menu/MenuContainer.js.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.d.ts +11 -3
- package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js +30 -4
- package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggleCheckbox.js +2 -2
- package/dist/js/components/MenuToggle/MenuToggleCheckbox.js.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.js +2 -4
- package/dist/js/components/Pagination/PaginationOptionsMenu.js.map +1 -1
- package/dist/js/components/Select/Select.js +2 -2
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/TextArea/TextArea.d.ts +0 -4
- package/dist/js/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/js/components/TextArea/TextArea.js.map +1 -1
- package/dist/js/components/ToggleGroup/ToggleGroupItem.d.ts +2 -0
- package/dist/js/components/ToggleGroup/ToggleGroupItem.d.ts.map +1 -1
- package/dist/js/components/ToggleGroup/ToggleGroupItem.js +5 -3
- package/dist/js/components/ToggleGroup/ToggleGroupItem.js.map +1 -1
- package/dist/js/helpers/GenerateId/GenerateId.d.ts +5 -1
- package/dist/js/helpers/GenerateId/GenerateId.d.ts.map +1 -1
- package/dist/js/helpers/GenerateId/GenerateId.js +14 -2
- package/dist/js/helpers/GenerateId/GenerateId.js.map +1 -1
- package/dist/umd/react-core.min.js +2 -2
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +5 -5
- package/src/components/Accordion/__tests__/AccordionToggle.test.tsx +28 -0
- package/src/components/CalendarMonth/CalendarMonth.tsx +38 -13
- package/src/components/ClipboardCopy/ClipboardCopy.tsx +18 -4
- package/src/components/ClipboardCopy/__tests__/ClipboardCopy.test.tsx +2 -0
- package/src/components/ClipboardCopy/__tests__/__snapshots__/ClipboardCopy.test.tsx.snap +1 -1
- package/src/components/DataList/examples/DataList.md +1 -1
- package/src/components/Drawer/__tests__/Drawer.test.tsx +2 -0
- package/src/components/Drawer/__tests__/DrawerPanelContent.test.tsx +2 -0
- package/src/components/Drawer/__tests__/Generated/DrawerPanelContent.test.tsx +2 -0
- package/src/components/Drawer/__tests__/Generated/__snapshots__/DrawerPanelContent.test.tsx.snap +1 -1
- package/src/components/Drawer/__tests__/__snapshots__/Drawer.test.tsx.snap +8 -8
- package/src/components/Dropdown/Dropdown.tsx +14 -4
- package/src/components/DualListSelector/examples/DualListSelector.md +1 -1
- package/src/components/Form/__tests__/FormFieldGroup.test.tsx +2 -0
- package/src/components/Form/__tests__/FormSection.test.tsx +2 -0
- package/src/components/Form/__tests__/__snapshots__/FormFieldGroup.test.tsx.snap +2 -2
- package/src/components/Form/__tests__/__snapshots__/FormSection.test.tsx.snap +2 -2
- package/src/components/Label/Label.tsx +17 -13
- package/src/components/Label/__tests__/LabelGroup.test.tsx +2 -0
- package/src/components/Label/__tests__/__snapshots__/LabelGroup.test.tsx.snap +8 -8
- package/src/components/Label/examples/LabelCompact.tsx +19 -6
- package/src/components/Label/examples/LabelFilled.tsx +107 -17
- package/src/components/Label/examples/LabelOutline.tsx +142 -10
- package/src/components/Menu/Menu.tsx +5 -3
- package/src/components/Menu/MenuContainer.tsx +2 -2
- package/src/components/MenuToggle/MenuToggle.tsx +37 -3
- package/src/components/MenuToggle/MenuToggleCheckbox.tsx +2 -2
- package/src/components/MenuToggle/__tests__/MenuToggle.test.tsx +15 -0
- package/src/components/MenuToggle/examples/MenuToggle.md +23 -3
- package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckboxWithToggleText.tsx +51 -0
- package/src/components/MenuToggle/examples/MenuToggleStatus.tsx +20 -0
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUpload.test.tsx +2 -0
- package/src/components/MultipleFileUpload/__tests__/MultipleFileUploadStatus.test.tsx +2 -0
- package/src/components/MultipleFileUpload/__tests__/__snapshots__/MultipleFileUploadStatus.test.tsx.snap +16 -16
- package/src/components/Pagination/PaginationOptionsMenu.tsx +2 -4
- package/src/components/SearchInput/__tests__/SearchInput.test.tsx +1 -0
- package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +2 -2
- package/src/components/Select/Select.tsx +2 -2
- package/src/components/Select/examples/Select.md +33 -9
- package/src/components/Select/examples/SelectMultiTypeaheadCheckbox.tsx +6 -1
- package/src/components/Select/examples/SelectValidated.tsx +74 -0
- package/src/components/Tabs/__tests__/Tabs.test.tsx +2 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +3 -3
- package/src/components/TextArea/TextArea.tsx +0 -4
- package/src/components/ToggleGroup/ToggleGroupItem.tsx +7 -1
- package/src/components/ToggleGroup/examples/ToggleGroupTextIcon.tsx +52 -23
- package/src/components/Toolbar/__tests__/Toolbar.test.tsx +2 -0
- package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +4 -4
- package/src/demos/AlertGroup.md +1 -0
- package/src/demos/BackToTop.md +1 -0
- package/src/demos/Banner.md +5 -4
- package/src/demos/CardView/CardView.md +2 -0
- package/src/demos/CardView/examples/CardView.tsx +1 -1
- package/src/demos/DataList/examples/DataListBasic.tsx +6 -4
- package/src/demos/DataListDemo.md +1 -0
- package/src/demos/Filters/examples/FilterAttributeSearch.tsx +1 -1
- package/src/demos/Filters/examples/FilterCheckboxSelect.tsx +1 -1
- package/src/demos/Filters/examples/FilterFaceted.tsx +1 -1
- package/src/demos/Filters/examples/FilterMixedSelectGroup.tsx +1 -1
- package/src/demos/Filters/examples/FilterSameSelectGroup.tsx +1 -1
- package/src/demos/Filters/examples/FilterSearchInput.tsx +1 -1
- package/src/demos/Filters/examples/FilterSingleSelect.tsx +1 -1
- package/src/demos/JumpLinks.md +2 -1
- package/src/demos/PrimaryDetail.md +1 -0
- package/src/demos/RTL/RTL.md +1 -1
- package/src/demos/RTL/examples/PaginatedTable.tsx +533 -0
- package/src/demos/Tabs.md +5 -2
- package/src/demos/Toolbar.md +1 -0
- package/src/demos/Wizard/WizardDemo.md +1 -0
- package/src/demos/examples/AlertGroup/AlertGroupToastWithNotificationDrawer.tsx +1 -1
- package/src/demos/examples/BackToTop/BackToTopNameDemo.tsx +1 -1
- package/src/demos/examples/Card/CardStatus.tsx +1 -1
- package/src/demos/examples/JumpLinks/JumpLinksWithDrawer.js +1 -1
- package/src/demos/examples/Nav/NavDefault.tsx +1 -1
- package/src/demos/examples/Nav/NavExpandable.tsx +1 -1
- package/src/demos/examples/Nav/NavWithSubnav.tsx +1 -1
- package/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx +1 -1
- package/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx +1 -1
- package/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx +1 -1
- package/src/demos/examples/Tabs/ModalTabs.tsx +1 -1
- package/src/demos/examples/Tabs/NestedTabs.tsx +1 -1
- package/src/demos/examples/Tabs/NestedUnindentedTabs.tsx +1 -1
- package/src/demos/examples/Tabs/TabsAndTable.tsx +1 -1
- package/src/demos/examples/Toolbar/ConsoleLogViewerToolbar.tsx +1 -1
- package/src/demos/examples/Wizard/InModal.tsx +1 -1
- package/src/deprecated/components/Chip/__tests__/ChipGroup.test.tsx +4 -2
- package/src/deprecated/components/Select/__tests__/Select.test.tsx +2 -0
- package/src/deprecated/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +19 -19
- package/src/helpers/GenerateId/GenerateId.ts +17 -3
- package/src/helpers/GenerateId/__mocks__/GenerateId.ts +11 -0
- package/src/helpers/GenerateId/__tests__/GenerateId.test.tsx +3 -1
|
@@ -53,6 +53,21 @@ describe('menu toggle', () => {
|
|
|
53
53
|
expect(asFragment()).toMatchSnapshot();
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
test('shows success status', () => {
|
|
57
|
+
render(<MenuToggle status="success">Toggle</MenuToggle>);
|
|
58
|
+
expect(screen.getByRole('button')).toHaveClass('pf-m-success');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('shows warning status', () => {
|
|
62
|
+
render(<MenuToggle status="warning">Toggle</MenuToggle>);
|
|
63
|
+
expect(screen.getByRole('button')).toHaveClass('pf-m-warning');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('shows danger status', () => {
|
|
67
|
+
render(<MenuToggle status="danger">Toggle</MenuToggle>);
|
|
68
|
+
expect(screen.getByRole('button')).toHaveClass('pf-m-danger');
|
|
69
|
+
});
|
|
70
|
+
|
|
56
71
|
test('split toggle passes onClick', async () => {
|
|
57
72
|
const mockClick = jest.fn();
|
|
58
73
|
const user = userEvent.setup();
|
|
@@ -152,9 +152,9 @@ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
|
152
152
|
|
|
153
153
|
### Plain toggle with icon
|
|
154
154
|
|
|
155
|
-
To apply plain styling to a menu toggle with an icon, pass in `variant="plain"
|
|
155
|
+
To apply plain styling to a menu toggle with an icon, pass in `variant="plain"`. This will remove the default bottom border and caret. You may pass in an `icon` to serve as the menu toggle. The following example passes in an `EllipsisVIcon`.
|
|
156
156
|
|
|
157
|
-
If the toggle does not have any visible text content,
|
|
157
|
+
If the toggle does not have any visible text content, use the `aria-label` property to provide an accessible name.
|
|
158
158
|
|
|
159
159
|
```ts
|
|
160
160
|
import React from 'react';
|
|
@@ -203,7 +203,7 @@ Variant styling can be applied to split button toggles to adjust their appearanc
|
|
|
203
203
|
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
### Split button toggle with
|
|
206
|
+
### Split button toggle with checkbox label
|
|
207
207
|
|
|
208
208
|
To display text in a split button menu toggle, add a label to the `items` property of `splitButtonOptions`.
|
|
209
209
|
|
|
@@ -211,6 +211,16 @@ To display text in a split button menu toggle, add a label to the `items` proper
|
|
|
211
211
|
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
+
### Split button toggle with checkbox and toggle button text
|
|
215
|
+
|
|
216
|
+
For split button toggles that should still contain text which will trigger the toggle's `onClick`, pass `children` to the `MenuToggle`.
|
|
217
|
+
|
|
218
|
+
The following example shows a split button with a `<MenuToggleCheckbox>` and toggle button text.
|
|
219
|
+
|
|
220
|
+
```ts file='MenuToggleSplitButtonCheckboxWithToggleText.tsx'
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
|
|
214
224
|
### Split button toggle with action
|
|
215
225
|
|
|
216
226
|
To add an action to a split button, pass `variant='action'` into `splitButtonOptions` and add a `<MenuToggleAction>` to the `items` property of `splitButtonOptions`.
|
|
@@ -266,3 +276,13 @@ To create a multiple typeahead toggle, pass a `<TextInputGroup>` component imple
|
|
|
266
276
|
```ts file='MenuToggleTypeahead.tsx'
|
|
267
277
|
|
|
268
278
|
```
|
|
279
|
+
|
|
280
|
+
### Status toggle
|
|
281
|
+
|
|
282
|
+
To create a toggle with a status, pass in the `status` property to the `MenuToggle`. The default icon associated with each status may be overridden by using the `statusIcon` property.
|
|
283
|
+
|
|
284
|
+
When the status value is "warning" or "danger", you must include helper text that conveys what is causing the warning/error.
|
|
285
|
+
|
|
286
|
+
```ts isBeta file='MenuToggleStatus.tsx'
|
|
287
|
+
|
|
288
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuToggleCheckbox, MenuToggle } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const MenuToggleSplitButtonCheckboxWithToggleText: React.FunctionComponent = () => (
|
|
5
|
+
<React.Fragment>
|
|
6
|
+
<MenuToggle
|
|
7
|
+
splitButtonOptions={{
|
|
8
|
+
items: [
|
|
9
|
+
<MenuToggleCheckbox
|
|
10
|
+
id="split-button-checkbox-with-text-example"
|
|
11
|
+
key="split-checkbox-with-text"
|
|
12
|
+
aria-label="Select all"
|
|
13
|
+
/>
|
|
14
|
+
]
|
|
15
|
+
}}
|
|
16
|
+
aria-label="Menu toggle with checkbox split button and text"
|
|
17
|
+
>
|
|
18
|
+
10 selected
|
|
19
|
+
</MenuToggle>{' '}
|
|
20
|
+
<MenuToggle
|
|
21
|
+
variant="primary"
|
|
22
|
+
splitButtonOptions={{
|
|
23
|
+
items: [
|
|
24
|
+
<MenuToggleCheckbox
|
|
25
|
+
id="split-button-checkbox-primary-example"
|
|
26
|
+
key="split-checkbox-primary"
|
|
27
|
+
aria-label="Select all"
|
|
28
|
+
/>
|
|
29
|
+
]
|
|
30
|
+
}}
|
|
31
|
+
aria-label="Primary menu toggle with checkbox split button"
|
|
32
|
+
>
|
|
33
|
+
10 selected
|
|
34
|
+
</MenuToggle>{' '}
|
|
35
|
+
<MenuToggle
|
|
36
|
+
variant="secondary"
|
|
37
|
+
splitButtonOptions={{
|
|
38
|
+
items: [
|
|
39
|
+
<MenuToggleCheckbox
|
|
40
|
+
id="split-button-checkbox-secondary-example"
|
|
41
|
+
key="split-checkbox-secondary"
|
|
42
|
+
aria-label="Select all"
|
|
43
|
+
/>
|
|
44
|
+
]
|
|
45
|
+
}}
|
|
46
|
+
aria-label="Secondary menu toggle with checkbox split button"
|
|
47
|
+
>
|
|
48
|
+
10 selected
|
|
49
|
+
</MenuToggle>
|
|
50
|
+
</React.Fragment>
|
|
51
|
+
);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuToggle, HelperText, HelperTextItem } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const MenuToggleStatus: React.FunctionComponent = () => (
|
|
5
|
+
<React.Fragment>
|
|
6
|
+
<MenuToggle status="success">Success</MenuToggle>
|
|
7
|
+
<br />
|
|
8
|
+
<br />
|
|
9
|
+
<MenuToggle status="warning">Warning</MenuToggle>
|
|
10
|
+
<HelperText>
|
|
11
|
+
<HelperTextItem variant="warning">Warning text that explains the issue.</HelperTextItem>
|
|
12
|
+
</HelperText>
|
|
13
|
+
<br />
|
|
14
|
+
<br />
|
|
15
|
+
<MenuToggle status="danger">Danger</MenuToggle>
|
|
16
|
+
<HelperText>
|
|
17
|
+
<HelperTextItem variant="error">Danger text that explains the issue.</HelperTextItem>
|
|
18
|
+
</HelperText>
|
|
19
|
+
</React.Fragment>
|
|
20
|
+
);
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { MultipleFileUpload } from '../MultipleFileUpload';
|
|
4
4
|
|
|
5
|
+
jest.mock('../../../helpers/GenerateId/GenerateId');
|
|
6
|
+
|
|
5
7
|
describe('MultipleFileUpload', () => {
|
|
6
8
|
test('renders with expected class names when not horizontal', () => {
|
|
7
9
|
const { asFragment } = render(<MultipleFileUpload>Foo</MultipleFileUpload>);
|
|
@@ -3,6 +3,8 @@ import { render } from '@testing-library/react';
|
|
|
3
3
|
import { MultipleFileUploadStatus } from '../MultipleFileUploadStatus';
|
|
4
4
|
import InProgressIcon from '@patternfly/react-icons/dist/esm/icons/in-progress-icon';
|
|
5
5
|
|
|
6
|
+
jest.mock('../../../helpers/GenerateId/GenerateId');
|
|
7
|
+
|
|
6
8
|
describe('MultipleFileUploadStatus', () => {
|
|
7
9
|
test('renders with expected class names', () => {
|
|
8
10
|
const { asFragment } = render(<MultipleFileUploadStatus>Foo</MultipleFileUploadStatus>);
|
|
@@ -9,10 +9,10 @@ exports[`MultipleFileUploadStatus renders custom class names 1`] = `
|
|
|
9
9
|
class="pf-v6-c-expandable-section pf-m-expanded"
|
|
10
10
|
>
|
|
11
11
|
<button
|
|
12
|
-
aria-controls="
|
|
12
|
+
aria-controls="generated-id-content"
|
|
13
13
|
aria-expanded="true"
|
|
14
14
|
class="pf-v6-c-expandable-section__toggle"
|
|
15
|
-
id="
|
|
15
|
+
id="generated-id-toggle"
|
|
16
16
|
type="button"
|
|
17
17
|
>
|
|
18
18
|
<span
|
|
@@ -48,9 +48,9 @@ exports[`MultipleFileUploadStatus renders custom class names 1`] = `
|
|
|
48
48
|
</span>
|
|
49
49
|
</button>
|
|
50
50
|
<div
|
|
51
|
-
aria-labelledby="
|
|
51
|
+
aria-labelledby="generated-id-toggle"
|
|
52
52
|
class="pf-v6-c-expandable-section__content"
|
|
53
|
-
id="
|
|
53
|
+
id="generated-id-content"
|
|
54
54
|
role="region"
|
|
55
55
|
>
|
|
56
56
|
<ul
|
|
@@ -74,10 +74,10 @@ exports[`MultipleFileUploadStatus renders status toggle icon 1`] = `
|
|
|
74
74
|
class="pf-v6-c-expandable-section pf-m-expanded"
|
|
75
75
|
>
|
|
76
76
|
<button
|
|
77
|
-
aria-controls="
|
|
77
|
+
aria-controls="generated-id-content"
|
|
78
78
|
aria-expanded="true"
|
|
79
79
|
class="pf-v6-c-expandable-section__toggle"
|
|
80
|
-
id="
|
|
80
|
+
id="generated-id-toggle"
|
|
81
81
|
type="button"
|
|
82
82
|
>
|
|
83
83
|
<span
|
|
@@ -127,9 +127,9 @@ exports[`MultipleFileUploadStatus renders status toggle icon 1`] = `
|
|
|
127
127
|
</span>
|
|
128
128
|
</button>
|
|
129
129
|
<div
|
|
130
|
-
aria-labelledby="
|
|
130
|
+
aria-labelledby="generated-id-toggle"
|
|
131
131
|
class="pf-v6-c-expandable-section__content"
|
|
132
|
-
id="
|
|
132
|
+
id="generated-id-content"
|
|
133
133
|
role="region"
|
|
134
134
|
>
|
|
135
135
|
<ul
|
|
@@ -153,10 +153,10 @@ exports[`MultipleFileUploadStatus renders status toggle text 1`] = `
|
|
|
153
153
|
class="pf-v6-c-expandable-section pf-m-expanded"
|
|
154
154
|
>
|
|
155
155
|
<button
|
|
156
|
-
aria-controls="
|
|
156
|
+
aria-controls="generated-id-content"
|
|
157
157
|
aria-expanded="true"
|
|
158
158
|
class="pf-v6-c-expandable-section__toggle"
|
|
159
|
-
id="
|
|
159
|
+
id="generated-id-toggle"
|
|
160
160
|
type="button"
|
|
161
161
|
>
|
|
162
162
|
<span
|
|
@@ -194,9 +194,9 @@ exports[`MultipleFileUploadStatus renders status toggle text 1`] = `
|
|
|
194
194
|
</span>
|
|
195
195
|
</button>
|
|
196
196
|
<div
|
|
197
|
-
aria-labelledby="
|
|
197
|
+
aria-labelledby="generated-id-toggle"
|
|
198
198
|
class="pf-v6-c-expandable-section__content"
|
|
199
|
-
id="
|
|
199
|
+
id="generated-id-content"
|
|
200
200
|
role="region"
|
|
201
201
|
>
|
|
202
202
|
<ul
|
|
@@ -220,10 +220,10 @@ exports[`MultipleFileUploadStatus renders with expected class names 1`] = `
|
|
|
220
220
|
class="pf-v6-c-expandable-section pf-m-expanded"
|
|
221
221
|
>
|
|
222
222
|
<button
|
|
223
|
-
aria-controls="
|
|
223
|
+
aria-controls="generated-id-content"
|
|
224
224
|
aria-expanded="true"
|
|
225
225
|
class="pf-v6-c-expandable-section__toggle"
|
|
226
|
-
id="
|
|
226
|
+
id="generated-id-toggle"
|
|
227
227
|
type="button"
|
|
228
228
|
>
|
|
229
229
|
<span
|
|
@@ -259,9 +259,9 @@ exports[`MultipleFileUploadStatus renders with expected class names 1`] = `
|
|
|
259
259
|
</span>
|
|
260
260
|
</button>
|
|
261
261
|
<div
|
|
262
|
-
aria-labelledby="
|
|
262
|
+
aria-labelledby="generated-id-toggle"
|
|
263
263
|
class="pf-v6-c-expandable-section__content"
|
|
264
|
-
id="
|
|
264
|
+
id="generated-id-content"
|
|
265
265
|
role="region"
|
|
266
266
|
>
|
|
267
267
|
<ul
|
|
@@ -125,10 +125,8 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
|
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
const handleClick = (event: MouseEvent) => {
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
|
|
131
|
-
if (event.detail === 0 && isOpen && toggleRef.current?.contains(event.target as Node)) {
|
|
128
|
+
// Focus the first non-disabled menu item on toggle 'click'
|
|
129
|
+
if (isOpen && toggleRef.current?.contains(event.target as Node)) {
|
|
132
130
|
setTimeout(() => {
|
|
133
131
|
const firstElement = menuRef?.current?.querySelector('li button:not(:disabled)');
|
|
134
132
|
firstElement && (firstElement as HTMLElement).focus();
|
|
@@ -11,6 +11,7 @@ import badgeStyles from '@patternfly/react-styles/css/components/Badge/badge';
|
|
|
11
11
|
import textInputGroupStyles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
|
|
12
12
|
|
|
13
13
|
jest.mock('../../../helpers/OUIA/ouia');
|
|
14
|
+
jest.mock('../../../helpers/GenerateId/GenerateId');
|
|
14
15
|
|
|
15
16
|
const props = {
|
|
16
17
|
onChange: jest.fn(),
|
|
@@ -364,7 +364,7 @@ exports[`SearchInput advanced search with custom attributes 1`] = `
|
|
|
364
364
|
>
|
|
365
365
|
<label
|
|
366
366
|
class="pf-v6-c-form__label"
|
|
367
|
-
for="
|
|
367
|
+
for="generated-id"
|
|
368
368
|
>
|
|
369
369
|
<span
|
|
370
370
|
class="pf-v6-c-form__label-text"
|
|
@@ -382,7 +382,7 @@ exports[`SearchInput advanced search with custom attributes 1`] = `
|
|
|
382
382
|
>
|
|
383
383
|
<input
|
|
384
384
|
aria-invalid="false"
|
|
385
|
-
id="
|
|
385
|
+
id="generated-id"
|
|
386
386
|
type="text"
|
|
387
387
|
value=""
|
|
388
388
|
/>
|
|
@@ -124,8 +124,8 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
const handleClick = (event: MouseEvent) => {
|
|
127
|
-
// toggle was
|
|
128
|
-
if (isOpen && toggleRef.current?.contains(event.target as Node)
|
|
127
|
+
// toggle was opened, focus on first menu item
|
|
128
|
+
if (isOpen && toggleRef.current?.contains(event.target as Node)) {
|
|
129
129
|
setTimeout(() => {
|
|
130
130
|
const firstElement = menuRef?.current?.querySelector('li button:not(:disabled),li input:not(:disabled)');
|
|
131
131
|
firstElement && (firstElement as HTMLElement).focus();
|
|
@@ -15,7 +15,10 @@ import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
|
15
15
|
|
|
16
16
|
Select builds off of the menu component suite to adapt commonly used properties and functions to create a select menu. See the [menu documentation](/components/menus/menu) for a full list of properties that may be used to further customize a select menu. View the [custom menu examples](/components/menus/custom-menus) to see examples of fully functional select menus.
|
|
17
17
|
|
|
18
|
+
For use cases that do not require a lot of customization, there are various template components available to use in the `@react-templates` package. These templates have a streamlined API and logic, making them easier to set up and use, but are limited in scope and flexibility. See the [templates page](/components/menus/select/react-templates) for details.
|
|
19
|
+
|
|
18
20
|
### Single select
|
|
21
|
+
|
|
19
22
|
To let users select a single item from a list, use a single select menu.
|
|
20
23
|
|
|
21
24
|
You can add multiple `<SelectOption>` components to build out a list of menu items. For each select option, pass a relevant option label to the `value` property.
|
|
@@ -28,30 +31,42 @@ To disable the select menu toggle, use the `isDisabled` property. In the followi
|
|
|
28
31
|
|
|
29
32
|
### Select option variants
|
|
30
33
|
|
|
31
|
-
The following example showcases different option variants and customizations that are commonly used in a select menu.
|
|
34
|
+
The following example showcases different option variants and customizations that are commonly used in a select menu.
|
|
32
35
|
|
|
33
|
-
To create these variants, you can pass different properties into a `<SelectOption>` component.
|
|
36
|
+
To create these variants, you can pass different properties into a `<SelectOption>` component.
|
|
34
37
|
|
|
35
|
-
This example provides examples of:
|
|
38
|
+
This example provides examples of:
|
|
36
39
|
|
|
37
40
|
- An option with a description, which is created by using the `description` property.
|
|
38
|
-
- An option with a link, which is created by passing a URL into the `to` property. For external links, use the `isExternalLink` property so that the option is styled with an outbound link icon.
|
|
39
|
-
- An option with an icon, which is created by using the `icon` property.
|
|
40
|
-
- An option that is disabled by using the `isDisabled` property.
|
|
41
|
+
- An option with a link, which is created by passing a URL into the `to` property. For external links, use the `isExternalLink` property so that the option is styled with an outbound link icon.
|
|
42
|
+
- An option with an icon, which is created by using the `icon` property.
|
|
43
|
+
- An option that is disabled by using the `isDisabled` property.
|
|
41
44
|
|
|
42
45
|
```ts file="./SelectOptionVariations.tsx"
|
|
43
46
|
|
|
44
47
|
```
|
|
45
48
|
|
|
46
49
|
### With grouped items
|
|
50
|
+
|
|
47
51
|
To group related select options together, use 1 or more `<SelectGroup>` components and title each group using the `label` property.
|
|
48
52
|
|
|
49
53
|
```ts file="./SelectGrouped.tsx"
|
|
50
54
|
|
|
51
55
|
```
|
|
52
56
|
|
|
57
|
+
### With validation
|
|
58
|
+
|
|
59
|
+
To create a toggle with a status, pass in `status` to the `MenuToggle`. The default icon associated with each status may be overridden by using the `statusIcon` property.
|
|
60
|
+
|
|
61
|
+
When the status value is "warning" or "danger", you must include helper text that conveys what is causing the warning/error.
|
|
62
|
+
|
|
63
|
+
```ts isBeta file="./SelectValidated.tsx"
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
|
|
53
67
|
### Checkbox select
|
|
54
|
-
|
|
68
|
+
|
|
69
|
+
To let users select multiple list options via checkbox input, use a checkbox select.
|
|
55
70
|
|
|
56
71
|
To create a checkbox select, pass `role="menu"` to the `<Select>`, and `hasCheckbox` into each `<SelectOption>` component. To indicate that an option is selected, use the `isSelected` property.
|
|
57
72
|
|
|
@@ -64,6 +79,8 @@ By default, the menu toggle will display a badge to indicate the number of items
|
|
|
64
79
|
### Typeahead
|
|
65
80
|
Typeahead is a select variant that replaces the typical button toggle for opening the select menu with a text input and button toggle combo. As a user enters characters into the text input, the menu options will be filtered to match.
|
|
66
81
|
|
|
82
|
+
Typeahead is a select variant that replaces the typical button toggle for opening the select menu with a text input and button toggle combo. As a user enters characters into the text input, the menu options will be filtered to match.
|
|
83
|
+
|
|
67
84
|
To make a typeahead, pass `variant=typeahead` into the `<MenuToggle>` component and link an `onClick` function to the `<TextInputGroupMain>` component.
|
|
68
85
|
|
|
69
86
|
```ts file="./SelectTypeahead.tsx"
|
|
@@ -73,6 +90,8 @@ To make a typeahead, pass `variant=typeahead` into the `<MenuToggle>` component
|
|
|
73
90
|
### Typeahead with create option
|
|
74
91
|
If a user enters a value into a typeahead select menu that does not exist, you can allow them to create an option of that value.
|
|
75
92
|
|
|
93
|
+
If a user enters a value into a typeahead select menu that does not exist, you can allow them to create an option of that value.
|
|
94
|
+
|
|
76
95
|
To enable the creation ability, pass a predetermined `value` into a `<SelectOption>` component. You can use the `placeholder` property to change the default text shown in the text input.
|
|
77
96
|
|
|
78
97
|
The following example outlines the code implementation required to create a working typeahead menu that allows for creation.
|
|
@@ -84,6 +103,8 @@ The following example outlines the code implementation required to create a work
|
|
|
84
103
|
### Multiple typeahead with chips
|
|
85
104
|
A multiple typeahead can be used to allow users to select multiple options from a list. Additionally, you can render a chip group to be placed in the select toggle.
|
|
86
105
|
|
|
106
|
+
A multiple typeahead can be used to allow users to select multiple options from a list. Additionally, you can render a chip group to be placed in the select toggle.
|
|
107
|
+
|
|
87
108
|
When more items than the allowed limit are selected, overflowing items will be hidden under a "more" button. The following example hides items after more than 3 are selected. To show hidden items, select the “more” button. Select "show less" to hide extra items again.
|
|
88
109
|
|
|
89
110
|
```ts file="./SelectMultiTypeahead.tsx"
|
|
@@ -93,6 +114,8 @@ When more items than the allowed limit are selected, overflowing items will be h
|
|
|
93
114
|
### Multiple typeahead with create option
|
|
94
115
|
If the text that is entered into a typeahead doesn't match a menu item, users can choose to create a new option that matches the text input. You can also combine this create functionality with a chip group to display created items as chips."
|
|
95
116
|
|
|
117
|
+
If the text that is entered into a typeahead doesn't match a menu item, users can choose to create a new option that matches the text input. You can also combine this create functionality with a chip group to display created items as chips."
|
|
118
|
+
|
|
96
119
|
```ts file="./SelectMultiTypeaheadCreatable.tsx"
|
|
97
120
|
|
|
98
121
|
```
|
|
@@ -100,11 +123,13 @@ If the text that is entered into a typeahead doesn't match a menu item, users ca
|
|
|
100
123
|
### Multiple typeahead with checkboxes
|
|
101
124
|
By default, a multiple typeahead select allows you to select multiple menu items, placing a checkmark beside selected items. Like basic checkbox select menus, you can add checkboxes to your menu items. This approach may be more accurate and comprehensive for more complex menu scenarios like filtering.
|
|
102
125
|
|
|
126
|
+
By default, a multiple typeahead select allows you to select multiple menu items, placing a checkmark beside selected items. Like basic checkbox select menus, you can add checkboxes to your menu items. This approach may be more accurate and comprehensive for more complex menu scenarios like filtering.
|
|
127
|
+
|
|
103
128
|
```ts file="./SelectMultiTypeaheadCheckbox.tsx"
|
|
104
129
|
|
|
105
130
|
```
|
|
106
131
|
|
|
107
|
-
### With view more
|
|
132
|
+
### With view more
|
|
108
133
|
|
|
109
134
|
To reduce the processing load for long select lists, you can add a "View more" action to load additional items.
|
|
110
135
|
|
|
@@ -118,7 +143,6 @@ The following example shows 3 items before the "View more" link, but you can adj
|
|
|
118
143
|
|
|
119
144
|
You can add a `<MenuFooter>` component to a select menu to hold additional actions that users can take on menu items, through elements such as link buttons. A footer will be placed beneath a divider at the end of the select menu.
|
|
120
145
|
|
|
121
|
-
|
|
122
146
|
```ts file="./SelectFooter.tsx"
|
|
123
147
|
|
|
124
148
|
```
|
|
@@ -44,7 +44,12 @@ export const SelectMultiTypeaheadCheckbox: React.FunctionComponent = () => {
|
|
|
44
44
|
// When no options are found after filtering, display 'No results found'
|
|
45
45
|
if (!newSelectOptions.length) {
|
|
46
46
|
newSelectOptions = [
|
|
47
|
-
{
|
|
47
|
+
{
|
|
48
|
+
isDisabled: false,
|
|
49
|
+
children: `No results found for "${inputValue}"`,
|
|
50
|
+
value: 'no results',
|
|
51
|
+
hasCheckbox: false
|
|
52
|
+
}
|
|
48
53
|
];
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Select,
|
|
4
|
+
SelectOption,
|
|
5
|
+
SelectList,
|
|
6
|
+
MenuToggle,
|
|
7
|
+
MenuToggleElement,
|
|
8
|
+
MenuToggleStatus,
|
|
9
|
+
HelperText,
|
|
10
|
+
HelperTextItem
|
|
11
|
+
} from '@patternfly/react-core';
|
|
12
|
+
|
|
13
|
+
export const SelectValidated: React.FunctionComponent = () => {
|
|
14
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
15
|
+
const [selected, setSelected] = React.useState<string>('Select a value');
|
|
16
|
+
const [status, setStatus] = React.useState<MenuToggleStatus>();
|
|
17
|
+
|
|
18
|
+
const onToggleClick = () => {
|
|
19
|
+
setIsOpen(!isOpen);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const onSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.log('selected', value);
|
|
25
|
+
|
|
26
|
+
setSelected(value as string);
|
|
27
|
+
setStatus((value as string).toLowerCase() as MenuToggleStatus);
|
|
28
|
+
setIsOpen(false);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const toggle = (toggleRef: React.Ref<MenuToggleElement>) => (
|
|
32
|
+
<MenuToggle
|
|
33
|
+
ref={toggleRef}
|
|
34
|
+
onClick={onToggleClick}
|
|
35
|
+
isExpanded={isOpen}
|
|
36
|
+
style={
|
|
37
|
+
{
|
|
38
|
+
width: '200px'
|
|
39
|
+
} as React.CSSProperties
|
|
40
|
+
}
|
|
41
|
+
status={status}
|
|
42
|
+
>
|
|
43
|
+
{selected}
|
|
44
|
+
</MenuToggle>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<React.Fragment>
|
|
49
|
+
<Select
|
|
50
|
+
id="single-select"
|
|
51
|
+
isOpen={isOpen}
|
|
52
|
+
selected={selected}
|
|
53
|
+
onSelect={onSelect}
|
|
54
|
+
onOpenChange={(isOpen) => setIsOpen(isOpen)}
|
|
55
|
+
toggle={toggle}
|
|
56
|
+
shouldFocusToggleOnSelect
|
|
57
|
+
>
|
|
58
|
+
<SelectList>
|
|
59
|
+
<SelectOption value="Success">Success</SelectOption>
|
|
60
|
+
<SelectOption value="Warning">Warning</SelectOption>
|
|
61
|
+
<SelectOption value="Danger">Danger</SelectOption>
|
|
62
|
+
</SelectList>
|
|
63
|
+
</Select>
|
|
64
|
+
{(status === MenuToggleStatus.warning || status === MenuToggleStatus.danger) && (
|
|
65
|
+
<HelperText isLiveRegion>
|
|
66
|
+
<HelperTextItem variant={status === MenuToggleStatus.warning ? 'warning' : 'error'}>
|
|
67
|
+
{status === MenuToggleStatus.warning && 'Warning text that explains the issue.'}
|
|
68
|
+
{status === MenuToggleStatus.danger && 'Danger text that explains the issue.'}
|
|
69
|
+
</HelperTextItem>
|
|
70
|
+
</HelperText>
|
|
71
|
+
)}
|
|
72
|
+
</React.Fragment>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -7,6 +7,8 @@ import { TabTitleIcon } from '../TabTitleIcon';
|
|
|
7
7
|
import { TabContent } from '../TabContent';
|
|
8
8
|
import { TabContentBody } from '../TabContentBody';
|
|
9
9
|
|
|
10
|
+
jest.mock('../../../helpers/GenerateId/GenerateId');
|
|
11
|
+
|
|
10
12
|
test('should render simple tabs', () => {
|
|
11
13
|
const { asFragment } = render(
|
|
12
14
|
<Tabs id="simpleTabs">
|
|
@@ -408,12 +408,12 @@ exports[`should render expandable vertical tabs 1`] = `
|
|
|
408
408
|
>
|
|
409
409
|
<button
|
|
410
410
|
aria-disabled="false"
|
|
411
|
-
aria-labelledby="
|
|
411
|
+
aria-labelledby="generated-id-text generated-id-button"
|
|
412
412
|
class="pf-v6-c-button pf-m-plain"
|
|
413
413
|
data-ouia-component-id="OUIA-Generated-Button-plain-3"
|
|
414
414
|
data-ouia-component-type="PF5/Button"
|
|
415
415
|
data-ouia-safe="true"
|
|
416
|
-
id="
|
|
416
|
+
id="generated-id-button"
|
|
417
417
|
type="button"
|
|
418
418
|
>
|
|
419
419
|
<span
|
|
@@ -436,7 +436,7 @@ exports[`should render expandable vertical tabs 1`] = `
|
|
|
436
436
|
</span>
|
|
437
437
|
<span
|
|
438
438
|
class="pf-v6-c-tabs__toggle-text"
|
|
439
|
-
id="
|
|
439
|
+
id="generated-id-text"
|
|
440
440
|
>
|
|
441
441
|
toggle
|
|
442
442
|
</span>
|
|
@@ -36,10 +36,6 @@ export interface TextAreaProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'onC
|
|
|
36
36
|
value?: string | number;
|
|
37
37
|
/** A callback for when the text area value changes. */
|
|
38
38
|
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>, value: string) => void;
|
|
39
|
-
/** Callback function when text area is focused */
|
|
40
|
-
onFocus?: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
41
|
-
/** Callback function when text area is blurred (focus leaves) */
|
|
42
|
-
onBlur?: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
|
|
43
39
|
/** Sets the orientation to limit the resize to */
|
|
44
40
|
resizeOrientation?: 'horizontal' | 'vertical' | 'both';
|
|
45
41
|
/** Custom flag to show that the text area requires an associated id or aria-label. */
|
|
@@ -8,6 +8,8 @@ export interface ToggleGroupItemProps extends Omit<React.HTMLProps<HTMLDivElemen
|
|
|
8
8
|
text?: React.ReactNode;
|
|
9
9
|
/** Icon rendered inside the toggle group item */
|
|
10
10
|
icon?: React.ReactNode;
|
|
11
|
+
/** Sets position of the icon when text is also passed in */
|
|
12
|
+
iconPosition?: 'start' | 'end';
|
|
11
13
|
/** Additional classes added to the toggle group item */
|
|
12
14
|
className?: string;
|
|
13
15
|
/** Flag indicating if the toggle group item is disabled */
|
|
@@ -25,6 +27,7 @@ export interface ToggleGroupItemProps extends Omit<React.HTMLProps<HTMLDivElemen
|
|
|
25
27
|
export const ToggleGroupItem: React.FunctionComponent<ToggleGroupItemProps> = ({
|
|
26
28
|
text,
|
|
27
29
|
icon,
|
|
30
|
+
iconPosition = 'start',
|
|
28
31
|
className,
|
|
29
32
|
isDisabled = false,
|
|
30
33
|
isSelected = false,
|
|
@@ -42,6 +45,8 @@ export const ToggleGroupItem: React.FunctionComponent<ToggleGroupItemProps> = ({
|
|
|
42
45
|
console.warn('An accessible aria-label is required when using the toggle group item icon variant.');
|
|
43
46
|
}
|
|
44
47
|
|
|
48
|
+
const toggleGroupIcon = <ToggleGroupItemElement variant={ToggleGroupItemVariant.icon}>{icon}</ToggleGroupItemElement>;
|
|
49
|
+
|
|
45
50
|
return (
|
|
46
51
|
<div className={css(styles.toggleGroupItem, className)} {...props}>
|
|
47
52
|
<button
|
|
@@ -53,8 +58,9 @@ export const ToggleGroupItem: React.FunctionComponent<ToggleGroupItemProps> = ({
|
|
|
53
58
|
disabled={isDisabled}
|
|
54
59
|
id={buttonId}
|
|
55
60
|
>
|
|
56
|
-
{icon &&
|
|
61
|
+
{icon && iconPosition === 'start' && toggleGroupIcon}
|
|
57
62
|
{text && <ToggleGroupItemElement variant={ToggleGroupItemVariant.text}>{text}</ToggleGroupItemElement>}
|
|
63
|
+
{icon && iconPosition === 'end' && toggleGroupIcon}
|
|
58
64
|
</button>
|
|
59
65
|
</div>
|
|
60
66
|
);
|