@alaarab/ogrid-angular-material 2.0.8 → 2.0.11
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.
- package/dist/esm/column-chooser/column-chooser.component.js +5 -34
- package/dist/esm/column-header-filter/column-header-filter.component.js +67 -213
- package/dist/esm/column-header-menu/column-header-menu.component.js +91 -58
- package/dist/esm/datagrid-table/datagrid-table.component.js +74 -30
- package/dist/esm/datagrid-table/inline-cell-editor.component.js +48 -20
- package/dist/esm/datagrid-table/popover-cell-editor.component.js +38 -18
- package/dist/esm/index.js +2 -0
- package/dist/esm/ogrid/ogrid.component.js +25 -17
- package/dist/esm/pagination-controls/pagination-controls.component.js +14 -31
- package/dist/types/column-chooser/column-chooser.component.d.ts +2 -20
- package/dist/types/column-header-filter/column-header-filter.component.d.ts +6 -68
- package/dist/types/column-header-menu/column-header-menu.component.d.ts +13 -13
- package/dist/types/datagrid-table/datagrid-table.component.d.ts +16 -3
- package/dist/types/datagrid-table/inline-cell-editor.component.d.ts +13 -10
- package/dist/types/datagrid-table/popover-cell-editor.component.d.ts +9 -9
- package/dist/types/index.d.ts +0 -2
- package/dist/types/ogrid/ogrid.component.d.ts +7 -4
- package/dist/types/pagination-controls/pagination-controls.component.d.ts +2 -10
- package/package.json +2 -2
|
@@ -4,8 +4,8 @@ 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,
|
|
8
|
-
import { BaseDataGridTableComponent, DataGridStateService, MarchingAntsOverlayComponent, CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, } from '@alaarab/ogrid-angular';
|
|
7
|
+
import { Component, ChangeDetectionStrategy, Input, ViewChild, signal } from '@angular/core';
|
|
8
|
+
import { BaseDataGridTableComponent, DataGridStateService, MarchingAntsOverlayComponent, StatusBarComponent, GridContextMenuComponent, CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, } from '@alaarab/ogrid-angular';
|
|
9
9
|
import { ColumnHeaderFilterComponent } from '../column-header-filter/column-header-filter.component';
|
|
10
10
|
import { ColumnHeaderMenuComponent } from '../column-header-menu/column-header-menu.component';
|
|
11
11
|
import { InlineCellEditorComponent } from './inline-cell-editor.component';
|
|
@@ -15,30 +15,54 @@ import { PopoverCellEditorComponent } from './popover-cell-editor.component';
|
|
|
15
15
|
* Standalone component — this is the workhorse of the grid.
|
|
16
16
|
*/
|
|
17
17
|
let DataGridTableComponent = class DataGridTableComponent extends BaseDataGridTableComponent {
|
|
18
|
+
set propsInput(value) {
|
|
19
|
+
this.propsSignal.set(value);
|
|
20
|
+
}
|
|
18
21
|
constructor() {
|
|
19
22
|
super();
|
|
20
|
-
this.
|
|
21
|
-
this.wrapperRef = viewChild('wrapperEl');
|
|
22
|
-
this.tableContainerRef = viewChild('tableContainerEl');
|
|
23
|
+
this.propsSignal = signal(undefined);
|
|
23
24
|
this.initBase();
|
|
24
25
|
}
|
|
25
26
|
getProps() {
|
|
26
|
-
return this.
|
|
27
|
+
return this.propsSignal();
|
|
27
28
|
}
|
|
28
29
|
getWrapperRef() {
|
|
29
|
-
return this.wrapperRef
|
|
30
|
+
return this.wrapperRef;
|
|
30
31
|
}
|
|
31
32
|
getTableContainerRef() {
|
|
32
|
-
return this.tableContainerRef
|
|
33
|
+
return this.tableContainerRef;
|
|
34
|
+
}
|
|
35
|
+
/** Build column header menu handlers for a given column */
|
|
36
|
+
getColumnMenuHandlers(columnId) {
|
|
37
|
+
return {
|
|
38
|
+
onPinLeft: () => this.onPinColumn(columnId, 'left'),
|
|
39
|
+
onPinRight: () => this.onPinColumn(columnId, 'right'),
|
|
40
|
+
onUnpin: () => this.onUnpinColumn(columnId),
|
|
41
|
+
onSortAsc: () => this.onSortAsc(columnId),
|
|
42
|
+
onSortDesc: () => this.onSortDesc(columnId),
|
|
43
|
+
onClearSort: () => this.onClearSort(),
|
|
44
|
+
onAutosizeThis: () => this.onAutosizeColumn(columnId),
|
|
45
|
+
onAutosizeAll: () => this.onAutosizeAllColumns(),
|
|
46
|
+
onClose: () => { }
|
|
47
|
+
};
|
|
33
48
|
}
|
|
34
49
|
};
|
|
50
|
+
__decorate([
|
|
51
|
+
Input({ required: true, alias: 'props' })
|
|
52
|
+
], DataGridTableComponent.prototype, "propsInput", null);
|
|
53
|
+
__decorate([
|
|
54
|
+
ViewChild('wrapperEl')
|
|
55
|
+
], DataGridTableComponent.prototype, "wrapperRef", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
ViewChild('tableContainerEl')
|
|
58
|
+
], DataGridTableComponent.prototype, "tableContainerRef", void 0);
|
|
35
59
|
DataGridTableComponent = __decorate([
|
|
36
60
|
Component({
|
|
37
61
|
selector: 'ogrid-datagrid-table',
|
|
38
62
|
standalone: true,
|
|
39
|
-
imports: [ColumnHeaderFilterComponent, ColumnHeaderMenuComponent, MarchingAntsOverlayComponent, InlineCellEditorComponent, PopoverCellEditorComponent],
|
|
40
|
-
providers: [DataGridStateService],
|
|
41
63
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
64
|
+
imports: [ColumnHeaderFilterComponent, ColumnHeaderMenuComponent, StatusBarComponent, GridContextMenuComponent, MarchingAntsOverlayComponent, InlineCellEditorComponent, PopoverCellEditorComponent],
|
|
65
|
+
providers: [DataGridStateService],
|
|
42
66
|
template: `
|
|
43
67
|
<div class="ogrid-datagrid-root">
|
|
44
68
|
<div
|
|
@@ -103,16 +127,21 @@ DataGridTableComponent = __decorate([
|
|
|
103
127
|
@let pinned = isPinned(col.columnId);
|
|
104
128
|
@let pinnedLeft = pinned === 'left' || (isFreezeCol && colIdx === 0);
|
|
105
129
|
@let pinnedRight = pinned === 'right';
|
|
130
|
+
@let sortState = getSortState(col.columnId);
|
|
131
|
+
@let ariaSort = sortState === 'asc' ? 'ascending' : sortState === 'desc' ? 'descending' : null;
|
|
106
132
|
<th scope="col"
|
|
107
133
|
class="ogrid-datagrid-th"
|
|
108
134
|
[class.ogrid-datagrid-th--pinned-left]="pinnedLeft"
|
|
109
135
|
[class.ogrid-datagrid-th--pinned-right]="pinnedRight"
|
|
110
136
|
[attr.rowSpan]="headerRows().length > 1 ? headerRows().length - rowIdx : null"
|
|
111
137
|
[attr.data-column-id]="col.columnId"
|
|
138
|
+
[attr.aria-sort]="ariaSort"
|
|
112
139
|
[style.minWidth.px]="col.minWidth ?? 80"
|
|
113
140
|
[style.width.px]="colW"
|
|
114
141
|
[style.maxWidth.px]="colW"
|
|
115
142
|
[style.cursor]="columnReorderService.isDragging() ? 'grabbing' : 'grab'"
|
|
143
|
+
[style.left.px]="pinnedLeft ? getPinnedLeftOffset(col.columnId) : null"
|
|
144
|
+
[style.right.px]="pinnedRight ? getPinnedRightOffset(col.columnId) : null"
|
|
116
145
|
(mousedown)="onHeaderMouseDown(col.columnId, $event)"
|
|
117
146
|
>
|
|
118
147
|
<div style="display:flex;align-items:center;gap:4px;">
|
|
@@ -136,14 +165,16 @@ DataGridTableComponent = __decorate([
|
|
|
136
165
|
[onDateChange]="getFilterConfig(col).onDateChange"
|
|
137
166
|
/>
|
|
138
167
|
@let pinState = getPinState(col.columnId);
|
|
168
|
+
@let sortState = getSortState(col.columnId);
|
|
139
169
|
<column-header-menu
|
|
140
170
|
[columnId]="col.columnId"
|
|
141
|
-
[onPinLeft]="() => onPinColumn(col.columnId, 'left')"
|
|
142
|
-
[onPinRight]="() => onPinColumn(col.columnId, 'right')"
|
|
143
|
-
[onUnpin]="() => onUnpinColumn(col.columnId)"
|
|
144
171
|
[canPinLeft]="pinState.canPinLeft"
|
|
145
172
|
[canPinRight]="pinState.canPinRight"
|
|
146
173
|
[canUnpin]="pinState.canUnpin"
|
|
174
|
+
[currentSort]="sortState"
|
|
175
|
+
[isSortable]="col.sortable !== false"
|
|
176
|
+
[isResizable]="col.resizable !== false"
|
|
177
|
+
[handlers]="getColumnMenuHandlers(col.columnId)"
|
|
147
178
|
/>
|
|
148
179
|
</div>
|
|
149
180
|
<div class="ogrid-datagrid-resize-handle" (mousedown)="onResizeStart($event, col)"></div>
|
|
@@ -200,6 +231,8 @@ DataGridTableComponent = __decorate([
|
|
|
200
231
|
[style.minWidth.px]="colLayout.minWidth"
|
|
201
232
|
[style.width.px]="colLayout.width"
|
|
202
233
|
[style.maxWidth.px]="colLayout.width"
|
|
234
|
+
[style.left.px]="colLayout.pinnedLeft ? getPinnedLeftOffset(colLayout.col.columnId) : null"
|
|
235
|
+
[style.right.px]="colLayout.pinnedRight ? getPinnedRightOffset(colLayout.col.columnId) : null"
|
|
203
236
|
>
|
|
204
237
|
@let descriptor = getCellDescriptor(item, colLayout.col, rowIndex, colIdx);
|
|
205
238
|
@if (descriptor.mode === 'editing-inline') {
|
|
@@ -221,7 +254,7 @@ DataGridTableComponent = __decorate([
|
|
|
221
254
|
[globalColIndex]="descriptor.globalColIndex"
|
|
222
255
|
[displayValue]="descriptor.displayValue"
|
|
223
256
|
[editorProps]="editorProps"
|
|
224
|
-
[onCancel]="
|
|
257
|
+
[onCancel]="cancelEdit.bind(this)"
|
|
225
258
|
></ogrid-mat-popover-cell-editor>
|
|
226
259
|
} @else {
|
|
227
260
|
@let content = resolveCellContent(colLayout.col, item, descriptor.displayValue);
|
|
@@ -267,12 +300,15 @@ DataGridTableComponent = __decorate([
|
|
|
267
300
|
</table>
|
|
268
301
|
|
|
269
302
|
<ogrid-marching-ants-overlay
|
|
270
|
-
[containerEl]="tableContainerEl
|
|
303
|
+
[containerEl]="tableContainerEl"
|
|
271
304
|
[selectionRange]="state().interaction.selectionRange"
|
|
272
305
|
[copyRange]="state().interaction.copyRange"
|
|
273
306
|
[cutRange]="state().interaction.cutRange"
|
|
274
307
|
[colOffset]="state().layout.colOffset"
|
|
275
308
|
[columnSizingVersion]="columnSizingVersion()"
|
|
309
|
+
[items]="items()"
|
|
310
|
+
[visibleColumns]="propsVisibleColumns()"
|
|
311
|
+
[columnOrder]="propsColumnOrder()"
|
|
276
312
|
></ogrid-marching-ants-overlay>
|
|
277
313
|
|
|
278
314
|
@if (showEmptyInGrid() && emptyState()) {
|
|
@@ -305,12 +341,12 @@ DataGridTableComponent = __decorate([
|
|
|
305
341
|
(click)="closeContextMenu()"
|
|
306
342
|
(contextmenu)="$event.preventDefault(); closeContextMenu()"
|
|
307
343
|
>
|
|
308
|
-
<ogrid-
|
|
344
|
+
<ogrid-context-menu
|
|
309
345
|
[x]="menuPosition()!.x"
|
|
310
346
|
[y]="menuPosition()!.y"
|
|
311
347
|
[hasSelection]="hasCellSelection()"
|
|
312
|
-
[
|
|
313
|
-
[
|
|
348
|
+
[canUndoProp]="canUndo()"
|
|
349
|
+
[canRedoProp]="canRedo()"
|
|
314
350
|
(undoAction)="onUndo()"
|
|
315
351
|
(redoAction)="onRedo()"
|
|
316
352
|
(copyAction)="handleCopy()"
|
|
@@ -358,24 +394,28 @@ DataGridTableComponent = __decorate([
|
|
|
358
394
|
.ogrid-datagrid-scroll-wrapper { display: flex; flex-direction: column; min-height: 100%; }
|
|
359
395
|
.ogrid-datagrid-table-wrapper--loading { position: relative; opacity: 0.6; }
|
|
360
396
|
.ogrid-datagrid-table {
|
|
361
|
-
width: 100%; border-collapse: collapse;
|
|
397
|
+
width: 100%; border-collapse: collapse; table-layout: fixed;
|
|
362
398
|
}
|
|
363
399
|
.ogrid-datagrid-thead {
|
|
364
|
-
|
|
400
|
+
z-index: 8; background: rgba(0,0,0,0.04);
|
|
365
401
|
}
|
|
366
402
|
.ogrid-datagrid-thead th { background: rgba(0,0,0,0.04); }
|
|
367
403
|
.ogrid-datagrid-header-row { background: rgba(0,0,0,0.04); }
|
|
368
404
|
.ogrid-datagrid-th {
|
|
369
|
-
font-weight: 600; position:
|
|
405
|
+
font-weight: 600; position: sticky; top: 0; padding: 6px 10px; text-align: left;
|
|
370
406
|
font-size: 14px; border-bottom: 1px solid rgba(0,0,0,0.12);
|
|
407
|
+
background: rgba(0,0,0,0.04); z-index: 8;
|
|
408
|
+
}
|
|
409
|
+
.ogrid-datagrid-th:focus-visible {
|
|
410
|
+
outline: 2px solid #1976d2; outline-offset: -2px; z-index: 11;
|
|
371
411
|
}
|
|
372
412
|
.ogrid-datagrid-th--pinned-left {
|
|
373
|
-
position: sticky; left: 0; z-index:
|
|
374
|
-
border-
|
|
413
|
+
position: sticky; top: 0; left: 0; z-index: 10; background: rgba(0,0,0,0.04); will-change: transform;
|
|
414
|
+
border-right: 2px solid rgba(0,0,0,0.12);
|
|
375
415
|
}
|
|
376
416
|
.ogrid-datagrid-th--pinned-right {
|
|
377
|
-
position: sticky; right: 0; z-index:
|
|
378
|
-
border-
|
|
417
|
+
position: sticky; top: 0; right: 0; z-index: 10; background: rgba(0,0,0,0.04); will-change: transform;
|
|
418
|
+
border-left: 2px solid rgba(0,0,0,0.12);
|
|
379
419
|
}
|
|
380
420
|
.ogrid-datagrid-group-header {
|
|
381
421
|
text-align: center; font-weight: 600; border-bottom: 2px solid rgba(0,0,0,0.12); padding: 6px;
|
|
@@ -402,11 +442,11 @@ DataGridTableComponent = __decorate([
|
|
|
402
442
|
.ogrid-datagrid-td { position: relative; padding: 0; height: 1px; border-bottom: 1px solid rgba(0,0,0,0.06); }
|
|
403
443
|
.ogrid-datagrid-td--pinned-left {
|
|
404
444
|
position: sticky; left: 0; z-index: 6; background: #fff; will-change: transform;
|
|
405
|
-
border-
|
|
445
|
+
border-right: 2px solid rgba(0,0,0,0.12);
|
|
406
446
|
}
|
|
407
447
|
.ogrid-datagrid-td--pinned-right {
|
|
408
448
|
position: sticky; right: 0; z-index: 6; background: #fff; will-change: transform;
|
|
409
|
-
border-
|
|
449
|
+
border-left: 2px solid rgba(0,0,0,0.12);
|
|
410
450
|
}
|
|
411
451
|
.ogrid-datagrid-cell {
|
|
412
452
|
width: 100%; height: 100%; display: flex; align-items: center; min-width: 0;
|
|
@@ -414,6 +454,9 @@ DataGridTableComponent = __decorate([
|
|
|
414
454
|
text-overflow: ellipsis; white-space: nowrap; user-select: none; outline: none;
|
|
415
455
|
font-size: 14px;
|
|
416
456
|
}
|
|
457
|
+
.ogrid-datagrid-cell:focus-visible {
|
|
458
|
+
outline: 2px solid #1976d2; outline-offset: -2px; z-index: 3;
|
|
459
|
+
}
|
|
417
460
|
.ogrid-datagrid-cell--numeric { justify-content: flex-end; text-align: right; }
|
|
418
461
|
.ogrid-datagrid-cell--boolean { justify-content: center; text-align: center; }
|
|
419
462
|
.ogrid-datagrid-cell--editable { cursor: cell; }
|
|
@@ -446,10 +489,11 @@ DataGridTableComponent = __decorate([
|
|
|
446
489
|
cursor: col-resize; user-select: none;
|
|
447
490
|
}
|
|
448
491
|
.ogrid-datagrid-resize-handle::after {
|
|
449
|
-
content: ''; position: absolute; top:
|
|
492
|
+
content: ''; position: absolute; top: 4px; right: 3px; bottom: 4px; width: 2px;
|
|
493
|
+
background: rgba(0,0,0,0.12); border-radius: 1px; transition: background 0.15s;
|
|
450
494
|
}
|
|
451
|
-
.ogrid-datagrid-resize-handle:hover::after { background:
|
|
452
|
-
.ogrid-datagrid-resize-handle:active::after { background: var(--mat-sys-primary, #
|
|
495
|
+
.ogrid-datagrid-resize-handle:hover::after { background: rgba(0,0,0,0.4); }
|
|
496
|
+
.ogrid-datagrid-resize-handle:active::after { background: var(--mat-sys-primary, #1976d2); }
|
|
453
497
|
.ogrid-datagrid-empty {
|
|
454
498
|
padding: 32px 16px; text-align: center; border-top: 1px solid rgba(0,0,0,0.12);
|
|
455
499
|
background: rgba(0,0,0,0.04);
|
|
@@ -4,32 +4,36 @@ 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,
|
|
7
|
+
import { Component, Input, Output, EventEmitter, signal, ViewChild } from '@angular/core';
|
|
8
8
|
import { CommonModule } from '@angular/common';
|
|
9
9
|
let InlineCellEditorComponent = class InlineCellEditorComponent {
|
|
10
10
|
constructor() {
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.column = input.required();
|
|
14
|
-
this.rowIndex = input.required();
|
|
15
|
-
this.editorType = input.required();
|
|
16
|
-
this.commit = output();
|
|
17
|
-
this.cancel = output();
|
|
18
|
-
this.inputEl = viewChild('inputEl');
|
|
11
|
+
this.commit = new EventEmitter();
|
|
12
|
+
this.cancel = new EventEmitter();
|
|
19
13
|
this.localValue = signal('');
|
|
20
14
|
this.selectOptions = signal([]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
this._initialized = false;
|
|
16
|
+
}
|
|
17
|
+
ngOnInit() {
|
|
18
|
+
this._initialized = true;
|
|
19
|
+
this.syncFromInputs();
|
|
20
|
+
}
|
|
21
|
+
ngOnChanges() {
|
|
22
|
+
if (this._initialized) {
|
|
23
|
+
this.syncFromInputs();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
syncFromInputs() {
|
|
27
|
+
const v = this.value;
|
|
28
|
+
this.localValue.set(v != null ? String(v) : '');
|
|
29
|
+
const col = this.column;
|
|
30
|
+
if (col?.cellEditorParams?.values) {
|
|
31
|
+
this.selectOptions.set(col.cellEditorParams.values);
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
ngAfterViewInit() {
|
|
31
35
|
setTimeout(() => {
|
|
32
|
-
const el = this.inputEl
|
|
36
|
+
const el = this.inputEl?.nativeElement;
|
|
33
37
|
if (el) {
|
|
34
38
|
el.focus();
|
|
35
39
|
if (el instanceof HTMLInputElement && el.type === 'text') {
|
|
@@ -72,20 +76,44 @@ let InlineCellEditorComponent = class InlineCellEditorComponent {
|
|
|
72
76
|
}
|
|
73
77
|
getInputStyle() {
|
|
74
78
|
const baseStyle = 'width:100%;box-sizing:border-box;padding:6px 10px;border:2px solid var(--ogrid-selection, #217346);border-radius:2px;outline:none;font:inherit;background:var(--ogrid-bg, #fff);color:var(--ogrid-fg, #242424);';
|
|
75
|
-
const col = this.column
|
|
79
|
+
const col = this.column;
|
|
76
80
|
if (col.type === 'numeric') {
|
|
77
81
|
return baseStyle + 'text-align:right;';
|
|
78
82
|
}
|
|
79
83
|
return baseStyle;
|
|
80
84
|
}
|
|
81
85
|
};
|
|
86
|
+
__decorate([
|
|
87
|
+
Input({ required: true })
|
|
88
|
+
], InlineCellEditorComponent.prototype, "value", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
Input({ required: true })
|
|
91
|
+
], InlineCellEditorComponent.prototype, "item", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
Input({ required: true })
|
|
94
|
+
], InlineCellEditorComponent.prototype, "column", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
Input({ required: true })
|
|
97
|
+
], InlineCellEditorComponent.prototype, "rowIndex", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
Input({ required: true })
|
|
100
|
+
], InlineCellEditorComponent.prototype, "editorType", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
Output()
|
|
103
|
+
], InlineCellEditorComponent.prototype, "commit", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
Output()
|
|
106
|
+
], InlineCellEditorComponent.prototype, "cancel", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
ViewChild('inputEl')
|
|
109
|
+
], InlineCellEditorComponent.prototype, "inputEl", void 0);
|
|
82
110
|
InlineCellEditorComponent = __decorate([
|
|
83
111
|
Component({
|
|
84
112
|
selector: 'ogrid-mat-inline-cell-editor',
|
|
85
113
|
standalone: true,
|
|
86
114
|
imports: [CommonModule],
|
|
87
115
|
template: `
|
|
88
|
-
@switch (editorType
|
|
116
|
+
@switch (editorType) {
|
|
89
117
|
@case ('text') {
|
|
90
118
|
<input
|
|
91
119
|
#inputEl
|
|
@@ -4,45 +4,38 @@ 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,
|
|
7
|
+
import { Component, ChangeDetectionStrategy, signal, effect, ViewChild, Injector, createComponent, EnvironmentInjector, inject, Input } from '@angular/core';
|
|
8
8
|
/**
|
|
9
9
|
* PopoverCellEditor component for Angular Material.
|
|
10
10
|
* Renders custom popover editor when anchor element is set.
|
|
11
11
|
*/
|
|
12
12
|
let PopoverCellEditorComponent = class PopoverCellEditorComponent {
|
|
13
13
|
constructor() {
|
|
14
|
-
this.item = input.required();
|
|
15
|
-
this.column = input.required();
|
|
16
|
-
this.rowIndex = input.required();
|
|
17
|
-
this.globalColIndex = input.required();
|
|
18
|
-
this.displayValue = input.required();
|
|
19
|
-
this.editorProps = input.required();
|
|
20
|
-
this.onCancel = input.required();
|
|
21
|
-
this.anchorRef = viewChild('anchorEl');
|
|
22
|
-
this.editorContainerRef = viewChild('editorContainer');
|
|
23
14
|
this.injector = inject(Injector);
|
|
24
15
|
this.envInjector = inject(EnvironmentInjector);
|
|
25
16
|
this.showEditor = signal(false);
|
|
26
17
|
// Show editor after anchor is rendered
|
|
27
18
|
effect(() => {
|
|
28
|
-
const anchor = this.anchorRef
|
|
19
|
+
const anchor = this.anchorRef;
|
|
29
20
|
if (anchor) {
|
|
30
21
|
setTimeout(() => this.showEditor.set(true), 0);
|
|
31
22
|
}
|
|
32
23
|
});
|
|
33
24
|
// Render custom editor component when container is available
|
|
34
25
|
effect(() => {
|
|
35
|
-
const container = this.editorContainerRef
|
|
36
|
-
const props = this.editorProps
|
|
37
|
-
const col = this.column
|
|
26
|
+
const container = this.editorContainerRef;
|
|
27
|
+
const props = this.editorProps;
|
|
28
|
+
const col = this.column;
|
|
38
29
|
if (!container || !this.showEditor() || typeof col.cellEditor !== 'function')
|
|
39
30
|
return;
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
32
|
const EditorComponent = col.cellEditor; // ComponentType
|
|
41
33
|
const componentRef = createComponent(EditorComponent, {
|
|
42
34
|
environmentInjector: this.envInjector,
|
|
43
35
|
elementInjector: this.injector,
|
|
44
36
|
});
|
|
45
37
|
// Pass props to component instance
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
39
|
Object.assign(componentRef.instance, props);
|
|
47
40
|
componentRef.changeDetectorRef.detectChanges();
|
|
48
41
|
// Append to DOM
|
|
@@ -52,9 +45,36 @@ let PopoverCellEditorComponent = class PopoverCellEditorComponent {
|
|
|
52
45
|
});
|
|
53
46
|
}
|
|
54
47
|
handleOverlayClick() {
|
|
55
|
-
this.onCancel()
|
|
48
|
+
this.onCancel();
|
|
56
49
|
}
|
|
57
50
|
};
|
|
51
|
+
__decorate([
|
|
52
|
+
Input({ required: true })
|
|
53
|
+
], PopoverCellEditorComponent.prototype, "item", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
Input({ required: true })
|
|
56
|
+
], PopoverCellEditorComponent.prototype, "column", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
Input({ required: true })
|
|
59
|
+
], PopoverCellEditorComponent.prototype, "rowIndex", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
Input({ required: true })
|
|
62
|
+
], PopoverCellEditorComponent.prototype, "globalColIndex", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
Input({ required: true })
|
|
65
|
+
], PopoverCellEditorComponent.prototype, "displayValue", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
Input({ required: true })
|
|
68
|
+
], PopoverCellEditorComponent.prototype, "editorProps", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
Input({ required: true })
|
|
71
|
+
], PopoverCellEditorComponent.prototype, "onCancel", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
ViewChild('anchorEl')
|
|
74
|
+
], PopoverCellEditorComponent.prototype, "anchorRef", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
ViewChild('editorContainer')
|
|
77
|
+
], PopoverCellEditorComponent.prototype, "editorContainerRef", void 0);
|
|
58
78
|
PopoverCellEditorComponent = __decorate([
|
|
59
79
|
Component({
|
|
60
80
|
selector: 'ogrid-mat-popover-cell-editor',
|
|
@@ -63,10 +83,10 @@ PopoverCellEditorComponent = __decorate([
|
|
|
63
83
|
template: `
|
|
64
84
|
<div #anchorEl
|
|
65
85
|
class="ogrid-popover-anchor"
|
|
66
|
-
[attr.data-row-index]="rowIndex
|
|
67
|
-
[attr.data-col-index]="globalColIndex
|
|
86
|
+
[attr.data-row-index]="rowIndex"
|
|
87
|
+
[attr.data-col-index]="globalColIndex"
|
|
68
88
|
>
|
|
69
|
-
{{ displayValue
|
|
89
|
+
{{ displayValue }}
|
|
70
90
|
</div>
|
|
71
91
|
@if (showEditor()) {
|
|
72
92
|
<div class="ogrid-popover-editor-overlay" (click)="handleOverlayClick()">
|
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,9 @@ export * from '@alaarab/ogrid-angular';
|
|
|
4
4
|
export { OGridComponent } from './ogrid/ogrid.component';
|
|
5
5
|
export { DataGridTableComponent } from './datagrid-table/datagrid-table.component';
|
|
6
6
|
export { ColumnHeaderFilterComponent } from './column-header-filter/column-header-filter.component';
|
|
7
|
+
// IColumnHeaderFilterProps is now exported from @alaarab/ogrid-angular (base class)
|
|
7
8
|
export { ColumnChooserComponent } from './column-chooser/column-chooser.component';
|
|
9
|
+
// IColumnChooserProps is now exported from @alaarab/ogrid-angular (base class)
|
|
8
10
|
export { PaginationControlsComponent } from './pagination-controls/pagination-controls.component';
|
|
9
11
|
export { ColumnHeaderMenuComponent } from './column-header-menu/column-header-menu.component';
|
|
10
12
|
export { InlineCellEditorComponent } from './datagrid-table/inline-cell-editor.component';
|
|
@@ -4,39 +4,47 @@ 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,
|
|
7
|
+
import { Component, ChangeDetectionStrategy, Input, signal, effect } from '@angular/core';
|
|
8
8
|
import { OGridService, OGridLayoutComponent, } from '@alaarab/ogrid-angular';
|
|
9
9
|
import { DataGridTableComponent } from '../datagrid-table/datagrid-table.component';
|
|
10
10
|
import { ColumnChooserComponent } from '../column-chooser/column-chooser.component';
|
|
11
11
|
import { PaginationControlsComponent } from '../pagination-controls/pagination-controls.component';
|
|
12
12
|
/**
|
|
13
13
|
* Top-level OGrid component for Angular Material.
|
|
14
|
-
* Equivalent to the React MaterialDataTable/OGrid component.
|
|
15
14
|
* Standalone component — provides OGridService and renders OGridLayout with all sub-components.
|
|
15
|
+
*
|
|
16
|
+
* Uses @Input with signal setter for JIT compatibility (project builds with tsc, not ngc).
|
|
17
|
+
* The effect() reactively configures the service when the input signal changes.
|
|
16
18
|
*/
|
|
17
19
|
let OGridComponent = class OGridComponent {
|
|
20
|
+
set props(value) {
|
|
21
|
+
this.propsSignal.set(value);
|
|
22
|
+
}
|
|
18
23
|
constructor() {
|
|
19
|
-
this.
|
|
20
|
-
this.dataGridProps = computed(() => {
|
|
21
|
-
// Ensure service is configured before accessing dataGridProps
|
|
22
|
-
this.ogridService.configure(this.props());
|
|
23
|
-
return this.ogridService.dataGridProps();
|
|
24
|
-
});
|
|
25
|
-
// The OGridService is provided at the component level, so inject it here
|
|
26
|
-
// But since we can't use inject() with generics well, we use the providers array
|
|
27
|
-
// and the Angular DI system will handle it.
|
|
28
|
-
// Actually we need a slightly different approach for the generic service.
|
|
24
|
+
this.propsSignal = signal(undefined);
|
|
29
25
|
this.ogridService = new OGridService();
|
|
26
|
+
effect(() => {
|
|
27
|
+
const p = this.propsSignal();
|
|
28
|
+
if (p)
|
|
29
|
+
this.ogridService.configure(p);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
get showToolbar() {
|
|
33
|
+
return this.ogridService.columnChooserPlacement() === 'toolbar' || this.ogridService.toolbar() != null;
|
|
30
34
|
}
|
|
31
35
|
onPageSizeChange(size) {
|
|
32
36
|
this.ogridService.pagination().setPageSize(size);
|
|
33
37
|
this.ogridService.pagination().setPage(1);
|
|
34
38
|
}
|
|
35
39
|
};
|
|
40
|
+
__decorate([
|
|
41
|
+
Input({ required: true })
|
|
42
|
+
], OGridComponent.prototype, "props", null);
|
|
36
43
|
OGridComponent = __decorate([
|
|
37
44
|
Component({
|
|
38
45
|
selector: 'ogrid',
|
|
39
46
|
standalone: true,
|
|
47
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
40
48
|
imports: [
|
|
41
49
|
OGridLayoutComponent,
|
|
42
50
|
DataGridTableComponent,
|
|
@@ -44,15 +52,15 @@ OGridComponent = __decorate([
|
|
|
44
52
|
PaginationControlsComponent,
|
|
45
53
|
],
|
|
46
54
|
providers: [OGridService],
|
|
47
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
48
55
|
template: `
|
|
49
56
|
<ogrid-layout
|
|
50
57
|
[className]="ogridService.className()"
|
|
51
58
|
[sideBar]="ogridService.sideBarProps()"
|
|
52
|
-
[
|
|
53
|
-
[
|
|
59
|
+
[hasToolbar]="showToolbar"
|
|
60
|
+
[hasToolbarBelow]="false"
|
|
61
|
+
[hasPagination]="true"
|
|
54
62
|
>
|
|
55
|
-
<ng-container
|
|
63
|
+
<ng-container toolbarEnd>
|
|
56
64
|
@if (ogridService.columnChooserPlacement() === 'toolbar') {
|
|
57
65
|
<ogrid-column-chooser
|
|
58
66
|
[columns]="ogridService.columnChooser().columns"
|
|
@@ -62,7 +70,7 @@ OGridComponent = __decorate([
|
|
|
62
70
|
}
|
|
63
71
|
</ng-container>
|
|
64
72
|
|
|
65
|
-
<ogrid-datagrid-table [props]="dataGridProps()" />
|
|
73
|
+
<ogrid-datagrid-table [props]="ogridService.dataGridProps()" />
|
|
66
74
|
|
|
67
75
|
<ng-container pagination>
|
|
68
76
|
<ogrid-pagination-controls
|
|
@@ -4,30 +4,13 @@ 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,
|
|
8
|
-
import {
|
|
7
|
+
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
|
8
|
+
import { BasePaginationControlsComponent } from '@alaarab/ogrid-angular';
|
|
9
9
|
/**
|
|
10
10
|
* Pagination controls component using Angular Material styling.
|
|
11
11
|
* Standalone component with inline template — no Angular Material dependency for pagination.
|
|
12
12
|
*/
|
|
13
|
-
let PaginationControlsComponent = class PaginationControlsComponent {
|
|
14
|
-
constructor() {
|
|
15
|
-
this.currentPage = input.required();
|
|
16
|
-
this.pageSize = input.required();
|
|
17
|
-
this.totalCount = input.required();
|
|
18
|
-
this.pageSizeOptions = input(undefined);
|
|
19
|
-
this.entityLabelPlural = input('items');
|
|
20
|
-
this.pageChange = output();
|
|
21
|
-
this.pageSizeChange = output();
|
|
22
|
-
this.vm = computed(() => {
|
|
23
|
-
const opts = this.pageSizeOptions();
|
|
24
|
-
return getPaginationViewModel(this.currentPage(), this.pageSize(), this.totalCount(), opts ? { pageSizeOptions: opts } : undefined);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
onPageSizeSelect(event) {
|
|
28
|
-
const value = Number(event.target.value);
|
|
29
|
-
this.pageSizeChange.emit(value);
|
|
30
|
-
}
|
|
13
|
+
let PaginationControlsComponent = class PaginationControlsComponent extends BasePaginationControlsComponent {
|
|
31
14
|
};
|
|
32
15
|
PaginationControlsComponent = __decorate([
|
|
33
16
|
Component({
|
|
@@ -38,20 +21,20 @@ PaginationControlsComponent = __decorate([
|
|
|
38
21
|
@if (vm(); as vm) {
|
|
39
22
|
<nav class="ogrid-pagination" role="navigation" aria-label="Pagination">
|
|
40
23
|
<span class="ogrid-pagination__info">
|
|
41
|
-
Showing {{ vm.startItem }} to {{ vm.endItem }} of {{ totalCount
|
|
24
|
+
Showing {{ vm.startItem }} to {{ vm.endItem }} of {{ totalCount.toLocaleString() }} {{ entityLabelPlural }}
|
|
42
25
|
</span>
|
|
43
26
|
|
|
44
27
|
<span class="ogrid-pagination__pages">
|
|
45
28
|
<button
|
|
46
29
|
class="ogrid-pagination__btn"
|
|
47
|
-
[disabled]="currentPage
|
|
30
|
+
[disabled]="currentPage === 1"
|
|
48
31
|
(click)="pageChange.emit(1)"
|
|
49
32
|
aria-label="First page"
|
|
50
33
|
>«</button>
|
|
51
34
|
<button
|
|
52
35
|
class="ogrid-pagination__btn"
|
|
53
|
-
[disabled]="currentPage
|
|
54
|
-
(click)="pageChange.emit(currentPage
|
|
36
|
+
[disabled]="currentPage === 1"
|
|
37
|
+
(click)="pageChange.emit(currentPage - 1)"
|
|
55
38
|
aria-label="Previous page"
|
|
56
39
|
>‹</button>
|
|
57
40
|
|
|
@@ -63,10 +46,10 @@ PaginationControlsComponent = __decorate([
|
|
|
63
46
|
@for (pageNum of vm.pageNumbers; track pageNum) {
|
|
64
47
|
<button
|
|
65
48
|
class="ogrid-pagination__btn"
|
|
66
|
-
[class.ogrid-pagination__btn--active]="currentPage
|
|
49
|
+
[class.ogrid-pagination__btn--active]="currentPage === pageNum"
|
|
67
50
|
(click)="pageChange.emit(pageNum)"
|
|
68
51
|
[attr.aria-label]="'Page ' + pageNum"
|
|
69
|
-
[attr.aria-current]="currentPage
|
|
52
|
+
[attr.aria-current]="currentPage === pageNum ? 'page' : null"
|
|
70
53
|
>{{ pageNum }}</button>
|
|
71
54
|
}
|
|
72
55
|
|
|
@@ -81,13 +64,13 @@ PaginationControlsComponent = __decorate([
|
|
|
81
64
|
|
|
82
65
|
<button
|
|
83
66
|
class="ogrid-pagination__btn"
|
|
84
|
-
[disabled]="currentPage
|
|
85
|
-
(click)="pageChange.emit(currentPage
|
|
67
|
+
[disabled]="currentPage >= vm.totalPages"
|
|
68
|
+
(click)="pageChange.emit(currentPage + 1)"
|
|
86
69
|
aria-label="Next page"
|
|
87
70
|
>›</button>
|
|
88
71
|
<button
|
|
89
72
|
class="ogrid-pagination__btn"
|
|
90
|
-
[disabled]="currentPage
|
|
73
|
+
[disabled]="currentPage >= vm.totalPages"
|
|
91
74
|
(click)="pageChange.emit(vm.totalPages)"
|
|
92
75
|
aria-label="Last page"
|
|
93
76
|
>»</button>
|
|
@@ -96,12 +79,12 @@ PaginationControlsComponent = __decorate([
|
|
|
96
79
|
<span class="ogrid-pagination__size">
|
|
97
80
|
<label>Rows
|
|
98
81
|
<select
|
|
99
|
-
[value]="pageSize
|
|
82
|
+
[value]="pageSize"
|
|
100
83
|
(change)="onPageSizeSelect($event)"
|
|
101
84
|
aria-label="Rows per page"
|
|
102
85
|
>
|
|
103
86
|
@for (n of vm.pageSizeOptions; track n) {
|
|
104
|
-
<option [value]="n" [selected]="pageSize
|
|
87
|
+
<option [value]="n" [selected]="pageSize === n">{{ n }}</option>
|
|
105
88
|
}
|
|
106
89
|
</select>
|
|
107
90
|
</label>
|