### File

`src/lib/table-filter/filter-header-row.directive.ts`

### Extends

`FormDirective`

### Implements

`OnInit` `OnDestroy`

### Metadata

Providers | `{ provide: ControlContainer, useExisting: forwardRef(() => FilterHeaderRowDirective), }`
Selector | `table[rxap-filter-header-row]`
Standalone | `true`

### Index

###### Inputs
rxap-filter-header-row
###### Accessors
useFormDefinition

### Constructor

`constructor(tableFilter: TableFilterService, cdr: ChangeDetectorRef, formDefinition: FormDefinition | null)`
Defined in src/lib/table-filter/filter-header-row.directive.ts:50
Parameters :
Name | Type | Optional
tableFilter | `TableFilterService` | No
cdr | `ChangeDetectorRef` | No
formDefinition | `FormDefinition | null` | No

### Inputs

rxap-filter-header-row
Type : `FormDefinition | string`
Defined in src/lib/table-filter/filter-header-row.directive.ts:43

### Accessors

useFormDefinition
set `useFormDefinition(value: FormDefinition | string)`
Defined in src/lib/table-filter/filter-header-row.directive.ts:43
Parameters :
Name | Type | Optional
value | `FormDefinition | string` | No
Returns : `void`

    import {
      ChangeDetectorRef,
      Directive,
      forwardRef,
      Inject,
      Input,
      OnDestroy,
      OnInit,
      Optional,
    } from '@angular/core';
    import { ControlContainer } from '@angular/forms';
    import {
      FormDefinition,
      FormDirective,
    } from '@rxap/forms';
    import { equals } from '@rxap/utilities';
    import { Subscription } from 'rxjs';
    import {
      debounceTime,
      distinctUntilChanged,
      tap,
    } from 'rxjs/operators';
    import { TableFilterService } from './table-filter.service';
    import { RXAP_TABLE_FILTER_FORM_DEFINITION } from './tokens';

    @Directive({
      // eslint-disable-next-line @angular-eslint/directive-selector
      selector: 'table[rxap-filter-header-row]',
      providers: [
        {
          provide: ControlContainer,
          // ignore coverage
          useExisting: forwardRef(() => FilterHeaderRowDirective),
        },
      ],
      standalone: true,
    })
    export class FilterHeaderRowDirective
      extends FormDirective
      implements OnInit, OnDestroy {

      @Input('rxap-filter-header-row')
      public override set useFormDefinition(value: FormDefinition | '') {
        if (value) {
          this._formDefinition = value as any;
          this.form = value.rxapFormGroup;
        }
      }

      private _subscription?: Subscription;

      constructor(
        private readonly tableFilter: TableFilterService,
        cdr: ChangeDetectorRef,
        @Optional()
        @Inject(RXAP_TABLE_FILTER_FORM_DEFINITION)
          formDefinition: FormDefinition | null,
      ) {
        super(cdr, formDefinition);
      }

      public override ngOnInit() {
        super.ngOnInit();
        this._subscription = new Subscription();
        this._subscription.add(this.tableFilter.reset$.subscribe(() => this.form.reset()));
        this._subscription.add(this.form.value$
                                 .pipe(
                                   debounceTime(1000),
                                   distinctUntilChanged((a, b) => equals(a, b)),
                                   tap(values => this.tableFilter.setMap(values)),
                                 )
                                 .subscribe());
      }

      public override ngOnDestroy() {
        super.ngOnDestroy();
        this._subscription?.unsubscribe();
      }
    }

# results matching ""

# No results matching ""