@yusufceng1z/ding-svelte 0.0.2 → 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.
@@ -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.2",
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.2"
19
+ "@yusufceng1z/ding": "0.0.3"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "svelte": "^5.0.0"