@toolbox-web/grid-vue 0.2.0 → 0.3.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/index.js CHANGED
@@ -1,12 +1,14 @@
1
- import { defineComponent as p, provide as G, inject as O, ref as y, createApp as g, computed as Y, onMounted as b, onBeforeUnmount as $, watch as B, createElementBlock as w, openBlock as E, renderSlot as I, useSlots as _, h } from "vue";
2
- import { DataGridElement as K } from "@toolbox-web/grid";
3
- import { c as J } from "./chunks/feature-registry-BgEOysSJ.js";
4
- import { a as Te, g as Be, b as Oe, i as _e, r as je } from "./chunks/feature-registry-BgEOysSJ.js";
5
- const z = /* @__PURE__ */ Symbol("grid-icons");
6
- function Q() {
7
- return O(z, void 0);
1
+ import { defineComponent as y, provide as L, inject as M, createApp as p, createVNode as V, ref as R, computed as ne, onMounted as T, onBeforeUnmount as q, watch as B, createElementBlock as O, openBlock as _, renderSlot as U, useSlots as P, h as C } from "vue";
2
+ import { DataGridElement as re } from "@toolbox-web/grid";
3
+ import { c as oe } from "./chunks/feature-registry-BgEOysSJ.js";
4
+ import { a as ke, g as Ve, b as Le, i as Me, r as Ne } from "./chunks/feature-registry-BgEOysSJ.js";
5
+ import { G as H } from "./chunks/use-grid-DwjXrO19.js";
6
+ import { u as Fe } from "./chunks/use-grid-DwjXrO19.js";
7
+ const K = /* @__PURE__ */ Symbol("grid-icons");
8
+ function ie() {
9
+ return M(K, void 0);
8
10
  }
9
- const X = p({
11
+ const se = y({
10
12
  name: "GridIconProvider",
11
13
  props: {
12
14
  /**
@@ -17,17 +19,17 @@ const X = p({
17
19
  required: !0
18
20
  }
19
21
  },
20
- setup(n, { slots: t }) {
21
- return G(z, n.icons), () => t.default?.();
22
+ setup(i, { slots: e }) {
23
+ return L(K, i.icons), () => e.default?.();
22
24
  }
23
- }), N = /* @__PURE__ */ Symbol("grid-type-defaults");
24
- function q() {
25
- return O(N, void 0);
25
+ }), Y = /* @__PURE__ */ Symbol("grid-type-defaults");
26
+ function J() {
27
+ return M(Y, void 0);
26
28
  }
27
- function fe(n) {
28
- return q()?.[n];
29
+ function Ce(i) {
30
+ return J()?.[i];
29
31
  }
30
- const Z = p({
32
+ const de = y({
31
33
  name: "GridTypeProvider",
32
34
  props: {
33
35
  /**
@@ -38,190 +40,388 @@ const Z = p({
38
40
  required: !0
39
41
  }
40
42
  },
41
- setup(n, { slots: t }) {
42
- return G(N, n.defaults), () => t.default?.();
43
- }
44
- }), L = /* @__PURE__ */ Symbol("tbw-grid");
45
- function pe() {
46
- const n = O(L, y(null));
47
- return {
48
- gridElement: n,
49
- forceLayout: async () => {
50
- await n.value?.forceLayout();
51
- },
52
- getConfig: () => n.value?.getConfig(),
53
- ready: async () => {
54
- await n.value?.ready();
55
- },
56
- getPlugin: (t) => n.value?.getPlugin(t)
57
- };
43
+ setup(i, { slots: e }) {
44
+ return L(Y, i.defaults), () => e.default?.();
45
+ }
46
+ }), Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new Map();
47
+ function le(i, e) {
48
+ const n = i.getAttribute("field"), t = v.get(i) ?? {};
49
+ if (t.renderer = e, v.set(i, t), n) {
50
+ const r = b.get(n) ?? {};
51
+ r.renderer = e, b.set(n, r);
52
+ }
58
53
  }
59
- const U = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new Map();
60
- function ee(n, t) {
61
- const e = n.getAttribute("field"), r = m.get(n) ?? {};
62
- if (r.renderer = t, m.set(n, r), e) {
63
- const i = v.get(e) ?? {};
64
- i.renderer = t, v.set(e, i);
54
+ function ce(i, e) {
55
+ const n = i.getAttribute("field"), t = v.get(i) ?? {};
56
+ if (t.editor = e, v.set(i, t), n) {
57
+ const r = b.get(n) ?? {};
58
+ r.editor = e, b.set(n, r);
65
59
  }
66
60
  }
67
- function te(n, t) {
68
- const e = n.getAttribute("field"), r = m.get(n) ?? {};
69
- if (r.editor = t, m.set(n, r), e) {
70
- const i = v.get(e) ?? {};
71
- i.editor = t, v.set(e, i);
61
+ function ae(i) {
62
+ let e = v.get(i)?.renderer;
63
+ if (!e) {
64
+ const n = i.getAttribute("field");
65
+ n && (e = b.get(n)?.renderer);
72
66
  }
67
+ return e;
73
68
  }
74
- function ne(n) {
75
- let t = m.get(n)?.renderer;
76
- if (!t) {
77
- const e = n.getAttribute("field");
78
- e && (t = v.get(e)?.renderer);
69
+ function ue(i) {
70
+ let e = v.get(i)?.editor;
71
+ if (!e) {
72
+ const n = i.getAttribute("field");
73
+ n && (e = b.get(n)?.editor);
79
74
  }
80
- return t;
75
+ return e;
81
76
  }
82
- function re(n) {
83
- let t = m.get(n)?.editor;
84
- if (!t) {
85
- const e = n.getAttribute("field");
86
- e && (t = v.get(e)?.editor);
77
+ function j(i) {
78
+ if (i == null || typeof i == "function" && i.prototype === void 0)
79
+ return !1;
80
+ if (typeof i == "object") {
81
+ const e = i;
82
+ if ("__name" in e || typeof e.setup == "function" || typeof e.render == "function") return !0;
83
+ }
84
+ if (typeof i == "function") {
85
+ const e = Function.prototype.toString.call(i);
86
+ if (e.startsWith("class ") || e.startsWith("class{")) return !0;
87
+ const n = i;
88
+ if ("__name" in n || typeof n.setup == "function") return !0;
87
89
  }
88
- return t;
90
+ return !1;
91
+ }
92
+ function S(i) {
93
+ return typeof i == "function" && !j(i);
89
94
  }
90
- class oe {
95
+ const E = /* @__PURE__ */ Symbol.for("tbw:vue-processed");
96
+ class fe {
91
97
  mountedViews = [];
92
98
  typeDefaults = null;
99
+ // #region Config Processing
100
+ /**
101
+ * Processes a Vue grid configuration, converting Vue component references
102
+ * and VNode-returning render functions to DOM-returning functions.
103
+ *
104
+ * This is idempotent — already-processed configs pass through safely.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * import { GridAdapter, type GridConfig } from '@toolbox-web/grid-vue';
109
+ * import StatusBadge from './StatusBadge.vue';
110
+ *
111
+ * const config: GridConfig<Employee> = {
112
+ * columns: [
113
+ * { field: 'status', renderer: StatusBadge },
114
+ * ],
115
+ * };
116
+ *
117
+ * const adapter = new GridAdapter();
118
+ * const processedConfig = adapter.processGridConfig(config);
119
+ * ```
120
+ *
121
+ * @param config - Vue grid config with possible component/VNode references
122
+ * @returns Processed config with DOM-returning functions
123
+ */
124
+ processGridConfig(e) {
125
+ const n = { ...e };
126
+ return e.columns && (n.columns = e.columns.map((t) => this.processColumn(t))), e.typeDefaults && (n.typeDefaults = this.processTypeDefaults(e.typeDefaults)), n;
127
+ }
128
+ /**
129
+ * Processes typeDefaults, converting Vue component/VNode references
130
+ * to DOM-returning functions.
131
+ *
132
+ * @param typeDefaults - Vue type defaults with possible component references
133
+ * @returns Processed TypeDefault record
134
+ */
135
+ processTypeDefaults(e) {
136
+ const n = {};
137
+ for (const [t, r] of Object.entries(e)) {
138
+ const s = {
139
+ editorParams: r.editorParams
140
+ };
141
+ r.renderer && (j(r.renderer) ? s.renderer = this.createConfigComponentRenderer(r.renderer) : S(r.renderer) && (s.renderer = this.createTypeRenderer(
142
+ r.renderer
143
+ ))), r.editor && (j(r.editor) ? s.editor = this.createConfigComponentEditor(
144
+ r.editor
145
+ ) : S(r.editor) && (s.editor = this.createTypeEditor(
146
+ r.editor
147
+ ))), n[t] = s;
148
+ }
149
+ return n;
150
+ }
151
+ /**
152
+ * Processes a single column configuration, converting Vue component references
153
+ * and VNode-returning render functions to DOM-returning functions.
154
+ *
155
+ * @param column - Vue column config
156
+ * @returns Processed ColumnConfig with DOM-returning functions
157
+ */
158
+ processColumn(e) {
159
+ const n = { ...e };
160
+ if (e.renderer && !e.renderer[E]) {
161
+ if (j(e.renderer)) {
162
+ const t = this.createConfigComponentRenderer(e.renderer);
163
+ t[E] = !0, n.renderer = t;
164
+ } else if (S(e.renderer)) {
165
+ const t = this.createConfigVNodeRenderer(e.renderer);
166
+ t[E] = !0, n.renderer = t;
167
+ }
168
+ }
169
+ if (e.editor && !e.editor[E]) {
170
+ if (j(e.editor)) {
171
+ const t = this.createConfigComponentEditor(e.editor);
172
+ t[E] = !0, n.editor = t;
173
+ } else if (S(e.editor)) {
174
+ const t = this.createConfigVNodeEditor(e.editor);
175
+ t[E] = !0, n.editor = t;
176
+ }
177
+ }
178
+ return n;
179
+ }
180
+ /**
181
+ * Creates a DOM-returning renderer from a Vue component class.
182
+ * Used for config-based renderers (not slot-based).
183
+ * @internal
184
+ */
185
+ createConfigComponentRenderer(e) {
186
+ const n = /* @__PURE__ */ new WeakMap();
187
+ return (t) => {
188
+ const r = t.cellEl;
189
+ if (r) {
190
+ const c = n.get(r);
191
+ if (c)
192
+ return c.update(t), c.container;
193
+ const a = document.createElement("div");
194
+ a.className = "vue-cell-renderer", a.style.display = "contents";
195
+ let u = t;
196
+ const g = e, h = p({
197
+ render() {
198
+ return V(g, { ...u });
199
+ }
200
+ });
201
+ return h.mount(a), n.set(r, {
202
+ app: h,
203
+ container: a,
204
+ update: (D) => {
205
+ u = D, h._instance?.update();
206
+ }
207
+ }), a;
208
+ }
209
+ const s = document.createElement("div");
210
+ s.className = "vue-cell-renderer", s.style.display = "contents";
211
+ const d = e, l = p({
212
+ render() {
213
+ return V(d, { ...t });
214
+ }
215
+ });
216
+ return l.mount(s), this.mountedViews.push({ app: l, container: s }), s;
217
+ };
218
+ }
219
+ /**
220
+ * Creates a DOM-returning renderer from a VNode-returning render function.
221
+ * Used for config-based renderers (not slot-based).
222
+ * @internal
223
+ */
224
+ createConfigVNodeRenderer(e) {
225
+ const n = /* @__PURE__ */ new WeakMap();
226
+ return (t) => {
227
+ const r = t.cellEl;
228
+ if (r) {
229
+ const l = n.get(r);
230
+ if (l)
231
+ return l.update(t), l.container;
232
+ const c = document.createElement("div");
233
+ c.className = "vue-cell-renderer", c.style.display = "contents";
234
+ let a = t;
235
+ const u = p({
236
+ render() {
237
+ return e(a);
238
+ }
239
+ });
240
+ return u.mount(c), n.set(r, {
241
+ app: u,
242
+ container: c,
243
+ update: (g) => {
244
+ a = g, u._instance?.update();
245
+ }
246
+ }), c;
247
+ }
248
+ const s = document.createElement("div");
249
+ s.className = "vue-cell-renderer", s.style.display = "contents";
250
+ const d = p({
251
+ render() {
252
+ return e(t);
253
+ }
254
+ });
255
+ return d.mount(s), this.mountedViews.push({ app: d, container: s }), s;
256
+ };
257
+ }
258
+ /**
259
+ * Creates a DOM-returning editor from a Vue component class.
260
+ * Used for config-based editors (not slot-based).
261
+ * @internal
262
+ */
263
+ createConfigComponentEditor(e) {
264
+ return (n) => {
265
+ const t = document.createElement("div");
266
+ t.className = "vue-cell-editor", t.style.display = "contents";
267
+ const r = e, s = p({
268
+ render() {
269
+ return V(r, { ...n });
270
+ }
271
+ });
272
+ return s.mount(t), this.mountedViews.push({ app: s, container: t }), t;
273
+ };
274
+ }
275
+ /**
276
+ * Creates a DOM-returning editor from a VNode-returning render function.
277
+ * Used for config-based editors (not slot-based).
278
+ * @internal
279
+ */
280
+ createConfigVNodeEditor(e) {
281
+ return (n) => {
282
+ const t = document.createElement("div");
283
+ t.className = "vue-cell-editor", t.style.display = "contents";
284
+ const r = p({
285
+ render() {
286
+ return e(n);
287
+ }
288
+ });
289
+ return r.mount(t), this.mountedViews.push({ app: r, container: t }), t;
290
+ };
291
+ }
292
+ // #endregion
93
293
  /**
94
294
  * Sets the type defaults map for this adapter.
95
295
  * Called by TbwGrid when it receives type defaults from context.
96
296
  *
97
297
  * @internal
98
298
  */
99
- setTypeDefaults(t) {
100
- this.typeDefaults = t;
299
+ setTypeDefaults(e) {
300
+ this.typeDefaults = e;
101
301
  }
102
302
  /**
103
303
  * Determines if this adapter can handle the given element.
104
304
  * Checks if a renderer or editor is registered for this element.
105
305
  */
106
- canHandle(t) {
107
- const e = t.getAttribute("field");
108
- let r = m.get(t);
109
- if (!r && e) {
110
- const l = v.get(e);
111
- l && (l.renderer || l.editor) && (r = l, m.set(t, r));
306
+ canHandle(e) {
307
+ const n = e.getAttribute("field");
308
+ let t = v.get(e);
309
+ if (!t && n) {
310
+ const d = b.get(n);
311
+ d && (d.renderer || d.editor) && (t = d, v.set(e, t));
112
312
  }
113
- const i = r?.renderer !== void 0, a = r?.editor !== void 0;
114
- return r !== void 0 && (i || a);
313
+ const r = t?.renderer !== void 0, s = t?.editor !== void 0;
314
+ return t !== void 0 && (r || s);
115
315
  }
116
316
  /**
117
317
  * Creates a view renderer function that renders a Vue component
118
318
  * and returns its container DOM element.
119
319
  */
120
- createRenderer(t) {
121
- const e = ne(t);
122
- if (!e)
320
+ createRenderer(e) {
321
+ const n = ae(e);
322
+ if (!n)
123
323
  return;
124
- const r = /* @__PURE__ */ new WeakMap();
125
- return (i) => {
126
- const a = i.cellEl;
127
- if (a) {
128
- const s = r.get(a);
129
- if (s)
130
- return s.update(i), s.container;
131
- const c = document.createElement("div");
132
- c.className = "vue-cell-renderer", c.style.display = "contents";
133
- let u = i;
134
- const R = g({
324
+ const t = /* @__PURE__ */ new WeakMap();
325
+ return (r) => {
326
+ const s = r.cellEl;
327
+ if (s) {
328
+ const c = t.get(s);
329
+ if (c)
330
+ return c.update(r), c.container;
331
+ const a = document.createElement("div");
332
+ a.className = "vue-cell-renderer", a.style.display = "contents";
333
+ let u = r;
334
+ const g = p({
135
335
  render() {
136
- return e(u);
336
+ return n(u);
137
337
  }
138
338
  });
139
- return R.mount(c), r.set(a, {
140
- app: R,
141
- container: c,
142
- update: (j) => {
143
- u = j, R._instance?.update();
339
+ return g.mount(a), t.set(s, {
340
+ app: g,
341
+ container: a,
342
+ update: (h) => {
343
+ u = h, g._instance?.update();
144
344
  }
145
- }), c;
345
+ }), a;
146
346
  }
147
- const l = document.createElement("div");
148
- l.className = "vue-cell-renderer", l.style.display = "contents";
149
- const d = g({
347
+ const d = document.createElement("div");
348
+ d.className = "vue-cell-renderer", d.style.display = "contents";
349
+ const l = p({
150
350
  render() {
151
- return e(i);
351
+ return n(r);
152
352
  }
153
353
  });
154
- return d.mount(l), this.mountedViews.push({ app: d, container: l }), l;
354
+ return l.mount(d), this.mountedViews.push({ app: l, container: d }), d;
155
355
  };
156
356
  }
157
357
  /**
158
358
  * Creates an editor spec that renders a Vue component for cell editing.
159
359
  * Returns a function that creates the editor DOM element.
160
360
  */
161
- createEditor(t) {
162
- const e = re(t);
163
- if (e)
164
- return (r) => {
165
- const i = document.createElement("div");
166
- i.className = "vue-cell-editor", i.style.display = "contents";
167
- const a = g({
361
+ createEditor(e) {
362
+ const n = ue(e);
363
+ if (n)
364
+ return (t) => {
365
+ const r = document.createElement("div");
366
+ r.className = "vue-cell-editor", r.style.display = "contents";
367
+ const s = p({
168
368
  render() {
169
- return e(r);
369
+ return n(t);
170
370
  }
171
371
  });
172
- return a.mount(i), this.mountedViews.push({ app: a, container: i }), i;
372
+ return s.mount(r), this.mountedViews.push({ app: s, container: r }), r;
173
373
  };
174
374
  }
175
375
  /**
176
376
  * Framework adapter hook called by MasterDetailPlugin during attach().
177
377
  * Parses the <tbw-grid-detail> element and returns a Vue-based renderer.
178
378
  */
179
- parseDetailElement(t) {
180
- const e = t.closest("tbw-grid");
181
- if (!e) return;
182
- const r = e.querySelector("tbw-grid-detail");
183
- if (!r) return;
184
- const i = U.get(r);
185
- if (i)
186
- return (a, l) => {
187
- const d = document.createElement("div");
188
- d.className = "vue-detail-panel";
189
- const c = i({ row: a, rowIndex: l });
190
- if (c && c.length > 0) {
191
- const u = g({
379
+ parseDetailElement(e) {
380
+ const n = e.closest("tbw-grid");
381
+ if (!n) return;
382
+ const t = n.querySelector("tbw-grid-detail");
383
+ if (!t) return;
384
+ const r = Q.get(t);
385
+ if (r)
386
+ return (s, d) => {
387
+ const l = document.createElement("div");
388
+ l.className = "vue-detail-panel";
389
+ const a = r({ row: s, rowIndex: d });
390
+ if (a && a.length > 0) {
391
+ const u = p({
192
392
  render() {
193
- return c;
393
+ return a;
194
394
  }
195
395
  });
196
- u.mount(d), this.mountedViews.push({ app: u, container: d });
396
+ u.mount(l), this.mountedViews.push({ app: u, container: l });
197
397
  }
198
- return d;
398
+ return l;
199
399
  };
200
400
  }
201
401
  /**
202
402
  * Framework adapter hook called by ResponsivePlugin during attach().
203
403
  * Parses the <tbw-grid-responsive-card> element and returns a Vue-based renderer.
204
404
  */
205
- parseResponsiveCardElement(t) {
206
- const e = t.closest("tbw-grid");
207
- if (!e) return;
208
- const r = e.querySelector("tbw-grid-responsive-card");
209
- if (!r) return;
210
- const i = H.get(r);
211
- if (i)
212
- return (a, l) => {
213
- const d = document.createElement("div");
214
- d.className = "vue-responsive-card";
215
- const c = i({ row: a, rowIndex: l });
216
- if (c && c.length > 0) {
217
- const u = g({
405
+ parseResponsiveCardElement(e) {
406
+ const n = e.closest("tbw-grid");
407
+ if (!n) return;
408
+ const t = n.querySelector("tbw-grid-responsive-card");
409
+ if (!t) return;
410
+ const r = X.get(t);
411
+ if (r)
412
+ return (s, d) => {
413
+ const l = document.createElement("div");
414
+ l.className = "vue-responsive-card";
415
+ const a = r({ row: s, rowIndex: d });
416
+ if (a && a.length > 0) {
417
+ const u = p({
218
418
  render() {
219
- return c;
419
+ return a;
220
420
  }
221
421
  });
222
- u.mount(d), this.mountedViews.push({ app: u, container: d });
422
+ u.mount(l), this.mountedViews.push({ app: u, container: l });
223
423
  }
224
- return d;
424
+ return l;
225
425
  };
226
426
  }
227
427
  // #region Type Defaults Support
@@ -253,47 +453,47 @@ class oe {
253
453
  * </template>
254
454
  * ```
255
455
  */
256
- getTypeDefault(t) {
456
+ getTypeDefault(e) {
257
457
  if (!this.typeDefaults)
258
458
  return;
259
- const e = this.typeDefaults[t];
260
- if (!e)
459
+ const n = this.typeDefaults[e];
460
+ if (!n)
261
461
  return;
262
- const r = {
263
- editorParams: e.editorParams
462
+ const t = {
463
+ editorParams: n.editorParams
264
464
  };
265
- return e.renderer && (r.renderer = this.createTypeRenderer(e.renderer)), e.editor && (r.editor = this.createTypeEditor(e.editor)), r;
465
+ return n.renderer && (t.renderer = this.createTypeRenderer(n.renderer)), n.editor && (t.editor = this.createTypeEditor(n.editor)), t;
266
466
  }
267
467
  /**
268
468
  * Creates a renderer function from a Vue render function for type defaults.
269
469
  * @internal
270
470
  */
271
- createTypeRenderer(t) {
272
- return (e) => {
273
- const r = document.createElement("span");
274
- r.style.display = "contents";
275
- const i = g({
471
+ createTypeRenderer(e) {
472
+ return (n) => {
473
+ const t = document.createElement("span");
474
+ t.style.display = "contents";
475
+ const r = p({
276
476
  render() {
277
- return t(e);
477
+ return e(n);
278
478
  }
279
479
  });
280
- return i.mount(r), this.mountedViews.push({ app: i, container: r }), r;
480
+ return r.mount(t), this.mountedViews.push({ app: r, container: t }), t;
281
481
  };
282
482
  }
283
483
  /**
284
484
  * Creates an editor function from a Vue render function for type defaults.
285
485
  * @internal
286
486
  */
287
- createTypeEditor(t) {
288
- return (e) => {
289
- const r = document.createElement("span");
290
- r.style.display = "contents";
291
- const i = g({
487
+ createTypeEditor(e) {
488
+ return (n) => {
489
+ const t = document.createElement("span");
490
+ t.style.display = "contents";
491
+ const r = p({
292
492
  render() {
293
- return t(e);
493
+ return e(n);
294
494
  }
295
495
  });
296
- return i.mount(r), this.mountedViews.push({ app: i, container: r }), r;
496
+ return r.mount(t), this.mountedViews.push({ app: r, container: t }), t;
297
497
  };
298
498
  }
299
499
  // #endregion
@@ -301,15 +501,15 @@ class oe {
301
501
  * Cleanup all mounted Vue apps.
302
502
  */
303
503
  cleanup() {
304
- for (const { app: t, container: e } of this.mountedViews)
504
+ for (const { app: e, container: n } of this.mountedViews)
305
505
  try {
306
- t.unmount(), e.remove();
506
+ e.unmount(), n.remove();
307
507
  } catch {
308
508
  }
309
509
  this.mountedViews = [];
310
510
  }
311
511
  }
312
- const me = /* @__PURE__ */ p({
512
+ const pe = fe, Re = /* @__PURE__ */ y({
313
513
  __name: "TbwGrid",
314
514
  props: {
315
515
  /** Row data to display */
@@ -452,15 +652,15 @@ const me = /* @__PURE__ */ p({
452
652
  }
453
653
  },
454
654
  emits: ["cell-commit", "row-commit", "cell-click", "cell-dblclick", "selection-change", "row-toggle", "sort-change", "ready"],
455
- setup(n, { expose: t, emit: e }) {
456
- let r = !1, i = null;
457
- function a() {
458
- return r || (i = new oe(), K.registerAdapter(i), r = !0), i;
655
+ setup(i, { expose: e, emit: n }) {
656
+ let t = !1, r = null;
657
+ function s() {
658
+ return t || (r = new pe(), re.registerAdapter(r), t = !0), r;
459
659
  }
460
- a();
461
- const l = n, d = e, s = y(null);
462
- G(L, s);
463
- const c = q(), u = Q(), R = [
660
+ s();
661
+ const d = i, l = n, c = R(null);
662
+ L(H, c);
663
+ const a = J(), u = ie(), g = [
464
664
  "selection",
465
665
  "editing",
466
666
  "clipboard",
@@ -485,98 +685,115 @@ const me = /* @__PURE__ */ p({
485
685
  "pivot",
486
686
  "serverSide"
487
687
  ];
488
- function j() {
688
+ function h() {
489
689
  const o = [];
490
- for (const f of R) {
491
- const T = l[f];
492
- if (T !== void 0) {
493
- const C = J(f, T);
494
- C && o.push(C);
690
+ for (const f of g) {
691
+ const w = d[f];
692
+ if (w !== void 0) {
693
+ const m = oe(f, w);
694
+ m && o.push(m);
495
695
  }
496
696
  }
497
697
  return o;
498
698
  }
499
- const D = Y(() => {
500
- const o = l.gridConfig ?? {}, f = j(), T = o.plugins ?? [], C = [...f, ...T], W = u ? { ...o.icons, ...u } : o.icons;
699
+ const D = ne(() => {
700
+ const o = d.gridConfig ?? {}, f = h(), w = o.plugins ?? [], m = [...f, ...w], G = u ? { ...o.icons, ...u } : o.icons;
501
701
  return {
502
702
  ...o,
503
- ...l.columns ? { columns: l.columns } : {},
504
- ...C.length > 0 ? { plugins: C } : {},
505
- ...W ? { icons: W } : {}
703
+ ...d.columns ? { columns: d.columns } : {},
704
+ ...m.length > 0 ? { plugins: m } : {},
705
+ ...G ? { icons: G } : {}
506
706
  };
507
707
  });
508
- function S(o) {
509
- d("cell-commit", o);
708
+ function N(o) {
709
+ l("cell-commit", o);
510
710
  }
511
- function k(o) {
512
- d("row-commit", o);
711
+ function A(o) {
712
+ l("row-commit", o);
513
713
  }
514
- function P(o) {
515
- d("cell-click", o);
714
+ function F(o) {
715
+ l("cell-click", o);
516
716
  }
517
717
  function x(o) {
518
- d("cell-dblclick", o);
718
+ l("cell-dblclick", o);
519
719
  }
520
- function F(o) {
521
- d("selection-change", o);
720
+ function W(o) {
721
+ l("selection-change", o);
522
722
  }
523
- function A(o) {
524
- d("row-toggle", o);
723
+ function $(o) {
724
+ l("row-toggle", o);
725
+ }
726
+ function I(o) {
727
+ l("sort-change", o);
525
728
  }
526
- function M(o) {
527
- d("sort-change", o);
729
+ function z(o) {
730
+ l("ready", o);
528
731
  }
529
- function V(o) {
530
- d("ready", o);
732
+ function Z(o, f) {
733
+ const w = Object.getPrototypeOf(o), m = Object.getOwnPropertyDescriptor(w, "gridConfig");
734
+ if (!m?.set || !m?.get) return;
735
+ const G = m.set, te = m.get;
736
+ Object.defineProperty(o, "gridConfig", {
737
+ get() {
738
+ return te.call(this);
739
+ },
740
+ set(k) {
741
+ k && f ? G.call(this, f.processGridConfig(k)) : G.call(this, k);
742
+ },
743
+ configurable: !0
744
+ });
531
745
  }
532
- return b(() => {
533
- const o = s.value;
746
+ function ee(o) {
747
+ delete o.gridConfig;
748
+ }
749
+ return T(() => {
750
+ const o = c.value;
534
751
  if (!o) return;
535
- const f = a();
536
- o.__frameworkAdapter = f, f.setTypeDefaults(c ?? null), o.addEventListener("cell-commit", S), o.addEventListener("row-commit", k), o.addEventListener("cell-click", P), o.addEventListener("cell-dblclick", x), o.addEventListener("selection-change", F), o.addEventListener("row-toggle", A), o.addEventListener("sort-change", M), o.addEventListener("ready", V), l.rows.length > 0 && (o.rows = l.rows), D.value && (o.gridConfig = D.value), l.fitMode && (o.fitMode = l.fitMode);
537
- }), $(() => {
538
- const o = s.value;
539
- o && (o.removeEventListener("cell-commit", S), o.removeEventListener("row-commit", k), o.removeEventListener("cell-click", P), o.removeEventListener("cell-dblclick", x), o.removeEventListener("selection-change", F), o.removeEventListener("row-toggle", A), o.removeEventListener("sort-change", M), o.removeEventListener("ready", V));
752
+ const f = s();
753
+ o.__frameworkAdapter = f, f.setTypeDefaults(a ?? null), Z(o, f), o.addEventListener("cell-commit", N), o.addEventListener("row-commit", A), o.addEventListener("cell-click", F), o.addEventListener("cell-dblclick", x), o.addEventListener("selection-change", W), o.addEventListener("row-toggle", $), o.addEventListener("sort-change", I), o.addEventListener("ready", z), d.rows.length > 0 && (o.rows = d.rows), D.value && (o.gridConfig = D.value), d.fitMode && (o.fitMode = d.fitMode);
754
+ }), q(() => {
755
+ const o = c.value;
756
+ o && (ee(o), o.removeEventListener("cell-commit", N), o.removeEventListener("row-commit", A), o.removeEventListener("cell-click", F), o.removeEventListener("cell-dblclick", x), o.removeEventListener("selection-change", W), o.removeEventListener("row-toggle", $), o.removeEventListener("sort-change", I), o.removeEventListener("ready", z));
540
757
  }), B(
541
- () => l.rows,
758
+ () => d.rows,
542
759
  (o) => {
543
- s.value && (s.value.rows = o);
760
+ c.value && (c.value.rows = o);
544
761
  },
545
762
  { deep: !0 }
546
763
  ), B(
547
764
  D,
548
765
  (o) => {
549
- s.value && o && (s.value.gridConfig = o);
766
+ c.value && o && (c.value.gridConfig = o);
550
767
  },
551
768
  { deep: !0 }
552
769
  ), B(
553
- () => l.fitMode,
770
+ () => d.fitMode,
554
771
  (o) => {
555
- s.value && o && (s.value.fitMode = o);
772
+ c.value && o && (c.value.fitMode = o);
556
773
  }
557
774
  ), B(
558
- () => c,
775
+ () => a,
559
776
  (o) => {
560
- a().setTypeDefaults(o ?? null);
777
+ s().setTypeDefaults(o ?? null);
561
778
  },
562
779
  { deep: !0 }
563
- ), t({
780
+ ), e({
564
781
  /** The underlying grid element */
565
- gridElement: s,
782
+ gridElement: c,
566
783
  /** Force a layout recalculation */
567
- forceLayout: () => s.value?.forceLayout(),
784
+ forceLayout: () => c.value?.forceLayout(),
568
785
  /** Get current grid configuration */
569
- getConfig: () => s.value?.getConfig(),
786
+ getConfig: () => c.value?.getConfig(),
570
787
  /** Wait for grid to be ready */
571
- ready: () => s.value?.ready()
572
- }), (o, f) => (E(), w("tbw-grid", {
788
+ ready: () => c.value?.ready()
789
+ }), (o, f) => (_(), O("tbw-grid", {
573
790
  ref_key: "gridRef",
574
- ref: s
791
+ ref: c
575
792
  }, [
576
- I(o.$slots, "default")
793
+ U(o.$slots, "default")
577
794
  ], 512));
578
795
  }
579
- }), ie = ["field", "header", "width", "min-width", "max-width", "sortable", "resizable", "editable", "type", "align", "hidden"], ge = /* @__PURE__ */ p({
796
+ }), me = ["field", "header", "width", "min-width", "max-width", "sortable", "resizable", "editable", "type", "align", "hidden"], Te = /* @__PURE__ */ y({
580
797
  __name: "TbwGridColumn",
581
798
  props: {
582
799
  field: {},
@@ -591,87 +808,87 @@ const me = /* @__PURE__ */ p({
591
808
  align: {},
592
809
  hidden: { type: Boolean }
593
810
  },
594
- setup(n) {
595
- const t = _(), e = y(null);
596
- return b(() => {
597
- const r = e.value;
598
- if (!r) return;
599
- const i = !!t.cell, a = !!t.editor;
600
- i && ee(r, (l) => {
601
- const d = t.cell;
602
- if (!d) return h("span");
603
- const s = d({
604
- value: l.value,
605
- row: l.row,
606
- column: l.column
811
+ setup(i) {
812
+ const e = P(), n = R(null);
813
+ return T(() => {
814
+ const t = n.value;
815
+ if (!t) return;
816
+ const r = !!e.cell, s = !!e.editor;
817
+ r && le(t, (d) => {
818
+ const l = e.cell;
819
+ if (!l) return C("span");
820
+ const c = l({
821
+ value: d.value,
822
+ row: d.row,
823
+ column: d.column
607
824
  });
608
- return h("div", { style: "display: contents" }, s);
609
- }), a && te(r, (l) => {
610
- const d = t.editor;
611
- if (!d) return h("span");
612
- const s = d({
613
- value: l.value,
614
- row: l.row,
615
- column: l.column,
616
- commit: l.commit,
617
- cancel: l.cancel
825
+ return C("div", { style: "display: contents" }, c);
826
+ }), s && ce(t, (d) => {
827
+ const l = e.editor;
828
+ if (!l) return C("span");
829
+ const c = l({
830
+ value: d.value,
831
+ row: d.row,
832
+ column: d.column,
833
+ commit: d.commit,
834
+ cancel: d.cancel
618
835
  });
619
- return h("div", { style: "display: contents" }, s);
836
+ return C("div", { style: "display: contents" }, c);
620
837
  });
621
- }), (r, i) => (E(), w("tbw-grid-column", {
838
+ }), (t, r) => (_(), O("tbw-grid-column", {
622
839
  ref_key: "columnRef",
623
- ref: e,
624
- field: n.field,
625
- header: n.header,
626
- width: n.width,
627
- "min-width": n.minWidth,
628
- "max-width": n.maxWidth,
629
- sortable: n.sortable,
630
- resizable: n.resizable,
631
- editable: n.editable,
632
- type: n.type,
633
- align: n.align,
634
- hidden: n.hidden
635
- }, null, 8, ie));
636
- }
637
- }), le = ["show-expand-column", "animation"], ve = /* @__PURE__ */ p({
840
+ ref: n,
841
+ field: i.field,
842
+ header: i.header,
843
+ width: i.width,
844
+ "min-width": i.minWidth,
845
+ "max-width": i.maxWidth,
846
+ sortable: i.sortable,
847
+ resizable: i.resizable,
848
+ editable: i.editable,
849
+ type: i.type,
850
+ align: i.align,
851
+ hidden: i.hidden
852
+ }, null, 8, me));
853
+ }
854
+ }), ge = ["show-expand-column", "animation"], Oe = /* @__PURE__ */ y({
638
855
  __name: "TbwGridDetailPanel",
639
856
  props: {
640
857
  showExpandColumn: { type: Boolean, default: !0 },
641
858
  animation: { type: [String, Boolean], default: "slide" }
642
859
  },
643
- setup(n) {
644
- const t = y(null), e = _();
645
- return b(() => {
646
- const r = t.value;
647
- !r || !e.default || U.set(r, (i) => e.default?.(i));
648
- }), (r, i) => (E(), w("tbw-grid-detail", {
860
+ setup(i) {
861
+ const e = R(null), n = P();
862
+ return T(() => {
863
+ const t = e.value;
864
+ !t || !n.default || Q.set(t, (r) => n.default?.(r));
865
+ }), (t, r) => (_(), O("tbw-grid-detail", {
649
866
  ref_key: "detailRef",
650
- ref: t,
651
- "show-expand-column": n.showExpandColumn,
652
- animation: n.animation
653
- }, null, 8, le));
867
+ ref: e,
868
+ "show-expand-column": i.showExpandColumn,
869
+ animation: i.animation
870
+ }, null, 8, ge));
654
871
  }
655
- }), ye = /* @__PURE__ */ p({
872
+ }), _e = /* @__PURE__ */ y({
656
873
  __name: "TbwGridResponsiveCard",
657
- setup(n) {
658
- const t = y(null), e = _();
659
- return b(() => {
660
- const r = t.value;
661
- !r || !e.default || H.set(r, (i) => e.default?.(i));
662
- }), (r, i) => (E(), w("tbw-grid-responsive-card", {
874
+ setup(i) {
875
+ const e = R(null), n = P();
876
+ return T(() => {
877
+ const t = e.value;
878
+ !t || !n.default || X.set(t, (r) => n.default?.(r));
879
+ }), (t, r) => (_(), O("tbw-grid-responsive-card", {
663
880
  ref_key: "cardRef",
664
- ref: t
881
+ ref: e
665
882
  }, null, 512));
666
883
  }
667
- }), he = /* @__PURE__ */ p({
884
+ }), De = /* @__PURE__ */ y({
668
885
  __name: "TbwGridToolButtons",
669
- setup(n) {
670
- return (t, e) => (E(), w("tbw-grid-tool-buttons", null, [
671
- I(t.$slots, "default")
886
+ setup(i) {
887
+ return (e, n) => (_(), O("tbw-grid-tool-buttons", null, [
888
+ U(e.$slots, "default")
672
889
  ]));
673
890
  }
674
- }), de = /* @__PURE__ */ new WeakMap(), se = ["id", "label", "icon", "position", "width"], be = /* @__PURE__ */ p({
891
+ }), ye = /* @__PURE__ */ new WeakMap(), ve = ["id", "label", "icon", "position", "width"], Ge = /* @__PURE__ */ y({
675
892
  __name: "TbwGridToolPanel",
676
893
  props: {
677
894
  id: {},
@@ -680,35 +897,35 @@ const me = /* @__PURE__ */ p({
680
897
  position: { default: "right" },
681
898
  width: { default: "250px" }
682
899
  },
683
- setup(n) {
684
- const t = y(null), e = _();
685
- return b(() => {
686
- const r = t.value;
687
- !r || !e.default || de.set(r, (i) => e.default?.(i));
688
- }), (r, i) => (E(), w("tbw-grid-tool-panel", {
900
+ setup(i) {
901
+ const e = R(null), n = P();
902
+ return T(() => {
903
+ const t = e.value;
904
+ !t || !n.default || ye.set(t, (r) => n.default?.(r));
905
+ }), (t, r) => (_(), O("tbw-grid-tool-panel", {
689
906
  ref_key: "panelRef",
690
- ref: t,
691
- id: n.id,
692
- label: n.label,
693
- icon: n.icon,
694
- position: n.position,
695
- width: n.width
696
- }, null, 8, se));
907
+ ref: e,
908
+ id: i.id,
909
+ label: i.label,
910
+ icon: i.icon,
911
+ position: i.position,
912
+ width: i.width
913
+ }, null, 8, ve));
697
914
  }
698
915
  });
699
- function we(n, t, e) {
700
- const r = e ?? O(L, y(null));
701
- let i = null;
702
- b(() => {
703
- const a = r.value;
704
- if (!a) return;
705
- const l = t;
706
- a.addEventListener(n, l), i = () => a.removeEventListener(n, l);
707
- }), $(() => {
708
- i?.();
916
+ function je(i, e, n) {
917
+ const t = n ?? M(H, R(null));
918
+ let r = null;
919
+ T(() => {
920
+ const s = t.value;
921
+ if (!s) return;
922
+ const d = e;
923
+ s.addEventListener(i, d), r = () => s.removeEventListener(i, d);
924
+ }), q(() => {
925
+ r?.();
709
926
  });
710
927
  }
711
- const Ee = p({
928
+ const Be = y({
712
929
  name: "GridProvider",
713
930
  props: {
714
931
  /**
@@ -726,37 +943,39 @@ const Ee = p({
726
943
  default: void 0
727
944
  }
728
945
  },
729
- setup(n, { slots: t }) {
946
+ setup(i, { slots: e }) {
730
947
  return () => {
731
- let e = t.default?.();
732
- return n.typeDefaults && (e = h(Z, { defaults: n.typeDefaults }, () => e)), n.icons && (e = h(X, { icons: n.icons }, () => e)), e;
948
+ let n = e.default?.();
949
+ return i.typeDefaults && (n = C(de, { defaults: i.typeDefaults }, () => n)), i.icons && (n = C(se, { icons: i.icons }, () => n)), n;
733
950
  };
734
951
  }
735
952
  });
736
953
  export {
737
- L as GRID_ELEMENT_KEY,
738
- z as GRID_ICONS,
739
- N as GRID_TYPE_DEFAULTS,
740
- X as GridIconProvider,
741
- Ee as GridProvider,
742
- Z as GridTypeProvider,
743
- me as TbwGrid,
744
- ge as TbwGridColumn,
745
- ve as TbwGridDetailPanel,
746
- ye as TbwGridResponsiveCard,
747
- he as TbwGridToolButtons,
748
- be as TbwGridToolPanel,
749
- oe as VueGridAdapter,
750
- Te as clearFeatureRegistry,
751
- J as createPluginFromFeature,
752
- Be as getFeatureFactory,
753
- Oe as getRegisteredFeatures,
754
- _e as isFeatureRegistered,
755
- je as registerFeature,
756
- pe as useGrid,
757
- we as useGridEvent,
758
- Q as useGridIcons,
759
- q as useGridTypeDefaults,
760
- fe as useTypeDefault
954
+ H as GRID_ELEMENT_KEY,
955
+ K as GRID_ICONS,
956
+ Y as GRID_TYPE_DEFAULTS,
957
+ fe as GridAdapter,
958
+ se as GridIconProvider,
959
+ Be as GridProvider,
960
+ de as GridTypeProvider,
961
+ Re as TbwGrid,
962
+ Te as TbwGridColumn,
963
+ Oe as TbwGridDetailPanel,
964
+ _e as TbwGridResponsiveCard,
965
+ De as TbwGridToolButtons,
966
+ Ge as TbwGridToolPanel,
967
+ pe as VueGridAdapter,
968
+ ke as clearFeatureRegistry,
969
+ oe as createPluginFromFeature,
970
+ Ve as getFeatureFactory,
971
+ Le as getRegisteredFeatures,
972
+ Me as isFeatureRegistered,
973
+ j as isVueComponent,
974
+ Ne as registerFeature,
975
+ Fe as useGrid,
976
+ je as useGridEvent,
977
+ ie as useGridIcons,
978
+ J as useGridTypeDefaults,
979
+ Ce as useTypeDefault
761
980
  };
762
981
  //# sourceMappingURL=index.js.map