adapter.d.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. /**
  24. * Defines the shape of the adapter expected by the foundation.
  25. * Implement this adapter for your framework of choice to delegate updates to
  26. * the component in your framework of choice. See architecture documentation
  27. * for more details.
  28. * https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md
  29. */
  30. export interface MDCTabAdapter {
  31. /**
  32. * Adds the given className to the root element.
  33. * @param className The className to add
  34. */
  35. addClass(className: string): void;
  36. /**
  37. * Removes the given className from the root element.
  38. * @param className The className to remove
  39. */
  40. removeClass(className: string): void;
  41. /**
  42. * Returns whether the root element has the given className.
  43. * @param className The className to remove
  44. */
  45. hasClass(className: string): boolean;
  46. /**
  47. * Sets the given attrName of the root element to the given value.
  48. * @param attr The attribute name to set
  49. * @param value The value so give the attribute
  50. */
  51. setAttr(attr: string, value: string): void;
  52. /**
  53. * Activates the indicator element.
  54. * @param previousIndicatorClientRect The client rect of the previously
  55. * activated indicator
  56. */
  57. activateIndicator(previousIndicatorClientRect?: DOMRect): void;
  58. /** Deactivates the indicator. */
  59. deactivateIndicator(): void;
  60. /**
  61. * Emits the MDCTab:interacted event for use by parent components
  62. */
  63. notifyInteracted(): void;
  64. /**
  65. * Returns the offsetLeft value of the root element.
  66. */
  67. getOffsetLeft(): number;
  68. /**
  69. * Returns the offsetWidth value of the root element.
  70. */
  71. getOffsetWidth(): number;
  72. /**
  73. * Returns the offsetLeft of the content element.
  74. */
  75. getContentOffsetLeft(): number;
  76. /**
  77. * Returns the offsetWidth of the content element.
  78. */
  79. getContentOffsetWidth(): number;
  80. /**
  81. * Applies focus to the root element
  82. */
  83. focus(): void;
  84. /**
  85. * Returns whether the root element is focused.
  86. */
  87. isFocused(): boolean;
  88. }