@melodicdev/components 3.0.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.
Files changed (178) hide show
  1. package/assets/melodic-components.js +4371 -2363
  2. package/assets/melodic-components.js.map +1 -1
  3. package/assets/melodic-components.min.js +6220 -4461
  4. package/lib/components/data-display/calendar-view/calendar-view-month.template.d.ts.map +1 -1
  5. package/lib/components/data-display/calendar-view/calendar-view-month.template.js +17 -0
  6. package/lib/components/data-display/calendar-view/calendar-view.component.d.ts +23 -3
  7. package/lib/components/data-display/calendar-view/calendar-view.component.d.ts.map +1 -1
  8. package/lib/components/data-display/calendar-view/calendar-view.component.js +76 -21
  9. package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts +9 -0
  10. package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts.map +1 -1
  11. package/lib/components/data-display/calendar-view/calendar-view.utils.js +68 -19
  12. package/lib/components/data-display/data-grid/data-grid.component.d.ts +24 -0
  13. package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
  14. package/lib/components/data-display/data-grid/data-grid.component.js +104 -31
  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 +3 -0
  17. package/lib/components/data-display/table/table.component.d.ts +7 -0
  18. package/lib/components/data-display/table/table.component.d.ts.map +1 -1
  19. package/lib/components/data-display/table/table.component.js +20 -5
  20. package/lib/components/data-display/table/table.template.d.ts.map +1 -1
  21. package/lib/components/data-display/table/table.template.js +3 -0
  22. package/lib/components/data-display/table-core/index.d.ts +1 -0
  23. package/lib/components/data-display/table-core/index.d.ts.map +1 -1
  24. package/lib/components/data-display/table-core/index.js +1 -0
  25. package/lib/components/data-display/table-core/memo.d.ts +10 -0
  26. package/lib/components/data-display/table-core/memo.d.ts.map +1 -0
  27. package/lib/components/data-display/table-core/memo.js +20 -0
  28. package/lib/components/feedback/alert/alert.styles.d.ts.map +1 -1
  29. package/lib/components/feedback/alert/alert.styles.js +25 -0
  30. package/lib/components/feedback/progress/progress.styles.d.ts.map +1 -1
  31. package/lib/components/feedback/progress/progress.styles.js +8 -3
  32. package/lib/components/feedback/spinner/spinner.styles.d.ts.map +1 -1
  33. package/lib/components/feedback/spinner/spinner.styles.js +2 -11
  34. package/lib/components/feedback/toast/toast-container.template.d.ts.map +1 -1
  35. package/lib/components/feedback/toast/toast-container.template.js +4 -0
  36. package/lib/components/feedback/toast/toast.component.d.ts +3 -2
  37. package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
  38. package/lib/components/feedback/toast/toast.component.js +10 -0
  39. package/lib/components/feedback/toast/toast.service.d.ts +26 -6
  40. package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
  41. package/lib/components/feedback/toast/toast.service.js +53 -18
  42. package/lib/components/feedback/toast/toast.template.js +1 -1
  43. package/lib/components/forms/autocomplete/autocomplete.component.d.ts +7 -0
  44. package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
  45. package/lib/components/forms/autocomplete/autocomplete.component.js +39 -0
  46. package/lib/components/forms/autocomplete/autocomplete.template.d.ts.map +1 -1
  47. package/lib/components/forms/autocomplete/autocomplete.template.js +5 -1
  48. package/lib/components/forms/button-group/button-group.component.d.ts +3 -2
  49. package/lib/components/forms/button-group/button-group.component.d.ts.map +1 -1
  50. package/lib/components/forms/button-group/button-group.component.js +11 -1
  51. package/lib/components/forms/checkbox/checkbox.component.d.ts +4 -0
  52. package/lib/components/forms/checkbox/checkbox.component.d.ts.map +1 -1
  53. package/lib/components/forms/checkbox/checkbox.component.js +5 -1
  54. package/lib/components/forms/checkbox/checkbox.template.d.ts.map +1 -1
  55. package/lib/components/forms/checkbox/checkbox.template.js +2 -0
  56. package/lib/components/forms/date-picker/calendar.component.d.ts +21 -0
  57. package/lib/components/forms/date-picker/calendar.component.d.ts.map +1 -1
  58. package/lib/components/forms/date-picker/calendar.component.js +69 -2
  59. package/lib/components/forms/date-picker/calendar.template.d.ts.map +1 -1
  60. package/lib/components/forms/date-picker/calendar.template.js +6 -3
  61. package/lib/components/forms/date-picker/date-picker.component.d.ts +6 -0
  62. package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
  63. package/lib/components/forms/date-picker/date-picker.component.js +41 -12
  64. package/lib/components/forms/file-upload/file-upload.component.d.ts.map +1 -1
  65. package/lib/components/forms/file-upload/file-upload.component.js +15 -5
  66. package/lib/components/forms/form-field/form-field.component.d.ts +8 -0
  67. package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
  68. package/lib/components/forms/form-field/form-field.component.js +41 -6
  69. package/lib/components/forms/form-field/form-field.template.js +1 -1
  70. package/lib/components/forms/input/input.component.d.ts +26 -3
  71. package/lib/components/forms/input/input.component.d.ts.map +1 -1
  72. package/lib/components/forms/input/input.component.js +46 -6
  73. package/lib/components/forms/input/input.template.d.ts.map +1 -1
  74. package/lib/components/forms/input/input.template.js +9 -0
  75. package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts +6 -0
  76. package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts.map +1 -1
  77. package/lib/components/forms/radio-card-group/radio-card-group.component.js +34 -0
  78. package/lib/components/forms/radio-card-group/radio-card.component.d.ts +6 -0
  79. package/lib/components/forms/radio-card-group/radio-card.component.d.ts.map +1 -1
  80. package/lib/components/forms/radio-card-group/radio-card.component.js +7 -1
  81. package/lib/components/forms/radio-card-group/radio-card.template.js +1 -1
  82. package/lib/components/forms/select/select.component.d.ts +8 -0
  83. package/lib/components/forms/select/select.component.d.ts.map +1 -1
  84. package/lib/components/forms/select/select.component.js +75 -1
  85. package/lib/components/forms/select/select.template.d.ts.map +1 -1
  86. package/lib/components/forms/select/select.template.js +5 -1
  87. package/lib/components/forms/textarea/textarea.component.d.ts +10 -3
  88. package/lib/components/forms/textarea/textarea.component.d.ts.map +1 -1
  89. package/lib/components/forms/textarea/textarea.component.js +10 -5
  90. package/lib/components/forms/textarea/textarea.template.d.ts.map +1 -1
  91. package/lib/components/forms/textarea/textarea.template.js +2 -0
  92. package/lib/components/forms/time-picker/time-picker.component.d.ts +16 -0
  93. package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
  94. package/lib/components/forms/time-picker/time-picker.component.js +43 -3
  95. package/lib/components/foundation/container/container.component.js +5 -5
  96. package/lib/components/foundation/container/container.styles.d.ts.map +1 -1
  97. package/lib/components/foundation/container/container.styles.js +10 -0
  98. package/lib/components/foundation/stack/stack.component.d.ts +6 -0
  99. package/lib/components/foundation/stack/stack.component.d.ts.map +1 -1
  100. package/lib/components/foundation/stack/stack.component.js +11 -5
  101. package/lib/components/foundation/stack/stack.styles.d.ts.map +1 -1
  102. package/lib/components/foundation/stack/stack.styles.js +14 -0
  103. package/lib/components/general/icon/icon.template.d.ts.map +1 -1
  104. package/lib/components/general/icon/icon.template.js +7 -1
  105. package/lib/components/navigation/breadcrumb/breadcrumb-item.template.d.ts.map +1 -1
  106. package/lib/components/navigation/breadcrumb/breadcrumb-item.template.js +2 -1
  107. package/lib/components/navigation/functions/match-by-route.function.d.ts +16 -0
  108. package/lib/components/navigation/functions/match-by-route.function.d.ts.map +1 -0
  109. package/lib/components/navigation/functions/match-by-route.function.js +34 -0
  110. package/lib/components/navigation/functions/route-link.function.d.ts +20 -0
  111. package/lib/components/navigation/functions/route-link.function.d.ts.map +1 -0
  112. package/lib/components/navigation/functions/route-link.function.js +34 -0
  113. package/lib/components/navigation/pagination/pagination.component.d.ts +8 -0
  114. package/lib/components/navigation/pagination/pagination.component.d.ts.map +1 -1
  115. package/lib/components/navigation/pagination/pagination.component.js +12 -2
  116. package/lib/components/navigation/pagination/pagination.styles.d.ts.map +1 -1
  117. package/lib/components/navigation/pagination/pagination.styles.js +10 -0
  118. package/lib/components/navigation/pagination/pagination.template.js +2 -2
  119. package/lib/components/navigation/sidebar/sidebar-item.template.d.ts.map +1 -1
  120. package/lib/components/navigation/sidebar/sidebar-item.template.js +5 -1
  121. package/lib/components/navigation/sidebar/sidebar.component.d.ts +12 -6
  122. package/lib/components/navigation/sidebar/sidebar.component.d.ts.map +1 -1
  123. package/lib/components/navigation/sidebar/sidebar.component.js +20 -12
  124. package/lib/components/navigation/sidebar/sidebar.template.d.ts.map +1 -1
  125. package/lib/components/navigation/sidebar/sidebar.template.js +5 -1
  126. package/lib/components/navigation/steps/step.component.d.ts.map +1 -1
  127. package/lib/components/navigation/steps/step.component.js +19 -1
  128. package/lib/components/navigation/steps/step.template.d.ts.map +1 -1
  129. package/lib/components/navigation/steps/step.template.js +6 -0
  130. package/lib/components/navigation/steps/steps.component.d.ts +10 -0
  131. package/lib/components/navigation/steps/steps.component.d.ts.map +1 -1
  132. package/lib/components/navigation/steps/steps.component.js +42 -9
  133. package/lib/components/navigation/steps/steps.template.js +9 -0
  134. package/lib/components/navigation/tabs/tab-panel.styles.d.ts.map +1 -1
  135. package/lib/components/navigation/tabs/tab-panel.styles.js +7 -2
  136. package/lib/components/navigation/tabs/tabs.component.d.ts +10 -0
  137. package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
  138. package/lib/components/navigation/tabs/tabs.component.js +36 -7
  139. package/lib/components/overlays/dialog/dialog-ref.class.d.ts +19 -9
  140. package/lib/components/overlays/dialog/dialog-ref.class.d.ts.map +1 -1
  141. package/lib/components/overlays/dialog/dialog-ref.class.js +37 -5
  142. package/lib/components/overlays/dropdown/dropdown.component.d.ts +7 -0
  143. package/lib/components/overlays/dropdown/dropdown.component.d.ts.map +1 -1
  144. package/lib/components/overlays/dropdown/dropdown.component.js +26 -11
  145. package/lib/components/overlays/popover/popover.component.d.ts +8 -0
  146. package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
  147. package/lib/components/overlays/popover/popover.component.js +17 -0
  148. package/lib/components/overlays/tooltip/tooltip.component.d.ts +6 -5
  149. package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
  150. package/lib/components/overlays/tooltip/tooltip.component.js +14 -10
  151. package/lib/components/sections/app-shell/app-shell.component.d.ts +13 -0
  152. package/lib/components/sections/app-shell/app-shell.component.d.ts.map +1 -1
  153. package/lib/components/sections/app-shell/app-shell.component.js +45 -1
  154. package/lib/components/sections/app-shell/app-shell.styles.d.ts.map +1 -1
  155. package/lib/components/sections/app-shell/app-shell.styles.js +15 -0
  156. package/lib/components/sections/app-shell/app-shell.template.d.ts.map +1 -1
  157. package/lib/components/sections/app-shell/app-shell.template.js +5 -0
  158. package/lib/components/sections/page-section/page-section.template.d.ts.map +1 -1
  159. package/lib/components/sections/page-section/page-section.template.js +6 -1
  160. package/lib/directives/tooltip.directive.d.ts.map +1 -1
  161. package/lib/directives/tooltip.directive.js +39 -6
  162. package/lib/theme/functions/apply-theme.function.d.ts +4 -1
  163. package/lib/theme/functions/apply-theme.function.d.ts.map +1 -1
  164. package/lib/theme/functions/apply-theme.function.js +20 -4
  165. package/lib/theme/functions/create-theme.function.js +0 -1
  166. package/lib/utils/accessibility/cross-root-aria.d.ts +40 -0
  167. package/lib/utils/accessibility/cross-root-aria.d.ts.map +1 -0
  168. package/lib/utils/accessibility/cross-root-aria.js +97 -0
  169. package/lib/utils/accessibility/index.d.ts +1 -0
  170. package/lib/utils/accessibility/index.d.ts.map +1 -1
  171. package/lib/utils/accessibility/index.js +1 -0
  172. package/lib/utils/directives/index.d.ts +1 -0
  173. package/lib/utils/directives/index.d.ts.map +1 -1
  174. package/lib/utils/directives/index.js +1 -0
  175. package/lib/utils/directives/watch-light-slots.d.ts +20 -0
  176. package/lib/utils/directives/watch-light-slots.d.ts.map +1 -0
  177. package/lib/utils/directives/watch-light-slots.js +36 -0
  178. package/package.json +2 -2
