@samline/notify 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/notify.d.mts +5 -1
- package/dist/notify.d.mts.map +1 -1
- package/dist/notify.d.ts +5 -1
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +117 -1
- package/dist/notify.mjs +117 -2
- package/dist/{react-notify-12s-BjWbwTu8.mjs → react-notify-12s--2JK5UjB.mjs} +180 -2
- package/dist/{react-notify-12s-7LOZlSBi.js → react-notify-12s-Kv2M6zlv.js} +180 -1
- package/dist/react.d.mts +5 -1
- package/dist/react.d.mts.map +1 -1
- package/dist/react.d.ts +5 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +2 -1
- package/dist/react.mjs +1 -1
- package/dist/render-notify-toasts.js +213 -0
- package/dist/styles.css +81 -0
- package/dist/svelte.d.mts +5 -1
- package/dist/svelte.d.mts.map +1 -1
- package/dist/svelte.d.ts +5 -1
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +116 -0
- package/dist/svelte.mjs +116 -1
- package/dist/vue.d.mts +5 -1
- package/dist/vue.d.mts.map +1 -1
- package/dist/vue.d.ts +5 -1
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +119 -3
- package/dist/vue.mjs +119 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,18 +36,21 @@ Include the CSS and UMD bundle via unpkg or jsDelivr:
|
|
|
36
36
|
|
|
37
37
|
```html
|
|
38
38
|
<!-- unpkg -->
|
|
39
|
-
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@1.0.
|
|
40
|
-
<script src="https://unpkg.com/@samline/notify@1.0.
|
|
39
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@1.0.2/dist/styles.css" />
|
|
40
|
+
<script src="https://unpkg.com/@samline/notify@1.0.2/dist/browser-notify.js"></script>
|
|
41
|
+
<script src="https://unpkg.com/@samline/notify@1.0.2/dist/render-notify-toasts.js"></script>
|
|
41
42
|
```
|
|
42
43
|
|
|
43
44
|
```html
|
|
44
45
|
<!-- jsDelivr -->
|
|
45
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@samline/notify@1.0.
|
|
46
|
-
<script src="https://cdn.jsdelivr.net/npm/@samline/notify@1.0.
|
|
46
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@samline/notify@1.0.2/dist/styles.css" />
|
|
47
|
+
<script src="https://cdn.jsdelivr.net/npm/@samline/notify@1.0.2/dist/browser-notify.js"></script>
|
|
48
|
+
<script src="https://cdn.jsdelivr.net/npm/@samline/notify@1.0.2/dist/render-notify-toasts.js"></script>
|
|
47
49
|
```
|
|
48
50
|
|
|
49
51
|
```html
|
|
50
52
|
<script>
|
|
53
|
+
renderNotifyToasts({ position: 'top-right' })
|
|
51
54
|
window.notify.show({
|
|
52
55
|
title: 'Hello from the browser',
|
|
53
56
|
type: 'success',
|
package/dist/notify.d.mts
CHANGED
|
@@ -39,6 +39,10 @@ interface NotifyItem extends NotifyOptions {
|
|
|
39
39
|
declare function showNotifyToast(options: NotifyOptions): string;
|
|
40
40
|
declare function onNotifyToastsChange(fn: (toasts: NotifyItem[]) => void): () => void;
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
declare function renderNotifyToasts(options?: {
|
|
43
|
+
position?: NotifyPosition;
|
|
44
|
+
}): () => boolean;
|
|
45
|
+
|
|
46
|
+
export { onNotifyToastsChange, renderNotifyToasts, showNotifyToast };
|
|
43
47
|
export type { NotifyButton, NotifyOptions, NotifyPosition, NotifyState, NotifyStyles };
|
|
44
48
|
//# sourceMappingURL=notify.d.mts.map
|
package/dist/notify.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify.d.mts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/vanilla-notify.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACPA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,oBAAoB,cAAc,UAAU;;;;","names":[]}
|
|
1
|
+
{"version":3,"file":"notify.d.mts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/vanilla-notify.ts","../src/render-notify-toasts.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACPA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,oBAAoB,cAAc,UAAU;;ACD7D,iBAAiB,kBAAkB;AACnC,eAAe,cAAc;AAC7B;;;;","names":[]}
|
package/dist/notify.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ interface NotifyItem extends NotifyOptions {
|
|
|
39
39
|
declare function showNotifyToast(options: NotifyOptions): string;
|
|
40
40
|
declare function onNotifyToastsChange(fn: (toasts: NotifyItem[]) => void): () => void;
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
declare function renderNotifyToasts(options?: {
|
|
43
|
+
position?: NotifyPosition;
|
|
44
|
+
}): () => boolean;
|
|
45
|
+
|
|
46
|
+
export { onNotifyToastsChange, renderNotifyToasts, showNotifyToast };
|
|
43
47
|
export type { NotifyButton, NotifyOptions, NotifyPosition, NotifyState, NotifyStyles };
|
|
44
48
|
//# sourceMappingURL=notify.d.ts.map
|
package/dist/notify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify.d.ts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/vanilla-notify.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACPA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,oBAAoB,cAAc,UAAU;;;;","names":[]}
|
|
1
|
+
{"version":3,"file":"notify.d.ts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/vanilla-notify.ts","../src/render-notify-toasts.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACPA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,oBAAoB,cAAc,UAAU;;ACD7D,iBAAiB,kBAAkB;AACnC,eAAe,cAAc;AAC7B;;;;","names":[]}
|
package/dist/notify.js
CHANGED
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
|
|
12
12
|
var cc = require('./cc-DGff5sSY.js');
|
|
13
13
|
|
|
14
|
-
__insertCSS(":root{--notify-spring-easing:linear(\n\t\t0,\n\t\t0.002 0.6%,\n\t\t0.007 1.2%,\n\t\t0.015 1.8%,\n\t\t0.026 2.4%,\n\t\t0.041 3.1%,\n\t\t0.06 3.8%,\n\t\t0.108 5.3%,\n\t\t0.157 6.6%,\n\t\t0.214 8%,\n\t\t0.467 13.7%,\n\t\t0.577 16.3%,\n\t\t0.631 17.7%,\n\t\t0.682 19.1%,\n\t\t0.73 20.5%,\n\t\t0.771 21.8%,\n\t\t0.808 23.1%,\n\t\t0.844 24.5%,\n\t\t0.874 25.8%,\n\t\t0.903 27.2%,\n\t\t0.928 28.6%,\n\t\t0.952 30.1%,\n\t\t0.972 31.6%,\n\t\t0.988 33.1%,\n\t\t1.01 35.7%,\n\t\t1.025 38.5%,\n\t\t1.034 41.6%,\n\t\t1.038 45%,\n\t\t1.035 50.1%,\n\t\t1.012 64.2%,\n\t\t1.003 73%,\n\t\t0.999 83.7%,\n\t\t1\n\t);--notify-duration:600ms;--notify-height:40px;--notify-width:350px;--notify-state-success:oklch(0.723 0.219 142.136);--notify-state-loading:oklch(0.556 0 0);--notify-state-error:oklch(0.637 0.237 25.331);--notify-state-warning:oklch(0.795 0.184 86.047);--notify-state-info:oklch(0.685 0.169 237.323);--notify-state-action:oklch(0.623 0.214 259.815)}[data-notify-toast]{position:relative;cursor:pointer;pointer-events:auto;touch-action:none;border:0;background:0 0;padding:0;width:var(--notify-width);height:var(--_h,var(--notify-height));opacity:0;transform:translateZ(0) scale(.95);transform-origin:center;contain:layout style;overflow:visible}[data-notify-toast][data-state=loading]{cursor:default}[data-notify-toast][data-ready=true]{opacity:1;transform:translateZ(0) scale(1);transition:transform calc(var(--notify-duration) * .66) var(--notify-spring-easing),opacity calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-bottom calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-top calc(var(--notify-duration) * .66) var(--notify-spring-easing),height var(--notify-duration) var(--notify-spring-easing)}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){transform:translateY(6px) scale(.95)}[data-notify-toast][data-ready=true][data-exiting=true]{opacity:0;pointer-events:none}[data-notify-viewport][data-position^=top] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(6px) scale(.95)}[data-notify-canvas]{position:absolute;left:0;right:0;pointer-events:none;transform:translateZ(0);contain:layout style;overflow:visible}[data-sileo-canvas][data-edge=top]{bottom:0;transform:scaleY(-1) translateZ(0)}[data-sileo-canvas][data-edge=bottom]{top:0}[data-notify-svg]{overflow:visible}[data-notify-header]{position:absolute;z-index:20;display:flex;align-items:center;padding:.5rem;height:var(--sileo-height);overflow:hidden;left:var(--_px,0);transform:var(--_ht);max-width:var(--_pw)}[data-notify-toast][data-ready=true] [data-notify-header]{transition:transform var(--sileo-duration) var(--sileo-spring-easing),left var(--sileo-duration) var(--sileo-spring-easing),max-width var(--sileo-duration) var(--sileo-spring-easing)}[data-notify-header][data-edge=top]{bottom:0}[data-notify-header][data-edge=bottom]{top:0}[data-notify-header-stack]{position:relative;display:inline-flex;align-items:center;height:100%}[data-notify-header-inner]{display:flex;align-items:center;gap:.5rem;white-space:nowrap;opacity:1;filter:blur(0px);transform:translateZ(0)}[data-notify-header-inner][data-layer=current]{position:relative;z-index:1;animation:sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both}[data-notify-header-inner][data-exiting=true],[data-notify-header-inner][data-layer=current]:not(:only-child){will-change:opacity,filter}[data-notify-header-inner][data-layer=prev]{position:absolute;left:0;top:0;z-index:0;pointer-events:none}[data-notify-header-inner][data-exiting=true]{animation:notify-header-exit calc(var(--notify-duration) * .7) ease forwards}[data-notify-badge]{display:flex;height:24px;width:24px;flex-shrink:0;align-items:center;justify-content:center;padding:2px;box-sizing:border-box;border-radius:9999px;color:var(--sileo-tone,currentColor);background-color:var(--sileo-tone-bg,transparent)}[data-notify-title]{font-size:.825rem;line-height:1rem;font-weight:500;text-transform:capitalize;color:var(--sileo-tone,currentColor)}:is([data-notify-badge],[data-notify-title],[data-notify-button])[data-state]{--_c:var(--notify-state-success)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=loading]{--_c:var(--notify-state-loading)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=error]{--_c:var(--notify-state-error)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=warning]{--_c:var(--notify-state-warning)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=info]{--_c:var(--notify-state-info)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=action]{--_c:var(--notify-state-action)}:is([data-notify-badge],[data-notify-title])[data-state]{--notify-tone:var(--_c);--notify-tone-bg:color-mix(in oklch, var(--_c) 20%, transparent)}[data-notify-content]{position:absolute;left:0;z-index:10;width:100%;pointer-events:none;opacity:var(--_co, 0)}[data-notify-content]:not([data-visible=true]){content-visibility:hidden}[data-notify-toast][data-ready=true] [data-notify-content]{transition:opacity calc(var(--notify-duration) * .08) ease calc(var(--notify-duration) * .04)}[data-notify-content][data-edge=top]{top:0}[data-notify-content][data-edge=bottom]{top:var(--sileo-height)}[data-notify-content][data-visible=true]{pointer-events:auto}[data-notify-toast][data-ready=true] [data-notify-content][data-visible=true]{transition:opacity calc(var(--notify-duration) * .6) ease calc(var(--notify-duration) * .3)}[data-notify-description]{width:100%;text-align:left;padding:1rem;font-size:.875rem;line-height:1.25rem;contain:layout style paint;content-visibility:auto}[data-notify-button]{display:flex;align-items:center;justify-content:center;height:1.75rem;padding:0 .625rem;margin-top:.75rem;border-radius:9999px;border:0;font-size:.75rem;font-weight:500;cursor:pointer;color:var(--sileo-btn-color,currentColor);background-color:var(--sileo-btn-bg,transparent);transition:background-color 150ms ease}[data-notify-button]:hover{background-color:var(--sileo-btn-bg-hover,transparent)}[data-notify-button][data-state]{--notify-btn-color:var(--_c);--notify-btn-bg:color-mix(in oklch, var(--_c) 15%, transparent);--notify-btn-bg-hover:color-mix(in oklch, var(--_c) 25%, transparent)}[data-notify-icon=spin]{animation:notify-spin 1s linear infinite}@keyframes notify-spin{to{transform:rotate(360deg)}}@keyframes notify-header-enter{from{opacity:0;filter:blur(6px)}to{opacity:1;filter:blur(0px)}}@keyframes notify-header-exit{from{opacity:1;filter:blur(0px)}to{opacity:0;filter:blur(6px)}}[data-notify-viewport]{position:fixed;z-index:50;display:flex;gap:.75rem;padding:.75rem;pointer-events:none;max-width:calc(100vw - 1.5rem);contain:layout style}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){margin-bottom:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){margin-top:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=top]{top:0;flex-direction:column-reverse}[data-notify-viewport][data-position^=bottom]{bottom:0;flex-direction:column}[data-notify-viewport][data-position$=left]{left:0;align-items:flex-start}[data-notify-viewport][data-position$=right]{right:0;align-items:flex-end}[data-notify-viewport][data-position$=center]{left:50%;transform:translateX(-50%);align-items:center}@media (prefers-reduced-motion:no-preference){[data-notify-toast][data-ready=true]:hover,[data-notify-toast][data-ready=true][data-exiting=true]{will-change:transform,opacity,height}}@media (prefers-reduced-motion:reduce){[data-notify-viewport],[data-notify-viewport] *,[data-notify-viewport] ::after,[data-notify-viewport] ::before{animation-duration:0s;animation-iteration-count:1;transition-duration:0s}}[data-notify-viewport][data-theme=dark] [data-notify-description]{color:rgba(0,0,0,.5)}[data-notify-viewport][data-theme=light] [data-notify-description]{color:rgba(255,255,255,.5)}");
|
|
14
|
+
__insertCSS(":root{--notify-spring-easing:linear(\n\t\t0,\n\t\t0.002 0.6%,\n\t\t0.007 1.2%,\n\t\t0.015 1.8%,\n\t\t0.026 2.4%,\n\t\t0.041 3.1%,\n\t\t0.06 3.8%,\n\t\t0.108 5.3%,\n\t\t0.157 6.6%,\n\t\t0.214 8%,\n\t\t0.467 13.7%,\n\t\t0.577 16.3%,\n\t\t0.631 17.7%,\n\t\t0.682 19.1%,\n\t\t0.73 20.5%,\n\t\t0.771 21.8%,\n\t\t0.808 23.1%,\n\t\t0.844 24.5%,\n\t\t0.874 25.8%,\n\t\t0.903 27.2%,\n\t\t0.928 28.6%,\n\t\t0.952 30.1%,\n\t\t0.972 31.6%,\n\t\t0.988 33.1%,\n\t\t1.01 35.7%,\n\t\t1.025 38.5%,\n\t\t1.034 41.6%,\n\t\t1.038 45%,\n\t\t1.035 50.1%,\n\t\t1.012 64.2%,\n\t\t1.003 73%,\n\t\t0.999 83.7%,\n\t\t1\n\t);--notify-duration:600ms;--notify-height:40px;--notify-width:350px;--notify-state-success:oklch(0.723 0.219 142.136);--notify-state-loading:oklch(0.556 0 0);--notify-state-error:oklch(0.637 0.237 25.331);--notify-state-warning:oklch(0.795 0.184 86.047);--notify-state-info:oklch(0.685 0.169 237.323);--notify-state-action:oklch(0.623 0.214 259.815)}[data-notify-toast]{position:relative;cursor:pointer;pointer-events:auto;touch-action:none;border:0;background:0 0;padding:0;width:var(--notify-width);height:var(--_h,var(--notify-height));opacity:0;transform:translateZ(0) scale(.95);transform-origin:center;contain:layout style;overflow:visible}[data-notify-toast][data-state=loading]{cursor:default}[data-notify-toast][data-ready=true]{opacity:1;transform:translateZ(0) scale(1);transition:transform calc(var(--notify-duration) * .66) var(--notify-spring-easing),opacity calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-bottom calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-top calc(var(--notify-duration) * .66) var(--notify-spring-easing),height var(--notify-duration) var(--notify-spring-easing)}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){transform:translateY(6px) scale(.95)}[data-notify-toast][data-ready=true][data-exiting=true]{opacity:0;pointer-events:none}[data-notify-viewport][data-position^=top] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(6px) scale(.95)}[data-notify-canvas]{position:absolute;left:0;right:0;pointer-events:none;transform:translateZ(0);contain:layout style;overflow:visible}[data-sileo-canvas][data-edge=top]{bottom:0;transform:scaleY(-1) translateZ(0)}[data-sileo-canvas][data-edge=bottom]{top:0}[data-notify-svg]{overflow:visible}[data-notify-header]{position:absolute;z-index:20;display:flex;align-items:center;padding:.5rem;height:var(--sileo-height);overflow:hidden;left:var(--_px,0);transform:var(--_ht);max-width:var(--_pw)}[data-notify-toast][data-ready=true] [data-notify-header]{transition:transform var(--sileo-duration) var(--sileo-spring-easing),left var(--sileo-duration) var(--sileo-spring-easing),max-width var(--sileo-duration) var(--sileo-spring-easing)}[data-notify-header][data-edge=top]{bottom:0}[data-notify-header][data-edge=bottom]{top:0}[data-notify-header-stack]{position:relative;display:inline-flex;align-items:center;height:100%}[data-notify-header-inner]{display:flex;align-items:center;gap:.5rem;white-space:nowrap;opacity:1;filter:blur(0px);transform:translateZ(0)}[data-notify-header-inner][data-layer=current]{position:relative;z-index:1;animation:sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both}[data-notify-header-inner][data-exiting=true],[data-notify-header-inner][data-layer=current]:not(:only-child){will-change:opacity,filter}[data-notify-header-inner][data-layer=prev]{position:absolute;left:0;top:0;z-index:0;pointer-events:none}[data-notify-header-inner][data-exiting=true]{animation:notify-header-exit calc(var(--notify-duration) * .7) ease forwards}[data-notify-badge]{display:flex;height:24px;width:24px;flex-shrink:0;align-items:center;justify-content:center;padding:2px;box-sizing:border-box;border-radius:9999px;color:var(--sileo-tone,currentColor);background-color:var(--sileo-tone-bg,transparent)}[data-notify-title]{font-size:.825rem;line-height:1rem;font-weight:500;text-transform:capitalize;color:var(--sileo-tone,currentColor)}:is([data-notify-badge],[data-notify-title],[data-notify-button])[data-state]{--_c:var(--notify-state-success)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=loading]{--_c:var(--notify-state-loading)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=error]{--_c:var(--notify-state-error)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=warning]{--_c:var(--notify-state-warning)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=info]{--_c:var(--notify-state-info)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=action]{--_c:var(--notify-state-action)}:is([data-notify-badge],[data-notify-title])[data-state]{--notify-tone:var(--_c);--notify-tone-bg:color-mix(in oklch, var(--_c) 20%, transparent)}[data-notify-content]{position:absolute;left:0;z-index:10;width:100%;pointer-events:none;opacity:var(--_co, 0)}[data-notify-content]:not([data-visible=true]){content-visibility:hidden}[data-notify-toast][data-ready=true] [data-notify-content]{transition:opacity calc(var(--notify-duration) * .08) ease calc(var(--notify-duration) * .04)}[data-notify-content][data-edge=top]{top:0}[data-notify-content][data-edge=bottom]{top:var(--sileo-height)}[data-notify-content][data-visible=true]{pointer-events:auto}[data-notify-toast][data-ready=true] [data-notify-content][data-visible=true]{transition:opacity calc(var(--notify-duration) * .6) ease calc(var(--notify-duration) * .3)}[data-notify-description]{width:100%;text-align:left;padding:1rem;font-size:.875rem;line-height:1.25rem;contain:layout style paint;content-visibility:auto}[data-notify-button]{display:flex;align-items:center;justify-content:center;height:1.75rem;padding:0 .625rem;margin-top:.75rem;border-radius:9999px;border:0;font-size:.75rem;font-weight:500;cursor:pointer;color:var(--sileo-btn-color,currentColor);background-color:var(--sileo-btn-bg,transparent);transition:background-color 150ms ease}[data-notify-button]:hover{background-color:var(--sileo-btn-bg-hover,transparent)}[data-notify-button][data-state]{--notify-btn-color:var(--_c);--notify-btn-bg:color-mix(in oklch, var(--_c) 15%, transparent);--notify-btn-bg-hover:color-mix(in oklch, var(--_c) 25%, transparent)}[data-notify-icon=spin]{animation:notify-spin 1s linear infinite}@keyframes notify-spin{to{transform:rotate(360deg)}}@keyframes notify-header-enter{from{opacity:0;filter:blur(6px)}to{opacity:1;filter:blur(0px)}}@keyframes notify-header-exit{from{opacity:1;filter:blur(0px)}to{opacity:0;filter:blur(6px)}}[data-notify-viewport]{position:fixed;z-index:50;display:flex;gap:.75rem;padding:.75rem;pointer-events:none;max-width:calc(100vw - 1.5rem);contain:layout style}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){margin-bottom:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){margin-top:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=top]{top:0;flex-direction:column-reverse}[data-notify-viewport][data-position^=bottom]{bottom:0;flex-direction:column}[data-notify-viewport][data-position$=left]{left:0;align-items:flex-start}[data-notify-viewport][data-position$=right]{right:0;align-items:flex-end}[data-notify-viewport][data-position$=center]{left:50%;transform:translateX(-50%);align-items:center}@media (prefers-reduced-motion:no-preference){[data-notify-toast][data-ready=true]:hover,[data-notify-toast][data-ready=true][data-exiting=true]{will-change:transform,opacity,height}}@media (prefers-reduced-motion:reduce){[data-notify-viewport],[data-notify-viewport] *,[data-notify-viewport] ::after,[data-notify-viewport] ::before{animation-duration:0s;animation-iteration-count:1;transition-duration:0s}}[data-notify-viewport][data-theme=dark] [data-notify-description]{color:rgba(0,0,0,.5)}[data-notify-viewport][data-theme=light] [data-notify-description]{color:rgba(255,255,255,.5)}[data-notify-toast]:has([data-notify-card]){width:auto;height:auto;background:0 0}[data-notify-card]{background:#fff;border-radius:20px;box-shadow:0 4px 24px rgba(0,0,0,.1),0 1px 4px rgba(0,0,0,.06);width:var(--notify-width);overflow:hidden}[data-notify-card] [data-notify-header]{position:relative;display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;height:auto;left:auto;max-width:none;transform:none;overflow:visible}[data-notify-card] [data-notify-content]{position:relative;opacity:1;pointer-events:auto;content-visibility:visible;border-top:1px solid rgba(0,0,0,.06)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state]{color:var(--notify-state-success)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=error]{color:var(--notify-state-error)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=warning]{color:var(--notify-state-warning)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=info]{color:var(--notify-state-info)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=loading]{color:var(--notify-state-loading)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=action]{color:var(--notify-state-action)}[data-notify-card] [data-notify-description]{color:rgba(0,0,0,.6)}");
|
|
15
15
|
|
|
16
16
|
// Notify logic (no React dependencies)
|
|
17
17
|
// Provides toast management and utilities for VanillaJS, Vue, Svelte, etc.
|
|
@@ -86,5 +86,121 @@ function onNotifyToastsChange(fn) {
|
|
|
86
86
|
return notifyCore.subscribe(fn);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
const ICONS = {
|
|
90
|
+
success: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>',
|
|
91
|
+
error: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',
|
|
92
|
+
warning: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',
|
|
93
|
+
info: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="m4.93 4.93 4.24 4.24"/><path d="m14.83 9.17 4.24-4.24"/><path d="m14.83 14.83 4.24 4.24"/><path d="m9.17 14.83-4.24 4.24"/><circle cx="12" cy="12" r="4"/></svg>',
|
|
94
|
+
loading: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" data-notify-icon="spin" aria-hidden="true"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',
|
|
95
|
+
action: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>'
|
|
96
|
+
};
|
|
97
|
+
const EXIT_MS = 600;
|
|
98
|
+
function capitalize(s) {
|
|
99
|
+
return s ? s.charAt(0).toUpperCase() + s.slice(1) : "";
|
|
100
|
+
}
|
|
101
|
+
let viewport = null;
|
|
102
|
+
const toastEls = new Map();
|
|
103
|
+
function getOrCreateViewport(position) {
|
|
104
|
+
if (!viewport) {
|
|
105
|
+
viewport = document.createElement("div");
|
|
106
|
+
viewport.setAttribute("data-notify-viewport", "");
|
|
107
|
+
viewport.setAttribute("data-position", position);
|
|
108
|
+
viewport.setAttribute("data-theme", "light");
|
|
109
|
+
document.body.appendChild(viewport);
|
|
110
|
+
}
|
|
111
|
+
return viewport;
|
|
112
|
+
}
|
|
113
|
+
function buildToastEl(toast) {
|
|
114
|
+
const state = toast.type || "success";
|
|
115
|
+
const btn = document.createElement("button");
|
|
116
|
+
btn.type = "button";
|
|
117
|
+
btn.setAttribute("data-notify-toast", "");
|
|
118
|
+
btn.setAttribute("data-state", state);
|
|
119
|
+
btn.setAttribute("data-ready", "false");
|
|
120
|
+
btn.setAttribute("data-exiting", "false");
|
|
121
|
+
const card = document.createElement("div");
|
|
122
|
+
card.setAttribute("data-notify-card", "");
|
|
123
|
+
const header = document.createElement("div");
|
|
124
|
+
header.setAttribute("data-notify-header", "");
|
|
125
|
+
const badge = document.createElement("div");
|
|
126
|
+
badge.setAttribute("data-notify-badge", "");
|
|
127
|
+
badge.setAttribute("data-state", state);
|
|
128
|
+
badge.innerHTML = ICONS[state] || ICONS.success;
|
|
129
|
+
const titleEl = document.createElement("span");
|
|
130
|
+
titleEl.setAttribute("data-notify-title", "");
|
|
131
|
+
titleEl.setAttribute("data-state", state);
|
|
132
|
+
titleEl.textContent = toast.title || capitalize(state);
|
|
133
|
+
header.appendChild(badge);
|
|
134
|
+
header.appendChild(titleEl);
|
|
135
|
+
card.appendChild(header);
|
|
136
|
+
if (toast.description || toast.button) {
|
|
137
|
+
const content = document.createElement("div");
|
|
138
|
+
content.setAttribute("data-notify-content", "");
|
|
139
|
+
content.setAttribute("data-visible", "true");
|
|
140
|
+
if (toast.description) {
|
|
141
|
+
const desc = document.createElement("div");
|
|
142
|
+
desc.setAttribute("data-notify-description", "");
|
|
143
|
+
desc.textContent = toast.description;
|
|
144
|
+
content.appendChild(desc);
|
|
145
|
+
}
|
|
146
|
+
if (toast.button) {
|
|
147
|
+
const actionBtn = document.createElement("button");
|
|
148
|
+
actionBtn.setAttribute("data-notify-button", "");
|
|
149
|
+
actionBtn.setAttribute("data-state", state);
|
|
150
|
+
actionBtn.textContent = toast.button.title;
|
|
151
|
+
actionBtn.addEventListener("click", (e)=>{
|
|
152
|
+
var _toast_button;
|
|
153
|
+
e.stopPropagation();
|
|
154
|
+
(_toast_button = toast.button) == null ? void 0 : _toast_button.onClick();
|
|
155
|
+
notifyCore.dismiss(toast.id);
|
|
156
|
+
});
|
|
157
|
+
content.appendChild(actionBtn);
|
|
158
|
+
}
|
|
159
|
+
card.appendChild(content);
|
|
160
|
+
}
|
|
161
|
+
btn.appendChild(card);
|
|
162
|
+
btn.addEventListener("click", ()=>notifyCore.dismiss(toast.id));
|
|
163
|
+
requestAnimationFrame(()=>{
|
|
164
|
+
requestAnimationFrame(()=>{
|
|
165
|
+
btn.setAttribute("data-ready", "true");
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
return btn;
|
|
169
|
+
}
|
|
170
|
+
function updateToastEl(el, toast) {
|
|
171
|
+
const state = toast.type || "success";
|
|
172
|
+
el.setAttribute("data-state", state);
|
|
173
|
+
if (toast.exiting) {
|
|
174
|
+
el.setAttribute("data-exiting", "true");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function renderNotifyToasts(options = {}) {
|
|
178
|
+
var _options_position;
|
|
179
|
+
const position = (_options_position = options.position) != null ? _options_position : "top-right";
|
|
180
|
+
const vp = getOrCreateViewport(position);
|
|
181
|
+
return notifyCore.subscribe((toasts)=>{
|
|
182
|
+
const liveIds = new Set(toasts.map((t)=>t.id));
|
|
183
|
+
for (const [id, el] of toastEls){
|
|
184
|
+
if (!liveIds.has(id)) {
|
|
185
|
+
el.setAttribute("data-exiting", "true");
|
|
186
|
+
setTimeout(()=>{
|
|
187
|
+
el.remove();
|
|
188
|
+
toastEls.delete(id);
|
|
189
|
+
}, EXIT_MS);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const toast of toasts){
|
|
193
|
+
if (toastEls.has(toast.id)) {
|
|
194
|
+
updateToastEl(toastEls.get(toast.id), toast);
|
|
195
|
+
} else {
|
|
196
|
+
const el = buildToastEl(toast);
|
|
197
|
+
toastEls.set(toast.id, el);
|
|
198
|
+
vp.appendChild(el);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
89
204
|
exports.onNotifyToastsChange = onNotifyToastsChange;
|
|
205
|
+
exports.renderNotifyToasts = renderNotifyToasts;
|
|
90
206
|
exports.showNotifyToast = showNotifyToast;
|
package/dist/notify.mjs
CHANGED
|
@@ -9,7 +9,7 @@ function __insertCSS(code) {
|
|
|
9
9
|
|
|
10
10
|
import { _ as _extends } from './cc-2Yt7NqMX.mjs';
|
|
11
11
|
|
|
12
|
-
__insertCSS(":root{--notify-spring-easing:linear(\n\t\t0,\n\t\t0.002 0.6%,\n\t\t0.007 1.2%,\n\t\t0.015 1.8%,\n\t\t0.026 2.4%,\n\t\t0.041 3.1%,\n\t\t0.06 3.8%,\n\t\t0.108 5.3%,\n\t\t0.157 6.6%,\n\t\t0.214 8%,\n\t\t0.467 13.7%,\n\t\t0.577 16.3%,\n\t\t0.631 17.7%,\n\t\t0.682 19.1%,\n\t\t0.73 20.5%,\n\t\t0.771 21.8%,\n\t\t0.808 23.1%,\n\t\t0.844 24.5%,\n\t\t0.874 25.8%,\n\t\t0.903 27.2%,\n\t\t0.928 28.6%,\n\t\t0.952 30.1%,\n\t\t0.972 31.6%,\n\t\t0.988 33.1%,\n\t\t1.01 35.7%,\n\t\t1.025 38.5%,\n\t\t1.034 41.6%,\n\t\t1.038 45%,\n\t\t1.035 50.1%,\n\t\t1.012 64.2%,\n\t\t1.003 73%,\n\t\t0.999 83.7%,\n\t\t1\n\t);--notify-duration:600ms;--notify-height:40px;--notify-width:350px;--notify-state-success:oklch(0.723 0.219 142.136);--notify-state-loading:oklch(0.556 0 0);--notify-state-error:oklch(0.637 0.237 25.331);--notify-state-warning:oklch(0.795 0.184 86.047);--notify-state-info:oklch(0.685 0.169 237.323);--notify-state-action:oklch(0.623 0.214 259.815)}[data-notify-toast]{position:relative;cursor:pointer;pointer-events:auto;touch-action:none;border:0;background:0 0;padding:0;width:var(--notify-width);height:var(--_h,var(--notify-height));opacity:0;transform:translateZ(0) scale(.95);transform-origin:center;contain:layout style;overflow:visible}[data-notify-toast][data-state=loading]{cursor:default}[data-notify-toast][data-ready=true]{opacity:1;transform:translateZ(0) scale(1);transition:transform calc(var(--notify-duration) * .66) var(--notify-spring-easing),opacity calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-bottom calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-top calc(var(--notify-duration) * .66) var(--notify-spring-easing),height var(--notify-duration) var(--notify-spring-easing)}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){transform:translateY(6px) scale(.95)}[data-notify-toast][data-ready=true][data-exiting=true]{opacity:0;pointer-events:none}[data-notify-viewport][data-position^=top] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(6px) scale(.95)}[data-notify-canvas]{position:absolute;left:0;right:0;pointer-events:none;transform:translateZ(0);contain:layout style;overflow:visible}[data-sileo-canvas][data-edge=top]{bottom:0;transform:scaleY(-1) translateZ(0)}[data-sileo-canvas][data-edge=bottom]{top:0}[data-notify-svg]{overflow:visible}[data-notify-header]{position:absolute;z-index:20;display:flex;align-items:center;padding:.5rem;height:var(--sileo-height);overflow:hidden;left:var(--_px,0);transform:var(--_ht);max-width:var(--_pw)}[data-notify-toast][data-ready=true] [data-notify-header]{transition:transform var(--sileo-duration) var(--sileo-spring-easing),left var(--sileo-duration) var(--sileo-spring-easing),max-width var(--sileo-duration) var(--sileo-spring-easing)}[data-notify-header][data-edge=top]{bottom:0}[data-notify-header][data-edge=bottom]{top:0}[data-notify-header-stack]{position:relative;display:inline-flex;align-items:center;height:100%}[data-notify-header-inner]{display:flex;align-items:center;gap:.5rem;white-space:nowrap;opacity:1;filter:blur(0px);transform:translateZ(0)}[data-notify-header-inner][data-layer=current]{position:relative;z-index:1;animation:sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both}[data-notify-header-inner][data-exiting=true],[data-notify-header-inner][data-layer=current]:not(:only-child){will-change:opacity,filter}[data-notify-header-inner][data-layer=prev]{position:absolute;left:0;top:0;z-index:0;pointer-events:none}[data-notify-header-inner][data-exiting=true]{animation:notify-header-exit calc(var(--notify-duration) * .7) ease forwards}[data-notify-badge]{display:flex;height:24px;width:24px;flex-shrink:0;align-items:center;justify-content:center;padding:2px;box-sizing:border-box;border-radius:9999px;color:var(--sileo-tone,currentColor);background-color:var(--sileo-tone-bg,transparent)}[data-notify-title]{font-size:.825rem;line-height:1rem;font-weight:500;text-transform:capitalize;color:var(--sileo-tone,currentColor)}:is([data-notify-badge],[data-notify-title],[data-notify-button])[data-state]{--_c:var(--notify-state-success)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=loading]{--_c:var(--notify-state-loading)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=error]{--_c:var(--notify-state-error)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=warning]{--_c:var(--notify-state-warning)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=info]{--_c:var(--notify-state-info)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=action]{--_c:var(--notify-state-action)}:is([data-notify-badge],[data-notify-title])[data-state]{--notify-tone:var(--_c);--notify-tone-bg:color-mix(in oklch, var(--_c) 20%, transparent)}[data-notify-content]{position:absolute;left:0;z-index:10;width:100%;pointer-events:none;opacity:var(--_co, 0)}[data-notify-content]:not([data-visible=true]){content-visibility:hidden}[data-notify-toast][data-ready=true] [data-notify-content]{transition:opacity calc(var(--notify-duration) * .08) ease calc(var(--notify-duration) * .04)}[data-notify-content][data-edge=top]{top:0}[data-notify-content][data-edge=bottom]{top:var(--sileo-height)}[data-notify-content][data-visible=true]{pointer-events:auto}[data-notify-toast][data-ready=true] [data-notify-content][data-visible=true]{transition:opacity calc(var(--notify-duration) * .6) ease calc(var(--notify-duration) * .3)}[data-notify-description]{width:100%;text-align:left;padding:1rem;font-size:.875rem;line-height:1.25rem;contain:layout style paint;content-visibility:auto}[data-notify-button]{display:flex;align-items:center;justify-content:center;height:1.75rem;padding:0 .625rem;margin-top:.75rem;border-radius:9999px;border:0;font-size:.75rem;font-weight:500;cursor:pointer;color:var(--sileo-btn-color,currentColor);background-color:var(--sileo-btn-bg,transparent);transition:background-color 150ms ease}[data-notify-button]:hover{background-color:var(--sileo-btn-bg-hover,transparent)}[data-notify-button][data-state]{--notify-btn-color:var(--_c);--notify-btn-bg:color-mix(in oklch, var(--_c) 15%, transparent);--notify-btn-bg-hover:color-mix(in oklch, var(--_c) 25%, transparent)}[data-notify-icon=spin]{animation:notify-spin 1s linear infinite}@keyframes notify-spin{to{transform:rotate(360deg)}}@keyframes notify-header-enter{from{opacity:0;filter:blur(6px)}to{opacity:1;filter:blur(0px)}}@keyframes notify-header-exit{from{opacity:1;filter:blur(0px)}to{opacity:0;filter:blur(6px)}}[data-notify-viewport]{position:fixed;z-index:50;display:flex;gap:.75rem;padding:.75rem;pointer-events:none;max-width:calc(100vw - 1.5rem);contain:layout style}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){margin-bottom:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){margin-top:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=top]{top:0;flex-direction:column-reverse}[data-notify-viewport][data-position^=bottom]{bottom:0;flex-direction:column}[data-notify-viewport][data-position$=left]{left:0;align-items:flex-start}[data-notify-viewport][data-position$=right]{right:0;align-items:flex-end}[data-notify-viewport][data-position$=center]{left:50%;transform:translateX(-50%);align-items:center}@media (prefers-reduced-motion:no-preference){[data-notify-toast][data-ready=true]:hover,[data-notify-toast][data-ready=true][data-exiting=true]{will-change:transform,opacity,height}}@media (prefers-reduced-motion:reduce){[data-notify-viewport],[data-notify-viewport] *,[data-notify-viewport] ::after,[data-notify-viewport] ::before{animation-duration:0s;animation-iteration-count:1;transition-duration:0s}}[data-notify-viewport][data-theme=dark] [data-notify-description]{color:rgba(0,0,0,.5)}[data-notify-viewport][data-theme=light] [data-notify-description]{color:rgba(255,255,255,.5)}");
|
|
12
|
+
__insertCSS(":root{--notify-spring-easing:linear(\n\t\t0,\n\t\t0.002 0.6%,\n\t\t0.007 1.2%,\n\t\t0.015 1.8%,\n\t\t0.026 2.4%,\n\t\t0.041 3.1%,\n\t\t0.06 3.8%,\n\t\t0.108 5.3%,\n\t\t0.157 6.6%,\n\t\t0.214 8%,\n\t\t0.467 13.7%,\n\t\t0.577 16.3%,\n\t\t0.631 17.7%,\n\t\t0.682 19.1%,\n\t\t0.73 20.5%,\n\t\t0.771 21.8%,\n\t\t0.808 23.1%,\n\t\t0.844 24.5%,\n\t\t0.874 25.8%,\n\t\t0.903 27.2%,\n\t\t0.928 28.6%,\n\t\t0.952 30.1%,\n\t\t0.972 31.6%,\n\t\t0.988 33.1%,\n\t\t1.01 35.7%,\n\t\t1.025 38.5%,\n\t\t1.034 41.6%,\n\t\t1.038 45%,\n\t\t1.035 50.1%,\n\t\t1.012 64.2%,\n\t\t1.003 73%,\n\t\t0.999 83.7%,\n\t\t1\n\t);--notify-duration:600ms;--notify-height:40px;--notify-width:350px;--notify-state-success:oklch(0.723 0.219 142.136);--notify-state-loading:oklch(0.556 0 0);--notify-state-error:oklch(0.637 0.237 25.331);--notify-state-warning:oklch(0.795 0.184 86.047);--notify-state-info:oklch(0.685 0.169 237.323);--notify-state-action:oklch(0.623 0.214 259.815)}[data-notify-toast]{position:relative;cursor:pointer;pointer-events:auto;touch-action:none;border:0;background:0 0;padding:0;width:var(--notify-width);height:var(--_h,var(--notify-height));opacity:0;transform:translateZ(0) scale(.95);transform-origin:center;contain:layout style;overflow:visible}[data-notify-toast][data-state=loading]{cursor:default}[data-notify-toast][data-ready=true]{opacity:1;transform:translateZ(0) scale(1);transition:transform calc(var(--notify-duration) * .66) var(--notify-spring-easing),opacity calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-bottom calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-top calc(var(--notify-duration) * .66) var(--notify-spring-easing),height var(--notify-duration) var(--notify-spring-easing)}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){transform:translateY(6px) scale(.95)}[data-notify-toast][data-ready=true][data-exiting=true]{opacity:0;pointer-events:none}[data-notify-viewport][data-position^=top] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(6px) scale(.95)}[data-notify-canvas]{position:absolute;left:0;right:0;pointer-events:none;transform:translateZ(0);contain:layout style;overflow:visible}[data-sileo-canvas][data-edge=top]{bottom:0;transform:scaleY(-1) translateZ(0)}[data-sileo-canvas][data-edge=bottom]{top:0}[data-notify-svg]{overflow:visible}[data-notify-header]{position:absolute;z-index:20;display:flex;align-items:center;padding:.5rem;height:var(--sileo-height);overflow:hidden;left:var(--_px,0);transform:var(--_ht);max-width:var(--_pw)}[data-notify-toast][data-ready=true] [data-notify-header]{transition:transform var(--sileo-duration) var(--sileo-spring-easing),left var(--sileo-duration) var(--sileo-spring-easing),max-width var(--sileo-duration) var(--sileo-spring-easing)}[data-notify-header][data-edge=top]{bottom:0}[data-notify-header][data-edge=bottom]{top:0}[data-notify-header-stack]{position:relative;display:inline-flex;align-items:center;height:100%}[data-notify-header-inner]{display:flex;align-items:center;gap:.5rem;white-space:nowrap;opacity:1;filter:blur(0px);transform:translateZ(0)}[data-notify-header-inner][data-layer=current]{position:relative;z-index:1;animation:sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both}[data-notify-header-inner][data-exiting=true],[data-notify-header-inner][data-layer=current]:not(:only-child){will-change:opacity,filter}[data-notify-header-inner][data-layer=prev]{position:absolute;left:0;top:0;z-index:0;pointer-events:none}[data-notify-header-inner][data-exiting=true]{animation:notify-header-exit calc(var(--notify-duration) * .7) ease forwards}[data-notify-badge]{display:flex;height:24px;width:24px;flex-shrink:0;align-items:center;justify-content:center;padding:2px;box-sizing:border-box;border-radius:9999px;color:var(--sileo-tone,currentColor);background-color:var(--sileo-tone-bg,transparent)}[data-notify-title]{font-size:.825rem;line-height:1rem;font-weight:500;text-transform:capitalize;color:var(--sileo-tone,currentColor)}:is([data-notify-badge],[data-notify-title],[data-notify-button])[data-state]{--_c:var(--notify-state-success)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=loading]{--_c:var(--notify-state-loading)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=error]{--_c:var(--notify-state-error)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=warning]{--_c:var(--notify-state-warning)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=info]{--_c:var(--notify-state-info)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=action]{--_c:var(--notify-state-action)}:is([data-notify-badge],[data-notify-title])[data-state]{--notify-tone:var(--_c);--notify-tone-bg:color-mix(in oklch, var(--_c) 20%, transparent)}[data-notify-content]{position:absolute;left:0;z-index:10;width:100%;pointer-events:none;opacity:var(--_co, 0)}[data-notify-content]:not([data-visible=true]){content-visibility:hidden}[data-notify-toast][data-ready=true] [data-notify-content]{transition:opacity calc(var(--notify-duration) * .08) ease calc(var(--notify-duration) * .04)}[data-notify-content][data-edge=top]{top:0}[data-notify-content][data-edge=bottom]{top:var(--sileo-height)}[data-notify-content][data-visible=true]{pointer-events:auto}[data-notify-toast][data-ready=true] [data-notify-content][data-visible=true]{transition:opacity calc(var(--notify-duration) * .6) ease calc(var(--notify-duration) * .3)}[data-notify-description]{width:100%;text-align:left;padding:1rem;font-size:.875rem;line-height:1.25rem;contain:layout style paint;content-visibility:auto}[data-notify-button]{display:flex;align-items:center;justify-content:center;height:1.75rem;padding:0 .625rem;margin-top:.75rem;border-radius:9999px;border:0;font-size:.75rem;font-weight:500;cursor:pointer;color:var(--sileo-btn-color,currentColor);background-color:var(--sileo-btn-bg,transparent);transition:background-color 150ms ease}[data-notify-button]:hover{background-color:var(--sileo-btn-bg-hover,transparent)}[data-notify-button][data-state]{--notify-btn-color:var(--_c);--notify-btn-bg:color-mix(in oklch, var(--_c) 15%, transparent);--notify-btn-bg-hover:color-mix(in oklch, var(--_c) 25%, transparent)}[data-notify-icon=spin]{animation:notify-spin 1s linear infinite}@keyframes notify-spin{to{transform:rotate(360deg)}}@keyframes notify-header-enter{from{opacity:0;filter:blur(6px)}to{opacity:1;filter:blur(0px)}}@keyframes notify-header-exit{from{opacity:1;filter:blur(0px)}to{opacity:0;filter:blur(6px)}}[data-notify-viewport]{position:fixed;z-index:50;display:flex;gap:.75rem;padding:.75rem;pointer-events:none;max-width:calc(100vw - 1.5rem);contain:layout style}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){margin-bottom:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){margin-top:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=top]{top:0;flex-direction:column-reverse}[data-notify-viewport][data-position^=bottom]{bottom:0;flex-direction:column}[data-notify-viewport][data-position$=left]{left:0;align-items:flex-start}[data-notify-viewport][data-position$=right]{right:0;align-items:flex-end}[data-notify-viewport][data-position$=center]{left:50%;transform:translateX(-50%);align-items:center}@media (prefers-reduced-motion:no-preference){[data-notify-toast][data-ready=true]:hover,[data-notify-toast][data-ready=true][data-exiting=true]{will-change:transform,opacity,height}}@media (prefers-reduced-motion:reduce){[data-notify-viewport],[data-notify-viewport] *,[data-notify-viewport] ::after,[data-notify-viewport] ::before{animation-duration:0s;animation-iteration-count:1;transition-duration:0s}}[data-notify-viewport][data-theme=dark] [data-notify-description]{color:rgba(0,0,0,.5)}[data-notify-viewport][data-theme=light] [data-notify-description]{color:rgba(255,255,255,.5)}[data-notify-toast]:has([data-notify-card]){width:auto;height:auto;background:0 0}[data-notify-card]{background:#fff;border-radius:20px;box-shadow:0 4px 24px rgba(0,0,0,.1),0 1px 4px rgba(0,0,0,.06);width:var(--notify-width);overflow:hidden}[data-notify-card] [data-notify-header]{position:relative;display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;height:auto;left:auto;max-width:none;transform:none;overflow:visible}[data-notify-card] [data-notify-content]{position:relative;opacity:1;pointer-events:auto;content-visibility:visible;border-top:1px solid rgba(0,0,0,.06)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state]{color:var(--notify-state-success)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=error]{color:var(--notify-state-error)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=warning]{color:var(--notify-state-warning)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=info]{color:var(--notify-state-info)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=loading]{color:var(--notify-state-loading)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=action]{color:var(--notify-state-action)}[data-notify-card] [data-notify-description]{color:rgba(0,0,0,.6)}");
|
|
13
13
|
|
|
14
14
|
// Notify logic (no React dependencies)
|
|
15
15
|
// Provides toast management and utilities for VanillaJS, Vue, Svelte, etc.
|
|
@@ -84,4 +84,119 @@ function onNotifyToastsChange(fn) {
|
|
|
84
84
|
return notifyCore.subscribe(fn);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
const ICONS = {
|
|
88
|
+
success: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>',
|
|
89
|
+
error: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',
|
|
90
|
+
warning: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',
|
|
91
|
+
info: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="m4.93 4.93 4.24 4.24"/><path d="m14.83 9.17 4.24-4.24"/><path d="m14.83 14.83 4.24 4.24"/><path d="m9.17 14.83-4.24 4.24"/><circle cx="12" cy="12" r="4"/></svg>',
|
|
92
|
+
loading: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" data-notify-icon="spin" aria-hidden="true"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',
|
|
93
|
+
action: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>'
|
|
94
|
+
};
|
|
95
|
+
const EXIT_MS = 600;
|
|
96
|
+
function capitalize(s) {
|
|
97
|
+
return s ? s.charAt(0).toUpperCase() + s.slice(1) : "";
|
|
98
|
+
}
|
|
99
|
+
let viewport = null;
|
|
100
|
+
const toastEls = new Map();
|
|
101
|
+
function getOrCreateViewport(position) {
|
|
102
|
+
if (!viewport) {
|
|
103
|
+
viewport = document.createElement("div");
|
|
104
|
+
viewport.setAttribute("data-notify-viewport", "");
|
|
105
|
+
viewport.setAttribute("data-position", position);
|
|
106
|
+
viewport.setAttribute("data-theme", "light");
|
|
107
|
+
document.body.appendChild(viewport);
|
|
108
|
+
}
|
|
109
|
+
return viewport;
|
|
110
|
+
}
|
|
111
|
+
function buildToastEl(toast) {
|
|
112
|
+
const state = toast.type || "success";
|
|
113
|
+
const btn = document.createElement("button");
|
|
114
|
+
btn.type = "button";
|
|
115
|
+
btn.setAttribute("data-notify-toast", "");
|
|
116
|
+
btn.setAttribute("data-state", state);
|
|
117
|
+
btn.setAttribute("data-ready", "false");
|
|
118
|
+
btn.setAttribute("data-exiting", "false");
|
|
119
|
+
const card = document.createElement("div");
|
|
120
|
+
card.setAttribute("data-notify-card", "");
|
|
121
|
+
const header = document.createElement("div");
|
|
122
|
+
header.setAttribute("data-notify-header", "");
|
|
123
|
+
const badge = document.createElement("div");
|
|
124
|
+
badge.setAttribute("data-notify-badge", "");
|
|
125
|
+
badge.setAttribute("data-state", state);
|
|
126
|
+
badge.innerHTML = ICONS[state] || ICONS.success;
|
|
127
|
+
const titleEl = document.createElement("span");
|
|
128
|
+
titleEl.setAttribute("data-notify-title", "");
|
|
129
|
+
titleEl.setAttribute("data-state", state);
|
|
130
|
+
titleEl.textContent = toast.title || capitalize(state);
|
|
131
|
+
header.appendChild(badge);
|
|
132
|
+
header.appendChild(titleEl);
|
|
133
|
+
card.appendChild(header);
|
|
134
|
+
if (toast.description || toast.button) {
|
|
135
|
+
const content = document.createElement("div");
|
|
136
|
+
content.setAttribute("data-notify-content", "");
|
|
137
|
+
content.setAttribute("data-visible", "true");
|
|
138
|
+
if (toast.description) {
|
|
139
|
+
const desc = document.createElement("div");
|
|
140
|
+
desc.setAttribute("data-notify-description", "");
|
|
141
|
+
desc.textContent = toast.description;
|
|
142
|
+
content.appendChild(desc);
|
|
143
|
+
}
|
|
144
|
+
if (toast.button) {
|
|
145
|
+
const actionBtn = document.createElement("button");
|
|
146
|
+
actionBtn.setAttribute("data-notify-button", "");
|
|
147
|
+
actionBtn.setAttribute("data-state", state);
|
|
148
|
+
actionBtn.textContent = toast.button.title;
|
|
149
|
+
actionBtn.addEventListener("click", (e)=>{
|
|
150
|
+
var _toast_button;
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
(_toast_button = toast.button) == null ? void 0 : _toast_button.onClick();
|
|
153
|
+
notifyCore.dismiss(toast.id);
|
|
154
|
+
});
|
|
155
|
+
content.appendChild(actionBtn);
|
|
156
|
+
}
|
|
157
|
+
card.appendChild(content);
|
|
158
|
+
}
|
|
159
|
+
btn.appendChild(card);
|
|
160
|
+
btn.addEventListener("click", ()=>notifyCore.dismiss(toast.id));
|
|
161
|
+
requestAnimationFrame(()=>{
|
|
162
|
+
requestAnimationFrame(()=>{
|
|
163
|
+
btn.setAttribute("data-ready", "true");
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
return btn;
|
|
167
|
+
}
|
|
168
|
+
function updateToastEl(el, toast) {
|
|
169
|
+
const state = toast.type || "success";
|
|
170
|
+
el.setAttribute("data-state", state);
|
|
171
|
+
if (toast.exiting) {
|
|
172
|
+
el.setAttribute("data-exiting", "true");
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function renderNotifyToasts(options = {}) {
|
|
176
|
+
var _options_position;
|
|
177
|
+
const position = (_options_position = options.position) != null ? _options_position : "top-right";
|
|
178
|
+
const vp = getOrCreateViewport(position);
|
|
179
|
+
return notifyCore.subscribe((toasts)=>{
|
|
180
|
+
const liveIds = new Set(toasts.map((t)=>t.id));
|
|
181
|
+
for (const [id, el] of toastEls){
|
|
182
|
+
if (!liveIds.has(id)) {
|
|
183
|
+
el.setAttribute("data-exiting", "true");
|
|
184
|
+
setTimeout(()=>{
|
|
185
|
+
el.remove();
|
|
186
|
+
toastEls.delete(id);
|
|
187
|
+
}, EXIT_MS);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
for (const toast of toasts){
|
|
191
|
+
if (toastEls.has(toast.id)) {
|
|
192
|
+
updateToastEl(toastEls.get(toast.id), toast);
|
|
193
|
+
} else {
|
|
194
|
+
const el = buildToastEl(toast);
|
|
195
|
+
toastEls.set(toast.id, el);
|
|
196
|
+
vp.appendChild(el);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { onNotifyToastsChange, renderNotifyToasts, showNotifyToast };
|
|
@@ -13,7 +13,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
13
13
|
import { memo, useMemo, useState, useRef, useLayoutEffect, useEffect, useCallback } from 'react';
|
|
14
14
|
import { motion } from 'motion/react';
|
|
15
15
|
|
|
16
|
-
__insertCSS(":root{--notify-spring-easing:linear(\n\t\t0,\n\t\t0.002 0.6%,\n\t\t0.007 1.2%,\n\t\t0.015 1.8%,\n\t\t0.026 2.4%,\n\t\t0.041 3.1%,\n\t\t0.06 3.8%,\n\t\t0.108 5.3%,\n\t\t0.157 6.6%,\n\t\t0.214 8%,\n\t\t0.467 13.7%,\n\t\t0.577 16.3%,\n\t\t0.631 17.7%,\n\t\t0.682 19.1%,\n\t\t0.73 20.5%,\n\t\t0.771 21.8%,\n\t\t0.808 23.1%,\n\t\t0.844 24.5%,\n\t\t0.874 25.8%,\n\t\t0.903 27.2%,\n\t\t0.928 28.6%,\n\t\t0.952 30.1%,\n\t\t0.972 31.6%,\n\t\t0.988 33.1%,\n\t\t1.01 35.7%,\n\t\t1.025 38.5%,\n\t\t1.034 41.6%,\n\t\t1.038 45%,\n\t\t1.035 50.1%,\n\t\t1.012 64.2%,\n\t\t1.003 73%,\n\t\t0.999 83.7%,\n\t\t1\n\t);--notify-duration:600ms;--notify-height:40px;--notify-width:350px;--notify-state-success:oklch(0.723 0.219 142.136);--notify-state-loading:oklch(0.556 0 0);--notify-state-error:oklch(0.637 0.237 25.331);--notify-state-warning:oklch(0.795 0.184 86.047);--notify-state-info:oklch(0.685 0.169 237.323);--notify-state-action:oklch(0.623 0.214 259.815)}[data-notify-toast]{position:relative;cursor:pointer;pointer-events:auto;touch-action:none;border:0;background:0 0;padding:0;width:var(--notify-width);height:var(--_h,var(--notify-height));opacity:0;transform:translateZ(0) scale(.95);transform-origin:center;contain:layout style;overflow:visible}[data-notify-toast][data-state=loading]{cursor:default}[data-notify-toast][data-ready=true]{opacity:1;transform:translateZ(0) scale(1);transition:transform calc(var(--notify-duration) * .66) var(--notify-spring-easing),opacity calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-bottom calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-top calc(var(--notify-duration) * .66) var(--notify-spring-easing),height var(--notify-duration) var(--notify-spring-easing)}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){transform:translateY(6px) scale(.95)}[data-notify-toast][data-ready=true][data-exiting=true]{opacity:0;pointer-events:none}[data-notify-viewport][data-position^=top] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(6px) scale(.95)}[data-notify-canvas]{position:absolute;left:0;right:0;pointer-events:none;transform:translateZ(0);contain:layout style;overflow:visible}[data-sileo-canvas][data-edge=top]{bottom:0;transform:scaleY(-1) translateZ(0)}[data-sileo-canvas][data-edge=bottom]{top:0}[data-notify-svg]{overflow:visible}[data-notify-header]{position:absolute;z-index:20;display:flex;align-items:center;padding:.5rem;height:var(--sileo-height);overflow:hidden;left:var(--_px,0);transform:var(--_ht);max-width:var(--_pw)}[data-notify-toast][data-ready=true] [data-notify-header]{transition:transform var(--sileo-duration) var(--sileo-spring-easing),left var(--sileo-duration) var(--sileo-spring-easing),max-width var(--sileo-duration) var(--sileo-spring-easing)}[data-notify-header][data-edge=top]{bottom:0}[data-notify-header][data-edge=bottom]{top:0}[data-notify-header-stack]{position:relative;display:inline-flex;align-items:center;height:100%}[data-notify-header-inner]{display:flex;align-items:center;gap:.5rem;white-space:nowrap;opacity:1;filter:blur(0px);transform:translateZ(0)}[data-notify-header-inner][data-layer=current]{position:relative;z-index:1;animation:sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both}[data-notify-header-inner][data-exiting=true],[data-notify-header-inner][data-layer=current]:not(:only-child){will-change:opacity,filter}[data-notify-header-inner][data-layer=prev]{position:absolute;left:0;top:0;z-index:0;pointer-events:none}[data-notify-header-inner][data-exiting=true]{animation:notify-header-exit calc(var(--notify-duration) * .7) ease forwards}[data-notify-badge]{display:flex;height:24px;width:24px;flex-shrink:0;align-items:center;justify-content:center;padding:2px;box-sizing:border-box;border-radius:9999px;color:var(--sileo-tone,currentColor);background-color:var(--sileo-tone-bg,transparent)}[data-notify-title]{font-size:.825rem;line-height:1rem;font-weight:500;text-transform:capitalize;color:var(--sileo-tone,currentColor)}:is([data-notify-badge],[data-notify-title],[data-notify-button])[data-state]{--_c:var(--notify-state-success)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=loading]{--_c:var(--notify-state-loading)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=error]{--_c:var(--notify-state-error)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=warning]{--_c:var(--notify-state-warning)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=info]{--_c:var(--notify-state-info)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=action]{--_c:var(--notify-state-action)}:is([data-notify-badge],[data-notify-title])[data-state]{--notify-tone:var(--_c);--notify-tone-bg:color-mix(in oklch, var(--_c) 20%, transparent)}[data-notify-content]{position:absolute;left:0;z-index:10;width:100%;pointer-events:none;opacity:var(--_co, 0)}[data-notify-content]:not([data-visible=true]){content-visibility:hidden}[data-notify-toast][data-ready=true] [data-notify-content]{transition:opacity calc(var(--notify-duration) * .08) ease calc(var(--notify-duration) * .04)}[data-notify-content][data-edge=top]{top:0}[data-notify-content][data-edge=bottom]{top:var(--sileo-height)}[data-notify-content][data-visible=true]{pointer-events:auto}[data-notify-toast][data-ready=true] [data-notify-content][data-visible=true]{transition:opacity calc(var(--notify-duration) * .6) ease calc(var(--notify-duration) * .3)}[data-notify-description]{width:100%;text-align:left;padding:1rem;font-size:.875rem;line-height:1.25rem;contain:layout style paint;content-visibility:auto}[data-notify-button]{display:flex;align-items:center;justify-content:center;height:1.75rem;padding:0 .625rem;margin-top:.75rem;border-radius:9999px;border:0;font-size:.75rem;font-weight:500;cursor:pointer;color:var(--sileo-btn-color,currentColor);background-color:var(--sileo-btn-bg,transparent);transition:background-color 150ms ease}[data-notify-button]:hover{background-color:var(--sileo-btn-bg-hover,transparent)}[data-notify-button][data-state]{--notify-btn-color:var(--_c);--notify-btn-bg:color-mix(in oklch, var(--_c) 15%, transparent);--notify-btn-bg-hover:color-mix(in oklch, var(--_c) 25%, transparent)}[data-notify-icon=spin]{animation:notify-spin 1s linear infinite}@keyframes notify-spin{to{transform:rotate(360deg)}}@keyframes notify-header-enter{from{opacity:0;filter:blur(6px)}to{opacity:1;filter:blur(0px)}}@keyframes notify-header-exit{from{opacity:1;filter:blur(0px)}to{opacity:0;filter:blur(6px)}}[data-notify-viewport]{position:fixed;z-index:50;display:flex;gap:.75rem;padding:.75rem;pointer-events:none;max-width:calc(100vw - 1.5rem);contain:layout style}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){margin-bottom:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){margin-top:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=top]{top:0;flex-direction:column-reverse}[data-notify-viewport][data-position^=bottom]{bottom:0;flex-direction:column}[data-notify-viewport][data-position$=left]{left:0;align-items:flex-start}[data-notify-viewport][data-position$=right]{right:0;align-items:flex-end}[data-notify-viewport][data-position$=center]{left:50%;transform:translateX(-50%);align-items:center}@media (prefers-reduced-motion:no-preference){[data-notify-toast][data-ready=true]:hover,[data-notify-toast][data-ready=true][data-exiting=true]{will-change:transform,opacity,height}}@media (prefers-reduced-motion:reduce){[data-notify-viewport],[data-notify-viewport] *,[data-notify-viewport] ::after,[data-notify-viewport] ::before{animation-duration:0s;animation-iteration-count:1;transition-duration:0s}}[data-notify-viewport][data-theme=dark] [data-notify-description]{color:rgba(0,0,0,.5)}[data-notify-viewport][data-theme=light] [data-notify-description]{color:rgba(255,255,255,.5)}");
|
|
16
|
+
__insertCSS(":root{--notify-spring-easing:linear(\n\t\t0,\n\t\t0.002 0.6%,\n\t\t0.007 1.2%,\n\t\t0.015 1.8%,\n\t\t0.026 2.4%,\n\t\t0.041 3.1%,\n\t\t0.06 3.8%,\n\t\t0.108 5.3%,\n\t\t0.157 6.6%,\n\t\t0.214 8%,\n\t\t0.467 13.7%,\n\t\t0.577 16.3%,\n\t\t0.631 17.7%,\n\t\t0.682 19.1%,\n\t\t0.73 20.5%,\n\t\t0.771 21.8%,\n\t\t0.808 23.1%,\n\t\t0.844 24.5%,\n\t\t0.874 25.8%,\n\t\t0.903 27.2%,\n\t\t0.928 28.6%,\n\t\t0.952 30.1%,\n\t\t0.972 31.6%,\n\t\t0.988 33.1%,\n\t\t1.01 35.7%,\n\t\t1.025 38.5%,\n\t\t1.034 41.6%,\n\t\t1.038 45%,\n\t\t1.035 50.1%,\n\t\t1.012 64.2%,\n\t\t1.003 73%,\n\t\t0.999 83.7%,\n\t\t1\n\t);--notify-duration:600ms;--notify-height:40px;--notify-width:350px;--notify-state-success:oklch(0.723 0.219 142.136);--notify-state-loading:oklch(0.556 0 0);--notify-state-error:oklch(0.637 0.237 25.331);--notify-state-warning:oklch(0.795 0.184 86.047);--notify-state-info:oklch(0.685 0.169 237.323);--notify-state-action:oklch(0.623 0.214 259.815)}[data-notify-toast]{position:relative;cursor:pointer;pointer-events:auto;touch-action:none;border:0;background:0 0;padding:0;width:var(--notify-width);height:var(--_h,var(--notify-height));opacity:0;transform:translateZ(0) scale(.95);transform-origin:center;contain:layout style;overflow:visible}[data-notify-toast][data-state=loading]{cursor:default}[data-notify-toast][data-ready=true]{opacity:1;transform:translateZ(0) scale(1);transition:transform calc(var(--notify-duration) * .66) var(--notify-spring-easing),opacity calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-bottom calc(var(--notify-duration) * .66) var(--notify-spring-easing),margin-top calc(var(--notify-duration) * .66) var(--notify-spring-easing),height var(--notify-duration) var(--notify-spring-easing)}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){transform:translateY(6px) scale(.95)}[data-notify-toast][data-ready=true][data-exiting=true]{opacity:0;pointer-events:none}[data-notify-viewport][data-position^=top] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(-6px) scale(.95)}[data-notify-viewport][data-position^=bottom] [data-notify-toast][data-ready=true][data-exiting=true]{transform:translateY(6px) scale(.95)}[data-notify-canvas]{position:absolute;left:0;right:0;pointer-events:none;transform:translateZ(0);contain:layout style;overflow:visible}[data-sileo-canvas][data-edge=top]{bottom:0;transform:scaleY(-1) translateZ(0)}[data-sileo-canvas][data-edge=bottom]{top:0}[data-notify-svg]{overflow:visible}[data-notify-header]{position:absolute;z-index:20;display:flex;align-items:center;padding:.5rem;height:var(--sileo-height);overflow:hidden;left:var(--_px,0);transform:var(--_ht);max-width:var(--_pw)}[data-notify-toast][data-ready=true] [data-notify-header]{transition:transform var(--sileo-duration) var(--sileo-spring-easing),left var(--sileo-duration) var(--sileo-spring-easing),max-width var(--sileo-duration) var(--sileo-spring-easing)}[data-notify-header][data-edge=top]{bottom:0}[data-notify-header][data-edge=bottom]{top:0}[data-notify-header-stack]{position:relative;display:inline-flex;align-items:center;height:100%}[data-notify-header-inner]{display:flex;align-items:center;gap:.5rem;white-space:nowrap;opacity:1;filter:blur(0px);transform:translateZ(0)}[data-notify-header-inner][data-layer=current]{position:relative;z-index:1;animation:sileo-header-enter var(--sileo-duration) var(--sileo-spring-easing) both}[data-notify-header-inner][data-exiting=true],[data-notify-header-inner][data-layer=current]:not(:only-child){will-change:opacity,filter}[data-notify-header-inner][data-layer=prev]{position:absolute;left:0;top:0;z-index:0;pointer-events:none}[data-notify-header-inner][data-exiting=true]{animation:notify-header-exit calc(var(--notify-duration) * .7) ease forwards}[data-notify-badge]{display:flex;height:24px;width:24px;flex-shrink:0;align-items:center;justify-content:center;padding:2px;box-sizing:border-box;border-radius:9999px;color:var(--sileo-tone,currentColor);background-color:var(--sileo-tone-bg,transparent)}[data-notify-title]{font-size:.825rem;line-height:1rem;font-weight:500;text-transform:capitalize;color:var(--sileo-tone,currentColor)}:is([data-notify-badge],[data-notify-title],[data-notify-button])[data-state]{--_c:var(--notify-state-success)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=loading]{--_c:var(--notify-state-loading)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=error]{--_c:var(--notify-state-error)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=warning]{--_c:var(--notify-state-warning)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=info]{--_c:var(--notify-state-info)}:is(\n[data-notify-badge],[data-notify-title],[data-notify-button]\n)[data-state=action]{--_c:var(--notify-state-action)}:is([data-notify-badge],[data-notify-title])[data-state]{--notify-tone:var(--_c);--notify-tone-bg:color-mix(in oklch, var(--_c) 20%, transparent)}[data-notify-content]{position:absolute;left:0;z-index:10;width:100%;pointer-events:none;opacity:var(--_co, 0)}[data-notify-content]:not([data-visible=true]){content-visibility:hidden}[data-notify-toast][data-ready=true] [data-notify-content]{transition:opacity calc(var(--notify-duration) * .08) ease calc(var(--notify-duration) * .04)}[data-notify-content][data-edge=top]{top:0}[data-notify-content][data-edge=bottom]{top:var(--sileo-height)}[data-notify-content][data-visible=true]{pointer-events:auto}[data-notify-toast][data-ready=true] [data-notify-content][data-visible=true]{transition:opacity calc(var(--notify-duration) * .6) ease calc(var(--notify-duration) * .3)}[data-notify-description]{width:100%;text-align:left;padding:1rem;font-size:.875rem;line-height:1.25rem;contain:layout style paint;content-visibility:auto}[data-notify-button]{display:flex;align-items:center;justify-content:center;height:1.75rem;padding:0 .625rem;margin-top:.75rem;border-radius:9999px;border:0;font-size:.75rem;font-weight:500;cursor:pointer;color:var(--sileo-btn-color,currentColor);background-color:var(--sileo-btn-bg,transparent);transition:background-color 150ms ease}[data-notify-button]:hover{background-color:var(--sileo-btn-bg-hover,transparent)}[data-notify-button][data-state]{--notify-btn-color:var(--_c);--notify-btn-bg:color-mix(in oklch, var(--_c) 15%, transparent);--notify-btn-bg-hover:color-mix(in oklch, var(--_c) 25%, transparent)}[data-notify-icon=spin]{animation:notify-spin 1s linear infinite}@keyframes notify-spin{to{transform:rotate(360deg)}}@keyframes notify-header-enter{from{opacity:0;filter:blur(6px)}to{opacity:1;filter:blur(0px)}}@keyframes notify-header-exit{from{opacity:1;filter:blur(0px)}to{opacity:0;filter:blur(6px)}}[data-notify-viewport]{position:fixed;z-index:50;display:flex;gap:.75rem;padding:.75rem;pointer-events:none;max-width:calc(100vw - 1.5rem);contain:layout style}[data-notify-viewport][data-position^=top] [data-notify-toast]:not([data-ready=true]){margin-bottom:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=bottom] [data-notify-toast]:not([data-ready=true]){margin-top:calc(-1 * (var(--notify-height) + .75rem))}[data-notify-viewport][data-position^=top]{top:0;flex-direction:column-reverse}[data-notify-viewport][data-position^=bottom]{bottom:0;flex-direction:column}[data-notify-viewport][data-position$=left]{left:0;align-items:flex-start}[data-notify-viewport][data-position$=right]{right:0;align-items:flex-end}[data-notify-viewport][data-position$=center]{left:50%;transform:translateX(-50%);align-items:center}@media (prefers-reduced-motion:no-preference){[data-notify-toast][data-ready=true]:hover,[data-notify-toast][data-ready=true][data-exiting=true]{will-change:transform,opacity,height}}@media (prefers-reduced-motion:reduce){[data-notify-viewport],[data-notify-viewport] *,[data-notify-viewport] ::after,[data-notify-viewport] ::before{animation-duration:0s;animation-iteration-count:1;transition-duration:0s}}[data-notify-viewport][data-theme=dark] [data-notify-description]{color:rgba(0,0,0,.5)}[data-notify-viewport][data-theme=light] [data-notify-description]{color:rgba(255,255,255,.5)}[data-notify-toast]:has([data-notify-card]){width:auto;height:auto;background:0 0}[data-notify-card]{background:#fff;border-radius:20px;box-shadow:0 4px 24px rgba(0,0,0,.1),0 1px 4px rgba(0,0,0,.06);width:var(--notify-width);overflow:hidden}[data-notify-card] [data-notify-header]{position:relative;display:flex;align-items:center;gap:.5rem;padding:.5rem .75rem;height:auto;left:auto;max-width:none;transform:none;overflow:visible}[data-notify-card] [data-notify-content]{position:relative;opacity:1;pointer-events:auto;content-visibility:visible;border-top:1px solid rgba(0,0,0,.06)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state]{color:var(--notify-state-success)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=error]{color:var(--notify-state-error)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=warning]{color:var(--notify-state-warning)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=info]{color:var(--notify-state-info)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=loading]{color:var(--notify-state-loading)}[data-notify-card] :is([data-notify-badge],[data-notify-title])[data-state=action]{color:var(--notify-state-action)}[data-notify-card] [data-notify-description]{color:rgba(0,0,0,.6)}");
|
|
17
17
|
|
|
18
18
|
/* --------------------------------- Layout --------------------------------- */ const HEIGHT = 40;
|
|
19
19
|
const WIDTH = 350;
|
|
@@ -1063,4 +1063,182 @@ function Toaster({ children, position = "top-right", offset, options, theme }) {
|
|
|
1063
1063
|
});
|
|
1064
1064
|
}
|
|
1065
1065
|
|
|
1066
|
-
|
|
1066
|
+
// Notify logic (no React dependencies)
|
|
1067
|
+
// Provides toast management and utilities for VanillaJS, Vue, Svelte, etc.
|
|
1068
|
+
class NotifyCore {
|
|
1069
|
+
generateId() {
|
|
1070
|
+
return `${++this.idCounter}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1071
|
+
}
|
|
1072
|
+
subscribe(fn) {
|
|
1073
|
+
this.listeners.add(fn);
|
|
1074
|
+
fn(this.toasts);
|
|
1075
|
+
return ()=>this.listeners.delete(fn);
|
|
1076
|
+
}
|
|
1077
|
+
emit() {
|
|
1078
|
+
for (const fn of this.listeners)fn(this.toasts);
|
|
1079
|
+
}
|
|
1080
|
+
update(fn) {
|
|
1081
|
+
this.toasts = fn(this.toasts);
|
|
1082
|
+
this.emit();
|
|
1083
|
+
}
|
|
1084
|
+
dismiss(id) {
|
|
1085
|
+
const item = this.toasts.find((t)=>t.id === id);
|
|
1086
|
+
if (!item || item.exiting) return;
|
|
1087
|
+
this.update((prev)=>prev.map((t)=>t.id === id ? _extends({}, t, {
|
|
1088
|
+
exiting: true
|
|
1089
|
+
}) : t));
|
|
1090
|
+
setTimeout(()=>this.update((prev)=>prev.filter((t)=>t.id !== id)), 600);
|
|
1091
|
+
}
|
|
1092
|
+
show(opts) {
|
|
1093
|
+
var _ref, _ref1, _opts_type;
|
|
1094
|
+
// Use a unique identifier based on options (e.g., the title or a generated key)
|
|
1095
|
+
// If not provided, use a default one
|
|
1096
|
+
const id = opts.title ? `notify-${opts.title}` : "notify-default";
|
|
1097
|
+
const prevItem = this.toasts.find((t)=>t.id === id);
|
|
1098
|
+
const instanceId = (_ref = prevItem == null ? void 0 : prevItem.instanceId) != null ? _ref : this.generateId();
|
|
1099
|
+
// Set the state correctly
|
|
1100
|
+
const state = (_ref1 = (_opts_type = opts.type) != null ? _opts_type : prevItem == null ? void 0 : prevItem.type) != null ? _ref1 : "success";
|
|
1101
|
+
const item = _extends({}, prevItem, opts, {
|
|
1102
|
+
id,
|
|
1103
|
+
instanceId,
|
|
1104
|
+
type: state
|
|
1105
|
+
});
|
|
1106
|
+
this.update((prev)=>{
|
|
1107
|
+
const filtered = prev.filter((t)=>t.id !== id);
|
|
1108
|
+
return [
|
|
1109
|
+
...filtered,
|
|
1110
|
+
item
|
|
1111
|
+
];
|
|
1112
|
+
});
|
|
1113
|
+
return id;
|
|
1114
|
+
}
|
|
1115
|
+
getToasts() {
|
|
1116
|
+
return this.toasts;
|
|
1117
|
+
}
|
|
1118
|
+
constructor(){
|
|
1119
|
+
this.toasts = [];
|
|
1120
|
+
this.listeners = new Set();
|
|
1121
|
+
this.position = "top-right";
|
|
1122
|
+
this.options = undefined;
|
|
1123
|
+
this.idCounter = 0;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
// Global instance for multiplatform usage
|
|
1127
|
+
const notifyCore = new NotifyCore();
|
|
1128
|
+
|
|
1129
|
+
const ICONS = {
|
|
1130
|
+
success: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>',
|
|
1131
|
+
error: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>',
|
|
1132
|
+
warning: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg>',
|
|
1133
|
+
info: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="m4.93 4.93 4.24 4.24"/><path d="m14.83 9.17 4.24-4.24"/><path d="m14.83 14.83 4.24 4.24"/><path d="m9.17 14.83-4.24 4.24"/><circle cx="12" cy="12" r="4"/></svg>',
|
|
1134
|
+
loading: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" data-notify-icon="spin" aria-hidden="true"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',
|
|
1135
|
+
action: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="m12 5 7 7-7 7"/></svg>'
|
|
1136
|
+
};
|
|
1137
|
+
const EXIT_MS = 600;
|
|
1138
|
+
function capitalize(s) {
|
|
1139
|
+
return s ? s.charAt(0).toUpperCase() + s.slice(1) : "";
|
|
1140
|
+
}
|
|
1141
|
+
let viewport = null;
|
|
1142
|
+
const toastEls = new Map();
|
|
1143
|
+
function getOrCreateViewport(position) {
|
|
1144
|
+
if (!viewport) {
|
|
1145
|
+
viewport = document.createElement("div");
|
|
1146
|
+
viewport.setAttribute("data-notify-viewport", "");
|
|
1147
|
+
viewport.setAttribute("data-position", position);
|
|
1148
|
+
viewport.setAttribute("data-theme", "light");
|
|
1149
|
+
document.body.appendChild(viewport);
|
|
1150
|
+
}
|
|
1151
|
+
return viewport;
|
|
1152
|
+
}
|
|
1153
|
+
function buildToastEl(toast) {
|
|
1154
|
+
const state = toast.type || "success";
|
|
1155
|
+
const btn = document.createElement("button");
|
|
1156
|
+
btn.type = "button";
|
|
1157
|
+
btn.setAttribute("data-notify-toast", "");
|
|
1158
|
+
btn.setAttribute("data-state", state);
|
|
1159
|
+
btn.setAttribute("data-ready", "false");
|
|
1160
|
+
btn.setAttribute("data-exiting", "false");
|
|
1161
|
+
const card = document.createElement("div");
|
|
1162
|
+
card.setAttribute("data-notify-card", "");
|
|
1163
|
+
const header = document.createElement("div");
|
|
1164
|
+
header.setAttribute("data-notify-header", "");
|
|
1165
|
+
const badge = document.createElement("div");
|
|
1166
|
+
badge.setAttribute("data-notify-badge", "");
|
|
1167
|
+
badge.setAttribute("data-state", state);
|
|
1168
|
+
badge.innerHTML = ICONS[state] || ICONS.success;
|
|
1169
|
+
const titleEl = document.createElement("span");
|
|
1170
|
+
titleEl.setAttribute("data-notify-title", "");
|
|
1171
|
+
titleEl.setAttribute("data-state", state);
|
|
1172
|
+
titleEl.textContent = toast.title || capitalize(state);
|
|
1173
|
+
header.appendChild(badge);
|
|
1174
|
+
header.appendChild(titleEl);
|
|
1175
|
+
card.appendChild(header);
|
|
1176
|
+
if (toast.description || toast.button) {
|
|
1177
|
+
const content = document.createElement("div");
|
|
1178
|
+
content.setAttribute("data-notify-content", "");
|
|
1179
|
+
content.setAttribute("data-visible", "true");
|
|
1180
|
+
if (toast.description) {
|
|
1181
|
+
const desc = document.createElement("div");
|
|
1182
|
+
desc.setAttribute("data-notify-description", "");
|
|
1183
|
+
desc.textContent = toast.description;
|
|
1184
|
+
content.appendChild(desc);
|
|
1185
|
+
}
|
|
1186
|
+
if (toast.button) {
|
|
1187
|
+
const actionBtn = document.createElement("button");
|
|
1188
|
+
actionBtn.setAttribute("data-notify-button", "");
|
|
1189
|
+
actionBtn.setAttribute("data-state", state);
|
|
1190
|
+
actionBtn.textContent = toast.button.title;
|
|
1191
|
+
actionBtn.addEventListener("click", (e)=>{
|
|
1192
|
+
var _toast_button;
|
|
1193
|
+
e.stopPropagation();
|
|
1194
|
+
(_toast_button = toast.button) == null ? void 0 : _toast_button.onClick();
|
|
1195
|
+
notifyCore.dismiss(toast.id);
|
|
1196
|
+
});
|
|
1197
|
+
content.appendChild(actionBtn);
|
|
1198
|
+
}
|
|
1199
|
+
card.appendChild(content);
|
|
1200
|
+
}
|
|
1201
|
+
btn.appendChild(card);
|
|
1202
|
+
btn.addEventListener("click", ()=>notifyCore.dismiss(toast.id));
|
|
1203
|
+
requestAnimationFrame(()=>{
|
|
1204
|
+
requestAnimationFrame(()=>{
|
|
1205
|
+
btn.setAttribute("data-ready", "true");
|
|
1206
|
+
});
|
|
1207
|
+
});
|
|
1208
|
+
return btn;
|
|
1209
|
+
}
|
|
1210
|
+
function updateToastEl(el, toast) {
|
|
1211
|
+
const state = toast.type || "success";
|
|
1212
|
+
el.setAttribute("data-state", state);
|
|
1213
|
+
if (toast.exiting) {
|
|
1214
|
+
el.setAttribute("data-exiting", "true");
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
function renderNotifyToasts(options = {}) {
|
|
1218
|
+
var _options_position;
|
|
1219
|
+
const position = (_options_position = options.position) != null ? _options_position : "top-right";
|
|
1220
|
+
const vp = getOrCreateViewport(position);
|
|
1221
|
+
return notifyCore.subscribe((toasts)=>{
|
|
1222
|
+
const liveIds = new Set(toasts.map((t)=>t.id));
|
|
1223
|
+
for (const [id, el] of toastEls){
|
|
1224
|
+
if (!liveIds.has(id)) {
|
|
1225
|
+
el.setAttribute("data-exiting", "true");
|
|
1226
|
+
setTimeout(()=>{
|
|
1227
|
+
el.remove();
|
|
1228
|
+
toastEls.delete(id);
|
|
1229
|
+
}, EXIT_MS);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
for (const toast of toasts){
|
|
1233
|
+
if (toastEls.has(toast.id)) {
|
|
1234
|
+
updateToastEl(toastEls.get(toast.id), toast);
|
|
1235
|
+
} else {
|
|
1236
|
+
const el = buildToastEl(toast);
|
|
1237
|
+
toastEls.set(toast.id, el);
|
|
1238
|
+
vp.appendChild(el);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
export { Toaster as T, notify as n, renderNotifyToasts as r, showNotifyToast as s };
|