vueye-table 2.0.0-alpha.3 → 2.0.0-alpha.4

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.
Files changed (26) hide show
  1. package/LICENSE +14 -13
  2. package/README.md +56 -30
  3. package/dist/components/core/VueyeTable/VueyeTable.vue.d.ts +10 -10
  4. package/dist/components/core/VueyeTable/api.d.ts +14 -0
  5. package/dist/components/core/VueyeTable/{VueyeBody → components/VueyeBody}/VueyeBody.vue.d.ts +8 -9
  6. package/dist/components/core/VueyeTable/components/VueyeBody/index.d.ts +2 -0
  7. package/dist/components/core/VueyeTable/components/VueyeDropdown/api.d.ts +17 -0
  8. package/dist/components/core/VueyeTable/components/VueyeDropdown/index.d.ts +4 -0
  9. package/dist/components/core/VueyeTable/{VueyeHead → components/VueyeHead}/VueyeHead.vue.d.ts +1 -2
  10. package/dist/components/core/VueyeTable/components/VueyePagination/index.d.ts +2 -0
  11. package/dist/components/core/VueyeTable/components/index.d.ts +4 -0
  12. package/dist/components/core/VueyeTable/composables/index.d.ts +3 -0
  13. package/dist/components/core/VueyeTable/composables/usePagination.d.ts +11 -0
  14. package/dist/components/core/VueyeTable/types/Utils.d.ts +6 -0
  15. package/dist/style.css +1 -1
  16. package/dist/vueye-table.js +308 -369
  17. package/dist/vueye-table.umd.cjs +1 -1
  18. package/package.json +11 -2
  19. package/dist/components/core/VueyeTable/VSelect.d.ts +0 -15
  20. package/dist/components/core/VueyeTable/VueyeBody/index.d.ts +0 -2
  21. package/dist/components/core/VueyeTable/VueyePagination/index.d.ts +0 -6
  22. package/dist/components/core/VueyeTable/util-components/VueyeDropdown.vue.d.ts +0 -53
  23. package/dist/data/product.d.ts +0 -14
  24. package/dist/data/user.d.ts +0 -22
  25. package/dist/components/core/VueyeTable/{VueyeHead → components/VueyeHead}/index.d.ts +0 -0
  26. package/dist/components/core/VueyeTable/{VueyePagination → components/VueyePagination}/VueyePagination.vue.d.ts +11 -11
