@wikicasa-dev/utilities 1.0.5 → 1.0.6
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/AdressUtils.cjs +1 -0
- package/dist/AdressUtils.js +12 -0
- package/dist/GAutocompleteUtils.cjs +1 -0
- package/dist/GAutocompleteUtils.js +16 -0
- package/dist/StringUtils.cjs +1 -1
- package/dist/StringUtils.js +13 -20
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +41 -37
- package/dist/utils/AdressUtils.d.ts +22 -0
- package/dist/utils/GAutocompleteUtils.d.ts +2 -0
- package/dist/utils/StringUtils.d.ts +6 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./StringUtils.cjs");function f(d,s,o,n){const i=[];d&&d!=="ND"&&(s&&s!=="ND"&&s!=="0"?i.push(`${d} ${s}`):i.push(d)),o&&n?i.push(`${o} (${n})`):i.push(o);const t=i.filter(r=>!!r).join(", ");return l.capitalizeFirstLetter(t)}const u=(d,s,o,n)=>s?f(s,o||"",n):d;exports.formatAddress=f;exports.formattedAddress=u;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { capitalizeFirstLetter as h } from "./StringUtils.js";
|
|
2
|
+
function l(s, o, f, i) {
|
|
3
|
+
const d = [];
|
|
4
|
+
s && s !== "ND" && (o && o !== "ND" && o !== "0" ? d.push(`${s} ${o}`) : d.push(s)), f && i ? d.push(`${f} (${i})`) : d.push(f);
|
|
5
|
+
const n = d.filter((p) => !!p).join(", ");
|
|
6
|
+
return h(n);
|
|
7
|
+
}
|
|
8
|
+
const u = (s, o, f, i) => o ? l(o, f || "", i) : s;
|
|
9
|
+
export {
|
|
10
|
+
l as formatAddress,
|
|
11
|
+
u as formattedAddress
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./StringUtils.cjs"),i=async(t,o,n)=>{const s={};for(let e=0;e<t.address_components.length;e++)t.address_components[e].types.indexOf("administrative_area_level_3")!==-1?s.city=t.address_components[e].long_name:t.address_components[e].types.indexOf("locality")!==-1?s.locality=t.address_components[e].long_name:t.address_components[e].types.indexOf("route")!==-1?s.streetName=t.address_components[e].long_name:t.address_components[e].types.indexOf("street_number")!==-1?s.streetNumber=t.address_components[e].long_name:t.address_components[e].types.indexOf("postal_code")!==-1&&(s.zip=t.address_components[e].long_name);if(s.latitude=t.geometry.location.lat,s.longitude=t.geometry.location.lng,s.address=d.cleanASCII(o),typeof s.streetNumber>"u"&&(s.streetNumber=null),delete n.city,delete n.locality,n={...n,...s},!n.streetNumber){const e=parseInt(n.address.split(",")[1]),r=parseInt(n.zip);e&&e!==r&&(n.streetNumber=e.toString())}return n};exports.googlePlaceConverter=i;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { cleanASCII as d } from "./StringUtils.js";
|
|
2
|
+
const m = async (t, o, n) => {
|
|
3
|
+
const s = {};
|
|
4
|
+
for (let e = 0; e < t.address_components.length; e++)
|
|
5
|
+
t.address_components[e].types.indexOf(
|
|
6
|
+
"administrative_area_level_3"
|
|
7
|
+
) !== -1 ? s.city = t.address_components[e].long_name : t.address_components[e].types.indexOf("locality") !== -1 ? s.locality = t.address_components[e].long_name : t.address_components[e].types.indexOf("route") !== -1 ? s.streetName = t.address_components[e].long_name : t.address_components[e].types.indexOf("street_number") !== -1 ? s.streetNumber = t.address_components[e].long_name : t.address_components[e].types.indexOf("postal_code") !== -1 && (s.zip = t.address_components[e].long_name);
|
|
8
|
+
if (s.latitude = t.geometry.location.lat, s.longitude = t.geometry.location.lng, s.address = d(o), typeof s.streetNumber > "u" && (s.streetNumber = null), delete n.city, delete n.locality, n = { ...n, ...s }, !n.streetNumber) {
|
|
9
|
+
const e = parseInt(n.address.split(",")[1]), r = parseInt(n.zip);
|
|
10
|
+
e && e !== r && (n.streetNumber = e.toString());
|
|
11
|
+
}
|
|
12
|
+
return n;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
m as googlePlaceConverter
|
|
16
|
+
};
|
package/dist/StringUtils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(e,t,n){return e.replace(new RegExp(t,"g"),n)}function i(e){return e.charAt(0).toUpperCase()+e.slice(1)}function l(e){if(!e)return"";const t=document.createElement("span");return t.innerHTML=e,t.textContent||""}function o(e,t){const n=new RegExp(Object.keys(t).map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|"),"gi");return e.replace(n,function(r){return t[r.toLowerCase()]})}function a(e){return e.replace(/[\uA78C\uA78B]/g,"'").replace(/[^\x00-\x7F]/g,"")}const u=(e="")=>!e||!e.trim()?"":(e=e.trim(),e.replace(" ","-").toLowerCase());exports.capitalizeFirstLetter=i;exports.cleanASCII=a;exports.decodeTextWithEntities=l;exports.replaceAll=c;exports.replaceAllTokens=o;exports.stringToHyphened=u;
|
package/dist/StringUtils.js
CHANGED
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(e, n, r) {
|
|
2
2
|
return e.replace(new RegExp(n, "g"), r);
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function o(e) {
|
|
5
5
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
6
6
|
}
|
|
7
|
-
function l(e, n, r, o) {
|
|
8
|
-
const t = [];
|
|
9
|
-
e && e !== "ND" && (n && n !== "ND" && n !== "0" ? t.push(`${e} ${n}`) : t.push(e)), r && o ? t.push(`${r} (${o})`) : t.push(r);
|
|
10
|
-
const c = t.filter((u) => !!u).join(", ");
|
|
11
|
-
return i(c);
|
|
12
|
-
}
|
|
13
7
|
function a(e) {
|
|
14
8
|
if (!e)
|
|
15
9
|
return "";
|
|
16
10
|
const n = document.createElement("span");
|
|
17
11
|
return n.innerHTML = e, n.textContent || "";
|
|
18
12
|
}
|
|
19
|
-
function
|
|
13
|
+
function u(e, n) {
|
|
20
14
|
const r = new RegExp(
|
|
21
|
-
Object.keys(n).map((
|
|
15
|
+
Object.keys(n).map((t) => t.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")).join("|"),
|
|
22
16
|
"gi"
|
|
23
17
|
);
|
|
24
|
-
return e.replace(r, function(
|
|
25
|
-
return n[
|
|
18
|
+
return e.replace(r, function(t) {
|
|
19
|
+
return n[t.toLowerCase()];
|
|
26
20
|
});
|
|
27
21
|
}
|
|
28
|
-
function
|
|
22
|
+
function i(e) {
|
|
29
23
|
return e.replace(/[\uA78C\uA78B]/g, "'").replace(/[^\x00-\x7F]/g, "");
|
|
30
24
|
}
|
|
31
|
-
const
|
|
25
|
+
const l = (e = "") => !e || !e.trim() ? "" : (e = e.trim(), e.replace(" ", "-").toLowerCase());
|
|
32
26
|
export {
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
o as capitalizeFirstLetter,
|
|
28
|
+
i as cleanASCII,
|
|
35
29
|
a as decodeTextWithEntities,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
d as stringToHyphened
|
|
30
|
+
c as replaceAll,
|
|
31
|
+
u as replaceAllTokens,
|
|
32
|
+
l as stringToHyphened
|
|
40
33
|
};
|
package/dist/index.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 b=require("./ArrayUtils.cjs"),O=require("./ColorUtils.cjs"),i=require("./CookieUtils.cjs"),p=require("./CurrencyUtils.cjs"),C=require("./DateUtils.cjs"),o=require("./DeviceDetectionUtils.cjs"),s=require("./DOMUtils.cjs"),n=require("./EmailUtils.cjs"),E=require("./FunctionUtils.cjs"),c=require("./GenericUtils.cjs"),r=require("./NumberUtils.cjs"),a=require("./ObjectUtils.cjs"),R=require("./ObserverUtils.cjs"),m=require("./PermissionUtils.cjs"),l=require("./RESB_UrlBuilder.cjs"),t=require("./StringUtils.cjs"),g=require("./URLBuilderUtils.cjs"),e=require("./RegexUtils.cjs"),u=require("./GeolocationUtils.cjs"),d=require("./AdressUtils.cjs"),S=require("./GAutocompleteUtils.cjs");exports.isArrNullOrEmpty=b.isArrNullOrEmpty;exports.rgba=O.rgba;exports.decodeCookie=i.decodeCookie;exports.encodeCookie=i.encodeCookie;exports.getCookie=i.getCookie;exports.removeCookie=i.removeCookie;exports.formatCurrency=p.formatCurrency;exports.formatDate=C.formatDate;exports.getCurrentDeviceSize=o.getCurrentDeviceSize;exports.isMobile=o.isMobile;exports.isSafari=o.isSafari;exports.isiOSDevice=o.isiOSDevice;exports.emptyElem=s.emptyElem;exports.getSingleElement=s.getSingleElement;exports.hideElem=s.hideElem;exports.showElem=s.showElem;exports.hash256=n.hash256;exports.hashEmail=n.hashEmail;exports.debounce=E.debounce;exports.isPromise=E.isPromise;exports.awaitableSetTimeout=c.awaitableSetTimeout;exports.createCustomEvent=c.createCustomEvent;exports.formatFloat=r.formatFloat;exports.formatInteger=r.formatInteger;exports.formatLocaleNumber=r.formatLocaleNumber;exports.formatNumber=r.formatNumber;exports.formatterNumberObj=r.formatterNumberObj;exports.parseLocaleNumber=r.parseLocaleNumber;exports.deepCopy=a.deepCopy;exports.isEmptyObject=a.isEmptyObject;exports.shallowCopyObjectTo=a.shallowCopyObjectTo;exports.observeOnce=R.observeOnce;exports.addPermissionStateListener=m.addPermissionStateListener;exports.onNotificationsPermissionChange=m.onNotificationsPermissionChange;exports.buildParams=l.buildParams;exports.buildParamsForAgency=l.buildParamsForAgency;exports.buildURL=l.buildURL;exports.capitalizeFirstLetter=t.capitalizeFirstLetter;exports.cleanASCII=t.cleanASCII;exports.decodeTextWithEntities=t.decodeTextWithEntities;exports.replaceAll=t.replaceAll;exports.replaceAllTokens=t.replaceAllTokens;exports.stringToHyphened=t.stringToHyphened;exports.appendQueryString=g.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=u.browserSupportGeolocation;exports.getUserPosition=u.getUserPosition;exports.formatAddress=d.formatAddress;exports.formattedAddress=d.formattedAddress;exports.googlePlaceConverter=S.googlePlaceConverter;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,77 +2,81 @@ import { isArrNullOrEmpty as r } from "./ArrayUtils.js";
|
|
|
2
2
|
import { rgba as m } from "./ColorUtils.js";
|
|
3
3
|
import { decodeCookie as a, encodeCookie as E, getCookie as p, removeCookie as s } from "./CookieUtils.js";
|
|
4
4
|
import { formatCurrency as l } from "./CurrencyUtils.js";
|
|
5
|
-
import { formatDate as
|
|
5
|
+
import { formatDate as x } from "./DateUtils.js";
|
|
6
6
|
import { getCurrentDeviceSize as d, isMobile as b, isSafari as u, isiOSDevice as O } from "./DeviceDetectionUtils.js";
|
|
7
|
-
import { emptyElem as
|
|
8
|
-
import { hash256 as
|
|
9
|
-
import { debounce as
|
|
7
|
+
import { emptyElem as R, getSingleElement as g, hideElem as S, showElem as _ } from "./DOMUtils.js";
|
|
8
|
+
import { hash256 as G, hashEmail as X } from "./EmailUtils.js";
|
|
9
|
+
import { debounce as T, isPromise as h } from "./FunctionUtils.js";
|
|
10
10
|
import { awaitableSetTimeout as y, createCustomEvent as N } from "./GenericUtils.js";
|
|
11
|
-
import { formatFloat as I, formatInteger as
|
|
11
|
+
import { formatFloat as I, formatInteger as v, formatLocaleNumber as M, formatNumber as k, formatterNumberObj as w, parseLocaleNumber as j } from "./NumberUtils.js";
|
|
12
12
|
import { deepCopy as H, isEmptyObject as U, shallowCopyObjectTo as z } from "./ObjectUtils.js";
|
|
13
13
|
import { observeOnce as W } from "./ObserverUtils.js";
|
|
14
14
|
import { addPermissionStateListener as q, onNotificationsPermissionChange as J } from "./PermissionUtils.js";
|
|
15
15
|
import { buildParams as V, buildParamsForAgency as Y, buildURL as Z } from "./RESB_UrlBuilder.js";
|
|
16
|
-
import { capitalizeFirstLetter as ee, cleanASCII as oe, decodeTextWithEntities as re,
|
|
17
|
-
import { appendQueryString as
|
|
18
|
-
import { COMPETITOR_REGEX as
|
|
19
|
-
import { browserSupportGeolocation as
|
|
16
|
+
import { capitalizeFirstLetter as ee, cleanASCII as oe, decodeTextWithEntities as re, replaceAll as te, replaceAllTokens as me, stringToHyphened as ie } from "./StringUtils.js";
|
|
17
|
+
import { appendQueryString as Ee } from "./URLBuilderUtils.js";
|
|
18
|
+
import { COMPETITOR_REGEX as se, DATE_REGEX as fe, EMAIL_REGEX as le, EMAIL_REGEX_INTO_TEXT as ne, EXCLUDED_REGEX as xe, GLOBAL_PHONE_REGEX as ce, PASSWORD_REGEX as de, PHONE_REGEX as be, ROOMS_REGEX as ue, SQM_REGEX as Oe } from "./RegexUtils.js";
|
|
19
|
+
import { browserSupportGeolocation as Re, getUserPosition as ge } from "./GeolocationUtils.js";
|
|
20
|
+
import { formatAddress as _e, formattedAddress as Ae } from "./AdressUtils.js";
|
|
21
|
+
import { googlePlaceConverter as Xe } from "./GAutocompleteUtils.js";
|
|
20
22
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
se as COMPETITOR_REGEX,
|
|
24
|
+
fe as DATE_REGEX,
|
|
25
|
+
le as EMAIL_REGEX,
|
|
26
|
+
ne as EMAIL_REGEX_INTO_TEXT,
|
|
25
27
|
xe as EXCLUDED_REGEX,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
ce as GLOBAL_PHONE_REGEX,
|
|
29
|
+
de as PASSWORD_REGEX,
|
|
30
|
+
be as PHONE_REGEX,
|
|
31
|
+
ue as ROOMS_REGEX,
|
|
32
|
+
Oe as SQM_REGEX,
|
|
31
33
|
q as addPermissionStateListener,
|
|
32
|
-
|
|
34
|
+
Ee as appendQueryString,
|
|
33
35
|
y as awaitableSetTimeout,
|
|
34
|
-
|
|
36
|
+
Re as browserSupportGeolocation,
|
|
35
37
|
V as buildParams,
|
|
36
38
|
Y as buildParamsForAgency,
|
|
37
39
|
Z as buildURL,
|
|
38
40
|
ee as capitalizeFirstLetter,
|
|
39
41
|
oe as cleanASCII,
|
|
40
42
|
N as createCustomEvent,
|
|
41
|
-
|
|
43
|
+
T as debounce,
|
|
42
44
|
a as decodeCookie,
|
|
43
45
|
re as decodeTextWithEntities,
|
|
44
46
|
H as deepCopy,
|
|
45
|
-
|
|
47
|
+
R as emptyElem,
|
|
46
48
|
E as encodeCookie,
|
|
47
|
-
|
|
49
|
+
_e as formatAddress,
|
|
48
50
|
l as formatCurrency,
|
|
49
|
-
|
|
51
|
+
x as formatDate,
|
|
50
52
|
I as formatFloat,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
v as formatInteger,
|
|
54
|
+
M as formatLocaleNumber,
|
|
55
|
+
k as formatNumber,
|
|
56
|
+
Ae as formattedAddress,
|
|
54
57
|
w as formatterNumberObj,
|
|
55
58
|
p as getCookie,
|
|
56
59
|
d as getCurrentDeviceSize,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
g as getSingleElement,
|
|
61
|
+
ge as getUserPosition,
|
|
62
|
+
Xe as googlePlaceConverter,
|
|
63
|
+
G as hash256,
|
|
64
|
+
X as hashEmail,
|
|
65
|
+
S as hideElem,
|
|
62
66
|
r as isArrNullOrEmpty,
|
|
63
67
|
U as isEmptyObject,
|
|
64
68
|
b as isMobile,
|
|
65
|
-
|
|
69
|
+
h as isPromise,
|
|
66
70
|
u as isSafari,
|
|
67
71
|
O as isiOSDevice,
|
|
68
72
|
W as observeOnce,
|
|
69
73
|
J as onNotificationsPermissionChange,
|
|
70
74
|
j as parseLocaleNumber,
|
|
71
75
|
s as removeCookie,
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
te as replaceAll,
|
|
77
|
+
me as replaceAllTokens,
|
|
74
78
|
m as rgba,
|
|
75
79
|
z as shallowCopyObjectTo,
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
_ as showElem,
|
|
81
|
+
ie as stringToHyphened
|
|
78
82
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats the address based on the provided street name, street number, city name, and province acronym.
|
|
3
|
+
*
|
|
4
|
+
* @param streetName The name of the street.
|
|
5
|
+
* @param streetNumber The number of the street.
|
|
6
|
+
* @param cityName The name of the city.
|
|
7
|
+
* @param provinceAcronym The acronym of the province (optional).
|
|
8
|
+
* @returns The formatted address with capitalized first letters of each component.
|
|
9
|
+
*/
|
|
10
|
+
export declare function formatAddress(streetName: string, streetNumber: string, cityName: string, provinceAcronym?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Formats the address based on the provided parameters.
|
|
13
|
+
* If streetName is provided, it calls the formatAddress function with streetName, streetNumber, and cityName.
|
|
14
|
+
* If streetName is not provided, it returns the addressName.
|
|
15
|
+
*
|
|
16
|
+
* @param addressName - The name of the address.
|
|
17
|
+
* @param streetName - The name of the street.
|
|
18
|
+
* @param streetNumber - The number of the street.
|
|
19
|
+
* @param cityName - The name of the city.
|
|
20
|
+
* @returns The formatted address string.
|
|
21
|
+
*/
|
|
22
|
+
export declare const formattedAddress: (addressName: string, streetName: string | undefined, streetNumber: string | undefined, cityName: string) => string;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export declare function replaceAll(str: string, find: string, replace: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Capitalizes the first letter of a given string.
|
|
4
|
+
*
|
|
5
|
+
* @param string The input string to capitalize the first letter.
|
|
6
|
+
* @returns The input string with the first letter capitalized.
|
|
7
|
+
*/
|
|
2
8
|
export declare function capitalizeFirstLetter(string: string): string;
|
|
3
|
-
export declare function formatAddress(streetName: string, streetNumber: string, cityName: string, provinceAcronym?: string): string;
|
|
4
9
|
export declare function decodeTextWithEntities(strWithEntities: string | null): string;
|
|
5
10
|
/**
|
|
6
11
|
* Replaces a given string with the values of the object
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wikicasa-dev/utilities",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Wikicasa frontend utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typescript": "^5.4.3",
|
|
39
39
|
"vite": "^5.2.3",
|
|
40
40
|
"vite-plugin-dts": "^3.7.3",
|
|
41
|
-
"@wikicasa-dev/types": "^1.2.
|
|
41
|
+
"@wikicasa-dev/types": "^1.2.2"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"axios": "^1.4.0",
|