asterui 0.12.14 → 0.12.16

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 (159) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Autocomplete.d.ts +22 -2
  3. package/dist/components/Button.d.ts +10 -5
  4. package/dist/components/Form.d.ts +11 -1
  5. package/dist/components/HoverGallery.d.ts +10 -0
  6. package/dist/components/Rating.d.ts +12 -4
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.js +156 -154
  9. package/dist/index.js.map +1 -1
  10. package/dist/index100.js +11 -43
  11. package/dist/index100.js.map +1 -1
  12. package/dist/index101.js +44 -11
  13. package/dist/index101.js.map +1 -1
  14. package/dist/index102.js +10 -12
  15. package/dist/index102.js.map +1 -1
  16. package/dist/index103.js +14 -7
  17. package/dist/index103.js.map +1 -1
  18. package/dist/index104.js +7 -12
  19. package/dist/index104.js.map +1 -1
  20. package/dist/index105.js +11 -29
  21. package/dist/index105.js.map +1 -1
  22. package/dist/index106.js +29 -16
  23. package/dist/index106.js.map +1 -1
  24. package/dist/index107.js +21 -0
  25. package/dist/index107.js.map +1 -0
  26. package/dist/index21.js +1 -1
  27. package/dist/index34.js +133 -119
  28. package/dist/index34.js.map +1 -1
  29. package/dist/index37.js +15 -120
  30. package/dist/index37.js.map +1 -1
  31. package/dist/index38.js +119 -37
  32. package/dist/index38.js.map +1 -1
  33. package/dist/index39.js +40 -398
  34. package/dist/index39.js.map +1 -1
  35. package/dist/index40.js +390 -89
  36. package/dist/index40.js.map +1 -1
  37. package/dist/index41.js +90 -215
  38. package/dist/index41.js.map +1 -1
  39. package/dist/index42.js +211 -135
  40. package/dist/index42.js.map +1 -1
  41. package/dist/index43.js +155 -15
  42. package/dist/index43.js.map +1 -1
  43. package/dist/index44.js +15 -17
  44. package/dist/index44.js.map +1 -1
  45. package/dist/index45.js +17 -21
  46. package/dist/index45.js.map +1 -1
  47. package/dist/index46.js +18 -134
  48. package/dist/index46.js.map +1 -1
  49. package/dist/index47.js +134 -10
  50. package/dist/index47.js.map +1 -1
  51. package/dist/index48.js +13 -35
  52. package/dist/index48.js.map +1 -1
  53. package/dist/index49.js +35 -34
  54. package/dist/index49.js.map +1 -1
  55. package/dist/index5.js +161 -80
  56. package/dist/index5.js.map +1 -1
  57. package/dist/index50.js +34 -81
  58. package/dist/index50.js.map +1 -1
  59. package/dist/index51.js +71 -166
  60. package/dist/index51.js.map +1 -1
  61. package/dist/index52.js +167 -144
  62. package/dist/index52.js.map +1 -1
  63. package/dist/index53.js +152 -11
  64. package/dist/index53.js.map +1 -1
  65. package/dist/index54.js +10 -20
  66. package/dist/index54.js.map +1 -1
  67. package/dist/index55.js +22 -14
  68. package/dist/index55.js.map +1 -1
  69. package/dist/index56.js +14 -7
  70. package/dist/index56.js.map +1 -1
  71. package/dist/index57.js +6 -333
  72. package/dist/index57.js.map +1 -1
  73. package/dist/index58.js +334 -47
  74. package/dist/index58.js.map +1 -1
  75. package/dist/index59.js +47 -122
  76. package/dist/index59.js.map +1 -1
  77. package/dist/index60.js +120 -108
  78. package/dist/index60.js.map +1 -1
  79. package/dist/index61.js +107 -167
  80. package/dist/index61.js.map +1 -1
  81. package/dist/index62.js +167 -29
  82. package/dist/index62.js.map +1 -1
  83. package/dist/index63.js +30 -120
  84. package/dist/index63.js.map +1 -1
  85. package/dist/index64.js +116 -80
  86. package/dist/index64.js.map +1 -1
  87. package/dist/index65.js +85 -19
  88. package/dist/index65.js.map +1 -1
  89. package/dist/index66.js +19 -73
  90. package/dist/index66.js.map +1 -1
  91. package/dist/index67.js +71 -54
  92. package/dist/index67.js.map +1 -1
  93. package/dist/index68.js +56 -44
  94. package/dist/index68.js.map +1 -1
  95. package/dist/index69.js +42 -49
  96. package/dist/index69.js.map +1 -1
  97. package/dist/index70.js +52 -62
  98. package/dist/index70.js.map +1 -1
  99. package/dist/index71.js +118 -102
  100. package/dist/index71.js.map +1 -1
  101. package/dist/index72.js +107 -41
  102. package/dist/index72.js.map +1 -1
  103. package/dist/index73.js +41 -68
  104. package/dist/index73.js.map +1 -1
  105. package/dist/index74.js +66 -19
  106. package/dist/index74.js.map +1 -1
  107. package/dist/index75.js +18 -55
  108. package/dist/index75.js.map +1 -1
  109. package/dist/index76.js +55 -251
  110. package/dist/index76.js.map +1 -1
  111. package/dist/index77.js +254 -22
  112. package/dist/index77.js.map +1 -1
  113. package/dist/index78.js +22 -31
  114. package/dist/index78.js.map +1 -1
  115. package/dist/index79.js +30 -93
  116. package/dist/index79.js.map +1 -1
  117. package/dist/index80.js +89 -324
  118. package/dist/index80.js.map +1 -1
  119. package/dist/index81.js +322 -73
  120. package/dist/index81.js.map +1 -1
  121. package/dist/index82.js +79 -39
  122. package/dist/index82.js.map +1 -1
  123. package/dist/index83.js +40 -23
  124. package/dist/index83.js.map +1 -1
  125. package/dist/index84.js +21 -93
  126. package/dist/index84.js.map +1 -1
  127. package/dist/index85.js +87 -148
  128. package/dist/index85.js.map +1 -1
  129. package/dist/index86.js +147 -152
  130. package/dist/index86.js.map +1 -1
  131. package/dist/index87.js +159 -63
  132. package/dist/index87.js.map +1 -1
  133. package/dist/index88.js +65 -35
  134. package/dist/index88.js.map +1 -1
  135. package/dist/index89.js +35 -234
  136. package/dist/index89.js.map +1 -1
  137. package/dist/index9.js +55 -53
  138. package/dist/index9.js.map +1 -1
  139. package/dist/index90.js +231 -31
  140. package/dist/index90.js.map +1 -1
  141. package/dist/index91.js +34 -210
  142. package/dist/index91.js.map +1 -1
  143. package/dist/index92.js +195 -198
  144. package/dist/index92.js.map +1 -1
  145. package/dist/index93.js +159 -241
  146. package/dist/index93.js.map +1 -1
  147. package/dist/index94.js +283 -166
  148. package/dist/index94.js.map +1 -1
  149. package/dist/index95.js +173 -253
  150. package/dist/index95.js.map +1 -1
  151. package/dist/index96.js +258 -14
  152. package/dist/index96.js.map +1 -1
  153. package/dist/index97.js +12 -31
  154. package/dist/index97.js.map +1 -1
  155. package/dist/index98.js +32 -5
  156. package/dist/index98.js.map +1 -1
  157. package/dist/index99.js +5 -13
  158. package/dist/index99.js.map +1 -1
  159. package/package.json +1 -1
