@siemens/ix-icons 0.0.0-pr-69-20250203134847 → 0.0.0-pr-69-20250205144920

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/components/index.js +1 -2
  2. package/components/index.js.map +1 -1
  3. package/components/ix-icon.js +1 -1
  4. package/components/p-187634d0.js +1363 -0
  5. package/components/p-187634d0.js.map +1 -0
  6. package/dist/cjs/{icon-88309350.js → icon-319056c0.js} +61 -51
  7. package/dist/cjs/icon-319056c0.js.map +1 -0
  8. package/dist/cjs/index.cjs.js +1 -1
  9. package/dist/cjs/ix-icon.cjs.entry.js +1 -1
  10. package/dist/collection/components/icon/icon.js +23 -15
  11. package/dist/collection/components/icon/icon.js.map +1 -1
  12. package/dist/collection/components/icon/parser.js +22 -0
  13. package/dist/collection/components/icon/parser.js.map +1 -0
  14. package/dist/collection/components/icon/resolveIcon.js +26 -43
  15. package/dist/collection/components/icon/resolveIcon.js.map +1 -1
  16. package/dist/esm/{icon-4feff534.js → icon-fc868c56.js} +62 -52
  17. package/dist/esm/icon-fc868c56.js.map +1 -0
  18. package/dist/esm/index.js +1 -1
  19. package/dist/esm/ix-icon.entry.js +1 -1
  20. package/dist/ix-icons/index.esm.js +1 -1
  21. package/dist/ix-icons/ix-icons.esm.js +1 -1
  22. package/dist/ix-icons/p-423803cb.js +2 -0
  23. package/dist/ix-icons/p-423803cb.js.map +1 -0
  24. package/dist/ix-icons/p-ca4fc358.entry.js +2 -0
  25. package/dist/types/components/icon/icon.d.ts +5 -2
  26. package/dist/types/components/icon/meta-tag.d.ts +1 -1
  27. package/dist/types/components/icon/parser.d.ts +2 -0
  28. package/dist/types/components/icon/resolveIcon.d.ts +1 -2
  29. package/dist/types/components.d.ts +8 -2
  30. package/icons/package.json +1 -1
  31. package/package.json +1 -1
  32. package/components/icon.js +0 -248
  33. package/components/icon.js.map +0 -1
  34. package/dist/cjs/icon-88309350.js.map +0 -1
  35. package/dist/collection/components/icon/icons.js +0 -1258
  36. package/dist/collection/components/icon/icons.js.map +0 -1
  37. package/dist/esm/icon-4feff534.js.map +0 -1
  38. package/dist/ix-icons/p-08f117ce.entry.js +0 -2
  39. package/dist/ix-icons/p-588f84dc.js +0 -2
  40. package/dist/ix-icons/p-588f84dc.js.map +0 -1
  41. package/dist/types/components/icon/icons.d.ts +0 -1256
  42. /package/dist/ix-icons/{p-08f117ce.entry.js.map → p-ca4fc358.entry.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import { g as getAssetPath, a as setAssetPath, r as registerInstance, h, H as Host, c as getElement } from './index-051cb4f1.js';
1
+ import { g as getAssetPath, r as registerInstance, h, H as Host, c as getElement } from './index-051cb4f1.js';
2
2
 
3
3
  /**
4
4
  * Provide custom SVG path for icons
@@ -14,6 +14,28 @@ function getCustomAssetUrl() {
14
14
  return false;
15
15
  }
16
16
 
17
+ /*
18
+ * COPYRIGHT (c) Siemens AG 2018-2025 ALL RIGHTS RESERVED.
19
+ */
20
+ let parser = null;
21
+ const errorSymbol = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path fill-rule='evenodd' d='M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z' transform='translate(64 64)'/></svg>";
22
+ function parseSVGDataContent(content) {
23
+ if (typeof window['DOMParser'] === 'undefined') {
24
+ console.error('DOMParser not supported by your browser.');
25
+ return '';
26
+ }
27
+ if (parser === null) {
28
+ parser = new window['DOMParser']();
29
+ }
30
+ const svgDocument = parser.parseFromString(content, 'text/html');
31
+ const svgElement = svgDocument.querySelector('svg');
32
+ if (!svgElement) {
33
+ console.error('No valid svg data provided');
34
+ return '';
35
+ }
36
+ return svgElement.outerHTML;
37
+ }
38
+
17
39
  /*
18
40
  * SPDX-FileCopyrightText: 2023 Siemens AG
19
41
  *
@@ -24,7 +46,6 @@ function getCustomAssetUrl() {
24
46
  */
25
47
  let fetchCache;
26
48
  const requests = new Map();
27
- let parser = null;
28
49
  const getIconCacheMap = () => {
29
50
  if (typeof window === 'undefined') {
30
51
  return new Map();
@@ -44,21 +65,6 @@ const isSvgDataUrl = (url) => {
44
65
  }
45
66
  return url.startsWith('data:image/svg+xml');
46
67
  };
47
- function parseSVGDataContent(content) {
48
- if (typeof window['DOMParser'] === 'undefined') {
49
- console.warn('DOMParser not supported by your browser.');
50
- return;
51
- }
52
- if (parser === null) {
53
- parser = new window['DOMParser']();
54
- }
55
- const svgDocument = parser.parseFromString(content, 'text/html');
56
- const svgElement = svgDocument.querySelector('svg');
57
- if (!svgElement) {
58
- throw Error('No valid svg data provided');
59
- }
60
- return svgElement.outerHTML;
61
- }
62
68
  async function fetchSVG(url) {
63
69
  const cache = getIconCacheMap();
64
70
  if (cache.has(url)) {
@@ -67,18 +73,27 @@ async function fetchSVG(url) {
67
73
  if (requests.has(url)) {
68
74
  return requests.get(url);
69
75
  }
70
- const fetching = fetch(url).then(async (response) => {
76
+ const fetching = fetch(url)
77
+ .then(async (response) => {
71
78
  const responseText = await response.text();
72
- if (!response.ok) {
73
- console.error(responseText);
74
- throw Error(responseText);
79
+ let svgContent = '';
80
+ if (response.ok) {
81
+ svgContent = parseSVGDataContent(responseText);
82
+ cache.set(url, svgContent);
83
+ }
84
+ else {
85
+ console.error('Failed to request svg data from', url, 'with status code', response.status);
75
86
  }
76
- const svgContent = parseSVGDataContent(responseText);
77
- cache.set(url, svgContent);
78
- requests.delete(url);
79
87
  return svgContent;
88
+ })
89
+ .catch(() => {
90
+ console.error('Failed to fetch svg data:', url);
91
+ cache.set(url, '');
92
+ return '';
93
+ })
94
+ .finally(() => {
95
+ requests.delete(url);
80
96
  });
81
- requests.set(url, fetching);
82
97
  return fetching;
83
98
  }
84
99
  const urlRegex = /^(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:www\.)?(?:\S+\.\S+)(?:\S*)$/i;
@@ -95,20 +110,19 @@ function getIconUrl(name) {
95
110
  url = getAssetPath(url);
96
111
  }
97
112
  catch (error) {
98
- console.warn(error);
99
- setAssetPath(`${window.location.origin}/`);
100
- url = getAssetPath(url);
113
+ console.warn(`Could not load icon with name "${name}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to property.`);
101
114
  }
102
115
  return url;
103
116
  }
104
- async function resolveIcon(iconName) {
117
+ async function resolveIcon(element, iconName) {
105
118
  if (!iconName) {
106
- throw Error('No icon name provided');
119
+ console.warn('No icon was provided', element);
120
+ return '';
107
121
  }
108
122
  if (isSvgDataUrl(iconName)) {
109
123
  return parseSVGDataContent(iconName);
110
124
  }
111
- return await loadIcon(iconName);
125
+ return loadIcon(iconName);
112
126
  }
113
127
  async function loadIcon(iconName) {
114
128
  const cache = getIconCacheMap();
@@ -116,19 +130,9 @@ async function loadIcon(iconName) {
116
130
  return cache.get(iconName);
117
131
  }
118
132
  if (isValidUrl(iconName)) {
119
- try {
120
- return fetchSVG(iconName);
121
- }
122
- catch (error) {
123
- throw error;
124
- }
125
- }
126
- try {
127
- return fetchSVG(getIconUrl(iconName));
128
- }
129
- catch (error) {
130
- throw Error(`Could not resolve ${iconName}`);
133
+ return fetchSVG(iconName);
131
134
  }
135
+ return fetchSVG(getIconUrl(iconName));
132
136
  }
133
137
  function removePrefix(name, prefix) {
134
138
  if (name.startsWith(prefix)) {
@@ -160,10 +164,16 @@ function addIconToCache(name, icon) {
160
164
  const iconCss = ":host{display:inline-flex;height:1.5rem;width:1.5rem;min-height:1.5rem;min-width:1.5rem;color:inherit}:host .svg-container{display:block;position:relative;width:100%;height:100%}:host .svg-container svg{display:block;position:relative;height:100%;width:100%}:host .svg-container svg,:host .svg-container svg[fill],:host .svg-container svg [fill]{fill:currentColor !important}:host(.size-12){height:0.75rem;width:0.75rem;min-height:0.75rem;min-width:0.75rem}:host(.size-16){height:1rem;width:1rem;min-height:1rem;min-width:1rem}:host(.size-32){height:2rem;width:2rem;min-height:2rem;min-width:2rem}";
161
165
  const IxIconStyle0 = iconCss;
162
166
 
163
- const iconMissingSymbol = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path fill-rule='evenodd' d='M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z' transform='translate(64 64)'/></svg>";
164
167
  const Icon = class {
165
168
  constructor(hostRef) {
166
169
  registerInstance(this, hostRef);
170
+ /**
171
+ * Size of the icon
172
+ */
173
+ this.size = '24';
174
+ /**
175
+ * Only fetch and parse svg data when icon is visible
176
+ */
167
177
  this.lazyLoading = false;
168
178
  this.isVisible = false;
169
179
  }
@@ -174,12 +184,12 @@ const Icon = class {
174
184
  });
175
185
  }
176
186
  async loadIconContent() {
177
- try {
178
- this.svgContent = await resolveIcon(this.name);
179
- }
180
- catch (error) {
181
- this.svgContent = parseSVGDataContent(iconMissingSymbol);
187
+ const content = await resolveIcon(this.hostElement, this.name);
188
+ if (!content) {
189
+ this.svgContent = parseSVGDataContent(errorSymbol);
190
+ return;
182
191
  }
192
+ this.svgContent = content;
183
193
  }
184
194
  waitForRendering(onRender) {
185
195
  if (this.lazyLoading && typeof window !== 'undefined' && window.IntersectionObserver) {
@@ -204,12 +214,12 @@ const Icon = class {
204
214
  if (this.color) {
205
215
  style['color'] = `var(--theme-${this.color})`;
206
216
  }
207
- return (h(Host, { key: '8dc18bf3b1ab1e2a521bd0fee33fa91b856dc52b', style: style, class: {
217
+ return (h(Host, { key: '484071b4f74e0b803b8d36913c866bfdb4b1a259', style: style, class: {
208
218
  ['size-12']: this.size === '12',
209
219
  ['size-16']: this.size === '16',
210
220
  ['size-24']: this.size === '24',
211
221
  ['size-32']: this.size === '32',
212
- } }, h("div", { key: '48c3e8ae8e0d36be5fa112dbd408756f56c19535', class: 'svg-container', innerHTML: this.svgContent })));
222
+ } }, h("div", { key: 'd988ef0fcc83087c24c905cf95ff02fe187aed5e', class: 'svg-container', innerHTML: this.svgContent })));
213
223
  }
214
224
  static get assetsDirs() { return ["svg"]; }
215
225
  get hostElement() { return getElement(this); }
@@ -221,4 +231,4 @@ Icon.style = IxIconStyle0;
221
231
 
222
232
  export { Icon as I, addIcons as a, addIconToCache as b };
223
233
 
224
- //# sourceMappingURL=icon-4feff534.js.map
234
+ //# sourceMappingURL=icon-fc868c56.js.map
@@ -0,0 +1 @@
1
+ {"file":"icon-fc868c56.js","mappings":";;AAAA;;;;;SAKgB,iBAAiB;IAC/B,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,4BAA4B,CAAC,CAAC;IACvE,IAAI,SAAS,EAAE;QACb,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf;;ACbA;;;AAIA,IAAI,MAAM,GAAQ,IAAI,CAAC;AAEhB,MAAM,WAAW,GACtB,gdAAgd,CAAC;SAEnc,mBAAmB,CAAC,OAAe;IACjD,IAAI,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,WAAW,EAAE;QAC9C,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,OAAO,EAAE,CAAC;KACX;IAED,IAAI,MAAM,KAAK,IAAI,EAAE;QACnB,MAAM,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;KACpC;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,CAAC,KAAK,CAAgB,CAAC;IAEnE,IA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,IAAI,CAAC,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW,IAAK,MAAc,CAAC,oBAAoB,EAAE;YAChH,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,OAAO;gBACL,OAAO,CAAC,OAAO,CAAC,KAAK;oBACnB,IAAI,KAAK,CAAC,cAAc,EAAE;wBACxB,QAAQ,EAAE,CAAC;wBACX,QAAQ,CAAC,UAAU,EAAE,CAAC;qBACvB;iBACF,CAAC,CAAC;aACJ,EACD;gBACE,UAAU,EAAE,MAAM;aACnB,CACF,CAAC;YAEF,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SACpC;aAAM;YACL,QAAQ,EAAE,CAAC;SACZ;KACF;IAED,MAAM;QACJ,MAAM,KAAK,GAEP,EAAE,CAAC;QAEP,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,KAAK,CAAC,OAAO,CAAC,GAAG,eAAe,IAAI,CAAC,KAAK,GAAG,CAAC;SAC/C;QAED,QACE,EAAC,IAAI,qDACH,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE;gBACL,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI;gBAC/B,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI;gBAC/B,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI;gBAC/B,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI;aAChC,IAED,4DAAK,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,GAAQ,CAC1D,EACP;KACH;;;;;;;;;;;","names":[],"sources":["src/components/icon/meta-tag.ts","src/components/icon/parser.ts","src/components/icon/resolveIcon.ts","src/components/icon/icon.scss?tag=ix-icon&encapsulation=shadow","src/components/icon/icon.tsx"],"sourcesContent":["/**\n * Provide custom SVG path for icons\n *\n * <meta name=\"ix-icons:path\" content=\"/build/svg\" />\n */\nexport function getCustomAssetUrl() {\n const assetPath = document.querySelector(\"meta[name='ix-icons:path']\");\n if (assetPath) {\n const path = assetPath.getAttribute('content');\n return path;\n }\n\n return false;\n}\n","/*\n * COPYRIGHT (c) Siemens AG 2018-2025 ALL RIGHTS RESERVED.\n */\n\nlet parser: any = null;\n\nexport const errorSymbol =\n \"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path fill-rule='evenodd' d='M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z' transform='translate(64 64)'/></svg>\";\n\nexport function parseSVGDataContent(content: string): string {\n if (typeof window['DOMParser'] === 'undefined') {\n console.error('DOMParser not supported by your browser.');\n return '';\n }\n\n if (parser === null) {\n parser = new window['DOMParser']();\n }\n\n const svgDocument = parser.parseFromString(content, 'text/html');\n const svgElement = svgDocument.querySelector('svg') as HTMLElement;\n\n if (!svgElement) {\n console.error('No valid svg data provided');\n return '';\n }\n\n return svgElement.outerHTML;\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getAssetPath } from '@stencil/core';\nimport { getCustomAssetUrl } from './meta-tag';\nimport { parseSVGDataContent } from './parser';\n\ndeclare global {\n interface Window {\n IxIcons: any;\n }\n}\n\nlet fetchCache: Map<string, string>;\nconst requests = new Map<string, Promise<string>>();\n\nexport const getIconCacheMap = (): Map<string, string> => {\n if (typeof window === 'undefined') {\n return new Map();\n }\n\n if (!fetchCache) {\n window.IxIcons = window.IxIcons || {};\n fetchCache = window.IxIcons.map = window.IxIcons.map || new Map();\n }\n\n return fetchCache;\n};\n\nexport const isSvgDataUrl = (url: string) => {\n if (!url) {\n return false;\n }\n\n if (typeof url !== 'string') {\n return false;\n }\n\n return url.startsWith('data:image/svg+xml');\n};\n\nasync function fetchSVG(url: string) {\n const cache = getIconCacheMap();\n\n if (cache.has(url)) {\n return cache.get(url)!;\n }\n\n if (requests.has(url)) {\n return requests.get(url)!;\n }\n\n const fetching = fetch(url)\n .then(async response => {\n const responseText = await response.text();\n\n let svgContent = '';\n if (response.ok) {\n svgContent = parseSVGDataContent(responseText);\n cache.set(url, svgContent);\n } else {\n console.error('Failed to request svg data from', url, 'with status code', response.status);\n }\n\n return svgContent;\n })\n .catch(() => {\n console.error('Failed to fetch svg data:', url);\n cache.set(url, '');\n return '';\n })\n .finally(() => {\n requests.delete(url);\n });\n\n return fetching;\n}\n\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nexport function getIconUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n let url: string = `svg/${name}.svg`;\n\n try {\n url = getAssetPath(url);\n } catch (error) {\n console.warn(`Could not load icon with name \"${name}\". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to property.`);\n }\n\n return url;\n}\n\nexport async function resolveIcon(element: HTMLIxIconElement, iconName?: string): Promise<string> {\n if (!iconName) {\n console.warn('No icon was provided', element);\n return '';\n }\n\n if (isSvgDataUrl(iconName)) {\n return parseSVGDataContent(iconName);\n }\n\n return loadIcon(iconName);\n}\n\nasync function loadIcon(iconName: string): Promise<string> {\n const cache = getIconCacheMap();\n\n if (cache.has(iconName)) {\n return cache.get(iconName)!;\n }\n\n if (isValidUrl(iconName)) {\n return fetchSVG(iconName);\n }\n\n return fetchSVG(getIconUrl(iconName));\n}\n\nfunction removePrefix(name: string, prefix: string) {\n if (name.startsWith(prefix)) {\n name = name.slice(prefix.length);\n return name.replace(/^(\\w)/, (_match, p1) => p1.toLowerCase());\n }\n\n return name;\n}\n\nexport function addIcons(icons: { [name: string]: any }) {\n Object.keys(icons).forEach(name => {\n const icon = icons[name];\n name = removePrefix(name, 'icon');\n\n addIconToCache(name, icon);\n });\n}\n\nexport function addIconToCache(name: string, icon: string) {\n const cache = getIconCacheMap();\n\n if (cache.has(name)) {\n console.warn(`Icon name '${name}' already in cache. Overwritting with new icon data.`);\n }\n\n const svg = parseSVGDataContent(icon);\n\n cache.set(name, svg);\n\n const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z0-9])/g, '$1-$2').toLowerCase();\n\n if (name != toKebabCase) {\n cache.set(toKebabCase, svg);\n }\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n@mixin size($size) {\n height: $size;\n width: $size;\n min-height: $size;\n min-width: $size;\n}\n\n:host {\n display: inline-flex;\n @include size(1.5rem);\n color: inherit;\n\n .svg-container {\n display: block;\n position: relative;\n width: 100%;\n height: 100%;\n\n svg {\n display: block;\n position: relative;\n height: 100%;\n width: 100%;\n }\n\n svg,\n svg[fill],\n svg [fill] {\n fill: currentColor !important;\n }\n }\n}\n\n:host(.size-12) {\n @include size(0.75rem);\n}\n\n:host(.size-16) {\n @include size(1rem);\n}\n\n:host(.size-32) {\n @include size(2rem);\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Component, h, Host, Prop, State, Watch, Element, Build } from '@stencil/core';\nimport { resolveIcon } from './resolveIcon';\nimport { errorSymbol, parseSVGDataContent } from './parser';\n\n@Component({\n tag: 'ix-icon',\n styleUrl: 'icon.scss',\n shadow: true,\n assetsDirs: ['svg'],\n})\nexport class Icon {\n @Element() hostElement!: HTMLIxIconElement;\n\n /**\n * Size of the icon\n */\n @Prop() size: '12' | '16' | '24' | '32' = '24';\n\n /**\n * Color of the icon\n */\n @Prop() color?: string;\n\n /**\n * Use one of our defined icon names e.g. `copy`\n *\n * https://ix.siemens.io/docs/icon-library/icons\n *\n * or the import variant\n *\n * ```\n * import { rocket } from '@siemens/ix-icons/icons';\n *\n * <ix-icon name={rocket}></ix-icon>\n * ```\n */\n @Prop() name?: string;\n\n /**\n * Only fetch and parse svg data when icon is visible\n */\n @Prop() lazyLoading = false;\n\n @State() svgContent?: string;\n @State() isVisible = false;\n\n componentWillLoad() {\n this.waitForRendering(() => {\n this.isVisible = true;\n this.loadIconContent();\n });\n }\n\n @Watch('name')\n async loadIconContent() {\n const content = await resolveIcon(this.hostElement, this.name);\n\n if (!content) {\n this.svgContent = parseSVGDataContent(errorSymbol);\n return;\n }\n\n this.svgContent = content;\n }\n\n private waitForRendering(onRender: () => void) {\n if (Build.isBrowser && this.lazyLoading && typeof window !== 'undefined' && (window as any).IntersectionObserver) {\n const observer = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n onRender();\n observer.disconnect();\n }\n });\n },\n {\n rootMargin: '25px',\n },\n );\n\n observer.observe(this.hostElement);\n } else {\n onRender();\n }\n }\n\n render() {\n const style: {\n [key: string]: string;\n } = {};\n\n if (this.color) {\n style['color'] = `var(--theme-${this.color})`;\n }\n\n return (\n <Host\n style={style}\n class={{\n ['size-12']: this.size === '12',\n ['size-16']: this.size === '16',\n ['size-24']: this.size === '24',\n ['size-32']: this.size === '32',\n }}\n >\n <div class={'svg-container'} innerHTML={this.svgContent}></div>\n </Host>\n );\n }\n}\n"],"version":3}
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { I as Icon, b as addIconToCache, a as addIcons } from './icon-4feff534.js';
1
+ export { I as Icon, b as addIconToCache, a as addIcons } from './icon-fc868c56.js';
2
2
  export { a as setAssetPath } from './index-051cb4f1.js';
3
3
 
4
4
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export { I as ix_icon } from './icon-4feff534.js';
1
+ export { I as ix_icon } from './icon-fc868c56.js';
2
2
  import './index-051cb4f1.js';
3
3
 
4
4
  //# sourceMappingURL=ix-icon.entry.js.map
@@ -1,2 +1,2 @@
1
- export{I as Icon,b as addIconToCache,a as addIcons}from"./p-588f84dc.js";export{a as setAssetPath}from"./p-48b5ebf2.js";
1
+ export{I as Icon,b as addIconToCache,a as addIcons}from"./p-423803cb.js";export{a as setAssetPath}from"./p-48b5ebf2.js";
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1,2 +1,2 @@
1
- import{p as o,b as n}from"./p-48b5ebf2.js";export{s as setNonce}from"./p-48b5ebf2.js";import{g as e}from"./p-e1255160.js";var a=()=>{const n=import.meta.url;const e={};if(n!==""){e.resourcesUrl=new URL(".",n).href}return o(e)};a().then((async o=>{await e();return n([["p-08f117ce",[[1,"ix-icon",{size:[1],color:[1],name:[1],lazyLoading:[4,"lazy-loading"],svgContent:[32],isVisible:[32]},null,{name:["loadIconContent"]}]]]],o)}));
1
+ import{p as o,b as n}from"./p-48b5ebf2.js";export{s as setNonce}from"./p-48b5ebf2.js";import{g as a}from"./p-e1255160.js";var e=()=>{const n=import.meta.url;const a={};if(n!==""){a.resourcesUrl=new URL(".",n).href}return o(a)};e().then((async o=>{await a();return n([["p-ca4fc358",[[1,"ix-icon",{size:[1],color:[1],name:[1],lazyLoading:[4,"lazy-loading"],svgContent:[32],isVisible:[32]},null,{name:["loadIconContent"]}]]]],o)}));
2
2
  //# sourceMappingURL=ix-icons.esm.js.map
@@ -0,0 +1,2 @@
1
+ import{g as t,r as e,h as n,H as i,c as s}from"./p-48b5ebf2.js";function o(){const t=document.querySelector("meta[name='ix-icons:path']");if(t){const e=t.getAttribute("content");return e}return false}let r=null;const c="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path fill-rule='evenodd' d='M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z' transform='translate(64 64)'/></svg>";function a(t){if(typeof window["DOMParser"]==="undefined"){console.error("DOMParser not supported by your browser.");return""}if(r===null){r=new window["DOMParser"]}const e=r.parseFromString(t,"text/html");const n=e.querySelector("svg");if(!n){console.error("No valid svg data provided");return""}return n.outerHTML}let h;const d=new Map;const f=()=>{if(typeof window==="undefined"){return new Map}if(!h){window.IxIcons=window.IxIcons||{};h=window.IxIcons.map=window.IxIcons.map||new Map}return h};const l=t=>{if(!t){return false}if(typeof t!=="string"){return false}return t.startsWith("data:image/svg+xml")};async function u(t){const e=f();if(e.has(t)){return e.get(t)}if(d.has(t)){return d.get(t)}const n=fetch(t).then((async n=>{const i=await n.text();let s="";if(n.ok){s=a(i);e.set(t,s)}else{console.error("Failed to request svg data from",t,"with status code",n.status)}return s})).catch((()=>{console.error("Failed to fetch svg data:",t);e.set(t,"");return""})).finally((()=>{d.delete(t)}));return n}const w=/^(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:www\.)?(?:\S+\.\S+)(?:\S*)$/i;function g(t){return w.test(t)}function m(e){const n=o();if(n){return`${n}/${e}.svg`}let i=`svg/${e}.svg`;try{i=t(i)}catch(t){console.warn(`Could not load icon with name "${e}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to property.`)}return i}async function v(t,e){if(!e){console.warn("No icon was provided",t);return""}if(l(e)){return a(e)}return p(e)}async function p(t){const e=f();if(e.has(t)){return e.get(t)}if(g(t)){return u(t)}return u(m(t))}function y(t,e){if(t.startsWith(e)){t=t.slice(e.length);return t.replace(/^(\w)/,((t,e)=>e.toLowerCase()))}return t}function L(t){Object.keys(t).forEach((e=>{const n=t[e];e=y(e,"icon");b(e,n)}))}function b(t,e){const n=f();if(n.has(t)){console.warn(`Icon name '${t}' already in cache. Overwritting with new icon data.`)}const i=a(e);n.set(t,i);const s=t.replace(/([a-z0-9]|(?=[A-Z]))([A-Z0-9])/g,"$1-$2").toLowerCase();if(t!=s){n.set(s,i)}}const M=":host{display:inline-flex;height:1.5rem;width:1.5rem;min-height:1.5rem;min-width:1.5rem;color:inherit}:host .svg-container{display:block;position:relative;width:100%;height:100%}:host .svg-container svg{display:block;position:relative;height:100%;width:100%}:host .svg-container svg,:host .svg-container svg[fill],:host .svg-container svg [fill]{fill:currentColor !important}:host(.size-12){height:0.75rem;width:0.75rem;min-height:0.75rem;min-width:0.75rem}:host(.size-16){height:1rem;width:1rem;min-height:1rem;min-width:1rem}:host(.size-32){height:2rem;width:2rem;min-height:2rem;min-width:2rem}";const x=M;const $=class{constructor(t){e(this,t);this.size="24";this.lazyLoading=false;this.isVisible=false}componentWillLoad(){this.waitForRendering((()=>{this.isVisible=true;this.loadIconContent()}))}async loadIconContent(){const t=await v(this.hostElement,this.name);if(!t){this.svgContent=a(c);return}this.svgContent=t}waitForRendering(t){if(this.lazyLoading&&typeof window!=="undefined"&&window.IntersectionObserver){const e=new IntersectionObserver((n=>{n.forEach((n=>{if(n.isIntersecting){t();e.disconnect()}}))}),{rootMargin:"25px"});e.observe(this.hostElement)}else{t()}}render(){const t={};if(this.color){t["color"]=`var(--theme-${this.color})`}return n(i,{key:"484071b4f74e0b803b8d36913c866bfdb4b1a259",style:t,class:{["size-12"]:this.size==="12",["size-16"]:this.size==="16",["size-24"]:this.size==="24",["size-32"]:this.size==="32"}},n("div",{key:"d988ef0fcc83087c24c905cf95ff02fe187aed5e",class:"svg-container",innerHTML:this.svgContent}))}static get assetsDirs(){return["svg"]}get hostElement(){return s(this)}static get watchers(){return{name:["loadIconContent"]}}};$.style=x;export{$ as I,L as a,b};
2
+ //# sourceMappingURL=p-423803cb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getCustomAssetUrl","assetPath","document","querySelector","path","getAttribute","parser","errorSymbol","parseSVGDataContent","content","window","console","error","svgDocument","parseFromString","svgElement","outerHTML","fetchCache","requests","Map","getIconCacheMap","IxIcons","map","isSvgDataUrl","url","startsWith","async","fetchSVG","cache","has","get","fetching","fetch","then","response","responseText","text","svgContent","ok","set","status","catch","finally","delete","urlRegex","isValidUrl","test","getIconUrl","name","customAssetUrl","getAssetPath","warn","resolveIcon","element","iconName","loadIcon","removePrefix","prefix","slice","length","replace","_match","p1","toLowerCase","addIcons","icons","Object","keys","forEach","icon","addIconToCache","svg","toKebabCase","iconCss","IxIconStyle0","Icon","constructor","hostRef","this","size","lazyLoading","isVisible","componentWillLoad","waitForRendering","loadIconContent","hostElement","onRender","IntersectionObserver","observer","entries","entry","isIntersecting","disconnect","rootMargin","observe","render","style","color","h","Host","key","class","innerHTML"],"sources":["src/components/icon/meta-tag.ts","src/components/icon/parser.ts","src/components/icon/resolveIcon.ts","src/components/icon/icon.scss?tag=ix-icon&encapsulation=shadow","src/components/icon/icon.tsx"],"sourcesContent":["/**\n * Provide custom SVG path for icons\n *\n * <meta name=\"ix-icons:path\" content=\"/build/svg\" />\n */\nexport function getCustomAssetUrl() {\n const assetPath = document.querySelector(\"meta[name='ix-icons:path']\");\n if (assetPath) {\n const path = assetPath.getAttribute('content');\n return path;\n }\n\n return false;\n}\n","/*\n * COPYRIGHT (c) Siemens AG 2018-2025 ALL RIGHTS RESERVED.\n */\n\nlet parser: any = null;\n\nexport const errorSymbol =\n \"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path fill-rule='evenodd' d='M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z' transform='translate(64 64)'/></svg>\";\n\nexport function parseSVGDataContent(content: string): string {\n if (typeof window['DOMParser'] === 'undefined') {\n console.error('DOMParser not supported by your browser.');\n return '';\n }\n\n if (parser === null) {\n parser = new window['DOMParser']();\n }\n\n const svgDocument = parser.parseFromString(content, 'text/html');\n const svgElement = svgDocument.querySelector('svg') as HTMLElement;\n\n if (!svgElement) {\n console.error('No valid svg data provided');\n return '';\n }\n\n return svgElement.outerHTML;\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getAssetPath } from '@stencil/core';\nimport { getCustomAssetUrl } from './meta-tag';\nimport { parseSVGDataContent } from './parser';\n\ndeclare global {\n interface Window {\n IxIcons: any;\n }\n}\n\nlet fetchCache: Map<string, string>;\nconst requests = new Map<string, Promise<string>>();\n\nexport const getIconCacheMap = (): Map<string, string> => {\n if (typeof window === 'undefined') {\n return new Map();\n }\n\n if (!fetchCache) {\n window.IxIcons = window.IxIcons || {};\n fetchCache = window.IxIcons.map = window.IxIcons.map || new Map();\n }\n\n return fetchCache;\n};\n\nexport const isSvgDataUrl = (url: string) => {\n if (!url) {\n return false;\n }\n\n if (typeof url !== 'string') {\n return false;\n }\n\n return url.startsWith('data:image/svg+xml');\n};\n\nasync function fetchSVG(url: string) {\n const cache = getIconCacheMap();\n\n if (cache.has(url)) {\n return cache.get(url)!;\n }\n\n if (requests.has(url)) {\n return requests.get(url)!;\n }\n\n const fetching = fetch(url)\n .then(async response => {\n const responseText = await response.text();\n\n let svgContent = '';\n if (response.ok) {\n svgContent = parseSVGDataContent(responseText);\n cache.set(url, svgContent);\n } else {\n console.error('Failed to request svg data from', url, 'with status code', response.status);\n }\n\n return svgContent;\n })\n .catch(() => {\n console.error('Failed to fetch svg data:', url);\n cache.set(url, '');\n return '';\n })\n .finally(() => {\n requests.delete(url);\n });\n\n return fetching;\n}\n\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nexport function getIconUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n let url: string = `svg/${name}.svg`;\n\n try {\n url = getAssetPath(url);\n } catch (error) {\n console.warn(`Could not load icon with name \"${name}\". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to property.`);\n }\n\n return url;\n}\n\nexport async function resolveIcon(element: HTMLIxIconElement, iconName?: string): Promise<string> {\n if (!iconName) {\n console.warn('No icon was provided', element);\n return '';\n }\n\n if (isSvgDataUrl(iconName)) {\n return parseSVGDataContent(iconName);\n }\n\n return loadIcon(iconName);\n}\n\nasync function loadIcon(iconName: string): Promise<string> {\n const cache = getIconCacheMap();\n\n if (cache.has(iconName)) {\n return cache.get(iconName)!;\n }\n\n if (isValidUrl(iconName)) {\n return fetchSVG(iconName);\n }\n\n return fetchSVG(getIconUrl(iconName));\n}\n\nfunction removePrefix(name: string, prefix: string) {\n if (name.startsWith(prefix)) {\n name = name.slice(prefix.length);\n return name.replace(/^(\\w)/, (_match, p1) => p1.toLowerCase());\n }\n\n return name;\n}\n\nexport function addIcons(icons: { [name: string]: any }) {\n Object.keys(icons).forEach(name => {\n const icon = icons[name];\n name = removePrefix(name, 'icon');\n\n addIconToCache(name, icon);\n });\n}\n\nexport function addIconToCache(name: string, icon: string) {\n const cache = getIconCacheMap();\n\n if (cache.has(name)) {\n console.warn(`Icon name '${name}' already in cache. Overwritting with new icon data.`);\n }\n\n const svg = parseSVGDataContent(icon);\n\n cache.set(name, svg);\n\n const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z0-9])/g, '$1-$2').toLowerCase();\n\n if (name != toKebabCase) {\n cache.set(toKebabCase, svg);\n }\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n@mixin size($size) {\n height: $size;\n width: $size;\n min-height: $size;\n min-width: $size;\n}\n\n:host {\n display: inline-flex;\n @include size(1.5rem);\n color: inherit;\n\n .svg-container {\n display: block;\n position: relative;\n width: 100%;\n height: 100%;\n\n svg {\n display: block;\n position: relative;\n height: 100%;\n width: 100%;\n }\n\n svg,\n svg[fill],\n svg [fill] {\n fill: currentColor !important;\n }\n }\n}\n\n:host(.size-12) {\n @include size(0.75rem);\n}\n\n:host(.size-16) {\n @include size(1rem);\n}\n\n:host(.size-32) {\n @include size(2rem);\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Component, h, Host, Prop, State, Watch, Element, Build } from '@stencil/core';\nimport { resolveIcon } from './resolveIcon';\nimport { errorSymbol, parseSVGDataContent } from './parser';\n\n@Component({\n tag: 'ix-icon',\n styleUrl: 'icon.scss',\n shadow: true,\n assetsDirs: ['svg'],\n})\nexport class Icon {\n @Element() hostElement!: HTMLIxIconElement;\n\n /**\n * Size of the icon\n */\n @Prop() size: '12' | '16' | '24' | '32' = '24';\n\n /**\n * Color of the icon\n */\n @Prop() color?: string;\n\n /**\n * Use one of our defined icon names e.g. `copy`\n *\n * https://ix.siemens.io/docs/icon-library/icons\n *\n * or the import variant\n *\n * ```\n * import { rocket } from '@siemens/ix-icons/icons';\n *\n * <ix-icon name={rocket}></ix-icon>\n * ```\n */\n @Prop() name?: string;\n\n /**\n * Only fetch and parse svg data when icon is visible\n */\n @Prop() lazyLoading = false;\n\n @State() svgContent?: string;\n @State() isVisible = false;\n\n componentWillLoad() {\n this.waitForRendering(() => {\n this.isVisible = true;\n this.loadIconContent();\n });\n }\n\n @Watch('name')\n async loadIconContent() {\n const content = await resolveIcon(this.hostElement, this.name);\n\n if (!content) {\n this.svgContent = parseSVGDataContent(errorSymbol);\n return;\n }\n\n this.svgContent = content;\n }\n\n private waitForRendering(onRender: () => void) {\n if (Build.isBrowser && this.lazyLoading && typeof window !== 'undefined' && (window as any).IntersectionObserver) {\n const observer = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n onRender();\n observer.disconnect();\n }\n });\n },\n {\n rootMargin: '25px',\n },\n );\n\n observer.observe(this.hostElement);\n } else {\n onRender();\n }\n }\n\n render() {\n const style: {\n [key: string]: string;\n } = {};\n\n if (this.color) {\n style['color'] = `var(--theme-${this.color})`;\n }\n\n return (\n <Host\n style={style}\n class={{\n ['size-12']: this.size === '12',\n ['size-16']: this.size === '16',\n ['size-24']: this.size === '24',\n ['size-32']: this.size === '32',\n }}\n >\n <div class={'svg-container'} innerHTML={this.svgContent}></div>\n </Host>\n );\n }\n}\n"],"mappings":"yEAKgBA,IACd,MAAMC,EAAYC,SAASC,cAAc,8BACzC,GAAIF,EAAW,CACb,MAAMG,EAAOH,EAAUI,aAAa,WACpC,OAAOD,C,CAGT,OAAO,KACT,CCTA,IAAIE,EAAc,KAEX,MAAMC,EACX,id,SAEcC,EAAoBC,GAClC,UAAWC,OAAO,eAAiB,YAAa,CAC9CC,QAAQC,MAAM,4CACd,MAAO,E,CAGT,GAAIN,IAAW,KAAM,CACnBA,EAAS,IAAII,OAAO,Y,CAGtB,MAAMG,EAAcP,EAAOQ,gBAAgBL,EAAS,aACpD,MAAMM,EAAaF,EAAYV,cAAc,OAE7C,IAAKY,EAAY,CACfJ,QAAQC,MAAM,8BACd,MAAO,E,CAGT,OAAOG,EAAWC,SACpB,CCVA,IAAIC,EACJ,MAAMC,EAAW,IAAIC,IAEd,MAAMC,EAAkB,KAC7B,UAAWV,SAAW,YAAa,CACjC,OAAO,IAAIS,G,CAGb,I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AAaP,KAAK9B,MAEzD,IAAKvC,EAAS,CACZqE,KAAKzC,WAAa7B,EAAoBD,GACtC,M,CAGFuE,KAAKzC,WAAa5B,C,CAGZ,gBAAA0E,CAAiBG,GACvB,GAAuBR,KAAKE,oBAAsBtE,SAAW,aAAgBA,OAAe6E,qBAAsB,CAChH,MAAMC,EAAW,IAAID,sBACnBE,IACEA,EAAQrB,SAAQsB,IACd,GAAIA,EAAMC,eAAgB,CACxBL,IACAE,EAASI,Y,IAEX,GAEJ,CACEC,WAAY,SAIhBL,EAASM,QAAQhB,KAAKO,Y,KACjB,CACLC,G,EAIJ,MAAAS,GACE,MAAMC,EAEF,GAEJ,GAAIlB,KAAKmB,MAAO,CACdD,EAAM,SAAW,eAAelB,KAAKmB,Q,CAGvC,OACEC,EAACC,EAAI,CAAAC,IAAA,2CACHJ,MAAOA,EACPK,MAAO,CACL,CAAC,WAAYvB,KAAKC,OAAS,KAC3B,CAAC,WAAYD,KAAKC,OAAS,KAC3B,CAAC,WAAYD,KAAKC,OAAS,KAC3B,CAAC,WAAYD,KAAKC,OAAS,OAG7BmB,EAAA,OAAAE,IAAA,2CAAKC,MAAO,gBAAiBC,UAAWxB,KAAKzC,a","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export{I as ix_icon}from"./p-423803cb.js";import"./p-48b5ebf2.js";
2
+ //# sourceMappingURL=p-ca4fc358.entry.js.map
@@ -7,7 +7,7 @@ export declare class Icon {
7
7
  /**
8
8
  * Color of the icon
9
9
  */
10
- color: string;
10
+ color?: string;
11
11
  /**
12
12
  * Use one of our defined icon names e.g. `copy`
13
13
  *
@@ -21,7 +21,10 @@ export declare class Icon {
21
21
  * <ix-icon name={rocket}></ix-icon>
22
22
  * ```
23
23
  */
24
- name: string;
24
+ name?: string;
25
+ /**
26
+ * Only fetch and parse svg data when icon is visible
27
+ */
25
28
  lazyLoading: boolean;
26
29
  svgContent?: string;
27
30
  isVisible: boolean;
@@ -3,4 +3,4 @@
3
3
  *
4
4
  * <meta name="ix-icons:path" content="/build/svg" />
5
5
  */
6
- export declare function getCustomAssetUrl(): string | false;
6
+ export declare function getCustomAssetUrl(): string | false | null;
@@ -0,0 +1,2 @@
1
+ export declare const errorSymbol = "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path fill-rule='evenodd' d='M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z' transform='translate(64 64)'/></svg>";
2
+ export declare function parseSVGDataContent(content: string): string;
@@ -5,9 +5,8 @@ declare global {
5
5
  }
6
6
  export declare const getIconCacheMap: () => Map<string, string>;
7
7
  export declare const isSvgDataUrl: (url: string) => boolean;
8
- export declare function parseSVGDataContent(content: string): string;
9
8
  export declare function getIconUrl(name: string): string;
10
- export declare function resolveIcon(iconName: string): Promise<string>;
9
+ export declare function resolveIcon(element: HTMLIxIconElement, iconName?: string): Promise<string>;
11
10
  export declare function addIcons(icons: {
12
11
  [name: string]: any;
13
12
  }): void;
@@ -10,12 +10,15 @@ export namespace Components {
10
10
  /**
11
11
  * Color of the icon
12
12
  */
13
- "color": string;
13
+ "color"?: string;
14
+ /**
15
+ * Only fetch and parse svg data when icon is visible
16
+ */
14
17
  "lazyLoading": boolean;
15
18
  /**
16
19
  * Use one of our defined icon names e.g. `copy` https://ix.siemens.io/docs/icon-library/icons or the import variant ``` import { rocket } from '@siemens/ix-icons/icons'; <ix-icon name={rocket}></ix-icon> ```
17
20
  */
18
- "name": string;
21
+ "name"?: string;
19
22
  /**
20
23
  * Size of the icon
21
24
  */
@@ -39,6 +42,9 @@ declare namespace LocalJSX {
39
42
  * Color of the icon
40
43
  */
41
44
  "color"?: string;
45
+ /**
46
+ * Only fetch and parse svg data when icon is visible
47
+ */
42
48
  "lazyLoading"?: boolean;
43
49
  /**
44
50
  * Use one of our defined icon names e.g. `copy` https://ix.siemens.io/docs/icon-library/icons or the import variant ``` import { rocket } from '@siemens/ix-icons/icons'; <ix-icon name={rocket}></ix-icon> ```
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siemens/ix/icons",
3
- "version": "0.0.0-pr-69-20250203134847",
3
+ "version": "0.0.0-pr-69-20250205144920",
4
4
  "module": "index.mjs",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siemens/ix-icons",
3
- "version": "0.0.0-pr-69-20250203134847",
3
+ "version": "0.0.0-pr-69-20250205144920",
4
4
  "license": "MIT",
5
5
  "description": "Siemens iX icon library",
6
6
  "author": "Siemens AG",