@pingux/astro 2.81.0-alpha.0 → 2.81.0-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.
Files changed (59) hide show
  1. package/lib/cjs/components/NavBar/NavBar.styles.d.ts +30 -0
  2. package/lib/cjs/components/NavBar/NavBar.styles.js +34 -1
  3. package/lib/cjs/components/NavBarSection/NavBarItemLink.js +1 -4
  4. package/lib/cjs/components/NavSideBar/Icon.test.d.ts +1 -0
  5. package/lib/cjs/components/NavSideBar/Icon.test.js +67 -0
  6. package/lib/cjs/components/NavSideBar/NavSideBar.d.ts +4 -0
  7. package/lib/cjs/components/NavSideBar/NavSideBar.js +115 -0
  8. package/lib/cjs/components/NavSideBar/NavSideBar.mdx +42 -0
  9. package/lib/cjs/components/NavSideBar/NavSideBar.stories.d.ts +8 -0
  10. package/lib/cjs/components/NavSideBar/NavSideBar.stories.js +1344 -0
  11. package/lib/cjs/components/NavSideBar/NavSideBar.test.d.ts +1 -0
  12. package/lib/cjs/components/NavSideBar/NavSideBar.test.js +311 -0
  13. package/lib/cjs/components/NavSideBar/NavSideBarHeader.d.ts +4 -0
  14. package/lib/cjs/components/NavSideBar/NavSideBarHeader.js +33 -0
  15. package/lib/cjs/components/NavSideBar/NavSideBarItem.d.ts +4 -0
  16. package/lib/cjs/components/NavSideBar/NavSideBarItem.js +112 -0
  17. package/lib/cjs/components/NavSideBar/NavSideBarSection.d.ts +4 -0
  18. package/lib/cjs/components/NavSideBar/NavSideBarSection.js +122 -0
  19. package/lib/cjs/components/NavSideBar/NavSideBarSectionHeader.d.ts +4 -0
  20. package/lib/cjs/components/NavSideBar/NavSideBarSectionHeader.js +98 -0
  21. package/lib/cjs/components/NavSideBar/NavSideBarSectionItem.d.ts +4 -0
  22. package/lib/cjs/components/NavSideBar/NavSideBarSectionItem.js +81 -0
  23. package/lib/cjs/components/NavSideBar/NavSideBarSubTitle.d.ts +4 -0
  24. package/lib/cjs/components/NavSideBar/NavSideBarSubTitle.js +25 -0
  25. package/lib/cjs/components/NavSideBar/icons.d.ts +15 -0
  26. package/lib/cjs/components/NavSideBar/icons.js +174 -0
  27. package/lib/cjs/components/NavSideBar/index.d.ts +5 -0
  28. package/lib/cjs/components/NavSideBar/index.js +42 -0
  29. package/lib/cjs/hooks/useNavBarStyling/useNavBarStyling.d.ts +1 -0
  30. package/lib/cjs/hooks/useNavBarStyling/useNavBarStyling.js +14 -3
  31. package/lib/cjs/hooks/useNavBarStyling/useNavBarStyling.test.js +1 -1
  32. package/lib/cjs/index.d.ts +2 -0
  33. package/lib/cjs/index.js +54 -35
  34. package/lib/cjs/types/index.d.ts +1 -0
  35. package/lib/cjs/types/index.js +28 -17
  36. package/lib/cjs/types/link.d.ts +1 -0
  37. package/lib/cjs/types/navSideBar.d.ts +75 -0
  38. package/lib/cjs/types/navSideBar.js +6 -0
  39. package/lib/components/NavBar/NavBar.styles.js +34 -1
  40. package/lib/components/NavBarSection/NavBarItemLink.js +1 -4
  41. package/lib/components/NavSideBar/Icon.test.js +58 -0
  42. package/lib/components/NavSideBar/NavSideBar.js +101 -0
  43. package/lib/components/NavSideBar/NavSideBar.mdx +42 -0
  44. package/lib/components/NavSideBar/NavSideBar.stories.js +1326 -0
  45. package/lib/components/NavSideBar/NavSideBar.test.js +308 -0
  46. package/lib/components/NavSideBar/NavSideBarHeader.js +19 -0
  47. package/lib/components/NavSideBar/NavSideBarItem.js +98 -0
  48. package/lib/components/NavSideBar/NavSideBarSection.js +108 -0
  49. package/lib/components/NavSideBar/NavSideBarSectionHeader.js +84 -0
  50. package/lib/components/NavSideBar/NavSideBarSectionItem.js +69 -0
  51. package/lib/components/NavSideBar/NavSideBarSubTitle.js +16 -0
  52. package/lib/components/NavSideBar/icons.js +102 -0
  53. package/lib/components/NavSideBar/index.js +5 -0
  54. package/lib/hooks/useNavBarStyling/useNavBarStyling.js +14 -3
  55. package/lib/hooks/useNavBarStyling/useNavBarStyling.test.js +1 -1
  56. package/lib/index.js +2 -0
  57. package/lib/types/index.js +1 -0
  58. package/lib/types/navSideBar.js +1 -0
  59. package/package.json +1 -1
