@alaarab/ogrid-angular-primeng 2.2.0 → 2.4.0

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { INLINE_CELL_EDITOR_STYLES, INLINE_CELL_EDITOR_TEMPLATE, POPOVER_CELL_EDITOR_OVERLAY_STYLES, POPOVER_CELL_EDITOR_TEMPLATE, OGRID_THEME_VARS_CSS, DataGridStateService, ColumnReorderService, VirtualScrollService, StatusBarComponent, GridContextMenuComponent, MarchingAntsOverlayComponent, EmptyStateComponent, OGridService, OGridLayoutComponent, BaseColumnHeaderFilterComponent, getColumnHeaderMenuItems, BaseInlineCellEditorComponent, BasePopoverCellEditorComponent, BaseDataGridTableComponent, DEFAULT_MIN_COLUMN_WIDTH, BaseColumnChooserComponent, BasePaginationControlsComponent } from '@alaarab/ogrid-angular';
1
+ import { INLINE_CELL_EDITOR_STYLES, INLINE_CELL_EDITOR_TEMPLATE, POPOVER_CELL_EDITOR_OVERLAY_STYLES, POPOVER_CELL_EDITOR_TEMPLATE, OGRID_THEME_VARS_CSS, DataGridStateService, ColumnReorderService, VirtualScrollService, StatusBarComponent, GridContextMenuComponent, MarchingAntsOverlayComponent, EmptyStateComponent, FormulaRefOverlayComponent, OGridService, OGridLayoutComponent, BaseColumnHeaderFilterComponent, BaseColumnHeaderMenuComponent, BaseInlineCellEditorComponent, BasePopoverCellEditorComponent, BaseDataGridTableComponent, DEFAULT_MIN_COLUMN_WIDTH, formatCellReference, indexToColumnLetter, BaseColumnChooserComponent, BasePaginationControlsComponent } from '@alaarab/ogrid-angular';
2
2
  export { AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX, BaseColumnChooserComponent, BaseColumnHeaderFilterComponent, BaseDataGridTableComponent, BaseInlineCellEditorComponent, BaseOGridComponent, BasePaginationControlsComponent, BasePopoverCellEditorComponent, CELL_PADDING, CHECKBOX_COLUMN_WIDTH, COLUMN_HEADER_MENU_ITEMS, ColumnReorderService, DEFAULT_DEBOUNCE_MS, DEFAULT_MIN_COLUMN_WIDTH, DataGridEditingHelper, DataGridInteractionHelper, DataGridLayoutHelper, DataGridStateService, EmptyStateComponent, GRID_BORDER_RADIUS, GRID_CONTEXT_MENU_ITEMS, GridContextMenuComponent, INLINE_CELL_EDITOR_STYLES, INLINE_CELL_EDITOR_TEMPLATE, MAX_PAGE_BUTTONS, MarchingAntsOverlayComponent, OGRID_THEME_VARS_CSS, OGridLayoutComponent, OGridService, PAGE_SIZE_OPTIONS, PEOPLE_SEARCH_DEBOUNCE_MS, POPOVER_CELL_EDITOR_OVERLAY_STYLES, POPOVER_CELL_EDITOR_TEMPLATE, ROW_NUMBER_COLUMN_WIDTH, SIDEBAR_TRANSITION_MS, SideBarComponent, StatusBarComponent, UndoRedoStack, VirtualScrollService, Z_INDEX, applyCellDeletion, applyCutClear, applyFillValues, applyPastedValues, applyRangeRowSelection, areGridRowPropsEqual, booleanParser, buildCsvHeader, buildCsvRows, buildHeaderRows, buildInlineEditorProps, buildPopoverEditorProps, calculateDropTarget, clampSelectionToBounds, computeAggregations, computeArrowNavigation, computeAutoScrollSpeed, computeNextSortState, computeRowSelectionState, computeTabNavigation, computeTotalHeight, computeVisibleRange, createDebouncedCallback, createDebouncedSignal, createLatestCallback, currencyParser, dateParser, debounce, deriveFilterOptionsFromData, emailParser, escapeCsvValue, exportToCsv, findCtrlArrowTarget, flattenColumns, formatCellValueForTsv, formatSelectionAsTsv, formatShortcut, getCellRenderDescriptor, getCellValue, getColumnHeaderMenuItems, getContextMenuHandlers, getDataGridStatusBarConfig, getFilterField, getHeaderFilterConfig, getMultiSelectFilterFields, getPaginationViewModel, getPinStateForColumn, getScrollTopForRow, getStatusBarParts, injectGlobalStyles, isFilterConfig, isInSelectionRange, isRowInRange, measureColumnContentWidth, measureRange, mergeFilter, normalizeSelectionRange, numberParser, parseTsvClipboard, parseValue, processClientSideData, rangesEqual, reorderColumnArray, resolveCellDisplayContent, resolveCellStyle, toUserLike, triggerCsvDownload, validateColumns, validateRowIds } from '@alaarab/ogrid-angular';
