@rozie-ui/toast-lit 0.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/LICENSE +21 -0
- package/README.md +80 -0
- package/dist/index.cjs +598 -0
- package/dist/index.d.cts +112 -0
- package/dist/index.d.mts +112 -0
- package/dist/index.mjs +593 -0
- package/package.json +73 -0
- package/src/Toaster.ts +662 -0
- package/src/index.ts +2 -0
- package/src/themes/base.css +57 -0
- package/src/themes/bootstrap.css +27 -0
- package/src/themes/material.css +28 -0
- package/src/themes/shadcn.css +29 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as _$lit from "lit";
|
|
2
|
+
import { LitElement } from "lit";
|
|
3
|
+
|
|
4
|
+
//#region src/Toaster.d.ts
|
|
5
|
+
declare const Toaster_base: typeof LitElement;
|
|
6
|
+
declare class Toaster extends Toaster_base {
|
|
7
|
+
static styles: _$lit.CSSResult;
|
|
8
|
+
/**
|
|
9
|
+
* Which corner the toast stack renders in: `'top-left'`, `'top-right'`, `'top-center'`, `'bottom-left'`, `'bottom-right'`, or `'bottom-center'`. Drives the fixed-position layout and the stack direction.
|
|
10
|
+
*/
|
|
11
|
+
position: string;
|
|
12
|
+
/**
|
|
13
|
+
* Default auto-dismiss time in milliseconds, applied to any toast that does not pass its own `duration`. `0` (or a per-toast `duration` of `0`) makes the toast sticky — it stays until explicitly dismissed.
|
|
14
|
+
*/
|
|
15
|
+
duration: number;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of visible toasts (`0` = unlimited). When the queue exceeds this, the oldest toasts drop off the stack.
|
|
18
|
+
*/
|
|
19
|
+
max: number;
|
|
20
|
+
/**
|
|
21
|
+
* Opt **out** of pausing the auto-dismiss timers while the pointer is over the stack. By default hovering pauses every timer and leaving restarts them; set this to keep toasts dismissing on schedule regardless of hover.
|
|
22
|
+
*/
|
|
23
|
+
disablePauseOnHover: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Accessible name for the live region (`role="region"`), applied as its `aria-label`. Defaults to `'Notifications'` when not set, so assistive tech can navigate to the toast stack as a landmark.
|
|
26
|
+
*/
|
|
27
|
+
ariaLabel: string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Opt **out** of pointer swipe-to-dismiss. By default, dragging a toast past 45% of its own width/height (direction auto-derived from `position`) or a fast flick dismisses it with reason `'swipe'`; a short drag springs back. A drag starting on the close button (or any button/link) never swipes.
|
|
30
|
+
*/
|
|
31
|
+
disableSwipe: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Opt **in** to a sonner-style collapsed stack: a single-cell grid overlay with depth-driven transforms (toasts at depth 3+ fade to invisible), newest on top. Hovering the region or moving keyboard focus into it expands to the normal flex-column stack; leaving re-collapses. `false` (default) renders the plain flex column at all times.
|
|
34
|
+
*/
|
|
35
|
+
stacked: boolean;
|
|
36
|
+
private _toasts;
|
|
37
|
+
private _seq;
|
|
38
|
+
private _swipe;
|
|
39
|
+
private _swipeGesture;
|
|
40
|
+
private _hasSlotToast;
|
|
41
|
+
private _slotToastElements;
|
|
42
|
+
toast?: (scope: {
|
|
43
|
+
toast: unknown;
|
|
44
|
+
dismiss: unknown;
|
|
45
|
+
}) => unknown;
|
|
46
|
+
private _disconnectCleanups;
|
|
47
|
+
private _rozieTornDown;
|
|
48
|
+
private _armListeners;
|
|
49
|
+
connectedCallback(): void;
|
|
50
|
+
firstUpdated(): void;
|
|
51
|
+
disconnectedCallback(): void;
|
|
52
|
+
render(): _$lit.TemplateResult<1>;
|
|
53
|
+
timers: {};
|
|
54
|
+
exitFailsafes: {};
|
|
55
|
+
unmounted: boolean;
|
|
56
|
+
seqLocal: number;
|
|
57
|
+
paused: boolean;
|
|
58
|
+
startTimer: (toast: any) => void;
|
|
59
|
+
clearTimer: (id: any) => void;
|
|
60
|
+
pauseTimers: () => void;
|
|
61
|
+
resumeTimers: () => void;
|
|
62
|
+
teardownTimers: () => void;
|
|
63
|
+
show: (input: any) => any;
|
|
64
|
+
EXIT_FAILSAFE_MS: number;
|
|
65
|
+
removeToast: (id: any) => void;
|
|
66
|
+
dismissBegin: (id: any, reason: any, extra?: {
|
|
67
|
+
swipeExitSign?: number;
|
|
68
|
+
}) => void;
|
|
69
|
+
dismiss: (id: any) => void;
|
|
70
|
+
clear: () => void;
|
|
71
|
+
patch: (id: any, changes: any) => boolean;
|
|
72
|
+
settlePromise: (id: any, type: any, messageOrFn: any, value: any) => void;
|
|
73
|
+
promise: (p: any, opts: any) => any;
|
|
74
|
+
swipeAxisFor: (position: any) => "x" | "y";
|
|
75
|
+
swipeSignFor: (position: any) => 1 | -1;
|
|
76
|
+
onToastPointerDown: (t: any, event: any) => void;
|
|
77
|
+
onToastPointerMove: (t: any, event: any) => void;
|
|
78
|
+
onToastPointerUp: (t: any, event: any) => void;
|
|
79
|
+
onToastPointerCancel: (t: any) => void;
|
|
80
|
+
depth: (t: any) => number;
|
|
81
|
+
toastStyle: (t: any) => string;
|
|
82
|
+
onMouseEnter: () => void;
|
|
83
|
+
onMouseLeave: () => void;
|
|
84
|
+
regionLabel: () => string;
|
|
85
|
+
liveFor: (type: any) => "assertive" | "polite";
|
|
86
|
+
/**
|
|
87
|
+
* Plan 14-05 — cross-framework attribute fallthrough source. Reads the
|
|
88
|
+
* host custom element's attributes on each call so a consumer-side bound
|
|
89
|
+
* attribute flows through on every render. The `rozieSpread` directive
|
|
90
|
+
* (D-02) does the cross-render diff downstream.
|
|
91
|
+
*
|
|
92
|
+
* Phase 15 follow-up Bug A — declared-prop attribute names are filtered
|
|
93
|
+
* out so `$attrs` returns "rest after declared props" (semantic parity
|
|
94
|
+
* with React/Vue/Svelte/Solid/Angular). Both Lit attribute-naming
|
|
95
|
+
* forms are folded into the skip set: kebab-case for model props
|
|
96
|
+
* (explicit `attribute:`) AND lowercased property name (Lit's default).
|
|
97
|
+
*/
|
|
98
|
+
private get $attrs();
|
|
99
|
+
/**
|
|
100
|
+
* Phase 15 D-19 — consumer-passed listener cluster placeholder.
|
|
101
|
+
* Lit attaches event listeners directly on the host element via
|
|
102
|
+
* `addEventListener` (no per-instance prop rest binding), so the
|
|
103
|
+
* runtime value is undefined; the `rozieListeners` directive's
|
|
104
|
+
* nullish coercion (`obj ?? {}`) handles the no-op cleanly.
|
|
105
|
+
* The declaration exists to satisfy `tsc --noEmit` on consumer
|
|
106
|
+
* projects with strict mode — bare `$listeners` in `render()`
|
|
107
|
+
* would otherwise raise TS2304 (Cannot find name).
|
|
108
|
+
*/
|
|
109
|
+
private get $listeners();
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { Toaster, Toaster as default };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as _$lit from "lit";
|
|
2
|
+
import { LitElement } from "lit";
|
|
3
|
+
|
|
4
|
+
//#region src/Toaster.d.ts
|
|
5
|
+
declare const Toaster_base: typeof LitElement;
|
|
6
|
+
declare class Toaster extends Toaster_base {
|
|
7
|
+
static styles: _$lit.CSSResult;
|
|
8
|
+
/**
|
|
9
|
+
* Which corner the toast stack renders in: `'top-left'`, `'top-right'`, `'top-center'`, `'bottom-left'`, `'bottom-right'`, or `'bottom-center'`. Drives the fixed-position layout and the stack direction.
|
|
10
|
+
*/
|
|
11
|
+
position: string;
|
|
12
|
+
/**
|
|
13
|
+
* Default auto-dismiss time in milliseconds, applied to any toast that does not pass its own `duration`. `0` (or a per-toast `duration` of `0`) makes the toast sticky — it stays until explicitly dismissed.
|
|
14
|
+
*/
|
|
15
|
+
duration: number;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of visible toasts (`0` = unlimited). When the queue exceeds this, the oldest toasts drop off the stack.
|
|
18
|
+
*/
|
|
19
|
+
max: number;
|
|
20
|
+
/**
|
|
21
|
+
* Opt **out** of pausing the auto-dismiss timers while the pointer is over the stack. By default hovering pauses every timer and leaving restarts them; set this to keep toasts dismissing on schedule regardless of hover.
|
|
22
|
+
*/
|
|
23
|
+
disablePauseOnHover: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Accessible name for the live region (`role="region"`), applied as its `aria-label`. Defaults to `'Notifications'` when not set, so assistive tech can navigate to the toast stack as a landmark.
|
|
26
|
+
*/
|
|
27
|
+
ariaLabel: string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Opt **out** of pointer swipe-to-dismiss. By default, dragging a toast past 45% of its own width/height (direction auto-derived from `position`) or a fast flick dismisses it with reason `'swipe'`; a short drag springs back. A drag starting on the close button (or any button/link) never swipes.
|
|
30
|
+
*/
|
|
31
|
+
disableSwipe: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Opt **in** to a sonner-style collapsed stack: a single-cell grid overlay with depth-driven transforms (toasts at depth 3+ fade to invisible), newest on top. Hovering the region or moving keyboard focus into it expands to the normal flex-column stack; leaving re-collapses. `false` (default) renders the plain flex column at all times.
|
|
34
|
+
*/
|
|
35
|
+
stacked: boolean;
|
|
36
|
+
private _toasts;
|
|
37
|
+
private _seq;
|
|
38
|
+
private _swipe;
|
|
39
|
+
private _swipeGesture;
|
|
40
|
+
private _hasSlotToast;
|
|
41
|
+
private _slotToastElements;
|
|
42
|
+
toast?: (scope: {
|
|
43
|
+
toast: unknown;
|
|
44
|
+
dismiss: unknown;
|
|
45
|
+
}) => unknown;
|
|
46
|
+
private _disconnectCleanups;
|
|
47
|
+
private _rozieTornDown;
|
|
48
|
+
private _armListeners;
|
|
49
|
+
connectedCallback(): void;
|
|
50
|
+
firstUpdated(): void;
|
|
51
|
+
disconnectedCallback(): void;
|
|
52
|
+
render(): _$lit.TemplateResult<1>;
|
|
53
|
+
timers: {};
|
|
54
|
+
exitFailsafes: {};
|
|
55
|
+
unmounted: boolean;
|
|
56
|
+
seqLocal: number;
|
|
57
|
+
paused: boolean;
|
|
58
|
+
startTimer: (toast: any) => void;
|
|
59
|
+
clearTimer: (id: any) => void;
|
|
60
|
+
pauseTimers: () => void;
|
|
61
|
+
resumeTimers: () => void;
|
|
62
|
+
teardownTimers: () => void;
|
|
63
|
+
show: (input: any) => any;
|
|
64
|
+
EXIT_FAILSAFE_MS: number;
|
|
65
|
+
removeToast: (id: any) => void;
|
|
66
|
+
dismissBegin: (id: any, reason: any, extra?: {
|
|
67
|
+
swipeExitSign?: number;
|
|
68
|
+
}) => void;
|
|
69
|
+
dismiss: (id: any) => void;
|
|
70
|
+
clear: () => void;
|
|
71
|
+
patch: (id: any, changes: any) => boolean;
|
|
72
|
+
settlePromise: (id: any, type: any, messageOrFn: any, value: any) => void;
|
|
73
|
+
promise: (p: any, opts: any) => any;
|
|
74
|
+
swipeAxisFor: (position: any) => "x" | "y";
|
|
75
|
+
swipeSignFor: (position: any) => 1 | -1;
|
|
76
|
+
onToastPointerDown: (t: any, event: any) => void;
|
|
77
|
+
onToastPointerMove: (t: any, event: any) => void;
|
|
78
|
+
onToastPointerUp: (t: any, event: any) => void;
|
|
79
|
+
onToastPointerCancel: (t: any) => void;
|
|
80
|
+
depth: (t: any) => number;
|
|
81
|
+
toastStyle: (t: any) => string;
|
|
82
|
+
onMouseEnter: () => void;
|
|
83
|
+
onMouseLeave: () => void;
|
|
84
|
+
regionLabel: () => string;
|
|
85
|
+
liveFor: (type: any) => "assertive" | "polite";
|
|
86
|
+
/**
|
|
87
|
+
* Plan 14-05 — cross-framework attribute fallthrough source. Reads the
|
|
88
|
+
* host custom element's attributes on each call so a consumer-side bound
|
|
89
|
+
* attribute flows through on every render. The `rozieSpread` directive
|
|
90
|
+
* (D-02) does the cross-render diff downstream.
|
|
91
|
+
*
|
|
92
|
+
* Phase 15 follow-up Bug A — declared-prop attribute names are filtered
|
|
93
|
+
* out so `$attrs` returns "rest after declared props" (semantic parity
|
|
94
|
+
* with React/Vue/Svelte/Solid/Angular). Both Lit attribute-naming
|
|
95
|
+
* forms are folded into the skip set: kebab-case for model props
|
|
96
|
+
* (explicit `attribute:`) AND lowercased property name (Lit's default).
|
|
97
|
+
*/
|
|
98
|
+
private get $attrs();
|
|
99
|
+
/**
|
|
100
|
+
* Phase 15 D-19 — consumer-passed listener cluster placeholder.
|
|
101
|
+
* Lit attaches event listeners directly on the host element via
|
|
102
|
+
* `addEventListener` (no per-instance prop rest binding), so the
|
|
103
|
+
* runtime value is undefined; the `rozieListeners` directive's
|
|
104
|
+
* nullish coercion (`obj ?? {}`) handles the no-op cleanly.
|
|
105
|
+
* The declaration exists to satisfy `tsc --noEmit` on consumer
|
|
106
|
+
* projects with strict mode — bare `$listeners` in `render()`
|
|
107
|
+
* would otherwise raise TS2304 (Cannot find name).
|
|
108
|
+
*/
|
|
109
|
+
private get $listeners();
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { Toaster, Toaster as default };
|