component.d.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 { MDCComponent } from '@material/base/component';
  24. import { MDCFloatingLabelFactory } from '@material/floating-label/component';
  25. import { MDCLineRippleFactory } from '@material/line-ripple/component';
  26. import { MDCMenuFactory } from '@material/menu/component';
  27. import { MDCNotchedOutlineFactory } from '@material/notched-outline/component';
  28. import { MDCSelectFoundation } from './foundation';
  29. import { MDCSelectHelperTextFactory } from './helper-text/component';
  30. import { MDCSelectIconFactory } from './icon/component';
  31. /** MDC Select */
  32. export declare class MDCSelect extends MDCComponent<MDCSelectFoundation> {
  33. static attachTo(root: HTMLElement): MDCSelect;
  34. private ripple;
  35. private menu;
  36. private selectAnchor;
  37. private selectedText;
  38. private hiddenInput;
  39. private menuElement;
  40. private menuItemValues;
  41. private leadingIcon?;
  42. private helperText;
  43. private lineRipple;
  44. private label;
  45. private outline;
  46. private handleFocus;
  47. private handleBlur;
  48. private handleClick;
  49. private handleKeydown;
  50. private handleMenuOpened;
  51. private handleMenuClosed;
  52. private handleMenuClosing;
  53. private handleMenuItemAction;
  54. initialize(labelFactory?: MDCFloatingLabelFactory, lineRippleFactory?: MDCLineRippleFactory, outlineFactory?: MDCNotchedOutlineFactory, menuFactory?: MDCMenuFactory, iconFactory?: MDCSelectIconFactory, helperTextFactory?: MDCSelectHelperTextFactory): void;
  55. /**
  56. * Initializes the select's event listeners and internal state based
  57. * on the environment's state.
  58. */
  59. initialSyncWithDOM(): void;
  60. destroy(): void;
  61. get value(): string;
  62. set value(value: string);
  63. setValue(value: string, skipNotify?: boolean): void;
  64. get selectedIndex(): number;
  65. set selectedIndex(selectedIndex: number);
  66. setSelectedIndex(selectedIndex: number, skipNotify?: boolean): void;
  67. get disabled(): boolean;
  68. set disabled(disabled: boolean);
  69. set leadingIconAriaLabel(label: string);
  70. /**
  71. * Sets the text content of the leading icon.
  72. */
  73. set leadingIconContent(content: string);
  74. /**
  75. * Sets the text content of the helper text.
  76. */
  77. set helperTextContent(content: string);
  78. /**
  79. * Enables or disables the default validation scheme where a required select
  80. * must be non-empty. Set to false for custom validation.
  81. * @param useDefaultValidation Set this to false to ignore default
  82. * validation scheme.
  83. */
  84. set useDefaultValidation(useDefaultValidation: boolean);
  85. /**
  86. * Sets the current invalid state of the select.
  87. */
  88. set valid(isValid: boolean);
  89. /**
  90. * Checks if the select is in a valid state.
  91. */
  92. get valid(): boolean;
  93. /**
  94. * Sets the control to the required state.
  95. */
  96. set required(isRequired: boolean);
  97. /**
  98. * Returns whether the select is required.
  99. */
  100. get required(): boolean;
  101. /**
  102. * Re-calculates if the notched outline should be notched and if the label
  103. * should float.
  104. */
  105. layout(): void;
  106. /**
  107. * Synchronizes the list of options with the state of the foundation. Call
  108. * this whenever menu options are dynamically updated.
  109. */
  110. layoutOptions(): void;
  111. getDefaultFoundation(): MDCSelectFoundation;
  112. /**
  113. * Handles setup for the menu.
  114. */
  115. private menuSetup;
  116. private createRipple;
  117. private getSelectAdapterMethods;
  118. private getCommonAdapterMethods;
  119. private getOutlineAdapterMethods;
  120. private getLabelAdapterMethods;
  121. /**
  122. * Calculates where the line ripple should start based on the x coordinate
  123. * within the component.
  124. */
  125. private getNormalizedXCoordinate;
  126. private isTouchEvent;
  127. /**
  128. * Returns a map of all subcomponents to subfoundations.
  129. */
  130. private getFoundationMap;
  131. }