foundation.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 { MDCTabInteractionEvent } from '@material/tab/types';
  25. import { MDCTabBarAdapter } from './adapter';
  26. /** MDC Tab Bar Foundation */
  27. export declare class MDCTabBarFoundation extends MDCFoundation<MDCTabBarAdapter> {
  28. static get strings(): {
  29. ARROW_LEFT_KEY: string;
  30. ARROW_RIGHT_KEY: string;
  31. END_KEY: string;
  32. ENTER_KEY: string;
  33. HOME_KEY: string;
  34. SPACE_KEY: string;
  35. TAB_ACTIVATED_EVENT: string;
  36. TAB_SCROLLER_SELECTOR: string;
  37. TAB_SELECTOR: string;
  38. };
  39. static get numbers(): {
  40. ARROW_LEFT_KEYCODE: number;
  41. ARROW_RIGHT_KEYCODE: number;
  42. END_KEYCODE: number;
  43. ENTER_KEYCODE: number;
  44. EXTRA_SCROLL_AMOUNT: number;
  45. HOME_KEYCODE: number;
  46. SPACE_KEYCODE: number;
  47. };
  48. static get defaultAdapter(): MDCTabBarAdapter;
  49. private useAutomaticActivation;
  50. constructor(adapter?: Partial<MDCTabBarAdapter>);
  51. /**
  52. * Switches between automatic and manual activation modes.
  53. * See https://www.w3.org/TR/wai-aria-practices/#tabpanel for examples.
  54. */
  55. setUseAutomaticActivation(useAutomaticActivation: boolean): void;
  56. activateTab(index: number): void;
  57. handleKeyDown(evt: KeyboardEvent): void;
  58. /**
  59. * Handles the MDCTab:interacted event
  60. */
  61. handleTabInteraction(evt: MDCTabInteractionEvent): void;
  62. /**
  63. * Scrolls the tab at the given index into view
  64. * @param index The tab index to make visible
  65. */
  66. scrollIntoView(index: number): void;
  67. /**
  68. * Private method for determining the index of the destination tab based on
  69. * what key was pressed
  70. * @param origin The original index from which to determine the destination
  71. * @param key The name of the key
  72. */
  73. private determineTargetFromKey;
  74. /**
  75. * Calculates the scroll increment that will make the tab at the given index
  76. * visible
  77. * @param index The index of the tab
  78. * @param nextIndex The index of the next tab
  79. * @param scrollPosition The current scroll position
  80. * @param barWidth The width of the Tab Bar
  81. */
  82. private calculateScrollIncrement;
  83. /**
  84. * Calculates the scroll increment that will make the tab at the given index
  85. * visible in RTL
  86. * @param index The index of the tab
  87. * @param nextIndex The index of the next tab
  88. * @param scrollPosition The current scroll position
  89. * @param barWidth The width of the Tab Bar
  90. * @param scrollContentWidth The width of the scroll content
  91. */
  92. private calculateScrollIncrementRTL;
  93. /**
  94. * Determines the index of the adjacent tab closest to either edge of the Tab
  95. * Bar
  96. * @param index The index of the tab
  97. * @param tabDimensions The dimensions of the tab
  98. * @param scrollPosition The current scroll position
  99. * @param barWidth The width of the tab bar
  100. */
  101. private findAdjacentTabIndexClosestToEdge;
  102. /**
  103. * Determines the index of the adjacent tab closest to either edge of the Tab
  104. * Bar in RTL
  105. * @param index The index of the tab
  106. * @param tabDimensions The dimensions of the tab
  107. * @param scrollPosition The current scroll position
  108. * @param barWidth The width of the tab bar
  109. * @param scrollContentWidth The width of the scroller content
  110. */
  111. private findAdjacentTabIndexClosestToEdgeRTL;
  112. /**
  113. * Returns the key associated with a keydown event
  114. * @param evt The keydown event
  115. */
  116. private getKeyFromEvent;
  117. private isActivationKey;
  118. /**
  119. * Returns whether a given index is inclusively between the ends
  120. * @param index The index to test
  121. */
  122. private indexIsInRange;
  123. /**
  124. * Returns the view's RTL property
  125. */
  126. private isRTL;
  127. /**
  128. * Scrolls the tab at the given index into view for left-to-right user agents.
  129. * @param index The index of the tab to scroll into view
  130. */
  131. private scrollIntoViewImpl;
  132. /**
  133. * Scrolls the tab at the given index into view in RTL
  134. * @param index The tab index to make visible
  135. */
  136. private scrollIntoViewImplRTL;
  137. }
  138. export default MDCTabBarFoundation;