mhz-helpers 1.0.2 → 1.0.3
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.
- package/dist/composables/usePage.d.ts +3 -1
- package/dist/index.js +44 -43
- package/package.json +3 -3
|
@@ -5,14 +5,16 @@ export interface ISortOption {
|
|
|
5
5
|
export interface IPageQuery {
|
|
6
6
|
page: number;
|
|
7
7
|
sort: ISortOption;
|
|
8
|
+
filter: object;
|
|
8
9
|
}
|
|
9
|
-
export declare function usePage(): {
|
|
10
|
+
export declare function usePage(filter?: object): {
|
|
10
11
|
query: import("vue").Ref<{
|
|
11
12
|
page: number;
|
|
12
13
|
sort: {
|
|
13
14
|
value?: string | undefined;
|
|
14
15
|
isAsc: boolean;
|
|
15
16
|
};
|
|
17
|
+
filter: object;
|
|
16
18
|
}>;
|
|
17
19
|
resetQuery: (value: string) => void;
|
|
18
20
|
setQueryPage: (pageToSet: number) => void;
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { useRouter as
|
|
3
|
-
function
|
|
4
|
-
const t =
|
|
5
|
-
function
|
|
6
|
-
return !
|
|
1
|
+
import { computed as c, ref as i, watch as l, toRaw as s } from "vue";
|
|
2
|
+
import { useRouter as f, useRoute as m } from "vue-router";
|
|
3
|
+
function v(e) {
|
|
4
|
+
const t = c(() => e.value?.data), u = c(() => e.value?.total);
|
|
5
|
+
function r(n, a) {
|
|
6
|
+
return !u.value || n === 0 || n === u.value + 1 ? a : n;
|
|
7
7
|
}
|
|
8
|
-
return { data: t, total:
|
|
8
|
+
return { data: t, total: u, setPage: r };
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
page: Number(
|
|
10
|
+
function g(e) {
|
|
11
|
+
const t = f(), u = m(), r = i({
|
|
12
|
+
page: Number(u.query.page || 1),
|
|
13
13
|
sort: {
|
|
14
|
-
value:
|
|
15
|
-
isAsc:
|
|
16
|
-
}
|
|
14
|
+
value: u.query.sort?.toString(),
|
|
15
|
+
isAsc: u.query.dir !== "desc"
|
|
16
|
+
},
|
|
17
|
+
filter: e || {}
|
|
17
18
|
});
|
|
18
|
-
function
|
|
19
|
-
r.value = Object.assign(r.value, { page: 1, sort: { value:
|
|
19
|
+
function n(o) {
|
|
20
|
+
r.value = Object.assign(r.value, { page: 1, sort: { value: o, isAsc: !0 }, filter: {} });
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
r.value.page =
|
|
22
|
+
function a(o) {
|
|
23
|
+
r.value.page = o;
|
|
23
24
|
}
|
|
24
|
-
return
|
|
25
|
+
return l(
|
|
25
26
|
() => r.value,
|
|
26
27
|
() => {
|
|
27
|
-
|
|
28
|
-
path:
|
|
28
|
+
t.push({
|
|
29
|
+
path: u.path,
|
|
29
30
|
query: {
|
|
30
31
|
page: r.value.page,
|
|
31
32
|
sort: r.value.sort.value,
|
|
@@ -34,25 +35,25 @@ function v() {
|
|
|
34
35
|
});
|
|
35
36
|
},
|
|
36
37
|
{ deep: !0 }
|
|
37
|
-
), { query: r, resetQuery:
|
|
38
|
+
), { query: r, resetQuery: n, setQueryPage: a };
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
-
const e =
|
|
41
|
-
function
|
|
42
|
-
t.value = [...t.value, ...
|
|
40
|
+
function y() {
|
|
41
|
+
const e = i(1), t = i([]);
|
|
42
|
+
function u(n) {
|
|
43
|
+
t.value = [...t.value, ...n];
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
45
|
+
function r(n, a) {
|
|
46
|
+
n || (e.value = a);
|
|
46
47
|
}
|
|
47
|
-
return { page: e, allData: t, addData:
|
|
48
|
+
return { page: e, allData: t, addData: u, handleScroll: r };
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function D(e) {
|
|
50
51
|
return structuredClone(s(e));
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function h(e) {
|
|
53
54
|
return e ? new Intl.DateTimeFormat().format(new Date(e)) : "-";
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function I(e) {
|
|
56
57
|
return e ? new Intl.DateTimeFormat(void 0, {
|
|
57
58
|
year: "numeric",
|
|
58
59
|
month: "numeric",
|
|
@@ -61,23 +62,23 @@ function h(e) {
|
|
|
61
62
|
minute: "numeric"
|
|
62
63
|
}).format(new Date(e)) : "-";
|
|
63
64
|
}
|
|
64
|
-
function
|
|
65
|
+
function q() {
|
|
65
66
|
return `temp-${crypto.randomUUID()}`;
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
+
function P(e) {
|
|
68
69
|
return e.map((t) => (t._id?.includes("temp") && delete t._id, t));
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
+
function w(e) {
|
|
71
72
|
return e.map((t) => (delete t._id, t));
|
|
72
73
|
}
|
|
73
74
|
export {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
D as clone,
|
|
76
|
+
q as createTempId,
|
|
77
|
+
w as deleteId,
|
|
78
|
+
P as deleteTempId,
|
|
79
|
+
h as formatDate,
|
|
80
|
+
I as formatDateTime,
|
|
81
|
+
y as useInfiniteScroll,
|
|
82
|
+
g as usePage,
|
|
83
|
+
v as usePagination
|
|
83
84
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mhz-helpers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "mhz-helpers",
|
|
5
5
|
"author": "dergunov.com",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"vue-router": "4.2.4"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "20.5.
|
|
23
|
+
"@types/node": "20.5.6",
|
|
24
24
|
"@typescript-eslint/eslint-plugin": "6.4.1",
|
|
25
25
|
"@typescript-eslint/parser": "6.4.1",
|
|
26
26
|
"@vitejs/plugin-vue": "4.3.3",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"stylelint-config-recommended-scss": "12.0.0",
|
|
38
38
|
"stylelint-config-recommended-vue": "1.5.0",
|
|
39
39
|
"stylelint-prettier": "4.0.2",
|
|
40
|
-
"typescript": "5.
|
|
40
|
+
"typescript": "5.2.2",
|
|
41
41
|
"vite": "4.4.9",
|
|
42
42
|
"vite-plugin-dts": "3.5.2",
|
|
43
43
|
"vue-linters-config": "0.1.6",
|