varsel 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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/dist/VarselItem.svelte +875 -0
  4. package/dist/VarselItem.svelte.d.ts +31 -0
  5. package/dist/VarselItem.svelte.d.ts.map +1 -0
  6. package/dist/VarselManager.svelte +387 -0
  7. package/dist/VarselManager.svelte.d.ts +24 -0
  8. package/dist/VarselManager.svelte.d.ts.map +1 -0
  9. package/dist/VarselToaster.svelte +46 -0
  10. package/dist/VarselToaster.svelte.d.ts +22 -0
  11. package/dist/VarselToaster.svelte.d.ts.map +1 -0
  12. package/dist/core/accessibility.d.ts +2 -0
  13. package/dist/core/accessibility.d.ts.map +1 -0
  14. package/dist/core/accessibility.js +8 -0
  15. package/dist/core/animations.d.ts +14 -0
  16. package/dist/core/animations.d.ts.map +1 -0
  17. package/dist/core/animations.js +13 -0
  18. package/dist/core/positions.d.ts +64 -0
  19. package/dist/core/positions.d.ts.map +1 -0
  20. package/dist/core/positions.js +26 -0
  21. package/dist/core/swipe.d.ts +8 -0
  22. package/dist/core/swipe.d.ts.map +1 -0
  23. package/dist/core/swipe.js +20 -0
  24. package/dist/core/toast-factory.d.ts +3 -0
  25. package/dist/core/toast-factory.d.ts.map +1 -0
  26. package/dist/core/toast-factory.js +67 -0
  27. package/dist/core/toast-state.d.ts +17 -0
  28. package/dist/core/toast-state.d.ts.map +1 -0
  29. package/dist/core/toast-state.js +47 -0
  30. package/dist/core/toaster-instances.d.ts +10 -0
  31. package/dist/core/toaster-instances.d.ts.map +1 -0
  32. package/dist/core/toaster-instances.js +21 -0
  33. package/dist/core/types.d.ts +55 -0
  34. package/dist/core/types.d.ts.map +1 -0
  35. package/dist/core/types.js +1 -0
  36. package/dist/core/utils.d.ts +2 -0
  37. package/dist/core/utils.d.ts.map +1 -0
  38. package/dist/core/utils.js +1 -0
  39. package/dist/core/variants.d.ts +8 -0
  40. package/dist/core/variants.d.ts.map +1 -0
  41. package/dist/core/variants.js +36 -0
  42. package/dist/index.d.ts +4 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +2 -0
  45. package/dist/internals.d.ts +11 -0
  46. package/dist/internals.d.ts.map +1 -0
  47. package/dist/internals.js +9 -0
  48. package/dist/styles.css +174 -0
  49. package/dist/variant-icons.d.ts +77 -0
  50. package/dist/variant-icons.d.ts.map +1 -0
  51. package/dist/variant-icons.js +32 -0
  52. package/package.json +61 -0
