@hitachivantara/uikit-react-core 6.8.1 → 6.9.0
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/dist/Accordion/Accordion.js +69 -80
- package/dist/Accordion/Accordion.styles.js +21 -16
- package/dist/ActionBar/ActionBar.js +18 -17
- package/dist/ActionBar/ActionBar.styles.js +12 -15
- package/dist/ActionsGeneric/ActionsGeneric.js +72 -98
- package/dist/ActionsGeneric/ActionsGeneric.styles.js +17 -14
- package/dist/AppSwitcher/Action/Action.js +96 -111
- package/dist/AppSwitcher/Action/Action.styles.js +44 -48
- package/dist/AppSwitcher/AppSwitcher.js +70 -98
- package/dist/AppSwitcher/AppSwitcher.styles.js +50 -53
- package/dist/Avatar/Avatar.js +66 -111
- package/dist/Avatar/Avatar.styles.js +62 -52
- package/dist/AvatarGroup/AvatarGroup.js +49 -78
- package/dist/AvatarGroup/AvatarGroup.styles.js +40 -60
- package/dist/AvatarGroup/AvatarGroupContext.js +13 -16
- package/dist/Badge/Badge.js +40 -47
- package/dist/Badge/Badge.styles.js +50 -44
- package/dist/Banner/Banner.js +51 -83
- package/dist/Banner/Banner.styles.js +13 -22
- package/dist/Banner/BannerContent/BannerContent.js +35 -56
- package/dist/Banner/BannerContent/BannerContent.styles.js +31 -36
- package/dist/BaseCheckBox/BaseCheckBox.js +71 -88
- package/dist/BaseCheckBox/BaseCheckBox.styles.js +24 -31
- package/dist/BaseCheckBox/CheckBoxIcon.js +57 -73
- package/dist/BaseDropdown/BaseDropdown.js +147 -189
- package/dist/BaseDropdown/BaseDropdown.styles.js +72 -84
- package/dist/BaseDropdown/BaseDropdownPanel.js +69 -86
- package/dist/BaseDropdown/utils.js +77 -76
- package/dist/BaseInput/BaseInput.js +53 -89
- package/dist/BaseInput/BaseInput.styles.js +85 -105
- package/dist/BaseInput/validations.js +72 -69
- package/dist/BaseRadio/BaseRadio.js +61 -85
- package/dist/BaseRadio/BaseRadio.styles.js +26 -31
- package/dist/BaseRadio/RadioIcon.js +43 -48
- package/dist/BaseSwitch/BaseSwitch.js +70 -108
- package/dist/BaseSwitch/BaseSwitch.styles.js +94 -113
- package/dist/BreadCrumb/BreadCrumb.js +84 -106
- package/dist/BreadCrumb/BreadCrumb.styles.js +20 -17
- package/dist/BreadCrumb/Page/Page.js +24 -34
- package/dist/BreadCrumb/Page/Page.styles.js +20 -25
- package/dist/BreadCrumb/PathElement/PathElement.js +17 -17
- package/dist/BreadCrumb/PathElement/PathElement.styles.js +9 -7
- package/dist/BreadCrumb/utils.js +19 -27
- package/dist/BulkActions/BulkActions.js +57 -96
- package/dist/BulkActions/BulkActions.styles.js +37 -45
- package/dist/Button/Button.js +67 -95
- package/dist/Button/Button.styles.js +107 -124
- package/dist/ButtonBase/ButtonBase.js +32 -51
- package/dist/ButtonBase/ButtonBase.styles.js +21 -30
- package/dist/Calendar/Calendar.js +73 -101
- package/dist/Calendar/Calendar.styles.js +14 -32
- package/dist/Calendar/CalendarHeader/CalendarHeader.js +91 -118
- package/dist/Calendar/CalendarHeader/CalendarHeader.styles.js +11 -16
- package/dist/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.js +36 -50
- package/dist/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.styles.js +12 -18
- package/dist/Calendar/CalendarNavigation/MonthSelector/MonthSelector.js +23 -43
- package/dist/Calendar/CalendarNavigation/MonthSelector/MonthSelector.styles.js +21 -24
- package/dist/Calendar/CalendarNavigation/Navigation/Navigation.js +43 -59
- package/dist/Calendar/CalendarNavigation/Navigation/Navigation.styles.js +21 -24
- package/dist/Calendar/SingleCalendar/CalendarCell.js +60 -84
- package/dist/Calendar/SingleCalendar/CalendarCell.styles.js +39 -56
- package/dist/Calendar/SingleCalendar/SingleCalendar.js +121 -154
- package/dist/Calendar/SingleCalendar/SingleCalendar.styles.js +53 -68
- package/dist/Calendar/model.js +45 -62
- package/dist/Calendar/utils.js +233 -128
- package/dist/Card/Card.js +35 -53
- package/dist/Card/Card.styles.js +37 -50
- package/dist/Card/Content/Content.js +15 -27
- package/dist/Card/Content/Content.styles.js +5 -10
- package/dist/Card/Header/Header.js +22 -35
- package/dist/Card/Header/Header.styles.js +22 -25
- package/dist/Card/Media/Media.js +16 -26
- package/dist/Card/Media/Media.styles.js +6 -7
- package/dist/Carousel/Carousel.js +179 -207
- package/dist/Carousel/Carousel.styles.js +141 -166
- package/dist/Carousel/CarouselControls.js +48 -62
- package/dist/Carousel/CarouselSlide/CarouselSlide.js +19 -25
- package/dist/Carousel/CarouselSlide/CarouselSlide.styles.js +10 -11
- package/dist/Carousel/CarouselThumbnails.js +29 -36
- package/dist/CheckBox/CheckBox.js +112 -182
- package/dist/CheckBox/CheckBox.styles.js +48 -57
- package/dist/CheckBoxGroup/CheckBoxGroup.js +154 -245
- package/dist/CheckBoxGroup/CheckBoxGroup.styles.js +29 -35
- package/dist/ColorPicker/ColorPicker.js +146 -222
- package/dist/ColorPicker/ColorPicker.styles.js +40 -45
- package/dist/ColorPicker/Picker/Fields.js +125 -141
- package/dist/ColorPicker/Picker/Picker.js +51 -50
- package/dist/ColorPicker/Picker/Picker.styles.js +42 -42
- package/dist/ColorPicker/PresetColors/PresetColors.js +25 -28
- package/dist/ColorPicker/PresetColors/PresetColors.styles.js +17 -17
- package/dist/ColorPicker/SavedColors/SavedColors.js +37 -41
- package/dist/ColorPicker/SavedColors/SavedColors.styles.js +27 -29
- package/dist/ColorPicker/Swatch.js +22 -37
- package/dist/Container/Container.js +37 -58
- package/dist/Container/Container.styles.js +12 -13
- package/dist/Controls/Controls.js +50 -74
- package/dist/Controls/Controls.styles.js +16 -13
- package/dist/Controls/LeftControl/LeftControl.js +25 -38
- package/dist/Controls/LeftControl/LeftControl.styles.js +7 -7
- package/dist/Controls/RightControl/RightControl.js +31 -46
- package/dist/Controls/RightControl/RightControl.styles.js +9 -7
- package/dist/Controls/context/ControlsContext.js +5 -6
- package/dist/DatePicker/DatePicker.js +286 -339
- package/dist/DatePicker/DatePicker.styles.js +25 -40
- package/dist/DatePicker/useVisibleDate.js +142 -126
- package/dist/DatePicker/utils.js +17 -26
- package/dist/Dialog/Actions/Actions.js +19 -29
- package/dist/Dialog/Actions/Actions.styles.js +20 -20
- package/dist/Dialog/Content/Content.js +29 -46
- package/dist/Dialog/Content/Content.styles.js +14 -15
- package/dist/Dialog/Dialog.js +49 -69
- package/dist/Dialog/Dialog.styles.js +33 -46
- package/dist/Dialog/Title/Title.js +20 -42
- package/dist/Dialog/Title/Title.styles.js +14 -16
- package/dist/Dialog/context.js +5 -6
- package/dist/DotPagination/DotPagination.js +44 -59
- package/dist/DotPagination/DotPagination.styles.js +44 -47
- package/dist/Drawer/Drawer.js +37 -64
- package/dist/Drawer/Drawer.styles.js +18 -21
- package/dist/DropDownMenu/DropDownMenu.js +88 -124
- package/dist/DropDownMenu/DropDownMenu.styles.js +12 -21
- package/dist/Dropdown/Dropdown.js +221 -310
- package/dist/Dropdown/Dropdown.styles.js +39 -48
- package/dist/Dropdown/List/List.js +194 -176
- package/dist/Dropdown/List/List.styles.js +23 -24
- package/dist/Dropdown/utils.js +15 -16
- package/dist/DropdownButton/DropdownButton.js +42 -46
- package/dist/DropdownButton/DropdownButton.styles.js +37 -47
- package/dist/EmptyState/EmptyState.js +48 -61
- package/dist/EmptyState/EmptyState.styles.js +31 -31
- package/dist/FileUploader/DropZone/DropZone.js +141 -179
- package/dist/FileUploader/DropZone/DropZone.styles.js +55 -68
- package/dist/FileUploader/File/File.js +85 -75
- package/dist/FileUploader/File/File.styles.js +55 -60
- package/dist/FileUploader/FileList/FileList.js +19 -28
- package/dist/FileUploader/FileList/FileList.styles.js +15 -16
- package/dist/FileUploader/FileUploader.js +35 -55
- package/dist/FileUploader/FileUploader.styles.js +4 -7
- package/dist/FileUploader/Preview/Preview.js +37 -52
- package/dist/FileUploader/Preview/Preview.styles.js +22 -28
- package/dist/FileUploader/utils.js +24 -11
- package/dist/FilterGroup/Counter/Counter.js +31 -43
- package/dist/FilterGroup/Counter/Counter.styles.js +12 -15
- package/dist/FilterGroup/FilterContent/FilterContent.js +138 -177
- package/dist/FilterGroup/FilterContent/FilterContent.styles.js +46 -53
- package/dist/FilterGroup/FilterContent/HeaderButton.js +77 -100
- package/dist/FilterGroup/FilterGroup.js +87 -136
- package/dist/FilterGroup/FilterGroup.styles.js +9 -10
- package/dist/FilterGroup/FilterGroupContext.js +68 -73
- package/dist/FilterGroup/LeftPanel/LeftPanel.js +28 -31
- package/dist/FilterGroup/LeftPanel/LeftPanel.styles.js +6 -11
- package/dist/FilterGroup/RightPanel/RightPanel.js +118 -151
- package/dist/FilterGroup/RightPanel/RightPanel.styles.js +17 -27
- package/dist/Focus/Focus.js +248 -344
- package/dist/Focus/Focus.styles.js +28 -39
- package/dist/Focus/utils.js +14 -20
- package/dist/Footer/Footer.js +36 -38
- package/dist/Footer/Footer.styles.js +40 -43
- package/dist/FormElement/Adornment/Adornment.js +38 -49
- package/dist/FormElement/Adornment/Adornment.styles.js +14 -15
- package/dist/FormElement/CharCounter/CharCounter.js +51 -73
- package/dist/FormElement/CharCounter/CharCounter.styles.js +12 -10
- package/dist/FormElement/FormElement.js +53 -31
- package/dist/FormElement/FormElement.styles.js +4 -7
- package/dist/FormElement/InfoMessage/InfoMessage.js +26 -41
- package/dist/FormElement/InfoMessage/InfoMessage.styles.js +11 -9
- package/dist/FormElement/Label/Label.js +33 -56
- package/dist/FormElement/Label/Label.styles.js +11 -9
- package/dist/FormElement/LabelContainer.js +46 -55
- package/dist/FormElement/Suggestions/Suggestions.js +46 -71
- package/dist/FormElement/Suggestions/Suggestions.styles.js +9 -16
- package/dist/FormElement/WarningText/WarningText.js +41 -62
- package/dist/FormElement/WarningText/WarningText.styles.js +25 -28
- package/dist/FormElement/context.js +6 -10
- package/dist/FormElement/utils.js +54 -58
- package/dist/GlobalActions/GlobalActions.js +53 -59
- package/dist/GlobalActions/GlobalActions.styles.js +67 -76
- package/dist/Grid/Grid.js +82 -112
- package/dist/Grid/Grid.styles.js +37 -38
- package/dist/Header/Actions/Actions.js +15 -17
- package/dist/Header/Actions/Actions.styles.js +12 -15
- package/dist/Header/Brand/Brand.js +27 -23
- package/dist/Header/Brand/Brand.styles.js +16 -14
- package/dist/Header/Header.js +22 -31
- package/dist/Header/Header.styles.js +32 -30
- package/dist/Header/Navigation/MenuBar/Bar.js +23 -36
- package/dist/Header/Navigation/MenuBar/Bar.styles.js +54 -61
- package/dist/Header/Navigation/MenuBar/MenuBar.js +20 -26
- package/dist/Header/Navigation/MenuItem/MenuItem.js +104 -120
- package/dist/Header/Navigation/MenuItem/MenuItem.styles.js +48 -63
- package/dist/Header/Navigation/Navigation.js +32 -37
- package/dist/Header/Navigation/Navigation.styles.js +11 -17
- package/dist/Header/Navigation/useSelectionPath.js +17 -20
- package/dist/Header/Navigation/utils/FocusContext.js +23 -20
- package/dist/Header/Navigation/utils/SelectionContext.js +4 -4
- package/dist/IconButton/IconButton.js +25 -32
- package/dist/IconContainer/IconContainer.js +55 -76
- package/dist/InlineEditor/InlineEditor.js +105 -131
- package/dist/InlineEditor/InlineEditor.styles.js +44 -53
- package/dist/Input/Input.js +385 -461
- package/dist/Input/Input.styles.js +34 -47
- package/dist/Input/icons.js +16 -21
- package/dist/Input/utils.js +8 -11
- package/dist/List/List.js +196 -247
- package/dist/List/List.styles.js +44 -49
- package/dist/List/useSelectableList.js +11 -8
- package/dist/List/utils.js +24 -33
- package/dist/ListContainer/ListContainer.js +52 -65
- package/dist/ListContainer/ListContainer.styles.js +7 -10
- package/dist/ListContainer/ListContext/ListContext.js +4 -4
- package/dist/ListContainer/ListItem/ListItem.js +79 -117
- package/dist/ListContainer/ListItem/ListItem.styles.js +57 -78
- package/dist/Loading/Loading.js +31 -46
- package/dist/Loading/Loading.styles.js +41 -48
- package/dist/LoadingContainer/LoadingContainer.js +34 -40
- package/dist/LoadingContainer/LoadingContainer.styles.js +17 -18
- package/dist/Login/Login.js +22 -29
- package/dist/Login/Login.styles.js +20 -21
- package/dist/MultiButton/MultiButton.js +41 -59
- package/dist/MultiButton/MultiButton.styles.js +117 -137
- package/dist/NumberInput/NumberInput.js +51 -50
- package/dist/NumberInput/NumberInput.styles.js +5 -10
- package/dist/OverflowTooltip/OverflowTooltip.js +55 -75
- package/dist/OverflowTooltip/OverflowTooltip.styles.js +19 -23
- package/dist/Pagination/Pagination.js +176 -164
- package/dist/Pagination/Pagination.styles.js +86 -90
- package/dist/Pagination/Select.js +51 -60
- package/dist/Pagination/Select.styles.js +13 -19
- package/dist/Panel/Panel.js +19 -20
- package/dist/Panel/Panel.styles.js +12 -15
- package/dist/ProgressBar/ProgressBar.js +40 -53
- package/dist/ProgressBar/ProgressBar.styles.js +28 -40
- package/dist/QueryBuilder/ConfirmationDialog.js +35 -28
- package/dist/QueryBuilder/Context.js +308 -322
- package/dist/QueryBuilder/QueryBuilder.js +108 -137
- package/dist/QueryBuilder/QueryBuilder.styles.js +117 -108
- package/dist/QueryBuilder/Rule/Attribute.js +56 -62
- package/dist/QueryBuilder/Rule/Operator.js +53 -57
- package/dist/QueryBuilder/Rule/Rule.js +70 -96
- package/dist/QueryBuilder/Rule/Rule.styles.js +49 -54
- package/dist/QueryBuilder/RuleGroup.js +160 -206
- package/dist/QueryBuilder/Value/BooleanValue.js +38 -37
- package/dist/QueryBuilder/Value/DateTimeValue.js +233 -299
- package/dist/QueryBuilder/Value/EmptyValue.js +14 -14
- package/dist/QueryBuilder/Value/NumericValue.js +152 -204
- package/dist/QueryBuilder/Value/TextValue.js +38 -54
- package/dist/QueryBuilder/Value/Value.js +42 -67
- package/dist/QueryBuilder/types.js +4 -4
- package/dist/QueryBuilder/utils/index.js +40 -74
- package/dist/QueryBuilder/utils/reducer.js +86 -92
- package/dist/Radio/Radio.js +96 -145
- package/dist/Radio/Radio.styles.js +47 -55
- package/dist/RadioGroup/RadioGroup.js +98 -159
- package/dist/RadioGroup/RadioGroup.styles.js +28 -34
- package/dist/ScrollToHorizontal/HorizontalScrollListItem/HorizontalScrollListItem.js +34 -51
- package/dist/ScrollToHorizontal/HorizontalScrollListItem/HorizontalScrollListItem.styles.js +39 -48
- package/dist/ScrollToHorizontal/ScrollToHorizontal.js +56 -91
- package/dist/ScrollToHorizontal/ScrollToHorizontal.styles.js +28 -32
- package/dist/ScrollToVertical/ScrollToVertical.js +45 -77
- package/dist/ScrollToVertical/ScrollToVertical.styles.js +31 -38
- package/dist/ScrollToVertical/VerticalScrollListItem/VerticalScrollListItem.js +30 -39
- package/dist/ScrollToVertical/VerticalScrollListItem/VerticalScrollListItem.styles.js +44 -51
- package/dist/SearchInput/SearchInput.js +27 -25
- package/dist/SearchInput/SearchInput.styles.js +6 -7
- package/dist/Section/Section.js +69 -104
- package/dist/Section/Section.styles.js +53 -57
- package/dist/Select/Option.js +29 -46
- package/dist/Select/OptionGroup.js +18 -30
- package/dist/Select/Select.js +163 -219
- package/dist/Select/Select.styles.js +26 -32
- package/dist/SelectionList/SelectionList.js +162 -216
- package/dist/SelectionList/SelectionList.styles.js +36 -36
- package/dist/SimpleGrid/SimpleGrid.js +16 -27
- package/dist/SimpleGrid/SimpleGrid.styles.js +28 -39
- package/dist/Skeleton/Skeleton.js +26 -44
- package/dist/Skeleton/Skeleton.styles.js +43 -66
- package/dist/Slider/Slider.js +316 -431
- package/dist/Slider/Slider.styles.js +183 -216
- package/dist/Slider/SliderInput/SliderInput.js +38 -57
- package/dist/Slider/SliderInput/SliderInput.styles.js +13 -14
- package/dist/Slider/base.js +221 -243
- package/dist/Slider/utils.js +247 -233
- package/dist/Snackbar/Snackbar.js +59 -88
- package/dist/Snackbar/Snackbar.styles.js +25 -42
- package/dist/Snackbar/SnackbarContent/SnackbarContent.js +31 -50
- package/dist/Snackbar/SnackbarContent/SnackbarContent.styles.js +27 -30
- package/dist/SnackbarProvider/SnackbarProvider.js +73 -105
- package/dist/SnackbarProvider/SnackbarProvider.styles.js +20 -26
- package/dist/Stack/Stack.js +74 -84
- package/dist/Stack/Stack.styles.js +14 -33
- package/dist/StatusIcon/StatusIcon.js +78 -102
- package/dist/StatusIcon/StatusIcon.styles.js +42 -52
- package/dist/Switch/Switch.js +91 -138
- package/dist/Switch/Switch.styles.js +49 -60
- package/dist/Table/Table.js +62 -66
- package/dist/Table/Table.styles.js +23 -28
- package/dist/Table/TableBody/TableBody.js +45 -56
- package/dist/Table/TableBody/TableBody.styles.js +8 -7
- package/dist/Table/TableCell/TableCell.js +37 -66
- package/dist/Table/TableCell/TableCell.styles.js +125 -162
- package/dist/Table/TableContainer/TableContainer.js +18 -28
- package/dist/Table/TableContainer/TableContainer.styles.js +8 -12
- package/dist/Table/TableContext.js +4 -4
- package/dist/Table/TableHead/TableHead.js +27 -39
- package/dist/Table/TableHead/TableHead.styles.js +10 -7
- package/dist/Table/TableHeader/TableHeader.js +73 -124
- package/dist/Table/TableHeader/TableHeader.styles.js +135 -150
- package/dist/Table/TableHeader/utils.js +11 -15
- package/dist/Table/TableRow/TableRow.js +32 -51
- package/dist/Table/TableRow/TableRow.styles.js +64 -84
- package/dist/Table/TableSection/TableSection.js +21 -20
- package/dist/Table/TableSection/TableSection.styles.js +63 -96
- package/dist/Table/TableSectionContext.js +4 -4
- package/dist/Table/hooks/useHvBulkActions.js +54 -89
- package/dist/Table/hooks/useHvFilters.js +4 -4
- package/dist/Table/hooks/useHvGlobalFilter.js +4 -4
- package/dist/Table/hooks/useHvHeaderGroups.js +73 -82
- package/dist/Table/hooks/useHvPagination.js +31 -51
- package/dist/Table/hooks/useHvResizeColumns.js +25 -31
- package/dist/Table/hooks/useHvRowExpand.js +54 -69
- package/dist/Table/hooks/useHvRowSelection.js +294 -420
- package/dist/Table/hooks/useHvRowState.js +4 -4
- package/dist/Table/hooks/useHvSortBy.js +23 -30
- package/dist/Table/hooks/useHvSticky.js +114 -154
- package/dist/Table/hooks/useHvTable.js +40 -64
- package/dist/Table/hooks/useHvTableStyles.js +51 -82
- package/dist/Table/renderers/DateColumnCell.js +12 -13
- package/dist/Table/renderers/DefaultCell.js +13 -20
- package/dist/Table/renderers/DropdownColumnCell.js +4 -4
- package/dist/Table/renderers/ProgressColumnCell.js +43 -47
- package/dist/Table/renderers/SwitchColumnCell.js +37 -50
- package/dist/Table/renderers/renderers.js +146 -183
- package/dist/Tabs/Tab/Tab.js +21 -31
- package/dist/Tabs/Tab/Tab.styles.js +44 -54
- package/dist/Tabs/Tabs.js +23 -28
- package/dist/Tabs/Tabs.styles.js +9 -14
- package/dist/Tag/Tag.js +86 -129
- package/dist/Tag/Tag.styles.js +63 -88
- package/dist/TagsInput/TagsInput.js +349 -417
- package/dist/TagsInput/TagsInput.styles.js +77 -90
- package/dist/TextArea/TextArea.js +207 -274
- package/dist/TextArea/TextArea.styles.js +25 -20
- package/dist/TimeAgo/TimeAgo.js +24 -30
- package/dist/TimeAgo/TimeAgo.styles.js +4 -7
- package/dist/TimeAgo/formatUtils.js +57 -65
- package/dist/TimeAgo/useTimeAgo.js +18 -18
- package/dist/TimeAgo/useTimeout.js +14 -14
- package/dist/TimePicker/Placeholder.js +46 -52
- package/dist/TimePicker/TimePicker.js +164 -214
- package/dist/TimePicker/TimePicker.styles.js +30 -39
- package/dist/TimePicker/Unit/Unit.js +63 -49
- package/dist/TimePicker/Unit/Unit.styles.js +41 -46
- package/dist/ToggleButton/ToggleButton.js +25 -34
- package/dist/Tooltip/Tooltip.js +41 -51
- package/dist/Tooltip/Tooltip.styles.js +25 -26
- package/dist/TreeView/TreeItem/DefaultContent.js +51 -72
- package/dist/TreeView/TreeItem/TreeItem.js +102 -140
- package/dist/TreeView/TreeItem/TreeItem.styles.js +56 -70
- package/dist/TreeView/TreeItem/useHvTreeItem.js +38 -53
- package/dist/TreeView/TreeView.js +65 -62
- package/dist/TreeView/TreeView.styles.js +11 -13
- package/dist/TreeView/internals/DescendantProvider.js +120 -120
- package/dist/TreeView/internals/TreeViewProvider.js +32 -26
- package/dist/TreeView/internals/corePlugins.js +8 -4
- package/dist/TreeView/internals/hooks/plugins/defaultPlugins.js +10 -10
- package/dist/TreeView/internals/hooks/plugins/useTreeViewContextValueBuilder.js +20 -22
- package/dist/TreeView/internals/hooks/plugins/useTreeViewExpansion.js +39 -61
- package/dist/TreeView/internals/hooks/plugins/useTreeViewFocus.js +56 -80
- package/dist/TreeView/internals/hooks/plugins/useTreeViewKeyboardNavigation.js +149 -211
- package/dist/TreeView/internals/hooks/plugins/useTreeViewNodes.js +42 -68
- package/dist/TreeView/internals/hooks/plugins/useTreeViewSelection.js +162 -195
- package/dist/TreeView/internals/hooks/useInstanceEventHandler.js +52 -74
- package/dist/TreeView/internals/hooks/useTreeView.js +54 -69
- package/dist/TreeView/internals/hooks/useTreeViewInstanceEvents.js +28 -33
- package/dist/TreeView/internals/hooks/useTreeViewModels.js +34 -43
- package/dist/TreeView/internals/hooks/utils.js +28 -42
- package/dist/TreeView/internals/utils/EventManager.js +49 -58
- package/dist/TreeView/internals/utils/FinalizationRegistryBasedCleanupTracking.js +14 -18
- package/dist/TreeView/internals/utils/TimerBasedCleanupTracking.js +33 -37
- package/dist/TreeView/internals/utils/publishTreeViewEvent.js +5 -5
- package/dist/Typography/Typography.js +34 -51
- package/dist/Typography/Typography.styles.js +20 -23
- package/dist/VerticalNavigation/Actions/Action.js +23 -42
- package/dist/VerticalNavigation/Actions/Action.styles.js +21 -28
- package/dist/VerticalNavigation/Actions/Actions.js +15 -31
- package/dist/VerticalNavigation/Actions/Actions.styles.js +13 -19
- package/dist/VerticalNavigation/Header/Header.js +51 -91
- package/dist/VerticalNavigation/Header/Header.styles.js +22 -32
- package/dist/VerticalNavigation/Navigation/Navigation.js +183 -267
- package/dist/VerticalNavigation/Navigation/Navigation.styles.js +14 -24
- package/dist/VerticalNavigation/NavigationPopup/NavigationPopup.styles.js +9 -17
- package/dist/VerticalNavigation/NavigationPopup/NavigationPopupContainer.js +30 -32
- package/dist/VerticalNavigation/NavigationSlider/NavigationSlider.js +45 -63
- package/dist/VerticalNavigation/NavigationSlider/NavigationSlider.styles.js +23 -33
- package/dist/VerticalNavigation/NavigationSlider/utils.js +56 -39
- package/dist/VerticalNavigation/TreeView/TreeView.js +515 -664
- package/dist/VerticalNavigation/TreeView/TreeView.styles.js +10 -16
- package/dist/VerticalNavigation/TreeView/TreeViewContext.js +5 -6
- package/dist/VerticalNavigation/TreeView/TreeViewItem.js +319 -414
- package/dist/VerticalNavigation/TreeView/TreeViewItem.styles.js +91 -143
- package/dist/VerticalNavigation/VerticalNavigation.js +70 -97
- package/dist/VerticalNavigation/VerticalNavigation.styles.js +31 -45
- package/dist/VerticalNavigation/VerticalNavigationContext.js +8 -10
- package/dist/hooks/useClickOutside.js +21 -23
- package/dist/hooks/useComputation.js +13 -13
- package/dist/hooks/useControlled.js +10 -17
- package/dist/hooks/useEnhancedEffect.js +5 -5
- package/dist/hooks/useExpandable.js +24 -31
- package/dist/hooks/useFocus.js +31 -34
- package/dist/hooks/useForkRef.js +19 -19
- package/dist/hooks/useImageLoaded.js +26 -26
- package/dist/hooks/useIsMounted.js +13 -13
- package/dist/hooks/useLabels.js +7 -7
- package/dist/hooks/useScrollTo.js +101 -130
- package/dist/hooks/useUniqueId.js +6 -6
- package/dist/hooks/useWidth.js +10 -13
- package/dist/icons.js +77 -88
- package/dist/index.d.ts +8 -8
- package/dist/index.js +226 -554
- package/dist/providers/Provider.js +44 -75
- package/dist/providers/ThemeProvider.js +79 -71
- package/dist/providers/utils.js +40 -47
- package/dist/themes/index.js +6 -5
- package/dist/themes/next.js +132 -271
- package/dist/themes/pentaho.js +832 -1173
- package/dist/types/generic.js +5 -4
- package/dist/utils/Callout.js +123 -171
- package/dist/utils/CounterLabel.js +14 -15
- package/dist/utils/deepMerge.js +13 -15
- package/dist/utils/document.js +8 -8
- package/dist/utils/focusUtils.js +6 -7
- package/dist/utils/focusableElementFinder.js +23 -26
- package/dist/utils/helpers.js +15 -23
- package/dist/utils/iconVariant.js +15 -12
- package/dist/utils/keyboardUtils.js +28 -28
- package/dist/utils/multiSelectionEventHandler.js +37 -52
- package/dist/utils/scroll.js +50 -76
- package/dist/utils/setId.js +4 -4
- package/dist/utils/theme.js +11 -8
- package/dist/utils/useSavedState.js +19 -16
- package/package.json +5 -5
|
@@ -1,676 +1,527 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useRef, useState, useCallback, useMemo } from "react";
|
|
3
|
-
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
4
|
-
import { useControlled } from "../../hooks/useControlled.js";
|
|
5
1
|
import { useForkRef } from "../../hooks/useForkRef.js";
|
|
6
2
|
import { useUniqueId } from "../../hooks/useUniqueId.js";
|
|
3
|
+
import { useControlled } from "../../hooks/useControlled.js";
|
|
7
4
|
import { DescendantProvider } from "../../TreeView/internals/DescendantProvider.js";
|
|
8
5
|
import { useClasses } from "./TreeView.styles.js";
|
|
9
|
-
import { staticClasses } from "./TreeView.styles.js";
|
|
10
6
|
import { TreeViewControlContext, TreeViewStateContext } from "./TreeViewContext.js";
|
|
7
|
+
import { useDefaultProps } from "@hitachivantara/uikit-react-utils";
|
|
8
|
+
import { forwardRef, useCallback, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
//#region src/VerticalNavigation/TreeView/TreeView.tsx
|
|
11
11
|
function isPrintableCharacter(string) {
|
|
12
|
-
|
|
12
|
+
return string && string.length === 1 && string.match(/\S/);
|
|
13
13
|
}
|
|
14
14
|
function findNextFirstChar(firstChars, startIndex, char) {
|
|
15
|
-
|
|
15
|
+
return firstChars.slice(startIndex).findIndex((c) => c === char);
|
|
16
16
|
}
|
|
17
17
|
function noopSelection() {
|
|
18
|
-
|
|
18
|
+
return false;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
526
|
-
event.stopPropagation();
|
|
527
|
-
break;
|
|
528
|
-
case "Enter":
|
|
529
|
-
if (!isDisabled(focusedNodeId)) {
|
|
530
|
-
if (isExpandable(focusedNodeId)) {
|
|
531
|
-
toggleExpansion(event);
|
|
532
|
-
flag = true;
|
|
533
|
-
} else if (isSelectable(focusedNodeId)) {
|
|
534
|
-
if (multiSelect && event.shiftKey) {
|
|
535
|
-
selectRange(event, { end: focusedNodeId });
|
|
536
|
-
flag = true;
|
|
537
|
-
} else if (multiSelect) {
|
|
538
|
-
flag = selectNode(event, focusedNodeId, true);
|
|
539
|
-
} else {
|
|
540
|
-
flag = selectNode(event, focusedNodeId);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
event.stopPropagation();
|
|
545
|
-
break;
|
|
546
|
-
case "ArrowDown":
|
|
547
|
-
if (multiSelect && event.shiftKey) {
|
|
548
|
-
selectNextNode(event, focusedNodeId);
|
|
549
|
-
}
|
|
550
|
-
focusNextNode(event, focusedNodeId);
|
|
551
|
-
flag = true;
|
|
552
|
-
break;
|
|
553
|
-
case "ArrowUp":
|
|
554
|
-
if (multiSelect && event.shiftKey) {
|
|
555
|
-
selectPreviousNode(event, focusedNodeId);
|
|
556
|
-
}
|
|
557
|
-
focusPreviousNode(event, focusedNodeId);
|
|
558
|
-
flag = true;
|
|
559
|
-
break;
|
|
560
|
-
case "ArrowRight":
|
|
561
|
-
flag = handleNextArrow(event);
|
|
562
|
-
break;
|
|
563
|
-
case "ArrowLeft":
|
|
564
|
-
flag = handlePreviousArrow(event);
|
|
565
|
-
break;
|
|
566
|
-
case "Home":
|
|
567
|
-
if (multiSelect && ctrlPressed && event.shiftKey && !isDisabled(focusedNodeId)) {
|
|
568
|
-
rangeSelectToFirst(event, focusedNodeId);
|
|
569
|
-
}
|
|
570
|
-
focusFirstNode(event);
|
|
571
|
-
flag = true;
|
|
572
|
-
break;
|
|
573
|
-
case "End":
|
|
574
|
-
if (multiSelect && ctrlPressed && event.shiftKey && !isDisabled(focusedNodeId)) {
|
|
575
|
-
rangeSelectToLast(event, focusedNodeId);
|
|
576
|
-
}
|
|
577
|
-
focusLastNode(event);
|
|
578
|
-
flag = true;
|
|
579
|
-
break;
|
|
580
|
-
default:
|
|
581
|
-
if (key === "*") {
|
|
582
|
-
expandAllSiblings(event, focusedNodeId);
|
|
583
|
-
flag = true;
|
|
584
|
-
} else if (multiSelect && ctrlPressed && key.toLowerCase() === "a") {
|
|
585
|
-
selectAllNodes(event);
|
|
586
|
-
flag = true;
|
|
587
|
-
} else if (!ctrlPressed && !event.shiftKey && isPrintableCharacter(key)) {
|
|
588
|
-
focusByFirstCharacter(event, focusedNodeId, key);
|
|
589
|
-
flag = true;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
if (flag) {
|
|
593
|
-
event.preventDefault();
|
|
594
|
-
event.stopPropagation();
|
|
595
|
-
}
|
|
596
|
-
onKeyDown?.(event);
|
|
597
|
-
};
|
|
598
|
-
const handleFocus = (event) => {
|
|
599
|
-
if (event.target === event.currentTarget) {
|
|
600
|
-
const firstSelected = Array.isArray(selected) ? selected[0] : selected;
|
|
601
|
-
focus(event, firstSelected || getNavigableChildrenIds(null)[0]);
|
|
602
|
-
}
|
|
603
|
-
onFocus?.(event);
|
|
604
|
-
};
|
|
605
|
-
const handleBlur = (event) => {
|
|
606
|
-
setFocusedNodeId(null);
|
|
607
|
-
onBlur?.(event);
|
|
608
|
-
};
|
|
609
|
-
const activeDescendant = focusedNodeId && nodeMap.current[focusedNodeId] ? nodeMap.current[focusedNodeId].idAttribute : null;
|
|
610
|
-
const treeControlContext = useMemo(
|
|
611
|
-
() => ({
|
|
612
|
-
treeId,
|
|
613
|
-
mode,
|
|
614
|
-
collapsible,
|
|
615
|
-
toggleExpansion,
|
|
616
|
-
multiSelect,
|
|
617
|
-
selectNode: selectable ? selectNode : noopSelection,
|
|
618
|
-
selectRange: selectable ? selectRange : noopSelection,
|
|
619
|
-
disabledItemsFocusable,
|
|
620
|
-
registerNode,
|
|
621
|
-
unregisterNode,
|
|
622
|
-
mapFirstChar,
|
|
623
|
-
unMapFirstChar,
|
|
624
|
-
focus
|
|
625
|
-
}),
|
|
626
|
-
[
|
|
627
|
-
registerNode,
|
|
628
|
-
unregisterNode,
|
|
629
|
-
mapFirstChar,
|
|
630
|
-
unMapFirstChar,
|
|
631
|
-
toggleExpansion,
|
|
632
|
-
selectable,
|
|
633
|
-
selectNode,
|
|
634
|
-
selectRange,
|
|
635
|
-
mode,
|
|
636
|
-
collapsible,
|
|
637
|
-
multiSelect,
|
|
638
|
-
disabledItemsFocusable,
|
|
639
|
-
treeId
|
|
640
|
-
]
|
|
641
|
-
);
|
|
642
|
-
const treeStateContext = useMemo(
|
|
643
|
-
() => ({
|
|
644
|
-
isExpanded,
|
|
645
|
-
isSelected,
|
|
646
|
-
isFocused,
|
|
647
|
-
isDisabled,
|
|
648
|
-
isChildSelected
|
|
649
|
-
}),
|
|
650
|
-
[isDisabled, isExpanded, isFocused, isSelected, isChildSelected]
|
|
651
|
-
);
|
|
652
|
-
return /* @__PURE__ */ jsx(TreeViewControlContext.Provider, { value: treeControlContext, children: /* @__PURE__ */ jsx(TreeViewStateContext.Provider, { value: treeStateContext, children: /* @__PURE__ */ jsx(DescendantProvider, { children: /* @__PURE__ */ jsx(
|
|
653
|
-
"ul",
|
|
654
|
-
{
|
|
655
|
-
ref: handleRef,
|
|
656
|
-
id: idProp,
|
|
657
|
-
className: cx(classes.root, className),
|
|
658
|
-
...treeviewMode && {
|
|
659
|
-
id: treeId,
|
|
660
|
-
role: "tree",
|
|
661
|
-
"aria-multiselectable": multiSelect,
|
|
662
|
-
"aria-activedescendant": activeDescendant,
|
|
663
|
-
tabIndex: 0,
|
|
664
|
-
onFocus: handleFocus,
|
|
665
|
-
onBlur: handleBlur,
|
|
666
|
-
onKeyDown: handleKeyDown
|
|
667
|
-
},
|
|
668
|
-
...others,
|
|
669
|
-
children
|
|
670
|
-
}
|
|
671
|
-
) }) }) });
|
|
20
|
+
var HvVerticalNavigationTreeView = forwardRef(function HvVerticalNavigationTreeView(props, ref) {
|
|
21
|
+
const { id: idProp, className, classes: classesProp, mode = "treeview", collapsible = false, expanded: expandedProp, defaultExpanded = [], onToggle, selectable = false, multiSelect: multiSelectProp = false, selected: selectedProp, defaultSelected = [], onChange, disabledItemsFocusable = false, onFocus, onBlur, onKeyDown, children, ...others } = useDefaultProps("HvVerticalNavigationTreeView", props);
|
|
22
|
+
const { classes, cx } = useClasses(classesProp);
|
|
23
|
+
const treeviewMode = mode === "treeview";
|
|
24
|
+
const multiSelect = selectable && multiSelectProp;
|
|
25
|
+
const treeId = useUniqueId(idProp);
|
|
26
|
+
const treeRef = useRef(null);
|
|
27
|
+
const handleRef = useForkRef(treeRef, ref);
|
|
28
|
+
const [expanded, setExpandedState] = useControlled(expandedProp, defaultExpanded);
|
|
29
|
+
const [selected, setSelectedState] = useControlled(selectedProp, defaultSelected);
|
|
30
|
+
const [focusedNodeId, setFocusedNodeId] = useState(null);
|
|
31
|
+
const nodeMap = useRef({});
|
|
32
|
+
const firstCharMap = useRef({});
|
|
33
|
+
const isExpanded = useCallback((id) => !collapsible || (Array.isArray(expanded) ? expanded.indexOf(id) !== -1 : false), [collapsible, expanded]);
|
|
34
|
+
const isExpandable = useCallback((id) => collapsible && nodeMap.current[id] && nodeMap.current[id].expandable, [collapsible]);
|
|
35
|
+
const isSelected = useCallback((id) => selectable && (Array.isArray(selected) ? selected.indexOf(id) !== -1 : selected === id), [selectable, selected]);
|
|
36
|
+
const isSelectable = useCallback((id) => selectable && nodeMap.current[id] && nodeMap.current[id].selectable, [selectable]);
|
|
37
|
+
const isDisabled = useCallback((id) => {
|
|
38
|
+
let node = nodeMap.current[id];
|
|
39
|
+
if (!node) return false;
|
|
40
|
+
if (node.disabled) return true;
|
|
41
|
+
while (node.parentId != null) {
|
|
42
|
+
node = nodeMap.current[node.parentId];
|
|
43
|
+
if (node.disabled) return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}, []);
|
|
47
|
+
const isFocused = useCallback((id) => focusedNodeId === id, [focusedNodeId]);
|
|
48
|
+
const isChildSelected = useCallback((id) => {
|
|
49
|
+
return Array().concat(selected).some((s) => s.startsWith(id) && s.includes("-"));
|
|
50
|
+
}, [selected]);
|
|
51
|
+
const getChildrenIds = (id) => Object.keys(nodeMap.current).map((key) => {
|
|
52
|
+
return nodeMap.current[key];
|
|
53
|
+
}).filter((node) => node.parentId === id).toSorted((a, b) => a.index - b.index).map((child) => child.id);
|
|
54
|
+
const getNavigableChildrenIds = useCallback((id) => {
|
|
55
|
+
let childrenIds = getChildrenIds(id);
|
|
56
|
+
if (!disabledItemsFocusable) childrenIds = childrenIds.filter((node) => !isDisabled(node));
|
|
57
|
+
return childrenIds;
|
|
58
|
+
}, [disabledItemsFocusable, isDisabled]);
|
|
59
|
+
const getNextNode = useCallback((id) => {
|
|
60
|
+
if (isExpanded(id) && getNavigableChildrenIds(id).length > 0) return getNavigableChildrenIds(id)[0];
|
|
61
|
+
let node = nodeMap.current[id];
|
|
62
|
+
while (node != null) {
|
|
63
|
+
const siblings = getNavigableChildrenIds(node.parentId);
|
|
64
|
+
const nextSibling = siblings[siblings.indexOf(node.id) + 1];
|
|
65
|
+
if (nextSibling) return nextSibling;
|
|
66
|
+
node = nodeMap.current[node.parentId];
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}, [getNavigableChildrenIds, isExpanded]);
|
|
70
|
+
const getPreviousNode = (id) => {
|
|
71
|
+
const node = nodeMap.current[id];
|
|
72
|
+
const siblings = getNavigableChildrenIds(node.parentId);
|
|
73
|
+
const nodeIndex = siblings.indexOf(id);
|
|
74
|
+
if (nodeIndex === 0) return node.parentId;
|
|
75
|
+
let currentNode = siblings[nodeIndex - 1];
|
|
76
|
+
while (isExpanded(currentNode) && getNavigableChildrenIds(currentNode).length > 0) currentNode = getNavigableChildrenIds(currentNode).pop();
|
|
77
|
+
return currentNode;
|
|
78
|
+
};
|
|
79
|
+
const getLastNode = () => {
|
|
80
|
+
let lastNode = getNavigableChildrenIds(null).pop();
|
|
81
|
+
while (isExpanded(lastNode)) lastNode = getNavigableChildrenIds(lastNode).pop();
|
|
82
|
+
return lastNode;
|
|
83
|
+
};
|
|
84
|
+
const getFirstNode = () => getNavigableChildrenIds(null)[0];
|
|
85
|
+
const getParent = (id) => nodeMap.current[id].parentId;
|
|
86
|
+
/**
|
|
87
|
+
* This is used to determine the start and end of a selection range so
|
|
88
|
+
* we can get the nodes between the two border nodes.
|
|
89
|
+
*
|
|
90
|
+
* It finds the nodes' common ancestor using
|
|
91
|
+
* a naive implementation of a lowest common ancestor algorithm
|
|
92
|
+
* (https://en.wikipedia.org/wiki/Lowest_common_ancestor).
|
|
93
|
+
* Then compares the ancestor's 2 children that are ancestors of nodeA and NodeB
|
|
94
|
+
* so we can compare their indexes to work out which node comes first in a depth first search.
|
|
95
|
+
* (https://en.wikipedia.org/wiki/Depth-first_search)
|
|
96
|
+
*
|
|
97
|
+
* Another way to put it is which node is shallower in a trémaux tree
|
|
98
|
+
* https://en.wikipedia.org/wiki/Tr%C3%A9maux_tree
|
|
99
|
+
*/
|
|
100
|
+
const findOrderInTremauxTree = useCallback((nodeAId, nodeBId) => {
|
|
101
|
+
if (nodeAId === nodeBId) return [nodeAId, nodeBId];
|
|
102
|
+
const nodeA = nodeMap.current[nodeAId];
|
|
103
|
+
const nodeB = nodeMap.current[nodeBId];
|
|
104
|
+
if (nodeA.parentId === nodeB.id || nodeB.parentId === nodeA.id) return nodeB.parentId === nodeA.id ? [nodeA.id, nodeB.id] : [nodeB.id, nodeA.id];
|
|
105
|
+
const aFamily = [nodeA.id];
|
|
106
|
+
const bFamily = [nodeB.id];
|
|
107
|
+
let aAncestor = nodeA.parentId;
|
|
108
|
+
let bAncestor = nodeB.parentId;
|
|
109
|
+
let aAncestorIsCommon = bFamily.indexOf(aAncestor) !== -1;
|
|
110
|
+
let bAncestorIsCommon = aFamily.indexOf(bAncestor) !== -1;
|
|
111
|
+
let continueA = true;
|
|
112
|
+
let continueB = true;
|
|
113
|
+
while (!bAncestorIsCommon && !aAncestorIsCommon) {
|
|
114
|
+
if (continueA) {
|
|
115
|
+
aFamily.push(aAncestor);
|
|
116
|
+
aAncestorIsCommon = bFamily.indexOf(aAncestor) !== -1;
|
|
117
|
+
continueA = aAncestor !== null;
|
|
118
|
+
if (!aAncestorIsCommon && continueA) aAncestor = nodeMap.current[aAncestor].parentId;
|
|
119
|
+
}
|
|
120
|
+
if (continueB && !aAncestorIsCommon) {
|
|
121
|
+
bFamily.push(bAncestor);
|
|
122
|
+
bAncestorIsCommon = aFamily.indexOf(bAncestor) !== -1;
|
|
123
|
+
continueB = bAncestor !== null;
|
|
124
|
+
if (!bAncestorIsCommon && continueB) bAncestor = nodeMap.current[bAncestor].parentId;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const commonAncestor = aAncestorIsCommon ? aAncestor : bAncestor;
|
|
128
|
+
const ancestorFamily = getChildrenIds(commonAncestor);
|
|
129
|
+
const aSide = aFamily[aFamily.indexOf(commonAncestor) - 1];
|
|
130
|
+
const bSide = bFamily[bFamily.indexOf(commonAncestor) - 1];
|
|
131
|
+
return ancestorFamily.indexOf(aSide) < ancestorFamily.indexOf(bSide) ? [nodeAId, nodeBId] : [nodeBId, nodeAId];
|
|
132
|
+
}, []);
|
|
133
|
+
const getNodesInRange = useCallback((nodeA, nodeB) => {
|
|
134
|
+
if (nodeA && nodeB) {
|
|
135
|
+
const [first, last] = findOrderInTremauxTree(nodeA, nodeB);
|
|
136
|
+
const nodes = [first];
|
|
137
|
+
let current = first;
|
|
138
|
+
while (current !== last) {
|
|
139
|
+
current = getNextNode(current);
|
|
140
|
+
nodes.push(current);
|
|
141
|
+
}
|
|
142
|
+
return nodes;
|
|
143
|
+
}
|
|
144
|
+
return [];
|
|
145
|
+
}, [findOrderInTremauxTree, getNextNode]);
|
|
146
|
+
const focus = (event, id) => {
|
|
147
|
+
if (id) {
|
|
148
|
+
setFocusedNodeId(id);
|
|
149
|
+
if (nodeMap.current[id]?.onFocus) nodeMap.current[id].onFocus(event);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const focusNextNode = (event, id) => focus(event, getNextNode(id));
|
|
153
|
+
const focusPreviousNode = (event, id) => focus(event, getPreviousNode(id));
|
|
154
|
+
const focusFirstNode = (event) => focus(event, getFirstNode());
|
|
155
|
+
const focusLastNode = (event) => focus(event, getLastNode());
|
|
156
|
+
const focusByFirstCharacter = (event, id, char) => {
|
|
157
|
+
let start;
|
|
158
|
+
let index;
|
|
159
|
+
const lowercaseChar = char.toLowerCase();
|
|
160
|
+
const firstCharIds = [];
|
|
161
|
+
const firstChars = [];
|
|
162
|
+
Object.keys(firstCharMap.current).forEach((nodeId) => {
|
|
163
|
+
const firstChar = firstCharMap.current[nodeId];
|
|
164
|
+
const map = nodeMap.current[nodeId];
|
|
165
|
+
const visible = map.parentId ? isExpanded(map.parentId) : true;
|
|
166
|
+
const shouldBeSkipped = disabledItemsFocusable ? false : isDisabled(nodeId);
|
|
167
|
+
if (visible && !shouldBeSkipped) {
|
|
168
|
+
firstCharIds.push(nodeId);
|
|
169
|
+
firstChars.push(firstChar);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
start = firstCharIds.indexOf(id) + 1;
|
|
173
|
+
if (start >= firstCharIds.length) start = 0;
|
|
174
|
+
index = findNextFirstChar(firstChars, start, lowercaseChar);
|
|
175
|
+
if (index === -1) index = findNextFirstChar(firstChars, 0, lowercaseChar);
|
|
176
|
+
if (index > -1) focus(event, firstCharIds[index]);
|
|
177
|
+
};
|
|
178
|
+
const toggleExpansion = useCallback((event, value = focusedNodeId) => {
|
|
179
|
+
if (!value) return;
|
|
180
|
+
const newExpanded = expanded.includes(value) ? expanded.filter((id) => id !== value) : [value].concat(expanded);
|
|
181
|
+
onToggle?.(event, newExpanded);
|
|
182
|
+
setExpandedState(newExpanded);
|
|
183
|
+
}, [
|
|
184
|
+
expanded,
|
|
185
|
+
focusedNodeId,
|
|
186
|
+
onToggle,
|
|
187
|
+
setExpandedState
|
|
188
|
+
]);
|
|
189
|
+
const expandAllSiblings = (event, id) => {
|
|
190
|
+
const map = nodeMap.current[id];
|
|
191
|
+
const diff = getChildrenIds(map.parentId).filter((child) => isExpandable(child) && !isExpanded(child));
|
|
192
|
+
const newExpanded = expanded.concat(diff);
|
|
193
|
+
if (diff.length > 0) {
|
|
194
|
+
setExpandedState(newExpanded);
|
|
195
|
+
onToggle?.(event, newExpanded);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const lastSelectedNode = useRef(null);
|
|
199
|
+
const lastSelectionWasRange = useRef(false);
|
|
200
|
+
const currentRangeSelection = useRef([]);
|
|
201
|
+
const isDivElement = (element) => {
|
|
202
|
+
return element.nodeType === 1;
|
|
203
|
+
};
|
|
204
|
+
const handleRangeArrowSelect = useCallback((event, nodes) => {
|
|
205
|
+
let base = Array().concat(selected);
|
|
206
|
+
const { start, next, current } = nodes;
|
|
207
|
+
if (!next || !current) return;
|
|
208
|
+
if (isDivElement(current) && currentRangeSelection.current.indexOf(current) === -1) currentRangeSelection.current = [];
|
|
209
|
+
if (lastSelectionWasRange.current) if (isDivElement(next) && currentRangeSelection.current.indexOf(next) !== -1) {
|
|
210
|
+
base = base.filter((id) => id === start || id !== current);
|
|
211
|
+
currentRangeSelection.current = currentRangeSelection.current.filter((id) => id === start || id !== current);
|
|
212
|
+
} else {
|
|
213
|
+
base.push(next);
|
|
214
|
+
currentRangeSelection.current.push(next);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
base.push(next);
|
|
218
|
+
currentRangeSelection.current.push(current, next);
|
|
219
|
+
}
|
|
220
|
+
onChange?.(event, base, base.map((id) => nodeMap.current[id]?.payload));
|
|
221
|
+
setSelectedState(base);
|
|
222
|
+
}, [
|
|
223
|
+
onChange,
|
|
224
|
+
selected,
|
|
225
|
+
setSelectedState
|
|
226
|
+
]);
|
|
227
|
+
const handleRangeSelect = useCallback((event, nodes) => {
|
|
228
|
+
let base = Array().concat(selected);
|
|
229
|
+
const { start, end } = nodes;
|
|
230
|
+
if (lastSelectionWasRange.current) base = base.filter((id) => !currentRangeSelection.current.includes(id));
|
|
231
|
+
let range = getNodesInRange(start, end);
|
|
232
|
+
range = range.filter((node) => !isDisabled(node));
|
|
233
|
+
currentRangeSelection.current = range;
|
|
234
|
+
let newSelected = base.concat(range);
|
|
235
|
+
newSelected = newSelected.filter((id, i) => newSelected.indexOf(id) === i);
|
|
236
|
+
onChange?.(event, newSelected, newSelected.map((id) => nodeMap.current[id]?.payload));
|
|
237
|
+
setSelectedState(newSelected);
|
|
238
|
+
}, [
|
|
239
|
+
getNodesInRange,
|
|
240
|
+
isDisabled,
|
|
241
|
+
onChange,
|
|
242
|
+
selected,
|
|
243
|
+
setSelectedState
|
|
244
|
+
]);
|
|
245
|
+
const handleMultipleSelect = useCallback((event, value) => {
|
|
246
|
+
const newSelected = selected.includes(value) ? selected.filter((id) => id !== value) : [value].concat(selected);
|
|
247
|
+
onChange?.(event, newSelected, newSelected.map((id) => nodeMap.current[id]?.payload));
|
|
248
|
+
setSelectedState(newSelected);
|
|
249
|
+
}, [
|
|
250
|
+
onChange,
|
|
251
|
+
selected,
|
|
252
|
+
setSelectedState
|
|
253
|
+
]);
|
|
254
|
+
const handleSingleSelect = useCallback((event, value) => {
|
|
255
|
+
const newSelected = multiSelect ? [value] : value;
|
|
256
|
+
if (onChange) {
|
|
257
|
+
const nodeValue = nodeMap.current[newSelected]?.payload;
|
|
258
|
+
onChange(event, newSelected, multiSelect ? [nodeValue] : nodeValue);
|
|
259
|
+
}
|
|
260
|
+
setSelectedState(newSelected);
|
|
261
|
+
}, [
|
|
262
|
+
multiSelect,
|
|
263
|
+
onChange,
|
|
264
|
+
setSelectedState
|
|
265
|
+
]);
|
|
266
|
+
const selectNode = useCallback((event, id, multiple = false) => {
|
|
267
|
+
if (id && isSelectable(id)) {
|
|
268
|
+
if (multiple) handleMultipleSelect(event, id);
|
|
269
|
+
else handleSingleSelect(event, id);
|
|
270
|
+
lastSelectedNode.current = id;
|
|
271
|
+
lastSelectionWasRange.current = false;
|
|
272
|
+
currentRangeSelection.current = [];
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
}, [
|
|
277
|
+
handleMultipleSelect,
|
|
278
|
+
handleSingleSelect,
|
|
279
|
+
isSelectable
|
|
280
|
+
]);
|
|
281
|
+
const selectRange = useCallback((event, nodes, stacked = false) => {
|
|
282
|
+
const { start = lastSelectedNode.current, end, current } = nodes;
|
|
283
|
+
if (stacked) handleRangeArrowSelect(event, {
|
|
284
|
+
start,
|
|
285
|
+
next: end,
|
|
286
|
+
current
|
|
287
|
+
});
|
|
288
|
+
else if (start != null && end != null) handleRangeSelect(event, {
|
|
289
|
+
start,
|
|
290
|
+
end
|
|
291
|
+
});
|
|
292
|
+
lastSelectionWasRange.current = true;
|
|
293
|
+
}, [handleRangeArrowSelect, handleRangeSelect]);
|
|
294
|
+
const rangeSelectToFirst = (event, id) => {
|
|
295
|
+
if (!lastSelectedNode.current) lastSelectedNode.current = id;
|
|
296
|
+
selectRange(event, {
|
|
297
|
+
start: lastSelectionWasRange.current ? lastSelectedNode.current : id,
|
|
298
|
+
end: getFirstNode()
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
const rangeSelectToLast = (event, id) => {
|
|
302
|
+
if (!lastSelectedNode.current) lastSelectedNode.current = id;
|
|
303
|
+
selectRange(event, {
|
|
304
|
+
start: lastSelectionWasRange.current ? lastSelectedNode.current : id,
|
|
305
|
+
end: getLastNode()
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
const selectNextNode = (event, id) => {
|
|
309
|
+
if (!isDisabled(getNextNode(id))) selectRange(event, {
|
|
310
|
+
end: getNextNode(id),
|
|
311
|
+
current: id
|
|
312
|
+
}, true);
|
|
313
|
+
};
|
|
314
|
+
const selectPreviousNode = (event, id) => {
|
|
315
|
+
if (!isDisabled(getPreviousNode(id))) selectRange(event, {
|
|
316
|
+
end: getPreviousNode(id),
|
|
317
|
+
current: id
|
|
318
|
+
}, true);
|
|
319
|
+
};
|
|
320
|
+
const selectAllNodes = (event) => {
|
|
321
|
+
selectRange(event, {
|
|
322
|
+
start: getFirstNode(),
|
|
323
|
+
end: getLastNode()
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
const registerNode = useCallback((node) => {
|
|
327
|
+
const { id, index, parentId, expandable, idAttribute, disabled, selectable: nodeSelectable, onFocus: nodeOnFocus, payload } = node;
|
|
328
|
+
nodeMap.current[id] = {
|
|
329
|
+
id,
|
|
330
|
+
index,
|
|
331
|
+
parentId,
|
|
332
|
+
expandable,
|
|
333
|
+
idAttribute,
|
|
334
|
+
disabled,
|
|
335
|
+
selectable: nodeSelectable,
|
|
336
|
+
onFocus: nodeOnFocus,
|
|
337
|
+
payload
|
|
338
|
+
};
|
|
339
|
+
}, []);
|
|
340
|
+
const unregisterNode = useCallback((id) => {
|
|
341
|
+
const newMap = { ...nodeMap.current };
|
|
342
|
+
delete newMap[id];
|
|
343
|
+
nodeMap.current = newMap;
|
|
344
|
+
setFocusedNodeId((oldFocusedNodeId) => {
|
|
345
|
+
if (oldFocusedNodeId === id && treeRef.current && treeRef.current === (treeRef.current.ownerDocument || document).activeElement) return getChildrenIds(null)[0];
|
|
346
|
+
return oldFocusedNodeId;
|
|
347
|
+
});
|
|
348
|
+
}, []);
|
|
349
|
+
const mapFirstChar = useCallback((id, firstChar) => {
|
|
350
|
+
firstCharMap.current[id] = firstChar;
|
|
351
|
+
}, []);
|
|
352
|
+
const unMapFirstChar = useCallback((id) => {
|
|
353
|
+
const newMap = { ...firstCharMap.current };
|
|
354
|
+
delete newMap[id];
|
|
355
|
+
firstCharMap.current = newMap;
|
|
356
|
+
}, []);
|
|
357
|
+
/**
|
|
358
|
+
* Event handlers and Navigation
|
|
359
|
+
*/
|
|
360
|
+
const handleNextArrow = (event) => {
|
|
361
|
+
if (!focusedNodeId) return false;
|
|
362
|
+
if (isExpandable(focusedNodeId)) {
|
|
363
|
+
if (isExpanded(focusedNodeId)) focusNextNode(event, focusedNodeId);
|
|
364
|
+
else if (!isDisabled(focusedNodeId)) toggleExpansion(event);
|
|
365
|
+
}
|
|
366
|
+
return true;
|
|
367
|
+
};
|
|
368
|
+
const handlePreviousArrow = (event) => {
|
|
369
|
+
if (!focusedNodeId) return false;
|
|
370
|
+
if (isExpanded(focusedNodeId) && !isDisabled(focusedNodeId)) {
|
|
371
|
+
toggleExpansion(event, focusedNodeId);
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
const parent = getParent(focusedNodeId);
|
|
375
|
+
if (parent) {
|
|
376
|
+
focus(event, parent);
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
return false;
|
|
380
|
+
};
|
|
381
|
+
const handleKeyDown = (event) => {
|
|
382
|
+
let flag = false;
|
|
383
|
+
const { key } = event;
|
|
384
|
+
if (event.altKey || event.currentTarget !== event.target || !focusedNodeId) return;
|
|
385
|
+
const ctrlPressed = event.ctrlKey || event.metaKey;
|
|
386
|
+
switch (key) {
|
|
387
|
+
case " ":
|
|
388
|
+
if (isSelectable(focusedNodeId) && !isDisabled(focusedNodeId)) if (multiSelect && event.shiftKey) {
|
|
389
|
+
selectRange(event, { end: focusedNodeId });
|
|
390
|
+
flag = true;
|
|
391
|
+
} else if (multiSelect) flag = selectNode(event, focusedNodeId, true);
|
|
392
|
+
else flag = selectNode(event, focusedNodeId);
|
|
393
|
+
event.stopPropagation();
|
|
394
|
+
break;
|
|
395
|
+
case "Enter":
|
|
396
|
+
if (!isDisabled(focusedNodeId)) {
|
|
397
|
+
if (isExpandable(focusedNodeId)) {
|
|
398
|
+
toggleExpansion(event);
|
|
399
|
+
flag = true;
|
|
400
|
+
} else if (isSelectable(focusedNodeId)) if (multiSelect && event.shiftKey) {
|
|
401
|
+
selectRange(event, { end: focusedNodeId });
|
|
402
|
+
flag = true;
|
|
403
|
+
} else if (multiSelect) flag = selectNode(event, focusedNodeId, true);
|
|
404
|
+
else flag = selectNode(event, focusedNodeId);
|
|
405
|
+
}
|
|
406
|
+
event.stopPropagation();
|
|
407
|
+
break;
|
|
408
|
+
case "ArrowDown":
|
|
409
|
+
if (multiSelect && event.shiftKey) selectNextNode(event, focusedNodeId);
|
|
410
|
+
focusNextNode(event, focusedNodeId);
|
|
411
|
+
flag = true;
|
|
412
|
+
break;
|
|
413
|
+
case "ArrowUp":
|
|
414
|
+
if (multiSelect && event.shiftKey) selectPreviousNode(event, focusedNodeId);
|
|
415
|
+
focusPreviousNode(event, focusedNodeId);
|
|
416
|
+
flag = true;
|
|
417
|
+
break;
|
|
418
|
+
case "ArrowRight":
|
|
419
|
+
flag = handleNextArrow(event);
|
|
420
|
+
break;
|
|
421
|
+
case "ArrowLeft":
|
|
422
|
+
flag = handlePreviousArrow(event);
|
|
423
|
+
break;
|
|
424
|
+
case "Home":
|
|
425
|
+
if (multiSelect && ctrlPressed && event.shiftKey && !isDisabled(focusedNodeId)) rangeSelectToFirst(event, focusedNodeId);
|
|
426
|
+
focusFirstNode(event);
|
|
427
|
+
flag = true;
|
|
428
|
+
break;
|
|
429
|
+
case "End":
|
|
430
|
+
if (multiSelect && ctrlPressed && event.shiftKey && !isDisabled(focusedNodeId)) rangeSelectToLast(event, focusedNodeId);
|
|
431
|
+
focusLastNode(event);
|
|
432
|
+
flag = true;
|
|
433
|
+
break;
|
|
434
|
+
default: if (key === "*") {
|
|
435
|
+
expandAllSiblings(event, focusedNodeId);
|
|
436
|
+
flag = true;
|
|
437
|
+
} else if (multiSelect && ctrlPressed && key.toLowerCase() === "a") {
|
|
438
|
+
selectAllNodes(event);
|
|
439
|
+
flag = true;
|
|
440
|
+
} else if (!ctrlPressed && !event.shiftKey && isPrintableCharacter(key)) {
|
|
441
|
+
focusByFirstCharacter(event, focusedNodeId, key);
|
|
442
|
+
flag = true;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (flag) {
|
|
446
|
+
event.preventDefault();
|
|
447
|
+
event.stopPropagation();
|
|
448
|
+
}
|
|
449
|
+
onKeyDown?.(event);
|
|
450
|
+
};
|
|
451
|
+
const handleFocus = (event) => {
|
|
452
|
+
if (event.target === event.currentTarget) focus(event, (Array.isArray(selected) ? selected[0] : selected) || getNavigableChildrenIds(null)[0]);
|
|
453
|
+
onFocus?.(event);
|
|
454
|
+
};
|
|
455
|
+
const handleBlur = (event) => {
|
|
456
|
+
setFocusedNodeId(null);
|
|
457
|
+
onBlur?.(event);
|
|
458
|
+
};
|
|
459
|
+
const activeDescendant = focusedNodeId && nodeMap.current[focusedNodeId] ? nodeMap.current[focusedNodeId].idAttribute : null;
|
|
460
|
+
const treeControlContext = useMemo(() => ({
|
|
461
|
+
treeId,
|
|
462
|
+
mode,
|
|
463
|
+
collapsible,
|
|
464
|
+
toggleExpansion,
|
|
465
|
+
multiSelect,
|
|
466
|
+
selectNode: selectable ? selectNode : noopSelection,
|
|
467
|
+
selectRange: selectable ? selectRange : noopSelection,
|
|
468
|
+
disabledItemsFocusable,
|
|
469
|
+
registerNode,
|
|
470
|
+
unregisterNode,
|
|
471
|
+
mapFirstChar,
|
|
472
|
+
unMapFirstChar,
|
|
473
|
+
focus
|
|
474
|
+
}), [
|
|
475
|
+
registerNode,
|
|
476
|
+
unregisterNode,
|
|
477
|
+
mapFirstChar,
|
|
478
|
+
unMapFirstChar,
|
|
479
|
+
toggleExpansion,
|
|
480
|
+
selectable,
|
|
481
|
+
selectNode,
|
|
482
|
+
selectRange,
|
|
483
|
+
mode,
|
|
484
|
+
collapsible,
|
|
485
|
+
multiSelect,
|
|
486
|
+
disabledItemsFocusable,
|
|
487
|
+
treeId
|
|
488
|
+
]);
|
|
489
|
+
const treeStateContext = useMemo(() => ({
|
|
490
|
+
isExpanded,
|
|
491
|
+
isSelected,
|
|
492
|
+
isFocused,
|
|
493
|
+
isDisabled,
|
|
494
|
+
isChildSelected
|
|
495
|
+
}), [
|
|
496
|
+
isDisabled,
|
|
497
|
+
isExpanded,
|
|
498
|
+
isFocused,
|
|
499
|
+
isSelected,
|
|
500
|
+
isChildSelected
|
|
501
|
+
]);
|
|
502
|
+
return /* @__PURE__ */ jsx(TreeViewControlContext.Provider, {
|
|
503
|
+
value: treeControlContext,
|
|
504
|
+
children: /* @__PURE__ */ jsx(TreeViewStateContext.Provider, {
|
|
505
|
+
value: treeStateContext,
|
|
506
|
+
children: /* @__PURE__ */ jsx(DescendantProvider, { children: /* @__PURE__ */ jsx("ul", {
|
|
507
|
+
ref: handleRef,
|
|
508
|
+
id: idProp,
|
|
509
|
+
className: cx(classes.root, className),
|
|
510
|
+
...treeviewMode && {
|
|
511
|
+
id: treeId,
|
|
512
|
+
role: "tree",
|
|
513
|
+
"aria-multiselectable": multiSelect,
|
|
514
|
+
"aria-activedescendant": activeDescendant,
|
|
515
|
+
tabIndex: 0,
|
|
516
|
+
onFocus: handleFocus,
|
|
517
|
+
onBlur: handleBlur,
|
|
518
|
+
onKeyDown: handleKeyDown
|
|
519
|
+
},
|
|
520
|
+
...others,
|
|
521
|
+
children
|
|
522
|
+
}) })
|
|
523
|
+
})
|
|
524
|
+
});
|
|
672
525
|
});
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
staticClasses as treeViewClasses
|
|
676
|
-
};
|
|
526
|
+
//#endregion
|
|
527
|
+
export { HvVerticalNavigationTreeView };
|