@patternfly/react-core 5.4.0-prerelease.1 → 5.4.0-prerelease.11
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 +58 -0
- package/CONTRIBUTING.md +0 -2
- 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/Chip/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/DragDrop/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/ContextSelector/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/dynamic-modules.json +772 -0
- package/dist/esm/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +10 -5
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerPanelContent.d.ts +4 -4
- package/dist/esm/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/esm/components/NotificationDrawer/NotificationDrawerGroup.d.ts +1 -1
- package/dist/esm/components/NotificationDrawer/NotificationDrawerGroup.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/esm/components/NumberInput/NumberInput.js +4 -3
- package/dist/esm/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/esm/components/Page/Page.d.ts +6 -0
- package/dist/esm/components/Page/Page.d.ts.map +1 -1
- package/dist/esm/components/Page/Page.js +3 -3
- package/dist/esm/components/Page/Page.js.map +1 -1
- package/dist/esm/components/Pagination/Navigation.d.ts +3 -3
- package/dist/esm/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Navigation.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +2 -1
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Pagination/PaginationOptionsMenu.d.ts +1 -0
- 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.d.ts +2 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +3 -3
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +4 -0
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +17 -0
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/TreeView/TreeView.d.ts +13 -0
- package/dist/esm/components/TreeView/TreeView.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeView.js +2 -2
- package/dist/esm/components/TreeView/TreeView.js.map +1 -1
- package/dist/esm/components/TreeView/TreeViewList.d.ts +13 -0
- package/dist/esm/components/TreeView/TreeViewList.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeViewList.js +2 -2
- package/dist/esm/components/TreeView/TreeViewList.js.map +1 -1
- package/dist/esm/components/TreeView/TreeViewListItem.d.ts.map +1 -1
- package/dist/esm/components/TreeView/TreeViewListItem.js +8 -8
- package/dist/esm/components/TreeView/TreeViewListItem.js.map +1 -1
- package/dist/esm/components/Truncate/Truncate.d.ts.map +1 -1
- package/dist/esm/components/Truncate/Truncate.js +54 -12
- package/dist/esm/components/Truncate/Truncate.js.map +1 -1
- package/dist/esm/components/Wizard/Wizard.d.ts +5 -1
- package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/esm/components/Wizard/Wizard.js +9 -2
- package/dist/esm/components/Wizard/Wizard.js.map +1 -1
- package/dist/esm/components/Wizard/WizardBody.js +8 -9
- package/dist/esm/components/Wizard/WizardBody.js.map +1 -1
- package/dist/esm/components/Wizard/WizardContext.d.ts +8 -0
- package/dist/esm/components/Wizard/WizardContext.d.ts.map +1 -1
- package/dist/esm/components/Wizard/WizardContext.js +4 -2
- package/dist/esm/components/Wizard/WizardContext.js.map +1 -1
- package/dist/esm/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/dist/esm/components/Wizard/WizardNavItem.js +10 -17
- package/dist/esm/components/Wizard/WizardNavItem.js.map +1 -1
- package/dist/esm/deprecated/components/OptionsMenu/OptionsMenuItemGroup.d.ts +1 -1
- package/dist/esm/deprecated/components/OptionsMenu/OptionsMenuItemGroup.d.ts.map +1 -1
- package/dist/esm/deprecated/components/Select/Select.d.ts +1 -1
- package/dist/esm/deprecated/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.js +10 -5
- package/dist/js/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/js/components/Drawer/DrawerPanelContent.d.ts +4 -4
- package/dist/js/components/Drawer/DrawerPanelContent.d.ts.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawerGroup.d.ts +1 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawerGroup.d.ts.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/js/components/NumberInput/NumberInput.js +4 -3
- package/dist/js/components/NumberInput/NumberInput.js.map +1 -1
- package/dist/js/components/Page/Page.d.ts +6 -0
- package/dist/js/components/Page/Page.d.ts.map +1 -1
- package/dist/js/components/Page/Page.js +3 -3
- package/dist/js/components/Page/Page.js.map +1 -1
- package/dist/js/components/Pagination/Navigation.d.ts +3 -3
- package/dist/js/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/js/components/Pagination/Navigation.js.map +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/js/components/Pagination/Pagination.js +2 -1
- package/dist/js/components/Pagination/Pagination.js.map +1 -1
- package/dist/js/components/Pagination/PaginationOptionsMenu.d.ts +1 -0
- 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.d.ts +2 -0
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +3 -3
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +4 -0
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +17 -0
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/components/TreeView/TreeView.d.ts +13 -0
- package/dist/js/components/TreeView/TreeView.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeView.js +2 -2
- package/dist/js/components/TreeView/TreeView.js.map +1 -1
- package/dist/js/components/TreeView/TreeViewList.d.ts +13 -0
- package/dist/js/components/TreeView/TreeViewList.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeViewList.js +2 -2
- package/dist/js/components/TreeView/TreeViewList.js.map +1 -1
- package/dist/js/components/TreeView/TreeViewListItem.d.ts.map +1 -1
- package/dist/js/components/TreeView/TreeViewListItem.js +8 -8
- package/dist/js/components/TreeView/TreeViewListItem.js.map +1 -1
- package/dist/js/components/Truncate/Truncate.d.ts.map +1 -1
- package/dist/js/components/Truncate/Truncate.js +54 -12
- package/dist/js/components/Truncate/Truncate.js.map +1 -1
- package/dist/js/components/Wizard/Wizard.d.ts +5 -1
- package/dist/js/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/js/components/Wizard/Wizard.js +9 -2
- package/dist/js/components/Wizard/Wizard.js.map +1 -1
- package/dist/js/components/Wizard/WizardBody.js +8 -9
- package/dist/js/components/Wizard/WizardBody.js.map +1 -1
- package/dist/js/components/Wizard/WizardContext.d.ts +8 -0
- package/dist/js/components/Wizard/WizardContext.d.ts.map +1 -1
- package/dist/js/components/Wizard/WizardContext.js +4 -2
- package/dist/js/components/Wizard/WizardContext.js.map +1 -1
- package/dist/js/components/Wizard/WizardNavItem.d.ts.map +1 -1
- package/dist/js/components/Wizard/WizardNavItem.js +10 -17
- package/dist/js/components/Wizard/WizardNavItem.js.map +1 -1
- package/dist/js/deprecated/components/OptionsMenu/OptionsMenuItemGroup.d.ts +1 -1
- package/dist/js/deprecated/components/OptionsMenu/OptionsMenuItemGroup.d.ts.map +1 -1
- package/dist/js/deprecated/components/Select/Select.d.ts +1 -1
- package/dist/js/deprecated/components/Select/Select.d.ts.map +1 -1
- package/dist/umd/react-core.min.js +9 -9
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +7 -8
- package/src/components/Checkbox/examples/Checkbox.md +14 -0
- package/src/components/Checkbox/examples/CheckboxLabelWraps.tsx +11 -0
- package/src/components/Checkbox/examples/CheckboxReversed.tsx +6 -0
- package/src/components/CodeBlock/examples/CodeBlock.md +6 -0
- package/src/components/CodeBlock/examples/CodeBlockBasic.tsx +1 -1
- package/src/components/CodeBlock/examples/CodeBlockExpandable.tsx +3 -3
- package/src/components/DatePicker/DatePicker.tsx +11 -5
- package/src/components/Drawer/DrawerPanelContent.tsx +4 -4
- package/src/components/MenuToggle/MenuToggle.tsx +1 -0
- package/src/components/NotificationDrawer/NotificationDrawerGroup.tsx +1 -1
- package/src/components/NumberInput/NumberInput.tsx +5 -3
- package/src/components/Page/Page.tsx +14 -1
- package/src/components/Pagination/Navigation.tsx +12 -12
- package/src/components/Pagination/Pagination.tsx +3 -1
- package/src/components/Pagination/PaginationOptionsMenu.tsx +13 -14
- package/src/components/Pagination/__tests__/Generated/__snapshots__/PaginationOptionsMenu.test.tsx.snap +36 -38
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +714 -754
- package/src/components/Radio/examples/Radio.md +11 -0
- package/src/components/Select/Select.tsx +5 -2
- package/src/components/Select/examples/SelectMultiTypeahead.tsx +111 -66
- package/src/components/Select/examples/SelectMultiTypeaheadCheckbox.tsx +103 -60
- package/src/components/Select/examples/SelectMultiTypeaheadCreatable.tsx +125 -79
- package/src/components/Select/examples/SelectTypeahead.tsx +113 -69
- package/src/components/Select/examples/SelectTypeaheadCreatable.tsx +115 -75
- package/src/components/Tabs/Tabs.tsx +21 -0
- package/src/components/ToggleGroup/examples/ToggleGroup.md +33 -8
- package/src/components/TreeView/TreeView.tsx +23 -1
- package/src/components/TreeView/TreeViewList.tsx +24 -1
- package/src/components/TreeView/TreeViewListItem.tsx +13 -7
- package/src/components/TreeView/__tests__/__snapshots__/TreeViewList.test.tsx.snap +2 -0
- package/src/components/TreeView/__tests__/__snapshots__/TreeViewListItem.test.tsx.snap +2 -0
- package/src/components/TreeView/examples/TreeView.md +12 -2
- package/src/components/TreeView/examples/TreeViewCompact.tsx +1 -1
- package/src/components/TreeView/examples/TreeViewCompactNoBackground.tsx +1 -1
- package/src/components/TreeView/examples/TreeViewGuides.tsx +1 -1
- package/src/components/TreeView/examples/TreeViewMultiselectable.tsx +86 -0
- package/src/components/TreeView/examples/TreeViewSelectionExpansion.tsx +9 -1
- package/src/components/TreeView/examples/{TreeViewDefault.tsx → TreeViewSingleSelectable.tsx} +8 -2
- package/src/components/TreeView/examples/TreeViewWithActionItems.tsx +8 -1
- package/src/components/TreeView/examples/TreeViewWithBadges.tsx +9 -1
- package/src/components/TreeView/examples/TreeViewWithCheckboxes.tsx +1 -1
- package/src/components/TreeView/examples/TreeViewWithCustomBadges.tsx +9 -1
- package/src/components/TreeView/examples/TreeViewWithIcons.tsx +1 -0
- package/src/components/TreeView/examples/TreeViewWithMemoization.tsx +8 -1
- package/src/components/TreeView/examples/TreeViewWithSearch.tsx +1 -0
- package/src/components/Truncate/Truncate.tsx +73 -7
- package/src/components/Truncate/__tests__/Truncate.test.tsx +6 -0
- package/src/components/Wizard/Wizard.tsx +15 -0
- package/src/components/Wizard/WizardBody.tsx +9 -9
- package/src/components/Wizard/WizardContext.tsx +14 -2
- package/src/components/Wizard/WizardNavItem.tsx +7 -21
- package/src/components/Wizard/__tests__/Wizard.test.tsx +4 -4
- package/src/components/Wizard/examples/Wizard.md +29 -1
- package/src/components/Wizard/examples/WizardFocusOnNextBack.tsx +16 -0
- package/src/components/Wizard/examples/WizardWithCustomFooter.tsx +3 -3
- package/src/deprecated/components/ApplicationLauncher/examples/ApplicationLauncher.md +1 -0
- package/src/deprecated/components/OptionsMenu/OptionsMenuItemGroup.tsx +1 -1
- package/src/deprecated/components/Select/Select.tsx +1 -1
|
@@ -29,10 +29,11 @@ export const SelectTypeaheadCreatable: React.FunctionComponent = () => {
|
|
|
29
29
|
const [filterValue, setFilterValue] = React.useState<string>('');
|
|
30
30
|
const [selectOptions, setSelectOptions] = React.useState<SelectOptionProps[]>(initialSelectOptions);
|
|
31
31
|
const [focusedItemIndex, setFocusedItemIndex] = React.useState<number | null>(null);
|
|
32
|
-
const [
|
|
33
|
-
const [onCreation, setOnCreation] = React.useState<boolean>(false); // Boolean to refresh filter state after new option is created
|
|
32
|
+
const [activeItemId, setActiveItemId] = React.useState<string | null>(null);
|
|
34
33
|
const textInputRef = React.useRef<HTMLInputElement>();
|
|
35
34
|
|
|
35
|
+
const CREATE_NEW = 'create';
|
|
36
|
+
|
|
36
37
|
React.useEffect(() => {
|
|
37
38
|
let newSelectOptions: SelectOptionProps[] = initialSelectOptions;
|
|
38
39
|
|
|
@@ -42,9 +43,9 @@ export const SelectTypeaheadCreatable: React.FunctionComponent = () => {
|
|
|
42
43
|
String(menuItem.children).toLowerCase().includes(filterValue.toLowerCase())
|
|
43
44
|
);
|
|
44
45
|
|
|
45
|
-
//
|
|
46
|
-
if (!
|
|
47
|
-
newSelectOptions = [{
|
|
46
|
+
// If no option matches the filter exactly, display creation option
|
|
47
|
+
if (!initialSelectOptions.some((option) => option.value === filterValue)) {
|
|
48
|
+
newSelectOptions = [...newSelectOptions, { children: `Create new option "${filterValue}"`, value: CREATE_NEW }];
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
// Open the menu when the input value changes and the new value is not empty
|
|
@@ -54,96 +55,133 @@ export const SelectTypeaheadCreatable: React.FunctionComponent = () => {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
setSelectOptions(newSelectOptions);
|
|
57
|
-
|
|
58
|
+
}, [filterValue]);
|
|
59
|
+
|
|
60
|
+
const createItemId = (value: any) => `select-typeahead-${value.replace(' ', '-')}`;
|
|
61
|
+
|
|
62
|
+
const setActiveAndFocusedItem = (itemIndex: number) => {
|
|
63
|
+
setFocusedItemIndex(itemIndex);
|
|
64
|
+
const focusedItem = selectOptions[itemIndex];
|
|
65
|
+
setActiveItemId(createItemId(focusedItem.value));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const resetActiveAndFocusedItem = () => {
|
|
58
69
|
setFocusedItemIndex(null);
|
|
59
|
-
|
|
70
|
+
setActiveItemId(null);
|
|
71
|
+
};
|
|
60
72
|
|
|
61
|
-
const
|
|
62
|
-
setIsOpen(
|
|
73
|
+
const closeMenu = () => {
|
|
74
|
+
setIsOpen(false);
|
|
75
|
+
resetActiveAndFocusedItem();
|
|
63
76
|
};
|
|
64
77
|
|
|
65
|
-
const
|
|
78
|
+
const onInputClick = () => {
|
|
79
|
+
if (!isOpen) {
|
|
80
|
+
setIsOpen(true);
|
|
81
|
+
} else if (!inputValue) {
|
|
82
|
+
closeMenu();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const selectOption = (value: string | number, content: string | number) => {
|
|
66
87
|
// eslint-disable-next-line no-console
|
|
88
|
+
console.log('selected', content);
|
|
89
|
+
|
|
90
|
+
setInputValue(String(content));
|
|
91
|
+
setFilterValue('');
|
|
92
|
+
setSelected(String(value));
|
|
93
|
+
|
|
94
|
+
closeMenu();
|
|
95
|
+
};
|
|
67
96
|
|
|
97
|
+
const onSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, value: string | number | undefined) => {
|
|
68
98
|
if (value) {
|
|
69
|
-
if (value ===
|
|
70
|
-
if (!initialSelectOptions.some((item) => item.
|
|
99
|
+
if (value === CREATE_NEW) {
|
|
100
|
+
if (!initialSelectOptions.some((item) => item.children === filterValue)) {
|
|
71
101
|
initialSelectOptions = [...initialSelectOptions, { value: filterValue, children: filterValue }];
|
|
72
102
|
}
|
|
73
103
|
setSelected(filterValue);
|
|
74
|
-
setOnCreation(!onCreation);
|
|
75
104
|
setFilterValue('');
|
|
105
|
+
closeMenu();
|
|
76
106
|
} else {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
setInputValue(value as string);
|
|
80
|
-
setFilterValue('');
|
|
81
|
-
setSelected(value as string);
|
|
107
|
+
const optionText = selectOptions.find((option) => option.value === value)?.children;
|
|
108
|
+
selectOption(value, optionText as string);
|
|
82
109
|
}
|
|
83
110
|
}
|
|
84
|
-
|
|
85
|
-
setIsOpen(false);
|
|
86
|
-
setFocusedItemIndex(null);
|
|
87
|
-
setActiveItem(null);
|
|
88
111
|
};
|
|
89
112
|
|
|
90
113
|
const onTextInputChange = (_event: React.FormEvent<HTMLInputElement>, value: string) => {
|
|
91
114
|
setInputValue(value);
|
|
92
115
|
setFilterValue(value);
|
|
116
|
+
|
|
117
|
+
resetActiveAndFocusedItem();
|
|
118
|
+
|
|
119
|
+
if (value !== selected) {
|
|
120
|
+
setSelected('');
|
|
121
|
+
}
|
|
93
122
|
};
|
|
94
123
|
|
|
95
124
|
const handleMenuArrowKeys = (key: string) => {
|
|
96
|
-
let indexToFocus;
|
|
125
|
+
let indexToFocus = 0;
|
|
126
|
+
|
|
127
|
+
if (!isOpen) {
|
|
128
|
+
setIsOpen(true);
|
|
129
|
+
}
|
|
97
130
|
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
131
|
+
if (selectOptions.every((option) => option.isDisabled)) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (key === 'ArrowUp') {
|
|
136
|
+
// When no index is set or at the first index, focus to the last, otherwise decrement focus index
|
|
137
|
+
if (focusedItemIndex === null || focusedItemIndex === 0) {
|
|
138
|
+
indexToFocus = selectOptions.length - 1;
|
|
139
|
+
} else {
|
|
140
|
+
indexToFocus = focusedItemIndex - 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Skip disabled options
|
|
144
|
+
while (selectOptions[indexToFocus].isDisabled) {
|
|
145
|
+
indexToFocus--;
|
|
146
|
+
if (indexToFocus === -1) {
|
|
102
147
|
indexToFocus = selectOptions.length - 1;
|
|
103
|
-
} else {
|
|
104
|
-
indexToFocus = focusedItemIndex - 1;
|
|
105
148
|
}
|
|
106
149
|
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (key === 'ArrowDown') {
|
|
153
|
+
// When no index is set or at the last index, focus to the first, otherwise increment focus index
|
|
154
|
+
if (focusedItemIndex === null || focusedItemIndex === selectOptions.length - 1) {
|
|
155
|
+
indexToFocus = 0;
|
|
156
|
+
} else {
|
|
157
|
+
indexToFocus = focusedItemIndex + 1;
|
|
158
|
+
}
|
|
107
159
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
160
|
+
// Skip disabled options
|
|
161
|
+
while (selectOptions[indexToFocus].isDisabled) {
|
|
162
|
+
indexToFocus++;
|
|
163
|
+
if (indexToFocus === selectOptions.length) {
|
|
111
164
|
indexToFocus = 0;
|
|
112
|
-
} else {
|
|
113
|
-
indexToFocus = focusedItemIndex + 1;
|
|
114
165
|
}
|
|
115
166
|
}
|
|
116
|
-
|
|
117
|
-
setFocusedItemIndex(indexToFocus);
|
|
118
|
-
const focusedItem = selectOptions.filter((option) => !option.isDisabled)[indexToFocus];
|
|
119
|
-
setActiveItem(`select-create-typeahead-${focusedItem.value.replace(' ', '-')}`);
|
|
120
167
|
}
|
|
168
|
+
|
|
169
|
+
setActiveAndFocusedItem(indexToFocus);
|
|
121
170
|
};
|
|
122
171
|
|
|
123
172
|
const onInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
124
|
-
const
|
|
125
|
-
const [firstMenuItem] = enabledMenuItems;
|
|
126
|
-
const focusedItem = focusedItemIndex ? enabledMenuItems[focusedItemIndex] : firstMenuItem;
|
|
173
|
+
const focusedItem = focusedItemIndex !== null ? selectOptions[focusedItemIndex] : null;
|
|
127
174
|
|
|
128
175
|
switch (event.key) {
|
|
129
|
-
// Select the first available option
|
|
130
176
|
case 'Enter':
|
|
131
|
-
if (isOpen) {
|
|
177
|
+
if (isOpen && focusedItem && !focusedItem.isAriaDisabled) {
|
|
132
178
|
onSelect(undefined, focusedItem.value as string);
|
|
133
|
-
setIsOpen((prevIsOpen) => !prevIsOpen);
|
|
134
|
-
setFocusedItemIndex(null);
|
|
135
|
-
setActiveItem(null);
|
|
136
179
|
}
|
|
137
180
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
181
|
+
if (!isOpen) {
|
|
182
|
+
setIsOpen(true);
|
|
183
|
+
}
|
|
141
184
|
|
|
142
|
-
break;
|
|
143
|
-
case 'Tab':
|
|
144
|
-
case 'Escape':
|
|
145
|
-
setIsOpen(false);
|
|
146
|
-
setActiveItem(null);
|
|
147
185
|
break;
|
|
148
186
|
case 'ArrowUp':
|
|
149
187
|
case 'ArrowDown':
|
|
@@ -153,6 +191,19 @@ export const SelectTypeaheadCreatable: React.FunctionComponent = () => {
|
|
|
153
191
|
}
|
|
154
192
|
};
|
|
155
193
|
|
|
194
|
+
const onToggleClick = () => {
|
|
195
|
+
setIsOpen(!isOpen);
|
|
196
|
+
textInputRef?.current?.focus();
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const onClearButtonClick = () => {
|
|
200
|
+
setSelected('');
|
|
201
|
+
setInputValue('');
|
|
202
|
+
setFilterValue('');
|
|
203
|
+
resetActiveAndFocusedItem();
|
|
204
|
+
textInputRef?.current?.focus();
|
|
205
|
+
};
|
|
206
|
+
|
|
156
207
|
const toggle = (toggleRef: React.Ref<MenuToggleElement>) => (
|
|
157
208
|
<MenuToggle
|
|
158
209
|
ref={toggleRef}
|
|
@@ -165,34 +216,23 @@ export const SelectTypeaheadCreatable: React.FunctionComponent = () => {
|
|
|
165
216
|
<TextInputGroup isPlain>
|
|
166
217
|
<TextInputGroupMain
|
|
167
218
|
value={inputValue}
|
|
168
|
-
onClick={
|
|
219
|
+
onClick={onInputClick}
|
|
169
220
|
onChange={onTextInputChange}
|
|
170
221
|
onKeyDown={onInputKeyDown}
|
|
171
222
|
id="create-typeahead-select-input"
|
|
172
223
|
autoComplete="off"
|
|
173
224
|
innerRef={textInputRef}
|
|
174
225
|
placeholder="Select a state"
|
|
175
|
-
{...(
|
|
226
|
+
{...(activeItemId && { 'aria-activedescendant': activeItemId })}
|
|
176
227
|
role="combobox"
|
|
177
228
|
isExpanded={isOpen}
|
|
178
229
|
aria-controls="select-create-typeahead-listbox"
|
|
179
230
|
/>
|
|
180
231
|
|
|
181
|
-
<TextInputGroupUtilities>
|
|
182
|
-
{
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
onClick={() => {
|
|
186
|
-
setSelected('');
|
|
187
|
-
setInputValue('');
|
|
188
|
-
setFilterValue('');
|
|
189
|
-
textInputRef?.current?.focus();
|
|
190
|
-
}}
|
|
191
|
-
aria-label="Clear input value"
|
|
192
|
-
>
|
|
193
|
-
<TimesIcon aria-hidden />
|
|
194
|
-
</Button>
|
|
195
|
-
)}
|
|
232
|
+
<TextInputGroupUtilities {...(!inputValue ? { style: { display: 'none' } } : {})}>
|
|
233
|
+
<Button variant="plain" onClick={onClearButtonClick} aria-label="Clear input value">
|
|
234
|
+
<TimesIcon aria-hidden />
|
|
235
|
+
</Button>
|
|
196
236
|
</TextInputGroupUtilities>
|
|
197
237
|
</TextInputGroup>
|
|
198
238
|
</MenuToggle>
|
|
@@ -204,10 +244,11 @@ export const SelectTypeaheadCreatable: React.FunctionComponent = () => {
|
|
|
204
244
|
isOpen={isOpen}
|
|
205
245
|
selected={selected}
|
|
206
246
|
onSelect={onSelect}
|
|
207
|
-
onOpenChange={() => {
|
|
208
|
-
|
|
247
|
+
onOpenChange={(isOpen) => {
|
|
248
|
+
!isOpen && closeMenu();
|
|
209
249
|
}}
|
|
210
250
|
toggle={toggle}
|
|
251
|
+
shouldFocusFirstItemOnOpen={false}
|
|
211
252
|
>
|
|
212
253
|
<SelectList id="select-create-typeahead-listbox">
|
|
213
254
|
{selectOptions.map((option, index) => (
|
|
@@ -215,8 +256,7 @@ export const SelectTypeaheadCreatable: React.FunctionComponent = () => {
|
|
|
215
256
|
key={option.value || option.children}
|
|
216
257
|
isFocused={focusedItemIndex === index}
|
|
217
258
|
className={option.className}
|
|
218
|
-
|
|
219
|
-
id={`select-typeahead-${option.value.replace(' ', '-')}`}
|
|
259
|
+
id={createItemId(option.value)}
|
|
220
260
|
{...option}
|
|
221
261
|
ref={null}
|
|
222
262
|
/>
|
|
@@ -384,6 +384,27 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
384
384
|
this.direction = getLanguageDirection(this.tabList.current);
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
+
static getDerivedStateFromProps(nextProps: TabsProps, prevState: TabsState) {
|
|
388
|
+
if (prevState.uncontrolledActiveKey === undefined) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const childrenHasTabWithActiveEventKey = React.Children.toArray(nextProps.children)
|
|
393
|
+
.filter((child): child is TabElement => React.isValidElement(child))
|
|
394
|
+
.some(({ props }) => props.eventKey === prevState.uncontrolledActiveKey);
|
|
395
|
+
|
|
396
|
+
// if uncontrolledActiveKey is an existing eventKey of any Tab of nextProps.children --> don't update uncontrolledActiveKey
|
|
397
|
+
if (childrenHasTabWithActiveEventKey) {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// otherwise update state derived from nextProps.defaultActiveKey
|
|
402
|
+
return {
|
|
403
|
+
uncontrolledActiveKey: nextProps.defaultActiveKey,
|
|
404
|
+
shownKeys: nextProps.defaultActiveKey !== undefined ? [nextProps.defaultActiveKey] : [nextProps.activeKey] // only for mountOnEnter case
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
387
408
|
render() {
|
|
388
409
|
const {
|
|
389
410
|
className,
|
|
@@ -13,22 +13,47 @@ import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square
|
|
|
13
13
|
|
|
14
14
|
## Examples
|
|
15
15
|
|
|
16
|
-
###
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
### Single select toggle group
|
|
17
|
+
|
|
18
|
+
A single select toggle group allows users to toggle between multiple items.
|
|
19
|
+
|
|
20
|
+
To indicate whether a `<ToggleGroupItem>` is selected or not, use the `isSelected` property.
|
|
19
21
|
|
|
20
|
-
### Default with single selectable
|
|
21
22
|
```ts file="./ToggleGroupDefaultSingle.tsx"
|
|
22
23
|
```
|
|
23
24
|
|
|
24
|
-
###
|
|
25
|
+
### Multi select toggle group
|
|
26
|
+
|
|
27
|
+
A multi select toggle group allows users to select multiple items at once.
|
|
28
|
+
|
|
29
|
+
When a toggle item is disabled it cannot be selected. Click the "Disable all" button in the following example to see this in action.
|
|
30
|
+
|
|
31
|
+
```ts file="./ToggleGroupDefaultMultiple.tsx"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### With icons
|
|
35
|
+
|
|
36
|
+
You can use a recognizable icon as a toggle item label.
|
|
37
|
+
|
|
38
|
+
To do this, pass an imported icon to the `icon` property of a `<ToggleGroupItem>`.
|
|
39
|
+
|
|
25
40
|
```ts file="./ToggleGroupIcon.tsx"
|
|
26
41
|
```
|
|
27
42
|
|
|
28
|
-
###
|
|
43
|
+
### With text and icons
|
|
44
|
+
|
|
45
|
+
Adding text to a toggle item with an icon helps clarify the button's function.
|
|
46
|
+
|
|
47
|
+
To do this, pass a descriptive label to the `text` property of a `<ToggleGroupItem>`.
|
|
48
|
+
|
|
29
49
|
```ts file="./ToggleGroupTextIcon.tsx"
|
|
30
50
|
```
|
|
31
51
|
|
|
32
|
-
### Compact
|
|
52
|
+
### Compact toggle group
|
|
53
|
+
|
|
54
|
+
When space in a UI is limited, you can use a compact toggle group.
|
|
55
|
+
|
|
56
|
+
To apply compact styling to a `<ToggleGroup>`, use `isCompact`.
|
|
57
|
+
|
|
33
58
|
```ts file="./ToggleGroupCompact.tsx"
|
|
34
|
-
```
|
|
59
|
+
```
|
|
@@ -46,6 +46,14 @@ export interface TreeViewProps {
|
|
|
46
46
|
* internal state.
|
|
47
47
|
*/
|
|
48
48
|
allExpanded?: boolean;
|
|
49
|
+
/** A text string that sets the accessible name of the tree view list. Either this or the aria-labelledby property must
|
|
50
|
+
* be passed in.
|
|
51
|
+
*/
|
|
52
|
+
'aria-label'?: string;
|
|
53
|
+
/** A space separated list of element id's that sets the accessible name of the tree view list. Either
|
|
54
|
+
* this or the aria-label property must be passed in.
|
|
55
|
+
*/
|
|
56
|
+
'aria-labelledby'?: string;
|
|
49
57
|
/** Class to add if not passed a parentItem property. */
|
|
50
58
|
className?: string;
|
|
51
59
|
/** Comparison function for determining active items. */
|
|
@@ -72,6 +80,11 @@ export interface TreeViewProps {
|
|
|
72
80
|
icon?: React.ReactNode;
|
|
73
81
|
/** ID of the tree view. */
|
|
74
82
|
id?: string;
|
|
83
|
+
/** Flag indicating whether multiple nodes can be selected in the tree view. This will also set the
|
|
84
|
+
* aria-multiselectable attribute on the tree view list which is required to be true when multiple selection is intended.
|
|
85
|
+
* Can only be applied to the root tree view list.
|
|
86
|
+
*/
|
|
87
|
+
isMultiSelectable?: boolean;
|
|
75
88
|
/** Callback for item checkbox selection. */
|
|
76
89
|
onCheck?: (event: React.ChangeEvent<HTMLInputElement>, item: TreeViewDataItem, parentItem: TreeViewDataItem) => void;
|
|
77
90
|
/** Callback for item selection. */
|
|
@@ -104,6 +117,7 @@ export const TreeView: React.FunctionComponent<TreeViewProps> = ({
|
|
|
104
117
|
defaultAllExpanded = false,
|
|
105
118
|
allExpanded,
|
|
106
119
|
icon,
|
|
120
|
+
isMultiSelectable = false,
|
|
107
121
|
expandedIcon,
|
|
108
122
|
parentItem,
|
|
109
123
|
onSelect,
|
|
@@ -115,10 +129,18 @@ export const TreeView: React.FunctionComponent<TreeViewProps> = ({
|
|
|
115
129
|
compareItems = (item, itemToCheck) => item.id === itemToCheck.id,
|
|
116
130
|
className,
|
|
117
131
|
useMemo,
|
|
132
|
+
'aria-label': ariaLabel,
|
|
133
|
+
'aria-labelledby': ariaLabelledby,
|
|
118
134
|
...props
|
|
119
135
|
}: TreeViewProps) => {
|
|
120
136
|
const treeViewList = (
|
|
121
|
-
<TreeViewList
|
|
137
|
+
<TreeViewList
|
|
138
|
+
isNested={isNested}
|
|
139
|
+
toolbar={toolbar}
|
|
140
|
+
isMultiSelectable={isMultiSelectable}
|
|
141
|
+
aria-label={ariaLabel}
|
|
142
|
+
aria-labelledby={ariaLabelledby}
|
|
143
|
+
>
|
|
122
144
|
{data.map((item) => (
|
|
123
145
|
<TreeViewListItem
|
|
124
146
|
key={item.id?.toString() || item.name?.toString()}
|
|
@@ -10,12 +10,28 @@ export interface TreeViewListProps extends React.HTMLProps<HTMLUListElement> {
|
|
|
10
10
|
isNested?: boolean;
|
|
11
11
|
/** Toolbar to display above the tree view. */
|
|
12
12
|
toolbar?: React.ReactNode;
|
|
13
|
+
/** Flag indicating whether multiple nodes can be selected in the tree view. This will also set the
|
|
14
|
+
* aria-multiselectable attribute on the tree view list which is required to be true when multiple selection is intended.
|
|
15
|
+
* Can only be applied to the root tree view list.
|
|
16
|
+
*/
|
|
17
|
+
isMultiSelectable?: boolean;
|
|
18
|
+
/** A text string that sets the accessible name of the tree view list. Either this or the aria-labelledby property must
|
|
19
|
+
* be passed in.
|
|
20
|
+
*/
|
|
21
|
+
'aria-label'?: string;
|
|
22
|
+
/** A space separated list of element id's that sets the accessible name of the tree view list. Either
|
|
23
|
+
* this or the aria-label property must be passed in.
|
|
24
|
+
*/
|
|
25
|
+
'aria-labelledby'?: string;
|
|
13
26
|
}
|
|
14
27
|
|
|
15
28
|
export const TreeViewList: React.FunctionComponent<TreeViewListProps> = ({
|
|
16
29
|
isNested = false,
|
|
30
|
+
isMultiSelectable = false,
|
|
17
31
|
toolbar,
|
|
18
32
|
children,
|
|
33
|
+
'aria-label': ariaLabel,
|
|
34
|
+
'aria-labelledby': ariaLabelledby,
|
|
19
35
|
...props
|
|
20
36
|
}: TreeViewListProps) => (
|
|
21
37
|
<>
|
|
@@ -25,7 +41,14 @@ export const TreeViewList: React.FunctionComponent<TreeViewListProps> = ({
|
|
|
25
41
|
<Divider />
|
|
26
42
|
</React.Fragment>
|
|
27
43
|
)}
|
|
28
|
-
<ul
|
|
44
|
+
<ul
|
|
45
|
+
className={css(`${styles.treeView}__list`)}
|
|
46
|
+
role={isNested ? 'group' : 'tree'}
|
|
47
|
+
aria-multiselectable={isNested ? undefined : isMultiSelectable}
|
|
48
|
+
aria-label={ariaLabel}
|
|
49
|
+
aria-labelledby={ariaLabelledby}
|
|
50
|
+
{...props}
|
|
51
|
+
>
|
|
29
52
|
{children}
|
|
30
53
|
</ul>
|
|
31
54
|
</>
|
|
@@ -143,6 +143,8 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
|
|
|
143
143
|
</span>
|
|
144
144
|
</ToggleComponent>
|
|
145
145
|
);
|
|
146
|
+
|
|
147
|
+
const isCheckboxChecked = checkProps.checked === null ? false : checkProps.checked;
|
|
146
148
|
const renderCheck = (randomId: string) => (
|
|
147
149
|
<span className={css(styles.treeViewNodeCheck)}>
|
|
148
150
|
<input
|
|
@@ -151,7 +153,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
|
|
|
151
153
|
onClick={(evt) => evt.stopPropagation()}
|
|
152
154
|
ref={(elem) => elem && (elem.indeterminate = checkProps.checked === null)}
|
|
153
155
|
{...checkProps}
|
|
154
|
-
checked={
|
|
156
|
+
checked={isCheckboxChecked}
|
|
155
157
|
id={randomId}
|
|
156
158
|
tabIndex={-1}
|
|
157
159
|
/>
|
|
@@ -194,6 +196,13 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
|
|
|
194
196
|
)}
|
|
195
197
|
</>
|
|
196
198
|
);
|
|
199
|
+
|
|
200
|
+
const isSelected =
|
|
201
|
+
(!children || isSelectable) &&
|
|
202
|
+
activeItems &&
|
|
203
|
+
activeItems.length > 0 &&
|
|
204
|
+
activeItems.some((item) => compareItems && item && compareItems(item, itemData));
|
|
205
|
+
|
|
197
206
|
return (
|
|
198
207
|
<li
|
|
199
208
|
id={id}
|
|
@@ -201,6 +210,8 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
|
|
|
201
210
|
aria-expanded={internalIsExpanded}
|
|
202
211
|
role="treeitem"
|
|
203
212
|
tabIndex={-1}
|
|
213
|
+
{...(hasCheckbox && { 'aria-checked': isCheckboxChecked })}
|
|
214
|
+
{...(!hasCheckbox && { 'aria-selected': isSelected })}
|
|
204
215
|
>
|
|
205
216
|
<div className={css(styles.treeViewContent)}>
|
|
206
217
|
<GenerateId prefix={isSelectable ? 'selectable-id' : 'checkbox-id'}>
|
|
@@ -209,12 +220,7 @@ const TreeViewListItemBase: React.FunctionComponent<TreeViewListItemProps> = ({
|
|
|
209
220
|
className={css(
|
|
210
221
|
styles.treeViewNode,
|
|
211
222
|
children && (isSelectable || hasCheckbox) && styles.modifiers.selectable,
|
|
212
|
-
|
|
213
|
-
activeItems &&
|
|
214
|
-
activeItems.length > 0 &&
|
|
215
|
-
activeItems.some((item) => compareItems && item && compareItems(item, itemData))
|
|
216
|
-
? styles.modifiers.current
|
|
217
|
-
: ''
|
|
223
|
+
isSelected && styles.modifiers.current
|
|
218
224
|
)}
|
|
219
225
|
onClick={(evt: React.MouseEvent) => {
|
|
220
226
|
if (!hasCheckbox) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports[`Matches snapshot by default 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<ul
|
|
6
|
+
aria-multiselectable="false"
|
|
6
7
|
class="pf-v5-c-tree-view__list"
|
|
7
8
|
role="tree"
|
|
8
9
|
>
|
|
@@ -20,6 +21,7 @@ exports[`Matches snapshot when toolbar is passed 1`] = `
|
|
|
20
21
|
class="pf-v5-c-divider"
|
|
21
22
|
/>
|
|
22
23
|
<ul
|
|
24
|
+
aria-multiselectable="false"
|
|
23
25
|
class="pf-v5-c-tree-view__list"
|
|
24
26
|
role="tree"
|
|
25
27
|
>
|
|
@@ -4,6 +4,7 @@ exports[`Matches snapshot with children 1`] = `
|
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<li
|
|
6
6
|
aria-expanded="false"
|
|
7
|
+
aria-selected="false"
|
|
7
8
|
class="pf-v5-c-tree-view__list-item"
|
|
8
9
|
role="treeitem"
|
|
9
10
|
tabindex="-1"
|
|
@@ -56,6 +57,7 @@ exports[`Matches snapshot without children 1`] = `
|
|
|
56
57
|
<DocumentFragment>
|
|
57
58
|
<li
|
|
58
59
|
aria-expanded="false"
|
|
60
|
+
aria-selected="false"
|
|
59
61
|
class="pf-v5-c-tree-view__list-item"
|
|
60
62
|
role="treeitem"
|
|
61
63
|
tabindex="-1"
|
|
@@ -9,9 +9,17 @@ import { FolderIcon, FolderOpenIcon, EllipsisVIcon, ClipboardIcon, HamburgerIcon
|
|
|
9
9
|
|
|
10
10
|
## Examples
|
|
11
11
|
|
|
12
|
-
###
|
|
12
|
+
### Single selectable
|
|
13
13
|
|
|
14
|
-
```ts file='./
|
|
14
|
+
```ts file='./TreeViewSingleSelectable.tsx'
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Multiselectable
|
|
19
|
+
|
|
20
|
+
A tree view can be setup to allow multiple nodes to be selected. When a tree view is intended to allow multiple selection, the `isMultiSelectable` property must be passed.
|
|
21
|
+
|
|
22
|
+
```ts file='./TreeViewMultiselectable.tsx'
|
|
15
23
|
|
|
16
24
|
```
|
|
17
25
|
|
|
@@ -25,6 +33,8 @@ The `hasSelectableNodes` modifier will separate the expansion and selection beha
|
|
|
25
33
|
|
|
26
34
|
### With search
|
|
27
35
|
|
|
36
|
+
A search input can be used to filter tree view items. It is recommended that a tree view with more than 7 nodes includes a search input.
|
|
37
|
+
|
|
28
38
|
```ts file='./TreeViewWithSearch.tsx'
|
|
29
39
|
|
|
30
40
|
```
|
|
@@ -55,5 +55,5 @@ export const TreeViewCompactNoBackground: React.FunctionComponent = () => {
|
|
|
55
55
|
]
|
|
56
56
|
}
|
|
57
57
|
];
|
|
58
|
-
return <TreeView data={options} variant="compactNoBackground" />;
|
|
58
|
+
return <TreeView aria-label="Tree View compact no background example" data={options} variant="compactNoBackground" />;
|
|
59
59
|
};
|
|
@@ -61,5 +61,5 @@ export const GuidesTreeView: React.FunctionComponent = () => {
|
|
|
61
61
|
children: [{ name: 'Application 5', id: 'example8-App5' }]
|
|
62
62
|
}
|
|
63
63
|
];
|
|
64
|
-
return <TreeView data={options} hasGuides={true} />;
|
|
64
|
+
return <TreeView aria-label="Tree View guides example" data={options} hasGuides={true} />;
|
|
65
65
|
};
|