@ultraviolet/ui 3.0.0-beta.25 → 3.0.0-beta.27
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/components/ActionBar/styles.css.js +1 -0
- package/dist/components/Avatar/constants.d.ts +5 -5
- package/dist/components/Avatar/constants.js +1 -1
- package/dist/components/Avatar/styles.css.d.ts +24 -24
- package/dist/components/Avatar/styles.css.js +0 -1
- package/dist/components/BarChart/Tooltip.d.ts +3 -3
- package/dist/components/BarChart/Tooltip.js +2 -2
- package/dist/components/BarChart/index.d.ts +1 -1
- package/dist/components/BarChart/index.js +2 -2
- package/dist/components/Button/constants.d.ts +1 -0
- package/dist/components/Button/index.d.ts +0 -4
- package/dist/components/ExpandableCard/constants.d.ts +1 -0
- package/dist/components/ExpandableCard/index.d.ts +1 -1
- package/dist/components/ExpandableCard/styles.css.d.ts +1 -1
- package/dist/components/ExpandableCard/styles.css.js +2 -2
- package/dist/components/Key/constants.d.ts +8 -0
- package/dist/components/Key/constants.js +11 -0
- package/dist/components/Key/index.d.ts +0 -8
- package/dist/components/Key/index.js +1 -9
- package/dist/components/LineChart/helpers.js +2 -2
- package/dist/components/List/Row.js +1 -1
- package/dist/components/Loader/constants.d.ts +8 -0
- package/dist/components/Loader/constants.js +11 -0
- package/dist/components/Loader/index.d.ts +1 -8
- package/dist/components/Loader/index.js +5 -24
- package/dist/components/Loader/styles.css.d.ts +1 -0
- package/dist/components/Loader/styles.css.js +3 -1
- package/dist/components/Menu/MenuContent.js +7 -1
- package/dist/components/Menu/components/Item.d.ts +2 -2
- package/dist/components/Menu/components/Item.js +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Notification/Notification.d.ts +10 -0
- package/dist/components/Notification/{index.js → Notification.js} +2 -14
- package/dist/components/Notification/NotificationContainer.d.ts +30 -0
- package/dist/components/Notification/NotificationContainer.js +17 -0
- package/dist/components/Notification/index.d.ts +2 -37
- package/dist/components/PieChart/Legends.d.ts +2 -2
- package/dist/components/PieChart/Legends.js +2 -2
- package/dist/components/PieChart/Tooltip.d.ts +2 -2
- package/dist/components/PieChart/Tooltip.js +1 -1
- package/dist/components/PieChart/index.js +1 -1
- package/dist/components/Popup/index.js +8 -0
- package/dist/components/ProgressBar/styles.css.js +0 -1
- package/dist/components/ProgressBar/variables.css.js +1 -0
- package/dist/components/SelectInput/components/SearchBarDropdown.d.ts +1 -3
- package/dist/components/SelectInput/components/SearchBarDropdown.js +7 -4
- package/dist/components/SelectableCard/styles.css.js +0 -1
- package/dist/components/SelectableCard/variables.css.js +1 -0
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/TagList/index.js +1 -1
- package/dist/components/Text/constants.d.ts +9 -0
- package/dist/components/Text/index.d.ts +1 -4
- package/dist/components/Text/style.css.js +1 -0
- package/dist/components/Text/variables.css.js +0 -1
- package/dist/components/Toaster/Toaster.d.ts +7 -0
- package/dist/components/Toaster/Toaster.js +25 -0
- package/dist/components/Toaster/ToasterContainer.d.ts +38 -0
- package/dist/components/Toaster/ToasterContainer.js +18 -0
- package/dist/components/Toaster/components/CloseButton.d.ts +8 -0
- package/dist/components/Toaster/components/CloseButton.js +12 -0
- package/dist/components/Toaster/components/Content.d.ts +6 -0
- package/dist/components/Toaster/components/Content.js +10 -0
- package/dist/components/Toaster/constants.d.ts +1 -0
- package/dist/components/Toaster/constants.js +4 -0
- package/dist/components/Toaster/index.d.ts +3 -45
- package/dist/components/TreeMapChart/Tooltip.d.ts +6 -0
- package/dist/components/TreeMapChart/Tooltip.js +15 -0
- package/dist/components/TreeMapChart/index.d.ts +18 -0
- package/dist/components/TreeMapChart/index.js +68 -0
- package/dist/components/TreeMapChart/styles.css.d.ts +2 -0
- package/dist/components/TreeMapChart/styles.css.js +7 -0
- package/dist/components/TreeMapChart/types.d.ts +7 -0
- package/dist/components/VerificationCode/constants.d.ts +1 -0
- package/dist/components/VerificationCode/index.d.ts +0 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/helpers/legend.d.ts +2 -2
- package/dist/helpers/legend.js +1 -1
- package/dist/helpers/nivoTheme.d.ts +1 -1
- package/dist/helpers/treeMap.d.ts +90 -0
- package/dist/helpers/treeMap.js +42 -0
- package/dist/hooks/useIsOverflowing.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +37 -9
- package/dist/ui.css +1 -1
- package/dist/utils/animations/animations.d.ts +27 -0
- package/dist/utils/animations/animations.js +271 -0
- package/dist/utils/animations/animationsVE.css.d.ts +27 -0
- package/dist/utils/animations/animationsVE.css.js +57 -0
- package/dist/utils/index.d.ts +2 -2
- package/package.json +6 -4
- package/dist/components/ActionBar/index.cjs +0 -22
- package/dist/components/ActionBar/styles.css.cjs +0 -10
- package/dist/components/Alert/index.cjs +0 -55
- package/dist/components/Alert/styles.css.cjs +0 -14
- package/dist/components/Avatar/constants.cjs +0 -19
- package/dist/components/Avatar/index.cjs +0 -66
- package/dist/components/Avatar/styles.css.cjs +0 -18
- package/dist/components/Avatar/variables.css.cjs +0 -8
- package/dist/components/Badge/constant.cjs +0 -8
- package/dist/components/Badge/index.cjs +0 -27
- package/dist/components/Badge/styles.css.cjs +0 -6
- package/dist/components/Banner/assets/default-image-small.svg.cjs +0 -3
- package/dist/components/Banner/assets/default-image.svg.cjs +0 -3
- package/dist/components/Banner/index.cjs +0 -74
- package/dist/components/Banner/styles.css.cjs +0 -10
- package/dist/components/BarChart/Tooltip.cjs +0 -22
- package/dist/components/BarChart/index.cjs +0 -60
- package/dist/components/BarChart/styles.css.cjs +0 -9
- package/dist/components/BarStack/index.cjs +0 -35
- package/dist/components/BarStack/styles.css.cjs +0 -11
- package/dist/components/Breadcrumbs/components/Item.cjs +0 -41
- package/dist/components/Breadcrumbs/components/styles.css.cjs +0 -18
- package/dist/components/Breadcrumbs/index.cjs +0 -14
- package/dist/components/Breadcrumbs/styles.css.cjs +0 -5
- package/dist/components/Bullet/index.cjs +0 -24
- package/dist/components/Bullet/styles.css.cjs +0 -6
- package/dist/components/Button/constants.cjs +0 -6
- package/dist/components/Button/index.cjs +0 -84
- package/dist/components/Button/styles.css.cjs +0 -6
- package/dist/components/Card/index.cjs +0 -28
- package/dist/components/Card/styles.css.cjs +0 -7
- package/dist/components/Carousel/index.cjs +0 -74
- package/dist/components/Carousel/styles.css.cjs +0 -15
- package/dist/components/Checkbox/index.cjs +0 -58
- package/dist/components/Checkbox/styles.css.cjs +0 -17
- package/dist/components/CheckboxGroup/index.cjs +0 -78
- package/dist/components/CheckboxGroup/styles.css.cjs +0 -7
- package/dist/components/Chip/ChipContext.cjs +0 -6
- package/dist/components/Chip/ChipIcon.cjs +0 -52
- package/dist/components/Chip/index.cjs +0 -60
- package/dist/components/Chip/styles.css.cjs +0 -7
- package/dist/components/CopyButton/index.cjs +0 -35
- package/dist/components/DateInput/Context.cjs +0 -23
- package/dist/components/DateInput/components/CalendarContent.cjs +0 -61
- package/dist/components/DateInput/components/CalendarDaily.cjs +0 -169
- package/dist/components/DateInput/components/CalendarMonthly.cjs +0 -105
- package/dist/components/DateInput/components/Popup.cjs +0 -28
- package/dist/components/DateInput/components/styles.css.cjs +0 -12
- package/dist/components/DateInput/constants.cjs +0 -6
- package/dist/components/DateInput/helpers.cjs +0 -69
- package/dist/components/DateInput/helpersLocale.cjs +0 -64
- package/dist/components/DateInput/index.cjs +0 -192
- package/dist/components/DateInput/styles.css.cjs +0 -8
- package/dist/components/Dialog/Context.cjs +0 -14
- package/dist/components/Dialog/components/Button.cjs +0 -17
- package/dist/components/Dialog/components/Buttons.cjs +0 -13
- package/dist/components/Dialog/components/CancelButton.cjs +0 -12
- package/dist/components/Dialog/components/Stack.cjs +0 -10
- package/dist/components/Dialog/components/Text.cjs +0 -10
- package/dist/components/Dialog/index.cjs +0 -60
- package/dist/components/Dialog/styles.css.cjs +0 -7
- package/dist/components/Drawer/index.cjs +0 -56
- package/dist/components/Drawer/styles.css.cjs +0 -17
- package/dist/components/EmptyState/index.cjs +0 -42
- package/dist/components/EmptyState/styles.css.cjs +0 -10
- package/dist/components/Expandable/index.cjs +0 -108
- package/dist/components/Expandable/styles.css.cjs +0 -7
- package/dist/components/ExpandableCard/components/Title.cjs +0 -13
- package/dist/components/ExpandableCard/index.cjs +0 -114
- package/dist/components/ExpandableCard/styles.css.cjs +0 -17
- package/dist/components/GlobalAlert/GlobalAlertLink.cjs +0 -25
- package/dist/components/GlobalAlert/index.cjs +0 -39
- package/dist/components/GlobalAlert/styles.css.cjs +0 -7
- package/dist/components/InfiniteScroll/index.cjs +0 -91
- package/dist/components/Key/index.cjs +0 -45
- package/dist/components/Key/styles.css.cjs +0 -6
- package/dist/components/Label/index.cjs +0 -52
- package/dist/components/Label/styles.css.cjs +0 -5
- package/dist/components/LineChart/CustomLegend.cjs +0 -64
- package/dist/components/LineChart/Tooltip.cjs +0 -19
- package/dist/components/LineChart/helpers.cjs +0 -57
- package/dist/components/LineChart/index.cjs +0 -92
- package/dist/components/LineChart/styles.css.cjs +0 -27
- package/dist/components/Link/index.cjs +0 -69
- package/dist/components/Link/styles.css.cjs +0 -14
- package/dist/components/List/Cell.cjs +0 -31
- package/dist/components/List/ColumnProvider.cjs +0 -28
- package/dist/components/List/HeaderCell.cjs +0 -49
- package/dist/components/List/HeaderRow.cjs +0 -26
- package/dist/components/List/ListContext.cjs +0 -210
- package/dist/components/List/Row.cjs +0 -107
- package/dist/components/List/SelectBar.cjs +0 -28
- package/dist/components/List/SkeletonRows.cjs +0 -31
- package/dist/components/List/index.cjs +0 -49
- package/dist/components/List/styles.css.cjs +0 -35
- package/dist/components/List/variables.css.cjs +0 -16
- package/dist/components/Loader/index.cjs +0 -66
- package/dist/components/Loader/styles.css.cjs +0 -7
- package/dist/components/Menu/MenuContent.cjs +0 -177
- package/dist/components/Menu/MenuProvider.cjs +0 -44
- package/dist/components/Menu/components/Group.cjs +0 -25
- package/dist/components/Menu/components/Item.cjs +0 -97
- package/dist/components/Menu/helpers.cjs +0 -48
- package/dist/components/Menu/index.cjs +0 -20
- package/dist/components/Menu/styles.css.cjs +0 -24
- package/dist/components/Meter/index.cjs +0 -34
- package/dist/components/Meter/styles.css.cjs +0 -11
- package/dist/components/Modal/ModalContent.cjs +0 -39
- package/dist/components/Modal/ModalProvider.cjs +0 -41
- package/dist/components/Modal/components/Dialog.cjs +0 -148
- package/dist/components/Modal/components/Disclosure.cjs +0 -42
- package/dist/components/Modal/index.cjs +0 -58
- package/dist/components/Modal/styles.css.cjs +0 -21
- package/dist/components/Notice/index.cjs +0 -17
- package/dist/components/Notice/styles.css.cjs +0 -5
- package/dist/components/Notification/index.cjs +0 -35
- package/dist/components/Notification/styles.css.cjs +0 -5
- package/dist/components/NumberInput/index.cjs +0 -145
- package/dist/components/NumberInput/styles.css.cjs +0 -14
- package/dist/components/Pagination/PaginationButtons.cjs +0 -49
- package/dist/components/Pagination/PerPage.cjs +0 -49
- package/dist/components/Pagination/getPageNumbers.cjs +0 -23
- package/dist/components/Pagination/index.cjs +0 -43
- package/dist/components/Pagination/styles.css.cjs +0 -9
- package/dist/components/PasswordCheck/index.cjs +0 -18
- package/dist/components/PasswordCheck/styles.css.cjs +0 -5
- package/dist/components/PieChart/Legends.cjs +0 -36
- package/dist/components/PieChart/Tooltip.cjs +0 -18
- package/dist/components/PieChart/index.cjs +0 -71
- package/dist/components/PieChart/styles.css.cjs +0 -36
- package/dist/components/Popover/index.cjs +0 -67
- package/dist/components/Popover/styles.css.cjs +0 -8
- package/dist/components/Popup/helpers.cjs +0 -264
- package/dist/components/Popup/index.cjs +0 -283
- package/dist/components/Popup/styles.css.cjs +0 -13
- package/dist/components/Popup/variables.css.cjs +0 -18
- package/dist/components/ProgressBar/index.cjs +0 -46
- package/dist/components/ProgressBar/styles.css.cjs +0 -12
- package/dist/components/ProgressBar/variables.css.cjs +0 -4
- package/dist/components/Radio/index.cjs +0 -69
- package/dist/components/Radio/styles.css.cjs +0 -21
- package/dist/components/RadioGroup/index.cjs +0 -73
- package/dist/components/RadioGroup/styles.css.cjs +0 -5
- package/dist/components/Row/index.cjs +0 -46
- package/dist/components/Row/styles.css.cjs +0 -17
- package/dist/components/Row/variables.css.cjs +0 -7
- package/dist/components/SearchInput/KeyGroup.cjs +0 -13
- package/dist/components/SearchInput/index.cjs +0 -186
- package/dist/components/SearchInput/styles.css.cjs +0 -10
- package/dist/components/SelectInput/SelectInputProvider.cjs +0 -203
- package/dist/components/SelectInput/components/Dropdown.cjs +0 -341
- package/dist/components/SelectInput/components/DropdownOption.cjs +0 -47
- package/dist/components/SelectInput/components/SearchBarDropdown.cjs +0 -117
- package/dist/components/SelectInput/components/SelectBar.cjs +0 -237
- package/dist/components/SelectInput/components/dropdown.css.cjs +0 -34
- package/dist/components/SelectInput/components/selectBar.css.cjs +0 -22
- package/dist/components/SelectInput/findOptionInOptions.cjs +0 -12
- package/dist/components/SelectInput/index.cjs +0 -68
- package/dist/components/SelectInput/styles.css.cjs +0 -7
- package/dist/components/SelectInput/types.cjs +0 -9
- package/dist/components/SelectableCard/index.cjs +0 -149
- package/dist/components/SelectableCard/styles.css.cjs +0 -21
- package/dist/components/SelectableCard/variables.css.cjs +0 -8
- package/dist/components/SelectableCardGroup/index.cjs +0 -75
- package/dist/components/SelectableCardGroup/styles.css.cjs +0 -5
- package/dist/components/SelectableCardOptionGroup/Provider.cjs +0 -24
- package/dist/components/SelectableCardOptionGroup/components/Image.cjs +0 -17
- package/dist/components/SelectableCardOptionGroup/components/Option.cjs +0 -60
- package/dist/components/SelectableCardOptionGroup/index.cjs +0 -51
- package/dist/components/SelectableCardOptionGroup/styles.css.cjs +0 -21
- package/dist/components/Separator/index.cjs +0 -40
- package/dist/components/Separator/styles.css.cjs +0 -10
- package/dist/components/Skeleton/Block.cjs +0 -17
- package/dist/components/Skeleton/Blocks.cjs +0 -20
- package/dist/components/Skeleton/BoxWithIcon.cjs +0 -20
- package/dist/components/Skeleton/Donut.cjs +0 -16
- package/dist/components/Skeleton/IconSkeleton.cjs +0 -7
- package/dist/components/Skeleton/Line.cjs +0 -12
- package/dist/components/Skeleton/List.cjs +0 -18
- package/dist/components/Skeleton/Slider.cjs +0 -14
- package/dist/components/Skeleton/Square.cjs +0 -7
- package/dist/components/Skeleton/index.cjs +0 -39
- package/dist/components/Skeleton/styles.css.cjs +0 -7
- package/dist/components/Skeleton/stylesVariants.css.cjs +0 -47
- package/dist/components/Slider/components/DoubleSlider.cjs +0 -236
- package/dist/components/Slider/components/Options.cjs +0 -35
- package/dist/components/Slider/components/SingleSlider.cjs +0 -153
- package/dist/components/Slider/constant.cjs +0 -4
- package/dist/components/Slider/index.cjs +0 -61
- package/dist/components/Slider/styles.css.cjs +0 -36
- package/dist/components/Snippet/index.cjs +0 -64
- package/dist/components/Snippet/styles.css.cjs +0 -26
- package/dist/components/Stack/index.cjs +0 -85
- package/dist/components/Stack/styles.css.cjs +0 -19
- package/dist/components/Stack/variables.css.cjs +0 -11
- package/dist/components/Status/index.cjs +0 -25
- package/dist/components/Status/styles.css.cjs +0 -11
- package/dist/components/StepList/index.cjs +0 -32
- package/dist/components/StepList/styles.css.cjs +0 -10
- package/dist/components/Stepper/Step.cjs +0 -72
- package/dist/components/Stepper/StepperProvider.cjs +0 -41
- package/dist/components/Stepper/index.cjs +0 -49
- package/dist/components/Stepper/styles.css.cjs +0 -20
- package/dist/components/SwitchButton/FocusOverlay.cjs +0 -16
- package/dist/components/SwitchButton/Option.cjs +0 -40
- package/dist/components/SwitchButton/SwitchButtonContext.cjs +0 -13
- package/dist/components/SwitchButton/constant.cjs +0 -4
- package/dist/components/SwitchButton/index.cjs +0 -110
- package/dist/components/SwitchButton/styles.css.cjs +0 -9
- package/dist/components/Table/Body.cjs +0 -8
- package/dist/components/Table/Cell.cjs +0 -35
- package/dist/components/Table/Header.cjs +0 -9
- package/dist/components/Table/HeaderCell.cjs +0 -55
- package/dist/components/Table/HeaderRow.cjs +0 -28
- package/dist/components/Table/Row.cjs +0 -88
- package/dist/components/Table/SelectBar.cjs +0 -28
- package/dist/components/Table/SkeletonRows.cjs +0 -24
- package/dist/components/Table/TableContext.cjs +0 -43
- package/dist/components/Table/constants.cjs +0 -4
- package/dist/components/Table/index.cjs +0 -56
- package/dist/components/Table/styles.css.cjs +0 -29
- package/dist/components/Table/variables.css.cjs +0 -14
- package/dist/components/Tabs/Tab.cjs +0 -52
- package/dist/components/Tabs/TabMenu.cjs +0 -32
- package/dist/components/Tabs/TabMenuItem.cjs +0 -27
- package/dist/components/Tabs/TabsContext.cjs +0 -7
- package/dist/components/Tabs/index.cjs +0 -74
- package/dist/components/Tabs/styles.css.cjs +0 -21
- package/dist/components/Tag/index.cjs +0 -63
- package/dist/components/Tag/styles.css.cjs +0 -10
- package/dist/components/TagInput/index.cjs +0 -163
- package/dist/components/TagInput/styles.css.cjs +0 -12
- package/dist/components/TagList/constant.cjs +0 -5
- package/dist/components/TagList/index.cjs +0 -163
- package/dist/components/TagList/styles.css.cjs +0 -14
- package/dist/components/Text/constant.d.ts +0 -6
- package/dist/components/Text/index.cjs +0 -53
- package/dist/components/Text/style.css.cjs +0 -6
- package/dist/components/Text/variables.css.cjs +0 -7
- package/dist/components/TextArea/index.cjs +0 -123
- package/dist/components/TextArea/styles.css.cjs +0 -12
- package/dist/components/TextInput/index.cjs +0 -119
- package/dist/components/TextInput/styles.css.cjs +0 -17
- package/dist/components/TimeInput/constants.cjs +0 -13
- package/dist/components/TimeInput/helpers.cjs +0 -66
- package/dist/components/TimeInput/index.cjs +0 -273
- package/dist/components/TimeInput/styles.css.cjs +0 -10
- package/dist/components/Toaster/index.cjs +0 -47
- package/dist/components/Toaster/index.js +0 -47
- package/dist/components/Toaster/styles.css.cjs +0 -7
- package/dist/components/Toggle/index.cjs +0 -50
- package/dist/components/Toggle/styles.css.cjs +0 -10
- package/dist/components/ToggleGroup/index.cjs +0 -72
- package/dist/components/ToggleGroup/styles.css.cjs +0 -5
- package/dist/components/Tooltip/index.cjs +0 -26
- package/dist/components/Tooltip/styles.css.cjs +0 -5
- package/dist/components/UnitInput/index.cjs +0 -111
- package/dist/components/UnitInput/styles.css.cjs +0 -18
- package/dist/components/VerificationCode/index.cjs +0 -148
- package/dist/components/VerificationCode/styles.css.cjs +0 -9
- package/dist/helpers/isClientSide.cjs +0 -4
- package/dist/helpers/legend.cjs +0 -14
- package/dist/helpers/nivoTheme.cjs +0 -22
- package/dist/helpers/recursivelyGetChildrenString.cjs +0 -17
- package/dist/hooks/useIsOverflowing.cjs +0 -23
- package/dist/index.cjs +0 -214
- package/dist/theme/ThemeProvider.cjs +0 -16
- package/dist/theme/index.cjs +0 -38
- package/dist/utils/animationVanillaExtract.css.cjs +0 -11
- package/dist/utils/animationVanillaExtract.css.d.ts +0 -4
- package/dist/utils/animationVanillaExtract.css.js +0 -11
- package/dist/utils/animations.cjs +0 -276
- package/dist/utils/animations.d.ts +0 -162
- package/dist/utils/animations.js +0 -276
- package/dist/utils/ids.cjs +0 -8
- package/dist/utils/normalize.cjs +0 -35
- package/dist/utils/responsive/Breakpoint.cjs +0 -15
- package/dist/utils/responsive/utilities.cjs +0 -17
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const themes = require("@ultraviolet/themes");
|
|
6
|
-
const react = require("react");
|
|
7
|
-
const index$4 = require("../../Checkbox/index.cjs");
|
|
8
|
-
const ModalProvider = require("../../Modal/ModalProvider.cjs");
|
|
9
|
-
const index = require("../../Popup/index.cjs");
|
|
10
|
-
const index$3 = require("../../Skeleton/index.cjs");
|
|
11
|
-
const index$1 = require("../../Stack/index.cjs");
|
|
12
|
-
const index$2 = require("../../Text/index.cjs");
|
|
13
|
-
const SelectInputProvider = require("../SelectInputProvider.cjs");
|
|
14
|
-
const types = require("../types.cjs");
|
|
15
|
-
const DropdownOption = require("./DropdownOption.cjs");
|
|
16
|
-
const dropdown_css = require("./dropdown.css.cjs");
|
|
17
|
-
const SearchBarDropdown = require("./SearchBarDropdown.cjs");
|
|
18
|
-
const DROPDOWN_MAX_HEIGHT = 256;
|
|
19
|
-
const NON_SEARCHABLE_KEYS = ["Tab", " ", "Enter", "CapsLock", "Shift", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Escape"];
|
|
20
|
-
const moveFocusDown = () => {
|
|
21
|
-
const options = document.querySelectorAll('#items > div[role="option"]:not([disabled])');
|
|
22
|
-
const activeItem = document.activeElement;
|
|
23
|
-
if (options) {
|
|
24
|
-
for (let i = 0; i < options?.length; i += 1) {
|
|
25
|
-
const listLength = options.length;
|
|
26
|
-
if (activeItem === options[i] && activeItem !== options[listLength - 1]) {
|
|
27
|
-
options[i + 1].focus();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const moveFocusUp = () => {
|
|
33
|
-
const options = document.querySelectorAll('#items > div[role="option"]:not([disabled])');
|
|
34
|
-
const activeItem = document.activeElement;
|
|
35
|
-
if (options) {
|
|
36
|
-
for (let i = 0; i < options.length; i += 1) {
|
|
37
|
-
if (activeItem === options[i] && activeItem !== options[0]) {
|
|
38
|
-
options[i - 1].focus();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const handleKeyDownSelect = (event) => {
|
|
44
|
-
if (event.key === "ArrowDown") {
|
|
45
|
-
event.preventDefault();
|
|
46
|
-
moveFocusDown();
|
|
47
|
-
}
|
|
48
|
-
if (event.key === "ArrowUp") {
|
|
49
|
-
event.preventDefault();
|
|
50
|
-
moveFocusUp();
|
|
51
|
-
}
|
|
52
|
-
if (event.key === " ") {
|
|
53
|
-
event.preventDefault();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const handleKeyDown = (event, ref, options, searchBarActive, setSearch, setDefaultSearch, search) => {
|
|
57
|
-
if (ref.current && !searchBarActive && !NON_SEARCHABLE_KEYS.includes(event.key) && document.activeElement?.ariaLabel !== "search-bar") {
|
|
58
|
-
const currentSearch = search + event.key;
|
|
59
|
-
setSearch(currentSearch);
|
|
60
|
-
ref.current.focus();
|
|
61
|
-
if (!Array.isArray(options)) {
|
|
62
|
-
const closestOptions = {
|
|
63
|
-
...options
|
|
64
|
-
};
|
|
65
|
-
Object.keys(closestOptions).map((group) => {
|
|
66
|
-
closestOptions[group] = closestOptions[group].filter((option) => option.searchText ? option.searchText.toLocaleLowerCase().startsWith(currentSearch) : option.value.toLocaleLowerCase().startsWith(currentSearch));
|
|
67
|
-
return null;
|
|
68
|
-
});
|
|
69
|
-
const closestOption = closestOptions[Object.keys(closestOptions)[0]][0];
|
|
70
|
-
if (closestOption) {
|
|
71
|
-
setDefaultSearch(closestOption.searchText ?? closestOption.value);
|
|
72
|
-
} else {
|
|
73
|
-
setDefaultSearch(null);
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
const closestOption = [...options].find((option) => option.searchText ? option.searchText.toLocaleLowerCase().startsWith(currentSearch) : option.value.toLocaleLowerCase().startsWith(currentSearch));
|
|
77
|
-
if (closestOption) {
|
|
78
|
-
setDefaultSearch(closestOption.searchText ?? closestOption.value);
|
|
79
|
-
} else {
|
|
80
|
-
setDefaultSearch(null);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const CreateDropdown = ({
|
|
86
|
-
isEmpty,
|
|
87
|
-
emptyState,
|
|
88
|
-
descriptionDirection,
|
|
89
|
-
loadMore,
|
|
90
|
-
optionalInfoPlacement,
|
|
91
|
-
defaultSearchValue,
|
|
92
|
-
isLoading
|
|
93
|
-
}) => {
|
|
94
|
-
const {
|
|
95
|
-
setIsDropdownVisible,
|
|
96
|
-
onChange,
|
|
97
|
-
options,
|
|
98
|
-
multiselect,
|
|
99
|
-
selectAll,
|
|
100
|
-
selectAllGroup,
|
|
101
|
-
displayedOptions,
|
|
102
|
-
setSelectedData,
|
|
103
|
-
selectedData
|
|
104
|
-
} = SelectInputProvider.useSelectInput();
|
|
105
|
-
const focusedItemRef = react.useRef(null);
|
|
106
|
-
react.useEffect(() => {
|
|
107
|
-
if (defaultSearchValue && focusedItemRef?.current) {
|
|
108
|
-
focusedItemRef.current.focus();
|
|
109
|
-
}
|
|
110
|
-
}, [defaultSearchValue]);
|
|
111
|
-
if (isEmpty) {
|
|
112
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index$1.Stack, { alignItems: "center", className: dropdown_css.dropdownEmptyState, gap: 2, children: emptyState ?? /* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "p", variant: "bodyStrong", children: "No options" }) });
|
|
113
|
-
}
|
|
114
|
-
const handleClick = (clickedOption, group) => {
|
|
115
|
-
setSelectedData({
|
|
116
|
-
clickedOption,
|
|
117
|
-
group,
|
|
118
|
-
type: "selectOption"
|
|
119
|
-
});
|
|
120
|
-
if (multiselect) {
|
|
121
|
-
if (selectedData.selectedValues.includes(clickedOption.value)) {
|
|
122
|
-
onChange?.(selectedData.selectedValues.filter((val) => val !== clickedOption.value));
|
|
123
|
-
} else {
|
|
124
|
-
onChange?.([...selectedData.selectedValues, clickedOption.value]);
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
onChange?.(clickedOption.value);
|
|
128
|
-
}
|
|
129
|
-
setIsDropdownVisible(multiselect);
|
|
130
|
-
};
|
|
131
|
-
const selectAllOptions = () => {
|
|
132
|
-
if (multiselect) {
|
|
133
|
-
setSelectedData({
|
|
134
|
-
type: "selectAll"
|
|
135
|
-
});
|
|
136
|
-
if (selectedData.allSelected && onChange) {
|
|
137
|
-
onChange([]);
|
|
138
|
-
} else {
|
|
139
|
-
const allValues = [];
|
|
140
|
-
if (!Array.isArray(options)) {
|
|
141
|
-
Object.keys(options).map((group) => options[group].map((option) => {
|
|
142
|
-
if (!option.disabled) {
|
|
143
|
-
allValues.push(option);
|
|
144
|
-
}
|
|
145
|
-
return null;
|
|
146
|
-
}));
|
|
147
|
-
} else {
|
|
148
|
-
options.map((option) => allValues.push(option));
|
|
149
|
-
}
|
|
150
|
-
onChange?.(allValues.map((value) => value.value));
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
const handleSelectGroup = (group) => {
|
|
155
|
-
if (multiselect) {
|
|
156
|
-
setSelectedData({
|
|
157
|
-
selectedGroup: group,
|
|
158
|
-
type: "selectGroup"
|
|
159
|
-
});
|
|
160
|
-
if (!Array.isArray(options)) {
|
|
161
|
-
if (selectedData.selectedGroups.includes(group)) {
|
|
162
|
-
const newSelectedValues = [...selectedData.selectedValues].filter((selectedValue) => !options[group].find((option) => option.value === selectedValue));
|
|
163
|
-
onChange?.(newSelectedValues);
|
|
164
|
-
} else {
|
|
165
|
-
const newSelectedValues = [...selectedData.selectedValues];
|
|
166
|
-
options[group].map((option) => newSelectedValues.includes(option.value) || option.disabled ? null : newSelectedValues.push(option.value));
|
|
167
|
-
onChange?.(newSelectedValues);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
return !Array.isArray(displayedOptions) ? /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { className: dropdown_css.dropdownContainer, "data-grouped": true, id: "select-dropdown", onKeyDown: handleKeyDownSelect, role: "listbox", children: [
|
|
173
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx(index$3.Skeleton, { variant: "block" }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
174
|
-
selectAll && multiselect ? /* @__PURE__ */ jsxRuntime.jsx(index$1.Stack, { id: "items", children: /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-disabled": false, "aria-label": "select-all", "aria-selected": selectedData.allSelected, className: dropdown_css.dropdownItem({
|
|
175
|
-
selected: selectedData.allSelected
|
|
176
|
-
}), "data-testid": "select-all", id: "select-all", onClick: selectAllOptions, onKeyDown: (event) => [" ", "Enter"].includes(event.key) ? selectAllOptions() : null, role: "option", tabIndex: 0, children: /* @__PURE__ */ jsxRuntime.jsx(index$4.Checkbox, { checked: selectedData.allSelected, className: dropdown_css.dropdownCheckbox, "data-testid": "select-all-checkbox", disabled: false, onChange: selectAllOptions, tabIndex: -1, value: "select-all", children: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { direction: "column", children: [
|
|
177
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", variant: "body", children: selectAll.label }),
|
|
178
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", prominence: "weak", sentiment: "neutral", variant: "bodySmall", children: selectAll.description })
|
|
179
|
-
] }) }) }) }) : null,
|
|
180
|
-
Object.keys(displayedOptions).map((group, index2) => /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { gap: 0.25, children: [
|
|
181
|
-
displayedOptions[group].length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: dropdown_css.dropdownGroupWrapper, id: selectAllGroup ? "items" : void 0, children: group ? /* @__PURE__ */ jsxRuntime.jsx("button", { className: `${selectAllGroup ? dropdown_css.dropdownGroupSelectable : ""} ${dropdown_css.dropdownGroup}`, "data-selectgroup": selectAllGroup, "data-testid": `group-${index2}`, onClick: () => selectAllGroup ? handleSelectGroup(group) : null, onKeyDown: (event) => {
|
|
182
|
-
if ([" ", "Enter"].includes(event.key)) {
|
|
183
|
-
event.preventDefault();
|
|
184
|
-
handleSelectGroup(group);
|
|
185
|
-
}
|
|
186
|
-
}, role: "group", tabIndex: selectAllGroup ? 0 : -1, type: "button", children: selectAllGroup ? /* @__PURE__ */ jsxRuntime.jsx(index$4.Checkbox, { checked: selectedData.selectedGroups.includes(group), className: dropdown_css.dropdownCheckbox, "data-testid": "select-group", disabled: false, onChange: () => selectAllGroup ? handleSelectGroup(group) : null, tabIndex: -1, value: group, children: /* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", sentiment: "neutral", variant: "caption", children: group.toUpperCase() }) }) : /* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", sentiment: "neutral", variant: "caption", children: group.toUpperCase() }) }, group) : null }) : null,
|
|
187
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$1.Stack, { gap: "0.25", id: "items", children: displayedOptions[group].map((option, indexOption) => /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-disabled": !!option.disabled, "aria-label": option.value, "aria-selected": selectedData.selectedValues.includes(option.value) && !option.disabled, className: dropdown_css.dropdownItem({
|
|
188
|
-
disabled: !!option.disabled,
|
|
189
|
-
selected: selectedData.selectedValues.includes(option.value) && !option.disabled
|
|
190
|
-
}), "data-testid": `option-${option.value}`, id: `option-${indexOption}`, onClick: () => {
|
|
191
|
-
if (!option.disabled) {
|
|
192
|
-
handleClick(option, group);
|
|
193
|
-
}
|
|
194
|
-
}, onKeyDown: (event) => [" ", "Enter"].includes(event.key) ? handleClick(option, group) : null, ref: option.value === defaultSearchValue || option.searchText === defaultSearchValue ? focusedItemRef : null, role: "option", tabIndex: !option.disabled ? 0 : -1, children: multiselect ? /* @__PURE__ */ jsxRuntime.jsx(index$4.Checkbox, { checked: selectedData.selectedValues.includes(option.value) && !option.disabled, className: dropdown_css.dropdownCheckbox, disabled: option.disabled, onChange: () => {
|
|
195
|
-
if (!option.disabled) {
|
|
196
|
-
handleClick(option, group);
|
|
197
|
-
}
|
|
198
|
-
}, tabIndex: -1, value: option.value, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownOption.DisplayOption, { descriptionDirection, option, optionalInfoPlacement }) }) : /* @__PURE__ */ jsxRuntime.jsx(DropdownOption.DisplayOption, { descriptionDirection, option, optionalInfoPlacement }) }, option.value)) })
|
|
199
|
-
] }, group))
|
|
200
|
-
] }),
|
|
201
|
-
loadMore ? /* @__PURE__ */ jsxRuntime.jsx(index$1.Stack, { className: dropdown_css.dropdownLoadMore, children: loadMore }) : null
|
|
202
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { className: `${dropdown_css.dropdownContainer} ${dropdown_css.dropdownContainerUnGrouped}`, gap: 0.25, id: "select-dropdown", onKeyDown: handleKeyDownSelect, role: "listbox", children: [
|
|
203
|
-
selectAll && multiselect ? /* @__PURE__ */ jsxRuntime.jsx(index$1.Stack, { gap: 0.25, id: "items", tabIndex: -1, children: /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-disabled": false, "aria-label": "select-all", "aria-selected": selectedData.allSelected, className: dropdown_css.dropdownItem({
|
|
204
|
-
selected: selectedData.allSelected
|
|
205
|
-
}), "data-testid": "select-all", onClick: selectAllOptions, onKeyDown: (event) => [" ", "Enter"].includes(event.key) ? selectAllOptions() : null, role: "option", tabIndex: 0, children: /* @__PURE__ */ jsxRuntime.jsx(index$4.Checkbox, { checked: selectedData.allSelected, className: dropdown_css.dropdownCheckbox, "data-testid": "select-all-checkbox", disabled: false, onChange: selectAllOptions, tabIndex: -1, value: "select-all", children: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { direction: "column", children: [
|
|
206
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", variant: "body", children: selectAll.label }),
|
|
207
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", prominence: "weak", sentiment: "neutral", variant: "bodySmall", children: selectAll.description })
|
|
208
|
-
] }) }) }) }) : null,
|
|
209
|
-
/* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { gap: 0.25, id: "items", children: [
|
|
210
|
-
isLoading ? /* @__PURE__ */ jsxRuntime.jsx(index$3.Skeleton, { variant: "block" }) : displayedOptions.map((option, index2) => /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-disabled": !!option.disabled, "aria-label": option.value, "aria-selected": selectedData.selectedValues.includes(option.value) && !option.disabled, className: dropdown_css.dropdownItem({
|
|
211
|
-
disabled: !!option.disabled,
|
|
212
|
-
selected: selectedData.selectedValues.includes(option.value) && !option.disabled
|
|
213
|
-
}), "data-testid": `option-${option.value}`, id: `option-${index2}`, onClick: () => {
|
|
214
|
-
if (!option.disabled) {
|
|
215
|
-
handleClick(option);
|
|
216
|
-
}
|
|
217
|
-
}, onKeyDown: (event) => [" ", "Enter"].includes(event.key) ? handleClick(option) : null, ref: option.value === defaultSearchValue || option.searchText === defaultSearchValue ? focusedItemRef : null, role: "option", tabIndex: !option.disabled ? 0 : -1, children: multiselect ? /* @__PURE__ */ jsxRuntime.jsx(index$4.Checkbox, { checked: selectedData.selectedValues.includes(option.value) && !option.disabled, className: dropdown_css.dropdownCheckbox, disabled: option.disabled, onChange: () => {
|
|
218
|
-
if (!option.disabled) {
|
|
219
|
-
handleClick(option);
|
|
220
|
-
}
|
|
221
|
-
}, tabIndex: -1, value: option.value, children: /* @__PURE__ */ jsxRuntime.jsx(DropdownOption.DisplayOption, { descriptionDirection, option, optionalInfoPlacement }) }) : /* @__PURE__ */ jsxRuntime.jsx(DropdownOption.DisplayOption, { descriptionDirection, option, optionalInfoPlacement }) }, option.value)),
|
|
222
|
-
loadMore ? /* @__PURE__ */ jsxRuntime.jsx(index$1.Stack, { className: dropdown_css.dropdownLoadMore, children: loadMore }) : null
|
|
223
|
-
] })
|
|
224
|
-
] });
|
|
225
|
-
};
|
|
226
|
-
const Dropdown = ({
|
|
227
|
-
children,
|
|
228
|
-
emptyState,
|
|
229
|
-
descriptionDirection,
|
|
230
|
-
searchable,
|
|
231
|
-
placeholder,
|
|
232
|
-
footer,
|
|
233
|
-
refSelect,
|
|
234
|
-
loadMore,
|
|
235
|
-
optionalInfoPlacement,
|
|
236
|
-
isLoading,
|
|
237
|
-
size,
|
|
238
|
-
dropdownAlign,
|
|
239
|
-
portalTarget,
|
|
240
|
-
id
|
|
241
|
-
}) => {
|
|
242
|
-
const {
|
|
243
|
-
setIsDropdownVisible,
|
|
244
|
-
isDropdownVisible,
|
|
245
|
-
onSearch,
|
|
246
|
-
searchInput,
|
|
247
|
-
options,
|
|
248
|
-
displayedOptions,
|
|
249
|
-
numberOfOptions
|
|
250
|
-
} = SelectInputProvider.useSelectInput();
|
|
251
|
-
const theme = themes.useTheme();
|
|
252
|
-
const [searchBarActive, setSearchBarActive] = react.useState(false);
|
|
253
|
-
const [defaultSearchValue, setDefaultSearch] = react.useState(null);
|
|
254
|
-
const ref = react.useRef(null);
|
|
255
|
-
const [search, setSearch] = react.useState("");
|
|
256
|
-
const [maxWidth, setWidth] = react.useState(refSelect.current?.offsetWidth ?? "100%");
|
|
257
|
-
const modalContext = react.useContext(ModalProvider.ModalContext);
|
|
258
|
-
react.useEffect(() => {
|
|
259
|
-
if (refSelect.current && isDropdownVisible) {
|
|
260
|
-
const position = refSelect.current.getBoundingClientRect().bottom + DROPDOWN_MAX_HEIGHT + Number(theme.sizing[types.INPUT_SIZE_HEIGHT[size]].replace("rem", "")) * 16 + Number.parseInt(theme.space["5"], 10);
|
|
261
|
-
const overflow = position - window.innerHeight + 32;
|
|
262
|
-
if (overflow > 0 && modalContext) {
|
|
263
|
-
const currentModal = modalContext.openedModals[0];
|
|
264
|
-
const modalElement = currentModal?.ref.current;
|
|
265
|
-
if (modalElement) {
|
|
266
|
-
const parentElement = modalElement.parentNode;
|
|
267
|
-
if (parentElement) {
|
|
268
|
-
parentElement.scrollBy({
|
|
269
|
-
behavior: "smooth",
|
|
270
|
-
top: overflow
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
} else {
|
|
274
|
-
window.scrollBy({
|
|
275
|
-
behavior: "smooth",
|
|
276
|
-
top: overflow
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}, [isDropdownVisible, refSelect, size, ref.current]);
|
|
282
|
-
const resizeDropdown = react.useCallback(() => {
|
|
283
|
-
if (refSelect.current && refSelect.current.getBoundingClientRect().width > 0) {
|
|
284
|
-
setWidth(refSelect.current.getBoundingClientRect().width);
|
|
285
|
-
}
|
|
286
|
-
}, [refSelect]);
|
|
287
|
-
react.useEffect(() => {
|
|
288
|
-
resizeDropdown();
|
|
289
|
-
window.addEventListener("resize", resizeDropdown);
|
|
290
|
-
return () => window.removeEventListener("resize", resizeDropdown);
|
|
291
|
-
}, [resizeDropdown]);
|
|
292
|
-
react.useEffect(() => {
|
|
293
|
-
if (!searchInput) {
|
|
294
|
-
onSearch(options);
|
|
295
|
-
}
|
|
296
|
-
}, [onSearch, options, searchInput]);
|
|
297
|
-
react.useEffect(() => {
|
|
298
|
-
if (!isDropdownVisible) {
|
|
299
|
-
setDefaultSearch(null);
|
|
300
|
-
setSearch("");
|
|
301
|
-
}
|
|
302
|
-
if (!searchable) {
|
|
303
|
-
document.addEventListener("keydown", (event) => handleKeyDown(event, ref, options, searchBarActive, setSearch, setDefaultSearch, search));
|
|
304
|
-
}
|
|
305
|
-
return () => {
|
|
306
|
-
if (!searchable) {
|
|
307
|
-
document.removeEventListener("keydown", (event) => handleKeyDown(event, ref, options, searchBarActive, setSearch, setDefaultSearch, search));
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}, [isDropdownVisible, searchBarActive, options, onSearch, search, refSelect, setDefaultSearch, setIsDropdownVisible, searchable]);
|
|
311
|
-
const isEmpty = react.useMemo(() => {
|
|
312
|
-
if (numberOfOptions === 0) {
|
|
313
|
-
return true;
|
|
314
|
-
}
|
|
315
|
-
if (Array.isArray(displayedOptions)) {
|
|
316
|
-
return displayedOptions.length === 0;
|
|
317
|
-
}
|
|
318
|
-
const groups = Object.keys(displayedOptions);
|
|
319
|
-
for (const group of groups) {
|
|
320
|
-
if (displayedOptions[group].length > 0) {
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return true;
|
|
325
|
-
}, [displayedOptions, numberOfOptions]);
|
|
326
|
-
const computedFooter = react.useMemo(() => {
|
|
327
|
-
if (footer && !isEmpty) {
|
|
328
|
-
if (typeof footer === "function") {
|
|
329
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: dropdown_css.footer, children: footer(() => setIsDropdownVisible(false)) });
|
|
330
|
-
}
|
|
331
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: dropdown_css.footer, children: footer });
|
|
332
|
-
}
|
|
333
|
-
return null;
|
|
334
|
-
}, [isEmpty, footer, setIsDropdownVisible]);
|
|
335
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index.Popup, { align: dropdownAlign ?? "start", className: dropdown_css.dropdown, containerFullWidth: true, debounceDelay: 0, disableAnimation: true, hasArrow: false, hideOnClickOutside: true, id, maxWidth: maxWidth ?? refSelect.current?.offsetWidth, onClose: () => setIsDropdownVisible(false), placement: "bottom", portalTarget, ref, role: "dialog", tabIndex: -1, text: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { children: [
|
|
336
|
-
searchable && !isLoading && numberOfOptions >= 6 ? /* @__PURE__ */ jsxRuntime.jsx(SearchBarDropdown.SearchBarDropdown, { displayedOptions, placeholder, setSearchBarActive }) : null,
|
|
337
|
-
/* @__PURE__ */ jsxRuntime.jsx(CreateDropdown, { defaultSearchValue, descriptionDirection, emptyState, isEmpty, isLoading, loadMore, optionalInfoPlacement }),
|
|
338
|
-
computedFooter
|
|
339
|
-
] }), visible: isDropdownVisible, children });
|
|
340
|
-
};
|
|
341
|
-
exports.Dropdown = Dropdown;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const index$1 = require("../../Stack/index.cjs");
|
|
6
|
-
const index$2 = require("../../Text/index.cjs");
|
|
7
|
-
const index = require("../../Tooltip/index.cjs");
|
|
8
|
-
const dropdown_css = require("./dropdown.css.cjs");
|
|
9
|
-
const DisplayOption = ({
|
|
10
|
-
option,
|
|
11
|
-
optionalInfoPlacement,
|
|
12
|
-
descriptionDirection
|
|
13
|
-
}) => {
|
|
14
|
-
if (descriptionDirection === "row" && optionalInfoPlacement === "left") {
|
|
15
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index.Tooltip, { text: option.tooltip, children: /* @__PURE__ */ jsxRuntime.jsx(index$1.Stack, { "data-testid": `option-stack-${option.value}`, direction: "row", gap: 0.5, justifyContent: "left", children: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { alignItems: "center", className: dropdown_css.dropdownInfoContainer, direction: "row", gap: 0.5, children: [
|
|
16
|
-
option.optionalInfo ?? null,
|
|
17
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", className: dropdown_css.dropdownInfoTextItem, placement: "left", variant: "body", children: option.label }),
|
|
18
|
-
option.description ? /* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", prominence: "weak", sentiment: "neutral", variant: "bodySmall", children: option.description }) : null
|
|
19
|
-
] }) }) });
|
|
20
|
-
}
|
|
21
|
-
if (descriptionDirection === "row" && optionalInfoPlacement === "right") {
|
|
22
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index.Tooltip, { text: option.tooltip, children: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { alignItems: "baseline", "data-testid": `option-stack-${option.value}`, direction: "row", gap: 0.5, justifyContent: "space-between", children: [
|
|
23
|
-
/* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { alignItems: "baseline", className: dropdown_css.dropdownInfoContainer, direction: "row", gap: 0.5, children: [
|
|
24
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", className: dropdown_css.dropdownInfoTextItem, placement: "left", variant: "body", children: option.label }),
|
|
25
|
-
option.description ? /* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", prominence: "weak", sentiment: "neutral", variant: "bodySmall", children: option.description }) : null
|
|
26
|
-
] }),
|
|
27
|
-
option.optionalInfo ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: dropdown_css.dropdownInfo, children: option.optionalInfo }) : null
|
|
28
|
-
] }) });
|
|
29
|
-
}
|
|
30
|
-
if (descriptionDirection === "column" && optionalInfoPlacement === "left") {
|
|
31
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index.Tooltip, { text: option.tooltip, children: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { alignItems: "normal", direction: "row", gap: 0.5, justifyContent: option.optionalInfo ? "left" : "space-between", children: [
|
|
32
|
-
option.optionalInfo ?? null,
|
|
33
|
-
/* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { className: dropdown_css.dropdownInfoContainer, "data-testid": `option-stack-${option.value}`, direction: "column", gap: 0.5, children: [
|
|
34
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", className: dropdown_css.dropdownInfoTextItem, placement: "left", variant: "body", children: option.label }),
|
|
35
|
-
option.description ? /* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", prominence: "weak", sentiment: "neutral", variant: "bodySmall", children: option.description }) : null
|
|
36
|
-
] })
|
|
37
|
-
] }) });
|
|
38
|
-
}
|
|
39
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index.Tooltip, { text: option.tooltip, children: /* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { alignItems: "normal", "data-testid": `option-stack-${option.value}`, direction: "column", gap: 0.5, children: [
|
|
40
|
-
/* @__PURE__ */ jsxRuntime.jsxs(index$1.Stack, { className: dropdown_css.dropdownInfoContainer, direction: "row", gap: 0.5, justifyContent: "space-between", children: [
|
|
41
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", className: dropdown_css.dropdownInfoTextItem, placement: "left", variant: "body", children: option.label }),
|
|
42
|
-
option.optionalInfo ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: dropdown_css.dropdownInfo, children: option.optionalInfo }) : null
|
|
43
|
-
] }),
|
|
44
|
-
option.description ? /* @__PURE__ */ jsxRuntime.jsx(index$2.Text, { as: "span", placement: "left", prominence: "weak", sentiment: "neutral", variant: "bodySmall", children: option.description }) : null
|
|
45
|
-
] }) });
|
|
46
|
-
};
|
|
47
|
-
exports.DisplayOption = DisplayOption;
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const fuzzySearch = require("@scaleway/fuzzy-search");
|
|
6
|
-
const Icon = require("@ultraviolet/icons");
|
|
7
|
-
const react = require("react");
|
|
8
|
-
const index = require("../../TextInput/index.cjs");
|
|
9
|
-
const SelectInputProvider = require("../SelectInputProvider.cjs");
|
|
10
|
-
const dropdown_css = require("./dropdown.css.cjs");
|
|
11
|
-
const getReferenceText = (option) => {
|
|
12
|
-
if (option.searchText) {
|
|
13
|
-
return fuzzySearch.normalizeString(option.searchText);
|
|
14
|
-
}
|
|
15
|
-
if (typeof option.label === "string") {
|
|
16
|
-
return fuzzySearch.normalizeString(option.label);
|
|
17
|
-
}
|
|
18
|
-
return "";
|
|
19
|
-
};
|
|
20
|
-
const searchRegex = (data, query) => data.filter((option) => {
|
|
21
|
-
const referenceText = getReferenceText(option);
|
|
22
|
-
const regex = new RegExp(query, "i");
|
|
23
|
-
return (query.length > 2 ? fuzzySearch.isFuzzyMatch(query, referenceText) : referenceText.match(regex)) || typeof option.description === "string" && option.description.match(regex) || option.value.match(regex);
|
|
24
|
-
});
|
|
25
|
-
const findClosestOption = (options, searchInput) => {
|
|
26
|
-
if (searchInput) {
|
|
27
|
-
if (!Array.isArray(options)) {
|
|
28
|
-
const possibleOptions = {
|
|
29
|
-
...options
|
|
30
|
-
};
|
|
31
|
-
Object.keys(possibleOptions).map((group) => {
|
|
32
|
-
possibleOptions[group] = possibleOptions[group].filter((option) => !option.disabled);
|
|
33
|
-
return null;
|
|
34
|
-
});
|
|
35
|
-
if (Object.keys(possibleOptions).some((group) => possibleOptions[group].length > 0)) {
|
|
36
|
-
const firstFit = Object.keys(possibleOptions).map((group) => possibleOptions[group][0]).find((value) => !!value);
|
|
37
|
-
return firstFit;
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
const possibleOption = [...options].find((option) => !option.disabled);
|
|
41
|
-
if (possibleOption) {
|
|
42
|
-
return possibleOption;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
};
|
|
48
|
-
const escapeRegExp = (string) => string.replace(/[.*+?^{}()|[\]\\]/g, String.raw`\$&`);
|
|
49
|
-
const SearchBarDropdown = ({
|
|
50
|
-
placeholder,
|
|
51
|
-
displayedOptions,
|
|
52
|
-
setSearchBarActive
|
|
53
|
-
}) => {
|
|
54
|
-
const searchInputRef = react.useRef(null);
|
|
55
|
-
const {
|
|
56
|
-
onChange,
|
|
57
|
-
onSearch,
|
|
58
|
-
setSearchInput,
|
|
59
|
-
searchInput,
|
|
60
|
-
options,
|
|
61
|
-
multiselect,
|
|
62
|
-
setSelectedData,
|
|
63
|
-
selectedData
|
|
64
|
-
} = SelectInputProvider.useSelectInput();
|
|
65
|
-
const handleChange = (search) => {
|
|
66
|
-
if (search.length > 0) {
|
|
67
|
-
if (!Array.isArray(options)) {
|
|
68
|
-
const filteredOptions = {
|
|
69
|
-
...options
|
|
70
|
-
};
|
|
71
|
-
Object.keys(filteredOptions).map((group) => {
|
|
72
|
-
filteredOptions[group] = searchRegex(filteredOptions[group], escapeRegExp(search.toString()));
|
|
73
|
-
return null;
|
|
74
|
-
});
|
|
75
|
-
onSearch(filteredOptions);
|
|
76
|
-
} else {
|
|
77
|
-
const filteredOptions = searchRegex([...options], escapeRegExp(search.toString()));
|
|
78
|
-
onSearch(filteredOptions);
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
onSearch(options);
|
|
82
|
-
}
|
|
83
|
-
setSearchInput(search);
|
|
84
|
-
};
|
|
85
|
-
const handleKeyDown = (key, search) => {
|
|
86
|
-
if (key === "Enter") {
|
|
87
|
-
const closestOption = findClosestOption(displayedOptions, search);
|
|
88
|
-
if (closestOption) {
|
|
89
|
-
if (multiselect) {
|
|
90
|
-
setSelectedData({
|
|
91
|
-
clickedOption: closestOption,
|
|
92
|
-
group: !Array.isArray(options) ? Object.keys(options).find((group) => options[group].includes(closestOption)) : void 0,
|
|
93
|
-
type: "selectOption"
|
|
94
|
-
});
|
|
95
|
-
onChange?.(selectedData.selectedValues.includes(closestOption.value) ? selectedData.selectedValues : [...selectedData.selectedValues, closestOption.value]);
|
|
96
|
-
} else {
|
|
97
|
-
setSelectedData({
|
|
98
|
-
clickedOption: closestOption,
|
|
99
|
-
type: "selectOption"
|
|
100
|
-
});
|
|
101
|
-
onChange?.(selectedData.selectedValues[0] ?? "");
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
} else if (key === "Tab") {
|
|
105
|
-
searchInputRef.current?.blur();
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
react.useEffect(() => {
|
|
109
|
-
setTimeout(() => {
|
|
110
|
-
searchInputRef.current?.focus();
|
|
111
|
-
}, 50);
|
|
112
|
-
}, []);
|
|
113
|
-
return /* @__PURE__ */ jsxRuntime.jsx(index.TextInput, { "aria-label": "search-bar", className: dropdown_css.searchBar, "data-testid": "search-bar", onBlur: () => setSearchBarActive(false), onChange: (event) => handleChange(event.target.value), onFocus: () => setSearchBarActive(true), onKeyDown: (event) => handleKeyDown(event.key, searchInput), placeholder, prefix: /* @__PURE__ */ jsxRuntime.jsx(Icon.SearchIcon, { sentiment: "neutral", size: "small" }), ref: searchInputRef, size: "medium", value: searchInput });
|
|
114
|
-
};
|
|
115
|
-
exports.SearchBarDropdown = SearchBarDropdown;
|
|
116
|
-
exports.getReferenceText = getReferenceText;
|
|
117
|
-
exports.searchRegex = searchRegex;
|