asterui 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -9
- package/dist/components/Segmented.d.ts +37 -0
- package/dist/components/Tour.d.ts +61 -0
- package/dist/hooks/useClickOutside.d.ts +17 -0
- package/dist/hooks/useClipboard.d.ts +20 -0
- package/dist/hooks/useDebounce.d.ts +18 -0
- package/dist/hooks/useDisclosure.d.ts +20 -0
- package/dist/hooks/useHover.d.ts +18 -0
- package/dist/hooks/useKeyPress.d.ts +40 -0
- package/dist/hooks/useLocalStorage.d.ts +12 -0
- package/dist/hooks/usePrevious.d.ts +15 -0
- package/dist/hooks/useWindowSize.d.ts +21 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +143 -120
- package/dist/index.js.map +1 -1
- package/dist/index100.js +5 -21
- package/dist/index100.js.map +1 -1
- package/dist/index101.js +41 -23
- package/dist/index101.js.map +1 -1
- package/dist/index102.js +2 -20
- package/dist/index102.js.map +1 -1
- package/dist/index103.js +6 -99
- package/dist/index103.js.map +1 -1
- package/dist/index104.js +149 -357
- package/dist/index104.js.map +1 -1
- package/dist/index105.js +28 -23
- package/dist/index105.js.map +1 -1
- package/dist/index106.js +28 -71
- package/dist/index106.js.map +1 -1
- package/dist/index107.js +2 -16
- package/dist/index107.js.map +1 -1
- package/dist/index108.js +71 -65
- package/dist/index108.js.map +1 -1
- package/dist/index109.js +34 -139
- package/dist/index109.js.map +1 -1
- package/dist/index110.js +26 -2
- package/dist/index110.js.map +1 -1
- package/dist/index111.js +20 -55
- package/dist/index111.js.map +1 -1
- package/dist/index112.js +24 -2
- package/dist/index112.js.map +1 -1
- package/dist/index113.js +20 -2
- package/dist/index113.js.map +1 -1
- package/dist/index114.js +100 -2
- package/dist/index114.js.map +1 -1
- package/dist/index115.js +360 -2
- package/dist/index115.js.map +1 -1
- package/dist/index116.js +25 -2
- package/dist/index116.js.map +1 -1
- package/dist/index117.js +73 -2
- package/dist/index117.js.map +1 -1
- package/dist/index118.js +16 -2
- package/dist/index118.js.map +1 -1
- package/dist/index119.js +66 -2
- package/dist/index119.js.map +1 -1
- package/dist/index120.js +140 -28
- package/dist/index120.js.map +1 -1
- package/dist/index121.js +2 -2
- package/dist/index122.js +55 -7
- package/dist/index122.js.map +1 -1
- package/dist/index123.js +2 -2
- package/dist/index124.js +2 -2
- package/dist/index125.js +2 -21
- package/dist/index125.js.map +1 -1
- package/dist/index126.js +2 -2
- package/dist/index127.js +2 -24
- package/dist/index127.js.map +1 -1
- package/dist/index128.js +2 -71
- package/dist/index128.js.map +1 -1
- package/dist/index129.js +2 -21
- package/dist/index129.js.map +1 -1
- package/dist/index130.js +31 -33
- package/dist/index130.js.map +1 -1
- package/dist/index131.js +2 -70
- package/dist/index131.js.map +1 -1
- package/dist/index132.js +8 -2
- package/dist/index132.js.map +1 -1
- package/dist/index133.js +2 -22
- package/dist/index133.js.map +1 -1
- package/dist/index135.js +21 -2
- package/dist/index135.js.map +1 -1
- package/dist/index137.js +24 -2
- package/dist/index137.js.map +1 -1
- package/dist/index138.js +70 -3
- package/dist/index138.js.map +1 -1
- package/dist/index139.js +24 -0
- package/dist/index139.js.map +1 -0
- package/dist/index14.js +1 -1
- package/dist/index140.js +37 -0
- package/dist/index140.js.map +1 -0
- package/dist/index141.js +73 -0
- package/dist/index141.js.map +1 -0
- package/dist/index142.js +5 -0
- package/dist/index142.js.map +1 -0
- package/dist/index143.js +5 -0
- package/dist/index143.js.map +1 -0
- package/dist/index144.js +25 -0
- package/dist/index144.js.map +1 -0
- package/dist/index145.js +5 -0
- package/dist/index145.js.map +1 -0
- package/dist/index146.js +5 -0
- package/dist/index146.js.map +1 -0
- package/dist/index147.js +5 -0
- package/dist/index147.js.map +1 -0
- package/dist/index148.js +5 -0
- package/dist/index148.js.map +1 -0
- package/dist/index149.js +7 -0
- package/dist/index149.js.map +1 -0
- package/dist/index59.js +1 -1
- package/dist/index66.js +66 -19
- package/dist/index66.js.map +1 -1
- package/dist/index67.js +18 -43
- package/dist/index67.js.map +1 -1
- package/dist/index68.js +44 -132
- package/dist/index68.js.map +1 -1
- package/dist/index69.js +132 -50
- package/dist/index69.js.map +1 -1
- package/dist/index70.js +51 -21
- package/dist/index70.js.map +1 -1
- package/dist/index71.js +19 -19
- package/dist/index71.js.map +1 -1
- package/dist/index72.js +20 -327
- package/dist/index72.js.map +1 -1
- package/dist/index73.js +323 -50
- package/dist/index73.js.map +1 -1
- package/dist/index74.js +56 -40
- package/dist/index74.js.map +1 -1
- package/dist/index75.js +40 -95
- package/dist/index75.js.map +1 -1
- package/dist/index76.js +88 -123
- package/dist/index76.js.map +1 -1
- package/dist/index77.js +123 -154
- package/dist/index77.js.map +1 -1
- package/dist/index78.js +159 -63
- package/dist/index78.js.map +1 -1
- package/dist/index79.js +65 -35
- package/dist/index79.js.map +1 -1
- package/dist/index80.js +35 -34
- package/dist/index80.js.map +1 -1
- package/dist/index81.js +222 -198
- package/dist/index81.js.map +1 -1
- package/dist/index82.js +34 -213
- package/dist/index82.js.map +1 -1
- package/dist/index83.js +190 -275
- package/dist/index83.js.map +1 -1
- package/dist/index84.js +202 -167
- package/dist/index84.js.map +1 -1
- package/dist/index85.js +263 -226
- package/dist/index85.js.map +1 -1
- package/dist/index86.js +176 -12
- package/dist/index86.js.map +1 -1
- package/dist/index87.js +257 -32
- package/dist/index87.js.map +1 -1
- package/dist/index88.js +13 -10792
- package/dist/index88.js.map +1 -1
- package/dist/index89.js +33 -5
- package/dist/index89.js.map +1 -1
- package/dist/index90.js +5 -41
- package/dist/index90.js.map +1 -1
- package/dist/index91.js +14 -2
- package/dist/index91.js.map +1 -1
- package/dist/index92.js +45 -6
- package/dist/index92.js.map +1 -1
- package/dist/index93.js +11 -150
- package/dist/index93.js.map +1 -1
- package/dist/index94.js +13 -28
- package/dist/index94.js.map +1 -1
- package/dist/index95.js +7 -29
- package/dist/index95.js.map +1 -1
- package/dist/index96.js +13 -2
- package/dist/index96.js.map +1 -1
- package/dist/index97.js +30 -71
- package/dist/index97.js.map +1 -1
- package/dist/index98.js +16 -37
- package/dist/index98.js.map +1 -1
- package/dist/index99.js +10792 -25
- package/dist/index99.js.map +1 -1
- package/package.json +2 -2
package/dist/index86.js
CHANGED
|
@@ -1,17 +1,181 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { jsx as e, jsxs as u, Fragment as C } from "react/jsx-runtime";
|
|
2
|
+
import { useState as g } from "react";
|
|
3
|
+
function f({ text: a }) {
|
|
4
|
+
const [t, r] = g(!1);
|
|
5
|
+
return /* @__PURE__ */ e(
|
|
6
|
+
"button",
|
|
7
|
+
{
|
|
8
|
+
onClick: async () => {
|
|
9
|
+
try {
|
|
10
|
+
await navigator.clipboard.writeText(a), r(!0), setTimeout(() => r(!1), 2e3);
|
|
11
|
+
} catch (s) {
|
|
12
|
+
console.error("Failed to copy:", s);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
className: "btn btn-ghost btn-xs ml-2 opacity-0 group-hover:opacity-100 transition-opacity",
|
|
16
|
+
title: "Copy to clipboard",
|
|
17
|
+
children: t ? /* @__PURE__ */ e("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e(
|
|
18
|
+
"path",
|
|
19
|
+
{
|
|
20
|
+
fillRule: "evenodd",
|
|
21
|
+
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
22
|
+
clipRule: "evenodd"
|
|
23
|
+
}
|
|
24
|
+
) }) : /* @__PURE__ */ u("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: [
|
|
25
|
+
/* @__PURE__ */ e("path", { d: "M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z" }),
|
|
26
|
+
/* @__PURE__ */ e("path", { d: "M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z" })
|
|
27
|
+
] })
|
|
28
|
+
}
|
|
29
|
+
);
|
|
7
30
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
31
|
+
function v({ children: a, size: t = "base", className: r = "", ...l }) {
|
|
32
|
+
const m = [
|
|
33
|
+
// Prose classes (only apply if @tailwindcss/typography is installed)
|
|
34
|
+
"prose dark:prose-invert max-w-none",
|
|
35
|
+
// Fallback styles (always apply)
|
|
36
|
+
"text-base-content leading-relaxed",
|
|
37
|
+
{
|
|
38
|
+
sm: "prose-sm text-sm",
|
|
39
|
+
base: "prose-base text-base",
|
|
40
|
+
lg: "prose-lg text-lg",
|
|
41
|
+
xl: "prose-xl text-xl",
|
|
42
|
+
"2xl": "prose-2xl text-2xl"
|
|
43
|
+
}[t],
|
|
44
|
+
r
|
|
45
|
+
].filter(Boolean).join(" ");
|
|
46
|
+
return /* @__PURE__ */ e("div", { className: m, ...l, children: a });
|
|
12
47
|
}
|
|
48
|
+
function N({ level: a = 1, children: t, copyable: r, ellipsis: l, className: s = "", id: m, ...c }) {
|
|
49
|
+
const o = typeof t == "string" ? t : "", i = m || (o ? o.toLowerCase().replace(/\s+/g, "-") : void 0), h = {
|
|
50
|
+
1: "text-4xl font-bold mb-4",
|
|
51
|
+
2: "text-3xl font-bold mb-3",
|
|
52
|
+
3: "text-2xl font-semibold mb-3",
|
|
53
|
+
4: "text-xl font-semibold mb-2",
|
|
54
|
+
5: "text-lg font-semibold mb-2"
|
|
55
|
+
}, p = l ? "truncate" : "", x = `group ${h[a]} ${p} ${s}`.trim(), d = /* @__PURE__ */ u(C, { children: [
|
|
56
|
+
t,
|
|
57
|
+
r && /* @__PURE__ */ e(f, { text: o })
|
|
58
|
+
] });
|
|
59
|
+
switch (a) {
|
|
60
|
+
case 1:
|
|
61
|
+
return /* @__PURE__ */ e("h1", { id: i, className: x, ...c, children: d });
|
|
62
|
+
case 2:
|
|
63
|
+
return /* @__PURE__ */ e("h2", { id: i, className: x, ...c, children: d });
|
|
64
|
+
case 3:
|
|
65
|
+
return /* @__PURE__ */ e("h3", { id: i, className: x, ...c, children: d });
|
|
66
|
+
case 4:
|
|
67
|
+
return /* @__PURE__ */ e("h4", { id: i, className: x, ...c, children: d });
|
|
68
|
+
case 5:
|
|
69
|
+
return /* @__PURE__ */ e("h5", { id: i, className: x, ...c, children: d });
|
|
70
|
+
default:
|
|
71
|
+
return /* @__PURE__ */ e("h1", { id: i, className: x, ...c, children: d });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const w = {
|
|
75
|
+
1: "line-clamp-1",
|
|
76
|
+
2: "line-clamp-2",
|
|
77
|
+
3: "line-clamp-3",
|
|
78
|
+
4: "line-clamp-4",
|
|
79
|
+
5: "line-clamp-5",
|
|
80
|
+
6: "line-clamp-6"
|
|
81
|
+
};
|
|
82
|
+
function k({ children: a, ellipsis: t, copyable: r, size: l, align: s, className: m = "", ...c }) {
|
|
83
|
+
const [o, i] = g(!1), h = typeof a == "string" ? a : "", p = typeof t == "object", x = p && t.rows || 3, d = p ? t.expandable : !1, n = Math.min(Math.max(x, 1), 6), y = [
|
|
84
|
+
"group",
|
|
85
|
+
"mb-4",
|
|
86
|
+
t && !o ? w[n] : "",
|
|
87
|
+
l === "sm" && "text-sm",
|
|
88
|
+
l === "base" && "text-base",
|
|
89
|
+
l === "lg" && "text-lg",
|
|
90
|
+
l === "xl" && "text-xl",
|
|
91
|
+
l === "2xl" && "text-2xl",
|
|
92
|
+
s === "left" && "text-left",
|
|
93
|
+
s === "center" && "text-center",
|
|
94
|
+
s === "right" && "text-right",
|
|
95
|
+
m
|
|
96
|
+
].filter(Boolean).join(" ");
|
|
97
|
+
return /* @__PURE__ */ u("div", { ...c, children: [
|
|
98
|
+
/* @__PURE__ */ u("p", { className: y, children: [
|
|
99
|
+
a,
|
|
100
|
+
r && /* @__PURE__ */ e(f, { text: h })
|
|
101
|
+
] }),
|
|
102
|
+
d && t && /* @__PURE__ */ e(
|
|
103
|
+
"button",
|
|
104
|
+
{
|
|
105
|
+
onClick: () => {
|
|
106
|
+
i(!o), p && t.onExpand && t.onExpand();
|
|
107
|
+
},
|
|
108
|
+
className: "text-primary text-sm hover:underline",
|
|
109
|
+
children: o ? "Show less" : "Show more"
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
function j({
|
|
115
|
+
children: a,
|
|
116
|
+
code: t,
|
|
117
|
+
mark: r,
|
|
118
|
+
strong: l,
|
|
119
|
+
italic: s,
|
|
120
|
+
underline: m,
|
|
121
|
+
delete: c,
|
|
122
|
+
type: o = "default",
|
|
123
|
+
copyable: i,
|
|
124
|
+
className: h = "",
|
|
125
|
+
...p
|
|
126
|
+
}) {
|
|
127
|
+
const x = typeof a == "string" ? a : "", d = {
|
|
128
|
+
default: "",
|
|
129
|
+
secondary: "text-base-content/70",
|
|
130
|
+
success: "text-success",
|
|
131
|
+
warning: "text-warning",
|
|
132
|
+
error: "text-error"
|
|
133
|
+
};
|
|
134
|
+
let n = a;
|
|
135
|
+
t && (n = /* @__PURE__ */ e("code", { className: "px-1.5 py-0.5 bg-base-200 rounded text-sm font-mono", children: n })), r && (n = /* @__PURE__ */ e("mark", { className: "bg-warning/30 px-1", children: n })), l && (n = /* @__PURE__ */ e("strong", { className: "font-bold", children: n })), s && (n = /* @__PURE__ */ e("em", { className: "italic", children: n })), m && (n = /* @__PURE__ */ e("u", { className: "underline", children: n })), c && (n = /* @__PURE__ */ e("del", { className: "line-through opacity-70", children: n }));
|
|
136
|
+
const b = `group inline ${d[o]} ${h}`.trim();
|
|
137
|
+
return /* @__PURE__ */ u("span", { className: b, ...p, children: [
|
|
138
|
+
n,
|
|
139
|
+
i && /* @__PURE__ */ e(f, { text: x })
|
|
140
|
+
] });
|
|
141
|
+
}
|
|
142
|
+
function B({ href: a = "#", children: t, target: r, external: l, size: s, className: m = "", ...c }) {
|
|
143
|
+
const o = l || a && a.startsWith("http"), i = r || (o ? "_blank" : void 0), h = o ? "noopener noreferrer" : void 0, p = [
|
|
144
|
+
"link",
|
|
145
|
+
"link-primary",
|
|
146
|
+
s === "sm" && "text-sm",
|
|
147
|
+
s === "base" && "text-base",
|
|
148
|
+
s === "lg" && "text-lg",
|
|
149
|
+
s === "xl" && "text-xl",
|
|
150
|
+
s === "2xl" && "text-2xl",
|
|
151
|
+
m
|
|
152
|
+
].filter(Boolean).join(" ");
|
|
153
|
+
return /* @__PURE__ */ u(
|
|
154
|
+
"a",
|
|
155
|
+
{
|
|
156
|
+
href: a,
|
|
157
|
+
target: i,
|
|
158
|
+
rel: h,
|
|
159
|
+
className: p,
|
|
160
|
+
...c,
|
|
161
|
+
children: [
|
|
162
|
+
t,
|
|
163
|
+
o && /* @__PURE__ */ u("svg", { className: "w-3 h-3 inline-block ml-1", fill: "currentColor", viewBox: "0 0 20 20", children: [
|
|
164
|
+
/* @__PURE__ */ e("path", { d: "M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z" }),
|
|
165
|
+
/* @__PURE__ */ e("path", { d: "M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z" })
|
|
166
|
+
] })
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
const E = Object.assign(v, {
|
|
172
|
+
Title: N,
|
|
173
|
+
Paragraph: k,
|
|
174
|
+
Text: j,
|
|
175
|
+
Link: B
|
|
176
|
+
});
|
|
13
177
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
178
|
+
E as Typography,
|
|
179
|
+
E as default
|
|
16
180
|
};
|
|
17
181
|
//# sourceMappingURL=index86.js.map
|
package/dist/index86.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index86.js","sources":["../src/components/Responsive.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { useBreakpoint, Breakpoint } from '../hooks/useBreakpoint'\n\nexport interface ShowProps {\n children: ReactNode\n above?: Breakpoint\n below?: Breakpoint\n at?: Breakpoint | Breakpoint[]\n between?: [Breakpoint, Breakpoint]\n}\n\nexport function Show({ children, above, below, at, between }: ShowProps): React.ReactElement | null {\n const { isAbove, isBelow, isAt, isBetween } = useBreakpoint()\n\n let shouldShow = false\n\n if (above !== undefined) {\n shouldShow = isAbove(above)\n } else if (below !== undefined) {\n shouldShow = isBelow(below)\n } else if (at !== undefined) {\n if (Array.isArray(at)) {\n shouldShow = at.some((bp) => isAt(bp))\n } else {\n shouldShow = isAt(at)\n }\n } else if (between !== undefined) {\n shouldShow = isBetween(between[0], between[1])\n } else {\n shouldShow = true\n }\n\n return shouldShow ? <>{children}</> : null\n}\n\nexport interface HideProps {\n children: ReactNode\n above?: Breakpoint\n below?: Breakpoint\n at?: Breakpoint | Breakpoint[]\n between?: [Breakpoint, Breakpoint]\n}\n\nexport function Hide({ children, above, below, at, between }: HideProps): React.ReactElement | null {\n const { isAbove, isBelow, isAt, isBetween } = useBreakpoint()\n\n let shouldHide = false\n\n if (above !== undefined) {\n shouldHide = isAbove(above)\n } else if (below !== undefined) {\n shouldHide = isBelow(below)\n } else if (at !== undefined) {\n if (Array.isArray(at)) {\n shouldHide = at.some((bp) => isAt(bp))\n } else {\n shouldHide = isAt(at)\n }\n } else if (between !== undefined) {\n shouldHide = isBetween(between[0], between[1])\n }\n\n return shouldHide ? null : <>{children}</>\n}\n"],"names":["Show","children","above","below","at","between","isAbove","isBelow","isAt","isBetween","useBreakpoint","shouldShow","bp","jsx","Fragment","Hide","shouldHide"],"mappings":";;AAWO,SAASA,EAAK,EAAE,UAAAC,GAAU,OAAAC,GAAO,OAAAC,GAAO,IAAAC,GAAI,SAAAC,KAAiD;AAClG,QAAM,EAAE,SAAAC,GAAS,SAAAC,GAAS,MAAAC,GAAM,WAAAC,EAAA,IAAcC,EAAA;AAE9C,MAAIC,IAAa;AAEjB,SAAIT,MAAU,SACZS,IAAaL,EAAQJ,CAAK,IACjBC,MAAU,SACnBQ,IAAaJ,EAAQJ,CAAK,IACjBC,MAAO,SACZ,MAAM,QAAQA,CAAE,IAClBO,IAAaP,EAAG,KAAK,CAACQ,MAAOJ,EAAKI,CAAE,CAAC,IAErCD,IAAaH,EAAKJ,CAAE,IAEbC,MAAY,SACrBM,IAAaF,EAAUJ,EAAQ,CAAC,GAAGA,EAAQ,CAAC,CAAC,IAE7CM,IAAa,IAGRA,IAAa,gBAAAE,EAAAC,GAAA,EAAG,UAAAb,EAAA,CAAS,IAAM;AACxC;AAUO,SAASc,EAAK,EAAE,UAAAd,GAAU,OAAAC,GAAO,OAAAC,GAAO,IAAAC,GAAI,SAAAC,KAAiD;AAClG,QAAM,EAAE,SAAAC,GAAS,SAAAC,GAAS,MAAAC,GAAM,WAAAC,EAAA,IAAcC,EAAA;AAE9C,MAAIM,IAAa;AAEjB,SAAId,MAAU,SACZc,IAAaV,EAAQJ,CAAK,IACjBC,MAAU,SACnBa,IAAaT,EAAQJ,CAAK,IACjBC,MAAO,SACZ,MAAM,QAAQA,CAAE,IAClBY,IAAaZ,EAAG,KAAK,CAACQ,MAAOJ,EAAKI,CAAE,CAAC,IAErCI,IAAaR,EAAKJ,CAAE,IAEbC,MAAY,WACrBW,IAAaP,EAAUJ,EAAQ,CAAC,GAAGA,EAAQ,CAAC,CAAC,IAGxCW,IAAa,OAAO,gBAAAH,EAAAC,GAAA,EAAG,UAAAb,EAAA,CAAS;AACzC;"}
|
|
1
|
+
{"version":3,"file":"index86.js","sources":["../src/components/Typography.tsx"],"sourcesContent":["import React, { useState } from 'react'\n\nexport type TypographySize = 'sm' | 'base' | 'lg' | 'xl' | '2xl'\nexport type TitleLevel = 1 | 2 | 3 | 4 | 5\n\nexport interface TypographyProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n size?: TypographySize\n}\n\nexport interface TitleProps extends Omit<React.HTMLAttributes<HTMLHeadingElement>, 'title'> {\n level?: TitleLevel\n children: React.ReactNode\n copyable?: boolean\n ellipsis?: boolean\n}\n\nexport interface ParagraphProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n ellipsis?: boolean | { rows?: number; expandable?: boolean; onExpand?: () => void }\n copyable?: boolean\n size?: TypographySize\n align?: 'left' | 'center' | 'right'\n}\n\nexport interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {\n children: React.ReactNode\n code?: boolean\n mark?: boolean\n strong?: boolean\n italic?: boolean\n underline?: boolean\n delete?: boolean\n type?: 'default' | 'secondary' | 'success' | 'warning' | 'error'\n copyable?: boolean\n}\n\nexport interface TypographyLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n href?: string\n children: React.ReactNode\n external?: boolean\n size?: TypographySize\n}\n\nfunction CopyButton({ text }: { text: string }) {\n const [copied, setCopied] = useState(false)\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(text)\n setCopied(true)\n setTimeout(() => setCopied(false), 2000)\n } catch (err) {\n console.error('Failed to copy:', err)\n }\n }\n\n return (\n <button\n onClick={handleCopy}\n className=\"btn btn-ghost btn-xs ml-2 opacity-0 group-hover:opacity-100 transition-opacity\"\n title=\"Copy to clipboard\"\n >\n {copied ? (\n <svg className=\"w-4 h-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n ) : (\n <svg className=\"w-4 h-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path d=\"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z\" />\n <path d=\"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z\" />\n </svg>\n )}\n </button>\n )\n}\n\nfunction TypographyRoot({ children, size = 'base', className = '', ...rest }: TypographyProps) {\n const sizeClasses = {\n sm: 'prose-sm text-sm',\n base: 'prose-base text-base',\n lg: 'prose-lg text-lg',\n xl: 'prose-xl text-xl',\n '2xl': 'prose-2xl text-2xl',\n }\n\n const classes = [\n // Prose classes (only apply if @tailwindcss/typography is installed)\n 'prose dark:prose-invert max-w-none',\n // Fallback styles (always apply)\n 'text-base-content leading-relaxed',\n sizeClasses[size],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return <div className={classes} {...rest}>{children}</div>\n}\n\nfunction Title({ level = 1, children, copyable, ellipsis, className = '', id, ...rest }: TitleProps) {\n const textContent = typeof children === 'string' ? children : ''\n const generatedId = id || (textContent ? textContent.toLowerCase().replace(/\\s+/g, '-') : undefined)\n\n const levelClasses = {\n 1: 'text-4xl font-bold mb-4',\n 2: 'text-3xl font-bold mb-3',\n 3: 'text-2xl font-semibold mb-3',\n 4: 'text-xl font-semibold mb-2',\n 5: 'text-lg font-semibold mb-2',\n }\n\n const ellipsisClass = ellipsis ? 'truncate' : ''\n const classes = `group ${levelClasses[level]} ${ellipsisClass} ${className}`.trim()\n\n const content = (\n <>\n {children}\n {copyable && <CopyButton text={textContent} />}\n </>\n )\n\n switch (level) {\n case 1:\n return <h1 id={generatedId} className={classes} {...rest}>{content}</h1>\n case 2:\n return <h2 id={generatedId} className={classes} {...rest}>{content}</h2>\n case 3:\n return <h3 id={generatedId} className={classes} {...rest}>{content}</h3>\n case 4:\n return <h4 id={generatedId} className={classes} {...rest}>{content}</h4>\n case 5:\n return <h5 id={generatedId} className={classes} {...rest}>{content}</h5>\n default:\n return <h1 id={generatedId} className={classes} {...rest}>{content}</h1>\n }\n}\n\nconst lineClampClasses = {\n 1: 'line-clamp-1',\n 2: 'line-clamp-2',\n 3: 'line-clamp-3',\n 4: 'line-clamp-4',\n 5: 'line-clamp-5',\n 6: 'line-clamp-6',\n} as const\n\nfunction Paragraph({ children, ellipsis, copyable, size, align, className = '', ...rest }: ParagraphProps) {\n const [expanded, setExpanded] = useState(false)\n const textContent = typeof children === 'string' ? children : ''\n\n const isEllipsisObject = typeof ellipsis === 'object'\n const rows = isEllipsisObject ? ellipsis.rows || 3 : 3\n const expandable = isEllipsisObject ? ellipsis.expandable : false\n\n const clampedRows = Math.min(Math.max(rows, 1), 6) as 1 | 2 | 3 | 4 | 5 | 6\n const ellipsisClass =\n ellipsis && !expanded ? lineClampClasses[clampedRows] : ''\n\n const classes = [\n 'group',\n 'mb-4',\n ellipsisClass,\n size === 'sm' && 'text-sm',\n size === 'base' && 'text-base',\n size === 'lg' && 'text-lg',\n size === 'xl' && 'text-xl',\n size === '2xl' && 'text-2xl',\n align === 'left' && 'text-left',\n align === 'center' && 'text-center',\n align === 'right' && 'text-right',\n className,\n ].filter(Boolean).join(' ')\n\n return (\n <div {...rest}>\n <p className={classes}>\n {children}\n {copyable && <CopyButton text={textContent} />}\n </p>\n {expandable && ellipsis && (\n <button\n onClick={() => {\n setExpanded(!expanded)\n if (isEllipsisObject && ellipsis.onExpand) {\n ellipsis.onExpand()\n }\n }}\n className=\"text-primary text-sm hover:underline\"\n >\n {expanded ? 'Show less' : 'Show more'}\n </button>\n )}\n </div>\n )\n}\n\nfunction Text({\n children,\n code,\n mark,\n strong,\n italic,\n underline,\n delete: del,\n type = 'default',\n copyable,\n className = '',\n ...rest\n}: TextProps) {\n const textContent = typeof children === 'string' ? children : ''\n\n const typeClasses = {\n default: '',\n secondary: 'text-base-content/70',\n success: 'text-success',\n warning: 'text-warning',\n error: 'text-error',\n }\n\n let content = children\n\n if (code) {\n content = (\n <code className=\"px-1.5 py-0.5 bg-base-200 rounded text-sm font-mono\">{content}</code>\n )\n }\n\n if (mark) {\n content = <mark className=\"bg-warning/30 px-1\">{content}</mark>\n }\n\n if (strong) {\n content = <strong className=\"font-bold\">{content}</strong>\n }\n\n if (italic) {\n content = <em className=\"italic\">{content}</em>\n }\n\n if (underline) {\n content = <u className=\"underline\">{content}</u>\n }\n\n if (del) {\n content = <del className=\"line-through opacity-70\">{content}</del>\n }\n\n const classes = `group inline ${typeClasses[type]} ${className}`.trim()\n\n return (\n <span className={classes} {...rest}>\n {content}\n {copyable && <CopyButton text={textContent} />}\n </span>\n )\n}\n\nfunction Link({ href = '#', children, target, external, size, className = '', ...rest }: TypographyLinkProps) {\n const isExternal = external || (href && href.startsWith('http'))\n const linkTarget = target || (isExternal ? '_blank' : undefined)\n const rel = isExternal ? 'noopener noreferrer' : undefined\n\n const classes = [\n 'link',\n 'link-primary',\n size === 'sm' && 'text-sm',\n size === 'base' && 'text-base',\n size === 'lg' && 'text-lg',\n size === 'xl' && 'text-xl',\n size === '2xl' && 'text-2xl',\n className,\n ].filter(Boolean).join(' ')\n\n return (\n <a\n href={href}\n target={linkTarget}\n rel={rel}\n className={classes}\n {...rest}\n >\n {children}\n {isExternal && (\n <svg className=\"w-3 h-3 inline-block ml-1\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path d=\"M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z\" />\n <path d=\"M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z\" />\n </svg>\n )}\n </a>\n )\n}\n\nexport const Typography = Object.assign(TypographyRoot, {\n Title,\n Paragraph,\n Text,\n Link,\n})\n\nexport default Typography\n"],"names":["CopyButton","text","copied","setCopied","useState","jsx","err","jsxs","TypographyRoot","children","size","className","rest","classes","Title","level","copyable","ellipsis","id","textContent","generatedId","levelClasses","ellipsisClass","content","Fragment","lineClampClasses","Paragraph","align","expanded","setExpanded","isEllipsisObject","rows","expandable","clampedRows","Text","code","mark","strong","italic","underline","del","type","typeClasses","Link","href","target","external","isExternal","linkTarget","rel","Typography"],"mappings":";;AA4CA,SAASA,EAAW,EAAE,MAAAC,KAA0B;AAC9C,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK;AAY1C,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAZe,YAAY;AAC7B,YAAI;AACF,gBAAM,UAAU,UAAU,UAAUJ,CAAI,GACxCE,EAAU,EAAI,GACd,WAAW,MAAMA,EAAU,EAAK,GAAG,GAAI;AAAA,QACzC,SAASG,GAAK;AACZ,kBAAQ,MAAM,mBAAmBA,CAAG;AAAA,QACtC;AAAA,MACF;AAAA,MAKI,WAAU;AAAA,MACV,OAAM;AAAA,MAEL,UAAAJ,sBACE,OAAA,EAAI,WAAU,WAAU,MAAK,gBAAe,SAAQ,aACnD,UAAA,gBAAAG;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,UAAS;AAAA,UACT,GAAE;AAAA,UACF,UAAS;AAAA,QAAA;AAAA,MAAA,EACX,CACF,IAEA,gBAAAE,EAAC,OAAA,EAAI,WAAU,WAAU,MAAK,gBAAe,SAAQ,aACnD,UAAA;AAAA,QAAA,gBAAAF,EAAC,QAAA,EAAK,GAAE,iDAAA,CAAiD;AAAA,QACzD,gBAAAA,EAAC,QAAA,EAAK,GAAE,6FAAA,CAA6F;AAAA,MAAA,EAAA,CACvG;AAAA,IAAA;AAAA,EAAA;AAIR;AAEA,SAASG,EAAe,EAAE,UAAAC,GAAU,MAAAC,IAAO,QAAQ,WAAAC,IAAY,IAAI,GAAGC,KAAyB;AAS7F,QAAMC,IAAU;AAAA;AAAA,IAEd;AAAA;AAAA,IAEA;AAAA,IAZkB;AAAA,MAClB,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,IAAA,EAQK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,OAAAM;AAAA,EACA,WAAAY;AAAA,EACA,MAAAQ;AAAA,EACA,MAAAS;AACF,CAAC;"}
|
package/dist/index87.js
CHANGED
|
@@ -1,36 +1,261 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { jsxs as p, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as U, useRef as x } from "react";
|
|
3
|
+
const K = ({
|
|
4
|
+
action: N,
|
|
5
|
+
accept: O,
|
|
6
|
+
multiple: A = !1,
|
|
7
|
+
maxCount: v,
|
|
8
|
+
maxSize: b,
|
|
9
|
+
listType: y = "text",
|
|
10
|
+
fileList: L,
|
|
11
|
+
defaultFileList: I = [],
|
|
12
|
+
beforeUpload: D,
|
|
13
|
+
onChange: m,
|
|
14
|
+
onRemove: F,
|
|
15
|
+
customRequest: k,
|
|
16
|
+
showUploadList: B = !0,
|
|
17
|
+
disabled: i = !1,
|
|
18
|
+
children: R,
|
|
19
|
+
className: T = "",
|
|
20
|
+
...W
|
|
21
|
+
}) => {
|
|
22
|
+
const [z, H] = U(I), [E, w] = U(!1), j = x(null), P = x(0), h = x(0), d = L !== void 0 ? L : z, S = () => (P.current += 1, `upload-${Date.now()}-${P.current}`), f = (e) => {
|
|
23
|
+
L === void 0 && H(e);
|
|
24
|
+
}, $ = (e) => {
|
|
25
|
+
const r = {
|
|
26
|
+
uid: S(),
|
|
27
|
+
name: e.name,
|
|
28
|
+
status: "uploading",
|
|
29
|
+
percent: 0,
|
|
30
|
+
originFileObj: e
|
|
31
|
+
}, n = [...d, r];
|
|
32
|
+
f(n), m?.({ file: r, fileList: n });
|
|
33
|
+
const l = (o) => {
|
|
34
|
+
const s = n.map(
|
|
35
|
+
(a) => a.uid === r.uid ? { ...a, percent: o } : a
|
|
36
|
+
);
|
|
37
|
+
f(s), m?.({ file: { ...r, percent: o }, fileList: s });
|
|
38
|
+
}, u = (o) => {
|
|
39
|
+
const s = {
|
|
40
|
+
...r,
|
|
41
|
+
status: "done",
|
|
42
|
+
percent: 100,
|
|
43
|
+
response: o
|
|
44
|
+
}, a = n.map(
|
|
45
|
+
(c) => c.uid === r.uid ? s : c
|
|
46
|
+
);
|
|
47
|
+
f(a), m?.({ file: s, fileList: a });
|
|
48
|
+
}, g = (o) => {
|
|
49
|
+
const s = {
|
|
50
|
+
...r,
|
|
51
|
+
status: "error",
|
|
52
|
+
error: o
|
|
53
|
+
}, a = n.map(
|
|
54
|
+
(c) => c.uid === r.uid ? s : c
|
|
55
|
+
);
|
|
56
|
+
f(a), m?.({ file: s, fileList: a });
|
|
57
|
+
};
|
|
58
|
+
if (k)
|
|
59
|
+
k({
|
|
60
|
+
file: e,
|
|
61
|
+
onProgress: l,
|
|
62
|
+
onSuccess: u,
|
|
63
|
+
onError: g
|
|
64
|
+
});
|
|
65
|
+
else if (N) {
|
|
66
|
+
const o = new FormData();
|
|
67
|
+
o.append("file", e);
|
|
68
|
+
const s = new XMLHttpRequest();
|
|
69
|
+
s.upload.addEventListener("progress", (a) => {
|
|
70
|
+
if (a.lengthComputable) {
|
|
71
|
+
const c = Math.round(a.loaded / a.total * 100);
|
|
72
|
+
l(c);
|
|
73
|
+
}
|
|
74
|
+
}), s.addEventListener("load", () => {
|
|
75
|
+
s.status >= 200 && s.status < 300 ? u(s.response) : g(new Error(`Upload failed with status ${s.status}`));
|
|
76
|
+
}), s.addEventListener("error", () => {
|
|
77
|
+
g(new Error("Upload failed"));
|
|
78
|
+
}), s.open("POST", N), s.send(o);
|
|
79
|
+
} else
|
|
80
|
+
u(null);
|
|
81
|
+
}, C = async (e) => {
|
|
82
|
+
if (i) return;
|
|
83
|
+
const r = Array.from(e);
|
|
84
|
+
if (v && d.length + r.length > v) {
|
|
85
|
+
console.warn(`Cannot upload more than ${v} files`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (b) {
|
|
89
|
+
const n = r.filter((l) => l.size > b);
|
|
90
|
+
if (n.length > 0) {
|
|
91
|
+
console.warn(
|
|
92
|
+
`Files exceed maximum size of ${b} bytes:`,
|
|
93
|
+
n.map((l) => l.name)
|
|
94
|
+
);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (D) {
|
|
99
|
+
const n = await Promise.all(
|
|
100
|
+
r.map((u) => D(u, r))
|
|
101
|
+
);
|
|
102
|
+
r.filter((u, g) => n[g] !== !1).forEach($);
|
|
103
|
+
} else
|
|
104
|
+
r.forEach($);
|
|
105
|
+
}, X = (e) => {
|
|
106
|
+
e.target.files && C(e.target.files), e.target.value = "";
|
|
107
|
+
}, _ = (e) => {
|
|
108
|
+
e.preventDefault(), e.stopPropagation(), i || (h.current++, w(!0));
|
|
109
|
+
}, q = (e) => {
|
|
110
|
+
e.preventDefault(), e.stopPropagation(), i || (h.current--, h.current === 0 && w(!1));
|
|
111
|
+
}, G = (e) => {
|
|
112
|
+
e.preventDefault(), e.stopPropagation();
|
|
113
|
+
}, J = (e) => {
|
|
114
|
+
e.preventDefault(), e.stopPropagation(), h.current = 0, w(!1), !i && e.dataTransfer.files && C(e.dataTransfer.files);
|
|
115
|
+
}, M = async (e) => {
|
|
116
|
+
if (F && await F(e) === !1)
|
|
117
|
+
return;
|
|
118
|
+
const r = d.filter((n) => n.uid !== e.uid);
|
|
119
|
+
f(r), m?.({ file: e, fileList: r });
|
|
31
120
|
};
|
|
32
|
-
|
|
121
|
+
return /* @__PURE__ */ p("div", { className: T, "data-state": E ? "dragging" : "idle", ...W, children: [
|
|
122
|
+
/* @__PURE__ */ t(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
onDragEnter: _,
|
|
126
|
+
onDragOver: G,
|
|
127
|
+
onDragLeave: q,
|
|
128
|
+
onDrop: J,
|
|
129
|
+
onClick: () => !i && j.current?.click(),
|
|
130
|
+
className: `
|
|
131
|
+
border-2 border-dashed rounded-lg p-4 cursor-pointer transition-colors
|
|
132
|
+
${E ? "border-primary bg-primary/5" : "border-base-content/20"}
|
|
133
|
+
${i ? "opacity-50 cursor-not-allowed" : "hover:border-primary"}
|
|
134
|
+
`,
|
|
135
|
+
children: R || /* @__PURE__ */ p("div", { className: "flex flex-col items-center gap-2 py-4", children: [
|
|
136
|
+
/* @__PURE__ */ t(
|
|
137
|
+
"svg",
|
|
138
|
+
{
|
|
139
|
+
className: "w-12 h-12 text-base-content/40",
|
|
140
|
+
fill: "none",
|
|
141
|
+
viewBox: "0 0 24 24",
|
|
142
|
+
stroke: "currentColor",
|
|
143
|
+
children: /* @__PURE__ */ t(
|
|
144
|
+
"path",
|
|
145
|
+
{
|
|
146
|
+
strokeLinecap: "round",
|
|
147
|
+
strokeLinejoin: "round",
|
|
148
|
+
strokeWidth: 2,
|
|
149
|
+
d: "M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ p("div", { className: "text-sm text-center", children: [
|
|
155
|
+
/* @__PURE__ */ t("span", { className: "font-semibold text-primary", children: "Click to upload" }),
|
|
156
|
+
/* @__PURE__ */ t("span", { className: "text-base-content/60", children: " or drag and drop" })
|
|
157
|
+
] })
|
|
158
|
+
] })
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
/* @__PURE__ */ t(
|
|
162
|
+
"input",
|
|
163
|
+
{
|
|
164
|
+
ref: j,
|
|
165
|
+
type: "file",
|
|
166
|
+
accept: O,
|
|
167
|
+
multiple: A,
|
|
168
|
+
onChange: X,
|
|
169
|
+
disabled: i,
|
|
170
|
+
className: "hidden"
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
!B || d.length === 0 ? null : y === "picture-card" ? /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2 mt-2", children: d.map((e) => /* @__PURE__ */ p(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
className: "relative w-24 h-24 border border-base-content/20 rounded-lg overflow-hidden",
|
|
177
|
+
children: [
|
|
178
|
+
e.status === "uploading" && /* @__PURE__ */ t("div", { className: "absolute inset-0 bg-base-300/80 flex items-center justify-center", children: /* @__PURE__ */ t("span", { className: "loading loading-spinner loading-sm" }) }),
|
|
179
|
+
e.status === "done" && e.url && /* @__PURE__ */ t(
|
|
180
|
+
"img",
|
|
181
|
+
{
|
|
182
|
+
src: e.url,
|
|
183
|
+
alt: e.name,
|
|
184
|
+
className: "w-full h-full object-cover"
|
|
185
|
+
}
|
|
186
|
+
),
|
|
187
|
+
e.status === "error" && /* @__PURE__ */ t("div", { className: "absolute inset-0 bg-error/10 flex items-center justify-center", children: /* @__PURE__ */ t(
|
|
188
|
+
"svg",
|
|
189
|
+
{
|
|
190
|
+
className: "w-8 h-8 text-error",
|
|
191
|
+
fill: "none",
|
|
192
|
+
viewBox: "0 0 24 24",
|
|
193
|
+
stroke: "currentColor",
|
|
194
|
+
children: /* @__PURE__ */ t(
|
|
195
|
+
"path",
|
|
196
|
+
{
|
|
197
|
+
strokeLinecap: "round",
|
|
198
|
+
strokeLinejoin: "round",
|
|
199
|
+
strokeWidth: 2,
|
|
200
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
) }),
|
|
205
|
+
/* @__PURE__ */ t(
|
|
206
|
+
"button",
|
|
207
|
+
{
|
|
208
|
+
onClick: () => M(e),
|
|
209
|
+
className: "absolute top-1 right-1 btn btn-xs btn-circle btn-error",
|
|
210
|
+
type: "button",
|
|
211
|
+
children: "✕"
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
e.uid
|
|
217
|
+
)) }) : /* @__PURE__ */ t("div", { className: "mt-2 space-y-2", children: d.map((e) => /* @__PURE__ */ p(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
className: "flex items-center gap-2 p-2 border border-base-content/10 rounded-lg",
|
|
221
|
+
children: [
|
|
222
|
+
y === "picture" && e.url && /* @__PURE__ */ t(
|
|
223
|
+
"img",
|
|
224
|
+
{
|
|
225
|
+
src: e.url,
|
|
226
|
+
alt: e.name,
|
|
227
|
+
className: "w-12 h-12 object-cover rounded"
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
/* @__PURE__ */ p("div", { className: "flex-1 min-w-0", children: [
|
|
231
|
+
/* @__PURE__ */ t("div", { className: "truncate text-sm", children: e.name }),
|
|
232
|
+
e.status === "uploading" && e.percent !== void 0 && /* @__PURE__ */ t("div", { className: "w-full bg-base-200 rounded-full h-1.5 mt-1", children: /* @__PURE__ */ t(
|
|
233
|
+
"div",
|
|
234
|
+
{
|
|
235
|
+
className: "bg-primary h-1.5 rounded-full transition-all",
|
|
236
|
+
style: { width: `${e.percent}%` }
|
|
237
|
+
}
|
|
238
|
+
) }),
|
|
239
|
+
e.status === "error" && /* @__PURE__ */ t("div", { className: "text-xs text-error mt-1", children: "Upload failed" })
|
|
240
|
+
] }),
|
|
241
|
+
/* @__PURE__ */ t(
|
|
242
|
+
"button",
|
|
243
|
+
{
|
|
244
|
+
onClick: () => M(e),
|
|
245
|
+
className: "btn btn-xs btn-ghost btn-circle",
|
|
246
|
+
type: "button",
|
|
247
|
+
children: "✕"
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
e.uid
|
|
253
|
+
)) })
|
|
254
|
+
] });
|
|
255
|
+
};
|
|
256
|
+
K.displayName = "Upload";
|
|
33
257
|
export {
|
|
34
|
-
|
|
258
|
+
K as Upload,
|
|
259
|
+
K as default
|
|
35
260
|
};
|
|
36
261
|
//# sourceMappingURL=index87.js.map
|
package/dist/index87.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index87.js","sources":["../src/hooks/useBreakpoint.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\n\nexport type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n\nconst breakpoints: Record<Breakpoint, number> = {\n xs: 0,\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n '2xl': 1536,\n}\n\nconst breakpointOrder: Breakpoint[] = ['xs', 'sm', 'md', 'lg', 'xl', '2xl']\n\nfunction getBreakpoint(width: number): Breakpoint {\n if (width >= breakpoints['2xl']) return '2xl'\n if (width >= breakpoints.xl) return 'xl'\n if (width >= breakpoints.lg) return 'lg'\n if (width >= breakpoints.md) return 'md'\n if (width >= breakpoints.sm) return 'sm'\n return 'xs'\n}\n\nfunction compareBreakpoints(a: Breakpoint, b: Breakpoint): number {\n return breakpointOrder.indexOf(a) - breakpointOrder.indexOf(b)\n}\n\nexport interface UseBreakpointReturn {\n breakpoint: Breakpoint\n width: number\n isAbove: (bp: Breakpoint) => boolean\n isBelow: (bp: Breakpoint) => boolean\n isAt: (bp: Breakpoint) => boolean\n isBetween: (min: Breakpoint, max: Breakpoint) => boolean\n}\n\nexport function useBreakpoint(): UseBreakpointReturn {\n const [width, setWidth] = useState(() =>\n typeof window !== 'undefined' ? window.innerWidth : 1024\n )\n\n useEffect(() => {\n const handleResize = () => setWidth(window.innerWidth)\n\n window.addEventListener('resize', handleResize)\n return () => window.removeEventListener('resize', handleResize)\n }, [])\n\n const breakpoint = getBreakpoint(width)\n\n return {\n breakpoint,\n width,\n isAbove: (bp: Breakpoint) => compareBreakpoints(breakpoint, bp) >= 0,\n isBelow: (bp: Breakpoint) => compareBreakpoints(breakpoint, bp) < 0,\n isAt: (bp: Breakpoint) => breakpoint === bp,\n isBetween: (min: Breakpoint, max: Breakpoint) =>\n compareBreakpoints(breakpoint, min) >= 0 && compareBreakpoints(breakpoint, max) <= 0,\n }\n}\n"],"names":["breakpoints","breakpointOrder","getBreakpoint","width","compareBreakpoints","a","b","useBreakpoint","setWidth","useState","useEffect","handleResize","breakpoint","bp","min","max"],"mappings":";AAIA,MAAMA,IAA0C;AAAA,EAE9C,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT,GAEMC,IAAgC,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,KAAK;AAE1E,SAASC,EAAcC,GAA2B;AAChD,SAAIA,KAASH,EAAY,KAAK,IAAU,QACpCG,KAASH,EAAY,KAAW,OAChCG,KAASH,EAAY,KAAW,OAChCG,KAASH,EAAY,KAAW,OAChCG,KAASH,EAAY,KAAW,OAC7B;AACT;AAEA,SAASI,EAAmBC,GAAeC,GAAuB;AAChE,SAAOL,EAAgB,QAAQI,CAAC,IAAIJ,EAAgB,QAAQK,CAAC;AAC/D;AAWO,SAASC,IAAqC;AACnD,QAAM,CAACJ,GAAOK,CAAQ,IAAIC;AAAA,IAAS,MACjC,OAAO,SAAW,MAAc,OAAO,aAAa;AAAA,EAAA;AAGtD,EAAAC,EAAU,MAAM;AACd,UAAMC,IAAe,MAAMH,EAAS,OAAO,UAAU;AAErD,kBAAO,iBAAiB,UAAUG,CAAY,GACvC,MAAM,OAAO,oBAAoB,UAAUA,CAAY;AAAA,EAChE,GAAG,CAAA,CAAE;AAEL,QAAMC,IAAaV,EAAcC,CAAK;AAEtC,SAAO;AAAA,IACL,YAAAS;AAAA,IACA,OAAAT;AAAA,IACA,SAAS,CAACU,MAAmBT,EAAmBQ,GAAYC,CAAE,KAAK;AAAA,IACnE,SAAS,CAACA,MAAmBT,EAAmBQ,GAAYC,CAAE,IAAI;AAAA,IAClE,MAAM,CAACA,MAAmBD,MAAeC;AAAA,IACzC,WAAW,CAACC,GAAiBC,MAC3BX,EAAmBQ,GAAYE,CAAG,KAAK,KAAKV,EAAmBQ,GAAYG,CAAG,KAAK;AAAA,EAAA;AAEzF;"}
|
|
1
|
+
{"version":3,"file":"index87.js","sources":["../src/components/Upload.tsx"],"sourcesContent":["import React, { useState, useRef, DragEvent, ChangeEvent } from 'react'\n\nexport interface UploadFile {\n uid: string\n name: string\n status: 'uploading' | 'done' | 'error'\n percent?: number\n url?: string\n response?: any\n error?: any\n originFileObj?: File\n}\n\nexport interface UploadProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n action?: string\n accept?: string\n multiple?: boolean\n maxCount?: number\n maxSize?: number // in bytes\n listType?: 'text' | 'picture' | 'picture-card'\n fileList?: UploadFile[]\n defaultFileList?: UploadFile[]\n beforeUpload?: (file: File, fileList: File[]) => boolean | Promise<boolean>\n onChange?: (info: { file: UploadFile; fileList: UploadFile[] }) => void\n onRemove?: (file: UploadFile) => void | boolean | Promise<void | boolean>\n customRequest?: (options: {\n file: File\n onProgress: (percent: number) => void\n onSuccess: (response: any) => void\n onError: (error: any) => void\n }) => void\n showUploadList?: boolean\n disabled?: boolean\n children?: React.ReactNode\n}\n\nexport const Upload: React.FC<UploadProps> = ({\n action,\n accept,\n multiple = false,\n maxCount,\n maxSize,\n listType = 'text',\n fileList: controlledFileList,\n defaultFileList = [],\n beforeUpload,\n onChange,\n onRemove,\n customRequest,\n showUploadList = true,\n disabled = false,\n children,\n className = '',\n ...rest\n}) => {\n const [internalFileList, setInternalFileList] = useState<UploadFile[]>(defaultFileList)\n const [isDragging, setIsDragging] = useState(false)\n const fileInputRef = useRef<HTMLInputElement>(null)\n const uidCounter = useRef(0)\n const dragCounter = useRef(0)\n\n const fileList = controlledFileList !== undefined ? controlledFileList : internalFileList\n\n const generateUid = () => {\n uidCounter.current += 1\n return `upload-${Date.now()}-${uidCounter.current}`\n }\n\n const updateFileList = (newFileList: UploadFile[]) => {\n if (controlledFileList === undefined) {\n setInternalFileList(newFileList)\n }\n }\n\n const uploadFile = (file: File) => {\n const uploadFile: UploadFile = {\n uid: generateUid(),\n name: file.name,\n status: 'uploading',\n percent: 0,\n originFileObj: file,\n }\n\n const newFileList = [...fileList, uploadFile]\n updateFileList(newFileList)\n onChange?.({ file: uploadFile, fileList: newFileList })\n\n const updateProgress = (percent: number) => {\n const updatedList = newFileList.map((f) =>\n f.uid === uploadFile.uid ? { ...f, percent } : f\n )\n updateFileList(updatedList)\n onChange?.({ file: { ...uploadFile, percent }, fileList: updatedList })\n }\n\n const onSuccess = (response: any) => {\n const successFile = {\n ...uploadFile,\n status: 'done' as const,\n percent: 100,\n response,\n }\n const updatedList = newFileList.map((f) =>\n f.uid === uploadFile.uid ? successFile : f\n )\n updateFileList(updatedList)\n onChange?.({ file: successFile, fileList: updatedList })\n }\n\n const onError = (error: any) => {\n const errorFile = {\n ...uploadFile,\n status: 'error' as const,\n error,\n }\n const updatedList = newFileList.map((f) =>\n f.uid === uploadFile.uid ? errorFile : f\n )\n updateFileList(updatedList)\n onChange?.({ file: errorFile, fileList: updatedList })\n }\n\n if (customRequest) {\n customRequest({\n file,\n onProgress: updateProgress,\n onSuccess,\n onError,\n })\n } else if (action) {\n const formData = new FormData()\n formData.append('file', file)\n\n const xhr = new XMLHttpRequest()\n\n xhr.upload.addEventListener('progress', (e) => {\n if (e.lengthComputable) {\n const percent = Math.round((e.loaded / e.total) * 100)\n updateProgress(percent)\n }\n })\n\n xhr.addEventListener('load', () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n onSuccess(xhr.response)\n } else {\n onError(new Error(`Upload failed with status ${xhr.status}`))\n }\n })\n\n xhr.addEventListener('error', () => {\n onError(new Error('Upload failed'))\n })\n\n xhr.open('POST', action)\n xhr.send(formData)\n } else {\n // No upload action, just mark as done\n onSuccess(null)\n }\n }\n\n const handleFiles = async (files: FileList | File[]) => {\n if (disabled) return\n\n const fileArray = Array.from(files)\n\n // Check maxCount\n if (maxCount && fileList.length + fileArray.length > maxCount) {\n console.warn(`Cannot upload more than ${maxCount} files`)\n return\n }\n\n // Check maxSize\n if (maxSize) {\n const oversizedFiles = fileArray.filter((file) => file.size > maxSize)\n if (oversizedFiles.length > 0) {\n console.warn(\n `Files exceed maximum size of ${maxSize} bytes:`,\n oversizedFiles.map((f) => f.name)\n )\n return\n }\n }\n\n // beforeUpload hook\n if (beforeUpload) {\n const results = await Promise.all(\n fileArray.map((file) => beforeUpload(file, fileArray))\n )\n const filteredFiles = fileArray.filter((_, index) => results[index] !== false)\n filteredFiles.forEach(uploadFile)\n } else {\n fileArray.forEach(uploadFile)\n }\n }\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files) {\n handleFiles(e.target.files)\n }\n // Reset input value to allow uploading the same file again\n e.target.value = ''\n }\n\n const handleDragEnter = (e: DragEvent) => {\n e.preventDefault()\n e.stopPropagation()\n if (!disabled) {\n dragCounter.current++\n setIsDragging(true)\n }\n }\n\n const handleDragLeave = (e: DragEvent) => {\n e.preventDefault()\n e.stopPropagation()\n if (!disabled) {\n dragCounter.current--\n if (dragCounter.current === 0) {\n setIsDragging(false)\n }\n }\n }\n\n const handleDragOver = (e: DragEvent) => {\n e.preventDefault()\n e.stopPropagation()\n }\n\n const handleDrop = (e: DragEvent) => {\n e.preventDefault()\n e.stopPropagation()\n dragCounter.current = 0\n setIsDragging(false)\n\n if (disabled) return\n\n if (e.dataTransfer.files) {\n handleFiles(e.dataTransfer.files)\n }\n }\n\n const handleRemove = async (file: UploadFile) => {\n if (onRemove) {\n const result = await onRemove(file)\n if (result === false) return\n }\n\n const newFileList = fileList.filter((f) => f.uid !== file.uid)\n updateFileList(newFileList)\n onChange?.({ file, fileList: newFileList })\n }\n\n const renderFileList = () => {\n if (!showUploadList || fileList.length === 0) return null\n\n if (listType === 'picture-card') {\n return (\n <div className=\"flex flex-wrap gap-2 mt-2\">\n {fileList.map((file) => (\n <div\n key={file.uid}\n className=\"relative w-24 h-24 border border-base-content/20 rounded-lg overflow-hidden\"\n >\n {file.status === 'uploading' && (\n <div className=\"absolute inset-0 bg-base-300/80 flex items-center justify-center\">\n <span className=\"loading loading-spinner loading-sm\"></span>\n </div>\n )}\n {file.status === 'done' && file.url && (\n <img\n src={file.url}\n alt={file.name}\n className=\"w-full h-full object-cover\"\n />\n )}\n {file.status === 'error' && (\n <div className=\"absolute inset-0 bg-error/10 flex items-center justify-center\">\n <svg\n className=\"w-8 h-8 text-error\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </div>\n )}\n <button\n onClick={() => handleRemove(file)}\n className=\"absolute top-1 right-1 btn btn-xs btn-circle btn-error\"\n type=\"button\"\n >\n ✕\n </button>\n </div>\n ))}\n </div>\n )\n }\n\n return (\n <div className=\"mt-2 space-y-2\">\n {fileList.map((file) => (\n <div\n key={file.uid}\n className=\"flex items-center gap-2 p-2 border border-base-content/10 rounded-lg\"\n >\n {listType === 'picture' && file.url && (\n <img\n src={file.url}\n alt={file.name}\n className=\"w-12 h-12 object-cover rounded\"\n />\n )}\n <div className=\"flex-1 min-w-0\">\n <div className=\"truncate text-sm\">{file.name}</div>\n {file.status === 'uploading' && file.percent !== undefined && (\n <div className=\"w-full bg-base-200 rounded-full h-1.5 mt-1\">\n <div\n className=\"bg-primary h-1.5 rounded-full transition-all\"\n style={{ width: `${file.percent}%` }}\n />\n </div>\n )}\n {file.status === 'error' && (\n <div className=\"text-xs text-error mt-1\">Upload failed</div>\n )}\n </div>\n <button\n onClick={() => handleRemove(file)}\n className=\"btn btn-xs btn-ghost btn-circle\"\n type=\"button\"\n >\n ✕\n </button>\n </div>\n ))}\n </div>\n )\n }\n\n return (\n <div className={className} data-state={isDragging ? 'dragging' : 'idle'} {...rest}>\n <div\n onDragEnter={handleDragEnter}\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onDrop={handleDrop}\n onClick={() => !disabled && fileInputRef.current?.click()}\n className={`\n border-2 border-dashed rounded-lg p-4 cursor-pointer transition-colors\n ${isDragging ? 'border-primary bg-primary/5' : 'border-base-content/20'}\n ${disabled ? 'opacity-50 cursor-not-allowed' : 'hover:border-primary'}\n `}\n >\n {children || (\n <div className=\"flex flex-col items-center gap-2 py-4\">\n <svg\n className=\"w-12 h-12 text-base-content/40\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12\"\n />\n </svg>\n <div className=\"text-sm text-center\">\n <span className=\"font-semibold text-primary\">Click to upload</span>\n <span className=\"text-base-content/60\"> or drag and drop</span>\n </div>\n </div>\n )}\n </div>\n\n <input\n ref={fileInputRef}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n onChange={handleChange}\n disabled={disabled}\n className=\"hidden\"\n />\n\n {renderFileList()}\n </div>\n )\n}\n\nUpload.displayName = 'Upload'\n\nexport default Upload\n"],"names":["Upload","action","accept","multiple","maxCount","maxSize","listType","controlledFileList","defaultFileList","beforeUpload","onChange","onRemove","customRequest","showUploadList","disabled","children","className","rest","internalFileList","setInternalFileList","useState","isDragging","setIsDragging","fileInputRef","useRef","uidCounter","dragCounter","fileList","generateUid","updateFileList","newFileList","uploadFile","file","updateProgress","percent","updatedList","f","onSuccess","response","successFile","onError","error","errorFile","formData","xhr","e","handleFiles","files","fileArray","oversizedFiles","results","_","index","handleChange","handleDragEnter","handleDragLeave","handleDragOver","handleDrop","handleRemove","jsxs","jsx"],"mappings":";;AAoCO,MAAMA,IAAgC,CAAC;AAAA,EAC5C,QAAAC;AAAA,EACA,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