@redvars/peacock 3.1.1 → 3.1.2

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 (132) hide show
  1. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.css.js.map +1 -1
  2. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.d.ts +19 -0
  3. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.js +19 -0
  4. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/avatar.js.map +1 -1
  5. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/p-avatar.d.ts +0 -7
  6. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/p-avatar.js +0 -7
  7. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/avatar/p-avatar.js.map +1 -1
  8. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.css.js +5 -4
  9. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.css.js.map +1 -1
  10. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.d.ts +15 -1
  11. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.js +27 -10
  12. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/badge.js.map +1 -1
  13. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/p-badge.d.ts +0 -5
  14. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/p-badge.js +0 -5
  15. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/badge/p-badge.js.map +1 -1
  16. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.css.d.ts +1 -0
  17. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.css.js +12 -0
  18. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.css.js.map +1 -0
  19. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.d.ts +27 -0
  20. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.js +58 -0
  21. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/clock.js.map +1 -0
  22. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/index.d.ts +1 -0
  23. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/index.js +2 -0
  24. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/clock/index.js.map +1 -0
  25. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.css.d.ts +1 -0
  26. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.css.js +58 -0
  27. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.css.js.map +1 -0
  28. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.d.ts +28 -0
  29. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.js +68 -0
  30. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/divider.js.map +1 -0
  31. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/index.d.ts +1 -0
  32. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/index.js +2 -0
  33. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/divider/index.js.map +1 -0
  34. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/icon.d.ts +21 -1
  35. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/icon.js +16 -0
  36. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/icon.js.map +1 -1
  37. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/p-icon.d.ts +0 -7
  38. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/p-icon.js +0 -7
  39. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/icon/p-icon.js.map +1 -1
  40. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/index.d.ts +2 -0
  41. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/index.js +2 -0
  42. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/index.js.map +1 -1
  43. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/peacock-loader.js +12 -2
  44. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/peacock-loader.js.map +1 -1
  45. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/utils.d.ts +1 -0
  46. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/utils.js +32 -0
  47. package/.rollup.cache/E/git/redvars/peacock/components/dist/src/utils.js.map +1 -1
  48. package/.rollup.cache/E/git/redvars/peacock/components/dist/tsconfig.tsbuildinfo +1 -1
  49. package/bin/typedoc-gen.mjs +64 -0
  50. package/custom-elements-manifest.config.mjs +5 -6
  51. package/demo/index.html +4 -5
  52. package/demo/int.html +2 -0
  53. package/dist/{component/avatar.js → avatar.js} +25 -19
  54. package/dist/avatar.js.map +1 -0
  55. package/dist/badge.js +89 -0
  56. package/dist/badge.js.map +1 -0
  57. package/dist/class-map-DpvLRi0h.js +11 -0
  58. package/dist/class-map-DpvLRi0h.js.map +1 -0
  59. package/dist/clock.js +70 -0
  60. package/dist/clock.js.map +1 -0
  61. package/dist/custom-elements-jsdocs.json +656 -0
  62. package/dist/directive-BKuZRRPO.js +9 -0
  63. package/dist/directive-BKuZRRPO.js.map +1 -0
  64. package/dist/divider.js +123 -0
  65. package/dist/divider.js.map +1 -0
  66. package/dist/{component/icon.js → icon.js} +20 -101
  67. package/dist/icon.js.map +1 -0
  68. package/dist/index.js +11 -67
  69. package/dist/index.js.map +1 -1
  70. package/dist/peacock-loader.js +21 -12
  71. package/dist/peacock-loader.js.map +1 -1
  72. package/dist/{directive-CKEA2P55.js → property-D4Kn9TsY.js} +6 -13
  73. package/dist/property-D4Kn9TsY.js.map +1 -0
  74. package/dist/src/avatar/avatar.d.ts +19 -0
  75. package/dist/src/avatar/p-avatar.d.ts +0 -7
  76. package/dist/src/badge/badge.d.ts +15 -1
  77. package/dist/src/badge/p-badge.d.ts +0 -5
  78. package/dist/src/clock/clock.css.d.ts +1 -0
  79. package/dist/src/clock/clock.d.ts +27 -0
  80. package/dist/src/clock/index.d.ts +1 -0
  81. package/dist/src/divider/divider.css.d.ts +1 -0
  82. package/dist/src/divider/divider.d.ts +28 -0
  83. package/dist/src/divider/index.d.ts +1 -0
  84. package/dist/src/icon/icon.d.ts +21 -1
  85. package/dist/src/icon/p-icon.d.ts +0 -7
  86. package/dist/src/index.d.ts +2 -0
  87. package/dist/src/utils.d.ts +1 -0
  88. package/dist/state-CxzmLNIi.js +10 -0
  89. package/dist/state-CxzmLNIi.js.map +1 -0
  90. package/dist/styleMixins.css-CivfMYtB.js +17 -0
  91. package/dist/styleMixins.css-CivfMYtB.js.map +1 -0
  92. package/dist/tsconfig.tsbuildinfo +1 -1
  93. package/dist/utils-_5no4mk7.js +128 -0
  94. package/dist/utils-_5no4mk7.js.map +1 -0
  95. package/package.json +8 -8
  96. package/readme.md +5 -17
  97. package/rollup.config.js +71 -37
  98. package/scratch.mjs +0 -0
  99. package/src/avatar/avatar.css.ts +1 -1
  100. package/src/avatar/avatar.ts +19 -0
  101. package/src/avatar/p-avatar.ts +0 -7
  102. package/src/badge/badge.css.ts +5 -4
  103. package/src/badge/badge.ts +30 -8
  104. package/src/badge/demo/index.html +9 -1
  105. package/src/badge/p-badge.ts +0 -5
  106. package/src/clock/clock.css.ts +12 -0
  107. package/src/clock/clock.ts +57 -0
  108. package/src/clock/demo/index.html +26 -0
  109. package/src/clock/index.ts +1 -0
  110. package/src/divider/demo/index.html +58 -0
  111. package/src/divider/divider.css.ts +58 -0
  112. package/src/divider/divider.ts +65 -0
  113. package/src/divider/index.ts +1 -0
  114. package/src/icon/icon.ts +21 -1
  115. package/src/icon/p-icon.ts +0 -7
  116. package/src/index.ts +2 -0
  117. package/src/peacock-loader.ts +12 -3
  118. package/src/utils.ts +43 -0
  119. package/assets/tokens.css +0 -522
  120. package/copyDesignFiles.js +0 -11
  121. package/custom-elements.md +0 -192
  122. package/dist/avatar-GQwWRGRw.js +0 -418
  123. package/dist/avatar-GQwWRGRw.js.map +0 -1
  124. package/dist/avatar-jfcIDB8G.js +0 -424
  125. package/dist/avatar-jfcIDB8G.js.map +0 -1
  126. package/dist/component/avatar.js.map +0 -1
  127. package/dist/component/icon.js.map +0 -1
  128. package/dist/directive-CKEA2P55.js.map +0 -1
  129. package/dist/utils-CSwoJIcG.js +0 -171
  130. package/dist/utils-CSwoJIcG.js.map +0 -1
  131. package/dist/web-types.json +0 -78
  132. package/readme-gen.mjs +0 -24
