material 3.8.2 → 3.9.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/README.md +3 -3
- package/dist/components/bottom-app-bar/bottom-app-bar.d.ts +6 -0
- package/dist/components/bottom-app-bar/constants.d.ts +16 -3
- package/dist/components/bottom-app-bar/types.d.ts +71 -10
- package/dist/components/bottom-sheet/config.js +1 -1
- package/dist/components/bottom-sheet/features/structure.js +10 -2
- package/dist/components/bottom-sheet/types.d.ts +2 -0
- package/dist/components/button-group/button-group.js +1 -1
- package/dist/components/checkbox/config.js +3 -2
- package/dist/components/checkbox/types.d.ts +5 -0
- package/dist/components/datepicker/config.js +1 -1
- package/dist/components/datepicker/datepicker.js +12 -3
- package/dist/components/datepicker/render.js +2 -2
- package/dist/components/datepicker/types.d.ts +4 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +1 -1
- package/dist/components/list/features/listbox.d.ts +16 -0
- package/dist/components/list/features/listbox.js +230 -0
- package/dist/components/list/index.d.ts +2 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/menu/config.js +2 -2
- package/dist/components/menu/constants.d.ts +4 -4
- package/dist/components/menu/constants.js +1 -1
- package/dist/components/menu/features/controller.js +12 -1
- package/dist/components/menu/features/position.js +15 -8
- package/dist/components/menu/features/submenu.js +3 -0
- package/dist/components/menu/types.d.ts +8 -1
- package/dist/components/radios/config.js +1 -0
- package/dist/components/radios/radio.js +2 -0
- package/dist/components/radios/types.d.ts +2 -0
- package/dist/components/search/features/input.js +6 -1
- package/dist/components/search/features/structure.js +3 -1
- package/dist/components/side-sheet/config.js +1 -1
- package/dist/components/side-sheet/features/structure.js +10 -2
- package/dist/components/side-sheet/types.d.ts +2 -0
- package/dist/components/slider/config.js +3 -2
- package/dist/components/slider/types.d.ts +5 -0
- package/dist/components/split-button/config.js +1 -1
- package/dist/components/switch/config.js +3 -2
- package/dist/components/switch/types.d.ts +5 -0
- package/dist/components/tabs/config.js +1 -0
- package/dist/components/tabs/tab.js +11 -5
- package/dist/components/tabs/types.d.ts +5 -1
- package/dist/components/text-field/config.js +7 -2
- package/dist/components/text-field/types.d.ts +5 -0
- package/dist/components/timepicker/api.js +7 -8
- package/dist/components/timepicker/config.js +1 -1
- package/dist/components/timepicker/render.js +22 -5
- package/dist/components/timepicker/timepicker.js +0 -1
- package/dist/components/timepicker/types.d.ts +4 -0
- package/dist/components/toolbar/config.js +1 -0
- package/dist/components/toolbar/constants.d.ts +4 -1
- package/dist/components/toolbar/constants.js +3 -0
- package/dist/components/toolbar/toolbar.js +18 -3
- package/dist/components/toolbar/types.d.ts +6 -2
- package/dist/core/config/component.d.ts +5 -515
- package/dist/core/config/control-label.js +5 -0
- package/dist/elements/bottom-app-bar.d.ts +19 -2
- package/dist/elements/bottom-sheet.js +3 -2
- package/dist/elements/css/badge.js +2 -2
- package/dist/elements/css/bottom-app-bar.js +2 -2
- package/dist/elements/css/bottom-sheet.js +2 -2
- package/dist/elements/css/button-group.js +2 -2
- package/dist/elements/css/button.css +1 -1
- package/dist/elements/css/button.js +2 -2
- package/dist/elements/css/card.js +2 -2
- package/dist/elements/css/carousel.js +2 -2
- package/dist/elements/css/checkbox.js +2 -2
- package/dist/elements/css/chips.js +2 -2
- package/dist/elements/css/datepicker.js +2 -2
- package/dist/elements/css/dialog.js +2 -2
- package/dist/elements/css/divider.js +2 -2
- package/dist/elements/css/drawer.js +2 -2
- package/dist/elements/css/extended-fab.js +2 -2
- package/dist/elements/css/fab-menu.js +2 -2
- package/dist/elements/css/fab.js +2 -2
- package/dist/elements/css/icon-button.js +2 -2
- package/dist/elements/css/list.css +1 -1
- package/dist/elements/css/list.js +2 -2
- package/dist/elements/css/loading-indicator.js +2 -2
- package/dist/elements/css/menu.css +1 -1
- package/dist/elements/css/menu.js +2 -2
- package/dist/elements/css/navigation-bar.js +2 -2
- package/dist/elements/css/navigation-rail.js +2 -2
- package/dist/elements/css/progress.js +2 -2
- package/dist/elements/css/radios.js +2 -2
- package/dist/elements/css/ripple.js +2 -2
- package/dist/elements/css/search.js +2 -2
- package/dist/elements/css/select.js +2 -2
- package/dist/elements/css/side-sheet.js +2 -2
- package/dist/elements/css/slider.js +2 -2
- package/dist/elements/css/snackbar.js +2 -2
- package/dist/elements/css/split-button.js +2 -2
- package/dist/elements/css/switch.js +2 -2
- package/dist/elements/css/tabs.js +2 -2
- package/dist/elements/css/text-field.js +2 -2
- package/dist/elements/css/timepicker.js +2 -2
- package/dist/elements/css/toolbar.css +1 -1
- package/dist/elements/css/toolbar.js +2 -2
- package/dist/elements/css/tooltip.js +2 -2
- package/dist/elements/css/top-app-bar.js +2 -2
- package/dist/elements/datepicker.d.ts +5 -0
- package/dist/elements/datepicker.js +1 -0
- package/dist/elements/index.d.ts +26 -323
- package/dist/elements/menu.js +17 -3
- package/dist/elements/preupgrade/badge.css +1 -1
- package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
- package/dist/elements/preupgrade/bottom-sheet.css +1 -1
- package/dist/elements/preupgrade/button-group.css +1 -1
- package/dist/elements/preupgrade/button.css +1 -1
- package/dist/elements/preupgrade/card.css +1 -1
- package/dist/elements/preupgrade/carousel.css +1 -1
- package/dist/elements/preupgrade/checkbox.css +1 -1
- package/dist/elements/preupgrade/chips.css +1 -1
- package/dist/elements/preupgrade/datepicker.css +1 -1
- package/dist/elements/preupgrade/dialog.css +1 -1
- package/dist/elements/preupgrade/divider.css +1 -1
- package/dist/elements/preupgrade/drawer.css +1 -1
- package/dist/elements/preupgrade/extended-fab.css +1 -1
- package/dist/elements/preupgrade/fab-menu.css +1 -1
- package/dist/elements/preupgrade/fab.css +1 -1
- package/dist/elements/preupgrade/icon-button.css +1 -1
- package/dist/elements/preupgrade/list.css +1 -1
- package/dist/elements/preupgrade/loading-indicator.css +1 -1
- package/dist/elements/preupgrade/menu.css +1 -1
- package/dist/elements/preupgrade/navigation-bar.css +1 -1
- package/dist/elements/preupgrade/navigation-rail.css +1 -1
- package/dist/elements/preupgrade/progress.css +1 -1
- package/dist/elements/preupgrade/radios.css +1 -1
- package/dist/elements/preupgrade/search.css +1 -1
- package/dist/elements/preupgrade/select.css +1 -1
- package/dist/elements/preupgrade/side-sheet.css +1 -1
- package/dist/elements/preupgrade/slider.css +1 -1
- package/dist/elements/preupgrade/snackbar.css +1 -1
- package/dist/elements/preupgrade/split-button.css +1 -1
- package/dist/elements/preupgrade/switch.css +1 -1
- package/dist/elements/preupgrade/tabs.css +1 -1
- package/dist/elements/preupgrade/text-field.css +1 -1
- package/dist/elements/preupgrade/timepicker.css +1 -1
- package/dist/elements/preupgrade/toolbar.css +1 -1
- package/dist/elements/preupgrade/tooltip.css +1 -1
- package/dist/elements/preupgrade/top-app-bar.css +1 -1
- package/dist/elements/preupgrade.css +1 -1
- package/dist/elements/preupgrade.js +2 -3
- package/dist/elements/radios.d.ts +1 -0
- package/dist/elements/radios.js +5 -1
- package/dist/elements/search.js +19 -3
- package/dist/elements/sheet.js +16 -6
- package/dist/elements/side-sheet.d.ts +3 -0
- package/dist/elements/side-sheet.js +5 -3
- package/dist/elements/styles.js +39 -0
- package/dist/elements/switch.d.ts +4 -0
- package/dist/elements/switch.js +1 -0
- package/dist/elements/tabs.d.ts +5 -0
- package/dist/elements/tabs.js +6 -0
- package/dist/elements/timepicker.d.ts +5 -0
- package/dist/elements/timepicker.js +1 -0
- package/dist/elements/toolbar.d.ts +9 -1
- package/dist/elements/toolbar.js +13 -1
- package/dist/react/bottom-app-bar.d.ts +1 -0
- package/dist/react/jsx.d.ts +1 -0
- package/dist/solid/bottom-app-bar.d.ts +1 -0
- package/dist/solid/jsx.d.ts +31 -27
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base-lite.css +1 -1
- package/dist/styles/base.css +1 -1
- package/dist/styles/bottom-app-bar.css +1 -1
- package/dist/styles/bottom-sheet.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +2 -2
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chips.css +1 -1
- package/dist/styles/contrast.css +1 -1
- package/dist/styles/datepicker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/extended-fab.css +1 -1
- package/dist/styles/fab-menu.css +1 -1
- package/dist/styles/fab.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +2 -2
- package/dist/styles/loading-indicator.css +1 -1
- package/dist/styles/menu.css +2 -2
- package/dist/styles/navigation-bar.css +1 -1
- package/dist/styles/navigation-rail.css +1 -1
- package/dist/styles/progress.css +1 -1
- package/dist/styles/radios.css +1 -1
- package/dist/styles/search.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/side-sheet.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/split-button.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timepicker.css +1 -1
- package/dist/styles/toolbar.css +2 -2
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/top-app-bar.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/utilities.css +1 -1
- package/dist/styles.css +2 -2
- package/dist/svelte/BottomAppBar.svelte.d.ts +1 -0
- package/dist/theme/2025.d.ts +3 -0
- package/dist/theme/2025.js +2 -0
- package/dist/theme/index.js +65 -17
- package/dist/theme/spec2025.d.ts +56 -0
- package/dist/theme/spec2025.js +37 -0
- package/dist/theme/vendor/dynamiccolor/color_spec_2025.js +846 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_color.d.ts +7 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_color.js +9 -5
- package/dist/theme/vendor/dynamiccolor/dynamic_scheme.d.ts +12 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_scheme.js +13 -9
- package/dist/theme/vendor/dynamiccolor/spec_2025.js +263 -0
- package/dist/theme/vendor/dynamiccolor/spec_extensions.js +70 -0
- package/dist/theme/vendor/palettes/tonal_palette.d.ts +23 -0
- package/dist/themes/autumn-contrast.css +1 -1
- package/dist/themes/autumn.css +1 -1
- package/dist/themes/baseline-contrast.css +1 -1
- package/dist/themes/baseline.css +1 -1
- package/dist/themes/brownbeige-contrast.css +1 -1
- package/dist/themes/brownbeige.css +1 -1
- package/dist/themes/content-contrast.css +1 -1
- package/dist/themes/content.css +1 -1
- package/dist/themes/desert-contrast.css +1 -1
- package/dist/themes/desert.css +1 -1
- package/dist/themes/expressive-contrast.css +1 -1
- package/dist/themes/expressive.css +1 -1
- package/dist/themes/fidelity-contrast.css +1 -1
- package/dist/themes/fidelity.css +1 -1
- package/dist/themes/forest-contrast.css +1 -1
- package/dist/themes/forest.css +1 -1
- package/dist/themes/fruit-salad-contrast.css +1 -1
- package/dist/themes/fruit-salad.css +1 -1
- package/dist/themes/highcontrast-contrast.css +1 -1
- package/dist/themes/highcontrast.css +1 -1
- package/dist/themes/monochrome-contrast.css +1 -1
- package/dist/themes/monochrome.css +1 -1
- package/dist/themes/neutral-contrast.css +1 -1
- package/dist/themes/neutral.css +1 -1
- package/dist/themes/ocean-contrast.css +1 -1
- package/dist/themes/ocean.css +1 -1
- package/dist/themes/rainbow-contrast.css +1 -1
- package/dist/themes/rainbow.css +1 -1
- package/dist/themes/sageivory-contrast.css +1 -1
- package/dist/themes/sageivory.css +1 -1
- package/dist/themes/spring-contrast.css +1 -1
- package/dist/themes/spring.css +1 -1
- package/dist/themes/summer-contrast.css +1 -1
- package/dist/themes/summer.css +1 -1
- package/dist/themes/sunset-contrast.css +1 -1
- package/dist/themes/sunset.css +1 -1
- package/dist/themes/tealcaramel-contrast.css +1 -1
- package/dist/themes/tealcaramel.css +1 -1
- package/dist/themes/vibrant-contrast.css +1 -1
- package/dist/themes/vibrant.css +1 -1
- package/dist/vue/bottom-app-bar.d.ts +1 -0
- package/package.json +8 -3
- package/src/styles/components/_button.scss +19 -0
- package/src/styles/components/_list.scss +35 -1
- package/src/styles/components/_menu.scss +64 -46
- package/src/styles/components/_toolbar.scss +19 -2
- package/dist/elements/css/badge.d.ts +0 -1
- package/dist/elements/css/bottom-app-bar.d.ts +0 -1
- package/dist/elements/css/bottom-sheet.d.ts +0 -1
- package/dist/elements/css/button-group.d.ts +0 -1
- package/dist/elements/css/button.d.ts +0 -1
- package/dist/elements/css/card.d.ts +0 -1
- package/dist/elements/css/carousel.d.ts +0 -1
- package/dist/elements/css/checkbox.d.ts +0 -1
- package/dist/elements/css/chips.d.ts +0 -1
- package/dist/elements/css/datepicker.d.ts +0 -1
- package/dist/elements/css/dialog.d.ts +0 -1
- package/dist/elements/css/divider.d.ts +0 -1
- package/dist/elements/css/drawer.d.ts +0 -1
- package/dist/elements/css/extended-fab.d.ts +0 -1
- package/dist/elements/css/fab-menu.d.ts +0 -1
- package/dist/elements/css/fab.d.ts +0 -1
- package/dist/elements/css/icon-button.d.ts +0 -1
- package/dist/elements/css/list.d.ts +0 -1
- package/dist/elements/css/loading-indicator.d.ts +0 -1
- package/dist/elements/css/menu.d.ts +0 -1
- package/dist/elements/css/navigation-bar.d.ts +0 -1
- package/dist/elements/css/navigation-rail.d.ts +0 -1
- package/dist/elements/css/progress.d.ts +0 -1
- package/dist/elements/css/radios.d.ts +0 -1
- package/dist/elements/css/ripple.d.ts +0 -1
- package/dist/elements/css/search.d.ts +0 -1
- package/dist/elements/css/select.d.ts +0 -1
- package/dist/elements/css/side-sheet.d.ts +0 -1
- package/dist/elements/css/slider.d.ts +0 -1
- package/dist/elements/css/snackbar.d.ts +0 -1
- package/dist/elements/css/split-button.d.ts +0 -1
- package/dist/elements/css/switch.d.ts +0 -1
- package/dist/elements/css/tabs.d.ts +0 -1
- package/dist/elements/css/text-field.d.ts +0 -1
- package/dist/elements/css/timepicker.d.ts +0 -1
- package/dist/elements/css/toolbar.d.ts +0 -1
- package/dist/elements/css/tooltip.d.ts +0 -1
- package/dist/elements/css/top-app-bar.d.ts +0 -1
- package/dist/styles/badge.d.ts +0 -1
- package/dist/styles/base-lite.d.ts +0 -1
- package/dist/styles/base.d.ts +0 -1
- package/dist/styles/bottom-app-bar.d.ts +0 -1
- package/dist/styles/bottom-sheet.d.ts +0 -1
- package/dist/styles/button-group.d.ts +0 -1
- package/dist/styles/button.d.ts +0 -1
- package/dist/styles/card.d.ts +0 -1
- package/dist/styles/carousel.d.ts +0 -1
- package/dist/styles/checkbox.d.ts +0 -1
- package/dist/styles/chips.d.ts +0 -1
- package/dist/styles/contrast.d.ts +0 -1
- package/dist/styles/datepicker.d.ts +0 -1
- package/dist/styles/dialog.d.ts +0 -1
- package/dist/styles/divider.d.ts +0 -1
- package/dist/styles/drawer.d.ts +0 -1
- package/dist/styles/extended-fab.d.ts +0 -1
- package/dist/styles/fab-menu.d.ts +0 -1
- package/dist/styles/fab.d.ts +0 -1
- package/dist/styles/icon-button.d.ts +0 -1
- package/dist/styles/list.d.ts +0 -1
- package/dist/styles/loading-indicator.d.ts +0 -1
- package/dist/styles/menu.d.ts +0 -1
- package/dist/styles/navigation-bar.d.ts +0 -1
- package/dist/styles/navigation-rail.d.ts +0 -1
- package/dist/styles/progress.d.ts +0 -1
- package/dist/styles/radios.d.ts +0 -1
- package/dist/styles/search.d.ts +0 -1
- package/dist/styles/select.d.ts +0 -1
- package/dist/styles/side-sheet.d.ts +0 -1
- package/dist/styles/slider.d.ts +0 -1
- package/dist/styles/snackbar.d.ts +0 -1
- package/dist/styles/split-button.d.ts +0 -1
- package/dist/styles/switch.d.ts +0 -1
- package/dist/styles/tabs.d.ts +0 -1
- package/dist/styles/text-field.d.ts +0 -1
- package/dist/styles/timepicker.d.ts +0 -1
- package/dist/styles/toolbar.d.ts +0 -1
- package/dist/styles/tooltip.d.ts +0 -1
- package/dist/styles/top-app-bar.d.ts +0 -1
- package/dist/styles/typography.d.ts +0 -1
- package/dist/styles/utilities.d.ts +0 -1
- package/dist/theme/roles.js +0 -68
- package/dist/theme/vendor/scheme/scheme_content.js +0 -30
- package/dist/theme/vendor/scheme/scheme_expressive.js +0 -30
- package/dist/theme/vendor/scheme/scheme_fidelity.js +0 -30
- package/dist/theme/vendor/scheme/scheme_monochrome.js +0 -30
- package/dist/theme/vendor/scheme/scheme_neutral.js +0 -30
- package/dist/theme/vendor/scheme/scheme_tonal_spot.js +0 -30
- package/dist/theme/vendor/scheme/scheme_vibrant.js +0 -30
|
@@ -42,8 +42,8 @@ attributes,
|
|
|
42
42
|
className: [
|
|
43
43
|
config.visible ? MENU_CLASSES.VISIBLE : null,
|
|
44
44
|
config.dense ? `${config.prefix}-menu--dense` : null,
|
|
45
|
-
config.variant
|
|
46
|
-
config.variant
|
|
45
|
+
config.variant !== "baseline" ? `${config.prefix}-menu--vertical` : null,
|
|
46
|
+
config.variant !== "baseline" && config.color === "vibrant"
|
|
47
47
|
? `${config.prefix}-menu--vibrant`
|
|
48
48
|
: null,
|
|
49
49
|
config.class,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Menu position options for alignment relative to opener element */
|
|
2
2
|
/** Menu variants The baseline menu is the original M3 design: square-ish corners, a surface-container container, and items that fill the width. */
|
|
3
3
|
export declare const MENU_VARIANTS: {
|
|
4
|
-
/** The original M3 menu
|
|
4
|
+
/** The original M3 baseline menu */
|
|
5
5
|
readonly BASELINE: "baseline";
|
|
6
|
-
/** The M3 expressive vertical menu */
|
|
6
|
+
/** The M3 expressive vertical menu (default) */
|
|
7
7
|
readonly VERTICAL: "vertical";
|
|
8
8
|
};
|
|
9
9
|
/** Colour mappings for the vertical menu Standard is surface-based and carries lower emphasis; vibrant is tertiary-based, is more prominent, and should be used sparingly (m3.material.io menu guidelines, "Color options"). */
|
|
@@ -39,8 +39,8 @@ export declare const MENU_POSITION: {
|
|
|
39
39
|
};
|
|
40
40
|
/** Default configuration values for menus */
|
|
41
41
|
export declare const MENU_DEFAULTS: {
|
|
42
|
-
/** Default variant; the
|
|
43
|
-
readonly VARIANT: "
|
|
42
|
+
/** Default variant; the M3 expressive vertical menu */
|
|
43
|
+
readonly VARIANT: "vertical";
|
|
44
44
|
/** Default colour mapping for the vertical variant */
|
|
45
45
|
readonly COLOR: "standard";
|
|
46
46
|
/** Default menu position */
|
|
@@ -76,7 +76,7 @@ if (state.selectedItemId && item.id === state.selectedItemId) {
|
|
|
76
76
|
itemElement.classList.add(`${itemClass}--selected`);
|
|
77
77
|
itemElement.setAttribute("aria-selected", "true");
|
|
78
78
|
}
|
|
79
|
-
else {
|
|
79
|
+
else if (listbox) {
|
|
80
80
|
itemElement.setAttribute("aria-selected", "false");
|
|
81
81
|
}
|
|
82
82
|
if (item.hasSubmenu) {
|
|
@@ -153,6 +153,14 @@ menuList.className = `${component.getClass("menu__list")}`;
|
|
|
153
153
|
menuList.setAttribute("role", listbox ? "listbox" : "menu");
|
|
154
154
|
if (listbox)
|
|
155
155
|
menuList.id = `${optionIdPrefix}-listbox`;
|
|
156
|
+
else {
|
|
157
|
+
const label = component.element.getAttribute("aria-label");
|
|
158
|
+
const labelledby = component.element.getAttribute("aria-labelledby");
|
|
159
|
+
if (label)
|
|
160
|
+
menuList.setAttribute("aria-label", label);
|
|
161
|
+
if (labelledby)
|
|
162
|
+
menuList.setAttribute("aria-labelledby", labelledby);
|
|
163
|
+
}
|
|
156
164
|
let target = menuList;
|
|
157
165
|
const startGroup = () => {
|
|
158
166
|
const group = document.createElement("li");
|
|
@@ -232,7 +240,10 @@ item.setAttribute("aria-selected", "true");
|
|
|
232
240
|
}
|
|
233
241
|
else {
|
|
234
242
|
item.classList.remove(`${component.getClass("menu__item--selected")}`);
|
|
243
|
+
if (listbox)
|
|
235
244
|
item.setAttribute("aria-selected", "false");
|
|
245
|
+
else
|
|
246
|
+
item.removeAttribute("aria-selected");
|
|
236
247
|
}
|
|
237
248
|
});
|
|
238
249
|
state.selectedItemId = itemId;
|
|
@@ -16,6 +16,13 @@ const scrollY = hasContainer || topLayer
|
|
|
16
16
|
? 0
|
|
17
17
|
: window.pageYOffset || document.documentElement.scrollTop;
|
|
18
18
|
const openerRect = openerElement.getBoundingClientRect();
|
|
19
|
+
const parentMenu = isSubmenu
|
|
20
|
+
? openerElement.closest(`.${component.getClass("menu")}`)
|
|
21
|
+
: null;
|
|
22
|
+
const rawParentMenuRect = parentMenu ? parentMenu.getBoundingClientRect() : null;
|
|
23
|
+
const horizontalRect = rawParentMenuRect && rawParentMenuRect.width >= openerRect.width
|
|
24
|
+
? rawParentMenuRect
|
|
25
|
+
: openerRect;
|
|
19
26
|
const tempMenu = menuElement.cloneNode(true);
|
|
20
27
|
tempMenu.style.visibility = "hidden";
|
|
21
28
|
tempMenu.style.display = "block";
|
|
@@ -43,11 +50,11 @@ let calculatedPosition = preferredPosition;
|
|
|
43
50
|
if (isSubmenu) {
|
|
44
51
|
calculatedPosition = preferredPosition || "right-start";
|
|
45
52
|
if (calculatedPosition.startsWith("right") &&
|
|
46
|
-
|
|
53
|
+
horizontalRect.right + menuRect.width + offset > viewportWidth - 16) {
|
|
47
54
|
calculatedPosition = calculatedPosition.replace("right", "left");
|
|
48
55
|
}
|
|
49
56
|
else if (calculatedPosition.startsWith("left") &&
|
|
50
|
-
|
|
57
|
+
horizontalRect.left - menuRect.width - offset < 16) {
|
|
51
58
|
calculatedPosition = calculatedPosition.replace("left", "right");
|
|
52
59
|
}
|
|
53
60
|
if (openerRect.top + menuRect.height > viewportHeight - 48) {
|
|
@@ -168,7 +175,7 @@ left = openerRect.right + offsetX - menuRect.width;
|
|
|
168
175
|
break;
|
|
169
176
|
case "right-start":
|
|
170
177
|
top = openerRect.top + offsetY;
|
|
171
|
-
left =
|
|
178
|
+
left = horizontalRect.right + offsetX + offset;
|
|
172
179
|
break;
|
|
173
180
|
case "right":
|
|
174
181
|
if (top === 0) {
|
|
@@ -181,11 +188,11 @@ height / 2;
|
|
|
181
188
|
else {
|
|
182
189
|
top += offsetY;
|
|
183
190
|
}
|
|
184
|
-
left =
|
|
191
|
+
left = horizontalRect.right + offsetX + offset;
|
|
185
192
|
break;
|
|
186
193
|
case "right-end":
|
|
187
194
|
top = openerRect.bottom + offsetY - height;
|
|
188
|
-
left =
|
|
195
|
+
left = horizontalRect.right + offsetX + offset;
|
|
189
196
|
break;
|
|
190
197
|
case "bottom-start":
|
|
191
198
|
top = openerRect.bottom + offsetY + offset;
|
|
@@ -202,7 +209,7 @@ left = openerRect.right + offsetX - menuRect.width;
|
|
|
202
209
|
break;
|
|
203
210
|
case "left-start":
|
|
204
211
|
top = openerRect.top + offsetY;
|
|
205
|
-
left =
|
|
212
|
+
left = horizontalRect.left + offsetX - menuRect.width - offset;
|
|
206
213
|
break;
|
|
207
214
|
case "left":
|
|
208
215
|
if (top === 0) {
|
|
@@ -215,11 +222,11 @@ height / 2;
|
|
|
215
222
|
else {
|
|
216
223
|
top += offsetY;
|
|
217
224
|
}
|
|
218
|
-
left =
|
|
225
|
+
left = horizontalRect.left + offsetX - menuRect.width - offset;
|
|
219
226
|
break;
|
|
220
227
|
case "left-end":
|
|
221
228
|
top = openerRect.bottom + offsetY - height;
|
|
222
|
-
left =
|
|
229
|
+
left = horizontalRect.left + offsetX - menuRect.width - offset;
|
|
223
230
|
break;
|
|
224
231
|
}
|
|
225
232
|
if (hasContainer) {
|
|
@@ -161,6 +161,8 @@ submenuElement.classList.add(name);
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
submenuElement.setAttribute("role", "menu");
|
|
164
|
+
if (item.text)
|
|
165
|
+
submenuElement.setAttribute("aria-label", item.text);
|
|
164
166
|
submenuElement.setAttribute("tabindex", "-1");
|
|
165
167
|
submenuElement.setAttribute("data-level", currentLevel.toString());
|
|
166
168
|
submenuElement.setAttribute("data-parent-item", item.id);
|
|
@@ -173,6 +175,7 @@ submenuElement.setAttribute("data-owner", ownerId);
|
|
|
173
175
|
submenuElement.style.zIndex = `${1000 + currentLevel * 10}`;
|
|
174
176
|
const submenuList = document.createElement("ul");
|
|
175
177
|
submenuList.className = `${component.getClass("menu__list")}`;
|
|
178
|
+
submenuList.setAttribute("role", "none");
|
|
176
179
|
const submenuItems = [];
|
|
177
180
|
component.emit("create-menu-items", {
|
|
178
181
|
items: item.submenu,
|
|
@@ -81,7 +81,7 @@ export interface MenuConfig {
|
|
|
81
81
|
items: MenuContent[];
|
|
82
82
|
/**
|
|
83
83
|
* Menu variant.
|
|
84
|
-
* @default '
|
|
84
|
+
* @default 'vertical'
|
|
85
85
|
*/
|
|
86
86
|
variant?: MenuVariant;
|
|
87
87
|
/** Colour mapping for the vertical variant. */
|
|
@@ -156,6 +156,8 @@ export interface MenuConfig {
|
|
|
156
156
|
dense?: boolean;
|
|
157
157
|
/** Additional CSS classes to add to the menu */
|
|
158
158
|
class?: string;
|
|
159
|
+
/** Accessible label for assistive technology on the menu surface and list */
|
|
160
|
+
ariaLabel?: string;
|
|
159
161
|
/**
|
|
160
162
|
* Component prefix for CSS class names
|
|
161
163
|
* @default 'mtrl'
|
|
@@ -364,3 +366,8 @@ export interface MenuFeatureHost {
|
|
|
364
366
|
}>;
|
|
365
367
|
};
|
|
366
368
|
}
|
|
369
|
+
declare module "../../core/config/global" {
|
|
370
|
+
interface ComponentConfigMap {
|
|
371
|
+
menu?: Partial<MenuConfig>;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
@@ -22,6 +22,8 @@ if (config.disabled || option.disabled) {
|
|
|
22
22
|
input.disabled = true;
|
|
23
23
|
radioContainer.classList.add(`${radiosClass}__item--disabled`);
|
|
24
24
|
}
|
|
25
|
+
if (config.required)
|
|
26
|
+
input.required = true;
|
|
25
27
|
const label = document.createElement('label');
|
|
26
28
|
label.classList.add(`${radiosClass}__label`);
|
|
27
29
|
const radioControl = document.createElement('span');
|
|
@@ -75,8 +75,13 @@ const setPlaceholder = (text) => {
|
|
|
75
75
|
currentPlaceholder = text;
|
|
76
76
|
const input = component.structure?.input;
|
|
77
77
|
if (input) {
|
|
78
|
+
const label = config.ariaLabel || text;
|
|
78
79
|
input.placeholder = text;
|
|
79
|
-
input.setAttribute("aria-label",
|
|
80
|
+
input.setAttribute("aria-label", label);
|
|
81
|
+
const surface = component.structure?.surface;
|
|
82
|
+
if (surface?.hasAttribute("aria-label")) {
|
|
83
|
+
surface.setAttribute("aria-label", label || "Search");
|
|
84
|
+
}
|
|
80
85
|
}
|
|
81
86
|
};
|
|
82
87
|
const getPlaceholder = () => {
|
|
@@ -47,7 +47,9 @@ const surface = createElement({
|
|
|
47
47
|
tag: "dialog",
|
|
48
48
|
className: getClass(SEARCH_CLASSES.SURFACE),
|
|
49
49
|
container: component.element,
|
|
50
|
-
attributes:
|
|
50
|
+
attributes: isViewState && config.viewMode === "fullscreen"
|
|
51
|
+
? { "aria-label": config.ariaLabel || placeholder }
|
|
52
|
+
: { role: "none" },
|
|
51
53
|
});
|
|
52
54
|
const container = createElement({
|
|
53
55
|
tag: "div",
|
|
@@ -19,7 +19,7 @@ merged.layer = undefined;
|
|
|
19
19
|
}
|
|
20
20
|
return merged;
|
|
21
21
|
};
|
|
22
|
-
export const getElementConfig = (config) => createElementConfig({ ...config, title: undefined }, {
|
|
22
|
+
export const getElementConfig = (config) => createElementConfig({ ...config, title: undefined, ariaLabel: undefined }, {
|
|
23
23
|
tag: config.layer === "top" ? "dialog" : "div",
|
|
24
24
|
className: [config.class].filter(Boolean),
|
|
25
25
|
attributes: {
|
|
@@ -14,11 +14,15 @@ scrim = document.createElement("div");
|
|
|
14
14
|
scrim.className = getClass(SIDE_SHEET_CLASSES.SCRIM);
|
|
15
15
|
element.appendChild(scrim);
|
|
16
16
|
}
|
|
17
|
+
const isTopDialog = element.localName === "dialog";
|
|
17
18
|
const container = document.createElement("div");
|
|
18
19
|
container.className = getClass(SIDE_SHEET_CLASSES.CONTAINER);
|
|
20
|
+
if (!isTopDialog) {
|
|
19
21
|
container.setAttribute("role", isModal ? "dialog" : "complementary");
|
|
20
22
|
if (isModal)
|
|
21
23
|
container.setAttribute("aria-modal", "true");
|
|
24
|
+
}
|
|
25
|
+
const surface = isTopDialog ? element : container;
|
|
22
26
|
container.tabIndex = -1;
|
|
23
27
|
if (config.width)
|
|
24
28
|
container.style.width = `${config.width}px`;
|
|
@@ -36,7 +40,7 @@ title.textContent = config.title;
|
|
|
36
40
|
title.id = `${getClass(SIDE_SHEET_CLASSES.TITLE)}-${Math.random()
|
|
37
41
|
.toString(36)
|
|
38
42
|
.slice(2, 9)}`;
|
|
39
|
-
|
|
43
|
+
surface.setAttribute("aria-labelledby", title.id);
|
|
40
44
|
header.appendChild(title);
|
|
41
45
|
}
|
|
42
46
|
if (config.closeButton) {
|
|
@@ -49,6 +53,9 @@ header.appendChild(closeButton);
|
|
|
49
53
|
}
|
|
50
54
|
container.appendChild(header);
|
|
51
55
|
}
|
|
56
|
+
if (!config.title && config.ariaLabel) {
|
|
57
|
+
surface.setAttribute("aria-label", config.ariaLabel);
|
|
58
|
+
}
|
|
52
59
|
const content = document.createElement("div");
|
|
53
60
|
content.className = getClass(SIDE_SHEET_CLASSES.CONTENT);
|
|
54
61
|
if (config.content instanceof HTMLElement)
|
|
@@ -84,7 +91,8 @@ title.textContent = next;
|
|
|
84
91
|
title.id = `${getClass(SIDE_SHEET_CLASSES.TITLE)}-${Math.random()
|
|
85
92
|
.toString(36)
|
|
86
93
|
.slice(2, 9)}`;
|
|
87
|
-
|
|
94
|
+
surface.removeAttribute("aria-label");
|
|
95
|
+
surface.setAttribute("aria-labelledby", title.id);
|
|
88
96
|
let header = container.querySelector(`.${getClass(SIDE_SHEET_CLASSES.HEADER)}`);
|
|
89
97
|
if (!header) {
|
|
90
98
|
header = document.createElement("div");
|
|
@@ -22,6 +22,8 @@ export interface SideSheetConfig {
|
|
|
22
22
|
position?: SideSheetPosition;
|
|
23
23
|
/** Headline in the header. */
|
|
24
24
|
title?: string;
|
|
25
|
+
/** Accessible label for assistive technology when no visible `title` headline is provided. */
|
|
26
|
+
ariaLabel?: string;
|
|
25
27
|
/** Body of the sheet, as markup or an element */
|
|
26
28
|
content?: string | HTMLElement;
|
|
27
29
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { controlLabelConfig } from "../../core/config/control-label.js";
|
|
1
2
|
import { PREFIX } from "../../core/config.js";
|
|
2
3
|
import { createComponentConfig, createElementConfig, } from "../../core/config/component.js";
|
|
3
4
|
import { SLIDER_DEFAULTS } from "./constants.js";
|
|
@@ -45,7 +46,7 @@ tabindex: "-1",
|
|
|
45
46
|
if (config.disabled) {
|
|
46
47
|
attributes["aria-disabled"] = "true";
|
|
47
48
|
}
|
|
48
|
-
return createElementConfig(config, {
|
|
49
|
+
return controlLabelConfig(createElementConfig(config, {
|
|
49
50
|
tag: "div",
|
|
50
51
|
attributes,
|
|
51
52
|
className: classes,
|
|
@@ -60,5 +61,5 @@ mousemove: true,
|
|
|
60
61
|
mouseup: true,
|
|
61
62
|
},
|
|
62
63
|
interactive: true,
|
|
63
|
-
});
|
|
64
|
+
}), config.controlLabelOnly);
|
|
64
65
|
};
|
|
@@ -9,6 +9,11 @@ export type SliderColor = "primary" | "secondary" | "tertiary" | "error";
|
|
|
9
9
|
export type SliderEventType = "change" | "input" | "focus" | "blur" | "start" | "end";
|
|
10
10
|
/** Configuration options for the slider component */
|
|
11
11
|
export interface SliderConfig extends BaseComponentConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Put ariaLabel only on the input/handle, omitting the generated wrapper label.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
controlLabelOnly?: boolean;
|
|
12
17
|
/** Minimum value of the slider */
|
|
13
18
|
min?: number;
|
|
14
19
|
/** Maximum value of the slider */
|
|
@@ -11,7 +11,7 @@ export const getElementConfig = (config) => {
|
|
|
11
11
|
const attributes = { role: "group" };
|
|
12
12
|
if (config.groupLabel)
|
|
13
13
|
attributes["aria-label"] = config.groupLabel;
|
|
14
|
-
return createElementConfig(config, {
|
|
14
|
+
return createElementConfig({ ...config, ariaLabel: undefined }, {
|
|
15
15
|
tag: "div",
|
|
16
16
|
attributes,
|
|
17
17
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { controlLabelConfig } from "../../core/config/control-label.js";
|
|
1
2
|
import { createComponentConfig, createElementConfig, } from "../../core/config/component.js";
|
|
2
3
|
import { SWITCH_DEFAULTS } from "./constants.js";
|
|
3
4
|
export const defaultConfig = {
|
|
@@ -6,11 +7,11 @@ componentName: "switch",
|
|
|
6
7
|
labelPosition: SWITCH_DEFAULTS.LABEL_POSITION,
|
|
7
8
|
};
|
|
8
9
|
export const createBaseConfig = (config = {}) => createComponentConfig(defaultConfig, config, "switch");
|
|
9
|
-
export const getElementConfig = (config) => createElementConfig(config, {
|
|
10
|
+
export const getElementConfig = (config) => controlLabelConfig(createElementConfig(config, {
|
|
10
11
|
tag: "div",
|
|
11
12
|
className: config.class,
|
|
12
13
|
interactive: true,
|
|
13
|
-
});
|
|
14
|
+
}), config.controlLabelOnly);
|
|
14
15
|
export const getApiConfig = (comp) => ({
|
|
15
16
|
disabled: {
|
|
16
17
|
enable: comp.disabled.enable,
|
|
@@ -25,6 +25,11 @@ export interface SwitchConfig {
|
|
|
25
25
|
class?: string;
|
|
26
26
|
/** ARIA label for accessibility */
|
|
27
27
|
ariaLabel?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Put ariaLabel only on the input/handle, omitting the generated wrapper label.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
controlLabelOnly?: boolean;
|
|
28
33
|
/** Prefix for class names */
|
|
29
34
|
prefix?: string;
|
|
30
35
|
/** Component name */
|
|
@@ -75,6 +75,7 @@ button.setValue(safeValue);
|
|
|
75
75
|
this.element.setAttribute("id", tabIdFor(baseConfig.groupId ?? "", safeValue));
|
|
76
76
|
registerTab(this.element, baseConfig.groupId ?? "", safeValue);
|
|
77
77
|
syncTabControls(this.element);
|
|
78
|
+
announceBadge();
|
|
78
79
|
return this;
|
|
79
80
|
},
|
|
80
81
|
activate() {
|
|
@@ -117,6 +118,11 @@ return this;
|
|
|
117
118
|
getText() {
|
|
118
119
|
return button.getText();
|
|
119
120
|
},
|
|
121
|
+
setAriaLabel(label) {
|
|
122
|
+
baseConfig.ariaLabel = label;
|
|
123
|
+
announceBadge();
|
|
124
|
+
return this;
|
|
125
|
+
},
|
|
120
126
|
setIcon(icon) {
|
|
121
127
|
button.setIcon(icon);
|
|
122
128
|
this.updateLayoutStyle();
|
|
@@ -135,6 +141,7 @@ prefix: baseConfig.prefix,
|
|
|
135
141
|
...(baseConfig.badgeConfig || {}),
|
|
136
142
|
};
|
|
137
143
|
this.badge = createBadge(badgeConfig);
|
|
144
|
+
this.badge.element.setAttribute("aria-hidden", "true");
|
|
138
145
|
}
|
|
139
146
|
else {
|
|
140
147
|
this.badge.setContent(content);
|
|
@@ -205,14 +212,12 @@ this.badge?.attachTo(anchor);
|
|
|
205
212
|
const announceBadge = () => {
|
|
206
213
|
const count = tab.badge?.isVisible()
|
|
207
214
|
? tab.badge.element.getAttribute("aria-label") || tab.badge.getContent() : "";
|
|
208
|
-
const
|
|
215
|
+
const text = button.getText();
|
|
216
|
+
const label = baseConfig.ariaLabel || text || button.getValue();
|
|
209
217
|
const name = [label, count].filter(Boolean).join(", ");
|
|
210
|
-
if (name !==
|
|
218
|
+
if (name !== text || baseConfig.ariaLabel) {
|
|
211
219
|
tab.element.setAttribute("aria-label", name);
|
|
212
220
|
}
|
|
213
|
-
else if (baseConfig.ariaLabel) {
|
|
214
|
-
tab.element.setAttribute("aria-label", baseConfig.ariaLabel);
|
|
215
|
-
}
|
|
216
221
|
else {
|
|
217
222
|
tab.element.removeAttribute("aria-label");
|
|
218
223
|
}
|
|
@@ -221,6 +226,7 @@ if (baseConfig.badge !== undefined) {
|
|
|
221
226
|
tab.setBadge(baseConfig.badge);
|
|
222
227
|
}
|
|
223
228
|
tab.updateLayoutStyle();
|
|
229
|
+
announceBadge();
|
|
224
230
|
return tab;
|
|
225
231
|
}
|
|
226
232
|
catch (error) {
|
|
@@ -48,7 +48,7 @@ export interface TabsEvents {
|
|
|
48
48
|
export interface TabConfig {
|
|
49
49
|
/** Id of the tab group this tab belongs to. */
|
|
50
50
|
groupId?: string;
|
|
51
|
-
/** Accessible name for a tab
|
|
51
|
+
/** Accessible name for a tab. */
|
|
52
52
|
ariaLabel?: string;
|
|
53
53
|
/**
|
|
54
54
|
* Tab state that determines if it's the active destination
|
|
@@ -105,6 +105,8 @@ export interface TabConfig {
|
|
|
105
105
|
}
|
|
106
106
|
/** Configuration interface for the Tabs component */
|
|
107
107
|
export interface TabsConfig {
|
|
108
|
+
/** Accessible name for the tablist when it has no visible label. */
|
|
109
|
+
ariaLabel?: string;
|
|
108
110
|
/** Id for this tab group, used to build each tab's element id as `tab-<groupId>-<value>` and to find panels as `tabpanel-<groupId>-<value>`; a value with characters outside `[A-Za-z0-9_-]` gets a derived id instead (`tabIdFor`, `tabPanelIdFor`, The group id itself is not encoded: keep a pinned one to `[A-Za-z0-9_]` (generated ones are), or `tabIdFor("a-b", "c")` and `tabIdFor("a", "b-c")` coincide and a space makes an unsafe id. */
|
|
109
111
|
groupId?: string;
|
|
110
112
|
/**
|
|
@@ -193,6 +195,8 @@ export interface TabComponent {
|
|
|
193
195
|
isDisabled: () => boolean;
|
|
194
196
|
/** Sets the tab's text content */
|
|
195
197
|
setText: (content: string) => TabComponent;
|
|
198
|
+
/** Sets the explicit accessible label; undefined restores text/value naming. */
|
|
199
|
+
setAriaLabel: (label: string | undefined) => TabComponent;
|
|
196
200
|
/** Gets the tab's text content */
|
|
197
201
|
getText: () => string;
|
|
198
202
|
/** Sets the tab's icon */
|
|
@@ -14,7 +14,7 @@ catch {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
})() && process.env.NODE_ENV !== "production") {
|
|
17
|
-
const KEY_LIST = "type variant density name label value placeholder required noAsterisk disabled readonly maxLength pattern autocomplete leadingIcon trailingIcon trailingIconLabel onTrailingClick supportingText error prefixText suffixText class prefix componentName className parent id title tabIndex style data role ariaLabel ariaDescribedBy ariaLabelledBy ariaHidden multiline";
|
|
17
|
+
const KEY_LIST = "type variant density name label value placeholder required noAsterisk disabled readonly maxLength pattern autocomplete leadingIcon trailingIcon trailingIconLabel onTrailingClick supportingText error prefixText suffixText class prefix componentName className parent id title tabIndex style data role ariaLabel ariaDescribedBy ariaLabelledBy ariaHidden multiline controlLabelOnly";
|
|
18
18
|
const _complete = true;
|
|
19
19
|
const _sound = true;
|
|
20
20
|
const CONFIG_KEYS = KEY_LIST.split(" ");
|
|
@@ -25,10 +25,15 @@ warnDev("text-field", `unknown config key "${key}"`);
|
|
|
25
25
|
}
|
|
26
26
|
return createComponentConfig(defaultConfig, config, "text-field");
|
|
27
27
|
};
|
|
28
|
-
export const getElementConfig = (config) =>
|
|
28
|
+
export const getElementConfig = (config) => {
|
|
29
|
+
const wrapper = createElementConfig(config, {
|
|
29
30
|
tag: "div",
|
|
30
31
|
className: config.class,
|
|
31
32
|
});
|
|
33
|
+
if (config.controlLabelOnly)
|
|
34
|
+
wrapper.ariaLabel = undefined;
|
|
35
|
+
return wrapper;
|
|
36
|
+
};
|
|
32
37
|
export const getApiConfig = (comp) => ({
|
|
33
38
|
disabled: {
|
|
34
39
|
enable: comp.disabled.enable,
|
|
@@ -44,6 +44,11 @@ export interface TextFieldConfig {
|
|
|
44
44
|
label?: string;
|
|
45
45
|
/** Accessible name for the input; the visible label is the fallback. */
|
|
46
46
|
ariaLabel?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Put ariaLabel only on the input/handle, omitting the generated wrapper label.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
controlLabelOnly?: boolean;
|
|
47
52
|
/** Initial value */
|
|
48
53
|
value?: string;
|
|
49
54
|
/** Placeholder text */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TIME_PICKER_TYPE, TIME_PICKER_ORIENTATION, TIME_FORMAT, TIME_PERIOD } from "./types.js";
|
|
2
2
|
import { TIMEPICKER_EVENTS as EVENTS } from "./constants.js";
|
|
3
3
|
import { formatFormValue } from "./utils.js";
|
|
4
|
-
import { renderTimePicker } from "./render.js";
|
|
4
|
+
import { nameTimePicker, renderTimePicker } from "./render.js";
|
|
5
5
|
import { setFormValue } from "../../core/dom/form-value.js";
|
|
6
6
|
import { deepActiveElement } from "../../core/dom/focus.js";
|
|
7
7
|
import { onModalEscape } from "../../core/dom/layer.js";
|
|
@@ -187,13 +187,12 @@ return config.orientation;
|
|
|
187
187
|
},
|
|
188
188
|
setTitle(title) {
|
|
189
189
|
config.title = title;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
190
|
+
nameTimePicker(dialogElement, config);
|
|
191
|
+
return this;
|
|
192
|
+
},
|
|
193
|
+
setAriaLabel(label) {
|
|
194
|
+
config.ariaLabel = label;
|
|
195
|
+
nameTimePicker(dialogElement, config);
|
|
197
196
|
return this;
|
|
198
197
|
},
|
|
199
198
|
getTitle() {
|
|
@@ -17,7 +17,7 @@ keyboardIcon: TIMEPICKER_ICONS.KEYBOARD,
|
|
|
17
17
|
export const createBaseConfig = (config = {}) => createComponentConfig(defaultConfig, config, "time-picker");
|
|
18
18
|
const inDialog = (event, prefix) => event.target instanceof Element && event.target.closest(`.${prefix}-time-picker__dialog`) !== null;
|
|
19
19
|
export const getContainerConfig = (config) => {
|
|
20
|
-
return createElementConfig({ ...config, title: undefined }, {
|
|
20
|
+
return createElementConfig({ ...config, title: undefined, ariaLabel: undefined }, {
|
|
21
21
|
tag: "div",
|
|
22
22
|
className: [
|
|
23
23
|
config.class,
|
|
@@ -4,15 +4,32 @@ import { padZero, convertTo12Hour, limitsOf, reachable, constrainTime, secondsOf
|
|
|
4
4
|
import { createDial, nameFor } from "./dial.js";
|
|
5
5
|
let fieldIds = 0;
|
|
6
6
|
import { setHTML } from "../../core/dom/html.js";
|
|
7
|
-
export const
|
|
8
|
-
container.
|
|
7
|
+
export const nameTimePicker = (container, config) => {
|
|
8
|
+
let title = container.querySelector(`.${config.prefix}-time-picker__title`);
|
|
9
9
|
if (config.title) {
|
|
10
|
-
|
|
10
|
+
if (!title) {
|
|
11
|
+
title = container.ownerDocument.createElement("div");
|
|
11
12
|
title.className = `${config.prefix}-time-picker__title`;
|
|
12
|
-
title.textContent = config.title;
|
|
13
13
|
title.id = config.titleId ?? `${config.prefix}-time-picker__title`;
|
|
14
|
-
container.
|
|
14
|
+
container.prepend(title);
|
|
15
|
+
}
|
|
16
|
+
title.textContent = config.title;
|
|
17
|
+
}
|
|
18
|
+
else
|
|
19
|
+
title?.remove();
|
|
20
|
+
const explicit = config.ariaLabel?.trim();
|
|
21
|
+
if (!explicit && config.title?.trim() && title) {
|
|
22
|
+
container.removeAttribute("aria-label");
|
|
23
|
+
container.setAttribute("aria-labelledby", title.id);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
container.removeAttribute("aria-labelledby");
|
|
27
|
+
container.setAttribute("aria-label", explicit || "Select time");
|
|
15
28
|
}
|
|
29
|
+
};
|
|
30
|
+
export const renderTimePicker = (container, timeValue, config, onTimeChange) => {
|
|
31
|
+
container.replaceChildren();
|
|
32
|
+
nameTimePicker(container, config);
|
|
16
33
|
const content = document.createElement("div");
|
|
17
34
|
content.className = `${config.prefix}-time-picker__content`;
|
|
18
35
|
container.appendChild(content);
|
|
@@ -13,7 +13,6 @@ try {
|
|
|
13
13
|
const baseComponent = pipe(createBase, withEvents(), withElement(getContainerConfig(baseConfig)), withLifecycle())(baseConfig);
|
|
14
14
|
baseConfig.titleId = `${baseConfig.prefix}-time-picker-${++pickers}__title`;
|
|
15
15
|
const dialogElement = document.createElement("dialog");
|
|
16
|
-
dialogElement.setAttribute("aria-labelledby", baseConfig.titleId);
|
|
17
16
|
dialogElement.className = [
|
|
18
17
|
`${baseConfig.prefix}-time-picker__dialog`,
|
|
19
18
|
`${baseConfig.prefix}-time-picker__dialog--${baseConfig.type}`,
|
|
@@ -92,6 +92,8 @@ export interface TimePickerConfig {
|
|
|
92
92
|
orientation?: TimePickerOrientation;
|
|
93
93
|
/** Title text for the time picker */
|
|
94
94
|
title?: string;
|
|
95
|
+
/** Accessible dialog name; defaults to the title, then "Select time". */
|
|
96
|
+
ariaLabel?: string;
|
|
95
97
|
/**
|
|
96
98
|
* Whether to show seconds selector
|
|
97
99
|
* @default false
|
|
@@ -229,6 +231,8 @@ export interface TimePickerComponent {
|
|
|
229
231
|
* @param title
|
|
230
232
|
*/
|
|
231
233
|
setTitle: (title: string) => TimePickerComponent;
|
|
234
|
+
/** Names the dialog; empty restores its title or "Select time". */
|
|
235
|
+
setAriaLabel: (label: string) => TimePickerComponent;
|
|
232
236
|
/** Gets the current time picker title */
|
|
233
237
|
getTitle: () => string;
|
|
234
238
|
/** Enables the picker */
|
|
@@ -41,6 +41,7 @@ arrangement: oneOf(TOOLBAR_ARRANGEMENTS, merged.arrangement, TOOLBAR_ARRANGEMENT
|
|
|
41
41
|
fabPosition: merged.fabPosition === "start" ? "start" : "end",
|
|
42
42
|
elevated: floating && merged.elevated !== false,
|
|
43
43
|
exit: merged.scrollBehavior === TOOLBAR_SCROLL_BEHAVIORS.EXIT,
|
|
44
|
+
collapse: !floating && merged.scrollBehavior === TOOLBAR_SCROLL_BEHAVIORS.COLLAPSE,
|
|
44
45
|
scrollThreshold: Math.max(0, Number(merged.scrollThreshold) || 0),
|
|
45
46
|
};
|
|
46
47
|
};
|