@toolbox-web/grid-angular 0.4.0 → 0.5.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/README.md +296 -16
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -1
- package/index.js +541 -273
- package/lib/angular-grid-adapter.d.ts.map +1 -1
- package/lib/base-grid-editor.d.ts +145 -0
- package/lib/base-grid-editor.d.ts.map +1 -0
- package/lib/directives/grid-column-editor.directive.d.ts +17 -0
- package/lib/directives/grid-column-editor.directive.d.ts.map +1 -1
- package/lib/directives/grid-form-array.directive.d.ts +141 -0
- package/lib/directives/grid-form-array.directive.d.ts.map +1 -0
- package/lib/directives/index.d.ts +2 -0
- package/lib/directives/index.d.ts.map +1 -1
- package/lib/directives/structural-directives.d.ts +10 -0
- package/lib/directives/structural-directives.d.ts.map +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
1
|
+
var qe = Object.create;
|
|
2
|
+
var j = Object.defineProperty;
|
|
3
|
+
var $e = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var ue = (n, e) => (e = Symbol[n]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + n), I = (n) => {
|
|
5
5
|
throw TypeError(n);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var h = (n) => [, , ,
|
|
10
|
-
for (var
|
|
11
|
-
return
|
|
12
|
-
}, v = (n, e, t,
|
|
13
|
-
var
|
|
14
|
-
return
|
|
15
|
-
}, set [t](
|
|
16
|
-
return
|
|
7
|
+
var Ue = (n, e, t) => e in n ? j(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
8
|
+
var ce = (n, e) => j(n, "name", { value: e, configurable: !0 });
|
|
9
|
+
var h = (n) => [, , , qe(n?.[ue("metadata")] ?? null)], de = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], O = (n) => n !== void 0 && typeof n != "function" ? I("Function expected") : n, We = (n, e, t, i, r) => ({ kind: de[n], name: e, metadata: i, addInitializer: (o) => t._ ? I("Already initialized") : r.push(O(o || null)) }), He = (n, e) => Ue(e, ue("metadata"), n[3]), g = (n, e, t, i) => {
|
|
10
|
+
for (var r = 0, o = n[e >> 1], s = o && o.length; r < s; r++) e & 1 ? o[r].call(t) : i = o[r].call(t, i);
|
|
11
|
+
return i;
|
|
12
|
+
}, v = (n, e, t, i, r, o) => {
|
|
13
|
+
var s, l, m, d, T, c = e & 7, C = !!(e & 8), a = !!(e & 16), b = c > 3 ? n.length + 1 : c ? C ? 1 : 2 : 0, D = de[c + 5], le = c > 3 && (n[b - 1] = []), Ge = n[b] || (n[b] = []), w = c && (!a && !C && (r = r.prototype), c < 5 && (c > 3 || !a) && $e(c < 4 ? r : { get [t]() {
|
|
14
|
+
return ae(this, o);
|
|
15
|
+
}, set [t](p) {
|
|
16
|
+
return me(this, o, p);
|
|
17
17
|
} }, t));
|
|
18
|
-
|
|
19
|
-
for (var
|
|
20
|
-
|
|
21
|
-
return
|
|
18
|
+
c ? a && c < 4 && ce(o, (c > 2 ? "set " : c > 1 ? "get " : "") + t) : ce(r, t);
|
|
19
|
+
for (var P = i.length - 1; P >= 0; P--)
|
|
20
|
+
d = We(c, t, m = {}, n[3], Ge), c && (d.static = C, d.private = a, T = d.access = { has: a ? (p) => Ye(r, p) : (p) => t in p }, c ^ 3 && (T.get = a ? (p) => (c ^ 1 ? ae : Xe)(p, r, c ^ 4 ? o : w.get) : (p) => p[t]), c > 2 && (T.set = a ? (p, F) => me(p, r, F, c ^ 4 ? o : w.set) : (p, F) => p[t] = F)), l = (0, i[P])(c ? c < 4 ? a ? o : w[D] : c > 4 ? void 0 : { get: w.get, set: w.set } : r, d), m._ = 1, c ^ 4 || l === void 0 ? O(l) && (c > 4 ? le.unshift(l) : c ? a ? o = l : w[D] = l : r = l) : typeof l != "object" || l === null ? I("Object expected") : (O(s = l.get) && (w.get = s), O(s = l.set) && (w.set = s), O(s = l.init) && le.unshift(s));
|
|
21
|
+
return c || He(n, r), w && j(r, t, w), a ? c ^ 4 ? o : w : r;
|
|
22
22
|
};
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
import { inject as
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
|
|
23
|
+
var k = (n, e, t) => e.has(n) || I("Cannot " + t), Ye = (n, e) => Object(e) !== e ? I('Cannot use the "in" operator on this value') : n.has(e), ae = (n, e, t) => (k(n, e, "read from private field"), t ? t.call(n) : e.get(n));
|
|
24
|
+
var me = (n, e, t, i) => (k(n, e, "write to private field"), i ? i.call(n, t) : e.set(n, t), t), Xe = (n, e, t) => (k(n, e, "access private method"), t);
|
|
25
|
+
import { inject as u, ElementRef as R, contentChild as x, TemplateRef as L, effect as y, Directive as E, input as f, InjectionToken as ze, Injectable as Be, makeEnvironmentProviders as Je, EventEmitter as fe, createComponent as pe, output as S, computed as A, EnvironmentInjector as Ke, ApplicationRef as Qe, ViewContainerRef as Ze } from "@angular/core";
|
|
26
|
+
import { FormGroup as he } from "@angular/forms";
|
|
27
|
+
import { DataGridElement as et } from "@toolbox-web/grid";
|
|
28
|
+
import { MasterDetailPlugin as ge, ResponsivePlugin as tt } from "@toolbox-web/grid/all";
|
|
29
|
+
function ve(n) {
|
|
29
30
|
if (typeof n != "function" || n.prototype === void 0)
|
|
30
31
|
return !1;
|
|
31
32
|
if (Object.prototype.hasOwnProperty.call(n, "ɵcmp") || Object.prototype.hasOwnProperty.call(n, "ɵfac"))
|
|
@@ -33,22 +34,22 @@ function me(n) {
|
|
|
33
34
|
const e = Function.prototype.toString.call(n);
|
|
34
35
|
return e.startsWith("class ") || e.startsWith("class{");
|
|
35
36
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
38
|
-
return
|
|
37
|
+
const Se = /* @__PURE__ */ new Map();
|
|
38
|
+
function Pe(n) {
|
|
39
|
+
return Se.get(n);
|
|
39
40
|
}
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
class
|
|
43
|
-
elementRef =
|
|
41
|
+
var Ce, X;
|
|
42
|
+
Ce = [E({ selector: "tbw-grid-column-editor" })];
|
|
43
|
+
class V {
|
|
44
|
+
elementRef = u(R);
|
|
44
45
|
/**
|
|
45
46
|
* Query for the ng-template content child.
|
|
46
47
|
*/
|
|
47
|
-
template = L
|
|
48
|
+
template = x(L);
|
|
48
49
|
/** Effect that triggers when the template is available */
|
|
49
|
-
onTemplateReceived =
|
|
50
|
+
onTemplateReceived = y(() => {
|
|
50
51
|
const e = this.template();
|
|
51
|
-
e &&
|
|
52
|
+
e && Se.set(this.elementRef.nativeElement, e);
|
|
52
53
|
});
|
|
53
54
|
/**
|
|
54
55
|
* Static type guard for template context.
|
|
@@ -58,23 +59,23 @@ class M {
|
|
|
58
59
|
return !0;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
function
|
|
64
|
-
return
|
|
62
|
+
X = h(null), V = v(X, 0, "GridColumnEditor", Ce, V), g(X, 1, V);
|
|
63
|
+
const Fe = /* @__PURE__ */ new Map();
|
|
64
|
+
function je(n) {
|
|
65
|
+
return Fe.get(n);
|
|
65
66
|
}
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
class
|
|
69
|
-
elementRef =
|
|
67
|
+
var ye, z;
|
|
68
|
+
ye = [E({ selector: "tbw-grid-column-view" })];
|
|
69
|
+
class N {
|
|
70
|
+
elementRef = u(R);
|
|
70
71
|
/**
|
|
71
72
|
* Query for the ng-template content child.
|
|
72
73
|
*/
|
|
73
|
-
template = L
|
|
74
|
+
template = x(L);
|
|
74
75
|
/** Effect that triggers when the template is available */
|
|
75
|
-
onTemplateReceived =
|
|
76
|
+
onTemplateReceived = y(() => {
|
|
76
77
|
const e = this.template();
|
|
77
|
-
e &&
|
|
78
|
+
e && Fe.set(this.elementRef.nativeElement, e);
|
|
78
79
|
});
|
|
79
80
|
/**
|
|
80
81
|
* Static type guard for template context.
|
|
@@ -84,29 +85,29 @@ class V {
|
|
|
84
85
|
return !0;
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
function
|
|
88
|
+
z = h(null), N = v(z, 0, "GridColumnView", ye, N), g(z, 1, N);
|
|
89
|
+
const ke = /* @__PURE__ */ new Map();
|
|
90
|
+
function we(n) {
|
|
90
91
|
const e = n.querySelector("tbw-grid-detail");
|
|
91
92
|
if (e)
|
|
92
|
-
return
|
|
93
|
+
return ke.get(e);
|
|
93
94
|
}
|
|
94
|
-
var
|
|
95
|
-
|
|
95
|
+
var be, B;
|
|
96
|
+
be = [E({ selector: "tbw-grid-detail" })];
|
|
96
97
|
class _ {
|
|
97
|
-
elementRef =
|
|
98
|
+
elementRef = u(R);
|
|
98
99
|
/** Whether to show the expand/collapse column. Default: true */
|
|
99
|
-
showExpandColumn =
|
|
100
|
+
showExpandColumn = f(!0);
|
|
100
101
|
/** Animation style for expand/collapse. Default: 'slide' */
|
|
101
|
-
animation =
|
|
102
|
+
animation = f("slide");
|
|
102
103
|
/**
|
|
103
104
|
* Query for the ng-template content child.
|
|
104
105
|
*/
|
|
105
|
-
template = L
|
|
106
|
+
template = x(L);
|
|
106
107
|
/** Effect that triggers when the template is available */
|
|
107
|
-
onTemplateReceived =
|
|
108
|
+
onTemplateReceived = y(() => {
|
|
108
109
|
const e = this.template();
|
|
109
|
-
e &&
|
|
110
|
+
e && ke.set(this.elementRef.nativeElement, e);
|
|
110
111
|
});
|
|
111
112
|
/**
|
|
112
113
|
* Static type guard for template context.
|
|
@@ -116,29 +117,146 @@ class _ {
|
|
|
116
117
|
return !0;
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
function
|
|
120
|
+
B = h(null), _ = v(B, 0, "GridDetailView", be, _), g(B, 1, _);
|
|
121
|
+
const ie = /* @__PURE__ */ Symbol("formArrayContext");
|
|
122
|
+
function rt(n) {
|
|
123
|
+
return n[ie];
|
|
124
|
+
}
|
|
125
|
+
var Te, J;
|
|
126
|
+
Te = [E({
|
|
127
|
+
selector: "tbw-grid[formArray]"
|
|
128
|
+
})];
|
|
129
|
+
class G {
|
|
130
|
+
elementRef = u(R);
|
|
131
|
+
cellCommitListener = null;
|
|
132
|
+
touchListener = null;
|
|
133
|
+
/**
|
|
134
|
+
* The FormArray to bind to the grid.
|
|
135
|
+
*/
|
|
136
|
+
formArray = f.required();
|
|
137
|
+
/**
|
|
138
|
+
* Effect that syncs the FormArray value to the grid rows.
|
|
139
|
+
*/
|
|
140
|
+
syncFormArrayToGrid = y(() => {
|
|
141
|
+
const e = this.formArray(), t = this.elementRef.nativeElement;
|
|
142
|
+
t && e && (t.rows = e.getRawValue());
|
|
143
|
+
});
|
|
144
|
+
ngOnInit() {
|
|
145
|
+
const e = this.elementRef.nativeElement;
|
|
146
|
+
e && (this.#r(e), this.cellCommitListener = (t) => {
|
|
147
|
+
const i = t.detail;
|
|
148
|
+
this.#i(i);
|
|
149
|
+
}, e.addEventListener("cell-commit", this.cellCommitListener), this.touchListener = () => {
|
|
150
|
+
this.formArray().markAsTouched(), this.touchListener && (e.removeEventListener("click", this.touchListener), this.touchListener = null);
|
|
151
|
+
}, e.addEventListener("click", this.touchListener));
|
|
152
|
+
}
|
|
153
|
+
ngOnDestroy() {
|
|
154
|
+
const e = this.elementRef.nativeElement;
|
|
155
|
+
e && (this.cellCommitListener && e.removeEventListener("cell-commit", this.cellCommitListener), this.touchListener && e.removeEventListener("click", this.touchListener), this.#n(e));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Checks if the FormArray contains FormGroups.
|
|
159
|
+
*/
|
|
160
|
+
#t() {
|
|
161
|
+
const e = this.formArray();
|
|
162
|
+
return e.length === 0 ? !1 : e.at(0) instanceof he;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Gets the FormGroup at a specific row index.
|
|
166
|
+
*/
|
|
167
|
+
#e(e) {
|
|
168
|
+
const i = this.formArray().at(e);
|
|
169
|
+
return i instanceof he ? i : void 0;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Stores the FormArrayContext on the grid element.
|
|
173
|
+
*/
|
|
174
|
+
#r(e) {
|
|
175
|
+
const t = (r) => this.#e(r), i = {
|
|
176
|
+
getRow: (r) => {
|
|
177
|
+
const s = this.formArray().at(r);
|
|
178
|
+
return s ? s.value : null;
|
|
179
|
+
},
|
|
180
|
+
updateField: (r, o, s) => {
|
|
181
|
+
const l = t(r);
|
|
182
|
+
if (l) {
|
|
183
|
+
const m = l.get(o);
|
|
184
|
+
m && (m.setValue(s), m.markAsDirty());
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
getValue: () => this.formArray().getRawValue(),
|
|
188
|
+
hasFormGroups: this.#t(),
|
|
189
|
+
getControl: (r, o) => {
|
|
190
|
+
const s = t(r);
|
|
191
|
+
if (s)
|
|
192
|
+
return s.get(o) ?? void 0;
|
|
193
|
+
},
|
|
194
|
+
getRowFormGroup: t,
|
|
195
|
+
isRowValid: (r) => {
|
|
196
|
+
const o = t(r);
|
|
197
|
+
return o ? o.valid : !0;
|
|
198
|
+
},
|
|
199
|
+
isRowTouched: (r) => {
|
|
200
|
+
const o = t(r);
|
|
201
|
+
return o ? o.touched : !1;
|
|
202
|
+
},
|
|
203
|
+
isRowDirty: (r) => {
|
|
204
|
+
const o = t(r);
|
|
205
|
+
return o ? o.dirty : !1;
|
|
206
|
+
},
|
|
207
|
+
getRowErrors: (r) => {
|
|
208
|
+
const o = t(r);
|
|
209
|
+
if (!o) return null;
|
|
210
|
+
const s = {};
|
|
211
|
+
let l = !1;
|
|
212
|
+
return Object.keys(o.controls).forEach((m) => {
|
|
213
|
+
const d = o.get(m);
|
|
214
|
+
d?.errors && (s[m] = d.errors, l = !0);
|
|
215
|
+
}), o.errors && (s._group = o.errors, l = !0), l ? s : null;
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
e[ie] = i;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Clears the FormArrayContext from the grid element.
|
|
222
|
+
*/
|
|
223
|
+
#n(e) {
|
|
224
|
+
delete e[ie];
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Handles cell-commit events by updating the FormControl in the FormGroup.
|
|
228
|
+
*/
|
|
229
|
+
#i(e) {
|
|
230
|
+
const { rowIndex: t, field: i, value: r } = e, o = this.#e(t);
|
|
231
|
+
if (o) {
|
|
232
|
+
const s = o.get(i);
|
|
233
|
+
s && (s.setValue(r), s.markAsDirty(), s.markAsTouched());
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
J = h(null), G = v(J, 0, "GridFormArray", Te, G), g(J, 1, G);
|
|
238
|
+
const Ve = /* @__PURE__ */ new Map();
|
|
239
|
+
function nt(n) {
|
|
122
240
|
const e = n.querySelector("tbw-grid-responsive-card");
|
|
123
241
|
if (e)
|
|
124
|
-
return
|
|
242
|
+
return Ve.get(e);
|
|
125
243
|
}
|
|
126
|
-
var
|
|
127
|
-
|
|
244
|
+
var Ae, K;
|
|
245
|
+
Ae = [E({
|
|
128
246
|
selector: "tbw-grid-responsive-card"
|
|
129
247
|
})];
|
|
130
|
-
class
|
|
131
|
-
elementRef =
|
|
248
|
+
class q {
|
|
249
|
+
elementRef = u(R);
|
|
132
250
|
/**
|
|
133
251
|
* The ng-template containing the card content.
|
|
134
252
|
*/
|
|
135
|
-
template = L
|
|
253
|
+
template = x(L);
|
|
136
254
|
/**
|
|
137
255
|
* Effect that registers the template when it becomes available.
|
|
138
256
|
*/
|
|
139
|
-
onTemplateReceived =
|
|
257
|
+
onTemplateReceived = y(() => {
|
|
140
258
|
const e = this.template();
|
|
141
|
-
e &&
|
|
259
|
+
e && Ve.set(
|
|
142
260
|
this.elementRef.nativeElement,
|
|
143
261
|
e
|
|
144
262
|
);
|
|
@@ -150,38 +268,38 @@ class x {
|
|
|
150
268
|
return !0;
|
|
151
269
|
}
|
|
152
270
|
}
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
function
|
|
156
|
-
return
|
|
271
|
+
K = h(null), q = v(K, 0, "GridResponsiveCard", Ae, q), g(K, 1, q);
|
|
272
|
+
const Ne = /* @__PURE__ */ new Map();
|
|
273
|
+
function it(n) {
|
|
274
|
+
return Ne.get(n);
|
|
157
275
|
}
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
class
|
|
161
|
-
elementRef =
|
|
276
|
+
var Le, Q;
|
|
277
|
+
Le = [E({ selector: "tbw-grid-tool-panel" })];
|
|
278
|
+
class $ {
|
|
279
|
+
elementRef = u(R);
|
|
162
280
|
/** Unique panel identifier (required) */
|
|
163
|
-
id =
|
|
281
|
+
id = f.required({ alias: "id" });
|
|
164
282
|
/** Panel title shown in accordion header (required) */
|
|
165
|
-
title =
|
|
283
|
+
title = f.required({ alias: "title" });
|
|
166
284
|
/** Icon for accordion section header (emoji or text) */
|
|
167
|
-
icon =
|
|
285
|
+
icon = f();
|
|
168
286
|
/** Tooltip for accordion section header */
|
|
169
|
-
tooltip =
|
|
287
|
+
tooltip = f();
|
|
170
288
|
/** Panel order priority (lower = first, default: 100) */
|
|
171
|
-
order =
|
|
289
|
+
order = f(100);
|
|
172
290
|
/**
|
|
173
291
|
* Query for the ng-template content child.
|
|
174
292
|
*/
|
|
175
|
-
template = L
|
|
293
|
+
template = x(L);
|
|
176
294
|
/** Effect that triggers when the template is available */
|
|
177
|
-
onTemplateReceived =
|
|
295
|
+
onTemplateReceived = y(() => {
|
|
178
296
|
const e = this.template(), t = this.elementRef.nativeElement;
|
|
179
297
|
if (e) {
|
|
180
298
|
t.setAttribute("id", this.id()), t.setAttribute("title", this.title());
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
299
|
+
const i = this.icon();
|
|
300
|
+
i && t.setAttribute("icon", i);
|
|
301
|
+
const r = this.tooltip();
|
|
302
|
+
r && t.setAttribute("tooltip", r), t.setAttribute("order", String(this.order())), Ne.set(t, e);
|
|
185
303
|
}
|
|
186
304
|
});
|
|
187
305
|
/**
|
|
@@ -192,30 +310,30 @@ class q {
|
|
|
192
310
|
return !0;
|
|
193
311
|
}
|
|
194
312
|
}
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
function
|
|
198
|
-
const e =
|
|
313
|
+
Q = h(null), $ = v(Q, 0, "GridToolPanel", Le, $), g(Q, 1, $);
|
|
314
|
+
const oe = /* @__PURE__ */ new Map(), se = /* @__PURE__ */ new Map();
|
|
315
|
+
function ot(n) {
|
|
316
|
+
const e = oe.get(n);
|
|
199
317
|
if (e) return e;
|
|
200
318
|
const t = n.querySelector("tbw-grid-column-view");
|
|
201
319
|
if (t)
|
|
202
|
-
return
|
|
320
|
+
return je(t);
|
|
203
321
|
}
|
|
204
|
-
function
|
|
205
|
-
const e =
|
|
322
|
+
function st(n) {
|
|
323
|
+
const e = se.get(n);
|
|
206
324
|
if (e) return e;
|
|
207
325
|
const t = n.querySelector("tbw-grid-column-editor");
|
|
208
326
|
if (t)
|
|
209
|
-
return
|
|
327
|
+
return Pe(t);
|
|
210
328
|
}
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
class
|
|
214
|
-
template =
|
|
215
|
-
elementRef =
|
|
329
|
+
var De, Z;
|
|
330
|
+
De = [E({ selector: "[tbwRenderer]" })];
|
|
331
|
+
class U {
|
|
332
|
+
template = u(L);
|
|
333
|
+
elementRef = u(R);
|
|
216
334
|
columnElement = null;
|
|
217
335
|
constructor() {
|
|
218
|
-
|
|
336
|
+
y(() => {
|
|
219
337
|
this.registerTemplate();
|
|
220
338
|
});
|
|
221
339
|
}
|
|
@@ -223,10 +341,10 @@ class k {
|
|
|
223
341
|
let e = this.elementRef.nativeElement?.parentElement;
|
|
224
342
|
for (; e && e.tagName !== "TBW-GRID-COLUMN"; )
|
|
225
343
|
e = e.parentElement;
|
|
226
|
-
e && (this.columnElement = e,
|
|
344
|
+
e && (this.columnElement = e, oe.set(e, this.template));
|
|
227
345
|
}
|
|
228
346
|
ngOnDestroy() {
|
|
229
|
-
this.columnElement &&
|
|
347
|
+
this.columnElement && oe.delete(this.columnElement);
|
|
230
348
|
}
|
|
231
349
|
/**
|
|
232
350
|
* Static type guard for template context.
|
|
@@ -236,15 +354,15 @@ class k {
|
|
|
236
354
|
return !0;
|
|
237
355
|
}
|
|
238
356
|
}
|
|
239
|
-
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
class
|
|
243
|
-
template =
|
|
244
|
-
elementRef =
|
|
357
|
+
Z = h(null), U = v(Z, 0, "TbwRenderer", De, U), g(Z, 1, U);
|
|
358
|
+
var Oe, ee;
|
|
359
|
+
Oe = [E({ selector: "[tbwEditor]" })];
|
|
360
|
+
class W {
|
|
361
|
+
template = u(L);
|
|
362
|
+
elementRef = u(R);
|
|
245
363
|
columnElement = null;
|
|
246
364
|
constructor() {
|
|
247
|
-
|
|
365
|
+
y(() => {
|
|
248
366
|
this.registerTemplate();
|
|
249
367
|
});
|
|
250
368
|
}
|
|
@@ -252,10 +370,10 @@ class $ {
|
|
|
252
370
|
let e = this.elementRef.nativeElement?.parentElement;
|
|
253
371
|
for (; e && e.tagName !== "TBW-GRID-COLUMN"; )
|
|
254
372
|
e = e.parentElement;
|
|
255
|
-
e && (this.columnElement = e,
|
|
373
|
+
e && (this.columnElement = e, se.set(e, this.template));
|
|
256
374
|
}
|
|
257
375
|
ngOnDestroy() {
|
|
258
|
-
this.columnElement &&
|
|
376
|
+
this.columnElement && se.delete(this.columnElement);
|
|
259
377
|
}
|
|
260
378
|
/**
|
|
261
379
|
* Static type guard for template context.
|
|
@@ -265,17 +383,17 @@ class $ {
|
|
|
265
383
|
return !0;
|
|
266
384
|
}
|
|
267
385
|
}
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
var
|
|
271
|
-
|
|
272
|
-
class
|
|
386
|
+
ee = h(null), W = v(ee, 0, "TbwEditor", Oe, W), g(ee, 1, W);
|
|
387
|
+
const _e = new ze("GRID_TYPE_DEFAULTS");
|
|
388
|
+
var Ie, te;
|
|
389
|
+
Ie = [Be({ providedIn: "root" })];
|
|
390
|
+
class M {
|
|
273
391
|
defaults = /* @__PURE__ */ new Map();
|
|
274
392
|
constructor() {
|
|
275
|
-
const e =
|
|
393
|
+
const e = u(_e, { optional: !0 });
|
|
276
394
|
if (e)
|
|
277
|
-
for (const [t,
|
|
278
|
-
this.defaults.set(t,
|
|
395
|
+
for (const [t, i] of Object.entries(e))
|
|
396
|
+
this.defaults.set(t, i);
|
|
279
397
|
}
|
|
280
398
|
/**
|
|
281
399
|
* Register type-level defaults for a custom type.
|
|
@@ -326,23 +444,23 @@ class P {
|
|
|
326
444
|
};
|
|
327
445
|
}
|
|
328
446
|
}
|
|
329
|
-
|
|
330
|
-
function
|
|
331
|
-
return
|
|
447
|
+
te = h(null), M = v(te, 0, "GridTypeRegistry", Ie, M), g(te, 1, M);
|
|
448
|
+
function ft(n) {
|
|
449
|
+
return Je([{ provide: _e, useValue: n }]);
|
|
332
450
|
}
|
|
333
|
-
function
|
|
334
|
-
const e =
|
|
335
|
-
return e ||
|
|
451
|
+
function Re(n) {
|
|
452
|
+
const e = ot(n);
|
|
453
|
+
return e || je(n);
|
|
336
454
|
}
|
|
337
|
-
function
|
|
338
|
-
const e =
|
|
339
|
-
return e ||
|
|
455
|
+
function Ee(n) {
|
|
456
|
+
const e = st(n);
|
|
457
|
+
return e || Pe(n);
|
|
340
458
|
}
|
|
341
|
-
class
|
|
342
|
-
constructor(e, t,
|
|
343
|
-
this.injector = e, this.appRef = t, this.viewContainerRef =
|
|
459
|
+
class lt {
|
|
460
|
+
constructor(e, t, i) {
|
|
461
|
+
this.injector = e, this.appRef = t, this.viewContainerRef = i, window.__ANGULAR_GRID_ADAPTER__ = this;
|
|
344
462
|
try {
|
|
345
|
-
this.typeRegistry = this.injector.get(
|
|
463
|
+
this.typeRegistry = this.injector.get(M, null);
|
|
346
464
|
} catch {
|
|
347
465
|
}
|
|
348
466
|
}
|
|
@@ -378,7 +496,7 @@ class Qe {
|
|
|
378
496
|
processGridConfig(e) {
|
|
379
497
|
if (!e.columns)
|
|
380
498
|
return e;
|
|
381
|
-
const t = e.columns.map((
|
|
499
|
+
const t = e.columns.map((i) => this.processColumn(i));
|
|
382
500
|
return {
|
|
383
501
|
...e,
|
|
384
502
|
columns: t
|
|
@@ -393,14 +511,14 @@ class Qe {
|
|
|
393
511
|
*/
|
|
394
512
|
processColumn(e) {
|
|
395
513
|
const t = { ...e };
|
|
396
|
-
return e.renderer &&
|
|
514
|
+
return e.renderer && ve(e.renderer) && (t.renderer = this.createComponentRenderer(e.renderer)), e.editor && ve(e.editor) && (t.editor = this.createComponentEditor(e.editor)), t;
|
|
397
515
|
}
|
|
398
516
|
/**
|
|
399
517
|
* Determines if this adapter can handle the given element.
|
|
400
518
|
* Checks if a template is registered for this element (structural or nested).
|
|
401
519
|
*/
|
|
402
520
|
canHandle(e) {
|
|
403
|
-
return
|
|
521
|
+
return Re(e) !== void 0 || Ee(e) !== void 0;
|
|
404
522
|
}
|
|
405
523
|
/**
|
|
406
524
|
* Creates a view renderer function that creates an embedded view
|
|
@@ -410,16 +528,16 @@ class Qe {
|
|
|
410
528
|
* allowing the grid to use its default rendering.
|
|
411
529
|
*/
|
|
412
530
|
createRenderer(e) {
|
|
413
|
-
const t =
|
|
531
|
+
const t = Re(e);
|
|
414
532
|
if (t)
|
|
415
|
-
return (
|
|
416
|
-
const
|
|
417
|
-
$implicit:
|
|
418
|
-
value:
|
|
419
|
-
row:
|
|
420
|
-
column:
|
|
421
|
-
},
|
|
422
|
-
return this.viewRefs.push(
|
|
533
|
+
return (i) => {
|
|
534
|
+
const r = {
|
|
535
|
+
$implicit: i.value,
|
|
536
|
+
value: i.value,
|
|
537
|
+
row: i.row,
|
|
538
|
+
column: i.column
|
|
539
|
+
}, o = this.viewContainerRef.createEmbeddedView(t, r);
|
|
540
|
+
return this.viewRefs.push(o), o.detectChanges(), o.rootNodes[0];
|
|
423
541
|
};
|
|
424
542
|
}
|
|
425
543
|
/**
|
|
@@ -441,30 +559,43 @@ class Qe {
|
|
|
441
559
|
* As long as the component emits `(commit)` with the new value.
|
|
442
560
|
*/
|
|
443
561
|
createEditor(e) {
|
|
444
|
-
const t =
|
|
562
|
+
const t = Ee(e), i = e.closest("tbw-grid");
|
|
445
563
|
return t ? (r) => {
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
|
|
564
|
+
const o = (a) => r.commit(a), s = () => r.cancel(), l = new fe(), m = new fe();
|
|
565
|
+
l.subscribe((a) => r.commit(a)), m.subscribe(() => r.cancel());
|
|
566
|
+
let d;
|
|
567
|
+
if (i) {
|
|
568
|
+
const a = rt(i);
|
|
569
|
+
if (a?.hasFormGroups) {
|
|
570
|
+
const b = i.rows;
|
|
571
|
+
if (b) {
|
|
572
|
+
const D = b.indexOf(r.row);
|
|
573
|
+
D >= 0 && (d = a.getControl(D, r.field));
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
const T = {
|
|
449
578
|
$implicit: r.value,
|
|
450
579
|
value: r.value,
|
|
451
580
|
row: r.row,
|
|
452
581
|
column: r.column,
|
|
453
582
|
// Preferred: simple callback functions
|
|
454
|
-
onCommit:
|
|
583
|
+
onCommit: o,
|
|
455
584
|
onCancel: s,
|
|
585
|
+
// FormControl from FormArray (if available)
|
|
586
|
+
control: d,
|
|
456
587
|
// Deprecated: EventEmitters (for backwards compatibility)
|
|
457
|
-
commit:
|
|
458
|
-
cancel:
|
|
459
|
-
},
|
|
460
|
-
this.viewRefs.push(
|
|
461
|
-
const
|
|
462
|
-
return
|
|
463
|
-
const
|
|
464
|
-
r.commit(
|
|
465
|
-
}),
|
|
588
|
+
commit: l,
|
|
589
|
+
cancel: m
|
|
590
|
+
}, c = this.viewContainerRef.createEmbeddedView(t, T);
|
|
591
|
+
this.viewRefs.push(c), c.detectChanges();
|
|
592
|
+
const C = c.rootNodes[0];
|
|
593
|
+
return C && C.addEventListener && (C.addEventListener("commit", (a) => {
|
|
594
|
+
const b = a;
|
|
595
|
+
r.commit(b.detail);
|
|
596
|
+
}), C.addEventListener("cancel", () => {
|
|
466
597
|
r.cancel();
|
|
467
|
-
})),
|
|
598
|
+
})), C;
|
|
468
599
|
} : (console.warn("[AngularGridAdapter] No editor template registered for element"), () => document.createElement("div"));
|
|
469
600
|
}
|
|
470
601
|
/**
|
|
@@ -472,16 +603,16 @@ class Qe {
|
|
|
472
603
|
* Renders Angular templates for expandable detail rows.
|
|
473
604
|
*/
|
|
474
605
|
createDetailRenderer(e) {
|
|
475
|
-
const t =
|
|
606
|
+
const t = we(e);
|
|
476
607
|
if (t)
|
|
477
|
-
return (
|
|
478
|
-
const
|
|
479
|
-
$implicit:
|
|
480
|
-
row:
|
|
481
|
-
},
|
|
482
|
-
this.viewRefs.push(
|
|
483
|
-
const
|
|
484
|
-
return
|
|
608
|
+
return (i) => {
|
|
609
|
+
const r = {
|
|
610
|
+
$implicit: i,
|
|
611
|
+
row: i
|
|
612
|
+
}, o = this.viewContainerRef.createEmbeddedView(t, r);
|
|
613
|
+
this.viewRefs.push(o), o.detectChanges();
|
|
614
|
+
const s = document.createElement("div");
|
|
615
|
+
return o.rootNodes.forEach((l) => s.appendChild(l)), s;
|
|
485
616
|
};
|
|
486
617
|
}
|
|
487
618
|
/**
|
|
@@ -492,16 +623,16 @@ class Qe {
|
|
|
492
623
|
* without manual configuration in the Grid directive.
|
|
493
624
|
*/
|
|
494
625
|
parseDetailElement(e) {
|
|
495
|
-
const t =
|
|
626
|
+
const t = we(e.closest("tbw-grid"));
|
|
496
627
|
if (t)
|
|
497
|
-
return (
|
|
498
|
-
const
|
|
499
|
-
$implicit:
|
|
500
|
-
row:
|
|
501
|
-
},
|
|
502
|
-
this.viewRefs.push(
|
|
503
|
-
const
|
|
504
|
-
return
|
|
628
|
+
return (i) => {
|
|
629
|
+
const r = {
|
|
630
|
+
$implicit: i,
|
|
631
|
+
row: i
|
|
632
|
+
}, o = this.viewContainerRef.createEmbeddedView(t, r);
|
|
633
|
+
this.viewRefs.push(o), o.detectChanges();
|
|
634
|
+
const s = document.createElement("div");
|
|
635
|
+
return o.rootNodes.forEach((l) => s.appendChild(l)), s;
|
|
505
636
|
};
|
|
506
637
|
}
|
|
507
638
|
/**
|
|
@@ -512,17 +643,17 @@ class Qe {
|
|
|
512
643
|
* @returns A card renderer function or undefined if no template is found
|
|
513
644
|
*/
|
|
514
645
|
createResponsiveCardRenderer(e) {
|
|
515
|
-
const t =
|
|
646
|
+
const t = nt(e);
|
|
516
647
|
if (t)
|
|
517
|
-
return (
|
|
518
|
-
const
|
|
519
|
-
$implicit:
|
|
520
|
-
row:
|
|
521
|
-
index:
|
|
522
|
-
},
|
|
523
|
-
this.viewRefs.push(
|
|
648
|
+
return (i, r) => {
|
|
649
|
+
const o = {
|
|
650
|
+
$implicit: i,
|
|
651
|
+
row: i,
|
|
652
|
+
index: r
|
|
653
|
+
}, s = this.viewContainerRef.createEmbeddedView(t, o);
|
|
654
|
+
this.viewRefs.push(s), s.detectChanges();
|
|
524
655
|
const l = document.createElement("div");
|
|
525
|
-
return
|
|
656
|
+
return s.rootNodes.forEach((m) => l.appendChild(m)), l;
|
|
526
657
|
};
|
|
527
658
|
}
|
|
528
659
|
/**
|
|
@@ -530,18 +661,18 @@ class Qe {
|
|
|
530
661
|
* The renderer creates an Angular template-based panel content.
|
|
531
662
|
*/
|
|
532
663
|
createToolPanelRenderer(e) {
|
|
533
|
-
const t =
|
|
664
|
+
const t = it(e);
|
|
534
665
|
if (!t)
|
|
535
666
|
return;
|
|
536
|
-
const
|
|
537
|
-
return (
|
|
538
|
-
const
|
|
539
|
-
$implicit:
|
|
540
|
-
grid:
|
|
541
|
-
},
|
|
542
|
-
return this.viewRefs.push(
|
|
543
|
-
const l = this.viewRefs.indexOf(
|
|
544
|
-
l > -1 && this.viewRefs.splice(l, 1),
|
|
667
|
+
const i = e.closest("tbw-grid");
|
|
668
|
+
return (r) => {
|
|
669
|
+
const o = {
|
|
670
|
+
$implicit: i ?? r,
|
|
671
|
+
grid: i ?? r
|
|
672
|
+
}, s = this.viewContainerRef.createEmbeddedView(t, o);
|
|
673
|
+
return this.viewRefs.push(s), s.detectChanges(), s.rootNodes.forEach((l) => r.appendChild(l)), () => {
|
|
674
|
+
const l = this.viewRefs.indexOf(s);
|
|
675
|
+
l > -1 && this.viewRefs.splice(l, 1), s.destroy();
|
|
545
676
|
};
|
|
546
677
|
};
|
|
547
678
|
}
|
|
@@ -578,10 +709,10 @@ class Qe {
|
|
|
578
709
|
const t = this.typeRegistry.get(e);
|
|
579
710
|
if (!t)
|
|
580
711
|
return;
|
|
581
|
-
const
|
|
712
|
+
const i = {
|
|
582
713
|
editorParams: t.editorParams
|
|
583
714
|
};
|
|
584
|
-
return t.renderer && (
|
|
715
|
+
return t.renderer && (i.renderer = this.createComponentRenderer(t.renderer)), t.editor && (i.editor = this.createComponentEditor(t.editor)), i;
|
|
585
716
|
}
|
|
586
717
|
/**
|
|
587
718
|
* Creates a renderer function from an Angular component class.
|
|
@@ -589,17 +720,17 @@ class Qe {
|
|
|
589
720
|
*/
|
|
590
721
|
createComponentRenderer(e) {
|
|
591
722
|
return (t) => {
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
const
|
|
723
|
+
const i = document.createElement("span");
|
|
724
|
+
i.style.display = "contents";
|
|
725
|
+
const r = pe(e, {
|
|
595
726
|
environmentInjector: this.injector,
|
|
596
|
-
hostElement:
|
|
727
|
+
hostElement: i
|
|
597
728
|
});
|
|
598
|
-
return this.setComponentInputs(
|
|
729
|
+
return this.setComponentInputs(r, {
|
|
599
730
|
value: t.value,
|
|
600
731
|
row: t.row,
|
|
601
732
|
column: t.column
|
|
602
|
-
}), this.appRef.attachView(
|
|
733
|
+
}), this.appRef.attachView(r.hostView), this.componentRefs.push(r), r.changeDetectorRef.detectChanges(), i;
|
|
603
734
|
};
|
|
604
735
|
}
|
|
605
736
|
/**
|
|
@@ -608,24 +739,24 @@ class Qe {
|
|
|
608
739
|
*/
|
|
609
740
|
createComponentEditor(e) {
|
|
610
741
|
return (t) => {
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
const
|
|
742
|
+
const i = document.createElement("span");
|
|
743
|
+
i.style.display = "contents";
|
|
744
|
+
const r = pe(e, {
|
|
614
745
|
environmentInjector: this.injector,
|
|
615
|
-
hostElement:
|
|
746
|
+
hostElement: i
|
|
616
747
|
});
|
|
617
|
-
this.setComponentInputs(
|
|
748
|
+
this.setComponentInputs(r, {
|
|
618
749
|
value: t.value,
|
|
619
750
|
row: t.row,
|
|
620
751
|
column: t.column
|
|
621
|
-
}), this.appRef.attachView(
|
|
622
|
-
const
|
|
623
|
-
return this.subscribeToOutput(
|
|
624
|
-
const l =
|
|
752
|
+
}), this.appRef.attachView(r.hostView), this.componentRefs.push(r), r.changeDetectorRef.detectChanges();
|
|
753
|
+
const o = r.instance;
|
|
754
|
+
return this.subscribeToOutput(o, "commit", (s) => t.commit(s)), this.subscribeToOutput(o, "cancel", () => t.cancel()), i.addEventListener("commit", (s) => {
|
|
755
|
+
const l = s;
|
|
625
756
|
t.commit(l.detail);
|
|
626
|
-
}),
|
|
757
|
+
}), i.addEventListener("cancel", () => {
|
|
627
758
|
t.cancel();
|
|
628
|
-
}),
|
|
759
|
+
}), i;
|
|
629
760
|
};
|
|
630
761
|
}
|
|
631
762
|
/**
|
|
@@ -633,18 +764,18 @@ class Qe {
|
|
|
633
764
|
* Works with both EventEmitter and OutputEmitterRef (signal outputs).
|
|
634
765
|
* @internal
|
|
635
766
|
*/
|
|
636
|
-
subscribeToOutput(e, t,
|
|
637
|
-
const
|
|
638
|
-
|
|
767
|
+
subscribeToOutput(e, t, i) {
|
|
768
|
+
const r = e[t];
|
|
769
|
+
r && typeof r.subscribe == "function" && r.subscribe(i);
|
|
639
770
|
}
|
|
640
771
|
/**
|
|
641
772
|
* Sets component inputs using Angular's setInput API.
|
|
642
773
|
* @internal
|
|
643
774
|
*/
|
|
644
775
|
setComponentInputs(e, t) {
|
|
645
|
-
for (const [
|
|
776
|
+
for (const [i, r] of Object.entries(t))
|
|
646
777
|
try {
|
|
647
|
-
e.setInput(
|
|
778
|
+
e.setInput(i, r);
|
|
648
779
|
} catch {
|
|
649
780
|
}
|
|
650
781
|
}
|
|
@@ -656,21 +787,155 @@ class Qe {
|
|
|
656
787
|
this.viewRefs.forEach((e) => e.destroy()), this.viewRefs = [], this.componentRefs.forEach((e) => e.destroy()), this.componentRefs = [];
|
|
657
788
|
}
|
|
658
789
|
}
|
|
659
|
-
var
|
|
660
|
-
|
|
661
|
-
class
|
|
662
|
-
elementRef =
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
790
|
+
var xe, re;
|
|
791
|
+
xe = [E()];
|
|
792
|
+
class H {
|
|
793
|
+
elementRef = u(R);
|
|
794
|
+
// ============================================================================
|
|
795
|
+
// Inputs
|
|
796
|
+
// ============================================================================
|
|
797
|
+
/**
|
|
798
|
+
* The cell value. Used when FormControl is not available.
|
|
799
|
+
* When a FormControl is provided, value is derived from control.value instead.
|
|
800
|
+
*/
|
|
801
|
+
value = f();
|
|
802
|
+
/**
|
|
803
|
+
* The full row data object.
|
|
804
|
+
*/
|
|
805
|
+
row = f();
|
|
806
|
+
/**
|
|
807
|
+
* The column configuration.
|
|
808
|
+
*/
|
|
809
|
+
column = f();
|
|
810
|
+
/**
|
|
811
|
+
* The FormControl for this cell, if the grid is bound to a FormArray.
|
|
812
|
+
* When provided, the editor uses control.value instead of the value input.
|
|
813
|
+
*/
|
|
814
|
+
control = f();
|
|
815
|
+
// ============================================================================
|
|
816
|
+
// Outputs
|
|
817
|
+
// ============================================================================
|
|
818
|
+
/**
|
|
819
|
+
* Emits when the user commits a new value.
|
|
820
|
+
*/
|
|
821
|
+
commit = S();
|
|
822
|
+
/**
|
|
823
|
+
* Emits when the user cancels editing.
|
|
824
|
+
*/
|
|
825
|
+
cancel = S();
|
|
826
|
+
// ============================================================================
|
|
827
|
+
// Computed State
|
|
828
|
+
// ============================================================================
|
|
829
|
+
/**
|
|
830
|
+
* The current value, derived from FormControl if available, otherwise from value input.
|
|
831
|
+
* This is the recommended way to get the current value in your editor template.
|
|
832
|
+
*/
|
|
833
|
+
currentValue = A(() => {
|
|
834
|
+
const e = this.control();
|
|
835
|
+
return e ? e.value : this.value();
|
|
836
|
+
});
|
|
837
|
+
/**
|
|
838
|
+
* Whether the control is invalid (has validation errors).
|
|
839
|
+
* Returns false if no FormControl is available.
|
|
840
|
+
*/
|
|
841
|
+
isInvalid = A(() => this.control()?.invalid ?? !1);
|
|
842
|
+
/**
|
|
843
|
+
* Whether the control is dirty (has been modified).
|
|
844
|
+
* Returns false if no FormControl is available.
|
|
845
|
+
*/
|
|
846
|
+
isDirty = A(() => this.control()?.dirty ?? !1);
|
|
847
|
+
/**
|
|
848
|
+
* Whether the control has been touched.
|
|
849
|
+
* Returns false if no FormControl is available.
|
|
850
|
+
*/
|
|
851
|
+
isTouched = A(() => this.control()?.touched ?? !1);
|
|
852
|
+
/**
|
|
853
|
+
* Whether the control has any validation errors.
|
|
854
|
+
*/
|
|
855
|
+
hasErrors = A(() => {
|
|
856
|
+
const e = this.control();
|
|
857
|
+
return e?.errors != null && Object.keys(e.errors).length > 0;
|
|
858
|
+
});
|
|
859
|
+
/**
|
|
860
|
+
* The first error message from the control's validation errors.
|
|
861
|
+
* Returns an empty string if no errors.
|
|
862
|
+
*/
|
|
863
|
+
firstErrorMessage = A(() => {
|
|
864
|
+
const e = this.control();
|
|
865
|
+
if (!e?.errors) return "";
|
|
866
|
+
const t = Object.keys(e.errors)[0];
|
|
867
|
+
return this.getErrorMessage(t, e.errors[t]);
|
|
868
|
+
});
|
|
869
|
+
/**
|
|
870
|
+
* All error messages from the control's validation errors.
|
|
871
|
+
*/
|
|
872
|
+
allErrorMessages = A(() => {
|
|
873
|
+
const e = this.control();
|
|
874
|
+
return e?.errors ? Object.entries(e.errors).map(([t, i]) => this.getErrorMessage(t, i)) : [];
|
|
875
|
+
});
|
|
876
|
+
// ============================================================================
|
|
877
|
+
// Methods
|
|
878
|
+
// ============================================================================
|
|
879
|
+
/**
|
|
880
|
+
* Commit a new value. Emits the commit output AND dispatches a DOM event.
|
|
881
|
+
* The DOM event enables the grid's auto-wiring to catch the commit.
|
|
882
|
+
* Call this when the user confirms their edit.
|
|
883
|
+
*/
|
|
884
|
+
commitValue(e) {
|
|
885
|
+
this.commit.emit(e), this.elementRef.nativeElement.dispatchEvent(new CustomEvent("commit", { detail: e, bubbles: !0 }));
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Cancel editing. Emits the cancel output AND dispatches a DOM event.
|
|
889
|
+
* Call this when the user cancels (e.g., presses Escape).
|
|
890
|
+
*/
|
|
891
|
+
cancelEdit() {
|
|
892
|
+
this.cancel.emit(), this.elementRef.nativeElement.dispatchEvent(new CustomEvent("cancel", { bubbles: !0 }));
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Get a human-readable error message for a validation error.
|
|
896
|
+
* Override this method to customize error messages for your editor.
|
|
897
|
+
*
|
|
898
|
+
* @param errorKey - The validation error key (e.g., 'required', 'minlength')
|
|
899
|
+
* @param errorValue - The error value (e.g., { requiredLength: 5, actualLength: 3 })
|
|
900
|
+
* @returns A human-readable error message
|
|
901
|
+
*/
|
|
902
|
+
getErrorMessage(e, t) {
|
|
903
|
+
switch (e) {
|
|
904
|
+
case "required":
|
|
905
|
+
return "This field is required";
|
|
906
|
+
case "minlength":
|
|
907
|
+
return `Minimum length is ${t?.requiredLength ?? "unknown"}`;
|
|
908
|
+
case "maxlength":
|
|
909
|
+
return `Maximum length is ${t?.requiredLength ?? "unknown"}`;
|
|
910
|
+
case "min":
|
|
911
|
+
return `Minimum value is ${t?.min ?? "unknown"}`;
|
|
912
|
+
case "max":
|
|
913
|
+
return `Maximum value is ${t?.max ?? "unknown"}`;
|
|
914
|
+
case "email":
|
|
915
|
+
return "Invalid email address";
|
|
916
|
+
case "pattern":
|
|
917
|
+
return "Invalid format";
|
|
918
|
+
default:
|
|
919
|
+
return `Invalid value (${e})`;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
re = h(null), H = v(re, 0, "BaseGridEditor", xe, H), g(re, 1, H);
|
|
924
|
+
var Me, ne;
|
|
925
|
+
Me = [E({ selector: "tbw-grid" })];
|
|
926
|
+
class Y {
|
|
927
|
+
elementRef = u(R);
|
|
928
|
+
injector = u(Ke);
|
|
929
|
+
appRef = u(Qe);
|
|
930
|
+
viewContainerRef = u(Ze);
|
|
666
931
|
adapter = null;
|
|
667
932
|
cellCommitListener = null;
|
|
668
933
|
constructor() {
|
|
669
|
-
|
|
934
|
+
y(() => {
|
|
670
935
|
const e = this.angularConfig();
|
|
671
936
|
if (!e || !this.adapter) return;
|
|
672
|
-
const t = this.adapter.processGridConfig(e),
|
|
673
|
-
|
|
937
|
+
const t = this.adapter.processGridConfig(e), i = this.elementRef.nativeElement;
|
|
938
|
+
i.gridConfig = t;
|
|
674
939
|
});
|
|
675
940
|
}
|
|
676
941
|
rowCommitListener = null;
|
|
@@ -691,7 +956,7 @@ class G {
|
|
|
691
956
|
* <tbw-grid [customStyles]="customStyles">...</tbw-grid>
|
|
692
957
|
* ```
|
|
693
958
|
*/
|
|
694
|
-
customStyles =
|
|
959
|
+
customStyles = f();
|
|
695
960
|
/**
|
|
696
961
|
* Angular-specific grid configuration that supports component classes for renderers/editors.
|
|
697
962
|
*
|
|
@@ -728,7 +993,7 @@ class G {
|
|
|
728
993
|
* ```
|
|
729
994
|
*/
|
|
730
995
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
731
|
-
angularConfig =
|
|
996
|
+
angularConfig = f();
|
|
732
997
|
/**
|
|
733
998
|
* Emitted when a cell value is committed (inline editing).
|
|
734
999
|
* Provides the row, field, new value, and change tracking information.
|
|
@@ -744,7 +1009,7 @@ class G {
|
|
|
744
1009
|
* }
|
|
745
1010
|
* ```
|
|
746
1011
|
*/
|
|
747
|
-
cellCommit =
|
|
1012
|
+
cellCommit = S();
|
|
748
1013
|
/**
|
|
749
1014
|
* Emitted when a row's values are committed (bulk/row editing).
|
|
750
1015
|
* Provides the row data and change tracking information.
|
|
@@ -754,16 +1019,16 @@ class G {
|
|
|
754
1019
|
* <tbw-grid (rowCommit)="onRowCommit($event)">...</tbw-grid>
|
|
755
1020
|
* ```
|
|
756
1021
|
*/
|
|
757
|
-
rowCommit =
|
|
1022
|
+
rowCommit = S();
|
|
758
1023
|
ngOnInit() {
|
|
759
|
-
this.adapter = new
|
|
1024
|
+
this.adapter = new lt(this.injector, this.appRef, this.viewContainerRef), et.registerAdapter(this.adapter);
|
|
760
1025
|
const e = this.elementRef.nativeElement;
|
|
761
1026
|
this.cellCommitListener = (t) => {
|
|
762
|
-
const
|
|
763
|
-
this.cellCommit.emit(
|
|
1027
|
+
const i = t.detail;
|
|
1028
|
+
this.cellCommit.emit(i);
|
|
764
1029
|
}, e.addEventListener("cell-commit", this.cellCommitListener), this.rowCommitListener = (t) => {
|
|
765
|
-
const
|
|
766
|
-
this.rowCommit.emit(
|
|
1030
|
+
const i = t.detail;
|
|
1031
|
+
this.rowCommit.emit(i);
|
|
767
1032
|
}, e.addEventListener("row-commit", this.rowCommitListener), e.__frameworkAdapter = this.adapter;
|
|
768
1033
|
}
|
|
769
1034
|
ngAfterContentInit() {
|
|
@@ -789,26 +1054,26 @@ class G {
|
|
|
789
1054
|
*/
|
|
790
1055
|
configureMasterDetail(e) {
|
|
791
1056
|
if (!this.adapter) return;
|
|
792
|
-
const t = e.getPlugin?.(
|
|
1057
|
+
const t = e.getPlugin?.(ge);
|
|
793
1058
|
if (t && typeof t.refreshDetailRenderer == "function") {
|
|
794
1059
|
t.refreshDetailRenderer();
|
|
795
1060
|
return;
|
|
796
1061
|
}
|
|
797
|
-
const
|
|
798
|
-
if (!r) return;
|
|
799
|
-
const i = this.adapter.createDetailRenderer(e);
|
|
1062
|
+
const i = e.querySelector("tbw-grid-detail");
|
|
800
1063
|
if (!i) return;
|
|
801
|
-
const
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
1064
|
+
const r = this.adapter.createDetailRenderer(e);
|
|
1065
|
+
if (!r) return;
|
|
1066
|
+
const o = i.getAttribute("animation");
|
|
1067
|
+
let s = "slide";
|
|
1068
|
+
o === "false" ? s = !1 : o === "fade" && (s = "fade");
|
|
1069
|
+
const l = i.getAttribute("showExpandColumn") !== "false", m = new ge({
|
|
1070
|
+
detailRenderer: r,
|
|
806
1071
|
showExpandColumn: l,
|
|
807
|
-
animation:
|
|
808
|
-
}),
|
|
1072
|
+
animation: s
|
|
1073
|
+
}), d = e.gridConfig || {}, T = d.plugins || [];
|
|
809
1074
|
e.gridConfig = {
|
|
810
|
-
...
|
|
811
|
-
plugins: [...
|
|
1075
|
+
...d,
|
|
1076
|
+
plugins: [...T, m]
|
|
812
1077
|
};
|
|
813
1078
|
}
|
|
814
1079
|
/**
|
|
@@ -818,11 +1083,11 @@ class G {
|
|
|
818
1083
|
*/
|
|
819
1084
|
configureResponsiveCard(e) {
|
|
820
1085
|
if (!this.adapter || !e.querySelector("tbw-grid-responsive-card")) return;
|
|
821
|
-
const
|
|
822
|
-
if (!
|
|
823
|
-
const
|
|
824
|
-
if (
|
|
825
|
-
|
|
1086
|
+
const i = this.adapter.createResponsiveCardRenderer(e);
|
|
1087
|
+
if (!i) return;
|
|
1088
|
+
const r = e.getPlugin?.(tt);
|
|
1089
|
+
if (r) {
|
|
1090
|
+
r.setCardRenderer(i);
|
|
826
1091
|
return;
|
|
827
1092
|
}
|
|
828
1093
|
console.warn(
|
|
@@ -840,21 +1105,24 @@ Add ResponsivePlugin to your gridConfig.plugins array:
|
|
|
840
1105
|
e && (this.cellCommitListener && (e.removeEventListener("cell-commit", this.cellCommitListener), this.cellCommitListener = null), this.rowCommitListener && (e.removeEventListener("row-commit", this.rowCommitListener), this.rowCommitListener = null)), e && this.customStyles() && e.unregisterStyles?.("angular-custom-styles"), this.adapter && (this.adapter.destroy?.(), this.adapter = null);
|
|
841
1106
|
}
|
|
842
1107
|
}
|
|
843
|
-
|
|
1108
|
+
ne = h(null), Y = v(ne, 0, "Grid", Me, Y), g(ne, 1, Y);
|
|
844
1109
|
export {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
V as
|
|
1110
|
+
lt as AngularGridAdapter,
|
|
1111
|
+
H as BaseGridEditor,
|
|
1112
|
+
_e as GRID_TYPE_DEFAULTS,
|
|
1113
|
+
Y as Grid,
|
|
1114
|
+
V as GridColumnEditor,
|
|
1115
|
+
N as GridColumnView,
|
|
850
1116
|
_ as GridDetailView,
|
|
851
|
-
|
|
852
|
-
q as
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
1117
|
+
G as GridFormArray,
|
|
1118
|
+
q as GridResponsiveCard,
|
|
1119
|
+
$ as GridToolPanel,
|
|
1120
|
+
M as GridTypeRegistry,
|
|
1121
|
+
W as TbwCellEditor,
|
|
1122
|
+
U as TbwCellView,
|
|
1123
|
+
W as TbwEditor,
|
|
1124
|
+
U as TbwRenderer,
|
|
1125
|
+
rt as getFormArrayContext,
|
|
1126
|
+
ve as isComponentClass,
|
|
1127
|
+
ft as provideGridTypeDefaults
|
|
860
1128
|
};
|