@@ -1,174 +1,171 @@
1
- import { getCurrentScope as W, onScopeDispose as x, unref as p, watch as z, defineComponent as S, ref as E, computed as P, watchEffect as F, openBlock as f, createElementBlock as g, createElementVNode as u, toDisplayString as b, Fragment as w, renderList as $, normalizeClass as O, createCommentVNode as U, createVNode as A, pushScopeId as q, popScopeId as G, renderSlot as k, createTextVNode as T, toRef as J, useSlots as Q, createSlots as X, withCtx as Y, normalizeProps as Z, guardReactiveProps as ee } from "vue";
2
- function te(n) {
3
- return W() ? (x(n), !0) : !1;
4
- }
5
- function H(n) {
6
- return typeof n == "function" ? n() : p(n);
7
- }
8
- const M = typeof window < "u" && typeof document < "u", ne = Object.prototype.toString, ae = (n) => ne.call(n) === "[object Object]", B = () => {
9
- }, oe = /* @__PURE__ */ se();
10
- function se() {
11
- var n;
12
- return M && ((n = window == null ? void 0 : window.navigator) == null ? void 0 : n.userAgent) && /* @__PURE__ */ /iP(ad|hone|od)/.test(window.navigator.userAgent);
13
- }
14
- function V(n) {
15
- var a;
16
- const e = H(n);
17
- return (a = e == null ? void 0 : e.$el) != null ? a : e;
18
- }
19
- const D = M ? window : void 0;
20
- function I(...n) {
21
- let a, e, t, r;
22
- if (typeof n[0] == "string" || Array.isArray(n[0]) ? ([e, t, r] = n, a = D) : [a, e, t, r] = n, !a)
23
- return B;
24
- Array.isArray(e) || (e = [e]), Array.isArray(t) || (t = [t]);
25
- const s = [], c = () => {
26
- s.forEach((l) => l()), s.length = 0;
27
- }, _ = (l, h, i, o) => (l.addEventListener(h, i, o), () => l.removeEventListener(h, i, o)), m = z(
28
- () => [V(a), H(r)],
29
- ([l, h]) => {
30
- if (c(), !l)
31
- return;
32
- const i = ae(h) ? { ...h } : h;
33
- s.push(
34
- ...e.flatMap((o) => t.map((d) => _(l, o, d, i)))
35
- );
36
- },
37
- { immediate: !0, flush: "post" }
38
- ), y = () => {
39
- m(), c();
40
- };
41
- return te(y), y;
42
- }
43
- let N = !1;
44
- function re(n, a, e = {}) {
45
- const { window: t = D, ignore: r = [], capture: s = !0, detectIframe: c = !1 } = e;
46
- if (!t)
47
- return;
48
- oe && !N && (N = !0, Array.from(t.document.body.children).forEach((i) => i.addEventListener("click", B)), t.document.documentElement.addEventListener("click", B));
49
- let _ = !0;
50
- const m = (i) => r.some((o) => {
51
- if (typeof o == "string")
52
- return Array.from(t.document.querySelectorAll(o)).some((d) => d === i.target || i.composedPath().includes(d));
53
- {
54
- const d = V(o);
55
- return d && (i.target === d || i.composedPath().includes(d));
56
- }
57
- }), l = [
58
- I(t, "click", (i) => {
59
- const o = V(n);
60
- if (!(!o || o === i.target || i.composedPath().includes(o))) {
61
- if (i.detail === 0 && (_ = !m(i)), !_) {
62
- _ = !0;
63
- return;
64
- }
65
- a(i);
66
- }
67
- }, { passive: !0, capture: s }),
68
- I(t, "pointerdown", (i) => {
69
- const o = V(n);
70
- o && (_ = !i.composedPath().includes(o) && !m(i));
71
- }, { passive: !0 }),
72
- c && I(t, "blur", (i) => {
73
- setTimeout(() => {
74
- var o;
75
- const d = V(n);
76
- ((o = t.document.activeElement) == null ? void 0 : o.tagName) === "IFRAME" && !(d != null && d.contains(t.document.activeElement)) && a(i);
77
- }, 0);
78
- })
79
- ].filter(Boolean);
80
- return () => l.forEach((i) => i());
81
- }
82
- const le = { class: "relative" }, ue = ["aria-expanded"], ie = /* @__PURE__ */ u("span", { class: "i-solar-alt-arrow-down-linear" }, null, -1), ce = {
1
+ import { defineComponent as C, mergeDefaults as H, ref as S, computed as h, watchEffect as T, openBlock as i, createElementBlock as d, createElementVNode as r, unref as u, toDisplayString as f, createCommentVNode as B, Fragment as $, renderList as v, normalizeClass as k, renderSlot as m, createTextVNode as j, createVNode as O, toRef as U, useSlots as K, createSlots as M, withCtx as I, normalizeProps as L, guardReactiveProps as z } from "vue";
2
+ const A = {
3
+ itemValue: "id",
4
+ columnHeaders: () => [],
5
+ data: () => [],
6
+ perPage: 10,
7
+ currentPage: 1,
8
+ perPageOptions: () => [5, 10, 20, 30],
9
+ loading: !1,
10
+ selectable: !1,
11
+ caption: "",
12
+ summary: ""
13
+ }, F = {
14
+ options: () => [],
15
+ modelValue: "",
16
+ label: ""
17
+ }, W = { class: "dropdown__wrapper" }, q = ["aria-expanded"], G = /* @__PURE__ */ r("span", { class: "i-solar-alt-arrow-down-linear" }, null, -1), J = {
83
18
  class: "py-1",
84
19
  role: "none"
85
- }, de = ["onClick"], pe = /* @__PURE__ */ S({
20
+ }, Q = ["onClick"], X = /* @__PURE__ */ C({
86
21
  __name: "VueyeDropdown",
87
- props: {
88
- options: { default: () => [] },
89
- modelValue: { default: "" },
90
- label: { default: "" },
22
+ props: H({
23
+ options: {},
24
+ modelValue: {},
25
+ label: {},
91
26
  defaultValue: {}
92
- },
27
+ }, F),
93
28
  emits: ["update:modelValue"],
94
- setup(n, { emit: a }) {
95
- const e = n, t = E(null);
96
- re(t, () => {
97
- r.value = !1;
98
- });
99
- const r = E(!1), s = E(-1), c = P(() => e.options[s.value] ?? e.defaultValue), _ = `dropdown-label-${Math.random().toString(36).substring(2, 9)}`;
100
- function m() {
101
- r.value = !r.value;
29
+ setup(s, { emit: t }) {
30
+ const e = s, n = S(!1), l = S(-1), a = h(() => e.options[l.value] ?? e.defaultValue), c = `dropdown-label-${Math.random().toString(36).substring(2, 9)}`;
31
+ function P() {
32
+ n.value = !n.value;
102
33
  }
103
- function y(l) {
104
- s.value = l, r.value = !1, a("update:modelValue", c.value.value);
34
+ function y(_) {
35
+ l.value = _, n.value = !1, t("update:modelValue", a.value.content);
105
36
  }
106
- return F(() => {
107
- const l = e.options.findIndex((h) => h.value === e.modelValue);
108
- l !== -1 && (s.value = l);
109
- }), (l, h) => (f(), g("div", le, [
110
- u("button", {
37
+ return T(() => {
38
+ const _ = e.options.findIndex((p) => p.content === e.modelValue);
39
+ _ !== -1 && (l.value = _);
40
+ }), (_, p) => (i(), d("div", W, [
41
+ r("button", {
111
42
  type: "button",
112
- class: "bg-slate-100 dark:bg-primary-900 border flex items-center space-x-2 rtl:space-x-reverse border-primary-300 dark:border-primary-900 rounded-md shadow-sm py-2 px-4 text-sm font-medium text-slate-700 dark:text-slate-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",
113
- onClick: m,
114
- "aria-expanded": p(r),
43
+ class: "dropdown__trigger",
44
+ onClick: P,
45
+ "aria-expanded": u(n),
115
46
  "aria-haspopup": !0,
116
47
  ref: "buttonRef"
117
48
  }, [
118
- u("span", null, b(p(c).label), 1),
119
- ie
120
- ], 8, ue),
121
- p(r) ? (f(), g("div", {
49
+ r("span", null, f(u(a).label), 1),
50
+ G
51
+ ], 8, q),
52
+ u(n) ? (i(), d("div", {
122
53
  key: 0,
123
- class: "origin-top-right bottom-full absolute right-0 mt-2 w-56 rounded-md shadow-lg bg-slate-100 dark:bg-primary-950 ring-1 ring-black ring-opacity-5 focus:outline-none z-40",
54
+ class: "dropdown__overlay",
55
+ onClick: P
56
+ })) : B("", !0),
57
+ u(n) ? (i(), d("div", {
58
+ key: 1,
59
+ class: "dropdown__menu",
124
60
  role: "menu",
125
61
  "aria-orientation": "vertical",
126
- "aria-labelledby": _,
127
- ref_key: "target",
128
- ref: t
62
+ "aria-labelledby": c
129
63
  }, [
130
- u("div", ce, [
131
- (f(!0), g(w, null, $(l.options, (i, o) => (f(), g("button", {
132
- key: o,
133
- class: O([{
134
- "text-slate-700 bg-slate-200 dark:text-slate-300 dark:bg-primary-900 ": o === p(s),
135
- "text-slate-700 dark:text-slate-50 hover:bg-slate-50": o !== p(s)
136
- }, "block px-4 py-2 text-sm text-left w-full text-slate-700 dark:text-slate-50 hover:bg-slate-200 hover:text-slate-900 focus:outline-none focus:bg-slate-100 focus:text-slate-900 dark:hover:text-slate-300 dark:hover:bg-primary-900"]),
64
+ r("div", J, [
65
+ (i(!0), d($, null, v(_.options, (w, b) => (i(), d("button", {
66
+ key: b,
67
+ class: k([{
68
+ "dropdown__menu__item--selected ": b === u(l)
69
+ }, "dropdown__menu__item"]),
137
70
  role: "menuitem",
138
- onClick: (d) => y(o)
139
- }, b(i.label), 11, de))), 128))
71
+ onClick: (o) => y(b)
72
+ }, f(w.label), 11, Q))), 128))
140
73
  ])
141
- ], 512)) : U("", !0)
74
+ ])) : B("", !0)
142
75
  ]));
143
76
  }
144
- }), v = (n) => (q("data-v-d06f6d12"), n = n(), G(), n), fe = { class: "pagination__wrapper" }, ge = { class: "pagination__details" }, _e = { class: "pagination__btn-list" }, he = ["disabled"], me = /* @__PURE__ */ v(() => /* @__PURE__ */ u("span", { class: "sr-only" }, "First page", -1)), be = /* @__PURE__ */ v(() => /* @__PURE__ */ u("span", {
77
+ });
78
+ const Y = { key: 0 }, Z = ["colspan"], x = /* @__PURE__ */ r("div", { class: "flex justify-center items-center" }, [
79
+ /* @__PURE__ */ r("div", { class: "loader animate-spin ease-linear rounded-full border-8 border-t-8 border-t-primary-300 dark:border-t-primary-800 dark:border-primary-600 border-primary-200 h-16 w-16" })
80
+ ], -1), ee = [
81
+ x
82
+ ], te = ["id"], ne = /* @__PURE__ */ C({
83
+ __name: "VueyeBody",
84
+ props: {
85
+ loading: { type: Boolean, default: !1 },
86
+ bodyRows: { default: () => [] },
87
+ itemValue: { default: "id" }
88
+ },
89
+ setup(s) {
90
+ const t = s, e = h(() => Object.keys(t.bodyRows[0]).length);
91
+ return (n, l) => (i(), d("tbody", null, [
92
+ n.loading ? (i(), d("tr", Y, [
93
+ r("td", { colspan: u(e) }, ee, 8, Z)
94
+ ])) : (i(!0), d($, { key: 1 }, v(n.bodyRows, (a) => (i(), d("tr", {
95
+ key: a[n.itemValue]
96
+ }, [
97
+ m(n.$slots, "default", { row: a }, () => [
98
+ (i(!0), d($, null, v(Object.keys(a), (c) => (i(), d("td", {
99
+ key: `${a[n.itemValue]}.${c}`,
100
+ id: `${a[n.itemValue]}.${c}`
101
+ }, [
102
+ m(n.$slots, "default", {
103
+ cell: a[c],
104
+ key: `${a[n.itemValue]}.${c}`
105
+ }, () => [
106
+ j(f(a[c]), 1)
107
+ ])
108
+ ], 8, te))), 128))
109
+ ])
110
+ ]))), 128))
111
+ ]));
112
+ }
113
+ }), ae = ["colspan", "rowspan", "scope"], se = /* @__PURE__ */ C({
114
+ __name: "VueyeHead",
115
+ props: {
116
+ columnHeaders: { default: () => [] }
117
+ },
118
+ setup(s) {
119
+ return (t, e) => (i(), d("thead", null, [
120
+ (i(!0), d($, null, v(t.columnHeaders, (n, l) => (i(), d("tr", { key: l }, [
121
+ (i(!0), d($, null, v(n, (a) => m(t.$slots, `headerCell.${a.key}`, {
122
+ key: a.key,
123
+ headerCell: a
124
+ }, () => [
125
+ r("th", {
126
+ colspan: a.colSpan,
127
+ rowspan: a.rowSpan,
128
+ scope: a.scope,
129
+ class: k([a.className, "th"])
130
+ }, [
131
+ m(t.$slots, `headerCellContent.${a.key}`, { headerCellContent: a }, () => [
132
+ r("span", {
133
+ class: k(a.labelClassName)
134
+ }, f(a.label), 3)
135
+ ])
136
+ ], 10, ae)
137
+ ])), 128))
138
+ ]))), 128))
139
+ ]));
140
+ }
141
+ }), oe = { class: "pagination__wrapper" }, re = { class: "pagination__details" }, le = { class: "pagination__btn-list" }, ue = ["disabled"], ie = /* @__PURE__ */ r("span", { class: "sr-only" }, "First page", -1), de = /* @__PURE__ */ r("span", {
145
142
  "aria-hidden": "true",
146
143
  class: "i-solar-alt-arrow-left-linear"
147
- }, null, -1)), ye = [
148
- me,
149
- be
150
- ], Pe = ["disabled"], ve = /* @__PURE__ */ v(() => /* @__PURE__ */ u("span", { class: "sr-only" }, "Previous page", -1)), ke = /* @__PURE__ */ v(() => /* @__PURE__ */ u("span", {
144
+ }, null, -1), ce = [
145
+ ie,
146
+ de
147
+ ], pe = ["disabled"], _e = /* @__PURE__ */ r("span", { class: "sr-only" }, "Previous page", -1), ge = /* @__PURE__ */ r("span", {
151
148
  "aria-hidden": "true",
152
149
  class: "i-solar-double-alt-arrow-left-linear"
153
- }, null, -1)), $e = [
154
- ve,
155
- ke
156
- ], we = ["onClick"], Ce = {
150
+ }, null, -1), fe = [
151
+ _e,
152
+ ge
153
+ ], he = ["onClick"], Pe = {
157
154
  key: 1,
158
155
  class: "pagination__btn"
159
- }, Ve = ["disabled"], Oe = /* @__PURE__ */ v(() => /* @__PURE__ */ u("span", { class: "sr-only" }, "Next page", -1)), Se = /* @__PURE__ */ v(() => /* @__PURE__ */ u("span", {
156
+ }, be = ["disabled"], ye = /* @__PURE__ */ r("span", { class: "sr-only" }, "Next page", -1), me = /* @__PURE__ */ r("span", {
160
157
  "aria-hidden": "true",
161
158
  class: "i-solar-alt-arrow-right-linear"
162
- }, null, -1)), Ee = [
163
- Oe,
164
- Se
165
- ], Ae = ["disabled"], Ie = /* @__PURE__ */ v(() => /* @__PURE__ */ u("span", { class: "sr-only" }, "Last page", -1)), Be = /* @__PURE__ */ v(() => /* @__PURE__ */ u("span", {
159
+ }, null, -1), ve = [
160
+ ye,
161
+ me
162
+ ], $e = ["disabled"], Ve = /* @__PURE__ */ r("span", { class: "sr-only" }, "Last page", -1), ke = /* @__PURE__ */ r("span", {
166
163
  "aria-hidden": "true",
167
164
  class: "i-solar-double-alt-arrow-right-linear"
168
- }, null, -1)), Re = [
169
- Ie,
170
- Be
171
- ], je = /* @__PURE__ */ S({
165
+ }, null, -1), Ce = [
166
+ Ve,
167
+ ke
168
+ ], we = /* @__PURE__ */ C({
172
169
  __name: "VueyePagination",
173
170
  props: {
174
171
  perPage: { default: 10 },
@@ -177,301 +174,243 @@ const le = { class: "relative" }, ue = ["aria-expanded"], ie = /* @__PURE__ */ u
177
174
  perPageOptions: { default: () => [10, 20, 30, 40, 50] }
178
175
  },
179
176
  emits: ["update:currentPage", "update:perPage"],
180
- setup(n, { emit: a }) {
181
- const e = n, t = P(() => Math.ceil(e.total / e.perPage)), r = P(() => e.perPageOptions.map((o) => ({
177
+ setup(s, { emit: t }) {
178
+ const e = s, n = h(() => Math.ceil(e.total / e.perPage)), l = h(() => e.perPageOptions.map((o) => ({
182
179
  value: o,
183
180
  label: o.toString()
184
- }))), s = P(() => r.value.find((o) => o.value === e.perPage)), c = P(() => Array.from({ length: t.value }, (o, d) => d + 1).reduce(
185
- (o, d) => (d === 1 || d === e.total || d >= e.currentPage - 2 && d <= e.currentPage + 2 ? o.push(d) : (d === e.currentPage - 3 || d === e.currentPage + 3) && o.push("..."), o),
181
+ }))), a = h(() => l.value.find((o) => o.value === e.perPage)), c = h(() => Array.from({ length: n.value }, (o, g) => g + 1).reduce(
182
+ (o, g) => (g === 1 || g === e.total || g >= e.currentPage - 2 && g <= e.currentPage + 2 ? o.push(g) : (g === e.currentPage - 3 || g === e.currentPage + 3) && o.push("..."), o),
186
183
  []
187
184
  ));
188
- function _() {
189
- e.currentPage < t.value && a("update:currentPage", e.currentPage + 1);
190
- }
191
- function m() {
192
- e.currentPage > 1 && a("update:currentPage", e.currentPage - 1);
185
+ function P() {
186
+ e.currentPage < n.value && t("update:currentPage", e.currentPage + 1);
193
187
  }
194
188
  function y() {
195
- e.currentPage > 1 && a("update:currentPage", 1);
189
+ e.currentPage > 1 && t("update:currentPage", e.currentPage - 1);
190
+ }
191
+ function _() {
192
+ e.currentPage > 1 && t("update:currentPage", 1);
196
193
  }
197
- function l() {
198
- e.currentPage < t.value && a("update:currentPage", e.total);
194
+ function p() {
195
+ e.currentPage < n.value && t("update:currentPage", e.total);
199
196
  }
200
- function h(o) {
201
- o > 0 && o <= t.value && a("update:currentPage", o);
197
+ function w(o) {
198
+ o > 0 && o <= n.value && t("update:currentPage", o);
202
199
  }
203
- function i(o) {
204
- a("update:perPage", Number(o));
200
+ function b(o) {
201
+ t("update:perPage", Number(o));
205
202
  }
206
- return (o, d) => (f(), g("div", fe, [
207
- u("div", null, [
208
- A(pe, {
209
- options: p(r),
210
- "default-value": p(s),
203
+ return (o, g) => (i(), d("div", oe, [
204
+ r("div", null, [
205
+ O(u(X), {
206
+ options: u(l),
207
+ "default-value": u(a),
211
208
  label: "Per page",
212
- "onUpdate:modelValue": i
209
+ "onUpdate:modelValue": b
213
210
  }, null, 8, ["options", "default-value"])
214
211
  ]),
215
- u("div", null, [
216
- u("span", ge, b((o.currentPage - 1) * o.perPage + 1) + " - " + b(o.currentPage * o.perPage > o.total ? o.total : o.currentPage * o.perPage) + " of " + b(o.total), 1)
212
+ r("div", null, [
213
+ r("span", re, f((o.currentPage - 1) * o.perPage + 1) + " - " + f(o.currentPage * o.perPage > o.total ? o.total : o.currentPage * o.perPage) + " of " + f(o.total), 1)
217
214
  ]),
218
- u("ul", _e, [
219
- u("li", null, [
220
- u("button", {
215
+ r("ul", le, [
216
+ r("li", null, [
217
+ r("button", {
221
218
  class: "pagination__btn",
222
- onClick: y,
219
+ onClick: _,
223
220
  disabled: o.currentPage === 1
224
- }, ye, 8, he)
221
+ }, ce, 8, ue)
225
222
  ]),
226
- u("li", null, [
227
- u("button", {
223
+ r("li", null, [
224
+ r("button", {
228
225
  class: "pagination__btn",
229
- onClick: m,
226
+ onClick: y,
230
227
  disabled: o.currentPage === 1
231
- }, $e, 8, Pe)
228
+ }, fe, 8, pe)
232
229
  ]),
233
- (f(!0), g(w, null, $(p(c), (C) => (f(), g("li", { key: C }, [
234
- typeof C == "number" ? (f(), g("button", {
230
+ (i(!0), d($, null, v(u(c), (V) => (i(), d("li", { key: V }, [
231
+ typeof V == "number" ? (i(), d("button", {
235
232
  key: 0,
236
- class: O(["pagination__btn", { "pagination__btn--current": C === o.currentPage }]),
237
- onClick: (Ze) => h(C)
238
- }, b(C), 11, we)) : (f(), g("span", Ce, "..."))
233
+ class: k(["pagination__btn", { "pagination__btn--current": V === o.currentPage }]),
234
+ onClick: (je) => w(V)
235
+ }, f(V), 11, he)) : (i(), d("span", Pe, "..."))
239
236
  ]))), 128)),
240
- u("li", null, [
241
- u("button", {
237
+ r("li", null, [
238
+ r("button", {
242
239
  class: "pagination__btn",
243
- onClick: _,
244
- disabled: o.currentPage === p(t)
245
- }, Ee, 8, Ve)
240
+ onClick: P,
241
+ disabled: o.currentPage === u(n)
242
+ }, ve, 8, be)
246
243
  ]),
247
- u("li", null, [
248
- u("button", {
244
+ r("li", null, [
245
+ r("button", {
249
246
  class: "pagination__btn",
250
- onClick: l,
251
- disabled: o.currentPage === p(t)
252
- }, Re, 8, Ae)
247
+ onClick: p,
248
+ disabled: o.currentPage === u(n)
249
+ }, Ce, 8, $e)
253
250
  ])
254
251
  ])
255
252
  ]));
256
253
  }
257
254
  });
258
- const Le = (n, a) => {
259
- const e = n.__vccOpts || n;
260
- for (const [t, r] of a)
261
- e[t] = r;
262
- return e;
263
- }, Ne = /* @__PURE__ */ Le(je, [["__scopeId", "data-v-d06f6d12"]]);
264
- function R(n) {
265
- let a = 1;
266
- return n.forEach((e) => {
267
- e.children && (a = Math.max(a, R(e.children) + 1));
268
- }), a;
255
+ function R(s) {
256
+ let t = 1;
257
+ return s.forEach((e) => {
258
+ e.children && (t = Math.max(t, R(e.children) + 1));
259
+ }), t;
269
260
  }
270
- function K(n) {
271
- let a = 0;
272
- return n.forEach((e) => {
273
- e.children ? a += K(e.children) : a++;
274
- }), a;
261
+ function N(s) {
262
+ let t = 0;
263
+ return s.forEach((e) => {
264
+ e.children ? t += N(e.children) : t++;
265
+ }), t;
275
266
  }
276
- function j(n, a, e = [], t = 0, r = 0) {
277
- return n.forEach((s) => {
278
- if (e[t] || (e[t] = []), s.children) {
279
- const { children: c, ..._ } = s, m = K(c);
280
- e[t].push({
281
- ..._,
282
- colSpan: m,
267
+ function D(s, t, e = [], n = 0, l = 0) {
268
+ return s.forEach((a) => {
269
+ if (e[n] || (e[n] = []), a.children) {
270
+ const { children: c, ...P } = a, y = N(c);
271
+ e[n].push({
272
+ ...P,
273
+ colSpan: y,
283
274
  scope: "colgroup"
284
- }), j(c, a, e, t + 1, r + 1);
275
+ }), D(c, t, e, n + 1, l + 1);
285
276
  } else {
286
- const c = a - r;
287
- e[t].push({
288
- ...s,
289
- key: s.key,
290
- label: s.label,
277
+ const c = t - l;
278
+ e[n].push({
279
+ ...a,
280
+ key: a.key,
281
+ label: a.label,
291
282
  rowSpan: c,
292
283
  scope: "col"
293
284
  });
294
285
  }
295
286
  }), e;
296
287
  }
297
- function L(n, a = "", e = []) {
298
- return n.forEach((t) => {
299
- t.children ? L(t.children, `${a}${t.key}.`, e) : e.push(`${a}${t.key}`);
288
+ function E(s, t = "", e = []) {
289
+ return s.forEach((n) => {
290
+ n.children ? E(n.children, `${t}${n.key}.`, e) : e.push(`${t}${n.key}`);
300
291
  }), e;
301
292
  }
302
- function tt(n) {
303
- const a = R(n);
304
- return j(n, a).reduce((r, s) => [...r, ...s], []);
293
+ function Ke(s) {
294
+ const t = R(s);
295
+ return D(s, t).reduce((l, a) => [...l, ...a], []);
305
296
  }
306
- const Te = (n, a) => {
307
- const e = a.split(".");
308
- let t = n;
309
- for (let r = 0; r < e.length; r++)
310
- if (t[e[r]])
311
- t = t[e[r]];
297
+ const Oe = (s, t) => {
298
+ const e = t.split(".");
299
+ let n = s;
300
+ for (let l = 0; l < e.length; l++)
301
+ if (n[e[l]])
302
+ n = n[e[l]];
312
303
  else
313
304
  return;
314
- return t;
305
+ return n;
315
306
  };
316
- function He(n, a, e = 0, t = n.length) {
317
- return n.map((r) => L(a).map((s) => ({
318
- [s]: Te(r, s)
319
- })).reduce((s, c) => ({ ...s, ...c }), {})).slice(e, t);
307
+ function Se(s, t, e = 0, n = s.length) {
308
+ return s.map((l) => E(t).map((a) => ({
309
+ [a]: Oe(l, a)
310
+ })).reduce((a, c) => ({ ...a, ...c }), {})).slice(e, n);
311
+ }
312
+ function Me(s) {
313
+ return {
314
+ headerKeys: h(() => E(s.flat()))
315
+ };
316
+ }
317
+ function Be(s = {}) {
318
+ const t = S({
319
+ perPage: s.perPage || 10,
320
+ currentPage: s.currentPage || 1
321
+ });
322
+ function e(l) {
323
+ t.value.currentPage = l;
324
+ }
325
+ function n(l) {
326
+ t.value.perPage = l;
327
+ }
328
+ return {
329
+ pagination: t,
330
+ updateCurrentPage: e,
331
+ updatePerPage: n
332
+ };
320
333
  }
321
- function Me(n, a, e) {
334
+ function Re(s, t, e) {
322
335
  return {
323
- bodyRows: P(() => {
324
- const r = e.value.perPage * (e.value.currentPage - 1), s = e.value.perPage * e.value.currentPage;
325
- return He(n, p(a), r, s);
336
+ bodyRows: h(() => {
337
+ const l = t.value.perPage * (t.value.currentPage - 1), a = t.value.perPage * t.value.currentPage;
338
+ return Se(s, u(e), l, a);
326
339
  })
327
340
  };
328
341
  }
329
- function De(n) {
330
- const a = p(n) ?? [];
342
+ function De(s) {
343
+ const t = u(s) ?? [];
331
344
  return {
332
- headers: P(() => j(a, R(a)))
345
+ headers: h(() => D(t, R(t)))
333
346
  };
334
347
  }
335
- const Ke = { key: 0 }, We = ["colspan"], xe = /* @__PURE__ */ u("div", { class: "flex justify-center items-center" }, [
336
- /* @__PURE__ */ u("div", { class: "loader animate-spin ease-linear rounded-full border-8 border-t-8 border-t-primary-300 dark:border-t-primary-800 dark:border-primary-600 border-primary-200 h-16 w-16" })
337
- ], -1), ze = [
338
- xe
339
- ], Fe = ["id"], Ue = /* @__PURE__ */ S({
340
- __name: "VueyeBody",
341
- props: {
342
- loading: { type: Boolean, default: !1 },
343
- bodyRows: { default: () => [] },
344
- itemValue: { default: "id" }
345
- },
346
- setup(n) {
347
- const a = n, e = P(() => Object.keys(a.bodyRows[0]).length);
348
- return (t, r) => (f(), g("tbody", null, [
349
- t.loading ? (f(), g("tr", Ke, [
350
- u("td", { colspan: p(e) }, ze, 8, We)
351
- ])) : (f(!0), g(w, { key: 1 }, $(t.bodyRows, (s) => (f(), g("tr", {
352
- key: s[t.itemValue]
353
- }, [
354
- k(t.$slots, "default", { row: s }, () => [
355
- (f(!0), g(w, null, $(Object.keys(s), (c) => (f(), g("td", {
356
- key: `${s[t.itemValue]}.${c}`,
357
- id: `${s[t.itemValue]}.${c}`
358
- }, [
359
- k(t.$slots, "default", {
360
- cell: s[c],
361
- key: `${s[t.itemValue]}.${c}`
362
- }, () => [
363
- T(b(s[c]), 1)
364
- ])
365
- ], 8, Fe))), 128))
366
- ])
367
- ]))), 128))
368
- ]));
369
- }
370
- }), qe = ["colspan", "rowspan", "scope"], Ge = /* @__PURE__ */ S({
371
- __name: "VueyeHead",
372
- props: {
373
- columnHeaders: { default: () => [] }
374
- },
375
- setup(n) {
376
- return (a, e) => (f(), g("thead", null, [
377
- (f(!0), g(w, null, $(a.columnHeaders, (t, r) => (f(), g("tr", { key: r }, [
378
- (f(!0), g(w, null, $(t, (s) => k(a.$slots, `headerCell.${s.key}`, {
379
- key: s.key,
380
- headerCell: s
381
- }, () => [
382
- u("th", {
383
- colspan: s.colSpan,
384
- rowspan: s.rowSpan,
385
- scope: s.scope,
386
- class: O([s.className, "th"])
387
- }, [
388
- k(a.$slots, `headerCellContent.${s.key}`, { headerCellContent: s }, () => [
389
- u("span", {
390
- class: O(s.labelClassName)
391
- }, b(s.label), 3)
392
- ])
393
- ], 10, qe)
394
- ])), 128))
395
- ]))), 128))
396
- ]));
397
- }
398
- }), Je = { class: "table__wrapper" }, Qe = { class: "table__caption" }, Xe = { class: "table__summary" }, Ye = { class: "table__pagination-wrapper" }, nt = /* @__PURE__ */ S({
348
+ const Ee = { class: "table__wrapper" }, He = {
349
+ key: 0,
350
+ class: "table__caption"
351
+ }, Ne = { class: "table__summary" }, Te = { class: "table__pagination-wrapper" }, Ie = /* @__PURE__ */ C({
399
352
  inheritAttrs: !1,
400
353
  __name: "VueyeTable",
401
- props: {
402
- itemValue: { default: "id" },
403
- columnHeaders: { default: () => [] },
404
- data: { default: () => [] },
405
- perPage: { default: 10 },
406
- currentPage: { default: 1 },
407
- perPageOptions: { default: () => [5, 10, 20, 30] },
408
- loading: { type: Boolean, default: !1 },
409
- selectable: { type: Boolean, default: !1 },
410
- caption: { default: "" },
411
- summary: { default: "" }
412
- },
413
- setup(n) {
414
- const a = n, e = J(a, "columnHeaders"), t = E({
415
- perPage: a.perPage || 10,
416
- currentPage: a.currentPage || 1
417
- });
418
- console.log(a);
419
- const { headers: r } = De(e), { bodyRows: s } = Me(a.data, e, t), c = Q(), _ = Object.keys(c).filter((l) => l.startsWith("headerCell"));
420
- function m(l) {
421
- t.value.currentPage = l;
422
- }
423
- function y(l) {
424
- t.value.perPage = l;
425
- }
426
- return (l, h) => (f(), g("div", Je, [
427
- T(" The table Header "),
428
- u("table", {
429
- class: O(l.$attrs.class ?? "table")
354
+ props: H({
355
+ itemValue: {},
356
+ columnHeaders: {},
357
+ data: {},
358
+ perPage: {},
359
+ currentPage: {},
360
+ perPageOptions: {},
361
+ loading: { type: Boolean },
362
+ selectable: { type: Boolean },
363
+ caption: {},
364
+ summary: {}
365
+ }, A),
366
+ setup(s) {
367
+ const t = s, e = U(() => t.columnHeaders), { headers: n } = De(e), l = K(), a = Object.keys(l).filter((p) => p.startsWith("headerCell")), { pagination: c, updateCurrentPage: P, updatePerPage: y } = Be(t), { bodyRows: _ } = Re(t.data, c, e);
368
+ return (p, w) => (i(), d("div", Ee, [
369
+ r("table", {
370
+ class: k(p.$attrs.class ?? "table")
430
371
  }, [
431
- k(l.$slots, "caption", {}, () => [
432
- u("caption", Qe, b(l.caption), 1)
372
+ m(p.$slots, "caption", {}, () => [
373
+ p.caption ? (i(), d("caption", He, f(p.caption), 1)) : B("", !0)
433
374
  ]),
434
- A(p(Ge), { columnHeaders: p(r) }, X({ _: 2 }, [
435
- $(p(_), (i) => ({
436
- name: i,
437
- fn: Y((o) => [
438
- k(l.$slots, i, Z(ee(o)))
375
+ O(u(se), { columnHeaders: u(n) }, M({ _: 2 }, [
376
+ v(u(a), (b) => ({
377
+ name: b,
378
+ fn: I((o) => [
379
+ m(p.$slots, b, L(z(o)))
439
380
  ])
440
381
  }))
441
382
  ]), 1032, ["columnHeaders"]),
442
- A(p(Ue), {
443
- bodyRows: p(s),
444
- loading: l.loading
383
+ O(u(ne), {
384
+ bodyRows: u(_),
385
+ loading: p.loading
445
386
  }, null, 8, ["bodyRows", "loading"]),
446
- k(l.$slots, "summary", {}, () => [
447
- u("caption", Xe, b(l.summary), 1)
387
+ m(p.$slots, "summary", {}, () => [
388
+ r("caption", Ne, f(p.summary), 1)
448
389
  ])
449
390
  ], 2),
450
- u("div", Ye, [
451
- A(Ne, {
452
- perPage: p(t).perPage,
453
- currentPage: p(t).currentPage,
454
- perPageOptions: l.perPageOptions,
455
- total: l.data.length,
456
- "onUpdate:currentPage": m,
457
- "onUpdate:perPage": y
458
- }, null, 8, ["perPage", "currentPage", "perPageOptions", "total"])
391
+ r("div", Te, [
392
+ O(u(we), {
393
+ perPage: u(c).perPage,
394
+ currentPage: u(c).currentPage,
395
+ perPageOptions: p.perPageOptions,
396
+ total: p.data.length,
397
+ "onUpdate:currentPage": u(P),
398
+ "onUpdate:perPage": u(y)
399
+ }, null, 8, ["perPage", "currentPage", "perPageOptions", "total", "onUpdate:currentPage", "onUpdate:perPage"])
459
400
  ])
460
401
  ]));
461
402
  }
462
403
  });
463
- function at(n) {
464
- return {
465
- headerKeys: P(() => L(n.flat()))
466
- };
467
- }
468
404
  export {
469
- nt as VueyeTable,
470
- tt as defineColumnHeaders,
405
+ Ie as VueyeTable,
406
+ Ke as defineColumnHeaders,
471
407
  R as depthCount,
472
- j as flatHeadersToRows,
473
- He as getBodyRows,
474
- L as getHeaderKeys,
475
- K as leafCount,
476
- at as useHeaderKeys
408
+ D as flatHeadersToRows,
409
+ Se as getBodyRows,
410
+ E as getHeaderKeys,
411
+ N as leafCount,
412
+ Re as useBodyRows,
413
+ Me as useHeaderKeys,
414
+ De as useHeaders,
415
+ Be as usePagination
477
416
  };