@vesperjs/shared 0.3.2 → 0.4.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
@@ -46,8 +46,8 @@ declare const useBackendErrorInfo: <R extends object>() => {
46
46
  };
47
47
  //#endregion
48
48
  //#region src/composables/util/use-date.d.ts
49
- declare const useDate: () => {
50
- isValidDate: (str: string) => boolean;
49
+ declare const useDate: (fmtDate?: string, locale?: string) => {
50
+ isValidDate: (value: string) => boolean;
51
51
  };
52
52
  //#endregion
53
53
  //#region src/composables/use-entity.d.ts
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.2",
3
+ "version": "0.4.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.0",
25
- "@typescript-eslint/parser": "^8.59.0",
26
- "@typescript-eslint/project-service": "^8.59.0",
27
- "@typescript-eslint/typescript-estree": "^8.59.0",
28
- "@typescript-eslint/utils": "^8.59.0",
27
+ "@typescript-eslint/eslint-plugin": "^8.59.1",
28
+ "@typescript-eslint/parser": "^8.59.1",
29
29
  "@vue/eslint-config-typescript": "^14.7.0",
30
30
  "eslint": "^10.2.1",
31
31
  "eslint-plugin-vue": "^10.9.0",
32
- "oxfmt": "^0.46.0",
32
+ "oxfmt": "^0.47.0",
33
33
  "tsdown": "^0.21.10",
34
34
  "typescript": "^6.0.3",
35
- "typescript-eslint": "^8.59.0"
35
+ "typescript-eslint": "^8.59.1"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@vue/reactivity": "^3.5.33 || ^3.6.0-beta.10"