@siemens/ix-icons 0.0.0-20240827135516 → 0.0.0-20250114162200

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. package/README.md +19 -2
  2. package/components/icon.js +9 -2
  3. package/components/icon.js.map +1 -1
  4. package/components/index.js +1 -1
  5. package/dist/cjs/{icon-93104dbb.js → icon-7938bd17.js} +11 -3
  6. package/dist/cjs/icon-7938bd17.js.map +1 -0
  7. package/dist/cjs/index-12b9d30e.js +1221 -0
  8. package/dist/cjs/index-12b9d30e.js.map +1 -0
  9. package/dist/cjs/index.cjs.js +3 -2
  10. package/dist/cjs/index.cjs.js.map +1 -1
  11. package/dist/cjs/ix-icon.cjs.entry.js +2 -2
  12. package/dist/cjs/ix-icons.cjs.js +9 -9
  13. package/dist/cjs/ix-icons.cjs.js.map +1 -1
  14. package/dist/cjs/loader.cjs.js +1 -1
  15. package/dist/collection/collection-manifest.json +2 -2
  16. package/dist/collection/components/icon/resolveIcon.js +8 -1
  17. package/dist/collection/components/icon/resolveIcon.js.map +1 -1
  18. package/dist/collection/components/icon/test/{rocker-example.js → rocket-example.js} +1 -1
  19. package/dist/collection/components/icon/test/{rocker-example.js.map → rocket-example.js.map} +1 -1
  20. package/dist/collection/index.js +1 -0
  21. package/dist/collection/index.js.map +1 -1
  22. package/dist/esm/{icon-97776d4a.js → icon-7346da2f.js} +11 -4
  23. package/dist/esm/icon-7346da2f.js.map +1 -0
  24. package/dist/esm/index-05493327.js +1191 -0
  25. package/dist/esm/index-05493327.js.map +1 -0
  26. package/dist/esm/index.js +2 -2
  27. package/dist/esm/ix-icon.entry.js +2 -2
  28. package/dist/esm/ix-icons.js +10 -10
  29. package/dist/esm/ix-icons.js.map +1 -1
  30. package/dist/esm/loader.js +2 -2
  31. package/dist/ix-icons/index.esm.js +1 -1
  32. package/dist/ix-icons/index.esm.js.map +1 -1
  33. package/dist/ix-icons/ix-icons.esm.js +1 -1
  34. package/dist/ix-icons/ix-icons.esm.js.map +1 -1
  35. package/dist/ix-icons/p-07c8bd06.entry.js +2 -0
  36. package/dist/ix-icons/p-07c8bd06.entry.js.map +1 -0
  37. package/dist/ix-icons/p-20132e89.js +3 -0
  38. package/dist/ix-icons/p-20132e89.js.map +1 -0
  39. package/dist/ix-icons/p-daba5432.js +2 -0
  40. package/dist/ix-icons/p-daba5432.js.map +1 -0
  41. package/dist/ix-icons/p-e1255160.js.map +1 -1
  42. package/dist/types/components/icon/resolveIcon.d.ts +1 -0
  43. package/dist/types/index.d.ts +1 -0
  44. package/dist/types/stencil-public-runtime.d.ts +3 -10
  45. package/icons/package.json +1 -1
  46. package/loader/cdn.js +1 -3
  47. package/loader/index.cjs.js +1 -3
  48. package/loader/index.d.ts +3 -0
  49. package/loader/index.es2017.js +1 -3
  50. package/loader/index.js +1 -3
  51. package/package.json +2 -2
  52. package/dist/cjs/icon-93104dbb.js.map +0 -1
  53. package/dist/cjs/index-8f585802.js +0 -1810
  54. package/dist/cjs/index-8f585802.js.map +0 -1
  55. package/dist/collection/components/icon/test/ix-icon.spec.js +0 -61
  56. package/dist/collection/components/icon/test/ix-icon.spec.js.map +0 -1
  57. package/dist/collection/components/icon/test/resolveIcon.spec.js +0 -88
  58. package/dist/collection/components/icon/test/resolveIcon.spec.js.map +0 -1
  59. package/dist/esm/icon-97776d4a.js.map +0 -1
  60. package/dist/esm/index-d1072d3f.js +0 -1780
  61. package/dist/esm/index-d1072d3f.js.map +0 -1
  62. package/dist/esm/polyfills/core-js.js +0 -11
  63. package/dist/esm/polyfills/dom.js +0 -79
  64. package/dist/esm/polyfills/es5-html-element.js +0 -1
  65. package/dist/esm/polyfills/index.js +0 -34
  66. package/dist/esm/polyfills/system.js +0 -6
  67. package/dist/ix-icons/p-05455ad0.js +0 -3
  68. package/dist/ix-icons/p-05455ad0.js.map +0 -1
  69. package/dist/ix-icons/p-60aebf69.entry.js +0 -2
  70. package/dist/ix-icons/p-60aebf69.entry.js.map +0 -1
  71. package/dist/ix-icons/p-cf592f05.js +0 -2
  72. package/dist/ix-icons/p-cf592f05.js.map +0 -1
  73. /package/dist/types/components/icon/test/{rocker-example.d.ts → rocket-example.d.ts} +0 -0
