adapter.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 { MDCTabDimensions } from '@material/tab/types';
  24. /**
  25. * Defines the shape of the adapter expected by the foundation.
  26. * Implement this adapter for your framework of choice to delegate updates to
  27. * the component in your framework of choice. See architecture documentation
  28. * for more details.
  29. * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
  30. */
  31. export interface MDCTabBarAdapter {
  32. /**
  33. * Scrolls to the given position
  34. * @param scrollX The position to scroll to
  35. */
  36. scrollTo(scrollX: number): void;
  37. /**
  38. * Increments the current scroll position by the given amount
  39. * @param scrollXIncrement The amount to increment scroll
  40. */
  41. incrementScroll(scrollXIncrement: number): void;
  42. /**
  43. * Returns the current scroll position
  44. */
  45. getScrollPosition(): number;
  46. /**
  47. * Returns the width of the scroll content
  48. */
  49. getScrollContentWidth(): number;
  50. /**
  51. * Returns the root element's offsetWidth
  52. */
  53. getOffsetWidth(): number;
  54. /**
  55. * Returns if the Tab Bar language direction is RTL
  56. */
  57. isRTL(): boolean;
  58. /**
  59. * Sets the tab at the given index to be activated
  60. * @param index The index of the tab to activate
  61. */
  62. setActiveTab(index: number): void;
  63. /**
  64. * Activates the tab at the given index with the given client rect
  65. * @param index The index of the tab to activate
  66. * @param clientRect The client rect of the previously active Tab Indicator
  67. */
  68. activateTabAtIndex(index: number, clientRect?: DOMRect): void;
  69. /**
  70. * Deactivates the tab at the given index
  71. * @param index The index of the tab to deactivate
  72. */
  73. deactivateTabAtIndex(index: number): void;
  74. /**
  75. * Focuses the tab at the given index
  76. * @param index The index of the tab to focus
  77. */
  78. focusTabAtIndex(index: number): void;
  79. /**
  80. * Returns the client rect of the tab's indicator
  81. * @param index The index of the tab
  82. */
  83. getTabIndicatorClientRectAtIndex(index: number): DOMRect;
  84. /**
  85. * Returns the tab dimensions of the tab at the given index
  86. * @param index The index of the tab
  87. */
  88. getTabDimensionsAtIndex(index: number): MDCTabDimensions;
  89. /**
  90. * Returns the length of the tab list
  91. */
  92. getTabListLength(): number;
  93. /**
  94. * Returns the index of the previously active tab
  95. */
  96. getPreviousActiveTabIndex(): number;
  97. /**
  98. * Returns the index of the focused tab
  99. */
  100. getFocusedTabIndex(): number;
  101. /**
  102. * Returns the index of the given tab
  103. * @param id The ID of the tab whose index to determine
  104. */
  105. getIndexOfTabById(id: string): number;
  106. /**
  107. * Emits the MDCTabBar:activated event
  108. * @param index The index of the activated tab
  109. */
  110. notifyTabActivated(index: number): void;
  111. }