@mcistudio/unoui-vue 1.2.6 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/chunks/IconPicker-B0EhOCL1.js +632 -0
  2. package/dist/chunks/IconPicker-B0EhOCL1.js.map +1 -0
  3. package/dist/chunks/{Table-M8DquYXh.js → Table-DFBQntI1.js} +3 -2
  4. package/dist/chunks/Table-DFBQntI1.js.map +1 -0
  5. package/dist/chunks/drawer-BgGY0UFF.js +197 -0
  6. package/dist/chunks/drawer-BgGY0UFF.js.map +1 -0
  7. package/dist/chunks/{input-FN9FbBR8.js → input-CiYVpf72.js} +5 -5
  8. package/dist/chunks/input-CiYVpf72.js.map +1 -0
  9. package/dist/chunks/internal-drag-B2-9vftX.js +29 -0
  10. package/dist/chunks/internal-drag-B2-9vftX.js.map +1 -0
  11. package/dist/chunks/modal-BqB5SsLw.js +82 -0
  12. package/dist/chunks/modal-BqB5SsLw.js.map +1 -0
  13. package/dist/chunks/{pagination-DCJuheFj.js → pagination-zi5YKmBI.js} +2 -2
  14. package/dist/chunks/{pagination-DCJuheFj.js.map → pagination-zi5YKmBI.js.map} +1 -1
  15. package/dist/chunks/{slider-Z03Wx_8m.js → slider-DoS0hURd.js} +3 -3
  16. package/dist/chunks/slider-DoS0hURd.js.map +1 -0
  17. package/dist/drawer/index.js +1 -1
  18. package/dist/iconpicker/IconPicker.vue.d.ts +43 -0
  19. package/dist/iconpicker/index.d.ts +27 -0
  20. package/dist/iconpicker/index.js +2 -0
  21. package/dist/iconpicker/svg-icon.d.ts +23 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +20 -19
  24. package/dist/input/index.js +1 -1
  25. package/dist/modal/index.js +1 -1
  26. package/dist/pagination/index.js +1 -1
  27. package/dist/slider/index.js +1 -1
  28. package/dist/style.css +1 -1
  29. package/dist/tab/Tabs.vue.d.ts +1 -1
  30. package/dist/table/index.js +1 -1
  31. package/dist/utils/internal-drag.d.ts +7 -0
  32. package/package.json +2 -1
  33. package/dist/chunks/Table-M8DquYXh.js.map +0 -1
  34. package/dist/chunks/drawer-C3JZ28Xo.js +0 -193
  35. package/dist/chunks/drawer-C3JZ28Xo.js.map +0 -1
  36. package/dist/chunks/input-FN9FbBR8.js.map +0 -1
  37. package/dist/chunks/modal-D6l1iIvE.js +0 -81
  38. package/dist/chunks/modal-D6l1iIvE.js.map +0 -1
  39. package/dist/chunks/slider-Z03Wx_8m.js.map +0 -1