@@ -0,0 +1,31 @@
1
+ import { type PositionedToast } from "./internals";
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const VarselItem: $$__sveltets_2_IsomorphicComponent<{
16
+ toast: PositionedToast;
17
+ onRemove: (id: string) => void;
18
+ isGroupHovered?: boolean;
19
+ expandedOffset?: number;
20
+ expandedGap?: number;
21
+ collapsedOffset?: number | undefined;
22
+ hiddenCollapsedOffset?: number | undefined;
23
+ onHeightChange?: ((id: string, height: number) => void) | undefined;
24
+ onGroupHoverEnter?: (() => void) | undefined;
25
+ onGroupHoldChange?: ((holding: boolean) => void) | undefined;
26
+ }, {
27
+ [evt: string]: CustomEvent<any>;
28
+ }, {}, {}, string>;
29
+ type VarselItem = InstanceType<typeof VarselItem>;
30
+ export default VarselItem;
31
+ //# sourceMappingURL=VarselItem.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VarselItem.svelte.d.ts","sourceRoot":"","sources":["../src/lib/VarselItem.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,EAYN,KAAK,eAAe,EAIpB,MAAM,aAAa,CAAC;AA8wBrB,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,UAAU;WAX6U,eAAe;cAAY,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI;;;kBAAgG,MAAM;sBAAoB,MAAM,GAAG,SAAS;4BAA0B,MAAM,GAAG,SAAS;qBAAmB,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS;wBAAsB,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS;wBAAwB,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,GACxuB,SAAS;;;kBAUmF,CAAC;AAC9E,KAAK,UAAU,GAAG,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;AACpD,eAAe,UAAU,CAAC"}
@@ -0,0 +1,387 @@
1
+ <script lang="ts">
2
+ import { onMount } from "svelte";
3
+ import VarselItem from "./VarselItem.svelte";
4
+ import {
5
+ ANIMATION_CONFIG,
6
+ type PositionedToast,
7
+ type ToastData,
8
+ type ToastPosition,
9
+ } from "./internals";
10
+
11
+ export let toasts: ToastData[] = [];
12
+ export let onRemove: (id: string) => void;
13
+ export let expandedGap: number = ANIMATION_CONFIG.EXPANDED_GAP;
14
+
15
+ const createPositionMap = <T>(value: () => T): Record<ToastPosition, T> => ({
16
+ "top-left": value(),
17
+ "top-center": value(),
18
+ "top-right": value(),
19
+ "bottom-left": value(),
20
+ "bottom-center": value(),
21
+ "bottom-right": value(),
22
+ });
23
+
24
+ let heights: Record<string, number> = {};
25
+ let hovered: Record<ToastPosition, boolean> = createPositionMap(() => false);
26
+ let heldToasts: Record<ToastPosition, Set<string>> = createPositionMap(
27
+ () => new Set<string>(),
28
+ );
29
+ let previousStackIndex: Record<string, number> = {};
30
+ let previousCollapsedOffsets: Record<string, number> = {};
31
+ let previousExpandedOffsets: Record<string, number> = {};
32
+ let toastsByPosition: Record<ToastPosition, PositionedToast[]> =
33
+ createPositionMap<PositionedToast[]>(() => []);
34
+ let positionEntries: [ToastPosition, PositionedToast[]][] = [];
35
+ let collapsedOffsetData: {
36
+ byPosition: Record<ToastPosition, number[]>;
37
+ byId: Record<string, number>;
38
+ } = { byPosition: createPositionMap<number[]>(() => []), byId: {} };
39
+ let expandedOffsetData: {
40
+ byPosition: Record<ToastPosition, number[]>;
41
+ byId: Record<string, number>;
42
+ } = { byPosition: createPositionMap<number[]>(() => []), byId: {} };
43
+
44
+ let latestPositionEntries: [ToastPosition, PositionedToast[]][] = [];
45
+ let latestHovered: Record<ToastPosition, boolean> = hovered;
46
+
47
+ $: latestPositionEntries = positionEntries;
48
+ $: latestHovered = hovered;
49
+
50
+ const updateHoldState = (
51
+ position: ToastPosition,
52
+ toastId: string,
53
+ isHolding: boolean,
54
+ ) => {
55
+ const current = heldToasts[position] ?? new Set<string>();
56
+ const next = new Set(current);
57
+ if (isHolding) {
58
+ next.add(toastId);
59
+ } else {
60
+ next.delete(toastId);
61
+ }
62
+ if (next.size !== current.size) {
63
+ heldToasts = { ...heldToasts, [position]: next };
64
+ }
65
+ };
66
+
67
+ $: {
68
+ const grouped = createPositionMap<ToastData[]>(() => []);
69
+ for (const toast of toasts) {
70
+ const pos = toast.position || "bottom-center";
71
+ grouped[pos].push(toast);
72
+ }
73
+
74
+ const nextStackIndices: Record<string, number> = {};
75
+ const positioned = createPositionMap<PositionedToast[]>(() => []);
76
+
77
+ for (const position of Object.keys(grouped) as ToastPosition[]) {
78
+ const list = grouped[position];
79
+ const activeToasts = list.filter(
80
+ (toast) => !toast.isLeaving && !toast.shouldClose,
81
+ );
82
+ const activeIndexMap = new Map<string, number>();
83
+ activeToasts.forEach((toast, activeIndex) => {
84
+ activeIndexMap.set(toast.id, activeIndex);
85
+ });
86
+
87
+ positioned[position] = list.map((toast, orderIndex) => {
88
+ let stackIndex =
89
+ activeIndexMap.get(toast.id) ?? previousStackIndex[toast.id];
90
+ if (stackIndex == null || Number.isNaN(stackIndex)) {
91
+ stackIndex = orderIndex;
92
+ }
93
+
94
+ nextStackIndices[toast.id] = stackIndex;
95
+
96
+ return {
97
+ ...toast,
98
+ index: stackIndex,
99
+ renderIndex: orderIndex,
100
+ total: list.length,
101
+ };
102
+ }) as PositionedToast[];
103
+ }
104
+
105
+ previousStackIndex = nextStackIndices;
106
+ toastsByPosition = positioned;
107
+ }
108
+
109
+ $: {
110
+ const next = { ...hovered };
111
+ let changed = false;
112
+ for (const pos of Object.keys(hovered) as ToastPosition[]) {
113
+ const hasToast = (toastsByPosition[pos]?.length ?? 0) > 0;
114
+ if (!hasToast && next[pos]) {
115
+ next[pos] = false;
116
+ changed = true;
117
+ }
118
+ }
119
+ if (changed) {
120
+ hovered = next;
121
+ }
122
+ }
123
+
124
+ $: positionEntries = Object.entries(toastsByPosition) as [
125
+ ToastPosition,
126
+ PositionedToast[],
127
+ ][];
128
+
129
+ $: collapsedOffsetData = (() => {
130
+ const byPosition = createPositionMap<number[]>(() => []);
131
+ const byId: Record<string, number> = {};
132
+
133
+ for (const [pos, group] of positionEntries) {
134
+ const isTopPosition = pos.startsWith("top-");
135
+ const activeToasts = group.filter((toast) => !toast.shouldClose);
136
+ const offsetsForActive: number[] = [];
137
+
138
+ for (let i = 0; i < activeToasts.length; i++) {
139
+ if (i === 0) {
140
+ offsetsForActive.push(0);
141
+ continue;
142
+ }
143
+
144
+ const prevToast = activeToasts[i - 1];
145
+ const currentToast = activeToasts[i];
146
+ const prevOffset = offsetsForActive[i - 1] ?? 0;
147
+ if (!prevToast || !currentToast) {
148
+ offsetsForActive.push(prevOffset);
149
+ continue;
150
+ }
151
+ const prevHeight = heights[prevToast.id];
152
+ const currentHeight = heights[currentToast.id];
153
+ const fallbackOffset =
154
+ prevOffset + (isTopPosition ? 1 : -1) * ANIMATION_CONFIG.STACK_OFFSET;
155
+
156
+ if (
157
+ prevHeight == null ||
158
+ currentHeight == null ||
159
+ Number.isNaN(prevHeight) ||
160
+ Number.isNaN(currentHeight)
161
+ ) {
162
+ offsetsForActive.push(fallbackOffset);
163
+ continue;
164
+ }
165
+
166
+ if (isTopPosition) {
167
+ offsetsForActive.push(
168
+ prevOffset +
169
+ (prevHeight - currentHeight + ANIMATION_CONFIG.STACK_OFFSET),
170
+ );
171
+ } else {
172
+ offsetsForActive.push(
173
+ prevOffset +
174
+ (currentHeight - prevHeight - ANIMATION_CONFIG.STACK_OFFSET),
175
+ );
176
+ }
177
+ }
178
+
179
+ for (let i = 0; i < activeToasts.length; i++) {
180
+ const toast = activeToasts[i];
181
+ if (!toast) continue;
182
+ byId[toast.id] = offsetsForActive[i] ?? 0;
183
+ }
184
+
185
+ for (const toast of group) {
186
+ if (byId[toast.id] != null) continue;
187
+ const previousOffset = previousCollapsedOffsets[toast.id];
188
+ if (typeof previousOffset === "number") {
189
+ byId[toast.id] = previousOffset;
190
+ continue;
191
+ }
192
+
193
+ const defaultOffset = isTopPosition
194
+ ? toast.index * ANIMATION_CONFIG.STACK_OFFSET
195
+ : -(toast.index * ANIMATION_CONFIG.STACK_OFFSET);
196
+ byId[toast.id] = defaultOffset;
197
+ }
198
+
199
+ byPosition[pos] = group.map((toast) => byId[toast.id] ?? 0);
200
+ }
201
+
202
+ previousCollapsedOffsets = byId;
203
+ return { byPosition, byId };
204
+ })();
205
+
206
+ $: expandedOffsetData = (() => {
207
+ const byPosition = createPositionMap<number[]>(() => []);
208
+ const byId: Record<string, number> = {};
209
+
210
+ for (const [pos, group] of positionEntries) {
211
+ const offsets: number[] = [];
212
+ const activeToasts = group.filter((toast) => !toast.shouldClose);
213
+ let acc = 0;
214
+
215
+ for (let i = 0; i < activeToasts.length; i++) {
216
+ if (i === 0) {
217
+ offsets.push(0);
218
+ continue;
219
+ }
220
+ const prevToast = activeToasts[i - 1];
221
+ const prevHeight = prevToast ? (heights[prevToast.id] ?? 0) : 0;
222
+ acc += prevHeight + expandedGap;
223
+ offsets.push(acc);
224
+ }
225
+
226
+ for (let i = 0; i < activeToasts.length; i++) {
227
+ const toast = activeToasts[i];
228
+ if (!toast) continue;
229
+ byId[toast.id] = offsets[i] ?? 0;
230
+ }
231
+
232
+ for (const toast of group) {
233
+ if (byId[toast.id] != null) continue;
234
+
235
+ const previousOffset = previousExpandedOffsets[toast.id];
236
+ if (typeof previousOffset === "number") {
237
+ byId[toast.id] = previousOffset;
238
+ continue;
239
+ }
240
+
241
+ let fallback = 0;
242
+ for (const candidate of group) {
243
+ if (candidate.id === toast.id) break;
244
+ const height = heights[candidate.id] ?? 0;
245
+ fallback += height + expandedGap;
246
+ }
247
+ byId[toast.id] = fallback;
248
+ }
249
+
250
+ byPosition[pos] = group.map((toast) => byId[toast.id] ?? 0);
251
+ }
252
+
253
+ previousExpandedOffsets = byId;
254
+ return { byPosition, byId };
255
+ })();
256
+
257
+ onMount(() => {
258
+ const handleMouseMove = (event: MouseEvent) => {
259
+ if (latestPositionEntries.length === 0) return;
260
+ const { clientX: x, clientY: y } = event;
261
+ const next: Record<ToastPosition, boolean> = {
262
+ ...latestHovered,
263
+ };
264
+ for (const [pos, group] of latestPositionEntries) {
265
+ let top = Number.POSITIVE_INFINITY;
266
+ let left = Number.POSITIVE_INFINITY;
267
+ let right = Number.NEGATIVE_INFINITY;
268
+ let bottom = Number.NEGATIVE_INFINITY;
269
+ let any = false;
270
+ for (const t of group) {
271
+ if (t.index >= ANIMATION_CONFIG.MAX_VISIBLE_TOASTS) continue;
272
+ const el = document.querySelector(
273
+ `[data-toast-id="${t.id}"]`,
274
+ ) as HTMLElement | null;
275
+ if (!el) continue;
276
+ const rect = el.getBoundingClientRect();
277
+ top = Math.min(top, rect.top);
278
+ left = Math.min(left, rect.left);
279
+ right = Math.max(right, rect.right);
280
+ bottom = Math.max(bottom, rect.bottom);
281
+ any = true;
282
+ }
283
+
284
+ if (!any) {
285
+ next[pos] = false;
286
+ continue;
287
+ }
288
+
289
+ const inside = x >= left && x <= right && y >= top && y <= bottom;
290
+ next[pos] = inside;
291
+ }
292
+
293
+ const changed = (Object.keys(next) as ToastPosition[]).some(
294
+ (key) => next[key] !== hovered[key],
295
+ );
296
+ if (changed) {
297
+ hovered = next;
298
+ }
299
+ };
300
+
301
+ const handleKeyDown = (event: KeyboardEvent) => {
302
+ if (event.key !== "Escape") return;
303
+ for (const [, group] of latestPositionEntries) {
304
+ const latestToast = group?.[0];
305
+ if (!latestToast) continue;
306
+ const container = document.querySelector(
307
+ `[data-toast-id="${latestToast.id}"]`,
308
+ ) as HTMLElement | null;
309
+ if (!container) continue;
310
+ const active = document.activeElement as HTMLElement | null;
311
+ if (active && container.contains(active)) {
312
+ const closeBtn = container.querySelector(
313
+ '[aria-label="Close toast"]',
314
+ ) as HTMLButtonElement | null;
315
+ if (closeBtn) {
316
+ event.preventDefault();
317
+ closeBtn.click();
318
+ }
319
+ }
320
+ }
321
+ };
322
+
323
+ document.addEventListener("mousemove", handleMouseMove);
324
+ document.addEventListener("keydown", handleKeyDown);
325
+ return () => {
326
+ document.removeEventListener("mousemove", handleMouseMove);
327
+ document.removeEventListener("keydown", handleKeyDown);
328
+ };
329
+ });
330
+
331
+ const handleHeightChange = (id: string, height: number) => {
332
+ if (heights[id] === height) return;
333
+ heights = { ...heights, [id]: height };
334
+ };
335
+ </script>
336
+
337
+ {#if toasts.length > 0}
338
+ <div class="pointer-events-none fixed inset-0 z-50">
339
+ {#each positionEntries as [position, positionToasts]}
340
+ {@const pos = position}
341
+ {@const expandedOffsets = expandedOffsetData.byPosition[pos]}
342
+ {@const collapsedOffsets = collapsedOffsetData.byPosition[pos]}
343
+ {@const isHovered = hovered[pos]}
344
+ {@const isHeld = (heldToasts[pos]?.size ?? 0) > 0}
345
+ {@const isGroupActive = isHovered || isHeld}
346
+ {@const activeToasts = positionToasts.filter((toast) => !toast.shouldClose)}
347
+ {@const visibleStackLimit = Math.max(ANIMATION_CONFIG.MAX_VISIBLE_TOASTS - 1, 0)}
348
+ {@const maxVisibleStackIndex = Math.min(
349
+ Math.max(activeToasts.length - 1, 0),
350
+ visibleStackLimit,
351
+ )}
352
+ {@const lastVisibleToastId = activeToasts[maxVisibleStackIndex]?.id}
353
+ {@const lastVisibleRenderIndex = lastVisibleToastId != null
354
+ ? positionToasts.findIndex(
355
+ (candidate) => candidate.id === lastVisibleToastId,
356
+ )
357
+ : -1}
358
+ {@const sharedHiddenCollapsedOffset =
359
+ lastVisibleRenderIndex >= 0
360
+ ? collapsedOffsets?.[lastVisibleRenderIndex]
361
+ : undefined}
362
+ {#each positionToasts as toast, idx (toast.id)}
363
+ {@const toastIsHidden =
364
+ toast.index >= ANIMATION_CONFIG.MAX_VISIBLE_TOASTS}
365
+ {@const hiddenCollapsedOffset = toastIsHidden
366
+ ? sharedHiddenCollapsedOffset ?? collapsedOffsets?.[idx]
367
+ : collapsedOffsets?.[idx]}
368
+ {@const collapsedOffsetValue = collapsedOffsets?.[idx]}
369
+ <VarselItem
370
+ {toast}
371
+ {onRemove}
372
+ isGroupHovered={isGroupActive}
373
+ expandedOffset={expandedOffsets?.[idx] ?? 0}
374
+ {expandedGap}
375
+ onHeightChange={handleHeightChange}
376
+ onGroupHoverEnter={() => {
377
+ hovered = { ...hovered, [pos]: true };
378
+ }}
379
+ onGroupHoldChange={(holding) =>
380
+ updateHoldState(pos, toast.id, holding)}
381
+ collapsedOffset={collapsedOffsetValue}
382
+ hiddenCollapsedOffset={hiddenCollapsedOffset}
383
+ />
384
+ {/each}
385
+ {/each}
386
+ </div>
387
+ {/if}
@@ -0,0 +1,24 @@
1
+ import { type ToastData } from "./internals";
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const VarselManager: $$__sveltets_2_IsomorphicComponent<{
16
+ toasts?: ToastData[];
17
+ onRemove: (id: string) => void;
18
+ expandedGap?: number;
19
+ }, {
20
+ [evt: string]: CustomEvent<any>;
21
+ }, {}, {}, string>;
22
+ type VarselManager = InstanceType<typeof VarselManager>;
23
+ export default VarselManager;
24
+ //# sourceMappingURL=VarselManager.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VarselManager.svelte.d.ts","sourceRoot":"","sources":["../src/lib/VarselManager.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,EAGN,KAAK,SAAS,EAEd,MAAM,aAAa,CAAC;AAwXrB,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,aAAa;aAV2E,SAAS,EAAE;cAAY,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI;kBAAgB,MAAM;;;kBAU7D,CAAC;AACjF,KAAK,aAAa,GAAG,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC;AAC1D,eAAe,aAAa,CAAC"}
@@ -0,0 +1,46 @@
1
+ <script lang="ts" context="module">
2
+ export {
3
+ toast,
4
+ type ToastData,
5
+ type ToastInvoker,
6
+ type ToastPosition,
7
+ } from "./internals";
8
+ </script>
9
+
10
+ <script lang="ts">
11
+ import { onMount } from 'svelte';
12
+ import VarselManager from './VarselManager.svelte';
13
+ import {
14
+ toastState,
15
+ toasterInstanceManager,
16
+ type ToastData,
17
+ } from './internals';
18
+
19
+ export let expandedGap: number | undefined = undefined;
20
+
21
+ let toasts: ToastData[] = [];
22
+ const instanceId = toasterInstanceManager.registerInstance();
23
+
24
+ const handleRemove = (id: string) => {
25
+ toastState.remove(id);
26
+ };
27
+
28
+ onMount(() => {
29
+ toasts = toastState.getToasts();
30
+ const unsubscribe = toastState.subscribe((value) => {
31
+ toasts = value;
32
+ });
33
+ return () => {
34
+ unsubscribe();
35
+ toasterInstanceManager.unregisterInstance(instanceId);
36
+ };
37
+ });
38
+ </script>
39
+
40
+ {#if toasterInstanceManager.isActiveInstance(instanceId)}
41
+ {#if expandedGap === undefined}
42
+ <VarselManager {toasts} onRemove={handleRemove} />
43
+ {:else}
44
+ <VarselManager {toasts} onRemove={handleRemove} {expandedGap} />
45
+ {/if}
46
+ {/if}
@@ -0,0 +1,22 @@
1
+ export { toast, type ToastData, type ToastInvoker, type ToastPosition, } from "./internals";
2
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
+ $$bindings?: Bindings;
5
+ } & Exports;
6
+ (internal: unknown, props: Props & {
7
+ $$events?: Events;
8
+ $$slots?: Slots;
9
+ }): Exports & {
10
+ $set?: any;
11
+ $on?: any;
12
+ };
13
+ z_$$bindings?: Bindings;
14
+ }
15
+ declare const VarselToaster: $$__sveltets_2_IsomorphicComponent<{
16
+ expandedGap?: number | undefined;
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type VarselToaster = InstanceType<typeof VarselToaster>;
21
+ export default VarselToaster;
22
+ //# sourceMappingURL=VarselToaster.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VarselToaster.svelte.d.ts","sourceRoot":"","sources":["../src/lib/VarselToaster.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,GAClB,MAAM,aAAa,CAAC;AAiDrB,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,aAAa;kBAV0C,MAAM,GAAG,SAAS;;;kBAUmB,CAAC;AACjF,KAAK,aAAa,GAAG,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC;AAC1D,eAAe,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const FOCUSABLE_SELECTORS: string;
2
+ //# sourceMappingURL=accessibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessibility.d.ts","sourceRoot":"","sources":["../../src/lib/core/accessibility.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,QAOpB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export const FOCUSABLE_SELECTORS = [
2
+ "button:not([disabled])",
3
+ "input:not([disabled])",
4
+ "textarea:not([disabled])",
5
+ "select:not([disabled])",
6
+ "a[href]",
7
+ '[tabindex]:not([tabindex="-1"])',
8
+ ].join(", ");
@@ -0,0 +1,14 @@
1
+ export declare const ANIMATION_CONFIG: {
2
+ readonly ENTER_DURATION: 0.75;
3
+ readonly EXIT_DURATION: 0.75;
4
+ readonly STACK_DURATION: 0.75;
5
+ readonly STACK_OFFSET: 16;
6
+ readonly EXPANDED_GAP: 12;
7
+ readonly SCALE_FACTOR: 0.04;
8
+ readonly MIN_SCALE: 0.92;
9
+ readonly MAX_VISIBLE_TOASTS: 3;
10
+ readonly Z_INDEX_BASE: 50;
11
+ readonly EASING_DEFAULT: "var(--ease-vs-toast)";
12
+ readonly EASING_EXIT: "var(--ease-vs-toast)";
13
+ };
14
+ //# sourceMappingURL=animations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animations.d.ts","sourceRoot":"","sources":["../../src/lib/core/animations.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;CAYnB,CAAC"}
@@ -0,0 +1,13 @@
1
+ export const ANIMATION_CONFIG = {
2
+ ENTER_DURATION: 0.75,
3
+ EXIT_DURATION: 0.75,
4
+ STACK_DURATION: 0.75,
5
+ STACK_OFFSET: 16,
6
+ EXPANDED_GAP: 12,
7
+ SCALE_FACTOR: 0.04,
8
+ MIN_SCALE: 0.92,
9
+ MAX_VISIBLE_TOASTS: 3,
10
+ Z_INDEX_BASE: 50,
11
+ EASING_DEFAULT: "var(--ease-vs-toast)",
12
+ EASING_EXIT: "var(--ease-vs-toast)",
13
+ };
@@ -0,0 +1,64 @@
1
+ export declare const POSITION_CONFIGS: {
2
+ readonly "top-left": {
3
+ readonly animateIn: {
4
+ readonly x: -100;
5
+ readonly y: -20;
6
+ };
7
+ readonly animateOut: {
8
+ readonly x: -100;
9
+ readonly y: -100;
10
+ };
11
+ };
12
+ readonly "top-center": {
13
+ readonly animateIn: {
14
+ readonly x: 0;
15
+ readonly y: -100;
16
+ };
17
+ readonly animateOut: {
18
+ readonly x: 0;
19
+ readonly y: -100;
20
+ };
21
+ };
22
+ readonly "top-right": {
23
+ readonly animateIn: {
24
+ readonly x: 100;
25
+ readonly y: -20;
26
+ };
27
+ readonly animateOut: {
28
+ readonly x: 100;
29
+ readonly y: -100;
30
+ };
31
+ };
32
+ readonly "bottom-left": {
33
+ readonly animateIn: {
34
+ readonly x: -100;
35
+ readonly y: 20;
36
+ };
37
+ readonly animateOut: {
38
+ readonly x: -100;
39
+ readonly y: 100;
40
+ };
41
+ };
42
+ readonly "bottom-center": {
43
+ readonly animateIn: {
44
+ readonly x: 0;
45
+ readonly y: 100;
46
+ };
47
+ readonly animateOut: {
48
+ readonly x: 0;
49
+ readonly y: 100;
50
+ };
51
+ };
52
+ readonly "bottom-right": {
53
+ readonly animateIn: {
54
+ readonly x: 100;
55
+ readonly y: 20;
56
+ };
57
+ readonly animateOut: {
58
+ readonly x: 100;
59
+ readonly y: 100;
60
+ };
61
+ };
62
+ };
63
+ export type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
64
+ //# sourceMappingURL=positions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../../src/lib/core/positions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyBnB,CAAC;AAEX,MAAM,MAAM,aAAa,GACtB,UAAU,GACV,YAAY,GACZ,WAAW,GACX,aAAa,GACb,eAAe,GACf,cAAc,CAAC"}
@@ -0,0 +1,26 @@
1
+ export const POSITION_CONFIGS = {
2
+ "top-left": {
3
+ animateIn: { x: -100, y: -20 },
4
+ animateOut: { x: -100, y: -100 },
5
+ },
6
+ "top-center": {
7
+ animateIn: { x: 0, y: -100 },
8
+ animateOut: { x: 0, y: -100 },
9
+ },
10
+ "top-right": {
11
+ animateIn: { x: 100, y: -20 },
12
+ animateOut: { x: 100, y: -100 },
13
+ },
14
+ "bottom-left": {
15
+ animateIn: { x: -100, y: 20 },
16
+ animateOut: { x: -100, y: 100 },
17
+ },
18
+ "bottom-center": {
19
+ animateIn: { x: 0, y: 100 },
20
+ animateOut: { x: 0, y: 100 },
21
+ },
22
+ "bottom-right": {
23
+ animateIn: { x: 100, y: 20 },
24
+ animateOut: { x: 100, y: 100 },
25
+ },
26
+ };
@@ -0,0 +1,8 @@
1
+ import type { ToastPosition } from "./positions";
2
+ export type SwipeDirection = "top" | "bottom" | "left" | "right";
3
+ export type SwipeAxis = "x" | "y";
4
+ export declare const SWIPE_DISMISS_THRESHOLD = 45;
5
+ export declare const SWIPE_DISMISS_VELOCITY = 0.11;
6
+ export declare const SWIPE_EXIT_DISTANCE = 600;
7
+ export declare const getDefaultSwipeDirections: (position?: ToastPosition | null) => SwipeDirection[];
8
+ //# sourceMappingURL=swipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swipe.d.ts","sourceRoot":"","sources":["../../src/lib/core/swipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AACjE,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,CAAC;AAElC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,eAAO,MAAM,yBAAyB,GACrC,WAAW,aAAa,GAAG,IAAI,KAC7B,cAAc,EAwBhB,CAAC"}