@quandis/qbo4.ui 4.0.1-CI-20241118-185949 → 4.0.1-CI-20241118-231433

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
@@ -3,7 +3,7 @@
3
3
  "author": "Quandis, Inc.",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "4.0.1-CI-20241118-185949",
6
+ "version": "4.0.1-CI-20241118-231433",
7
7
  "workspaces": [
8
8
  "code"
9
9
  ],
package/scss/qbo.scss CHANGED
@@ -444,7 +444,7 @@ nav {
444
444
 
445
445
  > span {
446
446
  font-weight: bold;
447
- margin-top: 17px;
447
+ margin-top: 14px;
448
448
  padding-inline-start: 10px;
449
449
  }
450
450
 
@@ -43,5 +43,3 @@ export declare function matches(source: any, match: any, wildCard?: string, igno
43
43
  export declare function elementData(element: HTMLElement): Record<string, string>;
44
44
  export declare function elementDate(date: string): string;
45
45
  export declare function elementDateTime(date: string): string;
46
- export declare function elementMoney(amount: string, currency?: string, locale?: string): string;
47
- export declare function elementPercentage(value: string, decimals?: number, locale?: string): string;
@@ -54,20 +54,3 @@ export function elementDateTime(date) {
54
54
  return '';
55
55
  return new Date(date).toLocaleString().replace(',', '');
56
56
  }
57
- export function elementMoney(amount, currency = 'USD', locale = 'en-US') {
58
- if (!amount)
59
- return '';
60
- return new Intl.NumberFormat(locale, {
61
- style: 'currency',
62
- currency,
63
- }).format(Number(amount));
64
- }
65
- export function elementPercentage(value, decimals = 2, locale = 'en-US') {
66
- if (!value)
67
- return '';
68
- return new Intl.NumberFormat(locale, {
69
- style: 'percent',
70
- minimumFractionDigits: decimals,
71
- maximumFractionDigits: decimals,
72
- }).format(Number(value));
73
- }
@@ -73,20 +73,3 @@ export function elementDateTime(date: string) {
73
73
  if (!date || date.trim() == '') return '';
74
74
  return new Date(date).toLocaleString().replace(',', '');
75
75
  }
76
-
77
- export function elementMoney(amount: string, currency: string = 'USD', locale: string = 'en-US'): string {
78
- if (!amount) return '';
79
- return new Intl.NumberFormat(locale, {
80
- style: 'currency',
81
- currency,
82
- }).format(Number(amount));
83
- }
84
-
85
- export function elementPercentage(value: string, decimals: number = 2, locale: string = 'en-US'): string {
86
- if (!value) return '';
87
- return new Intl.NumberFormat(locale, {
88
- style: 'percent',
89
- minimumFractionDigits: decimals,
90
- maximumFractionDigits: decimals,
91
- }).format(Number(value));
92
- }
@@ -16,3 +16,6 @@ export declare function setUserPreference(preference: string, value: any, storag
16
16
  export declare function getUserPreference(preference: string, storageKey?: string): any;
17
17
  export declare function join(values: (string | null | undefined)[], separator?: string): string;
18
18
  export declare function formatDate(dateString: string | Date | undefined | null, format?: string | null): string | null;
19
+ export declare function formatMoney(amount: string | number | undefined | null, currency?: string, locale?: string): string;
20
+ export declare function formatPercentage(value: string | number | undefined | null, decimals?: number, locale?: string): string;
21
+ export declare function timeRemaining(targetDate: string | Date | undefined | null, interval?: string): import("lit-html").TemplateResult<1> | null;
@@ -176,3 +176,36 @@ export function formatDate(dateString, format = null) {
176
176
  const formattedDate = new Intl.DateTimeFormat(undefined, options).format(new Date(dateString));
177
177
  return formattedDate;
178
178
  }
179
+ export function formatMoney(amount, currency = 'USD', locale = 'en-US') {
180
+ if (!amount)
181
+ return '';
182
+ return new Intl.NumberFormat(locale, {
183
+ style: 'currency',
184
+ currency,
185
+ }).format(Number(amount));
186
+ }
187
+ export function formatPercentage(value, decimals = 2, locale = 'en-US') {
188
+ if (!value)
189
+ return '';
190
+ return new Intl.NumberFormat(locale, {
191
+ style: 'percent',
192
+ minimumFractionDigits: decimals,
193
+ maximumFractionDigits: decimals,
194
+ }).format(Number(value));
195
+ }
196
+ export function timeRemaining(targetDate, interval = 'months') {
197
+ if (targetDate == null || isNaN(new Date(targetDate).getTime()))
198
+ return null;
199
+ let years = new Date(targetDate).getFullYear() - new Date().getFullYear();
200
+ let months = new Date(targetDate).getMonth() - new Date().getMonth();
201
+ if (months < 0) {
202
+ years -= 1;
203
+ months = 12 + months;
204
+ }
205
+ if (years < 1 && months < 1)
206
+ return html ``;
207
+ else if (years < 1 && months > 0)
208
+ return html `${months} month${months > 1 ? 's' : ''}`;
209
+ else
210
+ return html `${years} year${years > 1 ? 's' : ''}, ${months} month${months != 1 ? 's' : ''} (${years * 12 + months})`;
211
+ }
@@ -165,3 +165,41 @@ export function formatDate(dateString: string | Date | undefined | null, format:
165
165
 
166
166
  return formattedDate;
167
167
  }
168
+
169
+ export function formatMoney(amount: string | number | undefined | null, currency: string = 'USD', locale: string = 'en-US'): string {
170
+ if (!amount) return '';
171
+ return new Intl.NumberFormat(locale, {
172
+ style: 'currency',
173
+ currency,
174
+ }).format(Number(amount));
175
+ }
176
+
177
+ export function formatPercentage(value: string | number | undefined | null, decimals: number = 2, locale: string = 'en-US'): string {
178
+ if (!value) return '';
179
+ return new Intl.NumberFormat(locale, {
180
+ style: 'percent',
181
+ minimumFractionDigits: decimals,
182
+ maximumFractionDigits: decimals,
183
+ }).format(Number(value));
184
+ }
185
+
186
+ export function timeRemaining(targetDate: string | Date | undefined | null, interval: string = 'months') {
187
+
188
+ if (targetDate == null || isNaN(new Date(targetDate).getTime()))
189
+ return null;
190
+
191
+ let years = new Date(targetDate).getFullYear() - new Date().getFullYear();
192
+ let months = new Date(targetDate).getMonth() - new Date().getMonth();
193
+
194
+ if (months < 0) {
195
+ years -= 1;
196
+ months = 12 + months;
197
+ }
198
+
199
+ if (years < 1 && months < 1)
200
+ return html``;
201
+ else if (years < 1 && months > 0)
202
+ return html`${months} month${months > 1 ? 's' : ''}`;
203
+ else
204
+ return html`${years} year${years > 1 ? 's' : ''}, ${months} month${months != 1 ? 's' : ''} (${years * 12 + months})`;
205
+ }