@skeletonlabs/skeleton 2.9.2 → 3.0.0-next.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 (177) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +1 -0
  3. package/dist/core/index.js.map +1 -0
  4. package/dist/plugin/index.cjs +419 -0
  5. package/dist/plugin/index.cjs.map +1 -0
  6. package/dist/plugin/index.d.ts +270 -0
  7. package/dist/themes/index.d.ts +1117 -0
  8. package/dist/themes/index.js +935 -0
  9. package/dist/themes/index.js.map +1 -0
  10. package/package.json +31 -50
  11. package/README.md +0 -38
  12. package/dist/actions/Clipboard/clipboard.d.ts +0 -11
  13. package/dist/actions/Clipboard/clipboard.js +0 -64
  14. package/dist/actions/Filters/filter.d.ts +0 -6
  15. package/dist/actions/Filters/filter.js +0 -16
  16. package/dist/actions/Filters/svg-filters/Apollo.svelte +0 -13
  17. package/dist/actions/Filters/svg-filters/Apollo.svelte.d.ts +0 -23
  18. package/dist/actions/Filters/svg-filters/BlueNight.svelte +0 -12
  19. package/dist/actions/Filters/svg-filters/BlueNight.svelte.d.ts +0 -23
  20. package/dist/actions/Filters/svg-filters/Emerald.svelte +0 -23
  21. package/dist/actions/Filters/svg-filters/Emerald.svelte.d.ts +0 -23
  22. package/dist/actions/Filters/svg-filters/GreenFall.svelte +0 -27
  23. package/dist/actions/Filters/svg-filters/GreenFall.svelte.d.ts +0 -23
  24. package/dist/actions/Filters/svg-filters/Noir.svelte +0 -17
  25. package/dist/actions/Filters/svg-filters/Noir.svelte.d.ts +0 -23
  26. package/dist/actions/Filters/svg-filters/NoirLight.svelte +0 -19
  27. package/dist/actions/Filters/svg-filters/NoirLight.svelte.d.ts +0 -23
  28. package/dist/actions/Filters/svg-filters/Rustic.svelte +0 -14
  29. package/dist/actions/Filters/svg-filters/Rustic.svelte.d.ts +0 -23
  30. package/dist/actions/Filters/svg-filters/Summer84.svelte +0 -12
  31. package/dist/actions/Filters/svg-filters/Summer84.svelte.d.ts +0 -23
  32. package/dist/actions/Filters/svg-filters/XPro.svelte +0 -12
  33. package/dist/actions/Filters/svg-filters/XPro.svelte.d.ts +0 -23
  34. package/dist/actions/FocusTrap/focusTrap.d.ts +0 -4
  35. package/dist/actions/FocusTrap/focusTrap.js +0 -89
  36. package/dist/components/Accordion/Accordion.svelte +0 -49
  37. package/dist/components/Accordion/Accordion.svelte.d.ts +0 -56
  38. package/dist/components/Accordion/AccordionItem.svelte +0 -126
  39. package/dist/components/Accordion/AccordionItem.svelte.d.ts +0 -73
  40. package/dist/components/AppBar/AppBar.svelte +0 -53
  41. package/dist/components/AppBar/AppBar.svelte.d.ts +0 -49
  42. package/dist/components/AppRail/AppRail.svelte +0 -41
  43. package/dist/components/AppRail/AppRail.svelte.d.ts +0 -45
  44. package/dist/components/AppRail/AppRailAnchor.svelte +0 -46
  45. package/dist/components/AppRail/AppRailAnchor.svelte.d.ts +0 -38
  46. package/dist/components/AppRail/AppRailTile.svelte +0 -60
  47. package/dist/components/AppRail/AppRailTile.svelte.d.ts +0 -45
  48. package/dist/components/AppShell/AppShell.svelte +0 -72
  49. package/dist/components/AppShell/AppShell.svelte.d.ts +0 -50
  50. package/dist/components/Autocomplete/Autocomplete.svelte +0 -98
  51. package/dist/components/Autocomplete/Autocomplete.svelte.d.ts +0 -58
  52. package/dist/components/Autocomplete/types.d.ts +0 -10
  53. package/dist/components/Autocomplete/types.js +0 -2
  54. package/dist/components/Avatar/Avatar.svelte +0 -54
  55. package/dist/components/Avatar/Avatar.svelte.d.ts +0 -50
  56. package/dist/components/ConicGradient/ConicGradient.svelte +0 -77
  57. package/dist/components/ConicGradient/ConicGradient.svelte.d.ts +0 -42
  58. package/dist/components/ConicGradient/settings.d.ts +0 -9
  59. package/dist/components/ConicGradient/settings.js +0 -334
  60. package/dist/components/ConicGradient/types.d.ts +0 -10
  61. package/dist/components/ConicGradient/types.js +0 -2
  62. package/dist/components/FileButton/FileButton.svelte +0 -37
  63. package/dist/components/FileButton/FileButton.svelte.d.ts +0 -33
  64. package/dist/components/FileDropzone/FileDropzone.svelte +0 -63
  65. package/dist/components/FileDropzone/FileDropzone.svelte.d.ts +0 -55
  66. package/dist/components/InputChip/InputChip.svelte +0 -203
  67. package/dist/components/InputChip/InputChip.svelte.d.ts +0 -114
  68. package/dist/components/ListBox/ListBox.svelte +0 -29
  69. package/dist/components/ListBox/ListBox.svelte.d.ts +0 -40
  70. package/dist/components/ListBox/ListBoxItem.svelte +0 -117
  71. package/dist/components/ListBox/ListBoxItem.svelte.d.ts +0 -41
  72. package/dist/components/Paginator/Paginator.svelte +0 -190
  73. package/dist/components/Paginator/Paginator.svelte.d.ts +0 -68
  74. package/dist/components/Paginator/icons.d.ts +0 -4
  75. package/dist/components/Paginator/icons.js +0 -4
  76. package/dist/components/Paginator/types.d.ts +0 -10
  77. package/dist/components/Paginator/types.js +0 -2
  78. package/dist/components/ProgressBar/ProgressBar.svelte +0 -50
  79. package/dist/components/ProgressBar/ProgressBar.svelte.d.ts +0 -36
  80. package/dist/components/ProgressRadial/ProgressRadial.svelte +0 -73
  81. package/dist/components/ProgressRadial/ProgressRadial.svelte.d.ts +0 -38
  82. package/dist/components/Radio/RadioGroup.svelte +0 -29
  83. package/dist/components/Radio/RadioGroup.svelte.d.ts +0 -44
  84. package/dist/components/Radio/RadioItem.svelte +0 -61
  85. package/dist/components/Radio/RadioItem.svelte.d.ts +0 -41
  86. package/dist/components/RangeSlider/RangeSlider.svelte +0 -72
  87. package/dist/components/RangeSlider/RangeSlider.svelte.d.ts +0 -41
  88. package/dist/components/Ratings/Ratings.svelte +0 -52
  89. package/dist/components/Ratings/Ratings.svelte.d.ts +0 -41
  90. package/dist/components/SlideToggle/SlideToggle.svelte +0 -91
  91. package/dist/components/SlideToggle/SlideToggle.svelte.d.ts +0 -44
  92. package/dist/components/Stepper/Step.svelte +0 -97
  93. package/dist/components/Stepper/Step.svelte.d.ts +0 -56
  94. package/dist/components/Stepper/Stepper.svelte +0 -107
  95. package/dist/components/Stepper/Stepper.svelte.d.ts +0 -85
  96. package/dist/components/Stepper/types.d.ts +0 -25
  97. package/dist/components/Stepper/types.js +0 -1
  98. package/dist/components/Tab/Tab.svelte +0 -95
  99. package/dist/components/Tab/Tab.svelte.d.ts +0 -49
  100. package/dist/components/Tab/TabAnchor.svelte +0 -44
  101. package/dist/components/Tab/TabAnchor.svelte.d.ts +0 -44
  102. package/dist/components/Tab/TabGroup.svelte +0 -44
  103. package/dist/components/Tab/TabGroup.svelte.d.ts +0 -48
  104. package/dist/components/Table/Table.svelte +0 -86
  105. package/dist/components/Table/Table.svelte.d.ts +0 -42
  106. package/dist/components/Table/actions.d.ts +0 -8
  107. package/dist/components/Table/actions.js +0 -114
  108. package/dist/components/Table/types.d.ts +0 -10
  109. package/dist/components/Table/types.js +0 -1
  110. package/dist/components/Table/utils.d.ts +0 -7
  111. package/dist/components/Table/utils.js +0 -33
  112. package/dist/components/TreeView/RecursiveTreeView.svelte +0 -64
  113. package/dist/components/TreeView/RecursiveTreeView.svelte.d.ts +0 -63
  114. package/dist/components/TreeView/RecursiveTreeViewItem.svelte +0 -141
  115. package/dist/components/TreeView/RecursiveTreeViewItem.svelte.d.ts +0 -38
  116. package/dist/components/TreeView/TreeView.svelte +0 -68
  117. package/dist/components/TreeView/TreeView.svelte.d.ts +0 -55
  118. package/dist/components/TreeView/TreeViewItem.svelte +0 -319
  119. package/dist/components/TreeView/TreeViewItem.svelte.d.ts +0 -145
  120. package/dist/components/TreeView/types.d.ts +0 -17
  121. package/dist/components/TreeView/types.js +0 -1
  122. package/dist/index.d.ts +0 -75
  123. package/dist/index.js +0 -79
  124. package/dist/internal/transitions.d.ts +0 -10
  125. package/dist/internal/transitions.js +0 -11
  126. package/dist/transitions/crossfade.d.ts +0 -1
  127. package/dist/transitions/crossfade.js +0 -21
  128. package/dist/types.d.ts +0 -8
  129. package/dist/types.js +0 -1
  130. package/dist/utilities/CodeBlock/CodeBlock.svelte +0 -70
  131. package/dist/utilities/CodeBlock/CodeBlock.svelte.d.ts +0 -43
  132. package/dist/utilities/CodeBlock/stores.d.ts +0 -2
  133. package/dist/utilities/CodeBlock/stores.js +0 -3
  134. package/dist/utilities/Drawer/Drawer.svelte +0 -182
  135. package/dist/utilities/Drawer/Drawer.svelte.d.ts +0 -62
  136. package/dist/utilities/Drawer/stores.d.ts +0 -34
  137. package/dist/utilities/Drawer/stores.js +0 -50
  138. package/dist/utilities/Drawer/types.d.ts +0 -42
  139. package/dist/utilities/Drawer/types.js +0 -2
  140. package/dist/utilities/LightSwitch/LightSwitch.svelte +0 -78
  141. package/dist/utilities/LightSwitch/LightSwitch.svelte.d.ts +0 -39
  142. package/dist/utilities/LightSwitch/lightswitch.d.ts +0 -21
  143. package/dist/utilities/LightSwitch/lightswitch.js +0 -72
  144. package/dist/utilities/LocalStorageStore/LocalStorageStore.d.ts +0 -12
  145. package/dist/utilities/LocalStorageStore/LocalStorageStore.js +0 -49
  146. package/dist/utilities/Modal/Modal.svelte +0 -247
  147. package/dist/utilities/Modal/Modal.svelte.d.ts +0 -72
  148. package/dist/utilities/Modal/ModalTest.svelte +0 -8
  149. package/dist/utilities/Modal/ModalTest.svelte.d.ts +0 -17
  150. package/dist/utilities/Modal/stores.d.ts +0 -36
  151. package/dist/utilities/Modal/stores.js +0 -54
  152. package/dist/utilities/Modal/types.d.ts +0 -41
  153. package/dist/utilities/Modal/types.js +0 -2
  154. package/dist/utilities/Popup/popup.d.ts +0 -7
  155. package/dist/utilities/Popup/popup.js +0 -240
  156. package/dist/utilities/Popup/types.d.ts +0 -40
  157. package/dist/utilities/Popup/types.js +0 -2
  158. package/dist/utilities/PrefersReducedMotion/PrefersReducedMotion.d.ts +0 -7
  159. package/dist/utilities/PrefersReducedMotion/PrefersReducedMotion.js +0 -26
  160. package/dist/utilities/TableOfContents/TableOfContents.svelte +0 -56
  161. package/dist/utilities/TableOfContents/TableOfContents.svelte.d.ts +0 -34
  162. package/dist/utilities/TableOfContents/crawler.d.ts +0 -16
  163. package/dist/utilities/TableOfContents/crawler.js +0 -78
  164. package/dist/utilities/TableOfContents/stores.d.ts +0 -6
  165. package/dist/utilities/TableOfContents/stores.js +0 -5
  166. package/dist/utilities/TableOfContents/types.d.ts +0 -5
  167. package/dist/utilities/TableOfContents/types.js +0 -2
  168. package/dist/utilities/Toast/Toast.svelte +0 -150
  169. package/dist/utilities/Toast/Toast.svelte.d.ts +0 -55
  170. package/dist/utilities/Toast/ToastTest.svelte +0 -16
  171. package/dist/utilities/Toast/ToastTest.svelte.d.ts +0 -20
  172. package/dist/utilities/Toast/stores.d.ts +0 -37
  173. package/dist/utilities/Toast/stores.js +0 -107
  174. package/dist/utilities/Toast/types.d.ts +0 -35
  175. package/dist/utilities/Toast/types.js +0 -2
  176. package/dist/utilities/index.d.ts +0 -18
  177. package/dist/utilities/index.js +0 -25
