asterui 0.12.2 → 0.12.3

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 (298) hide show
  1. package/dist/index.d.ts +0 -3
  2. package/dist/index.js +196 -201
  3. package/dist/index.js.map +1 -1
  4. package/dist/index100.js +11 -44
  5. package/dist/index100.js.map +1 -1
  6. package/dist/index101.js +12 -10
  7. package/dist/index101.js.map +1 -1
  8. package/dist/index102.js +7 -14
  9. package/dist/index102.js.map +1 -1
  10. package/dist/index103.js +12 -7
  11. package/dist/index103.js.map +1 -1
  12. package/dist/index104.js +29 -11
  13. package/dist/index104.js.map +1 -1
  14. package/dist/index105.js +16 -29
  15. package/dist/index105.js.map +1 -1
  16. package/dist/index13.js +95 -35
  17. package/dist/index13.js.map +1 -1
  18. package/dist/index14.js +153 -90
  19. package/dist/index14.js.map +1 -1
  20. package/dist/index15.js +146 -154
  21. package/dist/index15.js.map +1 -1
  22. package/dist/index16.js +5 -150
  23. package/dist/index16.js.map +1 -1
  24. package/dist/index17.js +71 -5
  25. package/dist/index17.js.map +1 -1
  26. package/dist/index18.js +17 -71
  27. package/dist/index18.js.map +1 -1
  28. package/dist/index19.js +96 -15
  29. package/dist/index19.js.map +1 -1
  30. package/dist/index20.js +105 -89
  31. package/dist/index20.js.map +1 -1
  32. package/dist/index21.js +177 -107
  33. package/dist/index21.js.map +1 -1
  34. package/dist/index22.js +107 -181
  35. package/dist/index22.js.map +1 -1
  36. package/dist/index23.js +19 -110
  37. package/dist/index23.js.map +1 -1
  38. package/dist/index24.js +41 -17
  39. package/dist/index24.js.map +1 -1
  40. package/dist/index25.js +32 -43
  41. package/dist/index25.js.map +1 -1
  42. package/dist/index26.js +41 -32
  43. package/dist/index26.js.map +1 -1
  44. package/dist/index27.js +12 -41
  45. package/dist/index27.js.map +1 -1
  46. package/dist/index28.js +33 -12
  47. package/dist/index28.js.map +1 -1
  48. package/dist/index29.js +63 -33
  49. package/dist/index29.js.map +1 -1
  50. package/dist/index30.js +77 -60
  51. package/dist/index30.js.map +1 -1
  52. package/dist/index31.js +18 -80
  53. package/dist/index31.js.map +1 -1
  54. package/dist/index32.js +217 -15
  55. package/dist/index32.js.map +1 -1
  56. package/dist/index33.js +1078 -216
  57. package/dist/index33.js.map +1 -1
  58. package/dist/index34.js +17 -1081
  59. package/dist/index34.js.map +1 -1
  60. package/dist/index35.js +121 -17
  61. package/dist/index35.js.map +1 -1
  62. package/dist/index36.js +37 -119
  63. package/dist/index36.js.map +1 -1
  64. package/dist/index37.js +182 -31
  65. package/dist/index37.js.map +1 -1
  66. package/dist/index38.js +97 -191
  67. package/dist/index38.js.map +1 -1
  68. package/dist/index39.js +158 -93
  69. package/dist/index39.js.map +1 -1
  70. package/dist/index40.js +139 -155
  71. package/dist/index40.js.map +1 -1
  72. package/dist/index41.js +15 -146
  73. package/dist/index41.js.map +1 -1
  74. package/dist/index42.js +17 -14
  75. package/dist/index42.js.map +1 -1
  76. package/dist/index43.js +21 -18
  77. package/dist/index43.js.map +1 -1
  78. package/dist/index44.js +116 -18
  79. package/dist/index44.js.map +1 -1
  80. package/dist/index45.js +10 -116
  81. package/dist/index45.js.map +1 -1
  82. package/dist/index46.js +35 -13
  83. package/dist/index46.js.map +1 -1
  84. package/dist/index47.js +10 -35
  85. package/dist/index47.js.map +1 -1
  86. package/dist/index48.js +116 -10
  87. package/dist/index48.js.map +1 -1
  88. package/dist/index49.js +174 -114
  89. package/dist/index49.js.map +1 -1
  90. package/dist/index50.js +136 -165
  91. package/dist/index50.js.map +1 -1
  92. package/dist/index51.js +11 -146
  93. package/dist/index51.js.map +1 -1
  94. package/dist/index52.js +20 -10
  95. package/dist/index52.js.map +1 -1
  96. package/dist/index53.js +14 -22
  97. package/dist/index53.js.map +1 -1
  98. package/dist/index54.js +7 -14
  99. package/dist/index54.js.map +1 -1
  100. package/dist/index55.js +265 -6
  101. package/dist/index55.js.map +1 -1
  102. package/dist/index56.js +17 -266
  103. package/dist/index56.js.map +1 -1
  104. package/dist/index57.js +122 -17
  105. package/dist/index57.js.map +1 -1
  106. package/dist/index58.js +108 -120
  107. package/dist/index58.js.map +1 -1
  108. package/dist/index59.js +167 -107
  109. package/dist/index59.js.map +1 -1
  110. package/dist/index60.js +29 -167
  111. package/dist/index60.js.map +1 -1
  112. package/dist/index61.js +120 -30
  113. package/dist/index61.js.map +1 -1
  114. package/dist/index62.js +80 -116
  115. package/dist/index62.js.map +1 -1
  116. package/dist/index63.js +19 -85
  117. package/dist/index63.js.map +1 -1
  118. package/dist/index64.js +73 -19
  119. package/dist/index64.js.map +1 -1
  120. package/dist/index65.js +54 -71
  121. package/dist/index65.js.map +1 -1
  122. package/dist/index66.js +44 -56
  123. package/dist/index66.js.map +1 -1
  124. package/dist/index67.js +49 -42
  125. package/dist/index67.js.map +1 -1
  126. package/dist/index68.js +62 -52
  127. package/dist/index68.js.map +1 -1
  128. package/dist/index69.js +101 -56
  129. package/dist/index69.js.map +1 -1
  130. package/dist/index70.js +41 -107
  131. package/dist/index70.js.map +1 -1
  132. package/dist/index71.js +68 -41
  133. package/dist/index71.js.map +1 -1
  134. package/dist/index72.js +19 -66
  135. package/dist/index72.js.map +1 -1
  136. package/dist/index73.js +43 -18
  137. package/dist/index73.js.map +1 -1
  138. package/dist/index74.js +132 -44
  139. package/dist/index74.js.map +1 -1
  140. package/dist/index75.js +50 -132
  141. package/dist/index75.js.map +1 -1
  142. package/dist/index76.js +21 -51
  143. package/dist/index76.js.map +1 -1
  144. package/dist/index77.js +31 -22
  145. package/dist/index77.js.map +1 -1
  146. package/dist/index78.js +22 -31
  147. package/dist/index78.js.map +1 -1
  148. package/dist/index79.js +327 -20
  149. package/dist/index79.js.map +1 -1
  150. package/dist/index80.js +50 -323
  151. package/dist/index80.js.map +1 -1
  152. package/dist/index81.js +40 -56
  153. package/dist/index81.js.map +1 -1
  154. package/dist/index82.js +23 -40
  155. package/dist/index82.js.map +1 -1
  156. package/dist/index83.js +93 -21
  157. package/dist/index83.js.map +1 -1
  158. package/dist/index84.js +123 -88
  159. package/dist/index84.js.map +1 -1
  160. package/dist/index85.js +154 -123
  161. package/dist/index85.js.map +1 -1
  162. package/dist/index86.js +63 -159
  163. package/dist/index86.js.map +1 -1
  164. package/dist/index87.js +35 -65
  165. package/dist/index87.js.map +1 -1
  166. package/dist/index88.js +234 -35
  167. package/dist/index88.js.map +1 -1
  168. package/dist/index89.js +31 -231
  169. package/dist/index89.js.map +1 -1
  170. package/dist/index90.js +210 -34
  171. package/dist/index90.js.map +1 -1
  172. package/dist/index91.js +198 -195
  173. package/dist/index91.js.map +1 -1
  174. package/dist/index92.js +241 -159
  175. package/dist/index92.js.map +1 -1
  176. package/dist/index93.js +166 -283
  177. package/dist/index93.js.map +1 -1
  178. package/dist/index94.js +253 -173
  179. package/dist/index94.js.map +1 -1
  180. package/dist/index95.js +14 -258
  181. package/dist/index95.js.map +1 -1
  182. package/dist/index96.js +31 -12
  183. package/dist/index96.js.map +1 -1
  184. package/dist/index97.js +5 -32
  185. package/dist/index97.js.map +1 -1
  186. package/dist/index98.js +13 -5
  187. package/dist/index98.js.map +1 -1
  188. package/dist/index99.js +43 -11
  189. package/dist/index99.js.map +1 -1
  190. package/package.json +11 -5
  191. package/dist/components/Calendar.d.ts +0 -23
  192. package/dist/index.css +0 -1
  193. package/dist/index106.js +0 -21
  194. package/dist/index106.js.map +0 -1
  195. package/dist/index107.js +0 -177
  196. package/dist/index107.js.map +0 -1
  197. package/dist/index109.js +0 -10796
  198. package/dist/index109.js.map +0 -1
  199. package/dist/index110.js +0 -8
  200. package/dist/index110.js.map +0 -1
  201. package/dist/index111.js +0 -45
  202. package/dist/index111.js.map +0 -1
  203. package/dist/index112.js +0 -5
  204. package/dist/index112.js.map +0 -1
  205. package/dist/index113.js +0 -10
  206. package/dist/index113.js.map +0 -1
  207. package/dist/index114.js +0 -155
  208. package/dist/index114.js.map +0 -1
  209. package/dist/index115.js +0 -33
  210. package/dist/index115.js.map +0 -1
  211. package/dist/index116.js +0 -33
  212. package/dist/index116.js.map +0 -1
  213. package/dist/index117.js +0 -5
  214. package/dist/index117.js.map +0 -1
  215. package/dist/index118.js +0 -75
  216. package/dist/index118.js.map +0 -1
  217. package/dist/index119.js +0 -42
  218. package/dist/index119.js.map +0 -1
  219. package/dist/index120.js +0 -29
  220. package/dist/index120.js.map +0 -1
  221. package/dist/index121.js +0 -24
  222. package/dist/index121.js.map +0 -1
  223. package/dist/index122.js +0 -27
  224. package/dist/index122.js.map +0 -1
  225. package/dist/index123.js +0 -23
  226. package/dist/index123.js.map +0 -1
  227. package/dist/index124.js +0 -103
  228. package/dist/index124.js.map +0 -1
  229. package/dist/index125.js +0 -363
  230. package/dist/index125.js.map +0 -1
  231. package/dist/index126.js +0 -28
  232. package/dist/index126.js.map +0 -1
  233. package/dist/index127.js +0 -76
  234. package/dist/index127.js.map +0 -1
  235. package/dist/index128.js +0 -19
  236. package/dist/index128.js.map +0 -1
  237. package/dist/index129.js +0 -69
  238. package/dist/index129.js.map +0 -1
  239. package/dist/index130.js +0 -147
  240. package/dist/index130.js.map +0 -1
  241. package/dist/index131.js +0 -5
  242. package/dist/index131.js.map +0 -1
  243. package/dist/index132.js +0 -59
  244. package/dist/index132.js.map +0 -1
  245. package/dist/index133.js +0 -5
  246. package/dist/index133.js.map +0 -1
  247. package/dist/index134.js +0 -5
  248. package/dist/index134.js.map +0 -1
  249. package/dist/index135.js +0 -5
  250. package/dist/index135.js.map +0 -1
  251. package/dist/index136.js +0 -5
  252. package/dist/index136.js.map +0 -1
  253. package/dist/index137.js +0 -5
  254. package/dist/index137.js.map +0 -1
  255. package/dist/index138.js +0 -5
  256. package/dist/index138.js.map +0 -1
  257. package/dist/index139.js +0 -5
  258. package/dist/index139.js.map +0 -1
  259. package/dist/index140.js +0 -5
  260. package/dist/index140.js.map +0 -1
  261. package/dist/index141.js +0 -35
  262. package/dist/index141.js.map +0 -1
  263. package/dist/index142.js +0 -5
  264. package/dist/index142.js.map +0 -1
  265. package/dist/index143.js +0 -11
  266. package/dist/index143.js.map +0 -1
  267. package/dist/index144.js +0 -5
  268. package/dist/index144.js.map +0 -1
  269. package/dist/index145.js +0 -5
  270. package/dist/index145.js.map +0 -1
  271. package/dist/index146.js +0 -24
  272. package/dist/index146.js.map +0 -1
  273. package/dist/index147.js +0 -5
  274. package/dist/index147.js.map +0 -1
  275. package/dist/index148.js +0 -27
  276. package/dist/index148.js.map +0 -1
  277. package/dist/index149.js +0 -74
  278. package/dist/index149.js.map +0 -1
  279. package/dist/index150.js +0 -24
  280. package/dist/index150.js.map +0 -1
  281. package/dist/index151.js +0 -37
  282. package/dist/index151.js.map +0 -1
  283. package/dist/index152.js +0 -73
  284. package/dist/index152.js.map +0 -1
  285. package/dist/index153.js +0 -5
  286. package/dist/index153.js.map +0 -1
  287. package/dist/index154.js +0 -25
  288. package/dist/index154.js.map +0 -1
  289. package/dist/index155.js +0 -5
  290. package/dist/index155.js.map +0 -1
  291. package/dist/index156.js +0 -5
  292. package/dist/index156.js.map +0 -1
  293. package/dist/index157.js +0 -5
  294. package/dist/index157.js.map +0 -1
  295. package/dist/index158.js +0 -5
  296. package/dist/index158.js.map +0 -1
  297. package/dist/index159.js +0 -7
  298. package/dist/index159.js.map +0 -1