3
3
  import { ViewChild, Component, ChangeDetectionStrategy, Input, ViewEncapsulation, inject, DestroyRef, effect, computed, signal } from '@angular/core';
4
4
  import { ButtonModule } from 'primeng/button';
@@ -256,47 +256,16 @@ ColumnHeaderFilterComponent = __decorateClass([
256
256
  `]
257
257
  })
258
258
  ], ColumnHeaderFilterComponent);
259
- var ColumnHeaderMenuComponent = class {
259
+ var ColumnHeaderMenuComponent = class extends BaseColumnHeaderMenuComponent {
260
260
  constructor() {
261
- this.canPinLeft = true;
262
- this.canPinRight = true;
263
- this.canUnpin = false;
264
- this.currentSort = null;
265
- this.isSortable = true;
266
- this.isResizable = true;
267
- this.handlers = {};
261
+ super(...arguments);
268
262
  this.menuModel = computed(() => {
269
- const items = getColumnHeaderMenuItems({
270
- canPinLeft: this.canPinLeft,
271
- canPinRight: this.canPinRight,
272
- canUnpin: this.canUnpin,
273
- currentSort: this.currentSort,
274
- isSortable: this.isSortable,
275
- isResizable: this.isResizable
276
- });
277
- const h = this.handlers;
278
- const actionMap = {
279
- pinLeft: h.onPinLeft,
280
- pinRight: h.onPinRight,
281
- unpin: h.onUnpin,
282
- sortAsc: h.onSortAsc,
283
- sortDesc: h.onSortDesc,
284
- clearSort: h.onClearSort,
285
- autosizeThis: h.onAutosizeThis,
286
- autosizeAll: h.onAutosizeAll
287
- };
288
263
  const result = [];
289
- for (const item of items) {
264
+ for (const item of this.menuItems()) {
290
265
  result.push({
291
266
  label: item.label,
292
267
  disabled: item.disabled,
293
- command: () => {
294
- const action = actionMap[item.id];
295
- if (action) {
296
- action();
297
- h.onClose?.();
298
- }
299
- }
268
+ command: () => this.handleMenuItemClick(item.id)
300
269
  });
301
270
  if (item.divider) {
302
271
  result.push({ separator: true });
@@ -306,30 +275,6 @@ var ColumnHeaderMenuComponent = class {
306
275
  });
307
276
  }
308
277
  };
309
- __decorateClass([
310
- Input({ required: true })
311
- ], ColumnHeaderMenuComponent.prototype, "columnId", 2);
312
- __decorateClass([
313
- Input()
314
- ], ColumnHeaderMenuComponent.prototype, "canPinLeft", 2);
315
- __decorateClass([
316
- Input()
317
- ], ColumnHeaderMenuComponent.prototype, "canPinRight", 2);
318
- __decorateClass([
319
- Input()
320
- ], ColumnHeaderMenuComponent.prototype, "canUnpin", 2);
321
- __decorateClass([
322
- Input()
323
- ], ColumnHeaderMenuComponent.prototype, "currentSort", 2);
324
- __decorateClass([
325
- Input()
326
- ], ColumnHeaderMenuComponent.prototype, "isSortable", 2);
327
- __decorateClass([
328
- Input()
329
- ], ColumnHeaderMenuComponent.prototype, "isResizable", 2);
330
- __decorateClass([
331
- Input()
332
- ], ColumnHeaderMenuComponent.prototype, "handlers", 2);
333
278
  __decorateClass([
334
279
  ViewChild("menu")
335
280
  ], ColumnHeaderMenuComponent.prototype, "menuRef", 2);
@@ -443,6 +388,10 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
443
388
  this.ariaLabelInput = void 0;
444
389
  this.ariaLabelledByInput = void 0;
445
390
  this.showRowNumbers = false;
391
+ this.showColumnLettersInput = false;
392
+ this.showNameBoxInput = false;
393
+ this.onActiveCellChange = void 0;
394
+ this.formulaReferencesInput = void 0;
446
395
  this.currentPageInput = 1;
447
396
  this.pageSizeInput = 25;
448
397
  this.defaultMinWidth = DEFAULT_MIN_COLUMN_WIDTH;
@@ -467,6 +416,8 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
467
416
  this.resizeStartWidth = 0;
468
417
  // Bound method reference for template
469
418
  this.cancelEditHandler = () => this.cancelEdit();
419
+ this.showColumnLetters = computed(() => !!this.getProps()?.showColumnLetters);
420
+ this.formulaReferences = computed(() => this.getProps()?.formulaReferences);
470
421
  // --- PrimeNG-specific computed signals ---
471
422
  this.resolvedAriaLabel = computed(
472
423
  () => this.ariaLabelInput ?? (this.ariaLabelledByInput ? void 0 : "Data grid")
@@ -484,6 +435,19 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
484
435
  return "100%";
485
436
  });
486
437
  this.initBase();
438
+ effect(() => {
439
+ const props = this.getProps();
440
+ const onActiveCellChange = props?.onActiveCellChange;
441
+ if (!onActiveCellChange) return;
442
+ const ac = this.activeCell();
443
+ if (ac) {
444
+ const colIndex = ac.columnIndex - this.colOffset();
445
+ const rowNumber = ac.rowIndex + 1;
446
+ onActiveCellChange(formatCellReference(colIndex, rowNumber));
447
+ } else {
448
+ onActiveCellChange(null);
449
+ }
450
+ });
487
451
  }
488
452
  ngOnChanges(changes) {
489
453
  if (changes["initialColumnWidths"]) {
@@ -607,6 +571,9 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
607
571
  selectedRows: this.selectedRows,
608
572
  onSelectionChange: this.onSelectionChange,
609
573
  showRowNumbers: this.showRowNumbers,
574
+ showColumnLetters: this.showColumnLettersInput,
575
+ showNameBox: this.showNameBoxInput,
576
+ onActiveCellChange: this.onActiveCellChange,
610
577
  currentPage: this.currentPageInput,
611
578
  pageSize: this.pageSizeInput,
612
579
  statusBar: this.statusBar,
@@ -620,9 +587,13 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
620
587
  onCellError: this.onCellError,
621
588
  stickyHeader: this.stickyHeaderInput,
622
589
  "aria-label": this.ariaLabelInput,
623
- "aria-labelledby": this.ariaLabelledByInput
590
+ "aria-labelledby": this.ariaLabelledByInput,
591
+ formulaReferences: this.formulaReferencesInput
624
592
  };
625
593
  }
594
+ getColumnLetter(colIdx) {
595
+ return indexToColumnLetter(colIdx);
596
+ }
626
597
  };
627
598
  __decorateClass([
628
599
  ViewChild("wrapper")
@@ -753,6 +724,18 @@ __decorateClass([
753
724
  __decorateClass([
754
725
  Input()
755
726
  ], DataGridTableComponent.prototype, "showRowNumbers", 2);
727
+ __decorateClass([
728
+ Input({ alias: "showColumnLetters" })
729
+ ], DataGridTableComponent.prototype, "showColumnLettersInput", 2);
730
+ __decorateClass([
731
+ Input({ alias: "showNameBox" })
732
+ ], DataGridTableComponent.prototype, "showNameBoxInput", 2);
733
+ __decorateClass([
734
+ Input()
735
+ ], DataGridTableComponent.prototype, "onActiveCellChange", 2);
736
+ __decorateClass([
737
+ Input({ alias: "formulaReferences" })
738
+ ], DataGridTableComponent.prototype, "formulaReferencesInput", 2);
756
739
  __decorateClass([
757
740
  Input({ alias: "currentPage" })
758
741
  ], DataGridTableComponent.prototype, "currentPageInput", 2);
@@ -768,6 +751,7 @@ DataGridTableComponent = __decorateClass([
768
751
  GridContextMenuComponent,
769
752
  MarchingAntsOverlayComponent,
770
753
  EmptyStateComponent,
754
+ FormulaRefOverlayComponent,
771
755
  ColumnHeaderFilterComponent,
772
756
  ColumnHeaderMenuComponent,
773
757
  InlineCellEditorComponent,
@@ -802,6 +786,21 @@ DataGridTableComponent = __decorateClass([
802
786
  <div #tableContainer class="ogrid-table-wrapper">
803
787
  <table class="ogrid-table" role="grid" [attr.data-virtual-scroll]="vsEnabled() ? '' : null">
804
788
  <thead [class]="stickyHeader() ? 'ogrid-thead ogrid-sticky-header' : 'ogrid-thead'">
789
+ @if (showColumnLetters()) {
790
+ <tr class="ogrid-column-letter-row">
791
+ @if (hasCheckboxCol()) {
792
+ <th class="ogrid-column-letter-cell"></th>
793
+ }
794
+ @if (hasRowNumbersCol()) {
795
+ <th class="ogrid-column-letter-cell"></th>
796
+ }
797
+ @for (col of visibleCols(); track col.columnId; let colIdx = $index) {
798
+ <th class="ogrid-column-letter-cell">
799
+ {{ getColumnLetter(colIdx) }}
800
+ </th>
801
+ }
802
+ </tr>
803
+ }
805
804
  @for (row of headerRows(); track $index; let rowIdx = $index) {
806
805
  <tr>
807
806
  @if (rowIdx === headerRows().length - 1 && hasCheckboxCol()) {
@@ -983,16 +982,20 @@ DataGridTableComponent = __decorateClass([
983
982
  <div
984
983
  [attr.data-row-index]="rowIndex"
985
984
  [attr.data-col-index]="descriptor.globalColIndex"
985
+ [attr.data-active-cell]="descriptor.isActive ? 'true' : null"
986
+ [attr.data-in-range]="descriptor.isInRange ? 'true' : null"
987
+ [attr.tabindex]="descriptor.isActive ? 0 : -1"
986
988
  (mousedown)="onCellMouseDown($event, rowIndex, descriptor.globalColIndex)"
989
+ (click)="onCellClick(rowIndex, descriptor.globalColIndex)"
987
990
  (dblclick)="descriptor.canEditAny ? onCellDblClick(descriptor.rowId, col.columnId) : null"
988
991
  (contextmenu)="onCellContextMenu($event)"
989
992
  class="ogrid-cell-content"
990
993
  [style.cursor]="descriptor.canEditAny ? 'cell' : 'default'"
991
- [style.background]="descriptor.isInRange && !descriptor.isActive ? 'var(--ogrid-range-bg, rgba(33, 115, 70, 0.08))' : null"
992
- [style.outline]="descriptor.isActive ? '2px solid var(--ogrid-selection, #217346)' : null"
993
- [style.outline-offset]="descriptor.isActive ? '-2px' : null"
994
+ [style.background]="descriptor.isInRange && !descriptor.isActive ? 'var(--ogrid-range-bg, rgba(33, 115, 70, 0.08))' : (descriptor.isActive && descriptor.isInRange ? 'var(--ogrid-bg, #fff)' : null)"
995
+ [style.outline]="descriptor.isActive && !descriptor.isInRange ? '2px solid var(--ogrid-selection, #217346)' : null"
996
+ [style.outline-offset]="descriptor.isActive && !descriptor.isInRange ? '-2px' : null"
994
997
  >
995
- <span [style]="resolveCellStyleFn(col, item)">{{ resolveCellContent(col, item, descriptor.displayValue) }}</span>
998
+ <span [style]="resolveCellStyleFn(col, item, descriptor.displayValue)">{{ resolveCellContent(col, item, descriptor.displayValue) }}</span>
996
999
  @if (descriptor.canEditAny && descriptor.isSelectionEndCell) {
997
1000
  <div
998
1001
  (mousedown)="onFillHandleMouseDown($event)"
@@ -1028,6 +1031,14 @@ DataGridTableComponent = __decorateClass([
1028
1031
  [columnOrder]="propsColumnOrder()"
1029
1032
  ></ogrid-marching-ants-overlay>
1030
1033
 
1034
+ @if (formulaReferences() && formulaReferences()!.length > 0) {
1035
+ <ogrid-formula-ref-overlay
1036
+ [containerEl]="tableContainerEl()"
1037
+ [references]="formulaReferences()!"
1038
+ [colOffset]="colOffset()"
1039
+ />
1040
+ }
1041
+
1031
1042
  @if (showEmptyInGrid() && emptyState()) {
1032
1043
  <div class="ogrid-empty-container">
1033
1044
  <div>
@@ -1402,6 +1413,17 @@ DataGridTableComponent = __decorateClass([
1402
1413
  border-color: var(--ogrid-border, rgba(0, 0, 0, 0.12));
1403
1414
  margin: 4px 0;
1404
1415
  }
1416
+ .ogrid-column-letter-cell {
1417
+ text-align: center;
1418
+ font-size: 11px;
1419
+ font-weight: 500;
1420
+ color: var(--ogrid-fg-muted, rgba(0, 0, 0, 0.4));
1421
+ padding: 2px 4px;
1422
+ background: var(--ogrid-column-letter-bg, var(--ogrid-header-bg, #f5f5f5));
1423
+ border-bottom: 1px solid var(--ogrid-border, rgba(0, 0, 0, 0.12));
1424
+ user-select: none;
1425
+ font-variant-numeric: tabular-nums;
1426
+ }
1405
1427
  `]
1406
1428
  })
