@siemens/ix-icons 0.0.0-20240515161342 → 0.0.0-20240613090826
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/dist/cjs/{icon-8d6a19b5.js → icon-0c8b3da7.js} +4 -5
- package/dist/cjs/icon-0c8b3da7.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/resolveIcon.js +3 -4
- package/dist/collection/components/icon/resolveIcon.js.map +1 -1
- package/dist/components/icon.js +3 -4
- package/dist/components/icon.js.map +1 -1
- package/dist/esm/{icon-9458edad.js → icon-7b034d22.js} +4 -5
- package/dist/esm/icon-7b034d22.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-94b37f0d.entry.js +2 -0
- package/dist/ix-icons/p-f737ff39.js +2 -0
- package/dist/ix-icons/p-f737ff39.js.map +1 -0
- package/icons/package.json +1 -1
- package/package.json +1 -1
- package/dist/cjs/icon-8d6a19b5.js.map +0 -1
- package/dist/esm/icon-9458edad.js.map +0 -1
- package/dist/ix-icons/p-1dac0290.js +0 -2
- package/dist/ix-icons/p-1dac0290.js.map +0 -1
- package/dist/ix-icons/p-f748c4c1.entry.js +0 -2
- /package/dist/ix-icons/{p-f748c4c1.entry.js.map → p-94b37f0d.entry.js.map} +0 -0
|
@@ -109,14 +109,13 @@ function parseSVGDataContent(content) {
|
|
|
109
109
|
return svgElement.outerHTML;
|
|
110
110
|
}
|
|
111
111
|
async function fetchSVG(url) {
|
|
112
|
-
const request = requests.get(url);
|
|
113
|
-
if (request) {
|
|
114
|
-
return request;
|
|
115
|
-
}
|
|
116
112
|
const cache = getIconCacheMap();
|
|
117
113
|
if (cache.has(url)) {
|
|
118
114
|
return cache.get(url);
|
|
119
115
|
}
|
|
116
|
+
if (requests.has(url)) {
|
|
117
|
+
return requests.get(url);
|
|
118
|
+
}
|
|
120
119
|
const fetching = fetch(url).then(async (response) => {
|
|
121
120
|
const responseText = await response.text();
|
|
122
121
|
if (!response.ok) {
|
|
@@ -242,4 +241,4 @@ Icon.style = IxIconStyle0;
|
|
|
242
241
|
|
|
243
242
|
exports.Icon = Icon;
|
|
244
243
|
|
|
245
|
-
//# sourceMappingURL=icon-
|
|
244
|
+
//# sourceMappingURL=icon-0c8b3da7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"icon-0c8b3da7.js","mappings":";;;;AAAA;;;AAIA,SAAS,uBAAuB;IAC9B,OAAO,QAAQ,CAAC,aAAa,CAAC,kCAAkC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,uBAAuB;IAC9B,MAAM,oBAAoB,GAAG,uBAAuB,EAAE,CAAC;IACvD,IAAI,oBAAoB,EAAE;QACxB,OAAO,oBAAoB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;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,CAAC;AAED;;;;;SAKgB,kBAAkB;IAChC,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAC;IAE3C,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAC;KACd;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;QACzC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf;;ACjDA;;;;;;;;AAiBA,I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BAAoB,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,QACEC,QAACC,UAAI,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,IAEDD,kEAAK,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,GAAQ,CAC1D,EACP;KACH;;;;;;;;;;;","names":["getAssetPath","h","Host"],"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 * COPYRIGHT (c) Siemens AG 2018-2024 ALL RIGHTS RESERVED.\n */\n\nfunction getV3PreviewMetaElement() {\n return document.querySelector(\"meta[name='ix-icons:v3-preview']\");\n}\n\nfunction getV3PreviewMetaContent() {\n const v3PreviewMetaElement = getV3PreviewMetaElement();\n if (v3PreviewMetaElement) {\n return v3PreviewMetaElement.getAttribute('content').split(';');\n }\n\n return null;\n}\n\n/**\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/**\n * Enable v3 preview features\n *\n * <meta name=\"ix-icons:v3-preview\" content=\"svg-path-loading;\" />\n */\nexport function isV3PreviewEnabled() {\n const features = getV3PreviewMetaContent();\n\n if (!features) {\n return false;\n }\n\n if (features.includes('svg-path-loading')) {\n return true;\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 } from '@stencil/core';\nimport { getCustomAssetUrl, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\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 connectedCallback() {\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}
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -65,14 +65,13 @@ export function parseSVGDataContent(content) {
|
|
|
65
65
|
return svgElement.outerHTML;
|
|
66
66
|
}
|
|
67
67
|
async function fetchSVG(url) {
|
|
68
|
-
const request = requests.get(url);
|
|
69
|
-
if (request) {
|
|
70
|
-
return request;
|
|
71
|
-
}
|
|
72
68
|
const cache = getIconCacheMap();
|
|
73
69
|
if (cache.has(url)) {
|
|
74
70
|
return cache.get(url);
|
|
75
71
|
}
|
|
72
|
+
if (requests.has(url)) {
|
|
73
|
+
return requests.get(url);
|
|
74
|
+
}
|
|
76
75
|
const fetching = fetch(url).then(async (response) => {
|
|
77
76
|
const responseText = await response.text();
|
|
78
77
|
if (!response.ok) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveIcon.js","sourceRoot":"","sources":["../../../src/components/icon/resolveIcon.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAQnE,IAAI,UAA+B,CAAC;AACpC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AACpD,IAAI,MAAM,GAAG,IAAI,CAAC;AAElB,SAAS,WAAW,CAAC,KAAa;IAChC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,yCAAyC,EAAE,GAAG,CAAC,CAAC;IACtE,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,iBAAiB,GAAG,IAAI,CAAC;IAC7B,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAAC;YACxD,iBAAiB,GAAG,IAAI,CAAC;QAC3B,CAAC;aAAM,IAAI,iBAAiB,EAAE,CAAC;YAC7B,C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ACf,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,IAAI,kBAAkB,EAAE,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QAC5D,IAAI,CAAC;YACH,OAAO,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAC,yBAAyB,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["/*\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, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\n}\n"]}
|
package/dist/components/icon.js
CHANGED
|
@@ -107,14 +107,13 @@ function parseSVGDataContent(content) {
|
|
|
107
107
|
return svgElement.outerHTML;
|
|
108
108
|
}
|
|
109
109
|
async function fetchSVG(url) {
|
|
110
|
-
const request = requests.get(url);
|
|
111
|
-
if (request) {
|
|
112
|
-
return request;
|
|
113
|
-
}
|
|
114
110
|
const cache = getIconCacheMap();
|
|
115
111
|
if (cache.has(url)) {
|
|
116
112
|
return cache.get(url);
|
|
117
113
|
}
|
|
114
|
+
if (requests.has(url)) {
|
|
115
|
+
return requests.get(url);
|
|
116
|
+
}
|
|
118
117
|
const fetching = fetch(url).then(async (response) => {
|
|
119
118
|
const responseText = await response.text();
|
|
120
119
|
if (!response.ok) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"icon.js","mappings":";;AAAA;;;AAIA,SAAS,uBAAuB;IAC9B,OAAO,QAAQ,CAAC,aAAa,CAAC,kCAAkC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,uBAAuB;IAC9B,MAAM,oBAAoB,GAAG,uBAAuB,EAAE,CAAC;IACvD,IAAI,oBAAoB,EAAE;QACxB,OAAO,oBAAoB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;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,CAAC;AA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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 * COPYRIGHT (c) Siemens AG 2018-2024 ALL RIGHTS RESERVED.\n */\n\nfunction getV3PreviewMetaElement() {\n return document.querySelector(\"meta[name='ix-icons:v3-preview']\");\n}\n\nfunction getV3PreviewMetaContent() {\n const v3PreviewMetaElement = getV3PreviewMetaElement();\n if (v3PreviewMetaElement) {\n return v3PreviewMetaElement.getAttribute('content').split(';');\n }\n\n return null;\n}\n\n/**\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/**\n * Enable v3 preview features\n *\n * <meta name=\"ix-icons:v3-preview\" content=\"svg-path-loading;\" />\n */\nexport function isV3PreviewEnabled() {\n const features = getV3PreviewMetaContent();\n\n if (!features) {\n return false;\n }\n\n if (features.includes('svg-path-loading')) {\n return true;\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 } from '@stencil/core';\nimport { getCustomAssetUrl, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 request = requests.get(url);\n\n if (request) {\n return request;\n }\n\n const cache = getIconCacheMap();\n\n if (cache.has(url)) {\n return cache.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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\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 connectedCallback() {\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
|
+
{"file":"icon.js","mappings":";;AAAA;;;AAIA,SAAS,uBAAuB;IAC9B,OAAO,QAAQ,CAAC,aAAa,CAAC,kCAAkC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,uBAAuB;IAC9B,MAAM,oBAAoB,GAAG,uBAAuB,EAAE,CAAC;IACvD,IAAI,oBAAoB,EAAE;QACxB,OAAO,oBAAoB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;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,CAAC;AAED;;;;;SAKgB,kBAAkB;IAChC,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAC;IAE3C,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAC;KACd;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;QACzC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf;;ACjDA;;;;;;;;AAiBA,IAAI,UAA+B,CAAC;AACpC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AACpD,IAAI,MAAM,GAAG,IAAI,CAAC;AAElB,SAAS,WAAW,CAAC,KAAa;IAChC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,yCAAyC,EAAE,GAAG,CAAC,CAAC;IACtE,IAAI,WAAW,GAAG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AAM;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 * COPYRIGHT (c) Siemens AG 2018-2024 ALL RIGHTS RESERVED.\n */\n\nfunction getV3PreviewMetaElement() {\n return document.querySelector(\"meta[name='ix-icons:v3-preview']\");\n}\n\nfunction getV3PreviewMetaContent() {\n const v3PreviewMetaElement = getV3PreviewMetaElement();\n if (v3PreviewMetaElement) {\n return v3PreviewMetaElement.getAttribute('content').split(';');\n }\n\n return null;\n}\n\n/**\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/**\n * Enable v3 preview features\n *\n * <meta name=\"ix-icons:v3-preview\" content=\"svg-path-loading;\" />\n */\nexport function isV3PreviewEnabled() {\n const features = getV3PreviewMetaContent();\n\n if (!features) {\n return false;\n }\n\n if (features.includes('svg-path-loading')) {\n return true;\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 } from '@stencil/core';\nimport { getCustomAssetUrl, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\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 connectedCallback() {\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}
|
|
@@ -107,14 +107,13 @@ function parseSVGDataContent(content) {
|
|
|
107
107
|
return svgElement.outerHTML;
|
|
108
108
|
}
|
|
109
109
|
async function fetchSVG(url) {
|
|
110
|
-
const request = requests.get(url);
|
|
111
|
-
if (request) {
|
|
112
|
-
return request;
|
|
113
|
-
}
|
|
114
110
|
const cache = getIconCacheMap();
|
|
115
111
|
if (cache.has(url)) {
|
|
116
112
|
return cache.get(url);
|
|
117
113
|
}
|
|
114
|
+
if (requests.has(url)) {
|
|
115
|
+
return requests.get(url);
|
|
116
|
+
}
|
|
118
117
|
const fetching = fetch(url).then(async (response) => {
|
|
119
118
|
const responseText = await response.text();
|
|
120
119
|
if (!response.ok) {
|
|
@@ -240,4 +239,4 @@ Icon.style = IxIconStyle0;
|
|
|
240
239
|
|
|
241
240
|
export { Icon as I };
|
|
242
241
|
|
|
243
|
-
//# sourceMappingURL=icon-
|
|
242
|
+
//# sourceMappingURL=icon-7b034d22.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"icon-7b034d22.js","mappings":";;AAAA;;;AAIA,SAAS,uBAAuB;IAC9B,OAAO,QAAQ,CAAC,aAAa,CAAC,kCAAkC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,uBAAuB;IAC9B,MAAM,oBAAoB,GAAG,uBAAuB,EAAE,CAAC;IACvD,IAAI,oBAAoB,EAAE;QACxB,OAAO,oBAAoB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAChE;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;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,CAAC;AAED;;;;;SAKgB,kBAAkB;IAChC,MAAM,QAAQ,GAAG,uBAAuB,EAAE,CAAC;IAE3C,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAC;KACd;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;QACzC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,KAAK,CAAC;AACf;;ACjDA;;;;;;;;AAiBA,IAAI,UAA+B,CAAC;AACpC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AACpD,IAAI,MAAM,GAAG,IAAI,CAAC;AAElB,SA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C;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 * COPYRIGHT (c) Siemens AG 2018-2024 ALL RIGHTS RESERVED.\n */\n\nfunction getV3PreviewMetaElement() {\n return document.querySelector(\"meta[name='ix-icons:v3-preview']\");\n}\n\nfunction getV3PreviewMetaContent() {\n const v3PreviewMetaElement = getV3PreviewMetaElement();\n if (v3PreviewMetaElement) {\n return v3PreviewMetaElement.getAttribute('content').split(';');\n }\n\n return null;\n}\n\n/**\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/**\n * Enable v3 preview features\n *\n * <meta name=\"ix-icons:v3-preview\" content=\"svg-path-loading;\" />\n */\nexport function isV3PreviewEnabled() {\n const features = getV3PreviewMetaContent();\n\n if (!features) {\n return false;\n }\n\n if (features.includes('svg-path-loading')) {\n return true;\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 } from '@stencil/core';\nimport { getCustomAssetUrl, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\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 connectedCallback() {\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}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{I as Icon}from"./p-
|
|
1
|
+
export{I as Icon}from"./p-f737ff39.js";import"./p-efdd4090.js";
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as o,b as n}from"./p-efdd4090.js";export{s as setNonce}from"./p-efdd4090.js";import{g as e}from"./p-e1255160.js";const t=()=>{const n=import.meta.url;const s={};if(n!==""){s.resourcesUrl=new URL(".",n).href}return o(s)};t().then((async o=>{await e();return n([["p-
|
|
1
|
+
import{p as o,b as n}from"./p-efdd4090.js";export{s as setNonce}from"./p-efdd4090.js";import{g as e}from"./p-e1255160.js";const t=()=>{const n=import.meta.url;const s={};if(n!==""){s.resourcesUrl=new URL(".",n).href}return o(s)};t().then((async o=>{await e();return n([["p-94b37f0d",[[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,a as r}from"./p-efdd4090.js";function s(){return document.querySelector("meta[name='ix-icons:v3-preview']")}function o(){const t=s();if(t){return t.getAttribute("content").split(";")}return null}function a(){const t=document.querySelector("meta[name='ix-icons:path']");if(t){const e=t.getAttribute("content");return e}return false}function c(){const t=o();if(!t){return false}if(t.includes("svg-path-loading")){return true}return false}let h;const f=new Map;let d=null;function u(t){t=t.replace(/[\(\)\[\]\{\}\=\?\!\.\:,\-_\+\\\"#~\/]/g," ");let e="";let n=true;t=t.toLowerCase();for(let i=0;t.length>i;i++){let r=t.charAt(i);if(r.match(/^\s+$/g)||r.match(/[\(\)\[\]\{\}\\\/]/g)){n=true}else if(n){r=r.toUpperCase();n=false}e+=r}const i=e.replace(/\s+/g,"");return i.charAt(0).toUpperCase()+i.slice(1)}const l=()=>{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 w=t=>{if(!t){return false}if(typeof t!=="string"){return false}return t.startsWith("data:image/svg+xml")};function g(t){if(typeof window["DOMParser"]==="undefined"){console.warn("DOMParser not supported by your browser.");return}if(d===null){d=new window["DOMParser"]}const e=d.parseFromString(t,"text/html");const n=e.querySelector("svg");if(!n){throw Error("No valid svg data provided")}return n.outerHTML}async function m(t){const e=l();if(e.has(t)){return e.get(t)}if(f.has(t)){return f.get(t)}const n=fetch(t).then((async n=>{const i=await n.text();if(!n.ok){console.error(i);throw Error(i)}const r=g(i);e.set(t,r);return r}));f.set(t,n);return n}const v=/^(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:www\.)?(?:\S+\.\S+)(?:\S*)$/i;function p(t){return v.test(t)}function y(e){const n=a();if(n){return`${n}/${e}.svg`}return t(`svg/${e}.svg`)}async function L(t){const e=await import("./p-51684ec4.js");let n=u(t);n=`icon${n}`;return g(e[n])}async function b(t){if(!t){throw Error("No icon name provided")}if(w(t)){return g(t)}if(p(t)){try{return m(t)}catch(t){throw t}}if(c()){console.warn("Using V3 preview feature for loading icons.");try{return m(y(t))}catch(t){throw Error("Cannot resolve any icon")}}return L(t)}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 z="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>";const $=class{constructor(t){e(this,t);this.size=undefined;this.color=undefined;this.name=undefined;this.lazyLoading=false;this.svgContent=undefined;this.isVisible=false}connectedCallback(){this.waitForRendering((()=>{this.isVisible=true;this.loadIconContent()}))}async loadIconContent(){try{this.svgContent=await b(this.name)}catch(t){this.svgContent=g(z)}}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:"8dc18bf3b1ab1e2a521bd0fee33fa91b856dc52b",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:"48c3e8ae8e0d36be5fa112dbd408756f56c19535",class:"svg-container",innerHTML:this.svgContent}))}static get assetsDirs(){return["svg"]}get hostElement(){return r(this)}static get watchers(){return{name:["loadIconContent"]}}};$.style=x;export{$ as I};
|
|
2
|
+
//# sourceMappingURL=p-f737ff39.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getV3PreviewMetaElement","document","querySelector","getV3PreviewMetaContent","v3PreviewMetaElement","getAttribute","split","getCustomAssetUrl","assetPath","path","isV3PreviewEnabled","features","includes","fetchCache","requests","Map","parser","toCamelCase","value","replace","returnValue","makeNextUppercase","toLowerCase","i","length","c","charAt","match","toUpperCase","normalized","slice","getIconCacheMap","window","IxIcons","map","isSvgDataUrl","url","startsWith","parseSVGDataContent","content","console","warn","svgDocument","parseFromString","svgElement","Error","outerHTML","async","fetchSVG","cache","has","get","fetching","fetch","then","response","responseText","text","ok","error","svgContent","set","urlRegex","isValidUrl","test","getAssetUrl","name","customAssetUrl","getAssetPath","getESMIcon","esmIcon","import","iconName","resolveIcon","iconCss","IxIconStyle0","iconMissingSymbol","Icon","connectedCallback","this","waitForRendering","isVisible","loadIconContent","onRender","lazyLoading","IntersectionObserver","observer","entries","forEach","entry","isIntersecting","disconnect","rootMargin","observe","hostElement","render","style","color","h","Host","key","class","size","innerHTML"],"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 * COPYRIGHT (c) Siemens AG 2018-2024 ALL RIGHTS RESERVED.\n */\n\nfunction getV3PreviewMetaElement() {\n return document.querySelector(\"meta[name='ix-icons:v3-preview']\");\n}\n\nfunction getV3PreviewMetaContent() {\n const v3PreviewMetaElement = getV3PreviewMetaElement();\n if (v3PreviewMetaElement) {\n return v3PreviewMetaElement.getAttribute('content').split(';');\n }\n\n return null;\n}\n\n/**\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/**\n * Enable v3 preview features\n *\n * <meta name=\"ix-icons:v3-preview\" content=\"svg-path-loading;\" />\n */\nexport function isV3PreviewEnabled() {\n const features = getV3PreviewMetaContent();\n\n if (!features) {\n return false;\n }\n\n if (features.includes('svg-path-loading')) {\n return true;\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 } from '@stencil/core';\nimport { getCustomAssetUrl, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\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 connectedCallback() {\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"],"mappings":"gEAIA,SAASA,IACP,OAAOC,SAASC,cAAc,mCAChC,CAEA,SAASC,IACP,MAAMC,EAAuBJ,IAC7B,GAAII,EAAsB,CACxB,OAAOA,EAAqBC,aAAa,WAAWC,MAAM,I,CAG5D,OAAO,IACT,C,SAOgBC,IACd,MAAMC,EAAYP,SAASC,cAAc,8BACzC,GAAIM,EAAW,CACb,MAAMC,EAAOD,EAAUH,aAAa,WACpC,OAAOI,C,CAGT,OAAO,KACT,C,SAOgBC,IACd,MAAMC,EAAWR,IAEjB,IAAKQ,EAAU,CACb,OAAO,K,CAGT,GAAIA,EAASC,SAAS,oBAAqB,CACzC,OAAO,I,CAGT,OAAO,KACT,CChCA,IAAIC,EACJ,MAAMC,EAAW,IAAIC,IACrB,IAAIC,EAAS,KAEb,SAASC,EAAYC,GACnBA,EAAQA,EAAMC,QAAQ,0CAA2C,KACjE,IAAIC,EAAc,GAClB,IAAIC,EAAoB,KACxBH,EAAQA,EAAMI,cACd,IAAK,IAAIC,EAAI,EAAGL,EAAMM,OAASD,EAAGA,IAAK,CACrC,IAAIE,EAAIP,EAAMQ,OAAOH,GACrB,GAAIE,EAAEE,MAAM,WAAaF,EAAEE,MAAM,uBAAwB,CACvDN,EAAoB,I,MACf,GAAIA,EAAmB,CAC5BI,EAAIA,EAAEG,cACNP,EAAoB,K,CAEtBD,GAAeK,C,CAEjB,MAAMI,EAAaT,EAAYD,QAAQ,OAAQ,IAC/C,OAAOU,EAAWH,OAAO,GAAGE,cAAgBC,EAAWC,MAAM,EAC/D,CAEO,MAAMC,EAAkB,KAC7B,UAAWC,SAAW,YAAa,CACjC,OAAO,IAAIjB,G,CAGb,IAAKF,EAAY,CACfmB,OAAOC,QAAU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AAQ,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,QACEC,QAACC,UAAI,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,IAEDD,kEAAK,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,GAAQ,CAC1D,EACP;KACH;;;;;;;;;;;","names":["getAssetPath","h","Host"],"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 * COPYRIGHT (c) Siemens AG 2018-2024 ALL RIGHTS RESERVED.\n */\n\nfunction getV3PreviewMetaElement() {\n return document.querySelector(\"meta[name='ix-icons:v3-preview']\");\n}\n\nfunction getV3PreviewMetaContent() {\n const v3PreviewMetaElement = getV3PreviewMetaElement();\n if (v3PreviewMetaElement) {\n return v3PreviewMetaElement.getAttribute('content').split(';');\n }\n\n return null;\n}\n\n/**\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/**\n * Enable v3 preview features\n *\n * <meta name=\"ix-icons:v3-preview\" content=\"svg-path-loading;\" />\n */\nexport function isV3PreviewEnabled() {\n const features = getV3PreviewMetaContent();\n\n if (!features) {\n return false;\n }\n\n if (features.includes('svg-path-loading')) {\n return true;\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 } from '@stencil/core';\nimport { getCustomAssetUrl, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 request = requests.get(url);\n\n if (request) {\n return request;\n }\n\n const cache = getIconCacheMap();\n\n if (cache.has(url)) {\n return cache.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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\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 connectedCallback() {\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-9458edad.js","mappings":";;AAAA;;;AAIA,SAAS,uBAAuB;IAC9B,OAAO,QAAQ,CAAC,aAAa,CAAC,kCAAkC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,uBAAuB;IAC9B,MAAM,oBAAoB,GAAG,uBAAuB,EAAE,CAAC;IACvD,IAAI,oBAAoB,EAAE;QACxB,OAAO,oBAAoB,CAAC,YAAY,CAAC,SAAS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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 * COPYRIGHT (c) Siemens AG 2018-2024 ALL RIGHTS RESERVED.\n */\n\nfunction getV3PreviewMetaElement() {\n return document.querySelector(\"meta[name='ix-icons:v3-preview']\");\n}\n\nfunction getV3PreviewMetaContent() {\n const v3PreviewMetaElement = getV3PreviewMetaElement();\n if (v3PreviewMetaElement) {\n return v3PreviewMetaElement.getAttribute('content').split(';');\n }\n\n return null;\n}\n\n/**\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/**\n * Enable v3 preview features\n *\n * <meta name=\"ix-icons:v3-preview\" content=\"svg-path-loading;\" />\n */\nexport function isV3PreviewEnabled() {\n const features = getV3PreviewMetaContent();\n\n if (!features) {\n return false;\n }\n\n if (features.includes('svg-path-loading')) {\n return true;\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 } from '@stencil/core';\nimport { getCustomAssetUrl, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 request = requests.get(url);\n\n if (request) {\n return request;\n }\n\n const cache = getIconCacheMap();\n\n if (cache.has(url)) {\n return cache.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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\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 connectedCallback() {\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,2 +0,0 @@
|
|
|
1
|
-
import{g as t,r as e,h as n,H as i,a as r}from"./p-efdd4090.js";function s(){return document.querySelector("meta[name='ix-icons:v3-preview']")}function o(){const t=s();if(t){return t.getAttribute("content").split(";")}return null}function a(){const t=document.querySelector("meta[name='ix-icons:path']");if(t){const e=t.getAttribute("content");return e}return false}function c(){const t=o();if(!t){return false}if(t.includes("svg-path-loading")){return true}return false}let h;const f=new Map;let d=null;function u(t){t=t.replace(/[\(\)\[\]\{\}\=\?\!\.\:,\-_\+\\\"#~\/]/g," ");let e="";let n=true;t=t.toLowerCase();for(let i=0;t.length>i;i++){let r=t.charAt(i);if(r.match(/^\s+$/g)||r.match(/[\(\)\[\]\{\}\\\/]/g)){n=true}else if(n){r=r.toUpperCase();n=false}e+=r}const i=e.replace(/\s+/g,"");return i.charAt(0).toUpperCase()+i.slice(1)}const l=()=>{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 w=t=>{if(!t){return false}if(typeof t!=="string"){return false}return t.startsWith("data:image/svg+xml")};function g(t){if(typeof window["DOMParser"]==="undefined"){console.warn("DOMParser not supported by your browser.");return}if(d===null){d=new window["DOMParser"]}const e=d.parseFromString(t,"text/html");const n=e.querySelector("svg");if(!n){throw Error("No valid svg data provided")}return n.outerHTML}async function m(t){const e=f.get(t);if(e){return e}const n=l();if(n.has(t)){return n.get(t)}const i=fetch(t).then((async e=>{const i=await e.text();if(!e.ok){console.error(i);throw Error(i)}const r=g(i);n.set(t,r);return r}));f.set(t,i);return i}const v=/^(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:www\.)?(?:\S+\.\S+)(?:\S*)$/i;function p(t){return v.test(t)}function y(e){const n=a();if(n){return`${n}/${e}.svg`}return t(`svg/${e}.svg`)}async function L(t){const e=await import("./p-51684ec4.js");let n=u(t);n=`icon${n}`;return g(e[n])}async function b(t){if(!t){throw Error("No icon name provided")}if(w(t)){return g(t)}if(p(t)){try{return m(t)}catch(t){throw t}}if(c()){console.warn("Using V3 preview feature for loading icons.");try{return m(y(t))}catch(t){throw Error("Cannot resolve any icon")}}return L(t)}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 z="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>";const $=class{constructor(t){e(this,t);this.size=undefined;this.color=undefined;this.name=undefined;this.lazyLoading=false;this.svgContent=undefined;this.isVisible=false}connectedCallback(){this.waitForRendering((()=>{this.isVisible=true;this.loadIconContent()}))}async loadIconContent(){try{this.svgContent=await b(this.name)}catch(t){this.svgContent=g(z)}}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:"8dc18bf3b1ab1e2a521bd0fee33fa91b856dc52b",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:"48c3e8ae8e0d36be5fa112dbd408756f56c19535",class:"svg-container",innerHTML:this.svgContent}))}static get assetsDirs(){return["svg"]}get hostElement(){return r(this)}static get watchers(){return{name:["loadIconContent"]}}};$.style=x;export{$ as I};
|
|
2
|
-
//# sourceMappingURL=p-1dac0290.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getV3PreviewMetaElement","document","querySelector","getV3PreviewMetaContent","v3PreviewMetaElement","getAttribute","split","getCustomAssetUrl","assetPath","path","isV3PreviewEnabled","features","includes","fetchCache","requests","Map","parser","toCamelCase","value","replace","returnValue","makeNextUppercase","toLowerCase","i","length","c","charAt","match","toUpperCase","normalized","slice","getIconCacheMap","window","IxIcons","map","isSvgDataUrl","url","startsWith","parseSVGDataContent","content","console","warn","svgDocument","parseFromString","svgElement","Error","outerHTML","async","fetchSVG","request","get","cache","has","fetching","fetch","then","response","responseText","text","ok","error","svgContent","set","urlRegex","isValidUrl","test","getAssetUrl","name","customAssetUrl","getAssetPath","getESMIcon","esmIcon","import","iconName","resolveIcon","iconCss","IxIconStyle0","iconMissingSymbol","Icon","connectedCallback","this","waitForRendering","isVisible","loadIconContent","onRender","lazyLoading","IntersectionObserver","observer","entries","forEach","entry","isIntersecting","disconnect","rootMargin","observe","hostElement","render","style","color","h","Host","key","class","size","innerHTML"],"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 * COPYRIGHT (c) Siemens AG 2018-2024 ALL RIGHTS RESERVED.\n */\n\nfunction getV3PreviewMetaElement() {\n return document.querySelector(\"meta[name='ix-icons:v3-preview']\");\n}\n\nfunction getV3PreviewMetaContent() {\n const v3PreviewMetaElement = getV3PreviewMetaElement();\n if (v3PreviewMetaElement) {\n return v3PreviewMetaElement.getAttribute('content').split(';');\n }\n\n return null;\n}\n\n/**\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/**\n * Enable v3 preview features\n *\n * <meta name=\"ix-icons:v3-preview\" content=\"svg-path-loading;\" />\n */\nexport function isV3PreviewEnabled() {\n const features = getV3PreviewMetaContent();\n\n if (!features) {\n return false;\n }\n\n if (features.includes('svg-path-loading')) {\n return true;\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 } from '@stencil/core';\nimport { getCustomAssetUrl, isV3PreviewEnabled } 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\nfunction toCamelCase(value: string) {\n value = value.replace(/[\\(\\)\\[\\]\\{\\}\\=\\?\\!\\.\\:,\\-_\\+\\\\\\\"#~\\/]/g, ' ');\n let returnValue = '';\n let makeNextUppercase = true;\n value = value.toLowerCase();\n for (let i = 0; value.length > i; i++) {\n let c = value.charAt(i);\n if (c.match(/^\\s+$/g) || c.match(/[\\(\\)\\[\\]\\{\\}\\\\\\/]/g)) {\n makeNextUppercase = true;\n } else if (makeNextUppercase) {\n c = c.toUpperCase();\n makeNextUppercase = false;\n }\n returnValue += c;\n }\n const normalized = returnValue.replace(/\\s+/g, '');\n return normalized.charAt(0).toUpperCase() + normalized.slice(1);\n}\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 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 request = requests.get(url);\n\n if (request) {\n return request;\n }\n\n const cache = getIconCacheMap();\n\n if (cache.has(url)) {\n return cache.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 return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nfunction getAssetUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n return getAssetPath(`svg/${name}.svg`);\n}\n\nasync function getESMIcon(name: string) {\n const esmIcon = await import('./icons');\n let iconName = toCamelCase(name);\n iconName = `icon${iconName}`;\n\n return parseSVGDataContent(esmIcon[iconName]);\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 if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n if (isV3PreviewEnabled()) {\n console.warn('Using V3 preview feature for loading icons.');\n try {\n return fetchSVG(getAssetUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n }\n\n return getESMIcon(iconName);\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 connectedCallback() {\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"],"mappings":"gEAIA,SAASA,IACP,OAAOC,SAASC,cAAc,mCAChC,CAEA,SAASC,IACP,MAAMC,EAAuBJ,IAC7B,GAAII,EAAsB,CACxB,OAAOA,EAAqBC,aAAa,WAAWC,MAAM,I,CAG5D,OAAO,IACT,C,SAOgBC,IACd,MAAMC,EAAYP,SAASC,cAAc,8BACzC,GAAIM,EAAW,CACb,MAAMC,EAAOD,EAAUH,aAAa,WACpC,OAAOI,C,CAGT,OAAO,KACT,C,SAOgBC,IACd,MAAMC,EAAWR,IAEjB,IAAKQ,EAAU,CACb,OAAO,K,CAGT,GAAIA,EAASC,SAAS,oBAAqB,CACzC,OAAO,I,CAGT,OAAO,KACT,CChCA,IAAIC,EACJ,MAAMC,EAAW,IAAIC,IACrB,IAAIC,EAAS,KAEb,SAASC,EAAYC,GACnBA,EAAQA,EAAMC,QAAQ,0CAA2C,KACjE,IAAIC,EAAc,GAClB,IAAIC,EAAoB,KACxBH,EAAQA,EAAMI,cACd,IAAK,IAAIC,EAAI,EAAGL,EAAMM,OAASD,EAAGA,IAAK,CACrC,IAAIE,EAAIP,EAAMQ,OAAOH,GACrB,GAAIE,EAAEE,MAAM,WAAaF,EAAEE,MAAM,uBAAwB,CACvDN,EAAoB,I,MACf,GAAIA,EAAmB,CAC5BI,EAAIA,EAAEG,cACNP,EAAoB,K,CAEtBD,GAAeK,C,CAEjB,MAAMI,EAAaT,EAAYD,QAAQ,OAAQ,IAC/C,OAAOU,EAAWH,OAAO,GAAGE,cAAgBC,EAAWC,MAAM,EAC/D,CAEO,MAAMC,EAAkB,KAC7B,UAAWC,SAAW,YAAa,CACjC,OAAO,IAAIjB,G,CAGb,IA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