package/dist/index95.js CHANGED
@@ -1,261 +1,17 @@
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";
1
+ import { jsx as v, Fragment as A } from "react/jsx-runtime";
2
+ import { useBreakpoint as m } from "./index96.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
+ }
257
13
  export {
258
- K as Upload,
259
- K as default
14
+ p as Hide,
15
+ h as Show
260
16
  };
261
17
  //# sourceMappingURL=index95.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index95.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;AAA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A,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;"}
1
+ {"version":3,"file":"index95.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/index96.js CHANGED
@@ -1,17 +1,36 @@
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;
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";
7
11
  }
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
+ 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
+ };
12
32
  }
13
33
  export {
14
- p as Hide,
15
- h as Show
34
+ m as useBreakpoint
16
35
  };
17
36
  //# 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","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 {"version":3,"file":"index96.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/index97.js CHANGED
@@ -1,36 +1,9 @@
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
- };
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 };
32
5
  }
33
6
  export {
34
- m as useBreakpoint
7
+ p as useDisclosure
35
8
  };
36
9
  //# 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/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/dist/index98.js CHANGED
@@ -1,9 +1,17 @@
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 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 };
5
13
  }
6
14
  export {
7
- p as useDisclosure
15
+ p as useClipboard
8
16
  };
9
17
  //# 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/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;"}
