@signal24/vue-foundation 4.21.1 → 4.24.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/eslint.config.mjs CHANGED
@@ -3,6 +3,7 @@ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
3
3
  import simpleImportSort from 'eslint-plugin-simple-import-sort';
4
4
  import unusedImports from 'eslint-plugin-unused-imports';
5
5
  import pluginVue from 'eslint-plugin-vue';
6
+ import globals from 'globals';
6
7
  import tseslint from 'typescript-eslint';
7
8
 
8
9
  export default tseslint.config(
@@ -27,11 +28,13 @@ export default tseslint.config(
27
28
  projectService: true
28
29
  },
29
30
 
30
- // not sure why some of these TS generics are needed.
31
- // will circle back when Vue officially updates to ESLint 9
32
31
  globals: {
32
+ // not sure why some of these TS generics are needed.
33
+ // will circle back when Vue officially updates to ESLint 9
33
34
  Omit: false,
34
- Record: false
35
+ Record: false,
36
+
37
+ ...globals.browser
35
38
  }
36
39
  }
37
40
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signal24/vue-foundation",
3
3
  "type": "module",
4
- "version": "4.21.1",
4
+ "version": "4.24.0",
5
5
  "description": "Common components, directives, and helpers for Vue 3 apps",
6
6
  "module": "./dist/vue-foundation.es.js",
7
7
  "exports": {
@@ -34,6 +34,7 @@
34
34
  },
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
+ "currency.js": "^2.0.4",
37
38
  "uuid": "^11.1.0"
38
39
  },
39
40
  "peerDependencies": {
@@ -43,38 +44,38 @@
43
44
  "vue": "^3.4.0"
44
45
  },
45
46
  "devDependencies": {
46
- "@eslint/js": "9.21.0",
47
+ "@eslint/js": "9.27.0",
47
48
  "@nabla/vite-plugin-eslint": "^2.0.5",
48
- "@signal24/openapi-client-codegen": "^2.2.1",
49
- "@tsconfig/node22": "^22.0.0",
49
+ "@signal24/openapi-client-codegen": "^2.5.0",
50
+ "@tsconfig/node22": "^22.0.1",
50
51
  "@types/jsdom": "^21.1.7",
51
52
  "@types/lodash": "^4.17.16",
52
- "@types/node": "^22.13.8",
53
+ "@types/node": "^22.15.18",
53
54
  "@types/uuid": "^10.0.0",
54
- "@vitejs/plugin-vue": "^5.2.1",
55
+ "@vitejs/plugin-vue": "^5.2.4",
55
56
  "@vue/eslint-config-prettier": "^10.2.0",
56
- "@vue/eslint-config-typescript": "^14.4.0",
57
+ "@vue/eslint-config-typescript": "^14.5.0",
57
58
  "@vue/test-utils": "^2.4.6",
58
59
  "@vue/tsconfig": "^0.7.0",
59
- "cypress": "^14.1.0",
60
+ "cypress": "^14.3.3",
60
61
  "date-fns": "^4.1.0",
61
- "eslint": "9.21.0",
62
- "eslint-plugin-cypress": "^4.1.0",
62
+ "eslint": "9.27.0",
63
+ "eslint-plugin-cypress": "^4.3.0",
63
64
  "eslint-plugin-simple-import-sort": "^12.1.1",
64
65
  "eslint-plugin-unused-imports": "^4.1.4",
65
- "eslint-plugin-vue": "^9.32.0",
66
- "jsdom": "^26.0.0",
66
+ "eslint-plugin-vue": "^10.1.0",
67
+ "jsdom": "^26.1.0",
67
68
  "lodash": "^4.17.21",
68
- "prettier": "^3.5.2",
69
- "sass": "^1.85.1",
70
- "start-server-and-test": "^2.0.10",
71
- "type-fest": "^4.36.0",
69
+ "prettier": "^3.5.3",
70
+ "sass": "^1.89.0",
71
+ "start-server-and-test": "^2.0.12",
72
+ "type-fest": "^4.41.0",
72
73
  "typescript": "~5.8",
73
- "typescript-eslint": "^8.25.0",
74
- "vite": "^6.2.0",
75
- "vitest": "^3.0.7",
76
- "vue": "^3.5.13",
77
- "vue-tsc": "^2.2.4"
74
+ "typescript-eslint": "^8.32.1",
75
+ "vite": "^6.3.5",
76
+ "vitest": "^3.1.3",
77
+ "vue": "^3.5.14",
78
+ "vue-tsc": "^2.2.10"
78
79
  },
