@orchidui/core 1.8.1-122 → 1.8.1-123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { ref as o, computed as m } from "vue";
2
- function E(L) {
3
- const { name: w, localDb: _, options: c } = L, u = o(w), f = o(_), y = o([]), s = o({
1
+ import { ref as o, computed as L } from "vue";
2
+ function q(w) {
3
+ const { name: _, localDb: C, options: c } = w, i = o(_), f = o(C), g = o([]), r = o({
4
4
  updated_at: "desc"
5
5
  }), n = o({
6
6
  page: 1,
@@ -9,74 +9,74 @@ function E(L) {
9
9
  total: 0,
10
10
  last_page: 1
11
11
  }), p = o(!1);
12
- let b = null;
13
- const D = m(() => {
12
+ let y = null;
13
+ const D = L(() => {
14
14
  const e = {}, l = (c == null ? void 0 : c.filterable_fields) ?? [];
15
15
  return Object.entries(n.value).forEach(([t, a]) => {
16
16
  l.includes(t) && a !== void 0 && a !== null && a !== "" && (e[t] = a);
17
17
  }), e;
18
- }), g = m(() => {
18
+ }), b = L(() => {
19
19
  const e = {}, l = (c == null ? void 0 : c.sortable_fields) ?? [];
20
- return Object.entries(s.value).forEach(([t, a]) => {
20
+ return Object.entries(r.value).forEach(([t, a]) => {
21
21
  l.includes(t) && a !== void 0 && a !== null && a !== "" && (e[t] = a);
22
22
  }), e;
23
- }), C = () => {
24
- let e = f.value.table(u.value);
25
- return g.value && Object.keys(g.value).length > 0 && Object.entries(g.value).forEach(([l, t]) => {
23
+ }), m = () => {
24
+ let e = f.value.table(i.value);
25
+ return b.value && Object.keys(b.value).length > 0 && Object.entries(b.value).forEach(([l, t]) => {
26
26
  t === "desc" ? e = e.orderBy(l).reverse() : e = e.orderBy(l);
27
27
  }), D.value && Object.entries(D.value).forEach(([l, t]) => {
28
28
  t && (Array.isArray(t) ? e = e.filter((a) => {
29
- const r = a[l];
30
- return r == null ? !1 : t.some((d) => d == null ? !1 : typeof d == "string" && typeof r == "string" ? r.toLowerCase().includes(d.toLowerCase()) : r === d);
29
+ const s = a[l];
30
+ return s == null ? !1 : t.some((d) => d == null ? !1 : typeof d == "string" && typeof s == "string" ? s.toLowerCase().includes(d.toLowerCase()) : s === d);
31
31
  }) : typeof t == "string" ? e = e.filter((a) => {
32
- const r = a[l];
33
- return typeof r != "string" ? !1 : r.toLowerCase().includes(t.toLowerCase());
32
+ const s = a[l];
33
+ return typeof s != "string" ? !1 : s.toLowerCase().includes(t.toLowerCase());
34
34
  }) : e = e.filter((a) => a[l] === t));
35
35
  }), e;
36
- }, i = async () => {
37
- p.value = !0, b && clearTimeout(b), b = setTimeout(async () => {
38
- const e = C(), l = (parseInt(n.value.page) - 1) * parseInt(n.value.per_page), t = await e.offset(l).limit(parseInt(n.value.per_page)).toArray();
39
- y.value = t;
40
- const a = await e.count();
36
+ }, u = async () => {
37
+ p.value = !0, y && clearTimeout(y), y = setTimeout(async () => {
38
+ const e = m(), l = (parseInt(n.value.page) - 1) * parseInt(n.value.per_page), t = await e.offset(l).limit(parseInt(n.value.per_page)).toArray();
39
+ g.value = t;
40
+ const s = await m().count();
41
41
  v.value = {
42
- total: a,
43
- last_page: Math.ceil(parseInt(a) / parseInt(n.value.per_page))
42
+ total: s,
43
+ last_page: Math.ceil(parseInt(s) / parseInt(n.value.per_page))
44
44
  }, p.value = !1;
45
45
  }, 500);
46
46
  };
47
47
  return {
48
48
  // State
49
- localData: y,
50
- sortByData: s,
49
+ localData: g,
50
+ sortByData: r,
51
51
  filterData: n,
52
52
  paginationData: v,
53
53
  isLoading: p,
54
54
  // Methods
55
55
  toggleSort: (e) => {
56
- const l = s.value.find((t) => t.column === e);
57
- l ? l.direction === "asc" ? s.value = { ...s.value, [e]: "desc" } : delete s.value[e] : s.value = { ...s.value, [e]: "asc" }, i();
56
+ const l = r.value.find((t) => t.column === e);
57
+ l ? l.direction === "asc" ? r.value = { ...r.value, [e]: "desc" } : delete r.value[e] : r.value = { ...r.value, [e]: "asc" }, u();
58
58
  },
59
59
  bulkPutLocalData: async (e) => {
60
- await f.value.table(u.value).bulkPut(e), await i();
60
+ await f.value.table(i.value).bulkPut(e), await u();
61
61
  },
62
62
  bulkDeleteLocalData: async (e) => {
63
- await f.value.table(u.value).bulkDelete(e), await i();
63
+ await f.value.table(i.value).bulkDelete(e), await u();
64
64
  },
65
65
  getLocalDataUpdatedAt: async () => {
66
- const e = await f.value.table(u.value).orderBy("updated_at").reverse().limit(1).first();
66
+ const e = await f.value.table(i.value).orderBy("updated_at").reverse().limit(1).first();
67
67
  return e == null ? void 0 : e.updated_at;
68
68
  },
69
- getLocalDataIds: async () => await f.value.table(u.value).toCollection().primaryKeys(),
70
- syncLocalData: i,
69
+ getLocalDataIds: async () => await f.value.table(i.value).toCollection().primaryKeys(),
70
+ syncLocalData: u,
71
71
  // Setters
72
72
  setFilter: (e) => {
73
- n.value = { ...e }, i();
73
+ n.value = { ...e }, u();
74
74
  },
75
75
  setSortBy: (e) => {
76
- s.value = { ...e }, i();
76
+ r.value = { ...e }, u();
77
77
  }
78
78
  };
79
79
  }
80
80
  export {
81
- E as useDataTable
81
+ q as useDataTable
82
82
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orchidui/core",
3
3
  "description": "Orchid UI, Library Vue 3 tailwind css",
4
- "version": "1.8.1-122",
4
+ "version": "1.8.1-123",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "vite build"