package/dist/index96.js CHANGED
@@ -1,17 +1,261 @@
1
- import { jsx as v, Fragment as A } from "react/jsx-runtime";
2
- import { useBreakpoint as m } from "./index97.js";
3
- function h({ children: f, above: o, below: r, at: s, between: e }) {
4
- const { isAbove: d, isBelow: n, isAt: l, isBetween: u } = m();
5
- let i = !1;
6
- return o !== void 0 ? i = d(o) : r !== void 0 ? i = n(r) : s !== void 0 ? Array.isArray(s) ? i = s.some((t) => l(t)) : i = l(s) : e !== void 0 ? i = u(e[0], e[1]) : i = !0, i ? /* @__PURE__ */ v(A, { children: f }) : null;
7
- }
8
- function p({ children: f, above: o, below: r, at: s, between: e }) {
9
- const { isAbove: d, isBelow: n, isAt: l, isBetween: u } = m();
10
- let i = !1;
11
- return o !== void 0 ? i = d(o) : r !== void 0 ? i = n(r) : s !== void 0 ? Array.isArray(s) ? i = s.some((t) => l(t)) : i = l(s) : e !== void 0 && (i = u(e[0], e[1])), i ? null : /* @__PURE__ */ v(A, { children: f });
12
- }
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 });
120
+ };
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";
13
257
  export {
14
- p as Hide,
15
- h as Show
258
+ K as Upload,
259
+ K as default
16
260
  };