@@ -0,0 +1,128 @@
1
+ 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
+ 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
+ function __hasMeaningfulContent(slotElement) {
95
+ const nodes = slotElement.assignedNodes({ flatten: true });
96
+ for (const node of nodes) {
97
+ // If it's an element node, it has content
98
+ if (node.nodeType === Node.ELEMENT_NODE) {
99
+ return true;
100
+ }
101
+ // If it's a text node and contains non-whitespace characters, it has content
102
+ if (node.nodeType === Node.TEXT_NODE &&
103
+ node.textContent.trim().length > 0) {
104
+ return true;
105
+ }
106
+ }
107
+ // No meaningful content found
108
+ return false;
109
+ }
110
+ function observerSlotChangesWithCallback(slot, callback) {
111
+ const observer = new MutationObserver(() => {
112
+ callback(__hasMeaningfulContent(slot));
113
+ });
114
+ // Observe the elements currently assigned to the slot
115
+ const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];
116
+ assignedNodes.forEach(node => {
117
+ observer.observe(node, {
118
+ attributes: true,
119
+ childList: true,
120
+ characterData: true,
121
+ subtree: true,
122
+ });
123
+ });
124
+ callback(__hasMeaningfulContent(slot));
125
+ }
126
+
127
+ export { createCacheFetch as c, observerSlotChangesWithCallback as o, sanitizeSvg as s };
128
+ //# sourceMappingURL=utils-_5no4mk7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-_5no4mk7.js","sources":["../../src/utils.ts"],"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\nfunction __hasMeaningfulContent(slotElement: any) {\n const nodes = slotElement.assignedNodes({ flatten: true });\n\n for (const node of nodes) {\n // If it's an element node, it has content\n if (node.nodeType === Node.ELEMENT_NODE) {\n return true;\n }\n // If it's a text node and contains non-whitespace characters, it has content\n if (\n node.nodeType === Node.TEXT_NODE &&\n node.textContent.trim().length > 0\n ) {\n return true;\n }\n }\n\n // No meaningful content found\n return false;\n}\n\nexport function observerSlotChangesWithCallback(\n slot: HTMLSlotElement | null,\n callback: (hasContent: boolean) => void,\n) {\n const observer = new MutationObserver(() => {\n callback(__hasMeaningfulContent(slot));\n });\n\n // Observe the elements currently assigned to the slot\n const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];\n assignedNodes.forEach(node => {\n observer.observe(node, {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true,\n });\n });\n\n callback(__hasMeaningfulContent(slot));\n}\n"],"names":[],"mappings":"AAAO,eAAe,gBAAgB,CAAC,IAAY,EAAA;IACjD,IAAI,KAAK,GAAiB,IAAI;;AAE9B,IAAA,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA2B;AAE3D,IAAA,IAAI;QACF,KAAK,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;IACxC;IAAE,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC;IAClD;AAEA,IAAA,OAAO,OAAO,GAAW,KAAqB;;AAE5C,QAAA,IAAI,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;;AAE7B,YAAA,OAAO,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAE;QACnC;;AAGA,QAAA,MAAM,YAAY,GAAG,CAAC,YAAW;AAC/B,YAAA,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;;YAGhC,IAAI,KAAK,EAAE;gBACT,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;gBACjD,IAAI,cAAc,EAAE;AAClB,oBAAA,OAAO,MAAM,cAAc,CAAC,IAAI,EAAE;gBACpC;YACF;;YAGA,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;YACnC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,CAAC,MAAM;YAE7D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;AACxC,gBAAA,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM;gBACvC,WAAW,EAAE,YAAY,GAAG,aAAa,GAAG,MAAM;AACnD,aAAA,CAAC;;AA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,KAAK;AACd;AAEM,SAAU,+BAA+B,CAC7C,IAA4B,EAC5B,QAAuC,EAAA;AAEvC,IAAA,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAK;AACzC,QAAA,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;AACxC,IAAA,CAAC,CAAC;;AAGF,IAAA,MAAM,aAAa,GAAG,IAAI,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AAClE,IAAA,aAAa,CAAC,OAAO,CAAC,IAAI,IAAG;AAC3B,QAAA,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;AACrB,YAAA,UAAU,EAAE,IAAI;AAChB,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA,CAAC;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;AACxC;;;;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@redvars/peacock",
3
3
  "description": "The foundation for beautiful user interfaces",
