@wikicasa-dev/utilities 0.2.0 → 1.0.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 (112) hide show
  1. package/dist/ArrayUtils.cjs +1 -0
  2. package/dist/ArrayUtils.js +4 -0
  3. package/dist/ColorUtils.cjs +1 -0
  4. package/dist/ColorUtils.js +8 -0
  5. package/dist/CookieUtils.cjs +1 -0
  6. package/dist/CookieUtils.js +32 -0
  7. package/dist/CurrencyUtils.cjs +1 -0
  8. package/dist/CurrencyUtils.js +14 -0
  9. package/dist/DOMUtils.cjs +1 -0
  10. package/dist/DOMUtils.js +18 -0
  11. package/dist/DateUtils.cjs +1 -0
  12. package/dist/DateUtils.js +7 -0
  13. package/dist/DeviceDetectionUtils.cjs +1 -0
  14. package/dist/DeviceDetectionUtils.js +8 -0
  15. package/dist/EmailUtils.cjs +1 -0
  16. package/dist/EmailUtils.js +27 -0
  17. package/dist/FunctionUtils.cjs +1 -0
  18. package/dist/FunctionUtils.js +21 -0
  19. package/dist/GenericUtils.cjs +1 -0
  20. package/dist/GenericUtils.js +25 -0
  21. package/dist/LazyLoadingBg.cjs +1 -0
  22. package/dist/LazyLoadingBg.js +13 -0
  23. package/dist/NumberUtils.cjs +1 -0
  24. package/dist/NumberUtils.js +50 -0
  25. package/dist/ObjectUtils.cjs +1 -0
  26. package/dist/ObjectUtils.js +23 -0
  27. package/dist/ObserverUtils.cjs +1 -0
  28. package/dist/ObserverUtils.js +20 -0
  29. package/dist/PermissionUtils.cjs +1 -0
  30. package/dist/PermissionUtils.js +18 -0
  31. package/dist/RESB_UrlBuilder.cjs +1 -0
  32. package/dist/RESB_UrlBuilder.js +80 -0
  33. package/dist/StringUtils.cjs +1 -0
  34. package/dist/StringUtils.js +40 -0
  35. package/dist/URLBuilderUtils.cjs +1 -0
  36. package/dist/URLBuilderUtils.js +11 -0
  37. package/dist/index.cjs +1 -0
  38. package/dist/index.d.ts +17 -34
  39. package/dist/index.js +62 -0
  40. package/dist/main.cjs +1 -0
  41. package/dist/vite-env.cjs +1 -0
  42. package/dist/vite-env.js +1 -0
  43. package/package.json +17 -13
  44. package/dist/custom/constants.d.ts +0 -2
  45. package/dist/custom/icons.d.ts +0 -5
  46. package/dist/custom/leaflet_map.d.ts +0 -99
  47. package/dist/services/agencyAPI.d.ts +0 -19
  48. package/dist/services/geographyAPI.d.ts +0 -9
  49. package/dist/services/insightsAPI.d.ts +0 -2
  50. package/dist/services/mailAPI.d.ts +0 -24
  51. package/dist/services/placesAPI.d.ts +0 -5
  52. package/dist/services/portfolioCustomerAPI.d.ts +0 -1
  53. package/dist/services/publicUserAPI.d.ts +0 -20
  54. package/dist/services/realEstateAPI.d.ts +0 -14
  55. package/dist/services/requestAPI.d.ts +0 -16
  56. package/dist/services/servicesUtils.d.ts +0 -8
  57. package/dist/services/statisticsAPI.d.ts +0 -9
  58. package/dist/services/valuationAPI.d.ts +0 -11
  59. package/dist/services/wikicasaPro.d.ts +0 -2
  60. package/dist/utilities.cjs +0 -5
  61. package/dist/utilities.iife.js +0 -5
  62. package/dist/utilities.mjs +0 -2437
  63. package/dist/utils/FavoriteUtils.d.ts +0 -2
  64. package/dist/utils/GAutocompleteUtils.d.ts +0 -6
  65. package/dist/utils/MapUtils.d.ts +0 -23
  66. package/dist/utils/RequestUtils.d.ts +0 -2
  67. package/dist/utils/URLPagesFactory.d.ts +0 -9
  68. package/index.html +0 -13
  69. package/src/custom/constants.ts +0 -3
  70. package/src/custom/icons.ts +0 -63
  71. package/src/custom/leaflet_map.ts +0 -946
  72. package/src/index.ts +0 -171
  73. package/src/services/agencyAPI.ts +0 -105
  74. package/src/services/geographyAPI.ts +0 -129
  75. package/src/services/insightsAPI.ts +0 -20
  76. package/src/services/mailAPI.ts +0 -89
  77. package/src/services/placesAPI.ts +0 -72
  78. package/src/services/portfolioCustomerAPI.ts +0 -16
  79. package/src/services/publicUserAPI.ts +0 -216
  80. package/src/services/realEstateAPI.ts +0 -133
  81. package/src/services/requestAPI.ts +0 -40
  82. package/src/services/servicesUtils.ts +0 -27
  83. package/src/services/statisticsAPI.ts +0 -84
  84. package/src/services/valuationAPI.ts +0 -45
  85. package/src/services/wikicasaPro.ts +0 -25
  86. package/src/utils/ArrayUtils.ts +0 -2
  87. package/src/utils/ColorUtils.ts +0 -11
  88. package/src/utils/CookieUtils.ts +0 -43
  89. package/src/utils/CurrencyUtils.ts +0 -18
  90. package/src/utils/DOMUtils.ts +0 -28
  91. package/src/utils/DateUtils.ts +0 -9
  92. package/src/utils/DeviceDetectionUtils.ts +0 -17
  93. package/src/utils/EmailUtils.ts +0 -45
  94. package/src/utils/FavoriteUtils.ts +0 -19
  95. package/src/utils/FunctionUtils.ts +0 -29
  96. package/src/utils/GAutocompleteUtils.ts +0 -70
  97. package/src/utils/GenericUtils.ts +0 -37
  98. package/src/utils/LazyLoadingBg.ts +0 -18
  99. package/src/utils/MapUtils.ts +0 -118
  100. package/src/utils/NumberUtils.ts +0 -90
  101. package/src/utils/ObjectUtils.ts +0 -34
  102. package/src/utils/ObserverUtils.ts +0 -32
  103. package/src/utils/PermissionUtils.ts +0 -41
  104. package/src/utils/RESB_UrlBuilder.ts +0 -99
  105. package/src/utils/RequestUtils.ts +0 -20
  106. package/src/utils/StringUtils.ts +0 -75
  107. package/src/utils/URLBuilderUtils.ts +0 -21
  108. package/src/utils/URLPagesFactory.ts +0 -20
  109. package/src/vite-env.d.ts +0 -1
  110. package/tsconfig.json +0 -38
  111. package/vite.config.ts +0 -42
  112. /package/{src/main.ts → dist/main.js} +0 -0
