@ultraviolet/ui 1.51.1 → 1.51.2
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/index.d.ts +20 -0
- package/dist/components/ActionBar/index.js +40 -0
- package/dist/components/Alert/index.d.ts +27 -0
- package/dist/components/Alert/index.js +126 -0
- package/dist/components/Avatar/index.d.ts +43 -0
- package/dist/components/Avatar/index.js +54 -0
- package/dist/components/Badge/index.d.ts +31 -0
- package/dist/components/Badge/index.js +115 -0
- package/dist/components/Banner/assets/default-image-small.svg.js +4 -0
- package/dist/components/Banner/assets/default-image.svg.js +4 -0
- package/dist/components/Banner/index.d.ts +24 -0
- package/dist/components/Banner/index.js +191 -0
- package/dist/components/BarChart/Tooltip.d.ts +9 -0
- package/dist/components/BarChart/Tooltip.js +36 -0
- package/dist/components/BarChart/index.d.ts +27 -0
- package/dist/components/BarChart/index.js +82 -0
- package/dist/components/BarStack/index.d.ts +36 -0
- package/dist/components/BarStack/index.js +188 -0
- package/dist/components/Breadcrumbs/index.d.ts +30 -0
- package/dist/components/Breadcrumbs/index.js +76 -0
- package/dist/components/Bullet/index.d.ts +39 -0
- package/dist/components/Bullet/index.js +88 -0
- package/dist/components/Button/index.d.ts +120 -0
- package/dist/components/Button/index.js +291 -0
- package/dist/components/Card/index.d.ts +20 -0
- package/dist/components/Card/index.js +59 -0
- package/dist/components/Carousel/index.d.ts +19 -0
- package/dist/components/Carousel/index.js +147 -0
- package/dist/components/Checkbox/index.d.ts +36 -0
- package/dist/components/Checkbox/index.js +359 -0
- package/dist/components/CheckboxGroup/index.d.ts +24 -0
- package/dist/components/CheckboxGroup/index.js +112 -0
- package/dist/components/CopyButton/index.d.ts +19 -0
- package/dist/components/CopyButton/index.js +37 -0
- package/dist/components/DateInput/datepicker.css.js +4 -0
- package/dist/components/DateInput/index.d.ts +38 -0
- package/dist/components/DateInput/index.js +301 -0
- package/dist/components/Dialog/Context.d.ts +7 -0
- package/dist/components/Dialog/Context.js +15 -0
- package/dist/components/Dialog/constants.d.ts +2 -0
- package/dist/components/Dialog/index.d.ts +87 -0
- package/dist/components/Dialog/index.js +87 -0
- package/dist/components/Dialog/subComponents/Button.d.ts +7 -0
- package/dist/components/Dialog/subComponents/Button.js +24 -0
- package/dist/components/Dialog/subComponents/Buttons.d.ts +7 -0
- package/dist/components/Dialog/subComponents/Buttons.js +12 -0
- package/dist/components/Dialog/subComponents/CancelButton.d.ts +8 -0
- package/dist/components/Dialog/subComponents/CancelButton.js +9 -0
- package/dist/components/Dialog/subComponents/Stack.d.ts +6 -0
- package/dist/components/Dialog/subComponents/Stack.js +6 -0
- package/dist/components/Dialog/subComponents/Text.d.ts +6 -0
- package/dist/components/Dialog/subComponents/Text.js +6 -0
- package/dist/components/EmptyState/index.d.ts +38 -0
- package/dist/components/EmptyState/index.js +82 -0
- package/dist/components/Expandable/index.d.ts +33 -0
- package/dist/components/Expandable/index.js +79 -0
- package/dist/components/GlobalAlert/GlobalAlertLink.d.ts +3 -0
- package/dist/components/GlobalAlert/GlobalAlertLink.js +39 -0
- package/dist/components/GlobalAlert/index.d.ts +40 -0
- package/dist/components/GlobalAlert/index.js +112 -0
- package/dist/components/LineChart/CustomLegend.d.ts +13 -0
- package/dist/components/LineChart/CustomLegend.js +109 -0
- package/dist/components/LineChart/Tooltip.d.ts +6 -0
- package/dist/components/LineChart/Tooltip.js +46 -0
- package/dist/components/LineChart/helpers.d.ts +8 -0
- package/dist/components/LineChart/helpers.js +50 -0
- package/dist/components/LineChart/index.d.ts +25 -0
- package/dist/components/LineChart/index.js +118 -0
- package/dist/components/Link/index.d.ts +33 -0
- package/dist/components/Link/index.js +167 -0
- package/dist/components/List/Body.d.ts +6 -0
- package/dist/components/List/Body.js +11 -0
- package/dist/components/List/Cell.d.ts +12 -0
- package/dist/components/List/Cell.js +38 -0
- package/dist/components/List/HeaderCell.d.ts +11 -0
- package/dist/components/List/HeaderCell.js +96 -0
- package/dist/components/List/HeaderRow.d.ts +7 -0
- package/dist/components/List/HeaderRow.js +38 -0
- package/dist/components/List/ListContext.d.ts +34 -0
- package/dist/components/List/ListContext.js +155 -0
- package/dist/components/List/Row.d.ts +23 -0
- package/dist/components/List/Row.js +194 -0
- package/dist/components/List/SelectBar.d.ts +15 -0
- package/dist/components/List/SelectBar.js +35 -0
- package/dist/components/List/SkeletonRows.d.ts +7 -0
- package/dist/components/List/SkeletonRows.js +36 -0
- package/dist/components/List/constants.d.ts +2 -0
- package/dist/{src/components → components}/List/constants.js +4 -2
- package/dist/components/List/index.d.ts +68 -0
- package/dist/components/List/index.js +80 -0
- package/dist/components/Loader/index.d.ts +22 -0
- package/dist/components/Loader/index.js +98 -0
- package/dist/components/Menu/Item.d.ts +15 -0
- package/dist/components/Menu/Item.js +101 -0
- package/dist/components/Menu/index.d.ts +49 -0
- package/dist/components/Menu/index.js +182 -0
- package/dist/components/MenuV2/Group.d.ts +7 -0
- package/dist/components/MenuV2/Group.js +23 -0
- package/dist/components/MenuV2/Item.d.ts +16 -0
- package/dist/components/MenuV2/Item.js +120 -0
- package/dist/components/MenuV2/index.d.ts +90 -0
- package/dist/components/MenuV2/index.js +124 -0
- package/dist/components/Meter/index.d.ts +26 -0
- package/dist/components/Meter/index.js +76 -0
- package/dist/components/Modal/Dialog.d.ts +3 -0
- package/dist/components/Modal/Dialog.js +197 -0
- package/dist/components/Modal/Disclosure.d.ts +3 -0
- package/dist/{src/components → components}/Modal/Disclosure.js +12 -12
- package/dist/components/Modal/constants.d.ts +3 -0
- package/dist/{src/components → components}/Modal/constants.js +8 -6
- package/dist/components/Modal/index.d.ts +42 -0
- package/dist/components/Modal/index.js +114 -0
- package/dist/components/Modal/types.d.ts +48 -0
- package/dist/components/Notice/index.d.ts +11 -0
- package/dist/components/Notice/index.js +39 -0
- package/dist/components/Notification/index.d.ts +36 -0
- package/dist/components/Notification/index.js +88 -0
- package/dist/components/Notification/react-toastify.css.js +4 -0
- package/dist/components/NumberInput/helpers.d.ts +4 -0
- package/dist/{src/components → components}/NumberInput/helpers.js +6 -2
- package/dist/components/NumberInput/index.d.ts +41 -0
- package/dist/components/NumberInput/index.js +349 -0
- package/dist/components/NumberInputV2/index.d.ts +27 -0
- package/dist/components/NumberInputV2/index.js +370 -0
- package/dist/components/Pagination/getPageNumbers.d.ts +8 -0
- package/dist/{src/components → components}/Pagination/getPageNumbers.js +4 -12
- package/dist/components/Pagination/index.d.ts +30 -0
- package/dist/components/Pagination/index.js +124 -0
- package/dist/components/PasswordCheck/index.d.ts +20 -0
- package/dist/components/PasswordCheck/index.js +29 -0
- package/dist/components/PasswordStrengthMeter/index.d.ts +39 -0
- package/dist/components/PasswordStrengthMeter/index.js +98 -0
- package/dist/components/PieChart/Legends.d.ts +9 -0
- package/dist/components/PieChart/Legends.js +120 -0
- package/dist/components/PieChart/Tooltip.d.ts +12 -0
- package/dist/components/PieChart/Tooltip.js +29 -0
- package/dist/components/PieChart/index.d.ts +20 -0
- package/dist/components/PieChart/index.js +120 -0
- package/dist/components/PieChart/types.d.ts +7 -0
- package/dist/components/Popover/index.d.ts +55 -0
- package/dist/components/Popover/index.js +149 -0
- package/dist/components/Popup/animations.d.ts +11 -0
- package/dist/{src/components → components}/Popup/animations.js +7 -6
- package/dist/components/Popup/helpers.d.ts +31 -0
- package/dist/components/Popup/helpers.js +204 -0
- package/dist/components/Popup/index.d.ts +72 -0
- package/dist/components/Popup/index.js +385 -0
- package/dist/components/ProgressBar/index.d.ts +14 -0
- package/dist/components/ProgressBar/index.js +71 -0
- package/dist/components/Radio/index.d.ts +21 -0
- package/dist/components/Radio/index.js +202 -0
- package/dist/components/RadioGroup/index.d.ts +25 -0
- package/dist/components/RadioGroup/index.js +104 -0
- package/dist/components/Row/index.d.ts +22 -0
- package/dist/components/Row/index.js +43 -0
- package/dist/components/SelectInput/index.d.ts +75 -0
- package/dist/components/SelectInput/index.js +563 -0
- package/dist/components/SelectInputV2/Dropdown.d.ts +23 -0
- package/dist/components/SelectInputV2/Dropdown.js +669 -0
- package/dist/components/SelectInputV2/DropdownOption.d.ts +8 -0
- package/dist/components/SelectInputV2/DropdownOption.js +133 -0
- package/dist/components/SelectInputV2/SearchBarDropdown.d.ts +9 -0
- package/dist/components/SelectInputV2/SearchBarDropdown.js +123 -0
- package/dist/components/SelectInputV2/SelectBar.d.ts +14 -0
- package/dist/components/SelectInputV2/SelectBar.js +327 -0
- package/dist/components/SelectInputV2/SelectInputProvider.d.ts +41 -0
- package/dist/components/SelectInputV2/SelectInputProvider.js +203 -0
- package/dist/components/SelectInputV2/findOptionInOptions.d.ts +2 -0
- package/dist/components/SelectInputV2/findOptionInOptions.js +12 -0
- package/dist/components/SelectInputV2/index.d.ts +115 -0
- package/dist/components/SelectInputV2/index.js +146 -0
- package/dist/components/SelectInputV2/types.d.ts +38 -0
- package/dist/{src/components → components}/SelectInputV2/types.js +4 -2
- package/dist/components/SelectableCard/index.d.ts +25 -0
- package/dist/components/SelectableCard/index.js +193 -0
- package/dist/components/SelectableCardGroup/index.d.ts +23 -0
- package/dist/components/SelectableCardGroup/index.js +112 -0
- package/dist/components/Separator/index.d.ts +17 -0
- package/dist/components/Separator/index.js +76 -0
- package/dist/components/Skeleton/Block.d.ts +3 -0
- package/dist/components/Skeleton/Block.js +30 -0
- package/dist/components/Skeleton/Blocks.d.ts +4 -0
- package/dist/components/Skeleton/Blocks.js +28 -0
- package/dist/components/Skeleton/BoxWithIcon.d.ts +4 -0
- package/dist/components/Skeleton/BoxWithIcon.js +29 -0
- package/dist/components/Skeleton/Donut.d.ts +1 -0
- package/dist/components/Skeleton/Donut.js +36 -0
- package/dist/components/Skeleton/IconSkeleton.d.ts +5 -0
- package/dist/components/Skeleton/IconSkeleton.js +12 -0
- package/dist/components/Skeleton/Line.d.ts +5 -0
- package/dist/components/Skeleton/Line.js +13 -0
- package/dist/components/Skeleton/List.d.ts +4 -0
- package/dist/components/Skeleton/List.js +29 -0
- package/dist/components/Skeleton/Slider.d.ts +3 -0
- package/dist/components/Skeleton/Slider.js +26 -0
- package/dist/components/Skeleton/Square.d.ts +5 -0
- package/dist/components/Skeleton/Square.js +10 -0
- package/dist/components/Skeleton/index.d.ts +47 -0
- package/dist/components/Skeleton/index.js +86 -0
- package/dist/components/Snippet/index.d.ts +23 -0
- package/dist/components/Snippet/index.js +171 -0
- package/dist/components/Stack/index.d.ts +23 -0
- package/dist/components/Stack/index.js +36 -0
- package/dist/components/Status/index.d.ts +32 -0
- package/dist/components/Status/index.js +57 -0
- package/dist/components/StepList/index.d.ts +33 -0
- package/dist/components/StepList/index.js +69 -0
- package/dist/components/Stepper/index.d.ts +15 -0
- package/dist/components/Stepper/index.js +153 -0
- package/dist/components/SwitchButton/FocusOverlay.d.ts +8 -0
- package/dist/components/SwitchButton/FocusOverlay.js +47 -0
- package/dist/components/SwitchButton/index.d.ts +26 -0
- package/dist/components/SwitchButton/index.js +140 -0
- package/dist/components/Table/Body.d.ts +6 -0
- package/dist/components/Table/Body.js +5 -0
- package/dist/components/Table/Cell.d.ts +9 -0
- package/dist/components/Table/Cell.js +10 -0
- package/dist/components/Table/Header.d.ts +6 -0
- package/dist/components/Table/Header.js +9 -0
- package/dist/components/Table/HeaderCell.d.ts +14 -0
- package/dist/components/Table/HeaderCell.js +123 -0
- package/dist/components/Table/HeaderRow.d.ts +7 -0
- package/dist/components/Table/HeaderRow.js +25 -0
- package/dist/components/Table/Row.d.ts +14 -0
- package/dist/components/Table/Row.js +85 -0
- package/dist/components/Table/SelectBar.d.ts +15 -0
- package/dist/components/Table/SelectBar.js +35 -0
- package/dist/components/Table/SkeletonRows.d.ts +7 -0
- package/dist/components/Table/SkeletonRows.js +22 -0
- package/dist/components/Table/TableContext.d.ts +27 -0
- package/dist/components/Table/TableContext.js +103 -0
- package/dist/components/Table/index.d.ts +60 -0
- package/dist/components/Table/index.js +81 -0
- package/dist/components/Tabs/Tab.d.ts +20 -0
- package/dist/components/Tabs/Tab.js +170 -0
- package/dist/components/Tabs/TabMenu.d.ts +8 -0
- package/dist/components/Tabs/TabMenu.js +63 -0
- package/dist/components/Tabs/TabMenuItem.d.ts +20 -0
- package/dist/components/Tabs/TabMenuItem.js +39 -0
- package/dist/components/Tabs/TabsContext.d.ts +8 -0
- package/dist/components/Tabs/TabsContext.js +9 -0
- package/dist/components/Tabs/index.d.ts +50 -0
- package/dist/components/Tabs/index.js +137 -0
- package/dist/components/Tag/index.d.ts +26 -0
- package/dist/components/Tag/index.js +153 -0
- package/dist/components/TagInput/index.d.ts +55 -0
- package/dist/components/TagInput/index.js +316 -0
- package/dist/components/TagList/index.d.ts +37 -0
- package/dist/components/TagList/index.js +103 -0
- package/dist/components/Text/index.d.ts +40 -0
- package/dist/components/Text/index.js +107 -0
- package/dist/components/TextArea/index.d.ts +50 -0
- package/dist/components/TextArea/index.js +226 -0
- package/dist/components/TextInput/index.d.ts +75 -0
- package/dist/components/TextInput/index.js +472 -0
- package/dist/components/TextInputV2/index.d.ts +30 -0
- package/dist/components/TextInputV2/index.js +314 -0
- package/dist/components/TimeInput/index.d.ts +25 -0
- package/dist/components/TimeInput/index.js +199 -0
- package/dist/components/Toaster/index.d.ts +46 -0
- package/dist/components/Toaster/index.js +131 -0
- package/dist/components/Toaster/react-toastify.css.js +4 -0
- package/dist/components/Toggle/index.d.ts +34 -0
- package/dist/components/Toggle/index.js +196 -0
- package/dist/components/ToggleGroup/index.d.ts +24 -0
- package/dist/components/ToggleGroup/index.js +87 -0
- package/dist/components/Tooltip/index.d.ts +9 -0
- package/dist/components/Tooltip/index.js +47 -0
- package/dist/components/VerificationCode/index.d.ts +36 -0
- package/dist/components/VerificationCode/index.js +222 -0
- package/dist/components/index.d.ts +75 -0
- package/dist/helpers/isJSON.d.ts +2 -0
- package/dist/{src/helpers → helpers}/isJSON.js +4 -3
- package/dist/helpers/jestMockMatchMedia.d.ts +6 -0
- package/dist/helpers/keycode.d.ts +3 -0
- package/dist/helpers/legend.d.ts +2 -0
- package/dist/helpers/legend.js +14 -0
- package/dist/helpers/numbers.d.ts +2 -0
- package/dist/helpers/recursivelyGetChildrenString.d.ts +3 -0
- package/dist/helpers/recursivelyGetChildrenString.js +15 -0
- package/dist/hooks/useIsOverflowing.d.ts +5 -0
- package/dist/hooks/useIsOverflowing.js +23 -0
- package/dist/index.d.ts +4 -3723
- package/dist/index.js +187 -0
- package/dist/mocks/list.d.ts +12 -0
- package/dist/theme/index.d.ts +1573 -0
- package/dist/theme/index.js +30 -0
- package/dist/types.d.ts +6 -0
- package/dist/utils/animations.d.ts +27 -0
- package/dist/{src/utils → utils}/animations.js +30 -4
- package/dist/utils/capitalize.d.ts +2 -0
- package/dist/utils/capitalize.js +4 -0
- package/dist/utils/ids.d.ts +1 -0
- package/dist/utils/ids.js +6 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/normalize.d.ts +2 -0
- package/dist/{src/utils → utils}/normalize.js +4 -3
- package/dist/utils/orderBy.d.ts +2 -0
- package/dist/utils/responsive/Breakpoint.d.ts +9 -0
- package/dist/utils/responsive/Breakpoint.js +13 -0
- package/dist/utils/responsive/index.d.ts +2 -0
- package/dist/utils/responsive/utilities.d.ts +3 -0
- package/dist/{src/utils → utils}/responsive/utilities.js +9 -6
- package/package.json +17 -7
- package/dist/react-datepicker/dist/react-datepicker.min.css.js +0 -3
- package/dist/react-toastify/dist/ReactToastify.min.css.js +0 -3
- package/dist/src/components/ActionBar/index.js +0 -40
- package/dist/src/components/Alert/index.js +0 -133
- package/dist/src/components/Avatar/index.js +0 -74
- package/dist/src/components/Badge/index.js +0 -116
- package/dist/src/components/Banner/assets/default-image-small.svg.js +0 -5
- package/dist/src/components/Banner/assets/default-image.svg.js +0 -5
- package/dist/src/components/Banner/index.js +0 -159
- package/dist/src/components/BarChart/Tooltip.js +0 -48
- package/dist/src/components/BarChart/index.js +0 -95
- package/dist/src/components/BarStack/index.js +0 -136
- package/dist/src/components/Breadcrumbs/index.js +0 -82
- package/dist/src/components/Bullet/index.js +0 -98
- package/dist/src/components/Button/index.js +0 -311
- package/dist/src/components/Card/index.js +0 -67
- package/dist/src/components/Carousel/index.js +0 -128
- package/dist/src/components/Checkbox/index.js +0 -316
- package/dist/src/components/CheckboxGroup/index.js +0 -143
- package/dist/src/components/CopyButton/index.js +0 -37
- package/dist/src/components/DateInput/index.js +0 -242
- package/dist/src/components/Dialog/Context.js +0 -12
- package/dist/src/components/Dialog/index.js +0 -88
- package/dist/src/components/Dialog/subComponents/Button.js +0 -21
- package/dist/src/components/Dialog/subComponents/Buttons.js +0 -14
- package/dist/src/components/Dialog/subComponents/CancelButton.js +0 -14
- package/dist/src/components/Dialog/subComponents/Stack.js +0 -11
- package/dist/src/components/Dialog/subComponents/Text.js +0 -12
- package/dist/src/components/EmptyState/index.js +0 -112
- package/dist/src/components/Expandable/index.js +0 -96
- package/dist/src/components/GlobalAlert/GlobalAlertLink.js +0 -38
- package/dist/src/components/GlobalAlert/index.js +0 -82
- package/dist/src/components/LineChart/CustomLegend.js +0 -138
- package/dist/src/components/LineChart/Tooltip.js +0 -43
- package/dist/src/components/LineChart/helpers.js +0 -40
- package/dist/src/components/LineChart/index.js +0 -131
- package/dist/src/components/Link/index.js +0 -147
- package/dist/src/components/List/Body.js +0 -16
- package/dist/src/components/List/Cell.js +0 -43
- package/dist/src/components/List/HeaderCell.js +0 -90
- package/dist/src/components/List/HeaderRow.js +0 -43
- package/dist/src/components/List/ListContext.js +0 -138
- package/dist/src/components/List/Row.js +0 -185
- package/dist/src/components/List/SelectBar.js +0 -48
- package/dist/src/components/List/SkeletonRows.js +0 -53
- package/dist/src/components/List/index.js +0 -75
- package/dist/src/components/Loader/index.js +0 -100
- package/dist/src/components/Menu/Item.js +0 -112
- package/dist/src/components/Menu/index.js +0 -129
- package/dist/src/components/MenuV2/Group.js +0 -25
- package/dist/src/components/MenuV2/Item.js +0 -139
- package/dist/src/components/MenuV2/index.js +0 -118
- package/dist/src/components/Meter/index.js +0 -76
- package/dist/src/components/Modal/Dialog.js +0 -182
- package/dist/src/components/Modal/index.js +0 -113
- package/dist/src/components/Notice/index.js +0 -34
- package/dist/src/components/Notification/index.js +0 -77
- package/dist/src/components/NumberInput/index.js +0 -299
- package/dist/src/components/NumberInputV2/index.js +0 -284
- package/dist/src/components/Pagination/index.js +0 -117
- package/dist/src/components/PasswordCheck/index.js +0 -41
- package/dist/src/components/PasswordStrengthMeter/index.js +0 -102
- package/dist/src/components/PieChart/Legends.js +0 -138
- package/dist/src/components/PieChart/Tooltip.js +0 -61
- package/dist/src/components/PieChart/index.js +0 -125
- package/dist/src/components/Popover/index.js +0 -146
- package/dist/src/components/Popup/helpers.js +0 -252
- package/dist/src/components/Popup/index.js +0 -383
- package/dist/src/components/ProgressBar/index.js +0 -57
- package/dist/src/components/Radio/index.js +0 -157
- package/dist/src/components/RadioGroup/index.js +0 -131
- package/dist/src/components/Row/index.js +0 -41
- package/dist/src/components/SelectInput/index.js +0 -610
- package/dist/src/components/SelectInputV2/Dropdown.js +0 -594
- package/dist/src/components/SelectInputV2/DropdownOption.js +0 -130
- package/dist/src/components/SelectInputV2/SearchBarDropdown.js +0 -122
- package/dist/src/components/SelectInputV2/SelectBar.js +0 -282
- package/dist/src/components/SelectInputV2/SelectInputProvider.js +0 -169
- package/dist/src/components/SelectInputV2/findOptionInOptions.js +0 -11
- package/dist/src/components/SelectInputV2/index.js +0 -137
- package/dist/src/components/SelectableCard/index.js +0 -175
- package/dist/src/components/SelectableCardGroup/index.js +0 -141
- package/dist/src/components/Separator/index.js +0 -73
- package/dist/src/components/Skeleton/Block.js +0 -35
- package/dist/src/components/Skeleton/Blocks.js +0 -34
- package/dist/src/components/Skeleton/BoxWithIcon.js +0 -32
- package/dist/src/components/Skeleton/Donut.js +0 -55
- package/dist/src/components/Skeleton/IconSkeleton.js +0 -19
- package/dist/src/components/Skeleton/Line.js +0 -13
- package/dist/src/components/Skeleton/List.js +0 -51
- package/dist/src/components/Skeleton/Slider.js +0 -36
- package/dist/src/components/Skeleton/Square.js +0 -9
- package/dist/src/components/Skeleton/index.js +0 -82
- package/dist/src/components/Snippet/index.js +0 -200
- package/dist/src/components/Stack/index.js +0 -29
- package/dist/src/components/Status/index.js +0 -74
- package/dist/src/components/StepList/index.js +0 -69
- package/dist/src/components/Stepper/index.js +0 -150
- package/dist/src/components/SwitchButton/FocusOverlay.js +0 -37
- package/dist/src/components/SwitchButton/index.js +0 -108
- package/dist/src/components/Table/Body.js +0 -9
- package/dist/src/components/Table/Cell.js +0 -21
- package/dist/src/components/Table/Header.js +0 -15
- package/dist/src/components/Table/HeaderCell.js +0 -103
- package/dist/src/components/Table/HeaderRow.js +0 -32
- package/dist/src/components/Table/Row.js +0 -89
- package/dist/src/components/Table/SelectBar.js +0 -48
- package/dist/src/components/Table/SkeletonRows.js +0 -51
- package/dist/src/components/Table/TableContext.js +0 -90
- package/dist/src/components/Table/index.js +0 -82
- package/dist/src/components/Tabs/Tab.js +0 -138
- package/dist/src/components/Tabs/TabMenu.js +0 -59
- package/dist/src/components/Tabs/TabMenuItem.js +0 -36
- package/dist/src/components/Tabs/TabsContext.js +0 -6
- package/dist/src/components/Tabs/index.js +0 -117
- package/dist/src/components/Tag/index.js +0 -169
- package/dist/src/components/TagInput/index.js +0 -309
- package/dist/src/components/TagList/index.js +0 -106
- package/dist/src/components/Text/index.js +0 -107
- package/dist/src/components/TextArea/index.js +0 -210
- package/dist/src/components/TextInput/index.js +0 -451
- package/dist/src/components/TextInputV2/index.js +0 -289
- package/dist/src/components/TimeInput/index.js +0 -37
- package/dist/src/components/Toaster/index.js +0 -131
- package/dist/src/components/Toggle/index.js +0 -160
- package/dist/src/components/ToggleGroup/index.js +0 -122
- package/dist/src/components/Tooltip/index.js +0 -55
- package/dist/src/components/VerificationCode/index.js +0 -222
- package/dist/src/helpers/legend.js +0 -13
- package/dist/src/helpers/recursivelyGetChildrenString.js +0 -11
- package/dist/src/hooks/useIsOverflowing.js +0 -34
- package/dist/src/index.js +0 -77
- package/dist/src/theme/index.js +0 -29
- package/dist/src/utils/capitalize.js +0 -3
- package/dist/src/utils/ids.js +0 -7
- package/dist/src/utils/responsive/Breakpoint.js +0 -12
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
export type PopupPlacement = 'top' | 'right' | 'bottom' | 'left' | 'auto';
|
|
3
|
+
export declare const ARROW_WIDTH = 8;
|
|
4
|
+
export declare const DEFAULT_POSITIONS: {
|
|
5
|
+
arrowLeft: number;
|
|
6
|
+
arrowTop: number;
|
|
7
|
+
arrowTransform: string;
|
|
8
|
+
placement: string;
|
|
9
|
+
rotate: number;
|
|
10
|
+
popupInitialPosition: string;
|
|
11
|
+
popupPosition: string;
|
|
12
|
+
};
|
|
13
|
+
type ComputePositionsTypes = {
|
|
14
|
+
placement: PopupPlacement;
|
|
15
|
+
childrenRef: RefObject<HTMLDivElement>;
|
|
16
|
+
popupRef: RefObject<HTMLDivElement>;
|
|
17
|
+
popupPortalTarget: HTMLElement;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* This function will compute the positions of popup and arrow based on children position and popup size
|
|
21
|
+
*/
|
|
22
|
+
export declare const computePositions: ({ placement, childrenRef, popupRef, popupPortalTarget, }: ComputePositionsTypes) => {
|
|
23
|
+
arrowLeft: number;
|
|
24
|
+
arrowTop: number;
|
|
25
|
+
arrowTransform: string;
|
|
26
|
+
placement: string;
|
|
27
|
+
rotate: number;
|
|
28
|
+
popupInitialPosition: string;
|
|
29
|
+
popupPosition: string;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
const ARROW_WIDTH = 8;
|
|
2
|
+
const SPACE = 4;
|
|
3
|
+
const TOTAL_USED_SPACE = 0;
|
|
4
|
+
const DEFAULT_POSITIONS = {
|
|
5
|
+
arrowLeft: 0,
|
|
6
|
+
arrowTop: 0,
|
|
7
|
+
arrowTransform: "translate(-50%, -50)",
|
|
8
|
+
placement: "top",
|
|
9
|
+
rotate: 135,
|
|
10
|
+
popupInitialPosition: "translate3d(0px, 0px, 0)",
|
|
11
|
+
popupPosition: "translate3d(0px, 0px, 0)"
|
|
12
|
+
};
|
|
13
|
+
const computePlacement = ({
|
|
14
|
+
childrenStructuredRef,
|
|
15
|
+
popupStructuredRef,
|
|
16
|
+
offsetParentRect,
|
|
17
|
+
offsetParent,
|
|
18
|
+
popupPortalTarget
|
|
19
|
+
}) => {
|
|
20
|
+
const {
|
|
21
|
+
top: childrenTop,
|
|
22
|
+
left: childrenLeft,
|
|
23
|
+
right: childrenRight,
|
|
24
|
+
width: childrenWidth
|
|
25
|
+
} = childrenStructuredRef;
|
|
26
|
+
const { top: parentTop, left: parentLeft } = offsetParentRect;
|
|
27
|
+
const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
|
|
28
|
+
const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
|
|
29
|
+
const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
|
|
30
|
+
const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenLeft - parentLeft + childrenWidth;
|
|
31
|
+
const { width: popupWidth, height: popupHeight } = popupStructuredRef;
|
|
32
|
+
if (overloadedChildrenTop - popupHeight - TOTAL_USED_SPACE < 0) {
|
|
33
|
+
return "bottom";
|
|
34
|
+
}
|
|
35
|
+
if (overloadedChildrenLeft - popupWidth - TOTAL_USED_SPACE < 0) {
|
|
36
|
+
return "right";
|
|
37
|
+
}
|
|
38
|
+
if (overloadedChildrenRight + popupWidth + TOTAL_USED_SPACE > window.innerWidth) {
|
|
39
|
+
return "left";
|
|
40
|
+
}
|
|
41
|
+
return "top";
|
|
42
|
+
};
|
|
43
|
+
const findOffsetParent = (element) => {
|
|
44
|
+
const offsetParent = element?.current?.offsetParent;
|
|
45
|
+
if (offsetParent && !["TH", "TD", "TABLE"].includes(offsetParent.tagName)) {
|
|
46
|
+
return offsetParent;
|
|
47
|
+
}
|
|
48
|
+
let currentElement = element?.current;
|
|
49
|
+
while (currentElement && currentElement.tagName !== "BODY") {
|
|
50
|
+
const { position } = window.getComputedStyle(currentElement);
|
|
51
|
+
if (position !== "static") {
|
|
52
|
+
return currentElement;
|
|
53
|
+
}
|
|
54
|
+
currentElement = currentElement.parentElement;
|
|
55
|
+
}
|
|
56
|
+
return document.body;
|
|
57
|
+
};
|
|
58
|
+
const getPopupOverflowFromParent = (position, offsetParentRect, childrenRect, popupStructuredRef) => {
|
|
59
|
+
const {
|
|
60
|
+
top: parentTop,
|
|
61
|
+
left: parentLeft,
|
|
62
|
+
right: parentRight
|
|
63
|
+
} = offsetParentRect;
|
|
64
|
+
const {
|
|
65
|
+
top: childrenTop,
|
|
66
|
+
bottom: childrenBottom,
|
|
67
|
+
left: childrenLeft,
|
|
68
|
+
right: childrenRight,
|
|
69
|
+
width: childrenWidth
|
|
70
|
+
} = childrenRect;
|
|
71
|
+
const { width: popupWidth, height: popupHeight } = popupStructuredRef;
|
|
72
|
+
const popupHalfWidthWithArrow = popupWidth / 2 - ARROW_WIDTH;
|
|
73
|
+
const popupHalfHeightWithArrow = popupHeight / 2 - ARROW_WIDTH;
|
|
74
|
+
if (position === "top" || position === "bottom") {
|
|
75
|
+
const popupOverflowRight = childrenRight - childrenWidth / 2 + popupWidth / 2;
|
|
76
|
+
const popupOverflowLeft = childrenLeft + childrenWidth / 2 - parentLeft - popupWidth / 2;
|
|
77
|
+
if (popupOverflowRight > parentRight) {
|
|
78
|
+
if (Math.abs(popupOverflowRight - parentRight) > popupHalfWidthWithArrow) {
|
|
79
|
+
return -popupHalfWidthWithArrow;
|
|
80
|
+
}
|
|
81
|
+
return parentRight - popupOverflowRight;
|
|
82
|
+
}
|
|
83
|
+
if (popupOverflowLeft < 0) {
|
|
84
|
+
if (Math.abs(popupOverflowLeft) > popupHalfWidthWithArrow) {
|
|
85
|
+
return popupHalfWidthWithArrow;
|
|
86
|
+
}
|
|
87
|
+
return Math.abs(popupOverflowLeft);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (position === "left" || position === "right") {
|
|
91
|
+
const popupOverflowTop = childrenTop - parentTop - popupHeight / 2;
|
|
92
|
+
if (popupOverflowTop < 0) {
|
|
93
|
+
if (Math.abs(childrenTop - parentTop - popupHalfHeightWithArrow) > popupHalfHeightWithArrow) {
|
|
94
|
+
return popupHalfHeightWithArrow;
|
|
95
|
+
}
|
|
96
|
+
return Math.abs(popupOverflowTop);
|
|
97
|
+
}
|
|
98
|
+
if (childrenBottom + popupHeight > window.innerHeight) {
|
|
99
|
+
return -popupHalfHeightWithArrow;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return 0;
|
|
103
|
+
};
|
|
104
|
+
const computePositions = ({
|
|
105
|
+
placement,
|
|
106
|
+
childrenRef,
|
|
107
|
+
popupRef,
|
|
108
|
+
popupPortalTarget
|
|
109
|
+
}) => {
|
|
110
|
+
const childrenRect = childrenRef.current.getBoundingClientRect();
|
|
111
|
+
const offsetParent = findOffsetParent(childrenRef);
|
|
112
|
+
const offsetParentRect = offsetParent?.getBoundingClientRect() ?? {
|
|
113
|
+
top: 0,
|
|
114
|
+
left: 0,
|
|
115
|
+
right: 0
|
|
116
|
+
};
|
|
117
|
+
const popupStructuredRef = popupRef.current.getBoundingClientRect();
|
|
118
|
+
const placementBasedOnWindowSize = placement === "auto" ? computePlacement({
|
|
119
|
+
childrenStructuredRef: childrenRect,
|
|
120
|
+
popupStructuredRef,
|
|
121
|
+
offsetParentRect,
|
|
122
|
+
popupPortalTarget,
|
|
123
|
+
offsetParent
|
|
124
|
+
}) : placement;
|
|
125
|
+
const {
|
|
126
|
+
top: childrenTop,
|
|
127
|
+
left: childrenLeft,
|
|
128
|
+
right: childrenRight,
|
|
129
|
+
width: childrenWidth,
|
|
130
|
+
height: childrenHeight
|
|
131
|
+
} = childrenRect;
|
|
132
|
+
const { top: parentTop, left: parentLeft } = offsetParentRect;
|
|
133
|
+
const { width: popupWidth, height: popupHeight } = popupStructuredRef;
|
|
134
|
+
const isPopupPortalTargetBody = popupPortalTarget === document.body || offsetParent === document.body;
|
|
135
|
+
const scrollTopValue = isPopupPortalTargetBody ? document.documentElement.scrollTop : offsetParent.scrollTop;
|
|
136
|
+
const overloadedChildrenLeft = isPopupPortalTargetBody ? childrenLeft : childrenLeft - parentLeft;
|
|
137
|
+
const overloadedChildrenTop = isPopupPortalTargetBody ? childrenTop : childrenTop - parentTop;
|
|
138
|
+
const overloadedChildrenRight = isPopupPortalTargetBody ? childrenRight : childrenLeft - parentLeft + childrenWidth;
|
|
139
|
+
const popupOverflow = getPopupOverflowFromParent(
|
|
140
|
+
placementBasedOnWindowSize,
|
|
141
|
+
offsetParentRect,
|
|
142
|
+
childrenRect,
|
|
143
|
+
popupStructuredRef
|
|
144
|
+
);
|
|
145
|
+
switch (placementBasedOnWindowSize) {
|
|
146
|
+
case "bottom": {
|
|
147
|
+
const positionX = overloadedChildrenLeft + childrenWidth / 2 - popupWidth / 2;
|
|
148
|
+
const positionY = overloadedChildrenTop + scrollTopValue + childrenHeight + ARROW_WIDTH + SPACE;
|
|
149
|
+
return {
|
|
150
|
+
arrowLeft: popupWidth / 2 + popupOverflow * -1,
|
|
151
|
+
arrowTop: -ARROW_WIDTH - 5,
|
|
152
|
+
arrowTransform: "",
|
|
153
|
+
placement: "bottom",
|
|
154
|
+
rotate: 180,
|
|
155
|
+
popupInitialPosition: `translate3d(${positionX + popupOverflow}px, ${positionY - TOTAL_USED_SPACE}px, 0)`,
|
|
156
|
+
popupPosition: `translate3d(${positionX + popupOverflow}px, ${positionY}px, 0)`
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
case "left": {
|
|
160
|
+
const positionX = overloadedChildrenLeft - popupWidth - ARROW_WIDTH - SPACE * 2;
|
|
161
|
+
const positionY = overloadedChildrenTop + scrollTopValue - popupHeight / 2 + childrenHeight / 2;
|
|
162
|
+
return {
|
|
163
|
+
arrowLeft: popupWidth + ARROW_WIDTH + 5,
|
|
164
|
+
arrowTop: popupHeight / 2 + popupOverflow * -1,
|
|
165
|
+
arrowTransform: "translate(-50%, -50%)",
|
|
166
|
+
placement: "left",
|
|
167
|
+
rotate: -90,
|
|
168
|
+
popupInitialPosition: `translate3d(${positionX + TOTAL_USED_SPACE}px, ${positionY + popupOverflow}px, 0)`,
|
|
169
|
+
popupPosition: `translate3d(${positionX}px, ${positionY + popupOverflow}px, 0)`
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
case "right": {
|
|
173
|
+
const positionX = overloadedChildrenRight + ARROW_WIDTH + SPACE * 2;
|
|
174
|
+
const positionY = overloadedChildrenTop + scrollTopValue - popupHeight / 2 + childrenHeight / 2;
|
|
175
|
+
return {
|
|
176
|
+
arrowLeft: -ARROW_WIDTH - 5,
|
|
177
|
+
arrowTop: popupHeight / 2 + popupOverflow * -1,
|
|
178
|
+
arrowTransform: "translate(50%, -50%)",
|
|
179
|
+
placement: "right",
|
|
180
|
+
rotate: 90,
|
|
181
|
+
popupInitialPosition: `translate3d(${positionX - TOTAL_USED_SPACE}px, ${positionY + popupOverflow}px, 0)`,
|
|
182
|
+
popupPosition: `translate3d(${positionX}px, ${positionY + popupOverflow}px, 0)`
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
default: {
|
|
186
|
+
const positionX = overloadedChildrenLeft + childrenWidth / 2 - popupWidth / 2;
|
|
187
|
+
const positionY = overloadedChildrenTop + scrollTopValue - popupHeight - ARROW_WIDTH - SPACE;
|
|
188
|
+
return {
|
|
189
|
+
arrowLeft: popupWidth / 2 + popupOverflow * -1,
|
|
190
|
+
arrowTop: popupHeight - 1,
|
|
191
|
+
arrowTransform: "",
|
|
192
|
+
placement: "top",
|
|
193
|
+
rotate: 0,
|
|
194
|
+
popupInitialPosition: `translate3d(${positionX + popupOverflow}px, ${positionY + TOTAL_USED_SPACE}px, 0)`,
|
|
195
|
+
popupPosition: `translate3d(${positionX + popupOverflow}px, ${positionY}px, 0)`
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
export {
|
|
201
|
+
ARROW_WIDTH,
|
|
202
|
+
DEFAULT_POSITIONS,
|
|
203
|
+
computePositions
|
|
204
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { HTMLAttributes, KeyboardEventHandler, ReactNode, Ref, RefObject } from 'react';
|
|
2
|
+
import type { PopupPlacement } from './helpers';
|
|
3
|
+
type PopupProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Id is automatically generated if not set. It is used for associating popup wrapper with popup portal.
|
|
6
|
+
*/
|
|
7
|
+
id?: string;
|
|
8
|
+
children: ReactNode | ((renderProps: {
|
|
9
|
+
className?: string;
|
|
10
|
+
onBlur: () => void;
|
|
11
|
+
onFocus: () => void;
|
|
12
|
+
onPointerEnter: () => void;
|
|
13
|
+
onPointerLeave: () => void;
|
|
14
|
+
ref: RefObject<HTMLDivElement>;
|
|
15
|
+
}) => ReactNode);
|
|
16
|
+
maxWidth?: number | string;
|
|
17
|
+
/**
|
|
18
|
+
* `auto` placement will change the position of the popup if it doesn't fit in the viewport.
|
|
19
|
+
*/
|
|
20
|
+
placement?: PopupPlacement;
|
|
21
|
+
/**
|
|
22
|
+
* Content of the popup, preferably text inside.
|
|
23
|
+
*/
|
|
24
|
+
text?: ReactNode;
|
|
25
|
+
className?: string;
|
|
26
|
+
/**
|
|
27
|
+
* It will add `width: 100%` to the popup container.
|
|
28
|
+
*/
|
|
29
|
+
containerFullWidth?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* It will force display popup. This can be useful if you need to always display the popup without hover needed.
|
|
32
|
+
*/
|
|
33
|
+
visible?: boolean;
|
|
34
|
+
innerRef?: Ref<HTMLDivElement | null>;
|
|
35
|
+
role?: string;
|
|
36
|
+
'data-testid'?: string;
|
|
37
|
+
hasArrow?: boolean;
|
|
38
|
+
onClose?: () => void;
|
|
39
|
+
tabIndex?: number;
|
|
40
|
+
onKeyDown?: KeyboardEventHandler;
|
|
41
|
+
'aria-haspopup'?: HTMLAttributes<HTMLDivElement>['aria-haspopup'];
|
|
42
|
+
hideOnClickOutside?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* If you set debounceTime to false, the popup will not debounce the hover event and will be displayed instantly.
|
|
45
|
+
* If set to 0 it will disable debounce.
|
|
46
|
+
*/
|
|
47
|
+
debounceDelay?: number;
|
|
48
|
+
/**
|
|
49
|
+
* If you set a max height keep in mind that the animation is disabled, or it will not work properly on some browsers.
|
|
50
|
+
*/
|
|
51
|
+
maxHeight?: string | number;
|
|
52
|
+
/**
|
|
53
|
+
* Will remove the animation on the popup if set to false.
|
|
54
|
+
*/
|
|
55
|
+
disableAnimation?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* By default, the portal target is children container or document.body if children is a function. You can override this
|
|
58
|
+
* behavior by setting a portalTarget prop.
|
|
59
|
+
*/
|
|
60
|
+
portalTarget?: HTMLElement;
|
|
61
|
+
/**
|
|
62
|
+
* If you set this to true, the popup will be rendered in the DOM only when it is visible.
|
|
63
|
+
* When set to false, the popup will always be rendered in the DOM. By default this value is set to `true`, if for some
|
|
64
|
+
* reason you need to disable it, you can set it to `false`.
|
|
65
|
+
*/
|
|
66
|
+
dynamicDomRendering?: boolean;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* @experimental This component is experimental and may be subject to breaking changes in the future.
|
|
70
|
+
*/
|
|
71
|
+
export declare const Popup: import("react").ForwardRefExoticComponent<PopupProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { jsx, Fragment, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
|
+
import styled from "@emotion/styled";
|
|
4
|
+
import { forwardRef, useRef, useImperativeHandle, useMemo, useState, useId, useCallback, useEffect } from "react";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
import { animation, exitAnimation } from "./animations.js";
|
|
7
|
+
import { ARROW_WIDTH, DEFAULT_POSITIONS, computePositions } from "./helpers.js";
|
|
8
|
+
const DEFAULT_ANIMATION_DURATION = 230;
|
|
9
|
+
const DEFAULT_DEBOUNCE_DURATION = 200;
|
|
10
|
+
function noop() {
|
|
11
|
+
}
|
|
12
|
+
const StyledPopup = styled("div", {
|
|
13
|
+
shouldForwardProp: (prop) => ![
|
|
14
|
+
"maxWidth",
|
|
15
|
+
"positions",
|
|
16
|
+
"reverseAnimation",
|
|
17
|
+
"maxHeight",
|
|
18
|
+
"animationDuration",
|
|
19
|
+
"isDialog"
|
|
20
|
+
].includes(prop)
|
|
21
|
+
})`
|
|
22
|
+
background: ${({ theme }) => theme.colors.neutral.backgroundStronger};
|
|
23
|
+
color: ${({ theme }) => theme.colors.neutral.textStronger};
|
|
24
|
+
border-radius: ${({ theme }) => theme.radii.default};
|
|
25
|
+
padding: ${({ theme }) => `${theme.space["0.5"]} ${theme.space["1"]}`};
|
|
26
|
+
text-align: center;
|
|
27
|
+
position: absolute;
|
|
28
|
+
max-width: ${({ maxWidth }) => typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth};
|
|
29
|
+
max-height: ${({ maxHeight }) => typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight};
|
|
30
|
+
overflow: ${({ maxHeight }) => maxHeight ? "auto" : void 0};
|
|
31
|
+
overflow-wrap: break-word;
|
|
32
|
+
font-size: 0.8rem;
|
|
33
|
+
inset: 0 auto auto 0;
|
|
34
|
+
top: 0;
|
|
35
|
+
left: 0;
|
|
36
|
+
opacity: 0;
|
|
37
|
+
z-index: 1;
|
|
38
|
+
transform: ${({ positions }) => positions.popupPosition};
|
|
39
|
+
animation: ${({
|
|
40
|
+
positions,
|
|
41
|
+
reverseAnimation,
|
|
42
|
+
maxHeight,
|
|
43
|
+
animationDuration
|
|
44
|
+
}) => maxHeight || animationDuration === 0 || animationDuration === void 0 ? void 0 : css`
|
|
45
|
+
${animationDuration}ms ${!reverseAnimation ? animation(positions) : exitAnimation(positions)} forwards
|
|
46
|
+
`};
|
|
47
|
+
|
|
48
|
+
&[data-has-arrow='true'] {
|
|
49
|
+
&::after {
|
|
50
|
+
content: ' ';
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: ${({ positions }) => positions.arrowTop}px;
|
|
53
|
+
left: ${({ positions }) => positions.arrowLeft}px;
|
|
54
|
+
transform: ${({ positions }) => positions.arrowTransform}
|
|
55
|
+
rotate(${({ positions }) => positions.rotate}deg);
|
|
56
|
+
margin-left: -${ARROW_WIDTH}px;
|
|
57
|
+
border-width: ${ARROW_WIDTH}px;
|
|
58
|
+
border-style: solid;
|
|
59
|
+
border-color: ${({ theme }) => theme.colors.neutral.backgroundStronger}
|
|
60
|
+
transparent transparent transparent;
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&[data-visible-in-dom='false'] {
|
|
66
|
+
display: none;
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
const StyledChildrenContainer = styled.div`
|
|
70
|
+
display: inherit;
|
|
71
|
+
|
|
72
|
+
&[data-container-full-width='true'] {
|
|
73
|
+
width: 100%;
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
const Popup = forwardRef(
|
|
77
|
+
({
|
|
78
|
+
children,
|
|
79
|
+
text = "",
|
|
80
|
+
placement = "auto",
|
|
81
|
+
id,
|
|
82
|
+
className,
|
|
83
|
+
containerFullWidth,
|
|
84
|
+
maxWidth = 232,
|
|
85
|
+
maxHeight,
|
|
86
|
+
visible,
|
|
87
|
+
innerRef,
|
|
88
|
+
role = "popup",
|
|
89
|
+
"data-testid": dataTestId,
|
|
90
|
+
hasArrow = true,
|
|
91
|
+
onClose,
|
|
92
|
+
tabIndex = 0,
|
|
93
|
+
onKeyDown,
|
|
94
|
+
"aria-haspopup": ariaHasPopup,
|
|
95
|
+
hideOnClickOutside = false,
|
|
96
|
+
debounceDelay = DEFAULT_DEBOUNCE_DURATION,
|
|
97
|
+
disableAnimation = false,
|
|
98
|
+
portalTarget,
|
|
99
|
+
dynamicDomRendering = true
|
|
100
|
+
}, ref) => {
|
|
101
|
+
const childrenRef = useRef(null);
|
|
102
|
+
useImperativeHandle(innerRef, () => childrenRef.current);
|
|
103
|
+
const innerPopupRef = useRef(null);
|
|
104
|
+
useImperativeHandle(ref, () => innerPopupRef.current);
|
|
105
|
+
const timer = useRef();
|
|
106
|
+
const popupPortalTarget = useMemo(() => {
|
|
107
|
+
if (portalTarget)
|
|
108
|
+
return portalTarget;
|
|
109
|
+
if (role === "dialog") {
|
|
110
|
+
if (childrenRef.current)
|
|
111
|
+
return childrenRef.current;
|
|
112
|
+
if (typeof window !== "undefined")
|
|
113
|
+
return document.body;
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
if (typeof window !== "undefined") {
|
|
117
|
+
return document.body;
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
}, [portalTarget, role, childrenRef.current]);
|
|
121
|
+
const animationDuration = disableAnimation || maxHeight ? 0 : DEFAULT_ANIMATION_DURATION;
|
|
122
|
+
const debounceTimer = useRef();
|
|
123
|
+
const [visibleInDom, setVisibleInDom] = useState(false);
|
|
124
|
+
const [reverseAnimation, setReverseAnimation] = useState(false);
|
|
125
|
+
const [positions, setPositions] = useState({
|
|
126
|
+
...DEFAULT_POSITIONS
|
|
127
|
+
});
|
|
128
|
+
const uniqueId = useId();
|
|
129
|
+
const generatedId = id ?? uniqueId;
|
|
130
|
+
const isControlled = visible !== void 0;
|
|
131
|
+
const generatePopupPositions = useCallback(() => {
|
|
132
|
+
if (childrenRef.current && innerPopupRef.current) {
|
|
133
|
+
setPositions(
|
|
134
|
+
computePositions({
|
|
135
|
+
childrenRef,
|
|
136
|
+
placement,
|
|
137
|
+
popupRef: innerPopupRef,
|
|
138
|
+
popupPortalTarget
|
|
139
|
+
})
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}, [placement, popupPortalTarget]);
|
|
143
|
+
const onWindowChangeDetected = useCallback(() => {
|
|
144
|
+
if (innerPopupRef.current) {
|
|
145
|
+
innerPopupRef.current.style.animation = "none";
|
|
146
|
+
}
|
|
147
|
+
generatePopupPositions();
|
|
148
|
+
}, [generatePopupPositions, innerPopupRef]);
|
|
149
|
+
const unmountPopupFromDom = useCallback(() => {
|
|
150
|
+
setVisibleInDom(false);
|
|
151
|
+
setReverseAnimation(false);
|
|
152
|
+
window.removeEventListener("scroll", onWindowChangeDetected, true);
|
|
153
|
+
}, [onWindowChangeDetected]);
|
|
154
|
+
const closePopup = useCallback(() => {
|
|
155
|
+
debounceTimer.current = setTimeout(
|
|
156
|
+
() => {
|
|
157
|
+
setReverseAnimation(true);
|
|
158
|
+
timer.current = setTimeout(() => {
|
|
159
|
+
unmountPopupFromDom();
|
|
160
|
+
onClose?.();
|
|
161
|
+
}, animationDuration);
|
|
162
|
+
},
|
|
163
|
+
debounceDelay && !disableAnimation ? debounceDelay : 0
|
|
164
|
+
);
|
|
165
|
+
}, [
|
|
166
|
+
animationDuration,
|
|
167
|
+
disableAnimation,
|
|
168
|
+
debounceDelay,
|
|
169
|
+
onClose,
|
|
170
|
+
unmountPopupFromDom
|
|
171
|
+
]);
|
|
172
|
+
const onPointerEvent = useCallback(
|
|
173
|
+
(isVisible) => () => {
|
|
174
|
+
if (!visible && debounceDelay > 0 && debounceTimer.current) {
|
|
175
|
+
clearTimeout(debounceTimer.current);
|
|
176
|
+
debounceTimer.current = void 0;
|
|
177
|
+
}
|
|
178
|
+
if (!isVisible && innerPopupRef.current && !debounceTimer.current) {
|
|
179
|
+
closePopup();
|
|
180
|
+
} else if (isVisible) {
|
|
181
|
+
if (timer.current) {
|
|
182
|
+
setReverseAnimation(false);
|
|
183
|
+
clearTimeout(timer.current);
|
|
184
|
+
timer.current = void 0;
|
|
185
|
+
}
|
|
186
|
+
if (debounceTimer.current) {
|
|
187
|
+
clearTimeout(debounceTimer.current);
|
|
188
|
+
debounceTimer.current = void 0;
|
|
189
|
+
}
|
|
190
|
+
if (debounceDelay > 0) {
|
|
191
|
+
debounceTimer.current = setTimeout(() => {
|
|
192
|
+
setVisibleInDom(true);
|
|
193
|
+
}, debounceDelay);
|
|
194
|
+
} else {
|
|
195
|
+
setVisibleInDom(true);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
[closePopup, debounceDelay, visible]
|
|
200
|
+
);
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
if (visibleInDom) {
|
|
203
|
+
generatePopupPositions();
|
|
204
|
+
if (popupPortalTarget === document.body) {
|
|
205
|
+
window.addEventListener("scroll", onWindowChangeDetected, true);
|
|
206
|
+
}
|
|
207
|
+
window.addEventListener("resize", onWindowChangeDetected, true);
|
|
208
|
+
}
|
|
209
|
+
return () => {
|
|
210
|
+
window.removeEventListener("scroll", onWindowChangeDetected, true);
|
|
211
|
+
window.removeEventListener("resize", onWindowChangeDetected, true);
|
|
212
|
+
if (timer.current) {
|
|
213
|
+
clearTimeout(timer.current);
|
|
214
|
+
timer.current = void 0;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
}, [
|
|
218
|
+
generatePopupPositions,
|
|
219
|
+
onWindowChangeDetected,
|
|
220
|
+
visibleInDom,
|
|
221
|
+
maxWidth,
|
|
222
|
+
popupPortalTarget
|
|
223
|
+
]);
|
|
224
|
+
useEffect(
|
|
225
|
+
() => {
|
|
226
|
+
if (visibleInDom && innerPopupRef.current) {
|
|
227
|
+
innerPopupRef.current.style.opacity = "1";
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
231
|
+
[positions]
|
|
232
|
+
);
|
|
233
|
+
useEffect(() => {
|
|
234
|
+
if (isControlled) {
|
|
235
|
+
onPointerEvent(visible)();
|
|
236
|
+
}
|
|
237
|
+
}, [isControlled, onPointerEvent, visible]);
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
const handleEscPress = (event) => {
|
|
240
|
+
if (event.key === "Escape") {
|
|
241
|
+
event.preventDefault();
|
|
242
|
+
event.stopPropagation();
|
|
243
|
+
closePopup();
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
const handleClickOutside = (event) => {
|
|
247
|
+
const popupCurrent = innerPopupRef.current;
|
|
248
|
+
const childrenCurrent = childrenRef.current;
|
|
249
|
+
if (popupCurrent && hideOnClickOutside && !event.defaultPrevented) {
|
|
250
|
+
if (event.target && event.target !== popupCurrent && event.target !== childrenCurrent && !childrenCurrent?.contains(event.target) && !popupCurrent.contains(event.target)) {
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
event.stopPropagation();
|
|
253
|
+
closePopup();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
if (visibleInDom) {
|
|
258
|
+
document.body.addEventListener("keyup", handleEscPress);
|
|
259
|
+
document.body.addEventListener("click", handleClickOutside);
|
|
260
|
+
}
|
|
261
|
+
return () => {
|
|
262
|
+
document.body.removeEventListener("keyup", handleEscPress);
|
|
263
|
+
document.body.removeEventListener("click", handleClickOutside);
|
|
264
|
+
};
|
|
265
|
+
}, [
|
|
266
|
+
closePopup,
|
|
267
|
+
visibleInDom,
|
|
268
|
+
innerPopupRef,
|
|
269
|
+
childrenRef,
|
|
270
|
+
hideOnClickOutside
|
|
271
|
+
]);
|
|
272
|
+
const handleFocusTrap = useCallback((event) => {
|
|
273
|
+
const isTabPressed = event.key === "Tab";
|
|
274
|
+
if (!isTabPressed) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
event.stopPropagation();
|
|
278
|
+
const focusableEls = innerPopupRef.current?.querySelectorAll(
|
|
279
|
+
"a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled])"
|
|
280
|
+
) ?? [];
|
|
281
|
+
if (focusableEls.length === 0) {
|
|
282
|
+
event.preventDefault();
|
|
283
|
+
}
|
|
284
|
+
const firstFocusableEl = focusableEls[0];
|
|
285
|
+
const lastFocusableEl = focusableEls[focusableEls.length - 1];
|
|
286
|
+
if (event.shiftKey) {
|
|
287
|
+
if (document.activeElement === firstFocusableEl || document.activeElement === innerPopupRef.current) {
|
|
288
|
+
lastFocusableEl.focus();
|
|
289
|
+
event.preventDefault();
|
|
290
|
+
}
|
|
291
|
+
} else if (document.activeElement === lastFocusableEl || document.activeElement === innerPopupRef.current) {
|
|
292
|
+
firstFocusableEl.focus();
|
|
293
|
+
event.preventDefault();
|
|
294
|
+
}
|
|
295
|
+
}, []);
|
|
296
|
+
const renderChildren = useCallback(() => {
|
|
297
|
+
if (typeof children === "function") {
|
|
298
|
+
return children({
|
|
299
|
+
onBlur: !isControlled ? onPointerEvent(false) : noop,
|
|
300
|
+
onFocus: !isControlled ? onPointerEvent(true) : noop,
|
|
301
|
+
onPointerEnter: !isControlled ? onPointerEvent(true) : noop,
|
|
302
|
+
onPointerLeave: !isControlled ? onPointerEvent(false) : noop,
|
|
303
|
+
ref: childrenRef
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return /* @__PURE__ */ jsx(
|
|
307
|
+
StyledChildrenContainer,
|
|
308
|
+
{
|
|
309
|
+
"aria-describedby": generatedId,
|
|
310
|
+
"aria-controls": generatedId,
|
|
311
|
+
onBlur: !isControlled ? onPointerEvent(false) : noop,
|
|
312
|
+
onFocus: !isControlled ? onPointerEvent(true) : noop,
|
|
313
|
+
onPointerEnter: !isControlled ? onPointerEvent(true) : noop,
|
|
314
|
+
onPointerLeave: !isControlled ? onPointerEvent(false) : noop,
|
|
315
|
+
ref: childrenRef,
|
|
316
|
+
tabIndex,
|
|
317
|
+
onKeyDown: (event) => {
|
|
318
|
+
onKeyDown?.(event);
|
|
319
|
+
},
|
|
320
|
+
"data-container-full-width": containerFullWidth,
|
|
321
|
+
"aria-haspopup": ariaHasPopup,
|
|
322
|
+
children
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
}, [
|
|
326
|
+
ariaHasPopup,
|
|
327
|
+
children,
|
|
328
|
+
containerFullWidth,
|
|
329
|
+
generatedId,
|
|
330
|
+
isControlled,
|
|
331
|
+
onKeyDown,
|
|
332
|
+
onPointerEvent,
|
|
333
|
+
tabIndex
|
|
334
|
+
]);
|
|
335
|
+
const shouldRender = useMemo(() => {
|
|
336
|
+
if (!dynamicDomRendering) {
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
if (dynamicDomRendering && visibleInDom) {
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
return false;
|
|
343
|
+
}, [dynamicDomRendering, visibleInDom]);
|
|
344
|
+
if (!text) {
|
|
345
|
+
if (typeof children === "function")
|
|
346
|
+
return null;
|
|
347
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
348
|
+
}
|
|
349
|
+
const stopClickPropagation = (event) => {
|
|
350
|
+
event.nativeEvent.stopImmediatePropagation();
|
|
351
|
+
};
|
|
352
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
353
|
+
renderChildren(),
|
|
354
|
+
shouldRender ? createPortal(
|
|
355
|
+
/* @__PURE__ */ jsx(
|
|
356
|
+
StyledPopup,
|
|
357
|
+
{
|
|
358
|
+
ref: innerPopupRef,
|
|
359
|
+
positions,
|
|
360
|
+
maxWidth,
|
|
361
|
+
maxHeight,
|
|
362
|
+
role,
|
|
363
|
+
id: generatedId,
|
|
364
|
+
className,
|
|
365
|
+
reverseAnimation,
|
|
366
|
+
"data-testid": dataTestId,
|
|
367
|
+
"data-has-arrow": hasArrow,
|
|
368
|
+
onClick: stopClickPropagation,
|
|
369
|
+
onPointerEnter: !isControlled ? onPointerEvent(true) : noop,
|
|
370
|
+
onPointerLeave: !isControlled ? onPointerEvent(false) : noop,
|
|
371
|
+
animationDuration,
|
|
372
|
+
onKeyDown: role === "dialog" ? handleFocusTrap : void 0,
|
|
373
|
+
isDialog: role === "dialog",
|
|
374
|
+
"data-visible-in-dom": !dynamicDomRendering ? visibleInDom : void 0,
|
|
375
|
+
children: text
|
|
376
|
+
}
|
|
377
|
+
),
|
|
378
|
+
popupPortalTarget
|
|
379
|
+
) : null
|
|
380
|
+
] });
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
export {
|
|
384
|
+
Popup
|
|
385
|
+
};
|