@spectrum-web-components/menu 0.12.2 → 0.12.4
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/package.json +8 -8
- package/sp-menu-divider.d.ts +6 -0
- package/sp-menu-divider.js +14 -0
- package/sp-menu-divider.js.map +1 -0
- package/sp-menu-group.d.ts +6 -0
- package/sp-menu-group.js +14 -0
- package/sp-menu-group.js.map +1 -0
- package/sp-menu-item.d.ts +6 -0
- package/sp-menu-item.js +14 -0
- package/sp-menu-item.js.map +1 -0
- package/sp-menu.d.ts +6 -0
- package/sp-menu.js +14 -0
- package/sp-menu.js.map +1 -0
- package/src/Menu.d.ts +104 -0
- package/src/Menu.js +625 -0
- package/src/Menu.js.map +1 -0
- package/src/MenuDivider.d.ts +8 -0
- package/src/MenuDivider.js +25 -0
- package/src/MenuDivider.js.map +1 -0
- package/src/MenuGroup.d.ts +20 -0
- package/src/MenuGroup.js +86 -0
- package/src/MenuGroup.js.map +1 -0
- package/src/MenuItem.d.ts +110 -0
- package/src/MenuItem.js +465 -0
- package/src/MenuItem.js.map +1 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +16 -0
- package/src/index.js.map +1 -0
- package/src/menu-divider.css.d.ts +2 -0
- package/src/menu-divider.css.js +19 -0
- package/src/menu-divider.css.js.map +1 -0
- package/src/menu-group.css.d.ts +2 -0
- package/src/menu-group.css.js +19 -0
- package/src/menu-group.css.js.map +1 -0
- package/src/menu-item.css.d.ts +2 -0
- package/src/menu-item.css.js +76 -0
- package/src/menu-item.css.js.map +1 -0
- package/src/menu.css.d.ts +2 -0
- package/src/menu.css.js +74 -0
- package/src/menu.css.js.map +1 -0
- package/src/spectrum-checkmark.css.d.ts +2 -0
- package/src/spectrum-checkmark.css.js +21 -0
- package/src/spectrum-checkmark.css.js.map +1 -0
- package/src/spectrum-chevron.css.d.ts +2 -0
- package/src/spectrum-chevron.css.js +21 -0
- package/src/spectrum-chevron.css.js.map +1 -0
- package/src/spectrum-itemLabel.css.d.ts +2 -0
- package/src/spectrum-itemLabel.css.js +17 -0
- package/src/spectrum-itemLabel.css.js.map +1 -0
- package/src/spectrum-menu-divider.css.d.ts +2 -0
- package/src/spectrum-menu-divider.css.js +19 -0
- package/src/spectrum-menu-divider.css.js.map +1 -0
- package/src/spectrum-menu-item.css.d.ts +2 -0
- package/src/spectrum-menu-item.css.js +68 -0
- package/src/spectrum-menu-item.css.js.map +1 -0
- package/src/spectrum-menu-sectionHeading.css.d.ts +2 -0
- package/src/spectrum-menu-sectionHeading.css.js +19 -0
- package/src/spectrum-menu-sectionHeading.css.js.map +1 -0
- package/src/spectrum-menu.css.d.ts +2 -0
- package/src/spectrum-menu.css.js +74 -0
- package/src/spectrum-menu.css.js.map +1 -0
- package/stories/menu-group.stories.js +136 -0
- package/stories/menu-group.stories.js.map +1 -0
- package/stories/menu-item.stories.js +82 -0
- package/stories/menu-item.stories.js.map +1 -0
- package/stories/menu.stories.js +247 -0
- package/stories/menu.stories.js.map +1 -0
- package/stories/submenu.stories.js +302 -0
- package/stories/submenu.stories.js.map +1 -0
package/src/MenuItem.js
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { __decorate } from "tslib";
|
|
13
|
+
import { html, } from '@spectrum-web-components/base';
|
|
14
|
+
import { property, query, } from '@spectrum-web-components/base/src/decorators.js';
|
|
15
|
+
import '@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js';
|
|
16
|
+
import { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';
|
|
17
|
+
import { Focusable } from '@spectrum-web-components/shared/src/focusable.js';
|
|
18
|
+
import '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';
|
|
19
|
+
import chevronStyles from '@spectrum-web-components/icon/src/spectrum-icon-chevron.css.js';
|
|
20
|
+
import { openOverlay } from '@spectrum-web-components/overlay/src/loader.js';
|
|
21
|
+
import menuItemStyles from './menu-item.css.js';
|
|
22
|
+
import checkmarkStyles from '@spectrum-web-components/icon/src/spectrum-icon-checkmark.css.js';
|
|
23
|
+
import { reparentChildren } from '@spectrum-web-components/shared/src/reparent-children.js';
|
|
24
|
+
/**
|
|
25
|
+
* Duration during which a pointing device can leave an `<sp-menu-item>` element
|
|
26
|
+
* and return to it or to the submenu opened from it before closing that submenu.
|
|
27
|
+
**/
|
|
28
|
+
const POINTERLEAVE_TIMEOUT = 100;
|
|
29
|
+
export class MenuItemRemovedEvent extends Event {
|
|
30
|
+
constructor() {
|
|
31
|
+
super('sp-menu-item-removed', {
|
|
32
|
+
bubbles: true,
|
|
33
|
+
composed: true,
|
|
34
|
+
});
|
|
35
|
+
this.focused = false;
|
|
36
|
+
}
|
|
37
|
+
get item() {
|
|
38
|
+
return this._item;
|
|
39
|
+
}
|
|
40
|
+
reset(item) {
|
|
41
|
+
this._item = item;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class MenuItemAddedOrUpdatedEvent extends Event {
|
|
45
|
+
constructor() {
|
|
46
|
+
super('sp-menu-item-added-or-updated', {
|
|
47
|
+
bubbles: true,
|
|
48
|
+
composed: true,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
set focusRoot(root) {
|
|
52
|
+
this.item.menuData.focusRoot = this.item.menuData.focusRoot || root;
|
|
53
|
+
}
|
|
54
|
+
set selectionRoot(root) {
|
|
55
|
+
this.item.menuData.selectionRoot =
|
|
56
|
+
this.item.menuData.selectionRoot || root;
|
|
57
|
+
}
|
|
58
|
+
get item() {
|
|
59
|
+
return this._item;
|
|
60
|
+
}
|
|
61
|
+
set currentAncestorWithSelects(ancestor) {
|
|
62
|
+
this._currentAncestorWithSelects = ancestor;
|
|
63
|
+
}
|
|
64
|
+
get currentAncestorWithSelects() {
|
|
65
|
+
return this._currentAncestorWithSelects;
|
|
66
|
+
}
|
|
67
|
+
reset(item) {
|
|
68
|
+
this._item = item;
|
|
69
|
+
this._currentAncestorWithSelects = undefined;
|
|
70
|
+
item.menuData = {
|
|
71
|
+
focusRoot: undefined,
|
|
72
|
+
selectionRoot: undefined,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const addOrUpdateEvent = new MenuItemAddedOrUpdatedEvent();
|
|
77
|
+
const removeEvent = new MenuItemRemovedEvent();
|
|
78
|
+
/**
|
|
79
|
+
* @element sp-menu-item
|
|
80
|
+
*
|
|
81
|
+
* @slot - text content to display within the Menu Item
|
|
82
|
+
* @slot icon - icon element to be placed at the start of the Menu Item
|
|
83
|
+
* @slot value - content placed at the end of the Menu Item like values, keyboard shortcuts, etc.
|
|
84
|
+
* @fires sp-menu-item-added - announces the item has been added so a parent menu can take ownerships
|
|
85
|
+
* @fires sp-menu-item-removed - announces when removed from the DOM so the parent menu can remove ownership and update selected state
|
|
86
|
+
*/
|
|
87
|
+
export class MenuItem extends LikeAnchor(Focusable) {
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
this.isInSubmenu = false;
|
|
91
|
+
this.active = false;
|
|
92
|
+
this.focused = false;
|
|
93
|
+
this.selected = false;
|
|
94
|
+
this._value = '';
|
|
95
|
+
this.hasSubmenu = false;
|
|
96
|
+
this.noWrap = false;
|
|
97
|
+
this.open = false;
|
|
98
|
+
/**
|
|
99
|
+
* When there is a `change` event in the submenu for this item
|
|
100
|
+
* then we "click" this item to cascade the selection up the
|
|
101
|
+
* menu tree allowing all submenus between the initial selection
|
|
102
|
+
* and the root of the tree to have their selection changes and
|
|
103
|
+
* be closed.
|
|
104
|
+
*/
|
|
105
|
+
this.handleSubmenuChange = () => {
|
|
106
|
+
var _a;
|
|
107
|
+
(_a = this.menuData.selectionRoot) === null || _a === void 0 ? void 0 : _a.selectOrToggleItem(this);
|
|
108
|
+
};
|
|
109
|
+
this.handleSubmenuPointerenter = () => {
|
|
110
|
+
if (this.leaveTimeout) {
|
|
111
|
+
clearTimeout(this.leaveTimeout);
|
|
112
|
+
delete this.leaveTimeout;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
this.menuData = {
|
|
116
|
+
focusRoot: undefined,
|
|
117
|
+
selectionRoot: undefined,
|
|
118
|
+
};
|
|
119
|
+
this.proxyFocus = this.proxyFocus.bind(this);
|
|
120
|
+
this.addEventListener('click', this.handleClickCapture, {
|
|
121
|
+
capture: true,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
static get styles() {
|
|
125
|
+
return [menuItemStyles, checkmarkStyles, chevronStyles];
|
|
126
|
+
}
|
|
127
|
+
get value() {
|
|
128
|
+
return this._value || this.itemText;
|
|
129
|
+
}
|
|
130
|
+
set value(value) {
|
|
131
|
+
if (value === this._value) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
this._value = value || '';
|
|
135
|
+
if (this._value) {
|
|
136
|
+
this.setAttribute('value', this._value);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.removeAttribute('value');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
get itemText() {
|
|
146
|
+
return this.itemChildren.content.reduce((acc, node) => acc + (node.textContent || '').trim(), '');
|
|
147
|
+
}
|
|
148
|
+
get focusElement() {
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
get itemChildren() {
|
|
152
|
+
if (this._itemChildren) {
|
|
153
|
+
return this._itemChildren;
|
|
154
|
+
}
|
|
155
|
+
const iconSlot = this.shadowRoot.querySelector('slot[name="icon"]');
|
|
156
|
+
const icon = !iconSlot
|
|
157
|
+
? []
|
|
158
|
+
: iconSlot.assignedElements().map((element) => {
|
|
159
|
+
const newElement = element.cloneNode(true);
|
|
160
|
+
newElement.removeAttribute('slot');
|
|
161
|
+
newElement.classList.toggle('icon');
|
|
162
|
+
return newElement;
|
|
163
|
+
});
|
|
164
|
+
const contentSlot = this.shadowRoot.querySelector('slot:not([name])');
|
|
165
|
+
const content = !contentSlot
|
|
166
|
+
? []
|
|
167
|
+
: contentSlot.assignedNodes().map((node) => node.cloneNode(true));
|
|
168
|
+
this._itemChildren = { icon, content };
|
|
169
|
+
return this._itemChildren;
|
|
170
|
+
}
|
|
171
|
+
click() {
|
|
172
|
+
if (this.disabled) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (this.shouldProxyClick()) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
super.click();
|
|
179
|
+
}
|
|
180
|
+
handleClickCapture(event) {
|
|
181
|
+
if (this.disabled) {
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
event.stopImmediatePropagation();
|
|
184
|
+
event.stopPropagation();
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
proxyFocus() {
|
|
189
|
+
this.focus();
|
|
190
|
+
}
|
|
191
|
+
shouldProxyClick() {
|
|
192
|
+
let handled = false;
|
|
193
|
+
if (this.anchorElement) {
|
|
194
|
+
this.anchorElement.click();
|
|
195
|
+
handled = true;
|
|
196
|
+
}
|
|
197
|
+
return handled;
|
|
198
|
+
}
|
|
199
|
+
breakItemChildrenCache() {
|
|
200
|
+
this._itemChildren = undefined;
|
|
201
|
+
this.triggerUpdate();
|
|
202
|
+
}
|
|
203
|
+
render() {
|
|
204
|
+
return html `
|
|
205
|
+
<slot name="icon" @slotchange=${this.breakItemChildrenCache}></slot>
|
|
206
|
+
<div id="label">
|
|
207
|
+
<slot
|
|
208
|
+
id="slot"
|
|
209
|
+
@slotchange=${this.breakItemChildrenCache}
|
|
210
|
+
></slot>
|
|
211
|
+
</div>
|
|
212
|
+
<slot name="value"></slot>
|
|
213
|
+
${this.selected
|
|
214
|
+
? html `
|
|
215
|
+
<sp-icon-checkmark100
|
|
216
|
+
id="selected"
|
|
217
|
+
class="spectrum-UIIcon-Checkmark100 icon checkmark"
|
|
218
|
+
></sp-icon-checkmark100>
|
|
219
|
+
`
|
|
220
|
+
: html ``}
|
|
221
|
+
${this.href && this.href.length > 0
|
|
222
|
+
? super.renderAnchor({
|
|
223
|
+
id: 'button',
|
|
224
|
+
ariaHidden: true,
|
|
225
|
+
className: 'button anchor hidden',
|
|
226
|
+
})
|
|
227
|
+
: html ``}
|
|
228
|
+
<slot
|
|
229
|
+
hidden
|
|
230
|
+
name="submenu"
|
|
231
|
+
@slotchange=${this.manageSubmenu}
|
|
232
|
+
></slot>
|
|
233
|
+
${this.hasSubmenu
|
|
234
|
+
? html `
|
|
235
|
+
<sp-icon-chevron100
|
|
236
|
+
class="spectrum-UIIcon-ChevronRight100 chevron icon"
|
|
237
|
+
></sp-icon-chevron100>
|
|
238
|
+
`
|
|
239
|
+
: html ``}
|
|
240
|
+
`;
|
|
241
|
+
}
|
|
242
|
+
manageSubmenu(event) {
|
|
243
|
+
const assignedElements = event.target.assignedElements({
|
|
244
|
+
flatten: true,
|
|
245
|
+
});
|
|
246
|
+
this.hasSubmenu = this.open || !!assignedElements.length;
|
|
247
|
+
}
|
|
248
|
+
handleRemoveActive(event) {
|
|
249
|
+
if ((event.type === 'pointerleave' && this.hasSubmenu) ||
|
|
250
|
+
this.hasSubmenu ||
|
|
251
|
+
this.open) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
this.active = false;
|
|
255
|
+
}
|
|
256
|
+
handlePointerdown() {
|
|
257
|
+
this.active = true;
|
|
258
|
+
}
|
|
259
|
+
firstUpdated(changes) {
|
|
260
|
+
super.firstUpdated(changes);
|
|
261
|
+
this.setAttribute('tabindex', '-1');
|
|
262
|
+
this.addEventListener('pointerdown', this.handlePointerdown);
|
|
263
|
+
if (!this.hasAttribute('id')) {
|
|
264
|
+
this.id = `sp-menu-item-${MenuItem.instanceCount++}`;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
handleSubmenuClick() {
|
|
268
|
+
this.openOverlay({ immediate: true });
|
|
269
|
+
}
|
|
270
|
+
handlePointerenter() {
|
|
271
|
+
if (this.leaveTimeout) {
|
|
272
|
+
clearTimeout(this.leaveTimeout);
|
|
273
|
+
delete this.leaveTimeout;
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
this.openOverlay();
|
|
277
|
+
}
|
|
278
|
+
handlePointerleave() {
|
|
279
|
+
if (this.hasSubmenu && this.open) {
|
|
280
|
+
this.leaveTimeout = setTimeout(() => {
|
|
281
|
+
delete this.leaveTimeout;
|
|
282
|
+
if (this.closeOverlay)
|
|
283
|
+
this.closeOverlay(true);
|
|
284
|
+
}, POINTERLEAVE_TIMEOUT);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
async openOverlay({ immediate, } = {}) {
|
|
288
|
+
var _a;
|
|
289
|
+
if (!this.hasSubmenu || this.open) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
this.open = true;
|
|
293
|
+
this.active = true;
|
|
294
|
+
const submenu = this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements()[0];
|
|
295
|
+
submenu.addEventListener('pointerenter', this.handleSubmenuPointerenter);
|
|
296
|
+
submenu.addEventListener('change', this.handleSubmenuChange);
|
|
297
|
+
const popover = document.createElement('sp-popover');
|
|
298
|
+
const returnSubmenu = reparentChildren([submenu], popover, (el) => {
|
|
299
|
+
const slotName = el.slot;
|
|
300
|
+
el.tabIndex = 0;
|
|
301
|
+
el.removeAttribute('slot');
|
|
302
|
+
return (el) => {
|
|
303
|
+
el.tabIndex = -1;
|
|
304
|
+
el.slot = slotName;
|
|
305
|
+
};
|
|
306
|
+
});
|
|
307
|
+
const closeOverlay = openOverlay(this, 'click', popover, {
|
|
308
|
+
placement: this.isLTR ? 'right-start' : 'left-start',
|
|
309
|
+
receivesFocus: 'auto',
|
|
310
|
+
delayed: !immediate && false,
|
|
311
|
+
});
|
|
312
|
+
let closing = false;
|
|
313
|
+
const closeSubmenu = async (leave = false) => {
|
|
314
|
+
var _a;
|
|
315
|
+
delete this.closeOverlay;
|
|
316
|
+
if (submenu.hasOpenSubmenu) {
|
|
317
|
+
await submenu.closeOpenSubmenu(leave);
|
|
318
|
+
}
|
|
319
|
+
if (!leave) {
|
|
320
|
+
closing = true;
|
|
321
|
+
}
|
|
322
|
+
(_a = this.menuData.focusRoot) === null || _a === void 0 ? void 0 : _a.submenuWillCloseOn(this);
|
|
323
|
+
(await closeOverlay)();
|
|
324
|
+
};
|
|
325
|
+
this.closeOverlay = closeSubmenu;
|
|
326
|
+
if ((_a = this.menuData.focusRoot) === null || _a === void 0 ? void 0 : _a.hasOpenSubmenu) {
|
|
327
|
+
this.menuData.focusRoot.closeOpenSubmenu(true);
|
|
328
|
+
}
|
|
329
|
+
const setup = () => {
|
|
330
|
+
var _a;
|
|
331
|
+
submenu.setCloseSelfAsSubmenu(closeSubmenu);
|
|
332
|
+
(_a = this.menuData.focusRoot) === null || _a === void 0 ? void 0 : _a.setCloseOpenSubmenu(closeSubmenu);
|
|
333
|
+
};
|
|
334
|
+
const cleanup = (event) => {
|
|
335
|
+
var _a, _b;
|
|
336
|
+
event.stopPropagation();
|
|
337
|
+
returnSubmenu();
|
|
338
|
+
submenu.setCloseSelfAsSubmenu(closeSubmenu);
|
|
339
|
+
(_a = this.menuData.focusRoot) === null || _a === void 0 ? void 0 : _a.setCloseOpenSubmenu(closeSubmenu);
|
|
340
|
+
this.open = false;
|
|
341
|
+
this.active = false;
|
|
342
|
+
if (closing || event.detail.reason === 'external-click') {
|
|
343
|
+
(_b = this.menuData.focusRoot) === null || _b === void 0 ? void 0 : _b.dispatchEvent(new CustomEvent('close', {
|
|
344
|
+
bubbles: true,
|
|
345
|
+
composed: true,
|
|
346
|
+
detail: { reason: 'external-click' },
|
|
347
|
+
}));
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
this.addEventListener('sp-opened', setup, {
|
|
351
|
+
once: true,
|
|
352
|
+
});
|
|
353
|
+
this.addEventListener('sp-closed', cleanup, {
|
|
354
|
+
once: true,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
updateAriaSelected() {
|
|
358
|
+
const role = this.getAttribute('role');
|
|
359
|
+
if (role === 'option') {
|
|
360
|
+
this.setAttribute('aria-selected', this.selected ? 'true' : 'false');
|
|
361
|
+
}
|
|
362
|
+
else if (role === 'menuitemcheckbox' || role === 'menuitemradio') {
|
|
363
|
+
this.setAttribute('aria-checked', this.selected ? 'true' : 'false');
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
setRole(role) {
|
|
367
|
+
this.setAttribute('role', role);
|
|
368
|
+
this.updateAriaSelected();
|
|
369
|
+
}
|
|
370
|
+
updated(changes) {
|
|
371
|
+
super.updated(changes);
|
|
372
|
+
if (changes.has('label')) {
|
|
373
|
+
this.setAttribute('aria-label', this.label || '');
|
|
374
|
+
}
|
|
375
|
+
if (changes.has('active')) {
|
|
376
|
+
if (this.active) {
|
|
377
|
+
this.addEventListener('pointerup', this.handleRemoveActive);
|
|
378
|
+
this.addEventListener('pointerleave', this.handleRemoveActive);
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
this.removeEventListener('pointerup', this.handleRemoveActive);
|
|
382
|
+
this.removeEventListener('pointerleave', this.handleRemoveActive);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (this.anchorElement) {
|
|
386
|
+
this.anchorElement.addEventListener('focus', this.proxyFocus);
|
|
387
|
+
this.anchorElement.tabIndex = -1;
|
|
388
|
+
}
|
|
389
|
+
if (changes.has('selected')) {
|
|
390
|
+
this.updateAriaSelected();
|
|
391
|
+
}
|
|
392
|
+
if (changes.has('hasSubmenu')) {
|
|
393
|
+
if (this.hasSubmenu) {
|
|
394
|
+
this.addEventListener('click', this.handleSubmenuClick);
|
|
395
|
+
this.addEventListener('pointerenter', this.handlePointerenter);
|
|
396
|
+
this.addEventListener('pointerleave', this.handlePointerleave);
|
|
397
|
+
}
|
|
398
|
+
else if (!this.closeOverlay) {
|
|
399
|
+
this.removeEventListener('click', this.handleSubmenuClick);
|
|
400
|
+
this.removeEventListener('pointerenter', this.handlePointerenter);
|
|
401
|
+
this.removeEventListener('pointerleave', this.handlePointerleave);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
connectedCallback() {
|
|
406
|
+
super.connectedCallback();
|
|
407
|
+
this.isInSubmenu = !!this.closest('[slot="submenu"]');
|
|
408
|
+
if (this.isInSubmenu) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
addOrUpdateEvent.reset(this);
|
|
412
|
+
this.dispatchEvent(addOrUpdateEvent);
|
|
413
|
+
this._parentElement = this.parentElement;
|
|
414
|
+
}
|
|
415
|
+
disconnectedCallback() {
|
|
416
|
+
var _a;
|
|
417
|
+
removeEvent.reset(this);
|
|
418
|
+
if (!this.isInSubmenu) {
|
|
419
|
+
(_a = this._parentElement) === null || _a === void 0 ? void 0 : _a.dispatchEvent(removeEvent);
|
|
420
|
+
}
|
|
421
|
+
this.isInSubmenu = false;
|
|
422
|
+
super.disconnectedCallback();
|
|
423
|
+
}
|
|
424
|
+
async triggerUpdate() {
|
|
425
|
+
if (this.isInSubmenu) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
await new Promise((ready) => requestAnimationFrame(ready));
|
|
429
|
+
addOrUpdateEvent.reset(this);
|
|
430
|
+
this.dispatchEvent(addOrUpdateEvent);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
MenuItem.instanceCount = 0;
|
|
434
|
+
__decorate([
|
|
435
|
+
property({ type: Boolean, reflect: true })
|
|
436
|
+
], MenuItem.prototype, "active", void 0);
|
|
437
|
+
__decorate([
|
|
438
|
+
property({ type: Boolean, reflect: true })
|
|
439
|
+
], MenuItem.prototype, "focused", void 0);
|
|
440
|
+
__decorate([
|
|
441
|
+
property({ type: Boolean, reflect: true })
|
|
442
|
+
], MenuItem.prototype, "selected", void 0);
|
|
443
|
+
__decorate([
|
|
444
|
+
property({ type: String })
|
|
445
|
+
], MenuItem.prototype, "value", null);
|
|
446
|
+
__decorate([
|
|
447
|
+
property({ type: Boolean })
|
|
448
|
+
], MenuItem.prototype, "hasSubmenu", void 0);
|
|
449
|
+
__decorate([
|
|
450
|
+
property({
|
|
451
|
+
type: Boolean,
|
|
452
|
+
reflect: true,
|
|
453
|
+
attribute: 'no-wrap',
|
|
454
|
+
hasChanged() {
|
|
455
|
+
return false;
|
|
456
|
+
},
|
|
457
|
+
})
|
|
458
|
+
], MenuItem.prototype, "noWrap", void 0);
|
|
459
|
+
__decorate([
|
|
460
|
+
query('.anchor')
|
|
461
|
+
], MenuItem.prototype, "anchorElement", void 0);
|
|
462
|
+
__decorate([
|
|
463
|
+
property({ type: Boolean })
|
|
464
|
+
], MenuItem.prototype, "open", void 0);
|
|
465
|
+
//# sourceMappingURL=MenuItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuItem.js","sourceRoot":"","sources":["MenuItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;;AAEF,OAAO,EAEH,IAAI,GAGP,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,QAAQ,EACR,KAAK,GACR,MAAM,iDAAiD,CAAC;AAEzD,OAAO,iEAAiE,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAC7E,OAAO,+DAA+D,CAAC;AACvE,OAAO,aAAa,MAAM,gEAAgE,CAAC;AAC3F,OAA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Q,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACF;AAU1B;IARC,QAAQ,CAAC;QACN,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,SAAS;QACpB,UAAU;YACN,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;wCACoB;AAGtB;IADC,KAAK,CAAC,SAAS,CAAC;+CACyB;AA6C1C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sCACR","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js';\nimport { LikeAnchor } from '@spectrum-web-components/shared/src/like-anchor.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-chevron100.js';\nimport chevronStyles from '@spectrum-web-components/icon/src/spectrum-icon-chevron.css.js';\nimport { openOverlay } from '@spectrum-web-components/overlay/src/loader.js';\n\nimport menuItemStyles from './menu-item.css.js';\nimport checkmarkStyles from '@spectrum-web-components/icon/src/spectrum-icon-checkmark.css.js';\nimport type { Menu } from './Menu.js';\nimport type { OverlayOpenCloseDetail } from '@spectrum-web-components/overlay';\nimport { reparentChildren } from '@spectrum-web-components/shared/src/reparent-children.js';\n\n/**\n * Duration during which a pointing device can leave an `<sp-menu-item>` element\n * and return to it or to the submenu opened from it before closing that submenu.\n **/\nconst POINTERLEAVE_TIMEOUT = 100;\n\nexport class MenuItemRemovedEvent extends Event {\n constructor() {\n super('sp-menu-item-removed', {\n bubbles: true,\n composed: true,\n });\n }\n get item(): MenuItem {\n return this._item;\n }\n _item!: MenuItem;\n focused = false;\n reset(item: MenuItem): void {\n this._item = item;\n }\n}\n\nexport class MenuItemAddedOrUpdatedEvent extends Event {\n constructor() {\n super('sp-menu-item-added-or-updated', {\n bubbles: true,\n composed: true,\n });\n }\n set focusRoot(root: Menu | undefined) {\n this.item.menuData.focusRoot = this.item.menuData.focusRoot || root;\n }\n set selectionRoot(root: Menu) {\n this.item.menuData.selectionRoot =\n this.item.menuData.selectionRoot || root;\n }\n get item(): MenuItem {\n return this._item;\n }\n _item!: MenuItem;\n set currentAncestorWithSelects(ancestor: Menu | undefined) {\n this._currentAncestorWithSelects = ancestor;\n }\n get currentAncestorWithSelects(): Menu | undefined {\n return this._currentAncestorWithSelects;\n }\n _currentAncestorWithSelects?: Menu;\n reset(item: MenuItem): void {\n this._item = item;\n this._currentAncestorWithSelects = undefined;\n item.menuData = {\n focusRoot: undefined,\n selectionRoot: undefined,\n };\n }\n}\n\nexport type MenuItemChildren = { icon: Element[]; content: Node[] };\n\nconst addOrUpdateEvent = new MenuItemAddedOrUpdatedEvent();\nconst removeEvent = new MenuItemRemovedEvent();\n\n/**\n * @element sp-menu-item\n *\n * @slot - text content to display within the Menu Item\n * @slot icon - icon element to be placed at the start of the Menu Item\n * @slot value - content placed at the end of the Menu Item like values, keyboard shortcuts, etc.\n * @fires sp-menu-item-added - announces the item has been added so a parent menu can take ownerships\n * @fires sp-menu-item-removed - announces when removed from the DOM so the parent menu can remove ownership and update selected state\n */\nexport class MenuItem extends LikeAnchor(Focusable) {\n public static get styles(): CSSResultArray {\n return [menuItemStyles, checkmarkStyles, chevronStyles];\n }\n\n static instanceCount = 0;\n\n private isInSubmenu = false;\n\n @property({ type: Boolean, reflect: true })\n public active = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @property({ type: Boolean, reflect: true })\n public selected = false;\n\n @property({ type: String })\n public get value(): string {\n return this._value || this.itemText;\n }\n\n public set value(value: string) {\n if (value === this._value) {\n return;\n }\n this._value = value || '';\n if (this._value) {\n this.setAttribute('value', this._value);\n } else {\n this.removeAttribute('value');\n }\n }\n\n private _value = '';\n\n /**\n * @private\n */\n public get itemText(): string {\n return this.itemChildren.content.reduce(\n (acc, node) => acc + (node.textContent || '').trim(),\n ''\n );\n }\n\n @property({ type: Boolean })\n public hasSubmenu = false;\n\n @property({\n type: Boolean,\n reflect: true,\n attribute: 'no-wrap',\n hasChanged() {\n return false;\n },\n })\n public noWrap = false;\n\n @query('.anchor')\n private anchorElement!: HTMLAnchorElement;\n\n public get focusElement(): HTMLElement {\n return this;\n }\n\n public get itemChildren(): MenuItemChildren {\n if (this._itemChildren) {\n return this._itemChildren;\n }\n\n const iconSlot = this.shadowRoot.querySelector(\n 'slot[name=\"icon\"]'\n ) as HTMLSlotElement;\n const icon = !iconSlot\n ? []\n : iconSlot.assignedElements().map((element) => {\n const newElement = element.cloneNode(true) as HTMLElement;\n newElement.removeAttribute('slot');\n newElement.classList.toggle('icon');\n return newElement;\n });\n const contentSlot = this.shadowRoot.querySelector(\n 'slot:not([name])'\n ) as HTMLSlotElement;\n const content = !contentSlot\n ? []\n : contentSlot.assignedNodes().map((node) => node.cloneNode(true));\n this._itemChildren = { icon, content };\n\n return this._itemChildren;\n }\n\n private _itemChildren?: MenuItemChildren;\n\n constructor() {\n super();\n this.proxyFocus = this.proxyFocus.bind(this);\n\n this.addEventListener('click', this.handleClickCapture, {\n capture: true,\n });\n }\n\n @property({ type: Boolean })\n public open = false;\n\n public click(): void {\n if (this.disabled) {\n return;\n }\n\n if (this.shouldProxyClick()) {\n return;\n }\n\n super.click();\n }\n\n private handleClickCapture(event: Event): void | boolean {\n if (this.disabled) {\n event.preventDefault();\n event.stopImmediatePropagation();\n event.stopPropagation();\n return false;\n }\n }\n\n private proxyFocus(): void {\n this.focus();\n }\n\n private shouldProxyClick(): boolean {\n let handled = false;\n if (this.anchorElement) {\n this.anchorElement.click();\n handled = true;\n }\n return handled;\n }\n\n protected breakItemChildrenCache(): void {\n this._itemChildren = undefined;\n this.triggerUpdate();\n }\n\n protected render(): TemplateResult {\n return html`\n <slot name=\"icon\" @slotchange=${this.breakItemChildrenCache}></slot>\n <div id=\"label\">\n <slot\n id=\"slot\"\n @slotchange=${this.breakItemChildrenCache}\n ></slot>\n </div>\n <slot name=\"value\"></slot>\n ${this.selected\n ? html`\n <sp-icon-checkmark100\n id=\"selected\"\n class=\"spectrum-UIIcon-Checkmark100 icon checkmark\"\n ></sp-icon-checkmark100>\n `\n : html``}\n ${this.href && this.href.length > 0\n ? super.renderAnchor({\n id: 'button',\n ariaHidden: true,\n className: 'button anchor hidden',\n })\n : html``}\n <slot\n hidden\n name=\"submenu\"\n @slotchange=${this.manageSubmenu}\n ></slot>\n ${this.hasSubmenu\n ? html`\n <sp-icon-chevron100\n class=\"spectrum-UIIcon-ChevronRight100 chevron icon\"\n ></sp-icon-chevron100>\n `\n : html``}\n `;\n }\n\n protected manageSubmenu(event: Event & { target: HTMLSlotElement }): void {\n const assignedElements = event.target.assignedElements({\n flatten: true,\n });\n this.hasSubmenu = this.open || !!assignedElements.length;\n }\n\n private handleRemoveActive(event: Event): void {\n if (\n (event.type === 'pointerleave' && this.hasSubmenu) ||\n this.hasSubmenu ||\n this.open\n ) {\n return;\n }\n this.active = false;\n }\n\n private handlePointerdown(): void {\n this.active = true;\n }\n\n protected firstUpdated(changes: PropertyValues): void {\n super.firstUpdated(changes);\n this.setAttribute('tabindex', '-1');\n this.addEventListener('pointerdown', this.handlePointerdown);\n if (!this.hasAttribute('id')) {\n this.id = `sp-menu-item-${MenuItem.instanceCount++}`;\n }\n }\n\n public closeOverlay?: (leave?: boolean) => Promise<void>;\n\n protected handleSubmenuClick(): void {\n this.openOverlay({ immediate: true });\n }\n\n protected handlePointerenter(): void {\n if (this.leaveTimeout) {\n clearTimeout(this.leaveTimeout);\n delete this.leaveTimeout;\n return;\n }\n this.openOverlay();\n }\n\n protected leaveTimeout?: ReturnType<typeof setTimeout>;\n\n protected handlePointerleave(): void {\n if (this.hasSubmenu && this.open) {\n this.leaveTimeout = setTimeout(() => {\n delete this.leaveTimeout;\n if (this.closeOverlay) this.closeOverlay(true);\n }, POINTERLEAVE_TIMEOUT);\n }\n }\n\n /**\n * When there is a `change` event in the submenu for this item\n * then we \"click\" this item to cascade the selection up the\n * menu tree allowing all submenus between the initial selection\n * and the root of the tree to have their selection changes and\n * be closed.\n */\n protected handleSubmenuChange = (): void => {\n this.menuData.selectionRoot?.selectOrToggleItem(this);\n };\n\n protected handleSubmenuPointerenter = (): void => {\n if (this.leaveTimeout) {\n clearTimeout(this.leaveTimeout);\n delete this.leaveTimeout;\n }\n };\n\n public async openOverlay({\n immediate,\n }: { immediate?: boolean } = {}): Promise<void> {\n if (!this.hasSubmenu || this.open) {\n return;\n }\n this.open = true;\n this.active = true;\n const submenu = (\n this.shadowRoot.querySelector(\n 'slot[name=\"submenu\"]'\n ) as HTMLSlotElement\n ).assignedElements()[0] as Menu;\n submenu.addEventListener(\n 'pointerenter',\n this.handleSubmenuPointerenter\n );\n submenu.addEventListener('change', this.handleSubmenuChange);\n const popover = document.createElement('sp-popover');\n const returnSubmenu = reparentChildren([submenu], popover, (el) => {\n const slotName = el.slot;\n el.tabIndex = 0;\n el.removeAttribute('slot');\n return (el) => {\n el.tabIndex = -1;\n el.slot = slotName;\n };\n });\n const closeOverlay = openOverlay(this, 'click', popover, {\n placement: this.isLTR ? 'right-start' : 'left-start',\n receivesFocus: 'auto',\n delayed: !immediate && false,\n });\n let closing = false;\n const closeSubmenu = async (leave = false): Promise<void> => {\n delete this.closeOverlay;\n if (submenu.hasOpenSubmenu) {\n await submenu.closeOpenSubmenu(leave);\n }\n if (!leave) {\n closing = true;\n }\n this.menuData.focusRoot?.submenuWillCloseOn(this);\n (await closeOverlay)();\n };\n this.closeOverlay = closeSubmenu;\n if (this.menuData.focusRoot?.hasOpenSubmenu) {\n this.menuData.focusRoot.closeOpenSubmenu(true);\n }\n const setup = (): void => {\n submenu.setCloseSelfAsSubmenu(closeSubmenu);\n this.menuData.focusRoot?.setCloseOpenSubmenu(closeSubmenu);\n };\n const cleanup = (event: CustomEvent<OverlayOpenCloseDetail>): void => {\n event.stopPropagation();\n returnSubmenu();\n submenu.setCloseSelfAsSubmenu(closeSubmenu);\n this.menuData.focusRoot?.setCloseOpenSubmenu(closeSubmenu);\n this.open = false;\n this.active = false;\n if (closing || event.detail.reason === 'external-click') {\n this.menuData.focusRoot?.dispatchEvent(\n new CustomEvent('close', {\n bubbles: true,\n composed: true,\n detail: { reason: 'external-click' },\n })\n );\n }\n };\n this.addEventListener('sp-opened', setup as EventListener, {\n once: true,\n });\n this.addEventListener('sp-closed', cleanup as EventListener, {\n once: true,\n });\n }\n\n updateAriaSelected(): void {\n const role = this.getAttribute('role');\n if (role === 'option') {\n this.setAttribute(\n 'aria-selected',\n this.selected ? 'true' : 'false'\n );\n } else if (role === 'menuitemcheckbox' || role === 'menuitemradio') {\n this.setAttribute('aria-checked', this.selected ? 'true' : 'false');\n }\n }\n\n public setRole(role: string): void {\n this.setAttribute('role', role);\n this.updateAriaSelected();\n }\n\n protected updated(changes: PropertyValues<this>): void {\n super.updated(changes);\n if (changes.has('label')) {\n this.setAttribute('aria-label', this.label || '');\n }\n if (changes.has('active')) {\n if (this.active) {\n this.addEventListener('pointerup', this.handleRemoveActive);\n this.addEventListener('pointerleave', this.handleRemoveActive);\n } else {\n this.removeEventListener('pointerup', this.handleRemoveActive);\n this.removeEventListener(\n 'pointerleave',\n this.handleRemoveActive\n );\n }\n }\n if (this.anchorElement) {\n this.anchorElement.addEventListener('focus', this.proxyFocus);\n this.anchorElement.tabIndex = -1;\n }\n if (changes.has('selected')) {\n this.updateAriaSelected();\n }\n if (changes.has('hasSubmenu')) {\n if (this.hasSubmenu) {\n this.addEventListener('click', this.handleSubmenuClick);\n this.addEventListener('pointerenter', this.handlePointerenter);\n this.addEventListener('pointerleave', this.handlePointerleave);\n } else if (!this.closeOverlay) {\n this.removeEventListener('click', this.handleSubmenuClick);\n this.removeEventListener(\n 'pointerenter',\n this.handlePointerenter\n );\n this.removeEventListener(\n 'pointerleave',\n this.handlePointerleave\n );\n }\n }\n }\n\n public connectedCallback(): void {\n super.connectedCallback();\n this.isInSubmenu = !!this.closest('[slot=\"submenu\"]');\n if (this.isInSubmenu) {\n return;\n }\n addOrUpdateEvent.reset(this);\n this.dispatchEvent(addOrUpdateEvent);\n this._parentElement = this.parentElement as HTMLElement;\n }\n\n _parentElement!: HTMLElement;\n\n public disconnectedCallback(): void {\n removeEvent.reset(this);\n if (!this.isInSubmenu) {\n this._parentElement?.dispatchEvent(removeEvent);\n }\n this.isInSubmenu = false;\n super.disconnectedCallback();\n }\n\n public async triggerUpdate(): Promise<void> {\n if (this.isInSubmenu) {\n return;\n }\n await new Promise((ready) => requestAnimationFrame(ready));\n addOrUpdateEvent.reset(this);\n this.dispatchEvent(addOrUpdateEvent);\n }\n\n public menuData: {\n focusRoot?: Menu;\n selectionRoot?: Menu;\n } = {\n focusRoot: undefined,\n selectionRoot: undefined,\n };\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'sp-menu-item-added-or-updated': MenuItemAddedOrUpdatedEvent;\n 'sp-menu-item-removed': MenuItemRemovedEvent;\n }\n}\n"]}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export * from './Menu.js';
|
|
13
|
+
export * from './MenuDivider.js';
|
|
14
|
+
export * from './MenuGroup.js';
|
|
15
|
+
export * from './MenuItem.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Menu.js';\nexport * from './MenuDivider.js';\nexport * from './MenuGroup.js';\nexport * from './MenuItem.js';\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
:host{border:none;box-sizing:content-box;height:var(--spectrum-listitem-texticon-divider-size);margin:calc(var(--spectrum-listitem-texticon-divider-padding)/2) var(--spectrum-listitem-texticon-padding-y);overflow:visible;padding:0}:host{background-color:var(
|
|
15
|
+
--spectrum-listitem-m-texticon-divider-color,var(--spectrum-alias-border-color-extralight)
|
|
16
|
+
)}:host{display:block}
|
|
17
|
+
`;
|
|
18
|
+
export default styles;
|
|
19
|
+
//# sourceMappingURL=menu-divider.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-divider.css.js","sourceRoot":"","sources":["menu-divider.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;CAIjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{border:none;box-sizing:content-box;height:var(--spectrum-listitem-texticon-divider-size);margin:calc(var(--spectrum-listitem-texticon-divider-padding)/2) var(--spectrum-listitem-texticon-padding-y);overflow:visible;padding:0}:host{background-color:var(\n--spectrum-listitem-m-texticon-divider-color,var(--spectrum-alias-border-color-extralight)\n)}:host{display:block}\n`;\nexport default styles;"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { css } from '@spectrum-web-components/base';
|
|
13
|
+
const styles = css `
|
|
14
|
+
.header{color:var(--spectrum-listheading-text-color);display:block;font-size:var(--spectrum-listitem-texticon-heading-text-size);font-weight:var(--spectrum-listitem-texticon-heading-text-font-weight);letter-spacing:var(
|
|
15
|
+
--spectrum-listitem-texticon-heading-letter-spacing
|
|
16
|
+
);line-height:var(--spectrum-listitem-texticon-heading-line-height);margin:var(--spectrum-listitem-texticon-heading-margin);padding:var(--spectrum-listitem-texticon-heading-padding);text-transform:var(--spectrum-listitem-texticon-heading-text-transform)}:host{display:inline-flex;flex-direction:column;margin:0;overflow:visible}:host([dir=ltr]) .header{padding:0 var(--spectrum-global-dimension-size-450) 0 var(--spectrum-global-dimension-size-150)}:host([dir=rtl]) .header{padding:0 var(--spectrum-global-dimension-size-150) 0 var(--spectrum-global-dimension-size-450)}sp-menu{--swc-menu-width:100%}:host(:last-child) sp-menu{margin-bottom:0}:host(:first-child) .header[hidden]+sp-menu{margin-top:0}[hidden]{display:none!important}
|
|
17
|
+
`;
|
|
18
|
+
export default styles;
|
|
19
|
+
//# sourceMappingURL=menu-group.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu-group.css.js","sourceRoot":"","sources":["menu-group.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;CAIjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n.header{color:var(--spectrum-listheading-text-color);display:block;font-size:var(--spectrum-listitem-texticon-heading-text-size);font-weight:var(--spectrum-listitem-texticon-heading-text-font-weight);letter-spacing:var(\n--spectrum-listitem-texticon-heading-letter-spacing\n);line-height:var(--spectrum-listitem-texticon-heading-line-height);margin:var(--spectrum-listitem-texticon-heading-margin);padding:var(--spectrum-listitem-texticon-heading-padding);text-transform:var(--spectrum-listitem-texticon-heading-text-transform)}:host{display:inline-flex;flex-direction:column;margin:0;overflow:visible}:host([dir=ltr]) .header{padding:0 var(--spectrum-global-dimension-size-450) 0 var(--spectrum-global-dimension-size-150)}:host([dir=rtl]) .header{padding:0 var(--spectrum-global-dimension-size-150) 0 var(--spectrum-global-dimension-size-450)}sp-menu{--swc-menu-width:100%}:host(:last-child) sp-menu{margin-bottom:0}:host(:first-child) .header[hidden]+sp-menu{margin-top:0}[hidden]{display:none!important}\n`;\nexport default styles;"]}
|