@wikicasa-dev/utilities 0.1.1 → 0.2.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.
Files changed (57) hide show
  1. package/README.md +32 -2
  2. package/dist/index.d.ts +3 -3
  3. package/dist/main.d.ts +0 -0
  4. package/dist/utilities.cjs +4 -4
  5. package/dist/utilities.iife.js +4 -4
  6. package/dist/utilities.mjs +892 -1181
  7. package/dist/utils/DateUtils.d.ts +1 -0
  8. package/dist/utils/FunctionUtils.d.ts +2 -2
  9. package/dist/utils/StringUtils.d.ts +1 -0
  10. package/index.html +13 -0
  11. package/package.json +4 -6
  12. package/src/custom/constants.ts +3 -0
  13. package/src/custom/icons.ts +63 -0
  14. package/src/custom/leaflet_map.ts +946 -0
  15. package/src/index.ts +171 -0
  16. package/src/main.ts +1 -0
  17. package/src/services/agencyAPI.ts +105 -0
  18. package/src/services/geographyAPI.ts +129 -0
  19. package/src/services/insightsAPI.ts +20 -0
  20. package/src/services/mailAPI.ts +89 -0
  21. package/src/services/placesAPI.ts +72 -0
  22. package/src/services/portfolioCustomerAPI.ts +16 -0
  23. package/src/services/publicUserAPI.ts +216 -0
  24. package/src/services/realEstateAPI.ts +133 -0
  25. package/src/services/requestAPI.ts +40 -0
  26. package/src/services/servicesUtils.ts +27 -0
  27. package/src/services/statisticsAPI.ts +84 -0
  28. package/src/services/valuationAPI.ts +45 -0
  29. package/src/services/wikicasaPro.ts +25 -0
  30. package/src/utils/ArrayUtils.ts +2 -0
  31. package/src/utils/ColorUtils.ts +11 -0
  32. package/src/utils/CookieUtils.ts +43 -0
  33. package/src/utils/CurrencyUtils.ts +18 -0
  34. package/src/utils/DOMUtils.ts +28 -0
  35. package/src/utils/DateUtils.ts +9 -0
  36. package/src/utils/DeviceDetectionUtils.ts +17 -0
  37. package/src/utils/EmailUtils.ts +45 -0
  38. package/src/utils/FavoriteUtils.ts +19 -0
  39. package/src/utils/FunctionUtils.ts +29 -0
  40. package/src/utils/GAutocompleteUtils.ts +70 -0
  41. package/src/utils/GenericUtils.ts +37 -0
  42. package/src/utils/LazyLoadingBg.ts +18 -0
  43. package/src/utils/MapUtils.ts +118 -0
  44. package/src/utils/NumberUtils.ts +90 -0
  45. package/src/utils/ObjectUtils.ts +34 -0
  46. package/src/utils/ObserverUtils.ts +32 -0
  47. package/src/utils/PermissionUtils.ts +41 -0
  48. package/src/utils/RESB_UrlBuilder.ts +99 -0
  49. package/src/utils/RequestUtils.ts +20 -0
  50. package/src/utils/StringUtils.ts +75 -0
  51. package/src/utils/URLBuilderUtils.ts +21 -0
  52. package/src/utils/URLPagesFactory.ts +20 -0
  53. package/src/vite-env.d.ts +1 -0
  54. package/tsconfig.json +38 -0
  55. package/vite.config.ts +42 -0
  56. package/dist/utils/AppRedirectUtils.d.ts +0 -1
  57. package/dist/utils/GAEvents.d.ts +0 -2
@@ -0,0 +1 @@
1
+ export declare function formatDate(date: Date, display?: boolean): string;
@@ -4,7 +4,7 @@
4
4
  * @returns a function correctly typed as Promise
5
5
  */
6
6
  export declare function isPromise<T>(functionToCheck: any): Promise<T>;
7
- export declare function debounce<T extends Function, TReturn>(timeout: {
7
+ export declare function debounce<T extends (...args: any[]) => any, TReturn>(timeout: {
8
8
  id?: ReturnType<typeof setTimeout>;
9
9
  delay: number;
10
- }, func: T): (...args: any) => Promise<TReturn>;
10
+ }, func: T): (...args: any[]) => Promise<TReturn>;
@@ -10,3 +10,4 @@ export declare function decodeTextWithEntities(strWithEntities: string | null):
10
10
  * */
11
11
  export declare function replaceAllTokens(str: string, mapObj: Record<string, string>): string;
12
12
  export declare function cleanASCII(str: string): string;
13
+ export declare const stringToHyphened: (str?: string) => string;
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Utilities</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikicasa-dev/utilities",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Wikicasa frontend utilities",
5
5
  "type": "module",
6
6
  "main": "./dist/utilities.cjs",
@@ -12,9 +12,6 @@
12
12
  }
13
13
  },
14
14
  "types": "./dist/index.d.ts",
15
- "files": [
16
- "dist"
17
- ],
18
15
  "repository": {
19
16
  "type": "git",
20
17
  "url": "git+https://matteocarniglia@bitbucket.org/wikicasa/wikicasa-fe.git"
@@ -48,11 +45,12 @@
48
45
  "leaflet-draw": "^1.0.4",
49
46
  "leaflet-freedraw": "^2.13.3",
50
47
  "uuid": "^9.0.0",
51
- "@wikicasa-dev/types": "^0.0.4"
48
+ "@wikicasa-dev/types": "^0.9.0"
52
49
  },
53
50
  "scripts": {
54
51
  "dev": "vite",
55
52
  "build": "tsc && vite build",
56
- "preview": "vite preview"
53
+ "preview": "vite preview",
54
+ "prepublish": "pnpm build"
57
55
  }
58
56
  }
@@ -0,0 +1,3 @@
1
+ export const MAP_TILER_STYLE = "ac216796-6d5d-4f21-a7ce-d80a4b3a45e4";
2
+ export const MAP_TILER_TOKEN =
3
+ "pk.eyJ1Ijoid2lraWNhc2EiLCJhIjoiY2pqZnVlNXFrMHRzMTNwcGF4aXd2a3N5ZiJ9.BctgdXWxGJ9JRMp2U-SyRw";
@@ -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
+ });