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