@orchidui/core 1.8.1-111 → 1.8.1-113

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