@orchidui/core 1.8.1-106 → 1.8.1-107

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,81 +1,81 @@
1
- import { ref as s } from "vue";
1
+ import { ref as n } from "vue";
2
2
  function O(L) {
3
- const { id: w, name: B, localDb: _ } = L, C = s(w), n = s(B), r = s(_), m = s([]), a = s([]), i = s({
3
+ const { id: w, name: _, localDb: B } = L, I = n(w), s = n(_), i = n(B), m = n([]), a = n([]), r = n({
4
4
  page: 1,
5
5
  per_page: 10
6
- }), g = s({
6
+ }), p = n({
7
7
  total: 0,
8
8
  last_page: 0
9
- }), y = s(!1);
10
- let b = null;
11
- const p = async () => {
12
- y.value = !0, b && clearTimeout(b), b = setTimeout(async () => {
13
- let e = r.value.table(n.value);
14
- const l = I();
9
+ }), y = n(!1);
10
+ let v = null;
11
+ const g = async () => {
12
+ y.value = !0, v && clearTimeout(v), v = setTimeout(async () => {
13
+ let e = i.value.table(s.value);
14
+ const l = C();
15
15
  l.filter && Object.entries(l.filter).forEach(([u, o]) => {
16
- o && Array.isArray(o) ? e = e.filter((d) => {
17
- const f = d[u];
18
- return o.some((v) => typeof v == "string" && typeof f == "string" ? f.toLowerCase().includes(v.toLowerCase()) : f === v);
19
- }) : o && typeof o == "string" ? e = e.filter((d) => {
20
- const f = d[u];
21
- return typeof f == "string" && f.toLowerCase().includes(o.toLowerCase());
22
- }) : o != null && (e = e.filter((d) => d[u] === o));
16
+ o && Array.isArray(o) ? e = e.filter((f) => {
17
+ const d = f[u];
18
+ return o.some((D) => typeof D == "string" && typeof d == "string" ? d.toLowerCase().includes(D.toLowerCase()) : d === D);
19
+ }) : o && typeof o == "string" ? e = e.filter((f) => {
20
+ const d = f[u];
21
+ return typeof d == "string" && d.toLowerCase().includes(o.toLowerCase());
22
+ }) : o != null && (e = e.filter((f) => f[u] === o));
23
23
  }), l.sortBy && l.sortBy.length > 0 && l.sortBy.forEach((u) => {
24
24
  e = e.sortBy(u.column), u.direction === "desc" && (e = e.reverse());
25
25
  });
26
- const t = (parseInt(i.value.page) - 1) * parseInt(i.value.per_page);
27
- e = e.offset(t).limit(parseInt(i.value.per_page));
26
+ const t = (parseInt(r.value.page) - 1) * parseInt(r.value.per_page);
27
+ e = e.offset(t).limit(parseInt(r.value.per_page));
28
28
  const c = await e.toArray();
29
29
  m.value = c;
30
- const D = await r.value.table(n.value).count();
31
- g.value = {
32
- total: D,
33
- last_page: Math.ceil(D / i.value.per_page)
34
- }, y.value = !1;
30
+ const b = await i.value.table(s.value).count();
31
+ console.log("totalField", b), p.value = {
32
+ total: b,
33
+ last_page: Math.ceil(b / parseInt(r.value.per_page))
34
+ }, console.log("paginationData", p.value, r.value.per_page), y.value = !1;
35
35
  }, 300);
36
- }, I = () => {
36
+ }, C = () => {
37
37
  const e = {}, l = ["columnEdit", "page", "per_page"];
38
- return Object.entries(i.value).forEach(([t, c]) => {
38
+ return Object.entries(r.value).forEach(([t, c]) => {
39
39
  !l.includes(t) && c !== void 0 && c !== null && c !== "" && (e[t] = c);
40
40
  }), {
41
41
  filter: e,
42
42
  sortBy: a.value,
43
- pagination: g.value
43
+ pagination: p.value
44
44
  };
45
45
  };
46
46
  return {
47
47
  // State
48
48
  sortBy: a,
49
49
  localData: m,
50
- dataTableId: C,
51
- dbTablename: n,
52
- paginationData: g,
50
+ dataTableId: I,
51
+ dbTablename: s,
52
+ paginationData: p,
53
53
  isLoading: y,
54
54
  // Methods
55
55
  toggleSort: (e) => {
56
56
  const l = a.value.find((t) => t.column === e);
57
57
  l ? l.direction === "asc" ? a.value = a.value.map(
58
58
  (t) => t.column === e ? { ...t, direction: "desc" } : t
59
- ) : a.value = a.value.filter((t) => t.column !== e) : a.value = [...a.value, { column: e, direction: "asc" }], p();
59
+ ) : a.value = a.value.filter((t) => t.column !== e) : a.value = [...a.value, { column: e, direction: "asc" }], g();
60
60
  },
61
61
  bulkPutLocalData: async (e) => {
62
- await r.value.table(n.value).bulkPut(e);
62
+ await i.value.table(s.value).bulkPut(e);
63
63
  },
64
64
  bulkDeleteLocalData: async (e) => {
65
- await r.value.table(n.value).bulkDelete(e);
65
+ await i.value.table(s.value).bulkDelete(e);
66
66
  },
67
67
  getLocalDataUpdatedAt: async () => {
68
- const e = await r.value.table(n.value).orderBy("updated_at").reverse().limit(1).first();
68
+ const e = await i.value.table(s.value).orderBy("updated_at").reverse().limit(1).first();
69
69
  return e == null ? void 0 : e.updated_at;
70
70
  },
71
- getLocalDataIds: async () => await r.value.table(n.value).toCollection().primaryKeys(),
72
- syncLocalData: p,
71
+ getLocalDataIds: async () => await i.value.table(s.value).toCollection().primaryKeys(),
72
+ syncLocalData: g,
73
73
  // Setters
74
74
  setFilter: (e) => {
75
- i.value = { ...e }, p();
75
+ r.value = { ...e }, g();
76
76
  },
77
77
  setSortBy: (e) => {
78
- a.value = { ...e }, p();
78
+ a.value = { ...e }, g();
79
79
  }
80
80
  };
81
81
  }
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-106",
4
+ "version": "1.8.1-107",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "vite build"