@ultraviolet/ui 1.51.0 → 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 -3693
- 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 +23 -13
- 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 -116
- 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 -144
- package/dist/src/components/Popup/helpers.js +0 -252
- package/dist/src/components/Popup/index.js +0 -363
- 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 -128
- 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,90 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactElement, ReactNode, Ref } from 'react';
|
|
2
|
+
export type DisclosureProps = {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
};
|
|
5
|
+
type DisclosureElement = ((disclosure: DisclosureProps) => ReactElement<ButtonHTMLAttributes<HTMLButtonElement>>) | (ReactElement<ButtonHTMLAttributes<HTMLButtonElement>> & {
|
|
6
|
+
ref?: Ref<HTMLButtonElement>;
|
|
7
|
+
});
|
|
8
|
+
type ChildMenuProps = {
|
|
9
|
+
toggle: () => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A menu is a widget that offers a list of choices to the user, such as a set of actions or functions.
|
|
13
|
+
* A menu is usually opened, or made visible, by activating a menu button, choosing an item in a menu that opens a
|
|
14
|
+
* sub menu, or by invoking a command, such as `Shift + F10` on Windows, that opens a context specific menu.
|
|
15
|
+
* When a user activates a choice in a menu, the menu usually closes unless the choice opened a submenu.
|
|
16
|
+
*/
|
|
17
|
+
export declare const MenuV2: import("react").ForwardRefExoticComponent<{
|
|
18
|
+
id?: string | undefined;
|
|
19
|
+
ariaLabel?: string | undefined;
|
|
20
|
+
children?: ReactNode | (({ toggle }: ChildMenuProps) => ReactNode);
|
|
21
|
+
className?: string | undefined;
|
|
22
|
+
disclosure: DisclosureElement;
|
|
23
|
+
hasArrow?: boolean | undefined;
|
|
24
|
+
visible?: boolean | undefined;
|
|
25
|
+
'data-testid'?: string | undefined;
|
|
26
|
+
maxHeight?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated: use `size` instead
|
|
29
|
+
*/
|
|
30
|
+
maxWidth?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* By default, the portal target is children container or document.body if children is a function. You can override this
|
|
33
|
+
* behavior by setting a portalTarget prop.
|
|
34
|
+
*/
|
|
35
|
+
portalTarget?: HTMLElement | undefined;
|
|
36
|
+
size?: "large" | "small" | "medium" | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The behavior of the menu when it is opened. If set to `click`, the menu will open when the user clicks on the disclosure.
|
|
39
|
+
* If set to `hover`, the menu will open when the user hovers over the disclosure.
|
|
40
|
+
*/
|
|
41
|
+
triggerMethod?: "click" | "hover" | undefined;
|
|
42
|
+
} & Pick<{
|
|
43
|
+
id?: string | undefined;
|
|
44
|
+
children: ReactNode | ((renderProps: {
|
|
45
|
+
className?: string | undefined;
|
|
46
|
+
onBlur: () => void;
|
|
47
|
+
onFocus: () => void;
|
|
48
|
+
onPointerEnter: () => void;
|
|
49
|
+
onPointerLeave: () => void;
|
|
50
|
+
ref: import("react").RefObject<HTMLDivElement>;
|
|
51
|
+
}) => ReactNode);
|
|
52
|
+
maxWidth?: string | number | undefined;
|
|
53
|
+
placement?: import("../Popup/helpers").PopupPlacement | undefined;
|
|
54
|
+
text?: ReactNode;
|
|
55
|
+
className?: string | undefined;
|
|
56
|
+
containerFullWidth?: boolean | undefined;
|
|
57
|
+
visible?: boolean | undefined;
|
|
58
|
+
innerRef?: Ref<HTMLDivElement | null> | undefined;
|
|
59
|
+
role?: string | undefined;
|
|
60
|
+
'data-testid'?: string | undefined;
|
|
61
|
+
hasArrow?: boolean | undefined;
|
|
62
|
+
onClose?: (() => void) | undefined;
|
|
63
|
+
tabIndex?: number | undefined;
|
|
64
|
+
onKeyDown?: import("react").KeyboardEventHandler | undefined;
|
|
65
|
+
'aria-haspopup'?: boolean | "menu" | "dialog" | "grid" | "listbox" | "tree" | "false" | "true" | undefined;
|
|
66
|
+
hideOnClickOutside?: boolean | undefined;
|
|
67
|
+
debounceDelay?: number | undefined;
|
|
68
|
+
maxHeight?: string | number | undefined;
|
|
69
|
+
disableAnimation?: boolean | undefined;
|
|
70
|
+
portalTarget?: HTMLElement | undefined;
|
|
71
|
+
dynamicDomRendering?: boolean | undefined;
|
|
72
|
+
} & import("react").RefAttributes<HTMLDivElement>, "placement" | "dynamicDomRendering"> & import("react").RefAttributes<HTMLButtonElement>> & {
|
|
73
|
+
Item: import("react").ForwardRefExoticComponent<{
|
|
74
|
+
href?: string | undefined;
|
|
75
|
+
disabled?: boolean | undefined;
|
|
76
|
+
tooltip?: string | undefined;
|
|
77
|
+
className?: string | undefined;
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
onClick?: import("react").MouseEventHandler<HTMLElement> | undefined;
|
|
80
|
+
borderless?: boolean | undefined;
|
|
81
|
+
sentiment?: ("primary" | "neutral" | "danger") | undefined;
|
|
82
|
+
active?: boolean | undefined;
|
|
83
|
+
'data-testid'?: string | undefined;
|
|
84
|
+
} & import("react").RefAttributes<HTMLElement>>;
|
|
85
|
+
Group: ({ label, children }: {
|
|
86
|
+
label: string;
|
|
87
|
+
children: ReactNode;
|
|
88
|
+
}) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
89
|
+
};
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { forwardRef, useState, useRef, useId, isValidElement, useImperativeHandle, cloneElement } from "react";
|
|
4
|
+
import { Popup } from "../Popup/index.js";
|
|
5
|
+
import { Stack } from "../Stack/index.js";
|
|
6
|
+
import { Group } from "./Group.js";
|
|
7
|
+
import Item from "./Item.js";
|
|
8
|
+
const SIZES = {
|
|
9
|
+
small: "180px",
|
|
10
|
+
medium: "280px",
|
|
11
|
+
large: "380px"
|
|
12
|
+
};
|
|
13
|
+
const StyledPopup = styled(Popup, {
|
|
14
|
+
shouldForwardProp: (prop) => !["size"].includes(prop)
|
|
15
|
+
})`
|
|
16
|
+
background-color: ${({ theme }) => theme.colors.neutral.background};
|
|
17
|
+
box-shadow: ${({ theme }) => theme.shadows.menu};
|
|
18
|
+
padding: 0;
|
|
19
|
+
|
|
20
|
+
&[data-has-arrow='true'] {
|
|
21
|
+
&::after {
|
|
22
|
+
border-color: ${({ theme }) => theme.colors.neutral.background}
|
|
23
|
+
transparent transparent transparent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
width: ${({ size }) => SIZES[size]};
|
|
28
|
+
max-width: none;
|
|
29
|
+
padding: ${({ theme }) => `${theme.space["0.25"]} 0`};
|
|
30
|
+
`;
|
|
31
|
+
const MenuList = styled(Stack)`
|
|
32
|
+
overflow-y: auto;
|
|
33
|
+
overflow-x: hidden;
|
|
34
|
+
&:after,
|
|
35
|
+
&:before {
|
|
36
|
+
border: solid transparent;
|
|
37
|
+
border-width: 9px;
|
|
38
|
+
content: ' ';
|
|
39
|
+
height: 0;
|
|
40
|
+
width: 0;
|
|
41
|
+
position: absolute;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:after {
|
|
46
|
+
border-color: transparent;
|
|
47
|
+
}
|
|
48
|
+
&:before {
|
|
49
|
+
border-color: transparent;
|
|
50
|
+
}
|
|
51
|
+
background-color: ${({ theme }) => theme.colors.neutral.backgroundWeakElevated};
|
|
52
|
+
color: ${({ theme }) => theme.colors.neutral.text};
|
|
53
|
+
border-radius: ${({ theme }) => theme.radii.default};
|
|
54
|
+
position: relative;
|
|
55
|
+
`;
|
|
56
|
+
const FwdMenu = forwardRef(
|
|
57
|
+
({
|
|
58
|
+
id,
|
|
59
|
+
ariaLabel = "Menu",
|
|
60
|
+
children,
|
|
61
|
+
disclosure,
|
|
62
|
+
hasArrow = false,
|
|
63
|
+
placement = "bottom",
|
|
64
|
+
visible = false,
|
|
65
|
+
className,
|
|
66
|
+
"data-testid": dataTestId,
|
|
67
|
+
maxHeight,
|
|
68
|
+
maxWidth,
|
|
69
|
+
portalTarget,
|
|
70
|
+
size = "small",
|
|
71
|
+
triggerMethod = "click",
|
|
72
|
+
dynamicDomRendering
|
|
73
|
+
}, ref) => {
|
|
74
|
+
const [isVisible, setIsVisible] = useState(visible);
|
|
75
|
+
const popupRef = useRef(null);
|
|
76
|
+
const disclosureRef = useRef(null);
|
|
77
|
+
const tempId = useId();
|
|
78
|
+
const finalId = `menu-${id ?? tempId}`;
|
|
79
|
+
const target = isValidElement(
|
|
80
|
+
disclosure
|
|
81
|
+
) ? disclosure : disclosure({ visible: isVisible });
|
|
82
|
+
const innerRef = useRef(target);
|
|
83
|
+
useImperativeHandle(ref, () => innerRef.current);
|
|
84
|
+
const finalDisclosure = cloneElement(target, {
|
|
85
|
+
onClick: (event) => {
|
|
86
|
+
target.props.onClick?.(event);
|
|
87
|
+
setIsVisible(!isVisible);
|
|
88
|
+
},
|
|
89
|
+
"aria-haspopup": "dialog",
|
|
90
|
+
"aria-expanded": isVisible,
|
|
91
|
+
// @ts-expect-error not sure how to fix this
|
|
92
|
+
ref: disclosureRef
|
|
93
|
+
});
|
|
94
|
+
return /* @__PURE__ */ jsx(
|
|
95
|
+
StyledPopup,
|
|
96
|
+
{
|
|
97
|
+
debounceDelay: triggerMethod === "hover" ? 250 : 0,
|
|
98
|
+
hideOnClickOutside: true,
|
|
99
|
+
"aria-label": ariaLabel,
|
|
100
|
+
className,
|
|
101
|
+
visible: triggerMethod === "click" ? isVisible : void 0,
|
|
102
|
+
placement,
|
|
103
|
+
hasArrow,
|
|
104
|
+
"data-has-arrow": hasArrow,
|
|
105
|
+
role: "dialog",
|
|
106
|
+
id: finalId,
|
|
107
|
+
ref: popupRef,
|
|
108
|
+
onClose: () => setIsVisible(false),
|
|
109
|
+
tabIndex: -1,
|
|
110
|
+
maxHeight: maxHeight ?? "480px",
|
|
111
|
+
maxWidth,
|
|
112
|
+
size,
|
|
113
|
+
text: /* @__PURE__ */ jsx(MenuList, { "data-testid": dataTestId, className, role: "menu", children: typeof children === "function" ? children({ toggle: () => setIsVisible(!isVisible) }) : children }),
|
|
114
|
+
portalTarget,
|
|
115
|
+
dynamicDomRendering,
|
|
116
|
+
children: finalDisclosure
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
const MenuV2 = Object.assign(FwdMenu, { Item, Group });
|
|
122
|
+
export {
|
|
123
|
+
MenuV2
|
|
124
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type Strength = {
|
|
2
|
+
/**
|
|
3
|
+
* Color to display
|
|
4
|
+
*/
|
|
5
|
+
color: string;
|
|
6
|
+
/**
|
|
7
|
+
* Text to display
|
|
8
|
+
*/
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
11
|
+
type PasswordStrengthMeterProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Strength is used for defining different color and text associated with it.
|
|
14
|
+
*/
|
|
15
|
+
strength: Strength[];
|
|
16
|
+
title: string;
|
|
17
|
+
value: number;
|
|
18
|
+
className?: string;
|
|
19
|
+
'data-testid'?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Show strength of a password based on different criteria.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Meter: ({ strength, title, value, className, "data-testid": dataTestId, id, }: PasswordStrengthMeterProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsxs, jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { Text } from "../Text/index.js";
|
|
4
|
+
const StyledStrength = styled(Text, {
|
|
5
|
+
shouldForwardProp: (prop) => !["color"].includes(prop)
|
|
6
|
+
})`
|
|
7
|
+
float: right;
|
|
8
|
+
vertical-align: top;
|
|
9
|
+
color: ${({ strength }) => strength.color};
|
|
10
|
+
`;
|
|
11
|
+
const StyledWrapper = styled.div`
|
|
12
|
+
background-color: ${({ theme }) => theme.colors.neutral.backgroundDisabled};
|
|
13
|
+
border-radius: ${({ theme }) => theme.radii.default};
|
|
14
|
+
height: ${({ theme }) => theme.space["1"]};
|
|
15
|
+
margin-top: ${({ theme }) => theme.space["1"]};
|
|
16
|
+
margin-bottom: ${({ theme }) => theme.space["2"]};
|
|
17
|
+
`;
|
|
18
|
+
const StyledMeter = styled.div`
|
|
19
|
+
border-radius: ${({ theme }) => theme.radii.default};
|
|
20
|
+
height: 100%;
|
|
21
|
+
transition: all 0.5s;
|
|
22
|
+
`;
|
|
23
|
+
const Meter = ({
|
|
24
|
+
strength,
|
|
25
|
+
title,
|
|
26
|
+
value,
|
|
27
|
+
className,
|
|
28
|
+
"data-testid": dataTestId,
|
|
29
|
+
id
|
|
30
|
+
}) => {
|
|
31
|
+
const toValue = (value + 1) / strength.length * 100;
|
|
32
|
+
const width = `${toValue}%`;
|
|
33
|
+
const backgroundColor = strength[value]?.color ?? strength[0].color;
|
|
34
|
+
const text = strength[value]?.text ?? strength[0].text;
|
|
35
|
+
return /* @__PURE__ */ jsxs(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
"aria-live": "polite",
|
|
39
|
+
"aria-valuemax": strength.length ?? 0,
|
|
40
|
+
"aria-valuemin": 0,
|
|
41
|
+
"aria-valuenow": value,
|
|
42
|
+
className,
|
|
43
|
+
"data-testid": dataTestId,
|
|
44
|
+
id,
|
|
45
|
+
role: "meter",
|
|
46
|
+
title,
|
|
47
|
+
"aria-labelledby": "meter-label",
|
|
48
|
+
children: [
|
|
49
|
+
/* @__PURE__ */ jsxs(Text, { id: "meter-label", variant: "bodySmallStrong", as: "p", children: [
|
|
50
|
+
title,
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
StyledStrength,
|
|
53
|
+
{
|
|
54
|
+
as: "span",
|
|
55
|
+
variant: "bodySmallStrong",
|
|
56
|
+
strength: strength[value],
|
|
57
|
+
children: text
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] }),
|
|
61
|
+
/* @__PURE__ */ jsx(StyledWrapper, { children: /* @__PURE__ */ jsx(
|
|
62
|
+
StyledMeter,
|
|
63
|
+
{
|
|
64
|
+
style: {
|
|
65
|
+
backgroundColor,
|
|
66
|
+
width
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
) })
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
Meter
|
|
76
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DialogProps } from './types';
|
|
3
|
+
export declare const Dialog: ({ children, open, placement, onClose, hideOnClickOutside, size, id, ariaLabel, className, "data-testid": dataTestId, preventBodyScroll, hideOnEsc, backdropClassName, dialogCss, backdropCss, }: DialogProps) => import("react").ReactPortal | null;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import styled from "@emotion/styled";
|
|
3
|
+
import { useRef, useEffect, useCallback } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { MODAL_WIDTH, MODAL_PLACEMENT } from "./constants.js";
|
|
6
|
+
const StyledBackdrop = styled.div`
|
|
7
|
+
position: fixed;
|
|
8
|
+
top: 0;
|
|
9
|
+
right: 0;
|
|
10
|
+
height: 0;
|
|
11
|
+
width: 0;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
background-color: ${({ theme }) => theme.colors.overlay};
|
|
14
|
+
z-index: 1;
|
|
15
|
+
|
|
16
|
+
&[data-open='true'] {
|
|
17
|
+
padding: ${({ theme }) => theme.space["2"]};
|
|
18
|
+
overflow: auto;
|
|
19
|
+
display: flex;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
height: 100%;
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
const StyledDialog = styled.dialog`
|
|
27
|
+
background-color: ${({ theme }) => theme.colors.neutral.backgroundWeakElevated};
|
|
28
|
+
position: relative;
|
|
29
|
+
border-radius: ${({ theme }) => theme.radii.default};
|
|
30
|
+
border: 0;
|
|
31
|
+
padding: ${({ theme }) => theme.space["3"]};
|
|
32
|
+
width: ${MODAL_WIDTH.medium}px;
|
|
33
|
+
box-shadow: ${({ theme }) => theme.shadows.modal};
|
|
34
|
+
|
|
35
|
+
${Object.entries(MODAL_WIDTH).map(
|
|
36
|
+
([size, value]) => `
|
|
37
|
+
&[data-size="${size}"] {
|
|
38
|
+
width: ${value}px;
|
|
39
|
+
}
|
|
40
|
+
`
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
${Object.entries(MODAL_PLACEMENT).map(
|
|
44
|
+
([placement, value]) => `
|
|
45
|
+
&[data-placement="${placement}"] {
|
|
46
|
+
${value}
|
|
47
|
+
}
|
|
48
|
+
`
|
|
49
|
+
)}
|
|
50
|
+
`;
|
|
51
|
+
const Dialog = ({
|
|
52
|
+
children,
|
|
53
|
+
open,
|
|
54
|
+
placement,
|
|
55
|
+
onClose,
|
|
56
|
+
hideOnClickOutside,
|
|
57
|
+
size,
|
|
58
|
+
id,
|
|
59
|
+
ariaLabel,
|
|
60
|
+
className,
|
|
61
|
+
"data-testid": dataTestId,
|
|
62
|
+
preventBodyScroll,
|
|
63
|
+
hideOnEsc,
|
|
64
|
+
backdropClassName,
|
|
65
|
+
dialogCss,
|
|
66
|
+
backdropCss
|
|
67
|
+
}) => {
|
|
68
|
+
const containerRef = useRef(document.createElement("div"));
|
|
69
|
+
const dialogRef = useRef(null);
|
|
70
|
+
const onCloseRef = useRef(onClose);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const element = containerRef.current;
|
|
73
|
+
if (open) {
|
|
74
|
+
document.body.appendChild(element);
|
|
75
|
+
}
|
|
76
|
+
return () => {
|
|
77
|
+
if (document.body.contains(element)) {
|
|
78
|
+
document.body.removeChild(element);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}, [open]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
onCloseRef.current = onClose;
|
|
84
|
+
}, [onClose]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (open) {
|
|
87
|
+
dialogRef.current?.focus();
|
|
88
|
+
}
|
|
89
|
+
}, [open]);
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const previousOverflow = document.body.style.overflow;
|
|
92
|
+
if (open && preventBodyScroll) {
|
|
93
|
+
document.body.style.overflow = "hidden";
|
|
94
|
+
}
|
|
95
|
+
return () => {
|
|
96
|
+
document.body.style.overflow = previousOverflow;
|
|
97
|
+
};
|
|
98
|
+
}, [preventBodyScroll, open]);
|
|
99
|
+
const stopFocus = useCallback((event) => {
|
|
100
|
+
event.stopPropagation();
|
|
101
|
+
}, []);
|
|
102
|
+
const stopClick = useCallback((event) => {
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
}, []);
|
|
105
|
+
const handleKeyUp = useCallback(
|
|
106
|
+
(event) => {
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
if (event.key === "Escape" && hideOnEsc) {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
onCloseRef.current();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
[hideOnEsc]
|
|
114
|
+
);
|
|
115
|
+
const handleClose = useCallback(
|
|
116
|
+
(event) => {
|
|
117
|
+
event.stopPropagation();
|
|
118
|
+
if (hideOnClickOutside) {
|
|
119
|
+
onCloseRef.current();
|
|
120
|
+
} else {
|
|
121
|
+
dialogRef.current?.focus();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
[hideOnClickOutside]
|
|
125
|
+
);
|
|
126
|
+
const handleFocusTrap = useCallback((event) => {
|
|
127
|
+
event.stopPropagation();
|
|
128
|
+
if (event.key === "Escape") {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const isTabPressed = event.key === "Tab";
|
|
133
|
+
if (!isTabPressed) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const focusableEls = dialogRef.current?.querySelectorAll(
|
|
137
|
+
"a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled])"
|
|
138
|
+
) ?? [];
|
|
139
|
+
if (focusableEls.length === 0) {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
}
|
|
142
|
+
const firstFocusableEl = focusableEls[0];
|
|
143
|
+
const lastFocusableEl = focusableEls[focusableEls.length - 1];
|
|
144
|
+
if (event.shiftKey) {
|
|
145
|
+
if (document.activeElement === firstFocusableEl || document.activeElement === dialogRef.current) {
|
|
146
|
+
lastFocusableEl.focus();
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
}
|
|
149
|
+
} else if (document.activeElement === lastFocusableEl || document.activeElement === dialogRef.current) {
|
|
150
|
+
firstFocusableEl.focus();
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
}
|
|
153
|
+
}, []);
|
|
154
|
+
const stopCancel = (event) => {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
event.stopPropagation();
|
|
157
|
+
};
|
|
158
|
+
return open ? createPortal(
|
|
159
|
+
/* @__PURE__ */ jsx(
|
|
160
|
+
StyledBackdrop,
|
|
161
|
+
{
|
|
162
|
+
"data-open": open,
|
|
163
|
+
onClick: handleClose,
|
|
164
|
+
className: backdropClassName,
|
|
165
|
+
css: backdropCss,
|
|
166
|
+
"data-testid": dataTestId ? `${dataTestId}-backdrop` : void 0,
|
|
167
|
+
onFocus: stopFocus,
|
|
168
|
+
children: /* @__PURE__ */ jsx(
|
|
169
|
+
StyledDialog,
|
|
170
|
+
{
|
|
171
|
+
css: dialogCss,
|
|
172
|
+
onKeyUp: handleKeyUp,
|
|
173
|
+
onKeyDown: handleFocusTrap,
|
|
174
|
+
className,
|
|
175
|
+
id,
|
|
176
|
+
"data-testid": dataTestId,
|
|
177
|
+
"aria-label": ariaLabel,
|
|
178
|
+
"data-placement": placement,
|
|
179
|
+
"data-size": size,
|
|
180
|
+
open,
|
|
181
|
+
onClick: stopClick,
|
|
182
|
+
onCancel: stopCancel,
|
|
183
|
+
onClose: stopCancel,
|
|
184
|
+
"aria-modal": true,
|
|
185
|
+
ref: dialogRef,
|
|
186
|
+
tabIndex: 0,
|
|
187
|
+
children: open ? children : null
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
containerRef.current
|
|
193
|
+
) : null;
|
|
194
|
+
};
|
|
195
|
+
export {
|
|
196
|
+
Dialog
|
|
197
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { DisclosureProps } from './types';
|
|
3
|
+
export declare const Disclosure: ({ disclosure, handleOpen, visible, handleClose, toggle, id, }: DisclosureProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { useEffect, useMemo, isValidElement, cloneElement
|
|
2
|
-
|
|
1
|
+
import { createRef, useEffect, useMemo, isValidElement, cloneElement } from "react";
|
|
3
2
|
const Disclosure = ({
|
|
4
3
|
disclosure,
|
|
5
4
|
handleOpen,
|
|
@@ -8,16 +7,16 @@ const Disclosure = ({
|
|
|
8
7
|
toggle,
|
|
9
8
|
id
|
|
10
9
|
}) => {
|
|
11
|
-
const disclosureRef =
|
|
10
|
+
const disclosureRef = createRef();
|
|
12
11
|
useEffect(() => {
|
|
13
12
|
const element = disclosureRef.current;
|
|
14
|
-
element?.addEventListener(
|
|
13
|
+
element?.addEventListener("click", handleOpen);
|
|
15
14
|
return () => {
|
|
16
|
-
element?.removeEventListener(
|
|
15
|
+
element?.removeEventListener("click", handleOpen);
|
|
17
16
|
};
|
|
18
17
|
}, [handleOpen, disclosureRef]);
|
|
19
18
|
const finalDisclosure = useMemo(() => {
|
|
20
|
-
if (typeof disclosure ===
|
|
19
|
+
if (typeof disclosure === "function") {
|
|
21
20
|
return disclosure({
|
|
22
21
|
visible,
|
|
23
22
|
onClose: handleClose,
|
|
@@ -31,14 +30,15 @@ const Disclosure = ({
|
|
|
31
30
|
}
|
|
32
31
|
return disclosure;
|
|
33
32
|
}, [disclosure, handleOpen, handleClose, id, toggle, visible]);
|
|
34
|
-
if (!
|
|
33
|
+
if (!isValidElement(finalDisclosure)) {
|
|
35
34
|
return null;
|
|
36
35
|
}
|
|
37
|
-
return
|
|
36
|
+
return cloneElement(finalDisclosure, {
|
|
38
37
|
ref: disclosureRef,
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
"aria-controls": id,
|
|
39
|
+
"aria-haspopup": "dialog"
|
|
41
40
|
});
|
|
42
41
|
};
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
export {
|
|
43
|
+
Disclosure
|
|
44
|
+
};
|
|
@@ -10,12 +10,12 @@ const MODAL_PLACEMENT = {
|
|
|
10
10
|
margin: auto;
|
|
11
11
|
margin-bottom: 0;
|
|
12
12
|
`,
|
|
13
|
-
|
|
13
|
+
"bottom-left": `
|
|
14
14
|
margin: auto;
|
|
15
15
|
margin-left: 0;
|
|
16
16
|
margin-bottom: 0;
|
|
17
17
|
`,
|
|
18
|
-
|
|
18
|
+
"bottom-right": `
|
|
19
19
|
margin: auto;
|
|
20
20
|
margin-right: 0;
|
|
21
21
|
margin-bottom: 0;
|
|
@@ -35,16 +35,18 @@ const MODAL_PLACEMENT = {
|
|
|
35
35
|
margin: auto;
|
|
36
36
|
margin-top: 0px;
|
|
37
37
|
`,
|
|
38
|
-
|
|
38
|
+
"top-left": `
|
|
39
39
|
margin: auto;
|
|
40
40
|
margin-left: 0;
|
|
41
41
|
margin-top: 0;
|
|
42
42
|
`,
|
|
43
|
-
|
|
43
|
+
"top-right": `
|
|
44
44
|
margin: auto;
|
|
45
45
|
margin-right: 0;
|
|
46
46
|
margin-top: 0;
|
|
47
47
|
`
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
export {
|
|
50
|
+
MODAL_PLACEMENT,
|
|
51
|
+
MODAL_WIDTH
|
|
52
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
import type { ModalPlacement, ModalSize, ModalState } from './types';
|
|
4
|
+
export type ModalProps = {
|
|
5
|
+
id?: string;
|
|
6
|
+
hideOnEsc?: boolean;
|
|
7
|
+
hideOnClickOutside?: boolean;
|
|
8
|
+
preventBodyScroll?: boolean;
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
disclosure?: ReactElement | ((state: ModalState) => ReactElement);
|
|
11
|
+
isClosable?: boolean;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
onBeforeClose?: () => Promise<void> | void;
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated You should use open prop instead
|
|
17
|
+
*/
|
|
18
|
+
opened?: boolean;
|
|
19
|
+
placement?: ModalPlacement;
|
|
20
|
+
size?: ModalSize;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated You should use size prop instead
|
|
23
|
+
*/
|
|
24
|
+
width?: ModalSize;
|
|
25
|
+
children: ReactNode | ((args: ModalState) => ReactNode);
|
|
26
|
+
className?: string;
|
|
27
|
+
'data-testid'?: string;
|
|
28
|
+
backdropClassName?: string;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated You should use backdropClassName instead
|
|
31
|
+
*/
|
|
32
|
+
customDialogBackdropStyles?: React.JSX.IntrinsicAttributes['css'];
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated You should use className instead
|
|
35
|
+
*/
|
|
36
|
+
customDialogStyles?: React.JSX.IntrinsicAttributes['css'];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Modal is a component that allows you to display content on top of other content.
|
|
40
|
+
* It is often used to display a dialog with additional information or to ask for a confirmation.
|
|
41
|
+
*/
|
|
42
|
+
export declare const Modal: ({ ariaLabel, id, children, disclosure, hideOnClickOutside, hideOnEsc, isClosable, onClose, onBeforeClose, open, opened, placement, preventBodyScroll, size, className, "data-testid": dataTestId, backdropClassName, width, customDialogStyles, customDialogBackdropStyles, }: ModalProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|