package/dist/index99.js CHANGED
@@ -1,17 +1,49 @@
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) => {
1
+ import { useState as u, useCallback as c, useEffect as f } from "react";
2
+ function S(o, t) {
3
+ const [s, n] = u(() => {
4
+ if (typeof window > "u")
5
+ return t;
4
6
  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;
7
+ const e = window.localStorage.getItem(o);
8
+ return e ? JSON.parse(e) : t;
9
+ } catch {
10
+ return t;
8
11
  }
9
- }, [t]), u = s(() => {
10
- r(!1), e(null);
11
- }, []);
12
- return { copy: c, copied: n, error: l, reset: u };
12
+ }), d = c(
13
+ (e) => {
14
+ n((r) => {
15
+ const a = e instanceof Function ? e(r) : e;
16
+ if (typeof window < "u")
17
+ try {
18
+ window.localStorage.setItem(o, JSON.stringify(a));
19
+ } catch (l) {
20
+ console.warn(`Failed to save to localStorage key "${o}":`, l);
21
+ }
22
+ return a;
23
+ });
24
+ },
25
+ [o]
26
+ ), w = c(() => {
27
+ if (typeof window < "u")
28
+ try {
29
+ window.localStorage.removeItem(o);
30
+ } catch (e) {
31
+ console.warn(`Failed to remove localStorage key "${o}":`, e);
32
+ }
33
+ n(t);
34
+ }, [o, t]);
35
+ return f(() => {
36
+ const e = (r) => {
37
+ if (r.key === o && r.newValue !== null)
38
+ try {
39
+ n(JSON.parse(r.newValue));
40
+ } catch {
41
+ }
42
+ };
43
+ return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
44
+ }, [o]), [s, d, w];
13
45
  }