79
80
  "packageManager": "yarn@4.6.0"
80
81
  }
@@ -1,5 +1,9 @@
1
+ import currency from 'currency.js';
2
+ import { addDays, format, parse } from 'date-fns';
1
3
  import { startCase as _startCase, upperFirst as _upperFirst } from 'lodash';
2
4
 
5
+ import { VfOptions } from '@/config';
6
+
3
7
  import { desnakeCase, formatNumber, formatPhone, formatUSCurrency } from '..';
4
8
 
5
9
  function bytes(value: number) {
@@ -48,6 +52,12 @@ function upperCase(value: string | null) {
48
52
  return value ? value.toUpperCase() : null;
49
53
  }
50
54
 
55
+ function upperWords(value: null): null;
56
+ function upperWords(value: string): string;
57
+ function upperWords(value: string | null) {
58
+ return value ? startCase(value.toLowerCase()) : null;
59
+ }
60
+
51
61
  function desnake(value: null): null;
52
62
  function desnake(value: string): string;
53
63
  function desnake(value: string | null) {
@@ -58,6 +68,30 @@ function usCurrency(value: string | number, divisor = 1) {
58
68
  return formatUSCurrency(value, divisor);
59
69
  }
60
70
 
71
+ function divide(value: number, divisor: number) {
72
+ return currency(value).divide(divisor).value;
73
+ }
74
+
75
+ function date(value: string | null, formatStr?: string) {
76
+ if (!value) return value;
77
+ return format(new Date(value), formatStr ?? VfOptions.defaultDateFormat);
78
+ }
79
+
80
+ function time(value: string | null, formatStr?: string) {
81
+ if (!value) return value;
82
+ return format(new Date(value), formatStr ?? VfOptions.defaultTimeFormat);
83
+ }
84
+
85
+ function dateTime(value: string | null, formatStr?: string) {
86
+ if (!value) return value;
87
+ return format(new Date(value), formatStr ?? VfOptions.defaultDateFormat);
88
+ }
89
+
90
+ function oneDayForward(date?: string | null) {
91
+ if (!date) return date;
92
+ return format(addDays(parse(date, 'yyyy-MM-dd', new Date()), 1), VfOptions.defaultDateFormat);
93
+ }
94
+
61
95
  const FilterFns = {
62
96
  bytes,
63
97
  dash,
@@ -67,8 +101,14 @@ const FilterFns = {
67
101
  upperFirst,
68
102
  startCase,
69
103
  upperCase,
104
+ upperWords,
70
105
  desnake,
71
- usCurrency
106
+ usCurrency,
107
+ divide,
108
+ date,
109
+ time,
110
+ dateTime,
111
+ oneDayForward
72
112
  };
73
113
 
74
114
  // type FilterFn = (value: any, ...unknown: any[]) => any;
@@ -20,7 +20,14 @@ export function formatError(err: any): string {
20
20
 
21
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
22
  export function toError(err: any) {
23
- return err instanceof Error ? err : new Error(String(err));
23
+ if (isError(err)) return err;
24
+ return new Error(String(err));
25
+ }
26
+
27
+ export function isError(err: unknown): err is Error {
28
+ if (err instanceof Error) return true;
29
+ if (typeof err === 'object' && err !== null && 'message' in err && 'name' in err) return true;
30
+ return false;
24
31
  }
25
32
 
26
33
  interface IErrorAlertOptions {
@@ -1,3 +1,4 @@
1
+ import currency from 'currency.js';
1
2
  import { v4 as uuidv4 } from 'uuid';
2
3
 
3
4
  // placing this here so we don't have to use the ESLint rule everywhere
@@ -19,13 +20,7 @@ export function formatPhone(value: string) {
19
20
  }
20
21
 
21
22
  export function formatUSCurrency(value: string | number, divisor = 1) {
22
- return (
23
- '$' +
24
- (Number(value) / divisor)
25
- .toFixed(3)
26
- .replace(/0$/, '')
27
- .replace(/\B(?=(\d{3})+(?!\d))/g, ',')
28
- );
23
+ return currency(value).divide(divisor).format();
29
24
  }
30
25
 
31
26
  export function uuid() {