@siemens/ix-icons 0.0.0-pr-69-20250205111227 → 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 (40) hide show
  1. package/components/index.js +1 -1
  2. package/components/ix-icon.js +1 -1
  3. package/components/{p-da232b5d.js → p-187634d0.js} +61 -51
  4. package/components/p-187634d0.js.map +1 -0
  5. package/dist/cjs/{icon-88309350.js → icon-319056c0.js} +61 -51
  6. package/dist/cjs/icon-319056c0.js.map +1 -0
  7. package/dist/cjs/index.cjs.js +1 -1
  8. package/dist/cjs/ix-icon.cjs.entry.js +1 -1
  9. package/dist/collection/components/icon/icon.js +23 -15
  10. package/dist/collection/components/icon/icon.js.map +1 -1
  11. package/dist/collection/components/icon/parser.js +22 -0
  12. package/dist/collection/components/icon/parser.js.map +1 -0
  13. package/dist/collection/components/icon/resolveIcon.js +26 -43
  14. package/dist/collection/components/icon/resolveIcon.js.map +1 -1
  15. package/dist/esm/{icon-4feff534.js → icon-fc868c56.js} +62 -52
  16. package/dist/esm/icon-fc868c56.js.map +1 -0
  17. package/dist/esm/index.js +1 -1
  18. package/dist/esm/ix-icon.entry.js +1 -1
  19. package/dist/ix-icons/index.esm.js +1 -1
  20. package/dist/ix-icons/ix-icons.esm.js +1 -1
  21. package/dist/ix-icons/p-423803cb.js +2 -0
  22. package/dist/ix-icons/p-423803cb.js.map +1 -0
  23. package/dist/ix-icons/p-ca4fc358.entry.js +2 -0
  24. package/dist/types/components/icon/icon.d.ts +5 -2
  25. package/dist/types/components/icon/meta-tag.d.ts +1 -1
  26. package/dist/types/components/icon/parser.d.ts +2 -0
  27. package/dist/types/components/icon/resolveIcon.d.ts +1 -2
  28. package/dist/types/components.d.ts +8 -2
  29. package/icons/package.json +1 -1
  30. package/package.json +1 -1
  31. package/components/p-da232b5d.js.map +0 -1
  32. package/dist/cjs/icon-88309350.js.map +0 -1
  33. package/dist/collection/components/icon/icons.js +0 -1258
  34. package/dist/collection/components/icon/icons.js.map +0 -1
  35. package/dist/esm/icon-4feff534.js.map +0 -1
  36. package/dist/ix-icons/p-08f117ce.entry.js +0 -2
  37. package/dist/ix-icons/p-588f84dc.js +0 -2
  38. package/dist/ix-icons/p-588f84dc.js.map +0 -1
  39. package/dist/types/components/icon/icons.d.ts +0 -1256
  40. /package/dist/ix-icons/{p-08f117ce.entry.js.map → p-ca4fc358.entry.js.map} +0 -0
@@ -1,3 +1,3 @@
1
- export { I as Icon, d as addIconToCache, c as addIcons, e as defineCustomElement, g as getAssetPath, s as setAssetPath, a as setNonce, b as setPlatformOptions } from './p-da232b5d.js';
1
+ export { I as Icon, d as addIconToCache, c as addIcons, e as defineCustomElement, g as getAssetPath, s as setAssetPath, a as setNonce, b as setPlatformOptions } from './p-187634d0.js';
2
2
 
3
3
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { I as Icon, e as defineCustomElement$1 } from './p-da232b5d.js';
1
+ import { I as Icon, e as defineCustomElement$1 } from './p-187634d0.js';
2
2
 
3
3
  const IxIcon = Icon;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1119,6 +1119,28 @@ function getCustomAssetUrl() {
1119
1119
  return false;
1120
1120
  }
1121
1121
 
