@redvars/peacock 3.0.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.
Files changed (61) hide show
  1. package/.editorconfig +29 -0
  2. package/.husky/pre-commit +1 -0
  3. package/LICENSE +21 -0
  4. package/README.md +46 -0
  5. package/custom-elements-manifest.config.mjs +34 -0
  6. package/custom-elements.md +252 -0
  7. package/demo/index.html +24 -0
  8. package/demo/tokens.css +510 -0
  9. package/dist/src/LoaderUtils.d.ts +23 -0
  10. package/dist/src/LoaderUtils.js +81 -0
  11. package/dist/src/LoaderUtils.js.map +1 -0
  12. package/dist/src/avatar/avatar.css.d.ts +1 -0
  13. package/dist/src/avatar/avatar.css.js +41 -0
  14. package/dist/src/avatar/avatar.css.js.map +1 -0
  15. package/dist/src/avatar/avatar.d.ts +14 -0
  16. package/dist/src/avatar/avatar.js +44 -0
  17. package/dist/src/avatar/avatar.js.map +1 -0
  18. package/dist/src/icon/datasource.d.ts +2 -0
  19. package/dist/src/icon/datasource.js +20 -0
  20. package/dist/src/icon/datasource.js.map +1 -0
  21. package/dist/src/icon/icon.css.d.ts +1 -0
  22. package/dist/src/icon/icon.css.js +22 -0
  23. package/dist/src/icon/icon.css.js.map +1 -0
  24. package/dist/src/icon/icon.d.ts +26 -0
  25. package/dist/src/icon/icon.js +119 -0
  26. package/dist/src/icon/icon.js.map +1 -0
  27. package/dist/src/icon/p-icon.d.ts +3 -0
  28. package/dist/src/icon/p-icon.js +10 -0
  29. package/dist/src/icon/p-icon.js.map +1 -0
  30. package/dist/src/index.d.ts +2 -0
  31. package/dist/src/index.js +3 -0
  32. package/dist/src/index.js.map +1 -0
  33. package/dist/src/peacock-loader.d.ts +1 -0
  34. package/dist/src/peacock-loader.js +16 -0
  35. package/dist/src/peacock-loader.js.map +1 -0
  36. package/dist/src/utils.d.ts +3 -0
  37. package/dist/src/utils.js +101 -0
  38. package/dist/src/utils.js.map +1 -0
  39. package/dist/test/icon.test.d.ts +1 -0
  40. package/dist/test/icon.test.js +14 -0
  41. package/dist/test/icon.test.js.map +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -0
  43. package/package.json +87 -0
  44. package/readme-gen.mjs +11 -0
  45. package/rollup.config.js +19 -0
  46. package/src/LoaderUtils.ts +121 -0
  47. package/src/avatar/avatar.css.ts +41 -0
  48. package/src/avatar/avatar.ts +39 -0
  49. package/src/avatar/demo/index.html +26 -0
  50. package/src/icon/datasource.ts +28 -0
  51. package/src/icon/demo/index.html +25 -0
  52. package/src/icon/icon.css.ts +22 -0
  53. package/src/icon/icon.ts +117 -0
  54. package/src/icon/p-icon.ts +5 -0
  55. package/src/index.ts +2 -0
  56. package/src/peacock-loader.ts +17 -0
  57. package/src/utils.ts +118 -0
  58. package/test/icon.test.ts +16 -0
  59. package/tsconfig.json +22 -0
  60. package/web-dev-server.config.js +27 -0
  61. package/web-test-runner.config.js +41 -0
