@melodicdev/components 3.1.0 → 4.0.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/assets/melodic-components.js +4269 -2377
- package/assets/melodic-components.js.map +1 -1
- package/assets/melodic-components.min.js +5477 -3831
- package/lib/components/data-display/calendar-view/calendar-view-month.template.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view-month.template.js +17 -0
- package/lib/components/data-display/calendar-view/calendar-view.component.d.ts +23 -3
- package/lib/components/data-display/calendar-view/calendar-view.component.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.component.js +76 -21
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts +9 -0
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.utils.js +68 -19
- package/lib/components/data-display/data-grid/data-grid.component.d.ts +24 -0
- package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.component.js +104 -31
- package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.template.js +3 -0
- package/lib/components/data-display/table/table.component.d.ts +7 -0
- package/lib/components/data-display/table/table.component.d.ts.map +1 -1
- package/lib/components/data-display/table/table.component.js +20 -5
- package/lib/components/data-display/table/table.template.d.ts.map +1 -1
- package/lib/components/data-display/table/table.template.js +3 -0
- package/lib/components/data-display/table-core/index.d.ts +1 -0
- package/lib/components/data-display/table-core/index.d.ts.map +1 -1
- package/lib/components/data-display/table-core/index.js +1 -0
- package/lib/components/data-display/table-core/memo.d.ts +10 -0
- package/lib/components/data-display/table-core/memo.d.ts.map +1 -0
- package/lib/components/data-display/table-core/memo.js +20 -0
- package/lib/components/feedback/alert/alert.styles.d.ts.map +1 -1
- package/lib/components/feedback/alert/alert.styles.js +25 -0
- package/lib/components/feedback/progress/progress.styles.d.ts.map +1 -1
- package/lib/components/feedback/progress/progress.styles.js +8 -3
- package/lib/components/feedback/spinner/spinner.styles.d.ts.map +1 -1
- package/lib/components/feedback/spinner/spinner.styles.js +2 -11
- package/lib/components/feedback/toast/toast-container.template.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast-container.template.js +4 -0
- package/lib/components/feedback/toast/toast.component.d.ts +3 -2
- package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.component.js +10 -0
- package/lib/components/feedback/toast/toast.service.d.ts +26 -6
- package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.service.js +53 -18
- package/lib/components/feedback/toast/toast.template.js +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts +7 -0
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.js +39 -0
- package/lib/components/forms/autocomplete/autocomplete.template.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.template.js +5 -1
- package/lib/components/forms/button-group/button-group.component.d.ts +3 -2
- package/lib/components/forms/button-group/button-group.component.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group.component.js +11 -1
- package/lib/components/forms/checkbox/checkbox.component.d.ts +4 -0
- package/lib/components/forms/checkbox/checkbox.component.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.component.js +5 -1
- package/lib/components/forms/checkbox/checkbox.template.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.template.js +2 -0
- package/lib/components/forms/date-picker/calendar.component.d.ts +21 -0
- package/lib/components/forms/date-picker/calendar.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/calendar.component.js +69 -2
- package/lib/components/forms/date-picker/calendar.template.d.ts.map +1 -1
- package/lib/components/forms/date-picker/calendar.template.js +6 -3
- package/lib/components/forms/date-picker/date-picker.component.d.ts +6 -0
- package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/date-picker.component.js +41 -12
- package/lib/components/forms/file-upload/file-upload.component.d.ts.map +1 -1
- package/lib/components/forms/file-upload/file-upload.component.js +15 -5
- package/lib/components/forms/form-field/form-field.component.d.ts +8 -0
- package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
- package/lib/components/forms/form-field/form-field.component.js +41 -6
- package/lib/components/forms/form-field/form-field.template.js +1 -1
- package/lib/components/forms/input/input.component.d.ts +26 -3
- package/lib/components/forms/input/input.component.d.ts.map +1 -1
- package/lib/components/forms/input/input.component.js +46 -6
- package/lib/components/forms/input/input.template.d.ts.map +1 -1
- package/lib/components/forms/input/input.template.js +9 -0
- package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts +6 -0
- package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts.map +1 -1
- package/lib/components/forms/radio-card-group/radio-card-group.component.js +34 -0
- package/lib/components/forms/radio-card-group/radio-card.component.d.ts +6 -0
- package/lib/components/forms/radio-card-group/radio-card.component.d.ts.map +1 -1
- package/lib/components/forms/radio-card-group/radio-card.component.js +7 -1
- package/lib/components/forms/radio-card-group/radio-card.template.js +1 -1
- package/lib/components/forms/select/select.component.d.ts.map +1 -1
- package/lib/components/forms/select/select.component.js +13 -1
- package/lib/components/forms/select/select.template.d.ts.map +1 -1
- package/lib/components/forms/select/select.template.js +5 -1
- package/lib/components/forms/textarea/textarea.component.d.ts +10 -3
- package/lib/components/forms/textarea/textarea.component.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.component.js +10 -5
- package/lib/components/forms/textarea/textarea.template.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.template.js +2 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts +16 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
- package/lib/components/forms/time-picker/time-picker.component.js +43 -3
- package/lib/components/foundation/container/container.component.js +5 -5
- package/lib/components/foundation/container/container.styles.d.ts.map +1 -1
- package/lib/components/foundation/container/container.styles.js +10 -0
- package/lib/components/foundation/stack/stack.component.d.ts +6 -0
- package/lib/components/foundation/stack/stack.component.d.ts.map +1 -1
- package/lib/components/foundation/stack/stack.component.js +11 -5
- package/lib/components/foundation/stack/stack.styles.d.ts.map +1 -1
- package/lib/components/foundation/stack/stack.styles.js +14 -0
- package/lib/components/general/icon/icon.template.d.ts.map +1 -1
- package/lib/components/general/icon/icon.template.js +7 -1
- package/lib/components/navigation/breadcrumb/breadcrumb-item.template.d.ts.map +1 -1
- package/lib/components/navigation/breadcrumb/breadcrumb-item.template.js +2 -1
- package/lib/components/navigation/functions/match-by-route.function.d.ts +16 -0
- package/lib/components/navigation/functions/match-by-route.function.d.ts.map +1 -0
- package/lib/components/navigation/functions/match-by-route.function.js +34 -0
- package/lib/components/navigation/functions/route-link.function.d.ts +20 -0
- package/lib/components/navigation/functions/route-link.function.d.ts.map +1 -0
- package/lib/components/navigation/functions/route-link.function.js +34 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts +8 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.component.js +12 -2
- package/lib/components/navigation/pagination/pagination.styles.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.styles.js +10 -0
- package/lib/components/navigation/pagination/pagination.template.js +2 -2
- package/lib/components/navigation/sidebar/sidebar-item.template.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar-item.template.js +5 -1
- package/lib/components/navigation/sidebar/sidebar.component.d.ts +12 -6
- package/lib/components/navigation/sidebar/sidebar.component.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.component.js +20 -12
- package/lib/components/navigation/sidebar/sidebar.template.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.template.js +5 -1
- package/lib/components/navigation/steps/step.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.component.js +19 -1
- package/lib/components/navigation/steps/step.template.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.template.js +6 -0
- package/lib/components/navigation/steps/steps.component.d.ts +10 -0
- package/lib/components/navigation/steps/steps.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/steps.component.js +42 -9
- package/lib/components/navigation/steps/steps.template.js +9 -0
- package/lib/components/navigation/tabs/tab-panel.styles.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tab-panel.styles.js +7 -2
- package/lib/components/navigation/tabs/tabs.component.d.ts +10 -0
- package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tabs.component.js +36 -7
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts +19 -9
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts.map +1 -1
- package/lib/components/overlays/dialog/dialog-ref.class.js +37 -5
- package/lib/components/overlays/dropdown/dropdown.component.d.ts +7 -0
- package/lib/components/overlays/dropdown/dropdown.component.d.ts.map +1 -1
- package/lib/components/overlays/dropdown/dropdown.component.js +26 -11
- package/lib/components/overlays/popover/popover.component.d.ts +8 -0
- package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
- package/lib/components/overlays/popover/popover.component.js +17 -0
- package/lib/components/overlays/tooltip/tooltip.component.d.ts +6 -5
- package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
- package/lib/components/overlays/tooltip/tooltip.component.js +14 -10
- package/lib/components/sections/app-shell/app-shell.component.d.ts +13 -0
- package/lib/components/sections/app-shell/app-shell.component.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.component.js +45 -1
- package/lib/components/sections/app-shell/app-shell.styles.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.styles.js +15 -0
- package/lib/components/sections/app-shell/app-shell.template.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.template.js +5 -0
- package/lib/components/sections/page-section/page-section.template.d.ts.map +1 -1
- package/lib/components/sections/page-section/page-section.template.js +6 -1
- package/lib/directives/tooltip.directive.d.ts.map +1 -1
- package/lib/directives/tooltip.directive.js +39 -6
- package/lib/theme/functions/apply-theme.function.d.ts +4 -1
- package/lib/theme/functions/apply-theme.function.d.ts.map +1 -1
- package/lib/theme/functions/apply-theme.function.js +20 -4
- package/lib/theme/functions/create-theme.function.js +0 -1
- package/lib/utils/accessibility/cross-root-aria.d.ts +40 -0
- package/lib/utils/accessibility/cross-root-aria.d.ts.map +1 -0
- package/lib/utils/accessibility/cross-root-aria.js +97 -0
- package/lib/utils/accessibility/index.d.ts +1 -0
- package/lib/utils/accessibility/index.d.ts.map +1 -1
- package/lib/utils/accessibility/index.js +1 -0
- package/lib/utils/directives/index.d.ts +1 -0
- package/lib/utils/directives/index.d.ts.map +1 -1
- package/lib/utils/directives/index.js +1 -0
- package/lib/utils/directives/watch-light-slots.d.ts +20 -0
- package/lib/utils/directives/watch-light-slots.d.ts.map +1 -0
- package/lib/utils/directives/watch-light-slots.js +36 -0
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ import { OverlayPositioner, ToggleDismissGuard } from '../../../utils/overlay/in
|
|
|
9
9
|
import { isDeepFocusWithin } from '../../../utils/accessibility/focus-trap.js';
|
|
10
10
|
import { dropdownTemplate } from './dropdown.template.js';
|
|
11
11
|
import { dropdownStyles } from './dropdown.styles.js';
|
|
12
|
+
import { getFocusableControl, setCrossRootActiveDescendant } from '../../../utils/accessibility/cross-root-aria.js';
|
|
12
13
|
/**
|
|
13
14
|
* ml-dropdown - Dropdown menu component
|
|
14
15
|
*
|
|
@@ -156,11 +157,11 @@ let DropdownComponent = class DropdownComponent {
|
|
|
156
157
|
};
|
|
157
158
|
/** Keep the slotted trigger's menu-button ARIA in sync with open state. */
|
|
158
159
|
this.syncTriggerAria = () => {
|
|
159
|
-
const
|
|
160
|
-
if (!
|
|
160
|
+
const control = this.getTriggerControl();
|
|
161
|
+
if (!control)
|
|
161
162
|
return;
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
control.setAttribute('aria-haspopup', 'menu');
|
|
164
|
+
control.setAttribute('aria-expanded', String(this.isOpen));
|
|
164
165
|
};
|
|
165
166
|
}
|
|
166
167
|
onCreate() {
|
|
@@ -252,11 +253,12 @@ let DropdownComponent = class DropdownComponent {
|
|
|
252
253
|
items[i].focused = i === index;
|
|
253
254
|
}
|
|
254
255
|
this._focusedIndex = index;
|
|
255
|
-
// The
|
|
256
|
-
//
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
// The focusable control may be inside the trigger's own shadow root
|
|
257
|
+
// (<ml-button> wraps a <button>), in which case an id reference to a
|
|
258
|
+
// light-DOM item cannot resolve — use the element reference.
|
|
259
|
+
const control = this.getTriggerControl();
|
|
260
|
+
if (control) {
|
|
261
|
+
setCrossRootActiveDescendant(control, items[index]);
|
|
260
262
|
}
|
|
261
263
|
}
|
|
262
264
|
clearFocus() {
|
|
@@ -265,7 +267,10 @@ let DropdownComponent = class DropdownComponent {
|
|
|
265
267
|
item.focused = false;
|
|
266
268
|
}
|
|
267
269
|
this._focusedIndex = -1;
|
|
268
|
-
this.
|
|
270
|
+
const control = this.getTriggerControl();
|
|
271
|
+
if (control) {
|
|
272
|
+
setCrossRootActiveDescendant(control, null);
|
|
273
|
+
}
|
|
269
274
|
}
|
|
270
275
|
findFirstEnabled(items) {
|
|
271
276
|
return items.findIndex((item) => !item.disabled);
|
|
@@ -278,7 +283,7 @@ let DropdownComponent = class DropdownComponent {
|
|
|
278
283
|
return -1;
|
|
279
284
|
}
|
|
280
285
|
returnFocusToTrigger() {
|
|
281
|
-
this.getAssignedTrigger()?.focus();
|
|
286
|
+
(this.getTriggerControl() ?? this.getAssignedTrigger())?.focus();
|
|
282
287
|
}
|
|
283
288
|
/** First element assigned to the trigger slot (light DOM). */
|
|
284
289
|
getAssignedTrigger() {
|
|
@@ -286,6 +291,16 @@ let DropdownComponent = class DropdownComponent {
|
|
|
286
291
|
const assigned = triggerSlot?.assignedElements() ?? [];
|
|
287
292
|
return assigned[0] ?? null;
|
|
288
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* The element that actually receives focus for the slotted trigger. For
|
|
296
|
+
* `<ml-button>` that is the `<button>` inside its shadow root; ARIA set on
|
|
297
|
+
* the host is not announced, which made the documented example
|
|
298
|
+
* inaccessible.
|
|
299
|
+
*/
|
|
300
|
+
getTriggerControl() {
|
|
301
|
+
const trigger = this.getAssignedTrigger();
|
|
302
|
+
return trigger ? getFocusableControl(trigger) : null;
|
|
303
|
+
}
|
|
289
304
|
/** True when the (deep) focused element is inside this dropdown. */
|
|
290
305
|
startPositioning() {
|
|
291
306
|
const triggerEl = this.getTriggerEl();
|
|
@@ -40,6 +40,14 @@ export declare class PopoverComponent implements IElementRef, OnCreate, OnDestro
|
|
|
40
40
|
private _focusTrap;
|
|
41
41
|
private readonly _dismissGuard;
|
|
42
42
|
onCreate(): void;
|
|
43
|
+
/**
|
|
44
|
+
* `popover="manual"` opts out of the platform's light-dismiss AND of its
|
|
45
|
+
* close watcher, so Escape did nothing — and because the popover traps
|
|
46
|
+
* focus, a keyboard user had no way out of it at all. Close on Escape
|
|
47
|
+
* ourselves; a manual popover that must not be dismissible should not trap
|
|
48
|
+
* focus in the first place.
|
|
49
|
+
*/
|
|
50
|
+
private readonly handleKeyDown;
|
|
43
51
|
onDestroy(): void;
|
|
44
52
|
/** Open the popover */
|
|
45
53
|
open(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/popover/popover.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAMa,gBAAiB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IACjE,UAAU,EAAG,WAAW,CAAC;IAEhC,4CAA4C;IACrC,SAAS,EAAE,SAAS,CAAY;IAEvC,4CAA4C;IACrC,MAAM,SAAK;IAElB,0DAA0D;IACnD,MAAM,UAAS;IAEtB,wDAAwD;IACjD,KAAK,UAAS;IAErB,yBAAyB;IAClB,MAAM,UAAS;IAEtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAKxB;IACJ,OAAO,CAAC,UAAU,CAA0B;IAG5C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAEnD,QAAQ,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"popover.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/popover/popover.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMzD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAMa,gBAAiB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IACjE,UAAU,EAAG,WAAW,CAAC;IAEhC,4CAA4C;IACrC,SAAS,EAAE,SAAS,CAAY;IAEvC,4CAA4C;IACrC,MAAM,SAAK;IAElB,0DAA0D;IACnD,MAAM,UAAS;IAEtB,wDAAwD;IACjD,KAAK,UAAS;IAErB,yBAAyB;IAClB,MAAM,UAAS;IAEtB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAKxB;IACJ,OAAO,CAAC,UAAU,CAA0B;IAG5C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAEnD,QAAQ,IAAI,IAAI;IAQvB;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAQ5B;IAEK,SAAS,IAAI,IAAI;IAWxB,uBAAuB;IAChB,IAAI,IAAI,IAAI;IAOnB,wBAAwB;IACjB,KAAK,IAAI,IAAI;IAOpB,yBAAyB;IAClB,MAAM,QAAO,IAAI,CAUtB;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAsB3B;IAEF,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;CAGpB"}
|
|
@@ -55,6 +55,21 @@ let PopoverComponent = class PopoverComponent {
|
|
|
55
55
|
// Swallows the trigger click that just light-dismissed the open popover so
|
|
56
56
|
// it doesn't immediately reopen it.
|
|
57
57
|
this._dismissGuard = new ToggleDismissGuard();
|
|
58
|
+
/**
|
|
59
|
+
* `popover="manual"` opts out of the platform's light-dismiss AND of its
|
|
60
|
+
* close watcher, so Escape did nothing — and because the popover traps
|
|
61
|
+
* focus, a keyboard user had no way out of it at all. Close on Escape
|
|
62
|
+
* ourselves; a manual popover that must not be dismissible should not trap
|
|
63
|
+
* focus in the first place.
|
|
64
|
+
*/
|
|
65
|
+
this.handleKeyDown = (event) => {
|
|
66
|
+
if (event.key !== 'Escape' || !this.isOpen || !this.manual) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
event.stopPropagation();
|
|
71
|
+
this.close();
|
|
72
|
+
};
|
|
58
73
|
/** Toggle the popover */
|
|
59
74
|
this.toggle = () => {
|
|
60
75
|
// Swallow the click that just light-dismissed the open popover, so the
|
|
@@ -92,6 +107,7 @@ let PopoverComponent = class PopoverComponent {
|
|
|
92
107
|
const popoverEl = this.getPopoverEl();
|
|
93
108
|
if (popoverEl) {
|
|
94
109
|
popoverEl.addEventListener('toggle', this.handleToggle);
|
|
110
|
+
popoverEl.addEventListener('keydown', this.handleKeyDown);
|
|
95
111
|
}
|
|
96
112
|
}
|
|
97
113
|
onDestroy() {
|
|
@@ -101,6 +117,7 @@ let PopoverComponent = class PopoverComponent {
|
|
|
101
117
|
const popoverEl = this.getPopoverEl();
|
|
102
118
|
if (popoverEl) {
|
|
103
119
|
popoverEl.removeEventListener('toggle', this.handleToggle);
|
|
120
|
+
popoverEl.removeEventListener('keydown', this.handleKeyDown);
|
|
104
121
|
}
|
|
105
122
|
}
|
|
106
123
|
/** Open the popover */
|
|
@@ -47,11 +47,12 @@ export declare class TooltipComponent implements IElementRef, OnCreate, OnDestro
|
|
|
47
47
|
private dismiss;
|
|
48
48
|
private readonly handleDocumentKeydown;
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
50
|
+
* Describe the slotted trigger with the tooltip's content element.
|
|
51
|
+
*
|
|
52
|
+
* An `aria-describedby` IDREF pointing INTO this component's shadow root
|
|
53
|
+
* resolves to nothing, so the tooltip was set up to look correct in the DOM
|
|
54
|
+
* and was never announced. Element references cross the boundary; where
|
|
55
|
+
* they are unsupported the text is copied onto the trigger instead.
|
|
55
56
|
*/
|
|
56
57
|
private readonly syncTriggerAria;
|
|
57
58
|
private startPositioning;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/tooltip/tooltip.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAS,KAAK,QAAQ,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"tooltip.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/tooltip/tooltip.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAS,KAAK,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAK7E;;;;;;;;;;;;;;;GAeG;AACH,qBAMa,gBAAiB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IACjE,UAAU,EAAG,WAAW,CAAC;IAEhC,2BAA2B;IACpB,OAAO,SAAM;IAEpB,wBAAwB;IACjB,SAAS,EAAE,SAAS,CAAS;IAEpC,gCAAgC;IACzB,KAAK,SAAO;IAEnB,iCAAiC;IAC1B,SAAS,UAAS;IAEzB;;;;;OAKG;IACI,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAQ;IAE3C,8EAA8E;IACvE,SAAS,EAAE,QAAQ,CAAW;IAErC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAKxB;IAEG,QAAQ,IAAI,IAAI;IAMhB,SAAS,IAAI,IAAI;IAQjB,IAAI,QAAO,IAAI,CAapB;IAEK,IAAI,QAAO,IAAI,CASpB;IAEF,4CAA4C;IAC5C,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAYpC;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAW9B;IAEF,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,eAAe;IAIvB,mDAAmD;IACnD,OAAO,CAAC,cAAc;CAGtB"}
|
|
@@ -9,6 +9,7 @@ import { OverlayPositioner } from '../../../utils/overlay/index.js';
|
|
|
9
9
|
import { newID } from '../../../functions/new-id.function.js';
|
|
10
10
|
import { tooltipTemplate } from './tooltip.template.js';
|
|
11
11
|
import { tooltipStyles } from './tooltip.styles.js';
|
|
12
|
+
import { setCrossRootDescription } from '../../../utils/accessibility/cross-root-aria.js';
|
|
12
13
|
/**
|
|
13
14
|
* ml-tooltip - Tooltip component that shows on hover/focus
|
|
14
15
|
*
|
|
@@ -88,19 +89,22 @@ let TooltipComponent = class TooltipComponent {
|
|
|
88
89
|
this.dismiss();
|
|
89
90
|
};
|
|
90
91
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
92
|
+
* Describe the slotted trigger with the tooltip's content element.
|
|
93
|
+
*
|
|
94
|
+
* An `aria-describedby` IDREF pointing INTO this component's shadow root
|
|
95
|
+
* resolves to nothing, so the tooltip was set up to look correct in the DOM
|
|
96
|
+
* and was never announced. Element references cross the boundary; where
|
|
97
|
+
* they are unsupported the text is copied onto the trigger instead.
|
|
96
98
|
*/
|
|
97
99
|
this.syncTriggerAria = () => {
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const trigger =
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
const root = this.elementRef.shadowRoot;
|
|
101
|
+
const slot = root?.querySelector('.ml-tooltip__trigger slot');
|
|
102
|
+
const trigger = (slot?.assignedElements() ?? [])[0];
|
|
103
|
+
const content = root?.querySelector('.ml-tooltip__content');
|
|
104
|
+
if (!trigger || trigger.hasAttribute('aria-describedby')) {
|
|
105
|
+
return;
|
|
103
106
|
}
|
|
107
|
+
setCrossRootDescription(trigger, content ? [content] : []);
|
|
104
108
|
};
|
|
105
109
|
}
|
|
106
110
|
onCreate() {
|
|
@@ -33,12 +33,25 @@ export declare class AppShellComponent implements IElementRef, OnCreate, OnDestr
|
|
|
33
33
|
/** Media query for responsive behavior */
|
|
34
34
|
private _mediaQuery;
|
|
35
35
|
private readonly _handleMediaChange;
|
|
36
|
+
/**
|
|
37
|
+
* The viewport width below which the sidebar becomes a drawer, read from
|
|
38
|
+
* `--ml-app-shell-mobile-breakpoint`. The value used to be hardcoded in
|
|
39
|
+
* both the stylesheet and here, so overriding it in CSS left the JS
|
|
40
|
+
* behaviour switching at the old width.
|
|
41
|
+
*/
|
|
42
|
+
get mobileBreakpoint(): string;
|
|
36
43
|
onCreate(): void;
|
|
37
44
|
onDestroy(): void;
|
|
38
45
|
/** Toggle mobile sidebar drawer */
|
|
39
46
|
toggleMobileSidebar: () => void;
|
|
40
47
|
/** Close mobile sidebar */
|
|
41
48
|
closeMobileSidebar: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Escape closes the mobile drawer. It had no keyboard dismissal at all:
|
|
51
|
+
* the only way out was clicking the backdrop.
|
|
52
|
+
*/
|
|
53
|
+
handleKeyDown: (event: KeyboardEvent) => void;
|
|
54
|
+
private focusMenuButton;
|
|
42
55
|
private onMediaChange;
|
|
43
56
|
}
|
|
44
57
|
//# sourceMappingURL=app-shell.component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-shell.component.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/app-shell/app-shell.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"app-shell.component.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/app-shell/app-shell.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMzE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAMa,iBAAkB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAClE,UAAU,EAAG,WAAW,CAAC;IAEhC,+EAA+E;IACxE,eAAe,EAAE,eAAe,CAAU;IAEjD,sEAAsE;IAC/D,gBAAgB,UAAS;IAEhC,mEAAmE;IAC5D,WAAW,UAAS;IAE3B,oDAAoD;IAC7C,MAAM,UAAS;IAEtB,gDAAgD;IACzC,UAAU,UAAS;IAE1B,0CAA0C;IAC1C,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAiC;IAEpE;;;;;OAKG;IACH,IAAW,gBAAgB,IAAI,MAAM,CAGpC;IAEM,QAAQ,IAAI,IAAI;IAQhB,SAAS,IAAI,IAAI;IAIxB,mCAAmC;IAC5B,mBAAmB,QAAO,IAAI,CAanC;IAEF,2BAA2B;IACpB,kBAAkB,QAAO,IAAI,CAOlC;IAEF;;;OAGG;IACI,aAAa,GAAI,OAAO,aAAa,KAAG,IAAI,CAKjD;IAEF,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,aAAa;CAOrB"}
|
|
@@ -8,6 +8,7 @@ import { MelodicComponent } from '@melodicdev/core';
|
|
|
8
8
|
import { appShellTemplate } from './app-shell.template.js';
|
|
9
9
|
import { appShellStyles } from './app-shell.styles.js';
|
|
10
10
|
import { defineLegacyAliases } from '../../../functions/index.js';
|
|
11
|
+
import { focusFirst } from '../../../utils/accessibility/focus-utils.js';
|
|
11
12
|
/**
|
|
12
13
|
* ml-app-shell - Application shell layout component
|
|
13
14
|
*
|
|
@@ -44,20 +45,63 @@ let AppShellComponent = class AppShellComponent {
|
|
|
44
45
|
/** Toggle mobile sidebar drawer */
|
|
45
46
|
this.toggleMobileSidebar = () => {
|
|
46
47
|
this.mobileOpen = !this.mobileOpen;
|
|
48
|
+
if (this.mobileOpen) {
|
|
49
|
+
// Move focus into the drawer so a keyboard user lands where the
|
|
50
|
+
// content is, and Escape has somewhere to close from.
|
|
51
|
+
queueMicrotask(() => {
|
|
52
|
+
const sidebar = this.elementRef.shadowRoot?.querySelector('.ml-app-shell__sidebar');
|
|
53
|
+
focusFirst(sidebar ?? this.elementRef);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.focusMenuButton();
|
|
58
|
+
}
|
|
47
59
|
};
|
|
48
60
|
/** Close mobile sidebar */
|
|
49
61
|
this.closeMobileSidebar = () => {
|
|
62
|
+
if (!this.mobileOpen) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
50
65
|
this.mobileOpen = false;
|
|
66
|
+
this.focusMenuButton();
|
|
51
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Escape closes the mobile drawer. It had no keyboard dismissal at all:
|
|
70
|
+
* the only way out was clicking the backdrop.
|
|
71
|
+
*/
|
|
72
|
+
this.handleKeyDown = (event) => {
|
|
73
|
+
if (event.key === 'Escape' && this.mobileOpen) {
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
this.closeMobileSidebar();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The viewport width below which the sidebar becomes a drawer, read from
|
|
81
|
+
* `--ml-app-shell-mobile-breakpoint`. The value used to be hardcoded in
|
|
82
|
+
* both the stylesheet and here, so overriding it in CSS left the JS
|
|
83
|
+
* behaviour switching at the old width.
|
|
84
|
+
*/
|
|
85
|
+
get mobileBreakpoint() {
|
|
86
|
+
const value = getComputedStyle(this.elementRef).getPropertyValue('--ml-app-shell-mobile-breakpoint').trim();
|
|
87
|
+
return value || '768px';
|
|
52
88
|
}
|
|
53
89
|
onCreate() {
|
|
54
|
-
|
|
90
|
+
// Read the breakpoint from the same custom property the stylesheet uses,
|
|
91
|
+
// so overriding one no longer desynchronises JS from CSS.
|
|
92
|
+
this._mediaQuery = window.matchMedia(`(min-width: ${this.mobileBreakpoint})`);
|
|
55
93
|
this._mediaQuery.addEventListener('change', this._handleMediaChange);
|
|
56
94
|
this.mobile = !this._mediaQuery.matches;
|
|
57
95
|
}
|
|
58
96
|
onDestroy() {
|
|
59
97
|
this._mediaQuery?.removeEventListener('change', this._handleMediaChange);
|
|
60
98
|
}
|
|
99
|
+
focusMenuButton() {
|
|
100
|
+
queueMicrotask(() => {
|
|
101
|
+
const button = this.elementRef.shadowRoot?.querySelector('.ml-app-shell__menu-btn');
|
|
102
|
+
button?.focus();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
61
105
|
onMediaChange(event) {
|
|
62
106
|
this.mobile = !event.matches;
|
|
63
107
|
if (event.matches) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-shell.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/app-shell/app-shell.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"app-shell.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/app-shell/app-shell.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDAyO1B,CAAC"}
|
|
@@ -13,6 +13,10 @@ export const appShellStyles = () => css `
|
|
|
13
13
|
|
|
14
14
|
/* Mobile sidebar */
|
|
15
15
|
--ml-app-shell-sidebar-width: var(--ml-sidebar-width, 280px);
|
|
16
|
+
--ml-app-shell-sidebar-collapsed-width: var(--ml-sidebar-collapsed-width, 64px);
|
|
17
|
+
/* Viewport width below which the sidebar becomes a drawer. Kept in one
|
|
18
|
+
place so the CSS media query and the component's matchMedia agree. */
|
|
19
|
+
--ml-app-shell-mobile-breakpoint: 768px;
|
|
16
20
|
--ml-app-shell-sidebar-bg: var(--ml-color-surface);
|
|
17
21
|
--ml-app-shell-sidebar-transition: var(--ml-duration-200);
|
|
18
22
|
|
|
@@ -47,6 +51,17 @@ export const appShellStyles = () => css `
|
|
|
47
51
|
overflow: hidden;
|
|
48
52
|
}
|
|
49
53
|
|
|
54
|
+
/*
|
|
55
|
+
* Collapsed sidebar: narrow the sidebar column to an icon rail. This
|
|
56
|
+
* modifier class was rendered but had no rules at all, so the documented
|
|
57
|
+
* icon-only collapse did nothing.
|
|
58
|
+
*/
|
|
59
|
+
.ml-app-shell--sidebar-collapsed .ml-app-shell__sidebar {
|
|
60
|
+
width: var(--ml-app-shell-sidebar-collapsed-width);
|
|
61
|
+
min-width: var(--ml-app-shell-sidebar-collapsed-width);
|
|
62
|
+
transition: width var(--ml-app-shell-sidebar-transition) var(--ml-ease-in-out);
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
/* Sidebar on the right */
|
|
51
66
|
.ml-app-shell--sidebar-right {
|
|
52
67
|
grid-template-columns: 1fr auto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-shell.template.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/app-shell/app-shell.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"app-shell.template.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/app-shell/app-shell.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,iBAAiB,6CAgEpD"}
|
|
@@ -14,6 +14,7 @@ export function appShellTemplate(c) {
|
|
|
14
14
|
'ml-app-shell--header-fixed': headerFixed,
|
|
15
15
|
'ml-app-shell--mobile-open': mobileOpen
|
|
16
16
|
})}
|
|
17
|
+
@keydown=${c.handleKeyDown}
|
|
17
18
|
>
|
|
18
19
|
${when(isMobile, () => html `
|
|
19
20
|
<div
|
|
@@ -26,10 +27,12 @@ export function appShellTemplate(c) {
|
|
|
26
27
|
`)}
|
|
27
28
|
|
|
28
29
|
<aside
|
|
30
|
+
id="app-shell-sidebar"
|
|
29
31
|
class=${classMap({
|
|
30
32
|
'ml-app-shell__sidebar': true,
|
|
31
33
|
'ml-app-shell__sidebar--mobile-open': mobileOpen
|
|
32
34
|
})}
|
|
35
|
+
aria-hidden=${isMobile && !mobileOpen ? 'true' : 'false'}
|
|
33
36
|
>
|
|
34
37
|
<slot name="sidebar"></slot>
|
|
35
38
|
</aside>
|
|
@@ -41,6 +44,8 @@ export function appShellTemplate(c) {
|
|
|
41
44
|
class="ml-app-shell__menu-btn"
|
|
42
45
|
type="button"
|
|
43
46
|
aria-label="Toggle navigation"
|
|
47
|
+
aria-expanded=${mobileOpen ? 'true' : 'false'}
|
|
48
|
+
aria-controls="app-shell-sidebar"
|
|
44
49
|
@click=${c.toggleMobileSidebar}
|
|
45
50
|
>
|
|
46
51
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-section.template.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/page-section/page-section.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"page-section.template.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/page-section/page-section.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAIxE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,oBAAoB,6CAqC1D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { html, classMap, when } from '@melodicdev/core';
|
|
2
2
|
import { sanitizeHref } from './sanitize-href.function.js';
|
|
3
|
+
import { routeAnchorClick } from '../../navigation/functions/route-link.function.js';
|
|
3
4
|
/**
|
|
4
5
|
* The header (and its action slot) is always rendered so `slotchange` fires
|
|
5
6
|
* when action content is added or removed after mount (see
|
|
@@ -28,7 +29,11 @@ export function pageSectionTemplate(c) {
|
|
|
28
29
|
<div class="ml-page-section__action">
|
|
29
30
|
<slot name="action">
|
|
30
31
|
${when(!!c.actionLabel, () => html `
|
|
31
|
-
<a
|
|
32
|
+
<a
|
|
33
|
+
class="ml-page-section__action-link"
|
|
34
|
+
href=${sanitizeHref(c.actionHref)}
|
|
35
|
+
@click=${(event) => routeAnchorClick(event, sanitizeHref(c.actionHref))}
|
|
36
|
+
>${c.actionLabel}</a>
|
|
32
37
|
`)}
|
|
33
38
|
</slot>
|
|
34
39
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.directive.d.ts","sourceRoot":"","sources":["../../src/directives/tooltip.directive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAEnF,OAAO,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"tooltip.directive.d.ts","sourceRoot":"","sources":["../../src/directives/tooltip.directive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAEnF,OAAO,yCAAyC,CAAC;AAIjD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAiJD,iBAAS,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,iCAAiC,GAAG,IAAI,CA0CpG;AAID,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { registerAttributeDirective } from '@melodicdev/core/template';
|
|
2
2
|
// Registers the <ml-tooltip> custom element the directive instantiates.
|
|
3
3
|
import '../components/overlays/tooltip/index.js';
|
|
4
|
+
import { setCrossRootDescription, clearCrossRootDescription } from '../utils/accessibility/cross-root-aria.js';
|
|
4
5
|
/**
|
|
5
6
|
* Live tooltip state per decorated element. The template engine always runs
|
|
6
7
|
* the previous cleanup before re-running a directive with a new value; the
|
|
@@ -54,14 +55,45 @@ function createState(element) {
|
|
|
54
55
|
element.addEventListener('focusin', show);
|
|
55
56
|
element.addEventListener('focusout', hide);
|
|
56
57
|
const state = { tooltip, pendingRemoval: false, ownsDescribedBy: false, show, hide };
|
|
57
|
-
// Mirror ml-tooltip's slotted-trigger ARIA wiring
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
// Mirror ml-tooltip's slotted-trigger ARIA wiring. The content lives inside
|
|
59
|
+
// the tooltip's shadow root, so an IDREF would resolve to nothing —
|
|
60
|
+
// describe the element with the content ELEMENT instead.
|
|
61
|
+
//
|
|
62
|
+
// The tooltip has only just been created here, so its shadow content does
|
|
63
|
+
// not exist yet; wiring it synchronously silently described nothing at all.
|
|
64
|
+
describeWhenReady(element, tooltip, state);
|
|
65
|
+
return state;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Attach the description once the tooltip has rendered its content.
|
|
69
|
+
*
|
|
70
|
+
* Melodic renders on a microtask, so the content element appears shortly after
|
|
71
|
+
* the tooltip is constructed. A couple of microtask turns is enough; the
|
|
72
|
+
* fallback timeout covers a tooltip whose first render is deferred further.
|
|
73
|
+
*/
|
|
74
|
+
function describeWhenReady(element, tooltip, state) {
|
|
75
|
+
if (element.hasAttribute('aria-describedby')) {
|
|
76
|
+
return; // the consumer wired their own description; never overwrite it
|
|
77
|
+
}
|
|
78
|
+
const attach = () => {
|
|
79
|
+
const content = tooltip.shadowRoot?.querySelector('.ml-tooltip__content');
|
|
80
|
+
if (!content || state.pendingRemoval) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
setCrossRootDescription(element, [content]);
|
|
62
84
|
state.ownsDescribedBy = true;
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
87
|
+
if (attach()) {
|
|
88
|
+
return;
|
|
63
89
|
}
|
|
64
|
-
|
|
90
|
+
void Promise.resolve()
|
|
91
|
+
.then(() => attach())
|
|
92
|
+
.then((done) => {
|
|
93
|
+
if (!done) {
|
|
94
|
+
setTimeout(attach, 0);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
65
97
|
}
|
|
66
98
|
function destroyState(element, state) {
|
|
67
99
|
element.removeEventListener('mouseenter', state.show);
|
|
@@ -69,6 +101,7 @@ function destroyState(element, state) {
|
|
|
69
101
|
element.removeEventListener('focusin', state.show);
|
|
70
102
|
element.removeEventListener('focusout', state.hide);
|
|
71
103
|
if (state.ownsDescribedBy) {
|
|
104
|
+
clearCrossRootDescription(element);
|
|
72
105
|
element.removeAttribute('aria-describedby');
|
|
73
106
|
}
|
|
74
107
|
state.tooltip.anchorEl = null;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { ThemeMode } from '../../types/index.js';
|
|
2
2
|
type ThemeChangeCallback = (theme: ThemeMode, resolvedTheme: 'light' | 'dark') => void;
|
|
3
3
|
/**
|
|
4
|
-
* Get the currently applied theme mode
|
|
4
|
+
* Get the currently applied theme mode.
|
|
5
|
+
*
|
|
6
|
+
* Before `applyTheme()` has been called this reflects the document's own
|
|
7
|
+
* `data-theme`, so a theme applied by an inline script is respected.
|
|
5
8
|
*/
|
|
6
9
|
export declare function getTheme(): ThemeMode;
|
|
7
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-theme.function.d.ts","sourceRoot":"","sources":["../../../src/theme/functions/apply-theme.function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,KAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"apply-theme.function.d.ts","sourceRoot":"","sources":["../../../src/theme/functions/apply-theme.function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,KAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,CAAC;AAmBvF;;;;;GAKG;AACH,wBAAgB,QAAQ,IAAI,SAAS,CAGpC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,GAAG,MAAM,CAUnD;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAmCjD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI,CAGvE;AAMD;;;GAGG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC"}
|
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
// `null` until the first read, which adopts whatever the document already
|
|
2
|
+
// says. An inline anti-FOUC script setting data-theme="dark" before the module
|
|
3
|
+
// loads is the normal case, and assuming 'system' made the first toggleTheme()
|
|
4
|
+
// a no-op (it re-applied the theme that was already showing).
|
|
5
|
+
let currentTheme = null;
|
|
2
6
|
const themeListeners = new Set();
|
|
3
7
|
let mediaQueryCleanup = null;
|
|
8
|
+
function readDocumentTheme() {
|
|
9
|
+
if (typeof document === 'undefined') {
|
|
10
|
+
return 'system';
|
|
11
|
+
}
|
|
12
|
+
const attribute = document.documentElement.getAttribute('data-theme');
|
|
13
|
+
return attribute === 'light' || attribute === 'dark' ? attribute : 'system';
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
|
-
* Get the currently applied theme mode
|
|
16
|
+
* Get the currently applied theme mode.
|
|
17
|
+
*
|
|
18
|
+
* Before `applyTheme()` has been called this reflects the document's own
|
|
19
|
+
* `data-theme`, so a theme applied by an inline script is respected.
|
|
6
20
|
*/
|
|
7
21
|
export function getTheme() {
|
|
22
|
+
currentTheme ??= readDocumentTheme();
|
|
8
23
|
return currentTheme;
|
|
9
24
|
}
|
|
10
25
|
/**
|
|
11
26
|
* Get the resolved theme (light or dark) based on current mode
|
|
12
27
|
*/
|
|
13
28
|
export function getResolvedTheme() {
|
|
14
|
-
|
|
29
|
+
const theme = getTheme();
|
|
30
|
+
if (theme === 'system') {
|
|
15
31
|
if (typeof window === 'undefined' || !window.matchMedia) {
|
|
16
32
|
return 'light';
|
|
17
33
|
}
|
|
18
34
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
19
35
|
}
|
|
20
|
-
return
|
|
36
|
+
return theme;
|
|
21
37
|
}
|
|
22
38
|
/**
|
|
23
39
|
* Apply a theme mode to the document
|
|
@@ -7,7 +7,6 @@ const TOKEN_NAME_PATTERN = /^--[a-zA-Z0-9_-]+$/;
|
|
|
7
7
|
* arbitrary CSS rules (`;`, `{`, `}`) or markup when the returned CSS string
|
|
8
8
|
* is embedded in a page (`<`, `>`), plus control characters.
|
|
9
9
|
*/
|
|
10
|
-
// eslint-disable-next-line no-control-regex
|
|
11
10
|
const UNSAFE_VALUE_PATTERN = /[;{}<>\u0000-\u001f\u007f]/;
|
|
12
11
|
function assertValidThemeName(name) {
|
|
13
12
|
if (!THEME_NAME_PATTERN.test(name)) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ARIA relationships that cross a shadow-root boundary.
|
|
3
|
+
*
|
|
4
|
+
* `aria-describedby`, `aria-labelledby` and friends are IDREFs, and an IDREF
|
|
5
|
+
* only resolves within the same tree. A component whose description lives in
|
|
6
|
+
* its shadow root therefore cannot point a light-DOM trigger at it — the
|
|
7
|
+
* attribute is set, resolves to nothing, and the content is never announced.
|
|
8
|
+
*
|
|
9
|
+
* Element-reference properties (`ariaDescribedByElements`,
|
|
10
|
+
* `ariaLabelledByElements`) do cross the boundary and are the correct fix
|
|
11
|
+
* where they exist. Where they do not, the text itself is copied onto the
|
|
12
|
+
* element via `aria-description` / `aria-label`, which is announced even
|
|
13
|
+
* though it duplicates the string.
|
|
14
|
+
*/
|
|
15
|
+
/** True when this engine supports ARIA element references. */
|
|
16
|
+
export declare function supportsAriaElementReferences(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Describe `target` with `describers`, which may live in another root.
|
|
19
|
+
* Pass an empty array to clear the relationship.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setCrossRootDescription(target: Element, describers: Element[]): void;
|
|
22
|
+
/** Label `target` with `labels`, which may live in another root. */
|
|
23
|
+
export declare function setCrossRootLabel(target: Element, labels: Element[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* Point `target` at the currently active option, which may live in another
|
|
26
|
+
* root (a composite listbox's options are in the light DOM while the focused
|
|
27
|
+
* control is inside a shadow root).
|
|
28
|
+
*/
|
|
29
|
+
export declare function setCrossRootActiveDescendant(target: Element, active: Element | null): void;
|
|
30
|
+
/**
|
|
31
|
+
* The element that actually takes focus for a (possibly composite) control.
|
|
32
|
+
*
|
|
33
|
+
* ARIA state must sit on the focusable node, not on a wrapper: setting
|
|
34
|
+
* `aria-haspopup`/`aria-expanded` on an `<ml-button>` host leaves the real
|
|
35
|
+
* `<button>` inside its shadow root announcing nothing.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getFocusableControl(element: Element): HTMLElement;
|
|
38
|
+
/** Remove any cross-root description this module applied. */
|
|
39
|
+
export declare function clearCrossRootDescription(target: Element): void;
|
|
40
|
+
//# sourceMappingURL=cross-root-aria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cross-root-aria.d.ts","sourceRoot":"","sources":["../../../src/utils/accessibility/cross-root-aria.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,8DAA8D;AAC9D,wBAAgB,6BAA6B,IAAI,OAAO,CAEvD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAmBpF;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAkB1E;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAa1F;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAWjE;AAED,6DAA6D;AAC7D,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAE/D"}
|