@vesperjs/shared 0.3.3 → 0.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.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import * as _$_vue_reactivity0 from "@vue/reactivity";
2
- import { Ref } from "@vue/reactivity";
1
+ import { ComputedRef, Ref, WritableComputedRef } from "@vue/reactivity";
3
2
 
4
3
  //#region src/types/error/backend-error-info.d.ts
5
4
  interface BackendErrorInfo<BER> {
@@ -34,20 +33,20 @@ declare const useExternalErrors: <P extends string>({
34
33
  }: {
35
34
  flash: Ref<Flash>;
36
35
  }) => {
37
- externalErrors: _$_vue_reactivity0.WritableComputedRef<Partial<Record<P, string[]>>, Partial<Record<P, string[]>>>;
36
+ externalErrors: WritableComputedRef<Partial<Record<P, string[]>>, Partial<Record<P, string[]>>>;
38
37
  clearExternalErrors: () => void;
39
38
  isSuccess: () => boolean;
40
39
  };
41
40
  //#endregion
42
41
  //#region src/composables/backend/error/use-backend-error-info.d.ts
43
42
  declare const useBackendErrorInfo: <R extends object>() => {
44
- backendErrorInfo: _$_vue_reactivity0.ComputedRef<BackendErrorInfo<R>>;
43
+ backendErrorInfo: ComputedRef<BackendErrorInfo<R>>;
45
44
  clearBackendErrorInfo: () => void;
46
45
  };
47
46
  //#endregion
48
47
  //#region src/composables/util/use-date.d.ts
49
- declare const useDate: () => {
50
- isValidDate: (str: string) => boolean;
48
+ declare const useDate: (fmtDate?: string, locale?: string) => {
49
+ isValidDate: (value: string) => boolean;
51
50
  };
52
51
  //#endregion
53
52
  //#region src/composables/use-entity.d.ts
@@ -55,20 +54,20 @@ declare const useEntity: <M extends object, R extends object = M>() => {
55
54
  create: ({
56
55
  from
57
56
  }: {
58
- from: R | M;
57
+ from: M | R;
59
58
  }) => M;
60
59
  copy: ({
61
60
  from,
62
61
  to
63
62
  }: {
64
- from: R | M;
63
+ from: M | R;
65
64
  to: M;
66
65
  }) => void;
67
66
  };
68
67
  //#endregion
69
68
  //#region src/composables/use-flash.d.ts
70
69
  declare const useFlash: () => {
71
- flash: _$_vue_reactivity0.Ref<{
70
+ flash: Ref<{
72
71
  notice?: string | undefined;
73
72
  alert?: string | undefined;
74
73
  }, Flash | {
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { computed, ref } from "@vue/reactivity";
2
+ import { parse } from "@formkit/tempo";
2
3
  //#region src/composables/backend/error/use-external-errors.ts
3
4
  const useExternalErrors = function({ flash }) {
4
5
  const errors = ref({});
@@ -42,9 +43,14 @@ const useBackendErrorInfo = function() {
42
43
  };
43
44
  //#endregion
44
45
  //#region src/composables/util/use-date.ts
45
- const useDate = function() {
46
- const isValidDate = (str) => {
47
- return !!str && !!str.match(/\d{4}\/\d{2}\/\d{2}/) && !isNaN(Date.parse(str));
46
+ const useDate = function(fmtDate = "YYYY/MM/DD", locale) {
47
+ const isValidDate = (value) => {
48
+ try {
49
+ const date = value ? parse(value, fmtDate, locale) : null;
50
+ return date instanceof Date && !isNaN(date.getTime());
51
+ } catch {
52
+ return false;
53
+ }
48
54
  };
49
55
  return { isValidDate };
50
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesperjs/shared",
3
- "version": "0.3.3",
3
+ "version": "0.5.0",
4
4
  "keywords": [
5
5
  "Nuxt",
6
6
  "vue.js"
@@ -19,20 +19,20 @@
19
19
  ".": "./dist/index.mjs",
20
20
  "./package.json": "./package.json"
21
21
  },
22
+ "dependencies": {
23
+ "@formkit/tempo": "^1.0.0"
24
+ },
22
25
  "devDependencies": {
23
26
  "@eslint/js": "^10.0.1",
24
- "@typescript-eslint/eslint-plugin": "^8.59.1",
25
- "@typescript-eslint/parser": "^8.59.1",
26
- "@typescript-eslint/project-service": "^8.59.1",
27
- "@typescript-eslint/typescript-estree": "^8.59.1",
28
- "@typescript-eslint/utils": "^8.59.1",
27
+ "@typescript-eslint/eslint-plugin": "^8.59.2",
28
+ "@typescript-eslint/parser": "^8.59.2",
29
29
  "@vue/eslint-config-typescript": "^14.7.0",
30
- "eslint": "^10.2.1",
30
+ "eslint": "^10.3.0",
31
31
  "eslint-plugin-vue": "^10.9.0",
32
32
  "oxfmt": "^0.47.0",
33
33
  "tsdown": "^0.21.10",
34
34
  "typescript": "^6.0.3",
35
- "typescript-eslint": "^8.59.1"
35
+ "typescript-eslint": "^8.59.2"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@vue/reactivity": "^3.5.33 || ^3.6.0-beta.10"