@dvrd/dvr-controls 1.1.3 → 1.1.5
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
package/src/js/util/miscUtil.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Copyright (c) 2024. Dave van Rijn Development
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import React from
|
|
7
|
-
import
|
|
5
|
+
import DOMPurify from 'dompurify';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import {IndexedObject} from './interfaces';
|
|
8
8
|
|
|
9
9
|
declare global {
|
|
10
10
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -22,7 +22,7 @@ export const getSetting = (name: string): any => {
|
|
|
22
22
|
if (settings.hasOwnProperty(name))
|
|
23
23
|
return settings[name];
|
|
24
24
|
console.warn(`Global settings does not contain a value for '${name}'`);
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
26
|
|
|
27
27
|
export const getMode = (): 'prod' | 'test' | 'dev' | 'accept' => {
|
|
28
28
|
return window.settings.mode;
|
|
@@ -74,7 +74,7 @@ export const roundTo = (number: number, digits: number = 0): string => {
|
|
|
74
74
|
|
|
75
75
|
export const roundToNumber = (number: number, decimals: number = 0): number => {
|
|
76
76
|
return Number(roundTo(number, decimals).replace(',', '.'));
|
|
77
|
-
}
|
|
77
|
+
};
|
|
78
78
|
|
|
79
79
|
export const parseMoney = (money: number): string => {
|
|
80
80
|
let moneyString: string;
|
|
@@ -110,7 +110,7 @@ export const downloadRequiredFile = (path: string | { default: string }, fileNam
|
|
|
110
110
|
link.type = 'download';
|
|
111
111
|
link.download = name;
|
|
112
112
|
link.click();
|
|
113
|
-
}
|
|
113
|
+
};
|
|
114
114
|
|
|
115
115
|
const getFileName = (path: string, fileName?: string): string => {
|
|
116
116
|
if (fileName?.length) return fileName;
|
|
@@ -119,7 +119,7 @@ const getFileName = (path: string, fileName?: string): string => {
|
|
|
119
119
|
if (pathName.match(cacheReg))
|
|
120
120
|
pathName = pathName.replace(cacheReg, '');
|
|
121
121
|
return pathName;
|
|
122
|
-
}
|
|
122
|
+
};
|
|
123
123
|
|
|
124
124
|
export const preventDefault = (evt: Event | React.SyntheticEvent) => {
|
|
125
125
|
evt.preventDefault();
|
|
@@ -138,7 +138,7 @@ export const shuffleArray = (arr: any[]): any[] => {
|
|
|
138
138
|
|
|
139
139
|
export function nullify<T extends string | Array<any> | Set<any> | number | bigint>(value?: T | null): T | null {
|
|
140
140
|
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
141
|
-
if (value
|
|
141
|
+
if (value === 0) return value;
|
|
142
142
|
return null;
|
|
143
143
|
}
|
|
144
144
|
if (!value) return null;
|
|
@@ -163,7 +163,7 @@ export const copyToClipboard = (text: string): Promise<void> => {
|
|
|
163
163
|
|
|
164
164
|
export const copyClipboard = (text: string): Promise<void> => {
|
|
165
165
|
return window.navigator.clipboard.writeText(text);
|
|
166
|
-
}
|
|
166
|
+
};
|
|
167
167
|
|
|
168
168
|
export function webpSupported(): boolean {
|
|
169
169
|
try {
|
|
@@ -27,7 +27,8 @@ export default class NumberString {
|
|
|
27
27
|
if (!nullString) return null;
|
|
28
28
|
const numValue = Number(nullString.replace(',', '.'));
|
|
29
29
|
if (Number.isNaN(numValue)) return null;
|
|
30
|
-
return
|
|
30
|
+
if(!numValue) return this.zeroAsNull ? null : 0;
|
|
31
|
+
return numValue;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
setValue = (value: string | number): NumberString => {
|