@open-kingdom/shared-frontend-ui-notifications 0.0.2-0
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 +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +181 -0
- package/dist/lib/notification-toast.d.ts +9 -0
- package/dist/lib/notification-toast.d.ts.map +1 -0
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { jsx as e, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { useState as a, useEffect as w } from "react";
|
|
3
|
+
function b({
|
|
4
|
+
notification: r,
|
|
5
|
+
onDismissed: o,
|
|
6
|
+
onRemoved: i
|
|
7
|
+
}) {
|
|
8
|
+
const [c, l] = a(!1), [d, u] = a(!1);
|
|
9
|
+
w(() => {
|
|
10
|
+
const t = setTimeout(() => l(!0), 10);
|
|
11
|
+
return () => clearTimeout(t);
|
|
12
|
+
}, []);
|
|
13
|
+
const x = () => {
|
|
14
|
+
u(!0), o(r.id), setTimeout(() => {
|
|
15
|
+
i(r.id);
|
|
16
|
+
}, 300);
|
|
17
|
+
}, h = (t) => {
|
|
18
|
+
const s = "p-4 rounded-lg border shadow-lg transition-all duration-300 ease-in-out transform";
|
|
19
|
+
switch (t) {
|
|
20
|
+
case "success":
|
|
21
|
+
return `${s} bg-success-50 dark:bg-success-900/20 border-success-200 dark:border-success-700`;
|
|
22
|
+
case "warning":
|
|
23
|
+
return `${s} bg-warning-50 dark:bg-warning-900/20 border-warning-200 dark:border-warning-700`;
|
|
24
|
+
case "error":
|
|
25
|
+
return `${s} bg-error-50 dark:bg-error-900/20 border-error-200 dark:border-error-700`;
|
|
26
|
+
default:
|
|
27
|
+
return s;
|
|
28
|
+
}
|
|
29
|
+
}, m = (t) => {
|
|
30
|
+
switch (t) {
|
|
31
|
+
case "success":
|
|
32
|
+
return "text-success-800 dark:text-success-200";
|
|
33
|
+
case "warning":
|
|
34
|
+
return "text-warning-800 dark:text-warning-200";
|
|
35
|
+
case "error":
|
|
36
|
+
return "text-error-800 dark:text-error-200";
|
|
37
|
+
default:
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
}, k = (t) => {
|
|
41
|
+
switch (t) {
|
|
42
|
+
case "success":
|
|
43
|
+
return "text-success-600 dark:text-success-400";
|
|
44
|
+
case "warning":
|
|
45
|
+
return "text-warning-600 dark:text-warning-400";
|
|
46
|
+
case "error":
|
|
47
|
+
return "text-error-600 dark:text-error-400";
|
|
48
|
+
default:
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
}, g = (t) => {
|
|
52
|
+
switch (t) {
|
|
53
|
+
case "success":
|
|
54
|
+
return /* @__PURE__ */ e(
|
|
55
|
+
"svg",
|
|
56
|
+
{
|
|
57
|
+
className: "w-5 h-5 text-success-600 dark:text-success-400",
|
|
58
|
+
fill: "none",
|
|
59
|
+
stroke: "currentColor",
|
|
60
|
+
viewBox: "0 0 24 24",
|
|
61
|
+
children: /* @__PURE__ */ e(
|
|
62
|
+
"path",
|
|
63
|
+
{
|
|
64
|
+
strokeLinecap: "round",
|
|
65
|
+
strokeLinejoin: "round",
|
|
66
|
+
strokeWidth: 2,
|
|
67
|
+
d: "M5 13l4 4L19 7"
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
case "warning":
|
|
73
|
+
return /* @__PURE__ */ e(
|
|
74
|
+
"svg",
|
|
75
|
+
{
|
|
76
|
+
className: "w-5 h-5 text-warning-600 dark:text-warning-400",
|
|
77
|
+
fill: "none",
|
|
78
|
+
stroke: "currentColor",
|
|
79
|
+
viewBox: "0 0 24 24",
|
|
80
|
+
children: /* @__PURE__ */ e(
|
|
81
|
+
"path",
|
|
82
|
+
{
|
|
83
|
+
strokeLinecap: "round",
|
|
84
|
+
strokeLinejoin: "round",
|
|
85
|
+
strokeWidth: 2,
|
|
86
|
+
d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
case "error":
|
|
92
|
+
return /* @__PURE__ */ e(
|
|
93
|
+
"svg",
|
|
94
|
+
{
|
|
95
|
+
className: "w-5 h-5 text-error-600 dark:text-error-400",
|
|
96
|
+
fill: "none",
|
|
97
|
+
stroke: "currentColor",
|
|
98
|
+
viewBox: "0 0 24 24",
|
|
99
|
+
children: /* @__PURE__ */ e(
|
|
100
|
+
"path",
|
|
101
|
+
{
|
|
102
|
+
strokeLinecap: "round",
|
|
103
|
+
strokeLinejoin: "round",
|
|
104
|
+
strokeWidth: 2,
|
|
105
|
+
d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
default:
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return /* @__PURE__ */ e(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
className: `
|
|
118
|
+
${h(r.type)}
|
|
119
|
+
${c ? "translate-x-0 opacity-100" : "translate-x-full opacity-0"}
|
|
120
|
+
${d ? "translate-x-full opacity-0" : ""}
|
|
121
|
+
min-w-[320px] max-w-[480px] w-full
|
|
122
|
+
`,
|
|
123
|
+
role: "alert",
|
|
124
|
+
"aria-live": "assertive",
|
|
125
|
+
children: /* @__PURE__ */ n("div", { className: "flex items-start gap-3", children: [
|
|
126
|
+
/* @__PURE__ */ e("div", { className: "flex-shrink-0 mt-0.5", children: g(r.type) }),
|
|
127
|
+
/* @__PURE__ */ n("div", { className: "flex-1 min-w-0", children: [
|
|
128
|
+
/* @__PURE__ */ e(
|
|
129
|
+
"h4",
|
|
130
|
+
{
|
|
131
|
+
className: `text-sm font-semibold ${m(
|
|
132
|
+
r.type
|
|
133
|
+
)}`,
|
|
134
|
+
children: r.type.charAt(0).toUpperCase() + r.type.slice(1)
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ e(
|
|
138
|
+
"p",
|
|
139
|
+
{
|
|
140
|
+
"data-testid": "notification",
|
|
141
|
+
className: `text-sm mt-1 ${k(
|
|
142
|
+
r.type
|
|
143
|
+
)}`,
|
|
144
|
+
children: r.message
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
] }),
|
|
148
|
+
/* @__PURE__ */ e(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
"data-testid": "dismiss-button",
|
|
152
|
+
onClick: x,
|
|
153
|
+
className: "flex-shrink-0 p-1 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors",
|
|
154
|
+
"aria-label": "Dismiss notification",
|
|
155
|
+
children: /* @__PURE__ */ e(
|
|
156
|
+
"svg",
|
|
157
|
+
{
|
|
158
|
+
className: "w-4 h-4",
|
|
159
|
+
fill: "none",
|
|
160
|
+
stroke: "currentColor",
|
|
161
|
+
viewBox: "0 0 24 24",
|
|
162
|
+
children: /* @__PURE__ */ e(
|
|
163
|
+
"path",
|
|
164
|
+
{
|
|
165
|
+
strokeLinecap: "round",
|
|
166
|
+
strokeLinejoin: "round",
|
|
167
|
+
strokeWidth: 2,
|
|
168
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] })
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
b as NotificationToast
|
|
181
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NotificationEntry } from '@open-kingdom/shared-poly-util-types';
|
|
2
|
+
interface NotificationToastProps {
|
|
3
|
+
notification: NotificationEntry;
|
|
4
|
+
onDismissed: (id: string) => void;
|
|
5
|
+
onRemoved: (id: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function NotificationToast({ notification, onDismissed, onRemoved, }: NotificationToastProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=notification-toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-toast.d.ts","sourceRoot":"","sources":["../../src/lib/notification-toast.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,UAAU,sBAAsB;IAC9B,YAAY,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,YAAY,EACZ,WAAW,EACX,SAAS,GACV,EAAE,sBAAsB,2CAiLxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=test-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../src/test-setup.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@open-kingdom/shared-frontend-ui-notifications",
|
|
3
|
+
"version": "0.0.2-0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"development": "./src/index.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"!**/*.tsbuildinfo"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"nx": {
|
|
25
|
+
"name": "@open-kingdom/shared-frontend-ui-notifications",
|
|
26
|
+
"tags": [
|
|
27
|
+
"scope:shared",
|
|
28
|
+
"type:ui",
|
|
29
|
+
"environment:frontend"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"tailwindcss": "^3.4.0",
|
|
34
|
+
"react": "^19.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|