@toolbox-web/grid-angular 0.1.3 → 0.3.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 +185 -2
- package/index.d.ts +4 -0
- package/index.d.ts.map +1 -1
- package/index.js +473 -197
- package/lib/angular-column-config.d.ts +140 -0
- package/lib/angular-column-config.d.ts.map +1 -0
- package/lib/angular-grid-adapter.d.ts +89 -2
- package/lib/angular-grid-adapter.d.ts.map +1 -1
- package/lib/directives/grid.directive.d.ts +41 -3
- package/lib/directives/grid.directive.d.ts.map +1 -1
- package/lib/grid-type-registry.d.ts +110 -0
- package/lib/grid-type-registry.d.ts.map +1 -0
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,46 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
throw TypeError(
|
|
1
|
+
var Se = Object.create;
|
|
2
|
+
var P = Object.defineProperty;
|
|
3
|
+
var Ie = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var ne = (n, e) => (e = Symbol[n]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + n), D = (n) => {
|
|
5
|
+
throw TypeError(n);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var h = (
|
|
10
|
-
for (var r = 0, s =
|
|
11
|
-
return
|
|
12
|
-
}, w = (
|
|
13
|
-
var
|
|
14
|
-
return
|
|
7
|
+
var je = (n, e, t) => e in n ? P(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
8
|
+
var Z = (n, e) => P(n, "name", { value: e, configurable: !0 });
|
|
9
|
+
var h = (n) => [, , , Se(n?.[ne("metadata")] ?? null)], ie = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], A = (n) => n !== void 0 && typeof n != "function" ? D("Function expected") : n, Oe = (n, e, t, i, r) => ({ kind: ie[n], name: e, metadata: i, addInitializer: (s) => t._ ? D("Already initialized") : r.push(A(s || null)) }), Pe = (n, e) => je(e, ne("metadata"), n[3]), g = (n, e, t, i) => {
|
|
10
|
+
for (var r = 0, s = n[e >> 1], a = s && s.length; r < a; r++) e & 1 ? s[r].call(t) : i = s[r].call(t, i);
|
|
11
|
+
return i;
|
|
12
|
+
}, w = (n, e, t, i, r, s) => {
|
|
13
|
+
var a, l, y, u, d, o = e & 7, T = !!(e & 8), f = !!(e & 16), I = o > 3 ? n.length + 1 : o ? T ? 1 : 2 : 0, Q = ie[o + 5], X = o > 3 && (n[I - 1] = []), Le = n[I] || (n[I] = []), p = o && (!f && !T && (r = r.prototype), o < 5 && (o > 3 || !f) && Ie(o < 4 ? r : { get [t]() {
|
|
14
|
+
return ee(this, s);
|
|
15
15
|
}, set [t](c) {
|
|
16
|
-
return
|
|
16
|
+
return te(this, s, c);
|
|
17
17
|
} }, t));
|
|
18
|
-
o ?
|
|
19
|
-
for (var
|
|
20
|
-
|
|
21
|
-
return o ||
|
|
18
|
+
o ? f && o < 4 && Z(s, (o > 2 ? "set " : o > 1 ? "get " : "") + t) : Z(r, t);
|
|
19
|
+
for (var j = i.length - 1; j >= 0; j--)
|
|
20
|
+
u = Oe(o, t, y = {}, n[3], Le), o && (u.static = T, u.private = f, d = u.access = { has: f ? (c) => Ne(r, c) : (c) => t in c }, o ^ 3 && (d.get = f ? (c) => (o ^ 1 ? ee : Me)(c, r, o ^ 4 ? s : p.get) : (c) => c[t]), o > 2 && (d.set = f ? (c, O) => te(c, r, O, o ^ 4 ? s : p.set) : (c, O) => c[t] = O)), l = (0, i[j])(o ? o < 4 ? f ? s : p[Q] : o > 4 ? void 0 : { get: p.get, set: p.set } : r, u), y._ = 1, o ^ 4 || l === void 0 ? A(l) && (o > 4 ? X.unshift(l) : o ? f ? s = l : p[Q] = l : r = l) : typeof l != "object" || l === null ? D("Object expected") : (A(a = l.get) && (p.get = a), A(a = l.set) && (p.set = a), A(a = l.init) && X.unshift(a));
|
|
21
|
+
return o || Pe(n, r), p && P(r, t, p), f ? o ^ 4 ? s : p : r;
|
|
22
22
|
};
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
import { inject as
|
|
26
|
-
import { DataGridElement as
|
|
27
|
-
import { MasterDetailPlugin as
|
|
28
|
-
|
|
29
|
-
function
|
|
30
|
-
|
|
23
|
+
var N = (n, e, t) => e.has(n) || D("Cannot " + t), Ne = (n, e) => Object(e) !== e ? D('Cannot use the "in" operator on this value') : n.has(e), ee = (n, e, t) => (N(n, e, "read from private field"), t ? t.call(n) : e.get(n));
|
|
24
|
+
var te = (n, e, t, i) => (N(n, e, "write to private field"), i ? i.call(n, t) : e.set(n, t), t), Me = (n, e, t) => (N(n, e, "access private method"), t);
|
|
25
|
+
import { inject as m, ElementRef as v, contentChild as S, TemplateRef as b, effect as C, Directive as E, input as R, InjectionToken as Ve, Injectable as _e, makeEnvironmentProviders as qe, EventEmitter as re, createComponent as se, EnvironmentInjector as Ge, ApplicationRef as ke, ViewContainerRef as xe, output as oe } from "@angular/core";
|
|
26
|
+
import { DataGridElement as Ue } from "@toolbox-web/grid";
|
|
27
|
+
import { MasterDetailPlugin as ae } from "@toolbox-web/grid/all";
|
|
28
|
+
function le(n) {
|
|
29
|
+
if (typeof n != "function" || n.prototype === void 0)
|
|
30
|
+
return !1;
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(n, "ɵcmp") || Object.prototype.hasOwnProperty.call(n, "ɵfac"))
|
|
32
|
+
return !0;
|
|
33
|
+
const e = Function.prototype.toString.call(n);
|
|
34
|
+
return e.startsWith("class ") || e.startsWith("class{");
|
|
35
|
+
}
|
|
36
|
+
const Ce = /* @__PURE__ */ new Map();
|
|
37
|
+
function Ee(n) {
|
|
38
|
+
return Ce.get(n);
|
|
31
39
|
}
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
class
|
|
35
|
-
elementRef =
|
|
40
|
+
var de, U;
|
|
41
|
+
de = [E({ selector: "tbw-grid-column-editor" })];
|
|
42
|
+
class M {
|
|
43
|
+
elementRef = m(v);
|
|
36
44
|
/**
|
|
37
45
|
* Query for the ng-template content child.
|
|
38
46
|
*/
|
|
39
|
-
template =
|
|
47
|
+
template = S(b);
|
|
40
48
|
/** Effect that triggers when the template is available */
|
|
41
|
-
onTemplateReceived =
|
|
49
|
+
onTemplateReceived = C(() => {
|
|
42
50
|
const e = this.template();
|
|
43
|
-
e &&
|
|
51
|
+
e && Ce.set(this.elementRef.nativeElement, e);
|
|
44
52
|
});
|
|
45
53
|
/**
|
|
46
54
|
* Static type guard for template context.
|
|
@@ -50,23 +58,23 @@ class O {
|
|
|
50
58
|
return !0;
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
function
|
|
56
|
-
return
|
|
61
|
+
U = h(null), M = w(U, 0, "GridColumnEditor", de, M), g(U, 1, M);
|
|
62
|
+
const ye = /* @__PURE__ */ new Map();
|
|
63
|
+
function be(n) {
|
|
64
|
+
return ye.get(n);
|
|
57
65
|
}
|
|
58
|
-
var
|
|
59
|
-
|
|
66
|
+
var pe, $;
|
|
67
|
+
pe = [E({ selector: "tbw-grid-column-view" })];
|
|
60
68
|
class V {
|
|
61
|
-
elementRef =
|
|
69
|
+
elementRef = m(v);
|
|
62
70
|
/**
|
|
63
71
|
* Query for the ng-template content child.
|
|
64
72
|
*/
|
|
65
|
-
template =
|
|
73
|
+
template = S(b);
|
|
66
74
|
/** Effect that triggers when the template is available */
|
|
67
|
-
onTemplateReceived =
|
|
75
|
+
onTemplateReceived = C(() => {
|
|
68
76
|
const e = this.template();
|
|
69
|
-
e &&
|
|
77
|
+
e && ye.set(this.elementRef.nativeElement, e);
|
|
70
78
|
});
|
|
71
79
|
/**
|
|
72
80
|
* Static type guard for template context.
|
|
@@ -76,29 +84,29 @@ class V {
|
|
|
76
84
|
return !0;
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
function
|
|
82
|
-
const e =
|
|
87
|
+
$ = h(null), V = w($, 0, "GridColumnView", pe, V), g($, 1, V);
|
|
88
|
+
const Te = /* @__PURE__ */ new Map();
|
|
89
|
+
function ce(n) {
|
|
90
|
+
const e = n.querySelector("tbw-grid-detail");
|
|
83
91
|
if (e)
|
|
84
|
-
return
|
|
92
|
+
return Te.get(e);
|
|
85
93
|
}
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
class
|
|
89
|
-
elementRef =
|
|
94
|
+
var fe, W;
|
|
95
|
+
fe = [E({ selector: "tbw-grid-detail" })];
|
|
96
|
+
class _ {
|
|
97
|
+
elementRef = m(v);
|
|
90
98
|
/** Whether to show the expand/collapse column. Default: true */
|
|
91
|
-
showExpandColumn =
|
|
99
|
+
showExpandColumn = R(!0);
|
|
92
100
|
/** Animation style for expand/collapse. Default: 'slide' */
|
|
93
|
-
animation =
|
|
101
|
+
animation = R("slide");
|
|
94
102
|
/**
|
|
95
103
|
* Query for the ng-template content child.
|
|
96
104
|
*/
|
|
97
|
-
template =
|
|
105
|
+
template = S(b);
|
|
98
106
|
/** Effect that triggers when the template is available */
|
|
99
|
-
onTemplateReceived =
|
|
107
|
+
onTemplateReceived = C(() => {
|
|
100
108
|
const e = this.template();
|
|
101
|
-
e &&
|
|
109
|
+
e && Te.set(this.elementRef.nativeElement, e);
|
|
102
110
|
});
|
|
103
111
|
/**
|
|
104
112
|
* Static type guard for template context.
|
|
@@ -108,38 +116,38 @@ class q {
|
|
|
108
116
|
return !0;
|
|
109
117
|
}
|
|
110
118
|
}
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
function
|
|
114
|
-
return
|
|
119
|
+
W = h(null), _ = w(W, 0, "GridDetailView", fe, _), g(W, 1, _);
|
|
120
|
+
const Ae = /* @__PURE__ */ new Map();
|
|
121
|
+
function $e(n) {
|
|
122
|
+
return Ae.get(n);
|
|
115
123
|
}
|
|
116
|
-
var
|
|
117
|
-
|
|
118
|
-
class
|
|
119
|
-
elementRef =
|
|
124
|
+
var he, F;
|
|
125
|
+
he = [E({ selector: "tbw-grid-tool-panel" })];
|
|
126
|
+
class q {
|
|
127
|
+
elementRef = m(v);
|
|
120
128
|
/** Unique panel identifier (required) */
|
|
121
|
-
id =
|
|
129
|
+
id = R.required({ alias: "id" });
|
|
122
130
|
/** Panel title shown in accordion header (required) */
|
|
123
|
-
title =
|
|
131
|
+
title = R.required({ alias: "title" });
|
|
124
132
|
/** Icon for accordion section header (emoji or text) */
|
|
125
|
-
icon =
|
|
133
|
+
icon = R();
|
|
126
134
|
/** Tooltip for accordion section header */
|
|
127
|
-
tooltip =
|
|
135
|
+
tooltip = R();
|
|
128
136
|
/** Panel order priority (lower = first, default: 100) */
|
|
129
|
-
order =
|
|
137
|
+
order = R(100);
|
|
130
138
|
/**
|
|
131
139
|
* Query for the ng-template content child.
|
|
132
140
|
*/
|
|
133
|
-
template =
|
|
141
|
+
template = S(b);
|
|
134
142
|
/** Effect that triggers when the template is available */
|
|
135
|
-
onTemplateReceived =
|
|
143
|
+
onTemplateReceived = C(() => {
|
|
136
144
|
const e = this.template(), t = this.elementRef.nativeElement;
|
|
137
145
|
if (e) {
|
|
138
146
|
t.setAttribute("id", this.id()), t.setAttribute("title", this.title());
|
|
139
|
-
const
|
|
140
|
-
|
|
147
|
+
const i = this.icon();
|
|
148
|
+
i && t.setAttribute("icon", i);
|
|
141
149
|
const r = this.tooltip();
|
|
142
|
-
r && t.setAttribute("tooltip", r), t.setAttribute("order", String(this.order())),
|
|
150
|
+
r && t.setAttribute("tooltip", r), t.setAttribute("order", String(this.order())), Ae.set(t, e);
|
|
143
151
|
}
|
|
144
152
|
});
|
|
145
153
|
/**
|
|
@@ -150,30 +158,30 @@ class I {
|
|
|
150
158
|
return !0;
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
function
|
|
156
|
-
const e =
|
|
161
|
+
F = h(null), q = w(F, 0, "GridToolPanel", he, q), g(F, 1, q);
|
|
162
|
+
const J = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map();
|
|
163
|
+
function We(n) {
|
|
164
|
+
const e = J.get(n);
|
|
157
165
|
if (e) return e;
|
|
158
|
-
const t =
|
|
166
|
+
const t = n.querySelector("tbw-grid-column-view");
|
|
159
167
|
if (t)
|
|
160
|
-
return
|
|
168
|
+
return be(t);
|
|
161
169
|
}
|
|
162
|
-
function
|
|
163
|
-
const e =
|
|
170
|
+
function Fe(n) {
|
|
171
|
+
const e = K.get(n);
|
|
164
172
|
if (e) return e;
|
|
165
|
-
const t =
|
|
173
|
+
const t = n.querySelector("tbw-grid-column-editor");
|
|
166
174
|
if (t)
|
|
167
|
-
return
|
|
175
|
+
return Ee(t);
|
|
168
176
|
}
|
|
169
|
-
var
|
|
170
|
-
|
|
171
|
-
class
|
|
172
|
-
template =
|
|
173
|
-
elementRef =
|
|
177
|
+
var ge, H;
|
|
178
|
+
ge = [E({ selector: "[tbwRenderer]" })];
|
|
179
|
+
class G {
|
|
180
|
+
template = m(b);
|
|
181
|
+
elementRef = m(v);
|
|
174
182
|
columnElement = null;
|
|
175
183
|
constructor() {
|
|
176
|
-
|
|
184
|
+
C(() => {
|
|
177
185
|
this.registerTemplate();
|
|
178
186
|
});
|
|
179
187
|
}
|
|
@@ -181,10 +189,10 @@ class P {
|
|
|
181
189
|
let e = this.elementRef.nativeElement?.parentElement;
|
|
182
190
|
for (; e && e.tagName !== "TBW-GRID-COLUMN"; )
|
|
183
191
|
e = e.parentElement;
|
|
184
|
-
e && (this.columnElement = e,
|
|
192
|
+
e && (this.columnElement = e, J.set(e, this.template));
|
|
185
193
|
}
|
|
186
194
|
ngOnDestroy() {
|
|
187
|
-
this.columnElement &&
|
|
195
|
+
this.columnElement && J.delete(this.columnElement);
|
|
188
196
|
}
|
|
189
197
|
/**
|
|
190
198
|
* Static type guard for template context.
|
|
@@ -194,15 +202,15 @@ class P {
|
|
|
194
202
|
return !0;
|
|
195
203
|
}
|
|
196
204
|
}
|
|
197
|
-
|
|
198
|
-
var
|
|
199
|
-
|
|
200
|
-
class
|
|
201
|
-
template =
|
|
202
|
-
elementRef =
|
|
205
|
+
H = h(null), G = w(H, 0, "TbwRenderer", ge, G), g(H, 1, G);
|
|
206
|
+
var we, B;
|
|
207
|
+
we = [E({ selector: "[tbwEditor]" })];
|
|
208
|
+
class k {
|
|
209
|
+
template = m(b);
|
|
210
|
+
elementRef = m(v);
|
|
203
211
|
columnElement = null;
|
|
204
212
|
constructor() {
|
|
205
|
-
|
|
213
|
+
C(() => {
|
|
206
214
|
this.registerTemplate();
|
|
207
215
|
});
|
|
208
216
|
}
|
|
@@ -210,10 +218,10 @@ class j {
|
|
|
210
218
|
let e = this.elementRef.nativeElement?.parentElement;
|
|
211
219
|
for (; e && e.tagName !== "TBW-GRID-COLUMN"; )
|
|
212
220
|
e = e.parentElement;
|
|
213
|
-
e && (this.columnElement = e,
|
|
221
|
+
e && (this.columnElement = e, K.set(e, this.template));
|
|
214
222
|
}
|
|
215
223
|
ngOnDestroy() {
|
|
216
|
-
this.columnElement &&
|
|
224
|
+
this.columnElement && K.delete(this.columnElement);
|
|
217
225
|
}
|
|
218
226
|
/**
|
|
219
227
|
* Static type guard for template context.
|
|
@@ -223,26 +231,142 @@ class j {
|
|
|
223
231
|
return !0;
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
B = h(null), k = w(B, 0, "TbwEditor", we, k), g(B, 1, k);
|
|
235
|
+
const De = new Ve("GRID_TYPE_DEFAULTS");
|
|
236
|
+
var Re, Y;
|
|
237
|
+
Re = [_e({ providedIn: "root" })];
|
|
238
|
+
class L {
|
|
239
|
+
defaults = /* @__PURE__ */ new Map();
|
|
240
|
+
constructor() {
|
|
241
|
+
const e = m(De, { optional: !0 });
|
|
242
|
+
if (e)
|
|
243
|
+
for (const [t, i] of Object.entries(e))
|
|
244
|
+
this.defaults.set(t, i);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Register type-level defaults for a custom type.
|
|
248
|
+
*
|
|
249
|
+
* @param type - The type name (e.g., 'country', 'currency')
|
|
250
|
+
* @param defaults - Renderer/editor configuration
|
|
251
|
+
*/
|
|
252
|
+
register(e, t) {
|
|
253
|
+
this.defaults.set(e, t);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get type defaults for a given type.
|
|
257
|
+
*/
|
|
258
|
+
get(e) {
|
|
259
|
+
return this.defaults.get(e);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Remove type defaults for a type.
|
|
263
|
+
*/
|
|
264
|
+
unregister(e) {
|
|
265
|
+
this.defaults.delete(e);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Check if a type has registered defaults.
|
|
269
|
+
*/
|
|
270
|
+
has(e) {
|
|
271
|
+
return this.defaults.has(e);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Get all registered type names.
|
|
275
|
+
*/
|
|
276
|
+
getRegisteredTypes() {
|
|
277
|
+
return Array.from(this.defaults.keys());
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Convert to TypeDefault for use with grid's typeDefaults.
|
|
281
|
+
* This is used internally by the adapter.
|
|
282
|
+
*
|
|
283
|
+
* @internal
|
|
284
|
+
*/
|
|
285
|
+
getAsTypeDefault(e) {
|
|
286
|
+
const t = this.defaults.get(e);
|
|
287
|
+
if (t)
|
|
288
|
+
return {
|
|
289
|
+
editorParams: t.editorParams
|
|
290
|
+
// renderer and editor are handled by the adapter which creates
|
|
291
|
+
// the actual functions that instantiate Angular components
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
Y = h(null), L = w(Y, 0, "GridTypeRegistry", Re, L), g(Y, 1, L);
|
|
296
|
+
function Ke(n) {
|
|
297
|
+
return qe([{ provide: De, useValue: n }]);
|
|
230
298
|
}
|
|
231
|
-
function
|
|
232
|
-
const e =
|
|
233
|
-
return e ||
|
|
299
|
+
function me(n) {
|
|
300
|
+
const e = We(n);
|
|
301
|
+
return e || be(n);
|
|
234
302
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
303
|
+
function ue(n) {
|
|
304
|
+
const e = Fe(n);
|
|
305
|
+
return e || Ee(n);
|
|
306
|
+
}
|
|
307
|
+
class He {
|
|
308
|
+
constructor(e, t, i) {
|
|
309
|
+
this.injector = e, this.appRef = t, this.viewContainerRef = i, window.__ANGULAR_GRID_ADAPTER__ = this;
|
|
310
|
+
try {
|
|
311
|
+
this.typeRegistry = this.injector.get(L, null);
|
|
312
|
+
} catch {
|
|
313
|
+
}
|
|
238
314
|
}
|
|
239
315
|
viewRefs = [];
|
|
316
|
+
componentRefs = [];
|
|
317
|
+
typeRegistry = null;
|
|
318
|
+
/**
|
|
319
|
+
* Processes an Angular grid configuration, converting component class references
|
|
320
|
+
* to actual renderer/editor functions.
|
|
321
|
+
*
|
|
322
|
+
* Call this method on your gridConfig before passing it to the grid.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* import { AngularGridAdapter, type AngularGridConfig } from '@toolbox-web/grid-angular';
|
|
327
|
+
*
|
|
328
|
+
* const config: AngularGridConfig<Employee> = {
|
|
329
|
+
* columns: [
|
|
330
|
+
* { field: 'status', renderer: StatusBadgeComponent, editor: StatusEditorComponent },
|
|
331
|
+
* ],
|
|
332
|
+
* };
|
|
333
|
+
*
|
|
334
|
+
* // In component
|
|
335
|
+
* constructor() {
|
|
336
|
+
* const adapter = inject(AngularGridAdapter); // or create new instance
|
|
337
|
+
* this.processedConfig = adapter.processGridConfig(config);
|
|
338
|
+
* }
|
|
339
|
+
* ```
|
|
340
|
+
*
|
|
341
|
+
* @param config - Angular grid configuration with possible component class references
|
|
342
|
+
* @returns Processed GridConfig with actual renderer/editor functions
|
|
343
|
+
*/
|
|
344
|
+
processGridConfig(e) {
|
|
345
|
+
if (!e.columns)
|
|
346
|
+
return e;
|
|
347
|
+
const t = e.columns.map((i) => this.processColumn(i));
|
|
348
|
+
return {
|
|
349
|
+
...e,
|
|
350
|
+
columns: t
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Processes a single column configuration, converting component class references
|
|
355
|
+
* to actual renderer/editor functions.
|
|
356
|
+
*
|
|
357
|
+
* @param column - Angular column configuration
|
|
358
|
+
* @returns Processed ColumnConfig
|
|
359
|
+
*/
|
|
360
|
+
processColumn(e) {
|
|
361
|
+
const t = { ...e };
|
|
362
|
+
return e.renderer && le(e.renderer) && (t.renderer = this.createComponentRenderer(e.renderer)), e.editor && le(e.editor) && (t.editor = this.createComponentEditor(e.editor)), t;
|
|
363
|
+
}
|
|
240
364
|
/**
|
|
241
365
|
* Determines if this adapter can handle the given element.
|
|
242
366
|
* Checks if a template is registered for this element (structural or nested).
|
|
243
367
|
*/
|
|
244
368
|
canHandle(e) {
|
|
245
|
-
return
|
|
369
|
+
return me(e) !== void 0 || ue(e) !== void 0;
|
|
246
370
|
}
|
|
247
371
|
/**
|
|
248
372
|
* Creates a view renderer function that creates an embedded view
|
|
@@ -252,14 +376,14 @@ class Ie {
|
|
|
252
376
|
* allowing the grid to use its default rendering.
|
|
253
377
|
*/
|
|
254
378
|
createRenderer(e) {
|
|
255
|
-
const t =
|
|
379
|
+
const t = me(e);
|
|
256
380
|
if (t)
|
|
257
|
-
return (
|
|
381
|
+
return (i) => {
|
|
258
382
|
const r = {
|
|
259
|
-
$implicit:
|
|
260
|
-
value:
|
|
261
|
-
row:
|
|
262
|
-
column:
|
|
383
|
+
$implicit: i.value,
|
|
384
|
+
value: i.value,
|
|
385
|
+
row: i.row,
|
|
386
|
+
column: i.column
|
|
263
387
|
}, s = this.viewContainerRef.createEmbeddedView(t, r);
|
|
264
388
|
return this.viewRefs.push(s), s.detectChanges(), s.rootNodes[0];
|
|
265
389
|
};
|
|
@@ -283,29 +407,29 @@ class Ie {
|
|
|
283
407
|
* As long as the component emits `(commit)` with the new value.
|
|
284
408
|
*/
|
|
285
409
|
createEditor(e) {
|
|
286
|
-
const t =
|
|
287
|
-
return t ? (
|
|
288
|
-
const r = (o) =>
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
$implicit:
|
|
292
|
-
value:
|
|
293
|
-
row:
|
|
294
|
-
column:
|
|
410
|
+
const t = ue(e);
|
|
411
|
+
return t ? (i) => {
|
|
412
|
+
const r = (o) => i.commit(o), s = () => i.cancel(), a = new re(), l = new re();
|
|
413
|
+
a.subscribe((o) => i.commit(o)), l.subscribe(() => i.cancel());
|
|
414
|
+
const y = {
|
|
415
|
+
$implicit: i.value,
|
|
416
|
+
value: i.value,
|
|
417
|
+
row: i.row,
|
|
418
|
+
column: i.column,
|
|
295
419
|
// Preferred: simple callback functions
|
|
296
420
|
onCommit: r,
|
|
297
421
|
onCancel: s,
|
|
298
422
|
// Deprecated: EventEmitters (for backwards compatibility)
|
|
299
|
-
commit:
|
|
300
|
-
cancel:
|
|
301
|
-
},
|
|
302
|
-
this.viewRefs.push(
|
|
303
|
-
const d =
|
|
423
|
+
commit: a,
|
|
424
|
+
cancel: l
|
|
425
|
+
}, u = this.viewContainerRef.createEmbeddedView(t, y);
|
|
426
|
+
this.viewRefs.push(u), u.detectChanges();
|
|
427
|
+
const d = u.rootNodes[0];
|
|
304
428
|
return d && d.addEventListener && (d.addEventListener("commit", (o) => {
|
|
305
|
-
const
|
|
306
|
-
|
|
429
|
+
const T = o;
|
|
430
|
+
i.commit(T.detail);
|
|
307
431
|
}), d.addEventListener("cancel", () => {
|
|
308
|
-
|
|
432
|
+
i.cancel();
|
|
309
433
|
})), d;
|
|
310
434
|
} : (console.warn("[AngularGridAdapter] No editor template registered for element"), () => document.createElement("div"));
|
|
311
435
|
}
|
|
@@ -314,16 +438,16 @@ class Ie {
|
|
|
314
438
|
* Renders Angular templates for expandable detail rows.
|
|
315
439
|
*/
|
|
316
440
|
createDetailRenderer(e) {
|
|
317
|
-
const t =
|
|
441
|
+
const t = ce(e);
|
|
318
442
|
if (t)
|
|
319
|
-
return (
|
|
443
|
+
return (i) => {
|
|
320
444
|
const r = {
|
|
321
|
-
$implicit:
|
|
322
|
-
row:
|
|
445
|
+
$implicit: i,
|
|
446
|
+
row: i
|
|
323
447
|
}, s = this.viewContainerRef.createEmbeddedView(t, r);
|
|
324
448
|
this.viewRefs.push(s), s.detectChanges();
|
|
325
|
-
const
|
|
326
|
-
return s.rootNodes.forEach((
|
|
449
|
+
const a = document.createElement("div");
|
|
450
|
+
return s.rootNodes.forEach((l) => a.appendChild(l)), a;
|
|
327
451
|
};
|
|
328
452
|
}
|
|
329
453
|
/**
|
|
@@ -334,16 +458,16 @@ class Ie {
|
|
|
334
458
|
* without manual configuration in the Grid directive.
|
|
335
459
|
*/
|
|
336
460
|
parseDetailElement(e) {
|
|
337
|
-
const t =
|
|
461
|
+
const t = ce(e.closest("tbw-grid"));
|
|
338
462
|
if (t)
|
|
339
|
-
return (
|
|
463
|
+
return (i) => {
|
|
340
464
|
const r = {
|
|
341
|
-
$implicit:
|
|
342
|
-
row:
|
|
465
|
+
$implicit: i,
|
|
466
|
+
row: i
|
|
343
467
|
}, s = this.viewContainerRef.createEmbeddedView(t, r);
|
|
344
468
|
this.viewRefs.push(s), s.detectChanges();
|
|
345
|
-
const
|
|
346
|
-
return s.rootNodes.forEach((
|
|
469
|
+
const a = document.createElement("div");
|
|
470
|
+
return s.rootNodes.forEach((l) => a.appendChild(l)), a;
|
|
347
471
|
};
|
|
348
472
|
}
|
|
349
473
|
/**
|
|
@@ -351,41 +475,152 @@ class Ie {
|
|
|
351
475
|
* The renderer creates an Angular template-based panel content.
|
|
352
476
|
*/
|
|
353
477
|
createToolPanelRenderer(e) {
|
|
354
|
-
const t =
|
|
478
|
+
const t = $e(e);
|
|
355
479
|
if (!t)
|
|
356
480
|
return;
|
|
357
|
-
const
|
|
481
|
+
const i = e.closest("tbw-grid");
|
|
358
482
|
return (r) => {
|
|
359
483
|
const s = {
|
|
360
|
-
$implicit:
|
|
361
|
-
grid:
|
|
362
|
-
},
|
|
363
|
-
return this.viewRefs.push(
|
|
364
|
-
const
|
|
365
|
-
|
|
484
|
+
$implicit: i ?? r,
|
|
485
|
+
grid: i ?? r
|
|
486
|
+
}, a = this.viewContainerRef.createEmbeddedView(t, s);
|
|
487
|
+
return this.viewRefs.push(a), a.detectChanges(), a.rootNodes.forEach((l) => r.appendChild(l)), () => {
|
|
488
|
+
const l = this.viewRefs.indexOf(a);
|
|
489
|
+
l > -1 && this.viewRefs.splice(l, 1), a.destroy();
|
|
366
490
|
};
|
|
367
491
|
};
|
|
368
492
|
}
|
|
369
493
|
/**
|
|
370
|
-
*
|
|
494
|
+
* Gets type-level defaults from the application's GridTypeRegistry.
|
|
495
|
+
*
|
|
496
|
+
* This enables application-wide type defaults configured via `provideGridTypeDefaults()`.
|
|
497
|
+
* The returned TypeDefault contains renderer/editor functions that instantiate
|
|
498
|
+
* Angular components dynamically.
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```typescript
|
|
502
|
+
* // app.config.ts
|
|
503
|
+
* export const appConfig: ApplicationConfig = {
|
|
504
|
+
* providers: [
|
|
505
|
+
* provideGridTypeDefaults({
|
|
506
|
+
* country: {
|
|
507
|
+
* renderer: CountryCellComponent,
|
|
508
|
+
* editor: CountryEditorComponent
|
|
509
|
+
* }
|
|
510
|
+
* })
|
|
511
|
+
* ]
|
|
512
|
+
* };
|
|
513
|
+
*
|
|
514
|
+
* // Any grid with type: 'country' columns will use these components
|
|
515
|
+
* gridConfig = {
|
|
516
|
+
* columns: [{ field: 'country', type: 'country' }]
|
|
517
|
+
* };
|
|
518
|
+
* ```
|
|
519
|
+
*/
|
|
520
|
+
getTypeDefault(e) {
|
|
521
|
+
if (!this.typeRegistry)
|
|
522
|
+
return;
|
|
523
|
+
const t = this.typeRegistry.get(e);
|
|
524
|
+
if (!t)
|
|
525
|
+
return;
|
|
526
|
+
const i = {
|
|
527
|
+
editorParams: t.editorParams
|
|
528
|
+
};
|
|
529
|
+
return t.renderer && (i.renderer = this.createComponentRenderer(t.renderer)), t.editor && (i.editor = this.createComponentEditor(t.editor)), i;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Creates a renderer function from an Angular component class.
|
|
533
|
+
* @internal
|
|
534
|
+
*/
|
|
535
|
+
createComponentRenderer(e) {
|
|
536
|
+
return (t) => {
|
|
537
|
+
const i = document.createElement("span");
|
|
538
|
+
i.style.display = "contents";
|
|
539
|
+
const r = se(e, {
|
|
540
|
+
environmentInjector: this.injector,
|
|
541
|
+
hostElement: i
|
|
542
|
+
});
|
|
543
|
+
return this.setComponentInputs(r, {
|
|
544
|
+
value: t.value,
|
|
545
|
+
row: t.row,
|
|
546
|
+
column: t.column
|
|
547
|
+
}), this.appRef.attachView(r.hostView), this.componentRefs.push(r), r.changeDetectorRef.detectChanges(), i;
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Creates an editor function from an Angular component class.
|
|
552
|
+
* @internal
|
|
553
|
+
*/
|
|
554
|
+
createComponentEditor(e) {
|
|
555
|
+
return (t) => {
|
|
556
|
+
const i = document.createElement("span");
|
|
557
|
+
i.style.display = "contents";
|
|
558
|
+
const r = se(e, {
|
|
559
|
+
environmentInjector: this.injector,
|
|
560
|
+
hostElement: i
|
|
561
|
+
});
|
|
562
|
+
this.setComponentInputs(r, {
|
|
563
|
+
value: t.value,
|
|
564
|
+
row: t.row,
|
|
565
|
+
column: t.column
|
|
566
|
+
}), this.appRef.attachView(r.hostView), this.componentRefs.push(r), r.changeDetectorRef.detectChanges();
|
|
567
|
+
const s = r.instance;
|
|
568
|
+
return this.subscribeToOutput(s, "commit", (a) => t.commit(a)), this.subscribeToOutput(s, "cancel", () => t.cancel()), i.addEventListener("commit", (a) => {
|
|
569
|
+
const l = a;
|
|
570
|
+
t.commit(l.detail);
|
|
571
|
+
}), i.addEventListener("cancel", () => {
|
|
572
|
+
t.cancel();
|
|
573
|
+
}), i;
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Subscribes to an Angular output on a component instance.
|
|
578
|
+
* Works with both EventEmitter and OutputEmitterRef (signal outputs).
|
|
579
|
+
* @internal
|
|
580
|
+
*/
|
|
581
|
+
subscribeToOutput(e, t, i) {
|
|
582
|
+
const r = e[t];
|
|
583
|
+
r && typeof r.subscribe == "function" && r.subscribe(i);
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Sets component inputs using Angular's setInput API.
|
|
587
|
+
* @internal
|
|
588
|
+
*/
|
|
589
|
+
setComponentInputs(e, t) {
|
|
590
|
+
for (const [i, r] of Object.entries(t))
|
|
591
|
+
try {
|
|
592
|
+
e.setInput(i, r);
|
|
593
|
+
} catch {
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Clean up all view references and component references.
|
|
371
598
|
* Call this when your app/component is destroyed.
|
|
372
599
|
*/
|
|
373
600
|
destroy() {
|
|
374
|
-
this.viewRefs.forEach((e) => e.destroy()), this.viewRefs = [];
|
|
601
|
+
this.viewRefs.forEach((e) => e.destroy()), this.viewRefs = [], this.componentRefs.forEach((e) => e.destroy()), this.componentRefs = [];
|
|
375
602
|
}
|
|
376
603
|
}
|
|
377
|
-
var
|
|
378
|
-
|
|
379
|
-
class
|
|
380
|
-
elementRef =
|
|
381
|
-
injector =
|
|
382
|
-
appRef =
|
|
383
|
-
viewContainerRef =
|
|
604
|
+
var ve, z;
|
|
605
|
+
ve = [E({ selector: "tbw-grid" })];
|
|
606
|
+
class x {
|
|
607
|
+
elementRef = m(v);
|
|
608
|
+
injector = m(Ge);
|
|
609
|
+
appRef = m(ke);
|
|
610
|
+
viewContainerRef = m(xe);
|
|
384
611
|
adapter = null;
|
|
385
612
|
cellCommitListener = null;
|
|
613
|
+
constructor() {
|
|
614
|
+
C(() => {
|
|
615
|
+
const e = this.angularConfig();
|
|
616
|
+
if (!e || !this.adapter) return;
|
|
617
|
+
const t = this.adapter.processGridConfig(e), i = this.elementRef.nativeElement;
|
|
618
|
+
i.gridConfig = t;
|
|
619
|
+
});
|
|
620
|
+
}
|
|
386
621
|
rowCommitListener = null;
|
|
387
622
|
/**
|
|
388
|
-
* Custom CSS styles to inject into the grid
|
|
623
|
+
* Custom CSS styles to inject into the grid.
|
|
389
624
|
* Use this to style custom cell renderers, editors, or detail panels.
|
|
390
625
|
*
|
|
391
626
|
* @example
|
|
@@ -401,7 +636,44 @@ class $ {
|
|
|
401
636
|
* <tbw-grid [customStyles]="customStyles">...</tbw-grid>
|
|
402
637
|
* ```
|
|
403
638
|
*/
|
|
404
|
-
customStyles =
|
|
639
|
+
customStyles = R();
|
|
640
|
+
/**
|
|
641
|
+
* Angular-specific grid configuration that supports component classes for renderers/editors.
|
|
642
|
+
*
|
|
643
|
+
* Use this input when you want to specify Angular component classes directly in column configs.
|
|
644
|
+
* Components must implement the appropriate interfaces:
|
|
645
|
+
* - Renderers: `AngularCellRenderer<TRow, TValue>` - requires `value()` and `row()` signal inputs
|
|
646
|
+
* - Editors: `AngularCellEditor<TRow, TValue>` - adds `commit` and `cancel` outputs
|
|
647
|
+
*
|
|
648
|
+
* The directive automatically processes component classes and converts them to grid-compatible
|
|
649
|
+
* renderer/editor functions before applying to the grid.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```typescript
|
|
653
|
+
* // Component that implements AngularCellEditor
|
|
654
|
+
* @Component({...})
|
|
655
|
+
* export class BonusEditorComponent implements AngularCellEditor<Employee, number> {
|
|
656
|
+
* value = input.required<number>();
|
|
657
|
+
* row = input.required<Employee>();
|
|
658
|
+
* commit = output<number>();
|
|
659
|
+
* cancel = output<void>();
|
|
660
|
+
* }
|
|
661
|
+
*
|
|
662
|
+
* // In your grid config
|
|
663
|
+
* config: AngularGridConfig<Employee> = {
|
|
664
|
+
* columns: [
|
|
665
|
+
* { field: 'name', header: 'Name' },
|
|
666
|
+
* { field: 'bonus', header: 'Bonus', editable: true, editor: BonusEditorComponent }
|
|
667
|
+
* ]
|
|
668
|
+
* };
|
|
669
|
+
* ```
|
|
670
|
+
*
|
|
671
|
+
* ```html
|
|
672
|
+
* <tbw-grid [angularConfig]="config" [rows]="employees"></tbw-grid>
|
|
673
|
+
* ```
|
|
674
|
+
*/
|
|
675
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
676
|
+
angularConfig = R();
|
|
405
677
|
/**
|
|
406
678
|
* Emitted when a cell value is committed (inline editing).
|
|
407
679
|
* Provides the row, field, new value, and change tracking information.
|
|
@@ -417,7 +689,7 @@ class $ {
|
|
|
417
689
|
* }
|
|
418
690
|
* ```
|
|
419
691
|
*/
|
|
420
|
-
cellCommit =
|
|
692
|
+
cellCommit = oe();
|
|
421
693
|
/**
|
|
422
694
|
* Emitted when a row's values are committed (bulk/row editing).
|
|
423
695
|
* Provides the row data and change tracking information.
|
|
@@ -427,16 +699,16 @@ class $ {
|
|
|
427
699
|
* <tbw-grid (rowCommit)="onRowCommit($event)">...</tbw-grid>
|
|
428
700
|
* ```
|
|
429
701
|
*/
|
|
430
|
-
rowCommit =
|
|
702
|
+
rowCommit = oe();
|
|
431
703
|
ngOnInit() {
|
|
432
|
-
this.adapter = new
|
|
704
|
+
this.adapter = new He(this.injector, this.appRef, this.viewContainerRef), Ue.registerAdapter(this.adapter);
|
|
433
705
|
const e = this.elementRef.nativeElement;
|
|
434
706
|
this.cellCommitListener = (t) => {
|
|
435
|
-
const
|
|
436
|
-
this.cellCommit.emit(
|
|
707
|
+
const i = t.detail;
|
|
708
|
+
this.cellCommit.emit(i);
|
|
437
709
|
}, e.addEventListener("cell-commit", this.cellCommitListener), this.rowCommitListener = (t) => {
|
|
438
|
-
const
|
|
439
|
-
this.rowCommit.emit(
|
|
710
|
+
const i = t.detail;
|
|
711
|
+
this.rowCommit.emit(i);
|
|
440
712
|
}, e.addEventListener("row-commit", this.rowCommitListener), e.__frameworkAdapter = this.adapter;
|
|
441
713
|
}
|
|
442
714
|
ngAfterContentInit() {
|
|
@@ -446,7 +718,7 @@ class $ {
|
|
|
446
718
|
}, 0);
|
|
447
719
|
}
|
|
448
720
|
/**
|
|
449
|
-
* Registers custom styles into the grid
|
|
721
|
+
* Registers custom styles into the grid.
|
|
450
722
|
* Uses the grid's registerStyles() API for clean encapsulation.
|
|
451
723
|
*/
|
|
452
724
|
registerCustomStyles(e) {
|
|
@@ -462,26 +734,26 @@ class $ {
|
|
|
462
734
|
*/
|
|
463
735
|
configureMasterDetail(e) {
|
|
464
736
|
if (!this.adapter) return;
|
|
465
|
-
const t = e.getPlugin?.(
|
|
737
|
+
const t = e.getPlugin?.(ae);
|
|
466
738
|
if (t && typeof t.refreshDetailRenderer == "function") {
|
|
467
739
|
t.refreshDetailRenderer();
|
|
468
740
|
return;
|
|
469
741
|
}
|
|
470
|
-
const
|
|
471
|
-
if (!
|
|
742
|
+
const i = e.querySelector("tbw-grid-detail");
|
|
743
|
+
if (!i) return;
|
|
472
744
|
const r = this.adapter.createDetailRenderer(e);
|
|
473
745
|
if (!r) return;
|
|
474
|
-
const s =
|
|
475
|
-
let
|
|
476
|
-
s === "false" ?
|
|
477
|
-
const
|
|
746
|
+
const s = i.getAttribute("animation");
|
|
747
|
+
let a = "slide";
|
|
748
|
+
s === "false" ? a = !1 : s === "fade" && (a = "fade");
|
|
749
|
+
const l = i.getAttribute("showExpandColumn") !== "false", y = new ae({
|
|
478
750
|
detailRenderer: r,
|
|
479
|
-
showExpandColumn:
|
|
480
|
-
animation:
|
|
481
|
-
}),
|
|
751
|
+
showExpandColumn: l,
|
|
752
|
+
animation: a
|
|
753
|
+
}), u = e.gridConfig || {}, d = u.plugins || [];
|
|
482
754
|
e.gridConfig = {
|
|
483
|
-
...
|
|
484
|
-
plugins: [...d,
|
|
755
|
+
...u,
|
|
756
|
+
plugins: [...d, y]
|
|
485
757
|
};
|
|
486
758
|
}
|
|
487
759
|
ngOnDestroy() {
|
|
@@ -489,16 +761,20 @@ class $ {
|
|
|
489
761
|
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);
|
|
490
762
|
}
|
|
491
763
|
}
|
|
492
|
-
z = h(null),
|
|
764
|
+
z = h(null), x = w(z, 0, "Grid", ve, x), g(z, 1, x);
|
|
493
765
|
export {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
766
|
+
He as AngularGridAdapter,
|
|
767
|
+
De as GRID_TYPE_DEFAULTS,
|
|
768
|
+
x as Grid,
|
|
769
|
+
M as GridColumnEditor,
|
|
497
770
|
V as GridColumnView,
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
771
|
+
_ as GridDetailView,
|
|
772
|
+
q as GridToolPanel,
|
|
773
|
+
L as GridTypeRegistry,
|
|
774
|
+
k as TbwCellEditor,
|
|
775
|
+
G as TbwCellView,
|
|
776
|
+
k as TbwEditor,
|
|
777
|
+
G as TbwRenderer,
|
|
778
|
+
le as isComponentClass,
|
|
779
|
+
Ke as provideGridTypeDefaults
|
|
504
780
|
};
|