@camunda/camunda-composite-components 0.0.33-rc1 → 0.0.33
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/lib/esm/components/c3-empty-state/c3-empty-state.js +2 -1
- package/lib/esm/components/c3-navigation/c3-navigation-appbar.d.ts +3 -0
- package/lib/esm/components/c3-navigation/c3-navigation-appbar.js +69 -0
- package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.js +31 -14
- package/lib/esm/components/c3-navigation/c3-navigation.js +19 -71
- package/lib/esm/components/c3-navigation/c3-navigation.types.d.ts +9 -0
- package/lib/esm/components/c3-navigation/helpers.d.ts +0 -1
- package/lib/esm/components/c3-navigation/helpers.js +0 -9
- package/lib/esm/components/c3-navigation/story-helpers.js +5 -1
- package/package.json +1 -1
|
@@ -13,4 +13,5 @@ export const C3EmptyState = ({ icon, heading, description, button, link, }) => (
|
|
|
13
13
|
React.createElement("p", { style: { maxWidth: "400px" } }, description),
|
|
14
14
|
React.createElement(Stack, { gap: 5 },
|
|
15
15
|
button && (React.createElement(Button, { id: button.id, size: "md", onClick: button.onClick, renderIcon: button.icon, disabled: button.disabled }, button.label)),
|
|
16
|
-
link && (React.createElement(
|
|
16
|
+
link && (React.createElement("div", null,
|
|
17
|
+
React.createElement(Link, { target: "_blank", href: link.href, onClick: link.onClick }, link.label)))))))));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Close } from "@carbon/react/icons";
|
|
3
|
+
import { useOnClickOutside } from "./helpers";
|
|
4
|
+
import { HeaderGlobalAction, HeaderMenuItem, HeaderSideNavItems, SideNav, SideNavItems, SideNavLink, SideNavMenu, SideNavMenuItem, } from "@carbon/react";
|
|
5
|
+
import { C3AppMenuIcon } from "../../icons/c3-icons";
|
|
6
|
+
const C3NavigationExternalLink = ({ label }) => React.createElement(React.Fragment, null, label);
|
|
7
|
+
export const C3NavigationAppBar = ({ appBar, forwardRef, navbar, }) => {
|
|
8
|
+
const [appBarOpen, setAppBarOpen] = useState(appBar.isOpen);
|
|
9
|
+
const [panelRef, iconRef] = useOnClickOutside(() => setAppBarOpen(false));
|
|
10
|
+
return (React.createElement(React.Fragment, null,
|
|
11
|
+
React.createElement(HeaderGlobalAction, { ref: iconRef, "aria-label": "App Switcher", isActive: appBarOpen, onClick: () => {
|
|
12
|
+
setAppBarOpen(!appBarOpen);
|
|
13
|
+
}, tooltipAlignment: "start" }, appBarOpen ? React.createElement(Close, { size: 20 }) : React.createElement(C3AppMenuIcon, { size: 20 })),
|
|
14
|
+
React.createElement(SideNav, { ref: panelRef, "aria-label": appBar.ariaLabel || "Side Navigation", expanded: appBarOpen, isPersistent: false, style: {
|
|
15
|
+
display: "grid",
|
|
16
|
+
gridAutoFlow: "row",
|
|
17
|
+
gridAutoRows: "max-content 1fr",
|
|
18
|
+
borderRight: appBarOpen
|
|
19
|
+
? "1px solid var(--cds-border-subtle)"
|
|
20
|
+
: undefined,
|
|
21
|
+
overflowY: "auto",
|
|
22
|
+
} },
|
|
23
|
+
React.createElement(SideNavItems, null,
|
|
24
|
+
navbar.elements.length > 0 && (React.createElement(HeaderSideNavItems, { hasDivider: true }, navbar.elements.map((element) => (React.createElement(HeaderMenuItem, { key: element.key, element: forwardRef, isCurrentPage: element.isCurrentPage, ...element.routeProps, onClick: () => {
|
|
25
|
+
if (appBar.closeOnClick !== false) {
|
|
26
|
+
setAppBarOpen(false);
|
|
27
|
+
}
|
|
28
|
+
} }, element.label))))),
|
|
29
|
+
appBar.elements &&
|
|
30
|
+
appBar.elements.map((element) => {
|
|
31
|
+
if (element.subElements && element.subElements.length > 0) {
|
|
32
|
+
return (React.createElement(SideNavMenu, { large: true, title: element.label, key: element.key }, element.subElements.map((subElement) => (React.createElement(SideNavMenuItem, { key: subElement.key, href: subElement.href, target: subElement.href ? subElement.target : undefined, onClick: () => {
|
|
33
|
+
if (subElement.onClick) {
|
|
34
|
+
subElement.onClick();
|
|
35
|
+
}
|
|
36
|
+
if (appBar.closeOnClick !== false) {
|
|
37
|
+
setAppBarOpen(false);
|
|
38
|
+
}
|
|
39
|
+
if (appBar.elementClicked) {
|
|
40
|
+
appBar.elementClicked(subElement.key);
|
|
41
|
+
}
|
|
42
|
+
} },
|
|
43
|
+
React.createElement(C3NavigationExternalLink, { label: subElement.label }))))));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return element.routeProps ? (React.createElement(SideNavLink, { element: forwardRef, key: element.key, large: true, isActive: element.active, ...element.routeProps, onClick: () => {
|
|
47
|
+
if (element.onClick) {
|
|
48
|
+
element.onClick();
|
|
49
|
+
}
|
|
50
|
+
if (appBar.closeOnClick !== false) {
|
|
51
|
+
setAppBarOpen(false);
|
|
52
|
+
}
|
|
53
|
+
if (appBar.elementClicked) {
|
|
54
|
+
appBar.elementClicked(element.key);
|
|
55
|
+
}
|
|
56
|
+
} }, element.label)) : (React.createElement(SideNavLink, { key: element.key, large: true, onClick: () => {
|
|
57
|
+
if (element.onClick) {
|
|
58
|
+
element.onClick();
|
|
59
|
+
}
|
|
60
|
+
if (appBar.closeOnClick !== false) {
|
|
61
|
+
setAppBarOpen(false);
|
|
62
|
+
}
|
|
63
|
+
if (appBar.elementClicked) {
|
|
64
|
+
appBar.elementClicked(element.key);
|
|
65
|
+
}
|
|
66
|
+
}, href: element.href, target: element.href ? element.target : undefined }, element.label));
|
|
67
|
+
}
|
|
68
|
+
})))));
|
|
69
|
+
};
|
package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.js
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
import { Button, SwitcherDivider } from "@carbon/react";
|
|
2
|
-
import React from "react";
|
|
3
|
-
const C3NavigationSidebarElement = (props) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
const C3NavigationSidebarElement = (props) => {
|
|
4
|
+
const sideBarElementRef = useRef(null);
|
|
5
|
+
const [isOverflown, setIsOverflown] = useState(false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const element = sideBarElementRef.current;
|
|
8
|
+
setIsOverflown(element ? element.offsetWidth < element.scrollWidth : false);
|
|
9
|
+
}, [JSON.stringify(props.element)]);
|
|
10
|
+
return (React.createElement(React.Fragment, null,
|
|
11
|
+
props.element.preceedingDivider && React.createElement(SwitcherDivider, null),
|
|
12
|
+
React.createElement(Button, { style: {
|
|
13
|
+
width: "16rem",
|
|
14
|
+
...(props.index === 0 &&
|
|
15
|
+
(!("elements" in props.sideBar) || !props.sideBar.elements)
|
|
16
|
+
? { marginTop: "1.5rem" }
|
|
17
|
+
: {}),
|
|
18
|
+
}, size: "sm", kind: props.element.kind ?? "ghost", className: "cds--switcher__item", onClick: () => {
|
|
19
|
+
if (props.element.onClick) {
|
|
20
|
+
props.element.onClick();
|
|
21
|
+
}
|
|
22
|
+
if (props.sideBar.closeOnClick !== false) {
|
|
23
|
+
props.setSideBarOpen(false);
|
|
24
|
+
}
|
|
25
|
+
}, tabIndex: props.itemTabIndex, renderIcon: props.element.renderIcon },
|
|
26
|
+
React.createElement("span", { ref: (el) => (sideBarElementRef.current = el), title: isOverflown ? props.element.label : "", style: {
|
|
27
|
+
overflow: "hidden",
|
|
28
|
+
textOverflow: "ellipsis",
|
|
29
|
+
whiteSpace: "nowrap",
|
|
30
|
+
width: "100%",
|
|
31
|
+
} }, props.element.label))));
|
|
32
|
+
};
|
|
16
33
|
export default C3NavigationSidebarElement;
|
|
@@ -1,82 +1,30 @@
|
|
|
1
|
-
import { Header, HeaderContainer,
|
|
2
|
-
import
|
|
3
|
-
import React, { useState } from "react";
|
|
4
|
-
import { C3AppMenuIcon } from "../../icons/c3-icons";
|
|
1
|
+
import { Header, HeaderContainer, HeaderGlobalBar, HeaderMenuItem, HeaderName, HeaderNavigation, SkipToContent, Tag, Toggletip, ToggletipButton, ToggletipContent, } from "@carbon/react";
|
|
2
|
+
import React from "react";
|
|
5
3
|
import C3InfoSidebar from "./c3-navigation-sidebar/c3-info-sidebar";
|
|
6
4
|
import { C3NotificationSidebar } from "./c3-navigation-sidebar/c3-notification-sidebar";
|
|
7
5
|
import C3OrgSidebar from "./c3-navigation-sidebar/c3-org-sidebar";
|
|
8
6
|
import C3UserSidebar from "./c3-navigation-sidebar/c3-user-sidebar";
|
|
9
|
-
import {
|
|
7
|
+
import { useMediaQuery } from "./helpers";
|
|
8
|
+
import { C3NavigationAppBar } from "./c3-navigation-appbar";
|
|
9
|
+
import styled from "styled-components";
|
|
10
|
+
/**
|
|
11
|
+
* UI SHELL
|
|
12
|
+
* Docs: https://react.carbondesignsystem.com/?path=/story/components-ui-shell--fixed-side-nav
|
|
13
|
+
*/
|
|
10
14
|
const BREAKPOINT_LG_WIDTH = "66rem"; // This is Carbon's breakpoint (lg) width https://github.com/carbon-design-system/carbon/blob/main/packages/layout/src/index.js#L56
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
display: "grid",
|
|
21
|
-
gridAutoFlow: "row",
|
|
22
|
-
gridAutoRows: "max-content 1fr",
|
|
23
|
-
borderRight: appBarOpen
|
|
24
|
-
? "1px solid var(--cds-border-subtle)"
|
|
25
|
-
: undefined,
|
|
26
|
-
overflowY: "auto",
|
|
27
|
-
} },
|
|
28
|
-
React.createElement(SideNavItems, null,
|
|
29
|
-
navbar.elements.length > 0 && (React.createElement(HeaderSideNavItems, { hasDivider: true }, navbar.elements.map((element) => (React.createElement(HeaderMenuItem, { key: element.key, element: forwardRef, isCurrentPage: element.isCurrentPage, ...element.routeProps, onClick: () => {
|
|
30
|
-
if (appBar.closeOnClick !== false) {
|
|
31
|
-
setAppBarOpen(false);
|
|
32
|
-
}
|
|
33
|
-
} }, element.label))))),
|
|
34
|
-
appBar.elements &&
|
|
35
|
-
appBar.elements.map((element) => {
|
|
36
|
-
if (element.subElements && element.subElements.length > 0) {
|
|
37
|
-
return (React.createElement(SideNavMenu, { large: true, title: element.label, key: element.key }, element.subElements.map((subElement) => (React.createElement(SideNavMenuItem, { key: subElement.key, href: subElement.href, target: subElement.href ? subElement.target : undefined, onClick: () => {
|
|
38
|
-
if (subElement.onClick) {
|
|
39
|
-
subElement.onClick();
|
|
40
|
-
}
|
|
41
|
-
if (appBar.closeOnClick !== false) {
|
|
42
|
-
setAppBarOpen(false);
|
|
43
|
-
}
|
|
44
|
-
if (appBar.elementClicked) {
|
|
45
|
-
appBar.elementClicked(subElement.key);
|
|
46
|
-
}
|
|
47
|
-
} },
|
|
48
|
-
React.createElement(C3NavigationExternalLink, { label: subElement.label }))))));
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return element.routeProps ? (React.createElement(SideNavLink, { element: forwardRef, key: element.key, large: true, isActive: element.active, ...element.routeProps, onClick: () => {
|
|
52
|
-
if (element.onClick) {
|
|
53
|
-
element.onClick();
|
|
54
|
-
}
|
|
55
|
-
if (appBar.closeOnClick !== false) {
|
|
56
|
-
setAppBarOpen(false);
|
|
57
|
-
}
|
|
58
|
-
if (appBar.elementClicked) {
|
|
59
|
-
appBar.elementClicked(element.key);
|
|
60
|
-
}
|
|
61
|
-
} }, element.label)) : (React.createElement(SideNavLink, { key: element.key, large: true, onClick: () => {
|
|
62
|
-
if (element.onClick) {
|
|
63
|
-
element.onClick();
|
|
64
|
-
}
|
|
65
|
-
if (appBar.closeOnClick !== false) {
|
|
66
|
-
setAppBarOpen(false);
|
|
67
|
-
}
|
|
68
|
-
if (appBar.elementClicked) {
|
|
69
|
-
appBar.elementClicked(element.key);
|
|
70
|
-
}
|
|
71
|
-
}, href: element.href, target: element.href ? element.target : undefined }, element.label));
|
|
72
|
-
}
|
|
73
|
-
})))));
|
|
74
|
-
};
|
|
15
|
+
const StyledToggletipContent = styled(ToggletipContent) `
|
|
16
|
+
.cds--link:visited {
|
|
17
|
+
color: var(--cds-link-text-color);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.cds--link:visited:hover {
|
|
21
|
+
color: var(--cds-link-hover-text-color);
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
75
24
|
export const C3Navigation = ({ app, appBar, forwardRef, navbar, orgSideBar, infoSideBar, userSideBar, notificationSideBar, }) => {
|
|
76
25
|
const isLargeScreen = useMediaQuery(`(min-width: ${BREAKPOINT_LG_WIDTH}`);
|
|
77
26
|
const appBarElementsLength = appBar.elements?.length ?? 0;
|
|
78
27
|
const displayAppBar = appBarElementsLength > 0 || (!isLargeScreen && navbar.elements.length > 0);
|
|
79
|
-
const inverseThemeClassName = useInverseThemeClassName();
|
|
80
28
|
return (React.createElement(HeaderContainer, { render: () => {
|
|
81
29
|
return (React.createElement(Header, { "aria-label": app.ariaLabel },
|
|
82
30
|
React.createElement(SkipToContent, null),
|
|
@@ -109,7 +57,7 @@ export const C3Navigation = ({ app, appBar, forwardRef, navbar, orgSideBar, info
|
|
|
109
57
|
marginLeft: 0,
|
|
110
58
|
cursor: "pointer",
|
|
111
59
|
} }, tag.label)),
|
|
112
|
-
React.createElement(
|
|
60
|
+
React.createElement(StyledToggletipContent, null, content))));
|
|
113
61
|
}
|
|
114
62
|
return (React.createElement(Tag, { key: tag.key, style: {
|
|
115
63
|
height: "1.5rem",
|
|
@@ -57,4 +57,13 @@ export interface C3NavigationProps {
|
|
|
57
57
|
navbar: C3NavigationNavBarProps;
|
|
58
58
|
forwardRef?: React.ForwardRefExoticComponent<any>;
|
|
59
59
|
}
|
|
60
|
+
export declare type LinkProps = {
|
|
61
|
+
element?: React.ElementType;
|
|
62
|
+
isSideNavExpanded?: boolean;
|
|
63
|
+
children: React.ReactNode;
|
|
64
|
+
className?: string;
|
|
65
|
+
isActive?: boolean;
|
|
66
|
+
large?: boolean;
|
|
67
|
+
renderIcon?: (() => React.ReactNode) | object;
|
|
68
|
+
};
|
|
60
69
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare function useOnClickOutside(handler: (e: Event) => void): ((node: unknown) => void)[];
|
|
2
2
|
export declare function executeMediaQuery(mediaQuery: string): MediaQueryList;
|
|
3
3
|
export declare function useMediaQuery(mediaQuery: string): boolean;
|
|
4
|
-
export declare function useInverseThemeClassName(): string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { usePrefix, useTheme } from "@carbon/react";
|
|
3
2
|
export function useOnClickOutside(handler) {
|
|
4
3
|
const panelRef = useRef(null);
|
|
5
4
|
const iconRef = useRef(null);
|
|
@@ -52,11 +51,3 @@ export function useMediaQuery(mediaQuery) {
|
|
|
52
51
|
}, []);
|
|
53
52
|
return isMatched;
|
|
54
53
|
}
|
|
55
|
-
export function useInverseThemeClassName() {
|
|
56
|
-
const { theme } = useTheme();
|
|
57
|
-
const prefix = usePrefix();
|
|
58
|
-
if (!["g10", "g100"].includes(theme)) {
|
|
59
|
-
return "";
|
|
60
|
-
}
|
|
61
|
-
return theme === "g10" ? `${prefix}--g100` : `${prefix}--g10`;
|
|
62
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { Link } from "@carbon/react";
|
|
2
3
|
import { ArrowRight } from "@carbon/react/icons";
|
|
3
4
|
export function createAppProps() {
|
|
4
5
|
return {
|
|
@@ -79,7 +80,10 @@ export function createNavBarBarProps(options = {}) {
|
|
|
79
80
|
label: "I am a tooltip pill",
|
|
80
81
|
color: "cool-gray",
|
|
81
82
|
tooltip: {
|
|
82
|
-
content: React.createElement("p", null,
|
|
83
|
+
content: (React.createElement("p", null,
|
|
84
|
+
"tooltip popover with a",
|
|
85
|
+
" ",
|
|
86
|
+
React.createElement(Link, { href: "http://camunda.com/" }, "link"))),
|
|
83
87
|
buttonLabel: "open the tooltip",
|
|
84
88
|
},
|
|
85
89
|
},
|