4
4
  "license": "Apache-2.0",
5
- "version": "3.1.1",
5
+ "version": "3.1.2",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
@@ -16,23 +16,22 @@
16
16
  "./icon.js": "./dist/src/index.js"
17
17
  },
18
18
  "scripts": {
19
- "analyze": "cem analyze --config \"./custom-elements-manifest.config.mjs\" && node readme-gen.mjs",
20
- "start": "npm run copy_design_files && rollup -c && concurrently -k -r \"rollup -c -w\" \"web-dev-server\"",
21
- "build": "npm run copy_design_files && rollup -c && npm run analyze -- --exclude dist",
19
+ "analyze": "cem analyze --config \"./custom-elements-manifest.config.mjs\" && node bin/typedoc-gen.mjs",
20
+ "start": "rollup -c && concurrently -k -r \"rollup -c -w\" \"web-dev-server\"",
21
+ "build": "rollup -c && npm run analyze -- --exclude dist",
22
22
  "prepublish": "rollup -c && npm run analyze -- --exclude dist",
23
23
  "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
24
24
  "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
25
25
  "prepare": "husky",
26
- "copy_design_files": "node copyDesignFiles.js",
27
26
  "test": "tsc && wtr --coverage",
28
27
  "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
29
28
  },
30
29
  "dependencies": {
30
+ "@redvars/peacock-design-tokens": "^0.1.0",
31
31
  "lit": "^3.1.4"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@custom-elements-manifest/analyzer": "^0.10.3",
35
- "@custom-elements-manifest/to-markdown": "^0.1.0",
36
35
  "@open-wc/eslint-config": "^12.0.3",
37
36
  "@open-wc/testing": "^4.0.0",
38
37
  "@rollup/plugin-commonjs": "^29.0.0",
@@ -41,13 +40,13 @@
41
40
  "@types/mocha": "^10.0.7",
42
41
  "@typescript-eslint/eslint-plugin": "^7.16.0",
43
42
  "@typescript-eslint/parser": "^7.16.0",
44
- "@wc-toolkit/lazy-loader": "^1.0.1",
43
+ "@wc-toolkit/jsdoc-tags": "^1.1.0",
45
44
  "@web/dev-server": "^0.4.6",
46
45
  "@web/test-runner": "^0.18.2",
47
46
  "concurrently": "^8.2.2",
48
- "custom-element-jet-brains-integration": "^1.7.0",
49
47
  "eslint": "^8.57.0",
50
48
  "eslint-config-prettier": "^9.1.0",
49
+ "glob": "^13.0.0",
51
50
  "husky": "^9.0.11",
52
51
  "lint-staged": "^15.2.7",
53
52
  "prettier": "^3.3.2",
@@ -59,6 +58,7 @@
59
58
  "rollup-plugin-summary": "^3.0.1",
60
59
  "sass": "^1.97.2",
61
60
  "tslib": "^2.6.3",
61
+ "typedoc": "^0.28.16",
62
62
  "typescript": "^5.5.3",
63
63
  "unplugin-jsdelivr": "^1.0.0"
64
64
  },
