@yusufceng1z/ding-svelte 0.0.0-stage → 0.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yusuf Cengiz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,33 @@
1
- # Temporary Holding Version
1
+ # @yusufceng1z/ding-svelte
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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)
@@ -0,0 +1,89 @@
1
+ <script lang="ts">
2
+ import { toast, injectStyles, bindToast, onToastKey, ICONS, type Position, type Theme } from '@yusufceng1z/ding';
3
+
4
+ let { position, theme }: { position?: Position; theme?: Theme } = $props();
5
+
6
+ let state = $state(toast.getState());
7
+
8
+ $effect(() => {
9
+ injectStyles();
10
+ state = toast.getState();
11
+ return toast.subscribe(() => (state = toast.getState()));
12
+ });
13
+ $effect(() => toast.configure({ position, theme }));
14
+
15
+ function bind(node: HTMLElement, id: string) {
16
+ return { destroy: bindToast(node, id) };
17
+ }
18
+ </script>
19
+
20
+ <svelte:document onkeydown={onToastKey} />
21
+
22
+ <div
23
+ class="tst-viewport"
24
+ role="region"
25
+ aria-label="Notifications"
26
+ data-position={state.position}
27
+ data-theme={state.theme}
28
+ onpointerenter={() => toast.pause()}
29
+ onpointerleave={() => toast.resume()}
30
+ onfocusin={(e) => (e.target as Element).matches(':focus-visible') && toast.pause()}
31
+ onfocusout={() => toast.resume()}
32
+ >
33
+ <div class="tst-sr" role="status">{state.status}</div>
34
+ <div class="tst-sr" role="alert">{state.alert}</div>
35
+ {#each state.toasts as t, idx (t.id)}
36
+ {@const i = state.toasts.length - 1 - idx}
37
+ <div class="tst-slot" style:--tst-i={i} use:bind={t.id}>
38
+ <!-- Announced through the viewport's persistent live regions, not here. -->
39
+ <div
40
+ class="tst"
41
+ data-phase={t.phase}
42
+ data-type={t.type}
43
+ style:--tst-life="{t.duration}ms"
44
+ >
45
+ {#if (t.action || t.secondary) && t.duration > 0}{#key t.duration}<div class="tst-timer"></div>{/key}{/if}
46
+ {#if t.progress !== undefined}<div class="tst-progress" style:--pg={t.progress}></div>{/if}
47
+ <div class="tst-icon">
48
+ {#if t.image}
49
+ <img class="tst-media" src={t.image} alt="" />
50
+ {:else}
51
+ <div class="tst-badge">
52
+ <svg class="tst-svg" viewBox="0 0 24 24" aria-hidden="true">
53
+ {#each ICONS[t.type] as d (d)}
54
+ <path {d} pathLength="1" />
55
+ {/each}
56
+ </svg>
57
+ </div>
58
+ {/if}
59
+ </div>
60
+ <div class="tst-body">
61
+ <div class="tst-copy">
62
+ <div class="tst-title">{t.title}{#if t.count > 1}<span class="tst-count">×{t.count}</span>{/if}{#if t.meta}<span class="tst-meta">{t.meta}</span>{/if}</div>
63
+ {#if t.description}<div class="tst-desc">{t.description}</div>{/if}
64
+ </div>
65
+ {#if t.secondary}
66
+ <button type="button" class="tst-action tst-secondary" tabindex={t.phase === 'open' ? 0 : -1} onclick={() => toast.act(t.id, 'secondary')}>{t.secondary.label}</button>
67
+ {/if}
68
+ {#if t.action}
69
+ <button
70
+ type="button"
71
+ class="tst-action"
72
+ tabindex={t.phase === 'open' ? 0 : -1}
73
+ onclick={() => {
74
+ toast.act(t.id);
75
+ }}
76
+ >
77
+ {t.action.label}
78
+ </button>
79
+ {/if}
80
+ {#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)}>
82
+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18" /></svg>
83
+ </button>
84
+ {/if}
85
+ </div>
86
+ </div>
87
+ </div>
88
+ {/each}
89
+ </div>
@@ -0,0 +1,8 @@
1
+ import { type Position, type Theme } from '@yusufceng1z/ding';
2
+ type $$ComponentProps = {
3
+ position?: Position;
4
+ theme?: Theme;
5
+ };
6
+ declare const Toaster: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type Toaster = ReturnType<typeof Toaster>;
8
+ export default Toaster;
@@ -0,0 +1,2 @@
1
+ export { toast, type Position, type Theme } from '@yusufceng1z/ding';
2
+ export { default as Toaster } from './Toaster.svelte';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { toast } from '@yusufceng1z/ding';
2
+ export { default as Toaster } from './Toaster.svelte';
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "@yusufceng1z/ding-svelte",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "svelte": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "svelte": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@yusufceng1z/ding": "0.0.2"
20
+ },
21
+ "peerDependencies": {
22
+ "svelte": "^5.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "@sveltejs/package": "^3.0.2",
26
+ "svelte": "^5.0.0",
27
+ "svelte-check": "^4.7.8"
28
+ },
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
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/YusufCeng1z/ding.git",
37
+ "directory": "packages/svelte"
38
+ },
39
+ "keywords": [
40
+ "toast",
41
+ "notification",
42
+ "spring",
43
+ "animation",
44
+ "svelte"
45
+ ],
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "license": "MIT",
50
+ "author": "Yusuf Cengiz",
51
+ "scripts": {
52
+ "build": "svelte-package -i src/lib -o dist",
53
+ "typecheck": "svelte-check --tsconfig ./tsconfig.json"
54
+ }
6
55
  }