@gjsify/adwaita-web 0.22.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,6 +41,54 @@ Vite preset (or any Vite/bundler setup). Type declarations are shipped
41
41
  pre-built at `lib/types/index.d.ts`, so `gjsify tsc` consumers resolve the
42
42
  package's types without compiling its source.
43
43
 
44
+ ## Shared behaviour (`@gjsify/adwaita-core`)
45
+
46
+ The widget *behaviour* — as opposed to the DOM rendering — comes from
47
+ [`@gjsify/adwaita-core`](../adwaita-core), the headless Adwaita layer defined by
48
+ [ADR 0004](../../../docs/adr/0004-headless-adwaita-core.md). It is pure TypeScript
49
+ with no platform imports, and `@gjsify/adwaita-nativescript` composes the exact
50
+ same state machines, so a behaviour fix lands once and both ports pick it up.
51
+
52
+ | Element | Core state machine | What core owns |
53
+ | --- | --- | --- |
54
+ | `<adw-toast-overlay>` | `AdwToastQueue` + `AdwToast` | one toast at a time, FIFO ordering, auto-dismiss lifecycle |
55
+ | `<adw-combo-row>` | `ComboState` | options list, index↔value mapping, out-of-range guards, programmatic-vs-user split |
56
+ | `<adw-spin-row>` | `SpinState` | value/min/max/step with clamping on every mutation |
57
+ | `<adw-toggle-group>` | `ToggleGroupState` | segment list, guarded active index |
58
+ | `<adw-expander-row>` | `ExpanderState` | expanded/collapsed disclosure |
59
+ | `<adw-alert-dialog>` | `AdwAlertResponses` | response registry, default/close response, resolve-to-chosen-id |
60
+
61
+ Each element keeps only the DOM half: the markup, the CSS classes and the
62
+ `notify::*` / `response` `CustomEvent`s. The public element API is unchanged —
63
+ the composition is an implementation detail.
64
+
65
+ ### Toasts are queued, one at a time
66
+
67
+ `<adw-toast-overlay>` follows `Adw.ToastOverlay`: it shows **exactly one** toast
68
+ and queues the rest FIFO. Each queued toast is shown only after the visible one
69
+ is dismissed — by its timeout, by its close button, by its action button, or by
70
+ `dismiss()`.
71
+
72
+ ```typescript
73
+ const overlay = document.querySelector('adw-toast-overlay');
74
+
75
+ overlay.addToast('File moved to Trash', { timeout: 3, buttonLabel: 'Undo', onAction: undo });
76
+ overlay.addToast('Second file moved'); // waits its turn — not shown yet
77
+
78
+ overlay.currentToast?.title; // 'File moved to Trash'
79
+ overlay.pendingToasts; // 1
80
+
81
+ overlay.dismiss(); // show the next queued toast now
82
+ overlay.clearToasts(); // dismiss the visible one and drop the queue
83
+ ```
84
+
85
+ `addToast()`'s `timeout` is in **seconds** (mirroring `Adw.Toast:timeout`); `0`
86
+ keeps the toast until it is dismissed and holds the queue behind it. The
87
+ auto-dismiss runs on the browser's timers by default; assign
88
+ `overlay.scheduler` a custom `ToastScheduler` (the seam `@gjsify/adwaita-core`
89
+ defines) to drive toast lifetimes from your own clock — that is how the
90
+ package's own regression tests advance time without real timers.
91
+
44
92
  ## Theming a page without `<adw-window>`
45
93
 
46
94
  The components read their colours from the `--window-*` CSS custom properties,