@melodicdev/components 4.0.1 → 4.2.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.
Files changed (210) hide show
  1. package/README.md +4 -4
  2. package/assets/fonts/phosphor/phosphor.css +5 -25
  3. package/assets/melodic-components.css +50 -25
  4. package/assets/melodic-components.js +5374 -4233
  5. package/assets/melodic-components.js.map +1 -1
  6. package/assets/melodic-components.min.css +1 -21
  7. package/assets/melodic-components.min.js +1808 -26662
  8. package/lib/components/data-display/calendar-view/calendar-view.styles.d.ts.map +1 -1
  9. package/lib/components/data-display/calendar-view/calendar-view.styles.js +14 -0
  10. package/lib/components/data-display/data-grid/data-grid.component.d.ts +43 -2
  11. package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
  12. package/lib/components/data-display/data-grid/data-grid.component.js +94 -8
  13. package/lib/components/data-display/data-grid/data-grid.styles.d.ts.map +1 -1
  14. package/lib/components/data-display/data-grid/data-grid.styles.js +17 -0
  15. package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
  16. package/lib/components/data-display/data-grid/data-grid.template.js +19 -10
  17. package/lib/components/data-display/data-grid/index.d.ts +1 -0
  18. package/lib/components/data-display/data-grid/index.d.ts.map +1 -1
  19. package/lib/components/data-display/list/list-item.styles.js +1 -1
  20. package/lib/components/data-display/table/index.d.ts +1 -0
  21. package/lib/components/data-display/table/index.d.ts.map +1 -1
  22. package/lib/components/data-display/table/table.component.d.ts +16 -0
  23. package/lib/components/data-display/table/table.component.d.ts.map +1 -1
  24. package/lib/components/data-display/table/table.component.js +28 -3
  25. package/lib/components/data-display/table/table.styles.d.ts.map +1 -1
  26. package/lib/components/data-display/table/table.styles.js +7 -1
  27. package/lib/components/data-display/table/table.template.d.ts.map +1 -1
  28. package/lib/components/data-display/table/table.template.js +8 -6
  29. package/lib/components/data-display/table-core/index.d.ts +2 -2
  30. package/lib/components/data-display/table-core/index.d.ts.map +1 -1
  31. package/lib/components/data-display/table-core/index.js +1 -1
  32. package/lib/components/data-display/table-core/table-core.d.ts +16 -2
  33. package/lib/components/data-display/table-core/table-core.d.ts.map +1 -1
  34. package/lib/components/data-display/table-core/table-core.js +32 -5
  35. package/lib/components/data-display/tag/tag.styles.d.ts.map +1 -1
  36. package/lib/components/data-display/tag/tag.styles.js +11 -4
  37. package/lib/components/feedback/alert/alert.styles.d.ts.map +1 -1
  38. package/lib/components/feedback/alert/alert.styles.js +11 -0
  39. package/lib/components/feedback/toast/index.d.ts +1 -0
  40. package/lib/components/feedback/toast/index.d.ts.map +1 -1
  41. package/lib/components/feedback/toast/toast-container.styles.d.ts.map +1 -1
  42. package/lib/components/feedback/toast/toast-container.styles.js +20 -0
  43. package/lib/components/feedback/toast/toast.component.d.ts +16 -0
  44. package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
  45. package/lib/components/feedback/toast/toast.component.js +63 -5
  46. package/lib/components/feedback/toast/toast.service.d.ts +14 -0
  47. package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
  48. package/lib/components/feedback/toast/toast.service.js +41 -0
  49. package/lib/components/feedback/toast/toast.styles.d.ts.map +1 -1
  50. package/lib/components/feedback/toast/toast.styles.js +6 -0
  51. package/lib/components/feedback/toast/toast.template.js +1 -1
  52. package/lib/components/forms/autocomplete/autocomplete.component.d.ts +14 -4
  53. package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
  54. package/lib/components/forms/autocomplete/autocomplete.component.js +40 -96
  55. package/lib/components/forms/autocomplete/autocomplete.styles.d.ts.map +1 -1
  56. package/lib/components/forms/autocomplete/autocomplete.styles.js +22 -6
  57. package/lib/components/forms/autocomplete/autocomplete.template.js +7 -1
  58. package/lib/components/forms/button/button.styles.d.ts.map +1 -1
  59. package/lib/components/forms/button/button.styles.js +11 -0
  60. package/lib/components/forms/button-group/button-group-item.styles.d.ts.map +1 -1
  61. package/lib/components/forms/button-group/button-group-item.styles.js +11 -0
  62. package/lib/components/forms/button-group/button-group.styles.js +2 -2
  63. package/lib/components/forms/checkbox/checkbox.styles.d.ts.map +1 -1
  64. package/lib/components/forms/checkbox/checkbox.styles.js +13 -2
  65. package/lib/components/forms/date-picker/calendar.component.d.ts +20 -7
  66. package/lib/components/forms/date-picker/calendar.component.d.ts.map +1 -1
  67. package/lib/components/forms/date-picker/calendar.component.js +88 -13
  68. package/lib/components/forms/date-picker/calendar.styles.d.ts.map +1 -1
  69. package/lib/components/forms/date-picker/calendar.styles.js +19 -0
  70. package/lib/components/forms/date-picker/date-picker.component.d.ts +2 -3
  71. package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
  72. package/lib/components/forms/date-picker/date-picker.component.js +70 -18
  73. package/lib/components/forms/date-picker/date-picker.styles.d.ts.map +1 -1
  74. package/lib/components/forms/date-picker/date-picker.styles.js +12 -1
  75. package/lib/components/forms/date-time-picker/date-time-picker.styles.d.ts.map +1 -1
  76. package/lib/components/forms/date-time-picker/date-time-picker.styles.js +12 -1
  77. package/lib/components/forms/date-time-picker/tz-utils.d.ts.map +1 -1
  78. package/lib/components/forms/date-time-picker/tz-utils.js +24 -3
  79. package/lib/components/forms/file-upload/file-upload-item.styles.d.ts.map +1 -1
  80. package/lib/components/forms/file-upload/file-upload-item.styles.js +13 -1
  81. package/lib/components/forms/file-upload/file-upload.styles.d.ts.map +1 -1
  82. package/lib/components/forms/file-upload/file-upload.styles.js +11 -0
  83. package/lib/components/forms/form-field/form-field.component.d.ts +18 -1
  84. package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
  85. package/lib/components/forms/form-field/form-field.component.js +55 -16
  86. package/lib/components/forms/form-field/form-field.styles.d.ts.map +1 -1
  87. package/lib/components/forms/form-field/form-field.styles.js +15 -2
  88. package/lib/components/forms/input/input.styles.d.ts.map +1 -1
  89. package/lib/components/forms/input/input.styles.js +16 -1
  90. package/lib/components/forms/listbox-core/index.d.ts +3 -0
  91. package/lib/components/forms/listbox-core/index.d.ts.map +1 -0
  92. package/lib/components/forms/listbox-core/index.js +2 -0
  93. package/lib/components/forms/listbox-core/listbox-core.d.ts +57 -0
  94. package/lib/components/forms/listbox-core/listbox-core.d.ts.map +1 -0
  95. package/lib/components/forms/listbox-core/listbox-core.js +168 -0
  96. package/lib/components/forms/radio/radio-group.styles.js +1 -1
  97. package/lib/components/forms/radio/radio.styles.d.ts.map +1 -1
  98. package/lib/components/forms/radio/radio.styles.js +12 -1
  99. package/lib/components/forms/radio-card-group/radio-card-group.styles.js +1 -1
  100. package/lib/components/forms/radio-card-group/radio-card.styles.d.ts.map +1 -1
  101. package/lib/components/forms/radio-card-group/radio-card.styles.js +11 -0
  102. package/lib/components/forms/select/select.component.d.ts +12 -4
  103. package/lib/components/forms/select/select.component.d.ts.map +1 -1
  104. package/lib/components/forms/select/select.component.js +41 -110
  105. package/lib/components/forms/select/select.styles.d.ts.map +1 -1
  106. package/lib/components/forms/select/select.styles.js +23 -6
  107. package/lib/components/forms/select/select.template.d.ts.map +1 -1
  108. package/lib/components/forms/select/select.template.js +25 -9
  109. package/lib/components/forms/slider/slider.component.js +1 -1
  110. package/lib/components/forms/slider/slider.styles.d.ts.map +1 -1
  111. package/lib/components/forms/slider/slider.styles.js +11 -0
  112. package/lib/components/forms/slider/slider.template.d.ts.map +1 -1
  113. package/lib/components/forms/slider/slider.template.js +5 -1
  114. package/lib/components/forms/textarea/textarea.styles.d.ts.map +1 -1
  115. package/lib/components/forms/textarea/textarea.styles.js +13 -2
  116. package/lib/components/forms/time-picker/time-picker.component.d.ts +1 -2
  117. package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
  118. package/lib/components/forms/time-picker/time-picker.component.js +8 -17
  119. package/lib/components/forms/time-picker/time-picker.styles.d.ts.map +1 -1
  120. package/lib/components/forms/time-picker/time-picker.styles.js +23 -3
  121. package/lib/components/forms/toggle/toggle.styles.d.ts.map +1 -1
  122. package/lib/components/forms/toggle/toggle.styles.js +13 -2
  123. package/lib/components/foundation/card/card.styles.d.ts.map +1 -1
  124. package/lib/components/foundation/card/card.styles.js +11 -0
  125. package/lib/components/foundation/container/container.styles.js +4 -4
  126. package/lib/components/navigation/breadcrumb/breadcrumb-item.template.d.ts.map +1 -1
  127. package/lib/components/navigation/breadcrumb/breadcrumb-item.template.js +5 -3
  128. package/lib/components/navigation/sidebar/sidebar-item.styles.js +4 -4
  129. package/lib/components/navigation/sidebar/sidebar-item.template.js +2 -2
  130. package/lib/components/navigation/sidebar/sidebar.styles.js +5 -5
  131. package/lib/components/navigation/sidebar/sidebar.template.js +2 -2
  132. package/lib/components/navigation/steps/step.styles.js +3 -3
  133. package/lib/components/navigation/steps/steps.styles.js +3 -3
  134. package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
  135. package/lib/components/navigation/tabs/tabs.component.js +4 -1
  136. package/lib/components/navigation/tabs/tabs.styles.js +8 -8
  137. package/lib/components/overlays/dialog/dialog.component.d.ts +15 -2
  138. package/lib/components/overlays/dialog/dialog.component.d.ts.map +1 -1
  139. package/lib/components/overlays/dialog/dialog.component.js +33 -1
  140. package/lib/components/overlays/dialog/dialog.service.d.ts +8 -2
  141. package/lib/components/overlays/dialog/dialog.service.d.ts.map +1 -1
  142. package/lib/components/overlays/dialog/dialog.service.js +1 -0
  143. package/lib/components/overlays/dialog/index.d.ts +1 -0
  144. package/lib/components/overlays/dialog/index.d.ts.map +1 -1
  145. package/lib/components/overlays/drawer/drawer.component.d.ts +18 -3
  146. package/lib/components/overlays/drawer/drawer.component.d.ts.map +1 -1
  147. package/lib/components/overlays/drawer/drawer.component.js +59 -16
  148. package/lib/components/overlays/dropdown/dropdown-item.styles.d.ts.map +1 -1
  149. package/lib/components/overlays/dropdown/dropdown-item.styles.js +12 -0
  150. package/lib/components/overlays/popover/popover.component.d.ts +12 -0
  151. package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
  152. package/lib/components/overlays/popover/popover.component.js +28 -1
  153. package/lib/components/overlays/popover/popover.template.d.ts.map +1 -1
  154. package/lib/components/overlays/popover/popover.template.js +2 -0
  155. package/lib/components/overlays/tooltip/tooltip.component.d.ts +8 -5
  156. package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
  157. package/lib/components/overlays/tooltip/tooltip.component.js +10 -3
  158. package/lib/components/sections/app-shell/app-shell.styles.js +1 -1
  159. package/lib/directives/tooltip.directive.d.ts.map +1 -1
  160. package/lib/directives/tooltip.directive.js +22 -3
  161. package/lib/theme/presets/base.preset.d.ts.map +1 -1
  162. package/lib/theme/presets/base.preset.js +17 -0
  163. package/lib/theme/presets/dark.preset.d.ts +8 -0
  164. package/lib/theme/presets/dark.preset.d.ts.map +1 -1
  165. package/lib/theme/presets/dark.preset.js +9 -0
  166. package/lib/theme/presets/light.preset.d.ts +6 -0
  167. package/lib/theme/presets/light.preset.d.ts.map +1 -1
  168. package/lib/theme/presets/light.preset.js +7 -0
  169. package/lib/theme/tokens/all-tokens.d.ts +10 -0
  170. package/lib/theme/tokens/all-tokens.d.ts.map +1 -1
  171. package/lib/theme/tokens/colors.tokens.d.ts +8 -0
  172. package/lib/theme/tokens/colors.tokens.d.ts.map +1 -1
  173. package/lib/theme/tokens/colors.tokens.js +11 -0
  174. package/lib/theme/tokens/transitions.tokens.d.ts +1 -0
  175. package/lib/theme/tokens/transitions.tokens.d.ts.map +1 -1
  176. package/lib/theme/tokens/transitions.tokens.js +3 -0
  177. package/lib/theme/tokens/typography.tokens.d.ts +1 -0
  178. package/lib/theme/tokens/typography.tokens.d.ts.map +1 -1
  179. package/lib/theme/tokens/typography.tokens.js +1 -0
  180. package/lib/utils/accessibility/cross-root-aria.d.ts +16 -8
  181. package/lib/utils/accessibility/cross-root-aria.d.ts.map +1 -1
  182. package/lib/utils/accessibility/cross-root-aria.js +58 -22
  183. package/lib/utils/accessibility/focus-trap.d.ts.map +1 -1
  184. package/lib/utils/accessibility/focus-trap.js +9 -19
  185. package/lib/utils/accessibility/focus-utils.d.ts +10 -1
  186. package/lib/utils/accessibility/focus-utils.d.ts.map +1 -1
  187. package/lib/utils/accessibility/focus-utils.js +48 -14
  188. package/lib/utils/accessibility/index.d.ts +2 -1
  189. package/lib/utils/accessibility/index.d.ts.map +1 -1
  190. package/lib/utils/accessibility/index.js +1 -1
  191. package/lib/utils/positioning/compute-position.d.ts +6 -1
  192. package/lib/utils/positioning/compute-position.d.ts.map +1 -1
  193. package/lib/utils/positioning/compute-position.js +3 -2
  194. package/lib/utils/positioning/middlewares/flip.middleware.js +2 -51
  195. package/package.json +8 -5
  196. package/assets/fonts/phosphor/Phosphor-Bold.svg +0 -3057
  197. package/assets/fonts/phosphor/Phosphor-Bold.ttf +0 -0
  198. package/assets/fonts/phosphor/Phosphor-Bold.woff +0 -0
  199. package/assets/fonts/phosphor/Phosphor-Fill.svg +0 -3057
  200. package/assets/fonts/phosphor/Phosphor-Fill.ttf +0 -0
  201. package/assets/fonts/phosphor/Phosphor-Fill.woff +0 -0
  202. package/assets/fonts/phosphor/Phosphor-Light.svg +0 -3057
  203. package/assets/fonts/phosphor/Phosphor-Light.ttf +0 -0
  204. package/assets/fonts/phosphor/Phosphor-Light.woff +0 -0
  205. package/assets/fonts/phosphor/Phosphor-Thin.svg +0 -3057
  206. package/assets/fonts/phosphor/Phosphor-Thin.ttf +0 -0
  207. package/assets/fonts/phosphor/Phosphor-Thin.woff +0 -0
  208. package/assets/fonts/phosphor/Phosphor.svg +0 -3056
  209. package/assets/fonts/phosphor/Phosphor.ttf +0 -0
  210. package/assets/fonts/phosphor/Phosphor.woff +0 -0
