foundation.d.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /**
  2. * @license
  3. * Copyright 2016 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 { MDCSelectAdapter } from './adapter';
  25. import { MDCSelectFoundationMap } from './types';
  26. /** MDC Select Foundation */
  27. export declare class MDCSelectFoundation extends MDCFoundation<MDCSelectAdapter> {
  28. static get cssClasses(): {
  29. ACTIVATED: string;
  30. DISABLED: string;
  31. FOCUSED: string;
  32. INVALID: string;
  33. MENU_INVALID: string;
  34. OUTLINED: string;
  35. REQUIRED: string;
  36. ROOT: string;
  37. WITH_LEADING_ICON: string;
  38. };
  39. static get numbers(): {
  40. LABEL_SCALE: number;
  41. UNSET_INDEX: number;
  42. CLICK_DEBOUNCE_TIMEOUT_MS: number;
  43. };
  44. static get strings(): {
  45. ARIA_CONTROLS: string;
  46. ARIA_DESCRIBEDBY: string;
  47. ARIA_SELECTED_ATTR: string;
  48. CHANGE_EVENT: string;
  49. HIDDEN_INPUT_SELECTOR: string;
  50. LABEL_SELECTOR: string;
  51. LEADING_ICON_SELECTOR: string;
  52. LINE_RIPPLE_SELECTOR: string;
  53. MENU_SELECTOR: string; /**
  54. * See {@link MDCSelectAdapter} for typing information on parameters and
  55. * return types.
  56. */
  57. OUTLINE_SELECTOR: string;
  58. SELECTED_TEXT_SELECTOR: string;
  59. SELECT_ANCHOR_SELECTOR: string;
  60. VALUE_ATTR: string;
  61. };
  62. /**
  63. * See {@link MDCSelectAdapter} for typing information on parameters and
  64. * return types.
  65. */
  66. static get defaultAdapter(): MDCSelectAdapter;
  67. private readonly leadingIcon;
  68. private readonly helperText;
  69. private readonly ariaDescribedbyIds;
  70. private disabled;
  71. private isMenuOpen;
  72. private useDefaultValidation;
  73. private customValidity;
  74. private lastSelectedIndex;
  75. private clickDebounceTimeout;
  76. private recentlyClicked;
  77. /**
  78. * @param adapter
  79. * @param foundationMap Map from subcomponent names to their subfoundations.
  80. */
  81. constructor(adapter?: Partial<MDCSelectAdapter>, foundationMap?: Partial<MDCSelectFoundationMap>);
  82. /** Returns the index of the currently selected menu item, or -1 if none. */
  83. getSelectedIndex(): number;
  84. setSelectedIndex(index: number, closeMenu?: boolean, skipNotify?: boolean): void;
  85. setValue(value: string, skipNotify?: boolean): void;
  86. getValue(): string;
  87. getDisabled(): boolean;
  88. setDisabled(isDisabled: boolean): void;
  89. /** Opens the menu. */
  90. openMenu(): void;
  91. /**
  92. * @param content Sets the content of the helper text.
  93. */
  94. setHelperTextContent(content: string): void;
  95. /**
  96. * Re-calculates if the notched outline should be notched and if the label
  97. * should float.
  98. */
  99. layout(): void;
  100. /**
  101. * Synchronizes the list of options with the state of the foundation. Call
  102. * this whenever menu options are dynamically updated.
  103. */
  104. layoutOptions(): void;
  105. handleMenuOpened(): void;
  106. handleMenuClosing(): void;
  107. handleMenuClosed(): void;
  108. /**
  109. * Handles value changes, via change event or programmatic updates.
  110. */
  111. handleChange(): void;
  112. handleMenuItemAction(index: number): void;
  113. /**
  114. * Handles focus events from select element.
  115. */
  116. handleFocus(): void;
  117. /**
  118. * Handles blur events from select element.
  119. */
  120. handleBlur(): void;
  121. handleClick(normalizedX: number): void;
  122. /**
  123. * Handles keydown events on select element. Depending on the type of
  124. * character typed, does typeahead matching or opens menu.
  125. */
  126. handleKeydown(event: KeyboardEvent): void;
  127. /**
  128. * Opens/closes the notched outline.
  129. */
  130. notchOutline(openNotch: boolean): void;
  131. /**
  132. * Sets the aria label of the leading icon.
  133. */
  134. setLeadingIconAriaLabel(label: string): void;
  135. /**
  136. * Sets the text content of the leading icon.
  137. */
  138. setLeadingIconContent(content: string): void;
  139. getUseDefaultValidation(): boolean;
  140. setUseDefaultValidation(useDefaultValidation: boolean): void;
  141. setValid(isValid: boolean): void;
  142. isValid(): boolean;
  143. setRequired(isRequired: boolean): void;
  144. getRequired(): boolean;
  145. init(): void;
  146. /**
  147. * Unfocuses the select component.
  148. */
  149. private blur;
  150. private syncHelperTextValidity;
  151. private setClickDebounceTimeout;
  152. }
  153. export default MDCSelectFoundation;