@tetacom/ng-components 1.6.26 → 1.6.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,15 @@
1
- import { ChangeDetectorRef, OnDestroy, OnInit } from '@angular/core';
1
+ import { ChangeDetectorRef, Signal } from '@angular/core';
2
2
  import { TableService } from '../service/table.service';
3
3
  import * as i0 from "@angular/core";
4
- export declare class SelectionCellComponent<T> implements OnInit, OnDestroy {
4
+ export declare class SelectionCellComponent<T> {
5
5
  private _svc;
6
6
  private _cdr;
7
- row: T;
7
+ row: import("@angular/core").InputSignal<T>;
8
8
  private readonly tableCellClass;
9
- selectedRows: T[];
10
- private _alive;
9
+ selectedRows: Signal<T[]>;
10
+ isSelected: Signal<boolean>;
11
11
  constructor(_svc: TableService<T>, _cdr: ChangeDetectorRef);
12
12
  selectRow(value: boolean): void;
13
- ngOnInit(): void;
14
- ngOnDestroy(): void;
15
13
  static ɵfac: i0.ɵɵFactoryDeclaration<SelectionCellComponent<any>, never>;
16
- static ɵcmp: i0.ɵɵComponentDeclaration<SelectionCellComponent<any>, "teta-selection-cell", never, { "row": { "alias": "row"; "required": false; }; }, {}, never, never, true, never>;
14
+ static ɵcmp: i0.ɵɵComponentDeclaration<SelectionCellComponent<any>, "teta-selection-cell", never, { "row": { "alias": "row"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
17
15
  }
@@ -8199,36 +8199,35 @@ class SelectionCellComponent {
8199
8199
  constructor(_svc, _cdr) {
8200
8200
  this._svc = _svc;
8201
8201
  this._cdr = _cdr;
8202
+ this.row = input.required();
8202
8203
  this.tableCellClass = true;
8203
- this.selectedRows = [];
8204
- this._alive = true;
8204
+ this.selectedRows = toSignal(this._svc.selectedRows, {
8205
+ initialValue: [],
8206
+ });
8207
+ this.isSelected = computed(() => {
8208
+ const selectedRows = this.selectedRows();
8209
+ const row = this.row();
8210
+ if (row && selectedRows) {
8211
+ return selectedRows.indexOf(row) >= 0;
8212
+ }
8213
+ return false;
8214
+ });
8205
8215
  }
8206
8216
  selectRow(value) {
8207
8217
  if (value) {
8208
- this._svc.selectRow(this.row);
8218
+ this._svc.selectRow(this.row());
8209
8219
  }
8210
8220
  else {
8211
- this._svc.deselectRow(this.row);
8221
+ this._svc.deselectRow(this.row());
8212
8222
  }
8213
8223
  }
8214
- ngOnInit() {
8215
- this._svc.selectedRows.pipe(takeWhile((_) => this._alive)).subscribe((_) => {
8216
- this.selectedRows = _;
8217
- this._cdr.markForCheck();
8218
- });
8219
- }
8220
- ngOnDestroy() {
8221
- this._alive = false;
8222
- }
8223
8224
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SelectionCellComponent, deps: [{ token: TableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
8224
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.5", type: SelectionCellComponent, isStandalone: true, selector: "teta-selection-cell", inputs: { row: "row" }, host: { properties: { "class.cell": "this.tableCellClass" } }, ngImport: i0, template: "<teta-checkbox\n [binary]=\"true\"\n [noLabel]=\"true\"\n [ngModel]=\"selectedRows?.indexOf(row) >= 0\"\n (ngModelChange)=\"selectRow($event)\"\n (click)=\"$event.stopPropagation()\"\n></teta-checkbox>\n", styles: [":host{display:flex;align-items:center;justify-content:center}\n"], dependencies: [{ kind: "component", type: CheckboxComponent, selector: "teta-checkbox", inputs: ["class", "palette", "noLabel", "disabled", "value", "binary", "labelPosition", "allowNull"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
8225
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.0.5", type: SelectionCellComponent, isStandalone: true, selector: "teta-selection-cell", inputs: { row: { classPropertyName: "row", publicName: "row", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class.cell": "this.tableCellClass" } }, ngImport: i0, template: "<teta-checkbox\n [binary]=\"true\"\n [noLabel]=\"true\"\n [ngModel]=\"isSelected()\"\n (ngModelChange)=\"selectRow($event)\"\n (click)=\"$event.stopPropagation()\"\n></teta-checkbox>\n", styles: [":host{display:flex;align-items:center;justify-content:center}\n"], dependencies: [{ kind: "component", type: CheckboxComponent, selector: "teta-checkbox", inputs: ["class", "palette", "noLabel", "disabled", "value", "binary", "labelPosition", "allowNull"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
8225
8226
  }
8226
8227
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SelectionCellComponent, decorators: [{
8227
8228
  type: Component,
8228
- args: [{ selector: 'teta-selection-cell', changeDetection: ChangeDetectionStrategy.OnPush, imports: [CheckboxComponent, FormsModule], template: "<teta-checkbox\n [binary]=\"true\"\n [noLabel]=\"true\"\n [ngModel]=\"selectedRows?.indexOf(row) >= 0\"\n (ngModelChange)=\"selectRow($event)\"\n (click)=\"$event.stopPropagation()\"\n></teta-checkbox>\n", styles: [":host{display:flex;align-items:center;justify-content:center}\n"] }]
8229
- }], ctorParameters: () => [{ type: TableService }, { type: i0.ChangeDetectorRef }], propDecorators: { row: [{
8230
- type: Input
8231
- }], tableCellClass: [{
8229
+ args: [{ selector: 'teta-selection-cell', changeDetection: ChangeDetectionStrategy.OnPush, imports: [CheckboxComponent, FormsModule], template: "<teta-checkbox\n [binary]=\"true\"\n [noLabel]=\"true\"\n [ngModel]=\"isSelected()\"\n (ngModelChange)=\"selectRow($event)\"\n (click)=\"$event.stopPropagation()\"\n></teta-checkbox>\n", styles: [":host{display:flex;align-items:center;justify-content:center}\n"] }]
8230
+ }], ctorParameters: () => [{ type: TableService }, { type: i0.ChangeDetectorRef }], propDecorators: { tableCellClass: [{
8232
8231
  type: HostBinding,
8233
8232
  args: ['class.cell']
8234
8233
  }] } });