17
261
  //# sourceMappingURL=index96.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index96.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":"index96.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,QAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAUC;AAAA,EACV,iBAAAC,IAAkB,CAAA;AAAA,EAClB,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,UAAAC,IAAW;AAAA,EACX,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AACJ,QAAM,CAACC,GAAkBC,CAAmB,IAAIC,EAAuBZ,CAAe,GAChF,CAACa,GAAYC,CAAa,IAAIF,EAAS,EAAK,GAC5CG,IAAeC,EAAyB,IAAI,GAC5CC,IAAaD,EAAO,CAAC,GACrBE,IAAcF,EAAO,CAAC,GAEtBG,IAAWpB,MAAuB,SAAYA,IAAqBW,GAEnEU,IAAc,OAClBH,EAAW,WAAW,GACf,UAAU,KAAK,IAAA,CAAK,IAAIA,EAAW,OAA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AArD,MAAa,aAAa0B,EAAK,OAC9B,gBAAA4B;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK5B,EAAK;AAAA,cACV,KAAKA,EAAK;AAAA,cACV,WAAU;AAAA,YAAA;AAAA,UAAA;AAAA,UAGd,gBAAA2B,EAAC,OAAA,EAAI,WAAU,kBACb,UAAA;AAAA,YAAA,gBAAAC,EAAC,OAAA,EAAI,WAAU,oBAAoB,UAAA5B,EAAK,MAAK;AAAA,YAC5CA,EAAK,WAAW,eAAeA,EAAK,YAAY,UAC/C,gBAAA4B,EAAC,OAAA,EAAI,WAAU,8CACb,UAAA,gBAAAA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAU;AAAA,gBACV,OAAO,EAAE,OAAO,GAAG5B,EAAK,OAAO,IAAA;AAAA,cAAI;AAAA,YAAA,GAEvC;AAAA,YAEDA,EAAK,WAAW,6BACd,OAAA,EAAI,WAAU,2BAA0B,UAAA,gBAAA,CAAa;AAAA,UAAA,GAE1D;AAAA,UACA,gBAAA4B;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS,MAAMF,EAAa1B,CAAI;AAAA,cAChC,WAAU;AAAA,cACV,MAAK;AAAA,cACN,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QAED;AAAA,MAAA;AAAA,MA9BKA,EAAK;AAAA,IAAA,CAgCb,GACH;AAAA,EAmDgB,GAClB;AAEJ;AAEAhC,EAAO,cAAc;"}
