@fluentui/web-components 3.0.0-beta.32 → 3.0.0-beta.34
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/CHANGELOG.md +20 -2
- package/dist/dts/menu/menu.d.ts +55 -39
- package/dist/dts/menu-item/menu-item.d.ts +11 -57
- package/dist/dts/menu-list/menu-list.d.ts +5 -10
- package/dist/esm/menu/menu.js +98 -127
- package/dist/esm/menu/menu.js.map +1 -1
- package/dist/esm/menu/menu.styles.js +22 -8
- package/dist/esm/menu/menu.styles.js.map +1 -1
- package/dist/esm/menu/menu.template.js +3 -10
- package/dist/esm/menu/menu.template.js.map +1 -1
- package/dist/esm/menu-item/menu-item.js +59 -121
- package/dist/esm/menu-item/menu-item.js.map +1 -1
- package/dist/esm/menu-item/menu-item.styles.js +88 -116
- package/dist/esm/menu-item/menu-item.styles.js.map +1 -1
- package/dist/esm/menu-item/menu-item.template.js +17 -47
- package/dist/esm/menu-item/menu-item.template.js.map +1 -1
- package/dist/esm/menu-list/menu-list.js +12 -48
- package/dist/esm/menu-list/menu-list.js.map +1 -1
- package/dist/web-components.d.ts +71 -106
- package/dist/web-components.js +119 -1209
- package/dist/web-components.min.js +337 -334
- package/package.json +5 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { keyArrowLeft, keyArrowRight, keyEnter, keyEscape, keySpace } from '@microsoft/fast-web-utilities';
|
|
2
|
+
import { attr, FASTElement, observable } from '@microsoft/fast-element';
|
|
3
|
+
import { keyArrowLeft, keyArrowRight, keyEnter, keySpace } from '@microsoft/fast-web-utilities';
|
|
5
4
|
import { StartEnd } from '../patterns/start-end.js';
|
|
6
5
|
import { applyMixins } from '../utils/apply-mixins.js';
|
|
7
6
|
import { MenuItemRole, roleForMenuItem } from './menu-item.options.js';
|
|
@@ -10,21 +9,13 @@ export { MenuItemRole, roleForMenuItem };
|
|
|
10
9
|
* A Switch Custom HTML Element.
|
|
11
10
|
* Implements {@link https://www.w3.org/TR/wai-aria-1.1/#menuitem | ARIA menuitem }, {@link https://www.w3.org/TR/wai-aria-1.1/#menuitemcheckbox | ARIA menuitemcheckbox}, or {@link https://www.w3.org/TR/wai-aria-1.1/#menuitemradio | ARIA menuitemradio }.
|
|
12
11
|
*
|
|
13
|
-
* @slot
|
|
14
|
-
* @slot radio-indicator - The radio indicator
|
|
12
|
+
* @slot indicator - The checkbox or radio indicator
|
|
15
13
|
* @slot start - Content which can be provided before the menu item content
|
|
16
|
-
* @slot end - Content which can be provided after the menu item content
|
|
17
14
|
* @slot - The default slot for menu item content
|
|
18
|
-
* @slot
|
|
15
|
+
* @slot end - Content which can be provided after the menu item content
|
|
16
|
+
* @slot submenu-glyph - The submenu expand/collapse indicator
|
|
19
17
|
* @slot submenu - Used to nest menu's within menu items
|
|
20
|
-
* @csspart input-container - The element representing the visual checked or radio indicator
|
|
21
|
-
* @csspart checkbox - The element wrapping the `menuitemcheckbox` indicator
|
|
22
|
-
* @csspart radio - The element wrapping the `menuitemradio` indicator
|
|
23
18
|
* @csspart content - The element wrapping the menu item content
|
|
24
|
-
* @csspart expand-collapse-glyph-container - The element wrapping the expand collapse element
|
|
25
|
-
* @csspart expand-collapse - The expand/collapse element
|
|
26
|
-
* @csspart submenu-region - The container for the submenu, used for positioning
|
|
27
|
-
* @fires expanded-change - Fires a custom 'expanded-change' event when the expanded state changes
|
|
28
19
|
* @fires change - Fires a custom 'change' event when a non-submenu item with a role of `menuitemcheckbox`, `menuitemradio`, or `menuitem` is invoked
|
|
29
20
|
*
|
|
30
21
|
* @public
|
|
@@ -48,11 +39,11 @@ export class MenuItem extends FASTElement {
|
|
|
48
39
|
* HTML Attribute: checked
|
|
49
40
|
*/
|
|
50
41
|
this.checked = false;
|
|
51
|
-
this.focusSubmenuOnLoad = false;
|
|
52
42
|
/**
|
|
53
43
|
* @internal
|
|
54
44
|
*/
|
|
55
45
|
this.handleMenuItemKeyDown = (e) => {
|
|
46
|
+
var _a, _b, _c;
|
|
56
47
|
if (e.defaultPrevented) {
|
|
57
48
|
return false;
|
|
58
49
|
}
|
|
@@ -63,21 +54,17 @@ export class MenuItem extends FASTElement {
|
|
|
63
54
|
return false;
|
|
64
55
|
case keyArrowRight:
|
|
65
56
|
//open/focus on submenu
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// close submenu
|
|
70
|
-
if (this.expanded) {
|
|
71
|
-
this.closeSubMenu();
|
|
72
|
-
return false;
|
|
57
|
+
if (!this.disabled) {
|
|
58
|
+
(_a = this.submenu) === null || _a === void 0 ? void 0 : _a.togglePopover(true);
|
|
59
|
+
(_b = this.submenu) === null || _b === void 0 ? void 0 : _b.focus();
|
|
73
60
|
}
|
|
74
|
-
|
|
61
|
+
return false;
|
|
75
62
|
case keyArrowLeft:
|
|
76
63
|
//close submenu
|
|
77
|
-
if (this.
|
|
78
|
-
this.
|
|
79
|
-
return false;
|
|
64
|
+
if ((_c = this.parentElement) === null || _c === void 0 ? void 0 : _c.hasAttribute('popover')) {
|
|
65
|
+
this.parentElement.togglePopover(false);
|
|
80
66
|
}
|
|
67
|
+
return false;
|
|
81
68
|
}
|
|
82
69
|
return true;
|
|
83
70
|
};
|
|
@@ -91,56 +78,42 @@ export class MenuItem extends FASTElement {
|
|
|
91
78
|
this.invoke();
|
|
92
79
|
return false;
|
|
93
80
|
};
|
|
94
|
-
/**
|
|
95
|
-
* @internal
|
|
96
|
-
*/
|
|
97
|
-
this.submenuLoaded = () => {
|
|
98
|
-
if (!this.focusSubmenuOnLoad) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
this.focusSubmenuOnLoad = false;
|
|
102
|
-
if (this.submenu) {
|
|
103
|
-
this.submenu.focus();
|
|
104
|
-
this.setAttribute('tabindex', '-1');
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
81
|
/**
|
|
108
82
|
* @internal
|
|
109
83
|
*/
|
|
110
84
|
this.handleMouseOver = (e) => {
|
|
111
|
-
|
|
85
|
+
var _a;
|
|
86
|
+
if (this.disabled) {
|
|
112
87
|
return false;
|
|
113
88
|
}
|
|
114
|
-
this.
|
|
89
|
+
(_a = this.submenu) === null || _a === void 0 ? void 0 : _a.togglePopover(true);
|
|
115
90
|
return false;
|
|
116
91
|
};
|
|
117
92
|
/**
|
|
118
93
|
* @internal
|
|
119
94
|
*/
|
|
120
95
|
this.handleMouseOut = (e) => {
|
|
121
|
-
|
|
96
|
+
var _a;
|
|
97
|
+
if (this.contains(document.activeElement)) {
|
|
122
98
|
return false;
|
|
123
99
|
}
|
|
124
|
-
this.
|
|
100
|
+
(_a = this.submenu) === null || _a === void 0 ? void 0 : _a.togglePopover(false);
|
|
125
101
|
return false;
|
|
126
102
|
};
|
|
127
103
|
/**
|
|
104
|
+
* Setup required ARIA on open/close
|
|
128
105
|
* @internal
|
|
129
106
|
*/
|
|
130
|
-
this.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (!this.hasSubmenu) {
|
|
140
|
-
return;
|
|
107
|
+
this.toggleHandler = (e) => {
|
|
108
|
+
if (e instanceof ToggleEvent && e.newState === 'open') {
|
|
109
|
+
this.setAttribute('tabindex', '-1');
|
|
110
|
+
this.setAttribute('aria-expanded', 'true');
|
|
111
|
+
this.setSubmenuPosition();
|
|
112
|
+
}
|
|
113
|
+
if (e instanceof ToggleEvent && e.newState === 'closed') {
|
|
114
|
+
this.setAttribute('aria-expanded', 'false');
|
|
115
|
+
this.setAttribute('tabindex', '0');
|
|
141
116
|
}
|
|
142
|
-
this.focusSubmenuOnLoad = true;
|
|
143
|
-
this.expanded = true;
|
|
144
117
|
};
|
|
145
118
|
/**
|
|
146
119
|
* @internal
|
|
@@ -154,8 +127,9 @@ export class MenuItem extends FASTElement {
|
|
|
154
127
|
this.checked = !this.checked;
|
|
155
128
|
break;
|
|
156
129
|
case MenuItemRole.menuitem:
|
|
157
|
-
if (this.
|
|
158
|
-
this.
|
|
130
|
+
if (!!this.submenu) {
|
|
131
|
+
this.submenu.togglePopover(true);
|
|
132
|
+
this.submenu.focus();
|
|
159
133
|
break;
|
|
160
134
|
}
|
|
161
135
|
this.$emit('change');
|
|
@@ -167,90 +141,54 @@ export class MenuItem extends FASTElement {
|
|
|
167
141
|
break;
|
|
168
142
|
}
|
|
169
143
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Set fallback position of menu on open when CSS anchor not supported
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
this.setSubmenuPosition = () => {
|
|
149
|
+
if (!CSS.supports('anchor-name', '--anchor') && !!this.submenu) {
|
|
150
|
+
const thisRect = this.getBoundingClientRect();
|
|
151
|
+
const thisSubmenuRect = this.submenu.getBoundingClientRect();
|
|
152
|
+
const inlineEnd = getComputedStyle(this).direction === 'ltr' ? 'right' : 'left';
|
|
153
|
+
// If an open submenu is too wide for the viewport, move it above.
|
|
154
|
+
if (thisRect.width + thisSubmenuRect.width > window.innerWidth * 0.75) {
|
|
155
|
+
this.submenu.style.translate = '0 -100%';
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// If the open submenu is overflows the inline-end of the window (e.g. justify-content: end),
|
|
159
|
+
// move to inline-start of menu item
|
|
160
|
+
if (thisRect[inlineEnd] + thisSubmenuRect.width > window.innerWidth) {
|
|
161
|
+
this.submenu.style.translate = '-100% 0';
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
// Default to inline-end of menu item
|
|
165
|
+
this.submenu.style.translate = `${thisRect.width - 8}px 0`;
|
|
175
166
|
}
|
|
176
|
-
|
|
177
|
-
}
|
|
167
|
+
};
|
|
178
168
|
}
|
|
179
169
|
checkedChanged(oldValue, newValue) {
|
|
180
170
|
if (this.$fastController.isConnected) {
|
|
181
171
|
this.$emit('change');
|
|
182
172
|
}
|
|
183
173
|
}
|
|
184
|
-
/**
|
|
185
|
-
* @internal
|
|
186
|
-
*/
|
|
187
|
-
get hasSubmenu() {
|
|
188
|
-
return !!this.submenu;
|
|
189
|
-
}
|
|
190
174
|
/**
|
|
191
175
|
* Sets the submenu and updates its position.
|
|
192
176
|
*
|
|
193
177
|
* @internal
|
|
194
178
|
*/
|
|
195
179
|
slottedSubmenuChanged(prev, next) {
|
|
180
|
+
var _a;
|
|
181
|
+
(_a = this.submenu) === null || _a === void 0 ? void 0 : _a.removeEventListener('toggle', this.toggleHandler);
|
|
196
182
|
if (next.length) {
|
|
197
183
|
this.submenu = next[0];
|
|
198
|
-
this.
|
|
184
|
+
this.submenu.toggleAttribute('popover', true);
|
|
185
|
+
this.submenu.addEventListener('toggle', this.toggleHandler);
|
|
199
186
|
}
|
|
200
187
|
}
|
|
201
|
-
/**
|
|
202
|
-
* @internal
|
|
203
|
-
*/
|
|
204
|
-
disconnectedCallback() {
|
|
205
|
-
var _a;
|
|
206
|
-
(_a = this.cleanup) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
207
|
-
super.disconnectedCallback();
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Calculate and apply submenu positioning.
|
|
211
|
-
*
|
|
212
|
-
* @public
|
|
213
|
-
*/
|
|
214
|
-
updateSubmenu() {
|
|
215
|
-
var _a;
|
|
216
|
-
(_a = this.cleanup) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
217
|
-
if (!this.submenu || !this.expanded) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
Updates.enqueue(() => {
|
|
221
|
-
this.cleanup = autoUpdate(this, this.submenuContainer, async () => {
|
|
222
|
-
const fallbackPlacements = ['left-start', 'right-start'];
|
|
223
|
-
const { x, y } = await computePosition(this, this.submenuContainer, {
|
|
224
|
-
middleware: [
|
|
225
|
-
shift(),
|
|
226
|
-
size({
|
|
227
|
-
apply: ({ availableWidth, rects }) => {
|
|
228
|
-
if (availableWidth < rects.floating.width) {
|
|
229
|
-
fallbackPlacements.push('bottom-end', 'top-end');
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
}),
|
|
233
|
-
flip({ fallbackPlacements }),
|
|
234
|
-
],
|
|
235
|
-
placement: 'right-start',
|
|
236
|
-
strategy: 'fixed',
|
|
237
|
-
});
|
|
238
|
-
Object.assign(this.submenuContainer.style, {
|
|
239
|
-
left: `${x}px`,
|
|
240
|
-
position: 'fixed',
|
|
241
|
-
top: `${y}px`,
|
|
242
|
-
});
|
|
243
|
-
this.submenuLoaded();
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
188
|
}
|
|
248
189
|
__decorate([
|
|
249
190
|
attr({ mode: 'boolean' })
|
|
250
191
|
], MenuItem.prototype, "disabled", void 0);
|
|
251
|
-
__decorate([
|
|
252
|
-
attr({ mode: 'boolean' })
|
|
253
|
-
], MenuItem.prototype, "expanded", void 0);
|
|
254
192
|
__decorate([
|
|
255
193
|
attr
|
|
256
194
|
], MenuItem.prototype, "role", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["../../../src/menu-item/menu-item.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"menu-item.js","sourceRoot":"","sources":["../../../src/menu-item/menu-item.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAGhG,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIvE,OAAO,EAA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C;oBACzC,OAAO;iBACR;gBAED,qCAAqC;gBACrC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC;aAC5D;QACH,CAAC,CAAC;IACJ,CAAC;IA/LW,cAAc,CAAC,QAAiB,EAAE,QAAiB;QAC3D,IAAI,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE;YACpC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACtB;IACH,CAAC;IAoBD;;;;OAIG;IACO,qBAAqB,CAAC,IAA+B,EAAE,IAAmB;;QAClF,MAAA,IAAI,CAAC,OAAO,0CAAE,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAEhE,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC9C,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;SAC7D;IACH,CAAC;CA0JF;AApNC;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;0CACA;AAU1B;IADC,IAAI;sCAC6C;AAUlD;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;yCACM;AAehC;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;wCACF;AAQxB;IADC,UAAU;gDAC2B;AAqBtC;IADC,UAAU;yCAC6B;AA8J1C,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css } from '@microsoft/fast-element';
|
|
2
|
-
import { display } from '../utils/index.js';
|
|
3
|
-
import { borderRadiusMedium, colorCompoundBrandForeground1Hover, colorCompoundBrandForeground1Pressed, colorNeutralBackground1, colorNeutralBackground1Hover, colorNeutralBackground1Selected, colorNeutralBackgroundDisabled, colorNeutralForeground2, colorNeutralForeground2Hover, colorNeutralForeground2Pressed, colorNeutralForeground3, colorNeutralForegroundDisabled, fontFamilyBase, fontSizeBase200, fontSizeBase300,
|
|
2
|
+
import { display, forcedColorsStylesheetBehavior } from '../utils/index.js';
|
|
3
|
+
import { borderRadiusMedium, colorCompoundBrandForeground1Hover, colorCompoundBrandForeground1Pressed, colorNeutralBackground1, colorNeutralBackground1Hover, colorNeutralBackground1Selected, colorNeutralBackgroundDisabled, colorNeutralForeground2, colorNeutralForeground2Hover, colorNeutralForeground2Pressed, colorNeutralForeground3, colorNeutralForegroundDisabled, colorStrokeFocus2, fontFamilyBase, fontSizeBase200, fontSizeBase300, fontWeightRegular, lineHeightBase200, lineHeightBase300, } from '../theme/design-tokens.js';
|
|
4
4
|
/** MenuItem styles
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
@@ -8,76 +8,25 @@ export const styles = css `
|
|
|
8
8
|
${display('grid')}
|
|
9
9
|
|
|
10
10
|
:host {
|
|
11
|
-
|
|
11
|
+
--indent: 0;
|
|
12
12
|
align-items: center;
|
|
13
|
-
grid-gap: 4px;
|
|
14
|
-
height: 32px;
|
|
15
13
|
background: ${colorNeutralBackground1};
|
|
16
|
-
font: ${fontWeightRegular} ${fontSizeBase300} / ${lineHeightBase300} ${fontFamilyBase};
|
|
17
14
|
border-radius: ${borderRadiusMedium};
|
|
18
15
|
color: ${colorNeutralForeground2};
|
|
19
|
-
|
|
16
|
+
contain: layout;
|
|
20
17
|
cursor: pointer;
|
|
18
|
+
/* Prevent shrinking of MenuItems when max-height is applied to MenuList */
|
|
19
|
+
flex-shrink: 0;
|
|
20
|
+
font: ${fontWeightRegular} ${fontSizeBase300} / ${lineHeightBase300} ${fontFamilyBase};
|
|
21
|
+
grid-gap: 4px;
|
|
22
|
+
grid-template-columns: 20px 20px auto 20px;
|
|
23
|
+
height: 32px;
|
|
21
24
|
overflow: visible;
|
|
22
|
-
|
|
25
|
+
padding: 0 10px;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
:host(:hover) {
|
|
26
29
|
background: ${colorNeutralBackground1Hover};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.content {
|
|
30
|
-
white-space: nowrap;
|
|
31
|
-
flex-grow: 1;
|
|
32
|
-
grid-column: auto / span 2;
|
|
33
|
-
padding: 0 2px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.checkbox,
|
|
37
|
-
.radio {
|
|
38
|
-
display: none;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.input-container,
|
|
42
|
-
.expand-collapse-glyph-container,
|
|
43
|
-
::slotted([slot='start']),
|
|
44
|
-
::slotted([slot='end']),
|
|
45
|
-
:host([checked]) .checkbox,
|
|
46
|
-
:host([checked]) .radio {
|
|
47
|
-
display: inline-flex;
|
|
48
|
-
justify-content: center;
|
|
49
|
-
align-items: center;
|
|
50
|
-
color: ${colorNeutralForeground2};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.expand-collapse-glyph-container,
|
|
54
|
-
::slotted([slot='start']),
|
|
55
|
-
::slotted([slot='end']) {
|
|
56
|
-
height: 32px;
|
|
57
|
-
font-size: ${fontSizeBase500};
|
|
58
|
-
width: fit-content;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.input-container {
|
|
62
|
-
width: 20px;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
::slotted([slot='end']) {
|
|
66
|
-
color: ${colorNeutralForeground3};
|
|
67
|
-
font: ${fontWeightRegular} ${fontSizeBase200} / ${lineHeightBase200} ${fontFamilyBase};
|
|
68
|
-
white-space: nowrap;
|
|
69
|
-
grid-column: 4 / span 1;
|
|
70
|
-
justify-self: flex-end;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.expand-collapse-glyph-container {
|
|
74
|
-
grid-column: 4 / span 1;
|
|
75
|
-
justify-self: flex-end;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
:host(:hover) .input-container,
|
|
79
|
-
:host(:hover) .expand-collapse-glyph-container,
|
|
80
|
-
:host(:hover) .content {
|
|
81
30
|
color: ${colorNeutralForeground2Hover};
|
|
82
31
|
}
|
|
83
32
|
|
|
@@ -87,11 +36,6 @@ export const styles = css `
|
|
|
87
36
|
|
|
88
37
|
:host(:active) {
|
|
89
38
|
background-color: ${colorNeutralBackground1Selected};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
:host(:active) .input-container,
|
|
93
|
-
:host(:active) .expand-collapse-glyph-container,
|
|
94
|
-
:host(:active) .content {
|
|
95
39
|
color: ${colorNeutralForeground2Pressed};
|
|
96
40
|
}
|
|
97
41
|
|
|
@@ -101,67 +45,48 @@ export const styles = css `
|
|
|
101
45
|
|
|
102
46
|
:host([disabled]) {
|
|
103
47
|
background-color: ${colorNeutralBackgroundDisabled};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
:host([disabled]) .content,
|
|
107
|
-
:host([disabled]) .expand-collapse-glyph-container,
|
|
108
|
-
:host([disabled]) ::slotted([slot='end']),
|
|
109
|
-
:host([disabled]) ::slotted([slot='start']) {
|
|
110
48
|
color: ${colorNeutralForegroundDisabled};
|
|
111
49
|
}
|
|
112
50
|
|
|
113
|
-
:host([
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
:host([data-indent='1']) .content {
|
|
118
|
-
grid-column: 2 / span 1;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
:host([data-indent='1'][role='menuitemcheckbox']) {
|
|
122
|
-
display: grid;
|
|
51
|
+
:host([disabled]) ::slotted([slot='start']),
|
|
52
|
+
:host([disabled]) ::slotted([slot='end']) {
|
|
53
|
+
color: ${colorNeutralForegroundDisabled};
|
|
123
54
|
}
|
|
124
55
|
|
|
125
|
-
:host(
|
|
126
|
-
|
|
56
|
+
:host(:focus-visible) {
|
|
57
|
+
border-radius: ${borderRadiusMedium};
|
|
58
|
+
outline: 2px solid ${colorStrokeFocus2};
|
|
127
59
|
}
|
|
128
60
|
|
|
129
|
-
|
|
130
|
-
|
|
61
|
+
.content {
|
|
62
|
+
white-space: nowrap;
|
|
63
|
+
flex-grow: 1;
|
|
64
|
+
grid-column: auto / span 2;
|
|
65
|
+
padding: 0 2px;
|
|
131
66
|
}
|
|
132
67
|
|
|
133
|
-
:host([
|
|
134
|
-
|
|
68
|
+
:host(:not([checked])) .indicator,
|
|
69
|
+
:host(:not([checked])) ::slotted([slot='indicator']),
|
|
70
|
+
:host(:not([aria-haspopup='menu'])) .submenu-glyph,
|
|
71
|
+
:host(:not([aria-haspopup='menu'])) ::slotted([slot='submenu-glyph']) {
|
|
72
|
+
display: none;
|
|
135
73
|
}
|
|
136
74
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
75
|
+
::slotted([slot='end']) {
|
|
76
|
+
color: ${colorNeutralForeground3};
|
|
77
|
+
font: ${fontWeightRegular} ${fontSizeBase200} / ${lineHeightBase200} ${fontFamilyBase};
|
|
78
|
+
white-space: nowrap;
|
|
140
79
|
}
|
|
141
80
|
|
|
142
|
-
:host([
|
|
143
|
-
|
|
144
|
-
grid-column: 4 / span 1;
|
|
145
|
-
justify-self: flex-end;
|
|
81
|
+
:host([data-indent='1']) {
|
|
82
|
+
--indent: 1;
|
|
146
83
|
}
|
|
147
84
|
|
|
148
85
|
:host([data-indent='2']) {
|
|
149
|
-
|
|
86
|
+
--indent: 2;
|
|
150
87
|
grid-template-columns: 20px 20px auto auto;
|
|
151
88
|
}
|
|
152
89
|
|
|
153
|
-
:host([data-indent='2']) .content {
|
|
154
|
-
grid-column: 3 / span 1;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
:host([data-indent='2']) .input-container {
|
|
158
|
-
grid-column: 1 / span 1;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
:host([data-indent='2']) ::slotted([slot='start']) {
|
|
162
|
-
grid-column: 2 / span 1;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
90
|
:host([aria-haspopup='menu']) {
|
|
166
91
|
grid-template-columns: 20px auto auto 20px;
|
|
167
92
|
}
|
|
@@ -170,14 +95,61 @@ export const styles = css `
|
|
|
170
95
|
grid-template-columns: 20px 20px auto auto 20px;
|
|
171
96
|
}
|
|
172
97
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
98
|
+
.indicator,
|
|
99
|
+
::slotted([slot='indicator']) {
|
|
100
|
+
grid-column: 1 / span 1;
|
|
101
|
+
width: 20px;
|
|
176
102
|
}
|
|
177
103
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
104
|
+
::slotted([slot='start']) {
|
|
105
|
+
display: inline-flex;
|
|
106
|
+
grid-column: calc(var(--indent)) / span 1;
|
|
181
107
|
}
|
|
182
|
-
|
|
108
|
+
|
|
109
|
+
.content {
|
|
110
|
+
grid-column: calc(var(--indent) + 1) / span 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
::slotted([slot='end']) {
|
|
114
|
+
grid-column: calc(var(--indent) + 2) / span 1;
|
|
115
|
+
justify-self: end;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.submenu-glyph,
|
|
119
|
+
::slotted([slot='submenu-glyph']) {
|
|
120
|
+
grid-column: -2 / span 1;
|
|
121
|
+
justify-self: end;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@layer popover {
|
|
125
|
+
:host {
|
|
126
|
+
anchor-name: --menu-trigger;
|
|
127
|
+
position: relative;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
::slotted([popover]) {
|
|
131
|
+
inset-area: inline-end span-block-end;
|
|
132
|
+
margin: 0;
|
|
133
|
+
max-height: var(--menu-max-height, auto);
|
|
134
|
+
position: absolute;
|
|
135
|
+
position-anchor: --menu-trigger;
|
|
136
|
+
position-try-options: flip-inline, inset-area(block-start);
|
|
137
|
+
z-index: 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
::slotted([popover]:not(:popover-open)) {
|
|
141
|
+
display: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
::slotted([popover]:popover-open) {
|
|
145
|
+
inset: unset;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
`.withBehaviors(forcedColorsStylesheetBehavior(css `
|
|
149
|
+
:host([disabled]),
|
|
150
|
+
:host([disabled]) ::slotted([slot='start']),
|
|
151
|
+
:host([disabled]) ::slotted([slot='end']) {
|
|
152
|
+
color: GrayText;
|
|
153
|
+
}
|
|
154
|
+
`));
|
|
183
155
|
//# sourceMappingURL=menu-item.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-item.styles.js","sourceRoot":"","sources":["../../../src/menu-item/menu-item.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"menu-item.styles.js","sourceRoot":"","sources":["../../../src/menu-item/menu-item.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,kCAAkC,EAClC,oCAAoC,EACpC,uBAAuB,EACvB,4BAA4B,EAC5B,+BAA+B,EAC/B,8BAA8B,EAC9B,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,uBAAuB,EACvB,8BAA8B,EAC9B,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;IACrB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