1407
1429
  ], DataGridTableComponent);
@@ -1632,6 +1654,13 @@ OGridComponent = __decorateClass([
1632
1654
  [hasPagination]="true"
1633
1655
  [sideBar]="service.sideBarProps()"
1634
1656
  [fullScreen]="service.fullScreen()"
1657
+ [showNameBox]="!!(service.cellReferences() && !service.formulasEnabled())"
1658
+ [activeCellRef]="service.activeCellRef()"
1659
+ [formulaBar]="service.formulasEnabled() ? service.formulaBarState() : null"
1660
+ [sheetDefs]="service.sheetDefs()"
1661
+ [activeSheet]="service.activeSheet()"
1662
+ [onSheetChange]="service.onSheetChange()"
1663
+ [onSheetAdd]="service.onSheetAdd()"
1635
1664
  >
1636
1665
  <ng-content select="[toolbar]" toolbar></ng-content>
1637
1666
 
@@ -1682,6 +1711,11 @@ OGridComponent = __decorateClass([
1682
1711
  [aria-label]="service.ariaLabel()"
1683
1712
  [aria-labelledby]="service.ariaLabelledBy()"
1684
1713
  [emptyState]="emptyStateObj"
1714
+ [showRowNumbers]="service.dataGridProps().showRowNumbers ?? false"
1715
+ [showColumnLetters]="service.dataGridProps().showColumnLetters ?? false"
1716
+ [showNameBox]="service.dataGridProps().showNameBox ?? false"
1717
+ [onActiveCellChange]="service.dataGridProps().onActiveCellChange"
1718
+ [formulaReferences]="service.dataGridProps().formulaReferences"
1685
1719
  ></ogrid-primeng-datagrid-table>
1686
1720
 
1687
1721
  <div pagination>
@@ -1,19 +1,7 @@
1
1
  import type { Menu } from 'primeng/menu';
2
2
  import type { MenuItem } from 'primeng/api';
3
- import { type ColumnHeaderMenuHandlers } from '@alaarab/ogrid-angular';
4
- /**
5
- * Column header dropdown menu for pin/unpin, sort, and autosize actions.
6
- * Uses PrimeNG Menu component.
7
- */
8
- export declare class ColumnHeaderMenuComponent {
9
- columnId: string;
10
- canPinLeft: boolean;
11
- canPinRight: boolean;
12
- canUnpin: boolean;
13
- currentSort: 'asc' | 'desc' | null;
14
- isSortable: boolean;
15
- isResizable: boolean;
16
- handlers: Partial<ColumnHeaderMenuHandlers>;
3
+ import { BaseColumnHeaderMenuComponent } from '@alaarab/ogrid-angular';
4
+ export declare class ColumnHeaderMenuComponent extends BaseColumnHeaderMenuComponent {
17
5
  menuRef?: Menu;
18
6
  readonly menuModel: import("@angular/core").Signal<MenuItem[]>;
19
7
  }
@@ -59,6 +59,10 @@ export declare class DataGridTableComponent<T = unknown> extends BaseDataGridTab
59
59
  ariaLabelInput: string | undefined;
60
60
  ariaLabelledByInput: string | undefined;
61
61
  showRowNumbers: boolean;
62
+ showColumnLettersInput: boolean;
63
+ showNameBoxInput: boolean;
64
+ onActiveCellChange: ((ref: string | null) => void) | undefined;
65
+ formulaReferencesInput: import('@alaarab/ogrid-core').FormulaReference[] | undefined;
62
66
  currentPageInput: number;
63
67
  pageSizeInput: number;
64
68
  readonly defaultMinWidth = 80;
@@ -81,6 +85,8 @@ export declare class DataGridTableComponent<T = unknown> extends BaseDataGridTab
81
85
  private resizeColumnId;
82
86
  private resizeStartWidth;
83
87
  readonly cancelEditHandler: () => void;
88
+ readonly showColumnLetters: import("@angular/core").Signal<boolean>;
89
+ readonly formulaReferences: import("@angular/core").Signal<import("@alaarab/ogrid-core").FormulaReference[] | undefined>;
84
90
  constructor();
85
91
  ngOnChanges(changes: SimpleChanges): void;
86
92
  /** Shallow-compare two props objects by their top-level keys. */
@@ -98,4 +104,5 @@ export declare class DataGridTableComponent<T = unknown> extends BaseDataGridTab
98
104
  onRowCheckboxChangePrimeng(item: T, checked: boolean, rowIndex: number, _e: Event): void;
99
105
  onResizeStartPrimeng(e: MouseEvent, col: IColumnDef<T>): void;
100
106
  private buildProps;
107
+ getColumnLetter(colIdx: number): string;
101
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-angular-primeng",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
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",
@@ -37,7 +37,7 @@
37
37
  "node": ">=18"
38
38
  },
39
39
  "dependencies": {
40
- "@alaarab/ogrid-angular": "2.2.0"
40
+ "@alaarab/ogrid-angular": "2.4.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@angular/core": "^21.0.0",