@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.
- package/components/index.js +1 -2
- package/components/index.js.map +1 -1
- package/components/ix-icon.js +1 -1
- package/components/p-187634d0.js +1363 -0
- package/components/p-187634d0.js.map +1 -0
- package/dist/cjs/{icon-88309350.js → icon-319056c0.js} +61 -51
- package/dist/cjs/icon-319056c0.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/ix-icon.cjs.entry.js +1 -1
- package/dist/collection/components/icon/icon.js +23 -15
- package/dist/collection/components/icon/icon.js.map +1 -1
- package/dist/collection/components/icon/parser.js +22 -0
- package/dist/collection/components/icon/parser.js.map +1 -0
- package/dist/collection/components/icon/resolveIcon.js +26 -43
- package/dist/collection/components/icon/resolveIcon.js.map +1 -1
- package/dist/esm/{icon-4feff534.js → icon-fc868c56.js} +62 -52
- package/dist/esm/icon-fc868c56.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/ix-icon.entry.js +1 -1
- package/dist/ix-icons/index.esm.js +1 -1
- package/dist/ix-icons/ix-icons.esm.js +1 -1
- package/dist/ix-icons/p-423803cb.js +2 -0
- package/dist/ix-icons/p-423803cb.js.map +1 -0
- package/dist/ix-icons/p-ca4fc358.entry.js +2 -0
- package/dist/types/components/icon/icon.d.ts +5 -2
- package/dist/types/components/icon/meta-tag.d.ts +1 -1
- package/dist/types/components/icon/parser.d.ts +2 -0
- package/dist/types/components/icon/resolveIcon.d.ts +1 -2
- package/dist/types/components.d.ts +8 -2
- package/icons/package.json +1 -1
- package/package.json +1 -1
- package/components/icon.js +0 -248
- package/components/icon.js.map +0 -1
- package/dist/cjs/icon-88309350.js.map +0 -1
- package/dist/collection/components/icon/icons.js +0 -1258
- package/dist/collection/components/icon/icons.js.map +0 -1
- package/dist/esm/icon-4feff534.js.map +0 -1
- package/dist/ix-icons/p-08f117ce.entry.js +0 -2
- package/dist/ix-icons/p-588f84dc.js +0 -2
- package/dist/ix-icons/p-588f84dc.js.map +0 -1
- package/dist/types/components/icon/icons.d.ts +0 -1256
- /package/dist/ix-icons/{p-08f117ce.entry.js.map → p-ca4fc358.entry.js.map} +0 -0
package/components/icon.js
DELETED
@@ -1,248 +0,0 @@
|
|
1
|
-
import { getAssetPath, setAssetPath, proxyCustomElement, HTMLElement, Build, h, Host } from '@stencil/core/internal/client';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Provide custom SVG path for icons
|
5
|
-
*
|
6
|
-
* <meta name="ix-icons:path" content="/build/svg" />
|
7
|
-
*/
|
8
|
-
function getCustomAssetUrl() {
|
9
|
-
const assetPath = document.querySelector("meta[name='ix-icons:path']");
|
10
|
-
if (assetPath) {
|
11
|
-
const path = assetPath.getAttribute('content');
|
12
|
-
return path;
|
13
|
-
}
|
14
|
-
return false;
|
15
|
-
}
|
16
|
-
|
17
|
-
/*
|
18
|
-
* SPDX-FileCopyrightText: 2023 Siemens AG
|
19
|
-
*
|
20
|
-
* SPDX-License-Identifier: MIT
|
21
|
-
*
|
22
|
-
* This source code is licensed under the MIT license found in the
|
23
|
-
* LICENSE file in the root directory of this source tree.
|
24
|
-
*/
|
25
|
-
let fetchCache;
|
26
|
-
const requests = new Map();
|
27
|
-
let parser = null;
|
28
|
-
const getIconCacheMap = () => {
|
29
|
-
if (typeof window === 'undefined') {
|
30
|
-
return new Map();
|
31
|
-
}
|
32
|
-
if (!fetchCache) {
|
33
|
-
window.IxIcons = window.IxIcons || {};
|
34
|
-
fetchCache = window.IxIcons.map = window.IxIcons.map || new Map();
|
35
|
-
}
|
36
|
-
return fetchCache;
|
37
|
-
};
|
38
|
-
const isSvgDataUrl = (url) => {
|
39
|
-
if (!url) {
|
40
|
-
return false;
|
41
|
-
}
|
42
|
-
if (typeof url !== 'string') {
|
43
|
-
return false;
|
44
|
-
}
|
45
|
-
return url.startsWith('data:image/svg+xml');
|
46
|
-
};
|
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
|
-
async function fetchSVG(url) {
|
63
|
-
const cache = getIconCacheMap();
|
64
|
-
if (cache.has(url)) {
|
65
|
-
return cache.get(url);
|
66
|
-
}
|
67
|
-
if (requests.has(url)) {
|
68
|
-
return requests.get(url);
|
69
|
-
}
|
70
|
-
const fetching = fetch(url).then(async (response) => {
|
71
|
-
const responseText = await response.text();
|
72
|
-
if (!response.ok) {
|
73
|
-
console.error(responseText);
|
74
|
-
throw Error(responseText);
|
75
|
-
}
|
76
|
-
const svgContent = parseSVGDataContent(responseText);
|
77
|
-
cache.set(url, svgContent);
|
78
|
-
requests.delete(url);
|
79
|
-
return svgContent;
|
80
|
-
});
|
81
|
-
requests.set(url, fetching);
|
82
|
-
return fetching;
|
83
|
-
}
|
84
|
-
const urlRegex = /^(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:www\.)?(?:\S+\.\S+)(?:\S*)$/i;
|
85
|
-
function isValidUrl(url) {
|
86
|
-
return urlRegex.test(url);
|
87
|
-
}
|
88
|
-
function getIconUrl(name) {
|
89
|
-
const customAssetUrl = getCustomAssetUrl();
|
90
|
-
if (customAssetUrl) {
|
91
|
-
return `${customAssetUrl}/${name}.svg`;
|
92
|
-
}
|
93
|
-
let url = `svg/${name}.svg`;
|
94
|
-
try {
|
95
|
-
url = getAssetPath(url);
|
96
|
-
}
|
97
|
-
catch (error) {
|
98
|
-
console.warn(error);
|
99
|
-
setAssetPath(`${window.location.origin}/`);
|
100
|
-
url = getAssetPath(url);
|
101
|
-
}
|
102
|
-
return url;
|
103
|
-
}
|
104
|
-
async function resolveIcon(iconName) {
|
105
|
-
if (!iconName) {
|
106
|
-
throw Error('No icon name provided');
|
107
|
-
}
|
108
|
-
if (isSvgDataUrl(iconName)) {
|
109
|
-
return parseSVGDataContent(iconName);
|
110
|
-
}
|
111
|
-
return await loadIcon(iconName);
|
112
|
-
}
|
113
|
-
async function loadIcon(iconName) {
|
114
|
-
const cache = getIconCacheMap();
|
115
|
-
if (cache.has(iconName)) {
|
116
|
-
return cache.get(iconName);
|
117
|
-
}
|
118
|
-
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}`);
|
131
|
-
}
|
132
|
-
}
|
133
|
-
function removePrefix(name, prefix) {
|
134
|
-
if (name.startsWith(prefix)) {
|
135
|
-
name = name.slice(prefix.length);
|
136
|
-
return name.replace(/^(\w)/, (_match, p1) => p1.toLowerCase());
|
137
|
-
}
|
138
|
-
return name;
|
139
|
-
}
|
140
|
-
function addIcons(icons) {
|
141
|
-
Object.keys(icons).forEach(name => {
|
142
|
-
const icon = icons[name];
|
143
|
-
name = removePrefix(name, 'icon');
|
144
|
-
addIconToCache(name, icon);
|
145
|
-
});
|
146
|
-
}
|
147
|
-
function addIconToCache(name, icon) {
|
148
|
-
const cache = getIconCacheMap();
|
149
|
-
if (cache.has(name)) {
|
150
|
-
console.warn(`Icon name '${name}' already in cache. Overwritting with new icon data.`);
|
151
|
-
}
|
152
|
-
const svg = parseSVGDataContent(icon);
|
153
|
-
cache.set(name, svg);
|
154
|
-
const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z0-9])/g, '$1-$2').toLowerCase();
|
155
|
-
if (name != toKebabCase) {
|
156
|
-
cache.set(toKebabCase, svg);
|
157
|
-
}
|
158
|
-
}
|
159
|
-
|
160
|
-
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
|
-
const IxIconStyle0 = iconCss;
|
162
|
-
|
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
|
-
const Icon = /*@__PURE__*/ proxyCustomElement(class Icon extends HTMLElement {
|
165
|
-
constructor() {
|
166
|
-
super();
|
167
|
-
this.__registerHost();
|
168
|
-
this.__attachShadow();
|
169
|
-
this.lazyLoading = false;
|
170
|
-
this.isVisible = false;
|
171
|
-
}
|
172
|
-
componentWillLoad() {
|
173
|
-
this.waitForRendering(() => {
|
174
|
-
this.isVisible = true;
|
175
|
-
this.loadIconContent();
|
176
|
-
});
|
177
|
-
}
|
178
|
-
async loadIconContent() {
|
179
|
-
try {
|
180
|
-
this.svgContent = await resolveIcon(this.name);
|
181
|
-
}
|
182
|
-
catch (error) {
|
183
|
-
this.svgContent = parseSVGDataContent(iconMissingSymbol);
|
184
|
-
}
|
185
|
-
}
|
186
|
-
waitForRendering(onRender) {
|
187
|
-
if (Build.isBrowser && this.lazyLoading && typeof window !== 'undefined' && window.IntersectionObserver) {
|
188
|
-
const observer = new IntersectionObserver(entries => {
|
189
|
-
entries.forEach(entry => {
|
190
|
-
if (entry.isIntersecting) {
|
191
|
-
onRender();
|
192
|
-
observer.disconnect();
|
193
|
-
}
|
194
|
-
});
|
195
|
-
}, {
|
196
|
-
rootMargin: '25px',
|
197
|
-
});
|
198
|
-
observer.observe(this.hostElement);
|
199
|
-
}
|
200
|
-
else {
|
201
|
-
onRender();
|
202
|
-
}
|
203
|
-
}
|
204
|
-
render() {
|
205
|
-
const style = {};
|
206
|
-
if (this.color) {
|
207
|
-
style['color'] = `var(--theme-${this.color})`;
|
208
|
-
}
|
209
|
-
return (h(Host, { key: '8dc18bf3b1ab1e2a521bd0fee33fa91b856dc52b', style: style, class: {
|
210
|
-
['size-12']: this.size === '12',
|
211
|
-
['size-16']: this.size === '16',
|
212
|
-
['size-24']: this.size === '24',
|
213
|
-
['size-32']: this.size === '32',
|
214
|
-
} }, h("div", { key: '48c3e8ae8e0d36be5fa112dbd408756f56c19535', class: 'svg-container', innerHTML: this.svgContent })));
|
215
|
-
}
|
216
|
-
static get assetsDirs() { return ["svg"]; }
|
217
|
-
get hostElement() { return this; }
|
218
|
-
static get watchers() { return {
|
219
|
-
"name": ["loadIconContent"]
|
220
|
-
}; }
|
221
|
-
static get style() { return IxIconStyle0; }
|
222
|
-
}, [1, "ix-icon", {
|
223
|
-
"size": [1],
|
224
|
-
"color": [1],
|
225
|
-
"name": [1],
|
226
|
-
"lazyLoading": [4, "lazy-loading"],
|
227
|
-
"svgContent": [32],
|
228
|
-
"isVisible": [32]
|
229
|
-
}, undefined, {
|
230
|
-
"name": ["loadIconContent"]
|
231
|
-
}]);
|
232
|
-
function defineCustomElement() {
|
233
|
-
if (typeof customElements === "undefined") {
|
234
|
-
return;
|
235
|
-
}
|
236
|
-
const components = ["ix-icon"];
|
237
|
-
components.forEach(tagName => { switch (tagName) {
|
238
|
-
case "ix-icon":
|
239
|
-
if (!customElements.get(tagName)) {
|
240
|
-
customElements.define(tagName, Icon);
|
241
|
-
}
|
242
|
-
break;
|
243
|
-
} });
|
244
|
-
}
|
245
|
-
|
246
|
-
export { Icon as I, addIcons as a, addIconToCache as b, defineCustomElement as d };
|
247
|
-
|
248
|
-
//# sourceMappingURL=icon.js.map
|
package/components/icon.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"file":"icon.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;;;;;;;;AAiBA,IAAI,UAA+B,CAAC;AACpC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AACpD,IAAI,MAAM,GAAG,IAAI,CAAC;AAEX,MAAM,eAAe,GAAG;IAC7B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,IAAI,GAAG,EAAE,CAAC;KAClB;IAED,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QACtC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;KACnE;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEK,MAAM,YAAY,GAAG,CAAC,GAAW;IACtC,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,KAAK,CAAC;KACd;IAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EA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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/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 * 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, setAssetPath } from '@stencil/core';\nimport { getCustomAssetUrl } from './meta-tag';\n\ndeclare global {\n interface Window {\n IxIcons: any;\n }\n}\n\nlet fetchCache: Map<string, string>;\nconst requests = new Map<string, Promise<string>>();\nlet parser = null;\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\nexport function parseSVGDataContent(content: string) {\n if (typeof window['DOMParser'] === 'undefined') {\n console.warn('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 throw Error('No valid svg data provided');\n }\n\n return svgElement.outerHTML;\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).then(async response => {\n const responseText = await response.text();\n\n if (!response.ok) {\n console.error(responseText);\n throw Error(responseText);\n }\n\n const svgContent = parseSVGDataContent(responseText);\n cache.set(url, svgContent);\n\n requests.delete(url);\n\n return svgContent;\n });\n\n requests.set(url, fetching);\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(error);\n setAssetPath(`${window.location.origin}/`);\n url = getAssetPath(url);\n }\n\n return url;\n}\n\nexport async function resolveIcon(iconName: string) {\n if (!iconName) {\n throw Error('No icon name provided');\n }\n\n if (isSvgDataUrl(iconName)) {\n return parseSVGDataContent(iconName);\n }\n\n return await loadIcon(iconName);\n}\n\nasync function loadIcon(iconName: string) {\n const cache = getIconCacheMap();\n\n if (cache.has(iconName)) {\n return cache.get(iconName);\n }\n\n if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n try {\n return fetchSVG(getIconUrl(iconName));\n } catch (error) {\n throw Error(`Could not resolve ${iconName}`);\n }\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 { parseSVGDataContent, resolveIcon } from './resolveIcon';\n\nconst iconMissingSymbol =\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\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';\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 @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 try {\n this.svgContent = await resolveIcon(this.name);\n } catch (error) {\n this.svgContent = parseSVGDataContent(iconMissingSymbol);\n }\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}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"file":"icon-88309350.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;;;;;;;;AAiBA,IAAI,UAA+B,CAAC;AACpC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AACpD,IAAI,MAAM,GAAG,IAAI,CAAC;AAEX,MAAM,eAAe,GAAG;IAC7B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,IAAI,GAAG,EAAE,CAAC;KAClB;IAED,IAAI,CAAC,UAAU,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/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 * 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, setAssetPath } from '@stencil/core';\nimport { getCustomAssetUrl } from './meta-tag';\n\ndeclare global {\n interface Window {\n IxIcons: any;\n }\n}\n\nlet fetchCache: Map<string, string>;\nconst requests = new Map<string, Promise<string>>();\nlet parser = null;\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\nexport function parseSVGDataContent(content: string) {\n if (typeof window['DOMParser'] === 'undefined') {\n console.warn('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 throw Error('No valid svg data provided');\n }\n\n return svgElement.outerHTML;\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).then(async response => {\n const responseText = await response.text();\n\n if (!response.ok) {\n console.error(responseText);\n throw Error(responseText);\n }\n\n const svgContent = parseSVGDataContent(responseText);\n cache.set(url, svgContent);\n\n requests.delete(url);\n\n return svgContent;\n });\n\n requests.set(url, fetching);\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(error);\n setAssetPath(`${window.location.origin}/`);\n url = getAssetPath(url);\n }\n\n return url;\n}\n\nexport async function resolveIcon(iconName: string) {\n if (!iconName) {\n throw Error('No icon name provided');\n }\n\n if (isSvgDataUrl(iconName)) {\n return parseSVGDataContent(iconName);\n }\n\n return await loadIcon(iconName);\n}\n\nasync function loadIcon(iconName: string) {\n const cache = getIconCacheMap();\n\n if (cache.has(iconName)) {\n return cache.get(iconName);\n }\n\n if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n try {\n return fetchSVG(getIconUrl(iconName));\n } catch (error) {\n throw Error(`Could not resolve ${iconName}`);\n }\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 { parseSVGDataContent, resolveIcon } from './resolveIcon';\n\nconst iconMissingSymbol =\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\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';\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 @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 try {\n this.svgContent = await resolveIcon(this.name);\n } catch (error) {\n this.svgContent = parseSVGDataContent(iconMissingSymbol);\n }\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}
|