@@ -120,6 +120,7 @@ var sectionBody = _objectSpread(_objectSpread({}, accordionGrid.body), {}, {
120
120
  pl: '0'
121
121
  });
122
122
  var itemButton = {
123
+ marginY: '2px',
123
124
  textDecoration: 'none',
124
125
  outline: 'none',
125
126
  cursor: 'pointer',
@@ -289,6 +290,32 @@ var navBarItemBody = {
289
290
  var popUpNavBarItemBody = _objectSpread(_objectSpread({}, navBarItemBody), {}, {
290
291
  mb: 0
291
292
  });
293
+ var itemLinkButtonColor = {
294
+ color: 'white'
295
+ };
296
+ var sectionList = {
297
+ margin: 0,
298
+ padding: 0,
299
+ listStyle: 'none'
300
+ };
301
+ var itemIcon = {
302
+ mr: 'sm',
303
+ color: 'neutral.95',
304
+ fill: 'neutral.95'
305
+ };
306
+ var itemIconSelected = _objectSpread(_objectSpread({}, itemIcon), {}, {
307
+ color: 'white',
308
+ fill: 'white'
309
+ });
310
+ var itemCustomIcon = {
311
+ color: 'neutral.95',
312
+ fill: 'neutral.95',
313
+ ml: 'auto'
314
+ };
315
+ var itemCustomIconSelected = _objectSpread(_objectSpread({}, itemCustomIcon), {}, {
316
+ color: 'white',
317
+ fill: 'white'
318
+ });
292
319
  export default {
293
320
  container: container,
294
321
  popUpContainer: popUpContainer,
@@ -309,5 +336,11 @@ export default {
309
336
  item: item,
310
337
  popUpItem: popUpItem,
311
338
  navBarItemBody: navBarItemBody,
312
- popUpNavBarItemBody: popUpNavBarItemBody
339
+ popUpNavBarItemBody: popUpNavBarItemBody,
340
+ itemLinkButtonColor: itemLinkButtonColor,
341
+ sectionList: sectionList,
342
+ itemIcon: itemIcon,
343
+ itemIconSelected: itemIconSelected,
344
+ itemCustomIcon: itemCustomIcon,
345
+ itemCustomIconSelected: itemCustomIconSelected
313
346
  };
@@ -40,10 +40,7 @@ var NavBarItemLink = function NavBarItemLink(props) {
40
40
  onPress: onNavPress,
41
41
  color: isSelected ? 'white' : undefined
42
42
  }, others, {
43
- sx: _objectSpread({
44
- paddingLeft: '45px',
45
- paddingRight: 'md'
46
- }, props.sx)
43
+ sx: _objectSpread({}, props.sx)
47
44
  }));
48
45
  };
49
46
  export default NavBarItemLink;
