@alaarab/ogrid-angular 2.1.3 → 2.1.5

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.
Files changed (32) hide show
  1. package/dist/esm/index.js +4606 -30
  2. package/dist/types/components/base-datagrid-table.component.d.ts +8 -8
  3. package/package.json +4 -4
  4. package/dist/esm/components/base-column-chooser.component.js +0 -78
  5. package/dist/esm/components/base-column-header-filter.component.js +0 -281
  6. package/dist/esm/components/base-datagrid-table.component.js +0 -648
  7. package/dist/esm/components/base-inline-cell-editor.component.js +0 -253
  8. package/dist/esm/components/base-ogrid.component.js +0 -36
  9. package/dist/esm/components/base-pagination-controls.component.js +0 -72
  10. package/dist/esm/components/base-popover-cell-editor.component.js +0 -114
  11. package/dist/esm/components/empty-state.component.js +0 -58
  12. package/dist/esm/components/grid-context-menu.component.js +0 -153
  13. package/dist/esm/components/inline-cell-editor-template.js +0 -107
  14. package/dist/esm/components/marching-ants-overlay.component.js +0 -164
  15. package/dist/esm/components/ogrid-layout.component.js +0 -188
  16. package/dist/esm/components/sidebar.component.js +0 -274
  17. package/dist/esm/components/status-bar.component.js +0 -71
  18. package/dist/esm/services/column-reorder.service.js +0 -180
  19. package/dist/esm/services/datagrid-editing.service.js +0 -52
  20. package/dist/esm/services/datagrid-interaction.service.js +0 -667
  21. package/dist/esm/services/datagrid-layout.service.js +0 -151
  22. package/dist/esm/services/datagrid-state.service.js +0 -591
  23. package/dist/esm/services/ogrid.service.js +0 -746
  24. package/dist/esm/services/virtual-scroll.service.js +0 -91
  25. package/dist/esm/styles/ogrid-theme-vars.js +0 -53
  26. package/dist/esm/types/columnTypes.js +0 -1
  27. package/dist/esm/types/dataGridTypes.js +0 -1
  28. package/dist/esm/types/index.js +0 -1
  29. package/dist/esm/utils/dataGridViewModel.js +0 -6
  30. package/dist/esm/utils/debounce.js +0 -68
  31. package/dist/esm/utils/index.js +0 -8
  32. package/dist/esm/utils/latestRef.js +0 -41
