vlite3 0.7.7 → 0.7.9

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,5 +1,5 @@
1
- import o from "./ColorIro.vue2.js";
2
- /* empty css */
1
+ import o from "./ColorIro.vue.js";
2
+ /* empty css */
3
3
  export {
4
4
  o as default
5
5
  };
@@ -5,8 +5,8 @@ import O from "../Input.vue.js";
5
5
  /* empty css */
6
6
  import "../../core/config.js";
7
7
  import y from "../Button.vue.js";
8
- import E from "./ColorIro.vue2.js";
9
- /* empty css */
8
+ import E from "./ColorIro.vue.js";
9
+ /* empty css */
10
10
  import { useEyeDropper as P } from "@vueuse/core";
11
11
  const I = {
12
12
  key: 0,
@@ -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: import('./types').TableHeader[];
42
+ headers: TableHeader[];
43
43
  paginationProps: import('./types').DataTablePaginationProps;
44
44
  emptyIcon: string;
45
45
  showPagination: boolean;
@@ -1,24 +1,24 @@
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";
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
+ import he from "../CheckBox.vue.js";
3
+ import ge from "../Button.vue.js";
4
+ import pe from "../ConfirmationModal.vue.js";
5
+ import be from "../Pagination/Pagination.vue.js";
6
+ import ye from "../Empty/Empty.vue.js";
7
+ import we from "./DataTableHeader.vue.js";
8
+ import Pe from "./DataTableRow.vue.js";
9
+ import Ce from "./DataTableToolbar.vue.js";
10
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 = {
11
+ import { SCREEN_CONTEXT_KEY as ke } from "./types.js";
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,
14
14
  scope: "col",
15
15
  class: "w-[48px] px-0 text-center font-medium text-muted-foreground",
16
16
  style: { width: "48px" }
17
- }, De = { class: "flex items-center justify-center" }, xe = { class: "[&_tr:last-child]:border-0" }, $e = {
17
+ }, xe = { class: "flex items-center justify-center" }, $e = { class: "[&_tr:last-child]:border-0" }, Be = {
18
18
  key: 0,
19
19
  class: "w-[48px] px-0 py-4 align-middle text-center",
20
20
  style: { width: "48px" }
21
- }, Be = { key: 2 }, Ee = ["colspan"], Re = { key: 1 }, Ye = /* @__PURE__ */ me({
21
+ }, Ee = { key: 2 }, Re = ["colspan"], ze = { key: 1 }, We = /* @__PURE__ */ me({
22
22
  __name: "DataTable",
23
23
  props: {
24
24
  rows: { default: () => [] },
@@ -60,81 +60,78 @@ const ke = { class: "space-y-6.5" }, Ie = { class: "overflow-x-auto w-full" }, S
60
60
  setup(o, { emit: Y }) {
61
61
  const W = (e, t) => {
62
62
  if (!(!e || !t))
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
- const a = ["id", "_id"];
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 n of a)
69
- if (n in e[0]) return n;
68
+ for (const s of l)
69
+ if (s in e[0]) return s;
70
70
  }
71
71
  return "_id";
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
- l.pageInfo?.itemsPerPage || l.paginationProps?.itemsPerPage || 10
74
- ), h = b(l.pageInfo?.currentPage || 1), p = b(l.search || ""), P = b(!1), q = r(() => l.loading);
75
- v(
76
- () => l.loading,
77
- (e, t) => {
78
- }
79
- ), v(
80
- () => 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,
81
77
  (e) => {
82
78
  e !== void 0 && e !== p.value && (p.value = e);
83
79
  }
84
80
  );
85
81
  let R = null;
86
- v(p, () => {
82
+ h(p, () => {
87
83
  R && clearTimeout(R), R = setTimeout(() => {
88
- h.value = 1, x();
84
+ v.value = 1, x();
89
85
  }, 300);
90
- }), v(() => l.pageInfo?.itemsPerPage, (e) => {
86
+ }), h(() => a.pageInfo?.itemsPerPage, (e) => {
91
87
  e !== void 0 && (w.value = e);
92
- }), v(() => l.paginationProps?.itemsPerPage, (e) => {
88
+ }), h(() => a.paginationProps?.itemsPerPage, (e) => {
93
89
  e !== void 0 && (w.value = e);
94
- }), v(() => l.pageInfo?.currentPage, (e) => {
95
- e && (h.value = e);
90
+ }), h(() => a.pageInfo?.currentPage, (e) => {
91
+ e && (v.value = e);
96
92
  });
97
- const s = b(/* @__PURE__ */ new Set());
98
- v(
99
- () => l.selectedRows,
93
+ const n = b(/* @__PURE__ */ new Set());
94
+ h(
95
+ () => a.selectedRows,
100
96
  (e) => {
101
- const t = new Set((e || []).map((a) => f(a, d.value)));
102
- (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);
103
99
  },
104
100
  { immediate: !0, deep: !0 }
105
101
  );
106
102
  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(() => {
109
- const e = [...l.selectedRows || [], ...l.rows], t = /* @__PURE__ */ new Map();
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 = () => {
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();
111
+ }, K = () => {
116
112
  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));
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));
123
119
  }), 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();
126
120
  }, Z = (e) => {
127
- h.value = e, x();
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();
128
123
  }, _ = (e) => {
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;
124
+ v.value = e, x();
125
+ }, ee = (e) => {
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;
132
129
  };
133
- let V = null;
130
+ let A = null;
134
131
  const x = () => {
135
- V && clearTimeout(V), V = setTimeout(() => {
132
+ A && clearTimeout(A), A = setTimeout(() => {
136
133
  const e = {
137
- pagination: { page: h.value, limit: w.value },
134
+ pagination: { page: v.value, limit: w.value },
138
135
  sort: { ...c.value },
139
136
  search: p.value,
140
137
  filter: {}
@@ -142,43 +139,43 @@ const ke = { class: "space-y-6.5" }, Ie = { class: "overflow-x-auto w-full" }, S
142
139
  g("change", e), E?.onTableChange?.(e);
143
140
  }, 10);
144
141
  };
145
- v(
146
- () => l.rows,
142
+ h(
143
+ () => a.rows,
147
144
  () => {
148
- const e = new Set(l.rows.map((t) => f(t, d.value)));
149
- 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)));
150
147
  }
151
148
  );
152
- const le = r(() => [
149
+ const ae = r(() => [
153
150
  "w-full flex flex-col",
154
- l.variant === "raised" ? "bg-background shadow-sm p-2 rounded-lg" : "bg-background rounded",
151
+ a.variant === "raised" ? "bg-background shadow-sm p-2 rounded-lg" : "bg-background rounded",
155
152
  "overflow-hidden",
156
- l.bordered ? "border border-border" : "",
157
- l.class
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(() => {
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(() => {
159
156
  const e = y("vlite.dataTable.confirmDeleteTitle");
160
157
  return e !== "vlite.dataTable.confirmDeleteTitle" ? e : "Confirm Deletion";
161
- }), ie = r(() => {
158
+ }), de = r(() => {
162
159
  const e = y("vlite.dataTable.confirmDeleteDesc");
163
160
  return e !== "vlite.dataTable.confirmDeleteDesc" ? e : "Are you sure you want to delete the selected items?";
164
- }), de = r(() => {
161
+ }), ce = r(() => {
165
162
  const e = y("vlite.dataTable.deleteBtn");
166
163
  return e !== "vlite.dataTable.deleteBtn" ? e : "Delete";
167
- }), ce = r(() => {
164
+ }), ue = r(() => {
168
165
  const e = y("vlite.dataTable.cancelBtn");
169
166
  return e !== "vlite.dataTable.cancelBtn" ? e : "Cancel";
170
167
  });
171
- return (e, t) => (i(), u("div", ke, [
172
- U.value || e.$slots?.["toolbar-left"] || e.$slots?.["toolbar-right"] ? (i(), A(Pe, {
168
+ return (e, t) => (i(), u("div", Ie, [
169
+ U.value || e.$slots?.["toolbar-left"] || e.$slots?.["toolbar-right"] ? (i(), N(Ce, {
173
170
  key: 0,
174
171
  modelValue: p.value,
175
- "onUpdate:modelValue": t[1] || (t[1] = (a) => p.value = a),
172
+ "onUpdate:modelValue": t[1] || (t[1] = (l) => p.value = l),
176
173
  "show-search": U.value,
177
174
  placeholder: o.searchPlaceholder,
178
175
  placeholderI18n: o.searchPlaceholderI18n,
179
176
  class: C(o.toolbarClass),
180
177
  "search-class": o.toolbarSearchClass
181
- }, N({ _: 2 }, [
178
+ }, V({ _: 2 }, [
182
179
  e.$slots?.["toolbar-left"] ? {
183
180
  name: "left",
184
181
  fn: k(() => [
@@ -186,15 +183,15 @@ const ke = { class: "space-y-6.5" }, Ie = { class: "overflow-x-auto w-full" }, S
186
183
  ]),
187
184
  key: "0"
188
185
  } : void 0,
189
- s.value.size > 0 ? {
186
+ n.value.size > 0 ? {
190
187
  name: "delete",
191
188
  fn: k(() => [
192
- S(he, {
189
+ S(ge, {
193
190
  rounded: "full",
194
191
  variant: "outline",
195
192
  size: "lg",
196
193
  icon: "lucide:trash-2",
197
- onClick: t[0] || (t[0] = (a) => P.value = !0)
194
+ onClick: t[0] || (t[0] = (l) => P.value = !0)
198
195
  })
199
196
  ]),
200
197
  key: "1"
@@ -207,94 +204,94 @@ const ke = { class: "space-y-6.5" }, Ie = { class: "overflow-x-auto w-full" }, S
207
204
  key: "2"
208
205
  } : void 0
209
206
  ]), 1032, ["modelValue", "show-search", "placeholder", "placeholderI18n", "class", "search-class"])) : $("", !0),
210
- m("div", {
211
- class: C(le.value)
207
+ f("div", {
208
+ class: C(ae.value)
212
209
  }, [
213
- m("div", Ie, [
214
- m("table", {
215
- class: C([ae.value, "data-table"])
210
+ f("div", Se, [
211
+ f("table", {
212
+ class: C([oe.value, "data-table"])
216
213
  }, [
217
- m("thead", {
214
+ f("thead", {
218
215
  class: C([
219
216
  "[&_tr]:border-b [&_tr]:border-border bg-muted",
220
217
  o.variant === "raised" ? "[&_th:first-child]:rounded-tl-lg [&_th:last-child]:rounded-tr-lg" : ""
221
218
  ])
222
219
  }, [
223
- m("tr", Se, [
224
- D.value ? (i(), u("th", Te, [
225
- m("div", De, [
226
- S(ve, {
220
+ f("tr", Te, [
221
+ D.value ? (i(), u("th", De, [
222
+ f("div", xe, [
223
+ S(he, {
227
224
  "model-value": z.value,
228
225
  indeterminate: F.value,
229
226
  size: "xs",
230
- "onUpdate:modelValue": H
227
+ "onUpdate:modelValue": J
231
228
  }, null, 8, ["model-value", "indeterminate"])
232
229
  ])
233
230
  ])) : $("", !0),
234
- (i(!0), u(B, null, T(o.headers, (a) => (i(), A(ye, {
235
- key: a.field,
236
- header: a,
231
+ (i(!0), u(B, null, T(o.headers, (l) => (i(), N(we, {
232
+ key: l.field,
233
+ header: l,
237
234
  "sort-config": c.value,
238
235
  compact: o.compact,
239
236
  "table-sortable": o.sortable,
240
- onSort: Q,
237
+ onSort: Z,
241
238
  class: "last:pr-5!",
242
- style: O({ width: oe(a) })
239
+ style: j({ width: se(l) })
243
240
  }, null, 8, ["header", "sort-config", "compact", "table-sortable", "style"]))), 128))
244
241
  ])
245
242
  ], 2),
246
- m("tbody", xe, [
247
- q.value ? (i(!0), u(B, { key: 0 }, T(Math.min(w.value, 15), (a) => (i(), u("tr", {
248
- key: "skeleton-" + a,
243
+ f("tbody", $e, [
244
+ G.value ? (i(!0), u(B, { key: 0 }, T(Math.min(w.value, 15), (l) => (i(), u("tr", {
245
+ key: "skeleton-" + l,
249
246
  class: "border-b border-border/70 bg-background transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
250
247
  }, [
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" })
248
+ D.value ? (i(), u("td", Be, [...t[4] || (t[4] = [
249
+ f("div", { class: "flex items-center justify-center" }, [
250
+ f("div", { class: "h-4 w-4 rounded-[4px] bg-muted/50 animate-pulse" })
254
251
  ], -1)
255
252
  ])])) : $("", !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" : ""]])
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" : ""]])
259
256
  }, [
260
- m("div", {
257
+ f("div", {
261
258
  class: "rounded-md bg-muted/50 animate-pulse h-4",
262
- style: O({ width: `${50 + Math.random() * 40}%` })
259
+ style: j({ width: `${50 + Math.random() * 40}%` })
263
260
  }, null, 4)
264
261
  ], 2))), 128))
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),
267
- row: a,
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,
268
265
  headers: o.headers,
269
- index: n,
266
+ index: s,
270
267
  "key-field": d.value,
271
268
  selectable: D.value,
272
- "is-selected": s.value.has(f(a, d.value)),
269
+ "is-selected": n.value.has(m(l, d.value)),
273
270
  hoverable: o.hoverable,
274
271
  striped: o.striped,
275
272
  compact: o.compact,
276
- onSelect: J,
277
- onRowClick: ee,
273
+ onSelect: Q,
274
+ onRowClick: te,
278
275
  class: "[&_td:last-child]:pr-3.5!"
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))
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))
284
281
  ])
285
282
  }))
286
- ]), 1032, ["row", "headers", "index", "key-field", "selectable", "is-selected", "hoverable", "striped", "compact"]))), 128)) : (i(), u("tr", Be, [
287
- m("td", {
283
+ ]), 1032, ["row", "headers", "index", "key-field", "selectable", "is-selected", "hoverable", "striped", "compact"]))), 128)) : (i(), u("tr", Ee, [
284
+ f("td", {
288
285
  colspan: D.value ? o.headers.length + 1 : o.headers.length,
289
286
  class: "align-middle hover:bg-transparent"
290
287
  }, [
291
288
  I(e.$slots, "empty", {}, () => [
292
- S(L(be), {
293
- title: se.value,
294
- description: ne.value,
289
+ S(L(ye), {
290
+ title: ne.value,
291
+ description: re.value,
295
292
  icon: o.emptyIcon,
296
293
  class: "border-none! bg-transparent! py-16!"
297
- }, N({ _: 2 }, [
294
+ }, V({ _: 2 }, [
298
295
  e.$slots["empty-action"] ? {
299
296
  name: "action",
300
297
  fn: k(() => [
@@ -304,36 +301,36 @@ const ke = { class: "space-y-6.5" }, Ie = { class: "overflow-x-auto w-full" }, S
304
301
  } : void 0
305
302
  ]), 1032, ["title", "description", "icon"])
306
303
  ])
307
- ], 8, Ee)
304
+ ], 8, Re)
308
305
  ]))
309
306
  ])
310
307
  ], 2)
311
308
  ])
312
309
  ], 2),
313
- o.showPagination && o.pageInfo && o.pageInfo.totalPages > 1 ? (i(), u("div", Re, [
314
- S(L(pe), K({
315
- "current-page": h.value,
310
+ o.showPagination && o.pageInfo && o.pageInfo.totalPages > 1 ? (i(), u("div", ze, [
311
+ S(L(be), O({
312
+ "current-page": v.value,
316
313
  "total-pages": o.pageInfo.totalPages,
317
314
  "total-items": o.pageInfo.totalItems
318
315
  }, o.paginationProps, {
319
- onChange: Z,
320
- "onUpdate:itemsPerPage": _
316
+ onChange: _,
317
+ "onUpdate:itemsPerPage": ee
321
318
  }), null, 16, ["current-page", "total-pages", "total-items"])
322
319
  ])) : $("", !0),
323
- S(ge, {
320
+ S(pe, {
324
321
  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,
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,
330
327
  variant: "danger",
331
- onConfirm: te,
332
- onCancel: t[3] || (t[3] = (a) => P.value = !1)
328
+ onConfirm: le,
329
+ onCancel: t[3] || (t[3] = (l) => P.value = !1)
333
330
  }, null, 8, ["show", "title", "description", "confirm-text", "cancel-text"])
334
331
  ]));
335
332
  }
336
333
  });
337
334
  export {
338
- Ye as default
335
+ We as default
339
336
  };
@@ -1,10 +1,10 @@
1
- import { defineComponent as p, computed as o, openBlock as a, createElementBlock as n, normalizeClass as r, createElementVNode as l, toDisplayString as g, createVNode as x, createCommentVNode as b } from "vue";
2
- import y from "../Icon.vue.js";
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 v = { class: "text-xs font-bold! uppercase tracking-wider text-gray-900 truncate" }, w = {
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
- }, I = /* @__PURE__ */ p({
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, s = i, c = o(() => e.sortConfig?.field === e.header.field && e.sortConfig?.order), d = o(() => !e.sortConfig || e.sortConfig.field !== e.header.field ? "lucide:chevrons-up-down" : e.sortConfig.order === "asc" ? "lucide:arrow-up" : e.sortConfig.order === "desc" ? "lucide:arrow-down" : "lucide:chevrons-up-down"), f = () => {
18
- e.tableSortable && e.header.sortable !== !1 && s("sort", e.header.field);
19
- }, u = o(() => ({
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"]), h = o(() => e.header.titleI18n ? C(e.header.titleI18n) : e.header.title);
24
- return (m, k) => (a(), n("th", {
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: f
35
+ onClick: u
32
36
  }, [
33
- l("div", {
34
- class: r(["flex items-center gap-2 space-x-2", u.value])
37
+ s("div", {
38
+ class: r(["flex items-center gap-2 space-x-2", h.value])
35
39
  }, [
36
- l("span", v, g(h.value), 1),
37
- t.tableSortable && t.header.sortable !== !1 ? (a(), n("span", w, [
38
- x(y, {
39
- icon: d.value,
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
- ])) : b("", !0)
46
+ ])) : y("", !0)
45
47
  ], 2)
46
48
  ], 2));
47
49
  }
48
50
  });
49
51
  export {
50
- I as default
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;