@ui0/icon 0.1.2 → 0.1.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.
- package/dist/icon.module.css +0 -1
- package/dist/icon.vue.d.ts +3 -1
- package/dist/icon.vue.d.ts.map +1 -1
- package/dist/index.js +342 -279
- package/dist/interactions.vue.d.ts +10 -0
- package/dist/interactions.vue.d.ts.map +1 -0
- package/dist/modifiers.d.ts +15 -0
- package/dist/modifiers.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/vite/compose.d.ts.map +1 -1
- package/dist/vite/index.d.ts +2 -3
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +704 -500
- package/dist/vite/next/compose.d.ts +15 -0
- package/dist/vite/next/compose.d.ts.map +1 -0
- package/dist/vite/next/plugin.d.ts +5 -0
- package/dist/vite/next/plugin.d.ts.map +1 -0
- package/dist/vite/next/sources.d.ts +27 -0
- package/dist/vite/next/sources.d.ts.map +1 -0
- package/dist/vite/options.d.ts +2 -0
- package/dist/vite/options.d.ts.map +1 -1
- package/dist/vite/progress/compiler.d.ts +25 -0
- package/dist/vite/progress/compiler.d.ts.map +1 -0
- package/dist/vite/progress/runtime.d.ts +3 -0
- package/dist/vite/progress/runtime.d.ts.map +1 -0
- package/dist/vite/progress/types.d.ts +21 -0
- package/dist/vite/progress/types.d.ts.map +1 -0
- package/dist/vite/transformer-next.d.ts +16 -0
- package/dist/vite/transformer-next.d.ts.map +1 -0
- package/dist/vite/transformer.d.ts +3 -0
- package/dist/vite/transformer.d.ts.map +1 -1
- package/dist/vite/types.d.ts +22 -3
- package/dist/vite/types.d.ts.map +1 -1
- package/package.json +11 -10
package/dist/vite/index.js
CHANGED
|
@@ -1,138 +1,70 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
`, ot = `<svg>
|
|
22
|
-
<path class="no-fill" d="M480,480h280c0,74.2-29.5,145.5-82,198-52.5,52.5-123.8,82-198,82v-280Z"/>
|
|
23
|
-
</svg>
|
|
24
|
-
`, ct = `<svg viewBox="0 0 960 960"><circle cx="480" cy="480" r="60"/></svg>
|
|
25
|
-
`, lt = `<svg data-icon="utility no-progress" viewBox="0 0 960 960">
|
|
26
|
-
<path d="M441.3,253.9c17.2-29.8,60.2-29.8,77.4,0l117.6,203.8,117.6,203.8c17.2,29.8-4.3,67-38.7,67H244.7c-34.4,0-55.9-37.2-38.7-67l117.6-203.8,117.6-203.8Z"/>
|
|
27
|
-
</svg>
|
|
28
|
-
`, j = {
|
|
29
|
-
"arc-90": it,
|
|
30
|
-
arrow: rt,
|
|
31
|
-
chevron: at,
|
|
32
|
-
circle: nt,
|
|
33
|
-
"pie-90": ot,
|
|
34
|
-
point: ct,
|
|
35
|
-
triangle: lt
|
|
36
|
-
};
|
|
37
|
-
function k(i) {
|
|
38
|
-
return "file" in i;
|
|
39
|
-
}
|
|
40
|
-
const y = ".svg", A = "ui0-icon:";
|
|
41
|
-
function P(i, t, s, r = 480, e = 480) {
|
|
42
|
-
const c = i.split(/[\s,]+/).map(parseFloat), l = i.includes(",") ? "," : " ";
|
|
43
|
-
return c.map((u, p) => {
|
|
44
|
-
const o = p % 2 === 0, g = o ? r : e, d = o ? t : s;
|
|
45
|
-
return ((u - g) * d + g).toFixed(2);
|
|
46
|
-
}).reduce((u, p, o) => u + (o > 0 ? o % 2 === 0 ? " " : l : "") + p, "");
|
|
47
|
-
}
|
|
48
|
-
function Y(i, t) {
|
|
49
|
-
return i.replace(/([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/g, (s) => (parseFloat(s) * t).toFixed(2));
|
|
50
|
-
}
|
|
51
|
-
function G(i, t, s) {
|
|
52
|
-
const [r = 0, e = 0] = s, { x1: c, y1: l, x2: u, y2: p, ...o } = i, g = parseFloat(c).toFixed(3), d = parseFloat(l).toFixed(3), n = parseFloat(u).toFixed(3), h = parseFloat(p).toFixed(3), a = (f, x) => (x + (f - x) * t).toFixed(3);
|
|
1
|
+
var At = Object.defineProperty;
|
|
2
|
+
var St = (r, t, e) => t in r ? At(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var I = (r, t, e) => St(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { createHash as Nt } from "node:crypto";
|
|
5
|
+
import { createRequire as kt } from "node:module";
|
|
6
|
+
import k from "node:path";
|
|
7
|
+
import { parse as Ct, compileTemplate as Et, compileStyle as Pt } from "vue/compiler-sfc";
|
|
8
|
+
import { readdirSync as Ft, readFileSync as z } from "node:fs";
|
|
9
|
+
function X(r, t, e, s = 480, i = 480) {
|
|
10
|
+
const f = r.split(/[\s,]+/).map(parseFloat), l = r.includes(",") ? "," : " ";
|
|
11
|
+
return f.map((a, o) => {
|
|
12
|
+
const u = o % 2 === 0, p = u ? s : i, g = u ? t : e;
|
|
13
|
+
return ((a - p) * g + p).toFixed(2);
|
|
14
|
+
}).reduce((a, o, u) => a + (u > 0 ? u % 2 === 0 ? " " : l : "") + o, "");
|
|
15
|
+
}
|
|
16
|
+
function at(r, t) {
|
|
17
|
+
return r.replace(/([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)/g, (e) => (parseFloat(e) * t).toFixed(2));
|
|
18
|
+
}
|
|
19
|
+
function tt(r, t, e) {
|
|
20
|
+
const [s = 0, i = 0] = e, { x1: f, y1: l, x2: a, y2: o, ...u } = r, p = parseFloat(f).toFixed(3), g = parseFloat(l).toFixed(3), n = parseFloat(a).toFixed(3), m = parseFloat(o).toFixed(3), c = (h, d) => (d + (h - d) * t).toFixed(3);
|
|
53
21
|
return {
|
|
54
|
-
...
|
|
22
|
+
...u,
|
|
55
23
|
// Сохраняем остальные атрибуты
|
|
56
|
-
x1:
|
|
57
|
-
y1:
|
|
58
|
-
x2:
|
|
59
|
-
y2:
|
|
24
|
+
x1: c(+p, s),
|
|
25
|
+
y1: c(+g, i),
|
|
26
|
+
x2: c(+n, s),
|
|
27
|
+
y2: c(+m, i)
|
|
60
28
|
};
|
|
61
29
|
}
|
|
62
|
-
function
|
|
63
|
-
const [
|
|
30
|
+
function et(r, t, e) {
|
|
31
|
+
const [s = 0, i = 0] = e, { x: f, y: l, width: a, height: o, ...u } = r, p = (g, n) => (n + (g - n) * t).toFixed(3);
|
|
64
32
|
return {
|
|
65
|
-
...
|
|
66
|
-
x:
|
|
67
|
-
y:
|
|
68
|
-
width: (+
|
|
69
|
-
height: (+
|
|
33
|
+
...u,
|
|
34
|
+
x: p(+f, s),
|
|
35
|
+
y: p(+l, i),
|
|
36
|
+
width: (+a * t).toFixed(3),
|
|
37
|
+
height: (+o * t).toFixed(3)
|
|
70
38
|
};
|
|
71
39
|
}
|
|
72
|
-
function
|
|
73
|
-
return isNaN(t) || isNaN(
|
|
74
|
-
if (/^[Zz]$/.test(
|
|
75
|
-
const l =
|
|
76
|
-
let
|
|
77
|
-
return
|
|
78
|
-
const
|
|
79
|
-
let
|
|
80
|
-
isNaN(
|
|
81
|
-
}),
|
|
40
|
+
function D(r, t, e) {
|
|
41
|
+
return isNaN(t) || isNaN(e) ? r : r.replace(/([MLHVCSQTZmlhvcsqtaz])([^MLHVCSQTZmlhvcsqtaz]*)/gi, (s, i, f) => {
|
|
42
|
+
if (/^[Zz]$/.test(i)) return i;
|
|
43
|
+
const l = i === i.toLowerCase();
|
|
44
|
+
let a = i, o = 0;
|
|
45
|
+
return f.split(/[\s,]+/).filter(Boolean).forEach((u) => {
|
|
46
|
+
const p = parseFloat(u);
|
|
47
|
+
let g = u;
|
|
48
|
+
isNaN(p) || (l || (g = (o % 2 === 0 ? p + t : p + e).toFixed(3)), o++), a += (a === i ? "" : " ") + g;
|
|
49
|
+
}), a;
|
|
82
50
|
});
|
|
83
51
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
86
|
-
}
|
|
87
|
-
function Z(i) {
|
|
88
|
-
return i.startsWith("@") || i.startsWith(":") ? i : i.replace(/[^a-zA-Z0-9]+(.)/g, (t, s) => s.toUpperCase()).replace(/^[A-Z]/, (t) => t.toLowerCase());
|
|
89
|
-
}
|
|
90
|
-
function ft(i) {
|
|
91
|
-
if (i.startsWith(A)) return i;
|
|
92
|
-
const t = i.split("?", 1)[0];
|
|
93
|
-
if (t) {
|
|
94
|
-
const r = t.replace(A, "").replace(y, "");
|
|
95
|
-
return `${A}${r}`;
|
|
96
|
-
}
|
|
97
|
-
return i;
|
|
98
|
-
}
|
|
99
|
-
function K(i) {
|
|
100
|
-
return i.split(/(\\|\/)/g).pop();
|
|
52
|
+
function It(r) {
|
|
53
|
+
return r.replace(/[A-Z]+(?![a-z])|[A-Z]/g, (t, e) => (e ? "-" : "") + t.toLowerCase());
|
|
101
54
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
55
|
+
function st(r) {
|
|
56
|
+
return r.startsWith("@") || r.startsWith(":") ? r : r.replace(/[^a-zA-Z0-9]+(.)/g, (t, e) => e.toUpperCase()).replace(/^[A-Z]/, (t) => t.toLowerCase());
|
|
104
57
|
}
|
|
105
|
-
function
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
t = J.readFileSync(i);
|
|
113
|
-
} catch {
|
|
114
|
-
console.error(`${i} couldn't be loaded by loader, fallback to default loader`);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
return Buffer.from(t).toString();
|
|
118
|
-
}
|
|
119
|
-
function C(i) {
|
|
120
|
-
try {
|
|
121
|
-
return Buffer.from(J.readFileSync(i)).toString();
|
|
122
|
-
} catch {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
function gt(i, t, s) {
|
|
127
|
-
const r = [];
|
|
128
|
-
for (let e = 0; e < i.length; e++) {
|
|
129
|
-
const c = i.indexOf(">", e);
|
|
130
|
-
if (i.startsWith(`<${t}`, e) && c > -1 && i[c - 1] !== "/" && r.push(e), i.startsWith(`</${t}>`, e) && r.length > 0 && r.pop() === s)
|
|
131
|
-
return e;
|
|
58
|
+
function Ot(r, t, e) {
|
|
59
|
+
const s = [];
|
|
60
|
+
for (let i = 0; i < r.length; i++) {
|
|
61
|
+
const f = r.indexOf(">", i);
|
|
62
|
+
if (r.startsWith(`<${t}`, i) && f > -1 && r[f - 1] !== "/" && s.push(i), r.startsWith(`</${t}>`, i) && s.length > 0 && s.pop() === e)
|
|
63
|
+
return i;
|
|
132
64
|
}
|
|
133
65
|
return -1;
|
|
134
66
|
}
|
|
135
|
-
const
|
|
67
|
+
const _t = [
|
|
136
68
|
"attributeName",
|
|
137
69
|
"repeatCount",
|
|
138
70
|
"repeatDur",
|
|
@@ -148,7 +80,7 @@ const xt = [
|
|
|
148
80
|
"lengthAdjust",
|
|
149
81
|
"ariaHidden",
|
|
150
82
|
"ariaLabel"
|
|
151
|
-
],
|
|
83
|
+
], Mt = [
|
|
152
84
|
"svg",
|
|
153
85
|
"g",
|
|
154
86
|
"path",
|
|
@@ -212,10 +144,10 @@ const xt = [
|
|
|
212
144
|
"a",
|
|
213
145
|
"switch"
|
|
214
146
|
];
|
|
215
|
-
function
|
|
216
|
-
return
|
|
147
|
+
function Bt(r, t) {
|
|
148
|
+
return Mt.includes(r.tag) ? !_t.includes(t) : !0;
|
|
217
149
|
}
|
|
218
|
-
class
|
|
150
|
+
class x {
|
|
219
151
|
static createNode(t = {}) {
|
|
220
152
|
return {
|
|
221
153
|
tag: "node",
|
|
@@ -225,102 +157,102 @@ class $ {
|
|
|
225
157
|
content: "",
|
|
226
158
|
raw: "",
|
|
227
159
|
...t,
|
|
228
|
-
getAttr(
|
|
229
|
-
return this.attributes[
|
|
160
|
+
getAttr(e) {
|
|
161
|
+
return this.attributes[e] ?? null;
|
|
230
162
|
},
|
|
231
|
-
setAttr(
|
|
232
|
-
this.attributes[
|
|
163
|
+
setAttr(e, s) {
|
|
164
|
+
this.attributes[e] = s;
|
|
233
165
|
},
|
|
234
|
-
hasAttr(
|
|
235
|
-
return
|
|
166
|
+
hasAttr(e) {
|
|
167
|
+
return st(e) in this.attributes;
|
|
236
168
|
},
|
|
237
169
|
/**
|
|
238
170
|
* Is node is child of node or any of nodes
|
|
239
171
|
* @param child
|
|
240
172
|
* @param parent
|
|
241
173
|
*/
|
|
242
|
-
isChildOf(
|
|
243
|
-
if (!
|
|
244
|
-
const
|
|
245
|
-
for (const
|
|
246
|
-
let
|
|
247
|
-
for (;
|
|
248
|
-
if (
|
|
174
|
+
isChildOf(e) {
|
|
175
|
+
if (!e) return !1;
|
|
176
|
+
const s = Array.isArray(e) ? e : [e];
|
|
177
|
+
for (const i of s) {
|
|
178
|
+
let f = this.parent;
|
|
179
|
+
for (; f !== null; ) {
|
|
180
|
+
if (f === i)
|
|
249
181
|
return !0;
|
|
250
|
-
|
|
182
|
+
f = f.parent;
|
|
251
183
|
}
|
|
252
184
|
}
|
|
253
185
|
return !1;
|
|
254
186
|
},
|
|
255
|
-
hasClass(
|
|
256
|
-
return !!(this.attributes.class && this.attributes.class.split(" ").includes(
|
|
187
|
+
hasClass(e) {
|
|
188
|
+
return !!(this.attributes.class && this.attributes.class.split(" ").includes(e));
|
|
257
189
|
},
|
|
258
|
-
walk(
|
|
259
|
-
return
|
|
190
|
+
walk(e) {
|
|
191
|
+
return x.walk(this, e);
|
|
260
192
|
},
|
|
261
193
|
serialize() {
|
|
262
|
-
return
|
|
194
|
+
return x.serialize(this);
|
|
263
195
|
},
|
|
264
|
-
addClass(
|
|
265
|
-
const
|
|
266
|
-
|
|
196
|
+
addClass(e) {
|
|
197
|
+
const s = this.attributes.class.split(" ");
|
|
198
|
+
s.includes(e) || (s.push(e), this.attributes.class = s.join(" "));
|
|
267
199
|
},
|
|
268
|
-
addStyle(
|
|
269
|
-
this.hasAttr("style") ? this.attributes.style +=
|
|
200
|
+
addStyle(e) {
|
|
201
|
+
this.hasAttr("style") ? this.attributes.style += e + ";" : this.attributes.style = e + ";";
|
|
270
202
|
},
|
|
271
|
-
removeClass(
|
|
272
|
-
const
|
|
273
|
-
|
|
203
|
+
removeClass(e) {
|
|
204
|
+
const s = this.attributes.class.split(" ");
|
|
205
|
+
s.includes(e) && (s.splice(s.indexOf(e), 1), this.attributes.class = s.join(" "));
|
|
274
206
|
}
|
|
275
207
|
};
|
|
276
208
|
}
|
|
277
209
|
// todo when exists end tag between quotes - "something >" parser have issues
|
|
278
|
-
static parse(t,
|
|
279
|
-
let
|
|
280
|
-
const
|
|
281
|
-
for (;
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
|
|
210
|
+
static parse(t, e, s = {}) {
|
|
211
|
+
let i = t.replace(/\r?\n/g, " ").replace(/\s+/g, " ").trim();
|
|
212
|
+
const f = [], { parent: l = null } = s;
|
|
213
|
+
for (; i.length > 0; ) {
|
|
214
|
+
if (i.startsWith("<!--")) {
|
|
215
|
+
const d = i.indexOf("-->") + 3;
|
|
216
|
+
i = i.slice(d).trim();
|
|
285
217
|
continue;
|
|
286
218
|
}
|
|
287
|
-
if (
|
|
288
|
-
const
|
|
289
|
-
|
|
219
|
+
if (i.startsWith("<?")) {
|
|
220
|
+
const d = i.indexOf("?>") + 2;
|
|
221
|
+
i = i.slice(d).trim();
|
|
290
222
|
continue;
|
|
291
223
|
}
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
294
|
-
|
|
224
|
+
if (i.startsWith("<![CDATA[")) {
|
|
225
|
+
const d = i.indexOf("]]>") + 3;
|
|
226
|
+
i = i.slice(d).trim();
|
|
295
227
|
continue;
|
|
296
228
|
}
|
|
297
|
-
if (
|
|
298
|
-
const
|
|
299
|
-
|
|
229
|
+
if (i.startsWith("<!")) {
|
|
230
|
+
const d = i.indexOf(">") + 1;
|
|
231
|
+
i = i.slice(d).trim();
|
|
300
232
|
continue;
|
|
301
233
|
}
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
|
|
234
|
+
if (i.startsWith("</")) {
|
|
235
|
+
const d = i.indexOf(">");
|
|
236
|
+
if (d === -1) break;
|
|
237
|
+
i = i.slice(d + 1).trim();
|
|
306
238
|
continue;
|
|
307
239
|
}
|
|
308
|
-
if (!
|
|
309
|
-
const
|
|
240
|
+
if (!i.startsWith("<")) {
|
|
241
|
+
const d = i.indexOf("<"), b = d === -1 ? i : i.slice(0, d), y = this.createNode({
|
|
310
242
|
tag: "#text",
|
|
311
243
|
attributes: {},
|
|
312
244
|
children: [],
|
|
313
245
|
parent: l,
|
|
314
246
|
content: b,
|
|
315
247
|
raw: b
|
|
316
|
-
}),
|
|
317
|
-
|
|
248
|
+
}), v = e ? e(y) : y;
|
|
249
|
+
v && f.push(...Array.isArray(v) ? v : [v]), i = d === -1 ? "" : i.slice(d);
|
|
318
250
|
continue;
|
|
319
251
|
}
|
|
320
|
-
const
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
tag:
|
|
252
|
+
const a = i.indexOf(">");
|
|
253
|
+
if (a === -1) break;
|
|
254
|
+
const o = i[a - 1] === "/", u = i.slice(1, o ? a - 1 : a), p = u.indexOf(" "), g = p === -1 ? u : u.slice(0, p), n = p === -1 ? "" : u.slice(p + 1), m = this.createNode({
|
|
255
|
+
tag: g,
|
|
324
256
|
attributes: this.parseAttributes(n),
|
|
325
257
|
children: [],
|
|
326
258
|
parent: l,
|
|
@@ -328,18 +260,18 @@ class $ {
|
|
|
328
260
|
raw: ""
|
|
329
261
|
// Will be set later
|
|
330
262
|
});
|
|
331
|
-
let
|
|
332
|
-
if (!
|
|
333
|
-
const
|
|
334
|
-
b !== -1 && (
|
|
263
|
+
let c = a + 1;
|
|
264
|
+
if (!o) {
|
|
265
|
+
const d = `</${g}>`, b = Ot(i, g, 0);
|
|
266
|
+
b !== -1 && (m.raw = i.slice(c, b), m.content = m.raw.slice(0, b - c), m.raw.includes("<") && (m.children = this.parse(m.raw, e, { parent: m })), c = b + d.length);
|
|
335
267
|
}
|
|
336
|
-
const
|
|
337
|
-
|
|
268
|
+
const h = e ? e(m) : m;
|
|
269
|
+
h ? f.push(...Array.isArray(h) ? h : [h]) : m.parent && (m.parent.content = m.parent.content.replace(this.serialize(m), "")), i = i.slice(c).trim();
|
|
338
270
|
}
|
|
339
|
-
return
|
|
271
|
+
return f;
|
|
340
272
|
}
|
|
341
|
-
static parseAsSingle(t,
|
|
342
|
-
return this.parse(t,
|
|
273
|
+
static parseAsSingle(t, e, s = {}) {
|
|
274
|
+
return this.parse(t, e, s)[0];
|
|
343
275
|
}
|
|
344
276
|
/**
|
|
345
277
|
* Serialize
|
|
@@ -348,9 +280,9 @@ class $ {
|
|
|
348
280
|
*/
|
|
349
281
|
static serialize(t) {
|
|
350
282
|
if (Array.isArray(t))
|
|
351
|
-
return t.map((
|
|
352
|
-
const
|
|
353
|
-
return t.children.length === 0 ? t.content ? `<${t.tag}${
|
|
283
|
+
return t.map((i) => this.serialize(i)).join("");
|
|
284
|
+
const e = Object.entries(t.attributes).map(([i, f]) => ` ${Bt(t, i) ? It(i) : i}="${f}"`).join(""), s = t.children.map((i) => this.serialize(i)).join("");
|
|
285
|
+
return t.children.length === 0 ? t.content ? `<${t.tag}${e}>${t.content}</${t.tag}>` : `<${t.tag}${e}/>` : `<${t.tag}${e}>${s}</${t.tag}>`;
|
|
354
286
|
}
|
|
355
287
|
/**
|
|
356
288
|
* walk nodes with callback
|
|
@@ -359,156 +291,178 @@ class $ {
|
|
|
359
291
|
* @param onEntry
|
|
360
292
|
* @param options Optional traversal options
|
|
361
293
|
*/
|
|
362
|
-
static walk(t,
|
|
363
|
-
const
|
|
364
|
-
(
|
|
294
|
+
static walk(t, e, s) {
|
|
295
|
+
const i = Array.isArray(t) ? t : [t], f = (s == null ? void 0 : s.includeText) ?? !0, l = (a) => {
|
|
296
|
+
(a.tag !== "#text" || f) && e(a) === !1 || a.children.forEach((o) => l(o));
|
|
365
297
|
};
|
|
366
|
-
|
|
298
|
+
i.forEach(l);
|
|
367
299
|
}
|
|
368
|
-
static clone(t,
|
|
369
|
-
const
|
|
300
|
+
static clone(t, e = null) {
|
|
301
|
+
const s = this.createNode({
|
|
370
302
|
tag: t.tag,
|
|
371
303
|
attributes: { ...t.attributes },
|
|
372
304
|
children: [],
|
|
373
|
-
parent:
|
|
305
|
+
parent: e,
|
|
374
306
|
content: t.content,
|
|
375
307
|
raw: t.raw
|
|
376
308
|
});
|
|
377
|
-
return
|
|
309
|
+
return s.children = t.children.map((i) => this.clone(i, s)), s;
|
|
378
310
|
}
|
|
379
311
|
static parseAttributes(t) {
|
|
380
|
-
const
|
|
381
|
-
let
|
|
382
|
-
for (; (
|
|
383
|
-
|
|
384
|
-
return
|
|
312
|
+
const e = {}, s = /([^\s=]+)="([^"]*)"/g;
|
|
313
|
+
let i;
|
|
314
|
+
for (; (i = s.exec(t)) !== null; )
|
|
315
|
+
e[st(i[1])] = i[2];
|
|
316
|
+
return e;
|
|
385
317
|
}
|
|
386
318
|
}
|
|
387
|
-
const
|
|
388
|
-
function
|
|
389
|
-
|
|
390
|
-
return { x: D + (e - 1) * c, y: D + (r - 1) * l, width: c, height: l };
|
|
319
|
+
const Lt = /* @__PURE__ */ new Set(["path", "rect", "circle", "ellipse", "line", "polyline", "polygon"]), nt = ["dataProgressAt", "dataProgressInactive", "dataProgressActive"];
|
|
320
|
+
function $(r, t) {
|
|
321
|
+
throw new Error(`[ui0-icon] ${r}: ${t}`);
|
|
391
322
|
}
|
|
392
|
-
function
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
height: s
|
|
399
|
-
};
|
|
323
|
+
function B(r, t, e, s) {
|
|
324
|
+
if (r === void 0) return t;
|
|
325
|
+
if (typeof r != "number" && typeof r != "string" || String(r).trim() === "")
|
|
326
|
+
return $(s, "expected a number");
|
|
327
|
+
const i = Number(r);
|
|
328
|
+
return !Number.isFinite(i) || i < 0 || i > e ? $(s, `expected a finite number between 0 and ${e}`) : i;
|
|
400
329
|
}
|
|
401
|
-
|
|
402
|
-
function vt(i) {
|
|
403
|
-
const t = i.indexOf("?"), s = t === -1 ? void 0 : i.slice(t), r = t === -1 ? i : i.slice(0, t), e = r.indexOf("#"), c = e === -1 ? r : r.slice(0, e), [l, ...u] = c.split("."), p = e === -1 ? void 0 : r.slice(e + 1);
|
|
330
|
+
function U(r, t, e) {
|
|
404
331
|
return {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
query: s,
|
|
408
|
-
modifiers: u.length ? u.map((o) => o.replace(/:/g, "-")) : void 0
|
|
332
|
+
inactive: B(r.inactive, t.inactive ?? 0.2, 1, `${e} inactive`),
|
|
333
|
+
active: B(r.active, t.active ?? 1, 1, `${e} active`)
|
|
409
334
|
};
|
|
410
335
|
}
|
|
411
|
-
function
|
|
412
|
-
return
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
function
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
const l = (
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
c = p;
|
|
336
|
+
function P(r) {
|
|
337
|
+
return nt.some((t) => r.attributes[t] !== void 0);
|
|
338
|
+
}
|
|
339
|
+
function J(r, t) {
|
|
340
|
+
P(r) && $(t, "progress declaration inside an excluded subtree"), r.children.forEach((e) => J(e, t));
|
|
341
|
+
}
|
|
342
|
+
function it(r) {
|
|
343
|
+
return JSON.stringify(nt.map((t) => r.attributes[t]));
|
|
344
|
+
}
|
|
345
|
+
function Rt(r, t) {
|
|
346
|
+
const e = [], s = r.attributes.dataProgressBy === "layers";
|
|
347
|
+
r.attributes.dataProgressBy !== void 0 && !s && $(t, `unknown progress target mode '${r.attributes.dataProgressBy}'`);
|
|
348
|
+
const f = (r.attributes.dataIcon ?? "").split(/[\s,]+/).includes("no-progress") || r.hasClass("no-progress"), l = (r.attributes.dataLayers ?? "").split(/[\s,]+/).filter(Boolean);
|
|
349
|
+
s && (!l.length || new Set(l).size !== l.length) && $(t, "layer progress requires a nonempty, unique data-layers list");
|
|
350
|
+
const a = new Map(l.map((n) => [n, []])), o = (n, m, c) => {
|
|
351
|
+
if (["defs", "mask", "clipPath"].includes(n.tag)) {
|
|
352
|
+
J(n, t);
|
|
429
353
|
return;
|
|
430
354
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
function O(i, t, s = 0, r = 1) {
|
|
436
|
-
const e = s % 180 !== 0, c = e ? t.height : t.width, l = e ? t.width : t.height, u = Math.min(i.width / c, i.height / l) * r, p = i.x + i.width / 2, o = i.y + i.height / 2;
|
|
437
|
-
if (t.x === 0 && t.y === 0 && t.width === w && t.height === w)
|
|
438
|
-
return `translate(${p} ${o}) scale(${u}) rotate(${s}) translate(${-w / 2} ${-w / 2})`;
|
|
439
|
-
const g = p - c * u / 2 - (e ? t.y : t.x) * u, d = o - l * u / 2 - (e ? t.x : t.y) * u, n = t.x + c / 2, h = t.y + l / 2;
|
|
440
|
-
return `translate(${g} ${d}) scale(${u}) rotate(${s} ${n} ${h})`;
|
|
441
|
-
}
|
|
442
|
-
function E(i, t, s, r = /* @__PURE__ */ new Set()) {
|
|
443
|
-
var c;
|
|
444
|
-
if (r.has(i))
|
|
445
|
-
return console.warn(`[ui0-icon] virtual '${i}': circular composition skipped`), `<svg viewBox="0 0 ${w} ${w}"/>`;
|
|
446
|
-
r.add(i);
|
|
447
|
-
const e = [];
|
|
448
|
-
for (const [l, u] of Object.entries(t.cells)) {
|
|
449
|
-
const p = typeof u == "string" ? { value: u } : u, o = vt(p.value), g = wt(o.query);
|
|
450
|
-
g.weight !== void 0 && console.warn(`[ui0-icon] virtual '${i}': 'weight' is not supported yet (source '${p.value}')`);
|
|
451
|
-
const d = p.rotate ?? (g.rotate !== void 0 ? Number(g.rotate) : 0), n = $t[g.fit] ?? 1, h = (c = o.modifiers) != null && c.length ? ` class="${o.modifiers.join(" ")}"` : "", a = s(o.name);
|
|
452
|
-
if (!a) {
|
|
453
|
-
console.warn(`[ui0-icon] virtual '${i}': source '${p.value}' not found`);
|
|
454
|
-
continue;
|
|
455
|
-
}
|
|
456
|
-
const f = p.cell === "full" ? B(t.rows, t.cols, l) : X(B(t.rows, t.cols, l));
|
|
457
|
-
if (a.def && !k(a.def) && !a.svg) {
|
|
458
|
-
const b = E(o.name, a.def, s, new Set(r)), v = O(
|
|
459
|
-
f,
|
|
460
|
-
{ x: 0, y: 0, width: w, height: w },
|
|
461
|
-
d,
|
|
462
|
-
n
|
|
463
|
-
);
|
|
464
|
-
e.push(`<g transform="${v}"${h}>${_(b)}</g>`);
|
|
465
|
-
continue;
|
|
355
|
+
if (f || n.hasClass("no-progress") || n.hasAttr("data-skip")) {
|
|
356
|
+
J(n, t);
|
|
357
|
+
return;
|
|
466
358
|
}
|
|
467
|
-
|
|
468
|
-
if (
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const v = At(a.svg, o.cell, b.rows, b.cols);
|
|
477
|
-
if (!v) {
|
|
478
|
-
console.warn(`[ui0-icon] virtual '${i}': template '${o.name}' has no <g data-cell="${o.cell}"> part`);
|
|
479
|
-
continue;
|
|
359
|
+
const h = n.tag === "g" && n.hasAttr("data-group");
|
|
360
|
+
if (m && (h || P(n)) && $(t, "nested progress targets conflict with their containing group"), s) {
|
|
361
|
+
const d = n.attributes.dataLayer;
|
|
362
|
+
d !== void 0 ? (a.has(d) || $(t, `unknown layer '${d}'`), c !== void 0 && $(t, "nested progress layers overlap"), a.get(d).push(n)) : P(n) && n !== r && $(t, "layer progress declarations must be placed on a data-layer node"), n.children.forEach((b) => o(b, !1, d ?? c));
|
|
363
|
+
} else {
|
|
364
|
+
const d = h || Lt.has(n.tag);
|
|
365
|
+
if (n.attributes[":opacity"] !== void 0 || n.attributes[":data-p-on"] !== void 0) {
|
|
366
|
+
P(n) && $(t, "progress conflicts with an existing :opacity binding");
|
|
367
|
+
return;
|
|
480
368
|
}
|
|
481
|
-
|
|
482
|
-
e.push(`<g transform="${m}"${h}>${v.markup}</g>`);
|
|
483
|
-
continue;
|
|
369
|
+
!m && d && e.push([n]), !d && P(n) && n !== r && $(t, "progress declaration requires a paint node or data-group"), n.children.forEach((b) => o(b, m || h));
|
|
484
370
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
371
|
+
};
|
|
372
|
+
if (o(r, !1), s && !f)
|
|
373
|
+
for (const [n, m] of a)
|
|
374
|
+
m.length || $(t, `layer '${n}' has no progress targets`), e.push(m);
|
|
375
|
+
const u = e.map((n) => n.filter(P)), p = u.some((n) => n.length);
|
|
376
|
+
return { steps: e.map((n, m) => {
|
|
377
|
+
var b;
|
|
378
|
+
const c = u[m];
|
|
379
|
+
c.some((y) => it(y) !== it(c[0])) && $(t, "conflicting declarations for the same layer");
|
|
380
|
+
const h = ((b = c[0]) == null ? void 0 : b.attributes) ?? {};
|
|
381
|
+
p && h.dataProgressAt === void 0 && $(t, "explicit and automatic progress thresholds cannot be mixed");
|
|
382
|
+
const d = p ? B(h.dataProgressAt, 0, 100, `${t} at`) : Number((100 * (m + 1) / e.length).toFixed(3));
|
|
383
|
+
return {
|
|
384
|
+
targets: n,
|
|
385
|
+
at: d,
|
|
386
|
+
...U({ inactive: h.dataProgressInactive, active: h.dataProgressActive }, {}, t)
|
|
387
|
+
};
|
|
388
|
+
}) };
|
|
389
|
+
}
|
|
390
|
+
function jt(r, t, e) {
|
|
391
|
+
if (!r) return { steps: [] };
|
|
392
|
+
Array.isArray(r.steps) || $(e, "progress.steps must be an array");
|
|
393
|
+
const s = U(r, {}, e), i = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Map(), l = (o) => {
|
|
394
|
+
if (["defs", "mask", "clipPath"].includes(o.tag) || o.hasClass("no-progress") || o.hasAttr("data-skip")) return;
|
|
395
|
+
const u = o.attributes.dataLayer;
|
|
396
|
+
u && f.set(u, [...f.get(u) ?? [], o]), o.children.forEach(l);
|
|
397
|
+
};
|
|
398
|
+
return t.forEach(l), { steps: r.steps.map((o, u) => {
|
|
399
|
+
const p = `${e} progress step ${u + 1}`;
|
|
400
|
+
o.at === void 0 && $(p, "at is required");
|
|
401
|
+
const g = o.cells !== void 0;
|
|
402
|
+
g === (o.layers !== void 0) && $(p, "use either cells or layers");
|
|
403
|
+
const n = g ? o.cells : o.layers;
|
|
404
|
+
n.length || $(p, "target list cannot be empty");
|
|
405
|
+
const m = [];
|
|
406
|
+
for (const c of n) {
|
|
407
|
+
const h = g ? t.has(c) ? [t.get(c)] : [] : f.get(c) ?? [];
|
|
408
|
+
h.length || $(p, `unknown ${g ? "cell" : "layer"} '${c}'`);
|
|
409
|
+
for (const d of h)
|
|
410
|
+
[...i].some((b) => b === d || d.isChildOf(b) || b.isChildOf(d)) && $(p, `overlapping target '${c}'`), i.add(d), m.push(d);
|
|
411
|
+
}
|
|
412
|
+
return { targets: m, at: B(o.at, 0, 100, `${p} at`), ...U(o, s, p) };
|
|
413
|
+
}) };
|
|
414
|
+
}
|
|
415
|
+
function ct(r) {
|
|
416
|
+
for (const t of r.steps)
|
|
417
|
+
for (const e of t.targets) {
|
|
418
|
+
if (!e.parent) throw new Error("[ui0-icon] progress target has no parent");
|
|
419
|
+
const s = e.parent, i = s.children.indexOf(e);
|
|
420
|
+
if (i < 0) throw new Error("[ui0-icon] progress target is detached");
|
|
421
|
+
const f = x.createNode({
|
|
422
|
+
tag: "g",
|
|
423
|
+
parent: s,
|
|
424
|
+
children: [e],
|
|
425
|
+
attributes: { ":opacity": `iconProgressValue >= ${t.at} ? ${t.active} : ${t.inactive}` }
|
|
426
|
+
});
|
|
427
|
+
s.children[i] = f, e.parent = f;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function lt(r, t) {
|
|
431
|
+
const e = x.parseAsSingle(r);
|
|
432
|
+
return (!e || e.tag !== "svg") && $(t, "expected an SVG root"), ct(Rt(e, t)), e.serialize();
|
|
433
|
+
}
|
|
434
|
+
function ft(r, t, e) {
|
|
435
|
+
const s = x.parseAsSingle(r);
|
|
436
|
+
(!s || s.tag !== "svg") && $(e, "expected an SVG root");
|
|
437
|
+
const i = /* @__PURE__ */ new Map();
|
|
438
|
+
for (const f of s.children) {
|
|
439
|
+
const l = f.attributes.dataCell;
|
|
440
|
+
l !== void 0 && (i.has(l) && $(e, `duplicate placement cell '${l}'`), i.set(l, f));
|
|
492
441
|
}
|
|
493
|
-
return
|
|
442
|
+
return ct(jt(t.progress, i, e)), s.serialize();
|
|
443
|
+
}
|
|
444
|
+
function Tt(r, t) {
|
|
445
|
+
if (r === void 0) return 100;
|
|
446
|
+
const s = typeof r == "number" || typeof r == "string" && r.trim() !== "" ? Number(r) : NaN;
|
|
447
|
+
return Number.isFinite(s) ? Math.max(0, Math.min(100, s)) : (t == null || t("[ui0-icon] invalid progress value, using 100"), 100);
|
|
494
448
|
}
|
|
495
|
-
const
|
|
496
|
-
function
|
|
497
|
-
return t !== 1 ?
|
|
449
|
+
const W = /\s|,/, rt = ["path", "rect", "circle", "ellipse", "line", "polyline", "polygon"], F = (r) => (960 * r - 960) / 2;
|
|
450
|
+
function ot(r, t = 1) {
|
|
451
|
+
return t !== 1 ? D(at(r, t), -F(t), -F(t)) : r;
|
|
498
452
|
}
|
|
499
|
-
class
|
|
453
|
+
class zt {
|
|
500
454
|
constructor(t = {}) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
const { fit:
|
|
455
|
+
I(this, "options");
|
|
456
|
+
I(this, "name");
|
|
457
|
+
I(this, "result");
|
|
458
|
+
const { fit: e = !0, process: s = !0, rescaling: i = !0 } = t;
|
|
505
459
|
this.result = {}, this.options = {
|
|
506
|
-
fit:
|
|
507
|
-
process:
|
|
508
|
-
rescaling:
|
|
460
|
+
fit: e,
|
|
461
|
+
process: s,
|
|
462
|
+
rescaling: i
|
|
509
463
|
}, this.name = "";
|
|
510
464
|
}
|
|
511
|
-
process(t,
|
|
465
|
+
process(t, e = "", s = this.options) {
|
|
512
466
|
this.result[t] = {
|
|
513
467
|
sfc: {
|
|
514
468
|
template: "",
|
|
@@ -522,22 +476,22 @@ class St {
|
|
|
522
476
|
modifiers: []
|
|
523
477
|
}
|
|
524
478
|
};
|
|
525
|
-
let
|
|
479
|
+
let i = "", f = {
|
|
526
480
|
x: 1,
|
|
527
481
|
y: 1
|
|
528
482
|
}, l = this.result[t].options;
|
|
529
483
|
l.flags ?? (l.flags = []), l.modifiers ?? (l.modifiers = []), l.layers ?? (l.layers = []);
|
|
530
|
-
const
|
|
531
|
-
var
|
|
484
|
+
const a = x.parseAsSingle(e, (n) => {
|
|
485
|
+
var m;
|
|
532
486
|
if (n.tag === "svg" || n.tag === "g") {
|
|
533
487
|
if (n.tag === "svg" && n.hasAttr("viewBox")) {
|
|
534
|
-
const [, ,
|
|
535
|
-
(
|
|
488
|
+
const [, , c = "960", h = "960"] = n.attributes.viewBox.split(" ");
|
|
489
|
+
(c !== "960" || h !== "960") && (f.x = 960 / +c, f.y = 960 / +h);
|
|
536
490
|
}
|
|
537
|
-
n.hasAttr("data-icon") && (l.flags = n.attributes.dataIcon.split(
|
|
491
|
+
n.hasAttr("data-icon") && (l.flags = n.attributes.dataIcon.split(W)), n.hasAttr("data-layers") && (l.layers = n.attributes.dataLayers.split(W)), n.hasAttr("data-modifiers") && (l.modifiers = n.attributes.dataModifiers.split(W));
|
|
538
492
|
}
|
|
539
493
|
if (n.tag === "template")
|
|
540
|
-
return
|
|
494
|
+
return x.createNode({
|
|
541
495
|
tag: "template",
|
|
542
496
|
attributes: n.attributes,
|
|
543
497
|
content: n.raw,
|
|
@@ -545,22 +499,22 @@ class St {
|
|
|
545
499
|
parent: n.parent,
|
|
546
500
|
raw: ""
|
|
547
501
|
});
|
|
548
|
-
if (n.tag === "style" && ((
|
|
549
|
-
return
|
|
550
|
-
if (
|
|
551
|
-
const { id:
|
|
552
|
-
|
|
502
|
+
if (n.tag === "style" && ((m = n.parent) == null ? void 0 : m.tag) === "defs")
|
|
503
|
+
return i += n.content, null;
|
|
504
|
+
if (rt.includes(n.tag) || n.tag === "g") {
|
|
505
|
+
const { id: c } = n.attributes;
|
|
506
|
+
c && (c.startsWith("r-icon") || c.startsWith("no-")) && (n.attributes.class = c + " " + (n.attributes.class ?? ""), delete n.attributes.id);
|
|
553
507
|
}
|
|
554
508
|
return n;
|
|
555
509
|
});
|
|
556
|
-
!l.flags.includes("no-rescale") && this.options.rescaling &&
|
|
557
|
-
(n.tag !== "g" &&
|
|
510
|
+
!l.flags.includes("no-rescale") && this.options.rescaling && a.walk((n) => {
|
|
511
|
+
(n.tag !== "g" && f && f.x !== 1 || f.y !== 1) && this.processBoxScaling(n, f.x, f.y);
|
|
558
512
|
});
|
|
559
|
-
const
|
|
560
|
-
delete
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
|
|
513
|
+
const o = this.processNode(t, a);
|
|
514
|
+
delete a.attributes.id, delete a.attributes.viewBox;
|
|
515
|
+
const u = {};
|
|
516
|
+
a.children.unshift(
|
|
517
|
+
x.createNode({
|
|
564
518
|
tag: "rect",
|
|
565
519
|
children: [],
|
|
566
520
|
attributes: {
|
|
@@ -570,55 +524,55 @@ class St {
|
|
|
570
524
|
}
|
|
571
525
|
})
|
|
572
526
|
);
|
|
573
|
-
const
|
|
527
|
+
const p = x.createNode({
|
|
574
528
|
tag: "g",
|
|
575
|
-
content:
|
|
576
|
-
raw:
|
|
577
|
-
children:
|
|
529
|
+
content: a.content,
|
|
530
|
+
raw: a.raw,
|
|
531
|
+
children: a.children,
|
|
578
532
|
attributes: {
|
|
579
|
-
...
|
|
533
|
+
...u,
|
|
580
534
|
":class": "modifiers",
|
|
581
535
|
"data-icon-body": ""
|
|
582
536
|
},
|
|
583
537
|
parent: null
|
|
584
538
|
});
|
|
585
|
-
|
|
586
|
-
let
|
|
539
|
+
a.hasAttr("class") && (p.attributes.class = a.attributes.class), a.hasAttr("style") && (p.attributes.style = a.attributes.style), this.options.fit && (p.attributes[":style"] = "'--r-icon-fit-ratio: ' + fitRatios[fit]");
|
|
540
|
+
let g = x.serialize(p);
|
|
587
541
|
return this.result[t].sfc = {
|
|
588
|
-
template:
|
|
589
|
-
style:
|
|
590
|
-
script:
|
|
542
|
+
template: g,
|
|
543
|
+
style: i,
|
|
544
|
+
script: o
|
|
591
545
|
}, this.result[t].sfc;
|
|
592
546
|
}
|
|
593
547
|
render(t) {
|
|
594
548
|
if (!this.result) return "";
|
|
595
|
-
const { template:
|
|
596
|
-
let
|
|
597
|
-
return
|
|
549
|
+
const { template: e = "", style: s = "", script: i = "" } = this.result[t].sfc;
|
|
550
|
+
let f = "";
|
|
551
|
+
return e && (f += `
|
|
598
552
|
<template>
|
|
599
|
-
${
|
|
600
|
-
</template>`),
|
|
553
|
+
${e}
|
|
554
|
+
</template>`), s && (f += `
|
|
601
555
|
<style scoped lang="scss">
|
|
602
|
-
${
|
|
603
|
-
</style>`),
|
|
556
|
+
${s.trim()}
|
|
557
|
+
</style>`), i && (f += `
|
|
604
558
|
<script>
|
|
605
|
-
${
|
|
606
|
-
<\/script>`),
|
|
559
|
+
${i}
|
|
560
|
+
<\/script>`), f;
|
|
607
561
|
}
|
|
608
|
-
processBoxScaling(t,
|
|
609
|
-
if (!(
|
|
562
|
+
processBoxScaling(t, e = 1, s = 1) {
|
|
563
|
+
if (!(e === 1 && s === 1))
|
|
610
564
|
switch (t.tag) {
|
|
611
565
|
case "path":
|
|
612
|
-
t.hasAttr("d") && t.setAttr("d",
|
|
566
|
+
t.hasAttr("d") && t.setAttr("d", at(t.attributes.d, e));
|
|
613
567
|
break;
|
|
614
568
|
}
|
|
615
569
|
}
|
|
616
|
-
processNode(t,
|
|
617
|
-
const
|
|
618
|
-
|
|
570
|
+
processNode(t, e) {
|
|
571
|
+
const s = this.result[t].options, i = ["fit", "progress", "rendering", "modifiers"], { layers: f = [] } = this.processFeatures(t, e);
|
|
572
|
+
s.layers = [...s.layers, ...f];
|
|
619
573
|
const l = {
|
|
620
|
-
...this.processFit(
|
|
621
|
-
layers:
|
|
574
|
+
...this.processFit(e),
|
|
575
|
+
layers: f,
|
|
622
576
|
fitRatios: {
|
|
623
577
|
default: 1,
|
|
624
578
|
small: 0.84210526,
|
|
@@ -627,203 +581,453 @@ ${e}
|
|
|
627
581
|
};
|
|
628
582
|
return Array.isArray(this.options.fit) && (this.options.fit.length === 2 && ([l.fitRatios.small, l.fitRatios.large] = this.options.fit), this.options.fit[2] && ([l.fitRatios.small, l.fitRatios.default, l.fitRatios.large] = this.options.fit)), `export default {
|
|
629
583
|
setup: () => (${JSON.stringify(l)}),
|
|
630
|
-
props: ${JSON.stringify(
|
|
631
|
-
customOptions: ${JSON.stringify(
|
|
584
|
+
props: ${JSON.stringify(i)},
|
|
585
|
+
customOptions: ${JSON.stringify(s)}
|
|
632
586
|
}`;
|
|
633
587
|
}
|
|
634
588
|
processNodesIfModifiers(t) {
|
|
635
|
-
(Array.isArray(t) ? t : [t]).forEach((
|
|
636
|
-
|
|
589
|
+
(Array.isArray(t) ? t : [t]).forEach((s) => {
|
|
590
|
+
s.hasAttr("data-mod") && (s.attributes.dataMod === "default" ? s.attributes.vIf = "modifiers.includes('default') || modifiers.length === 0" : s.attributes.vIf = `modifiers.includes('${s.attributes.dataMod}')`, delete s.attributes.dataMod);
|
|
637
591
|
});
|
|
638
592
|
}
|
|
639
593
|
processPointNodes(t) {
|
|
640
|
-
t.forEach((
|
|
641
|
-
|
|
594
|
+
t.forEach((e, s) => {
|
|
595
|
+
e.attributes["data-p-i"] = `${s}`, e.addStyle(`--r-icon-p-i: ${s}`);
|
|
642
596
|
});
|
|
643
597
|
}
|
|
644
598
|
processRendering(t) {
|
|
645
|
-
var
|
|
646
|
-
const
|
|
647
|
-
t.attributes.fill && !
|
|
599
|
+
var s;
|
|
600
|
+
const e = ((s = t.attributes.dataSkipAttr) == null ? void 0 : s.split(",")) ?? [];
|
|
601
|
+
t.attributes.fill && !e.includes("fill") && (t.attributes[":fill"] = `rendering === 'original' ? '${t.attributes.fill}' : undefined`, delete t.attributes.fill), t.attributes.stroke && !e.includes("stroke") && (t.attributes[":stroke"] = `rendering === 'original' ? '${t.attributes.stroke}' : undefined`, delete t.attributes.stroke);
|
|
648
602
|
}
|
|
649
603
|
processFit(t) {
|
|
650
|
-
let
|
|
651
|
-
const
|
|
652
|
-
return t.walk((
|
|
653
|
-
var
|
|
654
|
-
if (!
|
|
655
|
-
if (
|
|
656
|
-
const { x1:
|
|
657
|
-
|
|
658
|
-
x1:
|
|
604
|
+
let e = 0, s = 0, i = 0, f = 0, l = 0;
|
|
605
|
+
const a = [], o = [], u = [], p = [], g = [], [n = 0.84210526, m = 1.16666667] = Array.isArray(this.options.fit) ? this.options.fit : [];
|
|
606
|
+
return t.walk((c) => {
|
|
607
|
+
var h;
|
|
608
|
+
if (!c.hasClass("no-fit") && ((h = c.parent) == null ? void 0 : h.tag) !== "mask") {
|
|
609
|
+
if (c.tag === "line") {
|
|
610
|
+
const { x1: d = "0", x2: b = "0", y1: y = "0", y2: v = "0" } = c.attributes;
|
|
611
|
+
u.push({
|
|
612
|
+
x1: d,
|
|
659
613
|
x2: b,
|
|
660
|
-
y1:
|
|
661
|
-
y2:
|
|
662
|
-
}),
|
|
614
|
+
y1: y,
|
|
615
|
+
y2: v
|
|
616
|
+
}), c.attributes[":x1"] = `fitLine[${i}][this.fit].x1`, c.attributes[":x2"] = `fitLine[${i}][this.fit].x2`, c.attributes[":y1"] = `fitLine[${i}][this.fit].y1`, c.attributes[":y2"] = `fitLine[${i}][this.fit].y2`, delete c.attributes.x1, delete c.attributes.x2, delete c.attributes.y1, delete c.attributes.y2, i++;
|
|
663
617
|
}
|
|
664
|
-
if (
|
|
665
|
-
const { width:
|
|
666
|
-
|
|
618
|
+
if (c.tag === "path" && c.hasAttr("d") && (a.push(c.attributes.d), c.attributes[":d"] = `fitPath[${s}][this.fit]`, s++, delete c.attributes.d), c.tag === "polyline" && (p.push(c.attributes.points), c.attributes[":points"] = `fitPolyline[${e}][this.fit]`, delete c.attributes.points, e++), c.tag === "circle" && c.hasAttr("r") && (g.push(c.attributes.r), c.attributes[":r"] = `fitCircle[${f}][this.fit]`, f++, delete c.attributes.r), c.tag === "rect" && c.hasAttr("width") && c.hasAttr("height")) {
|
|
619
|
+
const { width: d, height: b, x: y, y: v } = c.attributes;
|
|
620
|
+
o.push({ width: d, height: b, x: y, y: v }), c.attributes[":width"] = `fitRect[${l}][this.fit].width`, c.attributes[":height"] = `fitRect[${l}][this.fit].height`, c.attributes[":x"] = `fitRect[${l}][this.fit].x`, c.attributes[":y"] = `fitRect[${l}][this.fit].y`, l++, delete c.attributes.width, delete c.attributes.height, delete c.attributes.x, delete c.attributes.y;
|
|
667
621
|
}
|
|
668
622
|
}
|
|
669
623
|
}), {
|
|
670
|
-
fitPolyline:
|
|
671
|
-
...
|
|
624
|
+
fitPolyline: p.reduce((c, h) => [
|
|
625
|
+
...c,
|
|
672
626
|
{
|
|
673
|
-
default:
|
|
674
|
-
small:
|
|
675
|
-
large:
|
|
627
|
+
default: h,
|
|
628
|
+
small: D(X(h, n, n), -F(n), -F(n)),
|
|
629
|
+
large: D(X(h, m, m), -F(m), -F(m))
|
|
676
630
|
}
|
|
677
631
|
], []),
|
|
678
|
-
fitLine:
|
|
679
|
-
...
|
|
632
|
+
fitLine: u.reduce((c, h) => [
|
|
633
|
+
...c,
|
|
680
634
|
{
|
|
681
|
-
default:
|
|
682
|
-
small:
|
|
683
|
-
large:
|
|
635
|
+
default: h,
|
|
636
|
+
small: tt(h, n, [480, 480]),
|
|
637
|
+
large: tt(h, m, [480, 480])
|
|
684
638
|
}
|
|
685
639
|
], []),
|
|
686
|
-
fitPath:
|
|
687
|
-
...
|
|
640
|
+
fitPath: a.reduce((c, h) => [
|
|
641
|
+
...c,
|
|
688
642
|
{
|
|
689
|
-
default:
|
|
690
|
-
small:
|
|
691
|
-
large:
|
|
643
|
+
default: h,
|
|
644
|
+
small: ot(h, n),
|
|
645
|
+
large: ot(h, m)
|
|
692
646
|
}
|
|
693
647
|
], []),
|
|
694
|
-
fitRect:
|
|
695
|
-
...
|
|
648
|
+
fitRect: o.reduce((c, h) => [
|
|
649
|
+
...c,
|
|
696
650
|
{
|
|
697
|
-
default:
|
|
698
|
-
small:
|
|
699
|
-
large:
|
|
651
|
+
default: h,
|
|
652
|
+
small: et(h, n, [480, 480]),
|
|
653
|
+
large: et(h, m, [480, 480])
|
|
700
654
|
}
|
|
701
655
|
], []),
|
|
702
|
-
fitCircle:
|
|
703
|
-
...
|
|
656
|
+
fitCircle: g.reduce((c, h) => [
|
|
657
|
+
...c,
|
|
704
658
|
{
|
|
705
|
-
default:
|
|
706
|
-
small: (+
|
|
707
|
-
large: (+
|
|
659
|
+
default: h,
|
|
660
|
+
small: (+h * n).toFixed(3),
|
|
661
|
+
large: (+h * m).toFixed(3)
|
|
708
662
|
}
|
|
709
663
|
], [])
|
|
710
664
|
};
|
|
711
665
|
}
|
|
712
|
-
processFeatures(t,
|
|
713
|
-
const
|
|
714
|
-
return
|
|
715
|
-
const
|
|
666
|
+
processFeatures(t, e) {
|
|
667
|
+
const s = [], i = [], f = [], l = [], a = /* @__PURE__ */ new Set();
|
|
668
|
+
return e.walk((o) => {
|
|
669
|
+
const u = rt.includes(o.tag), p = o.tag === "g";
|
|
716
670
|
if (!o.hasAttr("data-skip")) {
|
|
717
671
|
if (o.hasAttr("data-layer")) {
|
|
718
|
-
|
|
719
|
-
const
|
|
720
|
-
o.addStyle(`--r-icon-l-i: ${
|
|
672
|
+
a.add(o.attributes.dataLayer);
|
|
673
|
+
const g = [...a].indexOf(o.attributes.dataLayer);
|
|
674
|
+
o.addStyle(`--r-icon-l-i: ${g}`), o.attributes["data-l-i"] = g.toString();
|
|
721
675
|
}
|
|
722
|
-
if (o.hasClass("no-progress") &&
|
|
723
|
-
const
|
|
724
|
-
|
|
676
|
+
if (o.hasClass("no-progress") && f.push(o), o.tag === "mask" && l.push(o), u || p) {
|
|
677
|
+
const g = o.attributes.class && o.attributes.class.indexOf("no-progress") > -1;
|
|
678
|
+
p && o.hasAttr("data-group") && (s.push(o), i.push(o), delete o.attributes.dataGroup), u && !o.isChildOf(i) && (g || s.push(o)), o.isChildOf(l) || this.processRendering(o);
|
|
725
679
|
}
|
|
726
680
|
this.processNodesIfModifiers(o);
|
|
727
681
|
}
|
|
728
|
-
}),
|
|
729
|
-
|
|
730
|
-
const d = ((100 / r.length || 1) * (g + 1)).toFixed(3);
|
|
731
|
-
o.attributes["data-p-on"] = d, o.attributes[":opacity"] = `(progress ?? 100) >= ${d} ? 1 : .2`;
|
|
732
|
-
}
|
|
733
|
-
}), {
|
|
734
|
-
layers: p
|
|
682
|
+
}), e.addStyle(`--r-icon-l-c: ${a.size}`), e.addStyle(`--r-icon-p-c: ${s.length}`), this.processPointNodes(s), this.applyProgress(t, s, f, l), {
|
|
683
|
+
layers: a
|
|
735
684
|
};
|
|
736
685
|
}
|
|
686
|
+
/** Applies the legacy progress behavior; the next transformer supplies its own compiled program. */
|
|
687
|
+
applyProgress(t, e, s, i) {
|
|
688
|
+
this.result[t].options.flags.includes("no-progress") || e.forEach((f, l) => {
|
|
689
|
+
if (!f.isChildOf([...s, ...i])) {
|
|
690
|
+
const a = ((100 / e.length || 1) * (l + 1)).toFixed(3);
|
|
691
|
+
f.attributes["data-p-on"] = a, f.attributes[":opacity"] = `(progress ?? 100) >= ${a} ? 1 : .2`;
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
}
|
|
737
695
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
696
|
+
class Wt extends zt {
|
|
697
|
+
/** Consumes an already compiled progress template from the next loader. */
|
|
698
|
+
processPrepared(t, e) {
|
|
699
|
+
return this.processCompiled(t, e, this.options);
|
|
700
|
+
}
|
|
701
|
+
/** Transforms author declarations into a component with one shared reactive progress value. */
|
|
702
|
+
process(t, e = "", s = this.options) {
|
|
703
|
+
return this.processCompiled(t, lt(e, t), s);
|
|
704
|
+
}
|
|
705
|
+
/** Compiles composition-owned progress without automatically progressing each source body. */
|
|
706
|
+
processVirtual(t, e, s) {
|
|
707
|
+
return this.processCompiled(t, ft(e, s, t), this.options);
|
|
708
|
+
}
|
|
709
|
+
/** Adds one computed normalization per component while preserving the existing generated setup data. */
|
|
710
|
+
processCompiled(t, e, s) {
|
|
711
|
+
const i = x.parseAsSingle(e), f = i == null ? void 0 : i.attributes.transform, l = super.process(t, e, s);
|
|
712
|
+
if (f && (l.template = l.template.replace(/^<g(?=[\s>])/, `<g transform="${f}"`)), i != null && i.attributes.dataModifiers) {
|
|
713
|
+
const a = x.parseAsSingle(l.template);
|
|
714
|
+
a.walk((o) => {
|
|
715
|
+
if (!["path", "rect", "circle", "ellipse", "line", "polyline", "polygon"].includes(o.tag)) return;
|
|
716
|
+
const u = "{ '--ui0-icon-state': modifiers.join('|') }", p = o.attributes[":style"];
|
|
717
|
+
o.attributes[":style"] = p ? `[${p}, ${u}]` : u;
|
|
718
|
+
}), l.template = a.serialize();
|
|
748
719
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
const
|
|
755
|
-
|
|
720
|
+
return l.script = `import { computed as __iconComputed } from 'vue'
|
|
721
|
+
const __iconNormalize = ${Tt.toString()}
|
|
722
|
+
${l.script}`.replace(
|
|
723
|
+
/setup: \(\) => \((.*?)\),\n props:/s,
|
|
724
|
+
(a, o) => {
|
|
725
|
+
const u = JSON.parse(o);
|
|
726
|
+
for (const p of Object.values(u)) {
|
|
727
|
+
const g = Array.isArray(p) ? p : [p];
|
|
728
|
+
for (const n of g)
|
|
729
|
+
n && typeof n == "object" && "default" in n && (n.normal = n.default);
|
|
730
|
+
}
|
|
731
|
+
return `setup: (__props) => ({ ...(${JSON.stringify(u)}), iconProgressValue: __iconComputed(() => __iconNormalize(__props.progress, import.meta.env.DEV ? console.warn : undefined)) }),
|
|
732
|
+
props:`;
|
|
733
|
+
}
|
|
734
|
+
), l;
|
|
735
|
+
}
|
|
736
|
+
/** Declarative progress is already compiled; skip the legacy automatic opacity rewrite. */
|
|
737
|
+
applyProgress() {
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
function ut(r) {
|
|
741
|
+
return "file" in r;
|
|
742
|
+
}
|
|
743
|
+
function Vt(r) {
|
|
744
|
+
const t = r.indexOf("?"), e = t === -1 ? void 0 : r.slice(t), s = t === -1 ? r : r.slice(0, t), i = s.indexOf("#"), f = i === -1 ? s : s.slice(0, i), [l, ...a] = f.split("."), o = i === -1 ? void 0 : s.slice(i + 1);
|
|
745
|
+
return {
|
|
746
|
+
name: l,
|
|
747
|
+
cell: o,
|
|
748
|
+
query: e,
|
|
749
|
+
modifiers: a.length ? a.map((u) => u.replace(/:/g, "-")) : void 0
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
const Gt = `<svg width="960" height="960" viewBox="0 0 960 960">>
|
|
753
|
+
<path class="no-fill" d="M340 340 C494.6 340 620 465.4 620 620" />
|
|
754
|
+
</svg>
|
|
755
|
+
`, qt = `<svg width="960" height="960" viewBox="0 0 960 960">
|
|
756
|
+
<path class="no-fill" d="M480 600 L480 360 M480 360 L395.1 444.9 M480 360 L564.9 444.9"/>
|
|
757
|
+
</svg>
|
|
758
|
+
`, Dt = `<svg width="960" height="960" viewBox="0 0 960 960">
|
|
759
|
+
|
|
760
|
+
<polyline points="347.69,546.155 480,413.845 612.31,546.155"/>
|
|
761
|
+
|
|
762
|
+
</svg>
|
|
763
|
+
`, Ut = `<svg viewBox="0 0 960 960">
|
|
764
|
+
<circle cx="480" cy="480" r="320"/>
|
|
765
|
+
</svg>
|
|
766
|
+
`, Jt = `<svg>
|
|
767
|
+
<path class="no-fill" d="M480,480h280c0,74.2-29.5,145.5-82,198-52.5,52.5-123.8,82-198,82v-280Z"/>
|
|
768
|
+
</svg>
|
|
769
|
+
`, Zt = `<svg viewBox="0 0 960 960"><circle cx="480" cy="480" r="60"/></svg>
|
|
770
|
+
`, Ht = `<svg data-icon="utility no-progress" viewBox="0 0 960 960">
|
|
771
|
+
<path d="M441.3,253.9c17.2-29.8,60.2-29.8,77.4,0l117.6,203.8,117.6,203.8c17.2,29.8-4.3,67-38.7,67H244.7c-34.4,0-55.9-37.2-38.7-67l117.6-203.8,117.6-203.8Z"/>
|
|
772
|
+
</svg>
|
|
773
|
+
`, V = {
|
|
774
|
+
"arc-90": Gt,
|
|
775
|
+
arrow: qt,
|
|
776
|
+
chevron: Dt,
|
|
777
|
+
circle: Ut,
|
|
778
|
+
"pie-90": Jt,
|
|
779
|
+
point: Zt,
|
|
780
|
+
triangle: Ht
|
|
781
|
+
};
|
|
782
|
+
class Kt {
|
|
783
|
+
constructor(t, e, s) {
|
|
784
|
+
I(this, "files", /* @__PURE__ */ new Map());
|
|
785
|
+
this.options = t, this.root = e, this.warn = s;
|
|
786
|
+
}
|
|
787
|
+
/** Indexes configured directories and rejects duplicate assets or reserved pack overrides. */
|
|
788
|
+
scan() {
|
|
789
|
+
var e;
|
|
790
|
+
if (this.files.clear(), ((e = this.options.packs) == null ? void 0 : e.blocks) !== void 0) throw new Error("[ui0-icon] packs.blocks cannot override the built-in pack");
|
|
791
|
+
const t = typeof this.options.dir == "string" ? [this.options.dir] : this.options.dir ?? [];
|
|
792
|
+
for (const s of t) this.scanDirectory("assets", k.resolve(this.root, s));
|
|
793
|
+
for (const [s, i] of Object.entries(this.options.packs ?? {}))
|
|
794
|
+
typeof i == "string" && this.scanDirectory(s, k.resolve(this.root, i));
|
|
795
|
+
}
|
|
796
|
+
/** Registers every nested SVG with a path relative to its configured directory. */
|
|
797
|
+
scanDirectory(t, e, s = "") {
|
|
798
|
+
for (const i of Ft(k.join(e, s), { withFileTypes: !0 })) {
|
|
799
|
+
const f = k.posix.join(s, i.name);
|
|
800
|
+
if (i.isDirectory()) this.scanDirectory(t, e, f);
|
|
801
|
+
else if (i.isFile() && f.endsWith(".svg")) {
|
|
802
|
+
const l = `${t}/${f.slice(0, -4)}`, a = k.join(e, f);
|
|
803
|
+
if (this.files.has(l)) throw new Error(`[ui0-icon] duplicate source '${l}'`);
|
|
804
|
+
this.files.set(l, a);
|
|
756
805
|
}
|
|
757
|
-
const m = (i.sources ?? []).map((S) => C(I.join(S, h + y))).find(Boolean);
|
|
758
|
-
return { def: f, svg: m };
|
|
759
806
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
807
|
+
}
|
|
808
|
+
/** Finds a file-backed icon name for ordinary imports within the configured source roots. */
|
|
809
|
+
nameOfFile(t) {
|
|
810
|
+
for (const [e, s] of this.files) if (k.resolve(s) === k.resolve(t)) return e;
|
|
811
|
+
}
|
|
812
|
+
/** Checks whether the next loader owns a complete icon name. */
|
|
813
|
+
has(t) {
|
|
763
814
|
var f;
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
815
|
+
const e = t.indexOf("/"), s = t.slice(0, e), i = t.slice(e + 1);
|
|
816
|
+
return this.files.has(t) || s === "blocks" && i in V || s === "virtual" && i in (this.options.virtual ?? {}) || typeof ((f = this.options.packs) == null ? void 0 : f[s]) == "object" && i in this.options.packs[s];
|
|
817
|
+
}
|
|
818
|
+
/** Reads one registered source and records its actual filesystem dependencies. */
|
|
819
|
+
read(t) {
|
|
820
|
+
var a, o;
|
|
821
|
+
const e = t.indexOf("/"), s = t.slice(0, e), i = t.slice(e + 1);
|
|
822
|
+
if (s === "virtual") {
|
|
823
|
+
const u = (a = this.options.virtual) == null ? void 0 : a[i];
|
|
824
|
+
if (!u) throw new Error(`[ui0-icon] unknown source '${t}'`);
|
|
825
|
+
if (ut(u)) {
|
|
826
|
+
if (u.file.trimStart().startsWith("<")) return { svg: u.file, definition: u, files: /* @__PURE__ */ new Set() };
|
|
827
|
+
const p = k.resolve(this.root, u.file);
|
|
828
|
+
return { svg: z(p, "utf8"), definition: u, files: /* @__PURE__ */ new Set([p]) };
|
|
829
|
+
}
|
|
830
|
+
return { definition: u, files: /* @__PURE__ */ new Set() };
|
|
831
|
+
}
|
|
832
|
+
if (s === "blocks" && V[i]) return { svg: V[i], files: /* @__PURE__ */ new Set() };
|
|
833
|
+
const f = (o = this.options.packs) == null ? void 0 : o[s];
|
|
834
|
+
if (f && typeof f == "object" && i in f) {
|
|
835
|
+
const u = f[i];
|
|
836
|
+
if (this.files.has(t) && this.warn(`[ui0-icon] packs.${s}.${i} overrides the directory source`), typeof u != "string") throw new Error(`[ui0-icon] '${t}' must retain an SVG file reference`);
|
|
837
|
+
const p = k.resolve(this.root, u);
|
|
838
|
+
return { svg: z(p, "utf8"), files: /* @__PURE__ */ new Set([p]) };
|
|
839
|
+
}
|
|
840
|
+
const l = this.files.get(t);
|
|
841
|
+
if (!l) throw new Error(`[ui0-icon] unknown source '${t}'`);
|
|
842
|
+
return { svg: z(l, "utf8"), files: /* @__PURE__ */ new Set([l]) };
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
function pt(r, t, e) {
|
|
846
|
+
const s = r.attributes.viewBox === void 0 ? [0, 0, t, t] : r.attributes.viewBox.trim().split(/[\s,]+/).map(Number);
|
|
847
|
+
if (s.length !== 4 || s.some((i) => !Number.isFinite(i)) || s[2] <= 0 || s[3] <= 0)
|
|
848
|
+
throw new Error(`[ui0-icon] ${e}: invalid viewBox`);
|
|
849
|
+
return s;
|
|
850
|
+
}
|
|
851
|
+
function Qt(r) {
|
|
852
|
+
const t = { ...r.attributes };
|
|
853
|
+
return delete t.viewBox, delete t.width, delete t.height, x.createNode({ tag: "g", attributes: t, children: r.children, content: r.content }).serialize();
|
|
854
|
+
}
|
|
855
|
+
function dt(r, t, e, s, i = /* @__PURE__ */ new Set()) {
|
|
856
|
+
var m;
|
|
857
|
+
if (i.has(r)) throw new Error(`[ui0-icon] ${r}: cyclic composition`);
|
|
858
|
+
const f = new Set(i).add(r), l = t.read(r);
|
|
859
|
+
if (!l.definition || ut(l.definition))
|
|
860
|
+
return { svg: l.svg, files: l.files, virtual: !1 };
|
|
861
|
+
const a = l.definition, { rows: o, cols: u } = a;
|
|
862
|
+
if (![o, u].every((c) => Number.isSafeInteger(c) && c > 0))
|
|
863
|
+
throw new Error(`[ui0-icon] ${r}: rows and cols must be positive integers`);
|
|
864
|
+
const p = [], g = new Set(l.files);
|
|
865
|
+
for (const [c, h] of Object.entries(a.cells)) {
|
|
866
|
+
if (h === void 0) continue;
|
|
867
|
+
const d = `${r} cell ${c}`, b = c.split("-").map(Number), [y, v] = b;
|
|
868
|
+
if (b.length !== 2 || !b.every(Number.isSafeInteger) || y < 1 || y > o || v < 1 || v > u)
|
|
869
|
+
throw new Error(`[ui0-icon] ${d}: cell is outside ${o}x${u}`);
|
|
870
|
+
const w = typeof h == "string" ? { value: h } : h, { rows: E, cols: N } = w.span ?? { rows: 1, cols: 1 };
|
|
871
|
+
if (![E, N].every((A) => Number.isSafeInteger(A) && A > 0))
|
|
872
|
+
throw new Error(`[ui0-icon] ${d}: span rows and cols must be positive integers`);
|
|
873
|
+
if (E > o - y + 1 || N > u - v + 1)
|
|
874
|
+
throw new Error(`[ui0-icon] ${d}: span ${E}x${N} is outside ${o}x${u}`);
|
|
875
|
+
const S = Vt(w.value), C = Object.fromEntries(new URLSearchParams(S.query));
|
|
876
|
+
if ("weight" in w || C.weight !== void 0) throw new Error(`[ui0-icon] ${d}: local weight is forbidden`);
|
|
877
|
+
if ("shape" in w || "badge" in w || C.shape !== void 0 || C.badge !== void 0)
|
|
878
|
+
throw new Error(`[ui0-icon] ${d}: shape and badge belong to the complete icon`);
|
|
879
|
+
if ("progress" in w || C.progress !== void 0)
|
|
880
|
+
throw new Error(`[ui0-icon] ${d}: progress belongs to the composition program`);
|
|
881
|
+
w.cell === "full" && s(`[ui0-icon] ${d}: cell:'full' is deprecated and has no placement effect`);
|
|
882
|
+
for (const A of ["fit", "rotate", "flipped", "filled", "rendering", "modifiers"])
|
|
883
|
+
w[A] !== void 0 && C[A] !== void 0 && String(w[A]) !== C[A] && s(`[ui0-icon] ${d}: ${A}=${String(w[A])} overrides value parameter ${C[A]}`);
|
|
884
|
+
let L;
|
|
885
|
+
try {
|
|
886
|
+
L = dt(S.name, t, e, s, f);
|
|
887
|
+
} catch (A) {
|
|
888
|
+
throw new Error(`[ui0-icon] ${d} source '${S.name}': ${String(A)}`);
|
|
889
|
+
}
|
|
890
|
+
L.files.forEach((A) => g.add(A));
|
|
891
|
+
const Z = x.parseAsSingle(L.svg), [ht, gt, _, M] = pt(Z, e, `${d} source ${S.name}`), R = w.rotate ?? Number(C.rotate ?? 0);
|
|
892
|
+
if (!Number.isFinite(R)) throw new Error(`[ui0-icon] ${d}: invalid rotate`);
|
|
893
|
+
const H = Math.abs(R % 180) === 90, mt = H ? M / _ : _ / M, bt = N * o / (E * u);
|
|
894
|
+
if (Math.abs(mt - bt) > 1e-6)
|
|
895
|
+
throw new Error(`[ui0-icon] ${d} source ${S.name}: source proportions do not match the placement area`);
|
|
896
|
+
const j = w.fit ?? C.fit ?? "normal", K = { normal: 1, default: 1, small: 0.84210526, large: 1.16666667 };
|
|
897
|
+
if (!(j in K)) throw new Error(`[ui0-icon] ${d}: unknown fit '${j}'`);
|
|
898
|
+
const T = e * 0.75 * N / u / ((H ? M : _) * 0.75) * K[j], vt = e * 0.125 + (v - 1 + N / 2) * e * 0.75 / u, wt = e * 0.125 + (y - 1 + E / 2) * e * 0.75 / o, $t = w.flipped ?? C.flipped === "true", Q = w.filled ?? (C.filled === "true" || ((m = S.modifiers) == null ? void 0 : m.some((A) => ["fill", "filled"].includes(A)))), yt = typeof w.modifiers == "string" ? w.modifiers.split(/[\s,]+/) : w.modifiers ?? [], Y = {
|
|
899
|
+
dataCell: c,
|
|
900
|
+
transform: `translate(${vt} ${wt}) scale(${$t ? -T : T} ${T}) rotate(${R}) translate(${-ht - _ / 2} ${-gt - M / 2})`,
|
|
901
|
+
class: [...S.modifiers ?? [], ...yt].join(" ")
|
|
902
|
+
};
|
|
903
|
+
Q !== void 0 && (Y.style = `fill:${Q ? "var(--0-icon-fill-color, currentColor)" : "none"}`);
|
|
904
|
+
const xt = Qt(Z).replaceAll("iconProgressValue", "100");
|
|
905
|
+
p.push(x.createNode({ tag: "g", attributes: Y, content: xt }).serialize());
|
|
906
|
+
}
|
|
907
|
+
const n = `<svg viewBox="0 0 ${e} ${e}">${p.join("")}</svg>`;
|
|
908
|
+
return { svg: ft(n, a, r), files: g, virtual: !0 };
|
|
909
|
+
}
|
|
910
|
+
function Yt(r, t, e) {
|
|
911
|
+
const s = x.parseAsSingle(r);
|
|
912
|
+
if (!s || s.tag !== "svg") throw new Error(`[ui0-icon] ${e}: expected SVG root`);
|
|
913
|
+
const [i, f, l, a] = pt(s, t, e), o = 960 / Math.max(l, a);
|
|
914
|
+
if (s.attributes.viewBox = "0 0 960 960", i !== 0 || f !== 0 || l !== 960 || a !== 960) {
|
|
915
|
+
const u = `translate(480 480) scale(${o}) translate(${-i - l / 2} ${-f - a / 2})`;
|
|
916
|
+
s.attributes.transform = `${u} ${s.attributes.transform ?? ""}`.trim();
|
|
917
|
+
}
|
|
918
|
+
return s.serialize();
|
|
919
|
+
}
|
|
920
|
+
const G = "virtual:ui0-icon-next/", O = "\0ui0-icon-next/", q = "/@ui0-icon-next/";
|
|
921
|
+
function oe(r = {}) {
|
|
922
|
+
let t = "";
|
|
923
|
+
const e = r.size ?? 960;
|
|
924
|
+
if (!Number.isFinite(e) || e <= 0) throw new Error("[ui0-icon] size must be a positive number");
|
|
925
|
+
let s;
|
|
926
|
+
const i = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), l = new Wt({ fit: r.fit ?? !0, rescaling: !1 });
|
|
769
927
|
return {
|
|
770
928
|
name: "vite:ui0-icon",
|
|
771
929
|
enforce: "pre",
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
return d;
|
|
775
|
-
if (yt.test(d)) {
|
|
776
|
-
const h = ht(d);
|
|
777
|
-
if (n) return `${A}${dt(n) + h}`;
|
|
778
|
-
}
|
|
930
|
+
configResolved(a) {
|
|
931
|
+
t = a.root, s = new Kt(r, t, (o) => a.logger.warn(o)), s.scan();
|
|
779
932
|
},
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
if (
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
}
|
|
787
|
-
if (d.startsWith(A) && d.indexOf("?vue") > -1) {
|
|
788
|
-
const b = g(h);
|
|
789
|
-
return b !== void 0 && ((f = i.virtual) != null && f[N(h)]) && c.set(d, N(h)), p.process(h, b ?? ""), ((x = p.result[h]) == null ? void 0 : x.sfc.style) ?? "";
|
|
790
|
-
}
|
|
933
|
+
resolveId(a, o) {
|
|
934
|
+
if (a.startsWith(q) || a.startsWith(O)) return a;
|
|
935
|
+
if (a.startsWith(G)) return O + decodeURIComponent(a.slice(G.length));
|
|
936
|
+
if (!o || !/\.svg(?:\?icon)?$/.test(a)) return;
|
|
937
|
+
const u = a.replace(/\?icon$/, ""), p = k.isAbsolute(u) ? u : k.resolve(k.dirname(o.split("?")[0]), u), g = s.nameOfFile(p) ?? (u.startsWith("/") ? s.nameOfFile(k.join(t, u)) : void 0);
|
|
938
|
+
if (g) return O + g;
|
|
791
939
|
},
|
|
792
|
-
|
|
793
|
-
if (
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
940
|
+
load(a) {
|
|
941
|
+
if (a.startsWith(q)) return f.get(a) ?? "";
|
|
942
|
+
if (!a.startsWith(O)) return;
|
|
943
|
+
const o = a.slice(O.length), u = dt(o, s, e, (d) => this.warn(d));
|
|
944
|
+
i.set(a, u.files), u.files.forEach((d) => this.addWatchFile(d));
|
|
945
|
+
const p = u.virtual ? u.svg : lt(u.svg, o), g = l.processPrepared(o, Yt(p, e, o)), n = Nt("sha256").update(o).digest("hex").slice(0, 12), m = `data-v-${n}`, c = Et({ source: g.template, filename: `${o}.vue`, id: m, scoped: !!g.style });
|
|
946
|
+
if (c.errors.length) throw c.errors[0];
|
|
947
|
+
let h = "";
|
|
948
|
+
if (g.style) {
|
|
949
|
+
const d = kt(k.join(t, "package.json")), b = Pt({
|
|
950
|
+
source: g.style,
|
|
951
|
+
filename: `${o}.scss`,
|
|
952
|
+
id: m,
|
|
953
|
+
scoped: !0,
|
|
954
|
+
preprocessLang: "scss",
|
|
955
|
+
preprocessCustomRequire: (v) => {
|
|
956
|
+
if (v !== "sass") return d(v);
|
|
957
|
+
try {
|
|
958
|
+
return d("sass-embedded");
|
|
959
|
+
} catch {
|
|
960
|
+
return d("sass");
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
if (b.errors.length) throw b.errors[0];
|
|
965
|
+
const y = `${q}${n}.css`;
|
|
966
|
+
f.set(y, b.code), h += `import ${JSON.stringify(y)}
|
|
967
|
+
`;
|
|
968
|
+
}
|
|
969
|
+
return h += g.script.replace("export default", "const _body =") + `
|
|
970
|
+
`, h += c.code.replace("export function render", "function render"), h += `
|
|
971
|
+
_body.render = render
|
|
972
|
+
`, g.style && (h += `_body.__scopeId = ${JSON.stringify(m)}
|
|
973
|
+
`), h + `export default _body
|
|
974
|
+
`;
|
|
802
975
|
},
|
|
803
|
-
|
|
804
|
-
var
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
976
|
+
transform(a, o) {
|
|
977
|
+
var b, y;
|
|
978
|
+
if (!o.endsWith(".vue")) return;
|
|
979
|
+
const { descriptor: u, errors: p } = Ct(a, { filename: o });
|
|
980
|
+
if (p.length || !((b = u.template) != null && b.ast)) return;
|
|
981
|
+
const g = /* @__PURE__ */ new Set(), n = (v) => {
|
|
982
|
+
var w, E;
|
|
983
|
+
if (v.type === 1 && ["Icon", "icon", "Ui0Icon", "ui0-icon"].includes(v.tag ?? ""))
|
|
984
|
+
for (const N of v.props ?? []) {
|
|
985
|
+
if (N.type === 6 && ["value", "badge"].includes(N.name) && N.value) {
|
|
986
|
+
const S = N.value.content.split(/[.?]/, 1)[0];
|
|
987
|
+
if (s.has(S)) g.add(S);
|
|
988
|
+
else if (/^(assets|virtual|blocks)\//.test(S) || S.split("/")[0] in (r.packs ?? {}))
|
|
989
|
+
throw new Error(`[ui0-icon] ${o}: unknown source '${S}'`);
|
|
990
|
+
}
|
|
991
|
+
if (N.type === 7 && N.name === "bind" && ((w = N.arg) == null ? void 0 : w.content) === "value")
|
|
992
|
+
for (const S of Object.keys(r.virtual ?? {})) g.add(`virtual/${S}`);
|
|
993
|
+
}
|
|
994
|
+
(E = v.children) == null || E.forEach(n);
|
|
995
|
+
};
|
|
996
|
+
if (n(u.template.ast), !g.size) return;
|
|
997
|
+
const m = [...g].map((v, w) => `import __ui0Body${w} from ${JSON.stringify(G + encodeURIComponent(v))}`).join(`
|
|
998
|
+
`), c = [...g].map((v, w) => `${JSON.stringify(v)}: __ui0Body${w}`).join(","), h = `
|
|
999
|
+
import { provide as __ui0Provide, inject as __ui0Inject } from 'vue'
|
|
1000
|
+
${m}
|
|
1001
|
+
const __ui0Key = Symbol.for('ui0-icon-generated')
|
|
1002
|
+
__ui0Provide(__ui0Key, { ...__ui0Inject(__ui0Key, {}), ${c} })
|
|
1003
|
+
`;
|
|
1004
|
+
if (u.scriptSetup) {
|
|
1005
|
+
const v = u.scriptSetup.loc.start.offset;
|
|
1006
|
+
return { code: a.slice(0, v) + h + a.slice(v), map: null };
|
|
817
1007
|
}
|
|
818
|
-
const
|
|
819
|
-
return
|
|
1008
|
+
const d = (y = u.script) != null && y.lang ? ` lang="${u.script.lang}"` : "";
|
|
1009
|
+
return { code: `${a}
|
|
1010
|
+
<script setup${d}>${h}<\/script>`, map: null };
|
|
820
1011
|
},
|
|
821
|
-
|
|
822
|
-
|
|
1012
|
+
handleHotUpdate(a) {
|
|
1013
|
+
s.scan();
|
|
1014
|
+
const o = [];
|
|
1015
|
+
for (const [u, p] of i) {
|
|
1016
|
+
if (!p.has(a.file)) continue;
|
|
1017
|
+
const g = a.server.moduleGraph.getModuleById(u);
|
|
1018
|
+
g && o.push(g);
|
|
1019
|
+
}
|
|
1020
|
+
for (const u of f.keys()) {
|
|
1021
|
+
const p = a.server.moduleGraph.getModuleById(u);
|
|
1022
|
+
p && o.length && o.push(p);
|
|
1023
|
+
}
|
|
1024
|
+
if (o.length) return o;
|
|
823
1025
|
}
|
|
824
1026
|
};
|
|
825
1027
|
}
|
|
826
1028
|
export {
|
|
827
|
-
|
|
828
|
-
|
|
1029
|
+
oe as ViteUi0Icon,
|
|
1030
|
+
oe as ViteUi0IconNext,
|
|
1031
|
+
oe as default,
|
|
1032
|
+
ut as isVirtualTemplate
|
|
829
1033
|
};
|