@salmexio/ui 0.4.0 → 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/README.md +52 -3
- package/dist/dialogs/ContextMenu/ContextMenu.svelte +97 -94
- package/dist/dialogs/ContextMenu/ContextMenu.svelte.d.ts +3 -2
- package/dist/dialogs/ContextMenu/ContextMenu.svelte.d.ts.map +1 -1
- package/dist/dialogs/Modal/Modal.svelte +112 -116
- package/dist/dialogs/Modal/Modal.svelte.d.ts +1 -1
- package/dist/feedback/Alert/Alert.svelte +119 -220
- package/dist/feedback/Alert/Alert.svelte.d.ts +1 -1
- package/dist/feedback/ProgressBar/ProgressBar.svelte +265 -0
- package/dist/feedback/ProgressBar/ProgressBar.svelte.d.ts +40 -0
- package/dist/feedback/ProgressBar/ProgressBar.svelte.d.ts.map +1 -0
- package/dist/feedback/ProgressBar/index.d.ts +2 -0
- package/dist/feedback/ProgressBar/index.d.ts.map +1 -0
- package/dist/feedback/ProgressBar/index.js +1 -0
- package/dist/feedback/Skeleton/Skeleton.svelte +157 -0
- package/dist/feedback/Skeleton/Skeleton.svelte.d.ts +37 -0
- package/dist/feedback/Skeleton/Skeleton.svelte.d.ts.map +1 -0
- package/dist/feedback/Skeleton/index.d.ts +2 -0
- package/dist/feedback/Skeleton/index.d.ts.map +1 -0
- package/dist/feedback/Skeleton/index.js +1 -0
- package/dist/feedback/Spinner/Spinner.svelte +86 -151
- package/dist/feedback/Spinner/Spinner.svelte.d.ts +5 -3
- package/dist/feedback/Spinner/Spinner.svelte.d.ts.map +1 -1
- package/dist/feedback/Toast/Toaster.svelte +431 -0
- package/dist/feedback/Toast/Toaster.svelte.d.ts +22 -0
- package/dist/feedback/Toast/Toaster.svelte.d.ts.map +1 -0
- package/dist/feedback/Toast/index.d.ts +4 -0
- package/dist/feedback/Toast/index.d.ts.map +1 -0
- package/dist/feedback/Toast/index.js +2 -0
- package/dist/feedback/Toast/toastStore.d.ts +34 -0
- package/dist/feedback/Toast/toastStore.d.ts.map +1 -0
- package/dist/feedback/Toast/toastStore.js +43 -0
- package/dist/feedback/index.d.ts +4 -0
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/feedback/index.js +3 -0
- package/dist/forms/Checkbox/Checkbox.svelte +87 -104
- package/dist/forms/Checkbox/Checkbox.svelte.d.ts +1 -1
- package/dist/forms/Select/Select.svelte +137 -179
- package/dist/forms/Select/Select.svelte.d.ts +1 -1
- package/dist/forms/Slider/Slider.svelte +356 -0
- package/dist/forms/Slider/Slider.svelte.d.ts +50 -0
- package/dist/forms/Slider/Slider.svelte.d.ts.map +1 -0
- package/dist/forms/Slider/index.d.ts +2 -0
- package/dist/forms/Slider/index.d.ts.map +1 -0
- package/dist/forms/Slider/index.js +1 -0
- package/dist/forms/TextInput/TextInput.svelte +161 -167
- package/dist/forms/TextInput/TextInput.svelte.d.ts +1 -1
- package/dist/forms/Textarea/Textarea.svelte +615 -0
- package/dist/forms/Textarea/Textarea.svelte.d.ts +47 -0
- package/dist/forms/Textarea/Textarea.svelte.d.ts.map +1 -0
- package/dist/forms/Textarea/index.d.ts +2 -0
- package/dist/forms/Textarea/index.d.ts.map +1 -0
- package/dist/forms/Textarea/index.js +1 -0
- package/dist/forms/Toggle/Toggle.svelte +239 -0
- package/dist/forms/Toggle/Toggle.svelte.d.ts +39 -0
- package/dist/forms/Toggle/Toggle.svelte.d.ts.map +1 -0
- package/dist/forms/Toggle/index.d.ts +2 -0
- package/dist/forms/Toggle/index.d.ts.map +1 -0
- package/dist/forms/Toggle/index.js +1 -0
- package/dist/forms/index.d.ts +3 -0
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +3 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/layout/Card/Card.svelte +66 -39
- package/dist/layout/Card/Card.svelte.d.ts +1 -1
- package/dist/layout/Card/Card.svelte.d.ts.map +1 -1
- package/dist/layout/Container/Container.svelte +71 -71
- package/dist/layout/Container/Container.svelte.d.ts +2 -2
- package/dist/layout/ThermalBackground/ThermalBackground.svelte +313 -0
- package/dist/layout/ThermalBackground/ThermalBackground.svelte.d.ts +16 -0
- package/dist/layout/ThermalBackground/ThermalBackground.svelte.d.ts.map +1 -0
- package/dist/layout/ThermalBackground/index.d.ts +2 -0
- package/dist/layout/ThermalBackground/index.d.ts.map +1 -0
- package/dist/layout/ThermalBackground/index.js +1 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +1 -0
- package/dist/navigation/CommandPalette/CommandPalette.svelte +407 -189
- package/dist/navigation/CommandPalette/CommandPalette.svelte.d.ts +8 -3
- package/dist/navigation/CommandPalette/CommandPalette.svelte.d.ts.map +1 -1
- package/dist/navigation/Tabs/Tabs.svelte +139 -192
- package/dist/navigation/Tabs/Tabs.svelte.d.ts +2 -2
- package/dist/primitives/Badge/Badge.svelte +85 -220
- package/dist/primitives/Badge/Badge.svelte.d.ts +2 -2
- package/dist/primitives/Badge/Badge.svelte.d.ts.map +1 -1
- package/dist/primitives/Button/Button.svelte +214 -194
- package/dist/primitives/Button/Button.svelte.d.ts +3 -3
- package/dist/primitives/Button/Button.svelte.d.ts.map +1 -1
- package/dist/primitives/Tooltip/Tooltip.svelte +260 -0
- package/dist/primitives/Tooltip/Tooltip.svelte.d.ts +36 -0
- package/dist/primitives/Tooltip/Tooltip.svelte.d.ts.map +1 -0
- package/dist/primitives/Tooltip/index.d.ts +2 -0
- package/dist/primitives/Tooltip/index.d.ts.map +1 -0
- package/dist/primitives/Tooltip/index.js +1 -0
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +1 -0
- package/dist/styles/tokens.css +329 -260
- package/package.json +5 -5
- package/dist/windowing/Window/Window.svelte +0 -637
- package/dist/windowing/Window/Window.svelte.d.ts +0 -65
- package/dist/windowing/Window/Window.svelte.d.ts.map +0 -1
- package/dist/windowing/Window/index.d.ts +0 -2
- package/dist/windowing/Window/index.d.ts.map +0 -1
- package/dist/windowing/Window/index.js +0 -1
- package/dist/windowing/WindowManager/WindowManager.svelte +0 -425
- package/dist/windowing/WindowManager/WindowManager.svelte.d.ts +0 -38
- package/dist/windowing/WindowManager/WindowManager.svelte.d.ts.map +0 -1
- package/dist/windowing/WindowManager/index.d.ts +0 -2
- package/dist/windowing/WindowManager/index.d.ts.map +0 -1
- package/dist/windowing/WindowManager/index.js +0 -1
- package/dist/windowing/index.d.ts +0 -5
- package/dist/windowing/index.d.ts.map +0 -1
- package/dist/windowing/index.js +0 -3
- package/dist/windowing/windowStore.svelte.d.ts +0 -49
- package/dist/windowing/windowStore.svelte.d.ts.map +0 -1
- package/dist/windowing/windowStore.svelte.js +0 -170
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component Toaster
|
|
3
|
+
|
|
4
|
+
INFRARED — Toast notification container.
|
|
5
|
+
Renders stacked toast notifications with slide-in/out animations,
|
|
6
|
+
auto-dismiss with pause-on-hover, keyboard dismiss, and ARIA live region.
|
|
7
|
+
|
|
8
|
+
Place once at your app root:
|
|
9
|
+
@example
|
|
10
|
+
<Toaster />
|
|
11
|
+
-->
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { cn } from '../../utils/cn.js';
|
|
14
|
+
import { toasts } from './toastStore.js';
|
|
15
|
+
import type { ToastItem } from './toastStore.js';
|
|
16
|
+
import { onMount } from 'svelte';
|
|
17
|
+
|
|
18
|
+
type ToastPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
/** Position on screen */
|
|
22
|
+
position?: ToastPosition;
|
|
23
|
+
/** Additional CSS class */
|
|
24
|
+
class?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let {
|
|
28
|
+
position = 'bottom-right',
|
|
29
|
+
class: className = ''
|
|
30
|
+
}: Props = $props();
|
|
31
|
+
|
|
32
|
+
let timers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
33
|
+
let pausedToasts = new Set<string>();
|
|
34
|
+
let dismissingIds = $state(new Set<string>());
|
|
35
|
+
|
|
36
|
+
function startTimer(toast: ToastItem) {
|
|
37
|
+
if (!toast.duration || toast.duration <= 0) return;
|
|
38
|
+
clearTimer(toast.id);
|
|
39
|
+
timers.set(
|
|
40
|
+
toast.id,
|
|
41
|
+
setTimeout(() => dismiss(toast.id), toast.duration)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function clearTimer(id: string) {
|
|
46
|
+
const t = timers.get(id);
|
|
47
|
+
if (t) {
|
|
48
|
+
clearTimeout(t);
|
|
49
|
+
timers.delete(id);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function pauseTimer(id: string) {
|
|
54
|
+
pausedToasts.add(id);
|
|
55
|
+
clearTimer(id);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function resumeTimer(toast: ToastItem) {
|
|
59
|
+
pausedToasts.delete(toast.id);
|
|
60
|
+
startTimer(toast);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function dismiss(id: string) {
|
|
64
|
+
dismissingIds = new Set([...dismissingIds, id]);
|
|
65
|
+
clearTimer(id);
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
dismissingIds = new Set([...dismissingIds].filter((d) => d !== id));
|
|
68
|
+
toasts.dismiss(id);
|
|
69
|
+
}, 150);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleKeydown(e: KeyboardEvent, id: string) {
|
|
73
|
+
if (e.key === 'Escape') {
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
dismiss(id);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getIcon(type: ToastItem['type']): string {
|
|
80
|
+
switch (type) {
|
|
81
|
+
case 'success': return 'M9 12l2 2 4-4';
|
|
82
|
+
case 'error': return 'M18 6L6 18M6 6l12 12';
|
|
83
|
+
case 'warning': return 'M12 9v4m0 4h.01';
|
|
84
|
+
case 'info': return 'M12 16v-4m0-4h.01';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Start timers for new toasts
|
|
89
|
+
$effect(() => {
|
|
90
|
+
const currentToasts = $toasts;
|
|
91
|
+
for (const toast of currentToasts) {
|
|
92
|
+
if (!timers.has(toast.id) && !pausedToasts.has(toast.id) && !dismissingIds.has(toast.id)) {
|
|
93
|
+
startTimer(toast);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
onMount(() => {
|
|
99
|
+
return () => {
|
|
100
|
+
for (const t of timers.values()) clearTimeout(t);
|
|
101
|
+
timers.clear();
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<div
|
|
107
|
+
class={cn('sx-toaster', `sx-toaster-${position}`, className)}
|
|
108
|
+
aria-live="polite"
|
|
109
|
+
aria-atomic="false"
|
|
110
|
+
role="region"
|
|
111
|
+
aria-label="Notifications"
|
|
112
|
+
>
|
|
113
|
+
{#each $toasts as toast (toast.id)}
|
|
114
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
115
|
+
<div
|
|
116
|
+
class={cn(
|
|
117
|
+
'sx-toast',
|
|
118
|
+
`sx-toast-${toast.type}`,
|
|
119
|
+
dismissingIds.has(toast.id) && 'sx-toast-exit'
|
|
120
|
+
)}
|
|
121
|
+
role="status"
|
|
122
|
+
aria-atomic="true"
|
|
123
|
+
tabindex={-1}
|
|
124
|
+
onmouseenter={() => pauseTimer(toast.id)}
|
|
125
|
+
onmouseleave={() => resumeTimer(toast)}
|
|
126
|
+
onkeydown={(e) => handleKeydown(e, toast.id)}
|
|
127
|
+
>
|
|
128
|
+
<span class="sx-toast-icon" aria-hidden="true">
|
|
129
|
+
{#if toast.type === 'success'}
|
|
130
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
131
|
+
<circle cx="12" cy="12" r="10" /><path d={getIcon(toast.type)} />
|
|
132
|
+
</svg>
|
|
133
|
+
{:else if toast.type === 'error'}
|
|
134
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
135
|
+
<circle cx="12" cy="12" r="10" /><path d={getIcon(toast.type)} />
|
|
136
|
+
</svg>
|
|
137
|
+
{:else if toast.type === 'warning'}
|
|
138
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
139
|
+
<path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" /><path d={getIcon(toast.type)} />
|
|
140
|
+
</svg>
|
|
141
|
+
{:else}
|
|
142
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
143
|
+
<circle cx="12" cy="12" r="10" /><path d={getIcon(toast.type)} />
|
|
144
|
+
</svg>
|
|
145
|
+
{/if}
|
|
146
|
+
</span>
|
|
147
|
+
|
|
148
|
+
<div class="sx-toast-content">
|
|
149
|
+
<p class="sx-toast-message">{toast.message}</p>
|
|
150
|
+
{#if toast.description}
|
|
151
|
+
<p class="sx-toast-description">{toast.description}</p>
|
|
152
|
+
{/if}
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<div class="sx-toast-actions">
|
|
156
|
+
{#if toast.action}
|
|
157
|
+
<button
|
|
158
|
+
type="button"
|
|
159
|
+
class="sx-toast-action-btn"
|
|
160
|
+
onclick={() => { toast.action?.onclick(); dismiss(toast.id); }}
|
|
161
|
+
>
|
|
162
|
+
{toast.action.label}
|
|
163
|
+
</button>
|
|
164
|
+
{/if}
|
|
165
|
+
{#if toast.dismissible}
|
|
166
|
+
<button
|
|
167
|
+
type="button"
|
|
168
|
+
class="sx-toast-close"
|
|
169
|
+
onclick={() => dismiss(toast.id)}
|
|
170
|
+
aria-label="Dismiss notification"
|
|
171
|
+
>
|
|
172
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
173
|
+
<path d="M18 6L6 18M6 6l12 12" />
|
|
174
|
+
</svg>
|
|
175
|
+
</button>
|
|
176
|
+
{/if}
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
{/each}
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<style>
|
|
183
|
+
.sx-toaster {
|
|
184
|
+
position: fixed;
|
|
185
|
+
z-index: var(--sx-z-tooltip);
|
|
186
|
+
display: flex;
|
|
187
|
+
flex-direction: column;
|
|
188
|
+
gap: var(--sx-space-2);
|
|
189
|
+
pointer-events: none;
|
|
190
|
+
max-width: 380px;
|
|
191
|
+
width: 100%;
|
|
192
|
+
padding: var(--sx-space-5);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.sx-toaster-bottom-right {
|
|
196
|
+
bottom: 0;
|
|
197
|
+
right: 0;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.sx-toaster-bottom-left {
|
|
201
|
+
bottom: 0;
|
|
202
|
+
left: 0;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.sx-toaster-top-right {
|
|
206
|
+
top: 0;
|
|
207
|
+
right: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.sx-toaster-top-left {
|
|
211
|
+
top: 0;
|
|
212
|
+
left: 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* ========== TOAST ========== */
|
|
216
|
+
.sx-toast {
|
|
217
|
+
pointer-events: auto;
|
|
218
|
+
display: flex;
|
|
219
|
+
align-items: flex-start;
|
|
220
|
+
gap: var(--sx-space-3);
|
|
221
|
+
padding: var(--sx-space-3) var(--sx-space-4);
|
|
222
|
+
background: var(--sx-glass-bg-strong);
|
|
223
|
+
backdrop-filter: var(--sx-glass-blur);
|
|
224
|
+
-webkit-backdrop-filter: var(--sx-glass-blur);
|
|
225
|
+
border: 1px solid var(--sx-color-border-strong);
|
|
226
|
+
border-radius: var(--sx-radius-md);
|
|
227
|
+
box-shadow: var(--sx-shadow-lg);
|
|
228
|
+
border-left: 3px solid var(--sx-color-text-secondary);
|
|
229
|
+
animation: sx-toast-in 250ms var(--sx-ease-out) both;
|
|
230
|
+
outline: none;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.sx-toast:focus-visible {
|
|
234
|
+
outline: 2px solid var(--sx-color-primary);
|
|
235
|
+
outline-offset: 2px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.sx-toast-exit {
|
|
239
|
+
animation: sx-toast-out 150ms ease-in both;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/* Type border colors */
|
|
243
|
+
.sx-toast-success {
|
|
244
|
+
border-left-color: var(--sx-color-green);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.sx-toast-error {
|
|
248
|
+
border-left-color: var(--sx-color-red);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.sx-toast-warning {
|
|
252
|
+
border-left-color: var(--sx-color-secondary);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.sx-toast-info {
|
|
256
|
+
border-left-color: var(--sx-color-primary);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/* Icon */
|
|
260
|
+
.sx-toast-icon {
|
|
261
|
+
flex-shrink: 0;
|
|
262
|
+
display: flex;
|
|
263
|
+
align-items: center;
|
|
264
|
+
margin-top: 1px;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.sx-toast-success .sx-toast-icon {
|
|
268
|
+
color: var(--sx-color-green);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.sx-toast-error .sx-toast-icon {
|
|
272
|
+
color: var(--sx-color-red);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.sx-toast-warning .sx-toast-icon {
|
|
276
|
+
color: var(--sx-color-secondary);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.sx-toast-info .sx-toast-icon {
|
|
280
|
+
color: var(--sx-color-primary);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/* Content */
|
|
284
|
+
.sx-toast-content {
|
|
285
|
+
flex: 1;
|
|
286
|
+
min-width: 0;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.sx-toast-message {
|
|
290
|
+
margin: 0;
|
|
291
|
+
font-family: var(--sx-font-body);
|
|
292
|
+
font-size: var(--sx-text-sm);
|
|
293
|
+
font-weight: 500;
|
|
294
|
+
color: var(--sx-color-text);
|
|
295
|
+
line-height: var(--sx-leading-normal);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.sx-toast-description {
|
|
299
|
+
margin: var(--sx-space-1) 0 0;
|
|
300
|
+
font-family: var(--sx-font-body);
|
|
301
|
+
font-size: var(--sx-text-xs);
|
|
302
|
+
color: var(--sx-color-text-secondary);
|
|
303
|
+
line-height: var(--sx-leading-relaxed);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* Actions */
|
|
307
|
+
.sx-toast-actions {
|
|
308
|
+
flex-shrink: 0;
|
|
309
|
+
display: flex;
|
|
310
|
+
align-items: center;
|
|
311
|
+
gap: var(--sx-space-1);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.sx-toast-action-btn {
|
|
315
|
+
border: none;
|
|
316
|
+
background: none;
|
|
317
|
+
font-family: var(--sx-font-body);
|
|
318
|
+
font-size: var(--sx-text-xs);
|
|
319
|
+
font-weight: 600;
|
|
320
|
+
color: var(--sx-color-primary);
|
|
321
|
+
cursor: pointer;
|
|
322
|
+
padding: var(--sx-space-1) var(--sx-space-2);
|
|
323
|
+
border-radius: var(--sx-radius-sm);
|
|
324
|
+
white-space: nowrap;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.sx-toast-action-btn:hover {
|
|
328
|
+
background: var(--sx-color-primary-subtle);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.sx-toast-action-btn:focus-visible {
|
|
332
|
+
outline: 2px solid var(--sx-color-primary);
|
|
333
|
+
outline-offset: 1px;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.sx-toast-close {
|
|
337
|
+
display: flex;
|
|
338
|
+
align-items: center;
|
|
339
|
+
justify-content: center;
|
|
340
|
+
width: 24px;
|
|
341
|
+
height: 24px;
|
|
342
|
+
border: none;
|
|
343
|
+
background: transparent;
|
|
344
|
+
color: var(--sx-color-text-disabled);
|
|
345
|
+
cursor: pointer;
|
|
346
|
+
border-radius: var(--sx-radius-sm);
|
|
347
|
+
padding: 0;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.sx-toast-close:hover {
|
|
351
|
+
background: var(--sx-color-surface-2);
|
|
352
|
+
color: var(--sx-color-text-secondary);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.sx-toast-close:focus-visible {
|
|
356
|
+
outline: 2px solid var(--sx-color-primary);
|
|
357
|
+
outline-offset: 1px;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/* Animations */
|
|
361
|
+
@keyframes sx-toast-in {
|
|
362
|
+
from {
|
|
363
|
+
opacity: 0;
|
|
364
|
+
transform: translateX(100%) scale(0.95);
|
|
365
|
+
}
|
|
366
|
+
to {
|
|
367
|
+
opacity: 1;
|
|
368
|
+
transform: translateX(0) scale(1);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
@keyframes sx-toast-out {
|
|
373
|
+
from {
|
|
374
|
+
opacity: 1;
|
|
375
|
+
transform: translateX(0) scale(1);
|
|
376
|
+
}
|
|
377
|
+
to {
|
|
378
|
+
opacity: 0;
|
|
379
|
+
transform: translateX(100%) scale(0.95);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.sx-toaster-bottom-left .sx-toast,
|
|
384
|
+
.sx-toaster-top-left .sx-toast {
|
|
385
|
+
animation-name: sx-toast-in-left;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.sx-toaster-bottom-left .sx-toast-exit,
|
|
389
|
+
.sx-toaster-top-left .sx-toast-exit {
|
|
390
|
+
animation-name: sx-toast-out-left;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
@keyframes sx-toast-in-left {
|
|
394
|
+
from {
|
|
395
|
+
opacity: 0;
|
|
396
|
+
transform: translateX(-100%) scale(0.95);
|
|
397
|
+
}
|
|
398
|
+
to {
|
|
399
|
+
opacity: 1;
|
|
400
|
+
transform: translateX(0) scale(1);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
@keyframes sx-toast-out-left {
|
|
405
|
+
from {
|
|
406
|
+
opacity: 1;
|
|
407
|
+
transform: translateX(0) scale(1);
|
|
408
|
+
}
|
|
409
|
+
to {
|
|
410
|
+
opacity: 0;
|
|
411
|
+
transform: translateX(-100%) scale(0.95);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@media (prefers-reduced-motion: reduce) {
|
|
416
|
+
.sx-toast,
|
|
417
|
+
.sx-toast-exit {
|
|
418
|
+
animation: none;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/* Mobile: full width at bottom */
|
|
423
|
+
@media (max-width: 480px) {
|
|
424
|
+
.sx-toaster {
|
|
425
|
+
max-width: 100%;
|
|
426
|
+
left: 0;
|
|
427
|
+
right: 0;
|
|
428
|
+
padding: var(--sx-space-3);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type ToastPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Position on screen */
|
|
4
|
+
position?: ToastPosition;
|
|
5
|
+
/** Additional CSS class */
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Toaster
|
|
10
|
+
*
|
|
11
|
+
* INFRARED — Toast notification container.
|
|
12
|
+
* Renders stacked toast notifications with slide-in/out animations,
|
|
13
|
+
* auto-dismiss with pause-on-hover, keyboard dismiss, and ARIA live region.
|
|
14
|
+
*
|
|
15
|
+
* Place once at your app root:
|
|
16
|
+
* @example
|
|
17
|
+
* <Toaster />
|
|
18
|
+
*/
|
|
19
|
+
declare const Toaster: import("svelte").Component<Props, {}, "">;
|
|
20
|
+
type Toaster = ReturnType<typeof Toaster>;
|
|
21
|
+
export default Toaster;
|
|
22
|
+
//# sourceMappingURL=Toaster.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toaster.svelte.d.ts","sourceRoot":"","sources":["../../../src/feedback/Toast/Toaster.svelte.ts"],"names":[],"mappings":"AASA,KAAK,aAAa,GAAG,cAAc,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,CAAC;AAE/E,UAAU,KAAK;IACd,yBAAyB;IACzB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAkJD;;;;;;;;;;GAUG;AACH,QAAA,MAAM,OAAO,2CAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/feedback/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type ToastType = 'success' | 'error' | 'warning' | 'info';
|
|
2
|
+
export interface ToastItem {
|
|
3
|
+
id: string;
|
|
4
|
+
type: ToastType;
|
|
5
|
+
message: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
duration?: number;
|
|
8
|
+
dismissible?: boolean;
|
|
9
|
+
action?: {
|
|
10
|
+
label: string;
|
|
11
|
+
onclick: () => void;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ToastOptions {
|
|
15
|
+
type?: ToastType;
|
|
16
|
+
description?: string;
|
|
17
|
+
duration?: number;
|
|
18
|
+
dismissible?: boolean;
|
|
19
|
+
action?: {
|
|
20
|
+
label: string;
|
|
21
|
+
onclick: () => void;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare const toasts: {
|
|
25
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<ToastItem[]>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
26
|
+
add: (message: string, options?: ToastOptions) => string;
|
|
27
|
+
dismiss: (id: string) => void;
|
|
28
|
+
clear: () => void;
|
|
29
|
+
success: (message: string, options?: Omit<ToastOptions, "type">) => string;
|
|
30
|
+
error: (message: string, options?: Omit<ToastOptions, "type">) => string;
|
|
31
|
+
warning: (message: string, options?: Omit<ToastOptions, "type">) => string;
|
|
32
|
+
info: (message: string, options?: Omit<ToastOptions, "type">) => string;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=toastStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toastStore.d.ts","sourceRoot":"","sources":["../../../src/feedback/Toast/toastStore.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjE,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CAChD;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CAChD;AAsDD,eAAO,MAAM,MAAM;;mBA9CI,MAAM,YAAW,YAAY,KAAQ,MAAM;kBAsB5C,MAAM;;uBAaP,MAAM,YAAY,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC;qBAE9C,MAAM,YAAY,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC;uBAE1C,MAAM,YAAY,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC;oBAE/C,MAAM,YAAY,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC;CAKtB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
const MAX_VISIBLE = 5;
|
|
3
|
+
let counter = 0;
|
|
4
|
+
function createToastStore() {
|
|
5
|
+
const { subscribe, update } = writable([]);
|
|
6
|
+
function add(message, options = {}) {
|
|
7
|
+
const id = `toast-${++counter}`;
|
|
8
|
+
const toast = {
|
|
9
|
+
id,
|
|
10
|
+
type: options.type ?? 'info',
|
|
11
|
+
message,
|
|
12
|
+
description: options.description,
|
|
13
|
+
duration: options.duration ?? 5000,
|
|
14
|
+
dismissible: options.dismissible ?? true,
|
|
15
|
+
action: options.action
|
|
16
|
+
};
|
|
17
|
+
update((toasts) => {
|
|
18
|
+
const next = [toast, ...toasts];
|
|
19
|
+
// Keep queue bounded
|
|
20
|
+
if (next.length > MAX_VISIBLE)
|
|
21
|
+
return next.slice(0, MAX_VISIBLE);
|
|
22
|
+
return next;
|
|
23
|
+
});
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
26
|
+
function dismiss(id) {
|
|
27
|
+
update((toasts) => toasts.filter((t) => t.id !== id));
|
|
28
|
+
}
|
|
29
|
+
function clear() {
|
|
30
|
+
update(() => []);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
subscribe,
|
|
34
|
+
add,
|
|
35
|
+
dismiss,
|
|
36
|
+
clear,
|
|
37
|
+
success: (message, options) => add(message, { ...options, type: 'success' }),
|
|
38
|
+
error: (message, options) => add(message, { ...options, type: 'error' }),
|
|
39
|
+
warning: (message, options) => add(message, { ...options, type: 'warning' }),
|
|
40
|
+
info: (message, options) => add(message, { ...options, type: 'info' })
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export const toasts = createToastStore();
|
package/dist/feedback/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { Alert } from './Alert/index.js';
|
|
2
2
|
export { Spinner } from './Spinner/index.js';
|
|
3
|
+
export { Toaster, toasts } from './Toast/index.js';
|
|
4
|
+
export type { ToastItem, ToastOptions, ToastType } from './Toast/index.js';
|
|
5
|
+
export { ProgressBar } from './ProgressBar/index.js';
|
|
6
|
+
export { Skeleton } from './Skeleton/index.js';
|
|
3
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/feedback/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/feedback/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/feedback/index.js
CHANGED