legacy-input.mjs 6.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import * as i0 from '@angular/core';
  2. import { inject, Directive, NgModule } from '@angular/core';
  3. import { MatInput } from '@angular/material/input';
  4. export { MAT_INPUT_VALUE_ACCESSOR as MAT_LEGACY_INPUT_VALUE_ACCESSOR, getMatInputUnsupportedTypeError as getMatLegacyInputUnsupportedTypeError } from '@angular/material/input';
  5. import { MAT_LEGACY_FORM_FIELD, MatLegacyFormFieldControl, MatLegacyFormFieldModule } from '@angular/material/legacy-form-field';
  6. import { TextFieldModule } from '@angular/cdk/text-field';
  7. import { MatCommonModule, ErrorStateMatcher } from '@angular/material/core';
  8. /**
  9. * Directive that allows a native input to work inside a `MatFormField`.
  10. * @deprecated Use `MatInput` from `@angular/material/input` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
  11. * @breaking-change 17.0.0
  12. */
  13. class MatLegacyInput extends MatInput {
  14. constructor() {
  15. super(...arguments);
  16. this._legacyFormField = inject(MAT_LEGACY_FORM_FIELD, { optional: true });
  17. }
  18. _getPlaceholder() {
  19. // If we're hiding the native placeholder, it should also be cleared from the DOM, otherwise
  20. // screen readers will read it out twice: once from the label and once from the attribute.
  21. // TODO: can be removed once we get rid of the `legacy` style for the form field, because it's
  22. // the only one that supports promoting the placeholder to a label.
  23. const formField = this._legacyFormField;
  24. return formField && formField.appearance === 'legacy' && !formField._hasLabel?.()
  25. ? null
  26. : this.placeholder;
  27. }
  28. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatLegacyInput, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
  29. static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.0.0", type: MatLegacyInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],\n input[matNativeControl], textarea[matNativeControl]", host: { properties: { "class.mat-input-server": "_isServer", "class.mat-mdc-input-element": "false", "class.mat-mdc-form-field-textarea-control": "false", "class.mat-mdc-form-field-input-control": "false", "class.mdc-text-field__input": "false", "class.mat-mdc-native-select-inline": "false", "attr.data-placeholder": "placeholder", "class.mat-native-select-inline": "_isInlineSelect()" }, classAttribute: "mat-input-element mat-form-field-autofill-control" }, providers: [{ provide: MatLegacyFormFieldControl, useExisting: MatLegacyInput }], exportAs: ["matInput"], usesInheritance: true, ngImport: i0 }); }
  30. }
  31. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatLegacyInput, decorators: [{
  32. type: Directive,
  33. args: [{
  34. selector: `input[matInput], textarea[matInput], select[matNativeControl],
  35. input[matNativeControl], textarea[matNativeControl]`,
  36. exportAs: 'matInput',
  37. host: {
  38. /**
  39. * @breaking-change 8.0.0 remove .mat-form-field-autofill-control in favor of AutofillMonitor.
  40. */
  41. 'class': 'mat-input-element mat-form-field-autofill-control',
  42. '[class.mat-input-server]': '_isServer',
  43. // These classes are inherited from the base input class and need to be cleared.
  44. '[class.mat-mdc-input-element]': 'false',
  45. '[class.mat-mdc-form-field-textarea-control]': 'false',
  46. '[class.mat-mdc-form-field-input-control]': 'false',
  47. '[class.mdc-text-field__input]': 'false',
  48. '[class.mat-mdc-native-select-inline]': 'false',
  49. // At the time of writing, we have a lot of customer tests that look up the input based on its
  50. // placeholder. Since we sometimes omit the placeholder attribute from the DOM to prevent screen
  51. // readers from reading it twice, we have to keep it somewhere in the DOM for the lookup.
  52. '[attr.data-placeholder]': 'placeholder',
  53. '[class.mat-native-select-inline]': '_isInlineSelect()',
  54. },
  55. providers: [{ provide: MatLegacyFormFieldControl, useExisting: MatLegacyInput }],
  56. }]
  57. }] });
  58. /**
  59. * @deprecated Use `MatInputModule` from `@angular/material/input` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
  60. * @breaking-change 17.0.0
  61. */
  62. class MatLegacyInputModule {
  63. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatLegacyInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
  64. static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: MatLegacyInputModule, declarations: [MatLegacyInput], imports: [TextFieldModule, MatLegacyFormFieldModule, MatCommonModule], exports: [TextFieldModule,
  65. // We re-export the `MatLegacyFormFieldModule` since `MatLegacyInput` will almost always
  66. // be used together with `MatLegacyFormField`.
  67. MatLegacyFormFieldModule,
  68. MatLegacyInput] }); }
  69. static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatLegacyInputModule, providers: [ErrorStateMatcher], imports: [TextFieldModule, MatLegacyFormFieldModule, MatCommonModule, TextFieldModule,
  70. // We re-export the `MatLegacyFormFieldModule` since `MatLegacyInput` will almost always
  71. // be used together with `MatLegacyFormField`.
  72. MatLegacyFormFieldModule] }); }
  73. }
  74. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatLegacyInputModule, decorators: [{
  75. type: NgModule,
  76. args: [{
  77. declarations: [MatLegacyInput],
  78. imports: [TextFieldModule, MatLegacyFormFieldModule, MatCommonModule],
  79. exports: [
  80. TextFieldModule,
  81. // We re-export the `MatLegacyFormFieldModule` since `MatLegacyInput` will almost always
  82. // be used together with `MatLegacyFormField`.
  83. MatLegacyFormFieldModule,
  84. MatLegacyInput,
  85. ],
  86. providers: [ErrorStateMatcher],
  87. }]
  88. }] });
  89. /**
  90. * Generated bundle index. Do not edit.
  91. */
  92. export { MatLegacyInput, MatLegacyInputModule };
  93. //# sourceMappingURL=legacy-input.mjs.map