foundation.d.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @license
  3. * Copyright 2018 Google Inc.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. import { MDCFoundation } from '@material/base/foundation';
  24. import { MDCMenuAdapter } from './adapter';
  25. import { DefaultFocusState } from './constants';
  26. /** MDC Menu Foundation */
  27. export declare class MDCMenuFoundation extends MDCFoundation<MDCMenuAdapter> {
  28. static get cssClasses(): {
  29. MENU_SELECTED_LIST_ITEM: string;
  30. MENU_SELECTION_GROUP: string;
  31. ROOT: string;
  32. };
  33. static get strings(): {
  34. ARIA_CHECKED_ATTR: string;
  35. ARIA_DISABLED_ATTR: string;
  36. CHECKBOX_SELECTOR: string;
  37. LIST_SELECTOR: string;
  38. SELECTED_EVENT: string;
  39. SKIP_RESTORE_FOCUS: string;
  40. };
  41. static get numbers(): {
  42. FOCUS_ROOT_INDEX: number;
  43. };
  44. private defaultFocusState;
  45. private selectedIndex;
  46. /**
  47. * @see {@link MDCMenuAdapter} for typing information on parameters and return types.
  48. */
  49. static get defaultAdapter(): MDCMenuAdapter;
  50. constructor(adapter?: Partial<MDCMenuAdapter>);
  51. destroy(): void;
  52. handleKeydown(evt: KeyboardEvent): void;
  53. handleItemAction(listItem: HTMLElement): void;
  54. handleMenuSurfaceOpened(): void;
  55. /**
  56. * Sets default focus state where the menu should focus every time when menu
  57. * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
  58. * default.
  59. */
  60. setDefaultFocusState(focusState: DefaultFocusState): void;
  61. /** @return Index of the currently selected list item within the menu. */
  62. getSelectedIndex(): number;
  63. /**
  64. * Selects the list item at `index` within the menu.
  65. * @param index Index of list item within the menu.
  66. */
  67. setSelectedIndex(index: number): void;
  68. /**
  69. * Sets the enabled state to isEnabled for the menu item at the given index.
  70. * @param index Index of the menu item
  71. * @param isEnabled The desired enabled state of the menu item.
  72. */
  73. setEnabled(index: number, isEnabled: boolean): void;
  74. private validatedIndex;
  75. }
  76. export default MDCMenuFoundation;