svelora 3.0.14 → 3.0.16

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 (100) hide show
  1. package/dist/components/ConfirmDialog/ConfirmDialog.svelte +167 -0
  2. package/dist/components/ConfirmDialog/ConfirmDialog.svelte.d.ts +10 -0
  3. package/dist/components/ConfirmDialog/confirm.d.ts +9 -0
  4. package/dist/components/ConfirmDialog/confirm.js +24 -0
  5. package/dist/components/ConfirmDialog/confirm.types.d.ts +22 -0
  6. package/dist/components/ConfirmDialog/confirm.types.js +1 -0
  7. package/dist/components/ConfirmDialog/index.d.ts +4 -0
  8. package/dist/components/ConfirmDialog/index.js +2 -0
  9. package/dist/components/Editor/editor.schemas.js +1 -1
  10. package/dist/components/SortableList/SortableList.svelte +54 -0
  11. package/dist/components/SortableList/SortableList.svelte.d.ts +26 -0
  12. package/dist/components/SortableList/index.d.ts +2 -0
  13. package/dist/components/SortableList/index.js +1 -0
  14. package/dist/components/SortableList/sortable-list.types.d.ts +17 -0
  15. package/dist/components/SortableList/sortable-list.types.js +1 -0
  16. package/dist/components/Table/Table.svelte +57 -1
  17. package/dist/components/Table/table.types.d.ts +2 -0
  18. package/dist/components/Table/table.variants.d.ts +34 -0
  19. package/dist/components/Table/table.variants.js +13 -0
  20. package/dist/components/Toast/Toaster.svelte +194 -137
  21. package/dist/components/Toast/index.d.ts +2 -0
  22. package/dist/components/Toast/index.js +1 -0
  23. package/dist/components/Toast/internal/AnimatedIcon.svelte +446 -0
  24. package/dist/components/Toast/internal/AnimatedIcon.svelte.d.ts +15 -0
  25. package/dist/components/Toast/internal/animated-icon.types.d.ts +1 -0
  26. package/dist/components/Toast/internal/animated-icon.types.js +1 -0
  27. package/dist/components/Toast/internal/french-toast/LICENSE.md +21 -0
  28. package/dist/components/Toast/internal/french-toast/components/CheckmarkIcon.svelte +64 -0
  29. package/dist/components/Toast/internal/french-toast/components/CheckmarkIcon.svelte.d.ts +8 -0
  30. package/dist/components/Toast/internal/french-toast/components/ErrorIcon.svelte +74 -0
  31. package/dist/components/Toast/internal/french-toast/components/ErrorIcon.svelte.d.ts +8 -0
  32. package/dist/components/Toast/internal/french-toast/components/LoaderIcon.svelte +28 -0
  33. package/dist/components/Toast/internal/french-toast/components/LoaderIcon.svelte.d.ts +8 -0
  34. package/dist/components/Toast/internal/french-toast/components/ToastBar.svelte +169 -0
  35. package/dist/components/Toast/internal/french-toast/components/ToastBar.svelte.d.ts +20 -0
  36. package/dist/components/Toast/internal/french-toast/components/ToastIcon.svelte +81 -0
  37. package/dist/components/Toast/internal/french-toast/components/ToastIcon.svelte.d.ts +7 -0
  38. package/dist/components/Toast/internal/french-toast/components/ToastMessage.svelte +13 -0
  39. package/dist/components/Toast/internal/french-toast/components/ToastMessage.svelte.d.ts +8 -0
  40. package/dist/components/Toast/internal/french-toast/components/ToastWrapper.svelte +57 -0
  41. package/dist/components/Toast/internal/french-toast/components/ToastWrapper.svelte.d.ts +12 -0
  42. package/dist/components/Toast/internal/french-toast/components/Toaster.svelte +73 -0
  43. package/dist/components/Toast/internal/french-toast/components/Toaster.svelte.d.ts +23 -0
  44. package/dist/components/Toast/internal/french-toast/core/store.svelte.d.ts +15 -0
  45. package/dist/components/Toast/internal/french-toast/core/store.svelte.js +92 -0
  46. package/dist/components/Toast/internal/french-toast/core/toast.d.ts +21 -0
  47. package/dist/components/Toast/internal/french-toast/core/toast.js +67 -0
  48. package/dist/components/Toast/internal/french-toast/core/types.d.ts +58 -0
  49. package/dist/components/Toast/internal/french-toast/core/types.js +4 -0
  50. package/dist/components/Toast/internal/french-toast/core/use-toaster.svelte.d.ts +16 -0
  51. package/dist/components/Toast/internal/french-toast/core/use-toaster.svelte.js +71 -0
  52. package/dist/components/Toast/internal/french-toast/core/utils.d.ts +6 -0
  53. package/dist/components/Toast/internal/french-toast/core/utils.js +25 -0
  54. package/dist/components/Toast/internal/french-toast/toast-context.d.ts +18 -0
  55. package/dist/components/Toast/internal/french-toast/toast-context.js +10 -0
  56. package/dist/components/Toast/internal/notify.d.ts +31 -0
  57. package/dist/components/Toast/internal/notify.js +100 -0
  58. package/dist/components/Toast/internal/toast-icons/ToastError.svelte +8 -0
  59. package/dist/components/Toast/internal/toast-icons/ToastError.svelte.d.ts +4 -0
  60. package/dist/components/Toast/internal/toast-icons/ToastInfo.svelte +8 -0
  61. package/dist/components/Toast/internal/toast-icons/ToastInfo.svelte.d.ts +4 -0
  62. package/dist/components/Toast/internal/toast-icons/ToastLoading.svelte +8 -0
  63. package/dist/components/Toast/internal/toast-icons/ToastLoading.svelte.d.ts +4 -0
  64. package/dist/components/Toast/internal/toast-icons/ToastProcessing.svelte +8 -0
  65. package/dist/components/Toast/internal/toast-icons/ToastProcessing.svelte.d.ts +4 -0
  66. package/dist/components/Toast/internal/toast-icons/ToastSuccess.svelte +8 -0
  67. package/dist/components/Toast/internal/toast-icons/ToastSuccess.svelte.d.ts +4 -0
  68. package/dist/components/Toast/internal/toast-icons/ToastWarning.svelte +8 -0
  69. package/dist/components/Toast/internal/toast-icons/ToastWarning.svelte.d.ts +4 -0
  70. package/dist/components/Toast/internal/toast-icons/index.d.ts +6 -0
  71. package/dist/components/Toast/internal/toast-icons/index.js +6 -0
  72. package/dist/components/Toast/internal/toast-icons/toast-icon.types.d.ts +4 -0
  73. package/dist/components/Toast/internal/toast-icons/toast-icon.types.js +1 -0
  74. package/dist/components/Toast/toast.d.ts +31 -16
  75. package/dist/components/Toast/toast.js +45 -20
  76. package/dist/components/Toast/toast.types.d.ts +20 -7
  77. package/dist/hooks/index.d.ts +2 -0
  78. package/dist/hooks/index.js +2 -0
  79. package/dist/hooks/internal/DragDropProviderScope.svelte +29 -0
  80. package/dist/hooks/internal/DragDropProviderScope.svelte.d.ts +7 -0
  81. package/dist/hooks/internal/SortableProvider.svelte +30 -0
  82. package/dist/hooks/internal/SortableProvider.svelte.d.ts +7 -0
  83. package/dist/hooks/internal/drag-drop-context.d.ts +12 -0
  84. package/dist/hooks/internal/drag-drop-context.js +1 -0
  85. package/dist/hooks/internal/sortable-context.d.ts +12 -0
  86. package/dist/hooks/internal/sortable-context.js +1 -0
  87. package/dist/hooks/useDragDrop/index.d.ts +1 -0
  88. package/dist/hooks/useDragDrop/index.js +1 -0
  89. package/dist/hooks/useDragDrop/useDragDrop.svelte.d.ts +40 -0
  90. package/dist/hooks/useDragDrop/useDragDrop.svelte.js +128 -0
  91. package/dist/hooks/useSortable/index.d.ts +2 -0
  92. package/dist/hooks/useSortable/index.js +2 -0
  93. package/dist/hooks/useSortable/sortable-utils.d.ts +1 -0
  94. package/dist/hooks/useSortable/sortable-utils.js +13 -0
  95. package/dist/hooks/useSortable/useSortable.svelte.d.ts +52 -0
  96. package/dist/hooks/useSortable/useSortable.svelte.js +120 -0
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.js +2 -0
  99. package/dist/mcp/svelora-docs.data.json +14 -6
  100. package/package.json +5 -3