1122
+ /*
1123
+ * COPYRIGHT (c) Siemens AG 2018-2025 ALL RIGHTS RESERVED.
1124
+ */
1125
+ let parser = null;
1126
+ 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>";
1127
+ function parseSVGDataContent(content) {
1128
+ if (typeof window['DOMParser'] === 'undefined') {
1129
+ console.error('DOMParser not supported by your browser.');
1130
+ return '';
1131
+ }
1132
+ if (parser === null) {
1133
+ parser = new window['DOMParser']();
1134
+ }
1135
+ const svgDocument = parser.parseFromString(content, 'text/html');
1136
+ const svgElement = svgDocument.querySelector('svg');
1137
+ if (!svgElement) {
1138
+ console.error('No valid svg data provided');
1139
+ return '';
1140
+ }
1141
+ return svgElement.outerHTML;
1142
+ }
1143
+
1122
1144
  /*
1123
1145
  * SPDX-FileCopyrightText: 2023 Siemens AG
1124
1146
  *
@@ -1129,7 +1151,6 @@ function getCustomAssetUrl() {
1129
1151
  */
1130
1152
  let fetchCache;
1131
1153
  const requests = new Map();
1132
- let parser = null;
1133
1154
  const getIconCacheMap = () => {
1134
1155
  if (typeof window === 'undefined') {
1135
1156
  return new Map();
@@ -1149,21 +1170,6 @@ const isSvgDataUrl = (url) => {
1149
1170
  }
1150
1171
  return url.startsWith('data:image/svg+xml');
1151
1172
  };
1152
- function parseSVGDataContent(content) {
1153
- if (typeof window['DOMParser'] === 'undefined') {
1154
- console.warn('DOMParser not supported by your browser.');
1155
- return;
1156
- }
1157
- if (parser === null) {
1158
- parser = new window['DOMParser']();
1159
- }
1160
- const svgDocument = parser.parseFromString(content, 'text/html');
1161
- const svgElement = svgDocument.querySelector('svg');
1162
- if (!svgElement) {
1163
- throw Error('No valid svg data provided');
1164
- }
1165
- return svgElement.outerHTML;
1166
- }
1167
1173
  async function fetchSVG(url) {
1168
1174
  const cache = getIconCacheMap();
1169
1175
  if (cache.has(url)) {
@@ -1172,18 +1178,27 @@ async function fetchSVG(url) {
1172
1178
  if (requests.has(url)) {
1173
1179
  return requests.get(url);
1174
1180
  }
1175
- const fetching = fetch(url).then(async (response) => {
1181
+ const fetching = fetch(url)
1182
+ .then(async (response) => {
1176
1183
  const responseText = await response.text();
1177
- if (!response.ok) {
1178
- console.error(responseText);
1179
- throw Error(responseText);
1184
+ let svgContent = '';
1185
+ if (response.ok) {
1186
+ svgContent = parseSVGDataContent(responseText);
1187
+ cache.set(url, svgContent);
1188
+ }
1189
+ else {
1190
+ console.error('Failed to request svg data from', url, 'with status code', response.status);
1180
1191
  }
1181
- const svgContent = parseSVGDataContent(responseText);
1182
- cache.set(url, svgContent);
1183
- requests.delete(url);
1184
1192
  return svgContent;
1193
+ })
1194
+ .catch(() => {
1195
+ console.error('Failed to fetch svg data:', url);
1196
+ cache.set(url, '');
1197
+ return '';
1198
+ })
1199
+ .finally(() => {
1200
+ requests.delete(url);
1185
1201
  });
1186
- requests.set(url, fetching);
1187
1202
  return fetching;
1188
1203
  }
1189
1204
  const urlRegex = /^(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:www\.)?(?:\S+\.\S+)(?:\S*)$/i;
@@ -1200,20 +1215,19 @@ function getIconUrl(name) {
1200
1215
  url = getAssetPath(url);
1201
1216
  }
1202
1217
  catch (error) {
1203
- console.warn(error);
1204
- setAssetPath(`${window.location.origin}/`);
1205
- url = getAssetPath(url);
1218
+ 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.`);
1206
1219
  }
1207
1220
  return url;
1208
1221
  }
1209
- async function resolveIcon(iconName) {
1222
+ async function resolveIcon(element, iconName) {
1210
1223
  if (!iconName) {
1211
- throw Error('No icon name provided');
1224
+ console.warn('No icon was provided', element);
1225
+ return '';
1212
1226
  }
1213
1227
  if (isSvgDataUrl(iconName)) {
1214
1228
  return parseSVGDataContent(iconName);
1215
1229
  }
1216
- return await loadIcon(iconName);
1230
+ return loadIcon(iconName);
1217
1231
  }
1218
1232
  async function loadIcon(iconName) {
1219
1233
  const cache = getIconCacheMap();
@@ -1221,19 +1235,9 @@ async function loadIcon(iconName) {
1221
1235
  return cache.get(iconName);
1222
1236
  }
1223
1237
  if (isValidUrl(iconName)) {
1224
- try {
1225
- return fetchSVG(iconName);
1226
- }
1227
- catch (error) {
1228
- throw error;
1229
- }
1230
- }
1231
- try {
1232
- return fetchSVG(getIconUrl(iconName));
1233
- }
1234
- catch (error) {
1235
- throw Error(`Could not resolve ${iconName}`);
1238
+ return fetchSVG(iconName);
1236
1239
  }
1240
+ return fetchSVG(getIconUrl(iconName));
1237
1241
  }
1238
1242
  function removePrefix(name, prefix) {
1239
1243
  if (name.startsWith(prefix)) {
@@ -1265,12 +1269,18 @@ function addIconToCache(name, icon) {
1265
1269
  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}";
1266
1270
  const IxIconStyle0 = iconCss;
1267
1271
 
1268
- 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>";
1269
1272
  const Icon = /*@__PURE__*/ proxyCustomElement(class Icon extends H {
1270
1273
  constructor() {
1271
1274
  super();
1272
1275
  this.__registerHost();
1273
1276
  this.__attachShadow();
1277
+ /**
1278
+ * Size of the icon
1279
+ */
1280
+ this.size = '24';
1281
+ /**
1282
+ * Only fetch and parse svg data when icon is visible
1283
+ */
1274
1284
  this.lazyLoading = false;
1275
1285
  this.isVisible = false;
1276
1286
  }
@@ -1281,12 +1291,12 @@ const Icon = /*@__PURE__*/ proxyCustomElement(class Icon extends H {
1281
1291
  });
1282
1292
  }
1283
1293
  async loadIconContent() {
1284
- try {
1285
- this.svgContent = await resolveIcon(this.name);
1286
- }
1287
- catch (error) {
1288
- this.svgContent = parseSVGDataContent(iconMissingSymbol);
1294
+ const content = await resolveIcon(this.hostElement, this.name);
1295
+ if (!content) {
1296
+ this.svgContent = parseSVGDataContent(errorSymbol);
1297
+ return;
1289
1298
  }
1299
+ this.svgContent = content;
1290
1300
  }
1291
1301
  waitForRendering(onRender) {
1292
1302
  if (this.lazyLoading && typeof window !== 'undefined' && window.IntersectionObserver) {
@@ -1311,12 +1321,12 @@ const Icon = /*@__PURE__*/ proxyCustomElement(class Icon extends H {
1311
1321
  if (this.color) {
1312
1322
  style['color'] = `var(--theme-${this.color})`;
1313
1323
  }
1314
- return (h(Host, { key: '8dc18bf3b1ab1e2a521bd0fee33fa91b856dc52b', style: style, class: {
1324
+ return (h(Host, { key: '484071b4f74e0b803b8d36913c866bfdb4b1a259', style: style, class: {
1315
1325
  ['size-12']: this.size === '12',
1316
1326
  ['size-16']: this.size === '16',
1317
1327
  ['size-24']: this.size === '24',
1318
1328
  ['size-32']: this.size === '32',
1319
- } }, h("div", { key: '48c3e8ae8e0d36be5fa112dbd408756f56c19535', class: 'svg-container', innerHTML: this.svgContent })));
1329
+ } }, h("div", { key: 'd988ef0fcc83087c24c905cf95ff02fe187aed5e', class: 'svg-container', innerHTML: this.svgContent })));
1320
1330
  }
1321
1331
  static get assetsDirs() { return ["svg"]; }
1322
1332
  get hostElement() { return this; }
@@ -1350,4 +1360,4 @@ function defineCustomElement() {
1350
1360
 
1351
1361
  export { Icon as I, setNonce as a, setPlatformOptions as b, addIcons as c, addIconToCache as d, defineCustomElement as e, getAssetPath as g, setAssetPath as s };
1352
1362
 
1353
- //# sourceMappingURL=p-da232b5d.js.map
1363
+ //# sourceMappingURL=p-187634d0.js.map