@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.
- package/dist/ArrayUtils.cjs +1 -0
- package/dist/ArrayUtils.js +4 -0
- package/dist/ColorUtils.cjs +1 -0
- package/dist/ColorUtils.js +8 -0
- package/dist/CookieUtils.cjs +1 -0
- package/dist/CookieUtils.js +32 -0
- package/dist/CurrencyUtils.cjs +1 -0
- package/dist/CurrencyUtils.js +14 -0
- package/dist/DOMUtils.cjs +1 -0
- package/dist/DOMUtils.js +18 -0
- package/dist/DateUtils.cjs +1 -0
- package/dist/DateUtils.js +7 -0
- package/dist/DeviceDetectionUtils.cjs +1 -0
- package/dist/DeviceDetectionUtils.js +8 -0
- package/dist/EmailUtils.cjs +1 -0
- package/dist/EmailUtils.js +27 -0
- package/dist/FunctionUtils.cjs +1 -0
- package/dist/FunctionUtils.js +21 -0
- package/dist/GenericUtils.cjs +1 -0
- package/dist/GenericUtils.js +25 -0
- package/dist/LazyLoadingBg.cjs +1 -0
- package/dist/LazyLoadingBg.js +13 -0
- package/dist/NumberUtils.cjs +1 -0
- package/dist/NumberUtils.js +50 -0
- package/dist/ObjectUtils.cjs +1 -0
- package/dist/ObjectUtils.js +23 -0
- package/dist/ObserverUtils.cjs +1 -0
- package/dist/ObserverUtils.js +20 -0
- package/dist/PermissionUtils.cjs +1 -0
- package/dist/PermissionUtils.js +18 -0
- package/dist/RESB_UrlBuilder.cjs +1 -0
- package/dist/RESB_UrlBuilder.js +80 -0
- package/dist/StringUtils.cjs +1 -0
- package/dist/StringUtils.js +40 -0
- package/dist/URLBuilderUtils.cjs +1 -0
- package/dist/URLBuilderUtils.js +11 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +17 -34
- package/dist/index.js +62 -0
- package/dist/main.cjs +1 -0
- package/dist/vite-env.cjs +1 -0
- package/dist/vite-env.js +1 -0
- package/package.json +17 -13
- package/dist/custom/constants.d.ts +0 -2
- package/dist/custom/icons.d.ts +0 -5
- package/dist/custom/leaflet_map.d.ts +0 -99
- package/dist/services/agencyAPI.d.ts +0 -19
- package/dist/services/geographyAPI.d.ts +0 -9
- package/dist/services/insightsAPI.d.ts +0 -2
- package/dist/services/mailAPI.d.ts +0 -24
- package/dist/services/placesAPI.d.ts +0 -5
- package/dist/services/portfolioCustomerAPI.d.ts +0 -1
- package/dist/services/publicUserAPI.d.ts +0 -20
- package/dist/services/realEstateAPI.d.ts +0 -14
- package/dist/services/requestAPI.d.ts +0 -16
- package/dist/services/servicesUtils.d.ts +0 -8
- package/dist/services/statisticsAPI.d.ts +0 -9
- package/dist/services/valuationAPI.d.ts +0 -11
- package/dist/services/wikicasaPro.d.ts +0 -2
- package/dist/utilities.cjs +0 -5
- package/dist/utilities.iife.js +0 -5
- package/dist/utilities.mjs +0 -2437
- package/dist/utils/FavoriteUtils.d.ts +0 -2
- package/dist/utils/GAutocompleteUtils.d.ts +0 -6
- package/dist/utils/MapUtils.d.ts +0 -23
- package/dist/utils/RequestUtils.d.ts +0 -2
- package/dist/utils/URLPagesFactory.d.ts +0 -9
- package/index.html +0 -13
- package/src/custom/constants.ts +0 -3
- package/src/custom/icons.ts +0 -63
- package/src/custom/leaflet_map.ts +0 -946
- package/src/index.ts +0 -171
- package/src/services/agencyAPI.ts +0 -105
- package/src/services/geographyAPI.ts +0 -129
- package/src/services/insightsAPI.ts +0 -20
- package/src/services/mailAPI.ts +0 -89
- package/src/services/placesAPI.ts +0 -72
- package/src/services/portfolioCustomerAPI.ts +0 -16
- package/src/services/publicUserAPI.ts +0 -216
- package/src/services/realEstateAPI.ts +0 -133
- package/src/services/requestAPI.ts +0 -40
- package/src/services/servicesUtils.ts +0 -27
- package/src/services/statisticsAPI.ts +0 -84
- package/src/services/valuationAPI.ts +0 -45
- package/src/services/wikicasaPro.ts +0 -25
- package/src/utils/ArrayUtils.ts +0 -2
- package/src/utils/ColorUtils.ts +0 -11
- package/src/utils/CookieUtils.ts +0 -43
- package/src/utils/CurrencyUtils.ts +0 -18
- package/src/utils/DOMUtils.ts +0 -28
- package/src/utils/DateUtils.ts +0 -9
- package/src/utils/DeviceDetectionUtils.ts +0 -17
- package/src/utils/EmailUtils.ts +0 -45
- package/src/utils/FavoriteUtils.ts +0 -19
- package/src/utils/FunctionUtils.ts +0 -29
- package/src/utils/GAutocompleteUtils.ts +0 -70
- package/src/utils/GenericUtils.ts +0 -37
- package/src/utils/LazyLoadingBg.ts +0 -18
- package/src/utils/MapUtils.ts +0 -118
- package/src/utils/NumberUtils.ts +0 -90
- package/src/utils/ObjectUtils.ts +0 -34
- package/src/utils/ObserverUtils.ts +0 -32
- package/src/utils/PermissionUtils.ts +0 -41
- package/src/utils/RESB_UrlBuilder.ts +0 -99
- package/src/utils/RequestUtils.ts +0 -20
- package/src/utils/StringUtils.ts +0 -75
- package/src/utils/URLBuilderUtils.ts +0 -21
- package/src/utils/URLPagesFactory.ts +0 -20
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -38
- package/vite.config.ts +0 -42
- /package/{src/main.ts → dist/main.js} +0 -0
package/src/utils/StringUtils.ts
DELETED
|
@@ -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
|