@camunda/camunda-composite-components 0.1.1 → 0.1.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/README.md +60 -0
- package/lib/esm/api/api.d.ts +19 -19
- package/lib/esm/api/api.js +67 -65
- package/lib/esm/api/endpoints.const.d.ts +12 -12
- package/lib/esm/api/endpoints.const.js +25 -24
- package/lib/esm/api/jwt.utils.d.ts +3 -3
- package/lib/esm/api/jwt.utils.js +21 -23
- package/lib/esm/api/notifications.d.ts +35 -64
- package/lib/esm/api/notifications.js +159 -168
- package/lib/esm/components/c3-empty-state/c3-empty-state.d.ts +2 -9
- package/lib/esm/components/c3-empty-state/c3-empty-state.js +17 -58
- package/lib/esm/components/c3-empty-state/c3-empty-state.test.d.ts +1 -0
- package/lib/esm/components/c3-empty-state/c3-empty-state.test.js +12 -0
- package/lib/esm/components/c3-empty-state/c3-empty-state.types.d.ts +19 -19
- package/lib/esm/components/c3-empty-state/c3-empty-state.types.js +1 -1
- package/lib/esm/components/c3-navigation/c3-info-button.d.ts +3 -3
- package/lib/esm/components/c3-navigation/c3-info-button.js +5 -13
- package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.js +13 -21
- package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.types.d.ts +10 -6
- package/lib/esm/components/c3-navigation/c3-navigation-actions/c3-action-buttons.types.js +1 -1
- package/lib/esm/components/c3-navigation/c3-navigation-appbar.d.ts +3 -3
- package/lib/esm/components/c3-navigation/c3-navigation-appbar.js +68 -157
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-info-sidebar.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-info-sidebar.js +39 -62
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.d.ts +9 -10
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.js +33 -56
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.d.ts +9 -9
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.js +57 -110
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.d.ts +61 -72
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.js +1 -1
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-notification-sidebar.d.ts +4 -4
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-notification-sidebar.js +88 -142
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-org-sidebar.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-org-sidebar.js +51 -105
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-sidebar-state-provider.d.ts +24 -26
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-sidebar-state-provider.js +25 -38
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-user-sidebar.d.ts +5 -5
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-user-sidebar.js +57 -146
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/components.d.ts +2 -8
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/components.js +4 -4
- package/lib/esm/components/c3-navigation/c3-navigation.d.ts +2 -14
- package/lib/esm/components/c3-navigation/c3-navigation.js +90 -214
- package/lib/esm/components/c3-navigation/c3-navigation.test.d.ts +1 -0
- package/lib/esm/components/c3-navigation/c3-navigation.test.js +80 -0
- package/lib/esm/components/c3-navigation/c3-navigation.types.d.ts +63 -70
- package/lib/esm/components/c3-navigation/c3-navigation.types.js +1 -1
- package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-container.d.ts +13 -30
- package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-container.js +70 -114
- package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-provider.d.ts +27 -29
- package/lib/esm/components/c3-navigation/c3-notification-provider/c3-notification-provider.js +90 -118
- package/lib/esm/components/c3-navigation/helpers.d.ts +3 -5
- package/lib/esm/components/c3-navigation/helpers.js +49 -53
- package/lib/esm/components/c3-navigation/index.d.ts +2 -4
- package/lib/esm/components/c3-navigation/index.js +3 -3
- package/lib/esm/components/c3-navigation/story-helpers.d.ts +18 -24
- package/lib/esm/components/c3-navigation/story-helpers.js +197 -200
- package/lib/esm/components/c3-navigation/story-templates.d.ts +8 -8
- package/lib/esm/components/c3-navigation/story-templates.js +33 -66
- package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.d.ts +16 -20
- package/lib/esm/components/c3-user-configuration/c3-user-configuration-provider.js +4 -9
- package/lib/esm/components/test-utils.d.ts +3 -0
- package/lib/esm/components/test-utils.js +22 -0
- package/lib/esm/icons/c3-icons.d.ts +5 -8
- package/lib/esm/icons/c3-icons.js +14 -82
- package/lib/esm/icons/c3-icons.types.d.ts +1 -1
- package/lib/esm/icons/c3-icons.types.js +1 -1
- package/lib/esm/index.d.ts +9 -14
- package/lib/esm/index.js +4 -4
- package/package.json +30 -20
|
@@ -1,121 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import React from "react"
|
|
9
|
-
import { useOnClickOutside } from "../helpers"
|
|
10
|
-
import C3NavigationSidebarElement from "./c3-navigation-sidebar-element"
|
|
11
|
-
import styled from "styled-components"
|
|
12
|
-
import { useSidebarState } from "./c3-sidebar-state-provider"
|
|
13
|
-
const Wrapper = styled.div`
|
|
1
|
+
import { Button, HeaderGlobalAction, HeaderPanel as CarbonHeaderPanel, Stack, SwitcherDivider, } from "@carbon/react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useOnClickOutside } from "../helpers";
|
|
4
|
+
import C3NavigationSidebarElement from "./c3-navigation-sidebar-element";
|
|
5
|
+
import styled from "styled-components";
|
|
6
|
+
import { useSidebarState } from "./c3-sidebar-state-provider";
|
|
7
|
+
const Wrapper = styled.div `
|
|
14
8
|
.cds--popover * {
|
|
15
9
|
z-index: 9000;
|
|
16
10
|
}
|
|
17
|
-
|
|
18
|
-
const HeaderPanel = styled(CarbonHeaderPanel)`
|
|
11
|
+
`;
|
|
12
|
+
const HeaderPanel = styled(CarbonHeaderPanel) `
|
|
19
13
|
visibility: ${({ expanded }) => (expanded ? "visible" : "hidden")};
|
|
20
14
|
display: grid;
|
|
21
15
|
grid-auto-flow: row;
|
|
22
16
|
grid-auto-rows: max-content 1fr;
|
|
23
17
|
overflow-y: auto;
|
|
24
18
|
overflow-x: hidden;
|
|
25
|
-
|
|
26
|
-
const BottomElements = styled.div`
|
|
19
|
+
`;
|
|
20
|
+
const BottomElements = styled.div `
|
|
27
21
|
align-self: end;
|
|
28
|
-
|
|
22
|
+
`;
|
|
29
23
|
const C3NavigationSideBar = (props) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
sideBar.customElements &&
|
|
76
|
-
"activeOrganization" in sideBar.customElements &&
|
|
77
|
-
!sideBar.customElements?.activeOrganization &&
|
|
78
|
-
React.createElement(SwitcherDivider, null),
|
|
79
|
-
sideBar.elements?.map((element, index) =>
|
|
80
|
-
React.createElement(C3NavigationSidebarElement, {
|
|
81
|
-
key: element.key,
|
|
82
|
-
element: element,
|
|
83
|
-
index: index,
|
|
84
|
-
sideBar: sideBar,
|
|
85
|
-
setSideBarOpen: setIsOpen,
|
|
86
|
-
itemTabIndex: itemTabIndex,
|
|
87
|
-
}),
|
|
88
|
-
),
|
|
89
|
-
bottomChildren,
|
|
90
|
-
),
|
|
91
|
-
version,
|
|
92
|
-
React.createElement(
|
|
93
|
-
BottomElements,
|
|
94
|
-
null,
|
|
95
|
-
sideBar.bottomElements &&
|
|
96
|
-
sideBar.bottomElements.map((element) =>
|
|
97
|
-
React.createElement(
|
|
98
|
-
Button,
|
|
99
|
-
{
|
|
100
|
-
kind: element.kind,
|
|
101
|
-
key: element.key,
|
|
102
|
-
className: "cds--switcher__item",
|
|
103
|
-
renderIcon: element.renderIcon,
|
|
104
|
-
onClick: () => {
|
|
105
|
-
if (element.onClick) {
|
|
106
|
-
element.onClick()
|
|
107
|
-
}
|
|
108
|
-
if (sideBar.closeOnClick !== false) {
|
|
109
|
-
setIsOpen(false)
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
tabIndex: itemTabIndex,
|
|
113
|
-
},
|
|
114
|
-
element.label,
|
|
115
|
-
),
|
|
116
|
-
),
|
|
117
|
-
),
|
|
118
|
-
),
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
export default C3NavigationSideBar
|
|
24
|
+
const { icon, sideBar, children, version, bottomChildren } = props;
|
|
25
|
+
const { callbacks, onOpen } = sideBar;
|
|
26
|
+
const { isOpen, setIsOpen: setOpenState } = useSidebarState()[sideBar.type];
|
|
27
|
+
const setIsOpen = (open) => {
|
|
28
|
+
if (open) {
|
|
29
|
+
callbacks?.beforeOpening?.();
|
|
30
|
+
onOpen?.();
|
|
31
|
+
}
|
|
32
|
+
setOpenState(open);
|
|
33
|
+
if (!open)
|
|
34
|
+
callbacks?.afterClosing?.();
|
|
35
|
+
};
|
|
36
|
+
const itemTabIndex = isOpen ? undefined : -1;
|
|
37
|
+
const [panelRef, iconRef] = useOnClickOutside(() => setIsOpen(false));
|
|
38
|
+
const id = `c3-${sideBar.type}-sidebar`;
|
|
39
|
+
return (React.createElement(Wrapper, null,
|
|
40
|
+
React.createElement(HeaderGlobalAction, { ref: iconRef, "aria-label": `Open ${sideBar.ariaLabel}`, "aria-expanded": isOpen, "aria-controls": id, onClick: () => {
|
|
41
|
+
setIsOpen(!isOpen);
|
|
42
|
+
}, isActive: isOpen, tooltipAlignment: sideBar.type === "user" ? "end" : "center",
|
|
43
|
+
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
|
|
44
|
+
/* @ts-ignore */
|
|
45
|
+
leaveDelayMs: 100 }, icon),
|
|
46
|
+
React.createElement(HeaderPanel, { ref: panelRef, expanded: isOpen, id: id },
|
|
47
|
+
React.createElement(Stack, null,
|
|
48
|
+
children,
|
|
49
|
+
sideBar.elements &&
|
|
50
|
+
sideBar.elements.length > 0 &&
|
|
51
|
+
"customElements" in sideBar &&
|
|
52
|
+
sideBar.customElements &&
|
|
53
|
+
"activeOrganization" in sideBar.customElements &&
|
|
54
|
+
!sideBar.customElements?.activeOrganization && React.createElement(SwitcherDivider, null),
|
|
55
|
+
sideBar.elements?.map((element, index) => (React.createElement(C3NavigationSidebarElement, { key: element.key, element: element, index: index, sideBar: sideBar, setSideBarOpen: setIsOpen, itemTabIndex: itemTabIndex }))),
|
|
56
|
+
bottomChildren),
|
|
57
|
+
version,
|
|
58
|
+
React.createElement(BottomElements, null, sideBar.bottomElements &&
|
|
59
|
+
sideBar.bottomElements.map((element) => (React.createElement(Button, { kind: element.kind, key: element.key, className: "cds--switcher__item", renderIcon: element.renderIcon, onClick: () => {
|
|
60
|
+
if (element.onClick) {
|
|
61
|
+
element.onClick();
|
|
62
|
+
}
|
|
63
|
+
if (sideBar.closeOnClick !== false) {
|
|
64
|
+
setIsOpen(false);
|
|
65
|
+
}
|
|
66
|
+
}, tabIndex: itemTabIndex }, element.label)))))));
|
|
67
|
+
};
|
|
68
|
+
export default C3NavigationSideBar;
|
package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.d.ts
CHANGED
|
@@ -1,75 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { Notification } from "../../../api/notifications"
|
|
1
|
+
import { C3NavigationElementProps } from "../c3-navigation.types";
|
|
2
|
+
import { Notification } from "../../../api/notifications";
|
|
4
3
|
export declare type C3NavigationSideBarBaseProps = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
export declare type C3NavigationOrgSideBarProps =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
C3NavigationSideBarBaseProps & {
|
|
58
|
-
type: "notifications"
|
|
59
|
-
onLinkClick?: (meta: Notification["meta"]) => void
|
|
60
|
-
}
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
isOpen?: boolean;
|
|
6
|
+
onOpen?: () => void;
|
|
7
|
+
closeOnClick?: boolean;
|
|
8
|
+
elementClicked?: (key: string) => void;
|
|
9
|
+
elements?: C3NavigationElementProps[];
|
|
10
|
+
bottomElements?: C3NavigationElementProps[];
|
|
11
|
+
};
|
|
12
|
+
export declare type C3NavigationOrgSideBarProps = C3NavigationSideBarBaseProps & {
|
|
13
|
+
type: "org";
|
|
14
|
+
customElements?: {
|
|
15
|
+
activeOrganization?: {
|
|
16
|
+
activeLabel: string;
|
|
17
|
+
otherLabel: string;
|
|
18
|
+
orgName: string;
|
|
19
|
+
action: {
|
|
20
|
+
label: string;
|
|
21
|
+
onClick: () => void;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare type C3NavigationInfoSideBarProps = C3NavigationSideBarBaseProps & {
|
|
27
|
+
type: "info";
|
|
28
|
+
version?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare type C3NavigationUserSideBarProps = C3NavigationSideBarBaseProps & {
|
|
31
|
+
type: "user";
|
|
32
|
+
version?: string;
|
|
33
|
+
customElements?: {
|
|
34
|
+
customSection?: JSX.Element;
|
|
35
|
+
profile?: {
|
|
36
|
+
label: string;
|
|
37
|
+
user: {
|
|
38
|
+
name: string;
|
|
39
|
+
email: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
themeSelector?: {
|
|
43
|
+
currentTheme: string;
|
|
44
|
+
onChange: (newValue: string) => void;
|
|
45
|
+
};
|
|
46
|
+
stageToggle?: {
|
|
47
|
+
prodFeaturesEnabled: boolean;
|
|
48
|
+
toggle: () => void;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare type C3NavigationNotificationsSideBarProps = C3NavigationSideBarBaseProps & {
|
|
53
|
+
type: "notifications";
|
|
54
|
+
onLinkClick?: (meta: Notification["meta"]) => void;
|
|
55
|
+
};
|
|
61
56
|
export declare type C3NavigationAppBarProps = C3NavigationSideBarBaseProps & {
|
|
62
|
-
|
|
63
|
-
}
|
|
57
|
+
type: "app";
|
|
58
|
+
};
|
|
64
59
|
export declare type C3NavigationSideBarProps = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
} & (
|
|
70
|
-
| C3NavigationOrgSideBarProps
|
|
71
|
-
| C3NavigationInfoSideBarProps
|
|
72
|
-
| C3NavigationUserSideBarProps
|
|
73
|
-
| C3NavigationNotificationsSideBarProps
|
|
74
|
-
| C3NavigationAppBarProps
|
|
75
|
-
)
|
|
60
|
+
callbacks?: {
|
|
61
|
+
beforeOpening?: () => void;
|
|
62
|
+
afterClosing?: () => void;
|
|
63
|
+
};
|
|
64
|
+
} & (C3NavigationOrgSideBarProps | C3NavigationInfoSideBarProps | C3NavigationUserSideBarProps | C3NavigationNotificationsSideBarProps | C3NavigationAppBarProps);
|
package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar.types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FC } from "react"
|
|
2
|
-
import { C3NavigationNotificationsSideBarProps } from "./c3-navigation-sidebar.types"
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { C3NavigationNotificationsSideBarProps } from "./c3-navigation-sidebar.types";
|
|
3
3
|
export declare const C3NotificationSidebar: FC<{
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
sideBar: C3NavigationNotificationsSideBarProps;
|
|
5
|
+
}>;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { Button } from "@carbon/react"
|
|
2
|
-
import { Notification as NotificationIcon } from "@carbon/react/icons"
|
|
3
|
-
import React, { useContext, useEffect, useRef, useState } from "react"
|
|
4
|
-
import styled from "styled-components"
|
|
5
|
-
import { C3BellIcon, C3NotificationsUnreadIcon } from "../../../icons/c3-icons"
|
|
6
|
-
import C3NotificationContainer, {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "
|
|
10
|
-
|
|
11
|
-
import C3NavigationSideBar from "./c3-navigation-sidebar"
|
|
12
|
-
import { useNotificationSidebarState } from "./c3-sidebar-state-provider"
|
|
13
|
-
const PanelHeader = styled.div`
|
|
1
|
+
import { Button } from "@carbon/react";
|
|
2
|
+
import { Notification as NotificationIcon } from "@carbon/react/icons";
|
|
3
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
4
|
+
import styled from "styled-components";
|
|
5
|
+
import { C3BellIcon, C3NotificationsUnreadIcon } from "../../../icons/c3-icons";
|
|
6
|
+
import C3NotificationContainer, { NotificationDescription, NotificationTitle, } from "../c3-notification-provider/c3-notification-container";
|
|
7
|
+
import { C3NotificationContext } from "../c3-notification-provider/c3-notification-provider";
|
|
8
|
+
import C3NavigationSideBar from "./c3-navigation-sidebar";
|
|
9
|
+
import { useNotificationSidebarState } from "./c3-sidebar-state-provider";
|
|
10
|
+
const PanelHeader = styled.div `
|
|
14
11
|
background: var(--cds-layer-01);
|
|
15
12
|
box-shadow: inset 0px -1px 0px var(--cds-border-subtle-01);
|
|
16
13
|
width: 100%;
|
|
@@ -20,146 +17,95 @@ const PanelHeader = styled.div`
|
|
|
20
17
|
flex-direction: row;
|
|
21
18
|
justify-content: space-between;
|
|
22
19
|
align-items: center;
|
|
23
|
-
|
|
24
|
-
const PanelTitle = styled.span`
|
|
20
|
+
`;
|
|
21
|
+
const PanelTitle = styled.span `
|
|
25
22
|
color: var(--cds-text-primary);
|
|
26
23
|
font-size: var(--cds-body-01-font-size);
|
|
27
24
|
font-weight: var(--cds-body-01-font-weight);
|
|
28
25
|
line-height: var(--cds-body-01-line-height);
|
|
29
26
|
letter-spacing: var(--cds-body-01-letter-spacing);
|
|
30
|
-
|
|
31
|
-
const DismissAllButton = styled(Button)`
|
|
27
|
+
`;
|
|
28
|
+
const DismissAllButton = styled(Button) `
|
|
32
29
|
font-size: var(--cds-helper-text-01-font-size);
|
|
33
30
|
font-weight: var(--cds-helper-text-01-font-weight);
|
|
34
31
|
line-height: var(--cds-helper-text-01-line-height);
|
|
35
32
|
letter-spacing: var(--cds-helper-text-01-letter-spacing);
|
|
36
|
-
|
|
37
|
-
const EmptyState = styled.div`
|
|
33
|
+
`;
|
|
34
|
+
const EmptyState = styled.div `
|
|
38
35
|
padding: 16px;
|
|
39
|
-
|
|
40
|
-
const EmptyStateTitle = styled(NotificationTitle)`
|
|
36
|
+
`;
|
|
37
|
+
const EmptyStateTitle = styled(NotificationTitle) `
|
|
41
38
|
margin-top: 24px;
|
|
42
|
-
|
|
43
|
-
const EmptyStateDescription = styled(NotificationDescription)`
|
|
39
|
+
`;
|
|
40
|
+
const EmptyStateDescription = styled(NotificationDescription) `
|
|
44
41
|
color: var(--cds-text-secondary);
|
|
45
42
|
margin-top: 8px;
|
|
46
|
-
|
|
43
|
+
`;
|
|
47
44
|
export const C3NotificationSidebar = ({ sideBar }) => {
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
PanelHeader,
|
|
116
|
-
null,
|
|
117
|
-
React.createElement(PanelTitle, null, "Notifications"),
|
|
118
|
-
notifications.length > 0 &&
|
|
119
|
-
// eslint-disable-next-line
|
|
120
|
-
// @ts-ignore
|
|
121
|
-
React.createElement(
|
|
122
|
-
DismissAllButton,
|
|
123
|
-
{ kind: "ghost", size: "sm", onClick: dismissAllSidebar },
|
|
124
|
-
"Dismiss all",
|
|
125
|
-
),
|
|
126
|
-
),
|
|
127
|
-
notifications.length > 0
|
|
128
|
-
? notifications.sort(sortNotificationsDescending).map((notification) =>
|
|
129
|
-
React.createElement(C3NotificationContainer, {
|
|
130
|
-
key: notification.uuid,
|
|
131
|
-
onRead: () => {
|
|
132
|
-
if (notification.state === "new") {
|
|
133
|
-
markAsRead(notification)
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
onDismiss: () => dismiss(notification),
|
|
137
|
-
originalOnLinkClick: onLinkClick,
|
|
138
|
-
onLinkClick: () => {
|
|
139
|
-
if (enabled && analytics) {
|
|
140
|
-
analytics(
|
|
141
|
-
"notification-clicked-cta",
|
|
142
|
-
notification.meta?.identifier,
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
if (onLinkClick) {
|
|
146
|
-
onLinkClick(notification.meta)
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
unread: unreadNotifications.some((id) => id === notification.uuid),
|
|
150
|
-
...notification,
|
|
151
|
-
}),
|
|
152
|
-
)
|
|
153
|
-
: React.createElement(
|
|
154
|
-
EmptyState,
|
|
155
|
-
null,
|
|
156
|
-
React.createElement(C3BellIcon, { size: 56 }),
|
|
157
|
-
React.createElement(EmptyStateTitle, null, "No notifications"),
|
|
158
|
-
React.createElement(
|
|
159
|
-
EmptyStateDescription,
|
|
160
|
-
null,
|
|
161
|
-
"New updates regarding your processes, clusters and more will appear here.",
|
|
162
|
-
),
|
|
163
|
-
),
|
|
164
|
-
)
|
|
165
|
-
}
|
|
45
|
+
const { onLinkClick } = sideBar;
|
|
46
|
+
const { notifications, markAsRead, dismiss, markAllAsRead, dismissAll, analytics, enabled, } = useContext(C3NotificationContext);
|
|
47
|
+
const [unreadNotifications, setUnreadNotifications] = useState([]);
|
|
48
|
+
const hasUnreadNotifications = notifications.some(({ state }) => state === "new");
|
|
49
|
+
const { isOpen } = useNotificationSidebarState();
|
|
50
|
+
const notificationsRef = useRef();
|
|
51
|
+
notificationsRef.current = notifications;
|
|
52
|
+
const markAllAsReadSidebar = () => {
|
|
53
|
+
const newNotifications = notificationsRef.current?.filter((notification) => notification.state === "new");
|
|
54
|
+
if (newNotifications)
|
|
55
|
+
markAllAsRead(newNotifications);
|
|
56
|
+
};
|
|
57
|
+
const dismissAllSidebar = () => dismissAll(notifications);
|
|
58
|
+
const beforeOpening = () => {
|
|
59
|
+
// remember new notifications, so the dots can be displayed
|
|
60
|
+
if (notificationsRef.current)
|
|
61
|
+
setUnreadNotifications(notificationsRef.current
|
|
62
|
+
.filter(({ state }) => state === "new")
|
|
63
|
+
.map(({ uuid }) => uuid));
|
|
64
|
+
markAllAsReadSidebar();
|
|
65
|
+
if (enabled && analytics) {
|
|
66
|
+
analytics("notification-panel-opened");
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const afterClosing = () => {
|
|
70
|
+
markAllAsReadSidebar();
|
|
71
|
+
setUnreadNotifications([]);
|
|
72
|
+
};
|
|
73
|
+
const sortNotificationsDescending = (a, b) => {
|
|
74
|
+
if (new Date(a.timestamp) > new Date(b.timestamp))
|
|
75
|
+
return -1;
|
|
76
|
+
return 0;
|
|
77
|
+
};
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
// mark notifications as read on unmount
|
|
80
|
+
return () => {
|
|
81
|
+
if (isOpen)
|
|
82
|
+
markAllAsReadSidebar();
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
return (React.createElement(C3NavigationSideBar, { sideBar: {
|
|
86
|
+
...sideBar,
|
|
87
|
+
ariaLabel: sideBar.ariaLabel || "Notification Sidebar",
|
|
88
|
+
callbacks: { beforeOpening, afterClosing },
|
|
89
|
+
}, icon: hasUnreadNotifications ? (React.createElement(C3NotificationsUnreadIcon, { size: 20 })) : (React.createElement(NotificationIcon, { size: 20, label: "Notifications" })) },
|
|
90
|
+
React.createElement(PanelHeader, null,
|
|
91
|
+
React.createElement(PanelTitle, null, "Notifications"),
|
|
92
|
+
notifications.length > 0 && (
|
|
93
|
+
// eslint-disable-next-line
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
React.createElement(DismissAllButton, { kind: "ghost", size: "sm", onClick: dismissAllSidebar }, "Dismiss all"))),
|
|
96
|
+
notifications.length > 0 ? (notifications.sort(sortNotificationsDescending).map((notification) => (React.createElement(C3NotificationContainer, { key: notification.uuid, onRead: () => {
|
|
97
|
+
if (notification.state === "new") {
|
|
98
|
+
markAsRead(notification);
|
|
99
|
+
}
|
|
100
|
+
}, onDismiss: () => dismiss(notification), originalOnLinkClick: onLinkClick, onLinkClick: () => {
|
|
101
|
+
if (enabled && analytics) {
|
|
102
|
+
analytics("notification-clicked-cta", notification.meta?.identifier);
|
|
103
|
+
}
|
|
104
|
+
if (onLinkClick) {
|
|
105
|
+
onLinkClick(notification.meta);
|
|
106
|
+
}
|
|
107
|
+
}, unread: unreadNotifications.some((id) => id === notification.uuid), ...notification })))) : (React.createElement(EmptyState, null,
|
|
108
|
+
React.createElement(C3BellIcon, { size: 56 }),
|
|
109
|
+
React.createElement(EmptyStateTitle, null, "No notifications"),
|
|
110
|
+
React.createElement(EmptyStateDescription, null, "New updates regarding your processes, clusters and more will appear here.")))));
|
|
111
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC } from "react"
|
|
2
|
-
import { C3NavigationOrgSideBarProps } from "./c3-navigation-sidebar.types"
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { C3NavigationOrgSideBarProps } from "./c3-navigation-sidebar.types";
|
|
3
3
|
declare const C3OrgSidebar: FC<{
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export default C3OrgSidebar
|
|
4
|
+
sideBar: C3NavigationOrgSideBarProps;
|
|
5
|
+
}>;
|
|
6
|
+
export default C3OrgSidebar;
|