@wikicasa-dev/utilities 1.0.20 → 1.0.21
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/NumberUtils.cjs +1 -1
- package/dist/NumberUtils.js +17 -17
- package/dist/index.cjs +1 -1
- package/dist/index.js +58 -57
- package/dist/utils/NumberUtils.d.ts +10 -5
- package/package.json +1 -1
package/dist/NumberUtils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=(r,t="it-IT")=>{const e=Intl.NumberFormat(t).format(1111).replace(/\p{Number}/gu,""),a=Intl.NumberFormat(t).format(1.1).replace(/\p{Number}/gu,""),o=parseFloat(`${r}`.replace(new RegExp("\\"+e,"g"),"").replace(new RegExp("\\"+a),"."));return isNaN(o)?"":o},i=r=>u(r,navigator.language),c=(r,t,e="it-IT")=>{if(r==null)return;if(r=parseFloat(`${r}`),isNaN(r))return"";const a={style:"currency",currency:"EUR"};let n={...{maximumFractionDigits:0}};return t?.currency&&(n={...n,...a}),new Intl.NumberFormat(e,{...n}).format(r)},f=(r,t)=>c(r,t,navigator.language);function l(r,t=!1){return r==null?"":m(t?Math.round(r):Math.floor(r),0)}function m(r,t){return!r&&r!==0?"":r.toLocaleString("it-IT",{minimumFractionDigits:t,maximumFractionDigits:t})}function s(r,t=2){return m(r,t)}const p={formatFn:r=>c(r)??"",unFormatFn:r=>u(r)};exports.formatFloat=s;exports.formatInteger=l;exports.formatLocaleNumber=c;exports.formatLocaleNumberAuto=f;exports.formatNumber=m;exports.formatterNumberObj=p;exports.parseLocaleNumber=u;exports.parseLocaleNumberAuto=i;
|
package/dist/NumberUtils.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`${r}`.replace(new RegExp("\\" + n, "g"), "").replace(new RegExp("\\" + e), ".")
|
|
1
|
+
const u = (r, t = "it-IT") => {
|
|
2
|
+
const e = Intl.NumberFormat(t).format(1111).replace(/\p{Number}/gu, ""), n = Intl.NumberFormat(t).format(1.1).replace(/\p{Number}/gu, ""), a = parseFloat(
|
|
3
|
+
`${r}`.replace(new RegExp("\\" + e, "g"), "").replace(new RegExp("\\" + n), ".")
|
|
5
4
|
);
|
|
6
5
|
return isNaN(a) ? "" : a;
|
|
7
|
-
}, i = (r, t,
|
|
6
|
+
}, m = (r) => u(r, navigator.language), i = (r, t, e = "it-IT") => {
|
|
8
7
|
if (r == null)
|
|
9
8
|
return;
|
|
10
9
|
if (r = parseFloat(`${r}`), isNaN(r))
|
|
11
10
|
return "";
|
|
12
|
-
const
|
|
11
|
+
const n = {
|
|
13
12
|
style: "currency",
|
|
14
13
|
currency: "EUR"
|
|
15
14
|
};
|
|
16
15
|
let o = { ...{
|
|
17
16
|
maximumFractionDigits: 0
|
|
18
17
|
} };
|
|
19
|
-
return t?.currency && (o = { ...o, ...
|
|
18
|
+
return t?.currency && (o = { ...o, ...n }), new Intl.NumberFormat(e, {
|
|
20
19
|
...o
|
|
21
20
|
}).format(r);
|
|
22
|
-
},
|
|
21
|
+
}, s = (r, t) => i(r, t, navigator.language);
|
|
23
22
|
function f(r, t = !1) {
|
|
24
|
-
return r == null ? "" :
|
|
23
|
+
return r == null ? "" : c(t ? Math.round(r) : Math.floor(r), 0);
|
|
25
24
|
}
|
|
26
|
-
function
|
|
25
|
+
function c(r, t) {
|
|
27
26
|
return !r && r !== 0 ? "" : r.toLocaleString(
|
|
28
27
|
"it-IT",
|
|
29
28
|
// usare una stringa tipo 'en-US' per sovrascrivere la lingua del browser
|
|
@@ -33,19 +32,20 @@ function u(r, t) {
|
|
|
33
32
|
}
|
|
34
33
|
);
|
|
35
34
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
35
|
+
function l(r, t = 2) {
|
|
36
|
+
return c(r, t);
|
|
38
37
|
}
|
|
39
38
|
const p = {
|
|
40
39
|
formatFn: (r) => i(r) ?? "",
|
|
41
|
-
unFormatFn: (r) =>
|
|
40
|
+
unFormatFn: (r) => u(r)
|
|
42
41
|
};
|
|
43
42
|
export {
|
|
44
|
-
|
|
43
|
+
l as formatFloat,
|
|
45
44
|
f as formatInteger,
|
|
46
45
|
i as formatLocaleNumber,
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
s as formatLocaleNumberAuto,
|
|
47
|
+
c as formatNumber,
|
|
49
48
|
p as formatterNumberObj,
|
|
50
|
-
|
|
49
|
+
u as parseLocaleNumber,
|
|
50
|
+
m as parseLocaleNumberAuto
|
|
51
51
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./ArrayUtils.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./ArrayUtils.cjs"),p=require("./ColorUtils.cjs"),i=require("./CookieUtils.cjs"),g=require("./CurrencyUtils.cjs"),l=require("./DateUtils.cjs"),s=require("./DeviceDetectionUtils.cjs"),a=require("./DOMUtils.cjs"),c=require("./EmailUtils.cjs"),E=require("./FunctionUtils.cjs"),u=require("./GenericUtils.cjs"),t=require("./NumberUtils.cjs"),r=require("./ObjectUtils.cjs"),A=require("./ObserverUtils.cjs"),m=require("./PermissionUtils.cjs"),n=require("./RESB_UrlBuilder.cjs"),o=require("./StringUtils.cjs"),C=require("./URLBuilderUtils.cjs"),e=require("./RegexUtils.cjs"),d=require("./GeolocationUtils.cjs"),b=require("./AdressUtils.cjs"),R=require("./GAutocompleteUtils.cjs"),S=require("./DownloadUtils.cjs");exports.isArrNullOrEmpty=O.isArrNullOrEmpty;exports.rgba=p.rgba;exports.decodeCookie=i.decodeCookie;exports.encodeCookie=i.encodeCookie;exports.getCookie=i.getCookie;exports.removeCookie=i.removeCookie;exports.formatCurrency=g.formatCurrency;exports.formatDate=l.formatDate;exports.formatDateToddMMYYYY=l.formatDateToddMMYYYY;exports.subtractDaysFromDate=l.subtractDaysFromDate;exports.getCurrentDeviceSize=s.getCurrentDeviceSize;exports.isMobile=s.isMobile;exports.isSafari=s.isSafari;exports.isiOSDevice=s.isiOSDevice;exports.emptyElem=a.emptyElem;exports.getSingleElement=a.getSingleElement;exports.hideElem=a.hideElem;exports.showElem=a.showElem;exports.hash256=c.hash256;exports.hashEmail=c.hashEmail;exports.debounce=E.debounce;exports.isPromise=E.isPromise;exports.awaitableSetTimeout=u.awaitableSetTimeout;exports.createCustomEvent=u.createCustomEvent;exports.formatFloat=t.formatFloat;exports.formatInteger=t.formatInteger;exports.formatLocaleNumber=t.formatLocaleNumber;exports.formatLocaleNumberAuto=t.formatLocaleNumberAuto;exports.formatNumber=t.formatNumber;exports.formatterNumberObj=t.formatterNumberObj;exports.parseLocaleNumber=t.parseLocaleNumber;exports.parseLocaleNumberAuto=t.parseLocaleNumberAuto;exports.deepCopy=r.deepCopy;exports.getOrNull=r.getOrNull;exports.invertFlatObject=r.invertFlatObject;exports.invertKeyToValue=r.invertKeyToValue;exports.isEmptyObject=r.isEmptyObject;exports.shallowCopyObjectTo=r.shallowCopyObjectTo;exports.observeOnce=A.observeOnce;exports.addPermissionStateListener=m.addPermissionStateListener;exports.onNotificationsPermissionChange=m.onNotificationsPermissionChange;exports.buildParams=n.buildParams;exports.buildParamsForAgency=n.buildParamsForAgency;exports.buildURL=n.buildURL;exports.capitalizeFirstLetter=o.capitalizeFirstLetter;exports.cleanASCII=o.cleanASCII;exports.decodeTextWithEntities=o.decodeTextWithEntities;exports.replaceAll=o.replaceAll;exports.replaceAllTokens=o.replaceAllTokens;exports.stringToHyphened=o.stringToHyphened;exports.appendQueryString=C.appendQueryString;exports.COMPETITOR_REGEX=e.COMPETITOR_REGEX;exports.DATE_REGEX=e.DATE_REGEX;exports.EMAIL_REGEX=e.EMAIL_REGEX;exports.EMAIL_REGEX_INTO_TEXT=e.EMAIL_REGEX_INTO_TEXT;exports.EXCLUDED_REGEX=e.EXCLUDED_REGEX;exports.GLOBAL_PHONE_REGEX=e.GLOBAL_PHONE_REGEX;exports.PASSWORD_REGEX=e.PASSWORD_REGEX;exports.PHONE_REGEX=e.PHONE_REGEX;exports.ROOMS_REGEX=e.ROOMS_REGEX;exports.SQM_REGEX=e.SQM_REGEX;exports.browserSupportGeolocation=d.browserSupportGeolocation;exports.getUserPosition=d.getUserPosition;exports.formatAddress=b.formatAddress;exports.formattedAddress=b.formattedAddress;exports.googlePlaceConverter=R.googlePlaceConverter;exports.downloadFile=S.downloadFile;
|
package/dist/index.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
import { isArrNullOrEmpty as r } from "./ArrayUtils.js";
|
|
2
2
|
import { rgba as m } from "./ColorUtils.js";
|
|
3
|
-
import { decodeCookie as i, encodeCookie as
|
|
4
|
-
import { formatCurrency as
|
|
3
|
+
import { decodeCookie as i, encodeCookie as p, getCookie as E, removeCookie as l } from "./CookieUtils.js";
|
|
4
|
+
import { formatCurrency as f } from "./CurrencyUtils.js";
|
|
5
5
|
import { formatDate as c, formatDateToddMMYYYY as d, subtractDaysFromDate as x } from "./DateUtils.js";
|
|
6
|
-
import { getCurrentDeviceSize as b, isMobile as O, isSafari as g, isiOSDevice as
|
|
7
|
-
import { emptyElem as
|
|
8
|
-
import { hash256 as
|
|
9
|
-
import { debounce as
|
|
6
|
+
import { getCurrentDeviceSize as b, isMobile as O, isSafari as g, isiOSDevice as A } from "./DeviceDetectionUtils.js";
|
|
7
|
+
import { emptyElem as R, getSingleElement as S, hideElem as T, showElem as _ } from "./DOMUtils.js";
|
|
8
|
+
import { hash256 as L, hashEmail as N } from "./EmailUtils.js";
|
|
9
|
+
import { debounce as y, isPromise as P } from "./FunctionUtils.js";
|
|
10
10
|
import { awaitableSetTimeout as D, createCustomEvent as v } from "./GenericUtils.js";
|
|
11
|
-
import { formatFloat as I, formatInteger as F, formatLocaleNumber as k, formatLocaleNumberAuto as w, formatNumber as j, formatterNumberObj as Y, parseLocaleNumber as H } from "./NumberUtils.js";
|
|
12
|
-
import { deepCopy as
|
|
13
|
-
import { observeOnce as
|
|
14
|
-
import { addPermissionStateListener as
|
|
15
|
-
import { buildParams as
|
|
16
|
-
import { capitalizeFirstLetter as
|
|
17
|
-
import { appendQueryString as
|
|
18
|
-
import { COMPETITOR_REGEX as
|
|
19
|
-
import { browserSupportGeolocation as
|
|
20
|
-
import { formatAddress as
|
|
21
|
-
import { googlePlaceConverter as
|
|
22
|
-
import { downloadFile as
|
|
11
|
+
import { formatFloat as I, formatInteger as F, formatLocaleNumber as k, formatLocaleNumberAuto as w, formatNumber as j, formatterNumberObj as Y, parseLocaleNumber as H, parseLocaleNumberAuto as U } from "./NumberUtils.js";
|
|
12
|
+
import { deepCopy as Q, getOrNull as W, invertFlatObject as B, invertKeyToValue as K, isEmptyObject as V, shallowCopyObjectTo as q } from "./ObjectUtils.js";
|
|
13
|
+
import { observeOnce as Z } from "./ObserverUtils.js";
|
|
14
|
+
import { addPermissionStateListener as ee, onNotificationsPermissionChange as oe } from "./PermissionUtils.js";
|
|
15
|
+
import { buildParams as te, buildParamsForAgency as me, buildURL as ae } from "./RESB_UrlBuilder.js";
|
|
16
|
+
import { capitalizeFirstLetter as pe, cleanASCII as Ee, decodeTextWithEntities as le, replaceAll as se, replaceAllTokens as fe, stringToHyphened as ne } from "./StringUtils.js";
|
|
17
|
+
import { appendQueryString as de } from "./URLBuilderUtils.js";
|
|
18
|
+
import { COMPETITOR_REGEX as ue, DATE_REGEX as be, EMAIL_REGEX as Oe, EMAIL_REGEX_INTO_TEXT as ge, EXCLUDED_REGEX as Ae, GLOBAL_PHONE_REGEX as Ce, PASSWORD_REGEX as Re, PHONE_REGEX as Se, ROOMS_REGEX as Te, SQM_REGEX as _e } from "./RegexUtils.js";
|
|
19
|
+
import { browserSupportGeolocation as Le, getUserPosition as Ne } from "./GeolocationUtils.js";
|
|
20
|
+
import { formatAddress as ye, formattedAddress as Pe } from "./AdressUtils.js";
|
|
21
|
+
import { googlePlaceConverter as De } from "./GAutocompleteUtils.js";
|
|
22
|
+
import { downloadFile as Me } from "./DownloadUtils.js";
|
|
23
23
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
ue as COMPETITOR_REGEX,
|
|
25
|
+
be as DATE_REGEX,
|
|
26
|
+
Oe as EMAIL_REGEX,
|
|
27
|
+
ge as EMAIL_REGEX_INTO_TEXT,
|
|
28
|
+
Ae as EXCLUDED_REGEX,
|
|
29
29
|
Ce as GLOBAL_PHONE_REGEX,
|
|
30
30
|
Re as PASSWORD_REGEX,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
Se as PHONE_REGEX,
|
|
32
|
+
Te as ROOMS_REGEX,
|
|
33
|
+
_e as SQM_REGEX,
|
|
34
|
+
ee as addPermissionStateListener,
|
|
35
|
+
de as appendQueryString,
|
|
36
36
|
D as awaitableSetTimeout,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
Le as browserSupportGeolocation,
|
|
38
|
+
te as buildParams,
|
|
39
|
+
me as buildParamsForAgency,
|
|
40
|
+
ae as buildURL,
|
|
41
|
+
pe as capitalizeFirstLetter,
|
|
42
42
|
Ee as cleanASCII,
|
|
43
43
|
v as createCustomEvent,
|
|
44
|
-
|
|
44
|
+
y as debounce,
|
|
45
45
|
i as decodeCookie,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
le as decodeTextWithEntities,
|
|
47
|
+
Q as deepCopy,
|
|
48
|
+
Me as downloadFile,
|
|
49
|
+
R as emptyElem,
|
|
50
|
+
p as encodeCookie,
|
|
51
|
+
ye as formatAddress,
|
|
52
|
+
f as formatCurrency,
|
|
53
53
|
c as formatDate,
|
|
54
54
|
d as formatDateToddMMYYYY,
|
|
55
55
|
I as formatFloat,
|
|
@@ -57,34 +57,35 @@ export {
|
|
|
57
57
|
k as formatLocaleNumber,
|
|
58
58
|
w as formatLocaleNumberAuto,
|
|
59
59
|
j as formatNumber,
|
|
60
|
-
|
|
60
|
+
Pe as formattedAddress,
|
|
61
61
|
Y as formatterNumberObj,
|
|
62
|
-
|
|
62
|
+
E as getCookie,
|
|
63
63
|
b as getCurrentDeviceSize,
|
|
64
|
-
|
|
64
|
+
W as getOrNull,
|
|
65
65
|
S as getSingleElement,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
Ne as getUserPosition,
|
|
67
|
+
De as googlePlaceConverter,
|
|
68
|
+
L as hash256,
|
|
69
|
+
N as hashEmail,
|
|
70
70
|
T as hideElem,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
B as invertFlatObject,
|
|
72
|
+
K as invertKeyToValue,
|
|
73
73
|
r as isArrNullOrEmpty,
|
|
74
|
-
|
|
74
|
+
V as isEmptyObject,
|
|
75
75
|
O as isMobile,
|
|
76
76
|
P as isPromise,
|
|
77
77
|
g as isSafari,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
A as isiOSDevice,
|
|
79
|
+
Z as observeOnce,
|
|
80
|
+
oe as onNotificationsPermissionChange,
|
|
81
81
|
H as parseLocaleNumber,
|
|
82
|
+
U as parseLocaleNumberAuto,
|
|
82
83
|
l as removeCookie,
|
|
83
|
-
|
|
84
|
+
se as replaceAll,
|
|
84
85
|
fe as replaceAllTokens,
|
|
85
86
|
m as rgba,
|
|
86
|
-
|
|
87
|
+
q as shallowCopyObjectTo,
|
|
87
88
|
_ as showElem,
|
|
88
|
-
|
|
89
|
+
ne as stringToHyphened,
|
|
89
90
|
x as subtractDaysFromDate
|
|
90
91
|
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
export declare const parseLocaleNumber: (stringNumber: string, locale?: Intl.LocalesArgument) => number | string | null;
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Automatically parses a string number to a number according to the user's locale settings.
|
|
4
|
+
*
|
|
5
|
+
* Utilizes `parseLocaleNumber` to parse the provided string number with optional currency parsing.
|
|
6
|
+
* The locale is determined using the user's browser language settings.
|
|
7
|
+
*
|
|
8
|
+
* @param stringNumber - The string number to parse
|
|
9
|
+
* @returns The parsed number, or undefined if the input is invalid
|
|
5
10
|
*/
|
|
6
|
-
export declare const
|
|
11
|
+
export declare const parseLocaleNumberAuto: (stringNumber: string) => string | number | null;
|
|
7
12
|
export declare const formatLocaleNumber: (numberToFormat?: number | string, props?: {
|
|
8
13
|
currency: boolean;
|
|
9
|
-
}, lang?:
|
|
14
|
+
}, lang?: Intl.LocalesArgument) => string | undefined | null;
|
|
10
15
|
/**
|
|
11
16
|
* Automatically formats a number according to the user's locale settings.
|
|
12
17
|
*
|