@scalar/use-toasts 0.6.7 → 0.7.1
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/CHANGELOG.md +17 -0
- package/dist/components/ScalarToasts.vue.d.ts +1 -0
- package/dist/components/ScalarToasts.vue.d.ts.map +1 -1
- package/dist/components/ScalarToasts.vue.js +28 -0
- package/dist/components/ScalarToasts.vue2.js +4 -0
- package/dist/components/ScalarToasts.vue3.js +5 -0
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useToasts.js +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -612
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @scalar/use-toasts
|
|
2
2
|
|
|
3
|
+
## 0.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e0fc110: chore: patch bump all package
|
|
8
|
+
|
|
9
|
+
## 0.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 7f8ef74: chore: remove aliasing
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- b38c7ed: Update build configs to a standardized format
|
|
18
|
+
- 6fbb57e: feat: release all the packages
|
|
19
|
+
|
|
3
20
|
## 0.6.7
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
2
|
export default _default;
|
|
3
|
+
|
|
3
4
|
//# sourceMappingURL=ScalarToasts.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarToasts.vue.d.ts","sourceRoot":"","sources":["../../src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oBAAoB,IAAK,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineComponent as c, ref as i, onMounted as u, openBlock as m, createBlock as f, unref as p, createCommentVNode as l } from "vue";
|
|
2
|
+
import { toast as t, Toaster as d } from "vue-sonner";
|
|
3
|
+
import { useToasts as _ } from "../hooks/useToasts.js";
|
|
4
|
+
const v = /* @__PURE__ */ c({
|
|
5
|
+
__name: "ScalarToasts",
|
|
6
|
+
setup(T) {
|
|
7
|
+
const o = i(!1);
|
|
8
|
+
u(() => o.value = !0);
|
|
9
|
+
const e = {
|
|
10
|
+
success: t.success,
|
|
11
|
+
error: t.error,
|
|
12
|
+
warn: t.warning,
|
|
13
|
+
info: t
|
|
14
|
+
}, { initializeToasts: a } = _();
|
|
15
|
+
return a((s, r = "info", n = {}) => {
|
|
16
|
+
(e[r] || e.info)(s, {
|
|
17
|
+
duration: n.timeout || 3e3,
|
|
18
|
+
description: n.description
|
|
19
|
+
});
|
|
20
|
+
}), (s, r) => o.value ? (m(), f(p(d), {
|
|
21
|
+
key: 0,
|
|
22
|
+
toastOptions: { className: "toaster" }
|
|
23
|
+
})) : l("", !0);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
v as default
|
|
28
|
+
};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './useToasts';
|
|
1
|
+
export * from './useToasts.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const o = {
|
|
2
|
+
toast: () => null
|
|
3
|
+
};
|
|
4
|
+
function a(t) {
|
|
5
|
+
o.toast = t;
|
|
6
|
+
}
|
|
7
|
+
function i() {
|
|
8
|
+
return {
|
|
9
|
+
initializeToasts: a,
|
|
10
|
+
toast: (t, s = "info", n = { timeout: 3e3 }) => {
|
|
11
|
+
o.toast(t, s, n);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
a as initializeToasts,
|
|
17
|
+
i as useToasts
|
|
18
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,614 +1,9 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var elementStyle = document.createElement("style");
|
|
6
|
-
elementStyle.appendChild(document.createTextNode("/**\n* We need to be explicit to avoid !important. :)\n*\n* Original: https://github.com/xiaoluoboding/vue-sonner/blob/311ecc8d9a51b619f968e20f4b44992ad8412850/packages/styles.css#L91-L103\n*/\n.toaster[data-sonner-toast][data-styled='true'] {\n background: var(--scalar-background-1);\n color: var(--scalar-color-1);\n padding: 18px;\n border: none;\n border-radius: var(--scalar-radius-lg);\n font-size: var(--scalar-font-size-3);\n font-weight: var(--scalar-font-medium);\n box-shadow: var(--scalar-shadow-2);\n}\n.toaster[data-sonner-toast] [data-icon] {\n align-self: start;\n}\n.toaster[data-sonner-toast][data-styled='true'][data-expanded='true'] {\n height: auto;\n}\n.toaster[data-sonner-toast][data-type='error'] {\n background: var(--scalar-background-1);\n}\n.toaster[data-sonner-toast][data-type='error'] [data-icon] {\n color: color-mix(in srgb, var(--scalar-color-red) 75%, var(--scalar-color-1));\n}\n.toaster[data-sonner-toast][data-type='warning'] {\n background: var(--scalar-background-1);\n}\n.toaster[data-sonner-toast][data-type='warning'] [data-icon] {\n color: color-mix(\n in srgb,\n var(--scalar-color-orange) 90%,\n var(--scalar-color-1)\n );\n}"));
|
|
7
|
-
document.head.appendChild(elementStyle);
|
|
8
|
-
}
|
|
9
|
-
} catch (e) {
|
|
10
|
-
console.error("vite-plugin-css-injected-by-js", e);
|
|
11
|
-
}
|
|
12
|
-
})();
|
|
13
|
-
import { defineComponent, useAttrs, ref, computed, onMounted, nextTick, onUnmounted, watch, watchEffect, openBlock, createElementBlock, unref, createElementVNode, normalizeStyle, Fragment, renderList, createBlock, normalizeClass, createVNode, createCommentVNode, createTextVNode, toDisplayString, resolveDynamicComponent } from "vue";
|
|
14
|
-
var yt = Object.defineProperty;
|
|
15
|
-
var xt = (r, t, e) => t in r ? yt(r, t, { enumerable: true, configurable: true, writable: true, value: e }) : r[t] = e;
|
|
16
|
-
var g = (r, t, e) => (xt(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
17
|
-
function wt(r) {
|
|
18
|
-
if (!r || typeof document > "u")
|
|
19
|
-
return;
|
|
20
|
-
let t = document.head || document.getElementsByTagName("head")[0], e = document.createElement("style");
|
|
21
|
-
e.type = "text/css", t.appendChild(e), e.styleSheet ? e.styleSheet.cssText = r : e.appendChild(document.createTextNode(r));
|
|
22
|
-
}
|
|
23
|
-
wt("[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}[data-sonner-toaster][data-x-position=right]{right:max(var(--offset),env(safe-area-inset-right))}[data-sonner-toaster][data-x-position=left]{left:max(var(--offset),env(safe-area-inset-left))}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:max(var(--offset),env(safe-area-inset-top))}[data-sonner-toaster][data-y-position=bottom]{bottom:max(var(--offset),env(safe-area-inset-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;will-change:transform,opacity,height;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-description]{font-weight:400;line-height:1.4;color:inherit}[data-sonner-toast] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast] [data-icon]{display:flex;height:20px;width:20px;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-icon]>*{flex-shrink:0}[data-sonner-toast] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast] [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;cursor:pointer;outline:0;transition:opacity .4s,box-shadow .2s;z-index:100}[data-sonner-toast] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toast][data-theme=dark] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast] [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;background:var(--gray1);color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;opacity:0;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [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-disabled=true]{cursor:not-allowed}[data-sonner-toast]:hover [data-close-button]{opacity:1}[data-sonner-toast]:focus [data-close-button]{opacity:1}[data-sonner-toast]:focus-within [data-close-button]{opacity:1}[data-sonner-toast]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]:before{content:'';position:absolute;left:0;right:0;height:100%}[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]: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-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,0));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{from{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;--mobile-offset:16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - 32px)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 91%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 91%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 91%);--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-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-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--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, 100%, 12%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 12%);--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-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);inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{display:none;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}}");
|
|
24
|
-
let tt = 1;
|
|
25
|
-
class Bt {
|
|
26
|
-
constructor() {
|
|
27
|
-
g(this, "subscribers");
|
|
28
|
-
g(this, "toasts");
|
|
29
|
-
g(this, "subscribe", (t) => (this.subscribers.push(t), () => {
|
|
30
|
-
const e = this.subscribers.indexOf(t);
|
|
31
|
-
this.subscribers.splice(e, 1);
|
|
32
|
-
}));
|
|
33
|
-
g(this, "publish", (t) => {
|
|
34
|
-
this.subscribers.forEach((e) => e(t));
|
|
35
|
-
});
|
|
36
|
-
g(this, "addToast", (t) => {
|
|
37
|
-
this.publish(t), this.toasts = [...this.toasts, t];
|
|
38
|
-
});
|
|
39
|
-
g(this, "create", (t) => {
|
|
40
|
-
var h;
|
|
41
|
-
const { message: e, ...n } = t, a = typeof (t == null ? void 0 : t.id) == "number" || ((h = t.id) == null ? void 0 : h.length) > 0 ? t.id : tt++, p = this.toasts.findIndex((x) => x.id === a), u = t.dismissible === void 0 ? true : t.dismissible;
|
|
42
|
-
return p !== -1 ? this.toasts = this.toasts.map((x) => x.id === a ? (this.publish({ ...x, ...t, id: a, title: e }), {
|
|
43
|
-
...x,
|
|
44
|
-
...t,
|
|
45
|
-
id: a,
|
|
46
|
-
dismissible: u,
|
|
47
|
-
title: e
|
|
48
|
-
}) : x) : this.addToast({ title: e, ...n, dismissible: u, id: a }), a;
|
|
49
|
-
});
|
|
50
|
-
g(this, "dismiss", (t) => (t || this.toasts.forEach((e) => {
|
|
51
|
-
this.subscribers.forEach(
|
|
52
|
-
(n) => n({ id: e.id, dismiss: true })
|
|
53
|
-
);
|
|
54
|
-
}), this.subscribers.forEach((e) => e({ id: t, dismiss: true })), t));
|
|
55
|
-
g(this, "message", (t, e) => this.create({ ...e, message: t }));
|
|
56
|
-
g(this, "error", (t, e) => this.create({ ...e, type: "error", message: t }));
|
|
57
|
-
g(this, "success", (t, e) => this.create({ ...e, type: "success", message: t }));
|
|
58
|
-
g(this, "info", (t, e) => this.create({ ...e, type: "info", message: t }));
|
|
59
|
-
g(this, "warning", (t, e) => this.create({ ...e, type: "warning", message: t }));
|
|
60
|
-
g(this, "loading", (t, e) => this.create({ ...e, type: "loading", message: t }));
|
|
61
|
-
g(this, "promise", (t, e) => {
|
|
62
|
-
if (!e)
|
|
63
|
-
return;
|
|
64
|
-
let n;
|
|
65
|
-
e.loading !== void 0 && (n = this.create({
|
|
66
|
-
...e,
|
|
67
|
-
promise: t,
|
|
68
|
-
type: "loading",
|
|
69
|
-
message: e.loading
|
|
70
|
-
}));
|
|
71
|
-
const a = t instanceof Promise ? t : t();
|
|
72
|
-
let p = n !== void 0;
|
|
73
|
-
return a.then((u) => {
|
|
74
|
-
if (e.success !== void 0) {
|
|
75
|
-
p = false;
|
|
76
|
-
const h = typeof e.success == "function" ? e.success(u) : e.success;
|
|
77
|
-
this.create({ id: n, type: "success", message: h });
|
|
78
|
-
}
|
|
79
|
-
}).catch((u) => {
|
|
80
|
-
if (e.error !== void 0) {
|
|
81
|
-
p = false;
|
|
82
|
-
const h = typeof e.error == "function" ? e.error(u) : e.error;
|
|
83
|
-
this.create({ id: n, type: "error", message: h });
|
|
84
|
-
}
|
|
85
|
-
}).finally(() => {
|
|
86
|
-
var u;
|
|
87
|
-
p && (this.dismiss(n), n = void 0), (u = e.finally) == null || u.call(e);
|
|
88
|
-
}), n;
|
|
89
|
-
});
|
|
90
|
-
g(this, "custom", (t, e) => {
|
|
91
|
-
const n = (e == null ? void 0 : e.id) || tt++;
|
|
92
|
-
return this.publish({ ...e, id: n, title: t }), n;
|
|
93
|
-
});
|
|
94
|
-
this.subscribers = [], this.toasts = [];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const k = new Bt(), Et = (r, t) => {
|
|
98
|
-
const e = (t == null ? void 0 : t.id) || tt++;
|
|
99
|
-
return k.publish({
|
|
100
|
-
title: r,
|
|
101
|
-
...t,
|
|
102
|
-
id: e
|
|
103
|
-
}), e;
|
|
104
|
-
}, St = Et, Ie = Object.assign(St, {
|
|
105
|
-
success: k.success,
|
|
106
|
-
info: k.info,
|
|
107
|
-
warning: k.warning,
|
|
108
|
-
error: k.error,
|
|
109
|
-
custom: k.custom,
|
|
110
|
-
message: k.message,
|
|
111
|
-
promise: k.promise,
|
|
112
|
-
dismiss: k.dismiss,
|
|
113
|
-
loading: k.loading
|
|
114
|
-
}), It = ["data-visible"], zt = { className: "sonner-spinner" }, Nt = /* @__PURE__ */ defineComponent({
|
|
115
|
-
__name: "Loader",
|
|
116
|
-
props: {
|
|
117
|
-
visible: Boolean
|
|
118
|
-
},
|
|
119
|
-
setup(r) {
|
|
120
|
-
const t = Array(12).fill(0);
|
|
121
|
-
return (e, n) => (openBlock(), createElementBlock("div", {
|
|
122
|
-
className: "sonner-loading-wrapper",
|
|
123
|
-
"data-visible": r.visible
|
|
124
|
-
}, [
|
|
125
|
-
createElementVNode("div", zt, [
|
|
126
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(t), (a) => (openBlock(), createElementBlock("div", {
|
|
127
|
-
key: `spinner-bar-${a}`,
|
|
128
|
-
className: "sonner-loading-bar"
|
|
129
|
-
}))), 128))
|
|
130
|
-
])
|
|
131
|
-
], 8, It));
|
|
132
|
-
}
|
|
133
|
-
}), H = (r, t) => {
|
|
134
|
-
const e = r.__vccOpts || r;
|
|
135
|
-
for (const [n, a] of t)
|
|
136
|
-
e[n] = a;
|
|
137
|
-
return e;
|
|
138
|
-
}, Mt = {}, Ot = {
|
|
139
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
140
|
-
viewBox: "0 0 20 20",
|
|
141
|
-
fill: "currentColor",
|
|
142
|
-
height: "20",
|
|
143
|
-
width: "20"
|
|
144
|
-
}, Pt = /* @__PURE__ */ createElementVNode("path", {
|
|
145
|
-
"fill-rule": "evenodd",
|
|
146
|
-
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",
|
|
147
|
-
"clip-rule": "evenodd"
|
|
148
|
-
}, null, -1), At = [
|
|
149
|
-
Pt
|
|
150
|
-
];
|
|
151
|
-
function Dt(r, t) {
|
|
152
|
-
return openBlock(), createElementBlock("svg", Ot, At);
|
|
153
|
-
}
|
|
154
|
-
const Yt = /* @__PURE__ */ H(Mt, [["render", Dt]]), Rt = {}, Ht = {
|
|
155
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
156
|
-
viewBox: "0 0 20 20",
|
|
157
|
-
fill: "currentColor",
|
|
158
|
-
height: "20",
|
|
159
|
-
width: "20"
|
|
160
|
-
}, Lt = /* @__PURE__ */ createElementVNode("path", {
|
|
161
|
-
"fill-rule": "evenodd",
|
|
162
|
-
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",
|
|
163
|
-
"clip-rule": "evenodd"
|
|
164
|
-
}, null, -1), Ut = [
|
|
165
|
-
Lt
|
|
166
|
-
];
|
|
167
|
-
function Vt(r, t) {
|
|
168
|
-
return openBlock(), createElementBlock("svg", Ht, Ut);
|
|
169
|
-
}
|
|
170
|
-
const jt = /* @__PURE__ */ H(Rt, [["render", Vt]]), Ft = {}, Kt = {
|
|
171
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
172
|
-
viewBox: "0 0 24 24",
|
|
173
|
-
fill: "currentColor",
|
|
174
|
-
height: "20",
|
|
175
|
-
width: "20"
|
|
176
|
-
}, Wt = /* @__PURE__ */ createElementVNode("path", {
|
|
177
|
-
"fill-rule": "evenodd",
|
|
178
|
-
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",
|
|
179
|
-
"clip-rule": "evenodd"
|
|
180
|
-
}, null, -1), Xt = [
|
|
181
|
-
Wt
|
|
182
|
-
];
|
|
183
|
-
function Gt(r, t) {
|
|
184
|
-
return openBlock(), createElementBlock("svg", Kt, Xt);
|
|
185
|
-
}
|
|
186
|
-
const qt = /* @__PURE__ */ H(Ft, [["render", Gt]]), Jt = {}, Qt = {
|
|
187
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
188
|
-
viewBox: "0 0 20 20",
|
|
189
|
-
fill: "currentColor",
|
|
190
|
-
height: "20",
|
|
191
|
-
width: "20"
|
|
192
|
-
}, Zt = /* @__PURE__ */ createElementVNode("path", {
|
|
193
|
-
"fill-rule": "evenodd",
|
|
194
|
-
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",
|
|
195
|
-
"clip-rule": "evenodd"
|
|
196
|
-
}, null, -1), te = [
|
|
197
|
-
Zt
|
|
198
|
-
];
|
|
199
|
-
function ee(r, t) {
|
|
200
|
-
return openBlock(), createElementBlock("svg", Qt, te);
|
|
201
|
-
}
|
|
202
|
-
const ae = /* @__PURE__ */ H(Jt, [["render", ee]]), oe = {}, se = {
|
|
203
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
204
|
-
width: "12",
|
|
205
|
-
height: "12",
|
|
206
|
-
viewBox: "0 0 24 24",
|
|
207
|
-
fill: "none",
|
|
208
|
-
stroke: "currentColor",
|
|
209
|
-
"stoke-width": "1.5",
|
|
210
|
-
"stroke-linecap": "round",
|
|
211
|
-
"stroke-linejoin": "round"
|
|
212
|
-
}, ne = /* @__PURE__ */ createElementVNode("line", {
|
|
213
|
-
x1: "18",
|
|
214
|
-
y1: "6",
|
|
215
|
-
x2: "6",
|
|
216
|
-
y2: "18"
|
|
217
|
-
}, null, -1), re = /* @__PURE__ */ createElementVNode("line", {
|
|
218
|
-
x1: "6",
|
|
219
|
-
y1: "6",
|
|
220
|
-
x2: "18",
|
|
221
|
-
y2: "18"
|
|
222
|
-
}, null, -1), ie = [
|
|
223
|
-
ne,
|
|
224
|
-
re
|
|
225
|
-
];
|
|
226
|
-
function le(r, t) {
|
|
227
|
-
return openBlock(), createElementBlock("svg", se, ie);
|
|
228
|
-
}
|
|
229
|
-
const de = /* @__PURE__ */ H(oe, [["render", le]]), ce = ["aria-live", "data-styled", "data-mounted", "data-promise", "data-removed", "data-visible", "data-y-position", "data-x-position", "data-index", "data-front", "data-swiping", "data-type", "data-invert", "data-swipe-out", "data-expanded"], ue = ["data-disabled"], fe = {
|
|
230
|
-
key: 1,
|
|
231
|
-
"data-icon": ""
|
|
232
|
-
}, pe = { "data-content": "" }, me = { "data-title": "" }, he = 4e3, ge = 14, ve = 20, be = 200, ye = /* @__PURE__ */ defineComponent({
|
|
233
|
-
__name: "Toast",
|
|
234
|
-
props: {
|
|
235
|
-
toast: {},
|
|
236
|
-
toasts: {},
|
|
237
|
-
index: {},
|
|
238
|
-
expanded: { type: Boolean },
|
|
239
|
-
invert: { type: Boolean },
|
|
240
|
-
heights: {},
|
|
241
|
-
position: {},
|
|
242
|
-
visibleToasts: {},
|
|
243
|
-
expandByDefault: { type: Boolean },
|
|
244
|
-
closeButton: { type: Boolean },
|
|
245
|
-
interacting: { type: Boolean },
|
|
246
|
-
duration: {},
|
|
247
|
-
descriptionClass: {}
|
|
248
|
-
},
|
|
249
|
-
emits: ["update:heights", "removeToast"],
|
|
250
|
-
setup(r, { emit: t }) {
|
|
251
|
-
const e = (o) => !!o.promise, n = t, a = r, p = ref(false), u = ref(false), h = ref(false), x = ref(false), w = ref(null), z = ref(0), L = ref(0), U = ref(null), s = ref(null), i = computed(() => a.index === 0), b = computed(() => a.index + 1 <= a.visibleToasts), y = computed(() => a.toast.type), N = computed(() => a.toast.dismissible), B = a.toast.className || "", E = a.toast.descriptionClassName || "", V = a.toast.style || {}, P = computed(
|
|
252
|
-
() => a.heights.findIndex((o) => o.toastId === a.toast.id) || 0
|
|
253
|
-
), K = computed(
|
|
254
|
-
() => a.toast.duration || a.duration || he
|
|
255
|
-
), W = ref(0), A = ref(0), X = ref(K.value), at = ref(0), M = ref(null), G = computed(() => a.position.split("-")), ct = computed(() => G.value[0]), ut = computed(() => G.value[1]), ft = computed(() => a.heights.reduce((o, l, m) => m >= P.value ? o : o + l.height, 0)), pt = computed(() => a.toast.invert || a.invert), q = computed(() => w.value === "loading"), j = computed(
|
|
256
|
-
() => w.value ?? (a.toast.type || null)
|
|
257
|
-
), J = computed(() => !e(a.toast) && typeof a.toast.title == "object"), mt = computed(() => {
|
|
258
|
-
if (!e(a.toast))
|
|
259
|
-
return null;
|
|
260
|
-
switch (w.value) {
|
|
261
|
-
case "loading":
|
|
262
|
-
return a.toast.loading;
|
|
263
|
-
case "success":
|
|
264
|
-
return typeof a.toast.success == "function" ? U.value : a.toast.success;
|
|
265
|
-
case "error":
|
|
266
|
-
return typeof a.toast.error == "function" ? U.value : a.toast.error;
|
|
267
|
-
default:
|
|
268
|
-
return null;
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
onMounted(() => p.value = true), watchEffect(() => {
|
|
272
|
-
A.value = P.value * ge + ft.value;
|
|
273
|
-
});
|
|
274
|
-
function ht() {
|
|
275
|
-
var o, l;
|
|
276
|
-
(!q.value || N.value) && (S(), (l = (o = a.toast).onDismiss) == null || l.call(o, a.toast));
|
|
277
|
-
}
|
|
278
|
-
function S() {
|
|
279
|
-
u.value = true, z.value = A.value;
|
|
280
|
-
const o = a.heights.filter(
|
|
281
|
-
(l) => l.toastId !== a.toast.id
|
|
282
|
-
);
|
|
283
|
-
n("update:heights", o), setTimeout(() => {
|
|
284
|
-
n("removeToast", a.toast);
|
|
285
|
-
}, be);
|
|
286
|
-
}
|
|
287
|
-
const gt = (o) => {
|
|
288
|
-
q || (z.value = A.value, o.target.setPointerCapture(o.pointerId), o.target.tagName !== "BUTTON" && (h.value = true, M.value = { x: o.clientX, y: o.clientY }));
|
|
289
|
-
}, vt = (o) => {
|
|
290
|
-
var m, D, _, $;
|
|
291
|
-
if (x.value)
|
|
292
|
-
return;
|
|
293
|
-
M.value = null;
|
|
294
|
-
const l = Number(
|
|
295
|
-
((m = s.value) == null ? void 0 : m.style.getPropertyValue("--swipe-amount").replace("px", "")) || 0
|
|
296
|
-
);
|
|
297
|
-
if (Math.abs(l) >= ve) {
|
|
298
|
-
z.value = A.value, (_ = (D = a.toast).onDismiss) == null || _.call(D, a.toast), S(), x.value = true;
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
($ = s.value) == null || $.style.setProperty("--swipe-amount", "0px"), h.value = true;
|
|
302
|
-
}, bt = (o) => {
|
|
303
|
-
var ot;
|
|
304
|
-
if (!M.value)
|
|
305
|
-
return;
|
|
306
|
-
const l = o.clientY - M.value.y, m = o.clientX - M.value.x, _ = (G.value[0] === "top" ? Math.min : Math.max)(0, l), $ = o.pointerType === "touch" ? 10 : 2;
|
|
307
|
-
Math.abs(_) > $ ? (ot = s.value) == null || ot.style.setProperty("--swipe-amount", `${l}px`) : Math.abs(m) > $ && (M.value = null);
|
|
308
|
-
};
|
|
309
|
-
return watchEffect((o) => {
|
|
310
|
-
if (a.toast.promise && w.value === "loading" || a.toast.duration === 1 / 0)
|
|
311
|
-
return;
|
|
312
|
-
let l;
|
|
313
|
-
const m = () => {
|
|
314
|
-
if (at.value < W.value) {
|
|
315
|
-
const _ = (/* @__PURE__ */ new Date()).getTime() - W.value;
|
|
316
|
-
X.value = X.value - _;
|
|
317
|
-
}
|
|
318
|
-
at.value = (/* @__PURE__ */ new Date()).getTime();
|
|
319
|
-
}, D = () => {
|
|
320
|
-
W.value = (/* @__PURE__ */ new Date()).getTime(), l = setTimeout(() => {
|
|
321
|
-
var _, $;
|
|
322
|
-
($ = (_ = a.toast).onAutoClose) == null || $.call(_, a.toast), S();
|
|
323
|
-
}, X.value);
|
|
324
|
-
};
|
|
325
|
-
a.expanded || a.interacting ? m() : D(), o(() => {
|
|
326
|
-
clearTimeout(l);
|
|
327
|
-
});
|
|
328
|
-
}), onMounted(() => {
|
|
329
|
-
if (s.value) {
|
|
330
|
-
const o = s.value.getBoundingClientRect().height;
|
|
331
|
-
L.value = o;
|
|
332
|
-
const l = [{ toastId: a.toast.id, height: o }, ...a.heights];
|
|
333
|
-
n("update:heights", l);
|
|
334
|
-
}
|
|
335
|
-
}), onUnmounted(() => {
|
|
336
|
-
if (s.value) {
|
|
337
|
-
const o = a.heights.filter(
|
|
338
|
-
(l) => l.toastId !== a.toast.id
|
|
339
|
-
);
|
|
340
|
-
n("update:heights", o);
|
|
341
|
-
}
|
|
342
|
-
}), watchEffect(() => {
|
|
343
|
-
a.toast.delete && S();
|
|
344
|
-
}), (o, l) => (openBlock(), createElementBlock("li", {
|
|
345
|
-
"aria-live": o.toast.important ? "assertive" : "polite",
|
|
346
|
-
"aria-atomic": "",
|
|
347
|
-
role: "status",
|
|
348
|
-
tabindex: "0",
|
|
349
|
-
ref_key: "toastRef",
|
|
350
|
-
ref: s,
|
|
351
|
-
"data-sonner-toast": "",
|
|
352
|
-
class: normalizeClass(unref(B)),
|
|
353
|
-
"data-styled": !J.value,
|
|
354
|
-
"data-mounted": p.value,
|
|
355
|
-
"data-promise": !!o.toast.promise,
|
|
356
|
-
"data-removed": u.value,
|
|
357
|
-
"data-visible": b.value,
|
|
358
|
-
"data-y-position": ct.value,
|
|
359
|
-
"data-x-position": ut.value,
|
|
360
|
-
"data-index": a.index,
|
|
361
|
-
"data-front": i.value,
|
|
362
|
-
"data-swiping": h.value,
|
|
363
|
-
"data-type": w.value !== "loading" && w.value ? w.value : y.value,
|
|
364
|
-
"data-invert": pt.value,
|
|
365
|
-
"data-swipe-out": x.value,
|
|
366
|
-
"data-expanded": !!(a.expanded || a.expandByDefault && p.value),
|
|
367
|
-
style: normalizeStyle({
|
|
368
|
-
"--index": a.index,
|
|
369
|
-
"--toasts-before": a.index,
|
|
370
|
-
"--z-index": o.toasts.length - a.index,
|
|
371
|
-
"--offset": `${u.value ? z.value : A.value}px`,
|
|
372
|
-
"--initial-height": a.expandByDefault ? "auto" : `${L.value}px`,
|
|
373
|
-
...unref(V)
|
|
374
|
-
}),
|
|
375
|
-
onPointerdown: gt,
|
|
376
|
-
onPointerup: vt,
|
|
377
|
-
onPointermove: bt
|
|
378
|
-
}, [
|
|
379
|
-
a.closeButton && !J.value ? (openBlock(), createElementBlock("button", {
|
|
380
|
-
key: 0,
|
|
381
|
-
"aria-label": "Close toast",
|
|
382
|
-
"data-close-button": "",
|
|
383
|
-
"data-disabled": q.value,
|
|
384
|
-
onClick: ht
|
|
385
|
-
}, [
|
|
386
|
-
createVNode(de)
|
|
387
|
-
], 8, ue)) : createCommentVNode("", true),
|
|
388
|
-
y.value || o.toast.icon || o.toast.promise ? (openBlock(), createElementBlock("div", fe, [
|
|
389
|
-
typeof o.toast.promise == "function" || y.value === "loading" ? (openBlock(), createBlock(Nt, {
|
|
390
|
-
key: 0,
|
|
391
|
-
visible: w.value === "loading" || y.value === "loading"
|
|
392
|
-
}, null, 8, ["visible"])) : createCommentVNode("", true),
|
|
393
|
-
j.value === "success" ? (openBlock(), createBlock(Yt, { key: 1 })) : j.value === "info" ? (openBlock(), createBlock(jt, { key: 2 })) : j.value === "warning" ? (openBlock(), createBlock(qt, { key: 3 })) : j.value === "error" ? (openBlock(), createBlock(ae, { key: 4 })) : createCommentVNode("", true)
|
|
394
|
-
])) : createCommentVNode("", true),
|
|
395
|
-
createElementVNode("div", pe, [
|
|
396
|
-
createElementVNode("div", me, [
|
|
397
|
-
typeof o.toast.title == "string" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
398
|
-
createTextVNode(toDisplayString(o.toast.title), 1)
|
|
399
|
-
], 64)) : o.toast.title === void 0 || o.toast.title === null ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
400
|
-
createTextVNode(toDisplayString(mt.value), 1)
|
|
401
|
-
], 64)) : J.value ? (openBlock(), createBlock(resolveDynamicComponent(o.toast.title), {
|
|
402
|
-
key: 2,
|
|
403
|
-
onCloseToast: l[0] || (l[0] = () => {
|
|
404
|
-
var m;
|
|
405
|
-
S(), (m = o.toast.cancel) != null && m.onClick && o.toast.cancel.onClick();
|
|
406
|
-
})
|
|
407
|
-
}, null, 32)) : createCommentVNode("", true)
|
|
408
|
-
]),
|
|
409
|
-
o.toast.description ? (openBlock(), createElementBlock("div", {
|
|
410
|
-
key: 0,
|
|
411
|
-
"data-description": "",
|
|
412
|
-
class: normalizeClass(o.descriptionClass + unref(E))
|
|
413
|
-
}, toDisplayString(o.toast.description), 3)) : createCommentVNode("", true)
|
|
414
|
-
]),
|
|
415
|
-
o.toast.cancel ? (openBlock(), createElementBlock("button", {
|
|
416
|
-
key: 2,
|
|
417
|
-
"data-button": "",
|
|
418
|
-
"data-cancel": "",
|
|
419
|
-
onClick: l[1] || (l[1] = () => {
|
|
420
|
-
var m;
|
|
421
|
-
S(), (m = o.toast.cancel) != null && m.onClick && o.toast.cancel.onClick();
|
|
422
|
-
})
|
|
423
|
-
}, toDisplayString(o.toast.cancel.label), 1)) : createCommentVNode("", true),
|
|
424
|
-
o.toast.action ? (openBlock(), createElementBlock("button", {
|
|
425
|
-
key: 3,
|
|
426
|
-
"data-button": "",
|
|
427
|
-
onClick: l[2] || (l[2] = () => {
|
|
428
|
-
var m;
|
|
429
|
-
S(), (m = o.toast.action) == null || m.onClick();
|
|
430
|
-
})
|
|
431
|
-
}, toDisplayString(o.toast.action.label), 1)) : createCommentVNode("", true)
|
|
432
|
-
], 46, ce));
|
|
433
|
-
}
|
|
434
|
-
}), xe = ["aria-label"], we = ["dir", "data-theme", "data-rich-colors", "data-y-position", "data-x-position"], ke = 3, rt = "32px", Te = 4e3, _e = 356, it = 14, $e = typeof window < "u" && typeof document < "u", Ce = /* @__PURE__ */ defineComponent({
|
|
435
|
-
name: "Toaster",
|
|
436
|
-
inheritAttrs: false,
|
|
437
|
-
__name: "Toaster",
|
|
438
|
-
props: {
|
|
439
|
-
invert: { type: Boolean, default: false },
|
|
440
|
-
theme: { default: "light" },
|
|
441
|
-
position: { default: "bottom-right" },
|
|
442
|
-
hotkey: { default: () => ["altKey", "KeyT"] },
|
|
443
|
-
richColors: { type: Boolean, default: false },
|
|
444
|
-
expand: { type: Boolean, default: false },
|
|
445
|
-
duration: { default: Te },
|
|
446
|
-
gap: { default: it },
|
|
447
|
-
visibleToasts: { default: ke },
|
|
448
|
-
closeButton: { type: Boolean, default: false },
|
|
449
|
-
toastOptions: { default: () => ({}) },
|
|
450
|
-
className: { default: "" },
|
|
451
|
-
style: { default: () => ({}) },
|
|
452
|
-
offset: { default: rt },
|
|
453
|
-
dir: { default: "auto" }
|
|
454
|
-
},
|
|
455
|
-
setup(r) {
|
|
456
|
-
const t = r, e = useAttrs(), n = ref([]), a = ref([]), p = ref(false), u = ref(false), h = ref(
|
|
457
|
-
t.theme !== "system" ? t.theme : typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
|
458
|
-
), x = computed(() => t.position.split("-")), w = ref(null), z = t.hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
459
|
-
function L(s) {
|
|
460
|
-
n.value = n.value.filter(({ id: i }) => i !== s.id);
|
|
461
|
-
}
|
|
462
|
-
function U() {
|
|
463
|
-
if (typeof window > "u")
|
|
464
|
-
return "ltr";
|
|
465
|
-
const s = document.documentElement.getAttribute("dir");
|
|
466
|
-
return s === "auto" || !s ? window.getComputedStyle(document.documentElement).direction : s;
|
|
467
|
-
}
|
|
468
|
-
return onMounted(() => {
|
|
469
|
-
const s = k.subscribe((i) => {
|
|
470
|
-
if (i.dismiss) {
|
|
471
|
-
n.value = n.value.map(
|
|
472
|
-
(b) => b.id === i.id ? { ...b, delete: true } : b
|
|
473
|
-
);
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
nextTick(() => {
|
|
477
|
-
const b = n.value.findIndex((y) => y.id === i.id);
|
|
478
|
-
b !== -1 ? n.value.splice(b, 1, i) : n.value = [i, ...n.value];
|
|
479
|
-
});
|
|
480
|
-
});
|
|
481
|
-
onUnmounted(() => {
|
|
482
|
-
s();
|
|
483
|
-
});
|
|
484
|
-
}), watch(
|
|
485
|
-
() => t.theme,
|
|
486
|
-
(s) => {
|
|
487
|
-
if (s !== "system") {
|
|
488
|
-
h.value = s;
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
s === "system" && (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? h.value = "dark" : h.value = "light"), !(typeof window > "u") && window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", ({ matches: i }) => {
|
|
492
|
-
i ? h.value = "dark" : h.value = "light";
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
), watchEffect(() => {
|
|
496
|
-
n.value.length <= 1 && (p.value = false);
|
|
497
|
-
}), watchEffect((s) => {
|
|
498
|
-
function i(b) {
|
|
499
|
-
var N, B;
|
|
500
|
-
t.hotkey.every(
|
|
501
|
-
(E) => b[E] || b.code === E
|
|
502
|
-
) && (p.value = true, (N = w.value) == null || N.focus()), b.code === "Escape" && (document.activeElement === w.value || (B = w.value) != null && B.contains(document.activeElement)) && (p.value = false);
|
|
503
|
-
}
|
|
504
|
-
$e && (document.addEventListener("keydown", i), s(() => {
|
|
505
|
-
document.removeEventListener("keydown", i);
|
|
506
|
-
}));
|
|
507
|
-
}), (s, i) => {
|
|
508
|
-
var b;
|
|
509
|
-
return openBlock(), createElementBlock("section", {
|
|
510
|
-
"aria-label": `Notifications ${unref(z)}`,
|
|
511
|
-
tabIndex: -1
|
|
512
|
-
}, [
|
|
513
|
-
createElementVNode("ol", {
|
|
514
|
-
ref_key: "listRef",
|
|
515
|
-
ref: w,
|
|
516
|
-
"data-sonner-toaster": "",
|
|
517
|
-
dir: s.dir === "auto" ? U() : s.dir,
|
|
518
|
-
tabIndex: -1,
|
|
519
|
-
"data-theme": s.theme,
|
|
520
|
-
"data-rich-colors": s.richColors,
|
|
521
|
-
"data-y-position": x.value[0],
|
|
522
|
-
"data-x-position": x.value[1],
|
|
523
|
-
style: normalizeStyle(
|
|
524
|
-
{
|
|
525
|
-
"--front-toast-height": `${(b = a.value[0]) == null ? void 0 : b.height}px`,
|
|
526
|
-
"--offset": typeof s.offset == "number" ? `${s.offset}px` : s.offset || rt,
|
|
527
|
-
"--width": `${_e}px`,
|
|
528
|
-
"--gap": `${it}px`,
|
|
529
|
-
...unref(e).style
|
|
530
|
-
}
|
|
531
|
-
),
|
|
532
|
-
onMouseenter: i[1] || (i[1] = (y) => p.value = true),
|
|
533
|
-
onMousemove: i[2] || (i[2] = (y) => p.value = true),
|
|
534
|
-
onMouseleave: i[3] || (i[3] = () => {
|
|
535
|
-
u.value || (p.value = false);
|
|
536
|
-
}),
|
|
537
|
-
onPointerdown: i[4] || (i[4] = (y) => u.value = false),
|
|
538
|
-
onPointerup: i[5] || (i[5] = (y) => u.value = false)
|
|
539
|
-
}, [
|
|
540
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(n.value, (y, N) => {
|
|
541
|
-
var B, E, V, P;
|
|
542
|
-
return openBlock(), createBlock(ye, {
|
|
543
|
-
key: y.id,
|
|
544
|
-
index: N,
|
|
545
|
-
toast: y,
|
|
546
|
-
duration: ((B = s.toastOptions) == null ? void 0 : B.duration) ?? s.duration,
|
|
547
|
-
className: (E = s.toastOptions) == null ? void 0 : E.className,
|
|
548
|
-
descriptionClassName: (V = s.toastOptions) == null ? void 0 : V.descriptionClassName,
|
|
549
|
-
invert: s.invert,
|
|
550
|
-
visibleToasts: s.visibleToasts,
|
|
551
|
-
closeButton: s.closeButton,
|
|
552
|
-
interacting: u.value,
|
|
553
|
-
position: s.position,
|
|
554
|
-
style: normalizeStyle((P = s.toastOptions) == null ? void 0 : P.style),
|
|
555
|
-
toasts: n.value,
|
|
556
|
-
expandByDefault: s.expand,
|
|
557
|
-
gap: s.gap,
|
|
558
|
-
expanded: p.value,
|
|
559
|
-
heights: a.value,
|
|
560
|
-
"onUpdate:heights": i[0] || (i[0] = (K) => a.value = K),
|
|
561
|
-
onRemoveToast: L
|
|
562
|
-
}, null, 8, ["index", "toast", "duration", "className", "descriptionClassName", "invert", "visibleToasts", "closeButton", "interacting", "position", "style", "toasts", "expandByDefault", "gap", "expanded", "heights"]);
|
|
563
|
-
}), 128))
|
|
564
|
-
], 44, we)
|
|
565
|
-
], 8, xe);
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
const state = {
|
|
570
|
-
toast: () => null
|
|
571
|
-
};
|
|
572
|
-
function initializeToasts(toastFunction) {
|
|
573
|
-
state.toast = toastFunction;
|
|
574
|
-
}
|
|
575
|
-
function useToasts() {
|
|
576
|
-
return {
|
|
577
|
-
initializeToasts,
|
|
578
|
-
toast: (message, level = "info", options = { timeout: 3e3 }) => {
|
|
579
|
-
state.toast(message, level, options);
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
584
|
-
__name: "ScalarToasts",
|
|
585
|
-
setup(__props) {
|
|
586
|
-
const isClientMounted = ref(false);
|
|
587
|
-
onMounted(() => isClientMounted.value = true);
|
|
588
|
-
const toastMethods = {
|
|
589
|
-
success: Ie.success,
|
|
590
|
-
error: Ie.error,
|
|
591
|
-
warn: Ie.warning,
|
|
592
|
-
info: Ie
|
|
593
|
-
};
|
|
594
|
-
const { initializeToasts: initializeToasts2 } = useToasts();
|
|
595
|
-
initializeToasts2((message, level = "info", options = {}) => {
|
|
596
|
-
const toastAction = toastMethods[level] || toastMethods.info;
|
|
597
|
-
toastAction(message, {
|
|
598
|
-
duration: options.timeout || 3e3,
|
|
599
|
-
description: options.description
|
|
600
|
-
});
|
|
601
|
-
});
|
|
602
|
-
return (_ctx, _cache) => {
|
|
603
|
-
return isClientMounted.value ? (openBlock(), createBlock(unref(Ce), {
|
|
604
|
-
key: 0,
|
|
605
|
-
toastOptions: { className: "toaster" }
|
|
606
|
-
})) : createCommentVNode("", true);
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
});
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode(".toaster[data-sonner-toast][data-styled=true]{background:var(--scalar-background-1);color:var(--scalar-color-1);padding:18px;border:none;border-radius:var(--scalar-radius-lg);font-size:var(--scalar-font-size-3);font-weight:var(--scalar-font-medium);box-shadow:var(--scalar-shadow-2)}.toaster[data-sonner-toast] [data-icon]{align-self:start}.toaster[data-sonner-toast][data-styled=true][data-expanded=true]{height:auto}.toaster[data-sonner-toast][data-type=error]{background:var(--scalar-background-1)}.toaster[data-sonner-toast][data-type=error] [data-icon]{color:color-mix(in srgb,var(--scalar-color-red) 75%,var(--scalar-color-1))}.toaster[data-sonner-toast][data-type=warning]{background:var(--scalar-background-1)}.toaster[data-sonner-toast][data-type=warning] [data-icon]{color:color-mix(in srgb,var(--scalar-color-orange) 90%,var(--scalar-color-1))}")),document.head.appendChild(a)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
+
import { default as t } from "./components/ScalarToasts.vue.js";
|
|
3
|
+
import "./components/ScalarToasts.vue2.js";
|
|
4
|
+
import { initializeToasts as e, useToasts as i } from "./hooks/useToasts.js";
|
|
610
5
|
export {
|
|
611
|
-
|
|
612
|
-
initializeToasts,
|
|
613
|
-
useToasts
|
|
6
|
+
t as ScalarToasts,
|
|
7
|
+
e as initializeToasts,
|
|
8
|
+
i as useToasts
|
|
614
9
|
};
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"vue",
|
|
18
18
|
"vue3"
|
|
19
19
|
],
|
|
20
|
-
"version": "0.
|
|
20
|
+
"version": "0.7.1",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=18"
|
|
23
23
|
},
|
|
@@ -29,14 +29,15 @@
|
|
|
29
29
|
],
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@vitejs/plugin-vue": "^5.0.4",
|
|
32
|
-
"@vitest/coverage-v8": "^1.
|
|
33
|
-
"nanoid": "^5.0.
|
|
32
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
33
|
+
"nanoid": "^5.0.7",
|
|
34
34
|
"tsc-alias": "^1.8.8",
|
|
35
35
|
"vite": "^5.2.10",
|
|
36
36
|
"vite-plugin-css-injected-by-js": "^3.4.0",
|
|
37
|
-
"vitest": "^1.
|
|
38
|
-
"vue": "^3.4.
|
|
39
|
-
"vue-tsc": "^
|
|
37
|
+
"vitest": "^1.6.0",
|
|
38
|
+
"vue": "^3.4.22",
|
|
39
|
+
"vue-tsc": "^2.0.13",
|
|
40
|
+
"@scalar/build-tooling": "0.1.6"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"nanoid": "4 - 5",
|