@qlibs/utils 1.1.3 → 1.3.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/utils/image.d.ts +1 -1
- package/dist/utils/image.js +1 -0
- package/dist/utils/number.d.ts +2 -0
- package/dist/utils/number.js +38 -0
- package/package.json +1 -1
package/dist/utils/image.d.ts
CHANGED
@@ -8,5 +8,5 @@ export declare function bytesToMB(sizeInBytes: number): number;
|
|
8
8
|
export declare function isImage(file: File | Blob): any;
|
9
9
|
export declare const getBase64: (file: File) => Promise<string>;
|
10
10
|
export declare function fileListToBase64(fileList: any[]): Promise<string[]>;
|
11
|
-
export declare function getFile(newFile: any): any;
|
11
|
+
export declare function getFile(newFile: File | any): any;
|
12
12
|
export declare function isPhotoDataOK(item: any): boolean;
|
package/dist/utils/image.js
CHANGED
@@ -106,6 +106,7 @@ async function fileListToBase64(fileList) {
|
|
106
106
|
return (await Promise.all(promises));
|
107
107
|
}
|
108
108
|
function getFile(newFile) {
|
109
|
+
console.info('getFile - newFile instanceof File', newFile instanceof File);
|
109
110
|
if (isImage(newFile) && newFile.originFileObj) {
|
110
111
|
console.info('getFile - return (newFile as any).originFileObj');
|
111
112
|
return newFile.originFileObj;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.formatNumberRange = formatNumberRange;
|
4
|
+
exports.formatNumber = formatNumber;
|
5
|
+
function formatNumberRange(amountStart, amountEnd) {
|
6
|
+
if (amountStart === amountEnd) {
|
7
|
+
return formatNumber(amountStart);
|
8
|
+
}
|
9
|
+
else if (amountStart && amountEnd) {
|
10
|
+
return (formatNumber(amountStart) +
|
11
|
+
' - ' +
|
12
|
+
formatNumber(amountEnd));
|
13
|
+
}
|
14
|
+
else if (amountStart) {
|
15
|
+
return formatNumber(amountStart) + ' - unlimited';
|
16
|
+
}
|
17
|
+
else if (amountEnd) {
|
18
|
+
return 'up to ' + formatNumber(amountEnd);
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
return '';
|
22
|
+
}
|
23
|
+
}
|
24
|
+
function formatNumber(amount, thousandSep = ',', decimalSep = '.', showDecimal = true) {
|
25
|
+
if (typeof amount === 'string')
|
26
|
+
amount = Number(amount);
|
27
|
+
if (!amount)
|
28
|
+
amount = 0;
|
29
|
+
const [intPart, decPart] = amount.toFixed(2).split('.');
|
30
|
+
let intPartWithSep = '';
|
31
|
+
for (let i = intPart.length - 1, j = 0; i >= 0; i--, j++) {
|
32
|
+
if (j > 0 && j % 3 === 0) {
|
33
|
+
intPartWithSep = thousandSep + intPartWithSep;
|
34
|
+
}
|
35
|
+
intPartWithSep = intPart[i] + intPartWithSep;
|
36
|
+
}
|
37
|
+
return (intPartWithSep + (showDecimal ? decimalSep + decPart : ''));
|
38
|
+
}
|