@stephenchenorg/astro 8.1.0 → 8.3.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { PropType } from "vue";
|
|
1
|
+
import * as vue15 from "vue";
|
|
2
|
+
import { PropType, SlotsType } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/form-validator/types.d.ts
|
|
5
5
|
type FormErrors = Record<string, string[]>;
|
|
@@ -23,7 +23,7 @@ declare class FormValidator {
|
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/form-validator/components/FormField.d.ts
|
|
26
|
-
declare const FormField:
|
|
26
|
+
declare const FormField: vue15.DefineComponent<vue15.ExtractPropTypes<{
|
|
27
27
|
id: {
|
|
28
28
|
type: StringConstructor;
|
|
29
29
|
required: true;
|
|
@@ -32,9 +32,9 @@ declare const FormField: vue5.DefineComponent<vue5.ExtractPropTypes<{
|
|
|
32
32
|
type: PropType<FormRule[]>;
|
|
33
33
|
default: () => never[];
|
|
34
34
|
};
|
|
35
|
-
}>, () =>
|
|
35
|
+
}>, () => vue15.VNode<vue15.RendererNode, vue15.RendererElement, {
|
|
36
36
|
[key: string]: any;
|
|
37
|
-
}>[]
|
|
37
|
+
}>[], {}, {}, {}, vue15.ComponentOptionsMixin, vue15.ComponentOptionsMixin, {}, string, vue15.PublicProps, Readonly<vue15.ExtractPropTypes<{
|
|
38
38
|
id: {
|
|
39
39
|
type: StringConstructor;
|
|
40
40
|
required: true;
|
|
@@ -45,27 +45,35 @@ declare const FormField: vue5.DefineComponent<vue5.ExtractPropTypes<{
|
|
|
45
45
|
};
|
|
46
46
|
}>> & Readonly<{}>, {
|
|
47
47
|
rules: FormRule[];
|
|
48
|
-
}, {
|
|
48
|
+
}, SlotsType<{
|
|
49
|
+
default: {
|
|
50
|
+
error: string | null;
|
|
51
|
+
};
|
|
52
|
+
}>, {}, {}, string, vue15.ComponentProvideOptions, true, {}, any>;
|
|
49
53
|
//#endregion
|
|
50
54
|
//#region src/form-validator/components/FormValidatorProvider.d.ts
|
|
51
55
|
interface FormValidatorProviderExposed {
|
|
52
56
|
formValidator: () => FormValidator;
|
|
53
57
|
}
|
|
54
|
-
declare const FormValidatorProvider:
|
|
58
|
+
declare const FormValidatorProvider: vue15.DefineComponent<vue15.ExtractPropTypes<{
|
|
55
59
|
errors: {
|
|
56
60
|
type: PropType<FormErrors>;
|
|
57
61
|
default: () => {};
|
|
58
62
|
};
|
|
59
|
-
}>, () =>
|
|
63
|
+
}>, () => vue15.VNode<vue15.RendererNode, vue15.RendererElement, {
|
|
60
64
|
[key: string]: any;
|
|
61
|
-
}>[]
|
|
65
|
+
}>[], {}, {}, {}, vue15.ComponentOptionsMixin, vue15.ComponentOptionsMixin, {}, string, vue15.PublicProps, Readonly<vue15.ExtractPropTypes<{
|
|
62
66
|
errors: {
|
|
63
67
|
type: PropType<FormErrors>;
|
|
64
68
|
default: () => {};
|
|
65
69
|
};
|
|
66
70
|
}>> & Readonly<{}>, {
|
|
67
71
|
errors: FormErrors;
|
|
68
|
-
}, {
|
|
72
|
+
}, SlotsType<{
|
|
73
|
+
default: {
|
|
74
|
+
errors: FormErrors;
|
|
75
|
+
};
|
|
76
|
+
}>, {}, {}, string, vue15.ComponentProvideOptions, true, {}, any>;
|
|
69
77
|
//#endregion
|
|
70
78
|
//#region src/form-validator/useFormValidator.d.ts
|
|
71
79
|
declare function useFormValidator(): FormValidator;
|
|
@@ -25,12 +25,13 @@ const FormField = defineComponent({
|
|
|
25
25
|
default: () => []
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
+
slots: Object,
|
|
28
29
|
setup(props, { slots }) {
|
|
29
|
-
const error = ref(
|
|
30
|
+
const error = ref(null);
|
|
30
31
|
const formValidator = useFormValidator();
|
|
31
32
|
if (props.rules) formValidator.appendRules(props.id, props.rules);
|
|
32
33
|
formValidator.onErrorsUpdated((errors) => {
|
|
33
|
-
error.value = errors[props.id]?.[0];
|
|
34
|
+
error.value = errors[props.id]?.[0] || null;
|
|
34
35
|
});
|
|
35
36
|
return () => slots.default?.({ error: error.value });
|
|
36
37
|
}
|
|
@@ -90,6 +91,7 @@ const FormValidatorProvider = defineComponent({
|
|
|
90
91
|
type: Object,
|
|
91
92
|
default: () => ({})
|
|
92
93
|
} },
|
|
94
|
+
slots: Object,
|
|
93
95
|
setup(props, { slots, expose }) {
|
|
94
96
|
const formValidator = new FormValidator();
|
|
95
97
|
provide(formValidatorInjectionKey, formValidator);
|
package/dist/page/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as graphql4 from "graphql";
|
|
2
2
|
|
|
3
3
|
//#region src/page/field/fragments.d.ts
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import * as graphql3 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: graphql4.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) => graphql4.DocumentNode;
|
|
92
92
|
//#endregion
|
|
93
93
|
//#region src/page/seo-meta/helpers.d.ts
|
|
94
94
|
type UseSeoMetaOptions = Partial<Omit<PageMeta, 'title'>> & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue5 from "vue";
|
|
2
2
|
import { MaybeRefOrGetter } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/pagination-vue-server-side/types.d.ts
|
|
@@ -16,16 +16,16 @@ declare function usePagination(options: {
|
|
|
16
16
|
perPage?: MaybeRefOrGetter<number | undefined>;
|
|
17
17
|
visiblePages?: MaybeRefOrGetter<number | undefined>;
|
|
18
18
|
}): {
|
|
19
|
-
items:
|
|
20
|
-
showPagination:
|
|
21
|
-
canFirst:
|
|
22
|
-
canPrev:
|
|
23
|
-
canNext:
|
|
24
|
-
canLast:
|
|
25
|
-
firstUrl:
|
|
26
|
-
prevUrl:
|
|
27
|
-
nextUrl:
|
|
28
|
-
lastUrl:
|
|
19
|
+
items: vue5.ComputedRef<number[]>;
|
|
20
|
+
showPagination: vue5.ComputedRef<boolean>;
|
|
21
|
+
canFirst: vue5.ComputedRef<boolean>;
|
|
22
|
+
canPrev: vue5.ComputedRef<boolean>;
|
|
23
|
+
canNext: vue5.ComputedRef<boolean>;
|
|
24
|
+
canLast: vue5.ComputedRef<boolean>;
|
|
25
|
+
firstUrl: vue5.ComputedRef<string>;
|
|
26
|
+
prevUrl: vue5.ComputedRef<string>;
|
|
27
|
+
nextUrl: vue5.ComputedRef<string>;
|
|
28
|
+
lastUrl: vue5.ComputedRef<string>;
|
|
29
29
|
getUrl: (page: number) => string;
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
@@ -22,6 +22,7 @@ declare global {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
interface QueryParamsUrlOptions {
|
|
25
|
+
mergeArray?: string[];
|
|
25
26
|
clear?: boolean;
|
|
26
27
|
transformParams?: (params: Record<string, any>) => Record<string, any>;
|
|
27
28
|
}
|
|
@@ -29,7 +30,10 @@ declare function queryParamsUrl(additionalParams: Record<string, any>, urlConfig
|
|
|
29
30
|
declare function parseQueryParams(search: string): qs.ParsedQuery<string>;
|
|
30
31
|
//#endregion
|
|
31
32
|
//#region src/query-params/utils.d.ts
|
|
32
|
-
|
|
33
|
+
interface MergeUrlParamsOptions {
|
|
34
|
+
mergeArray?: string[];
|
|
35
|
+
}
|
|
36
|
+
declare function mergeUrlParams<Params extends Record<string, any> = Record<string, any>>(baseParams: Params, userParams: Partial<Params>, options?: MergeUrlParamsOptions): Params;
|
|
33
37
|
declare function cleanParams(params: Record<string, any>, defaultParams: Record<string, any>): Record<string, any>;
|
|
34
38
|
//#endregion
|
|
35
|
-
export { QueryParamsUrlOptions, UrlConfig, cleanParams, createUrlConfig, mergeUrlParams, parseQueryParams, queryParamsUrl, urlConfigStore };
|
|
39
|
+
export { MergeUrlParamsOptions, QueryParamsUrlOptions, UrlConfig, cleanParams, createUrlConfig, mergeUrlParams, parseQueryParams, queryParamsUrl, urlConfigStore };
|
|
@@ -17,10 +17,12 @@ const urlConfigStore = atom({
|
|
|
17
17
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/query-params/utils.ts
|
|
20
|
-
function mergeUrlParams(baseParams, userParams) {
|
|
20
|
+
function mergeUrlParams(baseParams, userParams, options = {}) {
|
|
21
|
+
const { mergeArray = [] } = options;
|
|
21
22
|
return Object.keys(baseParams).reduce((result, key) => {
|
|
22
23
|
if (userParams[key] === null) result[key] = null;
|
|
23
|
-
else if (Array.isArray(baseParams[key])) result[key] = Array.from(new Set([...baseParams[key], ...userParams[key] || []]));
|
|
24
|
+
else if (Array.isArray(baseParams[key])) if (mergeArray.includes(key)) result[key] = Array.from(new Set([...baseParams[key], ...userParams[key] || []]));
|
|
25
|
+
else result[key] = userParams[key] || baseParams[key] || [];
|
|
24
26
|
else result[key] = typeof userParams[key] !== "undefined" ? userParams[key] : baseParams[key];
|
|
25
27
|
return result;
|
|
26
28
|
}, {});
|
|
@@ -39,11 +41,11 @@ function queryParamsUrl(additionalParams, urlConfig = {
|
|
|
39
41
|
baseUrl: "",
|
|
40
42
|
params: {}
|
|
41
43
|
}, options = {}) {
|
|
42
|
-
const { clear = false, transformParams } = options;
|
|
44
|
+
const { mergeArray = [], clear = false, transformParams } = options;
|
|
43
45
|
const config = typeof window !== "undefined" ? urlConfigStore.get() : urlConfig;
|
|
44
46
|
let params = {};
|
|
45
47
|
if (!clear) {
|
|
46
|
-
params = mergeUrlParams(config.params, additionalParams);
|
|
48
|
+
params = mergeUrlParams(config.params, additionalParams, { mergeArray });
|
|
47
49
|
if (transformParams) params = transformParams(params);
|
|
48
50
|
params = cleanParams(params, config.defaultParams || {});
|
|
49
51
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stephenchenorg/astro",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.3.0",
|
|
5
5
|
"description": "Stephenchenorg Astro 前端通用套件",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://stephenchenorg-astro.netlify.app",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@astrojs/check": "^0.9.4",
|
|
106
106
|
"@astrojs/vue": "^5.1.0",
|
|
107
|
-
"@ycs77/eslint-config": "^5.0.
|
|
107
|
+
"@ycs77/eslint-config": "^5.0.1",
|
|
108
108
|
"astro": "^5.13.4",
|
|
109
109
|
"bumpp": "^10.2.3",
|
|
110
110
|
"eslint": "^9.34.0",
|