package/readme.md CHANGED
@@ -37,30 +37,18 @@ Visit [https://peacock.redvars.com](https://goatui.com) to view the documentatio
37
37
 
38
38
 
39
39
  ```html
40
- <!doctype html>
41
- <html lang='en'>
42
40
  <head>
43
- <meta charset='utf-8' />
44
- <meta name='viewport' content='width=device-width' />
45
- <title>Goat UI Component</title>
46
-
47
- <link href="https://cdn.jsdelivr.net/npm/@redvars/components@3.1.0/dist/assets/styles/tokens.css" rel='stylesheet' />
48
-
49
- <script type='module'
50
- src='https://cdn.jsdelivr.net/npm/@redvars/components@3.1.0/dist/peacock-loader.js'></script>
51
-
52
- <!-- Default font : Noto Sans and Noto Sans Mono -->
41
+
42
+ <!-- Default font : Noto Sans and Noto Sans Mono -->
53
43
  <link rel="preconnect" href="https://fonts.googleapis.com">
54
44
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
55
45
  <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
56
46
 
57
-
47
+ <script type='module'
48
+ src='https://cdn.jsdelivr.net/npm/@redvars/peacock@3.1.1/dist/peacock-loader.js'></script>
58
49
  </head>
59
- <body>
60
- <p-avatar name="Shivaji Varma"></p-icon>
61
50
 
62
- </body>
63
- </html>
51
+ <p-avatar name="Shivaji Varma"></p-avatar>
64
52
  ```
65
53
 
66
54
  # Components
package/rollup.config.js CHANGED
@@ -2,42 +2,76 @@ import typescript from '@rollup/plugin-typescript';
2
2
  import { nodeResolve } from '@rollup/plugin-node-resolve';
3
3
  import css from 'rollup-plugin-import-css';
4
4
  import copy from 'rollup-plugin-copy';
5
+ import { readFile } from 'node:fs/promises';
6
+ import { glob } from 'glob';
5
7
 
6
- export default [
7
- {
8
- input: ['src/index.ts', 'src/peacock-loader.ts'], // Your main TypeScript entry file
9
- output: {
10
- dir: 'dist',
11
- format: 'esm', // Output as ES Modules (esm), also supports cjs, umd, etc.
12
- sourcemap: true,
8
+ export default async function () {
9
+ const files = await findLitComponents();
10
+ return [
11
+ {
12
+ input: ['src/index.ts', 'src/peacock-loader.ts', ...files], // Your main TypeScript entry file
13
+ output: {
14
+ dir: 'dist',
15
+ format: 'esm', // Output as ES Modules (esm), also supports cjs, umd, etc.
16
+ sourcemap: true,
17
+ },
18
+ plugins: [
19
+ typescript(), // The plugin loads options from tsconfig.json by default
20
+ css(),
21
+ nodeResolve(),
22
+ copy({
23
+ targets: [
24
+ {
25
+ src: '../readme.md',
26
+ dest: './',
27
+ },
28
+ {
29
+ src: './node_modules/@redvars/peacock-design-tokens/dist/tokens.css',
30
+ dest: './dist/assets/styles/',
31
+ },
32
+ ],
33
+ }),
34
+ ],
13
35
  },
14
- plugins: [
15
- typescript(), // The plugin loads options from tsconfig.json by default
16
- css(),
17
- nodeResolve(),
18
- ],
19
- },
20
- {
21
- input: ['src/icon/icon.ts', 'src/avatar/avatar.ts'], // Your main TypeScript entry file
22
- output: {
23
- dir: `dist`,
24
- format: 'esm', // Output as ES Modules (esm), also supports cjs, umd, etc.
25
- sourcemap: true,
26
- entryFileNames: 'component/[name].js',
27
- },
28
- plugins: [
29
- typescript(), // The plugin loads options from tsconfig.json by default
30
- css(),
31
- nodeResolve(),
32
-
33
- copy({
34
- targets: [
35
- {
36
- src: '../readme.md',
37
- dest: './',
38
- },
39
- ],
40
- }),
41
- ],
42
- },
43
- ];
36
+ ];
37
+ }
38
+
39
+ async function findLitComponents(searchDir = 'src') {
40
+ console.log(`🚀 Scanning for Lit components in "${searchDir}"...\n`);
41
+ /**
42
+ * We look for:
43
+ * 1. Lit imports
44
+ * 2. Class extensions
45
+ * 3. Custom element decorators
46
+ */
47
+ const LIT_SIGNATURES = [/extends\s+LitElement/];
48
+
49
+ try {
50
+ // glob() returns a Promise that resolves to an array of file paths
51
+ // We ignore node_modules and typical build folders
52
+ const files = await glob(`${searchDir}/**/*.{js,ts,mjs}`, {
53
+ ignore: ['**/node_modules/**', '**/dist/**', '**/build/**'],
54
+ });
55
+
56
+ const results = [];
57
+
58
+ for (const file of files) {
59
+ const content = await readFile(file, 'utf8');
60
+
61
+ // Check if any Lit-specific pattern exists in the file
62
+ const isLit = LIT_SIGNATURES.some(pattern => pattern.test(content));
63
+
64
+ if (isLit) {
65
+ results.push(file);
66
+ console.log(`✅ Found: ${file}`);
67
+ }
68
+ }
69
+
70
+ console.log(
71
+ `\n✨ Search complete. Total Lit components: ${results.length}`,
72
+ );
73
+ return results;
74
+ } catch (error) {
75
+ console.error('❌ Error during scan:', error);
76
+ }
77
+ }
package/scratch.mjs ADDED
File without changes
@@ -1,4 +1,4 @@
1
- import { css, unsafeCSS } from 'lit';
1
+ import { css } from 'lit';
2
2
  import { getTypography } from '../styleMixins.css.js';
3
3
 
4
4
  export const styles = css`
@@ -3,6 +3,25 @@ import { property } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { styles } from './avatar.css.js';
5
5
 
6
+ /**
7
+ * @label Avatar
8
+ * @tag p-avatar
9
+ * @rawTag avatar
10
+ * @summary The Avatar component is used to represent user, and displays the profile picture, initials or fallback icon.
11
+ *
12
+ * @cssprop --avatar-border-radius - Controls the border radius of the avatar.
13
+ * @cssprop --avatar-background-color - Controls the color of the avatar.
14
+ * @cssprop --avatar-size - Controls the size of the avatar.
15
+ * @cssprop --avatar-text-color - Controls the color of the text inside the avatar.
16
+ *
17
+ *
18
+ * @example
19
+ * ```html
20
+ * <p-avatar name="Shivaji Varma" src="https://peacock.redvars.com/assets/img/avatar.webp"></p-avatar>
21
+ * ```
22
+ *
23
+ * @tags display
24
+ */
6
25
  export class Avatar extends LitElement {
7
26
  static styles = [styles];
8
27
 
@@ -1,12 +1,5 @@
1
1
  import { customElement } from 'lit/decorators.js';
2
2
  import { Avatar } from './avatar.js';
3
3
 
4
- /**
5
- * @summary The Avatar component is used to represent user, and displays the profile picture, initials or fallback icon.
6
- *
7
- * @cssprop --avatar-background-color - Controls the color of the avatar.
8
- * @cssprop --avatar-size - Controls the size of the avatar.
9
- * @cssprop --avatar-text-color - Controls the color of the text inside the avatar.
10
- */
11
4
  @customElement('p-avatar')
12
5
  export class PAvatar extends Avatar {}
@@ -16,8 +16,9 @@ export const styles = css`
16
16
  align-items: center;
17
17
  background-color: var(--badge-color);
18
18
  border-radius: var(--shape-corner-full);
19
+ box-sizing: border-box;
19
20
 
20
- &.has-content {
21
+ &.slot-has-content {
21
22
  height: 1rem;
22
23
  min-width: 1rem;
23
24
  padding-inline: var(--spacing-050);
@@ -25,9 +26,9 @@ export const styles = css`
25
26
  color: var(--color-on-error);
26
27
  }
27
28
 
28
- &:not(.has-content) {
29
- height: 6px;
30
- width: 6px;
29
+ &:not(.slot-has-content) {
30
+ height: 0.375rem;
31
+ width: 0.375rem;
31
32
  }
32
33
  }
33
34
  `;
@@ -2,7 +2,22 @@ import { html, LitElement } from 'lit';
2
2
  import { property, state } from 'lit/decorators.js';
3
3
  import { classMap } from 'lit/directives/class-map.js';
4
4
  import { styles } from './badge.css.js';
5
+ import { observerSlotChangesWithCallback } from '../utils.js';
5
6
 
7
+ /**
8
+ * @label Badge
9
+ * @tag p-badge
10
+ * @rawTag badge
11
+ * @summary The badge component is used to display a small amount of information to the user.
12
+ *
13
+ * @cssprop --badge-color - Controls the color of the badge.
14
+ *
15
+ * @example
16
+ * ```html
17
+ * <p-badge>1</p-badge>
18
+ * ```
19
+ * @tags display
20
+ */
6
21
  export class Badge extends LitElement {
7
22
  static styles = [styles];
8
23
 
@@ -13,17 +28,24 @@ export class Badge extends LitElement {
13
28
  @state()
14
29
  slotHasContent = false;
15
30
 
31
+ firstUpdated() {
32
+ observerSlotChangesWithCallback(
33
+ this.renderRoot.querySelector('slot'),
34
+ hasContent => {
35
+ this.slotHasContent = hasContent;
36
+ this.requestUpdate();
37
+ },
38
+ );
39
+ }
40
+
16
41
  render() {
17
42
  return html`<div
18
- class=${classMap({ badge: true, 'has-content': this.slotHasContent })}
43
+ class=${classMap({
44
+ badge: true,
45
+ 'slot-has-content': this.slotHasContent,
46
+ })}
19
47
  >
20
- <slot @slotchange=${this.#handleSlotChange}></slot>
48
+ <slot></slot>
21
49
  </div>`;
22
50
  }
23
-
24
- #handleSlotChange(event: { target: any }) {
25
- const slot = event.target;
26
- // Check assignedElements length
27
- this.slotHasContent = slot.assignedElements().length > 0;
28
- }
29
51
  }
@@ -43,7 +43,15 @@
43
43
  </div>
44
44
 
45
45
 
46
- <p-avatar name='Shivaji Varma'></p-avatar>
46
+ <div class="badge-wrapper">
47
+ <p-icon name="notifications"></p-icon>
48
+ <p-badge class="badge-anchor">1</p-badge>
49
+ </div>
50
+
51
+ <div class="badge-wrapper">
52
+ <p-icon name="notifications"></p-icon>
53
+ <p-badge class="badge-anchor">999+</p-badge>
54
+ </div>
47
55
 
48
56
  <script type='module'>
49
57
  import { Icon, Badge } from '/dist/index.js';
@@ -1,10 +1,5 @@
1
1
  import { customElement } from 'lit/decorators.js';
2
2
  import { Badge } from './badge.js';
3
3
 
4
- /**
5
- * @summary The badge component is used to display a small amount of information to the user.
6
- *
7
- * @cssprop --badge-color - Controls the color of the badge.
8
- */
9
4
  @customElement('p-badge')
10
5
  export class PBadge extends Badge {}
@@ -0,0 +1,12 @@
1
+ import { css } from 'lit';
2
+ import { getTypography } from '../styleMixins.css.js';
3
+
4
+ export const styles = css`
5
+ :host {
6
+ display: inline-block;
7
+ }
8
+
9
+ .current-time {
10
+ ${getTypography('body-medium')}
11
+ }
12
+ `;
@@ -0,0 +1,57 @@
1
+ import { html, LitElement } from 'lit';
2
+ import { property, state } from 'lit/decorators.js';
3
+ import { styles } from './clock.css.js';
4
+
5
+ /**
6
+ * @label Clock
7
+ * @tag p-clock
8
+ * @rawTag clock
9
+ *
10
+ * @summary Displays the current time in a given timezone.
11
+ * @overview
12
+ * - Clocks are used to display the current time in a specified timezone.
13
+ * - They can be displayed in various formats, including 12-hour and 24-hour time.
14
+ *
15
+ * @example
16
+ * ```html
17
+ * <p-clock></p-clock>
18
+ * ```
19
+ * @tags display
20
+ */
21
+ export class Clock extends LitElement {
22
+ static styles = [styles];
23
+
24
+ @property() timezone?: string;
25
+
26
+ // `currentTime` is decorated with `@State()`,
27
+ // as we need to trigger a rerender when its
28
+ // value changes to show the latest time
29
+ @state() currentTime: string = '';
30
+
31
+ private _timerId: any;
32
+
33
+ connectedCallback() {
34
+ super.connectedCallback();
35
+ this.__updateCurrentTime();
36
+ this._timerId = setInterval(() => {
37
+ this.__updateCurrentTime();
38
+ }, 1000);
39
+ }
40
+
41
+ disconnectedCallback() {
42
+ if (this._timerId) {
43
+ clearInterval(this._timerId);
44
+ }
45
+ super.disconnectedCallback();
46
+ }
47
+
48
+ __updateCurrentTime() {
49
+ this.currentTime = new Date().toLocaleTimeString('en-US', {
50
+ timeZone: this.timezone,
51
+ });
52
+ }
53
+
54
+ render() {
55
+ return html`<div class="current-time">${this.currentTime}</div>`;
56
+ }
57
+ }
@@ -0,0 +1,26 @@
1
+ <!doctype html>
2
+ <html lang='en-GB'>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <meta name='viewport' content='width=device-width, initial-scale=1.0, viewport-fit=cover' />
6
+ <link rel='stylesheet' href='/dist/assets/styles/tokens.css' />
7
+ <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
8
+
9
+ <style>
10
+ body {
11
+ background: #fafafa;
12
+ }
13
+ </style>
14
+ </head>
15
+ <body>
16
+
17
+
18
+ <p-clock></p-clock>
19
+
20
+ <script type='module'>
21
+ import { Clock } from '/dist/index.js';
22
+
23
+ window.customElements.define('p-clock', Clock);
24
+ </script>
25
+ </body>
26
+ </html>
@@ -0,0 +1 @@
1
+ export { Clock } from './clock.js';