component.d.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 { MDCNotchedOutlineFactory } from '@material/notched-outline/component';
  27. import { MDCRipple, MDCRippleFactory } from '@material/ripple/component';
  28. import { MDCRippleCapableSurface } from '@material/ripple/types';
  29. import { MDCTextFieldCharacterCounterFactory } from './character-counter/component';
  30. import { MDCTextFieldFoundation } from './foundation';
  31. import { MDCTextFieldHelperTextFactory } from './helper-text/component';
  32. import { MDCTextFieldIconFactory } from './icon/component';
  33. /** MDC Text Field */
  34. export declare class MDCTextField extends MDCComponent<MDCTextFieldFoundation> implements MDCRippleCapableSurface {
  35. static attachTo(root: HTMLElement): MDCTextField;
  36. ripple: MDCRipple | null;
  37. private input;
  38. private characterCounter;
  39. private helperText;
  40. private label;
  41. private leadingIcon;
  42. private lineRipple;
  43. private outline;
  44. private trailingIcon;
  45. private prefix;
  46. private suffix;
  47. initialize(rippleFactory?: MDCRippleFactory, lineRippleFactory?: MDCLineRippleFactory, helperTextFactory?: MDCTextFieldHelperTextFactory, characterCounterFactory?: MDCTextFieldCharacterCounterFactory, iconFactory?: MDCTextFieldIconFactory, labelFactory?: MDCFloatingLabelFactory, outlineFactory?: MDCNotchedOutlineFactory): void;
  48. destroy(): void;
  49. /**
  50. * Initializes the Text Field's internal state based on the environment's
  51. * state.
  52. */
  53. initialSyncWithDOM(): void;
  54. get value(): string;
  55. /**
  56. * @param value The value to set on the input.
  57. */
  58. set value(value: string);
  59. get disabled(): boolean;
  60. /**
  61. * @param disabled Sets the Text Field disabled or enabled.
  62. */
  63. set disabled(disabled: boolean);
  64. get valid(): boolean;
  65. /**
  66. * @param valid Sets the Text Field valid or invalid.
  67. */
  68. set valid(valid: boolean);
  69. get required(): boolean;
  70. /**
  71. * @param required Sets the Text Field to required.
  72. */
  73. set required(required: boolean);
  74. get pattern(): string;
  75. /**
  76. * @param pattern Sets the input element's validation pattern.
  77. */
  78. set pattern(pattern: string);
  79. get minLength(): number;
  80. /**
  81. * @param minLength Sets the input element's minLength.
  82. */
  83. set minLength(minLength: number);
  84. get maxLength(): number;
  85. /**
  86. * @param maxLength Sets the input element's maxLength.
  87. */
  88. set maxLength(maxLength: number);
  89. get min(): string;
  90. /**
  91. * @param min Sets the input element's min.
  92. */
  93. set min(min: string);
  94. get max(): string;
  95. /**
  96. * @param max Sets the input element's max.
  97. */
  98. set max(max: string);
  99. get step(): string;
  100. /**
  101. * @param step Sets the input element's step.
  102. */
  103. set step(step: string);
  104. /**
  105. * Sets the helper text element content.
  106. */
  107. set helperTextContent(content: string);
  108. /**
  109. * Sets the aria label of the leading icon.
  110. */
  111. set leadingIconAriaLabel(label: string);
  112. /**
  113. * Sets the text content of the leading icon.
  114. */
  115. set leadingIconContent(content: string);
  116. /**
  117. * Sets the aria label of the trailing icon.
  118. */
  119. set trailingIconAriaLabel(label: string);
  120. /**
  121. * Sets the text content of the trailing icon.
  122. */
  123. set trailingIconContent(content: string);
  124. /**
  125. * Enables or disables the use of native validation. Use this for custom
  126. * validation.
  127. * @param useNativeValidation Set this to false to ignore native input
  128. * validation.
  129. */
  130. set useNativeValidation(useNativeValidation: boolean);
  131. /**
  132. * Gets the text content of the prefix, or null if it does not exist.
  133. */
  134. get prefixText(): string | null;
  135. /**
  136. * Sets the text content of the prefix, if it exists.
  137. */
  138. set prefixText(prefixText: string | null);
  139. /**
  140. * Gets the text content of the suffix, or null if it does not exist.
  141. */
  142. get suffixText(): string | null;
  143. /**
  144. * Sets the text content of the suffix, if it exists.
  145. */
  146. set suffixText(suffixText: string | null);
  147. /**
  148. * Focuses the input element.
  149. */
  150. focus(): void;
  151. /**
  152. * Recomputes the outline SVG path for the outline element.
  153. */
  154. layout(): void;
  155. getDefaultFoundation(): MDCTextFieldFoundation;
  156. private getRootAdapterMethods;
  157. private getInputAdapterMethods;
  158. private getLabelAdapterMethods;
  159. private getLineRippleAdapterMethods;
  160. private getOutlineAdapterMethods;
  161. /**
  162. * @return A map of all subcomponents to subfoundations.
  163. */
  164. private getFoundationMap;
  165. private createRipple;
  166. }