@cloudparker/moldex.js 4.1.7 → 4.1.9
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/actions/badge.d.ts +12 -0
- package/dist/actions/badge.js +22 -0
- package/dist/actions/index.d.ts +3 -0
- package/dist/actions/index.js +3 -0
- package/dist/actions/no-context-menu.d.ts +3 -0
- package/dist/actions/no-context-menu.js +11 -0
- package/dist/actions/ripple.css +29 -0
- package/dist/actions/ripple.d.ts +7 -0
- package/dist/actions/ripple.js +74 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/services/date/date-service.d.ts +52 -0
- package/dist/services/date/date-service.js +206 -0
- package/dist/services/dialog/dialog-service.d.ts +96 -0
- package/dist/services/dialog/dialog-service.js +350 -0
- package/dist/services/index.d.ts +12 -0
- package/dist/services/index.js +12 -0
- package/dist/services/navigation/navigation-service.d.ts +39 -0
- package/dist/services/navigation/navigation-service.js +100 -0
- package/dist/services/screen/screen-service.d.ts +17 -0
- package/dist/services/screen/screen-service.js +40 -0
- package/dist/services/toast/toast-service.d.ts +5 -0
- package/dist/services/toast/toast-service.js +26 -0
- package/dist/services/utils/color-service.d.ts +46 -0
- package/dist/services/utils/color-service.js +73 -0
- package/dist/services/utils/currency-service.d.ts +91 -0
- package/dist/services/utils/currency-service.js +140 -0
- package/dist/services/utils/download-service.d.ts +91 -0
- package/dist/services/utils/download-service.js +159 -0
- package/dist/services/utils/file-service.d.ts +140 -0
- package/dist/services/utils/file-service.js +301 -0
- package/dist/services/utils/http-service.d.ts +77 -0
- package/dist/services/utils/http-service.js +158 -0
- package/dist/services/utils/image-service.d.ts +107 -0
- package/dist/services/utils/image-service.js +260 -0
- package/dist/services/utils/melody-service.d.ts +5 -0
- package/dist/services/utils/melody-service.js +41 -0
- package/dist/services/utils/utils-service.d.ts +260 -0
- package/dist/services/utils/utils-service.js +413 -0
- package/dist/stores/referrer-store/referrer-store.svelte.d.ts +3 -0
- package/dist/stores/referrer-store/referrer-store.svelte.js +11 -0
- package/dist/stores/screen-size/screen-size-store.svelte.d.ts +11 -0
- package/dist/stores/screen-size/screen-size-store.svelte.js +33 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.js +16 -0
- package/dist/views/core/button/components/button/button.svelte +161 -0
- package/dist/views/core/button/components/button/button.svelte.d.ts +4 -0
- package/dist/views/core/button/components/button-back/button-back.svelte +46 -0
- package/dist/views/core/button/components/button-back/button-back.svelte.d.ts +11 -0
- package/dist/views/core/button/components/button-close/button-close.svelte +8 -0
- package/dist/views/core/button/components/button-close/button-close.svelte.d.ts +4 -0
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte +47 -0
- package/dist/views/core/button/components/button-close-icon/button-close-icon.svelte.d.ts +11 -0
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte +149 -0
- package/dist/views/core/button/components/button-dropdown/button-dropdown.svelte.d.ts +24 -0
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte +136 -0
- package/dist/views/core/button/components/button-list-item/button-list-item.svelte.d.ts +4 -0
- package/dist/views/core/button/components/button-menu/button-menu.svelte +105 -0
- package/dist/views/core/button/components/button-menu/button-menu.svelte.d.ts +21 -0
- package/dist/views/core/button/components/button-ok/button-ok.svelte +9 -0
- package/dist/views/core/button/components/button-ok/button-ok.svelte.d.ts +4 -0
- package/dist/views/core/button/components/button-search/button-search.svelte +72 -0
- package/dist/views/core/button/components/button-search/button-search.svelte.d.ts +21 -0
- package/dist/views/core/button/components/switch/switch.svelte +62 -0
- package/dist/views/core/button/components/switch/switch.svelte.d.ts +4 -0
- package/dist/views/core/button/index.d.ts +12 -0
- package/dist/views/core/button/index.js +12 -0
- package/dist/views/core/button/types.d.ts +100 -0
- package/dist/views/core/button/types.js +1 -0
- package/dist/views/core/common/components/content-area/content-area.svelte +47 -0
- package/dist/views/core/common/components/content-area/content-area.svelte.d.ts +12 -0
- package/dist/views/core/common/components/loading/loading.svelte +14 -0
- package/dist/views/core/common/components/loading/loading.svelte.d.ts +7 -0
- package/dist/views/core/common/components/virtual-scrolling/virtual-scrolling-list.svelte +60 -0
- package/dist/views/core/common/components/virtual-scrolling/virtual-scrolling-list.svelte.d.ts +11 -0
- package/dist/views/core/common/index.d.ts +4 -0
- package/dist/views/core/common/index.js +4 -0
- package/dist/views/core/dialog/components/cropper-dialog/cropper-dialog.svelte +51 -0
- package/dist/views/core/dialog/components/cropper-dialog/cropper-dialog.svelte.d.ts +5 -0
- package/dist/views/core/dialog/components/dialog/dialog.svelte +370 -0
- package/dist/views/core/dialog/components/dialog/dialog.svelte.d.ts +19 -0
- package/dist/views/core/dialog/components/loading-dialog/loading-dialog.svelte +42 -0
- package/dist/views/core/dialog/components/loading-dialog/loading-dialog.svelte.d.ts +12 -0
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte +22 -0
- package/dist/views/core/dialog/components/msg-dialog/msg-dialog.svelte.d.ts +9 -0
- package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte +57 -0
- package/dist/views/core/dialog/components/number-field-dialog/number-field-dialog.svelte.d.ts +14 -0
- package/dist/views/core/dialog/components/picker-dialog/picker-dialog.svelte +181 -0
- package/dist/views/core/dialog/components/picker-dialog/picker-dialog.svelte.d.ts +5 -0
- package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte +56 -0
- package/dist/views/core/dialog/components/text-field-dialog/text-field-dialog.svelte.d.ts +15 -0
- package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte +56 -0
- package/dist/views/core/dialog/components/textarea-field-dialog/textarea-field-dialog.svelte.d.ts +15 -0
- package/dist/views/core/dialog/index.d.ts +9 -0
- package/dist/views/core/dialog/index.js +9 -0
- package/dist/views/core/dialog/types.d.ts +105 -0
- package/dist/views/core/dialog/types.js +1 -0
- package/dist/views/core/drawer/components/drawer/drawer.svelte +110 -0
- package/dist/views/core/drawer/components/drawer/drawer.svelte.d.ts +19 -0
- package/dist/views/core/drawer/index.d.ts +2 -0
- package/dist/views/core/drawer/index.js +2 -0
- package/dist/views/core/icon/components/icon/icon.svelte +27 -0
- package/dist/views/core/icon/components/icon/icon.svelte.d.ts +12 -0
- package/dist/views/core/icon/components/icon-circle/icon-circle.svelte +17 -0
- package/dist/views/core/icon/components/icon-circle/icon-circle.svelte.d.ts +8 -0
- package/dist/views/core/icon/index.d.ts +4 -0
- package/dist/views/core/icon/index.js +4 -0
- package/dist/views/core/icon/services/icon-path-service.d.ts +23 -0
- package/dist/views/core/icon/services/icon-path-service.js +24 -0
- package/dist/views/core/index.d.ts +16 -0
- package/dist/views/core/index.js +16 -0
- package/dist/views/core/input/components/checkbox-field/checkbox-field.svelte +83 -0
- package/dist/views/core/input/components/checkbox-field/checkbox-field.svelte.d.ts +19 -0
- package/dist/views/core/input/components/color-field/color-field.svelte +135 -0
- package/dist/views/core/input/components/color-field/color-field.svelte.d.ts +11 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte +492 -0
- package/dist/views/core/input/components/combobox-field/combobox-field.svelte.d.ts +7 -0
- package/dist/views/core/input/components/date-field/date-field.svelte +40 -0
- package/dist/views/core/input/components/date-field/date-field.svelte.d.ts +11 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte +22 -0
- package/dist/views/core/input/components/datetime-field/datetime-field.svelte.d.ts +8 -0
- package/dist/views/core/input/components/email-field/email-field.svelte +27 -0
- package/dist/views/core/input/components/email-field/email-field.svelte.d.ts +8 -0
- package/dist/views/core/input/components/file-field/file-field.svelte +106 -0
- package/dist/views/core/input/components/file-field/file-field.svelte.d.ts +13 -0
- package/dist/views/core/input/components/input-field/input-field.svelte +336 -0
- package/dist/views/core/input/components/input-field/input-field.svelte.d.ts +9 -0
- package/dist/views/core/input/components/label/label.svelte +48 -0
- package/dist/views/core/input/components/label/label.svelte.d.ts +14 -0
- package/dist/views/core/input/components/number-field/number-field.svelte +22 -0
- package/dist/views/core/input/components/number-field/number-field.svelte.d.ts +8 -0
- package/dist/views/core/input/components/password-field/password-field.svelte +100 -0
- package/dist/views/core/input/components/password-field/password-field.svelte.d.ts +12 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte +187 -0
- package/dist/views/core/input/components/phone-field/phone-field.svelte.d.ts +12 -0
- package/dist/views/core/input/components/radio-field/radio-field.svelte +127 -0
- package/dist/views/core/input/components/radio-field/radio-field.svelte.d.ts +4 -0
- package/dist/views/core/input/components/range-field/range-field.svelte +120 -0
- package/dist/views/core/input/components/range-field/range-field.svelte.d.ts +23 -0
- package/dist/views/core/input/components/search-field/search-field.svelte +80 -0
- package/dist/views/core/input/components/search-field/search-field.svelte.d.ts +12 -0
- package/dist/views/core/input/components/text-field/text-field.svelte +31 -0
- package/dist/views/core/input/components/text-field/text-field.svelte.d.ts +11 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte +27 -0
- package/dist/views/core/input/components/textarea-field/textarea-field.svelte.d.ts +8 -0
- package/dist/views/core/input/components/time-field/time-field.svelte +21 -0
- package/dist/views/core/input/components/time-field/time-field.svelte.d.ts +8 -0
- package/dist/views/core/input/index.d.ts +20 -0
- package/dist/views/core/input/index.js +20 -0
- package/dist/views/core/input/types.d.ts +159 -0
- package/dist/views/core/input/types.js +1 -0
- package/dist/views/core/navbar/components/navbar/navbar.svelte +133 -0
- package/dist/views/core/navbar/components/navbar/navbar.svelte.d.ts +4 -0
- package/dist/views/core/navbar/index.d.ts +3 -0
- package/dist/views/core/navbar/index.js +3 -0
- package/dist/views/core/navbar/types.d.ts +35 -0
- package/dist/views/core/navbar/types.js +1 -0
- package/dist/views/core/no-data/components/no-data/no-data.svelte +47 -0
- package/dist/views/core/no-data/components/no-data/no-data.svelte.d.ts +13 -0
- package/dist/views/core/no-data/index.d.ts +2 -0
- package/dist/views/core/no-data/index.js +2 -0
- package/dist/views/core/pagination/components/pagination/pagination.svelte +151 -0
- package/dist/views/core/pagination/components/pagination/pagination.svelte.d.ts +16 -0
- package/dist/views/core/pagination/index.d.ts +2 -0
- package/dist/views/core/pagination/index.js +2 -0
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte +55 -0
- package/dist/views/core/progressbar/components/progressbar/progressbar.svelte.d.ts +11 -0
- package/dist/views/core/progressbar/index.d.ts +2 -0
- package/dist/views/core/progressbar/index.js +2 -0
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte +8 -0
- package/dist/views/core/ruler/components/vertical-ruler/verticcal-ruler.svelte.d.ts +6 -0
- package/dist/views/core/ruler/index.d.ts +2 -0
- package/dist/views/core/ruler/index.js +2 -0
- package/dist/views/core/screen-detector/components/screen-detector.svelte +17 -0
- package/dist/views/core/screen-detector/components/screen-detector.svelte.d.ts +3 -0
- package/dist/views/core/screen-detector/index.d.ts +2 -0
- package/dist/views/core/screen-detector/index.js +2 -0
- package/dist/views/core/sidebar/components/sidebar.svelte +49 -0
- package/dist/views/core/sidebar/components/sidebar.svelte.d.ts +12 -0
- package/dist/views/core/sidebar/index.d.ts +2 -0
- package/dist/views/core/sidebar/index.js +2 -0
- package/dist/views/core/spinner/components/spinner/spinner.svelte +21 -0
- package/dist/views/core/spinner/components/spinner/spinner.svelte.d.ts +6 -0
- package/dist/views/core/spinner/index.d.ts +2 -0
- package/dist/views/core/spinner/index.js +2 -0
- package/dist/views/core/text/components/text-await/text-await.svelte +23 -0
- package/dist/views/core/text/components/text-await/text-await.svelte.d.ts +10 -0
- package/dist/views/core/text/components/text-copy/text-copy.svelte +40 -0
- package/dist/views/core/text/components/text-copy/text-copy.svelte.d.ts +10 -0
- package/dist/views/core/text/components/text-currency/text-currency.svelte +24 -0
- package/dist/views/core/text/components/text-currency/text-currency.svelte.d.ts +11 -0
- package/dist/views/core/text/components/text-date/text-date.svelte +40 -0
- package/dist/views/core/text/components/text-date/text-date.svelte.d.ts +10 -0
- package/dist/views/core/text/components/text-email/text-email.svelte +22 -0
- package/dist/views/core/text/components/text-email/text-email.svelte.d.ts +9 -0
- package/dist/views/core/text/components/text-html/text-html.svelte +7 -0
- package/dist/views/core/text/components/text-html/text-html.svelte.d.ts +6 -0
- package/dist/views/core/text/components/text-phone/text-phone.svelte +25 -0
- package/dist/views/core/text/components/text-phone/text-phone.svelte.d.ts +9 -0
- package/dist/views/core/text/index.d.ts +8 -0
- package/dist/views/core/text/index.js +8 -0
- package/dist/views/core/toast/components/toast/toast.svelte +46 -0
- package/dist/views/core/toast/components/toast/toast.svelte.d.ts +7 -0
- package/dist/views/core/toast/index.d.ts +3 -0
- package/dist/views/core/toast/index.js +3 -0
- package/dist/views/core/toast/types.d.ts +8 -0
- package/dist/views/core/toast/types.js +1 -0
- package/dist/views/extra/fields/country-combobox-field.svelte +42 -0
- package/dist/views/extra/fields/country-combobox-field.svelte.d.ts +8 -0
- package/dist/views/extra/index.d.ts +6 -0
- package/dist/views/extra/index.js +6 -0
- package/dist/views/extra/loaders/country-loader.svelte +38 -0
- package/dist/views/extra/loaders/country-loader.svelte.d.ts +12 -0
- package/dist/views/extra/texts/text-country-state.svelte +48 -0
- package/dist/views/extra/texts/text-country-state.svelte.d.ts +6 -0
- package/dist/views/extra/texts/text-country.svelte +22 -0
- package/dist/views/extra/texts/text-country.svelte.d.ts +6 -0
- package/dist/views/extra/types.d.ts +5 -0
- package/dist/views/extra/types.js +1 -0
- package/dist/views/index.d.ts +2 -0
- package/dist/views/index.js +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates whether a given string is a valid hexadecimal color code.
|
|
3
|
+
*
|
|
4
|
+
* This function checks if a given string matches the pattern for a valid hex color code,
|
|
5
|
+
* which can be either 3 or 6 characters long, prefixed with '#'.
|
|
6
|
+
*
|
|
7
|
+
* @param hex - The string to validate as a hex color code.
|
|
8
|
+
* @returns A boolean indicating whether the string is a valid hex color code.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* console.log(isValidHexColor('#FFF')); // Output: true
|
|
12
|
+
* console.log(isValidHexColor('#123ABC')); // Output: true
|
|
13
|
+
* console.log(isValidHexColor('#1234')); // Output: false
|
|
14
|
+
*/
|
|
15
|
+
export function isValidHexColor(hex) {
|
|
16
|
+
const hexRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
17
|
+
return hexRegex.test(hex);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Converts a named or RGB color string to its hexadecimal representation.
|
|
21
|
+
*
|
|
22
|
+
* This function creates a temporary DOM element, sets its color property to the provided color string,
|
|
23
|
+
* and retrieves the computed color value. It then converts the RGB color to a hexadecimal format.
|
|
24
|
+
*
|
|
25
|
+
* @param color - A color string, such as a named color ('red'), RGB color ('rgb(255, 0, 0)'), or hex color ('#FF0000').
|
|
26
|
+
* @returns The hexadecimal representation of the color.
|
|
27
|
+
*
|
|
28
|
+
* @throws An error if the color cannot be parsed.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* console.log(colorToHex('red')); // Output: #FF0000
|
|
32
|
+
* console.log(colorToHex('rgb(0, 255, 0)')); // Output: #00FF00
|
|
33
|
+
*/
|
|
34
|
+
export function colorToHex(color) {
|
|
35
|
+
// Create a temporary div element to use its computed style
|
|
36
|
+
const tempDiv = document.createElement("div");
|
|
37
|
+
tempDiv.style.color = color;
|
|
38
|
+
document.body.appendChild(tempDiv);
|
|
39
|
+
// Get the computed color from the div element
|
|
40
|
+
const computedColor = window.getComputedStyle(tempDiv).color;
|
|
41
|
+
document.body.removeChild(tempDiv);
|
|
42
|
+
// Extract the RGB values from the computed color
|
|
43
|
+
const rgb = computedColor.match(/\d+/g)?.map(Number);
|
|
44
|
+
if (!rgb || rgb.length !== 3) {
|
|
45
|
+
throw new Error(`Unable to parse color: ${color}`);
|
|
46
|
+
}
|
|
47
|
+
// Convert RGB values to a hex color and return
|
|
48
|
+
return rgbToHex(rgb[0], rgb[1], rgb[2]);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Converts RGB values to a hexadecimal color code.
|
|
52
|
+
*
|
|
53
|
+
* This function takes the red, green, and blue components and converts them to a hexadecimal string.
|
|
54
|
+
* The resulting hex code is formatted as '#RRGGBB'.
|
|
55
|
+
*
|
|
56
|
+
* @param r - The red component (0-255).
|
|
57
|
+
* @param g - The green component (0-255).
|
|
58
|
+
* @param b - The blue component (0-255).
|
|
59
|
+
* @returns The hexadecimal color code in the format '#RRGGBB'.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* console.log(rgbToHex(255, 0, 0)); // Output: #FF0000
|
|
63
|
+
*/
|
|
64
|
+
export function rgbToHex(r, g, b) {
|
|
65
|
+
if (![r, g, b].every((value) => typeof value === 'number' && value >= 0 && value <= 255)) {
|
|
66
|
+
throw new Error('RGB values must be numbers between 0 and 255.');
|
|
67
|
+
}
|
|
68
|
+
return ("#" +
|
|
69
|
+
[r, g, b]
|
|
70
|
+
.map((x) => x.toString(16).padStart(2, "0")) // Convert to hex and ensure two characters
|
|
71
|
+
.join("")
|
|
72
|
+
.toUpperCase());
|
|
73
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export declare enum CurrencySymbols {
|
|
2
|
+
AED = "\u062F.\u0625",
|
|
3
|
+
AUD = "$",
|
|
4
|
+
BDT = "\u09F3",
|
|
5
|
+
BHD = ".\u062F.\u0628",
|
|
6
|
+
BRL = "R$",
|
|
7
|
+
CAD = "$",
|
|
8
|
+
CHF = "CHF",
|
|
9
|
+
CNY = "\u00A5",
|
|
10
|
+
CZK = "K\u010D",
|
|
11
|
+
DKK = "kr",
|
|
12
|
+
EGP = "\u00A3",
|
|
13
|
+
EUR = "\u20AC",
|
|
14
|
+
GBP = "\u00A3",
|
|
15
|
+
HKD = "$",
|
|
16
|
+
HUF = "Ft",
|
|
17
|
+
IDR = "Rp",
|
|
18
|
+
ILS = "\u20AA",
|
|
19
|
+
INR = "\u20B9",
|
|
20
|
+
JOD = "\u062F.\u0627",
|
|
21
|
+
JPY = "\u00A5",
|
|
22
|
+
KRW = "\u20A9",
|
|
23
|
+
KWD = "\u062F.\u0643",
|
|
24
|
+
LKR = "Rs",
|
|
25
|
+
MXN = "$",
|
|
26
|
+
MYR = "RM",
|
|
27
|
+
NGN = "\u20A6",
|
|
28
|
+
NOK = "kr",
|
|
29
|
+
NPR = "\u20A8",
|
|
30
|
+
NZD = "$",
|
|
31
|
+
OMR = "\u0631.\u0639.",
|
|
32
|
+
PHP = "\u20B1",
|
|
33
|
+
PKR = "\u20A8",
|
|
34
|
+
PLN = "z\u0142",
|
|
35
|
+
QAR = "\u0631.\u0642",
|
|
36
|
+
RUB = "\u20BD",
|
|
37
|
+
SAR = "\uFDFC",
|
|
38
|
+
SEK = "kr",
|
|
39
|
+
SGD = "$",
|
|
40
|
+
THB = "\u0E3F",
|
|
41
|
+
TRY = "\u20BA",
|
|
42
|
+
USD = "$",
|
|
43
|
+
VND = "\u20AB",
|
|
44
|
+
ZAR = "R"
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts a number into words based on the Indian numbering system.
|
|
48
|
+
* Supports up to Crore level and works for numbers up to 99 Crore.
|
|
49
|
+
*
|
|
50
|
+
* @param num - The number to convert to words.
|
|
51
|
+
* @returns A string representing the number in words.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* numberToWords(190005000) // Output: "Nineteen Crore, Fifty Thousand"
|
|
55
|
+
* numberToWords(123456789) // Output: "Twelve Crore, Thirty-Four Lakh, Fifty-Six Thousand, Seven Hundred and Eighty-Nine"
|
|
56
|
+
*/
|
|
57
|
+
export declare function numberToWords(num: number): string;
|
|
58
|
+
/**
|
|
59
|
+
* Converts a two-digit number into words.
|
|
60
|
+
*
|
|
61
|
+
* @param num - The number to convert.
|
|
62
|
+
* @returns The number in words.
|
|
63
|
+
*/
|
|
64
|
+
export declare function convertTwoDigits(num: number): string;
|
|
65
|
+
/**
|
|
66
|
+
* Converts a number to a currency-formatted string.
|
|
67
|
+
*
|
|
68
|
+
* This function formats a given number as a currency string, using a specified currency symbol
|
|
69
|
+
* (default is '$'). It handles negative values by adding a '-' sign in front of the formatted value.
|
|
70
|
+
*
|
|
71
|
+
* @param value - The numeric value to format as currency.
|
|
72
|
+
* @param symbol - The currency symbol to use. Default is '$'.
|
|
73
|
+
* @returns A formatted string representing the currency value.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const formattedValue = toCurrency(1234.56, '$');
|
|
77
|
+
* console.log(formattedValue); // Output: "$ 1234.56"
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const formattedNegative = toCurrency(-1234.56, '€');
|
|
81
|
+
* console.log(formattedNegative); // Output: "- € 1234.56"
|
|
82
|
+
*/
|
|
83
|
+
export declare function toCurrency(value?: number, symbol?: string): string;
|
|
84
|
+
/**
|
|
85
|
+
* Formats a number into Indian currency format with commas
|
|
86
|
+
* Example: 1234567890.50 -> "1,23,45,67,890.50"
|
|
87
|
+
*
|
|
88
|
+
* @param amount - The number to format (can include decimals).
|
|
89
|
+
* @returns A string formatted with commas as per the Indian numbering system.
|
|
90
|
+
*/
|
|
91
|
+
export declare function formatIndianCurrency(amount: number | string): string;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const belowTwenty = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"];
|
|
2
|
+
const tens = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
|
|
3
|
+
const scales = ["", "Thousand", "Lakh", "Crore"];
|
|
4
|
+
export var CurrencySymbols;
|
|
5
|
+
(function (CurrencySymbols) {
|
|
6
|
+
CurrencySymbols["AED"] = "\u062F.\u0625";
|
|
7
|
+
CurrencySymbols["AUD"] = "$";
|
|
8
|
+
CurrencySymbols["BDT"] = "\u09F3";
|
|
9
|
+
CurrencySymbols["BHD"] = ".\u062F.\u0628";
|
|
10
|
+
CurrencySymbols["BRL"] = "R$";
|
|
11
|
+
CurrencySymbols["CAD"] = "$";
|
|
12
|
+
CurrencySymbols["CHF"] = "CHF";
|
|
13
|
+
CurrencySymbols["CNY"] = "\u00A5";
|
|
14
|
+
CurrencySymbols["CZK"] = "K\u010D";
|
|
15
|
+
CurrencySymbols["DKK"] = "kr";
|
|
16
|
+
CurrencySymbols["EGP"] = "\u00A3";
|
|
17
|
+
CurrencySymbols["EUR"] = "\u20AC";
|
|
18
|
+
CurrencySymbols["GBP"] = "\u00A3";
|
|
19
|
+
CurrencySymbols["HKD"] = "$";
|
|
20
|
+
CurrencySymbols["HUF"] = "Ft";
|
|
21
|
+
CurrencySymbols["IDR"] = "Rp";
|
|
22
|
+
CurrencySymbols["ILS"] = "\u20AA";
|
|
23
|
+
CurrencySymbols["INR"] = "\u20B9";
|
|
24
|
+
CurrencySymbols["JOD"] = "\u062F.\u0627";
|
|
25
|
+
CurrencySymbols["JPY"] = "\u00A5";
|
|
26
|
+
CurrencySymbols["KRW"] = "\u20A9";
|
|
27
|
+
CurrencySymbols["KWD"] = "\u062F.\u0643";
|
|
28
|
+
CurrencySymbols["LKR"] = "Rs";
|
|
29
|
+
CurrencySymbols["MXN"] = "$";
|
|
30
|
+
CurrencySymbols["MYR"] = "RM";
|
|
31
|
+
CurrencySymbols["NGN"] = "\u20A6";
|
|
32
|
+
CurrencySymbols["NOK"] = "kr";
|
|
33
|
+
CurrencySymbols["NPR"] = "\u20A8";
|
|
34
|
+
CurrencySymbols["NZD"] = "$";
|
|
35
|
+
CurrencySymbols["OMR"] = "\u0631.\u0639.";
|
|
36
|
+
CurrencySymbols["PHP"] = "\u20B1";
|
|
37
|
+
CurrencySymbols["PKR"] = "\u20A8";
|
|
38
|
+
CurrencySymbols["PLN"] = "z\u0142";
|
|
39
|
+
CurrencySymbols["QAR"] = "\u0631.\u0642";
|
|
40
|
+
CurrencySymbols["RUB"] = "\u20BD";
|
|
41
|
+
CurrencySymbols["SAR"] = "\uFDFC";
|
|
42
|
+
CurrencySymbols["SEK"] = "kr";
|
|
43
|
+
CurrencySymbols["SGD"] = "$";
|
|
44
|
+
CurrencySymbols["THB"] = "\u0E3F";
|
|
45
|
+
CurrencySymbols["TRY"] = "\u20BA";
|
|
46
|
+
CurrencySymbols["USD"] = "$";
|
|
47
|
+
CurrencySymbols["VND"] = "\u20AB";
|
|
48
|
+
CurrencySymbols["ZAR"] = "R";
|
|
49
|
+
})(CurrencySymbols || (CurrencySymbols = {}));
|
|
50
|
+
/**
|
|
51
|
+
* Converts a number into words based on the Indian numbering system.
|
|
52
|
+
* Supports up to Crore level and works for numbers up to 99 Crore.
|
|
53
|
+
*
|
|
54
|
+
* @param num - The number to convert to words.
|
|
55
|
+
* @returns A string representing the number in words.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* numberToWords(190005000) // Output: "Nineteen Crore, Fifty Thousand"
|
|
59
|
+
* numberToWords(123456789) // Output: "Twelve Crore, Thirty-Four Lakh, Fifty-Six Thousand, Seven Hundred and Eighty-Nine"
|
|
60
|
+
*/
|
|
61
|
+
export function numberToWords(num) {
|
|
62
|
+
if (num === 0)
|
|
63
|
+
return "Zero";
|
|
64
|
+
const crore = Math.floor(num / 10000000);
|
|
65
|
+
const lakh = Math.floor((num % 10000000) / 100000);
|
|
66
|
+
const thousand = Math.floor((num % 100000) / 1000);
|
|
67
|
+
const hundred = Math.floor((num % 1000) / 100);
|
|
68
|
+
const remainder = num % 100;
|
|
69
|
+
let result = '';
|
|
70
|
+
if (crore > 0) {
|
|
71
|
+
result += `${convertTwoDigits(crore)} Crore`;
|
|
72
|
+
}
|
|
73
|
+
if (lakh > 0) {
|
|
74
|
+
result += result ? `, ${convertTwoDigits(lakh)} Lakh` : `${convertTwoDigits(lakh)} Lakh`;
|
|
75
|
+
}
|
|
76
|
+
if (thousand > 0) {
|
|
77
|
+
result += result ? `, ${convertTwoDigits(thousand)} Thousand` : `${convertTwoDigits(thousand)} Thousand`;
|
|
78
|
+
}
|
|
79
|
+
if (hundred > 0) {
|
|
80
|
+
result += result ? `, ${convertTwoDigits(hundred)} Hundred` : `${convertTwoDigits(hundred)} Hundred`;
|
|
81
|
+
}
|
|
82
|
+
if (remainder > 0) {
|
|
83
|
+
result += result ? ` and ${convertTwoDigits(remainder)}` : `${convertTwoDigits(remainder)}`;
|
|
84
|
+
}
|
|
85
|
+
return result.trim();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Converts a two-digit number into words.
|
|
89
|
+
*
|
|
90
|
+
* @param num - The number to convert.
|
|
91
|
+
* @returns The number in words.
|
|
92
|
+
*/
|
|
93
|
+
export function convertTwoDigits(num) {
|
|
94
|
+
if (num < 20) {
|
|
95
|
+
return belowTwenty[num];
|
|
96
|
+
}
|
|
97
|
+
const ten = Math.floor(num / 10);
|
|
98
|
+
const unit = num % 10;
|
|
99
|
+
return `${tens[ten]}${unit ? " " + belowTwenty[unit] : ""}`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Converts a number to a currency-formatted string.
|
|
103
|
+
*
|
|
104
|
+
* This function formats a given number as a currency string, using a specified currency symbol
|
|
105
|
+
* (default is '$'). It handles negative values by adding a '-' sign in front of the formatted value.
|
|
106
|
+
*
|
|
107
|
+
* @param value - The numeric value to format as currency.
|
|
108
|
+
* @param symbol - The currency symbol to use. Default is '$'.
|
|
109
|
+
* @returns A formatted string representing the currency value.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* const formattedValue = toCurrency(1234.56, '$');
|
|
113
|
+
* console.log(formattedValue); // Output: "$ 1234.56"
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const formattedNegative = toCurrency(-1234.56, '€');
|
|
117
|
+
* console.log(formattedNegative); // Output: "- € 1234.56"
|
|
118
|
+
*/
|
|
119
|
+
export function toCurrency(value = 0, symbol = '$') {
|
|
120
|
+
const isNegative = value < 0;
|
|
121
|
+
const currencyValue = Math.abs(value).toFixed(2);
|
|
122
|
+
return `${isNegative ? '- ' : ''}${symbol} ${currencyValue}`;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Formats a number into Indian currency format with commas
|
|
126
|
+
* Example: 1234567890.50 -> "1,23,45,67,890.50"
|
|
127
|
+
*
|
|
128
|
+
* @param amount - The number to format (can include decimals).
|
|
129
|
+
* @returns A string formatted with commas as per the Indian numbering system.
|
|
130
|
+
*/
|
|
131
|
+
export function formatIndianCurrency(amount) {
|
|
132
|
+
let amountStr = typeof amount === 'number' ? amount.toFixed(2) : parseFloat(amount).toFixed(2);
|
|
133
|
+
let [integerPart, decimalPart] = amountStr.split(".");
|
|
134
|
+
let lastThreeDigits = integerPart.slice(-3);
|
|
135
|
+
let otherDigits = integerPart.slice(0, -3);
|
|
136
|
+
if (otherDigits !== "") {
|
|
137
|
+
otherDigits = otherDigits.replace(/\B(?=(\d{2})+(?!\d))/g, ",");
|
|
138
|
+
}
|
|
139
|
+
return otherDigits + (otherDigits ? "," : "") + lastThreeDigits + "." + decimalPart;
|
|
140
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloads a file from various data sources (string, URL, Data URL, or File object).
|
|
3
|
+
*
|
|
4
|
+
* This function handles downloading files from a variety of sources, including:
|
|
5
|
+
* - String data (text, JSON, etc.)
|
|
6
|
+
* - URLs (file URLs or remote URLs)
|
|
7
|
+
* - Data URLs (Base64 encoded strings)
|
|
8
|
+
* - File or Blob objects
|
|
9
|
+
*
|
|
10
|
+
* @param data - The data to download. It can be a string, URL, Data URL, or a File/Blob object.
|
|
11
|
+
* @param filename - The name for the downloaded file.
|
|
12
|
+
* @param mimeType - Optional. The MIME type of the file. Default is 'application/octet-stream'.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Download a string as a text file
|
|
16
|
+
* downloadFile('Hello, world!', 'example.txt', 'text/plain');
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Download a file from a URL
|
|
20
|
+
* downloadFile('https://example.com/file.pdf', 'downloaded-file.pdf');
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Download a file from a Data URL
|
|
24
|
+
* const dataUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...';
|
|
25
|
+
* downloadFile(dataUrl, 'image.png');
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Download a File object
|
|
29
|
+
* const myFile = new File(['Hello, world!'], 'example.txt', { type: 'text/plain' });
|
|
30
|
+
* downloadFile(myFile);
|
|
31
|
+
*/
|
|
32
|
+
export declare function downloadFile(data: string | URL | File | Blob, filename?: string, mimeType?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Downloads plain string data as a file.
|
|
35
|
+
*
|
|
36
|
+
* @param data - The string data to download.
|
|
37
|
+
* @param filename - The name for the downloaded file.
|
|
38
|
+
* @param mimeType - The MIME type of the file.
|
|
39
|
+
*/
|
|
40
|
+
export declare function downloadStringData(data: string, filename: string, mimeType: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Downloads a file from a given URL.
|
|
43
|
+
*
|
|
44
|
+
* @param url - The URL to download the file from.
|
|
45
|
+
* @param filename - The name for the downloaded file.
|
|
46
|
+
*/
|
|
47
|
+
export declare function downloadFromUrl(url: string, filename: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Downloads a file from a Data URL (Base64 encoded string).
|
|
50
|
+
*
|
|
51
|
+
* @param dataUrl - The Data URL to download.
|
|
52
|
+
* @param filename - The name for the downloaded file.
|
|
53
|
+
* @param mimeType - Optional. The MIME type of the file.
|
|
54
|
+
*/
|
|
55
|
+
export declare function downloadDataUrl(dataUrl: string, filename: string, mimeType?: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Downloads a File or Blob object.
|
|
58
|
+
*
|
|
59
|
+
* @param file - The File or Blob object to download.
|
|
60
|
+
* @param filename - The name for the downloaded file.
|
|
61
|
+
*/
|
|
62
|
+
export declare function downloadBlob(file: Blob, filename: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Converts a Data URL to a Blob object.
|
|
65
|
+
*
|
|
66
|
+
* @param dataUrl - The Data URL to convert.
|
|
67
|
+
* @param mimeType - Optional. The MIME type of the resulting Blob.
|
|
68
|
+
* @returns A Blob object representing the data.
|
|
69
|
+
*/
|
|
70
|
+
export declare function dataUrlToBlob(dataUrl: string, mimeType?: string): Blob;
|
|
71
|
+
/**
|
|
72
|
+
* Determines if a given string is a valid Data URL.
|
|
73
|
+
*
|
|
74
|
+
* @param str - The string to validate.
|
|
75
|
+
* @returns A boolean indicating whether the string is a valid Data URL.
|
|
76
|
+
*/
|
|
77
|
+
export declare function isDataUrl(str: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Determines if a given string is a valid URL.
|
|
80
|
+
*
|
|
81
|
+
* @param str - The string to validate.
|
|
82
|
+
* @returns A boolean indicating whether the string is a valid URL.
|
|
83
|
+
*/
|
|
84
|
+
export declare function isUrl(str: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Extracts the filename from a URL.
|
|
87
|
+
*
|
|
88
|
+
* @param url - The URL string.
|
|
89
|
+
* @returns The extracted filename, or 'download' if the URL does not contain a filename.
|
|
90
|
+
*/
|
|
91
|
+
export declare function getFilenameFromUrl(url: string): string;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloads a file from various data sources (string, URL, Data URL, or File object).
|
|
3
|
+
*
|
|
4
|
+
* This function handles downloading files from a variety of sources, including:
|
|
5
|
+
* - String data (text, JSON, etc.)
|
|
6
|
+
* - URLs (file URLs or remote URLs)
|
|
7
|
+
* - Data URLs (Base64 encoded strings)
|
|
8
|
+
* - File or Blob objects
|
|
9
|
+
*
|
|
10
|
+
* @param data - The data to download. It can be a string, URL, Data URL, or a File/Blob object.
|
|
11
|
+
* @param filename - The name for the downloaded file.
|
|
12
|
+
* @param mimeType - Optional. The MIME type of the file. Default is 'application/octet-stream'.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Download a string as a text file
|
|
16
|
+
* downloadFile('Hello, world!', 'example.txt', 'text/plain');
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Download a file from a URL
|
|
20
|
+
* downloadFile('https://example.com/file.pdf', 'downloaded-file.pdf');
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Download a file from a Data URL
|
|
24
|
+
* const dataUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...';
|
|
25
|
+
* downloadFile(dataUrl, 'image.png');
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Download a File object
|
|
29
|
+
* const myFile = new File(['Hello, world!'], 'example.txt', { type: 'text/plain' });
|
|
30
|
+
* downloadFile(myFile);
|
|
31
|
+
*/
|
|
32
|
+
export function downloadFile(data, filename, mimeType) {
|
|
33
|
+
// Determine the type of the data and handle accordingly
|
|
34
|
+
if (typeof data === 'string') {
|
|
35
|
+
if (isDataUrl(data)) {
|
|
36
|
+
// Handle Data URL
|
|
37
|
+
downloadDataUrl(data, filename || 'download', mimeType);
|
|
38
|
+
}
|
|
39
|
+
else if (isUrl(data)) {
|
|
40
|
+
// Handle URL download
|
|
41
|
+
downloadFromUrl(data, filename || getFilenameFromUrl(data));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Handle plain string data
|
|
45
|
+
downloadStringData(data, filename || 'download.txt', mimeType || 'application/octet-stream');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else if (data instanceof File || data instanceof Blob) {
|
|
49
|
+
// Handle File or Blob object
|
|
50
|
+
downloadBlob(data, filename || data.name || 'download');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.error('Unsupported data type for download.');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Downloads plain string data as a file.
|
|
58
|
+
*
|
|
59
|
+
* @param data - The string data to download.
|
|
60
|
+
* @param filename - The name for the downloaded file.
|
|
61
|
+
* @param mimeType - The MIME type of the file.
|
|
62
|
+
*/
|
|
63
|
+
export function downloadStringData(data, filename, mimeType) {
|
|
64
|
+
const blob = new Blob([data], { type: mimeType });
|
|
65
|
+
downloadBlob(blob, filename);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Downloads a file from a given URL.
|
|
69
|
+
*
|
|
70
|
+
* @param url - The URL to download the file from.
|
|
71
|
+
* @param filename - The name for the downloaded file.
|
|
72
|
+
*/
|
|
73
|
+
export function downloadFromUrl(url, filename) {
|
|
74
|
+
const link = document.createElement('a');
|
|
75
|
+
link.href = url;
|
|
76
|
+
link.download = filename;
|
|
77
|
+
document.body.appendChild(link);
|
|
78
|
+
link.click();
|
|
79
|
+
document.body.removeChild(link);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Downloads a file from a Data URL (Base64 encoded string).
|
|
83
|
+
*
|
|
84
|
+
* @param dataUrl - The Data URL to download.
|
|
85
|
+
* @param filename - The name for the downloaded file.
|
|
86
|
+
* @param mimeType - Optional. The MIME type of the file.
|
|
87
|
+
*/
|
|
88
|
+
export function downloadDataUrl(dataUrl, filename, mimeType) {
|
|
89
|
+
const blob = dataUrlToBlob(dataUrl, mimeType);
|
|
90
|
+
downloadBlob(blob, filename);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Downloads a File or Blob object.
|
|
94
|
+
*
|
|
95
|
+
* @param file - The File or Blob object to download.
|
|
96
|
+
* @param filename - The name for the downloaded file.
|
|
97
|
+
*/
|
|
98
|
+
export function downloadBlob(file, filename) {
|
|
99
|
+
const link = document.createElement('a');
|
|
100
|
+
link.href = URL.createObjectURL(file);
|
|
101
|
+
link.download = filename;
|
|
102
|
+
document.body.appendChild(link);
|
|
103
|
+
link.click();
|
|
104
|
+
// Clean up the URL object to free up memory
|
|
105
|
+
URL.revokeObjectURL(link.href);
|
|
106
|
+
document.body.removeChild(link);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Converts a Data URL to a Blob object.
|
|
110
|
+
*
|
|
111
|
+
* @param dataUrl - The Data URL to convert.
|
|
112
|
+
* @param mimeType - Optional. The MIME type of the resulting Blob.
|
|
113
|
+
* @returns A Blob object representing the data.
|
|
114
|
+
*/
|
|
115
|
+
export function dataUrlToBlob(dataUrl, mimeType) {
|
|
116
|
+
const byteString = atob(dataUrl.split(',')[1]);
|
|
117
|
+
const ab = new ArrayBuffer(byteString.length);
|
|
118
|
+
const ia = new Uint8Array(ab);
|
|
119
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
120
|
+
ia[i] = byteString.charCodeAt(i);
|
|
121
|
+
}
|
|
122
|
+
return new Blob([ab], { type: mimeType || 'application/octet-stream' });
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Determines if a given string is a valid Data URL.
|
|
126
|
+
*
|
|
127
|
+
* @param str - The string to validate.
|
|
128
|
+
* @returns A boolean indicating whether the string is a valid Data URL.
|
|
129
|
+
*/
|
|
130
|
+
export function isDataUrl(str) {
|
|
131
|
+
const pattern = /^data:([a-zA-Z0-9/+.-]+);base64,/;
|
|
132
|
+
return pattern.test(str);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Determines if a given string is a valid URL.
|
|
136
|
+
*
|
|
137
|
+
* @param str - The string to validate.
|
|
138
|
+
* @returns A boolean indicating whether the string is a valid URL.
|
|
139
|
+
*/
|
|
140
|
+
export function isUrl(str) {
|
|
141
|
+
try {
|
|
142
|
+
new URL(str);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
catch (_) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Extracts the filename from a URL.
|
|
151
|
+
*
|
|
152
|
+
* @param url - The URL string.
|
|
153
|
+
* @returns The extracted filename, or 'download' if the URL does not contain a filename.
|
|
154
|
+
*/
|
|
155
|
+
export function getFilenameFromUrl(url) {
|
|
156
|
+
const segments = url.split('/');
|
|
157
|
+
const filename = segments.pop();
|
|
158
|
+
return filename && filename.includes('.') ? filename : 'download';
|
|
159
|
+
}
|