@@ -10,15 +10,45 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { MelodicComponent, Service } from '@melodicdev/core';
11
11
  import { dialogTemplate } from './dialog.template';
12
12
  import { dialogStyles } from './dialog.styles';
13
+ import { setCrossRootLabel } from '../../../utils/accessibility/cross-root-aria';
13
14
  import { newID } from '../../../functions/new-id.function';
14
15
  import { DialogService } from './dialog.service';
15
16
  let DialogComponent = class DialogComponent {
16
17
  constructor() {
18
+ /**
19
+ * Accessible name for the dialog (`aria-label`). Optional: when omitted,
20
+ * the dialog is named by whatever is slotted into `dialog-header`.
21
+ */
22
+ this.label = '';
17
23
  this._dialogID = newID();
18
24
  this._registered = false;
25
+ /**
26
+ * Give the `<dialog>` an accessible name — it had none, so a screen
27
+ * reader announced just "dialog". An explicit `label` wins; otherwise the
28
+ * slotted header names it (the header is in the light DOM, an ancestor
29
+ * tree of this shadow root, so an element reference to it is valid).
30
+ */
31
+ this.syncAccessibleName = () => {
32
+ const root = this.elementRef.shadowRoot;
33
+ const dialogEl = root?.querySelector('dialog');
34
+ if (!root || !dialogEl)
35
+ return;
36
+ if (this.label) {
37
+ setCrossRootLabel(dialogEl, []);
38
+ dialogEl.setAttribute('aria-label', this.label);
39
+ return;
40
+ }
41
+ const slot = root.querySelector('slot[name="dialog-header"]');
42
+ setCrossRootLabel(dialogEl, slot?.assignedElements({ flatten: true }) ?? []);
43
+ };
19
44
  }
20
45
  onCreate() {
21
46
  this.registerDialog();
47
+ this.elementRef.shadowRoot?.addEventListener('slotchange', this.syncAccessibleName);
48
+ this.syncAccessibleName();
49
+ }
50
+ onRender() {
51
+ this.syncAccessibleName();
22
52
  }
23
53
  registerDialog() {
24
54
  if (this._registered)
@@ -36,6 +66,7 @@ let DialogComponent = class DialogComponent {
36
66
  // Only this element should be able to remove its own registration. On a
37
67
  // re-render the new instance registers (same id) before this stale one
38
68
  // tears down; passing our element lets the service ignore that delete.
69
+ this.elementRef.shadowRoot?.removeEventListener('slotchange', this.syncAccessibleName);
39
70
  if (!this._registered)
40
71
  return;
41
72
  this._dialogService.removeDialog(this._dialogID, this._dialogEl);
@@ -46,6 +77,7 @@ let DialogComponent = class DialogComponent {
46
77
  console.warn('[ml-dialog] Cannot open: dialog element is not rendered yet.');
47
78
  return;
48
79
  }
80
+ this.syncAccessibleName();
49
81
  this._dialogRef.open();
50
82
  }
51
83
  close(result) {
@@ -67,7 +99,7 @@ DialogComponent = __decorate([
67
99
  selector: 'ml-dialog',
68
100
  template: dialogTemplate,
69
101
  styles: dialogStyles,
70
- attributes: []
102
+ attributes: ['label']
71
103
  })
72
104
  ], DialogComponent);
73
105
  export { DialogComponent };
@@ -14,8 +14,14 @@ export declare class DialogService {
14
14
  */
15
15
  removeDialog(dialogID: UniqueID, dialogEl?: HTMLDialogElement): void;
16
16
  open<TResult = unknown, TData = unknown>(dialogComponent: new (...args: any[]) => any, config?: IDialogConfig<TData>): DialogRef<TResult, TData> | undefined;
17
- open<TResult = unknown, TData = unknown>(dialogID: UniqueID): DialogRef<TResult, TData> | undefined;
18
- close<T = unknown>(dialogID: UniqueID, result?: T): void;
17
+ /**
18
+ * Open an inline dialog by id: the name of the `#`-prefixed attribute on its
19
+ * `<ml-dialog>` (`<ml-dialog #confirm>` opens with `open('confirm')`), or a
20
+ * `DialogRef.dialogID`. A plain string is accepted; no `UniqueID` cast is needed.
21
+ */
22
+ open<TResult = unknown, TData = unknown>(dialogID: string): DialogRef<TResult, TData> | undefined;
23
+ /** Close a dialog by id. Takes the same plain-string id as `open()`. */
24
+ close<T = unknown>(dialogID: string, result?: T): void;
19
25
  private cleanUpDialog;
20
26
  private mountDialog;
21
27
  private unmountDialog;
@@ -1 +1 @@
1
- {"version":3,"file":"dialog.service.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dialog/dialog.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAa/D,qBACa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwC;IAE1D,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,SAAS;IA2B5E;;;;;;;OAOG;IACI,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAcpE,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAAE,eAAe,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,SAAS;IAC5J,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,SAAS;IA4CnG,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI;IAU/D,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,aAAa;CAGrB"}
1
+ {"version":3,"file":"dialog.service.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dialog/dialog.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAa/D,qBACa,aAAa;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwC;IAE1D,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,SAAS;IA2B5E;;;;;;;OAOG;IACI,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAcpE,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAAE,eAAe,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,SAAS;IACnK;;;;OAIG;IACI,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,KAAK,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,SAAS;IA4CxG,wEAAwE;IACjE,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI;IAU7D,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,aAAa;CAGrB"}
@@ -84,6 +84,7 @@ let DialogService = class DialogService {
84
84
  dialogElements.dialogRef.open();
85
85
  return dialogElements.dialogRef;
86
86
  }
87
+ /** Close a dialog by id. Takes the same plain-string id as `open()`. */
87
88
  close(dialogID, result) {
88
89
  const dialogElements = this._dialogs.get(dialogID);
89
90
  if (!dialogElements) {
@@ -2,5 +2,6 @@ export { DialogComponent } from './dialog.component';
2
2
  export { DialogService } from './dialog.service';
3
3
  export { DialogRef } from './dialog-ref.class';
4
4
  export type { IDialogRef } from './idialog-ref.interface';
5
+ export type { IDialogConfig } from './dialog-config.interface';
5
6
  export type { DialogComponentLoader } from './dialog-loader.type';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dialog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { IElementRef, OnCreate, OnDestroy } from '@melodicdev/core';
1
+ import type { IElementRef, OnCreate, OnDestroy, OnRender } from '@melodicdev/core';
2
2
  type DrawerSide = 'left' | 'right';
3
3
  type DrawerSize = 'sm' | 'md' | 'lg' | 'xl';
4
4
  /**
@@ -23,7 +23,7 @@ type DrawerSize = 'sm' | 'md' | 'lg' | 'xl';
23
23
  * @fires ml:close - Emitted when closing starts
24
24
  * @fires ml:closed - Emitted after the close animation finishes (dialog closed)
25
25
  */
26
- export declare class DrawerComponent implements IElementRef, OnCreate, OnDestroy {
26
+ export declare class DrawerComponent implements IElementRef, OnCreate, OnDestroy, OnRender {
27
27
  elementRef: HTMLElement;
28
28
  /** Which side the drawer slides from */
29
29
  side: DrawerSide;
@@ -31,17 +31,32 @@ export declare class DrawerComponent implements IElementRef, OnCreate, OnDestroy
31
31
  size: DrawerSize;
32
32
  /** Show close button in header */
33
33
  showClose: boolean;
34
+ /**
35
+ * Accessible name for the drawer (`aria-label`). Optional: when omitted,
36
+ * the drawer is named by whatever is slotted into `drawer-header`.
37
+ */
38
+ label: string;
34
39
  private _dialogEl;
35
40
  private _panelEl;
36
- private get _positionProp();
41
+ /** True while the slide-out animation is running (the dialog is still open). */
42
+ private _closing;
43
+ /** Off-screen transform for the current side. */
44
+ private get _offscreen();
37
45
  /**
38
46
  * Resolve slide animation timing from the component-scoped tokens
39
47
  * (--ml-drawer-transition-duration / --ml-drawer-transition-easing).
48
+ * Users who ask for reduced motion get no slide at all.
40
49
  */
41
50
  private getAnimationTiming;
42
51
  private cancelAnimations;
43
52
  onCreate(): void;
53
+ onRender(): void;
44
54
  onDestroy(): void;
55
+ /**
56
+ * Give the `<dialog>` an accessible name — it had none. An explicit
57
+ * `label` wins; otherwise the slotted header names it.
58
+ */
59
+ private readonly syncAccessibleName;
45
60
  /** Open the drawer */
46
61
  open(): void;
47
62
  /** Close the drawer */
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/drawer/drawer.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIzE,KAAK,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AACnC,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAMa,eAAgB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS;IAChE,UAAU,EAAG,WAAW,CAAC;IAEhC,wCAAwC;IACjC,IAAI,EAAE,UAAU,CAAW;IAElC,mBAAmB;IACZ,IAAI,EAAE,UAAU,CAAQ;IAE/B,kCAAkC;IAC3B,SAAS,UAAQ;IAExB,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,QAAQ,CAAe;IAE/B,OAAO,KAAK,aAAa,GAExB;IAED;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,gBAAgB;IAMjB,QAAQ,IAAI,IAAI;IAOhB,SAAS,IAAI,IAAI;IAKxB,sBAAsB;IACf,IAAI,IAAI,IAAI;IA2BnB,uBAAuB;IAChB,KAAK,QAAO,IAAI,CAuBrB;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAIlC;IAEF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAGjC;CACF"}
1
+ {"version":3,"file":"drawer.component.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/drawer/drawer.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKnF,KAAK,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AACnC,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAMa,eAAgB,YAAW,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;IAC1E,UAAU,EAAG,WAAW,CAAC;IAEhC,wCAAwC;IACjC,IAAI,EAAE,UAAU,CAAW;IAElC,mBAAmB;IACZ,IAAI,EAAE,UAAU,CAAQ;IAE/B,kCAAkC;IAC3B,SAAS,UAAQ;IAExB;;;OAGG;IACI,KAAK,SAAM;IAElB,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,QAAQ,CAAe;IAE/B,gFAAgF;IAChF,OAAO,CAAC,QAAQ,CAAS;IAEzB,iDAAiD;IACjD,OAAO,KAAK,UAAU,GAErB;IAED;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAsB1B,OAAO,CAAC,gBAAgB;IAMjB,QAAQ,IAAI,IAAI;IAShB,QAAQ,IAAI,IAAI;IAIhB,SAAS,IAAI,IAAI;IAMxB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAajC;IAEF,sBAAsB;IACf,IAAI,IAAI,IAAI;IA6BnB,uBAAuB;IAChB,KAAK,QAAO,IAAI,CAiBrB;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAIlC;IAEF,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAGjC;CACF"}
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { MelodicComponent } from '@melodicdev/core';
8
+ import { setCrossRootLabel } from '../../../utils/accessibility/cross-root-aria.js';
8
9
  import { drawerTemplate } from './drawer.template.js';
9
10
  import { drawerStyles } from './drawer.styles.js';
10
11
  /**
@@ -37,18 +38,42 @@ let DrawerComponent = class DrawerComponent {
37
38
  this.size = 'md';
38
39
  /** Show close button in header */
39
40
  this.showClose = true;
41
+ /**
42
+ * Accessible name for the drawer (`aria-label`). Optional: when omitted,
43
+ * the drawer is named by whatever is slotted into `drawer-header`.
44
+ */
45
+ this.label = '';
46
+ /** True while the slide-out animation is running (the dialog is still open). */
47
+ this._closing = false;
48
+ /**
49
+ * Give the `<dialog>` an accessible name — it had none. An explicit
50
+ * `label` wins; otherwise the slotted header names it.
51
+ */
52
+ this.syncAccessibleName = () => {
53
+ const root = this.elementRef.shadowRoot;
54
+ const dialogEl = root?.querySelector('dialog');
55
+ if (!root || !dialogEl)
56
+ return;
57
+ if (this.label) {
58
+ setCrossRootLabel(dialogEl, []);
59
+ dialogEl.setAttribute('aria-label', this.label);
60
+ return;
61
+ }
62
+ const slot = root.querySelector('slot[name="drawer-header"]');
63
+ setCrossRootLabel(dialogEl, slot?.assignedElements({ flatten: true }) ?? []);
64
+ };
40
65
  /** Close the drawer */
41
66
  this.close = () => {
42
- if (!this._dialogEl?.open)
67
+ if (!this._dialogEl?.open || this._closing)
43
68
  return;
44
69
  this.cancelAnimations();
45
- const prop = this._positionProp;
46
- const width = this._panelEl.offsetWidth;
70
+ this._closing = true;
47
71
  const { duration, easing } = this.getAnimationTiming();
48
- const anim = this._panelEl.animate([{ [prop]: '0px' }, { [prop]: `${-width}px` }], { duration, easing, fill: 'forwards' });
72
+ const anim = this._panelEl.animate([{ transform: 'translateX(0)' }, { transform: this._offscreen }], { duration, easing, fill: 'forwards' });
49
73
  anim.onfinish = () => {
50
- this._panelEl.style[prop] = '';
74
+ this._closing = false;
51
75
  this._dialogEl.close();
76
+ anim.cancel();
52
77
  this.elementRef.dispatchEvent(new CustomEvent('ml:closed', { bubbles: true, composed: true }));
53
78
  };
54
79
  // ml:close keeps its historical fire-at-start timing; ml:closed fires
@@ -65,12 +90,14 @@ let DrawerComponent = class DrawerComponent {
65
90
  this.close();
66
91
  };
67
92
  }
68
- get _positionProp() {
69
- return this.side === 'left' ? 'left' : 'right';
93
+ /** Off-screen transform for the current side. */
94
+ get _offscreen() {
95
+ return this.side === 'left' ? 'translateX(-100%)' : 'translateX(100%)';
70
96
  }
71
97
  /**
72
98
  * Resolve slide animation timing from the component-scoped tokens
73
99
  * (--ml-drawer-transition-duration / --ml-drawer-transition-easing).
100
+ * Users who ask for reduced motion get no slide at all.
74
101
  */
75
102
  getAnimationTiming() {
76
103
  const styles = getComputedStyle(this._panelEl);
@@ -86,6 +113,9 @@ let DrawerComponent = class DrawerComponent {
86
113
  if (!Number.isFinite(duration)) {
87
114
  duration = 300;
88
115
  }
116
+ if (typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
117
+ duration = 0;
118
+ }
89
119
  return { duration, easing: rawEasing || 'cubic-bezier(0.16, 1, 0.3, 1)' };
90
120
  }
91
121
  cancelAnimations() {
@@ -98,25 +128,38 @@ let DrawerComponent = class DrawerComponent {
98
128
  this._panelEl = this._dialogEl?.querySelector('.ml-drawer__panel');
99
129
  this._dialogEl?.addEventListener('click', this.handleBackdropClick);
100
130
  this._dialogEl?.addEventListener('cancel', this.handleDialogCancel);
131
+ this.elementRef.shadowRoot?.addEventListener('slotchange', this.syncAccessibleName);
132
+ this.syncAccessibleName();
133
+ }
134
+ onRender() {
135
+ this.syncAccessibleName();
101
136
  }
102
137
  onDestroy() {
103
138
  this._dialogEl?.removeEventListener('click', this.handleBackdropClick);
104
139
  this._dialogEl?.removeEventListener('cancel', this.handleDialogCancel);
140
+ this.elementRef.shadowRoot?.removeEventListener('slotchange', this.syncAccessibleName);
105
141
  }
106
142
  /** Open the drawer */
107
143
  open() {
108
- if (this._dialogEl?.open)
144
+ // Still open and not on its way out: nothing to do. A drawer that is
145
+ // mid-close IS still `open`, and used to swallow this call — it then
146
+ // finished closing even though open() was the last thing asked for.
147
+ if (this._dialogEl?.open && !this._closing)
109
148
  return;
149
+ this._closing = false;
110
150
  this.cancelAnimations();
111
- this._dialogEl.showModal();
112
- const prop = this._positionProp;
113
- const width = this._panelEl.offsetWidth;
151
+ this.syncAccessibleName();
152
+ if (!this._dialogEl.open) {
153
+ this._dialogEl.showModal();
154
+ }
155
+ // Slide with a transform (compositor-only) rather than animating
156
+ // `left`/`right`, which re-ran layout on every frame.
114
157
  const { duration, easing } = this.getAnimationTiming();
115
- this._panelEl.style[prop] = `${-width}px`;
116
- this._panelEl.getBoundingClientRect();
117
- const anim = this._panelEl.animate([{ [prop]: `${-width}px` }, { [prop]: '0px' }], { duration, easing, fill: 'forwards' });
158
+ const anim = this._panelEl.animate([{ transform: this._offscreen }, { transform: 'translateX(0)' }], { duration, easing, fill: 'forwards' });
118
159
  anim.onfinish = () => {
119
- this._panelEl.style[prop] = '0px';
160
+ // Drop the animation so no transform lingers on the panel (a
161
+ // transformed ancestor re-anchors position: fixed descendants).
162
+ anim.cancel();
120
163
  this.elementRef.dispatchEvent(new CustomEvent('ml:opened', { bubbles: true, composed: true }));
121
164
  };
122
165
  // ml:open keeps its historical fire-at-start timing; ml:opened fires
@@ -129,7 +172,7 @@ DrawerComponent = __decorate([
129
172
  selector: 'ml-drawer',
130
173
  template: drawerTemplate,
131
174
  styles: drawerStyles,
132
- attributes: ['side', 'size', 'show-close']
175
+ attributes: ['side', 'size', 'show-close', 'label']
133
176
  })
134
177
  ], DrawerComponent);
135
178
  export { DrawerComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown-item.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dropdown/dropdown-item.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,iDAkG9B,CAAC"}
1
+ {"version":3,"file":"dropdown-item.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/dropdown/dropdown-item.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,iDA8G9B,CAAC"}
@@ -97,4 +97,16 @@ export const dropdownItemStyles = () => css `
97
97
  font-size: var(--ml-dropdown-item-addon-font-size, 12px);
98
98
  color: var(--ml-dropdown-item-addon-color, var(--ml-color-text-tertiary));
99
99
  }
100
+
101
+ /*
102
+ * Forced colors (Windows High Contrast): box-shadow rings and background
103
+ * highlights are not painted there, so focus falls back to a real outline.
104
+ */
105
+ @media (forced-colors: active) {
106
+ .ml-dropdown-item--focused,
107
+ .ml-dropdown-item--destructive.ml-dropdown-item--focused {
108
+ outline: 2px solid Highlight;
109
+ outline-offset: -2px;
110
+ }
111
+ }
100
112
  `;
@@ -34,12 +34,24 @@ export declare class PopoverComponent implements IElementRef, OnCreate, OnDestro
34
34
  manual: boolean;
35
35
  /** When true, shows an arrow pointing to the trigger */
36
36
  arrow: boolean;
37
+ /**
38
+ * Accessible name for the popover panel (`aria-label`). Optional, but the
39
+ * panel is a focus-trapping `role="dialog"`, which should be named.
40
+ */
41
+ label: string;
37
42
  /** Current open state */
38
43
  isOpen: boolean;
39
44
  private readonly _positioner;
40
45
  private _focusTrap;
41
46
  private readonly _dismissGuard;
42
47
  onCreate(): void;
48
+ /**
49
+ * Tell assistive tech that the slotted trigger opens a dialog and whether
50
+ * it is open. The state goes on the element that takes focus (for an
51
+ * `<ml-button>` trigger, the `<button>` inside it), and a consumer's own
52
+ * `aria-haspopup` is left alone.
53
+ */
54
+ private readonly syncTriggerAria;
43
55
  /**
44
56
  * `popover="manual"` opts out of the platform's light-dismiss AND of its
45
57
  * close watcher, so Escape did nothing — and because the popover traps
@@ -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;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"}
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;AAOzD;;;;;;;;;;;;;;;;;;;;;;;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;;;OAGG;IACI,KAAK,SAAM;IAElB,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;IAUvB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAU9B;IAEF;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAQ5B;IAEK,SAAS,IAAI,IAAI;IAYxB,uBAAuB;IAChB,IAAI,IAAI,IAAI;IAOnB,wBAAwB;IACjB,KAAK,IAAI,IAAI;IAOpB,yBAAyB;IAClB,MAAM,QAAO,IAAI,CAUtB;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAuB3B;IAEF,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;CAGpB"}
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { MelodicComponent } from '@melodicdev/core';
8
8
  import { OverlayPositioner, ToggleDismissGuard } from '../../../utils/overlay/index.js';
9
9
  import { createFocusTrap, isDeepFocusWithin } from '../../../utils/accessibility/focus-trap.js';
10
+ import { getFocusableControl } from '../../../utils/accessibility/cross-root-aria.js';
10
11
  import { popoverTemplate } from './popover.template.js';
11
12
  import { popoverStyles } from './popover.styles.js';
12
13
  /**
@@ -43,6 +44,11 @@ let PopoverComponent = class PopoverComponent {
43
44
  this.manual = false;
44
45
  /** When true, shows an arrow pointing to the trigger */
45
46
  this.arrow = false;
47
+ /**
48
+ * Accessible name for the popover panel (`aria-label`). Optional, but the
49
+ * panel is a focus-trapping `role="dialog"`, which should be named.
50
+ */
51
+ this.label = '';
46
52
  /** Current open state */
47
53
  this.isOpen = false;
48
54
  this._positioner = new OverlayPositioner(() => ({
@@ -55,6 +61,23 @@ let PopoverComponent = class PopoverComponent {
55
61
  // Swallows the trigger click that just light-dismissed the open popover so
56
62
  // it doesn't immediately reopen it.
57
63
  this._dismissGuard = new ToggleDismissGuard();
64
+ /**
65
+ * Tell assistive tech that the slotted trigger opens a dialog and whether
66
+ * it is open. The state goes on the element that takes focus (for an
67
+ * `<ml-button>` trigger, the `<button>` inside it), and a consumer's own
68
+ * `aria-haspopup` is left alone.
69
+ */
70
+ this.syncTriggerAria = () => {
71
+ const slot = this.elementRef.shadowRoot?.querySelector('slot[name="trigger"]');
72
+ const trigger = slot?.assignedElements()[0];
73
+ if (!trigger)
74
+ return;
75
+ const control = getFocusableControl(trigger);
76
+ if (!control.hasAttribute('aria-haspopup')) {
77
+ control.setAttribute('aria-haspopup', 'dialog');
78
+ }
79
+ control.setAttribute('aria-expanded', String(this.isOpen));
80
+ };
58
81
  /**
59
82
  * `popover="manual"` opts out of the platform's light-dismiss AND of its
60
83
  * close watcher, so Escape did nothing — and because the popover traps
@@ -101,6 +124,7 @@ let PopoverComponent = class PopoverComponent {
101
124
  this._focusTrap = null;
102
125
  this.elementRef.dispatchEvent(new CustomEvent('ml:close', { bubbles: true, composed: true }));
103
126
  }
127
+ this.syncTriggerAria();
104
128
  };
105
129
  }
106
130
  onCreate() {
@@ -109,6 +133,8 @@ let PopoverComponent = class PopoverComponent {
109
133
  popoverEl.addEventListener('toggle', this.handleToggle);
110
134
  popoverEl.addEventListener('keydown', this.handleKeyDown);
111
135
  }
136
+ this.elementRef.shadowRoot?.addEventListener('slotchange', this.syncTriggerAria);
137
+ this.syncTriggerAria();
112
138
  }
113
139
  onDestroy() {
114
140
  this._positioner.stop();
@@ -119,6 +145,7 @@ let PopoverComponent = class PopoverComponent {
119
145
  popoverEl.removeEventListener('toggle', this.handleToggle);
120
146
  popoverEl.removeEventListener('keydown', this.handleKeyDown);
121
147
  }
148
+ this.elementRef.shadowRoot?.removeEventListener('slotchange', this.syncTriggerAria);
122
149
  }
123
150
  /** Open the popover */
124
151
  open() {
@@ -161,7 +188,7 @@ PopoverComponent = __decorate([
161
188
  selector: 'ml-popover',
162
189
  template: popoverTemplate,
163
190
  styles: popoverStyles,
164
- attributes: ['placement', 'offset', 'manual', 'arrow']
191
+ attributes: ['placement', 'offset', 'manual', 'arrow', 'label']
165
192
  })
166
193
  ], PopoverComponent);
167
194
  export { PopoverComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"popover.template.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/popover/popover.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,wBAAgB,eAAe,CAAC,CAAC,EAAE,gBAAgB,6CAkBlD"}
1
+ {"version":3,"file":"popover.template.d.ts","sourceRoot":"","sources":["../../../../src/components/overlays/popover/popover.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,wBAAgB,eAAe,CAAC,CAAC,EAAE,gBAAgB,6CAoBlD"}
@@ -8,6 +8,8 @@ export function popoverTemplate(c) {
8
8
  <div
9
9
  class="ml-popover__content"
10
10
  popover=${c.manual ? 'manual' : 'auto'}
11
+ role="dialog"
12
+ aria-label=${c.label || undefined}
11
13
  >
12
14
  <slot></slot>
13
15
  ${when(c.arrow, () => html `<div class="ml-popover__arrow"></div>`)}
@@ -1,4 +1,4 @@
1
- import type { IElementRef, OnCreate, OnDestroy } from '@melodicdev/core';
1
+ import type { IElementRef, OnCreate, OnDestroy, OnRender } from '@melodicdev/core';
2
2
  import type { Placement } from '../../../types/index.js';
3
3
  import { type UniqueID } from '../../../functions/new-id.function.js';
4
4
  /**
@@ -17,7 +17,7 @@ import { type UniqueID } from '../../../functions/new-id.function.js';
17
17
  *
18
18
  * @slot default - The trigger element
19
19
  */
20
- export declare class TooltipComponent implements IElementRef, OnCreate, OnDestroy {
20
+ export declare class TooltipComponent implements IElementRef, OnCreate, OnDestroy, OnRender {
21
21
  elementRef: HTMLElement;
22
22
  /** Tooltip content text */
23
23
  content: string;
@@ -40,6 +40,7 @@ export declare class TooltipComponent implements IElementRef, OnCreate, OnDestro
40
40
  private _hideTimeout;
41
41
  private readonly _positioner;
42
42
  onCreate(): void;
43
+ onRender(): void;
43
44
  onDestroy(): void;
44
45
  show: () => void;
45
46
  hide: () => void;
@@ -50,9 +51,11 @@ export declare class TooltipComponent implements IElementRef, OnCreate, OnDestro
50
51
  * Describe the slotted trigger with the tooltip's content element.
51
52
  *
52
53
  * 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.
54
+ * resolves to nothing, and so does an element reference
55
+ * (`ariaDescribedByElements`) in that direction — a light-DOM element may
56
+ * only reference its own tree or an ancestor tree. Either way the tooltip
57
+ * looked wired up in the DOM and was never announced, so the text is
58
+ * copied onto the trigger as `aria-description` instead.
56
59
  */
57
60
  private readonly syncTriggerAria;
58
61
  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;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"}
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,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnF,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,EAAE,QAAQ;IAC3E,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,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;;;;;;;;;OASG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAW9B;IAEF,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,eAAe;IAIvB,mDAAmD;IACnD,OAAO,CAAC,cAAc;CAGtB"}
@@ -92,9 +92,11 @@ let TooltipComponent = class TooltipComponent {
92
92
  * Describe the slotted trigger with the tooltip's content element.
93
93
  *
94
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.
95
+ * resolves to nothing, and so does an element reference
96
+ * (`ariaDescribedByElements`) in that direction — a light-DOM element may
97
+ * only reference its own tree or an ancestor tree. Either way the tooltip
98
+ * looked wired up in the DOM and was never announced, so the text is
99
+ * copied onto the trigger as `aria-description` instead.
98
100
  */
99
101
  this.syncTriggerAria = () => {
100
102
  const root = this.elementRef.shadowRoot;
@@ -112,6 +114,11 @@ let TooltipComponent = class TooltipComponent {
112
114
  this.elementRef.shadowRoot?.addEventListener('slotchange', this.syncTriggerAria);
113
115
  this.syncTriggerAria();
114
116
  }
117
+ onRender() {
118
+ // The description is carried as text (see syncTriggerAria), so it has
119
+ // to follow the content when that changes.
120
+ this.syncTriggerAria();
121
+ }
115
122
  onDestroy() {
116
123
  if (this._showTimeout)
117
124
  clearTimeout(this._showTimeout);
@@ -161,7 +161,7 @@ export const appShellStyles = () => css `
161
161
  flex-shrink: 0;
162
162
  width: var(--ml-app-shell-menu-btn-size, 36px);
163
163
  height: var(--ml-app-shell-menu-btn-size, 36px);
164
- margin-left: var(--ml-app-shell-menu-btn-margin, var(--ml-space-3));
164
+ margin-inline-start: var(--ml-app-shell-menu-btn-margin, var(--ml-space-3));
165
165
  padding: 0;
166
166
  border: none;
167
167
  border-radius: var(--ml-app-shell-menu-btn-radius, var(--ml-radius));
@@ -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;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
+ {"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;AAsKD,iBAAS,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,iCAAiC,GAAG,IAAI,CA2CpG;AAID,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -56,8 +56,9 @@ function createState(element) {
56
56
  element.addEventListener('focusout', hide);
57
57
  const state = { tooltip, pendingRemoval: false, ownsDescribedBy: false, show, hide };
58
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.
59
+ // the tooltip's shadow root, where neither an IDREF nor an element
60
+ // reference from this element can reach — its text is copied onto the
61
+ // element as `aria-description` instead.
61
62
  //
62
63
  // The tooltip has only just been created here, so its shadow content does
63
64
  // not exist yet; wiring it synchronously silently described nothing at all.
@@ -95,14 +96,31 @@ function describeWhenReady(element, tooltip, state) {
95
96
  }
96
97
  });
97
98
  }
99
+ /**
100
+ * The description is the tooltip's text copied onto the element, so it must
101
+ * be refreshed once the tooltip has re-rendered with new content.
102
+ */
103
+ function redescribeAfterRender(element, state) {
104
+ if (!state.ownsDescribedBy) {
105
+ return; // first render (describeWhenReady handles it) or consumer-owned
106
+ }
107
+ const refresh = () => {
108
+ const content = state.tooltip.shadowRoot?.querySelector('.ml-tooltip__content');
109
+ if (content && !state.pendingRemoval && state.ownsDescribedBy) {
110
+ setCrossRootDescription(element, [content]);
111
+ }
112
+ };
113
+ void Promise.resolve().then(refresh);
114
+ setTimeout(refresh, 0);
115
+ }
98
116
  function destroyState(element, state) {
99
117
  element.removeEventListener('mouseenter', state.show);
100
118
  element.removeEventListener('mouseleave', state.hide);
101
119
  element.removeEventListener('focusin', state.show);
102
120
  element.removeEventListener('focusout', state.hide);
103
121
  if (state.ownsDescribedBy) {
122
+ state.ownsDescribedBy = false;
104
123
  clearCrossRootDescription(element);
105
- element.removeAttribute('aria-describedby');
106
124
  }
107
125
  state.tooltip.anchorEl = null;
108
126
  // Disconnecting runs the tooltip component's onDestroy (timers, autoUpdate,
@@ -134,6 +152,7 @@ function tooltipDirective(element, value) {
134
152
  // tooltip's attributeChangedCallback each time.
135
153
  if (state.tooltip.getAttribute('content') !== content) {
136
154
  state.tooltip.setAttribute('content', content);
155
+ redescribeAfterRender(element, state);
137
156
  }
138
157
  const resolvedPlacement = placement ?? 'top';
139
158
  if (state.tooltip.getAttribute('placement') !== resolvedPlacement) {
@@ -1 +1 @@
1
- {"version":3,"file":"base.preset.d.ts","sourceRoot":"","sources":["../../../src/theme/presets/base.preset.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,YAAY,QAKvB,CAAC"}
1
+ {"version":3,"file":"base.preset.d.ts","sourceRoot":"","sources":["../../../src/theme/presets/base.preset.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,eAAO,MAAM,YAAY,QAWvB,CAAC"}
@@ -1,4 +1,15 @@
1
1
  import { allTokens, tokensToCss } from '../tokens/all-tokens.js';
2
+ import { transitionTokens } from '../tokens/transitions.tokens.js';
3
+ /**
4
+ * Every non-zero duration token, collapsed to 0ms. Component transitions and
5
+ * animations all take their duration from these tokens (directly or through a
6
+ * component token whose default is one), so redefining them is enough to
7
+ * switch motion off library-wide for users who ask for reduced motion.
8
+ */
9
+ const reducedMotionDurations = Object.keys(transitionTokens)
10
+ .filter((name) => name.startsWith('--ml-duration-') && name !== '--ml-duration-0')
11
+ .map((name) => `${name}: 0ms;`)
12
+ .join('\n\t\t');
2
13
  /**
3
14
  * Base theme - includes all primitive tokens
4
15
  * Applied to :root for both light and dark themes
@@ -8,4 +19,10 @@ export const baseThemeCss = `:root {
8
19
 
9
20
  /* Default to light color scheme */
10
21
  color-scheme: light;
22
+ }
23
+
24
+ @media (prefers-reduced-motion: reduce) {
25
+ :root {
26
+ ${reducedMotionDurations}
27
+ }
11
28
  }`;