@preply/ds-web-lib 10.0.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion-B0hR-tcI.js +96 -0
- package/dist/AlertBannerProvider-Cf7w9AOq.js +76 -0
- package/dist/AlertDialog-BG-diKBi.js +475 -0
- package/dist/Avatar-B-JdqVyg.js +66 -0
- package/dist/AvatarWithStatus-CD9jEqEB.js +36 -0
- package/dist/Badge-Dd-CLBoW.js +50 -0
- package/dist/Box-BJBE9KNm.js +91 -0
- package/dist/BubbleCounter.module-BU2S0euA.js +16 -0
- package/dist/Button-C35BZJZT.js +91 -0
- package/dist/ButtonBase-8eUyTWxX.js +215 -0
- package/dist/Checkbox-CtolNbxI.js +108 -0
- package/dist/Chips-BRGw7Uup.js +99 -0
- package/dist/ChipsPrimitive-Bezq7ptE.js +1179 -0
- package/dist/CountryFlag-DVDKHmQH.js +43 -0
- package/dist/Dialog.module-Db2BJAn4.js +21 -0
- package/dist/DialogCloseButton-DjDd9Mid.js +98 -0
- package/dist/DialogDescription-8zw9t6pm.js +44 -0
- package/dist/DialogRoot-B67oJduC.js +335 -0
- package/dist/DialogRootContext-Bz8RW-Mq.js +12 -0
- package/dist/DialogTitle-C2Nn2ys-.js +43 -0
- package/dist/Divider-DvwDWB9_.js +17 -0
- package/dist/DropdownMenu.primitives-BrsTBvMk.js +4007 -0
- package/dist/FieldButton-B2slox8P.js +32 -0
- package/dist/FormControl-qnbQL1iF.js +128 -0
- package/dist/Heading-DA9gHfsx.js +71 -0
- package/dist/Icon-CixAeOSd.js +48 -0
- package/dist/IconButton-BPKpgfep.js +31 -0
- package/dist/InputContainer-CzzuOe_p.js +38 -0
- package/dist/LayoutFlex-e9auDvWD.js +86 -0
- package/dist/LayoutFlexItem-D9ziMmHe.js +48 -0
- package/dist/LayoutGridItem-Q8Lnvrri.js +34 -0
- package/dist/Link-CdoJVeER.js +66 -0
- package/dist/Loader-BMOxdJce.js +26 -0
- package/dist/OnboardingTooltip-B47_Yrsj.js +165 -0
- package/dist/OnboardingTour-DUUoI5WE.js +131 -0
- package/dist/PasswordField-Bx5YG62t.js +93 -0
- package/dist/PreplyLogo-abgOre30.js +112 -0
- package/dist/ProgressBar-CEU4GyHn.js +31 -0
- package/dist/ProgressSteps-BSqopxqv.js +45 -0
- package/dist/Select-Bo7PX_8V.js +124 -0
- package/dist/Slider-Crg4DEn_.js +64 -0
- package/dist/Spinner-Ck8KQA22.js +86 -0
- package/dist/Stars-D5QspUBE.js +72 -0
- package/dist/Steps-DbN5vFrP.js +173 -0
- package/dist/Switch-Ck_xB0ID.js +49 -0
- package/dist/Text-CaOF75Z-.js +121 -0
- package/dist/TextHighlighted-Dwq9Clgn.js +34 -0
- package/dist/TextInline-BcA4H2Tk.js +34 -0
- package/dist/Toast-wJAjSLfo.js +1019 -0
- package/dist/TokyoUIChevronDown-DGcVqR1z.js +14 -0
- package/dist/Tooltip-grvKQxTN.js +84 -0
- package/dist/VisuallyHidden-CtcHcZCK.js +29 -0
- package/dist/align-self-VrZUceie.js +42 -0
- package/dist/assets/Accordion.css +2 -2
- package/dist/assets/AlertBannerProvider.css +2 -2
- package/dist/assets/AlertDialog.css +2 -2
- package/dist/assets/Avatar.css +3 -3
- package/dist/assets/AvatarWithStatus.css +2 -2
- package/dist/assets/Badge.css +1 -1
- package/dist/assets/Box.css +3 -3
- package/dist/assets/BubbleCounter.css +1 -1
- package/dist/assets/Button.css +4 -4
- package/dist/assets/ButtonBase.css +40 -46
- package/dist/assets/Checkbox.css +1 -1
- package/dist/assets/Chips.css +2 -2
- package/dist/assets/ChipsPrimitive.css +2 -2
- package/dist/assets/CountryFlag.css +1 -1
- package/dist/assets/Dialog.css +13 -4
- package/dist/assets/Divider.css +1 -1
- package/dist/assets/DropdownMenu.css +2 -2
- package/dist/assets/FieldButton.css +3 -3
- package/dist/assets/FormControl.css +1 -1
- package/dist/assets/Heading.css +3 -3
- package/dist/assets/Icon.css +3 -3
- package/dist/assets/InputContainer.css +2 -2
- package/dist/assets/LayoutFlex.css +1 -1
- package/dist/assets/LayoutFlexItem.css +1 -1
- package/dist/assets/Link.css +3 -3
- package/dist/assets/Loader.css +1 -1
- package/dist/assets/OnboardingTooltip.css +6 -4
- package/dist/assets/OnboardingTour.css +3 -2
- package/dist/assets/PreplyLogo.css +1 -1
- package/dist/assets/ProgressBar.css +1 -1
- package/dist/assets/ProgressSteps.css +1 -1
- package/dist/assets/Select.css +2 -2
- package/dist/assets/Slider.css +1 -1
- package/dist/assets/Spinner.css +3 -3
- package/dist/assets/Stars.css +3 -3
- package/dist/assets/Steps.css +2 -2
- package/dist/assets/Switch.css +1 -1
- package/dist/assets/Text.css +3 -3
- package/dist/assets/TextHighlighted.css +3 -3
- package/dist/assets/TextInline.css +3 -3
- package/dist/assets/Toast.css +2 -2
- package/dist/assets/Tooltip.css +1 -1
- package/dist/assets/align-self.css +1 -1
- package/dist/assets/{IconTile.css → components.css} +9 -1
- package/dist/assets/exp-color.css +2 -2
- package/dist/assets/index.css +1 -1
- package/dist/assets/layout-gap.css +3 -3
- package/dist/assets/layout-grid.css +3 -3
- package/dist/assets/layout-hide.css +1 -1
- package/dist/assets/layout-padding.css +3 -3
- package/dist/assets/layout-relative.css +1 -1
- package/dist/assets/text-accent.css +2 -2
- package/dist/assets/text-centered.css +1 -1
- package/dist/assets/text-weight.css +2 -2
- package/dist/chunk-BVTlhY3a.js +24 -0
- package/dist/components/Accordion/Accordion.js +4 -60
- package/dist/components/Accordion/hooks/useOnOpenChange.js +19 -28
- package/dist/components/AlertBanner/AlertBanner.js +11 -26
- package/dist/components/AlertBanner/AlertBannerProvider.js +3 -8
- package/dist/components/AlertBanner/primitives/AlertBannerAction.js +11 -69
- package/dist/components/AlertBanner/primitives/AlertBannerIcon.js +77 -39
- package/dist/components/AlertBanner/primitives/AlertBannerRoot.js +26 -22
- package/dist/components/AlertBanner/primitives/AlertBannerText.js +11 -70
- package/dist/components/AlertDialog/AlertDialog.d.ts +3 -3
- package/dist/components/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/components/AlertDialog/AlertDialog.js +5 -94
- package/dist/components/Avatar/Avatar.js +3 -71
- package/dist/components/AvatarWithStatus/AvatarWithStatus.js +3 -43
- package/dist/components/Badge/Badge.js +4 -62
- package/dist/components/Box/Box.js +3 -95
- package/dist/components/BubbleCounter/BubbleCounter.js +23 -28
- package/dist/components/Button/Button.js +4 -80
- package/dist/components/CalloutBanner/CalloutBanner.js +61 -12
- package/dist/components/CalloutBanner/primitives/CalloutBannerDismissButton.js +50 -22
- package/dist/components/CalloutBanner/primitives/CalloutBannerIcon.js +86 -45
- package/dist/components/CalloutBanner/primitives/CalloutBannerRoot.js +50 -24
- package/dist/components/CalloutBanner/primitives/CalloutBannerText.js +41 -11
- package/dist/components/Checkbox/Checkbox.js +4 -78
- package/dist/components/Checkbox/hooks/useIndeterminate.js +24 -30
- package/dist/components/Chips/Chips.types.js +0 -1
- package/dist/components/Chips/DismissibleChips.js +117 -86
- package/dist/components/Chips/MultiSelectChips.js +98 -64
- package/dist/components/Chips/SingleSelectChips.js +94 -57
- package/dist/components/Chips/private/ChipsPrimitive.js +4 -17
- package/dist/components/CountryFlag/CountryFlag.js +3 -44
- package/dist/components/Dialog/Dialog.js +56 -31
- package/dist/components/Dialog/DialogSteps.js +40 -29
- package/dist/components/Dialog/primitives/DialogActions.js +26 -19
- package/dist/components/Dialog/primitives/DialogButtonStack.d.ts.map +1 -1
- package/dist/components/Dialog/primitives/DialogButtonStack.js +22 -15
- package/dist/components/Dialog/primitives/DialogCloseButton.d.ts +1 -1
- package/dist/components/Dialog/primitives/DialogCloseButton.d.ts.map +1 -1
- package/dist/components/Dialog/primitives/DialogCloseButton.js +4 -93
- package/dist/components/Dialog/primitives/DialogDescription.js +3 -43
- package/dist/components/Dialog/primitives/DialogFooter.js +37 -34
- package/dist/components/Dialog/primitives/DialogRoot.js +4 -1459
- package/dist/components/Dialog/primitives/DialogTitle.js +3 -42
- package/dist/components/Divider/Divider.js +3 -14
- package/dist/components/DropdownMenu/DropdownMenu.js +253 -188
- package/dist/components/DropdownMenu/primitives/DropdownMenu.primitives.js +5 -34
- package/dist/components/DropdownMenu/primitives/DropdownMenuSelectItem.primitives.js +121 -71
- package/dist/components/FieldButton/FieldButton.js +3 -37
- package/dist/components/FormControl/FormControl.js +3 -105
- package/dist/components/Heading/Heading.js +3 -78
- package/dist/components/Icon/Icon.js +4 -49
- package/dist/components/IconButton/IconButton.d.ts +5 -1
- package/dist/components/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/IconButton/IconButton.js +4 -28
- package/dist/components/IconTile/IconTile.js +11 -69
- package/dist/components/IntlFormatted/IntlFormattedAggregatedDateTime.js +16 -32
- package/dist/components/IntlFormatted/IntlFormattedCurrency.js +20 -42
- package/dist/components/IntlFormatted/IntlFormattedDate.js +73 -195
- package/dist/components/IntlFormatted/IntlFormattedTime.js +14 -24
- package/dist/components/IntlFormatted/Wrapper.js +14 -8
- package/dist/components/LayoutFlex/LayoutFlex.js +3 -100
- package/dist/components/LayoutFlex/style/getStyleAttrs.js +71 -143
- package/dist/components/LayoutFlex/tests/AlignItems.js +67 -97
- package/dist/components/LayoutFlex/tests/ColumnReverse.js +63 -100
- package/dist/components/LayoutFlex/tests/DataOverride.js +1498 -1093
- package/dist/components/LayoutFlex/tests/Default.js +19 -20
- package/dist/components/LayoutFlex/tests/Direction.js +65 -88
- package/dist/components/LayoutFlex/tests/Gap.js +115 -197
- package/dist/components/LayoutFlex/tests/HideInline.js +95 -136
- package/dist/components/LayoutFlex/tests/JustifyContent.js +75 -108
- package/dist/components/LayoutFlex/tests/Nowrap.js +35 -42
- package/dist/components/LayoutFlex/tests/Padding.js +207 -263
- package/dist/components/LayoutFlex/tests/Relative.js +49 -64
- package/dist/components/LayoutFlexItem/LayoutFlexItem.js +3 -54
- package/dist/components/LayoutGrid/LayoutGrid.js +26 -34
- package/dist/components/LayoutGridItem/LayoutGridItem.js +3 -41
- package/dist/components/Link/Link.js +3 -72
- package/dist/components/Loader/Loader.js +3 -32
- package/dist/components/NumberField/NumberField.js +33 -35
- package/dist/components/ObserveIntersection/ObserveIntersection.js +41 -42
- package/dist/components/OnboardingTooltip/OnboardingTooltip.js +4 -115
- package/dist/components/OnboardingTour/OnboardingTour.js +4 -114
- package/dist/components/PasswordField/PasswordField.js +3 -78
- package/dist/components/PreplyLogo/PreplyLogo.js +3 -81
- package/dist/components/ProgressBar/ProgressBar.js +3 -27
- package/dist/components/ProgressSteps/ProgressSteps.js +3 -48
- package/dist/components/Rating/Rating.js +29 -20
- package/dist/components/Rating/RatingInput.js +57 -59
- package/dist/components/Rating/Stars.js +4 -8
- package/dist/components/Rating/hooks/useHasError.js +11 -15
- package/dist/components/Rating/hooks/useHoverPercentage.js +37 -45
- package/dist/components/Rating/hooks/useInputState.js +18 -24
- package/dist/components/Rating/hooks/useLocalizations.js +12 -24
- package/dist/components/Rating/utils/roundToHalfDecimal.js +4 -4
- package/dist/components/SelectField/Select.js +5 -112
- package/dist/components/SelectField/SelectField.js +29 -24
- package/dist/components/SelectField/hooks/useBreakpointMatch.js +18 -19
- package/dist/components/ShowOnIntersection/ShowOnIntersection.js +32 -21
- package/dist/components/Slider/RangeSlider.js +62 -52
- package/dist/components/Slider/Slider.js +3 -10
- package/dist/components/Steps/Steps.js +4 -210
- package/dist/components/Switch/Switch.js +3 -51
- package/dist/components/Text/Text.js +3 -128
- package/dist/components/TextField/TextField.js +27 -29
- package/dist/components/TextHighlighted/TextHighlighted.js +3 -41
- package/dist/components/TextInline/TextInline.js +3 -40
- package/dist/components/TextareaField/TextareaField.js +26 -28
- package/dist/components/Toast/Toast.js +4 -1168
- package/dist/components/Tooltip/Tooltip.js +3 -66
- package/dist/components/deprecated/Chips/Chips.js +4 -76
- package/dist/components/deprecated/NativeSelectField/NativeSelect.js +40 -32
- package/dist/components/deprecated/NativeSelectField/NativeSelectField.js +34 -33
- package/dist/components/deprecated/index.js +5 -6
- package/dist/components/index.js +50 -150
- package/dist/components/private/ButtonBase/ButtonBase.d.ts +7 -11
- package/dist/components/private/ButtonBase/ButtonBase.d.ts.map +1 -1
- package/dist/components/private/ButtonBase/ButtonBase.js +3 -247
- package/dist/components/private/Input/Input.js +27 -19
- package/dist/components/private/Input/InputContainer.js +3 -5
- package/dist/components/private/Input/Textarea.js +24 -20
- package/dist/components/private/Input/index.js +2 -4
- package/dist/components/private/Spinner/Spinner.js +3 -52
- package/dist/components/private/VisuallyHidden/VisuallyHidden.js +3 -15
- package/dist/components-BIYP8wHJ.js +200 -0
- package/dist/exp-color-C5mKAN91.js +74 -0
- package/dist/floating-ui.utils.dom-CoeTbDZx.js +215 -0
- package/dist/index.js +50 -150
- package/dist/index.module-1c7ENvxc.js +7 -0
- package/dist/jsx-runtime-i4KUlhDu.js +743 -0
- package/dist/layout-gap.module-DLD8bcR4.js +95 -0
- package/dist/layout-grid.module-CZfhrKrB.js +101 -0
- package/dist/layout-hide.module-B1P0N4i3.js +53 -0
- package/dist/layout-padding-ugY-yd2q.js +389 -0
- package/dist/layout-relative.module-B5xrFD9j.js +6 -0
- package/dist/render-icon-Ch3b2dE0.js +290 -0
- package/dist/shared-styles/align-self/align-self.js +2 -36
- package/dist/shared-styles/exp-color/exp-color.js +2 -68
- package/dist/shared-styles/layout-gap/layout-gap.js +13 -7
- package/dist/shared-styles/layout-grid/layout-grid.js +28 -28
- package/dist/shared-styles/layout-grid-responsive-columns/layout-grid-responsive-columns.js +29 -43
- package/dist/shared-styles/layout-hide/layout-hide.js +8 -8
- package/dist/shared-styles/layout-padding/layout-padding.js +2 -5
- package/dist/shared-styles/layout-relative/layout-relative.js +14 -8
- package/dist/shared-styles/text-accent/text-accent.js +2 -25
- package/dist/shared-styles/text-centered/text-centered.js +2 -24
- package/dist/shared-styles/text-weight/text-weight.js +2 -15
- package/dist/store-sN_eYeZT.js +1064 -0
- package/dist/storybook-utils/consts.js +6 -8
- package/dist/storybook-utils/index.js +1 -5
- package/dist/text-accent-CfUFx-1K.js +30 -0
- package/dist/text-centered-Dwp2_-Yp.js +30 -0
- package/dist/text-weight-CwoqmM4o.js +21 -0
- package/dist/useBaseUiId-CWAD_PSs.js +13 -0
- package/dist/useBreakpointMatch-D9a3CTNK.js +338 -0
- package/dist/useButton-DHTh3Hm7.js +148 -0
- package/dist/useDialogClose-BzFIyWco.js +22 -0
- package/dist/useId-CJsH-2wV.js +34 -0
- package/dist/useOpenInteractionType-D8vA_ZKI.js +4104 -0
- package/dist/useRenderElement-ZBds6eRN.js +341 -0
- package/dist/utils/Orientation/OrientationProvider.js +54 -23
- package/dist/utils/Orientation/index.js +2 -4
- package/dist/utils/RovingTabIndex/RovingTabIndexProvider.js +70 -44
- package/dist/utils/RovingTabIndex/index.js +2 -4
- package/dist/utils/createRequiredContext.js +23 -13
- package/dist/utils/filterAttributesPassedByRadixUIAtRuntime.js +28 -25
- package/dist/utils/render-icon.js +3 -320
- package/dist/utils/shared-strings.js +24 -32
- package/dist/utils/useBreakpointMatch.d.ts.map +1 -1
- package/dist/utils/useBreakpointMatch.js +2 -183
- package/dist/utils/useControllableState/useControllableState.js +31 -25
- package/dist/utils/useMergeRefs.js +29 -14
- package/dist/utils/useStableCallback/useStableCallback.js +28 -13
- package/package.json +17 -22
- package/dist/AlertBannerProvider-DTx2Xp3V.js +0 -50
- package/dist/BubbleCounter.module-QMwXWFIS.js +0 -16
- package/dist/ChipsPrimitive-DzsaOWgY.js +0 -1244
- package/dist/Dialog.module-Ba1X7b3N.js +0 -29
- package/dist/DialogRootContext-BCXmmJAw.js +0 -15
- package/dist/DropdownMenu.primitives-CqJE9k4D.js +0 -5871
- package/dist/IconTile-D1G7MljH.js +0 -172
- package/dist/InputContainer-oHJlLWIi.js +0 -30
- package/dist/Slider-DB4Maswa.js +0 -55
- package/dist/Stars-C_mHop2H.js +0 -67
- package/dist/TokyoUIChevronDown-D_tD1yU8.js +0 -11
- package/dist/floating-ui.utils.dom-BvMNldxo.js +0 -234
- package/dist/index.module-Q9TzIR6B.js +0 -11
- package/dist/layout-gap.module-MKn_un_k.js +0 -97
- package/dist/layout-grid.module-P4B4WVUy.js +0 -103
- package/dist/layout-hide.module-Bpl3Pl-a.js +0 -55
- package/dist/layout-padding-D5I6rRlL.js +0 -373
- package/dist/layout-relative.module-1z75aSwo.js +0 -8
- package/dist/useBaseUiId-DavsGYu9.js +0 -8
- package/dist/useButton-fjQ0ak8m.js +0 -193
- package/dist/useId-BhIOp2JG.js +0 -28
- package/dist/useOpenInteractionType-DNYFqf-a.js +0 -2880
- package/dist/useRenderElement-BSthtPOr.js +0 -350
|
@@ -1,1168 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import ReactDOM__default from "react-dom";
|
|
6
|
-
import { getDatasetProps } from "@preply/ds-web-core";
|
|
7
|
-
import { webComponentNames } from "@preply/ds-visual-coverage-preply-component-names";
|
|
8
|
-
import { Icon } from "../Icon/Icon.js";
|
|
9
|
-
import { useIntl } from "react-intl";
|
|
10
|
-
import { genericAriaLabels } from "../../utils/shared-strings.js";
|
|
11
|
-
import '../../assets/Toast.css';function __insertCSS(code) {
|
|
12
|
-
if (typeof document == "undefined") return;
|
|
13
|
-
let head = document.head || document.getElementsByTagName("head")[0];
|
|
14
|
-
let style = document.createElement("style");
|
|
15
|
-
style.type = "text/css";
|
|
16
|
-
head.appendChild(style);
|
|
17
|
-
style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
|
|
18
|
-
}
|
|
19
|
-
const getAsset = (type) => {
|
|
20
|
-
switch (type) {
|
|
21
|
-
case "success":
|
|
22
|
-
return SuccessIcon;
|
|
23
|
-
case "info":
|
|
24
|
-
return InfoIcon;
|
|
25
|
-
case "warning":
|
|
26
|
-
return WarningIcon;
|
|
27
|
-
case "error":
|
|
28
|
-
return ErrorIcon;
|
|
29
|
-
default:
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const bars = Array(12).fill(0);
|
|
34
|
-
const Loader = ({ visible, className }) => {
|
|
35
|
-
return /* @__PURE__ */ React__default.createElement("div", {
|
|
36
|
-
className: [
|
|
37
|
-
"sonner-loading-wrapper",
|
|
38
|
-
className
|
|
39
|
-
].filter(Boolean).join(" "),
|
|
40
|
-
"data-visible": visible
|
|
41
|
-
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
42
|
-
className: "sonner-spinner"
|
|
43
|
-
}, bars.map((_, i) => /* @__PURE__ */ React__default.createElement("div", {
|
|
44
|
-
className: "sonner-loading-bar",
|
|
45
|
-
key: `spinner-bar-${i}`
|
|
46
|
-
}))));
|
|
47
|
-
};
|
|
48
|
-
const SuccessIcon = /* @__PURE__ */ React__default.createElement("svg", {
|
|
49
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
50
|
-
viewBox: "0 0 20 20",
|
|
51
|
-
fill: "currentColor",
|
|
52
|
-
height: "20",
|
|
53
|
-
width: "20"
|
|
54
|
-
}, /* @__PURE__ */ React__default.createElement("path", {
|
|
55
|
-
fillRule: "evenodd",
|
|
56
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
57
|
-
clipRule: "evenodd"
|
|
58
|
-
}));
|
|
59
|
-
const WarningIcon = /* @__PURE__ */ React__default.createElement("svg", {
|
|
60
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
61
|
-
viewBox: "0 0 24 24",
|
|
62
|
-
fill: "currentColor",
|
|
63
|
-
height: "20",
|
|
64
|
-
width: "20"
|
|
65
|
-
}, /* @__PURE__ */ React__default.createElement("path", {
|
|
66
|
-
fillRule: "evenodd",
|
|
67
|
-
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
68
|
-
clipRule: "evenodd"
|
|
69
|
-
}));
|
|
70
|
-
const InfoIcon = /* @__PURE__ */ React__default.createElement("svg", {
|
|
71
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
72
|
-
viewBox: "0 0 20 20",
|
|
73
|
-
fill: "currentColor",
|
|
74
|
-
height: "20",
|
|
75
|
-
width: "20"
|
|
76
|
-
}, /* @__PURE__ */ React__default.createElement("path", {
|
|
77
|
-
fillRule: "evenodd",
|
|
78
|
-
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
79
|
-
clipRule: "evenodd"
|
|
80
|
-
}));
|
|
81
|
-
const ErrorIcon = /* @__PURE__ */ React__default.createElement("svg", {
|
|
82
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
83
|
-
viewBox: "0 0 20 20",
|
|
84
|
-
fill: "currentColor",
|
|
85
|
-
height: "20",
|
|
86
|
-
width: "20"
|
|
87
|
-
}, /* @__PURE__ */ React__default.createElement("path", {
|
|
88
|
-
fillRule: "evenodd",
|
|
89
|
-
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
90
|
-
clipRule: "evenodd"
|
|
91
|
-
}));
|
|
92
|
-
const CloseIcon = /* @__PURE__ */ React__default.createElement("svg", {
|
|
93
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
94
|
-
width: "12",
|
|
95
|
-
height: "12",
|
|
96
|
-
viewBox: "0 0 24 24",
|
|
97
|
-
fill: "none",
|
|
98
|
-
stroke: "currentColor",
|
|
99
|
-
strokeWidth: "1.5",
|
|
100
|
-
strokeLinecap: "round",
|
|
101
|
-
strokeLinejoin: "round"
|
|
102
|
-
}, /* @__PURE__ */ React__default.createElement("line", {
|
|
103
|
-
x1: "18",
|
|
104
|
-
y1: "6",
|
|
105
|
-
x2: "6",
|
|
106
|
-
y2: "18"
|
|
107
|
-
}), /* @__PURE__ */ React__default.createElement("line", {
|
|
108
|
-
x1: "6",
|
|
109
|
-
y1: "6",
|
|
110
|
-
x2: "18",
|
|
111
|
-
y2: "18"
|
|
112
|
-
}));
|
|
113
|
-
const useIsDocumentHidden = () => {
|
|
114
|
-
const [isDocumentHidden, setIsDocumentHidden] = React__default.useState(document.hidden);
|
|
115
|
-
React__default.useEffect(() => {
|
|
116
|
-
const callback = () => {
|
|
117
|
-
setIsDocumentHidden(document.hidden);
|
|
118
|
-
};
|
|
119
|
-
document.addEventListener("visibilitychange", callback);
|
|
120
|
-
return () => window.removeEventListener("visibilitychange", callback);
|
|
121
|
-
}, []);
|
|
122
|
-
return isDocumentHidden;
|
|
123
|
-
};
|
|
124
|
-
let toastsCounter = 1;
|
|
125
|
-
class Observer {
|
|
126
|
-
constructor() {
|
|
127
|
-
this.subscribe = (subscriber) => {
|
|
128
|
-
this.subscribers.push(subscriber);
|
|
129
|
-
return () => {
|
|
130
|
-
const index = this.subscribers.indexOf(subscriber);
|
|
131
|
-
this.subscribers.splice(index, 1);
|
|
132
|
-
};
|
|
133
|
-
};
|
|
134
|
-
this.publish = (data) => {
|
|
135
|
-
this.subscribers.forEach((subscriber) => subscriber(data));
|
|
136
|
-
};
|
|
137
|
-
this.addToast = (data) => {
|
|
138
|
-
this.publish(data);
|
|
139
|
-
this.toasts = [
|
|
140
|
-
...this.toasts,
|
|
141
|
-
data
|
|
142
|
-
];
|
|
143
|
-
};
|
|
144
|
-
this.create = (data) => {
|
|
145
|
-
var _data_id;
|
|
146
|
-
const { message, ...rest } = data;
|
|
147
|
-
const id = typeof (data == null ? void 0 : data.id) === "number" || ((_data_id = data.id) == null ? void 0 : _data_id.length) > 0 ? data.id : toastsCounter++;
|
|
148
|
-
const alreadyExists = this.toasts.find((toast2) => {
|
|
149
|
-
return toast2.id === id;
|
|
150
|
-
});
|
|
151
|
-
const dismissible = data.dismissible === void 0 ? true : data.dismissible;
|
|
152
|
-
if (this.dismissedToasts.has(id)) {
|
|
153
|
-
this.dismissedToasts.delete(id);
|
|
154
|
-
}
|
|
155
|
-
if (alreadyExists) {
|
|
156
|
-
this.toasts = this.toasts.map((toast2) => {
|
|
157
|
-
if (toast2.id === id) {
|
|
158
|
-
this.publish({
|
|
159
|
-
...toast2,
|
|
160
|
-
...data,
|
|
161
|
-
id,
|
|
162
|
-
title: message
|
|
163
|
-
});
|
|
164
|
-
return {
|
|
165
|
-
...toast2,
|
|
166
|
-
...data,
|
|
167
|
-
id,
|
|
168
|
-
dismissible,
|
|
169
|
-
title: message
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
return toast2;
|
|
173
|
-
});
|
|
174
|
-
} else {
|
|
175
|
-
this.addToast({
|
|
176
|
-
title: message,
|
|
177
|
-
...rest,
|
|
178
|
-
dismissible,
|
|
179
|
-
id
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
return id;
|
|
183
|
-
};
|
|
184
|
-
this.dismiss = (id) => {
|
|
185
|
-
if (id) {
|
|
186
|
-
this.dismissedToasts.add(id);
|
|
187
|
-
requestAnimationFrame(() => this.subscribers.forEach((subscriber) => subscriber({
|
|
188
|
-
id,
|
|
189
|
-
dismiss: true
|
|
190
|
-
})));
|
|
191
|
-
} else {
|
|
192
|
-
this.toasts.forEach((toast2) => {
|
|
193
|
-
this.subscribers.forEach((subscriber) => subscriber({
|
|
194
|
-
id: toast2.id,
|
|
195
|
-
dismiss: true
|
|
196
|
-
}));
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
return id;
|
|
200
|
-
};
|
|
201
|
-
this.message = (message, data) => {
|
|
202
|
-
return this.create({
|
|
203
|
-
...data,
|
|
204
|
-
message
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
this.error = (message, data) => {
|
|
208
|
-
return this.create({
|
|
209
|
-
...data,
|
|
210
|
-
message,
|
|
211
|
-
type: "error"
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
this.success = (message, data) => {
|
|
215
|
-
return this.create({
|
|
216
|
-
...data,
|
|
217
|
-
type: "success",
|
|
218
|
-
message
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
this.info = (message, data) => {
|
|
222
|
-
return this.create({
|
|
223
|
-
...data,
|
|
224
|
-
type: "info",
|
|
225
|
-
message
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
this.warning = (message, data) => {
|
|
229
|
-
return this.create({
|
|
230
|
-
...data,
|
|
231
|
-
type: "warning",
|
|
232
|
-
message
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
this.loading = (message, data) => {
|
|
236
|
-
return this.create({
|
|
237
|
-
...data,
|
|
238
|
-
type: "loading",
|
|
239
|
-
message
|
|
240
|
-
});
|
|
241
|
-
};
|
|
242
|
-
this.promise = (promise, data) => {
|
|
243
|
-
if (!data) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
let id = void 0;
|
|
247
|
-
if (data.loading !== void 0) {
|
|
248
|
-
id = this.create({
|
|
249
|
-
...data,
|
|
250
|
-
promise,
|
|
251
|
-
type: "loading",
|
|
252
|
-
message: data.loading,
|
|
253
|
-
description: typeof data.description !== "function" ? data.description : void 0
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
const p = Promise.resolve(promise instanceof Function ? promise() : promise);
|
|
257
|
-
let shouldDismiss = id !== void 0;
|
|
258
|
-
let result;
|
|
259
|
-
const originalPromise = p.then(async (response) => {
|
|
260
|
-
result = [
|
|
261
|
-
"resolve",
|
|
262
|
-
response
|
|
263
|
-
];
|
|
264
|
-
const isReactElementResponse = React__default.isValidElement(response);
|
|
265
|
-
if (isReactElementResponse) {
|
|
266
|
-
shouldDismiss = false;
|
|
267
|
-
this.create({
|
|
268
|
-
id,
|
|
269
|
-
type: "default",
|
|
270
|
-
message: response
|
|
271
|
-
});
|
|
272
|
-
} else if (isHttpResponse(response) && !response.ok) {
|
|
273
|
-
shouldDismiss = false;
|
|
274
|
-
const promiseData = typeof data.error === "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
|
|
275
|
-
const description = typeof data.description === "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
|
|
276
|
-
const isExtendedResult = typeof promiseData === "object" && !React__default.isValidElement(promiseData);
|
|
277
|
-
const toastSettings = isExtendedResult ? promiseData : {
|
|
278
|
-
message: promiseData
|
|
279
|
-
};
|
|
280
|
-
this.create({
|
|
281
|
-
id,
|
|
282
|
-
type: "error",
|
|
283
|
-
description,
|
|
284
|
-
...toastSettings
|
|
285
|
-
});
|
|
286
|
-
} else if (response instanceof Error) {
|
|
287
|
-
shouldDismiss = false;
|
|
288
|
-
const promiseData = typeof data.error === "function" ? await data.error(response) : data.error;
|
|
289
|
-
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
290
|
-
const isExtendedResult = typeof promiseData === "object" && !React__default.isValidElement(promiseData);
|
|
291
|
-
const toastSettings = isExtendedResult ? promiseData : {
|
|
292
|
-
message: promiseData
|
|
293
|
-
};
|
|
294
|
-
this.create({
|
|
295
|
-
id,
|
|
296
|
-
type: "error",
|
|
297
|
-
description,
|
|
298
|
-
...toastSettings
|
|
299
|
-
});
|
|
300
|
-
} else if (data.success !== void 0) {
|
|
301
|
-
shouldDismiss = false;
|
|
302
|
-
const promiseData = typeof data.success === "function" ? await data.success(response) : data.success;
|
|
303
|
-
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
304
|
-
const isExtendedResult = typeof promiseData === "object" && !React__default.isValidElement(promiseData);
|
|
305
|
-
const toastSettings = isExtendedResult ? promiseData : {
|
|
306
|
-
message: promiseData
|
|
307
|
-
};
|
|
308
|
-
this.create({
|
|
309
|
-
id,
|
|
310
|
-
type: "success",
|
|
311
|
-
description,
|
|
312
|
-
...toastSettings
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
}).catch(async (error) => {
|
|
316
|
-
result = [
|
|
317
|
-
"reject",
|
|
318
|
-
error
|
|
319
|
-
];
|
|
320
|
-
if (data.error !== void 0) {
|
|
321
|
-
shouldDismiss = false;
|
|
322
|
-
const promiseData = typeof data.error === "function" ? await data.error(error) : data.error;
|
|
323
|
-
const description = typeof data.description === "function" ? await data.description(error) : data.description;
|
|
324
|
-
const isExtendedResult = typeof promiseData === "object" && !React__default.isValidElement(promiseData);
|
|
325
|
-
const toastSettings = isExtendedResult ? promiseData : {
|
|
326
|
-
message: promiseData
|
|
327
|
-
};
|
|
328
|
-
this.create({
|
|
329
|
-
id,
|
|
330
|
-
type: "error",
|
|
331
|
-
description,
|
|
332
|
-
...toastSettings
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
}).finally(() => {
|
|
336
|
-
if (shouldDismiss) {
|
|
337
|
-
this.dismiss(id);
|
|
338
|
-
id = void 0;
|
|
339
|
-
}
|
|
340
|
-
data.finally == null ? void 0 : data.finally.call(data);
|
|
341
|
-
});
|
|
342
|
-
const unwrap = () => new Promise((resolve, reject) => originalPromise.then(() => result[0] === "reject" ? reject(result[1]) : resolve(result[1])).catch(reject));
|
|
343
|
-
if (typeof id !== "string" && typeof id !== "number") {
|
|
344
|
-
return {
|
|
345
|
-
unwrap
|
|
346
|
-
};
|
|
347
|
-
} else {
|
|
348
|
-
return Object.assign(id, {
|
|
349
|
-
unwrap
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
this.custom = (jsx2, data) => {
|
|
354
|
-
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
355
|
-
this.create({
|
|
356
|
-
jsx: jsx2(id),
|
|
357
|
-
id,
|
|
358
|
-
...data
|
|
359
|
-
});
|
|
360
|
-
return id;
|
|
361
|
-
};
|
|
362
|
-
this.getActiveToasts = () => {
|
|
363
|
-
return this.toasts.filter((toast2) => !this.dismissedToasts.has(toast2.id));
|
|
364
|
-
};
|
|
365
|
-
this.subscribers = [];
|
|
366
|
-
this.toasts = [];
|
|
367
|
-
this.dismissedToasts = /* @__PURE__ */ new Set();
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
const ToastState = new Observer();
|
|
371
|
-
const toastFunction = (message, data) => {
|
|
372
|
-
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
373
|
-
ToastState.addToast({
|
|
374
|
-
title: message,
|
|
375
|
-
...data,
|
|
376
|
-
id
|
|
377
|
-
});
|
|
378
|
-
return id;
|
|
379
|
-
};
|
|
380
|
-
const isHttpResponse = (data) => {
|
|
381
|
-
return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
|
|
382
|
-
};
|
|
383
|
-
const basicToast = toastFunction;
|
|
384
|
-
const getHistory = () => ToastState.toasts;
|
|
385
|
-
const getToasts = () => ToastState.getActiveToasts();
|
|
386
|
-
const toast$1 = Object.assign(basicToast, {
|
|
387
|
-
success: ToastState.success,
|
|
388
|
-
info: ToastState.info,
|
|
389
|
-
warning: ToastState.warning,
|
|
390
|
-
error: ToastState.error,
|
|
391
|
-
custom: ToastState.custom,
|
|
392
|
-
message: ToastState.message,
|
|
393
|
-
promise: ToastState.promise,
|
|
394
|
-
dismiss: ToastState.dismiss,
|
|
395
|
-
loading: ToastState.loading
|
|
396
|
-
}, {
|
|
397
|
-
getHistory,
|
|
398
|
-
getToasts
|
|
399
|
-
});
|
|
400
|
-
__insertCSS("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
|
|
401
|
-
function isAction(action) {
|
|
402
|
-
return action.label !== void 0;
|
|
403
|
-
}
|
|
404
|
-
const VISIBLE_TOASTS_AMOUNT = 3;
|
|
405
|
-
const VIEWPORT_OFFSET = "24px";
|
|
406
|
-
const MOBILE_VIEWPORT_OFFSET = "16px";
|
|
407
|
-
const TOAST_LIFETIME = 4e3;
|
|
408
|
-
const TOAST_WIDTH = 356;
|
|
409
|
-
const GAP = 14;
|
|
410
|
-
const SWIPE_THRESHOLD = 45;
|
|
411
|
-
const TIME_BEFORE_UNMOUNT = 200;
|
|
412
|
-
function cn(...classes) {
|
|
413
|
-
return classes.filter(Boolean).join(" ");
|
|
414
|
-
}
|
|
415
|
-
function getDefaultSwipeDirections(position) {
|
|
416
|
-
const [y, x] = position.split("-");
|
|
417
|
-
const directions = [];
|
|
418
|
-
if (y) {
|
|
419
|
-
directions.push(y);
|
|
420
|
-
}
|
|
421
|
-
if (x) {
|
|
422
|
-
directions.push(x);
|
|
423
|
-
}
|
|
424
|
-
return directions;
|
|
425
|
-
}
|
|
426
|
-
const Toast = (props) => {
|
|
427
|
-
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
428
|
-
const { invert: ToasterInvert, toast: toast2, unstyled, interacting, setHeights, visibleToasts, heights, index, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props;
|
|
429
|
-
const [swipeDirection, setSwipeDirection] = React__default.useState(null);
|
|
430
|
-
const [swipeOutDirection, setSwipeOutDirection] = React__default.useState(null);
|
|
431
|
-
const [mounted, setMounted] = React__default.useState(false);
|
|
432
|
-
const [removed, setRemoved] = React__default.useState(false);
|
|
433
|
-
const [swiping, setSwiping] = React__default.useState(false);
|
|
434
|
-
const [swipeOut, setSwipeOut] = React__default.useState(false);
|
|
435
|
-
const [isSwiped, setIsSwiped] = React__default.useState(false);
|
|
436
|
-
const [offsetBeforeRemove, setOffsetBeforeRemove] = React__default.useState(0);
|
|
437
|
-
const [initialHeight, setInitialHeight] = React__default.useState(0);
|
|
438
|
-
const remainingTime = React__default.useRef(toast2.duration || durationFromToaster || TOAST_LIFETIME);
|
|
439
|
-
const dragStartTime = React__default.useRef(null);
|
|
440
|
-
const toastRef = React__default.useRef(null);
|
|
441
|
-
const isFront = index === 0;
|
|
442
|
-
const isVisible = index + 1 <= visibleToasts;
|
|
443
|
-
const toastType = toast2.type;
|
|
444
|
-
const dismissible = toast2.dismissible !== false;
|
|
445
|
-
const toastClassname = toast2.className || "";
|
|
446
|
-
const toastDescriptionClassname = toast2.descriptionClassName || "";
|
|
447
|
-
const heightIndex = React__default.useMemo(() => heights.findIndex((height) => height.toastId === toast2.id) || 0, [
|
|
448
|
-
heights,
|
|
449
|
-
toast2.id
|
|
450
|
-
]);
|
|
451
|
-
const closeButton2 = React__default.useMemo(() => {
|
|
452
|
-
var _toast_closeButton;
|
|
453
|
-
return (_toast_closeButton = toast2.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
454
|
-
}, [
|
|
455
|
-
toast2.closeButton,
|
|
456
|
-
closeButtonFromToaster
|
|
457
|
-
]);
|
|
458
|
-
const duration = React__default.useMemo(() => toast2.duration || durationFromToaster || TOAST_LIFETIME, [
|
|
459
|
-
toast2.duration,
|
|
460
|
-
durationFromToaster
|
|
461
|
-
]);
|
|
462
|
-
const closeTimerStartTimeRef = React__default.useRef(0);
|
|
463
|
-
const offset = React__default.useRef(0);
|
|
464
|
-
const lastCloseTimerStartTimeRef = React__default.useRef(0);
|
|
465
|
-
const pointerStartRef = React__default.useRef(null);
|
|
466
|
-
const [y, x] = position.split("-");
|
|
467
|
-
const toastsHeightBefore = React__default.useMemo(() => {
|
|
468
|
-
return heights.reduce((prev, curr, reducerIndex) => {
|
|
469
|
-
if (reducerIndex >= heightIndex) {
|
|
470
|
-
return prev;
|
|
471
|
-
}
|
|
472
|
-
return prev + curr.height;
|
|
473
|
-
}, 0);
|
|
474
|
-
}, [
|
|
475
|
-
heights,
|
|
476
|
-
heightIndex
|
|
477
|
-
]);
|
|
478
|
-
const isDocumentHidden = useIsDocumentHidden();
|
|
479
|
-
const invert = toast2.invert || ToasterInvert;
|
|
480
|
-
const disabled = toastType === "loading";
|
|
481
|
-
offset.current = React__default.useMemo(() => heightIndex * gap + toastsHeightBefore, [
|
|
482
|
-
heightIndex,
|
|
483
|
-
toastsHeightBefore
|
|
484
|
-
]);
|
|
485
|
-
React__default.useEffect(() => {
|
|
486
|
-
remainingTime.current = duration;
|
|
487
|
-
}, [
|
|
488
|
-
duration
|
|
489
|
-
]);
|
|
490
|
-
React__default.useEffect(() => {
|
|
491
|
-
setMounted(true);
|
|
492
|
-
}, []);
|
|
493
|
-
React__default.useEffect(() => {
|
|
494
|
-
const toastNode = toastRef.current;
|
|
495
|
-
if (toastNode) {
|
|
496
|
-
const height = toastNode.getBoundingClientRect().height;
|
|
497
|
-
setInitialHeight(height);
|
|
498
|
-
setHeights((h) => [
|
|
499
|
-
{
|
|
500
|
-
toastId: toast2.id,
|
|
501
|
-
height,
|
|
502
|
-
position: toast2.position
|
|
503
|
-
},
|
|
504
|
-
...h
|
|
505
|
-
]);
|
|
506
|
-
return () => setHeights((h) => h.filter((height2) => height2.toastId !== toast2.id));
|
|
507
|
-
}
|
|
508
|
-
}, [
|
|
509
|
-
setHeights,
|
|
510
|
-
toast2.id
|
|
511
|
-
]);
|
|
512
|
-
React__default.useLayoutEffect(() => {
|
|
513
|
-
if (!mounted) return;
|
|
514
|
-
const toastNode = toastRef.current;
|
|
515
|
-
const originalHeight = toastNode.style.height;
|
|
516
|
-
toastNode.style.height = "auto";
|
|
517
|
-
const newHeight = toastNode.getBoundingClientRect().height;
|
|
518
|
-
toastNode.style.height = originalHeight;
|
|
519
|
-
setInitialHeight(newHeight);
|
|
520
|
-
setHeights((heights2) => {
|
|
521
|
-
const alreadyExists = heights2.find((height) => height.toastId === toast2.id);
|
|
522
|
-
if (!alreadyExists) {
|
|
523
|
-
return [
|
|
524
|
-
{
|
|
525
|
-
toastId: toast2.id,
|
|
526
|
-
height: newHeight,
|
|
527
|
-
position: toast2.position
|
|
528
|
-
},
|
|
529
|
-
...heights2
|
|
530
|
-
];
|
|
531
|
-
} else {
|
|
532
|
-
return heights2.map((height) => height.toastId === toast2.id ? {
|
|
533
|
-
...height,
|
|
534
|
-
height: newHeight
|
|
535
|
-
} : height);
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
}, [
|
|
539
|
-
mounted,
|
|
540
|
-
toast2.title,
|
|
541
|
-
toast2.description,
|
|
542
|
-
setHeights,
|
|
543
|
-
toast2.id,
|
|
544
|
-
toast2.jsx,
|
|
545
|
-
toast2.action,
|
|
546
|
-
toast2.cancel
|
|
547
|
-
]);
|
|
548
|
-
const deleteToast = React__default.useCallback(() => {
|
|
549
|
-
setRemoved(true);
|
|
550
|
-
setOffsetBeforeRemove(offset.current);
|
|
551
|
-
setHeights((h) => h.filter((height) => height.toastId !== toast2.id));
|
|
552
|
-
setTimeout(() => {
|
|
553
|
-
removeToast(toast2);
|
|
554
|
-
}, TIME_BEFORE_UNMOUNT);
|
|
555
|
-
}, [
|
|
556
|
-
toast2,
|
|
557
|
-
removeToast,
|
|
558
|
-
setHeights,
|
|
559
|
-
offset
|
|
560
|
-
]);
|
|
561
|
-
React__default.useEffect(() => {
|
|
562
|
-
if (toast2.promise && toastType === "loading" || toast2.duration === Infinity || toast2.type === "loading") return;
|
|
563
|
-
let timeoutId;
|
|
564
|
-
const pauseTimer = () => {
|
|
565
|
-
if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
|
|
566
|
-
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
567
|
-
remainingTime.current = remainingTime.current - elapsedTime;
|
|
568
|
-
}
|
|
569
|
-
lastCloseTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
570
|
-
};
|
|
571
|
-
const startTimer = () => {
|
|
572
|
-
if (remainingTime.current === Infinity) return;
|
|
573
|
-
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
574
|
-
timeoutId = setTimeout(() => {
|
|
575
|
-
toast2.onAutoClose == null ? void 0 : toast2.onAutoClose.call(toast2, toast2);
|
|
576
|
-
deleteToast();
|
|
577
|
-
}, remainingTime.current);
|
|
578
|
-
};
|
|
579
|
-
if (expanded || interacting || isDocumentHidden) {
|
|
580
|
-
pauseTimer();
|
|
581
|
-
} else {
|
|
582
|
-
startTimer();
|
|
583
|
-
}
|
|
584
|
-
return () => clearTimeout(timeoutId);
|
|
585
|
-
}, [
|
|
586
|
-
expanded,
|
|
587
|
-
interacting,
|
|
588
|
-
toast2,
|
|
589
|
-
toastType,
|
|
590
|
-
isDocumentHidden,
|
|
591
|
-
deleteToast
|
|
592
|
-
]);
|
|
593
|
-
React__default.useEffect(() => {
|
|
594
|
-
if (toast2.delete) {
|
|
595
|
-
deleteToast();
|
|
596
|
-
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
597
|
-
}
|
|
598
|
-
}, [
|
|
599
|
-
deleteToast,
|
|
600
|
-
toast2.delete
|
|
601
|
-
]);
|
|
602
|
-
function getLoadingIcon() {
|
|
603
|
-
var _toast_classNames9;
|
|
604
|
-
if (icons == null ? void 0 : icons.loading) {
|
|
605
|
-
var _toast_classNames12;
|
|
606
|
-
return /* @__PURE__ */ React__default.createElement("div", {
|
|
607
|
-
className: cn(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames12 = toast2.classNames) == null ? void 0 : _toast_classNames12.loader, "sonner-loader"),
|
|
608
|
-
"data-visible": toastType === "loading"
|
|
609
|
-
}, icons.loading);
|
|
610
|
-
}
|
|
611
|
-
return /* @__PURE__ */ React__default.createElement(Loader, {
|
|
612
|
-
className: cn(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames9 = toast2.classNames) == null ? void 0 : _toast_classNames9.loader),
|
|
613
|
-
visible: toastType === "loading"
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
const icon = toast2.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
617
|
-
var _toast_richColors, _icons_close;
|
|
618
|
-
return /* @__PURE__ */ React__default.createElement("li", {
|
|
619
|
-
tabIndex: 0,
|
|
620
|
-
ref: toastRef,
|
|
621
|
-
className: cn(className, toastClassname, classNames == null ? void 0 : classNames.toast, toast2 == null ? void 0 : (_toast_classNames = toast2.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames.default, classNames == null ? void 0 : classNames[toastType], toast2 == null ? void 0 : (_toast_classNames1 = toast2.classNames) == null ? void 0 : _toast_classNames1[toastType]),
|
|
622
|
-
"data-sonner-toast": "",
|
|
623
|
-
"data-rich-colors": (_toast_richColors = toast2.richColors) != null ? _toast_richColors : defaultRichColors,
|
|
624
|
-
"data-styled": !Boolean(toast2.jsx || toast2.unstyled || unstyled),
|
|
625
|
-
"data-mounted": mounted,
|
|
626
|
-
"data-promise": Boolean(toast2.promise),
|
|
627
|
-
"data-swiped": isSwiped,
|
|
628
|
-
"data-removed": removed,
|
|
629
|
-
"data-visible": isVisible,
|
|
630
|
-
"data-y-position": y,
|
|
631
|
-
"data-x-position": x,
|
|
632
|
-
"data-index": index,
|
|
633
|
-
"data-front": isFront,
|
|
634
|
-
"data-swiping": swiping,
|
|
635
|
-
"data-dismissible": dismissible,
|
|
636
|
-
"data-type": toastType,
|
|
637
|
-
"data-invert": invert,
|
|
638
|
-
"data-swipe-out": swipeOut,
|
|
639
|
-
"data-swipe-direction": swipeOutDirection,
|
|
640
|
-
"data-expanded": Boolean(expanded || expandByDefault && mounted),
|
|
641
|
-
"data-testid": toast2.testId,
|
|
642
|
-
style: {
|
|
643
|
-
"--index": index,
|
|
644
|
-
"--toasts-before": index,
|
|
645
|
-
"--z-index": toasts.length - index,
|
|
646
|
-
"--offset": `${removed ? offsetBeforeRemove : offset.current}px`,
|
|
647
|
-
"--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
|
|
648
|
-
...style,
|
|
649
|
-
...toast2.style
|
|
650
|
-
},
|
|
651
|
-
onDragEnd: () => {
|
|
652
|
-
setSwiping(false);
|
|
653
|
-
setSwipeDirection(null);
|
|
654
|
-
pointerStartRef.current = null;
|
|
655
|
-
},
|
|
656
|
-
onPointerDown: (event) => {
|
|
657
|
-
if (event.button === 2) return;
|
|
658
|
-
if (disabled || !dismissible) return;
|
|
659
|
-
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
660
|
-
setOffsetBeforeRemove(offset.current);
|
|
661
|
-
event.target.setPointerCapture(event.pointerId);
|
|
662
|
-
if (event.target.tagName === "BUTTON") return;
|
|
663
|
-
setSwiping(true);
|
|
664
|
-
pointerStartRef.current = {
|
|
665
|
-
x: event.clientX,
|
|
666
|
-
y: event.clientY
|
|
667
|
-
};
|
|
668
|
-
},
|
|
669
|
-
onPointerUp: () => {
|
|
670
|
-
var _toastRef_current, _toastRef_current1, _dragStartTime_current;
|
|
671
|
-
if (swipeOut || !dismissible) return;
|
|
672
|
-
pointerStartRef.current = null;
|
|
673
|
-
const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0);
|
|
674
|
-
const swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0);
|
|
675
|
-
const timeTaken = (/* @__PURE__ */ new Date()).getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? void 0 : _dragStartTime_current.getTime());
|
|
676
|
-
const swipeAmount = swipeDirection === "x" ? swipeAmountX : swipeAmountY;
|
|
677
|
-
const velocity = Math.abs(swipeAmount) / timeTaken;
|
|
678
|
-
if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
|
|
679
|
-
setOffsetBeforeRemove(offset.current);
|
|
680
|
-
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
681
|
-
if (swipeDirection === "x") {
|
|
682
|
-
setSwipeOutDirection(swipeAmountX > 0 ? "right" : "left");
|
|
683
|
-
} else {
|
|
684
|
-
setSwipeOutDirection(swipeAmountY > 0 ? "down" : "up");
|
|
685
|
-
}
|
|
686
|
-
deleteToast();
|
|
687
|
-
setSwipeOut(true);
|
|
688
|
-
return;
|
|
689
|
-
} else {
|
|
690
|
-
var _toastRef_current2, _toastRef_current3;
|
|
691
|
-
(_toastRef_current2 = toastRef.current) == null ? void 0 : _toastRef_current2.style.setProperty("--swipe-amount-x", `0px`);
|
|
692
|
-
(_toastRef_current3 = toastRef.current) == null ? void 0 : _toastRef_current3.style.setProperty("--swipe-amount-y", `0px`);
|
|
693
|
-
}
|
|
694
|
-
setIsSwiped(false);
|
|
695
|
-
setSwiping(false);
|
|
696
|
-
setSwipeDirection(null);
|
|
697
|
-
},
|
|
698
|
-
onPointerMove: (event) => {
|
|
699
|
-
var _window_getSelection, _toastRef_current, _toastRef_current1;
|
|
700
|
-
if (!pointerStartRef.current || !dismissible) return;
|
|
701
|
-
const isHighlighted = ((_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString().length) > 0;
|
|
702
|
-
if (isHighlighted) return;
|
|
703
|
-
const yDelta = event.clientY - pointerStartRef.current.y;
|
|
704
|
-
const xDelta = event.clientX - pointerStartRef.current.x;
|
|
705
|
-
var _props_swipeDirections;
|
|
706
|
-
const swipeDirections = (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
|
|
707
|
-
if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {
|
|
708
|
-
setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? "x" : "y");
|
|
709
|
-
}
|
|
710
|
-
let swipeAmount = {
|
|
711
|
-
x: 0,
|
|
712
|
-
y: 0
|
|
713
|
-
};
|
|
714
|
-
const getDampening = (delta) => {
|
|
715
|
-
const factor = Math.abs(delta) / 20;
|
|
716
|
-
return 1 / (1.5 + factor);
|
|
717
|
-
};
|
|
718
|
-
if (swipeDirection === "y") {
|
|
719
|
-
if (swipeDirections.includes("top") || swipeDirections.includes("bottom")) {
|
|
720
|
-
if (swipeDirections.includes("top") && yDelta < 0 || swipeDirections.includes("bottom") && yDelta > 0) {
|
|
721
|
-
swipeAmount.y = yDelta;
|
|
722
|
-
} else {
|
|
723
|
-
const dampenedDelta = yDelta * getDampening(yDelta);
|
|
724
|
-
swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
} else if (swipeDirection === "x") {
|
|
728
|
-
if (swipeDirections.includes("left") || swipeDirections.includes("right")) {
|
|
729
|
-
if (swipeDirections.includes("left") && xDelta < 0 || swipeDirections.includes("right") && xDelta > 0) {
|
|
730
|
-
swipeAmount.x = xDelta;
|
|
731
|
-
} else {
|
|
732
|
-
const dampenedDelta = xDelta * getDampening(xDelta);
|
|
733
|
-
swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) {
|
|
738
|
-
setIsSwiped(true);
|
|
739
|
-
}
|
|
740
|
-
(_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
|
|
741
|
-
(_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
|
|
742
|
-
}
|
|
743
|
-
}, closeButton2 && !toast2.jsx && toastType !== "loading" ? /* @__PURE__ */ React__default.createElement("button", {
|
|
744
|
-
"aria-label": closeButtonAriaLabel,
|
|
745
|
-
"data-disabled": disabled,
|
|
746
|
-
"data-close-button": true,
|
|
747
|
-
onClick: disabled || !dismissible ? () => {
|
|
748
|
-
} : () => {
|
|
749
|
-
deleteToast();
|
|
750
|
-
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
751
|
-
},
|
|
752
|
-
className: cn(classNames == null ? void 0 : classNames.closeButton, toast2 == null ? void 0 : (_toast_classNames2 = toast2.classNames) == null ? void 0 : _toast_classNames2.closeButton)
|
|
753
|
-
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast2.icon || toast2.promise) && toast2.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast2.icon) ? /* @__PURE__ */ React__default.createElement("div", {
|
|
754
|
-
"data-icon": "",
|
|
755
|
-
className: cn(classNames == null ? void 0 : classNames.icon, toast2 == null ? void 0 : (_toast_classNames3 = toast2.classNames) == null ? void 0 : _toast_classNames3.icon)
|
|
756
|
-
}, toast2.promise || toast2.type === "loading" && !toast2.icon ? toast2.icon || getLoadingIcon() : null, toast2.type !== "loading" ? icon : null) : null, /* @__PURE__ */ React__default.createElement("div", {
|
|
757
|
-
"data-content": "",
|
|
758
|
-
className: cn(classNames == null ? void 0 : classNames.content, toast2 == null ? void 0 : (_toast_classNames4 = toast2.classNames) == null ? void 0 : _toast_classNames4.content)
|
|
759
|
-
}, /* @__PURE__ */ React__default.createElement("div", {
|
|
760
|
-
"data-title": "",
|
|
761
|
-
className: cn(classNames == null ? void 0 : classNames.title, toast2 == null ? void 0 : (_toast_classNames5 = toast2.classNames) == null ? void 0 : _toast_classNames5.title)
|
|
762
|
-
}, toast2.jsx ? toast2.jsx : typeof toast2.title === "function" ? toast2.title() : toast2.title), toast2.description ? /* @__PURE__ */ React__default.createElement("div", {
|
|
763
|
-
"data-description": "",
|
|
764
|
-
className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast2 == null ? void 0 : (_toast_classNames6 = toast2.classNames) == null ? void 0 : _toast_classNames6.description)
|
|
765
|
-
}, typeof toast2.description === "function" ? toast2.description() : toast2.description) : null), /* @__PURE__ */ React__default.isValidElement(toast2.cancel) ? toast2.cancel : toast2.cancel && isAction(toast2.cancel) ? /* @__PURE__ */ React__default.createElement("button", {
|
|
766
|
-
"data-button": true,
|
|
767
|
-
"data-cancel": true,
|
|
768
|
-
style: toast2.cancelButtonStyle || cancelButtonStyle,
|
|
769
|
-
onClick: (event) => {
|
|
770
|
-
if (!isAction(toast2.cancel)) return;
|
|
771
|
-
if (!dismissible) return;
|
|
772
|
-
toast2.cancel.onClick == null ? void 0 : toast2.cancel.onClick.call(toast2.cancel, event);
|
|
773
|
-
deleteToast();
|
|
774
|
-
},
|
|
775
|
-
className: cn(classNames == null ? void 0 : classNames.cancelButton, toast2 == null ? void 0 : (_toast_classNames7 = toast2.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
|
|
776
|
-
}, toast2.cancel.label) : null, /* @__PURE__ */ React__default.isValidElement(toast2.action) ? toast2.action : toast2.action && isAction(toast2.action) ? /* @__PURE__ */ React__default.createElement("button", {
|
|
777
|
-
"data-button": true,
|
|
778
|
-
"data-action": true,
|
|
779
|
-
style: toast2.actionButtonStyle || actionButtonStyle,
|
|
780
|
-
onClick: (event) => {
|
|
781
|
-
if (!isAction(toast2.action)) return;
|
|
782
|
-
toast2.action.onClick == null ? void 0 : toast2.action.onClick.call(toast2.action, event);
|
|
783
|
-
if (event.defaultPrevented) return;
|
|
784
|
-
deleteToast();
|
|
785
|
-
},
|
|
786
|
-
className: cn(classNames == null ? void 0 : classNames.actionButton, toast2 == null ? void 0 : (_toast_classNames8 = toast2.classNames) == null ? void 0 : _toast_classNames8.actionButton)
|
|
787
|
-
}, toast2.action.label) : null);
|
|
788
|
-
};
|
|
789
|
-
function getDocumentDirection() {
|
|
790
|
-
if (typeof window === "undefined") return "ltr";
|
|
791
|
-
if (typeof document === "undefined") return "ltr";
|
|
792
|
-
const dirAttribute = document.documentElement.getAttribute("dir");
|
|
793
|
-
if (dirAttribute === "auto" || !dirAttribute) {
|
|
794
|
-
return window.getComputedStyle(document.documentElement).direction;
|
|
795
|
-
}
|
|
796
|
-
return dirAttribute;
|
|
797
|
-
}
|
|
798
|
-
function assignOffset(defaultOffset, mobileOffset) {
|
|
799
|
-
const styles2 = {};
|
|
800
|
-
[
|
|
801
|
-
defaultOffset,
|
|
802
|
-
mobileOffset
|
|
803
|
-
].forEach((offset, index) => {
|
|
804
|
-
const isMobile = index === 1;
|
|
805
|
-
const prefix = isMobile ? "--mobile-offset" : "--offset";
|
|
806
|
-
const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
|
|
807
|
-
function assignAll(offset2) {
|
|
808
|
-
[
|
|
809
|
-
"top",
|
|
810
|
-
"right",
|
|
811
|
-
"bottom",
|
|
812
|
-
"left"
|
|
813
|
-
].forEach((key) => {
|
|
814
|
-
styles2[`${prefix}-${key}`] = typeof offset2 === "number" ? `${offset2}px` : offset2;
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
if (typeof offset === "number" || typeof offset === "string") {
|
|
818
|
-
assignAll(offset);
|
|
819
|
-
} else if (typeof offset === "object") {
|
|
820
|
-
[
|
|
821
|
-
"top",
|
|
822
|
-
"right",
|
|
823
|
-
"bottom",
|
|
824
|
-
"left"
|
|
825
|
-
].forEach((key) => {
|
|
826
|
-
if (offset[key] === void 0) {
|
|
827
|
-
styles2[`${prefix}-${key}`] = defaultValue;
|
|
828
|
-
} else {
|
|
829
|
-
styles2[`${prefix}-${key}`] = typeof offset[key] === "number" ? `${offset[key]}px` : offset[key];
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
} else {
|
|
833
|
-
assignAll(defaultValue);
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
return styles2;
|
|
837
|
-
}
|
|
838
|
-
const Toaster = /* @__PURE__ */ React__default.forwardRef(function Toaster2(props, ref) {
|
|
839
|
-
const { id, invert, position = "bottom-right", hotkey = [
|
|
840
|
-
"altKey",
|
|
841
|
-
"KeyT"
|
|
842
|
-
], expand, closeButton: closeButton2, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, containerAriaLabel = "Notifications" } = props;
|
|
843
|
-
const [toasts, setToasts] = React__default.useState([]);
|
|
844
|
-
const filteredToasts = React__default.useMemo(() => {
|
|
845
|
-
if (id) {
|
|
846
|
-
return toasts.filter((toast2) => toast2.toasterId === id);
|
|
847
|
-
}
|
|
848
|
-
return toasts.filter((toast2) => !toast2.toasterId);
|
|
849
|
-
}, [
|
|
850
|
-
toasts,
|
|
851
|
-
id
|
|
852
|
-
]);
|
|
853
|
-
const possiblePositions = React__default.useMemo(() => {
|
|
854
|
-
return Array.from(new Set([
|
|
855
|
-
position
|
|
856
|
-
].concat(filteredToasts.filter((toast2) => toast2.position).map((toast2) => toast2.position))));
|
|
857
|
-
}, [
|
|
858
|
-
filteredToasts,
|
|
859
|
-
position
|
|
860
|
-
]);
|
|
861
|
-
const [heights, setHeights] = React__default.useState([]);
|
|
862
|
-
const [expanded, setExpanded] = React__default.useState(false);
|
|
863
|
-
const [interacting, setInteracting] = React__default.useState(false);
|
|
864
|
-
const [actualTheme, setActualTheme] = React__default.useState(theme !== "system" ? theme : typeof window !== "undefined" ? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : "light");
|
|
865
|
-
const listRef = React__default.useRef(null);
|
|
866
|
-
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
867
|
-
const lastFocusedElementRef = React__default.useRef(null);
|
|
868
|
-
const isFocusWithinRef = React__default.useRef(false);
|
|
869
|
-
const removeToast = React__default.useCallback((toastToRemove) => {
|
|
870
|
-
setToasts((toasts2) => {
|
|
871
|
-
var _toasts_find;
|
|
872
|
-
if (!((_toasts_find = toasts2.find((toast2) => toast2.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) {
|
|
873
|
-
ToastState.dismiss(toastToRemove.id);
|
|
874
|
-
}
|
|
875
|
-
return toasts2.filter(({ id: id2 }) => id2 !== toastToRemove.id);
|
|
876
|
-
});
|
|
877
|
-
}, []);
|
|
878
|
-
React__default.useEffect(() => {
|
|
879
|
-
return ToastState.subscribe((toast2) => {
|
|
880
|
-
if (toast2.dismiss) {
|
|
881
|
-
requestAnimationFrame(() => {
|
|
882
|
-
setToasts((toasts2) => toasts2.map((t) => t.id === toast2.id ? {
|
|
883
|
-
...t,
|
|
884
|
-
delete: true
|
|
885
|
-
} : t));
|
|
886
|
-
});
|
|
887
|
-
return;
|
|
888
|
-
}
|
|
889
|
-
setTimeout(() => {
|
|
890
|
-
ReactDOM__default.flushSync(() => {
|
|
891
|
-
setToasts((toasts2) => {
|
|
892
|
-
const indexOfExistingToast = toasts2.findIndex((t) => t.id === toast2.id);
|
|
893
|
-
if (indexOfExistingToast !== -1) {
|
|
894
|
-
return [
|
|
895
|
-
...toasts2.slice(0, indexOfExistingToast),
|
|
896
|
-
{
|
|
897
|
-
...toasts2[indexOfExistingToast],
|
|
898
|
-
...toast2
|
|
899
|
-
},
|
|
900
|
-
...toasts2.slice(indexOfExistingToast + 1)
|
|
901
|
-
];
|
|
902
|
-
}
|
|
903
|
-
return [
|
|
904
|
-
toast2,
|
|
905
|
-
...toasts2
|
|
906
|
-
];
|
|
907
|
-
});
|
|
908
|
-
});
|
|
909
|
-
});
|
|
910
|
-
});
|
|
911
|
-
}, [
|
|
912
|
-
toasts
|
|
913
|
-
]);
|
|
914
|
-
React__default.useEffect(() => {
|
|
915
|
-
if (theme !== "system") {
|
|
916
|
-
setActualTheme(theme);
|
|
917
|
-
return;
|
|
918
|
-
}
|
|
919
|
-
if (theme === "system") {
|
|
920
|
-
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
921
|
-
setActualTheme("dark");
|
|
922
|
-
} else {
|
|
923
|
-
setActualTheme("light");
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
if (typeof window === "undefined") return;
|
|
927
|
-
const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
928
|
-
try {
|
|
929
|
-
darkMediaQuery.addEventListener("change", ({ matches }) => {
|
|
930
|
-
if (matches) {
|
|
931
|
-
setActualTheme("dark");
|
|
932
|
-
} else {
|
|
933
|
-
setActualTheme("light");
|
|
934
|
-
}
|
|
935
|
-
});
|
|
936
|
-
} catch (error) {
|
|
937
|
-
darkMediaQuery.addListener(({ matches }) => {
|
|
938
|
-
try {
|
|
939
|
-
if (matches) {
|
|
940
|
-
setActualTheme("dark");
|
|
941
|
-
} else {
|
|
942
|
-
setActualTheme("light");
|
|
943
|
-
}
|
|
944
|
-
} catch (e) {
|
|
945
|
-
console.error(e);
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
}, [
|
|
950
|
-
theme
|
|
951
|
-
]);
|
|
952
|
-
React__default.useEffect(() => {
|
|
953
|
-
if (toasts.length <= 1) {
|
|
954
|
-
setExpanded(false);
|
|
955
|
-
}
|
|
956
|
-
}, [
|
|
957
|
-
toasts
|
|
958
|
-
]);
|
|
959
|
-
React__default.useEffect(() => {
|
|
960
|
-
const handleKeyDown = (event) => {
|
|
961
|
-
var _listRef_current;
|
|
962
|
-
const isHotkeyPressed = hotkey.every((key) => event[key] || event.code === key);
|
|
963
|
-
if (isHotkeyPressed) {
|
|
964
|
-
var _listRef_current1;
|
|
965
|
-
setExpanded(true);
|
|
966
|
-
(_listRef_current1 = listRef.current) == null ? void 0 : _listRef_current1.focus();
|
|
967
|
-
}
|
|
968
|
-
if (event.code === "Escape" && (document.activeElement === listRef.current || ((_listRef_current = listRef.current) == null ? void 0 : _listRef_current.contains(document.activeElement)))) {
|
|
969
|
-
setExpanded(false);
|
|
970
|
-
}
|
|
971
|
-
};
|
|
972
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
973
|
-
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
974
|
-
}, [
|
|
975
|
-
hotkey
|
|
976
|
-
]);
|
|
977
|
-
React__default.useEffect(() => {
|
|
978
|
-
if (listRef.current) {
|
|
979
|
-
return () => {
|
|
980
|
-
if (lastFocusedElementRef.current) {
|
|
981
|
-
lastFocusedElementRef.current.focus({
|
|
982
|
-
preventScroll: true
|
|
983
|
-
});
|
|
984
|
-
lastFocusedElementRef.current = null;
|
|
985
|
-
isFocusWithinRef.current = false;
|
|
986
|
-
}
|
|
987
|
-
};
|
|
988
|
-
}
|
|
989
|
-
}, [
|
|
990
|
-
listRef.current
|
|
991
|
-
]);
|
|
992
|
-
return (
|
|
993
|
-
// Remove item from normal navigation flow, only available via hotkey
|
|
994
|
-
/* @__PURE__ */ React__default.createElement("section", {
|
|
995
|
-
ref,
|
|
996
|
-
"aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
|
|
997
|
-
tabIndex: -1,
|
|
998
|
-
"aria-live": "polite",
|
|
999
|
-
"aria-relevant": "additions text",
|
|
1000
|
-
"aria-atomic": "false",
|
|
1001
|
-
suppressHydrationWarning: true
|
|
1002
|
-
}, possiblePositions.map((position2, index) => {
|
|
1003
|
-
var _heights_;
|
|
1004
|
-
const [y, x] = position2.split("-");
|
|
1005
|
-
if (!filteredToasts.length) return null;
|
|
1006
|
-
return /* @__PURE__ */ React__default.createElement("ol", {
|
|
1007
|
-
key: position2,
|
|
1008
|
-
dir: dir === "auto" ? getDocumentDirection() : dir,
|
|
1009
|
-
tabIndex: -1,
|
|
1010
|
-
ref: listRef,
|
|
1011
|
-
className,
|
|
1012
|
-
"data-sonner-toaster": true,
|
|
1013
|
-
"data-sonner-theme": actualTheme,
|
|
1014
|
-
"data-y-position": y,
|
|
1015
|
-
"data-x-position": x,
|
|
1016
|
-
style: {
|
|
1017
|
-
"--front-toast-height": `${((_heights_ = heights[0]) == null ? void 0 : _heights_.height) || 0}px`,
|
|
1018
|
-
"--width": `${TOAST_WIDTH}px`,
|
|
1019
|
-
"--gap": `${gap}px`,
|
|
1020
|
-
...style,
|
|
1021
|
-
...assignOffset(offset, mobileOffset)
|
|
1022
|
-
},
|
|
1023
|
-
onBlur: (event) => {
|
|
1024
|
-
if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {
|
|
1025
|
-
isFocusWithinRef.current = false;
|
|
1026
|
-
if (lastFocusedElementRef.current) {
|
|
1027
|
-
lastFocusedElementRef.current.focus({
|
|
1028
|
-
preventScroll: true
|
|
1029
|
-
});
|
|
1030
|
-
lastFocusedElementRef.current = null;
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
},
|
|
1034
|
-
onFocus: (event) => {
|
|
1035
|
-
const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
|
|
1036
|
-
if (isNotDismissible) return;
|
|
1037
|
-
if (!isFocusWithinRef.current) {
|
|
1038
|
-
isFocusWithinRef.current = true;
|
|
1039
|
-
lastFocusedElementRef.current = event.relatedTarget;
|
|
1040
|
-
}
|
|
1041
|
-
},
|
|
1042
|
-
onMouseEnter: () => setExpanded(true),
|
|
1043
|
-
onMouseMove: () => setExpanded(true),
|
|
1044
|
-
onMouseLeave: () => {
|
|
1045
|
-
if (!interacting) {
|
|
1046
|
-
setExpanded(false);
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
onDragEnd: () => setExpanded(false),
|
|
1050
|
-
onPointerDown: (event) => {
|
|
1051
|
-
const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
|
|
1052
|
-
if (isNotDismissible) return;
|
|
1053
|
-
setInteracting(true);
|
|
1054
|
-
},
|
|
1055
|
-
onPointerUp: () => setInteracting(false)
|
|
1056
|
-
}, filteredToasts.filter((toast2) => !toast2.position && index === 0 || toast2.position === position2).map((toast2, index2) => {
|
|
1057
|
-
var _toastOptions_duration, _toastOptions_closeButton;
|
|
1058
|
-
return /* @__PURE__ */ React__default.createElement(Toast, {
|
|
1059
|
-
key: toast2.id,
|
|
1060
|
-
icons,
|
|
1061
|
-
index: index2,
|
|
1062
|
-
toast: toast2,
|
|
1063
|
-
defaultRichColors: richColors,
|
|
1064
|
-
duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
|
|
1065
|
-
className: toastOptions == null ? void 0 : toastOptions.className,
|
|
1066
|
-
descriptionClassName: toastOptions == null ? void 0 : toastOptions.descriptionClassName,
|
|
1067
|
-
invert,
|
|
1068
|
-
visibleToasts,
|
|
1069
|
-
closeButton: (_toastOptions_closeButton = toastOptions == null ? void 0 : toastOptions.closeButton) != null ? _toastOptions_closeButton : closeButton2,
|
|
1070
|
-
interacting,
|
|
1071
|
-
position: position2,
|
|
1072
|
-
style: toastOptions == null ? void 0 : toastOptions.style,
|
|
1073
|
-
unstyled: toastOptions == null ? void 0 : toastOptions.unstyled,
|
|
1074
|
-
classNames: toastOptions == null ? void 0 : toastOptions.classNames,
|
|
1075
|
-
cancelButtonStyle: toastOptions == null ? void 0 : toastOptions.cancelButtonStyle,
|
|
1076
|
-
actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
|
|
1077
|
-
closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
|
|
1078
|
-
removeToast,
|
|
1079
|
-
toasts: filteredToasts.filter((t) => t.position == toast2.position),
|
|
1080
|
-
heights: heights.filter((h) => h.position == toast2.position),
|
|
1081
|
-
setHeights,
|
|
1082
|
-
expandByDefault: expand,
|
|
1083
|
-
gap,
|
|
1084
|
-
expanded,
|
|
1085
|
-
swipeDirections: props.swipeDirections
|
|
1086
|
-
});
|
|
1087
|
-
}));
|
|
1088
|
-
}))
|
|
1089
|
-
);
|
|
1090
|
-
});
|
|
1091
|
-
const toast = "toast__JkBNR";
|
|
1092
|
-
const title = "title__GML0C";
|
|
1093
|
-
const critical = "critical__3Bvx3";
|
|
1094
|
-
const actionButton = "actionButton__-9sR3";
|
|
1095
|
-
const closeButton = "closeButton__KzpIU";
|
|
1096
|
-
const styles = {
|
|
1097
|
-
toast,
|
|
1098
|
-
title,
|
|
1099
|
-
critical,
|
|
1100
|
-
actionButton,
|
|
1101
|
-
closeButton
|
|
1102
|
-
};
|
|
1103
|
-
const SvgClose = ({
|
|
1104
|
-
title: title2,
|
|
1105
|
-
titleId,
|
|
1106
|
-
...props
|
|
1107
|
-
}, ref) => /* @__PURE__ */ React.createElement("svg", { "data-preply-ds-component": "SvgTokyoUIIcon", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", ref, "aria-labelledby": titleId, ...props }, title2 ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title2) : null, /* @__PURE__ */ React.createElement("path", { fillRule: "evenodd", d: "M7.044 5.63 5.63 7.044l4.95 4.95-4.95 4.95 1.414 1.414 4.95-4.95 4.95 4.95 1.414-1.414-4.95-4.95 4.95-4.95-1.414-1.414-4.95 4.95-4.95-4.95Z", clipRule: "evenodd" }));
|
|
1108
|
-
const ForwardRef$1 = forwardRef(SvgClose);
|
|
1109
|
-
const SvgError = ({
|
|
1110
|
-
title: title2,
|
|
1111
|
-
titleId,
|
|
1112
|
-
...props
|
|
1113
|
-
}, ref) => /* @__PURE__ */ React.createElement("svg", { "data-preply-ds-component": "SvgTokyoUIIcon", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", ref, "aria-labelledby": titleId, ...props }, title2 ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title2) : null, /* @__PURE__ */ React.createElement("path", { fillRule: "evenodd", d: "M15.728 3H8.272L3 8.272v7.456L8.272 21h7.456L21 15.728V8.272L15.728 3ZM10.98 8.04l.144 5.532h1.788l.144-5.532H10.98Zm.264 8.268c.216.216.476.324.78.324.296 0 .552-.108.768-.324a1.09 1.09 0 0 0 0-1.548 1.031 1.031 0 0 0-.768-.336c-.304 0-.564.112-.78.336a1.09 1.09 0 0 0 0 1.548Z", clipRule: "evenodd" }));
|
|
1114
|
-
const ForwardRef = forwardRef(SvgError);
|
|
1115
|
-
const InternalToastProvider = ({
|
|
1116
|
-
duration = 5e3
|
|
1117
|
-
}) => /* @__PURE__ */ jsx(Toaster, { position: "top-right", duration, visibleToasts: 3 });
|
|
1118
|
-
const ToastProvider = InternalToastProvider.bind(null, {
|
|
1119
|
-
duration: 5e3
|
|
1120
|
-
});
|
|
1121
|
-
const CloseButton = ({
|
|
1122
|
-
onClick
|
|
1123
|
-
}) => {
|
|
1124
|
-
const {
|
|
1125
|
-
formatMessage
|
|
1126
|
-
} = useIntl();
|
|
1127
|
-
return /* @__PURE__ */ jsx("button", { onClick, className: styles.closeButton, "aria-label": formatMessage(genericAriaLabels.close), children: /* @__PURE__ */ jsx(Icon, { svg: ForwardRef$1 }) });
|
|
1128
|
-
};
|
|
1129
|
-
function showToast(message, props) {
|
|
1130
|
-
const {
|
|
1131
|
-
variant = "info",
|
|
1132
|
-
leadingSvgIcon,
|
|
1133
|
-
actionLabel,
|
|
1134
|
-
actionOnClick,
|
|
1135
|
-
actionHref,
|
|
1136
|
-
dataset
|
|
1137
|
-
} = props != null ? props : {};
|
|
1138
|
-
const Action = actionHref ? "a" : "button";
|
|
1139
|
-
return toast$1.custom((id) => /* @__PURE__ */ jsxs(
|
|
1140
|
-
"div",
|
|
1141
|
-
{
|
|
1142
|
-
style: {
|
|
1143
|
-
display: "contents"
|
|
1144
|
-
},
|
|
1145
|
-
...getDatasetProps(dataset, {
|
|
1146
|
-
preplyDsComponent: webComponentNames.Toast
|
|
1147
|
-
}),
|
|
1148
|
-
children: [
|
|
1149
|
-
variant === "critical" ? /* @__PURE__ */ jsx(Icon, { svg: ForwardRef }) : leadingSvgIcon && /* @__PURE__ */ jsx(Icon, { svg: leadingSvgIcon }),
|
|
1150
|
-
/* @__PURE__ */ jsx("span", { className: styles.title, children: message }),
|
|
1151
|
-
/* @__PURE__ */ jsx(CloseButton, { onClick: () => toast$1.dismiss(id) }),
|
|
1152
|
-
actionLabel && /* @__PURE__ */ jsx(Action, { className: styles.actionButton, onClick: () => {
|
|
1153
|
-
toast$1.dismiss(id);
|
|
1154
|
-
actionOnClick == null ? void 0 : actionOnClick();
|
|
1155
|
-
}, href: actionHref, children: actionLabel })
|
|
1156
|
-
]
|
|
1157
|
-
}
|
|
1158
|
-
), {
|
|
1159
|
-
classNames: {
|
|
1160
|
-
toast: variant === "critical" ? `${styles.toast} ${styles.critical}` : styles.toast
|
|
1161
|
-
}
|
|
1162
|
-
});
|
|
1163
|
-
}
|
|
1164
|
-
export {
|
|
1165
|
-
InternalToastProvider,
|
|
1166
|
-
ToastProvider,
|
|
1167
|
-
showToast
|
|
1168
|
-
};
|
|
1
|
+
import "../../render-icon-Ch3b2dE0.js";
|
|
2
|
+
import "../../jsx-runtime-i4KUlhDu.js";
|
|
3
|
+
import { n as ToastProvider, r as showToast, t as InternalToastProvider } from "../../Toast-wJAjSLfo.js";
|
|
4
|
+
export { InternalToastProvider, ToastProvider, showToast };
|