@soft-toast/vue 1.0.2 → 1.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/README.md +8 -8
- package/dist/animations/gsapConfig.d.ts +2 -1
- package/dist/animations/gsapConfig.d.ts.map +1 -1
- package/dist/composables/{useToast.d.ts → useSoftToast.d.ts} +6 -6
- package/dist/composables/useSoftToast.d.ts.map +1 -0
- package/dist/composables/useSoftToast.test.d.ts +2 -0
- package/dist/composables/useSoftToast.test.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +794 -756
- package/dist/stores/toastStore.d.ts +1 -1
- package/dist/stores/toastStore.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +5 -5
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +15 -2
- package/src/animations/gsapConfig.ts +45 -14
- package/src/components/ToastItem.vue +41 -10
- package/src/components/ToastRegion.vue +6 -2
- package/src/composables/useFlash.ts +1 -1
- package/src/composables/{useToast.test.ts → useSoftToast.test.ts} +54 -54
- package/src/composables/{useToast.ts → useSoftToast.ts} +5 -5
- package/src/exports.test.ts +39 -22
- package/src/index.ts +1 -2
- package/src/stores/toastStore.ts +29 -9
- package/src/styles/toast.css +18 -9
- package/src/types/index.ts +5 -5
- package/dist/composables/useToast.d.ts.map +0 -1
- package/dist/composables/useToast.test.d.ts +0 -2
- package/dist/composables/useToast.test.d.ts.map +0 -1
|
@@ -17,7 +17,7 @@ export interface ToastStore {
|
|
|
17
17
|
warning: (title: string, options?: Omit<ToastOptions, 'type' | 'title'>) => string;
|
|
18
18
|
info: (title: string, options?: Omit<ToastOptions, 'type' | 'title'>) => string;
|
|
19
19
|
loading: (title: string, options?: Omit<ToastOptions, 'type' | 'title'>) => string;
|
|
20
|
-
promise: <T>(promiseFn: Promise<T>, messages: ToastPromiseMessages
|
|
20
|
+
promise: <T>(promiseFn: Promise<T>, messages: ToastPromiseMessages<T>, options?: Omit<ToastOptions, 'type' | 'promise' | 'promiseMessages'>) => Promise<T>;
|
|
21
21
|
clearAll: () => void;
|
|
22
22
|
remove: (id: string) => void;
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toastStore.d.ts","sourceRoot":"","sources":["../../src/stores/toastStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"toastStore.d.ts","sourceRoot":"","sources":["../../src/stores/toastStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAwSnG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAEtC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAA;IAC5B,mBAAmB,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,WAAW,CAAC,KAAK,EAAE,CAAC,CAAA;IACtE,GAAG,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,MAAM,CAAA;IACtC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;IAC5D,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;KAAE,KAAK,IAAI,CAAA;IACnE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3B,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5B,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CA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om:32px;margin-top:-32px;margin-bottom:-32px;width:100%;max-width:100%;display:flex;flex-direction:column;touch-action:manipulation}.soft-toast-container[data-expanded=true] .soft-toast-stack[data-v-ee86226d]{touch-action:none}.soft-toast-list[data-v-ee86226d]{position:relative;width:100%;flex-shrink:0}.soft-toast-stack[data-direction=up] .soft-toast-list[data-v-ee86226d]{margin-top:auto}.soft-toast-stack[data-direction=down] .soft-toast-list[data-v-ee86226d]{margin-bottom:auto}.soft-toast-list[data-v-ee86226d]>.soft-toast-item{position:absolute;width:100%}.soft-toast-container[data-position$=left] .soft-toast-list[data-v-ee86226d]>.soft-toast-item{left:0;right:auto}.soft-toast-container[data-position$=right] .soft-toast-list[data-v-ee86226d]>.soft-toast-item{right:0;left:auto}.soft-toast-stack[data-direction=down][data-v-ee86226d] .soft-toast-list>.soft-toast-item{top:0;bottom:auto}.soft-toast-stack[data-direction=up][data-v-ee86226d] .soft-toast-list>.soft-toast-item{top:auto;bottom:0}:root{--st-bg-default: #ffffff;--st-bg-success: #dcfce7;--st-bg-error: #fee2e2;--st-bg-warning: #fef3c7;--st-bg-info: #dbeafe;--st-text-default: #1f2937;--st-text-success: #166534;--st-text-error: #991b1b;--st-text-warning: #92400e;--st-text-info: #1e40af;--st-border-default: #e5e7eb;--st-border-success: #86efac;--st-border-error: #fca5a5;--st-border-warning: #fcd34d;--st-border-info: #93c5fd;--st-icon-success: #22c55e;--st-icon-error: #ef4444;--st-icon-warning: #f59e0b;--st-icon-info: #3b82f6;--st-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);--st-shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--st-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--st-shadow-glow: 0 0 20px rgb(0 0 0 / .05);--st-toast-min-width: 320px;--st-toast-max-width: 420px;--st-toast-padding: 16px;--st-toast-gap: 12px;--st-border-radius: 9999px;--st-border-radius-blob: 24px;--st-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--st-font-size-sm: 12px;--st-font-size-base: 14px;--st-font-size-lg: 16px;--st-font-weight-normal: 400;--st-font-weight-medium: 500;--st-font-weight-semibold: 600;--st-transition-fast: .15s;--st-transition-base: .3s;--st-transition-slow: .5s;--st-z-index: 9999}[data-soft-toast-theme=dark]{--st-bg-default: #1f2937;--st-bg-success: #14532d;--st-bg-error: #7f1d1d;--st-bg-warning: #713f12;--st-bg-info: #1e3a8a;--st-text-default: #f9fafb;--st-text-success: #86efac;--st-text-error: #fca5a5;--st-text-warning: #fcd34d;--st-text-info: #93c5fd;--st-border-default: #374151;--st-border-success: #166534;--st-border-error: #991b1b;--st-border-warning: #92400e;--st-border-info: #1e40af;--st-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .3);--st-shadow-md: 0 4px 6px -1px rgb(0 0 0 / .4), 0 2px 4px -2px rgb(0 0 0 / .3);--st-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .4), 0 4px 6px -4px rgb(0 0 0 / .3);--st-shadow-glow: 0 0 30px rgb(0 0 0 / .3)}.soft-toast-container{position:fixed;z-index:var(--st-z-index);pointer-events:none;display:flex;flex-direction:column;gap:10px;width:min(var(--st-width, 356px),calc(100vw - 64px));max-width:calc(100vw - 64px)}.soft-toast-container[data-position=top-left]{top:32px;left:32px}.soft-toast-container[data-position=top-center]{top:32px;left:50%;transform:translate(-50%)}.soft-toast-container[data-position=top-right]{top:32px;right:32px}.soft-toast-container[data-position=bottom-left]{bottom:32px;left:32px}.soft-toast-container[data-position=bottom-center]{bottom:32px;left:50%;transform:translate(-50%)}.soft-toast-container[data-position=bottom-right]{bottom:32px;right:32px}.soft-toast-container[data-position=top]{top:32px;left:50%;transform:translate(-50%)}.soft-toast-container[data-position=bottom]{bottom:32px;left:50%;transform:translate(-50%)}.soft-toast-container[data-position=left]{top:50%;left:32px;transform:translateY(-50%)}.soft-toast-container[data-position=right]{top:50%;right:32px;transform:translateY(-50%)}.soft-toast-item{pointer-events:auto;position:relative;box-sizing:border-box;width:100%;min-width:260px;max-width:360px;padding:12px 16px;border-radius:18px;font-family:var(--st-font-family);font-size:13.5px;line-height:1.45;cursor:default;-webkit-user-select:none;user-select:none;touch-action:pan-y;background:#fffffffa;border:1px solid rgba(226,232,240,.8);box-shadow:0 10px 30px -5px #00000014,inset 0 1px #fff}.soft-toast-item[data-interactive=false]{pointer-events:none;touch-action:none}.soft-toast-item--swipeable{cursor:grab}.soft-toast-item--swipeable:active{cursor:grabbing}.soft-toast-container[data-position=top-left] .soft-toast-item,.soft-toast-container[data-position=left] .soft-toast-item{border-top-left-radius:4px}.soft-toast-container[data-position=bottom-left] .soft-toast-item{border-bottom-left-radius:4px}.soft-toast-container[data-position=top-right] .soft-toast-item,.soft-toast-container[data-position=right] .soft-toast-item{border-top-right-radius:4px}.soft-toast-container[data-position=bottom-right] .soft-toast-item{border-bottom-right-radius:4px}.soft-toast-item[data-type=default]{--st-accent: #9ca3af;--st-icon-color: #64748b}.soft-toast-item[data-type=success]{--st-accent: #34d399;--st-icon-color: #059669}.soft-toast-item[data-type=error]{--st-accent: #fb7185;--st-icon-color: #e11d48}.soft-toast-item[data-type=warning]{--st-accent: #fbbf24;--st-icon-color: #d97706}.soft-toast-item[data-type=info]{--st-accent: #60a5fa;--st-icon-color: #3b82f6}.soft-toast-item[data-type=promise]{--st-accent: #a78bfa;--st-icon-color: #7c3aed}.soft-toast-content{position:relative;z-index:1;display:flex;align-items:flex-start;gap:11px}.soft-toast-icon{flex-shrink:0;width:24px;height:24px;margin-top:0;display:flex;align-items:center;justify-content:center;color:var(--st-icon-color, #64748b)}.soft-toast-icon svg,.soft-toast-icon .iconify,.soft-toast-icon-svg{display:block;flex:none;width:18px!important;height:18px!important;max-width:18px;max-height:18px;filter:drop-shadow(0 1px 2px rgba(0,0,0,.12))}.soft-toast-item[data-type=promise] .soft-toast-icon-svg{animation:st-spin .8s linear infinite}.soft-toast-spinner{width:18px;height:18px;border:2px solid rgba(139,92,246,.2);border-top-color:#8b5cf6;border-radius:50%;animation:st-spin .7s linear infinite}@keyframes st-spin{to{transform:rotate(360deg)}}.soft-toast-body{flex:1;min-width:0}.soft-toast-header-row{display:flex;align-items:center;gap:12px;min-height:24px}.soft-toast-title{font-weight:600;font-size:14px;color:#111827;margin:0;line-height:1.3;letter-spacing:0;padding-right:4px}.soft-toast-title--has-close{padding-right:24px}.soft-toast-description{font-size:13.5px;font-weight:400;color:#4b5563;margin:4px 0 0;line-height:1.5;max-height:120px;overflow-y:auto;padding-right:4px}.soft-toast-description::-webkit-scrollbar{width:4px}.soft-toast-description::-webkit-scrollbar-track{background:transparent}.soft-toast-description::-webkit-scrollbar-thumb{background:#0000001a;border-radius:4px}.soft-toast-description::-webkit-scrollbar-thumb:hover{background:#0003}.soft-toast-timestamp{display:inline-block;font-size:11px;color:#9ca3af;letter-spacing:.01em;white-space:nowrap;margin-top:6px}.soft-toast-action{display:flex;gap:8px;margin-top:12px}.soft-toast-action-button{flex:1;width:100%;padding:8px 16px;border-radius:12px;background:#64748b1f;background:color-mix(in srgb,var(--st-accent) 15%,transparent);color:var(--st-icon-color);border:none;font-size:13.5px;font-weight:600;cursor:pointer;font-family:inherit;transition:all .18s ease;letter-spacing:.01em;text-align:center}.soft-toast-action-button:hover{background:#64748b38;background:color-mix(in srgb,var(--st-accent) 25%,transparent);transform:scale(1.02)}.soft-toast-action-button:active{transform:scale(.98)}.soft-toast-action-primary{background:var(--st-icon-color);color:#fff}.soft-toast-action-primary:hover{background:color-mix(in srgb,var(--st-icon-color) 85%,#000)}.soft-toast-close{position:absolute;z-index:3;top:10px;right:10px;width:22px;height:22px;border-radius:50%;border:none;background:#0000000a;color:#9ca3af;cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .18s ease,background .18s ease,color .18s ease,transform .18s ease;padding:0}.soft-toast-close:hover{background:#0000001a;color:#374151;transform:scale(1.1)}.soft-toast-item:hover .soft-toast-close{opacity:1}@media (hover: none){.soft-toast-close{opacity:.7}}.soft-toast-close[data-position=top-left]{right:auto;left:10px}.st-close-line-1,.st-close-line-2{transition:transform .3s cubic-bezier(.4,0,.2,1),opacity .3s ease;transform-origin:center}.soft-toast-close:hover .st-close-line-1{transform:rotate(-45deg)}.soft-toast-close:hover .st-close-line-2{transform:rotate(45deg) scaleX(0);opacity:0}.soft-toast-progress{position:absolute;top:0;left:0;right:0;bottom:0;height:100%;background:transparent;z-index:0;pointer-events:none;border-radius:inherit;overflow:hidden}.soft-toast-progress-bar{height:100%;background:var(--st-accent);opacity:.12;transform-origin:left}[data-soft-toast-theme=dark] .soft-toast-item{background:#1c1c1e;border-color:#ffffff14;box-shadow:0 4px 24px -4px #00000080,0 1px 4px #0000004d}[data-soft-toast-theme=dark] .soft-toast-title{color:#f9fafb}[data-soft-toast-theme=dark] .soft-toast-description{color:#9ca3af}[data-soft-toast-theme=dark] .soft-toast-timestamp{color:#6b7280}[data-soft-toast-theme=dark] .soft-toast-item[data-type]{background:#1c1c1e;border-color:#ffffff14}[data-soft-toast-dir=rtl] .soft-toast-item:before{left:auto;right:0;border-radius:4px 0 0 4px}[data-soft-toast-dir=rtl] .soft-toast-content{flex-direction:row-reverse;padding-left:0;padding-right:10px}[data-soft-toast-dir=rtl] .soft-toast-body{align-items:flex-end;text-align:right}[data-soft-toast-dir=rtl] .soft-toast-close{right:auto;left:10px}@media (max-width: 640px){.soft-toast-container{left:12px!important;right:12px!important;width:auto;max-width:none;transform:none!important;align-items:stretch!important}.soft-toast-container[data-position^=top]{top:12px}.soft-toast-container[data-position^=bottom]{bottom:12px}.soft-toast-item{min-width:auto;max-width:none}.soft-toast-close{opacity:1}}@media (hover: none){.soft-toast-container:not([data-expanded=true]) .soft-toast-item[data-interactive=false]{pointer-events:none;touch-action:none}.soft-toast-container:not([data-expanded=true]) .soft-toast-item[data-st-index="0"]{touch-action:manipulation}.soft-toast-container[data-expanded=true] .soft-toast-item[data-interactive=true]{touch-action:pan-y}}@media (prefers-reduced-motion: reduce){.soft-toast-item,.soft-toast-action-button,.soft-toast-close,.soft-toast-spinner{transition:none!important;animation:none!important}}
|
|
1
|
+
.soft-toast-stack[data-v-ad802395]{position:relative;pointer-events:auto;padding-top:32px;padding-bottom:32px;margin-top:-32px;margin-bottom:-32px;width:100%;max-width:100%;display:flex;flex-direction:column;touch-action:manipulation}.soft-toast-container[data-expanded=true] .soft-toast-stack[data-v-ad802395]{touch-action:none}.soft-toast-list[data-v-ad802395]{position:relative;width:100%;flex-shrink:0}.soft-toast-stack[data-direction=up] .soft-toast-list[data-v-ad802395]{margin-top:auto}.soft-toast-stack[data-direction=down] .soft-toast-list[data-v-ad802395]{margin-bottom:auto}.soft-toast-list[data-v-ad802395]>.soft-toast-item{position:absolute;width:100%}.soft-toast-container[data-position$=left] .soft-toast-list[data-v-ad802395]>.soft-toast-item{left:0;right:auto}.soft-toast-container[data-position$=right] .soft-toast-list[data-v-ad802395]>.soft-toast-item{right:0;left:auto}.soft-toast-stack[data-direction=down][data-v-ad802395] .soft-toast-list>.soft-toast-item{top:0;bottom:auto}.soft-toast-stack[data-direction=up][data-v-ad802395] .soft-toast-list>.soft-toast-item{top:auto;bottom:0}:root{--st-bg-default: #ffffff;--st-bg-success: #dcfce7;--st-bg-error: #fee2e2;--st-bg-warning: #fef3c7;--st-bg-info: #dbeafe;--st-text-default: #1f2937;--st-text-success: #166534;--st-text-error: #991b1b;--st-text-warning: #92400e;--st-text-info: #1e40af;--st-border-default: #e5e7eb;--st-border-success: #86efac;--st-border-error: #fca5a5;--st-border-warning: #fcd34d;--st-border-info: #93c5fd;--st-icon-success: #22c55e;--st-icon-error: #ef4444;--st-icon-warning: #f59e0b;--st-icon-info: #3b82f6;--st-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .05);--st-shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--st-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--st-shadow-glow: 0 0 20px rgb(0 0 0 / .05);--st-toast-min-width: 320px;--st-toast-max-width: 420px;--st-toast-padding: 16px;--st-toast-gap: 12px;--st-border-radius: 9999px;--st-border-radius-blob: 24px;--st-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--st-font-size-sm: 12px;--st-font-size-base: 14px;--st-font-size-lg: 16px;--st-font-weight-normal: 400;--st-font-weight-medium: 500;--st-font-weight-semibold: 600;--st-transition-fast: .15s;--st-transition-base: .3s;--st-transition-slow: .5s;--st-z-index: 9999}[data-soft-toast-theme=dark]{--st-bg-default: #1f2937;--st-bg-success: #14532d;--st-bg-error: #7f1d1d;--st-bg-warning: #713f12;--st-bg-info: #1e3a8a;--st-text-default: #f9fafb;--st-text-success: #86efac;--st-text-error: #fca5a5;--st-text-warning: #fcd34d;--st-text-info: #93c5fd;--st-border-default: #374151;--st-border-success: #166534;--st-border-error: #991b1b;--st-border-warning: #92400e;--st-border-info: #1e40af;--st-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / .3);--st-shadow-md: 0 4px 6px -1px rgb(0 0 0 / .4), 0 2px 4px -2px rgb(0 0 0 / .3);--st-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .4), 0 4px 6px -4px rgb(0 0 0 / .3);--st-shadow-glow: 0 0 30px rgb(0 0 0 / .3)}.soft-toast-container{position:fixed;z-index:var(--st-z-index);pointer-events:none;display:flex;flex-direction:column;gap:10px;width:min(var(--st-width, 356px),calc(100vw - 64px));max-width:calc(100vw - 64px)}.soft-toast-container[data-position=top-left]{top:32px;left:32px}.soft-toast-container[data-position=top-center]{top:32px;left:50%;transform:translate(-50%)}.soft-toast-container[data-position=top-right]{top:32px;right:32px}.soft-toast-container[data-position=bottom-left]{bottom:32px;left:32px}.soft-toast-container[data-position=bottom-center]{bottom:32px;left:50%;transform:translate(-50%)}.soft-toast-container[data-position=bottom-right]{bottom:32px;right:32px}.soft-toast-container[data-position=top]{top:32px;left:50%;transform:translate(-50%)}.soft-toast-container[data-position=bottom]{bottom:32px;left:50%;transform:translate(-50%)}.soft-toast-container[data-position=left]{top:50%;left:32px;transform:translateY(-50%)}.soft-toast-container[data-position=right]{top:50%;right:32px;transform:translateY(-50%)}.soft-toast-item{pointer-events:auto;position:relative;box-sizing:border-box;width:100%;min-width:260px;max-width:360px;padding:12px 16px;border-radius:18px;font-family:var(--st-font-family);font-size:13.5px;line-height:1.45;cursor:default;-webkit-user-select:none;user-select:none;touch-action:pan-y;background:#fffffffa;border:1px solid rgba(226,232,240,.8);box-shadow:0 10px 30px -5px #00000014,inset 0 1px #fff}.soft-toast-item[data-interactive=false],.soft-toast-item[data-leaving=true]{pointer-events:none;touch-action:none}.soft-toast-item--swipeable{cursor:grab;touch-action:none}.soft-toast-item--swipeable:active{cursor:grabbing}.soft-toast-container[data-position=top-left] .soft-toast-item,.soft-toast-container[data-position=left] .soft-toast-item{border-top-left-radius:4px}.soft-toast-container[data-position=bottom-left] .soft-toast-item{border-bottom-left-radius:4px}.soft-toast-container[data-position=top-right] .soft-toast-item,.soft-toast-container[data-position=right] .soft-toast-item{border-top-right-radius:4px}.soft-toast-container[data-position=bottom-right] .soft-toast-item{border-bottom-right-radius:4px}.soft-toast-item[data-type=default]{--st-accent: #9ca3af;--st-icon-color: #64748b}.soft-toast-item[data-type=success]{--st-accent: #34d399;--st-icon-color: #059669}.soft-toast-item[data-type=error]{--st-accent: #fb7185;--st-icon-color: #e11d48}.soft-toast-item[data-type=warning]{--st-accent: #fbbf24;--st-icon-color: #d97706}.soft-toast-item[data-type=info]{--st-accent: #60a5fa;--st-icon-color: #3b82f6}.soft-toast-item[data-type=promise]{--st-accent: #a78bfa;--st-icon-color: #7c3aed}.soft-toast-content{position:relative;z-index:1;display:flex;align-items:flex-start;gap:11px}.soft-toast-icon{flex-shrink:0;width:24px;height:24px;margin-top:0;display:flex;align-items:center;justify-content:center;color:var(--st-icon-color, #64748b)}.soft-toast-icon svg,.soft-toast-icon .iconify,.soft-toast-icon-svg{display:block;flex:none;width:18px!important;height:18px!important;max-width:18px;max-height:18px;filter:drop-shadow(0 1px 2px rgba(0,0,0,.12))}.soft-toast-item[data-type=promise] .soft-toast-icon-svg{animation:st-spin .8s linear infinite}.soft-toast-spinner{width:18px;height:18px;border:2px solid rgba(139,92,246,.2);border-top-color:#8b5cf6;border-radius:50%;animation:st-spin .7s linear infinite}@keyframes st-spin{to{transform:rotate(360deg)}}.soft-toast-body{flex:1;min-width:0}.soft-toast-header-row{display:flex;align-items:center;gap:12px;min-height:24px}.soft-toast-title{font-weight:600;font-size:14px;color:#111827;margin:0;line-height:1.3;letter-spacing:0;padding-right:4px}.soft-toast-title--has-close{padding-right:24px}.soft-toast-description{font-size:13.5px;font-weight:400;color:#4b5563;margin:4px 0 0;line-height:1.5;max-height:120px;overflow-y:auto;padding-right:4px;scrollbar-width:none}.soft-toast-description::-webkit-scrollbar{width:0}.soft-toast-item:hover .soft-toast-description{scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.15) transparent}.soft-toast-item:hover .soft-toast-description::-webkit-scrollbar{width:4px}.soft-toast-item:hover .soft-toast-description::-webkit-scrollbar-track{background:transparent}.soft-toast-item:hover .soft-toast-description::-webkit-scrollbar-thumb{background:#00000026;border-radius:4px}.soft-toast-item:hover .soft-toast-description::-webkit-scrollbar-thumb:hover{background:#00000040}.soft-toast-timestamp{display:inline-block;font-size:11px;color:#9ca3af;letter-spacing:.01em;white-space:nowrap;margin-top:6px}.soft-toast-action{display:flex;gap:8px;margin-top:12px}.soft-toast-action-button{flex:1;width:100%;padding:8px 16px;border-radius:12px;background:#64748b1f;background:color-mix(in srgb,var(--st-accent) 15%,transparent);color:var(--st-icon-color);border:none;font-size:13.5px;font-weight:600;cursor:pointer;font-family:inherit;transition:all .18s ease;letter-spacing:.01em;text-align:center}.soft-toast-action-button:hover{background:#64748b38;background:color-mix(in srgb,var(--st-accent) 25%,transparent);transform:scale(1.02)}.soft-toast-action-button:active{transform:scale(.98)}.soft-toast-action-primary{background:var(--st-icon-color);color:#fff}.soft-toast-action-primary:hover{background:color-mix(in srgb,var(--st-icon-color) 85%,#000)}.soft-toast-close{position:absolute;z-index:3;top:10px;right:10px;width:22px;height:22px;border-radius:50%;border:none;background:#0000000a;color:#9ca3af;cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .18s ease,background .18s ease,color .18s ease,transform .18s ease;padding:0}.soft-toast-close:hover{background:#0000001a;color:#374151;transform:scale(1.1)}.soft-toast-item:hover .soft-toast-close{opacity:1}@media (hover: none){.soft-toast-close{opacity:.7}}.soft-toast-close[data-position=top-left]{right:auto;left:10px}.st-close-line-1,.st-close-line-2{transition:transform .3s cubic-bezier(.4,0,.2,1),opacity .3s ease;transform-origin:center}.soft-toast-close:hover .st-close-line-1{transform:rotate(-45deg)}.soft-toast-close:hover .st-close-line-2{transform:rotate(45deg) scaleX(0);opacity:0}.soft-toast-progress{position:absolute;top:0;left:0;right:0;bottom:0;height:100%;background:transparent;z-index:0;pointer-events:none;border-radius:inherit;overflow:hidden}.soft-toast-progress-bar{height:100%;background:var(--st-accent);opacity:.12;transform-origin:left}[data-soft-toast-theme=dark] .soft-toast-item{background:#1c1c1e;border-color:#ffffff14;box-shadow:0 4px 24px -4px #00000080,0 1px 4px #0000004d}[data-soft-toast-theme=dark] .soft-toast-title{color:#f9fafb}[data-soft-toast-theme=dark] .soft-toast-description{color:#9ca3af}[data-soft-toast-theme=dark] .soft-toast-timestamp{color:#6b7280}[data-soft-toast-theme=dark] .soft-toast-item[data-type]{background:#1c1c1e;border-color:#ffffff14}[data-soft-toast-dir=rtl] .soft-toast-item:before{left:auto;right:0;border-radius:4px 0 0 4px}[data-soft-toast-dir=rtl] .soft-toast-content{flex-direction:row-reverse;padding-left:0;padding-right:10px}[data-soft-toast-dir=rtl] .soft-toast-body{align-items:flex-end;text-align:right}[data-soft-toast-dir=rtl] .soft-toast-close{right:auto;left:10px}@media (max-width: 640px){.soft-toast-container{left:12px!important;right:12px!important;width:auto;max-width:none;transform:none!important;align-items:stretch!important}.soft-toast-container[data-position^=top]{top:12px}.soft-toast-container[data-position^=bottom]{bottom:12px}.soft-toast-item{min-width:auto;max-width:none}.soft-toast-close{opacity:1}}@media (hover: none){.soft-toast-container:not([data-expanded=true]) .soft-toast-item[data-interactive=false]{pointer-events:none;touch-action:none}.soft-toast-container:not([data-expanded=true]) .soft-toast-item[data-st-index="0"]{touch-action:manipulation}.soft-toast-container[data-expanded=true] .soft-toast-item[data-interactive=true]{touch-action:none}}@media (prefers-reduced-motion: reduce){.soft-toast-item,.soft-toast-action-button,.soft-toast-close,.soft-toast-spinner{transition:none!important;animation:none!important}}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,13 +10,13 @@ export interface ToastAction {
|
|
|
10
10
|
primary?: boolean;
|
|
11
11
|
class?: string;
|
|
12
12
|
}
|
|
13
|
-
export interface ToastPromiseMessages {
|
|
13
|
+
export interface ToastPromiseMessages<T = unknown> {
|
|
14
14
|
loading: string;
|
|
15
|
-
success: string;
|
|
16
|
-
error: string;
|
|
15
|
+
success: string | ((data: T) => string);
|
|
16
|
+
error: string | ((err: unknown) => string);
|
|
17
17
|
description?: {
|
|
18
|
-
success?: string;
|
|
19
|
-
error?: string;
|
|
18
|
+
success?: string | ((data: T) => string);
|
|
19
|
+
error?: string | ((err: unknown) => string);
|
|
20
20
|
};
|
|
21
21
|
action?: {
|
|
22
22
|
error?: ToastAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAE3C,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AACxF,MAAM,MAAM,aAAa,G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a,CAAA;IAC7B,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAA;CACvC;AAED,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soft-toast/vue",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Soft, fluid toast notifications for Vue 3 — part of the @soft-toast family",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -48,11 +48,24 @@
|
|
|
48
48
|
"keywords": [
|
|
49
49
|
"vue",
|
|
50
50
|
"vue3",
|
|
51
|
+
"nuxt",
|
|
52
|
+
"nuxt3",
|
|
53
|
+
"nuxt4",
|
|
51
54
|
"toast",
|
|
52
55
|
"notification",
|
|
56
|
+
"snackbar",
|
|
57
|
+
"alert",
|
|
58
|
+
"composable",
|
|
59
|
+
"useSoftToast",
|
|
60
|
+
"promise-toast",
|
|
61
|
+
"swipe-to-dismiss",
|
|
62
|
+
"spring-animation",
|
|
63
|
+
"dark-mode",
|
|
53
64
|
"animation",
|
|
54
65
|
"soft",
|
|
55
|
-
"fluid"
|
|
66
|
+
"fluid",
|
|
67
|
+
"vue-toastification-alternative",
|
|
68
|
+
"vue-sonner-alternative"
|
|
56
69
|
],
|
|
57
70
|
"author": "",
|
|
58
71
|
"license": "MIT",
|
|
@@ -152,18 +152,28 @@ export const morphAnimation = (
|
|
|
152
152
|
return tl
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
// Exit: Soft scale down + fade
|
|
155
|
+
// Exit: Soft scale down + fade, then collapse height so the gap closes cleanly
|
|
156
156
|
export const exitAnimation = (
|
|
157
157
|
element: HTMLElement
|
|
158
158
|
) => {
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
const tl = gsap.timeline()
|
|
160
|
+
tl.to(element, {
|
|
161
|
+
scale: 0.85,
|
|
161
162
|
opacity: 0,
|
|
162
163
|
force3D: true,
|
|
163
164
|
overwrite: 'auto',
|
|
164
|
-
duration: 0.
|
|
165
|
-
ease: 'power2.out'
|
|
165
|
+
duration: 0.2,
|
|
166
|
+
ease: 'power2.out',
|
|
166
167
|
})
|
|
168
|
+
tl.to(element, {
|
|
169
|
+
height: 0,
|
|
170
|
+
paddingTop: 0,
|
|
171
|
+
paddingBottom: 0,
|
|
172
|
+
marginBottom: 0,
|
|
173
|
+
duration: 0.14,
|
|
174
|
+
ease: 'power2.in',
|
|
175
|
+
}, '-=0.05')
|
|
176
|
+
return tl
|
|
167
177
|
}
|
|
168
178
|
|
|
169
179
|
// Swipe exit: fly off horizontally in the direction of the gesture
|
|
@@ -185,6 +195,7 @@ export const swipeExitAnimation = (
|
|
|
185
195
|
export const swipeSnapBack = (element: HTMLElement) => {
|
|
186
196
|
return gsap.to(element, {
|
|
187
197
|
x: 0,
|
|
198
|
+
rotate: 0,
|
|
188
199
|
opacity: 1,
|
|
189
200
|
force3D: true,
|
|
190
201
|
overwrite: 'auto',
|
|
@@ -217,6 +228,7 @@ export const positionAnimation = (
|
|
|
217
228
|
opacityStep?: number
|
|
218
229
|
maxVisible?: number
|
|
219
230
|
reposition?: boolean
|
|
231
|
+
resetSwipe?: boolean
|
|
220
232
|
}
|
|
221
233
|
) => {
|
|
222
234
|
const {
|
|
@@ -231,7 +243,8 @@ export const positionAnimation = (
|
|
|
231
243
|
scaleStep = 0.055,
|
|
232
244
|
opacityStep = 0.2,
|
|
233
245
|
maxVisible = 3,
|
|
234
|
-
reposition = false
|
|
246
|
+
reposition = false,
|
|
247
|
+
resetSwipe = false
|
|
235
248
|
} = options
|
|
236
249
|
|
|
237
250
|
const config = presetConfigs[preset] || presetConfigs.smooth
|
|
@@ -240,21 +253,23 @@ export const positionAnimation = (
|
|
|
240
253
|
if (expanded) {
|
|
241
254
|
// Expanded hover and dismiss restacking share one soft settle timing.
|
|
242
255
|
const expandedTarget = {
|
|
256
|
+
x: resetSwipe ? 0 : undefined,
|
|
243
257
|
y: expandedOffset * sign,
|
|
244
258
|
scale: 1,
|
|
245
|
-
opacity: 1
|
|
259
|
+
opacity: 1,
|
|
260
|
+
rotate: resetSwipe ? 0 : undefined
|
|
246
261
|
}
|
|
247
262
|
|
|
248
|
-
if (reposition && spring) {
|
|
263
|
+
if (reposition && spring && !resetSwipe) {
|
|
249
264
|
return cloudSettleAnimation(element, expandedTarget)
|
|
250
265
|
}
|
|
251
266
|
|
|
252
267
|
return gsap.to(element, {
|
|
253
268
|
...expandedTarget,
|
|
254
269
|
force3D: true,
|
|
255
|
-
overwrite:
|
|
256
|
-
duration: DUR(0.12),
|
|
257
|
-
ease: 'power2.out'
|
|
270
|
+
overwrite: true,
|
|
271
|
+
duration: DUR(resetSwipe ? 0.34 : 0.12),
|
|
272
|
+
ease: resetSwipe ? 'elastic.out(1, 0.55)' : 'power2.out'
|
|
258
273
|
})
|
|
259
274
|
}
|
|
260
275
|
|
|
@@ -265,6 +280,20 @@ export const positionAnimation = (
|
|
|
265
280
|
const targetOpacity = isHidden ? 0 : Math.max(0, 1 - clampedIdx * opacityStep)
|
|
266
281
|
|
|
267
282
|
if (reposition && spring) {
|
|
283
|
+
if (resetSwipe) {
|
|
284
|
+
return gsap.to(element, {
|
|
285
|
+
x: 0,
|
|
286
|
+
y: targetY,
|
|
287
|
+
scale: targetScale,
|
|
288
|
+
opacity: targetOpacity,
|
|
289
|
+
rotate: 0,
|
|
290
|
+
force3D: true,
|
|
291
|
+
overwrite: true,
|
|
292
|
+
duration: DUR(0.38),
|
|
293
|
+
ease: 'elastic.out(1, 0.55)'
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
|
|
268
297
|
return cloudSettleAnimation(element, {
|
|
269
298
|
y: targetY,
|
|
270
299
|
scale: targetScale,
|
|
@@ -276,13 +305,15 @@ export const positionAnimation = (
|
|
|
276
305
|
// paths above stay softer so hover and dismiss do not feel mismatched.
|
|
277
306
|
const restackEase = spring ? createElasticEase(bounce) : config.ease
|
|
278
307
|
return gsap.to(element, {
|
|
308
|
+
x: resetSwipe ? 0 : undefined,
|
|
279
309
|
y: targetY,
|
|
280
310
|
scale: targetScale,
|
|
281
311
|
opacity: targetOpacity,
|
|
312
|
+
rotate: resetSwipe ? 0 : undefined,
|
|
282
313
|
force3D: true,
|
|
283
|
-
overwrite: 'auto',
|
|
284
|
-
duration: DUR(config.duration * 0.85),
|
|
285
|
-
ease: restackEase
|
|
314
|
+
overwrite: resetSwipe ? true : 'auto',
|
|
315
|
+
duration: DUR(resetSwipe ? 0.38 : config.duration * 0.85),
|
|
316
|
+
ease: resetSwipe ? 'elastic.out(1, 0.55)' : restackEase
|
|
286
317
|
})
|
|
287
318
|
}
|
|
288
319
|
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
positionAnimation,
|
|
13
13
|
killAnimations,
|
|
14
14
|
swipeExitAnimation,
|
|
15
|
-
swipeSnapBack,
|
|
16
15
|
} from "../animations/gsapConfig";
|
|
17
16
|
import { gsap } from "gsap";
|
|
18
17
|
|
|
@@ -99,7 +98,11 @@ const normalizedActions = computed(() => {
|
|
|
99
98
|
|
|
100
99
|
// ─── Stack position via GSAP ─────────────────────────────────────────────────
|
|
101
100
|
|
|
102
|
-
const applyStackPosition = (
|
|
101
|
+
const applyStackPosition = (
|
|
102
|
+
reposition = false,
|
|
103
|
+
overrideOffset?: number,
|
|
104
|
+
resetSwipe = false,
|
|
105
|
+
) => {
|
|
103
106
|
if (!toastRef.value || props.toast.isLeaving || isSwiping) return;
|
|
104
107
|
positionAnimation(toastRef.value, {
|
|
105
108
|
index: props.index,
|
|
@@ -110,6 +113,7 @@ const applyStackPosition = (reposition = false, overrideOffset?: number) => {
|
|
|
110
113
|
direction: props.stackDirection,
|
|
111
114
|
expandedOffset: overrideOffset ?? props.expandedOffset,
|
|
112
115
|
reposition,
|
|
116
|
+
resetSwipe,
|
|
113
117
|
});
|
|
114
118
|
};
|
|
115
119
|
|
|
@@ -167,9 +171,8 @@ const resetSwipeTracking = () => {
|
|
|
167
171
|
|
|
168
172
|
const snapBackSwipe = () => {
|
|
169
173
|
if (!toastRef.value) return;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
toastStore.resume(props.toast.id);
|
|
174
|
+
if (!props.expanded) toastStore.resume(props.toast.id);
|
|
175
|
+
applyStackPosition(true, undefined, true);
|
|
173
176
|
};
|
|
174
177
|
|
|
175
178
|
const completeSwipe = () => {
|
|
@@ -203,7 +206,28 @@ const completeSwipe = () => {
|
|
|
203
206
|
};
|
|
204
207
|
|
|
205
208
|
const handlePointerDown = (e: PointerEvent) => {
|
|
206
|
-
|
|
209
|
+
// Guard: isSwiping can be left true if lostpointercapture fired but its
|
|
210
|
+
// 300 ms fallback hasn't resolved yet. If there is no active captured
|
|
211
|
+
// pointer any more, reset the stale state so the next gesture isn't blocked.
|
|
212
|
+
if (isSwiping && activePointerId !== null) {
|
|
213
|
+
try {
|
|
214
|
+
const el = activePointerTarget ?? (e.currentTarget as HTMLElement);
|
|
215
|
+
if (!el.hasPointerCapture(activePointerId)) {
|
|
216
|
+
resetSwipeTracking();
|
|
217
|
+
snapBackSwipe();
|
|
218
|
+
}
|
|
219
|
+
} catch {
|
|
220
|
+
resetSwipeTracking();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (
|
|
224
|
+
!isSwipeToDismissEnabled.value ||
|
|
225
|
+
isDismissing ||
|
|
226
|
+
isSwiping ||
|
|
227
|
+
props.toast.isLeaving
|
|
228
|
+
) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
207
231
|
// Only primary button for mouse; all pointers for touch/stylus
|
|
208
232
|
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
209
233
|
// Ignore if target is a button/link (don't hijack action clicks)
|
|
@@ -289,8 +313,10 @@ const handleLostPointerCapture = (e: PointerEvent) => {
|
|
|
289
313
|
activePointerTarget = null;
|
|
290
314
|
clearLostCaptureFallback();
|
|
291
315
|
lostCaptureFallbackId = window.setTimeout(() => {
|
|
292
|
-
if (isSwiping)
|
|
293
|
-
|
|
316
|
+
if (!isSwiping) return;
|
|
317
|
+
resetSwipeTracking();
|
|
318
|
+
snapBackSwipe();
|
|
319
|
+
}, 150);
|
|
294
320
|
};
|
|
295
321
|
|
|
296
322
|
const handleVisibilityChange = () => {
|
|
@@ -350,14 +376,19 @@ watch(
|
|
|
350
376
|
() => props.expanded,
|
|
351
377
|
(expanded) => {
|
|
352
378
|
if (expanded) toastStore.pause(props.toast.id);
|
|
353
|
-
else
|
|
379
|
+
else if (!isSwiping && !props.toast.isLeaving) {
|
|
380
|
+
toastStore.resume(props.toast.id);
|
|
381
|
+
}
|
|
354
382
|
},
|
|
355
383
|
);
|
|
356
384
|
|
|
357
385
|
watch(
|
|
358
386
|
() => props.toast.isLeaving,
|
|
359
387
|
(leaving) => {
|
|
360
|
-
if (leaving)
|
|
388
|
+
if (leaving) {
|
|
389
|
+
if (isSwiping) resetSwipeTracking();
|
|
390
|
+
dismiss();
|
|
391
|
+
}
|
|
361
392
|
},
|
|
362
393
|
);
|
|
363
394
|
|
|
@@ -541,7 +541,9 @@ const isSwipeToDismissEnabled = computed(() => props.swipeToDismiss !== false);
|
|
|
541
541
|
:expanded="isExpanded"
|
|
542
542
|
:expanded-offset="expandedOffsets[toast.id] ?? 0"
|
|
543
543
|
:stack-direction="stackDirection"
|
|
544
|
-
:interactive="
|
|
544
|
+
:interactive="
|
|
545
|
+
!toast.isLeaving && (isExpanded || getVisualIndex(toast, idx) === 0)
|
|
546
|
+
"
|
|
545
547
|
:close-button="toast.closeButton ?? closeButton"
|
|
546
548
|
:swipe-to-dismiss="isSwipeToDismissEnabled"
|
|
547
549
|
:style="
|
|
@@ -564,7 +566,9 @@ const isSwipeToDismissEnabled = computed(() => props.swipeToDismiss !== false);
|
|
|
564
566
|
:expanded="isExpanded"
|
|
565
567
|
:expanded-offset="expandedOffsets[toast.id] ?? 0"
|
|
566
568
|
:stack-direction="stackDirection"
|
|
567
|
-
:interactive="
|
|
569
|
+
:interactive="
|
|
570
|
+
!toast.isLeaving && (isExpanded || getVisualIndex(toast, idx) === 0)
|
|
571
|
+
"
|
|
568
572
|
:close-button="toast.closeButton ?? closeButton"
|
|
569
573
|
:swipe-to-dismiss="isSwipeToDismissEnabled"
|
|
570
574
|
:style="
|