vs-datatable 0.1.0 → 0.2.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,17 +1,11 @@
1
- import { defineComponent as H, computed as p, createElementBlock as i, openBlock as r, createElementVNode as o, createCommentVNode as k, normalizeClass as w, Fragment as R, renderList as L, toDisplayString as y, normalizeStyle as E, useAttrs as K, ref as A, resolveComponent as Q, createBlock as J, withCtx as W, renderSlot as M, createVNode as D, unref as X, withModifiers as Y, withDirectives as ee, vModelCheckbox as te, createTextVNode as se } from "vue";
2
- import './index.css';const ae = { ref: "vsPagination" }, oe = ["id"], le = { class: "page-item" }, ne = ["disabled"], re = {
3
- key: 0,
4
- class: "page-item d-flex"
5
- }, ie = {
6
- key: 0,
7
- class: "page-link disabled"
8
- }, de = ["id", "onClick"], ce = {
1
+ import { defineComponent as K, computed as v, createElementBlock as n, openBlock as r, createElementVNode as o, createCommentVNode as k, Fragment as M, renderList as D, normalizeClass as w, toDisplayString as b, useAttrs as W, ref as I, watch as X, createVNode as Z, renderSlot as _, normalizeStyle as Y, withModifiers as ee, withDirectives as te, vModelCheckbox as se, createTextVNode as ae } from "vue";
2
+ import './index.css';const le = ["id"], oe = ["disabled"], ne = {
9
3
  key: 1,
10
- class: "page-item d-flex"
11
- }, ue = {
12
- key: 0,
13
- class: "page-link me-2 disabled"
14
- }, pe = { class: "page-item" }, ve = ["disabled"], fe = /* @__PURE__ */ H({
4
+ class: "vs-pagination-ellipsis"
5
+ }, re = ["id", "onClick"], ie = {
6
+ key: 2,
7
+ class: "vs-pagination-ellipsis"
8
+ }, de = ["disabled"], ce = /* @__PURE__ */ K({
15
9
  __name: "VsPagination",
16
10
  props: {
17
11
  modelValue: {},
@@ -22,170 +16,124 @@ import './index.css';const ae = { ref: "vsPagination" }, oe = ["id"], le = { cla
22
16
  paginationClass: {}
23
17
  },
24
18
  emits: ["update:modelValue", "page-changed"],
25
- setup(e, { emit: b }) {
26
- const t = e, c = b, h = t.maxVisible ?? 3, d = p({
27
- get: () => t.modelValue,
28
- set: (m) => {
29
- c("update:modelValue", m), c("page-changed", m);
19
+ setup(l, { emit: C }) {
20
+ const s = l, c = C, g = s.maxVisible ?? 3, d = v({
21
+ get: () => s.modelValue,
22
+ set: (p) => {
23
+ c("update:modelValue", p), c("page-changed", p);
30
24
  }
31
- }), x = p(() => d.value <= Math.floor(h / 2) ? 1 : d.value >= u.value - Math.floor(h / 2) ? Math.max(u.value - h + 1, 1) : d.value - Math.floor(h / 2)), $ = p(() => Math.min(x.value + h - 1, u.value)), u = p(() => Math.ceil(t.totalRecords / t.rowsPerPage)), P = p(() => {
32
- const m = [];
33
- for (let g = x.value; g <= $.value; g++)
34
- m.push(g);
35
- return m;
36
- }), V = (m) => {
37
- m >= 1 && m <= u.value && (d.value = m);
38
- }, I = () => {
25
+ }), x = v(() => d.value <= Math.floor(g / 2) ? 1 : d.value >= f.value - Math.floor(g / 2) ? Math.max(f.value - g + 1, 1) : d.value - Math.floor(g / 2)), y = v(() => Math.min(x.value + g - 1, f.value)), f = v(() => Math.ceil(s.totalRecords / s.rowsPerPage)), $ = v(() => {
26
+ const p = [];
27
+ for (let h = x.value; h <= y.value; h++)
28
+ p.push(h);
29
+ return p;
30
+ }), V = (p) => {
31
+ p >= 1 && p <= f.value && (d.value = p);
32
+ }, O = () => {
39
33
  d.value > 1 && d.value--;
40
- }, C = () => {
41
- d.value < u.value && d.value++;
34
+ }, R = () => {
35
+ d.value < f.value && d.value++;
42
36
  };
43
- return (m, g) => (r(), i("div", ae, [
44
- o("ul", {
45
- class: "pagination pagination-sm mb-0 justify-content-center text-center",
46
- id: e.tablename + "-paginate-parent"
47
- }, [
48
- o("li", le, [
49
- o("button", {
50
- onClick: I,
51
- type: "button",
52
- class: w([e.tablename + "-paginate-navigators page-link", { disabled: d.value === 1 }]),
53
- disabled: d.value === 1
54
- }, " << ", 10, ne)
37
+ return (p, h) => (r(), n("div", {
38
+ class: "vs-pagination",
39
+ id: l.tablename + "-pagination"
40
+ }, [
41
+ o("button", {
42
+ onClick: O,
43
+ type: "button",
44
+ class: "vs-pagination-button vs-pagination-nav",
45
+ disabled: d.value === 1
46
+ }, " ‹‹ ", 8, oe),
47
+ x.value > 1 ? (r(), n("button", {
48
+ key: 0,
49
+ type: "button",
50
+ class: "vs-pagination-button",
51
+ onClick: h[0] || (h[0] = (m) => V(1))
52
+ }, " 1 ")) : k("", !0),
53
+ x.value > 2 ? (r(), n("span", ne, "...")) : k("", !0),
54
+ (r(!0), n(M, null, D($.value, (m) => (r(), n("button", {
55
+ key: m,
56
+ type: "button",
57
+ class: w([
58
+ "vs-pagination-button",
59
+ { "vs-active": d.value === m }
55
60
  ]),
56
- x.value > 1 ? (r(), i("li", re, [
57
- o("button", {
58
- type: "button",
59
- class: "page-link me-2",
60
- onClick: g[0] || (g[0] = (_) => V(1))
61
- }, "1"),
62
- x.value > 2 ? (r(), i("span", ie, "...")) : k("", !0)
63
- ])) : k("", !0),
64
- (r(!0), i(R, null, L(P.value, (_) => (r(), i("li", {
65
- key: _,
66
- class: "page-item"
67
- }, [
68
- o("button", {
69
- type: "button",
70
- class: w([d.value === _ ? "active" : "", "page-link", e.tablename + "-paginate-button"]),
71
- id: e.tablename + "-navigateButton-" + _,
72
- onClick: (T) => V(_)
73
- }, y(_), 11, de)
74
- ]))), 128)),
75
- $.value < u.value ? (r(), i("li", ce, [
76
- $.value < u.value - 1 ? (r(), i("span", ue, "...")) : k("", !0),
77
- o("button", {
78
- type: "button",
79
- class: "page-link",
80
- onClick: g[1] || (g[1] = (_) => V(u.value))
81
- }, y(u.value), 1)
82
- ])) : k("", !0),
83
- o("li", pe, [
84
- o("button", {
85
- onClick: C,
86
- type: "button",
87
- class: w([e.tablename + "-paginate-navigators page-link", { disabled: d.value === u.value }]),
88
- disabled: d.value === u.value
89
- }, " >> ", 10, ve)
90
- ])
91
- ], 8, oe)
92
- ], 512));
61
+ id: l.tablename + "-page-" + m,
62
+ onClick: (N) => V(m)
63
+ }, b(m), 11, re))), 128)),
64
+ y.value < f.value - 1 ? (r(), n("span", ie, "...")) : k("", !0),
65
+ y.value < f.value ? (r(), n("button", {
66
+ key: 3,
67
+ type: "button",
68
+ class: "vs-pagination-button",
69
+ onClick: h[1] || (h[1] = (m) => V(f.value))
70
+ }, b(f.value), 1)) : k("", !0),
71
+ o("button", {
72
+ onClick: R,
73
+ type: "button",
74
+ class: "vs-pagination-button vs-pagination-nav",
75
+ disabled: d.value === f.value
76
+ }, " ›› ", 8, de)
77
+ ], 8, le));
93
78
  }
94
- }), G = (e, b) => {
95
- const t = e.__vccOpts || e;
96
- for (const [c, h] of b)
97
- t[c] = h;
98
- return t;
99
- }, he = /* @__PURE__ */ G(fe, [["__scopeId", "data-v-126f4cdf"]]), me = { class: "flex-fill position-relative" }, ge = { class: "input-group" }, be = ["placeholder", "value"], _e = /* @__PURE__ */ H({
79
+ }), j = (l, C) => {
80
+ const s = l.__vccOpts || l;
81
+ for (const [c, g] of C)
82
+ s[c] = g;
83
+ return s;
84
+ }, ue = /* @__PURE__ */ j(ce, [["__scopeId", "data-v-a6d89ca2"]]), ve = { class: "vs-search" }, he = ["placeholder", "value"], pe = /* @__PURE__ */ K({
100
85
  __name: "VsSearch",
101
86
  props: {
102
87
  modelValue: {},
103
88
  placeholder: {}
104
89
  },
105
90
  emits: ["update:modelValue", "input-typed"],
106
- setup(e, { emit: b }) {
107
- const t = b, c = (h) => {
108
- const d = h.target;
109
- t("update:modelValue", d.value), t("input-typed", d.value);
91
+ setup(l, { emit: C }) {
92
+ const s = C, c = (g) => {
93
+ const d = g.target;
94
+ s("update:modelValue", d.value), s("input-typed", d.value);
110
95
  };
111
- return (h, d) => (r(), i("div", me, [
112
- o("div", ge, [
113
- d[0] || (d[0] = o("div", {
114
- class: "input-group-text position-absolute top-0 bottom-0 bg-none border-0",
115
- style: { "z-index": "1020" }
96
+ return (g, d) => (r(), n("div", ve, [
97
+ d[0] || (d[0] = o("div", { class: "vs-search-icon" }, [
98
+ o("svg", {
99
+ viewBox: "0 0 24 24",
100
+ fill: "currentColor"
116
101
  }, [
117
- o("i", { class: "fa fa-search opacity-5" })
118
- ], -1)),
119
- o("input", {
120
- type: "text",
121
- class: "form-control ps-35px",
122
- placeholder: e.placeholder,
123
- value: e.modelValue,
124
- onInput: c
125
- }, null, 40, be)
126
- ])
127
- ]));
128
- }
129
- }), ke = /* @__PURE__ */ H({
130
- __name: "Loader",
131
- props: {
132
- height: { default: "50px" }
133
- },
134
- setup(e) {
135
- return (b, t) => (r(), i("div", null, [
136
- o("div", {
137
- class: "loader",
138
- style: E({ height: e.height })
139
- }, null, 4)
102
+ o("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" })
103
+ ])
104
+ ], -1)),
105
+ o("input", {
106
+ type: "text",
107
+ class: "vs-search-input",
108
+ placeholder: l.placeholder,
109
+ value: l.modelValue,
110
+ onInput: c
111
+ }, null, 40, he)
140
112
  ]));
141
113
  }
142
- }), ye = /* @__PURE__ */ G(ke, [["__scopeId", "data-v-6ad4d2c7"]]), xe = (e, b = "") => `
143
- <svg width="60pt" height="60pt" id="Layer__${e}" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 70 70">
144
- <defs>
145
- <linearGradient id="no-data__rfq_${e}" x1="40.1" y1="64.17" x2="40.1" y2="5.83" gradientUnits="userSpaceOnUse">
146
- <stop offset="0" stop-color="#969698" stop-opacity="0.1" />
147
- <stop offset="1" stop-color="#869ac0" stop-opacity="0.25" />
148
- </linearGradient>
149
- <linearGradient id="no-data__rfq-2_${e}" x1="176.51" y1="-169.09" x2="196.67" y2="-169.09" gradientTransform="matrix(0.73, 0, 0, -0.73, -125.67, -73.17)" gradientUnits="userSpaceOnUse">
150
- <stop offset="0" stop-color="#969698" />
151
- <stop offset="1" stop-color="#869ac0" />
152
- </linearGradient>
153
- <linearGradient id="no-data__rfq-3_${e}" x1="187.34" y1="-148.34" x2="227.34" y2="-148.34" xlink:href="#no-data__rfq-2_${e}" />
154
- </defs>
155
- <path d="M61.25,20.42H46.67V5.83Z" fill="#929aa5" opacity="0.5" style="isolation:isolate" />
156
- <path d="M19,5.83H46.67L61.25,20.42V64.17H19ZM54,27H26.25V29.9H54Zm0,6.56H26.25v2.92H54ZM26.25,40.1H54V43H26.25Zm0,6.57H54v2.91H26.25Z" fill-rule="evenodd" fill="url(#no-data__rfq_${e})" />
157
- <path d="M3,53.35,13.62,42.78l4.12,4.13L7.17,57.48,3,53.35Z" fill-rule="evenodd" fill="url(#no-data__rfq-2_${e})" />
158
- <path d="M37.19,35A11.67,11.67,0,1,0,25.52,46.67,11.68,11.68,0,0,0,37.19,35Zm2.91,0A14.58,14.58,0,1,0,25.52,49.58,14.58,14.58,0,0,0,40.1,35Z" fill-rule="evenodd" fill="url(#no-data__rfq-3_${e})" />
159
- </svg>
160
- <div class="fs-5 fw-700 text-fmdqgray">${b}</div>
161
- `, we = { class: "card-body p-4 vs-table-card-body" }, $e = {
114
+ }), ge = { class: "vs-datatable" }, fe = {
162
115
  key: 0,
163
- class: "input-group mb-4"
164
- }, Ve = { class: "flex-fill position-relative" }, Pe = { class: "input-group" }, Ce = {
116
+ class: "vs-search-container"
117
+ }, be = {
165
118
  ref: "tableResponsiveRef",
166
- class: "table-responsive"
167
- }, Oe = {
119
+ class: "vs-table-wrapper"
120
+ }, me = {
168
121
  key: 0,
122
+ class: "vs-checkbox-column",
169
123
  style: { width: "5%" }
170
- }, Se = { class: "form-check mb-2px" }, Me = ["id", "checked"], Re = ["for"], Le = ["onClick"], He = { class: "d-inline-flex align-items-center gap-1" }, Ie = {
124
+ }, we = { class: "vs-checkbox" }, ye = ["id", "checked"], ke = ["for"], Ce = ["onClick"], xe = { class: "vs-header-content" }, Ve = { class: "vs-header-label" }, Pe = {
171
125
  key: 0,
172
- class: "sort-container flex-column"
173
- }, Te = {
126
+ class: "vs-sort-icons"
127
+ }, Se = {
174
128
  key: 1,
175
- class: "badge bg-secondary sort-badge"
176
- }, Be = { key: 0 }, Ze = {
177
- colspan: "100%",
178
- class: "text-center"
179
- }, qe = { key: 1 }, Ue = {
180
- colspan: "100%",
181
- class: "text-center"
182
- }, Ae = ["innerHTML"], De = ["onClick"], Ge = { class: "form-check mb-2px" }, Ne = ["id", "value"], ze = ["for"], Ee = { class: "d-md-flex align-items-center mt-1" }, je = {
129
+ class: "vs-sort-priority"
130
+ }, $e = { key: 0 }, Oe = ["colspan"], Re = { key: 1 }, Te = ["colspan"], Ie = { class: "vs-no-data-message" }, _e = { class: "vs-no-data-description" }, Me = ["onClick"], De = { class: "vs-checkbox" }, Be = ["id", "value"], Le = ["for"], ze = { class: "vs-table-footer" }, He = {
183
131
  key: 0,
184
- class: "me-md-auto text-md-left text-center mb-2 mb-md-0"
185
- }, Fe = {
132
+ class: "vs-table-info"
133
+ }, Ke = {
186
134
  key: 1,
187
- class: "me-md-auto"
188
- }, Ke = /* @__PURE__ */ H({
135
+ class: "vs-table-info"
136
+ }, Ne = /* @__PURE__ */ K({
189
137
  __name: "VsDataTable",
190
138
  props: {
191
139
  rows: { default: () => [] },
@@ -201,207 +149,253 @@ import './index.css';const ae = { ref: "vsPagination" }, oe = ["id"], le = { cla
201
149
  showSearch: { type: Boolean, default: !0 },
202
150
  tableClass: {},
203
151
  rowClass: {},
204
- showRowEntries: { type: Boolean, default: !0 }
152
+ showRowEntries: { type: Boolean, default: !0 },
153
+ containerClass: {},
154
+ headerClass: {},
155
+ cellClass: {},
156
+ searchClass: {},
157
+ paginationClass: {},
158
+ searchPlaceholder: { default: "Search..." },
159
+ loadingText: { default: "Loading..." },
160
+ noDataText: { default: "No data available" },
161
+ noDataDescription: { default: "Try adjusting your search criteria" },
162
+ entriesText: { default: "entries" },
163
+ maxVisiblePages: { default: 5 },
164
+ rowKey: { type: [String, Function], default: "id" }
205
165
  },
206
- emits: ["update:itemSelected", "update:serverItemsLength", "update:serverOptions", "input-typed", "page-updated", "sort-changed", "row-click"],
207
- setup(e, { emit: b }) {
208
- const t = e, c = b, h = K(), d = p(() => !!h.onRowClick);
209
- function x(s, l) {
210
- return l.split(".").reduce((n, a) => n?.[a], s) ?? "";
166
+ emits: ["update:itemSelected", "update:serverItemsLength", "update:serverOptions", "update:sort", "input-typed", "page-updated", "sort-changed", "row-click"],
167
+ setup(l, { emit: C }) {
168
+ const s = l, c = C, g = W(), d = v(() => !!g.onRowClick), x = v(() => s.columns.length + (z.value ? 1 : 0)), y = (t, a) => typeof s.rowKey == "function" ? s.rowKey(t, a) : t[s.rowKey] || a, f = (t) => P.value.some((a) => y(a, -1) === y(t, -1));
169
+ function $(t, a) {
170
+ return a.split(".").reduce((e, i) => e?.[i], t) ?? "";
211
171
  }
212
- const $ = (s) => t.serverOptions?.sort?.some((l) => l.field === s), u = (s) => {
213
- const l = t.serverOptions?.sort?.find((n) => n.field === s);
214
- return l ? l.priority ?? null : null;
215
- }, P = (s) => t.serverOptions?.sort?.find((l) => l.field === s)?.order ?? null, V = p(() => {
216
- const s = t.serverOptions?.sort ?? [];
217
- if (!s.length) return t.rows;
218
- const l = (n, a) => a.split(".").reduce((v, f) => v?.[f], n) ?? "";
219
- return [...t.rows].sort((n, a) => {
220
- for (const { field: v, order: f } of s) {
221
- const q = l(n, v), U = l(a, v);
222
- if (q !== U)
223
- return f === "asc" ? q > U ? 1 : -1 : q < U ? 1 : -1;
172
+ const V = (t) => h.value.some((a) => a.field === t), O = (t) => {
173
+ const a = h.value.find((e) => e.field === t);
174
+ return a ? a.priority ?? null : null;
175
+ }, R = (t) => h.value.find((a) => a.field === t)?.order ?? null, p = I(s.sort ?? []);
176
+ X(
177
+ () => s.sort,
178
+ (t) => {
179
+ t && (p.value = [...t]);
180
+ },
181
+ { deep: !0 }
182
+ );
183
+ const h = v(() => s.serverOptions?.sort ?? p.value ?? []), m = v(() => {
184
+ if (!h.value.length) return s.rows;
185
+ const t = (a, e) => e.split(".").reduce((i, u) => i?.[u], a) ?? "";
186
+ return [...s.rows].sort((a, e) => {
187
+ for (const { field: i, order: u } of h.value) {
188
+ const S = t(a, i), H = t(e, i);
189
+ if (S !== H)
190
+ return u === "asc" ? S > H ? 1 : -1 : S < H ? 1 : -1;
224
191
  }
225
192
  return 0;
226
193
  });
227
- }), I = (s, l) => {
228
- if (!t.serverOptions) return;
229
- let n = [...t.serverOptions.sort || []];
230
- const a = n.findIndex((v) => v.field === s);
231
- l.shiftKey ? a === -1 ? n.push({ field: s, order: "asc" }) : n[a]?.order === "asc" ? n[a].order = "desc" : n.splice(a, 1) : a === -1 ? n = [{ field: s, order: "asc" }] : n[a]?.order === "asc" ? n = [{ field: s, order: "desc" }] : n = [], n = n.map((v, f) => ({ ...v, priority: f + 1 })), c("update:serverOptions", { ...t.serverOptions, sort: n }), c("sort-changed", { sort: n });
232
- }, C = A(""), m = (s) => c("input-typed", s), g = A(10), _ = p({
233
- get: () => t.serverOptions?.rowsPerPage ?? g.value,
234
- set: (s) => {
235
- t.serverOptions ? c("update:serverOptions", { ...t.serverOptions, rowsPerPage: s }) : g.value = s;
194
+ }), N = (t, a) => {
195
+ let e = [...h.value];
196
+ const i = e.findIndex((u) => u.field === t);
197
+ a.shiftKey ? i === -1 ? e.push({ field: t, order: "asc" }) : e[i]?.order === "asc" ? e[i].order = "desc" : e.splice(i, 1) : i === -1 ? e = [{ field: t, order: "asc" }] : e[i]?.order === "asc" ? e = [{ field: t, order: "desc" }] : e = [], e = e.map((u, S) => ({ ...u, priority: S + 1 })), s.serverOptions ? c("update:serverOptions", { ...s.serverOptions, sort: e }) : (p.value = e, c("update:sort", e), c("sort-changed", { sort: e }));
198
+ }, A = I(""), Q = (t) => c("input-typed", t), E = I(10), q = v({
199
+ get: () => s.serverOptions?.rowsPerPage ?? E.value,
200
+ set: (t) => {
201
+ s.serverOptions ? c("update:serverOptions", { ...s.serverOptions, rowsPerPage: t }) : E.value = t;
236
202
  }
237
- }), T = A(1), B = p({
238
- get: () => t.serverItemsLength !== void 0 ? t.serverItemsLength : t.rows.length,
239
- set: (s) => {
240
- t.serverItemsLength !== void 0 && c("update:serverItemsLength", s);
203
+ }), U = I(1), B = v({
204
+ get: () => s.serverItemsLength !== void 0 ? s.serverItemsLength : s.rows.length,
205
+ set: (t) => {
206
+ s.serverItemsLength !== void 0 && c("update:serverItemsLength", t);
241
207
  }
242
- }), O = p({
243
- get: () => t.serverOptions?.page ?? T.value,
244
- set: (s) => {
245
- t.serverOptions ? c("update:serverOptions", { ...t.serverOptions, page: s }) : T.value = s;
208
+ }), T = v({
209
+ get: () => s.serverOptions?.page ?? U.value,
210
+ set: (t) => {
211
+ s.serverOptions ? c("update:serverOptions", { ...s.serverOptions, page: t }) : U.value = t;
246
212
  }
247
- }), j = (s) => {
248
- t.serverOptions && c("update:serverOptions", { ...t.serverOptions, page: s }), c("page-updated", s);
249
- }, Z = p(() => {
250
- const s = t.serverOptions?.rowsPerPage ?? 10, l = (O.value - 1) * s + 1, n = Math.min(O.value * s, B.value);
251
- return { start: l, end: n };
252
- }), S = p({
253
- get: () => t.itemSelected || [],
254
- set: (s) => c("update:itemSelected", s)
255
- }), N = p(() => t.itemSelected !== null), z = p(() => t.rows.length > 0 && S.value.length === t.rows.length), F = () => {
256
- S.value = z.value ? [] : [...t.rows];
213
+ }), G = (t) => {
214
+ s.serverOptions && c("update:serverOptions", { ...s.serverOptions, page: t }), c("page-updated", t);
215
+ }, L = v(() => {
216
+ const t = s.serverOptions?.rowsPerPage ?? 10, a = (T.value - 1) * t + 1, e = Math.min(T.value * t, B.value);
217
+ return { start: a, end: e };
218
+ }), P = v({
219
+ get: () => s.itemSelected || [],
220
+ set: (t) => c("update:itemSelected", t)
221
+ }), z = v(() => s.itemSelected !== null), F = v(
222
+ () => s.rows.length > 0 && P.value.length === s.rows.length
223
+ ), J = () => {
224
+ P.value = F.value ? [] : [...s.rows];
257
225
  };
258
- return (s, l) => {
259
- const n = Q("card");
260
- return r(), J(n, { class: "vs-table-card mb-3" }, {
261
- default: W(() => [
262
- o("div", we, [
263
- e.showSearch ? (r(), i("div", $e, [
264
- o("div", Ve, [
265
- o("div", Pe, [
266
- D(_e, {
267
- modelValue: C.value,
268
- "onUpdate:modelValue": l[0] || (l[0] = (a) => C.value = a),
269
- onInputTyped: m,
270
- placeholder: "Search products"
271
- }, null, 8, ["modelValue"]),
272
- l[4] || (l[4] = o("div", {
273
- class: "input-group-text position-absolute top-0 bottom-0 bg-none border-0",
274
- style: { "z-index": "1020" }
275
- }, [
276
- o("i", { class: "fa fa-search opacity-5" })
277
- ], -1))
278
- ])
279
- ]),
280
- M(s.$slots, "filterArea", {}, void 0, !0)
281
- ])) : k("", !0),
282
- o("div", Ce, [
283
- o("table", {
284
- class: w(["table table-hover text-nowrap vs-table", e.tableClass])
285
- }, [
286
- o("thead", null, [
287
- o("tr", null, [
288
- N.value ? (r(), i("th", Oe, [
289
- o("div", Se, [
290
- o("input", {
291
- type: "checkbox",
292
- class: "form-check-input",
293
- id: e.tablename + "-main-checkbox",
294
- checked: z.value,
295
- onChange: F
296
- }, null, 40, Me),
297
- o("label", {
298
- class: "form-check-label pt-1px",
299
- for: e.tablename + "-main-checkbox"
300
- }, null, 8, Re)
301
- ])
302
- ])) : k("", !0),
303
- (r(!0), i(R, null, L(e.columns, (a) => (r(), i("th", {
304
- key: a.field,
305
- onClick: (v) => a.sortable ? I(a.field, v) : null,
306
- style: E({ width: a.width + "%", cursor: a.sortable ? "pointer" : "default" }),
307
- class: "border-top-0 pt-0 pb-2"
308
- }, [
309
- M(s.$slots, `header-${a.field}`, {}, () => [
310
- o("div", He, [
311
- o("span", null, y(a.label), 1),
312
- a.sortable ? (r(), i("span", Ie, [
313
- o("i", {
314
- class: w(["fa fa-sort-up sort-icon", { "active-asc": $(a.field) && P(a.field) === "asc" }])
315
- }, null, 2),
316
- o("i", {
317
- class: w(["fa fa-sort-down sort-icon", { "active-desc": $(a.field) && P(a.field) === "desc" }])
318
- }, null, 2)
319
- ])) : k("", !0),
320
- u(a.field) !== null ? (r(), i("span", Te, y(u(a.field)), 1)) : k("", !0)
321
- ])
322
- ], !0)
323
- ], 12, Le))), 128))
226
+ return (t, a) => (r(), n("div", ge, [
227
+ l.showSearch ? (r(), n("div", fe, [
228
+ Z(pe, {
229
+ modelValue: A.value,
230
+ "onUpdate:modelValue": a[0] || (a[0] = (e) => A.value = e),
231
+ onInputTyped: Q,
232
+ placeholder: l.searchPlaceholder,
233
+ class: w(l.searchClass)
234
+ }, null, 8, ["modelValue", "placeholder", "class"]),
235
+ _(t.$slots, "filterArea", {}, void 0, !0)
236
+ ])) : k("", !0),
237
+ o("div", {
238
+ class: w(["vs-table-container", l.containerClass])
239
+ }, [
240
+ o("div", be, [
241
+ o("table", {
242
+ class: w(["vs-table", l.tableClass])
243
+ }, [
244
+ o("thead", null, [
245
+ o("tr", null, [
246
+ z.value ? (r(), n("th", me, [
247
+ o("div", we, [
248
+ o("input", {
249
+ type: "checkbox",
250
+ id: l.tablename + "-main-checkbox",
251
+ checked: F.value,
252
+ onChange: J
253
+ }, null, 40, ye),
254
+ o("label", {
255
+ for: l.tablename + "-main-checkbox"
256
+ }, null, 8, ke)
324
257
  ])
325
- ]),
326
- o("tbody", null, [
327
- e.loading ? (r(), i("tr", Be, [
328
- o("td", Ze, [
329
- D(ye)
258
+ ])) : k("", !0),
259
+ (r(!0), n(M, null, D(l.columns, (e) => (r(), n("th", {
260
+ key: e.field,
261
+ onClick: (i) => e.sortable ? N(e.field, i) : null,
262
+ style: Y({ width: e.width + "%" }),
263
+ class: w([e.sortable ? "vs-sortable" : "", l.headerClass])
264
+ }, [
265
+ _(t.$slots, `header-${e.field}`, { column: e }, () => [
266
+ o("div", xe, [
267
+ o("span", Ve, b(e.label), 1),
268
+ e.sortable ? (r(), n("div", Pe, [
269
+ o("span", {
270
+ class: w(["vs-sort-icon vs-sort-asc", {
271
+ "vs-active": V(e.field) && R(e.field) === "asc"
272
+ }])
273
+ }, [...a[4] || (a[4] = [
274
+ o("svg", {
275
+ xmlns: "http://www.w3.org/2000/svg",
276
+ height: "24px",
277
+ viewBox: "0 -960 960 960",
278
+ width: "24px"
279
+ }, [
280
+ o("path", { d: "m280-400 200-200 200 200H280Z" })
281
+ ], -1)
282
+ ])], 2),
283
+ o("span", {
284
+ class: w(["vs-sort-icon vs-sort-desc", {
285
+ "vs-active": V(e.field) && R(e.field) === "desc"
286
+ }])
287
+ }, [...a[5] || (a[5] = [
288
+ o("svg", {
289
+ xmlns: "http://www.w3.org/2000/svg",
290
+ height: "24px",
291
+ viewBox: "0 -960 960 960",
292
+ width: "24px"
293
+ }, [
294
+ o("path", { d: "M480-360 280-560h400L480-360Z" })
295
+ ], -1)
296
+ ])], 2)
297
+ ])) : k("", !0),
298
+ O(e.field) !== null ? (r(), n("span", Se, b(O(e.field)), 1)) : k("", !0)
330
299
  ])
331
- ])) : V.value.length ? (r(!0), i(R, { key: 2 }, L(V.value, (a, v) => (r(), i("tr", {
332
- key: v,
333
- class: w([e.rowClass, { "cursor-pointer": d.value }]),
334
- onClick: (f) => s.$emit("row-click", a, v)
335
- }, [
336
- N.value ? (r(), i("td", {
337
- key: 0,
338
- onClick: l[2] || (l[2] = Y(() => {
339
- }, ["stop"]))
340
- }, [
341
- o("div", Ge, [
342
- ee(o("input", {
343
- type: "checkbox",
344
- class: "form-check-input",
345
- id: e.tablename + "-checkbox-" + a.id,
346
- value: a,
347
- "onUpdate:modelValue": l[1] || (l[1] = (f) => S.value = f)
348
- }, null, 8, Ne), [
349
- [te, S.value]
350
- ]),
351
- o("label", {
352
- class: "form-check-label pt-1px",
353
- for: e.tablename + "-checkbox-" + a.id
354
- }, null, 8, ze)
300
+ ], !0)
301
+ ], 14, Ce))), 128))
302
+ ])
303
+ ]),
304
+ o("tbody", null, [
305
+ l.loading ? (r(), n("tr", $e, [
306
+ o("td", {
307
+ colspan: x.value,
308
+ class: "vs-loading"
309
+ }, [
310
+ a[6] || (a[6] = o("div", { class: "vs-spinner" }, null, -1)),
311
+ o("span", null, b(l.loadingText), 1)
312
+ ], 8, Oe)
313
+ ])) : m.value.length ? (r(!0), n(M, { key: 2 }, D(m.value, (e, i) => (r(), n("tr", {
314
+ key: y(e, i),
315
+ class: w([
316
+ l.rowClass,
317
+ { "vs-row-clickable": d.value },
318
+ { "vs-row-selected": f(e) }
319
+ ]),
320
+ onClick: (u) => t.$emit("row-click", e, i)
321
+ }, [
322
+ z.value ? (r(), n("td", {
323
+ key: 0,
324
+ onClick: a[2] || (a[2] = ee(() => {
325
+ }, ["stop"])),
326
+ class: "vs-checkbox-column"
327
+ }, [
328
+ o("div", De, [
329
+ te(o("input", {
330
+ type: "checkbox",
331
+ id: l.tablename + "-checkbox-" + y(e, i),
332
+ value: e,
333
+ "onUpdate:modelValue": a[1] || (a[1] = (u) => P.value = u)
334
+ }, null, 8, Be), [
335
+ [se, P.value]
336
+ ]),
337
+ o("label", {
338
+ for: l.tablename + "-checkbox-" + y(e, i)
339
+ }, null, 8, Le)
340
+ ])
341
+ ])) : k("", !0),
342
+ (r(!0), n(M, null, D(l.columns, (u) => (r(), n("td", {
343
+ key: u.field,
344
+ class: w(l.cellClass)
345
+ }, [
346
+ _(t.$slots, `cell-${u.field}`, {
347
+ item: e,
348
+ value: $(e, u.field),
349
+ column: u,
350
+ index: i
351
+ }, () => [
352
+ ae(b($(e, u.field)), 1)
353
+ ], !0)
354
+ ], 2))), 128))
355
+ ], 10, Me))), 128)) : (r(), n("tr", Re, [
356
+ o("td", {
357
+ colspan: x.value,
358
+ class: "vs-no-data"
359
+ }, [
360
+ _(t.$slots, "no-data", {}, () => [
361
+ a[7] || (a[7] = o("div", { class: "vs-no-data-icon" }, [
362
+ o("svg", {
363
+ viewBox: "0 0 24 24",
364
+ fill: "currentColor"
365
+ }, [
366
+ o("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" })
355
367
  ])
356
- ])) : k("", !0),
357
- (r(!0), i(R, null, L(e.columns, (f) => (r(), i("td", {
358
- key: f.field,
359
- class: "align-middle"
360
- }, [
361
- M(s.$slots, `cell-${f.field}`, {
362
- item: a,
363
- value: x(a, f.field)
364
- }, () => [
365
- se(y(x(a, f.field)), 1)
366
- ], !0)
367
- ]))), 128))
368
- ], 10, De))), 128)) : (r(), i("tr", qe, [
369
- o("td", Ue, [
370
- M(s.$slots, "no-data", {}, () => [
371
- o("div", {
372
- innerHTML: X(xe)("vs-table-no_data", "No data available")
373
- }, null, 8, Ae)
374
- ], !0)
375
- ])
376
- ]))
377
- ])
378
- ], 2)
379
- ], 512),
380
- o("div", Ee, [
381
- e.showRowEntries ? (r(), i("div", je, " Showing " + y(Z.value.start < 1 ? 0 : Z.value.start) + " to " + y(Z.value.end) + " of " + y(B.value) + " entries ", 1)) : (r(), i("div", Fe)),
382
- D(he, {
383
- modelValue: O.value,
384
- "onUpdate:modelValue": l[3] || (l[3] = (a) => O.value = a),
385
- totalRecords: B.value,
386
- rowsPerPage: _.value,
387
- maxVisible: 3,
388
- tablename: e.tablename,
389
- class: "text-center",
390
- onPageChanged: j
391
- }, null, 8, ["modelValue", "totalRecords", "rowsPerPage", "tablename"])
368
+ ], -1)),
369
+ o("div", Ie, b(l.noDataText), 1),
370
+ o("div", _e, b(l.noDataDescription), 1)
371
+ ], !0)
372
+ ], 8, Te)
373
+ ]))
392
374
  ])
393
- ])
394
- ]),
395
- _: 3
396
- });
397
- };
375
+ ], 2)
376
+ ], 512)
377
+ ], 2),
378
+ o("div", ze, [
379
+ l.showRowEntries ? (r(), n("div", He, "showing " + b(L.value.start < 1 ? 0 : L.value.start) + " - " + b(L.value.end) + " of " + b(B.value) + " " + b(l.entriesText), 1)) : (r(), n("div", Ke)),
380
+ Z(ue, {
381
+ modelValue: T.value,
382
+ "onUpdate:modelValue": a[3] || (a[3] = (e) => T.value = e),
383
+ totalRecords: B.value,
384
+ rowsPerPage: q.value,
385
+ maxVisible: l.maxVisiblePages,
386
+ tablename: l.tablename,
387
+ class: w(l.paginationClass),
388
+ onPageChanged: G
389
+ }, null, 8, ["modelValue", "totalRecords", "rowsPerPage", "maxVisible", "tablename", "class"])
390
+ ])
391
+ ]));
398
392
  }
399
- }), Qe = /* @__PURE__ */ G(Ke, [["__scopeId", "data-v-48b15b64"]]), We = {
400
- install(e) {
401
- e.component("VsDataTable", Qe);
393
+ }), Ae = /* @__PURE__ */ j(Ne, [["__scopeId", "data-v-73862aa1"]]), Ue = {
394
+ install(l) {
395
+ l.component("VsDataTable", Ae);
402
396
  }
403
397
  };
404
398
  export {
405
- Qe as VsDataTable,
406
- We as default
399
+ Ae as VsDataTable,
400
+ Ue as default
407
401
  };