@dazzadev/vuetify-datatable 1.0.1 → 1.0.3
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/README.md +5 -2
- package/dist/components/DataTable.vue.d.ts +3 -0
- package/dist/vuetify-datatable.js +244 -226
- package/dist/vuetify-datatable.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @dazzadev/vuetify-datatable
|
|
2
2
|
|
|
3
|
-
Reusable server-side DataTable component for Vuetify 3. Includes action buttons (view, edit, delete), configurable icons, and a built-in confirmation
|
|
3
|
+
Reusable server-side DataTable component for Vuetify 3. Includes action buttons (view, edit, delete), configurable icons, and a built-in delete confirmation dialog.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -24,7 +24,7 @@ app.use(VuetifyDatatable);
|
|
|
24
24
|
### Or import individually
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
import { DataTable
|
|
27
|
+
import { DataTable } from "@dazzadev/vuetify-datatable";
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Basic Usage
|
|
@@ -129,6 +129,9 @@ If no configuration is provided, the component uses Material Design Icons (inclu
|
|
|
129
129
|
| `viewIcon` | `string` | — | View icon name override |
|
|
130
130
|
| `editIcon` | `string` | — | Edit icon name override |
|
|
131
131
|
| `deleteIcon` | `string` | — | Delete icon name override |
|
|
132
|
+
| `disableView` | `(item: T) => boolean` | — | Per-row predicate: disable the view button when it returns `true` |
|
|
133
|
+
| `disableEdit` | `(item: T) => boolean` | — | Per-row predicate: disable the edit button when it returns `true` |
|
|
134
|
+
| `disableDelete` | `(item: T) => boolean` | — | Per-row predicate: disable the delete button when it returns `true` |
|
|
132
135
|
|
|
133
136
|
## Events
|
|
134
137
|
|
|
@@ -28,6 +28,9 @@ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>
|
|
|
28
28
|
viewIcon?: string;
|
|
29
29
|
editIcon?: string;
|
|
30
30
|
deleteIcon?: string;
|
|
31
|
+
disableView?: (item: T) => boolean;
|
|
32
|
+
disableEdit?: (item: T) => boolean;
|
|
33
|
+
disableDelete?: (item: T) => boolean;
|
|
31
34
|
} & Partial<{}>> & import("vue").PublicProps;
|
|
32
35
|
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
33
36
|
attrs: any;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as U, computed as M, resolveComponent as w, openBlock as g, createBlock as y, withCtx as n, createVNode as r, createTextVNode as T, toDisplayString as P, renderSlot as h, createCommentVNode as j, inject as _, ref as V, onMounted as ee, watch as O, createElementBlock as te, Fragment as oe, normalizeClass as ne, createSlots as ae, createElementVNode as le, mergeProps as E, resolveDynamicComponent as A, renderList as ie } from "vue";
|
|
2
2
|
function se(e) {
|
|
3
3
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
4
4
|
}
|
|
5
|
-
var z = { exports: {} },
|
|
6
|
-
function
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
function e(
|
|
10
|
-
if (typeof
|
|
11
|
-
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof
|
|
12
|
-
if (
|
|
5
|
+
var z = { exports: {} }, q;
|
|
6
|
+
function de() {
|
|
7
|
+
if (q) return z.exports;
|
|
8
|
+
q = 1;
|
|
9
|
+
function e(p, s = 100, m = {}) {
|
|
10
|
+
if (typeof p != "function")
|
|
11
|
+
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof p}\`.`);
|
|
12
|
+
if (s < 0)
|
|
13
13
|
throw new RangeError("`wait` must not be negative.");
|
|
14
|
-
const { immediate:
|
|
15
|
-
let f,
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
return f = void 0,
|
|
14
|
+
const { immediate: d } = typeof m == "boolean" ? { immediate: m } : m;
|
|
15
|
+
let f, B, a, k, v;
|
|
16
|
+
function c() {
|
|
17
|
+
const b = f, D = B;
|
|
18
|
+
return f = void 0, B = void 0, v = p.apply(b, D), v;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
|
|
20
|
+
function C() {
|
|
21
|
+
const b = Date.now() - k;
|
|
22
|
+
b < s && b >= 0 ? a = setTimeout(C, s - b) : (a = void 0, d || (v = c()));
|
|
23
23
|
}
|
|
24
|
-
const l = function(...
|
|
24
|
+
const l = function(...b) {
|
|
25
25
|
if (f && this !== f && Object.getPrototypeOf(this) === Object.getPrototypeOf(f))
|
|
26
26
|
throw new Error("Debounced method called with different contexts of the same prototype.");
|
|
27
|
-
f = this,
|
|
28
|
-
const
|
|
29
|
-
return a || (a = setTimeout(
|
|
27
|
+
f = this, B = b, k = Date.now();
|
|
28
|
+
const D = d && !a;
|
|
29
|
+
return a || (a = setTimeout(C, s)), D && (v = c()), v;
|
|
30
30
|
};
|
|
31
31
|
return Object.defineProperty(l, "isPending", {
|
|
32
32
|
get() {
|
|
@@ -37,13 +37,13 @@ function ie() {
|
|
|
37
37
|
}, l.flush = () => {
|
|
38
38
|
a && l.trigger();
|
|
39
39
|
}, l.trigger = () => {
|
|
40
|
-
v =
|
|
40
|
+
v = c(), l.clear();
|
|
41
41
|
}, l;
|
|
42
42
|
}
|
|
43
43
|
return z.exports.debounce = e, z.exports = e, z.exports;
|
|
44
44
|
}
|
|
45
|
-
var re = /* @__PURE__ */
|
|
46
|
-
const ce = /* @__PURE__ */ se(re),
|
|
45
|
+
var re = /* @__PURE__ */ de();
|
|
46
|
+
const ce = /* @__PURE__ */ se(re), ue = /* @__PURE__ */ U({
|
|
47
47
|
__name: "ConfirmationModal",
|
|
48
48
|
props: {
|
|
49
49
|
show: Boolean,
|
|
@@ -54,65 +54,65 @@ const ce = /* @__PURE__ */ se(re), de = /* @__PURE__ */ q({
|
|
|
54
54
|
},
|
|
55
55
|
emits: ["close", "confirm"],
|
|
56
56
|
setup(e) {
|
|
57
|
-
const
|
|
58
|
-
get: () =>
|
|
57
|
+
const p = e, s = M({
|
|
58
|
+
get: () => p.show,
|
|
59
59
|
set: () => {
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
return (m,
|
|
63
|
-
const f =
|
|
64
|
-
return
|
|
65
|
-
modelValue:
|
|
66
|
-
"onUpdate:modelValue":
|
|
62
|
+
return (m, d) => {
|
|
63
|
+
const f = w("v-card-title"), B = w("v-card-text"), a = w("v-spacer"), k = w("v-btn"), v = w("v-card-actions"), c = w("v-card"), C = w("v-dialog");
|
|
64
|
+
return g(), y(C, {
|
|
65
|
+
modelValue: s.value,
|
|
66
|
+
"onUpdate:modelValue": d[2] || (d[2] = (l) => s.value = l),
|
|
67
67
|
"max-width": "500px",
|
|
68
68
|
persistent: "",
|
|
69
69
|
"no-click-animation": ""
|
|
70
70
|
}, {
|
|
71
|
-
default:
|
|
72
|
-
c
|
|
73
|
-
default:
|
|
74
|
-
|
|
75
|
-
default:
|
|
76
|
-
|
|
71
|
+
default: n(() => [
|
|
72
|
+
r(c, null, {
|
|
73
|
+
default: n(() => [
|
|
74
|
+
r(f, { class: "text-h5 text-center py-6" }, {
|
|
75
|
+
default: n(() => [
|
|
76
|
+
T(P(e.title), 1)
|
|
77
77
|
]),
|
|
78
78
|
_: 1
|
|
79
79
|
}),
|
|
80
|
-
e.description ? (
|
|
80
|
+
e.description ? (g(), y(B, {
|
|
81
81
|
key: 0,
|
|
82
82
|
class: "text-center px-0 py-0"
|
|
83
83
|
}, {
|
|
84
|
-
default:
|
|
85
|
-
|
|
84
|
+
default: n(() => [
|
|
85
|
+
T(P(e.description) + " ", 1),
|
|
86
86
|
h(m.$slots, "description")
|
|
87
87
|
]),
|
|
88
88
|
_: 3
|
|
89
89
|
})) : j("", !0),
|
|
90
|
-
|
|
91
|
-
default:
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
r(v, null, {
|
|
91
|
+
default: n(() => [
|
|
92
|
+
r(a),
|
|
93
|
+
r(k, {
|
|
94
94
|
color: "error",
|
|
95
95
|
variant: "flat",
|
|
96
96
|
dark: "",
|
|
97
|
-
onClick:
|
|
97
|
+
onClick: d[0] || (d[0] = (l) => m.$emit("close"))
|
|
98
98
|
}, {
|
|
99
|
-
default:
|
|
100
|
-
|
|
99
|
+
default: n(() => [
|
|
100
|
+
T(P(e.cancelButtonText), 1)
|
|
101
101
|
]),
|
|
102
102
|
_: 1
|
|
103
103
|
}),
|
|
104
|
-
|
|
104
|
+
r(k, {
|
|
105
105
|
color: "success",
|
|
106
106
|
variant: "flat",
|
|
107
107
|
dark: "",
|
|
108
|
-
onClick:
|
|
108
|
+
onClick: d[1] || (d[1] = (l) => m.$emit("confirm"))
|
|
109
109
|
}, {
|
|
110
|
-
default:
|
|
111
|
-
|
|
110
|
+
default: n(() => [
|
|
111
|
+
T(P(e.confirmButtonText), 1)
|
|
112
112
|
]),
|
|
113
113
|
_: 1
|
|
114
114
|
}),
|
|
115
|
-
|
|
115
|
+
r(a)
|
|
116
116
|
]),
|
|
117
117
|
_: 1
|
|
118
118
|
})
|
|
@@ -124,15 +124,15 @@ const ce = /* @__PURE__ */ se(re), de = /* @__PURE__ */ q({
|
|
|
124
124
|
}, 8, ["modelValue"]);
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
}),
|
|
127
|
+
}), R = Symbol("DataTableConfig");
|
|
128
128
|
function ve(e) {
|
|
129
129
|
return {
|
|
130
|
-
install(
|
|
131
|
-
|
|
130
|
+
install(p) {
|
|
131
|
+
p.provide(R, e);
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
const
|
|
135
|
+
const me = /* @__PURE__ */ U({
|
|
136
136
|
__name: "DataTable",
|
|
137
137
|
props: {
|
|
138
138
|
tableClass: { default: "border rounded-md mt-5" },
|
|
@@ -156,120 +156,123 @@ const ue = /* @__PURE__ */ q({
|
|
|
156
156
|
editButtonText: {},
|
|
157
157
|
viewIcon: {},
|
|
158
158
|
editIcon: {},
|
|
159
|
-
deleteIcon: {}
|
|
159
|
+
deleteIcon: {},
|
|
160
|
+
disableView: {},
|
|
161
|
+
disableEdit: {},
|
|
162
|
+
disableDelete: {}
|
|
160
163
|
},
|
|
161
164
|
emits: ["onLoadData", "editItem", "deleteItem", "viewItem"],
|
|
162
|
-
setup(e, { emit:
|
|
163
|
-
const
|
|
165
|
+
setup(e, { emit: p }) {
|
|
166
|
+
const s = e, m = p, d = _(R, { icons: {} }), f = M(() => {
|
|
164
167
|
var t;
|
|
165
|
-
return
|
|
166
|
-
}),
|
|
168
|
+
return s.viewIcon ?? ((t = d.icons) == null ? void 0 : t.view) ?? "mdi-eye-outline";
|
|
169
|
+
}), B = M(() => {
|
|
167
170
|
var t;
|
|
168
|
-
return
|
|
171
|
+
return s.editIcon ?? ((t = d.icons) == null ? void 0 : t.edit) ?? "mdi-pencil-outline";
|
|
169
172
|
}), a = M(() => {
|
|
170
173
|
var t;
|
|
171
|
-
return
|
|
172
|
-
}),
|
|
174
|
+
return s.deleteIcon ?? ((t = d.icons) == null ? void 0 : t.delete) ?? "mdi-trash-can-outline";
|
|
175
|
+
}), k = M(() => d.iconProps ?? {});
|
|
173
176
|
function v(t) {
|
|
174
177
|
return typeof t != "string";
|
|
175
178
|
}
|
|
176
|
-
const
|
|
179
|
+
const c = V(s.itemsPerPage), C = V([]), l = V(1), b = V(null), D = V(!1), G = M(() => {
|
|
177
180
|
var t;
|
|
178
|
-
return ((t =
|
|
179
|
-
(
|
|
181
|
+
return ((t = s.headers) == null ? void 0 : t.filter(
|
|
182
|
+
(i) => i.key !== "actions" && i.key !== "expanded-row" && i.key !== "data-table-expand"
|
|
180
183
|
)) || [];
|
|
181
184
|
});
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
ee(() => {
|
|
186
|
+
S({
|
|
184
187
|
page: l.value,
|
|
185
|
-
itemsPerPage:
|
|
188
|
+
itemsPerPage: c.value
|
|
186
189
|
});
|
|
187
190
|
});
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
},
|
|
191
|
+
const K = (t) => {
|
|
192
|
+
b.value = t, D.value = !0;
|
|
193
|
+
}, Y = () => {
|
|
194
|
+
b.value = null, D.value = !1;
|
|
195
|
+
}, H = (t) => {
|
|
193
196
|
m("editItem", t);
|
|
194
|
-
},
|
|
197
|
+
}, J = (t) => {
|
|
195
198
|
m("viewItem", t);
|
|
196
|
-
},
|
|
197
|
-
m("deleteItem",
|
|
198
|
-
},
|
|
199
|
-
const
|
|
200
|
-
column:
|
|
201
|
-
direction:
|
|
199
|
+
}, Q = () => {
|
|
200
|
+
m("deleteItem", b.value), D.value = !1;
|
|
201
|
+
}, S = ({ page: t, itemsPerPage: i }) => {
|
|
202
|
+
const $ = C.value.map((I) => ({
|
|
203
|
+
column: I.key,
|
|
204
|
+
direction: I.order
|
|
202
205
|
}));
|
|
203
206
|
m("onLoadData", {
|
|
204
207
|
page: t,
|
|
205
|
-
itemsPerPage:
|
|
206
|
-
search:
|
|
207
|
-
sortBy:
|
|
208
|
+
itemsPerPage: i,
|
|
209
|
+
search: s.search,
|
|
210
|
+
sortBy: $
|
|
208
211
|
});
|
|
209
212
|
};
|
|
210
|
-
function
|
|
211
|
-
|
|
213
|
+
function W() {
|
|
214
|
+
S({
|
|
212
215
|
page: 1,
|
|
213
|
-
itemsPerPage:
|
|
216
|
+
itemsPerPage: c.value
|
|
214
217
|
});
|
|
215
218
|
}
|
|
216
|
-
const
|
|
217
|
-
|
|
219
|
+
const F = ce(W, 400), X = () => {
|
|
220
|
+
F();
|
|
218
221
|
};
|
|
219
222
|
return O(
|
|
220
|
-
() =>
|
|
221
|
-
(t,
|
|
222
|
-
t !==
|
|
223
|
+
() => s.search,
|
|
224
|
+
(t, i) => {
|
|
225
|
+
t !== i && F();
|
|
223
226
|
}
|
|
224
|
-
), O(
|
|
225
|
-
t !==
|
|
227
|
+
), O(c, (t, i) => {
|
|
228
|
+
t !== i && S({
|
|
226
229
|
page: 1,
|
|
227
230
|
itemsPerPage: t
|
|
228
231
|
});
|
|
229
|
-
}), O(
|
|
230
|
-
|
|
232
|
+
}), O(C, () => {
|
|
233
|
+
S({
|
|
231
234
|
page: 1,
|
|
232
|
-
itemsPerPage:
|
|
235
|
+
itemsPerPage: c.value
|
|
233
236
|
});
|
|
234
237
|
}), O(l, (t) => {
|
|
235
|
-
|
|
238
|
+
S({
|
|
236
239
|
page: t,
|
|
237
|
-
itemsPerPage:
|
|
240
|
+
itemsPerPage: c.value
|
|
238
241
|
});
|
|
239
|
-
}), (t,
|
|
240
|
-
const
|
|
241
|
-
return
|
|
242
|
-
|
|
242
|
+
}), (t, i) => {
|
|
243
|
+
const $ = w("v-icon"), I = w("v-btn"), L = w("v-tooltip"), Z = w("v-data-table-server");
|
|
244
|
+
return g(), te(oe, null, [
|
|
245
|
+
r(Z, {
|
|
243
246
|
headers: e.headers,
|
|
244
247
|
items: e.items,
|
|
245
248
|
loading: e.loading,
|
|
246
249
|
"items-length": e.totalItems,
|
|
247
|
-
"items-per-page":
|
|
248
|
-
"onUpdate:itemsPerPage":
|
|
250
|
+
"items-per-page": c.value,
|
|
251
|
+
"onUpdate:itemsPerPage": i[0] || (i[0] = (o) => c.value = o),
|
|
249
252
|
search: e.search,
|
|
250
|
-
onSearch:
|
|
251
|
-
"sort-by":
|
|
252
|
-
"onUpdate:sortBy":
|
|
253
|
+
onSearch: X,
|
|
254
|
+
"sort-by": C.value,
|
|
255
|
+
"onUpdate:sortBy": i[1] || (i[1] = (o) => C.value = o),
|
|
253
256
|
page: l.value,
|
|
254
|
-
"onUpdate:page":
|
|
257
|
+
"onUpdate:page": i[2] || (i[2] = (o) => l.value = o),
|
|
255
258
|
"item-value": e.itemValue,
|
|
256
259
|
"show-expand": e.showExpand,
|
|
257
|
-
class:
|
|
258
|
-
},
|
|
259
|
-
"item.data-table-expand":
|
|
260
|
+
class: ne(e.tableClass)
|
|
261
|
+
}, ae({
|
|
262
|
+
"item.data-table-expand": n(({ internalItem: o, isExpanded: u, toggleExpand: x }) => [
|
|
260
263
|
h(t.$slots, "item.data-table-expand", {
|
|
261
|
-
internalItem:
|
|
264
|
+
internalItem: o,
|
|
262
265
|
isExpanded: u,
|
|
263
|
-
toggleExpand:
|
|
266
|
+
toggleExpand: x
|
|
264
267
|
}, () => [
|
|
265
|
-
|
|
266
|
-
onClick: (
|
|
268
|
+
r(I, {
|
|
269
|
+
onClick: (N) => x(o),
|
|
267
270
|
rounded: ""
|
|
268
271
|
}, {
|
|
269
|
-
default:
|
|
270
|
-
|
|
271
|
-
default:
|
|
272
|
-
|
|
272
|
+
default: n(() => [
|
|
273
|
+
r($, null, {
|
|
274
|
+
default: n(() => [
|
|
275
|
+
T(P(u(o) ? "mdi-chevron-up" : "mdi-chevron-down"), 1)
|
|
273
276
|
]),
|
|
274
277
|
_: 2
|
|
275
278
|
}, 1024)
|
|
@@ -278,151 +281,166 @@ const ue = /* @__PURE__ */ q({
|
|
|
278
281
|
}, 1032, ["onClick"])
|
|
279
282
|
])
|
|
280
283
|
]),
|
|
281
|
-
"expanded-row":
|
|
284
|
+
"expanded-row": n(({ columns: o, item: u }) => [
|
|
282
285
|
h(t.$slots, "expanded-row", {
|
|
283
|
-
columns:
|
|
286
|
+
columns: o,
|
|
284
287
|
item: u
|
|
285
288
|
})
|
|
286
289
|
]),
|
|
287
|
-
"item.actions":
|
|
288
|
-
h(t.$slots, "before-actions", { item:
|
|
289
|
-
e.showViewButton ? (
|
|
290
|
+
"item.actions": n(({ item: o }) => [
|
|
291
|
+
h(t.$slots, "before-actions", { item: o }),
|
|
292
|
+
e.showViewButton ? (g(), y(L, {
|
|
290
293
|
key: 0,
|
|
291
294
|
text: e.viewButtonText
|
|
292
295
|
}, {
|
|
293
|
-
activator:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
296
|
+
activator: n(({ props: u }) => {
|
|
297
|
+
var x;
|
|
298
|
+
return [
|
|
299
|
+
r(I, E({
|
|
300
|
+
icon: "",
|
|
301
|
+
flat: "",
|
|
302
|
+
onClick: (N) => J(o)
|
|
303
|
+
}, u, {
|
|
304
|
+
disabled: (x = e.disableView) == null ? void 0 : x.call(e, o)
|
|
305
|
+
}), {
|
|
306
|
+
default: n(() => [
|
|
307
|
+
h(t.$slots, "view-icon", {}, () => [
|
|
308
|
+
v(f.value) ? (g(), y(A(f.value), E({
|
|
309
|
+
key: 0,
|
|
310
|
+
size: 20,
|
|
311
|
+
class: "text-info"
|
|
312
|
+
}, k.value), null, 16)) : (g(), y($, {
|
|
313
|
+
key: 1,
|
|
314
|
+
size: "20",
|
|
315
|
+
class: "text-info"
|
|
316
|
+
}, {
|
|
317
|
+
default: n(() => [
|
|
318
|
+
T(P(f.value), 1)
|
|
319
|
+
]),
|
|
320
|
+
_: 1
|
|
321
|
+
}))
|
|
322
|
+
])
|
|
323
|
+
]),
|
|
324
|
+
_: 3
|
|
325
|
+
}, 16, ["onClick", "disabled"])
|
|
326
|
+
];
|
|
327
|
+
}),
|
|
320
328
|
_: 2
|
|
321
329
|
}, 1032, ["text"])) : j("", !0),
|
|
322
|
-
e.showEditButton ? (
|
|
330
|
+
e.showEditButton ? (g(), y(L, {
|
|
323
331
|
key: 1,
|
|
324
332
|
text: e.editButtonText
|
|
325
333
|
}, {
|
|
326
|
-
activator:
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
334
|
+
activator: n(({ props: u }) => {
|
|
335
|
+
var x;
|
|
336
|
+
return [
|
|
337
|
+
r(I, E({
|
|
338
|
+
icon: "",
|
|
339
|
+
flat: "",
|
|
340
|
+
onClick: (N) => H(o)
|
|
341
|
+
}, u, {
|
|
342
|
+
disabled: (x = e.disableEdit) == null ? void 0 : x.call(e, o)
|
|
343
|
+
}), {
|
|
344
|
+
default: n(() => [
|
|
345
|
+
h(t.$slots, "edit-icon", {}, () => [
|
|
346
|
+
v(B.value) ? (g(), y(A(B.value), E({
|
|
347
|
+
key: 0,
|
|
348
|
+
size: 20,
|
|
349
|
+
class: "text-primary"
|
|
350
|
+
}, k.value), null, 16)) : (g(), y($, {
|
|
351
|
+
key: 1,
|
|
352
|
+
size: "20",
|
|
353
|
+
class: "text-primary"
|
|
354
|
+
}, {
|
|
355
|
+
default: n(() => [
|
|
356
|
+
T(P(B.value), 1)
|
|
357
|
+
]),
|
|
358
|
+
_: 1
|
|
359
|
+
}))
|
|
360
|
+
])
|
|
361
|
+
]),
|
|
362
|
+
_: 3
|
|
363
|
+
}, 16, ["onClick", "disabled"])
|
|
364
|
+
];
|
|
365
|
+
}),
|
|
353
366
|
_: 2
|
|
354
367
|
}, 1032, ["text"])) : j("", !0),
|
|
355
|
-
e.showDeleteButton ? (
|
|
368
|
+
e.showDeleteButton ? (g(), y(L, {
|
|
356
369
|
key: 2,
|
|
357
370
|
text: e.deleteButtonText
|
|
358
371
|
}, {
|
|
359
|
-
activator:
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
372
|
+
activator: n(({ props: u }) => {
|
|
373
|
+
var x;
|
|
374
|
+
return [
|
|
375
|
+
r(I, E({
|
|
376
|
+
icon: "",
|
|
377
|
+
flat: "",
|
|
378
|
+
onClick: (N) => K(o)
|
|
379
|
+
}, u, {
|
|
380
|
+
disabled: (x = e.disableDelete) == null ? void 0 : x.call(e, o)
|
|
381
|
+
}), {
|
|
382
|
+
default: n(() => [
|
|
383
|
+
h(t.$slots, "delete-icon", {}, () => [
|
|
384
|
+
v(a.value) ? (g(), y(A(a.value), E({
|
|
385
|
+
key: 0,
|
|
386
|
+
size: 20,
|
|
387
|
+
class: "text-error"
|
|
388
|
+
}, k.value), null, 16)) : (g(), y($, {
|
|
389
|
+
key: 1,
|
|
390
|
+
size: "20",
|
|
391
|
+
class: "text-error"
|
|
392
|
+
}, {
|
|
393
|
+
default: n(() => [
|
|
394
|
+
T(P(a.value), 1)
|
|
395
|
+
]),
|
|
396
|
+
_: 1
|
|
397
|
+
}))
|
|
398
|
+
])
|
|
399
|
+
]),
|
|
400
|
+
_: 3
|
|
401
|
+
}, 16, ["onClick", "disabled"])
|
|
402
|
+
];
|
|
403
|
+
}),
|
|
386
404
|
_: 2
|
|
387
405
|
}, 1032, ["text"])) : j("", !0),
|
|
388
|
-
h(t.$slots, "after-actions", { item:
|
|
406
|
+
h(t.$slots, "after-actions", { item: o })
|
|
389
407
|
]),
|
|
390
|
-
tfoot:
|
|
391
|
-
|
|
408
|
+
tfoot: n(() => [
|
|
409
|
+
le("tfoot", null, [
|
|
392
410
|
h(t.$slots, "item.tfoot")
|
|
393
411
|
])
|
|
394
412
|
]),
|
|
395
413
|
_: 2
|
|
396
414
|
}, [
|
|
397
|
-
|
|
398
|
-
name: `item.${
|
|
399
|
-
fn:
|
|
400
|
-
h(t.$slots, `item.${
|
|
401
|
-
|
|
415
|
+
ie(G.value, (o) => ({
|
|
416
|
+
name: `item.${o.key}`,
|
|
417
|
+
fn: n(({ item: u }) => [
|
|
418
|
+
h(t.$slots, `item.${o.key}`, { item: u }, () => [
|
|
419
|
+
T(P(u[o.key]), 1)
|
|
402
420
|
])
|
|
403
421
|
])
|
|
404
422
|
}))
|
|
405
423
|
]), 1032, ["headers", "items", "loading", "items-length", "items-per-page", "search", "sort-by", "page", "item-value", "show-expand", "class"]),
|
|
406
|
-
|
|
407
|
-
show:
|
|
424
|
+
r(ue, {
|
|
425
|
+
show: D.value,
|
|
408
426
|
title: e.deleteModalTitle,
|
|
409
427
|
description: e.deleteModalMessage,
|
|
410
428
|
confirmButtonText: e.deleteModalConfirmButtonText,
|
|
411
429
|
cancelButtonText: e.deleteModalCancelButtonText,
|
|
412
|
-
onClose:
|
|
413
|
-
onConfirm:
|
|
430
|
+
onClose: Y,
|
|
431
|
+
onConfirm: Q
|
|
414
432
|
}, null, 8, ["show", "title", "description", "confirmButtonText", "cancelButtonText"])
|
|
415
433
|
], 64);
|
|
416
434
|
};
|
|
417
435
|
}
|
|
418
|
-
}),
|
|
436
|
+
}), ge = {
|
|
419
437
|
install(e) {
|
|
420
|
-
e.component("DataTable",
|
|
438
|
+
e.component("DataTable", me);
|
|
421
439
|
}
|
|
422
440
|
};
|
|
423
441
|
export {
|
|
424
|
-
|
|
425
|
-
|
|
442
|
+
R as DATA_TABLE_CONFIG_KEY,
|
|
443
|
+
me as DataTable,
|
|
426
444
|
ve as createDataTableConfig,
|
|
427
|
-
|
|
445
|
+
ge as default
|
|
428
446
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(C,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(C=typeof globalThis<"u"?globalThis:C||self,e(C.VuetifyDatatable={},C.Vue))})(this,(function(C,e){"use strict";function E(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var D={exports:{}},N;function M(){if(N)return D.exports;N=1;function t(h,r=100,m={}){if(typeof h!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof h}\`.`);if(r<0)throw new RangeError("`wait` must not be negative.");const{immediate:c}=typeof m=="boolean"?{immediate:m}:m;let f,u,a,w,p;function d(){const x=f,B=u;return f=void 0,u=void 0,p=h.apply(x,B),p}function y(){const x=Date.now()-w;x<r&&x>=0?a=setTimeout(y,r-x):(a=void 0,c||(p=d()))}const l=function(...x){if(f&&this!==f&&Object.getPrototypeOf(this)===Object.getPrototypeOf(f))throw new Error("Debounced method called with different contexts of the same prototype.");f=this,u=x,w=Date.now();const B=c&&!a;return a||(a=setTimeout(y,r)),B&&(p=d()),p};return Object.defineProperty(l,"isPending",{get(){return a!==void 0}}),l.clear=()=>{a&&(clearTimeout(a),a=void 0)},l.flush=()=>{a&&l.trigger()},l.trigger=()=>{p=d(),l.clear()},l}return D.exports.debounce=t,D.exports=t,D.exports}var O=M();const j=E(O),A=e.defineComponent({__name:"ConfirmationModal",props:{show:Boolean,title:String,description:String,confirmButtonText:String,cancelButtonText:String},emits:["close","confirm"],setup(t){const h=t,r=e.computed({get:()=>h.show,set:()=>{}});return(m,c)=>{const f=e.resolveComponent("v-card-title"),u=e.resolveComponent("v-card-text"),a=e.resolveComponent("v-spacer"),w=e.resolveComponent("v-btn"),p=e.resolveComponent("v-card-actions"),d=e.resolveComponent("v-card"),y=e.resolveComponent("v-dialog");return e.openBlock(),e.createBlock(y,{modelValue:r.value,"onUpdate:modelValue":c[2]||(c[2]=l=>r.value=l),"max-width":"500px",persistent:"","no-click-animation":""},{default:e.withCtx(()=>[e.createVNode(d,null,{default:e.withCtx(()=>[e.createVNode(f,{class:"text-h5 text-center py-6"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.title),1)]),_:1}),t.description?(e.openBlock(),e.createBlock(u,{key:0,class:"text-center px-0 py-0"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.description)+" ",1),e.renderSlot(m.$slots,"description")]),_:3})):e.createCommentVNode("",!0),e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(a),e.createVNode(w,{color:"error",variant:"flat",dark:"",onClick:c[0]||(c[0]=l=>m.$emit("close"))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.cancelButtonText),1)]),_:1}),e.createVNode(w,{color:"success",variant:"flat",dark:"",onClick:c[1]||(c[1]=l=>m.$emit("confirm"))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.confirmButtonText),1)]),_:1}),e.createVNode(a)]),_:1})]),_:3})]),_:3},8,["modelValue"])}}}),V=Symbol("DataTableConfig");function z(t){return{install(h){h.provide(V,t)}}}const I=e.defineComponent({__name:"DataTable",props:{tableClass:{default:"border rounded-md mt-5"},headers:{default:()=>[]},items:{default:()=>[]},loading:{type:Boolean,default:!1},itemValue:{default:"id"},totalItems:{default:0},itemsPerPage:{default:10},search:{},showExpand:{type:Boolean,default:!1},showEditButton:{type:Boolean,default:!0},showDeleteButton:{type:Boolean,default:!0},showViewButton:{type:Boolean,default:!1},viewButtonText:{},deleteButtonText:{},deleteModalTitle:{},deleteModalMessage:{},deleteModalConfirmButtonText:{},deleteModalCancelButtonText:{},editButtonText:{},viewIcon:{},editIcon:{},deleteIcon:{},disableView:{},disableEdit:{},disableDelete:{}},emits:["onLoadData","editItem","deleteItem","viewItem"],setup(t,{emit:h}){const r=t,m=h,c=e.inject(V,{icons:{}}),f=e.computed(()=>{var o;return r.viewIcon??((o=c.icons)==null?void 0:o.view)??"mdi-eye-outline"}),u=e.computed(()=>{var o;return r.editIcon??((o=c.icons)==null?void 0:o.edit)??"mdi-pencil-outline"}),a=e.computed(()=>{var o;return r.deleteIcon??((o=c.icons)==null?void 0:o.delete)??"mdi-trash-can-outline"}),w=e.computed(()=>c.iconProps??{});function p(o){return typeof o!="string"}const d=e.ref(r.itemsPerPage),y=e.ref([]),l=e.ref(1),x=e.ref(null),B=e.ref(!1),F=e.computed(()=>{var o;return((o=r.headers)==null?void 0:o.filter(i=>i.key!=="actions"&&i.key!=="expanded-row"&&i.key!=="data-table-expand"))||[]});e.onMounted(()=>{T({page:l.value,itemsPerPage:d.value})});const q=o=>{x.value=o,B.value=!0},U=()=>{x.value=null,B.value=!1},R=o=>{m("editItem",o)},G=o=>{m("viewItem",o)},K=()=>{m("deleteItem",x.value),B.value=!1},T=({page:o,itemsPerPage:i})=>{const k=y.value.map(b=>({column:b.key,direction:b.order}));m("onLoadData",{page:o,itemsPerPage:i,search:r.search,sortBy:k})};function Y(){T({page:1,itemsPerPage:d.value})}const $=j(Y,400),H=()=>{$()};return e.watch(()=>r.search,(o,i)=>{o!==i&&$()}),e.watch(d,(o,i)=>{o!==i&&T({page:1,itemsPerPage:o})}),e.watch(y,()=>{T({page:1,itemsPerPage:d.value})}),e.watch(l,o=>{T({page:o,itemsPerPage:d.value})}),(o,i)=>{const k=e.resolveComponent("v-icon"),b=e.resolveComponent("v-btn"),P=e.resolveComponent("v-tooltip"),J=e.resolveComponent("v-data-table-server");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(J,{headers:t.headers,items:t.items,loading:t.loading,"items-length":t.totalItems,"items-per-page":d.value,"onUpdate:itemsPerPage":i[0]||(i[0]=n=>d.value=n),search:t.search,onSearch:H,"sort-by":y.value,"onUpdate:sortBy":i[1]||(i[1]=n=>y.value=n),page:l.value,"onUpdate:page":i[2]||(i[2]=n=>l.value=n),"item-value":t.itemValue,"show-expand":t.showExpand,class:e.normalizeClass(t.tableClass)},e.createSlots({"item.data-table-expand":e.withCtx(({internalItem:n,isExpanded:s,toggleExpand:g})=>[e.renderSlot(o.$slots,"item.data-table-expand",{internalItem:n,isExpanded:s,toggleExpand:g},()=>[e.createVNode(b,{onClick:S=>g(n),rounded:""},{default:e.withCtx(()=>[e.createVNode(k,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s(n)?"mdi-chevron-up":"mdi-chevron-down"),1)]),_:2},1024)]),_:2},1032,["onClick"])])]),"expanded-row":e.withCtx(({columns:n,item:s})=>[e.renderSlot(o.$slots,"expanded-row",{columns:n,item:s})]),"item.actions":e.withCtx(({item:n})=>[e.renderSlot(o.$slots,"before-actions",{item:n}),t.showViewButton?(e.openBlock(),e.createBlock(P,{key:0,text:t.viewButtonText},{activator:e.withCtx(({props:s})=>{var g;return[e.createVNode(b,e.mergeProps({icon:"",flat:"",onClick:S=>G(n)},s,{disabled:(g=t.disableView)==null?void 0:g.call(t,n)}),{default:e.withCtx(()=>[e.renderSlot(o.$slots,"view-icon",{},()=>[p(f.value)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.value),e.mergeProps({key:0,size:20,class:"text-info"},w.value),null,16)):(e.openBlock(),e.createBlock(k,{key:1,size:"20",class:"text-info"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(f.value),1)]),_:1}))])]),_:3},16,["onClick","disabled"])]}),_:2},1032,["text"])):e.createCommentVNode("",!0),t.showEditButton?(e.openBlock(),e.createBlock(P,{key:1,text:t.editButtonText},{activator:e.withCtx(({props:s})=>{var g;return[e.createVNode(b,e.mergeProps({icon:"",flat:"",onClick:S=>R(n)},s,{disabled:(g=t.disableEdit)==null?void 0:g.call(t,n)}),{default:e.withCtx(()=>[e.renderSlot(o.$slots,"edit-icon",{},()=>[p(u.value)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.value),e.mergeProps({key:0,size:20,class:"text-primary"},w.value),null,16)):(e.openBlock(),e.createBlock(k,{key:1,size:"20",class:"text-primary"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.value),1)]),_:1}))])]),_:3},16,["onClick","disabled"])]}),_:2},1032,["text"])):e.createCommentVNode("",!0),t.showDeleteButton?(e.openBlock(),e.createBlock(P,{key:2,text:t.deleteButtonText},{activator:e.withCtx(({props:s})=>{var g;return[e.createVNode(b,e.mergeProps({icon:"",flat:"",onClick:S=>q(n)},s,{disabled:(g=t.disableDelete)==null?void 0:g.call(t,n)}),{default:e.withCtx(()=>[e.renderSlot(o.$slots,"delete-icon",{},()=>[p(a.value)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),e.mergeProps({key:0,size:20,class:"text-error"},w.value),null,16)):(e.openBlock(),e.createBlock(k,{key:1,size:"20",class:"text-error"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value),1)]),_:1}))])]),_:3},16,["onClick","disabled"])]}),_:2},1032,["text"])):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"after-actions",{item:n})]),tfoot:e.withCtx(()=>[e.createElementVNode("tfoot",null,[e.renderSlot(o.$slots,"item.tfoot")])]),_:2},[e.renderList(F.value,n=>({name:`item.${n.key}`,fn:e.withCtx(({item:s})=>[e.renderSlot(o.$slots,`item.${n.key}`,{item:s},()=>[e.createTextVNode(e.toDisplayString(s[n.key]),1)])])}))]),1032,["headers","items","loading","items-length","items-per-page","search","sort-by","page","item-value","show-expand","class"]),e.createVNode(A,{show:B.value,title:t.deleteModalTitle,description:t.deleteModalMessage,confirmButtonText:t.deleteModalConfirmButtonText,cancelButtonText:t.deleteModalCancelButtonText,onClose:U,onConfirm:K},null,8,["show","title","description","confirmButtonText","cancelButtonText"])],64)}}}),L={install(t){t.component("DataTable",I)}};C.DATA_TABLE_CONFIG_KEY=V,C.DataTable=I,C.createDataTableConfig=z,C.default=L,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|