@databiosphere/findable-ui 10.1.1 → 10.2.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.
@@ -1,13 +1,8 @@
1
1
  import styled from "@emotion/styled";
2
- import { DESKTOP_SM } from "../../../../../../../../theme/common/breakpoints";
3
2
  export const HeaderActions = styled.div `
4
3
  align-items: center;
5
4
  display: flex;
6
- flex: 1;
5
+ flex: none;
7
6
  gap: 8px;
8
- justify-content: flex-end;
9
-
10
- ${({ theme }) => theme.breakpoints.up(DESKTOP_SM)} {
11
- flex: none;
12
- }
7
+ justify-content: inherit;
13
8
  `;
@@ -0,0 +1,10 @@
1
+ export interface Parameter {
2
+ [key: string]: string;
3
+ }
4
+ /**
5
+ * Replaces path parameters in the given URL string e.g. "/{portalURL}/overview" with the corresponding value.
6
+ * @param str - URL string, with parameters.
7
+ * @param parameter - Parameter.
8
+ * @returns string with parameters replaced.
9
+ */
10
+ export declare function replaceParameters(str: string, parameter: Parameter): string;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Replaces path parameters in the given URL string e.g. "/{portalURL}/overview" with the corresponding value.
3
+ * @param str - URL string, with parameters.
4
+ * @param parameter - Parameter.
5
+ * @returns string with parameters replaced.
6
+ */
7
+ export function replaceParameters(str, parameter) {
8
+ const result = Object.entries(parameter).reduce((acc, [parameterKey, parameterValue]) => {
9
+ const regex = new RegExp(`\\{${parameterKey}}`, "g");
10
+ return acc.replace(regex, parameterValue);
11
+ }, str);
12
+ if (/\{\w+}/.test(result)) {
13
+ throw new Error(`URL still contains path parameters: ${result}`);
14
+ }
15
+ return result;
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databiosphere/findable-ui",
3
- "version": "10.1.1",
3
+ "version": "10.2.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -1,14 +1,9 @@
1
1
  import styled from "@emotion/styled";
2
- import { DESKTOP_SM } from "../../../../../../../../theme/common/breakpoints";
3
2
 
4
3
  export const HeaderActions = styled.div`
5
4
  align-items: center;
6
5
  display: flex;
7
- flex: 1;
6
+ flex: none;
8
7
  gap: 8px;
9
- justify-content: flex-end;
10
-
11
- ${({ theme }) => theme.breakpoints.up(DESKTOP_SM)} {
12
- flex: none;
13
- }
8
+ justify-content: inherit;
14
9
  `;
@@ -0,0 +1,23 @@
1
+ export interface Parameter {
2
+ [key: string]: string;
3
+ }
4
+
5
+ /**
6
+ * Replaces path parameters in the given URL string e.g. "/{portalURL}/overview" with the corresponding value.
7
+ * @param str - URL string, with parameters.
8
+ * @param parameter - Parameter.
9
+ * @returns string with parameters replaced.
10
+ */
11
+ export function replaceParameters(str: string, parameter: Parameter): string {
12
+ const result = Object.entries(parameter).reduce(
13
+ (acc, [parameterKey, parameterValue]) => {
14
+ const regex = new RegExp(`\\{${parameterKey}}`, "g");
15
+ return acc.replace(regex, parameterValue);
16
+ },
17
+ str
18
+ );
19
+ if (/\{\w+}/.test(result)) {
20
+ throw new Error(`URL still contains path parameters: ${result}`);
21
+ }
22
+ return result;
23
+ }