@alaarab/ogrid-angular-primeng 2.3.0 → 2.4.1

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, formatCellReference, indexToColumnLetter, 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, ROW_NUMBER_COLUMN_ID, indexToColumnLetter, BaseColumnChooserComponent, BasePaginationControlsComponent, ROW_NUMBER_COLUMN_MIN_WIDTH } 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);
@@ -446,6 +391,7 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
446
391
  this.showColumnLettersInput = false;
447
392
  this.showNameBoxInput = false;
448
393
  this.onActiveCellChange = void 0;
394
+ this.formulaReferencesInput = void 0;
449
395
  this.currentPageInput = 1;
450
396
  this.pageSizeInput = 25;
451
397
  this.defaultMinWidth = DEFAULT_MIN_COLUMN_WIDTH;
@@ -471,6 +417,7 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
471
417
  // Bound method reference for template
472
418
  this.cancelEditHandler = () => this.cancelEdit();
473
419
  this.showColumnLetters = computed(() => !!this.getProps()?.showColumnLetters);
420
+ this.formulaReferences = computed(() => this.getProps()?.formulaReferences);
474
421
  // --- PrimeNG-specific computed signals ---
475
422
  this.resolvedAriaLabel = computed(
476
423
  () => this.ariaLabelInput ?? (this.ariaLabelledByInput ? void 0 : "Data grid")
@@ -568,10 +515,10 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
568
515
  this.getWrapperRef()?.nativeElement.focus({ preventScroll: true });
569
516
  this.resizeStartX = e.clientX;
570
517
  this.resizeColumnId = col.columnId;
571
- this.resizeStartWidth = this.getColumnWidth(col);
518
+ this.resizeStartWidth = col.columnId === ROW_NUMBER_COLUMN_ID ? this.getRowNumberWidth() : this.getColumnWidth(col);
572
519
  const onMove = (me) => {
573
520
  const delta = me.clientX - this.resizeStartX;
574
- const minW = col.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH;
521
+ const minW = col.columnId === ROW_NUMBER_COLUMN_ID ? ROW_NUMBER_COLUMN_MIN_WIDTH : col.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH;
575
522
  const newWidth = Math.max(minW, this.resizeStartWidth + delta);
576
523
  this.primengColumnSizingOverrides.update((prev) => ({ ...prev, [this.resizeColumnId]: newWidth }));
577
524
  this.columnSizingVersion.update((v) => v + 1);
@@ -592,6 +539,15 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
592
539
  window.addEventListener("mousemove", onMove, true);
593
540
  window.addEventListener("mouseup", onUp, true);
594
541
  }
542
+ onResizeRowNumber(event) {
543
+ event.stopPropagation();
544
+ this.onResizeStartPrimeng(event, { columnId: ROW_NUMBER_COLUMN_ID, name: "#" });
545
+ }
546
+ getRowNumberWidth() {
547
+ const override = this.primengColumnSizingOverrides()[ROW_NUMBER_COLUMN_ID];
548
+ if (override) return override;
549
+ return super.getRowNumberWidth();
550
+ }
595
551
  // --- Build props ---
596
552
  buildProps() {
597
553
  return {
@@ -640,7 +596,8 @@ var DataGridTableComponent = class extends BaseDataGridTableComponent {
640
596
  onCellError: this.onCellError,
641
597
  stickyHeader: this.stickyHeaderInput,
642
598
  "aria-label": this.ariaLabelInput,
643
- "aria-labelledby": this.ariaLabelledByInput
599
+ "aria-labelledby": this.ariaLabelledByInput,
600
+ formulaReferences: this.formulaReferencesInput
644
601
  };
645
602
  }
646
603
  getColumnLetter(colIdx) {
@@ -785,6 +742,9 @@ __decorateClass([
785
742
  __decorateClass([
786
743
  Input()
787
744
  ], DataGridTableComponent.prototype, "onActiveCellChange", 2);
745
+ __decorateClass([
746
+ Input({ alias: "formulaReferences" })
747
+ ], DataGridTableComponent.prototype, "formulaReferencesInput", 2);
788
748
  __decorateClass([
789
749
  Input({ alias: "currentPage" })
790
750
  ], DataGridTableComponent.prototype, "currentPageInput", 2);
@@ -800,6 +760,7 @@ DataGridTableComponent = __decorateClass([
800
760
  GridContextMenuComponent,
801
761
  MarchingAntsOverlayComponent,
802
762
  EmptyStateComponent,
763
+ FormulaRefOverlayComponent,
803
764
  ColumnHeaderFilterComponent,
804
765
  ColumnHeaderMenuComponent,
805
766
  InlineCellEditorComponent,
@@ -866,8 +827,17 @@ DataGridTableComponent = __decorateClass([
866
827
  <th [attr.rowSpan]="headerRows().length - 1"></th>
867
828
  }
868
829
  @if (rowIdx === headerRows().length - 1 && hasRowNumbersCol()) {
869
- <th scope="col" rowSpan="1" class="ogrid-row-number-header">
830
+ <th scope="col" rowSpan="1" class="ogrid-row-number-header"
831
+ [style.width.px]="getRowNumberWidth()"
832
+ [style.min-width.px]="getRowNumberWidth()"
833
+ [style.max-width.px]="getRowNumberWidth()"
834
+ >
870
835
  #
836
+ <div
837
+ class="ogrid-resize-handle"
838
+ (mousedown)="onResizeRowNumber($event)"
839
+ (dblclick)="$event.stopPropagation()"
840
+ ></div>
871
841
  </th>
872
842
  }
873
843
  @if (rowIdx === 0 && rowIdx < headerRows().length - 1 && hasRowNumbersCol()) {
@@ -980,8 +950,11 @@ DataGridTableComponent = __decorateClass([
980
950
  </td>
981
951
  }
982
952
  @if (hasRowNumbersCol()) {
983
- <td class="ogrid-row-number-cell">
984
-
953
+ <td class="ogrid-row-number-cell"
954
+ [style.width.px]="getRowNumberWidth()"
955
+ [style.min-width.px]="getRowNumberWidth()"
956
+ [style.max-width.px]="getRowNumberWidth()"
957
+ >
985
958
  {{ rowNumberOffset() + rowIndex + 1 }}
986
959
  </td>
987
960
  }
@@ -1043,7 +1016,11 @@ DataGridTableComponent = __decorateClass([
1043
1016
  [style.outline]="descriptor.isActive && !descriptor.isInRange ? '2px solid var(--ogrid-selection, #217346)' : null"
1044
1017
  [style.outline-offset]="descriptor.isActive && !descriptor.isInRange ? '-2px' : null"
1045
1018
  >
1046
- <span [style]="resolveCellStyleFn(col, item, descriptor.displayValue)">{{ resolveCellContent(col, item, descriptor.displayValue) }}</span>
1019
+ @if (col.type === 'boolean') {
1020
+ <input type="checkbox" [checked]="!!descriptor.displayValue" disabled style="margin:0;pointer-events:none" [attr.aria-label]="descriptor.displayValue ? 'True' : 'False'" />
1021
+ } @else {
1022
+ <span [style]="resolveCellStyleFn(col, item, descriptor.displayValue)">{{ resolveCellContent(col, item, descriptor.displayValue) }}</span>
1023
+ }
1047
1024
  @if (descriptor.canEditAny && descriptor.isSelectionEndCell) {
1048
1025
  <div
1049
1026
  (mousedown)="onFillHandleMouseDown($event)"
@@ -1079,6 +1056,14 @@ DataGridTableComponent = __decorateClass([
1079
1056
  [columnOrder]="propsColumnOrder()"
1080
1057
  ></ogrid-marching-ants-overlay>
1081
1058
 
1059
+ @if (formulaReferences() && formulaReferences()!.length > 0) {
1060
+ <ogrid-formula-ref-overlay
1061
+ [containerEl]="tableContainerEl()"
1062
+ [references]="formulaReferences()!"
1063
+ [colOffset]="colOffset()"
1064
+ />
1065
+ }
1066
+
1082
1067
  @if (showEmptyInGrid() && emptyState()) {
1083
1068
  <div class="ogrid-empty-container">
1084
1069
  <div>
@@ -1188,19 +1173,14 @@ DataGridTableComponent = __decorateClass([
1188
1173
  z-index: 3;
1189
1174
  }
1190
1175
  .ogrid-row-number-header {
1191
- width: 50px;
1192
- min-width: 50px;
1193
- max-width: 50px;
1194
1176
  text-align: center;
1195
1177
  font-weight: 600;
1196
1178
  background: var(--ogrid-header-bg, #f5f5f5);
1197
1179
  border-bottom: 2px solid var(--ogrid-border, rgba(0, 0, 0, 0.12));
1198
1180
  z-index: 3;
1181
+ position: relative;
1199
1182
  }
1200
1183
  .ogrid-row-number-spacer {
1201
- width: 50px;
1202
- min-width: 50px;
1203
- max-width: 50px;
1204
1184
  background: var(--ogrid-header-bg, #f5f5f5);
1205
1185
  }
1206
1186
  .ogrid-column-group-header {
@@ -1240,9 +1220,6 @@ DataGridTableComponent = __decorateClass([
1240
1220
  border-bottom: 1px solid var(--ogrid-border, rgba(0, 0, 0, 0.12));
1241
1221
  }
1242
1222
  .ogrid-row-number-cell {
1243
- width: 50px;
1244
- min-width: 50px;
1245
- max-width: 50px;
1246
1223
  padding: 6px;
1247
1224
  text-align: center;
1248
1225
  font-weight: 600;
@@ -1694,8 +1671,13 @@ OGridComponent = __decorateClass([
1694
1671
  [hasPagination]="true"
1695
1672
  [sideBar]="service.sideBarProps()"
1696
1673
  [fullScreen]="service.fullScreen()"
1697
- [showNameBox]="!!service.cellReferences()"
1674
+ [showNameBox]="!!(service.cellReferences() && !service.formulasEnabled())"
1698
1675
  [activeCellRef]="service.activeCellRef()"
1676
+ [formulaBar]="service.formulasEnabled() ? service.formulaBarState() : null"
1677
+ [sheetDefs]="service.sheetDefs()"
1678
+ [activeSheet]="service.activeSheet()"
1679
+ [onSheetChange]="service.onSheetChange()"
1680
+ [onSheetAdd]="service.onSheetAdd()"
1699
1681
  >
1700
1682
  <ng-content select="[toolbar]" toolbar></ng-content>
1701
1683
 
@@ -1750,6 +1732,7 @@ OGridComponent = __decorateClass([
1750
1732
  [showColumnLetters]="service.dataGridProps().showColumnLetters ?? false"
1751
1733
  [showNameBox]="service.dataGridProps().showNameBox ?? false"
1752
1734
  [onActiveCellChange]="service.dataGridProps().onActiveCellChange"
1735
+ [formulaReferences]="service.dataGridProps().formulaReferences"
1753
1736
  ></ogrid-primeng-datagrid-table>
1754
1737
 
1755
1738
  <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
  }
@@ -62,6 +62,7 @@ export declare class DataGridTableComponent<T = unknown> extends BaseDataGridTab
62
62
  showColumnLettersInput: boolean;
63
63
  showNameBoxInput: boolean;
64
64
  onActiveCellChange: ((ref: string | null) => void) | undefined;
65
+ formulaReferencesInput: import('@alaarab/ogrid-core').FormulaReference[] | undefined;
65
66
  currentPageInput: number;
66
67
  pageSizeInput: number;
67
68
  readonly defaultMinWidth = 80;
@@ -85,6 +86,7 @@ export declare class DataGridTableComponent<T = unknown> extends BaseDataGridTab
85
86
  private resizeStartWidth;
86
87
  readonly cancelEditHandler: () => void;
87
88
  readonly showColumnLetters: import("@angular/core").Signal<boolean>;
89
+ readonly formulaReferences: import("@angular/core").Signal<import("@alaarab/ogrid-core").FormulaReference[] | undefined>;
88
90
  constructor();
89
91
  ngOnChanges(changes: SimpleChanges): void;
90
92
  /** Shallow-compare two props objects by their top-level keys. */
@@ -101,6 +103,8 @@ export declare class DataGridTableComponent<T = unknown> extends BaseDataGridTab
101
103
  onRowClickPrimeng(e: MouseEvent, item: T): void;
102
104
  onRowCheckboxChangePrimeng(item: T, checked: boolean, rowIndex: number, _e: Event): void;
103
105
  onResizeStartPrimeng(e: MouseEvent, col: IColumnDef<T>): void;
106
+ onResizeRowNumber(event: MouseEvent): void;
107
+ getRowNumberWidth(): number;
104
108
  private buildProps;
105
109
  getColumnLetter(colIdx: number): string;
106
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-angular-primeng",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
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.3.0"
40
+ "@alaarab/ogrid-angular": "2.4.1"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@angular/core": "^21.0.0",