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