vlite3 0.2.7 → 0.2.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.
@@ -50,6 +50,7 @@ declare function __VLS_template(): {
50
50
  readonly autoFocus: boolean;
51
51
  readonly wheelOptions: import('vue-carousel-lite/types').WheelOptions;
52
52
  readonly paginationPosition?: import('vue-carousel-lite').PaginationPosition | import('vue-carousel-lite').PaginationPosition[];
53
+ readonly updateKey?: string | number;
53
54
  readonly paginationBackground?: boolean;
54
55
  readonly "onSlide-change"?: ((index: number) => any) | undefined;
55
56
  } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, "direction" | "pagination" | "paginationSize" | "paginationVisibility" | "paginationHoverInitialTimeout" | "paginationHoverEdgeThreshold" | "autoPlay" | "draggable" | "autoPlayInterval" | "itemsToShow" | "gap" | "speed" | "easing" | "mousewheel" | "loop" | "currentItem" | "bufferSize" | "maxDomElements" | "autoFocus" | "wheelOptions">;
@@ -147,6 +148,9 @@ declare function __VLS_template(): {
147
148
  type: import('vue').PropType<number>;
148
149
  default: number;
149
150
  };
151
+ updateKey: {
152
+ type: import('vue').PropType<string | number>;
153
+ };
150
154
  autoFocus: {
151
155
  type: import('vue').PropType<boolean>;
152
156
  default: boolean;
@@ -325,6 +329,9 @@ declare function __VLS_template(): {
325
329
  type: import('vue').PropType<number>;
326
330
  default: number;
327
331
  };
332
+ updateKey: {
333
+ type: import('vue').PropType<string | number>;
334
+ };
328
335
  autoFocus: {
329
336
  type: import('vue').PropType<boolean>;
330
337
  default: boolean;
@@ -469,6 +476,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
469
476
  readonly autoFocus: boolean;
470
477
  readonly wheelOptions: import('vue-carousel-lite/types').WheelOptions;
471
478
  readonly paginationPosition?: import('vue-carousel-lite').PaginationPosition | import('vue-carousel-lite').PaginationPosition[];
479
+ readonly updateKey?: string | number;
472
480
  readonly paginationBackground?: boolean;
473
481
  readonly "onSlide-change"?: ((index: number) => any) | undefined;
474
482
  } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, "direction" | "pagination" | "paginationSize" | "paginationVisibility" | "paginationHoverInitialTimeout" | "paginationHoverEdgeThreshold" | "autoPlay" | "draggable" | "autoPlayInterval" | "itemsToShow" | "gap" | "speed" | "easing" | "mousewheel" | "loop" | "currentItem" | "bufferSize" | "maxDomElements" | "autoFocus" | "wheelOptions">;
@@ -566,6 +574,9 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
566
574
  type: import('vue').PropType<number>;
567
575
  default: number;
568
576
  };
577
+ updateKey: {
578
+ type: import('vue').PropType<string | number>;
579
+ };
569
580
  autoFocus: {
570
581
  type: import('vue').PropType<boolean>;
571
582
  default: boolean;
@@ -744,6 +755,9 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
744
755
  type: import('vue').PropType<number>;
745
756
  default: number;
746
757
  };
