@redvars/peacock 3.4.0 → 3.5.1

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 (258) hide show
  1. package/dist/BaseButton-DuASuVth.js +219 -0
  2. package/dist/BaseButton-DuASuVth.js.map +1 -0
  3. package/dist/BaseHyperlinkMixin-BNuwbiEf.js +65 -0
  4. package/dist/BaseHyperlinkMixin-BNuwbiEf.js.map +1 -0
  5. package/dist/assets/components.css +1 -1
  6. package/dist/assets/components.css.map +1 -1
  7. package/dist/assets/styles.css +1 -1
  8. package/dist/assets/styles.css.map +1 -1
  9. package/dist/banner.js +187 -0
  10. package/dist/banner.js.map +1 -0
  11. package/dist/bottom-sheet.js +2 -2
  12. package/dist/{button-COYCtuA8.js → button-DouvOfEU.js} +92 -283
  13. package/dist/button-DouvOfEU.js.map +1 -0
  14. package/dist/{button-group-DsXquZQn.js → button-group-CEdMwvJJ.js} +72 -48
  15. package/dist/button-group-CEdMwvJJ.js.map +1 -0
  16. package/dist/button-group.js +8 -5
  17. package/dist/button-group.js.map +1 -1
  18. package/dist/button.js +7 -4
  19. package/dist/button.js.map +1 -1
  20. package/dist/card.js +29 -74
  21. package/dist/card.js.map +1 -1
  22. package/dist/chart-bar.js +2 -2
  23. package/dist/chart-bar.js.map +1 -1
  24. package/dist/chart-doughnut.js +2 -2
  25. package/dist/chart-doughnut.js.map +1 -1
  26. package/dist/chart-pie.js +2 -2
  27. package/dist/chart-pie.js.map +1 -1
  28. package/dist/chart-stacked-bar.js +2 -2
  29. package/dist/chart-stacked-bar.js.map +1 -1
  30. package/dist/{class-map-3TAnCMAX.js → class-map-YU7g0o3B.js} +2 -2
  31. package/dist/{class-map-3TAnCMAX.js.map → class-map-YU7g0o3B.js.map} +1 -1
  32. package/dist/clock.js.map +1 -1
  33. package/dist/code-editor.js +4 -4
  34. package/dist/code-editor.js.map +1 -1
  35. package/dist/code-highlighter.js +5 -4
  36. package/dist/code-highlighter.js.map +1 -1
  37. package/dist/custom-elements-jsdocs.json +6627 -3477
  38. package/dist/custom-elements.json +10954 -7810
  39. package/dist/directive-ZPhl09Yt.js +9 -0
  40. package/dist/directive-ZPhl09Yt.js.map +1 -0
  41. package/dist/dispatch-event-utils-CuEqjlPT.js +127 -0
  42. package/dist/dispatch-event-utils-CuEqjlPT.js.map +1 -0
  43. package/dist/fab.js +423 -0
  44. package/dist/fab.js.map +1 -0
  45. package/dist/index.js +17 -9
  46. package/dist/index.js.map +1 -1
  47. package/dist/{observe-theme-change-DKAIv5BB.js → is-dark-mode-DicqGkCJ.js} +6 -2
  48. package/dist/is-dark-mode-DicqGkCJ.js.map +1 -0
  49. package/dist/{select-C3XAzenC.js → navigation-rail-Lxetd5-Z.js} +2426 -898
  50. package/dist/navigation-rail-Lxetd5-Z.js.map +1 -0
  51. package/dist/notification.js +418 -0
  52. package/dist/notification.js.map +1 -0
  53. package/dist/number-counter.js +2 -2
  54. package/dist/number-counter.js.map +1 -1
  55. package/dist/observe-slot-change-BGJfgg2E.js +31 -0
  56. package/dist/observe-slot-change-BGJfgg2E.js.map +1 -0
  57. package/dist/peacock-loader.js +48 -13
  58. package/dist/peacock-loader.js.map +1 -1
  59. package/dist/search.js +456 -0
  60. package/dist/search.js.map +1 -0
  61. package/dist/side-sheet.js +2 -2
  62. package/dist/src/__mixins/BaseButtonMixin.d.ts +20 -0
  63. package/dist/src/__mixins/BaseHyperlinkMixin.d.ts +18 -0
  64. package/dist/src/__mixins/MixinConstructor.d.ts +1 -0
  65. package/dist/src/__utils/cache-fetch.d.ts +1 -0
  66. package/dist/src/__utils/is-dark-mode.d.ts +1 -0
  67. package/dist/src/__utils/is-in-viewport.d.ts +1 -0
  68. package/dist/src/__utils/observe-slot-change.d.ts +1 -0
  69. package/dist/src/__utils/sanitize-svg.d.ts +1 -0
  70. package/dist/src/__utils/throttle.d.ts +4 -0
  71. package/dist/src/accordion/accordion-item.d.ts +33 -9
  72. package/dist/src/accordion/accordion.d.ts +21 -5
  73. package/dist/src/banner/banner.d.ts +43 -0
  74. package/dist/src/banner/index.d.ts +1 -0
  75. package/dist/src/button/BaseButton.d.ts +7 -57
  76. package/dist/src/button/button/button.d.ts +32 -3
  77. package/dist/src/button/button-group/button-group.d.ts +4 -4
  78. package/dist/src/button/icon-button/icon-button.d.ts +33 -8
  79. package/dist/src/card/card.d.ts +4 -15
  80. package/dist/src/empty-state/empty-state.d.ts +1 -1
  81. package/dist/src/fab/fab.d.ts +80 -0
  82. package/dist/src/fab/index.d.ts +1 -0
  83. package/dist/src/focus-ring/focus-ring.d.ts +11 -5
  84. package/dist/src/index.d.ts +8 -1
  85. package/dist/src/link/link.d.ts +3 -10
  86. package/dist/src/menu/menu/menu.d.ts +3 -2
  87. package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -0
  88. package/dist/src/navigation-rail/index.d.ts +2 -0
  89. package/dist/src/navigation-rail/navigation-rail-item.d.ts +55 -0
  90. package/dist/src/navigation-rail/navigation-rail.d.ts +71 -0
  91. package/dist/src/notification/index.d.ts +1 -0
  92. package/dist/src/notification/notification.d.ts +69 -0
  93. package/dist/src/pagination/pagination.d.ts +8 -1
  94. package/dist/src/search/index.d.ts +1 -0
  95. package/dist/src/search/search.d.ts +76 -0
  96. package/dist/src/select/select.d.ts +3 -5
  97. package/dist/src/sidebar-menu/index.d.ts +3 -0
  98. package/dist/src/sidebar-menu/sidebar-menu-item.d.ts +58 -0
  99. package/dist/src/sidebar-menu/sidebar-menu.d.ts +38 -0
  100. package/dist/src/sidebar-menu/sidebar-sub-menu.d.ts +35 -0
  101. package/dist/src/slider/slider.d.ts +4 -0
  102. package/dist/src/snackbar/snackbar.d.ts +14 -1
  103. package/dist/src/toolbar/index.d.ts +1 -0
  104. package/dist/src/toolbar/toolbar.d.ts +86 -0
  105. package/dist/src/tooltip/tooltip.d.ts +3 -0
  106. package/dist/src/url-field/index.d.ts +1 -0
  107. package/dist/src/url-field/url-field.d.ts +48 -0
  108. package/dist/{style-map-CRFEoCEg.js → style-map-DVmWOuYy.js} +2 -2
  109. package/dist/{style-map-CRFEoCEg.js.map → style-map-DVmWOuYy.js.map} +1 -1
  110. package/dist/test/banner.test.d.ts +1 -0
  111. package/dist/test/search.test.d.ts +1 -0
  112. package/dist/test/sidebar-menu.test.d.ts +1 -0
  113. package/dist/test/toolbar.test.d.ts +1 -0
  114. package/dist/toolbar.js +306 -0
  115. package/dist/toolbar.js.map +1 -0
  116. package/dist/tsconfig.tsbuildinfo +1 -1
  117. package/dist/{unsafe-html-D3GHRaGQ.js → unsafe-html-BsGUjx94.js} +2 -2
  118. package/dist/{unsafe-html-D3GHRaGQ.js.map → unsafe-html-BsGUjx94.js.map} +1 -1
  119. package/package.json +1 -1
  120. package/readme.md +73 -65
  121. package/scss/mixin.scss +16 -0
  122. package/scss/styles.scss +4 -0
  123. package/src/__mixins/BaseButtonMixin.ts +83 -0
  124. package/src/__mixins/BaseHyperlinkMixin.ts +68 -0
  125. package/src/__mixins/MixinConstructor.ts +1 -0
  126. package/src/__mixins/README.md +19 -0
  127. package/src/__utils/cache-fetch.ts +65 -0
  128. package/src/__utils/is-dark-mode.ts +3 -0
  129. package/src/__utils/is-in-viewport.ts +6 -0
  130. package/src/__utils/observe-slot-change.ts +38 -0
  131. package/src/__utils/sanitize-svg.ts +27 -0
  132. package/src/__utils/throttle.ts +27 -0
  133. package/src/accordion/accordion-item.scss +136 -65
  134. package/src/accordion/accordion-item.ts +117 -44
  135. package/src/accordion/accordion.scss +24 -5
  136. package/src/accordion/accordion.ts +29 -23
  137. package/src/accordion/demo/index.html +74 -35
  138. package/src/banner/banner.scss +83 -0
  139. package/src/banner/banner.ts +101 -0
  140. package/src/banner/index.ts +1 -0
  141. package/src/button/BaseButton.ts +13 -115
  142. package/src/button/button/button-colors.scss +14 -14
  143. package/src/button/button/button-sizes.scss +4 -2
  144. package/src/button/button/button.ts +80 -26
  145. package/src/button/button-group/button-group.ts +5 -5
  146. package/src/button/icon-button/icon-button.ts +79 -44
  147. package/src/card/card.ts +50 -100
  148. package/src/chart-bar/chart-bar.ts +10 -15
  149. package/src/chart-bar/chart-stacked-bar.ts +15 -19
  150. package/src/chart-doughnut/chart-doughnut.ts +24 -28
  151. package/src/chart-pie/chart-pie.ts +20 -24
  152. package/src/checkbox/checkbox.scss +17 -34
  153. package/src/checkbox/checkbox.ts +4 -2
  154. package/src/clock/clock.ts +1 -1
  155. package/src/code-editor/code-editor.ts +4 -4
  156. package/src/code-highlighter/code-highlighter.scss +1 -0
  157. package/src/code-highlighter/code-highlighter.ts +3 -3
  158. package/src/date-picker/date-picker.ts +6 -3
  159. package/src/divider/divider.ts +3 -1
  160. package/src/elevation/elevation.scss +5 -5
  161. package/src/empty-state/empty-state.scss +7 -9
  162. package/src/empty-state/empty-state.ts +1 -1
  163. package/src/fab/fab-colors.scss +49 -0
  164. package/src/fab/fab-sizes.scss +47 -0
  165. package/src/fab/fab.scss +137 -0
  166. package/src/fab/fab.ts +214 -0
  167. package/src/fab/index.ts +1 -0
  168. package/src/field/field.ts +3 -1
  169. package/src/focus-ring/focus-ring.ts +47 -40
  170. package/src/icon/datasource.ts +1 -1
  171. package/src/icon/icon.ts +3 -1
  172. package/src/image/image.ts +3 -2
  173. package/src/index.ts +8 -1
  174. package/src/input/input.ts +8 -3
  175. package/src/link/link.ts +2 -15
  176. package/src/menu/menu/menu.scss +7 -0
  177. package/src/menu/menu/menu.ts +7 -4
  178. package/src/menu/menu-item/menu-item.ts +3 -1
  179. package/src/menu/sub-menu/sub-menu.ts +1 -0
  180. package/src/navigation-rail/index.ts +2 -0
  181. package/src/navigation-rail/navigation-rail-item.scss +216 -0
  182. package/src/navigation-rail/navigation-rail-item.ts +223 -0
  183. package/src/navigation-rail/navigation-rail.scss +72 -0
  184. package/src/navigation-rail/navigation-rail.ts +149 -0
  185. package/src/notification/index.ts +1 -0
  186. package/src/notification/notification.scss +201 -0
  187. package/src/notification/notification.ts +207 -0
  188. package/src/number-counter/number-counter.ts +3 -1
  189. package/src/number-field/number-field.ts +10 -6
  190. package/src/pagination/pagination.scss +33 -24
  191. package/src/pagination/pagination.ts +115 -60
  192. package/src/peacock-loader.ts +42 -5
  193. package/src/radio/radio.ts +3 -1
  194. package/src/search/index.ts +1 -0
  195. package/src/search/search-colors.scss +14 -0
  196. package/src/search/search.scss +204 -0
  197. package/src/search/search.ts +244 -0
  198. package/src/select/option.ts +1 -1
  199. package/src/select/select.scss +5 -0
  200. package/src/select/select.ts +71 -37
  201. package/src/sidebar-menu/demo/index.html +68 -0
  202. package/src/sidebar-menu/index.ts +3 -0
  203. package/src/sidebar-menu/sidebar-menu-item.scss +102 -0
  204. package/src/sidebar-menu/sidebar-menu-item.ts +151 -0
  205. package/src/{tree-view/tree-view.scss → sidebar-menu/sidebar-menu.scss} +1 -1
  206. package/src/sidebar-menu/sidebar-menu.ts +182 -0
  207. package/src/sidebar-menu/sidebar-sub-menu.scss +130 -0
  208. package/src/sidebar-menu/sidebar-sub-menu.ts +160 -0
  209. package/src/skeleton/skeleton.scss +18 -24
  210. package/src/slider/slider.scss +19 -0
  211. package/src/slider/slider.ts +30 -19
  212. package/src/snackbar/snackbar.scss +62 -31
  213. package/src/snackbar/snackbar.ts +91 -11
  214. package/src/switch/switch.ts +3 -1
  215. package/src/table/table.ts +3 -1
  216. package/src/tabs/tab.ts +10 -6
  217. package/src/text/text.css-component.scss +7 -1
  218. package/src/textarea/textarea.ts +4 -2
  219. package/src/time-picker/time-picker.ts +5 -3
  220. package/src/toolbar/index.ts +1 -0
  221. package/src/toolbar/toolbar-colors.scss +16 -0
  222. package/src/toolbar/toolbar.scss +165 -0
  223. package/src/toolbar/toolbar.ts +137 -0
  224. package/src/tooltip/tooltip.ts +24 -0
  225. package/src/url-field/index.ts +1 -0
  226. package/src/url-field/url-field.scss +50 -0
  227. package/src/url-field/url-field.ts +239 -0
  228. package/dist/button-COYCtuA8.js.map +0 -1
  229. package/dist/button-group-DsXquZQn.js.map +0 -1
  230. package/dist/directive-Cuw6h7YA.js +0 -9
  231. package/dist/directive-Cuw6h7YA.js.map +0 -1
  232. package/dist/dispatch-event-utils-B4odODQf.js +0 -277
  233. package/dist/dispatch-event-utils-B4odODQf.js.map +0 -1
  234. package/dist/observe-theme-change-DKAIv5BB.js.map +0 -1
  235. package/dist/select-C3XAzenC.js.map +0 -1
  236. package/dist/src/styleMixins.css.d.ts +0 -9
  237. package/dist/src/tree-view/index.d.ts +0 -2
  238. package/dist/src/tree-view/tree-node.d.ts +0 -69
  239. package/dist/src/tree-view/tree-view.d.ts +0 -40
  240. package/dist/src/tree-view/wc-tree-view.d.ts +0 -6
  241. package/dist/src/utils.d.ts +0 -9
  242. package/dist/test/tree-view.test.d.ts +0 -1
  243. package/src/styleMixins.css.ts +0 -55
  244. package/src/tree-view/demo/index.html +0 -57
  245. package/src/tree-view/index.ts +0 -2
  246. package/src/tree-view/tree-node.scss +0 -101
  247. package/src/tree-view/tree-node.ts +0 -268
  248. package/src/tree-view/tree-view.ts +0 -182
  249. package/src/tree-view/wc-tree-view.ts +0 -9
  250. package/src/utils.ts +0 -193
  251. /package/dist/src/{spread.d.ts → __directive/spread.d.ts} +0 -0
  252. /package/dist/src/{utils → __utils}/copy-to-clipboard.d.ts +0 -0
  253. /package/dist/src/{utils → __utils}/dispatch-event-utils.d.ts +0 -0
  254. /package/dist/src/{utils → __utils}/observe-theme-change.d.ts +0 -0
  255. /package/src/{spread.ts → __directive/spread.ts} +0 -0
  256. /package/src/{utils → __utils}/copy-to-clipboard.ts +0 -0
  257. /package/src/{utils → __utils}/dispatch-event-utils.ts +0 -0
  258. /package/src/{utils → __utils}/observe-theme-change.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import { A, E } from './IndividualComponent-DUINtMGK.js';
