@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,165 +1,76 @@
|
|
|
1
|
-
import React, { useState } from "react"
|
|
2
|
-
import { Close } from "@carbon/react/icons"
|
|
3
|
-
import { useOnClickOutside } from "./helpers"
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
SideNav as CarbonSideNav,
|
|
9
|
-
SideNavItems,
|
|
10
|
-
SideNavLink,
|
|
11
|
-
SideNavMenu,
|
|
12
|
-
SideNavMenuItem,
|
|
13
|
-
} from "@carbon/react"
|
|
14
|
-
import { C3AppMenuIcon } from "../../icons/c3-icons"
|
|
15
|
-
import styled from "styled-components"
|
|
16
|
-
const NavWrapper = styled.div`
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Close } from "@carbon/react/icons";
|
|
3
|
+
import { useOnClickOutside } from "./helpers";
|
|
4
|
+
import { HeaderGlobalAction, HeaderMenuItem, HeaderSideNavItems, SideNav as CarbonSideNav, SideNavItems, SideNavLink, SideNavMenu, SideNavMenuItem, } from "@carbon/react";
|
|
5
|
+
import { C3AppMenuIcon } from "../../icons/c3-icons";
|
|
6
|
+
import styled from "styled-components";
|
|
7
|
+
const NavWrapper = styled.div `
|
|
17
8
|
.cds--side-nav__overlay {
|
|
18
9
|
display: none;
|
|
19
10
|
}
|
|
20
|
-
|
|
21
|
-
const SideNav = styled(CarbonSideNav)`
|
|
11
|
+
`;
|
|
12
|
+
const SideNav = styled(CarbonSideNav) `
|
|
22
13
|
visibility: ${({ expanded }) => (expanded ? "visible" : "hidden")};
|
|
23
14
|
display: grid;
|
|
24
15
|
grid-auto-flow: row;
|
|
25
16
|
grid-auto-rows: max-content 1fr;
|
|
26
|
-
border-right: ${({ expanded }) =>
|
|
27
|
-
expanded ? "1px solid var(--cds-border-subtle)" : undefined};
|
|
17
|
+
border-right: ${({ expanded }) => expanded ? "1px solid var(--cds-border-subtle)" : undefined};
|
|
28
18
|
overflow-y: auto;
|
|
29
|
-
|
|
30
|
-
export const C3NavigationAppBar = ({ appBar, forwardRef, navbar }) => {
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (appBar.closeOnClick !== false) {
|
|
88
|
-
setAppBarOpen(false)
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
element.label,
|
|
93
|
-
),
|
|
94
|
-
),
|
|
95
|
-
),
|
|
96
|
-
),
|
|
97
|
-
appBar.elements &&
|
|
98
|
-
appBar.elements.map((element) => {
|
|
99
|
-
if (element.subElements && element.subElements.length > 0) {
|
|
100
|
-
return React.createElement(
|
|
101
|
-
SideNavMenu,
|
|
102
|
-
{ large: true, title: element.label, key: element.key },
|
|
103
|
-
element.subElements.map((subElement) =>
|
|
104
|
-
React.createElement(
|
|
105
|
-
SideNavMenuItem,
|
|
106
|
-
{
|
|
107
|
-
element: subElement.routeProps && forwardRef,
|
|
108
|
-
key: subElement.key,
|
|
109
|
-
href: subElement.href,
|
|
110
|
-
target: subElement.href ? subElement.target : undefined,
|
|
111
|
-
...subElement.routeProps,
|
|
112
|
-
onClick: () => {
|
|
113
|
-
if (subElement.onClick) {
|
|
114
|
-
subElement.onClick()
|
|
115
|
-
}
|
|
116
|
-
if (subElement.routeProps.onClick) {
|
|
117
|
-
subElement.routeProps.onClick()
|
|
118
|
-
}
|
|
119
|
-
if (appBar.closeOnClick !== false) {
|
|
120
|
-
setAppBarOpen(false)
|
|
121
|
-
}
|
|
122
|
-
if (appBar.elementClicked) {
|
|
123
|
-
appBar.elementClicked(subElement.key)
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
subElement.label,
|
|
128
|
-
),
|
|
129
|
-
),
|
|
130
|
-
)
|
|
131
|
-
} else {
|
|
132
|
-
return React.createElement(
|
|
133
|
-
SideNavLink,
|
|
134
|
-
{
|
|
135
|
-
element: element.routeProps && forwardRef,
|
|
136
|
-
key: element.key,
|
|
137
|
-
large: true,
|
|
138
|
-
isActive: element.active,
|
|
139
|
-
...element.routeProps,
|
|
140
|
-
onClick: () => {
|
|
141
|
-
if (element.onClick) {
|
|
142
|
-
element.onClick()
|
|
143
|
-
}
|
|
144
|
-
if (element.routeProps.onClick) {
|
|
145
|
-
element.routeProps.onClick()
|
|
146
|
-
}
|
|
147
|
-
if (appBar.closeOnClick !== false) {
|
|
148
|
-
setAppBarOpen(false)
|
|
149
|
-
}
|
|
150
|
-
if (appBar.elementClicked) {
|
|
151
|
-
appBar.elementClicked(element.key)
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
href: element.href,
|
|
155
|
-
target: element.href ? element.target : undefined,
|
|
156
|
-
},
|
|
157
|
-
element.label,
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
}),
|
|
161
|
-
),
|
|
162
|
-
),
|
|
163
|
-
),
|
|
164
|
-
)
|
|
165
|
-
}
|
|
19
|
+
`;
|
|
20
|
+
export const C3NavigationAppBar = ({ appBar, forwardRef, navbar, }) => {
|
|
21
|
+
const [appBarOpen, setAppBarOpen] = useState(appBar.isOpen);
|
|
22
|
+
const [panelRef, iconRef] = useOnClickOutside(() => setAppBarOpen(false));
|
|
23
|
+
return (React.createElement(React.Fragment, null,
|
|
24
|
+
React.createElement(HeaderGlobalAction, { ref: iconRef, "aria-label": "Camunda apps", isActive: appBarOpen, onClick: () => {
|
|
25
|
+
setAppBarOpen(!appBarOpen);
|
|
26
|
+
}, tooltipAlignment: "start",
|
|
27
|
+
/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
|
|
28
|
+
/* @ts-ignore */
|
|
29
|
+
leaveDelayMs: 100 }, appBarOpen ? React.createElement(Close, { size: 20 }) : React.createElement(C3AppMenuIcon, { size: 20 })),
|
|
30
|
+
React.createElement(NavWrapper, null,
|
|
31
|
+
React.createElement(SideNav, { ref: panelRef, "aria-label": appBar.ariaLabel || "Side Navigation", expanded: appBarOpen, isPersistent: false },
|
|
32
|
+
React.createElement(SideNavItems, null,
|
|
33
|
+
React.createElement("li", null, navbar.elements.length > 0 && (React.createElement(HeaderSideNavItems, { hasDivider: true }, navbar.elements.map((element) => (React.createElement(HeaderMenuItem, { key: element.key, element: element.routeProps && forwardRef, isActive: element.isCurrentPage, ...element.routeProps, onClick: () => {
|
|
34
|
+
if (element.routeProps.onClick) {
|
|
35
|
+
element.routeProps.onClick();
|
|
36
|
+
}
|
|
37
|
+
if (appBar.closeOnClick !== false) {
|
|
38
|
+
setAppBarOpen(false);
|
|
39
|
+
}
|
|
40
|
+
} }, element.label)))))),
|
|
41
|
+
appBar.elements &&
|
|
42
|
+
appBar.elements.map((element) => {
|
|
43
|
+
if (element.subElements && element.subElements.length > 0) {
|
|
44
|
+
return (React.createElement(SideNavMenu, { large: true, title: element.label, key: element.key }, element.subElements.map((subElement) => (React.createElement(SideNavMenuItem, { element: subElement.routeProps && forwardRef, key: subElement.key, href: subElement.href, target: subElement.href ? subElement.target : undefined, ...subElement.routeProps, onClick: () => {
|
|
45
|
+
if (subElement.onClick) {
|
|
46
|
+
subElement.onClick();
|
|
47
|
+
}
|
|
48
|
+
if (subElement.routeProps.onClick) {
|
|
49
|
+
subElement.routeProps.onClick();
|
|
50
|
+
}
|
|
51
|
+
if (appBar.closeOnClick !== false) {
|
|
52
|
+
setAppBarOpen(false);
|
|
53
|
+
}
|
|
54
|
+
if (appBar.elementClicked) {
|
|
55
|
+
appBar.elementClicked(subElement.key);
|
|
56
|
+
}
|
|
57
|
+
} }, subElement.label)))));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return (React.createElement(SideNavLink, { element: element.routeProps && forwardRef, key: element.key, large: true, isActive: element.active, ...element.routeProps, onClick: () => {
|
|
61
|
+
if (element.onClick) {
|
|
62
|
+
element.onClick();
|
|
63
|
+
}
|
|
64
|
+
if (element.routeProps.onClick) {
|
|
65
|
+
element.routeProps.onClick();
|
|
66
|
+
}
|
|
67
|
+
if (appBar.closeOnClick !== false) {
|
|
68
|
+
setAppBarOpen(false);
|
|
69
|
+
}
|
|
70
|
+
if (appBar.elementClicked) {
|
|
71
|
+
appBar.elementClicked(element.key);
|
|
72
|
+
}
|
|
73
|
+
}, href: element.href, target: element.href ? element.target : undefined }, element.label));
|
|
74
|
+
}
|
|
75
|
+
}))))));
|
|
76
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FC } from "react"
|
|
2
|
-
import { C3NavigationInfoSideBarProps } from "./c3-navigation-sidebar.types"
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { C3NavigationInfoSideBarProps } from "./c3-navigation-sidebar.types";
|
|
3
3
|
declare const C3InfoSidebar: FC<{
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export default C3InfoSidebar
|
|
4
|
+
sideBar: C3NavigationInfoSideBarProps;
|
|
5
|
+
}>;
|
|
6
|
+
export default C3InfoSidebar;
|
|
@@ -1,62 +1,39 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { SwitcherDivider } from "./components"
|
|
3
|
-
import { Help } from "@carbon/react/icons"
|
|
4
|
-
import C3NavigationSideBar from "./c3-navigation-sidebar"
|
|
5
|
-
const C3InfoSidebar = ({ sideBar }) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
React.createElement(
|
|
42
|
-
"span",
|
|
43
|
-
{
|
|
44
|
-
className: "cds--switcher__item",
|
|
45
|
-
style: {
|
|
46
|
-
paddingRight: "var(--cds-spacing-05)",
|
|
47
|
-
paddingLeft: "var(--cds-spacing-05)",
|
|
48
|
-
color: "var(--cds-text-secondary)",
|
|
49
|
-
fontSize: "var(--cds-label-01-font-size)",
|
|
50
|
-
fontWeight: "var(--cds-label-01-font-weight)",
|
|
51
|
-
lineHeight: "var(--cds-label-01-line-height)",
|
|
52
|
-
letterSpacing: "var(--cds-label-01-letter-spacing)",
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
`© Camunda Services GmbH ${new Date().getFullYear()}`,
|
|
56
|
-
React.createElement("br", null),
|
|
57
|
-
" All rights reserved.",
|
|
58
|
-
),
|
|
59
|
-
),
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
export default C3InfoSidebar
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SwitcherDivider } from "./components";
|
|
3
|
+
import { Help } from "@carbon/react/icons";
|
|
4
|
+
import C3NavigationSideBar from "./c3-navigation-sidebar";
|
|
5
|
+
const C3InfoSidebar = ({ sideBar, }) => {
|
|
6
|
+
const { version, ...sideBarProps } = sideBar;
|
|
7
|
+
if (version)
|
|
8
|
+
console.warn("The `version` prop in the info sidebar is deprecated and will be removed in a future release. Please set `version` in the `userSideBar` prop instead.");
|
|
9
|
+
return (React.createElement(C3NavigationSideBar, { sideBar: {
|
|
10
|
+
...sideBarProps,
|
|
11
|
+
ariaLabel: sideBarProps.ariaLabel || "Info Sidebar",
|
|
12
|
+
}, icon: React.createElement(Help, { size: 20 }), bottomChildren: version !== undefined && (React.createElement(React.Fragment, null,
|
|
13
|
+
React.createElement(SwitcherDivider, null),
|
|
14
|
+
React.createElement("span", { className: "cds--switcher__item", style: {
|
|
15
|
+
padding: "var(--cds-spacing-05)",
|
|
16
|
+
paddingTop: "var(--cds-spacing-03)",
|
|
17
|
+
paddingBottom: 0,
|
|
18
|
+
color: "var(--cds-text-primary)",
|
|
19
|
+
fontSize: "var(--cds-body-01-font-size)",
|
|
20
|
+
fontWeight: "var(--cds-body-01-font-weight)",
|
|
21
|
+
lineHeight: "var(--cds-body-01-line-height)",
|
|
22
|
+
letterSpacing: "var(--cds-body-01-letter-spacing)",
|
|
23
|
+
} },
|
|
24
|
+
"Version ",
|
|
25
|
+
version),
|
|
26
|
+
React.createElement("span", { className: "cds--switcher__item", style: {
|
|
27
|
+
paddingRight: "var(--cds-spacing-05)",
|
|
28
|
+
paddingLeft: "var(--cds-spacing-05)",
|
|
29
|
+
color: "var(--cds-text-secondary)",
|
|
30
|
+
fontSize: "var(--cds-label-01-font-size)",
|
|
31
|
+
fontWeight: "var(--cds-label-01-font-weight)",
|
|
32
|
+
lineHeight: "var(--cds-label-01-line-height)",
|
|
33
|
+
letterSpacing: "var(--cds-label-01-letter-spacing)",
|
|
34
|
+
} },
|
|
35
|
+
`© Camunda Services GmbH ${new Date().getFullYear()}`,
|
|
36
|
+
React.createElement("br", null),
|
|
37
|
+
" All rights reserved."))) }));
|
|
38
|
+
};
|
|
39
|
+
export default C3InfoSidebar;
|
package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { C3NavigationSideBarProps } from "./c3-navigation-sidebar.types"
|
|
1
|
+
import { C3NavigationElementProps } from "../c3-navigation.types";
|
|
2
|
+
import { C3NavigationSideBarProps } from "./c3-navigation-sidebar.types";
|
|
4
3
|
declare const C3NavigationSidebarElement: (props: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}) => JSX.Element
|
|
11
|
-
export default C3NavigationSidebarElement
|
|
4
|
+
element: C3NavigationElementProps;
|
|
5
|
+
index: number;
|
|
6
|
+
itemTabIndex?: number | undefined;
|
|
7
|
+
sideBar: C3NavigationSideBarProps;
|
|
8
|
+
setSideBarOpen: (open: boolean) => void;
|
|
9
|
+
}) => JSX.Element;
|
|
10
|
+
export default C3NavigationSidebarElement;
|
package/lib/esm/components/c3-navigation/c3-navigation-sidebar/c3-navigation-sidebar-element.js
CHANGED
|
@@ -1,57 +1,34 @@
|
|
|
1
|
-
import { Button } from "@carbon/react"
|
|
2
|
-
import React, { useEffect, useRef, useState } from "react"
|
|
3
|
-
import { SwitcherDivider } from "./components"
|
|
1
|
+
import { Button } from "@carbon/react";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { SwitcherDivider } from "./components";
|
|
4
4
|
const C3NavigationSidebarElement = (props) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
tabIndex: props.itemTabIndex,
|
|
38
|
-
renderIcon: props.element.renderIcon,
|
|
39
|
-
},
|
|
40
|
-
React.createElement(
|
|
41
|
-
"span",
|
|
42
|
-
{
|
|
43
|
-
ref: (el) => (sideBarElementRef.current = el),
|
|
44
|
-
title: isOverflown ? props.element.label : "",
|
|
45
|
-
style: {
|
|
46
|
-
overflow: "hidden",
|
|
47
|
-
textOverflow: "ellipsis",
|
|
48
|
-
whiteSpace: "nowrap",
|
|
49
|
-
width: "100%",
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
props.element.label,
|
|
53
|
-
),
|
|
54
|
-
),
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
export default C3NavigationSidebarElement
|
|
5
|
+
const sideBarElementRef = useRef(null);
|
|
6
|
+
const [isOverflown, setIsOverflown] = useState(false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const element = sideBarElementRef.current;
|
|
9
|
+
setIsOverflown(element ? element.offsetWidth < element.scrollWidth : false);
|
|
10
|
+
}, [JSON.stringify(props.element)]);
|
|
11
|
+
return (React.createElement(React.Fragment, null,
|
|
12
|
+
props.element.preceedingDivider && React.createElement(SwitcherDivider, null),
|
|
13
|
+
React.createElement(Button, { style: {
|
|
14
|
+
width: "calc(16rem - 2px)",
|
|
15
|
+
...(props.index === 0 &&
|
|
16
|
+
(!("elements" in props.sideBar) || !props.sideBar.elements)
|
|
17
|
+
? { marginTop: "1.5rem" }
|
|
18
|
+
: {}),
|
|
19
|
+
}, size: "sm", kind: props.element.kind ?? "ghost", className: "cds--switcher__item", onClick: () => {
|
|
20
|
+
if (props.element.onClick) {
|
|
21
|
+
props.element.onClick();
|
|
22
|
+
}
|
|
23
|
+
if (props.sideBar.closeOnClick !== false) {
|
|
24
|
+
props.setSideBarOpen(false);
|
|
25
|
+
}
|
|
26
|
+
}, tabIndex: props.itemTabIndex, renderIcon: props.element.renderIcon },
|
|
27
|
+
React.createElement("span", { ref: (el) => (sideBarElementRef.current = el), title: isOverflown ? props.element.label : "", style: {
|
|
28
|
+
overflow: "hidden",
|
|
29
|
+
textOverflow: "ellipsis",
|
|
30
|
+
whiteSpace: "nowrap",
|
|
31
|
+
width: "100%",
|
|
32
|
+
} }, props.element.label))));
|
|
33
|
+
};
|
|
34
|
+
export default C3NavigationSidebarElement;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from "react"
|
|
2
|
-
import { C3NavigationSideBarProps } from "./c3-navigation-sidebar.types"
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { C3NavigationSideBarProps } from "./c3-navigation-sidebar.types";
|
|
3
3
|
declare const C3NavigationSideBar: (props: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) => JSX.Element
|
|
10
|
-
export default C3NavigationSideBar
|
|
4
|
+
sideBar: C3NavigationSideBarProps;
|
|
5
|
+
icon: ReactElement;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
version?: ReactNode;
|
|
8
|
+
bottomChildren?: ReactNode;
|
|
9
|
+
}) => JSX.Element;
|
|
10
|
+
export default C3NavigationSideBar;
|