@@ -1,150 +0,0 @@
1
- <script context="module">import { fly } from "svelte/transition";
2
- import { prefersReducedMotionStore } from "../../index.js";
3
- import { dynamicTransition } from "../../internal/transitions.js";
4
- </script>
5
-
6
- <script generics="TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition">import { flip } from "svelte/animate";
7
- import { getToastStore } from "./stores.js";
8
- const toastStore = getToastStore();
9
- export let position = "b";
10
- export let max = 3;
11
- export let background = "variant-filled-secondary";
12
- export let width = "max-w-[640px]";
13
- export let color = "";
14
- export let padding = "p-4";
15
- export let spacing = "space-x-4";
16
- export let rounded = "rounded-container-token";
17
- export let shadow = "shadow-lg";
18
- export let zIndex = "z-[888]";
19
- export let buttonAction = "btn variant-filled";
20
- export let buttonDismiss = "btn-icon btn-icon-sm variant-filled";
21
- export let buttonDismissLabel = "\u2715";
22
- export let transitions = !$prefersReducedMotionStore;
23
- export let transitionIn = fly;
24
- export let transitionInParams = { duration: 250 };
25
- export let transitionOut = fly;
26
- export let transitionOutParams = { duration: 250 };
27
- const cWrapper = "flex fixed top-0 left-0 right-0 bottom-0 pointer-events-none";
28
- const cSnackbar = "flex flex-col gap-y-2";
29
- const cToast = "flex justify-between items-center pointer-events-auto";
30
- const cToastActions = "flex items-center space-x-2";
31
- let cPosition;
32
- let cAlign;
33
- let animAxis = { x: 0, y: 0 };
34
- switch (position) {
35
- case "t":
36
- cPosition = "justify-center items-start";
37
- cAlign = "items-center";
38
- animAxis = { x: 0, y: -100 };
39
- break;
40
- case "b":
41
- cPosition = "justify-center items-end";
42
- cAlign = "items-center";
43
- animAxis = { x: 0, y: 100 };
44
- break;
45
- case "l":
46
- cPosition = "justify-start items-center";
47
- cAlign = "items-start";
48
- animAxis = { x: -100, y: 0 };
49
- break;
50
- case "r":
51
- cPosition = "justify-end items-center";
52
- cAlign = "items-end";
53
- animAxis = { x: 100, y: 0 };
54
- break;
55
- case "tl":
56
- cPosition = "justify-start items-start";
57
- cAlign = "items-start";
58
- animAxis = { x: -100, y: 0 };
59
- break;
60
- case "tr":
61
- cPosition = "justify-end items-start";
62
- cAlign = "items-end";
63
- animAxis = { x: 100, y: 0 };
64
- break;
65
- case "bl":
66
- cPosition = "justify-start items-end";
67
- cAlign = "items-start";
68
- animAxis = { x: -100, y: 0 };
69
- break;
70
- case "br":
71
- cPosition = "justify-end items-end";
72
- cAlign = "items-end";
73
- animAxis = { x: 100, y: 0 };
74
- break;
75
- }
76
- function onAction(index) {
77
- $toastStore[index]?.action?.response();
78
- toastStore.close($toastStore[index].id);
79
- }
80
- function onMouseEnter(index) {
81
- if ($toastStore[index]?.hoverable) {
82
- toastStore.freeze(index);
83
- classesSnackbar += " scale-[105%]";
84
- }
85
- }
86
- function onMouseLeave(index) {
87
- if ($toastStore[index]?.hoverable) {
88
- toastStore.unfreeze(index);
89
- classesSnackbar = classesSnackbar.replace(" scale-[105%]", "");
90
- }
91
- }
92
- let wrapperVisible = false;
93
- $:
94
- classesWrapper = `${cWrapper} ${cPosition} ${zIndex} ${$$props.class || ""}`;
95
- $:
96
- classesSnackbar = `${cSnackbar} ${cAlign} ${padding}`;
97
- $:
98
- classesToast = `${cToast} ${width} ${color} ${padding} ${spacing} ${rounded} ${shadow}`;
99
- $:
100
- filteredToasts = Array.from($toastStore).slice(0, max);
101
- $:
102
- if (filteredToasts.length) {
103
- wrapperVisible = true;
104
- }
105
- </script>
106
-
107
- {#if filteredToasts.length > 0 || wrapperVisible}
108
- <!-- Wrapper -->
109
- <div class="snackbar-wrapper {classesWrapper}" data-testid="snackbar-wrapper">
110
- <!-- List -->
111
- <div class="snackbar {classesSnackbar}">
112
- {#each filteredToasts as t, i (t)}
113
- <div
114
- animate:flip={{ duration: transitions ? 250 : 0 }}
115
- in:dynamicTransition|global={{
116
- transition: transitionIn,
117
- params: { x: animAxis.x, y: animAxis.y, ...transitionInParams },
118
- enabled: transitions
119
- }}
120
- out:dynamicTransition|global={{
121
- transition: transitionOut,
122
- params: { x: animAxis.x, y: animAxis.y, ...transitionOutParams },
123
- enabled: transitions
124
- }}
125
- on:outroend={() => {
126
- const outroFinishedForLastToastOnQueue = filteredToasts.length === 0;
127
- if (outroFinishedForLastToastOnQueue) wrapperVisible = false;
128
- }}
129
- on:mouseenter={() => onMouseEnter(i)}
130
- on:mouseleave={() => onMouseLeave(i)}
131
- role={t.hideDismiss ? 'alert' : 'alertdialog'}
132
- aria-live="polite"
133
- >
134
- <!-- Toast -->
135
- <div class="toast {classesToast} {t.background ?? background} {t.classes ?? ''}" data-testid="toast">
136
- <div class="text-base">{@html t.message}</div>
137
- {#if t.action || !t.hideDismiss}
138
- <div class="toast-actions {cToastActions}">
139
- {#if t.action}<button class={buttonAction} on:click={() => onAction(i)}>{@html t.action.label}</button>{/if}
140
- {#if !t.hideDismiss}<button class={buttonDismiss} aria-label="Dismiss toast" on:click={() => toastStore.close(t.id)}
141
- >{buttonDismissLabel}</button
142
- >{/if}
143
- </div>
144
- {/if}
145
- </div>
146
- </div>
147
- {/each}
148
- </div>
149
- </div>
150
- {/if}
@@ -1,55 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- import { fly } from 'svelte/transition';
3
- import { type Transition, type TransitionParams } from '../../index.js';
4
- type FlyTransition = typeof fly;
5
- declare class __sveltets_Render<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> {
6
- props(): {
7
- [x: string]: any;
8
- /** Set the toast position.*/
9
- position?: "b" | "br" | "tr" | "t" | "l" | "r" | "tl" | "bl" | undefined;
10
- /** Maximum toasts that can show at once.*/
11
- max?: number | undefined;
12
- /** Provide classes to set the background color.*/
13
- background?: string | undefined;
14
- /** Provide classes to set width styles.*/
15
- width?: string | undefined;
16
- /** Provide classes to set the text color.*/
17
- color?: string | undefined;
18
- /** Provide classes to set the padding.*/
19
- padding?: string | undefined;
20
- /** Provide classes to set toast horizontal spacing.*/
21
- spacing?: string | undefined;
22
- /** Provide classes to set the border radius styles.*/
23
- rounded?: string | undefined;
24
- /** Provide classes to set the border box shadow.*/
25
- shadow?: string | undefined;
26
- /** Provide a class to override the z-index*/
27
- zIndex?: string | undefined;
28
- /** Provide styles for the action button.*/
29
- buttonAction?: string | undefined;
30
- /** Provide styles for the dismiss button.*/
31
- buttonDismiss?: string | undefined;
32
- /** The button label text.*/
33
- buttonDismissLabel?: string | undefined;
34
- /** Enable/Disable transitions*/
35
- transitions?: boolean | undefined;
36
- /** Provide the transition to used on entry.*/
37
- transitionIn?: TransitionIn | undefined;
38
- /** Transition params provided to `transitionIn`.*/
39
- transitionInParams?: TransitionParams<TransitionIn> | undefined;
40
- /** Provide the transition to used on exit.*/
41
- transitionOut?: TransitionOut | undefined;
42
- /** Transition params provided to `transitionOut`.*/
43
- transitionOutParams?: TransitionParams<TransitionOut> | undefined;
44
- };
45
- events(): {} & {
46
- [evt: string]: CustomEvent<any>;
47
- };
48
- slots(): {};
49
- }
50
- export type ToastProps<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['props']>;
51
- export type ToastEvents<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['events']>;
52
- export type ToastSlots<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['slots']>;
53
- export default class Toast<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> extends SvelteComponentTyped<ToastProps<TransitionIn, TransitionOut>, ToastEvents<TransitionIn, TransitionOut>, ToastSlots<TransitionIn, TransitionOut>> {
54
- }
55
- export {};
@@ -1,16 +0,0 @@
1
- <script>import { initializeToastStore, getToastStore } from "./stores.js";
2
- import Toast from "./Toast.svelte";
3
- export let toastSettings = [];
4
- export let max = void 0;
5
- initializeToastStore();
6
- const toastStore = getToastStore();
7
- toastSettings.forEach(({ triggerDelay, ...settings }) => {
8
- if (triggerDelay) {
9
- setTimeout(() => toastStore.trigger(settings), triggerDelay);
10
- } else {
11
- toastStore.trigger(settings);
12
- }
13
- });
14
- </script>
15
-
16
- <Toast {max} />
@@ -1,20 +0,0 @@
1
- import { SvelteComponentTyped } from "svelte";
2
- import type { ToastSettings } from './types.js';
3
- declare const __propDef: {
4
- props: {
5
- toastSettings?: (ToastSettings & {
6
- triggerDelay?: number | undefined;
7
- })[] | undefined;
8
- max?: number | undefined;
9
- };
10
- events: {
11
- [evt: string]: CustomEvent<any>;
12
- };
13
- slots: {};
14
- };
15
- export type ToastTestProps = typeof __propDef.props;
16
- export type ToastTestEvents = typeof __propDef.events;
17
- export type ToastTestSlots = typeof __propDef.slots;
18
- export default class ToastTest extends SvelteComponentTyped<ToastTestProps, ToastTestEvents, ToastTestSlots> {
19
- }
20
- export {};
@@ -1,37 +0,0 @@
1
- /// <reference types="svelte" />
2
- import type { ToastSettings, Toast } from './types.js';
3
- /**
4
- * Retrieves the `toastStore`.
5
- *
6
- * This can *ONLY* be called from the **top level** of components!
7
- *
8
- * @example
9
- * ```svelte
10
- * <script>
11
- * import { getToastStore } from "@skeletonlabs/skeleton";
12
- *
13
- * const toastStore = getToastStore();
14
- *
15
- * toastStore.open({ message: "Welcome!" });
16
- * </script>
17
- * ```
18
- */
19
- export declare function getToastStore(): ToastStore;
20
- /**
21
- * Initializes the `toastStore`.
22
- */
23
- export declare function initializeToastStore(): ToastStore;
24
- export type ToastStore = ReturnType<typeof toastService>;
25
- declare function toastService(): {
26
- subscribe: (this: void, run: import("svelte/store").Subscriber<Toast[]>, invalidate?: import("svelte/store").Invalidator<Toast[]> | undefined) => import("svelte/store").Unsubscriber;
27
- close: (id: string) => void;
28
- /** Add a new toast to the queue. */
29
- trigger: (toast: ToastSettings) => string;
30
- /** Remain visible on hover */
31
- freeze: (index: number) => void;
32
- /** Cancel remain visible on leave */
33
- unfreeze: (index: number) => void;
34
- /** Remove all toasts from queue */
35
- clear: () => void;
36
- };
37
- export {};
@@ -1,107 +0,0 @@
1
- // Toast Store Queue
2
- import { writable } from 'svelte/store';
3
- import { getContext, setContext } from 'svelte';
4
- const toastDefaults = { message: 'Missing Toast Message', autohide: true, timeout: 5000 };
5
- const TOAST_STORE_KEY = 'toastStore';
6
- /**
7
- * Retrieves the `toastStore`.
8
- *
9
- * This can *ONLY* be called from the **top level** of components!
10
- *
11
- * @example
12
- * ```svelte
13
- * <script>
14
- * import { getToastStore } from "@skeletonlabs/skeleton";
15
- *
16
- * const toastStore = getToastStore();
17
- *
18
- * toastStore.open({ message: "Welcome!" });
19
- * </script>
20
- * ```
21
- */
22
- export function getToastStore() {
23
- const toastStore = getContext(TOAST_STORE_KEY);
24
- if (!toastStore)
25
- throw new Error('toastStore is not initialized. Please ensure that `initializeStores()` is invoked in the root layout file of this app!');
26
- return toastStore;
27
- }
28
- /**
29
- * Initializes the `toastStore`.
30
- */
31
- export function initializeToastStore() {
32
- const toastStore = toastService();
33
- return setContext(TOAST_STORE_KEY, toastStore);
34
- }
35
- // Note for security; differentiates the queued toasts
36
- function randomUUID() {
37
- const random = Math.random();
38
- return Number(random).toString(32);
39
- }
40
- function toastService() {
41
- const { subscribe, set, update } = writable([]);
42
- /** Remove toast in queue*/
43
- const close = (id) => update((tStore) => {
44
- if (tStore.length > 0) {
45
- const index = tStore.findIndex((t) => t.id === id);
46
- const selectedToast = tStore[index];
47
- if (selectedToast) {
48
- // Trigger Callback
49
- if (selectedToast.callback)
50
- selectedToast.callback({ id, status: 'closed' });
51
- // Clear timeout
52
- if (selectedToast.timeoutId)
53
- clearTimeout(selectedToast.timeoutId);
54
- // Remove
55
- tStore.splice(index, 1);
56
- }
57
- }
58
- return tStore;
59
- });
60
- // If toast should auto-hide, wait X time, then close by ID
61
- function handleAutoHide(toast) {
62
- if (toast.autohide === true) {
63
- return setTimeout(() => {
64
- close(toast.id);
65
- }, toast.timeout);
66
- }
67
- }
68
- return {
69
- subscribe,
70
- close,
71
- /** Add a new toast to the queue. */
72
- trigger: (toast) => {
73
- const id = randomUUID();
74
- update((tStore) => {
75
- // Trigger Callback
76
- if (toast && toast.callback)
77
- toast.callback({ id, status: 'queued' });
78
- // activate autohide when dismiss button is hidden.
79
- if (toast.hideDismiss)
80
- toast.autohide = true;
81
- // Merge with defaults
82
- const tMerged = { ...toastDefaults, ...toast, id };
83
- // Handle auto-hide, if needed
84
- tMerged.timeoutId = handleAutoHide(tMerged);
85
- // Push into store
86
- tStore.push(tMerged);
87
- // Return
88
- return tStore;
89
- });
90
- return id;
91
- },
92
- /** Remain visible on hover */
93
- freeze: (index) => update((tStore) => {
94
- if (tStore.length > 0)
95
- clearTimeout(tStore[index].timeoutId);
96
- return tStore;
97
- }),
98
- /** Cancel remain visible on leave */
99
- unfreeze: (index) => update((tStore) => {
100
- if (tStore.length > 0)
101
- tStore[index].timeoutId = handleAutoHide(tStore[index]);
102
- return tStore;
103
- }),
104
- /** Remove all toasts from queue */
105
- clear: () => set([])
106
- };
107
- }
@@ -1,35 +0,0 @@
1
- export type { ToastStore } from './stores.js';
2
- export interface ToastSettings {
3
- /** Provide the toast message. Supports HTML. */
4
- message: string;
5
- /** Provide CSS classes to set the background color. */
6
- background?: string;
7
- /** Enables auto-hide after the timeout duration. */
8
- autohide?: boolean;
9
- /** Set the auto-hide timeout duration. */
10
- timeout?: number;
11
- /** Generate a custom action button UI. */
12
- action?: {
13
- /** The button label. Supports HTML. */
14
- label: string;
15
- /** The function triggered when the button is pressed. */
16
- response: () => void;
17
- };
18
- /** Hide dismiss button */
19
- hideDismiss?: boolean;
20
- /** Remain visible on Hover */
21
- hoverable?: boolean;
22
- /** Provide arbitrary CSS classes to style the toast. */
23
- classes?: string;
24
- /** Callback function that fires on trigger and close. */
25
- callback?: (response: {
26
- id: string;
27
- status: 'queued' | 'closed';
28
- }) => void;
29
- }
30
- export interface Toast extends ToastSettings {
31
- /** A UUID will be auto-assigned on `.trigger()`. */
32
- id: string;
33
- /** The id of the `setTimeout` if `autohide` is enabled */
34
- timeoutId?: ReturnType<typeof setTimeout>;
35
- }
@@ -1,2 +0,0 @@
1
- // Toast interface types
2
- export {};
@@ -1,18 +0,0 @@
1
- /**
2
- * Used to initialize the stores for the `Modal`, `Toast`, and `Drawer` utilities.
3
- *
4
- * @example
5
- * ```svelte
6
- * <!-- App's root +layout.svelte -->
7
- * <script>
8
- * import { initializeStores, Toast, Modal, Drawer } from "@skeletonlabs/skeleton";
9
- *
10
- * initializeStores();
11
- * </script>
12
- *
13
- * <Toast />
14
- * <Modal />
15
- * <Drawer />
16
- * ```
17
- */
18
- export declare function initializeStores(): void;
@@ -1,25 +0,0 @@
1
- import { initializeModalStore } from './Modal/stores.js';
2
- import { initializeToastStore } from './Toast/stores.js';
3
- import { initializeDrawerStore } from './Drawer/stores.js';
4
- /**
5
- * Used to initialize the stores for the `Modal`, `Toast`, and `Drawer` utilities.
6
- *
7
- * @example
8
- * ```svelte
9
- * <!-- App's root +layout.svelte -->
10
- * <script>
11
- * import { initializeStores, Toast, Modal, Drawer } from "@skeletonlabs/skeleton";
12
- *
13
- * initializeStores();
14
- * </script>
15
- *
16
- * <Toast />
17
- * <Modal />
18
- * <Drawer />
19
- * ```
20
- */
21
- export function initializeStores() {
22
- initializeModalStore();
23
- initializeToastStore();
24
- initializeDrawerStore();
25
- }