@salesforcedevs/dx-components 0.71.0 → 0.72.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -18,13 +18,15 @@
|
|
|
18
18
|
"coveo-search-ui": "^2.10082.5",
|
|
19
19
|
"debounce": "^1.2.0",
|
|
20
20
|
"lodash.get": "^4.4.2",
|
|
21
|
+
"lodash.kebabcase": "^4.1.1",
|
|
21
22
|
"microtip": "0.2.2"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/classnames": "^2.2.10",
|
|
25
26
|
"@types/debounce": "^1.2.0",
|
|
26
27
|
"@types/lodash.get": "^4.4.6",
|
|
28
|
+
"@types/lodash.kebabcase": "^4.1.7",
|
|
27
29
|
"@types/vimeo__player": "^2.16.2"
|
|
28
30
|
},
|
|
29
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "fd347f27dc9472a9ead4f35f701b8914ba9f872e"
|
|
30
32
|
}
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
-
import qs from "query-string";
|
|
1
|
+
import qs, { ParsedQuery } from "query-string";
|
|
2
|
+
/*
|
|
3
|
+
we import this util function below to get/set the query params as hyphenated versions of their camelcase counterparts.
|
|
4
|
+
*/
|
|
5
|
+
import kebabCase from "lodash.kebabcase";
|
|
2
6
|
|
|
3
7
|
export function getUrlParamValue(key: string) {
|
|
4
|
-
const urlParams = qs.parse(window.location.search);
|
|
8
|
+
const urlParams: ParsedQuery<string> = qs.parse(window.location.search);
|
|
9
|
+
const hyphenatedKey = kebabCase(key);
|
|
5
10
|
|
|
6
|
-
|
|
11
|
+
if (hyphenatedKey in urlParams) {
|
|
12
|
+
return (urlParams[hyphenatedKey] as string)
|
|
13
|
+
.split(",")
|
|
14
|
+
.map((urlParam) => urlParam.replace("-", " "));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return [];
|
|
7
18
|
}
|
|
8
19
|
|
|
9
|
-
export function setUrlParamValue(key: string
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
export function setUrlParamValue(options: { [key: string]: string[] }) {
|
|
21
|
+
const url = new URL(window.location.href);
|
|
22
|
+
|
|
23
|
+
const newParams = {} as any;
|
|
24
|
+
const urlParams = qs.parse(window.location.search) as any;
|
|
25
|
+
|
|
26
|
+
for (const [key, value] of Object.entries(options)) {
|
|
27
|
+
if (value?.length) {
|
|
28
|
+
newParams[kebabCase(key)] = value.map((v) => kebabCase(v));
|
|
29
|
+
} else {
|
|
30
|
+
delete urlParams[kebabCase(key)];
|
|
31
|
+
}
|
|
18
32
|
}
|
|
19
|
-
|
|
33
|
+
|
|
34
|
+
url.search = qs.stringify(
|
|
35
|
+
{
|
|
36
|
+
...urlParams,
|
|
37
|
+
...newParams
|
|
38
|
+
},
|
|
39
|
+
{ arrayFormat: "comma" }
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
window.history.replaceState(null, "", url.href);
|
|
20
43
|
}
|