@redvars/peacock 3.2.10 → 3.3.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/{PeacockComponent-CxJc63xj.js → IndividualComponent-tDnXrOLV.js} +3 -3
- package/dist/IndividualComponent-tDnXrOLV.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/button-group-DA7xoziD.js +292 -0
- package/dist/button-group-DA7xoziD.js.map +1 -0
- package/dist/button-group.js +6 -107
- package/dist/button-group.js.map +1 -1
- package/dist/{button-DaL4va7Q.js → button-trIfcqC7.js} +21 -35
- package/dist/button-trIfcqC7.js.map +1 -0
- package/dist/button.js +5 -5
- package/dist/chart-donut.js +307 -0
- package/dist/chart-donut.js.map +1 -0
- package/dist/chart-doughnut.js +307 -0
- package/dist/chart-doughnut.js.map +1 -0
- package/dist/chart-pie.js +259 -0
- package/dist/chart-pie.js.map +1 -0
- package/dist/{class-map-BvQRv7eW.js → class-map-hJdvjl-W.js} +9 -3
- package/dist/class-map-hJdvjl-W.js.map +1 -0
- package/dist/clock.js +5 -6
- package/dist/clock.js.map +1 -1
- package/dist/code-editor.js +38 -25
- package/dist/code-editor.js.map +1 -1
- package/dist/code-highlighter.js +10 -14
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +8144 -3654
- package/dist/custom-elements.json +7925 -3901
- package/dist/{dispatch-event-utils-vbdiOSeC.js → dispatch-event-utils-B4odODQf.js} +2 -15
- package/dist/dispatch-event-utils-B4odODQf.js.map +1 -0
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/dist/number-counter.js +12 -10
- package/dist/number-counter.js.map +1 -1
- package/dist/{observe-theme-change-NneLARW8.js → observe-theme-change-BISF-Gl5.js} +2 -2
- package/dist/{observe-theme-change-NneLARW8.js.map → observe-theme-change-BISF-Gl5.js.map} +1 -1
- package/dist/peacock-loader.js +94 -502
- package/dist/peacock-loader.js.map +1 -1
- package/dist/query-QBcUV-L_.js +15 -0
- package/dist/query-QBcUV-L_.js.map +1 -0
- package/dist/src/IndividualComponent.d.ts +1 -0
- package/dist/src/accordion/{accordion-item/accordion-item.d.ts → accordion-item.d.ts} +5 -4
- package/dist/src/accordion/{accordion/accordion.d.ts → accordion.d.ts} +6 -6
- package/dist/src/accordion/{accordion-item/index.d.ts → index.d.ts} +1 -0
- package/dist/src/avatar/avatar.d.ts +2 -2
- package/dist/src/badge/badge.d.ts +2 -2
- package/dist/src/breadcrumb/breadcrumb/breadcrumb.d.ts +9 -8
- package/dist/src/breadcrumb/breadcrumb-item/breadcrumb-item.d.ts +4 -3
- package/dist/src/button/button/button.d.ts +2 -2
- package/dist/src/button/button-group/button-group.d.ts +9 -5
- package/dist/src/button/icon-button/icon-button.d.ts +2 -2
- package/dist/src/chart-donut/chart-donut.d.ts +53 -0
- package/dist/src/chart-donut/index.d.ts +1 -0
- package/dist/src/chart-doughnut/chart-doughnut.d.ts +53 -0
- package/dist/src/chart-doughnut/index.d.ts +1 -0
- package/dist/src/chart-pie/chart-pie.d.ts +50 -0
- package/dist/src/chart-pie/index.d.ts +1 -0
- package/dist/src/checkbox/checkbox.d.ts +3 -6
- package/dist/src/chip/chip/chip.d.ts +4 -4
- package/dist/src/chip/tag/tag.d.ts +3 -3
- package/dist/src/clock/clock.d.ts +3 -4
- package/dist/src/code-editor/code-editor.d.ts +13 -10
- package/dist/src/code-highlighter/code-highlighter.d.ts +4 -7
- package/dist/src/container/container.d.ts +6 -11
- package/dist/src/date-picker/date-picker.d.ts +3 -3
- package/dist/src/divider/divider.d.ts +2 -2
- package/dist/src/elevation/elevation.d.ts +2 -2
- package/dist/src/empty-state/empty-state.d.ts +9 -2
- package/dist/src/field/field.d.ts +17 -0
- package/dist/src/focus-ring/focus-ring.d.ts +1 -1
- package/dist/src/icon/icon.d.ts +2 -2
- package/dist/src/image/image.d.ts +4 -12
- package/dist/src/index.d.ts +9 -1
- package/dist/src/input/input.d.ts +2 -2
- package/dist/src/link/link.d.ts +4 -5
- package/dist/src/menu/index.d.ts +3 -0
- package/dist/src/menu/menu/MenuSurfaceController.d.ts +18 -0
- package/dist/src/menu/menu/menu.d.ts +66 -8
- package/dist/src/menu/menu-item/menu-item.d.ts +24 -5
- package/dist/src/menu/sub-menu/sub-menu.d.ts +36 -0
- package/dist/src/number-counter/number-counter.d.ts +9 -7
- package/dist/src/number-field/number-field.d.ts +1 -1
- package/dist/src/pagination/index.d.ts +1 -0
- package/dist/src/pagination/pagination.d.ts +38 -0
- package/dist/src/popover/PopoverController.d.ts +4 -1
- package/dist/src/popover/index.d.ts +1 -1
- package/dist/src/progress/circular-progress/circular-progress.d.ts +3 -3
- package/dist/src/progress/linear-progress/linear-progress.d.ts +3 -3
- package/dist/src/ripple/ripple.d.ts +60 -4
- package/dist/src/skeleton/skeleton.d.ts +6 -5
- package/dist/src/slider/index.d.ts +1 -0
- package/dist/src/slider/slider.d.ts +52 -0
- package/dist/src/spinner/spinner.d.ts +2 -2
- package/dist/src/switch/switch.d.ts +2 -2
- package/dist/src/table/index.d.ts +1 -0
- package/dist/src/table/table.d.ts +110 -0
- package/dist/src/tabs/index.d.ts +4 -0
- package/dist/src/tabs/tab-group.d.ts +45 -0
- package/dist/src/tabs/tab-panel.d.ts +22 -0
- package/dist/src/tabs/tab.d.ts +59 -0
- package/dist/src/tabs/tabs.d.ts +29 -0
- package/dist/src/textarea/textarea.d.ts +3 -3
- package/dist/src/time-picker/time-picker.d.ts +3 -3
- package/dist/src/{popover/tooltip → tooltip}/tooltip.d.ts +4 -3
- package/dist/src/tree-view/index.d.ts +2 -0
- package/dist/src/tree-view/tree-node.d.ts +69 -0
- package/dist/src/tree-view/tree-view.d.ts +40 -0
- package/dist/src/tree-view/wc-tree-view.d.ts +6 -0
- package/dist/{style-map-B8xgVEc9.js → style-map-CfNHEkQp.js} +2 -2
- package/dist/{style-map-B8xgVEc9.js.map → style-map-CfNHEkQp.js.map} +1 -1
- package/dist/test/icon.test.d.ts +1 -1
- package/dist/test/menu.test.d.ts +1 -0
- package/dist/test/sub-menu.test.d.ts +1 -0
- package/dist/test/tree-view.test.d.ts +1 -0
- package/dist/transform-DRuHEvar.js +3312 -0
- package/dist/transform-DRuHEvar.js.map +1 -0
- package/dist/{image-v3BujlY5.js → tree-view-CLolVlU0.js} +4088 -672
- package/dist/tree-view-CLolVlU0.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{unsafe-html-B-dV3Jps.js → unsafe-html-CV6Je6HL.js} +2 -2
- package/dist/{unsafe-html-B-dV3Jps.js.map → unsafe-html-CV6Je6HL.js.map} +1 -1
- package/package.json +3 -1
- package/readme.md +40 -40
- package/src/{PeacockComponent.ts → IndividualComponent.ts} +1 -1
- package/src/accordion/{accordion-item/accordion-item.scss → accordion-item.scss} +1 -1
- package/src/accordion/{accordion-item/accordion-item.ts → accordion-item.ts} +7 -6
- package/src/accordion/{accordion/accordion.scss → accordion.scss} +2 -1
- package/src/accordion/{accordion/accordion.ts → accordion.ts} +6 -6
- package/src/accordion/{accordion-item/index.ts → index.ts} +2 -0
- package/src/avatar/avatar.ts +2 -2
- package/src/badge/badge.ts +2 -2
- package/src/breadcrumb/breadcrumb/breadcrumb.ts +10 -8
- package/src/breadcrumb/breadcrumb-item/breadcrumb-item.ts +4 -3
- package/src/button/BaseButton.ts +1 -1
- package/src/button/button/button.scss +9 -23
- package/src/button/button/button.ts +8 -8
- package/src/button/button-group/button-group.ts +13 -7
- package/src/button/icon-button/icon-button.ts +8 -8
- package/src/chart-donut/chart-donut.scss +37 -0
- package/src/chart-donut/chart-donut.ts +287 -0
- package/src/chart-donut/demo/index.html +51 -0
- package/src/chart-donut/index.ts +1 -0
- package/src/chart-doughnut/chart-donut.scss +37 -0
- package/src/chart-doughnut/chart-doughnut.ts +287 -0
- package/src/chart-doughnut/demo/index.html +51 -0
- package/src/chart-doughnut/index.ts +1 -0
- package/src/chart-pie/chart-pie.scss +27 -0
- package/src/chart-pie/chart-pie.ts +256 -0
- package/src/chart-pie/demo/index.html +51 -0
- package/src/chart-pie/index.ts +1 -0
- package/src/checkbox/checkbox.ts +3 -6
- package/src/chip/chip/chip.ts +6 -6
- package/src/chip/tag/tag.ts +6 -6
- package/src/clock/clock.ts +5 -6
- package/src/code-editor/code-editor.scss +3 -5
- package/src/code-editor/code-editor.ts +32 -16
- package/src/code-highlighter/code-highlighter.ts +8 -11
- package/src/container/container.ts +6 -11
- package/src/date-picker/date-picker.ts +7 -7
- package/src/divider/divider.scss +2 -2
- package/src/divider/divider.ts +2 -2
- package/src/elevation/elevation.ts +2 -2
- package/src/empty-state/empty-state.scss +1 -1
- package/src/empty-state/empty-state.ts +10 -3
- package/src/field/field.scss +4 -4
- package/src/field/field.ts +19 -2
- package/src/focus-ring/focus-ring.scss +2 -1
- package/src/focus-ring/focus-ring.ts +1 -1
- package/src/icon/icon.ts +2 -2
- package/src/icon/p-icon.ts +1 -1
- package/src/image/image.ts +4 -12
- package/src/index.ts +11 -3
- package/src/input/input.ts +6 -6
- package/src/link/link.ts +4 -5
- package/src/menu/index.ts +3 -0
- package/src/menu/menu/MenuSurfaceController.ts +61 -0
- package/src/menu/{menu-list/menu-list.scss → menu/menu.scss} +19 -4
- package/src/menu/menu/menu.ts +401 -77
- package/src/menu/menu-item/menu-item-colors.scss +2 -2
- package/src/menu/menu-item/menu-item.ts +128 -37
- package/src/menu/sub-menu/sub-menu.scss +7 -0
- package/src/menu/sub-menu/sub-menu.ts +243 -0
- package/src/number-counter/demo/index.html +1 -1
- package/src/number-counter/number-counter.ts +11 -9
- package/src/number-field/number-field.ts +7 -7
- package/src/pagination/index.ts +1 -0
- package/src/pagination/pagination.scss +59 -0
- package/src/pagination/pagination.ts +135 -0
- package/src/peacock-loader.ts +92 -51
- package/src/popover/PopoverController.ts +13 -7
- package/src/popover/index.ts +1 -1
- package/src/progress/circular-progress/circular-progress.scss +1 -1
- package/src/progress/circular-progress/circular-progress.ts +3 -3
- package/src/progress/linear-progress/linear-progress.ts +3 -3
- package/src/ripple/ripple.ts +478 -94
- package/src/skeleton/skeleton.ts +6 -5
- package/src/slider/index.ts +1 -0
- package/src/slider/slider.scss +130 -0
- package/src/slider/slider.ts +178 -0
- package/src/spinner/spinner.ts +2 -2
- package/src/switch/switch.ts +4 -4
- package/src/table/index.ts +1 -0
- package/src/table/table.scss +174 -0
- package/src/table/table.ts +475 -0
- package/src/tabs/index.ts +4 -0
- package/src/tabs/tab-group.scss +10 -0
- package/src/tabs/tab-group.ts +143 -0
- package/src/tabs/tab-panel.scss +12 -0
- package/src/tabs/tab-panel.ts +29 -0
- package/src/tabs/tab.scss +157 -0
- package/src/tabs/tab.ts +243 -0
- package/src/tabs/tabs.scss +19 -0
- package/src/tabs/tabs.ts +66 -0
- package/src/text/text.css-component.scss +6 -3
- package/src/textarea/textarea.ts +5 -5
- package/src/time-picker/time-picker.ts +7 -7
- package/src/{popover/tooltip → tooltip}/tooltip.scss +17 -14
- package/src/{popover/tooltip → tooltip}/tooltip.ts +12 -10
- package/src/tree-view/demo/index.html +57 -0
- package/src/tree-view/index.ts +2 -0
- package/src/tree-view/tree-node.scss +101 -0
- package/src/tree-view/tree-node.ts +268 -0
- package/src/tree-view/tree-view.scss +12 -0
- package/src/tree-view/tree-view.ts +182 -0
- package/src/tree-view/wc-tree-view.ts +9 -0
- package/dist/PeacockComponent-CxJc63xj.js.map +0 -1
- package/dist/button-DaL4va7Q.js.map +0 -1
- package/dist/class-map-BvQRv7eW.js.map +0 -1
- package/dist/dispatch-event-utils-vbdiOSeC.js.map +0 -1
- package/dist/image-v3BujlY5.js.map +0 -1
- package/dist/src/PeacockComponent.d.ts +0 -1
- package/dist/src/accordion/accordion/index.d.ts +0 -1
- package/dist/src/avatar/p-avatar.d.ts +0 -3
- package/dist/src/badge/p-badge.d.ts +0 -3
- package/dist/src/menu/menu-list/menu-list.d.ts +0 -7
- package/dist/state-B09bP3XH.js +0 -10
- package/dist/state-B09bP3XH.js.map +0 -1
- package/src/accordion/accordion/index.ts +0 -1
- package/src/avatar/p-avatar.ts +0 -5
- package/src/badge/p-badge.ts +0 -5
- package/src/menu/menu-list/menu-list.ts +0 -33
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
height: 100%;
|
|
8
|
+
--tab-outline-color: var(--color-primary);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.tab-element {
|
|
12
|
+
background: transparent;
|
|
13
|
+
border: none;
|
|
14
|
+
appearance: none;
|
|
15
|
+
margin: 0;
|
|
16
|
+
outline: none;
|
|
17
|
+
text-decoration: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.tab {
|
|
21
|
+
position: relative;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
height: var(--_tab-height);
|
|
27
|
+
padding: 0 var(--_container-padding);
|
|
28
|
+
width: 100%;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
|
|
31
|
+
.tab-content {
|
|
32
|
+
position: relative;
|
|
33
|
+
@include mixin.get-typography('title-small');
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
gap: var(--_tab-icon-label-spacing);
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
z-index: 0;
|
|
41
|
+
|
|
42
|
+
color: var(--_label-text-color);
|
|
43
|
+
opacity: var(--_label-text-opacity, 1);
|
|
44
|
+
--icon-size: var(--tab-icon-size, var(--_tab-icon-size));
|
|
45
|
+
--icon-color: var(--_label-text-color);
|
|
46
|
+
|
|
47
|
+
.slot-container {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.indicator {
|
|
53
|
+
position: absolute;
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
z-index: 1;
|
|
56
|
+
opacity: 0;
|
|
57
|
+
background: var(--_active-indicator-color);
|
|
58
|
+
border-radius: var(--_active-indicator-shape);
|
|
59
|
+
transform-origin: left bottom;
|
|
60
|
+
height: var(--_active-indicator-height);
|
|
61
|
+
inset: auto 0px 0px;
|
|
62
|
+
opacity: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.has-content {
|
|
66
|
+
.slot-container {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex: none;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&.disabled {
|
|
74
|
+
cursor: not-allowed;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
Background layers
|
|
79
|
+
*/
|
|
80
|
+
.focus-ring {
|
|
81
|
+
z-index: 2;
|
|
82
|
+
--focus-ring-container-shape-start-start: var(--_container-shape-start-start);
|
|
83
|
+
--focus-ring-container-shape-start-end: var(--_container-shape-start-end);
|
|
84
|
+
--focus-ring-container-shape-end-start: var(--_container-shape-end-start);
|
|
85
|
+
--focus-ring-container-shape-end-end: var(--_container-shape-end-end);
|
|
86
|
+
--focus-ring-container-shape-variant: var(--_container-corner-shape-variant);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ripple {
|
|
90
|
+
corner-shape: var(--_container-corner-shape-variant);
|
|
91
|
+
--ripple-state-opacity: var(--_container-state-opacity, 0);
|
|
92
|
+
--ripple-pressed-color: var(--_container-state-color);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.outline {
|
|
96
|
+
z-index: 1;
|
|
97
|
+
display: none;
|
|
98
|
+
position: absolute;
|
|
99
|
+
width: 100%;
|
|
100
|
+
height: 100%;
|
|
101
|
+
pointer-events: none;
|
|
102
|
+
border: var(--_outline-width) solid var(--_outline-color);
|
|
103
|
+
border-start-start-radius: var(--_container-shape-start-start);
|
|
104
|
+
border-start-end-radius: var(--_container-shape-start-end);
|
|
105
|
+
border-end-start-radius: var(--_container-shape-end-start);
|
|
106
|
+
border-end-end-radius: var(--_container-shape-end-end);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
:host-context([variant='line']) .tab {
|
|
113
|
+
--_tab-height: 100%;
|
|
114
|
+
--_container-padding: 1rem;
|
|
115
|
+
|
|
116
|
+
--_label-text-color: var(--color-on-surface);
|
|
117
|
+
--_container-state-color: var(--_label-text-color);
|
|
118
|
+
--_container-shape-start-start: var(--shape-corner-small);
|
|
119
|
+
--_container-shape-start-end: var(--shape-corner-small);
|
|
120
|
+
--_container-shape-end-start: var(--shape-corner-small);
|
|
121
|
+
--_container-shape-end-end: var(--shape-corner-small);
|
|
122
|
+
--_active-indicator-color: var(--color-primary);
|
|
123
|
+
--_active-indicator-shape: 3px 3px 0 0;
|
|
124
|
+
--_active-indicator-height: 2px;
|
|
125
|
+
|
|
126
|
+
.focus-ring {
|
|
127
|
+
inset: 3px 3px 4px 3px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&.active {
|
|
131
|
+
|
|
132
|
+
.tab-content .indicator {
|
|
133
|
+
opacity: 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.focus-ring {
|
|
137
|
+
inset: 3px 3px calc(4px + var(--_active-indicator-height)) 3px;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&:hover:not(:where(.disabled)) {
|
|
142
|
+
--_container-state-opacity: 0.08;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&.pressed:not(:where(.disabled)) {
|
|
146
|
+
--_container-state-opacity: 0.12;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&.disabled {
|
|
150
|
+
--_label-text-color: var(--color-on-surface);
|
|
151
|
+
--_label-text-opacity: 0.38;
|
|
152
|
+
|
|
153
|
+
.ripple {
|
|
154
|
+
display: none;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
package/src/tabs/tab.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { html, LitElement, nothing } from 'lit';
|
|
2
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { dispatchActivationClick, isActivationClick } from 'src/utils/dispatch-event-utils.js';
|
|
5
|
+
import { observerSlotChangesWithCallback, throttle } from 'src/utils.js';
|
|
6
|
+
import { spread } from 'src/spread.js';
|
|
7
|
+
import styles from './tab.scss';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @label Tab
|
|
11
|
+
* @tag wc-tab
|
|
12
|
+
* @rawTag tab
|
|
13
|
+
* @parentRawTag tabs
|
|
14
|
+
*
|
|
15
|
+
* @summary A tab component for use within tabs.
|
|
16
|
+
* @overview
|
|
17
|
+
* <p>Tab represents an individual tab in a tabs component.</p>
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```html
|
|
21
|
+
* <wc-tab>Tab Label</wc-tab>
|
|
22
|
+
* ```
|
|
23
|
+
* @tags navigation
|
|
24
|
+
*/
|
|
25
|
+
export class Tab extends LitElement {
|
|
26
|
+
|
|
27
|
+
#id = crypto.randomUUID();
|
|
28
|
+
|
|
29
|
+
static styles = [styles];
|
|
30
|
+
|
|
31
|
+
@property({ type: Boolean, reflect: true }) active = false;
|
|
32
|
+
|
|
33
|
+
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
34
|
+
|
|
35
|
+
@property({ type: String }) disabledReason = '';
|
|
36
|
+
|
|
37
|
+
@property({ type: String }) icon?: string;
|
|
38
|
+
|
|
39
|
+
@property({ type: String }) label?: string;
|
|
40
|
+
|
|
41
|
+
@property({ type: String }) value?: string;
|
|
42
|
+
|
|
43
|
+
@property({ reflect: true })
|
|
44
|
+
configAria?: { [key: string]: any };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sets or retrieves the window or frame at which to target content.
|
|
48
|
+
*/
|
|
49
|
+
@property() target: string = '_self';
|
|
50
|
+
|
|
51
|
+
@property({ type: String, reflect: true }) href?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Sets the delay for throttle in milliseconds. Defaults to 200 milliseconds.
|
|
55
|
+
*/
|
|
56
|
+
@property() throttleDelay = 200;
|
|
57
|
+
|
|
58
|
+
@state() hasFocus = false;
|
|
59
|
+
|
|
60
|
+
@state() slotHasContent = false;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* States
|
|
64
|
+
*/
|
|
65
|
+
@state()
|
|
66
|
+
isPressed = false;
|
|
67
|
+
|
|
68
|
+
private _tabindex = 0;
|
|
69
|
+
|
|
70
|
+
@query('.tab-element') readonly tabElement!: HTMLElement | null;
|
|
71
|
+
|
|
72
|
+
override focus() {
|
|
73
|
+
this.tabElement?.focus();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override blur() {
|
|
77
|
+
this.tabElement?.blur();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
constructor() {
|
|
82
|
+
super();
|
|
83
|
+
this._tabindex = 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
override firstUpdated() {
|
|
87
|
+
this.__dispatchClickWithThrottle = throttle(
|
|
88
|
+
this.__dispatchClick,
|
|
89
|
+
this.throttleDelay,
|
|
90
|
+
);
|
|
91
|
+
observerSlotChangesWithCallback(
|
|
92
|
+
this.renderRoot.querySelector('slot'),
|
|
93
|
+
hasContent => {
|
|
94
|
+
this.slotHasContent = hasContent;
|
|
95
|
+
this.requestUpdate();
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
__dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =
|
|
101
|
+
event => {
|
|
102
|
+
this.__dispatchClick(event);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
__dispatchClick = (event: MouseEvent | KeyboardEvent) => {
|
|
106
|
+
// If the button is soft-disabled or a disabled link, we need to explicitly
|
|
107
|
+
// prevent the click from propagating to other event listeners as well as
|
|
108
|
+
// prevent the default action.
|
|
109
|
+
if (this.disabled && this.href) {
|
|
110
|
+
event.stopImmediatePropagation();
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!isActivationClick(event) || !this.tabElement) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this.focus();
|
|
120
|
+
dispatchActivationClick(this.tabElement);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
__handlePress = (event: KeyboardEvent | MouseEvent) => {
|
|
124
|
+
if (this.disabled) return;
|
|
125
|
+
if (
|
|
126
|
+
event instanceof KeyboardEvent &&
|
|
127
|
+
event.type === 'keydown' &&
|
|
128
|
+
(event.key === 'Enter' || event.key === ' ')
|
|
129
|
+
) {
|
|
130
|
+
this.isPressed = true;
|
|
131
|
+
} else if (event.type === 'mousedown') {
|
|
132
|
+
this.isPressed = true;
|
|
133
|
+
} else {
|
|
134
|
+
this.isPressed = false;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
__isLink() {
|
|
139
|
+
return !!this.href;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// private handleKeyDown(evt: KeyboardEvent) {
|
|
143
|
+
// if (this.disabled || this.showLoader) return;
|
|
144
|
+
// if (evt.key === 'Enter' || evt.key === ' ') {
|
|
145
|
+
// evt.preventDefault();
|
|
146
|
+
// this.isActive = true;
|
|
147
|
+
// this.dispatchTabClick();
|
|
148
|
+
// }
|
|
149
|
+
// }
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
render() {
|
|
153
|
+
|
|
154
|
+
const isLink = this.__isLink();
|
|
155
|
+
|
|
156
|
+
const cssClasses = {
|
|
157
|
+
tab: true,
|
|
158
|
+
'tab-element': true,
|
|
159
|
+
disabled: this.disabled,
|
|
160
|
+
pressed: this.isPressed,
|
|
161
|
+
active: this.active,
|
|
162
|
+
'has-content': this.slotHasContent
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if (!isLink) {
|
|
167
|
+
return html`<button
|
|
168
|
+
class=${classMap(cssClasses)}
|
|
169
|
+
tabindex="0"
|
|
170
|
+
@mousedown=${this.__handlePress}
|
|
171
|
+
@keydown=${this.__handlePress}
|
|
172
|
+
@keyup=${this.__handlePress}
|
|
173
|
+
?aria-describedby=${this.__getDisabledReasonID()}
|
|
174
|
+
aria-disabled=${`${this.disabled}`}
|
|
175
|
+
?disabled=${this.disabled}
|
|
176
|
+
${spread(this.configAria)}
|
|
177
|
+
>
|
|
178
|
+
${this.renderTabContent()}
|
|
179
|
+
</button>`;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return html`<a
|
|
183
|
+
class=${classMap(cssClasses)}
|
|
184
|
+
id="button"
|
|
185
|
+
tabindex="0"
|
|
186
|
+
href=${this.href}
|
|
187
|
+
target=${this.target}
|
|
188
|
+
@mousedown=${this.__handlePress}
|
|
189
|
+
@keydown=${this.__handlePress}
|
|
190
|
+
@keyup=${this.__handlePress}
|
|
191
|
+
role="button"
|
|
192
|
+
?aria-describedby=${this.__getDisabledReasonID()}
|
|
193
|
+
aria-disabled=${`${this.disabled}`}
|
|
194
|
+
${spread(this.configAria)}
|
|
195
|
+
>
|
|
196
|
+
${this.renderTabContent()}
|
|
197
|
+
</a>`;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
renderTabContent() {
|
|
201
|
+
return html`
|
|
202
|
+
<wc-focus-ring class="focus-ring" .control=${this} element="tabElement"></wc-focus-ring>
|
|
203
|
+
<wc-elevation class="elevation"></wc-elevation>
|
|
204
|
+
<div class="background"></div>
|
|
205
|
+
<div class="outline"></div>
|
|
206
|
+
<wc-ripple class="ripple"></wc-ripple>
|
|
207
|
+
|
|
208
|
+
<div class="tab-content">
|
|
209
|
+
<div class="slot-container">
|
|
210
|
+
<slot></slot>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<slot name="icon"></slot>
|
|
214
|
+
|
|
215
|
+
<div class="indicator"></div>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
<div class="indicator"></div>
|
|
219
|
+
|
|
220
|
+
${this.__renderDisabledReason()}
|
|
221
|
+
`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
__getDisabledReasonID() {
|
|
225
|
+
return this.disabled && this.disabledReason
|
|
226
|
+
? `disabled-reason-${this.#id}`
|
|
227
|
+
: nothing;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
__renderDisabledReason() {
|
|
231
|
+
const disabledReasonID = this.__getDisabledReasonID();
|
|
232
|
+
if (disabledReasonID)
|
|
233
|
+
return html`<div
|
|
234
|
+
id="disabled-reason-${this.#id}"
|
|
235
|
+
role="tooltip"
|
|
236
|
+
aria-label=${this.disabledReason}
|
|
237
|
+
class="screen-reader-only"
|
|
238
|
+
>
|
|
239
|
+
{this.disabledReason}
|
|
240
|
+
</div>`;
|
|
241
|
+
return nothing;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
.tabs {
|
|
7
|
+
display: flex;
|
|
8
|
+
position: relative;
|
|
9
|
+
width: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:host-context([variant='line']), :host([variant='line']) {
|
|
13
|
+
--tabs-height: 3rem;
|
|
14
|
+
|
|
15
|
+
.tabs {
|
|
16
|
+
height: var(--tabs-height);
|
|
17
|
+
border-bottom: 1px solid var(--color-surface-variant);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/tabs/tabs.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { html, LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import styles from './tabs.scss';
|
|
4
|
+
import { Tab } from './tab.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @label Tabs
|
|
8
|
+
* @tag wc-tabs
|
|
9
|
+
* @rawTag tabs
|
|
10
|
+
*
|
|
11
|
+
* @summary Container for tab components.
|
|
12
|
+
* @overview
|
|
13
|
+
* <p>Tabs holds the tab buttons and manages their layout.</p>
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```html
|
|
17
|
+
* <wc-tabs>
|
|
18
|
+
* <wc-tab>Tab 1</wc-tab>
|
|
19
|
+
* <wc-tab>Tab 2</wc-tab>
|
|
20
|
+
* </wc-tabs>
|
|
21
|
+
* ```
|
|
22
|
+
* @tags navigation
|
|
23
|
+
*/
|
|
24
|
+
export class Tabs extends LitElement {
|
|
25
|
+
static styles = [styles];
|
|
26
|
+
|
|
27
|
+
static Tab = Tab;
|
|
28
|
+
|
|
29
|
+
@property({ type: Boolean }) managed = false;
|
|
30
|
+
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
super.connectedCallback();
|
|
33
|
+
this.addEventListener('click', this.__handleTabClick);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
disconnectedCallback() {
|
|
37
|
+
this.removeEventListener('click', this.__handleTabClick);
|
|
38
|
+
super.disconnectedCallback();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private __handleTabClick = (event: Event) => {
|
|
42
|
+
if (this.managed) return;
|
|
43
|
+
|
|
44
|
+
const detailEvent = event as CustomEvent;
|
|
45
|
+
const path = detailEvent.composedPath();
|
|
46
|
+
const clickedTab: Tab | undefined = path.find(
|
|
47
|
+
node => node instanceof Element && (node as Element).tagName.toLowerCase() === 'wc-tab',
|
|
48
|
+
) as Tab | undefined;
|
|
49
|
+
|
|
50
|
+
if (!clickedTab) return;
|
|
51
|
+
|
|
52
|
+
const tabs: NodeListOf<Tab> = this.querySelectorAll('wc-tab');
|
|
53
|
+
tabs.forEach(tab => {
|
|
54
|
+
tab.active = false;
|
|
55
|
+
});
|
|
56
|
+
(clickedTab as Tab).active = true;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
render() {
|
|
60
|
+
return html`
|
|
61
|
+
<div class="tabs">
|
|
62
|
+
<slot></slot>
|
|
63
|
+
</div>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -49,8 +49,11 @@ $sizes: "large", "medium", 'small';
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
.text-code-block {
|
|
52
|
-
|
|
53
|
-
background: var(--color-
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
background-color: var(--color-surface-variant);
|
|
54
|
+
text-shadow: 0 1px 1px var(--color-surface-variant);
|
|
55
|
+
color: var(--color-on-surface);
|
|
54
56
|
border-radius: var(--shape-corner-extra-small);
|
|
55
|
-
padding
|
|
57
|
+
padding: var(--spacing-050);
|
|
58
|
+
font-family: var(--font-family-monospace);
|
|
56
59
|
}
|
package/src/textarea/textarea.ts
CHANGED
|
@@ -7,14 +7,14 @@ import { spread } from '../spread.js';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @label Textarea
|
|
10
|
-
* @tag textarea
|
|
10
|
+
* @tag wc-textarea
|
|
11
11
|
* @rawTag textarea
|
|
12
|
-
*
|
|
13
12
|
* @summary The Textarea component is used to capture user input.
|
|
13
|
+
* @tags input
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```html
|
|
17
|
-
* <textarea
|
|
17
|
+
* <wc-textarea label="Description" placeholder="Enter text"></wc-textarea>
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export class Textarea extends BaseInput {
|
|
@@ -124,7 +124,7 @@ export class Textarea extends BaseInput {
|
|
|
124
124
|
|
|
125
125
|
render() {
|
|
126
126
|
return html`
|
|
127
|
-
<
|
|
127
|
+
<wc-field
|
|
128
128
|
?required=${this.required}
|
|
129
129
|
?disabled=${this.disabled}
|
|
130
130
|
?readonly=${this.readonly}
|
|
@@ -162,7 +162,7 @@ export class Textarea extends BaseInput {
|
|
|
162
162
|
></textarea>
|
|
163
163
|
|
|
164
164
|
<slot name="end" slot="field-end"></slot>
|
|
165
|
-
</
|
|
165
|
+
</wc-field>
|
|
166
166
|
`;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -7,14 +7,14 @@ import { spread } from '../spread.js';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @label Time Picker
|
|
10
|
-
* @tag time-picker
|
|
10
|
+
* @tag wc-time-picker
|
|
11
11
|
* @rawTag time-picker
|
|
12
|
-
*
|
|
13
12
|
* @summary The Time Picker component is used to capture time user input.
|
|
13
|
+
* @tags input
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```html
|
|
17
|
-
* <time-picker label="
|
|
17
|
+
* <wc-time-picker label="Time" placeholder="Select a time"></wc-time-picker>
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
export class TimePicker extends BaseInput {
|
|
@@ -122,7 +122,7 @@ export class TimePicker extends BaseInput {
|
|
|
122
122
|
|
|
123
123
|
render() {
|
|
124
124
|
return html`
|
|
125
|
-
<
|
|
125
|
+
<wc-field
|
|
126
126
|
?required=${this.required}
|
|
127
127
|
?disabled=${this.disabled}
|
|
128
128
|
?readonly=${this.readonly}
|
|
@@ -161,7 +161,7 @@ export class TimePicker extends BaseInput {
|
|
|
161
161
|
|
|
162
162
|
<slot name="end" slot="field-end"></slot>
|
|
163
163
|
|
|
164
|
-
<icon-button
|
|
164
|
+
<wc-icon-button
|
|
165
165
|
slot="field-end"
|
|
166
166
|
color="secondary"
|
|
167
167
|
variant="text"
|
|
@@ -174,8 +174,8 @@ export class TimePicker extends BaseInput {
|
|
|
174
174
|
});
|
|
175
175
|
}}
|
|
176
176
|
>
|
|
177
|
-
</icon-button>
|
|
178
|
-
</
|
|
177
|
+
</wc-icon-button>
|
|
178
|
+
</wc-field>
|
|
179
179
|
`;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
@use "
|
|
1
|
+
@use "../../scss/mixin";
|
|
2
2
|
@use "sass:string";
|
|
3
3
|
|
|
4
4
|
@include mixin.base-styles;
|
|
5
5
|
|
|
6
|
-
.tooltip {
|
|
7
|
-
pointer-events: none;
|
|
8
|
-
transition: transform var(--duration-short2) ease-in-out, opacity var(--duration-short2) ease-in-out;
|
|
9
|
-
transform: scale(0);
|
|
10
|
-
position: absolute;
|
|
11
|
-
top: 0;
|
|
12
|
-
left: 0;
|
|
13
|
-
opacity: 0;
|
|
14
|
-
}
|
|
15
6
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
:host(:not([preview])) {
|
|
8
|
+
.tooltip {
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
transition: transform var(--duration-short2) ease-in-out, opacity var(--duration-short2) ease-in-out;
|
|
11
|
+
transform: scale(0);
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
opacity: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.tooltip.open {
|
|
19
|
+
pointer-events: auto;
|
|
20
|
+
transform: scale(1);
|
|
21
|
+
opacity: 1;
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
.variant-plain .tooltip-content {
|
|
@@ -2,22 +2,22 @@ import { html, LitElement } from 'lit';
|
|
|
2
2
|
import { property, query } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import styles from './tooltip.scss';
|
|
5
|
-
import { PopoverController } from '../PopoverController.js';
|
|
5
|
+
import { PopoverController } from '../popover/PopoverController.js';
|
|
6
6
|
|
|
7
7
|
// Define a type for valid trigger combinations
|
|
8
8
|
export type TooltipTrigger = 'hover' | 'focus' | 'click';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @label Tooltip
|
|
12
|
-
* @tag
|
|
12
|
+
* @tag wc-tooltip
|
|
13
13
|
* @rawTag tooltip
|
|
14
14
|
* @summary Displays a tooltip for an element.
|
|
15
|
+
* @tags display
|
|
15
16
|
*
|
|
16
17
|
* @example
|
|
17
18
|
* ```html
|
|
18
|
-
* <
|
|
19
|
+
* <wc-tooltip preview>Tooltip</wc-tooltip>
|
|
19
20
|
* ```
|
|
20
|
-
* @tags display
|
|
21
21
|
*/
|
|
22
22
|
export class Tooltip extends LitElement {
|
|
23
23
|
static styles = [styles];
|
|
@@ -37,6 +37,8 @@ export class Tooltip extends LitElement {
|
|
|
37
37
|
@property({ type: String, reflect: true }) variant: 'plain' | 'rich' =
|
|
38
38
|
'plain';
|
|
39
39
|
|
|
40
|
+
@property({ type: Boolean, reflect: true }) preview = false;
|
|
41
|
+
|
|
40
42
|
@query('#tooltip') floatingEl!: HTMLElement;
|
|
41
43
|
|
|
42
44
|
private _target: HTMLElement | null = null;
|
|
@@ -54,13 +56,13 @@ export class Tooltip extends LitElement {
|
|
|
54
56
|
|
|
55
57
|
// Define listeners as arrow functions to maintain 'this' context
|
|
56
58
|
private _onMouseEnter = () => {
|
|
57
|
-
if (!this.hasTrigger('hover')) return;
|
|
59
|
+
if (this.preview || !this.hasTrigger('hover')) return;
|
|
58
60
|
window.clearTimeout(this._hideTimeout); // Cancel any pending close
|
|
59
61
|
this.show();
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
private _onMouseLeave = () => {
|
|
63
|
-
if (!this.hasTrigger('hover')) return;
|
|
65
|
+
if (this.preview || !this.hasTrigger('hover')) return;
|
|
64
66
|
|
|
65
67
|
// Small delay allows the mouse to move from target -> tooltip
|
|
66
68
|
// without the tooltip vanishing instantly.
|
|
@@ -75,17 +77,17 @@ export class Tooltip extends LitElement {
|
|
|
75
77
|
}, 100); // 100ms is usually enough for a smooth transition
|
|
76
78
|
};
|
|
77
79
|
|
|
78
|
-
private _onFocusIn = () => this.hasTrigger('focus') && this.show();
|
|
80
|
+
private _onFocusIn = () => this.preview && this.hasTrigger('focus') && this.show();
|
|
79
81
|
|
|
80
82
|
private _onFocusOut = (e: FocusEvent) => {
|
|
81
|
-
if (!this.hasTrigger('focus')) return;
|
|
83
|
+
if (this.preview || !this.hasTrigger('focus')) return;
|
|
82
84
|
if (this._target && !this._target.contains(e.relatedTarget as Node)) {
|
|
83
85
|
this.hide();
|
|
84
86
|
}
|
|
85
87
|
};
|
|
86
88
|
|
|
87
89
|
private _onClick = (e: MouseEvent) => {
|
|
88
|
-
if (!this.hasTrigger('click')) return;
|
|
90
|
+
if (this.preview || !this.hasTrigger('click')) return;
|
|
89
91
|
e.stopPropagation();
|
|
90
92
|
this.toggle();
|
|
91
93
|
};
|
|
@@ -210,7 +212,7 @@ export class Tooltip extends LitElement {
|
|
|
210
212
|
__renderRichTooltip() {
|
|
211
213
|
return html`
|
|
212
214
|
<div class="tooltip-content">
|
|
213
|
-
<
|
|
215
|
+
<wc-elevation class="elevation"></wc-elevation>
|
|
214
216
|
|
|
215
217
|
<div class="tooltip-title" id="tooltip-labelledby">
|
|
216
218
|
<slot name="title"></slot>
|