@wikicasa-dev/utilities 0.1.0 → 0.1.2
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/index.d.ts +1 -0
- package/dist/utilities.cjs +5 -0
- package/dist/{utilities.umd.cjs → utilities.iife.js} +4 -4
- package/dist/{utilities.js → utilities.mjs} +57 -51
- package/dist/utils/DateUtils.d.ts +1 -0
- package/package.json +10 -7
- package/src/custom/constants.ts +3 -0
- package/src/custom/icons.ts +63 -0
- package/src/custom/leaflet_map.ts +946 -0
- package/src/index.ts +173 -0
- package/src/services/agencyAPI.ts +105 -0
- package/src/services/geographyAPI.ts +129 -0
- package/src/services/insightsAPI.ts +20 -0
- package/src/services/mailAPI.ts +89 -0
- package/src/services/placesAPI.ts +72 -0
- package/src/services/portfolioCustomerAPI.ts +16 -0
- package/src/services/publicUserAPI.ts +216 -0
- package/src/services/realEstateAPI.ts +133 -0
- package/src/services/requestAPI.ts +40 -0
- package/src/services/servicesUtils.ts +27 -0
- package/src/services/statisticsAPI.ts +84 -0
- package/src/services/valuationAPI.ts +45 -0
- package/src/services/wikicasaPro.ts +25 -0
- package/src/utils/AppRedirectUtils.ts +26 -0
- package/src/utils/ArrayUtils.ts +2 -0
- package/src/utils/ColorUtils.ts +11 -0
- package/src/utils/CookieUtils.ts +43 -0
- package/src/utils/CurrencyUtils.ts +18 -0
- package/src/utils/DOMUtils.ts +28 -0
- package/src/utils/DateUtils.ts +9 -0
- package/src/utils/DeviceDetectionUtils.ts +17 -0
- package/src/utils/EmailUtils.ts +45 -0
- package/src/utils/FavoriteUtils.ts +19 -0
- package/src/utils/FunctionUtils.ts +29 -0
- package/src/utils/GAEvents.ts +414 -0
- package/src/utils/GAutocompleteUtils.ts +70 -0
- package/src/utils/GenericUtils.ts +37 -0
- package/src/utils/LazyLoadingBg.ts +18 -0
- package/src/utils/MapUtils.ts +118 -0
- package/src/utils/NumberUtils.ts +90 -0
- package/src/utils/ObjectUtils.ts +34 -0
- package/src/utils/ObserverUtils.ts +32 -0
- package/src/utils/PermissionUtils.ts +41 -0
- package/src/utils/RESB_UrlBuilder.ts +99 -0
- package/src/utils/RequestUtils.ts +20 -0
- package/src/utils/StringUtils.ts +67 -0
- package/src/utils/URLBuilderUtils.ts +21 -0
- package/src/utils/URLPagesFactory.ts +20 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +38 -0
- package/vite.config.ts +42 -0
|
@@ -2116,18 +2116,23 @@ const _o = (e, t, n = "it-IT") => {
|
|
|
2116
2116
|
maximumFractionDigits: 0
|
|
2117
2117
|
};
|
|
2118
2118
|
return Sn(t, r), new Intl.NumberFormat(n, r).format(e);
|
|
2119
|
-
}
|
|
2119
|
+
};
|
|
2120
|
+
function So(e, t = !1) {
|
|
2121
|
+
const n = e.getDate(), r = e.getMonth() + 1, o = e.getFullYear();
|
|
2122
|
+
return t ? `${("0" + n).slice(-2)}-${("0" + r).slice(-2)}-${o}` : `${o}-${("0" + r).slice(-2)}-${("0" + n).slice(-2)}`;
|
|
2123
|
+
}
|
|
2124
|
+
const Ro = () => /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream, $o = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
2120
2125
|
navigator.userAgent
|
|
2121
|
-
),
|
|
2126
|
+
), Oo = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent), Dn = (e) => {
|
|
2122
2127
|
const t = document.querySelector(e);
|
|
2123
2128
|
if (!t)
|
|
2124
2129
|
throw new Error(`No element found with the id: ${e}`);
|
|
2125
2130
|
return t;
|
|
2126
|
-
},
|
|
2131
|
+
}, Po = (e) => {
|
|
2127
2132
|
typeof e == "string" ? Dn(e).textContent = "" : e.textContent = "";
|
|
2128
|
-
},
|
|
2133
|
+
}, Co = (e, t = "block") => {
|
|
2129
2134
|
e && (e.style.display = t);
|
|
2130
|
-
},
|
|
2135
|
+
}, To = (e) => {
|
|
2131
2136
|
e && (e.style.display = "none");
|
|
2132
2137
|
}, qn = (e) => e.includes("@gmail");
|
|
2133
2138
|
async function jn(e) {
|
|
@@ -2147,16 +2152,16 @@ const Gn = (e) => {
|
|
|
2147
2152
|
r += o;
|
|
2148
2153
|
}
|
|
2149
2154
|
return `${r}@${t[1]}`;
|
|
2150
|
-
},
|
|
2155
|
+
}, Lo = (e) => {
|
|
2151
2156
|
if (!e || !e.trim())
|
|
2152
2157
|
throw new Error("The email in null or empty");
|
|
2153
2158
|
let t = e;
|
|
2154
2159
|
return qn(t) && (t = Gn(e)), jn(t);
|
|
2155
|
-
},
|
|
2160
|
+
}, No = (e) => {
|
|
2156
2161
|
document.querySelectorAll(`a[class^=fav][data-id='${e}']`).forEach((n) => {
|
|
2157
2162
|
n.classList.contains("fav-save") ? n.style.display = "none" : n.classList.contains("fav-remove") && (n.style.display = "block");
|
|
2158
2163
|
});
|
|
2159
|
-
},
|
|
2164
|
+
}, Uo = (e) => {
|
|
2160
2165
|
document.querySelectorAll(`a[class^=fav][data-id='${e}']`).forEach((n) => {
|
|
2161
2166
|
n.classList.contains("fav-save") ? n.style.display = "block" : n.classList.contains("fav-remove") && (n.style.display = "none");
|
|
2162
2167
|
});
|
|
@@ -2447,11 +2452,11 @@ const Gn = (e) => {
|
|
|
2447
2452
|
copy_trend_widget: ar,
|
|
2448
2453
|
send_avm_widget_request: cr
|
|
2449
2454
|
};
|
|
2450
|
-
function
|
|
2455
|
+
function xo(e, t) {
|
|
2451
2456
|
const n = ur[e];
|
|
2452
2457
|
t ? n(t) : n();
|
|
2453
2458
|
}
|
|
2454
|
-
function
|
|
2459
|
+
function Io(e, t, n) {
|
|
2455
2460
|
return e.replace(new RegExp(t, "g"), n);
|
|
2456
2461
|
}
|
|
2457
2462
|
function lr(e) {
|
|
@@ -2463,13 +2468,13 @@ function dr(e, t, n, r) {
|
|
|
2463
2468
|
const i = o.filter((s) => !!s).join(", ");
|
|
2464
2469
|
return lr(i);
|
|
2465
2470
|
}
|
|
2466
|
-
function
|
|
2471
|
+
function Fo(e) {
|
|
2467
2472
|
if (!e)
|
|
2468
2473
|
return "";
|
|
2469
2474
|
const t = document.createElement("span");
|
|
2470
2475
|
return t.innerHTML = e, t.textContent || "";
|
|
2471
2476
|
}
|
|
2472
|
-
function
|
|
2477
|
+
function Bo(e, t) {
|
|
2473
2478
|
const n = new RegExp(
|
|
2474
2479
|
Object.keys(t).map((r) => r.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")).join("|"),
|
|
2475
2480
|
"gi"
|
|
@@ -2494,10 +2499,10 @@ const pr = async (e, t) => {
|
|
|
2494
2499
|
o && o !== i && (r.streetNumber = o.toString());
|
|
2495
2500
|
}
|
|
2496
2501
|
return r;
|
|
2497
|
-
},
|
|
2502
|
+
}, Mo = async (e, t) => {
|
|
2498
2503
|
const n = await Cn(e), r = await pr(n, t), o = r.streetName ? dr(r.streetName, r.streetNumber || "", r.cityName) : r.address;
|
|
2499
2504
|
return { place: r, address: o };
|
|
2500
|
-
},
|
|
2505
|
+
}, ko = (e, t) => new Promise((n, r) => {
|
|
2501
2506
|
setTimeout(() => {
|
|
2502
2507
|
try {
|
|
2503
2508
|
e && e(), n();
|
|
@@ -2527,7 +2532,7 @@ const pr = async (e, t) => {
|
|
|
2527
2532
|
...o
|
|
2528
2533
|
}).format(e);
|
|
2529
2534
|
};
|
|
2530
|
-
function
|
|
2535
|
+
function Do(e, t = !1) {
|
|
2531
2536
|
return e == null ? "" : st(t ? Math.round(e) : Math.floor(e), 0);
|
|
2532
2537
|
}
|
|
2533
2538
|
function st(e, t) {
|
|
@@ -2540,14 +2545,14 @@ function st(e, t) {
|
|
|
2540
2545
|
}
|
|
2541
2546
|
);
|
|
2542
2547
|
}
|
|
2543
|
-
function
|
|
2548
|
+
function qo(e, t = 2) {
|
|
2544
2549
|
return st(e, t);
|
|
2545
2550
|
}
|
|
2546
|
-
const
|
|
2551
|
+
const jo = {
|
|
2547
2552
|
formatFn: mr,
|
|
2548
2553
|
unFormatFn: hr
|
|
2549
2554
|
};
|
|
2550
|
-
function
|
|
2555
|
+
function Go(e, t, n) {
|
|
2551
2556
|
const r = [].slice.call(document.querySelectorAll(e)), o = new IntersectionObserver(
|
|
2552
2557
|
(i, s) => {
|
|
2553
2558
|
for (let c = 0; c < i.length; c++) {
|
|
@@ -2565,9 +2570,9 @@ function jo(e, t, n) {
|
|
|
2565
2570
|
});
|
|
2566
2571
|
}
|
|
2567
2572
|
let xe = !1;
|
|
2568
|
-
const
|
|
2573
|
+
const zo = (e) => {
|
|
2569
2574
|
document.addEventListener("notification-permission-changed", e);
|
|
2570
|
-
},
|
|
2575
|
+
}, Vo = () => {
|
|
2571
2576
|
!navigator.permissions || !navigator.permissions.query || (!xe && navigator.permissions.query({ name: "notifications" }).then(function(e) {
|
|
2572
2577
|
e.onchange = function() {
|
|
2573
2578
|
document.dispatchEvent(
|
|
@@ -2578,7 +2583,7 @@ const Go = (e) => {
|
|
|
2578
2583
|
};
|
|
2579
2584
|
}), xe = !0);
|
|
2580
2585
|
};
|
|
2581
|
-
function
|
|
2586
|
+
function Ho(e) {
|
|
2582
2587
|
return new Promise(
|
|
2583
2588
|
(t, n) => f.post("/rest/request/addRequestGenericValuation", e, {
|
|
2584
2589
|
headers: { "Content-Type": "application/json", dataType: "json" }
|
|
@@ -2587,15 +2592,15 @@ function Vo(e) {
|
|
|
2587
2592
|
}).catch((r) => n(r))
|
|
2588
2593
|
);
|
|
2589
2594
|
}
|
|
2590
|
-
function
|
|
2595
|
+
function Wo(e, t, n, r, o, i, s) {
|
|
2591
2596
|
let c = "/";
|
|
2592
2597
|
return n && (c += (n == me.AUCTION ? window._auctionLabel : n == me.RENT ? window._rentLabel : window._saleLabel) + "-"), c += `${t}/`, i && (c += `${i}/`), e && (c += `${e.replace(/^-+|-+$/g, "")}/`), r && (c += `${r.replace(/^_+|_+$/g, "")}/`), !r && s && (c += `${s.replace(/^_+|_+$/g, "")}/`), o && (c += `${o.replace(/^_+|_+$/g, "")}/`), c;
|
|
2593
2598
|
}
|
|
2594
|
-
function
|
|
2599
|
+
function Jo(e) {
|
|
2595
2600
|
const t = Object.keys(Ue).map((n) => e[n] ? encodeURIComponent(Ue[n]) + "=" + encodeURIComponent(e[n]) : null).filter((n) => n !== null);
|
|
2596
2601
|
return t.length ? `?${t.join("&")}` : "";
|
|
2597
2602
|
}
|
|
2598
|
-
function
|
|
2603
|
+
function Ko(e) {
|
|
2599
2604
|
const t = Object.keys(le).map((n) => {
|
|
2600
2605
|
if (e[n])
|
|
2601
2606
|
if (Array.isArray(e[n])) {
|
|
@@ -2611,7 +2616,7 @@ function Jo(e) {
|
|
|
2611
2616
|
}).filter((n) => n !== null);
|
|
2612
2617
|
return t.length ? `?${t.join("&")}` : "";
|
|
2613
2618
|
}
|
|
2614
|
-
const
|
|
2619
|
+
const Qo = (e) => {
|
|
2615
2620
|
const t = `${window._baseURL}`;
|
|
2616
2621
|
switch (e) {
|
|
2617
2622
|
case "SAVED_SEARCHES":
|
|
@@ -2622,32 +2627,33 @@ const Ko = (e) => {
|
|
|
2622
2627
|
};
|
|
2623
2628
|
export {
|
|
2624
2629
|
ao as addGenericRequest,
|
|
2625
|
-
|
|
2630
|
+
Vo as addPermissionStateListener,
|
|
2626
2631
|
zr as addUserFavorite,
|
|
2627
2632
|
re as appendQueryString,
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2633
|
+
ko as awaitableSetTimeout,
|
|
2634
|
+
Jo as buildParams,
|
|
2635
|
+
Ko as buildParamsForAgency,
|
|
2636
|
+
Wo as buildURL,
|
|
2632
2637
|
lr as capitalizeFirstLetter,
|
|
2633
2638
|
fr as cleanASCII,
|
|
2634
2639
|
Eo as decodeCookie,
|
|
2635
|
-
|
|
2640
|
+
Fo as decodeTextWithEntities,
|
|
2636
2641
|
et as deepCopy,
|
|
2637
2642
|
qr as deleteAllSaveSearch,
|
|
2638
2643
|
jr as deleteSaveSearch,
|
|
2639
2644
|
Vr as deleteUserFavorite,
|
|
2640
2645
|
Kr as deleteUserFirebaseToken,
|
|
2641
|
-
|
|
2646
|
+
Po as emptyElem,
|
|
2642
2647
|
bo as encodeCookie,
|
|
2643
2648
|
mo as evaluateRealEstateWidget,
|
|
2644
2649
|
dr as formatAddress,
|
|
2645
2650
|
_o as formatCurrency,
|
|
2646
|
-
|
|
2647
|
-
|
|
2651
|
+
So as formatDate,
|
|
2652
|
+
qo as formatFloat,
|
|
2653
|
+
Do as formatInteger,
|
|
2648
2654
|
mr as formatLocaleNumber,
|
|
2649
2655
|
st as formatNumber,
|
|
2650
|
-
|
|
2656
|
+
jo as formatterNumberObj,
|
|
2651
2657
|
br as getAgenciesData,
|
|
2652
2658
|
gr as getAgencyById,
|
|
2653
2659
|
Rr as getCityPolygonJSON,
|
|
@@ -2659,7 +2665,7 @@ export {
|
|
|
2659
2665
|
Dr as getMarketingConsent,
|
|
2660
2666
|
Mr as getMenuInfo,
|
|
2661
2667
|
xr as getPlace,
|
|
2662
|
-
|
|
2668
|
+
Mo as getPlaceFromGAutocomplete,
|
|
2663
2669
|
Er as getPlaceFromPlaceID,
|
|
2664
2670
|
po as getPlaceTrendData,
|
|
2665
2671
|
Ar as getPlacesAddressAutocomplete,
|
|
@@ -2676,26 +2682,26 @@ export {
|
|
|
2676
2682
|
Yr as getSavedSearchesCount,
|
|
2677
2683
|
Dn as getSingleElement,
|
|
2678
2684
|
Or as getTransactionGraphData,
|
|
2679
|
-
|
|
2685
|
+
Qo as getURLPage,
|
|
2680
2686
|
Ir as getZones,
|
|
2681
2687
|
pr as googlePlaceConverter,
|
|
2682
2688
|
Tn as guessPlace,
|
|
2683
2689
|
h as handleAxiosError,
|
|
2684
|
-
|
|
2685
|
-
|
|
2690
|
+
Lo as hashEmail,
|
|
2691
|
+
To as hideElem,
|
|
2686
2692
|
go as isArrNullOrEmpty,
|
|
2687
2693
|
yr as isEmptyObject,
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2694
|
+
$o as isMobile,
|
|
2695
|
+
Oo as isSafari,
|
|
2696
|
+
Ro as isiOSDevice,
|
|
2697
|
+
Go as observeOnce,
|
|
2698
|
+
zo as onNotificationsPermissionChange,
|
|
2693
2699
|
hr as parseLocaleNumber,
|
|
2694
2700
|
wo as redirectToApp,
|
|
2695
2701
|
kn as removeCookie,
|
|
2696
2702
|
Wr as removeFavourites,
|
|
2697
|
-
|
|
2698
|
-
|
|
2703
|
+
Io as replaceAll,
|
|
2704
|
+
Bo as replaceAllTokens,
|
|
2699
2705
|
vo as rgba,
|
|
2700
2706
|
to as saveSearch,
|
|
2701
2707
|
no as saveSearchFromRequest,
|
|
@@ -2703,18 +2709,18 @@ export {
|
|
|
2703
2709
|
wr as sendAgencyContactAsync,
|
|
2704
2710
|
Lr as sendBrochureMR,
|
|
2705
2711
|
Cr as sendBrochureRequest,
|
|
2706
|
-
|
|
2712
|
+
xo as sendGAEvent,
|
|
2707
2713
|
Nr as sendInfoMR,
|
|
2708
2714
|
Pr as sendInfoPremium,
|
|
2709
2715
|
Tr as sendJobApplicationForm,
|
|
2710
2716
|
vr as sendMortgage,
|
|
2711
|
-
|
|
2717
|
+
Ho as sendRequestGeneric,
|
|
2712
2718
|
io as sendSuggestion,
|
|
2713
2719
|
co as sendWidgetRequest,
|
|
2714
2720
|
Sn as shallowCopyObjectTo,
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2721
|
+
Uo as showAddFavoritesIcon,
|
|
2722
|
+
Co as showElem,
|
|
2723
|
+
No as showRemoveFavoritesIcons,
|
|
2718
2724
|
Qr as updateMarketingConsent,
|
|
2719
2725
|
Br as updateNewsletterConsent,
|
|
2720
2726
|
Hr as updateNote,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatDate(date: Date, display?: boolean): string;
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wikicasa-dev/utilities",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Wikicasa frontend utilities",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/utilities.
|
|
6
|
+
"main": "./dist/utilities.cjs",
|
|
7
|
+
"module": "./dist/utilities.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/utilities.cjs",
|
|
11
|
+
"import": "./dist/utilities.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"module": "./dist/utilities.js",
|
|
9
|
-
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
],
|
|
12
15
|
"repository": {
|
|
13
16
|
"type": "git",
|
|
14
17
|
"url": "git+https://matteocarniglia@bitbucket.org/wikicasa/wikicasa-fe.git"
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
"leaflet-draw": "^1.0.4",
|
|
43
46
|
"leaflet-freedraw": "^2.13.3",
|
|
44
47
|
"uuid": "^9.0.0",
|
|
45
|
-
"@wikicasa-dev/types": "^0.0.
|
|
48
|
+
"@wikicasa-dev/types": "^0.0.10"
|
|
46
49
|
},
|
|
47
50
|
"scripts": {
|
|
48
51
|
"dev": "vite",
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// eslint-disable-next-line max-len
|
|
2
|
+
export const SVG = `<svg viewBox="0 0 128 128" class="icon-spin"><circle class="path" cx="64" cy="64" r="42" fill="none" stroke-width="9"></circle></svg>`;
|
|
3
|
+
|
|
4
|
+
export function addSpinner(btn: HTMLElement | JQuery, append: boolean = false): void {
|
|
5
|
+
|
|
6
|
+
if (!btn)
|
|
7
|
+
return;
|
|
8
|
+
|
|
9
|
+
const $btn: JQuery = $(btn);
|
|
10
|
+
const $svg: JQuery = $(SVG);
|
|
11
|
+
|
|
12
|
+
$btn.attr("disabled", "disabled");
|
|
13
|
+
|
|
14
|
+
const $icon: JQuery = $btn.find(".icon");
|
|
15
|
+
|
|
16
|
+
if (!$icon.length) {
|
|
17
|
+
$svg.addClass(`icon icon-md ${append ? "ml-5" : "mr-5"}`);
|
|
18
|
+
append ? $btn.append($svg): $btn.prepend($svg);
|
|
19
|
+
} else {
|
|
20
|
+
$btn.data("icon-prev", $icon);
|
|
21
|
+
$svg.addClass($icon.attr("class") || "");
|
|
22
|
+
$icon.replaceWith($svg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function removeSpinner(btn: HTMLElement | JQuery): void {
|
|
27
|
+
|
|
28
|
+
if (!btn)
|
|
29
|
+
return;
|
|
30
|
+
|
|
31
|
+
const $btn: JQuery = $(btn);
|
|
32
|
+
|
|
33
|
+
$btn.removeAttr("disabled");
|
|
34
|
+
|
|
35
|
+
const $svg: JQuery = $btn.find(".icon-spin");
|
|
36
|
+
|
|
37
|
+
const prev = $btn.data("icon-prev");
|
|
38
|
+
|
|
39
|
+
if (prev) {
|
|
40
|
+
$svg.replaceWith(prev);
|
|
41
|
+
} else
|
|
42
|
+
$svg.remove();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
$(() => {
|
|
46
|
+
const dataSpinners = [].slice.call(document.querySelectorAll("[data-spinner]"));
|
|
47
|
+
|
|
48
|
+
dataSpinners.forEach((entry: HTMLElement) => {
|
|
49
|
+
const $entry: JQuery = $(entry);
|
|
50
|
+
|
|
51
|
+
$entry.on("click", () => {
|
|
52
|
+
|
|
53
|
+
if ($entry[0].hasAttribute("disabled"))
|
|
54
|
+
return;
|
|
55
|
+
|
|
56
|
+
addSpinner($entry);
|
|
57
|
+
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
removeSpinner($entry);
|
|
60
|
+
}, 30000);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|