vs-datatable 0.5.0 → 0.6.0

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,49 +1,56 @@
1
- import { defineComponent as L, computed as C, createElementBlock as g, openBlock as f, createElementVNode as n, createCommentVNode as R, Fragment as A, renderList as B, normalizeClass as S, toDisplayString as p, unref as c, ref as H, watch as F, useAttrs as W, onMounted as X, onUnmounted as Y, onBeforeMount as q, createVNode as z, renderSlot as K, isRef as N, normalizeStyle as ee, withModifiers as te, createTextVNode as se } from "vue";
2
- import './index.css';function E(e, l) {
3
- return l.split(".").reduce((s, t) => s?.[t], e) ?? "";
1
+ import { defineComponent as K, computed as C, createElementBlock as f, openBlock as b, createElementVNode as n, createCommentVNode as x, Fragment as M, renderList as B, normalizeClass as V, toDisplayString as P, unref as d, ref as L, watch as F, useAttrs as W, onMounted as X, onUnmounted as Y, onBeforeMount as q, createVNode as z, renderSlot as A, isRef as N, normalizeStyle as ee, withModifiers as te, createTextVNode as se } from "vue";
2
+ import './index.css';function E(e, s) {
3
+ return s.split(".").reduce((l, t) => l?.[t], e) ?? "";
4
4
  }
5
- function k(e, l, s = "id") {
6
- return typeof s == "function" ? s(e, l) : e[s] || l;
5
+ function k(e, s, l = "id") {
6
+ return typeof l == "function" ? l(e, s) : e[l] || s;
7
7
  }
8
- function Z(e, l, s = "id") {
9
- return l.some(
10
- (t) => k(t, -1, s) === k(e, -1, s)
8
+ function Z(e, s, l = "id") {
9
+ return s.some(
10
+ (t) => k(t, -1, l) === k(e, -1, l)
11
11
  );
12
12
  }
13
- function le(e, l) {
14
- return e.length + (l ? 1 : 0);
13
+ function le(e, s) {
14
+ return e.length + (s ? 1 : 0);
15
15
  }
16
- function ae(e, l) {
17
- if (!l.length) return e;
18
- const s = (t, i) => i.split(".").reduce((r, o) => r?.[o], t) ?? "";
19
- return [...e].sort((t, i) => {
20
- for (const { field: r, order: o } of l) {
21
- const h = s(t, r), v = s(i, r);
22
- if (h !== v)
23
- return o === "asc" ? h > v ? 1 : -1 : h < v ? 1 : -1;
16
+ function ae(e, s) {
17
+ if (!s.length) return e;
18
+ const l = (t, r) => r.split(".").reduce((a, c) => a?.[c], t) ?? "";
19
+ return [...e].sort((t, r) => {
20
+ for (const { field: a, order: c } of s) {
21
+ const i = l(t, a), g = l(r, a);
22
+ if (i !== g)
23
+ return c === "asc" ? i > g ? 1 : -1 : i < g ? 1 : -1;
24
24
  }
25
25
  return 0;
26
26
  });
27
27
  }
28
- function oe(e, l, s) {
29
- if (!s) return e;
30
- const t = (l - 1) * s, i = t + s;
31
- return e.slice(t, i);
28
+ function oe(e, s, l) {
29
+ if (!l) return e;
30
+ const t = (s - 1) * l, r = t + l;
31
+ return e.slice(t, r);
32
32
  }
33
- function ne(e, l, s) {
34
- const t = (e - 1) * l + 1, i = Math.min(e * l, s);
35
- return { start: t, end: i };
33
+ function ne(e, s, l) {
34
+ const t = (e - 1) * s + 1, r = Math.min(e * s, l);
35
+ return { start: t, end: r };
36
36
  }
37
- function j(e, l) {
38
- return Math.ceil(e / l);
37
+ function Q(e, s) {
38
+ return Math.ceil(e / s);
39
39
  }
40
- const re = ["id"], ce = ["disabled"], de = {
40
+ function re(e, s, l) {
41
+ if (!s || s.trim() === "") return e;
42
+ const t = s.toLowerCase();
43
+ return e.filter((r) => Object.values(r).some(
44
+ (a) => String(a ?? "").toLowerCase().includes(t)
45
+ ));
46
+ }
47
+ const de = ["id"], ce = ["disabled"], ie = {
41
48
  key: 1,
42
49
  class: "vs-pagination-ellipsis"
43
- }, ie = ["id", "onClick"], ue = {
50
+ }, ue = ["id", "onClick"], ve = {
44
51
  key: 2,
45
52
  class: "vs-pagination-ellipsis"
46
- }, ve = ["disabled"], he = /* @__PURE__ */ L({
53
+ }, he = ["disabled"], ge = /* @__PURE__ */ K({
47
54
  __name: "VsPagination",
48
55
  props: {
49
56
  modelValue: {},
@@ -54,85 +61,85 @@ const re = ["id"], ce = ["disabled"], de = {
54
61
  paginationClass: {}
55
62
  },
56
63
  emits: ["update:modelValue", "page-changed"],
57
- setup(e, { emit: l }) {
58
- const s = e, t = l, i = s.maxVisible ?? 3, r = C({
59
- get: () => s.modelValue,
60
- set: (d) => {
61
- t("update:modelValue", d), t("page-changed", d);
64
+ setup(e, { emit: s }) {
65
+ const l = e, t = s, r = l.maxVisible ?? 3, a = C({
66
+ get: () => l.modelValue,
67
+ set: (m) => {
68
+ t("update:modelValue", m), t("page-changed", m);
62
69
  }
63
- }), o = C(() => r.value <= Math.floor(i / 2) ? 1 : r.value >= v.value - Math.floor(i / 2) ? Math.max(v.value - i + 1, 1) : r.value - Math.floor(i / 2)), h = C(() => Math.min(o.value + i - 1, v.value)), v = C(() => j(s.totalRecords, s.rowsPerPage)), y = C(() => {
64
- const d = [];
65
- for (let m = o.value; m <= h.value; m++)
66
- d.push(m);
67
- return d;
68
- }), T = (d) => {
69
- d >= 1 && d <= v.value && (r.value = d);
70
- }, M = () => {
71
- r.value > 1 && r.value--;
70
+ }), c = C(() => a.value <= Math.floor(r / 2) ? 1 : a.value >= g.value - Math.floor(r / 2) ? Math.max(g.value - r + 1, 1) : a.value - Math.floor(r / 2)), i = C(() => Math.min(c.value + r - 1, g.value)), g = C(() => Q(l.totalRecords, l.rowsPerPage)), S = C(() => {
71
+ const m = [];
72
+ for (let u = c.value; u <= i.value; u++)
73
+ m.push(u);
74
+ return m;
75
+ }), y = (m) => {
76
+ m >= 1 && m <= g.value && (a.value = m);
77
+ }, O = () => {
78
+ a.value > 1 && a.value--;
72
79
  }, D = () => {
73
- r.value < v.value && r.value++;
80
+ a.value < g.value && a.value++;
74
81
  };
75
- return (d, m) => (f(), g("div", {
82
+ return (m, u) => (b(), f("div", {
76
83
  class: "vs-pagination",
77
84
  id: e.tablename + "-pagination"
78
85
  }, [
79
86
  n("button", {
80
- onClick: M,
87
+ onClick: O,
81
88
  type: "button",
82
89
  class: "vs-pagination-button vs-pagination-nav",
83
- disabled: r.value === 1
90
+ disabled: a.value === 1
84
91
  }, " ‹‹ ", 8, ce),
85
- o.value > 1 ? (f(), g("button", {
92
+ c.value > 1 ? (b(), f("button", {
86
93
  key: 0,
87
94
  type: "button",
88
95
  class: "vs-pagination-button",
89
- onClick: m[0] || (m[0] = (a) => T(1))
90
- }, " 1 ")) : R("", !0),
91
- o.value > 2 ? (f(), g("span", de, "...")) : R("", !0),
92
- (f(!0), g(A, null, B(y.value, (a) => (f(), g("button", {
93
- key: a,
96
+ onClick: u[0] || (u[0] = (o) => y(1))
97
+ }, " 1 ")) : x("", !0),
98
+ c.value > 2 ? (b(), f("span", ie, "...")) : x("", !0),
99
+ (b(!0), f(M, null, B(S.value, (o) => (b(), f("button", {
100
+ key: o,
94
101
  type: "button",
95
- class: S([
102
+ class: V([
96
103
  "vs-pagination-button",
97
- { "vs-active": r.value === a }
104
+ { "vs-active": a.value === o }
98
105
  ]),
99
- id: e.tablename + "-page-" + a,
100
- onClick: (b) => T(a)
101
- }, p(a), 11, ie))), 128)),
102
- h.value < v.value - 1 ? (f(), g("span", ue, "...")) : R("", !0),
103
- h.value < v.value ? (f(), g("button", {
106
+ id: e.tablename + "-page-" + o,
107
+ onClick: (v) => y(o)
108
+ }, P(o), 11, ue))), 128)),
109
+ i.value < g.value - 1 ? (b(), f("span", ve, "...")) : x("", !0),
110
+ i.value < g.value ? (b(), f("button", {
104
111
  key: 3,
105
112
  type: "button",
106
113
  class: "vs-pagination-button",
107
- onClick: m[1] || (m[1] = (a) => T(v.value))
108
- }, p(v.value), 1)) : R("", !0),
114
+ onClick: u[1] || (u[1] = (o) => y(g.value))
115
+ }, P(g.value), 1)) : x("", !0),
109
116
  n("button", {
110
117
  onClick: D,
111
118
  type: "button",
112
119
  class: "vs-pagination-button vs-pagination-nav",
113
- disabled: r.value === v.value
114
- }, " ›› ", 8, ve)
115
- ], 8, re));
120
+ disabled: a.value === g.value
121
+ }, " ›› ", 8, he)
122
+ ], 8, de));
116
123
  }
117
- }), Q = (e, l) => {
118
- const s = e.__vccOpts || e;
119
- for (const [t, i] of l)
120
- s[t] = i;
121
- return s;
122
- }, ge = /* @__PURE__ */ Q(he, [["__scopeId", "data-v-dd26d1ca"]]), fe = { class: "vs-search" }, be = ["placeholder", "value"], me = /* @__PURE__ */ L({
124
+ }), U = (e, s) => {
125
+ const l = e.__vccOpts || e;
126
+ for (const [t, r] of s)
127
+ l[t] = r;
128
+ return l;
129
+ }, fe = /* @__PURE__ */ U(ge, [["__scopeId", "data-v-dd26d1ca"]]), be = { class: "vs-search" }, me = ["placeholder", "value"], we = /* @__PURE__ */ K({
123
130
  __name: "VsSearch",
124
131
  props: {
125
132
  modelValue: {},
126
133
  placeholder: {}
127
134
  },
128
135
  emits: ["update:modelValue", "input-typed"],
129
- setup(e, { emit: l }) {
130
- const s = l, t = (i) => {
131
- const r = i.target;
132
- s("update:modelValue", r.value), s("input-typed", r.value);
136
+ setup(e, { emit: s }) {
137
+ const l = s, t = (r) => {
138
+ const a = r.target;
139
+ l("update:modelValue", a.value), l("input-typed", a.value);
133
140
  };
134
- return (i, r) => (f(), g("div", fe, [
135
- r[0] || (r[0] = n("div", { class: "vs-search-icon" }, [
141
+ return (r, a) => (b(), f("div", be, [
142
+ a[0] || (a[0] = n("div", { class: "vs-search-icon" }, [
136
143
  n("svg", {
137
144
  viewBox: "0 0 24 24",
138
145
  fill: "currentColor"
@@ -146,233 +153,239 @@ const re = ["id"], ce = ["disabled"], de = {
146
153
  placeholder: e.placeholder,
147
154
  value: e.modelValue,
148
155
  onInput: t
149
- }, null, 40, be)
156
+ }, null, 40, me)
150
157
  ]));
151
158
  }
152
- }), we = { class: "vs-rows-per-page" }, ye = ["value"], Ce = ["value"], ke = /* @__PURE__ */ L({
159
+ }), ye = { class: "vs-rows-per-page" }, pe = ["value"], Ce = ["value"], ke = /* @__PURE__ */ K({
153
160
  __name: "VsRowsPerPage",
154
161
  props: {
155
162
  modelValue: {},
156
163
  options: {}
157
164
  },
158
165
  emits: ["update:modelValue", "rows-per-page-changed"],
159
- setup(e, { emit: l }) {
160
- const s = e, t = l, i = s.options ?? [10, 25, 50, 100], r = (o) => {
161
- const h = Number(o.target.value);
162
- t("update:modelValue", h), t("rows-per-page-changed", h);
166
+ setup(e, { emit: s }) {
167
+ const l = e, t = s, r = l.options ?? [10, 25, 50, 100], a = (c) => {
168
+ const i = Number(c.target.value);
169
+ t("update:modelValue", i), t("rows-per-page-changed", i);
163
170
  };
164
- return (o, h) => (f(), g("div", we, [
165
- h[0] || (h[0] = n("span", { class: "vs-rows-label" }, "Items Per Page", -1)),
171
+ return (c, i) => (b(), f("div", ye, [
172
+ i[0] || (i[0] = n("span", { class: "vs-rows-label" }, "Items Per Page", -1)),
166
173
  n("select", {
167
174
  class: "vs-items-dropdown",
168
175
  value: e.modelValue,
169
- onChange: r
176
+ onChange: a
170
177
  }, [
171
- (f(!0), g(A, null, B(c(i), (v) => (f(), g("option", {
172
- key: v,
173
- value: v
174
- }, p(v), 9, Ce))), 128))
175
- ], 40, ye)
178
+ (b(!0), f(M, null, B(d(r), (g) => (b(), f("option", {
179
+ key: g,
180
+ value: g
181
+ }, P(g), 9, Ce))), 128))
182
+ ], 40, pe)
176
183
  ]));
177
184
  }
178
- }), pe = /* @__PURE__ */ Q(ke, [["__scopeId", "data-v-dd11bb0e"]]);
179
- function Pe(e, l, s, t) {
180
- const i = H(1), r = H(e.sort ?? []);
185
+ }), Pe = /* @__PURE__ */ U(ke, [["__scopeId", "data-v-dd11bb0e"]]);
186
+ function Se(e, s, l, t, r) {
187
+ const a = L(1), c = L(e.sort ?? []);
181
188
  F(
182
189
  () => e.sort,
183
- (d) => {
184
- d && (r.value = [...d]);
190
+ (u) => {
191
+ u && (c.value = [...u]);
185
192
  },
186
193
  { deep: !0 }
187
194
  );
188
- const o = C(
189
- () => e.serverOptions?.sort ?? r.value ?? []
195
+ const i = C(
196
+ () => e.serverOptions?.sort ?? c.value ?? []
190
197
  );
191
198
  return {
192
199
  sortedRows: C(() => {
193
- let d = e.rows;
194
- return o.value.length && (d = ae(e.rows, o.value)), e.rowsPerPage && (d = oe(d, s.value, t.value)), d;
200
+ let u = e.rows;
201
+ return r.value && (u = re(u, r.value)), i.value.length && (u = ae(u, i.value)), e.rowsPerPage && (u = oe(u, l.value, t.value)), u;
195
202
  }),
196
- activeSort: o,
203
+ activeSort: i,
197
204
  sortHelpers: {
198
- isColumnSorted: (d) => o.value.some((m) => m.field === d),
199
- getSortPriority: (d) => {
200
- const m = o.value.find((a) => a.field === d);
201
- return m ? m.priority ?? null : null;
205
+ isColumnSorted: (u) => i.value.some((o) => o.field === u),
206
+ getSortPriority: (u) => {
207
+ const o = i.value.find((v) => v.field === u);
208
+ return o ? o.priority ?? null : null;
202
209
  },
203
- getSortOrder: (d) => o.value.find((m) => m.field === d)?.order ?? null,
204
- handleSort: (d, m) => {
205
- let a = [];
206
- e.serverOptions ? a = [...e.serverOptions.sort ?? []] : e.sort && (a = [...e.sort]);
207
- const b = a.findIndex((P) => P.field === d);
208
- m.shiftKey ? b === -1 ? a.push({ field: d, order: "asc" }) : a[b]?.order === "asc" ? a[b].order = "desc" : a.splice(b, 1) : b === -1 ? a = [{ field: d, order: "asc" }] : a[b]?.order === "asc" ? a = [{ field: d, order: "desc" }] : a = [], a = a.map((P, V) => ({ ...P, priority: V + 1 })), e.serverOptions ? l("update:serverOptions", { ...e.serverOptions, sort: a }) : l("update:sort", a), s.value = i.value, l("sort-changed", { sort: a });
210
+ getSortOrder: (u) => i.value.find((o) => o.field === u)?.order ?? null,
211
+ handleSort: (u, o) => {
212
+ let v = [];
213
+ e.serverOptions ? v = [...e.serverOptions.sort ?? []] : e.sort && (v = [...e.sort]);
214
+ const p = v.findIndex((R) => R.field === u);
215
+ o.shiftKey ? p === -1 ? v.push({ field: u, order: "asc" }) : v[p]?.order === "asc" ? v[p].order = "desc" : v.splice(p, 1) : p === -1 ? v = [{ field: u, order: "asc" }] : v[p]?.order === "asc" ? v = [{ field: u, order: "desc" }] : v = [], v = v.map((R, T) => ({ ...R, priority: T + 1 })), e.serverOptions ? s("update:serverOptions", { ...e.serverOptions, sort: v }) : s("update:sort", v), l.value = a.value, s("sort-changed", { sort: v });
209
216
  }
210
217
  }
211
218
  };
212
219
  }
213
- function Se(e, l, s, t) {
214
- const i = C({
215
- get: () => e.serverItemsLength !== void 0 ? e.serverItemsLength : e.rows.length,
220
+ function Re(e, s, l, t, r) {
221
+ const a = C({
222
+ get: () => e.serverItemsLength !== void 0 ? e.serverItemsLength : r.value.length,
216
223
  set: (y) => {
217
- e.serverItemsLength !== void 0 && l("update:serverItemsLength", y);
224
+ e.serverItemsLength !== void 0 && s("update:serverItemsLength", y);
218
225
  }
219
- }), r = C({
220
- get: () => e.serverOptions?.page ?? s.value,
226
+ }), c = C({
227
+ get: () => e.serverOptions?.page ?? l.value,
221
228
  set: (y) => {
222
- e.serverOptions ? l("update:serverOptions", { ...e.serverOptions, page: y }) : s.value = y;
229
+ e.serverOptions ? s("update:serverOptions", { ...e.serverOptions, page: y }) : l.value = y;
223
230
  }
224
- }), o = C(() => {
231
+ }), i = C(() => {
225
232
  const y = t.value;
226
- return ne(s.value, y, i.value);
227
- }), h = (y) => {
228
- e.serverOptions && l("update:serverOptions", { ...e.serverOptions, page: y }), l("page-updated", y);
233
+ return ne(l.value, y, a.value);
234
+ }), g = (y) => {
235
+ e.serverOptions && s("update:serverOptions", { ...e.serverOptions, page: y }), s("page-updated", y);
229
236
  };
230
237
  return {
231
- currentPage: r,
232
- totalRecords: i,
233
- recordRange: o,
234
- handlePageChange: h,
238
+ currentPage: c,
239
+ totalRecords: a,
240
+ recordRange: i,
241
+ handlePageChange: g,
235
242
  paginationHelpers: {
236
- page: s,
237
- totalRecords: i,
238
- recordRange: o,
239
- handlePageChange: h
243
+ page: l,
244
+ totalRecords: a,
245
+ recordRange: i,
246
+ handlePageChange: g
240
247
  }
241
248
  };
242
249
  }
243
- function Re(e, l, s, t) {
244
- const i = C({
250
+ function Ve(e, s, l, t) {
251
+ const r = C({
245
252
  get: () => t.value,
246
- set: (o) => t.value = o
253
+ set: (c) => t.value = c
247
254
  });
248
- return F(t, (o) => {
249
- const h = e.serverItemsLength ?? e.rows.length, v = j(h, o);
250
- s.value > v ? s.value = v || 1 : s.value < 1 && (s.value = 1);
255
+ return F(t, (c) => {
256
+ const i = e.serverItemsLength ?? e.rows.length, g = Q(i, c);
257
+ l.value > g ? l.value = g || 1 : l.value < 1 && (l.value = 1);
251
258
  }), {
252
- vsRowsPerPage: i,
253
- handleRowsPerPage: (o) => {
254
- t.value = o, l("rows-per-page-changed", o);
259
+ vsRowsPerPage: r,
260
+ handleRowsPerPage: (c) => {
261
+ t.value = c, s("rows-per-page-changed", c);
255
262
  }
256
263
  };
257
264
  }
258
- function Ve(e, l) {
259
- const s = H(1), t = H(e.serverOptions?.rowsPerPage ?? e.rowsPerPage), { totalRecords: i, recordRange: r, handlePageChange: o } = Se(e, l, s, t), { handleRowsPerPage: h } = Re(e, l, s, t), { sortedRows: v, sortHelpers: y } = Pe(e, l, s, t);
265
+ function xe(e, s) {
266
+ const l = (c) => {
267
+ s.value = c, e("input-typed", c);
268
+ };
260
269
  return {
261
- page: s,
262
- rowsPerPage: t,
270
+ searchQuery: s,
271
+ onInputTyped: l,
272
+ clearSearch: () => {
273
+ s.value = "", e("input-typed", "");
274
+ },
275
+ setSearchQuery: (c) => {
276
+ s.value = c, e("input-typed", c);
277
+ },
278
+ searchHelpers: {
279
+ searchQuery: s,
280
+ onInputTyped: l
281
+ }
282
+ };
283
+ }
284
+ function Te(e, s) {
285
+ const l = L(1), t = L(e.serverOptions?.rowsPerPage ?? e.rowsPerPage), r = L(""), { sortedRows: a, sortHelpers: c } = Se(e, s, l, t, r), { totalRecords: i, recordRange: g, handlePageChange: S } = Re(e, s, l, t, a), { handleRowsPerPage: y } = Ve(e, s, l, t), { onInputTyped: O } = xe(s, r);
286
+ return {
287
+ //Pagination
288
+ page: l,
263
289
  totalRecords: i,
264
- recordRange: r,
265
- handlePageChange: o,
266
- handleRowsPerPage: h,
267
- sortedRows: v,
268
- sortHelpers: y
290
+ recordRange: g,
291
+ handlePageChange: S,
292
+ //Row Per Page
293
+ rowsPerPage: t,
294
+ handleRowsPerPage: y,
295
+ //Sort
296
+ sortedRows: a,
297
+ sortHelpers: c,
298
+ //Search
299
+ searchQuery: r,
300
+ onInputTyped: O
269
301
  };
270
302
  }
271
- function xe(e, l) {
272
- const s = H(e.itemSelected || []);
303
+ function $e(e, s) {
304
+ const l = L(e.itemSelected || []);
273
305
  F(
274
306
  () => e.itemSelected,
275
- (a) => {
276
- a ? s.value = [...a] : s.value = [];
307
+ (o) => {
308
+ o ? l.value = [...o] : l.value = [];
277
309
  },
278
310
  { immediate: !0, deep: !0 }
279
311
  );
280
312
  const t = C({
281
- get: () => s.value,
282
- set: (a) => {
283
- s.value = a, l("update:itemSelected", a);
313
+ get: () => l.value,
314
+ set: (o) => {
315
+ l.value = o, s("update:itemSelected", o);
284
316
  }
285
- }), i = C(() => e.itemSelected !== null), r = C(
317
+ }), r = C(() => e.itemSelected !== null), a = C(
286
318
  () => e.rows.length > 0 && t.value.length === e.rows.length
287
- ), o = C(() => !e.rows.length || !t.value.length ? !1 : !r.value && e.rows.some(
288
- (a, b) => t.value.some(
289
- (P, V) => k(P, V, e.rowKey) === k(a, b, e.rowKey)
319
+ ), c = C(() => !e.rows.length || !t.value.length ? !1 : !a.value && e.rows.some(
320
+ (o, v) => t.value.some(
321
+ (p, R) => k(p, R, e.rowKey) === k(o, v, e.rowKey)
290
322
  )
291
- )), h = (a, b) => {
292
- const P = k(a, b, e.rowKey);
323
+ )), i = (o, v) => {
324
+ const p = k(o, v, e.rowKey);
293
325
  t.value.some(
294
- (I, O) => k(I, O, e.rowKey) === P
326
+ (T, H) => k(T, H, e.rowKey) === p
295
327
  ) ? (t.value = t.value.filter(
296
- (I, O) => k(I, O, e.rowKey) !== P
297
- ), l("row-deselected", a, b)) : (t.value = [...t.value, a], l("row-selected", a, b));
298
- }, v = (a) => {
299
- const b = a.target;
300
- t.value = b.checked ? [...e.rows] : [], l("all-rows-selected", t.value);
328
+ (T, H) => k(T, H, e.rowKey) !== p
329
+ ), s("row-deselected", o, v)) : (t.value = [...t.value, o], s("row-selected", o, v));
330
+ }, g = (o) => {
331
+ const v = o.target;
332
+ t.value = v.checked ? [...e.rows] : [], s("all-rows-selected", t.value);
301
333
  };
302
334
  return {
303
335
  selectedItems: t,
304
- isItemSelectedControlled: i,
305
- isAllChecked: r,
306
- isSomeChecked: o,
307
- toggleRow: h,
308
- toggleAll: v,
309
- selectRow: (a, b) => {
310
- Z(a, t.value, e.rowKey) || (t.value = [...t.value, a], l("row-selected", a, b));
336
+ isItemSelectedControlled: r,
337
+ isAllChecked: a,
338
+ isSomeChecked: c,
339
+ toggleRow: i,
340
+ toggleAll: g,
341
+ selectRow: (o, v) => {
342
+ Z(o, t.value, e.rowKey) || (t.value = [...t.value, o], s("row-selected", o, v));
311
343
  },
312
- deselectRow: (a, b) => {
313
- const P = k(a, b, e.rowKey);
344
+ deselectRow: (o, v) => {
345
+ const p = k(o, v, e.rowKey);
314
346
  t.value = t.value.filter(
315
- (V, I) => k(V, I, e.rowKey) !== P
316
- ), l("row-deselected", a, b);
347
+ (R, T) => k(R, T, e.rowKey) !== p
348
+ ), s("row-deselected", o, v);
317
349
  },
318
350
  selectAll: () => {
319
- t.value = [...e.rows], l("all-rows-selected", t.value);
351
+ t.value = [...e.rows], s("all-rows-selected", t.value);
320
352
  },
321
353
  deselectAll: () => {
322
- t.value = [], l("all-rows-selected", []);
354
+ t.value = [], s("all-rows-selected", []);
323
355
  },
324
356
  clearSelection: () => {
325
357
  t.value = [];
326
358
  },
327
359
  selectionHelpers: {
328
360
  selectedItems: t,
329
- isItemSelectedControlled: i,
330
- isAllChecked: r,
331
- isSomeChecked: o,
332
- toggleRow: h,
333
- toggleAll: v
334
- }
335
- };
336
- }
337
- function $e(e) {
338
- const l = H(""), s = (o) => {
339
- l.value = o, e("input-typed", o);
340
- };
341
- return {
342
- searchQuery: l,
343
- onInputTyped: s,
344
- clearSearch: () => {
345
- l.value = "", e("input-typed", "");
346
- },
347
- setSearchQuery: (o) => {
348
- l.value = o, e("input-typed", o);
349
- },
350
- searchHelpers: {
351
- searchQuery: l,
352
- onInputTyped: s
361
+ isItemSelectedControlled: r,
362
+ isAllChecked: a,
363
+ isSomeChecked: c,
364
+ toggleRow: i,
365
+ toggleAll: g
353
366
  }
354
367
  };
355
368
  }
356
- const Te = { class: "vs-datatable" }, Ie = {
369
+ const Ie = { class: "vs-datatable" }, Oe = {
357
370
  key: 0,
358
371
  class: "vs-search-container"
359
- }, Oe = {
372
+ }, _e = {
360
373
  ref: "tableResponsiveRef",
361
374
  class: "vs-table-wrapper"
362
- }, _e = {
375
+ }, De = {
363
376
  key: 0,
364
377
  class: "vs-checkbox-column",
365
378
  style: { width: "5%" }
366
- }, De = { class: "vs-checkbox" }, He = ["id", "checked", "indeterminate"], Me = ["for"], Ae = ["onClick"], Be = { class: "vs-header-content" }, Ke = { class: "vs-header-label" }, Le = {
379
+ }, He = { class: "vs-checkbox" }, Le = ["id", "checked", "indeterminate"], Me = ["for"], Be = ["onClick"], Ae = { class: "vs-header-content" }, Ke = { class: "vs-header-label" }, ze = {
367
380
  key: 0,
368
381
  class: "vs-sort-icons"
369
- }, ze = {
382
+ }, Ne = {
370
383
  key: 1,
371
384
  class: "vs-sort-priority"
372
- }, Ne = { key: 0 }, Fe = ["colspan"], Qe = { key: 1 }, Ue = ["colspan"], Ee = { class: "vs-no-data-message" }, Ze = { class: "vs-no-data-description" }, je = ["onClick"], Ge = { class: "vs-checkbox" }, Je = ["id", "value", "checked", "onChange"], We = ["for"], Xe = {
385
+ }, Fe = { key: 0 }, Ue = ["colspan"], je = { key: 1 }, Ee = ["colspan"], Ze = { class: "vs-no-data-message" }, Qe = { class: "vs-no-data-description" }, Ge = ["onClick"], Je = { class: "vs-checkbox" }, We = ["id", "value", "checked", "onChange"], Xe = ["for"], Ye = {
373
386
  key: 1,
374
387
  class: "vs-table-footer"
375
- }, Ye = { class: "vs-footer-left" }, qe = { class: "vs-table-info" }, et = /* @__PURE__ */ L({
388
+ }, qe = { class: "vs-footer-left" }, et = { class: "vs-table-info" }, tt = /* @__PURE__ */ K({
376
389
  __name: "VsDataTable",
377
390
  props: {
378
391
  rows: { default: () => [] },
@@ -385,16 +398,16 @@ const Te = { class: "vs-datatable" }, Ie = {
385
398
  headerText: { default: "" },
386
399
  loading: { type: Boolean, default: !1 },
387
400
  columns: {},
388
- showSearch: { type: Boolean, default: !0 },
389
401
  tableClass: {},
390
402
  rowClass: {},
391
403
  showFooter: { type: Boolean, default: !0 },
392
404
  containerClass: {},
393
405
  headerClass: {},
394
406
  cellClass: {},
407
+ showSearch: { type: Boolean, default: !0 },
395
408
  searchClass: {},
396
- paginationClass: {},
397
409
  searchPlaceholder: { default: "Search..." },
410
+ paginationClass: {},
398
411
  loadingText: { default: "Loading..." },
399
412
  noDataText: { default: "No data available" },
400
413
  noDataDescription: { default: "Try adjusting your search criteria" },
@@ -404,30 +417,32 @@ const Te = { class: "vs-datatable" }, Ie = {
404
417
  rowKey: { type: [String, Function], default: "id" }
405
418
  },
406
419
  emits: ["update:itemSelected", "update:serverItemsLength", "update:serverOptions", "update:sort", "input-typed", "page-updated", "sort-changed", "row-click", "row-selected", "row-deselected", "all-rows-selected", "table:mounted", "table:unmounted", "table:before-mount", "data-loaded", "data-error"],
407
- setup(e, { emit: l }) {
408
- const s = e, t = l, i = W(), r = C(() => !!i.onRowClick), {
409
- page: o,
410
- rowsPerPage: h,
411
- totalRecords: v,
412
- recordRange: y,
413
- handlePageChange: T,
414
- handleRowsPerPage: M,
420
+ setup(e, { emit: s }) {
421
+ const l = e, t = s, r = W(), a = C(() => !!r.onRowClick), {
422
+ page: c,
423
+ rowsPerPage: i,
424
+ totalRecords: g,
425
+ recordRange: S,
426
+ handlePageChange: y,
427
+ handleRowsPerPage: O,
415
428
  sortedRows: D,
416
- sortHelpers: d
417
- } = Ve(s, t), {
418
- selectedItems: m,
419
- isItemSelectedControlled: a,
420
- isAllChecked: b,
421
- isSomeChecked: P,
422
- toggleAll: V,
423
- toggleRow: I
424
- } = xe(s, t), { searchQuery: O, onInputTyped: G } = $e(t), U = C(
425
- () => le(s.columns, a.value)
429
+ sortHelpers: m,
430
+ searchQuery: u,
431
+ onInputTyped: o
432
+ } = Te(l, t), {
433
+ selectedItems: v,
434
+ isItemSelectedControlled: p,
435
+ isAllChecked: R,
436
+ isSomeChecked: T,
437
+ toggleAll: H,
438
+ toggleRow: G
439
+ } = $e(l, t), j = C(
440
+ () => le(l.columns, p.value)
426
441
  );
427
442
  return X(() => {
428
443
  t("table:mounted");
429
444
  try {
430
- t("data-loaded", s.rows);
445
+ t("data-loaded", l.rows);
431
446
  } catch (_) {
432
447
  t("data-error", _);
433
448
  }
@@ -435,54 +450,54 @@ const Te = { class: "vs-datatable" }, Ie = {
435
450
  t("table:unmounted");
436
451
  }), q(() => {
437
452
  t("table:before-mount");
438
- }), (_, w) => (f(), g("div", Te, [
439
- e.showSearch ? (f(), g("div", Ie, [
440
- z(me, {
441
- modelValue: c(O),
442
- "onUpdate:modelValue": w[0] || (w[0] = (u) => N(O) ? O.value = u : null),
443
- onInputTyped: c(G),
453
+ }), (_, w) => (b(), f("div", Ie, [
454
+ e.showSearch ? (b(), f("div", Oe, [
455
+ z(we, {
456
+ modelValue: d(u),
457
+ "onUpdate:modelValue": w[0] || (w[0] = (h) => N(u) ? u.value = h : null),
458
+ onInputTyped: d(o),
444
459
  placeholder: e.searchPlaceholder,
445
- class: S(e.searchClass)
460
+ class: V(e.searchClass)
446
461
  }, null, 8, ["modelValue", "onInputTyped", "placeholder", "class"]),
447
- K(_.$slots, "filterArea", {}, void 0, !0)
448
- ])) : R("", !0),
462
+ A(_.$slots, "filterArea", {}, void 0, !0)
463
+ ])) : x("", !0),
449
464
  n("div", {
450
- class: S(["vs-table-container", e.containerClass])
465
+ class: V(["vs-table-container", e.containerClass])
451
466
  }, [
452
- n("div", Oe, [
467
+ n("div", _e, [
453
468
  n("table", {
454
- class: S(["vs-table", e.tableClass])
469
+ class: V(["vs-table", e.tableClass])
455
470
  }, [
456
471
  n("thead", null, [
457
472
  n("tr", null, [
458
- c(a) ? (f(), g("th", _e, [
459
- n("div", De, [
473
+ d(p) ? (b(), f("th", De, [
474
+ n("div", He, [
460
475
  n("input", {
461
476
  type: "checkbox",
462
477
  id: e.tablename + "-main-checkbox",
463
- checked: c(b),
464
- indeterminate: c(P),
478
+ checked: d(R),
479
+ indeterminate: d(T),
465
480
  onChange: w[1] || (w[1] = //@ts-ignore
466
- (...u) => c(V) && c(V)(...u))
467
- }, null, 40, He),
481
+ (...h) => d(H) && d(H)(...h))
482
+ }, null, 40, Le),
468
483
  n("label", {
469
484
  for: e.tablename + "-main-checkbox"
470
485
  }, null, 8, Me)
471
486
  ])
472
- ])) : R("", !0),
473
- (f(!0), g(A, null, B(e.columns, (u) => (f(), g("th", {
474
- key: u.field,
475
- onClick: (x) => u.sortable ? c(d).handleSort(u.field, x) : null,
476
- style: ee({ width: u.width + "%" }),
477
- class: S([u.sortable ? "vs-sortable" : "", e.headerClass])
487
+ ])) : x("", !0),
488
+ (b(!0), f(M, null, B(e.columns, (h) => (b(), f("th", {
489
+ key: h.field,
490
+ onClick: ($) => h.sortable ? d(m).handleSort(h.field, $) : null,
491
+ style: ee({ width: h.width + "%" }),
492
+ class: V([h.sortable ? "vs-sortable" : "", e.headerClass])
478
493
  }, [
479
- K(_.$slots, `header-${u.field}`, { column: u }, () => [
480
- n("div", Be, [
481
- n("span", Ke, p(u.label), 1),
482
- u.sortable ? (f(), g("div", Le, [
494
+ A(_.$slots, `header-${h.field}`, { column: h }, () => [
495
+ n("div", Ae, [
496
+ n("span", Ke, P(h.label), 1),
497
+ h.sortable ? (b(), f("div", ze, [
483
498
  n("span", {
484
- class: S(["vs-sort-icon vs-sort-asc", {
485
- "vs-active": c(d).isColumnSorted(u.field) && c(d).getSortOrder(u.field) === "asc"
499
+ class: V(["vs-sort-icon vs-sort-asc", {
500
+ "vs-active": d(m).isColumnSorted(h.field) && d(m).getSortOrder(h.field) === "asc"
486
501
  }])
487
502
  }, [...w[5] || (w[5] = [
488
503
  n("svg", {
@@ -495,8 +510,8 @@ const Te = { class: "vs-datatable" }, Ie = {
495
510
  ], -1)
496
511
  ])], 2),
497
512
  n("span", {
498
- class: S(["vs-sort-icon vs-sort-desc", {
499
- "vs-active": c(d).isColumnSorted(u.field) && c(d).getSortOrder(u.field) === "desc"
513
+ class: V(["vs-sort-icon vs-sort-desc", {
514
+ "vs-active": d(m).isColumnSorted(h.field) && d(m).getSortOrder(h.field) === "desc"
500
515
  }])
501
516
  }, [...w[6] || (w[6] = [
502
517
  n("svg", {
@@ -508,69 +523,69 @@ const Te = { class: "vs-datatable" }, Ie = {
508
523
  n("path", { d: "M480-360 280-560h400L480-360Z" })
509
524
  ], -1)
510
525
  ])], 2)
511
- ])) : R("", !0),
512
- c(d).getSortPriority(u.field) !== null ? (f(), g("span", ze, p(c(d).getSortPriority(u.field)), 1)) : R("", !0)
526
+ ])) : x("", !0),
527
+ d(m).getSortPriority(h.field) !== null ? (b(), f("span", Ne, P(d(m).getSortPriority(h.field)), 1)) : x("", !0)
513
528
  ])
514
529
  ], !0)
515
- ], 14, Ae))), 128))
530
+ ], 14, Be))), 128))
516
531
  ])
517
532
  ]),
518
533
  n("tbody", null, [
519
- e.loading ? (f(), g("tr", Ne, [
534
+ e.loading ? (b(), f("tr", Fe, [
520
535
  n("td", {
521
- colspan: U.value,
536
+ colspan: j.value,
522
537
  class: "vs-loading"
523
538
  }, [
524
539
  w[7] || (w[7] = n("div", { class: "vs-spinner" }, null, -1)),
525
- n("span", null, p(e.loadingText), 1)
526
- ], 8, Fe)
527
- ])) : c(D).length ? (f(!0), g(A, { key: 2 }, B(c(D), (u, x) => (f(), g("tr", {
528
- key: c(k)(u, x),
529
- class: S([
540
+ n("span", null, P(e.loadingText), 1)
541
+ ], 8, Ue)
542
+ ])) : d(D).length ? (b(!0), f(M, { key: 2 }, B(d(D), (h, $) => (b(), f("tr", {
543
+ key: d(k)(h, $),
544
+ class: V([
530
545
  e.rowClass,
531
- { "vs-row-clickable": r.value },
532
- { "vs-row-selected": c(Z)(u, c(m), e.rowKey) }
546
+ { "vs-row-clickable": a.value },
547
+ { "vs-row-selected": d(Z)(h, d(v), e.rowKey) }
533
548
  ]),
534
- onClick: ($) => _.$emit("row-click", u, x)
549
+ onClick: (I) => _.$emit("row-click", h, $)
535
550
  }, [
536
- c(a) ? (f(), g("td", {
551
+ d(p) ? (b(), f("td", {
537
552
  key: 0,
538
553
  onClick: w[2] || (w[2] = te(() => {
539
554
  }, ["stop"])),
540
555
  class: "vs-checkbox-column"
541
556
  }, [
542
- n("div", Ge, [
557
+ n("div", Je, [
543
558
  n("input", {
544
559
  type: "checkbox",
545
- id: e.tablename + "-checkbox-" + c(k)(u, x),
546
- value: u,
547
- checked: c(m).some(($, J) => c(k)($, J) === c(k)(u, x)),
548
- onChange: ($) => c(I)(u, x)
549
- }, null, 40, Je),
560
+ id: e.tablename + "-checkbox-" + d(k)(h, $),
561
+ value: h,
562
+ checked: d(v).some((I, J) => d(k)(I, J) === d(k)(h, $)),
563
+ onChange: (I) => d(G)(h, $)
564
+ }, null, 40, We),
550
565
  n("label", {
551
- for: e.tablename + "-checkbox-" + c(k)(u, x)
552
- }, null, 8, We)
566
+ for: e.tablename + "-checkbox-" + d(k)(h, $)
567
+ }, null, 8, Xe)
553
568
  ])
554
- ])) : R("", !0),
555
- (f(!0), g(A, null, B(e.columns, ($) => (f(), g("td", {
556
- key: $.field,
557
- class: S(e.cellClass)
569
+ ])) : x("", !0),
570
+ (b(!0), f(M, null, B(e.columns, (I) => (b(), f("td", {
571
+ key: I.field,
572
+ class: V(e.cellClass)
558
573
  }, [
559
- K(_.$slots, `cell-${$.field}`, {
560
- item: u,
561
- value: c(E)(u, $.field),
562
- column: $,
563
- index: x
574
+ A(_.$slots, `cell-${I.field}`, {
575
+ item: h,
576
+ value: d(E)(h, I.field),
577
+ column: I,
578
+ index: $
564
579
  }, () => [
565
- se(p(c(E)(u, $.field)), 1)
580
+ se(P(d(E)(h, I.field)), 1)
566
581
  ], !0)
567
582
  ], 2))), 128))
568
- ], 10, je))), 128)) : (f(), g("tr", Qe, [
583
+ ], 10, Ge))), 128)) : (b(), f("tr", je, [
569
584
  n("td", {
570
- colspan: U.value,
585
+ colspan: j.value,
571
586
  class: "vs-no-data"
572
587
  }, [
573
- K(_.$slots, "no-data", {}, () => [
588
+ A(_.$slots, "no-data", {}, () => [
574
589
  w[8] || (w[8] = n("div", { class: "vs-no-data-icon" }, [
575
590
  n("svg", {
576
591
  viewBox: "0 0 24 24",
@@ -579,44 +594,44 @@ const Te = { class: "vs-datatable" }, Ie = {
579
594
  n("path", { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z" })
580
595
  ])
581
596
  ], -1)),
582
- n("div", Ee, p(e.noDataText), 1),
583
- n("div", Ze, p(e.noDataDescription), 1)
597
+ n("div", Ze, P(e.noDataText), 1),
598
+ n("div", Qe, P(e.noDataDescription), 1)
584
599
  ], !0)
585
- ], 8, Ue)
600
+ ], 8, Ee)
586
601
  ]))
587
602
  ])
588
603
  ], 2)
589
604
  ], 512)
590
605
  ], 2),
591
- e.showFooter ? (f(), g("div", Xe, [
592
- n("div", Ye, [
593
- z(pe, {
594
- modelValue: c(h),
595
- "onUpdate:modelValue": w[3] || (w[3] = (u) => N(h) ? h.value = u : null),
596
- onRowsPerPageChanged: c(M)
606
+ e.showFooter ? (b(), f("div", Ye, [
607
+ n("div", qe, [
608
+ z(Pe, {
609
+ modelValue: d(i),
610
+ "onUpdate:modelValue": w[3] || (w[3] = (h) => N(i) ? i.value = h : null),
611
+ onRowsPerPageChanged: d(O)
597
612
  }, null, 8, ["modelValue", "onRowsPerPageChanged"]),
598
613
  w[9] || (w[9] = n("div", { class: "vs-divider" }, null, -1)),
599
- n("div", qe, p(c(y).start < 1 ? 0 : c(y).start) + " - " + p(c(y).end) + " of " + p(c(v)) + " " + p(e.entriesText), 1)
614
+ n("div", et, P(d(S).start < 1 ? 0 : d(S).start) + " - " + P(d(S).end) + " of " + P(d(g)) + " " + P(e.entriesText), 1)
600
615
  ]),
601
- z(ge, {
602
- modelValue: c(o),
603
- "onUpdate:modelValue": w[4] || (w[4] = (u) => N(o) ? o.value = u : null),
604
- totalRecords: c(v),
605
- rowsPerPage: c(h),
616
+ z(fe, {
617
+ modelValue: d(c),
618
+ "onUpdate:modelValue": w[4] || (w[4] = (h) => N(c) ? c.value = h : null),
619
+ totalRecords: d(g),
620
+ rowsPerPage: d(i),
606
621
  maxVisible: e.maxVisiblePages,
607
622
  tablename: e.tablename,
608
- class: S(e.paginationClass),
609
- onPageChanged: c(T)
623
+ class: V(e.paginationClass),
624
+ onPageChanged: d(y)
610
625
  }, null, 8, ["modelValue", "totalRecords", "rowsPerPage", "maxVisible", "tablename", "class", "onPageChanged"])
611
- ])) : R("", !0)
626
+ ])) : x("", !0)
612
627
  ]));
613
628
  }
614
- }), tt = /* @__PURE__ */ Q(et, [["__scopeId", "data-v-b1f39b67"]]), lt = {
629
+ }), st = /* @__PURE__ */ U(tt, [["__scopeId", "data-v-84a43921"]]), at = {
615
630
  install(e) {
616
- e.component("VsDataTable", tt);
631
+ e.component("VsDataTable", st);
617
632
  }
618
633
  };
619
634
  export {
620
- tt as VsDataTable,
621
- lt as default
635
+ st as VsDataTable,
636
+ at as default
622
637
  };