@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.
- package/dist/BaseButton-DuASuVth.js +219 -0
- package/dist/BaseButton-DuASuVth.js.map +1 -0
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js +65 -0
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js.map +1 -0
- package/dist/assets/components.css +1 -1
- package/dist/assets/components.css.map +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/banner.js +187 -0
- package/dist/banner.js.map +1 -0
- package/dist/bottom-sheet.js +2 -2
- package/dist/{button-COYCtuA8.js → button-DouvOfEU.js} +92 -283
- package/dist/button-DouvOfEU.js.map +1 -0
- package/dist/{button-group-DsXquZQn.js → button-group-CEdMwvJJ.js} +72 -48
- package/dist/button-group-CEdMwvJJ.js.map +1 -0
- package/dist/button-group.js +8 -5
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +7 -4
- package/dist/button.js.map +1 -1
- package/dist/card.js +29 -74
- package/dist/card.js.map +1 -1
- package/dist/chart-bar.js +2 -2
- package/dist/chart-bar.js.map +1 -1
- package/dist/chart-doughnut.js +2 -2
- package/dist/chart-doughnut.js.map +1 -1
- package/dist/chart-pie.js +2 -2
- package/dist/chart-pie.js.map +1 -1
- package/dist/chart-stacked-bar.js +2 -2
- package/dist/chart-stacked-bar.js.map +1 -1
- package/dist/{class-map-3TAnCMAX.js → class-map-YU7g0o3B.js} +2 -2
- package/dist/{class-map-3TAnCMAX.js.map → class-map-YU7g0o3B.js.map} +1 -1
- package/dist/clock.js.map +1 -1
- package/dist/code-editor.js +4 -4
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +5 -4
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +6627 -3477
- package/dist/custom-elements.json +10954 -7810
- package/dist/directive-ZPhl09Yt.js +9 -0
- package/dist/directive-ZPhl09Yt.js.map +1 -0
- package/dist/dispatch-event-utils-CuEqjlPT.js +127 -0
- package/dist/dispatch-event-utils-CuEqjlPT.js.map +1 -0
- package/dist/fab.js +423 -0
- package/dist/fab.js.map +1 -0
- package/dist/index.js +17 -9
- package/dist/index.js.map +1 -1
- package/dist/{observe-theme-change-DKAIv5BB.js → is-dark-mode-DicqGkCJ.js} +6 -2
- package/dist/is-dark-mode-DicqGkCJ.js.map +1 -0
- package/dist/{select-C3XAzenC.js → navigation-rail-Lxetd5-Z.js} +2426 -898
- package/dist/navigation-rail-Lxetd5-Z.js.map +1 -0
- package/dist/notification.js +418 -0
- package/dist/notification.js.map +1 -0
- package/dist/number-counter.js +2 -2
- package/dist/number-counter.js.map +1 -1
- package/dist/observe-slot-change-BGJfgg2E.js +31 -0
- package/dist/observe-slot-change-BGJfgg2E.js.map +1 -0
- package/dist/peacock-loader.js +48 -13
- package/dist/peacock-loader.js.map +1 -1
- package/dist/search.js +456 -0
- package/dist/search.js.map +1 -0
- package/dist/side-sheet.js +2 -2
- package/dist/src/__mixins/BaseButtonMixin.d.ts +20 -0
- package/dist/src/__mixins/BaseHyperlinkMixin.d.ts +18 -0
- package/dist/src/__mixins/MixinConstructor.d.ts +1 -0
- package/dist/src/__utils/cache-fetch.d.ts +1 -0
- package/dist/src/__utils/is-dark-mode.d.ts +1 -0
- package/dist/src/__utils/is-in-viewport.d.ts +1 -0
- package/dist/src/__utils/observe-slot-change.d.ts +1 -0
- package/dist/src/__utils/sanitize-svg.d.ts +1 -0
- package/dist/src/__utils/throttle.d.ts +4 -0
- package/dist/src/accordion/accordion-item.d.ts +33 -9
- package/dist/src/accordion/accordion.d.ts +21 -5
- package/dist/src/banner/banner.d.ts +43 -0
- package/dist/src/banner/index.d.ts +1 -0
- package/dist/src/button/BaseButton.d.ts +7 -57
- package/dist/src/button/button/button.d.ts +32 -3
- package/dist/src/button/button-group/button-group.d.ts +4 -4
- package/dist/src/button/icon-button/icon-button.d.ts +33 -8
- package/dist/src/card/card.d.ts +4 -15
- package/dist/src/empty-state/empty-state.d.ts +1 -1
- package/dist/src/fab/fab.d.ts +80 -0
- package/dist/src/fab/index.d.ts +1 -0
- package/dist/src/focus-ring/focus-ring.d.ts +11 -5
- package/dist/src/index.d.ts +8 -1
- package/dist/src/link/link.d.ts +3 -10
- package/dist/src/menu/menu/menu.d.ts +3 -2
- package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -0
- package/dist/src/navigation-rail/index.d.ts +2 -0
- package/dist/src/navigation-rail/navigation-rail-item.d.ts +55 -0
- package/dist/src/navigation-rail/navigation-rail.d.ts +71 -0
- package/dist/src/notification/index.d.ts +1 -0
- package/dist/src/notification/notification.d.ts +69 -0
- package/dist/src/pagination/pagination.d.ts +8 -1
- package/dist/src/search/index.d.ts +1 -0
- package/dist/src/search/search.d.ts +76 -0
- package/dist/src/select/select.d.ts +3 -5
- package/dist/src/sidebar-menu/index.d.ts +3 -0
- package/dist/src/sidebar-menu/sidebar-menu-item.d.ts +58 -0
- package/dist/src/sidebar-menu/sidebar-menu.d.ts +38 -0
- package/dist/src/sidebar-menu/sidebar-sub-menu.d.ts +35 -0
- package/dist/src/slider/slider.d.ts +4 -0
- package/dist/src/snackbar/snackbar.d.ts +14 -1
- package/dist/src/toolbar/index.d.ts +1 -0
- package/dist/src/toolbar/toolbar.d.ts +86 -0
- package/dist/src/tooltip/tooltip.d.ts +3 -0
- package/dist/src/url-field/index.d.ts +1 -0
- package/dist/src/url-field/url-field.d.ts +48 -0
- package/dist/{style-map-CRFEoCEg.js → style-map-DVmWOuYy.js} +2 -2
- package/dist/{style-map-CRFEoCEg.js.map → style-map-DVmWOuYy.js.map} +1 -1
- package/dist/test/banner.test.d.ts +1 -0
- package/dist/test/search.test.d.ts +1 -0
- package/dist/test/sidebar-menu.test.d.ts +1 -0
- package/dist/test/toolbar.test.d.ts +1 -0
- package/dist/toolbar.js +306 -0
- package/dist/toolbar.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{unsafe-html-D3GHRaGQ.js → unsafe-html-BsGUjx94.js} +2 -2
- package/dist/{unsafe-html-D3GHRaGQ.js.map → unsafe-html-BsGUjx94.js.map} +1 -1
- package/package.json +1 -1
- package/readme.md +73 -65
- package/scss/mixin.scss +16 -0
- package/scss/styles.scss +4 -0
- package/src/__mixins/BaseButtonMixin.ts +83 -0
- package/src/__mixins/BaseHyperlinkMixin.ts +68 -0
- package/src/__mixins/MixinConstructor.ts +1 -0
- package/src/__mixins/README.md +19 -0
- package/src/__utils/cache-fetch.ts +65 -0
- package/src/__utils/is-dark-mode.ts +3 -0
- package/src/__utils/is-in-viewport.ts +6 -0
- package/src/__utils/observe-slot-change.ts +38 -0
- package/src/__utils/sanitize-svg.ts +27 -0
- package/src/__utils/throttle.ts +27 -0
- package/src/accordion/accordion-item.scss +136 -65
- package/src/accordion/accordion-item.ts +117 -44
- package/src/accordion/accordion.scss +24 -5
- package/src/accordion/accordion.ts +29 -23
- package/src/accordion/demo/index.html +74 -35
- package/src/banner/banner.scss +83 -0
- package/src/banner/banner.ts +101 -0
- package/src/banner/index.ts +1 -0
- package/src/button/BaseButton.ts +13 -115
- package/src/button/button/button-colors.scss +14 -14
- package/src/button/button/button-sizes.scss +4 -2
- package/src/button/button/button.ts +80 -26
- package/src/button/button-group/button-group.ts +5 -5
- package/src/button/icon-button/icon-button.ts +79 -44
- package/src/card/card.ts +50 -100
- package/src/chart-bar/chart-bar.ts +10 -15
- package/src/chart-bar/chart-stacked-bar.ts +15 -19
- package/src/chart-doughnut/chart-doughnut.ts +24 -28
- package/src/chart-pie/chart-pie.ts +20 -24
- package/src/checkbox/checkbox.scss +17 -34
- package/src/checkbox/checkbox.ts +4 -2
- package/src/clock/clock.ts +1 -1
- package/src/code-editor/code-editor.ts +4 -4
- package/src/code-highlighter/code-highlighter.scss +1 -0
- package/src/code-highlighter/code-highlighter.ts +3 -3
- package/src/date-picker/date-picker.ts +6 -3
- package/src/divider/divider.ts +3 -1
- package/src/elevation/elevation.scss +5 -5
- package/src/empty-state/empty-state.scss +7 -9
- package/src/empty-state/empty-state.ts +1 -1
- package/src/fab/fab-colors.scss +49 -0
- package/src/fab/fab-sizes.scss +47 -0
- package/src/fab/fab.scss +137 -0
- package/src/fab/fab.ts +214 -0
- package/src/fab/index.ts +1 -0
- package/src/field/field.ts +3 -1
- package/src/focus-ring/focus-ring.ts +47 -40
- package/src/icon/datasource.ts +1 -1
- package/src/icon/icon.ts +3 -1
- package/src/image/image.ts +3 -2
- package/src/index.ts +8 -1
- package/src/input/input.ts +8 -3
- package/src/link/link.ts +2 -15
- package/src/menu/menu/menu.scss +7 -0
- package/src/menu/menu/menu.ts +7 -4
- package/src/menu/menu-item/menu-item.ts +3 -1
- package/src/menu/sub-menu/sub-menu.ts +1 -0
- package/src/navigation-rail/index.ts +2 -0
- package/src/navigation-rail/navigation-rail-item.scss +216 -0
- package/src/navigation-rail/navigation-rail-item.ts +223 -0
- package/src/navigation-rail/navigation-rail.scss +72 -0
- package/src/navigation-rail/navigation-rail.ts +149 -0
- package/src/notification/index.ts +1 -0
- package/src/notification/notification.scss +201 -0
- package/src/notification/notification.ts +207 -0
- package/src/number-counter/number-counter.ts +3 -1
- package/src/number-field/number-field.ts +10 -6
- package/src/pagination/pagination.scss +33 -24
- package/src/pagination/pagination.ts +115 -60
- package/src/peacock-loader.ts +42 -5
- package/src/radio/radio.ts +3 -1
- package/src/search/index.ts +1 -0
- package/src/search/search-colors.scss +14 -0
- package/src/search/search.scss +204 -0
- package/src/search/search.ts +244 -0
- package/src/select/option.ts +1 -1
- package/src/select/select.scss +5 -0
- package/src/select/select.ts +71 -37
- package/src/sidebar-menu/demo/index.html +68 -0
- package/src/sidebar-menu/index.ts +3 -0
- package/src/sidebar-menu/sidebar-menu-item.scss +102 -0
- package/src/sidebar-menu/sidebar-menu-item.ts +151 -0
- package/src/{tree-view/tree-view.scss → sidebar-menu/sidebar-menu.scss} +1 -1
- package/src/sidebar-menu/sidebar-menu.ts +182 -0
- package/src/sidebar-menu/sidebar-sub-menu.scss +130 -0
- package/src/sidebar-menu/sidebar-sub-menu.ts +160 -0
- package/src/skeleton/skeleton.scss +18 -24
- package/src/slider/slider.scss +19 -0
- package/src/slider/slider.ts +30 -19
- package/src/snackbar/snackbar.scss +62 -31
- package/src/snackbar/snackbar.ts +91 -11
- package/src/switch/switch.ts +3 -1
- package/src/table/table.ts +3 -1
- package/src/tabs/tab.ts +10 -6
- package/src/text/text.css-component.scss +7 -1
- package/src/textarea/textarea.ts +4 -2
- package/src/time-picker/time-picker.ts +5 -3
- package/src/toolbar/index.ts +1 -0
- package/src/toolbar/toolbar-colors.scss +16 -0
- package/src/toolbar/toolbar.scss +165 -0
- package/src/toolbar/toolbar.ts +137 -0
- package/src/tooltip/tooltip.ts +24 -0
- package/src/url-field/index.ts +1 -0
- package/src/url-field/url-field.scss +50 -0
- package/src/url-field/url-field.ts +239 -0
- package/dist/button-COYCtuA8.js.map +0 -1
- package/dist/button-group-DsXquZQn.js.map +0 -1
- package/dist/directive-Cuw6h7YA.js +0 -9
- package/dist/directive-Cuw6h7YA.js.map +0 -1
- package/dist/dispatch-event-utils-B4odODQf.js +0 -277
- package/dist/dispatch-event-utils-B4odODQf.js.map +0 -1
- package/dist/observe-theme-change-DKAIv5BB.js.map +0 -1
- package/dist/select-C3XAzenC.js.map +0 -1
- package/dist/src/styleMixins.css.d.ts +0 -9
- package/dist/src/tree-view/index.d.ts +0 -2
- package/dist/src/tree-view/tree-node.d.ts +0 -69
- package/dist/src/tree-view/tree-view.d.ts +0 -40
- package/dist/src/tree-view/wc-tree-view.d.ts +0 -6
- package/dist/src/utils.d.ts +0 -9
- package/dist/test/tree-view.test.d.ts +0 -1
- package/src/styleMixins.css.ts +0 -55
- package/src/tree-view/demo/index.html +0 -57
- package/src/tree-view/index.ts +0 -2
- package/src/tree-view/tree-node.scss +0 -101
- package/src/tree-view/tree-node.ts +0 -268
- package/src/tree-view/tree-view.ts +0 -182
- package/src/tree-view/wc-tree-view.ts +0 -9
- package/src/utils.ts +0 -193
- /package/dist/src/{spread.d.ts → __directive/spread.d.ts} +0 -0
- /package/dist/src/{utils → __utils}/copy-to-clipboard.d.ts +0 -0
- /package/dist/src/{utils → __utils}/dispatch-event-utils.d.ts +0 -0
- /package/dist/src/{utils → __utils}/observe-theme-change.d.ts +0 -0
- /package/src/{spread.ts → __directive/spread.ts} +0 -0
- /package/src/{utils → __utils}/copy-to-clipboard.ts +0 -0
- /package/src/{utils → __utils}/dispatch-event-utils.ts +0 -0
- /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-
|
|
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-
|
|
11
|
+
//# sourceMappingURL=unsafe-html-BsGUjx94.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsafe-html-
|
|
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
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.
|
|
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.
|
|
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
|
|
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
|
|
75
|
-
| [Form control](https://peacock.redvars.com/components/
|
|
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
|
-
|
|
|
77
|
+
| HTML editor | html-editor | 🔴 |
|
|
78
78
|
| [Input](https://peacock.redvars.com/components/input) | wc-input | 🟢 |
|
|
79
|
-
|
|
|
79
|
+
| Input URL | input-url | 🔴 |
|
|
80
80
|
| Month picker | month-picker | 🔴 |
|
|
81
|
-
| [Number](https://peacock.redvars.com/components/number)
|
|
82
|
-
| [
|
|
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
|
|
95
|
-
|
|
96
|
-
| [Breadcrumb](https://peacock.redvars.com/components/breadcrumb)
|
|
97
|
-
|
|
|
98
|
-
| [Menu](https://peacock.redvars.com/components/menu)
|
|
99
|
-
| [Tabs](https://peacock.redvars.com/components/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
|
|
108
|
-
|
|
109
|
-
| [Badge](https://peacock.redvars.com/components/badge)
|
|
110
|
-
| [
|
|
111
|
-
| [Circular Progress](https://peacock.redvars.com/components/circular-progress)
|
|
112
|
-
| [
|
|
113
|
-
| [
|
|
114
|
-
| [
|
|
115
|
-
| [
|
|
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
|
|
125
|
-
|
|
126
|
-
| [Accordion](https://peacock.redvars.com/components/accordion)
|
|
127
|
-
|
|
|
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
|
|
134
|
-
|
|
135
|
-
| [Avatar](https://peacock.redvars.com/components/avatar)
|
|
136
|
-
| [Button](https://peacock.redvars.com/components/button)
|
|
137
|
-
| [Button Group](https://peacock.redvars.com/components/button-group)
|
|
138
|
-
|
|
|
139
|
-
| Card Select
|
|
140
|
-
| [
|
|
141
|
-
|
|
|
142
|
-
| [
|
|
143
|
-
| [
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
| [
|
|
147
|
-
|
|
|
148
|
-
| [
|
|
149
|
-
| [
|
|
150
|
-
| [
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
| [
|
|
156
|
-
|
|
|
157
|
-
|
|
|
158
|
-
| [Table](https://peacock.redvars.com/components/table)
|
|
159
|
-
| [Tag](https://peacock.redvars.com/components/tag)
|
|
160
|
-
|
|
|
161
|
-
| [
|
|
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
|
|
169
|
-
|
|
170
|
-
| [
|
|
171
|
-
| [
|
|
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,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
|
+
}
|