@rxap/data-grid 21.0.1-dev.1 → 22.0.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/compodoc/changelog.html +32 -0
- package/compodoc/dependencies.html +10 -10
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/properties.html +1 -1
- package/docs/documentation.json +100 -100
- package/docs/html/classes/DataGridCellDefDirective.html +2 -2
- package/docs/html/classes/DataGridComponent.html +5 -5
- package/docs/html/classes/DataGridEditCellDefDirective.html +2 -2
- package/docs/html/classes/DataGridHeaderCellDefDirective.html +2 -2
- package/docs/html/classes/DataGridRowDefDirective.html +3 -3
- package/docs/html/classes/DataGridValuePipe.html +2 -2
- package/docs/html/classes/IsEmptyPipe.html +2 -2
- package/docs/html/enums/DataGridMode.html +3 -3
- package/docs/html/index.html +2 -2
- package/docs/html/interfaces/DataGridCellDefDirectiveContext.html +2 -2
- package/docs/html/interfaces/DataGridEditCellDefDirectiveContext.html +2 -2
- package/docs/html/interfaces/DataGridHeaderCellDefDirectiveContext.html +2 -2
- package/docs/html/modules.html +1 -1
- package/docs/markdown/README.md +1 -1
- package/docs/markdown/classes/DataGridCellDefDirective.md +6 -6
- package/docs/markdown/classes/DataGridComponent.md +38 -38
- package/docs/markdown/classes/DataGridEditCellDefDirective.md +4 -4
- package/docs/markdown/classes/DataGridHeaderCellDefDirective.md +4 -4
- package/docs/markdown/classes/DataGridRowDefDirective.md +9 -9
- package/docs/markdown/classes/DataGridValuePipe.md +3 -3
- package/docs/markdown/classes/IsEmptyPipe.md +3 -3
- package/docs/markdown/enumerations/DataGridMode.md +4 -4
- package/docs/markdown/globals.md +2 -2
- package/docs/markdown/interfaces/DataGridCellDefDirectiveContext.md +4 -4
- package/docs/markdown/interfaces/DataGridEditCellDefDirectiveContext.md +4 -4
- package/docs/markdown/interfaces/DataGridHeaderCellDefDirectiveContext.md +3 -3
- package/docs/wiki/Class.DataGridCellDefDirective.md +5 -5
- package/docs/wiki/Class.DataGridComponent.md +37 -37
- package/docs/wiki/Class.DataGridEditCellDefDirective.md +3 -3
- package/docs/wiki/Class.DataGridHeaderCellDefDirective.md +3 -3
- package/docs/wiki/Class.DataGridRowDefDirective.md +8 -8
- package/docs/wiki/Class.DataGridValuePipe.md +2 -2
- package/docs/wiki/Class.IsEmptyPipe.md +2 -2
- package/docs/wiki/Enumeration.DataGridMode.md +3 -3
- package/docs/wiki/Interface.DataGridCellDefDirectiveContext.md +3 -3
- package/docs/wiki/Interface.DataGridEditCellDefDirectiveContext.md +3 -3
- package/docs/wiki/Interface.DataGridHeaderCellDefDirectiveContext.md +2 -2
- package/docs/wiki/globals.md +1 -1
- package/fesm2022/rxap-data-grid.mjs +803 -388
- package/fesm2022/rxap-data-grid.mjs.map +1 -1
- package/package.json +28 -28
- package/types/rxap-data-grid.d.ts +184 -137
|
@@ -1,395 +1,810 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { coerceBoolean, getFromObject
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import * as i1 from
|
|
8
|
-
import { MatButtonModule } from
|
|
9
|
-
import * as i3 from
|
|
10
|
-
import { MatDividerModule } from
|
|
11
|
-
import * as i4 from
|
|
12
|
-
import { MatFormFieldModule } from
|
|
13
|
-
import { MatIconModule } from
|
|
14
|
-
import * as i2 from
|
|
15
|
-
import { MatProgressSpinnerModule } from
|
|
16
|
-
import {
|
|
17
|
-
import { FormDirective, FormSubmitFailedDirective,
|
|
18
|
-
import { GetFromObjectPipe, ReplacePipe
|
|
19
|
-
import { ToggleSubject } from
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Directive, Pipe, TemplateRef, contentChild, contentChildren, inject, input, isDevMode, linkedSignal, output, signal } from "@angular/core";
|
|
3
|
+
import { clone, coerceBoolean, getFromObject } from "@rxap/utilities";
|
|
4
|
+
import { filter, map, shareReplay, take, tap } from "rxjs/operators";
|
|
5
|
+
import { AsyncPipe, NgClass, NgTemplateOutlet } from "@angular/common";
|
|
6
|
+
import { outputToObservable, toObservable } from "@angular/core/rxjs-interop";
|
|
7
|
+
import * as i1 from "@angular/material/button";
|
|
8
|
+
import { MatButtonModule } from "@angular/material/button";
|
|
9
|
+
import * as i3 from "@angular/material/divider";
|
|
10
|
+
import { MatDividerModule } from "@angular/material/divider";
|
|
11
|
+
import * as i4 from "@angular/material/form-field";
|
|
12
|
+
import { MatFormFieldModule } from "@angular/material/form-field";
|
|
13
|
+
import { MatIconModule } from "@angular/material/icon";
|
|
14
|
+
import * as i2 from "@angular/material/progress-spinner";
|
|
15
|
+
import { MatProgressSpinnerModule } from "@angular/material/progress-spinner";
|
|
16
|
+
import { ActivationEnd, Router } from "@angular/router";
|
|
17
|
+
import { FormDirective, FormSubmitFailedDirective, FormSubmitInvalidDirective, FormSubmitSuccessfulDirective } from "@rxap/forms";
|
|
18
|
+
import { EscapeQuotationMarkPipe, GetFromObjectPipe, ReplacePipe } from "@rxap/pipes";
|
|
19
|
+
import { ToggleSubject } from "@rxap/rxjs";
|
|
20
|
+
import { EMPTY, combineLatest, debounceTime, of } from "rxjs";
|
|
21
|
+
var DataGridCellDefDirective = class DataGridCellDefDirective {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.template = inject(TemplateRef);
|
|
24
|
+
}
|
|
25
|
+
static ngTemplateContextGuard(dir, ctx) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
static {
|
|
29
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
30
|
+
minVersion: "12.0.0",
|
|
31
|
+
version: "22.3.0",
|
|
32
|
+
ngImport: i0,
|
|
33
|
+
type: DataGridCellDefDirective,
|
|
34
|
+
deps: [],
|
|
35
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
static {
|
|
39
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
40
|
+
minVersion: "14.0.0",
|
|
41
|
+
version: "22.3.0",
|
|
42
|
+
type: DataGridCellDefDirective,
|
|
43
|
+
isStandalone: true,
|
|
44
|
+
selector: "[rxapDataGridCellDef]",
|
|
45
|
+
ngImport: i0
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
50
|
+
minVersion: "12.0.0",
|
|
51
|
+
version: "22.3.0",
|
|
52
|
+
ngImport: i0,
|
|
53
|
+
type: DataGridCellDefDirective,
|
|
54
|
+
decorators: [{
|
|
55
|
+
type: Directive,
|
|
56
|
+
args: [{
|
|
57
|
+
selector: "[rxapDataGridCellDef]",
|
|
58
|
+
standalone: true
|
|
59
|
+
}]
|
|
60
|
+
}]
|
|
61
|
+
});
|
|
62
|
+
var DataGridEditCellDefDirective = class DataGridEditCellDefDirective {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.template = inject(TemplateRef);
|
|
65
|
+
}
|
|
66
|
+
static ngTemplateContextGuard(dir, ctx) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
static {
|
|
70
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
71
|
+
minVersion: "12.0.0",
|
|
72
|
+
version: "22.3.0",
|
|
73
|
+
ngImport: i0,
|
|
74
|
+
type: DataGridEditCellDefDirective,
|
|
75
|
+
deps: [],
|
|
76
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
static {
|
|
80
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
81
|
+
minVersion: "14.0.0",
|
|
82
|
+
version: "22.3.0",
|
|
83
|
+
type: DataGridEditCellDefDirective,
|
|
84
|
+
isStandalone: true,
|
|
85
|
+
selector: "[rxapDataGridEditCellDef]",
|
|
86
|
+
ngImport: i0
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
91
|
+
minVersion: "12.0.0",
|
|
92
|
+
version: "22.3.0",
|
|
93
|
+
ngImport: i0,
|
|
94
|
+
type: DataGridEditCellDefDirective,
|
|
95
|
+
decorators: [{
|
|
96
|
+
type: Directive,
|
|
97
|
+
args: [{
|
|
98
|
+
selector: "[rxapDataGridEditCellDef]",
|
|
99
|
+
standalone: true
|
|
100
|
+
}]
|
|
101
|
+
}]
|
|
102
|
+
});
|
|
103
|
+
var DataGridHeaderCellDefDirective = class DataGridHeaderCellDefDirective {
|
|
104
|
+
constructor() {
|
|
105
|
+
this.template = inject(TemplateRef);
|
|
106
|
+
}
|
|
107
|
+
static ngTemplateContextGuard(dir, ctx) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
static {
|
|
111
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
112
|
+
minVersion: "12.0.0",
|
|
113
|
+
version: "22.3.0",
|
|
114
|
+
ngImport: i0,
|
|
115
|
+
type: DataGridHeaderCellDefDirective,
|
|
116
|
+
deps: [],
|
|
117
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
static {
|
|
121
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
122
|
+
minVersion: "14.0.0",
|
|
123
|
+
version: "22.3.0",
|
|
124
|
+
type: DataGridHeaderCellDefDirective,
|
|
125
|
+
isStandalone: true,
|
|
126
|
+
selector: "[rxapDataGridHeaderCellDef]",
|
|
127
|
+
ngImport: i0
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
132
|
+
minVersion: "12.0.0",
|
|
133
|
+
version: "22.3.0",
|
|
134
|
+
ngImport: i0,
|
|
135
|
+
type: DataGridHeaderCellDefDirective,
|
|
136
|
+
decorators: [{
|
|
137
|
+
type: Directive,
|
|
138
|
+
args: [{
|
|
139
|
+
selector: "[rxapDataGridHeaderCellDef]",
|
|
140
|
+
standalone: true
|
|
141
|
+
}]
|
|
142
|
+
}]
|
|
143
|
+
});
|
|
144
|
+
var DataGridRowDefDirective = class DataGridRowDefDirective {
|
|
145
|
+
constructor() {
|
|
146
|
+
this.data = input(null, ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
147
|
+
this.name = input(void 0, {
|
|
148
|
+
...ngDevMode ? { debugName: "name" } : /* istanbul ignore next */ {},
|
|
149
|
+
alias: "rxapDataGridRowDef"
|
|
150
|
+
});
|
|
151
|
+
this.flip = input(false, {
|
|
152
|
+
...ngDevMode ? { debugName: "flip" } : /* istanbul ignore next */ {},
|
|
153
|
+
transform: coerceBoolean
|
|
154
|
+
});
|
|
155
|
+
this.cell = contentChild(DataGridCellDefDirective, ...ngDevMode ? [{ debugName: "cell" }] : /* istanbul ignore next */ []);
|
|
156
|
+
this.headerCell = contentChild(DataGridHeaderCellDefDirective, ...ngDevMode ? [{ debugName: "headerCell" }] : /* istanbul ignore next */ []);
|
|
157
|
+
this.editCell = contentChild(DataGridEditCellDefDirective, ...ngDevMode ? [{ debugName: "editCell" }] : /* istanbul ignore next */ []);
|
|
158
|
+
}
|
|
159
|
+
get isSubHeader() {
|
|
160
|
+
return !this.name();
|
|
161
|
+
}
|
|
162
|
+
static {
|
|
163
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
164
|
+
minVersion: "12.0.0",
|
|
165
|
+
version: "22.3.0",
|
|
166
|
+
ngImport: i0,
|
|
167
|
+
type: DataGridRowDefDirective,
|
|
168
|
+
deps: [],
|
|
169
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
static {
|
|
173
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
174
|
+
minVersion: "17.2.0",
|
|
175
|
+
version: "22.3.0",
|
|
176
|
+
type: DataGridRowDefDirective,
|
|
177
|
+
isStandalone: true,
|
|
178
|
+
selector: "[rxapDataGridRowDef]",
|
|
179
|
+
inputs: {
|
|
180
|
+
data: {
|
|
181
|
+
classPropertyName: "data",
|
|
182
|
+
publicName: "data",
|
|
183
|
+
isSignal: true,
|
|
184
|
+
isRequired: false,
|
|
185
|
+
transformFunction: null
|
|
186
|
+
},
|
|
187
|
+
name: {
|
|
188
|
+
classPropertyName: "name",
|
|
189
|
+
publicName: "rxapDataGridRowDef",
|
|
190
|
+
isSignal: true,
|
|
191
|
+
isRequired: false,
|
|
192
|
+
transformFunction: null
|
|
193
|
+
},
|
|
194
|
+
flip: {
|
|
195
|
+
classPropertyName: "flip",
|
|
196
|
+
publicName: "flip",
|
|
197
|
+
isSignal: true,
|
|
198
|
+
isRequired: false,
|
|
199
|
+
transformFunction: null
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
queries: [
|
|
203
|
+
{
|
|
204
|
+
propertyName: "cell",
|
|
205
|
+
first: true,
|
|
206
|
+
predicate: DataGridCellDefDirective,
|
|
207
|
+
descendants: true,
|
|
208
|
+
isSignal: true
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
propertyName: "headerCell",
|
|
212
|
+
first: true,
|
|
213
|
+
predicate: DataGridHeaderCellDefDirective,
|
|
214
|
+
descendants: true,
|
|
215
|
+
isSignal: true
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
propertyName: "editCell",
|
|
219
|
+
first: true,
|
|
220
|
+
predicate: DataGridEditCellDefDirective,
|
|
221
|
+
descendants: true,
|
|
222
|
+
isSignal: true
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
ngImport: i0
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
230
|
+
minVersion: "12.0.0",
|
|
231
|
+
version: "22.3.0",
|
|
232
|
+
ngImport: i0,
|
|
233
|
+
type: DataGridRowDefDirective,
|
|
234
|
+
decorators: [{
|
|
235
|
+
type: Directive,
|
|
236
|
+
args: [{
|
|
237
|
+
selector: "[rxapDataGridRowDef]",
|
|
238
|
+
standalone: true
|
|
239
|
+
}]
|
|
240
|
+
}],
|
|
241
|
+
propDecorators: {
|
|
242
|
+
data: [{
|
|
243
|
+
type: i0.Input,
|
|
244
|
+
args: [{
|
|
245
|
+
isSignal: true,
|
|
246
|
+
alias: "data",
|
|
247
|
+
required: false
|
|
248
|
+
}]
|
|
249
|
+
}],
|
|
250
|
+
name: [{
|
|
251
|
+
type: i0.Input,
|
|
252
|
+
args: [{
|
|
253
|
+
isSignal: true,
|
|
254
|
+
alias: "rxapDataGridRowDef",
|
|
255
|
+
required: false
|
|
256
|
+
}]
|
|
257
|
+
}],
|
|
258
|
+
flip: [{
|
|
259
|
+
type: i0.Input,
|
|
260
|
+
args: [{
|
|
261
|
+
isSignal: true,
|
|
262
|
+
alias: "flip",
|
|
263
|
+
required: false
|
|
264
|
+
}]
|
|
265
|
+
}],
|
|
266
|
+
cell: [{
|
|
267
|
+
type: i0.ContentChild,
|
|
268
|
+
args: [i0.forwardRef(() => DataGridCellDefDirective), { isSignal: true }]
|
|
269
|
+
}],
|
|
270
|
+
headerCell: [{
|
|
271
|
+
type: i0.ContentChild,
|
|
272
|
+
args: [i0.forwardRef(() => DataGridHeaderCellDefDirective), { isSignal: true }]
|
|
273
|
+
}],
|
|
274
|
+
editCell: [{
|
|
275
|
+
type: i0.ContentChild,
|
|
276
|
+
args: [i0.forwardRef(() => DataGridEditCellDefDirective), { isSignal: true }]
|
|
277
|
+
}]
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
var DataGridValuePipe = class DataGridValuePipe {
|
|
281
|
+
transform(data, path) {
|
|
282
|
+
if (!path) throw new Error("FATAL: The path is required! Ensure the data grid row has a defined name property!");
|
|
283
|
+
return data.pipe(map((source) => getFromObject(source, path)));
|
|
284
|
+
}
|
|
285
|
+
static {
|
|
286
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
287
|
+
minVersion: "12.0.0",
|
|
288
|
+
version: "22.3.0",
|
|
289
|
+
ngImport: i0,
|
|
290
|
+
type: DataGridValuePipe,
|
|
291
|
+
deps: [],
|
|
292
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
static {
|
|
296
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
297
|
+
minVersion: "14.0.0",
|
|
298
|
+
version: "22.3.0",
|
|
299
|
+
ngImport: i0,
|
|
300
|
+
type: DataGridValuePipe,
|
|
301
|
+
isStandalone: true,
|
|
302
|
+
name: "dataGridValue"
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
307
|
+
minVersion: "12.0.0",
|
|
308
|
+
version: "22.3.0",
|
|
309
|
+
ngImport: i0,
|
|
310
|
+
type: DataGridValuePipe,
|
|
311
|
+
decorators: [{
|
|
312
|
+
type: Pipe,
|
|
313
|
+
args: [{
|
|
314
|
+
name: "dataGridValue",
|
|
315
|
+
standalone: true
|
|
316
|
+
}]
|
|
317
|
+
}]
|
|
318
|
+
});
|
|
319
|
+
var IsEmptyPipe = class IsEmptyPipe {
|
|
320
|
+
transform(data, path) {
|
|
321
|
+
if (!path) throw new Error("FATAL: The path is required! Ensure the data grid row has a defined name property!");
|
|
322
|
+
return data.pipe(map((source) => getFromObject(source, path)), map((value) => value === null || value === void 0 || value === ""));
|
|
323
|
+
}
|
|
324
|
+
static {
|
|
325
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
326
|
+
minVersion: "12.0.0",
|
|
327
|
+
version: "22.3.0",
|
|
328
|
+
ngImport: i0,
|
|
329
|
+
type: IsEmptyPipe,
|
|
330
|
+
deps: [],
|
|
331
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
static {
|
|
335
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
336
|
+
minVersion: "14.0.0",
|
|
337
|
+
version: "22.3.0",
|
|
338
|
+
ngImport: i0,
|
|
339
|
+
type: IsEmptyPipe,
|
|
340
|
+
isStandalone: true,
|
|
341
|
+
name: "isEmpty"
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
346
|
+
minVersion: "12.0.0",
|
|
347
|
+
version: "22.3.0",
|
|
348
|
+
ngImport: i0,
|
|
349
|
+
type: IsEmptyPipe,
|
|
350
|
+
decorators: [{
|
|
351
|
+
type: Pipe,
|
|
352
|
+
args: [{
|
|
353
|
+
name: "isEmpty",
|
|
354
|
+
standalone: true
|
|
355
|
+
}]
|
|
356
|
+
}]
|
|
357
|
+
});
|
|
151
358
|
var DataGridMode;
|
|
152
|
-
(function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
*/
|
|
156
|
-
DataGridMode["PLAIN"] = "plain";
|
|
157
|
-
/**
|
|
158
|
-
* The edit cell template is used to display the property value, but the form and all controls are marked as disabled
|
|
159
|
-
*/
|
|
160
|
-
DataGridMode["FORM"] = "form";
|
|
359
|
+
(function(DataGridMode) {
|
|
360
|
+
DataGridMode["PLAIN"] = "plain";
|
|
361
|
+
DataGridMode["FORM"] = "form";
|
|
161
362
|
})(DataGridMode || (DataGridMode = {}));
|
|
162
363
|
function IsDataGridMode(value) {
|
|
163
|
-
|
|
364
|
+
return [DataGridMode.PLAIN, DataGridMode.FORM].includes(value);
|
|
164
365
|
}
|
|
165
366
|
function coerceDataGridMode(value) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
throw new Error(`The data grid mode only support 'plain' and 'form' - given '${value}'`);
|
|
170
|
-
}
|
|
171
|
-
class DataGridComponent {
|
|
172
|
-
constructor() {
|
|
173
|
-
this.router = inject(Router);
|
|
174
|
-
this.formDirective = inject(FormDirective, { optional: true });
|
|
175
|
-
this.isDevMode = isDevMode();
|
|
176
|
-
this.header = input(false, { ...(ngDevMode ? { debugName: "header" } : /* istanbul ignore next */ {}), transform: coerceBoolean });
|
|
177
|
-
this.dataSource = input(...(ngDevMode ? [undefined, { debugName: "dataSource" }] : /* istanbul ignore next */ []));
|
|
178
|
-
this.viewer = input(this, ...(ngDevMode ? [{ debugName: "viewer" }] : /* istanbul ignore next */ []));
|
|
179
|
-
this.data = input(...(ngDevMode ? [undefined, { debugName: "data" }] : /* istanbul ignore next */ []));
|
|
180
|
-
/**
|
|
181
|
-
* The current data. Initialized from the data input and updated with the values emitted by the data source
|
|
182
|
-
*/
|
|
183
|
-
this.currentData = linkedSignal(() => this.data(), ...(ngDevMode ? [{ debugName: "currentData" }] : /* istanbul ignore next */ []));
|
|
184
|
-
this.displayProperties = input(null, ...(ngDevMode ? [{ debugName: "displayProperties" }] : /* istanbul ignore next */ []));
|
|
185
|
-
this.hideEmptyProperties = input(false, { ...(ngDevMode ? { debugName: "hideEmptyProperties" } : /* istanbul ignore next */ {}), transform: coerceBoolean });
|
|
186
|
-
this.rows = contentChildren(DataGridRowDefDirective, ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
187
|
-
this.editModeChange = output();
|
|
188
|
-
this.rows$ = toObservable(this.rows);
|
|
189
|
-
this.hasError$ = of(false);
|
|
190
|
-
this.dataLoading$ = of(false);
|
|
191
|
-
this.loading$ = new ToggleSubject();
|
|
192
|
-
this.mode = input(DataGridMode.PLAIN, { ...(ngDevMode ? { debugName: "mode" } : /* istanbul ignore next */ {}), transform: coerceDataGridMode });
|
|
193
|
-
this._editMode = signal(false, ...(ngDevMode ? [{ debugName: "_editMode" }] : /* istanbul ignore next */ []));
|
|
194
|
-
this.isEditMode$ = toObservable(this._editMode);
|
|
195
|
-
this.mode$ = toObservable(this.mode);
|
|
196
|
-
this.isFormMode$ = this.mode$.pipe(map(mode => mode === DataGridMode.FORM));
|
|
197
|
-
this.isPlainMode$ = this.mode$.pipe(map(mode => mode === DataGridMode.PLAIN));
|
|
198
|
-
this._routerEventSubscription = null;
|
|
199
|
-
}
|
|
200
|
-
get isFormModeOrHasAnyEditCells() {
|
|
201
|
-
return this.mode() === DataGridMode.FORM || this.hasAnyEditCells;
|
|
202
|
-
}
|
|
203
|
-
get isFormMode() {
|
|
204
|
-
return this.mode() === DataGridMode.FORM;
|
|
205
|
-
}
|
|
206
|
-
get hasAnyEditCells() {
|
|
207
|
-
return this.rows()?.some(row => !!row.editCell()) ?? false;
|
|
208
|
-
}
|
|
209
|
-
get isEditMode() {
|
|
210
|
-
return this._editMode();
|
|
211
|
-
}
|
|
212
|
-
set editMode(value) {
|
|
213
|
-
this._editMode.set(value);
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* @deprecated use the loading$ property instead
|
|
217
|
-
*/
|
|
218
|
-
get loading() {
|
|
219
|
-
return this.loading$.value;
|
|
220
|
-
}
|
|
221
|
-
logCurrentFormState() {
|
|
222
|
-
console.log(clone(this.formDirective?.form.value));
|
|
223
|
-
}
|
|
224
|
-
ngOnInit() {
|
|
225
|
-
// resets the edit mode if this component is used in a sibling router path
|
|
226
|
-
// if not reset the edit mode is president after the route changes
|
|
227
|
-
this._routerEventSubscription = this.router.events.pipe(filter(event => event instanceof ActivationEnd), tap(() => this.disableEditMode())).subscribe();
|
|
228
|
-
const dataSource = this.dataSource();
|
|
229
|
-
const dataValue = this.currentData();
|
|
230
|
-
if (dataSource && dataValue) {
|
|
231
|
-
throw new Error('You can not use both dataSource and data input');
|
|
232
|
-
}
|
|
233
|
-
let data$ = EMPTY;
|
|
234
|
-
if (dataSource) {
|
|
235
|
-
data$ = dataSource.connect(this.viewer());
|
|
236
|
-
}
|
|
237
|
-
if (dataValue) {
|
|
238
|
-
data$ = of(dataValue);
|
|
239
|
-
}
|
|
240
|
-
if (data$ === EMPTY && isDevMode()) {
|
|
241
|
-
console.warn('No data source or data input provided');
|
|
242
|
-
}
|
|
243
|
-
this.data$ = data$.pipe(debounceTime(100), tap(data => this.currentData.set(data)), tap(data => {
|
|
244
|
-
if (this.formDirective && this.isFormMode) {
|
|
245
|
-
this.formDirective.form.patchValue(data, {
|
|
246
|
-
coerce: true,
|
|
247
|
-
strict: true,
|
|
248
|
-
});
|
|
249
|
-
if (this.isFormMode) {
|
|
250
|
-
this.formDirective.form.disable();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}), shareReplay(1));
|
|
254
|
-
if (dataSource) {
|
|
255
|
-
this.hasError$ = dataSource.hasError$ ?? this.hasError$;
|
|
256
|
-
this.dataLoading$ = dataSource.loading$ ?? this.dataLoading$;
|
|
257
|
-
}
|
|
258
|
-
if (this.formDirective && this.isFormMode) {
|
|
259
|
-
this.formDirective.form.disabledWhile(combineLatest([
|
|
260
|
-
this.isEditMode$,
|
|
261
|
-
this.mode$,
|
|
262
|
-
]).pipe(map(([editMode, mode]) => !editMode && mode === 'form')), { onlySelf: false });
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
ngOnDestroy() {
|
|
266
|
-
this.dataSource()?.disconnect(this.viewer());
|
|
267
|
-
this._routerEventSubscription?.unsubscribe();
|
|
268
|
-
}
|
|
269
|
-
enableEditMode(skipPatchValue = false) {
|
|
270
|
-
if (!this.isFormModeOrHasAnyEditCells) {
|
|
271
|
-
if (isDevMode()) {
|
|
272
|
-
console.warn('Can not enable edit mode if the mode is not form');
|
|
273
|
-
}
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
if (!this.formDirective) {
|
|
277
|
-
if (isDevMode()) {
|
|
278
|
-
console.warn('Can not enable edit mode without a form directive');
|
|
279
|
-
}
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
this.editMode = true;
|
|
283
|
-
const data = this.currentData();
|
|
284
|
-
if (!skipPatchValue && data) {
|
|
285
|
-
this.formDirective.form.patchValue(data, {
|
|
286
|
-
coerce: true,
|
|
287
|
-
strict: true,
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
disableEditMode() {
|
|
292
|
-
if (!this.isFormModeOrHasAnyEditCells) {
|
|
293
|
-
if (isDevMode()) {
|
|
294
|
-
console.warn('Can not disable edit mode if the mode is not form');
|
|
295
|
-
}
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
if (!this.formDirective) {
|
|
299
|
-
if (isDevMode()) {
|
|
300
|
-
console.warn('Can not enable edit mode without a form directive');
|
|
301
|
-
}
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
this.editMode = false;
|
|
305
|
-
}
|
|
306
|
-
submit() {
|
|
307
|
-
if (!this.isFormModeOrHasAnyEditCells) {
|
|
308
|
-
if (isDevMode()) {
|
|
309
|
-
console.warn('Can not submit if the mode is not form');
|
|
310
|
-
}
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
if (!this.formDirective) {
|
|
314
|
-
if (isDevMode()) {
|
|
315
|
-
console.warn('Can not support without a form directive');
|
|
316
|
-
}
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
this.loading$.enable();
|
|
320
|
-
this.formDirective.form.markAllAsDirty();
|
|
321
|
-
this.formDirective.form.markAllAsTouched();
|
|
322
|
-
outputToObservable(this.formDirective.rxapSubmit).pipe(take(1), tap(() => {
|
|
323
|
-
this.disableEditMode();
|
|
324
|
-
})).subscribe();
|
|
325
|
-
outputToObservable(this.formDirective.invalidSubmit).pipe(take(1), tap(() => {
|
|
326
|
-
this.loading$.disable();
|
|
327
|
-
})).subscribe();
|
|
328
|
-
this.formDirective.submitError$.pipe(filter(Boolean), // if the error is undefined we do not want to disable the loading
|
|
329
|
-
take(1), tap(() => {
|
|
330
|
-
this.loading$.disable();
|
|
331
|
-
this.enableEditMode(true);
|
|
332
|
-
})).subscribe();
|
|
333
|
-
outputToObservable(this.formDirective.submitSuccessful$).pipe(take(1), tap(() => {
|
|
334
|
-
this.loading$.disable();
|
|
335
|
-
this.refresh();
|
|
336
|
-
})).subscribe();
|
|
337
|
-
this.formDirective.onSubmit(new Event('submit'));
|
|
338
|
-
}
|
|
339
|
-
reset() {
|
|
340
|
-
const data = this.currentData();
|
|
341
|
-
if (this.formDirective && data && this.isFormModeOrHasAnyEditCells) {
|
|
342
|
-
this.formDirective.form.patchValue(data, {
|
|
343
|
-
coerce: true,
|
|
344
|
-
strict: true,
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
refresh() {
|
|
349
|
-
const dataSource = this.dataSource();
|
|
350
|
-
if (dataSource) {
|
|
351
|
-
dataSource.refresh();
|
|
352
|
-
}
|
|
353
|
-
else if (isDevMode()) {
|
|
354
|
-
console.warn('can not refresh the data. data source is not defined');
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
cancel() {
|
|
358
|
-
this.reset();
|
|
359
|
-
this.disableEditMode();
|
|
360
|
-
}
|
|
361
|
-
retry() {
|
|
362
|
-
this.refresh();
|
|
363
|
-
}
|
|
364
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DataGridComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
365
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.9", type: DataGridComponent, isStandalone: true, selector: "rxap-data-grid", inputs: { header: { classPropertyName: "header", publicName: "header", isSignal: true, isRequired: false, transformFunction: null }, dataSource: { classPropertyName: "dataSource", publicName: "dataSource", isSignal: true, isRequired: false, transformFunction: null }, viewer: { classPropertyName: "viewer", publicName: "viewer", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, displayProperties: { classPropertyName: "displayProperties", publicName: "displayProperties", isSignal: true, isRequired: false, transformFunction: null }, hideEmptyProperties: { classPropertyName: "hideEmptyProperties", publicName: "hideEmptyProperties", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { editModeChange: "editModeChange" }, queries: [{ propertyName: "rows", predicate: DataGridRowDefDirective, isSignal: true }], ngImport: i0, template: "@if ((hasError$ | async)) {\n <div class=\"flex flex-col items-center justify-center gap-y-8\">\n <span i18n>Something has gone wrong!</span>\n <button (click)=\"retry()\" i18n mat-stroked-button type=\"button\">Retry</button>\n </div>\n}\n@if ((dataLoading$ | async)) {\n <div class=\"flex flex-col items-center justify-center gap-y-8\">\n <mat-spinner></mat-spinner>\n </div>\n}\n<!-- if the dataSource input is used. It is possible the the hasError$ or loading$ property is === EMPTY. this would\nresults in an null as output. If the === false check is used this can result into the behavior that the data grid is\nnever shown. -->\n<!-- eslint-disable-next-line @angular-eslint/template/no-negated-async -->\n@if (!(hasError$ | async) && !(dataLoading$ | async)) {\n <table class=\"w-full table-auto\">\n @if (header()) {\n <thead>\n <tr>\n <th class=\"py-2\" i18n>Label</th>\n <th class=\"py-2\" i18n>Value</th>\n </tr>\n </thead>\n }\n <tbody>\n @for (row of rows$ | async; track row; let first = $first) {\n @if ((!displayProperties() || row.isSubHeader || (row.name() && displayProperties()?.includes(row.name()!))) && (!hideEmptyProperties() || row.isSubHeader || false === (data$ | isEmpty: row.name() | async))) {\n <!-- region horizontal view -->\n @if (row.flip()) {\n <tr>\n <td class=\"py-2\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n <tr [attr.data-name]=\"row.name() + '-header'\">\n <ng-container\n *ngTemplateOutlet=\"row.headerCell()?.template ?? defaultHeaderCell; context: { $implicit: row.name() }\"></ng-container>\n </tr>\n <tr [attr.data-name]=\"row.name() + '-value'\">\n @if (row.name()) {\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n }\n </tr>\n <tr>\n <td class=\"py-4\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n } @else {\n @if (!first && row.isSubHeader) {\n <tr>\n <td class=\"py-4\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n }\n <tr [attr.data-name]=\"row.name()\" [ngClass]=\"{ 'sub-header text-2xl': row.isSubHeader }\">\n <ng-container\n *ngTemplateOutlet=\"row.headerCell()?.template ?? defaultHeaderCell; context: { $implicit: row.name() }\"></ng-container>\n @if (row.name()) {\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n }\n </tr>\n }\n <!-- endregion -->\n <!-- region normal view -->\n <!-- endregion -->\n }\n <ng-template #content>\n <td [attr.colspan]=\"row.flip() ? 2 : 1\" [ngClass]=\"{\n 'h-20': row.editCell()?.template && (isEditMode || isFormMode) && false,\n }\" class=\"pl-8 pr-4 w-full py-2\">\n @if (row.editCell()?.template && (isEditMode || isFormMode)) {\n <ng-container *ngTemplateOutlet=\"editMode\"></ng-container>\n } @else {\n <ng-container *ngTemplateOutlet=\"viewMode\"></ng-container>\n }\n </td>\n <ng-template #viewMode>\n <ng-container\n *ngTemplateOutlet=\"row.cell()?.template ?? defaultCell;context: { $implicit: data$ | dataGridValue: row.name() | async, data: data$ | async }\"></ng-container>\n </ng-template>\n <ng-template #editMode>\n <ng-container\n *ngTemplateOutlet=\"row.editCell()?.template ?? row.cell()?.template ?? defaultCell;context: { $implicit: data$ | dataGridValue: row.name() | async, data: data$ | async }\"></ng-container>\n </ng-template>\n </ng-template>\n }\n </tbody>\n @if (hasAnyEditCells) {\n <tfoot>\n <tr>\n <td class=\"py-2\" colspan=\"2\">\n @if (isEditMode) {\n <div class=\"pt-8 flex flex-col gap-y-6\">\n <div class=\"flex flex-row gap-x-6 items-center justify-start\">\n <button (click)=\"submit()\" [disabled]=\"loading$ | async\" color=\"primary\" mat-raised-button type=\"button\">\n <span class=\"flex flex-row gap-x-6 items-center justify-center\">\n <span i18n>Save</span>\n @if (loading$ | async) {\n <mat-spinner color=\"accent\" diameter=\"15\"></mat-spinner>\n }\n </span>\n </button>\n <button (click)=\"reset()\" [disabled]=\"loading$ | async\" mat-stroked-button type=\"button\">\n <ng-container i18n>Reset</ng-container>\n </button>\n <button (click)=\"cancel()\" [disabled]=\"loading$ | async\" color=\"warn\" mat-stroked-button type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n @if (isDevMode) {\n <button (click)=\"logCurrentFormState()\" mat-button type=\"button\">\n <ng-container i18n>Current Form State</ng-container>\n </button>\n }\n </div>\n <ng-template rxapFormSubmitInvalid>\n <mat-error i18n>Ensure all formula fields are valid.</mat-error>\n </ng-template>\n <ng-template let-error rxapFormSubmitFailed>\n <mat-error>{{ error.error?.message ?? error.message }}</mat-error>\n </ng-template>\n <ng-template rxapFormSubmitSuccessful>\n <span i18n>Submit successfully.</span>\n </ng-template>\n </div>\n } @else {\n <div class=\"pt-8\">\n <button (click)=\"enableEditMode()\" color=\"primary\" mat-raised-button type=\"button\">\n <span class=\"flex flex-row gap-x-6 items-center justify-center\">\n <span i18n>Edit</span>\n @if (loading$ | async) {\n <mat-spinner color=\"accent\" diameter=\"15\"></mat-spinner>\n }\n </span>\n </button>\n </div>\n }\n </td>\n </tr>\n </tfoot>\n }\n </table>\n}\n\n<ng-template #defaultCell let-value>\n <span>{{ value }}</span>\n</ng-template>\n<ng-template #defaultHeaderCell let-name>\n <th class=\"py-2 whitespace-nowrap\">{{ name }}</th>\n</ng-template>\n", styles: [":host ::ng-deep th{text-align:right;width:auto}\n"], dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i1.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "directive", type: FormSubmitFailedDirective, selector: "[rxapFormSubmitFailed]" }, { kind: "directive", type: FormSubmitSuccessfulDirective, selector: "[rxapFormSubmitSuccessful]" }, { kind: "directive", type: FormSubmitInvalidDirective, selector: "[rxapFormSubmitInvalid]" }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i2.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "ngmodule", type: MatDividerModule }, { kind: "component", type: i3.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: DataGridValuePipe, name: "dataGridValue" }, { kind: "pipe", type: IsEmptyPipe, name: "isEmpty" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
367
|
+
if (IsDataGridMode(value)) return value;
|
|
368
|
+
throw new Error(`The data grid mode only support 'plain' and 'form' - given '${value}'`);
|
|
366
369
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
*/
|
|
393
|
-
|
|
370
|
+
var DataGridComponent = class DataGridComponent {
|
|
371
|
+
constructor() {
|
|
372
|
+
this.router = inject(Router);
|
|
373
|
+
this.formDirective = inject(FormDirective, { optional: true });
|
|
374
|
+
this.isDevMode = isDevMode();
|
|
375
|
+
this.header = input(false, {
|
|
376
|
+
...ngDevMode ? { debugName: "header" } : /* istanbul ignore next */ {},
|
|
377
|
+
transform: coerceBoolean
|
|
378
|
+
});
|
|
379
|
+
this.dataSource = input(...ngDevMode ? [void 0, { debugName: "dataSource" }] : /* istanbul ignore next */ []);
|
|
380
|
+
this.viewer = input(this, ...ngDevMode ? [{ debugName: "viewer" }] : /* istanbul ignore next */ []);
|
|
381
|
+
this.data = input(...ngDevMode ? [void 0, { debugName: "data" }] : /* istanbul ignore next */ []);
|
|
382
|
+
this.currentData = linkedSignal(() => this.data(), ...ngDevMode ? [{ debugName: "currentData" }] : /* istanbul ignore next */ []);
|
|
383
|
+
this.displayProperties = input(null, ...ngDevMode ? [{ debugName: "displayProperties" }] : /* istanbul ignore next */ []);
|
|
384
|
+
this.hideEmptyProperties = input(false, {
|
|
385
|
+
...ngDevMode ? { debugName: "hideEmptyProperties" } : /* istanbul ignore next */ {},
|
|
386
|
+
transform: coerceBoolean
|
|
387
|
+
});
|
|
388
|
+
this.rows = contentChildren(DataGridRowDefDirective, ...ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []);
|
|
389
|
+
this.editModeChange = output();
|
|
390
|
+
this.rows$ = toObservable(this.rows);
|
|
391
|
+
this.hasError$ = of(false);
|
|
392
|
+
this.dataLoading$ = of(false);
|
|
393
|
+
this.loading$ = new ToggleSubject();
|
|
394
|
+
this.mode = input(DataGridMode.PLAIN, {
|
|
395
|
+
...ngDevMode ? { debugName: "mode" } : /* istanbul ignore next */ {},
|
|
396
|
+
transform: coerceDataGridMode
|
|
397
|
+
});
|
|
398
|
+
this._editMode = signal(false, ...ngDevMode ? [{ debugName: "_editMode" }] : /* istanbul ignore next */ []);
|
|
399
|
+
this.isEditMode$ = toObservable(this._editMode);
|
|
400
|
+
this.mode$ = toObservable(this.mode);
|
|
401
|
+
this.isFormMode$ = this.mode$.pipe(map((mode) => mode === DataGridMode.FORM));
|
|
402
|
+
this.isPlainMode$ = this.mode$.pipe(map((mode) => mode === DataGridMode.PLAIN));
|
|
403
|
+
this._routerEventSubscription = null;
|
|
404
|
+
}
|
|
405
|
+
get isFormModeOrHasAnyEditCells() {
|
|
406
|
+
return this.mode() === DataGridMode.FORM || this.hasAnyEditCells;
|
|
407
|
+
}
|
|
408
|
+
get isFormMode() {
|
|
409
|
+
return this.mode() === DataGridMode.FORM;
|
|
410
|
+
}
|
|
411
|
+
get hasAnyEditCells() {
|
|
412
|
+
return this.rows()?.some((row) => !!row.editCell()) ?? false;
|
|
413
|
+
}
|
|
414
|
+
get isEditMode() {
|
|
415
|
+
return this._editMode();
|
|
416
|
+
}
|
|
417
|
+
set editMode(value) {
|
|
418
|
+
this._editMode.set(value);
|
|
419
|
+
}
|
|
420
|
+
get loading() {
|
|
421
|
+
return this.loading$.value;
|
|
422
|
+
}
|
|
423
|
+
logCurrentFormState() {
|
|
424
|
+
console.log(clone(this.formDirective?.form.value));
|
|
425
|
+
}
|
|
426
|
+
ngOnInit() {
|
|
427
|
+
this._routerEventSubscription = this.router.events.pipe(filter((event) => event instanceof ActivationEnd), tap(() => this.disableEditMode())).subscribe();
|
|
428
|
+
const dataSource = this.dataSource();
|
|
429
|
+
const dataValue = this.currentData();
|
|
430
|
+
if (dataSource && dataValue) throw new Error("You can not use both dataSource and data input");
|
|
431
|
+
let data$ = EMPTY;
|
|
432
|
+
if (dataSource) data$ = dataSource.connect(this.viewer());
|
|
433
|
+
if (dataValue) data$ = of(dataValue);
|
|
434
|
+
if (data$ === EMPTY && isDevMode()) console.warn("No data source or data input provided");
|
|
435
|
+
this.data$ = data$.pipe(debounceTime(100), tap((data) => this.currentData.set(data)), tap((data) => {
|
|
436
|
+
if (this.formDirective && this.isFormMode) {
|
|
437
|
+
this.formDirective.form.patchValue(data, {
|
|
438
|
+
coerce: true,
|
|
439
|
+
strict: true
|
|
440
|
+
});
|
|
441
|
+
if (this.isFormMode) this.formDirective.form.disable();
|
|
442
|
+
}
|
|
443
|
+
}), shareReplay(1));
|
|
444
|
+
if (dataSource) {
|
|
445
|
+
this.hasError$ = dataSource.hasError$ ?? this.hasError$;
|
|
446
|
+
this.dataLoading$ = dataSource.loading$ ?? this.dataLoading$;
|
|
447
|
+
}
|
|
448
|
+
if (this.formDirective && this.isFormMode) this.formDirective.form.disabledWhile(combineLatest([this.isEditMode$, this.mode$]).pipe(map(([editMode, mode]) => !editMode && mode === "form")), { onlySelf: false });
|
|
449
|
+
}
|
|
450
|
+
ngOnDestroy() {
|
|
451
|
+
this.dataSource()?.disconnect(this.viewer());
|
|
452
|
+
this._routerEventSubscription?.unsubscribe();
|
|
453
|
+
}
|
|
454
|
+
enableEditMode(skipPatchValue = false) {
|
|
455
|
+
if (!this.isFormModeOrHasAnyEditCells) {
|
|
456
|
+
if (isDevMode()) console.warn("Can not enable edit mode if the mode is not form");
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
if (!this.formDirective) {
|
|
460
|
+
if (isDevMode()) console.warn("Can not enable edit mode without a form directive");
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
this.editMode = true;
|
|
464
|
+
const data = this.currentData();
|
|
465
|
+
if (!skipPatchValue && data) this.formDirective.form.patchValue(data, {
|
|
466
|
+
coerce: true,
|
|
467
|
+
strict: true
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
disableEditMode() {
|
|
471
|
+
if (!this.isFormModeOrHasAnyEditCells) {
|
|
472
|
+
if (isDevMode()) console.warn("Can not disable edit mode if the mode is not form");
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (!this.formDirective) {
|
|
476
|
+
if (isDevMode()) console.warn("Can not enable edit mode without a form directive");
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
this.editMode = false;
|
|
480
|
+
}
|
|
481
|
+
submit() {
|
|
482
|
+
if (!this.isFormModeOrHasAnyEditCells) {
|
|
483
|
+
if (isDevMode()) console.warn("Can not submit if the mode is not form");
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
if (!this.formDirective) {
|
|
487
|
+
if (isDevMode()) console.warn("Can not support without a form directive");
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
this.loading$.enable();
|
|
491
|
+
this.formDirective.form.markAllAsDirty();
|
|
492
|
+
this.formDirective.form.markAllAsTouched();
|
|
493
|
+
outputToObservable(this.formDirective.rxapSubmit).pipe(take(1), tap(() => {
|
|
494
|
+
this.disableEditMode();
|
|
495
|
+
})).subscribe();
|
|
496
|
+
outputToObservable(this.formDirective.invalidSubmit).pipe(take(1), tap(() => {
|
|
497
|
+
this.loading$.disable();
|
|
498
|
+
})).subscribe();
|
|
499
|
+
this.formDirective.submitError$.pipe(filter(Boolean), take(1), tap(() => {
|
|
500
|
+
this.loading$.disable();
|
|
501
|
+
this.enableEditMode(true);
|
|
502
|
+
})).subscribe();
|
|
503
|
+
outputToObservable(this.formDirective.submitSuccessful$).pipe(take(1), tap(() => {
|
|
504
|
+
this.loading$.disable();
|
|
505
|
+
this.refresh();
|
|
506
|
+
})).subscribe();
|
|
507
|
+
this.formDirective.onSubmit(new Event("submit"));
|
|
508
|
+
}
|
|
509
|
+
reset() {
|
|
510
|
+
const data = this.currentData();
|
|
511
|
+
if (this.formDirective && data && this.isFormModeOrHasAnyEditCells) this.formDirective.form.patchValue(data, {
|
|
512
|
+
coerce: true,
|
|
513
|
+
strict: true
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
refresh() {
|
|
517
|
+
const dataSource = this.dataSource();
|
|
518
|
+
if (dataSource) dataSource.refresh();
|
|
519
|
+
else if (isDevMode()) console.warn("can not refresh the data. data source is not defined");
|
|
520
|
+
}
|
|
521
|
+
cancel() {
|
|
522
|
+
this.reset();
|
|
523
|
+
this.disableEditMode();
|
|
524
|
+
}
|
|
525
|
+
retry() {
|
|
526
|
+
this.refresh();
|
|
527
|
+
}
|
|
528
|
+
static {
|
|
529
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
530
|
+
minVersion: "12.0.0",
|
|
531
|
+
version: "22.3.0",
|
|
532
|
+
ngImport: i0,
|
|
533
|
+
type: DataGridComponent,
|
|
534
|
+
deps: [],
|
|
535
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
static {
|
|
539
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
540
|
+
minVersion: "17.0.0",
|
|
541
|
+
version: "22.3.0",
|
|
542
|
+
type: DataGridComponent,
|
|
543
|
+
isStandalone: true,
|
|
544
|
+
selector: "rxap-data-grid",
|
|
545
|
+
inputs: {
|
|
546
|
+
header: {
|
|
547
|
+
classPropertyName: "header",
|
|
548
|
+
publicName: "header",
|
|
549
|
+
isSignal: true,
|
|
550
|
+
isRequired: false,
|
|
551
|
+
transformFunction: null
|
|
552
|
+
},
|
|
553
|
+
dataSource: {
|
|
554
|
+
classPropertyName: "dataSource",
|
|
555
|
+
publicName: "dataSource",
|
|
556
|
+
isSignal: true,
|
|
557
|
+
isRequired: false,
|
|
558
|
+
transformFunction: null
|
|
559
|
+
},
|
|
560
|
+
viewer: {
|
|
561
|
+
classPropertyName: "viewer",
|
|
562
|
+
publicName: "viewer",
|
|
563
|
+
isSignal: true,
|
|
564
|
+
isRequired: false,
|
|
565
|
+
transformFunction: null
|
|
566
|
+
},
|
|
567
|
+
data: {
|
|
568
|
+
classPropertyName: "data",
|
|
569
|
+
publicName: "data",
|
|
570
|
+
isSignal: true,
|
|
571
|
+
isRequired: false,
|
|
572
|
+
transformFunction: null
|
|
573
|
+
},
|
|
574
|
+
displayProperties: {
|
|
575
|
+
classPropertyName: "displayProperties",
|
|
576
|
+
publicName: "displayProperties",
|
|
577
|
+
isSignal: true,
|
|
578
|
+
isRequired: false,
|
|
579
|
+
transformFunction: null
|
|
580
|
+
},
|
|
581
|
+
hideEmptyProperties: {
|
|
582
|
+
classPropertyName: "hideEmptyProperties",
|
|
583
|
+
publicName: "hideEmptyProperties",
|
|
584
|
+
isSignal: true,
|
|
585
|
+
isRequired: false,
|
|
586
|
+
transformFunction: null
|
|
587
|
+
},
|
|
588
|
+
mode: {
|
|
589
|
+
classPropertyName: "mode",
|
|
590
|
+
publicName: "mode",
|
|
591
|
+
isSignal: true,
|
|
592
|
+
isRequired: false,
|
|
593
|
+
transformFunction: null
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
outputs: { editModeChange: "editModeChange" },
|
|
597
|
+
queries: [{
|
|
598
|
+
propertyName: "rows",
|
|
599
|
+
predicate: DataGridRowDefDirective,
|
|
600
|
+
isSignal: true
|
|
601
|
+
}],
|
|
602
|
+
ngImport: i0,
|
|
603
|
+
template: "@if ((hasError$ | async)) {\n <div class=\"flex flex-col items-center justify-center gap-y-8\">\n <span i18n>Something has gone wrong!</span>\n <button (click)=\"retry()\" i18n mat-stroked-button type=\"button\">Retry</button>\n </div>\n}\n@if ((dataLoading$ | async)) {\n <div class=\"flex flex-col items-center justify-center gap-y-8\">\n <mat-spinner></mat-spinner>\n </div>\n}\n<!-- if the dataSource input is used. It is possible the the hasError$ or loading$ property is === EMPTY. this would\nresults in an null as output. If the === false check is used this can result into the behavior that the data grid is\nnever shown. -->\n<!-- eslint-disable-next-line @angular-eslint/template/no-negated-async -->\n@if (!(hasError$ | async) && !(dataLoading$ | async)) {\n <table class=\"w-full table-auto\">\n @if (header()) {\n <thead>\n <tr>\n <th class=\"py-2\" i18n>Label</th>\n <th class=\"py-2\" i18n>Value</th>\n </tr>\n </thead>\n }\n <tbody>\n @for (row of rows$ | async; track row; let first = $first) {\n @if ((!displayProperties() || row.isSubHeader || (row.name() && displayProperties()?.includes(row.name()!))) && (!hideEmptyProperties() || row.isSubHeader || false === (data$ | isEmpty: row.name() | async))) {\n <!-- region horizontal view -->\n @if (row.flip()) {\n <tr>\n <td class=\"py-2\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n <tr [attr.data-name]=\"row.name() + '-header'\">\n <ng-container\n *ngTemplateOutlet=\"row.headerCell()?.template ?? defaultHeaderCell; context: { $implicit: row.name() }\"></ng-container>\n </tr>\n <tr [attr.data-name]=\"row.name() + '-value'\">\n @if (row.name()) {\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n }\n </tr>\n <tr>\n <td class=\"py-4\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n } @else {\n @if (!first && row.isSubHeader) {\n <tr>\n <td class=\"py-4\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n }\n <tr [attr.data-name]=\"row.name()\" [ngClass]=\"{ 'sub-header text-2xl': row.isSubHeader }\">\n <ng-container\n *ngTemplateOutlet=\"row.headerCell()?.template ?? defaultHeaderCell; context: { $implicit: row.name() }\"></ng-container>\n @if (row.name()) {\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n }\n </tr>\n }\n <!-- endregion -->\n <!-- region normal view -->\n <!-- endregion -->\n }\n <ng-template #content>\n <td [attr.colspan]=\"row.flip() ? 2 : 1\" [ngClass]=\"{\n 'h-20': row.editCell()?.template && (isEditMode || isFormMode) && false,\n }\" class=\"pl-8 pr-4 w-full py-2\">\n @if (row.editCell()?.template && (isEditMode || isFormMode)) {\n <ng-container *ngTemplateOutlet=\"editMode\"></ng-container>\n } @else {\n <ng-container *ngTemplateOutlet=\"viewMode\"></ng-container>\n }\n </td>\n <ng-template #viewMode>\n <ng-container\n *ngTemplateOutlet=\"row.cell()?.template ?? defaultCell;context: { $implicit: data$ | dataGridValue: row.name() | async, data: data$ | async }\"></ng-container>\n </ng-template>\n <ng-template #editMode>\n <ng-container\n *ngTemplateOutlet=\"row.editCell()?.template ?? row.cell()?.template ?? defaultCell;context: { $implicit: data$ | dataGridValue: row.name() | async, data: data$ | async }\"></ng-container>\n </ng-template>\n </ng-template>\n }\n </tbody>\n @if (hasAnyEditCells) {\n <tfoot>\n <tr>\n <td class=\"py-2\" colspan=\"2\">\n @if (isEditMode) {\n <div class=\"pt-8 flex flex-col gap-y-6\">\n <div class=\"flex flex-row gap-x-6 items-center justify-start\">\n <button (click)=\"submit()\" [disabled]=\"loading$ | async\" color=\"primary\" mat-raised-button type=\"button\">\n <span class=\"flex flex-row gap-x-6 items-center justify-center\">\n <span i18n>Save</span>\n @if (loading$ | async) {\n <mat-spinner color=\"accent\" diameter=\"15\"></mat-spinner>\n }\n </span>\n </button>\n <button (click)=\"reset()\" [disabled]=\"loading$ | async\" mat-stroked-button type=\"button\">\n <ng-container i18n>Reset</ng-container>\n </button>\n <button (click)=\"cancel()\" [disabled]=\"loading$ | async\" color=\"warn\" mat-stroked-button type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n @if (isDevMode) {\n <button (click)=\"logCurrentFormState()\" mat-button type=\"button\">\n <ng-container i18n>Current Form State</ng-container>\n </button>\n }\n </div>\n <ng-template rxapFormSubmitInvalid>\n <mat-error i18n>Ensure all formula fields are valid.</mat-error>\n </ng-template>\n <ng-template let-error rxapFormSubmitFailed>\n <mat-error>{{ error.error?.message ?? error.message }}</mat-error>\n </ng-template>\n <ng-template rxapFormSubmitSuccessful>\n <span i18n>Submit successfully.</span>\n </ng-template>\n </div>\n } @else {\n <div class=\"pt-8\">\n <button (click)=\"enableEditMode()\" color=\"primary\" mat-raised-button type=\"button\">\n <span class=\"flex flex-row gap-x-6 items-center justify-center\">\n <span i18n>Edit</span>\n @if (loading$ | async) {\n <mat-spinner color=\"accent\" diameter=\"15\"></mat-spinner>\n }\n </span>\n </button>\n </div>\n }\n </td>\n </tr>\n </tfoot>\n }\n </table>\n}\n\n<ng-template #defaultCell let-value>\n <span>{{ value }}</span>\n</ng-template>\n<ng-template #defaultHeaderCell let-name>\n <th class=\"py-2 whitespace-nowrap\">{{ name }}</th>\n</ng-template>\n",
|
|
604
|
+
styles: [":host ::ng-deep th{text-align:right;width:auto}\n"],
|
|
605
|
+
dependencies: [
|
|
606
|
+
{
|
|
607
|
+
kind: "ngmodule",
|
|
608
|
+
type: MatButtonModule
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
kind: "component",
|
|
612
|
+
type: i1.MatButton,
|
|
613
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
614
|
+
inputs: ["matButton"],
|
|
615
|
+
exportAs: ["matButton", "matAnchor"]
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
kind: "ngmodule",
|
|
619
|
+
type: MatIconModule
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
kind: "directive",
|
|
623
|
+
type: FormSubmitFailedDirective,
|
|
624
|
+
selector: "[rxapFormSubmitFailed]"
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
kind: "directive",
|
|
628
|
+
type: FormSubmitSuccessfulDirective,
|
|
629
|
+
selector: "[rxapFormSubmitSuccessful]"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
kind: "directive",
|
|
633
|
+
type: FormSubmitInvalidDirective,
|
|
634
|
+
selector: "[rxapFormSubmitInvalid]"
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
kind: "ngmodule",
|
|
638
|
+
type: MatProgressSpinnerModule
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
kind: "component",
|
|
642
|
+
type: i2.MatProgressSpinner,
|
|
643
|
+
selector: "mat-progress-spinner, mat-spinner",
|
|
644
|
+
inputs: [
|
|
645
|
+
"color",
|
|
646
|
+
"mode",
|
|
647
|
+
"value",
|
|
648
|
+
"diameter",
|
|
649
|
+
"strokeWidth"
|
|
650
|
+
],
|
|
651
|
+
exportAs: ["matProgressSpinner"]
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
kind: "ngmodule",
|
|
655
|
+
type: MatDividerModule
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
kind: "component",
|
|
659
|
+
type: i3.MatDivider,
|
|
660
|
+
selector: "mat-divider",
|
|
661
|
+
inputs: ["vertical", "inset"]
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
kind: "directive",
|
|
665
|
+
type: NgTemplateOutlet,
|
|
666
|
+
selector: "[ngTemplateOutlet]",
|
|
667
|
+
inputs: [
|
|
668
|
+
"ngTemplateOutletContext",
|
|
669
|
+
"ngTemplateOutlet",
|
|
670
|
+
"ngTemplateOutletInjector"
|
|
671
|
+
]
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
kind: "ngmodule",
|
|
675
|
+
type: MatFormFieldModule
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
kind: "directive",
|
|
679
|
+
type: i4.MatError,
|
|
680
|
+
selector: "mat-error, [matError]",
|
|
681
|
+
inputs: ["id"]
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
kind: "directive",
|
|
685
|
+
type: NgClass,
|
|
686
|
+
selector: "[ngClass]",
|
|
687
|
+
inputs: ["class", "ngClass"]
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
kind: "pipe",
|
|
691
|
+
type: AsyncPipe,
|
|
692
|
+
name: "async"
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
kind: "pipe",
|
|
696
|
+
type: DataGridValuePipe,
|
|
697
|
+
name: "dataGridValue"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
kind: "pipe",
|
|
701
|
+
type: IsEmptyPipe,
|
|
702
|
+
name: "isEmpty"
|
|
703
|
+
}
|
|
704
|
+
],
|
|
705
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
710
|
+
minVersion: "12.0.0",
|
|
711
|
+
version: "22.3.0",
|
|
712
|
+
ngImport: i0,
|
|
713
|
+
type: DataGridComponent,
|
|
714
|
+
decorators: [{
|
|
715
|
+
type: Component,
|
|
716
|
+
args: [{
|
|
717
|
+
selector: "rxap-data-grid",
|
|
718
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
719
|
+
imports: [
|
|
720
|
+
AsyncPipe,
|
|
721
|
+
MatButtonModule,
|
|
722
|
+
MatIconModule,
|
|
723
|
+
GetFromObjectPipe,
|
|
724
|
+
ReplacePipe,
|
|
725
|
+
EscapeQuotationMarkPipe,
|
|
726
|
+
FormSubmitFailedDirective,
|
|
727
|
+
FormSubmitSuccessfulDirective,
|
|
728
|
+
FormSubmitInvalidDirective,
|
|
729
|
+
DataGridValuePipe,
|
|
730
|
+
MatProgressSpinnerModule,
|
|
731
|
+
MatDividerModule,
|
|
732
|
+
NgTemplateOutlet,
|
|
733
|
+
MatFormFieldModule,
|
|
734
|
+
NgClass,
|
|
735
|
+
IsEmptyPipe
|
|
736
|
+
],
|
|
737
|
+
template: "@if ((hasError$ | async)) {\n <div class=\"flex flex-col items-center justify-center gap-y-8\">\n <span i18n>Something has gone wrong!</span>\n <button (click)=\"retry()\" i18n mat-stroked-button type=\"button\">Retry</button>\n </div>\n}\n@if ((dataLoading$ | async)) {\n <div class=\"flex flex-col items-center justify-center gap-y-8\">\n <mat-spinner></mat-spinner>\n </div>\n}\n<!-- if the dataSource input is used. It is possible the the hasError$ or loading$ property is === EMPTY. this would\nresults in an null as output. If the === false check is used this can result into the behavior that the data grid is\nnever shown. -->\n<!-- eslint-disable-next-line @angular-eslint/template/no-negated-async -->\n@if (!(hasError$ | async) && !(dataLoading$ | async)) {\n <table class=\"w-full table-auto\">\n @if (header()) {\n <thead>\n <tr>\n <th class=\"py-2\" i18n>Label</th>\n <th class=\"py-2\" i18n>Value</th>\n </tr>\n </thead>\n }\n <tbody>\n @for (row of rows$ | async; track row; let first = $first) {\n @if ((!displayProperties() || row.isSubHeader || (row.name() && displayProperties()?.includes(row.name()!))) && (!hideEmptyProperties() || row.isSubHeader || false === (data$ | isEmpty: row.name() | async))) {\n <!-- region horizontal view -->\n @if (row.flip()) {\n <tr>\n <td class=\"py-2\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n <tr [attr.data-name]=\"row.name() + '-header'\">\n <ng-container\n *ngTemplateOutlet=\"row.headerCell()?.template ?? defaultHeaderCell; context: { $implicit: row.name() }\"></ng-container>\n </tr>\n <tr [attr.data-name]=\"row.name() + '-value'\">\n @if (row.name()) {\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n }\n </tr>\n <tr>\n <td class=\"py-4\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n } @else {\n @if (!first && row.isSubHeader) {\n <tr>\n <td class=\"py-4\" colspan=\"2\">\n <mat-divider></mat-divider>\n </td>\n </tr>\n }\n <tr [attr.data-name]=\"row.name()\" [ngClass]=\"{ 'sub-header text-2xl': row.isSubHeader }\">\n <ng-container\n *ngTemplateOutlet=\"row.headerCell()?.template ?? defaultHeaderCell; context: { $implicit: row.name() }\"></ng-container>\n @if (row.name()) {\n <ng-container *ngTemplateOutlet=\"content\"></ng-container>\n }\n </tr>\n }\n <!-- endregion -->\n <!-- region normal view -->\n <!-- endregion -->\n }\n <ng-template #content>\n <td [attr.colspan]=\"row.flip() ? 2 : 1\" [ngClass]=\"{\n 'h-20': row.editCell()?.template && (isEditMode || isFormMode) && false,\n }\" class=\"pl-8 pr-4 w-full py-2\">\n @if (row.editCell()?.template && (isEditMode || isFormMode)) {\n <ng-container *ngTemplateOutlet=\"editMode\"></ng-container>\n } @else {\n <ng-container *ngTemplateOutlet=\"viewMode\"></ng-container>\n }\n </td>\n <ng-template #viewMode>\n <ng-container\n *ngTemplateOutlet=\"row.cell()?.template ?? defaultCell;context: { $implicit: data$ | dataGridValue: row.name() | async, data: data$ | async }\"></ng-container>\n </ng-template>\n <ng-template #editMode>\n <ng-container\n *ngTemplateOutlet=\"row.editCell()?.template ?? row.cell()?.template ?? defaultCell;context: { $implicit: data$ | dataGridValue: row.name() | async, data: data$ | async }\"></ng-container>\n </ng-template>\n </ng-template>\n }\n </tbody>\n @if (hasAnyEditCells) {\n <tfoot>\n <tr>\n <td class=\"py-2\" colspan=\"2\">\n @if (isEditMode) {\n <div class=\"pt-8 flex flex-col gap-y-6\">\n <div class=\"flex flex-row gap-x-6 items-center justify-start\">\n <button (click)=\"submit()\" [disabled]=\"loading$ | async\" color=\"primary\" mat-raised-button type=\"button\">\n <span class=\"flex flex-row gap-x-6 items-center justify-center\">\n <span i18n>Save</span>\n @if (loading$ | async) {\n <mat-spinner color=\"accent\" diameter=\"15\"></mat-spinner>\n }\n </span>\n </button>\n <button (click)=\"reset()\" [disabled]=\"loading$ | async\" mat-stroked-button type=\"button\">\n <ng-container i18n>Reset</ng-container>\n </button>\n <button (click)=\"cancel()\" [disabled]=\"loading$ | async\" color=\"warn\" mat-stroked-button type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n @if (isDevMode) {\n <button (click)=\"logCurrentFormState()\" mat-button type=\"button\">\n <ng-container i18n>Current Form State</ng-container>\n </button>\n }\n </div>\n <ng-template rxapFormSubmitInvalid>\n <mat-error i18n>Ensure all formula fields are valid.</mat-error>\n </ng-template>\n <ng-template let-error rxapFormSubmitFailed>\n <mat-error>{{ error.error?.message ?? error.message }}</mat-error>\n </ng-template>\n <ng-template rxapFormSubmitSuccessful>\n <span i18n>Submit successfully.</span>\n </ng-template>\n </div>\n } @else {\n <div class=\"pt-8\">\n <button (click)=\"enableEditMode()\" color=\"primary\" mat-raised-button type=\"button\">\n <span class=\"flex flex-row gap-x-6 items-center justify-center\">\n <span i18n>Edit</span>\n @if (loading$ | async) {\n <mat-spinner color=\"accent\" diameter=\"15\"></mat-spinner>\n }\n </span>\n </button>\n </div>\n }\n </td>\n </tr>\n </tfoot>\n }\n </table>\n}\n\n<ng-template #defaultCell let-value>\n <span>{{ value }}</span>\n</ng-template>\n<ng-template #defaultHeaderCell let-name>\n <th class=\"py-2 whitespace-nowrap\">{{ name }}</th>\n</ng-template>\n",
|
|
738
|
+
styles: [":host ::ng-deep th{text-align:right;width:auto}\n"]
|
|
739
|
+
}]
|
|
740
|
+
}],
|
|
741
|
+
propDecorators: {
|
|
742
|
+
header: [{
|
|
743
|
+
type: i0.Input,
|
|
744
|
+
args: [{
|
|
745
|
+
isSignal: true,
|
|
746
|
+
alias: "header",
|
|
747
|
+
required: false
|
|
748
|
+
}]
|
|
749
|
+
}],
|
|
750
|
+
dataSource: [{
|
|
751
|
+
type: i0.Input,
|
|
752
|
+
args: [{
|
|
753
|
+
isSignal: true,
|
|
754
|
+
alias: "dataSource",
|
|
755
|
+
required: false
|
|
756
|
+
}]
|
|
757
|
+
}],
|
|
758
|
+
viewer: [{
|
|
759
|
+
type: i0.Input,
|
|
760
|
+
args: [{
|
|
761
|
+
isSignal: true,
|
|
762
|
+
alias: "viewer",
|
|
763
|
+
required: false
|
|
764
|
+
}]
|
|
765
|
+
}],
|
|
766
|
+
data: [{
|
|
767
|
+
type: i0.Input,
|
|
768
|
+
args: [{
|
|
769
|
+
isSignal: true,
|
|
770
|
+
alias: "data",
|
|
771
|
+
required: false
|
|
772
|
+
}]
|
|
773
|
+
}],
|
|
774
|
+
displayProperties: [{
|
|
775
|
+
type: i0.Input,
|
|
776
|
+
args: [{
|
|
777
|
+
isSignal: true,
|
|
778
|
+
alias: "displayProperties",
|
|
779
|
+
required: false
|
|
780
|
+
}]
|
|
781
|
+
}],
|
|
782
|
+
hideEmptyProperties: [{
|
|
783
|
+
type: i0.Input,
|
|
784
|
+
args: [{
|
|
785
|
+
isSignal: true,
|
|
786
|
+
alias: "hideEmptyProperties",
|
|
787
|
+
required: false
|
|
788
|
+
}]
|
|
789
|
+
}],
|
|
790
|
+
rows: [{
|
|
791
|
+
type: i0.ContentChildren,
|
|
792
|
+
args: [i0.forwardRef(() => DataGridRowDefDirective), { isSignal: true }]
|
|
793
|
+
}],
|
|
794
|
+
editModeChange: [{
|
|
795
|
+
type: i0.Output,
|
|
796
|
+
args: ["editModeChange"]
|
|
797
|
+
}],
|
|
798
|
+
mode: [{
|
|
799
|
+
type: i0.Input,
|
|
800
|
+
args: [{
|
|
801
|
+
isSignal: true,
|
|
802
|
+
alias: "mode",
|
|
803
|
+
required: false
|
|
804
|
+
}]
|
|
805
|
+
}]
|
|
806
|
+
}
|
|
807
|
+
});
|
|
394
808
|
export { DataGridCellDefDirective, DataGridComponent, DataGridEditCellDefDirective, DataGridHeaderCellDefDirective, DataGridMode, DataGridRowDefDirective, DataGridValuePipe, IsEmptyPipe };
|
|
395
|
-
|
|
809
|
+
|
|
810
|
+
//# sourceMappingURL=rxap-data-grid.mjs.map
|