@skeletonlabs/skeleton 1.7.1 → 1.8.0-dev.cbef3c34

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.
@@ -7,7 +7,7 @@ import { drawerStore } from "./stores.js";
7
7
  export let position = "left";
8
8
  export let duration = 150;
9
9
  export let bgBackdrop = "bg-surface-backdrop-token";
10
- export let blur = "backdrop-blur-xs";
10
+ export let blur = "";
11
11
  export let padding = "";
12
12
  export let bgDrawer = "bg-surface-100-800-token";
13
13
  export let border = "";
@@ -69,6 +69,18 @@ function onAction(index) {
69
69
  $toastStore[index]?.action?.response();
70
70
  toastStore.close($toastStore[index].id);
71
71
  }
72
+ function onMouseEnter(index) {
73
+ if ($toastStore[index]?.hoverable) {
74
+ toastStore.freeze(index);
75
+ classesSnackbar += " scale-[105%]";
76
+ }
77
+ }
78
+ function onMouseLeave(index) {
79
+ if ($toastStore[index]?.hoverable) {
80
+ toastStore.unfreeze(index);
81
+ classesSnackbar = classesSnackbar.replace(" scale-[105%]", "");
82
+ }
83
+ }
72
84
  $:
73
85
  classesWrapper = `${cWrapper} ${cPosition} ${zIndex} ${$$props.class || ""}`;
74
86
  $:
@@ -100,7 +112,13 @@ const [send, receive] = crossfade({
100
112
  <!-- List -->
101
113
  <div class="snackbar {classesSnackbar}">
102
114
  {#each filteredToasts as t, i (t)}
103
- <div animate:flip={{ duration }} in:receive={{ key: t.id }} out:send={{ key: t.id }}>
115
+ <div
116
+ animate:flip={{ duration }}
117
+ in:receive={{ key: t.id }}
118
+ out:send={{ key: t.id }}
119
+ on:mouseenter={() => onMouseEnter(i)}
120
+ on:mouseleave={() => onMouseLeave(i)}
121
+ >
104
122
  <!-- Toast -->
105
123
  <div
106
124
  class="toast {classesToast} {t.background ?? background} {t.classes ?? ''}"
@@ -109,10 +127,12 @@ const [send, receive] = crossfade({
109
127
  data-testid="toast"
110
128
  >
111
129
  <div class="text-base">{@html t.message}</div>
112
- <div class="toast-actions {cToastActions}">
113
- {#if t.action}<button class={buttonAction} on:click={() => onAction(i)}>{@html t.action.label}</button>{/if}
114
- <button class={buttonDismiss} on:click={() => toastStore.close(t.id)}>{buttonDismissLabel}</button>
115
- </div>
130
+ {#if t.action || !t.hideDismiss}
131
+ <div class="toast-actions {cToastActions}">
132
+ {#if t.action}<button class={buttonAction} on:click={() => onAction(i)}>{@html t.action.label}</button>{/if}
133
+ {#if !t.hideDismiss}<button class={buttonDismiss} on:click={() => toastStore.close(t.id)}>{buttonDismissLabel}</button>{/if}
134
+ </div>
135
+ {/if}
116
136
  </div>
117
137
  </div>
118
138
  {/each}
@@ -2,9 +2,13 @@ import type { ToastSettings, Toast } from './types.js';
2
2
  export declare const toastStore: {
3
3
  subscribe: (this: void, run: import("svelte/store").Subscriber<Toast[]>, invalidate?: ((value?: Toast[] | undefined) => void) | undefined) => import("svelte/store").Unsubscriber;
4
4
  /** Add a new toast to the queue. */
5
- trigger: (toast: ToastSettings) => void;
6
- /** Remove first toast in queue */
5
+ trigger: (toast: ToastSettings) => string;
6
+ /** Remove toast in queue*/
7
7
  close: (id: string) => void;
8
+ /** remain visible on hover */
9
+ freeze: (index: number) => void;
10
+ /** cancel remain visible on leave */
11
+ unfreeze: (index: number) => void;
8
12
  /** Remove all toasts from queue */
9
13
  clear: () => void;
10
14
  };
@@ -19,21 +19,27 @@ function toastService() {
19
19
  return {
20
20
  subscribe,
21
21
  /** Add a new toast to the queue. */
22
- trigger: (toast) => update((tStore) => {
22
+ trigger: (toast) => {
23
23
  const id = randomUUID();
24
- // Trigger Callback
25
- if (toast && toast.callback)
26
- toast.callback({ id, status: 'queued' });
27
- // Merge with defaults
28
- const tMerged = { ...toastDefaults, ...toast, id };
29
- // Handle auto-hide, if needed
30
- tMerged.timeoutId = handleAutoHide(tMerged);
31
- // Push into store
32
- tStore.push(tMerged);
33
- // Return
34
- return tStore;
35
- }),
36
- /** Remove first toast in queue */
24
+ update((tStore) => {
25
+ // Trigger Callback
26
+ if (toast && toast.callback)
27
+ toast.callback({ id, status: 'queued' });
28
+ // activate autohide when dismiss button is hidden.
29
+ if (toast.hideDismiss)
30
+ toast.autohide = true;
31
+ // Merge with defaults
32
+ const tMerged = { ...toastDefaults, ...toast, id };
33
+ // Handle auto-hide, if needed
34
+ tMerged.timeoutId = handleAutoHide(tMerged);
35
+ // Push into store
36
+ tStore.push(tMerged);
37
+ // Return
38
+ return tStore;
39
+ });
40
+ return id;
41
+ },
42
+ /** Remove toast in queue*/
37
43
  close: (id) => update((tStore) => {
38
44
  if (tStore.length > 0) {
39
45
  const index = tStore.findIndex((t) => t.id === id);
@@ -51,6 +57,18 @@ function toastService() {
51
57
  }
52
58
  return tStore;
53
59
  }),
60
+ /** remain visible on hover */
61
+ freeze: (index) => update((tStore) => {
62
+ if (tStore.length > 0)
63
+ clearTimeout(tStore[index].timeoutId);
64
+ return tStore;
65
+ }),
66
+ /** cancel remain visible on leave */
67
+ unfreeze: (index) => update((tStore) => {
68
+ if (tStore.length > 0)
69
+ tStore[index].timeoutId = handleAutoHide(tStore[index]);
70
+ return tStore;
71
+ }),
54
72
  /** Remove all toasts from queue */
55
73
  clear: () => set([])
56
74
  };
@@ -14,6 +14,10 @@ export interface ToastSettings {
14
14
  /** The function triggered when the button is pressed. */
15
15
  response: () => void;
16
16
  };
17
+ /** Hide dismiss button */
18
+ hideDismiss?: boolean;
19
+ /** Remain visible on Hover */
20
+ hoverable?: boolean;
17
21
  /** Provide arbitrary CSS classes to style the toast. */
18
22
  classes?: string;
19
23
  /** Callback function that fires on trigger and close. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skeletonlabs/skeleton",
3
- "version": "1.7.1",
3
+ "version": "1.8.0-dev.cbef3c34",
4
4
  "description": "A SvelteKit component library.",
5
5
  "author": "endigo9740 <chris@skeletonlabs.dev>",
6
6
  "repository": {
@@ -27,34 +27,31 @@
27
27
  "license": "MIT",
28
28
  "homepage": "https://skeleton.dev/",
29
29
  "devDependencies": {
30
- "@floating-ui/dom": "1.2.5",
31
- "@sveltejs/adapter-auto": "2.0.0",
32
- "@sveltejs/kit": "1.15.0",
30
+ "@sveltejs/adapter-auto": "2.1.0",
31
+ "@sveltejs/kit": "1.20.2",
33
32
  "@sveltejs/package": "2.0.2",
34
- "@tailwindcss/forms": "0.5.3",
35
- "@tailwindcss/typography": "0.5.9",
36
- "@testing-library/dom": "9.2.0",
33
+ "@testing-library/dom": "9.3.0",
37
34
  "@testing-library/svelte": "3.2.2",
38
- "@typescript-eslint/eslint-plugin": "5.57.0",
39
- "@typescript-eslint/parser": "5.57.0",
40
- "@vitest/coverage-c8": "0.31.0",
35
+ "@typescript-eslint/eslint-plugin": "5.59.9",
36
+ "@typescript-eslint/parser": "5.59.9",
37
+ "@vitest/coverage-c8": "0.32.0",
41
38
  "autoprefixer": "10.4.14",
42
- "eslint": "8.37.0",
39
+ "eslint": "8.42.0",
43
40
  "eslint-config-prettier": "8.8.0",
44
- "eslint-plugin-svelte": "^2.29.0",
41
+ "eslint-plugin-svelte": "^2.30.0",
45
42
  "jsdom": "21.1.1",
46
- "postcss": "8.4.21",
43
+ "postcss": "8.4.24",
47
44
  "postcss-import": "15.1.0",
48
45
  "postcss-js": "4.0.1",
49
46
  "postcss-load-config": "4.0.1",
50
- "prettier": "2.8.7",
51
- "prettier-plugin-svelte": "2.10.0",
52
- "svelte-check": "3.1.4",
53
- "tailwindcss": "3.3.1",
54
- "tslib": "2.5.0",
55
- "typescript": "4.9.5",
56
- "vite": "4.2.1",
57
- "vitest": "0.31.0"
47
+ "prettier": "2.8.8",
48
+ "prettier-plugin-svelte": "2.10.1",
49
+ "svelte-check": "3.4.3",
50
+ "tailwindcss": "3.3.2",
51
+ "tslib": "2.5.3",
52
+ "typescript": "5.0.3",
53
+ "vite": "4.3.9",
54
+ "vitest": "0.32.0"
58
55
  },
59
56
  "type": "module",
60
57
  "dependencies": {
@@ -97,7 +94,7 @@
97
94
  "format": "prettier --ignore-path .prettierignore --write --plugin-search-dir=. .",
98
95
  "test": "vitest",
99
96
  "coverage": "vitest run --coverage",
100
- "sync": "svelte-kit sync",
97
+ "sync": "svelte-kit sync && pnpm build:jss",
101
98
  "build:jss": "node ./scripts/generate-jss.js --package"
102
99
  },
103
100
  "typesVersions": {