@@ -0,0 +1,169 @@
1
+ <script lang="ts">import { prefersReducedMotion } from "../core/utils.js";
2
+ import toastApi from "../core/toast.js";
3
+ import { getToastToasterContext } from "../toast-context.js";
4
+ import ToastIcon from "./ToastIcon.svelte";
5
+ import ToastMessage from "./ToastMessage.svelte";
6
+ let { toast, position = undefined, style = "", Component = undefined, children } = $props();
7
+ const toasterContext = $derived(getToastToasterContext());
8
+ let factor = $derived.by(() => {
9
+ const top = (toast.position || position || "top-center").includes("top");
10
+ return top ? 1 : -1;
11
+ });
12
+ let animation = $derived.by(() => {
13
+ const [enter, exit] = prefersReducedMotion() ? ["_sft-fadeIn", "_sft-fadeOut"] : ["_sft-enter", "_sft-exit"];
14
+ return toast.visible ? enter : exit;
15
+ });
16
+ const showCloseButton = $derived(toast.closeButton ?? toasterContext.closeButton ?? false);
17
+ </script>
18
+
19
+ <div
20
+ class="_sft-base {toast.height ? animation : '_sft-transparent'} {toast.className || ''}"
21
+ style="{style}; {toast.style}"
22
+ style:--factor={factor}
23
+ data-svelora-toast=""
24
+ data-styled="true"
25
+ data-type={toast.type}
26
+ >
27
+ {#if Component}
28
+ <Component>
29
+ {#snippet icon()}
30
+ <ToastIcon {toast} />
31
+ {/snippet}
32
+ {#snippet message()}
33
+ <ToastMessage {toast} />
34
+ {/snippet}
35
+ </Component>
36
+ {:else if children}
37
+ {@render children({ ToastIcon, ToastMessage, toast })}
38
+ {:else}
39
+ <ToastIcon {toast} />
40
+ <div data-content="">
41
+ <div data-title="">
42
+ <ToastMessage {toast} field="message" />
43
+ </div>
44
+ {#if toast.description}
45
+ <div data-description="" class={toast.descriptionClass || ''}>
46
+ <ToastMessage {toast} field="description" />
47
+ </div>
48
+ {/if}
49
+ </div>
50
+ {#if toast.action}
51
+ <button type="button" data-button="" onclick={toast.action.onClick}>
52
+ {toast.action.label}
53
+ </button>
54
+ {/if}
55
+ {#if toast.cancel}
56
+ <button type="button" data-cancel="" onclick={toast.cancel.onClick}>
57
+ {toast.cancel.label}
58
+ </button>
59
+ {/if}
60
+ {#if showCloseButton}
61
+ <button
62
+ type="button"
63
+ data-close-button=""
64
+ aria-label={toasterContext.closeButtonAriaLabel ?? 'Close toast'}
65
+ onclick={() => toastApi.dismiss(toast.id)}
66
+ >
67
+ {#if toasterContext.closeIcon}
68
+ {@render toasterContext.closeIcon()}
69
+ {:else}
70
+ ×
71
+ {/if}
72
+ </button>
73
+ {/if}
74
+ {/if}
75
+ </div>
76
+
77
+ <style>
78
+ @keyframes enterAnimation {
79
+ 0% {
80
+ transform: translate3d(0, calc(var(--factor) * -200%), 0) scale(0.6);
81
+ opacity: 0.5;
82
+ }
83
+ 100% {
84
+ transform: translate3d(0, 0, 0) scale(1);
85
+ opacity: 1;
86
+ }
87
+ }
88
+
89
+ @keyframes exitAnimation {
90
+ 0% {
91
+ transform: translate3d(0, 0, -1px) scale(1);
92
+ opacity: 1;
93
+ }
94
+ 100% {
95
+ transform: translate3d(0, calc(var(--factor) * -150%), -1px) scale(0.6);
96
+ opacity: 0;
97
+ }
98
+ }
99
+
100
+ @keyframes fadeInAnimation {
101
+ 0% {
102
+ opacity: 0;
103
+ }
104
+ 100% {
105
+ opacity: 1;
106
+ }
107
+ }
108
+
109
+ @keyframes fadeOutAnimation {
110
+ 0% {
111
+ opacity: 1;
112
+ }
113
+ 100% {
114
+ opacity: 0;
115
+ }
116
+ }
117
+
118
+ ._sft-base {
119
+ display: flex;
120
+ align-items: center;
121
+ line-height: 1.3;
122
+ will-change: transform;
123
+ pointer-events: auto;
124
+ position: relative;
125
+ width: 100%;
126
+ }
127
+
128
+ ._sft-transparent {
129
+ opacity: 0;
130
+ }
131
+
132
+ ._sft-enter {
133
+ animation: enterAnimation 0.35s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
134
+ }
135
+
136
+ ._sft-exit {
137
+ animation: exitAnimation 0.4s cubic-bezier(0.06, 0.71, 0.55, 1) forwards;
138
+ }
139
+
140
+ ._sft-fadeIn {
141
+ animation: fadeInAnimation 0.35s cubic-bezier(0.21, 1.02, 0.73, 1) forwards;
142
+ }
143
+
144
+ ._sft-fadeOut {
145
+ animation: fadeOutAnimation 0.4s cubic-bezier(0.06, 0.71, 0.55, 1) forwards;
146
+ }
147
+
148
+ [data-content] {
149
+ flex: 1 1 auto;
150
+ min-width: 0;
151
+ }
152
+
153
+ [data-button],
154
+ [data-cancel] {
155
+ border: none;
156
+ cursor: pointer;
157
+ white-space: nowrap;
158
+ }
159
+
160
+ [data-close-button] {
161
+ background-color: var(--toast-close-bg, var(--color-surface-container-highest));
162
+ border-color: var(--toast-close-border, transparent);
163
+ color: var(--toast-close-color, var(--color-on-surface-variant));
164
+ }
165
+
166
+ [data-close-button]:hover {
167
+ background-color: var(--toast-close-hover-bg, var(--color-surface-container-high));
168
+ }
169
+ </style>
@@ -0,0 +1,20 @@
1
+ import type { Component as ComponentType, Snippet } from 'svelte';
2
+ import type { Toast, ToastPosition } from '../core/types.js';
3
+ import ToastIcon from './ToastIcon.svelte';
4
+ import ToastMessage from './ToastMessage.svelte';
5
+ interface Props {
6
+ toast: Toast;
7
+ position?: ToastPosition | undefined;
8
+ style?: string;
9
+ Component?: ComponentType<Record<string, unknown>> | undefined;
10
+ children?: Snippet<[
11
+ {
12
+ ToastIcon: typeof ToastIcon;
13
+ ToastMessage: typeof ToastMessage;
14
+ toast: Toast;
15
+ }
16
+ ]>;
17
+ }
18
+ declare const ToastBar: ComponentType<Props, {}, "">;
19
+ type ToastBar = ReturnType<typeof ToastBar>;
20
+ export default ToastBar;
@@ -0,0 +1,81 @@
1
+ <script lang="ts">import { getToastToasterContext } from "../toast-context.js";
2
+ import { ToastError, ToastInfo, ToastLoading, ToastSuccess, ToastWarning } from "../../toast-icons/index.js";
3
+ let { toast } = $props();
4
+ let { type, icon } = $derived(toast);
5
+ const toasterContext = $derived(getToastToasterContext());
6
+ const iconTone = $derived(toasterContext.iconTone ?? "standard");
7
+ const hasIcon = $derived.by(() => {
8
+ if (icon === null) return false;
9
+ if (typeof icon === "string") return true;
10
+ if (typeof icon !== "undefined") return true;
11
+ return type === "loading" || type === "error" || type === "success" || type === "warning" || type === "info";
12
+ });
13
+ </script>
14
+
15
+ {#if hasIcon}
16
+ <div data-icon="">
17
+ {#if typeof icon === 'string'}
18
+ <div class="_sft-animated">{icon}</div>
19
+ {:else if typeof icon !== 'undefined'}
20
+ {@const IconComponent = icon}
21
+ <IconComponent />
22
+ {:else if type === 'loading'}
23
+ {#if toasterContext.loadingIcon}
24
+ {@render toasterContext.loadingIcon()}
25
+ {:else}
26
+ <ToastLoading tone={iconTone} />
27
+ {/if}
28
+ {:else if type === 'error'}
29
+ {#if toasterContext.errorIcon}
30
+ {@render toasterContext.errorIcon()}
31
+ {:else}
32
+ <ToastError tone={iconTone} />
33
+ {/if}
34
+ {:else if type === 'success'}
35
+ {#if toasterContext.successIcon}
36
+ {@render toasterContext.successIcon()}
37
+ {:else}
38
+ <ToastSuccess tone={iconTone} />
39
+ {/if}
40
+ {:else if type === 'warning'}
41
+ {#if toasterContext.warningIcon}
42
+ {@render toasterContext.warningIcon()}
43
+ {:else}
44
+ <ToastWarning tone={iconTone} />
45
+ {/if}
46
+ {:else if type === 'info'}
47
+ {#if toasterContext.infoIcon}
48
+ {@render toasterContext.infoIcon()}
49
+ {:else}
50
+ <ToastInfo tone={iconTone} />
51
+ {/if}
52
+ {/if}
53
+ </div>
54
+ {/if}
55
+
56
+ <style>
57
+ [data-icon] :global(.animated-icon-root) {
58
+ width: 1.5rem;
59
+ height: 1.5rem;
60
+ padding: 0;
61
+ }
62
+
63
+ ._sft-animated {
64
+ position: relative;
65
+ transform: scale(0.6);
66
+ opacity: 0.4;
67
+ min-width: 20px;
68
+ animation: enter 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
69
+ }
70
+
71
+ @keyframes enter {
72
+ from {
73
+ transform: scale(0.6);
74
+ opacity: 0.4;
75
+ }
76
+ to {
77
+ transform: scale(1);
78
+ opacity: 1;
79
+ }
80
+ }
81
+ </style>
@@ -0,0 +1,7 @@
1
+ import type { Toast } from '../core/types.js';
2
+ interface Props {
3
+ toast: Toast;
4
+ }
5
+ declare const ToastIcon: import("svelte").Component<Props, {}, "">;
6
+ type ToastIcon = ReturnType<typeof ToastIcon>;
7
+ export default ToastIcon;
@@ -0,0 +1,13 @@
1
+ <script lang="ts">let { toast, field = "message" } = $props();
2
+ const content = $derived(field === "description" ? toast.description : toast.message);
3
+ export {};
4
+ </script>
5
+
6
+ {#if content}
7
+ {#if typeof content === 'string'}
8
+ {content}
9
+ {:else}
10
+ {@const Content = content}
11
+ <Content {toast} {...toast.props} />
12
+ {/if}
13
+ {/if}
@@ -0,0 +1,8 @@
1
+ import type { Toast } from '../core/types.js';
2
+ interface Props {
3
+ toast: Toast;
4
+ field?: 'message' | 'description';
5
+ }
6
+ declare const ToastMessage: import("svelte").Component<Props, {}, "">;
7
+ type ToastMessage = ReturnType<typeof ToastMessage>;
8
+ export default ToastMessage;
@@ -0,0 +1,57 @@
1
+ <script lang="ts">import { onMount } from "svelte";
2
+ import { prefersReducedMotion } from "../core/utils.js";
3
+ import ToastBar from "./ToastBar.svelte";
4
+ import ToastMessage from "./ToastMessage.svelte";
5
+ let { toast, setHeight, children } = $props();
6
+ let clientHeight = $state();
7
+ onMount(() => {
8
+ if (clientHeight === undefined) return;
9
+ setHeight(clientHeight);
10
+ });
11
+ let top = $derived(toast.position?.includes("top") ? 0 : null);
12
+ let bottom = $derived(toast.position?.includes("bottom") ? 0 : null);
13
+ let factor = $derived(toast.position?.includes("top") ? 1 : -1);
14
+ let justifyContent = $derived(toast.position?.includes("center") && "center" || (toast.position?.includes("right") || toast.position?.includes("end")) && "flex-end" || null);
15
+ </script>
16
+
17
+ <div
18
+ bind:clientHeight
19
+ class="_sft-wrapper"
20
+ class:_sft-active={toast.visible}
21
+ class:_sft-transition={!prefersReducedMotion()}
22
+ style:--factor={factor}
23
+ style:--offset={toast.offset}
24
+ style:top
25
+ style:bottom
26
+ style:justify-content={justifyContent}
27
+ >
28
+ {#if toast.type === 'custom'}
29
+ <ToastMessage {toast} />
30
+ {:else if children}
31
+ {@render children({ toast })}
32
+ {:else}
33
+ <ToastBar {toast} position={toast.position} />
34
+ {/if}
35
+ </div>
36
+
37
+ <style>
38
+ ._sft-wrapper {
39
+ left: 0;
40
+ right: 0;
41
+ display: flex;
42
+ position: absolute;
43
+ transform: translateY(calc(var(--offset, 16px) * var(--factor) * 1px));
44
+ }
45
+
46
+ ._sft-transition {
47
+ transition: all 230ms cubic-bezier(0.21, 1.02, 0.73, 1);
48
+ }
49
+
50
+ ._sft-active {
51
+ z-index: 9999;
52
+ }
53
+
54
+ ._sft-active > :global(*) {
55
+ pointer-events: auto;
56
+ }
57
+ </style>
@@ -0,0 +1,12 @@
1
+ import { type Snippet } from 'svelte';
2
+ import type { DOMToast } from '../core/types.js';
3
+ interface Props {
4
+ toast: DOMToast;
5
+ setHeight: (height: number) => void;
6
+ children?: Snippet<[{
7
+ toast: DOMToast;
8
+ }]>;
9
+ }
10
+ declare const ToastWrapper: import("svelte").Component<Props, {}, "">;
11
+ type ToastWrapper = ReturnType<typeof ToastWrapper>;
12
+ export default ToastWrapper;
@@ -0,0 +1,73 @@
1
+ <script lang="ts">import { useToaster } from "../core/use-toaster.svelte.js";
2
+ import { parsePosition } from "../core/utils.js";
3
+ import { setToastToasterContext } from "../toast-context.js";
4
+ import ToastWrapper from "./ToastWrapper.svelte";
5
+ let { reverseOrder = false, position = "bottom-right", toastOptions = undefined, gutter = 14, containerStyle = undefined, containerClassName = undefined, closeButton = false, closeButtonAriaLabel = "Close toast", theme = "light", iconTone = "standard", successIcon, errorIcon, warningIcon, infoIcon, loadingIcon, closeIcon } = $props();
6
+ setToastToasterContext(() => ({
7
+ closeButton,
8
+ closeButtonAriaLabel,
9
+ iconTone,
10
+ successIcon,
11
+ errorIcon,
12
+ warningIcon,
13
+ infoIcon,
14
+ loadingIcon,
15
+ closeIcon
16
+ }));
17
+ const resolvedToastOptions = $derived(toastOptions ?? {});
18
+ const toaster = useToaster(() => resolvedToastOptions);
19
+ const _toasts = $derived(toaster.mergedToasts.map((toast) => ({
20
+ ...toast,
21
+ position: toast.position || position,
22
+ offset: toaster.handlers.calculateOffset(toast, toaster.mergedToasts, {
23
+ reverseOrder,
24
+ gutter,
25
+ defaultPosition: position
26
+ })
27
+ })));
28
+ const positionAttrs = $derived(parsePosition(position));
29
+ const resolvedTheme = $derived.by(() => {
30
+ if (theme !== "system") return theme;
31
+ if (typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches) {
32
+ return "dark";
33
+ }
34
+ return "light";
35
+ });
36
+ </script>
37
+
38
+ <div
39
+ class="_sft-toaster {containerClassName || ''}"
40
+ style={containerStyle}
41
+ data-svelora-toaster=""
42
+ data-x-position={positionAttrs.xPosition}
43
+ data-y-position={positionAttrs.yPosition}
44
+ data-svelora-theme={resolvedTheme}
45
+ onmouseenter={toaster.handlers.startPause}
46
+ onmouseleave={toaster.handlers.endPause}
47
+ role="alert"
48
+ >
49
+ {#each _toasts as toast (toast.id)}
50
+ <ToastWrapper {toast} setHeight={(height) => toaster.handlers.updateHeight(toast.id, height)} />
51
+ {/each}
52
+ </div>
53
+
54
+ <style>
55
+ ._sft-toaster {
56
+ --default-offset: 16px;
57
+
58
+ position: fixed;
59
+ z-index: 9999;
60
+ top: var(--default-offset);
61
+ left: var(--default-offset);
62
+ right: var(--default-offset);
63
+ bottom: var(--default-offset);
64
+ pointer-events: none;
65
+ }
66
+
67
+ :global(._sft-toaster ._sft-base) {
68
+ background: transparent;
69
+ box-shadow: none;
70
+ padding: 0;
71
+ max-width: none;
72
+ }
73
+ </style>
@@ -0,0 +1,23 @@
1
+ import type { ToastOptions, ToastPosition } from '../core/types.js';
2
+ import type { Snippet } from 'svelte';
3
+ interface Props {
4
+ reverseOrder?: boolean;
5
+ position?: ToastPosition;
6
+ toastOptions?: ToastOptions | undefined;
7
+ gutter?: number;
8
+ containerStyle?: string | undefined;
9
+ containerClassName?: string | undefined;
10
+ closeButton?: boolean;
11
+ closeButtonAriaLabel?: string;
12
+ theme?: 'light' | 'dark' | 'system';
13
+ successIcon?: Snippet;
14
+ errorIcon?: Snippet;
15
+ warningIcon?: Snippet;
16
+ infoIcon?: Snippet;
17
+ loadingIcon?: Snippet;
18
+ closeIcon?: Snippet;
19
+ iconTone?: import('../toast-context.js').ToastIconTone;
20
+ }
21
+ declare const Toaster: import("svelte").Component<Props, {}, "">;
22
+ type Toaster = ReturnType<typeof Toaster>;
23
+ export default Toaster;
@@ -0,0 +1,15 @@
1
+ import type { DefaultToastOptions, Toast } from './types.js';
2
+ declare class ToastStore {
3
+ toasts: Toast<Record<string, unknown>>[];
4
+ pausedAt: number | null;
5
+ }
6
+ export declare const toastStore: ToastStore;
7
+ export declare function update(toast: Partial<Toast>, clearTimeout?: boolean): void;
8
+ export declare function add(toast: Toast): void;
9
+ export declare function upsert(toast: Toast): void;
10
+ export declare function dismiss(toastId?: Toast['id']): void;
11
+ export declare function remove(toastId?: Toast['id']): void;
12
+ export declare function startPause(time: number): void;
13
+ export declare function endPause(time: number): void;
14
+ export declare function mergeToastOptions(toasts: Toast[], toastOptions?: DefaultToastOptions): Toast[];
15
+ export {};
@@ -0,0 +1,92 @@
1
+ // Vendored from svelte-french-toast (MIT License)
2
+ // https://github.com/kbrgl/svelte-french-toast
3
+ const TOAST_LIMIT = 20;
4
+ const defaultTimeouts = {
5
+ blank: 4000,
6
+ error: 4000,
7
+ success: 2000,
8
+ loading: Number.POSITIVE_INFINITY,
9
+ custom: 4000,
10
+ warning: 4000,
11
+ info: 4000
12
+ };
13
+ class ToastStore {
14
+ toasts = $state([]);
15
+ pausedAt = $state(null);
16
+ }
17
+ export const toastStore = new ToastStore();
18
+ const toastTimeouts = new Map();
19
+ const addToRemoveQueue = (toastId) => {
20
+ if (toastTimeouts.has(toastId)) {
21
+ return;
22
+ }
23
+ const timeout = setTimeout(() => {
24
+ toastTimeouts.delete(toastId);
25
+ remove(toastId);
26
+ }, 1000);
27
+ toastTimeouts.set(toastId, timeout);
28
+ };
29
+ const clearFromRemoveQueue = (toastId) => {
30
+ const timeout = toastTimeouts.get(toastId);
31
+ if (timeout) {
32
+ clearTimeout(timeout);
33
+ }
34
+ };
35
+ export function update(toast, clearTimeout = true) {
36
+ if (clearTimeout && toast.id) {
37
+ clearFromRemoveQueue(toast.id);
38
+ }
39
+ toastStore.toasts = toastStore.toasts.map((t) => (t.id === toast.id ? { ...t, ...toast } : t));
40
+ }
41
+ export function add(toast) {
42
+ toastStore.toasts = [toast, ...toastStore.toasts].slice(0, TOAST_LIMIT);
43
+ }
44
+ export function upsert(toast) {
45
+ if (toastStore.toasts.find((t) => t.id === toast.id)) {
46
+ update(toast);
47
+ }
48
+ else {
49
+ add(toast);
50
+ }
51
+ }
52
+ export function dismiss(toastId) {
53
+ if (toastId) {
54
+ addToRemoveQueue(toastId);
55
+ }
56
+ else {
57
+ toastStore.toasts.forEach((toast) => {
58
+ addToRemoveQueue(toast.id);
59
+ });
60
+ }
61
+ toastStore.toasts = toastStore.toasts.map((t) => t.id === toastId || toastId === undefined ? { ...t, visible: false } : t);
62
+ }
63
+ export function remove(toastId) {
64
+ if (toastId === undefined) {
65
+ toastStore.toasts = [];
66
+ return;
67
+ }
68
+ toastStore.toasts = toastStore.toasts.filter((t) => t.id !== toastId);
69
+ }
70
+ export function startPause(time) {
71
+ toastStore.pausedAt = time;
72
+ }
73
+ export function endPause(time) {
74
+ const diff = time - (toastStore.pausedAt || 0);
75
+ toastStore.pausedAt = null;
76
+ toastStore.toasts = toastStore.toasts.map((t) => ({
77
+ ...t,
78
+ pauseDuration: t.pauseDuration + diff
79
+ }));
80
+ }
81
+ export function mergeToastOptions(toasts, toastOptions = {}) {
82
+ return toasts.map((t) => ({
83
+ ...toastOptions,
84
+ ...toastOptions[t.type],
85
+ ...t,
86
+ duration: t.duration ||
87
+ toastOptions[t.type]?.duration ||
88
+ toastOptions?.duration ||
89
+ defaultTimeouts[t.type],
90
+ style: [toastOptions.style, toastOptions[t.type]?.style, t.style].filter(Boolean).join(';')
91
+ }));
92
+ }
@@ -0,0 +1,21 @@
1
+ import { type Renderable, type DefaultToastOptions, type ToastOptions, type ValueOrFunction } from './types.js';
2
+ type Message<T extends Record<string, unknown> = Record<string, unknown>> = Renderable<T>;
3
+ type ToastHandler = <T extends Record<string, unknown> = Record<string, unknown>>(message: Message<T>, options?: ToastOptions<T>) => string;
4
+ declare const toast: {
5
+ <T extends Record<string, unknown> = Record<string, unknown>>(message: Message<T>, opts?: ToastOptions<T>): string;
6
+ error: ToastHandler;
7
+ success: ToastHandler;
8
+ loading: ToastHandler;
9
+ custom: ToastHandler;
10
+ warning: ToastHandler;
11
+ info: ToastHandler;
12
+ message: ToastHandler;
13
+ dismiss(toastId?: string): void;
14
+ remove(toastId?: string): void;
15
+ promise<T>(promise: Promise<T>, msgs: {
16
+ loading: Renderable;
17
+ success: ValueOrFunction<Renderable, T>;
18
+ error: ValueOrFunction<Renderable, unknown>;
19
+ }, opts?: DefaultToastOptions): Promise<T>;
20
+ };
21
+ export default toast;
@@ -0,0 +1,67 @@
1
+ // Vendored from svelte-french-toast (MIT License)
2
+ // https://github.com/kbrgl/svelte-french-toast
3
+ import { dismiss, remove, upsert } from './store.svelte.js';
4
+ import { resolveValue } from './types.js';
5
+ import { genId } from './utils.js';
6
+ const createToast = (message, type = 'blank', opts) => ({
7
+ createdAt: Date.now(),
8
+ visible: true,
9
+ type,
10
+ ariaProps: {
11
+ role: type === 'error' ? 'alert' : 'status',
12
+ 'aria-live': type === 'error' ? 'assertive' : 'polite'
13
+ },
14
+ message,
15
+ pauseDuration: 0,
16
+ icon: opts?.icon,
17
+ description: opts?.description,
18
+ duration: opts?.duration,
19
+ iconTheme: opts?.iconTheme,
20
+ position: opts?.position,
21
+ props: opts?.props,
22
+ className: opts?.className,
23
+ descriptionClass: opts?.descriptionClass,
24
+ style: opts?.style,
25
+ action: opts?.action,
26
+ cancel: opts?.cancel,
27
+ closeButton: opts?.closeButton,
28
+ id: opts?.id?.toString() || genId()
29
+ });
30
+ const createHandler = (type) => (message, options) => {
31
+ const nextToast = createToast(message, type, options);
32
+ upsert(nextToast);
33
+ return nextToast.id;
34
+ };
35
+ const toast = (message, opts) => createHandler('blank')(message, opts);
36
+ toast.error = createHandler('error');
37
+ toast.success = createHandler('success');
38
+ toast.loading = createHandler('loading');
39
+ toast.custom = createHandler('custom');
40
+ toast.warning = createHandler('warning');
41
+ toast.info = createHandler('info');
42
+ toast.message = createHandler('blank');
43
+ toast.dismiss = (toastId) => {
44
+ dismiss(toastId);
45
+ };
46
+ toast.remove = (toastId) => remove(toastId);
47
+ toast.promise = (promise, msgs, opts) => {
48
+ const id = toast.loading(msgs.loading, { ...opts, ...opts?.loading });
49
+ promise
50
+ .then((p) => {
51
+ toast.success(resolveValue(msgs.success, p), {
52
+ id,
53
+ ...opts,
54
+ ...opts?.success
55
+ });
56
+ return p;
57
+ })
58
+ .catch((e) => {
59
+ toast.error(resolveValue(msgs.error, e), {
60
+ id,
61
+ ...opts,
62
+ ...opts?.error
63
+ });
64
+ });
65
+ return promise;
66
+ };
67
+ export default toast;