vueye-table 1.4.0 → 2.0.0-alpha.1

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