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