@@ -1,151 +0,0 @@
1
- import { signal, computed, effect } from '@angular/core';
2
- import { flattenColumns, CHECKBOX_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH, CELL_PADDING, } from '@alaarab/ogrid-core';
3
- /**
4
- * Manages column layout, visibility, sizing, and container measurement.
5
- * Extracted from DataGridStateService for modularity.
6
- *
7
- * Not @Injectable — instantiated and owned by DataGridStateService.
8
- */
9
- export class DataGridLayoutHelper {
10
- constructor(props, wrapperEl, ngZone) {
11
- // --- Internal state ---
12
- this.containerWidthSig = signal(0);
13
- this.columnSizingOverridesSig = signal({});
14
- // ResizeObserver
15
- this.resizeObserver = null;
16
- this.props = props;
17
- this.wrapperEl = wrapperEl;
18
- this.initialColumnWidthsSig = computed(() => this.props()?.initialColumnWidths);
19
- this.flatColumnsRaw = computed(() => {
20
- const p = this.props();
21
- if (!p)
22
- return [];
23
- return flattenColumns(p.columns);
24
- });
25
- this.flatColumns = computed(() => {
26
- const raw = this.flatColumnsRaw();
27
- const p = this.props();
28
- const pinnedColumns = p?.pinnedColumns;
29
- if (!pinnedColumns || Object.keys(pinnedColumns).length === 0)
30
- return raw;
31
- return raw.map((col) => {
32
- const override = pinnedColumns[col.columnId];
33
- if (override && col.pinned !== override)
34
- return { ...col, pinned: override };
35
- return col;
36
- });
37
- });
38
- this.visibleCols = computed(() => {
39
- const p = this.props();
40
- if (!p)
41
- return [];
42
- const flatCols = this.flatColumns();
43
- const filtered = p.visibleColumns
44
- ? flatCols.filter((c) => p.visibleColumns.has(c.columnId))
45
- : flatCols;
46
- const order = p.columnOrder;
47
- if (!order?.length)
48
- return filtered;
49
- const orderMap = new Map();
50
- for (let i = 0; i < order.length; i++) {
51
- orderMap.set(order[i], i);
52
- }
53
- return [...filtered].sort((a, b) => {
54
- const ia = orderMap.get(a.columnId) ?? -1;
55
- const ib = orderMap.get(b.columnId) ?? -1;
56
- if (ia === -1 && ib === -1)
57
- return 0;
58
- if (ia === -1)
59
- return 1;
60
- if (ib === -1)
61
- return -1;
62
- return ia - ib;
63
- });
64
- });
65
- this.visibleColumnCount = computed(() => this.visibleCols().length);
66
- this.hasCheckboxCol = computed(() => (this.props()?.rowSelection ?? 'none') === 'multiple');
67
- this.hasRowNumbersCol = computed(() => !!this.props()?.showRowNumbers);
68
- this.specialColsCount = computed(() => (this.hasCheckboxCol() ? 1 : 0) + (this.hasRowNumbersCol() ? 1 : 0));
69
- this.totalColCount = computed(() => this.visibleColumnCount() + this.specialColsCount());
70
- this.colOffset = computed(() => this.specialColsCount());
71
- this.rowIndexByRowId = computed(() => {
72
- const p = this.props();
73
- if (!p)
74
- return new Map();
75
- const m = new Map();
76
- p.items.forEach((item, idx) => m.set(p.getRowId(item), idx));
77
- return m;
78
- });
79
- this.minTableWidth = computed(() => {
80
- const checkboxW = this.hasCheckboxCol() ? CHECKBOX_COLUMN_WIDTH : 0;
81
- return this.visibleCols().reduce((sum, c) => sum + (c.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH) + CELL_PADDING, checkboxW);
82
- });
83
- this.desiredTableWidth = computed(() => {
84
- const checkboxW = this.hasCheckboxCol() ? CHECKBOX_COLUMN_WIDTH : 0;
85
- const overrides = this.columnSizingOverridesSig();
86
- return this.visibleCols().reduce((sum, c) => {
87
- const override = overrides[c.columnId];
88
- const w = override
89
- ? override.widthPx
90
- : (c.idealWidth ?? c.defaultWidth ?? c.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH);
91
- return sum + Math.max(c.minWidth ?? DEFAULT_MIN_COLUMN_WIDTH, w) + CELL_PADDING;
92
- }, checkboxW);
93
- });
94
- // Initialize column sizing overrides from initial widths
95
- effect(() => {
96
- const widths = this.initialColumnWidthsSig();
97
- if (widths) {
98
- const result = {};
99
- for (const [id, width] of Object.entries(widths)) {
100
- result[id] = { widthPx: width };
101
- }
102
- this.columnSizingOverridesSig.set(result);
103
- }
104
- });
105
- // Container width measurement via ResizeObserver
106
- effect(() => {
107
- const el = this.wrapperEl();
108
- if (this.resizeObserver) {
109
- this.resizeObserver.disconnect();
110
- this.resizeObserver = null;
111
- }
112
- if (!el)
113
- return;
114
- const measure = () => {
115
- const rect = el.getBoundingClientRect();
116
- const cs = window.getComputedStyle(el);
117
- const borderX = (parseFloat(cs.borderLeftWidth || '0') || 0) +
118
- (parseFloat(cs.borderRightWidth || '0') || 0);
119
- this.containerWidthSig.set(Math.max(0, rect.width - borderX));
120
- };
121
- ngZone.runOutsideAngular(() => {
122
- this.resizeObserver = new ResizeObserver(measure);
123
- this.resizeObserver.observe(el);
124
- });
125
- measure();
126
- });
127
- // Clean up column sizing overrides for removed columns
128
- effect(() => {
129
- const colIds = new Set(this.flatColumns().map((c) => c.columnId));
130
- this.columnSizingOverridesSig.update((prev) => {
131
- const next = {};
132
- let changed = false;
133
- for (const [id, value] of Object.entries(prev)) {
134
- if (colIds.has(id)) {
135
- next[id] = value;
136
- }
137
- else {
138
- changed = true;
139
- }
140
- }
141
- return changed ? next : prev;
142
- });
143
- });
144
- }
145
- destroy() {
146
- if (this.resizeObserver) {
147
- this.resizeObserver.disconnect();
148
- this.resizeObserver = null;
149
- }
150
- }
151
- }