@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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 One Learning Community LTD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @rozie-ui/toast-lit
2
+
3
+ Idiomatic **lit** `Toaster` — a headless, accessible toast / notification host (a live-region queue with per-toast auto-dismiss timers, hover-to-pause, six corner positions, and a per-toast close button) compiled from one [Rozie](https://github.com/One-Learning-Community/rozie.js) source. It is **not** a global singleton + context system: the host owns the queue + timers as internal state and exposes an imperative `show` / `dismiss` / `clear` handle you drive via `ref` — "call from anywhere" is your app's wiring concern (stash the ref). Every visual value is a CSS custom property, so it re-skins to any design system. This package is generated; do not edit `src/` by hand.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i @rozie-ui/toast-lit
9
+ ```
10
+
11
+ Peer dependencies: `lit + @lit-labs/preact-signals + @preact/signals-core`. Install them alongside this package.
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import '@rozie-ui/toast-lit';
17
+
18
+ // <rozie-toaster> is a custom element. Bind `position`/`duration` as properties,
19
+ // then call the imperative `show` / `dismiss` / `clear` methods on the element.
20
+ const el = document.querySelector('rozie-toaster');
21
+ el.position = 'bottom-right';
22
+ el.duration = 4000;
23
+ const id = el.show({ message: 'Saved!', type: 'success' });
24
+ // el.dismiss(id);
25
+ // el.clear();
26
+ ```
27
+
28
+ ## Theming
29
+
30
+ Every visual value is a `--rozie-toast-*` CSS custom property — override any of them at any ancestor scope. Ready-made design-system bridges ship in the package:
31
+
32
+ ```ts
33
+ import '@rozie-ui/toast-lit/themes/shadcn.css'; // or material.css, bootstrap.css, base.css
34
+ ```
35
+
36
+ ## Props
37
+
38
+ | Name | Type | Default | Two-way (model) | Required |
39
+ | --- | --- | --- | :---: | :---: |
40
+ | `position` | `String` | `"bottom-right"` | | |
41
+ | `duration` | `Number` | `4000` | | |
42
+ | `max` | `Number` | `0` | | |
43
+ | `disablePauseOnHover` | `Boolean` | `false` | | |
44
+ | `ariaLabel` | `String` | `null` | | |
45
+ | `disableSwipe` | `Boolean` | `false` | | |
46
+ | `stacked` | `Boolean` | `false` | | |
47
+
48
+ ## Events
49
+
50
+ | Event | Description |
51
+ | --- | --- |
52
+ | `dismissed` | Fired exactly once per toast, at dismissal initiation (before the exit animation runs). Payload is ONE object `{ toast, reason }` — `toast` is the full queue entry, `reason` is `'timeout'` (auto-dismiss), `'swipe'` (pointer swipe past threshold), `'close'` (the built-in close button), or `'api'` (the `dismiss(id)` verb). `clear()` removes every toast immediately and does NOT fire `dismissed` (documented bulk behavior). |
53
+
54
+ ## Imperative handle
55
+
56
+ The component has no events — its primary API is an imperative handle (declared once in the Rozie source via `$expose`). Grab a handle with the native ref mechanism and call the methods directly. None of the verbs overrides an inherited host-element member, so the Lit custom element emits no ROZ137 warning:
57
+
58
+ | Method | Description |
59
+ | --- | --- |
60
+ | `show` | Enqueue a toast. Accepts `{ message, type, duration, id }` (all optional — `message` defaults to `''`, `type` to `'info'`, `duration` to the `duration` prop). Returns the toast `id`. A non-sticky toast (duration > 0) auto-dismisses; `duration: 0` makes it sticky. |
61
+ | `dismiss` | Remove a single toast by the `id` returned from `show` (routes through the exit lifecycle with reason `'api'` — fires `dismissed`, plays the exit animation, then removes it). |
62
+ | `clear` | Remove every visible toast at once immediately (no exit animation) and clear all pending auto-dismiss timers. Does NOT fire `dismissed`. |
63
+ | `patch` | Update an existing toast in place. Accepts `(id, { message, type, duration })` — only the keys you pass are merged into the matching entry. Returns `true` if the id existed, `false` otherwise (no throw). Including a `duration` key clears and restarts that toast's auto-dismiss timer (`0` makes it sticky; a positive value arms/re-arms it); omitting `duration` leaves a running timer untouched. |
64
+ | `promise` | Sugar over `show`/`patch` for an async operation: `promise(p, { loading, success, error })` immediately shows a `{ type: 'loading', duration: 0 }` toast and returns its `id` SYNCHRONOUSLY. On resolve it patches the SAME toast to `{ type: 'success', message: resolve(success, value) }` (the auto-dismiss timer starts AT SETTLE); on reject, likewise with `error`. `success`/`error` accept a string or a `(value) => string` function. Never resurrects a toast dismissed while `p` was still pending, and never returns a derived promise — your own `.then`/`.catch` on `p` still fire. |
65
+
66
+ ```ts
67
+ // The custom element IS the handle — the exposed methods are public element
68
+ // methods (none overrides an inherited HTMLElement member, so there is no
69
+ // ROZ137 warning).
70
+ const el = document.querySelector('rozie-toaster');
71
+ const id = el.show({ message: 'Saved', type: 'success' });
72
+ el.dismiss(id);
73
+ el.clear();
74
+ ```
75
+
76
+ ## Slots
77
+
78
+ | Slot | Params |
79
+ | --- | --- |
80
+ | toast | toast, dismiss |