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