@stephenchenorg/astro 8.4.1 → 8.5.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.
@@ -72,6 +72,7 @@ declare const FormValidatorProvider: vue15.DefineComponent<vue15.ExtractPropType
72
72
  }, SlotsType<{
73
73
  default: {
74
74
  errors: FormErrors;
75
+ hasErrors: boolean;
75
76
  };
76
77
  }>, {}, {}, string, vue15.ComponentProvideOptions, true, {}, any>;
77
78
  //#endregion
@@ -1,4 +1,4 @@
1
- import { defineComponent, inject, onMounted, provide, ref, toRaw, watch } from "vue";
1
+ import { defineComponent, inject, onMounted, provide, ref, shallowRef, toRaw, watch } from "vue";
2
2
 
3
3
  //#region src/form-validator/injectionKey.ts
4
4
  const formValidatorInjectionKey = Symbol("");
@@ -94,7 +94,13 @@ const FormValidatorProvider = defineComponent({
94
94
  slots: Object,
95
95
  setup(props, { slots, expose }) {
96
96
  const formValidator = new FormValidator();
97
+ const errors = shallowRef({});
98
+ const hasErrors = ref(false);
97
99
  provide(formValidatorInjectionKey, formValidator);
100
+ formValidator.onErrorsUpdated((_errors) => {
101
+ hasErrors.value = Object.keys(_errors).length > 0;
102
+ errors.value = structuredClone(_errors);
103
+ });
98
104
  onMounted(() => {
99
105
  formValidator.setErrors(props.errors);
100
106
  });
@@ -102,7 +108,10 @@ const FormValidatorProvider = defineComponent({
102
108
  formValidator.setErrors(props.errors);
103
109
  }, { deep: true });
104
110
  expose({ formValidator: () => formValidator });
105
- return () => slots.default?.({ errors: formValidator.errors });
111
+ return () => slots.default?.({
112
+ errors: errors.value,
113
+ hasErrors: hasErrors.value
114
+ });
106
115
  }
107
116
  });
108
117
  var FormValidatorProvider_default = FormValidatorProvider;
@@ -1,4 +1,4 @@
1
- import * as graphql3 from "graphql";
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: graphql3.DocumentNode;
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) => graphql3.DocumentNode;
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'>> & {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stephenchenorg/astro",
3
3
  "type": "module",
4
- "version": "8.4.1",
4
+ "version": "8.5.0",
5
5
  "description": "Stephenchenorg Astro 前端通用套件",
6
6
  "license": "MIT",
7
7
  "homepage": "https://stephenchenorg-astro.netlify.app",