2
- import { e as e$1, i, t } from './directive-Cuw6h7YA.js';
2
+ import { e as e$1, i, t } from './directive-ZPhl09Yt.js';
3
3
 
4
4
  /**
5
5
  * @license
@@ -8,4 +8,4 @@ import { e as e$1, i, t } from './directive-Cuw6h7YA.js';
8
8
  */class e extends i{constructor(i){if(super(i),this.it=A,i.type!==t.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===A||null==r)return this._t=void 0,this.it=r;if(r===E)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName="unsafeHTML",e.resultType=1;const o=e$1(e);
9
9
 
10
10
  export { e, o };
11
- //# sourceMappingURL=unsafe-html-D3GHRaGQ.js.map
11
+ //# sourceMappingURL=unsafe-html-BsGUjx94.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unsafe-html-D3GHRaGQ.js","sources":["../node_modules/lit-html/directives/unsafe-html.js"],"sourcesContent":["import{nothing as t,noChange as i}from\"../lit-html.js\";import{directive as r,Directive as s,PartType as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class e extends s{constructor(i){if(super(i),this.it=t,i.type!==n.CHILD)throw Error(this.constructor.directiveName+\"() can only be used in child bindings\")}render(r){if(r===t||null==r)return this._t=void 0,this.it=r;if(r===i)return r;if(\"string\"!=typeof r)throw Error(this.constructor.directiveName+\"() called with a non-string value\");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName=\"unsafeHTML\",e.resultType=1;const o=r(e);export{e as UnsafeHTMLDirective,o as unsafeHTML};\n//# sourceMappingURL=unsafe-html.js.map\n"],"names":["s","t","n","i","r"],"mappings":";;;AACA;AACA;AACA;AACA;AACA,GAAG,MAAM,CAAC,SAASA,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAACC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAGC,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,uCAAuC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGD,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,mCAAmC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAM,MAAC,CAAC,CAACC,GAAC,CAAC,CAAC;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"unsafe-html-BsGUjx94.js","sources":["../node_modules/lit-html/directives/unsafe-html.js"],"sourcesContent":["import{nothing as t,noChange as i}from\"../lit-html.js\";import{directive as r,Directive as s,PartType as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class e extends s{constructor(i){if(super(i),this.it=t,i.type!==n.CHILD)throw Error(this.constructor.directiveName+\"() can only be used in child bindings\")}render(r){if(r===t||null==r)return this._t=void 0,this.it=r;if(r===i)return r;if(\"string\"!=typeof r)throw Error(this.constructor.directiveName+\"() called with a non-string value\");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName=\"unsafeHTML\",e.resultType=1;const o=r(e);export{e as UnsafeHTMLDirective,o as unsafeHTML};\n//# sourceMappingURL=unsafe-html.js.map\n"],"names":["s","t","n","i","r"],"mappings":";;;AACA;AACA;AACA;AACA;AACA,GAAG,MAAM,CAAC,SAASA,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAACC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAGC,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,uCAAuC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGD,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAGE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,mCAAmC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAM,MAAC,CAAC,CAACC,GAAC,CAAC,CAAC;;;;","x_google_ignoreList":[0]}
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.4.0",
5
+ "version": "3.5.1",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
package/readme.md CHANGED
@@ -44,9 +44,9 @@ Visit [https://peacock.redvars.com](https://peacock.redvars.com) to view the doc
44
44
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
45
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">
46
46
 
47
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@redvars/peacock@3.4.0/dist/assets/styles.css"></link>
47
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@redvars/peacock@3.5.1/dist/assets/styles.css"></link>
48
48
  <script type='module'
49
- src='https://cdn.jsdelivr.net/npm/@redvars/peacock@3.4.0/dist/peacock-loader.js'></script>
49
+ src='https://cdn.jsdelivr.net/npm/@redvars/peacock@3.5.1/dist/peacock-loader.js'></script>
50
50
  </head>
51
51
 
52
52
  <wc-button>Button</wc-button>
@@ -65,24 +65,25 @@ Input controls are UI design elements that allow users to input information into
65
65
  collecting data and enabling user interactions. Some common examples of input controls include text fields, dropdown
66
66
  menus, checkboxes, and radio buttons.
67
67
 
68
- | Name | Component | State |
69
- |---------------------------------------------------------------------|-------------------|-------|
68
+ | Name | Component | State |
69
+ |---------------------------------------------------------------------|-----------------|-------|
70
+ | [Checkbox](https://peacock.redvars.com/components/checkbox) | wc-checkbox | 🟢 |
70
71
  | [Code editor](https://peacock.redvars.com/components/code-editor) | wc-code-editor | 🟢 |
71
72
  | Color picker | color-picker | 🔴 |
72
- | [Checkbox](https://peacock.redvars.com/components/checkbox) | wc-checkbox | 🟢 |
73
73
  | [Date picker](https://peacock.redvars.com/components/date-picker) | wc-date-picker | 🟡 |
74
- | Date Time picker | datetime-picker | 🔴 |
75
- | [Form control](https://peacock.redvars.com/components/form-control) | wc-field | 🟡 |
74
+ | Date time picker | datetime-picker | 🔴 |
75
+ | [Field / Form control](https://peacock.redvars.com/components/field) | wc-field | 🟡 |
76
76
  | File picker | file-picker | 🔴 |
77
- | [HTML editor](https://peacock.redvars.com/components/html-editor) | html-editor | 🟢 |
77
+ | HTML editor | html-editor | 🔴 |
78
78
  | [Input](https://peacock.redvars.com/components/input) | wc-input | 🟢 |
79
- | [Input URL](https://peacock.redvars.com/components/input-url) | input-url | 🟢 |
79
+ | Input URL | input-url | 🔴 |
80
80
  | Month picker | month-picker | 🔴 |
81
- | [Number](https://peacock.redvars.com/components/number) | wc-number-field | 🟢 |
82
- | [Select](https://peacock.redvars.com/components/select) | base-select | 🟢 |
81
+ | [Number field](https://peacock.redvars.com/components/number) | wc-number-field | 🟢 |
82
+ | [Radio](https://peacock.redvars.com/components/radio) | wc-radio | 🟢 |
83
+ | [Search](https://peacock.redvars.com/components/search) | wc-search | 🟡 |
84
+ | [Select](https://peacock.redvars.com/components/select) | wc-select | 🟢 |
83
85
  | [Textarea](https://peacock.redvars.com/components/textarea) | wc-textarea | 🟢 |
84
86
  | [Time picker](https://peacock.redvars.com/components/time-picker) | wc-time-picker | 🟡 |
85
- | [URL input](https://peacock.redvars.com/components/url-input) | url-input | 🔴 |
86
87
  | Week picker | week-picker | 🔴 |
87
88
 
88
89
  ## Navigation
@@ -91,12 +92,13 @@ Navigational components are UI elements that help users move around the app or w
91
92
  and intuitive way to navigate through different sections and pages. Some common examples of navigational components
92
93
  include menus, tabs, and breadcrumbs.
93
94
 
94
- | Name | Component | State |
95
- |--------------------------------------------------------|-----------------|-------|
96
- | [Breadcrumb](https://peacock.redvars.com/components/breadcrumb) | wc-breadcrumb | 🟢 |
97
- | [Dropdown](https://peacock.redvars.com/components/dropdown) | base-dropdown | 🟡 |
98
- | [Menu](https://peacock.redvars.com/components/menu) | wc-base-menu | 🟡 |
99
- | [Tabs](https://peacock.redvars.com/components/tabs) | wc-tabs | 🟢 |
95
+ | Name | Component | State |
96
+ |-------------------------------------------------------------------------|---------------|-------|
97
+ | [Breadcrumb](https://peacock.redvars.com/components/breadcrumb) | wc-breadcrumb | 🟢 |
98
+ | Dropdown | wc-dropdown | 🔴 |
99
+ | [Menu](https://peacock.redvars.com/components/menu) | wc-menu | 🟡 |
100
+ | [Tabs](https://peacock.redvars.com/components/tabs) | wc-tabs | 🟢 |
101
+ | [Toolbar](https://peacock.redvars.com/components/toolbar) | wc-toolbar | 🟡 |
100
102
 
101
103
  ## Informational
102
104
 
@@ -104,15 +106,17 @@ Informational components are UI elements that provide information to users. They
104
106
  updates, or instructions within the app or website. Some common examples of informational components
105
107
  include notifications, tooltips, and progress bars.
106
108
 
107
- | Name | Component | State |
108
- |-------------------------------------------------------------------------------------|------------------------|-------|
109
- | [Badge](https://peacock.redvars.com/components/badge) | wc-badge | 🟢 |
110
- | [Linear Progress](https://peacock.redvars.com/components/linear-progress) | wc-linear-progress | 🟢 |
111
- | [Circular Progress](https://peacock.redvars.com/components/circular-progress) | wc-circular-progress | 🟢 |
112
- | [Spinner](https://peacock.redvars.com/components/spinner) | wc-spinner | 🟢 |
113
- | [Tooltip](https://peacock.redvars.com/components/tooltip) | wc-tooltip | 🟢 |
114
- | [Notification](https://peacock.redvars.com/components/notification) | base-notification | 🟢 |
115
- | [Notification Manager](https://peacock.redvars.com/components/notification-manager) | base-notification-manager | 🟢 |
109
+ | Name | Component | State |
110
+ |-------------------------------------------------------------------------------|----------------------|-------|
111
+ | [Badge](https://peacock.redvars.com/components/badge) | wc-badge | 🟢 |
112
+ | [Banner](https://peacock.redvars.com/components/banner) | wc-banner | 🟡 |
113
+ | [Circular Progress](https://peacock.redvars.com/components/circular-progress) | wc-circular-progress | 🟢 |
114
+ | [Linear Progress](https://peacock.redvars.com/components/linear-progress) | wc-linear-progress | 🟢 |
115
+ | [Notification](https://peacock.redvars.com/components/notification) | wc-notification | 🟢 |
116
+ | [Skeleton](https://peacock.redvars.com/components/skeleton) | wc-skeleton | 🟢 |
117
+ | [Snackbar](https://peacock.redvars.com/components/snackbar) | wc-snackbar | 🟡 |
118
+ | [Spinner](https://peacock.redvars.com/components/spinner) | wc-spinner | 🟢 |
119
+ | [Tooltip](https://peacock.redvars.com/components/tooltip) | wc-tooltip | 🟢 |
116
120
 
117
121
 
118
122
  ## Containers
@@ -121,54 +125,58 @@ Containers are UI elements that group similar content together, making it easier
121
125
  the interface. Examples of common containers include cards, carousels, and accordions, which provide structure and
122
126
  organization to the content.
123
127
 
124
- | Name | Component | State |
125
- |---------------------------------------------------------------|----------------|-------|
126
- | [Accordion](https://peacock.redvars.com/components/accordion) | wc-accordion | 🟢 |
127
- | Card | base-card | 🟡 |
128
+ | Name | Component | State |
129
+ |-----------------------------------------------------------------------|------------------|-------|
130
+ | [Accordion](https://peacock.redvars.com/components/accordion) | wc-accordion | 🟢 |
131
+ | [Bottom Sheet](https://peacock.redvars.com/components/bottom-sheet) | wc-bottom-sheet | 🟡 |
132
+ | [Card](https://peacock.redvars.com/components/card) | wc-card | 🟢 |
133
+ | Container | wc-container | 🟡 |
134
+ | [Side Sheet](https://peacock.redvars.com/components/side-sheet) | wc-side-sheet | 🟡 |
128
135
 
129
136
  ## General
130
137
 
131
138
  These components are used for general purpose. They include
132
139
 
133
- | Name | Component | State |
134
- |-------------------------------------------------------------------------------------|---------------------------|-------|
135
- | [Avatar](https://peacock.redvars.com/components/avatar) | wc-avatar | 🟢 |
136
- | [Button](https://peacock.redvars.com/components/button) | wc-button | 🟢 |
137
- | [Button Group](https://peacock.redvars.com/components/button-group) | wc-button-group | 🟢 |
138
- | [Calendar](https://peacock.redvars.com/components/calendar) | base-calendar | 🟢 |
139
- | Card Select | base-cardselect | 🔴 |
140
- | [Code Highlighter](https://peacock.redvars.com/components/code-highlighter) | wc-code-highlighter | 🟢 |
141
- | Column | base-col | 🔴 |
142
- | [Empty State](https://peacock.redvars.com/components/empty-state) | wc-empty-state | 🟡 |
143
- | [Flow Designer ](https://peacock.redvars.com/components/flow-designer) | flow-designer | 🔵 |
144
- | Grid | base-grid | 🔴 |
145
- | Group | base-group | 🔴 |
146
- | [Header](https://peacock.redvars.com/components/header) | base-header | 🟢 |
147
- | [Icon](https://peacock.redvars.com/components/icon) | wc-icon | 🟢 |
148
- | [Link](https://peacock.redvars.com/components/link) | wc-link | 🟢 |
149
- | [Modal](https://peacock.redvars.com/components/modal) | base-modal | 🟢 |
150
- | [Notification Manager](https://peacock.redvars.com/components/notification-manager) | notification-manager | 🟡 |
151
- | Observer | base-observer | 🔴 |
152
- | Pagination | wc-pagination | 🔴 |
153
- | Radio Group | base-radiogroup | 🔴 |
154
- | Row | base-row | 🔴 |
155
- | [Slider](https://peacock.redvars.com/components/slider) | wc-slider | 🟡 |
156
- | Spoiler | base-spoiler | 🔴 |
157
- | Stepper | base-stepper | 🔴 |
158
- | [Table](https://peacock.redvars.com/components/table) | wc-table | 🟡 |
159
- | [Tag](https://peacock.redvars.com/components/tag) / Chip | wc-tag | 🟢 |
160
- | [Text](https://peacock.redvars.com/components/text) | base-text | 🟢 |
161
- | [Tree View](https://peacock.redvars.com/components/tree-view) | wc-tree-view | 🟡 |
162
- | [Switch](https://peacock.redvars.com/components/switch) | wc-switch | 🟢 |
140
+ | Name | Component | State |
141
+ |-----------------------------------------------------------------------------|-----------------------|-------|
142
+ | [Avatar](https://peacock.redvars.com/components/avatar) | wc-avatar | 🟢 |
143
+ | [Button](https://peacock.redvars.com/components/button) | wc-button | 🟢 |
144
+ | [Button Group](https://peacock.redvars.com/components/button-group) | wc-button-group | 🟢 |
145
+ | Calendar | calendar | 🔴 |
146
+ | Card Select | card-select | 🔴 |
147
+ | [Chip](https://peacock.redvars.com/components/chip) | wc-chip | 🟢 |
148
+ | [Clock](https://peacock.redvars.com/components/clock) | wc-clock | 🟡 |
149
+ | [Code Highlighter](https://peacock.redvars.com/components/code-highlighter) | wc-code-highlighter | 🟢 |
150
+ | [Divider](https://peacock.redvars.com/components/divider) | wc-divider | 🟢 |
151
+ | [Empty State](https://peacock.redvars.com/components/empty-state) | wc-empty-state | 🟡 |
152
+ | [FAB](https://peacock.redvars.com/components/fab) | wc-fab | 🟢 |
153
+ | [Flow Designer](https://peacock.redvars.com/components/flow-designer) | flow-designer | 🔵 |
154
+ | Header | header | 🔴 |
155
+ | [Icon](https://peacock.redvars.com/components/icon) | wc-icon | 🟢 |
156
+ | [Icon Button](https://peacock.redvars.com/components/icon-button) | wc-icon-button | 🟢 |
157
+ | [Image](https://peacock.redvars.com/components/image) | wc-image | 🟡 |
158
+ | [Link](https://peacock.redvars.com/components/link) | wc-link | 🟢 |
159
+ | Modal | modal | 🔴 |
160
+ | [Number Counter](https://peacock.redvars.com/components/number-counter) | wc-number-counter | 🟡 |
161
+ | [Pagination](https://peacock.redvars.com/components/pagination) | wc-pagination | 🟡 |
162
+ | [Segmented Button](https://peacock.redvars.com/components/segmented-button) | wc-segmented-button | 🟡 |
163
+ | [Slider](https://peacock.redvars.com/components/slider) | wc-slider | 🟡 |
164
+ | [Switch](https://peacock.redvars.com/components/switch) | wc-switch | 🟢 |
165
+ | [Table](https://peacock.redvars.com/components/table) | wc-table | 🟡 |
166
+ | [Tag](https://peacock.redvars.com/components/tag) | wc-tag | 🟢 |
167
+ | Text | text | 🔴 |
168
+ | [Sidebar Menu](https://peacock.redvars.com/components/sidebar-menu) | wc-sidebar-menu | 🟡 |
163
169
 
164
170
  ## Charts
165
171
 
166
172
  These components are used to display data in a graphical format. They include
167
173
 
168
- | Name | Component | State |
169
- |----------------------------------------------------------------|---------------------|-------|
170
- | [Doughnut Chart](https://peacock.redvars.com/components/chart-doughnut) | wc-chart-doughnut | 🟢 |
171
- | [Pie Chart ](https://peacock.redvars.com/components/chart-pie) | wc-chart-pie | 🟢 |
174
+ | Name | Component | State |
175
+ |---------------------------------------------------------------------------------|------------------------|-------|
176
+ | [Bar Chart](https://peacock.redvars.com/components/chart-bar) | wc-chart-bar | 🟢 |
177
+ | [Doughnut Chart](https://peacock.redvars.com/components/chart-doughnut) | wc-chart-doughnut | 🟢 |
178
+ | [Pie Chart](https://peacock.redvars.com/components/chart-pie) | wc-chart-pie | 🟢 |
179
+ | [Stacked Bar Chart](https://peacock.redvars.com/components/chart-bar) | wc-chart-stacked-bar | 🟢 |
172
180
 
173
181
 
174
182
  ## 📄 License
package/scss/mixin.scss CHANGED
@@ -57,3 +57,19 @@
57
57
  @content;
58
58
  }
59
59
  }
60
+
61
+ @mixin apply-container-shape($name) {
62
+ border-start-start-radius: var(--#{$name}-container-shape-start-start, var(--#{$name}-container-shape));
63
+ border-start-end-radius: var(--#{$name}-container-shape-start-end, var(--#{$name}-container-shape));
64
+ border-end-start-radius: var(--#{$name}-container-shape-end-start, var(--#{$name}-container-shape));
65
+ border-end-end-radius: var(--#{$name}-container-shape-end-end, var(--#{$name}-container-shape));
66
+ corner-shape: var(--#{$name}-container-shape-variant);
67
+ }
68
+
69
+ @mixin copy-container-shape($from, $to) {
70
+ --#{$to}-container-shape-start-start: var(--#{$from}-container-shape-start-start, var(--#{$from}-container-shape));
71
+ --#{$to}-container-shape-start-end: var(--#{$from}-container-shape-start-end, var(--#{$from}-container-shape));
72
+ --#{$to}-container-shape-end-start: var(--#{$from}-container-shape-end-start, var(--#{$from}-container-shape));
73
+ --#{$to}-container-shape-end-end: var(--#{$from}-container-shape-end-end, var(--#{$from}-container-shape));
74
+ --#{$to}-container-shape-variant: var(--#{$from}-container-shape-variant);
75
+ }
package/scss/styles.scss CHANGED
@@ -3,9 +3,13 @@
3
3
  @use '../src/link/link.css-component.scss';
4
4
  @use '../src/popover/tooltip.css-component.scss';
5
5
 
6
+
7
+
8
+
6
9
  .surface, .surface-container-high, .surface-container-highest, .surface-container, .surface-container-low, .surface-container-lowest, .surface-dim {
7
10
  color: var(--color-on-surface);
8
11
  --icon-color: var(--color-on-surface);
12
+ transition: background-color .5s cubic-bezier(.2,0,0,1),background-image .5s cubic-bezier(.2,0,0,1), color .5s cubic-bezier(.2,0,0,1);
9
13
  }
10
14
 
11
15
  .surface {
@@ -0,0 +1,83 @@
1
+ import { LitElement } from 'lit';
2
+ import { property } from 'lit/decorators.js';
3
+ import type { MixinConstructor } from './MixinConstructor.js';
4
+
5
+
6
+ /**
7
+ * 1. Define an interface for the members the mixin adds.
8
+ * This makes the type annotation much cleaner.
9
+ */
10
+ export interface BaseButtonInterface {
11
+ htmlType: 'button' | 'submit' | 'reset';
12
+ disabled: boolean;
13
+ softDisabled: boolean;
14
+ disabledReason: string;
15
+ form: string;
16
+ name: string;
17
+ value: string;
18
+ }
19
+
20
+ /**
21
+ * 2. Apply the type annotation to the variable.
22
+ */
23
+ const BaseButtonMixin: <T extends MixinConstructor<LitElement>>(superclass: T) => T & MixinConstructor<BaseButtonInterface> = <T extends MixinConstructor<LitElement>>(superclass: T) => {
24
+ // Naming the class (BaseButtonElement) instead of using 'Mixin' or anonymous
25
+ // prevents the "__childPart" visibility error.
26
+ class BaseButtonElement extends superclass implements BaseButtonInterface {
27
+
28
+ /**
29
+ * The type of the underlying `<button>` element. Maps to the native `type` attribute.
30
+ * Possible values are `"button"`, `"submit"`, `"reset"`. Defaults to `"button"`.
31
+ */
32
+ @property({ type: String }) htmlType: 'button' | 'submit' | 'reset' =
33
+ 'button';
34
+
35
+ /**
36
+ * When `true`, the button is disabled and cannot be interacted with. Reflects to the `disabled` attribute. Defaults to `false`.
37
+ */
38
+ @property({ type: Boolean, reflect: true })
39
+ disabled: boolean = false;
40
+
41
+ /**
42
+ * When `true`, the button is visually styled as disabled and cannot be interacted with, but remains focusable.
43
+ * Use this in combination with `disabledReason` to communicate why the button is unavailable.
44
+ * Reflects to the `soft-disabled` attribute. Defaults to `false`.
45
+ */
46
+ @property({ type: Boolean, reflect: true, attribute: 'soft-disabled' })
47
+ softDisabled: boolean = false;
48
+
49
+ /**
50
+ * A human-readable explanation of why the button is disabled or soft-disabled.
51
+ * Rendered as a visually hidden tooltip and linked via `aria-describedby` for accessibility.
52
+ * Maps to the `disabled-reason` attribute.
53
+ */
54
+ @property({ attribute: 'disabled-reason' })
55
+ disabledReason: string = '';
56
+
57
+ /**
58
+ * The `id` of the `<form>` element to associate the button with.
59
+ * If omitted, the button is associated with its nearest ancestor form.
60
+ * Maps to the native `form` attribute.
61
+ */
62
+ @property()
63
+ form: string = '';
64
+
65
+ /**
66
+ * The name of the button, submitted as part of a name/value pair when the associated form is submitted.
67
+ * Maps to the native `name` attribute.
68
+ */
69
+ @property()
70
+ name: string = '';
71
+
72
+ /**
73
+ * The value of the button, submitted as part of a name/value pair when the associated form is submitted.
74
+ * Maps to the native `value` attribute.
75
+ */
76
+ @property()
77
+ value: string = '';
78
+ }
79
+
80
+ return BaseButtonElement as T & MixinConstructor<BaseButtonInterface>;
81
+ };
82
+
83
+ export default BaseButtonMixin;
@@ -0,0 +1,68 @@
1
+ import { LitElement } from 'lit';
2
+ import { property } from 'lit/decorators.js';
3
+ import type { MixinConstructor } from './MixinConstructor.js';
4
+
5
+
6
+ /**
7
+ * 1. Define an interface for the members the mixin adds.
8
+ * This makes the type annotation much cleaner.
9
+ */
10
+ export interface BaseHyperlinkInterface {
11
+ href?: string;
12
+ target: '_self' | '_parent' | '_blank' | '_top' | string;
13
+ rel?: string;
14
+ download?: string;
15
+ __isLink(): boolean;
16
+ }
17
+
18
+ /**
19
+ * 2. Apply the type annotation to the variable.
20
+ */
21
+ const BaseHyperlinkMixin: <T extends MixinConstructor<LitElement>>(superclass: T) => T & MixinConstructor<BaseHyperlinkInterface> = <T extends MixinConstructor<LitElement>>(superclass: T) => {
22
+ // Naming the class (BaseHyperlinkElement) instead of using 'Mixin' or anonymous
23
+ // prevents the "__childPart" visibility error.
24
+ class BaseHyperlinkElement extends superclass implements BaseHyperlinkInterface {
25
+ /**
26
+ * The URL that the hyperlink points to. When set, the component renders as an `<a>` element.
27
+ * Maps to the native `href` attribute.
28
+ */
29
+ @property({ reflect: true })
30
+ href?: string;
31
+
32
+ /**
33
+ * Where to display the linked URL. Maps to the native `target` attribute.
34
+ * Possible values are `"_self"`, `"_blank"`, `"_parent"`, `"_top"`, or a custom frame name.
35
+ * When using `"_blank"`, consider setting `rel="noopener noreferrer"` for security. Defaults to `"_self"`.
36
+ */
37
+ @property()
38
+ target: '_self' | '_parent' | '_blank' | '_top' | string = '_self';
39
+
40
+ /**
41
+ * The relationship between the current document and the linked URL.
42
+ * Maps to the native `rel` attribute on the rendered `<a>` element.
43
+ * When `target="_blank"`, use `"noopener noreferrer"` to prevent tab-napping attacks.
44
+ */
45
+ @property()
46
+ rel?: string;
47
+
48
+ /**
49
+ * Causes the browser to download the linked URL instead of navigating to it.
50
+ * If a string value is provided, it is used as the suggested filename.
51
+ * Omit or leave undefined to preserve normal navigation behaviour.
52
+ * Maps to the native `download` attribute. Only applies when `href` is set.
53
+ */
54
+ @property()
55
+ download?: string;
56
+
57
+ /**
58
+ * Returns `true` when `href` is set, indicating the component should render as a link.
59
+ */
60
+ __isLink(): boolean {
61
+ return !!this.href;
62
+ }
63
+ }
64
+
65
+ return BaseHyperlinkElement as T & MixinConstructor<BaseHyperlinkInterface>;
66
+ };
67
+
68
+ export default BaseHyperlinkMixin;
@@ -0,0 +1 @@
1
+ export type MixinConstructor<T = {}> = new (...args: any[]) => T;
@@ -0,0 +1,19 @@
1
+ # Mixins
2
+
3
+ The mixin element is an abstract foundation for component families.
4
+
5
+ It defines shared component contracts such as:
6
+
7
+ - Common props (for example state flags and cross-component attributes)
8
+ - Shared methods (for example focus, blur, value helpers, or utility behavior)
9
+ - Reusable behavior (for example event handling, validation flow, and state sync)
10
+
11
+ The base element does not define component-specific styles.
12
+
13
+ Child elements extend the base element and are responsible for:
14
+
15
+ - Implementing their own visual styles
16
+ - Providing component-specific rendering
17
+ - Extending or overriding shared behavior when needed
18
+
19
+ In short, the base element centralizes behavior and API shape, while child elements implement presentation and specialized logic.
@@ -0,0 +1,65 @@
1
+ export async function createCacheFetch(name: string) {
2
+ let cache: Cache | null = null;
3
+ // This map tracks requests currently being processed
4
+ const inFlightRequests = new Map<string, Promise<string>>();
5
+
6
+ try {
7
+ cache = await window.caches.open(name);
8
+ } catch (e) {
9
+ console.warn('window.caches access not allowed');
10
+ }
11
+
12
+ return async (url: string): Promise<string> => {
13
+ if (inFlightRequests.has(url)) {
14
+ return inFlightRequests.get(url)!;
15
+ }
16
+
17
+ const fetchPromise = (async () => {
18
+ const request = new Request(url);
19
+
20
+ if (cache) {
21
+ const cachedResponse = await cache.match(request);
22
+ if (cachedResponse) {
23
+ return cachedResponse.text();
24
+ }
25
+ }
26
+
27
+ const urlObj = new URL(request.url);
28
+ const isSameOrigin = urlObj.origin === window.location.origin;
29
+
30
+ const response = await fetch(request.url, {
31
+ method: 'GET',
32
+ mode: isSameOrigin ? 'no-cors' : 'cors',
33
+ credentials: isSameOrigin ? 'same-origin' : 'omit',
34
+ });
35
+
36
+ if (response.status === 404) {
37
+ console.error(`[Fetch Error] Resource not found (404): ${url}`);
38
+ return '';
39
+ }
40
+
41
+ const result = await response.text();
42
+
43
+ if (cache && response.status === 200) {
44
+ await cache.put(
45
+ request,
46
+ new Response(result, {
47
+ status: response.status,
48
+ statusText: response.statusText,
49
+ headers: response.headers,
50
+ }),
51
+ );
52
+ }
53
+
54
+ return result;
55
+ })();
56
+
57
+ inFlightRequests.set(url, fetchPromise);
58
+
59
+ try {
60
+ return await fetchPromise;
61
+ } finally {
62
+ inFlightRequests.delete(url);
63
+ }
64
+ };
65
+ }
@@ -0,0 +1,3 @@
1
+ export function isDarkMode() {
2
+ return document.documentElement.dataset.theme === 'dark';
3
+ }
@@ -0,0 +1,6 @@
1
+ export function isInViewport(element: HTMLElement) {
2
+ const rect = element.getBoundingClientRect();
3
+ return (
4
+ rect.top !== 0 || rect.left !== 0 || rect.bottom !== 0 || rect.right !== 0
5
+ );
6
+ }
@@ -0,0 +1,38 @@
1
+ function hasMeaningfulContent(slotElement: HTMLSlotElement | null) {
2
+ const nodes = slotElement?.assignedNodes({ flatten: true }) || [];
3
+
4
+ for (const node of nodes) {
5
+ if (node.nodeType === Node.ELEMENT_NODE) {
6
+ return true;
7
+ }
8
+ if (
9
+ node.nodeType === Node.TEXT_NODE &&
10
+ (node.textContent?.trim().length || 0) > 0
11
+ ) {
12
+ return true;
13
+ }
14
+ }
15
+
16
+ return false;
17
+ }
18
+
19
+ export function observerSlotChangesWithCallback(
20
+ slot: HTMLSlotElement | null,
21
+ callback: (hasContent: boolean) => void,
22
+ ) {
23
+ const observer = new MutationObserver(() => {
24
+ callback(hasMeaningfulContent(slot));
25
+ });
26
+
27
+ const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];
28
+ assignedNodes.forEach(node => {
29
+ observer.observe(node, {
30
+ attributes: true,
31
+ childList: true,
32
+ characterData: true,
33
+ subtree: true,
34
+ });
35
+ });
36
+
37
+ callback(hasMeaningfulContent(slot));
38
+ }
@@ -0,0 +1,27 @@
1
+ // Basic sanitization: remove <script>, <foreignObject>, event handler attributes (on*), and iframes
2
+ export function sanitizeSvg(rawSvg: string) {
3
+ try {
4
+ const parser = new DOMParser();
5
+ const doc = parser.parseFromString(rawSvg, 'image/svg+xml');
6
+
7
+ const scripts = Array.from(doc.querySelectorAll('script'));
8
+ scripts.forEach(n => n.remove());
9
+
10
+ const foreigns = Array.from(doc.querySelectorAll('foreignObject, iframe'));
11
+ foreigns.forEach(n => n.remove());
12
+
13
+ const all = Array.from(doc.querySelectorAll('*'));
14
+ all.forEach(el => {
15
+ const attrs = Array.from(el.attributes).filter(a => /^on/i.test(a.name));
16
+ attrs.forEach(a => el.removeAttribute(a.name));
17
+ });
18
+
19
+ const el = doc.documentElement;
20
+ if (!el) return '';
21
+
22
+ const serializer = new XMLSerializer();
23
+ return serializer.serializeToString(el);
24
+ } catch (e) {
25
+ return '';
26
+ }
27
+ }
@@ -0,0 +1,27 @@
1
+ export function throttle(
2
+ func: Function,
3
+ delay: number,
4
+ options = { leading: true, trailing: true },
5
+ ) {
6
+ let timerId: any;
7
+ let lastExec = 0;
8
+
9
+ return function (...args: any[]) {
10
+ // @ts-ignore
11
+ const context = this;
12
+ const now = Date.now();
13
+
14
+ const shouldCallNow = options.leading && now - lastExec >= delay;
15
+
16
+ if (shouldCallNow) {
17
+ func.apply(context, args);
18
+ lastExec = now;
19
+ } else if (options.trailing && !timerId) {
20
+ timerId = setTimeout(() => {
21
+ func.apply(context, args);
22
+ lastExec = Date.now();
23
+ timerId = null;
24
+ }, delay);
25
+ }
26
+ };
27
+ }