@redvars/peacock 3.8.2 → 3.8.3
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/assets/components.css.map +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/babel-DBsfpl3B.js +18 -0
- package/dist/babel-DBsfpl3B.js.map +1 -0
- package/dist/button-group.js +4 -4
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +5 -5
- package/dist/card.js +22 -7
- package/dist/card.js.map +1 -1
- package/dist/code-highlighter.js +74 -11212
- package/dist/code-highlighter.js.map +1 -1
- package/dist/color-picker.js +701 -0
- package/dist/color-picker.js.map +1 -0
- package/dist/custom-elements-jsdocs.json +96 -3
- package/dist/custom-elements.json +1202 -576
- package/dist/estree-C2LDzX4U.js +47 -0
- package/dist/estree-C2LDzX4U.js.map +1 -0
- package/dist/fab.js +1 -3
- package/dist/fab.js.map +1 -1
- package/dist/html-D22sQuVy.js +27 -0
- package/dist/html-D22sQuVy.js.map +1 -0
- package/dist/icon-button.js +5 -5
- package/dist/index-_g_oLekF.js +14095 -0
- package/dist/index-_g_oLekF.js.map +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/item.js +3 -2
- package/dist/item.js.map +1 -1
- package/dist/{list-D6JLh1uh.js → list-H0itjRte.js} +194 -20
- package/dist/list-H0itjRte.js.map +1 -0
- package/dist/list.js +2 -2
- package/dist/loader.js +6 -2
- package/dist/loader.js.map +1 -1
- package/dist/menu-item.js +103 -33
- package/dist/menu-item.js.map +1 -1
- package/dist/menu.js +4 -18
- package/dist/menu.js.map +1 -1
- package/dist/navigation-rail-item.js +21 -6
- package/dist/navigation-rail-item.js.map +1 -1
- package/dist/navigation-rail.js +22 -20
- package/dist/navigation-rail.js.map +1 -1
- package/dist/pierre-dark-DFWl0m-C.js +4 -0
- package/dist/pierre-dark-DFWl0m-C.js.map +1 -0
- package/dist/pierre-light-BEkAPImt.js +4 -0
- package/dist/pierre-light-BEkAPImt.js.map +1 -0
- package/dist/postcss-BhbitHaI.js +64 -0
- package/dist/postcss-BhbitHaI.js.map +1 -0
- package/dist/{select-Dwtk0RIU.js → select-CspawZ18.js} +13 -6
- package/dist/{select-Dwtk0RIU.js.map → select-CspawZ18.js.map} +1 -1
- package/dist/side-sheet.js +1 -1
- package/dist/side-sheet.js.map +1 -1
- package/dist/src/button/button-group/button-group.d.ts +4 -4
- package/dist/src/code-highlighter/code-highlighter.d.ts +2 -2
- package/dist/src/color-picker/color-picker.d.ts +85 -0
- package/dist/src/color-picker/index.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/item/item.d.ts +0 -1
- package/dist/src/list/list-item.d.ts +3 -1
- package/dist/src/list/list.d.ts +24 -0
- package/dist/src/menu/menu-item/menu-item.d.ts +1 -2
- package/dist/standalone-Ccq0tWwA.js +32 -0
- package/dist/standalone-Ccq0tWwA.js.map +1 -0
- package/dist/sub-menu.js +6 -1
- package/dist/sub-menu.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +3 -3
- package/scss/mixin.scss +1 -0
- package/src/button/button/button-base.scss +2 -1
- package/src/button/button/button-layers.scss +2 -6
- package/src/button/button-group/button-group.ts +4 -4
- package/src/button/fab/fab.ts +0 -4
- package/src/card/card.scss +18 -5
- package/src/code-highlighter/code-highlighter.ts +94 -39
- package/src/color-picker/color-picker.scss +217 -0
- package/src/color-picker/color-picker.ts +478 -0
- package/src/color-picker/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/item/item.scss +3 -1
- package/src/item/item.ts +0 -1
- package/src/list/list-item.scss +5 -1
- package/src/list/list-item.ts +40 -14
- package/src/list/list.ts +164 -2
- package/src/loader.ts +4 -0
- package/src/menu/menu/menu.scss +4 -18
- package/src/menu/menu/menu.ts +0 -1
- package/src/menu/menu-item/menu-item.scss +73 -43
- package/src/menu/menu-item/menu-item.ts +60 -27
- package/src/menu/sub-menu/sub-menu.scss +5 -1
- package/src/navigation-rail/navigation-rail-item.scss +25 -8
- package/src/navigation-rail/navigation-rail.scss +25 -22
- package/src/side-sheet/side-sheet.ts +1 -1
- package/src/sidebar-menu/sidebar-menu-item.scss +12 -6
- package/dist/list-D6JLh1uh.js.map +0 -1
package/src/list/list.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LitElement, html } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
2
|
+
import { property, state } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import styles from './list.scss';
|
|
5
5
|
import { ListItem } from './list-item.js';
|
|
@@ -20,6 +20,13 @@ import IndividualComponent from '@/IndividualComponent.js';
|
|
|
20
20
|
* Inbox
|
|
21
21
|
* <span slot="trailing">24</span>
|
|
22
22
|
* </wc-list-item>
|
|
23
|
+
* <wc-list-item>
|
|
24
|
+
* <wc-avatar slot="leading" name="Shivaji Varma"></wc-avatar>
|
|
25
|
+
* Shivaji Varma
|
|
26
|
+
* <span slot="supporting-text">Software Engineer</span>
|
|
27
|
+
* <span slot="trailing-supporting-text">7</span>
|
|
28
|
+
* <wc-icon slot="trailing" name="chevron_right"></wc-icon>
|
|
29
|
+
* </wc-list-item>
|
|
23
30
|
* </wc-list>
|
|
24
31
|
* ```
|
|
25
32
|
* @tags display
|
|
@@ -34,11 +41,166 @@ export class List extends LitElement {
|
|
|
34
41
|
@property({ type: String, reflect: true }) variant: 'standard' | 'segmented' =
|
|
35
42
|
'standard';
|
|
36
43
|
|
|
44
|
+
/** Index of the currently active item within the clickable items list. */
|
|
45
|
+
@state() private activeIndex = -1;
|
|
46
|
+
|
|
37
47
|
connectedCallback() {
|
|
38
48
|
super.connectedCallback();
|
|
39
49
|
this.setAttribute('role', 'list');
|
|
50
|
+
this.addEventListener('keydown', this._onKeyDown);
|
|
51
|
+
this.addEventListener('click', this._onClick);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
disconnectedCallback() {
|
|
55
|
+
this.removeEventListener('keydown', this._onKeyDown);
|
|
56
|
+
this.removeEventListener('click', this._onClick);
|
|
57
|
+
super.disconnectedCallback();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override focus() {
|
|
61
|
+
const target = this._getActiveItem() ?? this._getFirstClickableItem();
|
|
62
|
+
target?.focus();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── Items ─────────────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
get items(): ListItem[] {
|
|
68
|
+
const slot = this.shadowRoot?.querySelector('slot');
|
|
69
|
+
const elements = slot?.assignedElements({ flatten: true }) ?? [];
|
|
70
|
+
return elements.filter(el => el instanceof ListItem) as ListItem[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private _clickableItems() {
|
|
74
|
+
return this.items.filter(item => item.isClickable());
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ── Roving tabindex ───────────────────────────────────────────────────────
|
|
78
|
+
|
|
79
|
+
private _syncRovingTabIndex() {
|
|
80
|
+
const allItems = this.items;
|
|
81
|
+
const clickable = this._clickableItems();
|
|
82
|
+
|
|
83
|
+
for (const item of allItems) {
|
|
84
|
+
item.tabIndex = -1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!clickable.length) {
|
|
88
|
+
this.activeIndex = -1;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.activeIndex < 0 || this.activeIndex >= clickable.length) {
|
|
93
|
+
this.activeIndex = 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
clickable[this.activeIndex].tabIndex = 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private _setActiveByOffset(offset: 1 | -1) {
|
|
100
|
+
const clickable = this._clickableItems();
|
|
101
|
+
if (!clickable.length) return;
|
|
102
|
+
|
|
103
|
+
if (this.activeIndex < 0) {
|
|
104
|
+
this.activeIndex = 0;
|
|
105
|
+
} else {
|
|
106
|
+
const count = clickable.length;
|
|
107
|
+
this.activeIndex = (this.activeIndex + offset + count) % count;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
this._syncRovingTabIndex();
|
|
111
|
+
clickable[this.activeIndex]?.focus();
|
|
40
112
|
}
|
|
41
113
|
|
|
114
|
+
private _setBoundaryActive(index: number) {
|
|
115
|
+
const clickable = this._clickableItems();
|
|
116
|
+
if (!clickable.length) return;
|
|
117
|
+
|
|
118
|
+
this.activeIndex = index;
|
|
119
|
+
this._syncRovingTabIndex();
|
|
120
|
+
clickable[this.activeIndex]?.focus();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private _getActiveItem() {
|
|
124
|
+
const clickable = this._clickableItems();
|
|
125
|
+
if (!clickable.length || this.activeIndex < 0) return null;
|
|
126
|
+
return clickable[this.activeIndex] ?? null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private _getFirstClickableItem() {
|
|
130
|
+
return this._clickableItems()[0] ?? null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ── Event helpers ─────────────────────────────────────────────────────────
|
|
134
|
+
|
|
135
|
+
private _isEventFromThisList(event: Event) {
|
|
136
|
+
const path = event.composedPath();
|
|
137
|
+
const sourceList = path.find(target => target instanceof List);
|
|
138
|
+
return sourceList === this;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private _clickableItemFromEvent(event: Event) {
|
|
142
|
+
if (!this._isEventFromThisList(event)) return null;
|
|
143
|
+
const path = event.composedPath();
|
|
144
|
+
const clickable = this._clickableItems();
|
|
145
|
+
for (const target of path) {
|
|
146
|
+
if (target instanceof ListItem) {
|
|
147
|
+
const owned = clickable.find(item => item === target);
|
|
148
|
+
if (owned) return owned;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private _setActiveItem(item: ListItem) {
|
|
155
|
+
const clickable = this._clickableItems();
|
|
156
|
+
const nextIndex = clickable.indexOf(item);
|
|
157
|
+
if (nextIndex < 0) return;
|
|
158
|
+
this.activeIndex = nextIndex;
|
|
159
|
+
this._syncRovingTabIndex();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ── Handlers ──────────────────────────────────────────────────────────────
|
|
163
|
+
|
|
164
|
+
private _onKeyDown = (event: KeyboardEvent) => {
|
|
165
|
+
if (!this._isEventFromThisList(event)) return;
|
|
166
|
+
|
|
167
|
+
const eventItem = this._clickableItemFromEvent(event);
|
|
168
|
+
if (eventItem) {
|
|
169
|
+
this._setActiveItem(eventItem);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
switch (event.key) {
|
|
173
|
+
case 'ArrowDown':
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
this._setActiveByOffset(1);
|
|
176
|
+
break;
|
|
177
|
+
case 'ArrowUp':
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
this._setActiveByOffset(-1);
|
|
180
|
+
break;
|
|
181
|
+
case 'Home':
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
this._setBoundaryActive(0);
|
|
184
|
+
break;
|
|
185
|
+
case 'End':
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
this._setBoundaryActive(Math.max(this._clickableItems().length - 1, 0));
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
private _onClick = (event: Event) => {
|
|
195
|
+
const item = this._clickableItemFromEvent(event);
|
|
196
|
+
if (!item) return;
|
|
197
|
+
this._setActiveItem(item);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
private _onSlotChange = () => {
|
|
201
|
+
this._syncRovingTabIndex();
|
|
202
|
+
};
|
|
203
|
+
|
|
42
204
|
render() {
|
|
43
205
|
const cssClasses = {
|
|
44
206
|
list: true,
|
|
@@ -47,7 +209,7 @@ export class List extends LitElement {
|
|
|
47
209
|
|
|
48
210
|
return html`
|
|
49
211
|
<div class=${classMap(cssClasses)}>
|
|
50
|
-
<slot></slot>
|
|
212
|
+
<slot @slotchange=${this._onSlotChange}></slot>
|
|
51
213
|
</div>
|
|
52
214
|
`;
|
|
53
215
|
}
|
package/src/loader.ts
CHANGED
|
@@ -61,6 +61,7 @@ import { Tabs } from '@/tabs/tabs.js';
|
|
|
61
61
|
import { Tab } from '@/tabs/tab.js';
|
|
62
62
|
import { TabPanel } from '@/tabs/tab-panel.js';
|
|
63
63
|
import { Slider } from '@/slider/slider.js';
|
|
64
|
+
import { ColorPicker } from '@/color-picker/color-picker.js';
|
|
64
65
|
import { Table } from '@/table/table.js';
|
|
65
66
|
import { Pagination } from '@/pagination/pagination.js';
|
|
66
67
|
import { SidebarMenu } from '@/sidebar-menu/sidebar-menu.js';
|
|
@@ -315,6 +316,9 @@ const loaderConfig: LoaderConfig = {
|
|
|
315
316
|
'wc-slider': {
|
|
316
317
|
CustomElementClass: Slider,
|
|
317
318
|
},
|
|
319
|
+
'wc-color-picker': {
|
|
320
|
+
CustomElementClass: ColorPicker,
|
|
321
|
+
},
|
|
318
322
|
'wc-table': {
|
|
319
323
|
CustomElementClass: Table,
|
|
320
324
|
},
|
package/src/menu/menu/menu.scss
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
width: var(--menu-width, max-content);
|
|
10
10
|
max-width: 100vw;
|
|
11
11
|
min-width: 112px;
|
|
12
|
-
padding-block: var(--spacing-050);
|
|
13
12
|
transform-origin: top center;
|
|
14
13
|
|
|
15
14
|
--_menu-enter-duration: var(--duration-medium1);
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
.menu-content {
|
|
52
51
|
display: flex;
|
|
53
52
|
flex-direction: column;
|
|
54
|
-
gap: var(--spacing-050);
|
|
55
53
|
z-index: 1;
|
|
56
54
|
width: 100%;
|
|
57
55
|
|
|
@@ -74,8 +72,8 @@
|
|
|
74
72
|
display: block;
|
|
75
73
|
position: absolute;
|
|
76
74
|
inset: 0;
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
|
|
76
|
+
border: 1px solid var(--color-red);
|
|
79
77
|
|
|
80
78
|
border-start-start-radius: var(--_container-shape-start-start);
|
|
81
79
|
border-start-end-radius: var(--_container-shape-start-end);
|
|
@@ -83,18 +81,6 @@
|
|
|
83
81
|
border-end-end-radius: var(--_container-shape-end-end);
|
|
84
82
|
pointer-events: none;
|
|
85
83
|
}
|
|
86
|
-
|
|
87
|
-
.elevation {
|
|
88
|
-
--elevation-level: 2;
|
|
89
|
-
transition-duration: 280ms;
|
|
90
|
-
--elevation-container-shape-start-start: var(
|
|
91
|
-
--_container-shape-start-start
|
|
92
|
-
);
|
|
93
|
-
--elevation-container-shape-start-end: var(--_container-shape-start-end);
|
|
94
|
-
--elevation-container-shape-end-start: var(--_container-shape-end-start);
|
|
95
|
-
--elevation-container-shape-end-end: var(--_container-shape-end-end);
|
|
96
|
-
--elevation-container-shape-variant: var(--_container-corner-shape-variant);
|
|
97
|
-
}
|
|
98
84
|
}
|
|
99
85
|
|
|
100
86
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -111,10 +97,10 @@
|
|
|
111
97
|
--_container-shape-end-end: var(--shape-corner-large);
|
|
112
98
|
|
|
113
99
|
&.variant-standard {
|
|
114
|
-
--
|
|
100
|
+
--menu-item-container-color: var(--color-surface-container);
|
|
115
101
|
}
|
|
116
102
|
|
|
117
103
|
&.variant-vibrant {
|
|
118
|
-
--
|
|
104
|
+
--menu-item-container-color: var(--color-tertiary-container);
|
|
119
105
|
}
|
|
120
106
|
}
|
package/src/menu/menu/menu.ts
CHANGED
|
@@ -467,7 +467,6 @@ export class Menu extends LitElement {
|
|
|
467
467
|
aria-hidden=${String(!this.open)}
|
|
468
468
|
>
|
|
469
469
|
<div class="background"></div>
|
|
470
|
-
<wc-elevation class="elevation"></wc-elevation>
|
|
471
470
|
|
|
472
471
|
<div class="menu-content">
|
|
473
472
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
:host {
|
|
6
6
|
outline: none;
|
|
7
|
+
position: relative;
|
|
7
8
|
|
|
8
9
|
--menu-item-container-shape-start-start: var(--shape-corner-extra-small);
|
|
9
10
|
--menu-item-container-shape-start-end: var(--shape-corner-extra-small);
|
|
@@ -11,58 +12,87 @@
|
|
|
11
12
|
--menu-item-container-shape-end-end: var(--shape-corner-extra-small);
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
/*
|
|
16
|
+
* Reset native button/link styles
|
|
17
|
+
*/
|
|
18
|
+
.native-button {
|
|
19
|
+
@include mixin.reset-button-styles;
|
|
20
|
+
}
|
|
21
|
+
.native-link {
|
|
22
|
+
@include mixin.reset-link-styles;
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
.menu-item {
|
|
26
|
+
position: relative;
|
|
15
27
|
width: 100%;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
--item-container-shape-start-end: var(--menu-item-container-shape-start-end);
|
|
21
|
-
--item-container-shape-end-start: var(--menu-item-container-shape-end-start);
|
|
22
|
-
--item-container-shape-end-end: var(--menu-item-container-shape-end-end);
|
|
23
|
-
--item-container-shape-variant: none;
|
|
28
|
+
text-align: start;
|
|
29
|
+
padding-top: 2px;
|
|
30
|
+
padding-inline: var(--spacing-050);
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
.menu-item-background {
|
|
33
|
+
background-color: var(--menu-item-container-color);
|
|
34
|
+
position: absolute;
|
|
35
|
+
inset: 0px;
|
|
36
|
+
}
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
.menu-item-content {
|
|
39
|
+
--item-height: 1.5rem;
|
|
40
|
+
--item-multiline-height: 3rem;
|
|
41
|
+
--item-padding-inline: 10px;
|
|
42
|
+
--item-container-shape-start-start: var(
|
|
43
|
+
--menu-item-container-shape-start-start
|
|
44
|
+
);
|
|
45
|
+
--item-container-shape-start-end: var(
|
|
46
|
+
--menu-item-container-shape-start-end
|
|
47
|
+
);
|
|
48
|
+
--item-container-shape-end-start: var(
|
|
49
|
+
--menu-item-container-shape-end-start
|
|
50
|
+
);
|
|
51
|
+
--item-container-shape-end-end: var(--menu-item-container-shape-end-end);
|
|
52
|
+
--item-container-shape-variant: none;
|
|
37
53
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
--item-label-font-family: var(--typography-label-large-font-family);
|
|
55
|
+
--item-label-font-size: var(--typography-label-large-font-size);
|
|
56
|
+
--item-label-font-weight: var(--typography-label-large-font-weight);
|
|
57
|
+
--item-label-line-height: var(--typography-label-large-line-height);
|
|
58
|
+
--item-label-letter-spacing: var(--typography-label-large-letter-spacing);
|
|
43
59
|
|
|
44
|
-
|
|
45
|
-
--
|
|
46
|
-
--
|
|
47
|
-
--
|
|
48
|
-
--
|
|
49
|
-
|
|
50
|
-
--focus-ring-inset: 0px;
|
|
51
|
-
}
|
|
60
|
+
--item-label-text-color: var(--menu-item-label-color);
|
|
61
|
+
--item-leading-trailing-color: var(--menu-item-label-color);
|
|
62
|
+
--item-supporting-text-color: var(--menu-item-label-color);
|
|
63
|
+
--item-container-selected-color: var(--menu-item-container-selected-color);
|
|
64
|
+
--item-label-text-selected-color: var(--menu-item-label-selected-color);
|
|
65
|
+
--item-icon-size: var(--button-icon-size, var(--_button-icon-size));
|
|
52
66
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
.background {
|
|
68
|
+
background-color: var(--menu-item-container-color);
|
|
69
|
+
opacity: var(--_container-opacity, 1);
|
|
70
|
+
border-radius: var(--shape-corner-medium);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.focus-ring {
|
|
74
|
+
--focus-ring-container-shape-start-start: var(--shape-corner-medium);
|
|
75
|
+
--focus-ring-container-shape-start-end: var(--shape-corner-medium);
|
|
76
|
+
--focus-ring-container-shape-end-start: var(--shape-corner-medium);
|
|
77
|
+
--focus-ring-container-shape-end-end: var(--shape-corner-medium);
|
|
78
|
+
z-index: 2;
|
|
79
|
+
--focus-ring-inset: 0px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.ripple {
|
|
83
|
+
--ripple-state-opacity: var(--_container-state-opacity, 0);
|
|
84
|
+
--ripple-pressed-color: var(--_container-state-color);
|
|
85
|
+
border-radius: var(--shape-corner-medium);
|
|
86
|
+
}
|
|
58
87
|
|
|
59
|
-
|
|
60
|
-
|
|
88
|
+
.skeleton {
|
|
89
|
+
z-index: 2;
|
|
61
90
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
91
|
+
--skeleton-container-shape-start-start: var(--shape-corner-medium);
|
|
92
|
+
--skeleton-container-shape-start-end: var(--shape-corner-medium);
|
|
93
|
+
--skeleton-container-shape-end-start: var(--shape-corner-medium);
|
|
94
|
+
--skeleton-container-shape-end-end: var(--shape-corner-medium);
|
|
95
|
+
}
|
|
66
96
|
}
|
|
67
97
|
}
|
|
68
98
|
|
|
@@ -5,8 +5,9 @@ import styles from './menu-item.scss';
|
|
|
5
5
|
import colorStyles from './menu-item-colors.scss';
|
|
6
6
|
import NativeButtonMixin from '@/__internal/mixins/NativeButtonMixin.js';
|
|
7
7
|
import NativeHyperlinkMixin from '@/__internal/mixins/NativeHyperlinkMixin.js';
|
|
8
|
-
import {
|
|
8
|
+
import { isLink } from '@/__internal/utils/is-link.js';
|
|
9
9
|
import IndividualComponent from '@/IndividualComponent.js';
|
|
10
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @label Menu Item
|
|
@@ -51,7 +52,7 @@ export class MenuItem extends NativeButtonMixin(
|
|
|
51
52
|
|
|
52
53
|
// ── Queries ───────────────────────────────────────────────────────────────
|
|
53
54
|
|
|
54
|
-
@query('
|
|
55
|
+
@query('#menu-item') readonly itemElement!: HTMLElement | null;
|
|
55
56
|
|
|
56
57
|
// ── Private fields ────────────────────────────────────────────────────────
|
|
57
58
|
|
|
@@ -119,22 +120,51 @@ export class MenuItem extends NativeButtonMixin(
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
render() {
|
|
123
|
+
const isElementLink = isLink(this);
|
|
122
124
|
const controls = this.getAttribute('aria-controls');
|
|
123
125
|
|
|
126
|
+
const cssClasses = {
|
|
127
|
+
'menu-item': true,
|
|
128
|
+
'native-button': !isElementLink,
|
|
129
|
+
'native-link': isElementLink,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
if (isElementLink) {
|
|
133
|
+
return html`
|
|
134
|
+
<a
|
|
135
|
+
id="menu-item"
|
|
136
|
+
class=${classMap(cssClasses)}
|
|
137
|
+
role="menuitem"
|
|
138
|
+
href=${ifDefined(this.href)}
|
|
139
|
+
target=${this.target}
|
|
140
|
+
?rel=${this.rel}
|
|
141
|
+
?download=${this.download}
|
|
142
|
+
tabindex=${this.disabled ? '-1' : String(this.tabIndex)}
|
|
143
|
+
?selected=${this.selected}
|
|
144
|
+
aria-disabled=${this.disabled || this.softDisabled ? 'true' : nothing}
|
|
145
|
+
aria-haspopup=${this.hasSubmenu ? 'menu' : nothing}
|
|
146
|
+
aria-controls=${ifDefined(
|
|
147
|
+
this.hasSubmenu && controls ? controls : undefined,
|
|
148
|
+
)}
|
|
149
|
+
aria-expanded=${ifDefined(
|
|
150
|
+
this.hasSubmenu ? String(this.submenuOpen) : undefined,
|
|
151
|
+
)}
|
|
152
|
+
>
|
|
153
|
+
${this.renderContent()}
|
|
154
|
+
</a>
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
|
|
124
158
|
return html`
|
|
125
|
-
<
|
|
159
|
+
<button
|
|
126
160
|
id="menu-item"
|
|
127
|
-
class
|
|
161
|
+
class=${classMap(cssClasses)}
|
|
128
162
|
role="menuitem"
|
|
163
|
+
type=${this.htmlType}
|
|
164
|
+
?disabled=${this.disabled}
|
|
129
165
|
tabindex=${String(this.tabIndex)}
|
|
130
166
|
?selected=${this.selected}
|
|
131
|
-
|
|
132
|
-
.softDisabled=${this.softDisabled}
|
|
133
|
-
.htmlType=${this.htmlType}
|
|
134
|
-
.href=${this.href}
|
|
135
|
-
.target=${this.target}
|
|
136
|
-
.rel=${this.rel}
|
|
137
|
-
.download=${this.download}
|
|
167
|
+
aria-disabled=${this.softDisabled ? 'true' : nothing}
|
|
138
168
|
aria-haspopup=${this.hasSubmenu ? 'menu' : nothing}
|
|
139
169
|
aria-controls=${ifDefined(
|
|
140
170
|
this.hasSubmenu && controls ? controls : undefined,
|
|
@@ -143,6 +173,15 @@ export class MenuItem extends NativeButtonMixin(
|
|
|
143
173
|
this.hasSubmenu ? String(this.submenuOpen) : undefined,
|
|
144
174
|
)}
|
|
145
175
|
>
|
|
176
|
+
${this.renderContent()}
|
|
177
|
+
</button>
|
|
178
|
+
`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
renderContent() {
|
|
182
|
+
return html`
|
|
183
|
+
<div class="menu-item-background"></div>
|
|
184
|
+
<wc-item class="menu-item-content">
|
|
146
185
|
<wc-focus-ring
|
|
147
186
|
class="focus-ring"
|
|
148
187
|
for="menu-item"
|
|
@@ -151,23 +190,17 @@ export class MenuItem extends NativeButtonMixin(
|
|
|
151
190
|
<div class="background" slot="container"></div>
|
|
152
191
|
<wc-ripple class="ripple" for="menu-item" slot="container"></wc-ripple>
|
|
153
192
|
|
|
154
|
-
|
|
193
|
+
<slot name="start" slot="start"></slot>
|
|
194
|
+
<slot name="overline" slot="overline"></slot>
|
|
195
|
+
<slot name="headline" slot="headline"></slot>
|
|
196
|
+
<slot></slot>
|
|
197
|
+
<slot name="supporting-text" slot="supporting-text"></slot>
|
|
198
|
+
<slot
|
|
199
|
+
name="trailing-supporting-text"
|
|
200
|
+
slot="trailing-supporting-text"
|
|
201
|
+
></slot>
|
|
202
|
+
<slot name="end" slot="end"></slot>
|
|
155
203
|
</wc-item>
|
|
156
204
|
`;
|
|
157
205
|
}
|
|
158
|
-
|
|
159
|
-
renderContent() {
|
|
160
|
-
return html`
|
|
161
|
-
<slot name="start" slot="start"></slot>
|
|
162
|
-
<slot name="overline" slot="overline"></slot>
|
|
163
|
-
<slot name="headline" slot="headline"></slot>
|
|
164
|
-
<slot></slot>
|
|
165
|
-
<slot name="supporting-text" slot="supporting-text"></slot>
|
|
166
|
-
<slot
|
|
167
|
-
name="trailing-supporting-text"
|
|
168
|
-
slot="trailing-supporting-text"
|
|
169
|
-
></slot>
|
|
170
|
-
<slot name="end" slot="end"></slot>
|
|
171
|
-
`;
|
|
172
|
-
}
|
|
173
206
|
}
|
|
@@ -32,11 +32,26 @@
|
|
|
32
32
|
box-sizing: border-box;
|
|
33
33
|
|
|
34
34
|
/* Color tokens */
|
|
35
|
-
--_inactive-icon-color: var(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
--
|
|
35
|
+
--_inactive-icon-color: var(
|
|
36
|
+
--nav-rail-inactive-icon-color,
|
|
37
|
+
var(--color-on-surface-variant)
|
|
38
|
+
);
|
|
39
|
+
--_active-icon-color: var(
|
|
40
|
+
--nav-rail-active-icon-color,
|
|
41
|
+
var(--color-on-secondary-container)
|
|
42
|
+
);
|
|
43
|
+
--_inactive-label-color: var(
|
|
44
|
+
--nav-rail-inactive-label-color,
|
|
45
|
+
var(--color-on-surface-variant)
|
|
46
|
+
);
|
|
47
|
+
--_active-label-color: var(
|
|
48
|
+
--nav-rail-active-label-color,
|
|
49
|
+
var(--color-on-surface)
|
|
50
|
+
);
|
|
51
|
+
--_indicator-color: var(
|
|
52
|
+
--nav-rail-indicator-color,
|
|
53
|
+
var(--color-secondary-container)
|
|
54
|
+
);
|
|
40
55
|
--_indicator-shape: var(--nav-rail-indicator-shape, var(--shape-corner-full));
|
|
41
56
|
--_indicator-width: var(--nav-rail-indicator-width, 3.5rem); /* 56dp */
|
|
42
57
|
--_indicator-height: var(--nav-rail-indicator-height, 2rem); /* 32dp */
|
|
@@ -62,7 +77,8 @@
|
|
|
62
77
|
border-radius: var(--_indicator-shape);
|
|
63
78
|
overflow: hidden;
|
|
64
79
|
flex-shrink: 0;
|
|
65
|
-
transition: background-color var(--duration-short4, 200ms)
|
|
80
|
+
transition: background-color var(--duration-short4, 200ms)
|
|
81
|
+
var(--easing-standard, ease);
|
|
66
82
|
|
|
67
83
|
.ripple {
|
|
68
84
|
inset: 0;
|
|
@@ -95,7 +111,8 @@
|
|
|
95
111
|
text-align: center;
|
|
96
112
|
pointer-events: none;
|
|
97
113
|
z-index: 1;
|
|
98
|
-
transition:
|
|
114
|
+
transition:
|
|
115
|
+
color var(--duration-short4, 200ms) var(--easing-standard, ease),
|
|
99
116
|
font-weight var(--duration-short4, 200ms) var(--easing-standard, ease);
|
|
100
117
|
}
|
|
101
118
|
|
|
@@ -140,7 +157,7 @@
|
|
|
140
157
|
|
|
141
158
|
.label {
|
|
142
159
|
color: var(--_active-label-color);
|
|
143
|
-
font-weight: var(--
|
|
160
|
+
font-weight: var(--font-weight-bold) !important;
|
|
144
161
|
}
|
|
145
162
|
}
|
|
146
163
|
|