@eturnity/eturnity_reusable_components 9.19.8 → 9.19.9
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/package.json
CHANGED
|
@@ -250,7 +250,12 @@
|
|
|
250
250
|
const icon = reactive({ html: '' })
|
|
251
251
|
|
|
252
252
|
const loadSvg = async () => {
|
|
253
|
-
|
|
253
|
+
const raw = props.name
|
|
254
|
+
if (raw == null || String(raw).trim() === '') {
|
|
255
|
+
icon.html = ''
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
let svgString = await fetchIcon(String(raw).toLowerCase())
|
|
254
259
|
if (props.svgRotation) svgString = rotateSvg(svgString, props.svgRotation)
|
|
255
260
|
icon.html = svgString
|
|
256
261
|
}
|
|
@@ -1,23 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load SVG icon markup by file stem (lowercase), matching files in
|
|
3
|
+
* `src/assets/svgIcons/<stem>.svg`.
|
|
4
|
+
*
|
|
5
|
+
* Uses `import.meta.glob` instead of `new URL(..., import.meta.url)` + `fetch`
|
|
6
|
+
* so Vite does not emit a broken asset URL when this package is linked via
|
|
7
|
+
* `@fs/...` (which previously produced requests like `.../icon/undefined`).
|
|
8
|
+
*/
|
|
9
|
+
const rawIconModules = import.meta.glob('../../assets/svgIcons/*.svg', {
|
|
10
|
+
query: '?raw',
|
|
11
|
+
import: 'default',
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const iconLoadersByStem = {}
|
|
15
|
+
for (const path of Object.keys(rawIconModules)) {
|
|
16
|
+
const normalized = path.replace(/\\/g, '/')
|
|
17
|
+
const match = normalized.match(/\/([^/]+)\.svg$/i)
|
|
18
|
+
if (!match) continue
|
|
19
|
+
iconLoadersByStem[match[1].toLowerCase()] = rawIconModules[path]
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
const iconCache = {}
|
|
2
23
|
|
|
3
24
|
export const fetchIcon = async (fileName) => {
|
|
4
|
-
if (
|
|
5
|
-
|
|
25
|
+
if (fileName == null) {
|
|
26
|
+
console.warn('fetchIcon called with null or undefined fileName')
|
|
27
|
+
return ''
|
|
6
28
|
}
|
|
7
29
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
).href
|
|
30
|
+
const stem = String(fileName).trim().toLowerCase()
|
|
31
|
+
if (!stem) {
|
|
32
|
+
return ''
|
|
33
|
+
}
|
|
13
34
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
35
|
+
if (iconCache[stem]) {
|
|
36
|
+
return iconCache[stem]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const loader = iconLoadersByStem[stem]
|
|
40
|
+
if (!loader) {
|
|
41
|
+
console.error(`Unknown icon SVG: ${stem}.svg`)
|
|
42
|
+
return ''
|
|
43
|
+
}
|
|
18
44
|
|
|
45
|
+
try {
|
|
46
|
+
const rawFile = await loader()
|
|
47
|
+
iconCache[stem] = rawFile
|
|
19
48
|
return rawFile
|
|
20
49
|
} catch (error) {
|
|
21
|
-
console.error(`Failed to load ${
|
|
50
|
+
console.error(`Failed to load ${stem}.svg`, error)
|
|
51
|
+
return ''
|
|
22
52
|
}
|
|
23
53
|
}
|
|
@@ -142,6 +142,7 @@
|
|
|
142
142
|
>
|
|
143
143
|
<IconCell :is-collapsed="isCollapsed">
|
|
144
144
|
<IconComponent
|
|
145
|
+
v-if="item.icon"
|
|
145
146
|
:color="
|
|
146
147
|
item.id === activeItemId
|
|
147
148
|
? theme.semanticColors.purple[500]
|
|
@@ -187,6 +188,7 @@
|
|
|
187
188
|
>
|
|
188
189
|
<IconCell :is-collapsed="isCollapsed">
|
|
189
190
|
<IconComponent
|
|
191
|
+
v-if="item.icon"
|
|
190
192
|
:color="
|
|
191
193
|
item.id === activeParentId
|
|
192
194
|
? theme.semanticColors.purple[500]
|