@pingux/astro 1.37.2-alpha.0 → 1.37.2-alpha.1

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.
@@ -26,8 +26,6 @@ var _react = _interopRequireWildcard(require("react"));
26
26
 
27
27
  var _propTypes = _interopRequireDefault(require("prop-types"));
28
28
 
29
- var _uuid = require("uuid");
30
-
31
29
  var _focus = require("@react-aria/focus");
32
30
 
33
31
  var _NavBarContext = require("../../context/NavBarContext");
@@ -70,17 +68,15 @@ var NavBar = function NavBar(props) {
70
68
  selectedKey = _useProgressiveState2[0],
71
69
  setSelectedKey = _useProgressiveState2[1];
72
70
 
73
- var items = (0, _react.useMemo)(function () {
74
- return (0, _isArray["default"])(children) ? (0, _map["default"])(children).call(children, function (child) {
75
- return {
76
- item: child,
77
- key: (0, _uuid.v4)()
78
- };
79
- }) : [{
80
- item: children,
81
- key: (0, _uuid.v4)()
82
- }];
83
- }, []);
71
+ var items = (0, _isArray["default"])(children) ? (0, _map["default"])(children).call(children, function (child) {
72
+ return {
73
+ item: child,
74
+ key: child.key
75
+ };
76
+ }) : [{
77
+ item: children,
78
+ key: children.key
79
+ }];
84
80
  var contextValue = {
85
81
  selectedKey: selectedKey,
86
82
  setSelectedKey: setSelectedKeyProp || setSelectedKey,
@@ -432,7 +432,8 @@ var Controlled = function Controlled() {
432
432
  setSelectedKey: setSelectedKey,
433
433
  selectedKey: selectedKey
434
434
  }, (0, _react2.jsx)(_index.Box, {
435
- padding: "md"
435
+ padding: "md",
436
+ key: "top-logo-parent"
436
437
  }, (0, _react2.jsx)(_index.Link, {
437
438
  "aria-label": "home link",
438
439
  href: "https://pingidentity.com",
@@ -440,10 +441,12 @@ var Controlled = function Controlled() {
440
441
  }, logo)), (0, _react2.jsx)(_index.Separator, {
441
442
  marginTop: "lg",
442
443
  marginBottom: "0px",
443
- backgroundColor: "neutral.60"
444
+ backgroundColor: "neutral.60",
445
+ key: "top-separator"
444
446
  }), (0, _react2.jsx)(_index.Box, {
445
447
  variant: "navBar.sectionContainer",
446
- paddingBottom: "xl"
448
+ paddingBottom: "xl",
449
+ key: "first-section-container"
447
450
  }, (0, _react2.jsx)(_index.NavBarItem, {
448
451
  "data-id": "nav-bar-item",
449
452
  icon: _GlobeIcon["default"],
@@ -12,6 +12,8 @@ var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
12
12
 
13
13
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
14
14
 
15
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
16
+
15
17
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
16
18
 
17
19
  var _react = _interopRequireWildcard(require("react"));
@@ -113,15 +115,18 @@ var getComponent = function getComponent() {
113
115
  height: '100%',
114
116
  maxHeight: '100%',
115
117
  overflowY: 'overlay !important'
116
- }
118
+ },
119
+ key: "top-logo-parent"
117
120
  }, (0, _react2.jsx)(_.NavBarSection, {
118
121
  items: data,
119
122
  hasSeparator: true,
120
123
  "data-testid": DATA_ID,
121
- "data-id": DATA_ID
124
+ "data-id": DATA_ID,
125
+ key: "first-section"
122
126
  }), (0, _react2.jsx)(_.NavBarSection, {
123
127
  items: secondData,
124
- title: "test_title"
128
+ title: "test_title",
129
+ key: "second-section"
125
130
  }), (0, _react2.jsx)(_.NavBarItem, {
126
131
  id: "Overview",
127
132
  key: "Overview",
@@ -132,15 +137,13 @@ var getComponent = function getComponent() {
132
137
  };
133
138
 
134
139
  var ControlledComponent = function ControlledComponent() {
140
+ var _context;
141
+
135
142
  var _useState = (0, _react.useState)(''),
136
143
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
137
144
  selectedKey = _useState2[0],
138
145
  setSelectedKey = _useState2[1];
139
146
 
140
- var setKeys = function setKeys(e) {
141
- setSelectedKey(e);
142
- };
143
-
144
147
  var customData = [{
145
148
  icon: _GlobeIcon["default"],
146
149
  key: 'Environment',
@@ -153,16 +156,40 @@ var ControlledComponent = function ControlledComponent() {
153
156
  }
154
157
  }, "Click me for MFA Users"), (0, _react2.jsx)(_.NavBarItemButton, {
155
158
  key: "Earth Button Group",
156
- id: "Earth Button Group"
159
+ id: "Earth Button Group",
160
+ "data-testid": "group-item"
157
161
  }, "Group")]
158
162
  }];
163
+
164
+ var _useState3 = (0, _react.useState)((0, _concat["default"])(_context = []).call(_context, customData)),
165
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
166
+ thisData = _useState4[0],
167
+ setData = _useState4[1];
168
+
169
+ var testFunction = function testFunction() {
170
+ var _context2, _context3;
171
+
172
+ var newArray = (0, _concat["default"])(_context2 = []).call(_context2, customData);
173
+ newArray.pop();
174
+ setData((0, _concat["default"])(_context3 = []).call(_context3, newArray));
175
+ };
176
+
177
+ var setKeys = function setKeys(e) {
178
+ setSelectedKey(e);
179
+ };
180
+
159
181
  return (0, _react2.jsx)(_NavBar["default"], {
160
182
  setSelectedKey: setKeys,
161
183
  selectedKey: selectedKey
162
184
  }, (0, _react2.jsx)(_.Box, {
163
185
  variant: "navBar.sectionContainer",
164
- paddingBottom: "xl"
165
- }, (0, _react2.jsx)(_.NavBarItem, {
186
+ paddingBottom: "xl",
187
+ key: "top-logo-parent"
188
+ }, (0, _react2.jsx)("button", {
189
+ key: "test-button",
190
+ "data-testid": "test-button",
191
+ onClick: testFunction
192
+ }, "click me!"), (0, _react2.jsx)(_.NavBarItem, {
166
193
  id: "Overview",
167
194
  key: "Overview",
168
195
  text: "Overview",
@@ -178,20 +205,23 @@ var ControlledComponent = function ControlledComponent() {
178
205
  title: "PingOne Services",
179
206
  "data-id": "second-nav-bar-section"
180
207
  }), (0, _react2.jsx)(_.NavBarSection, {
181
- items: customData,
208
+ items: thisData,
182
209
  "data-id": "third-nav-bar-section"
183
210
  })));
184
211
  };
185
212
 
186
213
  var getComponentWithMultipleChildren = function getComponentWithMultipleChildren() {
187
214
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
188
- return (0, _testWrapper.render)((0, _react2.jsx)(_NavBar["default"], props, (0, _react2.jsx)(_.Box, null, (0, _react2.jsx)(_.Link, {
215
+ return (0, _testWrapper.render)((0, _react2.jsx)(_NavBar["default"], props, (0, _react2.jsx)(_.Box, {
216
+ key: "top-logo-parent"
217
+ }, (0, _react2.jsx)(_.Link, {
189
218
  href: "https://pingidentity.com",
190
219
  target: "_blank",
191
220
  "aria-label": "home link",
192
221
  "data-testid": "navLink"
193
222
  }, "home")), (0, _react2.jsx)(_.Button, {
194
- "data-testid": "navButton"
223
+ "data-testid": "navButton",
224
+ key: "nav-button"
195
225
  }, "test button")));
196
226
  };
197
227
 
@@ -534,4 +564,17 @@ test('when a child is selected, and the parent is collapsed, the parent has the
534
564
  var parentDiv = _testWrapper.screen.queryByTestId('Overview');
535
565
 
536
566
  expect(parentDiv).toHaveClass('is-selected');
567
+ });
568
+ test('controlled version: items can be updated.', function () {
569
+ (0, _testWrapper.render)((0, _react2.jsx)(ControlledComponent, null));
570
+
571
+ var button = _testWrapper.screen.getByTestId('test-button');
572
+
573
+ var thisitem = _testWrapper.screen.getByTestId('Environment title that is so long, it wraps');
574
+
575
+ expect(thisitem).toBeInTheDocument();
576
+
577
+ _userEvent["default"].click(button);
578
+
579
+ expect(_testWrapper.screen.queryByTestId('Environment title that is so long, it wraps')).not.toBeInTheDocument();
537
580
  });
@@ -1,9 +1,8 @@
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
3
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
4
- import React, { useMemo, useState } from 'react';
4
+ import React, { useState } from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { v4 as uuid } from 'uuid';
7
6
  import { FocusScope, useFocusManager } from '@react-aria/focus';
8
7
  import { NavBarContext } from '../../context/NavBarContext';
9
8
  import { isIterableProp } from '../../utils/devUtils/props/isIterable';
@@ -38,17 +37,15 @@ var NavBar = function NavBar(props) {
38
37
  selectedKey = _useProgressiveState2[0],
39
38
  setSelectedKey = _useProgressiveState2[1];
40
39
 
41
- var items = useMemo(function () {
42
- return _Array$isArray(children) ? _mapInstanceProperty(children).call(children, function (child) {
43
- return {
44
- item: child,
45
- key: uuid()
46
- };
47
- }) : [{
48
- item: children,
49
- key: uuid()
50
- }];
51
- }, []);
40
+ var items = _Array$isArray(children) ? _mapInstanceProperty(children).call(children, function (child) {
41
+ return {
42
+ item: child,
43
+ key: child.key
44
+ };
45
+ }) : [{
46
+ item: children,
47
+ key: children.key
48
+ }];
52
49
  var contextValue = {
53
50
  selectedKey: selectedKey,
54
51
  setSelectedKey: setSelectedKeyProp || setSelectedKey,
@@ -393,7 +393,8 @@ export var Controlled = function Controlled() {
393
393
  setSelectedKey: setSelectedKey,
394
394
  selectedKey: selectedKey
395
395
  }, ___EmotionJSX(Box, {
396
- padding: "md"
396
+ padding: "md",
397
+ key: "top-logo-parent"
397
398
  }, ___EmotionJSX(Link, {
398
399
  "aria-label": "home link",
399
400
  href: "https://pingidentity.com",
@@ -401,10 +402,12 @@ export var Controlled = function Controlled() {
401
402
  }, logo)), ___EmotionJSX(Separator, {
402
403
  marginTop: "lg",
403
404
  marginBottom: "0px",
404
- backgroundColor: "neutral.60"
405
+ backgroundColor: "neutral.60",
406
+ key: "top-separator"
405
407
  }), ___EmotionJSX(Box, {
406
408
  variant: "navBar.sectionContainer",
407
- paddingBottom: "xl"
409
+ paddingBottom: "xl",
410
+ key: "first-section-container"
408
411
  }, ___EmotionJSX(NavBarItem, {
409
412
  "data-id": "nav-bar-item",
410
413
  icon: GlobeIcon,
@@ -1,4 +1,5 @@
1
1
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
2
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
2
3
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
4
  import React, { useState } from 'react';
4
5
  import userEvent from '@testing-library/user-event';
@@ -80,15 +81,18 @@ var getComponent = function getComponent() {
80
81
  height: '100%',
81
82
  maxHeight: '100%',
82
83
  overflowY: 'overlay !important'
83
- }
84
+ },
85
+ key: "top-logo-parent"
84
86
  }, ___EmotionJSX(NavBarSection, {
85
87
  items: data,
86
88
  hasSeparator: true,
87
89
  "data-testid": DATA_ID,
88
- "data-id": DATA_ID
90
+ "data-id": DATA_ID,
91
+ key: "first-section"
89
92
  }), ___EmotionJSX(NavBarSection, {
90
93
  items: secondData,
91
- title: "test_title"
94
+ title: "test_title",
95
+ key: "second-section"
92
96
  }), ___EmotionJSX(NavBarItem, {
93
97
  id: "Overview",
94
98
  key: "Overview",
@@ -99,15 +103,13 @@ var getComponent = function getComponent() {
99
103
  };
100
104
 
101
105
  var ControlledComponent = function ControlledComponent() {
106
+ var _context;
107
+
102
108
  var _useState = useState(''),
103
109
  _useState2 = _slicedToArray(_useState, 2),
104
110
  selectedKey = _useState2[0],
105
111
  setSelectedKey = _useState2[1];
106
112
 
107
- var setKeys = function setKeys(e) {
108
- setSelectedKey(e);
109
- };
110
-
111
113
  var customData = [{
112
114
  icon: GlobeIcon,
113
115
  key: 'Environment',
@@ -120,16 +122,41 @@ var ControlledComponent = function ControlledComponent() {
120
122
  }
121
123
  }, "Click me for MFA Users"), ___EmotionJSX(NavBarItemButton, {
122
124
  key: "Earth Button Group",
123
- id: "Earth Button Group"
125
+ id: "Earth Button Group",
126
+ "data-testid": "group-item"
124
127
  }, "Group")]
125
128
  }];
129
+
130
+ var _useState3 = useState(_concatInstanceProperty(_context = []).call(_context, customData)),
131
+ _useState4 = _slicedToArray(_useState3, 2),
132
+ thisData = _useState4[0],
133
+ setData = _useState4[1];
134
+
135
+ var testFunction = function testFunction() {
136
+ var _context2, _context3;
137
+
138
+ var newArray = _concatInstanceProperty(_context2 = []).call(_context2, customData);
139
+
140
+ newArray.pop();
141
+ setData(_concatInstanceProperty(_context3 = []).call(_context3, newArray));
142
+ };
143
+
144
+ var setKeys = function setKeys(e) {
145
+ setSelectedKey(e);
146
+ };
147
+
126
148
  return ___EmotionJSX(NavBar, {
127
149
  setSelectedKey: setKeys,
128
150
  selectedKey: selectedKey
129
151
  }, ___EmotionJSX(Box, {
130
152
  variant: "navBar.sectionContainer",
131
- paddingBottom: "xl"
132
- }, ___EmotionJSX(NavBarItem, {
153
+ paddingBottom: "xl",
154
+ key: "top-logo-parent"
155
+ }, ___EmotionJSX("button", {
156
+ key: "test-button",
157
+ "data-testid": "test-button",
158
+ onClick: testFunction
159
+ }, "click me!"), ___EmotionJSX(NavBarItem, {
133
160
  id: "Overview",
134
161
  key: "Overview",
135
162
  text: "Overview",
@@ -145,20 +172,23 @@ var ControlledComponent = function ControlledComponent() {
145
172
  title: "PingOne Services",
146
173
  "data-id": "second-nav-bar-section"
147
174
  }), ___EmotionJSX(NavBarSection, {
148
- items: customData,
175
+ items: thisData,
149
176
  "data-id": "third-nav-bar-section"
150
177
  })));
151
178
  };
152
179
 
153
180
  var getComponentWithMultipleChildren = function getComponentWithMultipleChildren() {
154
181
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
155
- return render(___EmotionJSX(NavBar, props, ___EmotionJSX(Box, null, ___EmotionJSX(Link, {
182
+ return render(___EmotionJSX(NavBar, props, ___EmotionJSX(Box, {
183
+ key: "top-logo-parent"
184
+ }, ___EmotionJSX(Link, {
156
185
  href: "https://pingidentity.com",
157
186
  target: "_blank",
158
187
  "aria-label": "home link",
159
188
  "data-testid": "navLink"
160
189
  }, "home")), ___EmotionJSX(Button, {
161
- "data-testid": "navButton"
190
+ "data-testid": "navButton",
191
+ key: "nav-button"
162
192
  }, "test button")));
163
193
  };
164
194
 
@@ -428,4 +458,12 @@ test('when a child is selected, and the parent is collapsed, the parent has the
428
458
  userEvent.click(parent);
429
459
  var parentDiv = screen.queryByTestId('Overview');
430
460
  expect(parentDiv).toHaveClass('is-selected');
461
+ });
462
+ test('controlled version: items can be updated.', function () {
463
+ render(___EmotionJSX(ControlledComponent, null));
464
+ var button = screen.getByTestId('test-button');
465
+ var thisitem = screen.getByTestId('Environment title that is so long, it wraps');
466
+ expect(thisitem).toBeInTheDocument();
467
+ userEvent.click(button);
468
+ expect(screen.queryByTestId('Environment title that is so long, it wraps')).not.toBeInTheDocument();
431
469
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.37.2-alpha.0",
3
+ "version": "1.37.2-alpha.1",
4
4
  "description": "PingUX themeable React component library",
5
5
  "repository": {
6
6
  "type": "git",