@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
|
@@ -0,0 +1,1019 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as Icon } from "./Icon-CixAeOSd.js";
|
|
3
|
+
import { t as require_jsx_runtime } from "./jsx-runtime-i4KUlhDu.js";
|
|
4
|
+
import { genericAriaLabels } from "./utils/shared-strings.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import React, { forwardRef } from "react";
|
|
7
|
+
import { getDatasetProps } from "@preply/ds-web-core";
|
|
8
|
+
import { webComponentNames } from "@preply/ds-visual-coverage-preply-component-names";
|
|
9
|
+
import ReactDOM from "react-dom";
|
|
10
|
+
import { useIntl } from "react-intl";
|
|
11
|
+
import './assets/Toast.css';//#region ../../node_modules/sonner/dist/index.mjs
|
|
12
|
+
function __insertCSS(code) {
|
|
13
|
+
if (!code || typeof document == "undefined") return;
|
|
14
|
+
let head = document.head || document.getElementsByTagName("head")[0];
|
|
15
|
+
let style = document.createElement("style");
|
|
16
|
+
style.type = "text/css";
|
|
17
|
+
head.appendChild(style);
|
|
18
|
+
style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
|
|
19
|
+
}
|
|
20
|
+
var getAsset = (type) => {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case "success": return SuccessIcon;
|
|
23
|
+
case "info": return InfoIcon;
|
|
24
|
+
case "warning": return WarningIcon;
|
|
25
|
+
case "error": return ErrorIcon;
|
|
26
|
+
default: return null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var bars = Array(12).fill(0);
|
|
30
|
+
var Loader = ({ visible, className }) => {
|
|
31
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
32
|
+
className: ["sonner-loading-wrapper", className].filter(Boolean).join(" "),
|
|
33
|
+
"data-visible": visible
|
|
34
|
+
}, /* @__PURE__ */ React.createElement("div", { className: "sonner-spinner" }, bars.map((_, i) => /* @__PURE__ */ React.createElement("div", {
|
|
35
|
+
className: "sonner-loading-bar",
|
|
36
|
+
key: `spinner-bar-${i}`
|
|
37
|
+
}))));
|
|
38
|
+
};
|
|
39
|
+
var SuccessIcon = /* @__PURE__ */ React.createElement("svg", {
|
|
40
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
41
|
+
viewBox: "0 0 20 20",
|
|
42
|
+
fill: "currentColor",
|
|
43
|
+
height: "20",
|
|
44
|
+
width: "20"
|
|
45
|
+
}, /* @__PURE__ */ React.createElement("path", {
|
|
46
|
+
fillRule: "evenodd",
|
|
47
|
+
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",
|
|
48
|
+
clipRule: "evenodd"
|
|
49
|
+
}));
|
|
50
|
+
var WarningIcon = /* @__PURE__ */ React.createElement("svg", {
|
|
51
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
52
|
+
viewBox: "0 0 24 24",
|
|
53
|
+
fill: "currentColor",
|
|
54
|
+
height: "20",
|
|
55
|
+
width: "20"
|
|
56
|
+
}, /* @__PURE__ */ React.createElement("path", {
|
|
57
|
+
fillRule: "evenodd",
|
|
58
|
+
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",
|
|
59
|
+
clipRule: "evenodd"
|
|
60
|
+
}));
|
|
61
|
+
var InfoIcon = /* @__PURE__ */ React.createElement("svg", {
|
|
62
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
63
|
+
viewBox: "0 0 20 20",
|
|
64
|
+
fill: "currentColor",
|
|
65
|
+
height: "20",
|
|
66
|
+
width: "20"
|
|
67
|
+
}, /* @__PURE__ */ React.createElement("path", {
|
|
68
|
+
fillRule: "evenodd",
|
|
69
|
+
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",
|
|
70
|
+
clipRule: "evenodd"
|
|
71
|
+
}));
|
|
72
|
+
var ErrorIcon = /* @__PURE__ */ React.createElement("svg", {
|
|
73
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
74
|
+
viewBox: "0 0 20 20",
|
|
75
|
+
fill: "currentColor",
|
|
76
|
+
height: "20",
|
|
77
|
+
width: "20"
|
|
78
|
+
}, /* @__PURE__ */ React.createElement("path", {
|
|
79
|
+
fillRule: "evenodd",
|
|
80
|
+
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",
|
|
81
|
+
clipRule: "evenodd"
|
|
82
|
+
}));
|
|
83
|
+
var CloseIcon = /* @__PURE__ */ React.createElement("svg", {
|
|
84
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
85
|
+
width: "12",
|
|
86
|
+
height: "12",
|
|
87
|
+
viewBox: "0 0 24 24",
|
|
88
|
+
fill: "none",
|
|
89
|
+
stroke: "currentColor",
|
|
90
|
+
strokeWidth: "1.5",
|
|
91
|
+
strokeLinecap: "round",
|
|
92
|
+
strokeLinejoin: "round"
|
|
93
|
+
}, /* @__PURE__ */ React.createElement("line", {
|
|
94
|
+
x1: "18",
|
|
95
|
+
y1: "6",
|
|
96
|
+
x2: "6",
|
|
97
|
+
y2: "18"
|
|
98
|
+
}), /* @__PURE__ */ React.createElement("line", {
|
|
99
|
+
x1: "6",
|
|
100
|
+
y1: "6",
|
|
101
|
+
x2: "18",
|
|
102
|
+
y2: "18"
|
|
103
|
+
}));
|
|
104
|
+
var useIsDocumentHidden = () => {
|
|
105
|
+
const [isDocumentHidden, setIsDocumentHidden] = React.useState(document.hidden);
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
const callback = () => {
|
|
108
|
+
setIsDocumentHidden(document.hidden);
|
|
109
|
+
};
|
|
110
|
+
document.addEventListener("visibilitychange", callback);
|
|
111
|
+
return () => window.removeEventListener("visibilitychange", callback);
|
|
112
|
+
}, []);
|
|
113
|
+
return isDocumentHidden;
|
|
114
|
+
};
|
|
115
|
+
var toastsCounter = 1;
|
|
116
|
+
var Observer = class {
|
|
117
|
+
constructor() {
|
|
118
|
+
this.subscribe = (subscriber) => {
|
|
119
|
+
this.subscribers.push(subscriber);
|
|
120
|
+
return () => {
|
|
121
|
+
const index = this.subscribers.indexOf(subscriber);
|
|
122
|
+
this.subscribers.splice(index, 1);
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
this.publish = (data) => {
|
|
126
|
+
this.subscribers.forEach((subscriber) => subscriber(data));
|
|
127
|
+
};
|
|
128
|
+
this.addToast = (data) => {
|
|
129
|
+
this.publish(data);
|
|
130
|
+
this.toasts = [...this.toasts, data];
|
|
131
|
+
};
|
|
132
|
+
this.create = (data) => {
|
|
133
|
+
var _data_id;
|
|
134
|
+
const { message, ...rest } = data;
|
|
135
|
+
const id = typeof (data == null ? void 0 : data.id) === "number" || ((_data_id = data.id) == null ? void 0 : _data_id.length) > 0 ? data.id : toastsCounter++;
|
|
136
|
+
const alreadyExists = this.toasts.find((toast) => {
|
|
137
|
+
return toast.id === id;
|
|
138
|
+
});
|
|
139
|
+
const dismissible = data.dismissible === void 0 ? true : data.dismissible;
|
|
140
|
+
if (this.dismissedToasts.has(id)) this.dismissedToasts.delete(id);
|
|
141
|
+
if (alreadyExists) this.toasts = this.toasts.map((toast) => {
|
|
142
|
+
if (toast.id === id) {
|
|
143
|
+
this.publish({
|
|
144
|
+
...toast,
|
|
145
|
+
...data,
|
|
146
|
+
id,
|
|
147
|
+
title: message
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
...toast,
|
|
151
|
+
...data,
|
|
152
|
+
id,
|
|
153
|
+
dismissible,
|
|
154
|
+
title: message
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return toast;
|
|
158
|
+
});
|
|
159
|
+
else this.addToast({
|
|
160
|
+
title: message,
|
|
161
|
+
...rest,
|
|
162
|
+
dismissible,
|
|
163
|
+
id
|
|
164
|
+
});
|
|
165
|
+
return id;
|
|
166
|
+
};
|
|
167
|
+
this.dismiss = (id) => {
|
|
168
|
+
if (id) {
|
|
169
|
+
this.dismissedToasts.add(id);
|
|
170
|
+
requestAnimationFrame(() => this.subscribers.forEach((subscriber) => subscriber({
|
|
171
|
+
id,
|
|
172
|
+
dismiss: true
|
|
173
|
+
})));
|
|
174
|
+
} else this.toasts.forEach((toast) => {
|
|
175
|
+
this.subscribers.forEach((subscriber) => subscriber({
|
|
176
|
+
id: toast.id,
|
|
177
|
+
dismiss: true
|
|
178
|
+
}));
|
|
179
|
+
});
|
|
180
|
+
return id;
|
|
181
|
+
};
|
|
182
|
+
this.message = (message, data) => {
|
|
183
|
+
return this.create({
|
|
184
|
+
...data,
|
|
185
|
+
message
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
this.error = (message, data) => {
|
|
189
|
+
return this.create({
|
|
190
|
+
...data,
|
|
191
|
+
message,
|
|
192
|
+
type: "error"
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
this.success = (message, data) => {
|
|
196
|
+
return this.create({
|
|
197
|
+
...data,
|
|
198
|
+
type: "success",
|
|
199
|
+
message
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
this.info = (message, data) => {
|
|
203
|
+
return this.create({
|
|
204
|
+
...data,
|
|
205
|
+
type: "info",
|
|
206
|
+
message
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
this.warning = (message, data) => {
|
|
210
|
+
return this.create({
|
|
211
|
+
...data,
|
|
212
|
+
type: "warning",
|
|
213
|
+
message
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
this.loading = (message, data) => {
|
|
217
|
+
return this.create({
|
|
218
|
+
...data,
|
|
219
|
+
type: "loading",
|
|
220
|
+
message
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
this.promise = (promise, data) => {
|
|
224
|
+
if (!data) return;
|
|
225
|
+
let id = void 0;
|
|
226
|
+
if (data.loading !== void 0) id = this.create({
|
|
227
|
+
...data,
|
|
228
|
+
promise,
|
|
229
|
+
type: "loading",
|
|
230
|
+
message: data.loading,
|
|
231
|
+
description: typeof data.description !== "function" ? data.description : void 0
|
|
232
|
+
});
|
|
233
|
+
const p = Promise.resolve(promise instanceof Function ? promise() : promise);
|
|
234
|
+
let shouldDismiss = id !== void 0;
|
|
235
|
+
let result;
|
|
236
|
+
const originalPromise = p.then(async (response) => {
|
|
237
|
+
result = ["resolve", response];
|
|
238
|
+
if (React.isValidElement(response)) {
|
|
239
|
+
shouldDismiss = false;
|
|
240
|
+
this.create({
|
|
241
|
+
id,
|
|
242
|
+
type: "default",
|
|
243
|
+
message: response
|
|
244
|
+
});
|
|
245
|
+
} else if (isHttpResponse(response) && !response.ok) {
|
|
246
|
+
shouldDismiss = false;
|
|
247
|
+
const promiseData = typeof data.error === "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
|
|
248
|
+
const description = typeof data.description === "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
|
|
249
|
+
const toastSettings = typeof promiseData === "object" && !React.isValidElement(promiseData) ? promiseData : { message: promiseData };
|
|
250
|
+
this.create({
|
|
251
|
+
id,
|
|
252
|
+
type: "error",
|
|
253
|
+
description,
|
|
254
|
+
...toastSettings
|
|
255
|
+
});
|
|
256
|
+
} else if (response instanceof Error) {
|
|
257
|
+
shouldDismiss = false;
|
|
258
|
+
const promiseData = typeof data.error === "function" ? await data.error(response) : data.error;
|
|
259
|
+
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
260
|
+
const toastSettings = typeof promiseData === "object" && !React.isValidElement(promiseData) ? promiseData : { message: promiseData };
|
|
261
|
+
this.create({
|
|
262
|
+
id,
|
|
263
|
+
type: "error",
|
|
264
|
+
description,
|
|
265
|
+
...toastSettings
|
|
266
|
+
});
|
|
267
|
+
} else if (data.success !== void 0) {
|
|
268
|
+
shouldDismiss = false;
|
|
269
|
+
const promiseData = typeof data.success === "function" ? await data.success(response) : data.success;
|
|
270
|
+
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
271
|
+
const toastSettings = typeof promiseData === "object" && !React.isValidElement(promiseData) ? promiseData : { message: promiseData };
|
|
272
|
+
this.create({
|
|
273
|
+
id,
|
|
274
|
+
type: "success",
|
|
275
|
+
description,
|
|
276
|
+
...toastSettings
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}).catch(async (error) => {
|
|
280
|
+
result = ["reject", error];
|
|
281
|
+
if (data.error !== void 0) {
|
|
282
|
+
shouldDismiss = false;
|
|
283
|
+
const promiseData = typeof data.error === "function" ? await data.error(error) : data.error;
|
|
284
|
+
const description = typeof data.description === "function" ? await data.description(error) : data.description;
|
|
285
|
+
const toastSettings = typeof promiseData === "object" && !React.isValidElement(promiseData) ? promiseData : { message: promiseData };
|
|
286
|
+
this.create({
|
|
287
|
+
id,
|
|
288
|
+
type: "error",
|
|
289
|
+
description,
|
|
290
|
+
...toastSettings
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}).finally(() => {
|
|
294
|
+
if (shouldDismiss) {
|
|
295
|
+
this.dismiss(id);
|
|
296
|
+
id = void 0;
|
|
297
|
+
}
|
|
298
|
+
data.finally == null || data.finally.call(data);
|
|
299
|
+
});
|
|
300
|
+
const unwrap = () => new Promise((resolve, reject) => originalPromise.then(() => result[0] === "reject" ? reject(result[1]) : resolve(result[1])).catch(reject));
|
|
301
|
+
if (typeof id !== "string" && typeof id !== "number") return { unwrap };
|
|
302
|
+
else return Object.assign(id, { unwrap });
|
|
303
|
+
};
|
|
304
|
+
this.custom = (jsx, data) => {
|
|
305
|
+
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
306
|
+
this.create({
|
|
307
|
+
jsx: jsx(id),
|
|
308
|
+
id,
|
|
309
|
+
...data
|
|
310
|
+
});
|
|
311
|
+
return id;
|
|
312
|
+
};
|
|
313
|
+
this.getActiveToasts = () => {
|
|
314
|
+
return this.toasts.filter((toast) => !this.dismissedToasts.has(toast.id));
|
|
315
|
+
};
|
|
316
|
+
this.subscribers = [];
|
|
317
|
+
this.toasts = [];
|
|
318
|
+
this.dismissedToasts = /* @__PURE__ */ new Set();
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var ToastState = new Observer();
|
|
322
|
+
var toastFunction = (message, data) => {
|
|
323
|
+
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
324
|
+
ToastState.addToast({
|
|
325
|
+
title: message,
|
|
326
|
+
...data,
|
|
327
|
+
id
|
|
328
|
+
});
|
|
329
|
+
return id;
|
|
330
|
+
};
|
|
331
|
+
var isHttpResponse = (data) => {
|
|
332
|
+
return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
|
|
333
|
+
};
|
|
334
|
+
var basicToast = toastFunction;
|
|
335
|
+
var getHistory = () => ToastState.toasts;
|
|
336
|
+
var getToasts = () => ToastState.getActiveToasts();
|
|
337
|
+
var toast$1 = Object.assign(basicToast, {
|
|
338
|
+
success: ToastState.success,
|
|
339
|
+
info: ToastState.info,
|
|
340
|
+
warning: ToastState.warning,
|
|
341
|
+
error: ToastState.error,
|
|
342
|
+
custom: ToastState.custom,
|
|
343
|
+
message: ToastState.message,
|
|
344
|
+
promise: ToastState.promise,
|
|
345
|
+
dismiss: ToastState.dismiss,
|
|
346
|
+
loading: ToastState.loading
|
|
347
|
+
}, {
|
|
348
|
+
getHistory,
|
|
349
|
+
getToasts
|
|
350
|
+
});
|
|
351
|
+
__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%)}");
|
|
352
|
+
function isAction(action) {
|
|
353
|
+
return action.label !== void 0;
|
|
354
|
+
}
|
|
355
|
+
var VISIBLE_TOASTS_AMOUNT = 3;
|
|
356
|
+
var VIEWPORT_OFFSET = "24px";
|
|
357
|
+
var MOBILE_VIEWPORT_OFFSET = "16px";
|
|
358
|
+
var TOAST_LIFETIME = 4e3;
|
|
359
|
+
var TOAST_WIDTH = 356;
|
|
360
|
+
var GAP = 14;
|
|
361
|
+
var SWIPE_THRESHOLD = 45;
|
|
362
|
+
var TIME_BEFORE_UNMOUNT = 200;
|
|
363
|
+
function cn(...classes) {
|
|
364
|
+
return classes.filter(Boolean).join(" ");
|
|
365
|
+
}
|
|
366
|
+
function getDefaultSwipeDirections(position) {
|
|
367
|
+
const [y, x] = position.split("-");
|
|
368
|
+
const directions = [];
|
|
369
|
+
if (y) directions.push(y);
|
|
370
|
+
if (x) directions.push(x);
|
|
371
|
+
return directions;
|
|
372
|
+
}
|
|
373
|
+
var Toast = (props) => {
|
|
374
|
+
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
375
|
+
const { invert: ToasterInvert, toast, 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;
|
|
376
|
+
const [swipeDirection, setSwipeDirection] = React.useState(null);
|
|
377
|
+
const [swipeOutDirection, setSwipeOutDirection] = React.useState(null);
|
|
378
|
+
const [mounted, setMounted] = React.useState(false);
|
|
379
|
+
const [removed, setRemoved] = React.useState(false);
|
|
380
|
+
const [swiping, setSwiping] = React.useState(false);
|
|
381
|
+
const [swipeOut, setSwipeOut] = React.useState(false);
|
|
382
|
+
const [isSwiped, setIsSwiped] = React.useState(false);
|
|
383
|
+
const [offsetBeforeRemove, setOffsetBeforeRemove] = React.useState(0);
|
|
384
|
+
const [initialHeight, setInitialHeight] = React.useState(0);
|
|
385
|
+
const remainingTime = React.useRef(toast.duration || durationFromToaster || TOAST_LIFETIME);
|
|
386
|
+
const dragStartTime = React.useRef(null);
|
|
387
|
+
const toastRef = React.useRef(null);
|
|
388
|
+
const isFront = index === 0;
|
|
389
|
+
const isVisible = index + 1 <= visibleToasts;
|
|
390
|
+
const toastType = toast.type;
|
|
391
|
+
const dismissible = toast.dismissible !== false;
|
|
392
|
+
const toastClassname = toast.className || "";
|
|
393
|
+
const toastDescriptionClassname = toast.descriptionClassName || "";
|
|
394
|
+
const heightIndex = React.useMemo(() => heights.findIndex((height) => height.toastId === toast.id) || 0, [heights, toast.id]);
|
|
395
|
+
const closeButton = React.useMemo(() => {
|
|
396
|
+
var _toast_closeButton;
|
|
397
|
+
return (_toast_closeButton = toast.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
398
|
+
}, [toast.closeButton, closeButtonFromToaster]);
|
|
399
|
+
const duration = React.useMemo(() => toast.duration || durationFromToaster || TOAST_LIFETIME, [toast.duration, durationFromToaster]);
|
|
400
|
+
const closeTimerStartTimeRef = React.useRef(0);
|
|
401
|
+
const offset = React.useRef(0);
|
|
402
|
+
const lastCloseTimerStartTimeRef = React.useRef(0);
|
|
403
|
+
const pointerStartRef = React.useRef(null);
|
|
404
|
+
const [y, x] = position.split("-");
|
|
405
|
+
const toastsHeightBefore = React.useMemo(() => {
|
|
406
|
+
return heights.reduce((prev, curr, reducerIndex) => {
|
|
407
|
+
if (reducerIndex >= heightIndex) return prev;
|
|
408
|
+
return prev + curr.height;
|
|
409
|
+
}, 0);
|
|
410
|
+
}, [heights, heightIndex]);
|
|
411
|
+
const isDocumentHidden = useIsDocumentHidden();
|
|
412
|
+
const invert = toast.invert || ToasterInvert;
|
|
413
|
+
const disabled = toastType === "loading";
|
|
414
|
+
offset.current = React.useMemo(() => heightIndex * gap + toastsHeightBefore, [heightIndex, toastsHeightBefore]);
|
|
415
|
+
React.useEffect(() => {
|
|
416
|
+
remainingTime.current = duration;
|
|
417
|
+
}, [duration]);
|
|
418
|
+
React.useEffect(() => {
|
|
419
|
+
setMounted(true);
|
|
420
|
+
}, []);
|
|
421
|
+
React.useEffect(() => {
|
|
422
|
+
const toastNode = toastRef.current;
|
|
423
|
+
if (toastNode) {
|
|
424
|
+
const height = toastNode.getBoundingClientRect().height;
|
|
425
|
+
setInitialHeight(height);
|
|
426
|
+
setHeights((h) => [{
|
|
427
|
+
toastId: toast.id,
|
|
428
|
+
height,
|
|
429
|
+
position: toast.position
|
|
430
|
+
}, ...h]);
|
|
431
|
+
return () => setHeights((h) => h.filter((height) => height.toastId !== toast.id));
|
|
432
|
+
}
|
|
433
|
+
}, [setHeights, toast.id]);
|
|
434
|
+
React.useLayoutEffect(() => {
|
|
435
|
+
if (!mounted) return;
|
|
436
|
+
const toastNode = toastRef.current;
|
|
437
|
+
const originalHeight = toastNode.style.height;
|
|
438
|
+
toastNode.style.height = "auto";
|
|
439
|
+
const newHeight = toastNode.getBoundingClientRect().height;
|
|
440
|
+
toastNode.style.height = originalHeight;
|
|
441
|
+
setInitialHeight(newHeight);
|
|
442
|
+
setHeights((heights) => {
|
|
443
|
+
if (!heights.find((height) => height.toastId === toast.id)) return [{
|
|
444
|
+
toastId: toast.id,
|
|
445
|
+
height: newHeight,
|
|
446
|
+
position: toast.position
|
|
447
|
+
}, ...heights];
|
|
448
|
+
else return heights.map((height) => height.toastId === toast.id ? {
|
|
449
|
+
...height,
|
|
450
|
+
height: newHeight
|
|
451
|
+
} : height);
|
|
452
|
+
});
|
|
453
|
+
}, [
|
|
454
|
+
mounted,
|
|
455
|
+
toast.title,
|
|
456
|
+
toast.description,
|
|
457
|
+
setHeights,
|
|
458
|
+
toast.id,
|
|
459
|
+
toast.jsx,
|
|
460
|
+
toast.action,
|
|
461
|
+
toast.cancel
|
|
462
|
+
]);
|
|
463
|
+
const deleteToast = React.useCallback(() => {
|
|
464
|
+
setRemoved(true);
|
|
465
|
+
setOffsetBeforeRemove(offset.current);
|
|
466
|
+
setHeights((h) => h.filter((height) => height.toastId !== toast.id));
|
|
467
|
+
setTimeout(() => {
|
|
468
|
+
removeToast(toast);
|
|
469
|
+
}, TIME_BEFORE_UNMOUNT);
|
|
470
|
+
}, [
|
|
471
|
+
toast,
|
|
472
|
+
removeToast,
|
|
473
|
+
setHeights,
|
|
474
|
+
offset
|
|
475
|
+
]);
|
|
476
|
+
React.useEffect(() => {
|
|
477
|
+
if (toast.promise && toastType === "loading" || toast.duration === Infinity || toast.type === "loading") return;
|
|
478
|
+
let timeoutId;
|
|
479
|
+
const pauseTimer = () => {
|
|
480
|
+
if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
|
|
481
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
482
|
+
remainingTime.current = remainingTime.current - elapsedTime;
|
|
483
|
+
}
|
|
484
|
+
lastCloseTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
485
|
+
};
|
|
486
|
+
const startTimer = () => {
|
|
487
|
+
if (remainingTime.current === Infinity) return;
|
|
488
|
+
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
489
|
+
timeoutId = setTimeout(() => {
|
|
490
|
+
toast.onAutoClose == null || toast.onAutoClose.call(toast, toast);
|
|
491
|
+
deleteToast();
|
|
492
|
+
}, remainingTime.current);
|
|
493
|
+
};
|
|
494
|
+
if (expanded || interacting || isDocumentHidden) pauseTimer();
|
|
495
|
+
else startTimer();
|
|
496
|
+
return () => clearTimeout(timeoutId);
|
|
497
|
+
}, [
|
|
498
|
+
expanded,
|
|
499
|
+
interacting,
|
|
500
|
+
toast,
|
|
501
|
+
toastType,
|
|
502
|
+
isDocumentHidden,
|
|
503
|
+
deleteToast
|
|
504
|
+
]);
|
|
505
|
+
React.useEffect(() => {
|
|
506
|
+
if (toast.delete) {
|
|
507
|
+
deleteToast();
|
|
508
|
+
toast.onDismiss == null || toast.onDismiss.call(toast, toast);
|
|
509
|
+
}
|
|
510
|
+
}, [deleteToast, toast.delete]);
|
|
511
|
+
function getLoadingIcon() {
|
|
512
|
+
var _toast_classNames;
|
|
513
|
+
if (icons == null ? void 0 : icons.loading) {
|
|
514
|
+
var _toast_classNames1;
|
|
515
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
516
|
+
className: cn(classNames == null ? void 0 : classNames.loader, toast == null ? void 0 : (_toast_classNames1 = toast.classNames) == null ? void 0 : _toast_classNames1.loader, "sonner-loader"),
|
|
517
|
+
"data-visible": toastType === "loading"
|
|
518
|
+
}, icons.loading);
|
|
519
|
+
}
|
|
520
|
+
return /* @__PURE__ */ React.createElement(Loader, {
|
|
521
|
+
className: cn(classNames == null ? void 0 : classNames.loader, toast == null ? void 0 : (_toast_classNames = toast.classNames) == null ? void 0 : _toast_classNames.loader),
|
|
522
|
+
visible: toastType === "loading"
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
const icon = toast.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
526
|
+
var _toast_richColors, _icons_close;
|
|
527
|
+
return /* @__PURE__ */ React.createElement("li", {
|
|
528
|
+
tabIndex: 0,
|
|
529
|
+
ref: toastRef,
|
|
530
|
+
className: cn(className, toastClassname, classNames == null ? void 0 : classNames.toast, toast == null ? void 0 : (_toast_classNames = toast.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames.default, classNames == null ? void 0 : classNames[toastType], toast == null ? void 0 : (_toast_classNames1 = toast.classNames) == null ? void 0 : _toast_classNames1[toastType]),
|
|
531
|
+
"data-sonner-toast": "",
|
|
532
|
+
"data-rich-colors": (_toast_richColors = toast.richColors) != null ? _toast_richColors : defaultRichColors,
|
|
533
|
+
"data-styled": !Boolean(toast.jsx || toast.unstyled || unstyled),
|
|
534
|
+
"data-mounted": mounted,
|
|
535
|
+
"data-promise": Boolean(toast.promise),
|
|
536
|
+
"data-swiped": isSwiped,
|
|
537
|
+
"data-removed": removed,
|
|
538
|
+
"data-visible": isVisible,
|
|
539
|
+
"data-y-position": y,
|
|
540
|
+
"data-x-position": x,
|
|
541
|
+
"data-index": index,
|
|
542
|
+
"data-front": isFront,
|
|
543
|
+
"data-swiping": swiping,
|
|
544
|
+
"data-dismissible": dismissible,
|
|
545
|
+
"data-type": toastType,
|
|
546
|
+
"data-invert": invert,
|
|
547
|
+
"data-swipe-out": swipeOut,
|
|
548
|
+
"data-swipe-direction": swipeOutDirection,
|
|
549
|
+
"data-expanded": Boolean(expanded || expandByDefault && mounted),
|
|
550
|
+
"data-testid": toast.testId,
|
|
551
|
+
style: {
|
|
552
|
+
"--index": index,
|
|
553
|
+
"--toasts-before": index,
|
|
554
|
+
"--z-index": toasts.length - index,
|
|
555
|
+
"--offset": `${removed ? offsetBeforeRemove : offset.current}px`,
|
|
556
|
+
"--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
|
|
557
|
+
...style,
|
|
558
|
+
...toast.style
|
|
559
|
+
},
|
|
560
|
+
onDragEnd: () => {
|
|
561
|
+
setSwiping(false);
|
|
562
|
+
setSwipeDirection(null);
|
|
563
|
+
pointerStartRef.current = null;
|
|
564
|
+
},
|
|
565
|
+
onPointerDown: (event) => {
|
|
566
|
+
if (event.button === 2) return;
|
|
567
|
+
if (disabled || !dismissible) return;
|
|
568
|
+
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
569
|
+
setOffsetBeforeRemove(offset.current);
|
|
570
|
+
event.target.setPointerCapture(event.pointerId);
|
|
571
|
+
if (event.target.tagName === "BUTTON") return;
|
|
572
|
+
setSwiping(true);
|
|
573
|
+
pointerStartRef.current = {
|
|
574
|
+
x: event.clientX,
|
|
575
|
+
y: event.clientY
|
|
576
|
+
};
|
|
577
|
+
},
|
|
578
|
+
onPointerUp: () => {
|
|
579
|
+
var _toastRef_current, _toastRef_current1, _dragStartTime_current;
|
|
580
|
+
if (swipeOut || !dismissible) return;
|
|
581
|
+
pointerStartRef.current = null;
|
|
582
|
+
const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0);
|
|
583
|
+
const swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0);
|
|
584
|
+
const timeTaken = (/* @__PURE__ */ new Date()).getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? void 0 : _dragStartTime_current.getTime());
|
|
585
|
+
const swipeAmount = swipeDirection === "x" ? swipeAmountX : swipeAmountY;
|
|
586
|
+
const velocity = Math.abs(swipeAmount) / timeTaken;
|
|
587
|
+
if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > .11) {
|
|
588
|
+
setOffsetBeforeRemove(offset.current);
|
|
589
|
+
toast.onDismiss == null || toast.onDismiss.call(toast, toast);
|
|
590
|
+
if (swipeDirection === "x") setSwipeOutDirection(swipeAmountX > 0 ? "right" : "left");
|
|
591
|
+
else setSwipeOutDirection(swipeAmountY > 0 ? "down" : "up");
|
|
592
|
+
deleteToast();
|
|
593
|
+
setSwipeOut(true);
|
|
594
|
+
return;
|
|
595
|
+
} else {
|
|
596
|
+
var _toastRef_current2, _toastRef_current3;
|
|
597
|
+
(_toastRef_current2 = toastRef.current) == null || _toastRef_current2.style.setProperty("--swipe-amount-x", `0px`);
|
|
598
|
+
(_toastRef_current3 = toastRef.current) == null || _toastRef_current3.style.setProperty("--swipe-amount-y", `0px`);
|
|
599
|
+
}
|
|
600
|
+
setIsSwiped(false);
|
|
601
|
+
setSwiping(false);
|
|
602
|
+
setSwipeDirection(null);
|
|
603
|
+
},
|
|
604
|
+
onPointerMove: (event) => {
|
|
605
|
+
var _window_getSelection, _toastRef_current, _toastRef_current1;
|
|
606
|
+
if (!pointerStartRef.current || !dismissible) return;
|
|
607
|
+
if (((_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString().length) > 0) return;
|
|
608
|
+
const yDelta = event.clientY - pointerStartRef.current.y;
|
|
609
|
+
const xDelta = event.clientX - pointerStartRef.current.x;
|
|
610
|
+
var _props_swipeDirections;
|
|
611
|
+
const swipeDirections = (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
|
|
612
|
+
if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? "x" : "y");
|
|
613
|
+
let swipeAmount = {
|
|
614
|
+
x: 0,
|
|
615
|
+
y: 0
|
|
616
|
+
};
|
|
617
|
+
const getDampening = (delta) => {
|
|
618
|
+
return 1 / (1.5 + Math.abs(delta) / 20);
|
|
619
|
+
};
|
|
620
|
+
if (swipeDirection === "y") {
|
|
621
|
+
if (swipeDirections.includes("top") || swipeDirections.includes("bottom")) if (swipeDirections.includes("top") && yDelta < 0 || swipeDirections.includes("bottom") && yDelta > 0) swipeAmount.y = yDelta;
|
|
622
|
+
else {
|
|
623
|
+
const dampenedDelta = yDelta * getDampening(yDelta);
|
|
624
|
+
swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
|
|
625
|
+
}
|
|
626
|
+
} else if (swipeDirection === "x") {
|
|
627
|
+
if (swipeDirections.includes("left") || swipeDirections.includes("right")) if (swipeDirections.includes("left") && xDelta < 0 || swipeDirections.includes("right") && xDelta > 0) swipeAmount.x = xDelta;
|
|
628
|
+
else {
|
|
629
|
+
const dampenedDelta = xDelta * getDampening(xDelta);
|
|
630
|
+
swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) setIsSwiped(true);
|
|
634
|
+
(_toastRef_current = toastRef.current) == null || _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
|
|
635
|
+
(_toastRef_current1 = toastRef.current) == null || _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
|
|
636
|
+
}
|
|
637
|
+
}, closeButton && !toast.jsx && toastType !== "loading" ? /* @__PURE__ */ React.createElement("button", {
|
|
638
|
+
"aria-label": closeButtonAriaLabel,
|
|
639
|
+
"data-disabled": disabled,
|
|
640
|
+
"data-close-button": true,
|
|
641
|
+
onClick: disabled || !dismissible ? () => {} : () => {
|
|
642
|
+
deleteToast();
|
|
643
|
+
toast.onDismiss == null || toast.onDismiss.call(toast, toast);
|
|
644
|
+
},
|
|
645
|
+
className: cn(classNames == null ? void 0 : classNames.closeButton, toast == null ? void 0 : (_toast_classNames2 = toast.classNames) == null ? void 0 : _toast_classNames2.closeButton)
|
|
646
|
+
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast.icon || toast.promise) && toast.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast.icon) ? /* @__PURE__ */ React.createElement("div", {
|
|
647
|
+
"data-icon": "",
|
|
648
|
+
className: cn(classNames == null ? void 0 : classNames.icon, toast == null ? void 0 : (_toast_classNames3 = toast.classNames) == null ? void 0 : _toast_classNames3.icon)
|
|
649
|
+
}, toast.promise || toast.type === "loading" && !toast.icon ? toast.icon || getLoadingIcon() : null, toast.type !== "loading" ? icon : null) : null, /* @__PURE__ */ React.createElement("div", {
|
|
650
|
+
"data-content": "",
|
|
651
|
+
className: cn(classNames == null ? void 0 : classNames.content, toast == null ? void 0 : (_toast_classNames4 = toast.classNames) == null ? void 0 : _toast_classNames4.content)
|
|
652
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
653
|
+
"data-title": "",
|
|
654
|
+
className: cn(classNames == null ? void 0 : classNames.title, toast == null ? void 0 : (_toast_classNames5 = toast.classNames) == null ? void 0 : _toast_classNames5.title)
|
|
655
|
+
}, toast.jsx ? toast.jsx : typeof toast.title === "function" ? toast.title() : toast.title), toast.description ? /* @__PURE__ */ React.createElement("div", {
|
|
656
|
+
"data-description": "",
|
|
657
|
+
className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast == null ? void 0 : (_toast_classNames6 = toast.classNames) == null ? void 0 : _toast_classNames6.description)
|
|
658
|
+
}, typeof toast.description === "function" ? toast.description() : toast.description) : null), /* @__PURE__ */ React.isValidElement(toast.cancel) ? toast.cancel : toast.cancel && isAction(toast.cancel) ? /* @__PURE__ */ React.createElement("button", {
|
|
659
|
+
"data-button": true,
|
|
660
|
+
"data-cancel": true,
|
|
661
|
+
style: toast.cancelButtonStyle || cancelButtonStyle,
|
|
662
|
+
onClick: (event) => {
|
|
663
|
+
if (!isAction(toast.cancel)) return;
|
|
664
|
+
if (!dismissible) return;
|
|
665
|
+
toast.cancel.onClick == null || toast.cancel.onClick.call(toast.cancel, event);
|
|
666
|
+
deleteToast();
|
|
667
|
+
},
|
|
668
|
+
className: cn(classNames == null ? void 0 : classNames.cancelButton, toast == null ? void 0 : (_toast_classNames7 = toast.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
|
|
669
|
+
}, toast.cancel.label) : null, /* @__PURE__ */ React.isValidElement(toast.action) ? toast.action : toast.action && isAction(toast.action) ? /* @__PURE__ */ React.createElement("button", {
|
|
670
|
+
"data-button": true,
|
|
671
|
+
"data-action": true,
|
|
672
|
+
style: toast.actionButtonStyle || actionButtonStyle,
|
|
673
|
+
onClick: (event) => {
|
|
674
|
+
if (!isAction(toast.action)) return;
|
|
675
|
+
toast.action.onClick == null || toast.action.onClick.call(toast.action, event);
|
|
676
|
+
if (event.defaultPrevented) return;
|
|
677
|
+
deleteToast();
|
|
678
|
+
},
|
|
679
|
+
className: cn(classNames == null ? void 0 : classNames.actionButton, toast == null ? void 0 : (_toast_classNames8 = toast.classNames) == null ? void 0 : _toast_classNames8.actionButton)
|
|
680
|
+
}, toast.action.label) : null);
|
|
681
|
+
};
|
|
682
|
+
function getDocumentDirection() {
|
|
683
|
+
if (typeof window === "undefined") return "ltr";
|
|
684
|
+
if (typeof document === "undefined") return "ltr";
|
|
685
|
+
const dirAttribute = document.documentElement.getAttribute("dir");
|
|
686
|
+
if (dirAttribute === "auto" || !dirAttribute) return window.getComputedStyle(document.documentElement).direction;
|
|
687
|
+
return dirAttribute;
|
|
688
|
+
}
|
|
689
|
+
function assignOffset(defaultOffset, mobileOffset) {
|
|
690
|
+
const styles = {};
|
|
691
|
+
[defaultOffset, mobileOffset].forEach((offset, index) => {
|
|
692
|
+
const isMobile = index === 1;
|
|
693
|
+
const prefix = isMobile ? "--mobile-offset" : "--offset";
|
|
694
|
+
const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
|
|
695
|
+
function assignAll(offset) {
|
|
696
|
+
[
|
|
697
|
+
"top",
|
|
698
|
+
"right",
|
|
699
|
+
"bottom",
|
|
700
|
+
"left"
|
|
701
|
+
].forEach((key) => {
|
|
702
|
+
styles[`${prefix}-${key}`] = typeof offset === "number" ? `${offset}px` : offset;
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
if (typeof offset === "number" || typeof offset === "string") assignAll(offset);
|
|
706
|
+
else if (typeof offset === "object") [
|
|
707
|
+
"top",
|
|
708
|
+
"right",
|
|
709
|
+
"bottom",
|
|
710
|
+
"left"
|
|
711
|
+
].forEach((key) => {
|
|
712
|
+
if (offset[key] === void 0) styles[`${prefix}-${key}`] = defaultValue;
|
|
713
|
+
else styles[`${prefix}-${key}`] = typeof offset[key] === "number" ? `${offset[key]}px` : offset[key];
|
|
714
|
+
});
|
|
715
|
+
else assignAll(defaultValue);
|
|
716
|
+
});
|
|
717
|
+
return styles;
|
|
718
|
+
}
|
|
719
|
+
var Toaster = /* @__PURE__ */ React.forwardRef(function Toaster(props, ref) {
|
|
720
|
+
const { id, invert, position = "bottom-right", hotkey = ["altKey", "KeyT"], expand, closeButton, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, containerAriaLabel = "Notifications" } = props;
|
|
721
|
+
const [toasts, setToasts] = React.useState([]);
|
|
722
|
+
const filteredToasts = React.useMemo(() => {
|
|
723
|
+
if (id) return toasts.filter((toast) => toast.toasterId === id);
|
|
724
|
+
return toasts.filter((toast) => !toast.toasterId);
|
|
725
|
+
}, [toasts, id]);
|
|
726
|
+
const possiblePositions = React.useMemo(() => {
|
|
727
|
+
return Array.from(new Set([position].concat(filteredToasts.filter((toast) => toast.position).map((toast) => toast.position))));
|
|
728
|
+
}, [filteredToasts, position]);
|
|
729
|
+
const [heights, setHeights] = React.useState([]);
|
|
730
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
731
|
+
const [interacting, setInteracting] = React.useState(false);
|
|
732
|
+
const [actualTheme, setActualTheme] = React.useState(theme !== "system" ? theme : typeof window !== "undefined" ? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : "light");
|
|
733
|
+
const listRef = React.useRef(null);
|
|
734
|
+
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
735
|
+
const lastFocusedElementRef = React.useRef(null);
|
|
736
|
+
const isFocusWithinRef = React.useRef(false);
|
|
737
|
+
const removeToast = React.useCallback((toastToRemove) => {
|
|
738
|
+
setToasts((toasts) => {
|
|
739
|
+
var _toasts_find;
|
|
740
|
+
if (!((_toasts_find = toasts.find((toast) => toast.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) ToastState.dismiss(toastToRemove.id);
|
|
741
|
+
return toasts.filter(({ id }) => id !== toastToRemove.id);
|
|
742
|
+
});
|
|
743
|
+
}, []);
|
|
744
|
+
React.useEffect(() => {
|
|
745
|
+
return ToastState.subscribe((toast) => {
|
|
746
|
+
if (toast.dismiss) {
|
|
747
|
+
requestAnimationFrame(() => {
|
|
748
|
+
setToasts((toasts) => toasts.map((t) => t.id === toast.id ? {
|
|
749
|
+
...t,
|
|
750
|
+
delete: true
|
|
751
|
+
} : t));
|
|
752
|
+
});
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
setTimeout(() => {
|
|
756
|
+
ReactDOM.flushSync(() => {
|
|
757
|
+
setToasts((toasts) => {
|
|
758
|
+
const indexOfExistingToast = toasts.findIndex((t) => t.id === toast.id);
|
|
759
|
+
if (indexOfExistingToast !== -1) return [
|
|
760
|
+
...toasts.slice(0, indexOfExistingToast),
|
|
761
|
+
{
|
|
762
|
+
...toasts[indexOfExistingToast],
|
|
763
|
+
...toast
|
|
764
|
+
},
|
|
765
|
+
...toasts.slice(indexOfExistingToast + 1)
|
|
766
|
+
];
|
|
767
|
+
return [toast, ...toasts];
|
|
768
|
+
});
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
});
|
|
772
|
+
}, [toasts]);
|
|
773
|
+
React.useEffect(() => {
|
|
774
|
+
if (theme !== "system") {
|
|
775
|
+
setActualTheme(theme);
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
if (theme === "system") if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) setActualTheme("dark");
|
|
779
|
+
else setActualTheme("light");
|
|
780
|
+
if (typeof window === "undefined") return;
|
|
781
|
+
const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
782
|
+
try {
|
|
783
|
+
darkMediaQuery.addEventListener("change", ({ matches }) => {
|
|
784
|
+
if (matches) setActualTheme("dark");
|
|
785
|
+
else setActualTheme("light");
|
|
786
|
+
});
|
|
787
|
+
} catch (error) {
|
|
788
|
+
darkMediaQuery.addListener(({ matches }) => {
|
|
789
|
+
try {
|
|
790
|
+
if (matches) setActualTheme("dark");
|
|
791
|
+
else setActualTheme("light");
|
|
792
|
+
} catch (e) {
|
|
793
|
+
console.error(e);
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
}, [theme]);
|
|
798
|
+
React.useEffect(() => {
|
|
799
|
+
if (toasts.length <= 1) setExpanded(false);
|
|
800
|
+
}, [toasts]);
|
|
801
|
+
React.useEffect(() => {
|
|
802
|
+
const handleKeyDown = (event) => {
|
|
803
|
+
var _listRef_current;
|
|
804
|
+
if (hotkey.every((key) => event[key] || event.code === key)) {
|
|
805
|
+
var _listRef_current1;
|
|
806
|
+
setExpanded(true);
|
|
807
|
+
(_listRef_current1 = listRef.current) == null || _listRef_current1.focus();
|
|
808
|
+
}
|
|
809
|
+
if (event.code === "Escape" && (document.activeElement === listRef.current || ((_listRef_current = listRef.current) == null ? void 0 : _listRef_current.contains(document.activeElement)))) setExpanded(false);
|
|
810
|
+
};
|
|
811
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
812
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
813
|
+
}, [hotkey]);
|
|
814
|
+
React.useEffect(() => {
|
|
815
|
+
if (listRef.current) return () => {
|
|
816
|
+
if (lastFocusedElementRef.current) {
|
|
817
|
+
lastFocusedElementRef.current.focus({ preventScroll: true });
|
|
818
|
+
lastFocusedElementRef.current = null;
|
|
819
|
+
isFocusWithinRef.current = false;
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
}, [listRef.current]);
|
|
823
|
+
return /* @__PURE__ */ React.createElement("section", {
|
|
824
|
+
ref,
|
|
825
|
+
"aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
|
|
826
|
+
tabIndex: -1,
|
|
827
|
+
"aria-live": "polite",
|
|
828
|
+
"aria-relevant": "additions text",
|
|
829
|
+
"aria-atomic": "false",
|
|
830
|
+
suppressHydrationWarning: true
|
|
831
|
+
}, possiblePositions.map((position, index) => {
|
|
832
|
+
var _heights_;
|
|
833
|
+
const [y, x] = position.split("-");
|
|
834
|
+
if (!filteredToasts.length) return null;
|
|
835
|
+
return /* @__PURE__ */ React.createElement("ol", {
|
|
836
|
+
key: position,
|
|
837
|
+
dir: dir === "auto" ? getDocumentDirection() : dir,
|
|
838
|
+
tabIndex: -1,
|
|
839
|
+
ref: listRef,
|
|
840
|
+
className,
|
|
841
|
+
"data-sonner-toaster": true,
|
|
842
|
+
"data-sonner-theme": actualTheme,
|
|
843
|
+
"data-y-position": y,
|
|
844
|
+
"data-x-position": x,
|
|
845
|
+
style: {
|
|
846
|
+
"--front-toast-height": `${((_heights_ = heights[0]) == null ? void 0 : _heights_.height) || 0}px`,
|
|
847
|
+
"--width": `${TOAST_WIDTH}px`,
|
|
848
|
+
"--gap": `${gap}px`,
|
|
849
|
+
...style,
|
|
850
|
+
...assignOffset(offset, mobileOffset)
|
|
851
|
+
},
|
|
852
|
+
onBlur: (event) => {
|
|
853
|
+
if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {
|
|
854
|
+
isFocusWithinRef.current = false;
|
|
855
|
+
if (lastFocusedElementRef.current) {
|
|
856
|
+
lastFocusedElementRef.current.focus({ preventScroll: true });
|
|
857
|
+
lastFocusedElementRef.current = null;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
onFocus: (event) => {
|
|
862
|
+
if (event.target instanceof HTMLElement && event.target.dataset.dismissible === "false") return;
|
|
863
|
+
if (!isFocusWithinRef.current) {
|
|
864
|
+
isFocusWithinRef.current = true;
|
|
865
|
+
lastFocusedElementRef.current = event.relatedTarget;
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
onMouseEnter: () => setExpanded(true),
|
|
869
|
+
onMouseMove: () => setExpanded(true),
|
|
870
|
+
onMouseLeave: () => {
|
|
871
|
+
if (!interacting) setExpanded(false);
|
|
872
|
+
},
|
|
873
|
+
onDragEnd: () => setExpanded(false),
|
|
874
|
+
onPointerDown: (event) => {
|
|
875
|
+
if (event.target instanceof HTMLElement && event.target.dataset.dismissible === "false") return;
|
|
876
|
+
setInteracting(true);
|
|
877
|
+
},
|
|
878
|
+
onPointerUp: () => setInteracting(false)
|
|
879
|
+
}, filteredToasts.filter((toast) => !toast.position && index === 0 || toast.position === position).map((toast, index) => {
|
|
880
|
+
var _toastOptions_duration, _toastOptions_closeButton;
|
|
881
|
+
return /* @__PURE__ */ React.createElement(Toast, {
|
|
882
|
+
key: toast.id,
|
|
883
|
+
icons,
|
|
884
|
+
index,
|
|
885
|
+
toast,
|
|
886
|
+
defaultRichColors: richColors,
|
|
887
|
+
duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
|
|
888
|
+
className: toastOptions == null ? void 0 : toastOptions.className,
|
|
889
|
+
descriptionClassName: toastOptions == null ? void 0 : toastOptions.descriptionClassName,
|
|
890
|
+
invert,
|
|
891
|
+
visibleToasts,
|
|
892
|
+
closeButton: (_toastOptions_closeButton = toastOptions == null ? void 0 : toastOptions.closeButton) != null ? _toastOptions_closeButton : closeButton,
|
|
893
|
+
interacting,
|
|
894
|
+
position,
|
|
895
|
+
style: toastOptions == null ? void 0 : toastOptions.style,
|
|
896
|
+
unstyled: toastOptions == null ? void 0 : toastOptions.unstyled,
|
|
897
|
+
classNames: toastOptions == null ? void 0 : toastOptions.classNames,
|
|
898
|
+
cancelButtonStyle: toastOptions == null ? void 0 : toastOptions.cancelButtonStyle,
|
|
899
|
+
actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
|
|
900
|
+
closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
|
|
901
|
+
removeToast,
|
|
902
|
+
toasts: filteredToasts.filter((t) => t.position == toast.position),
|
|
903
|
+
heights: heights.filter((h) => h.position == toast.position),
|
|
904
|
+
setHeights,
|
|
905
|
+
expandByDefault: expand,
|
|
906
|
+
gap,
|
|
907
|
+
expanded,
|
|
908
|
+
swipeDirections: props.swipeDirections
|
|
909
|
+
});
|
|
910
|
+
}));
|
|
911
|
+
}));
|
|
912
|
+
});
|
|
913
|
+
var index_module_default = {
|
|
914
|
+
toast: "toast__JkBNR",
|
|
915
|
+
title: "title__GML0C",
|
|
916
|
+
critical: "critical__3Bvx3",
|
|
917
|
+
actionButton: "actionButton__-9sR3",
|
|
918
|
+
closeButton: "closeButton__KzpIU"
|
|
919
|
+
};
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/components/Toast/icons/close.svg
|
|
922
|
+
var SvgClose = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ React$1.createElement("svg", {
|
|
923
|
+
"data-preply-ds-component": "SvgTokyoUIIcon",
|
|
924
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
925
|
+
viewBox: "0 0 24 24",
|
|
926
|
+
ref,
|
|
927
|
+
"aria-labelledby": titleId,
|
|
928
|
+
...props
|
|
929
|
+
}, title ? /* @__PURE__ */ React$1.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React$1.createElement("path", {
|
|
930
|
+
fillRule: "evenodd",
|
|
931
|
+
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",
|
|
932
|
+
clipRule: "evenodd"
|
|
933
|
+
}));
|
|
934
|
+
var ForwardRef$1 = forwardRef(SvgClose);
|
|
935
|
+
//#endregion
|
|
936
|
+
//#region src/components/Toast/icons/error.svg
|
|
937
|
+
var SvgError = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ React$1.createElement("svg", {
|
|
938
|
+
"data-preply-ds-component": "SvgTokyoUIIcon",
|
|
939
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
940
|
+
viewBox: "0 0 24 24",
|
|
941
|
+
ref,
|
|
942
|
+
"aria-labelledby": titleId,
|
|
943
|
+
...props
|
|
944
|
+
}, title ? /* @__PURE__ */ React$1.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React$1.createElement("path", {
|
|
945
|
+
fillRule: "evenodd",
|
|
946
|
+
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",
|
|
947
|
+
clipRule: "evenodd"
|
|
948
|
+
}));
|
|
949
|
+
var ForwardRef = forwardRef(SvgError);
|
|
950
|
+
//#endregion
|
|
951
|
+
//#region src/components/Toast/Toast.tsx
|
|
952
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
953
|
+
/**
|
|
954
|
+
* An internal primitive used for testing.
|
|
955
|
+
* This should not be exported to consumers.
|
|
956
|
+
* @see {@link ToastProvider}
|
|
957
|
+
*/
|
|
958
|
+
var InternalToastProvider = ({ duration = 5e3 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Toaster, {
|
|
959
|
+
position: "top-right",
|
|
960
|
+
duration,
|
|
961
|
+
visibleToasts: 3
|
|
962
|
+
});
|
|
963
|
+
/**
|
|
964
|
+
* Toasts can be triggered via the `showToast` function, and are rendered
|
|
965
|
+
* onto a root `Toaster` component, which is typically placed somewhere high
|
|
966
|
+
* up in an application tree.
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* import { ToastProvider, showToast } from '@preply/ds-web-lib';
|
|
970
|
+
* const MyApp = () => (
|
|
971
|
+
* <div id="root">
|
|
972
|
+
* <ToastProvider />
|
|
973
|
+
* <button onClick={() => showToast('Hello World!')}>
|
|
974
|
+
* Create Toast
|
|
975
|
+
* </button>
|
|
976
|
+
* </div>
|
|
977
|
+
* );
|
|
978
|
+
*/
|
|
979
|
+
var ToastProvider = InternalToastProvider.bind(null, { duration: 5e3 });
|
|
980
|
+
var CloseButton = ({ onClick }) => {
|
|
981
|
+
const { formatMessage } = useIntl();
|
|
982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
983
|
+
onClick,
|
|
984
|
+
className: index_module_default.closeButton,
|
|
985
|
+
"aria-label": formatMessage(genericAriaLabels.close),
|
|
986
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { svg: ForwardRef$1 })
|
|
987
|
+
});
|
|
988
|
+
};
|
|
989
|
+
/**
|
|
990
|
+
* `showToast` creates and appends a toast notification instance to your
|
|
991
|
+
* application's `ToastProvider`.
|
|
992
|
+
*/
|
|
993
|
+
function showToast(message, props) {
|
|
994
|
+
const { variant = "info", leadingSvgIcon, actionLabel, actionOnClick, actionHref, dataset } = props !== null && props !== void 0 ? props : {};
|
|
995
|
+
const Action = actionHref ? "a" : "button";
|
|
996
|
+
return toast$1.custom((id) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
997
|
+
style: { display: "contents" },
|
|
998
|
+
...getDatasetProps(dataset, { preplyDsComponent: webComponentNames.Toast }),
|
|
999
|
+
children: [
|
|
1000
|
+
variant === "critical" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { svg: ForwardRef }) : leadingSvgIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { svg: leadingSvgIcon }),
|
|
1001
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
1002
|
+
className: index_module_default.title,
|
|
1003
|
+
children: message
|
|
1004
|
+
}),
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CloseButton, { onClick: () => toast$1.dismiss(id) }),
|
|
1006
|
+
actionLabel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Action, {
|
|
1007
|
+
className: index_module_default.actionButton,
|
|
1008
|
+
onClick: () => {
|
|
1009
|
+
toast$1.dismiss(id);
|
|
1010
|
+
actionOnClick === null || actionOnClick === void 0 || actionOnClick();
|
|
1011
|
+
},
|
|
1012
|
+
href: actionHref,
|
|
1013
|
+
children: actionLabel
|
|
1014
|
+
})
|
|
1015
|
+
]
|
|
1016
|
+
}), { classNames: { toast: variant === "critical" ? `${index_module_default.toast} ${index_module_default.critical}` : index_module_default.toast } });
|
|
1017
|
+
}
|
|
1018
|
+
//#endregion
|
|
1019
|
+
export { ToastProvider as n, showToast as r, InternalToastProvider as t };
|