@alaarab/ogrid-angular-primeng 2.0.2 → 2.0.3
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.
|
@@ -6,12 +6,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Component, input, inject, signal, computed, effect, viewChild, ChangeDetectionStrategy, } from '@angular/core';
|
|
8
8
|
import { CommonModule } from '@angular/common';
|
|
9
|
-
import { DataGridStateService, StatusBarComponent, GridContextMenuComponent, MarchingAntsOverlayComponent, EmptyStateComponent, DEFAULT_MIN_COLUMN_WIDTH, buildHeaderRows, getCellValue, } from '@alaarab/ogrid-angular';
|
|
9
|
+
import { DataGridStateService, ColumnReorderService, VirtualScrollService, StatusBarComponent, GridContextMenuComponent, MarchingAntsOverlayComponent, EmptyStateComponent, DEFAULT_MIN_COLUMN_WIDTH, buildHeaderRows, getCellValue, getHeaderFilterConfig, resolveCellDisplayContent, resolveCellStyle, } from '@alaarab/ogrid-angular';
|
|
10
10
|
import { ColumnHeaderFilterComponent } from '../column-header-filter/column-header-filter.component';
|
|
11
11
|
import { InlineCellEditorComponent } from './inline-cell-editor.component';
|
|
12
12
|
let DataGridTableComponent = class DataGridTableComponent {
|
|
13
13
|
constructor() {
|
|
14
14
|
this.stateService = inject(DataGridStateService);
|
|
15
|
+
this.columnReorderService = new ColumnReorderService();
|
|
16
|
+
this.virtualScrollService = new VirtualScrollService();
|
|
15
17
|
this.wrapperRef = viewChild('wrapper');
|
|
16
18
|
this.tableContainerRef = viewChild('tableContainer');
|
|
17
19
|
// Inputs mapped from IOGridDataGridProps
|
|
@@ -113,6 +115,19 @@ let DataGridTableComponent = class DataGridTableComponent {
|
|
|
113
115
|
effect(() => {
|
|
114
116
|
const el = this.wrapperRef()?.nativeElement ?? null;
|
|
115
117
|
this.stateService.wrapperEl.set(el);
|
|
118
|
+
this.columnReorderService.wrapperEl.set(el);
|
|
119
|
+
});
|
|
120
|
+
// Wire column reorder service inputs
|
|
121
|
+
effect(() => {
|
|
122
|
+
const cols = this.state().layout.visibleCols;
|
|
123
|
+
this.columnReorderService.columns.set(cols);
|
|
124
|
+
this.columnReorderService.columnOrder.set(this.columnOrder());
|
|
125
|
+
this.columnReorderService.onColumnOrderChange.set(this.onColumnOrderChange());
|
|
126
|
+
this.columnReorderService.enabled.set(!!this.onColumnOrderChange());
|
|
127
|
+
});
|
|
128
|
+
// Wire virtual scroll service inputs
|
|
129
|
+
effect(() => {
|
|
130
|
+
this.virtualScrollService.totalRows.set(this.items().length);
|
|
116
131
|
});
|
|
117
132
|
// Initialize column sizing from initial widths
|
|
118
133
|
effect(() => {
|
|
@@ -133,79 +148,17 @@ let DataGridTableComponent = class DataGridTableComponent {
|
|
|
133
148
|
}
|
|
134
149
|
getFilterConfig(col) {
|
|
135
150
|
const s = this.state();
|
|
136
|
-
|
|
137
|
-
const filterable = col.filterable && typeof col.filterable === 'object' ? col.filterable : null;
|
|
138
|
-
const filterType = filterable?.type ?? 'none';
|
|
139
|
-
const filterField = filterable?.filterField ?? col.columnId;
|
|
140
|
-
const sortable = col.sortable !== false;
|
|
141
|
-
const filterValue = hfi.filters[filterField];
|
|
142
|
-
const base = {
|
|
143
|
-
filterType,
|
|
144
|
-
isSorted: hfi.sortBy === col.columnId,
|
|
145
|
-
isSortedDescending: hfi.sortBy === col.columnId && hfi.sortDirection === 'desc',
|
|
146
|
-
onSort: sortable ? () => hfi.onColumnSort(col.columnId) : undefined,
|
|
147
|
-
};
|
|
148
|
-
if (filterType === 'text') {
|
|
149
|
-
return {
|
|
150
|
-
...base,
|
|
151
|
-
textValue: filterValue?.type === 'text' ? filterValue.value : '',
|
|
152
|
-
onTextChange: (v) => hfi.onFilterChange(filterField, v.trim() ? { type: 'text', value: v } : undefined),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
if (filterType === 'multiSelect') {
|
|
156
|
-
return {
|
|
157
|
-
...base,
|
|
158
|
-
options: hfi.filterOptions[filterField] ?? [],
|
|
159
|
-
isLoadingOptions: hfi.loadingFilterOptions[filterField] ?? false,
|
|
160
|
-
selectedValues: filterValue?.type === 'multiSelect' ? filterValue.value : [],
|
|
161
|
-
onFilterChange: (values) => hfi.onFilterChange(filterField, values.length ? { type: 'multiSelect', value: values } : undefined),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
if (filterType === 'people') {
|
|
165
|
-
return {
|
|
166
|
-
...base,
|
|
167
|
-
selectedUser: filterValue?.type === 'people' ? filterValue.value : undefined,
|
|
168
|
-
onUserChange: (u) => hfi.onFilterChange(filterField, u ? { type: 'people', value: u } : undefined),
|
|
169
|
-
peopleSearch: hfi.peopleSearch,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
if (filterType === 'date') {
|
|
173
|
-
return {
|
|
174
|
-
...base,
|
|
175
|
-
dateValue: filterValue?.type === 'date' ? filterValue.value : undefined,
|
|
176
|
-
onDateChange: (v) => hfi.onFilterChange(filterField, v ? { type: 'date', value: v } : undefined),
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
return base;
|
|
151
|
+
return getHeaderFilterConfig(col, s.viewModels.headerFilterInput);
|
|
180
152
|
}
|
|
181
153
|
getCellValueFn(item, col) {
|
|
182
154
|
return getCellValue(item, col);
|
|
183
155
|
}
|
|
184
156
|
resolveCellDisplay(col, item) {
|
|
185
|
-
if (col.renderCell && typeof col.renderCell === 'function') {
|
|
186
|
-
const result = col.renderCell(item);
|
|
187
|
-
return result ?? '';
|
|
188
|
-
}
|
|
189
157
|
const value = getCellValue(item, col);
|
|
190
|
-
|
|
191
|
-
return String(col.valueFormatter(value, item) ?? '');
|
|
192
|
-
if (value == null)
|
|
193
|
-
return '';
|
|
194
|
-
if (col.type === 'date') {
|
|
195
|
-
const d = new Date(String(value));
|
|
196
|
-
if (!Number.isNaN(d.getTime()))
|
|
197
|
-
return d.toLocaleDateString();
|
|
198
|
-
}
|
|
199
|
-
if (col.type === 'boolean')
|
|
200
|
-
return value ? 'True' : 'False';
|
|
201
|
-
return String(value);
|
|
158
|
+
return resolveCellDisplayContent(col, item, value);
|
|
202
159
|
}
|
|
203
160
|
getCellStyleObj(col, item) {
|
|
204
|
-
|
|
205
|
-
return null;
|
|
206
|
-
return typeof col.cellStyle === 'function'
|
|
207
|
-
? col.cellStyle(item)
|
|
208
|
-
: col.cellStyle;
|
|
161
|
+
return resolveCellStyle(col, item) ?? null;
|
|
209
162
|
}
|
|
210
163
|
canEditCell(col, item) {
|
|
211
164
|
const colEditable = col.editable === true || (typeof col.editable === 'function' && col.editable(item));
|
|
@@ -297,6 +250,9 @@ let DataGridTableComponent = class DataGridTableComponent {
|
|
|
297
250
|
handlePaste() {
|
|
298
251
|
void this.state().interaction.handlePaste();
|
|
299
252
|
}
|
|
253
|
+
onHeaderMouseDown(columnId, event) {
|
|
254
|
+
this.columnReorderService.handleHeaderMouseDown(columnId, event);
|
|
255
|
+
}
|
|
300
256
|
onResizeStart(e, col) {
|
|
301
257
|
e.preventDefault();
|
|
302
258
|
this.resizeStartX = e.clientX;
|
|
@@ -451,6 +407,8 @@ DataGridTableComponent = __decorate([
|
|
|
451
407
|
[style.min-width.px]="cell.columnDef!.minWidth ?? defaultMinWidth"
|
|
452
408
|
[style.width.px]="getColumnWidth(cell.columnDef!)"
|
|
453
409
|
[style.max-width.px]="getColumnWidth(cell.columnDef!)"
|
|
410
|
+
[style.cursor]="columnReorderService.isDragging() ? 'grabbing' : 'grab'"
|
|
411
|
+
(mousedown)="onHeaderMouseDown(cell.columnDef!.columnId, $event)"
|
|
454
412
|
>
|
|
455
413
|
<ogrid-primeng-column-header-filter
|
|
456
414
|
[columnKey]="cell.columnDef!.columnId"
|
|
@@ -581,6 +539,10 @@ DataGridTableComponent = __decorate([
|
|
|
581
539
|
</div>
|
|
582
540
|
</div>
|
|
583
541
|
|
|
542
|
+
@if (columnReorderService.isDragging() && columnReorderService.dropIndicatorX() !== null) {
|
|
543
|
+
<div class="ogrid-drop-indicator" [style.left.px]="columnReorderService.dropIndicatorX()"></div>
|
|
544
|
+
}
|
|
545
|
+
|
|
584
546
|
@if (state().contextMenu.menuPosition) {
|
|
585
547
|
<ogrid-context-menu
|
|
586
548
|
[x]="state().contextMenu.menuPosition!.x"
|
|
@@ -627,6 +589,16 @@ DataGridTableComponent = __decorate([
|
|
|
627
589
|
opacity: 0.5;
|
|
628
590
|
pointer-events: none;
|
|
629
591
|
}
|
|
592
|
+
.ogrid-drop-indicator {
|
|
593
|
+
position: absolute;
|
|
594
|
+
top: 0;
|
|
595
|
+
bottom: 0;
|
|
596
|
+
width: 3px;
|
|
597
|
+
background: var(--ogrid-primary, #217346);
|
|
598
|
+
pointer-events: none;
|
|
599
|
+
z-index: 100;
|
|
600
|
+
transition: left 0.05s;
|
|
601
|
+
}
|
|
630
602
|
`],
|
|
631
603
|
})
|
|
632
604
|
], DataGridTableComponent);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ElementRef } from '@angular/core';
|
|
2
|
-
import
|
|
2
|
+
import { ColumnReorderService, VirtualScrollService } from '@alaarab/ogrid-angular';
|
|
3
|
+
import type { IColumnDef, IColumnGroupDef, RowId, HeaderFilterConfig } from '@alaarab/ogrid-angular';
|
|
3
4
|
export declare class DataGridTableComponent<T = unknown> {
|
|
4
5
|
private readonly stateService;
|
|
6
|
+
readonly columnReorderService: ColumnReorderService<T>;
|
|
7
|
+
readonly virtualScrollService: VirtualScrollService;
|
|
5
8
|
readonly wrapperRef: import("@angular/core").Signal<ElementRef<HTMLDivElement> | undefined>;
|
|
6
9
|
readonly tableContainerRef: import("@angular/core").Signal<ElementRef<HTMLDivElement> | undefined>;
|
|
7
10
|
readonly items: import("@angular/core").InputSignal<T[]>;
|
|
@@ -81,29 +84,7 @@ export declare class DataGridTableComponent<T = unknown> {
|
|
|
81
84
|
readonly selectedCellCount: import("@angular/core").Signal<number | undefined>;
|
|
82
85
|
trackByRowId(_index: number, item: T): RowId;
|
|
83
86
|
getColumnWidth(col: IColumnDef<T>): number | undefined;
|
|
84
|
-
getFilterConfig(col: IColumnDef<T>):
|
|
85
|
-
filterType: string;
|
|
86
|
-
isSorted?: boolean;
|
|
87
|
-
isSortedDescending?: boolean;
|
|
88
|
-
onSort?: () => void;
|
|
89
|
-
selectedValues?: string[];
|
|
90
|
-
onFilterChange?: (values: string[]) => void;
|
|
91
|
-
options?: string[];
|
|
92
|
-
isLoadingOptions?: boolean;
|
|
93
|
-
textValue?: string;
|
|
94
|
-
onTextChange?: (value: string) => void;
|
|
95
|
-
selectedUser?: unknown;
|
|
96
|
-
onUserChange?: (user: unknown) => void;
|
|
97
|
-
peopleSearch?: (query: string) => Promise<unknown[]>;
|
|
98
|
-
dateValue?: {
|
|
99
|
-
from?: string;
|
|
100
|
-
to?: string;
|
|
101
|
-
};
|
|
102
|
-
onDateChange?: (value: {
|
|
103
|
-
from?: string;
|
|
104
|
-
to?: string;
|
|
105
|
-
} | undefined) => void;
|
|
106
|
-
};
|
|
87
|
+
getFilterConfig(col: IColumnDef<T>): HeaderFilterConfig;
|
|
107
88
|
getCellValueFn(item: T, col: IColumnDef<T>): unknown;
|
|
108
89
|
resolveCellDisplay(col: IColumnDef<T>, item: T): string;
|
|
109
90
|
getCellStyleObj(col: IColumnDef<T>, item: T): Record<string, string> | null;
|
|
@@ -125,6 +106,7 @@ export declare class DataGridTableComponent<T = unknown> {
|
|
|
125
106
|
onRowClick(e: MouseEvent, item: T): void;
|
|
126
107
|
onRowCheckboxChange(item: T, checked: boolean, rowIndex: number, e: Event): void;
|
|
127
108
|
handlePaste(): void;
|
|
109
|
+
onHeaderMouseDown(columnId: string, event: MouseEvent): void;
|
|
128
110
|
onResizeStart(e: MouseEvent, col: IColumnDef<T>): void;
|
|
129
111
|
private buildProps;
|
|
130
112
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alaarab/ogrid-angular-primeng",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "OGrid PrimeNG – PrimeNG Table-based data grid with sorting, filtering, pagination, column chooser, and CSV export.",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"files": ["dist", "README.md", "LICENSE"],
|
|
23
23
|
"engines": { "node": ">=18" },
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@alaarab/ogrid-angular": "2.0.
|
|
25
|
+
"@alaarab/ogrid-angular": "2.0.3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@angular/core": "^21.0.0",
|