mtrl 0.8.0-next.42 → 0.8.0-next.43

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 (62) hide show
  1. package/dist/components/navigation-rail/config.js +2 -1
  2. package/dist/components/navigation-rail/constants.d.ts +5 -0
  3. package/dist/components/navigation-rail/constants.js +4 -0
  4. package/dist/components/navigation-rail/navigation-rail.js +19 -1
  5. package/dist/components/navigation-rail/types.d.ts +4 -0
  6. package/dist/index.cjs +12 -12
  7. package/dist/package.json +1 -1
  8. package/dist/styles/badge.css +1 -1
  9. package/dist/styles/base.css +1 -1
  10. package/dist/styles/bottom-app-bar.css +1 -1
  11. package/dist/styles/bottom-sheet.css +1 -1
  12. package/dist/styles/button-group.css +1 -1
  13. package/dist/styles/button.css +1 -1
  14. package/dist/styles/card.css +1 -1
  15. package/dist/styles/carousel.css +1 -1
  16. package/dist/styles/checkbox.css +1 -1
  17. package/dist/styles/chips.css +1 -1
  18. package/dist/styles/dialog.css +1 -1
  19. package/dist/styles/divider.css +1 -1
  20. package/dist/styles/drawer.css +1 -1
  21. package/dist/styles/extended-fab.css +1 -1
  22. package/dist/styles/fab.css +1 -1
  23. package/dist/styles/icon-button.css +1 -1
  24. package/dist/styles/list.css +1 -1
  25. package/dist/styles/loading-indicator.css +1 -1
  26. package/dist/styles/menu.css +1 -1
  27. package/dist/styles/navigation-rail.css +2 -2
  28. package/dist/styles/navigation.css +1 -1
  29. package/dist/styles/progress.css +1 -1
  30. package/dist/styles/radios.css +1 -1
  31. package/dist/styles/search.css +1 -1
  32. package/dist/styles/segmented-button.css +1 -1
  33. package/dist/styles/select.css +1 -1
  34. package/dist/styles/side-sheet.css +1 -1
  35. package/dist/styles/slider.css +1 -1
  36. package/dist/styles/snackbar.css +1 -1
  37. package/dist/styles/split-button.css +1 -1
  38. package/dist/styles/switch.css +1 -1
  39. package/dist/styles/tabs.css +1 -1
  40. package/dist/styles/textfield.css +1 -1
  41. package/dist/styles/timepicker.css +1 -1
  42. package/dist/styles/top-app-bar.css +1 -1
  43. package/dist/styles/utilities.css +1 -1
  44. package/dist/styles.css +2 -2
  45. package/dist/themes/autumn.css +1 -1
  46. package/dist/themes/baseline.css +1 -1
  47. package/dist/themes/brownbeige.css +1 -1
  48. package/dist/themes/browngreen.css +1 -1
  49. package/dist/themes/desert.css +1 -1
  50. package/dist/themes/forest.css +1 -1
  51. package/dist/themes/highcontrast.css +1 -1
  52. package/dist/themes/legacy.css +1 -1
  53. package/dist/themes/material.css +1 -1
  54. package/dist/themes/ocean.css +1 -1
  55. package/dist/themes/sageivory.css +1 -1
  56. package/dist/themes/spring.css +1 -1
  57. package/dist/themes/summer.css +1 -1
  58. package/dist/themes/sunset.css +1 -1
  59. package/dist/themes/tealcaramel.css +1 -1
  60. package/dist/themes/winter.css +1 -1
  61. package/package.json +1 -1
  62. package/src/styles/components/_navigation-rail.scss +193 -65
@@ -1,10 +1,11 @@
1
1
  import { createComponentConfig } from "../../core/config/component.js";
