@skeletonlabs/skeleton 1.12.0-dev.b329241e → 2.0.0-dev.b15f66c2

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 (137) hide show
  1. package/dist/components/Accordion/Accordion.svelte +15 -3
  2. package/dist/components/Accordion/Accordion.svelte.d.ts +17 -23
  3. package/dist/components/Accordion/AccordionItem.svelte +8 -3
  4. package/dist/components/Accordion/AccordionItem.svelte.d.ts +15 -25
  5. package/dist/components/AppRail/AppRailTile.svelte +1 -1
  6. package/dist/components/Autocomplete/Autocomplete.svelte +17 -7
  7. package/dist/components/Autocomplete/Autocomplete.svelte.d.ts +17 -27
  8. package/dist/components/Avatar/Avatar.svelte +1 -1
  9. package/dist/components/ConicGradient/ConicGradient.svelte +1 -1
  10. package/dist/components/FileButton/FileButton.svelte +2 -3
  11. package/dist/components/InputChip/InputChip.svelte +31 -4
  12. package/dist/components/InputChip/InputChip.svelte.d.ts +22 -27
  13. package/dist/components/Paginator/Paginator.svelte +17 -15
  14. package/dist/components/Paginator/Paginator.svelte.d.ts +2 -2
  15. package/dist/components/Paginator/types.d.ts +2 -2
  16. package/dist/components/Ratings/Ratings.svelte +1 -1
  17. package/dist/components/Stepper/Step.svelte +11 -2
  18. package/dist/components/Stepper/Step.svelte.d.ts +15 -12
  19. package/dist/components/Stepper/Stepper.svelte +21 -3
  20. package/dist/components/Stepper/Stepper.svelte.d.ts +17 -27
  21. package/dist/components/Tab/TabGroup.svelte +1 -1
  22. package/dist/components/Table/Table.svelte +1 -1
  23. package/dist/components/TreeView/TreeView.svelte +45 -2
  24. package/dist/components/TreeView/TreeView.svelte.d.ts +21 -0
  25. package/dist/components/TreeView/TreeViewDataDrivenItem.svelte +90 -0
  26. package/dist/components/TreeView/TreeViewDataDrivenItem.svelte.d.ts +27 -0
  27. package/dist/components/TreeView/TreeViewItem.svelte +220 -10
  28. package/dist/components/TreeView/TreeViewItem.svelte.d.ts +95 -2
  29. package/dist/components/TreeView/types.d.ts +18 -0
  30. package/dist/components/TreeView/types.js +1 -0
  31. package/dist/index.d.ts +15 -12
  32. package/dist/index.js +11 -12
  33. package/dist/internal/transitions.d.ts +10 -0
  34. package/dist/internal/transitions.js +11 -0
  35. package/dist/transitions/crossfade.d.ts +1 -0
  36. package/dist/transitions/crossfade.js +21 -0
  37. package/dist/types.d.ts +8 -0
  38. package/dist/types.js +1 -0
  39. package/dist/utilities/Drawer/Drawer.svelte +33 -12
  40. package/dist/utilities/Drawer/Drawer.svelte.d.ts +4 -2
  41. package/dist/utilities/Drawer/stores.d.ts +24 -1
  42. package/dist/utilities/Drawer/stores.js +31 -2
  43. package/dist/utilities/Drawer/types.d.ts +3 -0
  44. package/dist/utilities/Modal/Modal.svelte +21 -23
  45. package/dist/utilities/Modal/Modal.svelte.d.ts +17 -37
  46. package/dist/utilities/Modal/ModalTest.svelte +8 -0
  47. package/dist/utilities/Modal/ModalTest.svelte.d.ts +17 -0
  48. package/dist/utilities/Modal/stores.d.ts +24 -1
  49. package/dist/utilities/Modal/stores.js +31 -1
  50. package/dist/utilities/Modal/types.d.ts +1 -0
  51. package/dist/utilities/PrefersReducedMotion/PrefersReducedMotion.d.ts +7 -0
  52. package/dist/utilities/PrefersReducedMotion/PrefersReducedMotion.js +26 -0
  53. package/dist/utilities/TableOfContents/TableOfContents.svelte +56 -0
  54. package/dist/utilities/TableOfContents/TableOfContents.svelte.d.ts +34 -0
  55. package/dist/utilities/TableOfContents/crawler.d.ts +16 -0
  56. package/dist/utilities/TableOfContents/crawler.js +78 -0
  57. package/dist/utilities/TableOfContents/stores.d.ts +6 -0
  58. package/dist/utilities/TableOfContents/stores.js +5 -0
  59. package/dist/utilities/TableOfContents/types.d.ts +5 -0
  60. package/dist/utilities/TableOfContents/types.js +2 -0
  61. package/dist/utilities/Toast/Toast.svelte +24 -23
  62. package/dist/utilities/Toast/Toast.svelte.d.ts +17 -24
  63. package/dist/utilities/Toast/ToastTest.svelte +12 -0
  64. package/dist/utilities/Toast/ToastTest.svelte.d.ts +18 -0
  65. package/dist/utilities/Toast/stores.d.ts +27 -5
  66. package/dist/utilities/Toast/stores.js +60 -29
  67. package/dist/utilities/Toast/types.d.ts +1 -0
  68. package/dist/utilities/index.d.ts +18 -0
  69. package/dist/utilities/index.js +25 -0
  70. package/package.json +3 -16
  71. package/dist/components/TableOfContents/TableOfContents.svelte +0 -111
  72. package/dist/components/TableOfContents/TableOfContents.svelte.d.ts +0 -44
  73. package/dist/styles/all.css +0 -30
  74. package/dist/styles/elements/alerts.css +0 -17
  75. package/dist/styles/elements/badges.css +0 -31
  76. package/dist/styles/elements/breadcrumbs.css +0 -36
  77. package/dist/styles/elements/buttons.css +0 -109
  78. package/dist/styles/elements/cards.css +0 -32
  79. package/dist/styles/elements/chips.css +0 -22
  80. package/dist/styles/elements/codeblocks.css +0 -16
  81. package/dist/styles/elements/forms.css +0 -283
  82. package/dist/styles/elements/lists.css +0 -51
  83. package/dist/styles/elements/logo-clouds.css +0 -29
  84. package/dist/styles/elements/modals.css +0 -15
  85. package/dist/styles/elements/placeholders.css +0 -17
  86. package/dist/styles/elements/popups.css +0 -16
  87. package/dist/styles/elements/tables.css +0 -102
  88. package/dist/styles/partials/core.css +0 -66
  89. package/dist/styles/partials/elements.css +0 -20
  90. package/dist/styles/partials/tailwind.css +0 -16
  91. package/dist/styles/partials/typography-next.css +0 -99
  92. package/dist/styles/partials/typography-prose.css +0 -49
  93. package/dist/styles/partials/typography.css +0 -99
  94. package/dist/styles/partials/variants.css +0 -204
  95. package/dist/styles/skeleton-minimal.css +0 -30
  96. package/dist/styles/skeleton.css +0 -30
  97. package/dist/tailwind/core.cjs +0 -37
  98. package/dist/tailwind/core.d.cts +0 -5
  99. package/dist/tailwind/generated/intellisense-classes.cjs +0 -1
  100. package/dist/tailwind/generated/intellisense-classes.d.cts +0 -2729
  101. package/dist/tailwind/intellisense.cjs +0 -21
  102. package/dist/tailwind/intellisense.d.cts +0 -5
  103. package/dist/tailwind/settings.cjs +0 -20
  104. package/dist/tailwind/settings.d.cts +0 -6
  105. package/dist/tailwind/skeleton.cjs +0 -19
  106. package/dist/tailwind/skeleton.d.cts +0 -7
  107. package/dist/tailwind/theme/colors.cjs +0 -18
  108. package/dist/tailwind/theme/colors.d.cts +0 -2
  109. package/dist/tailwind/tokens/backgrounds.cjs +0 -39
  110. package/dist/tailwind/tokens/backgrounds.d.cts +0 -2
  111. package/dist/tailwind/tokens/border-radius.cjs +0 -21
  112. package/dist/tailwind/tokens/border-radius.d.cts +0 -33
  113. package/dist/tailwind/tokens/borders.cjs +0 -20
  114. package/dist/tailwind/tokens/borders.d.cts +0 -6
  115. package/dist/tailwind/tokens/fills.cjs +0 -20
  116. package/dist/tailwind/tokens/fills.d.cts +0 -15
  117. package/dist/tailwind/tokens/rings.cjs +0 -50
  118. package/dist/tailwind/tokens/rings.d.cts +0 -22
  119. package/dist/tailwind/tokens/text.cjs +0 -31
  120. package/dist/tailwind/tokens/text.d.cts +0 -21
  121. package/dist/themes/theme-crimson.css +0 -100
  122. package/dist/themes/theme-gold-nouveau.css +0 -143
  123. package/dist/themes/theme-hamlindigo.css +0 -109
  124. package/dist/themes/theme-modern.css +0 -134
  125. package/dist/themes/theme-rocket.css +0 -120
  126. package/dist/themes/theme-sahara.css +0 -133
  127. package/dist/themes/theme-seafoam.css +0 -128
  128. package/dist/themes/theme-seasonal.css +0 -114
  129. package/dist/themes/theme-skeleton.css +0 -119
  130. package/dist/themes/theme-test.css +0 -96
  131. package/dist/themes/theme-vintage.css +0 -131
  132. package/dist/utilities/DataTable/DataTable.d.ts +0 -19
  133. package/dist/utilities/DataTable/DataTable.js +0 -137
  134. package/dist/utilities/DataTable/types.d.ts +0 -33
  135. package/dist/utilities/DataTable/types.js +0 -2
  136. /package/dist/{utilities/DataTable → components/Table}/actions.d.ts +0 -0
  137. /package/dist/{utilities/DataTable → components/Table}/actions.js +0 -0