@@ -0,0 +1,632 @@
1
+ import { r as e } from "./button-BvxNx3_0.js";
2
+ import { l as t } from "./input-CiYVpf72.js";
3
+ import { t as n } from "./modal-BqB5SsLw.js";
4
+ import { n as r } from "./message-xPfuG0EX.js";
5
+ import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, nextTick as ee, normalizeClass as te, normalizeStyle as ne, onBeforeUnmount as re, onMounted as ie, openBlock as p, ref as m, renderList as ae, toDisplayString as h, unref as g, watch as _, withCtx as v } from "vue";
6
+ import { Icon as oe, addAPIProvider as se } from "@iconify/vue";
7
+ //#region src/iconpicker/svg-icon.ts
8
+ var ce = /^[a-z0-9]+(?:-[a-z0-9]+)*:[a-z0-9]+(?:-[a-z0-9]+)*$/i, y = "i-", b = 1024 * 1024, x = /* @__PURE__ */ new Set([
9
+ "script",
10
+ "foreignobject",
11
+ "iframe",
12
+ "object",
13
+ "embed"
14
+ ]), S = /* @__PURE__ */ new Set([
15
+ "metadata",
16
+ "title",
17
+ "desc"
18
+ ]), C = /* @__PURE__ */ new Set([
19
+ "version",
20
+ "xml:space",
21
+ "enable-background",
22
+ "data-name"
23
+ ]), w = [
24
+ "fill",
25
+ "stroke",
26
+ "stop-color",
27
+ "flood-color",
28
+ "lighting-color"
29
+ ];
30
+ function le(e) {
31
+ let t = e.trim();
32
+ return t.toLowerCase().startsWith(y) ? t.slice(2) : t;
33
+ }
34
+ function T(e, t = "unocss") {
35
+ return t === "unocss" ? `${y}${e}` : e;
36
+ }
37
+ function ue(e) {
38
+ return ce.test(le(e));
39
+ }
40
+ function de(e) {
41
+ return /^\s*(?:<\?xml[^>]*\?>\s*|<!--[\s\S]*?-->\s*)*<svg(?:\s|>)/i.test(e);
42
+ }
43
+ function E(e) {
44
+ let t = new DOMParser().parseFromString(e, "image/svg+xml");
45
+ if (t.querySelector("parsererror") || t.documentElement.localName.toLowerCase() !== "svg") throw Error("文件不是有效的 SVG");
46
+ return t;
47
+ }
48
+ function D(e) {
49
+ return new XMLSerializer().serializeToString(e.documentElement);
50
+ }
51
+ function fe(e) {
52
+ if (new TextEncoder().encode(e).byteLength > b) throw Error("SVG 文件不能超过 1 MB");
53
+ let t = E(e);
54
+ for (let e of t.querySelectorAll("*")) {
55
+ if (x.has(e.localName.toLowerCase())) throw Error("SVG 包含不支持的嵌入内容");
56
+ for (let t of Array.from(e.attributes)) {
57
+ let e = t.name.toLowerCase(), n = t.value.trim();
58
+ if (e.startsWith("on")) throw Error("SVG 不能包含事件脚本");
59
+ if ((e === "href" || e === "xlink:href") && n && !n.startsWith("#") || /url\s*\(/i.test(n) && !/url\s*\(\s*['"]?#/i.test(n)) throw Error("SVG 不能引用外部资源");
60
+ }
61
+ if (e.localName.toLowerCase() === "style" && /@import|url\s*\(\s*(?!['"]?#)/i.test(e.textContent || "")) throw Error("SVG 样式不能引用外部资源");
62
+ }
63
+ return t.documentElement.setAttribute("xmlns", "http://www.w3.org/2000/svg"), D(t);
64
+ }
65
+ function pe(e) {
66
+ let t = E(fe(e)), n = t.documentElement, r = t.createTreeWalker(n, 128), i = [];
67
+ for (; r.nextNode();) i.push(r.currentNode);
68
+ for (let e of i) e.remove();
69
+ for (let e of Array.from(t.querySelectorAll("*"))) {
70
+ if (S.has(e.localName.toLowerCase())) {
71
+ e.remove();
72
+ continue;
73
+ }
74
+ for (let t of Array.from(e.attributes)) C.has(t.name.toLowerCase()) && e.removeAttribute(t.name);
75
+ for (let t of w) {
76
+ let n = e.getAttribute(t)?.trim();
77
+ n && n !== "none" && !/^url\s*\(/i.test(n) && e.setAttribute(t, "currentColor");
78
+ let r = e.style, i = r?.getPropertyValue(t).trim();
79
+ i && (e.setAttribute(t, i === "none" || /^url\s*\(/i.test(i) ? i : "currentColor"), r.removeProperty(t));
80
+ }
81
+ e.removeAttribute("color");
82
+ let t = e.style;
83
+ t?.removeProperty("color"), t && !t.cssText.trim() && e.removeAttribute("style");
84
+ }
85
+ if (!n.getAttribute("viewBox")) {
86
+ let e = Number.parseFloat(n.getAttribute("width") || ""), t = Number.parseFloat(n.getAttribute("height") || "");
87
+ Number.isFinite(e) && Number.isFinite(t) && e > 0 && t > 0 && n.setAttribute("viewBox", `0 0 ${e} ${t}`);
88
+ }
89
+ return n.getAttribute("viewBox") && (n.removeAttribute("width"), n.removeAttribute("height")), n.setAttribute("fill", "currentColor"), n.setAttribute("xmlns", "http://www.w3.org/2000/svg"), D(t);
90
+ }
91
+ function O(e) {
92
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`;
93
+ }
94
+ //#endregion
95
+ //#region src/iconpicker/IconPicker.vue?vue&type=script&setup=true&lang.ts
96
+ var me = {
97
+ "data-ui-icon-picker": "true",
98
+ class: "min-w-0"
99
+ }, he = {
100
+ class: "flex flex-wrap items-center gap-1",
101
+ "data-icon-picker-actions": ""
102
+ }, ge = ["innerHTML"], _e = {
103
+ "data-icon-picker-panel": "true",
104
+ class: "grid min-h-0 gap-4 p-4 md:h-full md:grid-cols-[260px_minmax(0,1fr)]"
105
+ }, ve = { class: "flex h-52 min-h-0 flex-col overflow-hidden rounded-md border border-medium bg-secondary md:h-auto" }, ye = { class: "border-b border-medium p-3" }, be = { class: "min-h-0 flex-1 overflow-auto p-2" }, xe = ["onClick"], Se = { class: "min-w-0" }, Ce = { class: "block truncate text-sm font-600" }, we = { class: "block truncate text-xs opacity-70" }, Te = { class: "shrink-0 text-xs opacity-70" }, Ee = {
106
+ key: 0,
107
+ class: "grid justify-items-center gap-3 px-3 py-6 text-center text-sm text-tertiary"
108
+ }, De = {
109
+ key: 1,
110
+ class: "px-3 py-6 text-center text-sm text-tertiary"
111
+ }, Oe = { class: "flex h-[26rem] min-h-0 flex-col overflow-hidden rounded-md border border-medium bg-primary md:h-auto" }, ke = { class: "grid grid-cols-1 items-start gap-3 border-b border-medium p-3 sm:grid-cols-[minmax(0,1fr)_minmax(180px,280px)]" }, Ae = { class: "min-w-0" }, je = { class: "truncate font-700 text-primary" }, Me = { class: "mt-1 flex min-h-4 items-center gap-1.5 text-xs text-tertiary" }, Ne = {
112
+ key: 0,
113
+ class: "i-lucide:loader-circle size-3.5 animate-spin text-brand",
114
+ "aria-label": "加载中"
115
+ }, Pe = {
116
+ key: 0,
117
+ class: "flex h-full items-center justify-center",
118
+ "aria-busy": "true"
119
+ }, Fe = {
120
+ key: 1,
121
+ class: "flex h-full flex-col items-center justify-center text-center text-sm text-tertiary"
122
+ }, Ie = ["title", "onClick"], Le = ["innerHTML"], Re = { class: "w-full truncate text-center text-xs" }, ze = {
123
+ key: 3,
124
+ class: "flex h-full flex-col items-center justify-center gap-2 text-center text-sm text-tertiary"
125
+ }, Be = {
126
+ key: 0,
127
+ class: "flex min-w-0 items-center gap-2"
128
+ }, Ve = {
129
+ key: 0,
130
+ class: "flex min-w-0 items-center gap-1.5 text-xs text-secondary"
131
+ }, He = ["innerHTML"], Ue = { class: "truncate" }, We = { class: "flex items-center gap-3" }, Ge = "https://api.iconify.design", k = "__all__", A = "__custom__", Ke = 8, j = 24, qe = 3, Je = 999, Ye = 300, M = /* @__PURE__ */ f({
132
+ __name: "IconPicker",
133
+ props: {
134
+ modelValue: { default: "" },
135
+ defaultValue: { default: "" },
136
+ size: { default: "md" },
137
+ disabled: {
138
+ type: Boolean,
139
+ default: !1
140
+ },
141
+ allowSvgUpload: {
142
+ type: Boolean,
143
+ default: !1
144
+ },
145
+ svgIcons: { default: () => [] },
146
+ valueFormat: { default: "unocss" },
147
+ apiBase: { default: "" },
148
+ title: { default: "选择图标" },
149
+ modalZIndex: { default: void 0 }
150
+ },
151
+ emits: ["update:modelValue", "upload-svg"],
152
+ setup(f, { emit: ce }) {
153
+ let y = f, b = ce, x = m(!1), S = m(!1), C = m(!1), w = m([]), E = m(""), D = m(""), O = m(""), M = m(k), N = m(y.modelValue), P = m(null), F = m([]), I = m([]), L = m(0), R = m(""), z = m(null), Xe = m(null), B = m([]), Ze = m(0), Qe = m(0), V = m(0), H = null, U = 0, $e, W = !1, et = /* @__PURE__ */ new Map(), tt = /* @__PURE__ */ new Map(), nt = /* @__PURE__ */ new Set(), G = a(() => (y.apiBase || Ge).replace(/\/+$/, "")), rt = a(() => ({
154
+ sm: "size-4",
155
+ md: "size-5",
156
+ lg: "size-6"
157
+ })[y.size]);
158
+ function it(e) {
159
+ let t = tt.get(e);
160
+ if (t !== void 0) return t;
161
+ let n = "";
162
+ try {
163
+ n = fe(e);
164
+ } catch {
165
+ n = "";
166
+ }
167
+ return tt.size > 200 && tt.clear(), tt.set(e, n), n;
168
+ }
169
+ let at = a(() => {
170
+ let e = new Map(y.svgIcons.map((e) => [e.name, e]));
171
+ for (let t of B.value) e.set(t.name, t);
172
+ return [...e.values()];
173
+ }), K = a(() => at.value.flatMap((e) => {
174
+ let t = it(e.svg);
175
+ return t ? [{
176
+ key: `svg:${t}`,
177
+ value: t,
178
+ label: e.name,
179
+ markup: t
180
+ }] : [];
181
+ })), q = a(() => {
182
+ let e = N.value;
183
+ if (!e) return null;
184
+ if (de(e)) {
185
+ let t = it(e);
186
+ return t ? K.value.find((e) => e.key === `svg:${t}`) ?? {
187
+ key: `svg:${t}`,
188
+ value: t,
189
+ label: "自定义图标",
190
+ markup: t
191
+ } : null;
192
+ }
193
+ let t = le(e);
194
+ return ue(t) ? {
195
+ key: t,
196
+ value: T(t, y.valueFormat),
197
+ label: t.split(":").slice(1).join(":"),
198
+ iconify: t
199
+ } : null;
200
+ }), ot = a(() => q.value?.key ?? ""), st = a(() => {
201
+ let e = B.value[0];
202
+ if (!e) return null;
203
+ let t = it(e.svg);
204
+ return t ? {
205
+ key: `svg:${t}`,
206
+ value: t,
207
+ label: e.name,
208
+ markup: t
209
+ } : null;
210
+ }), J = a(() => w.value.filter((e) => !e.hidden)), ct = a(() => K.value.length ? {
211
+ prefix: A,
212
+ name: "自定义图标",
213
+ total: K.value.length,
214
+ category: "自定义"
215
+ } : null), lt = a(() => ({
216
+ prefix: k,
217
+ name: "全部图标",
218
+ total: K.value.length + J.value.reduce((e, t) => e + t.total, 0),
219
+ category: "全部"
220
+ })), ut = a(() => {
221
+ let e = D.value.trim().toLowerCase(), t = (ct.value ? [ct.value, ...J.value] : J.value).filter((t) => !e || t.name.toLowerCase().includes(e) || t.prefix.toLowerCase().includes(e) || t.category?.toLowerCase().includes(e));
222
+ return !e || lt.value.name.toLowerCase().includes(e) || "all".includes(e) ? [lt.value, ...t] : t;
223
+ }), dt = a(() => w.value.find((e) => e.prefix === M.value)), Y = a(() => M.value === k), ft = a(() => M.value === A);
224
+ function pt(e) {
225
+ return e === k ? "all" : e === A ? "custom" : e;
226
+ }
227
+ let X = a(() => O.value.trim().toLowerCase()), mt = a(() => !!X.value), ht = a(() => Y.value ? I.value : ft.value ? K.value : F.value), Z = a(() => {
228
+ let e = X.value;
229
+ return !e || Y.value ? ht.value : ht.value.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e));
230
+ }), gt = a(() => Y.value ? lt.value.name : ft.value ? ct.value?.name || "自定义图标" : dt.value?.name || P.value?.title || M.value), _t = a(() => {
231
+ if (Y.value) {
232
+ if (!mt.value) return `共 ${lt.value.total} 个图标`;
233
+ if (!L.value) return C.value ? "正在搜索…" : "共 0 个图标";
234
+ let e = L.value > I.value.length ? `,显示前 ${I.value.length} 个` : "";
235
+ return `找到 ${L.value} 个图标${e}`;
236
+ }
237
+ return `${mt.value ? "找到" : "共"} ${Z.value.length} 个图标`;
238
+ }), vt = a(() => Y.value && !mt.value ? "在上方输入关键字,搜索所有图标集" : "没有匹配的图标"), yt = a(() => Y.value ? "搜索全部图标集" : `在 ${gt.value} 中搜索`), bt = a(() => {
239
+ let e = q.value;
240
+ return e ? e.markup ? `自定义 SVG:${e.label}` : e.iconify || y.title : y.title;
241
+ }), xt = a(() => q.value ? `当前图标:${bt.value}` : y.title), Q = a(() => Math.max(1, Math.floor((Ze.value + Ke) / 92))), St = a(() => Math.ceil(Z.value.length / Q.value)), Ct = a(() => Math.max(0, Math.floor(V.value / 88) - qe)), wt = a(() => Math.min(St.value, Math.ceil((V.value + Qe.value) / 88) + qe)), Tt = a(() => Z.value.slice(Ct.value * Q.value, wt.value * Q.value)), Et = a(() => St.value ? St.value * 88 - Ke : 0), Dt = a(() => ({
242
+ gridTemplateColumns: `repeat(${Q.value}, minmax(0, 1fr))`,
243
+ transform: `translateY(${Ct.value * 88}px)`
244
+ }));
245
+ _(() => y.modelValue, (e) => {
246
+ N.value = e, B.value = [];
247
+ }), _(x, (e) => {
248
+ e && (N.value = y.modelValue, B.value = [], ft.value && !K.value.length && (M.value = k), Ot(), At(), ee(() => {
249
+ qt(), $();
250
+ }));
251
+ }), _(X, () => {
252
+ $(), X.value && (W = !0), Y.value && (clearTimeout($e), $e = setTimeout(() => {
253
+ x.value && Y.value && Ft();
254
+ }, Ye));
255
+ }), _(Q, () => $()), ie(() => qt()), re(() => {
256
+ clearTimeout($e), H?.disconnect(), H = null;
257
+ });
258
+ function Ot() {
259
+ let e = G.value;
260
+ e === Ge || nt.has(e) || se("", { resources: [e] }) && nt.add(e);
261
+ }
262
+ function kt() {
263
+ y.disabled || (x.value = !0);
264
+ }
265
+ async function At() {
266
+ await jt(), x.value && (!W && Y.value && !mt.value && J.value.length && (M.value = J.value[0].prefix, W = !0), await Nt());
267
+ }
268
+ async function jt() {
269
+ if (w.value.length || S.value) return w.value;
270
+ S.value = !0, E.value = "";
271
+ try {
272
+ let e = await fetch(`${G.value}/collections`);
273
+ if (!e.ok) throw Error(`HTTP ${e.status}`);
274
+ let t = await e.json();
275
+ w.value = Object.entries(t).map(([e, t]) => ({
276
+ prefix: e,
277
+ ...t
278
+ })).sort((e, t) => (e.category || "").localeCompare(t.category || "") || e.name.localeCompare(t.name));
279
+ } catch {
280
+ E.value = "图标集列表加载失败", r.error("图标集列表加载失败,请检查网络或 API 地址");
281
+ } finally {
282
+ S.value = !1;
283
+ }
284
+ return w.value;
285
+ }
286
+ async function Mt() {
287
+ E.value = "", await jt(), x.value && await Nt();
288
+ }
289
+ async function Nt() {
290
+ if (Y.value) {
291
+ await Ft();
292
+ return;
293
+ }
294
+ if (ft.value) {
295
+ P.value = null, F.value = [], R.value = "", C.value = !1, $();
296
+ return;
297
+ }
298
+ await Pt(M.value);
299
+ }
300
+ async function Pt(e) {
301
+ let t = U + 1;
302
+ U = t, C.value = !0, R.value = "";
303
+ try {
304
+ let n = await Yt(e);
305
+ if (t !== U) return;
306
+ P.value = n, F.value = Xt(n, e), $();
307
+ } catch {
308
+ if (t !== U) return;
309
+ P.value = null, F.value = [], R.value = "图标加载失败,请稍后重试或检查 API 地址";
310
+ } finally {
311
+ t === U && (C.value = !1);
312
+ }
313
+ }
314
+ async function Ft() {
315
+ let e = X.value, t = U + 1;
316
+ if (U = t, R.value = "", $(), !e) {
317
+ I.value = [], L.value = 0, C.value = !1;
318
+ return;
319
+ }
320
+ C.value = !0;
321
+ try {
322
+ let n = await fetch(`${G.value}/search?query=${encodeURIComponent(e)}&limit=${Je}`);
323
+ if (!n.ok) throw Error(`HTTP ${n.status}`);
324
+ let r = await n.json();
325
+ if (t !== U) return;
326
+ I.value = (r.icons ?? []).map((e) => ({
327
+ key: e,
328
+ value: T(e, y.valueFormat),
329
+ label: e.split(":").slice(1).join(":"),
330
+ iconify: e
331
+ })), L.value = r.total ?? I.value.length;
332
+ } catch {
333
+ if (t !== U) return;
334
+ I.value = [], L.value = 0, R.value = "搜索失败,请稍后重试或检查 API 地址";
335
+ } finally {
336
+ t === U && (C.value = !1);
337
+ }
338
+ }
339
+ function It(e) {
340
+ e !== M.value && (W = !0, M.value = e, O.value = "", R.value = "", Nt());
341
+ }
342
+ function Lt() {
343
+ Nt();
344
+ }
345
+ function Rt(e) {
346
+ N.value = e.value;
347
+ }
348
+ function zt() {
349
+ N.value = "", b("update:modelValue", "");
350
+ }
351
+ function Bt() {
352
+ Xe.value?.click();
353
+ }
354
+ function Vt(e) {
355
+ return e.name.replace(/\.svg$/i, "");
356
+ }
357
+ async function Ht(e) {
358
+ let t = e.currentTarget, n = Array.from(t.files ?? []);
359
+ if (t.value = "", !n.length || !y.allowSvgUpload) return;
360
+ let i = await Promise.allSettled(n.map(async (e) => {
361
+ let t = Vt(e);
362
+ if (!t.trim()) throw Error(`${e.name || "未命名文件"}缺少有效的图标名`);
363
+ return {
364
+ name: t,
365
+ svg: pe(await e.text())
366
+ };
367
+ })), a = i.flatMap((e) => e.status === "fulfilled" ? [e.value] : []), o = i.filter((e) => e.status === "rejected");
368
+ if (o.length) {
369
+ let e = o[0]?.reason, t = e instanceof Error ? e.message : "SVG 读取失败";
370
+ r.error(`${o.length} 个 SVG 上传失败:${t}`);
371
+ }
372
+ if (!a.length) return;
373
+ let s = new Map(B.value.map((e) => [e.name, e]));
374
+ for (let e of a) s.set(e.name, e);
375
+ B.value = [...s.values()];
376
+ let c = K.value.find((e) => e.label === a[0].name);
377
+ c && (N.value = c.value), M.value = A, O.value = "", P.value = null, F.value = [], R.value = "", C.value = !1, $(), ee(Gt);
378
+ }
379
+ function Ut() {
380
+ y.defaultValue && (N.value = y.defaultValue, b("update:modelValue", y.defaultValue));
381
+ }
382
+ function Wt() {
383
+ if (q.value) {
384
+ if (B.value.length) {
385
+ b("upload-svg", {
386
+ icons: at.value,
387
+ value: N.value
388
+ }), B.value = [], b("update:modelValue", N.value), x.value = !1;
389
+ return;
390
+ }
391
+ b("update:modelValue", N.value), x.value = !1;
392
+ }
393
+ }
394
+ function Gt() {
395
+ let e = z.value, t = Z.value.findIndex((e) => e.key === ot.value);
396
+ !e || t < 0 || (e.scrollTop = Math.floor(t / Q.value) * 88, V.value = e.scrollTop);
397
+ }
398
+ function Kt(e) {
399
+ V.value = e.currentTarget.scrollTop;
400
+ }
401
+ function qt() {
402
+ let e = z.value;
403
+ !e || typeof ResizeObserver > "u" || (H?.disconnect(), Jt(e), H = new ResizeObserver(([e]) => {
404
+ e && (Ze.value = Math.max(0, e.contentRect.width - j), Qe.value = Math.max(0, e.contentRect.height - j));
405
+ }), H.observe(e));
406
+ }
407
+ function Jt(e) {
408
+ Ze.value = Math.max(0, e.clientWidth - j), Qe.value = Math.max(0, e.clientHeight - j), V.value = e.scrollTop;
409
+ }
410
+ function $() {
411
+ V.value = 0, z.value && (z.value.scrollTop = 0);
412
+ }
413
+ async function Yt(e) {
414
+ let t = et.get(e);
415
+ if (t) return t;
416
+ let n = `${G.value}/collection?prefix=${encodeURIComponent(e)}`, r = await fetch(n);
417
+ if (r.ok) {
418
+ let t = await r.json(), n = {
419
+ ...t,
420
+ prefix: t.prefix || e
421
+ };
422
+ return et.set(e, n), n;
423
+ }
424
+ let i = await fetch(`${G.value}/${encodeURIComponent(e)}.json`);
425
+ if (!i.ok) throw Error(`HTTP ${r.status}`);
426
+ let a = await i.json(), o = {
427
+ ...a,
428
+ prefix: a.prefix || e
429
+ };
430
+ return et.set(e, o), o;
431
+ }
432
+ function Xt(e, t) {
433
+ return Zt(e).map((e) => {
434
+ let n = `${t}:${e}`;
435
+ return {
436
+ key: n,
437
+ value: T(n, y.valueFormat),
438
+ label: e,
439
+ iconify: n
440
+ };
441
+ });
442
+ }
443
+ function Zt(e) {
444
+ let t = new Set(e.hidden ?? []);
445
+ for (let [n, r] of Object.entries(e.icons ?? {})) r.hidden && t.add(n);
446
+ let n = /* @__PURE__ */ new Set([...Object.values(e.categories || {}).flat(), ...e.uncategorized || []]);
447
+ for (let r of Object.keys(e.icons ?? {})) t.has(r) || n.add(r);
448
+ for (let r of Object.keys(e.aliases ?? {})) {
449
+ if (e.total !== void 0 && n.size >= e.total) break;
450
+ t.has(r) || n.add(r);
451
+ }
452
+ return Array.from(n).filter((e) => !t.has(e)).sort((e, t) => e.localeCompare(t));
453
+ }
454
+ return (r, a) => (p(), c("div", me, [l("div", he, [
455
+ d(g(e), {
456
+ variant: "mono",
457
+ size: f.size,
458
+ disabled: f.disabled,
459
+ "aria-label": xt.value,
460
+ title: bt.value,
461
+ onClick: kt
462
+ }, {
463
+ default: v(() => [q.value?.markup ? (p(), c("span", {
464
+ key: 0,
465
+ class: te(["flex items-center justify-center [&>svg]:size-full", rt.value]),
466
+ innerHTML: q.value.markup
467
+ }, null, 10, ge)) : q.value?.iconify ? (p(), o(g(oe), {
468
+ key: 1,
469
+ icon: q.value.iconify
470
+ }, null, 8, ["icon"])) : (p(), c(i, { key: 2 }, [u("选择图标")], 64))]),
471
+ _: 1
472
+ }, 8, [
473
+ "size",
474
+ "disabled",
475
+ "aria-label",
476
+ "title"
477
+ ]),
478
+ f.defaultValue ? (p(), o(g(e), {
479
+ key: 0,
480
+ size: "sm",
481
+ variant: "link",
482
+ icon: "i-lucide:rotate-ccw",
483
+ disabled: N.value === f.defaultValue,
484
+ onClick: Ut
485
+ }, {
486
+ default: v(() => [...a[4] ||= [u("恢复默认", -1)]]),
487
+ _: 1
488
+ }, 8, ["disabled"])) : s("", !0),
489
+ N.value ? (p(), o(g(e), {
490
+ key: 1,
491
+ size: "sm",
492
+ variant: "link",
493
+ icon: "i-lucide:trash-2",
494
+ onClick: zt
495
+ }, {
496
+ default: v(() => [...a[5] ||= [u("清空", -1)]]),
497
+ _: 1
498
+ })) : s("", !0)
499
+ ]), d(g(n), {
500
+ visible: x.value,
501
+ "onUpdate:visible": a[3] ||= (e) => x.value = e,
502
+ title: f.title,
503
+ width: "min(920px, calc(100vw - 2rem))",
504
+ height: "min(680px, calc(100dvh - 2rem))",
505
+ "z-index": f.modalZIndex
506
+ }, {
507
+ footer: v(() => [l("div", { class: te(["flex w-full flex-wrap items-center gap-3", f.allowSvgUpload ? "justify-between" : "justify-center"]) }, [f.allowSvgUpload ? (p(), c("div", Be, [
508
+ l("input", {
509
+ ref_key: "svgFileInputRef",
510
+ ref: Xe,
511
+ type: "file",
512
+ accept: ".svg,image/svg+xml",
513
+ class: "hidden",
514
+ "aria-hidden": "true",
515
+ tabindex: "-1",
516
+ multiple: "",
517
+ onChange: Ht
518
+ }, null, 544),
519
+ d(g(e), {
520
+ variant: "mono",
521
+ icon: "i-lucide:upload",
522
+ disabled: f.disabled,
523
+ onClick: Bt
524
+ }, {
525
+ default: v(() => [...a[11] ||= [u("上传 SVG", -1)]]),
526
+ _: 1
527
+ }, 8, ["disabled"]),
528
+ st.value ? (p(), c("span", Ve, [l("span", {
529
+ class: "flex size-4 shrink-0 items-center justify-center [&>svg]:size-full",
530
+ innerHTML: st.value.markup
531
+ }, null, 8, He), l("span", Ue, "已选择 " + h(B.value.length) + " 个 SVG", 1)])) : s("", !0)
532
+ ])) : s("", !0), l("div", We, [d(g(e), {
533
+ size: "lg",
534
+ variant: "mono",
535
+ onClick: a[2] ||= (e) => x.value = !1
536
+ }, {
537
+ default: v(() => [...a[12] ||= [u("取消", -1)]]),
538
+ _: 1
539
+ }), d(g(e), {
540
+ size: "lg",
541
+ disabled: !q.value,
542
+ onClick: Wt
543
+ }, {
544
+ default: v(() => [...a[13] ||= [u("确定", -1)]]),
545
+ _: 1
546
+ }, 8, ["disabled"])])], 2)]),
547
+ default: v(() => [l("div", _e, [l("aside", ve, [l("div", ye, [d(g(t), {
548
+ modelValue: D.value,
549
+ "onUpdate:modelValue": a[0] ||= (e) => D.value = e,
550
+ clearable: "",
551
+ size: "sm",
552
+ "prefix-icon": "i-lucide:search",
553
+ placeholder: "搜索图标集"
554
+ }, null, 8, ["modelValue"])]), l("div", be, [(p(!0), c(i, null, ae(ut.value, (e) => (p(), c("button", {
555
+ key: e.prefix,
556
+ type: "button",
557
+ "data-icon-picker-collection": "true",
558
+ class: te(["mb-1 flex w-full cursor-pointer items-center justify-between gap-3 rounded-md border-0 px-3 py-2 text-left transition-colors", e.prefix === M.value ? "bg-brand-50 text-brand-700 dark:bg-brand-700 dark:text-white" : "bg-transparent text-secondary hover:bg-tertiary hover:text-primary"]),
559
+ onClick: (t) => It(e.prefix)
560
+ }, [l("span", Se, [l("span", Ce, h(e.name), 1), l("span", we, h(pt(e.prefix)), 1)]), l("span", Te, h(e.total), 1)], 10, xe))), 128)), E.value ? (p(), c("div", Ee, [l("span", null, h(E.value), 1), d(g(e), {
561
+ variant: "mono",
562
+ size: "sm",
563
+ onClick: Mt
564
+ }, {
565
+ default: v(() => [...a[6] ||= [u("重试", -1)]]),
566
+ _: 1
567
+ })])) : !S.value && !ut.value.length ? (p(), c("div", De, "没有匹配的图标集")) : s("", !0)])]), l("section", Oe, [l("div", ke, [l("div", Ae, [l("div", je, h(gt.value), 1), l("div", Me, [l("span", null, h(_t.value), 1), C.value && Z.value.length ? (p(), c("span", Ne)) : s("", !0)])]), d(g(t), {
568
+ modelValue: O.value,
569
+ "onUpdate:modelValue": a[1] ||= (e) => O.value = e,
570
+ clearable: "",
571
+ size: "sm",
572
+ "prefix-icon": "i-lucide:search",
573
+ placeholder: yt.value,
574
+ class: "w-full"
575
+ }, null, 8, ["modelValue", "placeholder"])]), l("div", {
576
+ ref_key: "gridViewportRef",
577
+ ref: z,
578
+ class: "relative min-h-0 flex-1 overflow-auto p-3",
579
+ onScroll: Kt
580
+ }, [S.value || C.value && !Z.value.length ? (p(), c("div", Pe, [...a[7] ||= [l("span", {
581
+ class: "i-lucide:loader-circle size-6 animate-spin text-brand",
582
+ "aria-label": "加载中"
583
+ }, null, -1)]])) : R.value ? (p(), c("div", Fe, [
584
+ a[9] ||= l("span", { class: "i-lucide:circle-alert mb-3 text-36px text-amber-500" }, null, -1),
585
+ l("span", null, h(R.value), 1),
586
+ d(g(e), {
587
+ class: "mt-4",
588
+ variant: "mono",
589
+ size: "sm",
590
+ onClick: Lt
591
+ }, {
592
+ default: v(() => [...a[8] ||= [u("重试", -1)]]),
593
+ _: 1
594
+ })
595
+ ])) : Z.value.length ? (p(), c("div", {
596
+ key: 2,
597
+ class: "relative",
598
+ style: ne({ height: `${Et.value}px` })
599
+ }, [l("div", {
600
+ class: "absolute left-0 right-0 top-0 grid gap-2",
601
+ style: ne(Dt.value)
602
+ }, [(p(!0), c(i, null, ae(Tt.value, (e) => (p(), c("button", {
603
+ key: e.key,
604
+ type: "button",
605
+ "data-icon-picker-icon": "true",
606
+ class: te(["flex h-20 cursor-pointer flex-col items-center justify-center gap-2 rounded-md border bg-primary px-2 text-secondary transition-colors hover:border-brand hover:text-brand", e.key === ot.value ? "border-brand bg-brand-50 text-brand dark:border-brand dark:bg-brand-700 dark:text-white" : "border-light"]),
607
+ title: e.markup ? e.label : e.value,
608
+ onClick: (t) => Rt(e)
609
+ }, [e.markup ? (p(), c("span", {
610
+ key: 0,
611
+ class: "flex size-6 shrink-0 items-center justify-center [&>svg]:size-full",
612
+ innerHTML: e.markup
613
+ }, null, 8, Le)) : e.iconify ? (p(), o(g(oe), {
614
+ key: 1,
615
+ icon: e.iconify,
616
+ class: "size-6 shrink-0"
617
+ }, null, 8, ["icon"])) : s("", !0), l("span", Re, h(e.label), 1)], 10, Ie))), 128))], 4)], 4)) : (p(), c("div", ze, [a[10] ||= l("span", {
618
+ class: "i-lucide:search-x size-6 opacity-60",
619
+ "aria-hidden": "true"
620
+ }, null, -1), l("span", null, h(vt.value), 1)]))], 544)])])]),
621
+ _: 1
622
+ }, 8, [
623
+ "visible",
624
+ "title",
625
+ "z-index"
626
+ ])]));
627
+ }
628
+ });
629
+ //#endregion
630
+ export { pe as a, le as c, fe as i, ue as n, O as o, de as r, T as s, M as t };
631
+
632
+ //# sourceMappingURL=IconPicker-B0EhOCL1.js.map