@toolbox-web/grid-vue 0.3.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,14 +1,14 @@
1
- import { defineComponent as p, provide as j, inject as D, createApp as g, ref as h, computed as Y, onMounted as b, onBeforeUnmount as W, watch as B, createElementBlock as w, openBlock as E, renderSlot as $, useSlots as G, h as y } 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 Be, g as Ge, b as Oe, i as _e, r as je } from "./chunks/feature-registry-BgEOysSJ.js";
5
- import { G as I } from "./chunks/use-grid-DwjXrO19.js";
6
- import { u as ke } from "./chunks/use-grid-DwjXrO19.js";
7
- const z = /* @__PURE__ */ Symbol("grid-icons");
8
- function Q() {
9
- return D(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);
10
10
  }
11
- const X = p({
11
+ const se = y({
12
12
  name: "GridIconProvider",
13
13
  props: {
14
14
  /**
@@ -19,17 +19,17 @@ const X = p({
19
19
  required: !0
20
20
  }
21
21
  },
22
- setup(o, { slots: t }) {
23
- return j(z, o.icons), () => t.default?.();
22
+ setup(i, { slots: e }) {
23
+ return L(K, i.icons), () => e.default?.();
24
24
  }
25
- }), N = /* @__PURE__ */ Symbol("grid-type-defaults");
26
- function q() {
27
- return D(N, void 0);
25
+ }), Y = /* @__PURE__ */ Symbol("grid-type-defaults");
26
+ function J() {
27
+ return M(Y, void 0);
28
28
  }
29
- function me(o) {
30
- return q()?.[o];
29
+ function Ce(i) {
30
+ return J()?.[i];
31
31
  }
32
- const Z = p({
32
+ const de = y({
33
33
  name: "GridTypeProvider",
34
34
  props: {
35
35
  /**
@@ -40,175 +40,388 @@ const Z = p({
40
40
  required: !0
41
41
  }
42
42
  },
43
- setup(o, { slots: t }) {
44
- return j(N, o.defaults), () => t.default?.();
43
+ setup(i, { slots: e }) {
44
+ return L(Y, i.defaults), () => e.default?.();
45
45
  }
46
- }), U = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new Map();
47
- function ee(o, t) {
48
- const e = o.getAttribute("field"), n = m.get(o) ?? {};
49
- if (n.renderer = t, m.set(o, n), e) {
50
- const i = v.get(e) ?? {};
51
- i.renderer = t, v.set(e, i);
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
52
  }
53
53
  }
54
- function te(o, t) {
55
- const e = o.getAttribute("field"), n = m.get(o) ?? {};
56
- if (n.editor = t, m.set(o, n), e) {
57
- const i = v.get(e) ?? {};
58
- i.editor = 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);
59
59
  }
60
60
  }
61
- function ne(o) {
62
- let t = m.get(o)?.renderer;
63
- if (!t) {
64
- const e = o.getAttribute("field");
65
- e && (t = v.get(e)?.renderer);
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);
66
66
  }
67
- return t;
67
+ return e;
68
68
  }
69
- function re(o) {
70
- let t = m.get(o)?.editor;
71
- if (!t) {
72
- const e = o.getAttribute("field");
73
- e && (t = v.get(e)?.editor);
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);
74
74
  }
75
- return t;
75
+ return e;
76
76
  }
77
- class oe {
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;
89
+ }
90
+ return !1;
91
+ }
92
+ function S(i) {
93
+ return typeof i == "function" && !j(i);
94
+ }
95
+ const E = /* @__PURE__ */ Symbol.for("tbw:vue-processed");
96
+ class fe {
78
97
  mountedViews = [];
79
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
80
293
  /**
81
294
  * Sets the type defaults map for this adapter.
82
295
  * Called by TbwGrid when it receives type defaults from context.
83
296
  *
84
297
  * @internal
85
298
  */
86
- setTypeDefaults(t) {
87
- this.typeDefaults = t;
299
+ setTypeDefaults(e) {
300
+ this.typeDefaults = e;
88
301
  }
89
302
  /**
90
303
  * Determines if this adapter can handle the given element.
91
304
  * Checks if a renderer or editor is registered for this element.
92
305
  */
93
- canHandle(t) {
94
- const e = t.getAttribute("field");
95
- let n = m.get(t);
96
- if (!n && e) {
97
- const l = v.get(e);
98
- l && (l.renderer || l.editor) && (n = l, m.set(t, n));
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));
99
312
  }
100
- const i = n?.renderer !== void 0, a = n?.editor !== void 0;
101
- return n !== void 0 && (i || a);
313
+ const r = t?.renderer !== void 0, s = t?.editor !== void 0;
314
+ return t !== void 0 && (r || s);
102
315
  }
103
316
  /**
104
317
  * Creates a view renderer function that renders a Vue component
105
318
  * and returns its container DOM element.
106
319
  */
107
- createRenderer(t) {
108
- const e = ne(t);
109
- if (!e)
320
+ createRenderer(e) {
321
+ const n = ae(e);
322
+ if (!n)
110
323
  return;
111
- const n = /* @__PURE__ */ new WeakMap();
112
- return (i) => {
113
- const a = i.cellEl;
114
- if (a) {
115
- const s = n.get(a);
116
- if (s)
117
- return s.update(i), s.container;
118
- const c = document.createElement("div");
119
- c.className = "vue-cell-renderer", c.style.display = "contents";
120
- let u = i;
121
- 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({
122
335
  render() {
123
- return e(u);
336
+ return n(u);
124
337
  }
125
338
  });
126
- return R.mount(c), n.set(a, {
127
- app: R,
128
- container: c,
129
- update: (O) => {
130
- u = O, 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();
131
344
  }
132
- }), c;
345
+ }), a;
133
346
  }
134
- const l = document.createElement("div");
135
- l.className = "vue-cell-renderer", l.style.display = "contents";
136
- const d = g({
347
+ const d = document.createElement("div");
348
+ d.className = "vue-cell-renderer", d.style.display = "contents";
349
+ const l = p({
137
350
  render() {
138
- return e(i);
351
+ return n(r);
139
352
  }
140
353
  });
141
- 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;
142
355
  };
143
356
  }
144
357
  /**
145
358
  * Creates an editor spec that renders a Vue component for cell editing.
146
359
  * Returns a function that creates the editor DOM element.
147
360
  */
148
- createEditor(t) {
149
- const e = re(t);
150
- if (e)
151
- return (n) => {
152
- const i = document.createElement("div");
153
- i.className = "vue-cell-editor", i.style.display = "contents";
154
- 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({
155
368
  render() {
156
- return e(n);
369
+ return n(t);
157
370
  }
158
371
  });
159
- 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;
160
373
  };
161
374
  }
162
375
  /**
163
376
  * Framework adapter hook called by MasterDetailPlugin during attach().
164
377
  * Parses the <tbw-grid-detail> element and returns a Vue-based renderer.
165
378
  */
166
- parseDetailElement(t) {
167
- const e = t.closest("tbw-grid");
168
- if (!e) return;
169
- const n = e.querySelector("tbw-grid-detail");
379
+ parseDetailElement(e) {
380
+ const n = e.closest("tbw-grid");
170
381
  if (!n) return;
171
- const i = U.get(n);
172
- if (i)
173
- return (a, l) => {
174
- const d = document.createElement("div");
175
- d.className = "vue-detail-panel";
176
- const c = i({ row: a, rowIndex: l });
177
- if (c && c.length > 0) {
178
- const u = g({
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({
179
392
  render() {
180
- return c;
393
+ return a;
181
394
  }
182
395
  });
183
- u.mount(d), this.mountedViews.push({ app: u, container: d });
396
+ u.mount(l), this.mountedViews.push({ app: u, container: l });
184
397
  }
185
- return d;
398
+ return l;
186
399
  };
187
400
  }
188
401
  /**
189
402
  * Framework adapter hook called by ResponsivePlugin during attach().
190
403
  * Parses the <tbw-grid-responsive-card> element and returns a Vue-based renderer.
191
404
  */
192
- parseResponsiveCardElement(t) {
193
- const e = t.closest("tbw-grid");
194
- if (!e) return;
195
- const n = e.querySelector("tbw-grid-responsive-card");
405
+ parseResponsiveCardElement(e) {
406
+ const n = e.closest("tbw-grid");
196
407
  if (!n) return;
197
- const i = H.get(n);
198
- if (i)
199
- return (a, l) => {
200
- const d = document.createElement("div");
201
- d.className = "vue-responsive-card";
202
- const c = i({ row: a, rowIndex: l });
203
- if (c && c.length > 0) {
204
- const u = g({
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({
205
418
  render() {
206
- return c;
419
+ return a;
207
420
  }
208
421
  });
209
- u.mount(d), this.mountedViews.push({ app: u, container: d });
422
+ u.mount(l), this.mountedViews.push({ app: u, container: l });
210
423
  }
211
- return d;
424
+ return l;
212
425
  };
213
426
  }
214
427
  // #region Type Defaults Support
@@ -240,47 +453,47 @@ class oe {
240
453
  * </template>
241
454
  * ```
242
455
  */
243
- getTypeDefault(t) {
456
+ getTypeDefault(e) {
244
457
  if (!this.typeDefaults)
245
458
  return;
246
- const e = this.typeDefaults[t];
247
- if (!e)
459
+ const n = this.typeDefaults[e];
460
+ if (!n)
248
461
  return;
249
- const n = {
250
- editorParams: e.editorParams
462
+ const t = {
463
+ editorParams: n.editorParams
251
464
  };
252
- return e.renderer && (n.renderer = this.createTypeRenderer(e.renderer)), e.editor && (n.editor = this.createTypeEditor(e.editor)), n;
465
+ return n.renderer && (t.renderer = this.createTypeRenderer(n.renderer)), n.editor && (t.editor = this.createTypeEditor(n.editor)), t;
253
466
  }
254
467
  /**
255
468
  * Creates a renderer function from a Vue render function for type defaults.
256
469
  * @internal
257
470
  */
258
- createTypeRenderer(t) {
259
- return (e) => {
260
- const n = document.createElement("span");
261
- n.style.display = "contents";
262
- const i = g({
471
+ createTypeRenderer(e) {
472
+ return (n) => {
473
+ const t = document.createElement("span");
474
+ t.style.display = "contents";
475
+ const r = p({
263
476
  render() {
264
- return t(e);
477
+ return e(n);
265
478
  }
266
479
  });
267
- return i.mount(n), this.mountedViews.push({ app: i, container: n }), n;
480
+ return r.mount(t), this.mountedViews.push({ app: r, container: t }), t;
268
481
  };
269
482
  }
270
483
  /**
271
484
  * Creates an editor function from a Vue render function for type defaults.
272
485
  * @internal
273
486
  */
274
- createTypeEditor(t) {
275
- return (e) => {
276
- const n = document.createElement("span");
277
- n.style.display = "contents";
278
- const i = g({
487
+ createTypeEditor(e) {
488
+ return (n) => {
489
+ const t = document.createElement("span");
490
+ t.style.display = "contents";
491
+ const r = p({
279
492
  render() {
280
- return t(e);
493
+ return e(n);
281
494
  }
282
495
  });
283
- return i.mount(n), this.mountedViews.push({ app: i, container: n }), n;
496
+ return r.mount(t), this.mountedViews.push({ app: r, container: t }), t;
284
497
  };
285
498
  }
286
499
  // #endregion
@@ -288,15 +501,15 @@ class oe {
288
501
  * Cleanup all mounted Vue apps.
289
502
  */
290
503
  cleanup() {
291
- for (const { app: t, container: e } of this.mountedViews)
504
+ for (const { app: e, container: n } of this.mountedViews)
292
505
  try {
293
- t.unmount(), e.remove();
506
+ e.unmount(), n.remove();
294
507
  } catch {
295
508
  }
296
509
  this.mountedViews = [];
297
510
  }
298
511
  }
299
- const ie = oe, ge = /* @__PURE__ */ p({
512
+ const pe = fe, Re = /* @__PURE__ */ y({
300
513
  __name: "TbwGrid",
301
514
  props: {
302
515
  /** Row data to display */
@@ -439,15 +652,15 @@ const ie = oe, ge = /* @__PURE__ */ p({
439
652
  }
440
653
  },
441
654
  emits: ["cell-commit", "row-commit", "cell-click", "cell-dblclick", "selection-change", "row-toggle", "sort-change", "ready"],
442
- setup(o, { expose: t, emit: e }) {
443
- let n = !1, i = null;
444
- function a() {
445
- return n || (i = new ie(), K.registerAdapter(i), n = !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;
446
659
  }
447
- a();
448
- const l = o, d = e, s = h(null);
449
- j(I, s);
450
- 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 = [
451
664
  "selection",
452
665
  "editing",
453
666
  "clipboard",
@@ -472,98 +685,115 @@ const ie = oe, ge = /* @__PURE__ */ p({
472
685
  "pivot",
473
686
  "serverSide"
474
687
  ];
475
- function O() {
476
- const r = [];
477
- for (const f of R) {
478
- const T = l[f];
479
- if (T !== void 0) {
480
- const C = J(f, T);
481
- C && r.push(C);
688
+ function h() {
689
+ const o = [];
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);
482
695
  }
483
696
  }
484
- return r;
697
+ return o;
485
698
  }
486
- const _ = Y(() => {
487
- const r = l.gridConfig ?? {}, f = O(), T = r.plugins ?? [], C = [...f, ...T], V = u ? { ...r.icons, ...u } : r.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;
488
701
  return {
489
- ...r,
490
- ...l.columns ? { columns: l.columns } : {},
491
- ...C.length > 0 ? { plugins: C } : {},
492
- ...V ? { icons: V } : {}
702
+ ...o,
703
+ ...d.columns ? { columns: d.columns } : {},
704
+ ...m.length > 0 ? { plugins: m } : {},
705
+ ...G ? { icons: G } : {}
493
706
  };
494
707
  });
495
- function k(r) {
496
- d("cell-commit", r);
708
+ function N(o) {
709
+ l("cell-commit", o);
710
+ }
711
+ function A(o) {
712
+ l("row-commit", o);
497
713
  }
498
- function S(r) {
499
- d("row-commit", r);
714
+ function F(o) {
715
+ l("cell-click", o);
500
716
  }
501
- function L(r) {
502
- d("cell-click", r);
717
+ function x(o) {
718
+ l("cell-dblclick", o);
503
719
  }
504
- function P(r) {
505
- d("cell-dblclick", r);
720
+ function W(o) {
721
+ l("selection-change", o);
506
722
  }
507
- function x(r) {
508
- d("selection-change", r);
723
+ function $(o) {
724
+ l("row-toggle", o);
509
725
  }
510
- function A(r) {
511
- d("row-toggle", r);
726
+ function I(o) {
727
+ l("sort-change", o);
512
728
  }
513
- function F(r) {
514
- d("sort-change", r);
729
+ function z(o) {
730
+ l("ready", o);
515
731
  }
516
- function M(r) {
517
- d("ready", r);
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
+ });
518
745
  }
519
- return b(() => {
520
- const r = s.value;
521
- if (!r) return;
522
- const f = a();
523
- r.__frameworkAdapter = f, f.setTypeDefaults(c ?? null), r.addEventListener("cell-commit", k), r.addEventListener("row-commit", S), r.addEventListener("cell-click", L), r.addEventListener("cell-dblclick", P), r.addEventListener("selection-change", x), r.addEventListener("row-toggle", A), r.addEventListener("sort-change", F), r.addEventListener("ready", M), l.rows.length > 0 && (r.rows = l.rows), _.value && (r.gridConfig = _.value), l.fitMode && (r.fitMode = l.fitMode);
524
- }), W(() => {
525
- const r = s.value;
526
- r && (r.removeEventListener("cell-commit", k), r.removeEventListener("row-commit", S), r.removeEventListener("cell-click", L), r.removeEventListener("cell-dblclick", P), r.removeEventListener("selection-change", x), r.removeEventListener("row-toggle", A), r.removeEventListener("sort-change", F), r.removeEventListener("ready", M));
746
+ function ee(o) {
747
+ delete o.gridConfig;
748
+ }
749
+ return T(() => {
750
+ const o = c.value;
751
+ if (!o) return;
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));
527
757
  }), B(
528
- () => l.rows,
529
- (r) => {
530
- s.value && (s.value.rows = r);
758
+ () => d.rows,
759
+ (o) => {
760
+ c.value && (c.value.rows = o);
531
761
  },
532
762
  { deep: !0 }
533
763
  ), B(
534
- _,
535
- (r) => {
536
- s.value && r && (s.value.gridConfig = r);
764
+ D,
765
+ (o) => {
766
+ c.value && o && (c.value.gridConfig = o);
537
767
  },
538
768
  { deep: !0 }
539
769
  ), B(
540
- () => l.fitMode,
541
- (r) => {
542
- s.value && r && (s.value.fitMode = r);
770
+ () => d.fitMode,
771
+ (o) => {
772
+ c.value && o && (c.value.fitMode = o);
543
773
  }
544
774
  ), B(
545
- () => c,
546
- (r) => {
547
- a().setTypeDefaults(r ?? null);
775
+ () => a,
776
+ (o) => {
777
+ s().setTypeDefaults(o ?? null);
548
778
  },
549
779
  { deep: !0 }
550
- ), t({
780
+ ), e({
551
781
  /** The underlying grid element */
552
- gridElement: s,
782
+ gridElement: c,
553
783
  /** Force a layout recalculation */
554
- forceLayout: () => s.value?.forceLayout(),
784
+ forceLayout: () => c.value?.forceLayout(),
555
785
  /** Get current grid configuration */
556
- getConfig: () => s.value?.getConfig(),
786
+ getConfig: () => c.value?.getConfig(),
557
787
  /** Wait for grid to be ready */
558
- ready: () => s.value?.ready()
559
- }), (r, f) => (E(), w("tbw-grid", {
788
+ ready: () => c.value?.ready()
789
+ }), (o, f) => (_(), O("tbw-grid", {
560
790
  ref_key: "gridRef",
561
- ref: s
791
+ ref: c
562
792
  }, [
563
- $(r.$slots, "default")
793
+ U(o.$slots, "default")
564
794
  ], 512));
565
795
  }
566
- }), le = ["field", "header", "width", "min-width", "max-width", "sortable", "resizable", "editable", "type", "align", "hidden"], ve = /* @__PURE__ */ p({
796
+ }), me = ["field", "header", "width", "min-width", "max-width", "sortable", "resizable", "editable", "type", "align", "hidden"], Te = /* @__PURE__ */ y({
567
797
  __name: "TbwGridColumn",
568
798
  props: {
569
799
  field: {},
@@ -578,87 +808,87 @@ const ie = oe, ge = /* @__PURE__ */ p({
578
808
  align: {},
579
809
  hidden: { type: Boolean }
580
810
  },
581
- setup(o) {
582
- const t = G(), e = h(null);
583
- return b(() => {
584
- const n = e.value;
585
- if (!n) return;
586
- const i = !!t.cell, a = !!t.editor;
587
- i && ee(n, (l) => {
588
- const d = t.cell;
589
- if (!d) return y("span");
590
- const s = d({
591
- value: l.value,
592
- row: l.row,
593
- 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
594
824
  });
595
- return y("div", { style: "display: contents" }, s);
596
- }), a && te(n, (l) => {
597
- const d = t.editor;
598
- if (!d) return y("span");
599
- const s = d({
600
- value: l.value,
601
- row: l.row,
602
- column: l.column,
603
- commit: l.commit,
604
- 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
605
835
  });
606
- return y("div", { style: "display: contents" }, s);
836
+ return C("div", { style: "display: contents" }, c);
607
837
  });
608
- }), (n, i) => (E(), w("tbw-grid-column", {
838
+ }), (t, r) => (_(), O("tbw-grid-column", {
609
839
  ref_key: "columnRef",
610
- ref: e,
611
- field: o.field,
612
- header: o.header,
613
- width: o.width,
614
- "min-width": o.minWidth,
615
- "max-width": o.maxWidth,
616
- sortable: o.sortable,
617
- resizable: o.resizable,
618
- editable: o.editable,
619
- type: o.type,
620
- align: o.align,
621
- hidden: o.hidden
622
- }, null, 8, le));
623
- }
624
- }), de = ["show-expand-column", "animation"], ye = /* @__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({
625
855
  __name: "TbwGridDetailPanel",
626
856
  props: {
627
857
  showExpandColumn: { type: Boolean, default: !0 },
628
858
  animation: { type: [String, Boolean], default: "slide" }
629
859
  },
630
- setup(o) {
631
- const t = h(null), e = G();
632
- return b(() => {
633
- const n = t.value;
634
- !n || !e.default || U.set(n, (i) => e.default?.(i));
635
- }), (n, 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", {
636
866
  ref_key: "detailRef",
637
- ref: t,
638
- "show-expand-column": o.showExpandColumn,
639
- animation: o.animation
640
- }, null, 8, de));
867
+ ref: e,
868
+ "show-expand-column": i.showExpandColumn,
869
+ animation: i.animation
870
+ }, null, 8, ge));
641
871
  }
642
- }), he = /* @__PURE__ */ p({
872
+ }), _e = /* @__PURE__ */ y({
643
873
  __name: "TbwGridResponsiveCard",
644
- setup(o) {
645
- const t = h(null), e = G();
646
- return b(() => {
647
- const n = t.value;
648
- !n || !e.default || H.set(n, (i) => e.default?.(i));
649
- }), (n, 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", {
650
880
  ref_key: "cardRef",
651
- ref: t
881
+ ref: e
652
882
  }, null, 512));
653
883
  }
654
- }), be = /* @__PURE__ */ p({
884
+ }), De = /* @__PURE__ */ y({
655
885
  __name: "TbwGridToolButtons",
656
- setup(o) {
657
- return (t, e) => (E(), w("tbw-grid-tool-buttons", null, [
658
- $(t.$slots, "default")
886
+ setup(i) {
887
+ return (e, n) => (_(), O("tbw-grid-tool-buttons", null, [
888
+ U(e.$slots, "default")
659
889
  ]));
660
890
  }
661
- }), se = /* @__PURE__ */ new WeakMap(), ae = ["id", "label", "icon", "position", "width"], we = /* @__PURE__ */ p({
891
+ }), ye = /* @__PURE__ */ new WeakMap(), ve = ["id", "label", "icon", "position", "width"], Ge = /* @__PURE__ */ y({
662
892
  __name: "TbwGridToolPanel",
663
893
  props: {
664
894
  id: {},
@@ -667,35 +897,35 @@ const ie = oe, ge = /* @__PURE__ */ p({
667
897
  position: { default: "right" },
668
898
  width: { default: "250px" }
669
899
  },
670
- setup(o) {
671
- const t = h(null), e = G();
672
- return b(() => {
673
- const n = t.value;
674
- !n || !e.default || se.set(n, (i) => e.default?.(i));
675
- }), (n, 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", {
676
906
  ref_key: "panelRef",
677
- ref: t,
678
- id: o.id,
679
- label: o.label,
680
- icon: o.icon,
681
- position: o.position,
682
- width: o.width
683
- }, null, 8, ae));
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));
684
914
  }
685
915
  });
686
- function Ee(o, t, e) {
687
- const n = e ?? D(I, h(null));
688
- let i = null;
689
- b(() => {
690
- const a = n.value;
691
- if (!a) return;
692
- const l = t;
693
- a.addEventListener(o, l), i = () => a.removeEventListener(o, l);
694
- }), W(() => {
695
- 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?.();
696
926
  });
697
927
  }
698
- const Re = p({
928
+ const Be = y({
699
929
  name: "GridProvider",
700
930
  props: {
701
931
  /**
@@ -713,38 +943,39 @@ const Re = p({
713
943
  default: void 0
714
944
  }
715
945
  },
716
- setup(o, { slots: t }) {
946
+ setup(i, { slots: e }) {
717
947
  return () => {
718
- let e = t.default?.();
719
- return o.typeDefaults && (e = y(Z, { defaults: o.typeDefaults }, () => e)), o.icons && (e = y(X, { icons: o.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;
720
950
  };
721
951
  }
722
952
  });
723
953
  export {
724
- I as GRID_ELEMENT_KEY,
725
- z as GRID_ICONS,
726
- N as GRID_TYPE_DEFAULTS,
727
- oe as GridAdapter,
728
- X as GridIconProvider,
729
- Re as GridProvider,
730
- Z as GridTypeProvider,
731
- ge as TbwGrid,
732
- ve as TbwGridColumn,
733
- ye as TbwGridDetailPanel,
734
- he as TbwGridResponsiveCard,
735
- be as TbwGridToolButtons,
736
- we as TbwGridToolPanel,
737
- ie as VueGridAdapter,
738
- Be as clearFeatureRegistry,
739
- J as createPluginFromFeature,
740
- Ge as getFeatureFactory,
741
- Oe as getRegisteredFeatures,
742
- _e as isFeatureRegistered,
743
- je as registerFeature,
744
- ke as useGrid,
745
- Ee as useGridEvent,
746
- Q as useGridIcons,
747
- q as useGridTypeDefaults,
748
- me 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
749
980
  };
750
981
  //# sourceMappingURL=index.js.map