@pine-ds/icons 9.5.1 → 9.6.0
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/components/pds-icon.js +24 -133
- package/components/pds-icon.js.map +1 -1
- package/dist/cheatsheet.html +7 -5
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pds-icon.cjs.entry.js +23 -132
- package/dist/cjs/pds-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/pds-icon.entry.cjs.js.map +1 -1
- package/dist/cjs/pds-icons.cjs.js +1 -1
- package/dist/collection/components/pds-icon/pds-icon.js +17 -82
- package/dist/collection/components/pds-icon/pds-icon.js.map +1 -1
- package/dist/collection/components/pds-icon/request.js +9 -53
- package/dist/collection/components/pds-icon/request.js.map +1 -1
- package/dist/docs.json +5 -5
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pds-icon.entry.js +23 -132
- package/dist/esm/pds-icon.entry.js.map +1 -1
- package/dist/esm/pds-icons.js +1 -1
- package/dist/pds-icons/p-5a3a5e3c.entry.js +2 -0
- package/dist/pds-icons/p-5a3a5e3c.entry.js.map +1 -0
- package/dist/pds-icons/pds-icon.entry.esm.js.map +1 -1
- package/dist/pds-icons/pds-icons.esm.js +1 -1
- package/dist/pds-icons.json +11 -1
- package/dist/pds-icons.symbols.svg +2 -1
- package/dist/svg/switch-vertical.svg +1 -0
- package/dist/types/components/pds-icon/pds-icon.d.ts +1 -2
- package/dist/types/components/pds-icon/request.d.ts +1 -1
- package/dist/types/components.d.ts +2 -2
- package/icons/index.d.ts +2 -1
- package/icons/index.js +2 -1
- package/icons/index.mjs +2 -1
- package/icons/package.json +1 -1
- package/package.json +1 -1
- package/dist/pds-icons/p-560fb565.entry.js +0 -2
- package/dist/pds-icons/p-560fb565.entry.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds-icon.js","sourceRoot":"","sources":["../../../../src/components/pds-icon/pds-icon.tsx"],"names":[],"mapp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CAAC;AACT,CAAC,CAAC","sourcesContent":["import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';\nimport { getSvgContent, pdsIconContent } from './request';\nimport { getName, getUrl, inheritAttributes, isRTL, shouldRtlFlipIcon } from './utils';\n\n@Component({\n tag: 'pds-icon',\n assetsDirs: ['svg'],\n styleUrl: 'pds-icon.scss',\n shadow: true,\n})\nexport class PdsIcon {\n private didLoadIcon = false;\n private iconName: string | null = null;\n private io?: IntersectionObserver;\n private inheritedAttributes: { [k: string]: any } = {}; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n @Element() el!: HTMLPdsIconElement;\n\n @State() private ariaLabel?: string;\n @State() private isVisible = false;\n @State() private svgContent?: string;\n\n /**\n *\n * The color of the icon\n *\n */\n @Prop() color?: string;\n\n /**\n * Determines if the icon should be flipped when the `dir` is right-to-left (`\"rtl\"`).\n * This is automatically enabled for icons that are in the `ICONS_TO_FLIP` list and\n * when the `dir` is `\"rtl\"`. If `flipRtl` is set to `false`, the icon will not be flipped\n * even if the `dir` is `\"rtl\"`.\n */\n @Prop() flipRtl?: boolean;\n\n /**\n * This is a combination of both `name` and `src`. If a `src` URL is detected,\n * it will set the `src` property. Otherwise it assumes it's a built-in named\n * SVG and sets the `name` property.\n */\n @Prop() icon?: string;\n\n /**\n * The name of the icon to use from\n * the built-in set.\n */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * The size of the icon. This can be\n * 'small', 'regular', 'medium', 'large', or a\n * custom value (40px, 1rem, etc)\n *\n */\n @Prop({ reflect: true }) size?:\n | 'small' // 12px\n | 'regular' // 16px\n | 'medium' // 20px\n | 'large' // 24px\n | 'auto'\n | string = 'regular'\n\n /**\n *\n * Specifies the exact `src` of an SVG file to use.\n */\n @Prop() src?: string;\n\n private iconSize() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sizes: { [key: string]: any } = {\n small: '12px',\n regular: '16px',\n medium: '20px',\n large: '24px',\n }\n\n if (sizes[this.size]) {\n return sizes[this.size];\n } else {\n return this.size;\n }\n }\n\n componentDidLoad() {\n this.setCSSVariables();\n\n // Always attempt to load icon, but add delay for IntersectionObserver to complete\n setTimeout(() => {\n if (!this.didLoadIcon || !this.svgContent) {\n console.warn('Icon not loaded after component mount, forcing load attempt');\n this.isVisible = true; // Force visibility for fallback loading\n this.loadIcon();\n }\n }, 50);\n }\n\n componentWillLoad() {\n this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);\n this.setCSSVariables();\n }\n\n setCSSVariables() {\n this.el.style.setProperty(`--dimension-icon-height`, this.iconSize());\n this.el.style.setProperty(`--dimension-icon-width`, this.iconSize());\n this.el.style.setProperty(`--color-icon-fill`, typeof this.color !== 'undefined' ? this.color : 'currentColor');\n }\n\n connectedCallback() {\n // Set a fallback timeout in case IntersectionObserver never fires\n // This prevents icons from never loading due to intersection issues\n const fallbackTimeout = setTimeout(() => {\n if (!this.isVisible) {\n console.warn('IntersectionObserver timeout, forcing icon visibility');\n this.isVisible = true;\n this.loadIcon();\n }\n }, 100); // 100ms fallback\n\n this.waitUntilVisible(this.el, '50px', () => {\n clearTimeout(fallbackTimeout);\n this.isVisible = true;\n this.loadIcon();\n })\n }\n\n disconnectedCallback() {\n if (this.io) {\n this.io.disconnect();\n this.io = undefined;\n }\n }\n\n @Watch('size')\n @Watch('color')\n updateStyles() {\n this.setCSSVariables();\n }\n\n @Watch('name')\n @Watch('src')\n @Watch('icon')\n loadIcon() {\n if (Build.isBrowser) {\n const url = getUrl(this);\n if (url) {\n if (pdsIconContent.has(url)) {\n this.svgContent = pdsIconContent.get(url);\n } else {\n // Add comprehensive error handling and timeout\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(() => reject(new Error('Icon loading timeout')), 10000); // 10 second timeout\n });\n\n Promise.race([getSvgContent(url), timeoutPromise])\n .then(() => {\n this.svgContent = pdsIconContent.get(url);\n // Force re-render if content was loaded after initial render\n if (!this.svgContent) {\n console.warn(`Icon content not found after successful load: ${url}`);\n }\n })\n .catch((error) => {\n console.error(`Failed to load icon: ${url}`, error);\n // Set empty content to prevent infinite loading state\n pdsIconContent.set(url, '');\n this.svgContent = '';\n });\n }\n this.didLoadIcon = true;\n }\n }\n\n this.iconName = getName(this.name, this.icon);\n\n if (this.iconName) {\n this.ariaLabel = this.iconName.replace(/\\-/g, ' ');\n }\n }\n\n render() {\n const { ariaLabel, flipRtl, iconName,inheritedAttributes } = this;\n const shouldIconAutoFlip = iconName\n ? shouldRtlFlipIcon(iconName, this.el) && flipRtl !== false\n : false;\n const shouldFlip = flipRtl || shouldIconAutoFlip;\n\n // Debug information when enabled\n this.debugIconState();\n\n return (\n\n <Host\n aria-label={ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null }\n alt=\"\"\n role=\"img\"\n class={{\n ...createColorClasses(this.color),\n 'flip-rtl': shouldFlip,\n 'icon-rtl': shouldFlip && isRTL(this.el)\n }}\n {...inheritedAttributes}\n >\n {Build.isBrowser && this.svgContent ? (\n <div class=\"icon-inner\" innerHTML={this.svgContent}></div>\n ) : (\n <div class=\"icon-inner\"></div>\n )}\n </Host>\n )\n }\n\n /*****\n * Private Methods\n ****/\n\n private debugIconState() {\n if (typeof window !== 'undefined' && (window as Window & { __PDS_ICON_DEBUG__?: boolean }).__PDS_ICON_DEBUG__) {\n console.log('PDS Icon Debug:', {\n name: this.name,\n src: this.src,\n icon: this.icon,\n isVisible: this.isVisible,\n didLoadIcon: this.didLoadIcon,\n svgContent: this.svgContent ? 'loaded' : 'empty',\n url: getUrl(this),\n hasIntersectionObserver: !!this.io,\n element: this.el\n });\n }\n }\n\n private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {\n if (Build.isBrowser && typeof window !== 'undefined' && (window).IntersectionObserver) {\n try {\n const io = (this.io = new (window).IntersectionObserver(\n (data: IntersectionObserverEntry[]) => {\n if (data[0].isIntersecting) {\n io.disconnect();\n this.io = undefined;\n cb();\n }\n },\n { rootMargin },\n ));\n\n io.observe(el);\n\n // Add a safety timeout for IntersectionObserver\n setTimeout(() => {\n if (this.io) {\n console.warn('IntersectionObserver did not trigger within 5 seconds, forcing callback');\n this.io.disconnect();\n this.io = undefined;\n cb();\n }\n }, 5000);\n } catch (error) {\n console.error('IntersectionObserver initialization failed:', error);\n // Fall back to immediate execution\n cb();\n }\n } else {\n // browser doesn't support IntersectionObserver\n // so just fallback to always show it\n cb();\n }\n }\n\n private hasAriaHidden = () => {\n const { el } = this;\n\n return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';\n }\n}\n\nconst createColorClasses = (color: string | undefined) => {\n return color\n ? {\n 'pds-color': true,\n [`pds-color-${color}`]: true,\n }\n : null;\n };\n"]}
|
|
1
|
+
{"version":3,"file":"pds-icon.js","sourceRoot":"","sources":["../../../../src/components/pds-icon/pds-icon.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAQvF,MAAM,OAAO,OAAO;IANpB;QAOU,gBAAW,GAAG,KAAK,CAAC;QACpB,aAAQ,GAAkB,IAAI,CAAC;QAE/B,wBAAmB,GAAyB,EAAE,CAAC,CAAC,yDAAyD;QAKhG,cAAS,GAAG,KAAK,CAAC;QA+BnC;;;;;WAKG;QACsB,SAAI,GAMhB,SAAS,CAAA;QA4Id,kBAAa,GAAG,GAAG,EAAE;YAC3B,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;YAEpB,OAAO,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,MAAM,CAAC;QACrF,CA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EAAE,CAAC;gBACP,CAAC;YACH,CAAC,EACD,EAAE,UAAU,EAAE,CACf,CAAC,CAAC;YAEH,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,+CAA+C;YAC/C,qCAAqC;YACrC,EAAE,EAAE,CAAC;QACP,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOF;AAED,MAAM,kBAAkB,GAAG,CAAC,KAAyB,EAAE,EAAE;IACvD,OAAO,KAAK;QACX,CAAC,CAAC;YACE,WAAW,EAAE,IAAI;YACjB,CAAC,aAAa,KAAK,EAAE,CAAC,EAAE,IAAI;SAC7B;QACH,CAAC,CAAC,IAAI,CAAC;AACT,CAAC,CAAC","sourcesContent":["import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';\nimport { getSvgContent, pdsIconContent } from './request';\nimport { getName, getUrl, inheritAttributes, isRTL, shouldRtlFlipIcon } from './utils';\n\n@Component({\n tag: 'pds-icon',\n assetsDirs: ['svg'],\n styleUrl: 'pds-icon.scss',\n shadow: true,\n})\nexport class PdsIcon {\n private didLoadIcon = false;\n private iconName: string | null = null;\n private io?: IntersectionObserver;\n private inheritedAttributes: { [k: string]: any } = {}; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n @Element() el!: HTMLPdsIconElement;\n\n @State() private ariaLabel?: string;\n @State() private isVisible = false;\n @State() private svgContent?: string;\n\n /**\n *\n * The color of the icon\n *\n */\n @Prop() color?: string;\n\n /**\n * Determines if the icon should be flipped when the `dir` is right-to-left (`\"rtl\"`).\n * This is automatically enabled for icons that are in the `ICONS_TO_FLIP` list and\n * when the `dir` is `\"rtl\"`. If `flipRtl` is set to `false`, the icon will not be flipped\n * even if the `dir` is `\"rtl\"`.\n */\n @Prop() flipRtl?: boolean;\n\n /**\n * This is a combination of both `name` and `src`. If a `src` URL is detected,\n * it will set the `src` property. Otherwise it assumes it's a built-in named\n * SVG and sets the `name` property.\n */\n @Prop() icon?: any;\n\n /**\n * The name of the icon to use from\n * the built-in set.\n */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * The size of the icon. This can be\n * 'small', 'regular', 'medium', 'large', or a\n * custom value (40px, 1rem, etc)\n *\n */\n @Prop({ reflect: true }) size?:\n | 'small' // 12px\n | 'regular' // 16px\n | 'medium' // 20px\n | 'large' // 24px\n | 'auto'\n | string = 'regular'\n\n /**\n *\n * Specifies the exact `src` of an SVG file to use.\n */\n @Prop() src?: string;\n\n private iconSize() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sizes: { [key: string]: any } = {\n small: '12px',\n regular: '16px',\n medium: '20px',\n large: '24px',\n }\n\n if (sizes[this.size]) {\n return sizes[this.size];\n } else {\n return this.size;\n }\n }\n\n componentDidLoad() {\n this.setCSSVariables();\n\n if (!this.didLoadIcon) {\n this.loadIcon();\n }\n }\n\n componentWillLoad() {\n this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);\n this.setCSSVariables();\n }\n\n setCSSVariables() {\n this.el.style.setProperty(`--dimension-icon-height`, this.iconSize());\n this.el.style.setProperty(`--dimension-icon-width`, this.iconSize());\n this.el.style.setProperty(`--color-icon-fill`, typeof this.color !== 'undefined' ? this.color : 'currentColor');\n }\n\n connectedCallback() {\n this.waitUntilVisible(this.el, '50px', () => {\n this.isVisible = true;\n this.loadIcon();\n })\n }\n\n disconnectedCallback() {\n if (this.io) {\n this.io.disconnect();\n this.io = undefined;\n }\n }\n\n @Watch('size')\n @Watch('color')\n updateStyles() {\n this.setCSSVariables();\n }\n\n @Watch('name')\n @Watch('src')\n @Watch('icon')\n loadIcon() {\n if (Build.isBrowser && this.isVisible) {\n const url = getUrl(this);\n if (url) {\n if (pdsIconContent.has(url)) {\n this.svgContent = pdsIconContent.get(url);\n } else {\n getSvgContent(url).then(() => (this.svgContent = pdsIconContent.get(url)));\n }\n this.didLoadIcon = true;\n }\n }\n\n this.iconName = getName(this.name, this.icon);\n\n if (this.iconName) {\n this.ariaLabel = this.iconName.replace(/\\-/g, ' ');\n }\n }\n\n render() {\n const { ariaLabel, flipRtl, iconName,inheritedAttributes } = this;\n const shouldIconAutoFlip = iconName\n ? shouldRtlFlipIcon(iconName, this.el) && flipRtl !== false\n : false;\n const shouldFlip = flipRtl || shouldIconAutoFlip;\n\n return (\n\n <Host\n aria-label={ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null }\n alt=\"\"\n role=\"img\"\n class={{\n ...createColorClasses(this.color),\n 'flip-rtl': shouldFlip,\n 'icon-rtl': shouldFlip && isRTL(this.el)\n }}\n {...inheritedAttributes}\n >\n {Build.isBrowser && this.svgContent ? (\n <div class=\"icon-inner\" innerHTML={this.svgContent}></div>\n ) : (\n <div class=\"icon-inner\"></div>\n )}\n </Host>\n )\n }\n\n /*****\n * Private Methods\n ****/\n\n private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {\n if (Build.isBrowser && typeof window !== 'undefined' && (window).IntersectionObserver) {\n const io = (this.io = new (window).IntersectionObserver(\n (data: IntersectionObserverEntry[]) => {\n if (data[0].isIntersecting) {\n io.disconnect();\n this.io = undefined;\n cb();\n }\n },\n { rootMargin },\n ));\n\n io.observe(el);\n } else {\n // browser doesn't support IntersectionObserver\n // so just fallback to always show it\n cb();\n }\n }\n\n private hasAriaHidden = () => {\n const { el } = this;\n\n return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';\n }\n}\n\nconst createColorClasses = (color: string | undefined) => {\n return color\n ? {\n 'pds-color': true,\n [`pds-color-${color}`]: true,\n }\n : null;\n };\n"]}
|
|
@@ -2,7 +2,7 @@ import { isEncodedDataUrl, isSvgDataUrl, validateContent } from "./validate";
|
|
|
2
2
|
export const pdsIconContent = new Map();
|
|
3
3
|
const requests = new Map(); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
4
4
|
let parser;
|
|
5
|
-
export const getSvgContent = (url, sanitize = false
|
|
5
|
+
export const getSvgContent = (url, sanitize = false) => {
|
|
6
6
|
let req = requests.get(url);
|
|
7
7
|
if (!req) {
|
|
8
8
|
if (typeof fetch != 'undefined' && typeof document !== 'undefined') {
|
|
@@ -10,74 +10,30 @@ export const getSvgContent = (url, sanitize = false, retryCount = 0) => {
|
|
|
10
10
|
if (!parser) {
|
|
11
11
|
parser = new DOMParser();
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
pdsIconContent.set(url, svg.outerHTML);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
console.warn(`No SVG found in data URL: ${url}`);
|
|
21
|
-
pdsIconContent.set(url, '');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
console.error(`Failed to parse SVG data URL: ${url}`, error);
|
|
26
|
-
pdsIconContent.set(url, '');
|
|
13
|
+
const doc = parser.parseFromString(url, 'text/html');
|
|
14
|
+
const svg = doc.querySelector('svg');
|
|
15
|
+
if (svg) {
|
|
16
|
+
pdsIconContent.set(url, svg.outerHTML);
|
|
27
17
|
}
|
|
28
18
|
return Promise.resolve();
|
|
29
19
|
}
|
|
30
20
|
else {
|
|
31
|
-
//
|
|
32
|
-
req = fetch(url
|
|
33
|
-
method: 'GET',
|
|
34
|
-
headers: {
|
|
35
|
-
'Accept': 'image/svg+xml,text/plain,*/*'
|
|
36
|
-
},
|
|
37
|
-
cache: 'force-cache' // Aggressive caching for icons
|
|
38
|
-
}).then((rsp) => {
|
|
21
|
+
// we don't have a request
|
|
22
|
+
req = fetch(url).then((rsp) => {
|
|
39
23
|
if (rsp.ok) {
|
|
40
24
|
return rsp.text().then((svgContent) => {
|
|
41
25
|
if (svgContent && sanitize !== false) {
|
|
42
26
|
svgContent = validateContent(svgContent);
|
|
43
27
|
}
|
|
44
|
-
|
|
45
|
-
pdsIconContent.set(url, svgContent);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
console.warn(`Empty SVG content received for: ${url}`);
|
|
49
|
-
pdsIconContent.set(url, '');
|
|
50
|
-
}
|
|
28
|
+
pdsIconContent.set(url, svgContent || '');
|
|
51
29
|
});
|
|
52
30
|
}
|
|
53
|
-
|
|
54
|
-
throw new Error(`HTTP ${rsp.status}: ${rsp.statusText}`);
|
|
55
|
-
}
|
|
56
|
-
}).catch((error) => {
|
|
57
|
-
console.error(`Failed to fetch icon ${url}:`, error);
|
|
58
|
-
// Retry logic - attempt up to 3 times with exponential backoff
|
|
59
|
-
if (retryCount < 3) {
|
|
60
|
-
const delay = Math.pow(2, retryCount) * 1000; // 1s, 2s, 4s
|
|
61
|
-
console.log(`Retrying icon load in ${delay}ms (attempt ${retryCount + 1}/3): ${url}`);
|
|
62
|
-
return new Promise((resolve) => {
|
|
63
|
-
setTimeout(() => {
|
|
64
|
-
// Clear the failed request from cache to allow retry
|
|
65
|
-
requests.delete(url);
|
|
66
|
-
resolve(getSvgContent(url, sanitize, retryCount + 1));
|
|
67
|
-
}, delay);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// Final failure - set empty content to prevent infinite loading
|
|
72
|
-
pdsIconContent.set(url, '');
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
31
|
+
pdsIconContent.set(url, '');
|
|
75
32
|
});
|
|
76
33
|
requests.set(url, req);
|
|
77
34
|
}
|
|
78
35
|
}
|
|
79
36
|
else {
|
|
80
|
-
console.warn('Fetch or document not available, setting empty icon content');
|
|
81
37
|
pdsIconContent.set(url, '');
|
|
82
38
|
return Promise.resolve();
|
|
83
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/components/pds-icon/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gB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AAc,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;gBACzC,CAAC;gBAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,0BAA0B;gBAC1B,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;oBAC5B,IAAI,GAAG,CAAC,EAAE,EAAE,CAAC;wBACX,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;4BACpC,IAAI,UAAU,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;gCACrC,UAAU,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;4BAC3C,CAAC;4BACD,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;wBAC5C,CAAC,CAAC,CAAC;oBACL,CAAC;oBACD,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBAC9B,CAAC,CAAC,CAAC;gBAEH,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAA","sourcesContent":["import { isEncodedDataUrl, isSvgDataUrl, validateContent } from './validate';\n\nexport const pdsIconContent = new Map<string, string>();\nconst requests = new Map<string, Promise<any>>(); // eslint-disable-line @typescript-eslint/no-explicit-any\n\nlet parser: DOMParser;\n\nexport const getSvgContent = (url: string, sanitize = false) => {\n let req = requests.get(url);\n\n if(!req) {\n if (typeof fetch != 'undefined' && typeof document !== 'undefined') {\n if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {\n if (!parser) {\n parser = new DOMParser();\n }\n\n const doc = parser.parseFromString(url, 'text/html');\n const svg = doc.querySelector('svg');\n\n if (svg) {\n pdsIconContent.set(url, svg.outerHTML);\n }\n\n return Promise.resolve();\n } else {\n // we don't have a request\n req = fetch(url).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n pdsIconContent.set(url, svgContent || '');\n });\n }\n pdsIconContent.set(url, '');\n });\n\n requests.set(url, req);\n }\n } else {\n pdsIconContent.set(url, '');\n return Promise.resolve();\n }\n }\n\n return req;\n}\n"]}
|
package/dist/docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2025-
|
|
2
|
+
"timestamp": "2025-07-03T11:05:25",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.28.2",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
"name": "icon",
|
|
66
|
-
"type": "
|
|
66
|
+
"type": "any",
|
|
67
67
|
"complexType": {
|
|
68
|
-
"original": "
|
|
69
|
-
"resolved": "
|
|
68
|
+
"original": "any",
|
|
69
|
+
"resolved": "any",
|
|
70
70
|
"references": {}
|
|
71
71
|
},
|
|
72
72
|
"mutable": false,
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"docsTags": [],
|
|
77
77
|
"values": [
|
|
78
78
|
{
|
|
79
|
-
"type": "
|
|
79
|
+
"type": "any"
|
|
80
80
|
}
|
|
81
81
|
],
|
|
82
82
|
"optional": true,
|
package/dist/esm/loader.js
CHANGED
|
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-DQuL1Twl.js';
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await globalScripts();
|
|
8
|
-
return bootstrapLazy([["pds-icon",[[1,"pds-icon",{"color":[1],"flipRtl":[4,"flip-rtl"],"icon":[
|
|
8
|
+
return bootstrapLazy([["pds-icon",[[1,"pds-icon",{"color":[1],"flipRtl":[4,"flip-rtl"],"icon":[8],"name":[513],"size":[513],"src":[1],"ariaLabel":[32],"isVisible":[32],"svgContent":[32]},null,{"size":["updateStyles"],"color":["updateStyles"],"name":["loadIcon"],"src":["loadIcon"],"icon":["loadIcon"]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { defineCustomElements };
|
|
@@ -49,7 +49,7 @@ const isEncodedDataUrl = (url) => url.indexOf(';utf8,') !== -1;
|
|
|
49
49
|
const pdsIconContent = new Map();
|
|
50
50
|
const requests = new Map(); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
51
51
|
let parser;
|
|
52
|
-
const getSvgContent = (url, sanitize = false
|
|
52
|
+
const getSvgContent = (url, sanitize = false) => {
|
|
53
53
|
let req = requests.get(url);
|
|
54
54
|
if (!req) {
|
|
55
55
|
if (typeof fetch != 'undefined' && typeof document !== 'undefined') {
|
|
@@ -57,74 +57,30 @@ const getSvgContent = (url, sanitize = false, retryCount = 0) => {
|
|
|
57
57
|
if (!parser) {
|
|
58
58
|
parser = new DOMParser();
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
pdsIconContent.set(url, svg.outerHTML);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
console.warn(`No SVG found in data URL: ${url}`);
|
|
68
|
-
pdsIconContent.set(url, '');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
console.error(`Failed to parse SVG data URL: ${url}`, error);
|
|
73
|
-
pdsIconContent.set(url, '');
|
|
60
|
+
const doc = parser.parseFromString(url, 'text/html');
|
|
61
|
+
const svg = doc.querySelector('svg');
|
|
62
|
+
if (svg) {
|
|
63
|
+
pdsIconContent.set(url, svg.outerHTML);
|
|
74
64
|
}
|
|
75
65
|
return Promise.resolve();
|
|
76
66
|
}
|
|
77
67
|
else {
|
|
78
|
-
//
|
|
79
|
-
req = fetch(url
|
|
80
|
-
method: 'GET',
|
|
81
|
-
headers: {
|
|
82
|
-
'Accept': 'image/svg+xml,text/plain,*/*'
|
|
83
|
-
},
|
|
84
|
-
cache: 'force-cache' // Aggressive caching for icons
|
|
85
|
-
}).then((rsp) => {
|
|
68
|
+
// we don't have a request
|
|
69
|
+
req = fetch(url).then((rsp) => {
|
|
86
70
|
if (rsp.ok) {
|
|
87
71
|
return rsp.text().then((svgContent) => {
|
|
88
72
|
if (svgContent && sanitize !== false) {
|
|
89
73
|
svgContent = validateContent(svgContent);
|
|
90
74
|
}
|
|
91
|
-
|
|
92
|
-
pdsIconContent.set(url, svgContent);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
console.warn(`Empty SVG content received for: ${url}`);
|
|
96
|
-
pdsIconContent.set(url, '');
|
|
97
|
-
}
|
|
75
|
+
pdsIconContent.set(url, svgContent || '');
|
|
98
76
|
});
|
|
99
77
|
}
|
|
100
|
-
|
|
101
|
-
throw new Error(`HTTP ${rsp.status}: ${rsp.statusText}`);
|
|
102
|
-
}
|
|
103
|
-
}).catch((error) => {
|
|
104
|
-
console.error(`Failed to fetch icon ${url}:`, error);
|
|
105
|
-
// Retry logic - attempt up to 3 times with exponential backoff
|
|
106
|
-
if (retryCount < 3) {
|
|
107
|
-
const delay = Math.pow(2, retryCount) * 1000; // 1s, 2s, 4s
|
|
108
|
-
console.log(`Retrying icon load in ${delay}ms (attempt ${retryCount + 1}/3): ${url}`);
|
|
109
|
-
return new Promise((resolve) => {
|
|
110
|
-
setTimeout(() => {
|
|
111
|
-
// Clear the failed request from cache to allow retry
|
|
112
|
-
requests.delete(url);
|
|
113
|
-
resolve(getSvgContent(url, sanitize, retryCount + 1));
|
|
114
|
-
}, delay);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// Final failure - set empty content to prevent infinite loading
|
|
119
|
-
pdsIconContent.set(url, '');
|
|
120
|
-
throw error;
|
|
121
|
-
}
|
|
78
|
+
pdsIconContent.set(url, '');
|
|
122
79
|
});
|
|
123
80
|
requests.set(url, req);
|
|
124
81
|
}
|
|
125
82
|
}
|
|
126
83
|
else {
|
|
127
|
-
console.warn('Fetch or document not available, setting empty icon content');
|
|
128
84
|
pdsIconContent.set(url, '');
|
|
129
85
|
return Promise.resolve();
|
|
130
86
|
}
|
|
@@ -170,14 +126,9 @@ const PdsIcon = class {
|
|
|
170
126
|
}
|
|
171
127
|
componentDidLoad() {
|
|
172
128
|
this.setCSSVariables();
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
console.warn('Icon not loaded after component mount, forcing load attempt');
|
|
177
|
-
this.isVisible = true; // Force visibility for fallback loading
|
|
178
|
-
this.loadIcon();
|
|
179
|
-
}
|
|
180
|
-
}, 50);
|
|
129
|
+
if (!this.didLoadIcon) {
|
|
130
|
+
this.loadIcon();
|
|
131
|
+
}
|
|
181
132
|
}
|
|
182
133
|
componentWillLoad() {
|
|
183
134
|
this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);
|
|
@@ -189,17 +140,7 @@ const PdsIcon = class {
|
|
|
189
140
|
this.el.style.setProperty(`--color-icon-fill`, typeof this.color !== 'undefined' ? this.color : 'currentColor');
|
|
190
141
|
}
|
|
191
142
|
connectedCallback() {
|
|
192
|
-
// Set a fallback timeout in case IntersectionObserver never fires
|
|
193
|
-
// This prevents icons from never loading due to intersection issues
|
|
194
|
-
const fallbackTimeout = setTimeout(() => {
|
|
195
|
-
if (!this.isVisible) {
|
|
196
|
-
console.warn('IntersectionObserver timeout, forcing icon visibility');
|
|
197
|
-
this.isVisible = true;
|
|
198
|
-
this.loadIcon();
|
|
199
|
-
}
|
|
200
|
-
}, 100); // 100ms fallback
|
|
201
143
|
this.waitUntilVisible(this.el, '50px', () => {
|
|
202
|
-
clearTimeout(fallbackTimeout);
|
|
203
144
|
this.isVisible = true;
|
|
204
145
|
this.loadIcon();
|
|
205
146
|
});
|
|
@@ -214,31 +155,14 @@ const PdsIcon = class {
|
|
|
214
155
|
this.setCSSVariables();
|
|
215
156
|
}
|
|
216
157
|
loadIcon() {
|
|
217
|
-
{
|
|
158
|
+
if (this.isVisible) {
|
|
218
159
|
const url = getUrl(this);
|
|
219
160
|
if (url) {
|
|
220
161
|
if (pdsIconContent.has(url)) {
|
|
221
162
|
this.svgContent = pdsIconContent.get(url);
|
|
222
163
|
}
|
|
223
164
|
else {
|
|
224
|
-
|
|
225
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
226
|
-
setTimeout(() => reject(new Error('Icon loading timeout')), 10000); // 10 second timeout
|
|
227
|
-
});
|
|
228
|
-
Promise.race([getSvgContent(url), timeoutPromise])
|
|
229
|
-
.then(() => {
|
|
230
|
-
this.svgContent = pdsIconContent.get(url);
|
|
231
|
-
// Force re-render if content was loaded after initial render
|
|
232
|
-
if (!this.svgContent) {
|
|
233
|
-
console.warn(`Icon content not found after successful load: ${url}`);
|
|
234
|
-
}
|
|
235
|
-
})
|
|
236
|
-
.catch((error) => {
|
|
237
|
-
console.error(`Failed to load icon: ${url}`, error);
|
|
238
|
-
// Set empty content to prevent infinite loading state
|
|
239
|
-
pdsIconContent.set(url, '');
|
|
240
|
-
this.svgContent = '';
|
|
241
|
-
});
|
|
165
|
+
getSvgContent(url).then(() => (this.svgContent = pdsIconContent.get(url)));
|
|
242
166
|
}
|
|
243
167
|
this.didLoadIcon = true;
|
|
244
168
|
}
|
|
@@ -254,54 +178,21 @@ const PdsIcon = class {
|
|
|
254
178
|
? shouldRtlFlipIcon(iconName, this.el) && flipRtl !== false
|
|
255
179
|
: false;
|
|
256
180
|
const shouldFlip = flipRtl || shouldIconAutoFlip;
|
|
257
|
-
|
|
258
|
-
this.debugIconState();
|
|
259
|
-
return (h(Host, Object.assign({ key: '82420f9d474c932c9ed82bbf61b075cbbc67b6db', "aria-label": ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null, alt: "", role: "img", class: Object.assign(Object.assign({}, createColorClasses(this.color)), { 'flip-rtl': shouldFlip, 'icon-rtl': shouldFlip && isRTL(this.el) }) }, inheritedAttributes), this.svgContent ? (h("div", { class: "icon-inner", innerHTML: this.svgContent })) : (h("div", { class: "icon-inner" }))));
|
|
181
|
+
return (h(Host, Object.assign({ key: 'bc8e46daa75df27a8039e0e767bdb43164ad7d4c', "aria-label": ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null, alt: "", role: "img", class: Object.assign(Object.assign({}, createColorClasses(this.color)), { 'flip-rtl': shouldFlip, 'icon-rtl': shouldFlip && isRTL(this.el) }) }, inheritedAttributes), this.svgContent ? (h("div", { class: "icon-inner", innerHTML: this.svgContent })) : (h("div", { class: "icon-inner" }))));
|
|
260
182
|
}
|
|
261
183
|
/*****
|
|
262
184
|
* Private Methods
|
|
263
185
|
****/
|
|
264
|
-
debugIconState() {
|
|
265
|
-
if (typeof window !== 'undefined' && window.__PDS_ICON_DEBUG__) {
|
|
266
|
-
console.log('PDS Icon Debug:', {
|
|
267
|
-
name: this.name,
|
|
268
|
-
src: this.src,
|
|
269
|
-
icon: this.icon,
|
|
270
|
-
isVisible: this.isVisible,
|
|
271
|
-
didLoadIcon: this.didLoadIcon,
|
|
272
|
-
svgContent: this.svgContent ? 'loaded' : 'empty',
|
|
273
|
-
url: getUrl(this),
|
|
274
|
-
hasIntersectionObserver: !!this.io,
|
|
275
|
-
element: this.el
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
186
|
waitUntilVisible(el, rootMargin, cb) {
|
|
280
187
|
if (typeof window !== 'undefined' && (window).IntersectionObserver) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
io.observe(el);
|
|
290
|
-
// Add a safety timeout for IntersectionObserver
|
|
291
|
-
setTimeout(() => {
|
|
292
|
-
if (this.io) {
|
|
293
|
-
console.warn('IntersectionObserver did not trigger within 5 seconds, forcing callback');
|
|
294
|
-
this.io.disconnect();
|
|
295
|
-
this.io = undefined;
|
|
296
|
-
cb();
|
|
297
|
-
}
|
|
298
|
-
}, 5000);
|
|
299
|
-
}
|
|
300
|
-
catch (error) {
|
|
301
|
-
console.error('IntersectionObserver initialization failed:', error);
|
|
302
|
-
// Fall back to immediate execution
|
|
303
|
-
cb();
|
|
304
|
-
}
|
|
188
|
+
const io = (this.io = new (window).IntersectionObserver((data) => {
|
|
189
|
+
if (data[0].isIntersecting) {
|
|
190
|
+
io.disconnect();
|
|
191
|
+
this.io = undefined;
|
|
192
|
+
cb();
|
|
193
|
+
}
|
|
194
|
+
}, { rootMargin }));
|
|
195
|
+
io.observe(el);
|
|
305
196
|
}
|
|
306
197
|
else {
|
|
307
198
|
// browser doesn't support IntersectionObserver
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds-icon.entry.js","sources":["src/components/pds-icon/validate.ts","src/components/pds-icon/request.ts","src/components/pds-icon/pds-icon.scss?tag=pds-icon&encapsulation=shadow","src/components/pds-icon/pds-icon.tsx"],"sourcesContent":["import { isStr } from './utils';\n\nexport const validateContent = (svgContent: string) => {\n const div = document.createElement('div');\n div.innerHTML = svgContent;\n\n // setup this way to ensure it works on our buddy IE\n for (let i = div.childNodes.length - 1; i >= 0; i--) {\n if (div.childNodes[i].nodeName.toLowerCase() !== 'svg') {\n div.removeChild(div.childNodes[i]);\n }\n }\n\n // must only have 1 root element\n const svgElm = div.firstElementChild;\n if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {\n const svgClass = svgElm.getAttribute('class') || '';\n svgElm.setAttribute('class', (svgClass + ' s-pds-icon').trim());\n\n // root element must be an svg\n // lets double check we've got valid elements\n // do not allow scripts\n if (isValid(svgElm as HTMLElement)) {\n return div.innerHTML;\n }\n }\n return '';\n};\n\nexport const isValid = (elm: HTMLElement) => {\n if (elm.nodeType === 1) {\n if (elm.nodeName.toLowerCase() === 'script') {\n return false;\n }\n\n for (let i = 0; i < elm.attributes.length; i++) {\n const name = elm.attributes[i].name;\n if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {\n return false;\n }\n }\n\n for (let i = 0; i < elm.childNodes.length; i++) {\n if (!isValid(elm.childNodes[i] as HTMLElement)) {\n return false;\n }\n }\n }\n return true;\n};\n\nexport const isSvgDataUrl = (url: string) => url.startsWith('data:image/svg+xml');\nexport const isEncodedDataUrl = (url: string) => url.indexOf(';utf8,') !== -1;\n","import { isEncodedDataUrl, isSvgDataUrl, validateContent } from './validate';\n\nexport const pdsIconContent = new Map<string, string>();\nconst requests = new Map<string, Promise<any>>(); // eslint-disable-line @typescript-eslint/no-explicit-any\n\nlet parser: DOMParser;\n\nexport const getSvgContent = (url: string, sanitize = false, retryCount = 0) => {\n let req = requests.get(url);\n\n if(!req) {\n if (typeof fetch != 'undefined' && typeof document !== 'undefined') {\n if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {\n if (!parser) {\n parser = new DOMParser();\n }\n\n try {\n const doc = parser.parseFromString(url, 'text/html');\n const svg = doc.querySelector('svg');\n\n if (svg) {\n pdsIconContent.set(url, svg.outerHTML);\n } else {\n console.warn(`No SVG found in data URL: ${url}`);\n pdsIconContent.set(url, '');\n }\n } catch (error) {\n console.error(`Failed to parse SVG data URL: ${url}`, error);\n pdsIconContent.set(url, '');\n }\n\n return Promise.resolve();\n } else {\n // Add retry logic and better error handling\n req = fetch(url, {\n method: 'GET',\n headers: {\n 'Accept': 'image/svg+xml,text/plain,*/*'\n },\n cache: 'force-cache' // Aggressive caching for icons\n }).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n if (svgContent) {\n pdsIconContent.set(url, svgContent);\n } else {\n console.warn(`Empty SVG content received for: ${url}`);\n pdsIconContent.set(url, '');\n }\n });\n } else {\n throw new Error(`HTTP ${rsp.status}: ${rsp.statusText}`);\n }\n }).catch((error) => {\n console.error(`Failed to fetch icon ${url}:`, error);\n\n // Retry logic - attempt up to 3 times with exponential backoff\n if (retryCount < 3) {\n const delay = Math.pow(2, retryCount) * 1000; // 1s, 2s, 4s\n console.log(`Retrying icon load in ${delay}ms (attempt ${retryCount + 1}/3): ${url}`);\n\n return new Promise((resolve) => {\n setTimeout(() => {\n // Clear the failed request from cache to allow retry\n requests.delete(url);\n resolve(getSvgContent(url, sanitize, retryCount + 1));\n }, delay);\n });\n } else {\n // Final failure - set empty content to prevent infinite loading\n pdsIconContent.set(url, '');\n throw error;\n }\n });\n\n requests.set(url, req);\n }\n } else {\n console.warn('Fetch or document not available, setting empty icon content');\n pdsIconContent.set(url, '');\n return Promise.resolve();\n }\n }\n\n return req;\n}\n",":host {\n --dimension-icon-height: 16px;\n --dimension-icon-width: 16px;\n --color-icon-fill: currentColor;\n\n contain: strict;\n display: inline-block;\n fill: var(--color-icon-fill);\n flex-shrink: 0;\n height: var(--dimension-icon-height);\n width: var(--dimension-icon-width);\n\n .pdsicon {\n fill: var(--color-icon-fill);\n }\n}\n\n.pds-icon-fill-none {\n fill: none;\n}\n\n.icon-inner,\n.pds-icon,\nsvg {\n display: block;\n height: 100%;\n width: 100%;\n}\n\n/* :host-context is supported in chromium; :dir is supported in safari & firefox */\n:host(.flip-rtl):host-context([dir='rtl']) .icon-inner {\n transform: scaleX(-1);\n}\n\n:host(.flip-rtl:dir(rtl)) .icon-inner {\n transform: scaleX(-1);\n}\n\n/**\n * This is needed for WebKit otherwise the fallback\n * will always cause the icon to be flipped if the document\n * loads in RTL.\n */\n:host(.flip-rtl:dir(ltr)) .icon-inner {\n transform: scaleX(1);\n}\n\n","import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';\nimport { getSvgContent, pdsIconContent } from './request';\nimport { getName, getUrl, inheritAttributes, isRTL, shouldRtlFlipIcon } from './utils';\n\n@Component({\n tag: 'pds-icon',\n assetsDirs: ['svg'],\n styleUrl: 'pds-icon.scss',\n shadow: true,\n})\nexport class PdsIcon {\n private didLoadIcon = false;\n private iconName: string | null = null;\n private io?: IntersectionObserver;\n private inheritedAttributes: { [k: string]: any } = {}; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n @Element() el!: HTMLPdsIconElement;\n\n @State() private ariaLabel?: string;\n @State() private isVisible = false;\n @State() private svgContent?: string;\n\n /**\n *\n * The color of the icon\n *\n */\n @Prop() color?: string;\n\n /**\n * Determines if the icon should be flipped when the `dir` is right-to-left (`\"rtl\"`).\n * This is automatically enabled for icons that are in the `ICONS_TO_FLIP` list and\n * when the `dir` is `\"rtl\"`. If `flipRtl` is set to `false`, the icon will not be flipped\n * even if the `dir` is `\"rtl\"`.\n */\n @Prop() flipRtl?: boolean;\n\n /**\n * This is a combination of both `name` and `src`. If a `src` URL is detected,\n * it will set the `src` property. Otherwise it assumes it's a built-in named\n * SVG and sets the `name` property.\n */\n @Prop() icon?: string;\n\n /**\n * The name of the icon to use from\n * the built-in set.\n */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * The size of the icon. This can be\n * 'small', 'regular', 'medium', 'large', or a\n * custom value (40px, 1rem, etc)\n *\n */\n @Prop({ reflect: true }) size?:\n | 'small' // 12px\n | 'regular' // 16px\n | 'medium' // 20px\n | 'large' // 24px\n | 'auto'\n | string = 'regular'\n\n /**\n *\n * Specifies the exact `src` of an SVG file to use.\n */\n @Prop() src?: string;\n\n private iconSize() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sizes: { [key: string]: any } = {\n small: '12px',\n regular: '16px',\n medium: '20px',\n large: '24px',\n }\n\n if (sizes[this.size]) {\n return sizes[this.size];\n } else {\n return this.size;\n }\n }\n\n componentDidLoad() {\n this.setCSSVariables();\n\n // Always attempt to load icon, but add delay for IntersectionObserver to complete\n setTimeout(() => {\n if (!this.didLoadIcon || !this.svgContent) {\n console.warn('Icon not loaded after component mount, forcing load attempt');\n this.isVisible = true; // Force visibility for fallback loading\n this.loadIcon();\n }\n }, 50);\n }\n\n componentWillLoad() {\n this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);\n this.setCSSVariables();\n }\n\n setCSSVariables() {\n this.el.style.setProperty(`--dimension-icon-height`, this.iconSize());\n this.el.style.setProperty(`--dimension-icon-width`, this.iconSize());\n this.el.style.setProperty(`--color-icon-fill`, typeof this.color !== 'undefined' ? this.color : 'currentColor');\n }\n\n connectedCallback() {\n // Set a fallback timeout in case IntersectionObserver never fires\n // This prevents icons from never loading due to intersection issues\n const fallbackTimeout = setTimeout(() => {\n if (!this.isVisible) {\n console.warn('IntersectionObserver timeout, forcing icon visibility');\n this.isVisible = true;\n this.loadIcon();\n }\n }, 100); // 100ms fallback\n\n this.waitUntilVisible(this.el, '50px', () => {\n clearTimeout(fallbackTimeout);\n this.isVisible = true;\n this.loadIcon();\n })\n }\n\n disconnectedCallback() {\n if (this.io) {\n this.io.disconnect();\n this.io = undefined;\n }\n }\n\n @Watch('size')\n @Watch('color')\n updateStyles() {\n this.setCSSVariables();\n }\n\n @Watch('name')\n @Watch('src')\n @Watch('icon')\n loadIcon() {\n if (Build.isBrowser) {\n const url = getUrl(this);\n if (url) {\n if (pdsIconContent.has(url)) {\n this.svgContent = pdsIconContent.get(url);\n } else {\n // Add comprehensive error handling and timeout\n const timeoutPromise = new Promise((_, reject) => {\n setTimeout(() => reject(new Error('Icon loading timeout')), 10000); // 10 second timeout\n });\n\n Promise.race([getSvgContent(url), timeoutPromise])\n .then(() => {\n this.svgContent = pdsIconContent.get(url);\n // Force re-render if content was loaded after initial render\n if (!this.svgContent) {\n console.warn(`Icon content not found after successful load: ${url}`);\n }\n })\n .catch((error) => {\n console.error(`Failed to load icon: ${url}`, error);\n // Set empty content to prevent infinite loading state\n pdsIconContent.set(url, '');\n this.svgContent = '';\n });\n }\n this.didLoadIcon = true;\n }\n }\n\n this.iconName = getName(this.name, this.icon);\n\n if (this.iconName) {\n this.ariaLabel = this.iconName.replace(/\\-/g, ' ');\n }\n }\n\n render() {\n const { ariaLabel, flipRtl, iconName,inheritedAttributes } = this;\n const shouldIconAutoFlip = iconName\n ? shouldRtlFlipIcon(iconName, this.el) && flipRtl !== false\n : false;\n const shouldFlip = flipRtl || shouldIconAutoFlip;\n\n // Debug information when enabled\n this.debugIconState();\n\n return (\n\n <Host\n aria-label={ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null }\n alt=\"\"\n role=\"img\"\n class={{\n ...createColorClasses(this.color),\n 'flip-rtl': shouldFlip,\n 'icon-rtl': shouldFlip && isRTL(this.el)\n }}\n {...inheritedAttributes}\n >\n {Build.isBrowser && this.svgContent ? (\n <div class=\"icon-inner\" innerHTML={this.svgContent}></div>\n ) : (\n <div class=\"icon-inner\"></div>\n )}\n </Host>\n )\n }\n\n /*****\n * Private Methods\n ****/\n\n private debugIconState() {\n if (typeof window !== 'undefined' && (window as Window & { __PDS_ICON_DEBUG__?: boolean }).__PDS_ICON_DEBUG__) {\n console.log('PDS Icon Debug:', {\n name: this.name,\n src: this.src,\n icon: this.icon,\n isVisible: this.isVisible,\n didLoadIcon: this.didLoadIcon,\n svgContent: this.svgContent ? 'loaded' : 'empty',\n url: getUrl(this),\n hasIntersectionObserver: !!this.io,\n element: this.el\n });\n }\n }\n\n private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {\n if (Build.isBrowser && typeof window !== 'undefined' && (window).IntersectionObserver) {\n try {\n const io = (this.io = new (window).IntersectionObserver(\n (data: IntersectionObserverEntry[]) => {\n if (data[0].isIntersecting) {\n io.disconnect();\n this.io = undefined;\n cb();\n }\n },\n { rootMargin },\n ));\n\n io.observe(el);\n\n // Add a safety timeout for IntersectionObserver\n setTimeout(() => {\n if (this.io) {\n console.warn('IntersectionObserver did not trigger within 5 seconds, forcing callback');\n this.io.disconnect();\n this.io = undefined;\n cb();\n }\n }, 5000);\n } catch (error) {\n console.error('IntersectionObserver initialization failed:', error);\n // Fall back to immediate execution\n cb();\n }\n } else {\n // browser doesn't support IntersectionObserver\n // so just fallback to always show it\n cb();\n }\n }\n\n private hasAriaHidden = () => {\n const { el } = this;\n\n return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';\n }\n}\n\nconst createColorClasses = (color: string | undefined) => {\n return color\n ? {\n 'pds-color': true,\n [`pds-color-${color}`]: true,\n }\n : null;\n };\n"],"names":[],"mappings":";;;AAEO,MAAM,eAAe,GAAG,CAAC,UAAkB,KAAI;IACpD,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AACzC,IAAA,GAAG,CAAC,SAAS,GAAG,UAAU;;AAG1B,IAAA,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;AACnD,QAAA,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;YACtD,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;;;;AAKtC,IAAA,MAAM,MAAM,GAAG,GAAG,CAAC,iBAAiB;IACpC,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;QACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE;AACnD,QAAA,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,QAAQ,GAAG,aAAa,EAAE,IAAI,EAAE,CAAC;;;;AAK/D,QAAA,IAAI,OAAO,CAAC,MAAqB,CAAC,EAAE;YAClC,OAAO,GAAG,CAAC,SAAS;;;AAGxB,IAAA,OAAO,EAAE;AACX,CAAC;AAEM,MAAM,OAAO,GAAG,CAAC,GAAgB,KAAI;AAC1C,IAAA,IAAI,GAAG,CAAC,QAAQ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wBAAA,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE;AACpB,wBAAA,IAAI,CAAC,EAAE,GAAG,SAAS;AACnB,wBAAA,EAAE,EAAE;;iBAEP,EAAE,IAAI,CAAC;;YACR,OAAO,KAAK,EAAE;AACd,gBAAA,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC;;AAEnE,gBAAA,EAAE,EAAE;;;aAED;;;AAGL,YAAA,EAAE,EAAE;;;;;;;;;;;;;AAWV,MAAM,kBAAkB,GAAG,CAAC,KAAyB,KAAI;AACvD,IAAA,OAAO;AACN,UAAE;AACE,YAAA,WAAW,EAAE,IAAI;AACjB,YAAA,CAAC,CAAa,UAAA,EAAA,KAAK,CAAE,CAAA,GAAG,IAAI;AAC7B;UACD,IAAI;AACR,CAAC;;;;;"}
|
|
1
|
+
{"version":3,"file":"pds-icon.entry.js","sources":["src/components/pds-icon/validate.ts","src/components/pds-icon/request.ts","src/components/pds-icon/pds-icon.scss?tag=pds-icon&encapsulation=shadow","src/components/pds-icon/pds-icon.tsx"],"sourcesContent":["import { isStr } from './utils';\n\nexport const validateContent = (svgContent: string) => {\n const div = document.createElement('div');\n div.innerHTML = svgContent;\n\n // setup this way to ensure it works on our buddy IE\n for (let i = div.childNodes.length - 1; i >= 0; i--) {\n if (div.childNodes[i].nodeName.toLowerCase() !== 'svg') {\n div.removeChild(div.childNodes[i]);\n }\n }\n\n // must only have 1 root element\n const svgElm = div.firstElementChild;\n if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {\n const svgClass = svgElm.getAttribute('class') || '';\n svgElm.setAttribute('class', (svgClass + ' s-pds-icon').trim());\n\n // root element must be an svg\n // lets double check we've got valid elements\n // do not allow scripts\n if (isValid(svgElm as HTMLElement)) {\n return div.innerHTML;\n }\n }\n return '';\n};\n\nexport const isValid = (elm: HTMLElement) => {\n if (elm.nodeType === 1) {\n if (elm.nodeName.toLowerCase() === 'script') {\n return false;\n }\n\n for (let i = 0; i < elm.attributes.length; i++) {\n const name = elm.attributes[i].name;\n if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {\n return false;\n }\n }\n\n for (let i = 0; i < elm.childNodes.length; i++) {\n if (!isValid(elm.childNodes[i] as HTMLElement)) {\n return false;\n }\n }\n }\n return true;\n};\n\nexport const isSvgDataUrl = (url: string) => url.startsWith('data:image/svg+xml');\nexport const isEncodedDataUrl = (url: string) => url.indexOf(';utf8,') !== -1;\n","import { isEncodedDataUrl, isSvgDataUrl, validateContent } from './validate';\n\nexport const pdsIconContent = new Map<string, string>();\nconst requests = new Map<string, Promise<any>>(); // eslint-disable-line @typescript-eslint/no-explicit-any\n\nlet parser: DOMParser;\n\nexport const getSvgContent = (url: string, sanitize = false) => {\n let req = requests.get(url);\n\n if(!req) {\n if (typeof fetch != 'undefined' && typeof document !== 'undefined') {\n if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {\n if (!parser) {\n parser = new DOMParser();\n }\n\n const doc = parser.parseFromString(url, 'text/html');\n const svg = doc.querySelector('svg');\n\n if (svg) {\n pdsIconContent.set(url, svg.outerHTML);\n }\n\n return Promise.resolve();\n } else {\n // we don't have a request\n req = fetch(url).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n pdsIconContent.set(url, svgContent || '');\n });\n }\n pdsIconContent.set(url, '');\n });\n\n requests.set(url, req);\n }\n } else {\n pdsIconContent.set(url, '');\n return Promise.resolve();\n }\n }\n\n return req;\n}\n",":host {\n --dimension-icon-height: 16px;\n --dimension-icon-width: 16px;\n --color-icon-fill: currentColor;\n\n contain: strict;\n display: inline-block;\n fill: var(--color-icon-fill);\n flex-shrink: 0;\n height: var(--dimension-icon-height);\n width: var(--dimension-icon-width);\n\n .pdsicon {\n fill: var(--color-icon-fill);\n }\n}\n\n.pds-icon-fill-none {\n fill: none;\n}\n\n.icon-inner,\n.pds-icon,\nsvg {\n display: block;\n height: 100%;\n width: 100%;\n}\n\n/* :host-context is supported in chromium; :dir is supported in safari & firefox */\n:host(.flip-rtl):host-context([dir='rtl']) .icon-inner {\n transform: scaleX(-1);\n}\n\n:host(.flip-rtl:dir(rtl)) .icon-inner {\n transform: scaleX(-1);\n}\n\n/**\n * This is needed for WebKit otherwise the fallback\n * will always cause the icon to be flipped if the document\n * loads in RTL.\n */\n:host(.flip-rtl:dir(ltr)) .icon-inner {\n transform: scaleX(1);\n}\n\n","import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';\nimport { getSvgContent, pdsIconContent } from './request';\nimport { getName, getUrl, inheritAttributes, isRTL, shouldRtlFlipIcon } from './utils';\n\n@Component({\n tag: 'pds-icon',\n assetsDirs: ['svg'],\n styleUrl: 'pds-icon.scss',\n shadow: true,\n})\nexport class PdsIcon {\n private didLoadIcon = false;\n private iconName: string | null = null;\n private io?: IntersectionObserver;\n private inheritedAttributes: { [k: string]: any } = {}; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n @Element() el!: HTMLPdsIconElement;\n\n @State() private ariaLabel?: string;\n @State() private isVisible = false;\n @State() private svgContent?: string;\n\n /**\n *\n * The color of the icon\n *\n */\n @Prop() color?: string;\n\n /**\n * Determines if the icon should be flipped when the `dir` is right-to-left (`\"rtl\"`).\n * This is automatically enabled for icons that are in the `ICONS_TO_FLIP` list and\n * when the `dir` is `\"rtl\"`. If `flipRtl` is set to `false`, the icon will not be flipped\n * even if the `dir` is `\"rtl\"`.\n */\n @Prop() flipRtl?: boolean;\n\n /**\n * This is a combination of both `name` and `src`. If a `src` URL is detected,\n * it will set the `src` property. Otherwise it assumes it's a built-in named\n * SVG and sets the `name` property.\n */\n @Prop() icon?: any;\n\n /**\n * The name of the icon to use from\n * the built-in set.\n */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * The size of the icon. This can be\n * 'small', 'regular', 'medium', 'large', or a\n * custom value (40px, 1rem, etc)\n *\n */\n @Prop({ reflect: true }) size?:\n | 'small' // 12px\n | 'regular' // 16px\n | 'medium' // 20px\n | 'large' // 24px\n | 'auto'\n | string = 'regular'\n\n /**\n *\n * Specifies the exact `src` of an SVG file to use.\n */\n @Prop() src?: string;\n\n private iconSize() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sizes: { [key: string]: any } = {\n small: '12px',\n regular: '16px',\n medium: '20px',\n large: '24px',\n }\n\n if (sizes[this.size]) {\n return sizes[this.size];\n } else {\n return this.size;\n }\n }\n\n componentDidLoad() {\n this.setCSSVariables();\n\n if (!this.didLoadIcon) {\n this.loadIcon();\n }\n }\n\n componentWillLoad() {\n this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);\n this.setCSSVariables();\n }\n\n setCSSVariables() {\n this.el.style.setProperty(`--dimension-icon-height`, this.iconSize());\n this.el.style.setProperty(`--dimension-icon-width`, this.iconSize());\n this.el.style.setProperty(`--color-icon-fill`, typeof this.color !== 'undefined' ? this.color : 'currentColor');\n }\n\n connectedCallback() {\n this.waitUntilVisible(this.el, '50px', () => {\n this.isVisible = true;\n this.loadIcon();\n })\n }\n\n disconnectedCallback() {\n if (this.io) {\n this.io.disconnect();\n this.io = undefined;\n }\n }\n\n @Watch('size')\n @Watch('color')\n updateStyles() {\n this.setCSSVariables();\n }\n\n @Watch('name')\n @Watch('src')\n @Watch('icon')\n loadIcon() {\n if (Build.isBrowser && this.isVisible) {\n const url = getUrl(this);\n if (url) {\n if (pdsIconContent.has(url)) {\n this.svgContent = pdsIconContent.get(url);\n } else {\n getSvgContent(url).then(() => (this.svgContent = pdsIconContent.get(url)));\n }\n this.didLoadIcon = true;\n }\n }\n\n this.iconName = getName(this.name, this.icon);\n\n if (this.iconName) {\n this.ariaLabel = this.iconName.replace(/\\-/g, ' ');\n }\n }\n\n render() {\n const { ariaLabel, flipRtl, iconName,inheritedAttributes } = this;\n const shouldIconAutoFlip = iconName\n ? shouldRtlFlipIcon(iconName, this.el) && flipRtl !== false\n : false;\n const shouldFlip = flipRtl || shouldIconAutoFlip;\n\n return (\n\n <Host\n aria-label={ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null }\n alt=\"\"\n role=\"img\"\n class={{\n ...createColorClasses(this.color),\n 'flip-rtl': shouldFlip,\n 'icon-rtl': shouldFlip && isRTL(this.el)\n }}\n {...inheritedAttributes}\n >\n {Build.isBrowser && this.svgContent ? (\n <div class=\"icon-inner\" innerHTML={this.svgContent}></div>\n ) : (\n <div class=\"icon-inner\"></div>\n )}\n </Host>\n )\n }\n\n /*****\n * Private Methods\n ****/\n\n private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {\n if (Build.isBrowser && typeof window !== 'undefined' && (window).IntersectionObserver) {\n const io = (this.io = new (window).IntersectionObserver(\n (data: IntersectionObserverEntry[]) => {\n if (data[0].isIntersecting) {\n io.disconnect();\n this.io = undefined;\n cb();\n }\n },\n { rootMargin },\n ));\n\n io.observe(el);\n } else {\n // browser doesn't support IntersectionObserver\n // so just fallback to always show it\n cb();\n }\n }\n\n private hasAriaHidden = () => {\n const { el } = this;\n\n return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';\n }\n}\n\nconst createColorClasses = (color: string | undefined) => {\n return color\n ? {\n 'pds-color': true,\n [`pds-color-${color}`]: true,\n }\n : null;\n };\n"],"names":[],"mappings":";;;AAEO,MAAM,eAAe,GAAG,CAAC,UAAkB,KAAI;IACpD,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AACzC,IAAA,GAAG,CAAC,SAAS,GAAG,UAAU;;AAG1B,IAAA,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;AACnD,QAAA,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE;YACtD,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CA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U,EAAE,UAAU,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAA,CAAA,EAAA,EAEtC,mBAAmB,CAEtB,EAAmB,IAAI,CAAC,UAAU,IACjC,CAAK,CAAA,KAAA,EAAA,EAAA,KAAK,EAAC,YAAY,EAAC,SAAS,EAAE,IAAI,CAAC,UAAU,EAAA,CAAQ,KAE1D,CAAA,CAAA,KAAA,EAAA,EAAK,KAAK,EAAC,YAAY,GAAO,CAC/B,CACI;;AAIX;;AAEM;AAEE,IAAA,gBAAgB,CAAC,EAAe,EAAE,UAAkB,EAAE,EAAc,EAAA;AAC1E,QAAA,IAAuB,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE;AACrF,YAAA,MAAM,EAAE,IAAI,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,oBAAoB,CACrD,CAAC,IAAiC,KAAI;AACpC,gBAAA,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE;oBAC1B,EAAE,CAAC,UAAU,EAAE;AACf,oBAAA,IAAI,CAAC,EAAE,GAAG,SAAS;AACnB,oBAAA,EAAE,EAAE;;AAER,aAAC,EACD,EAAE,UAAU,EAAE,CACf,CAAC;AAEF,YAAA,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;;aACT;;;AAGL,YAAA,EAAE,EAAE;;;;;;;;;;;;;AAWV,MAAM,kBAAkB,GAAG,CAAC,KAAyB,KAAI;AACvD,IAAA,OAAO;AACN,UAAE;AACE,YAAA,WAAW,EAAE,IAAI;AACjB,YAAA,CAAC,CAAa,UAAA,EAAA,KAAK,CAAE,CAAA,GAAG,IAAI;AAC7B;UACD,IAAI;AACR,CAAC;;;;;"}
|
package/dist/esm/pds-icons.js
CHANGED
|
@@ -17,7 +17,7 @@ var patchBrowser = () => {
|
|
|
17
17
|
|
|
18
18
|
patchBrowser().then(async (options) => {
|
|
19
19
|
await globalScripts();
|
|
20
|
-
return bootstrapLazy([["pds-icon",[[1,"pds-icon",{"color":[1],"flipRtl":[4,"flip-rtl"],"icon":[
|
|
20
|
+
return bootstrapLazy([["pds-icon",[[1,"pds-icon",{"color":[1],"flipRtl":[4,"flip-rtl"],"icon":[8],"name":[513],"size":[513],"src":[1],"ariaLabel":[32],"isVisible":[32],"svgContent":[32]},null,{"size":["updateStyles"],"color":["updateStyles"],"name":["loadIcon"],"src":["loadIcon"],"icon":["loadIcon"]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
//# sourceMappingURL=pds-icons.js.map
|
|
23
23
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as i,h as t,H as s,g as e}from"./p-BtVkVfWm.js";import{i as n,a as o,g as r,b as l,s as c,c as a}from"./p-6DkR999u.js";const h=i=>{const t=document.createElement("div");t.innerHTML=i;for(let i=t.childNodes.length-1;i>=0;i--){if(t.childNodes[i].nodeName.toLowerCase()!=="svg"){t.removeChild(t.childNodes[i])}}const s=t.firstElementChild;if(s&&s.nodeName.toLowerCase()==="svg"){const i=s.getAttribute("class")||"";s.setAttribute("class",(i+" s-pds-icon").trim());if(d(s)){return t.innerHTML}}return""};const d=i=>{if(i.nodeType===1){if(i.nodeName.toLowerCase()==="script"){return false}for(let t=0;t<i.attributes.length;t++){const s=i.attributes[t].name;if(n(s)&&s.toLowerCase().indexOf("on")===0){return false}}for(let t=0;t<i.childNodes.length;t++){if(!d(i.childNodes[t])){return false}}}return true};const f=i=>i.startsWith("data:image/svg+xml");const u=i=>i.indexOf(";utf8,")!==-1;const p=new Map;const m=new Map;let g;const b=(i,t=false)=>{let s=m.get(i);if(!s){if(typeof fetch!="undefined"&&typeof document!=="undefined"){if(f(i)&&u(i)){if(!g){g=new DOMParser}const t=g.parseFromString(i,"text/html");const s=t.querySelector("svg");if(s){p.set(i,s.outerHTML)}return Promise.resolve()}else{s=fetch(i).then((s=>{if(s.ok){return s.text().then((s=>{if(s&&t!==false){s=h(s)}p.set(i,s||"")}))}p.set(i,"")}));m.set(i,s)}}else{p.set(i,"");return Promise.resolve()}}return s};const w=":host{--dimension-icon-height:16px;--dimension-icon-width:16px;--color-icon-fill:currentColor;contain:strict;display:inline-block;fill:var(--color-icon-fill);flex-shrink:0;height:var(--dimension-icon-height);width:var(--dimension-icon-width)}:host .pdsicon{fill:var(--color-icon-fill)}.pds-icon-fill-none{fill:none}.icon-inner,.pds-icon,svg{display:block;height:100%;width:100%}:host(.flip-rtl):host-context([dir=rtl]) .icon-inner{transform:scaleX(-1)}:host(.flip-rtl:dir(rtl)) .icon-inner{transform:scaleX(-1)}:host(.flip-rtl:dir(ltr)) .icon-inner{transform:scaleX(1)}";const v=class{constructor(t){i(this,t);this.didLoadIcon=false;this.iconName=null;this.inheritedAttributes={};this.isVisible=false;this.size="regular";this.hasAriaHidden=()=>{const{el:i}=this;return i.hasAttribute("aria-hidden")&&i.getAttribute("aria-hidden")==="true"}}iconSize(){const i={small:"12px",regular:"16px",medium:"20px",large:"24px"};if(i[this.size]){return i[this.size]}else{return this.size}}componentDidLoad(){this.setCSSVariables();if(!this.didLoadIcon){this.loadIcon()}}componentWillLoad(){this.inheritedAttributes=o(this.el,["aria-label"]);this.setCSSVariables()}setCSSVariables(){this.el.style.setProperty(`--dimension-icon-height`,this.iconSize());this.el.style.setProperty(`--dimension-icon-width`,this.iconSize());this.el.style.setProperty(`--color-icon-fill`,typeof this.color!=="undefined"?this.color:"currentColor")}connectedCallback(){this.waitUntilVisible(this.el,"50px",(()=>{this.isVisible=true;this.loadIcon()}))}disconnectedCallback(){if(this.io){this.io.disconnect();this.io=undefined}}updateStyles(){this.setCSSVariables()}loadIcon(){if(this.isVisible){const i=r(this);if(i){if(p.has(i)){this.svgContent=p.get(i)}else{b(i).then((()=>this.svgContent=p.get(i)))}this.didLoadIcon=true}}this.iconName=l(this.name,this.icon);if(this.iconName){this.ariaLabel=this.iconName.replace(/\-/g," ")}}render(){const{ariaLabel:i,flipRtl:e,iconName:n,inheritedAttributes:o}=this;const r=n?c(n,this.el)&&e!==false:false;const l=e||r;return t(s,Object.assign({key:"bc8e46daa75df27a8039e0e767bdb43164ad7d4c","aria-label":i!==undefined&&!this.hasAriaHidden()?i:null,alt:"",role:"img",class:Object.assign(Object.assign({},x(this.color)),{"flip-rtl":l,"icon-rtl":l&&a(this.el)})},o),this.svgContent?t("div",{class:"icon-inner",innerHTML:this.svgContent}):t("div",{class:"icon-inner"}))}waitUntilVisible(i,t,s){if(typeof window!=="undefined"&&window.IntersectionObserver){const e=this.io=new window.IntersectionObserver((i=>{if(i[0].isIntersecting){e.disconnect();this.io=undefined;s()}}),{rootMargin:t});e.observe(i)}else{s()}}static get assetsDirs(){return["svg"]}get el(){return e(this)}static get watchers(){return{size:["updateStyles"],color:["updateStyles"],name:["loadIcon"],src:["loadIcon"],icon:["loadIcon"]}}};const x=i=>i?{"pds-color":true,[`pds-color-${i}`]:true}:null;v.style=w;export{v as pds_icon};
|
|
2
|
+
//# sourceMappingURL=p-5a3a5e3c.entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["validateContent","svgContent","div","document","createElement","innerHTML","i","childNodes","length","nodeName","toLowerCase","removeChild","svgElm","firstElementChild","svgClass","getAttribute","setAttribute","trim","isValid","elm","nodeType","attributes","name","isStr","indexOf","isSvgDataUrl","url","startsWith","isEncodedDataUrl","pdsIconContent","Map","requests","parser","getSvgContent","sanitize","req","get","fetch","DOMParser","doc","parseFromString","svg","querySelector","set","outerHTML","Promise","resolve","then","rsp","ok","text","pdsIconCss","PdsIcon","constructor","hostRef","this","didLoadIcon","iconName","inheritedAttributes","isVisible","size","hasAriaHidden","el","hasAttribute","iconSize","sizes","small","regular","medium","large","componentDidLoad","setCSSVariables","loadIcon","componentWillLoad","inheritAttributes","style","setProperty","color","connectedCallback","waitUntilVisible","disconnectedCallback","io","disconnect","undefined","updateStyles","getUrl","has","getName","icon","ariaLabel","replace","render","flipRtl","shouldIconAutoFlip","shouldRtlFlipIcon","shouldFlip","h","Host","Object","assign","key","alt","role","class","createColorClasses","isRTL","rootMargin","cb","window","IntersectionObserver","data","isIntersecting","observe"],"sources":["src/components/pds-icon/validate.ts","src/components/pds-icon/request.ts","src/components/pds-icon/pds-icon.scss?tag=pds-icon&encapsulation=shadow","src/components/pds-icon/pds-icon.tsx"],"sourcesContent":["import { isStr } from './utils';\n\nexport const validateContent = (svgContent: string) => {\n const div = document.createElement('div');\n div.innerHTML = svgContent;\n\n // setup this way to ensure it works on our buddy IE\n for (let i = div.childNodes.length - 1; i >= 0; i--) {\n if (div.childNodes[i].nodeName.toLowerCase() !== 'svg') {\n div.removeChild(div.childNodes[i]);\n }\n }\n\n // must only have 1 root element\n const svgElm = div.firstElementChild;\n if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {\n const svgClass = svgElm.getAttribute('class') || '';\n svgElm.setAttribute('class', (svgClass + ' s-pds-icon').trim());\n\n // root element must be an svg\n // lets double check we've got valid elements\n // do not allow scripts\n if (isValid(svgElm as HTMLElement)) {\n return div.innerHTML;\n }\n }\n return '';\n};\n\nexport const isValid = (elm: HTMLElement) => {\n if (elm.nodeType === 1) {\n if (elm.nodeName.toLowerCase() === 'script') {\n return false;\n }\n\n for (let i = 0; i < elm.attributes.length; i++) {\n const name = elm.attributes[i].name;\n if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {\n return false;\n }\n }\n\n for (let i = 0; i < elm.childNodes.length; i++) {\n if (!isValid(elm.childNodes[i] as HTMLElement)) {\n return false;\n }\n }\n }\n return true;\n};\n\nexport const isSvgDataUrl = (url: string) => url.startsWith('data:image/svg+xml');\nexport const isEncodedDataUrl = (url: string) => url.indexOf(';utf8,') !== -1;\n","import { isEncodedDataUrl, isSvgDataUrl, validateContent } from './validate';\n\nexport const pdsIconContent = new Map<string, string>();\nconst requests = new Map<string, Promise<any>>(); // eslint-disable-line @typescript-eslint/no-explicit-any\n\nlet parser: DOMParser;\n\nexport const getSvgContent = (url: string, sanitize = false) => {\n let req = requests.get(url);\n\n if(!req) {\n if (typeof fetch != 'undefined' && typeof document !== 'undefined') {\n if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {\n if (!parser) {\n parser = new DOMParser();\n }\n\n const doc = parser.parseFromString(url, 'text/html');\n const svg = doc.querySelector('svg');\n\n if (svg) {\n pdsIconContent.set(url, svg.outerHTML);\n }\n\n return Promise.resolve();\n } else {\n // we don't have a request\n req = fetch(url).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n pdsIconContent.set(url, svgContent || '');\n });\n }\n pdsIconContent.set(url, '');\n });\n\n requests.set(url, req);\n }\n } else {\n pdsIconContent.set(url, '');\n return Promise.resolve();\n }\n }\n\n return req;\n}\n",":host {\n --dimension-icon-height: 16px;\n --dimension-icon-width: 16px;\n --color-icon-fill: currentColor;\n\n contain: strict;\n display: inline-block;\n fill: var(--color-icon-fill);\n flex-shrink: 0;\n height: var(--dimension-icon-height);\n width: var(--dimension-icon-width);\n\n .pdsicon {\n fill: var(--color-icon-fill);\n }\n}\n\n.pds-icon-fill-none {\n fill: none;\n}\n\n.icon-inner,\n.pds-icon,\nsvg {\n display: block;\n height: 100%;\n width: 100%;\n}\n\n/* :host-context is supported in chromium; :dir is supported in safari & firefox */\n:host(.flip-rtl):host-context([dir='rtl']) .icon-inner {\n transform: scaleX(-1);\n}\n\n:host(.flip-rtl:dir(rtl)) .icon-inner {\n transform: scaleX(-1);\n}\n\n/**\n * This is needed for WebKit otherwise the fallback\n * will always cause the icon to be flipped if the document\n * loads in RTL.\n */\n:host(.flip-rtl:dir(ltr)) .icon-inner {\n transform: scaleX(1);\n}\n\n","import { Build, Component, Element, Host, Prop, State, Watch, h } from '@stencil/core';\nimport { getSvgContent, pdsIconContent } from './request';\nimport { getName, getUrl, inheritAttributes, isRTL, shouldRtlFlipIcon } from './utils';\n\n@Component({\n tag: 'pds-icon',\n assetsDirs: ['svg'],\n styleUrl: 'pds-icon.scss',\n shadow: true,\n})\nexport class PdsIcon {\n private didLoadIcon = false;\n private iconName: string | null = null;\n private io?: IntersectionObserver;\n private inheritedAttributes: { [k: string]: any } = {}; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n @Element() el!: HTMLPdsIconElement;\n\n @State() private ariaLabel?: string;\n @State() private isVisible = false;\n @State() private svgContent?: string;\n\n /**\n *\n * The color of the icon\n *\n */\n @Prop() color?: string;\n\n /**\n * Determines if the icon should be flipped when the `dir` is right-to-left (`\"rtl\"`).\n * This is automatically enabled for icons that are in the `ICONS_TO_FLIP` list and\n * when the `dir` is `\"rtl\"`. If `flipRtl` is set to `false`, the icon will not be flipped\n * even if the `dir` is `\"rtl\"`.\n */\n @Prop() flipRtl?: boolean;\n\n /**\n * This is a combination of both `name` and `src`. If a `src` URL is detected,\n * it will set the `src` property. Otherwise it assumes it's a built-in named\n * SVG and sets the `name` property.\n */\n @Prop() icon?: any;\n\n /**\n * The name of the icon to use from\n * the built-in set.\n */\n @Prop({ reflect: true }) name?: string;\n\n /**\n * The size of the icon. This can be\n * 'small', 'regular', 'medium', 'large', or a\n * custom value (40px, 1rem, etc)\n *\n */\n @Prop({ reflect: true }) size?:\n | 'small' // 12px\n | 'regular' // 16px\n | 'medium' // 20px\n | 'large' // 24px\n | 'auto'\n | string = 'regular'\n\n /**\n *\n * Specifies the exact `src` of an SVG file to use.\n */\n @Prop() src?: string;\n\n private iconSize() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sizes: { [key: string]: any } = {\n small: '12px',\n regular: '16px',\n medium: '20px',\n large: '24px',\n }\n\n if (sizes[this.size]) {\n return sizes[this.size];\n } else {\n return this.size;\n }\n }\n\n componentDidLoad() {\n this.setCSSVariables();\n\n if (!this.didLoadIcon) {\n this.loadIcon();\n }\n }\n\n componentWillLoad() {\n this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);\n this.setCSSVariables();\n }\n\n setCSSVariables() {\n this.el.style.setProperty(`--dimension-icon-height`, this.iconSize());\n this.el.style.setProperty(`--dimension-icon-width`, this.iconSize());\n this.el.style.setProperty(`--color-icon-fill`, typeof this.color !== 'undefined' ? this.color : 'currentColor');\n }\n\n connectedCallback() {\n this.waitUntilVisible(this.el, '50px', () => {\n this.isVisible = true;\n this.loadIcon();\n })\n }\n\n disconnectedCallback() {\n if (this.io) {\n this.io.disconnect();\n this.io = undefined;\n }\n }\n\n @Watch('size')\n @Watch('color')\n updateStyles() {\n this.setCSSVariables();\n }\n\n @Watch('name')\n @Watch('src')\n @Watch('icon')\n loadIcon() {\n if (Build.isBrowser && this.isVisible) {\n const url = getUrl(this);\n if (url) {\n if (pdsIconContent.has(url)) {\n this.svgContent = pdsIconContent.get(url);\n } else {\n getSvgContent(url).then(() => (this.svgContent = pdsIconContent.get(url)));\n }\n this.didLoadIcon = true;\n }\n }\n\n this.iconName = getName(this.name, this.icon);\n\n if (this.iconName) {\n this.ariaLabel = this.iconName.replace(/\\-/g, ' ');\n }\n }\n\n render() {\n const { ariaLabel, flipRtl, iconName,inheritedAttributes } = this;\n const shouldIconAutoFlip = iconName\n ? shouldRtlFlipIcon(iconName, this.el) && flipRtl !== false\n : false;\n const shouldFlip = flipRtl || shouldIconAutoFlip;\n\n return (\n\n <Host\n aria-label={ariaLabel !== undefined && !this.hasAriaHidden() ? ariaLabel : null }\n alt=\"\"\n role=\"img\"\n class={{\n ...createColorClasses(this.color),\n 'flip-rtl': shouldFlip,\n 'icon-rtl': shouldFlip && isRTL(this.el)\n }}\n {...inheritedAttributes}\n >\n {Build.isBrowser && this.svgContent ? (\n <div class=\"icon-inner\" innerHTML={this.svgContent}></div>\n ) : (\n <div class=\"icon-inner\"></div>\n )}\n </Host>\n )\n }\n\n /*****\n * Private Methods\n ****/\n\n private waitUntilVisible(el: HTMLElement, rootMargin: string, cb: () => void) {\n if (Build.isBrowser && typeof window !== 'undefined' && (window).IntersectionObserver) {\n const io = (this.io = new (window).IntersectionObserver(\n (data: IntersectionObserverEntry[]) => {\n if (data[0].isIntersecting) {\n io.disconnect();\n this.io = undefined;\n cb();\n }\n },\n { rootMargin },\n ));\n\n io.observe(el);\n } else {\n // browser doesn't support IntersectionObserver\n // so just fallback to always show it\n cb();\n }\n }\n\n private hasAriaHidden = () => {\n const { el } = this;\n\n return el.hasAttribute('aria-hidden') && el.getAttribute('aria-hidden') === 'true';\n }\n}\n\nconst createColorClasses = (color: string | undefined) => {\n return color\n ? {\n 'pds-color': true,\n [`pds-color-${color}`]: true,\n }\n : null;\n };\n"],"mappings":"gIAEO,MAAMA,EAAmBC,IAC9B,MAAMC,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAYJ,EAGhB,IAAK,IAAIK,EAAIJ,EAAIK,WAAWC,OAAS,EAAGF,GAAK,EAAGA,IAAK,CACnD,GAAIJ,EAAIK,WAAWD,GAAGG,SAASC,gBAAkB,MAAO,CACtDR,EAAIS,YAAYT,EAAIK,WAAWD,G,EAKnC,MAAMM,EAASV,EAAIW,kBACnB,GAAID,GAAUA,EAAOH,SAASC,gBAAkB,MAAO,CACrD,MAAMI,EAAWF,EAAOG,aAAa,UAAY,GACjDH,EAAOI,aAAa,SAAUF,EAAW,eAAeG,QAKxD,GAAIC,EAAQN,GAAwB,CAClC,OAAOV,EAAIG,S,EAGf,MAAO,EAAE,EAGJ,MAAMa,EAAWC,IACtB,GAAIA,EAAIC,WAAa,EAAG,CACtB,GAAID,EAAIV,SAASC,gBAAkB,SAAU,CAC3C,OAAO,K,CAGT,IAAK,IAAIJ,EAAI,EAAGA,EAAIa,EAAIE,WAAWb,OAAQF,IAAK,CAC9C,MAAMgB,EAAOH,EAAIE,WAAWf,GAAGgB,KAC/B,GAAIC,EAAMD,IAASA,EAAKZ,cAAcc,QAAQ,QAAU,EAAG,CACzD,OAAO,K,EAIX,IAAK,IAAIlB,EAAI,EAAGA,EAAIa,EAAIZ,WAAWC,OAAQF,IAAK,CAC9C,IAAKY,EAAQC,EAAIZ,WAAWD,IAAoB,CAC9C,OAAO,K,GAIb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