@hitachivantara/uikit-react-core 5.22.1 → 5.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Accordion/Accordion.cjs +17 -15
- package/dist/cjs/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/cjs/components/ActionBar/ActionBar.cjs +2 -1
- package/dist/cjs/components/ActionBar/ActionBar.cjs.map +1 -1
- package/dist/cjs/components/ActionsGeneric/ActionsGeneric.cjs +13 -11
- package/dist/cjs/components/ActionsGeneric/ActionsGeneric.cjs.map +1 -1
- package/dist/cjs/components/AppSwitcher/AppSwitcher.cjs +16 -14
- package/dist/cjs/components/AppSwitcher/AppSwitcher.cjs.map +1 -1
- package/dist/cjs/components/Avatar/Avatar.cjs +22 -20
- package/dist/cjs/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/cjs/components/Badge/Badge.cjs +2 -1
- package/dist/cjs/components/Badge/Badge.cjs.map +1 -1
- package/dist/cjs/components/Banner/Banner.cjs +22 -20
- package/dist/cjs/components/Banner/Banner.cjs.map +1 -1
- package/dist/cjs/components/Banner/BannerContent/BannerContent.cjs +1 -1
- package/dist/cjs/components/Banner/BannerContent/BannerContent.cjs.map +1 -1
- package/dist/cjs/components/BaseCheckBox/BaseCheckBox.cjs +21 -19
- package/dist/cjs/components/BaseCheckBox/BaseCheckBox.cjs.map +1 -1
- package/dist/cjs/components/BaseDropdown/BaseDropdown.cjs +26 -24
- package/dist/cjs/components/BaseDropdown/BaseDropdown.cjs.map +1 -1
- package/dist/cjs/components/BaseInput/BaseInput.cjs +23 -21
- package/dist/cjs/components/BaseInput/BaseInput.cjs.map +1 -1
- package/dist/cjs/components/BaseRadio/BaseRadio.cjs +2 -1
- package/dist/cjs/components/BaseRadio/BaseRadio.cjs.map +1 -1
- package/dist/cjs/components/BaseSwitch/BaseSwitch.cjs +2 -1
- package/dist/cjs/components/BaseSwitch/BaseSwitch.cjs.map +1 -1
- package/dist/cjs/components/Box/Box.cjs +9 -8
- package/dist/cjs/components/Box/Box.cjs.map +1 -1
- package/dist/cjs/components/BreadCrumb/BreadCrumb.cjs +14 -12
- package/dist/cjs/components/BreadCrumb/BreadCrumb.cjs.map +1 -1
- package/dist/cjs/components/BulkActions/BulkActions.cjs +22 -20
- package/dist/cjs/components/BulkActions/BulkActions.cjs.map +1 -1
- package/dist/cjs/components/Button/Button.cjs +4 -3
- package/dist/cjs/components/Button/Button.cjs.map +1 -1
- package/dist/cjs/components/Calendar/Calendar.cjs +20 -18
- package/dist/cjs/components/Calendar/Calendar.cjs.map +1 -1
- package/dist/cjs/components/Card/Card.cjs +13 -11
- package/dist/cjs/components/Card/Card.cjs.map +1 -1
- package/dist/cjs/components/Carousel/Carousel.cjs +2 -2
- package/dist/cjs/components/Carousel/Carousel.cjs.map +1 -1
- package/dist/cjs/components/Carousel/CarouselControls.cjs +2 -3
- package/dist/cjs/components/Carousel/CarouselControls.cjs.map +1 -1
- package/dist/cjs/components/Carousel/CarouselSlide/CarouselSlide.cjs +1 -1
- package/dist/cjs/components/Carousel/CarouselSlide/CarouselSlide.cjs.map +1 -1
- package/dist/cjs/components/CheckBox/CheckBox.cjs +29 -27
- package/dist/cjs/components/CheckBox/CheckBox.cjs.map +1 -1
- package/dist/cjs/components/CheckBoxGroup/CheckBoxGroup.cjs +28 -26
- package/dist/cjs/components/CheckBoxGroup/CheckBoxGroup.cjs.map +1 -1
- package/dist/cjs/components/ColorPicker/ColorPicker.cjs +34 -32
- package/dist/cjs/components/ColorPicker/ColorPicker.cjs.map +1 -1
- package/dist/cjs/components/Container/Container.cjs +9 -7
- package/dist/cjs/components/Container/Container.cjs.map +1 -1
- package/dist/cjs/components/Controls/Controls.cjs +14 -12
- package/dist/cjs/components/Controls/Controls.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs +39 -37
- package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Actions/Actions.cjs +9 -7
- package/dist/cjs/components/Dialog/Actions/Actions.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Content/Content.cjs +8 -6
- package/dist/cjs/components/Dialog/Content/Content.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Dialog.cjs +16 -14
- package/dist/cjs/components/Dialog/Dialog.cjs.map +1 -1
- package/dist/cjs/components/Dialog/Title/Title.cjs +11 -9
- package/dist/cjs/components/Dialog/Title/Title.cjs.map +1 -1
- package/dist/cjs/components/DotPagination/DotPagination.cjs +14 -12
- package/dist/cjs/components/DotPagination/DotPagination.cjs.map +1 -1
- package/dist/cjs/components/Drawer/Drawer.cjs +13 -11
- package/dist/cjs/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs +20 -17
- package/dist/cjs/components/DropDownMenu/DropDownMenu.cjs.map +1 -1
- package/dist/cjs/components/Dropdown/Dropdown.cjs +2 -1
- package/dist/cjs/components/Dropdown/Dropdown.cjs.map +1 -1
- package/dist/cjs/components/EmptyState/EmptyState.cjs +2 -1
- package/dist/cjs/components/EmptyState/EmptyState.cjs.map +1 -1
- package/dist/cjs/components/FileUploader/File/File.cjs +0 -1
- package/dist/cjs/components/FileUploader/File/File.cjs.map +1 -1
- package/dist/cjs/components/FileUploader/FileUploader.cjs +17 -15
- package/dist/cjs/components/FileUploader/FileUploader.cjs.map +1 -1
- package/dist/cjs/components/FileUploader/Preview/Preview.cjs +0 -1
- package/dist/cjs/components/FileUploader/Preview/Preview.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/FilterGroup.cjs +30 -28
- package/dist/cjs/components/FilterGroup/FilterGroup.cjs.map +1 -1
- package/dist/cjs/components/FilterGroup/FilterGroupContext.cjs +8 -6
- package/dist/cjs/components/FilterGroup/FilterGroupContext.cjs.map +1 -1
- package/dist/cjs/components/Footer/Footer.cjs +2 -1
- package/dist/cjs/components/Footer/Footer.cjs.map +1 -1
- package/dist/cjs/components/Forms/CharCounter/CharCounter.cjs +13 -11
- package/dist/cjs/components/Forms/CharCounter/CharCounter.cjs.map +1 -1
- package/dist/cjs/components/Forms/FormElement/FormElement.cjs +15 -13
- package/dist/cjs/components/Forms/FormElement/FormElement.cjs.map +1 -1
- package/dist/cjs/components/Forms/InfoMessage/InfoMessage.cjs +11 -9
- package/dist/cjs/components/Forms/InfoMessage/InfoMessage.cjs.map +1 -1
- package/dist/cjs/components/Forms/Label/Label.cjs +13 -11
- package/dist/cjs/components/Forms/Label/Label.cjs.map +1 -1
- package/dist/cjs/components/Forms/WarningText/WarningText.cjs +16 -14
- package/dist/cjs/components/Forms/WarningText/WarningText.cjs.map +1 -1
- package/dist/cjs/components/GlobalActions/GlobalActions.cjs +13 -11
- package/dist/cjs/components/GlobalActions/GlobalActions.cjs.map +1 -1
- package/dist/cjs/components/Grid/Grid.cjs +10 -8
- package/dist/cjs/components/Grid/Grid.cjs.map +1 -1
- package/dist/cjs/components/Header/Actions/Actions.cjs +8 -6
- package/dist/cjs/components/Header/Actions/Actions.cjs.map +1 -1
- package/dist/cjs/components/Header/Brand/Brand.cjs +9 -7
- package/dist/cjs/components/Header/Brand/Brand.cjs.map +1 -1
- package/dist/cjs/components/Header/Header.cjs +2 -1
- package/dist/cjs/components/Header/Header.cjs.map +1 -1
- package/dist/cjs/components/Header/Navigation/Navigation.cjs +11 -9
- package/dist/cjs/components/Header/Navigation/Navigation.cjs.map +1 -1
- package/dist/cjs/components/InlineEditor/InlineEditor.cjs +18 -16
- package/dist/cjs/components/InlineEditor/InlineEditor.cjs.map +1 -1
- package/dist/cjs/components/Input/Input.cjs +2 -1
- package/dist/cjs/components/Input/Input.cjs.map +1 -1
- package/dist/cjs/components/Kpi/Kpi.cjs +13 -11
- package/dist/cjs/components/Kpi/Kpi.cjs.map +1 -1
- package/dist/cjs/components/Link/Link.cjs +11 -9
- package/dist/cjs/components/Link/Link.cjs.map +1 -1
- package/dist/cjs/components/List/List.cjs +21 -19
- package/dist/cjs/components/List/List.cjs.map +1 -1
- package/dist/cjs/components/ListContainer/ListContainer.cjs +12 -10
- package/dist/cjs/components/ListContainer/ListContainer.cjs.map +1 -1
- package/dist/cjs/components/ListContainer/ListItem/ListItem.cjs +20 -18
- package/dist/cjs/components/ListContainer/ListItem/ListItem.cjs.map +1 -1
- package/dist/cjs/components/Loading/Loading.cjs +2 -1
- package/dist/cjs/components/Loading/Loading.cjs.map +1 -1
- package/dist/cjs/components/Login/Login.cjs +10 -8
- package/dist/cjs/components/Login/Login.cjs.map +1 -1
- package/dist/cjs/components/MultiButton/MultiButton.cjs +11 -9
- package/dist/cjs/components/MultiButton/MultiButton.cjs.map +1 -1
- package/dist/cjs/components/OverflowTooltip/OverflowTooltip.cjs +12 -10
- package/dist/cjs/components/OverflowTooltip/OverflowTooltip.cjs.map +1 -1
- package/dist/cjs/components/Pagination/ButtonIconTooltip.cjs +0 -1
- package/dist/cjs/components/Pagination/ButtonIconTooltip.cjs.map +1 -1
- package/dist/cjs/components/Pagination/Pagination.cjs +22 -20
- package/dist/cjs/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/cjs/components/Pagination/Select.cjs +1 -1
- package/dist/cjs/components/Pagination/Select.cjs.map +1 -1
- package/dist/cjs/components/Panel/Panel.cjs +9 -7
- package/dist/cjs/components/Panel/Panel.cjs.map +1 -1
- package/dist/cjs/components/ProgressBar/ProgressBar.cjs +2 -1
- package/dist/cjs/components/ProgressBar/ProgressBar.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/QueryBuilder.cjs +13 -11
- package/dist/cjs/components/QueryBuilder/QueryBuilder.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/Rule/Rule.cjs +0 -1
- package/dist/cjs/components/QueryBuilder/Rule/Rule.cjs.map +1 -1
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs +1 -2
- package/dist/cjs/components/QueryBuilder/RuleGroup/RuleGroup.cjs.map +1 -1
- package/dist/cjs/components/Radio/Radio.cjs +2 -1
- package/dist/cjs/components/Radio/Radio.cjs.map +1 -1
- package/dist/cjs/components/RadioGroup/RadioGroup.cjs +25 -23
- package/dist/cjs/components/RadioGroup/RadioGroup.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs +18 -16
- package/dist/cjs/components/ScrollTo/Horizontal/ScrollToHorizontal.cjs.map +1 -1
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs +19 -17
- package/dist/cjs/components/ScrollTo/Vertical/ScrollToVertical.cjs.map +1 -1
- package/dist/cjs/components/SelectionList/SelectionList.cjs +27 -25
- package/dist/cjs/components/SelectionList/SelectionList.cjs.map +1 -1
- package/dist/cjs/components/SimpleGrid/SimpleGrid.cjs +9 -7
- package/dist/cjs/components/SimpleGrid/SimpleGrid.cjs.map +1 -1
- package/dist/cjs/components/Slider/Slider.cjs +37 -35
- package/dist/cjs/components/Slider/Slider.cjs.map +1 -1
- package/dist/cjs/components/Snackbar/Snackbar.cjs +1 -1
- package/dist/cjs/components/Snackbar/Snackbar.cjs.map +1 -1
- package/dist/cjs/components/Snackbar/SnackbarContentWrapper/SnackbarContentWrapper.cjs +1 -1
- package/dist/cjs/components/Snackbar/SnackbarContentWrapper/SnackbarContentWrapper.cjs.map +1 -1
- package/dist/cjs/components/Snackbar/SnackbarProvider/SnackbarProvider.cjs +2 -2
- package/dist/cjs/components/Snackbar/SnackbarProvider/SnackbarProvider.cjs.map +1 -1
- package/dist/cjs/components/Stack/Stack.cjs +13 -11
- package/dist/cjs/components/Stack/Stack.cjs.map +1 -1
- package/dist/cjs/components/Switch/Switch.cjs +2 -1
- package/dist/cjs/components/Switch/Switch.cjs.map +1 -1
- package/dist/cjs/components/Tab/Tab.cjs +8 -6
- package/dist/cjs/components/Tab/Tab.cjs.map +1 -1
- package/dist/cjs/components/Table/Table.cjs +12 -10
- package/dist/cjs/components/Table/Table.cjs.map +1 -1
- package/dist/cjs/components/Table/TableHeader/TableHeader.cjs +2 -3
- package/dist/cjs/components/Table/TableHeader/TableHeader.cjs.map +1 -1
- package/dist/cjs/components/Table/hooks/useRowExpand.cjs +0 -1
- package/dist/cjs/components/Table/hooks/useRowExpand.cjs.map +1 -1
- package/dist/cjs/components/Table/renderers/renderers.cjs +0 -1
- package/dist/cjs/components/Table/renderers/renderers.cjs.map +1 -1
- package/dist/cjs/components/Tabs/Tabs.cjs +6 -4
- package/dist/cjs/components/Tabs/Tabs.cjs.map +1 -1
- package/dist/cjs/components/Tag/Tag.cjs +18 -16
- package/dist/cjs/components/Tag/Tag.cjs.map +1 -1
- package/dist/cjs/components/TagsInput/TagsInput.cjs +39 -37
- package/dist/cjs/components/TagsInput/TagsInput.cjs.map +1 -1
- package/dist/cjs/components/TextArea/TextArea.cjs +2 -1
- package/dist/cjs/components/TextArea/TextArea.cjs.map +1 -1
- package/dist/cjs/components/TimeAgo/TimeAgo.cjs +14 -12
- package/dist/cjs/components/TimeAgo/TimeAgo.cjs.map +1 -1
- package/dist/cjs/components/TimePicker/TimePicker.cjs +3 -2
- package/dist/cjs/components/TimePicker/TimePicker.cjs.map +1 -1
- package/dist/cjs/components/ToggleButton/ToggleButton.cjs +2 -2
- package/dist/cjs/components/ToggleButton/ToggleButton.cjs.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs +2 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/cjs/components/Typography/Typography.cjs +2 -1
- package/dist/cjs/components/Typography/Typography.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/Header/Header.cjs +0 -2
- package/dist/cjs/components/VerticalNavigation/Header/Header.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/NavigationSlider/NavigationSlider.cjs +0 -1
- package/dist/cjs/components/VerticalNavigation/NavigationSlider/NavigationSlider.cjs.map +1 -1
- package/dist/cjs/components/VerticalNavigation/VerticalNavigation.cjs +12 -10
- package/dist/cjs/components/VerticalNavigation/VerticalNavigation.cjs.map +1 -1
- package/dist/cjs/hooks/useDefaultProps.cjs +41 -0
- package/dist/cjs/hooks/useDefaultProps.cjs.map +1 -0
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/components/Accordion/Accordion.js +17 -15
- package/dist/esm/components/Accordion/Accordion.js.map +1 -1
- package/dist/esm/components/ActionBar/ActionBar.js +2 -1
- package/dist/esm/components/ActionBar/ActionBar.js.map +1 -1
- package/dist/esm/components/ActionsGeneric/ActionsGeneric.js +13 -11
- package/dist/esm/components/ActionsGeneric/ActionsGeneric.js.map +1 -1
- package/dist/esm/components/AppSwitcher/AppSwitcher.js +16 -14
- package/dist/esm/components/AppSwitcher/AppSwitcher.js.map +1 -1
- package/dist/esm/components/Avatar/Avatar.js +22 -20
- package/dist/esm/components/Avatar/Avatar.js.map +1 -1
- package/dist/esm/components/Badge/Badge.js +2 -1
- package/dist/esm/components/Badge/Badge.js.map +1 -1
- package/dist/esm/components/Banner/Banner.js +22 -20
- package/dist/esm/components/Banner/Banner.js.map +1 -1
- package/dist/esm/components/Banner/BannerContent/BannerContent.js +1 -1
- package/dist/esm/components/Banner/BannerContent/BannerContent.js.map +1 -1
- package/dist/esm/components/BaseCheckBox/BaseCheckBox.js +21 -19
- package/dist/esm/components/BaseCheckBox/BaseCheckBox.js.map +1 -1
- package/dist/esm/components/BaseDropdown/BaseDropdown.js +26 -24
- package/dist/esm/components/BaseDropdown/BaseDropdown.js.map +1 -1
- package/dist/esm/components/BaseInput/BaseInput.js +23 -21
- package/dist/esm/components/BaseInput/BaseInput.js.map +1 -1
- package/dist/esm/components/BaseRadio/BaseRadio.js +2 -1
- package/dist/esm/components/BaseRadio/BaseRadio.js.map +1 -1
- package/dist/esm/components/BaseSwitch/BaseSwitch.js +2 -1
- package/dist/esm/components/BaseSwitch/BaseSwitch.js.map +1 -1
- package/dist/esm/components/Box/Box.js +9 -8
- package/dist/esm/components/Box/Box.js.map +1 -1
- package/dist/esm/components/BreadCrumb/BreadCrumb.js +14 -12
- package/dist/esm/components/BreadCrumb/BreadCrumb.js.map +1 -1
- package/dist/esm/components/BulkActions/BulkActions.js +22 -20
- package/dist/esm/components/BulkActions/BulkActions.js.map +1 -1
- package/dist/esm/components/Button/Button.js +4 -3
- package/dist/esm/components/Button/Button.js.map +1 -1
- package/dist/esm/components/Calendar/Calendar.js +20 -18
- package/dist/esm/components/Calendar/Calendar.js.map +1 -1
- package/dist/esm/components/Card/Card.js +13 -11
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Carousel/Carousel.js +2 -2
- package/dist/esm/components/Carousel/Carousel.js.map +1 -1
- package/dist/esm/components/Carousel/CarouselControls.js +2 -3
- package/dist/esm/components/Carousel/CarouselControls.js.map +1 -1
- package/dist/esm/components/Carousel/CarouselSlide/CarouselSlide.js +1 -1
- package/dist/esm/components/Carousel/CarouselSlide/CarouselSlide.js.map +1 -1
- package/dist/esm/components/CheckBox/CheckBox.js +29 -27
- package/dist/esm/components/CheckBox/CheckBox.js.map +1 -1
- package/dist/esm/components/CheckBoxGroup/CheckBoxGroup.js +28 -26
- package/dist/esm/components/CheckBoxGroup/CheckBoxGroup.js.map +1 -1
- package/dist/esm/components/ColorPicker/ColorPicker.js +34 -32
- package/dist/esm/components/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/esm/components/Container/Container.js +9 -7
- package/dist/esm/components/Container/Container.js.map +1 -1
- package/dist/esm/components/Controls/Controls.js +14 -12
- package/dist/esm/components/Controls/Controls.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +39 -37
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/Dialog/Actions/Actions.js +9 -7
- package/dist/esm/components/Dialog/Actions/Actions.js.map +1 -1
- package/dist/esm/components/Dialog/Content/Content.js +8 -6
- package/dist/esm/components/Dialog/Content/Content.js.map +1 -1
- package/dist/esm/components/Dialog/Dialog.js +16 -14
- package/dist/esm/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/components/Dialog/Title/Title.js +11 -9
- package/dist/esm/components/Dialog/Title/Title.js.map +1 -1
- package/dist/esm/components/DotPagination/DotPagination.js +14 -12
- package/dist/esm/components/DotPagination/DotPagination.js.map +1 -1
- package/dist/esm/components/Drawer/Drawer.js +13 -11
- package/dist/esm/components/Drawer/Drawer.js.map +1 -1
- package/dist/esm/components/DropDownMenu/DropDownMenu.js +20 -17
- package/dist/esm/components/DropDownMenu/DropDownMenu.js.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js +2 -1
- package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/EmptyState/EmptyState.js +2 -1
- package/dist/esm/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/esm/components/FileUploader/File/File.js +0 -1
- package/dist/esm/components/FileUploader/File/File.js.map +1 -1
- package/dist/esm/components/FileUploader/FileUploader.js +17 -15
- package/dist/esm/components/FileUploader/FileUploader.js.map +1 -1
- package/dist/esm/components/FileUploader/Preview/Preview.js +0 -1
- package/dist/esm/components/FileUploader/Preview/Preview.js.map +1 -1
- package/dist/esm/components/FilterGroup/FilterGroup.js +30 -28
- package/dist/esm/components/FilterGroup/FilterGroup.js.map +1 -1
- package/dist/esm/components/FilterGroup/FilterGroupContext.js +8 -6
- package/dist/esm/components/FilterGroup/FilterGroupContext.js.map +1 -1
- package/dist/esm/components/Footer/Footer.js +2 -1
- package/dist/esm/components/Footer/Footer.js.map +1 -1
- package/dist/esm/components/Forms/CharCounter/CharCounter.js +13 -11
- package/dist/esm/components/Forms/CharCounter/CharCounter.js.map +1 -1
- package/dist/esm/components/Forms/FormElement/FormElement.js +15 -13
- package/dist/esm/components/Forms/FormElement/FormElement.js.map +1 -1
- package/dist/esm/components/Forms/InfoMessage/InfoMessage.js +11 -9
- package/dist/esm/components/Forms/InfoMessage/InfoMessage.js.map +1 -1
- package/dist/esm/components/Forms/Label/Label.js +13 -11
- package/dist/esm/components/Forms/Label/Label.js.map +1 -1
- package/dist/esm/components/Forms/WarningText/WarningText.js +16 -14
- package/dist/esm/components/Forms/WarningText/WarningText.js.map +1 -1
- package/dist/esm/components/GlobalActions/GlobalActions.js +13 -11
- package/dist/esm/components/GlobalActions/GlobalActions.js.map +1 -1
- package/dist/esm/components/Grid/Grid.js +10 -8
- package/dist/esm/components/Grid/Grid.js.map +1 -1
- package/dist/esm/components/Header/Actions/Actions.js +8 -6
- package/dist/esm/components/Header/Actions/Actions.js.map +1 -1
- package/dist/esm/components/Header/Brand/Brand.js +9 -7
- package/dist/esm/components/Header/Brand/Brand.js.map +1 -1
- package/dist/esm/components/Header/Header.js +2 -1
- package/dist/esm/components/Header/Header.js.map +1 -1
- package/dist/esm/components/Header/Navigation/Navigation.js +11 -9
- package/dist/esm/components/Header/Navigation/Navigation.js.map +1 -1
- package/dist/esm/components/InlineEditor/InlineEditor.js +18 -16
- package/dist/esm/components/InlineEditor/InlineEditor.js.map +1 -1
- package/dist/esm/components/Input/Input.js +2 -1
- package/dist/esm/components/Input/Input.js.map +1 -1
- package/dist/esm/components/Kpi/Kpi.js +13 -11
- package/dist/esm/components/Kpi/Kpi.js.map +1 -1
- package/dist/esm/components/Link/Link.js +11 -9
- package/dist/esm/components/Link/Link.js.map +1 -1
- package/dist/esm/components/List/List.js +21 -19
- package/dist/esm/components/List/List.js.map +1 -1
- package/dist/esm/components/ListContainer/ListContainer.js +12 -10
- package/dist/esm/components/ListContainer/ListContainer.js.map +1 -1
- package/dist/esm/components/ListContainer/ListItem/ListItem.js +20 -18
- package/dist/esm/components/ListContainer/ListItem/ListItem.js.map +1 -1
- package/dist/esm/components/Loading/Loading.js +2 -1
- package/dist/esm/components/Loading/Loading.js.map +1 -1
- package/dist/esm/components/Login/Login.js +10 -8
- package/dist/esm/components/Login/Login.js.map +1 -1
- package/dist/esm/components/MultiButton/MultiButton.js +11 -9
- package/dist/esm/components/MultiButton/MultiButton.js.map +1 -1
- package/dist/esm/components/OverflowTooltip/OverflowTooltip.js +12 -10
- package/dist/esm/components/OverflowTooltip/OverflowTooltip.js.map +1 -1
- package/dist/esm/components/Pagination/ButtonIconTooltip.js +0 -1
- package/dist/esm/components/Pagination/ButtonIconTooltip.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +22 -20
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/Pagination/Select.js +1 -1
- package/dist/esm/components/Pagination/Select.js.map +1 -1
- package/dist/esm/components/Panel/Panel.js +9 -7
- package/dist/esm/components/Panel/Panel.js.map +1 -1
- package/dist/esm/components/ProgressBar/ProgressBar.js +2 -1
- package/dist/esm/components/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/esm/components/QueryBuilder/QueryBuilder.js +13 -11
- package/dist/esm/components/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/esm/components/QueryBuilder/Rule/Rule.js +0 -1
- package/dist/esm/components/QueryBuilder/Rule/Rule.js.map +1 -1
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js +1 -2
- package/dist/esm/components/QueryBuilder/RuleGroup/RuleGroup.js.map +1 -1
- package/dist/esm/components/Radio/Radio.js +2 -1
- package/dist/esm/components/Radio/Radio.js.map +1 -1
- package/dist/esm/components/RadioGroup/RadioGroup.js +25 -23
- package/dist/esm/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js +18 -16
- package/dist/esm/components/ScrollTo/Horizontal/ScrollToHorizontal.js.map +1 -1
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js +19 -17
- package/dist/esm/components/ScrollTo/Vertical/ScrollToVertical.js.map +1 -1
- package/dist/esm/components/SelectionList/SelectionList.js +27 -25
- package/dist/esm/components/SelectionList/SelectionList.js.map +1 -1
- package/dist/esm/components/SimpleGrid/SimpleGrid.js +9 -7
- package/dist/esm/components/SimpleGrid/SimpleGrid.js.map +1 -1
- package/dist/esm/components/Slider/Slider.js +37 -35
- package/dist/esm/components/Slider/Slider.js.map +1 -1
- package/dist/esm/components/Snackbar/Snackbar.js +1 -1
- package/dist/esm/components/Snackbar/Snackbar.js.map +1 -1
- package/dist/esm/components/Snackbar/SnackbarContentWrapper/SnackbarContentWrapper.js +1 -1
- package/dist/esm/components/Snackbar/SnackbarContentWrapper/SnackbarContentWrapper.js.map +1 -1
- package/dist/esm/components/Snackbar/SnackbarProvider/SnackbarProvider.js +2 -2
- package/dist/esm/components/Snackbar/SnackbarProvider/SnackbarProvider.js.map +1 -1
- package/dist/esm/components/Stack/Stack.js +13 -11
- package/dist/esm/components/Stack/Stack.js.map +1 -1
- package/dist/esm/components/Switch/Switch.js +2 -1
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Tab/Tab.js +8 -6
- package/dist/esm/components/Tab/Tab.js.map +1 -1
- package/dist/esm/components/Table/Table.js +12 -10
- package/dist/esm/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Table/TableHeader/TableHeader.js +2 -3
- package/dist/esm/components/Table/TableHeader/TableHeader.js.map +1 -1
- package/dist/esm/components/Table/hooks/useRowExpand.js +0 -1
- package/dist/esm/components/Table/hooks/useRowExpand.js.map +1 -1
- package/dist/esm/components/Table/renderers/renderers.js +0 -1
- package/dist/esm/components/Table/renderers/renderers.js.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +6 -4
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/Tag/Tag.js +18 -16
- package/dist/esm/components/Tag/Tag.js.map +1 -1
- package/dist/esm/components/TagsInput/TagsInput.js +39 -37
- package/dist/esm/components/TagsInput/TagsInput.js.map +1 -1
- package/dist/esm/components/TextArea/TextArea.js +2 -1
- package/dist/esm/components/TextArea/TextArea.js.map +1 -1
- package/dist/esm/components/TimeAgo/TimeAgo.js +14 -12
- package/dist/esm/components/TimeAgo/TimeAgo.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.js +3 -2
- package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/esm/components/ToggleButton/ToggleButton.js +2 -2
- package/dist/esm/components/ToggleButton/ToggleButton.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +2 -1
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/Typography/Typography.js +2 -1
- package/dist/esm/components/Typography/Typography.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/Header/Header.js +0 -2
- package/dist/esm/components/VerticalNavigation/Header/Header.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/NavigationSlider/NavigationSlider.js +0 -1
- package/dist/esm/components/VerticalNavigation/NavigationSlider/NavigationSlider.js.map +1 -1
- package/dist/esm/components/VerticalNavigation/VerticalNavigation.js +12 -10
- package/dist/esm/components/VerticalNavigation/VerticalNavigation.js.map +1 -1
- package/dist/esm/hooks/useDefaultProps.js +41 -0
- package/dist/esm/hooks/useDefaultProps.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +76 -59
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import cloneDeep from "lodash/cloneDeep";
|
|
2
2
|
import isEqual from "lodash/isEqual";
|
|
3
|
+
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
3
4
|
import { useState, useRef, useReducer, useContext, useMemo, useEffect } from "react";
|
|
4
5
|
import { QueryBuilderContext } from "./Context.js";
|
|
5
6
|
import { emptyGroup, clearNodeIds } from "./utils/index.js";
|
|
@@ -7,17 +8,18 @@ import reducer from "./utils/reducer.js";
|
|
|
7
8
|
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
8
9
|
import { RuleGroup } from "./RuleGroup/RuleGroup.js";
|
|
9
10
|
import { ConfirmationDialog } from "./ConfirmationDialog/ConfirmationDialog.js";
|
|
10
|
-
const HvQueryBuilder = ({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const HvQueryBuilder = (props) => {
|
|
12
|
+
const {
|
|
13
|
+
attributes,
|
|
14
|
+
query,
|
|
15
|
+
onChange,
|
|
16
|
+
operators,
|
|
17
|
+
combinators,
|
|
18
|
+
maxDepth = 1,
|
|
19
|
+
labels,
|
|
20
|
+
readOnly = false,
|
|
21
|
+
classes
|
|
22
|
+
} = useDefaultProps("HvQueryBuilder", props);
|
|
21
23
|
const [pendingAction, askAction] = useState();
|
|
22
24
|
const currentAttributes = useRef(null);
|
|
23
25
|
const [state, dispatchAction] = useReducer(reducer, query, (initialState2) => initialState2 || emptyGroup());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.js","sources":["../../../../src/components/QueryBuilder/QueryBuilder.tsx"],"sourcesContent":["import cloneDeep from \"lodash/cloneDeep\";\nimport isEqual from \"lodash/isEqual\";\n\nimport {\n useContext,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from \"react\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { ConfirmationDialog } from \"./ConfirmationDialog\";\nimport { QueryBuilderContext } from \"./Context\";\nimport { RuleGroup } from \"./RuleGroup\";\nimport {\n AskAction,\n Attribute,\n Query,\n QueryBuilderLabels,\n QueryCombinator,\n QueryOperator,\n} from \"./types\";\nimport { clearNodeIds, emptyGroup } from \"./utils\";\nimport reducer from \"./utils/reducer\";\nimport { useClasses, staticClasses } from \"./QueryBuilder.styles\";\n\nexport { staticClasses as queryBuilderClasses };\n\nexport type HvQueryBuilderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvQueryBuilderProps {\n attributes?: Record<string, Attribute>;\n /**\n * The query rules operators by attribute type and combinator.\n */\n operators?: Record<string, QueryOperator[]>;\n /**\n * The query combinators operands.\n */\n combinators?: QueryCombinator[];\n /**\n * The initial query representation.\n */\n query?: Query;\n /**\n * Callback fired when query changes.\n * @param {Query} value - the query representation.\n */\n onChange?: (value: Query) => void;\n /**\n * Max depth of nested query groups.\n */\n maxDepth?: number;\n /**\n * An object containing all the labels.\n */\n labels?: QueryBuilderLabels;\n /**\n * A flag indicating if the Query Builder is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Override or extend the styles applied to the component.\n * See CSS API tab for more details.\n */\n classes?: HvQueryBuilderClasses;\n}\n\n/**\n * **HvQueryBuilder** component allows you to create conditions and group them using logical operators.\n * It outputs a structured set of rules which can be easily parsed to create SQL/NoSQL/whatever queries.\n */\nexport const HvQueryBuilder = ({\n attributes,\n
|
|
1
|
+
{"version":3,"file":"QueryBuilder.js","sources":["../../../../src/components/QueryBuilder/QueryBuilder.tsx"],"sourcesContent":["import cloneDeep from \"lodash/cloneDeep\";\nimport isEqual from \"lodash/isEqual\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport {\n useContext,\n useEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from \"react\";\n\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { ConfirmationDialog } from \"./ConfirmationDialog\";\nimport { QueryBuilderContext } from \"./Context\";\nimport { RuleGroup } from \"./RuleGroup\";\nimport {\n AskAction,\n Attribute,\n Query,\n QueryBuilderLabels,\n QueryCombinator,\n QueryOperator,\n} from \"./types\";\nimport { clearNodeIds, emptyGroup } from \"./utils\";\nimport reducer from \"./utils/reducer\";\nimport { useClasses, staticClasses } from \"./QueryBuilder.styles\";\n\nexport { staticClasses as queryBuilderClasses };\n\nexport type HvQueryBuilderClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvQueryBuilderProps {\n attributes?: Record<string, Attribute>;\n /**\n * The query rules operators by attribute type and combinator.\n */\n operators?: Record<string, QueryOperator[]>;\n /**\n * The query combinators operands.\n */\n combinators?: QueryCombinator[];\n /**\n * The initial query representation.\n */\n query?: Query;\n /**\n * Callback fired when query changes.\n * @param {Query} value - the query representation.\n */\n onChange?: (value: Query) => void;\n /**\n * Max depth of nested query groups.\n */\n maxDepth?: number;\n /**\n * An object containing all the labels.\n */\n labels?: QueryBuilderLabels;\n /**\n * A flag indicating if the Query Builder is in read only mode.\n */\n readOnly?: boolean;\n /**\n * Override or extend the styles applied to the component.\n * See CSS API tab for more details.\n */\n classes?: HvQueryBuilderClasses;\n}\n\n/**\n * **HvQueryBuilder** component allows you to create conditions and group them using logical operators.\n * It outputs a structured set of rules which can be easily parsed to create SQL/NoSQL/whatever queries.\n */\nexport const HvQueryBuilder = (props: HvQueryBuilderProps) => {\n const {\n attributes,\n query,\n onChange,\n operators,\n combinators,\n maxDepth = 1,\n labels,\n readOnly = false,\n classes,\n } = useDefaultProps(\"HvQueryBuilder\", props);\n\n const [pendingAction, askAction] = useState<AskAction>();\n const currentAttributes = useRef<\n Record<string, Attribute> | undefined | null\n >(null);\n const [state, dispatchAction] = useReducer(\n reducer,\n query,\n (initialState) => initialState || emptyGroup()\n );\n\n const initialState = query === state;\n const [prevState, setPrevState] = useState();\n\n const defaultContext = useContext(QueryBuilderContext);\n\n const context = useMemo(\n () => ({\n dispatchAction,\n askAction,\n attributes,\n /* eslint-disable react/destructuring-assignment */\n operators: operators ?? defaultContext.operators,\n combinators: combinators ?? defaultContext.combinators,\n maxDepth: maxDepth ?? defaultContext.maxDepth,\n labels: labels ?? defaultContext.labels,\n initialTouched: initialState,\n readOnly,\n }),\n [\n attributes,\n operators,\n defaultContext.operators,\n defaultContext.combinators,\n defaultContext.maxDepth,\n defaultContext.labels,\n combinators,\n maxDepth,\n labels,\n readOnly,\n initialState,\n ]\n );\n\n useEffect(() => {\n if (currentAttributes.current == null) {\n // first run, nothing to do\n currentAttributes.current = attributes;\n } else if (currentAttributes.current !== attributes) {\n // attributes changed, the existing query is almost certain invalid, so reset it\n currentAttributes.current = attributes;\n dispatchAction({ type: \"reset-query\" });\n }\n }, [attributes]);\n\n // Propagate the change if the query is modified.\n useEffect(() => {\n if (!initialState && !isEqual(state, prevState)) {\n onChange?.(clearNodeIds(state));\n setPrevState(cloneDeep(state));\n }\n }, [state, prevState, initialState, onChange]);\n\n const onConfirmHandler = () => {\n if (pendingAction) {\n askAction(undefined);\n pendingAction.actions.forEach((action) => dispatchAction(action));\n }\n };\n\n const onCancelHandler = () => {\n askAction(undefined);\n };\n\n return (\n <QueryBuilderContext.Provider value={context}>\n <RuleGroup\n level={0}\n id={state.id}\n combinator={state.combinator}\n rules={state.rules}\n classes={classes}\n />\n <ConfirmationDialog\n isOpen={pendingAction != null}\n onConfirm={onConfirmHandler}\n onCancel={onCancelHandler}\n title={pendingAction?.dialog.dialogTitle || \"\"}\n message={pendingAction?.dialog.dialogMessage || \"\"}\n confirmButtonLabel={pendingAction?.dialog.dialogConfirm || \"\"}\n cancelButtonLabel={pendingAction?.dialog.dialogCancel || \"\"}\n closeButtonTooltip={pendingAction?.dialog.dialogCloseTooltip || \"\"}\n />\n </QueryBuilderContext.Provider>\n );\n};\n"],"names":["HvQueryBuilder","props","attributes","query","onChange","operators","combinators","maxDepth","labels","readOnly","classes","useDefaultProps","pendingAction","askAction","useState","currentAttributes","useRef","state","dispatchAction","useReducer","reducer","initialState","emptyGroup","prevState","setPrevState","defaultContext","useContext","QueryBuilderContext","context","useMemo","initialTouched","useEffect","current","type","isEqual","clearNodeIds","cloneDeep","onConfirmHandler","undefined","actions","forEach","action","onCancelHandler","_jsxs","Provider","value","children","_jsx","RuleGroup","level","id","combinator","rules","ConfirmationDialog","isOpen","onConfirm","onCancel","title","dialog","dialogTitle","message","dialogMessage","confirmButtonLabel","dialogConfirm","cancelButtonLabel","dialogCancel","closeButtonTooltip","dialogCloseTooltip"],"mappings":";;;;;;;;;;AA4EaA,MAAAA,iBAAiBA,CAACC,UAA+B;AACtD,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACXC;AAAAA,IACAC,WAAW;AAAA,IACXC;AAAAA,EAAAA,IACEC,gBAAgB,kBAAkBV,KAAK;AAE3C,QAAM,CAACW,eAAeC,SAAS,IAAIC,SAAoB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AWvB,WAAAA,eAAeuB,MAAM,CAAC;AAAA,IAClE;AAAA,EAAA;AAGF,QAAMC,kBAAkBA,MAAM;AAC5B7B,cAAUyB,MAAS;AAAA,EAAA;AAInBK,SAAAA,qBAAChB,oBAAoBiB,UAAQ;AAAA,IAACC,OAAOjB;AAAAA,IAAQkB,UAAA,CAC3CC,oBAACC,WAAS;AAAA,MACRC,OAAO;AAAA,MACPC,IAAIjC,MAAMiC;AAAAA,MACVC,YAAYlC,MAAMkC;AAAAA,MAClBC,OAAOnC,MAAMmC;AAAAA,MACb1C;AAAAA,IAAAA,CACD,GACDqC,oBAACM,oBAAkB;AAAA,MACjBC,QAAQ1C,iBAAiB;AAAA,MACzB2C,WAAWlB;AAAAA,MACXmB,UAAUd;AAAAA,MACVe,QAAO7C,+CAAe8C,OAAOC,gBAAe;AAAA,MAC5CC,UAAShD,+CAAe8C,OAAOG,kBAAiB;AAAA,MAChDC,qBAAoBlD,+CAAe8C,OAAOK,kBAAiB;AAAA,MAC3DC,oBAAmBpD,+CAAe8C,OAAOO,iBAAgB;AAAA,MACzDC,qBAAoBtD,+CAAe8C,OAAOS,uBAAsB;AAAA,IAAA,CACjE,CAAC;AAAA,EAAA,CAC0B;AAElC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rule.js","sources":["../../../../../src/components/QueryBuilder/Rule/Rule.tsx"],"sourcesContent":["import { Delete } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useMediaQuery, useTheme } from \"@mui/material\";\n\nimport { useContext, useMemo } from \"react\";\n\nimport { HvGrid } from \"@core/components/Grid\";\nimport { HvButton } from \"@core/components/Button\";\nimport { withTooltip } from \"@core/hocs/withTooltip\";\n\nimport { QueryBuilderContext } from \"../Context\";\nimport { Attribute } from \"./Attribute\";\nimport { Operator } from \"./Operator\";\nimport { Value } from \"./Value\";\nimport { useClasses } from \"./Rule.styles\";\n\nexport interface RuleProps {\n id: number;\n combinator: string;\n attribute: string;\n operator: string;\n value: any;\n disabled: boolean;\n isInvalid: boolean;\n}\n\nexport const Rule = ({\n id,\n combinator,\n attribute,\n operator,\n value,\n disabled,\n isInvalid,\n}: RuleProps) => {\n const { classes, cx } = useClasses();\n\n const context = useContext(QueryBuilderContext);\n\n const theme = useTheme();\n\n const isMdDown = useMediaQuery(theme.breakpoints.down(\"md\"));\n\n const { askAction, attributes, operators, labels, readOnly } = context;\n\n const availableOperators = useMemo(() => {\n const attributeSpec =\n attribute != null && attributes ? attributes[attribute] : null;\n if (attributeSpec != null) {\n const typeOperators = operators[attributeSpec.type];\n if (typeOperators != null) {\n return typeOperators.reduce(\n (count, item) =>\n count + (item.combinators.includes(combinator) ? 1 : 0),\n 0\n );\n }\n }\n\n return -1;\n }, [attribute, attributes, combinator, operators]);\n\n const shouldShowValueInput =\n operator !== \"Empty\" && operator !== \"IsNotEmpty\";\n\n const DeleteIcon = withTooltip(\n () => <Delete />,\n labels.rule.delete.tooltip,\n \"bottom\"\n );\n\n return (\n <HvGrid\n container\n className={cx(classes.root, { [classes.isMdDown]: isMdDown })}\n spacing={0}\n wrap=\"nowrap\"\n >\n <HvGrid item xs={2} lg={3}>\n <Attribute\n attribute={attribute}\n id={id}\n disabled={disabled}\n isInvalid={isInvalid}\n />\n </HvGrid>\n {attribute != null && availableOperators > 0 && (\n <HvGrid item xs={2} lg={3}>\n <Operator\n id={id}\n combinator={combinator}\n attribute={attribute}\n operator={operator}\n />\n </HvGrid>\n )}\n {attribute != null && (operator != null || availableOperators === 0) && (\n <HvGrid item xs>\n {shouldShowValueInput && (\n <Value\n attribute={attribute}\n id={id}\n operator={operator}\n value={value}\n />\n )}\n </HvGrid>\n )}\n <HvGrid item className={classes.actionsContainer}>\n <HvButton\n icon\n aria-label={labels.rule.delete.ariaLabel}\n onClick={() => {\n askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog: labels.rule.delete,\n });\n }}\n disabled={readOnly}\n
|
|
1
|
+
{"version":3,"file":"Rule.js","sources":["../../../../../src/components/QueryBuilder/Rule/Rule.tsx"],"sourcesContent":["import { Delete } from \"@hitachivantara/uikit-react-icons\";\n\nimport { useMediaQuery, useTheme } from \"@mui/material\";\n\nimport { useContext, useMemo } from \"react\";\n\nimport { HvGrid } from \"@core/components/Grid\";\nimport { HvButton } from \"@core/components/Button\";\nimport { withTooltip } from \"@core/hocs/withTooltip\";\n\nimport { QueryBuilderContext } from \"../Context\";\nimport { Attribute } from \"./Attribute\";\nimport { Operator } from \"./Operator\";\nimport { Value } from \"./Value\";\nimport { useClasses } from \"./Rule.styles\";\n\nexport interface RuleProps {\n id: number;\n combinator: string;\n attribute: string;\n operator: string;\n value: any;\n disabled: boolean;\n isInvalid: boolean;\n}\n\nexport const Rule = ({\n id,\n combinator,\n attribute,\n operator,\n value,\n disabled,\n isInvalid,\n}: RuleProps) => {\n const { classes, cx } = useClasses();\n\n const context = useContext(QueryBuilderContext);\n\n const theme = useTheme();\n\n const isMdDown = useMediaQuery(theme.breakpoints.down(\"md\"));\n\n const { askAction, attributes, operators, labels, readOnly } = context;\n\n const availableOperators = useMemo(() => {\n const attributeSpec =\n attribute != null && attributes ? attributes[attribute] : null;\n if (attributeSpec != null) {\n const typeOperators = operators[attributeSpec.type];\n if (typeOperators != null) {\n return typeOperators.reduce(\n (count, item) =>\n count + (item.combinators.includes(combinator) ? 1 : 0),\n 0\n );\n }\n }\n\n return -1;\n }, [attribute, attributes, combinator, operators]);\n\n const shouldShowValueInput =\n operator !== \"Empty\" && operator !== \"IsNotEmpty\";\n\n const DeleteIcon = withTooltip(\n () => <Delete />,\n labels.rule.delete.tooltip,\n \"bottom\"\n );\n\n return (\n <HvGrid\n container\n className={cx(classes.root, { [classes.isMdDown]: isMdDown })}\n spacing={0}\n wrap=\"nowrap\"\n >\n <HvGrid item xs={2} lg={3}>\n <Attribute\n attribute={attribute}\n id={id}\n disabled={disabled}\n isInvalid={isInvalid}\n />\n </HvGrid>\n {attribute != null && availableOperators > 0 && (\n <HvGrid item xs={2} lg={3}>\n <Operator\n id={id}\n combinator={combinator}\n attribute={attribute}\n operator={operator}\n />\n </HvGrid>\n )}\n {attribute != null && (operator != null || availableOperators === 0) && (\n <HvGrid item xs>\n {shouldShowValueInput && (\n <Value\n attribute={attribute}\n id={id}\n operator={operator}\n value={value}\n />\n )}\n </HvGrid>\n )}\n <HvGrid item className={classes.actionsContainer}>\n <HvButton\n icon\n aria-label={labels.rule.delete.ariaLabel}\n onClick={() => {\n askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog: labels.rule.delete,\n });\n }}\n disabled={readOnly}\n >\n <DeleteIcon />\n </HvButton>\n </HvGrid>\n </HvGrid>\n );\n};\n"],"names":["Rule","id","combinator","attribute","operator","value","disabled","isInvalid","classes","cx","useClasses","context","useContext","QueryBuilderContext","theme","useTheme","isMdDown","useMediaQuery","breakpoints","down","askAction","attributes","operators","labels","readOnly","availableOperators","useMemo","attributeSpec","typeOperators","type","reduce","count","item","combinators","includes","shouldShowValueInput","DeleteIcon","withTooltip","_jsx","Delete","rule","delete","tooltip","HvGrid","container","className","root","spacing","wrap","children","xs","lg","Attribute","Operator","Value","actionsContainer","HvButton","icon","ariaLabel","onClick","actions","dialog"],"mappings":";;;;;;;;;;;;AA0BO,MAAMA,OAAOA,CAAC;AAAA,EACnBC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACS,MAAM;AACT,QAAA;AAAA,IAAEC;AAAAA,IAASC;AAAAA,MAAOC,WAAW;AAE7BC,QAAAA,UAAUC,WAAWC,mBAAmB;AAE9C,QAAMC,QAAQC;AAEd,QAAMC,WAAWC,cAAcH,MAAMI,YAAYC,KAAK,IAAI,CAAC;AAErD,QAAA;AAAA,IAAEC;AAAAA,IAAWC;AAAAA,IAAYC;AAAAA,IAAWC;AAAAA,IAAQC;AAAAA,EAAab,IAAAA;AAEzDc,QAAAA,qBAAqBC,QAAQ,MAAM;AACvC,UAAMC,gBACJxB,aAAa,QAAQkB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nD;AAAAA,QACAF;AAAAA,QACAG;AAAAA,QACAC;AAAAA,MAAAA,CACD;AAAA,IAAA,CAEG,GAEViC,oBAACK,QAAM;AAAA,MAACX,MAAI;AAAA,MAACa,WAAWrC,QAAQ+C;AAAAA,MAAiBN,8BAC9CO,UAAQ;AAAA,QACPC,MAAI;AAAA,QACJ,cAAYlC,OAAOiB,KAAKC,OAAOiB;AAAAA,QAC/BC,SAASA,MAAM;AACH,oBAAA;AAAA,YACRC,SAAS,CAAC;AAAA,cAAE/B,MAAM;AAAA,cAAe5B;AAAAA,YAAAA,CAAI;AAAA,YACrC4D,QAAQtC,OAAOiB,KAAKC;AAAAA,UAAAA,CACrB;AAAA,QACH;AAAA,QACAnC,UAAUkB;AAAAA,QAASyB,UAEnBX,oBAACF,YAAY,EAAA;AAAA,MAAA,CACL;AAAA,IAAA,CACJ,CAAC;AAAA,EAAA,CACH;AAEZ;"}
|
|
@@ -15,7 +15,7 @@ const RuleGroup = ({
|
|
|
15
15
|
id,
|
|
16
16
|
combinator = "and",
|
|
17
17
|
rules = [],
|
|
18
|
-
classes: classesProp
|
|
18
|
+
classes: classesProp
|
|
19
19
|
}) => {
|
|
20
20
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
21
21
|
const {
|
|
@@ -115,7 +115,6 @@ const RuleGroup = ({
|
|
|
115
115
|
},
|
|
116
116
|
"aria-label": level === 0 && ((_n = (_m = labels.query) == null ? void 0 : _m.delete) == null ? void 0 : _n.ariaLabel) ? (_p = (_o = labels.query) == null ? void 0 : _o.delete) == null ? void 0 : _p.ariaLabel : labels.group.delete.ariaLabel,
|
|
117
117
|
disabled: readOnly,
|
|
118
|
-
variant: "secondaryGhost",
|
|
119
118
|
children: /* @__PURE__ */ jsx(DeleteIcon, {})
|
|
120
119
|
})
|
|
121
120
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleGroup.js","sources":["../../../../../src/components/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback, useContext } from \"react\";\n\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { HvEmptyState } from \"@core/components/EmptyState\";\nimport { HvGrid } from \"@core/components/Grid\";\nimport { HvMultiButton } from \"@core/components/MultiButton\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { withTooltip } from \"@core/hocs/withTooltip\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { Rule } from \"../Rule\";\nimport { QueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\n\nexport interface RuleGroupProps {\n /**\n * Override or extend the styles applied to the component.\n * See CSS API tab for more details.\n */\n classes?: ExtractNames<typeof useClasses>;\n id?: number;\n level?: number;\n combinator?: string;\n rules?: any[];\n}\n\nexport const RuleGroup = ({\n level = 0,\n id,\n combinator = \"and\",\n rules = [],\n classes: classesProp = {},\n}: RuleGroupProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(QueryBuilderContext);\n\n const { dispatchAction, askAction, maxDepth, combinators, labels, readOnly } =\n context;\n const normalizedMaxDepth = maxDepth - 1;\n\n const actionButtons = (\n <>\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addRule?.label != null\n ? labels.query?.addRule?.label\n : labels.group.addRule.label}\n </HvButton>\n </div>\n {level <= normalizedMaxDepth && (\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addGroup?.label != null\n ? labels.query?.addGroup?.label\n : labels.group.addGroup.label}\n </HvButton>\n </div>\n )}\n </>\n );\n\n const DeleteIcon = withTooltip(\n () => (\n <Delete className={cx({ [classes.topRemoveButtonDisabled]: readOnly })} />\n ),\n level === 0 && labels.query?.delete?.tooltip\n ? labels.query?.delete?.tooltip\n : labels.group.delete.tooltip,\n \"top\"\n );\n\n const onClickCombinator = useCallback(\n (item) => {\n dispatchAction({\n type: \"set-combinator\",\n id,\n combinator: item.operand,\n });\n },\n [dispatchAction, id]\n );\n\n return (\n <div\n className={cx(classes.root, {\n [classes.topGroup]: level === 0,\n [classes.subGroup]: level > 0,\n })}\n >\n <HvGrid container>\n <HvGrid item>\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators &&\n combinators.map((item) => (\n <HvButton\n key={item.operand}\n className={classes.combinatorButton}\n selected={item.operand === combinator}\n onClick={() => item.operand && onClickCombinator(item)}\n disabled={readOnly}\n size=\"xs\"\n >\n {item.label}\n </HvButton>\n ))}\n </HvMultiButton>\n </HvGrid>\n <HvGrid item>\n <div\n className={cx(classes.buttonBackground, classes.topRemoveButton)}\n >\n <HvButton\n icon\n className={classes.removeButton}\n onClick={() => {\n askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog:\n level === 0 && labels.query?.delete != null\n ? labels.query.delete\n : labels.group.delete,\n });\n }}\n aria-label={\n level === 0 && labels.query?.delete?.ariaLabel\n ? labels.query?.delete?.ariaLabel\n : labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n variant=\"secondaryGhost\"\n >\n <DeleteIcon />\n </HvButton>\n </div>\n </HvGrid>\n </HvGrid>\n {rules?.length > 0 && (\n <div\n className={cx(classes.rulesContainer, {\n [classes.subRulesContainer]: level > 0,\n [classes.topRulesContainer]: level === 0,\n })}\n >\n {rules.map((rule, index) => {\n if (\"combinator\" in rule) {\n return (\n <RuleGroup\n key={rule.id ?? index}\n level={level + 1}\n {...rule}\n id={rule.id}\n classes={classes}\n />\n );\n }\n\n const isInvalid =\n combinator === \"and\" &&\n rules.some((r, i) => {\n if (\"attribute\" in r) {\n if (\n r.attribute === rule.attribute &&\n r.id !== rule.id &&\n i < index\n ) {\n return true;\n }\n }\n return false;\n });\n\n return (\n <Rule\n key={rule.id ?? index}\n {...rule}\n isInvalid={isInvalid}\n id={rule.id}\n combinator={combinator}\n />\n );\n })}\n </div>\n )}\n {rules?.length === 0 && (\n <HvEmptyState\n title={labels.empty?.title}\n message={\n <>\n <HvTypography\n variant=\"link\"\n component=\"a\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n style={{ cursor: \"pointer\", textDecoration: \"underline\" }}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n variant=\"link\"\n component=\"a\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n style={{\n cursor: \"pointer\",\n textDecoration: \"underline\",\n }}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <HvGrid container>\n <HvGrid\n item\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </HvGrid>\n </HvGrid>\n </div>\n );\n};\n"],"names":["RuleGroup","level","id","combinator","rules","classes","classesProp","cx","useClasses","context","useContext","QueryBuilderContext","dispatchAction","askAction","maxDepth","combinators","labels","readOnly","normalizedMaxDepth","actionButtons","_Fragment","children","_jsx","className","buttonBackground","HvButton","variant","onClick","type","disabled","startIcon","Add","query","addRule","label","group","addGroup","DeleteIcon","withTooltip","Delete","topRemoveButtonDisabled","delete","tooltip","onClickCombinator","useCallback","item","operand","root","topGroup","subGroup","_jsxs","HvGrid","container","HvMultiButton","topCombinator","map","combinatorButton","selected","size","topRemoveButton","icon","removeButton","actions","dialog","ariaLabel","length","rulesContainer","subRulesContainer","topRulesContainer","rule","index","isInvalid","some","r","i","attribute","Rule","HvEmptyState","title","empty","message","HvTypography","component","style","cursor","textDecoration","createCondition","spacer","createGro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L,YAAO+D,UAAP/D,mBAAcuE,8BACjBN,cAAY;AAAA,YACXvD,SAAQ;AAAA,YACRwD,WAAU;AAAA,YACVvD,SAASA,MAAM;AACE,6BAAA;AAAA,gBAAEC,MAAM;AAAA,gBAAa1B;AAAAA,cAAAA,CAAI;AAAA,YAC1C;AAAA,YACAiF,OAAO;AAAA,cACLC,QAAQ;AAAA,cACRC,gBAAgB;AAAA,YAClB;AAAA,YAAEhE,UAEA,IAAEL,YAAO+D,UAAP/D,mBAAcwE;AAAAA,UAAAA,CACN,CAAC;AAAA,QAAA,CACf,CACH;AAAA,MAAA,CACD;AAAA,MAEJ5B,MAAMtC,oBAACmE,MAAM,EAAA;AAAA,IAAA,CACd,GAEHnE,oBAAC6B,QAAM;AAAA,MAACC,WAAS;AAAA,MAAA/B,8BACd8B,QAAM;AAAA,QACLN,MAAI;AAAA,QACJtB,WAAWhB,GACTF,QAAQqF,uBACRrF,QAAQsF,wBACV;AAAA,QAAEtE,UAEDF;AAAAA,MAAAA,CACK;AAAA,IAAA,CACF,CAAC;AAAA,EAAA,CACN;AAET;"}
|
|
1
|
+
{"version":3,"file":"RuleGroup.js","sources":["../../../../../src/components/QueryBuilder/RuleGroup/RuleGroup.tsx"],"sourcesContent":["import { useCallback, useContext } from \"react\";\n\nimport { Add, Delete, Info } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvButton } from \"@core/components/Button\";\nimport { HvEmptyState } from \"@core/components/EmptyState\";\nimport { HvGrid } from \"@core/components/Grid\";\nimport { HvMultiButton } from \"@core/components/MultiButton\";\nimport { HvTypography } from \"@core/components/Typography\";\nimport { withTooltip } from \"@core/hocs/withTooltip\";\nimport { ExtractNames } from \"@core/utils/classes\";\n\nimport { Rule } from \"../Rule\";\nimport { QueryBuilderContext } from \"../Context\";\nimport { useClasses } from \"../QueryBuilder.styles\";\n\nexport interface RuleGroupProps {\n /**\n * Override or extend the styles applied to the component.\n * See CSS API tab for more details.\n */\n classes?: ExtractNames<typeof useClasses>;\n id?: number;\n level?: number;\n combinator?: string;\n rules?: any[];\n}\n\nexport const RuleGroup = ({\n level = 0,\n id,\n combinator = \"and\",\n rules = [],\n classes: classesProp,\n}: RuleGroupProps) => {\n const { classes, cx } = useClasses(classesProp);\n\n const context = useContext(QueryBuilderContext);\n\n const { dispatchAction, askAction, maxDepth, combinators, labels, readOnly } =\n context;\n const normalizedMaxDepth = maxDepth - 1;\n\n const actionButtons = (\n <>\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addRule?.label != null\n ? labels.query?.addRule?.label\n : labels.group.addRule.label}\n </HvButton>\n </div>\n {level <= normalizedMaxDepth && (\n <div className={classes.buttonBackground}>\n <HvButton\n variant=\"secondarySubtle\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n disabled={readOnly}\n startIcon={<Add />}\n >\n {level === 0 && labels.query?.addGroup?.label != null\n ? labels.query?.addGroup?.label\n : labels.group.addGroup.label}\n </HvButton>\n </div>\n )}\n </>\n );\n\n const DeleteIcon = withTooltip(\n () => (\n <Delete className={cx({ [classes.topRemoveButtonDisabled]: readOnly })} />\n ),\n level === 0 && labels.query?.delete?.tooltip\n ? labels.query?.delete?.tooltip\n : labels.group.delete.tooltip,\n \"top\"\n );\n\n const onClickCombinator = useCallback(\n (item) => {\n dispatchAction({\n type: \"set-combinator\",\n id,\n combinator: item.operand,\n });\n },\n [dispatchAction, id]\n );\n\n return (\n <div\n className={cx(classes.root, {\n [classes.topGroup]: level === 0,\n [classes.subGroup]: level > 0,\n })}\n >\n <HvGrid container>\n <HvGrid item>\n <HvMultiButton\n className={cx(classes.combinator, classes.topCombinator)}\n disabled={readOnly}\n >\n {combinators &&\n combinators.map((item) => (\n <HvButton\n key={item.operand}\n className={classes.combinatorButton}\n selected={item.operand === combinator}\n onClick={() => item.operand && onClickCombinator(item)}\n disabled={readOnly}\n size=\"xs\"\n >\n {item.label}\n </HvButton>\n ))}\n </HvMultiButton>\n </HvGrid>\n <HvGrid item>\n <div\n className={cx(classes.buttonBackground, classes.topRemoveButton)}\n >\n <HvButton\n icon\n className={classes.removeButton}\n onClick={() => {\n askAction({\n actions: [{ type: \"remove-node\", id }],\n dialog:\n level === 0 && labels.query?.delete != null\n ? labels.query.delete\n : labels.group.delete,\n });\n }}\n aria-label={\n level === 0 && labels.query?.delete?.ariaLabel\n ? labels.query?.delete?.ariaLabel\n : labels.group.delete.ariaLabel\n }\n disabled={readOnly}\n >\n <DeleteIcon />\n </HvButton>\n </div>\n </HvGrid>\n </HvGrid>\n {rules?.length > 0 && (\n <div\n className={cx(classes.rulesContainer, {\n [classes.subRulesContainer]: level > 0,\n [classes.topRulesContainer]: level === 0,\n })}\n >\n {rules.map((rule, index) => {\n if (\"combinator\" in rule) {\n return (\n <RuleGroup\n key={rule.id ?? index}\n level={level + 1}\n {...rule}\n id={rule.id}\n classes={classes}\n />\n );\n }\n\n const isInvalid =\n combinator === \"and\" &&\n rules.some((r, i) => {\n if (\"attribute\" in r) {\n if (\n r.attribute === rule.attribute &&\n r.id !== rule.id &&\n i < index\n ) {\n return true;\n }\n }\n return false;\n });\n\n return (\n <Rule\n key={rule.id ?? index}\n {...rule}\n isInvalid={isInvalid}\n id={rule.id}\n combinator={combinator}\n />\n );\n })}\n </div>\n )}\n {rules?.length === 0 && (\n <HvEmptyState\n title={labels.empty?.title}\n message={\n <>\n <HvTypography\n variant=\"link\"\n component=\"a\"\n onClick={() => {\n dispatchAction({ type: \"add-rule\", id });\n }}\n style={{ cursor: \"pointer\", textDecoration: \"underline\" }}\n >\n {`${labels.empty?.createCondition}`}\n </HvTypography>\n {level <= normalizedMaxDepth && (\n <>\n {`${labels.empty?.spacer}`}\n <HvTypography\n variant=\"link\"\n component=\"a\"\n onClick={() => {\n dispatchAction({ type: \"add-group\", id });\n }}\n style={{\n cursor: \"pointer\",\n textDecoration: \"underline\",\n }}\n >\n {`${labels.empty?.createGroup}`}\n </HvTypography>\n </>\n )}\n </>\n }\n icon={<Info />}\n />\n )}\n <HvGrid container>\n <HvGrid\n item\n className={cx(\n classes.actionButtonContainer,\n classes.topActionButtonContainer\n )}\n >\n {actionButtons}\n </HvGrid>\n </HvGrid>\n </div>\n );\n};\n"],"names":["RuleGroup","level","id","combinator","rules","classes","classesProp","cx","useClasses","context","useContext","QueryBuilderContext","dispatchAction","askAction","maxDepth","combinators","labels","readOnly","normalizedMaxDepth","actionButtons","_Fragment","children","_jsx","className","buttonBackground","HvButton","variant","onClick","type","disabled","startIcon","Add","query","addRule","label","group","addGroup","DeleteIcon","withTooltip","Delete","topRemoveButtonDisabled","delete","tooltip","onClickCombinator","useCallback","item","operand","root","topGroup","subGroup","_jsxs","HvGrid","container","HvMultiButton","topCombinator","map","combinatorButton","selected","size","topRemoveButton","icon","removeButton","actions","dialog","ariaLabel","length","rulesContainer","subRulesContainer","topRulesContainer","rule","index","isInvalid","some","r","i","attribute","Rule","HvEmptyState","title","empty","message","HvTypography","component","style","cursor","textDecoration","createCondition","spacer","createGroup","Info","actionButtonContainer","topActionButtonContainer"],"mappings":";;;;;;;;;;;;AA4BO,MAAMA,YAAYA,CAAC;AAAA,EACxBC,QAAQ;AAAA,EACRC;AAAAA,EACAC,aAAa;AAAA,EACbC,QAAQ,CAAE;AAAA,EACVC,SAASC;AACK,MAAM;;AACd,QAAA;AAAA,IAAED;AAAAA,IAASE;AAAAA,EAAAA,IAAOC,WAAWF,WAAW;AAExCG,QAAAA,UAAUC,WAAWC,mBAAmB;AAExC,QAAA;AAAA,IAAEC;AAAAA,IAAgBC;AAAAA,IAAWC;AAAAA,IAAUC;AAAAA,IAAaC;AAAAA,IAAQC;AAAAA,EAChER,IAAAA;AACF,QAAMS,qBAAqBJ,WAAW;AAEhCK,QAAAA,qCACJC,UAAA;AAAA,IAAAC,WACEC,oBAAA,OAAA;AAAA,MAAKC,WAAWlB,QAAQmB;A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BACRrF,QAAQsF,wBACV;AAAA,QAAEtE,UAEDF;AAAAA,MAAAA,CACK;AAAA,IAAA,CACF,CAAC;AAAA,EAAA,CACN;AAET;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState, useCallback } from "react";
|
|
2
|
+
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
2
3
|
import { clsx } from "clsx";
|
|
3
4
|
import { useUniqueId } from "../../hooks/useUniqueId.js";
|
|
4
5
|
import { useControlled } from "../../hooks/useControlled.js";
|
|
@@ -34,7 +35,7 @@ const HvRadio = (props) => {
|
|
|
34
35
|
onFocusVisible,
|
|
35
36
|
onBlur,
|
|
36
37
|
...others
|
|
37
|
-
} = props;
|
|
38
|
+
} = useDefaultProps("HvRadio", props);
|
|
38
39
|
const elementId = useUniqueId(id, "hvradio");
|
|
39
40
|
const [focusVisible, setFocusVisible] = useState(false);
|
|
40
41
|
const onFocusVisibleCallback = useCallback((evt) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\n\nimport { clsx } from \"clsx\";\n\nimport { RadioProps as MuiRadioProps } from \"@mui/material\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvWarningText, HvLabelProps, isInvalid } from \"@core/components/Forms\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\n\nimport {\n StyledDivContainer,\n StyledHvBaseRadio,\n StyledHvFormElement,\n StyledHvLabel,\n} from \"./Radio.styles\";\nimport radioClasses, { HvRadioClasses } from \"./radioClasses\";\n\nexport type HvRadioStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvRadioProps\n extends Omit<MuiRadioProps, \"onChange\" | \"classes\">,\n HvBaseProps<HTMLButtonElement, \"onChange\" | \"color\"> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes?: HvRadioClasses;\n /**\n * Id to be applied to the form element root node.\n */\n id?: string;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided.\n */\n label?: React.ReactNode;\n /**\n * @ignore\n */\n \"aria-label\"?: string;\n /**\n * @ignore\n */\n \"aria-labelledby\"?: string;\n /**\n * @ignore\n */\n \"aria-describedby\"?: string;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that user input is required on the form element.\n *\n * If a single radio button in a group has the required attribute, a radio button in\n * that group must be check, though it doesn't have to be the one with the attribute is applied.\n *\n * For that reason, the component doesn't make any uncontrolled changes to its validation status.\n * That should ideally be managed in the context of a radio button group.\n */\n required?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * If `true` the radio button is selected, if set to `false` the radio button is not selected.\n *\n * When defined the radio button state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n */\n status?: HvRadioStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the radio button.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the radio button is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void;\n /**\n * Whether the selector should use semantic colors.\n */\n semantic?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible?: (event: React.FocusEvent<any>) => void;\n /**\n * @ignore\n */\n onBlur?: (event: React.FocusEvent<any>) => void;\n}\n\n/**\n * A Radio Button is a mechanism that allows user to select just an option from a group of options.\n *\n * It should used in a Radio Button Group to present the user with a range of options from\n * which the user <b>may select just one option</b> to complete their task.\n *\n * Individual use of radio buttons, at least uncontrolled, is unadvised as React state management doesn't\n * respond to the browser's native management of radio inputs checked state.\n */\nexport const HvRadio = (props: HvRadioProps) => {\n const {\n classes,\n className,\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n checked,\n defaultChecked = false,\n onChange,\n status = \"standBy\",\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n semantic = false,\n inputProps,\n onFocusVisible,\n onBlur,\n ...others\n } = props;\n\n const elementId = useUniqueId(id, \"hvradio\");\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible]\n );\n\n const onBlurCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur]\n );\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked)\n );\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(newChecked);\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, setIsChecked, value]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled\n const canShowError =\n ariaErrorMessage == null &&\n status !== undefined &&\n statusMessage !== undefined;\n\n const hasLabel = label != null;\n\n const isStateInvalid = isInvalid(status);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n const radio = (\n <StyledHvBaseRadio\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n className={clsx(\n radioClasses.radio,\n classes?.radio,\n isStateInvalid && clsx(radioClasses.invalidRadio, classes?.invalidRadio)\n )}\n $invalid={isStateInvalid}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n semantic={semantic}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n\n return (\n <StyledHvFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={clsx(className, radioClasses.root, classes?.root)}\n >\n {hasLabel ? (\n <StyledDivContainer\n className={clsx(\n radioClasses.container,\n classes?.container,\n disabled && clsx(radioClasses.disabled, classes?.disabled),\n focusVisible &&\n label &&\n clsx(radioClasses.focusVisible, classes?.focusVisible),\n isStateInvalid &&\n clsx(radioClasses.invalidContainer, classes?.invalidContainer)\n )}\n $invalid={isStateInvalid}\n $focusVisible={!!(focusVisible && label)}\n $disabled={disabled}\n >\n {radio}\n <StyledHvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={clsx(radioClasses.label, classes?.label)}\n $disabled={disabled}\n {...labelProps}\n />\n </StyledDivContainer>\n ) : (\n radio\n )}\n {canShowError && (\n <HvWarningText id={setId(elementId, \"error\")} disableBorder>\n {statusMessage}\n </HvWarningText>\n )}\n </StyledHvFormElement>\n );\n};\n"],"names":["HvRadio","props","classes","className","id","name","value","required","readOnly","disabled","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","labelProps","checked","defaultChecked","onChange","status","statusMessage","ariaErrorMessage","semantic","inputProps","onFocusVisible","onBlur","others","elementId","useUniqueId","focusVisible","setFocusVisible","useState","onFocusVisibleCallback","useCallback","evt","onBlurCallback","isChecked","setIsChecked","useControlled","Boolean","onLocalChange","newChecked","canShowError","undefined","hasLabel","isStateInvalid","isInvalid","errorMessageId","setId","radio","StyledHvBaseRadio","clsx","radioClasses","invalidRadio","$invalid","StyledHvFormElement","root","children","_jsxs","StyledDivContainer","container","invalidContainer","$focusVisible","$disabled","_jsx","StyledHvLabel","htmlFor","HvWarningText","disableBorder"],"mappings":";;;;;;;;;;AAsJaA,MAAAA,UAAUA,CAACC,UAAwB;AACxC,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnB,oBAAoBC;AAAAA,IACpBC;AAAAA,IACAC;AAAAA,IACAC,iBAAiB;AAAA,IACjBC;AAAAA,IACAC,SAAS;AAAA,IACTC;AAAAA,IACA,qBAAqBC;AAAAA,IACrBC,WAAW;AAAA,IACXC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EACDxB,IAAAA;AAEEyB,QAAAA,YAAYC,YAAYvB,IAAI,SAAS;AAE3C,QAAM,CAACwB,cAAcC,eAAe,IAAIC,SAAS,KAAK;AAEhDC,QAAAA,yBAAyBC,YAC7B,CAACC,QAA+B;AAC9BJ,oBAAgB,IAAI;AACpBN,qDAAiBU;AAAAA,EAAG,GAEtB,CAACV,cAAc,CACjB;AAEMW,QAAAA,iBAAiBF,YACrB,CAACC,QAA+B;AAC9BJ,oBAAgB,KAAK;AACrBL,qCAASS;AAAAA,EAAG,GAEd,CAACT,MAAM,CACT;A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AWgD,aAAaI,MAAMrD,mCAASqD,IAAI;AAAA,IAAEC,UAE5Db,CAAAA,WACCc,qBAACC,oBAAkB;AAAA,MACjBvD,WAAW+C,KACTC,aAAaQ,WACbzD,mCAASyD,WACTlD,YAAYyC,KAAKC,aAAa1C,UAAUP,mCAASO,QAAQ,GACzDmB,gBACElB,SACAwC,KAAKC,aAAavB,cAAc1B,mCAAS0B,YAAY,GACvDgB,kBACEM,KAAKC,aAAaS,kBAAkB1D,mCAAS0D,gBAAgB,CACjE;AAAA,MACAP,UAAUT;AAAAA,MACViB,eAAe,CAAC,EAAEjC,gBAAgBlB;AAAAA,MAClCoD,WAAWrD;AAAAA,MAAS+C,UAEnBR,CAAAA,OACDe,oBAACC,eAAa;AAAA,QACZ5D,IAAI2C,MAAMrB,WAAW,OAAO;AAAA,QAC5BuC,SAASlB,MAAMrB,WAAW,OAAO;AAAA,QACjChB;AAAAA,QACAP,WAAW+C,KAAKC,aAAazC,OAAOR,mCAASQ,KAAK;AAAA,QAClDoD,WAAWrD;AAAAA,QAAS,GAChBK;AAAAA,MAAAA,CACL,CAAC;AAAA,IACgB,CAAA,IAEpBkC,OAEDP,oCACEyB,eAAa;AAAA,MAAC9D,IAAI2C,MAAMrB,WAAW,OAAO;AAAA,MAAGyC,eAAa;AAAA,MAAAX,UACxDrC;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACkB;AAEzB;"}
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import React, { useCallback, useState } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { clsx } from \"clsx\";\n\nimport { RadioProps as MuiRadioProps } from \"@mui/material\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { HvWarningText, HvLabelProps, isInvalid } from \"@core/components/Forms\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\n\nimport {\n StyledDivContainer,\n StyledHvBaseRadio,\n StyledHvFormElement,\n StyledHvLabel,\n} from \"./Radio.styles\";\nimport radioClasses, { HvRadioClasses } from \"./radioClasses\";\n\nexport type HvRadioStatus = \"standBy\" | \"valid\" | \"invalid\";\n\nexport interface HvRadioProps\n extends Omit<MuiRadioProps, \"onChange\" | \"classes\">,\n HvBaseProps<HTMLButtonElement, \"onChange\" | \"color\"> {\n /**\n * Class names to be applied.\n */\n className?: string;\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes?: HvRadioClasses;\n /**\n * Id to be applied to the form element root node.\n */\n id?: string;\n /**\n * The form element name.\n */\n name?: string;\n /**\n * The value of the form element.\n *\n * The default value is \"on\".\n */\n value?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided.\n */\n label?: React.ReactNode;\n /**\n * @ignore\n */\n \"aria-label\"?: string;\n /**\n * @ignore\n */\n \"aria-labelledby\"?: string;\n /**\n * @ignore\n */\n \"aria-describedby\"?: string;\n /**\n * Properties passed on to the label element.\n */\n labelProps?: HvLabelProps;\n /**\n * Indicates that user input is required on the form element.\n *\n * If a single radio button in a group has the required attribute, a radio button in\n * that group must be check, though it doesn't have to be the one with the attribute is applied.\n *\n * For that reason, the component doesn't make any uncontrolled changes to its validation status.\n * That should ideally be managed in the context of a radio button group.\n */\n required?: boolean;\n /**\n * Indicates that the form element is not editable.\n */\n readOnly?: boolean;\n /**\n * Indicates that the form element is disabled.\n */\n disabled?: boolean;\n /**\n * If `true` the radio button is selected, if set to `false` the radio button is not selected.\n *\n * When defined the radio button state becomes controlled.\n */\n checked?: boolean;\n /**\n * When uncontrolled, defines the initial checked state.\n */\n defaultChecked?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n */\n status?: HvRadioStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: string;\n /**\n * Identifies the element that provides an error message for the radio button.\n *\n * Will only be used when the validation status is invalid.\n */\n \"aria-errormessage\"?: string;\n /**\n * The callback fired when the radio button is pressed.\n */\n onChange?: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void;\n /**\n * Whether the selector should use semantic colors.\n */\n semantic?: boolean;\n /**\n * Properties passed on to the input element.\n */\n inputProps?: React.InputHTMLAttributes<HTMLInputElement>;\n /**\n * Callback fired when the component is focused with a keyboard.\n * We trigger a `onFocus` callback too.\n */\n onFocusVisible?: (event: React.FocusEvent<any>) => void;\n /**\n * @ignore\n */\n onBlur?: (event: React.FocusEvent<any>) => void;\n}\n\n/**\n * A Radio Button is a mechanism that allows user to select just an option from a group of options.\n *\n * It should used in a Radio Button Group to present the user with a range of options from\n * which the user <b>may select just one option</b> to complete their task.\n *\n * Individual use of radio buttons, at least uncontrolled, is unadvised as React state management doesn't\n * respond to the browser's native management of radio inputs checked state.\n */\nexport const HvRadio = (props: HvRadioProps) => {\n const {\n classes,\n className,\n id,\n name,\n value = \"on\",\n required = false,\n readOnly = false,\n disabled = false,\n label,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n labelProps,\n checked,\n defaultChecked = false,\n onChange,\n status = \"standBy\",\n statusMessage,\n \"aria-errormessage\": ariaErrorMessage,\n semantic = false,\n inputProps,\n onFocusVisible,\n onBlur,\n ...others\n } = useDefaultProps(\"HvRadio\", props);\n\n const elementId = useUniqueId(id, \"hvradio\");\n\n const [focusVisible, setFocusVisible] = useState(false);\n\n const onFocusVisibleCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(true);\n onFocusVisible?.(evt);\n },\n [onFocusVisible]\n );\n\n const onBlurCallback = useCallback(\n (evt: React.FocusEvent<any>) => {\n setFocusVisible(false);\n onBlur?.(evt);\n },\n [onBlur]\n );\n\n const [isChecked, setIsChecked] = useControlled(\n checked,\n Boolean(defaultChecked)\n );\n\n const onLocalChange = useCallback(\n (evt: React.ChangeEvent<HTMLInputElement>, newChecked: boolean) => {\n setIsChecked(newChecked);\n\n onChange?.(evt, newChecked, value);\n },\n [onChange, setIsChecked, value]\n );\n\n // the error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled\n const canShowError =\n ariaErrorMessage == null &&\n status !== undefined &&\n statusMessage !== undefined;\n\n const hasLabel = label != null;\n\n const isStateInvalid = isInvalid(status);\n\n let errorMessageId: string | undefined;\n if (isStateInvalid) {\n errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n }\n\n const radio = (\n <StyledHvBaseRadio\n id={label ? setId(elementId, \"input\") : setId(id, \"input\")}\n name={name}\n className={clsx(\n radioClasses.radio,\n classes?.radio,\n isStateInvalid && clsx(radioClasses.invalidRadio, classes?.invalidRadio)\n )}\n $invalid={isStateInvalid}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onLocalChange}\n value={value}\n checked={isChecked}\n semantic={semantic}\n inputProps={{\n \"aria-invalid\": isStateInvalid ? true : undefined,\n \"aria-errormessage\": errorMessageId,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n ...inputProps,\n }}\n onFocusVisible={onFocusVisibleCallback}\n onBlur={onBlurCallback}\n {...others}\n />\n );\n\n return (\n <StyledHvFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={clsx(className, radioClasses.root, classes?.root)}\n >\n {hasLabel ? (\n <StyledDivContainer\n className={clsx(\n radioClasses.container,\n classes?.container,\n disabled && clsx(radioClasses.disabled, classes?.disabled),\n focusVisible &&\n label &&\n clsx(radioClasses.focusVisible, classes?.focusVisible),\n isStateInvalid &&\n clsx(radioClasses.invalidContainer, classes?.invalidContainer)\n )}\n $invalid={isStateInvalid}\n $focusVisible={!!(focusVisible && label)}\n $disabled={disabled}\n >\n {radio}\n <StyledHvLabel\n id={setId(elementId, \"label\")}\n htmlFor={setId(elementId, \"input\")}\n label={label}\n className={clsx(radioClasses.label, classes?.label)}\n $disabled={disabled}\n {...labelProps}\n />\n </StyledDivContainer>\n ) : (\n radio\n )}\n {canShowError && (\n <HvWarningText id={setId(elementId, \"error\")} disableBorder>\n {statusMessage}\n </HvWarningText>\n )}\n </StyledHvFormElement>\n );\n};\n"],"names":["HvRadio","props","classes","className","id","name","value","required","readOnly","disabled","label","ariaLabel","ariaLabelledBy","ariaDescribedBy","labelProps","checked","defaultChecked","onChange","status","statusMessage","ariaErrorMessage","semantic","inputProps","onFocusVisible","onBlur","others","useDefaultProps","elementId","useUniqueId","focusVisible","setFocusVisible","useState","onFocusVisibleCallback","useCallback","evt","onBlurCallback","isChecked","setIsChecked","useControlled","Boolean","onLocalChange","newChecked","canShowError","undefined","hasLabel","isStateInvalid","isInvalid","errorMessageId","setId","radio","StyledHvBaseRadio","clsx","radioClasses","invalidRadio","$invalid","StyledHvFormElement","root","children","_jsxs","StyledDivContainer","container","invalidContainer","$focusVisible","$disabled","_jsx","StyledHvLabel","htmlFor","HvWarningText","disableBorder"],"mappings":";;;;;;;;;;;AAuJaA,MAAAA,UAAUA,CAACC,UAAwB;AACxC,QAAA;AAAA,IACJC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,QAAQ;AAAA,IACRC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC;AAAAA,IACA,cAAcC;AAAAA,IACd,mBAAmBC;AAAAA,IACnB,oBAAoBC;AAAAA,IACpBC;AAAAA,IACAC;AAAAA,IACAC,iBAAiB;AAAA,IACjBC;AAAAA,IACAC,SAAS;AAAA,IACTC;AAAAA,IACA,qBAAqBC;AAAAA,IACrBC,WAAW;AAAA,IACXC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACA,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,WAAWzB,K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1,4 +1,5 @@
|
|
|
1
1
|
import { useCallback, useMemo, Children, cloneElement } from "react";
|
|
2
|
+
import { useDefaultProps } from "../../hooks/useDefaultProps.js";
|
|
2
3
|
import { clsx } from "clsx";
|
|
3
4
|
import { useUniqueId } from "../../hooks/useUniqueId.js";
|
|
4
5
|
import { useControlled } from "../../hooks/useControlled.js";
|
|
@@ -22,29 +23,30 @@ const getValueFromSelectedChildren = (children) => {
|
|
|
22
23
|
}
|
|
23
24
|
return null;
|
|
24
25
|
};
|
|
25
|
-
const HvRadioGroup = ({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
const HvRadioGroup = (props) => {
|
|
27
|
+
const {
|
|
28
|
+
id,
|
|
29
|
+
classes,
|
|
30
|
+
className,
|
|
31
|
+
children,
|
|
32
|
+
name,
|
|
33
|
+
value: valueProp,
|
|
34
|
+
defaultValue,
|
|
35
|
+
label,
|
|
36
|
+
description,
|
|
37
|
+
status,
|
|
38
|
+
statusMessage,
|
|
39
|
+
required = false,
|
|
40
|
+
readOnly = false,
|
|
41
|
+
disabled = false,
|
|
42
|
+
orientation = "vertical",
|
|
43
|
+
"aria-label": ariaLabel,
|
|
44
|
+
"aria-labelledby": ariaLabelledBy,
|
|
45
|
+
"aria-describedby": ariaDescribedBy,
|
|
46
|
+
"aria-errormessage": ariaErrorMessage,
|
|
47
|
+
onChange,
|
|
48
|
+
...others
|
|
49
|
+
} = useDefaultProps("HvRadioGroup", props);
|
|
48
50
|
const elementId = useUniqueId(id, "hvradiogroup");
|
|
49
51
|
const [value, setValue] = useControlled(valueProp, defaultValue !== void 0 ? defaultValue : (
|
|
50
52
|
// When uncontrolled and no default value is given,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sources":["../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { Children, useMemo, useCallback, cloneElement } from \"react\";\n\nimport { clsx } from \"clsx\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\nimport {\n HvFormStatus,\n HvInfoMessage,\n HvWarningText,\n} from \"@core/components/Forms\";\n\nimport {\n StyledFormElement,\n StyledGroup,\n StyledLabel,\n} from \"./RadioGroup.styles\";\nimport radioGroupClasses, { HvRadioGroupClasses } from \"./radioGroupClasses\";\n\nexport interface HvRadioGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children radio buttons, unless they already have one (which they shouldn't).\n */\n name?: string;\n /**\n * The value of the form element, represented in one of the child radio buttons values.\n *\n * When defined the radio button group state becomes controlled.\n */\n value?: any;\n /**\n * When uncontrolled, defines the initial value.\n */\n defaultValue?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * Indicates that the form element is disabled.\n * If `true` the state is propagated to the children radio buttons.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children radio buttons.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n * If `true` the state is propagated to the children radio buttons' input element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: React.ReactNode;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any) => void;\n /**\n * Indicates whether the radio buttons group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvRadioGroupClasses;\n}\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const childrenArray = Children.toArray(children);\n const childrenCount = childrenArray.length;\n for (let i = 0; i !== childrenCount; i += 1) {\n const child: any = childrenArray[i];\n\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n if (childIsSelected) {\n return child?.props?.value;\n }\n }\n\n return null;\n};\n\n/**\n * A group of radio buttons.\n *\n * A radio group is a type of selection list that can only have a single entry checked at any one time.\n */\nexport const HvRadioGroup = ({\n id,\n classes,\n className,\n children,\n name,\n value: valueProp,\n defaultValue,\n label,\n description,\n status,\n statusMessage,\n required = false,\n readOnly = false,\n disabled = false,\n orientation = \"vertical\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n}: HvRadioGroupProps) => {\n const elementId = useUniqueId(id, \"hvradiogroup\");\n\n const [value, setValue] = useControlled(\n valueProp,\n defaultValue !== undefined\n ? defaultValue\n : // When uncontrolled and no default value is given,\n // extract the initial selected values from the children own state\n () => getValueFromSelectedChildren(children)\n );\n\n const onChildChangeInterceptor = useCallback(\n (\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n newValue: any\n ) => {\n childOnChange?.(event, isChecked, newValue);\n\n onChange?.(event, newValue);\n\n setValue(newValue);\n },\n [onChange, setValue]\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any) => {\n const childValue = child?.props?.value ?? \"on\";\n\n const childIsSelected = childValue === value;\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name || elementId,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n newValue: any\n ) =>\n onChildChangeInterceptor(\n child?.props?.onChange,\n event,\n isChecked,\n newValue\n ),\n inputProps: {\n ...child?.props?.inputProps,\n // Set the required attribute directly in the input\n // the radio form element context shouldn't be aware so the\n // label doesn't show redundant asterisk\n required,\n },\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n elementId,\n name,\n onChildChangeInterceptor,\n readOnly,\n required,\n value,\n ]);\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n\n return (\n <StyledFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={clsx(className, classes?.root, radioGroupClasses.root)}\n >\n {label && (\n <StyledLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={clsx(classes?.label, radioGroupClasses.label)}\n />\n )}\n\n {description && (\n <HvInfoMessage id={setId(elementId, \"description\")}>\n {description}\n </HvInfoMessage>\n )}\n\n <StyledGroup\n role=\"radiogroup\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={status === \"invalid\" ? errorMessageId : undefined}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n className={clsx(\n classes?.group,\n radioGroupClasses.group,\n orientation === \"vertical\" &&\n clsx(classes?.vertical, radioGroupClasses.vertical),\n orientation === \"horizontal\" &&\n clsx(classes?.horizontal, radioGroupClasses.horizontal),\n status === \"invalid\" &&\n clsx(classes?.invalid, radioGroupClasses.invalid)\n )}\n $vertical={orientation === \"vertical\"}\n $horizontal={orientation === \"horizontal\"}\n $invalid={status === \"invalid\"}\n {...others}\n >\n {modifiedChildren}\n </StyledGroup>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={clsx(classes?.error, radioGroupClasses.error)}\n >\n {statusMessage}\n </HvWarningText>\n )}\n </StyledFormElement>\n );\n};\n"],"names":["getValueFromSelectedChildren","children","childrenArray","Children","toArray","childrenCount","length","i","child","childIsControlled","props","checked","undefined","childIsSelected","defaultChecked","value","HvRadioGroup","id","classes","className","name","valueProp","defaultValue","label","description","status","statusMessage","required","readOnly","disabled","orientation","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaErrorMessage","onChange","others","elementId","useUniqueId","setValue","useControlled","onChildChangeInterceptor","useCallback","childOnChange","event","isChecked","newValue","modifiedChildren","useMemo","map","childValue","cloneElement","inputProps","canShowError","errorMessageId","setId","StyledFormElement","clsx","root","radioGroupClasses","_jsx","StyledLabel","HvInfoMessage","StyledGroup","role","join","trim","group","vertical","horizontal","invalid","$vertical","$horizontal","$invalid","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;;;AA8FA,MAAMA,+BAA+BA,CAACC,aAA8B;;AAC5DC,QAAAA,gBAAgBC,SAASC,QAAQH,QAAQ;AAC/C,QAAMI,gBAAgBH,cAAcI;AACpC,WAASC,IAAI,GAAGA,MAAMF,eAAeE,KAAK,GAAG;AACrCC,UAAAA,QAAaN,cAAcK,CAAC;AAE5BE,UAAAA,sBAAoBD,oCAAOE,UAAPF,mBAAcG,aAAYC;AACpD,UAAMC,kBAAkBJ,qBACpBD,oCAAOE,UAA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AAmBa,WAAW,YAAY6B,iBAAiB1C;AAAAA,MAC3D,oBACE,CAACY,eAAe+B,MAAMlB,WAAW,aAAa,GAAGJ,eAAe,EAC7DgC,KAAK,GAAG,EACRC,UAAUtD;AAAAA,MAEfO,WAAWsC,KACTvC,mCAASiD,OACTR,kBAAkBQ,OAClBrC,gBAAgB,cACd2B,KAAKvC,mCAASkD,UAAUT,kBAAkBS,QAAQ,GACpDtC,gBAAgB,gBACd2B,KAAKvC,mCAASmD,YAAYV,kBAAkBU,UAAU,GACxD5C,WAAW,aACTgC,KAAKvC,mCAASoD,SAASX,kBAAkBW,OAAO,CACpD;AAAA,MACAC,WAAWzC,gBAAgB;AAAA,MAC3B0C,aAAa1C,gBAAgB;AAAA,MAC7B2C,UAAUhD,WAAW;AAAA,MAAU,GAC3BW;AAAAA,MAAMnC,UAET8C;AAAAA,IAAAA,CACU,GAEZM,gBACCO,oBAACc,eAAa;AAAA,MACZzD,IAAIsC,MAAMlB,WAAW,OAAO;AAAA,MAC5BsC,eAAa;AAAA,MACbxD,WAAWsC,KAAKvC,mCAAS0D,OAAOjB,kBAAkBiB,KAAK;AAAA,MAAE3E,UAExDyB;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACgB;AAEvB;"}
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sources":["../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import { Children, useMemo, useCallback, cloneElement } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { clsx } from \"clsx\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useControlled } from \"@core/hooks/useControlled\";\nimport { setId } from \"@core/utils/setId\";\nimport {\n HvFormStatus,\n HvInfoMessage,\n HvWarningText,\n} from \"@core/components/Forms\";\n\nimport {\n StyledFormElement,\n StyledGroup,\n StyledLabel,\n} from \"./RadioGroup.styles\";\nimport radioGroupClasses, { HvRadioGroupClasses } from \"./radioGroupClasses\";\n\nexport interface HvRadioGroupProps\n extends HvBaseProps<HTMLDivElement, \"onChange\"> {\n /**\n * The form element name.\n *\n * It is propagated to the children radio buttons, unless they already have one (which they shouldn't).\n */\n name?: string;\n /**\n * The value of the form element, represented in one of the child radio buttons values.\n *\n * When defined the radio button group state becomes controlled.\n */\n value?: any;\n /**\n * When uncontrolled, defines the initial value.\n */\n defaultValue?: any;\n /**\n * The label of the form element.\n *\n * The form element must be labeled for accessibility reasons.\n * If not provided, an aria-label or aria-labelledby must be provided instead.\n */\n label?: React.ReactNode;\n /**\n * Provide additional descriptive text for the form element.\n */\n description?: React.ReactNode;\n /**\n * Indicates that the form element is disabled.\n * If `true` the state is propagated to the children radio buttons.\n */\n disabled?: boolean;\n /**\n * Indicates that the form element is not editable.\n * If `true` the state is propagated to the children radio buttons.\n */\n readOnly?: boolean;\n /**\n * Indicates that user input is required on the form element.\n * If `true` the state is propagated to the children radio buttons' input element.\n */\n required?: boolean;\n /**\n * The status of the form element.\n *\n * Valid is correct, invalid is incorrect and standBy means no validations have run.\n *\n * When uncontrolled and unspecified it will default to \"standBy\" and change to either \"valid\"\n * or \"invalid\" after any change to the state.\n */\n status?: HvFormStatus;\n /**\n * The error message to show when `status` is \"invalid\".\n */\n statusMessage?: React.ReactNode;\n /**\n * The callback fired when the value changes.\n */\n onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: any) => void;\n /**\n * Indicates whether the radio buttons group's orientation is horizontal or vertical.\n *\n * Defaults to vertical.\n */\n orientation?: \"vertical\" | \"horizontal\";\n /**\n * A Jss Object used to override or extend the component styles applied.\n */\n classes?: HvRadioGroupClasses;\n}\n\nconst getValueFromSelectedChildren = (children: React.ReactNode) => {\n const childrenArray = Children.toArray(children);\n const childrenCount = childrenArray.length;\n for (let i = 0; i !== childrenCount; i += 1) {\n const child: any = childrenArray[i];\n\n const childIsControlled = child?.props?.checked !== undefined;\n const childIsSelected = childIsControlled\n ? child?.props?.checked\n : child?.props?.defaultChecked;\n\n if (childIsSelected) {\n return child?.props?.value;\n }\n }\n\n return null;\n};\n\n/**\n * A group of radio buttons.\n *\n * A radio group is a type of selection list that can only have a single entry checked at any one time.\n */\nexport const HvRadioGroup = (props: HvRadioGroupProps) => {\n const {\n id,\n classes,\n className,\n children,\n name,\n value: valueProp,\n defaultValue,\n label,\n description,\n status,\n statusMessage,\n required = false,\n readOnly = false,\n disabled = false,\n orientation = \"vertical\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n \"aria-describedby\": ariaDescribedBy,\n \"aria-errormessage\": ariaErrorMessage,\n onChange,\n ...others\n } = useDefaultProps(\"HvRadioGroup\", props);\n\n const elementId = useUniqueId(id, \"hvradiogroup\");\n\n const [value, setValue] = useControlled(\n valueProp,\n defaultValue !== undefined\n ? defaultValue\n : // When uncontrolled and no default value is given,\n // extract the initial selected values from the children own state\n () => getValueFromSelectedChildren(children)\n );\n\n const onChildChangeInterceptor = useCallback(\n (\n childOnChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n checked: boolean,\n value: any\n ) => void,\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n newValue: any\n ) => {\n childOnChange?.(event, isChecked, newValue);\n\n onChange?.(event, newValue);\n\n setValue(newValue);\n },\n [onChange, setValue]\n );\n\n const modifiedChildren = useMemo(() => {\n return Children.map(children, (child: any) => {\n const childValue = child?.props?.value ?? \"on\";\n\n const childIsSelected = childValue === value;\n\n return cloneElement(child, {\n checked: childIsSelected,\n name: child?.props?.name || name || elementId,\n onChange: (\n event: React.ChangeEvent<HTMLInputElement>,\n isChecked: boolean,\n newValue: any\n ) =>\n onChildChangeInterceptor(\n child?.props?.onChange,\n event,\n isChecked,\n newValue\n ),\n inputProps: {\n ...child?.props?.inputProps,\n // Set the required attribute directly in the input\n // the radio form element context shouldn't be aware so the\n // label doesn't show redundant asterisk\n required,\n },\n disabled: disabled || child?.props?.disabled,\n readOnly: readOnly || child?.props?.readOnly,\n });\n });\n }, [\n children,\n disabled,\n elementId,\n name,\n onChildChangeInterceptor,\n readOnly,\n required,\n value,\n ]);\n\n // The error message area will only be created if:\n // - an external element that provides an error message isn't identified via aria-errormessage AND\n // - both status and statusMessage properties are being controlled OR\n // - status is uncontrolled and required is true\n const canShowError =\n ariaErrorMessage == null &&\n ((status !== undefined && statusMessage !== undefined) ||\n (status === undefined && required));\n\n const errorMessageId = canShowError\n ? setId(elementId, \"error\")\n : ariaErrorMessage;\n\n return (\n <StyledFormElement\n id={id}\n name={name}\n status={status || \"standBy\"}\n disabled={disabled}\n required={required}\n readOnly={readOnly}\n className={clsx(className, classes?.root, radioGroupClasses.root)}\n >\n {label && (\n <StyledLabel\n id={setId(elementId, \"label\")}\n label={label}\n className={clsx(classes?.label, radioGroupClasses.label)}\n />\n )}\n\n {description && (\n <HvInfoMessage id={setId(elementId, \"description\")}>\n {description}\n </HvInfoMessage>\n )}\n\n <StyledGroup\n role=\"radiogroup\"\n aria-label={ariaLabel}\n aria-labelledby={\n ariaLabelledBy || (label && setId(elementId, \"label\")) || undefined\n }\n aria-invalid={status === \"invalid\" ? true : undefined}\n aria-errormessage={status === \"invalid\" ? errorMessageId : undefined}\n aria-describedby={\n [description && setId(elementId, \"description\"), ariaDescribedBy]\n .join(\" \")\n .trim() || undefined\n }\n className={clsx(\n classes?.group,\n radioGroupClasses.group,\n orientation === \"vertical\" &&\n clsx(classes?.vertical, radioGroupClasses.vertical),\n orientation === \"horizontal\" &&\n clsx(classes?.horizontal, radioGroupClasses.horizontal),\n status === \"invalid\" &&\n clsx(classes?.invalid, radioGroupClasses.invalid)\n )}\n $vertical={orientation === \"vertical\"}\n $horizontal={orientation === \"horizontal\"}\n $invalid={status === \"invalid\"}\n {...others}\n >\n {modifiedChildren}\n </StyledGroup>\n\n {canShowError && (\n <HvWarningText\n id={setId(elementId, \"error\")}\n disableBorder\n className={clsx(classes?.error, radioGroupClasses.error)}\n >\n {statusMessage}\n </HvWarningText>\n )}\n </StyledFormElement>\n );\n};\n"],"names":["getValueFromSelectedChildren","children","childrenArray","Children","toArray","childrenCount","length","i","child","childIsControlled","props","checked","undefined","childIsSelected","defaultChecked","value","HvRadioGroup","id","classes","className","name","valueProp","defaultValue","label","description","status","statusMessage","required","readOnly","disabled","orientation","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaErrorMessage","onChange","others","useDefaultProps","elementId","useUniqueId","setValue","useControlled","onChildChangeInterceptor","useCallback","childOnChange","event","isChecked","newValue","modifiedChildren","useMemo","map","childValue","cloneElement","inputProps","canShowError","errorMessageId","setId","StyledFormElement","clsx","root","radioGroupClasses","_jsx","StyledLabel","HvInfoMessage","StyledGroup","role","join","trim","group","vertical","horizontal","invalid","$vertical","$horizontal","$invalid","HvWarningText","disableBorder","error"],"mappings":";;;;;;;;;;;AA+FA,MAAMA,+BAA+BA,CAACC,aAA8B;;AAC5DC,QAAAA,gBAAgBC,SAASC,QAAQH,QAAQ;AAC/C,QAAMI,gBAAgBH,cAAcI;AACpC,WAASC,IAAI,GAAGA,MAAMF,eAAeE,KAAK,GAAG;AACrCC,UAAAA,QAAaN,cAAcK,CAAC;AAE5BE,UAAAA,sBAAoBD,oCAAOE,UAAPF,mBAAcG,aAAYC;AACpD,UAAMC,kBAAkBJ,qBACpBD,oCAAOE,UAAPF,mBAAcG,WACdH,oCAAOE,UAAPF,mBAAcM;AAElB,QAAID,iBAAiB;AACnB,cAAOL,oCAAOE,UAAPF,mBAAcO;AAAAA,IACvB;AAAA,EACF;AAEO,SAAA;AACT;AAOaC,MAAAA,eAAeA,CAACN,UAA6B;AAClD,QAAA;AAAA,IACJO;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAlB;AAAAA,IACAmB;AAAAA,IACAL,OAAOM;AAAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,WAAW;AAAA,IACXC,cAAc;AAAA,IACd,cA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W,OAAO,CACpD;AAAA,MACAC,WAAW1C,gBAAgB;AAAA,MAC3B2C,aAAa3C,gBAAgB;AAAA,MAC7B4C,UAAUjD,WAAW;AAAA,MAAU,GAC3BW;AAAAA,MAAMnC,UAET+C;AAAAA,IAAAA,CACU,GAEZM,gBACCO,oBAACc,eAAa;AAAA,MACZ1D,IAAIuC,MAAMlB,WAAW,OAAO;AAAA,MAC5BsC,eAAa;AAAA,MACbzD,WAAWuC,KAAKxC,mCAAS2D,OAAOjB,kBAAkBiB,KAAK;AAAA,MAAE5E,UAExDyB;AAAAA,IAAAA,CACY,CAChB;AAAA,EAAA,CACgB;AAEvB;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo, useCallback } from "react";
|
|
2
|
+
import { useDefaultProps } from "../../../hooks/useDefaultProps.js";
|
|
2
3
|
import { useTheme } from "@mui/material/styles";
|
|
3
4
|
import { useMediaQuery } from "@mui/material";
|
|
4
5
|
import { theme } from "@hitachivantara/uikit-styles";
|
|
@@ -14,22 +15,23 @@ import { useClasses } from "./ScrollToHorizontal.styles.js";
|
|
|
14
15
|
import { staticClasses } from "./ScrollToHorizontal.styles.js";
|
|
15
16
|
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
16
17
|
import { HvHorizontalScrollListItem } from "./HorizontalScrollListItem/HorizontalScrollListItem.js";
|
|
17
|
-
const HvScrollToHorizontal = ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
const HvScrollToHorizontal = (props) => {
|
|
19
|
+
const {
|
|
20
|
+
id,
|
|
21
|
+
defaultSelectedIndex = 0,
|
|
22
|
+
scrollElementId,
|
|
23
|
+
href = true,
|
|
24
|
+
onChange,
|
|
25
|
+
onClick,
|
|
26
|
+
onEnter,
|
|
27
|
+
className,
|
|
28
|
+
classes: classesProp,
|
|
29
|
+
options,
|
|
30
|
+
offset = 0,
|
|
31
|
+
position = "relative",
|
|
32
|
+
tooltipPosition = "top",
|
|
33
|
+
...others
|
|
34
|
+
} = useDefaultProps("HvScrollToHorizontal", props);
|
|
33
35
|
const {
|
|
34
36
|
classes,
|
|
35
37
|
css,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollToHorizontal.js","sources":["../../../../../src/components/ScrollTo/Horizontal/ScrollToHorizontal.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\n\nimport { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport { useMediaQuery } from \"@mui/material\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { CurrentStep } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport { HvScrollToTooltipPositions } from \"../types\";\nimport { withTooltip } from \"../withTooltip\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { staticClasses, useClasses } from \"./ScrollToHorizontal.styles\";\n\nexport { staticClasses as scrollToHorizontalClasses };\n\nexport type HvScrollToHorizontalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToHorizontalOption {\n key?: string;\n label: string;\n value: string;\n offset?: number;\n}\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToHorizontalOption[];\n /** True if the href location link should be applied. It will create an a element around every list item */\n href?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (event: React.MouseEvent<HTMLDivElement>, index: number) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (event: React.KeyboardEvent<HTMLDivElement>, index: number) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = ({\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n}: HvScrollToHorizontalProps) => {\n const { classes, css, cx } = useClasses(classesProp);\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const { activeTheme, selectedMode } = useTheme();\n\n const elementId = useUniqueId(id, \"hvHorizontalScrollto\");\n\n const [selectedIndex, setScrollTo] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n href,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tooltipWrappers = useMemo(() => {\n return options.map((option) => {\n return withTooltip(option.label, \"div\", tooltipPosition);\n });\n }, [options, tooltipPosition]);\n\n const NotSelected = useCallback(() => {\n return (\n <div className={classes.notSelectedRoot}>\n <div className={classes.notSelected} />\n </div>\n );\n }, [classes.notSelectedRoot, classes.notSelected]);\n\n const Selected = useCallback(() => {\n return (\n <CurrentStep\n height={activeTheme?.scrollTo.dotSelectedSize}\n width={activeTheme?.scrollTo.dotSelectedSize}\n className={classes.selected}\n />\n );\n }, [classes.selected, activeTheme?.scrollTo.dotSelectedSize]);\n\n const tabs = options.map((option, index) => {\n const selected = selectedIndex === index;\n const tooltipWrapper = tooltipWrappers[index];\n\n return (\n <HvHorizontalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n tooltipWrapper={tooltipWrapper}\n selected={selected}\n key={option.key || option.label}\n >\n <p>{option.label}</p>\n {selected ? <Selected /> : <NotSelected />}\n </HvHorizontalScrollListItem>\n );\n });\n\n return (\n <ol\n className={cx(\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n backgroundColor: hexToRgbA(\n activeTheme?.colors.modes[selectedMode].atmo2,\n activeTheme?.scrollTo.backgroundColorOpacity\n ),\n }),\n className,\n classes.root,\n {\n [classes.positionSticky]: position === \"sticky\",\n [classes.positionFixed]: position === \"fixed\",\n }\n )}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["HvScrollToHorizontal","id","defaultSelectedIndex","scrollElementId","href","onChange","onClick","onEnter","className","classes","classesProp","options","offset","position","tooltipPosition","others","css","cx","useClasses","muiTheme","useMuiTheme","downSm","useMediaQuery","breakpoints","down","upMd","up","activeTheme","selectedMode","useTheme","elementId","useUniqueId","selectedIndex","setScrollTo","useScrollTo","handleSelection","event","value","index","preventDefault","wrappedOnChange","tooltipWrappers","useMemo","map","option","withTooltip","label","NotSelected","useCallback","notSelectedRoot","children","notSelected","Selected","CurrentStep","height","scrollTo","dotSelectedSize","width","selected","tabs","tooltipWrapper","HvHorizontalScrollListItem","setId","onKeyDown","isKey","_jsx","key","theme","spacing","marginTop","marginBottom","marginRight","marginLeft","backgroundColor","hexToRgbA","colors","modes","atmo2","backgroundColorOpacity","root","positionSticky","positionFixed"],"mappings":";;;;;;;;;;;;;;;;AAgFO,MAAMA,uBAAuBA,CAAC;AAAA,EACnCC;AAAAA,EACAC,uBAAuB;AAAA,EACvBC;AAAAA,EACAC,OAAO;AAAA,EACPC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC,SAASC;AAAAA,EACTC;AAAAA,EACAC,SAAS;AAAA,EACTC,WAAW;AAAA,EACXC,kBAAkB;AAAA,EAClB,GAAGC;AACsB,MAAM;AACzB,QAAA;AAAA,IAAEN;AAAAA,IAASO;AAAAA,IAAKC;AAAAA,EAAAA,IAAOC,WAAWR,WAAW;AACnD,QAAMS,WAAWC;AAEjB,QAAMC,SAASC,cAAcH,SAASI,YAAYC,KAAK,IAAI,CAAC;AAC5D,QAAMC,OAAOH,cAAcH,SAASI,YAAYG,GAAG,IAAI,CAAC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AZ,IAAI6B;AAAAA,IAAU,GACVf;AAAAA,IAAMmC,UAETS;AAAAA,EAAAA,CACC;AAER;"}
|
|
1
|
+
{"version":3,"file":"ScrollToHorizontal.js","sources":["../../../../../src/components/ScrollTo/Horizontal/ScrollToHorizontal.tsx"],"sourcesContent":["import { useCallback, useMemo } from \"react\";\nimport { useDefaultProps } from \"@core/hooks/useDefaultProps\";\n\nimport { useTheme as useMuiTheme } from \"@mui/material/styles\";\nimport { useMediaQuery } from \"@mui/material\";\n\nimport { theme } from \"@hitachivantara/uikit-styles\";\nimport { CurrentStep } from \"@hitachivantara/uikit-react-icons\";\n\nimport { HvBaseProps } from \"@core/types/generic\";\nimport { useUniqueId } from \"@core/hooks/useUniqueId\";\nimport { useTheme } from \"@core/hooks/useTheme\";\nimport { ExtractNames } from \"@core/utils/classes\";\nimport { isKey } from \"@core/utils/keyboardUtils\";\nimport { setId } from \"@core/utils/setId\";\nimport { hexToRgbA } from \"@core/utils/hexToRgbA\";\n\nimport { HvScrollToTooltipPositions } from \"../types\";\nimport { withTooltip } from \"../withTooltip\";\nimport { HvHorizontalScrollListItem } from \"./HorizontalScrollListItem\";\nimport { useScrollTo } from \"../useScrollTo\";\nimport { staticClasses, useClasses } from \"./ScrollToHorizontal.styles\";\n\nexport { staticClasses as scrollToHorizontalClasses };\n\nexport type HvScrollToHorizontalClasses = ExtractNames<typeof useClasses>;\n\nexport interface HvScrollToHorizontalOption {\n key?: string;\n label: string;\n value: string;\n offset?: number;\n}\n\nexport type HvScrollToHorizontalPositions = \"sticky\" | \"fixed\" | \"relative\";\n\nexport interface HvScrollToHorizontalProps\n extends HvBaseProps<HTMLOListElement, \"onChange\" | \"onClick\"> {\n /** An Array of Objects with Label and Value. Label is the displayed Element and Value is the local navigation location applied */\n options: HvScrollToHorizontalOption[];\n /** True if the href location link should be applied. It will create an a element around every list item */\n href?: boolean;\n /** Default selected index passed from the parent. */\n defaultSelectedIndex?: number;\n /**\n * The Id of the scrollable container containing displayed elements.\n *\n * Defaults to `window` if unspecified.\n */\n scrollElementId?: string;\n /**\n * Defines the offset from the top of each element for getting an optimal viewing region in the container.\n * This allows to exclude regions of the container that are obscured by other content (such as fixed-positioned toolbars or titles)\n * or to put more breathing room between the targeted element and the edges of the container.\n *\n * Each element can also have a specific offset via the options property.\n */\n offset?: number;\n /** Position of the Horizontal scroll to. */\n position?: HvScrollToHorizontalPositions;\n /** Position of tooltip identifying the current item. */\n tooltipPosition?: HvScrollToTooltipPositions;\n /** A function called each time the selected index changes. */\n onChange?: (\n event:\n | Event\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n index: number\n ) => void;\n /** A function called each time an user clicks on a tab element. */\n onClick?: (event: React.MouseEvent<HTMLDivElement>, index: number) => void;\n /** A function called each time an user press enter on a tab element. */\n onEnter?: (event: React.KeyboardEvent<HTMLDivElement>, index: number) => void;\n /** A Jss Object used to override or extend the styles applied. */\n classes?: HvScrollToHorizontalClasses;\n}\n\n/**\n * The horizontal scroll to element can be used to quickly navigate in a page.\n */\nexport const HvScrollToHorizontal = (props: HvScrollToHorizontalProps) => {\n const {\n id,\n defaultSelectedIndex = 0,\n scrollElementId,\n href = true,\n onChange,\n onClick,\n onEnter,\n className,\n classes: classesProp,\n options,\n offset = 0,\n position = \"relative\",\n tooltipPosition = \"top\",\n ...others\n } = useDefaultProps(\"HvScrollToHorizontal\", props);\n\n const { classes, css, cx } = useClasses(classesProp);\n const muiTheme = useMuiTheme();\n\n const downSm = useMediaQuery(muiTheme.breakpoints.down(\"sm\"));\n const upMd = useMediaQuery(muiTheme.breakpoints.up(\"md\"));\n\n const { activeTheme, selectedMode } = useTheme();\n\n const elementId = useUniqueId(id, \"hvHorizontalScrollto\");\n\n const [selectedIndex, setScrollTo] = useScrollTo(\n defaultSelectedIndex,\n scrollElementId,\n href,\n offset,\n options,\n onChange\n );\n\n const handleSelection = (\n event:\n | React.MouseEvent<HTMLDivElement>\n | React.KeyboardEvent<HTMLDivElement>,\n value: string,\n index: number\n ) => {\n event.preventDefault();\n\n const wrappedOnChange = () => {\n onChange?.(event, index);\n };\n\n setScrollTo(event, value, index, wrappedOnChange);\n };\n\n const tooltipWrappers = useMemo(() => {\n return options.map((option) => {\n return withTooltip(option.label, \"div\", tooltipPosition);\n });\n }, [options, tooltipPosition]);\n\n const NotSelected = useCallback(() => {\n return (\n <div className={classes.notSelectedRoot}>\n <div className={classes.notSelected} />\n </div>\n );\n }, [classes.notSelectedRoot, classes.notSelected]);\n\n const Selected = useCallback(() => {\n return (\n <CurrentStep\n height={activeTheme?.scrollTo.dotSelectedSize}\n width={activeTheme?.scrollTo.dotSelectedSize}\n className={classes.selected}\n />\n );\n }, [classes.selected, activeTheme?.scrollTo.dotSelectedSize]);\n\n const tabs = options.map((option, index) => {\n const selected = selectedIndex === index;\n const tooltipWrapper = tooltipWrappers[index];\n\n return (\n <HvHorizontalScrollListItem\n id={setId(elementId, `item-${index}`)}\n onClick={(event) => {\n handleSelection(event, option.value, index);\n onClick?.(event, index);\n }}\n onKeyDown={(event) => {\n if (isKey(event, \"Enter\") === true) {\n handleSelection(event, option.value, index);\n onEnter?.(event, index);\n }\n }}\n tooltipWrapper={tooltipWrapper}\n selected={selected}\n key={option.key || option.label}\n >\n <p>{option.label}</p>\n {selected ? <Selected /> : <NotSelected />}\n </HvHorizontalScrollListItem>\n );\n });\n\n return (\n <ol\n className={cx(\n css({\n width:\n position === \"fixed\" && (upMd || downSm)\n ? `calc(100% - 2*${theme.spacing(upMd ? 4 : 2)})`\n : \"100%\",\n marginTop: 0,\n marginBottom: 0,\n marginRight:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n marginLeft:\n position === \"fixed\" && (upMd || downSm)\n ? theme.spacing(upMd ? 4 : 2)\n : 0,\n backgroundColor: hexToRgbA(\n activeTheme?.colors.modes[selectedMode].atmo2,\n activeTheme?.scrollTo.backgroundColorOpacity\n ),\n }),\n className,\n classes.root,\n {\n [classes.positionSticky]: position === \"sticky\",\n [classes.positionFixed]: position === \"fixed\",\n }\n )}\n id={elementId}\n {...others}\n >\n {tabs}\n </ol>\n );\n};\n"],"names":["HvScrollToHorizontal","props","id","defaultSelectedIndex","scrollElementId","href","onChange","onClick","onEnter","className","classes","classesProp","options","offset","position","tooltipPosition","others","useDefaultProps","css","cx","useClasses","muiTheme","useMuiTheme","downSm","useMediaQuery","breakpoints","down","upMd","up","activeTheme","selectedMode","useTheme","elementId","useUniqueId","selectedIndex","setScrollTo","useScrollTo","handleSelection","event","value","index","preventDefault","wrappedOnChange","tooltipWrappers","useMemo","map","option","withTooltip","label","NotSelected","useCallback","notSelectedRoot","children","notSelected","Selected","CurrentStep","height","scrollTo","dotSelectedSize","width","selected","tabs","tooltipWrapper","HvHorizontalScrollListItem","setId","onKeyDown","isKey","_jsx","key","theme","spacing","marginTop","marginBottom","marginRight","marginLeft","backgroundColor","hexToRgbA","colors","modes","atmo2","backgroundColorOpacity","root","positionSticky","positionFixed"],"mappings":";;;;;;;;;;;;;;;;;AAiFaA,MAAAA,uBAAuBA,CAACC,UAAqC;AAClE,QAAA;AAAA,IACJC;AAAAA,IACAC,uBAAuB;AAAA,IACvBC;AAAAA,IACAC,OAAO;AAAA,IACPC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC;AAAAA,IACAC,SAASC;AAAAA,IACTC;AAAAA,IACAC,SAAS;AAAA,IACTC,WAAW;AAAA,IACXC,kBAAkB;AAAA,IAClB,GAAGC;AAAAA,EAAAA,IACDC,gBAAgB,wBAAwBhB,KAAK;AAE3C,QAAA;AAAA,IAAES;AAAAA,IAASQ;AAAAA,IAAKC;AAAAA,EAAAA,IAAOC,WAAWT,WAAW;AACnD,QAAMU,WAAWC;AAEjB,QAAMC,SAASC,cAAcH,SAASI,YAAYC,KAAK,IAAI,CAAC;AAC5D,QAAMC,OAAOH,cAAcH,SAASI,YAAYG,GAAG,IAAI,CAAC;AAElD,QAAA;AAAA,IAAEC;AAAAA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B;AAAAA,IAAMoC,UAETS;AAAAA,EAAAA,CACC;AAER;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
+
import { useDefaultProps } from "../../../hooks/useDefaultProps.js";
|
|
2
3
|
import { useTheme } from "../../../hooks/useTheme.js";
|
|
3
4
|
import { useUniqueId } from "../../../hooks/useUniqueId.js";
|
|
4
5
|
import { isKey } from "../../../utils/keyboardUtils.js";
|
|
@@ -10,23 +11,24 @@ import { useScrollTo } from "../useScrollTo.js";
|
|
|
10
11
|
import { withTooltip } from "../withTooltip.js";
|
|
11
12
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
12
13
|
import { HvVerticalScrollListItem } from "./VerticalScrollListItem/VerticalScrollListItem.js";
|
|
13
|
-
const HvScrollToVertical = ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
const HvScrollToVertical = (props) => {
|
|
15
|
+
const {
|
|
16
|
+
id,
|
|
17
|
+
defaultSelectedIndex = 0,
|
|
18
|
+
scrollElementId,
|
|
19
|
+
href = true,
|
|
20
|
+
onChange,
|
|
21
|
+
onClick,
|
|
22
|
+
onEnter,
|
|
23
|
+
className,
|
|
24
|
+
classes: classesProp,
|
|
25
|
+
options,
|
|
26
|
+
offset = 0,
|
|
27
|
+
position = "relative",
|
|
28
|
+
tooltipPosition = "left",
|
|
29
|
+
style,
|
|
30
|
+
...others
|
|
31
|
+
} = useDefaultProps("HvScrollToVertical", props);
|
|
30
32
|
const {
|
|
31
33
|
classes,
|
|
32
34
|
css,
|