asterui 0.12.26 → 0.12.28

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.
Files changed (166) hide show
  1. package/dist/components/Collapse.d.ts +40 -20
  2. package/dist/components/Descriptions.d.ts +35 -3
  3. package/dist/components/Empty.d.ts +10 -1
  4. package/dist/components/Image.d.ts +13 -1
  5. package/dist/components/List.d.ts +74 -8
  6. package/dist/components/Table.d.ts +64 -10
  7. package/dist/components/Timeline.d.ts +62 -7
  8. package/dist/index.d.ts +4 -6
  9. package/dist/index.js +148 -150
  10. package/dist/index.js.map +1 -1
  11. package/dist/index10.js +1 -1
  12. package/dist/index100.js +5 -32
  13. package/dist/index100.js.map +1 -1
  14. package/dist/index101.js +13 -5
  15. package/dist/index101.js.map +1 -1
  16. package/dist/index102.js +43 -11
  17. package/dist/index102.js.map +1 -1
  18. package/dist/index103.js +11 -44
  19. package/dist/index103.js.map +1 -1
  20. package/dist/index104.js +12 -10
  21. package/dist/index104.js.map +1 -1
  22. package/dist/index105.js +7 -14
  23. package/dist/index105.js.map +1 -1
  24. package/dist/index106.js +12 -7
  25. package/dist/index106.js.map +1 -1
  26. package/dist/index107.js +29 -11
  27. package/dist/index107.js.map +1 -1
  28. package/dist/index108.js +16 -29
  29. package/dist/index108.js.map +1 -1
  30. package/dist/index109.js +31 -16
  31. package/dist/index109.js.map +1 -1
  32. package/dist/index110.js +517 -30
  33. package/dist/index110.js.map +1 -1
  34. package/dist/index111.js +45 -515
  35. package/dist/index111.js.map +1 -1
  36. package/dist/index18.js +105 -64
  37. package/dist/index18.js.map +1 -1
  38. package/dist/index22.js +1 -1
  39. package/dist/index23.js +127 -93
  40. package/dist/index23.js.map +1 -1
  41. package/dist/index39.js +162 -115
  42. package/dist/index39.js.map +1 -1
  43. package/dist/index40.js +398 -40
  44. package/dist/index40.js.map +1 -1
  45. package/dist/index41.js +132 -389
  46. package/dist/index41.js.map +1 -1
  47. package/dist/index42.js +252 -91
  48. package/dist/index42.js.map +1 -1
  49. package/dist/index43.js +143 -247
  50. package/dist/index43.js.map +1 -1
  51. package/dist/index44.js +15 -154
  52. package/dist/index44.js.map +1 -1
  53. package/dist/index45.js +17 -15
  54. package/dist/index45.js.map +1 -1
  55. package/dist/index46.js +136 -16
  56. package/dist/index46.js.map +1 -1
  57. package/dist/index47.js +118 -133
  58. package/dist/index47.js.map +1 -1
  59. package/dist/index48.js +35 -13
  60. package/dist/index48.js.map +1 -1
  61. package/dist/index49.js +34 -35
  62. package/dist/index49.js.map +1 -1
  63. package/dist/index50.js +81 -34
  64. package/dist/index50.js.map +1 -1
  65. package/dist/index51.js +166 -71
  66. package/dist/index51.js.map +1 -1
  67. package/dist/index52.js +144 -167
  68. package/dist/index52.js.map +1 -1
  69. package/dist/index53.js +11 -152
  70. package/dist/index53.js.map +1 -1
  71. package/dist/index54.js +55 -10
  72. package/dist/index54.js.map +1 -1
  73. package/dist/index55.js +12 -55
  74. package/dist/index55.js.map +1 -1
  75. package/dist/index56.js +7 -14
  76. package/dist/index56.js.map +1 -1
  77. package/dist/index57.js +333 -6
  78. package/dist/index57.js.map +1 -1
  79. package/dist/index58.js +47 -334
  80. package/dist/index58.js.map +1 -1
  81. package/dist/index59.js +122 -47
  82. package/dist/index59.js.map +1 -1
  83. package/dist/index60.js +108 -120
  84. package/dist/index60.js.map +1 -1
  85. package/dist/index61.js +167 -107
  86. package/dist/index61.js.map +1 -1
  87. package/dist/index62.js +29 -167
  88. package/dist/index62.js.map +1 -1
  89. package/dist/index63.js +120 -30
  90. package/dist/index63.js.map +1 -1
  91. package/dist/index64.js +80 -116
  92. package/dist/index64.js.map +1 -1
  93. package/dist/index65.js +19 -85
  94. package/dist/index65.js.map +1 -1
  95. package/dist/index66.js +73 -19
  96. package/dist/index66.js.map +1 -1
  97. package/dist/index67.js +54 -71
  98. package/dist/index67.js.map +1 -1
  99. package/dist/index68.js +44 -56
  100. package/dist/index68.js.map +1 -1
  101. package/dist/index69.js +49 -42
  102. package/dist/index69.js.map +1 -1
  103. package/dist/index70.js +121 -50
  104. package/dist/index70.js.map +1 -1
  105. package/dist/index71.js +102 -118
  106. package/dist/index71.js.map +1 -1
  107. package/dist/index72.js +72 -105
  108. package/dist/index72.js.map +1 -1
  109. package/dist/index73.js +67 -73
  110. package/dist/index73.js.map +1 -1
  111. package/dist/index74.js +19 -66
  112. package/dist/index74.js.map +1 -1
  113. package/dist/index75.js +55 -18
  114. package/dist/index75.js.map +1 -1
  115. package/dist/index76.js +251 -55
  116. package/dist/index76.js.map +1 -1
  117. package/dist/index77.js +22 -254
  118. package/dist/index77.js.map +1 -1
  119. package/dist/index78.js +31 -22
  120. package/dist/index78.js.map +1 -1
  121. package/dist/index79.js +93 -30
  122. package/dist/index79.js.map +1 -1
  123. package/dist/index80.js +626 -86
  124. package/dist/index80.js.map +1 -1
  125. package/dist/index81.js +73 -322
  126. package/dist/index81.js.map +1 -1
  127. package/dist/index82.js +39 -79
  128. package/dist/index82.js.map +1 -1
  129. package/dist/index83.js +23 -40
  130. package/dist/index83.js.map +1 -1
  131. package/dist/index84.js +207 -23
  132. package/dist/index84.js.map +1 -1
  133. package/dist/index85.js +148 -199
  134. package/dist/index85.js.map +1 -1
  135. package/dist/index86.js +152 -147
  136. package/dist/index86.js.map +1 -1
  137. package/dist/index87.js +143 -156
  138. package/dist/index87.js.map +1 -1
  139. package/dist/index88.js +35 -65
  140. package/dist/index88.js.map +1 -1
  141. package/dist/index89.js +234 -35
  142. package/dist/index89.js.map +1 -1
  143. package/dist/index90.js +31 -231
  144. package/dist/index90.js.map +1 -1
  145. package/dist/index91.js +210 -34
  146. package/dist/index91.js.map +1 -1
  147. package/dist/index92.js +418 -187
  148. package/dist/index92.js.map +1 -1
  149. package/dist/index93.js +686 -376
  150. package/dist/index93.js.map +1 -1
  151. package/dist/index94.js +165 -738
  152. package/dist/index94.js.map +1 -1
  153. package/dist/index95.js +253 -173
  154. package/dist/index95.js.map +1 -1
  155. package/dist/index96.js +64 -256
  156. package/dist/index96.js.map +1 -1
  157. package/dist/index97.js +121 -61
  158. package/dist/index97.js.map +1 -1
  159. package/dist/index98.js +14 -126
  160. package/dist/index98.js.map +1 -1
  161. package/dist/index99.js +31 -12
  162. package/dist/index99.js.map +1 -1
  163. package/package.json +1 -1
  164. package/dist/components/Indicator.d.ts +0 -7
  165. package/dist/index112.js +0 -53
  166. package/dist/index112.js.map +0 -1
