@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.
- package/assets/melodic-components.js +4371 -2363
- package/assets/melodic-components.js.map +1 -1
- package/assets/melodic-components.min.js +6220 -4461
- 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 +8 -0
- package/lib/components/forms/select/select.component.d.ts.map +1 -1
- package/lib/components/forms/select/select.component.js +75 -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
|
@@ -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"}
|
|
@@ -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 +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"}
|
|
@@ -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
|
+
"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": "^
|
|
283
|
+
"@melodicdev/core": "^4.0.0"
|
|
284
284
|
},
|
|
285
285
|
"devDependencies": {
|
|
286
286
|
"@melodicdev/core": "file:../..",
|