ngssm-ag-grid 22.3.0 → 22.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/README.md
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
1
1
|
# ngssm-ag-grid
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`ngssm-ag-grid` connects [AG Grid](https://www.ag-grid.com/) to the NgSsm store. It keeps grid column configuration and (optionally) row selection in application state, and provides helpers and components for common AG Grid integrations.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Tracks column order and visibility, sorting, pinning, resizing, column groups, and filter models in the NgSsm store.
|
|
8
|
+
- Restores stored column and filter state when a grid is initialized, and applies later state changes made outside the grid UI.
|
|
9
|
+
- Optionally keeps selected row IDs in the store and restores the selection when the grid is initialized.
|
|
10
|
+
- Exposes selected row IDs as a reactive signal for a grid.
|
|
11
|
+
- Can save and restore column state using browser `localStorage`. Startup loading and the grid context-menu commands can be enabled through configuration.
|
|
12
|
+
- Includes a theme directive, action cell renderer, confirmation popup, base cell editor, and column-definition helpers.
|
|
13
|
+
|
|
14
|
+
## Setup
|
|
15
|
+
|
|
16
|
+
Register the NgSsm store and the ag-grid providers in your application configuration:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { provideNgssmAgGrid } from 'ngssm-ag-grid';
|
|
20
|
+
import { provideNgssmStore } from 'ngssm-store';
|
|
21
|
+
|
|
22
|
+
export const appConfig = {
|
|
23
|
+
providers: [
|
|
24
|
+
provideNgssmStore(),
|
|
25
|
+
provideNgssmAgGrid({
|
|
26
|
+
loadSavedGridStatesAtStartup: true
|
|
27
|
+
})
|
|
28
|
+
]
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Set `loadSavedGridStatesAtStartup` to `true` to load grids with saved column state from `localStorage` during application startup. It is optional and defaults to disabled.
|
|
33
|
+
|
|
34
|
+
## Use the grid directive
|
|
35
|
+
|
|
36
|
+
Import `AgGridAngular` and the NgSsm directives into the component that declares the grid:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Component } from '@angular/core';
|
|
40
|
+
import { AgGridAngular } from 'ag-grid-angular';
|
|
41
|
+
import { NgssmAgGridDirective, NgssmAgGridThemeDirective } from 'ngssm-ag-grid';
|
|
42
|
+
|
|
43
|
+
@Component({
|
|
44
|
+
imports: [AgGridAngular, NgssmAgGridDirective, NgssmAgGridThemeDirective],
|
|
45
|
+
template: `
|
|
46
|
+
<ag-grid-angular
|
|
47
|
+
ngssmAgGridTheme
|
|
48
|
+
[ngssmAgGrid]="{ gridId: 'orders', keepSelection: true }"
|
|
49
|
+
[rowData]="orders"
|
|
50
|
+
[columnDefs]="columnDefs"
|
|
51
|
+
[getRowId]="getRowId" />
|
|
52
|
+
`
|
|
53
|
+
})
|
|
54
|
+
export class OrdersComponent {
|
|
55
|
+
// Define orders, columnDefs, and getRowId for your grid.
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Each grid needs a unique `gridId`. When `keepSelection` is enabled, provide AG Grid with a stable `getRowId` callback so selections can be restored reliably.
|
|
60
|
+
|
|
61
|
+
## Read selected row IDs
|
|
62
|
+
|
|
63
|
+
Use `selectedRowsIdsSignal` inside an Angular injection context, such as a component field initializer, to get a reactive signal of selected row IDs. It accepts either a grid ID string or a `Signal<string>`:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { signal } from '@angular/core';
|
|
67
|
+
import { selectedRowsIdsSignal } from 'ngssm-ag-grid';
|
|
68
|
+
|
|
69
|
+
export class OrdersComponent {
|
|
70
|
+
public readonly selectedOrderIds = selectedRowsIdsSignal('orders');
|
|
71
|
+
|
|
72
|
+
public readonly activeGridId = signal('orders');
|
|
73
|
+
public readonly activeGridSelectedIds = selectedRowsIdsSignal(this.activeGridId);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The returned signal updates when the selection in the store changes or, when given a grid ID signal, when that ID changes. It returns an empty array when the grid has no selected rows.
|
|
78
|
+
|
|
79
|
+
`NgssmAgGridConfig` also supports:
|
|
80
|
+
|
|
81
|
+
- `listenedColumnsEvents`: override the AG Grid events that trigger column state updates. By default, sort, filter, pin, resize, displayed-column, and column-group changes are listened to.
|
|
82
|
+
- `canSaveOnDiskColumnStates`: add save, restore, and reset commands to the grid context menu. This feature requires the AG Grid Enterprise context menu.
|
|
83
|
+
- `getContextMenuItems`: provide custom context-menu items.
|
|
84
|
+
|
|
85
|
+
The provider accepts `theme`, `defaultColDef`, and `statusBar` options as well. The `ngssmAgGridTheme` directive applies the configured theme class and supplies the optional defaults when they are not already set on the grid.
|
|
86
|
+
|
|
87
|
+
## Actions
|
|
88
|
+
|
|
89
|
+
The library provides actions for updating grid state and controlling persistence. The state-setting actions are registered by `provideNgssmAgGrid` and update the store when dispatched:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
import { ChangeOrigin, NgssmClearSelectedRowsAction, NgssmSetAgGridStateAction, NgssmSetSelectedRowsAction } from 'ngssm-ag-grid';
|
|
93
|
+
|
|
94
|
+
store.dispatchAction(new NgssmSetAgGridStateAction(gridId, ChangeOrigin.other, columnStates, columnGroupStates, filterModel));
|
|
95
|
+
store.dispatchAction(new NgssmSetSelectedRowsAction(gridId, ChangeOrigin.other, selectedRowIds));
|
|
96
|
+
store.dispatchAction(new NgssmClearSelectedRowsAction(gridId));
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`NgssmSetAgGridStateAction` sets a grid's column states, column group states, and filter model. `NgssmSetSelectedRowsAction` sets the selected row IDs. `NgssmClearSelectedRowsAction` clears the selected IDs and deselects rows in the grid. Use `ChangeOrigin.other` for changes made outside AG Grid so the directive applies them to the grid; the directive itself dispatches changes with `ChangeOrigin.agGrid`.
|
|
100
|
+
|
|
101
|
+
To save or restore a grid's column state in `localStorage`, dispatch `NgssmAgGridAction` with the corresponding action type:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { NgssmAgGridAction, NgssmAgGridActionType } from 'ngssm-ag-grid';
|
|
105
|
+
|
|
106
|
+
store.dispatchAction(new NgssmAgGridAction(NgssmAgGridActionType.saveColumnStatesOnDisk, gridId));
|
|
107
|
+
store.dispatchAction(new NgssmAgGridAction(NgssmAgGridActionType.restoreColumnStatesFromDisk, gridId));
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The action types are `setAgGridState`, `setSelectedRows`, `clearSelectedRows`, `saveColumnStatesOnDisk`, and `restoreColumnStatesFromDisk` on `NgssmAgGridActionType`. The directive can dispatch state and selection actions automatically; disk actions are also used by the optional context-menu commands.
|
|
111
|
+
|
|
112
|
+
## Exports
|
|
113
|
+
|
|
114
|
+
The package exports the grid directives and configuration, NgSsm grid state and actions, plus `getColDefWithNoPadding` and `getColDefForEditableColumn` helpers. It also exports the action cell renderer, confirmation popup, and base cell editor components.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { inject, makeEnvironmentProviders, provideAppInitializer } from "@angular/core";
|
|
2
2
|
import { Logger, Store } from "ngssm-store";
|
|
3
|
+
import { NgssmAgGridStateSpecification } from "ngssm-ag-grid";
|
|
3
4
|
import { StoreMock } from "ngssm-store/testing";
|
|
4
|
-
import { AgGridStateSpecification } from "ngssm-ag-grid";
|
|
5
5
|
const ngssmAgGridStateInitializer = () => {
|
|
6
6
|
inject(Logger).information("[ngssm-ag-grid-testing] Initialization of state and sources");
|
|
7
7
|
const store = inject(Store);
|
|
8
8
|
if (!(store instanceof StoreMock)) throw new Error("StoreMock is not registered.");
|
|
9
9
|
store.stateValue = {
|
|
10
10
|
...store.stateValue,
|
|
11
|
-
[
|
|
11
|
+
[NgssmAgGridStateSpecification.featureStateKey]: NgssmAgGridStateSpecification.initialState
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
const provideNgssmAgGridTesting = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngssm-ag-grid-testing.mjs","names":[],"sources":["../../../projects/ngssm-ag-grid/testing/src/provide-ngssm-ag-grid-testing.ts"],"sourcesContent":["import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\n\nimport { Logger, Store } from 'ngssm-store';\nimport {
|
|
1
|
+
{"version":3,"file":"ngssm-ag-grid-testing.mjs","names":[],"sources":["../../../projects/ngssm-ag-grid/testing/src/provide-ngssm-ag-grid-testing.ts"],"sourcesContent":["import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\n\nimport { Logger, Store } from 'ngssm-store';\nimport { NgssmAgGridStateSpecification } from 'ngssm-ag-grid';\nimport { StoreMock } from 'ngssm-store/testing';\n\n/**\n * App initializer that sets up the AgGrid state in the StoreMock for testing purposes.\n * Throws an error if StoreMock is not registered.\n */\nexport const ngssmAgGridStateInitializer = () => {\n const logger = inject(Logger);\n logger.information('[ngssm-ag-grid-testing] Initialization of state and sources');\n const store = inject(Store);\n if (!(store instanceof StoreMock)) {\n throw new Error('StoreMock is not registered.');\n }\n\n store.stateValue = {\n ...store.stateValue,\n [NgssmAgGridStateSpecification.featureStateKey]: NgssmAgGridStateSpecification.initialState\n };\n};\n\n/**\n * Provides environment providers for AgGrid testing, including the state initializer.\n */\nexport const provideNgssmAgGridTesting = (): EnvironmentProviders => {\n return makeEnvironmentProviders([provideAppInitializer(ngssmAgGridStateInitializer)]);\n};\n"],"mappings":";;;;AAUA,MAAa,oCAAmC;CAE9C,AADe,OAAO,MACtB,CAAA,CAAO,YAAY,6DAA6D;CAChF,MAAM,QAAQ,OAAO,KAAK;CAC1B,IAAI,EAAE,iBAAiB,YACrB,MAAM,IAAI,MAAM,8BAA8B;CAGhD,MAAM,aAAa;EACjB,GAAG,MAAM;GACR,8BAA8B,kBAAkB,8BAA8B;CAChF;AACH;AAKA,MAAa,kCAAuD;CAClE,OAAO,yBAAyB,CAAC,sBAAsB,2BAA2B,CAAC,CAAC;AACtF"}
|
|
@@ -1,51 +1,26 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import update from "immutability-helper";
|
|
3
|
-
import { Logger, NgSsmFeatureState, Store, createSignal,
|
|
3
|
+
import { Logger, NgSsmFeatureState, Store, createSignal, provideEffectFunc, provideReducerFunc } from "ngssm-store";
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
|
-
import { Component, Directive, EnvironmentInjector, HostBinding,
|
|
5
|
+
import { Component, Directive, EnvironmentInjector, HostBinding, InjectionToken, Injector, computed, effect, inject, input, isSignal, makeEnvironmentProviders, provideAppInitializer, runInInjectionContext, signal } from "@angular/core";
|
|
6
6
|
import { CdkConnectedOverlay, CdkOverlayOrigin } from "@angular/cdk/overlay";
|
|
7
7
|
import { MatIcon } from "@angular/material/icon";
|
|
8
8
|
import { MatTooltip } from "@angular/material/tooltip";
|
|
9
9
|
import { MatButton, MatIconButton } from "@angular/material/button";
|
|
10
10
|
import { isObservable, take } from "rxjs";
|
|
11
|
-
import {
|
|
11
|
+
import { toSignal } from "@angular/core/rxjs-interop";
|
|
12
12
|
import { NgssmComponentDisplayDirective } from "ngssm-toolkit";
|
|
13
13
|
import { AgGridAngular } from "ag-grid-angular";
|
|
14
14
|
import { MatCard, MatCardActions, MatCardHeader, MatCardTitle } from "@angular/material/card";
|
|
15
|
-
var
|
|
16
|
-
(function(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
origin;
|
|
25
|
-
columnStates;
|
|
26
|
-
columnGroupStates;
|
|
27
|
-
filterModel;
|
|
28
|
-
type = AgGridActionType.registerAgGridState;
|
|
29
|
-
constructor(gridId, origin, columnStates, columnGroupStates, filterModel) {
|
|
30
|
-
this.gridId = gridId;
|
|
31
|
-
this.origin = origin;
|
|
32
|
-
this.columnStates = columnStates;
|
|
33
|
-
this.columnGroupStates = columnGroupStates;
|
|
34
|
-
this.filterModel = filterModel;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var RegisterSelectedRowsAction = class {
|
|
38
|
-
gridId;
|
|
39
|
-
origin;
|
|
40
|
-
ids;
|
|
41
|
-
type = AgGridActionType.registerSelectedRows;
|
|
42
|
-
constructor(gridId, origin, ids) {
|
|
43
|
-
this.gridId = gridId;
|
|
44
|
-
this.origin = origin;
|
|
45
|
-
this.ids = ids;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var AgGridAction = class {
|
|
15
|
+
var NgssmAgGridActionType;
|
|
16
|
+
(function(NgssmAgGridActionType) {
|
|
17
|
+
NgssmAgGridActionType["setAgGridState"] = "[NgssmAgGridActionType] setAgGridState";
|
|
18
|
+
NgssmAgGridActionType["setSelectedRows"] = "[NgssmAgGridActionType] setSelectedRows";
|
|
19
|
+
NgssmAgGridActionType["clearSelectedRows"] = "[NgssmAgGridActionType] clearSelectedRows";
|
|
20
|
+
NgssmAgGridActionType["saveColumnStatesOnDisk"] = "[NgssmAgGridActionType] saveColumnStatesOnDisk";
|
|
21
|
+
NgssmAgGridActionType["restoreColumnStatesFromDisk"] = "[NgssmAgGridActionType] restoreColumnStatesFromDisk";
|
|
22
|
+
})(NgssmAgGridActionType || (NgssmAgGridActionType = {}));
|
|
23
|
+
var NgssmAgGridAction = class {
|
|
49
24
|
type;
|
|
50
25
|
gridId;
|
|
51
26
|
constructor(type, gridId) {
|
|
@@ -53,24 +28,29 @@ var AgGridAction = class {
|
|
|
53
28
|
this.gridId = gridId;
|
|
54
29
|
}
|
|
55
30
|
};
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
let
|
|
59
|
-
static featureStateKey = "ag-grid-state";
|
|
31
|
+
const selectNgssmAgGridState = (state) => state[NgssmAgGridStateSpecification.featureStateKey];
|
|
32
|
+
const updateNgssmAgGridState = (state, command) => update(state, { [NgssmAgGridStateSpecification.featureStateKey]: command });
|
|
33
|
+
let NgssmAgGridStateSpecification = class NgssmAgGridStateSpecification {
|
|
34
|
+
static featureStateKey = "ngssm-ag-grid-state";
|
|
60
35
|
static initialState = {
|
|
61
36
|
gridStates: {},
|
|
62
37
|
selectedRows: {}
|
|
63
38
|
};
|
|
64
39
|
};
|
|
65
|
-
|
|
66
|
-
featureStateKey:
|
|
67
|
-
initialState:
|
|
68
|
-
})],
|
|
40
|
+
NgssmAgGridStateSpecification = __decorate([NgSsmFeatureState({
|
|
41
|
+
featureStateKey: NgssmAgGridStateSpecification.featureStateKey,
|
|
42
|
+
initialState: NgssmAgGridStateSpecification.initialState
|
|
43
|
+
})], NgssmAgGridStateSpecification);
|
|
69
44
|
var ChangeOrigin;
|
|
70
45
|
(function(ChangeOrigin) {
|
|
71
46
|
ChangeOrigin["agGrid"] = "agGrid";
|
|
72
47
|
ChangeOrigin["other"] = "other";
|
|
73
48
|
})(ChangeOrigin || (ChangeOrigin = {}));
|
|
49
|
+
const selectedRowsIdsSignal = (gridId) => {
|
|
50
|
+
const store = inject(Store);
|
|
51
|
+
const gridIdSignal = computed(() => typeof gridId === "string" ? gridId : gridId(), ...ngDevMode ? [{ debugName: "gridIdSignal" }] : /* istanbul ignore next */ []);
|
|
52
|
+
return computed(() => selectNgssmAgGridState(store.state()).selectedRows[gridIdSignal()]?.ids ?? []);
|
|
53
|
+
};
|
|
74
54
|
var NgssmActionsCellRendererComponent = class NgssmActionsCellRendererComponent {
|
|
75
55
|
actionButtons = signal([], ...ngDevMode ? [{ debugName: "actionButtons" }] : /* istanbul ignore next */ []);
|
|
76
56
|
environmentInjector = inject(EnvironmentInjector);
|
|
@@ -315,6 +295,46 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
315
295
|
args: ["class"]
|
|
316
296
|
}] }
|
|
317
297
|
});
|
|
298
|
+
var NgssmSetAgGridStateAction = class {
|
|
299
|
+
gridId;
|
|
300
|
+
origin;
|
|
301
|
+
columnStates;
|
|
302
|
+
columnGroupStates;
|
|
303
|
+
filterModel;
|
|
304
|
+
type = NgssmAgGridActionType.setAgGridState;
|
|
305
|
+
constructor(gridId, origin, columnStates, columnGroupStates, filterModel) {
|
|
306
|
+
this.gridId = gridId;
|
|
307
|
+
this.origin = origin;
|
|
308
|
+
this.columnStates = columnStates;
|
|
309
|
+
this.columnGroupStates = columnGroupStates;
|
|
310
|
+
this.filterModel = filterModel;
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
const setAgGridState = (state, action) => {
|
|
314
|
+
return updateNgssmAgGridState(state, { gridStates: { [action.gridId]: { $set: {
|
|
315
|
+
origin: action.origin,
|
|
316
|
+
columnStates: action.columnStates,
|
|
317
|
+
columnGroupStates: action.columnGroupStates,
|
|
318
|
+
filterModel: action.filterModel
|
|
319
|
+
} } } });
|
|
320
|
+
};
|
|
321
|
+
var NgssmSetSelectedRowsAction = class {
|
|
322
|
+
gridId;
|
|
323
|
+
origin;
|
|
324
|
+
ids;
|
|
325
|
+
type = NgssmAgGridActionType.setSelectedRows;
|
|
326
|
+
constructor(gridId, origin, ids) {
|
|
327
|
+
this.gridId = gridId;
|
|
328
|
+
this.origin = origin;
|
|
329
|
+
this.ids = ids;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
const setSelectedRows = (state, action) => {
|
|
333
|
+
return updateNgssmAgGridState(state, { selectedRows: { [action.gridId]: { $set: {
|
|
334
|
+
origin: action.origin,
|
|
335
|
+
ids: action.ids
|
|
336
|
+
} } } });
|
|
337
|
+
};
|
|
318
338
|
var NgssmAgGridDirective = class NgssmAgGridDirective {
|
|
319
339
|
config = input.required({
|
|
320
340
|
...ngDevMode ? { debugName: "config" } : /* istanbul ignore next */ {},
|
|
@@ -329,8 +349,8 @@ var NgssmAgGridDirective = class NgssmAgGridDirective {
|
|
|
329
349
|
agGridAngular = inject(AgGridAngular);
|
|
330
350
|
injector = inject(Injector);
|
|
331
351
|
gridInitialized = signal(false, ...ngDevMode ? [{ debugName: "gridInitialized" }] : /* istanbul ignore next */ []);
|
|
332
|
-
gridStates = createSignal((state) =>
|
|
333
|
-
selectedRows = createSignal((state) =>
|
|
352
|
+
gridStates = createSignal((state) => selectNgssmAgGridState(state).gridStates);
|
|
353
|
+
selectedRows = createSignal((state) => selectNgssmAgGridState(state).selectedRows);
|
|
334
354
|
constructor() {
|
|
335
355
|
this.logger.information(`[NgssmAgGridDirective] Initialization...`);
|
|
336
356
|
this.agGridAngular.gridReady.pipe(take(1)).subscribe(() => this.gridInitialized.set(true));
|
|
@@ -388,18 +408,18 @@ var NgssmAgGridDirective = class NgssmAgGridDirective {
|
|
|
388
408
|
(this.config().listenedColumnsEvents ?? defaultAgGridColumnsEvents).forEach((eventType) => {
|
|
389
409
|
this.agGridAngular.api.addEventListener(eventType, () => this.saveGridState());
|
|
390
410
|
});
|
|
391
|
-
this.agGridAngular.
|
|
411
|
+
this.agGridAngular.api.addEventListener("selectionChanged", (event) => this.processSelectionChanged(event));
|
|
392
412
|
}
|
|
393
413
|
saveGridState() {
|
|
394
414
|
const state = this.agGridAngular.api.getColumnState();
|
|
395
415
|
const filterModel = this.agGridAngular.api.getFilterModel();
|
|
396
416
|
const columnGroupStates = this.agGridAngular.api.getColumnGroupState();
|
|
397
|
-
this.store.dispatchAction(new
|
|
417
|
+
this.store.dispatchAction(new NgssmSetAgGridStateAction(this.config().gridId, ChangeOrigin.agGrid, state, columnGroupStates, filterModel));
|
|
398
418
|
}
|
|
399
|
-
processSelectionChanged() {
|
|
419
|
+
processSelectionChanged(event) {
|
|
400
420
|
if (this.config().keepSelection !== true) return;
|
|
401
|
-
const selectedRows =
|
|
402
|
-
this.store.dispatchAction(new
|
|
421
|
+
const selectedRows = (event.selectedNodes ?? []).map((n) => n.id ?? "").filter((n) => n !== "");
|
|
422
|
+
this.store.dispatchAction(new NgssmSetSelectedRowsAction(this.config().gridId, ChangeOrigin.agGrid, selectedRows));
|
|
403
423
|
}
|
|
404
424
|
getContextMenuItems(params) {
|
|
405
425
|
this.logger.information("[NgssmAgGridDirective] Generating the context menu...");
|
|
@@ -413,12 +433,12 @@ var NgssmAgGridDirective = class NgssmAgGridDirective {
|
|
|
413
433
|
"separator",
|
|
414
434
|
{
|
|
415
435
|
name: "Save columns state",
|
|
416
|
-
action: () => this.store.dispatchAction(new
|
|
436
|
+
action: () => this.store.dispatchAction(new NgssmAgGridAction(NgssmAgGridActionType.saveColumnStatesOnDisk, gridId)),
|
|
417
437
|
icon: "<i class=\"fa-regular fa-floppy-disk\"></i>"
|
|
418
438
|
},
|
|
419
439
|
{
|
|
420
440
|
name: "Restore columns state",
|
|
421
|
-
action: () => this.store.dispatchAction(new
|
|
441
|
+
action: () => this.store.dispatchAction(new NgssmAgGridAction(NgssmAgGridActionType.restoreColumnStatesFromDisk, gridId)),
|
|
422
442
|
icon: "<i class=\"fa-solid fa-rotate-right\"></i>"
|
|
423
443
|
},
|
|
424
444
|
{
|
|
@@ -599,144 +619,52 @@ const getColDefForEditableColumn = () => ({
|
|
|
599
619
|
headerClass: "ngssm-ag-editable-cell",
|
|
600
620
|
valueSetter: () => false
|
|
601
621
|
});
|
|
602
|
-
var
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
switch (action.type) {
|
|
608
|
-
case AgGridActionType.saveColumnStatesOnDisk: {
|
|
609
|
-
const gridState = selectAgGridState(state).gridStates[agGridAction.gridId];
|
|
610
|
-
if (gridState) {
|
|
611
|
-
localStorage.setItem(this.getColumnStatesLocalStorageKey(agGridAction.gridId), JSON.stringify(gridState.columnStates));
|
|
612
|
-
localStorage.setItem(this.getcolumnGroupStatesLocalStorageKey(agGridAction.gridId), JSON.stringify(gridState.columnGroupStates));
|
|
613
|
-
if (gridState.filterModel) localStorage.setItem(this.getFilterModelLocalStorageKey(agGridAction.gridId), JSON.stringify(gridState.filterModel));
|
|
614
|
-
}
|
|
615
|
-
break;
|
|
616
|
-
}
|
|
617
|
-
case AgGridActionType.resetColumnStatesFromDisk: {
|
|
618
|
-
const stored = localStorage.getItem(this.getColumnStatesLocalStorageKey(agGridAction.gridId));
|
|
619
|
-
const columnGroupStates = localStorage.getItem(this.getcolumnGroupStatesLocalStorageKey(agGridAction.gridId));
|
|
620
|
-
const filterModelStored = localStorage.getItem(this.getFilterModelLocalStorageKey(agGridAction.gridId));
|
|
621
|
-
console.log(stored, filterModelStored);
|
|
622
|
-
if (stored) try {
|
|
623
|
-
const columnStates = JSON.parse(stored);
|
|
624
|
-
if (Array.isArray(columnStates)) {
|
|
625
|
-
const action = new RegisterAgGridStateAction(agGridAction.gridId, ChangeOrigin.other, columnStates, columnGroupStates ? JSON.parse(columnGroupStates) : [], filterModelStored ? JSON.parse(filterModelStored) : null);
|
|
626
|
-
actiondispatcher.dispatchAction(action);
|
|
627
|
-
} else this.logger.error(`Wrong columns state config for grid '${agGridAction.gridId}'`, stored);
|
|
628
|
-
} catch (error) {
|
|
629
|
-
this.logger.error(`Unable to load config for grid '${agGridAction.gridId}'`, error);
|
|
630
|
-
}
|
|
631
|
-
break;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
getColumnStatesLocalStorageKey(gridId) {
|
|
636
|
-
return `ngssm-ag-grid_${gridId}`;
|
|
637
|
-
}
|
|
638
|
-
getcolumnGroupStatesLocalStorageKey(gridId) {
|
|
639
|
-
return `ngssm-ag-grid_groups_${gridId}`;
|
|
640
|
-
}
|
|
641
|
-
getFilterModelLocalStorageKey(gridId) {
|
|
642
|
-
return `ngssm-ag-grid_filters_${gridId}`;
|
|
622
|
+
var NgssmClearSelectedRowsAction = class {
|
|
623
|
+
gridId;
|
|
624
|
+
type = NgssmAgGridActionType.clearSelectedRows;
|
|
625
|
+
constructor(gridId) {
|
|
626
|
+
this.gridId = gridId;
|
|
643
627
|
}
|
|
644
|
-
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
645
|
-
minVersion: "12.0.0",
|
|
646
|
-
version: "22.2.3",
|
|
647
|
-
ngImport: i0,
|
|
648
|
-
type: LocalStorageEffect,
|
|
649
|
-
deps: [],
|
|
650
|
-
target: i0.ɵɵFactoryTarget.Injectable
|
|
651
|
-
});
|
|
652
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
653
|
-
minVersion: "12.0.0",
|
|
654
|
-
version: "22.2.3",
|
|
655
|
-
ngImport: i0,
|
|
656
|
-
type: LocalStorageEffect
|
|
657
|
-
});
|
|
658
628
|
};
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
return state;
|
|
629
|
+
const clearSelectedRows = (state, action) => {
|
|
630
|
+
return updateNgssmAgGridState(state, { selectedRows: { [action.gridId]: { $set: {
|
|
631
|
+
origin: ChangeOrigin.other,
|
|
632
|
+
ids: []
|
|
633
|
+
} } } });
|
|
634
|
+
};
|
|
635
|
+
const getColumnStatesLocalStorageKey = (gridId) => {
|
|
636
|
+
return `ngssm-ag-grid_${gridId}`;
|
|
637
|
+
};
|
|
638
|
+
const getcolumnGroupStatesLocalStorageKey = (gridId) => {
|
|
639
|
+
return `ngssm-ag-grid_groups_${gridId}`;
|
|
640
|
+
};
|
|
641
|
+
const getFilterModelLocalStorageKey = (gridId) => {
|
|
642
|
+
return `ngssm-ag-grid_filters_${gridId}`;
|
|
643
|
+
};
|
|
644
|
+
const saveColumnStatesOnDisk = (state, action) => {
|
|
645
|
+
const gridState = selectNgssmAgGridState(state).gridStates[action.gridId];
|
|
646
|
+
if (gridState) {
|
|
647
|
+
localStorage.setItem(getColumnStatesLocalStorageKey(action.gridId), JSON.stringify(gridState.columnStates));
|
|
648
|
+
localStorage.setItem(getcolumnGroupStatesLocalStorageKey(action.gridId), JSON.stringify(gridState.columnGroupStates));
|
|
649
|
+
if (gridState.filterModel) localStorage.setItem(getFilterModelLocalStorageKey(action.gridId), JSON.stringify(gridState.filterModel));
|
|
681
650
|
}
|
|
682
|
-
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
683
|
-
minVersion: "12.0.0",
|
|
684
|
-
version: "22.2.3",
|
|
685
|
-
ngImport: i0,
|
|
686
|
-
type: GridStatesReducer,
|
|
687
|
-
deps: [],
|
|
688
|
-
target: i0.ɵɵFactoryTarget.Injectable
|
|
689
|
-
});
|
|
690
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
691
|
-
minVersion: "12.0.0",
|
|
692
|
-
version: "22.2.3",
|
|
693
|
-
ngImport: i0,
|
|
694
|
-
type: GridStatesReducer
|
|
695
|
-
});
|
|
696
651
|
};
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
origin: registerSelectedRowsAction.origin,
|
|
712
|
-
ids: registerSelectedRowsAction.ids
|
|
713
|
-
} } } });
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
return state;
|
|
652
|
+
const restoreColumnStatesFromDisk = (_, action) => {
|
|
653
|
+
const stored = localStorage.getItem(getColumnStatesLocalStorageKey(action.gridId));
|
|
654
|
+
const columnGroupStates = localStorage.getItem(getcolumnGroupStatesLocalStorageKey(action.gridId));
|
|
655
|
+
const filterModelStored = localStorage.getItem(getFilterModelLocalStorageKey(action.gridId));
|
|
656
|
+
const store = inject(Store);
|
|
657
|
+
const logger = inject(Logger);
|
|
658
|
+
if (stored) try {
|
|
659
|
+
const columnStates = JSON.parse(stored);
|
|
660
|
+
if (Array.isArray(columnStates)) {
|
|
661
|
+
const actionToDispatch = new NgssmSetAgGridStateAction(action.gridId, ChangeOrigin.other, columnStates, columnGroupStates ? JSON.parse(columnGroupStates) : [], filterModelStored ? JSON.parse(filterModelStored) : null);
|
|
662
|
+
store.dispatchAction(actionToDispatch);
|
|
663
|
+
} else logger.error(`Wrong columns state config for grid '${action.gridId}'`, stored);
|
|
664
|
+
} catch (error) {
|
|
665
|
+
logger.error(`Unable to load config for grid '${action.gridId}'`, error);
|
|
717
666
|
}
|
|
718
|
-
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
719
|
-
minVersion: "12.0.0",
|
|
720
|
-
version: "22.2.3",
|
|
721
|
-
ngImport: i0,
|
|
722
|
-
type: SelectedRowsReducer,
|
|
723
|
-
deps: [],
|
|
724
|
-
target: i0.ɵɵFactoryTarget.Injectable
|
|
725
|
-
});
|
|
726
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
727
|
-
minVersion: "12.0.0",
|
|
728
|
-
version: "22.2.3",
|
|
729
|
-
ngImport: i0,
|
|
730
|
-
type: SelectedRowsReducer
|
|
731
|
-
});
|
|
732
667
|
};
|
|
733
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
734
|
-
minVersion: "12.0.0",
|
|
735
|
-
version: "22.2.3",
|
|
736
|
-
ngImport: i0,
|
|
737
|
-
type: SelectedRowsReducer,
|
|
738
|
-
decorators: [{ type: Injectable }]
|
|
739
|
-
});
|
|
740
668
|
const loadGridStates = () => {
|
|
741
669
|
const logger = inject(Logger);
|
|
742
670
|
if (!inject(NGSSM_AG_GRID_OPTIONS, { optional: true })?.loadSavedGridStatesAtStartup) {
|
|
@@ -750,7 +678,7 @@ const loadGridStates = () => {
|
|
|
750
678
|
if (key?.startsWith(wantedPrefix)) {
|
|
751
679
|
const gridId = key.slice(14);
|
|
752
680
|
logger.information(`[ag-grid] Restoring '${gridId}'.`);
|
|
753
|
-
store.dispatchAction(new
|
|
681
|
+
store.dispatchAction(new NgssmAgGridAction(NgssmAgGridActionType.restoreColumnStatesFromDisk, gridId));
|
|
754
682
|
}
|
|
755
683
|
}
|
|
756
684
|
};
|
|
@@ -761,10 +689,13 @@ const provideNgssmAgGrid = (options) => {
|
|
|
761
689
|
provide: NGSSM_AG_GRID_OPTIONS,
|
|
762
690
|
useValue: options ?? null
|
|
763
691
|
},
|
|
764
|
-
|
|
765
|
-
|
|
692
|
+
provideReducerFunc([NgssmAgGridActionType.setAgGridState], setAgGridState),
|
|
693
|
+
provideReducerFunc([NgssmAgGridActionType.setSelectedRows], setSelectedRows),
|
|
694
|
+
provideReducerFunc([NgssmAgGridActionType.clearSelectedRows], clearSelectedRows),
|
|
695
|
+
provideEffectFunc(NgssmAgGridActionType.saveColumnStatesOnDisk, saveColumnStatesOnDisk),
|
|
696
|
+
provideEffectFunc(NgssmAgGridActionType.restoreColumnStatesFromDisk, restoreColumnStatesFromDisk)
|
|
766
697
|
]);
|
|
767
698
|
};
|
|
768
|
-
export { ActionConfirmationPopupComponent,
|
|
699
|
+
export { ActionConfirmationPopupComponent, ChangeOrigin, NGSSM_AG_GRID_OPTIONS, NgssmActionsCellRendererComponent, NgssmAgGridAction, NgssmAgGridActionType, NgssmAgGridDirective, NgssmAgGridOptions, NgssmAgGridStateSpecification, NgssmAgGridThemeDirective, NgssmBaseCellEditor, NgssmClearSelectedRowsAction, NgssmSetAgGridStateAction, NgssmSetSelectedRowsAction, clearSelectedRows, defaultAgGridColumnsEvents, getColDefForEditableColumn, getColDefWithNoPadding, getNgssmActionsCellColDef, loadGridStates, provideNgssmAgGrid, selectNgssmAgGridState, selectedRowsIdsSignal, setAgGridState, setSelectedRows, updateNgssmAgGridState };
|
|
769
700
|
|
|
770
701
|
//# sourceMappingURL=ngssm-ag-grid.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngssm-ag-grid.mjs","names":[],"sources":["../../../projects/ngssm-ag-grid/src/lib/actions/ag-grid-action-type.ts","../../../projects/ngssm-ag-grid/src/lib/actions/register-ag-grid-state.action.ts","../../../projects/ngssm-ag-grid/src/lib/actions/register-selected-rows.action.ts","../../../projects/ngssm-ag-grid/src/lib/actions/ag-grid.action.ts","../../../projects/ngssm-ag-grid/src/lib/state/ag-grid.state.ts","../../../projects/ngssm-ag-grid/src/lib/state/change-origin.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-actions-cell-renderer/ngssm-actions-cell-renderer.component.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-actions-cell-renderer/ngssm-actions-cell-renderer.component.html","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-actions-cell-renderer/ngssm-actions-cell-renderer-params.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-ag-grid-config.ts","../../../projects/ngssm-ag-grid/src/lib/ngssm-ag-grid-options.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-ag-grid-theme.directive.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-ag-grid.directive.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-base-cell-editor.ts","../../../projects/ngssm-ag-grid/src/lib/components/action-confirmation-popup/action-confirmation-popup.component.ts","../../../projects/ngssm-ag-grid/src/lib/components/action-confirmation-popup/action-confirmation-popup.component.html","../../../projects/ngssm-ag-grid/src/lib/helpers.ts","../../../projects/ngssm-ag-grid/src/lib/effects/local-storage.effect.ts","../../../projects/ngssm-ag-grid/src/lib/reducers/grid-states.reducer.ts","../../../projects/ngssm-ag-grid/src/lib/reducers/selected-rows.reducer.ts","../../../projects/ngssm-ag-grid/src/lib/provide-ngssm-ag-grid.ts"],"sourcesContent":["export enum AgGridActionType {\n registerAgGridState = '[AgGridActionType] registerAgGridState',\n registerSelectedRows = '[AgGridActionType] registerSelectedRows',\n saveColumnStatesOnDisk = '[AgGridActionType] saveColumnStatesOnDisk',\n resetColumnStatesFromDisk = '[AgGridActionType] resetColumnStatesFromDisk'\n}\n","import { ColumnState, FilterModel } from 'ag-grid-community';\n\nimport { Action } from 'ngssm-store';\n\nimport { ChangeOrigin, ColumnGroupState } from '../state';\nimport { AgGridActionType } from './ag-grid-action-type';\n\nexport class RegisterAgGridStateAction implements Action {\n public readonly type: string = AgGridActionType.registerAgGridState;\n\n constructor(\n public readonly gridId: string,\n public readonly origin: ChangeOrigin,\n public readonly columnStates: ColumnState[],\n public readonly columnGroupStates: ColumnGroupState[],\n public readonly filterModel: FilterModel | null\n ) {}\n}\n","import { Action } from 'ngssm-store';\nimport { ChangeOrigin } from '../state';\nimport { AgGridActionType } from './ag-grid-action-type';\n\nexport class RegisterSelectedRowsAction implements Action {\n public readonly type: string = AgGridActionType.registerSelectedRows;\n\n constructor(\n public readonly gridId: string,\n public readonly origin: ChangeOrigin,\n public readonly ids: string[]\n ) {}\n}\n","import { Action } from 'ngssm-store';\n\nexport class AgGridAction implements Action {\n constructor(\n public readonly type: string,\n public readonly gridId: string\n ) {}\n}\n","import update, { Spec } from 'immutability-helper';\n\nimport { NgSsmFeatureState, State } from 'ngssm-store';\nimport { GridState } from './grid-state';\nimport { SelectedRows } from './selected-rows';\n\nexport const selectAgGridState = (state: State): AgGridState => state[AgGridStateSpecification.featureStateKey] as AgGridState;\n\nexport const updateAgGridState = (state: State, command: Spec<AgGridState, never>): State =>\n update(state, {\n [AgGridStateSpecification.featureStateKey]: command\n });\n\nexport interface AgGridState {\n gridStates: Record<string, GridState>;\n selectedRows: Record<string, SelectedRows>;\n}\n\n@NgSsmFeatureState({\n featureStateKey: AgGridStateSpecification.featureStateKey,\n initialState: AgGridStateSpecification.initialState\n})\nexport class AgGridStateSpecification {\n public static readonly featureStateKey = 'ag-grid-state';\n public static readonly initialState: AgGridState = {\n gridStates: {},\n selectedRows: {}\n };\n}\n","export enum ChangeOrigin {\n agGrid = 'agGrid',\n other = 'other'\n}\n","/**\n * The `NgssmActionsCellRendererComponent` is a custom cell renderer for `ag-grid` that dynamically renders\n * action buttons within a grid cell. It provides flexibility in configuring button behavior, visibility, and state.\n *\n * ### Features:\n * - Dynamically generates action buttons based on the provided configuration.\n * - Supports reactive state management using Angular signals.\n * - Integrates with observables, functions, or signals for `isDisabled` and `isHidden` properties.\n * - Provides customizable tooltips and button styles.\n * - Executes custom actions when buttons are clicked.\n *\n * ### Usage:\n * To use this component, provide it as a cell renderer in your `ag-grid` column definition:\n *\n * ```typescript\n * columnDefs: [\n * {\n * headerName: 'Actions',\n * field: 'actions',\n * cellRenderer: NgssmActionsCellRendererComponent,\n * cellRendererParams: {\n * actions: [\n * {\n * cssClass: 'delete-button',\n * color: 'warn',\n * tooltip: 'Delete Item',\n * isDisabled: (params) => params.data.isLocked,\n * isHidden: (params) => !params.data.canDelete,\n * click: (params) => console.log('Delete action clicked', params)\n * }\n * ]\n * }\n * }\n * ];\n * ```\n *\n * ### Inputs:\n * - `NgssmActionsCellRendererParams`: Configuration object passed to the component via `cellRendererParams`.\n * - `actions`: Array of `ActionConfig` objects defining the buttons to render.\n *\n * ### Outputs:\n * None.\n *\n * ### Dependencies:\n * - Angular Material components: `MatIconButton`, `MatIcon`, `MatTooltip`.\n * - `ag-grid-angular` for integration with `ag-grid`.\n *\n * ### Example ActionConfig:\n * ```typescript\n * interface ActionConfig {\n * cssClass: string; // CSS class for the button.\n * color?: string; // Button color (e.g., 'primary', 'warn').\n * tooltip?: string; // Tooltip text for the button.\n * isDisabled?: boolean | Signal<boolean> | Observable<boolean> | ((params: ICellRendererParams) => boolean);\n * isHidden?: boolean | Signal<boolean> | Observable<boolean> | ((params: ICellRendererParams) => boolean);\n * click?: (params: ICellRendererParams) => void; // Action to execute on button click.\n * }\n * ```\n *\n * ### Methods:\n * - `agInit(params: ICellRendererParams)`: Initializes the component with the provided cell renderer parameters.\n * - `refresh(params: ICellRendererParams)`: Refreshes the component state when the grid updates.\n * - `executeAction(action: ActionButton)`: Executes the action associated with a button.\n *\n * ### Internal Logic:\n * - The `setupActions` method initializes the action buttons based on the provided configuration.\n * - The `setUpActionSignal` method handles the initialization of `isDisabled` and `isHidden` states for each button.\n * - The component uses Angular signals (`WritableSignal` and `Signal`) to manage the state of `isDisabled` and `isHidden`.\n * - Observables are converted to signals using `toSignal` for seamless integration with Angular's reactivity system.\n *\n * ### Notes:\n * - Ensure that the `actions` array in `NgssmActionsCellRendererParams` is properly configured to avoid runtime errors.\n * - The component is designed to work with Angular Material and requires the relevant modules to be imported in your application.\n * - The `isDisabled` and `isHidden` properties can accept multiple input types (boolean, function, signal, or observable), providing flexibility in defining button behavior.\n */\n\nimport { Component, signal, WritableSignal, Signal, inject, EnvironmentInjector, runInInjectionContext, isSignal } from '@angular/core';\nimport { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';\nimport { MatIcon } from '@angular/material/icon';\nimport { MatTooltip } from '@angular/material/tooltip';\nimport { MatIconButton } from '@angular/material/button';\nimport { isObservable } from 'rxjs';\nimport { toSignal } from '@angular/core/rxjs-interop';\n\nimport { ICellRendererAngularComp } from 'ag-grid-angular';\nimport { ICellRendererParams } from 'ag-grid-community';\n\nimport { NgssmComponentAction, NgssmComponentDisplayDirective } from 'ngssm-toolkit';\n\nimport { NgssmActionsCellRendererParams } from './ngssm-actions-cell-renderer-params';\nimport { ActionConfig, ActionDisabledFunc, ActionHiddenFunc, ActionPopupComponent } from './action-config';\n\ninterface ActionButton {\n cssClass: string;\n color: string;\n\n isDisabled: WritableSignal<boolean> | Signal<boolean>;\n isHidden: WritableSignal<boolean> | Signal<boolean>;\n\n isDisabledInputAFunction: boolean;\n isHiddenInputAFunction: boolean;\n\n actionConfig: ActionConfig;\n\n tooltip: string;\n\n popupRendered: WritableSignal<boolean>;\n popupAction?: NgssmComponentAction;\n}\n\n@Component({\n selector: 'ngssm-actions-cell-renderer',\n imports: [MatIconButton, MatIcon, MatTooltip, CdkOverlayOrigin, CdkConnectedOverlay, NgssmComponentDisplayDirective],\n templateUrl: './ngssm-actions-cell-renderer.component.html'\n})\nexport class NgssmActionsCellRendererComponent implements ICellRendererAngularComp {\n public readonly actionButtons = signal<ActionButton[]>([]);\n\n private environmentInjector = inject(EnvironmentInjector);\n private cellParams: ICellRendererParams | undefined;\n\n public agInit(params: ICellRendererParams): void {\n this.cellParams = params;\n this.setupActions(params as unknown as NgssmActionsCellRendererParams);\n }\n\n public refresh(params: ICellRendererParams): boolean {\n this.cellParams = params;\n this.actionButtons().forEach((a) => {\n if (a.isDisabledInputAFunction) {\n (a.isDisabled as WritableSignal<boolean>).set((a.actionConfig.isDisabled as ActionDisabledFunc)(params));\n }\n\n if (a.isHiddenInputAFunction) {\n (a.isHidden as WritableSignal<boolean>).set((a.actionConfig.isHidden as ActionHiddenFunc)(params));\n }\n });\n return true;\n }\n\n public executeAction(action: ActionButton): void {\n const params = this.cellParams;\n if (params) {\n action.actionConfig.click?.(params);\n }\n }\n\n private setupActions(rendererParams: NgssmActionsCellRendererParams): void {\n runInInjectionContext(this.environmentInjector, () => {\n const actionButtons: ActionButton[] = (rendererParams?.actions ?? []).map((a) => {\n const actionButton: ActionButton = {\n cssClass: a.cssClass,\n color: a.color ?? 'primary',\n isDisabled: signal(false),\n isDisabledInputAFunction: false,\n isHidden: signal(false),\n isHiddenInputAFunction: false,\n actionConfig: a,\n tooltip: a.tooltip ?? '',\n popupRendered: signal(false)\n };\n\n if (a.popupComponent) {\n actionButton.popupAction = ((component: ActionPopupComponent) =>\n this.setupPopupComponent(component, actionButton)) as NgssmComponentAction;\n }\n\n this.setUpActionSignal(actionButton, a, rendererParams, 'isDisabled');\n this.setUpActionSignal(actionButton, a, rendererParams, 'isHidden');\n\n return actionButton;\n });\n\n this.actionButtons.set(actionButtons);\n });\n }\n\n private setUpActionSignal(\n actionButton: ActionButton,\n config: ActionConfig,\n rendererParams: NgssmActionsCellRendererParams,\n signalName: 'isDisabled' | 'isHidden'\n ): void {\n const input = config[signalName];\n\n if (isSignal(input)) {\n actionButton[signalName] = input as Signal<boolean>;\n } else if (input instanceof Function) {\n (actionButton[signalName] as WritableSignal<boolean>).set(input(rendererParams as unknown as ICellRendererParams));\n actionButton[`${signalName}InputAFunction`] = true;\n } else if (isObservable(input)) {\n actionButton[signalName] = toSignal(input, { initialValue: false });\n }\n }\n\n private setupPopupComponent(component: ActionPopupComponent, action: ActionButton): void {\n component?.init?.(action.popupRendered, this.cellParams as unknown as ICellRendererParams, action.actionConfig.popupParameter);\n }\n}\n","<div class=\"ngssm-actions-cell\">\n @for (actionButton of actionButtons(); track actionButton; let idx = $index) {\n @if (!actionButton.isHidden()) {\n @if (actionButton.actionConfig.popupComponent) {\n <button\n mat-icon-button\n class=\"ngssm-actions-cell-button\"\n [color]=\"actionButton.color\"\n id=\"action_{{ idx }}\"\n [disabled]=\"actionButton.isDisabled()\"\n [matTooltip]=\"actionButton.tooltip\"\n cdkOverlayOrigin\n #trigger=\"cdkOverlayOrigin\"\n (click)=\"actionButton.popupRendered.set(true)\">\n <mat-icon [class]=\"actionButton.cssClass\"></mat-icon>\n </button>\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayHasBackdrop]=\"true\"\n [cdkConnectedOverlayOrigin]=\"trigger\"\n [cdkConnectedOverlayOpen]=\"actionButton.popupRendered()\">\n <div [ngssmComponentDisplay]=\"actionButton.actionConfig.popupComponent\" [ngssmComponentAction]=\"actionButton.popupAction\"></div>\n </ng-template>\n } @else {\n <button\n mat-icon-button\n class=\"ngssm-actions-cell-button\"\n [color]=\"actionButton.color\"\n id=\"action_{{ idx }}\"\n [disabled]=\"actionButton.isDisabled()\"\n (click)=\"executeAction(actionButton)\"\n [matTooltip]=\"actionButton.tooltip\">\n <mat-icon [class]=\"actionButton.cssClass\"></mat-icon>\n </button>\n }\n }\n }\n</div>\n","import { ColDef } from 'ag-grid-community';\n\nimport { ActionConfig } from './action-config';\nimport { NgssmActionsCellRendererComponent } from './ngssm-actions-cell-renderer.component';\n\n// Parameters of the actions cell renderer\n// For now, an action is rendered as a mat-icon-button with the class passed in ActionConfig\nexport interface NgssmActionsCellRendererParams<TData = unknown, TValue = unknown> {\n actions: ActionConfig<TData, TValue>[];\n}\n\nexport const getNgssmActionsCellColDef = <TData = unknown, TValue = unknown>(\n params: NgssmActionsCellRendererParams<TData, TValue>\n): Partial<ColDef> => ({\n cellRenderer: NgssmActionsCellRendererComponent,\n cellRendererParams: params\n});\n","import { AgPublicEventType, GetContextMenuItems } from 'ag-grid-community';\n\n/**\n * List of default ag-grid events listened by the directive to update the stored state.\n */\nexport const defaultAgGridColumnsEvents: AgPublicEventType[] = [\n 'sortChanged',\n 'filterChanged',\n 'columnPinned',\n 'columnResized',\n 'displayedColumnsChanged',\n 'filterChanged',\n 'columnGroupOpened'\n];\n\n/**\n * Configuration parameters of the {@link NgssmAgGridDirective} directive to apply on a\n * {@link https://www.ag-grid.com/ ag-grid instance}\n */\nexport interface NgssmAgGridConfig {\n /**\n * Unique identifier of the grid on which the directive is applied\n */\n gridId: string;\n\n /**\n * If true, the selected rows are stored in the state and restored when the directive is created.\n */\n keepSelection?: boolean;\n\n /**\n * If true, context menus are added to the grid to save the columns state into the local storage\n * and to restore from the local storage.\n *\n * @remarks\n *\n * this functionnality is only available for enterprise version of {@link https://www.ag-grid.com/}.\n */\n canSaveOnDiskColumnStates?: boolean;\n\n /**\n * Used to override default context menu items.\n */\n getContextMenuItems?: GetContextMenuItems;\n\n /**\n * Defines the list of ag-grid events listened to by the directive to update the state of stored columns.\n * By default: defaultAgGridColumnsEvents\n */\n listenedColumnsEvents?: AgPublicEventType[];\n}\n","import { InjectionToken } from '@angular/core';\nimport { ColDef, StatusPanelDef } from 'ag-grid-community';\n\n/**\n * Configuration options for NgssmAgGrid.\n * - theme: The CSS theme to use for the grid.\n * - statusBar: Optional status bar configuration for AG Grid.\n * - defaultColDef: Optional default column definition for all columns.\n * - loadSavedGridStatesAtStartup: If true, grid states saved in local storage are loaded during app initialization.\n */\nexport class NgssmAgGridOptions {\n theme = 'ag-theme-material';\n statusBar:\n | {\n statusPanels: StatusPanelDef[];\n }\n | undefined = undefined;\n defaultColDef: ColDef | undefined = undefined;\n loadSavedGridStatesAtStartup?: boolean = undefined;\n}\n\n/**\n * Injection token for providing NgssmAgGridOptions in Angular DI.\n *\n * Provide options through the provideNgssmAgGrid function instead of using this token.\n */\nexport const NGSSM_AG_GRID_OPTIONS = new InjectionToken<NgssmAgGridOptions>('NGSSM_AG_GRID_OPTIONS');\n","import { Directive, HostBinding, inject } from '@angular/core';\n\nimport { AgGridAngular } from 'ag-grid-angular';\n\nimport { NgssmAgGridOptions, NGSSM_AG_GRID_OPTIONS } from '../ngssm-ag-grid-options';\n\n@Directive({\n selector: '[ngssmAgGridTheme]'\n})\nexport class NgssmAgGridThemeDirective {\n @HostBinding('class') className = '';\n\n private readonly options: NgssmAgGridOptions | null = inject(NGSSM_AG_GRID_OPTIONS, { optional: true });\n private agGridAngular = inject(AgGridAngular);\n\n constructor() {\n this.className = (this.options ?? new NgssmAgGridOptions()).theme;\n if (this.agGridAngular.statusBar === undefined) {\n this.agGridAngular.statusBar = this.options?.statusBar;\n }\n\n if (this.agGridAngular.defaultColDef === undefined) {\n this.agGridAngular.defaultColDef = this.options?.defaultColDef;\n }\n }\n}\n","import { Directive, inject, signal, input, effect, runInInjectionContext, Injector } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { take } from 'rxjs';\n\nimport { AgGridAngular } from 'ag-grid-angular';\nimport { DefaultMenuItem, GetContextMenuItemsParams, MenuItemDef } from 'ag-grid-community';\n\nimport { createSignal, Logger, Store } from 'ngssm-store';\n\nimport { AgGridAction, AgGridActionType, RegisterAgGridStateAction, RegisterSelectedRowsAction } from '../actions';\nimport { ChangeOrigin, ColumnGroupState, selectAgGridState } from '../state';\nimport { defaultAgGridColumnsEvents, NgssmAgGridConfig } from './ngssm-ag-grid-config';\n\n@Directive({\n selector: '[ngssmAgGrid]'\n})\nexport class NgssmAgGridDirective {\n public readonly config = input.required<NgssmAgGridConfig, string | NgssmAgGridConfig>({\n alias: 'ngssmAgGrid',\n transform: (v) => {\n if (typeof v === 'string') {\n return {\n gridId: v as string\n };\n }\n\n const conf = v as NgssmAgGridConfig;\n return {\n ...conf\n };\n }\n });\n\n private readonly logger = inject(Logger);\n private readonly store = inject(Store);\n private readonly agGridAngular = inject(AgGridAngular);\n private readonly injector = inject(Injector);\n\n private readonly gridInitialized = signal(false);\n private readonly gridStates = createSignal((state) => selectAgGridState(state).gridStates);\n private readonly selectedRows = createSignal((state) => selectAgGridState(state).selectedRows);\n\n constructor() {\n this.logger.information(`[NgssmAgGridDirective] Initialization...`);\n\n // Setup gridInintialized signal\n this.agGridAngular.gridReady.pipe(take(1)).subscribe(() => this.gridInitialized.set(true));\n\n // Apply registered grid setup if any and start listening to ag-grid events\n const effectRef = effect(() => {\n if (!this.gridInitialized()) {\n return;\n }\n\n this.logger.information(`[NgssmAgGridDirective] Initialization for '${this.config().gridId}' in progress`);\n\n const gridState = this.gridStates()[this.config().gridId];\n if (gridState) {\n this.agGridAngular.api.setColumnGroupState(gridState.columnGroupStates);\n this.agGridAngular.api.applyColumnState({\n state: gridState.columnStates,\n applyOrder: true\n });\n this.agGridAngular.api.setFilterModel(gridState.filterModel);\n }\n\n if (this.config().keepSelection) {\n const selection = this.selectedRows()[this.config().gridId];\n if (selection) {\n const ids = selection.ids ?? [];\n this.agGridAngular.api.forEachNode((node) => {\n if (node.id) {\n node.setSelected(ids.includes(node.id));\n }\n });\n }\n }\n\n runInInjectionContext(this.injector, () => this.initSateChangeListener());\n\n effectRef.destroy();\n\n this.logger.information(`[NgssmAgGridDirective] Initialization for '${this.config().gridId}' done`);\n });\n\n // process changes in columns when not comming from ui\n effect(() => {\n if (!this.gridInitialized()) {\n return;\n }\n\n const gridState = this.gridStates()[this.config().gridId];\n if (gridState?.origin === ChangeOrigin.other) {\n this.agGridAngular.api.setColumnGroupState(gridState.columnGroupStates);\n this.agGridAngular.api.applyColumnState({\n state: gridState.columnStates,\n applyOrder: true\n });\n\n this.agGridAngular.api.setFilterModel(gridState.filterModel);\n }\n });\n\n // process changes in selection when not comming from ui\n effect(() => {\n if (!this.gridInitialized()) {\n return;\n }\n\n if (this.config().keepSelection !== true) {\n return;\n }\n\n const selection = this.selectedRows()[this.config().gridId];\n if (!selection || selection.origin !== ChangeOrigin.other) {\n return;\n }\n\n const ids = selection.ids ?? [];\n this.agGridAngular.api.forEachNode((node) => {\n if (node.id) {\n node.setSelected(ids.includes(node.id));\n }\n });\n });\n\n this.agGridAngular.getContextMenuItems = (params) => this.getContextMenuItems(params);\n this.logger.information(`[NgssmAgGridDirective] Initialization done.`);\n }\n\n private initSateChangeListener(): void {\n (this.config().listenedColumnsEvents ?? defaultAgGridColumnsEvents).forEach((eventType) => {\n this.agGridAngular.api.addEventListener(eventType, () => this.saveGridState());\n });\n\n this.agGridAngular.rowSelected.pipe(takeUntilDestroyed()).subscribe(() => this.processSelectionChanged());\n }\n\n private saveGridState(): void {\n const state = this.agGridAngular.api.getColumnState();\n const filterModel = this.agGridAngular.api.getFilterModel();\n const columnGroupStates: ColumnGroupState[] = this.agGridAngular.api.getColumnGroupState();\n this.store.dispatchAction(\n new RegisterAgGridStateAction(this.config().gridId, ChangeOrigin.agGrid, state, columnGroupStates, filterModel)\n );\n }\n\n private processSelectionChanged(): void {\n if (this.config().keepSelection !== true) {\n return;\n }\n\n const selectedRows = this.agGridAngular.api\n .getSelectedNodes()\n .map((n) => n.id ?? '')\n .filter((n) => n !== '');\n\n this.store.dispatchAction(new RegisterSelectedRowsAction(this.config().gridId, ChangeOrigin.agGrid, selectedRows));\n }\n\n private getContextMenuItems(params: GetContextMenuItemsParams): (DefaultMenuItem | MenuItemDef)[] {\n this.logger.information('[NgssmAgGridDirective] Generating the context menu...');\n const menuItems: (DefaultMenuItem | MenuItemDef)[] = [];\n const getContextMenuItems = this.config().getContextMenuItems;\n if (getContextMenuItems) {\n menuItems.push(...(getContextMenuItems(params) as (DefaultMenuItem | MenuItemDef)[]));\n } else {\n menuItems.push(...(params.defaultItems ?? []));\n }\n\n if (this.config().canSaveOnDiskColumnStates === true) {\n const gridId = this.config().gridId;\n menuItems.push(\n ...[\n 'separator' as DefaultMenuItem,\n {\n name: 'Save columns state',\n action: () => this.store.dispatchAction(new AgGridAction(AgGridActionType.saveColumnStatesOnDisk, gridId)),\n icon: '<i class=\"fa-regular fa-floppy-disk\"></i>'\n },\n {\n name: 'Restore columns state',\n action: () => this.store.dispatchAction(new AgGridAction(AgGridActionType.resetColumnStatesFromDisk, gridId)),\n icon: '<i class=\"fa-solid fa-rotate-right\"></i>'\n },\n {\n name: 'Reset columns state to default',\n action: () => {\n this.agGridAngular.api.resetColumnState();\n this.agGridAngular.api.resetColumnGroupState();\n this.agGridAngular.api.setFilterModel(null);\n },\n icon: '<i class=\"fa-solid fa-clock-rotate-left\"></i>'\n }\n ]\n );\n }\n return menuItems;\n }\n}\n","import { ICellEditorAngularComp } from 'ag-grid-angular';\nimport { ICellEditorParams } from 'ag-grid-community';\n\nexport abstract class NgssmBaseCellEditor implements ICellEditorAngularComp {\n protected params?: ICellEditorParams;\n\n public agInit(params: ICellEditorParams): void {\n this.params = params;\n }\n\n public getValue() {\n return '';\n }\n\n public isPopup(): boolean {\n return true;\n }\n\n public getPopupPosition(): 'over' | 'under' | undefined {\n return 'over';\n }\n\n public isCancelAfterEnd(): boolean {\n return true;\n }\n\n public cancel(): void {\n this.params?.stopEditing();\n }\n}\n","import { Component, signal, WritableSignal } from '@angular/core';\nimport { MatButton } from '@angular/material/button';\nimport { MatCard, MatCardActions, MatCardTitle, MatCardHeader } from '@angular/material/card';\nimport { ICellRendererParams } from 'ag-grid-community';\n\nimport { ActionConfirmationPopupParameter } from './action-confirmation-popup-parameter';\nimport { ActionPopupComponent } from '../ngssm-actions-cell-renderer';\n\n/**\n * The `ActionConfirmationPopupComponent` is a reusable confirmation popup component designed to work with `ag-grid`.\n * It provides a customizable confirmation dialog for user actions, allowing developers to define messages, button labels,\n * and actions dynamically.\n *\n * ### Features:\n * - Displays a confirmation popup with customizable message, button labels, and color.\n * - Integrates with the `ActionPopupComponent` interface for seamless use with `NgssmActionsCellRendererComponent`.\n * - Uses Angular signals for efficient state management.\n * - Supports dynamic initialization with parameters provided by `ag-grid`.\n * - Provides methods to handle user actions (confirm or cancel) and close the popup.\n *\n * ### Usage:\n * This component is typically used as a popup in conjunction with the `NgssmActionsCellRendererComponent`.\n * To configure it, pass an `ActionConfirmationPopupParameter` object when initializing the popup.\n *\n * Example:\n * ```typescript\n * const popupParameter: ActionConfirmationPopupParameter = {\n * messageBuilder: (params) => `Are you sure you want to delete ${params.data.name}?`,\n * color: 'warn',\n * cancelButtonLabel: 'No',\n * confirmButtonLabel: 'Yes',\n * confirmAction: (params) => console.log('Confirmed action for:', params.data)\n * };\n * ```\n *\n * ### Inputs:\n * - `popupRendered`: A writable signal indicating whether the popup is currently rendered.\n * - `params`: The cell renderer parameters provided by `ag-grid`.\n * - `popupParameter`: An object of type `ActionConfirmationPopupParameter` that defines the popup's behavior and content.\n *\n * ### Outputs:\n * None.\n *\n * ### Dependencies:\n * - Angular Material components: `MatCard`, `MatButton`.\n * - `ag-grid-community` for integration with `ag-grid`.\n *\n * ### Methods:\n * - `init(popupRendered, params, popupParameter)`: Initializes the popup with the provided parameters.\n * - `popupRendered`: A writable signal to track the popup's visibility.\n * - `params`: The cell renderer parameters from `ag-grid`.\n * - `popupParameter`: The configuration object for the popup.\n *\n * - `closePopup()`: Closes the popup by setting the `isOpen` signal to `false`.\n *\n * - `executeAction()`: Executes the confirmation action defined in the `popupParameter` and closes the popup.\n *\n * ### Signals:\n * - `message`: The message displayed in the popup.\n * - `cancelButtonLabel`: The label for the cancel button.\n * - `confirmButtonLabel`: The label for the confirm button.\n * - `color`: The color theme for the confirm button (e.g., 'primary', 'warn').\n * - `isOpen`: Tracks whether the popup is currently open.\n *\n * ### Example Initialization:\n * ```typescript\n * const popup = new ActionConfirmationPopupComponent();\n * popup.init(\n * popupRenderedSignal,\n * cellRendererParams,\n * {\n * messageBuilder: (params) => `Are you sure you want to delete ${params.data.name}?`,\n * color: 'warn',\n * cancelButtonLabel: 'No',\n * confirmButtonLabel: 'Yes',\n * confirmAction: (params) => console.log('Confirmed action for:', params.data)\n * }\n * );\n * ```\n *\n * ### Notes:\n * - Ensure that the `popupParameter` object is properly configured to avoid runtime errors.\n * - The `messageBuilder` function in `popupParameter` allows dynamic message generation based on the `params` object.\n * - The `isOpen` signal can be used to programmatically control the popup's visibility.\n */\n@Component({\n selector: 'ngssm-action-confirmation-popup',\n imports: [MatCard, MatCardHeader, MatCardTitle, MatCardActions, MatButton],\n templateUrl: './action-confirmation-popup.component.html'\n})\nexport class ActionConfirmationPopupComponent implements ActionPopupComponent<unknown, unknown, ActionConfirmationPopupParameter> {\n public readonly message = signal<string>('No message');\n public readonly cancelButtonLabel = signal<string>('No');\n public readonly confirmButtonLabel = signal<string>('Yes');\n public readonly color = signal<string>('primary');\n\n public isOpen = signal<boolean>(false);\n\n private params?: ICellRendererParams;\n private popupParameter?: ActionConfirmationPopupParameter;\n\n public init(\n popupRendered: WritableSignal<boolean>,\n params?: ICellRendererParams<unknown, unknown>,\n popupParameter?: ActionConfirmationPopupParameter\n ): void {\n this.params = params;\n this.popupParameter = popupParameter;\n\n this.message.set(popupParameter?.messageBuilder?.(params) ?? 'No message');\n this.color.set(popupParameter?.color ?? 'primary');\n this.cancelButtonLabel.set(popupParameter?.cancelButtonLabel ?? 'Cancel');\n this.confirmButtonLabel.set(popupParameter?.confirmButtonLabel ?? 'Confirm');\n\n this.isOpen = popupRendered;\n }\n\n public closePopup(): void {\n this.isOpen.set(false);\n }\n\n public executeAction(): void {\n this.popupParameter?.confirmAction?.(this.params);\n this.closePopup();\n }\n}\n","<mat-card class=\"fxFlex flex-column-stretch\">\n <mat-card-header>\n <mat-card-title>{{ message() }}</mat-card-title>\n </mat-card-header>\n <mat-card-actions class=\"flex-row-center\">\n <span class=\"fxFlex\"></span>\n <button mat-button (click)=\"closePopup()\">{{ cancelButtonLabel() }}</button>\n <button mat-raised-button [color]=\"color()\" (click)=\"executeAction()\">{{ confirmButtonLabel() }}</button>\n </mat-card-actions>\n</mat-card>\n","import { ColDef } from 'ag-grid-community';\n\nexport const getColDefWithNoPadding = (): Partial<ColDef> => ({\n cellClass: ['cell-with-no-padding']\n});\n\nexport const getColDefForEditableColumn = (): Partial<ColDef> => ({\n editable: true,\n headerClass: 'ngssm-ag-editable-cell',\n valueSetter: () => false\n});\n","import { inject, Injectable } from '@angular/core';\n\nimport { Effect, State, Action, Logger, ActionDispatcher } from 'ngssm-store';\n\nimport { AgGridAction, AgGridActionType, RegisterAgGridStateAction } from '../actions';\nimport { ChangeOrigin, selectAgGridState } from '../state';\n\n@Injectable()\nexport class LocalStorageEffect implements Effect {\n public readonly processedActions: string[] = [AgGridActionType.saveColumnStatesOnDisk, AgGridActionType.resetColumnStatesFromDisk];\n\n private readonly logger = inject(Logger);\n\n public processAction(actiondispatcher: ActionDispatcher, state: State, action: Action): void {\n const agGridAction = action as AgGridAction;\n\n switch (action.type) {\n case AgGridActionType.saveColumnStatesOnDisk: {\n const gridState = selectAgGridState(state).gridStates[agGridAction.gridId];\n if (gridState) {\n localStorage.setItem(this.getColumnStatesLocalStorageKey(agGridAction.gridId), JSON.stringify(gridState.columnStates));\n localStorage.setItem(this.getcolumnGroupStatesLocalStorageKey(agGridAction.gridId), JSON.stringify(gridState.columnGroupStates));\n if (gridState.filterModel) {\n localStorage.setItem(this.getFilterModelLocalStorageKey(agGridAction.gridId), JSON.stringify(gridState.filterModel));\n }\n }\n\n break;\n }\n\n case AgGridActionType.resetColumnStatesFromDisk: {\n const stored = localStorage.getItem(this.getColumnStatesLocalStorageKey(agGridAction.gridId));\n const columnGroupStates = localStorage.getItem(this.getcolumnGroupStatesLocalStorageKey(agGridAction.gridId));\n const filterModelStored = localStorage.getItem(this.getFilterModelLocalStorageKey(agGridAction.gridId));\n console.log(stored, filterModelStored);\n if (stored) {\n try {\n const columnStates = JSON.parse(stored);\n if (Array.isArray(columnStates)) {\n const action = new RegisterAgGridStateAction(\n agGridAction.gridId,\n ChangeOrigin.other,\n columnStates,\n columnGroupStates ? JSON.parse(columnGroupStates) : [],\n filterModelStored ? JSON.parse(filterModelStored) : null\n );\n actiondispatcher.dispatchAction(action);\n } else {\n this.logger.error(`Wrong columns state config for grid '${agGridAction.gridId}'`, stored);\n }\n } catch (error) {\n this.logger.error(`Unable to load config for grid '${agGridAction.gridId}'`, error);\n }\n }\n\n break;\n }\n }\n }\n\n private getColumnStatesLocalStorageKey(gridId: string): string {\n return `ngssm-ag-grid_${gridId}`;\n }\n\n private getcolumnGroupStatesLocalStorageKey(gridId: string): string {\n return `ngssm-ag-grid_groups_${gridId}`;\n }\n\n private getFilterModelLocalStorageKey(gridId: string): string {\n return `ngssm-ag-grid_filters_${gridId}`;\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Reducer, State, Action } from 'ngssm-store';\n\nimport { AgGridActionType, RegisterAgGridStateAction } from '../actions';\nimport { updateAgGridState } from '../state';\n\n@Injectable()\nexport class GridStatesReducer implements Reducer {\n public readonly processedActions: string[] = [AgGridActionType.registerAgGridState];\n\n public updateState(state: State, action: Action): State {\n switch (action.type) {\n case AgGridActionType.registerAgGridState: {\n const registerAgGridStateAction = action as RegisterAgGridStateAction;\n return updateAgGridState(state, {\n gridStates: {\n [registerAgGridStateAction.gridId]: {\n $set: {\n origin: registerAgGridStateAction.origin,\n columnStates: registerAgGridStateAction.columnStates,\n columnGroupStates: registerAgGridStateAction.columnGroupStates,\n filterModel: registerAgGridStateAction.filterModel\n }\n }\n }\n });\n }\n }\n\n return state;\n }\n}\n","import { Injectable } from '@angular/core';\n\nimport { Reducer, State, Action } from 'ngssm-store';\n\nimport { AgGridActionType, RegisterSelectedRowsAction } from '../actions';\nimport { updateAgGridState } from '../state';\n\n@Injectable()\nexport class SelectedRowsReducer implements Reducer {\n public readonly processedActions: string[] = [AgGridActionType.registerSelectedRows];\n\n public updateState(state: State, action: Action): State {\n switch (action.type) {\n case AgGridActionType.registerSelectedRows: {\n const registerSelectedRowsAction = action as RegisterSelectedRowsAction;\n return updateAgGridState(state, {\n selectedRows: {\n [registerSelectedRowsAction.gridId]: {\n $set: {\n origin: registerSelectedRowsAction.origin,\n ids: registerSelectedRowsAction.ids\n }\n }\n }\n });\n }\n }\n\n return state;\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\n\nimport { Logger, provideEffect, provideReducers, Store } from 'ngssm-store';\n\nimport { LocalStorageEffect } from './effects/local-storage.effect';\nimport { GridStatesReducer } from './reducers/grid-states.reducer';\nimport { SelectedRowsReducer } from './reducers/selected-rows.reducer';\nimport { NGSSM_AG_GRID_OPTIONS, NgssmAgGridOptions } from './ngssm-ag-grid-options';\nimport { AgGridAction, AgGridActionType } from './actions';\n\n/**\n * Loads saved grid states from localStorage at application startup if enabled in options.\n * Dispatches actions to restore grid state for each matching key.\n */\nexport const loadGridStates = () => {\n const logger = inject(Logger);\n const options = inject(NGSSM_AG_GRID_OPTIONS, { optional: true });\n if (!options?.loadSavedGridStatesAtStartup) {\n logger.information('[ag-grid] No grid state must be loaded at startup.');\n return;\n }\n\n const store = inject(Store);\n const wantedPrefix = 'ngssm-ag-grid_';\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key?.startsWith(wantedPrefix)) {\n const gridId = key.slice(wantedPrefix.length);\n logger.information(`[ag-grid] Restoring '${gridId}'.`);\n store.dispatchAction(new AgGridAction(AgGridActionType.resetColumnStatesFromDisk, gridId));\n }\n }\n};\n\n/**\n * Provides all necessary providers for NgssmAgGrid, including reducers, effects, options, and grid state loading.\n * @param options Optional configuration for the grid.\n * @returns EnvironmentProviders for NgssmAgGrid.\n */\nexport const provideNgssmAgGrid = (options?: NgssmAgGridOptions): EnvironmentProviders => {\n return makeEnvironmentProviders([\n provideAppInitializer(loadGridStates),\n {\n provide: NGSSM_AG_GRID_OPTIONS,\n useValue: options ?? null\n },\n provideReducers(GridStatesReducer, SelectedRowsReducer),\n provideEffect(LocalStorageEffect)\n ]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAY;CAAZ,SAAY,kBAAgB;CAC1B,iBAAA,yBAAA;CACA,iBAAA,0BAAA;CACA,iBAAA,4BAAA;CACA,iBAAA,+BAAA;AACF,EAAA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,EAAS,8BAA8B;EAC1C,OAAO,YAAY,oDAAoD;EACvE;CACF;CAEA,MAAM,QAAQ,OAAO,KAAK;CAC1B,MAAM,eAAe;CACrB,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAC5C,MAAM,MAAM,aAAa,IAAI,CAAC;EAC9B,IAAI,KAAK,WAAW,YAAY,GAAG;GACjC,MAAM,SAAS,IAAI,MAAM,EAAmB;GAC5C,OAAO,YAAY,wBAAwB,OAAM,GAAI;GACrD,MAAM,eAAe,IAAI,aAAa,iBAAiB,2BAA2B,MAAM,CAAC;EAC3F;CACF;AACF;AAOA,MAAa,sBAAsB,YAAsD;CACvF,OAAO,yBAAyB;EAC9B,sBAAsB,cAAc;EACpC;GACE,SAAS;GACT,UAAU,WAAW;EACtB;EACD,gBAAgB,mBAAmB,mBAAmB;EACtD,cAAc,kBAAkB;CACjC,CAAA;AACH"}
|
|
1
|
+
{"version":3,"file":"ngssm-ag-grid.mjs","names":[],"sources":["../../../projects/ngssm-ag-grid/src/lib/ngssm-ag-grid-action-type.ts","../../../projects/ngssm-ag-grid/src/lib/state/ngssm-ag-grid.state.ts","../../../projects/ngssm-ag-grid/src/lib/state/change-origin.ts","../../../projects/ngssm-ag-grid/src/lib/state/selected-rows.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-actions-cell-renderer/ngssm-actions-cell-renderer.component.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-actions-cell-renderer/ngssm-actions-cell-renderer.component.html","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-actions-cell-renderer/ngssm-actions-cell-renderer-params.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-ag-grid-config.ts","../../../projects/ngssm-ag-grid/src/lib/ngssm-ag-grid-options.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-ag-grid-theme.directive.ts","../../../projects/ngssm-ag-grid/src/lib/set-ag-grid-state.ts","../../../projects/ngssm-ag-grid/src/lib/set-selected-rows.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-ag-grid.directive.ts","../../../projects/ngssm-ag-grid/src/lib/components/ngssm-base-cell-editor.ts","../../../projects/ngssm-ag-grid/src/lib/components/action-confirmation-popup/action-confirmation-popup.component.ts","../../../projects/ngssm-ag-grid/src/lib/components/action-confirmation-popup/action-confirmation-popup.component.html","../../../projects/ngssm-ag-grid/src/lib/helpers.ts","../../../projects/ngssm-ag-grid/src/lib/clear-selected-rows.ts","../../../projects/ngssm-ag-grid/src/lib/save-column-states-on-disk.ts","../../../projects/ngssm-ag-grid/src/lib/restore-column-states-from-disk.ts","../../../projects/ngssm-ag-grid/src/lib/provide-ngssm-ag-grid.ts"],"sourcesContent":["import { Action } from 'ngssm-store';\n\nexport enum NgssmAgGridActionType {\n setAgGridState = '[NgssmAgGridActionType] setAgGridState',\n setSelectedRows = '[NgssmAgGridActionType] setSelectedRows',\n clearSelectedRows = '[NgssmAgGridActionType] clearSelectedRows',\n saveColumnStatesOnDisk = '[NgssmAgGridActionType] saveColumnStatesOnDisk',\n restoreColumnStatesFromDisk = '[NgssmAgGridActionType] restoreColumnStatesFromDisk'\n}\n\nexport class NgssmAgGridAction implements Action {\n constructor(\n public readonly type: string,\n public readonly gridId: string\n ) {}\n}\n","import update, { Spec } from 'immutability-helper';\n\nimport { NgSsmFeatureState, State } from 'ngssm-store';\nimport { GridState } from './grid-state';\nimport { SelectedRows } from './selected-rows';\n\nexport const selectNgssmAgGridState = (state: State): NgssmAgGridState =>\n state[NgssmAgGridStateSpecification.featureStateKey] as NgssmAgGridState;\n\nexport const updateNgssmAgGridState = (state: State, command: Spec<NgssmAgGridState, never>): State =>\n update(state, {\n [NgssmAgGridStateSpecification.featureStateKey]: command\n });\n\nexport interface NgssmAgGridState {\n gridStates: Record<string, GridState>;\n selectedRows: Record<string, SelectedRows>;\n}\n\n@NgSsmFeatureState({\n featureStateKey: NgssmAgGridStateSpecification.featureStateKey,\n initialState: NgssmAgGridStateSpecification.initialState\n})\nexport class NgssmAgGridStateSpecification {\n public static readonly featureStateKey = 'ngssm-ag-grid-state';\n public static readonly initialState: NgssmAgGridState = {\n gridStates: {},\n selectedRows: {}\n };\n}\n","export enum ChangeOrigin {\n agGrid = 'agGrid',\n other = 'other'\n}\n","import { computed, inject, Signal } from '@angular/core';\n\nimport { Store } from 'ngssm-store';\n\nimport { ChangeOrigin } from './change-origin';\nimport { selectNgssmAgGridState } from './ngssm-ag-grid.state';\n\nexport interface SelectedRows {\n origin: ChangeOrigin;\n ids: string[];\n}\n\nexport const selectedRowsIdsSignal = (gridId: string | Signal<string>): Signal<string[]> => {\n const store = inject(Store);\n const gridIdSignal = computed(() => (typeof gridId === 'string' ? gridId : gridId()));\n\n return computed(() => selectNgssmAgGridState(store.state()).selectedRows[gridIdSignal()]?.ids ?? []);\n};\n","/**\n * The `NgssmActionsCellRendererComponent` is a custom cell renderer for `ag-grid` that dynamically renders\n * action buttons within a grid cell. It provides flexibility in configuring button behavior, visibility, and state.\n *\n * ### Features:\n * - Dynamically generates action buttons based on the provided configuration.\n * - Supports reactive state management using Angular signals.\n * - Integrates with observables, functions, or signals for `isDisabled` and `isHidden` properties.\n * - Provides customizable tooltips and button styles.\n * - Executes custom actions when buttons are clicked.\n *\n * ### Usage:\n * To use this component, provide it as a cell renderer in your `ag-grid` column definition:\n *\n * ```typescript\n * columnDefs: [\n * {\n * headerName: 'Actions',\n * field: 'actions',\n * cellRenderer: NgssmActionsCellRendererComponent,\n * cellRendererParams: {\n * actions: [\n * {\n * cssClass: 'delete-button',\n * color: 'warn',\n * tooltip: 'Delete Item',\n * isDisabled: (params) => params.data.isLocked,\n * isHidden: (params) => !params.data.canDelete,\n * click: (params) => console.log('Delete action clicked', params)\n * }\n * ]\n * }\n * }\n * ];\n * ```\n *\n * ### Inputs:\n * - `NgssmActionsCellRendererParams`: Configuration object passed to the component via `cellRendererParams`.\n * - `actions`: Array of `ActionConfig` objects defining the buttons to render.\n *\n * ### Outputs:\n * None.\n *\n * ### Dependencies:\n * - Angular Material components: `MatIconButton`, `MatIcon`, `MatTooltip`.\n * - `ag-grid-angular` for integration with `ag-grid`.\n *\n * ### Example ActionConfig:\n * ```typescript\n * interface ActionConfig {\n * cssClass: string; // CSS class for the button.\n * color?: string; // Button color (e.g., 'primary', 'warn').\n * tooltip?: string; // Tooltip text for the button.\n * isDisabled?: boolean | Signal<boolean> | Observable<boolean> | ((params: ICellRendererParams) => boolean);\n * isHidden?: boolean | Signal<boolean> | Observable<boolean> | ((params: ICellRendererParams) => boolean);\n * click?: (params: ICellRendererParams) => void; // Action to execute on button click.\n * }\n * ```\n *\n * ### Methods:\n * - `agInit(params: ICellRendererParams)`: Initializes the component with the provided cell renderer parameters.\n * - `refresh(params: ICellRendererParams)`: Refreshes the component state when the grid updates.\n * - `executeAction(action: ActionButton)`: Executes the action associated with a button.\n *\n * ### Internal Logic:\n * - The `setupActions` method initializes the action buttons based on the provided configuration.\n * - The `setUpActionSignal` method handles the initialization of `isDisabled` and `isHidden` states for each button.\n * - The component uses Angular signals (`WritableSignal` and `Signal`) to manage the state of `isDisabled` and `isHidden`.\n * - Observables are converted to signals using `toSignal` for seamless integration with Angular's reactivity system.\n *\n * ### Notes:\n * - Ensure that the `actions` array in `NgssmActionsCellRendererParams` is properly configured to avoid runtime errors.\n * - The component is designed to work with Angular Material and requires the relevant modules to be imported in your application.\n * - The `isDisabled` and `isHidden` properties can accept multiple input types (boolean, function, signal, or observable), providing flexibility in defining button behavior.\n */\n\nimport { Component, signal, WritableSignal, Signal, inject, EnvironmentInjector, runInInjectionContext, isSignal } from '@angular/core';\nimport { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';\nimport { MatIcon } from '@angular/material/icon';\nimport { MatTooltip } from '@angular/material/tooltip';\nimport { MatIconButton } from '@angular/material/button';\nimport { isObservable } from 'rxjs';\nimport { toSignal } from '@angular/core/rxjs-interop';\n\nimport { ICellRendererAngularComp } from 'ag-grid-angular';\nimport { ICellRendererParams } from 'ag-grid-community';\n\nimport { NgssmComponentAction, NgssmComponentDisplayDirective } from 'ngssm-toolkit';\n\nimport { NgssmActionsCellRendererParams } from './ngssm-actions-cell-renderer-params';\nimport { ActionConfig, ActionDisabledFunc, ActionHiddenFunc, ActionPopupComponent } from './action-config';\n\ninterface ActionButton {\n cssClass: string;\n color: string;\n\n isDisabled: WritableSignal<boolean> | Signal<boolean>;\n isHidden: WritableSignal<boolean> | Signal<boolean>;\n\n isDisabledInputAFunction: boolean;\n isHiddenInputAFunction: boolean;\n\n actionConfig: ActionConfig;\n\n tooltip: string;\n\n popupRendered: WritableSignal<boolean>;\n popupAction?: NgssmComponentAction;\n}\n\n@Component({\n selector: 'ngssm-actions-cell-renderer',\n imports: [MatIconButton, MatIcon, MatTooltip, CdkOverlayOrigin, CdkConnectedOverlay, NgssmComponentDisplayDirective],\n templateUrl: './ngssm-actions-cell-renderer.component.html'\n})\nexport class NgssmActionsCellRendererComponent implements ICellRendererAngularComp {\n public readonly actionButtons = signal<ActionButton[]>([]);\n\n private environmentInjector = inject(EnvironmentInjector);\n private cellParams: ICellRendererParams | undefined;\n\n public agInit(params: ICellRendererParams): void {\n this.cellParams = params;\n this.setupActions(params as unknown as NgssmActionsCellRendererParams);\n }\n\n public refresh(params: ICellRendererParams): boolean {\n this.cellParams = params;\n this.actionButtons().forEach((a) => {\n if (a.isDisabledInputAFunction) {\n (a.isDisabled as WritableSignal<boolean>).set((a.actionConfig.isDisabled as ActionDisabledFunc)(params));\n }\n\n if (a.isHiddenInputAFunction) {\n (a.isHidden as WritableSignal<boolean>).set((a.actionConfig.isHidden as ActionHiddenFunc)(params));\n }\n });\n return true;\n }\n\n public executeAction(action: ActionButton): void {\n const params = this.cellParams;\n if (params) {\n action.actionConfig.click?.(params);\n }\n }\n\n private setupActions(rendererParams: NgssmActionsCellRendererParams): void {\n runInInjectionContext(this.environmentInjector, () => {\n const actionButtons: ActionButton[] = (rendererParams?.actions ?? []).map((a) => {\n const actionButton: ActionButton = {\n cssClass: a.cssClass,\n color: a.color ?? 'primary',\n isDisabled: signal(false),\n isDisabledInputAFunction: false,\n isHidden: signal(false),\n isHiddenInputAFunction: false,\n actionConfig: a,\n tooltip: a.tooltip ?? '',\n popupRendered: signal(false)\n };\n\n if (a.popupComponent) {\n actionButton.popupAction = ((component: ActionPopupComponent) =>\n this.setupPopupComponent(component, actionButton)) as NgssmComponentAction;\n }\n\n this.setUpActionSignal(actionButton, a, rendererParams, 'isDisabled');\n this.setUpActionSignal(actionButton, a, rendererParams, 'isHidden');\n\n return actionButton;\n });\n\n this.actionButtons.set(actionButtons);\n });\n }\n\n private setUpActionSignal(\n actionButton: ActionButton,\n config: ActionConfig,\n rendererParams: NgssmActionsCellRendererParams,\n signalName: 'isDisabled' | 'isHidden'\n ): void {\n const input = config[signalName];\n\n if (isSignal(input)) {\n actionButton[signalName] = input as Signal<boolean>;\n } else if (input instanceof Function) {\n (actionButton[signalName] as WritableSignal<boolean>).set(input(rendererParams as unknown as ICellRendererParams));\n actionButton[`${signalName}InputAFunction`] = true;\n } else if (isObservable(input)) {\n actionButton[signalName] = toSignal(input, { initialValue: false });\n }\n }\n\n private setupPopupComponent(component: ActionPopupComponent, action: ActionButton): void {\n component?.init?.(action.popupRendered, this.cellParams as unknown as ICellRendererParams, action.actionConfig.popupParameter);\n }\n}\n","<div class=\"ngssm-actions-cell\">\n @for (actionButton of actionButtons(); track actionButton; let idx = $index) {\n @if (!actionButton.isHidden()) {\n @if (actionButton.actionConfig.popupComponent) {\n <button\n mat-icon-button\n class=\"ngssm-actions-cell-button\"\n [color]=\"actionButton.color\"\n id=\"action_{{ idx }}\"\n [disabled]=\"actionButton.isDisabled()\"\n [matTooltip]=\"actionButton.tooltip\"\n cdkOverlayOrigin\n #trigger=\"cdkOverlayOrigin\"\n (click)=\"actionButton.popupRendered.set(true)\">\n <mat-icon [class]=\"actionButton.cssClass\"></mat-icon>\n </button>\n <ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayHasBackdrop]=\"true\"\n [cdkConnectedOverlayOrigin]=\"trigger\"\n [cdkConnectedOverlayOpen]=\"actionButton.popupRendered()\">\n <div [ngssmComponentDisplay]=\"actionButton.actionConfig.popupComponent\" [ngssmComponentAction]=\"actionButton.popupAction\"></div>\n </ng-template>\n } @else {\n <button\n mat-icon-button\n class=\"ngssm-actions-cell-button\"\n [color]=\"actionButton.color\"\n id=\"action_{{ idx }}\"\n [disabled]=\"actionButton.isDisabled()\"\n (click)=\"executeAction(actionButton)\"\n [matTooltip]=\"actionButton.tooltip\">\n <mat-icon [class]=\"actionButton.cssClass\"></mat-icon>\n </button>\n }\n }\n }\n</div>\n","import { ColDef } from 'ag-grid-community';\n\nimport { ActionConfig } from './action-config';\nimport { NgssmActionsCellRendererComponent } from './ngssm-actions-cell-renderer.component';\n\n// Parameters of the actions cell renderer\n// For now, an action is rendered as a mat-icon-button with the class passed in ActionConfig\nexport interface NgssmActionsCellRendererParams<TData = unknown, TValue = unknown> {\n actions: ActionConfig<TData, TValue>[];\n}\n\nexport const getNgssmActionsCellColDef = <TData = unknown, TValue = unknown>(\n params: NgssmActionsCellRendererParams<TData, TValue>\n): Partial<ColDef> => ({\n cellRenderer: NgssmActionsCellRendererComponent,\n cellRendererParams: params\n});\n","import { AgPublicEventType, GetContextMenuItems } from 'ag-grid-community';\n\n/**\n * List of default ag-grid events listened by the directive to update the stored state.\n */\nexport const defaultAgGridColumnsEvents: AgPublicEventType[] = [\n 'sortChanged',\n 'filterChanged',\n 'columnPinned',\n 'columnResized',\n 'displayedColumnsChanged',\n 'filterChanged',\n 'columnGroupOpened'\n];\n\n/**\n * Configuration parameters of the {@link NgssmAgGridDirective} directive to apply on a\n * {@link https://www.ag-grid.com/ ag-grid instance}\n */\nexport interface NgssmAgGridConfig {\n /**\n * Unique identifier of the grid on which the directive is applied\n */\n gridId: string;\n\n /**\n * If true, the selected rows are stored in the state and restored when the directive is created.\n */\n keepSelection?: boolean;\n\n /**\n * If true, context menus are added to the grid to save the columns state into the local storage\n * and to restore from the local storage.\n *\n * @remarks\n *\n * this functionnality is only available for enterprise version of {@link https://www.ag-grid.com/}.\n */\n canSaveOnDiskColumnStates?: boolean;\n\n /**\n * Used to override default context menu items.\n */\n getContextMenuItems?: GetContextMenuItems;\n\n /**\n * Defines the list of ag-grid events listened to by the directive to update the state of stored columns.\n * By default: defaultAgGridColumnsEvents\n */\n listenedColumnsEvents?: AgPublicEventType[];\n}\n","import { InjectionToken } from '@angular/core';\nimport { ColDef, StatusPanelDef } from 'ag-grid-community';\n\n/**\n * Configuration options for NgssmAgGrid.\n * - theme: The CSS theme to use for the grid.\n * - statusBar: Optional status bar configuration for AG Grid.\n * - defaultColDef: Optional default column definition for all columns.\n * - loadSavedGridStatesAtStartup: If true, grid states saved in local storage are loaded during app initialization.\n */\nexport class NgssmAgGridOptions {\n theme = 'ag-theme-material';\n statusBar:\n | {\n statusPanels: StatusPanelDef[];\n }\n | undefined = undefined;\n defaultColDef: ColDef | undefined = undefined;\n loadSavedGridStatesAtStartup?: boolean = undefined;\n}\n\n/**\n * Injection token for providing NgssmAgGridOptions in Angular DI.\n *\n * Provide options through the provideNgssmAgGrid function instead of using this token.\n */\nexport const NGSSM_AG_GRID_OPTIONS = new InjectionToken<NgssmAgGridOptions>('NGSSM_AG_GRID_OPTIONS');\n","import { Directive, HostBinding, inject } from '@angular/core';\n\nimport { AgGridAngular } from 'ag-grid-angular';\n\nimport { NgssmAgGridOptions, NGSSM_AG_GRID_OPTIONS } from '../ngssm-ag-grid-options';\n\n@Directive({\n selector: '[ngssmAgGridTheme]'\n})\nexport class NgssmAgGridThemeDirective {\n @HostBinding('class') className = '';\n\n private readonly options: NgssmAgGridOptions | null = inject(NGSSM_AG_GRID_OPTIONS, { optional: true });\n private agGridAngular = inject(AgGridAngular);\n\n constructor() {\n this.className = (this.options ?? new NgssmAgGridOptions()).theme;\n if (this.agGridAngular.statusBar === undefined) {\n this.agGridAngular.statusBar = this.options?.statusBar;\n }\n\n if (this.agGridAngular.defaultColDef === undefined) {\n this.agGridAngular.defaultColDef = this.options?.defaultColDef;\n }\n }\n}\n","import { Action, ReducerFunc } from 'ngssm-store';\n\nimport { ColumnState, FilterModel } from 'ag-grid-community';\n\nimport { NgssmAgGridActionType } from './ngssm-ag-grid-action-type';\nimport { ChangeOrigin, ColumnGroupState, updateNgssmAgGridState } from './state';\n\nexport class NgssmSetAgGridStateAction implements Action {\n public readonly type: string = NgssmAgGridActionType.setAgGridState;\n\n constructor(\n public readonly gridId: string,\n public readonly origin: ChangeOrigin,\n public readonly columnStates: ColumnState[],\n public readonly columnGroupStates: ColumnGroupState[],\n public readonly filterModel: FilterModel | null\n ) {}\n}\n\nexport const setAgGridState: ReducerFunc<NgssmSetAgGridStateAction> = (state, action) => {\n return updateNgssmAgGridState(state, {\n gridStates: {\n [action.gridId]: {\n $set: {\n origin: action.origin,\n columnStates: action.columnStates,\n columnGroupStates: action.columnGroupStates,\n filterModel: action.filterModel\n }\n }\n }\n });\n};\n","import { Action, ReducerFunc } from 'ngssm-store';\n\nimport { NgssmAgGridActionType } from './ngssm-ag-grid-action-type';\nimport { ChangeOrigin, updateNgssmAgGridState } from './state';\n\nexport class NgssmSetSelectedRowsAction implements Action {\n public readonly type: string = NgssmAgGridActionType.setSelectedRows;\n\n constructor(\n public readonly gridId: string,\n public readonly origin: ChangeOrigin,\n public readonly ids: string[]\n ) {}\n}\n\nexport const setSelectedRows: ReducerFunc<NgssmSetSelectedRowsAction> = (state, action) => {\n return updateNgssmAgGridState(state, {\n selectedRows: {\n [action.gridId]: {\n $set: {\n origin: action.origin,\n ids: action.ids\n }\n }\n }\n });\n};\n","import { Directive, inject, signal, input, effect, runInInjectionContext, Injector } from '@angular/core';\nimport { take } from 'rxjs';\n\nimport { AgGridAngular } from 'ag-grid-angular';\nimport { DefaultMenuItem, GetContextMenuItemsParams, MenuItemDef, SelectionChangedEvent } from 'ag-grid-community';\n\nimport { createSignal, Logger, Store } from 'ngssm-store';\n\nimport { ChangeOrigin, ColumnGroupState, selectNgssmAgGridState } from '../state';\nimport { defaultAgGridColumnsEvents, NgssmAgGridConfig } from './ngssm-ag-grid-config';\nimport { NgssmSetAgGridStateAction } from '../set-ag-grid-state';\nimport { NgssmAgGridAction, NgssmAgGridActionType } from '../ngssm-ag-grid-action-type';\nimport { NgssmSetSelectedRowsAction } from '../set-selected-rows';\n\n@Directive({\n selector: '[ngssmAgGrid]'\n})\nexport class NgssmAgGridDirective {\n public readonly config = input.required<NgssmAgGridConfig, string | NgssmAgGridConfig>({\n alias: 'ngssmAgGrid',\n transform: (v) => {\n if (typeof v === 'string') {\n return {\n gridId: v as string\n };\n }\n\n const conf = v as NgssmAgGridConfig;\n return {\n ...conf\n };\n }\n });\n\n private readonly logger = inject(Logger);\n private readonly store = inject(Store);\n private readonly agGridAngular = inject(AgGridAngular);\n private readonly injector = inject(Injector);\n\n private readonly gridInitialized = signal(false);\n private readonly gridStates = createSignal((state) => selectNgssmAgGridState(state).gridStates);\n private readonly selectedRows = createSignal((state) => selectNgssmAgGridState(state).selectedRows);\n\n constructor() {\n this.logger.information(`[NgssmAgGridDirective] Initialization...`);\n\n // Setup gridInintialized signal\n this.agGridAngular.gridReady.pipe(take(1)).subscribe(() => this.gridInitialized.set(true));\n\n // Apply registered grid setup if any and start listening to ag-grid events\n const effectRef = effect(() => {\n if (!this.gridInitialized()) {\n return;\n }\n\n this.logger.information(`[NgssmAgGridDirective] Initialization for '${this.config().gridId}' in progress`);\n\n const gridState = this.gridStates()[this.config().gridId];\n if (gridState) {\n this.agGridAngular.api.setColumnGroupState(gridState.columnGroupStates);\n this.agGridAngular.api.applyColumnState({\n state: gridState.columnStates,\n applyOrder: true\n });\n this.agGridAngular.api.setFilterModel(gridState.filterModel);\n }\n\n if (this.config().keepSelection) {\n const selection = this.selectedRows()[this.config().gridId];\n if (selection) {\n const ids = selection.ids ?? [];\n this.agGridAngular.api.forEachNode((node) => {\n if (node.id) {\n node.setSelected(ids.includes(node.id));\n }\n });\n }\n }\n\n runInInjectionContext(this.injector, () => this.initSateChangeListener());\n\n effectRef.destroy();\n\n this.logger.information(`[NgssmAgGridDirective] Initialization for '${this.config().gridId}' done`);\n });\n\n // process changes in columns when not comming from ui\n effect(() => {\n if (!this.gridInitialized()) {\n return;\n }\n\n const gridState = this.gridStates()[this.config().gridId];\n if (gridState?.origin === ChangeOrigin.other) {\n this.agGridAngular.api.setColumnGroupState(gridState.columnGroupStates);\n this.agGridAngular.api.applyColumnState({\n state: gridState.columnStates,\n applyOrder: true\n });\n\n this.agGridAngular.api.setFilterModel(gridState.filterModel);\n }\n });\n\n // process changes in selection when not comming from ui\n effect(() => {\n if (!this.gridInitialized()) {\n return;\n }\n\n if (this.config().keepSelection !== true) {\n return;\n }\n\n const selection = this.selectedRows()[this.config().gridId];\n if (!selection || selection.origin !== ChangeOrigin.other) {\n return;\n }\n\n const ids = selection.ids ?? [];\n this.agGridAngular.api.forEachNode((node) => {\n if (node.id) {\n node.setSelected(ids.includes(node.id));\n }\n });\n });\n\n this.agGridAngular.getContextMenuItems = (params) => this.getContextMenuItems(params);\n this.logger.information(`[NgssmAgGridDirective] Initialization done.`);\n }\n\n private initSateChangeListener(): void {\n (this.config().listenedColumnsEvents ?? defaultAgGridColumnsEvents).forEach((eventType) => {\n this.agGridAngular.api.addEventListener(eventType, () => this.saveGridState());\n });\n\n this.agGridAngular.api.addEventListener('selectionChanged', (event) => this.processSelectionChanged(event));\n }\n\n private saveGridState(): void {\n const state = this.agGridAngular.api.getColumnState();\n const filterModel = this.agGridAngular.api.getFilterModel();\n const columnGroupStates: ColumnGroupState[] = this.agGridAngular.api.getColumnGroupState();\n this.store.dispatchAction(\n new NgssmSetAgGridStateAction(this.config().gridId, ChangeOrigin.agGrid, state, columnGroupStates, filterModel)\n );\n }\n\n private processSelectionChanged(event: SelectionChangedEvent): void {\n if (this.config().keepSelection !== true) {\n return;\n }\n\n const selectedRows = (event.selectedNodes ?? []).map((n) => n.id ?? '').filter((n) => n !== '');\n\n this.store.dispatchAction(new NgssmSetSelectedRowsAction(this.config().gridId, ChangeOrigin.agGrid, selectedRows));\n }\n\n private getContextMenuItems(params: GetContextMenuItemsParams): (DefaultMenuItem | MenuItemDef)[] {\n this.logger.information('[NgssmAgGridDirective] Generating the context menu...');\n const menuItems: (DefaultMenuItem | MenuItemDef)[] = [];\n const getContextMenuItems = this.config().getContextMenuItems;\n if (getContextMenuItems) {\n menuItems.push(...(getContextMenuItems(params) as (DefaultMenuItem | MenuItemDef)[]));\n } else {\n menuItems.push(...(params.defaultItems ?? []));\n }\n\n if (this.config().canSaveOnDiskColumnStates === true) {\n const gridId = this.config().gridId;\n menuItems.push(\n ...[\n 'separator' as DefaultMenuItem,\n {\n name: 'Save columns state',\n action: () => this.store.dispatchAction(new NgssmAgGridAction(NgssmAgGridActionType.saveColumnStatesOnDisk, gridId)),\n icon: '<i class=\"fa-regular fa-floppy-disk\"></i>'\n },\n {\n name: 'Restore columns state',\n action: () => this.store.dispatchAction(new NgssmAgGridAction(NgssmAgGridActionType.restoreColumnStatesFromDisk, gridId)),\n icon: '<i class=\"fa-solid fa-rotate-right\"></i>'\n },\n {\n name: 'Reset columns state to default',\n action: () => {\n this.agGridAngular.api.resetColumnState();\n this.agGridAngular.api.resetColumnGroupState();\n this.agGridAngular.api.setFilterModel(null);\n },\n icon: '<i class=\"fa-solid fa-clock-rotate-left\"></i>'\n }\n ]\n );\n }\n return menuItems;\n }\n}\n","import { ICellEditorAngularComp } from 'ag-grid-angular';\nimport { ICellEditorParams } from 'ag-grid-community';\n\nexport abstract class NgssmBaseCellEditor implements ICellEditorAngularComp {\n protected params?: ICellEditorParams;\n\n public agInit(params: ICellEditorParams): void {\n this.params = params;\n }\n\n public getValue() {\n return '';\n }\n\n public isPopup(): boolean {\n return true;\n }\n\n public getPopupPosition(): 'over' | 'under' | undefined {\n return 'over';\n }\n\n public isCancelAfterEnd(): boolean {\n return true;\n }\n\n public cancel(): void {\n this.params?.stopEditing();\n }\n}\n","import { Component, signal, WritableSignal } from '@angular/core';\nimport { MatButton } from '@angular/material/button';\nimport { MatCard, MatCardActions, MatCardTitle, MatCardHeader } from '@angular/material/card';\nimport { ICellRendererParams } from 'ag-grid-community';\n\nimport { ActionConfirmationPopupParameter } from './action-confirmation-popup-parameter';\nimport { ActionPopupComponent } from '../ngssm-actions-cell-renderer';\n\n/**\n * The `ActionConfirmationPopupComponent` is a reusable confirmation popup component designed to work with `ag-grid`.\n * It provides a customizable confirmation dialog for user actions, allowing developers to define messages, button labels,\n * and actions dynamically.\n *\n * ### Features:\n * - Displays a confirmation popup with customizable message, button labels, and color.\n * - Integrates with the `ActionPopupComponent` interface for seamless use with `NgssmActionsCellRendererComponent`.\n * - Uses Angular signals for efficient state management.\n * - Supports dynamic initialization with parameters provided by `ag-grid`.\n * - Provides methods to handle user actions (confirm or cancel) and close the popup.\n *\n * ### Usage:\n * This component is typically used as a popup in conjunction with the `NgssmActionsCellRendererComponent`.\n * To configure it, pass an `ActionConfirmationPopupParameter` object when initializing the popup.\n *\n * Example:\n * ```typescript\n * const popupParameter: ActionConfirmationPopupParameter = {\n * messageBuilder: (params) => `Are you sure you want to delete ${params.data.name}?`,\n * color: 'warn',\n * cancelButtonLabel: 'No',\n * confirmButtonLabel: 'Yes',\n * confirmAction: (params) => console.log('Confirmed action for:', params.data)\n * };\n * ```\n *\n * ### Inputs:\n * - `popupRendered`: A writable signal indicating whether the popup is currently rendered.\n * - `params`: The cell renderer parameters provided by `ag-grid`.\n * - `popupParameter`: An object of type `ActionConfirmationPopupParameter` that defines the popup's behavior and content.\n *\n * ### Outputs:\n * None.\n *\n * ### Dependencies:\n * - Angular Material components: `MatCard`, `MatButton`.\n * - `ag-grid-community` for integration with `ag-grid`.\n *\n * ### Methods:\n * - `init(popupRendered, params, popupParameter)`: Initializes the popup with the provided parameters.\n * - `popupRendered`: A writable signal to track the popup's visibility.\n * - `params`: The cell renderer parameters from `ag-grid`.\n * - `popupParameter`: The configuration object for the popup.\n *\n * - `closePopup()`: Closes the popup by setting the `isOpen` signal to `false`.\n *\n * - `executeAction()`: Executes the confirmation action defined in the `popupParameter` and closes the popup.\n *\n * ### Signals:\n * - `message`: The message displayed in the popup.\n * - `cancelButtonLabel`: The label for the cancel button.\n * - `confirmButtonLabel`: The label for the confirm button.\n * - `color`: The color theme for the confirm button (e.g., 'primary', 'warn').\n * - `isOpen`: Tracks whether the popup is currently open.\n *\n * ### Example Initialization:\n * ```typescript\n * const popup = new ActionConfirmationPopupComponent();\n * popup.init(\n * popupRenderedSignal,\n * cellRendererParams,\n * {\n * messageBuilder: (params) => `Are you sure you want to delete ${params.data.name}?`,\n * color: 'warn',\n * cancelButtonLabel: 'No',\n * confirmButtonLabel: 'Yes',\n * confirmAction: (params) => console.log('Confirmed action for:', params.data)\n * }\n * );\n * ```\n *\n * ### Notes:\n * - Ensure that the `popupParameter` object is properly configured to avoid runtime errors.\n * - The `messageBuilder` function in `popupParameter` allows dynamic message generation based on the `params` object.\n * - The `isOpen` signal can be used to programmatically control the popup's visibility.\n */\n@Component({\n selector: 'ngssm-action-confirmation-popup',\n imports: [MatCard, MatCardHeader, MatCardTitle, MatCardActions, MatButton],\n templateUrl: './action-confirmation-popup.component.html'\n})\nexport class ActionConfirmationPopupComponent implements ActionPopupComponent<unknown, unknown, ActionConfirmationPopupParameter> {\n public readonly message = signal<string>('No message');\n public readonly cancelButtonLabel = signal<string>('No');\n public readonly confirmButtonLabel = signal<string>('Yes');\n public readonly color = signal<string>('primary');\n\n public isOpen = signal<boolean>(false);\n\n private params?: ICellRendererParams;\n private popupParameter?: ActionConfirmationPopupParameter;\n\n public init(\n popupRendered: WritableSignal<boolean>,\n params?: ICellRendererParams<unknown, unknown>,\n popupParameter?: ActionConfirmationPopupParameter\n ): void {\n this.params = params;\n this.popupParameter = popupParameter;\n\n this.message.set(popupParameter?.messageBuilder?.(params) ?? 'No message');\n this.color.set(popupParameter?.color ?? 'primary');\n this.cancelButtonLabel.set(popupParameter?.cancelButtonLabel ?? 'Cancel');\n this.confirmButtonLabel.set(popupParameter?.confirmButtonLabel ?? 'Confirm');\n\n this.isOpen = popupRendered;\n }\n\n public closePopup(): void {\n this.isOpen.set(false);\n }\n\n public executeAction(): void {\n this.popupParameter?.confirmAction?.(this.params);\n this.closePopup();\n }\n}\n","<mat-card class=\"fxFlex flex-column-stretch\">\n <mat-card-header>\n <mat-card-title>{{ message() }}</mat-card-title>\n </mat-card-header>\n <mat-card-actions class=\"flex-row-center\">\n <span class=\"fxFlex\"></span>\n <button mat-button (click)=\"closePopup()\">{{ cancelButtonLabel() }}</button>\n <button mat-raised-button [color]=\"color()\" (click)=\"executeAction()\">{{ confirmButtonLabel() }}</button>\n </mat-card-actions>\n</mat-card>\n","import { ColDef } from 'ag-grid-community';\n\nexport const getColDefWithNoPadding = (): Partial<ColDef> => ({\n cellClass: ['cell-with-no-padding']\n});\n\nexport const getColDefForEditableColumn = (): Partial<ColDef> => ({\n editable: true,\n headerClass: 'ngssm-ag-editable-cell',\n valueSetter: () => false\n});\n","import { Action, ReducerFunc } from 'ngssm-store';\n\nimport { NgssmAgGridActionType } from './ngssm-ag-grid-action-type';\nimport { ChangeOrigin, updateNgssmAgGridState } from './state';\n\nexport class NgssmClearSelectedRowsAction implements Action {\n public readonly type: string = NgssmAgGridActionType.clearSelectedRows;\n\n constructor(public readonly gridId: string) {}\n}\n\nexport const clearSelectedRows: ReducerFunc<NgssmClearSelectedRowsAction> = (state, action) => {\n return updateNgssmAgGridState(state, {\n selectedRows: {\n [action.gridId]: {\n $set: {\n origin: ChangeOrigin.other,\n ids: []\n }\n }\n }\n });\n};\n","import { EffectFunc } from 'ngssm-store';\n\nimport { NgssmAgGridAction } from './ngssm-ag-grid-action-type';\nimport { selectNgssmAgGridState } from './state';\n\nexport const getColumnStatesLocalStorageKey = (gridId: string): string => {\n return `ngssm-ag-grid_${gridId}`;\n};\n\nexport const getcolumnGroupStatesLocalStorageKey = (gridId: string): string => {\n return `ngssm-ag-grid_groups_${gridId}`;\n};\n\nexport const getFilterModelLocalStorageKey = (gridId: string): string => {\n return `ngssm-ag-grid_filters_${gridId}`;\n};\n\nexport const saveColumnStatesOnDisk: EffectFunc<NgssmAgGridAction> = (state, action) => {\n const gridState = selectNgssmAgGridState(state).gridStates[action.gridId];\n if (gridState) {\n localStorage.setItem(getColumnStatesLocalStorageKey(action.gridId), JSON.stringify(gridState.columnStates));\n localStorage.setItem(getcolumnGroupStatesLocalStorageKey(action.gridId), JSON.stringify(gridState.columnGroupStates));\n if (gridState.filterModel) {\n localStorage.setItem(getFilterModelLocalStorageKey(action.gridId), JSON.stringify(gridState.filterModel));\n }\n }\n};\n","import { inject } from '@angular/core';\n\nimport { EffectFunc, Logger, Store } from 'ngssm-store';\n\nimport { NgssmAgGridAction } from './ngssm-ag-grid-action-type';\nimport {\n getcolumnGroupStatesLocalStorageKey,\n getColumnStatesLocalStorageKey,\n getFilterModelLocalStorageKey\n} from './save-column-states-on-disk';\nimport { NgssmSetAgGridStateAction } from './set-ag-grid-state';\nimport { ChangeOrigin } from './state';\n\nexport const restoreColumnStatesFromDisk: EffectFunc<NgssmAgGridAction> = (_, action) => {\n const stored = localStorage.getItem(getColumnStatesLocalStorageKey(action.gridId));\n const columnGroupStates = localStorage.getItem(getcolumnGroupStatesLocalStorageKey(action.gridId));\n const filterModelStored = localStorage.getItem(getFilterModelLocalStorageKey(action.gridId));\n const store = inject(Store);\n const logger = inject(Logger);\n if (stored) {\n try {\n const columnStates = JSON.parse(stored);\n if (Array.isArray(columnStates)) {\n const actionToDispatch = new NgssmSetAgGridStateAction(\n action.gridId,\n ChangeOrigin.other,\n columnStates,\n columnGroupStates ? JSON.parse(columnGroupStates) : [],\n filterModelStored ? JSON.parse(filterModelStored) : null\n );\n store.dispatchAction(actionToDispatch);\n } else {\n logger.error(`Wrong columns state config for grid '${action.gridId}'`, stored);\n }\n } catch (error) {\n logger.error(`Unable to load config for grid '${action.gridId}'`, error);\n }\n }\n};\n","import { EnvironmentProviders, makeEnvironmentProviders, inject, provideAppInitializer } from '@angular/core';\n\nimport { Logger, provideEffectFunc, provideReducerFunc, Store } from 'ngssm-store';\n\nimport { NGSSM_AG_GRID_OPTIONS, NgssmAgGridOptions } from './ngssm-ag-grid-options';\nimport { NgssmAgGridAction, NgssmAgGridActionType } from './ngssm-ag-grid-action-type';\nimport { clearSelectedRows } from './clear-selected-rows';\nimport { setAgGridState } from './set-ag-grid-state';\nimport { setSelectedRows } from './set-selected-rows';\nimport { saveColumnStatesOnDisk } from './save-column-states-on-disk';\nimport { restoreColumnStatesFromDisk } from './restore-column-states-from-disk';\n\n/**\n * Loads saved grid states from localStorage at application startup if enabled in options.\n * Dispatches actions to restore grid state for each matching key.\n */\nexport const loadGridStates = () => {\n const logger = inject(Logger);\n const options = inject(NGSSM_AG_GRID_OPTIONS, { optional: true });\n if (!options?.loadSavedGridStatesAtStartup) {\n logger.information('[ag-grid] No grid state must be loaded at startup.');\n return;\n }\n\n const store = inject(Store);\n const wantedPrefix = 'ngssm-ag-grid_';\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key?.startsWith(wantedPrefix)) {\n const gridId = key.slice(wantedPrefix.length);\n logger.information(`[ag-grid] Restoring '${gridId}'.`);\n store.dispatchAction(new NgssmAgGridAction(NgssmAgGridActionType.restoreColumnStatesFromDisk, gridId));\n }\n }\n};\n\n/**\n * Provides all necessary providers for NgssmAgGrid, including reducers, effects, options, and grid state loading.\n * @param options Optional configuration for the grid.\n * @returns EnvironmentProviders for NgssmAgGrid.\n */\nexport const provideNgssmAgGrid = (options?: NgssmAgGridOptions): EnvironmentProviders => {\n return makeEnvironmentProviders([\n provideAppInitializer(loadGridStates),\n {\n provide: NGSSM_AG_GRID_OPTIONS,\n useValue: options ?? null\n },\n provideReducerFunc([NgssmAgGridActionType.setAgGridState], setAgGridState),\n provideReducerFunc([NgssmAgGridActionType.setSelectedRows], setSelectedRows),\n provideReducerFunc([NgssmAgGridActionType.clearSelectedRows], clearSelectedRows),\n provideEffectFunc(NgssmAgGridActionType.saveColumnStatesOnDisk, saveColumnStatesOnDisk),\n provideEffectFunc(NgssmAgGridActionType.restoreColumnStatesFromDisk, restoreColumnStatesFromDisk)\n ]);\n};\n"],"mappings":";;;;;;;;;;;;;;AAEA,IAAY;CAAZ,SAAY,uBAAqB;CAC/B,sBAAA,oBAAA;CACA,sBAAA,qBAAA;CACA,sBAAA,uBAAA;CACA,sBAAA,4BAAA;CACA,sBAAA,iCAAA;AACF,EAAA,CANY,0BAAA,wBAAqB,CAAA,EAAA;AAQjC,IAAa,oBAAb,MAA8B;CAEV;CACA;CAFlB,YACkB,MACA,QAAc;EADd,KAAA,OAAA;EACA,KAAA,SAAA;CACf;AACJ;ACTD,MAAa,0BAA0B,UACrC,MAAM,8BAA8B;AAEtC,MAAa,0BAA0B,OAAc,YACnD,OAAO,OAAO,GACX,8BAA8B,kBAAkB,QAClD,CAAA;AAWI,IAAM,gCAAN,MAAM,8BAA6B;CACjC,OAAgB,kBAAkB;CAClC,OAAgB,eAAiC;EACtD,YAAY,CAAA;EACZ,cAAc,CAAA;CACf;;AALU,gCAA6B,WAAA,CAJzC,kBAAkB;CACjB,iBAAiB,8BAA8B;CAC/C,cAAc,8BAA8B;AAC7C,CAAA,CACY,GAAA,6BAA6B;ACvB1C,IAAY;CAAZ,SAAY,cAAY;CACtB,aAAA,YAAA;CACA,aAAA,WAAA;AACF,EAAA,CAHY,iBAAA,eAAY,CAAA,EAAA;ACYxB,MAAa,yBAAyB,WAAqD;CACzF,MAAM,QAAQ,OAAO,KAAK;CAC1B,MAAM,eAAe,eAAgB,OAAO,WAAW,WAAW,SAAS,OAAM,GAAI,GAAA,YAAA,CAAA,EAAA,WAAA,eAAA,CAAA,+BAAA,CAAA,CAAA;CAErF,OAAO,eAAe,uBAAuB,MAAM,MAAK,CAAE,CAAC,CAAC,aAAa,aAAY,EAAG,EAAE,OAAO,CAAA,CAAE;AACrG;ACkGA,IAAa,oCAAb,MAAa,kCAAiC;CAC5B,gB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ACH"}
|
package/package.json
CHANGED
package/types/ngssm-ag-grid.d.ts
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Action, State } from "ngssm-store";
|
|
1
|
+
import { Action, ReducerFunc, State } from "ngssm-store";
|
|
3
2
|
import { Spec } from "immutability-helper";
|
|
3
|
+
import { AgPublicEventType, ColDef, ColumnState, FilterModel, GetContextMenuItems, ICellEditorParams, ICellRendererParams, StatusPanelDef } from "ag-grid-community";
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
import { EnvironmentProviders, InjectionToken, Signal, Type, WritableSignal } from "@angular/core";
|
|
6
6
|
import { ICellEditorAngularComp, ICellRendererAngularComp } from "ag-grid-angular";
|
|
7
7
|
import { NgssmComponentAction } from "ngssm-toolkit";
|
|
8
8
|
import { Observable } from "rxjs";
|
|
9
|
-
export declare enum
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export declare enum NgssmAgGridActionType {
|
|
10
|
+
setAgGridState = "[NgssmAgGridActionType] setAgGridState",
|
|
11
|
+
setSelectedRows = "[NgssmAgGridActionType] setSelectedRows",
|
|
12
|
+
clearSelectedRows = "[NgssmAgGridActionType] clearSelectedRows",
|
|
13
|
+
saveColumnStatesOnDisk = "[NgssmAgGridActionType] saveColumnStatesOnDisk",
|
|
14
|
+
restoreColumnStatesFromDisk = "[NgssmAgGridActionType] restoreColumnStatesFromDisk"
|
|
15
|
+
}
|
|
16
|
+
export declare class NgssmAgGridAction implements Action {
|
|
17
|
+
readonly type: string;
|
|
18
|
+
readonly gridId: string;
|
|
19
|
+
constructor(type: string, gridId: string);
|
|
14
20
|
}
|
|
15
21
|
export declare enum ChangeOrigin {
|
|
16
22
|
agGrid = "agGrid",
|
|
@@ -30,36 +36,16 @@ export interface SelectedRows {
|
|
|
30
36
|
origin: ChangeOrigin;
|
|
31
37
|
ids: string[];
|
|
32
38
|
}
|
|
33
|
-
export declare const
|
|
34
|
-
export declare const
|
|
35
|
-
export
|
|
39
|
+
export declare const selectedRowsIdsSignal: (gridId: string | Signal<string>) => Signal<string[]>;
|
|
40
|
+
export declare const selectNgssmAgGridState: (state: State) => NgssmAgGridState;
|
|
41
|
+
export declare const updateNgssmAgGridState: (state: State, command: Spec<NgssmAgGridState, never>) => State;
|
|
42
|
+
export interface NgssmAgGridState {
|
|
36
43
|
gridStates: Record<string, GridState>;
|
|
37
44
|
selectedRows: Record<string, SelectedRows>;
|
|
38
45
|
}
|
|
39
|
-
export declare class
|
|
40
|
-
static readonly featureStateKey = "ag-grid-state";
|
|
41
|
-
static readonly initialState:
|
|
42
|
-
}
|
|
43
|
-
export declare class RegisterAgGridStateAction implements Action {
|
|
44
|
-
readonly gridId: string;
|
|
45
|
-
readonly origin: ChangeOrigin;
|
|
46
|
-
readonly columnStates: ColumnState[];
|
|
47
|
-
readonly columnGroupStates: ColumnGroupState[];
|
|
48
|
-
readonly filterModel: FilterModel | null;
|
|
49
|
-
readonly type: string;
|
|
50
|
-
constructor(gridId: string, origin: ChangeOrigin, columnStates: ColumnState[], columnGroupStates: ColumnGroupState[], filterModel: FilterModel | null);
|
|
51
|
-
}
|
|
52
|
-
export declare class RegisterSelectedRowsAction implements Action {
|
|
53
|
-
readonly gridId: string;
|
|
54
|
-
readonly origin: ChangeOrigin;
|
|
55
|
-
readonly ids: string[];
|
|
56
|
-
readonly type: string;
|
|
57
|
-
constructor(gridId: string, origin: ChangeOrigin, ids: string[]);
|
|
58
|
-
}
|
|
59
|
-
export declare class AgGridAction implements Action {
|
|
60
|
-
readonly type: string;
|
|
61
|
-
readonly gridId: string;
|
|
62
|
-
constructor(type: string, gridId: string);
|
|
46
|
+
export declare class NgssmAgGridStateSpecification {
|
|
47
|
+
static readonly featureStateKey = "ngssm-ag-grid-state";
|
|
48
|
+
static readonly initialState: NgssmAgGridState;
|
|
63
49
|
}
|
|
64
50
|
/**
|
|
65
51
|
* A function type that determines whether an action is disabled.
|
|
@@ -413,4 +399,28 @@ export declare const loadGridStates: () => void;
|
|
|
413
399
|
* @returns EnvironmentProviders for NgssmAgGrid.
|
|
414
400
|
*/
|
|
415
401
|
export declare const provideNgssmAgGrid: (options?: NgssmAgGridOptions) => EnvironmentProviders;
|
|
402
|
+
export declare class NgssmSetAgGridStateAction implements Action {
|
|
403
|
+
readonly gridId: string;
|
|
404
|
+
readonly origin: ChangeOrigin;
|
|
405
|
+
readonly columnStates: ColumnState[];
|
|
406
|
+
readonly columnGroupStates: ColumnGroupState[];
|
|
407
|
+
readonly filterModel: FilterModel | null;
|
|
408
|
+
readonly type: string;
|
|
409
|
+
constructor(gridId: string, origin: ChangeOrigin, columnStates: ColumnState[], columnGroupStates: ColumnGroupState[], filterModel: FilterModel | null);
|
|
410
|
+
}
|
|
411
|
+
export declare const setAgGridState: ReducerFunc<NgssmSetAgGridStateAction>;
|
|
412
|
+
export declare class NgssmSetSelectedRowsAction implements Action {
|
|
413
|
+
readonly gridId: string;
|
|
414
|
+
readonly origin: ChangeOrigin;
|
|
415
|
+
readonly ids: string[];
|
|
416
|
+
readonly type: string;
|
|
417
|
+
constructor(gridId: string, origin: ChangeOrigin, ids: string[]);
|
|
418
|
+
}
|
|
419
|
+
export declare const setSelectedRows: ReducerFunc<NgssmSetSelectedRowsAction>;
|
|
420
|
+
export declare class NgssmClearSelectedRowsAction implements Action {
|
|
421
|
+
readonly gridId: string;
|
|
422
|
+
readonly type: string;
|
|
423
|
+
constructor(gridId: string);
|
|
424
|
+
}
|
|
425
|
+
export declare const clearSelectedRows: ReducerFunc<NgssmClearSelectedRowsAction>;
|
|
416
426
|
export {};
|