package/dist/index58.js CHANGED
@@ -1,337 +1,50 @@
1
- import { jsxs as m, jsx as t, Fragment as U } from "react/jsx-runtime";
2
- import M, { useRef as f, useId as I, useEffect as S } from "react";
3
- import { createRoot as V } from "react-dom/client";
4
- function u({
5
- children: e,
6
- title: r,
7
- footer: s,
8
- open: l = !1,
9
- onOk: a,
10
- onCancel: d,
11
- okText: y = "OK",
12
- cancelText: c = "Cancel",
13
- maskClosable: h = !0,
14
- closable: p = !0,
15
- position: n,
16
- align: b,
17
- width: i,
18
- centered: C,
19
- onClose: g,
20
- initialFocus: k,
21
- alertDialog: A = !1,
22
- className: D = "",
23
- ...K
24
- }) {
25
- const N = f(null), R = f(null), T = f(null), j = f(null), O = f(null), [L, B] = M.useState(!1), $ = I(), E = I(), v = g || d;
26
- S(() => {
27
- const o = N.current;
28
- o && (l ? o.open || (O.current = document.activeElement, o.showModal(), k && setTimeout(() => {
29
- switch (k) {
30
- case "ok":
31
- R.current?.focus();
32
- break;
33
- case "cancel":
34
- T.current?.focus();
35
- break;
36
- case "close":
37
- j.current?.focus();
38
- break;
39
- }
40
- }, 0)) : o.open && (o.close(), O.current?.focus()));
41
- }, [l, k]), S(() => {
42
- const o = N.current;
43
- if (!o) return;
44
- const x = () => {
45
- v?.();
46
- };
47
- return o.addEventListener("close", x), () => {
48
- o.removeEventListener("close", x);
49
- };
50
- }, [v]);
51
- const W = {
52
- top: "modal-top",
53
- middle: "modal-middle",
54
- bottom: "modal-bottom"
55
- }, P = {
56
- base: {
57
- top: "modal-top",
58
- middle: "modal-middle",
59
- bottom: "modal-bottom"
60
- },
61
- sm: {
62
- top: "sm:modal-top",
63
- middle: "sm:modal-middle",
64
- bottom: "sm:modal-bottom"
65
- },
66
- md: {
67
- top: "md:modal-top",
68
- middle: "md:modal-middle",
69
- bottom: "md:modal-bottom"
70
- },
71
- lg: {
72
- top: "lg:modal-top",
73
- middle: "lg:modal-middle",
74
- bottom: "lg:modal-bottom"
75
- },
76
- xl: {
77
- top: "xl:modal-top",
78
- middle: "xl:modal-middle",
79
- bottom: "xl:modal-bottom"
80
- },
81
- "2xl": {
82
- top: "2xl:modal-top",
83
- middle: "2xl:modal-middle",
84
- bottom: "2xl:modal-bottom"
85
- }
86
- }, _ = {
87
- start: "modal-start",
88
- end: "modal-end"
89
- }, F = [
90
- "modal",
91
- ...(() => {
92
- if (C)
93
- return [W.middle];
94
- if (!n)
95
- return [];
96
- if (typeof n == "string")
97
- return [W[n]];
98
- const o = [];
99
- for (const [x, z] of Object.entries(n))
100
- z && o.push(P[x][z]);
101
- return o;
102
- })(),
103
- b && _[b],
104
- D
105
- ].filter(Boolean).join(" "), H = async () => {
106
- if (a) {
107
- B(!0);
108
- try {
109
- await a(), B(!1);
110
- } catch (o) {
111
- throw B(!1), o;
112
- }
113
- }
114
- }, q = () => {
115
- h && v && v();
116
- }, G = i ? { width: typeof i == "number" ? `${i}px` : i, maxWidth: "90vw" } : {}, J = !s && (a || d), Q = s != null;
117
- return /* @__PURE__ */ m(
118
- "dialog",
119
- {
120
- ref: N,
121
- role: A ? "alertdialog" : "dialog",
122
- "aria-modal": "true",
123
- className: F,
124
- "data-state": l ? "open" : "closed",
125
- "aria-labelledby": r ? $ : void 0,
126
- "aria-describedby": E,
127
- ...K,
128
- children: [
129
- /* @__PURE__ */ m("div", { className: "modal-box", style: G, children: [
130
- r && /* @__PURE__ */ t("h3", { id: $, className: "text-lg font-bold mb-4", children: r }),
131
- /* @__PURE__ */ t("div", { id: E, className: "py-4", children: e }),
132
- J && /* @__PURE__ */ m("div", { className: "modal-action", children: [
133
- d && /* @__PURE__ */ t("button", { ref: T, className: "btn", onClick: d, children: c }),
134
- a && /* @__PURE__ */ t(
135
- "button",
136
- {
137
- ref: R,
138
- className: `btn btn-primary ${L ? "loading" : ""}`,
139
- onClick: H,
140
- disabled: L,
141
- "aria-busy": L || void 0,
142
- children: y
143
- }
144
- )
145
- ] }),
146
- Q && /* @__PURE__ */ t("div", { className: "modal-action", children: s })
147
- ] }),
148
- p && h && /* @__PURE__ */ t("form", { method: "dialog", className: "modal-backdrop", children: /* @__PURE__ */ t("button", { ref: j, onClick: q, children: /* @__PURE__ */ t("span", { className: "sr-only", children: "Close modal" }) }) })
149
- ]
150
- }
151
- );
152
- }
153
- function w(e) {
154
- const r = document.createElement("div");
155
- document.body.appendChild(r);
156
- const s = V(r), l = () => {
157
- s.unmount(), r.parentNode && r.parentNode.removeChild(r);
158
- }, a = () => {
159
- const [d, y] = M.useState(!0), [c, h] = M.useState(!1), p = () => {
160
- y(!1), setTimeout(l, 300);
161
- }, n = async () => {
162
- if (e.onOk) {
163
- h(!0);
164
- try {
165
- await e.onOk(), p();
166
- } catch {
167
- h(!1);
168
- }
169
- } else
170
- p();
171
- }, b = () => {
172
- e.onCancel?.(), p();
173
- }, i = () => {
174
- switch (e.type) {
175
- case "success":
176
- return "alert-success";
177
- case "warning":
178
- return "alert-warning";
179
- case "error":
180
- return "alert-error";
181
- case "info":
182
- default:
183
- return "alert-info";
184
- }
185
- }, C = () => {
186
- switch (e.type) {
187
- case "success":
188
- return /* @__PURE__ */ t(
189
- "svg",
190
- {
191
- xmlns: "http://www.w3.org/2000/svg",
192
- className: "stroke-current shrink-0 h-6 w-6",
193
- fill: "none",
194
- viewBox: "0 0 24 24",
195
- "aria-hidden": "true",
196
- children: /* @__PURE__ */ t(
197
- "path",
198
- {
199
- strokeLinecap: "round",
200
- strokeLinejoin: "round",
201
- strokeWidth: "2",
202
- d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
203
- }
204
- )
205
- }
206
- );
207
- case "warning":
208
- return /* @__PURE__ */ t(
209
- "svg",
210
- {
211
- xmlns: "http://www.w3.org/2000/svg",
212
- className: "stroke-current shrink-0 h-6 w-6",
213
- fill: "none",
214
- viewBox: "0 0 24 24",
215
- "aria-hidden": "true",
216
- children: /* @__PURE__ */ t(
217
- "path",
218
- {
219
- strokeLinecap: "round",
220
- strokeLinejoin: "round",
221
- strokeWidth: "2",
222
- d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
223
- }
224
- )
225
- }
226
- );
227
- case "error":
228
- return /* @__PURE__ */ t(
229
- "svg",
230
- {
231
- xmlns: "http://www.w3.org/2000/svg",
232
- className: "stroke-current shrink-0 h-6 w-6",
233
- fill: "none",
234
- viewBox: "0 0 24 24",
235
- "aria-hidden": "true",
236
- children: /* @__PURE__ */ t(
237
- "path",
238
- {
239
- strokeLinecap: "round",
240
- strokeLinejoin: "round",
241
- strokeWidth: "2",
242
- d: "M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
243
- }
244
- )
245
- }
246
- );
247
- case "info":
248
- default:
249
- return /* @__PURE__ */ t(
250
- "svg",
251
- {
252
- xmlns: "http://www.w3.org/2000/svg",
253
- fill: "none",
254
- viewBox: "0 0 24 24",
255
- className: "stroke-current shrink-0 w-6 h-6",
256
- "aria-hidden": "true",
257
- children: /* @__PURE__ */ t(
258
- "path",
259
- {
260
- strokeLinecap: "round",
261
- strokeLinejoin: "round",
262
- strokeWidth: "2",
263
- d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
264
- }
265
- )
266
- }
267
- );
268
- }
269
- }, g = e.type === "warning" || e.type === "error";
270
- return /* @__PURE__ */ m(
271
- u,
272
- {
273
- open: d,
274
- onOk: e.showCancel ? void 0 : n,
275
- onCancel: b,
276
- alertDialog: g,
277
- title: e.type ? /* @__PURE__ */ m("div", { className: `alert ${i()}`, children: [
278
- C(),
279
- /* @__PURE__ */ t("div", { children: e.title && /* @__PURE__ */ t("h3", { className: "font-bold", children: e.title }) })
280
- ] }) : e.title,
281
- okText: e.okText,
282
- cancelText: e.cancelText,
283
- footer: e.showCancel ? /* @__PURE__ */ m(U, { children: [
284
- /* @__PURE__ */ t("button", { className: "btn", onClick: b, children: e.cancelText || "Cancel" }),
285
- /* @__PURE__ */ t(
286
- "button",
287
- {
288
- className: `btn ${e.type === "error" ? "btn-error" : "btn-primary"} ${c ? "loading" : ""}`,
289
- onClick: n,
290
- disabled: c,
291
- children: e.okText || "OK"
292
- }
293
- )
294
- ] }) : /* @__PURE__ */ t(
295
- "button",
296
- {
297
- className: `btn ${e.type === "error" ? "btn-error" : "btn-primary"} ${c ? "loading" : ""}`,
298
- onClick: n,
299
- disabled: c,
300
- children: e.okText || "OK"
301
- }
302
- ),
303
- children: [
304
- e.type && e.content && /* @__PURE__ */ t("div", { className: "text-sm", children: e.content }),
305
- !e.type && e.content
306
- ]
307
- }
308
- );
309
- };
310
- return s.render(/* @__PURE__ */ t(a, {})), {
311
- destroy: l
312
- };
313
- }
314
- function X(e) {
315
- return w({ ...e, showCancel: !0 });
316
- }
317
- function Y(e) {
318
- return w({ ...e, type: "info", showCancel: !1 });
319
- }
320
- function Z(e) {
321
- return w({ ...e, type: "success", showCancel: !1 });
322
- }
323
- function ee(e) {
324
- return w({ ...e, type: "warning", showCancel: !1 });
325
- }
326
- function te(e) {
327
- return w({ ...e, type: "error", showCancel: !1 });
328
- }
329
- u.confirm = X;
330
- u.info = Y;
331
- u.success = Z;
332
- u.warning = ee;
333
- u.error = te;
1
+ import { jsx as a, jsxs as i } from "react/jsx-runtime";
2
+ const u = {
3
+ base: "bg-base-100",
4
+ neutral: "bg-neutral text-neutral-content",
5
+ primary: "bg-primary text-primary-content",
6
+ secondary: "bg-secondary text-secondary-content",
7
+ accent: "bg-accent text-accent-content"
8
+ }, v = {
9
+ none: "",
10
+ sm: "shadow-sm",
11
+ md: "shadow-md",
12
+ lg: "shadow-lg",
13
+ xl: "shadow-xl"
14
+ }, x = {
15
+ none: "",
16
+ sm: "rounded-sm",
17
+ md: "rounded-md",
18
+ lg: "rounded-lg",
19
+ xl: "rounded-xl",
20
+ full: "rounded-full"
21
+ }, h = ({
22
+ children: n,
23
+ start: e,
24
+ center: s,
25
+ end: o,
26
+ color: l = "base",
27
+ sticky: d = !1,
28
+ shadow: c = "none",
29
+ rounded: m = "none",
30
+ className: b = "",
31
+ ...r
32
+ }) => {
33
+ const t = [
34
+ "navbar",
35
+ u[l],
36
+ d && "sticky top-0 z-50",
37
+ v[c],
38
+ x[m],
39
+ b
40
+ ].filter(Boolean).join(" ");
41
+ return n ? /* @__PURE__ */ a("nav", { className: t, ...r, children: n }) : /* @__PURE__ */ i("nav", { className: t, ...r, children: [
42
+ e && /* @__PURE__ */ a("div", { className: "navbar-start", children: e }),
43
+ s && /* @__PURE__ */ a("div", { className: "navbar-center", children: s }),
44
+ o && /* @__PURE__ */ a("div", { className: "navbar-end", children: o })
45
+ ] });
46
+ };
334
47
  export {
335
- u as Modal
48
+ h as Navbar
336
49
  };
