@stonecrop/atable 0.2.5 → 0.2.7

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/dist/atable.js DELETED
@@ -1,775 +0,0 @@
1
- import { onMounted as xe, onBeforeUnmount as _e, ref as E, watch as j, unref as r, getCurrentScope as Ie, onScopeDispose as Ee, defineComponent as k, inject as O, computed as S, openBlock as m, createElementBlock as b, createBlock as P, resolveDynamicComponent as ie, mergeProps as V, toDisplayString as $, Fragment as L, createElementVNode as T, renderSlot as y, createCommentVNode as M, useCssVars as de, withDirectives as ce, vShow as ue, reactive as A, renderList as N, normalizeStyle as H, createTextVNode as ke, provide as Ce, nextTick as Ae, createVNode as z, withCtx as G } from "vue";
2
- var J;
3
- const pe = typeof window < "u", Te = (t) => typeof t == "string", $e = () => {
4
- };
5
- pe && (J = window == null ? void 0 : window.navigator) != null && J.userAgent && /iP(ad|hone|od)/.test(window.navigator.userAgent);
6
- function fe(t) {
7
- return typeof t == "function" ? t() : r(t);
8
- }
9
- function Oe(t) {
10
- return t;
11
- }
12
- function De(t) {
13
- return Ie() ? (Ee(t), !0) : !1;
14
- }
15
- function U(t) {
16
- var e;
17
- const n = fe(t);
18
- return (e = n == null ? void 0 : n.$el) != null ? e : n;
19
- }
20
- const me = pe ? window : void 0;
21
- function Re(...t) {
22
- let e, n, o, a;
23
- if (Te(t[0]) || Array.isArray(t[0]) ? ([n, o, a] = t, e = me) : [e, n, o, a] = t, !e)
24
- return $e;
25
- Array.isArray(n) || (n = [n]), Array.isArray(o) || (o = [o]);
26
- const l = [], s = () => {
27
- l.forEach((f) => f()), l.length = 0;
28
- }, i = (f, c, v, h) => (f.addEventListener(c, v, h), () => f.removeEventListener(c, v, h)), d = j(() => [U(e), fe(a)], ([f, c]) => {
29
- s(), f && l.push(...n.flatMap((v) => o.map((h) => i(f, v, h, c))));
30
- }, { immediate: !0, flush: "post" }), p = () => {
31
- d(), s();
32
- };
33
- return De(p), p;
34
- }
35
- const X = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Y = "__vueuse_ssr_handlers__";
36
- X[Y] = X[Y] || {};
37
- function Se(t, { window: e = me, scrollTarget: n } = {}) {
38
- const o = E(!1), a = () => {
39
- if (!e)
40
- return;
41
- const l = e.document, s = U(t);
42
- if (!s)
43
- o.value = !1;
44
- else {
45
- const i = s.getBoundingClientRect();
46
- o.value = i.top <= (e.innerHeight || l.documentElement.clientHeight) && i.left <= (e.innerWidth || l.documentElement.clientWidth) && i.bottom >= 0 && i.right >= 0;
47
- }
48
- };
49
- return j(() => U(t), () => a(), { immediate: !0, flush: "post" }), e && Re(n || e, "scroll", a, {
50
- capture: !1,
51
- passive: !0
52
- }), o;
53
- }
54
- var Z;
55
- (function(t) {
56
- t.UP = "UP", t.RIGHT = "RIGHT", t.DOWN = "DOWN", t.LEFT = "LEFT", t.NONE = "NONE";
57
- })(Z || (Z = {}));
58
- var Pe = Object.defineProperty, K = Object.getOwnPropertySymbols, He = Object.prototype.hasOwnProperty, Le = Object.prototype.propertyIsEnumerable, ee = (t, e, n) => e in t ? Pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, Me = (t, e) => {
59
- for (var n in e || (e = {}))
60
- He.call(e, n) && ee(t, n, e[n]);
61
- if (K)
62
- for (var n of K(e))
63
- Le.call(e, n) && ee(t, n, e[n]);
64
- return t;
65
- };
66
- const Ne = {
67
- easeInSine: [0.12, 0, 0.39, 0],
68
- easeOutSine: [0.61, 1, 0.88, 1],
69
- easeInOutSine: [0.37, 0, 0.63, 1],
70
- easeInQuad: [0.11, 0, 0.5, 0],
71
- easeOutQuad: [0.5, 1, 0.89, 1],
72
- easeInOutQuad: [0.45, 0, 0.55, 1],
73
- easeInCubic: [0.32, 0, 0.67, 0],
74
- easeOutCubic: [0.33, 1, 0.68, 1],
75
- easeInOutCubic: [0.65, 0, 0.35, 1],
76
- easeInQuart: [0.5, 0, 0.75, 0],
77
- easeOutQuart: [0.25, 1, 0.5, 1],
78
- easeInOutQuart: [0.76, 0, 0.24, 1],
79
- easeInQuint: [0.64, 0, 0.78, 0],
80
- easeOutQuint: [0.22, 1, 0.36, 1],
81
- easeInOutQuint: [0.83, 0, 0.17, 1],
82
- easeInExpo: [0.7, 0, 0.84, 0],
83
- easeOutExpo: [0.16, 1, 0.3, 1],
84
- easeInOutExpo: [0.87, 0, 0.13, 1],
85
- easeInCirc: [0.55, 0, 1, 0.45],
86
- easeOutCirc: [0, 0.55, 0.45, 1],
87
- easeInOutCirc: [0.85, 0, 0.15, 1],
88
- easeInBack: [0.36, 0, 0.66, -0.56],
89
- easeOutBack: [0.34, 1.56, 0.64, 1],
90
- easeInOutBack: [0.68, -0.6, 0.32, 1.6]
91
- };
92
- Me({
93
- linear: Oe
94
- }, Ne);
95
- const x = (t) => {
96
- let e = Se(t).value;
97
- return e = e && t.offsetHeight > 0, e;
98
- }, _ = (t) => t.tabIndex >= 0, te = (t) => {
99
- const e = t.target;
100
- return W(e);
101
- }, W = (t) => {
102
- var e;
103
- let n;
104
- if (t instanceof HTMLTableCellElement) {
105
- const o = (e = t.parentElement) == null ? void 0 : e.previousElementSibling;
106
- if (o) {
107
- const a = Array.from(o.children)[t.cellIndex];
108
- a && (n = a);
109
- }
110
- } else if (t instanceof HTMLTableRowElement) {
111
- const o = t.previousElementSibling;
112
- o && (n = o);
113
- }
114
- return n && (!_(n) || !x(n)) ? W(n) : n;
115
- }, Ue = (t) => {
116
- var e;
117
- const n = t.target;
118
- let o;
119
- if (n instanceof HTMLTableCellElement) {
120
- const a = (e = n.parentElement) == null ? void 0 : e.parentElement;
121
- if (a) {
122
- const l = a.firstElementChild.children[n.cellIndex];
123
- l && (o = l);
124
- }
125
- } else if (n instanceof HTMLTableRowElement) {
126
- const a = n.parentElement;
127
- if (a) {
128
- const l = a.firstElementChild;
129
- l && (o = l);
130
- }
131
- }
132
- return o && (!_(o) || !x(o)) ? B(o) : o;
133
- }, ne = (t) => {
134
- const e = t.target;
135
- return B(e);
136
- }, B = (t) => {
137
- var e;
138
- let n;
139
- if (t instanceof HTMLTableCellElement) {
140
- const o = (e = t.parentElement) == null ? void 0 : e.nextElementSibling;
141
- if (o) {
142
- const a = Array.from(o.children)[t.cellIndex];
143
- a && (n = a);
144
- }
145
- } else if (t instanceof HTMLTableRowElement) {
146
- const o = t.nextElementSibling;
147
- o && (n = o);
148
- }
149
- return n && (!_(n) || !x(n)) ? B(n) : n;
150
- }, je = (t) => {
151
- var e;
152
- const n = t.target;
153
- let o;
154
- if (n instanceof HTMLTableCellElement) {
155
- const a = (e = n.parentElement) == null ? void 0 : e.parentElement;
156
- if (a) {
157
- const l = a.lastElementChild.children[n.cellIndex];
158
- l && (o = l);
159
- }
160
- } else if (n instanceof HTMLTableRowElement) {
161
- const a = n.parentElement;
162
- if (a) {
163
- const l = a.lastElementChild;
164
- l && (o = l);
165
- }
166
- }
167
- return o && (!_(o) || !x(o)) ? W(o) : o;
168
- }, oe = (t) => {
169
- const e = t.target;
170
- return Q(e);
171
- }, Q = (t) => {
172
- var e;
173
- let n;
174
- if (t.previousElementSibling)
175
- n = t.previousElementSibling;
176
- else {
177
- const o = (e = t.parentElement) == null ? void 0 : e.previousElementSibling;
178
- n = o == null ? void 0 : o.lastElementChild;
179
- }
180
- return n && (!_(n) || !x(n)) ? Q(n) : n;
181
- }, le = (t) => {
182
- const e = t.target;
183
- return F(e);
184
- }, F = (t) => {
185
- var e;
186
- let n;
187
- if (t.nextElementSibling)
188
- n = t.nextElementSibling;
189
- else {
190
- const o = (e = t.parentElement) == null ? void 0 : e.nextElementSibling;
191
- n = o == null ? void 0 : o.firstElementChild;
192
- }
193
- return n && (!_(n) || !x(n)) ? F(n) : n;
194
- }, ae = (t) => {
195
- const e = t.target.parentElement.firstElementChild;
196
- return e && (!_(e) || !x(e)) ? F(e) : e;
197
- }, re = (t) => {
198
- const e = t.target.parentElement.lastElementChild;
199
- return e && (!_(e) || !x(e)) ? Q(e) : e;
200
- }, D = ["alt", "control", "shift", "meta"], Ve = {
201
- ArrowUp: "up",
202
- ArrowDown: "down",
203
- ArrowLeft: "left",
204
- ArrowRight: "right"
205
- }, we = {
206
- "keydown.up": (t) => {
207
- const e = te(t);
208
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
209
- },
210
- "keydown.down": (t) => {
211
- const e = ne(t);
212
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
213
- },
214
- "keydown.left": (t) => {
215
- const e = oe(t);
216
- t.preventDefault(), t.stopPropagation(), e && e.focus();
217
- },
218
- "keydown.right": (t) => {
219
- const e = le(t);
220
- t.preventDefault(), t.stopPropagation(), e && e.focus();
221
- },
222
- "keydown.control.up": (t) => {
223
- const e = Ue(t);
224
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
225
- },
226
- "keydown.control.down": (t) => {
227
- const e = je(t);
228
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
229
- },
230
- "keydown.control.left": (t) => {
231
- const e = ae(t);
232
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
233
- },
234
- "keydown.control.right": (t) => {
235
- const e = re(t);
236
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
237
- },
238
- "keydown.end": (t) => {
239
- const e = re(t);
240
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
241
- },
242
- "keydown.enter": (t) => {
243
- if (t.target instanceof HTMLTableCellElement) {
244
- t.preventDefault(), t.stopPropagation();
245
- const e = ne(t);
246
- e && e.focus();
247
- }
248
- },
249
- "keydown.shift.enter": (t) => {
250
- if (t.target instanceof HTMLTableCellElement) {
251
- t.preventDefault(), t.stopPropagation();
252
- const e = te(t);
253
- e && e.focus();
254
- }
255
- },
256
- "keydown.home": (t) => {
257
- const e = ae(t);
258
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
259
- },
260
- "keydown.tab": (t) => {
261
- const e = le(t);
262
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
263
- },
264
- "keydown.shift.tab": (t) => {
265
- const e = oe(t);
266
- e && (t.preventDefault(), t.stopPropagation(), e.focus());
267
- }
268
- };
269
- function q(t) {
270
- const e = (o) => {
271
- let a = null;
272
- o.parent && (typeof o.parent == "string" ? a = document.querySelector(o.parent) : o.parent instanceof Element ? a = o.parent : a = o.parent.value);
273
- let l = [];
274
- if (o.selectors)
275
- if (typeof o.selectors == "string")
276
- l = a ? Array.from(a.querySelectorAll(o.selectors)) : Array.from(document.querySelectorAll(o.selectors));
277
- else if (o.selectors instanceof Element)
278
- l.push(o.selectors);
279
- else if (Array.isArray(o.selectors.value))
280
- for (const s of o.selectors.value)
281
- s instanceof Element ? l.push(s) : l.push(s.$el);
282
- else
283
- l.push(o.selectors.value);
284
- else
285
- l = Array.from(a.children).filter((s) => _(s) && x(s));
286
- return l;
287
- }, n = (o) => (a) => {
288
- const l = Ve[a.key] || a.key.toLowerCase();
289
- if (D.includes(l))
290
- return;
291
- const s = o.handlers || we;
292
- for (const i of Object.keys(s)) {
293
- const [d, ...p] = i.split(".");
294
- if (d === "keydown" && p.includes(l)) {
295
- const f = s[i], c = p.filter((h) => D.includes(h)), v = D.some((h) => {
296
- const I = h.charAt(0).toUpperCase() + h.slice(1);
297
- return a.getModifierState(I);
298
- });
299
- if (c.length > 0) {
300
- if (v) {
301
- for (const h of D)
302
- if (p.includes(h)) {
303
- const I = h.charAt(0).toUpperCase() + h.slice(1);
304
- a.getModifierState(I) && f(a);
305
- }
306
- }
307
- } else
308
- v || f(a);
309
- }
310
- }
311
- };
312
- xe(() => {
313
- for (const o of t) {
314
- const a = e(o);
315
- for (const l of a)
316
- l.addEventListener("keydown", n(o));
317
- }
318
- }), _e(() => {
319
- for (const o of t) {
320
- const a = e(o);
321
- for (const l of a)
322
- l.removeEventListener("keydown", n(o));
323
- }
324
- });
325
- }
326
- const We = ["data-colindex", "data-rowindex", "data-editable", "contenteditable", "tabindex"], Be = { key: 1 }, Qe = /* @__PURE__ */ k({
327
- __name: "ACell",
328
- props: {
329
- colIndex: {},
330
- rowIndex: {},
331
- tableid: {},
332
- addNavigation: { type: [Boolean, Object], default: !0 },
333
- tabIndex: { default: 0 },
334
- clickHandler: {}
335
- },
336
- setup(t) {
337
- var I;
338
- const e = t, n = O(e.tableid), o = E(null);
339
- let a = E(!1);
340
- const l = S(() => {
341
- const u = n.cellData(e.colIndex, e.rowIndex);
342
- if (n.columns[e.colIndex].format) {
343
- const g = n.columns[e.colIndex].format;
344
- return typeof g == "function" ? g(u) : typeof g == "string" ? Function(`"use strict";return (${g})`)()(u) : u;
345
- } else
346
- return u;
347
- }), s = (u) => {
348
- if (e.clickHandler) {
349
- e.clickHandler(u);
350
- return;
351
- }
352
- if (n.columns[e.colIndex].mask, n.columns[e.colIndex].modalComponent) {
353
- const g = o.value.getBoundingClientRect();
354
- n.modal.visible = !0, n.modal.colIndex = e.colIndex, n.modal.rowIndex = e.rowIndex, n.modal.parent = o.value, n.modal.top = g.top + g.height, n.modal.left = g.left, n.modal.width = d.value, n.modal.component = n.columns[e.colIndex].modalComponent, n.modal.componentProps = n.columns[e.colIndex].modalComponentProps;
355
- }
356
- };
357
- if (e.addNavigation) {
358
- let u = {
359
- ...we,
360
- "keydown.f2": s,
361
- "keydown.alt.up": s,
362
- "keydown.alt.down": s,
363
- "keydown.alt.left": s,
364
- "keydown.alt.right": s
365
- };
366
- typeof e.addNavigation == "object" && (u = {
367
- ...u,
368
- ...e.addNavigation
369
- }), q([
370
- {
371
- selectors: o,
372
- handlers: u
373
- }
374
- ]);
375
- }
376
- const i = S(() => n.columns[e.colIndex].align || "center"), d = S(() => n.columns[e.colIndex].width || "40ch");
377
- let p = "";
378
- const f = () => {
379
- o.value && (p = o.value.innerText);
380
- }, c = () => {
381
- o.value && o.value.innerHTML !== p && (p = o.value.innerText, o.value.dispatchEvent(new Event("change")), a.value = !0, n.columns[e.colIndex].format || n.setCellData(e.rowIndex, e.colIndex, p));
382
- }, v = (u, g) => g && u === 0 && g > 0 ? `${g}ch` : "inherit", h = {
383
- textAlign: i.value,
384
- width: d.value,
385
- backgroundColor: a.value ? "var(--cell-modified-color)" : "inherit",
386
- fontWeight: a.value ? "bold" : "inherit",
387
- paddingLeft: v(e.colIndex, (I = n.display[e.rowIndex]) == null ? void 0 : I.indent)
388
- };
389
- return (u, g) => (m(), b("td", {
390
- ref_key: "cell",
391
- ref: o,
392
- "data-colindex": u.colIndex,
393
- "data-rowindex": u.rowIndex,
394
- "data-editable": r(n).columns[u.colIndex].edit,
395
- contenteditable: r(n).columns[u.colIndex].edit,
396
- tabindex: u.tabIndex,
397
- spellcheck: !1,
398
- style: h,
399
- onFocus: f,
400
- onPaste: c,
401
- onBlur: c,
402
- onInput: c,
403
- onClick: s,
404
- onMousedown: s
405
- }, [
406
- r(n).columns[u.colIndex].cellComponent ? (m(), P(ie(r(n).columns[u.colIndex].cellComponent), V({
407
- key: 0,
408
- value: l.value
409
- }, r(n).columns[u.colIndex].cellComponentProps), null, 16, ["value"])) : (m(), b("span", Be, $(l.value), 1))
410
- ], 40, We));
411
- }
412
- });
413
- const C = (t, e) => {
414
- const n = t.__vccOpts || t;
415
- for (const [o, a] of e)
416
- n[o] = a;
417
- return n;
418
- }, he = /* @__PURE__ */ C(Qe, [["__scopeId", "data-v-07dfe445"]]), Fe = ["tabindex"], qe = ["tabindex"], ze = ["colspan"], Ge = /* @__PURE__ */ k({
419
- __name: "AExpansionRow",
420
- props: {
421
- row: {},
422
- rowIndex: {},
423
- tableid: {},
424
- tabIndex: { default: -1 },
425
- addNavigation: {}
426
- },
427
- setup(t) {
428
- const e = t, n = O(e.tableid), o = E(null), a = E(null), l = () => n.display[e.rowIndex].expanded ? "▼" : "►";
429
- if (e.addNavigation !== void 0) {
430
- const s = Object.assign({}, e.addNavigation);
431
- s["keydown.control.g"] = (i) => {
432
- i.stopPropagation(), i.preventDefault(), n.toggleRowExpand(e.rowIndex);
433
- }, q([
434
- {
435
- selectors: o,
436
- handlers: s
437
- }
438
- ]);
439
- }
440
- return (s, i) => (m(), b(L, null, [
441
- T("tr", V(s.$attrs, {
442
- ref_key: "rowEl",
443
- ref: o,
444
- tabindex: s.tabIndex,
445
- class: "expandable-row"
446
- }), [
447
- T("td", {
448
- tabIndex: -1,
449
- onClick: i[0] || (i[0] = (d) => r(n).toggleRowExpand(s.rowIndex)),
450
- class: "row-index"
451
- }, $(l()), 1),
452
- y(s.$slots, "row", {}, void 0, !0)
453
- ], 16, Fe),
454
- r(n).display[e.rowIndex].expanded ? (m(), b("tr", {
455
- key: 0,
456
- ref_key: "rowExpanded",
457
- ref: a,
458
- tabindex: s.tabIndex,
459
- class: "expanded-row"
460
- }, [
461
- T("td", {
462
- tabIndex: -1,
463
- colspan: r(n).columns.length + 1,
464
- class: "expanded-row-content"
465
- }, [
466
- y(s.$slots, "content", {}, void 0, !0)
467
- ], 8, ze)
468
- ], 8, qe)) : M("", !0)
469
- ], 64));
470
- }
471
- });
472
- const Je = /* @__PURE__ */ C(Ge, [["__scopeId", "data-v-b2e2ed2d"]]), Xe = ["tabindex"], Ye = {
473
- key: 0,
474
- tabIndex: -1,
475
- class: "list-index"
476
- }, Ze = /* @__PURE__ */ k({
477
- __name: "ARow",
478
- props: {
479
- row: {},
480
- rowIndex: {},
481
- tableid: {},
482
- tabIndex: { default: -1 },
483
- addNavigation: {}
484
- },
485
- setup(t) {
486
- de((d) => ({
487
- "5b18ee03": r(a)
488
- }));
489
- const e = t, n = O(e.tableid), o = E(null), a = n.numberedRowWidth.value, l = () => n.config.view !== "tree" ? "" : n.display[e.rowIndex].isRoot || n.display[e.rowIndex].isParent ? n.display[e.rowIndex].childrenOpen ? "-" : "+" : "", s = () => n.config.view !== "tree" || n.display[e.rowIndex].isRoot || n.display[e.rowIndex].open, i = (d) => {
490
- n.toggleRowExpand(d);
491
- };
492
- return e.addNavigation && q([
493
- {
494
- selectors: o,
495
- handlers: e.addNavigation
496
- }
497
- ]), (d, p) => ce((m(), b("tr", {
498
- ref_key: "rowEl",
499
- ref: o,
500
- tabindex: d.tabIndex,
501
- class: "table-row"
502
- }, [
503
- r(n).config.view === "list" ? (m(), b("td", Ye, $(d.rowIndex + 1), 1)) : r(n).config.view === "tree" ? (m(), b("td", {
504
- key: 1,
505
- tabIndex: -1,
506
- class: "tree-index",
507
- onClick: p[0] || (p[0] = (f) => i(d.rowIndex))
508
- }, $(l()), 1)) : y(d.$slots, "indexCell", { key: 2 }, void 0, !0),
509
- y(d.$slots, "default", {}, void 0, !0)
510
- ], 8, Xe)), [
511
- [ue, s()]
512
- ]);
513
- }
514
- });
515
- const be = /* @__PURE__ */ C(Ze, [["__scopeId", "data-v-4c71a067"]]);
516
- let R;
517
- const Ke = new Uint8Array(16);
518
- function et() {
519
- if (!R && (R = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !R))
520
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
521
- return R(Ke);
522
- }
523
- const w = [];
524
- for (let t = 0; t < 256; ++t)
525
- w.push((t + 256).toString(16).slice(1));
526
- function tt(t, e = 0) {
527
- return w[t[e + 0]] + w[t[e + 1]] + w[t[e + 2]] + w[t[e + 3]] + "-" + w[t[e + 4]] + w[t[e + 5]] + "-" + w[t[e + 6]] + w[t[e + 7]] + "-" + w[t[e + 8]] + w[t[e + 9]] + "-" + w[t[e + 10]] + w[t[e + 11]] + w[t[e + 12]] + w[t[e + 13]] + w[t[e + 14]] + w[t[e + 15]];
528
- }
529
- const nt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), se = {
530
- randomUUID: nt
531
- };
532
- function ge(t, e, n) {
533
- if (se.randomUUID && !e && !t)
534
- return se.randomUUID();
535
- t = t || {};
536
- const o = t.random || (t.rng || et)();
537
- if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, e) {
538
- n = n || 0;
539
- for (let a = 0; a < 16; ++a)
540
- e[n + a] = o[a];
541
- return e;
542
- }
543
- return tt(o);
544
- }
545
- class ot {
546
- constructor(e, n, o, a, l, s) {
547
- this.id = e || ge(), this.rows = o, this.columns = A(n), this.config = A(a), this.table = l || A(this.createTableObject()), this.display = this.createDisplayObject(s), this.modal = A({ visible: !1 });
548
- }
549
- createTableObject() {
550
- const e = {};
551
- for (const [n, o] of this.columns.entries())
552
- for (const [a, l] of this.rows.entries())
553
- e[`${n}:${a}`] = l[o.name];
554
- return e;
555
- }
556
- createDisplayObject(e) {
557
- const n = [Object.assign({}, { modified: !1 })];
558
- if (e && "0:0" in e)
559
- return e;
560
- const o = /* @__PURE__ */ new Set();
561
- for (let a = this.rows.length - 1; a >= 0; a--) {
562
- const l = this.rows[a];
563
- l.parent && o.add(l.parent), n[a] = {
564
- childrenOpen: !1,
565
- expanded: !1,
566
- indent: l.indent || null,
567
- isParent: o.has(a),
568
- isRoot: l.parent === null || l.parent === void 0,
569
- modified: !1,
570
- open: l.parent === null || l.parent === void 0,
571
- parent: l.parent
572
- };
573
- }
574
- return A(n);
575
- }
576
- get zeroColumn() {
577
- return ["list", "tree", "list-expansion"].includes(this.config.view);
578
- }
579
- get numberedRowWidth() {
580
- return S(() => String(Math.ceil(this.rows.length / 100) + 1) + "ch");
581
- }
582
- cellData(e, n) {
583
- return this.table[`${e}:${n}`];
584
- }
585
- setCellData(e, n, o) {
586
- this.table[`${n}:${e}`] !== o && (this.display[e].modified = !0), this.table[`${n}:${e}`] = o;
587
- const a = this.columns[n];
588
- return this.rows[e][a.name] = o, this.table[`${n}:${e}`];
589
- }
590
- toggleRowExpand(e) {
591
- if (this.config.view === "tree") {
592
- this.display[e].childrenOpen = !this.display[e].childrenOpen;
593
- for (let n = this.rows.length - 1; n >= 0; n--)
594
- this.display[n].parent === e && (this.display[n].open = !this.display[n].open, this.display[n].childrenOpen && this.toggleRowExpand(n));
595
- } else
596
- this.config.view === "list-expansion" && (this.display[e].expanded = !this.display[e].expanded);
597
- }
598
- }
599
- const lt = { key: 0 }, at = {
600
- class: "atable-header-row",
601
- tabindex: "-1"
602
- }, rt = {
603
- key: 0,
604
- id: "header-index"
605
- }, st = /* @__PURE__ */ k({
606
- __name: "ATableHeader",
607
- props: {
608
- columns: {},
609
- config: {},
610
- tableid: {}
611
- },
612
- setup(t) {
613
- de((l) => ({
614
- "12d06943": r(o)
615
- }));
616
- const n = O(t.tableid), o = n.numberedRowWidth.value, a = (l) => ({
617
- minWidth: l.width || "40ch",
618
- textAlign: l.align || "center",
619
- width: n.config.fullWidth ? "auto" : null
620
- });
621
- return (l, s) => l.columns.length ? (m(), b("thead", lt, [
622
- T("tr", at, [
623
- r(n).zeroColumn ? (m(), b("th", rt)) : M("", !0),
624
- (m(!0), b(L, null, N(l.columns, (i, d) => (m(), b("th", {
625
- key: d,
626
- tabindex: "-1",
627
- style: H(a(i))
628
- }, [
629
- y(l.$slots, "default", {}, () => [
630
- ke($(i.label || String.fromCharCode(d + 97).toUpperCase()), 1)
631
- ], !0)
632
- ], 4))), 128))
633
- ])
634
- ])) : M("", !0);
635
- }
636
- });
637
- const ve = /* @__PURE__ */ C(st, [["__scopeId", "data-v-16e66636"]]), it = /* @__PURE__ */ k({
638
- __name: "ATableModal",
639
- props: {
640
- colIndex: {},
641
- rowIndex: {},
642
- tableid: {}
643
- },
644
- setup(t) {
645
- O(t.tableid);
646
- const n = (o) => {
647
- o.stopPropagation();
648
- };
649
- return (o, a) => (m(), b("div", {
650
- ref: "amodal",
651
- class: "amodal",
652
- tabindex: "-1",
653
- onClick: n,
654
- onInput: n
655
- }, [
656
- y(o.$slots, "default", {}, void 0, !0)
657
- ], 544));
658
- }
659
- });
660
- const ye = /* @__PURE__ */ C(it, [["__scopeId", "data-v-10a48b2a"]]), dt = /* @__PURE__ */ k({
661
- __name: "ATable",
662
- props: {
663
- id: {},
664
- modelValue: {},
665
- columns: {},
666
- rows: { default: () => [] },
667
- config: { default: () => new Object() },
668
- tableid: {}
669
- },
670
- emits: ["update:modelValue"],
671
- setup(t, { emit: e }) {
672
- const n = t, o = e;
673
- let a = n.modelValue ? n.modelValue : n.rows, l = new ot(n.id, n.columns, a, n.config);
674
- Ce(l.id, l), j(
675
- () => l.rows,
676
- (i, d) => {
677
- o("update:modelValue", i);
678
- },
679
- { deep: !0 }
680
- );
681
- const s = (i) => {
682
- var d;
683
- (d = l.modal.parent) != null && d.contains(i.target) || l.modal.visible && (l.modal.visible = !1);
684
- };
685
- return window.addEventListener("click", s), window.addEventListener("keydown", (i) => {
686
- if (i.key === "Escape" && l.modal.visible) {
687
- l.modal.visible = !1;
688
- const d = l.modal.parent;
689
- d && Ae().then(() => {
690
- const p = d.dataset.rowindex, f = d.dataset.colindex, c = document.querySelectorAll(`[data-rowindex='${p}'][data-colindex='${f}']`);
691
- c && c[0].focus();
692
- });
693
- }
694
- }), (i, d) => (m(), b("table", {
695
- class: "atable",
696
- style: H({ width: r(l).config.fullWidth ? "100%" : "auto" })
697
- }, [
698
- y(i.$slots, "header", { data: r(l) }, () => [
699
- z(ve, {
700
- columns: r(l).columns,
701
- config: r(l).config,
702
- tableid: r(l).id
703
- }, null, 8, ["columns", "config", "tableid"])
704
- ], !0),
705
- T("tbody", null, [
706
- y(i.$slots, "body", { data: r(l) }, () => [
707
- (m(!0), b(L, null, N(r(l).rows, (p, f) => (m(), P(be, {
708
- key: p.id || r(ge)(),
709
- row: p,
710
- rowIndex: f,
711
- tableid: r(l).id
712
- }, {
713
- default: G(() => [
714
- (m(!0), b(L, null, N(r(l).columns, (c, v) => (m(), P(he, {
715
- key: `${v}:${f}`,
716
- tableid: r(l).id,
717
- col: c,
718
- spellcheck: "false",
719
- rowIndex: f,
720
- colIndex: v + (r(l).zeroColumn ? 0 : -1),
721
- component: c.cellComponent,
722
- style: H({
723
- textAlign: (c == null ? void 0 : c.align) || "center",
724
- minWidth: (c == null ? void 0 : c.width) || "40ch",
725
- width: r(l).config.fullWidth ? "auto" : null
726
- })
727
- }, null, 8, ["tableid", "col", "rowIndex", "colIndex", "component", "style"]))), 128))
728
- ]),
729
- _: 2
730
- }, 1032, ["row", "rowIndex", "tableid"]))), 128))
731
- ], !0)
732
- ]),
733
- y(i.$slots, "footer", { data: r(l) }, void 0, !0),
734
- y(i.$slots, "modal", { data: r(l) }, () => [
735
- ce(z(ye, {
736
- colIndex: r(l).modal.colIndex,
737
- rowIndex: r(l).modal.rowIndex,
738
- tableid: r(l).id,
739
- style: H({
740
- left: r(l).modal.left + "px",
741
- top: r(l).modal.top + "px",
742
- maxWidth: r(l).modal.width + "px"
743
- })
744
- }, {
745
- default: G(() => [
746
- (m(), P(ie(r(l).modal.component), V({
747
- key: `${r(l).modal.rowIndex}:${r(l).modal.colIndex}`,
748
- colIndex: r(l).modal.colIndex,
749
- rowIndex: r(l).modal.rowIndex,
750
- tableid: r(l).id
751
- }, r(l).modal.componentProps), null, 16, ["colIndex", "rowIndex", "tableid"]))
752
- ]),
753
- _: 1
754
- }, 8, ["colIndex", "rowIndex", "tableid", "style"]), [
755
- [ue, r(l).modal.visible]
756
- ])
757
- ], !0)
758
- ], 4));
759
- }
760
- });
761
- const ct = /* @__PURE__ */ C(dt, [["__scopeId", "data-v-819abcc5"]]);
762
- function ft(t) {
763
- t.component("ACell", he), t.component("AExpansionRow", Je), t.component("ARow", be), t.component("ATable", ct), t.component("ATableHeader", ve), t.component("ATableModal", ye);
764
- }
765
- export {
766
- he as ACell,
767
- Je as AExpansionRow,
768
- be as ARow,
769
- ct as ATable,
770
- ve as ATableHeader,
771
- ye as ATableModal,
772
- ot as TableDataStore,
773
- ft as install
774
- };
775
- //# sourceMappingURL=atable.js.map