@pine-ds/icons 3.1.0 → 3.3.0-rc.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.d.ts +2 -2
- package/components/pds-icon.js +175 -171
- package/components/pds-icon.js.map +1 -1
- package/components/utils.js +65 -45
- package/components/utils.js.map +1 -1
- package/dist/cheatsheet.html +7 -5
- package/dist/cjs/{index-b35d5b0f.js → index-17212f65.js} +81 -21
- package/dist/cjs/index-17212f65.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/pds-icon.cjs.entry.js +152 -150
- package/dist/cjs/pds-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/pds-icons.cjs.js +3 -3
- package/dist/cjs/pds-icons.cjs.js.map +1 -1
- package/dist/cjs/utils-8c57ce6a.js +101 -0
- package/dist/cjs/utils-8c57ce6a.js.map +1 -0
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/pds-icon/pds-icon.js +189 -168
- package/dist/collection/components/pds-icon/pds-icon.js.map +1 -1
- package/dist/collection/components/pds-icon/request.js +21 -21
- package/dist/collection/components/pds-icon/request.js.map +1 -1
- package/dist/collection/components/pds-icon/svg/premium.svg +1 -0
- package/dist/collection/components/pds-icon/svg/theme-store.svg +1 -1
- package/dist/collection/components/pds-icon/test/pds-icon.e2e.js +6 -6
- package/dist/collection/components/pds-icon/test/pds-icon.e2e.js.map +1 -1
- package/dist/collection/components/pds-icon/test/pds-icon.spec.js +69 -31
- package/dist/collection/components/pds-icon/test/pds-icon.spec.js.map +1 -1
- package/dist/collection/components/pds-icon/utils.js +61 -51
- package/dist/collection/components/pds-icon/utils.js.map +1 -1
- package/dist/collection/components/pds-icon/validate.js +35 -35
- package/dist/collection/components/pds-icon/validate.js.map +1 -1
- package/dist/docs.json +23 -2
- package/dist/esm/{index-8effeb27.js → index-d1a605fc.js} +81 -21
- package/dist/esm/index-d1a605fc.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/pds-icon.entry.js +152 -150
- package/dist/esm/pds-icon.entry.js.map +1 -1
- package/dist/esm/pds-icons.js +4 -4
- package/dist/esm/pds-icons.js.map +1 -1
- package/dist/esm/utils-15462a67.js +95 -0
- package/dist/esm/utils-15462a67.js.map +1 -0
- package/dist/pds-icons/index.esm.js +1 -1
- package/dist/pds-icons/p-19d7058a.js +3 -0
- package/dist/pds-icons/p-19d7058a.js.map +1 -0
- package/dist/pds-icons/p-229b8f4e.entry.js +2 -0
- package/dist/pds-icons/p-229b8f4e.entry.js.map +1 -0
- package/dist/pds-icons/p-f0b1dbd6.js +2 -0
- package/dist/pds-icons/p-f0b1dbd6.js.map +1 -0
- package/dist/pds-icons/pds-icons.esm.js +1 -1
- package/dist/pds-icons/pds-icons.esm.js.map +1 -1
- package/dist/pds-icons.json +8 -1
- package/dist/pds-icons.symbols.svg +3 -2
- package/dist/svg/premium.svg +1 -0
- package/dist/svg/theme-store.svg +1 -1
- package/dist/types/components/pds-icon/pds-icon.d.ts +41 -35
- package/dist/types/components/pds-icon/utils.d.ts +4 -4
- package/dist/types/components.d.ts +8 -0
- package/dist/types/stencil-public-runtime.d.ts +29 -0
- package/icons/index.d.ts +2 -1
- package/icons/index.js +3 -2
- package/icons/index.mjs +3 -2
- package/icons/package.json +1 -1
- package/package.json +6 -6
- package/dist/cjs/index-b35d5b0f.js.map +0 -1
- package/dist/cjs/utils-395a38b7.js +0 -81
- package/dist/cjs/utils-395a38b7.js.map +0 -1
- package/dist/esm/index-8effeb27.js.map +0 -1
- package/dist/esm/utils-a0ad61d0.js +0 -75
- package/dist/esm/utils-a0ad61d0.js.map +0 -1
- package/dist/pds-icons/p-91678731.entry.js +0 -2
- package/dist/pds-icons/p-91678731.entry.js.map +0 -1
- package/dist/pds-icons/p-a3383818.js +0 -3
- package/dist/pds-icons/p-a3383818.js.map +0 -1
- package/dist/pds-icons/p-dc5765cb.js +0 -2
- package/dist/pds-icons/p-dc5765cb.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds-icon.spec.js","sourceRoot":"","sources":["../../../../src/components/pds-icon/test/pds-icon.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"pds-icon.spec.js","sourceRoot":"","sources":["../../../../src/components/pds-icon/test/pds-icon.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC;YACjC,UAAU,EAAE,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,uBAAuB;SAC9B,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;KAMxB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QACpD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC;YACjC,UAAU,EAAE,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,oCAAoC;SAC3C,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;KAMxB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;QAClC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,CAAC;YACjC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,CAAC;QAEvB,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;KAMxB,CAAC,CAAC;QAEH,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;SACrB;QACD,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAE5B,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC;;;;;;KAMxB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AAGL,CAAC,CAAC,CAAC","sourcesContent":["import { newSpecPage } from '@stencil/core/testing';\nimport { PdsIcon } from '../pds-icon';\n\ndescribe('pds-icon', () => {\n it('renders', async () => {\n const { root } = await newSpecPage({\n components: [PdsIcon],\n html: '<pds-icon></pds-icon>',\n });\n expect(root).toEqualHtml(`\n <pds-icon role=\"img\" size=\"regular\" style=\"height: 16px; width: 16px;\">\n <mock:shadow-root>\n <div class=\"icon-inner\"></div>\n </mock:shadow-root>\n </pds-icon>\n `);\n });\n\n it('renders the correct size when passed', async () => {\n const { root } = await newSpecPage({\n components: [PdsIcon],\n html: '<pds-icon size=\"small\"></pds-icon>',\n });\n expect(root).toEqualHtml(`\n <pds-icon role=\"img\" size=\"small\" style=\"height: 12px; width: 12px;\">\n <mock:shadow-root>\n <div class=\"icon-inner\"></div>\n </mock:shadow-root>\n </pds-icon>\n `);\n });\n\n it('allows custom size', async () => {\n const { root } = await newSpecPage({\n components: [PdsIcon],\n html: '<pds-icon size=\"32px\"></pds-icon>',\n });\n expect(root).toEqualHtml(`\n <pds-icon role=\"img\" size=\"32px\" style=\"height: 32px; width: 32px;\">\n <mock:shadow-root>\n <div class=\"icon-inner\"></div>\n </mock:shadow-root>\n </pds-icon>\n `);\n });\n\n it('renders icon when found', async () => {\n const { root } = await newSpecPage({\n components: [PdsIcon],\n html: '<pds-icon name=\"archive\"></pds-icon>',\n });\n expect(root).toEqualHtml(`\n <pds-icon aria-label=\"archive\" name=\"archive\" role=\"img\" size=\"regular\" style=\"height: 16px; width: 16px;\">\n <mock:shadow-root>\n <div class=\"icon-inner\"></div>\n </mock:shadow-root>\n </pds-icon>\n `);\n });\n\n it('add correct styles when color specified', async () => {\n const { root } = await newSpecPage({\n components: [PdsIcon],\n html: '<pds-icon name=\"archive\" color=\"red\"></pds-icon>',\n });\n expect(root).toEqualHtml(`\n <pds-icon aria-label=\"archive\" class=\"pds-color pds-color-red\" color=\"red\" name=\"archive\" role=\"img\" size=\"regular\" style=\"height: 16px; width: 16px; color: red\">\n <mock:shadow-root>\n <div class=\"icon-inner\"></div>\n </mock:shadow-root>\n </pds-icon>\n `);\n });\n\n it('renders custom aria-label', async () => {\n const { root } = await newSpecPage({\n components: [PdsIcon],\n html: `<pds-icon name=\"star\" aria-label=\"custom label\"></pds-icon>`,\n });\n\n expect(root).toEqualHtml(`\n <pds-icon name=\"star\" role=\"img\" aria-label=\"custom label\" size=\"regular\" style=\"height: 16px; width: 16px;\">\n <mock:shadow-root>\n <div class=\"icon-inner\"></div>\n </mock:shadow-root>\n </pds-icon>\n `);\n });\n\n it('renders custom label after changing source', async () => {\n const page = await newSpecPage({\n components: [PdsIcon],\n html: `<pds-icon name=\"youtube\" aria-label=\"custom label\"></pds-icon>`,\n });\n\n const icon = page.root;\n\n expect(icon).toEqualHtml(`\n <pds-icon name=\"youtube\" role=\"img\" aria-label=\"custom label\" size=\"regular\" style=\"height: 16px; width: 16px;\">\n <mock:shadow-root>\n <div class=\"icon-inner\"></div>\n </mock:shadow-root>\n </pds-icon>\n `);\n\n if (icon) {\n icon.name = 'trash';\n }\n await page.waitForChanges();\n\n expect(icon).toEqualHtml(`\n <pds-icon name=\"trash\" role=\"img\" aria-label=\"custom label\" size=\"regular\" style=\"height: 16px; width: 16px;\">\n <mock:shadow-root>\n <div class=\"icon-inner\"></div>\n </mock:shadow-root>\n </pds-icon>\n `);\n });\n\n\n});\n"]}
|
|
@@ -1,56 +1,66 @@
|
|
|
1
1
|
import { getAssetPath } from "@stencil/core";
|
|
2
2
|
let CACHED_MAP;
|
|
3
3
|
export const addIcons = (icons) => {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const map = getIconMap();
|
|
5
|
+
Object.keys(icons).forEach(name => map.set(name, icons[name]));
|
|
6
6
|
};
|
|
7
7
|
export const getIconMap = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
if (typeof window === 'undefined') {
|
|
9
|
+
return new Map();
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
if (!CACHED_MAP) {
|
|
13
|
+
const win = window; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
14
|
+
win.PdsIcons = win.PdsIcons || {};
|
|
15
|
+
CACHED_MAP = win.PdsIcons.map = win.PdsIcons.map || new Map();
|
|
16
|
+
}
|
|
17
|
+
return CACHED_MAP;
|
|
16
18
|
}
|
|
17
|
-
return CACHED_MAP;
|
|
18
|
-
}
|
|
19
19
|
};
|
|
20
|
-
export const getName = (iconName) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
export const getName = (iconName, icon) => {
|
|
21
|
+
if (!iconName && icon && !isSrc(icon)) {
|
|
22
|
+
iconName = icon;
|
|
23
|
+
}
|
|
24
|
+
if (isStr(iconName)) {
|
|
25
|
+
iconName = toLower(iconName);
|
|
26
|
+
}
|
|
27
|
+
if (!isStr(iconName) || iconName.trim() === '') {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const invalidChars = iconName.replace(/[a-z]|-|\d/gi, '');
|
|
31
|
+
if (invalidChars != '') {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return iconName;
|
|
32
35
|
};
|
|
33
36
|
const getNamedUrl = (iconName) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const url = getIconMap().get(iconName);
|
|
38
|
+
if (url) {
|
|
39
|
+
return url;
|
|
40
|
+
}
|
|
41
|
+
return getAssetPath(`svg/${iconName}.svg`);
|
|
39
42
|
};
|
|
40
43
|
export const getSrc = (src) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
if (isStr(src)) {
|
|
45
|
+
src = src.trim();
|
|
46
|
+
if (isSrc(src)) {
|
|
47
|
+
return src;
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
|
-
|
|
47
|
-
return null;
|
|
50
|
+
return null;
|
|
48
51
|
};
|
|
49
|
-
export const getUrl = (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
export const getUrl = (pdsIcon) => {
|
|
53
|
+
let url = getName(pdsIcon.name, pdsIcon.icon);
|
|
54
|
+
if (url) {
|
|
55
|
+
return getNamedUrl(url);
|
|
56
|
+
}
|
|
57
|
+
if (pdsIcon.icon) {
|
|
58
|
+
url = getSrc(pdsIcon.icon);
|
|
59
|
+
if (url) {
|
|
60
|
+
return url;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
54
64
|
};
|
|
55
65
|
export const isSrc = (str) => str.length > 0 && /(\/|\.)/.test(str);
|
|
56
66
|
export const isStr = (val) => typeof val === 'string'; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -66,16 +76,16 @@ export const toLower = (val) => val.toLowerCase();
|
|
|
66
76
|
* does not trigger a re-render.
|
|
67
77
|
*/
|
|
68
78
|
export const inheritAttributes = (el, attributes = []) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
const attributeObject = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
80
|
+
attributes.forEach(attr => {
|
|
81
|
+
if (el.hasAttribute(attr)) {
|
|
82
|
+
const value = el.getAttribute(attr);
|
|
83
|
+
if (value !== null) {
|
|
84
|
+
attributeObject[attr] = el.getAttribute(attr);
|
|
85
|
+
}
|
|
86
|
+
el.removeAttribute(attr);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return attributeObject;
|
|
80
90
|
};
|
|
81
91
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/pds-icon/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,IAAI,UAA+B,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAkC,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/pds-icon/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,IAAI,UAA+B,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAkC,EAAE,EAAE;IAC7D,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,GAAwB,EAAE;IAClD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,IAAI,GAAG,EAAE,CAAC;KAClB;SAAO;QACN,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,GAAG,GAAG,MAAa,CAAC,CAAC,yDAAyD;YACpF,GAAG,CAAC,QAAQ,GAAG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,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;aAC/C;YACD,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SAC1B;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC,CAAA","sourcesContent":["import { getAssetPath } from '@stencil/core';\nimport { PdsIcon } from './pds-icon';\n\nlet CACHED_MAP: Map<string, string>;\n\nexport const addIcons = (icons: { [name: string]: string; }) => {\n const map = getIconMap();\n Object.keys(icons).forEach(name => map.set(name, icons[name]));\n}\n\nexport const getIconMap = (): Map<string, string> => {\n if (typeof window === 'undefined') {\n return new Map();\n } else {\n if (!CACHED_MAP) {\n const win = window as any; // eslint-disable-line @typescript-eslint/no-explicit-any\n win.PdsIcons = win.PdsIcons || {};\n CACHED_MAP = win.PdsIcons.map = win.PdsIcons.map || new Map();\n }\n\n return CACHED_MAP;\n }\n}\n\nexport const getName = (\n iconName: string | undefined,\n icon: string | undefined\n ) => {\n\n if(!iconName && icon && !isSrc(icon)) {\n iconName = icon;\n }\n\n if (isStr(iconName)) {\n iconName = toLower(iconName);\n }\n\n if (!isStr(iconName) || iconName.trim() === '') {\n return null;\n }\n\n const invalidChars = iconName.replace(/[a-z]|-|\\d/gi,'');\n if (invalidChars != '') { return null; }\n\n return iconName;\n}\n\nconst getNamedUrl = (iconName: string) => {\n const url = getIconMap().get(iconName);\n if (url) {\n return url;\n }\n\n return getAssetPath(`svg/${iconName}.svg`);\n};\n\nexport const getSrc = (src: string | undefined) => {\n if (isStr(src)) {\n src = src.trim();\n\n if (isSrc(src)) {\n return src;\n }\n }\n\n return null;\n}\n\nexport const getUrl = (pdsIcon: PdsIcon) => {\n let url = getName(pdsIcon.name, pdsIcon.icon);\n if (url) {\n return getNamedUrl(url);\n }\n\n if (pdsIcon.icon) {\n url = getSrc(pdsIcon.icon);\n\n if(url) {\n return url;\n }\n }\n\n return null;\n};\n\n\nexport const isSrc = (str: string) => str.length > 0 && /(\\/|\\.)/.test(str);\nexport const isStr = (val: any): val is string => typeof val === 'string'; // eslint-disable-line @typescript-eslint/no-explicit-any\nexport const toLower = (val: string) => val.toLowerCase();\n\n/**\n * Elements inside of web components sometimes need to inherit global attributes\n * set on the host. For example, the inner input in `ion-input` should inherit\n * the `title` attribute that developers set directly on `ion-input`. This\n * helper function should be called in componentWillLoad and assigned to a variable\n * that is later used in the render function.\n *\n * This does not need to be reactive as changing attributes on the host element\n * does not trigger a re-render.\n */\n export const inheritAttributes = (el: HTMLElement, attributes: string[] = []) => {\n const attributeObject: { [k: string]: any } = {}; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n attributes.forEach(attr => {\n if (el.hasAttribute(attr)) {\n const value = el.getAttribute(attr);\n if (value !== null) {\n attributeObject[attr] = el.getAttribute(attr);\n }\n el.removeAttribute(attr);\n }\n });\n\n return attributeObject;\n}\n"]}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { isStr } from "./utils";
|
|
2
2
|
export const validateContent = (svgContent) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const div = document.createElement('div');
|
|
4
|
+
div.innerHTML = svgContent;
|
|
5
|
+
// setup this way to ensure it works on our buddy IE
|
|
6
|
+
for (let i = div.childNodes.length - 1; i >= 0; i--) {
|
|
7
|
+
if (div.childNodes[i].nodeName.toLowerCase() !== 'svg') {
|
|
8
|
+
div.removeChild(div.childNodes[i]);
|
|
9
|
+
}
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
// must only have 1 root element
|
|
12
|
+
const svgElm = div.firstElementChild;
|
|
13
|
+
if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {
|
|
14
|
+
const svgClass = svgElm.getAttribute('class') || '';
|
|
15
|
+
svgElm.setAttribute('class', (svgClass + ' s-ion-icon').trim());
|
|
16
|
+
// root element must be an svg
|
|
17
|
+
// lets double check we've got valid elements
|
|
18
|
+
// do not allow scripts
|
|
19
|
+
if (isValid(svgElm)) {
|
|
20
|
+
return div.innerHTML;
|
|
21
|
+
}
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
return '';
|
|
23
|
+
return '';
|
|
24
24
|
};
|
|
25
25
|
export const isValid = (elm) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (elm.nodeType === 1) {
|
|
27
|
+
if (elm.nodeName.toLowerCase() === 'script') {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
for (let i = 0; i < elm.attributes.length; i++) {
|
|
31
|
+
const name = elm.attributes[i].name;
|
|
32
|
+
if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (let i = 0; i < elm.childNodes.length; i++) {
|
|
37
|
+
if (!isValid(elm.childNodes[i])) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
29
41
|
}
|
|
30
|
-
|
|
31
|
-
const name = elm.attributes[i].name;
|
|
32
|
-
if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
for (let i = 0; i < elm.childNodes.length; i++) {
|
|
37
|
-
if (!isValid(elm.childNodes[i])) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
42
|
+
return true;
|
|
43
43
|
};
|
|
44
44
|
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/components/pds-icon/validate.ts"],"names":[],"mappings":"AAAA,OAAO,E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EF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAgB,EAAE,EAAE;IAC1C,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,EAAE;QACtB,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,EAAE;YAC3C,OAAO,KAAK,CAAC;SACd;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACpC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBACzD,OAAO,KAAK,CAAC;aACd;SACF;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAgB,CAAC,EAAE;gBAC9C,OAAO,KAAK,CAAC;aACd;SACF;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","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-ion-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"]}
|
package/dist/docs.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2023-
|
|
2
|
+
"timestamp": "2023-12-13T15:58:43",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
|
-
"version": "4.
|
|
5
|
+
"version": "4.8.1",
|
|
6
6
|
"typescriptVersion": "5.2.2"
|
|
7
7
|
},
|
|
8
8
|
"components": [
|
|
@@ -36,6 +36,27 @@
|
|
|
36
36
|
"optional": true,
|
|
37
37
|
"required": false
|
|
38
38
|
},
|
|
39
|
+
{
|
|
40
|
+
"name": "icon",
|
|
41
|
+
"type": "any",
|
|
42
|
+
"complexType": {
|
|
43
|
+
"original": "any",
|
|
44
|
+
"resolved": "any",
|
|
45
|
+
"references": {}
|
|
46
|
+
},
|
|
47
|
+
"mutable": false,
|
|
48
|
+
"attr": "icon",
|
|
49
|
+
"reflectToAttr": false,
|
|
50
|
+
"docs": "This a combination of both `name` and `src`. If a `src` url is detected\nit will set the `src` property. Otherwise it assumes it's a built-in named\nSVG and set the `name` property.",
|
|
51
|
+
"docsTags": [],
|
|
52
|
+
"values": [
|
|
53
|
+
{
|
|
54
|
+
"type": "any"
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"optional": true,
|
|
58
|
+
"required": false
|
|
59
|
+
},
|
|
39
60
|
{
|
|
40
61
|
"name": "name",
|
|
41
62
|
"type": "string",
|
|
@@ -31,6 +31,13 @@ const uniqueTime = (key, measureText) => {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
34
|
+
/**
|
|
35
|
+
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
36
|
+
*
|
|
37
|
+
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
38
|
+
* support as of Stencil v4.
|
|
39
|
+
*/
|
|
40
|
+
const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
|
|
34
41
|
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
35
42
|
/**
|
|
36
43
|
* Default style mode id
|
|
@@ -257,6 +264,10 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
257
264
|
}
|
|
258
265
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
259
266
|
}
|
|
267
|
+
// Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
|
|
268
|
+
if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
|
|
269
|
+
styleElm.innerHTML += SLOT_FB_CSS;
|
|
270
|
+
}
|
|
260
271
|
if (appliedStyles) {
|
|
261
272
|
appliedStyles.add(scopeId);
|
|
262
273
|
}
|
|
@@ -387,11 +398,19 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
387
398
|
// except for the first character, we keep the event name case
|
|
388
399
|
memberName = ln[2] + memberName.slice(3);
|
|
389
400
|
}
|
|
390
|
-
if (oldValue) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
401
|
+
if (oldValue || newValue) {
|
|
402
|
+
// Need to account for "capture" events.
|
|
403
|
+
// If the event name ends with "Capture", we'll update the name to remove
|
|
404
|
+
// the "Capture" suffix and make sure the event listener is setup to handle the capture event.
|
|
405
|
+
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
|
|
406
|
+
// Make sure we only replace the last instance of "Capture"
|
|
407
|
+
memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
|
|
408
|
+
if (oldValue) {
|
|
409
|
+
plt.rel(elm, memberName, oldValue, capture);
|
|
410
|
+
}
|
|
411
|
+
if (newValue) {
|
|
412
|
+
plt.ael(elm, memberName, newValue, capture);
|
|
413
|
+
}
|
|
395
414
|
}
|
|
396
415
|
}
|
|
397
416
|
else {
|
|
@@ -413,7 +432,11 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
413
432
|
elm[memberName] = newValue;
|
|
414
433
|
}
|
|
415
434
|
}
|
|
416
|
-
catch (e) {
|
|
435
|
+
catch (e) {
|
|
436
|
+
/**
|
|
437
|
+
* in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
|
|
438
|
+
*/
|
|
439
|
+
}
|
|
417
440
|
}
|
|
418
441
|
/**
|
|
419
442
|
* Need to manually update attribute if:
|
|
@@ -452,7 +475,14 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
452
475
|
}
|
|
453
476
|
};
|
|
454
477
|
const parseClassListRegex = /\s/;
|
|
478
|
+
/**
|
|
479
|
+
* Parsed a string of classnames into an array
|
|
480
|
+
* @param value className string, e.g. "foo bar baz"
|
|
481
|
+
* @returns list of classes, e.g. ["foo", "bar", "baz"]
|
|
482
|
+
*/
|
|
455
483
|
const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
|
484
|
+
const CAPTURE_EVENT_SUFFIX = 'Capture';
|
|
485
|
+
const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
|
|
456
486
|
const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
457
487
|
// if the element passed in is a shadow root, which is a document fragment
|
|
458
488
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
@@ -861,9 +891,9 @@ const patch = (oldVNode, newVNode) => {
|
|
|
861
891
|
}
|
|
862
892
|
};
|
|
863
893
|
/**
|
|
864
|
-
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by
|
|
865
|
-
*
|
|
866
|
-
*
|
|
894
|
+
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
|
|
895
|
+
* them with `null`. This signals that the DOM element corresponding to the VDom
|
|
896
|
+
* node has been removed from the DOM.
|
|
867
897
|
*
|
|
868
898
|
* @param vNode a virtual DOM node
|
|
869
899
|
*/
|
|
@@ -1230,13 +1260,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1230
1260
|
*/
|
|
1231
1261
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1232
1262
|
var _a;
|
|
1263
|
+
const prototype = Cstr.prototype;
|
|
1233
1264
|
if (cmpMeta.$members$) {
|
|
1234
1265
|
if (Cstr.watchers) {
|
|
1235
1266
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1236
1267
|
}
|
|
1237
1268
|
// It's better to have a const than two Object.entries()
|
|
1238
1269
|
const members = Object.entries(cmpMeta.$members$);
|
|
1239
|
-
const prototype = Cstr.prototype;
|
|
1240
1270
|
members.map(([memberName, [memberFlags]]) => {
|
|
1241
1271
|
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1242
1272
|
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
@@ -1259,6 +1289,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1259
1289
|
const attrNameToPropName = new Map();
|
|
1260
1290
|
prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
|
|
1261
1291
|
plt.jmp(() => {
|
|
1292
|
+
var _a;
|
|
1262
1293
|
const propName = attrNameToPropName.get(attrName);
|
|
1263
1294
|
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
1264
1295
|
// in the case where an attribute was set inline.
|
|
@@ -1314,11 +1345,12 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1314
1345
|
// 1. The instance is ready
|
|
1315
1346
|
// 2. The watchers are ready
|
|
1316
1347
|
// 3. The value has changed
|
|
1317
|
-
if (
|
|
1348
|
+
if (flags &&
|
|
1349
|
+
!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
|
|
1318
1350
|
flags & 128 /* HOST_FLAGS.isWatchReady */ &&
|
|
1319
1351
|
newValue !== oldValue) {
|
|
1320
1352
|
const instance = hostRef.$lazyInstance$ ;
|
|
1321
|
-
const entry = cmpMeta.$watchers$[attrName];
|
|
1353
|
+
const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
|
|
1322
1354
|
entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
|
|
1323
1355
|
if (instance[callbackName] != null) {
|
|
1324
1356
|
instance[callbackName].call(instance, newValue, oldValue, attrName);
|
|
@@ -1340,10 +1372,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1340
1372
|
...members
|
|
1341
1373
|
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
|
|
1342
1374
|
.map(([propName, m]) => {
|
|
1375
|
+
var _a;
|
|
1343
1376
|
const attrName = m[1] || propName;
|
|
1344
1377
|
attrNameToPropName.set(attrName, propName);
|
|
1345
1378
|
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1346
|
-
cmpMeta.$attrsToReflect
|
|
1379
|
+
(_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
|
|
1347
1380
|
}
|
|
1348
1381
|
return attrName;
|
|
1349
1382
|
}),
|
|
@@ -1352,7 +1385,18 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1352
1385
|
}
|
|
1353
1386
|
return Cstr;
|
|
1354
1387
|
};
|
|
1355
|
-
|
|
1388
|
+
/**
|
|
1389
|
+
* Initialize a Stencil component given a reference to its host element, its
|
|
1390
|
+
* runtime bookkeeping data structure, runtime metadata about the component,
|
|
1391
|
+
* and (optionally) an HMR version ID.
|
|
1392
|
+
*
|
|
1393
|
+
* @param elm a host element
|
|
1394
|
+
* @param hostRef the element's runtime bookkeeping object
|
|
1395
|
+
* @param cmpMeta runtime metadata for the Stencil component
|
|
1396
|
+
* @param hmrVersionId an (optional) HMR version ID
|
|
1397
|
+
*/
|
|
1398
|
+
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
1399
|
+
let Cstr;
|
|
1356
1400
|
// initializeComponent
|
|
1357
1401
|
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1358
1402
|
// Let the runtime know that the component has been initialized
|
|
@@ -1510,12 +1554,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1510
1554
|
const customElements = win.customElements;
|
|
1511
1555
|
const head = doc.head;
|
|
1512
1556
|
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
|
1513
|
-
const
|
|
1557
|
+
const dataStyles = /*@__PURE__*/ doc.createElement('style');
|
|
1514
1558
|
const deferredConnectedCallbacks = [];
|
|
1515
1559
|
let appLoadFallback;
|
|
1516
1560
|
let isBootstrapping = true;
|
|
1517
1561
|
Object.assign(plt, options);
|
|
1518
1562
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1563
|
+
let hasSlotRelocation = false;
|
|
1519
1564
|
lazyBundles.map((lazyBundle) => {
|
|
1520
1565
|
lazyBundle[1].map((compactMeta) => {
|
|
1521
1566
|
var _a;
|
|
@@ -1525,6 +1570,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1525
1570
|
$members$: compactMeta[2],
|
|
1526
1571
|
$listeners$: compactMeta[3],
|
|
1527
1572
|
};
|
|
1573
|
+
// Check if we are using slots outside the shadow DOM in this component.
|
|
1574
|
+
// We'll use this information later to add styles for `slot-fb` elements
|
|
1575
|
+
if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
|
|
1576
|
+
hasSlotRelocation = true;
|
|
1577
|
+
}
|
|
1528
1578
|
{
|
|
1529
1579
|
cmpMeta.$members$ = compactMeta[2];
|
|
1530
1580
|
}
|
|
@@ -1581,15 +1631,25 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1581
1631
|
}
|
|
1582
1632
|
});
|
|
1583
1633
|
});
|
|
1634
|
+
// Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
|
|
1635
|
+
if (hasSlotRelocation) {
|
|
1636
|
+
dataStyles.innerHTML += SLOT_FB_CSS;
|
|
1637
|
+
}
|
|
1638
|
+
// Add hydration styles
|
|
1584
1639
|
{
|
|
1585
|
-
|
|
1586
|
-
|
|
1640
|
+
dataStyles.innerHTML += cmpTags + HYDRATED_CSS;
|
|
1641
|
+
}
|
|
1642
|
+
// If we have styles, add them to the DOM
|
|
1643
|
+
if (dataStyles.innerHTML.length) {
|
|
1644
|
+
dataStyles.setAttribute('data-styles', '');
|
|
1587
1645
|
// Apply CSP nonce to the style tag if it exists
|
|
1588
1646
|
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1589
1647
|
if (nonce != null) {
|
|
1590
|
-
|
|
1648
|
+
dataStyles.setAttribute('nonce', nonce);
|
|
1591
1649
|
}
|
|
1592
|
-
|
|
1650
|
+
// Insert the styles into the document head
|
|
1651
|
+
// NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
|
|
1652
|
+
head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1593
1653
|
}
|
|
1594
1654
|
// Process deferred connectedCallbacks now all components have been registered
|
|
1595
1655
|
isBootstrapping = false;
|
|
@@ -1741,9 +1801,9 @@ const flush = () => {
|
|
|
1741
1801
|
}
|
|
1742
1802
|
}
|
|
1743
1803
|
};
|
|
1744
|
-
const nextTick =
|
|
1804
|
+
const nextTick = (cb) => promiseResolve().then(cb);
|
|
1745
1805
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1746
1806
|
|
|
1747
1807
|
export { Host as H, getElement as a, bootstrapLazy as b, getAssetPath as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|
|
1748
1808
|
|
|
1749
|
-
//# sourceMappingURL=index-
|
|
1809
|
+
//# sourceMappingURL=index-d1a605fc.js.map
|