@forjedio/inertia-table-vue 1.0.0
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/LICENSE +21 -0
- package/README.md +94 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +262 -0
- package/dist/index.js +1093 -0
- package/package.json +75 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1093 @@
|
|
|
1
|
+
import { ref as ye, onUnmounted as ue, watch as ve, defineComponent as A, openBlock as $, createElementBlock as w, toDisplayString as I, computed as P, normalizeClass as F, createBlock as de, resolveDynamicComponent as be, createCommentVNode as K, createTextVNode as ke, unref as p, withCtx as Pe, h as L, createElementVNode as B, useSlots as Re, renderSlot as Q, createVNode as re, Fragment as he, renderList as ge, mergeProps as Be } from "vue";
|
|
2
|
+
import { router as ce, Link as Oe } from "@inertiajs/vue3";
|
|
3
|
+
function ae(e, n = "page") {
|
|
4
|
+
const t = new URL(window.location.href);
|
|
5
|
+
for (const [s, f] of Object.entries(e))
|
|
6
|
+
f === null ? t.searchParams.delete(s) : t.searchParams.set(s, f);
|
|
7
|
+
n in e || t.searchParams.delete(n), ce.get(t.toString(), {}, { preserveState: !0, preserveScroll: !0 });
|
|
8
|
+
}
|
|
9
|
+
function He(e, n, t, c) {
|
|
10
|
+
const s = ye(
|
|
11
|
+
typeof window < "u" ? new URLSearchParams(window.location.search).get(n) ?? "" : ""
|
|
12
|
+
);
|
|
13
|
+
let f = null;
|
|
14
|
+
function d(l) {
|
|
15
|
+
s.value = l, f && clearTimeout(f), f = setTimeout(() => {
|
|
16
|
+
ae(
|
|
17
|
+
{ [n]: l || null },
|
|
18
|
+
t
|
|
19
|
+
);
|
|
20
|
+
}, e);
|
|
21
|
+
}
|
|
22
|
+
return ue(() => {
|
|
23
|
+
f && clearTimeout(f);
|
|
24
|
+
}), c && ve(c, (l, g, i) => {
|
|
25
|
+
if (!l || typeof window > "u") return;
|
|
26
|
+
const b = new URLSearchParams(window.location.search).get(n) ?? "";
|
|
27
|
+
l.value !== b && (l.value = b);
|
|
28
|
+
const D = () => {
|
|
29
|
+
d(l.value);
|
|
30
|
+
};
|
|
31
|
+
l.addEventListener("input", D), i(() => {
|
|
32
|
+
l.removeEventListener("input", D);
|
|
33
|
+
});
|
|
34
|
+
}, { immediate: !0 }), { searchTerm: s, onSearch: d, hasExternalSearch: !!c };
|
|
35
|
+
}
|
|
36
|
+
function xe(e) {
|
|
37
|
+
return e ? e.startsWith("-") ? { sortBy: e.slice(1), sortDir: "desc" } : { sortBy: e, sortDir: "asc" } : { sortBy: null, sortDir: "asc" };
|
|
38
|
+
}
|
|
39
|
+
function je(e, n) {
|
|
40
|
+
const t = typeof window < "u" ? window.location.search : "", c = new URLSearchParams(t), { sortBy: s, sortDir: f } = xe(c.get(e));
|
|
41
|
+
function d(g) {
|
|
42
|
+
const i = new URLSearchParams(window.location.search), { sortBy: v, sortDir: b } = xe(i.get(e));
|
|
43
|
+
ae(v === g ? b === "asc" ? { [e]: `-${g}` } : { [e]: null } : { [e]: g }, n);
|
|
44
|
+
}
|
|
45
|
+
function l(g) {
|
|
46
|
+
return {
|
|
47
|
+
active: s === g,
|
|
48
|
+
direction: s === g ? f : null
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return { sortBy: s, sortDir: f, onSort: d, getSortState: l };
|
|
52
|
+
}
|
|
53
|
+
function Le(e) {
|
|
54
|
+
function n(t) {
|
|
55
|
+
ae({ [e]: String(t) }, e);
|
|
56
|
+
}
|
|
57
|
+
return { onPageChange: n };
|
|
58
|
+
}
|
|
59
|
+
const X = /* @__PURE__ */ new Map();
|
|
60
|
+
function Rt(e, n) {
|
|
61
|
+
X.has(e) || X.set(e, []), X.get(e).push(n);
|
|
62
|
+
}
|
|
63
|
+
function Bt(e) {
|
|
64
|
+
e ? X.delete(e) : X.clear();
|
|
65
|
+
}
|
|
66
|
+
function _e(e) {
|
|
67
|
+
let n = "";
|
|
68
|
+
const t = [];
|
|
69
|
+
function c() {
|
|
70
|
+
const s = JSON.stringify(e.tableSettings);
|
|
71
|
+
if (n === s) return;
|
|
72
|
+
n = s, t.forEach((d) => d()), t.length = 0;
|
|
73
|
+
const f = () => {
|
|
74
|
+
ce.reload();
|
|
75
|
+
};
|
|
76
|
+
for (const [d, l] of Object.entries(e.tableSettings)) {
|
|
77
|
+
const g = X.get(d) ?? [];
|
|
78
|
+
for (const i of g) {
|
|
79
|
+
const b = i({ value: l, tableData: e, refresh: f });
|
|
80
|
+
typeof b == "function" && t.push(b);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
ve(
|
|
85
|
+
() => e.tableSettings,
|
|
86
|
+
() => c(),
|
|
87
|
+
{ immediate: !0, deep: !0 }
|
|
88
|
+
), ue(() => {
|
|
89
|
+
t.forEach((s) => s()), t.length = 0;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function Ie(e, n, t) {
|
|
93
|
+
return "key" in n && n.key ? e[n.key] : e[t];
|
|
94
|
+
}
|
|
95
|
+
const Ae = {
|
|
96
|
+
key: 0,
|
|
97
|
+
class: "text-gray-400 dark:text-gray-500"
|
|
98
|
+
}, Ee = { key: 1 }, Se = /* @__PURE__ */ A({
|
|
99
|
+
__name: "TextCell",
|
|
100
|
+
props: {
|
|
101
|
+
value: {},
|
|
102
|
+
nullText: {}
|
|
103
|
+
},
|
|
104
|
+
setup(e) {
|
|
105
|
+
return (n, t) => e.value == null ? ($(), w("span", Ae, I(e.nullText ?? "-"), 1)) : ($(), w("span", Ee, I(String(e.value)), 1));
|
|
106
|
+
}
|
|
107
|
+
}), pe = /* @__PURE__ */ new Map();
|
|
108
|
+
function Ot(e, n) {
|
|
109
|
+
pe.set(e, n);
|
|
110
|
+
}
|
|
111
|
+
function Ht(e) {
|
|
112
|
+
for (const [n, t] of Object.entries(e))
|
|
113
|
+
pe.set(n, t);
|
|
114
|
+
}
|
|
115
|
+
function Te(e) {
|
|
116
|
+
return pe.get(e);
|
|
117
|
+
}
|
|
118
|
+
const Ye = {
|
|
119
|
+
key: 0,
|
|
120
|
+
class: "text-gray-400 dark:text-gray-500"
|
|
121
|
+
}, Ue = ["title"], Ve = /* @__PURE__ */ A({
|
|
122
|
+
__name: "BadgeCell",
|
|
123
|
+
props: {
|
|
124
|
+
value: {},
|
|
125
|
+
variant: {},
|
|
126
|
+
colorField: {},
|
|
127
|
+
tooltipKey: {},
|
|
128
|
+
iconKey: {},
|
|
129
|
+
row: {},
|
|
130
|
+
nullText: {},
|
|
131
|
+
iconResolver: { type: Function }
|
|
132
|
+
},
|
|
133
|
+
setup(e) {
|
|
134
|
+
const n = {
|
|
135
|
+
default: "bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200",
|
|
136
|
+
success: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",
|
|
137
|
+
warning: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",
|
|
138
|
+
danger: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",
|
|
139
|
+
destructive: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",
|
|
140
|
+
info: "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",
|
|
141
|
+
gray: "bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",
|
|
142
|
+
outline: "bg-transparent text-gray-700 border border-gray-300 dark:text-gray-300 dark:border-gray-600"
|
|
143
|
+
}, t = e, c = P(() => t.colorField && t.row[t.colorField] ? String(t.row[t.colorField]) : t.variant ?? "default"), s = P(() => n[c.value] ?? n.default), f = P(() => t.tooltipKey ? t.row[t.tooltipKey] : void 0), d = P(() => {
|
|
144
|
+
var g;
|
|
145
|
+
if (!t.iconKey) return null;
|
|
146
|
+
const l = t.row[t.iconKey];
|
|
147
|
+
return l ? ((g = t.iconResolver) == null ? void 0 : g.call(t, l)) ?? Te(l) ?? null : null;
|
|
148
|
+
});
|
|
149
|
+
return (l, g) => e.value == null ? ($(), w("span", Ye, I(e.nullText ?? "-"), 1)) : ($(), w("span", {
|
|
150
|
+
key: 1,
|
|
151
|
+
class: F(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium ${s.value}`),
|
|
152
|
+
title: f.value
|
|
153
|
+
}, [
|
|
154
|
+
d.value ? ($(), de(be(d.value), {
|
|
155
|
+
key: 0,
|
|
156
|
+
class: "h-3 w-3"
|
|
157
|
+
})) : K("", !0),
|
|
158
|
+
ke(" " + I(String(e.value)), 1)
|
|
159
|
+
], 10, Ue));
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
function We(e) {
|
|
163
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
164
|
+
}
|
|
165
|
+
var le = { exports: {} }, ze = le.exports, we;
|
|
166
|
+
function Je() {
|
|
167
|
+
return we || (we = 1, (function(e, n) {
|
|
168
|
+
(function(t, c) {
|
|
169
|
+
e.exports = c();
|
|
170
|
+
})(ze, (function() {
|
|
171
|
+
var t = 1e3, c = 6e4, s = 36e5, f = "millisecond", d = "second", l = "minute", g = "hour", i = "day", v = "week", b = "month", D = "quarter", S = "year", O = "date", E = "Invalid Date", z = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, ee = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(h) {
|
|
172
|
+
var o = ["th", "st", "nd", "rd"], r = h % 100;
|
|
173
|
+
return "[" + h + (o[(r - 20) % 10] || o[r] || o[0]) + "]";
|
|
174
|
+
} }, Y = function(h, o, r) {
|
|
175
|
+
var u = String(h);
|
|
176
|
+
return !u || u.length >= o ? h : "" + Array(o + 1 - u.length).join(r) + h;
|
|
177
|
+
}, H = { s: Y, z: function(h) {
|
|
178
|
+
var o = -h.utcOffset(), r = Math.abs(o), u = Math.floor(r / 60), a = r % 60;
|
|
179
|
+
return (o <= 0 ? "+" : "-") + Y(u, 2, "0") + ":" + Y(a, 2, "0");
|
|
180
|
+
}, m: function h(o, r) {
|
|
181
|
+
if (o.date() < r.date()) return -h(r, o);
|
|
182
|
+
var u = 12 * (r.year() - o.year()) + (r.month() - o.month()), a = o.clone().add(u, b), m = r - a < 0, y = o.clone().add(u + (m ? -1 : 1), b);
|
|
183
|
+
return +(-(u + (r - a) / (m ? a - y : y - a)) || 0);
|
|
184
|
+
}, a: function(h) {
|
|
185
|
+
return h < 0 ? Math.ceil(h) || 0 : Math.floor(h);
|
|
186
|
+
}, p: function(h) {
|
|
187
|
+
return { M: b, y: S, w: v, d: i, D: O, h: g, m: l, s: d, ms: f, Q: D }[h] || String(h || "").toLowerCase().replace(/s$/, "");
|
|
188
|
+
}, u: function(h) {
|
|
189
|
+
return h === void 0;
|
|
190
|
+
} }, W = "en", U = {};
|
|
191
|
+
U[W] = M;
|
|
192
|
+
var V = "$isDayjsObject", fe = function(h) {
|
|
193
|
+
return h instanceof se || !(!h || !h[V]);
|
|
194
|
+
}, oe = function h(o, r, u) {
|
|
195
|
+
var a;
|
|
196
|
+
if (!o) return W;
|
|
197
|
+
if (typeof o == "string") {
|
|
198
|
+
var m = o.toLowerCase();
|
|
199
|
+
U[m] && (a = m), r && (U[m] = r, a = m);
|
|
200
|
+
var y = o.split("-");
|
|
201
|
+
if (!a && y.length > 1) return h(y[0]);
|
|
202
|
+
} else {
|
|
203
|
+
var x = o.name;
|
|
204
|
+
U[x] = o, a = x;
|
|
205
|
+
}
|
|
206
|
+
return !u && a && (W = a), a || !u && W;
|
|
207
|
+
}, T = function(h, o) {
|
|
208
|
+
if (fe(h)) return h.clone();
|
|
209
|
+
var r = typeof o == "object" ? o : {};
|
|
210
|
+
return r.date = h, r.args = arguments, new se(r);
|
|
211
|
+
}, k = H;
|
|
212
|
+
k.l = oe, k.i = fe, k.w = function(h, o) {
|
|
213
|
+
return T(h, { locale: o.$L, utc: o.$u, x: o.$x, $offset: o.$offset });
|
|
214
|
+
};
|
|
215
|
+
var se = (function() {
|
|
216
|
+
function h(r) {
|
|
217
|
+
this.$L = oe(r.locale, null, !0), this.parse(r), this.$x = this.$x || r.x || {}, this[V] = !0;
|
|
218
|
+
}
|
|
219
|
+
var o = h.prototype;
|
|
220
|
+
return o.parse = function(r) {
|
|
221
|
+
this.$d = (function(u) {
|
|
222
|
+
var a = u.date, m = u.utc;
|
|
223
|
+
if (a === null) return /* @__PURE__ */ new Date(NaN);
|
|
224
|
+
if (k.u(a)) return /* @__PURE__ */ new Date();
|
|
225
|
+
if (a instanceof Date) return new Date(a);
|
|
226
|
+
if (typeof a == "string" && !/Z$/i.test(a)) {
|
|
227
|
+
var y = a.match(z);
|
|
228
|
+
if (y) {
|
|
229
|
+
var x = y[2] - 1 || 0, C = (y[7] || "0").substring(0, 3);
|
|
230
|
+
return m ? new Date(Date.UTC(y[1], x, y[3] || 1, y[4] || 0, y[5] || 0, y[6] || 0, C)) : new Date(y[1], x, y[3] || 1, y[4] || 0, y[5] || 0, y[6] || 0, C);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return new Date(a);
|
|
234
|
+
})(r), this.init();
|
|
235
|
+
}, o.init = function() {
|
|
236
|
+
var r = this.$d;
|
|
237
|
+
this.$y = r.getFullYear(), this.$M = r.getMonth(), this.$D = r.getDate(), this.$W = r.getDay(), this.$H = r.getHours(), this.$m = r.getMinutes(), this.$s = r.getSeconds(), this.$ms = r.getMilliseconds();
|
|
238
|
+
}, o.$utils = function() {
|
|
239
|
+
return k;
|
|
240
|
+
}, o.isValid = function() {
|
|
241
|
+
return this.$d.toString() !== E;
|
|
242
|
+
}, o.isSame = function(r, u) {
|
|
243
|
+
var a = T(r);
|
|
244
|
+
return this.startOf(u) <= a && a <= this.endOf(u);
|
|
245
|
+
}, o.isAfter = function(r, u) {
|
|
246
|
+
return T(r) < this.startOf(u);
|
|
247
|
+
}, o.isBefore = function(r, u) {
|
|
248
|
+
return this.endOf(u) < T(r);
|
|
249
|
+
}, o.$g = function(r, u, a) {
|
|
250
|
+
return k.u(r) ? this[u] : this.set(a, r);
|
|
251
|
+
}, o.unix = function() {
|
|
252
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
253
|
+
}, o.valueOf = function() {
|
|
254
|
+
return this.$d.getTime();
|
|
255
|
+
}, o.startOf = function(r, u) {
|
|
256
|
+
var a = this, m = !!k.u(u) || u, y = k.p(r), x = function(q, j) {
|
|
257
|
+
var J = k.w(a.$u ? Date.UTC(a.$y, j, q) : new Date(a.$y, j, q), a);
|
|
258
|
+
return m ? J : J.endOf(i);
|
|
259
|
+
}, C = function(q, j) {
|
|
260
|
+
return k.w(a.toDate()[q].apply(a.toDate("s"), (m ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(j)), a);
|
|
261
|
+
}, N = this.$W, R = this.$M, _ = this.$D, G = "set" + (this.$u ? "UTC" : "");
|
|
262
|
+
switch (y) {
|
|
263
|
+
case S:
|
|
264
|
+
return m ? x(1, 0) : x(31, 11);
|
|
265
|
+
case b:
|
|
266
|
+
return m ? x(1, R) : x(0, R + 1);
|
|
267
|
+
case v:
|
|
268
|
+
var Z = this.$locale().weekStart || 0, te = (N < Z ? N + 7 : N) - Z;
|
|
269
|
+
return x(m ? _ - te : _ + (6 - te), R);
|
|
270
|
+
case i:
|
|
271
|
+
case O:
|
|
272
|
+
return C(G + "Hours", 0);
|
|
273
|
+
case g:
|
|
274
|
+
return C(G + "Minutes", 1);
|
|
275
|
+
case l:
|
|
276
|
+
return C(G + "Seconds", 2);
|
|
277
|
+
case d:
|
|
278
|
+
return C(G + "Milliseconds", 3);
|
|
279
|
+
default:
|
|
280
|
+
return this.clone();
|
|
281
|
+
}
|
|
282
|
+
}, o.endOf = function(r) {
|
|
283
|
+
return this.startOf(r, !1);
|
|
284
|
+
}, o.$set = function(r, u) {
|
|
285
|
+
var a, m = k.p(r), y = "set" + (this.$u ? "UTC" : ""), x = (a = {}, a[i] = y + "Date", a[O] = y + "Date", a[b] = y + "Month", a[S] = y + "FullYear", a[g] = y + "Hours", a[l] = y + "Minutes", a[d] = y + "Seconds", a[f] = y + "Milliseconds", a)[m], C = m === i ? this.$D + (u - this.$W) : u;
|
|
286
|
+
if (m === b || m === S) {
|
|
287
|
+
var N = this.clone().set(O, 1);
|
|
288
|
+
N.$d[x](C), N.init(), this.$d = N.set(O, Math.min(this.$D, N.daysInMonth())).$d;
|
|
289
|
+
} else x && this.$d[x](C);
|
|
290
|
+
return this.init(), this;
|
|
291
|
+
}, o.set = function(r, u) {
|
|
292
|
+
return this.clone().$set(r, u);
|
|
293
|
+
}, o.get = function(r) {
|
|
294
|
+
return this[k.p(r)]();
|
|
295
|
+
}, o.add = function(r, u) {
|
|
296
|
+
var a, m = this;
|
|
297
|
+
r = Number(r);
|
|
298
|
+
var y = k.p(u), x = function(R) {
|
|
299
|
+
var _ = T(m);
|
|
300
|
+
return k.w(_.date(_.date() + Math.round(R * r)), m);
|
|
301
|
+
};
|
|
302
|
+
if (y === b) return this.set(b, this.$M + r);
|
|
303
|
+
if (y === S) return this.set(S, this.$y + r);
|
|
304
|
+
if (y === i) return x(1);
|
|
305
|
+
if (y === v) return x(7);
|
|
306
|
+
var C = (a = {}, a[l] = c, a[g] = s, a[d] = t, a)[y] || 1, N = this.$d.getTime() + r * C;
|
|
307
|
+
return k.w(N, this);
|
|
308
|
+
}, o.subtract = function(r, u) {
|
|
309
|
+
return this.add(-1 * r, u);
|
|
310
|
+
}, o.format = function(r) {
|
|
311
|
+
var u = this, a = this.$locale();
|
|
312
|
+
if (!this.isValid()) return a.invalidDate || E;
|
|
313
|
+
var m = r || "YYYY-MM-DDTHH:mm:ssZ", y = k.z(this), x = this.$H, C = this.$m, N = this.$M, R = a.weekdays, _ = a.months, G = a.meridiem, Z = function(j, J, ne, ie) {
|
|
314
|
+
return j && (j[J] || j(u, m)) || ne[J].slice(0, ie);
|
|
315
|
+
}, te = function(j) {
|
|
316
|
+
return k.s(x % 12 || 12, j, "0");
|
|
317
|
+
}, q = G || function(j, J, ne) {
|
|
318
|
+
var ie = j < 12 ? "AM" : "PM";
|
|
319
|
+
return ne ? ie.toLowerCase() : ie;
|
|
320
|
+
};
|
|
321
|
+
return m.replace(ee, (function(j, J) {
|
|
322
|
+
return J || (function(ne) {
|
|
323
|
+
switch (ne) {
|
|
324
|
+
case "YY":
|
|
325
|
+
return String(u.$y).slice(-2);
|
|
326
|
+
case "YYYY":
|
|
327
|
+
return k.s(u.$y, 4, "0");
|
|
328
|
+
case "M":
|
|
329
|
+
return N + 1;
|
|
330
|
+
case "MM":
|
|
331
|
+
return k.s(N + 1, 2, "0");
|
|
332
|
+
case "MMM":
|
|
333
|
+
return Z(a.monthsShort, N, _, 3);
|
|
334
|
+
case "MMMM":
|
|
335
|
+
return Z(_, N);
|
|
336
|
+
case "D":
|
|
337
|
+
return u.$D;
|
|
338
|
+
case "DD":
|
|
339
|
+
return k.s(u.$D, 2, "0");
|
|
340
|
+
case "d":
|
|
341
|
+
return String(u.$W);
|
|
342
|
+
case "dd":
|
|
343
|
+
return Z(a.weekdaysMin, u.$W, R, 2);
|
|
344
|
+
case "ddd":
|
|
345
|
+
return Z(a.weekdaysShort, u.$W, R, 3);
|
|
346
|
+
case "dddd":
|
|
347
|
+
return R[u.$W];
|
|
348
|
+
case "H":
|
|
349
|
+
return String(x);
|
|
350
|
+
case "HH":
|
|
351
|
+
return k.s(x, 2, "0");
|
|
352
|
+
case "h":
|
|
353
|
+
return te(1);
|
|
354
|
+
case "hh":
|
|
355
|
+
return te(2);
|
|
356
|
+
case "a":
|
|
357
|
+
return q(x, C, !0);
|
|
358
|
+
case "A":
|
|
359
|
+
return q(x, C, !1);
|
|
360
|
+
case "m":
|
|
361
|
+
return String(C);
|
|
362
|
+
case "mm":
|
|
363
|
+
return k.s(C, 2, "0");
|
|
364
|
+
case "s":
|
|
365
|
+
return String(u.$s);
|
|
366
|
+
case "ss":
|
|
367
|
+
return k.s(u.$s, 2, "0");
|
|
368
|
+
case "SSS":
|
|
369
|
+
return k.s(u.$ms, 3, "0");
|
|
370
|
+
case "Z":
|
|
371
|
+
return y;
|
|
372
|
+
}
|
|
373
|
+
return null;
|
|
374
|
+
})(j) || y.replace(":", "");
|
|
375
|
+
}));
|
|
376
|
+
}, o.utcOffset = function() {
|
|
377
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
378
|
+
}, o.diff = function(r, u, a) {
|
|
379
|
+
var m, y = this, x = k.p(u), C = T(r), N = (C.utcOffset() - this.utcOffset()) * c, R = this - C, _ = function() {
|
|
380
|
+
return k.m(y, C);
|
|
381
|
+
};
|
|
382
|
+
switch (x) {
|
|
383
|
+
case S:
|
|
384
|
+
m = _() / 12;
|
|
385
|
+
break;
|
|
386
|
+
case b:
|
|
387
|
+
m = _();
|
|
388
|
+
break;
|
|
389
|
+
case D:
|
|
390
|
+
m = _() / 3;
|
|
391
|
+
break;
|
|
392
|
+
case v:
|
|
393
|
+
m = (R - N) / 6048e5;
|
|
394
|
+
break;
|
|
395
|
+
case i:
|
|
396
|
+
m = (R - N) / 864e5;
|
|
397
|
+
break;
|
|
398
|
+
case g:
|
|
399
|
+
m = R / s;
|
|
400
|
+
break;
|
|
401
|
+
case l:
|
|
402
|
+
m = R / c;
|
|
403
|
+
break;
|
|
404
|
+
case d:
|
|
405
|
+
m = R / t;
|
|
406
|
+
break;
|
|
407
|
+
default:
|
|
408
|
+
m = R;
|
|
409
|
+
}
|
|
410
|
+
return a ? m : k.a(m);
|
|
411
|
+
}, o.daysInMonth = function() {
|
|
412
|
+
return this.endOf(b).$D;
|
|
413
|
+
}, o.$locale = function() {
|
|
414
|
+
return U[this.$L];
|
|
415
|
+
}, o.locale = function(r, u) {
|
|
416
|
+
if (!r) return this.$L;
|
|
417
|
+
var a = this.clone(), m = oe(r, u, !0);
|
|
418
|
+
return m && (a.$L = m), a;
|
|
419
|
+
}, o.clone = function() {
|
|
420
|
+
return k.w(this.$d, this);
|
|
421
|
+
}, o.toDate = function() {
|
|
422
|
+
return new Date(this.valueOf());
|
|
423
|
+
}, o.toJSON = function() {
|
|
424
|
+
return this.isValid() ? this.toISOString() : null;
|
|
425
|
+
}, o.toISOString = function() {
|
|
426
|
+
return this.$d.toISOString();
|
|
427
|
+
}, o.toString = function() {
|
|
428
|
+
return this.$d.toUTCString();
|
|
429
|
+
}, h;
|
|
430
|
+
})(), $e = se.prototype;
|
|
431
|
+
return T.prototype = $e, [["$ms", f], ["$s", d], ["$m", l], ["$H", g], ["$W", i], ["$M", b], ["$y", S], ["$D", O]].forEach((function(h) {
|
|
432
|
+
$e[h[1]] = function(o) {
|
|
433
|
+
return this.$g(o, h[0], h[1]);
|
|
434
|
+
};
|
|
435
|
+
})), T.extend = function(h, o) {
|
|
436
|
+
return h.$i || (h(o, se, T), h.$i = !0), T;
|
|
437
|
+
}, T.locale = oe, T.isDayjs = fe, T.unix = function(h) {
|
|
438
|
+
return T(1e3 * h);
|
|
439
|
+
}, T.en = U[W], T.Ls = U, T.p = {}, T;
|
|
440
|
+
}));
|
|
441
|
+
})(le)), le.exports;
|
|
442
|
+
}
|
|
443
|
+
var Ke = Je();
|
|
444
|
+
const Ze = /* @__PURE__ */ We(Ke);
|
|
445
|
+
let Ne = (e, n) => Ze(String(e)).format(n ?? "YYYY-MM-DD HH:mm:ss");
|
|
446
|
+
function jt(e) {
|
|
447
|
+
Ne = e;
|
|
448
|
+
}
|
|
449
|
+
function qe(e, n) {
|
|
450
|
+
return Ne(e, n);
|
|
451
|
+
}
|
|
452
|
+
const Ge = {
|
|
453
|
+
key: 0,
|
|
454
|
+
class: "text-gray-400 dark:text-gray-500"
|
|
455
|
+
}, Qe = ["datetime"], Xe = /* @__PURE__ */ A({
|
|
456
|
+
__name: "DateCell",
|
|
457
|
+
props: {
|
|
458
|
+
value: {},
|
|
459
|
+
format: {},
|
|
460
|
+
tableFormat: {}
|
|
461
|
+
},
|
|
462
|
+
setup(e) {
|
|
463
|
+
const n = e, t = P(() => qe(n.value, n.format ?? n.tableFormat));
|
|
464
|
+
return (c, s) => e.value == null ? ($(), w("span", Ge, "-")) : ($(), w("time", {
|
|
465
|
+
key: 1,
|
|
466
|
+
datetime: String(e.value),
|
|
467
|
+
class: "text-sm text-gray-600 dark:text-gray-400"
|
|
468
|
+
}, I(t.value), 9, Qe));
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
function et(e, n) {
|
|
472
|
+
const t = {};
|
|
473
|
+
for (const [c, s] of Object.entries(n))
|
|
474
|
+
if (s.startsWith(":")) {
|
|
475
|
+
const f = s.slice(1);
|
|
476
|
+
t[c] = e[f];
|
|
477
|
+
} else
|
|
478
|
+
t[c] = s;
|
|
479
|
+
return t;
|
|
480
|
+
}
|
|
481
|
+
function tt(e, n) {
|
|
482
|
+
const t = window.route;
|
|
483
|
+
return typeof t == "function" ? t(e, n) : (console.warn(
|
|
484
|
+
`[inertia-table-vue] Ziggy route() not found. Set 'use_ziggy' => false in config to resolve routes server-side, or install ziggy-js. Route: ${e}`
|
|
485
|
+
), "#");
|
|
486
|
+
}
|
|
487
|
+
const nt = {
|
|
488
|
+
key: 0,
|
|
489
|
+
class: "text-gray-400 dark:text-gray-500"
|
|
490
|
+
}, rt = {
|
|
491
|
+
key: 1,
|
|
492
|
+
class: "text-gray-400 dark:text-gray-500"
|
|
493
|
+
}, at = /* @__PURE__ */ A({
|
|
494
|
+
__name: "LinkCell",
|
|
495
|
+
props: {
|
|
496
|
+
value: {},
|
|
497
|
+
route: {},
|
|
498
|
+
params: {},
|
|
499
|
+
resolvedHref: {},
|
|
500
|
+
row: {},
|
|
501
|
+
prefetch: { type: Boolean },
|
|
502
|
+
nullText: {}
|
|
503
|
+
},
|
|
504
|
+
setup(e) {
|
|
505
|
+
const n = e, t = P(() => {
|
|
506
|
+
if (n.resolvedHref) return n.resolvedHref;
|
|
507
|
+
if (n.route && n.params) {
|
|
508
|
+
const c = et(n.row, n.params);
|
|
509
|
+
return tt(n.route, c);
|
|
510
|
+
}
|
|
511
|
+
return null;
|
|
512
|
+
});
|
|
513
|
+
return (c, s) => e.value == null ? ($(), w("span", nt, I(e.nullText ?? "-"), 1)) : t.value ? ($(), de(p(Oe), {
|
|
514
|
+
key: 2,
|
|
515
|
+
href: t.value,
|
|
516
|
+
prefetch: e.prefetch !== !1 ? "hover" : void 0,
|
|
517
|
+
class: "text-blue-600 hover:text-blue-800 hover:underline dark:text-blue-400 dark:hover:text-blue-300"
|
|
518
|
+
}, {
|
|
519
|
+
default: Pe(() => [
|
|
520
|
+
ke(I(String(e.value)), 1)
|
|
521
|
+
]),
|
|
522
|
+
_: 1
|
|
523
|
+
}, 8, ["href", "prefetch"])) : ($(), w("span", rt, I(String(e.value)), 1));
|
|
524
|
+
}
|
|
525
|
+
}), ot = {
|
|
526
|
+
key: 0,
|
|
527
|
+
class: "text-gray-400 dark:text-gray-500"
|
|
528
|
+
}, st = ["aria-label", "title"], it = {
|
|
529
|
+
class: "h-3.5 w-3.5",
|
|
530
|
+
fill: "none",
|
|
531
|
+
viewBox: "0 0 24 24",
|
|
532
|
+
"stroke-width": "1.5",
|
|
533
|
+
stroke: "currentColor"
|
|
534
|
+
}, lt = {
|
|
535
|
+
key: 0,
|
|
536
|
+
"stroke-linecap": "round",
|
|
537
|
+
"stroke-linejoin": "round",
|
|
538
|
+
d: "M4.5 12.75l6 6 9-13.5"
|
|
539
|
+
}, ct = {
|
|
540
|
+
key: 1,
|
|
541
|
+
"stroke-linecap": "round",
|
|
542
|
+
"stroke-linejoin": "round",
|
|
543
|
+
d: "M15.666 3.888A2.25 2.25 0 0013.5 2.25h-3c-1.03 0-1.9.693-2.166 1.638m7.332 0c.055.194.084.4.084.612v0a.75.75 0 01-.75.75H9.75a.75.75 0 01-.75-.75v0c0-.212.03-.418.084-.612m7.332 0c.646.049 1.288.11 1.927.184 1.1.128 1.907 1.077 1.907 2.185V19.5a2.25 2.25 0 01-2.25 2.25H6.75A2.25 2.25 0 014.5 19.5V6.257c0-1.108.806-2.057 1.907-2.185a48.208 48.208 0 011.927-.184"
|
|
544
|
+
}, ut = /* @__PURE__ */ A({
|
|
545
|
+
__name: "CopyableCell",
|
|
546
|
+
props: {
|
|
547
|
+
value: {},
|
|
548
|
+
nullText: {}
|
|
549
|
+
},
|
|
550
|
+
setup(e) {
|
|
551
|
+
const n = e, t = ye(!1);
|
|
552
|
+
let c = null;
|
|
553
|
+
function s() {
|
|
554
|
+
n.value != null && navigator.clipboard.writeText(String(n.value)).then(() => {
|
|
555
|
+
t.value = !0, c && clearTimeout(c), c = setTimeout(() => t.value = !1, 2e3);
|
|
556
|
+
}).catch(() => {
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
return ue(() => {
|
|
560
|
+
c && clearTimeout(c);
|
|
561
|
+
}), (f, d) => e.value == null ? ($(), w("span", ot, I(e.nullText ?? "-"), 1)) : ($(), w("button", {
|
|
562
|
+
key: 1,
|
|
563
|
+
type: "button",
|
|
564
|
+
onClick: s,
|
|
565
|
+
class: F([
|
|
566
|
+
"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium transition-colors",
|
|
567
|
+
t.value ? "bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300" : "bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"
|
|
568
|
+
]),
|
|
569
|
+
"aria-label": t.value ? "Copied!" : `Copy ${String(e.value)} to clipboard`,
|
|
570
|
+
title: t.value ? "Copied!" : "Click to copy"
|
|
571
|
+
}, [
|
|
572
|
+
ke(I(String(e.value)) + " ", 1),
|
|
573
|
+
($(), w("svg", it, [
|
|
574
|
+
t.value ? ($(), w("path", lt)) : ($(), w("path", ct))
|
|
575
|
+
]))
|
|
576
|
+
], 10, st));
|
|
577
|
+
}
|
|
578
|
+
}), dt = /* @__PURE__ */ A({
|
|
579
|
+
__name: "IconCell",
|
|
580
|
+
props: {
|
|
581
|
+
iconName: {},
|
|
582
|
+
iconResolver: { type: Function }
|
|
583
|
+
},
|
|
584
|
+
setup(e) {
|
|
585
|
+
const n = e, t = P(() => {
|
|
586
|
+
var c;
|
|
587
|
+
return ((c = n.iconResolver) == null ? void 0 : c.call(n, n.iconName)) ?? Te(n.iconName);
|
|
588
|
+
});
|
|
589
|
+
return (c, s) => t.value ? ($(), de(be(t.value), {
|
|
590
|
+
key: 0,
|
|
591
|
+
class: "h-4 w-4 text-gray-500 dark:text-gray-400"
|
|
592
|
+
})) : K("", !0);
|
|
593
|
+
}
|
|
594
|
+
}), Fe = /* @__PURE__ */ new Map();
|
|
595
|
+
function Lt(e, n) {
|
|
596
|
+
Fe.set(e, n);
|
|
597
|
+
}
|
|
598
|
+
function ft(e) {
|
|
599
|
+
return Fe.get(e);
|
|
600
|
+
}
|
|
601
|
+
const Ce = /* @__PURE__ */ A({
|
|
602
|
+
__name: "ComponentCell",
|
|
603
|
+
props: {
|
|
604
|
+
componentName: {},
|
|
605
|
+
row: {},
|
|
606
|
+
columnName: {}
|
|
607
|
+
},
|
|
608
|
+
setup(e) {
|
|
609
|
+
const n = e, t = P(() => ft(n.componentName));
|
|
610
|
+
return (c, s) => t.value ? ($(), de(be(t.value), {
|
|
611
|
+
key: 0,
|
|
612
|
+
row: e.row,
|
|
613
|
+
value: e.row[e.columnName],
|
|
614
|
+
column: e.columnName
|
|
615
|
+
}, null, 8, ["row", "value", "column"])) : K("", !0);
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
function ht(e) {
|
|
619
|
+
const { tableData: n, slots: t, onSort: c, getSortState: s, nullText: f, classNames: d, iconResolver: l } = e;
|
|
620
|
+
return P(() => {
|
|
621
|
+
const g = [];
|
|
622
|
+
for (const i of n.columns)
|
|
623
|
+
i.hidden || g.push({
|
|
624
|
+
id: i.name,
|
|
625
|
+
fit: i.fit ?? !1,
|
|
626
|
+
sortable: i.sortable,
|
|
627
|
+
getAriaSort: () => {
|
|
628
|
+
if (!i.sortable) return;
|
|
629
|
+
const v = s(i.sort_key);
|
|
630
|
+
return v.active ? v.direction === "asc" ? "ascending" : "descending" : "none";
|
|
631
|
+
},
|
|
632
|
+
renderHeader: () => {
|
|
633
|
+
const v = s(i.sort_key), b = {
|
|
634
|
+
column: i,
|
|
635
|
+
sortState: v,
|
|
636
|
+
onSort: c,
|
|
637
|
+
index: g.length
|
|
638
|
+
}, D = t[`header-${i.name}`];
|
|
639
|
+
if (D) return D(b);
|
|
640
|
+
if (t.header) return t.header(b);
|
|
641
|
+
let S = null;
|
|
642
|
+
return i.sortable && (v.active ? S = L(
|
|
643
|
+
"svg",
|
|
644
|
+
{ class: "ml-1 h-3.5 w-3.5 inline-block", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" },
|
|
645
|
+
[L("path", { d: v.direction === "asc" ? "M4 10l4-4 4 4" : "M4 6l4 4 4-4" })]
|
|
646
|
+
) : S = L(
|
|
647
|
+
"span",
|
|
648
|
+
{ class: "ml-1 inline-block text-gray-300 dark:text-gray-600" },
|
|
649
|
+
"⇅"
|
|
650
|
+
)), L(
|
|
651
|
+
"div",
|
|
652
|
+
{
|
|
653
|
+
class: [
|
|
654
|
+
"flex items-center gap-1 -m-4 p-4",
|
|
655
|
+
i.sortable ? d.value.thSortable : "",
|
|
656
|
+
v.active ? d.value.thSorted : ""
|
|
657
|
+
].filter(Boolean).join(" "),
|
|
658
|
+
onClick: i.sortable ? () => c(i.sort_key) : void 0
|
|
659
|
+
},
|
|
660
|
+
[i.header, S]
|
|
661
|
+
);
|
|
662
|
+
},
|
|
663
|
+
renderCell: (v, b) => {
|
|
664
|
+
var E;
|
|
665
|
+
if (i.displays.length === 1 && i.displays[0].type === "actions")
|
|
666
|
+
return ((E = t.actions) == null ? void 0 : E.call(t, { row: v })) ?? null;
|
|
667
|
+
const D = v[i.name], S = {
|
|
668
|
+
row: v,
|
|
669
|
+
value: D,
|
|
670
|
+
column: i,
|
|
671
|
+
displays: i.displays,
|
|
672
|
+
rowIndex: b
|
|
673
|
+
}, O = t[`cell-${i.name}`];
|
|
674
|
+
if (O) return O(S);
|
|
675
|
+
if (t.cell) {
|
|
676
|
+
const z = () => De(i.displays, v, i.name, f, n.dateFormat, l);
|
|
677
|
+
return t.cell({ ...S, defaultRender: z });
|
|
678
|
+
}
|
|
679
|
+
return De(i.displays, v, i.name, f, n.dateFormat, l);
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
return t.actions && (n.columns.some(
|
|
683
|
+
(v) => v.displays.length === 1 && v.displays[0].type === "actions"
|
|
684
|
+
) || g.push({
|
|
685
|
+
id: "_actions",
|
|
686
|
+
fit: !0,
|
|
687
|
+
sortable: !1,
|
|
688
|
+
getAriaSort: () => {
|
|
689
|
+
},
|
|
690
|
+
renderHeader: () => null,
|
|
691
|
+
renderCell: (v) => t.actions({ row: v })
|
|
692
|
+
})), g;
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function De(e, n, t, c, s, f) {
|
|
696
|
+
if (!e || e.length === 0)
|
|
697
|
+
return L(Se, { value: n[t], nullText: c });
|
|
698
|
+
if (e.length === 1 && e[0].type === "component") {
|
|
699
|
+
const l = e[0];
|
|
700
|
+
return L(Ce, { componentName: l.component, row: n, columnName: t });
|
|
701
|
+
}
|
|
702
|
+
const d = e.map((l, g) => {
|
|
703
|
+
const i = Ie(n, l, t);
|
|
704
|
+
switch (l.type) {
|
|
705
|
+
case "text":
|
|
706
|
+
return L(Se, { key: g, value: i, nullText: c });
|
|
707
|
+
case "badge":
|
|
708
|
+
return L(Ve, {
|
|
709
|
+
key: g,
|
|
710
|
+
value: i,
|
|
711
|
+
variant: l.variant,
|
|
712
|
+
colorField: l.color_field,
|
|
713
|
+
tooltipKey: l.tooltip_key,
|
|
714
|
+
iconKey: l.icon_key,
|
|
715
|
+
row: n,
|
|
716
|
+
nullText: c,
|
|
717
|
+
iconResolver: f
|
|
718
|
+
});
|
|
719
|
+
case "date":
|
|
720
|
+
return L(Xe, { key: g, value: i, format: l.format, tableFormat: s });
|
|
721
|
+
case "link": {
|
|
722
|
+
const v = l.href_key ? n[l.href_key] : void 0;
|
|
723
|
+
return L(at, {
|
|
724
|
+
key: g,
|
|
725
|
+
value: i,
|
|
726
|
+
route: l.route,
|
|
727
|
+
params: l.params,
|
|
728
|
+
resolvedHref: v != null ? String(v) : void 0,
|
|
729
|
+
row: n,
|
|
730
|
+
prefetch: l.prefetch,
|
|
731
|
+
nullText: c
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
case "copyable":
|
|
735
|
+
return L(ut, { key: g, value: i, nullText: c });
|
|
736
|
+
case "icon":
|
|
737
|
+
return L(dt, { key: g, iconName: String(i ?? ""), iconResolver: f });
|
|
738
|
+
case "component":
|
|
739
|
+
return L(Ce, {
|
|
740
|
+
key: g,
|
|
741
|
+
componentName: l.component,
|
|
742
|
+
row: n,
|
|
743
|
+
columnName: t
|
|
744
|
+
});
|
|
745
|
+
default:
|
|
746
|
+
return null;
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
return d.length > 1 ? L("div", { class: "flex items-center gap-2" }, d) : d[0] ?? null;
|
|
750
|
+
}
|
|
751
|
+
const gt = {
|
|
752
|
+
wrapper: "rounded-lg border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-900",
|
|
753
|
+
toolbar: "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",
|
|
754
|
+
table: "min-w-full",
|
|
755
|
+
thead: "bg-gray-50 border-b border-gray-200 dark:bg-gray-800 dark:border-gray-700",
|
|
756
|
+
th: "px-4 py-3 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider dark:text-gray-400",
|
|
757
|
+
thSortable: "cursor-pointer select-none",
|
|
758
|
+
thSorted: "text-gray-900 dark:text-gray-100",
|
|
759
|
+
tbody: "divide-y divide-gray-100 dark:divide-gray-700",
|
|
760
|
+
tr: "hover:bg-gray-50 transition-colors dark:hover:bg-gray-800",
|
|
761
|
+
trClickable: "cursor-pointer",
|
|
762
|
+
td: "px-4 py-3 text-sm text-gray-900 dark:text-gray-200",
|
|
763
|
+
search: "rounded-md border border-gray-300 bg-white px-3 py-2 text-sm placeholder-gray-400 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:placeholder-gray-500 dark:focus:border-blue-400",
|
|
764
|
+
pagination: "flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",
|
|
765
|
+
paginationButton: "px-3 py-1.5 text-sm border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-700",
|
|
766
|
+
paginationInfo: "text-sm text-gray-500 dark:text-gray-400",
|
|
767
|
+
empty: "p-8 text-center text-gray-500 dark:text-gray-400"
|
|
768
|
+
};
|
|
769
|
+
function me(e, n, t) {
|
|
770
|
+
return e ? `${e}${n}` : t;
|
|
771
|
+
}
|
|
772
|
+
function mt(e, n) {
|
|
773
|
+
const { tableData: t } = e, c = e.nullText ?? "-", s = P(() => ({
|
|
774
|
+
...gt,
|
|
775
|
+
...e.classNames
|
|
776
|
+
})), f = t.identifier ?? null, d = me(f, "Search", "search"), l = me(f, "Sort", "sort"), g = me(f, "Page", "page"), { onPageChange: i } = Le(g), { searchTerm: v, onSearch: b, hasExternalSearch: D } = He(t.searchDebounce, d, g, e.searchRef), { sortBy: S, sortDir: O, onSort: E, getSortState: z } = je(l, g), ee = ht({
|
|
777
|
+
tableData: t,
|
|
778
|
+
slots: n,
|
|
779
|
+
onSort: E,
|
|
780
|
+
getSortState: z,
|
|
781
|
+
nullText: c,
|
|
782
|
+
classNames: s,
|
|
783
|
+
iconResolver: e.iconResolver
|
|
784
|
+
});
|
|
785
|
+
_e(t);
|
|
786
|
+
const M = yt(t, d, l, g);
|
|
787
|
+
return {
|
|
788
|
+
columns: ee,
|
|
789
|
+
classNames: s,
|
|
790
|
+
searchTerm: v,
|
|
791
|
+
onSearch: b,
|
|
792
|
+
hasExternalSearch: D,
|
|
793
|
+
sortBy: S,
|
|
794
|
+
sortDir: O,
|
|
795
|
+
onSort: E,
|
|
796
|
+
getSortState: z,
|
|
797
|
+
onPageChange: i,
|
|
798
|
+
isProcessing: M
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function yt(e, n, t, c) {
|
|
802
|
+
const s = ye(!1);
|
|
803
|
+
let f = e.data;
|
|
804
|
+
ve(() => e.data, (i) => {
|
|
805
|
+
f !== i && (f = i, s.value = !1);
|
|
806
|
+
});
|
|
807
|
+
const d = [n, t, c], l = ce.on("start", (i) => {
|
|
808
|
+
try {
|
|
809
|
+
const v = new URL(i.detail.visit.url), b = new URL(window.location.href);
|
|
810
|
+
d.some((S) => v.searchParams.get(S) !== b.searchParams.get(S)) && (s.value = !0);
|
|
811
|
+
} catch {
|
|
812
|
+
s.value = !0;
|
|
813
|
+
}
|
|
814
|
+
}), g = ce.on("finish", () => {
|
|
815
|
+
s.value = !1;
|
|
816
|
+
});
|
|
817
|
+
return ue(() => {
|
|
818
|
+
l(), g();
|
|
819
|
+
}), s;
|
|
820
|
+
}
|
|
821
|
+
const vt = { class: "relative" }, bt = ["value", "placeholder"], kt = /* @__PURE__ */ A({
|
|
822
|
+
__name: "TableSearch",
|
|
823
|
+
props: {
|
|
824
|
+
searchTerm: {},
|
|
825
|
+
onSearch: { type: Function },
|
|
826
|
+
placeholder: {},
|
|
827
|
+
className: {}
|
|
828
|
+
},
|
|
829
|
+
setup(e) {
|
|
830
|
+
return (n, t) => ($(), w("div", vt, [
|
|
831
|
+
t[1] || (t[1] = B("svg", {
|
|
832
|
+
class: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500",
|
|
833
|
+
fill: "none",
|
|
834
|
+
viewBox: "0 0 24 24",
|
|
835
|
+
"stroke-width": "1.5",
|
|
836
|
+
stroke: "currentColor"
|
|
837
|
+
}, [
|
|
838
|
+
B("path", {
|
|
839
|
+
"stroke-linecap": "round",
|
|
840
|
+
"stroke-linejoin": "round",
|
|
841
|
+
d: "M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
|
|
842
|
+
})
|
|
843
|
+
], -1)),
|
|
844
|
+
B("input", {
|
|
845
|
+
type: "text",
|
|
846
|
+
value: e.searchTerm,
|
|
847
|
+
onInput: t[0] || (t[0] = (c) => e.onSearch(c.target.value)),
|
|
848
|
+
placeholder: e.placeholder ?? "Search...",
|
|
849
|
+
class: F(`pl-9 ${e.className ?? ""}`),
|
|
850
|
+
"aria-label": "Search table"
|
|
851
|
+
}, null, 42, bt)
|
|
852
|
+
]));
|
|
853
|
+
}
|
|
854
|
+
}), pt = { class: "flex items-center gap-2" }, $t = ["disabled"], xt = ["disabled"], St = ["disabled"], wt = ["disabled"], Ct = /* @__PURE__ */ A({
|
|
855
|
+
__name: "TablePagination",
|
|
856
|
+
props: {
|
|
857
|
+
links: {},
|
|
858
|
+
meta: {},
|
|
859
|
+
onPageChange: { type: Function },
|
|
860
|
+
isFetching: { type: Boolean },
|
|
861
|
+
classNames: {}
|
|
862
|
+
},
|
|
863
|
+
setup(e) {
|
|
864
|
+
const n = e, t = P(() => n.links.prev !== null), c = P(() => n.links.next !== null), s = P(() => {
|
|
865
|
+
const { from: f, to: d } = n.meta;
|
|
866
|
+
return f !== null && d !== null ? n.meta.total !== void 0 ? `Showing ${f} to ${d} of ${n.meta.total} results` : `Showing ${f} to ${d} results` : "No results";
|
|
867
|
+
});
|
|
868
|
+
return (f, d) => ($(), w("nav", {
|
|
869
|
+
class: F(e.classNames.pagination),
|
|
870
|
+
"aria-label": "Table pagination"
|
|
871
|
+
}, [
|
|
872
|
+
B("span", {
|
|
873
|
+
class: F(e.classNames.paginationInfo)
|
|
874
|
+
}, I(s.value), 3),
|
|
875
|
+
B("div", pt, [
|
|
876
|
+
e.links.first !== null ? ($(), w("button", {
|
|
877
|
+
key: 0,
|
|
878
|
+
type: "button",
|
|
879
|
+
onClick: d[0] || (d[0] = (l) => e.onPageChange(1)),
|
|
880
|
+
disabled: !t.value || e.isFetching,
|
|
881
|
+
class: F(e.classNames.paginationButton),
|
|
882
|
+
"aria-label": "Go to first page"
|
|
883
|
+
}, " First ", 10, $t)) : K("", !0),
|
|
884
|
+
B("button", {
|
|
885
|
+
type: "button",
|
|
886
|
+
onClick: d[1] || (d[1] = (l) => e.onPageChange(e.meta.current_page - 1)),
|
|
887
|
+
disabled: !t.value || e.isFetching,
|
|
888
|
+
class: F(e.classNames.paginationButton),
|
|
889
|
+
"aria-label": "Go to previous page"
|
|
890
|
+
}, " Previous ", 10, xt),
|
|
891
|
+
B("button", {
|
|
892
|
+
type: "button",
|
|
893
|
+
onClick: d[2] || (d[2] = (l) => e.onPageChange(e.meta.current_page + 1)),
|
|
894
|
+
disabled: !c.value || e.isFetching,
|
|
895
|
+
class: F(e.classNames.paginationButton),
|
|
896
|
+
"aria-label": "Go to next page"
|
|
897
|
+
}, " Next ", 10, St),
|
|
898
|
+
e.links.last !== null && e.meta.last_page !== void 0 ? ($(), w("button", {
|
|
899
|
+
key: 1,
|
|
900
|
+
type: "button",
|
|
901
|
+
onClick: d[3] || (d[3] = (l) => e.onPageChange(e.meta.last_page)),
|
|
902
|
+
disabled: !c.value || e.isFetching,
|
|
903
|
+
class: F(e.classNames.paginationButton),
|
|
904
|
+
"aria-label": "Go to last page"
|
|
905
|
+
}, " Last ", 10, wt)) : K("", !0)
|
|
906
|
+
])
|
|
907
|
+
], 2));
|
|
908
|
+
}
|
|
909
|
+
}), Dt = ["colspan"], Mt = /* @__PURE__ */ A({
|
|
910
|
+
__name: "TableEmpty",
|
|
911
|
+
props: {
|
|
912
|
+
colSpan: {},
|
|
913
|
+
emptyText: {},
|
|
914
|
+
className: {}
|
|
915
|
+
},
|
|
916
|
+
setup(e) {
|
|
917
|
+
return (n, t) => ($(), w("tr", null, [
|
|
918
|
+
B("td", {
|
|
919
|
+
colspan: e.colSpan,
|
|
920
|
+
class: F(e.className)
|
|
921
|
+
}, I(e.emptyText ?? "No results found."), 11, Dt)
|
|
922
|
+
]));
|
|
923
|
+
}
|
|
924
|
+
}), Me = A({
|
|
925
|
+
name: "RenderVNode",
|
|
926
|
+
props: {
|
|
927
|
+
render: {
|
|
928
|
+
type: Function,
|
|
929
|
+
required: !0
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
setup(e) {
|
|
933
|
+
return () => e.render();
|
|
934
|
+
}
|
|
935
|
+
}), Tt = ["aria-busy"], Nt = ["aria-sort"], _t = /* @__PURE__ */ A({
|
|
936
|
+
__name: "InertiaTable",
|
|
937
|
+
props: {
|
|
938
|
+
tableData: {},
|
|
939
|
+
className: {},
|
|
940
|
+
classNames: {},
|
|
941
|
+
modal: { type: Boolean },
|
|
942
|
+
emptyText: {},
|
|
943
|
+
nullText: {},
|
|
944
|
+
onRowClick: {},
|
|
945
|
+
rowClassName: {},
|
|
946
|
+
isFetching: { type: Boolean, default: !1 },
|
|
947
|
+
searchRef: {},
|
|
948
|
+
iconResolver: {}
|
|
949
|
+
},
|
|
950
|
+
setup(e) {
|
|
951
|
+
const n = e, t = Re(), {
|
|
952
|
+
columns: c,
|
|
953
|
+
classNames: s,
|
|
954
|
+
searchTerm: f,
|
|
955
|
+
onSearch: d,
|
|
956
|
+
hasExternalSearch: l,
|
|
957
|
+
onPageChange: g,
|
|
958
|
+
isProcessing: i
|
|
959
|
+
} = mt(n, t), v = P(() => n.tableData.data.length > 0), b = c, D = P(() => n.isFetching || i.value), S = P(() => n.tableData.searchable && !l), O = P(() => new Set(b.value.filter((M) => M.fit).map((M) => M.id))), E = P(
|
|
960
|
+
() => [
|
|
961
|
+
n.modal ? "" : s.value.wrapper,
|
|
962
|
+
n.className ?? ""
|
|
963
|
+
].filter(Boolean).join(" ")
|
|
964
|
+
);
|
|
965
|
+
function z(M, Y) {
|
|
966
|
+
!n.onRowClick || Y.target.closest('a, button, input, select, textarea, [role="button"]') || n.onRowClick(M);
|
|
967
|
+
}
|
|
968
|
+
function ee(M, Y) {
|
|
969
|
+
n.onRowClick && (Y.key === "Enter" || Y.key === " ") && (Y.preventDefault(), n.onRowClick(M));
|
|
970
|
+
}
|
|
971
|
+
return (M, Y) => ($(), w("div", {
|
|
972
|
+
class: F(E.value)
|
|
973
|
+
}, [
|
|
974
|
+
S.value || p(t)["toolbar-actions"] ? Q(M.$slots, "toolbar", {
|
|
975
|
+
key: 0,
|
|
976
|
+
searchable: S.value,
|
|
977
|
+
searchTerm: p(f),
|
|
978
|
+
onSearch: p(d)
|
|
979
|
+
}, () => [
|
|
980
|
+
B("div", {
|
|
981
|
+
class: F(p(s).toolbar)
|
|
982
|
+
}, [
|
|
983
|
+
S.value ? Q(M.$slots, "search", {
|
|
984
|
+
key: 0,
|
|
985
|
+
searchTerm: p(f),
|
|
986
|
+
onSearch: p(d),
|
|
987
|
+
placeholder: "Search..."
|
|
988
|
+
}, () => [
|
|
989
|
+
re(kt, {
|
|
990
|
+
searchTerm: p(f),
|
|
991
|
+
onSearch: p(d),
|
|
992
|
+
className: p(s).search
|
|
993
|
+
}, null, 8, ["searchTerm", "onSearch", "className"])
|
|
994
|
+
]) : K("", !0),
|
|
995
|
+
Q(M.$slots, "toolbar-actions")
|
|
996
|
+
], 2)
|
|
997
|
+
]) : K("", !0),
|
|
998
|
+
B("div", {
|
|
999
|
+
class: F(["overflow-x-auto transition-opacity duration-150", D.value ? "opacity-50 pointer-events-none" : ""]),
|
|
1000
|
+
"aria-busy": D.value
|
|
1001
|
+
}, [
|
|
1002
|
+
B("table", {
|
|
1003
|
+
class: F(p(s).table)
|
|
1004
|
+
}, [
|
|
1005
|
+
B("thead", {
|
|
1006
|
+
class: F(p(s).thead)
|
|
1007
|
+
}, [
|
|
1008
|
+
B("tr", null, [
|
|
1009
|
+
($(!0), w(he, null, ge(p(b), (H) => ($(), w("th", {
|
|
1010
|
+
key: H.id,
|
|
1011
|
+
class: F([p(s).th, O.value.has(H.id) ? "w-0 whitespace-nowrap" : ""]),
|
|
1012
|
+
"aria-sort": H.getAriaSort()
|
|
1013
|
+
}, [
|
|
1014
|
+
re(p(Me), {
|
|
1015
|
+
render: H.renderHeader
|
|
1016
|
+
}, null, 8, ["render"])
|
|
1017
|
+
], 10, Nt))), 128))
|
|
1018
|
+
])
|
|
1019
|
+
], 2),
|
|
1020
|
+
B("tbody", {
|
|
1021
|
+
class: F(p(s).tbody)
|
|
1022
|
+
}, [
|
|
1023
|
+
v.value ? ($(!0), w(he, { key: 0 }, ge(e.tableData.data, (H, W) => Q(M.$slots, "row", {
|
|
1024
|
+
key: H.id,
|
|
1025
|
+
row: H,
|
|
1026
|
+
rowIndex: W
|
|
1027
|
+
}, () => {
|
|
1028
|
+
var U;
|
|
1029
|
+
return [
|
|
1030
|
+
B("tr", Be({
|
|
1031
|
+
class: [
|
|
1032
|
+
p(s).tr,
|
|
1033
|
+
e.onRowClick ? p(s).trClickable : "",
|
|
1034
|
+
((U = e.rowClassName) == null ? void 0 : U.call(e, H, W)) ?? ""
|
|
1035
|
+
].filter(Boolean).join(" ")
|
|
1036
|
+
}, { ref_for: !0 }, e.onRowClick ? {
|
|
1037
|
+
role: "button",
|
|
1038
|
+
tabindex: 0,
|
|
1039
|
+
onClick: (V) => z(H, V),
|
|
1040
|
+
onKeydown: (V) => ee(H, V)
|
|
1041
|
+
} : {}), [
|
|
1042
|
+
($(!0), w(he, null, ge(p(b), (V) => ($(), w("td", {
|
|
1043
|
+
key: V.id,
|
|
1044
|
+
class: F([p(s).td, O.value.has(V.id) ? "w-0 whitespace-nowrap" : ""])
|
|
1045
|
+
}, [
|
|
1046
|
+
re(p(Me), {
|
|
1047
|
+
render: () => V.renderCell(H, W)
|
|
1048
|
+
}, null, 8, ["render"])
|
|
1049
|
+
], 2))), 128))
|
|
1050
|
+
], 16)
|
|
1051
|
+
];
|
|
1052
|
+
})), 128)) : Q(M.$slots, "empty", { key: 1 }, () => [
|
|
1053
|
+
re(Mt, {
|
|
1054
|
+
colSpan: p(b).length,
|
|
1055
|
+
emptyText: e.emptyText,
|
|
1056
|
+
className: p(s).empty
|
|
1057
|
+
}, null, 8, ["colSpan", "emptyText", "className"])
|
|
1058
|
+
])
|
|
1059
|
+
], 2)
|
|
1060
|
+
], 2)
|
|
1061
|
+
], 10, Tt),
|
|
1062
|
+
v.value ? Q(M.$slots, "pagination", {
|
|
1063
|
+
key: 1,
|
|
1064
|
+
links: e.tableData.links,
|
|
1065
|
+
meta: e.tableData.meta,
|
|
1066
|
+
onPageChange: p(g),
|
|
1067
|
+
isFetching: D.value
|
|
1068
|
+
}, () => [
|
|
1069
|
+
re(Ct, {
|
|
1070
|
+
links: e.tableData.links,
|
|
1071
|
+
meta: e.tableData.meta,
|
|
1072
|
+
onPageChange: p(g),
|
|
1073
|
+
isFetching: D.value,
|
|
1074
|
+
classNames: {
|
|
1075
|
+
pagination: p(s).pagination,
|
|
1076
|
+
paginationButton: p(s).paginationButton,
|
|
1077
|
+
paginationInfo: p(s).paginationInfo
|
|
1078
|
+
}
|
|
1079
|
+
}, null, 8, ["links", "meta", "onPageChange", "isFetching", "classNames"])
|
|
1080
|
+
]) : K("", !0)
|
|
1081
|
+
], 2));
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
export {
|
|
1085
|
+
_t as InertiaTable,
|
|
1086
|
+
Bt as clearTableHooks,
|
|
1087
|
+
Lt as registerCellComponent,
|
|
1088
|
+
Ot as registerIcon,
|
|
1089
|
+
Ht as registerIcons,
|
|
1090
|
+
Rt as registerTableHook,
|
|
1091
|
+
jt as setDateFormatter,
|
|
1092
|
+
mt as useTable
|
|
1093
|
+
};
|