@@ -1,61 +0,0 @@
1
- /*
2
- * COPYRIGHT (c) Siemens AG 2018-2023 ALL RIGHTS RESERVED.
3
- */
4
- import { newSpecPage } from "@stencil/core/testing";
5
- import { Icon } from "../icon";
6
- import { rocket } from "./rocker-example";
7
- //@ts-ignore
8
- global.fetch = jest.fn(() => Promise.resolve({
9
- ok: true,
10
- text: () => Promise.resolve(`
11
- <svg height="512px" version="1.1" viewBox="0 0 512 512" width="512px" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
12
- <g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1">
13
- <g id="icon" transform="translate(42.666667, 64.000000)">
14
- <path d="M405.333333,1.42108547e-14 C396.316305,122.794806 364.316305,211.683695 309.333333,266.666667 C299.582265,276.417735 288.905446,285.33185 277.302879,293.409011 L277.302464,341.234872 L213.302464,405.234872 L174.248,336.891 L68.525,231.157 L7.10542736e-15,192 L64,128 L112.079613,128.000404 C120.083859,116.387258 128.94621,105.720457 138.666667,96 C193.649638,41.0170286 282.538527,9.01702859 405.333333,1.42108547e-14 Z M357.333333,47.9786667 L348.203556,49.3631108 C266.32942,62.2476147 206.763982,88.2424635 168.836556,126.169889 C146.004433,149.002012 128.637057,178.732412 116.876114,215.881246 L116.096,218.389333 L187.584,289.877333 L191.120585,288.76541 C224.531258,277.548675 251.975141,261.807487 273.818948,241.632769 L279.163444,236.496777 C317.09087,198.569351 343.085719,139.003914 355.970222,57.1297769 L357.333333,47.9786667 Z M75.9901363,269.368015 L30.7353023,314.622849 L0.565412939,284.452959 L45.8202469,239.198125 L75.9901363,269.368015 Z M121.24497,314.622849 L45.8202469,390.047572 L15.6503576,359.877683 L91.0750809,284.452959 L121.24497,314.622849 Z M136.329915,329.707793 L166.499804,359.877683 L121.24497,405.132517 L91.0750809,374.962627 L136.329915,329.707793 Z M245.333333,128 C263.006445,128 277.333333,142.326888 277.333333,160 C277.333333,177.673112 263.006445,192 245.333333,192 C227.660221,192 213.333333,177.673112 213.333333,160 C213.333333,142.326888 227.660221,128 245.333333,128 Z" id="Combined-Shape"></path>
15
- </g>
16
- </g>
17
- </svg>
18
- `),
19
- }));
20
- describe('ix-icon', () => {
21
- beforeEach(() => {
22
- //@ts-ignore
23
- fetch.mockClear();
24
- });
25
- it('should render base64 data url svg via src attribute', async () => {
26
- const page = await newSpecPage({
27
- components: [Icon],
28
- html: `<ix-icon name="${rocket}"></ix-icon>`,
29
- });
30
- expect(page.root.shadowRoot).toEqualHtml(`
31
- <div class="svg-container">
32
- <svg height="512px" version="1.1" viewBox="0 0 512 512" width="512px" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
33
- <g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1">
34
- <g id="icon" transform="translate(42.666667, 64.000000)">
35
- <path d="M405.333333,1.42108547e-14 C396.316305,122.794806 364.316305,211.683695 309.333333,266.666667 C299.582265,276.417735 288.905446,285.33185 277.302879,293.409011 L277.302464,341.234872 L213.302464,405.234872 L174.248,336.891 L68.525,231.157 L7.10542736e-15,192 L64,128 L112.079613,128.000404 C120.083859,116.387258 128.94621,105.720457 138.666667,96 C193.649638,41.0170286 282.538527,9.01702859 405.333333,1.42108547e-14 Z M357.333333,47.9786667 L348.203556,49.3631108 C266.32942,62.2476147 206.763982,88.2424635 168.836556,126.169889 C146.004433,149.002012 128.637057,178.732412 116.876114,215.881246 L116.096,218.389333 L187.584,289.877333 L191.120585,288.76541 C224.531258,277.548675 251.975141,261.807487 273.818948,241.632769 L279.163444,236.496777 C317.09087,198.569351 343.085719,139.003914 355.970222,57.1297769 L357.333333,47.9786667 Z M75.9901363,269.368015 L30.7353023,314.622849 L0.565412939,284.452959 L45.8202469,239.198125 L75.9901363,269.368015 Z M121.24497,314.622849 L45.8202469,390.047572 L15.6503576,359.877683 L91.0750809,284.452959 L121.24497,314.622849 Z M136.329915,329.707793 L166.499804,359.877683 L121.24497,405.132517 L91.0750809,374.962627 L136.329915,329.707793 Z M245.333333,128 C263.006445,128 277.333333,142.326888 277.333333,160 C277.333333,177.673112 263.006445,192 245.333333,192 C227.660221,192 213.333333,177.673112 213.333333,160 C213.333333,142.326888 227.660221,128 245.333333,128 Z" id="Combined-Shape"></path>
36
- </g>
37
- </g>
38
- </svg>
39
- </div>
40
- `);
41
- });
42
- it('should show error placeholder if svg is not found', async () => {
43
- //@ts-ignore
44
- global.fetch = jest.fn(() => Promise.resolve({
45
- ok: false,
46
- text: () => Promise.resolve(`ERROR!`),
47
- }));
48
- const page = await newSpecPage({
49
- components: [Icon],
50
- html: `<ix-icon name="/data/not-existing.svg"></ix-icon>`,
51
- });
52
- expect(page.root.shadowRoot).toEqualHtml(`
53
- <div class=\"svg-container\">
54
- <svg height=\"512\" viewBox=\"0 0 512 512\" width=\"512\" xmlns=\"http://www.w3.org/2000/svg\">
55
- <path d=\"M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z\" fill-rule=\"evenodd\" transform=\"translate(64 64)\"></path>
56
- </svg>
57
- </div>
58
- `);
59
- });
60
- });
61
- //# sourceMappingURL=ix-icon.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ix-icon.spec.js","sourceRoot":"","sources":["../../../../src/components/icon/test/ix-icon.spec.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,YAAY;AACZ,MAAM,C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GHT (c) Siemens AG 2018-2023 ALL RIGHTS RESERVED.\n */\nimport { newSpecPage } from '@stencil/core/testing';\nimport { Icon } from '../icon';\nimport { rocket } from './rocker-example';\n\n//@ts-ignore\nglobal.fetch = jest.fn(() =>\n Promise.resolve({\n ok: true,\n text: () =>\n Promise.resolve(`\n <svg height=\"512px\" version=\"1.1\" viewBox=\"0 0 512 512\" width=\"512px\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\">\n <g fill=\"none\" fill-rule=\"evenodd\" id=\"Page-1\" stroke=\"none\" stroke-width=\"1\">\n <g id=\"icon\" transform=\"translate(42.666667, 64.000000)\">\n <path d=\"M405.333333,1.42108547e-14 C396.316305,122.794806 364.316305,211.683695 309.333333,266.666667 C299.582265,276.417735 288.905446,285.33185 277.302879,293.409011 L277.302464,341.234872 L213.302464,405.234872 L174.248,336.891 L68.525,231.157 L7.10542736e-15,192 L64,128 L112.079613,128.000404 C120.083859,116.387258 128.94621,105.720457 138.666667,96 C193.649638,41.0170286 282.538527,9.01702859 405.333333,1.42108547e-14 Z M357.333333,47.9786667 L348.203556,49.3631108 C266.32942,62.2476147 206.763982,88.2424635 168.836556,126.169889 C146.004433,149.002012 128.637057,178.732412 116.876114,215.881246 L116.096,218.389333 L187.584,289.877333 L191.120585,288.76541 C224.531258,277.548675 251.975141,261.807487 273.818948,241.632769 L279.163444,236.496777 C317.09087,198.569351 343.085719,139.003914 355.970222,57.1297769 L357.333333,47.9786667 Z M75.9901363,269.368015 L30.7353023,314.622849 L0.565412939,284.452959 L45.8202469,239.198125 L75.9901363,269.368015 Z M121.24497,314.622849 L45.8202469,390.047572 L15.6503576,359.877683 L91.0750809,284.452959 L121.24497,314.622849 Z M136.329915,329.707793 L166.499804,359.877683 L121.24497,405.132517 L91.0750809,374.962627 L136.329915,329.707793 Z M245.333333,128 C263.006445,128 277.333333,142.326888 277.333333,160 C277.333333,177.673112 263.006445,192 245.333333,192 C227.660221,192 213.333333,177.673112 213.333333,160 C213.333333,142.326888 227.660221,128 245.333333,128 Z\" id=\"Combined-Shape\"></path>\n </g>\n </g>\n </svg>\n `),\n }),\n);\n\ndescribe('ix-icon', () => {\n beforeEach(() => {\n //@ts-ignore\n fetch.mockClear();\n });\n\n it('should render base64 data url svg via src attribute', async () => {\n const page = await newSpecPage({\n components: [Icon],\n html: `<ix-icon name=\"${rocket}\"></ix-icon>`,\n });\n expect(page.root.shadowRoot).toEqualHtml(`\n <div class=\"svg-container\">\n <svg height=\"512px\" version=\"1.1\" viewBox=\"0 0 512 512\" width=\"512px\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns=\"http://www.w3.org/2000/svg\">\n <g fill=\"none\" fill-rule=\"evenodd\" id=\"Page-1\" stroke=\"none\" stroke-width=\"1\">\n <g id=\"icon\" transform=\"translate(42.666667, 64.000000)\">\n <path d=\"M405.333333,1.42108547e-14 C396.316305,122.794806 364.316305,211.683695 309.333333,266.666667 C299.582265,276.417735 288.905446,285.33185 277.302879,293.409011 L277.302464,341.234872 L213.302464,405.234872 L174.248,336.891 L68.525,231.157 L7.10542736e-15,192 L64,128 L112.079613,128.000404 C120.083859,116.387258 128.94621,105.720457 138.666667,96 C193.649638,41.0170286 282.538527,9.01702859 405.333333,1.42108547e-14 Z M357.333333,47.9786667 L348.203556,49.3631108 C266.32942,62.2476147 206.763982,88.2424635 168.836556,126.169889 C146.004433,149.002012 128.637057,178.732412 116.876114,215.881246 L116.096,218.389333 L187.584,289.877333 L191.120585,288.76541 C224.531258,277.548675 251.975141,261.807487 273.818948,241.632769 L279.163444,236.496777 C317.09087,198.569351 343.085719,139.003914 355.970222,57.1297769 L357.333333,47.9786667 Z M75.9901363,269.368015 L30.7353023,314.622849 L0.565412939,284.452959 L45.8202469,239.198125 L75.9901363,269.368015 Z M121.24497,314.622849 L45.8202469,390.047572 L15.6503576,359.877683 L91.0750809,284.452959 L121.24497,314.622849 Z M136.329915,329.707793 L166.499804,359.877683 L121.24497,405.132517 L91.0750809,374.962627 L136.329915,329.707793 Z M245.333333,128 C263.006445,128 277.333333,142.326888 277.333333,160 C277.333333,177.673112 263.006445,192 245.333333,192 C227.660221,192 213.333333,177.673112 213.333333,160 C213.333333,142.326888 227.660221,128 245.333333,128 Z\" id=\"Combined-Shape\"></path>\n </g>\n </g>\n </svg>\n </div>\n `);\n });\n\n it('should show error placeholder if svg is not found', async () => {\n //@ts-ignore\n global.fetch = jest.fn(() =>\n Promise.resolve({\n ok: false,\n text: () => Promise.resolve(`ERROR!`),\n }),\n );\n\n const page = await newSpecPage({\n components: [Icon],\n html: `<ix-icon name=\"/data/not-existing.svg\"></ix-icon>`,\n });\n\n expect(page.root.shadowRoot).toEqualHtml(`\n <div class=\\\"svg-container\\\">\n <svg height=\\\"512\\\" viewBox=\\\"0 0 512 512\\\" width=\\\"512\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\">\n <path d=\\\"M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z\\\" fill-rule=\\\"evenodd\\\" transform=\\\"translate(64 64)\\\"></path>\n </svg>\n </div>\n `);\n });\n});\n"]}
@@ -1,88 +0,0 @@
1
- /*
2
- * COPYRIGHT (c) Siemens AG 2018-2023 ALL RIGHTS RESERVED.
3
- */
4
- import { iconStar } from "../icons";
5
- import { resolveIcon, getIconCacheMap, getIconUrl, parseSVGDataContent } from "../resolveIcon";
6
- const exampleSvg = `
7
- <?xml version="1.0" encoding="UTF-8"?>
8
- <svg width="512px" height="512px" viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
9
- <title>add</title>
10
- <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
11
- <g id="Shape" fill="#000000" transform="translate(65.929697, 65.929697)">
12
- <polygon points="211.189225 2.36847579e-14 211.189225 168.95138 380.140606 168.95138 380.140606 211.189225 211.189225 211.189225 211.189225 380.140606 168.95138 380.140606 168.95138 211.189225 -1.42108547e-14 211.189225 -1.42108547e-14 168.95138 168.95138 168.95138 168.95138 -1.42108547e-14"></polygon>
13
- </g>
14
- </g>
15
- </svg>
16
- `;
17
- const invalidexampleSvg = `
18
- <?xml version="1.0" encoding="UTF-8"?>
19
- <script>
20
- alert('Test!');
21
- </script>
22
- `;
23
- jest.mock('../meta-tag');
24
- jest.mock('../icons', () => ({
25
- iconStar: exampleSvg,
26
- }));
27
- let fetch = (global.fetch = jest.fn((url) => {
28
- console.log(url);
29
- if (url === '/svg/star.svg') {
30
- return Promise.resolve({
31
- text: () => Promise.resolve(iconStar),
32
- ok: true,
33
- });
34
- }
35
- if (url === '/svg/bulb.svg') {
36
- return Promise.resolve({
37
- text: () => Promise.resolve(exampleSvg),
38
- ok: true,
39
- });
40
- }
41
- if (url === 'http://localhost/test.svg') {
42
- return Promise.resolve({
43
- text: () => Promise.resolve(exampleSvg),
44
- ok: true,
45
- });
46
- }
47
- if (url === 'http://localhost/invalid.svg') {
48
- return Promise.resolve({
49
- text: () => Promise.resolve(invalidexampleSvg),
50
- ok: true,
51
- });
52
- }
53
- }));
54
- describe('resolve icon', () => {
55
- beforeEach(() => {
56
- fetch.mockClear();
57
- });
58
- it('should resolve svg from name', async () => {
59
- const data = await resolveIcon('bulb');
60
- expect(data).toBe(`<svg width=\"512px\" height=\"512px\" viewBox=\"0 0 512 512\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"> <title>add</title> <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"> <g id=\"Shape\" fill=\"#000000\" transform=\"translate(65.929697, 65.929697)\"> <polygon points=\"211.189225 2.36847579e-14 211.189225 168.95138 380.140606 168.95138 380.140606 211.189225 211.189225 211.189225 211.189225 380.140606 168.95138 380.140606 168.95138 211.189225 -1.42108547e-14 211.189225 -1.42108547e-14 168.95138 168.95138 168.95138 168.95138 -1.42108547e-14\"></polygon> </g> </g> </svg>`);
61
- });
62
- it('should resolve svg from src', async () => {
63
- const expectedName = await resolveIcon('http://localhost/test.svg');
64
- expect(expectedName).toEqual(`<svg width=\"512px\" height=\"512px\" viewBox=\"0 0 512 512\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"> <title>add</title> <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"> <g id=\"Shape\" fill=\"#000000\" transform=\"translate(65.929697, 65.929697)\"> <polygon points=\"211.189225 2.36847579e-14 211.189225 168.95138 380.140606 168.95138 380.140606 211.189225 211.189225 211.189225 211.189225 380.140606 168.95138 380.140606 168.95138 211.189225 -1.42108547e-14 211.189225 -1.42108547e-14 168.95138 168.95138 168.95138 168.95138 -1.42108547e-14\"></polygon> </g> </g> </svg>`);
65
- });
66
- it('should not resolve invalid svg from src', async () => {
67
- const icon = 'http://localhost/invalid.svg';
68
- await expect(resolveIcon(icon)).rejects.toThrow('No valid svg data provided');
69
- });
70
- });
71
- test('fill cache map if not loaded', async () => {
72
- fetch.mockClear();
73
- const cacheMap = getIconCacheMap();
74
- cacheMap.clear();
75
- expect(cacheMap.size).toBe(0);
76
- const data = await resolveIcon('star');
77
- expect(data).toBe(parseSVGDataContent(iconStar));
78
- expect(cacheMap.get(getIconUrl('star'))).toBe(parseSVGDataContent(iconStar));
79
- });
80
- test('preload custom icon', async () => {
81
- fetch.mockClear();
82
- const cacheMap = getIconCacheMap();
83
- cacheMap.clear();
84
- cacheMap.set(getIconUrl('star'), '<svg>Test</svg>');
85
- const data = await resolveIcon('star');
86
- expect(data).toBe('<svg>Test</svg>');
87
- });
88
- //# sourceMappingURL=resolveIcon.spec.js.map
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KAAK,EAAE,CAAC;IAEjB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE9B,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;IAEvC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;IACrC,KAAK,CAAC,SAAS,EAAE,CAAC;IAElB,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAEjB,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,CAAC;IAEpD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC","sourcesContent":["/*\n * COPYRIGHT (c) Siemens AG 2018-2023 ALL RIGHTS RESERVED.\n */\nimport { iconStar } from '../icons';\nimport { resolveIcon, getIconCacheMap, getIconUrl, parseSVGDataContent } from '../resolveIcon';\nconst exampleSvg = `\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg width=\"512px\" height=\"512px\" viewBox=\"0 0 512 512\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <title>add</title>\n <g id=\"Page-1\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <g id=\"Shape\" fill=\"#000000\" transform=\"translate(65.929697, 65.929697)\">\n <polygon points=\"211.189225 2.36847579e-14 211.189225 168.95138 380.140606 168.95138 380.140606 211.189225 211.189225 211.189225 211.189225 380.140606 168.95138 380.140606 168.95138 211.189225 -1.42108547e-14 211.189225 -1.42108547e-14 168.95138 168.95138 168.95138 168.95138 -1.42108547e-14\"></polygon>\n </g>\n </g>\n</svg>\n`;\n\nconst invalidexampleSvg = `\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<script>\n alert('Test!');\n</script>\n`;\n\njest.mock('../meta-tag');\njest.mock('../icons', () => ({\n iconStar: exampleSvg,\n}));\nlet fetch = (global.fetch = jest.fn((url: string) => {\n console.log(url);\n\n if (url === '/svg/star.svg') {\n return Promise.resolve({\n text: () => Promise.resolve(iconStar),\n ok: true,\n });\n }\n\n if (url === '/svg/bulb.svg') {\n return Promise.resolve({\n text: () => Promise.resolve(exampleSvg),\n ok: true,\n });\n }\n\n if (url === 'http://localhost/test.svg') {\n return Promise.resolve({\n text: () => Promise.resolve(exampleSvg),\n ok: true,\n });\n }\n\n if (url === 'http://localhost/invalid.svg') {\n return Promise.resolve({\n text: () => Promise.resolve(invalidexampleSvg),\n ok: true,\n });\n }\n}) as jest.Mock);\n\ndescribe('resolve icon', () => {\n beforeEach(() => {\n fetch.mockClear();\n });\n\n it('should resolve svg from name', async () => {\n const data = await resolveIcon('bulb');\n\n expect(data).toBe(\n `<svg width=\\\"512px\\\" height=\\\"512px\\\" viewBox=\\\"0 0 512 512\\\" version=\\\"1.1\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\" xmlns:xlink=\\\"http://www.w3.org/1999/xlink\\\"> <title>add</title> <g id=\\\"Page-1\\\" stroke=\\\"none\\\" stroke-width=\\\"1\\\" fill=\\\"none\\\" fill-rule=\\\"evenodd\\\"> <g id=\\\"Shape\\\" fill=\\\"#000000\\\" transform=\\\"translate(65.929697, 65.929697)\\\"> <polygon points=\\\"211.189225 2.36847579e-14 211.189225 168.95138 380.140606 168.95138 380.140606 211.189225 211.189225 211.189225 211.189225 380.140606 168.95138 380.140606 168.95138 211.189225 -1.42108547e-14 211.189225 -1.42108547e-14 168.95138 168.95138 168.95138 168.95138 -1.42108547e-14\\\"></polygon> </g> </g> </svg>`,\n );\n });\n\n it('should resolve svg from src', async () => {\n const expectedName = await resolveIcon('http://localhost/test.svg');\n\n expect(expectedName).toEqual(\n `<svg width=\\\"512px\\\" height=\\\"512px\\\" viewBox=\\\"0 0 512 512\\\" version=\\\"1.1\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\" xmlns:xlink=\\\"http://www.w3.org/1999/xlink\\\"> <title>add</title> <g id=\\\"Page-1\\\" stroke=\\\"none\\\" stroke-width=\\\"1\\\" fill=\\\"none\\\" fill-rule=\\\"evenodd\\\"> <g id=\\\"Shape\\\" fill=\\\"#000000\\\" transform=\\\"translate(65.929697, 65.929697)\\\"> <polygon points=\\\"211.189225 2.36847579e-14 211.189225 168.95138 380.140606 168.95138 380.140606 211.189225 211.189225 211.189225 211.189225 380.140606 168.95138 380.140606 168.95138 211.189225 -1.42108547e-14 211.189225 -1.42108547e-14 168.95138 168.95138 168.95138 168.95138 -1.42108547e-14\\\"></polygon> </g> </g> </svg>`,\n );\n });\n\n it('should not resolve invalid svg from src', async () => {\n const icon = 'http://localhost/invalid.svg';\n\n await expect(resolveIcon(icon)).rejects.toThrow('No valid svg data provided');\n });\n});\n\ntest('fill cache map if not loaded', async () => {\n fetch.mockClear();\n\n const cacheMap = getIconCacheMap();\n cacheMap.clear();\n\n expect(cacheMap.size).toBe(0);\n\n const data = await resolveIcon('star');\n\n expect(data).toBe(parseSVGDataContent(iconStar));\n expect(cacheMap.get(getIconUrl('star'))).toBe(parseSVGDataContent(iconStar));\n});\n\ntest('preload custom icon', async () => {\n fetch.mockClear();\n\n const cacheMap = getIconCacheMap();\n cacheMap.clear();\n\n cacheMap.set(getIconUrl('star'), '<svg>Test</svg>');\n\n const data = await resolveIcon('star');\n expect(data).toBe('<svg>Test</svg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AC/B,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI;gBAC/B,CAAC,SAAS,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI;aAChC,IAED,4DAAK,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,CAAC,UAAU,GAAQ,CAC1D,EACP;KACH;;;;;;;;;;;","names":[],"sources":["src/components/icon/meta-tag.ts","src/components/icon/resolveIcon.ts","src/components/icon/icon.scss?tag=ix-icon&encapsulation=shadow","src/components/icon/icon.tsx"],"sourcesContent":["/**\n * Provide custom SVG path for icons\n *\n * <meta name=\"ix-icons:path\" content=\"/build/svg\" />\n */\nexport function getCustomAssetUrl() {\n const assetPath = document.querySelector(\"meta[name='ix-icons:path']\");\n if (assetPath) {\n const path = assetPath.getAttribute('content');\n return path;\n }\n\n return false;\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getAssetPath, setAssetPath } from '@stencil/core';\nimport { getCustomAssetUrl } from './meta-tag';\n\ndeclare global {\n interface Window {\n IxIcons: any;\n }\n}\n\nlet fetchCache: Map<string, string>;\nconst requests = new Map<string, Promise<string>>();\nlet parser = null;\n\nexport const getIconCacheMap = (): Map<string, string> => {\n if (typeof window === 'undefined') {\n return new Map();\n }\n\n if (!fetchCache) {\n window.IxIcons = window.IxIcons || {};\n fetchCache = window.IxIcons.map = window.IxIcons.map || new Map();\n }\n return fetchCache;\n};\n\nexport const isSvgDataUrl = (url: string) => {\n if (!url) {\n return false;\n }\n\n if (typeof url !== 'string') {\n return false;\n }\n\n return url.startsWith('data:image/svg+xml');\n};\n\nexport function parseSVGDataContent(content: string) {\n if (typeof window['DOMParser'] === 'undefined') {\n console.warn('DOMParser not supported by your browser.');\n return;\n }\n\n if (parser === null) {\n parser = new window['DOMParser']();\n }\n\n const svgDocument = parser.parseFromString(content, 'text/html');\n const svgElement = svgDocument.querySelector('svg') as HTMLElement;\n\n if (!svgElement) {\n throw Error('No valid svg data provided');\n }\n\n return svgElement.outerHTML;\n}\n\nasync function fetchSVG(url: string) {\n const cache = getIconCacheMap();\n\n if (cache.has(url)) {\n return cache.get(url);\n }\n\n if (requests.has(url)) {\n return requests.get(url);\n }\n\n const fetching = fetch(url).then(async response => {\n const responseText = await response.text();\n\n if (!response.ok) {\n console.error(responseText);\n throw Error(responseText);\n }\n\n const svgContent = parseSVGDataContent(responseText);\n cache.set(url, svgContent);\n\n return svgContent;\n });\n\n requests.set(url, fetching);\n return fetching;\n}\nconst urlRegex = /^(?:(?:https?|ftp):\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:www\\.)?(?:\\S+\\.\\S+)(?:\\S*)$/i;\n\nfunction isValidUrl(url: string) {\n return urlRegex.test(url);\n}\n\nexport function getIconUrl(name: string) {\n const customAssetUrl = getCustomAssetUrl();\n if (customAssetUrl) {\n return `${customAssetUrl}/${name}.svg`;\n }\n\n let url: string = `svg/${name}.svg`;\n try {\n url = getAssetPath(url);\n } catch (error) {\n console.warn(error);\n setAssetPath(`${window.location.origin}/`);\n url = getAssetPath(url);\n }\n\n return url;\n}\n\nexport async function resolveIcon(iconName: string) {\n if (!iconName) {\n throw Error('No icon name provided');\n }\n\n if (isSvgDataUrl(iconName)) {\n return parseSVGDataContent(iconName);\n }\n\n if (isValidUrl(iconName)) {\n try {\n return fetchSVG(iconName);\n } catch (error) {\n throw error;\n }\n }\n\n try {\n return fetchSVG(getIconUrl(iconName));\n } catch (error) {\n throw Error('Cannot resolve any icon');\n }\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n@mixin size($size) {\n height: $size;\n width: $size;\n min-height: $size;\n min-width: $size;\n}\n\n:host {\n display: inline-flex;\n @include size(1.5rem);\n color: inherit;\n\n .svg-container {\n display: block;\n position: relative;\n width: 100%;\n height: 100%;\n\n svg {\n display: block;\n position: relative;\n height: 100%;\n width: 100%;\n }\n\n svg,\n svg[fill],\n svg [fill] {\n fill: currentColor !important;\n }\n }\n}\n\n:host(.size-12) {\n @include size(0.75rem);\n}\n\n:host(.size-16) {\n @include size(1rem);\n}\n\n:host(.size-32) {\n @include size(2rem);\n}\n","/*\n * SPDX-FileCopyrightText: 2023 Siemens AG\n *\n * SPDX-License-Identifier: MIT\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Component, h, Host, Prop, State, Watch, Element, Build } from '@stencil/core';\nimport { parseSVGDataContent, resolveIcon } from './resolveIcon';\n\nconst iconMissingSymbol =\n \"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='512' height='512' viewBox='0 0 512 512'><path fill-rule='evenodd' d='M384,0 L384,384 L0,384 L0,0 L384,0 Z M192,207.085 L57.751,341.333 L326.248,341.333 L192,207.085 Z M42.666,57.751 L42.666,326.248 L176.915,192 L42.666,57.751 Z M341.333,57.751 L207.085,192 L341.333,326.248 L341.333,57.751 Z M326.248,42.666 L57.751,42.666 L192,176.915 L326.248,42.666 Z' transform='translate(64 64)'/></svg>\";\n\n@Component({\n tag: 'ix-icon',\n styleUrl: 'icon.scss',\n shadow: true,\n assetsDirs: ['svg'],\n})\nexport class Icon {\n @Element() hostElement: HTMLIxIconElement;\n\n /**\n * Size of the icon\n */\n @Prop() size: '12' | '16' | '24' | '32';\n\n /**\n * Color of the icon\n */\n @Prop() color: string;\n\n /**\n * Use one of our defined icon names e.g. `copy`\n *\n * https://ix.siemens.io/docs/icon-library/icons\n *\n * or the import variant\n *\n * ```\n * import { rocket } from '@siemens/ix-icons/icons';\n *\n * <ix-icon name={rocket}></ix-icon>\n * ```\n */\n @Prop() name: string;\n\n @Prop() lazyLoading = false;\n\n @State() svgContent?: string;\n @State() isVisible = false;\n\n connectedCallback() {\n this.waitForRendering(() => {\n this.isVisible = true;\n this.loadIconContent();\n });\n }\n\n @Watch('name')\n async loadIconContent() {\n try {\n this.svgContent = await resolveIcon(this.name);\n } catch (error) {\n this.svgContent = parseSVGDataContent(iconMissingSymbol);\n }\n }\n\n private waitForRendering(onRender: () => void) {\n if (Build.isBrowser && this.lazyLoading && typeof window !== 'undefined' && (window as any).IntersectionObserver) {\n const observer = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n onRender();\n observer.disconnect();\n }\n });\n },\n {\n rootMargin: '25px',\n },\n );\n\n observer.observe(this.hostElement);\n } else {\n onRender();\n }\n }\n\n render() {\n const style: {\n [key: string]: string;\n } = {};\n\n if (this.color) {\n style['color'] = `var(--theme-${this.color})`;\n }\n\n return (\n <Host\n style={style}\n class={{\n ['size-12']: this.size === '12',\n ['size-16']: this.size === '16',\n ['size-24']: this.size === '24',\n ['size-32']: this.size === '32',\n }}\n >\n <div class={'svg-container'} innerHTML={this.svgContent}></div>\n </Host>\n );\n }\n}\n"],"version":3}