package/dist/index97.js CHANGED
@@ -1,36 +1,17 @@
1
- import { useState as u, useEffect as f } from "react";
2
- const t = {
3
- sm: 640,
4
- md: 768,
5
- lg: 1024,
6
- xl: 1280,
7
- "2xl": 1536
8
- }, s = ["xs", "sm", "md", "lg", "xl", "2xl"];
9
- function l(e) {
10
- return e >= t["2xl"] ? "2xl" : e >= t.xl ? "xl" : e >= t.lg ? "lg" : e >= t.md ? "md" : e >= t.sm ? "sm" : "xs";
1
+ import { jsx as v, Fragment as A } from "react/jsx-runtime";
2
+ import { useBreakpoint as m } from "./index98.js";
3
+ function h({ children: f, above: o, below: r, at: s, between: e }) {
4
+ const { isAbove: d, isBelow: n, isAt: l, isBetween: u } = m();
5
+ let i = !1;
6
+ return o !== void 0 ? i = d(o) : r !== void 0 ? i = n(r) : s !== void 0 ? Array.isArray(s) ? i = s.some((t) => l(t)) : i = l(s) : e !== void 0 ? i = u(e[0], e[1]) : i = !0, i ? /* @__PURE__ */ v(A, { children: f }) : null;
11
7
  }
12
- function i(e, o) {
13
- return s.indexOf(e) - s.indexOf(o);
14
- }
15
- function m() {
16
- const [e, o] = u(
17
- () => typeof window < "u" ? window.innerWidth : 1024
18
- );
19
- f(() => {
20
- const n = () => o(window.innerWidth);
21
- return window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
22
- }, []);
23
- const r = l(e);
24
- return {
25
- breakpoint: r,
26
- width: e,
27
- isAbove: (n) => i(r, n) >= 0,
28
- isBelow: (n) => i(r, n) < 0,
29
- isAt: (n) => r === n,
30
- isBetween: (n, d) => i(r, n) >= 0 && i(r, d) <= 0
31
- };
8
+ function p({ children: f, above: o, below: r, at: s, between: e }) {
9
+ const { isAbove: d, isBelow: n, isAt: l, isBetween: u } = m();
10
+ let i = !1;
11
+ return o !== void 0 ? i = d(o) : r !== void 0 ? i = n(r) : s !== void 0 ? Array.isArray(s) ? i = s.some((t) => l(t)) : i = l(s) : e !== void 0 && (i = u(e[0], e[1])), i ? null : /* @__PURE__ */ v(A, { children: f });
32
12
  }
33
13
  export {
34
- m as useBreakpoint
14
+ p as Hide,
15
+ h as Show
35
16
  };
36
17
  //# sourceMappingURL=index97.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index97.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":"index97.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;"}
package/dist/index98.js CHANGED
@@ -1,9 +1,36 @@
1
- import { useState as u, useCallback as s } from "react";
2
- function p(o = !1) {
3
- const [n, e] = u(o), t = s(() => e(!0), []), c = s(() => e(!1), []), l = s(() => e((r) => !r), []);
4
- return { isOpen: n, onOpen: t, onClose: c, onToggle: l, setIsOpen: e };
1
+ import { useState as u, useEffect as f } from "react";
2
+ const t = {
3
+ sm: 640,
4
+ md: 768,
5
+ lg: 1024,
6
+ xl: 1280,
7
+ "2xl": 1536
8
+ }, s = ["xs", "sm", "md", "lg", "xl", "2xl"];
9
+ function l(e) {
10
+ return e >= t["2xl"] ? "2xl" : e >= t.xl ? "xl" : e >= t.lg ? "lg" : e >= t.md ? "md" : e >= t.sm ? "sm" : "xs";
11
+ }
12
+ function i(e, o) {
13
+ return s.indexOf(e) - s.indexOf(o);
14
+ }
15
+ function m() {
16
+ const [e, o] = u(
17
+ () => typeof window < "u" ? window.innerWidth : 1024
18
+ );
19
+ f(() => {
20
+ const n = () => o(window.innerWidth);
21
+ return window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
22
+ }, []);
23
+ const r = l(e);
24
+ return {
25
+ breakpoint: r,
26
+ width: e,
27
+ isAbove: (n) => i(r, n) >= 0,
28
+ isBelow: (n) => i(r, n) < 0,
29
+ isAt: (n) => r === n,
30
+ isBetween: (n, d) => i(r, n) >= 0 && i(r, d) <= 0
31
+ };
5
32
  }
6
33
  export {
7
- p as useDisclosure
34
+ m as useBreakpoint
8
35
  };
9
36
  //# sourceMappingURL=index98.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index98.js","sources":["../src/hooks/useDisclosure.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseDisclosureReturn {\n isOpen: boolean\n onOpen: () => void\n onClose: () => void\n onToggle: () => void\n setIsOpen: (value: boolean) => void\n}\n\n/**\n * Hook for managing open/close state of modals, drawers, dropdowns, etc.\n *\n * @param defaultIsOpen - Initial open state (default: false)\n * @returns Object with isOpen state and control functions\n *\n * @example\n * const { isOpen, onOpen, onClose } = useDisclosure()\n *\n * <Button onClick={onOpen}>Open Modal</Button>\n * <Modal open={isOpen} onClose={onClose}>Content</Modal>\n */\nexport function useDisclosure(defaultIsOpen = false): UseDisclosureReturn {\n const [isOpen, setIsOpen] = useState(defaultIsOpen)\n\n const onOpen = useCallback(() => setIsOpen(true), [])\n const onClose = useCallback(() => setIsOpen(false), [])\n const onToggle = useCallback(() => setIsOpen(prev => !prev), [])\n\n return { isOpen, onOpen, onClose, onToggle, setIsOpen }\n}\n"],"names":["useDisclosure","defaultIsOpen","isOpen","setIsOpen","useState","onOpen","useCallback","onClose","onToggle","prev"],"mappings":";AAsBO,SAASA,EAAcC,IAAgB,IAA4B;AACxE,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAASH,CAAa,GAE5CI,IAASC,EAAY,MAAMH,EAAU,EAAI,GAAG,CAAA,CAAE,GAC9CI,IAAUD,EAAY,MAAMH,EAAU,EAAK,GAAG,CAAA,CAAE,GAChDK,IAAWF,EAAY,MAAMH,EAAU,OAAQ,CAACM,CAAI,GAAG,EAAE;AAE/D,SAAO,EAAE,QAAAP,GAAQ,QAAAG,GAAQ,SAAAE,GAAS,UAAAC,GAAU,WAAAL,EAAA;AAC9C;"}
1
+ {"version":3,"file":"index98.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;"}
package/dist/index99.js CHANGED
@@ -1,17 +1,9 @@
1
- import { useState as a, useCallback as s } from "react";
2
- function p(t = 2e3) {
3
- const [n, r] = a(!1), [l, e] = a(null), c = s(async (i) => {
4
- try {
5
- return await navigator.clipboard.writeText(i), r(!0), e(null), setTimeout(() => r(!1), t), !0;
6
- } catch (o) {
7
- return e(o instanceof Error ? o : new Error("Failed to copy")), r(!1), !1;
8
- }
9
- }, [t]), u = s(() => {
10
- r(!1), e(null);
11
- }, []);
12
- return { copy: c, copied: n, error: l, reset: u };
1
+ import { useState as u, useCallback as s } from "react";
2
+ function p(o = !1) {
3
+ const [n, e] = u(o), t = s(() => e(!0), []), c = s(() => e(!1), []), l = s(() => e((r) => !r), []);
4
+ return { isOpen: n, onOpen: t, onClose: c, onToggle: l, setIsOpen: e };
13
5
  }
14
6
  export {
15
- p as useClipboard
7
+ p as useDisclosure
16
8
  };
17
9
  //# sourceMappingURL=index99.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index99.js","sources":["../src/hooks/useClipboard.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseClipboardReturn {\n copy: (text: string) => Promise<boolean>\n copied: boolean\n error: Error | null\n reset: () => void\n}\n\n/**\n * Hook for copying text to clipboard with success/error state.\n *\n * @param timeout - Duration in ms to show copied state (default: 2000)\n * @returns Object with copy function and state\n *\n * @example\n * const { copy, copied } = useClipboard()\n *\n * <Button onClick={() => copy('Hello!')}>\n * {copied ? 'Copied!' : 'Copy'}\n * </Button>\n */\nexport function useClipboard(timeout = 2000): UseClipboardReturn {\n const [copied, setCopied] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const copy = useCallback(async (text: string): Promise<boolean> => {\n try {\n await navigator.clipboard.writeText(text)\n setCopied(true)\n setError(null)\n\n setTimeout(() => setCopied(false), timeout)\n return true\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to copy'))\n setCopied(false)\n return false\n }\n }, [timeout])\n\n const reset = useCallback(() => {\n setCopied(false)\n setError(null)\n }, [])\n\n return { copy, copied, error, reset }\n}\n"],"names":["useClipboard","timeout","copied","setCopied","useState","error","setError","copy","useCallback","text","err","reset"],"mappings":";AAsBO,SAASA,EAAaC,IAAU,KAA0B;AAC/D,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAE/CG,IAAOC,EAAY,OAAOC,MAAmC;AACjE,QAAI;AACF,mBAAM,UAAU,UAAU,UAAUA,CAAI,GACxCN,EAAU,EAAI,GACdG,EAAS,IAAI,GAEb,WAAW,MAAMH,EAAU,EAAK,GAAGF,CAAO,GACnC;AAAA,IACT,SAASS,GAAK;AACZ,aAAAJ,EAASI,aAAe,QAAQA,IAAM,IAAI,MAAM,gBAAgB,CAAC,GACjEP,EAAU,EAAK,GACR;AAAA,IACT;AAAA,EACF,GAAG,CAACF,CAAO,CAAC,GAENU,IAAQH,EAAY,MAAM;AAC9B,IAAAL,EAAU,EAAK,GACfG,EAAS,IAAI;AAAA,EACf,GAAG,CAAA,CAAE;AAEL,SAAO,EAAE,MAAAC,GAAM,QAAAL,GAAQ,OAAAG,GAAO,OAAAM,EAAA;AAChC;"}
1
+ {"version":3,"file":"index99.js","sources":["../src/hooks/useDisclosure.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseDisclosureReturn {\n isOpen: boolean\n onOpen: () => void\n onClose: () => void\n onToggle: () => void\n setIsOpen: (value: boolean) => void\n}\n\n/**\n * Hook for managing open/close state of modals, drawers, dropdowns, etc.\n *\n * @param defaultIsOpen - Initial open state (default: false)\n * @returns Object with isOpen state and control functions\n *\n * @example\n * const { isOpen, onOpen, onClose } = useDisclosure()\n *\n * <Button onClick={onOpen}>Open Modal</Button>\n * <Modal open={isOpen} onClose={onClose}>Content</Modal>\n */\nexport function useDisclosure(defaultIsOpen = false): UseDisclosureReturn {\n const [isOpen, setIsOpen] = useState(defaultIsOpen)\n\n const onOpen = useCallback(() => setIsOpen(true), [])\n const onClose = useCallback(() => setIsOpen(false), [])\n const onToggle = useCallback(() => setIsOpen(prev => !prev), [])\n\n return { isOpen, onOpen, onClose, onToggle, setIsOpen }\n}\n"],"names":["useDisclosure","defaultIsOpen","isOpen","setIsOpen","useState","onOpen","useCallback","onClose","onToggle","prev"],"mappings":";AAsBO,SAASA,EAAcC,IAAgB,IAA4B;AACxE,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAASH,CAAa,GAE5CI,IAASC,EAAY,MAAMH,EAAU,EAAI,GAAG,CAAA,CAAE,GAC9CI,IAAUD,EAAY,MAAMH,EAAU,EAAK,GAAG,CAAA,CAAE,GAChDK,IAAWF,EAAY,MAAMH,EAAU,OAAQ,CAACM,CAAI,GAAG,EAAE;AAE/D,SAAO,EAAE,QAAAP,GAAQ,QAAAG,GAAQ,SAAAE,GAAS,UAAAC,GAAU,WAAAL,EAAA;AAC9C;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asterui",
3
- "version": "0.12.14",
3
+ "version": "0.12.16",
4
4
  "description": "React UI component library with DaisyUI",
5
5
  "homepage": "https://asterui.com",
6
6
  "repository": {