@abcagency/hc-ui-components 1.3.29 → 1.3.31
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/components/HireControlMap.js +8 -3
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/components/modules/filter/item.js +1 -1
- package/dist/components/modules/filter/item.js.map +1 -1
- package/dist/components/modules/list/field-mapper.js +2 -2
- package/dist/components/modules/list/field-mapper.js.map +1 -1
- package/dist/components/modules/list/header-item.js +2 -1
- package/dist/components/modules/list/header-item.js.map +1 -1
- package/dist/components/modules/list/header.js +5 -1
- package/dist/components/modules/list/header.js.map +1 -1
- package/dist/components/modules/list/item-list.js +46 -19
- package/dist/components/modules/list/item-list.js.map +1 -1
- package/dist/components/modules/list/list-item/list-item.js +4 -4
- package/dist/components/modules/list/list-item/list-item.js.map +1 -1
- package/dist/components/modules/maps/info-window-content.js +1 -2
- package/dist/components/modules/maps/info-window-content.js.map +1 -1
- package/dist/contexts/mapListContext.js +2 -2
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/components/modules/list/header.d.ts +2 -1
- package/dist/types/contexts/mapListContext.d.ts +1 -0
- package/dist/types/util/urlFilterUtil.d.ts +1 -1
- package/dist/util/urlFilterUtil.js +2 -3
- package/dist/util/urlFilterUtil.js.map +1 -1
- package/package.json +1 -1
- package/src/components/HireControlMap.js +4 -1
- package/src/components/modules/filter/item.js +1 -1
- package/src/components/modules/list/field-mapper.js +4 -3
- package/src/components/modules/list/header-item.js +92 -91
- package/src/components/modules/list/header.js +51 -49
- package/src/components/modules/list/item-list.tsx +93 -59
- package/src/components/modules/list/list-item/list-item.js +130 -130
- package/src/contexts/mapListContext.tsx +4 -2
- package/src/util/urlFilterUtil.js +85 -86
|
@@ -1,86 +1,85 @@
|
|
|
1
|
-
export const updateURLWithFilters = (filters, location, query) => {
|
|
2
|
-
const searchParams = new URLSearchParams(location.search);
|
|
3
|
-
|
|
4
|
-
const filteredSearchParams = new URLSearchParams();
|
|
5
|
-
for (const [key, value] of searchParams.entries()) {
|
|
6
|
-
if (!key.includes('.') && key !== 'query') {
|
|
7
|
-
filteredSearchParams.set(key, value);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (query) {
|
|
12
|
-
filteredSearchParams.set('query', query);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
for (const category in filters) {
|
|
16
|
-
for (const filter in filters[category]) {
|
|
17
|
-
const key = `${category}.${filter}`;
|
|
18
|
-
if (filters[category][filter]) {
|
|
19
|
-
filteredSearchParams.set(key, 'true');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
queryString
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
1
|
+
export const updateURLWithFilters = (filters, location, query, handleUrlUpdate) => {
|
|
2
|
+
const searchParams = new URLSearchParams(location.search);
|
|
3
|
+
|
|
4
|
+
const filteredSearchParams = new URLSearchParams();
|
|
5
|
+
for (const [key, value] of searchParams.entries()) {
|
|
6
|
+
if (!key.includes('.') && key !== 'query') {
|
|
7
|
+
filteredSearchParams.set(key, value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (query) {
|
|
12
|
+
filteredSearchParams.set('query', query);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
for (const category in filters) {
|
|
16
|
+
for (const filter in filters[category]) {
|
|
17
|
+
const key = `${category}.${filter}`;
|
|
18
|
+
if (filters[category][filter]) {
|
|
19
|
+
filteredSearchParams.set(key, 'true');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
handleUrlUpdate(filteredSearchParams.toString());
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function notifyParentOfUrlChange() {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
var message = {
|
|
30
|
+
type: 'URL_CHANGE',
|
|
31
|
+
url: window.location.href
|
|
32
|
+
};
|
|
33
|
+
window.parent.postMessage(message, "*");
|
|
34
|
+
}, 500);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const parseQueryParams = search => {
|
|
38
|
+
const queryParams = {};
|
|
39
|
+
if (!search) return queryParams;
|
|
40
|
+
let queryString = search.split('?')[1];
|
|
41
|
+
if (!queryString) {
|
|
42
|
+
return queryParams;
|
|
43
|
+
}
|
|
44
|
+
queryString = queryString.replaceAll('+', ' ');
|
|
45
|
+
queryString.split('&').forEach(param => {
|
|
46
|
+
const [key, value] = param.split('=');
|
|
47
|
+
queryParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
48
|
+
});
|
|
49
|
+
return queryParams;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const filtersFromURL = location => {
|
|
53
|
+
if (!location || !location.search) return;
|
|
54
|
+
const filters = {};
|
|
55
|
+
let queryParam = null;
|
|
56
|
+
const queryParams = parseQueryParams(location.search);
|
|
57
|
+
if (!queryParams) return;
|
|
58
|
+
Object.keys(queryParams).forEach(key => {
|
|
59
|
+
if (key && key.includes('.')) {
|
|
60
|
+
const [category, filter] = key.split('.');
|
|
61
|
+
if (!filters[category]) {
|
|
62
|
+
filters[category] = {};
|
|
63
|
+
}
|
|
64
|
+
filters[category][filter] = queryParams[key] === 'true';
|
|
65
|
+
} else if (key === 'query') {
|
|
66
|
+
queryParam = queryParams[key];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return { filters, query: queryParam };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const hasFiltersInURL = location => {
|
|
74
|
+
if (!location || !location.search) return;
|
|
75
|
+
const queryParams = parseQueryParams(location.search);
|
|
76
|
+
if (!queryParams) return;
|
|
77
|
+
return Object.keys(queryParams).some(key => key.includes('.'));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const hasQueryInUrl = location => {
|
|
81
|
+
if (!location || !location.search) return;
|
|
82
|
+
const queryParams = parseQueryParams(location.search);
|
|
83
|
+
if (!queryParams) return;
|
|
84
|
+
return Object.keys(queryParams).includes('query');
|
|
85
|
+
};
|