@equinor/cpl-top-bar-react 0.5.0 → 0.5.2
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/index.d.mts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +59 -16
- package/dist/index.mjs +66 -16
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import * as React$1 from 'react';
|
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
import * as styled_components_dist_types from 'styled-components/dist/types';
|
|
5
5
|
import * as styled_components from 'styled-components';
|
|
6
|
+
import { TopbarProps } from '@equinor/eds-core-react';
|
|
6
7
|
|
|
7
8
|
interface FeedbackLinkProps {
|
|
8
9
|
link: string;
|
|
@@ -29,7 +30,6 @@ type AppUrls = {
|
|
|
29
30
|
prod: string;
|
|
30
31
|
};
|
|
31
32
|
};
|
|
32
|
-
|
|
33
33
|
type MenuItems = MenuItem | MenuItemGroup;
|
|
34
34
|
type MenuItem = {
|
|
35
35
|
name: string;
|
|
@@ -60,7 +60,16 @@ type SideMenuProps = {
|
|
|
60
60
|
};
|
|
61
61
|
declare function SideMenu({ isOpen, onToggle, mainMenuItems, logoElement, versionInfo, currentEnvironment, titleOtherMenuItems, otherMenuItems, appUrls, linkComponent, }: SideMenuProps): react_jsx_runtime.JSX.Element;
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Gets the url by app name and current environment
|
|
65
|
+
* @param appName
|
|
66
|
+
* @param currentEnvironment needs to match a key in the appUrls
|
|
67
|
+
* @param appUrls
|
|
68
|
+
* @returns a string url
|
|
69
|
+
*/
|
|
70
|
+
declare function useAppUrlByNameAndEnvironment(appName: string | undefined, currentEnvironment: string, appUrls: AppUrls): string;
|
|
71
|
+
|
|
72
|
+
interface TopBarProps extends TopbarProps {
|
|
64
73
|
appName: string;
|
|
65
74
|
logoLink: string;
|
|
66
75
|
sideMenuOpen?: boolean;
|
|
@@ -78,7 +87,7 @@ interface TopBarProps {
|
|
|
78
87
|
* To use the Topbar component in dark mode, you need to wrap it in the `ThemeProvider` from `@equinor/cpl-theme-react`
|
|
79
88
|
* and set the theme to 'dark'.
|
|
80
89
|
*/
|
|
81
|
-
declare function TopBar({ appName, logoLink, sideMenuOpen, setSideMenuOpen, feedbackLink, documentationLink, documentationName, userMenu, logoPath, logoAlt, }: TopBarProps): react_jsx_runtime.JSX.Element;
|
|
90
|
+
declare function TopBar({ appName, logoLink, sideMenuOpen, setSideMenuOpen, feedbackLink, documentationLink, documentationName, userMenu, logoPath, logoAlt, ...edsTopBarProps }: TopBarProps): react_jsx_runtime.JSX.Element;
|
|
82
91
|
declare const StyledLink: styled_components_dist_types.IStyledComponentBase<"web", styled_components.FastOmit<React$1.DetailedHTMLProps<React$1.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, never>> & string;
|
|
83
92
|
|
|
84
93
|
interface UserMenuProps {
|
|
@@ -92,4 +101,4 @@ interface UserMenuProps {
|
|
|
92
101
|
}
|
|
93
102
|
declare function UserMenu({ user, logout, settingsLink, children }: UserMenuProps): react_jsx_runtime.JSX.Element;
|
|
94
103
|
|
|
95
|
-
export { type AppUrls, FeedbackLink, MenuHeader, SideMenu, StyledLink, TopBar, UserMenu };
|
|
104
|
+
export { type AppUrls, FeedbackLink, MenuHeader, type MenuItem, type MenuItemGroup, type MenuItems, SideMenu, StyledLink, TopBar, UserMenu, useAppUrlByNameAndEnvironment };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as React$1 from 'react';
|
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
import * as styled_components_dist_types from 'styled-components/dist/types';
|
|
5
5
|
import * as styled_components from 'styled-components';
|
|
6
|
+
import { TopbarProps } from '@equinor/eds-core-react';
|
|
6
7
|
|
|
7
8
|
interface FeedbackLinkProps {
|
|
8
9
|
link: string;
|
|
@@ -29,7 +30,6 @@ type AppUrls = {
|
|
|
29
30
|
prod: string;
|
|
30
31
|
};
|
|
31
32
|
};
|
|
32
|
-
|
|
33
33
|
type MenuItems = MenuItem | MenuItemGroup;
|
|
34
34
|
type MenuItem = {
|
|
35
35
|
name: string;
|
|
@@ -60,7 +60,16 @@ type SideMenuProps = {
|
|
|
60
60
|
};
|
|
61
61
|
declare function SideMenu({ isOpen, onToggle, mainMenuItems, logoElement, versionInfo, currentEnvironment, titleOtherMenuItems, otherMenuItems, appUrls, linkComponent, }: SideMenuProps): react_jsx_runtime.JSX.Element;
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Gets the url by app name and current environment
|
|
65
|
+
* @param appName
|
|
66
|
+
* @param currentEnvironment needs to match a key in the appUrls
|
|
67
|
+
* @param appUrls
|
|
68
|
+
* @returns a string url
|
|
69
|
+
*/
|
|
70
|
+
declare function useAppUrlByNameAndEnvironment(appName: string | undefined, currentEnvironment: string, appUrls: AppUrls): string;
|
|
71
|
+
|
|
72
|
+
interface TopBarProps extends TopbarProps {
|
|
64
73
|
appName: string;
|
|
65
74
|
logoLink: string;
|
|
66
75
|
sideMenuOpen?: boolean;
|
|
@@ -78,7 +87,7 @@ interface TopBarProps {
|
|
|
78
87
|
* To use the Topbar component in dark mode, you need to wrap it in the `ThemeProvider` from `@equinor/cpl-theme-react`
|
|
79
88
|
* and set the theme to 'dark'.
|
|
80
89
|
*/
|
|
81
|
-
declare function TopBar({ appName, logoLink, sideMenuOpen, setSideMenuOpen, feedbackLink, documentationLink, documentationName, userMenu, logoPath, logoAlt, }: TopBarProps): react_jsx_runtime.JSX.Element;
|
|
90
|
+
declare function TopBar({ appName, logoLink, sideMenuOpen, setSideMenuOpen, feedbackLink, documentationLink, documentationName, userMenu, logoPath, logoAlt, ...edsTopBarProps }: TopBarProps): react_jsx_runtime.JSX.Element;
|
|
82
91
|
declare const StyledLink: styled_components_dist_types.IStyledComponentBase<"web", styled_components.FastOmit<React$1.DetailedHTMLProps<React$1.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, never>> & string;
|
|
83
92
|
|
|
84
93
|
interface UserMenuProps {
|
|
@@ -92,4 +101,4 @@ interface UserMenuProps {
|
|
|
92
101
|
}
|
|
93
102
|
declare function UserMenu({ user, logout, settingsLink, children }: UserMenuProps): react_jsx_runtime.JSX.Element;
|
|
94
103
|
|
|
95
|
-
export { type AppUrls, FeedbackLink, MenuHeader, SideMenu, StyledLink, TopBar, UserMenu };
|
|
104
|
+
export { type AppUrls, FeedbackLink, MenuHeader, type MenuItem, type MenuItemGroup, type MenuItems, SideMenu, StyledLink, TopBar, UserMenu, useAppUrlByNameAndEnvironment };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
8
37
|
var __export = (target, all) => {
|
|
9
38
|
for (var name in all)
|
|
10
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -35,7 +64,8 @@ __export(index_exports, {
|
|
|
35
64
|
SideMenu: () => SideMenu,
|
|
36
65
|
StyledLink: () => StyledLink,
|
|
37
66
|
TopBar: () => TopBar,
|
|
38
|
-
UserMenu: () => UserMenu
|
|
67
|
+
UserMenu: () => UserMenu,
|
|
68
|
+
useAppUrlByNameAndEnvironment: () => useAppUrlByNameAndEnvironment
|
|
39
69
|
});
|
|
40
70
|
module.exports = __toCommonJS(index_exports);
|
|
41
71
|
|
|
@@ -49,20 +79,32 @@ var import_eds_icons = require("@equinor/eds-icons");
|
|
|
49
79
|
var import_eds_tokens = require("@equinor/eds-tokens");
|
|
50
80
|
var import_styled_components = __toESM(require("styled-components"));
|
|
51
81
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
-
function TopBar({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
82
|
+
function TopBar(_a) {
|
|
83
|
+
var _b = _a, {
|
|
84
|
+
appName,
|
|
85
|
+
logoLink,
|
|
86
|
+
sideMenuOpen,
|
|
87
|
+
setSideMenuOpen,
|
|
88
|
+
feedbackLink,
|
|
89
|
+
documentationLink,
|
|
90
|
+
documentationName = "Documentation",
|
|
91
|
+
userMenu,
|
|
92
|
+
logoPath = ".",
|
|
93
|
+
logoAlt = "logo"
|
|
94
|
+
} = _b, edsTopBarProps = __objRest(_b, [
|
|
95
|
+
"appName",
|
|
96
|
+
"logoLink",
|
|
97
|
+
"sideMenuOpen",
|
|
98
|
+
"setSideMenuOpen",
|
|
99
|
+
"feedbackLink",
|
|
100
|
+
"documentationLink",
|
|
101
|
+
"documentationName",
|
|
102
|
+
"userMenu",
|
|
103
|
+
"logoPath",
|
|
104
|
+
"logoAlt"
|
|
105
|
+
]);
|
|
64
106
|
const hasSideMenu = setSideMenuOpen && sideMenuOpen !== void 0;
|
|
65
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StyledEDSTopBar, { children: [
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StyledEDSTopBar, __spreadProps(__spreadValues({}, edsTopBarProps), { children: [
|
|
66
108
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_eds_core_react.TopBar.Header, { style: { padding: 0 }, children: [
|
|
67
109
|
hasSideMenu && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
110
|
import_eds_core_react.Button,
|
|
@@ -86,7 +128,7 @@ function TopBar({
|
|
|
86
128
|
] }),
|
|
87
129
|
userMenu
|
|
88
130
|
] }) })
|
|
89
|
-
] });
|
|
131
|
+
] }));
|
|
90
132
|
}
|
|
91
133
|
var StyledEDSTopBar = (0, import_styled_components.default)(import_eds_core_react.TopBar)`
|
|
92
134
|
border-color: rgba(255, 255, 255, 0.16);
|
|
@@ -642,5 +684,6 @@ var IconAndTextWrapper = (0, import_styled_components6.default)(import_eds_core_
|
|
|
642
684
|
SideMenu,
|
|
643
685
|
StyledLink,
|
|
644
686
|
TopBar,
|
|
645
|
-
UserMenu
|
|
687
|
+
UserMenu,
|
|
688
|
+
useAppUrlByNameAndEnvironment
|
|
646
689
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,27 +1,76 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
|
|
1
33
|
// src/FeedbackLink/FeedbackLink.tsx
|
|
2
34
|
import { Icon as Icon2 } from "@equinor/eds-core-react";
|
|
3
35
|
import { email } from "@equinor/eds-icons";
|
|
4
36
|
|
|
5
37
|
// src/TopBar/TopBar.tsx
|
|
6
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
Button,
|
|
40
|
+
TopBar as EDSTopBar,
|
|
41
|
+
Icon,
|
|
42
|
+
Typography
|
|
43
|
+
} from "@equinor/eds-core-react";
|
|
7
44
|
import { external_link, menu } from "@equinor/eds-icons";
|
|
8
45
|
import { tokens } from "@equinor/eds-tokens";
|
|
9
46
|
import styled from "styled-components";
|
|
10
47
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
function TopBar({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
48
|
+
function TopBar(_a) {
|
|
49
|
+
var _b = _a, {
|
|
50
|
+
appName,
|
|
51
|
+
logoLink,
|
|
52
|
+
sideMenuOpen,
|
|
53
|
+
setSideMenuOpen,
|
|
54
|
+
feedbackLink,
|
|
55
|
+
documentationLink,
|
|
56
|
+
documentationName = "Documentation",
|
|
57
|
+
userMenu,
|
|
58
|
+
logoPath = ".",
|
|
59
|
+
logoAlt = "logo"
|
|
60
|
+
} = _b, edsTopBarProps = __objRest(_b, [
|
|
61
|
+
"appName",
|
|
62
|
+
"logoLink",
|
|
63
|
+
"sideMenuOpen",
|
|
64
|
+
"setSideMenuOpen",
|
|
65
|
+
"feedbackLink",
|
|
66
|
+
"documentationLink",
|
|
67
|
+
"documentationName",
|
|
68
|
+
"userMenu",
|
|
69
|
+
"logoPath",
|
|
70
|
+
"logoAlt"
|
|
71
|
+
]);
|
|
23
72
|
const hasSideMenu = setSideMenuOpen && sideMenuOpen !== void 0;
|
|
24
|
-
return /* @__PURE__ */ jsxs(StyledEDSTopBar, { children: [
|
|
73
|
+
return /* @__PURE__ */ jsxs(StyledEDSTopBar, __spreadProps(__spreadValues({}, edsTopBarProps), { children: [
|
|
25
74
|
/* @__PURE__ */ jsxs(EDSTopBar.Header, { style: { padding: 0 }, children: [
|
|
26
75
|
hasSideMenu && /* @__PURE__ */ jsx(
|
|
27
76
|
Button,
|
|
@@ -45,7 +94,7 @@ function TopBar({
|
|
|
45
94
|
] }),
|
|
46
95
|
userMenu
|
|
47
96
|
] }) })
|
|
48
|
-
] });
|
|
97
|
+
] }));
|
|
49
98
|
}
|
|
50
99
|
var StyledEDSTopBar = styled(EDSTopBar)`
|
|
51
100
|
border-color: rgba(255, 255, 255, 0.16);
|
|
@@ -600,5 +649,6 @@ export {
|
|
|
600
649
|
SideMenu,
|
|
601
650
|
StyledLink,
|
|
602
651
|
TopBar,
|
|
603
|
-
UserMenu
|
|
652
|
+
UserMenu,
|
|
653
|
+
useAppUrlByNameAndEnvironment
|
|
604
654
|
};
|