@@ -0,0 +1,14 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * @summary Icons are visual symbols used to represent ideas, objects, or actions.
4
+ *
5
+ * @cssprop --icon-color - Controls the color of the icon.
6
+ * @cssprop --icon-size - Controls the size of the icon.
7
+ */
8
+ export declare class Avatar extends LitElement {
9
+ static styles: import("lit").CSSResult[];
10
+ name: string;
11
+ src?: string;
12
+ render(): import("lit-html").TemplateResult<1>;
13
+ private __getInitials;
14
+ }
@@ -0,0 +1,44 @@
1
+ import { __decorate } from "tslib";
2
+ import { html, LitElement } from 'lit';
3
+ import { property } from 'lit/decorators.js';
4
+ import { classMap } from 'lit/directives/class-map.js';
5
+ import { styles } from './avatar.css.js';
6
+ /**
7
+ * @summary Icons are visual symbols used to represent ideas, objects, or actions.
8
+ *
9
+ * @cssprop --icon-color - Controls the color of the icon.
10
+ * @cssprop --icon-size - Controls the size of the icon.
11
+ */
12
+ export class Avatar extends LitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.name = '';
16
+ }
17
+ render() {
18
+ return html `<div class="avatar-container">
19
+ <div
20
+ class=${classMap({
21
+ avatar: true,
22
+ initials: !this.src,
23
+ image: !!this.src,
24
+ })}
25
+ >
26
+ ${this.src
27
+ ? html `<img class="image" src=${this.src} alt=${this.name} />`
28
+ : html `<div class="initials">${this.__getInitials()}</div>`}
29
+ </div>
30
+ </div>`;
31
+ }
32
+ __getInitials() {
33
+ const [first = '', last = ''] = this.name.split(' ');
34
+ return `${first.charAt(0)}${last.charAt(0)}`.toUpperCase();
35
+ }
36
+ }
37
+ Avatar.styles = [styles];
38
+ __decorate([
39
+ property({ type: String, reflect: true })
40
+ ], Avatar.prototype, "name", void 0);
41
+ __decorate([
42
+ property({ type: String, reflect: true })
43
+ ], Avatar.prototype, "src", void 0);
44
+ //# sourceMappingURL=avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar.js","sourceRoot":"","sources":["../../../src/avatar/avatar.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,OAAO,MAAO,SAAQ,UAAU;IAAtC;;QAG6C,SAAI,GAAW,EAAE,CAAC;IAwB/D,CAAC;IApBC,MAAM;QACJ,OAAO,IAAI,CAAA;;gBAEC,QAAQ,CAAC;YACf,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG;YACnB,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG;SAClB,CAAC;;UAEA,IAAI,CAAC,GAAG;YACR,CAAC,CAAC,IAAI,CAAA,0BAA0B,IAAI,CAAC,GAAG,QAAQ,IAAI,CAAC,IAAI,KAAK;YAC9D,CAAC,CAAC,IAAI,CAAA,yBAAyB,IAAI,CAAC,aAAa,EAAE,QAAQ;;WAE1D,CAAC;IACV,CAAC;IAEO,aAAa;QACnB,MAAM,CAAC,KAAK,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrD,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7D,CAAC;;AAzBM,aAAM,GAAG,CAAC,MAAM,CAAC,AAAX,CAAY;AAEkB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oCAAmB;AAElB;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mCAAc","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styles } from './avatar.css.js';\n\n/**\n * @summary Icons are visual symbols used to represent ideas, objects, or actions.\n *\n * @cssprop --icon-color - Controls the color of the icon.\n * @cssprop --icon-size - Controls the size of the icon.\n */\nexport class Avatar extends LitElement {\n static styles = [styles];\n\n @property({ type: String, reflect: true }) name: string = '';\n\n @property({ type: String, reflect: true }) src?: string;\n\n render() {\n return html`<div class=\"avatar-container\">\n <div\n class=${classMap({\n avatar: true,\n initials: !this.src,\n image: !!this.src,\n })}\n >\n ${this.src\n ? html`<img class=\"image\" src=${this.src} alt=${this.name} />`\n : html`<div class=\"initials\">${this.__getInitials()}</div>`}\n </div>\n </div>`;\n }\n\n private __getInitials() {\n const [first = '', last = ''] = this.name.split(' ');\n return `${first.charAt(0)}${last.charAt(0)}`.toUpperCase();\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function fetchSVG(url: string): Promise<string>;
2
+ export declare function fetchIcon(name: string, provider?: string): Promise<string>;
@@ -0,0 +1,20 @@
1
+ import { createCacheFetch } from '../utils.js';
2
+ const PROVIDERS = {
3
+ 'material-symbols': (name) => `https://cdn.jsdelivr.net/npm/@material-symbols/svg-500@0.40.1/outlined/${name}.svg`,
4
+ carbon: (name) => `https://cdn.jsdelivr.net/npm/@carbon/icons@11.41.0/svg/32/${name}.svg`,
5
+ };
6
+ const cacheFetch = await createCacheFetch('svg-cache');
7
+ export async function fetchSVG(url) {
8
+ if (!url)
9
+ return '';
10
+ return cacheFetch(url);
11
+ }
12
+ export async function fetchIcon(name, provider = 'material-symbols') {
13
+ if (!name)
14
+ return '';
15
+ if (!PROVIDERS[provider]) {
16
+ throw new Error(`Provider '${provider}' not found`);
17
+ }
18
+ return fetchSVG(PROVIDERS[provider](name));
19
+ }
20
+ //# sourceMappingURL=datasource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../../src/icon/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,SAAS,GAA6C;IAC1D,kBAAkB,EAAE,CAAC,IAAY,EAAE,EAAE,CACnC,0EAA0E,IAAI,MAAM;IACtF,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CACvB,6DAA6D,IAAI,MAAM;CAC1E,CAAC;AAEF,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,WAAW,CAAC,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,GAAW;IACxC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,IAAY,EACZ,WAAmB,kBAAkB;IAErC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,aAAa,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { createCacheFetch } from '../utils.js';\n\nconst PROVIDERS: Record<string, (name: string) => string> = {\n 'material-symbols': (name: string) =>\n `https://cdn.jsdelivr.net/npm/@material-symbols/svg-500@0.40.1/outlined/${name}.svg`,\n carbon: (name: string) =>\n `https://cdn.jsdelivr.net/npm/@carbon/icons@11.41.0/svg/32/${name}.svg`,\n};\n\nconst cacheFetch = await createCacheFetch('svg-cache');\n\nexport async function fetchSVG(url: string) {\n if (!url) return '';\n return cacheFetch(url);\n}\n\nexport async function fetchIcon(\n name: string,\n provider: string = 'material-symbols',\n) {\n if (!name) return '';\n\n if (!PROVIDERS[provider]) {\n throw new Error(`Provider '${provider}' not found`);\n }\n\n return fetchSVG(PROVIDERS[provider](name));\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,22 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ display: inline-block;
5
+ line-height: 0;
6
+ --icon-size: inherit;
7
+ --icon-color: inherit;
8
+ }
9
+
10
+ .icon {
11
+ display: inline-block;
12
+ height: var(--icon-size, 1rem);
13
+ width: var(--icon-size, 1rem);
14
+
15
+ svg {
16
+ fill: var(--icon-color);
17
+ height: 100%;
18
+ width: 100%;
19
+ }
20
+ }
21
+ `;
22
+ //# sourceMappingURL=icon.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.css.js","sourceRoot":"","sources":["../../../src/icon/icon.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;CAmBxB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`\n :host {\n display: inline-block;\n line-height: 0;\n --icon-size: inherit;\n --icon-color: inherit;\n }\n\n .icon {\n display: inline-block;\n height: var(--icon-size, 1rem);\n width: var(--icon-size, 1rem);\n\n svg {\n fill: var(--icon-color);\n height: 100%;\n width: 100%;\n }\n }\n`;\n"]}
@@ -0,0 +1,26 @@
1
+ import { LitElement } from 'lit';
2
+ /**
3
+ * @summary Icons are visual symbols used to represent ideas, objects, or actions.
4
+ *
5
+ * @cssprop --icon-color - Controls the color of the icon.
6
+ * @cssprop [--icon-size=1rem] - Controls the size of the icon. Defaults to "1rem"
7
+ */
8
+ export declare class Icon extends LitElement {
9
+ static styles: import("lit").CSSResult[];
10
+ name?: string;
11
+ src?: string;
12
+ provider?: 'material-symbols' | 'carbon';
13
+ private svgContent;
14
+ private loading;
15
+ private error;
16
+ private _fetchId;
17
+ private _debounceTimer;
18
+ firstUpdated(): void;
19
+ updated(changedProperties: any): void;
20
+ render(): import("lit-html").TemplateResult<1>;
21
+ private __scheduleUpdate;
22
+ /**
23
+ * @internal
24
+ */
25
+ private __updateSvg;
26
+ }
@@ -0,0 +1,119 @@
1
+ import { __decorate } from "tslib";
2
+ import { html, LitElement } from 'lit';
3
+ import { property, state } from 'lit/decorators.js';
4
+ import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
5
+ import { fetchIcon, fetchSVG } from './datasource.js';
6
+ import { sanitizeSvg } from '../utils.js';
7
+ import { styles } from './icon.css.js';
8
+ /**
9
+ * @summary Icons are visual symbols used to represent ideas, objects, or actions.
10
+ *
11
+ * @cssprop --icon-color - Controls the color of the icon.
12
+ * @cssprop [--icon-size=1rem] - Controls the size of the icon. Defaults to "1rem"
13
+ */
14
+ export class Icon extends LitElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.name = 'home';
18
+ this.provider = 'material-symbols';
19
+ this.svgContent = '';
20
+ // loading + error states for consumers/tests
21
+ this.loading = false;
22
+ this.error = null;
23
+ // token to avoid race conditions when multiple fetches overlap
24
+ this._fetchId = 0;
25
+ }
26
+ firstUpdated() {
27
+ // perform initial fetch once component is connected and rendered
28
+ this.__scheduleUpdate();
29
+ }
30
+ updated(changedProperties) {
31
+ // only refetch when name or src changed
32
+ if (changedProperties.has('name') || changedProperties.has('src')) {
33
+ this.__scheduleUpdate();
34
+ }
35
+ }
36
+ render() {
37
+ // accessible wrapper; consumers can provide a fallback via <slot name="fallback">.
38
+ return html ` <div class="icon">
39
+ ${this.svgContent
40
+ ? unsafeSVG(this.svgContent)
41
+ : html `<slot name="fallback"></slot>`}
42
+ </div>`;
43
+ }
44
+ // small debounce to coalesce rapid changes (50ms)
45
+ __scheduleUpdate() {
46
+ if (this._debounceTimer) {
47
+ clearTimeout(this._debounceTimer);
48
+ }
49
+ // @ts-ignore - setTimeout in DOM returns number
50
+ this._debounceTimer = window.setTimeout(() => this.__updateSvg(), 50);
51
+ }
52
+ /**
53
+ * @internal
54
+ */
55
+ async __updateSvg() {
56
+ this._fetchId += 1;
57
+ const currentId = this._fetchId;
58
+ this.loading = true;
59
+ this.error = null;
60
+ try {
61
+ let raw;
62
+ if (this.name) {
63
+ raw = await fetchIcon(this.name, this.provider);
64
+ }
65
+ else if (this.src) {
66
+ raw = await fetchSVG(this.src);
67
+ }
68
+ else {
69
+ raw = '';
70
+ }
71
+ // If another fetch started after this one, ignore this result
72
+ if (currentId !== this._fetchId)
73
+ return;
74
+ if (raw) {
75
+ this.svgContent = sanitizeSvg(raw);
76
+ }
77
+ else {
78
+ this.svgContent = '';
79
+ }
80
+ }
81
+ catch (err) {
82
+ // capture and surface error, but avoid throwing
83
+ this.error = err instanceof Error ? err : new Error(String(err));
84
+ this.svgContent = '';
85
+ // bubble an event so consumers can react
86
+ this.dispatchEvent(new CustomEvent('icon-error', {
87
+ detail: { name: this.name, src: this.src, error: this.error },
88
+ bubbles: true,
89
+ composed: true,
90
+ }));
91
+ }
92
+ finally {
93
+ // ensure loading is cleared unless another fetch started
94
+ if (currentId === this._fetchId) {
95
+ this.loading = false;
96
+ }
97
+ }
98
+ }
99
+ }
100
+ Icon.styles = [styles];
101
+ __decorate([
102
+ property({ type: String, reflect: true })
103
+ ], Icon.prototype, "name", void 0);
104
+ __decorate([
105
+ property({ type: String, reflect: true })
106
+ ], Icon.prototype, "src", void 0);
107
+ __decorate([
108
+ property({ type: String })
109
+ ], Icon.prototype, "provider", void 0);
110
+ __decorate([
111
+ state()
112
+ ], Icon.prototype, "svgContent", void 0);
113
+ __decorate([
114
+ state()
115
+ ], Icon.prototype, "loading", void 0);
116
+ __decorate([
117
+ state()
118
+ ], Icon.prototype, "error", void 0);
119
+ //# sourceMappingURL=icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.js","sourceRoot":"","sources":["../../../src/icon/icon.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,OAAO,IAAK,SAAQ,UAAU;IAApC;;QAG6C,SAAI,GAAY,MAAM,CAAC;QAItC,aAAQ,GAClC,kBAAkB,CAAC;QAGb,eAAU,GAAW,EAAE,CAAC;QAEhC,6CAA6C;QAErC,YAAO,GAAY,KAAK,CAAC;QAGzB,UAAK,GAAiB,IAAI,CAAC;QAEnC,+DAA+D;QACvD,aAAQ,GAAG,CAAC,CAAC;IAkFvB,CAAC;IA7EC,YAAY;QACV,iEAAiE;QACjE,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,C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AE,MAAM,EAAE,CAAC;sCACN;AAGb;IADP,KAAK,EAAE;wCACwB;AAIxB;IADP,KAAK,EAAE;qCACyB;AAGzB;IADP,KAAK,EAAE;mCAC2B","sourcesContent":["import { html, LitElement } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js';\nimport { fetchIcon, fetchSVG } from './datasource.js';\nimport { sanitizeSvg } from '../utils.js';\nimport { styles } from './icon.css.js';\n\n/**\n * @summary Icons are visual symbols used to represent ideas, objects, or actions.\n *\n * @cssprop --icon-color - Controls the color of the icon.\n * @cssprop [--icon-size=1rem] - Controls the size of the icon. Defaults to \"1rem\"\n */\nexport class Icon extends LitElement {\n static styles = [styles];\n\n @property({ type: String, reflect: true }) name?: string = 'home';\n\n @property({ type: String, reflect: true }) src?: string;\n\n @property({ type: String }) provider?: 'material-symbols' | 'carbon' =\n 'material-symbols';\n\n @state()\n private svgContent: string = '';\n\n // loading + error states for consumers/tests\n @state()\n private loading: boolean = false;\n\n @state()\n private error: Error | null = null;\n\n // token to avoid race conditions when multiple fetches overlap\n private _fetchId = 0;\n\n // optional debounce for rapid property changes\n private _debounceTimer: number | undefined;\n\n firstUpdated() {\n // perform initial fetch once component is connected and rendered\n this.__scheduleUpdate();\n }\n\n updated(changedProperties: any) {\n // only refetch when name or src changed\n if (changedProperties.has('name') || changedProperties.has('src')) {\n this.__scheduleUpdate();\n }\n }\n\n render() {\n // accessible wrapper; consumers can provide a fallback via <slot name=\"fallback\">.\n return html` <div class=\"icon\">\n ${this.svgContent\n ? unsafeSVG(this.svgContent)\n : html`<slot name=\"fallback\"></slot>`}\n </div>`;\n }\n\n // small debounce to coalesce rapid changes (50ms)\n private __scheduleUpdate() {\n if (this._debounceTimer) {\n clearTimeout(this._debounceTimer as any);\n }\n // @ts-ignore - setTimeout in DOM returns number\n this._debounceTimer = window.setTimeout(() => this.__updateSvg(), 50);\n }\n\n /**\n * @internal\n */\n private async __updateSvg() {\n this._fetchId += 1;\n const currentId = this._fetchId;\n this.loading = true;\n this.error = null;\n\n try {\n let raw: string | undefined;\n\n if (this.name) {\n raw = await fetchIcon(this.name, this.provider);\n } else if (this.src) {\n raw = await fetchSVG(this.src);\n } else {\n raw = '';\n }\n\n // If another fetch started after this one, ignore this result\n if (currentId !== this._fetchId) return;\n\n if (raw) {\n this.svgContent = sanitizeSvg(raw);\n } else {\n this.svgContent = '';\n }\n } catch (err: any) {\n // capture and surface error, but avoid throwing\n this.error = err instanceof Error ? err : new Error(String(err));\n this.svgContent = '';\n // bubble an event so consumers can react\n this.dispatchEvent(\n new CustomEvent('icon-error', {\n detail: { name: this.name, src: this.src, error: this.error },\n bubbles: true,\n composed: true,\n }),\n );\n } finally {\n // ensure loading is cleared unless another fetch started\n if (currentId === this._fetchId) {\n this.loading = false;\n }\n }\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { Icon } from './icon.js';
2
+ export declare class IconComponent extends Icon {
3
+ }
@@ -0,0 +1,10 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement } from 'lit/decorators.js';
3
+ import { Icon } from './icon.js';
4
+ let IconComponent = class IconComponent extends Icon {
5
+ };
6
+ IconComponent = __decorate([
7
+ customElement('p-icon')
8
+ ], IconComponent);
9
+ export { IconComponent };
10
+ //# sourceMappingURL=p-icon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"p-icon.js","sourceRoot":"","sources":["../../../src/icon/p-icon.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1B,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,IAAI;CAAG,CAAA;AAA7B,aAAa;IADzB,aAAa,CAAC,QAAQ,CAAC;GACX,aAAa,CAAgB","sourcesContent":["import { customElement } from 'lit/decorators.js';\nimport { Icon } from './icon.js';\n\n@customElement('p-icon')\nexport class IconComponent extends Icon {}\n"]}
@@ -0,0 +1,2 @@
1
+ export { Icon } from './icon/icon.js';
2
+ export { Avatar } from './avatar/avatar.js';
@@ -0,0 +1,3 @@
1
+ export { Icon } from './icon/icon.js';
2
+ export { Avatar } from './avatar/avatar.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["export { Icon } from './icon/icon.js';\nexport { Avatar } from './avatar/avatar.js';\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ // Eager loaded
2
+ import { Icon } from './icon/icon.js';
3
+ import { LoaderUtils } from './LoaderUtils.js';
4
+ const loaderConfig = {
5
+ prefix: 'p',
6
+ components: {
7
+ icon: {
8
+ CustomElementClass: Icon,
9
+ },
10
+ avatar: {
11
+ importPath: './avatar/avatar.js',
12
+ },
13
+ },
14
+ };
15
+ new LoaderUtils(loaderConfig).start();
16
+ //# sourceMappingURL=peacock-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peacock-loader.js","sourceRoot":"","sources":["../../src/peacock-loader.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAgB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,YAAY,GAAiB;IACjC,MAAM,EAAE,GAAG;IACX,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,kBAAkB,EAAE,IAAI;SACzB;QACD,MAAM,EAAE;YACN,UAAU,EAAE,oBAAoB;SACjC;KACF;CACF,CAAC;AAEF,IAAI,WAAW,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,CAAC","sourcesContent":["// Eager loaded\nimport { Icon } from './icon/icon.js';\nimport { LoaderConfig, LoaderUtils } from './LoaderUtils.js';\n\nconst loaderConfig: LoaderConfig = {\n prefix: 'p',\n components: {\n icon: {\n CustomElementClass: Icon,\n },\n avatar: {\n importPath: './avatar/avatar.js',\n },\n },\n};\n\nnew LoaderUtils(loaderConfig).start();\n"]}
@@ -0,0 +1,3 @@
1
+ export declare function createCacheFetch(name: string): Promise<(url: string) => Promise<string>>;
2
+ export declare function sanitizeSvg(rawSvg: string): string;
3
+ export declare const getTypography: (name: string) => string;
@@ -0,0 +1,101 @@
1
+ export async function createCacheFetch(name) {
2
+ let cache = null;
3
+ // This map tracks requests currently being processed
4
+ const inFlightRequests = new Map();
5
+ try {
6
+ cache = await window.caches.open(name);
7
+ }
8
+ catch (e) {
9
+ console.warn('window.caches access not allowed');
10
+ }
11
+ return async (url) => {
12
+ // 1. Check if we are already fetching this URL
13
+ if (inFlightRequests.has(url)) {
14
+ // Return the existing promise instead of starting a new one
15
+ return inFlightRequests.get(url);
16
+ }
17
+ // 2. Create the main logic as a promise
18
+ const fetchPromise = (async () => {
19
+ const request = new Request(url);
20
+ // Check Cache first
21
+ if (cache) {
22
+ const cachedResponse = await cache.match(request);
23
+ if (cachedResponse) {
24
+ return await cachedResponse.text();
25
+ }
26
+ }
27
+ // Prepare network request
28
+ const urlObj = new URL(request.url);
29
+ const isSameOrigin = urlObj.origin === window.location.origin;
30
+ const response = await fetch(request.url, {
31
+ method: 'GET',
32
+ mode: isSameOrigin ? 'no-cors' : 'cors',
33
+ credentials: isSameOrigin ? 'same-origin' : 'omit',
34
+ });
35
+ // --- Handle 404 ---
36
+ if (response.status === 404) {
37
+ console.error(`[Fetch Error] Resource not found (404): ${url}`);
38
+ return ''; // Return empty string as requested
39
+ }
40
+ const result = await response.text();
41
+ // Update Cache if applicable
42
+ if (cache && response.status === 200) {
43
+ // We clone the response logic by creating a new Response with the text body
44
+ await cache.put(request, new Response(result, {
45
+ status: response.status,
46
+ statusText: response.statusText,
47
+ headers: response.headers,
48
+ }));
49
+ }
50
+ return result;
51
+ })();
52
+ // 3. Store the promise in the map
53
+ inFlightRequests.set(url, fetchPromise);
54
+ try {
55
+ // 4. Wait for the result
56
+ return await fetchPromise;
57
+ }
58
+ finally {
59
+ // 5. Clean up: Remove the promise from the map when done
60
+ // This ensures subsequent calls (after this one finishes) can start fresh
61
+ inFlightRequests.delete(url);
62
+ }
63
+ };
64
+ }
65
+ // Basic sanitization: remove <script>, <foreignObject>, event handler attributes (on*), and iframes
66
+ export function sanitizeSvg(rawSvg) {
67
+ try {
68
+ const parser = new DOMParser();
69
+ const doc = parser.parseFromString(rawSvg, 'image/svg+xml');
70
+ // remove script tags
71
+ const scripts = Array.from(doc.querySelectorAll('script'));
72
+ scripts.forEach(n => n.remove());
73
+ // remove foreignObject and iframe-like elements
74
+ const foreigns = Array.from(doc.querySelectorAll('foreignObject, iframe'));
75
+ foreigns.forEach(n => n.remove());
76
+ // remove event handler attributes like onload, onclick, etc.
77
+ const all = Array.from(doc.querySelectorAll('*'));
78
+ all.forEach(el => {
79
+ const attrs = Array.from(el.attributes).filter(a => /^on/i.test(a.name));
80
+ attrs.forEach(a => el.removeAttribute(a.name));
81
+ });
82
+ const el = doc.documentElement;
83
+ if (!el)
84
+ return '';
85
+ // serialize back to string
86
+ const serializer = new XMLSerializer();
87
+ return serializer.serializeToString(el);
88
+ }
89
+ catch (e) {
90
+ // parsing failed; fall back to empty content to avoid injecting unsafe content
91
+ return '';
92
+ }
93
+ }
94
+ export const getTypography = (name) => `
95
+ font-family: var(--typography-${name}-font-family) !important;
96
+ font-size: var(--typography-${name}-font-size) !important;
97
+ font-weight: var(--typography-${name}-font-weight) !important;
98
+ line-height: var(--typography-${name}-line-height) !important;
99
+ letter-spacing: var(--typography-${name}-letter-spacing) !important;
100
+ `;
101
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,g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;kCACb,IAAI;gCACN,IAAI;kCACF,IAAI;kCACJ,IAAI;qCACD,IAAI;CACxC,CAAC","sourcesContent":["export async function createCacheFetch(name: string) {\n let cache: Cache | null = null;\n // This map tracks requests currently being processed\n const inFlightRequests = new Map<string, Promise<string>>();\n\n try {\n cache = await window.caches.open(name);\n } catch (e) {\n console.warn('window.caches access not allowed');\n }\n\n return async (url: string): Promise<string> => {\n // 1. Check if we are already fetching this URL\n if (inFlightRequests.has(url)) {\n // Return the existing promise instead of starting a new one\n return inFlightRequests.get(url)!;\n }\n\n // 2. Create the main logic as a promise\n const fetchPromise = (async () => {\n const request = new Request(url);\n\n // Check Cache first\n if (cache) {\n const cachedResponse = await cache.match(request);\n if (cachedResponse) {\n return await cachedResponse.text();\n }\n }\n\n // Prepare network request\n const urlObj = new URL(request.url);\n const isSameOrigin = urlObj.origin === window.location.origin;\n\n const response = await fetch(request.url, {\n method: 'GET',\n mode: isSameOrigin ? 'no-cors' : 'cors',\n credentials: isSameOrigin ? 'same-origin' : 'omit',\n });\n\n // --- Handle 404 ---\n if (response.status === 404) {\n console.error(`[Fetch Error] Resource not found (404): ${url}`);\n return ''; // Return empty string as requested\n }\n\n const result = await response.text();\n\n // Update Cache if applicable\n if (cache && response.status === 200) {\n // We clone the response logic by creating a new Response with the text body\n await cache.put(\n request,\n new Response(result, {\n status: response.status,\n statusText: response.statusText,\n headers: response.headers,\n }),\n );\n }\n\n return result;\n })();\n\n // 3. Store the promise in the map\n inFlightRequests.set(url, fetchPromise);\n\n try {\n // 4. Wait for the result\n return await fetchPromise;\n } finally {\n // 5. Clean up: Remove the promise from the map when done\n // This ensures subsequent calls (after this one finishes) can start fresh\n inFlightRequests.delete(url);\n }\n };\n}\n\n// Basic sanitization: remove <script>, <foreignObject>, event handler attributes (on*), and iframes\nexport function sanitizeSvg(rawSvg: string) {\n try {\n const parser = new DOMParser();\n const doc = parser.parseFromString(rawSvg, 'image/svg+xml');\n\n // remove script tags\n const scripts = Array.from(doc.querySelectorAll('script'));\n scripts.forEach(n => n.remove());\n\n // remove foreignObject and iframe-like elements\n const foreigns = Array.from(doc.querySelectorAll('foreignObject, iframe'));\n foreigns.forEach(n => n.remove());\n\n // remove event handler attributes like onload, onclick, etc.\n const all = Array.from(doc.querySelectorAll('*'));\n all.forEach(el => {\n const attrs = Array.from(el.attributes).filter(a => /^on/i.test(a.name));\n attrs.forEach(a => el.removeAttribute(a.name));\n });\n\n const el = doc.documentElement;\n if (!el) return '';\n\n // serialize back to string\n const serializer = new XMLSerializer();\n return serializer.serializeToString(el);\n } catch (e) {\n // parsing failed; fall back to empty content to avoid injecting unsafe content\n return '';\n }\n}\n\nexport const getTypography = (name: string) => `\n font-family: var(--typography-${name}-font-family) !important;\n font-size: var(--typography-${name}-font-size) !important;\n font-weight: var(--typography-${name}-font-weight) !important;\n line-height: var(--typography-${name}-line-height) !important;\n letter-spacing: var(--typography-${name}-letter-spacing) !important;\n`;\n"]}
@@ -0,0 +1 @@
1
+ import '../src/p-icon.js';
@@ -0,0 +1,14 @@
1
+ import { html } from 'lit';
2
+ import { fixture, expect } from '@open-wc/testing';
3
+ import '../src/p-icon.js';
4
+ describe('Icon', () => {
5
+ it('has a default name as home', async () => {
6
+ const el = await fixture(html `<p-icon></p-icon>`);
7
+ expect(el.name).to.equal('home');
8
+ });
9
+ it('passes the a11y audit', async () => {
10
+ const el = await fixture(html `<p-icon></p-icon>`);
11
+ await expect(el).shadowDom.to.be.accessible();
12
+ });
13
+ });
14
+ //# sourceMappingURL=icon.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon.test.js","sourceRoot":"","sources":["../../test/icon.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,kBAAkB,CAAC;AAE1B,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAO,IAAI,CAAA,mBAAmB,CAAC,CAAC;QACxD,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAO,IAAI,CAAA,mBAAmB,CAAC,CAAC;QACxD,MAAM,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\nimport { fixture, expect } from '@open-wc/testing';\nimport { Icon } from '../src/index.js';\nimport '../src/p-icon.js';\n\ndescribe('Icon', () => {\n it('has a default name as home', async () => {\n const el = await fixture<Icon>(html`<p-icon></p-icon>`);\n expect(el.name).to.equal('home');\n });\n\n it('passes the a11y audit', async () => {\n const el = await fixture<Icon>(html`<p-icon></p-icon>`);\n await expect(el).shadowDom.to.be.accessible();\n });\n});\n"]}