@reliability-design/web 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/rel-accordion/rel-accordion.ts +289 -150
- package/dist/components/rel-alert/rel-alert.ts +34 -34
- package/dist/components/rel-avatar/README.md +15 -4
- package/dist/components/rel-avatar/rel-avatar.ts +138 -94
- package/dist/components/rel-badge/README.md +7 -0
- package/dist/components/rel-badge/rel-badge.ts +39 -2
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +6 -6
- package/dist/components/rel-button/rel-button.ts +96 -28
- package/dist/components/rel-calendar/rel-calendar.ts +15 -8
- package/dist/components/rel-card/rel-card.ts +9 -17
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +20 -23
- package/dist/components/rel-carousel/rel-carousel.ts +596 -468
- package/dist/components/rel-checkbox/rel-checkbox.ts +68 -16
- package/dist/components/rel-chip/README.md +7 -0
- package/dist/components/rel-chip/rel-chip.ts +411 -244
- package/dist/components/rel-container/rel-container.ts +2 -2
- package/dist/components/rel-date-picker/rel-date-picker.ts +23 -19
- package/dist/components/rel-divider/rel-divider.ts +3 -3
- package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -2
- package/dist/components/rel-drawer/rel-drawer.ts +46 -90
- package/dist/components/rel-kbd/rel-kbd.ts +94 -118
- package/dist/components/rel-layout/rel-layout.ts +49 -58
- package/dist/components/rel-menu/rel-menu.ts +359 -359
- package/dist/components/rel-menubar/rel-menubar-menu.css +3 -0
- package/dist/components/rel-menubar/rel-menubar-menu.ts +2 -1
- package/dist/components/rel-menubar/rel-menubar.ts +603 -605
- package/dist/components/rel-otp/rel-otp.ts +22 -25
- package/dist/components/rel-pagination/rel-pagination.ts +442 -381
- package/dist/components/rel-popover/rel-popover-content.ts +6 -5
- package/dist/components/rel-popover/rel-popover.ts +26 -7
- package/dist/components/rel-progress/rel-progress.ts +10 -9
- package/dist/components/rel-radio/rel-radio.ts +228 -172
- package/dist/components/rel-range-picker/rel-range-picker.css +349 -0
- package/dist/components/rel-range-picker/rel-range-picker.ts +1080 -0
- package/dist/components/rel-resizable/rel-resizable-handle.ts +8 -7
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +41 -20
- package/dist/components/rel-select/README.md +34 -28
- package/dist/components/rel-select/rel-select.ts +1015 -275
- package/dist/components/rel-sheet/rel-sheet.ts +365 -684
- package/dist/components/rel-skeleton/rel-skeleton.ts +139 -0
- package/dist/components/rel-slider/rel-slider.ts +49 -27
- package/dist/components/rel-snackbar/rel-snackbar.ts +28 -28
- package/dist/components/rel-stepper/rel-stepper.ts +11 -10
- package/dist/components/rel-switch/rel-switch.ts +7 -6
- package/dist/components/rel-tab/rel-tab.ts +15 -29
- package/dist/components/rel-textfield/rel-textfield.ts +192 -35
- package/dist/components/rel-toast/rel-toast.ts +21 -13
- package/dist/components/rel-tooltip/rel-tooltip.ts +123 -123
- package/dist/components/rel-topbar/rel-topbar-actions.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-brand.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +32 -2
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +1 -1
- package/dist/components/rel-topbar/rel-topbar-item.ts +15 -10
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar-profile.ts +30 -56
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +1 -0
- package/dist/components/rel-topbar/rel-topbar.ts +137 -28
- package/dist/index.d.mts +310 -193
- package/dist/index.d.ts +310 -193
- package/dist/index.js +5562 -3526
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5328 -3284
- package/dist/index.mjs.map +1 -1
- package/dist/rel-menubar-menu-BEEQDAXW.css +3 -0
- package/dist/styles/vars-v2.css +525 -0
- package/dist/styles/vars.css +346 -346
- package/dist/{vars-TBB4BMSD.css → vars-I2PC74XD.css} +346 -346
- package/dist/vars-v2-VMGWTFJZ.css +525 -0
- package/package.json +2 -1
|
@@ -1,605 +1,603 @@
|
|
|
1
|
-
import { LitElement, html
|
|
2
|
-
import { customElement, state
|
|
3
|
-
import { RelMenubarMenu } from "./rel-menubar-menu";
|
|
4
|
-
import "@reliability-design/icons/rel-icon";
|
|
5
|
-
import "../rel-checkbox/rel-checkbox";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@state() private
|
|
18
|
-
@state() private
|
|
19
|
-
@state() private
|
|
20
|
-
|
|
21
|
-
@
|
|
22
|
-
|
|
23
|
-
private hoverSwitchEnabled = false;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
display:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
.menu-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
.menu-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.menu-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
left:
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
.menu-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
this.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
this.
|
|
243
|
-
this.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if (this.openMenuIndex
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
this.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
this.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
const
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
allRadios
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
this.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
this.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const positionTarget = renderedTrigger ?? submenuTrigger;
|
|
427
|
-
const rect = positionTarget.getBoundingClientRect();
|
|
428
|
-
submenuPanel.style.top = `${rect.top}px`;
|
|
429
|
-
submenuPanel.style.left = `${rect.right + 4}px`;
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
private handleSubmenuItemClick(
|
|
435
|
-
// Regular item - just close
|
|
436
|
-
this.closeAllMenus();
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
private dispatchChangeEvent(type: "checkbox" | "radio", labelOrName: string, value: string | boolean) {
|
|
440
|
-
const detail =
|
|
441
|
-
type === "checkbox"
|
|
442
|
-
? { type, label: labelOrName, name: "", checked: value as boolean }
|
|
443
|
-
: { type, label: "", name: labelOrName, value: value as string };
|
|
444
|
-
this.dispatchEvent(
|
|
445
|
-
new CustomEvent("rel-menubar-change", {
|
|
446
|
-
detail,
|
|
447
|
-
bubbles: true,
|
|
448
|
-
composed: true,
|
|
449
|
-
})
|
|
450
|
-
);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
private renderMenuItem(item: Element, index: number): any {
|
|
454
|
-
const isFocused = index === this.focusedItemIndex;
|
|
455
|
-
|
|
456
|
-
if (item.hasAttribute("data-item")) {
|
|
457
|
-
const button = item as HTMLButtonElement;
|
|
458
|
-
const disabled = button.disabled;
|
|
459
|
-
const shortcut = button.getAttribute("data-shortcut") || "";
|
|
460
|
-
|
|
461
|
-
return html`
|
|
462
|
-
<div
|
|
463
|
-
class="menu-item ${isFocused ? "focused" : ""}"
|
|
464
|
-
data-disabled="${disabled}"
|
|
465
|
-
@click="${() => !disabled && this.handleItemClick(item as HTMLElement)}"
|
|
466
|
-
>
|
|
467
|
-
<span>${button.textContent}</span>
|
|
468
|
-
${shortcut ? html`<span class="menu-shortcut">${shortcut}</span>` : ""}
|
|
469
|
-
</div>
|
|
470
|
-
`;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
if (item.hasAttribute("data-separator")) {
|
|
474
|
-
return html`<div class="menu-separator"></div>`;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
if (item.hasAttribute("data-checkbox")) {
|
|
478
|
-
const label = item as HTMLLabelElement;
|
|
479
|
-
const checkbox = label.querySelector('input[type="checkbox"]') as HTMLInputElement;
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
@
|
|
593
|
-
@
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
}
|
|
1
|
+
import { LitElement, html } from "lit";
|
|
2
|
+
import { customElement, state } from "lit/decorators.js";
|
|
3
|
+
import { RelMenubarMenu } from "./rel-menubar-menu";
|
|
4
|
+
import "@reliability-design/icons/rel-icon";
|
|
5
|
+
import "../rel-checkbox/rel-checkbox.js";
|
|
6
|
+
import "../rel-radio/rel-radio.js";
|
|
7
|
+
import "../../styles/vars-v2.css";
|
|
8
|
+
|
|
9
|
+
interface MenuState {
|
|
10
|
+
menu: RelMenubarMenu;
|
|
11
|
+
open: boolean;
|
|
12
|
+
panelElement?: HTMLElement;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@customElement("rel-menubar")
|
|
16
|
+
export class RelMenubar extends LitElement {
|
|
17
|
+
@state() private menus: MenuState[] = [];
|
|
18
|
+
@state() private openMenuIndex: number = -1;
|
|
19
|
+
@state() private focusedTriggerIndex: number = 0;
|
|
20
|
+
@state() private focusedItemIndex: number = -1;
|
|
21
|
+
@state() private openSubmenuElement: HTMLElement | null = null;
|
|
22
|
+
|
|
23
|
+
private hoverSwitchEnabled = false;
|
|
24
|
+
private _onScroll?: () => void;
|
|
25
|
+
|
|
26
|
+
public static readonly _css = `
|
|
27
|
+
:host {
|
|
28
|
+
display: block;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host > slot {
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.menubar-container {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: stretch;
|
|
38
|
+
background: var(--rel-color-bg-secondary);
|
|
39
|
+
border: var(--rel-borders-width-stroke-100) solid var(--rel-color-border-default);
|
|
40
|
+
border-radius: var(--rel-borders-radius-border-radius-200);
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
padding: 0;
|
|
43
|
+
gap: var(--rel-spacing-space-3xs);
|
|
44
|
+
font-family: var(--rel-fontFamilies-primary);
|
|
45
|
+
font-size: var(--rel-fontSizes-sm);
|
|
46
|
+
height: 40px;
|
|
47
|
+
width: fit-content;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.menubar-trigger {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
align-self: stretch;
|
|
54
|
+
height: 100%;
|
|
55
|
+
padding: 0 var(--rel-spacing-space-sm);
|
|
56
|
+
background: transparent;
|
|
57
|
+
border: none;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
font-family: inherit;
|
|
60
|
+
font-size: inherit;
|
|
61
|
+
color: var(--rel-color-text-heading);
|
|
62
|
+
transition: background 0.15s ease;
|
|
63
|
+
user-select: none;
|
|
64
|
+
outline: none;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.menubar-trigger:hover,
|
|
68
|
+
.menubar-trigger.active {
|
|
69
|
+
background: var(--rel-color-bg-selected);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.menubar-trigger:focus-visible {
|
|
73
|
+
outline: 2px solid var(--rel-color-border-focus);
|
|
74
|
+
outline-offset: 2px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.menubar-panel {
|
|
78
|
+
position: fixed;
|
|
79
|
+
min-width: 220px;
|
|
80
|
+
background: var(--rel-color-bg-primary);
|
|
81
|
+
border: var(--rel-borders-width-stroke-100) solid var(--rel-color-border-default);
|
|
82
|
+
border-radius: var(--rel-borders-radius-border-radius-200);
|
|
83
|
+
box-shadow: var(--rel-shadows-shadow-300);
|
|
84
|
+
padding: 0;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
z-index: 1000;
|
|
87
|
+
display: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.menubar-panel.open {
|
|
91
|
+
display: block;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.menu-item {
|
|
95
|
+
position: relative;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
justify-content: space-between;
|
|
99
|
+
gap: var(--rel-spacing-space-sm);
|
|
100
|
+
padding: var(--rel-spacing-space-xs) var(--rel-spacing-space-md);
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
transition: background 0.15s ease;
|
|
103
|
+
user-select: none;
|
|
104
|
+
color: var(--rel-color-text-heading);
|
|
105
|
+
line-height: var(--rel-lineHeights-sm);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.menu-item:hover,
|
|
109
|
+
.menu-item.focused {
|
|
110
|
+
background: var(--rel-color-bg-selected);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.menu-item[data-disabled="true"] {
|
|
114
|
+
opacity: 0.5;
|
|
115
|
+
cursor: not-allowed;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.menu-separator {
|
|
119
|
+
height: var(--rel-borders-width-stroke-100);
|
|
120
|
+
background: var(--rel-color-border-divider);
|
|
121
|
+
margin: 0;
|
|
122
|
+
padding: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
rel-icon {
|
|
126
|
+
display: inline-flex;
|
|
127
|
+
pointer-events: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.menu-submenu-trigger {
|
|
131
|
+
position: relative;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.menu-submenu-trigger rel-icon {
|
|
135
|
+
opacity: 0.6;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.submenu-panel {
|
|
139
|
+
position: fixed;
|
|
140
|
+
min-width: 200px;
|
|
141
|
+
background: var(--rel-color-bg-primary);
|
|
142
|
+
border: var(--rel-borders-width-stroke-100) solid var(--rel-color-border-default);
|
|
143
|
+
border-radius: var(--rel-borders-radius-border-radius-200);
|
|
144
|
+
box-shadow: var(--rel-shadows-shadow-300);
|
|
145
|
+
padding: 0;
|
|
146
|
+
overflow: hidden;
|
|
147
|
+
z-index: 1001;
|
|
148
|
+
display: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.submenu-panel.open {
|
|
152
|
+
display: block;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.menu-shortcut {
|
|
156
|
+
opacity: 0.6;
|
|
157
|
+
font-size: var(--rel-fontSizes-xs);
|
|
158
|
+
margin-left: auto;
|
|
159
|
+
display: flex;
|
|
160
|
+
align-items: center;
|
|
161
|
+
gap: var(--rel-spacing-space-3xs);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.menubar-panel rel-checkbox {
|
|
165
|
+
display: block;
|
|
166
|
+
width: 100%;
|
|
167
|
+
padding: var(--rel-spacing-space-xs, 8px) var(--rel-spacing-space-md, 16px);
|
|
168
|
+
box-sizing: border-box;
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
createRenderRoot() {
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
connectedCallback() {
|
|
178
|
+
super.connectedCallback();
|
|
179
|
+
this.discoverMenus();
|
|
180
|
+
document.addEventListener("click", this.handleOutsideClick);
|
|
181
|
+
this._onScroll = () => {
|
|
182
|
+
this._repositionOpenMenu();
|
|
183
|
+
this._repositionOpenSubmenu();
|
|
184
|
+
};
|
|
185
|
+
window.addEventListener('scroll', this._onScroll, { passive: true, capture: true });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
disconnectedCallback() {
|
|
189
|
+
super.disconnectedCallback();
|
|
190
|
+
document.removeEventListener("click", this.handleOutsideClick);
|
|
191
|
+
if (this._onScroll) {
|
|
192
|
+
window.removeEventListener('scroll', this._onScroll, { capture: true });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private _repositionOpenSubmenu() {
|
|
197
|
+
if (!this.openSubmenuElement) return;
|
|
198
|
+
const submenuPanel = this.querySelector('.submenu-panel.open') as HTMLElement;
|
|
199
|
+
if (!submenuPanel) return;
|
|
200
|
+
const trigger = this.querySelector('.menu-submenu-trigger.focused, .menu-submenu-trigger:hover') as HTMLElement
|
|
201
|
+
?? submenuPanel.previousElementSibling as HTMLElement;
|
|
202
|
+
if (!trigger) return;
|
|
203
|
+
const rect = trigger.getBoundingClientRect();
|
|
204
|
+
submenuPanel.style.top = `${rect.top}px`;
|
|
205
|
+
submenuPanel.style.left = `${rect.right + 4}px`;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private _repositionOpenMenu() {
|
|
209
|
+
if (this.openMenuIndex === -1) return;
|
|
210
|
+
const triggers = this.querySelectorAll('.menubar-trigger');
|
|
211
|
+
const trigger = triggers[this.openMenuIndex] as HTMLElement;
|
|
212
|
+
const panel = this.querySelector(`.menubar-panel[data-menu-index="${this.openMenuIndex}"]`) as HTMLElement;
|
|
213
|
+
if (!trigger || !panel) return;
|
|
214
|
+
const rect = trigger.getBoundingClientRect();
|
|
215
|
+
panel.style.top = `${rect.bottom + 4}px`;
|
|
216
|
+
panel.style.left = `${rect.left}px`;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private discoverMenus() {
|
|
220
|
+
const menuElements = Array.from(
|
|
221
|
+
this.querySelectorAll("rel-menubar-menu")
|
|
222
|
+
) as RelMenubarMenu[];
|
|
223
|
+
this.menus = menuElements.map((menu) => ({ menu, open: false }));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private handleOutsideClick = (e: MouseEvent) => {
|
|
227
|
+
if (!this.contains(e.target as Node)) {
|
|
228
|
+
this.closeAllMenus();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
private closeAllMenus() {
|
|
233
|
+
this.openMenuIndex = -1;
|
|
234
|
+
this.openSubmenuElement = null;
|
|
235
|
+
this.hoverSwitchEnabled = false;
|
|
236
|
+
this.requestUpdate();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private openMenu(index: number, triggerElement: HTMLElement) {
|
|
240
|
+
this.openMenuIndex = index;
|
|
241
|
+
this.focusedItemIndex = -1;
|
|
242
|
+
this.openSubmenuElement = null;
|
|
243
|
+
this.requestUpdate();
|
|
244
|
+
|
|
245
|
+
// Position the panel below the trigger
|
|
246
|
+
this.updateComplete.then(() => {
|
|
247
|
+
const panel = this.querySelector(
|
|
248
|
+
`.menubar-panel[data-menu-index="${index}"]`
|
|
249
|
+
) as HTMLElement;
|
|
250
|
+
if (panel && triggerElement) {
|
|
251
|
+
const rect = triggerElement.getBoundingClientRect();
|
|
252
|
+
panel.style.top = `${rect.bottom + 4}px`;
|
|
253
|
+
panel.style.left = `${rect.left}px`;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private handleTriggerClick(index: number, event: Event) {
|
|
259
|
+
const target = event.currentTarget as HTMLElement;
|
|
260
|
+
if (this.openMenuIndex === index) {
|
|
261
|
+
this.closeAllMenus();
|
|
262
|
+
} else {
|
|
263
|
+
this.openMenu(index, target);
|
|
264
|
+
this.hoverSwitchEnabled = true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private handleTriggerMouseEnter(index: number, event: Event) {
|
|
269
|
+
if (this.openMenuIndex !== -1 && this.hoverSwitchEnabled) {
|
|
270
|
+
const target = event.currentTarget as HTMLElement;
|
|
271
|
+
this.openMenu(index, target);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
private handleTriggerKeyDown(event: KeyboardEvent) {
|
|
276
|
+
const { key } = event;
|
|
277
|
+
|
|
278
|
+
if (key === "ArrowRight") {
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
this.focusedTriggerIndex = Math.min(
|
|
281
|
+
this.menus.length - 1,
|
|
282
|
+
this.focusedTriggerIndex + 1
|
|
283
|
+
);
|
|
284
|
+
this.focusTrigger(this.focusedTriggerIndex);
|
|
285
|
+
} else if (key === "ArrowLeft") {
|
|
286
|
+
event.preventDefault();
|
|
287
|
+
this.focusedTriggerIndex = Math.max(0, this.focusedTriggerIndex - 1);
|
|
288
|
+
this.focusTrigger(this.focusedTriggerIndex);
|
|
289
|
+
} else if (key === "Enter" || key === " ") {
|
|
290
|
+
event.preventDefault();
|
|
291
|
+
const trigger = this.querySelector(
|
|
292
|
+
`.menubar-trigger[data-index="${this.focusedTriggerIndex}"]`
|
|
293
|
+
) as HTMLElement;
|
|
294
|
+
if (trigger) {
|
|
295
|
+
this.openMenu(this.focusedTriggerIndex, trigger);
|
|
296
|
+
this.updateComplete.then(() => {
|
|
297
|
+
const focusTarget = this.querySelector<HTMLElement>(
|
|
298
|
+
"[autofocus], [role='menuitem']"
|
|
299
|
+
);
|
|
300
|
+
if (focusTarget) {
|
|
301
|
+
focusTarget.focus();
|
|
302
|
+
} else {
|
|
303
|
+
this.focusMenuItem(0);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
} else if (key === "ArrowDown" && this.openMenuIndex !== -1) {
|
|
308
|
+
event.preventDefault();
|
|
309
|
+
this.focusMenuItem(0);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private focusTrigger(index: number) {
|
|
314
|
+
const trigger = this.querySelector(
|
|
315
|
+
`.menubar-trigger[data-index="${index}"]`
|
|
316
|
+
) as HTMLElement;
|
|
317
|
+
trigger?.focus();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private handlePanelKeyDown(event: KeyboardEvent) {
|
|
321
|
+
const { key } = event;
|
|
322
|
+
const menuContent = this.menus[this.openMenuIndex]?.menu;
|
|
323
|
+
if (!menuContent) return;
|
|
324
|
+
|
|
325
|
+
const items = this.getFocusableItems(menuContent);
|
|
326
|
+
|
|
327
|
+
if (key === "ArrowDown") {
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
this.focusedItemIndex = Math.min(items.length - 1, this.focusedItemIndex + 1);
|
|
330
|
+
this.requestUpdate();
|
|
331
|
+
} else if (key === "ArrowUp") {
|
|
332
|
+
event.preventDefault();
|
|
333
|
+
this.focusedItemIndex = Math.max(0, this.focusedItemIndex - 1);
|
|
334
|
+
this.requestUpdate();
|
|
335
|
+
} else if (key === "ArrowRight") {
|
|
336
|
+
event.preventDefault();
|
|
337
|
+
const currentItem = items[this.focusedItemIndex];
|
|
338
|
+
if (currentItem?.hasAttribute("data-submenu")) {
|
|
339
|
+
this.openSubmenu(currentItem as HTMLElement);
|
|
340
|
+
}
|
|
341
|
+
} else if (key === "ArrowLeft") {
|
|
342
|
+
event.preventDefault();
|
|
343
|
+
if (this.openSubmenuElement) {
|
|
344
|
+
this.openSubmenuElement = null;
|
|
345
|
+
this.requestUpdate();
|
|
346
|
+
}
|
|
347
|
+
} else if (key === "Escape") {
|
|
348
|
+
event.preventDefault();
|
|
349
|
+
this.closeAllMenus();
|
|
350
|
+
this.focusTrigger(this.openMenuIndex);
|
|
351
|
+
} else if (key === "Enter" || key === " ") {
|
|
352
|
+
event.preventDefault();
|
|
353
|
+
const currentItem = items[this.focusedItemIndex];
|
|
354
|
+
if (currentItem) {
|
|
355
|
+
this.handleItemClick(currentItem as HTMLElement);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
private getFocusableItems(menuContent: RelMenubarMenu): Element[] {
|
|
361
|
+
return Array.from(menuContent.children).filter(
|
|
362
|
+
(el) =>
|
|
363
|
+
el.hasAttribute("data-item") ||
|
|
364
|
+
el.hasAttribute("data-checkbox") ||
|
|
365
|
+
el.hasAttribute("data-radio") ||
|
|
366
|
+
el.hasAttribute("data-submenu")
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
private focusMenuItem(index: number) {
|
|
371
|
+
this.focusedItemIndex = index;
|
|
372
|
+
const panel = this.querySelector(
|
|
373
|
+
`.menubar-panel[data-menu-index="${this.openMenuIndex}"]`
|
|
374
|
+
) as HTMLElement;
|
|
375
|
+
panel?.focus();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
private handleItemClick(item: HTMLElement) {
|
|
379
|
+
if (item.hasAttribute("data-checkbox")) {
|
|
380
|
+
const checkbox = item.querySelector('input[type="checkbox"]') as HTMLInputElement;
|
|
381
|
+
const labelText = Array.from(item.childNodes)
|
|
382
|
+
.filter(n => n.nodeType === Node.TEXT_NODE)
|
|
383
|
+
.map(n => n.textContent?.trim())
|
|
384
|
+
.filter(Boolean)
|
|
385
|
+
.join(' ') || item.getAttribute('label') || '';
|
|
386
|
+
if (checkbox) {
|
|
387
|
+
checkbox.checked = !checkbox.checked;
|
|
388
|
+
this.dispatchChangeEvent("checkbox", labelText, checkbox.checked);
|
|
389
|
+
this.requestUpdate();
|
|
390
|
+
}
|
|
391
|
+
} else if (item.hasAttribute("data-radio")) {
|
|
392
|
+
const radioGroup = item.closest("[data-radio-group]") as HTMLElement;
|
|
393
|
+
const value = item.getAttribute("data-radio") || item.getAttribute("value") || "";
|
|
394
|
+
const name = radioGroup?.getAttribute("name") || "";
|
|
395
|
+
|
|
396
|
+
// Update visual state
|
|
397
|
+
const allRadios = radioGroup?.querySelectorAll("[data-radio]");
|
|
398
|
+
allRadios?.forEach((radio) => radio.removeAttribute("data-checked"));
|
|
399
|
+
item.setAttribute("data-checked", "true");
|
|
400
|
+
|
|
401
|
+
// Update internal value
|
|
402
|
+
if (radioGroup) {
|
|
403
|
+
radioGroup.setAttribute("value", value);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
this.dispatchChangeEvent("radio", name, value);
|
|
407
|
+
this.requestUpdate();
|
|
408
|
+
} else if (item.hasAttribute("data-submenu")) {
|
|
409
|
+
this.openSubmenu(item);
|
|
410
|
+
} else {
|
|
411
|
+
// Regular item click
|
|
412
|
+
this.closeAllMenus();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
private openSubmenu(submenuTrigger: HTMLElement, renderedTrigger?: HTMLElement, submenuIndex?: number) {
|
|
417
|
+
this.openSubmenuElement = submenuTrigger;
|
|
418
|
+
this.requestUpdate();
|
|
419
|
+
|
|
420
|
+
this.updateComplete.then(() => {
|
|
421
|
+
const submenuId = `submenu-${submenuIndex ?? 0}`;
|
|
422
|
+
const submenuPanel = this.querySelector(
|
|
423
|
+
`.submenu-panel[data-submenu-id="${submenuId}"]`
|
|
424
|
+
) as HTMLElement;
|
|
425
|
+
if (submenuPanel) {
|
|
426
|
+
const positionTarget = renderedTrigger ?? submenuTrigger;
|
|
427
|
+
const rect = positionTarget.getBoundingClientRect();
|
|
428
|
+
submenuPanel.style.top = `${rect.top}px`;
|
|
429
|
+
submenuPanel.style.left = `${rect.right + 4}px`;
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
private handleSubmenuItemClick(_item: HTMLElement) {
|
|
435
|
+
// Regular item - just close
|
|
436
|
+
this.closeAllMenus();
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
private dispatchChangeEvent(type: "checkbox" | "radio", labelOrName: string, value: string | boolean) {
|
|
440
|
+
const detail =
|
|
441
|
+
type === "checkbox"
|
|
442
|
+
? { type, label: labelOrName, name: "", checked: value as boolean }
|
|
443
|
+
: { type, label: "", name: labelOrName, value: value as string };
|
|
444
|
+
this.dispatchEvent(
|
|
445
|
+
new CustomEvent("rel-menubar-change", {
|
|
446
|
+
detail,
|
|
447
|
+
bubbles: true,
|
|
448
|
+
composed: true,
|
|
449
|
+
})
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
private renderMenuItem(item: Element, index: number): any {
|
|
454
|
+
const isFocused = index === this.focusedItemIndex;
|
|
455
|
+
|
|
456
|
+
if (item.hasAttribute("data-item")) {
|
|
457
|
+
const button = item as HTMLButtonElement;
|
|
458
|
+
const disabled = button.disabled;
|
|
459
|
+
const shortcut = button.getAttribute("data-shortcut") || "";
|
|
460
|
+
|
|
461
|
+
return html`
|
|
462
|
+
<div
|
|
463
|
+
class="menu-item ${isFocused ? "focused" : ""}"
|
|
464
|
+
data-disabled="${disabled}"
|
|
465
|
+
@click="${() => !disabled && this.handleItemClick(item as HTMLElement)}"
|
|
466
|
+
>
|
|
467
|
+
<span>${button.textContent}</span>
|
|
468
|
+
${shortcut ? html`<span class="menu-shortcut">${shortcut}</span>` : ""}
|
|
469
|
+
</div>
|
|
470
|
+
`;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (item.hasAttribute("data-separator")) {
|
|
474
|
+
return html`<div class="menu-separator"></div>`;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
if (item.hasAttribute("data-checkbox")) {
|
|
478
|
+
const label = item as HTMLLabelElement;
|
|
479
|
+
const checkbox = label.querySelector('input[type="checkbox"]') as HTMLInputElement;
|
|
480
|
+
const labelText = Array.from(label.childNodes)
|
|
481
|
+
.filter(n => n.nodeType === Node.TEXT_NODE)
|
|
482
|
+
.map(n => n.textContent?.trim())
|
|
483
|
+
.filter(Boolean)
|
|
484
|
+
.join(' ') || label.getAttribute('label') || '';
|
|
485
|
+
|
|
486
|
+
return html`
|
|
487
|
+
<rel-checkbox
|
|
488
|
+
label=${labelText}
|
|
489
|
+
.status=${checkbox?.checked ? "checked" : "unchecked"}
|
|
490
|
+
@rel-change=${(e: CustomEvent) => {
|
|
491
|
+
if (checkbox) checkbox.checked = e.detail.checked;
|
|
492
|
+
this.dispatchChangeEvent("checkbox", labelText, e.detail.checked);
|
|
493
|
+
}}
|
|
494
|
+
></rel-checkbox>
|
|
495
|
+
`;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (item.hasAttribute("data-submenu")) {
|
|
499
|
+
const label = item.getAttribute("label") || item.textContent?.trim() || "";
|
|
500
|
+
const submenuId = `submenu-${index}`;
|
|
501
|
+
|
|
502
|
+
return html`
|
|
503
|
+
<div
|
|
504
|
+
class="menu-item menu-submenu-trigger ${isFocused ? "focused" : ""}"
|
|
505
|
+
@click="${(e: Event) => this.openSubmenu(item as HTMLElement, e.currentTarget as HTMLElement, index)}"
|
|
506
|
+
@mouseenter="${(e: Event) => this.openSubmenu(item as HTMLElement, e.currentTarget as HTMLElement, index)}"
|
|
507
|
+
>
|
|
508
|
+
<span>${label}</span>
|
|
509
|
+
<rel-icon name="chevron-right"></rel-icon>
|
|
510
|
+
</div>
|
|
511
|
+
${this.renderSubmenu(item as HTMLElement, submenuId)}
|
|
512
|
+
`;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (item.hasAttribute("data-radio-group")) {
|
|
516
|
+
const radioButtons = Array.from(item.querySelectorAll("[data-radio]"));
|
|
517
|
+
const currentValue = item.getAttribute("value") || "";
|
|
518
|
+
const groupName = item.getAttribute("name") || "";
|
|
519
|
+
|
|
520
|
+
const options = radioButtons.map(radio => ({
|
|
521
|
+
label: radio.textContent?.trim() || "",
|
|
522
|
+
value: radio.getAttribute("data-radio") || radio.getAttribute("value") || "",
|
|
523
|
+
}));
|
|
524
|
+
|
|
525
|
+
return html`
|
|
526
|
+
<rel-radio
|
|
527
|
+
.options=${options}
|
|
528
|
+
.value=${currentValue}
|
|
529
|
+
@rel-change=${(e: CustomEvent) => {
|
|
530
|
+
const newValue = e.detail.value;
|
|
531
|
+
item.setAttribute("value", newValue);
|
|
532
|
+
this.dispatchChangeEvent("radio", groupName, newValue);
|
|
533
|
+
}}
|
|
534
|
+
></rel-radio>
|
|
535
|
+
`;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
private renderSubmenu(submenuElement: HTMLElement, submenuId: string) {
|
|
542
|
+
const isOpen = this.openSubmenuElement === submenuElement;
|
|
543
|
+
const submenuItems = Array.from(submenuElement.children);
|
|
544
|
+
|
|
545
|
+
return html`
|
|
546
|
+
<div class="submenu-panel ${isOpen ? "open" : ""}" data-submenu-id="${submenuId}">
|
|
547
|
+
${submenuItems.map((subItem) => {
|
|
548
|
+
if (subItem.hasAttribute("data-item")) {
|
|
549
|
+
const button = subItem as HTMLButtonElement;
|
|
550
|
+
return html`
|
|
551
|
+
<div
|
|
552
|
+
class="menu-item"
|
|
553
|
+
@click="${() => this.handleSubmenuItemClick(subItem as HTMLElement)}"
|
|
554
|
+
>
|
|
555
|
+
<span>${button.textContent}</span>
|
|
556
|
+
</div>
|
|
557
|
+
`;
|
|
558
|
+
}
|
|
559
|
+
return null;
|
|
560
|
+
})}
|
|
561
|
+
</div>
|
|
562
|
+
`;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
private renderMenuPanel(menuState: MenuState, index: number) {
|
|
566
|
+
const isOpen = index === this.openMenuIndex;
|
|
567
|
+
const items = Array.from(menuState.menu.children);
|
|
568
|
+
|
|
569
|
+
return html`
|
|
570
|
+
<div
|
|
571
|
+
class="menubar-panel ${isOpen ? "open" : ""}"
|
|
572
|
+
data-menu-index="${index}"
|
|
573
|
+
tabindex="-1"
|
|
574
|
+
@keydown="${this.handlePanelKeyDown}"
|
|
575
|
+
>
|
|
576
|
+
${items.map((item, idx) => this.renderMenuItem(item, idx))}
|
|
577
|
+
</div>
|
|
578
|
+
`;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
render() {
|
|
582
|
+
return html`
|
|
583
|
+
<style>${RelMenubar._css}</style>
|
|
584
|
+
<slot></slot>
|
|
585
|
+
<div class="menubar-container">
|
|
586
|
+
${this.menus.map(
|
|
587
|
+
(menuState, index) => html`
|
|
588
|
+
<button
|
|
589
|
+
class="menubar-trigger ${index === this.openMenuIndex ? "active" : ""}"
|
|
590
|
+
data-index="${index}"
|
|
591
|
+
@click="${(e: Event) => this.handleTriggerClick(index, e)}"
|
|
592
|
+
@mouseenter="${(e: Event) => this.handleTriggerMouseEnter(index, e)}"
|
|
593
|
+
@keydown="${this.handleTriggerKeyDown}"
|
|
594
|
+
>
|
|
595
|
+
${menuState.menu.label}
|
|
596
|
+
</button>
|
|
597
|
+
`
|
|
598
|
+
)}
|
|
599
|
+
</div>
|
|
600
|
+
${this.menus.map((menuState, index) => this.renderMenuPanel(menuState, index))}
|
|
601
|
+
`;
|
|
602
|
+
}
|
|
603
|
+
}
|