@pingux/astro 1.36.3-alpha.1 → 1.37.0-alpha.0

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.
@@ -16,7 +16,9 @@ _Object$defineProperty(exports, "__esModule", {
16
16
 
17
17
  exports["default"] = void 0;
18
18
 
19
- var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
19
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
20
+
21
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
20
22
 
21
23
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
22
24
 
@@ -103,18 +105,24 @@ var SectionItem = function SectionItem(_ref2) {
103
105
  var navBarState = (0, _NavBarContext.useNavBarContext)();
104
106
  var expandedKeys = navBarState.expandedKeys,
105
107
  setExpandedKeys = navBarState.setExpandedKeys;
106
- var isExpanded = expandedKeys === null || expandedKeys === void 0 ? void 0 : expandedKeys.has(key);
108
+ var isExpanded = (0, _includes["default"])(expandedKeys).call(expandedKeys, key);
107
109
  var firstChildKey = children.length ? children[0].key : null;
108
110
  var lastChildKey = children.length ? children[children.length - 1].key : null;
109
111
 
110
112
  var onExpandedChange = function onExpandedChange(isOpen) {
113
+ var newArray;
114
+
111
115
  if (isOpen) {
112
- expandedKeys.add(key);
116
+ var _context;
117
+
118
+ newArray = (0, _concat["default"])(_context = []).call(_context, expandedKeys, [key]);
113
119
  } else {
114
- expandedKeys["delete"](key);
120
+ newArray = (0, _filter["default"])(expandedKeys).call(expandedKeys, function (thiskey) {
121
+ return thiskey !== key;
122
+ });
115
123
  }
116
124
 
117
- setExpandedKeys(new _set["default"](expandedKeys));
125
+ setExpandedKeys(newArray);
118
126
  };
119
127
 
120
128
  var focusManager = (0, _focus.useFocusManager)();
@@ -49,11 +49,11 @@ var _default = {
49
49
  exports["default"] = _default;
50
50
 
51
51
  var SideNav = function SideNav(_ref) {
52
- var setSelectedKeys = _ref.setSelectedKeys,
53
- selectedKeys = _ref.selectedKeys;
52
+ var setSelectedKey = _ref.setSelectedKey,
53
+ selectedKey = _ref.selectedKey;
54
54
  return (0, _react2.jsx)(_index.NavBar, {
55
- setSelectedKeys: setSelectedKeys,
56
- selectedKeys: selectedKeys
55
+ setSelectedKey: setSelectedKey,
56
+ selectedKey: selectedKey
57
57
  }, (0, _react2.jsx)(_index.Box, {
58
58
  padding: "md"
59
59
  }, (0, _react2.jsx)(_index.Link, {
@@ -86,15 +86,15 @@ var SideNav = function SideNav(_ref) {
86
86
  var Default = function Default() {
87
87
  var _useState = (0, _react.useState)('Overview'),
88
88
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
89
- selectedKeys = _useState2[0],
90
- setSelectedKeys = _useState2[1];
89
+ selectedKey = _useState2[0],
90
+ setSelectedKey = _useState2[1];
91
91
 
92
92
  return (0, _react2.jsx)(_index.Box, {
93
93
  bg: "accent.99",
94
94
  height: "100vh"
95
95
  }, (0, _react2.jsx)(SideNav, {
96
- setSelectedKeys: setSelectedKeys,
97
- selectedKeys: selectedKeys
96
+ setSelectedKey: setSelectedKey,
97
+ selectedKey: selectedKey
98
98
  }), (0, _react2.jsx)(_HeaderBar["default"], null), (0, _react2.jsx)(_index.Box, {
99
99
  ml: 255,
100
100
  mt: 25
@@ -104,7 +104,7 @@ var Default = function Default() {
104
104
  sx: {
105
105
  fontWeight: 3
106
106
  }
107
- }, selectedKeys)));
107
+ }, selectedKey)));
108
108
  };
109
109
 
110
110
  exports.Default = Default;
@@ -1,6 +1,5 @@
1
1
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
2
2
  import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
3
- import _Set from "@babel/runtime-corejs3/core-js-stable/set";
4
3
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
5
4
  import React, { useMemo, useState } from 'react';
6
5
  import PropTypes from 'prop-types';
@@ -23,21 +22,21 @@ import useProgressiveState from '../../hooks/useProgressiveState';
23
22
  import { jsx as ___EmotionJSX } from "@emotion/react";
24
23
 
25
24
  var NavBar = function NavBar(props) {
26
- var defaultSelectedKeys = props.defaultSelectedKeys,
27
- selectedKeysProp = props.selectedKeys,
28
- setSelectedKeysProp = props.setSelectedKeys,
25
+ var defaultSelectedKey = props.defaultSelectedKey,
26
+ selectedKeyProp = props.selectedKey,
27
+ setSelectedKeyProp = props.setSelectedKey,
29
28
  defaultExpandedKeys = props.defaultExpandedKeys,
30
29
  children = props.children;
31
30
 
32
- var _useState = useState(new _Set(defaultExpandedKeys)),
31
+ var _useState = useState(defaultExpandedKeys),
33
32
  _useState2 = _slicedToArray(_useState, 2),
34
33
  expandedKeys = _useState2[0],
35
34
  setExpandedKeys = _useState2[1];
36
35
 
37
- var _useProgressiveState = useProgressiveState(selectedKeysProp, defaultSelectedKeys),
36
+ var _useProgressiveState = useProgressiveState(selectedKeyProp, defaultSelectedKey),
38
37
  _useProgressiveState2 = _slicedToArray(_useProgressiveState, 2),
39
- selectedKeys = _useProgressiveState2[0],
40
- setSelectedKeys = _useProgressiveState2[1];
38
+ selectedKey = _useProgressiveState2[0],
39
+ setSelectedKey = _useProgressiveState2[1];
41
40
 
42
41
  var items = useMemo(function () {
43
42
  return _Array$isArray(children) ? _mapInstanceProperty(children).call(children, function (child) {
@@ -49,14 +48,15 @@ var NavBar = function NavBar(props) {
49
48
  item: children,
50
49
  key: uuid()
51
50
  }];
52
- }, [children]);
51
+ }, []);
52
+ var contextValue = {
53
+ selectedKey: selectedKey,
54
+ setSelectedKey: setSelectedKeyProp || setSelectedKey,
55
+ expandedKeys: expandedKeys,
56
+ setExpandedKeys: setExpandedKeys
57
+ };
53
58
  return ___EmotionJSX(NavBarContext.Provider, {
54
- value: {
55
- selectedKey: selectedKeys,
56
- setSelectedKey: setSelectedKeysProp || setSelectedKeys,
57
- expandedKeys: expandedKeys,
58
- setExpandedKeys: setExpandedKeys
59
- }
59
+ value: contextValue
60
60
  }, ___EmotionJSX(Box, {
61
61
  variant: "navBar.container",
62
62
  role: "navigation",
@@ -102,14 +102,23 @@ var FocusableItem = function FocusableItem(props) {
102
102
 
103
103
  NavBar.propTypes = {
104
104
  /** The initial selected key in the collection (uncontrolled). */
105
- defaultSelectedKeys: isIterableProp,
105
+ defaultSelectedKey: PropTypes.string,
106
106
 
107
107
  /** The initial expanded keys in the collection (uncontrolled). */
108
108
  defaultExpandedKeys: isIterableProp,
109
- selectedKeys: isIterableProp,
110
- setSelectedKeys: PropTypes.func
109
+
110
+ /** The selected key in the collection (controlled). */
111
+ selectedKey: isIterableProp,
112
+
113
+ /**
114
+ * Callback function that fires when the selected key changes.
115
+ *
116
+ * `(selectedKey: String) => void`
117
+ */
118
+ setSelectedKey: PropTypes.func
111
119
  };
112
120
  NavBar.defaultProps = {
113
- defaultSelectedKeys: []
121
+ defaultSelectedKey: '',
122
+ defaultExpandedKeys: []
114
123
  };
115
124
  export default NavBar;
@@ -1,5 +1,6 @@
1
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
1
2
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
- import React from 'react';
3
+ import React, { useState } from 'react';
3
4
  import AccountMultiple from 'mdi-react/AccountMultipleIcon';
4
5
  import Earth from 'mdi-react/EarthIcon';
5
6
  import EmoticonHappy from 'mdi-react/EmoticonHappyOutlineIcon';
@@ -113,10 +114,9 @@ var data = [{
113
114
  id: "Dashboard Link Group",
114
115
  variant: "buttons.navItemButton",
115
116
  href: "https://pingidentity.com/"
116
- }, "Group"), ___EmotionJSX(NavBarItemLink, {
117
+ }, "Group"), ___EmotionJSX(NavBarItemButton, {
117
118
  key: "Dashboard Link Populations",
118
- id: "Dashboard Link Populations",
119
- href: "https://pingidentity.com/"
119
+ id: "Dashboard Link Populations"
120
120
  }, "Populations")]
121
121
  }, {
122
122
  'data-id': 'identities-data-id',
@@ -139,10 +139,9 @@ var data = [{
139
139
  key: "Identities Link Attributes",
140
140
  id: "Identities Link Attributes",
141
141
  href: "https://pingidentity.com/"
142
- }, "Attributes"), ___EmotionJSX(NavBarItemLink, {
142
+ }, "Attributes"), ___EmotionJSX(NavBarItemButton, {
143
143
  key: "Identities Link Roles",
144
- id: "Identities Link Roles",
145
- href: "https://pingidentity.com/"
144
+ id: "Identities Link Roles"
146
145
  }, "Roles")]
147
146
  }, {
148
147
  'data-id': 'connections-data-id',
@@ -198,10 +197,9 @@ var data = [{
198
197
  key: "Connections Certificates & Key Pairs",
199
198
  id: "Connections Certificates & Key Pairs",
200
199
  href: "https://pingidentity.com/"
201
- }, "Certificates & Key Pairs"), ___EmotionJSX(NavBarItemLink, {
200
+ }, "Certificates & Key Pairs"), ___EmotionJSX(NavBarItemButton, {
202
201
  key: "Connections Resources",
203
- id: "Connections Resources",
204
- href: "https://pingidentity.com/"
202
+ id: "Connections Resources"
205
203
  }, "Resources")]
206
204
  }, {
207
205
  'data-id': 'experiences-data-id',
@@ -257,10 +255,9 @@ var data = [{
257
255
  key: "Experiences Vanity Domains",
258
256
  id: "Experiences Vanity Domains",
259
257
  href: "https://pingidentity.com/"
260
- }, "Vanity Domains"), ___EmotionJSX(NavBarItemLink, {
258
+ }, "Vanity Domains"), ___EmotionJSX(NavBarItemButton, {
261
259
  key: "Experiences Sender",
262
- id: "Experiences Sender",
263
- href: "https://pingidentity.com/"
260
+ id: "Experiences Sender"
264
261
  }, "Sender")]
265
262
  }];
266
263
  var secondData = [{
@@ -338,9 +335,7 @@ var thirdData = [{
338
335
  }, "Group")]
339
336
  }];
340
337
  export var Default = function Default() {
341
- return ___EmotionJSX(NavBar, {
342
- defaultSelectedKey: "Dashboard Link Group"
343
- }, ___EmotionJSX(Box, {
338
+ return ___EmotionJSX(NavBar, null, ___EmotionJSX(Box, {
344
339
  padding: "md"
345
340
  }, ___EmotionJSX(Link, {
346
341
  "aria-label": "home link",
@@ -372,4 +367,61 @@ export var Default = function Default() {
372
367
  items: thirdData,
373
368
  "data-id": "third-nav-bar-section"
374
369
  })));
370
+ };
371
+ export var Controlled = function Controlled() {
372
+ var _useState = useState('Dashboard Link Group'),
373
+ _useState2 = _slicedToArray(_useState, 2),
374
+ selectedKey = _useState2[0],
375
+ setSelectedKey = _useState2[1];
376
+
377
+ var customData = [{
378
+ icon: Earth,
379
+ key: 'Environment',
380
+ heading: 'Nested redirect is in here',
381
+ children: [___EmotionJSX(NavBarItemButton, {
382
+ key: "Click me for MFA Users",
383
+ id: "Click me for MFA Users",
384
+ onPress: function onPress() {
385
+ setSelectedKey('MFA Button Users');
386
+ }
387
+ }, "Click me for MFA Users"), ___EmotionJSX(NavBarItemButton, {
388
+ key: "Earth Button Group",
389
+ id: "Earth Button Group"
390
+ }, "Group")]
391
+ }];
392
+ return ___EmotionJSX(NavBar, {
393
+ setSelectedKey: setSelectedKey,
394
+ selectedKey: selectedKey
395
+ }, ___EmotionJSX(Box, {
396
+ padding: "md"
397
+ }, ___EmotionJSX(Link, {
398
+ "aria-label": "home link",
399
+ href: "https://pingidentity.com",
400
+ target: "_blank"
401
+ }, logo)), ___EmotionJSX(Separator, {
402
+ marginTop: "lg",
403
+ marginBottom: "0px",
404
+ backgroundColor: "neutral.60"
405
+ }), ___EmotionJSX(Box, {
406
+ variant: "navBar.sectionContainer",
407
+ paddingBottom: "xl"
408
+ }, ___EmotionJSX(NavBarItem, {
409
+ "data-id": "nav-bar-item",
410
+ icon: GlobeIcon,
411
+ id: "Overview",
412
+ key: "Overview",
413
+ text: "Overview"
414
+ }), ___EmotionJSX(NavBarSection, {
415
+ items: data,
416
+ hasSeparator: true,
417
+ "data-id": "first-nav-bar-section"
418
+ }), ___EmotionJSX(NavBarSection, {
419
+ items: secondData,
420
+ hasSeparator: true,
421
+ title: "PingOne Services",
422
+ "data-id": "second-nav-bar-section"
423
+ }), ___EmotionJSX(NavBarSection, {
424
+ items: customData,
425
+ "data-id": "third-nav-bar-section"
426
+ })));
375
427
  };
@@ -1,5 +1,6 @@
1
1
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
2
- import React from 'react';
2
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
+ import React, { useState } from 'react';
3
4
  import userEvent from '@testing-library/user-event';
4
5
  import GlobeIcon from 'mdi-react/GlobeIcon';
5
6
  import ViewDashboard from 'mdi-react/ViewDashboardIcon';
@@ -97,6 +98,58 @@ var getComponent = function getComponent() {
97
98
  }))));
98
99
  };
99
100
 
101
+ var ControlledComponent = function ControlledComponent() {
102
+ var _useState = useState(''),
103
+ _useState2 = _slicedToArray(_useState, 2),
104
+ selectedKey = _useState2[0],
105
+ setSelectedKey = _useState2[1];
106
+
107
+ var setKeys = function setKeys(e) {
108
+ setSelectedKey(e);
109
+ };
110
+
111
+ var customData = [{
112
+ icon: GlobeIcon,
113
+ key: 'Environment',
114
+ heading: 'Environment title that is so long, it wraps',
115
+ children: [___EmotionJSX(NavBarItemButton, {
116
+ key: "Click me for MFA Users",
117
+ id: "Click me for MFA Users",
118
+ onPress: function onPress() {
119
+ setSelectedKey('MFA Button Users');
120
+ }
121
+ }, "Click me for MFA Users"), ___EmotionJSX(NavBarItemButton, {
122
+ key: "Earth Button Group",
123
+ id: "Earth Button Group"
124
+ }, "Group")]
125
+ }];
126
+ return ___EmotionJSX(NavBar, {
127
+ setSelectedKey: setKeys,
128
+ selectedKey: selectedKey
129
+ }, ___EmotionJSX(Box, {
130
+ variant: "navBar.sectionContainer",
131
+ paddingBottom: "xl"
132
+ }, ___EmotionJSX(NavBarItem, {
133
+ id: "Overview",
134
+ key: "Overview",
135
+ text: "Overview",
136
+ icon: ViewDashboard,
137
+ "data-testid": "navItem"
138
+ }), ___EmotionJSX(NavBarSection, {
139
+ items: data,
140
+ hasSeparator: true,
141
+ "data-id": "nav-bar-section"
142
+ }), ___EmotionJSX(NavBarSection, {
143
+ items: secondData,
144
+ hasSeparator: true,
145
+ title: "PingOne Services",
146
+ "data-id": "second-nav-bar-section"
147
+ }), ___EmotionJSX(NavBarSection, {
148
+ items: customData,
149
+ "data-id": "third-nav-bar-section"
150
+ })));
151
+ };
152
+
100
153
  var getComponentWithMultipleChildren = function getComponentWithMultipleChildren() {
101
154
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
102
155
  return render(___EmotionJSX(NavBar, props, ___EmotionJSX(Box, null, ___EmotionJSX(Link, {
@@ -122,6 +175,10 @@ test('should render basic nav with children', function () {
122
175
  getComponent();
123
176
  expect(screen.queryByRole('navigation')).toBeInTheDocument();
124
177
  });
178
+ test('controlled: should render basic nav with children', function () {
179
+ render(___EmotionJSX(ControlledComponent, null));
180
+ expect(screen.queryByRole('navigation')).toBeInTheDocument();
181
+ });
125
182
  test('should render title for sections that have titles', function () {
126
183
  getComponent();
127
184
  expect(screen.getByText('test_title')).toBeInTheDocument();
@@ -139,6 +196,16 @@ test('should select NavItemLink', function () {
139
196
  userEvent.click(link);
140
197
  expect(link).toHaveClass('is-selected');
141
198
  });
199
+ test('controlled: should select NavItemLink', function () {
200
+ render(___EmotionJSX(ControlledComponent, null));
201
+ var link;
202
+ clickHeaderButtons();
203
+ link = screen.queryByTestId('navItemLink');
204
+ expect(link).toBeInTheDocument();
205
+ userEvent.click(link);
206
+ link = screen.queryByTestId('navItemLink');
207
+ expect(link).toHaveClass('is-selected');
208
+ });
142
209
  test('should select NavItemLink on space key press', function () {
143
210
  getComponent();
144
211
  clickHeaderButtons();
@@ -150,6 +217,32 @@ test('should select NavItemLink on space key press', function () {
150
217
  });
151
218
  expect(link).toHaveClass('is-selected');
152
219
  });
220
+ test('controlled: should select NavItemLink on space key press', function () {
221
+ render(___EmotionJSX(ControlledComponent, null));
222
+ var link;
223
+ clickHeaderButtons();
224
+ link = screen.queryByTestId('navItemLink');
225
+ expect(link).toBeInTheDocument();
226
+ fireEvent.keyDown(link, {
227
+ key: 'Space',
228
+ keyCode: 32
229
+ });
230
+ fireEvent.keyUp(link, {
231
+ key: 'Space',
232
+ keyCode: 32
233
+ });
234
+ link = screen.queryByTestId('navItemLink');
235
+ expect(link).toHaveClass('is-selected');
236
+ });
237
+ test('should select NavItem', function () {
238
+ render(___EmotionJSX(ControlledComponent, null));
239
+ var item;
240
+ item = screen.queryByTestId('navItem');
241
+ expect(item).toBeInTheDocument();
242
+ userEvent.click(item);
243
+ item = screen.queryByTestId('navItem');
244
+ expect(item).toHaveClass('is-selected');
245
+ });
153
246
  test('should select NavItem', function () {
154
247
  getComponent();
155
248
  var item = screen.getByTestId('navItem');
@@ -157,6 +250,15 @@ test('should select NavItem', function () {
157
250
  userEvent.click(item);
158
251
  expect(item).toHaveClass('is-selected');
159
252
  });
253
+ test('controlled: should select NavItem', function () {
254
+ render(___EmotionJSX(ControlledComponent, null));
255
+ var item;
256
+ item = screen.queryByTestId('navItem');
257
+ expect(item).toBeInTheDocument();
258
+ userEvent.click(item);
259
+ item = screen.queryByTestId('navItem');
260
+ expect(item).toHaveClass('is-selected');
261
+ });
160
262
  test('should select NavItemButton', function () {
161
263
  getComponent();
162
264
  clickHeaderButtons();
@@ -165,6 +267,16 @@ test('should select NavItemButton', function () {
165
267
  userEvent.click(button);
166
268
  expect(button).toHaveClass('is-selected');
167
269
  });
270
+ test('controlled: should select NavItemButton', function () {
271
+ render(___EmotionJSX(ControlledComponent, null));
272
+ var button;
273
+ clickHeaderButtons();
274
+ button = screen.queryByTestId('navItemButton');
275
+ expect(button).toBeInTheDocument();
276
+ userEvent.click(button);
277
+ button = screen.queryByTestId('navItemButton');
278
+ expect(button).toHaveClass('is-selected');
279
+ });
168
280
  test('should collapse NavItemBody', function () {
169
281
  getComponent();
170
282
  expect(screen.queryByText('Users')).not.toBeInTheDocument();
@@ -295,4 +407,25 @@ test('should render NavBarSection with data-id', function () {
295
407
  test('should render NavBarSection button with data-id', function () {
296
408
  getComponent();
297
409
  expect(screen.getByTestId(SECTION_BUTTON_DATA_ID)).toHaveAttribute(DATA_ID);
410
+ });
411
+ test('passing in a string into defaultSelectedKeys makes the key selected by default, and the parent expanded by default ', function () {
412
+ getComponent({
413
+ defaultSelectedKey: 'Credentials Button Users'
414
+ });
415
+ var child = screen.getByTestId('navItemButton');
416
+ expect(child).toBeInTheDocument();
417
+ expect(child).toHaveClass('is-selected');
418
+ });
419
+ test('when a child is selected, and the parent is collapsed, the parent has the is-selected class', function () {
420
+ getComponent({
421
+ defaultSelectedKey: 'Credentials Button Users'
422
+ });
423
+ var child = screen.getByTestId('navItemButton');
424
+ expect(child).toBeInTheDocument();
425
+ expect(child).toHaveClass('is-selected');
426
+ var parent = screen.queryByTestId(SECTION_BUTTON_DATA_ID);
427
+ expect(parent).not.toHaveClass('is-selected');
428
+ userEvent.click(parent);
429
+ var parentDiv = screen.queryByTestId('Overview');
430
+ expect(parentDiv).toHaveClass('is-selected');
298
431
  });
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
2
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
3
  var _excluded = ["icon", "text", "className", "id", "onPress"];
5
4
  import React, { useRef, forwardRef, useImperativeHandle } from 'react';
@@ -12,8 +11,6 @@ import { useStatusClasses, useNavBarPress } from '../../hooks';
12
11
  import { useNavBarContext } from '../../context/NavBarContext';
13
12
  import { jsx as ___EmotionJSX } from "@emotion/react";
14
13
  var NavBarItem = /*#__PURE__*/forwardRef(function (props, ref) {
15
- var _context;
16
-
17
14
  var icon = props.icon,
18
15
  text = props.text,
19
16
  className = props.className,
@@ -42,8 +39,7 @@ var NavBarItem = /*#__PURE__*/forwardRef(function (props, ref) {
42
39
  isFocusVisible = _useFocusRing2.isFocusVisible;
43
40
 
44
41
  var state = useNavBarContext();
45
-
46
- var isSelected = _includesInstanceProperty(_context = state.selectedKey).call(_context, key);
42
+ var isSelected = state.selectedKey === key;
47
43
 
48
44
  var _useNavBarPress = useNavBarPress({
49
45
  key: key,
@@ -8,13 +8,12 @@ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable
8
8
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
9
9
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
10
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
12
11
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
13
12
  var _excluded = ["className", "id", "onPress", "sx"];
14
13
 
15
14
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
15
 
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
18
17
 
19
18
  import React from 'react';
20
19
  import PropTypes from 'prop-types';
@@ -24,8 +23,6 @@ import { Button } from '../../index';
24
23
  import { jsx as ___EmotionJSX } from "@emotion/react";
25
24
 
26
25
  var NavBarItemButton = function NavBarItemButton(props) {
27
- var _context;
28
-
29
26
  var className = props.className,
30
27
  key = props.id,
31
28
  onPressCallback = props.onPress,
@@ -33,8 +30,7 @@ var NavBarItemButton = function NavBarItemButton(props) {
33
30
  others = _objectWithoutProperties(props, _excluded);
34
31
 
35
32
  var state = useNavBarContext();
36
-
37
- var isSelected = _includesInstanceProperty(_context = state.selectedKey).call(_context, key);
33
+ var isSelected = state.selectedKey === key;
38
34
 
39
35
  var _useNavBarPress = useNavBarPress({
40
36
  key: key,
@@ -1,6 +1,7 @@
1
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
1
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
2
2
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
3
- import React from 'react';
3
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
4
+ import React, { useEffect } from 'react';
4
5
  import PropTypes from 'prop-types';
5
6
  import MenuDown from 'mdi-react/MenuDownIcon';
6
7
  import MenuUp from 'mdi-react/MenuUpIcon';
@@ -10,7 +11,7 @@ import { useStatusClasses } from '../../hooks';
10
11
  import { jsx as ___EmotionJSX } from "@emotion/react";
11
12
 
12
13
  var NavBarItemHeader = function NavBarItemHeader(props) {
13
- var _navBarState$expanded, _context;
14
+ var _context;
14
15
 
15
16
  var item = props.item;
16
17
  var icon = item.icon,
@@ -18,7 +19,11 @@ var NavBarItemHeader = function NavBarItemHeader(props) {
18
19
  className = item.className,
19
20
  heading = item.heading;
20
21
  var navBarState = useNavBarContext();
21
- var isExpanded = (_navBarState$expanded = navBarState.expandedKeys) === null || _navBarState$expanded === void 0 ? void 0 : _navBarState$expanded.has(key);
22
+ var selectedKey = navBarState.selectedKey,
23
+ setExpandedKeys = navBarState.setExpandedKeys,
24
+ expandedKeys = navBarState.expandedKeys;
25
+
26
+ var isExpanded = _includesInstanceProperty(expandedKeys).call(expandedKeys, key);
22
27
 
23
28
  var array = _mapInstanceProperty(_context = item.children).call(_context, function (i) {
24
29
  return i.key;
@@ -26,6 +31,14 @@ var NavBarItemHeader = function NavBarItemHeader(props) {
26
31
 
27
32
  var childSelected = _includesInstanceProperty(array).call(array, navBarState.selectedKey);
28
33
 
34
+ useEffect(function () {
35
+ if (childSelected && isExpanded === false) {
36
+ var _context2;
37
+
38
+ setExpandedKeys(_concatInstanceProperty(_context2 = []).call(_context2, expandedKeys, [key]));
39
+ }
40
+ }, [selectedKey]);
41
+
29
42
  var _useStatusClasses = useStatusClasses(className, {
30
43
  isSelected: childSelected && !isExpanded
31
44
  }),
@@ -34,7 +47,8 @@ var NavBarItemHeader = function NavBarItemHeader(props) {
34
47
  return ___EmotionJSX(Box, {
35
48
  variant: "navBar.itemHeaderContainer",
36
49
  className: classNames,
37
- isRow: true
50
+ isRow: true,
51
+ "data-testid": heading
38
52
  }, icon && ___EmotionJSX(Icon, {
39
53
  icon: icon,
40
54
  size: 20,
@@ -8,13 +8,12 @@ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable
8
8
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
9
9
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
10
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
12
11
  import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
13
12
  var _excluded = ["className", "id", "onPress"];
14
13
 
15
14
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
15
 
17
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
18
17
 
19
18
  import React from 'react';
20
19
  import PropTypes from 'prop-types';
@@ -24,16 +23,13 @@ import { useStatusClasses, useNavBarPress } from '../../hooks';
24
23
  import { jsx as ___EmotionJSX } from "@emotion/react";
25
24
 
26
25
  var NavBarItemLink = function NavBarItemLink(props) {
27
- var _context;
28
-
29
26
  var className = props.className,
30
27
  key = props.id,
31
28
  onPressCallback = props.onPress,
32
29
  others = _objectWithoutProperties(props, _excluded);
33
30
 
34
31
  var state = useNavBarContext();
35
-
36
- var isSelected = _includesInstanceProperty(_context = state.selectedKey).call(_context, key);
32
+ var isSelected = state.selectedKey === key;
37
33
 
38
34
  var _useNavBarPress = useNavBarPress({
39
35
  key: key,