@signal24/vue-foundation 4.23.0 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@signal24/vue-foundation",
3
3
  "type": "module",
4
- "version": "4.23.0",
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,7 +44,7 @@
43
44
  "vue": "^3.4.0"
44
45
  },
45
46
  "devDependencies": {
46
- "@eslint/js": "9.26.0",
47
+ "@eslint/js": "9.27.0",
47
48
  "@nabla/vite-plugin-eslint": "^2.0.5",
48
49
  "@signal24/openapi-client-codegen": "^2.5.0",
49
50
  "@tsconfig/node22": "^22.0.1",
@@ -58,7 +59,7 @@
58
59
  "@vue/tsconfig": "^0.7.0",
59
60
  "cypress": "^14.3.3",
60
61
  "date-fns": "^4.1.0",
61
- "eslint": "9.26.0",
62
+ "eslint": "9.27.0",
62
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",
@@ -66,14 +67,14 @@
66
67
  "jsdom": "^26.1.0",
67
68
  "lodash": "^4.17.21",
68
69
  "prettier": "^3.5.3",
69
- "sass": "^1.88.0",
70
- "start-server-and-test": "^2.0.11",
70
+ "sass": "^1.89.0",
71
+ "start-server-and-test": "^2.0.12",
71
72
  "type-fest": "^4.41.0",
72
73
  "typescript": "~5.8",
73
74
  "typescript-eslint": "^8.32.1",
74
75
  "vite": "^6.3.5",
75
76
  "vitest": "^3.1.3",
76
- "vue": "^3.5.13",
77
+ "vue": "^3.5.14",
77
78
  "vue-tsc": "^2.2.10"
78
79
  },
79
80
  "packageManager": "yarn@4.6.0"
@@ -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;
@@ -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() {