line-Bm3zUbBF.mjs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import * as i0 from '@angular/core';
  2. import { Directive, NgModule } from '@angular/core';
  3. import { startWith } from 'rxjs/operators';
  4. import { M as MatCommonModule } from './common-module-WayjW0Pb.mjs';
  5. /**
  6. * Shared directive to count lines inside a text area, such as a list item.
  7. * Line elements can be extracted with a @ContentChildren(MatLine) query, then
  8. * counted by checking the query list's length.
  9. */
  10. class MatLine {
  11. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatLine, deps: [], target: i0.ɵɵFactoryTarget.Directive });
  12. static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.6", type: MatLine, isStandalone: true, selector: "[mat-line], [matLine]", host: { classAttribute: "mat-line" }, ngImport: i0 });
  13. }
  14. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatLine, decorators: [{
  15. type: Directive,
  16. args: [{
  17. selector: '[mat-line], [matLine]',
  18. host: { 'class': 'mat-line' },
  19. }]
  20. }] });
  21. /**
  22. * Helper that takes a query list of lines and sets the correct class on the host.
  23. * @docs-private
  24. */
  25. function setLines(lines, element, prefix = 'mat') {
  26. // Note: doesn't need to unsubscribe, because `changes`
  27. // gets completed by Angular when the view is destroyed.
  28. lines.changes.pipe(startWith(lines)).subscribe(({ length }) => {
  29. setClass(element, `${prefix}-2-line`, false);
  30. setClass(element, `${prefix}-3-line`, false);
  31. setClass(element, `${prefix}-multi-line`, false);
  32. if (length === 2 || length === 3) {
  33. setClass(element, `${prefix}-${length}-line`, true);
  34. }
  35. else if (length > 3) {
  36. setClass(element, `${prefix}-multi-line`, true);
  37. }
  38. });
  39. }
  40. /** Adds or removes a class from an element. */
  41. function setClass(element, className, isAdd) {
  42. element.nativeElement.classList.toggle(className, isAdd);
  43. }
  44. class MatLineModule {
  45. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatLineModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  46. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.6", ngImport: i0, type: MatLineModule, imports: [MatCommonModule, MatLine], exports: [MatLine, MatCommonModule] });
  47. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatLineModule, imports: [MatCommonModule, MatCommonModule] });
  48. }
  49. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.6", ngImport: i0, type: MatLineModule, decorators: [{
  50. type: NgModule,
  51. args: [{
  52. imports: [MatCommonModule, MatLine],
  53. exports: [MatLine, MatCommonModule],
  54. }]
  55. }] });
  56. export { MatLine as M, MatLineModule as a, setLines as s };
  57. //# sourceMappingURL=line-Bm3zUbBF.mjs.map