@pingux/astro 1.1.0-alpha.7 → 1.1.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/CHANGELOG.md +71 -0
- package/lib/cjs/components/CodeView/CodeView.js +175 -0
- package/lib/cjs/components/CodeView/CodeView.stories.js +93 -0
- package/lib/cjs/components/CodeView/CodeView.test.js +211 -0
- package/lib/cjs/components/CodeView/index.js +18 -0
- package/lib/cjs/components/CopyText/CopyText.js +34 -11
- package/lib/cjs/components/FileInputField/FileItem.js +2 -1
- package/lib/cjs/components/List/List.js +3 -0
- package/lib/cjs/components/List/List.stories.js +7 -2
- package/lib/cjs/components/NavBar/NavBar.js +38 -0
- package/lib/cjs/components/NavBar/NavBar.stories.js +679 -0
- package/lib/cjs/components/NavBar/NavBar.test.js +116 -0
- package/lib/cjs/components/NavBar/index.js +18 -0
- package/lib/cjs/components/NavBarSection/NavBarItemBody.js +56 -0
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +47 -0
- package/lib/cjs/components/NavBarSection/NavBarSection.js +82 -0
- package/lib/cjs/components/NavBarSection/index.js +18 -0
- package/lib/cjs/components/OverlayPanel/OverlayPanel.js +53 -6
- package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +59 -47
- package/lib/cjs/components/OverlayPanel/OverlayPanel.test.js +84 -0
- package/lib/cjs/components/PopoverMenu/PopoverMenu.js +1 -3
- package/lib/cjs/components/Separator/Separator.js +1 -1
- package/lib/cjs/components/TextArea/TextArea.js +5 -1
- package/lib/cjs/components/TooltipTrigger/TooltipTrigger.js +10 -5
- package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.js +20 -1
- package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.test.js +7 -3
- package/lib/cjs/index.js +84 -30
- package/lib/cjs/styles/variants/accordion.js +32 -1
- package/lib/cjs/styles/variants/boxes.js +24 -1
- package/lib/cjs/styles/variants/buttons.js +29 -1
- package/lib/cjs/styles/variants/codeView.js +77 -0
- package/lib/cjs/styles/variants/link.js +1 -1
- package/lib/cjs/styles/variants/separator.js +46 -3
- package/lib/cjs/styles/variants/text.js +15 -0
- package/lib/cjs/styles/variants/variants.js +3 -0
- package/lib/components/CodeView/CodeView.js +139 -0
- package/lib/components/CodeView/CodeView.stories.js +67 -0
- package/lib/components/CodeView/CodeView.test.js +171 -0
- package/lib/components/CodeView/index.js +1 -0
- package/lib/components/CopyText/CopyText.js +35 -11
- package/lib/components/FileInputField/FileItem.js +2 -1
- package/lib/components/List/List.js +2 -0
- package/lib/components/List/List.stories.js +6 -2
- package/lib/components/NavBar/NavBar.js +24 -0
- package/lib/components/NavBar/NavBar.stories.js +650 -0
- package/lib/components/NavBar/NavBar.test.js +92 -0
- package/lib/components/NavBar/index.js +1 -0
- package/lib/components/NavBarSection/NavBarItemBody.js +37 -0
- package/lib/components/NavBarSection/NavBarItemHeader.js +31 -0
- package/lib/components/NavBarSection/NavBarSection.js +65 -0
- package/lib/components/NavBarSection/index.js +1 -0
- package/lib/components/OverlayPanel/OverlayPanel.js +52 -8
- package/lib/components/OverlayPanel/OverlayPanel.stories.js +59 -49
- package/lib/components/OverlayPanel/OverlayPanel.test.js +73 -1
- package/lib/components/PopoverMenu/PopoverMenu.js +1 -3
- package/lib/components/Separator/Separator.js +1 -1
- package/lib/components/TextArea/TextArea.js +5 -1
- package/lib/components/TooltipTrigger/TooltipTrigger.js +10 -5
- package/lib/hooks/useOverlayPanelState/useOverlayPanelState.js +20 -1
- package/lib/hooks/useOverlayPanelState/useOverlayPanelState.test.js +7 -3
- package/lib/index.js +5 -0
- package/lib/styles/variants/accordion.js +32 -1
- package/lib/styles/variants/boxes.js +24 -1
- package/lib/styles/variants/buttons.js +29 -1
- package/lib/styles/variants/codeView.js +67 -0
- package/lib/styles/variants/link.js +1 -1
- package/lib/styles/variants/separator.js +33 -1
- package/lib/styles/variants/text.js +15 -0
- package/lib/styles/variants/variants.js +2 -0
- package/package.json +3 -2
@@ -0,0 +1,92 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import GlobeIcon from 'mdi-react/GlobeIcon';
|
3
|
+
import ViewDashboard from 'mdi-react/ViewDashboardIcon';
|
4
|
+
import AccountMultiple from 'mdi-react/AccountMultipleIcon';
|
5
|
+
import TransitConnection from 'mdi-react/TransitConnectionVariantIcon';
|
6
|
+
import EmoticonHappy from 'mdi-react/EmoticonHappyOutlineIcon';
|
7
|
+
import Fingerprint from 'mdi-react/FingerprintIcon';
|
8
|
+
import ScaleBalance from 'mdi-react/ScaleBalanceIcon';
|
9
|
+
import Verify from 'mdi-react/VerifiedIcon';
|
10
|
+
import NavBar from './NavBar';
|
11
|
+
import axeTest from '../../utils/testUtils/testAxe';
|
12
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
13
|
+
import { Box, NavBarSection } from '../../index';
|
14
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
|
+
var data = [{
|
16
|
+
icon: GlobeIcon,
|
17
|
+
key: 'Overview',
|
18
|
+
heading: 'Overview',
|
19
|
+
children: ['Users', 'Group', 'Populations', 'Attributes', 'A roles title that is really really really really long']
|
20
|
+
}, {
|
21
|
+
icon: ViewDashboard,
|
22
|
+
key: 'Dashboard',
|
23
|
+
heading: 'Dashboard',
|
24
|
+
children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
|
25
|
+
}, {
|
26
|
+
icon: AccountMultiple,
|
27
|
+
key: 'Identities',
|
28
|
+
heading: 'Identities',
|
29
|
+
children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
|
30
|
+
}, {
|
31
|
+
icon: TransitConnection,
|
32
|
+
key: 'Connections',
|
33
|
+
heading: 'Connections',
|
34
|
+
children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
|
35
|
+
}, {
|
36
|
+
icon: EmoticonHappy,
|
37
|
+
key: 'Experiences',
|
38
|
+
heading: 'Experiences',
|
39
|
+
children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
|
40
|
+
}];
|
41
|
+
var secondData = [{
|
42
|
+
icon: Fingerprint,
|
43
|
+
key: 'MFA',
|
44
|
+
heading: 'MFA',
|
45
|
+
children: ['Users', {
|
46
|
+
subTitle: 'PingOne Services'
|
47
|
+
}, 'Group', 'Populations', 'Attributes', 'Roles']
|
48
|
+
}, {
|
49
|
+
icon: ScaleBalance,
|
50
|
+
key: 'Risk',
|
51
|
+
heading: 'Risk',
|
52
|
+
children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
|
53
|
+
}, {
|
54
|
+
icon: Verify,
|
55
|
+
key: 'Verify',
|
56
|
+
heading: 'Verify',
|
57
|
+
children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
|
58
|
+
}];
|
59
|
+
|
60
|
+
var getComponent = function getComponent() {
|
61
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
62
|
+
return render(___EmotionJSX(NavBar, props, ___EmotionJSX(Box, {
|
63
|
+
sx: {
|
64
|
+
height: '100%',
|
65
|
+
maxHeight: '100%',
|
66
|
+
overflowY: 'overlay !important'
|
67
|
+
}
|
68
|
+
}, ___EmotionJSX(NavBarSection, {
|
69
|
+
items: data,
|
70
|
+
hasSeparator: true
|
71
|
+
}), ___EmotionJSX(NavBarSection, {
|
72
|
+
items: secondData,
|
73
|
+
title: "test_title"
|
74
|
+
}))));
|
75
|
+
};
|
76
|
+
|
77
|
+
axeTest(getComponent);
|
78
|
+
test('should render basic nav with children', function () {
|
79
|
+
getComponent();
|
80
|
+
var nav = screen.queryByRole('navigation');
|
81
|
+
expect(nav).toBeInTheDocument();
|
82
|
+
});
|
83
|
+
test('should render title for sections that have titles', function () {
|
84
|
+
getComponent();
|
85
|
+
var title = screen.getByText('test_title');
|
86
|
+
expect(title).toBeInTheDocument();
|
87
|
+
});
|
88
|
+
test('should render title for itemBodies that have subTitles', function () {
|
89
|
+
getComponent();
|
90
|
+
var subTitle = screen.getByText('PingOne Services');
|
91
|
+
expect(subTitle).toBeInTheDocument();
|
92
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './NavBar';
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
2
|
+
import React, { Fragment } from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import { Separator, Box, Text } from '../../index';
|
5
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
6
|
+
|
7
|
+
var NavBarItemBody = function NavBarItemBody(props) {
|
8
|
+
var _context;
|
9
|
+
|
10
|
+
return ___EmotionJSX(Box, {
|
11
|
+
sx: {
|
12
|
+
alignItems: 'flex-start',
|
13
|
+
mb: '15px'
|
14
|
+
}
|
15
|
+
}, _mapInstanceProperty(_context = props.item.children).call(_context, function (child) {
|
16
|
+
return child.subTitle ? ___EmotionJSX(Fragment, {
|
17
|
+
key: "fragment".concat(child.subTitle)
|
18
|
+
}, ___EmotionJSX(Separator, {
|
19
|
+
variant: "separator.navBarSubtitleSeparator",
|
20
|
+
key: "separator".concat(child.subTitle)
|
21
|
+
}), ___EmotionJSX(Text, {
|
22
|
+
key: "text".concat(child.subTitle),
|
23
|
+
variant: "text.navBarSubtitle",
|
24
|
+
sx: {
|
25
|
+
mb: '10px',
|
26
|
+
ml: '45px'
|
27
|
+
}
|
28
|
+
}, child.subTitle)) : child;
|
29
|
+
}));
|
30
|
+
};
|
31
|
+
|
32
|
+
NavBarItemBody.propTypes = {
|
33
|
+
item: PropTypes.shape({
|
34
|
+
children: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object]))
|
35
|
+
})
|
36
|
+
};
|
37
|
+
export default NavBarItemBody;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { Box, Icon, Text } from '../../index';
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
|
+
|
6
|
+
var NavBarItemHeader = function NavBarItemHeader(props) {
|
7
|
+
var item = props.item;
|
8
|
+
var icon = item.icon;
|
9
|
+
return ___EmotionJSX(Box, {
|
10
|
+
variant: "boxes.navBarItemHeaderContainer",
|
11
|
+
isRow: true
|
12
|
+
}, icon && ___EmotionJSX(Icon, {
|
13
|
+
icon: icon,
|
14
|
+
size: 20,
|
15
|
+
sx: {
|
16
|
+
mr: '10px',
|
17
|
+
color: 'white',
|
18
|
+
fill: 'white'
|
19
|
+
}
|
20
|
+
}), ___EmotionJSX(Text, {
|
21
|
+
variant: "navBarHeaderText"
|
22
|
+
}, props.item.heading));
|
23
|
+
};
|
24
|
+
|
25
|
+
NavBarItemHeader.propTypes = {
|
26
|
+
item: PropTypes.shape({
|
27
|
+
heading: PropTypes.string,
|
28
|
+
icon: PropTypes.elementType
|
29
|
+
})
|
30
|
+
};
|
31
|
+
export default NavBarItemHeader;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { Separator, AccordionGridGroup, Text, Item, Box } from '../../index';
|
4
|
+
import NavBarItemBody from './NavBarItemBody';
|
5
|
+
import NavBarItemHeader from './NavBarItemHeader';
|
6
|
+
/**
|
7
|
+
* Composed component that creates an AccordionGrid group
|
8
|
+
* with title, and separator options.
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
|
12
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
13
|
+
|
14
|
+
var NavBarSection = function NavBarSection(props) {
|
15
|
+
var hasSeparator = props.hasSeparator,
|
16
|
+
title = props.title,
|
17
|
+
items = props.items;
|
18
|
+
return ___EmotionJSX(React.Fragment, null, title && ___EmotionJSX(Text, {
|
19
|
+
variant: "text.navBarSubtitle",
|
20
|
+
sx: {
|
21
|
+
mt: '25px',
|
22
|
+
mb: '15px',
|
23
|
+
ml: '15px'
|
24
|
+
}
|
25
|
+
}, title), ___EmotionJSX(AccordionGridGroup, {
|
26
|
+
items: items
|
27
|
+
}, function (item) {
|
28
|
+
return ___EmotionJSX(Item, {
|
29
|
+
headerProps: {
|
30
|
+
variant: 'accordion.accordionGridHeaderNav'
|
31
|
+
},
|
32
|
+
textValue: item
|
33
|
+
}, ___EmotionJSX(NavBarItemHeader, {
|
34
|
+
item: item
|
35
|
+
}), ___EmotionJSX(NavBarItemBody, {
|
36
|
+
item: item
|
37
|
+
}));
|
38
|
+
}), hasSeparator && ___EmotionJSX(Box, {
|
39
|
+
sx: {
|
40
|
+
pl: '15px',
|
41
|
+
pr: '15px',
|
42
|
+
mt: '25px'
|
43
|
+
}
|
44
|
+
}, ___EmotionJSX(Separator, {
|
45
|
+
variant: "separator.navBarSeparator"
|
46
|
+
})));
|
47
|
+
};
|
48
|
+
|
49
|
+
NavBarSection.defaultProps = {
|
50
|
+
hasSeparator: false
|
51
|
+
};
|
52
|
+
NavBarSection.propTypes = {
|
53
|
+
/** If true, a separator will render at the end of the section */
|
54
|
+
hasSeparator: PropTypes.bool,
|
55
|
+
|
56
|
+
/** If present, this string will render at the top of the section */
|
57
|
+
title: PropTypes.string,
|
58
|
+
|
59
|
+
/**
|
60
|
+
* *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
|
61
|
+
* For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
|
62
|
+
*/
|
63
|
+
items: PropTypes.arrayOf(PropTypes.shape({}))
|
64
|
+
};
|
65
|
+
export default NavBarSection;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './NavBarSection';
|
@@ -1,11 +1,13 @@
|
|
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";
|
4
5
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
5
|
-
import React, { forwardRef, useRef, useImperativeHandle } from 'react';
|
6
|
+
import React, { forwardRef, useRef, useImperativeHandle, useEffect, useState } from 'react';
|
6
7
|
import PropTypes from 'prop-types';
|
8
|
+
import { FocusScope } from '@react-aria/focus';
|
7
9
|
import Box from '../Box';
|
8
|
-
import { useStatusClasses } from '../../hooks';
|
10
|
+
import { useStatusClasses, useOverlayPanelState } from '../../hooks';
|
9
11
|
import { panelSizes } from '../../utils/devUtils/constants/panelSizes';
|
10
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
11
13
|
var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
@@ -13,13 +15,25 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
13
15
|
|
14
16
|
var children = props.children,
|
15
17
|
isOpen = props.isOpen,
|
18
|
+
onCloseProp = props.onClose,
|
16
19
|
className = props.className,
|
20
|
+
state = props.state,
|
17
21
|
size = props.size,
|
18
|
-
|
22
|
+
triggerRef = props.triggerRef,
|
23
|
+
others = _objectWithoutProperties(props, ["children", "isOpen", "onClose", "className", "state", "size", "triggerRef"]);
|
24
|
+
|
25
|
+
var _useOverlayPanelState = useOverlayPanelState(),
|
26
|
+
onClose = _useOverlayPanelState.onClose;
|
19
27
|
|
20
28
|
var overlayPanelRef = useRef();
|
29
|
+
|
30
|
+
var _useState = useState(true),
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
32
|
+
contain = _useState2[0],
|
33
|
+
setIsContained = _useState2[1];
|
21
34
|
/* istanbul ignore next */
|
22
35
|
|
36
|
+
|
23
37
|
useImperativeHandle(ref, function () {
|
24
38
|
return overlayPanelRef.current;
|
25
39
|
});
|
@@ -29,14 +43,32 @@ var OverlayPanel = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
29
43
|
}, "is-".concat((props === null || props === void 0 ? void 0 : (_props$sx = props.sx) === null || _props$sx === void 0 ? void 0 : _props$sx.width) ? 'custom' : size), size)),
|
30
44
|
classNames = _useStatusClasses.classNames;
|
31
45
|
|
32
|
-
|
33
|
-
|
46
|
+
var handleClose = function handleClose(e) {
|
47
|
+
e.stopPropagation();
|
48
|
+
|
49
|
+
if (e.key === 'Escape') {
|
50
|
+
setIsContained(false);
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
useEffect(function () {
|
55
|
+
if (!contain && onClose) {
|
56
|
+
onClose(state, triggerRef, onCloseProp);
|
57
|
+
}
|
58
|
+
}, [contain]);
|
59
|
+
return ___EmotionJSX(FocusScope, {
|
60
|
+
autoFocus: true,
|
61
|
+
contain: contain
|
62
|
+
}, ___EmotionJSX(Box, _extends({
|
63
|
+
variant: "overlayPanel.overlayPanel",
|
64
|
+
ref: overlayPanelRef
|
34
65
|
}, others, {
|
35
|
-
className: classNames
|
66
|
+
className: classNames,
|
67
|
+
onKeyUp: handleClose
|
36
68
|
}), ___EmotionJSX(Box, {
|
37
69
|
variant: "overlayPanel.overlayPanelBody",
|
38
70
|
className: classNames
|
39
|
-
}, children));
|
71
|
+
}, children)));
|
40
72
|
});
|
41
73
|
OverlayPanel.propTypes = {
|
42
74
|
/** Sets the open state of the menu. */
|
@@ -48,7 +80,19 @@ OverlayPanel.propTypes = {
|
|
48
80
|
/** JSX styling that is passed into the component. */
|
49
81
|
sx: PropTypes.shape({
|
50
82
|
width: PropTypes.string
|
51
|
-
})
|
83
|
+
}),
|
84
|
+
|
85
|
+
/** State object that is passed in from the useOverlayPanelState hook */
|
86
|
+
state: PropTypes.shape({
|
87
|
+
close: PropTypes.func
|
88
|
+
}),
|
89
|
+
|
90
|
+
/** Callback function that runs when the esc key is used to close the OverlayPanel. */
|
91
|
+
onClose: PropTypes.func,
|
92
|
+
|
93
|
+
/** Ref that is connected to the button that triggers the overlay state.
|
94
|
+
Focus will return to this ref when the keyboard is used to close the OverlayPanel. */
|
95
|
+
triggerRef: PropTypes.shape({})
|
52
96
|
};
|
53
97
|
OverlayPanel.defaultProps = {
|
54
98
|
size: 'medium'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
|
-
import React, { useState } from 'react';
|
3
|
+
import React, { useState, useRef } from 'react';
|
4
4
|
import { Item } from '@react-stately/collections';
|
5
5
|
import { useOverlayPanelState } from '../../hooks';
|
6
6
|
import OverlayPanel from './OverlayPanel';
|
7
|
-
import { OverlayProvider, Box, Text, List, ListItem, Separator, Messages, Button
|
7
|
+
import { OverlayProvider, Box, Text, List, ListItem, Separator, Messages, Button } from '../../index';
|
8
8
|
import { panelSizes } from '../../utils/devUtils/constants/panelSizes';
|
9
9
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
10
10
|
export default {
|
@@ -37,28 +37,43 @@ export default {
|
|
37
37
|
export var Default = function Default(_ref) {
|
38
38
|
var args = _extends({}, _ref);
|
39
39
|
|
40
|
-
var
|
40
|
+
var _useOverlayPanelState = useOverlayPanelState(),
|
41
|
+
state = _useOverlayPanelState.state,
|
42
|
+
onClose = _useOverlayPanelState.onClose;
|
43
|
+
|
44
|
+
var triggerRef = useRef();
|
41
45
|
return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
42
|
-
// readers when an overlay
|
46
|
+
// readers when an overlay is open.
|
43
47
|
___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."), ___EmotionJSX("br", null), ___EmotionJSX(Button, {
|
48
|
+
ref: triggerRef,
|
44
49
|
onPress: state.open
|
45
|
-
}, "Open Panel"), ___EmotionJSX(OverlayPanel, _extends({
|
46
|
-
isOpen: state.isOpen
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}, ___EmotionJSX(Text,
|
50
|
+
}, "Open Panel"), state.isOpen && ___EmotionJSX(OverlayPanel, _extends({
|
51
|
+
isOpen: state.isOpen,
|
52
|
+
state: state
|
53
|
+
}, args, {
|
54
|
+
triggerRef: triggerRef
|
55
|
+
}), ___EmotionJSX(Box, null, ___EmotionJSX(Button, {
|
56
|
+
onPress: function onPress() {
|
57
|
+
onClose(state, triggerRef);
|
58
|
+
}
|
59
|
+
}, "Close Panel"), ___EmotionJSX(Text, {
|
60
|
+
pt: "md"
|
61
|
+
}, "Children render here."))))
|
55
62
|
);
|
56
63
|
};
|
57
64
|
export var InnerPanel = function InnerPanel(_ref2) {
|
58
65
|
var args = _extends({}, _ref2);
|
59
66
|
|
60
|
-
var
|
61
|
-
|
67
|
+
var _useOverlayPanelState2 = useOverlayPanelState(),
|
68
|
+
state = _useOverlayPanelState2.state,
|
69
|
+
onClose = _useOverlayPanelState2.onClose;
|
70
|
+
|
71
|
+
var _useOverlayPanelState3 = useOverlayPanelState(),
|
72
|
+
innerState = _useOverlayPanelState3.state,
|
73
|
+
onCloseInner = _useOverlayPanelState3.onClose;
|
74
|
+
|
75
|
+
var outerTriggerRef = useRef();
|
76
|
+
var innerTriggerRef = useRef();
|
62
77
|
|
63
78
|
var _useState = useState(false),
|
64
79
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -74,15 +89,22 @@ export var InnerPanel = function InnerPanel(_ref2) {
|
|
74
89
|
innerState.close();
|
75
90
|
}
|
76
91
|
|
77
|
-
state
|
92
|
+
onClose(state, outerTriggerRef);
|
93
|
+
};
|
94
|
+
|
95
|
+
var closeInnerPanel = function closeInnerPanel() {
|
96
|
+
onCloseInner(innerState, innerTriggerRef);
|
78
97
|
};
|
79
98
|
|
80
99
|
var inner = ___EmotionJSX(React.Fragment, null, innerState.isOpen && ___EmotionJSX(OverlayPanel, _extends({
|
81
100
|
variant: "overlayPanel.overlayPanelInner" // applies higher z-index
|
82
101
|
,
|
83
102
|
isOpen: innerState.isOpen
|
84
|
-
}, args
|
85
|
-
|
103
|
+
}, args, {
|
104
|
+
state: innerState,
|
105
|
+
triggerRef: innerTriggerRef
|
106
|
+
}), ___EmotionJSX(Box, null, ___EmotionJSX(Button, {
|
107
|
+
onPress: closeInnerPanel
|
86
108
|
}, "Close Inner Panel"), ___EmotionJSX(Text, {
|
87
109
|
pt: "md"
|
88
110
|
}, "Children render here."))));
|
@@ -93,7 +115,10 @@ export var InnerPanel = function InnerPanel(_ref2) {
|
|
93
115
|
sx: {
|
94
116
|
p: '0px'
|
95
117
|
}
|
96
|
-
}, args
|
118
|
+
}, args, {
|
119
|
+
state: state,
|
120
|
+
triggerRef: outerTriggerRef
|
121
|
+
}), ___EmotionJSX(Box, {
|
97
122
|
sx: {
|
98
123
|
p: '12px'
|
99
124
|
}
|
@@ -116,39 +141,17 @@ export var InnerPanel = function InnerPanel(_ref2) {
|
|
116
141
|
mr: "auto"
|
117
142
|
}, "Form 2")), ___EmotionJSX(Separator, {
|
118
143
|
margin: "0"
|
119
|
-
}), ___EmotionJSX(ListItem, {
|
120
|
-
title: "Form 3"
|
121
|
-
}, ___EmotionJSX(Text, {
|
122
|
-
variant: "itemTitle",
|
123
|
-
alignSelf: "center",
|
124
|
-
mr: "auto"
|
125
|
-
}, "Form 3")), ___EmotionJSX(Separator, {
|
126
|
-
margin: "0"
|
127
|
-
}), ___EmotionJSX(ListItem, {
|
128
|
-
title: "Form 4"
|
129
|
-
}, ___EmotionJSX(Text, {
|
130
|
-
variant: "itemTitle",
|
131
|
-
alignSelf: "center",
|
132
|
-
mr: "auto"
|
133
|
-
}, "Form 4")), ___EmotionJSX(Separator, {
|
134
|
-
margin: "0"
|
135
|
-
}), ___EmotionJSX(ListItem, {
|
136
|
-
title: "Form 5"
|
137
|
-
}, ___EmotionJSX(Text, {
|
138
|
-
variant: "itemTitle",
|
139
|
-
alignSelf: "center",
|
140
|
-
mr: "auto"
|
141
|
-
}, "Form 5")), ___EmotionJSX(Separator, {
|
142
|
-
margin: "0"
|
143
144
|
})), ___EmotionJSX("br", null), ___EmotionJSX(Button, {
|
144
145
|
onPress: toggleMessagesOpen
|
145
146
|
}, "Toggle Messages"), ___EmotionJSX("br", null), ___EmotionJSX(Button, {
|
147
|
+
ref: innerTriggerRef,
|
146
148
|
onPress: innerState.open
|
147
149
|
}, "Open Inner Panel"), inner)));
|
148
150
|
|
149
151
|
return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
150
152
|
// readers when an overlay opens.
|
151
153
|
___EmotionJSX(React.Fragment, null, ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
154
|
+
ref: outerTriggerRef,
|
152
155
|
onPress: state.open
|
153
156
|
}, "Open Panel"), outer), messagesOpen && ___EmotionJSX(Messages, {
|
154
157
|
sx: {
|
@@ -161,20 +164,27 @@ export var InnerPanel = function InnerPanel(_ref2) {
|
|
161
164
|
);
|
162
165
|
};
|
163
166
|
export var CustomWidth = function CustomWidth() {
|
164
|
-
var
|
167
|
+
var _useOverlayPanelState4 = useOverlayPanelState(),
|
168
|
+
state = _useOverlayPanelState4.state,
|
169
|
+
onClose = _useOverlayPanelState4.onClose;
|
170
|
+
|
171
|
+
var triggerRef = useRef();
|
165
172
|
return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
166
173
|
// readers when an overlay opens.
|
167
|
-
//
|
168
|
-
// For a custom width, provide the width via the 'sx' prop
|
169
174
|
___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."), ___EmotionJSX("br", null), ___EmotionJSX(Button, {
|
175
|
+
ref: triggerRef,
|
170
176
|
onPress: state.open
|
171
|
-
}, "Open Panel"), ___EmotionJSX(OverlayPanel, {
|
177
|
+
}, "Open Panel"), state.isOpen && ___EmotionJSX(OverlayPanel, {
|
172
178
|
isOpen: state.isOpen,
|
179
|
+
state: state,
|
180
|
+
triggerRef: triggerRef,
|
173
181
|
sx: {
|
174
182
|
width: '720px'
|
175
183
|
}
|
176
184
|
}, ___EmotionJSX(Box, null, ___EmotionJSX(Button, {
|
177
|
-
onPress:
|
185
|
+
onPress: function onPress() {
|
186
|
+
onClose(state, triggerRef);
|
187
|
+
}
|
178
188
|
}, "Close Panel"), ___EmotionJSX(Text, {
|
179
189
|
pt: "md"
|
180
190
|
}, "Children render here."))))
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React from 'react';
|
3
3
|
import axeTest from '../../utils/testUtils/testAxe';
|
4
|
-
import { render, screen } from '../../utils/testUtils/testWrapper';
|
4
|
+
import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
|
5
5
|
import OverlayPanel from './OverlayPanel';
|
6
6
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
7
|
var testId = 'test-overlayPanel';
|
@@ -38,4 +38,76 @@ test('custom overlayPanel gets custom width', function () {
|
|
38
38
|
var overlayPanel = screen.getByTestId(testId);
|
39
39
|
expect(overlayPanel).toBeInTheDocument();
|
40
40
|
expect(overlayPanel).toHaveStyleRule('width', '240px');
|
41
|
+
});
|
42
|
+
test('onClose callback fires when provided', function () {
|
43
|
+
var onClose = jest.fn();
|
44
|
+
getComponent({
|
45
|
+
onClose: onClose,
|
46
|
+
children: ___EmotionJSX("div", null, "Test")
|
47
|
+
});
|
48
|
+
var overlayPanel = screen.getByTestId(testId);
|
49
|
+
fireEvent.keyDown(overlayPanel, {
|
50
|
+
key: 'Escape',
|
51
|
+
code: 'Escape',
|
52
|
+
keyCode: 27,
|
53
|
+
charCode: 27
|
54
|
+
});
|
55
|
+
fireEvent.keyUp(overlayPanel, {
|
56
|
+
key: 'Escape',
|
57
|
+
code: 'Escape',
|
58
|
+
keyCode: 27,
|
59
|
+
charCode: 27
|
60
|
+
});
|
61
|
+
expect(onClose).toHaveBeenCalled();
|
62
|
+
});
|
63
|
+
test('neither callback fires when not provided', function () {
|
64
|
+
var onClose = jest.fn();
|
65
|
+
getComponent({
|
66
|
+
children: ___EmotionJSX("div", null, "Test")
|
67
|
+
});
|
68
|
+
var overlayPanel = screen.getByTestId(testId);
|
69
|
+
fireEvent.keyDown(overlayPanel, {
|
70
|
+
key: 'Escape',
|
71
|
+
code: 'Escape',
|
72
|
+
keyCode: 27,
|
73
|
+
charCode: 27
|
74
|
+
});
|
75
|
+
fireEvent.keyUp(overlayPanel, {
|
76
|
+
key: 'Escape',
|
77
|
+
code: 'Escape',
|
78
|
+
keyCode: 27,
|
79
|
+
charCode: 27
|
80
|
+
});
|
81
|
+
expect(onClose).not.toHaveBeenCalled();
|
82
|
+
});
|
83
|
+
test('triggerRef.current.focus() fires when provided', function () {
|
84
|
+
var onClose = jest.fn();
|
85
|
+
var focusFunction = jest.fn();
|
86
|
+
var state = {
|
87
|
+
close: onClose
|
88
|
+
};
|
89
|
+
var triggerRef = {
|
90
|
+
current: {
|
91
|
+
focus: focusFunction
|
92
|
+
}
|
93
|
+
};
|
94
|
+
getComponent({
|
95
|
+
state: state,
|
96
|
+
children: ___EmotionJSX("div", null, "Test"),
|
97
|
+
triggerRef: triggerRef
|
98
|
+
});
|
99
|
+
var overlayPanel = screen.getByTestId(testId);
|
100
|
+
fireEvent.keyDown(overlayPanel, {
|
101
|
+
key: 'Escape',
|
102
|
+
code: 'Escape',
|
103
|
+
keyCode: 27,
|
104
|
+
charCode: 27
|
105
|
+
});
|
106
|
+
fireEvent.keyUp(overlayPanel, {
|
107
|
+
key: 'Escape',
|
108
|
+
code: 'Escape',
|
109
|
+
keyCode: 27,
|
110
|
+
charCode: 27
|
111
|
+
});
|
112
|
+
expect(focusFunction).toHaveBeenCalled();
|
41
113
|
});
|
@@ -29,7 +29,7 @@ var Separator = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
29
29
|
return ___EmotionJSX(Box, _extends({
|
30
30
|
ref: ref,
|
31
31
|
className: classNames,
|
32
|
-
variant: "separator"
|
32
|
+
variant: "separator.base"
|
33
33
|
}, others, separatorProps));
|
34
34
|
});
|
35
35
|
Separator.propTypes = {
|
@@ -12,7 +12,11 @@ import { Textarea as ThemeUITextArea } from 'theme-ui';
|
|
12
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
13
13
|
var TextArea = /*#__PURE__*/forwardRef(function (props, ref) {
|
14
14
|
return ___EmotionJSX(ThemeUITextArea, _extends({
|
15
|
-
ref: ref
|
15
|
+
ref: ref // this requires to fix safari resizing issue (UIP-4995)
|
16
|
+
,
|
17
|
+
sx: {
|
18
|
+
position: 'relative'
|
19
|
+
}
|
16
20
|
}, props));
|
17
21
|
});
|
18
22
|
TextArea.displayName = 'TextArea';
|