asterui 0.12.61 → 0.12.63
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/dist/components/Affix.d.ts +2 -0
- package/dist/components/Affix.js.map +1 -1
- package/dist/components/Alert.d.ts +2 -0
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Anchor.d.ts +2 -0
- package/dist/components/Anchor.js +79 -75
- package/dist/components/Anchor.js.map +1 -1
- package/dist/components/Autocomplete.d.ts +1 -0
- package/dist/components/Autocomplete.js +115 -110
- package/dist/components/Autocomplete.js.map +1 -1
- package/dist/components/Avatar.d.ts +4 -0
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Breadcrumb.d.ts +4 -2
- package/dist/components/Breadcrumb.js +54 -29
- package/dist/components/Breadcrumb.js.map +1 -1
- package/dist/components/Browser.d.ts +2 -0
- package/dist/components/Browser.js.map +1 -1
- package/dist/components/Button.d.ts +5 -1
- package/dist/components/Button.js +117 -107
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Chart.d.ts +1 -0
- package/dist/components/Chart.js +31 -30
- package/dist/components/Chart.js.map +1 -1
- package/dist/components/Chat.d.ts +1 -0
- package/dist/components/Chat.js +39 -28
- package/dist/components/Chat.js.map +1 -1
- package/dist/components/Code.d.ts +2 -0
- package/dist/components/Code.js.map +1 -1
- package/dist/components/Command.d.ts +5 -2
- package/dist/components/Command.js +262 -233
- package/dist/components/Command.js.map +1 -1
- package/dist/components/Container.d.ts +2 -0
- package/dist/components/Container.js.map +1 -1
- package/dist/components/ContextMenu.d.ts +4 -0
- package/dist/components/ContextMenu.js +157 -122
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton.d.ts +2 -0
- package/dist/components/CopyButton.js +9 -8
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/Countdown.d.ts +3 -3
- package/dist/components/Countdown.js +49 -47
- package/dist/components/Countdown.js.map +1 -1
- package/dist/components/Diff.d.ts +3 -3
- package/dist/components/Diff.js +14 -10
- package/dist/components/Diff.js.map +1 -1
- package/dist/components/Divider.d.ts +2 -0
- package/dist/components/Divider.js.map +1 -1
- package/dist/components/Dock.d.ts +6 -0
- package/dist/components/Dock.js +75 -38
- package/dist/components/Dock.js.map +1 -1
- package/dist/components/Dropdown.js +110 -110
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Fieldset.d.ts +2 -0
- package/dist/components/Fieldset.js.map +1 -1
- package/dist/components/FileInput.d.ts +1 -0
- package/dist/components/FileInput.js +26 -26
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Filter.d.ts +1 -0
- package/dist/components/Filter.js +43 -40
- package/dist/components/Filter.js.map +1 -1
- package/dist/components/Flex.d.ts +1 -0
- package/dist/components/Flex.js +43 -42
- package/dist/components/Flex.js.map +1 -1
- package/dist/components/FloatButton.d.ts +9 -0
- package/dist/components/FloatButton.js +211 -136
- package/dist/components/FloatButton.js.map +1 -1
- package/dist/components/Footer.d.ts +2 -0
- package/dist/components/Footer.js.map +1 -1
- package/dist/components/Grid.d.ts +4 -0
- package/dist/components/Grid.js.map +1 -1
- package/dist/components/Hero.d.ts +2 -0
- package/dist/components/Hero.js.map +1 -1
- package/dist/components/HoverGallery.d.ts +3 -3
- package/dist/components/HoverGallery.js +12 -10
- package/dist/components/HoverGallery.js.map +1 -1
- package/dist/components/Input.d.ts +1 -0
- package/dist/components/Input.js +201 -184
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Join.d.ts +2 -0
- package/dist/components/Join.js.map +1 -1
- package/dist/components/Kbd.d.ts +2 -0
- package/dist/components/Kbd.js.map +1 -1
- package/dist/components/Loading.d.ts +3 -0
- package/dist/components/Loading.js +58 -35
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/Mask.d.ts +2 -2
- package/dist/components/Mask.js.map +1 -1
- package/dist/components/Masonry.d.ts +1 -0
- package/dist/components/Masonry.js +45 -42
- package/dist/components/Masonry.js.map +1 -1
- package/dist/components/Mention.d.ts +1 -0
- package/dist/components/Mention.js +95 -91
- package/dist/components/Mention.js.map +1 -1
- package/dist/components/MonthCalendar.d.ts +1 -0
- package/dist/components/MonthCalendar.js +104 -97
- package/dist/components/MonthCalendar.js.map +1 -1
- package/dist/components/Navbar.d.ts +2 -0
- package/dist/components/Navbar.js.map +1 -1
- package/dist/components/Notification.js +32 -18
- package/dist/components/Notification.js.map +1 -1
- package/dist/components/Phone.d.ts +3 -2
- package/dist/components/Phone.js +10 -8
- package/dist/components/Phone.js.map +1 -1
- package/dist/components/Popconfirm.js +110 -92
- package/dist/components/Popconfirm.js.map +1 -1
- package/dist/components/Popover.d.ts +2 -0
- package/dist/components/Popover.js.map +1 -1
- package/dist/components/Progress.d.ts +2 -0
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/QRCode.d.ts +1 -0
- package/dist/components/QRCode.js +84 -55
- package/dist/components/QRCode.js.map +1 -1
- package/dist/components/RadialProgress.d.ts +1 -0
- package/dist/components/RadialProgress.js +19 -17
- package/dist/components/RadialProgress.js.map +1 -1
- package/dist/components/Radio.d.ts +6 -3
- package/dist/components/Radio.js +9 -9
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Range.d.ts +1 -0
- package/dist/components/Range.js +45 -43
- package/dist/components/Range.js.map +1 -1
- package/dist/components/Rating.d.ts +4 -2
- package/dist/components/Rating.js +83 -79
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/Responsive.d.ts +4 -2
- package/dist/components/Responsive.js +10 -9
- package/dist/components/Responsive.js.map +1 -1
- package/dist/components/Result.d.ts +1 -0
- package/dist/components/Result.js +24 -22
- package/dist/components/Result.js.map +1 -1
- package/dist/components/Select.d.ts +1 -0
- package/dist/components/Select.js +72 -62
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Skeleton.d.ts +2 -0
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Space.d.ts +2 -0
- package/dist/components/Space.js.map +1 -1
- package/dist/components/Splitter.d.ts +2 -0
- package/dist/components/Splitter.js +137 -131
- package/dist/components/Splitter.js.map +1 -1
- package/dist/components/Stat.d.ts +4 -2
- package/dist/components/Stat.js +19 -18
- package/dist/components/Stat.js.map +1 -1
- package/dist/components/Status.d.ts +3 -3
- package/dist/components/Status.js +27 -25
- package/dist/components/Status.js.map +1 -1
- package/dist/components/Steps.d.ts +4 -2
- package/dist/components/Steps.js +56 -52
- package/dist/components/Steps.js.map +1 -1
- package/dist/components/TextRotate.d.ts +1 -0
- package/dist/components/TextRotate.js +14 -12
- package/dist/components/TextRotate.js.map +1 -1
- package/dist/components/Textarea.d.ts +1 -0
- package/dist/components/Textarea.js +31 -30
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/ThemeController.d.ts +6 -3
- package/dist/components/ThemeController.js +101 -92
- package/dist/components/ThemeController.js.map +1 -1
- package/dist/components/Toggle.d.ts +2 -0
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/Tooltip.d.ts +2 -0
- package/dist/components/Tooltip.js +38 -32
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/Typography.d.ts +10 -5
- package/dist/components/Typography.js +84 -81
- package/dist/components/Typography.js.map +1 -1
- package/dist/components/VirtualList.d.ts +2 -1
- package/dist/components/VirtualList.js +40 -36
- package/dist/components/VirtualList.js.map +1 -1
- package/dist/components/Watermark.d.ts +1 -0
- package/dist/components/Watermark.js +74 -71
- package/dist/components/Watermark.js.map +1 -1
- package/dist/components/WeekCalendar.d.ts +1 -0
- package/dist/components/WeekCalendar.js +91 -76
- package/dist/components/WeekCalendar.js.map +1 -1
- package/dist/components/Window.d.ts +3 -2
- package/dist/components/Window.js +9 -7
- package/dist/components/Window.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as p, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as J, useState as L } from "react";
|
|
3
|
+
const q = {
|
|
4
4
|
locale: "en",
|
|
5
5
|
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
6
6
|
monthsLong: [
|
|
@@ -18,179 +18,186 @@ const A = {
|
|
|
18
18
|
"December"
|
|
19
19
|
],
|
|
20
20
|
moreText: "more"
|
|
21
|
-
},
|
|
22
|
-
const
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
const e = /* @__PURE__ */ new Date(),
|
|
26
|
-
return e.setHours(0, 0, 0, 0),
|
|
27
|
-
},
|
|
28
|
-
const e = /* @__PURE__ */ new Date(),
|
|
29
|
-
return e.setHours(0, 0, 0, 0),
|
|
30
|
-
},
|
|
31
|
-
(
|
|
32
|
-
),
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
for (let
|
|
37
|
-
const x =
|
|
38
|
-
|
|
21
|
+
}, $ = (t) => k(t, /* @__PURE__ */ new Date()), k = (t, e) => {
|
|
22
|
+
const s = new Date(t), o = new Date(e);
|
|
23
|
+
return s.setHours(0, 0, 0, 0), o.setHours(0, 0, 0, 0), o.getTime() === s.getTime();
|
|
24
|
+
}, z = (t) => {
|
|
25
|
+
const e = /* @__PURE__ */ new Date(), s = new Date(t);
|
|
26
|
+
return e.setHours(0, 0, 0, 0), s.setHours(0, 0, 0, 0), s > e;
|
|
27
|
+
}, G = (t) => {
|
|
28
|
+
const e = /* @__PURE__ */ new Date(), s = new Date(t);
|
|
29
|
+
return e.setHours(0, 0, 0, 0), s.setHours(0, 0, 0, 0), s < e;
|
|
30
|
+
}, K = (t, e) => t.filter(
|
|
31
|
+
(s) => s.date.getDate() === e.getDate() && s.date.getMonth() === e.getMonth() && s.date.getFullYear() === e.getFullYear()
|
|
32
|
+
), T = (t, e) => new Date(t, e + 1, 0).getDate(), R = (t, e) => new Date(t, e, 1).getDay(), W = (t, e) => {
|
|
33
|
+
const s = T(t, e), o = R(t, e), f = [];
|
|
34
|
+
if (o > 0) {
|
|
35
|
+
const r = e === 0 ? 11 : e - 1, a = e === 0 ? t - 1 : t, d = T(a, r);
|
|
36
|
+
for (let u = 0; u < o; u++) {
|
|
37
|
+
const x = d - o + u + 1;
|
|
38
|
+
f.push({
|
|
39
39
|
day: x,
|
|
40
|
-
month:
|
|
40
|
+
month: r,
|
|
41
41
|
year: a,
|
|
42
42
|
isCurrentMonth: !1,
|
|
43
|
-
date: new Date(a,
|
|
43
|
+
date: new Date(a, r, x)
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
for (let
|
|
49
|
-
|
|
50
|
-
day:
|
|
47
|
+
const h = [];
|
|
48
|
+
for (let r = 1; r <= s; r++)
|
|
49
|
+
h.push({
|
|
50
|
+
day: r,
|
|
51
51
|
month: e,
|
|
52
52
|
year: t,
|
|
53
53
|
isCurrentMonth: !0,
|
|
54
|
-
date: new Date(t, e,
|
|
54
|
+
date: new Date(t, e, r)
|
|
55
55
|
});
|
|
56
|
-
const m = [],
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
for (let
|
|
56
|
+
const m = [], g = 42 - (f.length + h.length);
|
|
57
|
+
if (g > 0) {
|
|
58
|
+
const r = e === 11 ? 0 : e + 1, a = e === 11 ? t + 1 : t;
|
|
59
|
+
for (let d = 1; d <= g; d++)
|
|
60
60
|
m.push({
|
|
61
|
-
day:
|
|
62
|
-
month:
|
|
61
|
+
day: d,
|
|
62
|
+
month: r,
|
|
63
63
|
year: a,
|
|
64
64
|
isCurrentMonth: !1,
|
|
65
|
-
date: new Date(a,
|
|
65
|
+
date: new Date(a, r, d)
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
return [...
|
|
69
|
-
},
|
|
68
|
+
return [...f, ...h, ...m];
|
|
69
|
+
}, B = J(
|
|
70
70
|
({
|
|
71
71
|
date: t = /* @__PURE__ */ new Date(),
|
|
72
72
|
events: e = [],
|
|
73
|
-
maxEventsPerDay:
|
|
74
|
-
onEventClick:
|
|
75
|
-
onDayClick:
|
|
76
|
-
onMoreEventsClick:
|
|
73
|
+
maxEventsPerDay: s = 5,
|
|
74
|
+
onEventClick: o,
|
|
75
|
+
onDayClick: f,
|
|
76
|
+
onMoreEventsClick: h,
|
|
77
77
|
header: m,
|
|
78
|
-
daySelector:
|
|
79
|
-
locale:
|
|
80
|
-
ellipsis:
|
|
78
|
+
daySelector: M,
|
|
79
|
+
locale: g = q,
|
|
80
|
+
ellipsis: r,
|
|
81
81
|
allowPastInteraction: a = !1,
|
|
82
|
-
className:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
className: d = "",
|
|
83
|
+
"data-testid": u,
|
|
84
|
+
...x
|
|
85
|
+
}, F) => {
|
|
86
|
+
const [S, H] = L(/* @__PURE__ */ new Date()), N = t.getFullYear(), v = t.getMonth(), l = (n) => u ? `${u}-${n}` : void 0;
|
|
87
|
+
return /* @__PURE__ */ p(
|
|
87
88
|
"div",
|
|
88
89
|
{
|
|
89
|
-
ref:
|
|
90
|
-
className: `flex h-full w-full flex-col bg-base-100 ${
|
|
91
|
-
|
|
90
|
+
ref: F,
|
|
91
|
+
className: `flex h-full w-full flex-col bg-base-100 ${d}`,
|
|
92
|
+
"data-testid": u,
|
|
93
|
+
...x,
|
|
92
94
|
children: [
|
|
93
|
-
m && /* @__PURE__ */
|
|
94
|
-
|
|
95
|
+
m && /* @__PURE__ */ c("div", { className: "mb-4 flex items-center justify-between", "data-testid": l("header"), children: /* @__PURE__ */ c("div", { children: /* @__PURE__ */ p("h2", { className: "m-0 text-lg font-medium text-base-content", children: [
|
|
96
|
+
g.monthsLong[v],
|
|
95
97
|
" ",
|
|
96
|
-
|
|
98
|
+
N
|
|
97
99
|
] }) }) }),
|
|
98
|
-
/* @__PURE__ */
|
|
100
|
+
/* @__PURE__ */ c("div", { className: "grid grid-cols-7 border-b border-base-300", "data-testid": l("weekday-header"), children: g.daysShort.map((n, D) => /* @__PURE__ */ c(
|
|
99
101
|
"div",
|
|
100
102
|
{
|
|
101
103
|
className: "py-1 text-center text-xs font-medium uppercase text-base-content/60",
|
|
102
|
-
|
|
104
|
+
"data-testid": l(`weekday-${D}`),
|
|
105
|
+
children: n
|
|
103
106
|
},
|
|
104
|
-
|
|
107
|
+
D
|
|
105
108
|
)) }),
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
const
|
|
108
|
-
return /* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ c("div", { className: "grid flex-1 grid-cols-7 grid-rows-6 border-l border-base-300", "data-testid": l("grid"), children: W(N, v).map((n, D) => {
|
|
110
|
+
const y = K(e, n.date), b = G(n.date) && !$(n.date), Y = M && k(n.date, S), w = `${n.year}-${n.month + 1}-${n.day}`;
|
|
111
|
+
return /* @__PURE__ */ p(
|
|
109
112
|
"div",
|
|
110
113
|
{
|
|
111
114
|
className: `
|
|
112
115
|
relative cursor-pointer overflow-hidden border-b border-r border-base-300 p-1
|
|
113
116
|
hover:bg-base-200
|
|
114
|
-
${
|
|
115
|
-
${
|
|
116
|
-
${
|
|
117
|
-
${
|
|
118
|
-
${
|
|
117
|
+
${n.isCurrentMonth ? "" : "bg-base-200"}
|
|
118
|
+
${$(n.date) ? "bg-primary/10" : ""}
|
|
119
|
+
${b ? "opacity-60" : ""}
|
|
120
|
+
${b && !a ? "cursor-not-allowed" : ""}
|
|
121
|
+
${Y ? "z-10 outline outline-2 outline-primary" : ""}
|
|
119
122
|
`,
|
|
123
|
+
"data-testid": l(`day-${w}`),
|
|
120
124
|
onClick: () => {
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
b && !a || (M && H(n.date), setTimeout(() => {
|
|
126
|
+
f?.(n.date);
|
|
123
127
|
}, 0));
|
|
124
128
|
},
|
|
125
129
|
children: [
|
|
126
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ c("div", { className: "mb-0.5 flex justify-center", children: /* @__PURE__ */ c(
|
|
127
131
|
"span",
|
|
128
132
|
{
|
|
129
133
|
className: `
|
|
130
134
|
flex items-center justify-center text-xs leading-none
|
|
131
|
-
${
|
|
132
|
-
${
|
|
133
|
-
${
|
|
135
|
+
${$(n.date) ? "font-bold text-primary" : "text-base-content"}
|
|
136
|
+
${n.isCurrentMonth ? "" : "text-base-content/40"}
|
|
137
|
+
${b && n.isCurrentMonth ? "text-base-content/40" : ""}
|
|
134
138
|
`,
|
|
135
|
-
|
|
139
|
+
"data-testid": l(`day-number-${w}`),
|
|
140
|
+
children: n.day
|
|
136
141
|
}
|
|
137
142
|
) }),
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
|
|
143
|
+
/* @__PURE__ */ p("div", { className: "flex flex-col", children: [
|
|
144
|
+
y.slice(
|
|
140
145
|
0,
|
|
141
|
-
|
|
142
|
-
).map((
|
|
146
|
+
y.length > s ? s - 1 : s
|
|
147
|
+
).map((i, C) => /* @__PURE__ */ p(
|
|
143
148
|
"div",
|
|
144
149
|
{
|
|
145
150
|
className: `
|
|
146
151
|
flex cursor-pointer items-center rounded px-1 py-0.5 text-xs leading-none
|
|
147
152
|
transition-colors hover:bg-base-content/5
|
|
148
|
-
${
|
|
149
|
-
${
|
|
153
|
+
${z(i.date), "text-base-content"}
|
|
154
|
+
${i.strikethrough ? "line-through" : ""}
|
|
150
155
|
`,
|
|
151
|
-
style:
|
|
152
|
-
|
|
153
|
-
|
|
156
|
+
style: i.style,
|
|
157
|
+
"data-testid": l(`event-${w}-${C}`),
|
|
158
|
+
onClick: (A) => {
|
|
159
|
+
A.stopPropagation(), o && o(i);
|
|
154
160
|
},
|
|
155
|
-
title:
|
|
161
|
+
title: i.title,
|
|
156
162
|
children: [
|
|
157
|
-
/* @__PURE__ */
|
|
163
|
+
/* @__PURE__ */ c(
|
|
158
164
|
"span",
|
|
159
165
|
{
|
|
160
166
|
className: "mr-1.5 inline-block h-2 w-2 shrink-0 rounded-full",
|
|
161
|
-
style: { backgroundColor:
|
|
167
|
+
style: { backgroundColor: i.color }
|
|
162
168
|
}
|
|
163
169
|
),
|
|
164
|
-
/* @__PURE__ */
|
|
170
|
+
/* @__PURE__ */ c(
|
|
165
171
|
"span",
|
|
166
172
|
{
|
|
167
|
-
className: `overflow-hidden whitespace-nowrap ${
|
|
168
|
-
children:
|
|
173
|
+
className: `overflow-hidden whitespace-nowrap ${r ? "text-ellipsis" : ""}`,
|
|
174
|
+
children: i.title
|
|
169
175
|
}
|
|
170
176
|
)
|
|
171
177
|
]
|
|
172
178
|
},
|
|
173
|
-
|
|
179
|
+
C
|
|
174
180
|
)),
|
|
175
|
-
|
|
181
|
+
y.length > s && /* @__PURE__ */ p(
|
|
176
182
|
"div",
|
|
177
183
|
{
|
|
178
184
|
className: "cursor-pointer rounded px-1 py-0.5 text-[11px] text-base-content/60 hover:bg-base-content/5",
|
|
179
|
-
|
|
180
|
-
|
|
185
|
+
"data-testid": l(`more-${w}`),
|
|
186
|
+
onClick: (i) => {
|
|
187
|
+
i.stopPropagation(), h && h(n.date, y);
|
|
181
188
|
},
|
|
182
189
|
children: [
|
|
183
190
|
"+",
|
|
184
|
-
|
|
191
|
+
y.length - s + 1,
|
|
185
192
|
" ",
|
|
186
|
-
|
|
193
|
+
g.moreText
|
|
187
194
|
]
|
|
188
195
|
}
|
|
189
196
|
)
|
|
190
197
|
] })
|
|
191
198
|
]
|
|
192
199
|
},
|
|
193
|
-
|
|
200
|
+
D
|
|
194
201
|
);
|
|
195
202
|
}) })
|
|
196
203
|
]
|
|
@@ -198,8 +205,8 @@ const A = {
|
|
|
198
205
|
);
|
|
199
206
|
}
|
|
200
207
|
);
|
|
201
|
-
|
|
208
|
+
B.displayName = "MonthCalendar";
|
|
202
209
|
export {
|
|
203
|
-
|
|
210
|
+
B as MonthCalendar
|
|
204
211
|
};
|
|
205
212
|
//# sourceMappingURL=MonthCalendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonthCalendar.js","sources":["../../src/components/MonthCalendar.tsx"],"sourcesContent":["import React, { useState, forwardRef } from 'react'\n\n// DaisyUI classes\n// (No DaisyUI classes used in this component)\n\n// Types\nexport type CalendarEvent = {\n date: Date\n title: string\n color: string\n strikethrough?: boolean\n style?: React.CSSProperties\n}\n\nexport type CalendarLocale = {\n locale: string\n daysShort: string[]\n monthsLong: string[]\n moreText: string\n formatTime?: (date: Date) => string\n}\n\n// Default English locale\nconst defaultLocale: CalendarLocale = {\n locale: 'en',\n daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n monthsLong: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n moreText: 'more',\n}\n\n// Utility functions\nconst isToday = (date: Date) => isEqual(date, new Date())\n\nconst isEqual = (a: Date, b: Date) => {\n const acopy = new Date(a)\n const bcopy = new Date(b)\n acopy.setHours(0, 0, 0, 0)\n bcopy.setHours(0, 0, 0, 0)\n return bcopy.getTime() === acopy.getTime()\n}\n\nconst isFutureDate = (date: Date) => {\n const today = new Date()\n const checkDate = new Date(date)\n today.setHours(0, 0, 0, 0)\n checkDate.setHours(0, 0, 0, 0)\n return checkDate > today\n}\n\nconst isPastDate = (date: Date) => {\n const today = new Date()\n const checkDate = new Date(date)\n today.setHours(0, 0, 0, 0)\n checkDate.setHours(0, 0, 0, 0)\n return checkDate < today\n}\n\nconst getEventsForDate = <T extends CalendarEvent>(events: T[], date: Date) => {\n return events.filter(\n (event) =>\n event.date.getDate() === date.getDate() &&\n event.date.getMonth() === date.getMonth() &&\n event.date.getFullYear() === date.getFullYear()\n )\n}\n\nconst getDaysInMonth = (year: number, month: number) => {\n return new Date(year, month + 1, 0).getDate()\n}\n\nconst getFirstDayOfMonth = (year: number, month: number) => {\n return new Date(year, month, 1).getDay()\n}\n\nconst generateCalendarGrid = (year: number, month: number) => {\n const daysInMonth = getDaysInMonth(year, month)\n const firstDayOfMonth = getFirstDayOfMonth(year, month)\n\n const prevMonthDays = []\n\n if (firstDayOfMonth > 0) {\n const prevMonth = month === 0 ? 11 : month - 1\n const prevMonthYear = month === 0 ? year - 1 : year\n const daysInPrevMonth = getDaysInMonth(prevMonthYear, prevMonth)\n\n for (let i = 0; i < firstDayOfMonth; i++) {\n const day = daysInPrevMonth - firstDayOfMonth + i + 1\n prevMonthDays.push({\n day,\n month: prevMonth,\n year: prevMonthYear,\n isCurrentMonth: false,\n date: new Date(prevMonthYear, prevMonth, day),\n })\n }\n }\n\n const currentMonthDays = []\n\n for (let day = 1; day <= daysInMonth; day++) {\n currentMonthDays.push({\n day,\n month,\n year,\n isCurrentMonth: true,\n date: new Date(year, month, day),\n })\n }\n\n const nextMonthDays = []\n const totalDaysDisplayed = prevMonthDays.length + currentMonthDays.length\n const daysToAdd = 6 * 7 - totalDaysDisplayed\n\n if (daysToAdd > 0) {\n const nextMonth = month === 11 ? 0 : month + 1\n const nextMonthYear = month === 11 ? year + 1 : year\n\n for (let day = 1; day <= daysToAdd; day++) {\n nextMonthDays.push({\n day,\n month: nextMonth,\n year: nextMonthYear,\n isCurrentMonth: false,\n date: new Date(nextMonthYear, nextMonth, day),\n })\n }\n }\n\n return [...prevMonthDays, ...currentMonthDays, ...nextMonthDays]\n}\n\nexport interface MonthCalendarProps<T extends CalendarEvent = CalendarEvent>\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n date?: Date\n events?: T[]\n onEventClick?: (event: T) => void\n onDayClick?: (date: Date) => void\n locale?: CalendarLocale\n allowPastInteraction?: boolean\n maxEventsPerDay?: number\n onMoreEventsClick?: (date: Date, events: T[]) => void\n header?: boolean\n daySelector?: boolean\n ellipsis?: boolean\n}\n\nexport const MonthCalendar = forwardRef<HTMLDivElement, MonthCalendarProps>(\n <T extends CalendarEvent>(\n {\n date = new Date(),\n events = [],\n maxEventsPerDay = 5,\n onEventClick,\n onDayClick,\n onMoreEventsClick,\n header,\n daySelector,\n locale = defaultLocale,\n ellipsis,\n allowPastInteraction = false,\n className = '',\n ...rest\n }: MonthCalendarProps<T>,\n ref: React.ForwardedRef<HTMLDivElement>\n ) => {\n const [selectedDate, setSelectedDate] = useState(new Date())\n\n const year = date.getFullYear()\n const month = date.getMonth()\n\n return (\n <div\n ref={ref}\n className={`flex h-full w-full flex-col bg-base-100 ${className}`}\n {...rest}\n >\n {header && (\n <div className=\"mb-4 flex items-center justify-between\">\n <div>\n <h2 className=\"m-0 text-lg font-medium text-base-content\">\n {locale.monthsLong[month]} {year}\n </h2>\n </div>\n </div>\n )}\n\n {/* Weekday header */}\n <div className=\"grid grid-cols-7 border-b border-base-300\">\n {locale.daysShort.map((day, index) => (\n <div\n key={index}\n className=\"py-1 text-center text-xs font-medium uppercase text-base-content/60\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid flex-1 grid-cols-7 grid-rows-6 border-l border-base-300\">\n {generateCalendarGrid(year, month).map((dateObj, index) => {\n const dateEvents = getEventsForDate(events as T[], dateObj.date)\n const isPast = isPastDate(dateObj.date) && !isToday(dateObj.date)\n const isSelected = daySelector && isEqual(dateObj.date, selectedDate)\n\n return (\n <div\n key={index}\n className={`\n relative cursor-pointer overflow-hidden border-b border-r border-base-300 p-1\n hover:bg-base-200\n ${!dateObj.isCurrentMonth ? 'bg-base-200' : ''}\n ${isToday(dateObj.date) ? 'bg-primary/10' : ''}\n ${isPast ? 'opacity-60' : ''}\n ${isPast && !allowPastInteraction ? 'cursor-not-allowed' : ''}\n ${isSelected ? 'z-10 outline outline-2 outline-primary' : ''}\n `}\n onClick={() => {\n if (isPast && !allowPastInteraction) {\n return\n }\n\n if (daySelector) {\n setSelectedDate(dateObj.date)\n }\n\n setTimeout(() => {\n onDayClick?.(dateObj.date)\n }, 0)\n }}\n >\n {/* Date number */}\n <div className=\"mb-0.5 flex justify-center\">\n <span\n className={`\n flex items-center justify-center text-xs leading-none\n ${isToday(dateObj.date) ? 'font-bold text-primary' : 'text-base-content'}\n ${!dateObj.isCurrentMonth ? 'text-base-content/40' : ''}\n ${isPast && dateObj.isCurrentMonth ? 'text-base-content/40' : ''}\n `}\n >\n {dateObj.day}\n </span>\n </div>\n\n {/* Events container */}\n <div className=\"flex flex-col\">\n {dateEvents\n .slice(\n 0,\n dateEvents.length > maxEventsPerDay\n ? maxEventsPerDay - 1\n : maxEventsPerDay\n )\n .map((event, eventIndex) => (\n <div\n key={eventIndex}\n className={`\n flex cursor-pointer items-center rounded px-1 py-0.5 text-xs leading-none\n transition-colors hover:bg-base-content/5\n ${isFutureDate(event.date) ? 'text-base-content' : 'text-base-content'}\n ${event.strikethrough ? 'line-through' : ''}\n `}\n style={event.style}\n onClick={(e) => {\n e.stopPropagation()\n if (onEventClick) {\n onEventClick(event)\n }\n }}\n title={event.title}\n >\n <span\n className=\"mr-1.5 inline-block h-2 w-2 shrink-0 rounded-full\"\n style={{ backgroundColor: event.color }}\n />\n <span\n className={`overflow-hidden whitespace-nowrap ${ellipsis ? 'text-ellipsis' : ''}`}\n >\n {event.title}\n </span>\n </div>\n ))}\n {dateEvents.length > maxEventsPerDay && (\n <div\n className=\"cursor-pointer rounded px-1 py-0.5 text-[11px] text-base-content/60 hover:bg-base-content/5\"\n onClick={(e) => {\n e.stopPropagation()\n if (onMoreEventsClick) {\n onMoreEventsClick(dateObj.date, dateEvents)\n }\n }}\n >\n +{dateEvents.length - maxEventsPerDay + 1} {locale.moreText}\n </div>\n )}\n </div>\n </div>\n )\n })}\n </div>\n </div>\n )\n }\n) as <T extends CalendarEvent = CalendarEvent>(\n props: MonthCalendarProps<T> & { ref?: React.ForwardedRef<HTMLDivElement> }\n) => React.ReactElement\n\n;(MonthCalendar as React.FC).displayName = 'MonthCalendar'\n"],"names":["defaultLocale","isToday","date","isEqual","a","b","acopy","bcopy","isFutureDate","today","checkDate","isPastDate","getEventsForDate","events","event","getDaysInMonth","year","month","getFirstDayOfMonth","generateCalendarGrid","daysInMonth","firstDayOfMonth","prevMonthDays","prevMonth","prevMonthYear","daysInPrevMonth","i","day","currentMonthDays","nextMonthDays","daysToAdd","nextMonth","nextMonthYear","MonthCalendar","forwardRef","maxEventsPerDay","onEventClick","onDayClick","onMoreEventsClick","header","daySelector","locale","ellipsis","allowPastInteraction","className","rest","ref","selectedDate","setSelectedDate","useState","jsxs","jsx","index","dateObj","dateEvents","isPast","isSelected","eventIndex","e"],"mappings":";;AAuBA,MAAMA,IAAgC;AAAA,EACpC,QAAQ;AAAA,EACR,WAAW,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAAA,EAC3D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AACZ,GAGMC,IAAU,CAACC,MAAeC,EAAQD,GAAM,oBAAI,MAAM,GAElDC,IAAU,CAACC,GAASC,MAAY;AACpC,QAAMC,IAAQ,IAAI,KAAKF,CAAC,GAClBG,IAAQ,IAAI,KAAKF,CAAC;AACxB,SAAAC,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GAClBA,EAAM,cAAcD,EAAM,QAAA;AACnC,GAEME,IAAe,CAACN,MAAe;AACnC,QAAMO,wBAAY,KAAA,GACZC,IAAY,IAAI,KAAKR,CAAI;AAC/B,SAAAO,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAU,SAAS,GAAG,GAAG,GAAG,CAAC,GACtBA,IAAYD;AACrB,GAEME,IAAa,CAACT,MAAe;AACjC,QAAMO,wBAAY,KAAA,GACZC,IAAY,IAAI,KAAKR,CAAI;AAC/B,SAAAO,EAAM,SAAS,GAAG,GAAG,GAAG,CAAC,GACzBC,EAAU,SAAS,GAAG,GAAG,GAAG,CAAC,GACtBA,IAAYD;AACrB,GAEMG,IAAmB,CAA0BC,GAAaX,MACvDW,EAAO;AAAA,EACZ,CAACC,M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;AAAA,oBAAA;AAAA,kBACrD,EAAA,CAEJ;AAAA,gBAAA;AAAA,cAAA;AAAA,cAzFKW;AAAA,YAAA;AAAA,UA4FX,CAAC,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAIEnB,EAA2B,cAAc;"}
|
|
1
|
+
{"version":3,"file":"MonthCalendar.js","sources":["../../src/components/MonthCalendar.tsx"],"sourcesContent":["import React, { useState, forwardRef } from 'react'\n\n// DaisyUI classes\n// (No DaisyUI classes used in this component)\n\n// Types\nexport type CalendarEvent = {\n date: Date\n title: string\n color: string\n strikethrough?: boolean\n style?: React.CSSProperties\n}\n\nexport type CalendarLocale = {\n locale: string\n daysShort: string[]\n monthsLong: string[]\n moreText: string\n formatTime?: (date: Date) => string\n}\n\n// Default English locale\nconst defaultLocale: CalendarLocale = {\n locale: 'en',\n daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n monthsLong: [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n ],\n moreText: 'more',\n}\n\n// Utility functions\nconst isToday = (date: Date) => isEqual(date, new Date())\n\nconst isEqual = (a: Date, b: Date) => {\n const acopy = new Date(a)\n const bcopy = new Date(b)\n acopy.setHours(0, 0, 0, 0)\n bcopy.setHours(0, 0, 0, 0)\n return bcopy.getTime() === acopy.getTime()\n}\n\nconst isFutureDate = (date: Date) => {\n const today = new Date()\n const checkDate = new Date(date)\n today.setHours(0, 0, 0, 0)\n checkDate.setHours(0, 0, 0, 0)\n return checkDate > today\n}\n\nconst isPastDate = (date: Date) => {\n const today = new Date()\n const checkDate = new Date(date)\n today.setHours(0, 0, 0, 0)\n checkDate.setHours(0, 0, 0, 0)\n return checkDate < today\n}\n\nconst getEventsForDate = <T extends CalendarEvent>(events: T[], date: Date) => {\n return events.filter(\n (event) =>\n event.date.getDate() === date.getDate() &&\n event.date.getMonth() === date.getMonth() &&\n event.date.getFullYear() === date.getFullYear()\n )\n}\n\nconst getDaysInMonth = (year: number, month: number) => {\n return new Date(year, month + 1, 0).getDate()\n}\n\nconst getFirstDayOfMonth = (year: number, month: number) => {\n return new Date(year, month, 1).getDay()\n}\n\nconst generateCalendarGrid = (year: number, month: number) => {\n const daysInMonth = getDaysInMonth(year, month)\n const firstDayOfMonth = getFirstDayOfMonth(year, month)\n\n const prevMonthDays = []\n\n if (firstDayOfMonth > 0) {\n const prevMonth = month === 0 ? 11 : month - 1\n const prevMonthYear = month === 0 ? year - 1 : year\n const daysInPrevMonth = getDaysInMonth(prevMonthYear, prevMonth)\n\n for (let i = 0; i < firstDayOfMonth; i++) {\n const day = daysInPrevMonth - firstDayOfMonth + i + 1\n prevMonthDays.push({\n day,\n month: prevMonth,\n year: prevMonthYear,\n isCurrentMonth: false,\n date: new Date(prevMonthYear, prevMonth, day),\n })\n }\n }\n\n const currentMonthDays = []\n\n for (let day = 1; day <= daysInMonth; day++) {\n currentMonthDays.push({\n day,\n month,\n year,\n isCurrentMonth: true,\n date: new Date(year, month, day),\n })\n }\n\n const nextMonthDays = []\n const totalDaysDisplayed = prevMonthDays.length + currentMonthDays.length\n const daysToAdd = 6 * 7 - totalDaysDisplayed\n\n if (daysToAdd > 0) {\n const nextMonth = month === 11 ? 0 : month + 1\n const nextMonthYear = month === 11 ? year + 1 : year\n\n for (let day = 1; day <= daysToAdd; day++) {\n nextMonthDays.push({\n day,\n month: nextMonth,\n year: nextMonthYear,\n isCurrentMonth: false,\n date: new Date(nextMonthYear, nextMonth, day),\n })\n }\n }\n\n return [...prevMonthDays, ...currentMonthDays, ...nextMonthDays]\n}\n\nexport interface MonthCalendarProps<T extends CalendarEvent = CalendarEvent>\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n date?: Date\n events?: T[]\n onEventClick?: (event: T) => void\n onDayClick?: (date: Date) => void\n locale?: CalendarLocale\n allowPastInteraction?: boolean\n maxEventsPerDay?: number\n onMoreEventsClick?: (date: Date, events: T[]) => void\n header?: boolean\n daySelector?: boolean\n ellipsis?: boolean\n 'data-testid'?: string\n}\n\nexport const MonthCalendar = forwardRef<HTMLDivElement, MonthCalendarProps>(\n <T extends CalendarEvent>(\n {\n date = new Date(),\n events = [],\n maxEventsPerDay = 5,\n onEventClick,\n onDayClick,\n onMoreEventsClick,\n header,\n daySelector,\n locale = defaultLocale,\n ellipsis,\n allowPastInteraction = false,\n className = '',\n 'data-testid': testId,\n ...rest\n }: MonthCalendarProps<T>,\n ref: React.ForwardedRef<HTMLDivElement>\n ) => {\n const [selectedDate, setSelectedDate] = useState(new Date())\n\n const year = date.getFullYear()\n const month = date.getMonth()\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n return (\n <div\n ref={ref}\n className={`flex h-full w-full flex-col bg-base-100 ${className}`}\n data-testid={testId}\n {...rest}\n >\n {header && (\n <div className=\"mb-4 flex items-center justify-between\" data-testid={getTestId('header')}>\n <div>\n <h2 className=\"m-0 text-lg font-medium text-base-content\">\n {locale.monthsLong[month]} {year}\n </h2>\n </div>\n </div>\n )}\n\n {/* Weekday header */}\n <div className=\"grid grid-cols-7 border-b border-base-300\" data-testid={getTestId('weekday-header')}>\n {locale.daysShort.map((day, index) => (\n <div\n key={index}\n className=\"py-1 text-center text-xs font-medium uppercase text-base-content/60\"\n data-testid={getTestId(`weekday-${index}`)}\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid flex-1 grid-cols-7 grid-rows-6 border-l border-base-300\" data-testid={getTestId('grid')}>\n {generateCalendarGrid(year, month).map((dateObj, index) => {\n const dateEvents = getEventsForDate(events as T[], dateObj.date)\n const isPast = isPastDate(dateObj.date) && !isToday(dateObj.date)\n const isSelected = daySelector && isEqual(dateObj.date, selectedDate)\n const dateKey = `${dateObj.year}-${dateObj.month + 1}-${dateObj.day}`\n\n return (\n <div\n key={index}\n className={`\n relative cursor-pointer overflow-hidden border-b border-r border-base-300 p-1\n hover:bg-base-200\n ${!dateObj.isCurrentMonth ? 'bg-base-200' : ''}\n ${isToday(dateObj.date) ? 'bg-primary/10' : ''}\n ${isPast ? 'opacity-60' : ''}\n ${isPast && !allowPastInteraction ? 'cursor-not-allowed' : ''}\n ${isSelected ? 'z-10 outline outline-2 outline-primary' : ''}\n `}\n data-testid={getTestId(`day-${dateKey}`)}\n onClick={() => {\n if (isPast && !allowPastInteraction) {\n return\n }\n\n if (daySelector) {\n setSelectedDate(dateObj.date)\n }\n\n setTimeout(() => {\n onDayClick?.(dateObj.date)\n }, 0)\n }}\n >\n {/* Date number */}\n <div className=\"mb-0.5 flex justify-center\">\n <span\n className={`\n flex items-center justify-center text-xs leading-none\n ${isToday(dateObj.date) ? 'font-bold text-primary' : 'text-base-content'}\n ${!dateObj.isCurrentMonth ? 'text-base-content/40' : ''}\n ${isPast && dateObj.isCurrentMonth ? 'text-base-content/40' : ''}\n `}\n data-testid={getTestId(`day-number-${dateKey}`)}\n >\n {dateObj.day}\n </span>\n </div>\n\n {/* Events container */}\n <div className=\"flex flex-col\">\n {dateEvents\n .slice(\n 0,\n dateEvents.length > maxEventsPerDay\n ? maxEventsPerDay - 1\n : maxEventsPerDay\n )\n .map((event, eventIndex) => (\n <div\n key={eventIndex}\n className={`\n flex cursor-pointer items-center rounded px-1 py-0.5 text-xs leading-none\n transition-colors hover:bg-base-content/5\n ${isFutureDate(event.date) ? 'text-base-content' : 'text-base-content'}\n ${event.strikethrough ? 'line-through' : ''}\n `}\n style={event.style}\n data-testid={getTestId(`event-${dateKey}-${eventIndex}`)}\n onClick={(e) => {\n e.stopPropagation()\n if (onEventClick) {\n onEventClick(event)\n }\n }}\n title={event.title}\n >\n <span\n className=\"mr-1.5 inline-block h-2 w-2 shrink-0 rounded-full\"\n style={{ backgroundColor: event.color }}\n />\n <span\n className={`overflow-hidden whitespace-nowrap ${ellipsis ? 'text-ellipsis' : ''}`}\n >\n {event.title}\n </span>\n </div>\n ))}\n {dateEvents.length > maxEventsPerDay && (\n <div\n className=\"cursor-pointer rounded px-1 py-0.5 text-[11px] text-base-content/60 hover:bg-base-content/5\"\n data-testid={getTestId(`more-${dateKey}`)}\n onClick={(e) => {\n e.stopPropagation()\n if (onMoreEventsClick) {\n onMoreEventsClick(dateObj.date, dateEvents)\n }\n }}\n >\n +{dateEvents.length - maxEventsPerDay + 1} {locale.moreText}\n </div>\n )}\n </div>\n </div>\n )\n })}\n </div>\n </div>\n )\n }\n) as <T extends CalendarEvent = CalendarEvent>(\n props: MonthCalendarProps<T> & { ref?: React.ForwardedRef<HTMLDivElement> }\n) => React.ReactElement\n\n;(MonthCalendar as React.FC).displayName = 'MonthCalendar'\n"],"names":["defaultLocale","isToday","date","isEqual","a","b","acopy","bcopy","isFutureDate","today","checkDate","isPastDate","getEventsForDate","events","event","getDaysInMonth","year","month","getFirstDayOfMonth","generateCalendarGrid","daysInMonth","firstDayOfMonth","prevMonthDays","prevMonth","prevMonthYear","daysInPrevMonth","i","day","currentMonthDays","nextMonthDays","daysToAdd","nextMonth","nextMonthYear","MonthCalendar","forwardRef","maxEventsPerDay","onEventClick","onDayClick","onMoreEventsClick","header","daySelector","locale","ellipsis","allowPastInteraction","className","testId","rest","ref","selectedDate","setSelectedDate","useState","getTestId","suffix","jsxs","jsx","index","dateObj","dateEvents","isPast","isSelected","dateKey","eventIndex","e"],"mappings":";;AAuBA,MAAMA,IAAgC;AAAA,EACpC,QAAQ;AAAA,EACR,WAAW,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAAA,EAC3D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,UAAU;AACZ,GAGMC,IAAU,CAACC,MAAeC,EAAQD,GAAM,oBAAI,MAAM,GAElDC,IAAU,CAACC,G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A,kBACrD,EAAA,CAEJ;AAAA,gBAAA;AAAA,cAAA;AAAA,cA7FKc;AAAA,YAAA;AAAA,UAgGX,CAAC,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAIEtB,EAA2B,cAAc;"}
|
|
@@ -18,5 +18,7 @@ export interface NavbarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'co
|
|
|
18
18
|
shadow?: NavbarShadow;
|
|
19
19
|
/** Border radius */
|
|
20
20
|
rounded?: NavbarRounded;
|
|
21
|
+
/** Test ID for testing */
|
|
22
|
+
'data-testid'?: string;
|
|
21
23
|
}
|
|
22
24
|
export declare const Navbar: React.FC<NavbarProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navbar.js","sources":["../../src/components/Navbar.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dNavbar = 'navbar'\nconst dNavbarStart = 'navbar-start'\nconst dNavbarCenter = 'navbar-center'\nconst dNavbarEnd = 'navbar-end'\n\nexport type NavbarColor = 'base' | 'neutral' | 'primary' | 'secondary' | 'accent'\nexport type NavbarShadow = 'none' | 'sm' | 'md' | 'lg' | 'xl'\nexport type NavbarRounded = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\nexport interface NavbarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'> {\n children?: React.ReactNode\n /** Content for the start section of the navbar (typically logo/brand) */\n start?: React.ReactNode\n /** Content for the center section of the navbar */\n center?: React.ReactNode\n /** Content for the end section of the navbar (typically actions/menu) */\n end?: React.ReactNode\n /** Background color variant */\n color?: NavbarColor\n /** Make navbar sticky at the top */\n sticky?: boolean\n /** Shadow depth */\n shadow?: NavbarShadow\n /** Border radius */\n rounded?: NavbarRounded\n}\n\nconst colorClasses: Record<NavbarColor, string> = {\n base: 'bg-base-100',\n neutral: 'bg-neutral text-neutral-content',\n primary: 'bg-primary text-primary-content',\n secondary: 'bg-secondary text-secondary-content',\n accent: 'bg-accent text-accent-content',\n}\n\nconst shadowClasses: Record<NavbarShadow, string> = {\n none: '',\n sm: 'shadow-sm',\n md: 'shadow-md',\n lg: 'shadow-lg',\n xl: 'shadow-xl',\n}\n\nconst roundedClasses: Record<NavbarRounded, string> = {\n none: '',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-lg',\n xl: 'rounded-xl',\n full: 'rounded-full',\n}\n\nexport const Navbar: React.FC<NavbarProps> = ({\n children,\n start,\n center,\n end,\n color = 'base',\n sticky = false,\n shadow = 'none',\n rounded = 'none',\n className = '',\n ...rest\n}) => {\n const navbarClasses = [\n dNavbar,\n colorClasses[color],\n sticky && 'sticky top-0 z-50',\n shadowClasses[shadow],\n roundedClasses[rounded],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n if (children) {\n return <nav className={navbarClasses} {...rest}>{children}</nav>\n }\n\n return (\n <nav className={navbarClasses} {...rest}>\n {start && <div className={dNavbarStart}>{start}</div>}\n {center && <div className={dNavbarCenter}>{center}</div>}\n {end && <div className={dNavbarEnd}>{end}</div>}\n </nav>\n )\n}\n"],"names":["dNavbar","dNavbarStart","dNavbarCenter","dNavbarEnd","colorClasses","shadowClasses","roundedClasses","Navbar","children","start","center","end","color","sticky","shadow","rounded","className","rest","navbarClasses","jsxs","jsx"],"mappings":";AAGA,MAAMA,IAAU,UACVC,IAAe,gBACfC,IAAgB,iBAChBC,IAAa,
|
|
1
|
+
{"version":3,"file":"Navbar.js","sources":["../../src/components/Navbar.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dNavbar = 'navbar'\nconst dNavbarStart = 'navbar-start'\nconst dNavbarCenter = 'navbar-center'\nconst dNavbarEnd = 'navbar-end'\n\nexport type NavbarColor = 'base' | 'neutral' | 'primary' | 'secondary' | 'accent'\nexport type NavbarShadow = 'none' | 'sm' | 'md' | 'lg' | 'xl'\nexport type NavbarRounded = 'none' | 'sm' | 'md' | 'lg' | 'xl' | 'full'\n\nexport interface NavbarProps extends Omit<React.HTMLAttributes<HTMLElement>, 'color'> {\n children?: React.ReactNode\n /** Content for the start section of the navbar (typically logo/brand) */\n start?: React.ReactNode\n /** Content for the center section of the navbar */\n center?: React.ReactNode\n /** Content for the end section of the navbar (typically actions/menu) */\n end?: React.ReactNode\n /** Background color variant */\n color?: NavbarColor\n /** Make navbar sticky at the top */\n sticky?: boolean\n /** Shadow depth */\n shadow?: NavbarShadow\n /** Border radius */\n rounded?: NavbarRounded\n /** Test ID for testing */\n 'data-testid'?: string\n}\n\nconst colorClasses: Record<NavbarColor, string> = {\n base: 'bg-base-100',\n neutral: 'bg-neutral text-neutral-content',\n primary: 'bg-primary text-primary-content',\n secondary: 'bg-secondary text-secondary-content',\n accent: 'bg-accent text-accent-content',\n}\n\nconst shadowClasses: Record<NavbarShadow, string> = {\n none: '',\n sm: 'shadow-sm',\n md: 'shadow-md',\n lg: 'shadow-lg',\n xl: 'shadow-xl',\n}\n\nconst roundedClasses: Record<NavbarRounded, string> = {\n none: '',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-lg',\n xl: 'rounded-xl',\n full: 'rounded-full',\n}\n\nexport const Navbar: React.FC<NavbarProps> = ({\n children,\n start,\n center,\n end,\n color = 'base',\n sticky = false,\n shadow = 'none',\n rounded = 'none',\n className = '',\n ...rest\n}) => {\n const navbarClasses = [\n dNavbar,\n colorClasses[color],\n sticky && 'sticky top-0 z-50',\n shadowClasses[shadow],\n roundedClasses[rounded],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n if (children) {\n return <nav className={navbarClasses} {...rest}>{children}</nav>\n }\n\n return (\n <nav className={navbarClasses} {...rest}>\n {start && <div className={dNavbarStart}>{start}</div>}\n {center && <div className={dNavbarCenter}>{center}</div>}\n {end && <div className={dNavbarEnd}>{end}</div>}\n </nav>\n )\n}\n"],"names":["dNavbar","dNavbarStart","dNavbarCenter","dNavbarEnd","colorClasses","shadowClasses","roundedClasses","Navbar","children","start","center","end","color","stic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GAAa,UAAAQ,EAAA,CAAI;AAAA,EAAA,GAC3C;AAEJ;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as s, Fragment as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
const l = "toast", h = "toast-top", p = "toast-bottom", u = "toast-start", m = "toast-end", v = "toast-center",
|
|
1
|
+
import { jsx as s, Fragment as w, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useEffect as C } from "react";
|
|
3
|
+
import $ from "react-dom/client";
|
|
4
|
+
const l = "toast", h = "toast-top", p = "toast-bottom", u = "toast-start", m = "toast-end", v = "toast-center", f = "alert", g = "alert-success", N = "alert-error", x = "alert-info", y = "alert-warning", z = "btn", R = "btn-xs", B = "btn-ghost", L = "btn-circle";
|
|
5
5
|
class M {
|
|
6
6
|
notifications = [];
|
|
7
7
|
listeners = [];
|
|
@@ -20,7 +20,7 @@ class M {
|
|
|
20
20
|
this.listeners.forEach((e) => e());
|
|
21
21
|
}
|
|
22
22
|
ensureContainer() {
|
|
23
|
-
this.container || (this.container = document.createElement("div"), document.body.appendChild(this.container), this.root =
|
|
23
|
+
this.container || (this.container = document.createElement("div"), document.body.appendChild(this.container), this.root = $.createRoot(this.container), this.root.render(/* @__PURE__ */ s(T, { manager: this })));
|
|
24
24
|
}
|
|
25
25
|
open(e) {
|
|
26
26
|
this.ensureContainer();
|
|
@@ -59,7 +59,7 @@ class M {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
function T({ manager: t }) {
|
|
62
|
-
const [, e] =
|
|
62
|
+
const [, e] = b({});
|
|
63
63
|
C(() => t.subscribe(() => {
|
|
64
64
|
e({});
|
|
65
65
|
}), [t]);
|
|
@@ -82,20 +82,30 @@ function T({ manager: t }) {
|
|
|
82
82
|
bottomLeft: `${l} ${p} ${u} z-[9999]`,
|
|
83
83
|
bottomCenter: `${l} ${p} ${v} z-[9999]`
|
|
84
84
|
};
|
|
85
|
-
return /* @__PURE__ */ s(
|
|
86
|
-
|
|
85
|
+
return /* @__PURE__ */ s(w, { children: Object.entries(n).map(([r, a]) => a.length === 0 ? null : /* @__PURE__ */ s(
|
|
86
|
+
"div",
|
|
87
87
|
{
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
className: i[r],
|
|
89
|
+
role: "region",
|
|
90
|
+
"aria-live": "polite",
|
|
91
|
+
"aria-label": "Notifications",
|
|
92
|
+
children: a.map((c) => /* @__PURE__ */ s(
|
|
93
|
+
k,
|
|
94
|
+
{
|
|
95
|
+
notification: c,
|
|
96
|
+
onClose: () => t.close(c.id)
|
|
97
|
+
},
|
|
98
|
+
c.id
|
|
99
|
+
))
|
|
90
100
|
},
|
|
91
|
-
|
|
92
|
-
)) }
|
|
101
|
+
r
|
|
102
|
+
)) });
|
|
93
103
|
}
|
|
94
104
|
function k({ notification: t, onClose: e }) {
|
|
95
105
|
const o = t.variant === "compact", n = {
|
|
96
|
-
success:
|
|
97
|
-
error:
|
|
98
|
-
info:
|
|
106
|
+
success: g,
|
|
107
|
+
error: N,
|
|
108
|
+
info: x,
|
|
99
109
|
warning: y
|
|
100
110
|
}, i = {
|
|
101
111
|
success: /* @__PURE__ */ s("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z", clipRule: "evenodd" }) }),
|
|
@@ -108,22 +118,24 @@ function k({ notification: t, onClose: e }) {
|
|
|
108
118
|
return o ? /* @__PURE__ */ s(
|
|
109
119
|
"div",
|
|
110
120
|
{
|
|
111
|
-
className: `${
|
|
121
|
+
className: `${f} ${n[t.type]} shadow-md py-2 px-4 cursor-pointer${t.className ? ` ${t.className}` : ""}`,
|
|
112
122
|
style: t.style,
|
|
113
123
|
"data-testid": t["data-testid"],
|
|
114
124
|
onClick: r,
|
|
125
|
+
role: "alert",
|
|
115
126
|
children: /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
|
|
116
|
-
a,
|
|
127
|
+
/* @__PURE__ */ s("span", { "aria-hidden": "true", children: a }),
|
|
117
128
|
/* @__PURE__ */ s("span", { children: t.message })
|
|
118
129
|
] })
|
|
119
130
|
}
|
|
120
131
|
) : /* @__PURE__ */ d(
|
|
121
132
|
"div",
|
|
122
133
|
{
|
|
123
|
-
className: `${
|
|
134
|
+
className: `${f} ${n[t.type]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative${t.className ? ` ${t.className}` : ""}`,
|
|
124
135
|
style: t.style,
|
|
125
136
|
"data-testid": t["data-testid"],
|
|
126
137
|
onClick: r,
|
|
138
|
+
role: "alert",
|
|
127
139
|
children: [
|
|
128
140
|
/* @__PURE__ */ d("div", { className: t.closable ? "pr-8" : "", children: [
|
|
129
141
|
t.message && /* @__PURE__ */ s("div", { className: "font-bold", children: t.message }),
|
|
@@ -132,10 +144,12 @@ function k({ notification: t, onClose: e }) {
|
|
|
132
144
|
t.closable && /* @__PURE__ */ s(
|
|
133
145
|
"button",
|
|
134
146
|
{
|
|
147
|
+
type: "button",
|
|
135
148
|
className: `${z} ${R} ${B} ${L} absolute top-2 right-2`,
|
|
136
149
|
onClick: (c) => {
|
|
137
150
|
c.stopPropagation(), e();
|
|
138
151
|
},
|
|
152
|
+
"aria-label": "Close notification",
|
|
139
153
|
children: "✕"
|
|
140
154
|
}
|
|
141
155
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Notification.js","sources":["../../src/components/Notification.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport ReactDOM from 'react-dom/client'\n\n// DaisyUI classes\nconst dToast = 'toast'\nconst dToastTop = 'toast-top'\nconst dToastBottom = 'toast-bottom'\nconst dToastStart = 'toast-start'\nconst dToastEnd = 'toast-end'\nconst dToastCenter = 'toast-center'\nconst dAlert = 'alert'\nconst dAlertSuccess = 'alert-success'\nconst dAlertError = 'alert-error'\nconst dAlertInfo = 'alert-info'\nconst dAlertWarning = 'alert-warning'\nconst dBtn = 'btn'\nconst dBtnXs = 'btn-xs'\nconst dBtnGhost = 'btn-ghost'\nconst dBtnCircle = 'btn-circle'\n\nexport type NotificationType = 'success' | 'info' | 'warning' | 'error'\nexport type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topCenter' | 'bottomCenter'\nexport type NotificationVariant = 'default' | 'compact'\n\nexport interface NotificationConfig {\n message: React.ReactNode\n description?: React.ReactNode\n type?: NotificationType\n duration?: number // in seconds, 0 = no auto close\n placement?: NotificationPlacement\n variant?: NotificationVariant\n closable?: boolean\n icon?: React.ReactNode\n key?: string\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n onClick?: () => void\n onClose?: () => void\n}\n\ninterface NotificationItem extends NotificationConfig {\n id: string\n createdAt: number\n}\n\ntype Listener = () => void\n\nclass NotificationManager {\n private notifications: NotificationItem[] = []\n private listeners: Listener[] = []\n private container: HTMLDivElement | null = null\n private root: ReactDOM.Root | null = null\n private idCounter = 0\n\n subscribe(listener: Listener) {\n this.listeners.push(listener)\n return () => {\n this.listeners = this.listeners.filter((l) => l !== listener)\n }\n }\n\n getNotifications() {\n return this.notifications\n }\n\n private emit() {\n this.listeners.forEach((listener) => listener())\n }\n\n private ensureContainer() {\n if (!this.container) {\n this.container = document.createElement('div')\n document.body.appendChild(this.container)\n this.root = ReactDOM.createRoot(this.container)\n this.root.render(<NotificationContainer manager={this} />)\n }\n }\n\n open(config: NotificationConfig) {\n this.ensureContainer()\n\n const id = config.key ?? `notification-${++this.idCounter}`\n const isCompact = config.variant === 'compact'\n const notificationItem: NotificationItem = {\n ...config,\n id,\n createdAt: Date.now(),\n duration: config.duration ?? (isCompact ? 3 : 4.5),\n placement: config.placement ?? (isCompact ? 'topCenter' : 'topRight'),\n variant: config.variant ?? 'default',\n closable: config.closable ?? !isCompact,\n type: config.type ?? 'info',\n }\n\n // If key exists, update the existing notification\n const existingIndex = this.notifications.findIndex((n) => n.id === id)\n if (existingIndex !== -1) {\n this.notifications[existingIndex] = notificationItem\n } else {\n this.notifications.push(notificationItem)\n }\n this.emit()\n\n // Auto-dismiss\n if (notificationItem.duration && notificationItem.duration > 0) {\n setTimeout(() => {\n this.close(id)\n }, notificationItem.duration * 1000)\n }\n\n return id\n }\n\n close(id: string) {\n const notification = this.notifications.find((n) => n.id === id)\n this.notifications = this.notifications.filter((n) => n.id !== id)\n this.emit()\n\n if (notification?.onClose) {\n notification.onClose()\n }\n }\n\n success(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'success' })\n }\n\n error(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'error' })\n }\n\n info(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'info' })\n }\n\n warning(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'warning' })\n }\n\n destroy() {\n this.notifications = []\n this.emit()\n }\n}\n\ninterface NotificationContainerProps {\n manager: NotificationManager\n}\n\nfunction NotificationContainer({ manager }: NotificationContainerProps) {\n const [, forceUpdate] = useState({})\n\n useEffect(() => {\n const unsubscribe = manager.subscribe(() => {\n forceUpdate({})\n })\n return unsubscribe\n }, [manager])\n\n const notifications = manager.getNotifications()\n\n // Group by placement\n const grouped: Record<NotificationPlacement, NotificationItem[]> = {\n topLeft: [],\n topRight: [],\n topCenter: [],\n bottomLeft: [],\n bottomRight: [],\n bottomCenter: [],\n }\n\n notifications.forEach((notification) => {\n grouped[notification.placement!].push(notification)\n })\n\n const placementClasses: Record<NotificationPlacement, string> = {\n topRight: `${dToast} ${dToastTop} ${dToastEnd} z-[9999]`,\n topLeft: `${dToast} ${dToastTop} ${dToastStart} z-[9999]`,\n topCenter: `${dToast} ${dToastTop} ${dToastCenter} z-[9999]`,\n bottomRight: `${dToast} ${dToastBottom} ${dToastEnd} z-[9999]`,\n bottomLeft: `${dToast} ${dToastBottom} ${dToastStart} z-[9999]`,\n bottomCenter: `${dToast} ${dToastBottom} ${dToastCenter} z-[9999]`,\n }\n\n return (\n <>\n {Object.entries(grouped).map(([placement, items]) => {\n if (items.length === 0) return null\n\n return (\n <div key={placement} className={placementClasses[placement as NotificationPlacement]}>\n {items.map((notification) => (\n <NotificationItem\n key={notification.id}\n notification={notification}\n onClose={() => manager.close(notification.id)}\n />\n ))}\n </div>\n )\n })}\n </>\n )\n}\n\ninterface NotificationItemProps {\n notification: NotificationItem\n onClose: () => void\n}\n\nfunction NotificationItem({ notification, onClose }: NotificationItemProps) {\n const isCompact = notification.variant === 'compact'\n\n const alertTypeClasses: Record<NotificationType, string> = {\n success: dAlertSuccess,\n error: dAlertError,\n info: dAlertInfo,\n warning: dAlertWarning,\n }\n\n const typeIcons: Record<NotificationType, React.ReactNode> = {\n success: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clipRule=\"evenodd\" /></svg>,\n error: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z\" clipRule=\"evenodd\" /></svg>,\n info: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z\" clipRule=\"evenodd\" /></svg>,\n warning: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clipRule=\"evenodd\" /></svg>,\n }\n\n const handleClick = () => {\n if (notification.onClick) {\n notification.onClick()\n }\n }\n\n const icon = notification.icon ?? typeIcons[notification.type!]\n\n if (isCompact) {\n return (\n <div\n className={`${dAlert} ${alertTypeClasses[notification.type!]} shadow-md py-2 px-4 cursor-pointer${notification.className ? ` ${notification.className}` : ''}`}\n style={notification.style}\n data-testid={notification['data-testid']}\n onClick={handleClick}\n >\n <div className=\"flex items-center gap-2\">\n {icon}\n <span>{notification.message}</span>\n </div>\n </div>\n )\n }\n\n return (\n <div\n className={`${dAlert} ${alertTypeClasses[notification.type!]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative${notification.className ? ` ${notification.className}` : ''}`}\n style={notification.style}\n data-testid={notification['data-testid']}\n onClick={handleClick}\n >\n <div className={notification.closable ? 'pr-8' : ''}>\n {notification.message && <div className=\"font-bold\">{notification.message}</div>}\n {notification.description && <div className=\"text-sm\">{notification.description}</div>}\n </div>\n {notification.closable && (\n <button\n className={`${dBtn} ${dBtnXs} ${dBtnGhost} ${dBtnCircle} absolute top-2 right-2`}\n onClick={(e) => {\n e.stopPropagation()\n onClose()\n }}\n >\n ✕\n </button>\n )}\n </div>\n )\n}\n\nexport const notification = new NotificationManager()\n"],"names":["dToast","dToastTop","dToastBottom","dToastStart","dToastEnd","dToastCenter","dAlert","dAlertSuccess","dAlertError","dAlertInfo","dAlertWarning","dBtn","dBtnXs","dBtnGhost","dBtnCircle","NotificationManager","listener","l","ReactDOM","jsx","NotificationContainer","config","id","isCompact","notificationItem","existingIndex","n","notification","manager","forceUpdate","useState","useEffect","notifications","grouped","placementClasses","Fragment","placement","items","NotificationItem","onClose","alertTypeClasses","typeIcons","handleClick","icon","jsxs","e"],"mappings":";;;AAIA,MAAMA,IAAS,SACTC,IAAY,aACZC,IAAe,gBACfC,IAAc,eACdC,IAAY,aACZC,IAAe,gBACfC,IAAS,SACTC,IAAgB,iBAChBC,IAAc,eACdC,IAAa,cACbC,IAAgB,iBAChBC,IAAO,OACPC,IAAS,UACTC,IAAY,aACZC,IAAa;AA8BnB,MAAMC,EAAoB;AAAA,EAChB,gBAAoC,CAAA;AAAA,EACpC,YAAwB,CAAA;AAAA,EACxB,YAAmC;AAAA,EACnC,OAA6B;AAAA,EAC7B,YAAY;AAAA,EAEpB,UAAUC,GAAoB;AAC5B,gBAAK,UAAU,KAAKA,CAAQ,GACrB,MAAM;AACX,WAAK,YAAY,KAAK,UAAU,OAAO,CAACC,MAAMA,MAAMD,CAAQ;AAAA,IAC9D;AAAA,EACF;AAAA,EAEA,mBAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ,OAAO;AACb,SAAK,UAAU,QAAQ,CAACA,MAAaA,GAAU;AAAA,EACjD;AAAA,EAEQ,kBAAkB;AACxB,IAAK,KAAK,cACR,KAAK,YAAY,SAAS,cAAc,KAAK,GAC7C,SAAS,KAAK,YAAY,KAAK,SAAS,GACxC,KAAK,OAAOE,EAAS,WAAW,KAAK,SAAS,GAC9C,KAAK,KAAK,OAAO,gBAAAC,EAACC,GAAA,EAAsB,SAAS,MAAM,CAAE;AAAA,EAE7D;AAAA,EAEA,KAAKC,GAA4B;AAC/B,SAAK,gB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,MAED;AAAA,IAAA;AAAA,EAAA;AAIR;AAEO,MAAMZ,IAAe,IAAIZ,EAAA;"}
|
|
1
|
+
{"version":3,"file":"Notification.js","sources":["../../src/components/Notification.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport ReactDOM from 'react-dom/client'\n\n// DaisyUI classes\nconst dToast = 'toast'\nconst dToastTop = 'toast-top'\nconst dToastBottom = 'toast-bottom'\nconst dToastStart = 'toast-start'\nconst dToastEnd = 'toast-end'\nconst dToastCenter = 'toast-center'\nconst dAlert = 'alert'\nconst dAlertSuccess = 'alert-success'\nconst dAlertError = 'alert-error'\nconst dAlertInfo = 'alert-info'\nconst dAlertWarning = 'alert-warning'\nconst dBtn = 'btn'\nconst dBtnXs = 'btn-xs'\nconst dBtnGhost = 'btn-ghost'\nconst dBtnCircle = 'btn-circle'\n\nexport type NotificationType = 'success' | 'info' | 'warning' | 'error'\nexport type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topCenter' | 'bottomCenter'\nexport type NotificationVariant = 'default' | 'compact'\n\nexport interface NotificationConfig {\n message: React.ReactNode\n description?: React.ReactNode\n type?: NotificationType\n duration?: number // in seconds, 0 = no auto close\n placement?: NotificationPlacement\n variant?: NotificationVariant\n closable?: boolean\n icon?: React.ReactNode\n key?: string\n className?: string\n style?: React.CSSProperties\n 'data-testid'?: string\n onClick?: () => void\n onClose?: () => void\n}\n\ninterface NotificationItem extends NotificationConfig {\n id: string\n createdAt: number\n}\n\ntype Listener = () => void\n\nclass NotificationManager {\n private notifications: NotificationItem[] = []\n private listeners: Listener[] = []\n private container: HTMLDivElement | null = null\n private root: ReactDOM.Root | null = null\n private idCounter = 0\n\n subscribe(listener: Listener) {\n this.listeners.push(listener)\n return () => {\n this.listeners = this.listeners.filter((l) => l !== listener)\n }\n }\n\n getNotifications() {\n return this.notifications\n }\n\n private emit() {\n this.listeners.forEach((listener) => listener())\n }\n\n private ensureContainer() {\n if (!this.container) {\n this.container = document.createElement('div')\n document.body.appendChild(this.container)\n this.root = ReactDOM.createRoot(this.container)\n this.root.render(<NotificationContainer manager={this} />)\n }\n }\n\n open(config: NotificationConfig) {\n this.ensureContainer()\n\n const id = config.key ?? `notification-${++this.idCounter}`\n const isCompact = config.variant === 'compact'\n const notificationItem: NotificationItem = {\n ...config,\n id,\n createdAt: Date.now(),\n duration: config.duration ?? (isCompact ? 3 : 4.5),\n placement: config.placement ?? (isCompact ? 'topCenter' : 'topRight'),\n variant: config.variant ?? 'default',\n closable: config.closable ?? !isCompact,\n type: config.type ?? 'info',\n }\n\n // If key exists, update the existing notification\n const existingIndex = this.notifications.findIndex((n) => n.id === id)\n if (existingIndex !== -1) {\n this.notifications[existingIndex] = notificationItem\n } else {\n this.notifications.push(notificationItem)\n }\n this.emit()\n\n // Auto-dismiss\n if (notificationItem.duration && notificationItem.duration > 0) {\n setTimeout(() => {\n this.close(id)\n }, notificationItem.duration * 1000)\n }\n\n return id\n }\n\n close(id: string) {\n const notification = this.notifications.find((n) => n.id === id)\n this.notifications = this.notifications.filter((n) => n.id !== id)\n this.emit()\n\n if (notification?.onClose) {\n notification.onClose()\n }\n }\n\n success(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'success' })\n }\n\n error(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'error' })\n }\n\n info(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'info' })\n }\n\n warning(config: Omit<NotificationConfig, 'type'>) {\n return this.open({ ...config, type: 'warning' })\n }\n\n destroy() {\n this.notifications = []\n this.emit()\n }\n}\n\ninterface NotificationContainerProps {\n manager: NotificationManager\n}\n\nfunction NotificationContainer({ manager }: NotificationContainerProps) {\n const [, forceUpdate] = useState({})\n\n useEffect(() => {\n const unsubscribe = manager.subscribe(() => {\n forceUpdate({})\n })\n return unsubscribe\n }, [manager])\n\n const notifications = manager.getNotifications()\n\n // Group by placement\n const grouped: Record<NotificationPlacement, NotificationItem[]> = {\n topLeft: [],\n topRight: [],\n topCenter: [],\n bottomLeft: [],\n bottomRight: [],\n bottomCenter: [],\n }\n\n notifications.forEach((notification) => {\n grouped[notification.placement!].push(notification)\n })\n\n const placementClasses: Record<NotificationPlacement, string> = {\n topRight: `${dToast} ${dToastTop} ${dToastEnd} z-[9999]`,\n topLeft: `${dToast} ${dToastTop} ${dToastStart} z-[9999]`,\n topCenter: `${dToast} ${dToastTop} ${dToastCenter} z-[9999]`,\n bottomRight: `${dToast} ${dToastBottom} ${dToastEnd} z-[9999]`,\n bottomLeft: `${dToast} ${dToastBottom} ${dToastStart} z-[9999]`,\n bottomCenter: `${dToast} ${dToastBottom} ${dToastCenter} z-[9999]`,\n }\n\n return (\n <>\n {Object.entries(grouped).map(([placement, items]) => {\n if (items.length === 0) return null\n\n return (\n <div\n key={placement}\n className={placementClasses[placement as NotificationPlacement]}\n role=\"region\"\n aria-live=\"polite\"\n aria-label=\"Notifications\"\n >\n {items.map((notification) => (\n <NotificationItem\n key={notification.id}\n notification={notification}\n onClose={() => manager.close(notification.id)}\n />\n ))}\n </div>\n )\n })}\n </>\n )\n}\n\ninterface NotificationItemProps {\n notification: NotificationItem\n onClose: () => void\n}\n\nfunction NotificationItem({ notification, onClose }: NotificationItemProps) {\n const isCompact = notification.variant === 'compact'\n\n const alertTypeClasses: Record<NotificationType, string> = {\n success: dAlertSuccess,\n error: dAlertError,\n info: dAlertInfo,\n warning: dAlertWarning,\n }\n\n const typeIcons: Record<NotificationType, React.ReactNode> = {\n success: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\" clipRule=\"evenodd\" /></svg>,\n error: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z\" clipRule=\"evenodd\" /></svg>,\n info: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z\" clipRule=\"evenodd\" /></svg>,\n warning: <svg xmlns=\"http://www.w3.org/2000/svg\" className=\"h-5 w-5\" viewBox=\"0 0 20 20\" fill=\"currentColor\"><path fillRule=\"evenodd\" d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\" clipRule=\"evenodd\" /></svg>,\n }\n\n const handleClick = () => {\n if (notification.onClick) {\n notification.onClick()\n }\n }\n\n const icon = notification.icon ?? typeIcons[notification.type!]\n\n if (isCompact) {\n return (\n <div\n className={`${dAlert} ${alertTypeClasses[notification.type!]} shadow-md py-2 px-4 cursor-pointer${notification.className ? ` ${notification.className}` : ''}`}\n style={notification.style}\n data-testid={notification['data-testid']}\n onClick={handleClick}\n role=\"alert\"\n >\n <div className=\"flex items-center gap-2\">\n <span aria-hidden=\"true\">{icon}</span>\n <span>{notification.message}</span>\n </div>\n </div>\n )\n }\n\n return (\n <div\n className={`${dAlert} ${alertTypeClasses[notification.type!]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative${notification.className ? ` ${notification.className}` : ''}`}\n style={notification.style}\n data-testid={notification['data-testid']}\n onClick={handleClick}\n role=\"alert\"\n >\n <div className={notification.closable ? 'pr-8' : ''}>\n {notification.message && <div className=\"font-bold\">{notification.message}</div>}\n {notification.description && <div className=\"text-sm\">{notification.description}</div>}\n </div>\n {notification.closable && (\n <button\n type=\"button\"\n className={`${dBtn} ${dBtnXs} ${dBtnGhost} ${dBtnCircle} absolute top-2 right-2`}\n onClick={(e) => {\n e.stopPropagation()\n onClose()\n }}\n aria-label=\"Close notification\"\n >\n ✕\n </button>\n )}\n </div>\n )\n}\n\nexport const notification = new NotificationManager()\n"],"names":["dToast","dToastTop","dToastBottom","dToastStart","dToastEnd","dToastCenter","dAlert","dAlertSuccess","dAlertError","dAlertInfo","dAlertWarning","dBtn","dBtnXs","dBtnGhost","dBtnCircle","NotificationManager","listener","l","ReactDOM","jsx","NotificationContainer","config","id","isCompact","notificationItem","existingIndex","n","notification","manager","forceUpdate","useState","useEffect","notifications","grouped","placementClasses","Fragment","placement","items","NotificationItem","onClose","alertTypeClasses","typeIcons","handleClick","icon","jsxs","e"],"mappings":";;;AAIA,MAAMA,IAAS,SACTC,IAAY,aACZC,IAAe,gBACfC,IAAc,eACdC,IAAY,aACZC,IAAe,gBACfC,IAAS,SACTC,IAAgB,iBAChBC,IAAc,eACdC,IAAa,cACbC,IAAgB,iBAChBC,IAAO,OACPC,IAAS,UACTC,IAAY,aACZC,IAAa;AA8BnB,MAAMC,EAAoB;AAAA,EAChB,gBAAoC,CAAA;AAAA,EACpC,YAAwB,CAAA;AAAA,EACxB,YAAmC;AAAA,EACnC,OAA6B;AAAA,EAC7B,YAAY;AAAA,EAEpB,UAAUC,GAAoB;AAC5B,gBAAK,UAAU,KAAKA,CAAQ,GACrB,MAAM;AACX,WAAK,YAAY,KAAK,UAAU,OAAO,CAACC,MAAMA,MAAMD,CA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