@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/index.js CHANGED
@@ -1,46 +1,54 @@
1
- var ye = Object.create;
2
- var M = Object.defineProperty;
3
- var Te = Object.getOwnPropertyDescriptor;
4
- var ee = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), L = (i) => {
5
- throw TypeError(i);
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 be = (i, e, t) => e in i ? M(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
8
- var X = (i, e) => M(i, "name", { value: e, configurable: !0 });
9
- var h = (i) => [, , , ye(i?.[ee("metadata")] ?? null)], te = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], A = (i) => i !== void 0 && typeof i != "function" ? L("Function expected") : i, Ae = (i, e, t, n, r) => ({ kind: te[i], name: e, metadata: n, addInitializer: (s) => t._ ? L("Already initialized") : r.push(A(s || null)) }), Le = (i, e) => be(e, ee("metadata"), i[3]), g = (i, e, t, n) => {
10
- for (var r = 0, s = i[e >> 1], l = s && s.length; r < l; r++) e & 1 ? s[r].call(t) : n = s[r].call(t, n);
11
- return n;
12
- }, w = (i, e, t, n, r, s) => {
13
- var l, a, C, m, d, o = e & 7, b = !!(e & 8), p = !!(e & 16), S = o > 3 ? i.length + 1 : o ? b ? 1 : 2 : 0, K = te[o + 5], Q = o > 3 && (i[S - 1] = []), Ce = i[S] || (i[S] = []), f = o && (!p && !b && (r = r.prototype), o < 5 && (o > 3 || !p) && Te(o < 4 ? r : { get [t]() {
14
- return Y(this, s);
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 Z(this, s, c);
16
+ return te(this, s, c);
17
17
  } }, t));
18
- o ? p && o < 4 && X(s, (o > 2 ? "set " : o > 1 ? "get " : "") + t) : X(r, t);
19
- for (var N = n.length - 1; N >= 0; N--)
20
- m = Ae(o, t, C = {}, i[3], Ce), o && (m.static = b, m.private = p, d = m.access = { has: p ? (c) => De(r, c) : (c) => t in c }, o ^ 3 && (d.get = p ? (c) => (o ^ 1 ? Y : Se)(c, r, o ^ 4 ? s : f.get) : (c) => c[t]), o > 2 && (d.set = p ? (c, x) => Z(c, r, x, o ^ 4 ? s : f.set) : (c, x) => c[t] = x)), a = (0, n[N])(o ? o < 4 ? p ? s : f[K] : o > 4 ? void 0 : { get: f.get, set: f.set } : r, m), C._ = 1, o ^ 4 || a === void 0 ? A(a) && (o > 4 ? Q.unshift(a) : o ? p ? s = a : f[K] = a : r = a) : typeof a != "object" || a === null ? L("Object expected") : (A(l = a.get) && (f.get = l), A(l = a.set) && (f.set = l), A(l = a.init) && Q.unshift(l));
21
- return o || Le(i, r), f && M(r, t, f), p ? o ^ 4 ? s : f : r;
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 _ = (i, e, t) => e.has(i) || L("Cannot " + t), De = (i, e) => Object(e) !== e ? L('Cannot use the "in" operator on this value') : i.has(e), Y = (i, e, t) => (_(i, e, "read from private field"), t ? t.call(i) : e.get(i));
24
- var Z = (i, e, t, n) => (_(i, e, "write to private field"), n ? n.call(i, t) : e.set(i, t), t), Se = (i, e, t) => (_(i, e, "access private method"), t);
25
- import { inject as u, ElementRef as R, contentChild as D, TemplateRef as y, effect as T, Directive as E, input as v, EventEmitter as ie, EnvironmentInjector as Ne, ApplicationRef as xe, ViewContainerRef as Me, output as ne } from "@angular/core";
26
- import { DataGridElement as _e } from "@toolbox-web/grid";
27
- import { MasterDetailPlugin as re } from "@toolbox-web/grid/all";
28
- const he = /* @__PURE__ */ new Map();
29
- function ge(i) {
30
- return he.get(i);
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 ae, G;
33
- ae = [E({ selector: "tbw-grid-column-editor" })];
34
- class O {
35
- elementRef = u(R);
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 = D(y);
47
+ template = S(b);
40
48
  /** Effect that triggers when the template is available */
41
- onTemplateReceived = T(() => {
49
+ onTemplateReceived = C(() => {
42
50
  const e = this.template();
43
- e && he.set(this.elementRef.nativeElement, 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
- G = h(null), O = w(G, 0, "GridColumnEditor", ae, O), g(G, 1, O);
54
- const we = /* @__PURE__ */ new Map();
55
- function ve(i) {
56
- return we.get(i);
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 ce, H;
59
- ce = [E({ selector: "tbw-grid-column-view" })];
66
+ var pe, $;
67
+ pe = [E({ selector: "tbw-grid-column-view" })];
60
68
  class V {
61
- elementRef = u(R);
69
+ elementRef = m(v);
62
70
  /**
63
71
  * Query for the ng-template content child.
64
72
  */
65
- template = D(y);
73
+ template = S(b);
66
74
  /** Effect that triggers when the template is available */
67
- onTemplateReceived = T(() => {
75
+ onTemplateReceived = C(() => {
68
76
  const e = this.template();
69
- e && we.set(this.elementRef.nativeElement, 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
- H = h(null), V = w(H, 0, "GridColumnView", ce, V), g(H, 1, V);
80
- const Re = /* @__PURE__ */ new Map();
81
- function se(i) {
82
- const e = i.querySelector("tbw-grid-detail");
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 Re.get(e);
92
+ return Te.get(e);
85
93
  }
86
- var me, U;
87
- me = [E({ selector: "tbw-grid-detail" })];
88
- class q {
89
- elementRef = u(R);
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 = v(!0);
99
+ showExpandColumn = R(!0);
92
100
  /** Animation style for expand/collapse. Default: 'slide' */
93
- animation = v("slide");
101
+ animation = R("slide");
94
102
  /**
95
103
  * Query for the ng-template content child.
96
104
  */
97
- template = D(y);
105
+ template = S(b);
98
106
  /** Effect that triggers when the template is available */
99
- onTemplateReceived = T(() => {
107
+ onTemplateReceived = C(() => {
100
108
  const e = this.template();
101
- e && Re.set(this.elementRef.nativeElement, 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
- U = h(null), q = w(U, 0, "GridDetailView", me, q), g(U, 1, q);
112
- const Ee = /* @__PURE__ */ new Map();
113
- function Oe(i) {
114
- return Ee.get(i);
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 ue, B;
117
- ue = [E({ selector: "tbw-grid-tool-panel" })];
118
- class I {
119
- elementRef = u(R);
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 = v.required({ alias: "id" });
129
+ id = R.required({ alias: "id" });
122
130
  /** Panel title shown in accordion header (required) */
123
- title = v.required({ alias: "title" });
131
+ title = R.required({ alias: "title" });
124
132
  /** Icon for accordion section header (emoji or text) */
125
- icon = v();
133
+ icon = R();
126
134
  /** Tooltip for accordion section header */
127
- tooltip = v();
135
+ tooltip = R();
128
136
  /** Panel order priority (lower = first, default: 100) */
129
- order = v(100);
137
+ order = R(100);
130
138
  /**
131
139
  * Query for the ng-template content child.
132
140
  */
133
- template = D(y);
141
+ template = S(b);
134
142
  /** Effect that triggers when the template is available */
135
- onTemplateReceived = T(() => {
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 n = this.icon();
140
- n && t.setAttribute("icon", n);
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())), Ee.set(t, e);
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
- B = h(null), I = w(B, 0, "GridToolPanel", ue, I), g(B, 1, I);
154
- const F = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map();
155
- function Ve(i) {
156
- const e = F.get(i);
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 = i.querySelector("tbw-grid-column-view");
166
+ const t = n.querySelector("tbw-grid-column-view");
159
167
  if (t)
160
- return ve(t);
168
+ return be(t);
161
169
  }
162
- function qe(i) {
163
- const e = J.get(i);
170
+ function Fe(n) {
171
+ const e = K.get(n);
164
172
  if (e) return e;
165
- const t = i.querySelector("tbw-grid-column-editor");
173
+ const t = n.querySelector("tbw-grid-column-editor");
166
174
  if (t)
167
- return ge(t);
175
+ return Ee(t);
168
176
  }
169
- var de, W;
170
- de = [E({ selector: "[tbwRenderer]" })];
171
- class P {
172
- template = u(y);
173
- elementRef = u(R);
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
- T(() => {
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, F.set(e, this.template));
192
+ e && (this.columnElement = e, J.set(e, this.template));
185
193
  }
186
194
  ngOnDestroy() {
187
- this.columnElement && F.delete(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
- W = h(null), P = w(W, 0, "TbwRenderer", de, P), g(W, 1, P);
198
- var fe, k;
199
- fe = [E({ selector: "[tbwEditor]" })];
200
- class j {
201
- template = u(y);
202
- elementRef = u(R);
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
- T(() => {
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, J.set(e, this.template));
221
+ e && (this.columnElement = e, K.set(e, this.template));
214
222
  }
215
223
  ngOnDestroy() {
216
- this.columnElement && J.delete(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
- k = h(null), j = w(k, 0, "TbwEditor", fe, j), g(k, 1, j);
227
- function oe(i) {
228
- const e = Ve(i);
229
- return e || ve(i);
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 le(i) {
232
- const e = qe(i);
233
- return e || ge(i);
299
+ function me(n) {
300
+ const e = We(n);
301
+ return e || be(n);
234
302
  }
235
- class Ie {
236
- constructor(e, t, n) {
237
- this.injector = e, this.appRef = t, this.viewContainerRef = n, window.__ANGULAR_GRID_ADAPTER__ = this;
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 oe(e) !== void 0 || le(e) !== void 0;
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 = oe(e);
379
+ const t = me(e);
256
380
  if (t)
257
- return (n) => {
381
+ return (i) => {
258
382
  const r = {
259
- $implicit: n.value,
260
- value: n.value,
261
- row: n.row,
262
- column: n.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 = le(e);
287
- return t ? (n) => {
288
- const r = (o) => n.commit(o), s = () => n.cancel(), l = new ie(), a = new ie();
289
- l.subscribe((o) => n.commit(o)), a.subscribe(() => n.cancel());
290
- const C = {
291
- $implicit: n.value,
292
- value: n.value,
293
- row: n.row,
294
- column: n.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: l,
300
- cancel: a
301
- }, m = this.viewContainerRef.createEmbeddedView(t, C);
302
- this.viewRefs.push(m), m.detectChanges();
303
- const d = m.rootNodes[0];
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 b = o;
306
- n.commit(b.detail);
429
+ const T = o;
430
+ i.commit(T.detail);
307
431
  }), d.addEventListener("cancel", () => {
308
- n.cancel();
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 = se(e);
441
+ const t = ce(e);
318
442
  if (t)
319
- return (n) => {
443
+ return (i) => {
320
444
  const r = {
321
- $implicit: n,
322
- row: n
445
+ $implicit: i,
446
+ row: i
323
447
  }, s = this.viewContainerRef.createEmbeddedView(t, r);
324
448
  this.viewRefs.push(s), s.detectChanges();
325
- const l = document.createElement("div");
326
- return s.rootNodes.forEach((a) => l.appendChild(a)), l;
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 = se(e.closest("tbw-grid"));
461
+ const t = ce(e.closest("tbw-grid"));
338
462
  if (t)
339
- return (n) => {
463
+ return (i) => {
340
464
  const r = {
341
- $implicit: n,
342
- row: n
465
+ $implicit: i,
466
+ row: i
343
467
  }, s = this.viewContainerRef.createEmbeddedView(t, r);
344
468
  this.viewRefs.push(s), s.detectChanges();
345
- const l = document.createElement("div");
346
- return s.rootNodes.forEach((a) => l.appendChild(a)), l;
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 = Oe(e);
478
+ const t = $e(e);
355
479
  if (!t)
356
480
  return;
357
- const n = e.closest("tbw-grid");
481
+ const i = e.closest("tbw-grid");
358
482
  return (r) => {
359
483
  const s = {
360
- $implicit: n ?? r,
361
- grid: n ?? r
362
- }, l = this.viewContainerRef.createEmbeddedView(t, s);
363
- return this.viewRefs.push(l), l.detectChanges(), l.rootNodes.forEach((a) => r.appendChild(a)), () => {
364
- const a = this.viewRefs.indexOf(l);
365
- a > -1 && this.viewRefs.splice(a, 1), l.destroy();
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
- * Clean up all view references.
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 pe, z;
378
- pe = [E({ selector: "tbw-grid" })];
379
- class $ {
380
- elementRef = u(R);
381
- injector = u(Ne);
382
- appRef = u(xe);
383
- viewContainerRef = u(Me);
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's shadow DOM.
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 = v();
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 = ne();
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 = ne();
702
+ rowCommit = oe();
431
703
  ngOnInit() {
432
- this.adapter = new Ie(this.injector, this.appRef, this.viewContainerRef), _e.registerAdapter(this.adapter);
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 n = t.detail;
436
- this.cellCommit.emit(n);
707
+ const i = t.detail;
708
+ this.cellCommit.emit(i);
437
709
  }, e.addEventListener("cell-commit", this.cellCommitListener), this.rowCommitListener = (t) => {
438
- const n = t.detail;
439
- this.rowCommit.emit(n);
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's shadow DOM.
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?.(re);
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 n = e.querySelector("tbw-grid-detail");
471
- if (!n) return;
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 = n.getAttribute("animation");
475
- let l = "slide";
476
- s === "false" ? l = !1 : s === "fade" && (l = "fade");
477
- const a = n.getAttribute("showExpandColumn") !== "false", C = new re({
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: a,
480
- animation: l
481
- }), m = e.gridConfig || {}, d = m.plugins || [];
751
+ showExpandColumn: l,
752
+ animation: a
753
+ }), u = e.gridConfig || {}, d = u.plugins || [];
482
754
  e.gridConfig = {
483
- ...m,
484
- plugins: [...d, C]
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), $ = w(z, 0, "Grid", pe, $), g(z, 1, $);
764
+ z = h(null), x = w(z, 0, "Grid", ve, x), g(z, 1, x);
493
765
  export {
494
- Ie as AngularGridAdapter,
495
- $ as Grid,
496
- O as GridColumnEditor,
766
+ He as AngularGridAdapter,
767
+ De as GRID_TYPE_DEFAULTS,
768
+ x as Grid,
769
+ M as GridColumnEditor,
497
770
  V as GridColumnView,
498
- q as GridDetailView,
499
- I as GridToolPanel,
500
- j as TbwCellEditor,
501
- P as TbwCellView,
502
- j as TbwEditor,
503
- P as TbwRenderer
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
  };