orcs-design-system 3.3.39 → 3.3.41
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/es/components/Divider/index.js +1 -1
- package/es/components/Icon/index.js +45 -27
- package/es/components/Popover/index.js +9 -1
- package/es/components/SideNavV2/NavItem.js +231 -0
- package/es/components/SideNavV2/SideNav.js +295 -0
- package/es/components/SideNavV2/SideNavV2.stories.js +382 -0
- package/es/components/SideNavV2/__tests__/resize.test.js +129 -0
- package/es/components/SideNavV2/__tests__/sections.test.js +333 -0
- package/es/components/SideNavV2/components/BaseSection.js +178 -0
- package/es/components/SideNavV2/components/CurrentViewSectionPortalTarget.js +35 -0
- package/es/components/SideNavV2/components/ExpandedPanel.js +161 -0
- package/es/components/SideNavV2/components/ItemSection.js +156 -0
- package/es/components/SideNavV2/components/PanelControl.js +128 -0
- package/es/components/SideNavV2/components/RenderCurrentViewSection.js +39 -0
- package/es/components/SideNavV2/components/index.js +4 -0
- package/es/components/SideNavV2/constants/sideNav.js +21 -0
- package/es/components/SideNavV2/context/SideNavStateProvider.js +57 -0
- package/es/components/SideNavV2/hooks/index.js +3 -0
- package/es/components/SideNavV2/hooks/useResize.js +70 -0
- package/es/components/SideNavV2/hooks/useResponsive.js +32 -0
- package/es/components/SideNavV2/hooks/useSideNavState.js +88 -0
- package/es/components/SideNavV2/index.js +3 -0
- package/es/components/SideNavV2/sections/SideNavCurrentViewSection.js +124 -0
- package/es/components/SideNavV2/sections/SideNavPinnedSection.js +125 -0
- package/es/components/SideNavV2/sections/SideNavTeamsSection.js +91 -0
- package/es/components/SideNavV2/styles/SideNavV2.styles.js +156 -0
- package/es/components/SideNavV2/types/sideNav.js +53 -0
- package/es/components/SideNavV2/utils/index.js +2 -0
- package/es/components/SideNavV2/utils/itemUtils.js +51 -0
- package/es/components/SideNavV2/utils/resizeUtils.js +57 -0
- package/es/components/StatusDot/StatusDot.stories.js +59 -72
- package/es/components/StatusDot/index.js +14 -5
- package/es/components.test.js +4 -0
- package/es/index.js +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { BrowserRouter } from "react-router-dom";
|
|
4
|
+
import SideNavTeamsSection from "../sections/SideNavTeamsSection";
|
|
5
|
+
import SideNavPinnedSection from "../sections/SideNavPinnedSection";
|
|
6
|
+
import RenderCurrentViewSection from "../components/RenderCurrentViewSection";
|
|
7
|
+
import { SideNavStateProvider } from "../index";
|
|
8
|
+
|
|
9
|
+
// Mock the RenderCurrentViewSection component to avoid portal issues in tests
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
jest.mock("../components/RenderCurrentViewSection", () => {
|
|
12
|
+
return function MockRenderCurrentViewSection(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
viewingState
|
|
15
|
+
} = _ref;
|
|
16
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
17
|
+
"data-testid": "render-current-view-section",
|
|
18
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
19
|
+
"data-testid": "viewing-name",
|
|
20
|
+
children: viewingState.name
|
|
21
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
22
|
+
"data-testid": "viewing-team-link",
|
|
23
|
+
children: viewingState.teamLink
|
|
24
|
+
}), viewingState.avatar && /*#__PURE__*/_jsx("div", {
|
|
25
|
+
"data-testid": "viewing-avatar",
|
|
26
|
+
children: viewingState.avatar
|
|
27
|
+
}), viewingState.shape && /*#__PURE__*/_jsx("div", {
|
|
28
|
+
"data-testid": "viewing-shape",
|
|
29
|
+
children: viewingState.shape
|
|
30
|
+
}), viewingState.subNav && /*#__PURE__*/_jsx("div", {
|
|
31
|
+
"data-testid": "viewing-subnav",
|
|
32
|
+
children: viewingState.subNav.map((item, index) => /*#__PURE__*/_jsxs("div", {
|
|
33
|
+
"data-testid": `subnav-item-${index}`,
|
|
34
|
+
children: [item.name, ": ", item.link]
|
|
35
|
+
}, index))
|
|
36
|
+
}), viewingState.badge && /*#__PURE__*/_jsx("div", {
|
|
37
|
+
"data-testid": "viewing-badge",
|
|
38
|
+
children: viewingState.badge
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Mock components that might not be available in test environment
|
|
45
|
+
jest.mock("../../Avatar", () => {
|
|
46
|
+
return function MockAvatar(_ref2) {
|
|
47
|
+
let {
|
|
48
|
+
image,
|
|
49
|
+
customSize,
|
|
50
|
+
shape
|
|
51
|
+
} = _ref2;
|
|
52
|
+
return /*#__PURE__*/_jsx("div", {
|
|
53
|
+
"data-testid": "avatar",
|
|
54
|
+
"data-image": image,
|
|
55
|
+
"data-size": customSize,
|
|
56
|
+
"data-shape": shape
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
jest.mock("../../Icon", () => {
|
|
61
|
+
return function MockIcon(_ref3) {
|
|
62
|
+
let {
|
|
63
|
+
icon,
|
|
64
|
+
color,
|
|
65
|
+
size
|
|
66
|
+
} = _ref3;
|
|
67
|
+
return /*#__PURE__*/_jsx("div", {
|
|
68
|
+
"data-testid": "icon",
|
|
69
|
+
"data-icon": icon.join(" "),
|
|
70
|
+
"data-color": color,
|
|
71
|
+
"data-size": size
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
jest.mock("../../Button", () => {
|
|
76
|
+
return function MockButton(_ref4) {
|
|
77
|
+
let {
|
|
78
|
+
children,
|
|
79
|
+
onClick,
|
|
80
|
+
...props
|
|
81
|
+
} = _ref4;
|
|
82
|
+
return /*#__PURE__*/_jsx("button", {
|
|
83
|
+
"data-testid": "button",
|
|
84
|
+
onClick: onClick,
|
|
85
|
+
...props,
|
|
86
|
+
children: children
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
jest.mock("../../Popover", () => {
|
|
91
|
+
return function MockPopover(_ref5) {
|
|
92
|
+
let {
|
|
93
|
+
children,
|
|
94
|
+
text,
|
|
95
|
+
direction,
|
|
96
|
+
width
|
|
97
|
+
} = _ref5;
|
|
98
|
+
return /*#__PURE__*/_jsx("div", {
|
|
99
|
+
"data-testid": "popover",
|
|
100
|
+
"data-text": text,
|
|
101
|
+
"data-direction": direction,
|
|
102
|
+
"data-width": width,
|
|
103
|
+
children: children
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
jest.mock("../../Divider", () => {
|
|
108
|
+
return function MockDivider(_ref6) {
|
|
109
|
+
let {
|
|
110
|
+
light,
|
|
111
|
+
display
|
|
112
|
+
} = _ref6;
|
|
113
|
+
return /*#__PURE__*/_jsx("div", {
|
|
114
|
+
"data-testid": "divider",
|
|
115
|
+
"data-light": light,
|
|
116
|
+
"data-display": JSON.stringify(display)
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
jest.mock("../../Flex", () => {
|
|
121
|
+
return function MockFlex(_ref7) {
|
|
122
|
+
let {
|
|
123
|
+
children,
|
|
124
|
+
flexDirection,
|
|
125
|
+
gap,
|
|
126
|
+
p,
|
|
127
|
+
mt,
|
|
128
|
+
...props
|
|
129
|
+
} = _ref7;
|
|
130
|
+
return /*#__PURE__*/_jsx("div", {
|
|
131
|
+
"data-testid": "flex",
|
|
132
|
+
"data-direction": flexDirection,
|
|
133
|
+
"data-gap": gap,
|
|
134
|
+
"data-p": p,
|
|
135
|
+
"data-mt": mt,
|
|
136
|
+
...props,
|
|
137
|
+
children: children
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
jest.mock("../../Typography", () => ({
|
|
142
|
+
H5: _ref8 => {
|
|
143
|
+
let {
|
|
144
|
+
children,
|
|
145
|
+
fontWeight,
|
|
146
|
+
...props
|
|
147
|
+
} = _ref8;
|
|
148
|
+
return /*#__PURE__*/_jsx("h5", {
|
|
149
|
+
"data-testid": "h5",
|
|
150
|
+
"data-font-weight": fontWeight,
|
|
151
|
+
...props,
|
|
152
|
+
children: children
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
H6: _ref9 => {
|
|
156
|
+
let {
|
|
157
|
+
children,
|
|
158
|
+
sizing,
|
|
159
|
+
color,
|
|
160
|
+
...props
|
|
161
|
+
} = _ref9;
|
|
162
|
+
return /*#__PURE__*/_jsx("h6", {
|
|
163
|
+
"data-testid": "h6",
|
|
164
|
+
"data-sizing": sizing,
|
|
165
|
+
"data-color": color,
|
|
166
|
+
...props,
|
|
167
|
+
children: children
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}));
|
|
171
|
+
const renderWithRouter = component => {
|
|
172
|
+
return render(/*#__PURE__*/_jsx(BrowserRouter, {
|
|
173
|
+
children: component
|
|
174
|
+
}));
|
|
175
|
+
};
|
|
176
|
+
describe("SideNavTeamsSection", () => {
|
|
177
|
+
const mockTeams = [{
|
|
178
|
+
avatar: "team1.jpg",
|
|
179
|
+
name: "Team Alpha",
|
|
180
|
+
link: "/teams/alpha"
|
|
181
|
+
}, {
|
|
182
|
+
avatar: "team2.jpg",
|
|
183
|
+
name: "Team Beta",
|
|
184
|
+
link: "/teams/beta"
|
|
185
|
+
}];
|
|
186
|
+
it("should render teams section when expanded", () => {
|
|
187
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavTeamsSection, {
|
|
188
|
+
teams: mockTeams,
|
|
189
|
+
isExpanded: true
|
|
190
|
+
}));
|
|
191
|
+
expect(screen.getByText("Your Teams")).toBeInTheDocument();
|
|
192
|
+
expect(screen.getByText("Team Alpha")).toBeInTheDocument();
|
|
193
|
+
expect(screen.getByText("Team Beta")).toBeInTheDocument();
|
|
194
|
+
});
|
|
195
|
+
it("should not show title when collapsed", () => {
|
|
196
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavTeamsSection, {
|
|
197
|
+
teams: mockTeams,
|
|
198
|
+
isExpanded: false
|
|
199
|
+
}));
|
|
200
|
+
expect(screen.queryByText("Your Teams")).not.toBeInTheDocument();
|
|
201
|
+
});
|
|
202
|
+
it("should render avatars for each team", () => {
|
|
203
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavTeamsSection, {
|
|
204
|
+
teams: mockTeams,
|
|
205
|
+
isExpanded: true
|
|
206
|
+
}));
|
|
207
|
+
const avatars = screen.getAllByTestId("avatar");
|
|
208
|
+
expect(avatars).toHaveLength(2);
|
|
209
|
+
expect(avatars[0]).toHaveAttribute("data-image", "team1.jpg");
|
|
210
|
+
expect(avatars[1]).toHaveAttribute("data-image", "team2.jpg");
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
describe("SideNavPinnedSection", () => {
|
|
214
|
+
const mockPinnedItems = [{
|
|
215
|
+
avatar: "user1.jpg",
|
|
216
|
+
name: "John Doe",
|
|
217
|
+
link: "/users/john",
|
|
218
|
+
shape: "circle",
|
|
219
|
+
onUnpin: jest.fn()
|
|
220
|
+
}, {
|
|
221
|
+
avatar: "user2.jpg",
|
|
222
|
+
name: "Jane Smith",
|
|
223
|
+
link: "/users/jane",
|
|
224
|
+
shape: "square",
|
|
225
|
+
onUnpin: jest.fn()
|
|
226
|
+
}];
|
|
227
|
+
it("should render pinned section when expanded", () => {
|
|
228
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavPinnedSection, {
|
|
229
|
+
items: mockPinnedItems,
|
|
230
|
+
isExpanded: true
|
|
231
|
+
}));
|
|
232
|
+
expect(screen.getByText("Pinned")).toBeInTheDocument();
|
|
233
|
+
expect(screen.getByText("John Doe")).toBeInTheDocument();
|
|
234
|
+
expect(screen.getByText("Jane Smith")).toBeInTheDocument();
|
|
235
|
+
});
|
|
236
|
+
it("should not show title when collapsed", () => {
|
|
237
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavPinnedSection, {
|
|
238
|
+
items: mockPinnedItems,
|
|
239
|
+
isExpanded: false
|
|
240
|
+
}));
|
|
241
|
+
expect(screen.queryByText("Pinned")).not.toBeInTheDocument();
|
|
242
|
+
});
|
|
243
|
+
it("should render unpin buttons when expanded", () => {
|
|
244
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavPinnedSection, {
|
|
245
|
+
items: mockPinnedItems,
|
|
246
|
+
isExpanded: true
|
|
247
|
+
}));
|
|
248
|
+
const buttons = screen.getAllByTestId("button");
|
|
249
|
+
expect(buttons).toHaveLength(2);
|
|
250
|
+
});
|
|
251
|
+
it("should render avatars with correct shapes", () => {
|
|
252
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavPinnedSection, {
|
|
253
|
+
items: mockPinnedItems,
|
|
254
|
+
isExpanded: true
|
|
255
|
+
}));
|
|
256
|
+
const avatars = screen.getAllByTestId("avatar");
|
|
257
|
+
expect(avatars[0]).toHaveAttribute("data-shape", "circle");
|
|
258
|
+
expect(avatars[1]).toHaveAttribute("data-shape", "square");
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
describe("RenderCurrentViewSection", () => {
|
|
262
|
+
const mockViewingState = {
|
|
263
|
+
name: "Test Team",
|
|
264
|
+
teamLink: "/teams/test",
|
|
265
|
+
avatar: "/avatars/test.jpg",
|
|
266
|
+
shape: "square"
|
|
267
|
+
};
|
|
268
|
+
it("should render current view section with basic data", () => {
|
|
269
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavStateProvider, {
|
|
270
|
+
children: /*#__PURE__*/_jsx(RenderCurrentViewSection, {
|
|
271
|
+
viewingState: mockViewingState
|
|
272
|
+
})
|
|
273
|
+
}));
|
|
274
|
+
expect(screen.getByTestId("render-current-view-section")).toBeInTheDocument();
|
|
275
|
+
expect(screen.getByTestId("viewing-name")).toHaveTextContent("Test Team");
|
|
276
|
+
expect(screen.getByTestId("viewing-team-link")).toHaveTextContent("/teams/test");
|
|
277
|
+
expect(screen.getByTestId("viewing-avatar")).toHaveTextContent("/avatars/test.jpg");
|
|
278
|
+
expect(screen.getByTestId("viewing-shape")).toHaveTextContent("square");
|
|
279
|
+
});
|
|
280
|
+
it("should render current view section with subNav", () => {
|
|
281
|
+
const viewingStateWithSubNav = {
|
|
282
|
+
...mockViewingState,
|
|
283
|
+
subNav: [{
|
|
284
|
+
name: "Overview",
|
|
285
|
+
link: "/teams/test/overview"
|
|
286
|
+
}, {
|
|
287
|
+
name: "Members",
|
|
288
|
+
link: "/teams/test/members"
|
|
289
|
+
}]
|
|
290
|
+
};
|
|
291
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavStateProvider, {
|
|
292
|
+
children: /*#__PURE__*/_jsx(RenderCurrentViewSection, {
|
|
293
|
+
viewingState: viewingStateWithSubNav
|
|
294
|
+
})
|
|
295
|
+
}));
|
|
296
|
+
expect(screen.getByTestId("render-current-view-section")).toBeInTheDocument();
|
|
297
|
+
expect(screen.getByTestId("viewing-subnav")).toBeInTheDocument();
|
|
298
|
+
expect(screen.getByTestId("subnav-item-0")).toHaveTextContent("Overview: /teams/test/overview");
|
|
299
|
+
expect(screen.getByTestId("subnav-item-1")).toHaveTextContent("Members: /teams/test/members");
|
|
300
|
+
});
|
|
301
|
+
it("should render current view section with badge", () => {
|
|
302
|
+
const viewingStateWithBadge = {
|
|
303
|
+
...mockViewingState,
|
|
304
|
+
badge: /*#__PURE__*/_jsx("div", {
|
|
305
|
+
"data-testid": "badge",
|
|
306
|
+
children: "Badge"
|
|
307
|
+
})
|
|
308
|
+
};
|
|
309
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavStateProvider, {
|
|
310
|
+
children: /*#__PURE__*/_jsx(RenderCurrentViewSection, {
|
|
311
|
+
viewingState: viewingStateWithBadge
|
|
312
|
+
})
|
|
313
|
+
}));
|
|
314
|
+
expect(screen.getByTestId("render-current-view-section")).toBeInTheDocument();
|
|
315
|
+
expect(screen.getByTestId("viewing-badge")).toBeInTheDocument();
|
|
316
|
+
});
|
|
317
|
+
it("should handle viewing state without avatar", () => {
|
|
318
|
+
const viewingStateWithoutAvatar = {
|
|
319
|
+
name: "Team No Avatar",
|
|
320
|
+
teamLink: "/teams/no-avatar"
|
|
321
|
+
};
|
|
322
|
+
renderWithRouter(/*#__PURE__*/_jsx(SideNavStateProvider, {
|
|
323
|
+
children: /*#__PURE__*/_jsx(RenderCurrentViewSection, {
|
|
324
|
+
viewingState: viewingStateWithoutAvatar
|
|
325
|
+
})
|
|
326
|
+
}));
|
|
327
|
+
expect(screen.getByTestId("render-current-view-section")).toBeInTheDocument();
|
|
328
|
+
expect(screen.getByTestId("viewing-name")).toHaveTextContent("Team No Avatar");
|
|
329
|
+
expect(screen.getByTestId("viewing-team-link")).toHaveTextContent("/teams/no-avatar");
|
|
330
|
+
expect(screen.queryByTestId("viewing-avatar")).not.toBeInTheDocument();
|
|
331
|
+
expect(screen.queryByTestId("viewing-shape")).not.toBeInTheDocument();
|
|
332
|
+
});
|
|
333
|
+
});
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { H6 } from "../../Typography";
|
|
5
|
+
import Avatar from "../../Avatar";
|
|
6
|
+
import { Link } from "react-router-dom";
|
|
7
|
+
import Flex from "../../Flex";
|
|
8
|
+
import themeGet from "@styled-system/theme-get";
|
|
9
|
+
import Divider from "../../Divider";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
const ItemList = styled.ul.withConfig({
|
|
12
|
+
displayName: "BaseSection__ItemList",
|
|
13
|
+
componentId: "sc-1y67u5l-0"
|
|
14
|
+
})(["list-style:none;padding:0;margin:0;align-items:", ";text-align:", ";display:flex;flex-direction:column;gap:", ";"], props => props.isExpanded ? "flex-start" : "center", props => props.isExpanded ? "left" : "center", props => themeGet("space.s")(props));
|
|
15
|
+
const ItemName = styled.span.withConfig({
|
|
16
|
+
displayName: "BaseSection__ItemName",
|
|
17
|
+
componentId: "sc-1y67u5l-1"
|
|
18
|
+
})(["margin-left:0.5rem;font-size:", ";"], props => themeGet("fontSizes.1")(props));
|
|
19
|
+
export const Item = styled.li.withConfig({
|
|
20
|
+
displayName: "BaseSection__Item",
|
|
21
|
+
componentId: "sc-1y67u5l-2"
|
|
22
|
+
})(["display:flex;width:100%;gap:", ";justify-content:space-between;align-items:center;a{display:flex;align-items:center;font-size:", ";text-decoration:none;color:", ";&:hover,&:focus{outline:none;color:", ";}}"], props => themeGet("space.xs")(props), props => themeGet("fontSizes.1")(props), props => themeGet("colors.greyDarkest")(props), props => themeGet("colors.primary")(props));
|
|
23
|
+
export const AvatarLink = _ref => {
|
|
24
|
+
let {
|
|
25
|
+
avatar,
|
|
26
|
+
name,
|
|
27
|
+
link,
|
|
28
|
+
shape = "square",
|
|
29
|
+
showName
|
|
30
|
+
} = _ref;
|
|
31
|
+
return /*#__PURE__*/_jsxs(Link, {
|
|
32
|
+
to: link,
|
|
33
|
+
"aria-label": name,
|
|
34
|
+
children: [/*#__PURE__*/_jsx(Avatar, {
|
|
35
|
+
image: avatar,
|
|
36
|
+
customSize: "30px",
|
|
37
|
+
shape: shape
|
|
38
|
+
}), showName && /*#__PURE__*/_jsx(ItemName, {
|
|
39
|
+
children: name
|
|
40
|
+
})]
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
AvatarLink.propTypes = {
|
|
44
|
+
avatar: PropTypes.string,
|
|
45
|
+
name: PropTypes.string.isRequired,
|
|
46
|
+
link: PropTypes.string.isRequired,
|
|
47
|
+
shape: PropTypes.string,
|
|
48
|
+
showName: PropTypes.bool
|
|
49
|
+
};
|
|
50
|
+
const BaseSection = _ref2 => {
|
|
51
|
+
let {
|
|
52
|
+
title,
|
|
53
|
+
items,
|
|
54
|
+
isExpanded,
|
|
55
|
+
renderItem,
|
|
56
|
+
display = ["none", "none", "none", "flex"]
|
|
57
|
+
} = _ref2;
|
|
58
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
59
|
+
children: [/*#__PURE__*/_jsx(Divider, {
|
|
60
|
+
light: true,
|
|
61
|
+
display: ["none", "none", "none", "block"]
|
|
62
|
+
}), /*#__PURE__*/_jsxs(Flex, {
|
|
63
|
+
isExpanded: isExpanded,
|
|
64
|
+
flexDirection: "column",
|
|
65
|
+
gap: "r",
|
|
66
|
+
my: isExpanded ? "s" : "0",
|
|
67
|
+
display: display,
|
|
68
|
+
children: [isExpanded && /*#__PURE__*/_jsx(H6, {
|
|
69
|
+
sizing: "small",
|
|
70
|
+
color: "greyDark",
|
|
71
|
+
children: title
|
|
72
|
+
}), /*#__PURE__*/_jsx(ItemList, {
|
|
73
|
+
isExpanded: isExpanded,
|
|
74
|
+
children: items.map(item => renderItem(item, isExpanded))
|
|
75
|
+
})]
|
|
76
|
+
})]
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
BaseSection.propTypes = {
|
|
80
|
+
title: PropTypes.string.isRequired,
|
|
81
|
+
items: PropTypes.array.isRequired,
|
|
82
|
+
isExpanded: PropTypes.bool,
|
|
83
|
+
renderItem: PropTypes.func.isRequired,
|
|
84
|
+
display: PropTypes.array
|
|
85
|
+
};
|
|
86
|
+
BaseSection.__docgenInfo = {
|
|
87
|
+
"description": "",
|
|
88
|
+
"methods": [],
|
|
89
|
+
"displayName": "BaseSection",
|
|
90
|
+
"props": {
|
|
91
|
+
"display": {
|
|
92
|
+
"defaultValue": {
|
|
93
|
+
"value": "[\"none\", \"none\", \"none\", \"flex\"]",
|
|
94
|
+
"computed": false
|
|
95
|
+
},
|
|
96
|
+
"description": "",
|
|
97
|
+
"type": {
|
|
98
|
+
"name": "array"
|
|
99
|
+
},
|
|
100
|
+
"required": false
|
|
101
|
+
},
|
|
102
|
+
"title": {
|
|
103
|
+
"description": "",
|
|
104
|
+
"type": {
|
|
105
|
+
"name": "string"
|
|
106
|
+
},
|
|
107
|
+
"required": true
|
|
108
|
+
},
|
|
109
|
+
"items": {
|
|
110
|
+
"description": "",
|
|
111
|
+
"type": {
|
|
112
|
+
"name": "array"
|
|
113
|
+
},
|
|
114
|
+
"required": true
|
|
115
|
+
},
|
|
116
|
+
"isExpanded": {
|
|
117
|
+
"description": "",
|
|
118
|
+
"type": {
|
|
119
|
+
"name": "bool"
|
|
120
|
+
},
|
|
121
|
+
"required": false
|
|
122
|
+
},
|
|
123
|
+
"renderItem": {
|
|
124
|
+
"description": "",
|
|
125
|
+
"type": {
|
|
126
|
+
"name": "func"
|
|
127
|
+
},
|
|
128
|
+
"required": true
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
export default BaseSection;
|
|
133
|
+
AvatarLink.__docgenInfo = {
|
|
134
|
+
"description": "",
|
|
135
|
+
"methods": [],
|
|
136
|
+
"displayName": "AvatarLink",
|
|
137
|
+
"props": {
|
|
138
|
+
"shape": {
|
|
139
|
+
"defaultValue": {
|
|
140
|
+
"value": "\"square\"",
|
|
141
|
+
"computed": false
|
|
142
|
+
},
|
|
143
|
+
"description": "",
|
|
144
|
+
"type": {
|
|
145
|
+
"name": "string"
|
|
146
|
+
},
|
|
147
|
+
"required": false
|
|
148
|
+
},
|
|
149
|
+
"avatar": {
|
|
150
|
+
"description": "",
|
|
151
|
+
"type": {
|
|
152
|
+
"name": "string"
|
|
153
|
+
},
|
|
154
|
+
"required": false
|
|
155
|
+
},
|
|
156
|
+
"name": {
|
|
157
|
+
"description": "",
|
|
158
|
+
"type": {
|
|
159
|
+
"name": "string"
|
|
160
|
+
},
|
|
161
|
+
"required": true
|
|
162
|
+
},
|
|
163
|
+
"link": {
|
|
164
|
+
"description": "",
|
|
165
|
+
"type": {
|
|
166
|
+
"name": "string"
|
|
167
|
+
},
|
|
168
|
+
"required": true
|
|
169
|
+
},
|
|
170
|
+
"showName": {
|
|
171
|
+
"description": "",
|
|
172
|
+
"type": {
|
|
173
|
+
"name": "bool"
|
|
174
|
+
},
|
|
175
|
+
"required": false
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { CURRENT_VIEW_SECTION_ID } from "../constants/sideNav";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const CurrentViewSectionPortalTarget = () => {
|
|
5
|
+
const containerRef = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const observer = new MutationObserver(() => {
|
|
8
|
+
const container = document.getElementById(CURRENT_VIEW_SECTION_ID);
|
|
9
|
+
if (container?.children.length > 1) {
|
|
10
|
+
throw new Error("Only one current view section can be rendered at a time");
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
if (containerRef.current) {
|
|
14
|
+
observer.observe(containerRef.current, {
|
|
15
|
+
childList: true,
|
|
16
|
+
// Watch for children being added/removed
|
|
17
|
+
subtree: false // Set to true if you want to observe all descendants too
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return () => {
|
|
21
|
+
observer.disconnect(); // Cleanup on unmount
|
|
22
|
+
};
|
|
23
|
+
}, []);
|
|
24
|
+
return /*#__PURE__*/_jsx("div", {
|
|
25
|
+
ref: containerRef,
|
|
26
|
+
id: CURRENT_VIEW_SECTION_ID
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
CurrentViewSectionPortalTarget.propTypes = {};
|
|
30
|
+
CurrentViewSectionPortalTarget.__docgenInfo = {
|
|
31
|
+
"description": "",
|
|
32
|
+
"methods": [],
|
|
33
|
+
"displayName": "CurrentViewSectionPortalTarget"
|
|
34
|
+
};
|
|
35
|
+
export default CurrentViewSectionPortalTarget;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { SideNavExpanded, ResizeHandle } from "../styles/SideNavV2.styles";
|
|
4
|
+
import PanelControlComponent from "./PanelControl";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
const ExpandedPanel = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
item,
|
|
9
|
+
expandedItem,
|
|
10
|
+
isExpanded,
|
|
11
|
+
expandedWidth,
|
|
12
|
+
sideNavHeight,
|
|
13
|
+
isSmallScreen,
|
|
14
|
+
expandedRef,
|
|
15
|
+
onResizeStart,
|
|
16
|
+
onItemClick,
|
|
17
|
+
onBlur
|
|
18
|
+
} = _ref;
|
|
19
|
+
if (item.actionType !== "component" || item.hide) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return /*#__PURE__*/_jsxs(SideNavExpanded, {
|
|
23
|
+
ref: expandedRef,
|
|
24
|
+
tabIndex: "0",
|
|
25
|
+
sideNavHeight: sideNavHeight,
|
|
26
|
+
active: expandedItem,
|
|
27
|
+
large: item.large,
|
|
28
|
+
isExpanded: isExpanded,
|
|
29
|
+
width: expandedWidth,
|
|
30
|
+
children: [/*#__PURE__*/_jsx(ResizeHandle, {
|
|
31
|
+
onMouseDown: onResizeStart
|
|
32
|
+
}), /*#__PURE__*/_jsx(PanelControlComponent, {
|
|
33
|
+
isExpanded: true,
|
|
34
|
+
onClick: () => onItemClick(item),
|
|
35
|
+
ariaLabel: "toggle panel",
|
|
36
|
+
tooltipText: "Hide panel",
|
|
37
|
+
direction: "left",
|
|
38
|
+
position: "absolute",
|
|
39
|
+
onBlur: () => onBlur(item),
|
|
40
|
+
isSmallScreen: isSmallScreen
|
|
41
|
+
}), item.component()]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
ExpandedPanel.propTypes = {
|
|
45
|
+
item: PropTypes.shape({
|
|
46
|
+
actionType: PropTypes.string.isRequired,
|
|
47
|
+
hide: PropTypes.bool,
|
|
48
|
+
large: PropTypes.bool,
|
|
49
|
+
component: PropTypes.func,
|
|
50
|
+
name: PropTypes.string.isRequired
|
|
51
|
+
}).isRequired,
|
|
52
|
+
expandedItem: PropTypes.number,
|
|
53
|
+
isExpanded: PropTypes.bool,
|
|
54
|
+
expandedWidth: PropTypes.number,
|
|
55
|
+
sideNavHeight: PropTypes.string.isRequired,
|
|
56
|
+
isSmallScreen: PropTypes.bool,
|
|
57
|
+
expandedRef: PropTypes.object,
|
|
58
|
+
onResizeStart: PropTypes.func.isRequired,
|
|
59
|
+
onItemClick: PropTypes.func.isRequired,
|
|
60
|
+
onBlur: PropTypes.func.isRequired
|
|
61
|
+
};
|
|
62
|
+
ExpandedPanel.__docgenInfo = {
|
|
63
|
+
"description": "",
|
|
64
|
+
"methods": [],
|
|
65
|
+
"displayName": "ExpandedPanel",
|
|
66
|
+
"props": {
|
|
67
|
+
"item": {
|
|
68
|
+
"description": "",
|
|
69
|
+
"type": {
|
|
70
|
+
"name": "shape",
|
|
71
|
+
"value": {
|
|
72
|
+
"actionType": {
|
|
73
|
+
"name": "string",
|
|
74
|
+
"required": true
|
|
75
|
+
},
|
|
76
|
+
"hide": {
|
|
77
|
+
"name": "bool",
|
|
78
|
+
"required": false
|
|
79
|
+
},
|
|
80
|
+
"large": {
|
|
81
|
+
"name": "bool",
|
|
82
|
+
"required": false
|
|
83
|
+
},
|
|
84
|
+
"component": {
|
|
85
|
+
"name": "func",
|
|
86
|
+
"required": false
|
|
87
|
+
},
|
|
88
|
+
"name": {
|
|
89
|
+
"name": "string",
|
|
90
|
+
"required": true
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"required": true
|
|
95
|
+
},
|
|
96
|
+
"expandedItem": {
|
|
97
|
+
"description": "",
|
|
98
|
+
"type": {
|
|
99
|
+
"name": "number"
|
|
100
|
+
},
|
|
101
|
+
"required": false
|
|
102
|
+
},
|
|
103
|
+
"isExpanded": {
|
|
104
|
+
"description": "",
|
|
105
|
+
"type": {
|
|
106
|
+
"name": "bool"
|
|
107
|
+
},
|
|
108
|
+
"required": false
|
|
109
|
+
},
|
|
110
|
+
"expandedWidth": {
|
|
111
|
+
"description": "",
|
|
112
|
+
"type": {
|
|
113
|
+
"name": "number"
|
|
114
|
+
},
|
|
115
|
+
"required": false
|
|
116
|
+
},
|
|
117
|
+
"sideNavHeight": {
|
|
118
|
+
"description": "",
|
|
119
|
+
"type": {
|
|
120
|
+
"name": "string"
|
|
121
|
+
},
|
|
122
|
+
"required": true
|
|
123
|
+
},
|
|
124
|
+
"isSmallScreen": {
|
|
125
|
+
"description": "",
|
|
126
|
+
"type": {
|
|
127
|
+
"name": "bool"
|
|
128
|
+
},
|
|
129
|
+
"required": false
|
|
130
|
+
},
|
|
131
|
+
"expandedRef": {
|
|
132
|
+
"description": "",
|
|
133
|
+
"type": {
|
|
134
|
+
"name": "object"
|
|
135
|
+
},
|
|
136
|
+
"required": false
|
|
137
|
+
},
|
|
138
|
+
"onResizeStart": {
|
|
139
|
+
"description": "",
|
|
140
|
+
"type": {
|
|
141
|
+
"name": "func"
|
|
142
|
+
},
|
|
143
|
+
"required": true
|
|
144
|
+
},
|
|
145
|
+
"onItemClick": {
|
|
146
|
+
"description": "",
|
|
147
|
+
"type": {
|
|
148
|
+
"name": "func"
|
|
149
|
+
},
|
|
150
|
+
"required": true
|
|
151
|
+
},
|
|
152
|
+
"onBlur": {
|
|
153
|
+
"description": "",
|
|
154
|
+
"type": {
|
|
155
|
+
"name": "func"
|
|
156
|
+
},
|
|
157
|
+
"required": true
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
export default ExpandedPanel;
|