@stephenchenorg/astro 7.1.0 → 8.0.0
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/company-setting/index.d.ts +2 -2
- package/dist/form-validator/index.d.ts +10 -9
- package/dist/form-validator/index.js +8 -5
- package/dist/image/index.d.ts +4 -4
- package/dist/page/index.d.ts +3 -3
- package/dist/pagination-vue-client-side/index.d.ts +32 -0
- package/dist/pagination-vue-client-side/index.js +42 -0
- package/dist/pagination-vue-server-side/index.d.ts +32 -0
- package/dist/{pagination-vue → pagination-vue-server-side}/index.js +3 -4
- package/dist/query-params/index.d.ts +2 -2
- package/package.json +8 -4
- package/dist/pagination-vue/index.d.ts +0 -33
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as graphql6 from "graphql";
|
|
2
2
|
|
|
3
3
|
//#region src/company-setting/types.d.ts
|
|
4
4
|
interface DataCompanySetting {
|
|
@@ -42,6 +42,6 @@ declare function createCompanySetting(companySetting: Partial<CompanySetting>):
|
|
|
42
42
|
};
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/company-setting/fragments.d.ts
|
|
45
|
-
declare const companySettingFields:
|
|
45
|
+
declare const companySettingFields: graphql6.DocumentNode;
|
|
46
46
|
//#endregion
|
|
47
47
|
export { CompanySetting, DataCompanySetting, companySettingFields, createCompanySetting };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue33 from "vue";
|
|
2
2
|
import { PropType } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/form-validator/types.d.ts
|
|
@@ -6,6 +6,7 @@ type FormErrors = Record<string, string[]>;
|
|
|
6
6
|
interface FormRule {
|
|
7
7
|
validate: (value: any, form: Record<string, any>) => boolean;
|
|
8
8
|
message: string;
|
|
9
|
+
when?: (value: any, form: Record<string, any>) => boolean;
|
|
9
10
|
}
|
|
10
11
|
//#endregion
|
|
11
12
|
//#region src/form-validator/FormValidator.d.ts
|
|
@@ -22,7 +23,7 @@ declare class FormValidator {
|
|
|
22
23
|
}
|
|
23
24
|
//#endregion
|
|
24
25
|
//#region src/form-validator/components/FormField.d.ts
|
|
25
|
-
declare const FormField:
|
|
26
|
+
declare const FormField: vue33.DefineComponent<vue33.ExtractPropTypes<{
|
|
26
27
|
id: {
|
|
27
28
|
type: StringConstructor;
|
|
28
29
|
required: true;
|
|
@@ -31,9 +32,9 @@ declare const FormField: vue17.DefineComponent<vue17.ExtractPropTypes<{
|
|
|
31
32
|
type: PropType<FormRule[]>;
|
|
32
33
|
default: () => never[];
|
|
33
34
|
};
|
|
34
|
-
}>, () =>
|
|
35
|
+
}>, () => vue33.VNode<vue33.RendererNode, vue33.RendererElement, {
|
|
35
36
|
[key: string]: any;
|
|
36
|
-
}>[] | undefined, {}, {}, {},
|
|
37
|
+
}>[] | undefined, {}, {}, {}, vue33.ComponentOptionsMixin, vue33.ComponentOptionsMixin, {}, string, vue33.PublicProps, Readonly<vue33.ExtractPropTypes<{
|
|
37
38
|
id: {
|
|
38
39
|
type: StringConstructor;
|
|
39
40
|
required: true;
|
|
@@ -44,27 +45,27 @@ declare const FormField: vue17.DefineComponent<vue17.ExtractPropTypes<{
|
|
|
44
45
|
};
|
|
45
46
|
}>> & Readonly<{}>, {
|
|
46
47
|
rules: FormRule[];
|
|
47
|
-
}, {}, {}, {}, string,
|
|
48
|
+
}, {}, {}, {}, string, vue33.ComponentProvideOptions, true, {}, any>;
|
|
48
49
|
//#endregion
|
|
49
50
|
//#region src/form-validator/components/FormValidatorProvider.d.ts
|
|
50
51
|
interface FormValidatorProviderExposed {
|
|
51
52
|
formValidator: () => FormValidator;
|
|
52
53
|
}
|
|
53
|
-
declare const FormValidatorProvider:
|
|
54
|
+
declare const FormValidatorProvider: vue33.DefineComponent<vue33.ExtractPropTypes<{
|
|
54
55
|
errors: {
|
|
55
56
|
type: PropType<FormErrors>;
|
|
56
57
|
default: () => {};
|
|
57
58
|
};
|
|
58
|
-
}>, () =>
|
|
59
|
+
}>, () => vue33.VNode<vue33.RendererNode, vue33.RendererElement, {
|
|
59
60
|
[key: string]: any;
|
|
60
|
-
}>[] | undefined, {}, {}, {},
|
|
61
|
+
}>[] | undefined, {}, {}, {}, vue33.ComponentOptionsMixin, vue33.ComponentOptionsMixin, {}, string, vue33.PublicProps, Readonly<vue33.ExtractPropTypes<{
|
|
61
62
|
errors: {
|
|
62
63
|
type: PropType<FormErrors>;
|
|
63
64
|
default: () => {};
|
|
64
65
|
};
|
|
65
66
|
}>> & Readonly<{}>, {
|
|
66
67
|
errors: FormErrors;
|
|
67
|
-
}, {}, {}, {}, string,
|
|
68
|
+
}, {}, {}, {}, string, vue33.ComponentProvideOptions, true, {}, any>;
|
|
68
69
|
//#endregion
|
|
69
70
|
//#region src/form-validator/useFormValidator.d.ts
|
|
70
71
|
declare function useFormValidator(): FormValidator;
|
|
@@ -49,11 +49,14 @@ var FormValidator = class {
|
|
|
49
49
|
for (const field in this.rules) {
|
|
50
50
|
const fieldRules = this.rules[field];
|
|
51
51
|
const value = data[field];
|
|
52
|
-
for (const rule of fieldRules)
|
|
53
|
-
|
|
54
|
-
if (!
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
for (const rule of fieldRules) {
|
|
53
|
+
if (rule.when && !rule.when(value, data)) continue;
|
|
54
|
+
if (!rule.validate(value, data)) {
|
|
55
|
+
isValid = false;
|
|
56
|
+
if (!errors[field]) errors[field] = [];
|
|
57
|
+
errors[field].push(rule.message);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
this.setErrors(errors);
|
package/dist/image/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as graphql18 from "graphql";
|
|
2
2
|
|
|
3
3
|
//#region src/image/fragments.d.ts
|
|
4
|
-
declare const imageFields:
|
|
5
|
-
declare const coverFields:
|
|
6
|
-
declare const backgroundFields:
|
|
4
|
+
declare const imageFields: graphql18.DocumentNode;
|
|
5
|
+
declare const coverFields: graphql18.DocumentNode;
|
|
6
|
+
declare const backgroundFields: graphql18.DocumentNode;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/image/types.d.ts
|
|
9
9
|
interface ImageSource {
|
package/dist/page/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as graphql44 from "graphql";
|
|
2
2
|
|
|
3
3
|
//#region src/page/field/fragments.d.ts
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import * as graphql38 from "graphql";
|
|
|
6
6
|
* Page fields fragment requires explicit import image
|
|
7
7
|
* fields fragment `imageFields` from Image module.
|
|
8
8
|
*/
|
|
9
|
-
declare const pageFields:
|
|
9
|
+
declare const pageFields: graphql44.DocumentNode;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/page/types.d.ts
|
|
12
12
|
interface DataPage {
|
|
@@ -88,7 +88,7 @@ declare function pageTextField(fields: PageField[], key: string): string | null;
|
|
|
88
88
|
declare function pageImageFieldForBackground(fields: PageField[], key: string): string;
|
|
89
89
|
//#endregion
|
|
90
90
|
//#region src/page/seo-meta/fragments.d.ts
|
|
91
|
-
declare const seoMetaFields: (dummyClass: string) =>
|
|
91
|
+
declare const seoMetaFields: (dummyClass: string) => graphql44.DocumentNode;
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/page/seo-meta/helpers.d.ts
|
|
94
94
|
type UseSeoMetaOptions = Partial<Omit<PageMeta, 'title'>> & {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as vue0 from "vue";
|
|
2
|
+
import { MaybeRefOrGetter } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/pagination-vue-client-side/types.d.ts
|
|
5
|
+
interface Paginator<T> {
|
|
6
|
+
total: number;
|
|
7
|
+
per_page: number;
|
|
8
|
+
data: T[];
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/pagination-vue-client-side/usePagination.d.ts
|
|
12
|
+
declare function usePagination(options: {
|
|
13
|
+
total: MaybeRefOrGetter<number>;
|
|
14
|
+
currentPage: MaybeRefOrGetter<number>;
|
|
15
|
+
perPage?: MaybeRefOrGetter<number | undefined>;
|
|
16
|
+
visiblePages?: MaybeRefOrGetter<number | undefined>;
|
|
17
|
+
onChange?: (page: number) => void;
|
|
18
|
+
}): {
|
|
19
|
+
items: vue0.ComputedRef<number[]>;
|
|
20
|
+
showPagination: vue0.ComputedRef<boolean>;
|
|
21
|
+
canFirst: vue0.ComputedRef<boolean>;
|
|
22
|
+
canPrev: vue0.ComputedRef<boolean>;
|
|
23
|
+
canNext: vue0.ComputedRef<boolean>;
|
|
24
|
+
canLast: vue0.ComputedRef<boolean>;
|
|
25
|
+
gotoFirst: () => void;
|
|
26
|
+
gotoPrev: () => void;
|
|
27
|
+
gotoNext: () => void;
|
|
28
|
+
gotoLast: () => void;
|
|
29
|
+
gotoPage: (page: number) => void;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { Paginator, usePagination };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/pagination-vue-client-side/usePagination.ts
|
|
4
|
+
function usePagination(options) {
|
|
5
|
+
const total = computed(() => toValue(options.total));
|
|
6
|
+
const currentPage = computed(() => toValue(options.currentPage));
|
|
7
|
+
const perPage = computed(() => toValue(options.perPage) || 12);
|
|
8
|
+
const totalPages = computed(() => Math.ceil(total.value / perPage.value));
|
|
9
|
+
const visiblePages = computed(() => Math.min(toValue(options.visiblePages) || 5, totalPages.value));
|
|
10
|
+
const sideCount = computed(() => Math.floor(visiblePages.value / 2));
|
|
11
|
+
const items = computed(() => {
|
|
12
|
+
const items$1 = [];
|
|
13
|
+
let start = Math.max(1, currentPage.value - sideCount.value);
|
|
14
|
+
let end = Math.min(totalPages.value, currentPage.value + sideCount.value);
|
|
15
|
+
if (end - start + 1 < visiblePages.value && currentPage.value > 0) {
|
|
16
|
+
if (currentPage.value <= sideCount.value) end = Math.min(totalPages.value, start + visiblePages.value - 1);
|
|
17
|
+
else if (currentPage.value > totalPages.value - sideCount.value) start = Math.max(1, end - visiblePages.value + 1);
|
|
18
|
+
}
|
|
19
|
+
for (let i = start; i <= end; i++) items$1.push(i);
|
|
20
|
+
return items$1;
|
|
21
|
+
});
|
|
22
|
+
function gotoPage(page) {
|
|
23
|
+
const newPage = Math.max(1, Math.min(page, totalPages.value));
|
|
24
|
+
if (newPage !== currentPage.value) options.onChange?.(newPage);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
items,
|
|
28
|
+
showPagination: computed(() => total.value > perPage.value),
|
|
29
|
+
canFirst: computed(() => currentPage.value > 1),
|
|
30
|
+
canPrev: computed(() => currentPage.value > 1),
|
|
31
|
+
canNext: computed(() => currentPage.value < totalPages.value),
|
|
32
|
+
canLast: computed(() => currentPage.value < totalPages.value),
|
|
33
|
+
gotoFirst: () => gotoPage(1),
|
|
34
|
+
gotoPrev: () => gotoPage(currentPage.value - 1),
|
|
35
|
+
gotoNext: () => gotoPage(currentPage.value + 1),
|
|
36
|
+
gotoLast: () => gotoPage(totalPages.value),
|
|
37
|
+
gotoPage
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { usePagination };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as vue7 from "vue";
|
|
2
|
+
import { MaybeRefOrGetter } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/pagination-vue-server-side/types.d.ts
|
|
5
|
+
interface Paginator<T> {
|
|
6
|
+
total: number;
|
|
7
|
+
per_page: number;
|
|
8
|
+
data: T[];
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/pagination-vue-server-side/usePagination.d.ts
|
|
12
|
+
declare function usePagination(options: {
|
|
13
|
+
total: MaybeRefOrGetter<number>;
|
|
14
|
+
currentPage: MaybeRefOrGetter<number>;
|
|
15
|
+
url: string;
|
|
16
|
+
perPage?: MaybeRefOrGetter<number | undefined>;
|
|
17
|
+
visiblePages?: MaybeRefOrGetter<number | undefined>;
|
|
18
|
+
}): {
|
|
19
|
+
items: vue7.ComputedRef<number[]>;
|
|
20
|
+
showPagination: vue7.ComputedRef<boolean>;
|
|
21
|
+
canFirst: vue7.ComputedRef<boolean>;
|
|
22
|
+
canPrev: vue7.ComputedRef<boolean>;
|
|
23
|
+
canNext: vue7.ComputedRef<boolean>;
|
|
24
|
+
canLast: vue7.ComputedRef<boolean>;
|
|
25
|
+
firstUrl: vue7.ComputedRef<string>;
|
|
26
|
+
prevUrl: vue7.ComputedRef<string>;
|
|
27
|
+
nextUrl: vue7.ComputedRef<string>;
|
|
28
|
+
lastUrl: vue7.ComputedRef<string>;
|
|
29
|
+
getUrl: (page: number) => string;
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { Paginator, usePagination };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { computed, toValue } from "vue";
|
|
2
2
|
|
|
3
|
-
//#region src/pagination-vue/usePagination.ts
|
|
3
|
+
//#region src/pagination-vue-server-side/usePagination.ts
|
|
4
4
|
function usePagination(options) {
|
|
5
5
|
const total = computed(() => toValue(options.total));
|
|
6
6
|
const currentPage = computed(() => toValue(options.currentPage));
|
|
7
|
-
const perPage = computed(() => toValue(options.perPage || 12)
|
|
7
|
+
const perPage = computed(() => toValue(options.perPage) || 12);
|
|
8
8
|
const totalPages = computed(() => Math.ceil(total.value / perPage.value));
|
|
9
|
-
const visiblePages = computed(() => Math.min(toValue(options.visiblePages || 5
|
|
9
|
+
const visiblePages = computed(() => Math.min(toValue(options.visiblePages) || 5, totalPages.value));
|
|
10
10
|
const sideCount = computed(() => Math.floor(visiblePages.value / 2));
|
|
11
11
|
const items = computed(() => {
|
|
12
12
|
const items$1 = [];
|
|
@@ -27,7 +27,6 @@ function usePagination(options) {
|
|
|
27
27
|
return {
|
|
28
28
|
items,
|
|
29
29
|
showPagination: computed(() => total.value > perPage.value),
|
|
30
|
-
currentPage,
|
|
31
30
|
canFirst: computed(() => currentPage.value > 1),
|
|
32
31
|
canPrev: computed(() => currentPage.value > 1),
|
|
33
32
|
canNext: computed(() => currentPage.value < totalPages.value),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as nanostores17 from "nanostores";
|
|
2
2
|
import qs from "query-string";
|
|
3
3
|
|
|
4
4
|
//#region src/query-params/types.d.ts
|
|
@@ -13,7 +13,7 @@ interface UrlConfig {
|
|
|
13
13
|
declare function createUrlConfig(config: UrlConfig): UrlConfig;
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/query-params/store.d.ts
|
|
16
|
-
declare const urlConfigStore:
|
|
16
|
+
declare const urlConfigStore: nanostores17.PreinitializedWritableAtom<UrlConfig> & object;
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/query-params/url.d.ts
|
|
19
19
|
declare global {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stephenchenorg/astro",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"description": "Stephenchenorg Astro 前端通用套件",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://stephenchenorg-astro.netlify.app",
|
|
@@ -46,9 +46,13 @@
|
|
|
46
46
|
"types": "./dist/pagination-astro/index.d.ts",
|
|
47
47
|
"import": "./dist/pagination-astro/index.js"
|
|
48
48
|
},
|
|
49
|
-
"./pagination-vue": {
|
|
50
|
-
"types": "./dist/pagination-vue/index.d.ts",
|
|
51
|
-
"import": "./dist/pagination-vue/index.js"
|
|
49
|
+
"./pagination-vue-client-side": {
|
|
50
|
+
"types": "./dist/pagination-vue-client-side/index.d.ts",
|
|
51
|
+
"import": "./dist/pagination-vue-client-side/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./pagination-vue-server-side": {
|
|
54
|
+
"types": "./dist/pagination-vue-server-side/index.d.ts",
|
|
55
|
+
"import": "./dist/pagination-vue-server-side/index.js"
|
|
52
56
|
},
|
|
53
57
|
"./query-params": {
|
|
54
58
|
"types": "./dist/query-params/index.d.ts",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as vue1 from "vue";
|
|
2
|
-
import { MaybeRefOrGetter } from "vue";
|
|
3
|
-
|
|
4
|
-
//#region src/pagination-vue/types.d.ts
|
|
5
|
-
interface Paginator<T> {
|
|
6
|
-
total: number;
|
|
7
|
-
per_page: number;
|
|
8
|
-
data: T[];
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/pagination-vue/usePagination.d.ts
|
|
12
|
-
declare function usePagination(options: {
|
|
13
|
-
total: MaybeRefOrGetter<number>;
|
|
14
|
-
currentPage: MaybeRefOrGetter<number>;
|
|
15
|
-
url: string;
|
|
16
|
-
perPage?: MaybeRefOrGetter<number>;
|
|
17
|
-
visiblePages?: MaybeRefOrGetter<number>;
|
|
18
|
-
}): {
|
|
19
|
-
items: vue1.ComputedRef<number[]>;
|
|
20
|
-
showPagination: vue1.ComputedRef<boolean>;
|
|
21
|
-
currentPage: vue1.ComputedRef<number>;
|
|
22
|
-
canFirst: vue1.ComputedRef<boolean>;
|
|
23
|
-
canPrev: vue1.ComputedRef<boolean>;
|
|
24
|
-
canNext: vue1.ComputedRef<boolean>;
|
|
25
|
-
canLast: vue1.ComputedRef<boolean>;
|
|
26
|
-
firstUrl: vue1.ComputedRef<string>;
|
|
27
|
-
prevUrl: vue1.ComputedRef<string>;
|
|
28
|
-
nextUrl: vue1.ComputedRef<string>;
|
|
29
|
-
lastUrl: vue1.ComputedRef<string>;
|
|
30
|
-
getUrl: (page: number) => string;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
33
|
-
export { Paginator, usePagination };
|