@pingux/astro 2.53.0 → 2.53.1-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.
- package/lib/cjs/components/NavBar/NavBar.d.ts +4 -0
- package/lib/cjs/components/NavBar/NavBar.js +5 -26
- package/lib/cjs/components/NavBar/NavBar.stories.d.ts +7 -0
- package/lib/cjs/components/NavBar/NavBar.stories.js +1 -1
- package/lib/cjs/components/NavBar/NavBar.styles.d.ts +364 -0
- package/lib/cjs/components/NavBar/NavBar.test.d.ts +1 -0
- package/lib/cjs/components/NavBar/index.d.ts +1 -0
- package/lib/cjs/components/NavBarSection/NavBarItem.d.ts +4 -0
- package/lib/cjs/components/NavBarSection/NavBarItem.js +1 -12
- package/lib/cjs/components/NavBarSection/NavBarItemBody.d.ts +4 -0
- package/lib/cjs/components/NavBarSection/NavBarItemBody.js +6 -11
- package/lib/cjs/components/NavBarSection/NavBarItemBody.test.d.ts +1 -0
- package/lib/cjs/components/NavBarSection/NavBarItemButton.d.ts +4 -0
- package/lib/cjs/components/NavBarSection/NavBarItemButton.js +0 -7
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.d.ts +4 -0
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +9 -33
- package/lib/cjs/components/NavBarSection/NavBarItemLink.d.ts +4 -0
- package/lib/cjs/components/NavBarSection/NavBarItemLink.js +0 -9
- package/lib/cjs/components/NavBarSection/NavBarSection.d.ts +9 -0
- package/lib/cjs/components/NavBarSection/NavBarSection.js +18 -50
- package/lib/cjs/components/NavBarSection/index.d.ts +4 -0
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.d.ts +1 -1
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.js +5 -3
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +23 -12
- package/lib/cjs/types/link.d.ts +4 -0
- package/lib/cjs/types/navBar.d.ts +136 -0
- package/lib/cjs/types/navBar.js +6 -0
- package/lib/components/NavBar/NavBar.js +5 -26
- package/lib/components/NavBar/NavBar.stories.js +1 -1
- package/lib/components/NavBarSection/NavBarItem.js +3 -14
- package/lib/components/NavBarSection/NavBarItemBody.js +6 -11
- package/lib/components/NavBarSection/NavBarItemButton.js +0 -7
- package/lib/components/NavBarSection/NavBarItemHeader.js +9 -33
- package/lib/components/NavBarSection/NavBarItemLink.js +0 -9
- package/lib/components/NavBarSection/NavBarSection.js +18 -50
- package/lib/hooks/useNavBarPress/useNavBarPress.js +5 -3
- package/lib/types/index.js +1 -0
- package/lib/types/navBar.js +1 -0
- package/package.json +1 -1
@@ -17,7 +17,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
17
17
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
18
18
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
19
19
|
var _react = _interopRequireDefault(require("react"));
|
20
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
21
20
|
var _NavBarContext = require("../../context/NavBarContext");
|
22
21
|
var _hooks = require("../../hooks");
|
23
22
|
var _index = require("../../index");
|
@@ -54,13 +53,5 @@ var NavBarItemLink = function NavBarItemLink(props) {
|
|
54
53
|
}, props.sx)
|
55
54
|
}));
|
56
55
|
};
|
57
|
-
NavBarItemLink.propTypes = {
|
58
|
-
/** Specifies the location of the URL */
|
59
|
-
href: _propTypes["default"].string,
|
60
|
-
/** Handler that is called when the press is released over the target. */
|
61
|
-
onPress: _propTypes["default"].func,
|
62
|
-
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
63
|
-
id: _propTypes["default"].string.isRequired
|
64
|
-
};
|
65
56
|
var _default = NavBarItemLink;
|
66
57
|
exports["default"] = _default;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { NavBarSectionProps } from '../../types/navBar';
|
3
|
+
/**
|
4
|
+
* Composed component that creates a group
|
5
|
+
* with title, and separator options.
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
declare const NavBarSection: React.ForwardRefExoticComponent<NavBarSectionProps<object> & React.RefAttributes<HTMLUListElement>>;
|
9
|
+
export default NavBarSection;
|
@@ -9,6 +9,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
9
9
|
value: true
|
10
10
|
});
|
11
11
|
exports["default"] = void 0;
|
12
|
+
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
12
13
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
13
14
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
14
15
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
@@ -18,7 +19,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-c
|
|
18
19
|
var _react = _interopRequireWildcard(require("react"));
|
19
20
|
var _focus = require("@react-aria/focus");
|
20
21
|
var _interactions = require("@react-aria/interactions");
|
21
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
22
22
|
var _ = require("../..");
|
23
23
|
var _NavBarContext = require("../../context/NavBarContext");
|
24
24
|
var _NavBarItemBody = _interopRequireDefault(require("./NavBarItemBody"));
|
@@ -39,9 +39,12 @@ var NavBarSection = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
39
39
|
items = _ref.items,
|
40
40
|
onKeyDown = _ref.onKeyDown,
|
41
41
|
others = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
42
|
-
var childrenItems
|
43
|
-
|
44
|
-
|
42
|
+
var childrenItems;
|
43
|
+
if ((0, _isArray["default"])(items)) {
|
44
|
+
childrenItems = items === null || items === void 0 ? void 0 : (0, _filter["default"])(items).call(items, function (item) {
|
45
|
+
return item.children || item.href;
|
46
|
+
});
|
47
|
+
}
|
45
48
|
var state = (0, _NavBarContext.useNavBarContext)();
|
46
49
|
return (0, _react2.jsx)(_react["default"].Fragment, null, hasSeparator && (0, _react2.jsx)(_.Separator, {
|
47
50
|
variant: "separator.navBarSeparator"
|
@@ -55,7 +58,7 @@ var NavBarSection = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
55
58
|
padding: 0,
|
56
59
|
listStyle: 'none'
|
57
60
|
}
|
58
|
-
}, others), (0, _map["default"])(childrenItems).call(childrenItems, function (item) {
|
61
|
+
}, others), childrenItems && (0, _map["default"])(childrenItems).call(childrenItems, function (item) {
|
59
62
|
return (0, _react2.jsx)(_.Box, {
|
60
63
|
as: "li",
|
61
64
|
key: item.key,
|
@@ -73,16 +76,17 @@ var NavBarSection = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
73
76
|
var SectionItem = function SectionItem(_ref2) {
|
74
77
|
var item = _ref2.item,
|
75
78
|
onKeyDownProp = _ref2.onKeyDown;
|
76
|
-
var
|
77
|
-
|
78
|
-
|
79
|
+
var _ref3 = item,
|
80
|
+
key = _ref3.key,
|
81
|
+
children = _ref3.children,
|
82
|
+
others = (0, _objectWithoutProperties2["default"])(_ref3, _excluded2);
|
79
83
|
var navBarState = (0, _NavBarContext.useNavBarContext)();
|
80
84
|
var isAutoСollapsible = navBarState.isAutoСollapsible,
|
81
85
|
expandedKeys = navBarState.expandedKeys,
|
82
86
|
setExpandedKeys = navBarState.setExpandedKeys;
|
83
87
|
var isExpanded = (0, _includes["default"])(expandedKeys).call(expandedKeys, key);
|
84
|
-
var firstChildKey = children.length ? children[0].key : null;
|
85
|
-
var lastChildKey = children.length ? children[children.length - 1].key : null;
|
88
|
+
var firstChildKey = children && children.length ? children[0].key : null;
|
89
|
+
var lastChildKey = children && children.length ? children[children.length - 1].key : null;
|
86
90
|
var onExpandedChange = function onExpandedChange(isOpen) {
|
87
91
|
var newArray;
|
88
92
|
if (isOpen) {
|
@@ -130,7 +134,7 @@ var SectionItem = function SectionItem(_ref2) {
|
|
130
134
|
};
|
131
135
|
var _useKeyboard = (0, _interactions.useKeyboard)({
|
132
136
|
onKeyDown: function onKeyDown(e) {
|
133
|
-
_onKeyDown(e);
|
137
|
+
_onKeyDown(e, undefined);
|
134
138
|
e.continuePropagation();
|
135
139
|
}
|
136
140
|
}),
|
@@ -147,12 +151,12 @@ var SectionItem = function SectionItem(_ref2) {
|
|
147
151
|
onKeyDown: _onKeyDown
|
148
152
|
}));
|
149
153
|
};
|
150
|
-
var PrimaryItem = function PrimaryItem(
|
151
|
-
var item =
|
154
|
+
var PrimaryItem = function PrimaryItem(_ref4) {
|
155
|
+
var item = _ref4.item;
|
152
156
|
var state = (0, _NavBarContext.useNavBarContext)();
|
153
157
|
return (0, _react2.jsx)(_.Link, {
|
154
158
|
variant: state.navStyles.primaryItem,
|
155
|
-
href: item.href,
|
159
|
+
href: item && item.href,
|
156
160
|
target: "_blank"
|
157
161
|
}, (0, _react2.jsx)(_NavBarItemHeader["default"], {
|
158
162
|
item: item
|
@@ -161,41 +165,5 @@ var PrimaryItem = function PrimaryItem(_ref3) {
|
|
161
165
|
NavBarSection.defaultProps = {
|
162
166
|
hasSeparator: false
|
163
167
|
};
|
164
|
-
NavBarSection.propTypes = {
|
165
|
-
/** If true, a separator will render at the end of the section */
|
166
|
-
hasSeparator: _propTypes["default"].bool,
|
167
|
-
/** callback that runs on key down */
|
168
|
-
onKeyDown: _propTypes["default"].func,
|
169
|
-
/** If present, this string will render at the top of the section */
|
170
|
-
title: _propTypes["default"].string,
|
171
|
-
/**
|
172
|
-
* *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
|
173
|
-
* For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
|
174
|
-
*/
|
175
|
-
items: _propTypes["default"].arrayOf(_propTypes["default"].shape({}))
|
176
|
-
};
|
177
|
-
SectionItem.propTypes = {
|
178
|
-
onKeyDown: _propTypes["default"].func,
|
179
|
-
item: _propTypes["default"].shape({
|
180
|
-
key: _propTypes["default"].string,
|
181
|
-
children: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object])),
|
182
|
-
'aria-label': _propTypes["default"].string
|
183
|
-
}),
|
184
|
-
state: _propTypes["default"].shape({
|
185
|
-
collection: _propTypes["default"].shape({}),
|
186
|
-
selectedKey: _propTypes["default"].string,
|
187
|
-
setSelectedKey: _propTypes["default"].func,
|
188
|
-
selectionManager: _propTypes["default"].shape({
|
189
|
-
focusedKey: _propTypes["default"].string,
|
190
|
-
setFocusedKey: _propTypes["default"].func
|
191
|
-
})
|
192
|
-
}),
|
193
|
-
menuProps: _propTypes["default"].shape({})
|
194
|
-
};
|
195
|
-
PrimaryItem.propTypes = {
|
196
|
-
item: _propTypes["default"].shape({
|
197
|
-
href: _propTypes["default"].string
|
198
|
-
})
|
199
|
-
};
|
200
168
|
var _default = NavBarSection;
|
201
169
|
exports["default"] = _default;
|
@@ -8,7 +8,7 @@ interface UseNavBarPress {
|
|
8
8
|
* @callback props.onPressCallback The callback that will be called only if provided
|
9
9
|
*/
|
10
10
|
(params: {
|
11
|
-
key: string;
|
11
|
+
key: string | undefined;
|
12
12
|
onPressCallback?: () => void;
|
13
13
|
}, state: {
|
14
14
|
setSelectedKey: (key: string) => void;
|
@@ -10,9 +10,11 @@ var useNavBarPress = function useNavBarPress(_ref, state) {
|
|
10
10
|
onPressCallback = _ref.onPressCallback;
|
11
11
|
var setSelectedKey = state.setSelectedKey;
|
12
12
|
var onNavPress = function onNavPress() {
|
13
|
-
|
14
|
-
|
15
|
-
onPressCallback
|
13
|
+
if (key) {
|
14
|
+
setSelectedKey(key);
|
15
|
+
if (onPressCallback) {
|
16
|
+
onPressCallback();
|
17
|
+
}
|
16
18
|
}
|
17
19
|
};
|
18
20
|
return {
|
package/lib/cjs/types/index.d.ts
CHANGED
package/lib/cjs/types/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35;
|
3
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35, _context36;
|
4
4
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
5
5
|
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
6
6
|
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
@@ -271,8 +271,19 @@ _forEachInstanceProperty(_context24 = _Object$keys(_Modal)).call(_context24, fun
|
|
271
271
|
}
|
272
272
|
});
|
273
273
|
});
|
274
|
+
var _navBar = require("./navBar");
|
275
|
+
_forEachInstanceProperty(_context25 = _Object$keys(_navBar)).call(_context25, function (key) {
|
276
|
+
if (key === "default" || key === "__esModule") return;
|
277
|
+
if (key in exports && exports[key] === _navBar[key]) return;
|
278
|
+
_Object$defineProperty(exports, key, {
|
279
|
+
enumerable: true,
|
280
|
+
get: function get() {
|
281
|
+
return _navBar[key];
|
282
|
+
}
|
283
|
+
});
|
284
|
+
});
|
274
285
|
var _overlayPanel = require("./overlayPanel");
|
275
|
-
_forEachInstanceProperty(
|
286
|
+
_forEachInstanceProperty(_context26 = _Object$keys(_overlayPanel)).call(_context26, function (key) {
|
276
287
|
if (key === "default" || key === "__esModule") return;
|
277
288
|
if (key in exports && exports[key] === _overlayPanel[key]) return;
|
278
289
|
_Object$defineProperty(exports, key, {
|
@@ -283,7 +294,7 @@ _forEachInstanceProperty(_context25 = _Object$keys(_overlayPanel)).call(_context
|
|
283
294
|
});
|
284
295
|
});
|
285
296
|
var _popoverContainer = require("./popoverContainer");
|
286
|
-
_forEachInstanceProperty(
|
297
|
+
_forEachInstanceProperty(_context27 = _Object$keys(_popoverContainer)).call(_context27, function (key) {
|
287
298
|
if (key === "default" || key === "__esModule") return;
|
288
299
|
if (key in exports && exports[key] === _popoverContainer[key]) return;
|
289
300
|
_Object$defineProperty(exports, key, {
|
@@ -294,7 +305,7 @@ _forEachInstanceProperty(_context26 = _Object$keys(_popoverContainer)).call(_con
|
|
294
305
|
});
|
295
306
|
});
|
296
307
|
var _popoverMenu = require("./popoverMenu");
|
297
|
-
_forEachInstanceProperty(
|
308
|
+
_forEachInstanceProperty(_context28 = _Object$keys(_popoverMenu)).call(_context28, function (key) {
|
298
309
|
if (key === "default" || key === "__esModule") return;
|
299
310
|
if (key in exports && exports[key] === _popoverMenu[key]) return;
|
300
311
|
_Object$defineProperty(exports, key, {
|
@@ -305,7 +316,7 @@ _forEachInstanceProperty(_context27 = _Object$keys(_popoverMenu)).call(_context2
|
|
305
316
|
});
|
306
317
|
});
|
307
318
|
var _requirementsList = require("./requirementsList");
|
308
|
-
_forEachInstanceProperty(
|
319
|
+
_forEachInstanceProperty(_context29 = _Object$keys(_requirementsList)).call(_context29, function (key) {
|
309
320
|
if (key === "default" || key === "__esModule") return;
|
310
321
|
if (key in exports && exports[key] === _requirementsList[key]) return;
|
311
322
|
_Object$defineProperty(exports, key, {
|
@@ -316,7 +327,7 @@ _forEachInstanceProperty(_context28 = _Object$keys(_requirementsList)).call(_con
|
|
316
327
|
});
|
317
328
|
});
|
318
329
|
var _rockerButtonGroup = require("./rockerButtonGroup");
|
319
|
-
_forEachInstanceProperty(
|
330
|
+
_forEachInstanceProperty(_context30 = _Object$keys(_rockerButtonGroup)).call(_context30, function (key) {
|
320
331
|
if (key === "default" || key === "__esModule") return;
|
321
332
|
if (key in exports && exports[key] === _rockerButtonGroup[key]) return;
|
322
333
|
_Object$defineProperty(exports, key, {
|
@@ -327,7 +338,7 @@ _forEachInstanceProperty(_context29 = _Object$keys(_rockerButtonGroup)).call(_co
|
|
327
338
|
});
|
328
339
|
});
|
329
340
|
var _scrollBox = require("./scrollBox");
|
330
|
-
_forEachInstanceProperty(
|
341
|
+
_forEachInstanceProperty(_context31 = _Object$keys(_scrollBox)).call(_context31, function (key) {
|
331
342
|
if (key === "default" || key === "__esModule") return;
|
332
343
|
if (key in exports && exports[key] === _scrollBox[key]) return;
|
333
344
|
_Object$defineProperty(exports, key, {
|
@@ -338,7 +349,7 @@ _forEachInstanceProperty(_context30 = _Object$keys(_scrollBox)).call(_context30,
|
|
338
349
|
});
|
339
350
|
});
|
340
351
|
var _separator = require("./separator");
|
341
|
-
_forEachInstanceProperty(
|
352
|
+
_forEachInstanceProperty(_context32 = _Object$keys(_separator)).call(_context32, function (key) {
|
342
353
|
if (key === "default" || key === "__esModule") return;
|
343
354
|
if (key in exports && exports[key] === _separator[key]) return;
|
344
355
|
_Object$defineProperty(exports, key, {
|
@@ -349,7 +360,7 @@ _forEachInstanceProperty(_context31 = _Object$keys(_separator)).call(_context31,
|
|
349
360
|
});
|
350
361
|
});
|
351
362
|
var _shared = require("./shared");
|
352
|
-
_forEachInstanceProperty(
|
363
|
+
_forEachInstanceProperty(_context33 = _Object$keys(_shared)).call(_context33, function (key) {
|
353
364
|
if (key === "default" || key === "__esModule") return;
|
354
365
|
if (key in exports && exports[key] === _shared[key]) return;
|
355
366
|
_Object$defineProperty(exports, key, {
|
@@ -360,7 +371,7 @@ _forEachInstanceProperty(_context32 = _Object$keys(_shared)).call(_context32, fu
|
|
360
371
|
});
|
361
372
|
});
|
362
373
|
var _table = require("./table");
|
363
|
-
_forEachInstanceProperty(
|
374
|
+
_forEachInstanceProperty(_context34 = _Object$keys(_table)).call(_context34, function (key) {
|
364
375
|
if (key === "default" || key === "__esModule") return;
|
365
376
|
if (key in exports && exports[key] === _table[key]) return;
|
366
377
|
_Object$defineProperty(exports, key, {
|
@@ -371,7 +382,7 @@ _forEachInstanceProperty(_context33 = _Object$keys(_table)).call(_context33, fun
|
|
371
382
|
});
|
372
383
|
});
|
373
384
|
var _text = require("./text");
|
374
|
-
_forEachInstanceProperty(
|
385
|
+
_forEachInstanceProperty(_context35 = _Object$keys(_text)).call(_context35, function (key) {
|
375
386
|
if (key === "default" || key === "__esModule") return;
|
376
387
|
if (key in exports && exports[key] === _text[key]) return;
|
377
388
|
_Object$defineProperty(exports, key, {
|
@@ -382,7 +393,7 @@ _forEachInstanceProperty(_context34 = _Object$keys(_text)).call(_context34, func
|
|
382
393
|
});
|
383
394
|
});
|
384
395
|
var _tooltipTrigger = require("./tooltipTrigger");
|
385
|
-
_forEachInstanceProperty(
|
396
|
+
_forEachInstanceProperty(_context36 = _Object$keys(_tooltipTrigger)).call(_context36, function (key) {
|
386
397
|
if (key === "default" || key === "__esModule") return;
|
387
398
|
if (key in exports && exports[key] === _tooltipTrigger[key]) return;
|
388
399
|
_Object$defineProperty(exports, key, {
|
package/lib/cjs/types/link.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import { ThemeUICSSObject } from 'theme-ui';
|
2
3
|
import { TestingAttributes } from './shared/test';
|
3
4
|
type AS = Extract<keyof JSX.IntrinsicElements, 'a' | 'span'> | undefined;
|
4
5
|
export interface LinkProps extends TestingAttributes {
|
@@ -18,5 +19,8 @@ export interface LinkProps extends TestingAttributes {
|
|
18
19
|
isSafariCompatible?: boolean;
|
19
20
|
className?: string;
|
20
21
|
children?: React.ReactNode;
|
22
|
+
sx?: ThemeUICSSObject;
|
23
|
+
id?: string;
|
24
|
+
color?: string;
|
21
25
|
}
|
22
26
|
export {};
|
@@ -0,0 +1,136 @@
|
|
1
|
+
import React, { Key } from 'react';
|
2
|
+
import { ThemeUICSSObject } from 'theme-ui';
|
3
|
+
import { IconTypeExtended } from './icon';
|
4
|
+
import { DOMAttributes, StyleProps } from './shared';
|
5
|
+
export interface NavBarProps extends StyleProps, DOMAttributes {
|
6
|
+
/** Allows only one item to be expanded. */
|
7
|
+
isAutoСollapsible?: boolean;
|
8
|
+
/** This applies a style to the entire nav tree. the options are default and popup. */
|
9
|
+
variant?: 'default' | 'popupNav';
|
10
|
+
/** Whether or not the focus will return to the previously focused element upon unmount. */
|
11
|
+
hasRestoreFocus?: boolean;
|
12
|
+
/** The initial selected key in the collection (uncontrolled). */
|
13
|
+
defaultSelectedKey?: string;
|
14
|
+
/** The initial expanded keys in the collection (uncontrolled). */
|
15
|
+
defaultExpandedKeys?: Iterable<Key>;
|
16
|
+
/** The selected key in the collection (controlled). */
|
17
|
+
selectedKey?: Iterable<Key>;
|
18
|
+
/**
|
19
|
+
* Callback function that fires when the selected key changes.
|
20
|
+
*
|
21
|
+
* `(selectedKey: String) => void`
|
22
|
+
*/
|
23
|
+
setSelectedKey?: React.Dispatch<React.SetStateAction<string>>;
|
24
|
+
children?: React.ReactNode;
|
25
|
+
}
|
26
|
+
export interface NavBarItemProps extends StyleProps, DOMAttributes {
|
27
|
+
/** Handler that is called when the press is released over the target. */
|
28
|
+
onPress?: () => void;
|
29
|
+
/** The icon to render in between each node. */
|
30
|
+
icon?: IconTypeExtended;
|
31
|
+
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
32
|
+
id?: string;
|
33
|
+
/** Text that will render within the component */
|
34
|
+
text?: string;
|
35
|
+
className?: string;
|
36
|
+
}
|
37
|
+
export interface NavBarItemBodyProps {
|
38
|
+
item?: {
|
39
|
+
children?: string[] | object[];
|
40
|
+
key?: string;
|
41
|
+
};
|
42
|
+
onKeyDown?: (...args: unknown[]) => void;
|
43
|
+
}
|
44
|
+
export interface ChildItemWrapperProps {
|
45
|
+
children?: {
|
46
|
+
[key: string]: string[] | object[] | React.ReactNode;
|
47
|
+
};
|
48
|
+
onKeyDown?: (...args: unknown[]) => void;
|
49
|
+
}
|
50
|
+
export interface NavBarItemButtonProps {
|
51
|
+
/** Handler that is called when the press is released over the target. */
|
52
|
+
onPress?: () => void;
|
53
|
+
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
54
|
+
id: string;
|
55
|
+
className?: string;
|
56
|
+
sx?: ThemeUICSSObject;
|
57
|
+
children?: React.ReactNode;
|
58
|
+
}
|
59
|
+
export interface NavBarItemHeaderProps {
|
60
|
+
item: {
|
61
|
+
children?: string[] | object[];
|
62
|
+
href?: string;
|
63
|
+
};
|
64
|
+
}
|
65
|
+
export interface NavBarSectionItemHeaderProps {
|
66
|
+
item: {
|
67
|
+
heading?: string;
|
68
|
+
icon?: IconTypeExtended;
|
69
|
+
className?: string;
|
70
|
+
children?: string[] | object[];
|
71
|
+
key?: string;
|
72
|
+
href?: string;
|
73
|
+
};
|
74
|
+
}
|
75
|
+
export interface NavBarPrimaryItemHeaderProps {
|
76
|
+
item: {
|
77
|
+
heading?: string;
|
78
|
+
icon?: IconTypeExtended;
|
79
|
+
className?: string;
|
80
|
+
customIcon?: IconTypeExtended;
|
81
|
+
children?: string[] | object[] | undefined;
|
82
|
+
href?: string | undefined;
|
83
|
+
};
|
84
|
+
}
|
85
|
+
export interface NavBarItemLinkProps {
|
86
|
+
/** Specifies the location of the URL */
|
87
|
+
href?: string;
|
88
|
+
/** Handler that is called when the press is released over the target. */
|
89
|
+
onPress?: () => void;
|
90
|
+
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
91
|
+
id: string;
|
92
|
+
className?: string;
|
93
|
+
sx?: ThemeUICSSObject;
|
94
|
+
children?: React.ReactNode | string;
|
95
|
+
variant?: string;
|
96
|
+
onClick?: (e: Event) => void;
|
97
|
+
}
|
98
|
+
export interface NavBarSectionProps<T> {
|
99
|
+
/** If true, a separator will render at the end of the section */
|
100
|
+
hasSeparator?: boolean;
|
101
|
+
/** callback that runs on key down */
|
102
|
+
onKeyDown?: () => void;
|
103
|
+
/** If present, this string will render at the top of the section */
|
104
|
+
title?: string;
|
105
|
+
/**
|
106
|
+
* *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
|
107
|
+
* For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
|
108
|
+
*/
|
109
|
+
items?: Iterable<T>;
|
110
|
+
}
|
111
|
+
export interface ChildrenProps {
|
112
|
+
key?: string;
|
113
|
+
}
|
114
|
+
export interface SectionItemProps<T> {
|
115
|
+
onKeyDown?: (...arg: unknown[]) => void;
|
116
|
+
item?: {
|
117
|
+
key?: string;
|
118
|
+
children?: Array<ChildrenProps>;
|
119
|
+
'aria-label'?: string;
|
120
|
+
};
|
121
|
+
state?: {
|
122
|
+
collection?: Iterable<T>;
|
123
|
+
selectedKey?: string;
|
124
|
+
setSelectedKey?: () => void;
|
125
|
+
selectionManager?: {
|
126
|
+
focusedKey?: string;
|
127
|
+
setFocusedKey?: () => void;
|
128
|
+
};
|
129
|
+
};
|
130
|
+
menuProps?: StyleProps;
|
131
|
+
}
|
132
|
+
export interface PrimaryItemProps {
|
133
|
+
item: {
|
134
|
+
href?: string;
|
135
|
+
};
|
136
|
+
}
|
@@ -6,14 +6,13 @@ import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array
|
|
6
6
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
7
7
|
import React, { forwardRef, useMemo, useState } from 'react';
|
8
8
|
import { FocusScope, useFocusManager } from '@react-aria/focus';
|
9
|
-
import PropTypes from 'prop-types';
|
10
9
|
import { NavBarContext } from '../../context/NavBarContext';
|
11
10
|
import useNavBarStyling from '../../hooks/useNavBarStyling/useNavBarStyling';
|
12
11
|
import useProgressiveState from '../../hooks/useProgressiveState';
|
13
|
-
import { isIterableProp } from '../../utils/devUtils/props/isIterable';
|
14
12
|
import Box from '../Box/Box';
|
15
13
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
16
14
|
var NavBar = /*#__PURE__*/forwardRef(function (props, ref) {
|
15
|
+
var _children$;
|
17
16
|
var isAutoСollapsible = props.isAutoСollapsible,
|
18
17
|
defaultSelectedKey = props.defaultSelectedKey,
|
19
18
|
selectedKeyProp = props.selectedKey,
|
@@ -23,7 +22,7 @@ var NavBar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
23
22
|
children = props.children,
|
24
23
|
variant = props.variant,
|
25
24
|
others = _objectWithoutProperties(props, _excluded);
|
26
|
-
var initialExpandedKeys = isAutoСollapsible && defaultExpandedKeys.length ? defaultExpandedKeys[0] : defaultExpandedKeys;
|
25
|
+
var initialExpandedKeys = isAutoСollapsible && _Array$isArray(defaultExpandedKeys) && defaultExpandedKeys.length ? defaultExpandedKeys[0] : defaultExpandedKeys;
|
27
26
|
var _useState = useState(initialExpandedKeys),
|
28
27
|
_useState2 = _slicedToArray(_useState, 2),
|
29
28
|
expandedKeys = _useState2[0],
|
@@ -40,7 +39,7 @@ var NavBar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
40
39
|
};
|
41
40
|
}) : [{
|
42
41
|
item: children,
|
43
|
-
key: children
|
42
|
+
key: !children ? '' : (_children$ = children[0]) === null || _children$ === void 0 ? void 0 : _children$.key
|
44
43
|
}];
|
45
44
|
var contextValue = useMemo(function () {
|
46
45
|
return {
|
@@ -61,11 +60,11 @@ var NavBar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
61
60
|
as: "nav"
|
62
61
|
}, others), items.length ? ___EmotionJSX(FocusScope, {
|
63
62
|
restoreFocus: hasRestoreFocus
|
64
|
-
}, _mapInstanceProperty(items).call(items, function (_ref) {
|
63
|
+
}, _mapInstanceProperty(items).call(items, function (_ref, index) {
|
65
64
|
var item = _ref.item,
|
66
65
|
key = _ref.key;
|
67
66
|
return ___EmotionJSX(FocusableItem, {
|
68
|
-
key: key
|
67
|
+
key: key || "key".concat(index)
|
69
68
|
}, item);
|
70
69
|
})) : null));
|
71
70
|
});
|
@@ -92,26 +91,6 @@ var FocusableItem = function FocusableItem(props) {
|
|
92
91
|
});
|
93
92
|
return childWithFocusHandle;
|
94
93
|
};
|
95
|
-
NavBar.propTypes = {
|
96
|
-
/** Allows only one item to be expanded. */
|
97
|
-
isAutoСollapsible: PropTypes.bool,
|
98
|
-
/** This applies a style to the entire nav tree. the options are default and popup. */
|
99
|
-
variant: PropTypes.oneOf(['default', 'popupNav']),
|
100
|
-
/** Whether or not the focus will return to the previously focused element upon unmount. */
|
101
|
-
hasRestoreFocus: PropTypes.bool,
|
102
|
-
/** The initial selected key in the collection (uncontrolled). */
|
103
|
-
defaultSelectedKey: PropTypes.string,
|
104
|
-
/** The initial expanded keys in the collection (uncontrolled). */
|
105
|
-
defaultExpandedKeys: isIterableProp,
|
106
|
-
/** The selected key in the collection (controlled). */
|
107
|
-
selectedKey: isIterableProp,
|
108
|
-
/**
|
109
|
-
* Callback function that fires when the selected key changes.
|
110
|
-
*
|
111
|
-
* `(selectedKey: String) => void`
|
112
|
-
*/
|
113
|
-
setSelectedKey: PropTypes.func
|
114
|
-
};
|
115
94
|
NavBar.defaultProps = {
|
116
95
|
isAutoСollapsible: false,
|
117
96
|
defaultSelectedKey: '',
|
@@ -14,7 +14,7 @@ import ViewGridPlusOutline from '@pingux/mdi-react/ViewGridPlusOutlineIcon';
|
|
14
14
|
import { withDesign } from 'storybook-addon-designs';
|
15
15
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
16
16
|
import { Box, Link, NavBar, NavBarItem, NavBarItemButton, NavBarItemLink, NavBarSection, Separator } from '../../index';
|
17
|
-
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks
|
17
|
+
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
|
18
18
|
import NavBarReadme from './NavBar.mdx';
|
19
19
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
20
20
|
export default {
|
@@ -1,12 +1,11 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
3
|
var _excluded = ["icon", "text", "className", "id", "onPress"];
|
4
|
-
import React, { forwardRef, useImperativeHandle
|
4
|
+
import React, { forwardRef, useImperativeHandle } from 'react';
|
5
5
|
import { mergeProps, useFocusRing } from 'react-aria';
|
6
6
|
import { useHover, usePress } from '@react-aria/interactions';
|
7
|
-
import PropTypes from 'prop-types';
|
8
7
|
import { useNavBarContext } from '../../context/NavBarContext';
|
9
|
-
import { useNavBarPress, useStatusClasses } from '../../hooks';
|
8
|
+
import { useLocalOrForwardRef, useNavBarPress, useStatusClasses } from '../../hooks';
|
10
9
|
import { Box, Icon, Text } from '../../index';
|
11
10
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
12
11
|
var NavBarItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
@@ -16,7 +15,7 @@ var NavBarItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
16
15
|
key = props.id,
|
17
16
|
onPressCallback = props.onPress,
|
18
17
|
others = _objectWithoutProperties(props, _excluded);
|
19
|
-
var navItemRef =
|
18
|
+
var navItemRef = useLocalOrForwardRef(null);
|
20
19
|
|
21
20
|
/* istanbul ignore next */
|
22
21
|
useImperativeHandle(ref, function () {
|
@@ -85,14 +84,4 @@ var NavBarItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
85
84
|
variant: state.navStyles.navBarItemText
|
86
85
|
}, text)));
|
87
86
|
});
|
88
|
-
NavBarItem.propTypes = {
|
89
|
-
/** Handler that is called when the press is released over the target. */
|
90
|
-
onPress: PropTypes.func,
|
91
|
-
/** The icon to render in between each node. */
|
92
|
-
icon: PropTypes.elementType,
|
93
|
-
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
94
|
-
id: PropTypes.string,
|
95
|
-
/** Text that will render within the component */
|
96
|
-
text: PropTypes.string
|
97
|
-
};
|
98
87
|
export default NavBarItem;
|
@@ -35,28 +35,23 @@ var NavBarItemBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
35
35
|
return ___EmotionJSX(Box, {
|
36
36
|
variant: state.navStyles.navBarItemBody,
|
37
37
|
ref: ref
|
38
|
-
}, _mapInstanceProperty(_context = item.children).call(_context, renderChild));
|
38
|
+
}, (item === null || item === void 0 ? void 0 : item.children) && _mapInstanceProperty(_context = item.children).call(_context, renderChild));
|
39
39
|
});
|
40
40
|
var ChildItemWrapper = function ChildItemWrapper(_ref2) {
|
41
41
|
var children = _ref2.children,
|
42
42
|
_onKeyDown = _ref2.onKeyDown;
|
43
|
-
var childrenKey = children.key || children;
|
43
|
+
var childrenKey = (children === null || children === void 0 ? void 0 : children.key) || children;
|
44
44
|
var _useKeyboard = useKeyboard({
|
45
45
|
onKeyDown: function onKeyDown(e) {
|
46
|
-
return _onKeyDown(e, childrenKey);
|
46
|
+
return _onKeyDown ? _onKeyDown(e, childrenKey) : undefined;
|
47
47
|
}
|
48
48
|
}),
|
49
49
|
keyboardProps = _useKeyboard.keyboardProps;
|
50
50
|
return ___EmotionJSX(Box, _extends({
|
51
51
|
width: "100%"
|
52
|
-
}, keyboardProps
|
53
|
-
|
54
|
-
|
55
|
-
item: PropTypes.shape({
|
56
|
-
children: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])),
|
57
|
-
key: PropTypes.string
|
58
|
-
}),
|
59
|
-
onKeyDown: PropTypes.func
|
52
|
+
}, keyboardProps, {
|
53
|
+
role: "none"
|
54
|
+
}), ___EmotionJSX(React.Fragment, null, ' ', children && children));
|
60
55
|
};
|
61
56
|
ChildItemWrapper.propTypes = {
|
62
57
|
onKeyDown: PropTypes.func
|