14
46
  export {
15
- p as useClipboard
47
+ S as useLocalStorage
16
48
  };
17
49
  //# 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/useLocalStorage.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react'\n\n/**\n * Hook for persisting state to localStorage.\n *\n * @param key - localStorage key\n * @param initialValue - Initial value if key doesn't exist\n * @returns [value, setValue, removeValue] tuple\n *\n * @example\n * const [theme, setTheme] = useLocalStorage('theme', 'light')\n * const [user, setUser, removeUser] = useLocalStorage('user', null)\n */\nexport function useLocalStorage<T>(\n key: string,\n initialValue: T\n): [T, (value: T | ((prev: T) => T)) => void, () => void] {\n // Get initial value from localStorage or use default\n const [storedValue, setStoredValue] = useState<T>(() => {\n if (typeof window === 'undefined') {\n return initialValue\n }\n\n try {\n const item = window.localStorage.getItem(key)\n return item ? (JSON.parse(item) as T) : initialValue\n } catch {\n return initialValue\n }\n })\n\n // Update localStorage when value changes\n const setValue = useCallback(\n (value: T | ((prev: T) => T)) => {\n setStoredValue(prev => {\n const valueToStore = value instanceof Function ? value(prev) : value\n\n if (typeof window !== 'undefined') {\n try {\n window.localStorage.setItem(key, JSON.stringify(valueToStore))\n } catch (error) {\n console.warn(`Failed to save to localStorage key \"${key}\":`, error)\n }\n }\n\n return valueToStore\n })\n },\n [key]\n )\n\n // Remove from localStorage\n const removeValue = useCallback(() => {\n if (typeof window !== 'undefined') {\n try {\n window.localStorage.removeItem(key)\n } catch (error) {\n console.warn(`Failed to remove localStorage key \"${key}\":`, error)\n }\n }\n setStoredValue(initialValue)\n }, [key, initialValue])\n\n // Sync with other tabs/windows\n useEffect(() => {\n const handleStorageChange = (e: StorageEvent) => {\n if (e.key === key && e.newValue !== null) {\n try {\n setStoredValue(JSON.parse(e.newValue) as T)\n } catch {\n // Ignore parse errors\n }\n }\n }\n\n window.addEventListener('storage', handleStorageChange)\n return () => window.removeEventListener('storage', handleStorageChange)\n }, [key])\n\n return [storedValue, setValue, removeValue]\n}\n"],"names":["useLocalStorage","key","initialValue","storedValue","setStoredValue","useState","item","setValue","useCallback","value","prev","valueToStore","error","removeValue","useEffect","handleStorageChange","e"],"mappings":";AAaO,SAASA,EACdC,GACAC,GACwD;AAExD,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAY,MAAM;AACtD,QAAI,OAAO,SAAW;AACpB,aAAOH;AAGT,QAAI;AACF,YAAMI,IAAO,OAAO,aAAa,QAAQL,CAAG;AAC5C,aAAOK,IAAQ,KAAK,MAAMA,CAAI,IAAUJ;AAAA,IAC1C,QAAQ;AACN,aAAOA;AAAA,IACT;AAAA,EACF,CAAC,GAGKK,IAAWC;AAAA,IACf,CAACC,MAAgC;AAC/B,MAAAL,EAAe,CAAAM,MAAQ;AACrB,cAAMC,IAAeF,aAAiB,WAAWA,EAAMC,CAAI,IAAID;AAE/D,YAAI,OAAO,SAAW;AACpB,cAAI;AACF,mBAAO,aAAa,QAAQR,GAAK,KAAK,UAAUU,CAAY,CAAC;AAAA,UAC/D,SAASC,GAAO;AACd,oBAAQ,KAAK,uCAAuCX,CAAG,MAAMW,CAAK;AAAA,UACpE;AAGF,eAAOD;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,CAACV,CAAG;AAAA,EAAA,GAIAY,IAAcL,EAAY,MAAM;AACpC,QAAI,OAAO,SAAW;AACpB,UAAI;AACF,eAAO,aAAa,WAAWP,CAAG;AAAA,MACpC,SAASW,GAAO;AACd,gBAAQ,KAAK,sCAAsCX,CAAG,MAAMW,CAAK;AAAA,MACnE;AAEF,IAAAR,EAAeF,CAAY;AAAA,EAC7B,GAAG,CAACD,GAAKC,CAAY,CAAC;AAGtB,SAAAY,EAAU,MAAM;AACd,UAAMC,IAAsB,CAACC,MAAoB;AAC/C,UAAIA,EAAE,QAAQf,KAAOe,EAAE,aAAa;AAClC,YAAI;AACF,UAAAZ,EAAe,KAAK,MAAMY,EAAE,QAAQ,CAAM;AAAA,QAC5C,QAAQ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