@toolbox-web/grid-angular 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +394 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -1
- package/index.js +275 -127
- package/lib/angular-grid-adapter.d.ts +35 -8
- package/lib/angular-grid-adapter.d.ts.map +1 -1
- package/lib/directives/grid-column-editor.directive.d.ts +23 -7
- package/lib/directives/grid-column-editor.directive.d.ts.map +1 -1
- package/lib/directives/grid.directive.d.ts +62 -0
- package/lib/directives/grid.directive.d.ts.map +1 -1
- package/lib/directives/structural-directives.d.ts +164 -0
- package/lib/directives/structural-directives.d.ts.map +1 -0
- package/package.json +53 -53
- package/lib/grid-angular.d.ts +0 -2
- package/lib/grid-angular.d.ts.map +0 -1
package/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ye = Object.create;
|
|
2
2
|
var M = Object.defineProperty;
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var Te = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var ee = (i, e) => (e = Symbol[i]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + i), L = (i) => {
|
|
5
5
|
throw TypeError(i);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var h = (i) => [, , ,
|
|
10
|
-
for (var r = 0, s = i[e >> 1],
|
|
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
11
|
return n;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
return
|
|
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);
|
|
15
15
|
}, set [t](c) {
|
|
16
|
-
return
|
|
16
|
+
return Z(this, s, c);
|
|
17
17
|
} }, t));
|
|
18
|
-
|
|
19
|
-
for (var
|
|
20
|
-
m =
|
|
21
|
-
return
|
|
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;
|
|
22
22
|
};
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
import { inject as
|
|
26
|
-
import { DataGridElement as
|
|
27
|
-
import { MasterDetailPlugin as
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
return
|
|
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);
|
|
31
31
|
}
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
class
|
|
35
|
-
elementRef =
|
|
32
|
+
var ae, G;
|
|
33
|
+
ae = [E({ selector: "tbw-grid-column-editor" })];
|
|
34
|
+
class O {
|
|
35
|
+
elementRef = u(R);
|
|
36
36
|
/**
|
|
37
37
|
* Query for the ng-template content child.
|
|
38
38
|
*/
|
|
39
|
-
template =
|
|
39
|
+
template = D(y);
|
|
40
40
|
/** Effect that triggers when the template is available */
|
|
41
|
-
onTemplateReceived =
|
|
41
|
+
onTemplateReceived = T(() => {
|
|
42
42
|
const e = this.template();
|
|
43
|
-
e &&
|
|
43
|
+
e && he.set(this.elementRef.nativeElement, e);
|
|
44
44
|
});
|
|
45
45
|
/**
|
|
46
46
|
* Static type guard for template context.
|
|
@@ -50,23 +50,23 @@ class j {
|
|
|
50
50
|
return !0;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
function
|
|
56
|
-
return
|
|
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);
|
|
57
57
|
}
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
class
|
|
61
|
-
elementRef =
|
|
58
|
+
var ce, H;
|
|
59
|
+
ce = [E({ selector: "tbw-grid-column-view" })];
|
|
60
|
+
class V {
|
|
61
|
+
elementRef = u(R);
|
|
62
62
|
/**
|
|
63
63
|
* Query for the ng-template content child.
|
|
64
64
|
*/
|
|
65
|
-
template =
|
|
65
|
+
template = D(y);
|
|
66
66
|
/** Effect that triggers when the template is available */
|
|
67
|
-
onTemplateReceived =
|
|
67
|
+
onTemplateReceived = T(() => {
|
|
68
68
|
const e = this.template();
|
|
69
|
-
e &&
|
|
69
|
+
e && we.set(this.elementRef.nativeElement, e);
|
|
70
70
|
});
|
|
71
71
|
/**
|
|
72
72
|
* Static type guard for template context.
|
|
@@ -76,29 +76,29 @@ class $ {
|
|
|
76
76
|
return !0;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
function
|
|
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
82
|
const e = i.querySelector("tbw-grid-detail");
|
|
83
83
|
if (e)
|
|
84
|
-
return
|
|
84
|
+
return Re.get(e);
|
|
85
85
|
}
|
|
86
|
-
var
|
|
87
|
-
|
|
86
|
+
var me, U;
|
|
87
|
+
me = [E({ selector: "tbw-grid-detail" })];
|
|
88
88
|
class q {
|
|
89
|
-
elementRef =
|
|
89
|
+
elementRef = u(R);
|
|
90
90
|
/** Whether to show the expand/collapse column. Default: true */
|
|
91
|
-
showExpandColumn =
|
|
91
|
+
showExpandColumn = v(!0);
|
|
92
92
|
/** Animation style for expand/collapse. Default: 'slide' */
|
|
93
|
-
animation =
|
|
93
|
+
animation = v("slide");
|
|
94
94
|
/**
|
|
95
95
|
* Query for the ng-template content child.
|
|
96
96
|
*/
|
|
97
|
-
template =
|
|
97
|
+
template = D(y);
|
|
98
98
|
/** Effect that triggers when the template is available */
|
|
99
|
-
onTemplateReceived =
|
|
99
|
+
onTemplateReceived = T(() => {
|
|
100
100
|
const e = this.template();
|
|
101
|
-
e &&
|
|
101
|
+
e && Re.set(this.elementRef.nativeElement, e);
|
|
102
102
|
});
|
|
103
103
|
/**
|
|
104
104
|
* Static type guard for template context.
|
|
@@ -108,38 +108,38 @@ class q {
|
|
|
108
108
|
return !0;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
function
|
|
114
|
-
return
|
|
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);
|
|
115
115
|
}
|
|
116
|
-
var
|
|
117
|
-
|
|
116
|
+
var ue, B;
|
|
117
|
+
ue = [E({ selector: "tbw-grid-tool-panel" })];
|
|
118
118
|
class I {
|
|
119
|
-
elementRef =
|
|
119
|
+
elementRef = u(R);
|
|
120
120
|
/** Unique panel identifier (required) */
|
|
121
|
-
id =
|
|
121
|
+
id = v.required({ alias: "id" });
|
|
122
122
|
/** Panel title shown in accordion header (required) */
|
|
123
|
-
title =
|
|
123
|
+
title = v.required({ alias: "title" });
|
|
124
124
|
/** Icon for accordion section header (emoji or text) */
|
|
125
|
-
icon =
|
|
125
|
+
icon = v();
|
|
126
126
|
/** Tooltip for accordion section header */
|
|
127
|
-
tooltip =
|
|
127
|
+
tooltip = v();
|
|
128
128
|
/** Panel order priority (lower = first, default: 100) */
|
|
129
|
-
order =
|
|
129
|
+
order = v(100);
|
|
130
130
|
/**
|
|
131
131
|
* Query for the ng-template content child.
|
|
132
132
|
*/
|
|
133
|
-
template =
|
|
133
|
+
template = D(y);
|
|
134
134
|
/** Effect that triggers when the template is available */
|
|
135
|
-
onTemplateReceived =
|
|
135
|
+
onTemplateReceived = T(() => {
|
|
136
136
|
const e = this.template(), t = this.elementRef.nativeElement;
|
|
137
137
|
if (e) {
|
|
138
138
|
t.setAttribute("id", this.id()), t.setAttribute("title", this.title());
|
|
139
139
|
const n = this.icon();
|
|
140
140
|
n && t.setAttribute("icon", n);
|
|
141
141
|
const r = this.tooltip();
|
|
142
|
-
r && t.setAttribute("tooltip", r), t.setAttribute("order", String(this.order())),
|
|
142
|
+
r && t.setAttribute("tooltip", r), t.setAttribute("order", String(this.order())), Ee.set(t, e);
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
/**
|
|
@@ -150,53 +150,163 @@ class I {
|
|
|
150
150
|
return !0;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
|
|
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);
|
|
157
|
+
if (e) return e;
|
|
158
|
+
const t = i.querySelector("tbw-grid-column-view");
|
|
159
|
+
if (t)
|
|
160
|
+
return ve(t);
|
|
161
|
+
}
|
|
162
|
+
function qe(i) {
|
|
163
|
+
const e = J.get(i);
|
|
164
|
+
if (e) return e;
|
|
165
|
+
const t = i.querySelector("tbw-grid-column-editor");
|
|
166
|
+
if (t)
|
|
167
|
+
return ge(t);
|
|
168
|
+
}
|
|
169
|
+
var de, W;
|
|
170
|
+
de = [E({ selector: "[tbwRenderer]" })];
|
|
171
|
+
class P {
|
|
172
|
+
template = u(y);
|
|
173
|
+
elementRef = u(R);
|
|
174
|
+
columnElement = null;
|
|
175
|
+
constructor() {
|
|
176
|
+
T(() => {
|
|
177
|
+
this.registerTemplate();
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
registerTemplate() {
|
|
181
|
+
let e = this.elementRef.nativeElement?.parentElement;
|
|
182
|
+
for (; e && e.tagName !== "TBW-GRID-COLUMN"; )
|
|
183
|
+
e = e.parentElement;
|
|
184
|
+
e && (this.columnElement = e, F.set(e, this.template));
|
|
185
|
+
}
|
|
186
|
+
ngOnDestroy() {
|
|
187
|
+
this.columnElement && F.delete(this.columnElement);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Static type guard for template context.
|
|
191
|
+
* Uses `any` defaults for ergonomic template usage.
|
|
192
|
+
*/
|
|
193
|
+
static ngTemplateContextGuard(e, t) {
|
|
194
|
+
return !0;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
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);
|
|
203
|
+
columnElement = null;
|
|
204
|
+
constructor() {
|
|
205
|
+
T(() => {
|
|
206
|
+
this.registerTemplate();
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
registerTemplate() {
|
|
210
|
+
let e = this.elementRef.nativeElement?.parentElement;
|
|
211
|
+
for (; e && e.tagName !== "TBW-GRID-COLUMN"; )
|
|
212
|
+
e = e.parentElement;
|
|
213
|
+
e && (this.columnElement = e, J.set(e, this.template));
|
|
214
|
+
}
|
|
215
|
+
ngOnDestroy() {
|
|
216
|
+
this.columnElement && J.delete(this.columnElement);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Static type guard for template context.
|
|
220
|
+
* Uses `any` defaults for ergonomic template usage.
|
|
221
|
+
*/
|
|
222
|
+
static ngTemplateContextGuard(e, t) {
|
|
223
|
+
return !0;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
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);
|
|
230
|
+
}
|
|
231
|
+
function le(i) {
|
|
232
|
+
const e = qe(i);
|
|
233
|
+
return e || ge(i);
|
|
234
|
+
}
|
|
235
|
+
class Ie {
|
|
155
236
|
constructor(e, t, n) {
|
|
156
237
|
this.injector = e, this.appRef = t, this.viewContainerRef = n, window.__ANGULAR_GRID_ADAPTER__ = this;
|
|
157
238
|
}
|
|
158
239
|
viewRefs = [];
|
|
159
240
|
/**
|
|
160
241
|
* Determines if this adapter can handle the given element.
|
|
161
|
-
* Checks if a template is registered for this element.
|
|
242
|
+
* Checks if a template is registered for this element (structural or nested).
|
|
162
243
|
*/
|
|
163
244
|
canHandle(e) {
|
|
164
|
-
return
|
|
245
|
+
return oe(e) !== void 0 || le(e) !== void 0;
|
|
165
246
|
}
|
|
166
247
|
/**
|
|
167
248
|
* Creates a view renderer function that creates an embedded view
|
|
168
249
|
* from the registered template and returns its DOM element.
|
|
250
|
+
*
|
|
251
|
+
* Returns undefined if no template is registered for this element,
|
|
252
|
+
* allowing the grid to use its default rendering.
|
|
169
253
|
*/
|
|
170
254
|
createRenderer(e) {
|
|
171
|
-
const t =
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
255
|
+
const t = oe(e);
|
|
256
|
+
if (t)
|
|
257
|
+
return (n) => {
|
|
258
|
+
const r = {
|
|
259
|
+
$implicit: n.value,
|
|
260
|
+
value: n.value,
|
|
261
|
+
row: n.row,
|
|
262
|
+
column: n.column
|
|
263
|
+
}, s = this.viewContainerRef.createEmbeddedView(t, r);
|
|
264
|
+
return this.viewRefs.push(s), s.detectChanges(), s.rootNodes[0];
|
|
265
|
+
};
|
|
181
266
|
}
|
|
182
267
|
/**
|
|
183
|
-
* Creates an editor spec that creates an embedded view
|
|
184
|
-
*
|
|
268
|
+
* Creates an editor spec that creates an embedded view.
|
|
269
|
+
*
|
|
270
|
+
* **Auto-wiring**: The adapter automatically listens for `commit` and `cancel`
|
|
271
|
+
* CustomEvents on the rendered component. If the component emits these events,
|
|
272
|
+
* the adapter will call the grid's commit/cancel functions automatically.
|
|
273
|
+
*
|
|
274
|
+
* This means templates can be simplified from:
|
|
275
|
+
* ```html
|
|
276
|
+
* <app-editor *tbwEditor="let value; onCommit as onCommit"
|
|
277
|
+
* [value]="value" (commit)="onCommit($event)" />
|
|
278
|
+
* ```
|
|
279
|
+
* To just:
|
|
280
|
+
* ```html
|
|
281
|
+
* <app-editor *tbwEditor="let value" [value]="value" />
|
|
282
|
+
* ```
|
|
283
|
+
* As long as the component emits `(commit)` with the new value.
|
|
185
284
|
*/
|
|
186
285
|
createEditor(e) {
|
|
187
|
-
const t =
|
|
286
|
+
const t = le(e);
|
|
188
287
|
return t ? (n) => {
|
|
189
|
-
const r =
|
|
190
|
-
|
|
191
|
-
const
|
|
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 = {
|
|
192
291
|
$implicit: n.value,
|
|
193
292
|
value: n.value,
|
|
194
293
|
row: n.row,
|
|
195
294
|
column: n.column,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
295
|
+
// Preferred: simple callback functions
|
|
296
|
+
onCommit: r,
|
|
297
|
+
onCancel: s,
|
|
298
|
+
// 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];
|
|
304
|
+
return d && d.addEventListener && (d.addEventListener("commit", (o) => {
|
|
305
|
+
const b = o;
|
|
306
|
+
n.commit(b.detail);
|
|
307
|
+
}), d.addEventListener("cancel", () => {
|
|
308
|
+
n.cancel();
|
|
309
|
+
})), d;
|
|
200
310
|
} : (console.warn("[AngularGridAdapter] No editor template registered for element"), () => document.createElement("div"));
|
|
201
311
|
}
|
|
202
312
|
/**
|
|
@@ -204,7 +314,7 @@ class ye {
|
|
|
204
314
|
* Renders Angular templates for expandable detail rows.
|
|
205
315
|
*/
|
|
206
316
|
createDetailRenderer(e) {
|
|
207
|
-
const t =
|
|
317
|
+
const t = se(e);
|
|
208
318
|
if (t)
|
|
209
319
|
return (n) => {
|
|
210
320
|
const r = {
|
|
@@ -212,8 +322,8 @@ class ye {
|
|
|
212
322
|
row: n
|
|
213
323
|
}, s = this.viewContainerRef.createEmbeddedView(t, r);
|
|
214
324
|
this.viewRefs.push(s), s.detectChanges();
|
|
215
|
-
const
|
|
216
|
-
return s.rootNodes.forEach((a) =>
|
|
325
|
+
const l = document.createElement("div");
|
|
326
|
+
return s.rootNodes.forEach((a) => l.appendChild(a)), l;
|
|
217
327
|
};
|
|
218
328
|
}
|
|
219
329
|
/**
|
|
@@ -224,7 +334,7 @@ class ye {
|
|
|
224
334
|
* without manual configuration in the Grid directive.
|
|
225
335
|
*/
|
|
226
336
|
parseDetailElement(e) {
|
|
227
|
-
const t =
|
|
337
|
+
const t = se(e.closest("tbw-grid"));
|
|
228
338
|
if (t)
|
|
229
339
|
return (n) => {
|
|
230
340
|
const r = {
|
|
@@ -232,8 +342,8 @@ class ye {
|
|
|
232
342
|
row: n
|
|
233
343
|
}, s = this.viewContainerRef.createEmbeddedView(t, r);
|
|
234
344
|
this.viewRefs.push(s), s.detectChanges();
|
|
235
|
-
const
|
|
236
|
-
return s.rootNodes.forEach((a) =>
|
|
345
|
+
const l = document.createElement("div");
|
|
346
|
+
return s.rootNodes.forEach((a) => l.appendChild(a)), l;
|
|
237
347
|
};
|
|
238
348
|
}
|
|
239
349
|
/**
|
|
@@ -241,7 +351,7 @@ class ye {
|
|
|
241
351
|
* The renderer creates an Angular template-based panel content.
|
|
242
352
|
*/
|
|
243
353
|
createToolPanelRenderer(e) {
|
|
244
|
-
const t =
|
|
354
|
+
const t = Oe(e);
|
|
245
355
|
if (!t)
|
|
246
356
|
return;
|
|
247
357
|
const n = e.closest("tbw-grid");
|
|
@@ -249,10 +359,10 @@ class ye {
|
|
|
249
359
|
const s = {
|
|
250
360
|
$implicit: n ?? r,
|
|
251
361
|
grid: n ?? r
|
|
252
|
-
},
|
|
253
|
-
return this.viewRefs.push(
|
|
254
|
-
const a = this.viewRefs.indexOf(
|
|
255
|
-
a > -1 && this.viewRefs.splice(a, 1),
|
|
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();
|
|
256
366
|
};
|
|
257
367
|
};
|
|
258
368
|
}
|
|
@@ -264,14 +374,16 @@ class ye {
|
|
|
264
374
|
this.viewRefs.forEach((e) => e.destroy()), this.viewRefs = [];
|
|
265
375
|
}
|
|
266
376
|
}
|
|
267
|
-
var
|
|
268
|
-
|
|
269
|
-
class
|
|
270
|
-
elementRef =
|
|
271
|
-
injector =
|
|
272
|
-
appRef =
|
|
273
|
-
viewContainerRef =
|
|
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);
|
|
274
384
|
adapter = null;
|
|
385
|
+
cellCommitListener = null;
|
|
386
|
+
rowCommitListener = null;
|
|
275
387
|
/**
|
|
276
388
|
* Custom CSS styles to inject into the grid's shadow DOM.
|
|
277
389
|
* Use this to style custom cell renderers, editors, or detail panels.
|
|
@@ -289,11 +401,43 @@ class H {
|
|
|
289
401
|
* <tbw-grid [customStyles]="customStyles">...</tbw-grid>
|
|
290
402
|
* ```
|
|
291
403
|
*/
|
|
292
|
-
customStyles =
|
|
404
|
+
customStyles = v();
|
|
405
|
+
/**
|
|
406
|
+
* Emitted when a cell value is committed (inline editing).
|
|
407
|
+
* Provides the row, field, new value, and change tracking information.
|
|
408
|
+
*
|
|
409
|
+
* @example
|
|
410
|
+
* ```html
|
|
411
|
+
* <tbw-grid (cellCommit)="onCellCommit($event)">...</tbw-grid>
|
|
412
|
+
* ```
|
|
413
|
+
*
|
|
414
|
+
* ```typescript
|
|
415
|
+
* onCellCommit(event: CellCommitEvent) {
|
|
416
|
+
* console.log(`Changed ${event.field} to ${event.value} in row ${event.rowIndex}`);
|
|
417
|
+
* }
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
cellCommit = ne();
|
|
421
|
+
/**
|
|
422
|
+
* Emitted when a row's values are committed (bulk/row editing).
|
|
423
|
+
* Provides the row data and change tracking information.
|
|
424
|
+
*
|
|
425
|
+
* @example
|
|
426
|
+
* ```html
|
|
427
|
+
* <tbw-grid (rowCommit)="onRowCommit($event)">...</tbw-grid>
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
rowCommit = ne();
|
|
293
431
|
ngOnInit() {
|
|
294
|
-
this.adapter = new
|
|
432
|
+
this.adapter = new Ie(this.injector, this.appRef, this.viewContainerRef), _e.registerAdapter(this.adapter);
|
|
295
433
|
const e = this.elementRef.nativeElement;
|
|
296
|
-
|
|
434
|
+
this.cellCommitListener = (t) => {
|
|
435
|
+
const n = t.detail;
|
|
436
|
+
this.cellCommit.emit(n);
|
|
437
|
+
}, e.addEventListener("cell-commit", this.cellCommitListener), this.rowCommitListener = (t) => {
|
|
438
|
+
const n = t.detail;
|
|
439
|
+
this.rowCommit.emit(n);
|
|
440
|
+
}, e.addEventListener("row-commit", this.rowCommitListener), e.__frameworkAdapter = this.adapter;
|
|
297
441
|
}
|
|
298
442
|
ngAfterContentInit() {
|
|
299
443
|
const e = this.elementRef.nativeElement;
|
|
@@ -318,7 +462,7 @@ class H {
|
|
|
318
462
|
*/
|
|
319
463
|
configureMasterDetail(e) {
|
|
320
464
|
if (!this.adapter) return;
|
|
321
|
-
const t = e.getPlugin?.(
|
|
465
|
+
const t = e.getPlugin?.(re);
|
|
322
466
|
if (t && typeof t.refreshDetailRenderer == "function") {
|
|
323
467
|
t.refreshDetailRenderer();
|
|
324
468
|
return;
|
|
@@ -328,29 +472,33 @@ class H {
|
|
|
328
472
|
const r = this.adapter.createDetailRenderer(e);
|
|
329
473
|
if (!r) return;
|
|
330
474
|
const s = n.getAttribute("animation");
|
|
331
|
-
let
|
|
332
|
-
s === "false" ?
|
|
333
|
-
const a = n.getAttribute("showExpandColumn") !== "false",
|
|
475
|
+
let l = "slide";
|
|
476
|
+
s === "false" ? l = !1 : s === "fade" && (l = "fade");
|
|
477
|
+
const a = n.getAttribute("showExpandColumn") !== "false", C = new re({
|
|
334
478
|
detailRenderer: r,
|
|
335
479
|
showExpandColumn: a,
|
|
336
|
-
animation:
|
|
337
|
-
}), m = e.gridConfig || {},
|
|
480
|
+
animation: l
|
|
481
|
+
}), m = e.gridConfig || {}, d = m.plugins || [];
|
|
338
482
|
e.gridConfig = {
|
|
339
483
|
...m,
|
|
340
|
-
plugins: [...
|
|
484
|
+
plugins: [...d, C]
|
|
341
485
|
};
|
|
342
486
|
}
|
|
343
487
|
ngOnDestroy() {
|
|
344
488
|
const e = this.elementRef.nativeElement;
|
|
345
|
-
e && this.customStyles() && e.unregisterStyles?.("angular-custom-styles"), this.adapter && (this.adapter.destroy?.(), this.adapter = null);
|
|
489
|
+
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);
|
|
346
490
|
}
|
|
347
491
|
}
|
|
348
|
-
|
|
492
|
+
z = h(null), $ = w(z, 0, "Grid", pe, $), g(z, 1, $);
|
|
349
493
|
export {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
494
|
+
Ie as AngularGridAdapter,
|
|
495
|
+
$ as Grid,
|
|
496
|
+
O as GridColumnEditor,
|
|
497
|
+
V as GridColumnView,
|
|
354
498
|
q as GridDetailView,
|
|
355
|
-
I as GridToolPanel
|
|
499
|
+
I as GridToolPanel,
|
|
500
|
+
j as TbwCellEditor,
|
|
501
|
+
P as TbwCellView,
|
|
502
|
+
j as TbwEditor,
|
|
503
|
+
P as TbwRenderer
|
|
356
504
|
};
|
|
@@ -26,7 +26,17 @@ import { ColumnEditorSpec, ColumnViewRenderer, FrameworkAdapter } from '../../..
|
|
|
26
26
|
* }
|
|
27
27
|
* ```
|
|
28
28
|
*
|
|
29
|
-
* **Declarative configuration in templates:**
|
|
29
|
+
* **Declarative configuration in templates (structural directive - recommended):**
|
|
30
|
+
* ```html
|
|
31
|
+
* <tbw-grid>
|
|
32
|
+
* <tbw-grid-column field="status">
|
|
33
|
+
* <app-status-badge *tbwRenderer="let value; row as row" [value]="value" />
|
|
34
|
+
* <app-status-editor *tbwEditor="let value" [value]="value" />
|
|
35
|
+
* </tbw-grid-column>
|
|
36
|
+
* </tbw-grid>
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* **Declarative configuration in templates (nested directive - legacy):**
|
|
30
40
|
* ```html
|
|
31
41
|
* <tbw-grid>
|
|
32
42
|
* <tbw-grid-column field="status">
|
|
@@ -36,8 +46,8 @@ import { ColumnEditorSpec, ColumnViewRenderer, FrameworkAdapter } from '../../..
|
|
|
36
46
|
* </ng-template>
|
|
37
47
|
* </tbw-grid-column-view>
|
|
38
48
|
* <tbw-grid-column-editor>
|
|
39
|
-
* <ng-template let-value let-
|
|
40
|
-
* <app-status-select [value]="value" (commit)="
|
|
49
|
+
* <ng-template let-value let-onCommit="onCommit" let-onCancel="onCancel">
|
|
50
|
+
* <app-status-select [value]="value" (commit)="onCommit($event)" (cancel)="onCancel()" />
|
|
41
51
|
* </ng-template>
|
|
42
52
|
* </tbw-grid-column-editor>
|
|
43
53
|
* </tbw-grid-column>
|
|
@@ -45,9 +55,9 @@ import { ColumnEditorSpec, ColumnViewRenderer, FrameworkAdapter } from '../../..
|
|
|
45
55
|
* ```
|
|
46
56
|
*
|
|
47
57
|
* The adapter automatically:
|
|
48
|
-
* - Detects Angular templates registered by directives
|
|
58
|
+
* - Detects Angular templates registered by directives (both structural and nested)
|
|
49
59
|
* - Creates embedded views with cell context (value, row, column)
|
|
50
|
-
* - Handles editor
|
|
60
|
+
* - Handles editor callbacks (onCommit/onCancel)
|
|
51
61
|
* - Manages view lifecycle and change detection
|
|
52
62
|
*/
|
|
53
63
|
export declare class AngularGridAdapter implements FrameworkAdapter {
|
|
@@ -58,17 +68,34 @@ export declare class AngularGridAdapter implements FrameworkAdapter {
|
|
|
58
68
|
constructor(injector: EnvironmentInjector, appRef: ApplicationRef, viewContainerRef: ViewContainerRef);
|
|
59
69
|
/**
|
|
60
70
|
* Determines if this adapter can handle the given element.
|
|
61
|
-
* Checks if a template is registered for this element.
|
|
71
|
+
* Checks if a template is registered for this element (structural or nested).
|
|
62
72
|
*/
|
|
63
73
|
canHandle(element: HTMLElement): boolean;
|
|
64
74
|
/**
|
|
65
75
|
* Creates a view renderer function that creates an embedded view
|
|
66
76
|
* from the registered template and returns its DOM element.
|
|
77
|
+
*
|
|
78
|
+
* Returns undefined if no template is registered for this element,
|
|
79
|
+
* allowing the grid to use its default rendering.
|
|
67
80
|
*/
|
|
68
81
|
createRenderer<TRow = unknown, TValue = unknown>(element: HTMLElement): ColumnViewRenderer<TRow, TValue>;
|
|
69
82
|
/**
|
|
70
|
-
* Creates an editor spec that creates an embedded view
|
|
71
|
-
*
|
|
83
|
+
* Creates an editor spec that creates an embedded view.
|
|
84
|
+
*
|
|
85
|
+
* **Auto-wiring**: The adapter automatically listens for `commit` and `cancel`
|
|
86
|
+
* CustomEvents on the rendered component. If the component emits these events,
|
|
87
|
+
* the adapter will call the grid's commit/cancel functions automatically.
|
|
88
|
+
*
|
|
89
|
+
* This means templates can be simplified from:
|
|
90
|
+
* ```html
|
|
91
|
+
* <app-editor *tbwEditor="let value; onCommit as onCommit"
|
|
92
|
+
* [value]="value" (commit)="onCommit($event)" />
|
|
93
|
+
* ```
|
|
94
|
+
* To just:
|
|
95
|
+
* ```html
|
|
96
|
+
* <app-editor *tbwEditor="let value" [value]="value" />
|
|
97
|
+
* ```
|
|
98
|
+
* As long as the component emits `(commit)` with the new value.
|
|
72
99
|
*/
|
|
73
100
|
createEditor<TRow = unknown, TValue = unknown>(element: HTMLElement): ColumnEditorSpec<TRow, TValue>;
|
|
74
101
|
/**
|