@eturnity/eturnity_reusable_components 9.19.7 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "9.19.7",
3
+ "version": "9.19.9",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -250,7 +250,12 @@
250
250
  const icon = reactive({ html: '' })
251
251
 
252
252
  const loadSvg = async () => {
253
- let svgString = await fetchIcon(props.name.toLowerCase())
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 (iconCache[fileName]) {
5
- return iconCache[fileName]
25
+ if (fileName == null) {
26
+ console.warn('fetchIcon called with null or undefined fileName')
27
+ return ''
6
28
  }
7
29
 
8
- // We need to use "new URL" to load dynamic assets (https://vitejs.dev/guide/assets.html#new-url-url-import-meta-url)
9
- const fetchUrl = new URL(
10
- `../../assets/svgIcons/${fileName}.svg`,
11
- import.meta.url
12
- ).href
30
+ const stem = String(fileName).trim().toLowerCase()
31
+ if (!stem) {
32
+ return ''
33
+ }
13
34
 
14
- try {
15
- const response = await fetch(fetchUrl)
16
- const rawFile = await response.text()
17
- iconCache[fileName] = rawFile
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 ${fileName}.svg`)
50
+ console.error(`Failed to load ${stem}.svg`, error)
51
+ return ''
22
52
  }
23
53
  }
@@ -49,45 +49,46 @@
49
49
  @on-dropdown-close="onResponsibleSelectDropdownClose"
50
50
  @on-dropdown-open="onResponsibleSelectDropdownOpen"
51
51
  >
52
- <template #selector>
53
- <ResponsibleSelectorRow>
54
- <ResponsibleAvatar>{{
55
- responsibleInitials
56
- }}</ResponsibleAvatar>
57
- <ResponsibleTextStack>
58
- <ResponsibleRoleLabel>{{
59
- $gettext('responsible')
60
- }}</ResponsibleRoleLabel>
61
- <ResponsibleNameLine :title="responsibleDisplayName">{{
62
- responsibleDisplayName
63
- }}</ResponsibleNameLine>
64
- </ResponsibleTextStack>
65
- </ResponsibleSelectorRow>
66
- </template>
67
- <template #dropdown>
68
- <SelectOption
69
- v-for="(item, optionIdx) in projectManagerOptions"
70
- :key="
71
- item.id === null || item.id === undefined
72
- ? `pm_opt_none_${optionIdx}`
73
- : `pm_opt_${item.id}`
74
- "
75
- :data-id="`sidebar_responsible_option_${optionIdx + 1}`"
76
- :data-qa-id="`sidebar_responsible_option_${
77
- optionIdx + 1
78
- }`"
79
- :value="item.id"
80
- >
81
- <ResponsibleOptionRow>
82
- <ResponsibleOptionAvatar>{{
83
- initialsFromFullName(item.full_name)
84
- }}</ResponsibleOptionAvatar>
85
- <SelectOptionText :title="item.full_name">{{
86
- item.full_name
87
- }}</SelectOptionText>
88
- </ResponsibleOptionRow>
89
- </SelectOption>
90
- </template>
52
+ <template #selector>
53
+ <ResponsibleSelectorRow>
54
+ <ResponsibleAvatar>{{
55
+ responsibleInitials
56
+ }}</ResponsibleAvatar>
57
+ <ResponsibleTextStack>
58
+ <ResponsibleRoleLabel>{{
59
+ $gettext('responsible')
60
+ }}</ResponsibleRoleLabel>
61
+ <ResponsibleNameLine
62
+ :title="responsibleDisplayName"
63
+ >{{ responsibleDisplayName }}</ResponsibleNameLine
64
+ >
65
+ </ResponsibleTextStack>
66
+ </ResponsibleSelectorRow>
67
+ </template>
68
+ <template #dropdown>
69
+ <SelectOption
70
+ v-for="(item, optionIdx) in projectManagerOptions"
71
+ :key="
72
+ item.id === null || item.id === undefined
73
+ ? `pm_opt_none_${optionIdx}`
74
+ : `pm_opt_${item.id}`
75
+ "
76
+ :data-id="`sidebar_responsible_option_${optionIdx + 1}`"
77
+ :data-qa-id="`sidebar_responsible_option_${
78
+ optionIdx + 1
79
+ }`"
80
+ :value="item.id"
81
+ >
82
+ <ResponsibleOptionRow>
83
+ <ResponsibleOptionAvatar>{{
84
+ initialsFromFullName(item.full_name)
85
+ }}</ResponsibleOptionAvatar>
86
+ <SelectOptionText :title="item.full_name">{{
87
+ item.full_name
88
+ }}</SelectOptionText>
89
+ </ResponsibleOptionRow>
90
+ </SelectOption>
91
+ </template>
91
92
  </SelectComponent>
92
93
  </ResponsibleSelectSurface>
93
94
  </ResponsibleCard>
@@ -141,6 +142,7 @@
141
142
  >
142
143
  <IconCell :is-collapsed="isCollapsed">
143
144
  <IconComponent
145
+ v-if="item.icon"
144
146
  :color="
145
147
  item.id === activeItemId
146
148
  ? theme.semanticColors.purple[500]
@@ -186,6 +188,7 @@
186
188
  >
187
189
  <IconCell :is-collapsed="isCollapsed">
188
190
  <IconComponent
191
+ v-if="item.icon"
189
192
  :color="
190
193
  item.id === activeParentId
191
194
  ? theme.semanticColors.purple[500]
@@ -595,7 +598,7 @@
595
598
  align-items: center;
596
599
  justify-content: center;
597
600
  flex-shrink: 0;
598
- margin-left: ${(p) => (p.isCollapsed ? '0' : '0')};
601
+ margin-left: ${(p) => (p.isCollapsed ? '0' : 'auto')};
599
602
  `
600
603
 
601
604
  const ResponsibleBlock = styled.div`