@pingux/astro 1.2.0-alpha.8 → 1.3.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/CHANGELOG.md +64 -0
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +35 -22
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +148 -169
- package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +25 -30
- package/lib/cjs/components/AccordionGridItem/AccordionGridItem.js +29 -14
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +8 -5
- package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +20 -17
- package/lib/cjs/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +20 -1
- package/lib/cjs/components/ArrayField/ArrayField.js +213 -0
- package/lib/cjs/components/ArrayField/ArrayField.stories.js +223 -0
- package/lib/cjs/components/ArrayField/ArrayField.test.js +208 -0
- package/lib/cjs/components/ArrayField/ArrayFieldDeleteButton.js +61 -0
- package/lib/cjs/components/ArrayField/index.js +27 -0
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/cjs/components/Button/Button.js +14 -2
- package/lib/cjs/components/Button/Button.stories.js +33 -33
- package/lib/cjs/components/CodeView/CodeView.js +3 -3
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
- package/lib/cjs/components/Link/Link.js +2 -1
- package/lib/cjs/components/ListView/ListView.js +9 -13
- package/lib/cjs/components/ListView/ListView.stories.js +3 -0
- package/lib/cjs/components/ListViewItem/ListViewItem.js +15 -3
- package/lib/cjs/components/Loader/Loader.stories.js +3 -3
- package/lib/cjs/components/Modal/Modal.js +3 -0
- package/lib/cjs/components/Modal/Modal.stories.js +12 -67
- package/lib/cjs/components/NavBar/NavBar.js +30 -4
- package/lib/cjs/components/NavBar/NavBar.stories.js +70 -463
- package/lib/cjs/components/NavBar/NavBar.test.js +51 -1
- package/lib/cjs/components/NavBarSection/NavBarItem.js +137 -0
- package/lib/cjs/components/NavBarSection/NavBarItemButton.js +96 -0
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +1 -1
- package/lib/cjs/components/NavBarSection/NavBarItemLink.js +98 -0
- package/lib/cjs/components/NavBarSection/NavBarSection.js +10 -8
- package/lib/cjs/components/NavBarSection/index.js +28 -1
- package/lib/cjs/components/OverlayPanel/OverlayPanel.js +2 -16
- package/lib/cjs/components/OverlayPanel/OverlayPanel.test.js +44 -0
- package/lib/cjs/components/RockerButton/RockerButton.js +14 -22
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.stories.js +4 -22
- package/lib/cjs/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -14
- package/lib/cjs/components/SearchField/SearchField.stories.js +1 -15
- package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +8 -1
- package/lib/cjs/components/TextAreaField/TextAreaField.js +54 -9
- package/lib/cjs/components/TextAreaField/TextAreaField.stories.js +31 -52
- package/lib/cjs/components/TextAreaField/TextAreaField.test.js +12 -0
- package/lib/cjs/context/AccordionGridContext/index.js +20 -0
- package/lib/cjs/context/NavBarContext/index.js +20 -0
- package/lib/cjs/hooks/index.js +9 -0
- package/lib/cjs/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/cjs/hooks/useField/useField.js +5 -0
- package/lib/cjs/{components/AccordionGridGroup/AccordionGridContext.js → hooks/useNavBarPress/index.js} +7 -6
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.js +38 -0
- package/lib/cjs/hooks/useNavBarPress/useNavBarPress.test.js +42 -0
- package/lib/cjs/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/cjs/index.js +80 -58
- package/lib/cjs/layouts/ListLayout.stories.js +6 -6
- package/lib/cjs/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/cjs/styles/variants/accordion.js +39 -7
- package/lib/cjs/styles/variants/boxes.js +10 -24
- package/lib/cjs/styles/variants/buttons.js +27 -1
- package/lib/cjs/styles/variants/codeView.js +91 -0
- package/lib/cjs/styles/variants/navBar.js +68 -0
- package/lib/cjs/styles/variants/separator.js +2 -1
- package/lib/cjs/styles/variants/text.js +3 -1
- package/lib/cjs/styles/variants/variants.js +3 -0
- package/lib/components/AccordionGridGroup/AccordionGridGroup.js +35 -22
- package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +143 -166
- package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -25
- package/lib/components/AccordionGridItem/AccordionGridItem.js +29 -15
- package/lib/components/AccordionGridItem/AccordionGridItemBody.js +8 -6
- package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +22 -18
- package/lib/components/AccordionGroup/AccordionGroup.js +2 -1
- package/lib/components/AccordionGroup/AccordionGroup.test.js +16 -2
- package/lib/components/ArrayField/ArrayField.js +179 -0
- package/lib/components/ArrayField/ArrayField.stories.js +196 -0
- package/lib/components/ArrayField/ArrayField.test.js +185 -0
- package/lib/components/ArrayField/ArrayFieldDeleteButton.js +43 -0
- package/lib/components/ArrayField/index.js +2 -0
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -3
- package/lib/components/Button/Button.js +15 -3
- package/lib/components/Button/Button.stories.js +17 -15
- package/lib/components/CodeView/CodeView.js +2 -2
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +5 -3
- package/lib/components/Link/Link.js +2 -1
- package/lib/components/ListView/ListView.js +9 -12
- package/lib/components/ListView/ListView.stories.js +3 -0
- package/lib/components/ListViewItem/ListViewItem.js +14 -3
- package/lib/components/Loader/Loader.stories.js +1 -1
- package/lib/components/Modal/Modal.js +4 -1
- package/lib/components/Modal/Modal.stories.js +11 -60
- package/lib/components/NavBar/NavBar.js +25 -4
- package/lib/components/NavBar/NavBar.stories.js +71 -462
- package/lib/components/NavBar/NavBar.test.js +39 -2
- package/lib/components/NavBarSection/NavBarItem.js +111 -0
- package/lib/components/NavBarSection/NavBarItemButton.js +69 -0
- package/lib/components/NavBarSection/NavBarItemHeader.js +1 -1
- package/lib/components/NavBarSection/NavBarItemLink.js +71 -0
- package/lib/components/NavBarSection/NavBarSection.js +9 -8
- package/lib/components/NavBarSection/index.js +4 -1
- package/lib/components/OverlayPanel/OverlayPanel.js +3 -16
- package/lib/components/OverlayPanel/OverlayPanel.test.js +38 -0
- package/lib/components/RockerButton/RockerButton.js +14 -21
- package/lib/components/RockerButtonGroup/RockerButtonGroup.js +5 -9
- package/lib/components/RockerButtonGroup/RockerButtonGroup.stories.js +2 -17
- package/lib/components/RockerButtonGroup/RockerButtonGroup.test.js +5 -11
- package/lib/components/SearchField/SearchField.stories.js +0 -11
- package/lib/components/SelectFieldBase/SelectFieldBase.js +8 -1
- package/lib/components/TextAreaField/TextAreaField.js +54 -10
- package/lib/components/TextAreaField/TextAreaField.stories.js +26 -42
- package/lib/components/TextAreaField/TextAreaField.test.js +13 -0
- package/lib/context/AccordionGridContext/index.js +5 -0
- package/lib/context/NavBarContext/index.js +5 -0
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useAriaLabelWarning/useAriaLabelWarning.js +2 -1
- package/lib/hooks/useField/useField.js +5 -0
- package/lib/hooks/useNavBarPress/index.js +1 -0
- package/lib/hooks/useNavBarPress/useNavBarPress.js +27 -0
- package/lib/hooks/useNavBarPress/useNavBarPress.test.js +36 -0
- package/lib/hooks/useRockerButton/useRockerButton.js +4 -6
- package/lib/index.js +2 -0
- package/lib/layouts/ListLayout.stories.js +6 -6
- package/lib/recipes/ConditionalFilter.stories.js +7 -3
- package/lib/recipes/RadioButtonsWithLinks.stories.js +1 -1
- package/lib/styles/variants/accordion.js +26 -5
- package/lib/styles/variants/boxes.js +10 -24
- package/lib/styles/variants/buttons.js +27 -1
- package/lib/styles/variants/codeView.js +91 -0
- package/lib/styles/variants/navBar.js +46 -0
- package/lib/styles/variants/separator.js +2 -1
- package/lib/styles/variants/text.js +3 -1
- package/lib/styles/variants/variants.js +2 -0
- package/package.json +5 -3
- package/lib/cjs/recipes/ArrayField.stories.js +0 -169
- package/lib/components/AccordionGridGroup/AccordionGridContext.js +0 -2
- package/lib/recipes/ArrayField.stories.js +0 -134
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import userEvent from '@testing-library/user-event';
|
2
3
|
import GlobeIcon from 'mdi-react/GlobeIcon';
|
3
4
|
import ViewDashboard from 'mdi-react/ViewDashboardIcon';
|
4
5
|
import AccountMultiple from 'mdi-react/AccountMultipleIcon';
|
@@ -10,13 +11,22 @@ import Verify from 'mdi-react/VerifiedIcon';
|
|
10
11
|
import NavBar from './NavBar';
|
11
12
|
import axeTest from '../../utils/testUtils/testAxe';
|
12
13
|
import { render, screen } from '../../utils/testUtils/testWrapper';
|
13
|
-
import { Box, NavBarSection } from '../../index';
|
14
|
+
import { Box, NavBarSection, NavBarItem, NavBarItemButton, NavBarItemLink } from '../../index';
|
14
15
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
16
|
var data = [{
|
16
17
|
icon: GlobeIcon,
|
17
18
|
key: 'Overview',
|
18
19
|
heading: 'Overview',
|
19
|
-
children: [
|
20
|
+
children: [___EmotionJSX(NavBarItemButton, {
|
21
|
+
key: "Credentials Button Users",
|
22
|
+
id: "Credentials Button Users",
|
23
|
+
"data-testid": "navItemButton"
|
24
|
+
}, "Users"), ___EmotionJSX(NavBarItemLink, {
|
25
|
+
key: "Experiences Link Roles",
|
26
|
+
id: "Experiences Link Roles",
|
27
|
+
href: "https://pingidentity.com/",
|
28
|
+
"data-testid": "navItemLink"
|
29
|
+
}, "Roles")]
|
20
30
|
}, {
|
21
31
|
icon: ViewDashboard,
|
22
32
|
key: 'Dashboard',
|
@@ -71,6 +81,12 @@ var getComponent = function getComponent() {
|
|
71
81
|
}), ___EmotionJSX(NavBarSection, {
|
72
82
|
items: secondData,
|
73
83
|
title: "test_title"
|
84
|
+
}), ___EmotionJSX(NavBarItem, {
|
85
|
+
id: "Overview",
|
86
|
+
key: "Overview",
|
87
|
+
text: "Overview",
|
88
|
+
icon: ViewDashboard,
|
89
|
+
"data-testid": "navItem"
|
74
90
|
}))));
|
75
91
|
};
|
76
92
|
|
@@ -89,4 +105,25 @@ test('should render title for itemBodies that have subTitles', function () {
|
|
89
105
|
getComponent();
|
90
106
|
var subTitle = screen.getByText('PingOne Services');
|
91
107
|
expect(subTitle).toBeInTheDocument();
|
108
|
+
});
|
109
|
+
test('should select NavIemLink', function () {
|
110
|
+
getComponent();
|
111
|
+
var link = screen.getByTestId('navItemLink');
|
112
|
+
expect(link).toBeInTheDocument();
|
113
|
+
userEvent.click(link);
|
114
|
+
expect(link).toHaveClass('is-selected');
|
115
|
+
});
|
116
|
+
test('should select NavIem', function () {
|
117
|
+
getComponent();
|
118
|
+
var item = screen.getByTestId('navItem');
|
119
|
+
expect(item).toBeInTheDocument();
|
120
|
+
userEvent.click(item);
|
121
|
+
expect(item).toHaveClass('is-selected');
|
122
|
+
});
|
123
|
+
test('should select NavIemButton', function () {
|
124
|
+
getComponent();
|
125
|
+
var button = screen.getByTestId('navItemButton');
|
126
|
+
expect(button).toBeInTheDocument();
|
127
|
+
userEvent.click(button);
|
128
|
+
expect(button).toHaveClass('is-selected');
|
92
129
|
});
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
3
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
4
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
5
|
+
import React, { useRef, forwardRef, useImperativeHandle } from 'react';
|
6
|
+
import PropTypes from 'prop-types';
|
7
|
+
import { useHover, usePress } from '@react-aria/interactions';
|
8
|
+
import { mergeProps } from '@react-aria/utils';
|
9
|
+
import { useFocusRing } from '@react-aria/focus';
|
10
|
+
import { Box, Icon, Text } from '../../index';
|
11
|
+
import { useStatusClasses, useNavBarPress } from '../../hooks';
|
12
|
+
import { useNavBarContext } from '../../context/NavBarContext';
|
13
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
14
|
+
var NavBarItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
15
|
+
var _context, _context2;
|
16
|
+
|
17
|
+
var icon = props.icon,
|
18
|
+
text = props.text,
|
19
|
+
className = props.className,
|
20
|
+
key = props.id,
|
21
|
+
onPressCallback = props.onPress,
|
22
|
+
others = _objectWithoutProperties(props, ["icon", "text", "className", "id", "onPress"]);
|
23
|
+
|
24
|
+
var navItemRef = useRef();
|
25
|
+
/* istanbul ignore next */
|
26
|
+
|
27
|
+
useImperativeHandle(ref, function () {
|
28
|
+
return navItemRef.current;
|
29
|
+
});
|
30
|
+
|
31
|
+
var _useHover = useHover({}),
|
32
|
+
hoverProps = _useHover.hoverProps,
|
33
|
+
isHovered = _useHover.isHovered;
|
34
|
+
|
35
|
+
var _useFocusRing = useFocusRing({
|
36
|
+
within: true
|
37
|
+
}),
|
38
|
+
focusWithinProps = _useFocusRing.focusProps;
|
39
|
+
|
40
|
+
var _useFocusRing2 = useFocusRing(),
|
41
|
+
focusProps = _useFocusRing2.focusProps,
|
42
|
+
isFocusVisible = _useFocusRing2.isFocusVisible;
|
43
|
+
|
44
|
+
var state = useNavBarContext();
|
45
|
+
|
46
|
+
var isSelected = _includesInstanceProperty(_context = state.selectedKeys).call(_context, key);
|
47
|
+
|
48
|
+
var _useNavBarPress = useNavBarPress({
|
49
|
+
key: key,
|
50
|
+
onPressCallback: onPressCallback
|
51
|
+
}, state),
|
52
|
+
onNavPress = _useNavBarPress.onNavPress;
|
53
|
+
|
54
|
+
var _usePress = usePress({
|
55
|
+
ref: navItemRef,
|
56
|
+
onPress: onNavPress
|
57
|
+
}),
|
58
|
+
pressProps = _usePress.pressProps,
|
59
|
+
isPressed = _usePress.isPressed;
|
60
|
+
|
61
|
+
var mergedProps = mergeProps.apply(void 0, _concatInstanceProperty(_context2 = [pressProps, hoverProps, focusWithinProps, focusProps]).call(_context2, others));
|
62
|
+
|
63
|
+
var _useStatusClasses = useStatusClasses(className, {
|
64
|
+
isPressed: isPressed,
|
65
|
+
isHovered: isHovered,
|
66
|
+
isSelected: isSelected,
|
67
|
+
isFocused: isFocusVisible
|
68
|
+
}),
|
69
|
+
classNames = _useStatusClasses.classNames;
|
70
|
+
|
71
|
+
return ___EmotionJSX(Box, _extends({
|
72
|
+
id: key,
|
73
|
+
variant: "accordion.accordionGridNavItem",
|
74
|
+
isRow: true,
|
75
|
+
className: classNames,
|
76
|
+
ref: navItemRef
|
77
|
+
}, mergedProps, {
|
78
|
+
sx: {
|
79
|
+
maxHeight: '30px'
|
80
|
+
}
|
81
|
+
}), ___EmotionJSX(Box, {
|
82
|
+
isRow: true,
|
83
|
+
sx: {
|
84
|
+
alignItems: 'center'
|
85
|
+
}
|
86
|
+
}, icon && ___EmotionJSX(Icon, {
|
87
|
+
icon: icon,
|
88
|
+
size: 20,
|
89
|
+
sx: {
|
90
|
+
mr: '10px',
|
91
|
+
color: 'white',
|
92
|
+
fill: 'white'
|
93
|
+
}
|
94
|
+
}), ___EmotionJSX(Text, {
|
95
|
+
variant: "navBarHeaderText"
|
96
|
+
}, text)));
|
97
|
+
});
|
98
|
+
NavBarItem.propTypes = {
|
99
|
+
/** Handler that is called when the press is released over the target. */
|
100
|
+
onPress: PropTypes.func,
|
101
|
+
|
102
|
+
/** The icon to render in between each node. */
|
103
|
+
icon: PropTypes.elementType,
|
104
|
+
|
105
|
+
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
106
|
+
id: PropTypes.string,
|
107
|
+
|
108
|
+
/** Text that will render within the component */
|
109
|
+
text: PropTypes.string
|
110
|
+
};
|
111
|
+
export default NavBarItem;
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
7
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
12
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
13
|
+
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
15
|
+
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source), true)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
17
|
+
|
18
|
+
import React from 'react';
|
19
|
+
import PropTypes from 'prop-types';
|
20
|
+
import { useNavBarContext } from '../../context/NavBarContext';
|
21
|
+
import { useStatusClasses, useNavBarPress } from '../../hooks';
|
22
|
+
import { Button } from '../../index';
|
23
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
24
|
+
|
25
|
+
var NavBarItemButton = function NavBarItemButton(props) {
|
26
|
+
var _context;
|
27
|
+
|
28
|
+
var className = props.className,
|
29
|
+
key = props.id,
|
30
|
+
onPressCallback = props.onPress,
|
31
|
+
sx = props.sx,
|
32
|
+
others = _objectWithoutProperties(props, ["className", "id", "onPress", "sx"]);
|
33
|
+
|
34
|
+
var state = useNavBarContext();
|
35
|
+
|
36
|
+
var isSelected = _includesInstanceProperty(_context = state.selectedKeys).call(_context, key);
|
37
|
+
|
38
|
+
var _useNavBarPress = useNavBarPress({
|
39
|
+
key: key,
|
40
|
+
onPressCallback: onPressCallback
|
41
|
+
}, state),
|
42
|
+
onNavPress = _useNavBarPress.onNavPress;
|
43
|
+
|
44
|
+
var _useStatusClasses = useStatusClasses(className, {
|
45
|
+
isSelected: isSelected
|
46
|
+
}),
|
47
|
+
classNames = _useStatusClasses.classNames;
|
48
|
+
|
49
|
+
return ___EmotionJSX(Button, _extends({
|
50
|
+
id: key,
|
51
|
+
variant: "navItemButton",
|
52
|
+
onPress: onNavPress,
|
53
|
+
className: classNames
|
54
|
+
}, others, {
|
55
|
+
sx: _objectSpread({
|
56
|
+
paddingLeft: '45px',
|
57
|
+
paddingRight: '45px'
|
58
|
+
}, sx)
|
59
|
+
}));
|
60
|
+
};
|
61
|
+
|
62
|
+
NavBarItemButton.propTypes = {
|
63
|
+
/** Handler that is called when the press is released over the target. */
|
64
|
+
onPress: PropTypes.func,
|
65
|
+
|
66
|
+
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
67
|
+
id: PropTypes.string.isRequired
|
68
|
+
};
|
69
|
+
export default NavBarItemButton;
|
@@ -7,7 +7,7 @@ var NavBarItemHeader = function NavBarItemHeader(props) {
|
|
7
7
|
var item = props.item;
|
8
8
|
var icon = item.icon;
|
9
9
|
return ___EmotionJSX(Box, {
|
10
|
-
variant: "
|
10
|
+
variant: "navBar.itemHeaderContainer",
|
11
11
|
isRow: true
|
12
12
|
}, icon && ___EmotionJSX(Icon, {
|
13
13
|
icon: icon,
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
2
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
3
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
4
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
5
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
7
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
9
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
10
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
12
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
13
|
+
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
15
|
+
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source), true)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
17
|
+
|
18
|
+
import React from 'react';
|
19
|
+
import PropTypes from 'prop-types';
|
20
|
+
import { Link } from '../../index';
|
21
|
+
import { useNavBarContext } from '../../context/NavBarContext';
|
22
|
+
import { useStatusClasses, useNavBarPress } from '../../hooks';
|
23
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
24
|
+
|
25
|
+
var NavBarItemLink = function NavBarItemLink(props) {
|
26
|
+
var _context;
|
27
|
+
|
28
|
+
var className = props.className,
|
29
|
+
key = props.id,
|
30
|
+
onPressCallback = props.onPress,
|
31
|
+
others = _objectWithoutProperties(props, ["className", "id", "onPress"]);
|
32
|
+
|
33
|
+
var state = useNavBarContext();
|
34
|
+
|
35
|
+
var isSelected = _includesInstanceProperty(_context = state.selectedKeys).call(_context, key);
|
36
|
+
|
37
|
+
var _useNavBarPress = useNavBarPress({
|
38
|
+
key: key,
|
39
|
+
onPressCallback: onPressCallback
|
40
|
+
}, state),
|
41
|
+
onNavPress = _useNavBarPress.onNavPress;
|
42
|
+
|
43
|
+
var _useStatusClasses = useStatusClasses(className, {
|
44
|
+
isSelected: isSelected
|
45
|
+
}),
|
46
|
+
classNames = _useStatusClasses.classNames;
|
47
|
+
|
48
|
+
return ___EmotionJSX(Link, _extends({
|
49
|
+
id: key,
|
50
|
+
variant: "buttons.navItemButton",
|
51
|
+
className: classNames,
|
52
|
+
onPress: onNavPress
|
53
|
+
}, others, {
|
54
|
+
sx: _objectSpread({
|
55
|
+
paddingLeft: '45px',
|
56
|
+
paddingRight: '45px'
|
57
|
+
}, props.sx)
|
58
|
+
}));
|
59
|
+
};
|
60
|
+
|
61
|
+
NavBarItemLink.propTypes = {
|
62
|
+
/** Specifies the location of the URL */
|
63
|
+
href: PropTypes.string,
|
64
|
+
|
65
|
+
/** Handler that is called when the press is released over the target. */
|
66
|
+
onPress: PropTypes.func,
|
67
|
+
|
68
|
+
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
69
|
+
id: PropTypes.string.isRequired
|
70
|
+
};
|
71
|
+
export default NavBarItemLink;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
1
2
|
import React from 'react';
|
2
3
|
import PropTypes from 'prop-types';
|
3
4
|
import { Separator, AccordionGridGroup, Text, Item, Box } from '../../index';
|
@@ -16,19 +17,19 @@ var NavBarSection = function NavBarSection(props) {
|
|
16
17
|
title = props.title,
|
17
18
|
items = props.items;
|
18
19
|
return ___EmotionJSX(React.Fragment, null, title && ___EmotionJSX(Text, {
|
19
|
-
variant: "text.navBarSubtitle"
|
20
|
-
sx: {
|
21
|
-
mt: '25px',
|
22
|
-
mb: '15px',
|
23
|
-
ml: '15px'
|
24
|
-
}
|
20
|
+
variant: "text.navBarSubtitle"
|
25
21
|
}, title), ___EmotionJSX(AccordionGridGroup, {
|
26
|
-
items: items
|
22
|
+
items: _filterInstanceProperty(items).call(items, function (i) {
|
23
|
+
return i.children;
|
24
|
+
})
|
27
25
|
}, function (item) {
|
28
26
|
return ___EmotionJSX(Item, {
|
29
27
|
headerProps: {
|
30
28
|
variant: 'accordion.accordionGridHeaderNav'
|
31
29
|
},
|
30
|
+
bodyProps: {
|
31
|
+
variant: 'navBar.sectionBody'
|
32
|
+
},
|
32
33
|
textValue: item
|
33
34
|
}, ___EmotionJSX(NavBarItemHeader, {
|
34
35
|
item: item
|
@@ -39,7 +40,7 @@ var NavBarSection = function NavBarSection(props) {
|
|
39
40
|
sx: {
|
40
41
|
pl: '15px',
|
41
42
|
pr: '15px',
|
42
|
-
|
43
|
+
my: '10px'
|
43
44
|
}
|
44
45
|
}, ___EmotionJSX(Separator, {
|
45
46
|
variant: "separator.navBarSeparator"
|
@@ -1 +1,4 @@
|
|
1
|
-
export { default } from './NavBarSection';
|
1
|
+
export { default } from './NavBarSection';
|
2
|
+
export { default as NavBarItemButton } from './NavBarItemButton';
|
3
|
+
export { default as NavBarItemLink } from './NavBarItemLink';
|
4
|
+
export { default as NavBarItem } from './NavBarItem';
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
3
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
4
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
5
4
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
|
-
import React, { forwardRef, useRef, useImperativeHandle
|
5
|
+
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
7
6
|
import PropTypes from 'prop-types';
|
8
7
|
import { FocusScope } from '@react-aria/focus';
|
9
8
|
import Box from '../Box';
|
@@ -26,14 +25,8 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
25
|
onClose = _useOverlayPanelState.onClose;
|
27
26
|
|
28
27
|
var overlayPanelRef = useRef();
|
29
|
-
|
30
|
-
var _useState = useState(true),
|
31
|
-
_useState2 = _slicedToArray(_useState, 2),
|
32
|
-
contain = _useState2[0],
|
33
|
-
setIsContained = _useState2[1];
|
34
28
|
/* istanbul ignore next */
|
35
29
|
|
36
|
-
|
37
30
|
useImperativeHandle(ref, function () {
|
38
31
|
return overlayPanelRef.current;
|
39
32
|
});
|
@@ -47,18 +40,12 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
47
40
|
e.stopPropagation();
|
48
41
|
|
49
42
|
if (e.key === 'Escape') {
|
50
|
-
|
43
|
+
onClose(state, triggerRef, onCloseProp);
|
51
44
|
}
|
52
45
|
};
|
53
46
|
|
54
|
-
useEffect(function () {
|
55
|
-
if (!contain && onClose) {
|
56
|
-
onClose(state, triggerRef, onCloseProp);
|
57
|
-
}
|
58
|
-
}, [contain]);
|
59
47
|
return ___EmotionJSX(FocusScope, {
|
60
|
-
autoFocus: true
|
61
|
-
contain: contain
|
48
|
+
autoFocus: true
|
62
49
|
}, ___EmotionJSX(Box, _extends({
|
63
50
|
variant: "overlayPanel.overlayPanel",
|
64
51
|
ref: overlayPanelRef
|
@@ -60,6 +60,13 @@ test('onClose callback fires when provided', function () {
|
|
60
60
|
});
|
61
61
|
expect(onClose).toHaveBeenCalled();
|
62
62
|
});
|
63
|
+
test('custom classname can be passed', function () {
|
64
|
+
getComponent({
|
65
|
+
className: 'testing-class'
|
66
|
+
});
|
67
|
+
var overlayPanel = screen.getByTestId(testId);
|
68
|
+
expect(overlayPanel).toHaveClass('testing-class');
|
69
|
+
});
|
63
70
|
test('neither callback fires when not provided', function () {
|
64
71
|
var onClose = jest.fn();
|
65
72
|
getComponent({
|
@@ -110,4 +117,35 @@ test('triggerRef.current.focus() fires when provided', function () {
|
|
110
117
|
charCode: 27
|
111
118
|
});
|
112
119
|
expect(focusFunction).toHaveBeenCalled();
|
120
|
+
});
|
121
|
+
test('triggerRef.current.focus() does not fire when key other than esc is pressed', function () {
|
122
|
+
var onClose = jest.fn();
|
123
|
+
var focusFunction = jest.fn();
|
124
|
+
var state = {
|
125
|
+
close: onClose
|
126
|
+
};
|
127
|
+
var triggerRef = {
|
128
|
+
current: {
|
129
|
+
focus: focusFunction
|
130
|
+
}
|
131
|
+
};
|
132
|
+
getComponent({
|
133
|
+
state: state,
|
134
|
+
children: ___EmotionJSX("div", null, "Test"),
|
135
|
+
triggerRef: triggerRef
|
136
|
+
});
|
137
|
+
var overlayPanel = screen.getByTestId(testId);
|
138
|
+
fireEvent.keyDown(overlayPanel, {
|
139
|
+
key: 'KeyA',
|
140
|
+
code: 'KeyA',
|
141
|
+
keyCode: 65,
|
142
|
+
charCode: 65
|
143
|
+
});
|
144
|
+
fireEvent.keyUp(overlayPanel, {
|
145
|
+
key: 'KeyA',
|
146
|
+
code: 'KeyA',
|
147
|
+
keyCode: 65,
|
148
|
+
charCode: 65
|
149
|
+
});
|
150
|
+
expect(focusFunction).not.toHaveBeenCalled();
|
113
151
|
});
|
@@ -17,26 +17,18 @@ import React, { forwardRef, useContext, useImperativeHandle, useRef } from 'reac
|
|
17
17
|
import PropTypes from 'prop-types';
|
18
18
|
import { Item } from '@react-stately/collections';
|
19
19
|
import { useFocusRing } from '@react-aria/focus';
|
20
|
-
import { mergeProps } from '@react-aria/utils';
|
21
20
|
import { useRockerButton, useStatusClasses, usePropWarning } from '../../hooks';
|
22
|
-
import
|
21
|
+
import { Box } from '../../index';
|
23
22
|
import { RockerContext } from '../RockerButtonGroup';
|
24
23
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
24
|
export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
26
25
|
var className = props.className,
|
27
|
-
item = props.item
|
28
|
-
buttonGroupDisabled = props.isDisabled;
|
29
|
-
var defaultSelectedStyles = {
|
30
|
-
bg: 'active'
|
31
|
-
};
|
26
|
+
item = props.item;
|
32
27
|
var key = item.key,
|
33
28
|
rendered = item.rendered,
|
34
29
|
itemProps = item.props;
|
35
|
-
var _itemProps$selectedSt = itemProps.selectedStyles,
|
36
|
-
selectedStyles = _itemProps$selectedSt === void 0 ? defaultSelectedStyles : _itemProps$selectedSt,
|
37
|
-
rockerButtonDisabled = itemProps.isDisabled;
|
38
|
-
var isDisabled = buttonGroupDisabled || rockerButtonDisabled;
|
39
30
|
var state = useContext(RockerContext);
|
31
|
+
var isDisabled = state.disabledKeys.has(key);
|
40
32
|
|
41
33
|
var _useFocusRing = useFocusRing(),
|
42
34
|
isFocusVisible = _useFocusRing.isFocusVisible,
|
@@ -46,7 +38,8 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
|
|
46
38
|
|
47
39
|
var _useStatusClasses = useStatusClasses(className, {
|
48
40
|
isFocused: isFocusVisible,
|
49
|
-
isSelected: isSelected
|
41
|
+
isSelected: isSelected,
|
42
|
+
isDisabled: isDisabled
|
50
43
|
}),
|
51
44
|
classNames = _useStatusClasses.classNames;
|
52
45
|
|
@@ -60,25 +53,25 @@ export var CollectionRockerButton = /*#__PURE__*/forwardRef(function (props, ref
|
|
60
53
|
|
61
54
|
var _useRockerButton = useRockerButton({
|
62
55
|
item: item,
|
63
|
-
isDisabled: isDisabled
|
56
|
+
isDisabled: isDisabled,
|
57
|
+
isSelected: isSelected
|
64
58
|
}, state, rockerButtonRef),
|
65
59
|
rockerButtonProps = _useRockerButton.rockerButtonProps;
|
66
60
|
|
67
|
-
return ___EmotionJSX(
|
61
|
+
return ___EmotionJSX(Box, _extends({
|
62
|
+
as: "button",
|
68
63
|
className: classNames,
|
69
|
-
variant: "rocker"
|
70
|
-
},
|
71
|
-
ref: rockerButtonRef
|
64
|
+
variant: "buttons.rocker"
|
65
|
+
}, rockerButtonProps, {
|
66
|
+
ref: rockerButtonRef
|
67
|
+
}, focusProps, itemProps, {
|
72
68
|
sx: {
|
73
|
-
'&.is-selected': _objectSpread({}, selectedStyles)
|
69
|
+
'&.is-selected': _objectSpread({}, itemProps.selectedStyles)
|
74
70
|
}
|
75
71
|
}), rendered);
|
76
72
|
});
|
77
73
|
CollectionRockerButton.displayName = 'CollectionRockerButton';
|
78
74
|
CollectionRockerButton.propTypes = {
|
79
|
-
/** Whether the button is disabled. */
|
80
|
-
isDisabled: PropTypes.bool,
|
81
|
-
|
82
75
|
/** Allows custom styles to be passed to button. */
|
83
76
|
selectedStyles: PropTypes.shape({}),
|
84
77
|
// adding to surface in props table
|
@@ -34,10 +34,10 @@ var RockerButtonGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
34
34
|
var _context;
|
35
35
|
|
36
36
|
var children = props.children,
|
37
|
-
isDisabled = props.isDisabled,
|
38
37
|
onSelectionChange = props.onSelectionChange,
|
39
38
|
tabListProps = props.tabListProps,
|
40
|
-
|
39
|
+
disabledKeys = props.disabledKeys,
|
40
|
+
others = _objectWithoutProperties(props, ["children", "onSelectionChange", "tabListProps", "disabledKeys"]);
|
41
41
|
|
42
42
|
var buttonGroupRef = useRef();
|
43
43
|
usePropWarning(props, 'disabled', 'isDisabled');
|
@@ -67,8 +67,7 @@ var RockerButtonGroup = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
67
67
|
}), _mapInstanceProperty(_context = _Array$from(state.collection)).call(_context, function (item) {
|
68
68
|
return ___EmotionJSX(CollectionRockerButton, {
|
69
69
|
key: item.key,
|
70
|
-
item: item
|
71
|
-
isDisabled: isDisabled
|
70
|
+
item: item
|
72
71
|
});
|
73
72
|
}))));
|
74
73
|
});
|
@@ -79,14 +78,11 @@ RockerButtonGroup.propTypes = {
|
|
79
78
|
/** The button key that is currently selected. (controlled) */
|
80
79
|
selectedKey: PropTypes.string,
|
81
80
|
|
82
|
-
/**
|
83
|
-
|
81
|
+
/** Which keys should be disabled. */
|
82
|
+
disabledKeys: PropTypes.arrayOf(PropTypes.string),
|
84
83
|
|
85
84
|
/** Handler that is called when the selected button has changed. */
|
86
85
|
onSelectionChange: PropTypes.func
|
87
86
|
};
|
88
|
-
RockerButtonGroup.defaultProps = {
|
89
|
-
isDisabled: false
|
90
|
-
};
|
91
87
|
RockerButtonGroup.displayName = 'RockerButtonGroup';
|
92
88
|
export default RockerButtonGroup;
|
@@ -96,23 +96,8 @@ export var withCustomSelectedColors = function withCustomSelectedColors() {
|
|
96
96
|
};
|
97
97
|
export var DisabledSingleButton = function DisabledSingleButton() {
|
98
98
|
return ___EmotionJSX(RockerButtonGroup, {
|
99
|
-
defaultSelectedKey: "or"
|
100
|
-
|
101
|
-
name: "and",
|
102
|
-
key: "and",
|
103
|
-
isDisabled: true
|
104
|
-
}, "And"), ___EmotionJSX(RockerButton, {
|
105
|
-
name: "or",
|
106
|
-
key: "or"
|
107
|
-
}, "Or"), ___EmotionJSX(RockerButton, {
|
108
|
-
name: "maybe",
|
109
|
-
key: "maybe"
|
110
|
-
}, "Maybe"));
|
111
|
-
};
|
112
|
-
export var DisabledRockerButtonGroup = function DisabledRockerButtonGroup() {
|
113
|
-
return ___EmotionJSX(RockerButtonGroup, {
|
114
|
-
isDisabled: true,
|
115
|
-
defaultSelectedKey: "and"
|
99
|
+
defaultSelectedKey: "or",
|
100
|
+
disabledKeys: ['and']
|
116
101
|
}, ___EmotionJSX(RockerButton, {
|
117
102
|
name: "and",
|
118
103
|
key: "and"
|
@@ -66,9 +66,11 @@ test('buttonGroup is not disabled by default', function () {
|
|
66
66
|
expect(buttonKey).not.toHaveClass('is-disabled');
|
67
67
|
});
|
68
68
|
});
|
69
|
-
test('
|
69
|
+
test('rocker button is disabled when its key is included in disabledKeys', function () {
|
70
70
|
getComponent({
|
71
|
-
|
71
|
+
disabledKeys: _mapInstanceProperty(testButtons).call(testButtons, function (button) {
|
72
|
+
return button.key;
|
73
|
+
})
|
72
74
|
});
|
73
75
|
|
74
76
|
_forEachInstanceProperty(testButtons).call(testButtons, function (button) {
|
@@ -82,24 +84,16 @@ test('rockerButton renders selectedStyles prop when selected', function () {
|
|
82
84
|
expect(buttonColorKey).toHaveClass('is-selected');
|
83
85
|
});
|
84
86
|
test('selected button can be changed by keyboard interaction', function () {
|
85
|
-
getComponent();
|
86
|
-
|
87
|
-
userEvent.tab();
|
87
|
+
getComponent();
|
88
88
|
userEvent.tab();
|
89
89
|
var button0 = screen.getByText(testButtons[0].key);
|
90
90
|
expect(button0).toHaveClass('is-selected');
|
91
91
|
var button1 = screen.getByText(testButtons[1].key);
|
92
92
|
expect(button1).not.toHaveClass('is-selected');
|
93
|
-
userEvent.tab();
|
94
|
-
userEvent.tab();
|
95
93
|
fireEvent.keyDown(screen.getByText(testButtons[0].key), {
|
96
94
|
key: 'ArrowRight',
|
97
95
|
code: 'ArrowRight'
|
98
96
|
});
|
99
|
-
fireEvent.keyDown(screen.getByText(testButtons[1].key), {
|
100
|
-
key: 'ArrowRight',
|
101
|
-
code: 'ArrowRight'
|
102
|
-
});
|
103
97
|
expect(screen.getByText(testButtons[1].key)).toHaveClass('is-selected');
|
104
98
|
expect(screen.getByText(testButtons[0].key)).not.toHaveClass('is-selected');
|
105
99
|
});
|