@@ -0,0 +1,78 @@
1
+ // Action: Table of Contents Crawler
2
+ import { tocStore, tocActiveId } from './stores.js';
3
+ export function tocCrawler(node, args) {
4
+ let queryElements = 'h2, h3, h4, h5, h6';
5
+ let scrollTarget = 'body';
6
+ let headings;
7
+ let permalinks = [];
8
+ function init() {
9
+ // Reset headings
10
+ headings = node.querySelectorAll(queryElements);
11
+ // Reset the permalinks array:
12
+ permalinks = [];
13
+ // Set accepted list of query elements
14
+ if (args?.queryElements)
15
+ queryElements = args.queryElements;
16
+ // Set the desired scroll target to monitor
17
+ if (args?.scrollTarget)
18
+ scrollTarget = args.scrollTarget;
19
+ // Query and process the headings
20
+ queryHeadings();
21
+ }
22
+ function queryHeadings() {
23
+ headings?.forEach((elemHeading) => {
24
+ // If heading has ignore attribute, skip it
25
+ if (elemHeading.hasAttribute('data-toc-ignore'))
26
+ return;
27
+ // If generate mode and heading ID not present, assign one
28
+ if (args?.mode === 'generate' && !elemHeading.id) {
29
+ const newHeadingId = elemHeading.firstChild?.textContent
30
+ ?.trim()
31
+ .replaceAll(/[^a-zA-Z0-9 ]/g, '')
32
+ .replaceAll(' ', '-')
33
+ .toLowerCase();
34
+ const prefix = args.prefix ? `${args.prefix}-` : '';
35
+ const suffix = args.suffix ? `-${args.suffix}` : '';
36
+ elemHeading.id = prefix + newHeadingId + suffix;
37
+ }
38
+ // Push heading data to the permalink array
39
+ permalinks.push({
40
+ element: elemHeading.nodeName.toLowerCase(),
41
+ id: elemHeading.id,
42
+ text: elemHeading.firstChild?.textContent?.trim() || ''
43
+ });
44
+ });
45
+ // Set the store with the permalink array
46
+ tocStore.set(permalinks);
47
+ }
48
+ // Listens to scroll event, determines top-most heading, provides that to the `tocActiveId` store
49
+ function onWindowScroll(e) {
50
+ if (!headings?.length)
51
+ return;
52
+ const targetElem = e.target;
53
+ if (!(targetElem instanceof HTMLElement))
54
+ throw new Error('scrollTarget is not an HTMLElement');
55
+ const scrollableTop = targetElem.getBoundingClientRect().top || 0;
56
+ const headingSizeThreshold = 40; // px
57
+ for (const elemHeading of headings) {
58
+ const headerBoundTop = elemHeading.getBoundingClientRect().top;
59
+ const offsetTop = headerBoundTop - scrollableTop + headingSizeThreshold;
60
+ if (offsetTop >= 0)
61
+ return tocActiveId.set(elemHeading.id);
62
+ }
63
+ }
64
+ // Lifecycle
65
+ init();
66
+ if (scrollTarget)
67
+ document.querySelector(scrollTarget)?.addEventListener('scroll', onWindowScroll);
68
+ return {
69
+ update(newArgs) {
70
+ args = newArgs;
71
+ init();
72
+ },
73
+ destroy() {
74
+ if (scrollTarget)
75
+ document.querySelector(scrollTarget)?.removeEventListener('scroll', onWindowScroll);
76
+ }
77
+ };
78
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="svelte" />
2
+ import type { TOCHeadingLink } from './types.js';
3
+ /** Contains the set of table of contents link data. */
4
+ export declare const tocStore: import("svelte/store").Writable<TOCHeadingLink[]>;
5
+ /** Contains the ID of the top-most visible heading when scrolling. */
6
+ export declare const tocActiveId: import("svelte/store").Writable<string>;
@@ -0,0 +1,5 @@
1
+ import { writable } from 'svelte/store';
2
+ /** Contains the set of table of contents link data. */
3
+ export const tocStore = writable([]);
4
+ /** Contains the ID of the top-most visible heading when scrolling. */
5
+ export const tocActiveId = writable(undefined);
@@ -0,0 +1,5 @@
1
+ export interface TOCHeadingLink {
2
+ element: string;
3
+ id: string;
4
+ text: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ // Table of Content Types
2
+ export {};
@@ -1,10 +1,13 @@
1
- <script>import { crossfade } from "svelte/transition";
2
- import { cubicInOut } from "svelte/easing";
3
- import { flip } from "svelte/animate";
4
- import { toastStore } from "./stores.js";
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();
5
9
  export let position = "b";
6
10
  export let max = 3;
7
- export let duration = 250;
8
11
  export let background = "variant-filled-secondary";
9
12
  export let width = "max-w-[640px]";
10
13
  export let color = "";
@@ -16,6 +19,11 @@ export let zIndex = "z-[888]";
16
19
  export let buttonAction = "btn variant-filled";
17
20
  export let buttonDismiss = "btn-icon btn-icon-sm variant-filled";
18
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 };
19
27
  const cWrapper = "flex fixed top-0 left-0 right-0 bottom-0 pointer-events-none";
20
28
  const cSnackbar = "flex flex-col gap-y-2";
21
29
  const cToast = "flex justify-between items-center pointer-events-auto";
@@ -89,21 +97,6 @@ $:
89
97
  classesToast = `${cToast} ${width} ${color} ${padding} ${spacing} ${rounded} ${shadow}`;
90
98
  $:
91
99
  filteredToasts = Array.from($toastStore).slice(0, max);
92
- const [send, receive] = crossfade({
93
- duration: (d) => Math.sqrt(d * duration),
94
- fallback(node) {
95
- const style = getComputedStyle(node);
96
- const transform = style.transform === "none" ? "" : style.transform;
97
- return {
98
- duration,
99
- easing: cubicInOut,
100
- css: (t, u) => `
101
- transform: ${transform} scale(${t}) translate(${u * animAxis.x}%, ${u * animAxis.y}%);
102
- opacity: ${t}
103
- `
104
- };
105
- }
106
- });
107
100
  </script>
108
101
 
109
102
  {#if $toastStore.length}
@@ -113,9 +106,17 @@ const [send, receive] = crossfade({
113
106
  <div class="snackbar {classesSnackbar}">
114
107
  {#each filteredToasts as t, i (t)}
115
108
  <div
116
- animate:flip={{ duration }}
117
- in:receive|global={{ key: t.id }}
118
- out:send|global={{ key: t.id }}
109
+ animate:flip={{ duration: transitions ? 250 : 0 }}
110
+ in:dynamicTransition|global={{
111
+ transition: transitionIn,
112
+ params: { x: animAxis.x, y: animAxis.y, ...transitionInParams },
113
+ enabled: transitions
114
+ }}
115
+ out:dynamicTransition|global={{
116
+ transition: transitionOut,
117
+ params: { x: animAxis.x, y: animAxis.y, ...transitionOutParams },
118
+ enabled: transitions
119
+ }}
119
120
  on:mouseenter={() => onMouseEnter(i)}
120
121
  on:mouseleave={() => onMouseLeave(i)}
121
122
  role={t.hideDismiss ? 'alert' : 'alertdialog'}
@@ -1,44 +1,37 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- declare const __propDef: {
3
- props: {
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(): {
4
7
  [x: string]: any;
5
- /** Set the toast position.*/
6
8
  position?: "b" | "br" | "tr" | "t" | "l" | "r" | "tl" | "bl" | undefined;
7
- /** Maximum toasts that can show at once.*/
8
9
  max?: number | undefined;
9
- /** The duration of the fly in/out animation.*/
10
- duration?: number | undefined;
11
- /** Provide classes to set the background color.*/
12
10
  background?: string | undefined;
13
- /** Provide classes to set width styles.*/
14
11
  width?: string | undefined;
15
- /** Provide classes to set the text color.*/
16
12
  color?: string | undefined;
17
- /** Provide classes to set the padding.*/
18
13
  padding?: string | undefined;
19
- /** Provide classes to set toast horizontal spacing.*/
20
14
  spacing?: string | undefined;
21
- /** Provide classes to set the border radius styles.*/
22
15
  rounded?: string | undefined;
23
- /** Provide classes to set the border box shadow.*/
24
16
  shadow?: string | undefined;
25
- /** Provide a class to override the z-index*/
26
17
  zIndex?: string | undefined;
27
- /** Provide styles for the action button.*/
28
18
  buttonAction?: string | undefined;
29
- /** Provide styles for the dismiss button.*/
30
19
  buttonDismiss?: string | undefined;
31
- /** The button label text.*/
32
20
  buttonDismissLabel?: string | undefined;
21
+ transitions?: boolean | undefined;
22
+ transitionIn?: TransitionIn | undefined;
23
+ transitionInParams?: TransitionParams<TransitionIn> | undefined;
24
+ transitionOut?: TransitionOut | undefined;
25
+ transitionOutParams?: TransitionParams<TransitionOut> | undefined;
33
26
  };
34
- events: {
27
+ events(): {} & {
35
28
  [evt: string]: CustomEvent<any>;
36
29
  };
37
- slots: {};
38
- };
39
- export type ToastProps = typeof __propDef.props;
40
- export type ToastEvents = typeof __propDef.events;
41
- export type ToastSlots = typeof __propDef.slots;
42
- export default class Toast extends SvelteComponentTyped<ToastProps, ToastEvents, ToastSlots> {
30
+ slots(): {};
31
+ }
32
+ export type ToastProps<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['props']>;
33
+ export type ToastEvents<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['events']>;
34
+ export type ToastSlots<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> = ReturnType<__sveltets_Render<TransitionIn, TransitionOut>['slots']>;
35
+ export default class Toast<TransitionIn extends Transition = FlyTransition, TransitionOut extends Transition = FlyTransition> extends SvelteComponentTyped<ToastProps<TransitionIn, TransitionOut>, ToastEvents<TransitionIn, TransitionOut>, ToastSlots<TransitionIn, TransitionOut>> {
43
36
  }
44
37
  export {};
@@ -0,0 +1,12 @@
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((element) => {
8
+ toastStore.trigger(element);
9
+ });
10
+ </script>
11
+
12
+ <Toast {max} />
@@ -0,0 +1,18 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { ToastSettings } from './types.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ toastSettings?: ToastSettings[] | undefined;
6
+ max?: number | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type ToastTestProps = typeof __propDef.props;
14
+ export type ToastTestEvents = typeof __propDef.events;
15
+ export type ToastTestSlots = typeof __propDef.slots;
16
+ export default class ToastTest extends SvelteComponentTyped<ToastTestProps, ToastTestEvents, ToastTestSlots> {
17
+ }
18
+ export {};
@@ -1,15 +1,37 @@
1
1
  /// <reference types="svelte" />
2
2
  import type { ToastSettings, Toast } from './types.js';
3
- export declare const toastStore: {
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(): {
4
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;
5
28
  /** Add a new toast to the queue. */
6
29
  trigger: (toast: ToastSettings) => string;
7
- /** Remove toast in queue*/
8
- close: (id: string) => void;
9
- /** remain visible on hover */
30
+ /** Remain visible on hover */
10
31
  freeze: (index: number) => void;
11
- /** cancel remain visible on leave */
32
+ /** Cancel remain visible on leave */
12
33
  unfreeze: (index: number) => void;
13
34
  /** Remove all toasts from queue */
14
35
  clear: () => void;
15
36
  };
37
+ export {};
@@ -1,23 +1,73 @@
1
1
  // Toast Store Queue
2
2
  import { writable } from 'svelte/store';
3
+ import { getContext, setContext } from 'svelte';
3
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
+ }
4
35
  // Note for security; differentiates the queued toasts
5
36
  function randomUUID() {
6
37
  const random = Math.random();
7
38
  return Number(random).toString(32);
8
39
  }
9
- // If toast should auto-hide, wait X time, then close by ID
10
- function handleAutoHide(toast) {
11
- if (toast.autohide === true) {
12
- return setTimeout(() => {
13
- toastStore.close(toast.id);
14
- }, toast.timeout);
15
- }
16
- }
17
40
  function toastService() {
18
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
+ }
19
68
  return {
20
69
  subscribe,
70
+ close,
21
71
  /** Add a new toast to the queue. */
22
72
  trigger: (toast) => {
23
73
  const id = randomUUID();
@@ -39,31 +89,13 @@ function toastService() {
39
89
  });
40
90
  return id;
41
91
  },
42
- /** Remove toast in queue*/
43
- 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
- /** remain visible on hover */
92
+ /** Remain visible on hover */
61
93
  freeze: (index) => update((tStore) => {
62
94
  if (tStore.length > 0)
63
95
  clearTimeout(tStore[index].timeoutId);
64
96
  return tStore;
65
97
  }),
66
- /** cancel remain visible on leave */
98
+ /** Cancel remain visible on leave */
67
99
  unfreeze: (index) => update((tStore) => {
68
100
  if (tStore.length > 0)
69
101
  tStore[index].timeoutId = handleAutoHide(tStore[index]);
@@ -73,4 +105,3 @@ function toastService() {
73
105
  clear: () => set([])
74
106
  };
75
107
  }
76
- export const toastStore = toastService();
@@ -1,3 +1,4 @@
1
+ export type { ToastStore } from './stores.js';
1
2
  export interface ToastSettings {
2
3
  /** Provide the toast message. Supports HTML. */
3
4
  message: string;
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,25 @@
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton",
3
- "version": "1.12.0-dev.b329241e",
3
+ "version": "2.0.0-dev.b15f66c2",
4
4
  "description": "A SvelteKit component library.",
5
5
  "author": "endigo9740 <chris@skeletonlabs.dev>",
6
6
  "repository": {
@@ -67,12 +67,6 @@
67
67
  "types": "./dist/index.d.ts",
68
68
  "svelte": "./dist/index.js",
69
69
  "default": "./dist/index.js"
70
- },
71
- "./styles/*": "./dist/styles/*",
72
- "./themes/*": "./dist/themes/*",
73
- "./tailwind/skeleton.cjs": {
74
- "types": "./dist/tailwind/skeleton.cts",
75
- "default": "./dist/tailwind/skeleton.cjs"
76
70
  }
77
71
  },
78
72
  "files": [
@@ -81,15 +75,12 @@
81
75
  "./dist/**/*.d.ts",
82
76
  "./dist/**/*.cjs",
83
77
  "./dist/**/*.d.cts",
84
- "./dist/styles/*",
85
- "./dist/tailwind/*",
86
- "./dist/themes/*",
87
78
  "!./dist/**/*.test.*"
88
79
  ],
89
80
  "scripts": {
90
81
  "dev": "vite dev",
91
82
  "build": "vite build",
92
- "package": "node ./scripts/pre-build.js && pnpm build:jss && svelte-kit sync && svelte-package && node ./scripts/post-build.js",
83
+ "package": "node ./scripts/pre-build.js && svelte-kit sync && svelte-package && node ./scripts/post-build.js",
93
84
  "preview": "vite preview",
94
85
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
95
86
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
@@ -97,16 +88,12 @@
97
88
  "format": "prettier --ignore-path .prettierignore --write --plugin-search-dir=. .",
98
89
  "test": "vitest",
99
90
  "coverage": "vitest run --coverage",
100
- "sync": "svelte-kit sync && pnpm build:jss",
101
- "build:jss": "node ./scripts/generate-jss.js --package"
91
+ "sync": "svelte-kit sync"
102
92
  },
103
93
  "typesVersions": {
104
94
  ">4.0": {
105
95
  "index.d.ts": [
106
96
  "./dist/index.d.ts"
107
- ],
108
- "tailwind/skeleton.cjs": [
109
- "./dist/tailwind/skeleton.d.cts"
110
97
  ]
111
98
  }
112
99
  }
@@ -1,111 +0,0 @@
1
- <script>import { onDestroy, onMount } from "svelte";
2
- import { fade } from "svelte/transition";
3
- export let scrollParent = "#page";
4
- export let target = "#page";
5
- export let allowedHeadings = "h2, h3";
6
- export let label = "On This Page";
7
- export let width = "w-[240px]";
8
- export let spacing = "space-y-4";
9
- export let text = "text-surface-600-300-token";
10
- export let hover = "hover:bg-primary-hover-token";
11
- export let active = "bg-primary-active-token !text-on-primary-token";
12
- export let rounded = "rounded-token";
13
- export let regionLabel = "font-bold";
14
- export let regionList = "";
15
- const cLabel = "p-4 pt-0";
16
- const cList = "list-none space-y-1";
17
- const cListItem = "px-4 py-2 cursor-pointer";
18
- let elemScrollParent;
19
- let allowedHeadingsList;
20
- let filteredHeadingsList = [];
21
- let activeHeaderId;
22
- function queryAllowedHeadingsList() {
23
- const elemTarget = document.querySelector(target);
24
- allowedHeadingsList = elemTarget?.querySelectorAll(allowedHeadings);
25
- }
26
- function generateHeadingList() {
27
- allowedHeadingsList?.forEach((elem) => {
28
- if (elem.hasAttribute("data-toc-ignore"))
29
- return;
30
- if (!elem.id) {
31
- let newId = elem.innerText.replaceAll(/[^a-zA-Z0-9 ]/g, "").replaceAll(" ", "-").toLowerCase();
32
- elem.id = `${newId}`;
33
- }
34
- if (!elem.querySelector(".permalink")) {
35
- elem.innerHTML += `<a href="#${elem.id}" class="permalink">\u{1F517}</a>`;
36
- }
37
- filteredHeadingsList.push(elem);
38
- });
39
- filteredHeadingsList = [...filteredHeadingsList];
40
- }
41
- function setHeadingClasses(headingElem) {
42
- if (headingElem.tagName === "H3")
43
- return "ml-3";
44
- if (headingElem.tagName === "H4")
45
- return "ml-6";
46
- if (headingElem.tagName === "H5")
47
- return "ml-9";
48
- if (headingElem.tagName === "H6")
49
- return "ml-12";
50
- return "";
51
- }
52
- function scrollToHeading(headingElem) {
53
- const elemTarget = document.querySelector(`#${headingElem.id}`);
54
- if (elemTarget)
55
- elemTarget.scrollIntoView({ behavior: "smooth" });
56
- }
57
- function pageScrollHandler() {
58
- const headingSizeThreshold = 40;
59
- let visibleHeadings = [];
60
- allowedHeadingsList?.forEach((header) => {
61
- const scrollableTop = elemScrollParent?.getBoundingClientRect().top || 0;
62
- const headerBoundTop = header.getBoundingClientRect().top;
63
- const offsetTop = headerBoundTop - scrollableTop + headingSizeThreshold;
64
- if (offsetTop >= 0)
65
- visibleHeadings.push(header);
66
- });
67
- activeHeaderId = visibleHeadings[0]?.id;
68
- }
69
- onMount(() => {
70
- queryAllowedHeadingsList();
71
- generateHeadingList();
72
- elemScrollParent = document.querySelector(scrollParent);
73
- elemScrollParent?.addEventListener("scroll", pageScrollHandler);
74
- pageScrollHandler();
75
- });
76
- onDestroy(() => {
77
- elemScrollParent?.removeEventListener("scroll", pageScrollHandler);
78
- });
79
- $:
80
- classesBase = `${width} ${spacing} ${$$props.class ?? ""}`;
81
- $:
82
- classesLabel = `${cLabel} ${regionLabel}`;
83
- $:
84
- classesList = `${cList} ${regionList}`;
85
- $:
86
- classesListItem = `${cListItem} ${text} ${hover} ${rounded}`;
87
- </script>
88
-
89
- <!-- @component Allows you to quickly navigate the hierarchy of headings for the current page. -->
90
-
91
- {#if filteredHeadingsList.length > 0}
92
- <div class="toc {classesBase}" transition:fade|local={{ duration: 100 }}>
93
- <nav class="toc-list {classesList}">
94
- <div class="toc-label {classesLabel}">{label}</div>
95
- {#each filteredHeadingsList as headingElem}
96
- <!-- TODO: Remove for V2 -->
97
- <!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
98
- <!-- prettier-ignore -->
99
- <li
100
- class="toc-list-item {classesListItem} {setHeadingClasses(headingElem)} {headingElem.id === activeHeaderId ? active : ''}"
101
- on:click={() => { scrollToHeading(headingElem); }}
102
- on:click
103
- on:keypress
104
- >
105
- <!-- {headingElem.innerText} -->
106
- {headingElem.firstChild?.nodeValue}
107
- </li>
108
- {/each}
109
- </nav>
110
- </div>
111
- {/if}