foundation.d.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**
  2. * @license
  3. * Copyright 2017 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 { MDCDialogAdapter } from './adapter';
  25. import { DialogConfigOptions } from './types';
  26. /** MDC Dialog Foundation */
  27. export declare class MDCDialogFoundation extends MDCFoundation<MDCDialogAdapter> {
  28. static get cssClasses(): {
  29. CLOSING: string;
  30. OPEN: string;
  31. OPENING: string;
  32. SCROLLABLE: string;
  33. SCROLL_LOCK: string;
  34. STACKED: string;
  35. FULLSCREEN: string;
  36. SCROLL_DIVIDER_HEADER: string;
  37. SCROLL_DIVIDER_FOOTER: string;
  38. SURFACE_SCRIM_SHOWN: string;
  39. SURFACE_SCRIM_SHOWING: string;
  40. SURFACE_SCRIM_HIDING: string;
  41. SCRIM_HIDDEN: string;
  42. };
  43. static get strings(): {
  44. ACTION_ATTRIBUTE: string;
  45. BUTTON_DEFAULT_ATTRIBUTE: string;
  46. BUTTON_SELECTOR: string;
  47. CLOSED_EVENT: string;
  48. CLOSE_ACTION: string;
  49. CLOSING_EVENT: string;
  50. CONTAINER_SELECTOR: string;
  51. CONTENT_SELECTOR: string;
  52. DESTROY_ACTION: string;
  53. INITIAL_FOCUS_ATTRIBUTE: string;
  54. OPENED_EVENT: string;
  55. OPENING_EVENT: string;
  56. SCRIM_SELECTOR: string;
  57. SUPPRESS_DEFAULT_PRESS_SELECTOR: string;
  58. SURFACE_SELECTOR: string;
  59. };
  60. static get numbers(): {
  61. DIALOG_ANIMATION_CLOSE_TIME_MS: number;
  62. DIALOG_ANIMATION_OPEN_TIME_MS: number;
  63. };
  64. static get defaultAdapter(): MDCDialogAdapter;
  65. private dialogOpen;
  66. private isFullscreen;
  67. private animationFrame;
  68. private animationTimer;
  69. private escapeKeyAction;
  70. private scrimClickAction;
  71. private autoStackButtons;
  72. private areButtonsStacked;
  73. private suppressDefaultPressSelector;
  74. private readonly contentScrollHandler;
  75. private readonly animFrame;
  76. private readonly windowResizeHandler;
  77. private readonly windowOrientationChangeHandler;
  78. constructor(adapter?: Partial<MDCDialogAdapter>);
  79. init(): void;
  80. destroy(): void;
  81. open(dialogOptions?: DialogConfigOptions): void;
  82. close(action?: string): void;
  83. /**
  84. * Used only in instances of showing a secondary dialog over a full-screen
  85. * dialog. Shows the "surface scrim" displayed over the full-screen dialog.
  86. */
  87. showSurfaceScrim(): void;
  88. /**
  89. * Used only in instances of showing a secondary dialog over a full-screen
  90. * dialog. Hides the "surface scrim" displayed over the full-screen dialog.
  91. */
  92. hideSurfaceScrim(): void;
  93. /**
  94. * Handles `transitionend` event triggered when surface scrim animation is
  95. * finished.
  96. */
  97. handleSurfaceScrimTransitionEnd(): void;
  98. isOpen(): boolean;
  99. getEscapeKeyAction(): string;
  100. setEscapeKeyAction(action: string): void;
  101. getScrimClickAction(): string;
  102. setScrimClickAction(action: string): void;
  103. getAutoStackButtons(): boolean;
  104. setAutoStackButtons(autoStack: boolean): void;
  105. getSuppressDefaultPressSelector(): string;
  106. setSuppressDefaultPressSelector(selector: string): void;
  107. layout(): void;
  108. /** Handles click on the dialog root element. */
  109. handleClick(evt: MouseEvent): void;
  110. /** Handles keydown on the dialog root element. */
  111. handleKeydown(evt: KeyboardEvent): void;
  112. /** Handles keydown on the document. */
  113. handleDocumentKeydown(evt: KeyboardEvent): void;
  114. /**
  115. * Handles scroll event on the dialog's content element -- showing a scroll
  116. * divider on the header or footer based on the scroll position. This handler
  117. * should only be registered on full-screen dialogs with scrollable content.
  118. */
  119. private handleScrollEvent;
  120. private layoutInternal;
  121. private handleAnimationTimerEnd;
  122. /**
  123. * Runs the given logic on the next animation frame, using setTimeout to
  124. * factor in Firefox reflow behavior.
  125. */
  126. private runNextAnimationFrame;
  127. private detectStackedButtons;
  128. private toggleScrollableClasses;
  129. private toggleScrollDividerHeader;
  130. private toggleScrollDividerFooter;
  131. }
  132. export default MDCDialogFoundation;