@yusufceng1z/ding-svelte 0.0.1 → 0.0.3

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.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @yusufceng1z/ding-svelte
2
+
3
+ Toasts with real spring physics for Svelte 5. One toast that morphs in place. No stylesheet to import.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i @yusufceng1z/ding-svelte
9
+ ```
10
+
11
+ ## Use
12
+
13
+ Render the toaster once, then call `toast` from anywhere.
14
+
15
+ ```svelte
16
+ <script>
17
+ import { Toaster, toast } from '@yusufceng1z/ding-svelte';
18
+ </script>
19
+
20
+ <Toaster position="top-center" theme="system" />
21
+ <button onclick={() => toast.success('Saved')}>Save</button>
22
+ ```
23
+
24
+ Options, actions, progress, sound and accessibility are covered in the [docs](https://ding.yusufcengiz.dev/docs.html).
25
+
26
+ ## Links
27
+
28
+ - [Live demo and docs](https://ding.yusufcengiz.dev)
29
+ - [Source on GitHub](https://github.com/YusufCeng1z/ding)
30
+
31
+ ## License
32
+
33
+ [MIT](LICENSE)
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
- import { toast, injectStyles, bindToast, onToastKey, ICONS, type Position, type Theme } from '@yusufceng1z/ding';
2
+ import { toast, injectStyles, bindToast, onToastKey, ICONS, type Position, type Theme, type ToastLabels } from '@yusufceng1z/ding';
3
3
 
4
- let { position, theme }: { position?: Position; theme?: Theme } = $props();
4
+ let { position, theme, labels }: { position?: Position; theme?: Theme; labels?: Partial<ToastLabels> } = $props();
5
5
 
6
6
  let state = $state(toast.getState());
7
7
 
@@ -11,6 +11,8 @@
11
11
  return toast.subscribe(() => (state = toast.getState()));
12
12
  });
13
13
  $effect(() => toast.configure({ position, theme }));
14
+ // Read the strings so the effect tracks them, not the object identity.
15
+ $effect(() => toast.configure({ labels: { region: labels?.region, dismiss: labels?.dismiss } }));
14
16
 
15
17
  function bind(node: HTMLElement, id: string) {
16
18
  return { destroy: bindToast(node, id) };
@@ -22,7 +24,7 @@
22
24
  <div
23
25
  class="tst-viewport"
24
26
  role="region"
25
- aria-label="Notifications"
27
+ aria-label={state.labels.region}
26
28
  data-position={state.position}
27
29
  data-theme={state.theme}
28
30
  onpointerenter={() => toast.pause()}
@@ -34,7 +36,7 @@
34
36
  <div class="tst-sr" role="alert">{state.alert}</div>
35
37
  {#each state.toasts as t, idx (t.id)}
36
38
  {@const i = state.toasts.length - 1 - idx}
37
- <div class="tst-slot" style:--tst-i={i} use:bind={t.id}>
39
+ <div class="tst-slot" tabindex="-1" style:--tst-i={i} use:bind={t.id}>
38
40
  <!-- Announced through the viewport's persistent live regions, not here. -->
39
41
  <div
40
42
  class="tst"
@@ -78,7 +80,7 @@
78
80
  </button>
79
81
  {/if}
80
82
  {#if t.duration === 0 && t.type !== 'loading' && !t.secondary}
81
- <button type="button" class="tst-close" aria-label="Dismiss notification" tabindex={t.phase === 'open' ? 0 : -1} onclick={() => toast.dismiss(t.id)}>
83
+ <button type="button" class="tst-close" aria-label={state.labels.dismiss} tabindex={t.phase === 'open' ? 0 : -1} onclick={() => toast.dismiss(t.id)}>
82
84
  <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18" /></svg>
83
85
  </button>
84
86
  {/if}
@@ -1,7 +1,8 @@
1
- import { type Position, type Theme } from '@yusufceng1z/ding';
1
+ import { type Position, type Theme, type ToastLabels } from '@yusufceng1z/ding';
2
2
  type $$ComponentProps = {
3
3
  position?: Position;
4
4
  theme?: Theme;
5
+ labels?: Partial<ToastLabels>;
5
6
  };
6
7
  declare const Toaster: import("svelte").Component<$$ComponentProps, {}, "">;
7
8
  type Toaster = ReturnType<typeof Toaster>;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { toast, type Position, type Theme } from '@yusufceng1z/ding';
1
+ export { toast, type Position, type Theme, type ToastLabels } from '@yusufceng1z/ding';
2
2
  export { default as Toaster } from './Toaster.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yusufceng1z/ding-svelte",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "svelte": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@yusufceng1z/ding": "0.0.1"
19
+ "@yusufceng1z/ding": "0.0.3"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "svelte": "^5.0.0"
@@ -27,6 +27,10 @@
27
27
  "svelte-check": "^4.7.8"
28
28
  },
29
29
  "description": "Svelte 5 renderer for Ding spring-physics toasts.",
30
+ "homepage": "https://ding.yusufcengiz.dev",
31
+ "bugs": {
32
+ "url": "https://github.com/YusufCeng1z/ding/issues"
33
+ },
30
34
  "repository": {
31
35
  "type": "git",
32
36
  "url": "git+https://github.com/YusufCeng1z/ding.git",