vlite3 0.7.4 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { defineComponent as me, inject as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { $t as
|
|
11
|
-
import { SCREEN_CONTEXT_KEY as
|
|
12
|
-
const
|
|
1
|
+
import { defineComponent as me, inject as fe, computed as r, ref as b, watch as v, openBlock as i, createElementBlock as u, createBlock as A, normalizeClass as C, createSlots as N, withCtx as k, renderSlot as I, createVNode as S, createCommentVNode as $, createElementVNode as m, Fragment as B, renderList as T, normalizeStyle as O, mergeProps as K, unref as L } from "vue";
|
|
2
|
+
import ve from "../CheckBox.vue.js";
|
|
3
|
+
import he from "../Button.vue.js";
|
|
4
|
+
import ge from "../ConfirmationModal.vue.js";
|
|
5
|
+
import pe from "../Pagination/Pagination.vue.js";
|
|
6
|
+
import be from "../Empty/Empty.vue.js";
|
|
7
|
+
import ye from "./DataTableHeader.vue.js";
|
|
8
|
+
import we from "./DataTableRow.vue.js";
|
|
9
|
+
import Pe from "./DataTableToolbar.vue.js";
|
|
10
|
+
import { $t as y } from "../../utils/i18n.js";
|
|
11
|
+
import { SCREEN_CONTEXT_KEY as Ce } from "./types.js";
|
|
12
|
+
const ke = { class: "space-y-6.5" }, Ie = { class: "overflow-x-auto w-full" }, Se = { class: "hover:bg-transparent" }, Te = {
|
|
13
13
|
key: 0,
|
|
14
14
|
scope: "col",
|
|
15
15
|
class: "w-[48px] px-0 text-center font-medium text-muted-foreground",
|
|
16
16
|
style: { width: "48px" }
|
|
17
|
-
},
|
|
17
|
+
}, De = { class: "flex items-center justify-center" }, xe = { class: "[&_tr:last-child]:border-0" }, $e = {
|
|
18
18
|
key: 0,
|
|
19
19
|
class: "w-[48px] px-0 py-4 align-middle text-center",
|
|
20
20
|
style: { width: "48px" }
|
|
21
|
-
},
|
|
21
|
+
}, Be = { key: 2 }, Ee = ["colspan"], Re = { key: 1 }, Ye = /* @__PURE__ */ me({
|
|
22
22
|
__name: "DataTable",
|
|
23
23
|
props: {
|
|
24
24
|
rows: { default: () => [] },
|
|
@@ -57,320 +57,283 @@ const Ie = { class: "space-y-6.5" }, Se = { class: "overflow-x-auto w-full" }, T
|
|
|
57
57
|
variant: { default: "default" }
|
|
58
58
|
},
|
|
59
59
|
emits: ["change", "select", "rowClick", "update:itemsPerPage", "update:selectedRows", "delete"],
|
|
60
|
-
setup(o, { emit:
|
|
61
|
-
const
|
|
60
|
+
setup(o, { emit: Y }) {
|
|
61
|
+
const W = (e, t) => {
|
|
62
62
|
if (!(!e || !t))
|
|
63
|
-
return t.includes(".") ? t.split(".").reduce((a,
|
|
64
|
-
},
|
|
63
|
+
return t.includes(".") ? t.split(".").reduce((a, n) => a?.[n], e) : e[t];
|
|
64
|
+
}, f = (e, t) => W(e, t), X = (e, t) => {
|
|
65
65
|
const a = ["id", "_id"];
|
|
66
66
|
if (t && t !== "auto") return t;
|
|
67
67
|
if (e && e.length > 0) {
|
|
68
|
-
for (const
|
|
69
|
-
if (
|
|
68
|
+
for (const n of a)
|
|
69
|
+
if (n in e[0]) return n;
|
|
70
70
|
}
|
|
71
71
|
return "_id";
|
|
72
|
-
}, l = o,
|
|
72
|
+
}, l = o, g = Y, E = fe(Ce, null), U = r(() => E?.disableSearch ? !1 : l.showSearch), D = r(() => l.selectable || !!E?.forceSelectable), d = r(() => X(l.rows, l.keyField)), c = b({ field: "", order: "" }), w = b(
|
|
73
73
|
l.pageInfo?.itemsPerPage || l.paginationProps?.itemsPerPage || 10
|
|
74
|
-
),
|
|
75
|
-
|
|
74
|
+
), h = b(l.pageInfo?.currentPage || 1), p = b(l.search || ""), P = b(!1), q = r(() => l.loading);
|
|
75
|
+
v(
|
|
76
76
|
() => l.loading,
|
|
77
77
|
(e, t) => {
|
|
78
|
-
!e && t && (I.value = "idle");
|
|
79
78
|
}
|
|
80
|
-
),
|
|
79
|
+
), v(
|
|
81
80
|
() => l.search,
|
|
82
81
|
(e) => {
|
|
83
|
-
e !== void 0 && e !==
|
|
82
|
+
e !== void 0 && e !== p.value && (p.value = e);
|
|
84
83
|
}
|
|
85
84
|
);
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
let R = null;
|
|
86
|
+
v(p, () => {
|
|
87
|
+
R && clearTimeout(R), R = setTimeout(() => {
|
|
88
|
+
h.value = 1, x();
|
|
90
89
|
}, 300);
|
|
91
|
-
}),
|
|
92
|
-
(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
(e) => {
|
|
99
|
-
e !== void 0 && (C.value = e);
|
|
100
|
-
}
|
|
101
|
-
), g(
|
|
102
|
-
() => l.pageInfo?.currentPage,
|
|
103
|
-
(e) => {
|
|
104
|
-
e && (p.value = e);
|
|
105
|
-
}
|
|
106
|
-
);
|
|
90
|
+
}), v(() => l.pageInfo?.itemsPerPage, (e) => {
|
|
91
|
+
e !== void 0 && (w.value = e);
|
|
92
|
+
}), v(() => l.paginationProps?.itemsPerPage, (e) => {
|
|
93
|
+
e !== void 0 && (w.value = e);
|
|
94
|
+
}), v(() => l.pageInfo?.currentPage, (e) => {
|
|
95
|
+
e && (h.value = e);
|
|
96
|
+
});
|
|
107
97
|
const s = b(/* @__PURE__ */ new Set());
|
|
108
|
-
|
|
98
|
+
v(
|
|
109
99
|
() => l.selectedRows,
|
|
110
100
|
(e) => {
|
|
111
|
-
const t = new Set(
|
|
112
|
-
(e || []).map((a) => m(a, i.value))
|
|
113
|
-
);
|
|
101
|
+
const t = new Set((e || []).map((a) => f(a, d.value)));
|
|
114
102
|
(t.size !== s.value.size || [...t].some((a) => !s.value.has(a))) && (s.value = t);
|
|
115
103
|
},
|
|
116
104
|
{ immediate: !0, deep: !0 }
|
|
117
105
|
);
|
|
118
|
-
const
|
|
119
|
-
(e) => s.value.has(
|
|
120
|
-
)),
|
|
121
|
-
() => s.value.size > 0 && !U.value
|
|
122
|
-
), J = n(() => {
|
|
106
|
+
const z = r(
|
|
107
|
+
() => l.rows.length > 0 && l.rows.every((e) => s.value.has(f(e, d.value)))
|
|
108
|
+
), F = r(() => s.value.size > 0 && !z.value), G = r(() => {
|
|
123
109
|
const e = [...l.selectedRows || [], ...l.rows], t = /* @__PURE__ */ new Map();
|
|
124
|
-
return e.forEach((a) => t.set(
|
|
125
|
-
}),
|
|
126
|
-
e ? l.rows.forEach(
|
|
127
|
-
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
),
|
|
110
|
+
return e.forEach((a) => t.set(f(a, d.value), a)), Array.from(s.value).map((a) => t.get(a)).filter(Boolean);
|
|
111
|
+
}), H = (e) => {
|
|
112
|
+
e ? l.rows.forEach((t) => s.value.add(f(t, d.value))) : l.rows.forEach((t) => s.value.delete(f(t, d.value))), M();
|
|
113
|
+
}, J = (e) => {
|
|
114
|
+
s.value.has(e) ? s.value.delete(e) : s.value.add(e), M();
|
|
115
|
+
}, M = () => {
|
|
116
|
+
const e = /* @__PURE__ */ new Set(), t = [];
|
|
117
|
+
l.rows.forEach((a) => {
|
|
118
|
+
const n = f(a, d.value);
|
|
119
|
+
s.value.has(n) && (t.push(a), e.add(n));
|
|
120
|
+
}), (l.selectedRows || []).forEach((a) => {
|
|
121
|
+
const n = f(a, d.value);
|
|
122
|
+
!e.has(n) && s.value.has(n) && (t.push(a), e.add(n));
|
|
123
|
+
}), g("select", { selected: t, all: z.value, indeterminate: F.value }), g("update:selectedRows", t);
|
|
124
|
+
}, Q = (e) => {
|
|
125
|
+
c.value.field === e ? c.value.order === "asc" ? c.value.order = "desc" : c.value.order === "desc" ? (c.value.order = "", c.value.field = "") : c.value.order = "asc" : (c.value.field = e, c.value.order = "asc"), h.value = 1, x();
|
|
131
126
|
}, Z = (e) => {
|
|
132
|
-
|
|
133
|
-
}, K = () => {
|
|
134
|
-
const e = l.selectedRows || [], t = /* @__PURE__ */ new Set(), a = [];
|
|
135
|
-
l.rows.forEach((v) => {
|
|
136
|
-
const h = m(v, i.value);
|
|
137
|
-
s.value.has(h) && (a.push(v), t.add(h));
|
|
138
|
-
}), e.forEach((v) => {
|
|
139
|
-
const h = m(v, i.value);
|
|
140
|
-
!t.has(h) && s.value.has(h) && (a.push(v), t.add(h));
|
|
141
|
-
});
|
|
142
|
-
const c = {
|
|
143
|
-
selected: a,
|
|
144
|
-
all: U.value,
|
|
145
|
-
indeterminate: V.value
|
|
146
|
-
};
|
|
147
|
-
y("select", c), y("update:selectedRows", a);
|
|
127
|
+
h.value = e, x();
|
|
148
128
|
}, _ = (e) => {
|
|
149
|
-
|
|
150
|
-
}, ee = (e) => {
|
|
151
|
-
|
|
152
|
-
}, te = (e) => {
|
|
153
|
-
C.value = e, p.value = 1, I.value = "limit", y("update:itemsPerPage", e), E();
|
|
154
|
-
}, le = (e) => {
|
|
155
|
-
y("rowClick", e);
|
|
156
|
-
}, ae = () => {
|
|
157
|
-
const e = J.value;
|
|
158
|
-
y("delete", e), k.value = !1;
|
|
129
|
+
w.value = e, h.value = 1, g("update:itemsPerPage", e), x();
|
|
130
|
+
}, ee = (e) => g("rowClick", e), te = () => {
|
|
131
|
+
g("delete", G.value), P.value = !1;
|
|
159
132
|
};
|
|
160
|
-
let
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
pagination: {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
133
|
+
let V = null;
|
|
134
|
+
const x = () => {
|
|
135
|
+
V && clearTimeout(V), V = setTimeout(() => {
|
|
136
|
+
const e = {
|
|
137
|
+
pagination: { page: h.value, limit: w.value },
|
|
138
|
+
sort: { ...c.value },
|
|
139
|
+
search: p.value,
|
|
140
|
+
filter: {}
|
|
141
|
+
};
|
|
142
|
+
g("change", e), E?.onTableChange?.(e);
|
|
171
143
|
}, 10);
|
|
172
144
|
};
|
|
173
|
-
|
|
145
|
+
v(
|
|
174
146
|
() => l.rows,
|
|
175
147
|
() => {
|
|
176
|
-
const e = new Set(
|
|
177
|
-
l.rows.map((t) => m(t, i.value))
|
|
178
|
-
);
|
|
148
|
+
const e = new Set(l.rows.map((t) => f(t, d.value)));
|
|
179
149
|
s.value = new Set([...s.value].filter((t) => e.has(t)));
|
|
180
150
|
}
|
|
181
151
|
);
|
|
182
|
-
const
|
|
152
|
+
const le = r(() => [
|
|
183
153
|
"w-full flex flex-col",
|
|
184
154
|
l.variant === "raised" ? "bg-background shadow-sm p-2 rounded-lg" : "bg-background rounded",
|
|
185
155
|
"overflow-hidden",
|
|
186
156
|
l.bordered ? "border border-border" : "",
|
|
187
157
|
l.class
|
|
188
|
-
].join(" ")), se =
|
|
189
|
-
|
|
190
|
-
), ne = (e) => e.width || "auto", re = n(
|
|
191
|
-
() => l.emptyTitleI18n ? P(l.emptyTitleI18n) : l.emptyTitle
|
|
192
|
-
), ie = n(
|
|
193
|
-
() => l.emptyDescriptionI18n ? P(l.emptyDescriptionI18n) : l.emptyDescription
|
|
194
|
-
), de = n(() => {
|
|
195
|
-
const e = P("vlite.dataTable.confirmDeleteTitle");
|
|
158
|
+
].join(" ")), ae = r(() => ["w-full caption-bottom -text-fs-1", l.tableClass].join(" ")), oe = (e) => e.width || "auto", se = r(() => l.emptyTitleI18n ? y(l.emptyTitleI18n) : l.emptyTitle), ne = r(() => l.emptyDescriptionI18n ? y(l.emptyDescriptionI18n) : l.emptyDescription), re = r(() => {
|
|
159
|
+
const e = y("vlite.dataTable.confirmDeleteTitle");
|
|
196
160
|
return e !== "vlite.dataTable.confirmDeleteTitle" ? e : "Confirm Deletion";
|
|
197
|
-
}),
|
|
198
|
-
const e =
|
|
161
|
+
}), ie = r(() => {
|
|
162
|
+
const e = y("vlite.dataTable.confirmDeleteDesc");
|
|
199
163
|
return e !== "vlite.dataTable.confirmDeleteDesc" ? e : "Are you sure you want to delete the selected items?";
|
|
200
|
-
}),
|
|
201
|
-
const e =
|
|
164
|
+
}), de = r(() => {
|
|
165
|
+
const e = y("vlite.dataTable.deleteBtn");
|
|
202
166
|
return e !== "vlite.dataTable.deleteBtn" ? e : "Delete";
|
|
203
|
-
}),
|
|
204
|
-
const e =
|
|
167
|
+
}), ce = r(() => {
|
|
168
|
+
const e = y("vlite.dataTable.cancelBtn");
|
|
205
169
|
return e !== "vlite.dataTable.cancelBtn" ? e : "Cancel";
|
|
206
170
|
});
|
|
207
|
-
return (e, t) => (
|
|
208
|
-
|
|
171
|
+
return (e, t) => (i(), u("div", ke, [
|
|
172
|
+
U.value || e.$slots?.["toolbar-left"] || e.$slots?.["toolbar-right"] ? (i(), A(Pe, {
|
|
209
173
|
key: 0,
|
|
210
|
-
modelValue:
|
|
211
|
-
"onUpdate:modelValue": t[1] || (t[1] = (a) =>
|
|
212
|
-
"show-search":
|
|
174
|
+
modelValue: p.value,
|
|
175
|
+
"onUpdate:modelValue": t[1] || (t[1] = (a) => p.value = a),
|
|
176
|
+
"show-search": U.value,
|
|
213
177
|
placeholder: o.searchPlaceholder,
|
|
214
178
|
placeholderI18n: o.searchPlaceholderI18n,
|
|
215
|
-
class:
|
|
179
|
+
class: C(o.toolbarClass),
|
|
216
180
|
"search-class": o.toolbarSearchClass
|
|
217
|
-
},
|
|
181
|
+
}, N({ _: 2 }, [
|
|
218
182
|
e.$slots?.["toolbar-left"] ? {
|
|
219
183
|
name: "left",
|
|
220
|
-
fn:
|
|
221
|
-
|
|
184
|
+
fn: k(() => [
|
|
185
|
+
I(e.$slots, "toolbar-left")
|
|
222
186
|
]),
|
|
223
187
|
key: "0"
|
|
224
188
|
} : void 0,
|
|
225
189
|
s.value.size > 0 ? {
|
|
226
190
|
name: "delete",
|
|
227
|
-
fn:
|
|
228
|
-
|
|
229
|
-
key: 0,
|
|
191
|
+
fn: k(() => [
|
|
192
|
+
S(he, {
|
|
230
193
|
rounded: "full",
|
|
231
194
|
variant: "outline",
|
|
232
195
|
size: "lg",
|
|
233
196
|
icon: "lucide:trash-2",
|
|
234
|
-
onClick: t[0] || (t[0] = (a) =>
|
|
235
|
-
})
|
|
197
|
+
onClick: t[0] || (t[0] = (a) => P.value = !0)
|
|
198
|
+
})
|
|
236
199
|
]),
|
|
237
200
|
key: "1"
|
|
238
201
|
} : void 0,
|
|
239
202
|
e.$slots?.["toolbar-right"] ? {
|
|
240
203
|
name: "right",
|
|
241
|
-
fn:
|
|
242
|
-
|
|
204
|
+
fn: k(() => [
|
|
205
|
+
I(e.$slots, "toolbar-right")
|
|
243
206
|
]),
|
|
244
207
|
key: "2"
|
|
245
208
|
} : void 0
|
|
246
|
-
]), 1032, ["modelValue", "show-search", "placeholder", "placeholderI18n", "class", "search-class"])) :
|
|
247
|
-
|
|
248
|
-
class:
|
|
209
|
+
]), 1032, ["modelValue", "show-search", "placeholder", "placeholderI18n", "class", "search-class"])) : $("", !0),
|
|
210
|
+
m("div", {
|
|
211
|
+
class: C(le.value)
|
|
249
212
|
}, [
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
class:
|
|
213
|
+
m("div", Ie, [
|
|
214
|
+
m("table", {
|
|
215
|
+
class: C([ae.value, "data-table"])
|
|
253
216
|
}, [
|
|
254
|
-
|
|
255
|
-
class:
|
|
217
|
+
m("thead", {
|
|
218
|
+
class: C([
|
|
256
219
|
"[&_tr]:border-b [&_tr]:border-border bg-muted",
|
|
257
220
|
o.variant === "raised" ? "[&_th:first-child]:rounded-tl-lg [&_th:last-child]:rounded-tr-lg" : ""
|
|
258
221
|
])
|
|
259
222
|
}, [
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
"model-value":
|
|
265
|
-
indeterminate:
|
|
223
|
+
m("tr", Se, [
|
|
224
|
+
D.value ? (i(), u("th", Te, [
|
|
225
|
+
m("div", De, [
|
|
226
|
+
S(ve, {
|
|
227
|
+
"model-value": z.value,
|
|
228
|
+
indeterminate: F.value,
|
|
266
229
|
size: "xs",
|
|
267
|
-
"onUpdate:modelValue":
|
|
230
|
+
"onUpdate:modelValue": H
|
|
268
231
|
}, null, 8, ["model-value", "indeterminate"])
|
|
269
232
|
])
|
|
270
|
-
])) :
|
|
271
|
-
(
|
|
233
|
+
])) : $("", !0),
|
|
234
|
+
(i(!0), u(B, null, T(o.headers, (a) => (i(), A(ye, {
|
|
272
235
|
key: a.field,
|
|
273
236
|
header: a,
|
|
274
|
-
"sort-config":
|
|
237
|
+
"sort-config": c.value,
|
|
275
238
|
compact: o.compact,
|
|
276
239
|
"table-sortable": o.sortable,
|
|
277
|
-
onSort:
|
|
240
|
+
onSort: Q,
|
|
278
241
|
class: "last:pr-5!",
|
|
279
|
-
style:
|
|
242
|
+
style: O({ width: oe(a) })
|
|
280
243
|
}, null, 8, ["header", "sort-config", "compact", "table-sortable", "style"]))), 128))
|
|
281
244
|
])
|
|
282
245
|
], 2),
|
|
283
|
-
|
|
284
|
-
|
|
246
|
+
m("tbody", xe, [
|
|
247
|
+
q.value ? (i(!0), u(B, { key: 0 }, T(Math.min(w.value, 15), (a) => (i(), u("tr", {
|
|
285
248
|
key: "skeleton-" + a,
|
|
286
249
|
class: "border-b border-border/70 bg-background transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
|
|
287
250
|
}, [
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
251
|
+
D.value ? (i(), u("td", $e, [...t[4] || (t[4] = [
|
|
252
|
+
m("div", { class: "flex items-center justify-center" }, [
|
|
253
|
+
m("div", { class: "h-4 w-4 rounded-[4px] bg-muted/50 animate-pulse" })
|
|
291
254
|
], -1)
|
|
292
|
-
])])) :
|
|
293
|
-
(
|
|
294
|
-
key:
|
|
295
|
-
class:
|
|
255
|
+
])])) : $("", !0),
|
|
256
|
+
(i(!0), u(B, null, T(o.headers, (n) => (i(), u("td", {
|
|
257
|
+
key: n.field,
|
|
258
|
+
class: C(["p-5! align-middle last:pr-6!", [n.hideOnMobile ? "hidden md:table-cell" : ""]])
|
|
296
259
|
}, [
|
|
297
|
-
|
|
298
|
-
class: "rounded-md bg-muted/50 animate-pulse h-4
|
|
299
|
-
style:
|
|
260
|
+
m("div", {
|
|
261
|
+
class: "rounded-md bg-muted/50 animate-pulse h-4",
|
|
262
|
+
style: O({ width: `${50 + Math.random() * 40}%` })
|
|
300
263
|
}, null, 4)
|
|
301
264
|
], 2))), 128))
|
|
302
|
-
]))), 128)) : o.rows.length > 0 ? (
|
|
303
|
-
key:
|
|
265
|
+
]))), 128)) : o.rows.length > 0 ? (i(!0), u(B, { key: 1 }, T(o.rows, (a, n) => (i(), A(we, {
|
|
266
|
+
key: f(a, d.value),
|
|
304
267
|
row: a,
|
|
305
268
|
headers: o.headers,
|
|
306
|
-
index:
|
|
307
|
-
"key-field":
|
|
308
|
-
selectable:
|
|
309
|
-
"is-selected": s.value.has(
|
|
269
|
+
index: n,
|
|
270
|
+
"key-field": d.value,
|
|
271
|
+
selectable: D.value,
|
|
272
|
+
"is-selected": s.value.has(f(a, d.value)),
|
|
310
273
|
hoverable: o.hoverable,
|
|
311
274
|
striped: o.striped,
|
|
312
275
|
compact: o.compact,
|
|
313
|
-
onSelect:
|
|
314
|
-
onRowClick:
|
|
276
|
+
onSelect: J,
|
|
277
|
+
onRowClick: ee,
|
|
315
278
|
class: "[&_td:last-child]:pr-3.5!"
|
|
316
|
-
},
|
|
317
|
-
|
|
318
|
-
name:
|
|
319
|
-
fn:
|
|
320
|
-
|
|
279
|
+
}, N({ _: 2 }, [
|
|
280
|
+
T(o.headers, (j) => ({
|
|
281
|
+
name: j.field,
|
|
282
|
+
fn: k((ue) => [
|
|
283
|
+
I(e.$slots, j.field, K({ ref_for: !0 }, ue))
|
|
321
284
|
])
|
|
322
285
|
}))
|
|
323
|
-
]), 1032, ["row", "headers", "index", "key-field", "selectable", "is-selected", "hoverable", "striped", "compact"]))), 128)) : (
|
|
324
|
-
|
|
325
|
-
colspan:
|
|
286
|
+
]), 1032, ["row", "headers", "index", "key-field", "selectable", "is-selected", "hoverable", "striped", "compact"]))), 128)) : (i(), u("tr", Be, [
|
|
287
|
+
m("td", {
|
|
288
|
+
colspan: D.value ? o.headers.length + 1 : o.headers.length,
|
|
326
289
|
class: "align-middle hover:bg-transparent"
|
|
327
290
|
}, [
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
title:
|
|
331
|
-
description:
|
|
291
|
+
I(e.$slots, "empty", {}, () => [
|
|
292
|
+
S(L(be), {
|
|
293
|
+
title: se.value,
|
|
294
|
+
description: ne.value,
|
|
332
295
|
icon: o.emptyIcon,
|
|
333
296
|
class: "border-none! bg-transparent! py-16!"
|
|
334
|
-
},
|
|
297
|
+
}, N({ _: 2 }, [
|
|
335
298
|
e.$slots["empty-action"] ? {
|
|
336
299
|
name: "action",
|
|
337
|
-
fn:
|
|
338
|
-
|
|
300
|
+
fn: k(() => [
|
|
301
|
+
I(e.$slots, "empty-action")
|
|
339
302
|
]),
|
|
340
303
|
key: "0"
|
|
341
304
|
} : void 0
|
|
342
305
|
]), 1032, ["title", "description", "icon"])
|
|
343
306
|
])
|
|
344
|
-
], 8,
|
|
307
|
+
], 8, Ee)
|
|
345
308
|
]))
|
|
346
309
|
])
|
|
347
310
|
], 2)
|
|
348
311
|
])
|
|
349
312
|
], 2),
|
|
350
|
-
o.showPagination && o.pageInfo && o.pageInfo.totalPages > 1 ? (
|
|
351
|
-
|
|
352
|
-
"current-page":
|
|
313
|
+
o.showPagination && o.pageInfo && o.pageInfo.totalPages > 1 ? (i(), u("div", Re, [
|
|
314
|
+
S(L(pe), K({
|
|
315
|
+
"current-page": h.value,
|
|
353
316
|
"total-pages": o.pageInfo.totalPages,
|
|
354
317
|
"total-items": o.pageInfo.totalItems
|
|
355
318
|
}, o.paginationProps, {
|
|
356
|
-
onChange:
|
|
357
|
-
"onUpdate:itemsPerPage":
|
|
319
|
+
onChange: Z,
|
|
320
|
+
"onUpdate:itemsPerPage": _
|
|
358
321
|
}), null, 16, ["current-page", "total-pages", "total-items"])
|
|
359
|
-
])) :
|
|
360
|
-
|
|
361
|
-
show:
|
|
362
|
-
"onUpdate:show": t[2] || (t[2] = (a) =>
|
|
363
|
-
title:
|
|
364
|
-
description:
|
|
365
|
-
"confirm-text":
|
|
366
|
-
"cancel-text":
|
|
322
|
+
])) : $("", !0),
|
|
323
|
+
S(ge, {
|
|
324
|
+
show: P.value,
|
|
325
|
+
"onUpdate:show": t[2] || (t[2] = (a) => P.value = a),
|
|
326
|
+
title: re.value,
|
|
327
|
+
description: ie.value,
|
|
328
|
+
"confirm-text": de.value,
|
|
329
|
+
"cancel-text": ce.value,
|
|
367
330
|
variant: "danger",
|
|
368
|
-
onConfirm:
|
|
369
|
-
onCancel: t[3] || (t[3] = (a) =>
|
|
331
|
+
onConfirm: te,
|
|
332
|
+
onCancel: t[3] || (t[3] = (a) => P.value = !1)
|
|
370
333
|
}, null, 8, ["show", "title", "description", "confirm-text", "cancel-text"])
|
|
371
334
|
]));
|
|
372
335
|
}
|
|
373
336
|
});
|
|
374
337
|
export {
|
|
375
|
-
|
|
338
|
+
Ye as default
|
|
376
339
|
};
|
|
@@ -10,16 +10,17 @@ export interface SortConfig {
|
|
|
10
10
|
}
|
|
11
11
|
export interface TableState {
|
|
12
12
|
pagination: PaginationConfig;
|
|
13
|
-
|
|
13
|
+
sort: SortConfig;
|
|
14
14
|
search: string;
|
|
15
|
+
filter: Record<string, any>;
|
|
15
16
|
}
|
|
16
17
|
export interface FilterConfig {
|
|
17
|
-
search: string;
|
|
18
|
-
sorting: SortConfig;
|
|
19
18
|
[key: string]: any;
|
|
20
19
|
}
|
|
21
20
|
export interface TableFilter {
|
|
22
21
|
pagination: PaginationConfig;
|
|
22
|
+
search: string;
|
|
23
|
+
sort: SortConfig;
|
|
23
24
|
filter: FilterConfig;
|
|
24
25
|
}
|
|
25
26
|
export interface TableHeader {
|
|
@@ -49,10 +50,7 @@ export interface DataTableProps {
|
|
|
49
50
|
headers: TableHeader[];
|
|
50
51
|
/**
|
|
51
52
|
* Unique row identifier field.
|
|
52
|
-
*
|
|
53
|
-
* automatically pick the first matching key from ['id', '_id'] found on the
|
|
54
|
-
* first row. Explicitly passing 'id' or '_id' (or any other string) pins the
|
|
55
|
-
* field to that exact value.
|
|
53
|
+
* 'auto' → picks first of ['id','_id'] found on first row, fallback '_id'.
|
|
56
54
|
*/
|
|
57
55
|
keyField?: string;
|
|
58
56
|
loading?: boolean;
|
|
@@ -83,11 +81,18 @@ export interface RowClickPayload {
|
|
|
83
81
|
row: any;
|
|
84
82
|
index: number;
|
|
85
83
|
}
|
|
86
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Shape provided by Screen to all deeply nested components via provide/inject.
|
|
86
|
+
*
|
|
87
|
+
* - disableSearch → DataTable hides its own search toolbar (Screen owns search)
|
|
88
|
+
* - forceSelectable → DataTable enables row selection for bulk-delete
|
|
89
|
+
* - onTableChange → DataTable calls this whenever sort/pagination/search changes
|
|
90
|
+
* so Screen can merge the state and call its own refetch.
|
|
91
|
+
* Undefined when DataTable is used standalone (outside Screen).
|
|
92
|
+
*/
|
|
87
93
|
export interface ScreenContext {
|
|
88
|
-
/** When true, DataTable should hide its own search toolbar */
|
|
89
94
|
disableSearch: boolean;
|
|
90
|
-
/** When true, DataTable should enable row selection */
|
|
91
95
|
forceSelectable: boolean;
|
|
96
|
+
onTableChange?: (state: TableState) => void;
|
|
92
97
|
}
|
|
93
98
|
export declare const SCREEN_CONTEXT_KEY: unique symbol;
|