@yusufceng1z/ding-react 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,37 @@
1
- # Temporary Holding Version
1
+ # @yusufceng1z/ding-react
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 React 18+. One toast that morphs in place. No stylesheet to import.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i @yusufceng1z/ding-react
9
+ ```
10
+
11
+ ## Use
12
+
13
+ Render the toaster once, then call `toast` from anywhere.
14
+
15
+ ```tsx
16
+ import { Toaster, toast } from '@yusufceng1z/ding-react';
17
+
18
+ export default function App() {
19
+ return (
20
+ <>
21
+ <Toaster position="top-center" theme="system" />
22
+ <button onClick={() => toast.success('Saved')}>Save</button>
23
+ </>
24
+ );
25
+ }
26
+ ```
27
+
28
+ Options, actions, progress, sound and accessibility are covered in the [docs](https://ding.yusufcengiz.dev/docs.html).
29
+
30
+ ## Links
31
+
32
+ - [Live demo and docs](https://ding.yusufcengiz.dev)
33
+ - [Source on GitHub](https://github.com/YusufCeng1z/ding)
34
+
35
+ ## License
36
+
37
+ [MIT](LICENSE)
package/dist/index.cjs ADDED
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.tsx
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Toaster: () => Toaster,
24
+ toast: () => import_ding.toast
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_react = require("react");
28
+ var import_ding = require("@yusufceng1z/ding");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ function Item({ t, i }) {
31
+ const slot = (0, import_react.useRef)(null);
32
+ (0, import_react.useEffect)(() => slot.current ? (0, import_ding.bindToast)(slot.current, t.id) : void 0, [t.id]);
33
+ const sticky = t.duration === 0 && t.type !== "loading" && !t.secondary;
34
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: slot, className: "tst-slot", style: { "--tst-i": i }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
35
+ "div",
36
+ {
37
+ className: "tst",
38
+ "data-phase": t.phase,
39
+ "data-type": t.type,
40
+ style: { "--tst-life": `${t.duration}ms` },
41
+ children: [
42
+ (t.action || t.secondary) && t.duration > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tst-timer" }, t.duration),
43
+ t.progress !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tst-progress", style: { "--pg": t.progress } }),
44
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tst-icon", children: t.image ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { className: "tst-media", src: t.image, alt: "" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tst-badge", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className: "tst-svg", viewBox: "0 0 24 24", "aria-hidden": "true", children: import_ding.ICONS[t.type].map((d) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d, pathLength: 1 }, d)) }) }) }),
45
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tst-body", children: [
46
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tst-copy", children: [
47
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tst-title", children: [
48
+ t.title,
49
+ t.count > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "tst-count", children: [
50
+ "\xD7",
51
+ t.count
52
+ ] }),
53
+ t.meta && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "tst-meta", children: t.meta })
54
+ ] }),
55
+ t.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tst-desc", children: t.description })
56
+ ] }),
57
+ t.secondary && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "tst-action tst-secondary", tabIndex: t.phase === "open" ? 0 : -1, onClick: () => import_ding.toast.act(t.id, "secondary"), children: t.secondary.label }),
58
+ t.action && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
+ "button",
60
+ {
61
+ type: "button",
62
+ className: "tst-action",
63
+ tabIndex: t.phase === "open" ? 0 : -1,
64
+ onClick: () => {
65
+ import_ding.toast.act(t.id);
66
+ },
67
+ children: t.action.label
68
+ }
69
+ ),
70
+ sticky && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "tst-close", "aria-label": "Dismiss notification", tabIndex: t.phase === "open" ? 0 : -1, onClick: () => import_ding.toast.dismiss(t.id), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 6l12 12M18 6L6 18" }) }) })
71
+ ] })
72
+ ]
73
+ }
74
+ ) });
75
+ }
76
+ function Toaster({ position, theme }) {
77
+ const state = (0, import_react.useSyncExternalStore)(import_ding.toast.subscribe, import_ding.toast.getState, import_ding.toast.getState);
78
+ (0, import_react.useEffect)(() => (0, import_ding.injectStyles)(), []);
79
+ (0, import_react.useEffect)(() => import_ding.toast.configure({ position, theme }), [position, theme]);
80
+ (0, import_react.useEffect)(() => {
81
+ document.addEventListener("keydown", import_ding.onToastKey);
82
+ return () => document.removeEventListener("keydown", import_ding.onToastKey);
83
+ }, []);
84
+ const n = state.toasts.length;
85
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
86
+ "div",
87
+ {
88
+ className: "tst-viewport",
89
+ role: "region",
90
+ "aria-label": "Notifications",
91
+ "data-position": state.position,
92
+ "data-theme": state.theme,
93
+ onPointerEnter: () => import_ding.toast.pause(),
94
+ onPointerLeave: () => import_ding.toast.resume(),
95
+ onFocus: (e) => e.target.matches(":focus-visible") && import_ding.toast.pause(),
96
+ onBlur: () => import_ding.toast.resume(),
97
+ children: [
98
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tst-sr", role: "status", children: state.status }),
99
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tst-sr", role: "alert", children: state.alert }),
100
+ state.toasts.map((t, idx) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Item, { t, i: n - 1 - idx }, t.id))
101
+ ]
102
+ }
103
+ );
104
+ }
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ Toaster,
108
+ toast
109
+ });
@@ -0,0 +1,10 @@
1
+ import * as react from 'react';
2
+ import { Position, Theme } from '@yusufceng1z/ding';
3
+ export { Position, Theme, toast } from '@yusufceng1z/ding';
4
+
5
+ declare function Toaster({ position, theme }: {
6
+ position?: Position;
7
+ theme?: Theme;
8
+ }): react.JSX.Element;
9
+
10
+ export { Toaster };
@@ -0,0 +1,10 @@
1
+ import * as react from 'react';
2
+ import { Position, Theme } from '@yusufceng1z/ding';
3
+ export { Position, Theme, toast } from '@yusufceng1z/ding';
4
+
5
+ declare function Toaster({ position, theme }: {
6
+ position?: Position;
7
+ theme?: Theme;
8
+ }): react.JSX.Element;
9
+
10
+ export { Toaster };
package/dist/index.js ADDED
@@ -0,0 +1,83 @@
1
+ // src/index.tsx
2
+ import { useEffect, useRef, useSyncExternalStore } from "react";
3
+ import { toast, injectStyles, bindToast, onToastKey, ICONS } from "@yusufceng1z/ding";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ function Item({ t, i }) {
6
+ const slot = useRef(null);
7
+ useEffect(() => slot.current ? bindToast(slot.current, t.id) : void 0, [t.id]);
8
+ const sticky = t.duration === 0 && t.type !== "loading" && !t.secondary;
9
+ return /* @__PURE__ */ jsx("div", { ref: slot, className: "tst-slot", style: { "--tst-i": i }, children: /* @__PURE__ */ jsxs(
10
+ "div",
11
+ {
12
+ className: "tst",
13
+ "data-phase": t.phase,
14
+ "data-type": t.type,
15
+ style: { "--tst-life": `${t.duration}ms` },
16
+ children: [
17
+ (t.action || t.secondary) && t.duration > 0 && /* @__PURE__ */ jsx("div", { className: "tst-timer" }, t.duration),
18
+ t.progress !== void 0 && /* @__PURE__ */ jsx("div", { className: "tst-progress", style: { "--pg": t.progress } }),
19
+ /* @__PURE__ */ jsx("div", { className: "tst-icon", children: t.image ? /* @__PURE__ */ jsx("img", { className: "tst-media", src: t.image, alt: "" }) : /* @__PURE__ */ jsx("div", { className: "tst-badge", children: /* @__PURE__ */ jsx("svg", { className: "tst-svg", viewBox: "0 0 24 24", "aria-hidden": "true", children: ICONS[t.type].map((d) => /* @__PURE__ */ jsx("path", { d, pathLength: 1 }, d)) }) }) }),
20
+ /* @__PURE__ */ jsxs("div", { className: "tst-body", children: [
21
+ /* @__PURE__ */ jsxs("div", { className: "tst-copy", children: [
22
+ /* @__PURE__ */ jsxs("div", { className: "tst-title", children: [
23
+ t.title,
24
+ t.count > 1 && /* @__PURE__ */ jsxs("span", { className: "tst-count", children: [
25
+ "\xD7",
26
+ t.count
27
+ ] }),
28
+ t.meta && /* @__PURE__ */ jsx("span", { className: "tst-meta", children: t.meta })
29
+ ] }),
30
+ t.description && /* @__PURE__ */ jsx("div", { className: "tst-desc", children: t.description })
31
+ ] }),
32
+ t.secondary && /* @__PURE__ */ jsx("button", { type: "button", className: "tst-action tst-secondary", tabIndex: t.phase === "open" ? 0 : -1, onClick: () => toast.act(t.id, "secondary"), children: t.secondary.label }),
33
+ t.action && /* @__PURE__ */ jsx(
34
+ "button",
35
+ {
36
+ type: "button",
37
+ className: "tst-action",
38
+ tabIndex: t.phase === "open" ? 0 : -1,
39
+ onClick: () => {
40
+ toast.act(t.id);
41
+ },
42
+ children: t.action.label
43
+ }
44
+ ),
45
+ sticky && /* @__PURE__ */ jsx("button", { type: "button", className: "tst-close", "aria-label": "Dismiss notification", tabIndex: t.phase === "open" ? 0 : -1, onClick: () => toast.dismiss(t.id), children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M6 6l12 12M18 6L6 18" }) }) })
46
+ ] })
47
+ ]
48
+ }
49
+ ) });
50
+ }
51
+ function Toaster({ position, theme }) {
52
+ const state = useSyncExternalStore(toast.subscribe, toast.getState, toast.getState);
53
+ useEffect(() => injectStyles(), []);
54
+ useEffect(() => toast.configure({ position, theme }), [position, theme]);
55
+ useEffect(() => {
56
+ document.addEventListener("keydown", onToastKey);
57
+ return () => document.removeEventListener("keydown", onToastKey);
58
+ }, []);
59
+ const n = state.toasts.length;
60
+ return /* @__PURE__ */ jsxs(
61
+ "div",
62
+ {
63
+ className: "tst-viewport",
64
+ role: "region",
65
+ "aria-label": "Notifications",
66
+ "data-position": state.position,
67
+ "data-theme": state.theme,
68
+ onPointerEnter: () => toast.pause(),
69
+ onPointerLeave: () => toast.resume(),
70
+ onFocus: (e) => e.target.matches(":focus-visible") && toast.pause(),
71
+ onBlur: () => toast.resume(),
72
+ children: [
73
+ /* @__PURE__ */ jsx("div", { className: "tst-sr", role: "status", children: state.status }),
74
+ /* @__PURE__ */ jsx("div", { className: "tst-sr", role: "alert", children: state.alert }),
75
+ state.toasts.map((t, idx) => /* @__PURE__ */ jsx(Item, { t, i: n - 1 - idx }, t.id))
76
+ ]
77
+ }
78
+ );
79
+ }
80
+ export {
81
+ Toaster,
82
+ toast
83
+ };
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@yusufceng1z/ding-react",
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
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "dependencies": {
25
+ "@yusufceng1z/ding": "0.0.2"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=18"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^19.3.0",
32
+ "react": ">=18"
33
+ },
34
+ "description": "React renderer for Ding spring-physics toasts.",
35
+ "homepage": "https://ding.yusufcengiz.dev",
36
+ "bugs": {
37
+ "url": "https://github.com/YusufCeng1z/ding/issues"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/YusufCeng1z/ding.git",
42
+ "directory": "packages/react"
43
+ },
44
+ "keywords": [
45
+ "toast",
46
+ "notification",
47
+ "spring",
48
+ "animation",
49
+ "react"
50
+ ],
51
+ "engines": {
52
+ "node": ">=18"
53
+ },
54
+ "license": "MIT",
55
+ "author": "Yusuf Cengiz",
56
+ "scripts": {
57
+ "build": "tsup src/index.tsx --format esm,cjs --dts --clean --external react",
58
+ "typecheck": "tsc -p ."
59
+ }
6
60
  }