@hitachivantara/uikit-react-core 5.66.10 → 5.66.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/dist/cjs/Accordion/Accordion.cjs +1 -1
- package/dist/cjs/ActionBar/ActionBar.cjs +1 -1
- package/dist/cjs/ActionsGeneric/ActionsGeneric.cjs +1 -1
- package/dist/cjs/AppSwitcher/Action/Action.cjs +1 -1
- package/dist/cjs/AppSwitcher/AppSwitcher.cjs +2 -2
- package/dist/cjs/Avatar/Avatar.cjs +1 -1
- package/dist/cjs/AvatarGroup/AvatarGroup.cjs +1 -1
- package/dist/cjs/AvatarGroup/AvatarGroupContext.cjs +1 -1
- package/dist/cjs/Badge/Badge.cjs +1 -1
- package/dist/cjs/Banner/Banner.cjs +1 -1
- package/dist/cjs/Banner/BannerContent/ActionContainer/ActionContainer.cjs +1 -1
- package/dist/cjs/Banner/BannerContent/BannerContent.cjs +1 -1
- package/dist/cjs/Banner/BannerContent/MessageContainer/MessageContainer.cjs +1 -1
- package/dist/cjs/BaseCheckBox/BaseCheckBox.cjs +1 -1
- package/dist/cjs/BaseCheckBox/icons.cjs +1 -1
- package/dist/cjs/BaseDropdown/BaseDropdown.cjs +1 -1
- package/dist/cjs/BaseInput/BaseInput.cjs +1 -1
- package/dist/cjs/BaseRadio/BaseRadio.cjs +1 -1
- package/dist/cjs/BaseRadio/icons.cjs +1 -1
- package/dist/cjs/BaseSwitch/BaseSwitch.cjs +1 -1
- package/dist/cjs/Box/Box.cjs +1 -1
- package/dist/cjs/BreadCrumb/BreadCrumb.cjs +1 -1
- package/dist/cjs/BreadCrumb/Page/Page.cjs +1 -1
- package/dist/cjs/BreadCrumb/PathElement/PathElement.cjs +1 -1
- package/dist/cjs/BreadCrumb/utils.cjs +1 -1
- package/dist/cjs/BulkActions/BulkActions.cjs +1 -1
- package/dist/cjs/BulkActions/BulkActions.styles.cjs +1 -1
- package/dist/cjs/Button/Button.cjs +1 -1
- package/dist/cjs/Calendar/Calendar.cjs +10 -4
- package/dist/cjs/Calendar/CalendarHeader/CalendarHeader.cjs +1 -1
- package/dist/cjs/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.cjs +1 -1
- package/dist/cjs/Calendar/CalendarNavigation/MonthSelector/MonthSelector.cjs +1 -1
- package/dist/cjs/Calendar/CalendarNavigation/Navigation/Navigation.cjs +1 -1
- package/dist/cjs/Calendar/SingleCalendar/CalendarCell.cjs +2 -2
- package/dist/cjs/Calendar/SingleCalendar/SingleCalendar.cjs +1 -1
- package/dist/cjs/Card/Card.cjs +1 -1
- package/dist/cjs/Card/Content/Content.cjs +1 -1
- package/dist/cjs/Card/Header/Header.cjs +1 -1
- package/dist/cjs/Card/Media/Media.cjs +1 -7
- package/dist/cjs/Carousel/Carousel.cjs +1 -1
- package/dist/cjs/Carousel/CarouselControls.cjs +1 -1
- package/dist/cjs/Carousel/CarouselSlide/CarouselSlide.cjs +1 -1
- package/dist/cjs/Carousel/CarouselThumbnails.cjs +1 -1
- package/dist/cjs/CheckBox/CheckBox.cjs +1 -1
- package/dist/cjs/CheckBoxGroup/CheckBoxGroup.cjs +1 -1
- package/dist/cjs/ColorPicker/ColorPicker.cjs +1 -1
- package/dist/cjs/ColorPicker/Fields/Fields.cjs +1 -1
- package/dist/cjs/ColorPicker/Picker/Picker.cjs +1 -1
- package/dist/cjs/ColorPicker/PresetColors/PresetColors.cjs +1 -1
- package/dist/cjs/ColorPicker/SavedColors/SavedColors.cjs +1 -1
- package/dist/cjs/Container/Container.cjs +1 -1
- package/dist/cjs/Controls/Controls.cjs +1 -1
- package/dist/cjs/Controls/LeftControl/LeftControl.cjs +1 -1
- package/dist/cjs/Controls/RightControl/RightControl.cjs +1 -1
- package/dist/cjs/DatePicker/DatePicker.cjs +1 -1
- package/dist/cjs/Dialog/Actions/Actions.cjs +1 -1
- package/dist/cjs/Dialog/Content/Content.cjs +1 -1
- package/dist/cjs/Dialog/Dialog.cjs +1 -1
- package/dist/cjs/Dialog/Title/Title.cjs +1 -1
- package/dist/cjs/DotPagination/DotPagination.cjs +1 -1
- package/dist/cjs/Drawer/Drawer.cjs +1 -1
- package/dist/cjs/DropDownMenu/DropDownMenu.cjs +1 -1
- package/dist/cjs/Dropdown/Dropdown.cjs +1 -1
- package/dist/cjs/Dropdown/List/List.cjs +1 -1
- package/dist/cjs/DropdownButton/DropdownButton.cjs +1 -1
- package/dist/cjs/EmptyState/EmptyState.cjs +1 -1
- package/dist/cjs/FileUploader/DropZone/DropZone.cjs +1 -1
- package/dist/cjs/FileUploader/File/File.cjs +1 -1
- package/dist/cjs/FileUploader/FileList/FileList.cjs +1 -1
- package/dist/cjs/FileUploader/FileUploader.cjs +1 -1
- package/dist/cjs/FileUploader/Preview/Preview.cjs +1 -1
- package/dist/cjs/FilterGroup/Counter/Counter.cjs +1 -1
- package/dist/cjs/FilterGroup/FilterContent/FilterContent.cjs +1 -1
- package/dist/cjs/FilterGroup/FilterGroup.cjs +1 -1
- package/dist/cjs/FilterGroup/FilterGroupContext.cjs +1 -1
- package/dist/cjs/FilterGroup/LeftPanel/LeftPanel.cjs +1 -1
- package/dist/cjs/FilterGroup/RightPanel/RightPanel.cjs +1 -1
- package/dist/cjs/Focus/Focus.cjs +2 -3
- package/dist/cjs/Footer/Footer.cjs +1 -1
- package/dist/cjs/Forms/Adornment/Adornment.cjs +1 -1
- package/dist/cjs/Forms/CharCounter/CharCounter.cjs +1 -1
- package/dist/cjs/Forms/FormElement/FormElement.cjs +1 -1
- package/dist/cjs/Forms/InfoMessage/InfoMessage.cjs +1 -1
- package/dist/cjs/Forms/Label/Label.cjs +1 -1
- package/dist/cjs/Forms/Suggestions/Suggestions.cjs +1 -1
- package/dist/cjs/Forms/WarningText/WarningText.cjs +1 -1
- package/dist/cjs/GlobalActions/GlobalActions.cjs +1 -1
- package/dist/cjs/Grid/Grid.cjs +5 -8
- package/dist/cjs/Header/Actions/Actions.cjs +1 -1
- package/dist/cjs/Header/Brand/Brand.cjs +1 -1
- package/dist/cjs/Header/Header.cjs +1 -1
- package/dist/cjs/Header/Navigation/MenuBar/Bar.cjs +1 -1
- package/dist/cjs/Header/Navigation/MenuBar/MenuBar.cjs +1 -1
- package/dist/cjs/Header/Navigation/MenuItem/MenuItem.cjs +2 -2
- package/dist/cjs/Header/Navigation/Navigation.cjs +1 -1
- package/dist/cjs/Header/Navigation/useSelectionPath.cjs +1 -1
- package/dist/cjs/Header/Navigation/utils/FocusContext.cjs +1 -1
- package/dist/cjs/IconButton/IconButton.cjs +1 -1
- package/dist/cjs/InlineEditor/InlineEditor.cjs +1 -1
- package/dist/cjs/Input/Input.cjs +1 -1
- package/dist/cjs/Kpi/Kpi.cjs +1 -1
- package/dist/cjs/Link/Link.cjs +1 -1
- package/dist/cjs/List/List.cjs +1 -1
- package/dist/cjs/List/utils.cjs +1 -1
- package/dist/cjs/ListContainer/ListContainer.cjs +1 -1
- package/dist/cjs/ListContainer/ListItem/ListItem.cjs +1 -1
- package/dist/cjs/Loading/Loading.cjs +1 -1
- package/dist/cjs/LoadingContainer/LoadingContainer.cjs +1 -1
- package/dist/cjs/Login/Login.cjs +1 -1
- package/dist/cjs/MultiButton/MultiButton.cjs +1 -1
- package/dist/cjs/OverflowTooltip/OverflowTooltip.cjs +1 -1
- package/dist/cjs/Pagination/Pagination.cjs +1 -1
- package/dist/cjs/Pagination/Select.cjs +1 -1
- package/dist/cjs/Panel/Panel.cjs +1 -1
- package/dist/cjs/ProgressBar/ProgressBar.cjs +1 -1
- package/dist/cjs/QueryBuilder/ConfirmationDialog/ConfirmationDialog.cjs +1 -1
- package/dist/cjs/QueryBuilder/Context.cjs +1 -1
- package/dist/cjs/QueryBuilder/QueryBuilder.cjs +1 -1
- package/dist/cjs/QueryBuilder/Rule/Attribute/Attribute.cjs +1 -1
- package/dist/cjs/QueryBuilder/Rule/Operator/Operator.cjs +1 -1
- package/dist/cjs/QueryBuilder/Rule/Rule.cjs +1 -1
- package/dist/cjs/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.cjs +1 -1
- package/dist/cjs/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.cjs +1 -1
- package/dist/cjs/QueryBuilder/Rule/Value/NumericValue/NumericValue.cjs +1 -1
- package/dist/cjs/QueryBuilder/Rule/Value/TextValue/TextValue.cjs +1 -1
- package/dist/cjs/QueryBuilder/Rule/Value/Value.cjs +1 -1
- package/dist/cjs/QueryBuilder/RuleGroup/RuleGroup.cjs +1 -1
- package/dist/cjs/QueryBuilder/utils/index.cjs +1 -1
- package/dist/cjs/Radio/Radio.cjs +1 -1
- package/dist/cjs/RadioGroup/RadioGroup.cjs +1 -1
- package/dist/cjs/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.cjs +1 -1
- package/dist/cjs/ScrollTo/Horizontal/ScrollToHorizontal.cjs +1 -1
- package/dist/cjs/ScrollTo/Vertical/ScrollToVertical.cjs +1 -1
- package/dist/cjs/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.cjs +1 -1
- package/dist/cjs/ScrollTo/utils.cjs +2 -2
- package/dist/cjs/Section/Section.cjs +1 -1
- package/dist/cjs/Select/Option.cjs +1 -1
- package/dist/cjs/Select/OptionGroup.cjs +1 -1
- package/dist/cjs/Select/Select.cjs +1 -1
- package/dist/cjs/SelectionList/SelectionList.cjs +1 -1
- package/dist/cjs/SimpleGrid/SimpleGrid.cjs +1 -1
- package/dist/cjs/Skeleton/Skeleton.cjs +1 -1
- package/dist/cjs/Slider/Slider.cjs +1 -1
- package/dist/cjs/Slider/SliderInput/SliderInput.cjs +1 -1
- package/dist/cjs/Snackbar/Snackbar.cjs +1 -1
- package/dist/cjs/Snackbar/SnackbarContent/SnackbarContent.cjs +1 -1
- package/dist/cjs/SnackbarProvider/SnackbarProvider.cjs +1 -1
- package/dist/cjs/Stack/Stack.cjs +10 -11
- package/dist/cjs/Switch/Switch.cjs +1 -1
- package/dist/cjs/Tab/Tab.cjs +1 -1
- package/dist/cjs/Table/Table.cjs +1 -1
- package/dist/cjs/Table/TableBody/TableBody.cjs +1 -1
- package/dist/cjs/Table/TableCell/TableCell.cjs +1 -1
- package/dist/cjs/Table/TableContainer/TableContainer.cjs +1 -1
- package/dist/cjs/Table/TableHead/TableHead.cjs +1 -1
- package/dist/cjs/Table/TableHeader/TableHeader.cjs +1 -1
- package/dist/cjs/Table/TableRow/TableRow.cjs +1 -1
- package/dist/cjs/Table/hooks/useRowExpand.cjs +1 -1
- package/dist/cjs/Table/hooks/useRowSelection.cjs +7 -7
- package/dist/cjs/Table/renderers/DateColumnCell/DateColumnCell.cjs +1 -1
- package/dist/cjs/Table/renderers/DropdownColumnCell/DropdownColumnCell.cjs +1 -1
- package/dist/cjs/Table/renderers/ProgressColumnCell/ProgressColumnCell.cjs +1 -1
- package/dist/cjs/Table/renderers/SwitchColumnCell/SwitchColumnCell.cjs +1 -1
- package/dist/cjs/Table/renderers/renderers.cjs +1 -1
- package/dist/cjs/TableSection/TableSection.cjs +1 -1
- package/dist/cjs/TableSection/TableSection.styles.cjs +1 -1
- package/dist/cjs/Tabs/Tabs.cjs +1 -1
- package/dist/cjs/Tag/Tag.cjs +1 -1
- package/dist/cjs/TagsInput/TagsInput.cjs +2 -2
- package/dist/cjs/TextArea/TextArea.cjs +1 -1
- package/dist/cjs/TimeAgo/TimeAgo.cjs +1 -1
- package/dist/cjs/TimePicker/Placeholder.cjs +1 -1
- package/dist/cjs/TimePicker/TimePicker.cjs +1 -1
- package/dist/cjs/TimePicker/Unit/Unit.cjs +1 -1
- package/dist/cjs/ToggleButton/ToggleButton.cjs +1 -1
- package/dist/cjs/Tooltip/Tooltip.cjs +1 -1
- package/dist/cjs/TreeView/TreeItem/DefaultContent.cjs +1 -1
- package/dist/cjs/TreeView/TreeItem/TreeItem.cjs +1 -1
- package/dist/cjs/TreeView/TreeView.cjs +1 -1
- package/dist/cjs/TreeView/internals/DescendantProvider.cjs +2 -2
- package/dist/cjs/TreeView/internals/TreeViewProvider.cjs +1 -1
- package/dist/cjs/Typography/Typography.cjs +1 -1
- package/dist/cjs/VerticalNavigation/Actions/Action.cjs +13 -11
- package/dist/cjs/VerticalNavigation/Actions/Action.styles.cjs +4 -4
- package/dist/cjs/VerticalNavigation/Actions/Actions.cjs +9 -9
- package/dist/cjs/VerticalNavigation/Header/Header.cjs +46 -26
- package/dist/cjs/VerticalNavigation/Header/Header.styles.cjs +3 -1
- package/dist/cjs/VerticalNavigation/Navigation/Navigation.cjs +23 -29
- package/dist/cjs/VerticalNavigation/NavigationPopup/NavigationPopup.styles.cjs +0 -8
- package/dist/cjs/VerticalNavigation/NavigationPopup/NavigationPopupContainer.cjs +20 -6
- package/dist/cjs/VerticalNavigation/NavigationSlider/NavigationSlider.cjs +41 -30
- package/dist/cjs/VerticalNavigation/NavigationSlider/NavigationSlider.styles.cjs +6 -9
- package/dist/cjs/VerticalNavigation/TreeView/IconWrapper/IconWrapper.cjs +7 -18
- package/dist/cjs/VerticalNavigation/TreeView/TreeView.cjs +614 -631
- package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.cjs +39 -26
- package/dist/cjs/VerticalNavigation/TreeView/TreeViewItem.styles.cjs +25 -13
- package/dist/cjs/VerticalNavigation/VerticalNavigation.cjs +1 -1
- package/dist/cjs/hocs/withTooltip.cjs +1 -1
- package/dist/cjs/hooks/useEmotionCache.cjs +1 -1
- package/dist/cjs/hooks/useTheme.cjs +1 -1
- package/dist/cjs/providers/Provider.cjs +1 -1
- package/dist/cjs/providers/ThemeProvider.cjs +1 -1
- package/dist/cjs/utils/focusableElementFinder.cjs +1 -1
- package/dist/cjs/utils/iconVariant.cjs +1 -1
- package/dist/esm/Accordion/Accordion.js +1 -1
- package/dist/esm/ActionBar/ActionBar.js +1 -1
- package/dist/esm/ActionsGeneric/ActionsGeneric.js +1 -1
- package/dist/esm/AppSwitcher/Action/Action.js +1 -1
- package/dist/esm/AppSwitcher/AppSwitcher.js +2 -2
- package/dist/esm/AppSwitcher/AppSwitcher.js.map +1 -1
- package/dist/esm/Avatar/Avatar.js +1 -1
- package/dist/esm/AvatarGroup/AvatarGroup.js +1 -1
- package/dist/esm/AvatarGroup/AvatarGroupContext.js +1 -1
- package/dist/esm/Badge/Badge.js +1 -1
- package/dist/esm/Banner/Banner.js +1 -1
- package/dist/esm/Banner/BannerContent/ActionContainer/ActionContainer.js +1 -1
- package/dist/esm/Banner/BannerContent/BannerContent.js +1 -1
- package/dist/esm/Banner/BannerContent/MessageContainer/MessageContainer.js +1 -1
- package/dist/esm/BaseCheckBox/BaseCheckBox.js +1 -1
- package/dist/esm/BaseCheckBox/icons.js +1 -1
- package/dist/esm/BaseDropdown/BaseDropdown.js +1 -1
- package/dist/esm/BaseInput/BaseInput.js +1 -1
- package/dist/esm/BaseRadio/BaseRadio.js +1 -1
- package/dist/esm/BaseRadio/icons.js +1 -1
- package/dist/esm/BaseSwitch/BaseSwitch.js +1 -1
- package/dist/esm/Box/Box.js +1 -1
- package/dist/esm/BreadCrumb/BreadCrumb.js +1 -1
- package/dist/esm/BreadCrumb/Page/Page.js +1 -1
- package/dist/esm/BreadCrumb/PathElement/PathElement.js +1 -1
- package/dist/esm/BreadCrumb/utils.js +1 -1
- package/dist/esm/BulkActions/BulkActions.js +1 -1
- package/dist/esm/BulkActions/BulkActions.styles.js +1 -1
- package/dist/esm/Button/Button.js +1 -1
- package/dist/esm/Calendar/Calendar.js +10 -4
- package/dist/esm/Calendar/Calendar.js.map +1 -1
- package/dist/esm/Calendar/CalendarHeader/CalendarHeader.js +1 -1
- package/dist/esm/Calendar/CalendarNavigation/ComposedNavigation/ComposedNavigation.js +1 -1
- package/dist/esm/Calendar/CalendarNavigation/MonthSelector/MonthSelector.js +1 -1
- package/dist/esm/Calendar/CalendarNavigation/Navigation/Navigation.js +1 -1
- package/dist/esm/Calendar/SingleCalendar/CalendarCell.js +2 -2
- package/dist/esm/Calendar/SingleCalendar/CalendarCell.js.map +1 -1
- package/dist/esm/Calendar/SingleCalendar/SingleCalendar.js +1 -1
- package/dist/esm/Card/Card.js +1 -1
- package/dist/esm/Card/Content/Content.js +1 -1
- package/dist/esm/Card/Header/Header.js +1 -1
- package/dist/esm/Card/Media/Media.js +1 -7
- package/dist/esm/Card/Media/Media.js.map +1 -1
- package/dist/esm/Carousel/Carousel.js +1 -1
- package/dist/esm/Carousel/CarouselControls.js +1 -1
- package/dist/esm/Carousel/CarouselSlide/CarouselSlide.js +1 -1
- package/dist/esm/Carousel/CarouselThumbnails.js +1 -1
- package/dist/esm/CheckBox/CheckBox.js +1 -1
- package/dist/esm/CheckBoxGroup/CheckBoxGroup.js +1 -1
- package/dist/esm/ColorPicker/ColorPicker.js +1 -1
- package/dist/esm/ColorPicker/Fields/Fields.js +1 -1
- package/dist/esm/ColorPicker/Picker/Picker.js +1 -1
- package/dist/esm/ColorPicker/PresetColors/PresetColors.js +1 -1
- package/dist/esm/ColorPicker/SavedColors/SavedColors.js +1 -1
- package/dist/esm/Container/Container.js +1 -1
- package/dist/esm/Controls/Controls.js +1 -1
- package/dist/esm/Controls/LeftControl/LeftControl.js +1 -1
- package/dist/esm/Controls/RightControl/RightControl.js +1 -1
- package/dist/esm/DatePicker/DatePicker.js +1 -1
- package/dist/esm/Dialog/Actions/Actions.js +1 -1
- package/dist/esm/Dialog/Content/Content.js +1 -1
- package/dist/esm/Dialog/Dialog.js +1 -1
- package/dist/esm/Dialog/Title/Title.js +1 -1
- package/dist/esm/DotPagination/DotPagination.js +1 -1
- package/dist/esm/Drawer/Drawer.js +1 -1
- package/dist/esm/DropDownMenu/DropDownMenu.js +1 -1
- package/dist/esm/Dropdown/Dropdown.js +1 -1
- package/dist/esm/Dropdown/List/List.js +1 -1
- package/dist/esm/DropdownButton/DropdownButton.js +1 -1
- package/dist/esm/EmptyState/EmptyState.js +1 -1
- package/dist/esm/FileUploader/DropZone/DropZone.js +1 -1
- package/dist/esm/FileUploader/File/File.js +1 -1
- package/dist/esm/FileUploader/FileList/FileList.js +1 -1
- package/dist/esm/FileUploader/FileUploader.js +1 -1
- package/dist/esm/FileUploader/Preview/Preview.js +1 -1
- package/dist/esm/FilterGroup/Counter/Counter.js +1 -1
- package/dist/esm/FilterGroup/FilterContent/FilterContent.js +1 -1
- package/dist/esm/FilterGroup/FilterGroup.js +1 -1
- package/dist/esm/FilterGroup/FilterGroupContext.js +1 -1
- package/dist/esm/FilterGroup/LeftPanel/LeftPanel.js +1 -1
- package/dist/esm/FilterGroup/RightPanel/RightPanel.js +1 -1
- package/dist/esm/Focus/Focus.js +2 -3
- package/dist/esm/Focus/Focus.js.map +1 -1
- package/dist/esm/Footer/Footer.js +1 -1
- package/dist/esm/Forms/Adornment/Adornment.js +1 -1
- package/dist/esm/Forms/CharCounter/CharCounter.js +1 -1
- package/dist/esm/Forms/FormElement/FormElement.js +1 -1
- package/dist/esm/Forms/InfoMessage/InfoMessage.js +1 -1
- package/dist/esm/Forms/Label/Label.js +1 -1
- package/dist/esm/Forms/Suggestions/Suggestions.js +1 -1
- package/dist/esm/Forms/WarningText/WarningText.js +1 -1
- package/dist/esm/GlobalActions/GlobalActions.js +1 -1
- package/dist/esm/Grid/Grid.js +5 -8
- package/dist/esm/Grid/Grid.js.map +1 -1
- package/dist/esm/Header/Actions/Actions.js +1 -1
- package/dist/esm/Header/Brand/Brand.js +1 -1
- package/dist/esm/Header/Header.js +1 -1
- package/dist/esm/Header/Navigation/MenuBar/Bar.js +1 -1
- package/dist/esm/Header/Navigation/MenuBar/MenuBar.js +1 -1
- package/dist/esm/Header/Navigation/MenuItem/MenuItem.js +2 -2
- package/dist/esm/Header/Navigation/MenuItem/MenuItem.js.map +1 -1
- package/dist/esm/Header/Navigation/Navigation.js +1 -1
- package/dist/esm/Header/Navigation/useSelectionPath.js +1 -1
- package/dist/esm/Header/Navigation/useSelectionPath.js.map +1 -1
- package/dist/esm/Header/Navigation/utils/FocusContext.js +1 -1
- package/dist/esm/IconButton/IconButton.js +1 -1
- package/dist/esm/InlineEditor/InlineEditor.js +1 -1
- package/dist/esm/Input/Input.js +1 -1
- package/dist/esm/Kpi/Kpi.js +1 -1
- package/dist/esm/Link/Link.js +1 -1
- package/dist/esm/Link/Link.js.map +1 -1
- package/dist/esm/List/List.js +1 -1
- package/dist/esm/List/utils.js +1 -1
- package/dist/esm/List/utils.js.map +1 -1
- package/dist/esm/ListContainer/ListContainer.js +1 -1
- package/dist/esm/ListContainer/ListItem/ListItem.js +1 -1
- package/dist/esm/Loading/Loading.js +1 -1
- package/dist/esm/LoadingContainer/LoadingContainer.js +1 -1
- package/dist/esm/Login/Login.js +1 -1
- package/dist/esm/MultiButton/MultiButton.js +1 -1
- package/dist/esm/OverflowTooltip/OverflowTooltip.js +1 -1
- package/dist/esm/Pagination/Pagination.js +1 -1
- package/dist/esm/Pagination/Select.js +1 -1
- package/dist/esm/Panel/Panel.js +1 -1
- package/dist/esm/ProgressBar/ProgressBar.js +1 -1
- package/dist/esm/QueryBuilder/ConfirmationDialog/ConfirmationDialog.js +1 -1
- package/dist/esm/QueryBuilder/Context.js +1 -1
- package/dist/esm/QueryBuilder/QueryBuilder.js +1 -1
- package/dist/esm/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/esm/QueryBuilder/Rule/Attribute/Attribute.js +1 -1
- package/dist/esm/QueryBuilder/Rule/Operator/Operator.js +1 -1
- package/dist/esm/QueryBuilder/Rule/Rule.js +1 -1
- package/dist/esm/QueryBuilder/Rule/Value/BooleanValue/BooleanValue.js +1 -1
- package/dist/esm/QueryBuilder/Rule/Value/DateTimeValue/DateTimeValue.js +1 -1
- package/dist/esm/QueryBuilder/Rule/Value/NumericValue/NumericValue.js +1 -1
- package/dist/esm/QueryBuilder/Rule/Value/TextValue/TextValue.js +1 -1
- package/dist/esm/QueryBuilder/Rule/Value/Value.js +1 -1
- package/dist/esm/QueryBuilder/RuleGroup/RuleGroup.js +1 -1
- package/dist/esm/QueryBuilder/utils/index.js +1 -1
- package/dist/esm/QueryBuilder/utils/index.js.map +1 -1
- package/dist/esm/Radio/Radio.js +1 -1
- package/dist/esm/RadioGroup/RadioGroup.js +1 -1
- package/dist/esm/ScrollTo/Horizontal/HorizontalScrollListItem/HorizontalScrollListItem.js +1 -1
- package/dist/esm/ScrollTo/Horizontal/ScrollToHorizontal.js +1 -1
- package/dist/esm/ScrollTo/Vertical/ScrollToVertical.js +1 -1
- package/dist/esm/ScrollTo/Vertical/VerticalScrollListItem/VerticalScrollListItem.js +1 -1
- package/dist/esm/ScrollTo/useScrollTo.js.map +1 -1
- package/dist/esm/ScrollTo/utils.js +2 -2
- package/dist/esm/ScrollTo/utils.js.map +1 -1
- package/dist/esm/Section/Section.js +1 -1
- package/dist/esm/Select/Option.js +1 -1
- package/dist/esm/Select/OptionGroup.js +1 -1
- package/dist/esm/Select/Select.js +1 -1
- package/dist/esm/SelectionList/SelectionList.js +1 -1
- package/dist/esm/SimpleGrid/SimpleGrid.js +1 -1
- package/dist/esm/Skeleton/Skeleton.js +1 -1
- package/dist/esm/Slider/Slider.js +1 -1
- package/dist/esm/Slider/SliderInput/SliderInput.js +1 -1
- package/dist/esm/Slider/utils.js.map +1 -1
- package/dist/esm/Snackbar/Snackbar.js +1 -1
- package/dist/esm/Snackbar/SnackbarContent/SnackbarContent.js +1 -1
- package/dist/esm/SnackbarProvider/SnackbarProvider.js +1 -1
- package/dist/esm/Stack/Stack.js +10 -11
- package/dist/esm/Stack/Stack.js.map +1 -1
- package/dist/esm/Switch/Switch.js +1 -1
- package/dist/esm/Tab/Tab.js +1 -1
- package/dist/esm/Table/Table.js +1 -1
- package/dist/esm/Table/TableBody/TableBody.js +1 -1
- package/dist/esm/Table/TableCell/TableCell.js +1 -1
- package/dist/esm/Table/TableContainer/TableContainer.js +1 -1
- package/dist/esm/Table/TableHead/TableHead.js +1 -1
- package/dist/esm/Table/TableHeader/TableHeader.js +1 -1
- package/dist/esm/Table/TableRow/TableRow.js +1 -1
- package/dist/esm/Table/hooks/useRowExpand.js +1 -1
- package/dist/esm/Table/hooks/useRowSelection.js +7 -7
- package/dist/esm/Table/hooks/useRowSelection.js.map +1 -1
- package/dist/esm/Table/renderers/DateColumnCell/DateColumnCell.js +1 -1
- package/dist/esm/Table/renderers/DropdownColumnCell/DropdownColumnCell.js +1 -1
- package/dist/esm/Table/renderers/ProgressColumnCell/ProgressColumnCell.js +1 -1
- package/dist/esm/Table/renderers/SwitchColumnCell/SwitchColumnCell.js +1 -1
- package/dist/esm/Table/renderers/renderers.js +1 -1
- package/dist/esm/Table/renderers/renderers.js.map +1 -1
- package/dist/esm/TableSection/TableSection.js +1 -1
- package/dist/esm/TableSection/TableSection.styles.js +1 -1
- package/dist/esm/Tabs/Tabs.js +1 -1
- package/dist/esm/Tag/Tag.js +1 -1
- package/dist/esm/TagsInput/TagsInput.js +2 -2
- package/dist/esm/TagsInput/TagsInput.js.map +1 -1
- package/dist/esm/TextArea/TextArea.js +1 -1
- package/dist/esm/TimeAgo/TimeAgo.js +1 -1
- package/dist/esm/TimePicker/Placeholder.js +1 -1
- package/dist/esm/TimePicker/TimePicker.js +1 -1
- package/dist/esm/TimePicker/Unit/Unit.js +1 -1
- package/dist/esm/ToggleButton/ToggleButton.js +1 -1
- package/dist/esm/Tooltip/Tooltip.js +1 -1
- package/dist/esm/TreeView/TreeItem/DefaultContent.js +1 -1
- package/dist/esm/TreeView/TreeItem/TreeItem.js +1 -1
- package/dist/esm/TreeView/TreeView.js +1 -1
- package/dist/esm/TreeView/internals/DescendantProvider.js +2 -2
- package/dist/esm/TreeView/internals/DescendantProvider.js.map +1 -1
- package/dist/esm/TreeView/internals/TreeViewProvider.js +1 -1
- package/dist/esm/Typography/Typography.js +1 -1
- package/dist/esm/VerticalNavigation/Actions/Action.js +13 -11
- package/dist/esm/VerticalNavigation/Actions/Action.js.map +1 -1
- package/dist/esm/VerticalNavigation/Actions/Action.styles.js +4 -4
- package/dist/esm/VerticalNavigation/Actions/Action.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/Actions/Actions.js +9 -9
- package/dist/esm/VerticalNavigation/Actions/Actions.js.map +1 -1
- package/dist/esm/VerticalNavigation/Header/Header.js +46 -26
- package/dist/esm/VerticalNavigation/Header/Header.js.map +1 -1
- package/dist/esm/VerticalNavigation/Header/Header.styles.js +3 -1
- package/dist/esm/VerticalNavigation/Header/Header.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/Navigation/Navigation.js +23 -29
- package/dist/esm/VerticalNavigation/Navigation/Navigation.js.map +1 -1
- package/dist/esm/VerticalNavigation/NavigationPopup/NavigationPopup.styles.js +0 -6
- package/dist/esm/VerticalNavigation/NavigationPopup/NavigationPopup.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/NavigationPopup/NavigationPopupContainer.js +21 -7
- package/dist/esm/VerticalNavigation/NavigationPopup/NavigationPopupContainer.js.map +1 -1
- package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.js +41 -30
- package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.js.map +1 -1
- package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.styles.js +6 -9
- package/dist/esm/VerticalNavigation/NavigationSlider/NavigationSlider.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/IconWrapper/IconWrapper.js +7 -18
- package/dist/esm/VerticalNavigation/TreeView/IconWrapper/IconWrapper.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeView.js +614 -631
- package/dist/esm/VerticalNavigation/TreeView/TreeView.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeView.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js +39 -26
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.js.map +1 -1
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.styles.js +25 -13
- package/dist/esm/VerticalNavigation/TreeView/TreeViewItem.styles.js.map +1 -1
- package/dist/esm/VerticalNavigation/VerticalNavigation.js +1 -1
- package/dist/esm/VerticalNavigation/VerticalNavigation.js.map +1 -1
- package/dist/esm/hocs/withTooltip.js +1 -1
- package/dist/esm/hooks/useEmotionCache.js +1 -1
- package/dist/esm/hooks/useTheme.js +1 -1
- package/dist/esm/providers/Provider.js +1 -1
- package/dist/esm/providers/ThemeProvider.js +1 -1
- package/dist/esm/types/generic.js.map +1 -1
- package/dist/esm/utils/focusableElementFinder.js +1 -1
- package/dist/esm/utils/focusableElementFinder.js.map +1 -1
- package/dist/esm/utils/iconVariant.js +1 -1
- package/dist/types/index.d.ts +82 -231
- package/package.json +5 -5
- package/dist/cjs/VerticalNavigation/TreeView/IconWrapper/IconWrapper.styles.cjs +0 -20
- package/dist/esm/VerticalNavigation/TreeView/IconWrapper/IconWrapper.styles.js +0 -18
- package/dist/esm/VerticalNavigation/TreeView/IconWrapper/IconWrapper.styles.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useDefaultProps } from "../../../hooks/useDefaultProps.js";
|
|
3
3
|
import { useClasses } from "./VerticalScrollListItem.styles.js";
|
|
4
4
|
import { staticClasses } from "./VerticalScrollListItem.styles.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollTo.js","sources":["../../../src/ScrollTo/useScrollTo.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { HvScrollToOption } from \"./types\";\nimport {\n findFirstVisibleElement,\n getScrollTop,\n isScrolledToTheBottom,\n scrollElement,\n verticalScrollOffset,\n} from \"./utils\";\n\ninterface HvScrollToOptionWithLink extends HvScrollToOption {\n href: string;\n}\n\nexport const useScrollTo = (\n selectedIndexProp: number = 0,\n scrollElementId: string | undefined = undefined,\n navigationMode: \"push\" | \"replace\" | \"none\" = \"push\",\n relativeLinks: boolean = false,\n offset: number = 0,\n options: HvScrollToOption[] = [],\n onChange:\n | ((\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void)\n | undefined = undefined,\n direction: \"column\" | \"row\" = \"column\",\n): [\n number,\n (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n id: string,\n index: number,\n wrappedOnChange?: (index: number) => void,\n ) => void,\n HvScrollToOptionWithLink[],\n] => {\n const RETRY_MAX: number = 5;\n const [selectedIndex, setSelectedIndex] = useState<number>(selectedIndexProp);\n\n const scrollEle = useRef<HTMLElement | (Window & typeof globalThis)>(window);\n const requestedAnimationFrame = useRef(0);\n const lastContainerScrollTop = useRef<number>(0);\n\n // Ref to use a often-changing value in useCallback, as recommended in\n // https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n const selectedIndexRef = useRef(selectedIndex);\n\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n useEffect(() => {\n scrollEle.current =\n (scrollElementId && document.getElementById(scrollElementId)) || window;\n\n lastContainerScrollTop.current = verticalScrollOffset(scrollEle.current);\n }, [scrollElementId]);\n\n const checkScroll = useCallback(\n (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n ) => {\n if (\n requestedAnimationFrame.current === 0 &&\n window?.requestAnimationFrame\n ) {\n requestedAnimationFrame.current = window.requestAnimationFrame(() => {\n requestedAnimationFrame.current = 0;\n\n const firstVisibleElementIndex = findFirstVisibleElement(\n scrollEle.current,\n options,\n offset,\n );\n\n let newSelectedIndex = firstVisibleElementIndex;\n\n // select the first element when all elements are bellow the container's top\n if (firstVisibleElementIndex < 0) {\n newSelectedIndex = 0;\n }\n\n // if the user has reached the bottom of the container, select the first nav item still visible\n // (usually this selects the last nav item, when it can't reach the top the container)\n // in theory only needed when scrolling down, but no... because of the Safari bouncing behaviour\n if (\n newSelectedIndex < options.length - 1 &&\n isScrolledToTheBottom(scrollEle.current)\n ) {\n newSelectedIndex += 1;\n }\n\n const containerScrollTop = getScrollTop(scrollEle.current);\n const isScrollingDown =\n containerScrollTop > lastContainerScrollTop.current;\n lastContainerScrollTop.current = containerScrollTop;\n\n // only update the selected item if the scroll direction is moving away from it\n if (isScrollingDown) {\n if (newSelectedIndex < selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n } else if (newSelectedIndex > selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n\n setSelectedIndex(newSelectedIndex);\n onChange?.(event, newSelectedIndex);\n });\n }\n },\n [offset, options, onChange],\n );\n\n // Registers and unregisters the scroll listener\n useEffect(() => {\n if (scrollEle.current) {\n scrollEle.current.addEventListener(\"scroll\", checkScroll, false);\n }\n\n return () => {\n if (scrollEle.current) {\n scrollEle.current.removeEventListener(\"scroll\", checkScroll);\n }\n\n if (requestedAnimationFrame.current !== 0) {\n window.cancelAnimationFrame(requestedAnimationFrame.current);\n requestedAnimationFrame.current = 0;\n }\n };\n }, [checkScroll]);\n\n // Waits for the elements to be rendered and scrolls to the one referenced in the URL hash, if any\n useEffect(() => {\n let checkRenderedInterval: any;\n\n if (navigationMode !== \"none\") {\n const hashValue = document.location.hash.split(\"#\")[1] || \"\";\n\n const option = options.find((o) => o.value === hashValue);\n\n if (option) {\n let retry = 0;\n checkRenderedInterval = setInterval(() => {\n const ele = document.getElementById(option.value);\n\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset);\n clearInterval(checkRenderedInterval);\n } else {\n retry += 1;\n if (retry === RETRY_MAX) {\n clearInterval(checkRenderedInterval);\n }\n }\n }, 1000);\n }\n }\n\n return () => {\n clearInterval(checkRenderedInterval);\n };\n\n // We really want to run this just in the first load\n // in fact this doesn't even belong here, the logic should be external\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const baseUrl =\n relativeLinks || window == null ? \"\" : window.location.href.split(\"#\")[0];\n\n const elements = useMemo(\n () =>\n options.map((o) => ({\n ...o,\n href: `${baseUrl}#${o.value}`,\n })),\n [options, baseUrl],\n );\n\n const setScrollTo = useCallback(\n (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n id: string,\n index: number,\n wrappedOnChange?: (index: number) => void,\n ) => {\n const option = elements.find((o) => o.value === id);\n\n if (option) {\n const ele = document.getElementById(id);\n if (ele) {\n scrollElement(\n ele,\n scrollEle.current,\n option.offset || offset,\n direction,\n );\n }\n\n if (navigationMode === \"push\") {\n window.history.pushState({}, \"\", option.href);\n } else if (navigationMode === \"replace\") {\n window.history.replaceState({}, \"\", option.href);\n }\n\n setSelectedIndex(index);\n wrappedOnChange?.(index);\n\n // Safari scrolls immediately (no smooth scroll support),\n // so this ref value must be updated asap\n selectedIndexRef.current = index;\n }\n },\n [elements, navigationMode, direction, offset],\n );\n\n return [selectedIndex, setScrollTo, elements];\n};\n"],"names":[],"mappings":";;AAeO,MAAM,cAAc,CACzB,oBAA4B,GAC5B,kBAAsC,QACtC,iBAA8C,QAC9C,gBAAyB,OACzB,SAAiB,GACjB,UAA8B,IAC9B,WAQgB,QAChB,YAA8B,aAY3B;AACH,QAAM,YAAoB;AAC1B,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAiB,iBAAiB;AAEtE,QAAA,YAAY,OAAmD,MAAM;AACrE,QAAA,0BAA0B,OAAO,CAAC;AAClC,QAAA,yBAAyB,OAAe,CAAC;AAIzC,QAAA,mBAAmB,OAAO,aAAa;AAE7C,YAAU,MAAM;AACd,qBAAiB,UAAU;AAAA,EAAA,GAC1B,CAAC,aAAa,CAAC;AAElB,YAAU,MAAM;AACd,cAAU,UACP,mBAAmB,SAAS,eAAe,eAAe,KAAM;AAE5C,2BAAA,UAAU,qBAAqB,UAAU,OAAO;AAAA,EAAA,GACtE,CAAC,eAAe,CAAC;AAEpB,QAAM,cAAc;AAAA,IAClB,CACE,UAIG;AACH,UACE,wBAAwB,YAAY,KACpC,QAAQ,uBACR;AACwB,gCAAA,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;AAAA,IACA,CAAC,UAAU,gBAAgB,WAAW,MAAM;AAAA,EAAA;AAGvC,SAAA,CAAC,eAAe,aAAa,QAAQ;AAC9C;"}
|
|
1
|
+
{"version":3,"file":"useScrollTo.js","sources":["../../../src/ScrollTo/useScrollTo.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { HvScrollToOption } from \"./types\";\nimport {\n findFirstVisibleElement,\n getScrollTop,\n isScrolledToTheBottom,\n scrollElement,\n verticalScrollOffset,\n} from \"./utils\";\n\ninterface HvScrollToOptionWithLink extends HvScrollToOption {\n href: string;\n}\n\nexport const useScrollTo = (\n selectedIndexProp = 0,\n scrollElementId: string | undefined = undefined,\n navigationMode: \"push\" | \"replace\" | \"none\" = \"push\",\n relativeLinks = false,\n offset = 0,\n options: HvScrollToOption[] = [],\n onChange:\n | ((\n event:\n | Event\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n index: number,\n ) => void)\n | undefined = undefined,\n direction: \"column\" | \"row\" = \"column\",\n): [\n number,\n (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n id: string,\n index: number,\n wrappedOnChange?: (index: number) => void,\n ) => void,\n HvScrollToOptionWithLink[],\n] => {\n const RETRY_MAX: number = 5;\n const [selectedIndex, setSelectedIndex] = useState<number>(selectedIndexProp);\n\n const scrollEle = useRef<HTMLElement | (Window & typeof globalThis)>(window);\n const requestedAnimationFrame = useRef(0);\n const lastContainerScrollTop = useRef<number>(0);\n\n // Ref to use a often-changing value in useCallback, as recommended in\n // https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback\n const selectedIndexRef = useRef(selectedIndex);\n\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n useEffect(() => {\n scrollEle.current =\n (scrollElementId && document.getElementById(scrollElementId)) || window;\n\n lastContainerScrollTop.current = verticalScrollOffset(scrollEle.current);\n }, [scrollElementId]);\n\n const checkScroll = useCallback(\n (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n ) => {\n if (\n requestedAnimationFrame.current === 0 &&\n window?.requestAnimationFrame\n ) {\n requestedAnimationFrame.current = window.requestAnimationFrame(() => {\n requestedAnimationFrame.current = 0;\n\n const firstVisibleElementIndex = findFirstVisibleElement(\n scrollEle.current,\n options,\n offset,\n );\n\n let newSelectedIndex = firstVisibleElementIndex;\n\n // select the first element when all elements are bellow the container's top\n if (firstVisibleElementIndex < 0) {\n newSelectedIndex = 0;\n }\n\n // if the user has reached the bottom of the container, select the first nav item still visible\n // (usually this selects the last nav item, when it can't reach the top the container)\n // in theory only needed when scrolling down, but no... because of the Safari bouncing behaviour\n if (\n newSelectedIndex < options.length - 1 &&\n isScrolledToTheBottom(scrollEle.current)\n ) {\n newSelectedIndex += 1;\n }\n\n const containerScrollTop = getScrollTop(scrollEle.current);\n const isScrollingDown =\n containerScrollTop > lastContainerScrollTop.current;\n lastContainerScrollTop.current = containerScrollTop;\n\n // only update the selected item if the scroll direction is moving away from it\n if (isScrollingDown) {\n if (newSelectedIndex < selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n } else if (newSelectedIndex > selectedIndexRef.current) {\n newSelectedIndex = selectedIndexRef.current;\n }\n\n setSelectedIndex(newSelectedIndex);\n onChange?.(event, newSelectedIndex);\n });\n }\n },\n [offset, options, onChange],\n );\n\n // Registers and unregisters the scroll listener\n useEffect(() => {\n if (scrollEle.current) {\n scrollEle.current.addEventListener(\"scroll\", checkScroll, false);\n }\n\n return () => {\n if (scrollEle.current) {\n scrollEle.current.removeEventListener(\"scroll\", checkScroll);\n }\n\n if (requestedAnimationFrame.current !== 0) {\n window.cancelAnimationFrame(requestedAnimationFrame.current);\n requestedAnimationFrame.current = 0;\n }\n };\n }, [checkScroll]);\n\n // Waits for the elements to be rendered and scrolls to the one referenced in the URL hash, if any\n useEffect(() => {\n let checkRenderedInterval: any;\n\n if (navigationMode !== \"none\") {\n const hashValue = document.location.hash.split(\"#\")[1] || \"\";\n\n const option = options.find((o) => o.value === hashValue);\n\n if (option) {\n let retry = 0;\n checkRenderedInterval = setInterval(() => {\n const ele = document.getElementById(option.value);\n\n if (ele) {\n scrollElement(ele, scrollEle.current, option.offset || offset);\n clearInterval(checkRenderedInterval);\n } else {\n retry += 1;\n if (retry === RETRY_MAX) {\n clearInterval(checkRenderedInterval);\n }\n }\n }, 1000);\n }\n }\n\n return () => {\n clearInterval(checkRenderedInterval);\n };\n\n // We really want to run this just in the first load\n // in fact this doesn't even belong here, the logic should be external\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const baseUrl =\n relativeLinks || window == null ? \"\" : window.location.href.split(\"#\")[0];\n\n const elements = useMemo(\n () =>\n options.map((o) => ({\n ...o,\n href: `${baseUrl}#${o.value}`,\n })),\n [options, baseUrl],\n );\n\n const setScrollTo = useCallback(\n (\n event:\n | React.MouseEvent<HTMLDivElement | HTMLAnchorElement>\n | React.KeyboardEvent<HTMLDivElement | HTMLAnchorElement>,\n id: string,\n index: number,\n wrappedOnChange?: (index: number) => void,\n ) => {\n const option = elements.find((o) => o.value === id);\n\n if (option) {\n const ele = document.getElementById(id);\n if (ele) {\n scrollElement(\n ele,\n scrollEle.current,\n option.offset || offset,\n direction,\n );\n }\n\n if (navigationMode === \"push\") {\n window.history.pushState({}, \"\", option.href);\n } else if (navigationMode === \"replace\") {\n window.history.replaceState({}, \"\", option.href);\n }\n\n setSelectedIndex(index);\n wrappedOnChange?.(index);\n\n // Safari scrolls immediately (no smooth scroll support),\n // so this ref value must be updated asap\n selectedIndexRef.current = index;\n }\n },\n [elements, navigationMode, direction, offset],\n );\n\n return [selectedIndex, setScrollTo, elements];\n};\n"],"names":[],"mappings":";;AAeO,MAAM,cAAc,CACzB,oBAAoB,GACpB,kBA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AAAA,IAAA,EAC3B;AAAA,IACJ,CAAC,SAAS,OAAO;AAAA,EAAA;AAGnB,QAAM,cAAc;AAAA,IAClB,CACE,OAGA,IACA,OACA,oBACG;AACH,YAAM,SAAS,SAAS,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE;AAElD,UAAI,QAAQ;AACJ,cAAA,MAAM,SAAS,eAAe,EAAE;AACtC,YAAI,KAAK;AACP;AAAA,YACE;AAAA,YACA,UAAU;AAAA,YACV,OAAO,UAAU;AAAA,YACjB;AAAA,UAAA;AAAA,QAEJ;AAEA,YAAI,mBAAmB,QAAQ;AAC7B,iBAAO,QAAQ,UAAU,CAAA,GAAI,IAAI,OAAO,IAAI;AAAA,QAAA,WACnC,mBAAmB,WAAW;AACvC,iBAAO,QAAQ,aAAa,CAAA,GAAI,IAAI,OAAO,IAAI;AAAA,QACjD;AAEA,yBAAiB,KAAK;AACtB,0BAAkB,KAAK;AAIvB,yBAAiB,UAAU;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,UAAU,gBAAgB,WAAW,MAAM;AAAA,EAAA;AAGvC,SAAA,CAAC,eAAe,aAAa,QAAQ;AAC9C;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const getScrollTop = (c = window) => {
|
|
2
2
|
if (c === window) {
|
|
3
|
-
return window.scrollY || window.pageYOffset || document.documentElement
|
|
3
|
+
return window.scrollY || window.pageYOffset || document.documentElement?.scrollTop || document.body.scrollTop;
|
|
4
4
|
}
|
|
5
5
|
return c.scrollTop;
|
|
6
6
|
};
|
|
@@ -41,7 +41,7 @@ const scrollElement = (element, container, offset = 0, direction) => {
|
|
|
41
41
|
const isScrolledToTheBottom = (container) => {
|
|
42
42
|
const containerScrollTop = getScrollTop(container);
|
|
43
43
|
if (container === window) {
|
|
44
|
-
const scrollHeight = document.documentElement
|
|
44
|
+
const scrollHeight = document.documentElement?.scrollHeight || document.body.scrollHeight;
|
|
45
45
|
return containerScrollTop + window.innerHeight >= scrollHeight;
|
|
46
46
|
}
|
|
47
47
|
return containerScrollTop + container.offsetHeight >= container.scrollHeight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/ScrollTo/utils.ts"],"sourcesContent":["import { HvScrollToOption } from \"./types\";\n\ntype ExtendedWindow = Window & typeof globalThis & HTMLElement;\n\nexport const getScrollTop = (\n c: HTMLElement | (Window & typeof globalThis) = window,\n) => {\n if (c === window) {\n return (\n window.scrollY ||\n window.pageYOffset ||\n
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/ScrollTo/utils.ts"],"sourcesContent":["import { HvScrollToOption } from \"./types\";\n\ntype ExtendedWindow = Window & typeof globalThis & HTMLElement;\n\nexport const getScrollTop = (\n c: HTMLElement | (Window & typeof globalThis) = window,\n) => {\n if (c === window) {\n return (\n window.scrollY ||\n window.pageYOffset ||\n document.documentElement?.scrollTop ||\n document.body.scrollTop\n );\n }\n\n return (c as ExtendedWindow).scrollTop;\n};\n\nexport const verticalScrollOffset = (\n t: HTMLElement | (Window & typeof globalThis),\n c: HTMLElement | (Window & typeof globalThis) = window,\n) => {\n if (c === window) {\n return (\n ((t as ExtendedWindow)?.getBoundingClientRect?.().top || 0) +\n (window.scrollY || window.pageYOffset)\n );\n }\n if (getComputedStyle(c as ExtendedWindow).position !== \"static\") {\n return (t as ExtendedWindow).offsetTop;\n }\n\n return (t as ExtendedWindow).offsetTop - (c as ExtendedWindow).offsetTop;\n};\n\nexport const horizontalScrollOffset = (\n t: HTMLElement,\n c: HTMLElement | (Window & typeof globalThis) = window,\n) => {\n if (c === window) {\n return (\n (t?.getBoundingClientRect?.().left || 0) +\n (window.scrollX || window.pageXOffset)\n );\n }\n if (getComputedStyle(c as ExtendedWindow).position !== \"static\") {\n return t.offsetLeft;\n }\n\n return t.offsetLeft - (c as ExtendedWindow).offsetLeft;\n};\n\nexport const scrollElement = (\n element: HTMLElement,\n container: HTMLElement | (Window & typeof globalThis),\n offset = 0,\n direction?: \"row\" | \"column\",\n) => {\n if (direction === \"row\") {\n const elemLeft = horizontalScrollOffset(element, container);\n container?.scrollTo?.({\n left: elemLeft - offset,\n behavior: \"smooth\",\n });\n } else {\n const elemTop = verticalScrollOffset(element, container);\n container?.scrollTo?.({\n top: elemTop - offset,\n behavior: \"smooth\",\n });\n }\n element.focus({ preventScroll: true });\n};\n\nexport const isScrolledToTheBottom = (\n container: HTMLElement | (Window & typeof globalThis),\n) => {\n const containerScrollTop = getScrollTop(container);\n\n if (container === window) {\n // Accounting for cases where html/body are set to height:100%\n const scrollHeight =\n document.documentElement?.scrollHeight || document.body.scrollHeight;\n\n return containerScrollTop + window.innerHeight >= scrollHeight;\n }\n\n return (\n containerScrollTop + (container as ExtendedWindow).offsetHeight >=\n (container as ExtendedWindow).scrollHeight\n );\n};\n\nexport const findFirstVisibleElement = (\n container: HTMLElement | (Window & typeof globalThis),\n options: HvScrollToOption[],\n offset: number,\n) => {\n const boundsTop = verticalScrollOffset(container);\n\n let i = 0;\n\n // Find index of first element whose top is still visible inside the container\n for (; i < options.length; i += 1) {\n const ele = document.getElementById(options[i].value);\n\n if (ele) {\n const elemTop = verticalScrollOffset(ele) - (options[i].offset || offset);\n\n if (elemTop > boundsTop) {\n break;\n }\n }\n }\n\n // Return the previous index, the element that last scrolled past the top\n return i - 1;\n};\n"],"names":[],"mappings":"AAIa,MAAA,eAAe,CAC1B,IAAgD,WAC7C;AACH,MAAI,MAAM,QAAQ;AAEd,WAAA,OAAO,WACP,OAAO,eACP,SAAS,iBAAiB,aAC1B,SAAS,KAAK;AAAA,EAElB;AAEA,SAAQ,EAAqB;AAC/B;AAEO,MAAM,uBAAuB,CAClC,GACA,IAAgD,WAC7C;AACH,MAAI,MAAM,QAAQ;AAChB,YACI,GAAsB,wBAAwB,EAAE,OAAO,MACxD,OAAO,WAAW,OAAO;AAAA,EAE9B;AACA,MAAI,iBAAiB,CAAmB,EAAE,aAAa,UAAU;AAC/D,WAAQ,EAAqB;AAAA,EAC/B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AAA,IACF;AAAA,EACF;AAGA,SAAO,IAAI;AACb;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from "
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState, useRef } from "react";
|
|
3
3
|
import { Popper } from "@mui/base/Popper";
|
|
4
4
|
import { useSelect, SelectProvider } from "@mui/base/useSelect";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs, jsx } from "
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useMemo, Children, useRef, useEffect, useCallback, cloneElement } from "react";
|
|
3
3
|
import { useForkRef } from "@mui/material/utils";
|
|
4
4
|
import { useControlled } from "../hooks/useControlled.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useDefaultProps } from "../hooks/useDefaultProps.js";
|
|
3
3
|
import { useClasses, getContainerStyle } from "./SimpleGrid.styles.js";
|
|
4
4
|
import { staticClasses } from "./SimpleGrid.styles.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../src/Slider/utils.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFormStatus } from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { sliderStyles as styles } from \"./Slider.styles\";\nimport { HvKnobProperty, HvMarkProperty } from \"./types\";\n\n/**\n * Transform the scaled values into knobs positions.\n *\n * @param {*} sliderValue - he value of the slider to be scaled\n * @param {*} minPointVlue - The value of the first point in the slider from left to right.\n * @param {*} stepVlue - The calculated separation between the values of the slider.\n */\nexport const knobsPositionToScaledValue = (\n sliderValue: number,\n minPointValue: number,\n stepValue: number,\n): number => minPointValue + stepValue * sliderValue;\n\n/**\n * Transform the scaled values into knobs positions.\n *\n * @param {*} scaledValue - The value of the slider to be scaled\n * @param {*} minPointValue - The value of the first point in\n * the slider from left to right.\n * @param {*} inverseStepValue - The inverse of calculated separation between\n * the value of the points that compose the slider.\n */\nexport const scaledValueToKnobsPositionValue = (\n scaledValue: number | undefined,\n minPointValue: number,\n inverseStepValue: number,\n): number =>\n typeof scaledValue === \"number\"\n ? Math.floor((scaledValue - minPointValue) * inverseStepValue)\n : NaN;\n\n/**\n * Transform the received knobs values into knob positions\n *\n * @param {Object} values - The values of the slider.\n * @param {Number} inverseStepValue - The inverse of calculated separation between\n * the value of the points that compose the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @returns {Array} - The position of the knobs.\n */\nexport const knobsValuesToKnobsPositions = (\n values: (number | undefined)[],\n inverseStepValue: number,\n minPointValue: number,\n): number[] => {\n const knobsPositions: number[] = [];\n\n values.forEach((value, index) => {\n knobsPositions[index] = scaledValueToKnobsPositionValue(\n value,\n minPointValue,\n inverseStepValue,\n );\n });\n\n return knobsPositions;\n};\n\n/**\n * Transform the received knobs positions into knob values\n *\n * @param {Object} knobPositions - The values of the slider.\n * @param {Number} stepValue - The calculated separation between\n * the value of the points that compose the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @returns {Array} - The position of the knobs.\n */\nexport const knobsPositionsToKnobsValues = (\n knobPositions: number[],\n stepValue: number,\n minPointValue: number,\n): number[] => {\n const knobsValues: number[] = [];\n\n knobPositions.forEach((value, index) => {\n knobsValues[index] = knobsPositionToScaledValue(\n value,\n minPointValue,\n stepValue,\n );\n });\n\n return knobsValues;\n};\n\n/**\n * Calculates the separation between each value in the slider.\n *\n * @param {*} maxPointValue - The value of the last point in the slider from left to right.\n * @param {*} minPointValue - The value of the first point in the slider from left to right.\n * @param {*} divisionQuantity - How many subdivisions there are in the slider.\n */\nexport const calculateStepValue = (\n maxPointValue: number,\n minPointValue: number,\n divisionQuantity: number,\n): number => Math.abs(maxPointValue - minPointValue) / divisionQuantity;\n\n/**\n * Generates the inline styles used for the track of each knob, applying colors if necessary.\n *\n * @param {Object} markProperties - The object provided by the user with\n * the desired configuration for the marks.\n * @param {Integer} markstep - The separation between marks.\n * @param {Integer} divisionQuantity - How many subdivisions there are in the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @param {Integer} stepValue - The calculated separation between the values of the slider.\n * @param {Integer} markDigits - How many decimals the mark will show.\n * @param {Function} formatMark - A function provided by the user that is going to\n * be executed to format the mark text.\n * @param {Object} styles - the default styles for the marks.\n * @returns {Object} - An object with the for the marks.\n * @memberof HvSlider\n */\nexport const createMark = (\n markProperties: HvMarkProperty[],\n markstep: number,\n divisionQuantity: number,\n minPointValue: number,\n maxPointValue: number,\n stepValue: number,\n markDigits: number,\n disabled: boolean,\n formatMark: (label: React.ReactNode) => React.ReactNode = (mark) => mark,\n): Record<number, { label: string; style: React.CSSProperties }> => {\n const marks: Record<number, { label: string; style: React.CSSProperties }> =\n {};\n\n const values: string[] = [];\n\n if (markProperties.length > 0) {\n markProperties.forEach((markProperty) => {\n if (typeof markProperty.position === \"number\") {\n marks[markProperty.position] = disabled\n ? {\n label: `${markProperty.label}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${markProperty.label}`,\n style: {\n ...styles.mark,\n },\n };\n }\n });\n } else {\n const roundedMarkStep = Math.floor(markstep);\n\n for (let index = 0; index <= divisionQuantity; index += roundedMarkStep) {\n let labelValue: React.ReactNode = knobsPositionToScaledValue(\n index,\n minPointValue,\n stepValue,\n ).toFixed(markDigits);\n\n values.push(labelValue as string);\n labelValue = formatMark?.(labelValue) || labelValue;\n\n marks[index] = disabled\n ? {\n label: `${labelValue}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${labelValue}`,\n style: {\n ...styles.mark,\n },\n };\n }\n\n if (!values.includes(maxPointValue.toString())) {\n const lastMarkPosition = knobsValuesToKnobsPositions(\n [maxPointValue],\n 1 / stepValue,\n minPointValue,\n );\n\n const lastMarkLabel = formatMark?.(maxPointValue.toFixed(markDigits));\n marks[lastMarkPosition[0]] = disabled\n ? {\n label: `${lastMarkLabel}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${lastMarkLabel}`,\n style: {\n ...styles.mark,\n },\n };\n }\n }\n\n return marks;\n};\n\n/**\n * Generates the inline styles used for the track of each knob, applying colors if necessary.\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Object} styles - the default styles for the tracks.\n * @returns {Object} - An object with the style for each track.\n * @memberof HvSlider\n */\nexport const createTrackStyles = (\n knobProperties: HvKnobProperty[],\n): React.CSSProperties[] => {\n const trackStyles: React.CSSProperties[] = [];\n\n if (knobProperties.length > 0) {\n knobProperties.forEach((knobProperty, index) => {\n trackStyles[index] = { ...styles.track };\n if (knobProperty.color) {\n trackStyles[index].backgroundColor = knobProperty.trackColor;\n }\n });\n }\n\n return trackStyles;\n};\n\n/**\n * Generates the inline styles used for each knob, applying colors if specified.\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Object} styles - the default styles for the knobs.\n * @returns {Object} - An object with both the inner and outer styles for the knob.\n * @memberof HvSlider\n */\nexport const createKnobStyles = (\n knobProperties: HvKnobProperty[],\n): {\n knobInner: React.CSSProperties[];\n knobOuterStyle: React.CSSProperties[];\n} => {\n const knobInner: React.CSSProperties[] = [];\n const knobOuterStyle: React.CSSProperties[] = [];\n\n const lastItem = knobProperties.length - 1;\n if (knobProperties.length > 0) {\n knobProperties.forEach((knobProperty, index) => {\n knobInner[index] = { ...styles.knobInner };\n knobOuterStyle[index] = { ...styles.knobOuter };\n\n if (knobProperty.color) {\n knobInner[index].backgroundColor = knobProperty.color;\n knobOuterStyle[index].backgroundColor = \"transparent\";\n }\n\n if (knobProperty.hidden) {\n knobInner[index] = styles.knobHidden;\n if (index === lastItem) {\n knobInner[index] = { ...styles.knobHiddenLast };\n knobInner[index].backgroundColor = knobProperty.color;\n knobOuterStyle[index] = { ...styles.knobHidden };\n knobOuterStyle[index].backgroundColor = knobProperty.color;\n }\n }\n });\n }\n\n return {\n knobInner,\n knobOuterStyle,\n };\n};\n\n/**\n * Analyzes both the values and the default values to determine whether the slider is working in single mode.\n *\n * @param {Array} values - the values where the knobs are positioned when controlled.\n * @param {Array} defaultValues - the values where the knobs start when uncontrolled.\n * @returns {Boolean} - if true the slider should work as single slider\n */\nexport const isSingleSlider = (\n values: number[],\n defaultValues: (number | undefined)[],\n): boolean => {\n if (!(values?.length > 1)) {\n return defaultValues.length === 1;\n }\n return values.length === 1;\n};\n\n/**\n * Generates the default knob styles for each knob\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Integer} numberOfKnobs - the default styles for the knobs.\n * @param {Object} theme - The theme to extract the colors.\n *\n * @returns {Object} - An object with both the inner and outer styles for the knob.\n * @memberof HvSlider\n */\nexport const generateDefaultKnobProperties = (\n numberOfKnobs: number = 1,\n disabled: boolean = false,\n knobPropertiesProp?: HvKnobProperty[],\n): HvKnobProperty[] => {\n let knobProperties = knobPropertiesProp || [];\n\n const defaultKnobStyles = {\n color: theme.colors.secondary,\n hoverColor: theme.colors.secondary,\n trackColor: theme.colors.secondary,\n dragColor: theme.colors.secondary,\n knobRingColor: theme.colors.atmo1,\n };\n\n const disabledKnobStyles = {\n color: theme.colors.secondary_60,\n hoverColor: theme.colors.secondary_60,\n trackColor: theme.colors.secondary_60,\n dragColor: theme.colors.secondary_60,\n knobRingColor: theme.colors.secondary_60,\n };\n\n if (knobProperties.length > 0) {\n knobProperties = knobProperties.slice(0, numberOfKnobs);\n knobProperties = knobProperties.map((knobProperty) => {\n if (!disabled) {\n return {\n ...disabledKnobStyles,\n ...knobProperty,\n };\n }\n return {\n ...defaultKnobStyles,\n ...knobProperty,\n };\n });\n } else {\n for (let i = 0; i < numberOfKnobs; i += 1) {\n if (!disabled) knobProperties.push(defaultKnobStyles);\n if (disabled) knobProperties.push(disabledKnobStyles);\n }\n }\n\n return knobProperties;\n};\n\nconst pushSlider = (\n index: number,\n inputIndex: number,\n inputValue: number,\n): number => {\n const difference = index - inputIndex;\n\n return inputValue + difference;\n};\n\nexport const ensureValuesConsistency = (\n knobPositions: number[],\n inputIndex: number,\n): number[] => {\n const newKnobsPosition: number[] = [...knobPositions];\n\n newKnobsPosition.forEach((value, index) => {\n if (Number.isNaN(value) || value == null) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n } else if (index < inputIndex && value > newKnobsPosition[inputIndex]) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n } else if (index > inputIndex && value < newKnobsPosition[inputIndex]) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n }\n });\n\n return newKnobsPosition;\n};\n\nexport const convertStatusToArray = (\n length: number,\n status?: HvFormStatus | HvFormStatus[],\n): {\n arrayStatus?: HvFormStatus[];\n arrayDefaultStatus: (keyof typeof validationStates)[];\n} => {\n const result: {\n arrayStatus?: HvFormStatus[];\n arrayDefaultStatus: (keyof typeof validationStates)[];\n } = {\n arrayDefaultStatus: Array.from({ length }, () => validationStates.standBy),\n };\n\n if (status == null) {\n return result;\n }\n if (!Array.isArray(status)) {\n result.arrayStatus = Array.from({ length }, () => status);\n return result;\n }\n result.arrayStatus = status;\n\n return result;\n};\n\nexport const statusArrayToFormStatus = (\n arrayStatus: HvFormStatus[],\n): keyof typeof validationStates => {\n const invalid = arrayStatus.some(\n (status) => status === validationStates.invalid,\n );\n\n if (invalid) return validationStates.invalid;\n\n const valid = arrayStatus.some((status) => status === validationStates.valid);\n\n if (valid) return validationStates.valid;\n\n return validationStates.standBy;\n};\n\nexport const knobsValuesToString = (\n knobsValues: number[],\n markDigits: number,\n): string[] =>\n knobsValues.map((knobValue) =>\n Number.isNaN(knobValue) ? \"\" : knobValue.toFixed(markDigits),\n );\n\nexport const stringValuesToKnobs = (inputsValues: string[]): number[] =>\n inputsValues.map((inputValue) => parseFloat(inputValue));\n"],"names":["styles","validationStates"],"mappings":";;;AAcO,MAAM,6BAA6B,CACxC,aACA,eACA,cACW,gBAAgB,YAAY;AAWlC,MAAM,kCAAkC,CAC7C,aACA,eACA,qBAEA,OAAO,gBAAgB,WACnB,KAAK,OAAO,cAAc,iBAAiB,gBAAgB,IAC3D;AAYC,MAAM,8BAA8B,CACzC,QACA,kBACA,kBACa;AACb,QAAM,iBAA2B,CAAA;AAE1B,SAAA,QAAQ,CAAC,OAAO,UAAU;AAC/B,mBAAe,KAAK,IAAI;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF,CACD;AAEM,SAAA;AACT;AAYO,MAAM,8BAA8B,CACzC,eACA,WACA,kBACa;AACb,QAAM,cAAwB,CAAA;AAEhB,gBAAA,QAAQ,CAAC,OAAO,UAAU;AACtC,gBAAY,KAAK,IAAI;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF,CACD;AAEM,SAAA;AACT;AASa,MAAA,qBAAqB,CAChC,eACA,eACA,qBACW,KAAK,IAAI,gBAAgB,aAAa,IAAI;AAmBhD,MAAM,aAAa,CACxB,gBACA,UACA,kBACA,eACA,eACA,WACA,YACA,UACA,aAA0D,CAAC,SAAS,SACF;AAClE,QAAM,QACJ,CAAA;AAEF,QAAM,SAAmB,CAAA;AAErB,MAAA,eAAe,SAAS,GAAG;AACd,mBAAA,QAAQ,CAAC,iBAAiB;AACnC,UAAA,OAAO,aAAa,aAAa,UAAU;AACvC,cAAA,aAAa,QAAQ,IAAI,WAC3B;AAAA,UACE,OAAO,GAAG,aAAa,KAAK;AAAA,UAC5B,OAAO;AAAA,YACL,GAAGA,aAAO;AAAA,UACZ;AAAA,QAAA,IAEF;AAAA,UACE,OAAO,GAAG,aAAa,KAAK;AAAA,UAC5B,OAAO;AAAA,YACL,GAAGA,aAAO;AAAA,UACZ;AAAA,QAAA;AAAA,M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AAAA,QACA,iBAAiB,UAAU;AAAA,MAAA;AAAA,IAE/B;AAAA,EAAA,CACD;AAEM,SAAA;AACT;AAEa,MAAA,uBAAuB,CAClC,QACA,WAIG;AACH,QAAM,SAGF;AAAA,IACF,oBAAoB,MAAM,KAAK,EAAE,UAAU,MAAMC,gBAAiB,OAAO;AAAA,EAAA;AAG3E,MAAI,UAAU,MAAM;AACX,WAAA;AAAA,EACT;AACA,MAAI,CAAC,MAAM,QAAQ,MAAM,GAAG;AAC1B,WAAO,cAAc,MAAM,KAAK,EAAE,OAAO,GAAG,MAAM,MAAM;AACjD,WAAA;AAAA,EACT;AACA,SAAO,cAAc;AAEd,SAAA;AACT;AAEa,MAAA,0BAA0B,CACrC,gBACkC;AAClC,QAAM,UAAU,YAAY;AAAA,IAC1B,CAAC,WAAW,WAAWA,gBAAiB;AAAA,EAAA;AAGtC,MAAA;AAAS,WAAOA,gBAAiB;AAErC,QAAM,QAAQ,YAAY,KAAK,CAAC,WAAW,WAAWA,gBAAiB,KAAK;AAExE,MAAA;AAAO,WAAOA,gBAAiB;AAEnC,SAAOA,gBAAiB;AAC1B;AAEO,MAAM,sBAAsB,CACjC,aACA,eAEA,YAAY;AAAA,EAAI,CAAC,cACf,OAAO,MAAM,SAAS,IAAI,KAAK,UAAU,QAAQ,UAAU;AAC7D;AAEW,MAAA,sBAAsB,CAAC,iBAClC,aAAa,IAAI,CAAC,eAAe,WAAW,UAAU,CAAC;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/Slider/utils.ts"],"sourcesContent":["import { theme } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFormStatus } from \"../Forms\";\nimport validationStates from \"../Forms/FormElement/validationStates\";\nimport { sliderStyles as styles } from \"./Slider.styles\";\nimport { HvKnobProperty, HvMarkProperty } from \"./types\";\n\n/**\n * Transform the scaled values into knobs positions.\n *\n * @param {*} sliderValue - he value of the slider to be scaled\n * @param {*} minPointVlue - The value of the first point in the slider from left to right.\n * @param {*} stepVlue - The calculated separation between the values of the slider.\n */\nexport const knobsPositionToScaledValue = (\n sliderValue: number,\n minPointValue: number,\n stepValue: number,\n): number => minPointValue + stepValue * sliderValue;\n\n/**\n * Transform the scaled values into knobs positions.\n *\n * @param {*} scaledValue - The value of the slider to be scaled\n * @param {*} minPointValue - The value of the first point in\n * the slider from left to right.\n * @param {*} inverseStepValue - The inverse of calculated separation between\n * the value of the points that compose the slider.\n */\nexport const scaledValueToKnobsPositionValue = (\n scaledValue: number | undefined,\n minPointValue: number,\n inverseStepValue: number,\n): number =>\n typeof scaledValue === \"number\"\n ? Math.floor((scaledValue - minPointValue) * inverseStepValue)\n : NaN;\n\n/**\n * Transform the received knobs values into knob positions\n *\n * @param {Object} values - The values of the slider.\n * @param {Number} inverseStepValue - The inverse of calculated separation between\n * the value of the points that compose the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @returns {Array} - The position of the knobs.\n */\nexport const knobsValuesToKnobsPositions = (\n values: (number | undefined)[],\n inverseStepValue: number,\n minPointValue: number,\n): number[] => {\n const knobsPositions: number[] = [];\n\n values.forEach((value, index) => {\n knobsPositions[index] = scaledValueToKnobsPositionValue(\n value,\n minPointValue,\n inverseStepValue,\n );\n });\n\n return knobsPositions;\n};\n\n/**\n * Transform the received knobs positions into knob values\n *\n * @param {Object} knobPositions - The values of the slider.\n * @param {Number} stepValue - The calculated separation between\n * the value of the points that compose the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @returns {Array} - The position of the knobs.\n */\nexport const knobsPositionsToKnobsValues = (\n knobPositions: number[],\n stepValue: number,\n minPointValue: number,\n): number[] => {\n const knobsValues: number[] = [];\n\n knobPositions.forEach((value, index) => {\n knobsValues[index] = knobsPositionToScaledValue(\n value,\n minPointValue,\n stepValue,\n );\n });\n\n return knobsValues;\n};\n\n/**\n * Calculates the separation between each value in the slider.\n *\n * @param {*} maxPointValue - The value of the last point in the slider from left to right.\n * @param {*} minPointValue - The value of the first point in the slider from left to right.\n * @param {*} divisionQuantity - How many subdivisions there are in the slider.\n */\nexport const calculateStepValue = (\n maxPointValue: number,\n minPointValue: number,\n divisionQuantity: number,\n): number => Math.abs(maxPointValue - minPointValue) / divisionQuantity;\n\n/**\n * Generates the inline styles used for the track of each knob, applying colors if necessary.\n *\n * @param {Object} markProperties - The object provided by the user with\n * the desired configuration for the marks.\n * @param {Integer} markstep - The separation between marks.\n * @param {Integer} divisionQuantity - How many subdivisions there are in the slider.\n * @param {Integer} minPointValue - The value of the first point in the slider from\n * left to right.\n * @param {Integer} stepValue - The calculated separation between the values of the slider.\n * @param {Integer} markDigits - How many decimals the mark will show.\n * @param {Function} formatMark - A function provided by the user that is going to\n * be executed to format the mark text.\n * @param {Object} styles - the default styles for the marks.\n * @returns {Object} - An object with the for the marks.\n * @memberof HvSlider\n */\nexport const createMark = (\n markProperties: HvMarkProperty[],\n markstep: number,\n divisionQuantity: number,\n minPointValue: number,\n maxPointValue: number,\n stepValue: number,\n markDigits: number,\n disabled: boolean,\n formatMark: (label: React.ReactNode) => React.ReactNode = (mark) => mark,\n): Record<number, { label: string; style: React.CSSProperties }> => {\n const marks: Record<number, { label: string; style: React.CSSProperties }> =\n {};\n\n const values: string[] = [];\n\n if (markProperties.length > 0) {\n markProperties.forEach((markProperty) => {\n if (typeof markProperty.position === \"number\") {\n marks[markProperty.position] = disabled\n ? {\n label: `${markProperty.label}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${markProperty.label}`,\n style: {\n ...styles.mark,\n },\n };\n }\n });\n } else {\n const roundedMarkStep = Math.floor(markstep);\n\n for (let index = 0; index <= divisionQuantity; index += roundedMarkStep) {\n let labelValue: React.ReactNode = knobsPositionToScaledValue(\n index,\n minPointValue,\n stepValue,\n ).toFixed(markDigits);\n\n values.push(labelValue as string);\n labelValue = formatMark?.(labelValue) || labelValue;\n\n marks[index] = disabled\n ? {\n label: `${labelValue}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${labelValue}`,\n style: {\n ...styles.mark,\n },\n };\n }\n\n if (!values.includes(maxPointValue.toString())) {\n const lastMarkPosition = knobsValuesToKnobsPositions(\n [maxPointValue],\n 1 / stepValue,\n minPointValue,\n );\n\n const lastMarkLabel = formatMark?.(maxPointValue.toFixed(markDigits));\n marks[lastMarkPosition[0]] = disabled\n ? {\n label: `${lastMarkLabel}`,\n style: {\n ...styles.disabledMark,\n },\n }\n : {\n label: `${lastMarkLabel}`,\n style: {\n ...styles.mark,\n },\n };\n }\n }\n\n return marks;\n};\n\n/**\n * Generates the inline styles used for the track of each knob, applying colors if necessary.\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Object} styles - the default styles for the tracks.\n * @returns {Object} - An object with the style for each track.\n * @memberof HvSlider\n */\nexport const createTrackStyles = (\n knobProperties: HvKnobProperty[],\n): React.CSSProperties[] => {\n const trackStyles: React.CSSProperties[] = [];\n\n if (knobProperties.length > 0) {\n knobProperties.forEach((knobProperty, index) => {\n trackStyles[index] = { ...styles.track };\n if (knobProperty.color) {\n trackStyles[index].backgroundColor = knobProperty.trackColor;\n }\n });\n }\n\n return trackStyles;\n};\n\n/**\n * Generates the inline styles used for each knob, applying colors if specified.\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Object} styles - the default styles for the knobs.\n * @returns {Object} - An object with both the inner and outer styles for the knob.\n * @memberof HvSlider\n */\nexport const createKnobStyles = (\n knobProperties: HvKnobProperty[],\n): {\n knobInner: React.CSSProperties[];\n knobOuterStyle: React.CSSProperties[];\n} => {\n const knobInner: React.CSSProperties[] = [];\n const knobOuterStyle: React.CSSProperties[] = [];\n\n const lastItem = knobProperties.length - 1;\n if (knobProperties.length > 0) {\n knobProperties.forEach((knobProperty, index) => {\n knobInner[index] = { ...styles.knobInner };\n knobOuterStyle[index] = { ...styles.knobOuter };\n\n if (knobProperty.color) {\n knobInner[index].backgroundColor = knobProperty.color;\n knobOuterStyle[index].backgroundColor = \"transparent\";\n }\n\n if (knobProperty.hidden) {\n knobInner[index] = styles.knobHidden;\n if (index === lastItem) {\n knobInner[index] = { ...styles.knobHiddenLast };\n knobInner[index].backgroundColor = knobProperty.color;\n knobOuterStyle[index] = { ...styles.knobHidden };\n knobOuterStyle[index].backgroundColor = knobProperty.color;\n }\n }\n });\n }\n\n return {\n knobInner,\n knobOuterStyle,\n };\n};\n\n/**\n * Analyzes both the values and the default values to determine whether the slider is working in single mode.\n *\n * @param {Array} values - the values where the knobs are positioned when controlled.\n * @param {Array} defaultValues - the values where the knobs start when uncontrolled.\n * @returns {Boolean} - if true the slider should work as single slider\n */\nexport const isSingleSlider = (\n values: number[],\n defaultValues: (number | undefined)[],\n): boolean => {\n if (!(values?.length > 1)) {\n return defaultValues.length === 1;\n }\n return values.length === 1;\n};\n\n/**\n * Generates the default knob styles for each knob\n *\n * @param {Object} knobProperties - The object provided by the user with\n * the desired configuration for the knobs.\n * @param {Integer} numberOfKnobs - the default styles for the knobs.\n * @param {Object} theme - The theme to extract the colors.\n *\n * @returns {Object} - An object with both the inner and outer styles for the knob.\n * @memberof HvSlider\n */\nexport const generateDefaultKnobProperties = (\n numberOfKnobs = 1,\n disabled = false,\n knobPropertiesProp?: HvKnobProperty[],\n): HvKnobProperty[] => {\n let knobProperties = knobPropertiesProp || [];\n\n const defaultKnobStyles = {\n color: theme.colors.secondary,\n hoverColor: theme.colors.secondary,\n trackColor: theme.colors.secondary,\n dragColor: theme.colors.secondary,\n knobRingColor: theme.colors.atmo1,\n };\n\n const disabledKnobStyles = {\n color: theme.colors.secondary_60,\n hoverColor: theme.colors.secondary_60,\n trackColor: theme.colors.secondary_60,\n dragColor: theme.colors.secondary_60,\n knobRingColor: theme.colors.secondary_60,\n };\n\n if (knobProperties.length > 0) {\n knobProperties = knobProperties.slice(0, numberOfKnobs);\n knobProperties = knobProperties.map((knobProperty) => {\n if (!disabled) {\n return {\n ...disabledKnobStyles,\n ...knobProperty,\n };\n }\n return {\n ...defaultKnobStyles,\n ...knobProperty,\n };\n });\n } else {\n for (let i = 0; i < numberOfKnobs; i += 1) {\n if (!disabled) knobProperties.push(defaultKnobStyles);\n if (disabled) knobProperties.push(disabledKnobStyles);\n }\n }\n\n return knobProperties;\n};\n\nconst pushSlider = (\n index: number,\n inputIndex: number,\n inputValue: number,\n): number => {\n const difference = index - inputIndex;\n\n return inputValue + difference;\n};\n\nexport const ensureValuesConsistency = (\n knobPositions: number[],\n inputIndex: number,\n): number[] => {\n const newKnobsPosition: number[] = [...knobPositions];\n\n newKnobsPosition.forEach((value, index) => {\n if (Number.isNaN(value) || value == null) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n } else if (index < inputIndex && value > newKnobsPosition[inputIndex]) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n } else if (index > inputIndex && value < newKnobsPosition[inputIndex]) {\n newKnobsPosition[index] = pushSlider(\n index,\n inputIndex,\n newKnobsPosition[inputIndex],\n );\n }\n });\n\n return newKnobsPosition;\n};\n\nexport const convertStatusToArray = (\n length: number,\n status?: HvFormStatus | HvFormStatus[],\n): {\n arrayStatus?: HvFormStatus[];\n arrayDefaultStatus: (keyof typeof validationStates)[];\n} => {\n const result: {\n arrayStatus?: HvFormStatus[];\n arrayDefaultStatus: (keyof typeof validationStates)[];\n } = {\n arrayDefaultStatus: Array.from({ length }, () => validationStates.standBy),\n };\n\n if (status == null) {\n return result;\n }\n if (!Array.isArray(status)) {\n result.arrayStatus = Array.from({ length }, () => status);\n return result;\n }\n result.arrayStatus = status;\n\n return result;\n};\n\nexport const statusArrayToFormStatus = (\n arrayStatus: HvFormStatus[],\n): keyof typeof validationStates => {\n const invalid = arrayStatus.some(\n (status) => status === validationStates.invalid,\n );\n\n if (invalid) return validationStates.invalid;\n\n const valid = arrayStatus.some((status) => status === validationStates.valid);\n\n if (valid) return validationStates.valid;\n\n return validationStates.standBy;\n};\n\nexport const knobsValuesToString = (\n knobsValues: number[],\n markDigits: number,\n): string[] =>\n knobsValues.map((knobValue) =>\n Number.isNaN(knobValue) ? \"\" : knobValue.toFixed(markDigits),\n );\n\nexport const stringValuesToKnobs = (inputsValues: string[]): number[] =>\n inputsValues.map((inputValue) => parseFloat(inputValue));\n"],"names":["styles","validationStates"],"mappings":";;;AAcO,MAAM,6BAA6B,CACxC,aACA,eACA,cACW,gBAAgB,YAAY;AAWlC,MAAM,kCAAkC,CAC7C,aACA,eACA,qBAEA,OAAO,gBAAgB,WACnB,KAAK,OAAO,cAAc,iBAAiB,gBAAgB,IAC3D;AAYC,MAAM,8BAA8B,CACzC,QACA,kBACA,kBACa;AACb,QAAM,iBAA2B,CAAA;AAE1B,SAAA,QAAQ,CAAC,OAAO,UAAU;AAC/B,mBAAe,KAAK,IAAI;AAAA,MACtB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF,CACD;AAEM,SAAA;AACT;AAYO,MAAM,8BAA8B,CACzC,eACA,WACA,kBACa;AACb,QAAM,cAAwB,CAAA;AAEhB,gBAAA,QAAQ,CAAC,OAAO,UAAU;AACtC,gBAAY,KAAK,IAAI;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF,CACD;AAEM,SAAA;AACT;AASa,MAAA,qBAAqB,CAChC,eACA,eACA,qBACW,KAAK,IAAI,gBAAgB,aAAa,IAAI;AAmBhD,MAAM,aAAa,CACxB,gBACA,UACA,kBACA,eACA,eACA,WACA,YACA,UACA,aAA0D,CAAC,SAAS,SACF;AAClE,QAAM,QACJ,CAAA;AAEF,QAAM,SAAmB,CAAA;AAErB,MAAA,eAAe,SAAS,GAAG;AACd,mBAAA,QAAQ,CAAC,iBAAiB;AACnC,UAAA,OAAO,aAAa,aAAa,UAAU;AACvC,cAAA,aAAa,QAAQ,IAAI,WAC3B;AAAA,UACE,OAAO,GAAG,aAAa,KAAK;AAAA,UAC5B,OAAO;AAAA,YACL,GA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A;AAAA,QACA,iBAAiB,UAAU;AAAA,MAAA;AAAA,IAC7B,WACS,QAAQ,cAAc,QAAQ,iBAAiB,UAAU,GAAG;AACrE,uBAAiB,KAAK,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA,iBAAiB,UAAU;AAAA,MAAA;AAAA,IAE/B;AAAA,EAAA,CACD;AAEM,SAAA;AACT;AAEa,MAAA,uBAAuB,CAClC,QACA,WAIG;AACH,QAAM,SAGF;AAAA,IACF,oBAAoB,MAAM,KAAK,EAAE,UAAU,MAAMC,gBAAiB,OAAO;AAAA,EAAA;AAG3E,MAAI,UAAU,MAAM;AACX,WAAA;AAAA,EACT;AACA,MAAI,CAAC,MAAM,QAAQ,MAAM,GAAG;AAC1B,WAAO,cAAc,MAAM,KAAK,EAAE,OAAO,GAAG,MAAM,MAAM;AACjD,WAAA;AAAA,EACT;AACA,SAAO,cAAc;AAEd,SAAA;AACT;AAEa,MAAA,0BAA0B,CACrC,gBACkC;AAClC,QAAM,UAAU,YAAY;AAAA,IAC1B,CAAC,WAAW,WAAWA,gBAAiB;AAAA,EAAA;AAGtC,MAAA;AAAS,WAAOA,gBAAiB;AAErC,QAAM,QAAQ,YAAY,KAAK,CAAC,WAAW,WAAWA,gBAAiB,KAAK;AAExE,MAAA;AAAO,WAAOA,gBAAiB;AAEnC,SAAOA,gBAAiB;AAC1B;AAEO,MAAM,sBAAsB,CACjC,aACA,eAEA,YAAY;AAAA,EAAI,CAAC,cACf,OAAO,MAAM,SAAS,IAAI,KAAK,UAAU,QAAQ,UAAU;AAC7D;AAEW,MAAA,sBAAsB,CAAC,iBAClC,aAAa,IAAI,CAAC,eAAe,WAAW,UAAU,CAAC;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from "
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, isValidElement } from "react";
|
|
3
3
|
import SnackbarContent from "@mui/material/SnackbarContent";
|
|
4
4
|
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback, useMemo } from "react";
|
|
3
3
|
import { SnackbarContent, useSnackbar, SnackbarProvider } from "notistack";
|
|
4
4
|
import { useClasses } from "./SnackbarProvider.styles.js";
|
package/dist/esm/Stack/Stack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from "
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useRef, useMemo, useCallback, Children } from "react";
|
|
3
3
|
import MuiDivider from "@mui/material/Divider";
|
|
4
4
|
import { useTheme } from "@mui/material/styles";
|
|
@@ -22,7 +22,7 @@ const HvStack = (props) => {
|
|
|
22
22
|
classes: classesProp,
|
|
23
23
|
className,
|
|
24
24
|
children,
|
|
25
|
-
direction = "column",
|
|
25
|
+
direction: directionProp = "column",
|
|
26
26
|
spacing = "sm",
|
|
27
27
|
divider = false,
|
|
28
28
|
withNavigation = false,
|
|
@@ -33,18 +33,17 @@ const HvStack = (props) => {
|
|
|
33
33
|
const width = useWidth();
|
|
34
34
|
const containerRef = useRef(null);
|
|
35
35
|
const { breakpoints } = useTheme();
|
|
36
|
-
const
|
|
37
|
-
() => getDirection(
|
|
38
|
-
[
|
|
36
|
+
const direction = useMemo(
|
|
37
|
+
() => getDirection(directionProp, width, breakpoints.keys),
|
|
38
|
+
[directionProp, width, breakpoints]
|
|
39
39
|
);
|
|
40
40
|
const getDividerComponent = useCallback(() => {
|
|
41
41
|
if (typeof divider === "boolean" && divider) {
|
|
42
42
|
return /* @__PURE__ */ jsx(
|
|
43
43
|
MuiDivider,
|
|
44
44
|
{
|
|
45
|
-
orientation:
|
|
46
|
-
flexItem:
|
|
47
|
-
role: "separator",
|
|
45
|
+
orientation: direction === "column" ? "horizontal" : "vertical",
|
|
46
|
+
flexItem: direction === "row",
|
|
48
47
|
classes: {
|
|
49
48
|
root: classes.divider
|
|
50
49
|
},
|
|
@@ -53,14 +52,14 @@ const HvStack = (props) => {
|
|
|
53
52
|
);
|
|
54
53
|
}
|
|
55
54
|
return divider;
|
|
56
|
-
}, [classes.divider, divider, dividerProps,
|
|
55
|
+
}, [classes.divider, divider, dividerProps, direction]);
|
|
57
56
|
return /* @__PURE__ */ jsx(
|
|
58
57
|
"div",
|
|
59
58
|
{
|
|
60
59
|
ref: containerRef,
|
|
61
60
|
className: cx(
|
|
62
61
|
classes.root,
|
|
63
|
-
classes[
|
|
62
|
+
classes[direction],
|
|
64
63
|
classes[spacing],
|
|
65
64
|
className
|
|
66
65
|
),
|
|
@@ -74,7 +73,7 @@ const HvStack = (props) => {
|
|
|
74
73
|
rootRef: containerRef,
|
|
75
74
|
focusDisabled: false,
|
|
76
75
|
strategy: "grid",
|
|
77
|
-
navigationJump:
|
|
76
|
+
navigationJump: direction === "column" ? 1 : Children.count(children) || 0,
|
|
78
77
|
filterClass: "child",
|
|
79
78
|
children: /* @__PURE__ */ jsx("div", { className: "child", children: child })
|
|
80
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stack.js","sources":["../../../src/Stack/Stack.tsx"],"sourcesContent":["import { Children, useCallback, useMemo, useRef } from \"react\";\nimport MuiDivider, {\n DividerProps as MuiDividerProps,\n} from \"@mui/material/Divider\";\nimport { useTheme } from \"@mui/material/styles\";\nimport { HvBreakpoints } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFocus } from \"../Focus\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useWidth } from \"../hooks/useWidth\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { staticClasses, useClasses } from \"./Stack.styles\";\n\nexport { staticClasses as stackClasses };\n\nexport type HvStackClasses = ExtractNames<typeof useClasses>;\n\nexport type HvStackDirection = \"column\" | \"row\" | Partial<HvStackBreakpoints>;\nexport interface HvStackBreakpoints extends Record<HvBreakpoints, string> {}\n\nexport interface HvStackProps extends HvBaseProps {\n /** The direction of the stack. Can be either a string or an object that states the direction for each breakpoint. */\n direction?: HvStackDirection;\n /** The spacing between elements of the stack. */\n spacing?: HvBreakpoints;\n /** The divider component to be used between the stack elements.\n * - If `true` the Material-UI Divider component will be used.\n * - If a React node is passed then the custom divider will be used.\n */\n divider?: boolean | React.ReactNode;\n /** The properties to pass on to the Material-UI component. */\n dividerProps?: MuiDividerProps;\n /** Sets whether or not there should be arrow navigation between the stack elements. */\n withNavigation?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvStackClasses;\n}\n\n/**\n * @returns {string} - Returns a direction for the stack: column or row. If the\n * `direction` property is a string and a valid direction then we\n * use it. If it's an object with multiple directions by breakpoint\n * we use the appropriate one or search for the nearest breakpoint\n * smaller than the current one to use.\n */\nconst getDirection = (direction: any, width: any, breakpoints: any) => {\n if (typeof direction === \"string\") return direction;\n\n for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {\n if (direction[breakpoints[i]] !== undefined) {\n return direction[breakpoints[i]];\n }\n }\n return \"column\";\n};\n\n/**\n * A Stack component allows the organization of its children in a vertical or horizontal layout.\n *\n * It also allows the specification of the spacing between the stack elements and the addition of a divider between the elements.\n */\nexport const HvStack = (props: HvStackProps) => {\n const {\n classes: classesProp,\n className,\n children,\n direction = \"column\",\n spacing = \"sm\",\n divider = false,\n withNavigation = false,\n dividerProps = {},\n ...others\n } = useDefaultProps(\"HvStack\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const width = useWidth();\n const containerRef = useRef(null);\n const { breakpoints } = useTheme();\n\n const
|
|
1
|
+
{"version":3,"file":"Stack.js","sources":["../../../src/Stack/Stack.tsx"],"sourcesContent":["import { Children, useCallback, useMemo, useRef } from \"react\";\nimport MuiDivider, {\n DividerProps as MuiDividerProps,\n} from \"@mui/material/Divider\";\nimport { useTheme } from \"@mui/material/styles\";\nimport { HvBreakpoints } from \"@hitachivantara/uikit-styles\";\n\nimport { HvFocus } from \"../Focus\";\nimport { useDefaultProps } from \"../hooks/useDefaultProps\";\nimport { useWidth } from \"../hooks/useWidth\";\nimport { HvBaseProps } from \"../types/generic\";\nimport { ExtractNames } from \"../utils/classes\";\nimport { staticClasses, useClasses } from \"./Stack.styles\";\n\nexport { staticClasses as stackClasses };\n\nexport type HvStackClasses = ExtractNames<typeof useClasses>;\n\nexport type HvStackDirection = \"column\" | \"row\" | Partial<HvStackBreakpoints>;\nexport interface HvStackBreakpoints extends Record<HvBreakpoints, string> {}\n\nexport interface HvStackProps extends HvBaseProps {\n /** The direction of the stack. Can be either a string or an object that states the direction for each breakpoint. */\n direction?: HvStackDirection;\n /** The spacing between elements of the stack. */\n spacing?: HvBreakpoints;\n /** The divider component to be used between the stack elements.\n * - If `true` the Material-UI Divider component will be used.\n * - If a React node is passed then the custom divider will be used.\n */\n divider?: boolean | React.ReactNode;\n /** The properties to pass on to the Material-UI component. */\n dividerProps?: MuiDividerProps;\n /** Sets whether or not there should be arrow navigation between the stack elements. */\n withNavigation?: boolean;\n /** A Jss Object used to override or extend the styles applied to the component. */\n classes?: HvStackClasses;\n}\n\n/**\n * @returns {string} - Returns a direction for the stack: column or row. If the\n * `direction` property is a string and a valid direction then we\n * use it. If it's an object with multiple directions by breakpoint\n * we use the appropriate one or search for the nearest breakpoint\n * smaller than the current one to use.\n */\nconst getDirection = (direction: any, width: any, breakpoints: any) => {\n if (typeof direction === \"string\") return direction;\n\n for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {\n if (direction[breakpoints[i]] !== undefined) {\n return direction[breakpoints[i]];\n }\n }\n return \"column\";\n};\n\n/**\n * A Stack component allows the organization of its children in a vertical or horizontal layout.\n *\n * It also allows the specification of the spacing between the stack elements and the addition of a divider between the elements.\n */\nexport const HvStack = (props: HvStackProps) => {\n const {\n classes: classesProp,\n className,\n children,\n direction: directionProp = \"column\",\n spacing = \"sm\",\n divider = false,\n withNavigation = false,\n dividerProps = {},\n ...others\n } = useDefaultProps(\"HvStack\", props);\n const { classes, cx } = useClasses(classesProp);\n\n const width = useWidth();\n const containerRef = useRef(null);\n const { breakpoints } = useTheme();\n\n const direction = useMemo(\n () => getDirection(directionProp, width, breakpoints.keys),\n [directionProp, width, breakpoints],\n );\n\n /**\n * @returns {node} - The divider component to use. If the property `divider` is\n * set to `true` then the Material-UI divider is used, otherwise\n * we use the custom divider the user passed.\n */\n const getDividerComponent = useCallback(() => {\n if (typeof divider === \"boolean\" && divider) {\n return (\n <MuiDivider\n orientation={direction === \"column\" ? \"horizontal\" : \"vertical\"}\n flexItem={direction === \"row\"}\n classes={{\n root: classes.divider,\n }}\n {...dividerProps}\n />\n );\n }\n return divider;\n }, [classes.divider, divider, dividerProps, direction]);\n\n return (\n <div\n ref={containerRef}\n className={cx(\n classes.root,\n classes[direction],\n classes[spacing],\n className,\n )}\n {...others}\n >\n {Children.map(children, (child, i) => {\n return (\n <>\n {divider && i !== 0 && getDividerComponent()}\n {withNavigation ? (\n <HvFocus\n rootRef={containerRef}\n focusDisabled={false}\n strategy=\"grid\"\n navigationJump={\n direction === \"column\" ? 1 : Children.count(children) || 0\n }\n filterClass=\"child\"\n >\n <div className=\"child\">{child}</div>\n </HvFocus>\n ) : (\n child\n )}\n </>\n );\n })}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA8CA,MAAM,eAAe,CAAC,WAAgB,OAAY,gBAAqB;AACrE,MAAI,OAAO,cAAc;AAAiB,WAAA;AAEjC,WAAA,IAAI,YAAY,QAAQ,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;AACvD,QAAI,UAAU,YAAY,CAAC,CAAC,MAAM,QAAW;AACpC,aAAA,UAAU,YAAY,CAAC,CAAC;AAAA,IACjC;AAAA,EACF;AACO,SAAA;AACT;AAOa,MAAA,UAAU,CAAC,UAAwB;AACxC,QAAA;AAAA,IACJ,SAAS;AAAA,IACT;AAAA,IACA;A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EZ,UAAC,oBAAA,OAAA,EAAI,WAAU,SAAS,UAAM,OAAA;AAAA,YAAA;AAAA,UAAA,IAGhC;AAAA,QAEJ,EAAA,CAAA;AAAA,MAAA,CAEH;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs, jsx } from "
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback } from "react";
|
|
3
3
|
import { isInvalid } from "../Forms/FormElement/validationStates.js";
|
|
4
4
|
import { useControlled } from "../hooks/useControlled.js";
|
package/dist/esm/Tab/Tab.js
CHANGED
package/dist/esm/Table/Table.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useContext, useRef, Children, isValidElement } from "react";
|
|
3
3
|
import { useForkRef } from "../../hooks/useForkRef.js";
|
|
4
4
|
import TableContext from "../TableContext.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from "
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useContext, useMemo } from "react";
|
|
3
3
|
import { alpha, hexToRgb } from "@mui/material/styles";
|
|
4
4
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from "
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DropDownXS, DropUpXS } from "@hitachivantara/uikit-react-icons";
|
|
3
3
|
import { useLabels } from "../../hooks/useLabels.js";
|
|
4
4
|
import { HvButton } from "../../Button/Button.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx } from "
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useCallback } from "react";
|
|
3
3
|
import { actions, ensurePluginOrder, useGetLatest, useMountedLayoutEffect, makePropGetter } from "react-table";
|
|
4
4
|
import { useLabels } from "../../hooks/useLabels.js";
|
|
@@ -56,7 +56,7 @@ const defaultGetToggleRowSelectedProps = (props, meta) => {
|
|
|
56
56
|
const { instance, row } = meta;
|
|
57
57
|
const { manualRowSelectedKey = "isSelected" } = instance;
|
|
58
58
|
let checked = false;
|
|
59
|
-
if (row.original
|
|
59
|
+
if (row.original?.[manualRowSelectedKey]) {
|
|
60
60
|
checked = true;
|
|
61
61
|
} else {
|
|
62
62
|
checked = row.isSelected;
|
|
@@ -253,7 +253,7 @@ function getRowIsSelected(row, selectedRowIds, getSubRows) {
|
|
|
253
253
|
return true;
|
|
254
254
|
}
|
|
255
255
|
const subRows = getSubRows(row);
|
|
256
|
-
if (subRows
|
|
256
|
+
if (subRows?.length) {
|
|
257
257
|
let allChildrenSelected = true;
|
|
258
258
|
let someSelected = false;
|
|
259
259
|
subRows.forEach((subRow) => {
|
|
@@ -342,15 +342,15 @@ function useInstance(instance) {
|
|
|
342
342
|
} else {
|
|
343
343
|
isAllSelectableRowsSelected = existsLockedRows && !Object.keys(rowsToSelect).filter((id) => !lockedSelectionRowIds[id]).some((id) => !selectedRowIds[id]);
|
|
344
344
|
isAllSelectableRowsUnselected = !existsLockedRows || !Object.keys(rowsToSelect).filter((id) => !lockedSelectionRowIds[id]).some((id) => selectedRowIds[id]);
|
|
345
|
-
isAllPageRowsSelected = !(page
|
|
345
|
+
isAllPageRowsSelected = !(page?.length && page.some(({ id }) => !selectedRowIds[id]));
|
|
346
346
|
if (isAllPageRowsSelected) {
|
|
347
347
|
isAllSelectablePageRowsSelected = true;
|
|
348
348
|
isAllSelectablePageRowsUnselected = existsLockedRows && page && page.length && page.filter(({ id }) => !lockedSelectionRowIds[id]).length === 0;
|
|
349
349
|
isNoPageRowsSelected = false;
|
|
350
350
|
} else {
|
|
351
|
-
isAllSelectablePageRowsSelected = existsLockedRows && !(page
|
|
352
|
-
isAllSelectablePageRowsUnselected = !existsLockedRows || !(page
|
|
353
|
-
isNoPageRowsSelected = !(page
|
|
351
|
+
isAllSelectablePageRowsSelected = existsLockedRows && !(page?.length && page.filter(({ id }) => !lockedSelectionRowIds[id]).some(({ id }) => !selectedRowIds[id]));
|
|
352
|
+
isAllSelectablePageRowsUnselected = !existsLockedRows || !(page?.length && page.filter(({ id }) => !lockedSelectionRowIds[id]).some(({ id }) => selectedRowIds[id]));
|
|
353
|
+
isNoPageRowsSelected = !(page?.length && page.some(({ id }) => selectedRowIds[id]));
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
}
|