@@ -0,0 +1,58 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import React, { forwardRef } from 'react';
3
+ import { render, screen } from '@testing-library/react';
4
+ import { Icon } from '../../index';
5
+ import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
6
+ import { Credentials, Verify } from './icons';
7
+ import { jsx as ___EmotionJSX } from "@emotion/react";
8
+ var testId = 'test-icon';
9
+ var defaultProps = {
10
+ 'data-testid': testId
11
+ };
12
+ var getComponent = function getComponent() {
13
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14
+ return render(___EmotionJSX(Icon, _extends({}, defaultProps, props)));
15
+ };
16
+
17
+ // The mdi-react and @pingux/mid-react libraries don't support ref forwarding
18
+ // A simple implementation of an SVG component demonstrates ref forwarding
19
+ var SVGTestComponent = /*#__PURE__*/forwardRef(function (props, ref) {
20
+ return ___EmotionJSX("svg", _extends({
21
+ ref: ref
22
+ }, props, {
23
+ "aria-labelledby": "id"
24
+ }), ___EmotionJSX("title", {
25
+ id: "id"
26
+ }, "title"));
27
+ });
28
+
29
+ // Needs to be added to each components test file
30
+ universalComponentTests({
31
+ renderComponent: function renderComponent(props) {
32
+ return ___EmotionJSX(Icon, _extends({
33
+ icon: SVGTestComponent
34
+ }, props));
35
+ }
36
+ });
37
+ test('Credentials icon', function () {
38
+ getComponent({
39
+ icon: Credentials,
40
+ title: {
41
+ name: 'Credentials Icon'
42
+ }
43
+ });
44
+ var icon = screen.getByTestId(testId);
45
+ expect(icon).toBeInstanceOf(SVGSVGElement);
46
+ expect(icon).toBeInTheDocument();
47
+ });
48
+ test('Verify icon', function () {
49
+ getComponent({
50
+ icon: Verify,
51
+ title: {
52
+ name: 'Verify Icon'
53
+ }
54
+ });
55
+ var icon = screen.getByTestId(testId);
56
+ expect(icon).toBeInstanceOf(SVGSVGElement);
57
+ expect(icon).toBeInTheDocument();
58
+ });
@@ -0,0 +1,101 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
4
+ var _excluded = ["isAuto\u0421ollapsible", "defaultSelectedKey", "selectedKey", "setSelectedKey", "hasRestoreFocus", "defaultExpandedKeys", "children", "variant"];
5
+ import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
6
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
7
+ import React, { forwardRef, useMemo, useState } from 'react';
8
+ import { FocusScope, useFocusManager } from '@react-aria/focus';
9
+ import { NavBarContext } from '../../context/NavBarContext';
10
+ import { useLocalOrForwardRef } from '../../hooks';
11
+ import useNavBarStyling from '../../hooks/useNavBarStyling/useNavBarStyling';
12
+ import useProgressiveState from '../../hooks/useProgressiveState';
13
+ import Box from '../Box/Box';
14
+ import { jsx as ___EmotionJSX } from "@emotion/react";
15
+ var NavSideBar = /*#__PURE__*/forwardRef(function (props, ref) {
16
+ var _context;
17
+ var isAutoСollapsible = props.isAutoСollapsible,
18
+ defaultSelectedKey = props.defaultSelectedKey,
19
+ selectedKeyProp = props.selectedKey,
20
+ setSelectedKeyProp = props.setSelectedKey,
21
+ hasRestoreFocus = props.hasRestoreFocus,
22
+ defaultExpandedKeys = props.defaultExpandedKeys,
23
+ children = props.children,
24
+ variant = props.variant,
25
+ others = _objectWithoutProperties(props, _excluded);
26
+ var initialExpandedKeys = isAutoСollapsible && _Array$isArray(defaultExpandedKeys) && defaultExpandedKeys.length ? defaultExpandedKeys[0] : defaultExpandedKeys;
27
+ var _useState = useState(initialExpandedKeys),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ expandedKeys = _useState2[0],
30
+ setExpandedKeys = _useState2[1];
31
+ var _useProgressiveState = useProgressiveState(selectedKeyProp, defaultSelectedKey),
32
+ _useProgressiveState2 = _slicedToArray(_useProgressiveState, 2),
33
+ selectedKey = _useProgressiveState2[0],
34
+ setSelectedKey = _useProgressiveState2[1];
35
+ var navStyles = useNavBarStyling(variant || 'default');
36
+ var items = _mapInstanceProperty(_context = React.Children.toArray(children)).call(_context, function (child) {
37
+ return {
38
+ item: child,
39
+ key: /*#__PURE__*/React.isValidElement(child) ? child.key : ''
40
+ };
41
+ });
42
+ var contextValue = useMemo(function () {
43
+ return {
44
+ isAutoСollapsible: isAutoСollapsible,
45
+ selectedKey: selectedKey,
46
+ setSelectedKey: setSelectedKeyProp || setSelectedKey,
47
+ expandedKeys: expandedKeys,
48
+ setExpandedKeys: setExpandedKeys,
49
+ navStyles: navStyles
50
+ };
51
+ }, [isAutoСollapsible, selectedKey, setSelectedKeyProp, setSelectedKey, expandedKeys, setExpandedKeys, navStyles]);
52
+ var navSideBarRef = useLocalOrForwardRef(ref);
53
+ return ___EmotionJSX(NavBarContext.Provider, {
54
+ value: contextValue
55
+ }, ___EmotionJSX(Box, _extends({
56
+ ref: navSideBarRef,
57
+ variant: navStyles.navBar,
58
+ role: "navigation",
59
+ as: "nav"
60
+ }, others), items.length ? ___EmotionJSX(FocusScope, {
61
+ restoreFocus: hasRestoreFocus
62
+ }, _mapInstanceProperty(items).call(items, function (_ref, index) {
63
+ var item = _ref.item,
64
+ key = _ref.key;
65
+ return ___EmotionJSX(FocusableItem, {
66
+ key: key || "key".concat(index)
67
+ }, item);
68
+ })) : null));
69
+ });
70
+ var FocusableItem = function FocusableItem(props) {
71
+ var focusManager = useFocusManager();
72
+ var onKeyDown = function onKeyDown(e) {
73
+ switch (e.key) {
74
+ case 'ArrowRight':
75
+ case 'ArrowDown':
76
+ e.preventDefault();
77
+ focusManager.focusNext();
78
+ break;
79
+ case 'ArrowLeft':
80
+ case 'ArrowUp':
81
+ e.preventDefault();
82
+ focusManager.focusPrevious();
83
+ break;
84
+ default:
85
+ break;
86
+ }
87
+ };
88
+ var childWithFocusHandle = /*#__PURE__*/React.cloneElement(props.children, {
89
+ onKeyDown: onKeyDown
90
+ });
91
+ return childWithFocusHandle;
92
+ };
93
+ NavSideBar.defaultProps = {
94
+ isAutoСollapsible: false,
95
+ defaultSelectedKey: '',
96
+ defaultExpandedKeys: [],
97
+ variant: 'default',
98
+ hasRestoreFocus: true
99
+ };
100
+ NavSideBar.displayName = 'NavSideBar';
101
+ export default NavSideBar;
@@ -0,0 +1,42 @@
1
+ import { Meta } from '@storybook/addon-docs';
2
+
3
+ <Meta title="Components/NavSideBar/NavSideBar" />
4
+
5
+ # NavSideBar
6
+
7
+ The NavSideBar component is primarily to navigate within apps.
8
+ This component is built to have the NavSideBarSection component passed into it. Inside the NavSideBarSection, the NavSideBarSectionItem is passed.
9
+
10
+ The NavSideBar should:
11
+ - Be visually separate from the content.
12
+ - Have descriptive titles describing the destination, action item or category.
13
+ - Group navigation items into sections based on related categories.
14
+ - Order content logically for a natural progression.
15
+
16
+ ### Required Components
17
+
18
+ This component requires these components:
19
+ - NavSideBarHeader
20
+ - NavSideBarItem
21
+ - NavSideBarSectionItem
22
+ - NavSideBarSection
23
+
24
+ ### Accessibility
25
+
26
+ #### Keyboard Navigation
27
+
28
+ These keys provide additional functionality to the component.
29
+
30
+ | Key | Functions |
31
+ | ---- | ---- |
32
+ | Tab | All of the content in the NavSideBar is focusable. |
33
+ | Shift + Tab | Moves focus to the previous focusable component. |
34
+ | Space or Enter | Toggles the component when the accordion is focused. |
35
+ | Arrow keys | All components within the NavSideBar are accessible using arrow keys. |
36
+ | Esc | Pressing the escape key when the accordion is open and focused collapses the component. |
37
+
38
+ #### Screen readers
39
+
40
+ This component uses the following attributes to assist screen readers:
41
+ - Each Link component uses the **`aria-label`** attribute to provide an accessible name.
42
+ - The Icon uses the **`aria-hidden`** attribute to hide its content from assistive technology.