react-snackbar-glass 0.0.0-stage β†’ 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.1.0] - 2026-10-28
9
+
10
+ ### Added
11
+
12
+ - Global `toast` API: callable (`toast('Saved')`), option objects
13
+ (`toast({ message, variant })`), every variant preset, plus `show`,
14
+ `update`, `dismiss`, `dismissAll`, `promise` and a `store` accessor.
15
+ - `getDefaultStore()` / `setDefaultStore()` to share or swap the store behind
16
+ the global API.
17
+ - `<SnackbarProvider>` now renders the shared default store when no `store`
18
+ prop is given, so `toast` works with zero wiring.
19
+
20
+ ### Changed
21
+
22
+ - Copy and docs rebranded from "premium" to "glass".
23
+ - Added `repository`, `homepage` and `bugs` metadata.
24
+
25
+ ## [1.0.0] - 2026-10-28
26
+
27
+ ### Added
28
+
29
+ - Initial public release.
30
+ - `SnackbarProvider`, `useSnackbar`, `useSnackbarStore` and a headless
31
+ `createSnackbarStore` + `SnackbarHost` pair.
32
+ - Seven variants (`neutral`, `success`, `error`, `warning`, `info`, `loading`,
33
+ `custom`), glass/solid tones and four sizes.
34
+ - Six screen placements with queueing and `maxVisible` stacking.
35
+ - Promise-aware `promise()` flows with loading, success, error and mapper
36
+ content.
37
+ - Swipe-to-dismiss, pause on hover/focus/hidden document, countdown hairline.
38
+ - Accessible live regions, keyboard-reachable actions, reduced-motion support.
39
+ - Token-driven CSS theming via `--prs-*` custom properties.
40
+ - ESM, CJS and TypeScript declarations with zero runtime dependencies.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 react-snackbar-glass contributors
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 CHANGED
@@ -1,3 +1,244 @@
1
- # Temporary Holding Version
1
+ # react-snackbar-glass
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A glassmorphic snackbar system for React β€” queueing, promise-aware
4
+ states, swipe-to-dismiss and token-driven theming with **zero runtime
5
+ dependencies**.
6
+
7
+ - πŸͺŸ **Glass or solid** surfaces, `xs` β†’ `lg` sizes, six screen corners
8
+ - 🌍 **Global `toast`** β€” call it from anywhere, no hook required
9
+ - ⏳ **Promise aware** β€” one call moves a snackbar through loading β†’ success β†’ error
10
+ - πŸ‘† **Swipe to dismiss**, hover/focus/document-hidden pause, countdown hairline
11
+ - β™Ώ **Accessible** β€” polite/assertive live regions, keyboard reachable actions, `prefers-reduced-motion`
12
+ - 🧩 **Typed** β€” written in TypeScript, ships ESM + CJS + `.d.ts`
13
+ - πŸͺΆ **Tiny** β€” React is the only peer dependency
14
+ - πŸ–₯️ **SSR safe** β€” no `window` access during render
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install react-snackbar-glass
20
+ ```
21
+
22
+ Import the stylesheet once in your app entry point:
23
+
24
+ ```ts
25
+ import 'react-snackbar-glass/styles.css';
26
+ ```
27
+
28
+ ## Quick start
29
+
30
+ ```tsx
31
+ import { SnackbarProvider, useSnackbar } from 'react-snackbar-glass';
32
+ import 'react-snackbar-glass/styles.css';
33
+
34
+ export default function App() {
35
+ return (
36
+ <SnackbarProvider position="bottom-right" theme="auto">
37
+ <Dashboard />
38
+ </SnackbarProvider>
39
+ );
40
+ }
41
+
42
+ function Dashboard() {
43
+ const snackbar = useSnackbar();
44
+
45
+ return (
46
+ <button onClick={() => snackbar.success('Saved to your workspace.')}>
47
+ Save
48
+ </button>
49
+ );
50
+ }
51
+ ```
52
+
53
+ ## API
54
+
55
+ ### `useSnackbar()`
56
+
57
+ | Method | Description |
58
+ | --- | --- |
59
+ | `show(options)` | Queue a fully customised snackbar, returns its `id`. |
60
+ | `update(id, options)` | Patch an existing snackbar in place; timers restart if `duration` changes. |
61
+ | `dismiss(id?, reason?)` | Close one snackbar (or the oldest) and report a close reason. |
62
+ | `dismissAll(reason?)` | Close every visible snackbar. |
63
+ | `success / error / warning / info / neutral / loading / custom(message, options?)` | Variant presets. |
64
+ | `promise(promise, messages, options?)` | Drive a single snackbar through loading, success and error. |
65
+ | `store` | Escape hatch: the underlying store for subscriptions and advanced updates. |
66
+
67
+ ### `toast` β€” global API
68
+
69
+ Import `toast` when you are outside a component: data layers, event
70
+ emitters, API clients, `setTimeout` callbacks. It targets the same store
71
+ that `<SnackbarProvider>` renders, so no hook is needed.
72
+
73
+ ```ts
74
+ import { toast } from 'react-snackbar-glass';
75
+
76
+ toast('Draft saved');
77
+ toast.success('Deployment complete.', { title: 'v1.4.0 is live' });
78
+ toast.error('Payment declined', { action: { label: 'Retry', onClick: retry } });
79
+ ```
80
+
81
+ It mirrors `useSnackbar()` one-to-one β€” `show`, `update`, `dismiss`,
82
+ `dismissAll`, every variant preset, `promise`, and `store`:
83
+
84
+ ```ts
85
+ const id = toast.loading('Saving…');
86
+ await save();
87
+ toast.update(id, { variant: 'success', message: 'Saved', duration: 3000 });
88
+ ```
89
+
90
+ `<SnackbarProvider>` renders the shared store by default. Mount
91
+ `<SnackbarHost store={getDefaultStore()} />` if you need the host without a
92
+ provider, and `setDefaultStore(store)` to point `toast` at a store of your
93
+ own (handy in tests or multi-app setups). On the server, pass an explicit
94
+ `store` so requests stay isolated.
95
+
96
+ ### Promise-aware flows
97
+
98
+ ```tsx
99
+ const snackbar = useSnackbar();
100
+
101
+ snackbar.promise(deploy(), {
102
+ loading: { title: 'Deploying', message: 'Uploading assets…' },
103
+ success: { title: 'Deployed', message: 'Build #4821 is live.' },
104
+ error: (error) => ({
105
+ title: 'Deployment failed',
106
+ message: error instanceof Error ? error.message : 'Something went wrong.',
107
+ action: { label: 'View logs' },
108
+ }),
109
+ });
110
+ ```
111
+
112
+ `success` and `error` can be plain content, full options, or a mapper that
113
+ receives the resolved value / rejection reason.
114
+
115
+ ### Sticky snackbars with in-place updates
116
+
117
+ ```tsx
118
+ const id = snackbar.show({
119
+ variant: 'loading',
120
+ title: 'Uploading assets',
121
+ message: '42% Β· 8 of 19 files',
122
+ duration: null,
123
+ });
124
+
125
+ // later…
126
+ snackbar.update(id, {
127
+ variant: 'success',
128
+ title: 'Upload complete',
129
+ message: '19 assets are ready to use.',
130
+ duration: 4200,
131
+ });
132
+ ```
133
+
134
+ ### Actions and undo windows
135
+
136
+ ```tsx
137
+ snackbar.show({
138
+ message: 'Project archived.',
139
+ duration: 7000,
140
+ action: {
141
+ label: 'Undo',
142
+ onClick: () => restoreProject(),
143
+ },
144
+ });
145
+ ```
146
+
147
+ Action handlers may return a promise: the button shows a pending state and
148
+ the snackbar only closes after the handler settles (`closeOnClick`, default
149
+ `true`).
150
+
151
+ ## `<SnackbarProvider>` props
152
+
153
+ | Prop | Type | Default | Description |
154
+ | --- | --- | --- | --- |
155
+ | `position` | `SnackbarPosition` | `'bottom-right'` | Default corner for new snackbars. |
156
+ | `duration` | `number \| null` | `5000` | Auto-dismiss delay in ms. `null`/`0`/`Infinity` = persistent. |
157
+ | `tone` | `'glass' \| 'solid'` | `'glass'` | Surface treatment. |
158
+ | `size` | `'xs' \| 'sm' \| 'md' \| 'lg'` | `'md'` | Card density/width. |
159
+ | `theme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Color scheme. |
160
+ | `maxVisible` | `number` | `3` | Simultaneously visible cards per corner. |
161
+ | `dismissible` | `boolean` | `true` | Show the close button. |
162
+ | `progress` | `boolean` | `true` | Show the countdown hairline. |
163
+ | `pauseOnHover` | `boolean` | `true` | Freeze the timer while hovered. |
164
+ | `pauseOnFocus` | `boolean` | `true` | Freeze the timer while focus is inside. |
165
+ | `pauseOnDocumentHidden` | `boolean` | `true` | Pause when the tab is hidden. |
166
+ | `swipeToDismiss` | `boolean` | `true` | Drag/flick a card to dismiss. |
167
+ | `swipeThreshold` | `number` | `88` | Drag distance (px) that triggers dismissal. |
168
+ | `store` | `SnackbarStore` | β€” | Bring your own store (tests, SSR, multiple apps). |
169
+ | `offset` / `gap` / `width` | `number` | `20` / `12` / `384` | Layout tuning in px. |
170
+ | `icons` / `closeIcon` / `closeLabel` / `regionLabel` | β€” | β€” | Icon and a11y overrides. |
171
+ | `container` | `HTMLElement \| () => HTMLElement \| null` | `document.body` | Portal target. |
172
+ | `dir` | `'ltr' \| 'rtl'` | inherited | Text direction. |
173
+ | `zIndex` | `number` | `2147483000` | Host stacking context. |
174
+
175
+ ## `SnackbarOptions`
176
+
177
+ `id`, `title`, `message`, `variant`, `duration`, `position`, `icon`,
178
+ `action`, `dismissible`, `progress`, `tone`, `size`, `className`, `style`,
179
+ `onOpen`, `onClose`.
180
+
181
+ Reusing an `id` updates (or revives) the existing snackbar instead of stacking
182
+ a duplicate β€” ideal for progress-style flows.
183
+
184
+ ## Theming
185
+
186
+ Colors, radii, blur and motion are CSS custom properties on `.prs-root`
187
+ (and per-card inline styles). Override globally:
188
+
189
+ ```css
190
+ :root {
191
+ --prs-accent: #8b5cf6;
192
+ --prs-radius: 16px;
193
+ }
194
+ ```
195
+
196
+ Or scope a single snackbar:
197
+
198
+ ```tsx
199
+ snackbar.custom('Added to collection.', {
200
+ style: { '--prs-accent': '#f472b6', '--prs-solid': '#be185d' },
201
+ });
202
+ ```
203
+
204
+ ## Store-only usage
205
+
206
+ ```tsx
207
+ import { createSnackbarStore, SnackbarHost } from 'react-snackbar-glass';
208
+
209
+ const store = createSnackbarStore({ position: 'top-center' });
210
+
211
+ function App() {
212
+ return (
213
+ <>
214
+ <button onClick={() => store.show({ message: 'Hi there' })}>Notify</button>
215
+ <SnackbarHost store={store} />
216
+ </>
217
+ );
218
+ }
219
+ ```
220
+
221
+ ## Server-side rendering
222
+
223
+ `SnackbarProvider` and `SnackbarHost` render nothing until mounted, and the
224
+ store returns a stable server snapshot. No `window` access during render, so
225
+ the components are safe in Next.js, Remix and other SSR frameworks.
226
+
227
+ ## Requirements
228
+
229
+ - React 18 or 19
230
+ - Modern evergreen browsers (CSS `backdrop-filter` degrades gracefully)
231
+
232
+ ## Development
233
+
234
+ ```bash
235
+ npm install
236
+ npm run dev # demo playground (Vite)
237
+ npm run typecheck
238
+ npm test
239
+ npm run build # ESM + CJS + d.ts + styles
240
+ ```
241
+
242
+ ## License
243
+
244
+ MIT