758
+ updateKey: {
759
+ type: import('vue').PropType<string | number>;
760
+ };
747
761
  autoFocus: {
748
762
  type: import('vue').PropType<boolean>;
749
763
  default: boolean;
@@ -1,7 +1,319 @@
1
- import o from "./DataTable.vue2.js";
2
- /* empty css */
3
- import t from "../../_virtual/_plugin-vue_export-helper.js";
4
- const e = /* @__PURE__ */ t(o, [["__scopeId", "data-v-53f1fe21"]]);
1
+ import { defineComponent as ee, ref as g, computed as b, watch as p, onMounted as te, openBlock as n, createElementBlock as i, createVNode as C, createSlots as j, withCtx as T, renderSlot as S, createBlock as D, createCommentVNode as I, createElementVNode as r, normalizeClass as B, Fragment as R, renderList as $, normalizeStyle as A, mergeProps as le, toDisplayString as M, createTextVNode as ae, unref as se } from "vue";
2
+ import oe from "../Icon.vue.js";
3
+ import ne from "../CheckBox.vue.js";
4
+ import re from "../Button.vue.js";
5
+ import ie from "../ConfirmationModal.vue.js";
6
+ import de from "../Pagination/Pagination.vue.js";
7
+ import ue from "./DataTableHeader.vue.js";
8
+ import ce from "./DataTableRow.vue.js";
9
+ import me from "./DataTableToolbar.vue.js";
10
+ const fe = { class: "space-y-4" }, he = { class: "overflow-x-auto w-full" }, ve = { class: "hover:bg-transparent" }, ge = {
11
+ key: 0,
12
+ scope: "col",
13
+ class: "w-[48px] px-0 text-center font-medium text-muted-foreground",
14
+ style: { width: "48px" }
15
+ }, pe = { class: "flex items-center justify-center" }, we = { class: "[&_tr:last-child]:border-0" }, ye = {
16
+ key: 0,
17
+ class: "w-[48px] px-0 py-4 align-middle text-center",
18
+ style: { width: "48px" }
19
+ }, be = { key: 2 }, ke = ["colspan"], Pe = { class: "flex flex-col items-center justify-center gap-2 text-muted-foreground p-8" }, xe = { class: "flex h-12 w-12 items-center justify-center rounded-full bg-muted" }, Ce = { class: "mt-1 text-base font-semibold text-foreground" }, Se = { class: "text-sm max-w-sm mx-auto" }, Ie = {
20
+ key: 0,
21
+ class: "mt-4"
22
+ }, $e = { key: 0 }, je = /* @__PURE__ */ ee({
23
+ __name: "DataTable",
24
+ props: {
25
+ rows: { default: () => [] },
26
+ selectedRows: { default: () => [] },
27
+ search: { default: "" },
28
+ showSearch: { type: Boolean, default: !0 },
29
+ searchPlaceholder: { default: "Search..." },
30
+ headers: { default: () => [] },
31
+ keyField: { default: "_id" },
32
+ loading: { type: Boolean, default: !1 },
33
+ selectable: { type: Boolean, default: !1 },
34
+ emptyTitle: { default: "No data available" },
35
+ emptyDescription: { default: "No results found. Try adjusting your filters or search terms." },
36
+ emptyIcon: { default: "lucide:inbox" },
37
+ showPagination: { type: Boolean, default: !0 },
38
+ paginationPosition: {},
39
+ pageInfo: {},
40
+ itemsPerPage: { default: 10 },
41
+ itemsPerPageOptions: { default: () => [10, 25, 50, 100] },
42
+ showItemsPerPage: { type: Boolean, default: !0 },
43
+ striped: { type: Boolean, default: !1 },
44
+ hoverable: { type: Boolean, default: !0 },
45
+ bordered: { type: Boolean, default: !0 },
46
+ compact: { type: Boolean, default: !1 },
47
+ tableClass: {},
48
+ class: {},
49
+ sortable: { type: Boolean, default: !1 },
50
+ variant: { default: "default" }
51
+ },
52
+ emits: ["change", "select", "rowClick", "update:itemsPerPage", "update:selectedRows", "delete"],
53
+ setup(a, { emit: U }) {
54
+ const O = (e, t) => {
55
+ if (!(!e || !t))
56
+ return t.includes(".") ? t.split(".").reduce((s, c) => s?.[c], e) : e[t];
57
+ }, u = (e, t) => O(e, t), l = a, w = U, d = g({ field: "", order: "" }), k = g(l.itemsPerPage), h = g(l.pageInfo?.currentPage || 1), y = g(l.search || ""), P = g(!1), v = g("initial"), L = b(() => l.loading && (v.value === "initial" || v.value === "page"));
58
+ p(
59
+ () => l.loading,
60
+ (e, t) => {
61
+ !e && t && (v.value = "idle");
62
+ }
63
+ ), p(
64
+ () => l.search,
65
+ (e) => {
66
+ e !== void 0 && e !== y.value && (y.value = e);
67
+ }
68
+ );
69
+ let F = null;
70
+ p(y, (e) => {
71
+ F && clearTimeout(F), F = setTimeout(() => {
72
+ h.value = 1, v.value = "search", x();
73
+ }, 300);
74
+ }), p(
75
+ () => l.itemsPerPage,
76
+ (e) => {
77
+ k.value = e;
78
+ }
79
+ ), p(
80
+ () => l.pageInfo?.currentPage,
81
+ (e) => {
82
+ e && (h.value = e);
83
+ }
84
+ );
85
+ const E = (e) => u(e, l.keyField), o = g(/* @__PURE__ */ new Set());
86
+ p(
87
+ () => l.selectedRows,
88
+ (e) => {
89
+ const t = new Set((e || []).map((s) => u(s, l.keyField)));
90
+ (t.size !== o.value.size || [...t].some((s) => !o.value.has(s))) && (o.value = t);
91
+ },
92
+ { immediate: !0, deep: !0 }
93
+ );
94
+ const z = b(() => l.rows.length === 0 ? !1 : l.rows.every((e) => o.value.has(u(e, l.keyField)))), N = b(() => o.value.size > 0 && !z.value), W = b(() => {
95
+ const e = [...l.selectedRows || [], ...l.rows], t = /* @__PURE__ */ new Map();
96
+ return e.forEach((s) => t.set(u(s, l.keyField), s)), Array.from(o.value).map((s) => t.get(s)).filter(Boolean);
97
+ }), q = (e) => {
98
+ e ? l.rows.forEach((t) => o.value.add(u(t, l.keyField))) : o.value.size > 0 && l.rows.forEach((t) => o.value.delete(u(t, l.keyField))), V();
99
+ }, G = (e) => {
100
+ o.value.has(e) ? o.value.delete(e) : o.value.add(e), V();
101
+ }, V = () => {
102
+ const e = l.selectedRows || [], t = /* @__PURE__ */ new Set(), s = [];
103
+ l.rows.forEach((m) => {
104
+ const f = u(m, l.keyField);
105
+ o.value.has(f) && (s.push(m), t.add(f));
106
+ }), e.forEach((m) => {
107
+ const f = u(m, l.keyField);
108
+ !t.has(f) && o.value.has(f) && (s.push(m), t.add(f));
109
+ });
110
+ const c = {
111
+ selected: s,
112
+ all: z.value,
113
+ indeterminate: N.value
114
+ };
115
+ w("select", c), w("update:selectedRows", s);
116
+ }, H = (e) => {
117
+ d.value.field === e ? d.value.order === "asc" ? d.value.order = "desc" : d.value.order === "desc" ? (d.value.order = "", d.value.field = "") : d.value.order = "asc" : (d.value.field = e, d.value.order = "asc"), h.value = 1, v.value = "sort", x();
118
+ }, J = (e) => {
119
+ h.value = e, v.value = "page", x();
120
+ }, K = (e) => {
121
+ k.value = e, h.value = 1, v.value = "limit", w("update:itemsPerPage", e), x();
122
+ }, Q = (e) => {
123
+ w("rowClick", e);
124
+ }, X = () => {
125
+ const e = W.value;
126
+ w("delete", e), P.value = !1;
127
+ }, x = () => {
128
+ w("change", {
129
+ pagination: {
130
+ page: h.value,
131
+ limit: k.value
132
+ },
133
+ sorting: { ...d.value },
134
+ search: y.value
135
+ });
136
+ }, Y = b(() => [
137
+ "w-full flex flex-col",
138
+ l.variant === "raised" ? "bg-background shadow-sm p-2 rounded-lg" : "bg-background rounded",
139
+ "overflow-hidden",
140
+ l.bordered ? "border border-border/60" : "",
141
+ l.class
142
+ ].join(" ")), Z = b(() => ["w-full caption-bottom text-sm", l.tableClass].join(" ")), _ = (e) => e.width ? e.width : "auto";
143
+ return p(
144
+ () => l.rows,
145
+ () => {
146
+ const e = new Set(l.rows.map((t) => u(t, l.keyField)));
147
+ o.value = new Set([...o.value].filter((t) => e.has(t)));
148
+ }
149
+ ), te(() => {
150
+ x();
151
+ }), (e, t) => (n(), i("div", fe, [
152
+ C(me, {
153
+ modelValue: y.value,
154
+ "onUpdate:modelValue": t[1] || (t[1] = (s) => y.value = s),
155
+ "show-search": a.showSearch,
156
+ placeholder: a.searchPlaceholder
157
+ }, j({ _: 2 }, [
158
+ e.$slots?.["toolbar-left"] ? {
159
+ name: "left",
160
+ fn: T(() => [
161
+ S(e.$slots, "toolbar-left")
162
+ ]),
163
+ key: "0"
164
+ } : void 0,
165
+ e.$slots?.["toolbar-right"] || o.value.size > 0 ? {
166
+ name: "right",
167
+ fn: T(() => [
168
+ o.value.size > 0 ? (n(), D(re, {
169
+ key: 0,
170
+ rounded: "full",
171
+ variant: "ghost",
172
+ icon: "lucide:trash-2",
173
+ class: "text-destructive! bg-destructive/10 hover:bg-destructive/15",
174
+ onClick: t[0] || (t[0] = (s) => P.value = !0)
175
+ })) : I("", !0),
176
+ S(e.$slots, "toolbar-right")
177
+ ]),
178
+ key: "1"
179
+ } : void 0
180
+ ]), 1032, ["modelValue", "show-search", "placeholder"]),
181
+ r("div", {
182
+ class: B(Y.value)
183
+ }, [
184
+ r("div", he, [
185
+ r("table", {
186
+ class: B([Z.value, "data-table"])
187
+ }, [
188
+ r("thead", {
189
+ class: B([
190
+ "[&_tr]:border-b [&_tr]:border-border/70! bg-muted",
191
+ a.variant === "raised" ? "[&_th:first-child]:rounded-tl-lg [&_th:last-child]:rounded-tr-lg" : ""
192
+ ])
193
+ }, [
194
+ r("tr", ve, [
195
+ a.selectable ? (n(), i("th", ge, [
196
+ r("div", pe, [
197
+ C(ne, {
198
+ "model-value": z.value,
199
+ indeterminate: N.value,
200
+ size: "xs",
201
+ "onUpdate:modelValue": q
202
+ }, null, 8, ["model-value", "indeterminate"])
203
+ ])
204
+ ])) : I("", !0),
205
+ (n(!0), i(R, null, $(a.headers, (s) => (n(), D(ue, {
206
+ key: s.field,
207
+ header: s,
208
+ "sort-config": d.value,
209
+ compact: a.compact,
210
+ "table-sortable": a.sortable,
211
+ onSort: H,
212
+ class: "last:pr-5!",
213
+ style: A({
214
+ width: _(s)
215
+ })
216
+ }, null, 8, ["header", "sort-config", "compact", "table-sortable", "style"]))), 128))
217
+ ])
218
+ ], 2),
219
+ r("tbody", we, [
220
+ L.value ? (n(!0), i(R, { key: 0 }, $(Math.min(k.value, 15), (s) => (n(), i("tr", {
221
+ key: "skeleton-" + s,
222
+ class: "border-b border-border/50 bg-background transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted"
223
+ }, [
224
+ a.selectable ? (n(), i("td", ye, [...t[4] || (t[4] = [
225
+ r("div", { class: "flex items-center justify-center" }, [
226
+ r("div", { class: "h-4 w-4 rounded-[4px] bg-muted/50 animate-pulse" })
227
+ ], -1)
228
+ ])])) : I("", !0),
229
+ (n(!0), i(R, null, $(a.headers, (c) => (n(), i("td", {
230
+ key: c.field,
231
+ class: B(["p-5! align-middle last:pr-6!", [c.hideOnMobile ? "hidden md:table-cell" : ""]])
232
+ }, [
233
+ r("div", {
234
+ class: "rounded-md bg-muted/50 animate-pulse h-4 w-full",
235
+ style: A({
236
+ width: `${50 + Math.random() * 40}%`
237
+ })
238
+ }, null, 4)
239
+ ], 2))), 128))
240
+ ]))), 128)) : a.rows.length > 0 ? (n(!0), i(R, { key: 1 }, $(a.rows, (s, c) => (n(), D(ce, {
241
+ key: E(s),
242
+ row: s,
243
+ headers: a.headers,
244
+ index: c,
245
+ "key-field": a.keyField,
246
+ selectable: a.selectable,
247
+ "is-selected": o.value.has(E(s)),
248
+ hoverable: a.hoverable,
249
+ striped: a.striped,
250
+ compact: a.compact,
251
+ onSelect: G,
252
+ onRowClick: Q,
253
+ class: "[&_td:last-child]:pr-3.5!"
254
+ }, j({ _: 2 }, [
255
+ $(a.headers, (m) => ({
256
+ name: m.field,
257
+ fn: T((f) => [
258
+ S(e.$slots, m.field, le({ ref_for: !0 }, f))
259
+ ])
260
+ }))
261
+ ]), 1032, ["row", "headers", "index", "key-field", "selectable", "is-selected", "hoverable", "striped", "compact"]))), 128)) : (n(), i("tr", be, [
262
+ r("td", {
263
+ colspan: a.selectable ? a.headers.length + 1 : a.headers.length,
264
+ class: "h-96 text-center align-middle hover:bg-transparent"
265
+ }, [
266
+ r("div", Pe, [
267
+ r("div", xe, [
268
+ C(oe, {
269
+ icon: a.emptyIcon,
270
+ class: "h-6 w-6 text-muted-foreground/80"
271
+ }, null, 8, ["icon"])
272
+ ]),
273
+ r("h3", Ce, M(a.emptyTitle), 1),
274
+ r("p", Se, [
275
+ S(e.$slots, "empty-description", {}, () => [
276
+ ae(M(a.emptyDescription), 1)
277
+ ])
278
+ ]),
279
+ e.$slots["empty-action"] ? (n(), i("div", Ie, [
280
+ S(e.$slots, "empty-action")
281
+ ])) : I("", !0)
282
+ ])
283
+ ], 8, ke)
284
+ ]))
285
+ ])
286
+ ], 2)
287
+ ])
288
+ ], 2),
289
+ a.showPagination && a.pageInfo && a.pageInfo.totalItems > 0 ? (n(), i("div", $e, [
290
+ C(se(de), {
291
+ "current-page": h.value,
292
+ "total-pages": a.pageInfo.totalPages,
293
+ "show-page-info": !1,
294
+ "show-items-per-page": a.showItemsPerPage,
295
+ "items-per-page": k.value,
296
+ "items-per-page-options": a.itemsPerPageOptions,
297
+ "nav-type": "icon",
298
+ alignment: l.paginationPosition,
299
+ onChange: J,
300
+ "onUpdate:itemsPerPage": K
301
+ }, null, 8, ["current-page", "total-pages", "show-items-per-page", "items-per-page", "items-per-page-options", "alignment"])
302
+ ])) : I("", !0),
303
+ C(ie, {
304
+ show: P.value,
305
+ "onUpdate:show": t[2] || (t[2] = (s) => P.value = s),
306
+ title: "Confirm Deletion",
307
+ description: "Are you sure you want to delete the selected items?",
308
+ "confirm-text": "Delete",
309
+ "cancel-text": "Cancel",
310
+ variant: "danger",
311
+ onConfirm: X,
312
+ onCancel: t[3] || (t[3] = (s) => P.value = !1)
313
+ }, null, 8, ["show"])
314
+ ]));
315
+ }
316
+ });
5
317
  export {
6
- e as default
318
+ je as default
7
319
  };