@@ -1,75 +0,0 @@
1
- export function replaceAll(str: string, find: string, replace: string): string {
2
- return str.replace(new RegExp(find, "g"), replace);
3
- }
4
-
5
- export function capitalizeFirstLetter(string: string): string {
6
- return string.charAt(0).toUpperCase() + string.slice(1);
7
- }
8
-
9
- export function formatAddress(
10
- streetName: string,
11
- streetNumber: string,
12
- cityName: string,
13
- provinceAcronym?: string
14
- ): string {
15
- const components: Array<string> = [];
16
-
17
- if (streetName && streetName !== "ND") {
18
- if (streetNumber && streetNumber !== "ND" && streetNumber !== "0")
19
- components.push(`${streetName} ${streetNumber}`);
20
- else components.push(streetName);
21
- }
22
-
23
- if (cityName && provinceAcronym) {
24
- components.push(`${cityName} (${provinceAcronym})`);
25
- } else {
26
- components.push(cityName);
27
- }
28
-
29
- const address = components
30
- .filter((component: string) => !!component)
31
- .join(", ");
32
-
33
- return capitalizeFirstLetter(address);
34
- }
35
-
36
- export function decodeTextWithEntities(strWithEntities: string | null): string {
37
- if (!strWithEntities) return "";
38
-
39
- const a = document.createElement("span");
40
- a.innerHTML = strWithEntities;
41
- return a.textContent || "";
42
- }
43
-
44
- /**
45
- * Replaces a given string with the values of the object
46
- * @param str string to replace
47
- * @param mapObj Object whose keys are the tokens to replace and whose values are the ones that will replace that matched token
48
- * e.g. replaceAllToken('Here we go', {Here: Now, go: eat}) returns 'Now we eat'
49
- * */
50
- export function replaceAllTokens(
51
- str: string,
52
- mapObj: Record<string, string>
53
- ): string {
54
- const re = new RegExp(
55
- Object.keys(mapObj)
56
- .map((key) => key.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
57
- .join("|"),
58
- "gi"
59
- );
60
- return str.replace(re, function (matched) {
61
- return mapObj[matched.toLowerCase()];
62
- });
63
- }
64
-
65
- export function cleanASCII(str: string): string {
66
- return str.replace(/[\uA78C\uA78B]/g, "'").replace(/[^\x00-\x7F]/g, "");
67
- }
68
-
69
- export const stringToHyphened = (str = ""): string => {
70
- if(!str || !str.trim())
71
- return ""
72
-
73
- str = str.trim()
74
- return str.replace(" ", "-").toLowerCase()
75
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * <p>Adds a query string to the provided URL using the params object</p>
3
- * <p>e.g. Input => URL: www.sample.com, params = {userId: 56, name: "Jonas"}</p>
4
- * Output => www.sample.com?userId=56&name=Jonas
5
- * @param url The url that will contain the query string
6
- * @param params The object that will be transformed into a query string
7
- * @return A new url instance containing the query string
8
- * */
9
- export const appendQueryString = (
10
- url: URL,
11
- params: Record<string, any> = {}
12
- ): URL => {
13
- if (Object.keys(params).length === 0)
14
- throw "The params object can't be empty";
15
-
16
- const urlWithQueryString = new URL(url);
17
- for (const key in params)
18
- urlWithQueryString.searchParams.append(key, `${params[key]}`);
19
-
20
- return urlWithQueryString;
21
- };
@@ -1,20 +0,0 @@
1
- import type { PAGES } from "@wikicasa-dev/types";
2
-
3
- declare global {
4
- interface Window {
5
- _baseURL: string;
6
- _privateURL: string;
7
- _saveSearchesURL: string;
8
- }
9
- }
10
-
11
- export const getURLPage = (page: PAGES): string => {
12
- const baseUrl = `${window["_baseURL"]}`;
13
-
14
- switch (page) {
15
- case "SAVED_SEARCHES":
16
- return `${baseUrl}/${window["_privateURL"]}/${window["_saveSearchesURL"]}`;
17
- default:
18
- throw new Error(`There is no matching URL for ${page}`);
19
- }
20
- };
package/src/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
package/tsconfig.json DELETED
@@ -1,38 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "baseUrl": "src",
5
- "outDir": "./dist",
6
- "declaration": true,
7
- "useDefineForClassFields": true,
8
- "module": "ESNext",
9
- "lib": ["ESNext", "DOM", "DOM.Iterable"],
10
- "skipLibCheck": true,
11
- "paths": {
12
- "@utils/*": ["./utils/*"],
13
- "@services/*": ["./services/*"]
14
- },
15
-
16
- "sourceMap": true,
17
- "esModuleInterop": true,
18
- "noImplicitReturns": true,
19
- "forceConsistentCasingInFileNames": true,
20
-
21
- /* Bundler mode */
22
- "moduleResolution": "Node",
23
- "allowImportingTsExtensions": true,
24
- "resolveJsonModule": true,
25
- "isolatedModules": true,
26
- "noEmit": true,
27
-
28
- /* Linting */
29
- "strict": true,
30
- "noUnusedLocals": true,
31
- "noUnusedParameters": true,
32
- "noFallthroughCasesInSwitch": true,
33
-
34
- "strictPropertyInitialization": false
35
- },
36
- "include": ["src"],
37
- "exclude": ["node_modules"]
38
- }
package/vite.config.ts DELETED
@@ -1,42 +0,0 @@
1
- // vite.config.ts
2
- import { fileURLToPath, URL } from "url";
3
- import { resolve } from "path";
4
- import { defineConfig } from "vite";
5
- import dts from "vite-plugin-dts";
6
-
7
- const getPackageName = () => {
8
- return "utilities";
9
- };
10
-
11
- const fileName = {
12
- es: `${getPackageName()}.mjs`,
13
- cjs: `${getPackageName()}.cjs`,
14
- iife: `${getPackageName()}.iife.js`,
15
- };
16
-
17
- const formats = Object.keys(fileName) as Array<keyof typeof fileName>;
18
-
19
- // https://vitejs.dev/guide/build.html#library-mode
20
- export default defineConfig({
21
- build: {
22
- lib: {
23
- entry: resolve(__dirname, "src/index.ts"),
24
- name: getPackageName(),
25
- formats,
26
- fileName: (format) => fileName[format],
27
- },
28
- },
29
- resolve: {
30
- alias: [
31
- {
32
- find: "@utils",
33
- replacement: fileURLToPath(new URL("./src/utils", import.meta.url)),
34
- },
35
- {
36
- find: "@services",
37
- replacement: fileURLToPath(new URL("./src/services", import.meta.url)),
38
- },
39
- ],
40
- },
41
- plugins: [dts()],
42
- });
File without changes