2
- import { NAVIGATION_RAIL_DEFAULTS as defaults } from "./constants.js";
2
+ import { NAVIGATION_RAIL_DEFAULTS as defaults, NAVIGATION_RAIL_ICONS as icons } from "./constants.js";
3
3
  export const createBaseConfig = (config) => {
4
4
  const result = createComponentConfig({
5
5
  expanded: defaults.EXPANDED, expandedWidth: defaults.EXPANDED_WIDTH,
6
6
  showToggle: defaults.SHOW_TOGGLE, ripple: true, items: [],
7
7
  expandLabel: 'Expand navigation', collapseLabel: 'Collapse navigation',
8
+ expandIcon: icons.EXPAND, collapseIcon: icons.COLLAPSE,
8
9
  }, config, 'navigation-rail');
9
10
  const width = result.expandedWidth;
10
11
  result.expandedWidth = Number.isFinite(width)
@@ -7,3 +7,8 @@ export declare const NAVIGATION_RAIL_DEFAULTS: {
7
7
  readonly MAX_EXPANDED_WIDTH: 360;
8
8
  readonly SHOW_TOGGLE: true;
9
9
  };
10
+ /** Material Symbols `menu` and `menu_open`, the M3 rail menu button in each state. */
11
+ export declare const NAVIGATION_RAIL_ICONS: {
12
+ readonly EXPAND: "<svg viewBox=\"0 -960 960 960\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z\"/></svg>";
13
+ readonly COLLAPSE: "<svg viewBox=\"0 -960 960 960\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M120-240v-80h520v80H120Zm664-40L584-480l200-200 56 56-144 144 144 144-56 56ZM120-440v-80h400v80H120Zm0-200v-80h520v80H120Z\"/></svg>";
14
+ };
@@ -6,3 +6,7 @@ export const NAVIGATION_RAIL_DEFAULTS = {
6
6
  MAX_EXPANDED_WIDTH: 360,
7
7
  SHOW_TOGGLE: true,
8
8
  };
9
+ export const NAVIGATION_RAIL_ICONS = {
10
+ EXPAND: '<svg viewBox="0 -960 960 960" aria-hidden="true" focusable="false"><path d="M120-240v-80h720v80H120Zm0-200v-80h720v80H120Zm0-200v-80h720v80H120Z"/></svg>',
11
+ COLLAPSE: '<svg viewBox="0 -960 960 960" aria-hidden="true" focusable="false"><path d="M120-240v-80h520v80H120Zm664-40L584-480l200-200 56 56-144 144 144 144-56 56ZM120-440v-80h400v80H120Zm0-200v-80h520v80H120Z"/></svg>',
12
+ };
@@ -27,6 +27,19 @@ export default function createNavigationRail(config = {}) {
27
27
  const emitter = createEmitter();
28
28
  let expanded = !!options.expanded;
29
29
  let destroyed = false;
30
+ let switching = null;
31
+ const SWITCH_DURATION = 450;
32
+ const endSwitch = () => {
33
+ if (switching !== null)
34
+ clearTimeout(switching);
35
+ switching = null;
36
+ root.classList.remove(cls('--switching'));
37
+ };
38
+ const startSwitch = () => {
39
+ endSwitch();
40
+ root.classList.add(cls('--switching'));
41
+ switching = setTimeout(endSwitch, SWITCH_DURATION);
42
+ };
30
43
  let connectionObserver = null;
31
44
  const dialog = options.layout === 'modal' ? root : null;
32
45
  if (dialog)
@@ -43,7 +56,6 @@ export default function createNavigationRail(config = {}) {
43
56
  toggle = document.createElement('button');
44
57
  toggle.type = 'button';
45
58
  toggle.className = cls('__toggle');
46
- toggle.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>';
47
59
  header.append(toggle);
48
60
  }
49
61
  if (options.header)
@@ -57,6 +69,7 @@ export default function createNavigationRail(config = {}) {
57
69
  const visible = item.badge !== undefined && item.badge !== false && item.badge !== '';
58
70
  if (!visible) {
59
71
  badge?.remove();
72
+ element.classList.remove(cls('__item--badged'));
60
73
  element.setAttribute('aria-label', item.label);
61
74
  return;
62
75
  }
@@ -68,6 +81,7 @@ export default function createNavigationRail(config = {}) {
68
81
  }
69
82
  badge.classList.toggle(cls('__badge--dot'), item.badge === true);
70
83
  badge.textContent = item.badge === true ? '' : String(item.badge);
84
+ element.classList.toggle(cls('__item--badged'), item.badge !== true);
71
85
  element.setAttribute('aria-label', `${item.label}, ${item.badgeLabel || (item.badge === true ? 'New activity' : String(item.badge))}`);
72
86
  };
73
87
  const updateSelection = () => {
@@ -147,6 +161,8 @@ export default function createNavigationRail(config = {}) {
147
161
  root.classList.toggle(cls('--expanded'), expanded);
148
162
  toggle?.setAttribute('aria-expanded', String(expanded));
149
163
  toggle?.setAttribute('aria-label', (expanded ? options.collapseLabel : options.expandLabel));
164
+ if (toggle)
165
+ toggle.innerHTML = (expanded ? options.collapseIcon : options.expandIcon);
150
166
  if (dialog) {
151
167
  if (expanded)
152
168
  showModal();
@@ -166,6 +182,7 @@ export default function createNavigationRail(config = {}) {
166
182
  if (destroyed || expanded === value)
167
183
  return api;
168
184
  expanded = value;
185
+ startSwitch();
169
186
  synchronize();
170
187
  emitter.emit(value ? 'expand' : 'collapse', { expanded: value });
171
188
  if (!destroyed) {
@@ -264,6 +281,7 @@ export default function createNavigationRail(config = {}) {
264
281
  if (destroyed)
265
282
  return;
266
283
  destroyed = true;
284
+ endSwitch();
267
285
  connectionObserver?.disconnect();
268
286
  connectionObserver = null;
269
287
  dialog?.removeEventListener('keydown', modalTab);
@@ -40,6 +40,10 @@ export interface NavigationRailConfig extends BaseComponentConfig {
40
40
  showToggle?: boolean;
41
41
  expandLabel?: string;
42
42
  collapseLabel?: string;
43
+ /** Menu button icon while collapsed. Default: Material Symbols `menu`. */
44
+ expandIcon?: string;
45
+ /** Menu button icon while expanded. Default: Material Symbols `menu_open`. */
46
+ collapseIcon?: string;
43
47
  /** Optional application-owned header, such as a FAB. Its lifecycle stays with its owner. */
44
48
  header?: HTMLElement;
45
49
  ripple?: boolean;