@@ -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;AAMvF;;GAEG;AACH,wBAAgB,QAAQ,IAAI,SAAS,CAEpC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,GAAG,MAAM,CAQnD;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
+ {"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
- let currentTheme = 'system';
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
- if (currentTheme === 'system') {
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 currentTheme;
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"}
@@ -0,0 +1,97 @@
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 function supportsAriaElementReferences() {
17
+ return typeof Element !== 'undefined' && 'ariaDescribedByElements' in Element.prototype;
18
+ }
19
+ /**
20
+ * Describe `target` with `describers`, which may live in another root.
21
+ * Pass an empty array to clear the relationship.
22
+ */
23
+ export function setCrossRootDescription(target, describers) {
24
+ const reflected = target;
25
+ if ('ariaDescribedByElements' in reflected) {
26
+ reflected.ariaDescribedByElements = describers.length > 0 ? describers : null;
27
+ target.removeAttribute('aria-description');
28
+ return;
29
+ }
30
+ const text = describers
31
+ .map((element) => element.textContent?.trim() ?? '')
32
+ .filter(Boolean)
33
+ .join('. ');
34
+ if (text) {
35
+ target.setAttribute('aria-description', text);
36
+ }
37
+ else {
38
+ target.removeAttribute('aria-description');
39
+ }
40
+ }
41
+ /** Label `target` with `labels`, which may live in another root. */
42
+ export function setCrossRootLabel(target, labels) {
43
+ const reflected = target;
44
+ if ('ariaLabelledByElements' in reflected) {
45
+ reflected.ariaLabelledByElements = labels.length > 0 ? labels : null;
46
+ return;
47
+ }
48
+ const text = labels
49
+ .map((element) => element.textContent?.trim() ?? '')
50
+ .filter(Boolean)
51
+ .join(' ');
52
+ if (text) {
53
+ target.setAttribute('aria-label', text);
54
+ }
55
+ else {
56
+ target.removeAttribute('aria-label');
57
+ }
58
+ }
59
+ /**
60
+ * Point `target` at the currently active option, which may live in another
61
+ * root (a composite listbox's options are in the light DOM while the focused
62
+ * control is inside a shadow root).
63
+ */
64
+ export function setCrossRootActiveDescendant(target, active) {
65
+ const reflected = target;
66
+ if ('ariaActiveDescendantElement' in reflected) {
67
+ reflected.ariaActiveDescendantElement = active;
68
+ return;
69
+ }
70
+ if (active?.id) {
71
+ target.setAttribute('aria-activedescendant', active.id);
72
+ }
73
+ else {
74
+ target.removeAttribute('aria-activedescendant');
75
+ }
76
+ }
77
+ /**
78
+ * The element that actually takes focus for a (possibly composite) control.
79
+ *
80
+ * ARIA state must sit on the focusable node, not on a wrapper: setting
81
+ * `aria-haspopup`/`aria-expanded` on an `<ml-button>` host leaves the real
82
+ * `<button>` inside its shadow root announcing nothing.
83
+ */
84
+ export function getFocusableControl(element) {
85
+ const root = element.shadowRoot;
86
+ if (root) {
87
+ const control = root.querySelector('button, [role="button"], a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
88
+ if (control) {
89
+ return control;
90
+ }
91
+ }
92
+ return element;
93
+ }
94
+ /** Remove any cross-root description this module applied. */
95
+ export function clearCrossRootDescription(target) {
96
+ setCrossRootDescription(target, []);
97
+ }
@@ -3,4 +3,5 @@ export type { FocusTrap, FocusTrapOptions, FocusTrapDeactivateOptions } from './
3
3
  export { focusVisible, isFocusVisible } from './focus-visible.js';
4
4
  export { announce, createLiveRegion } from './live-region.js';
5
5
  export { getFirstFocusable, getLastFocusable, getFocusableElements, focusFirst, focusLast } from './focus-utils.js';
6
+ export { setCrossRootDescription, setCrossRootLabel, setCrossRootActiveDescendant, clearCrossRootDescription, getFocusableControl, supportsAriaElementReferences } from './cross-root-aria.js';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/accessibility/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACtG,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/accessibility/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACtG,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpH,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,4BAA4B,EAC5B,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,MAAM,sBAAsB,CAAC"}
@@ -2,3 +2,4 @@ export { focusTrap, createFocusTrap, getDeepActiveElement, isDeepFocusWithin } f
2
2
  export { focusVisible, isFocusVisible } from './focus-visible.js';
3
3
  export { announce, createLiveRegion } from './live-region.js';
4
4
  export { getFirstFocusable, getLastFocusable, getFocusableElements, focusFirst, focusLast } from './focus-utils.js';
5
+ export { setCrossRootDescription, setCrossRootLabel, setCrossRootActiveDescendant, clearCrossRootDescription, getFocusableControl, supportsAriaElementReferences } from './cross-root-aria.js';
@@ -1,2 +1,3 @@
1
1
  export { clickOutside } from './click-outside.directive.js';
2
+ export { watchLightSlots, hasLightSlot } from './watch-light-slots.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/directives/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/directives/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1 +1,2 @@
1
1
  export { clickOutside } from './click-outside.directive.js';
2
+ export { watchLightSlots, hasLightSlot } from './watch-light-slots.js';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Watch the light DOM for which named slots have content.
3
+ *
4
+ * `watchSlotPresence` listens on the shadow `<slot>` elements, which only
5
+ * works when those slots are always rendered. A component that renders a slot
6
+ * conditionally (`${when(hasSearch, …)}`) has a chicken-and-egg problem: the
7
+ * slot that would fire `slotchange` exists only once the flag is already true,
8
+ * so content slotted after mount never appears at all.
9
+ *
10
+ * Only direct children participate in slot projection, but a `slot` attribute
11
+ * change on a child is observable only with `subtree: true` — so the subtree is
12
+ * observed and the mutations are filtered down to the ones that can actually
13
+ * change projection. Deep mutations inside slotted content are ignored.
14
+ *
15
+ * Returns a disconnect function; call it from `onDestroy`.
16
+ */
17
+ export declare function watchLightSlots(host: HTMLElement, onChange: () => void): () => void;
18
+ /** True when `host` has a direct child assigned to `slotName`. */
19
+ export declare function hasLightSlot(host: HTMLElement, slotName: string): boolean;
20
+ //# sourceMappingURL=watch-light-slots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch-light-slots.d.ts","sourceRoot":"","sources":["../../../src/utils/directives/watch-light-slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAqBnF;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzE"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Watch the light DOM for which named slots have content.
3
+ *
4
+ * `watchSlotPresence` listens on the shadow `<slot>` elements, which only
5
+ * works when those slots are always rendered. A component that renders a slot
6
+ * conditionally (`${when(hasSearch, …)}`) has a chicken-and-egg problem: the
7
+ * slot that would fire `slotchange` exists only once the flag is already true,
8
+ * so content slotted after mount never appears at all.
9
+ *
10
+ * Only direct children participate in slot projection, but a `slot` attribute
11
+ * change on a child is observable only with `subtree: true` — so the subtree is
12
+ * observed and the mutations are filtered down to the ones that can actually
13
+ * change projection. Deep mutations inside slotted content are ignored.
14
+ *
15
+ * Returns a disconnect function; call it from `onDestroy`.
16
+ */
17
+ export function watchLightSlots(host, onChange) {
18
+ const observer = new MutationObserver((mutations) => {
19
+ const relevant = mutations.some((mutation) => mutation.type === 'childList' ? mutation.target === host : mutation.target.parentNode === host);
20
+ if (relevant) {
21
+ onChange();
22
+ }
23
+ });
24
+ observer.observe(host, {
25
+ childList: true,
26
+ subtree: true,
27
+ attributes: true,
28
+ attributeFilter: ['slot']
29
+ });
30
+ onChange();
31
+ return () => observer.disconnect();
32
+ }
33
+ /** True when `host` has a direct child assigned to `slotName`. */
34
+ export function hasLightSlot(host, slotName) {
35
+ return host.querySelector(`:scope > [slot="${slotName}"]`) !== null;
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melodicdev/components",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Themeable UI component library built on the Melodic Framework",
5
5
  "license": "MIT",
6
6
  "author": "Melodic Development",
@@ -280,7 +280,7 @@
280
280
  "generate:icon-map": "node scripts/generate-icon-map.mjs"
281
281
  },
282
282
  "peerDependencies": {
283
- "@melodicdev/core": "^3.0.0"
283
+ "@melodicdev/core": "^4.0.0"
284
284
  },
285
285
  "devDependencies": {
286
286
  "@melodicdev/core": "file:../..",