@alaarab/ogrid-angular-primeng 2.0.6 → 2.0.8

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.
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { Component, Input, Output, EventEmitter, ViewChild } from '@angular/core';
7
+ import { Component, input, computed, viewChild, ChangeDetectionStrategy } from '@angular/core';
8
8
  import { ButtonModule } from 'primeng/button';
9
9
  import { MenuModule } from 'primeng/menu';
10
10
  import { COLUMN_HEADER_MENU_ITEMS } from '@alaarab/ogrid-core';
@@ -14,93 +14,54 @@ import { COLUMN_HEADER_MENU_ITEMS } from '@alaarab/ogrid-core';
14
14
  */
15
15
  let ColumnHeaderMenuComponent = class ColumnHeaderMenuComponent {
16
16
  constructor() {
17
- this.pinLeft = new EventEmitter();
18
- this.pinRight = new EventEmitter();
19
- this.unpin = new EventEmitter();
20
- this._canPinLeft = true;
21
- this._canPinRight = true;
22
- this._canUnpin = false;
23
- this.menuModel = [];
24
- }
25
- set canPinLeft(value) {
26
- this._canPinLeft = value;
27
- this.updateMenuModel();
28
- }
29
- set canPinRight(value) {
30
- this._canPinRight = value;
31
- this.updateMenuModel();
32
- }
33
- set canUnpin(value) {
34
- this._canUnpin = value;
35
- this.updateMenuModel();
36
- }
37
- ngOnInit() {
38
- this.updateMenuModel();
39
- }
40
- updateMenuModel() {
41
- this.menuModel = [
17
+ this.columnId = input.required();
18
+ this.canPinLeft = input(true);
19
+ this.canPinRight = input(true);
20
+ this.canUnpin = input(false);
21
+ this.onPinLeft = input(undefined);
22
+ this.onPinRight = input(undefined);
23
+ this.onUnpin = input(undefined);
24
+ this.menuRef = viewChild('menu');
25
+ this.menuModel = computed(() => [
42
26
  {
43
27
  label: COLUMN_HEADER_MENU_ITEMS[0].label,
44
- disabled: !this._canPinLeft,
28
+ disabled: !this.canPinLeft(),
45
29
  command: () => this.handlePinLeft(),
46
30
  },
47
31
  {
48
32
  label: COLUMN_HEADER_MENU_ITEMS[1].label,
49
- disabled: !this._canPinRight,
33
+ disabled: !this.canPinRight(),
50
34
  command: () => this.handlePinRight(),
51
35
  },
52
36
  {
53
37
  label: COLUMN_HEADER_MENU_ITEMS[2].label,
54
- disabled: !this._canUnpin,
38
+ disabled: !this.canUnpin(),
55
39
  command: () => this.handleUnpin(),
56
40
  },
57
- ];
41
+ ]);
58
42
  }
59
43
  handlePinLeft() {
60
- if (this._canPinLeft) {
61
- this.pinLeft.emit();
44
+ if (this.canPinLeft()) {
45
+ this.onPinLeft()?.();
62
46
  }
63
47
  }
64
48
  handlePinRight() {
65
- if (this._canPinRight) {
66
- this.pinRight.emit();
49
+ if (this.canPinRight()) {
50
+ this.onPinRight()?.();
67
51
  }
68
52
  }
69
53
  handleUnpin() {
70
- if (this._canUnpin) {
71
- this.unpin.emit();
54
+ if (this.canUnpin()) {
55
+ this.onUnpin()?.();
72
56
  }
73
57
  }
74
58
  };
75
- __decorate([
76
- Input()
77
- ], ColumnHeaderMenuComponent.prototype, "columnId", void 0);
78
- __decorate([
79
- Input()
80
- ], ColumnHeaderMenuComponent.prototype, "canPinLeft", null);
81
- __decorate([
82
- Input()
83
- ], ColumnHeaderMenuComponent.prototype, "canPinRight", null);
84
- __decorate([
85
- Input()
86
- ], ColumnHeaderMenuComponent.prototype, "canUnpin", null);
87
- __decorate([
88
- Output()
89
- ], ColumnHeaderMenuComponent.prototype, "pinLeft", void 0);
90
- __decorate([
91
- Output()
92
- ], ColumnHeaderMenuComponent.prototype, "pinRight", void 0);
93
- __decorate([
94
- Output()
95
- ], ColumnHeaderMenuComponent.prototype, "unpin", void 0);
96
- __decorate([
97
- ViewChild('menu')
98
- ], ColumnHeaderMenuComponent.prototype, "menu", void 0);
99
59
  ColumnHeaderMenuComponent = __decorate([
100
60
  Component({
101
61
  selector: 'column-header-menu',
102
62
  standalone: true,
103
63
  imports: [ButtonModule, MenuModule],
64
+ changeDetection: ChangeDetectionStrategy.OnPush,
104
65
  template: `
105
66
  <button
106
67
  pButton
@@ -108,12 +69,12 @@ ColumnHeaderMenuComponent = __decorate([
108
69
  icon="pi pi-ellipsis-v"
109
70
  class="p-button-text p-button-sm column-header-menu-trigger"
110
71
  (click)="menu.toggle($event)"
111
- [attr.aria-label]="'Column options for ' + columnId"
72
+ [attr.aria-label]="'Column options for ' + columnId()"
112
73
  ></button>
113
74
 
114
75
  <p-menu
115
76
  #menu
116
- [model]="menuModel"
77
+ [model]="menuModel()"
117
78
  [popup]="true"
118
79
  appendTo="body"
119
80
  ></p-menu>