337
50
  //# sourceMappingURL=index58.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index58.js","sources":["../src/components/Modal.tsx"],"sourcesContent":["import React, { useEffect, useRef, useId } from 'react'\nimport { createRoot } from 'react-dom/client'\n\nexport type ModalPosition = 'top' | 'middle' | 'bottom'\nexport type ModalAlign = 'start' | 'end'\nexport type Breakpoint = 'base' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n\nexport type ResponsivePosition = Partial<Record<Breakpoint, ModalPosition>>\n\nexport interface ModalProps extends Omit<React.HTMLAttributes<HTMLDialogElement>, 'title'> {\n children: React.ReactNode\n title?: React.ReactNode\n footer?: React.ReactNode\n open?: boolean\n onOk?: () => void | Promise<void>\n onCancel?: () => void\n okText?: string\n cancelText?: string\n maskClosable?: boolean\n closable?: boolean\n /** Modal position - can be a single value or responsive object */\n position?: ModalPosition | ResponsivePosition\n align?: ModalAlign\n /** Width of the modal box */\n width?: number | string\n /** Center the modal vertically */\n centered?: boolean\n /** Callback when modal is closed */\n onClose?: () => void\n /** Where to place initial focus: 'ok', 'cancel', or 'close' button */\n initialFocus?: 'ok' | 'cancel' | 'close'\n /** Use alertdialog role for urgent messages */\n alertDialog?: boolean\n}\n\nexport interface ModalFuncProps {\n title?: React.ReactNode\n content?: React.ReactNode\n onOk?: () => void | Promise<void>\n onCancel?: () => void\n okText?: string\n cancelText?: string\n type?: 'info' | 'success' | 'warning' | 'error'\n}\n\nexport function Modal({\n children,\n title,\n footer,\n open = false,\n onOk,\n onCancel,\n okText = 'OK',\n cancelText = 'Cancel',\n maskClosable = true,\n closable = true,\n position,\n align,\n width,\n centered,\n onClose,\n initialFocus,\n alertDialog = false,\n className = '',\n ...rest\n}: ModalProps) {\n const dialogRef = useRef<HTMLDialogElement>(null)\n const okButtonRef = useRef<HTMLButtonElement>(null)\n const cancelButtonRef = useRef<HTMLButtonElement>(null)\n const closeButtonRef = useRef<HTMLButtonElement>(null)\n const previousActiveElement = useRef<HTMLElement | null>(null)\n const [loading, setLoading] = React.useState(false)\n const titleId = useId()\n const contentId = useId()\n\n // Handle close - use onClose if provided, otherwise onCancel\n const closeHandler = onClose || onCancel\n\n useEffect(() => {\n const dialog = dialogRef.current\n if (!dialog) return\n\n if (open) {\n if (!dialog.open) {\n // Save currently focused element for restoration\n previousActiveElement.current = document.activeElement as HTMLElement\n dialog.showModal()\n\n // Handle custom initial focus placement\n if (initialFocus) {\n setTimeout(() => {\n switch (initialFocus) {\n case 'ok':\n okButtonRef.current?.focus()\n break\n case 'cancel':\n cancelButtonRef.current?.focus()\n break\n case 'close':\n closeButtonRef.current?.focus()\n break\n }\n }, 0)\n }\n }\n } else {\n if (dialog.open) {\n dialog.close()\n // Restore focus to previously focused element\n previousActiveElement.current?.focus()\n }\n }\n }, [open, initialFocus])\n\n useEffect(() => {\n const dialog = dialogRef.current\n if (!dialog) return\n\n const onDialogClose = () => {\n closeHandler?.()\n }\n\n dialog.addEventListener('close', onDialogClose)\n return () => {\n dialog.removeEventListener('close', onDialogClose)\n }\n }, [closeHandler])\n\n // Static class mappings for positions (no interpolation per qa.md)\n const positionClasses: Record<ModalPosition, string> = {\n top: 'modal-top',\n middle: 'modal-middle',\n bottom: 'modal-bottom',\n }\n\n // Responsive position class mappings for each breakpoint\n const responsivePositionClasses: Record<Breakpoint, Record<ModalPosition, string>> = {\n base: {\n top: 'modal-top',\n middle: 'modal-middle',\n bottom: 'modal-bottom',\n },\n sm: {\n top: 'sm:modal-top',\n middle: 'sm:modal-middle',\n bottom: 'sm:modal-bottom',\n },\n md: {\n top: 'md:modal-top',\n middle: 'md:modal-middle',\n bottom: 'md:modal-bottom',\n },\n lg: {\n top: 'lg:modal-top',\n middle: 'lg:modal-middle',\n bottom: 'lg:modal-bottom',\n },\n xl: {\n top: 'xl:modal-top',\n middle: 'xl:modal-middle',\n bottom: 'xl:modal-bottom',\n },\n '2xl': {\n top: '2xl:modal-top',\n middle: '2xl:modal-middle',\n bottom: '2xl:modal-bottom',\n },\n }\n\n const alignClasses: Record<ModalAlign, string> = {\n start: 'modal-start',\n end: 'modal-end',\n }\n\n // Build position classes - handle both simple and responsive values\n const getPositionClasses = (): string[] => {\n // centered is an alias for position=\"middle\"\n if (centered) {\n return [positionClasses.middle]\n }\n\n if (!position) {\n return []\n }\n\n // Simple string position\n if (typeof position === 'string') {\n return [positionClasses[position]]\n }\n\n // Responsive object position\n const classes: string[] = []\n for (const [breakpoint, pos] of Object.entries(position) as [Breakpoint, ModalPosition][]) {\n if (pos) {\n classes.push(responsivePositionClasses[breakpoint][pos])\n }\n }\n return classes\n }\n\n const classes = [\n 'modal',\n ...getPositionClasses(),\n align && alignClasses[align],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const handleOk = async () => {\n if (onOk) {\n setLoading(true)\n try {\n await onOk()\n setLoading(false)\n } catch (error) {\n setLoading(false)\n throw error\n }\n }\n }\n\n const handleBackdropClick = () => {\n if (maskClosable && closeHandler) {\n closeHandler()\n }\n }\n\n // Calculate modal-box style for custom width\n const modalBoxStyle: React.CSSProperties = width\n ? { width: typeof width === 'number' ? `${width}px` : width, maxWidth: '90vw' }\n : {}\n\n // Render default footer if no custom footer provided and either onOk or onCancel exists\n const shouldRenderDefaultFooter = !footer && (onOk || onCancel)\n const shouldRenderCustomFooter = footer !== null && footer !== undefined\n\n return (\n <dialog\n ref={dialogRef}\n role={alertDialog ? 'alertdialog' : 'dialog'}\n aria-modal=\"true\"\n className={classes}\n data-state={open ? 'open' : 'closed'}\n aria-labelledby={title ? titleId : undefined}\n aria-describedby={contentId}\n {...rest}\n >\n <div className=\"modal-box\" style={modalBoxStyle}>\n {title && (\n <h3 id={titleId} className=\"text-lg font-bold mb-4\">\n {title}\n </h3>\n )}\n <div id={contentId} className=\"py-4\">\n {children}\n </div>\n {shouldRenderDefaultFooter && (\n <div className=\"modal-action\">\n {onCancel && (\n <button ref={cancelButtonRef} className=\"btn\" onClick={onCancel}>\n {cancelText}\n </button>\n )}\n {onOk && (\n <button\n ref={okButtonRef}\n className={`btn btn-primary ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n aria-busy={loading || undefined}\n >\n {okText}\n </button>\n )}\n </div>\n )}\n {shouldRenderCustomFooter && <div className=\"modal-action\">{footer}</div>}\n </div>\n {closable && maskClosable && (\n <form method=\"dialog\" className=\"modal-backdrop\">\n <button ref={closeButtonRef} onClick={handleBackdropClick}>\n <span className=\"sr-only\">Close modal</span>\n </button>\n </form>\n )}\n </dialog>\n )\n}\n\nfunction createModal(config: ModalFuncProps & { showCancel?: boolean }) {\n const div = document.createElement('div')\n document.body.appendChild(div)\n const root = createRoot(div)\n\n const destroy = () => {\n root.unmount()\n if (div.parentNode) {\n div.parentNode.removeChild(div)\n }\n }\n\n const ModalContent = () => {\n const [open, setOpen] = React.useState(true)\n const [loading, setLoading] = React.useState(false)\n\n const handleClose = () => {\n setOpen(false)\n setTimeout(destroy, 300) // Wait for animation\n }\n\n const handleOk = async () => {\n if (config.onOk) {\n setLoading(true)\n try {\n await config.onOk()\n handleClose()\n } catch (error) {\n setLoading(false)\n }\n } else {\n handleClose()\n }\n }\n\n const handleCancel = () => {\n config.onCancel?.()\n handleClose()\n }\n\n const getAlertClass = () => {\n switch (config.type) {\n case 'success':\n return 'alert-success'\n case 'warning':\n return 'alert-warning'\n case 'error':\n return 'alert-error'\n case 'info':\n default:\n return 'alert-info'\n }\n }\n\n const getIcon = () => {\n switch (config.type) {\n case 'success':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z\"\n />\n </svg>\n )\n case 'warning':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n )\n case 'error':\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"stroke-current shrink-0 h-6 w-6\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z\"\n />\n </svg>\n )\n case 'info':\n default:\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n className=\"stroke-current shrink-0 w-6 h-6\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z\"\n ></path>\n </svg>\n )\n }\n }\n\n // Use alertdialog role for warning/error types\n const isAlert = config.type === 'warning' || config.type === 'error'\n\n return (\n <Modal\n open={open}\n onOk={config.showCancel ? undefined : handleOk}\n onCancel={handleCancel}\n alertDialog={isAlert}\n title={\n config.type ? (\n <div className={`alert ${getAlertClass()}`}>\n {getIcon()}\n <div>\n {config.title && <h3 className=\"font-bold\">{config.title}</h3>}\n </div>\n </div>\n ) : (\n config.title\n )\n }\n okText={config.okText}\n cancelText={config.cancelText}\n footer={\n config.showCancel ? (\n <>\n <button className=\"btn\" onClick={handleCancel}>\n {config.cancelText || 'Cancel'}\n </button>\n <button\n className={`btn ${config.type === 'error' ? 'btn-error' : 'btn-primary'} ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n >\n {config.okText || 'OK'}\n </button>\n </>\n ) : (\n <button\n className={`btn ${config.type === 'error' ? 'btn-error' : 'btn-primary'} ${loading ? 'loading' : ''}`}\n onClick={handleOk}\n disabled={loading}\n >\n {config.okText || 'OK'}\n </button>\n )\n }\n >\n {config.type && config.content && <div className=\"text-sm\">{config.content}</div>}\n {!config.type && config.content}\n </Modal>\n )\n }\n\n root.render(<ModalContent />)\n\n return {\n destroy,\n }\n}\n\nfunction confirm(config: ModalFuncProps) {\n return createModal({ ...config, showCancel: true })\n}\n\nfunction info(config: ModalFuncProps) {\n return createModal({ ...config, type: 'info', showCancel: false })\n}\n\nfunction success(config: ModalFuncProps) {\n return createModal({ ...config, type: 'success', showCancel: false })\n}\n\nfunction warning(config: ModalFuncProps) {\n return createModal({ ...config, type: 'warning', showCancel: false })\n}\n\nfunction error(config: ModalFuncProps) {\n return createModal({ ...config, type: 'error', showCancel: false })\n}\n\nModal.confirm = confirm\nModal.info = info\nModal.success = success\nModal.warning = warning\nModal.error = error\n"],"names":["Modal","children","title","footer","open","onOk","onCancel","okText","cancelText","maskClosable","closable","position","align","width","centered","onClose","initialFocus","alertDialog","className","rest","dialogRef","useRef","okButtonRef","cancelButtonRef","closeButtonRef","previousActiveElement","loading","setLoading","React","titleId","useId","contentId","closeHandler","useEffect","dialog","onDialogClose","positionClasses","responsivePositionClasses","alignClasses","classes","breakpoint","pos","handleOk","error","handleBackdropClick","modalBoxStyle","shouldRenderDefaultFooter","shouldRenderCustomFooter","jsxs","jsx","createModal","config","div","root","createRoot","destroy","ModalContent","setOpen","handleClose","handleCancel","getAlertClass","getIcon","isAlert","Fragment","confirm","info","success","warning"],"mappings":";;;AA6CO,SAASA,EAAM;AAAA,EACpB,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,cAAAC,IAAe;AAAA,EACf,UAAAC,IAAW;AAAA,EACX,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,GAAe;AACb,QAAMC,IAAYC,EAA0B,IAAI,GAC1CC,IAAcD,EAA0B,IAAI,GAC5CE,IAAkBF,EAA0B,IAAI,GAChDG,IAAiBH,EAA0B,IAAI,GAC/CI,IAAwBJ,EAA2B,IAAI,GACvD,CAACK,GAASC,CAAU,IAAIC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,GAAwB;AACvC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,YAAY,IAAM;AACpD;AAEA,SAASc,EAAKd,GAAwB;AACpC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,MAAM,QAAQ,YAAY,IAAO;AACnE;AAEA,SAASe,EAAQf,GAAwB;AACvC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,MAAM,WAAW,YAAY,IAAO;AACtE;AAEA,SAASgB,GAAQhB,GAAwB;AACvC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,MAAM,WAAW,YAAY,IAAO;AACtE;AAEA,SAASR,GAAMQ,GAAwB;AACrC,SAAOD,EAAY,EAAE,GAAGC,GAAQ,MAAM,SAAS,YAAY,IAAO;AACpE;AAEAnD,EAAM,UAAUgE;AAChBhE,EAAM,OAAOiE;AACbjE,EAAM,UAAUkE;AAChBlE,EAAM,UAAUmE;AAChBnE,EAAM,QAAQ2C;"}
