@deepfuture/dui-components 0.0.12 → 0.0.13
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/_deprecated/center/center.js +2 -2
- package/_deprecated/hstack/hstack.js +79 -33
- package/_deprecated/page-inset/page-inset.js +104 -56
- package/_deprecated/vstack/vstack.js +61 -19
- package/accordion/accordion-item.js +217 -147
- package/accordion/accordion.js +214 -149
- package/alert-dialog/alert-dialog-close.js +2 -2
- package/alert-dialog/alert-dialog-popup.js +230 -166
- package/alert-dialog/alert-dialog-trigger.js +2 -2
- package/alert-dialog/alert-dialog.js +128 -73
- package/avatar/avatar.js +175 -115
- package/badge/badge.js +2 -2
- package/breadcrumb/breadcrumb-ellipsis.js +2 -2
- package/breadcrumb/breadcrumb-item.js +2 -2
- package/breadcrumb/breadcrumb-link.js +2 -2
- package/breadcrumb/breadcrumb-page.js +2 -2
- package/breadcrumb/breadcrumb-separator.js +2 -2
- package/breadcrumb/breadcrumb.js +2 -2
- package/button/button.js +109 -65
- package/calendar/calendar.js +368 -290
- package/checkbox/checkbox-group.js +146 -87
- package/checkbox/checkbox.js +232 -167
- package/collapsible/collapsible.js +210 -132
- package/combobox/combobox.js +318 -252
- package/command/command-empty.js +67 -25
- package/command/command-group.js +87 -47
- package/command/command-input.js +84 -44
- package/command/command-item.js +168 -124
- package/command/command-list.js +60 -18
- package/command/command-separator.js +2 -2
- package/command/command-shortcut.js +2 -2
- package/command/command.js +297 -232
- package/data-table/data-table.js +225 -153
- package/dialog/dialog-close.js +2 -2
- package/dialog/dialog-popup.js +247 -181
- package/dialog/dialog-trigger.js +2 -2
- package/dialog/dialog.js +128 -73
- package/dropzone/dropzone.js +310 -249
- package/icon/icon.js +2 -2
- package/input/input.js +204 -143
- package/link/link.js +62 -24
- package/menu/menu-item.js +66 -24
- package/menu/menu.js +189 -136
- package/menubar/menubar.js +142 -91
- package/number-field/number-field.js +277 -204
- package/package.json +2 -2
- package/popover/popover-close.js +2 -2
- package/popover/popover-popup.js +126 -76
- package/popover/popover-trigger.js +2 -2
- package/popover/popover.js +181 -120
- package/portal/portal.js +128 -86
- package/preview-card/preview-card-popup.js +114 -66
- package/preview-card/preview-card-trigger.js +2 -2
- package/preview-card/preview-card.js +211 -142
- package/progress/progress.js +91 -45
- package/radio/radio-group.js +153 -90
- package/radio/radio.js +137 -94
- package/scroll-area/scroll-area.js +382 -283
- package/select/select.js +260 -203
- package/separator/separator.js +60 -18
- package/sidebar/sidebar-content.js +2 -2
- package/sidebar/sidebar-footer.js +2 -2
- package/sidebar/sidebar-group-label.js +2 -2
- package/sidebar/sidebar-group.js +2 -2
- package/sidebar/sidebar-header.js +2 -2
- package/sidebar/sidebar-inset.js +2 -2
- package/sidebar/sidebar-menu-button.js +118 -74
- package/sidebar/sidebar-menu-item.js +2 -2
- package/sidebar/sidebar-menu.js +2 -2
- package/sidebar/sidebar-provider.js +202 -129
- package/sidebar/sidebar-separator.js +2 -2
- package/sidebar/sidebar-trigger.js +2 -2
- package/sidebar/sidebar.js +150 -85
- package/slider/slider.js +217 -159
- package/spinner/spinner.js +70 -28
- package/switch/switch.js +174 -111
- package/tabs/tab.js +89 -47
- package/tabs/tabs-indicator.js +2 -2
- package/tabs/tabs-list.js +92 -54
- package/tabs/tabs-panel.js +90 -44
- package/tabs/tabs.js +130 -71
- package/textarea/textarea.js +153 -95
- package/toggle/toggle-group.js +184 -125
- package/toggle/toggle.js +131 -76
- package/toolbar/toolbar.js +79 -33
- package/tooltip/tooltip-popup.js +108 -60
- package/tooltip/tooltip-trigger.js +93 -55
- package/tooltip/tooltip.js +225 -154
- package/trunc/trunc.js +78 -34
package/menu/menu.js
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
/** Ported from original DUI: deep-future-app/app/client/components/dui/menu */
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
+
};
|
|
2
40
|
import { css, html, LitElement } from "lit";
|
|
41
|
+
import { state } from "lit/decorators.js";
|
|
3
42
|
import { base } from "@deepfuture/dui-core/base";
|
|
4
43
|
import { FloatingPortalController } from "@deepfuture/dui-core/floating-portal-controller";
|
|
5
44
|
import { DuiMenuItem } from "./menu-item.js";
|
|
@@ -39,31 +78,43 @@ const portalPopupStyles = [
|
|
|
39
78
|
* @slot trigger - The element that opens the menu on click.
|
|
40
79
|
* @slot default - `dui-menu-item` children rendered inside the popup.
|
|
41
80
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
81
|
+
let DuiMenu = (() => {
|
|
82
|
+
let _classSuper = LitElement;
|
|
83
|
+
let _private_highlightedIndex_decorators;
|
|
84
|
+
let _private_highlightedIndex_initializers = [];
|
|
85
|
+
let _private_highlightedIndex_extraInitializers = [];
|
|
86
|
+
let _private_highlightedIndex_descriptor;
|
|
87
|
+
return class DuiMenu extends _classSuper {
|
|
88
|
+
static {
|
|
89
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
90
|
+
_private_highlightedIndex_decorators = [state()];
|
|
91
|
+
__esDecorate(this, _private_highlightedIndex_descriptor = { get: __setFunctionName(function () { return this.#highlightedIndex_accessor_storage; }, "#highlightedIndex", "get"), set: __setFunctionName(function (value) { this.#highlightedIndex_accessor_storage = value; }, "#highlightedIndex", "set") }, _private_highlightedIndex_decorators, { kind: "accessor", name: "#highlightedIndex", static: false, private: true, access: { has: obj => #highlightedIndex in obj, get: obj => obj.#highlightedIndex, set: (obj, value) => { obj.#highlightedIndex = value; } }, metadata: _metadata }, _private_highlightedIndex_initializers, _private_highlightedIndex_extraInitializers);
|
|
92
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
93
|
+
}
|
|
94
|
+
static tagName = "dui-menu";
|
|
95
|
+
static styles = [base, hostStyles, componentStyles];
|
|
96
|
+
#highlightedIndex_accessor_storage = __runInitializers(this, _private_highlightedIndex_initializers, -1);
|
|
97
|
+
get #highlightedIndex() { return _private_highlightedIndex_descriptor.get.call(this); }
|
|
98
|
+
set #highlightedIndex(value) { return _private_highlightedIndex_descriptor.set.call(this, value); }
|
|
99
|
+
#getTriggerElement = (__runInitializers(this, _private_highlightedIndex_extraInitializers), () => {
|
|
100
|
+
const slot = this.shadowRoot?.querySelector('slot[name="trigger"]');
|
|
101
|
+
return slot?.assignedElements()?.[0];
|
|
102
|
+
});
|
|
103
|
+
#popup = new FloatingPortalController(this, {
|
|
104
|
+
getAnchor: () => this.#getTriggerElement() ?? this,
|
|
105
|
+
matchWidth: false,
|
|
106
|
+
styles: portalPopupStyles,
|
|
107
|
+
contentContainer: ".Menu",
|
|
108
|
+
contentSelector: "dui-menu-item",
|
|
109
|
+
onOpen: () => {
|
|
110
|
+
this.#highlightedIndex = -1;
|
|
111
|
+
this.#getTriggerElement()?.setAttribute("data-open", "");
|
|
112
|
+
},
|
|
113
|
+
onClose: () => {
|
|
114
|
+
this.#highlightedIndex = -1;
|
|
115
|
+
this.#getTriggerElement()?.removeAttribute("data-open");
|
|
116
|
+
},
|
|
117
|
+
renderPopup: (portal) => html `
|
|
67
118
|
<div
|
|
68
119
|
class="Popup"
|
|
69
120
|
?data-starting-style="${portal.isStarting}"
|
|
@@ -78,130 +129,130 @@ export class DuiMenu extends LitElement {
|
|
|
78
129
|
></div>
|
|
79
130
|
</div>
|
|
80
131
|
`,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
updated() {
|
|
88
|
-
const items = this.#items;
|
|
89
|
-
for (let i = 0; i < items.length; i++) {
|
|
90
|
-
if (i === this.#highlightedIndex) {
|
|
91
|
-
items[i].setAttribute("data-highlighted", "");
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
items[i].removeAttribute("data-highlighted");
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
#togglePopup() {
|
|
99
|
-
if (this.#popup.isOpen) {
|
|
100
|
-
this.#popup.close();
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
this.#popup.open();
|
|
132
|
+
});
|
|
133
|
+
#menuId = `menu-${crypto.randomUUID().slice(0, 8)}`;
|
|
134
|
+
get #items() {
|
|
135
|
+
const container = this.#popup.renderRoot?.querySelector(".Menu") ?? this;
|
|
136
|
+
return [...container.querySelectorAll("dui-menu-item")];
|
|
104
137
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
#onItemSlotClick = (event) => {
|
|
112
|
-
const item = event
|
|
113
|
-
.composedPath()
|
|
114
|
-
.find((el) => el instanceof HTMLElement && el.matches(DuiMenuItem.tagName));
|
|
115
|
-
if (item && !item.disabled) {
|
|
116
|
-
this.#popup.close();
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
#onKeyDown = (event) => {
|
|
120
|
-
const items = this.#items;
|
|
121
|
-
switch (event.key) {
|
|
122
|
-
case "ArrowDown": {
|
|
123
|
-
event.preventDefault();
|
|
124
|
-
if (!this.#popup.isOpen) {
|
|
125
|
-
this.#popup.open();
|
|
138
|
+
updated() {
|
|
139
|
+
const items = this.#items;
|
|
140
|
+
for (let i = 0; i < items.length; i++) {
|
|
141
|
+
if (i === this.#highlightedIndex) {
|
|
142
|
+
items[i].setAttribute("data-highlighted", "");
|
|
126
143
|
}
|
|
127
144
|
else {
|
|
128
|
-
|
|
129
|
-
while (next < items.length && items[next]?.disabled)
|
|
130
|
-
next++;
|
|
131
|
-
if (next < items.length)
|
|
132
|
-
this.#highlightedIndex = next;
|
|
145
|
+
items[i].removeAttribute("data-highlighted");
|
|
133
146
|
}
|
|
134
|
-
break;
|
|
135
147
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
while (prev >= 0 && items[prev]?.disabled)
|
|
144
|
-
prev--;
|
|
145
|
-
if (prev >= 0)
|
|
146
|
-
this.#highlightedIndex = prev;
|
|
147
|
-
}
|
|
148
|
-
break;
|
|
148
|
+
}
|
|
149
|
+
#togglePopup() {
|
|
150
|
+
if (this.#popup.isOpen) {
|
|
151
|
+
this.#popup.close();
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
this.#popup.open();
|
|
149
155
|
}
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
}
|
|
157
|
+
#onTriggerClick = (event) => {
|
|
158
|
+
event.stopPropagation();
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
this.#togglePopup();
|
|
161
|
+
};
|
|
162
|
+
#onItemSlotClick = (event) => {
|
|
163
|
+
const item = event
|
|
164
|
+
.composedPath()
|
|
165
|
+
.find((el) => el instanceof HTMLElement && el.matches(DuiMenuItem.tagName));
|
|
166
|
+
if (item && !item.disabled) {
|
|
167
|
+
this.#popup.close();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
#onKeyDown = (event) => {
|
|
171
|
+
const items = this.#items;
|
|
172
|
+
switch (event.key) {
|
|
173
|
+
case "ArrowDown": {
|
|
152
174
|
event.preventDefault();
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
175
|
+
if (!this.#popup.isOpen) {
|
|
176
|
+
this.#popup.open();
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
let next = this.#highlightedIndex + 1;
|
|
180
|
+
while (next < items.length && items[next]?.disabled)
|
|
181
|
+
next++;
|
|
182
|
+
if (next < items.length)
|
|
183
|
+
this.#highlightedIndex = next;
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
156
186
|
}
|
|
157
|
-
|
|
158
|
-
case "End":
|
|
159
|
-
if (this.#popup.isOpen) {
|
|
187
|
+
case "ArrowUp": {
|
|
160
188
|
event.preventDefault();
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
189
|
+
if (!this.#popup.isOpen) {
|
|
190
|
+
this.#popup.open();
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
let prev = this.#highlightedIndex - 1;
|
|
194
|
+
while (prev >= 0 && items[prev]?.disabled)
|
|
195
|
+
prev--;
|
|
196
|
+
if (prev >= 0)
|
|
197
|
+
this.#highlightedIndex = prev;
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case "Home":
|
|
202
|
+
if (this.#popup.isOpen) {
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
const firstEnabled = items.findIndex((item) => !item.disabled);
|
|
205
|
+
if (firstEnabled >= 0)
|
|
206
|
+
this.#highlightedIndex = firstEnabled;
|
|
207
|
+
}
|
|
208
|
+
break;
|
|
209
|
+
case "End":
|
|
210
|
+
if (this.#popup.isOpen) {
|
|
211
|
+
event.preventDefault();
|
|
212
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
213
|
+
if (!items[i]?.disabled) {
|
|
214
|
+
this.#highlightedIndex = i;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case "Enter":
|
|
221
|
+
case " ": {
|
|
222
|
+
if (this.#popup.isOpen && this.#highlightedIndex >= 0) {
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
const item = items[this.#highlightedIndex];
|
|
225
|
+
if (item && !item.disabled) {
|
|
226
|
+
item.click();
|
|
227
|
+
this.#popup.close();
|
|
165
228
|
}
|
|
166
229
|
}
|
|
230
|
+
else if (!this.#popup.isOpen) {
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
this.#popup.open();
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
167
235
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
if (this.#popup.isOpen && this.#highlightedIndex >= 0) {
|
|
172
|
-
event.preventDefault();
|
|
173
|
-
const item = items[this.#highlightedIndex];
|
|
174
|
-
if (item && !item.disabled) {
|
|
175
|
-
item.click();
|
|
236
|
+
case "Escape":
|
|
237
|
+
if (this.#popup.isOpen) {
|
|
238
|
+
event.preventDefault();
|
|
176
239
|
this.#popup.close();
|
|
177
240
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
241
|
+
break;
|
|
242
|
+
case "Tab":
|
|
243
|
+
if (this.#popup.isOpen) {
|
|
244
|
+
this.#popup.close();
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
184
247
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
this.#popup.close();
|
|
194
|
-
}
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
#onMenuMouseMove = () => {
|
|
199
|
-
if (this.#highlightedIndex >= 0) {
|
|
200
|
-
this.#highlightedIndex = -1;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
render() {
|
|
204
|
-
return html `
|
|
248
|
+
};
|
|
249
|
+
#onMenuMouseMove = () => {
|
|
250
|
+
if (this.#highlightedIndex >= 0) {
|
|
251
|
+
this.#highlightedIndex = -1;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
render() {
|
|
255
|
+
return html `
|
|
205
256
|
<div
|
|
206
257
|
class="Trigger"
|
|
207
258
|
aria-haspopup="menu"
|
|
@@ -213,5 +264,7 @@ export class DuiMenu extends LitElement {
|
|
|
213
264
|
<slot name="trigger"></slot>
|
|
214
265
|
</div>
|
|
215
266
|
`;
|
|
216
|
-
|
|
217
|
-
}
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
})();
|
|
270
|
+
export { DuiMenu };
|
package/menubar/menubar.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
35
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
36
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
37
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
6
38
|
};
|
|
7
39
|
import { css, html, LitElement } from "lit";
|
|
8
40
|
import { property, state } from "lit/decorators.js";
|
|
@@ -34,85 +66,112 @@ const styles = css `
|
|
|
34
66
|
* @slot - `dui-menu` children.
|
|
35
67
|
* @csspart root - The menubar container.
|
|
36
68
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (direction === "next") {
|
|
65
|
-
nextIndex = currentIndex + 1;
|
|
66
|
-
if (nextIndex >= menus.length) {
|
|
67
|
-
nextIndex = this.loop ? 0 : menus.length - 1;
|
|
68
|
-
}
|
|
69
|
+
let DuiMenubar = (() => {
|
|
70
|
+
let _classSuper = LitElement;
|
|
71
|
+
let _loop_decorators;
|
|
72
|
+
let _loop_initializers = [];
|
|
73
|
+
let _loop_extraInitializers = [];
|
|
74
|
+
let _orientation_decorators;
|
|
75
|
+
let _orientation_initializers = [];
|
|
76
|
+
let _orientation_extraInitializers = [];
|
|
77
|
+
let _private_activeMenuId_decorators;
|
|
78
|
+
let _private_activeMenuId_initializers = [];
|
|
79
|
+
let _private_activeMenuId_extraInitializers = [];
|
|
80
|
+
let _private_activeMenuId_descriptor;
|
|
81
|
+
let __ctx_decorators;
|
|
82
|
+
let __ctx_initializers = [];
|
|
83
|
+
let __ctx_extraInitializers = [];
|
|
84
|
+
return class DuiMenubar extends _classSuper {
|
|
85
|
+
static {
|
|
86
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
87
|
+
_loop_decorators = [property({ type: Boolean })];
|
|
88
|
+
_orientation_decorators = [property({ reflect: true })];
|
|
89
|
+
_private_activeMenuId_decorators = [state()];
|
|
90
|
+
__ctx_decorators = [provide({ context: menubarContext }), state()];
|
|
91
|
+
__esDecorate(this, null, _loop_decorators, { kind: "accessor", name: "loop", static: false, private: false, access: { has: obj => "loop" in obj, get: obj => obj.loop, set: (obj, value) => { obj.loop = value; } }, metadata: _metadata }, _loop_initializers, _loop_extraInitializers);
|
|
92
|
+
__esDecorate(this, null, _orientation_decorators, { kind: "accessor", name: "orientation", static: false, private: false, access: { has: obj => "orientation" in obj, get: obj => obj.orientation, set: (obj, value) => { obj.orientation = value; } }, metadata: _metadata }, _orientation_initializers, _orientation_extraInitializers);
|
|
93
|
+
__esDecorate(this, _private_activeMenuId_descriptor = { get: __setFunctionName(function () { return this.#activeMenuId_accessor_storage; }, "#activeMenuId", "get"), set: __setFunctionName(function (value) { this.#activeMenuId_accessor_storage = value; }, "#activeMenuId", "set") }, _private_activeMenuId_decorators, { kind: "accessor", name: "#activeMenuId", static: false, private: true, access: { has: obj => #activeMenuId in obj, get: obj => obj.#activeMenuId, set: (obj, value) => { obj.#activeMenuId = value; } }, metadata: _metadata }, _private_activeMenuId_initializers, _private_activeMenuId_extraInitializers);
|
|
94
|
+
__esDecorate(this, null, __ctx_decorators, { kind: "accessor", name: "_ctx", static: false, private: false, access: { has: obj => "_ctx" in obj, get: obj => obj._ctx, set: (obj, value) => { obj._ctx = value; } }, metadata: _metadata }, __ctx_initializers, __ctx_extraInitializers);
|
|
95
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
69
96
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
static tagName = "dui-menubar";
|
|
98
|
+
static styles = [base, styles];
|
|
99
|
+
#loop_accessor_storage = __runInitializers(this, _loop_initializers, true);
|
|
100
|
+
get loop() { return this.#loop_accessor_storage; }
|
|
101
|
+
set loop(value) { this.#loop_accessor_storage = value; }
|
|
102
|
+
#orientation_accessor_storage = (__runInitializers(this, _loop_extraInitializers), __runInitializers(this, _orientation_initializers, "horizontal"));
|
|
103
|
+
get orientation() { return this.#orientation_accessor_storage; }
|
|
104
|
+
set orientation(value) { this.#orientation_accessor_storage = value; }
|
|
105
|
+
#activeMenuId_accessor_storage = (__runInitializers(this, _orientation_extraInitializers), __runInitializers(this, _private_activeMenuId_initializers, null));
|
|
106
|
+
get #activeMenuId() { return _private_activeMenuId_descriptor.get.call(this); }
|
|
107
|
+
set #activeMenuId(value) { return _private_activeMenuId_descriptor.set.call(this, value); }
|
|
108
|
+
#getMenus() {
|
|
109
|
+
return [...this.querySelectorAll("dui-menu")];
|
|
82
110
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
get _ctx() { return this.#_ctx_accessor_storage; }
|
|
89
|
-
set _ctx(value) { this.#_ctx_accessor_storage = value; }
|
|
90
|
-
#buildContext() {
|
|
91
|
-
return {
|
|
92
|
-
activeMenuId: this.#activeMenuId,
|
|
93
|
-
openMenu: this.#openMenu,
|
|
94
|
-
closeAll: this.#closeAll,
|
|
95
|
-
navigateToMenu: this.#navigateToMenu,
|
|
111
|
+
#openMenu = (__runInitializers(this, _private_activeMenuId_extraInitializers), (id) => {
|
|
112
|
+
this.#activeMenuId = id;
|
|
113
|
+
});
|
|
114
|
+
#closeAll = () => {
|
|
115
|
+
this.#activeMenuId = null;
|
|
96
116
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
#navigateToMenu = (direction) => {
|
|
118
|
+
const menus = this.#getMenus();
|
|
119
|
+
if (menus.length === 0)
|
|
120
|
+
return;
|
|
121
|
+
const currentIndex = menus.findIndex((m) => m.getAttribute("data-menubar-id") === this.#activeMenuId);
|
|
122
|
+
let nextIndex;
|
|
123
|
+
if (direction === "next") {
|
|
124
|
+
nextIndex = currentIndex + 1;
|
|
125
|
+
if (nextIndex >= menus.length) {
|
|
126
|
+
nextIndex = this.loop ? 0 : menus.length - 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
nextIndex = currentIndex - 1;
|
|
131
|
+
if (nextIndex < 0) {
|
|
132
|
+
nextIndex = this.loop ? menus.length - 1 : 0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const nextMenu = menus[nextIndex];
|
|
136
|
+
if (!nextMenu)
|
|
137
|
+
return;
|
|
138
|
+
const nextId = nextMenu.getAttribute("data-menubar-id");
|
|
139
|
+
if (nextId) {
|
|
140
|
+
this.#activeMenuId = nextId;
|
|
141
|
+
}
|
|
142
|
+
// Focus the trigger of the next menu
|
|
143
|
+
const trigger = nextMenu.querySelector('[slot="trigger"]');
|
|
144
|
+
trigger?.focus();
|
|
145
|
+
};
|
|
146
|
+
#_ctx_accessor_storage = __runInitializers(this, __ctx_initializers, this.#buildContext());
|
|
147
|
+
get _ctx() { return this.#_ctx_accessor_storage; }
|
|
148
|
+
set _ctx(value) { this.#_ctx_accessor_storage = value; }
|
|
149
|
+
#buildContext() {
|
|
150
|
+
return {
|
|
151
|
+
activeMenuId: this.#activeMenuId,
|
|
152
|
+
openMenu: this.#openMenu,
|
|
153
|
+
closeAll: this.#closeAll,
|
|
154
|
+
navigateToMenu: this.#navigateToMenu,
|
|
155
|
+
};
|
|
108
156
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.#navigateToMenu("prev");
|
|
157
|
+
willUpdate() {
|
|
158
|
+
this._ctx = this.#buildContext();
|
|
112
159
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
160
|
+
#onKeyDown = (__runInitializers(this, __ctx_extraInitializers), (e) => {
|
|
161
|
+
const isHorizontal = this.orientation === "horizontal";
|
|
162
|
+
const nextKey = isHorizontal ? "ArrowRight" : "ArrowDown";
|
|
163
|
+
const prevKey = isHorizontal ? "ArrowLeft" : "ArrowUp";
|
|
164
|
+
if (e.key === nextKey) {
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
this.#navigateToMenu("next");
|
|
167
|
+
}
|
|
168
|
+
else if (e.key === prevKey) {
|
|
169
|
+
e.preventDefault();
|
|
170
|
+
this.#navigateToMenu("prev");
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
render() {
|
|
174
|
+
return html `
|
|
116
175
|
<div
|
|
117
176
|
part="root"
|
|
118
177
|
role="menubar"
|
|
@@ -122,15 +181,7 @@ export class DuiMenubar extends LitElement {
|
|
|
122
181
|
<slot></slot>
|
|
123
182
|
</div>
|
|
124
183
|
`;
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
], DuiMenubar.prototype, "loop", null);
|
|
130
|
-
__decorate([
|
|
131
|
-
property({ reflect: true })
|
|
132
|
-
], DuiMenubar.prototype, "orientation", null);
|
|
133
|
-
__decorate([
|
|
134
|
-
provide({ context: menubarContext }),
|
|
135
|
-
state()
|
|
136
|
-
], DuiMenubar.prototype, "_ctx", null);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
})();
|
|
187
|
+
export { DuiMenubar };
|