@basmilius/common 3.0.0 → 3.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/composable/useCopy.d.ts +2 -1
- package/dist/composable/useDtoForm.d.ts +1 -1
- package/dist/composable/useLocalFile.d.ts +8 -1
- package/dist/composable/useNamedRoute.d.ts +7 -2
- package/dist/composable/useNavigate.d.ts +8 -2
- package/dist/composable/usePagination.d.ts +11 -1
- package/dist/composable/usePasswordStrength.d.ts +9 -2
- package/dist/composable/useRouteMeta.d.ts +1 -1
- package/dist/composable/useRouteNames.d.ts +2 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +11 -11
- package/package.json +5 -5
- package/src/composable/useCopy.ts +3 -1
- package/src/composable/useDtoForm.ts +2 -2
- package/src/composable/useLocalFile.ts +10 -2
- package/src/composable/useNamedRoute.ts +8 -3
- package/src/composable/useNavigate.ts +9 -2
- package/src/composable/usePagination.ts +13 -2
- package/src/composable/usePasswordStrength.ts +2 -2
- package/src/composable/useRouteMeta.ts +1 -1
- package/src/composable/useRouteNames.ts +2 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basmilius/common",
|
|
3
3
|
"description": "Common code shared in personal projects.",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/basmilius",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|
|
34
|
-
"provenance":
|
|
34
|
+
"provenance": true
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsgo --noEmit && bun -b build.ts"
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"./*": "./*"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@basmilius/http-client": "3.0.
|
|
52
|
-
"@basmilius/utils": "3.0.
|
|
51
|
+
"@basmilius/http-client": "3.0.3",
|
|
52
|
+
"@basmilius/utils": "3.0.3",
|
|
53
53
|
"@flux-ui/components": "^3.0.0-next.26",
|
|
54
54
|
"@flux-ui/internals": "^3.0.0-next.26",
|
|
55
55
|
"pinia": "^3.0.4",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"vue-router": "^5.0.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@basmilius/tools": "3.0.
|
|
60
|
+
"@basmilius/tools": "3.0.3",
|
|
61
61
|
"@types/culori": "^4.0.1",
|
|
62
62
|
"@types/lodash-es": "^4.17.12",
|
|
63
63
|
"culori": "^4.0.2",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type Ref, unref } from 'vue';
|
|
2
2
|
|
|
3
|
-
export default function (contents: Ref<string>, onSuccess?: Function) {
|
|
3
|
+
export default function (contents: Ref<string>, onSuccess?: Function): UseCopy {
|
|
4
4
|
return async () => {
|
|
5
5
|
await navigator.clipboard.writeText(unref(contents));
|
|
6
6
|
onSuccess?.();
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
type UseCopy = () => Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { cloneDto, markDtoClean } from '@basmilius/http-client';
|
|
2
2
|
import { ref, type Ref, watch } from 'vue';
|
|
3
3
|
|
|
4
|
-
export default function <T>(dtoRef: Ref<T | null>) {
|
|
5
|
-
const form = ref<T>()
|
|
4
|
+
export default function <T>(dtoRef: Ref<T | null>): Ref<T> {
|
|
5
|
+
const form = ref<T>() as Ref<T>;
|
|
6
6
|
|
|
7
7
|
watch(dtoRef, dto => {
|
|
8
8
|
if (!dto) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ref, watch } from 'vue';
|
|
1
|
+
import { type Ref, ref, watch } from 'vue';
|
|
2
2
|
|
|
3
|
-
export default function () {
|
|
3
|
+
export default function (): UseLocalFile {
|
|
4
4
|
const file = ref<File | null>(null);
|
|
5
5
|
const url = ref<string | null>(null);
|
|
6
6
|
|
|
@@ -38,3 +38,11 @@ export default function () {
|
|
|
38
38
|
upload: uploadFile
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
type UseLocalFile = {
|
|
43
|
+
readonly file: Ref<File | null>;
|
|
44
|
+
readonly url: Ref<string | null>;
|
|
45
|
+
|
|
46
|
+
delete: () => void;
|
|
47
|
+
upload: (uploadedFile: File) => void;
|
|
48
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { computed, provide, type Ref, unref } from 'vue';
|
|
2
|
-
import { useRoute, viewDepthKey } from 'vue-router';
|
|
1
|
+
import { computed, type ComputedRef, provide, type Ref, unref } from 'vue';
|
|
2
|
+
import { type RouteLocationNormalizedLoadedGeneric, useRoute, viewDepthKey } from 'vue-router';
|
|
3
3
|
|
|
4
|
-
export default function (nameRef: Ref<string> | string) {
|
|
4
|
+
export default function (nameRef: Ref<string> | string): UseNamedRoute {
|
|
5
5
|
const route = useRoute();
|
|
6
6
|
|
|
7
7
|
const depth = computed(() => route.matched.findIndex(m => !!m.components && unref(nameRef) in m.components));
|
|
@@ -15,3 +15,8 @@ export default function (nameRef: Ref<string> | string) {
|
|
|
15
15
|
viewKey
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
type UseNamedRoute = {
|
|
20
|
+
readonly route: RouteLocationNormalizedLoadedGeneric;
|
|
21
|
+
readonly viewKey: ComputedRef<string | undefined>;
|
|
22
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type NavigationFailure, type RouteLocationRaw, useRouter } from 'vue-router';
|
|
2
2
|
|
|
3
|
+
type Result = NavigationFailure | void | undefined;
|
|
3
4
|
type To = Omit<RouteLocationRaw, 'replace'>;
|
|
4
|
-
type Navigate = (to: To, replace?: boolean) => Promise<
|
|
5
|
+
type Navigate = (to: To, replace?: boolean) => Promise<Result>;
|
|
5
6
|
type Wrap = (fn: Navigate) => Navigate;
|
|
6
7
|
|
|
7
|
-
export default function (...wrap: Wrap[]) {
|
|
8
|
+
export default function (...wrap: Wrap[]): UseNavigate {
|
|
8
9
|
const router = useRouter();
|
|
9
10
|
|
|
10
11
|
let navigate = async (to: To, replace: boolean = false) => {
|
|
@@ -26,3 +27,9 @@ export default function (...wrap: Wrap[]) {
|
|
|
26
27
|
replace: (to: To) => navigate(to, true)
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
|
|
31
|
+
type UseNavigate = {
|
|
32
|
+
navigate(to: To, replace?: boolean): Promise<Result>;
|
|
33
|
+
push(to: To): Promise<Result>;
|
|
34
|
+
replace(to: To): Promise<Result>;
|
|
35
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ref } from 'vue';
|
|
1
|
+
import { ref, type Ref } from 'vue';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_LIMITS = [5, 10, 25, 50, 100];
|
|
4
4
|
const DEFAULT_PAGE = 1;
|
|
5
5
|
const DEFAULT_PER_PAGE = 25;
|
|
6
6
|
|
|
7
|
-
export default function () {
|
|
7
|
+
export default function (): UsePagination {
|
|
8
8
|
const limits = ref(DEFAULT_LIMITS);
|
|
9
9
|
const page = ref(DEFAULT_PAGE);
|
|
10
10
|
const perPage = ref(DEFAULT_PER_PAGE);
|
|
@@ -33,3 +33,14 @@ export default function () {
|
|
|
33
33
|
setTotal
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
+
|
|
37
|
+
type UsePagination = {
|
|
38
|
+
readonly limits: Ref<number[]>;
|
|
39
|
+
readonly page: Ref<number>;
|
|
40
|
+
readonly perPage: Ref<number>;
|
|
41
|
+
readonly total: Ref<number>;
|
|
42
|
+
|
|
43
|
+
setPage(num: number): void;
|
|
44
|
+
setPerPage(num: number): void;
|
|
45
|
+
setTotal(num: number): void;
|
|
46
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, type Ref, unref } from 'vue';
|
|
1
|
+
import { computed, type ComputedRef, type Ref, unref } from 'vue';
|
|
2
2
|
|
|
3
3
|
type PasswordRuleType =
|
|
4
4
|
| 'lowercase'
|
|
@@ -44,7 +44,7 @@ const rules: PasswordRule[] = [
|
|
|
44
44
|
{regex: new RegExp('[!"#\$%&\'\(\)\*\+,-\./:;<=>\?@\[\\\\\\]\^_`\{|\}~]'), type: 'symbol'}
|
|
45
45
|
];
|
|
46
46
|
|
|
47
|
-
export default function (passwordRef: Ref<string>) {
|
|
47
|
+
export default function (passwordRef: Ref<string>): ComputedRef<Result | null> {
|
|
48
48
|
return computed<Result | null>(() => {
|
|
49
49
|
const password = unref(passwordRef);
|
|
50
50
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { computed } from 'vue';
|
|
1
|
+
import { computed, type ComputedRef } from 'vue';
|
|
2
2
|
import { useRoute } from 'vue-router';
|
|
3
3
|
|
|
4
|
-
export default function () {
|
|
4
|
+
export default function (): ComputedRef<string[]> {
|
|
5
5
|
const route = useRoute();
|
|
6
6
|
|
|
7
7
|
return computed(() => {
|