@opengis/table 0.0.14 → 0.0.16

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