@opengis/table 0.0.1 → 0.0.12

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.mjs ADDED
@@ -0,0 +1,811 @@
1
+ import { defineComponent as S, computed as f, createElementBlock as u, openBlock as i, toDisplayString as x, normalizeStyle as de, normalizeClass as b, Fragment as B, renderList as R, createElementVNode as c, createTextVNode as P, ref as w, useSlots as ve, watch as A, onMounted as ge, provide as _e, createCommentVNode as z, createBlock as U, renderSlot as pe, resolveDynamicComponent as Z, inject as we, withDirectives as Ce, vShow as $e } from "vue";
2
+ const Te = /* @__PURE__ */ S({
3
+ name: "NumberFormat",
4
+ __name: "NumberFormat",
5
+ props: {
6
+ value: {},
7
+ row: {},
8
+ column: {}
9
+ },
10
+ setup(y) {
11
+ const a = y, e = f(() => a.value === null || a.value === void 0 ? "" : typeof a.value == "number" ? a.value.toLocaleString() : a.value);
12
+ return (g, l) => (i(), u("span", null, x(e.value), 1));
13
+ }
14
+ }), Se = /* @__PURE__ */ S({
15
+ name: "DateFormat",
16
+ __name: "DateFormat",
17
+ props: {
18
+ value: {},
19
+ row: {},
20
+ column: {}
21
+ },
22
+ setup(y) {
23
+ const a = y, e = f(() => {
24
+ if (!a.value) return "";
25
+ try {
26
+ return new Date(a.value).toLocaleDateString();
27
+ } catch {
28
+ return a.value;
29
+ }
30
+ });
31
+ return (g, l) => (i(), u("span", null, x(e.value), 1));
32
+ }
33
+ }), De = /* @__PURE__ */ S({
34
+ name: "TextFormat",
35
+ __name: "TextFormat",
36
+ props: {
37
+ value: {},
38
+ row: {},
39
+ column: {}
40
+ },
41
+ setup(y) {
42
+ return (a, e) => (i(), u("span", null, x(a.value), 1));
43
+ }
44
+ }), Fe = /* @__PURE__ */ S({
45
+ name: "BadgeFormat",
46
+ __name: "BadgeFormat",
47
+ props: {
48
+ value: {},
49
+ row: {},
50
+ column: {}
51
+ },
52
+ setup(y) {
53
+ const a = y, e = f(() => {
54
+ const n = String(a.value || "").toLowerCase(), o = "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium";
55
+ return n.includes("success") || n.includes("active") || n.includes("completed") ? `${o} bg-green-100 text-green-800` : n.includes("error") || n.includes("failed") || n.includes("inactive") ? `${o} bg-red-100 text-red-800` : n.includes("warning") || n.includes("pending") ? `${o} bg-yellow-100 text-yellow-800` : n.includes("info") || n.includes("processing") ? `${o} bg-blue-100 text-blue-800` : a.value.color && !/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(a.value.color) ? `${o} bg-${a.value.color}-100 text-${a.value.color}-800` : `${o} bg-gray-100 text-gray-800`;
56
+ }), g = f(() => {
57
+ const n = {
58
+ minWidth: "60px",
59
+ textAlign: "center",
60
+ display: "inline-block"
61
+ };
62
+ return /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(a.value.color) ? {
63
+ ...n,
64
+ backgroundColor: l(a.value.color, 0.1),
65
+ color: l(a.value.color, 0.8)
66
+ } : n;
67
+ });
68
+ function l(n, o = 1) {
69
+ const _ = parseInt(n.slice(1, 3), 16), $ = parseInt(n.slice(3, 5), 16), T = parseInt(n.slice(5, 7), 16);
70
+ return `rgba(${_}, ${$}, ${T}, ${o})`;
71
+ }
72
+ return (n, o) => (i(), u("span", {
73
+ class: b(["badge", e.value]),
74
+ style: de(g.value)
75
+ }, x(n.value.text || n.value.ua || n.value), 7));
76
+ }
77
+ }), Ie = (y, a) => {
78
+ const e = y.__vccOpts || y;
79
+ for (const [g, l] of a)
80
+ e[g] = l;
81
+ return e;
82
+ }, Be = /* @__PURE__ */ Ie(Fe, [["__scopeId", "data-v-aaab5e06"]]), Re = { class: "flex flex-wrap gap-1" }, je = /* @__PURE__ */ S({
83
+ name: "ArrayFormat",
84
+ __name: "ArrayFormat",
85
+ props: {
86
+ value: {},
87
+ row: {},
88
+ column: {}
89
+ },
90
+ setup(y) {
91
+ const a = y, e = f(() => a.value ? Array.isArray(a.value) ? a.value : [a.value] : []), g = (l) => l ? typeof l == "object" && l.name ? l.name : typeof l == "string" || typeof l == "number" ? String(l) : JSON.stringify(l) : "";
92
+ return (l, n) => (i(), u("div", Re, [
93
+ (i(!0), u(B, null, R(e.value, (o, _) => (i(), u("span", {
94
+ key: _,
95
+ class: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 hover:bg-blue-200 transition-colors"
96
+ }, x(g(o)), 1))), 128))
97
+ ]));
98
+ }
99
+ }), ze = ["href", "target"], Ae = /* @__PURE__ */ S({
100
+ __name: "LinkFormat",
101
+ props: {
102
+ href: { default: "" },
103
+ target: { default: "_self" },
104
+ onClick: { type: Function, default: void 0 },
105
+ value: {},
106
+ row: {},
107
+ column: {}
108
+ },
109
+ setup(y) {
110
+ const a = y, e = f(() => typeof a.value == "string" || typeof a.value == "number" ? a.value : a.value?.text || a.value?.label || "Link"), g = f(() => a.href ? a.href : typeof a.value == "object" && a.value?.href ? a.value.href : ""), l = f(() => a.target ? a.target : typeof a.value == "object" && a.value?.target ? a.value.target : "_self"), n = f(() => "text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 underline cursor-pointer"), o = (_) => {
111
+ a.onClick && a.row && (_.preventDefault(), a.onClick(a.row, a.value));
112
+ };
113
+ return (_, $) => g.value ? (i(), u("a", {
114
+ key: 0,
115
+ href: g.value,
116
+ target: l.value,
117
+ class: b(n.value),
118
+ onClick: o
119
+ }, x(e.value), 11, ze)) : (i(), u("button", {
120
+ key: 1,
121
+ type: "button",
122
+ class: b(n.value),
123
+ onClick: o
124
+ }, x(e.value), 3));
125
+ }
126
+ }), ue = {
127
+ number: Te,
128
+ date: Se,
129
+ text: De,
130
+ badge: Be,
131
+ array: je,
132
+ link: Ae
133
+ }, Pe = { class: "flex items-center space-x-4" }, Le = { class: "font-medium" }, Ve = { class: "font-medium" }, Me = { class: "font-medium" }, Ne = { class: "flex items-center space-x-2" }, Ee = ["disabled"], He = { class: "flex items-center space-x-1" }, We = ["onClick"], Ue = ["disabled"], fe = /* @__PURE__ */ S({
134
+ name: "Pagination",
135
+ __name: "Pagination",
136
+ props: {
137
+ page: {},
138
+ limit: {},
139
+ total: {},
140
+ theme: { default: "light" },
141
+ size: { default: "medium" }
142
+ },
143
+ emits: ["update:page"],
144
+ setup(y, { emit: a }) {
145
+ const e = y, g = f(() => ({
146
+ small: {
147
+ text: "text-xs",
148
+ button: "px-2 h-7 text-xs min-w-[28px] flex items-center justify-center",
149
+ icon: "w-3.5 h-3.5"
150
+ },
151
+ medium: {
152
+ text: "text-sm",
153
+ button: "px-3 h-9 text-sm min-w-[36px] flex items-center justify-center",
154
+ icon: "w-4 h-4"
155
+ },
156
+ large: {
157
+ text: "text-base",
158
+ button: "px-4 h-11 text-base min-w-[44px] flex items-center justify-center",
159
+ icon: "w-5 h-5"
160
+ }
161
+ })[e.size]), l = f(() => {
162
+ const { theme: p } = e;
163
+ return p === "dark" ? {
164
+ container: "bg-gray-900 border-gray-700",
165
+ text: "text-gray-300",
166
+ button: "text-gray-300 bg-gray-800 border-gray-600 hover:bg-gray-700",
167
+ buttonDisabled: "text-gray-500 bg-gray-800",
168
+ buttonActive: "bg-blue-600 text-white",
169
+ ellipsis: "text-gray-400"
170
+ } : p === "light" ? {
171
+ container: "bg-white border-gray-200",
172
+ text: "text-gray-700",
173
+ button: "text-gray-700 bg-white border-gray-300 hover:bg-gray-50",
174
+ buttonDisabled: "text-gray-400 bg-gray-100",
175
+ buttonActive: "bg-blue-600 text-white",
176
+ ellipsis: "text-gray-500"
177
+ } : {
178
+ container: "bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700",
179
+ text: "text-gray-700 dark:text-gray-300",
180
+ button: "text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700",
181
+ buttonDisabled: "text-gray-400 dark:text-gray-500 bg-gray-100 dark:bg-gray-800",
182
+ buttonActive: "bg-blue-600 text-white",
183
+ ellipsis: "text-gray-500 dark:text-gray-400"
184
+ };
185
+ }), n = a, o = f(() => Math.ceil(e.total / e.limit)), _ = f(() => e.total === 0 ? 0 : (e.page - 1) * e.limit + 1), $ = f(() => Math.min(e.page * e.limit, e.total)), T = f(() => {
186
+ const p = [];
187
+ if (o.value <= 7)
188
+ for (let k = 1; k <= o.value; k += 1)
189
+ p.push(k);
190
+ else {
191
+ p.push(1), e.page > 4 && p.push("...");
192
+ const k = Math.max(2, e.page - 1), j = Math.min(o.value - 1, e.page + 1);
193
+ for (let D = k; D <= j; D += 1)
194
+ D !== 1 && D !== o.value && p.push(D);
195
+ e.page < o.value - 3 && p.push("..."), o.value > 1 && p.push(o.value);
196
+ }
197
+ return p;
198
+ }), F = (p) => {
199
+ p >= 1 && p <= o.value && p !== e.page && n("update:page", p);
200
+ };
201
+ return (p, m) => (i(), u("div", {
202
+ class: b(["flex items-center justify-between py-3 border-t", l.value.container])
203
+ }, [
204
+ c("div", Pe, [
205
+ c("div", {
206
+ class: b(["flex items-center text-sm", l.value.text, g.value.text])
207
+ }, [
208
+ c("span", null, [
209
+ m[2] || (m[2] = P(" Показано ", -1)),
210
+ c("span", Le, x(_.value), 1),
211
+ m[3] || (m[3] = P(" до ", -1)),
212
+ c("span", Ve, x($.value), 1),
213
+ m[4] || (m[4] = P(" з ", -1)),
214
+ c("span", Me, x(p.total), 1),
215
+ m[5] || (m[5] = P(" результатів ", -1))
216
+ ])
217
+ ], 2)
218
+ ]),
219
+ c("div", Ne, [
220
+ c("button", {
221
+ onClick: m[0] || (m[0] = (k) => F(p.page - 1)),
222
+ disabled: p.page <= 1,
223
+ class: b([
224
+ "relative font-medium rounded-md",
225
+ g.value.button,
226
+ p.page <= 1 ? l.value.buttonDisabled : l.value.button
227
+ ])
228
+ }, [
229
+ (i(), u("svg", {
230
+ class: b(g.value.icon),
231
+ fill: "none",
232
+ stroke: "currentColor",
233
+ viewBox: "0 0 24 24"
234
+ }, m[6] || (m[6] = [
235
+ c("path", {
236
+ "stroke-linecap": "round",
237
+ "stroke-linejoin": "round",
238
+ "stroke-width": "2",
239
+ d: "M15 19l-7-7 7-7"
240
+ }, null, -1)
241
+ ]), 2))
242
+ ], 10, Ee),
243
+ c("div", He, [
244
+ (i(!0), u(B, null, R(T.value, (k) => (i(), u(B, { key: k }, [
245
+ k === "..." ? (i(), u("span", {
246
+ key: 0,
247
+ class: b(["font-medium", g.value.button, l.value.ellipsis])
248
+ }, " ... ", 2)) : (i(), u("button", {
249
+ key: 1,
250
+ onClick: (j) => F(k),
251
+ class: b([
252
+ "relative font-medium rounded-md",
253
+ g.value.button,
254
+ k === p.page ? l.value.buttonActive : l.value.button
255
+ ])
256
+ }, x(k), 11, We))
257
+ ], 64))), 128))
258
+ ]),
259
+ c("button", {
260
+ onClick: m[1] || (m[1] = (k) => F(p.page + 1)),
261
+ disabled: p.page >= o.value,
262
+ class: b([
263
+ "relative font-medium rounded-md",
264
+ g.value.button,
265
+ p.page >= o.value ? l.value.buttonDisabled : l.value.button
266
+ ])
267
+ }, [
268
+ (i(), u("svg", {
269
+ class: b(g.value.icon),
270
+ fill: "none",
271
+ stroke: "currentColor",
272
+ viewBox: "0 0 24 24"
273
+ }, m[7] || (m[7] = [
274
+ c("path", {
275
+ "stroke-linecap": "round",
276
+ "stroke-linejoin": "round",
277
+ "stroke-width": "2",
278
+ d: "M9 5l7 7-7 7"
279
+ }, null, -1)
280
+ ]), 2))
281
+ ], 10, Ue)
282
+ ])
283
+ ], 2));
284
+ }
285
+ }), Oe = {
286
+ key: 0,
287
+ class: "text-center py-8"
288
+ }, Je = { class: "inline-flex items-center space-x-2" }, qe = {
289
+ key: 2,
290
+ class: "overflow-x-auto"
291
+ }, Ge = ["checked", "indeterminate"], Ke = ["onClick"], Qe = { class: "flex items-center justify-between" }, Xe = {
292
+ key: 0,
293
+ class: "ml-1 text-xs"
294
+ }, Ye = ["onClick"], Ze = ["checked", "onChange"], ce = /* @__PURE__ */ S({
295
+ name: "DataTable",
296
+ __name: "DataTable",
297
+ props: {
298
+ rows: { default: () => [] },
299
+ columns: { default: () => [] },
300
+ api: {},
301
+ tableStyle: { default: "min-width: 50rem" },
302
+ tableClass: { default: "min-w-full divide-y divide-gray-200 dark:divide-gray-700" },
303
+ tableClassWrapper: {},
304
+ size: { default: "medium" },
305
+ theme: { default: "light" },
306
+ loading: { type: Boolean, default: !1 },
307
+ classTr: { default: "" },
308
+ classTd: { default: "" },
309
+ classTh: { default: "" },
310
+ classLink: { default: "" },
311
+ selectable: { type: Boolean, default: !1 },
312
+ selectedRows: { default: () => [] },
313
+ limit: { default: 10 },
314
+ page: { default: 1 },
315
+ total: { default: 0 },
316
+ showPagination: { type: Boolean, default: !0 },
317
+ sortable: { type: Boolean, default: !1 },
318
+ clickable: { type: Boolean, default: !1 },
319
+ getCellData: { type: Function, default: void 0 }
320
+ },
321
+ emits: ["update:page", "update:selectedRows", "row-click", "sort"],
322
+ setup(y, { emit: a }) {
323
+ const e = y, g = a, l = w(e.selectedRows || []), n = w([]), o = w([]), _ = w([]), $ = w(!1), T = w(null), F = ve(), p = f(() => F.action), m = f(() => {
324
+ if (e.api)
325
+ return o.value;
326
+ if (e.sortable && n.value.length > 0) {
327
+ const t = [...e.rows];
328
+ return t.sort((d, r) => {
329
+ for (const v of n.value) {
330
+ if (!v.direction)
331
+ return 0;
332
+ const s = d[v.field], h = r[v.field];
333
+ if (s == null) return 1;
334
+ if (h == null) return -1;
335
+ let I = 0;
336
+ typeof s == "string" && typeof h == "string" ? I = s.localeCompare(h) : s < h ? I = -1 : s > h ? I = 1 : I = 0;
337
+ const W = v.direction === "desc" ? -I : I;
338
+ if (W !== 0) return W;
339
+ }
340
+ return 0;
341
+ }), t;
342
+ }
343
+ return e.rows;
344
+ });
345
+ A(() => e.selectedRows, (t) => {
346
+ l.value = t || [];
347
+ });
348
+ const k = (t) => l.value.some((d) => d === t), j = (t) => {
349
+ const d = l.value.findIndex((r) => r === t);
350
+ d > -1 ? l.value.splice(d, 1) : l.value.push(t), g("update:selectedRows", [...l.value]);
351
+ }, D = f(() => m.value.length > 0 && l.value.length === m.value.length), ee = f(() => l.value.length > 0 && l.value.length < m.value.length), te = () => {
352
+ D.value ? l.value = [] : l.value = [...m.value], g("update:selectedRows", [...l.value]);
353
+ }, L = (t) => {
354
+ if (!e.sortable) return;
355
+ const d = n.value.findIndex((v) => v.field === t);
356
+ if (d >= 0) {
357
+ const v = n.value[d];
358
+ v.direction === "asc" ? v.direction = "desc" : v.direction === "desc" && n.value.splice(d, 1);
359
+ } else
360
+ n.value.unshift({
361
+ field: t,
362
+ direction: "asc"
363
+ });
364
+ const r = n.value.filter((v) => v.direction).map((v) => ({
365
+ name: v.field,
366
+ asc: v.direction === "asc"
367
+ }));
368
+ g("sort", r), e.api && N();
369
+ }, O = (t) => n.value.find((r) => r.field === t)?.direction === "asc", me = (t) => {
370
+ const d = n.value.find((r) => r.field === t);
371
+ if (!d)
372
+ return "↑↓";
373
+ switch (d.direction) {
374
+ case "asc":
375
+ return "↑";
376
+ // Up arrow for ascending
377
+ case "desc":
378
+ return "↓";
379
+ // Down arrow for descending
380
+ default:
381
+ return "↕️";
382
+ }
383
+ }, J = (t) => e.sortable && t.sortable !== !1, be = (t) => {
384
+ e.clickable && g("row-click", t);
385
+ }, q = (t, d) => {
386
+ let r = d[t.name];
387
+ if (t.suffix && r === void 0) {
388
+ const v = `${t.name}${t.suffix}`;
389
+ r = d[v];
390
+ }
391
+ if (e.getCellData || t.getCellData) {
392
+ const v = t.getCellData || e.getCellData;
393
+ if (v) {
394
+ const s = {
395
+ name: t.name,
396
+ row: d,
397
+ value: r
398
+ };
399
+ r = v(s);
400
+ }
401
+ }
402
+ return r;
403
+ }, ae = (t) => t.width ? t.width === "w-full" ? "w-full" : typeof t.width == "string" ? t.width : typeof t.width == "number" ? `w-${t.width}` : "" : "", G = w(e.page), re = w(e.limit), K = w(e.total), V = w(1), Q = w(10), M = w(0), le = f(() => e.api ? V.value : G.value), ne = f(() => e.api ? Q.value : re.value), se = f(() => e.api ? M.value : K.value), C = f(() => {
404
+ const { theme: t } = e;
405
+ return t === "dark" ? {
406
+ container: "dark",
407
+ loading: "text-gray-400",
408
+ error: "text-red-400",
409
+ thead: "bg-gray-800",
410
+ th: "text-gray-300",
411
+ thHover: "hover:bg-gray-700",
412
+ tbody: "bg-gray-900 divide-gray-700",
413
+ tr: "hover:bg-gray-800",
414
+ td: "text-gray-300",
415
+ empty: "text-gray-400",
416
+ checkbox: "border-gray-600 bg-gray-700 text-blue-400"
417
+ } : t === "light" ? {
418
+ container: "",
419
+ loading: "text-gray-500",
420
+ error: "text-red-500",
421
+ thead: "bg-gray-50",
422
+ th: "text-gray-500",
423
+ thHover: "hover:bg-gray-100",
424
+ tbody: "bg-white divide-gray-200",
425
+ tr: "hover:bg-gray-50",
426
+ td: "text-gray-900",
427
+ empty: "text-gray-500",
428
+ checkbox: "border-gray-300 bg-white text-blue-600"
429
+ } : {
430
+ container: "",
431
+ loading: "text-gray-500 dark:text-gray-400",
432
+ error: "text-red-500 dark:text-red-400",
433
+ thead: "bg-gray-50 dark:bg-gray-800",
434
+ th: "text-gray-500 dark:text-gray-300",
435
+ thHover: "hover:bg-gray-100 dark:hover:bg-gray-700",
436
+ tbody: "bg-white dark:bg-gray-900 divide-gray-200 dark:divide-gray-700",
437
+ tr: "hover:bg-gray-50 dark:hover:bg-gray-800",
438
+ td: "text-gray-900 dark:text-gray-300",
439
+ empty: "text-gray-500 dark:text-gray-400",
440
+ checkbox: "border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-blue-600 dark:text-blue-400"
441
+ };
442
+ });
443
+ A(() => e.page, (t) => {
444
+ G.value = t;
445
+ }), A(() => e.limit, (t) => {
446
+ re.value = t;
447
+ }), A(() => e.total, (t) => {
448
+ K.value = t;
449
+ });
450
+ const N = async () => {
451
+ if (e.api) {
452
+ $.value = !0, T.value = null;
453
+ try {
454
+ const t = new URL(e.api, window.location.origin);
455
+ if (t.searchParams.set("page", le.value.toString()), t.searchParams.set("limit", ne.value.toString()), n.value.length > 0) {
456
+ const v = n.value.filter((s) => s.direction).map((s) => `${s.field}:${s.direction}`).join(",");
457
+ v && t.searchParams.set("sort", v);
458
+ }
459
+ const d = await fetch(t.toString());
460
+ if (!d.ok)
461
+ throw new Error(`HTTP error! status: ${d.status}`);
462
+ const r = await d.json();
463
+ r.rows && Array.isArray(r.rows) && (o.value = r.rows), r.columns && Array.isArray(r.columns) && (_.value = r.columns), r.total !== void 0 && (e.api ? M.value = r.total : K.value = r.total);
464
+ } catch (t) {
465
+ T.value = t instanceof Error ? t.message : "Failed to fetch data", console.error("Error fetching data:", t);
466
+ } finally {
467
+ $.value = !1;
468
+ }
469
+ }
470
+ }, ye = (t) => {
471
+ e.api ? V.value = t : (G.value = t, g("update:page", t)), e.api && N();
472
+ }, he = f(() => e.showPagination && se.value > 0), E = f(() => ({
473
+ small: {
474
+ header: "px-3 py-2 text-xs",
475
+ cell: "px-3 py-2 text-xs"
476
+ },
477
+ medium: {
478
+ header: "px-6 py-3 text-xs",
479
+ cell: "px-6 py-4 text-sm"
480
+ },
481
+ large: {
482
+ header: "px-8 py-4 text-sm",
483
+ cell: "px-8 py-6 text-base"
484
+ }
485
+ })[e.size]);
486
+ ge(() => {
487
+ e.api && (e.page && (V.value = e.page), e.limit && (Q.value = e.limit), e.total && (M.value = e.total), N());
488
+ }), A(() => e.api, (t) => {
489
+ t && (V.value = e.page || 1, Q.value = e.limit || 10, M.value = e.total || 0, N());
490
+ });
491
+ const xe = f(() => e.api ? _.value : e.columns), X = w([]), H = w({});
492
+ _e("registerColumn", (t, d) => {
493
+ X.value.push(t), d && t.slotName && (H.value[t.name] = d);
494
+ });
495
+ const oe = f(() => {
496
+ const t = xe.value || [], d = [], r = F.default?.();
497
+ if (r) {
498
+ const v = r.filter((s) => s.type?.name === "Column" || s.type === "Column" || s.type && typeof s.type == "object" && s.type.name === "Column").map((s) => {
499
+ const h = s.props || s.componentProps || {}, I = h.field || h.name || "", W = h.header || h.label || "", ie = s.children && s.children.body, Y = {
500
+ name: I,
501
+ // Use field as the name for data access
502
+ ua: W,
503
+ // Use header as the display name
504
+ format: h.format || "text",
505
+ slotName: ie ? "body" : void 0,
506
+ ...h
507
+ };
508
+ return ie && Y.name && (H.value[Y.name] = s.children.body), Y;
509
+ });
510
+ d.push(...v);
511
+ }
512
+ if (X.value.length > 0 && d.push(...X.value), d.length > 0) {
513
+ const v = [], s = new Set(d.map((h) => h.name));
514
+ return t.forEach((h) => {
515
+ s.has(h.name) || v.push(h);
516
+ }), v.push(...d), console.log("Combined columns:", {
517
+ default: t.length,
518
+ custom: d.length,
519
+ combined: v.length
520
+ }), v;
521
+ }
522
+ return t.length > 0 ? (console.log("Using default columns:", t.length), t) : [];
523
+ }), ke = (t = "text") => ue[t] || ue.text;
524
+ return (t, d) => (i(), u("div", {
525
+ class: b(["w-full", C.value.container])
526
+ }, [
527
+ $.value || e.loading ? (i(), u("div", Oe, [
528
+ c("div", Je, [
529
+ d[0] || (d[0] = c("div", { class: "animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600" }, null, -1)),
530
+ c("span", {
531
+ class: b(C.value.loading)
532
+ }, "Loading...", 2)
533
+ ])
534
+ ])) : T.value ? (i(), u("div", {
535
+ key: 1,
536
+ class: b(["text-center py-8", C.value.error])
537
+ }, x(T.value), 3)) : !e.loading && m.value.length > 0 ? (i(), u("div", qe, [
538
+ c("div", {
539
+ class: b(t.tableClassWrapper ? t.tableClassWrapper : "relative w-full overflow-auto")
540
+ }, [
541
+ c("table", {
542
+ class: b(t.tableClass),
543
+ style: de(t.tableStyle)
544
+ }, [
545
+ c("thead", {
546
+ class: b(C.value.thead)
547
+ }, [
548
+ c("tr", null, [
549
+ t.selectable ? (i(), u("th", {
550
+ key: 0,
551
+ class: b(["text-left font-medium uppercase tracking-wider", C.value.th, E.value.header, e.classTh, "w-12"])
552
+ }, [
553
+ c("input", {
554
+ type: "checkbox",
555
+ checked: D.value,
556
+ indeterminate: ee.value,
557
+ onChange: te,
558
+ class: b(["h-4 w-4 focus:ring-blue-500 rounded", C.value.checkbox])
559
+ }, null, 42, Ge)
560
+ ], 2)) : z("", !0),
561
+ (i(!0), u(B, null, R(oe.value, (r) => (i(), u("th", {
562
+ key: r.name,
563
+ class: b([
564
+ "text-left font-medium uppercase tracking-wider",
565
+ C.value.th,
566
+ E.value.header,
567
+ e.classTh,
568
+ r.align ? `text-${r.align}` : "",
569
+ J(r) ? ["cursor-pointer", C.value.thHover] : "",
570
+ ae(r)
571
+ ]),
572
+ onClick: (v) => J(r) ? L(r.name) : void 0
573
+ }, [
574
+ c("div", Qe, [
575
+ c("span", null, x(r.ua || r.header || r.name), 1),
576
+ J(r) ? (i(), u("span", Xe, [
577
+ pe(t.$slots, "sort", {
578
+ asc: O(r.name)
579
+ }, () => [
580
+ P(x(me(r.name)), 1)
581
+ ])
582
+ ])) : z("", !0)
583
+ ])
584
+ ], 10, Ke))), 128))
585
+ ])
586
+ ], 2),
587
+ c("tbody", {
588
+ class: b(C.value.tbody)
589
+ }, [
590
+ (i(!0), u(B, null, R(m.value, (r, v) => (i(), u("tr", {
591
+ key: v,
592
+ class: b([
593
+ C.value.tr,
594
+ e.classTr,
595
+ e.clickable ? "cursor-pointer" : ""
596
+ ]),
597
+ onClick: (s) => e.clickable ? be(r) : void 0
598
+ }, [
599
+ t.selectable ? (i(), u("td", {
600
+ key: 0,
601
+ class: b(["whitespace-nowrap", C.value.td, E.value.cell, e.classTd, "w-12"])
602
+ }, [
603
+ c("input", {
604
+ type: "checkbox",
605
+ checked: k(r),
606
+ onChange: (s) => j(r),
607
+ class: b(["h-4 w-4 focus:ring-blue-500 rounded", C.value.checkbox])
608
+ }, null, 42, Ze)
609
+ ], 2)) : z("", !0),
610
+ (i(!0), u(B, null, R(oe.value, (s) => (i(), u("td", {
611
+ key: s.name,
612
+ class: b([
613
+ "whitespace-nowrap",
614
+ C.value.td,
615
+ E.value.cell,
616
+ e.classTd,
617
+ s.align ? `text-${s.align}` : "",
618
+ ae(s)
619
+ ])
620
+ }, [
621
+ s.action && p.value ? (i(), U(Z(p.value), {
622
+ key: 0,
623
+ row: r,
624
+ value: q(s, r)
625
+ }, null, 8, ["row", "value"])) : s.slotName && H.value[s.name] ? (i(), U(Z(H.value[s.name]), {
626
+ key: 1,
627
+ data: r,
628
+ value: q(s, r),
629
+ row: r,
630
+ column: s
631
+ }, null, 8, ["data", "value", "row", "column"])) : (i(), U(Z(ke(s.format)), {
632
+ key: 2,
633
+ value: q(s, r),
634
+ row: r,
635
+ column: s,
636
+ href: s.link?.href,
637
+ target: s.link?.target,
638
+ onClick: s.link?.onClick
639
+ }, null, 8, ["value", "row", "column", "href", "target", "onClick"]))
640
+ ], 2))), 128))
641
+ ], 10, Ye))), 128))
642
+ ], 2)
643
+ ], 6)
644
+ ], 2)
645
+ ])) : z("", !0),
646
+ he.value && !$.value && !e.loading && !T.value ? (i(), U(fe, {
647
+ key: 3,
648
+ page: le.value,
649
+ limit: ne.value,
650
+ total: se.value,
651
+ theme: e.theme,
652
+ size: e.size,
653
+ "onUpdate:page": ye
654
+ }, null, 8, ["page", "limit", "total", "theme", "size"])) : z("", !0),
655
+ !$.value && !e.loading && !T.value && m.value.length === 0 ? (i(), u("div", {
656
+ key: 4,
657
+ class: b(["text-center py-8", C.value.empty])
658
+ }, " Дані відсутні ", 2)) : z("", !0)
659
+ ], 2));
660
+ }
661
+ }), et = { style: { display: "none" } }, tt = /* @__PURE__ */ S({
662
+ name: "Column",
663
+ __name: "Column",
664
+ props: {
665
+ field: {},
666
+ name: {},
667
+ header: {},
668
+ label: {},
669
+ format: {},
670
+ hidden: { type: Boolean },
671
+ sortable: { type: Boolean },
672
+ width: {},
673
+ align: {},
674
+ slot: {},
675
+ slotName: {},
676
+ link: {},
677
+ action: { type: Boolean },
678
+ getCellData: { type: Function },
679
+ suffix: {}
680
+ },
681
+ setup(y) {
682
+ const a = y, e = ve(), g = we("registerColumn");
683
+ return ge(() => {
684
+ if (g) {
685
+ const {
686
+ field: l,
687
+ name: n,
688
+ header: o,
689
+ label: _,
690
+ format: $,
691
+ slotName: T,
692
+ link: F,
693
+ action: p,
694
+ getCellData: m,
695
+ suffix: k,
696
+ ...j
697
+ } = a, L = {
698
+ name: l || n || "",
699
+ ua: o || _ || "",
700
+ format: $ || "text",
701
+ slotName: T || (e.body ? "body" : void 0),
702
+ // Use 'body' slot if it exists
703
+ link: F,
704
+ action: p,
705
+ getCellData: m,
706
+ suffix: k,
707
+ ...j
708
+ };
709
+ console.log("Registering column:", L);
710
+ const O = e.body;
711
+ g(L, O);
712
+ }
713
+ }), (l, n) => (i(), u("div", et, [
714
+ pe(l.$slots, "body", { data: {} })
715
+ ]));
716
+ }
717
+ }), at = { class: "mt-4" }, rt = { class: "text-sm text-gray-600 dark:text-gray-300" }, lt = /* @__PURE__ */ S({
718
+ __name: "SelectionInfo",
719
+ props: {
720
+ selectedRows: {},
721
+ totalCount: {}
722
+ },
723
+ setup(y) {
724
+ const a = y, e = f(() => a.selectedRows.length);
725
+ return (g, l) => (i(), u("div", at, [
726
+ c("div", rt, " Обрано: " + x(e.value) + " з " + x(g.totalCount) + " записів ", 1)
727
+ ]));
728
+ }
729
+ }), nt = { class: "mt-4" }, st = { class: "border-b border-gray-200 dark:border-gray-700" }, ot = { class: "-mb-px flex space-x-8" }, it = ["onClick"], ut = { class: "mt-4" }, ct = { class: "bg-gray-900 rounded-lg overflow-hidden" }, dt = { class: "flex items-center justify-between px-4 py-2 bg-gray-800 border-b border-gray-700" }, vt = { class: "text-sm text-gray-300" }, gt = ["onClick"], pt = { class: "p-4 text-sm text-gray-100 overflow-x-auto" }, ft = /* @__PURE__ */ S({
730
+ __name: "CodeTabs",
731
+ props: {
732
+ tabs: {},
733
+ defaultTab: { default: void 0 }
734
+ },
735
+ setup(y) {
736
+ const a = y, e = w(a.defaultTab || a.tabs[0]?.id || ""), g = async (l) => {
737
+ try {
738
+ await navigator.clipboard.writeText(l), console.log("Код скопійовано!");
739
+ } catch (n) {
740
+ console.error("Помилка копіювання:", n);
741
+ }
742
+ };
743
+ return (l, n) => (i(), u("div", nt, [
744
+ c("div", st, [
745
+ c("nav", ot, [
746
+ (i(!0), u(B, null, R(l.tabs, (o) => (i(), u("button", {
747
+ key: o.id,
748
+ onClick: (_) => e.value = o.id,
749
+ class: b([
750
+ "py-2 px-1 border-b-2 font-medium text-sm transition-colors",
751
+ e.value === o.id ? "border-blue-500 text-blue-600 dark:text-blue-400" : "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"
752
+ ])
753
+ }, x(o.label), 11, it))), 128))
754
+ ])
755
+ ]),
756
+ c("div", ut, [
757
+ (i(!0), u(B, null, R(l.tabs, (o) => Ce((i(), u("div", {
758
+ key: o.id
759
+ }, [
760
+ c("div", ct, [
761
+ c("div", dt, [
762
+ c("span", vt, x(o.label), 1),
763
+ c("button", {
764
+ onClick: (_) => g(o.content),
765
+ class: "text-gray-400 hover:text-white transition-colors",
766
+ title: "Копіювати код"
767
+ }, n[0] || (n[0] = [
768
+ c("svg", {
769
+ class: "w-4 h-4",
770
+ fill: "none",
771
+ stroke: "currentColor",
772
+ viewBox: "0 0 24 24"
773
+ }, [
774
+ c("path", {
775
+ "stroke-linecap": "round",
776
+ "stroke-linejoin": "round",
777
+ "stroke-width": "2",
778
+ d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
779
+ })
780
+ ], -1)
781
+ ]), 8, gt)
782
+ ]),
783
+ c("pre", pt, [
784
+ c("code", null, x(o.content), 1)
785
+ ])
786
+ ])
787
+ ])), [
788
+ [$e, e.value === o.id]
789
+ ])), 128))
790
+ ])
791
+ ]));
792
+ }
793
+ });
794
+ ce.install = function(a) {
795
+ a.component("DataTable", ce), a.component("Column", tt), a.component("Pagination", fe), a.component("SelectionInfo", lt), a.component("CodeTabs", ft);
796
+ };
797
+ export {
798
+ je as ArrayFormat,
799
+ Be as BadgeFormat,
800
+ ft as CodeTabs,
801
+ tt as Column,
802
+ ce as DataTable,
803
+ Se as DateFormat,
804
+ Ae as LinkFormat,
805
+ Te as NumberFormat,
806
+ fe as Pagination,
807
+ lt as SelectionInfo,
808
+ De as TextFormat,
809
+ ce as default,
810
+ ue as formatComponents
811
+ };