1
+ {"version":3,"file":"index58.js","sources":["../src/components/Navbar.tsx"],"sourcesContent":["import React from 'react'\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 'navbar',\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=\"navbar-start\">{start}</div>}\n {center && <div className=\"navbar-center\">{center}</div>}\n {end && <div className=\"navbar-end\">{end}</div>}\n </nav>\n )\n}\n"],"names":["colorClasses","shadowClasses","roundedClasses","Navbar","children","start","center","end","color","sticky","shadow","rounded","className","rest","navbarClasses","jsxs","jsx"],"mappings":";AAwBA,MAAMA,IAA4C;AAAA,EAChD,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AACV,GAEMC,IAA8C;AAAA,EAClD,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,IAAgD;AAAA,EACpD,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR,GAEaC,IAAgC,CAAC;AAAA,EAC5C,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,KAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,QAAAC,IAAS;AAAA,EACT,SAAAC,IAAU;AAAA,EACV,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAgB;AAAA,IACpB;AAAA,IACAd,EAAaQ,CAAK;AAAA,IAClBC,KAAU;AAAA,IACVR,EAAcS,CAAM;AAAA,IACpBR,EAAeS,CAAO;AAAA,IACtBC;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,SAAIR,sBACM,OAAA,EAAI,WAAWU,GAAgB,GAAGD,GAAO,UAAAT,GAAS,IAI1D,gBAAAW,EAAC,OAAA,EAAI,WAAWD,GAAgB,GAAGD,GAChC,UAAA;AAAA,IAAAR,KAAS,gBAAAW,EAAC,OAAA,EAAI,WAAU,gBAAgB,UAAAX,GAAM;AAAA,IAC9CC,KAAU,gBAAAU,EAAC,OAAA,EAAI,WAAU,iBAAiB,UAAAV,GAAO;AAAA,IACjDC,KAAO,gBAAAS,EAAC,OAAA,EAAI,WAAU,cAAc,UAAAT,EAAA,CAAI;AAAA,EAAA,GAC3C;AAEJ;"}
package/dist/index59.js CHANGED
@@ -1,50 +1,125 @@
1
- import { jsx as a, jsxs as i } from "react/jsx-runtime";
2
- const u = {
3
- base: "bg-base-100",
4
- neutral: "bg-neutral text-neutral-content",
5
- primary: "bg-primary text-primary-content",
6
- secondary: "bg-secondary text-secondary-content",
7
- accent: "bg-accent text-accent-content"
8
- }, v = {
9
- none: "",
10
- sm: "shadow-sm",
11
- md: "shadow-md",
12
- lg: "shadow-lg",
13
- xl: "shadow-xl"
14
- }, x = {
15
- none: "",
16
- sm: "rounded-sm",
17
- md: "rounded-md",
18
- lg: "rounded-lg",
19
- xl: "rounded-xl",
20
- full: "rounded-full"
21
- }, h = ({
22
- children: n,
23
- start: e,
24
- center: s,
25
- end: o,
26
- color: l = "base",
27
- sticky: d = !1,
28
- shadow: c = "none",
29
- rounded: m = "none",
30
- className: b = "",
31
- ...r
32
- }) => {
33
- const t = [
34
- "navbar",
35
- u[l],
36
- d && "sticky top-0 z-50",
37
- v[c],
38
- x[m],
39
- b
40
- ].filter(Boolean).join(" ");
41
- return n ? /* @__PURE__ */ a("nav", { className: t, ...r, children: n }) : /* @__PURE__ */ i("nav", { className: t, ...r, children: [
42
- e && /* @__PURE__ */ a("div", { className: "navbar-start", children: e }),
43
- s && /* @__PURE__ */ a("div", { className: "navbar-center", children: s }),
44
- o && /* @__PURE__ */ a("div", { className: "navbar-end", children: o })
45
- ] });
46
- };
1
+ import { jsx as i, Fragment as h, jsxs as l } from "react/jsx-runtime";
2
+ import { useState as u, useEffect as p } from "react";
3
+ import d from "react-dom/client";
4
+ class m {
5
+ notifications = [];
6
+ listeners = [];
7
+ container = null;
8
+ root = null;
9
+ idCounter = 0;
10
+ subscribe(t) {
11
+ return this.listeners.push(t), () => {
12
+ this.listeners = this.listeners.filter((o) => o !== t);
13
+ };
14
+ }
15
+ getNotifications() {
16
+ return this.notifications;
17
+ }
18
+ emit() {
19
+ this.listeners.forEach((t) => t());
20
+ }
21
+ ensureContainer() {
22
+ this.container || (this.container = document.createElement("div"), document.body.appendChild(this.container), this.root = d.createRoot(this.container), this.root.render(/* @__PURE__ */ i(f, { manager: this })));
23
+ }
24
+ open(t) {
25
+ this.ensureContainer();
26
+ const o = `notification-${++this.idCounter}`, s = {
27
+ ...t,
28
+ id: o,
29
+ createdAt: Date.now(),
30
+ duration: t.duration ?? 4.5,
31
+ placement: t.placement ?? "topRight",
32
+ closable: t.closable ?? !0,
33
+ type: t.type ?? "info"
34
+ };
35
+ return this.notifications.push(s), this.emit(), s.duration && s.duration > 0 && setTimeout(() => {
36
+ this.close(o);
37
+ }, s.duration * 1e3), o;
38
+ }
39
+ close(t) {
40
+ const o = this.notifications.find((s) => s.id === t);
41
+ this.notifications = this.notifications.filter((s) => s.id !== t), this.emit(), o?.onClose && o.onClose();
42
+ }
43
+ success(t) {
44
+ return this.open({ ...t, type: "success" });
45
+ }
46
+ error(t) {
47
+ return this.open({ ...t, type: "error" });
48
+ }
49
+ info(t) {
50
+ return this.open({ ...t, type: "info" });
51
+ }
52
+ warning(t) {
53
+ return this.open({ ...t, type: "warning" });
54
+ }
55
+ destroy() {
56
+ this.notifications = [], this.emit();
57
+ }
58
+ }
59
+ function f({ manager: e }) {
60
+ const [, t] = u({});
61
+ p(() => e.subscribe(() => {
62
+ t({});
63
+ }), [e]);
64
+ const o = e.getNotifications(), s = {
65
+ topLeft: [],
66
+ topRight: [],
67
+ bottomLeft: [],
68
+ bottomRight: []
69
+ };
70
+ o.forEach((n) => {
71
+ s[n.placement].push(n);
72
+ });
73
+ const r = {
74
+ topRight: "toast toast-top toast-end",
75
+ topLeft: "toast toast-top toast-start",
76
+ bottomRight: "toast toast-bottom toast-end",
77
+ bottomLeft: "toast toast-bottom toast-start"
78
+ };
79
+ return /* @__PURE__ */ i(h, { children: Object.entries(s).map(([n, c]) => c.length === 0 ? null : /* @__PURE__ */ i("div", { className: r[n], children: c.map((a) => /* @__PURE__ */ i(
80
+ b,
81
+ {
82
+ notification: a,
83
+ onClose: () => e.close(a.id)
84
+ },
85
+ a.id
86
+ )) }, n)) });
87
+ }
88
+ function b({ notification: e, onClose: t }) {
89
+ const o = {
90
+ success: "alert-success",
91
+ error: "alert-error",
92
+ info: "alert-info",
93
+ warning: "alert-warning"
94
+ }, s = () => {
95
+ e.onClick && e.onClick();
96
+ };
97
+ return /* @__PURE__ */ l(
98
+ "div",
99
+ {
100
+ className: `alert ${o[e.type]} shadow-lg cursor-pointer min-w-[300px] max-w-[400px] relative`,
101
+ onClick: s,
102
+ children: [
103
+ /* @__PURE__ */ l("div", { className: e.closable ? "pr-8" : "", children: [
104
+ e.message && /* @__PURE__ */ i("div", { className: "font-bold", children: e.message }),
105
+ e.description && /* @__PURE__ */ i("div", { className: "text-sm", children: e.description })
106
+ ] }),
107
+ e.closable && /* @__PURE__ */ i(
108
+ "button",
109
+ {
110
+ className: "btn btn-xs btn-ghost btn-circle absolute top-2 right-2",
111
+ onClick: (r) => {
112
+ r.stopPropagation(), t();
113
+ },
114
+ children: "✕"
115
+ }
116
+ )
117
+ ]
118
+ }
119
+ );
120
+ }
121
+ const y = new m();
47
122
  export {
48
- h as Navbar
123
+ y as notification
49
124
  };
50
125
  //# sourceMappingURL=index59.js.map