@pingux/astro 1.1.0-alpha.6 → 1.1.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.test.js +24 -0
  3. package/lib/cjs/components/AccordionGroup/AccordionGroup.test.js +29 -0
  4. package/lib/cjs/components/AccordionItem/AccordionItem.js +4 -2
  5. package/lib/cjs/components/CodeView/CodeView.js +165 -0
  6. package/lib/cjs/components/CodeView/CodeView.stories.js +93 -0
  7. package/lib/cjs/components/CodeView/CodeView.test.js +211 -0
  8. package/lib/cjs/components/CodeView/index.js +18 -0
  9. package/lib/cjs/components/CopyText/CopyText.js +34 -11
  10. package/lib/cjs/components/FileInputField/FileItem.js +2 -1
  11. package/lib/cjs/components/List/List.js +3 -0
  12. package/lib/cjs/components/List/List.stories.js +7 -2
  13. package/lib/cjs/components/NavBar/NavBar.js +38 -0
  14. package/lib/cjs/components/NavBar/NavBar.stories.js +679 -0
  15. package/lib/cjs/components/NavBar/NavBar.test.js +116 -0
  16. package/lib/cjs/components/NavBar/index.js +18 -0
  17. package/lib/cjs/components/NavBarSection/NavBarItemBody.js +56 -0
  18. package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +47 -0
  19. package/lib/cjs/components/NavBarSection/NavBarSection.js +82 -0
  20. package/lib/cjs/components/NavBarSection/index.js +18 -0
  21. package/lib/cjs/components/OverlayPanel/OverlayPanel.js +53 -6
  22. package/lib/cjs/components/OverlayPanel/OverlayPanel.stories.js +63 -50
  23. package/lib/cjs/components/OverlayPanel/OverlayPanel.test.js +84 -0
  24. package/lib/cjs/components/PopoverContainer/PopoverContainer.test.js +15 -0
  25. package/lib/cjs/components/Separator/Separator.js +1 -1
  26. package/lib/cjs/components/TextArea/TextArea.js +5 -1
  27. package/lib/cjs/components/TooltipTrigger/TooltipTrigger.js +10 -5
  28. package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.js +20 -1
  29. package/lib/cjs/hooks/useOverlayPanelState/useOverlayPanelState.test.js +7 -3
  30. package/lib/cjs/index.js +84 -30
  31. package/lib/cjs/styles/variants/accordion.js +34 -3
  32. package/lib/cjs/styles/variants/boxes.js +24 -1
  33. package/lib/cjs/styles/variants/buttons.js +29 -1
  34. package/lib/cjs/styles/variants/codeView.js +80 -0
  35. package/lib/cjs/styles/variants/link.js +1 -1
  36. package/lib/cjs/styles/variants/separator.js +46 -3
  37. package/lib/cjs/styles/variants/text.js +15 -0
  38. package/lib/cjs/styles/variants/variants.js +3 -0
  39. package/lib/components/AccordionGridGroup/AccordionGridGroup.test.js +23 -1
  40. package/lib/components/AccordionGroup/AccordionGroup.test.js +26 -0
  41. package/lib/components/AccordionItem/AccordionItem.js +4 -2
  42. package/lib/components/CodeView/CodeView.js +130 -0
  43. package/lib/components/CodeView/CodeView.stories.js +67 -0
  44. package/lib/components/CodeView/CodeView.test.js +171 -0
  45. package/lib/components/CodeView/index.js +1 -0
  46. package/lib/components/CopyText/CopyText.js +35 -11
  47. package/lib/components/FileInputField/FileItem.js +2 -1
  48. package/lib/components/List/List.js +2 -0
  49. package/lib/components/List/List.stories.js +6 -2
  50. package/lib/components/NavBar/NavBar.js +24 -0
  51. package/lib/components/NavBar/NavBar.stories.js +650 -0
  52. package/lib/components/NavBar/NavBar.test.js +92 -0
  53. package/lib/components/NavBar/index.js +1 -0
  54. package/lib/components/NavBarSection/NavBarItemBody.js +37 -0
  55. package/lib/components/NavBarSection/NavBarItemHeader.js +31 -0
  56. package/lib/components/NavBarSection/NavBarSection.js +65 -0
  57. package/lib/components/NavBarSection/index.js +1 -0
  58. package/lib/components/OverlayPanel/OverlayPanel.js +52 -8
  59. package/lib/components/OverlayPanel/OverlayPanel.stories.js +56 -44
  60. package/lib/components/OverlayPanel/OverlayPanel.test.js +73 -1
  61. package/lib/components/PopoverContainer/PopoverContainer.test.js +16 -1
  62. package/lib/components/Separator/Separator.js +1 -1
  63. package/lib/components/TextArea/TextArea.js +5 -1
  64. package/lib/components/TooltipTrigger/TooltipTrigger.js +10 -5
  65. package/lib/hooks/useOverlayPanelState/useOverlayPanelState.js +20 -1
  66. package/lib/hooks/useOverlayPanelState/useOverlayPanelState.test.js +7 -3
  67. package/lib/index.js +5 -0
  68. package/lib/styles/variants/accordion.js +34 -3
  69. package/lib/styles/variants/boxes.js +24 -1
  70. package/lib/styles/variants/buttons.js +29 -1
  71. package/lib/styles/variants/codeView.js +68 -0
  72. package/lib/styles/variants/link.js +1 -1
  73. package/lib/styles/variants/separator.js +33 -1
  74. package/lib/styles/variants/text.js +15 -0
  75. package/lib/styles/variants/variants.js +2 -0
  76. package/package.json +4 -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
- others = _objectWithoutProperties(props, ["children", "isOpen", "className", "size"]);
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
- return ___EmotionJSX(Box, _extends({
33
- variant: "overlayPanel.overlayPanel"
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,11 +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
- import Button from '../Button/Button';
7
6
  import OverlayPanel from './OverlayPanel';
8
- import { OverlayProvider, Box, Text, List, ListItem, Separator, Messages } from '../../index';
7
+ import { OverlayProvider, Box, Text, List, ListItem, Separator, Messages, Button } from '../../index';
9
8
  import { panelSizes } from '../../utils/devUtils/constants/panelSizes';
10
9
  import { jsx as ___EmotionJSX } from "@emotion/react";
11
10
  export default {
@@ -38,15 +37,25 @@ export default {
38
37
  export var Default = function Default(_ref) {
39
38
  var args = _extends({}, _ref);
40
39
 
41
- var state = useOverlayPanelState();
40
+ var _useOverlayPanelState = useOverlayPanelState(),
41
+ state = _useOverlayPanelState.state,
42
+ onClose = _useOverlayPanelState.onClose;
43
+
44
+ var triggerRef = useRef();
42
45
  return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
43
- // readers when an overlay opens.
46
+ // readers when an overlay is open.
44
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,
45
49
  onPress: state.open
46
- }, "Open Panel"), ___EmotionJSX(OverlayPanel, _extends({
47
- isOpen: state.isOpen
48
- }, args), ___EmotionJSX(Box, null, ___EmotionJSX(Button, {
49
- onPress: state.close
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
+ }
50
59
  }, "Close Panel"), ___EmotionJSX(Text, {
51
60
  pt: "md"
52
61
  }, "Children render here."))))
@@ -55,8 +64,16 @@ export var Default = function Default(_ref) {
55
64
  export var InnerPanel = function InnerPanel(_ref2) {
56
65
  var args = _extends({}, _ref2);
57
66
 
58
- var state = useOverlayPanelState();
59
- var innerState = useOverlayPanelState();
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();
60
77
 
61
78
  var _useState = useState(false),
62
79
  _useState2 = _slicedToArray(_useState, 2),
@@ -72,15 +89,22 @@ export var InnerPanel = function InnerPanel(_ref2) {
72
89
  innerState.close();
73
90
  }
74
91
 
75
- state.close();
92
+ onClose(state, outerTriggerRef);
93
+ };
94
+
95
+ var closeInnerPanel = function closeInnerPanel() {
96
+ onCloseInner(innerState, innerTriggerRef);
76
97
  };
77
98
 
78
99
  var inner = ___EmotionJSX(React.Fragment, null, innerState.isOpen && ___EmotionJSX(OverlayPanel, _extends({
79
100
  variant: "overlayPanel.overlayPanelInner" // applies higher z-index
80
101
  ,
81
102
  isOpen: innerState.isOpen
82
- }, args), ___EmotionJSX(Box, null, ___EmotionJSX(Button, {
83
- onPress: innerState.close
103
+ }, args, {
104
+ state: innerState,
105
+ triggerRef: innerTriggerRef
106
+ }), ___EmotionJSX(Box, null, ___EmotionJSX(Button, {
107
+ onPress: closeInnerPanel
84
108
  }, "Close Inner Panel"), ___EmotionJSX(Text, {
85
109
  pt: "md"
86
110
  }, "Children render here."))));
@@ -91,7 +115,10 @@ export var InnerPanel = function InnerPanel(_ref2) {
91
115
  sx: {
92
116
  p: '0px'
93
117
  }
94
- }, args), ___EmotionJSX(Box, {
118
+ }, args, {
119
+ state: state,
120
+ triggerRef: outerTriggerRef
121
+ }), ___EmotionJSX(Box, {
95
122
  sx: {
96
123
  p: '12px'
97
124
  }
@@ -114,39 +141,17 @@ export var InnerPanel = function InnerPanel(_ref2) {
114
141
  mr: "auto"
115
142
  }, "Form 2")), ___EmotionJSX(Separator, {
116
143
  margin: "0"
117
- }), ___EmotionJSX(ListItem, {
118
- title: "Form 3"
119
- }, ___EmotionJSX(Text, {
120
- variant: "itemTitle",
121
- alignSelf: "center",
122
- mr: "auto"
123
- }, "Form 3")), ___EmotionJSX(Separator, {
124
- margin: "0"
125
- }), ___EmotionJSX(ListItem, {
126
- title: "Form 4"
127
- }, ___EmotionJSX(Text, {
128
- variant: "itemTitle",
129
- alignSelf: "center",
130
- mr: "auto"
131
- }, "Form 4")), ___EmotionJSX(Separator, {
132
- margin: "0"
133
- }), ___EmotionJSX(ListItem, {
134
- title: "Form 5"
135
- }, ___EmotionJSX(Text, {
136
- variant: "itemTitle",
137
- alignSelf: "center",
138
- mr: "auto"
139
- }, "Form 5")), ___EmotionJSX(Separator, {
140
- margin: "0"
141
144
  })), ___EmotionJSX("br", null), ___EmotionJSX(Button, {
142
145
  onPress: toggleMessagesOpen
143
146
  }, "Toggle Messages"), ___EmotionJSX("br", null), ___EmotionJSX(Button, {
147
+ ref: innerTriggerRef,
144
148
  onPress: innerState.open
145
149
  }, "Open Inner Panel"), inner)));
146
150
 
147
151
  return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
148
152
  // readers when an overlay opens.
149
153
  ___EmotionJSX(React.Fragment, null, ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
154
+ ref: outerTriggerRef,
150
155
  onPress: state.open
151
156
  }, "Open Panel"), outer), messagesOpen && ___EmotionJSX(Messages, {
152
157
  sx: {
@@ -159,20 +164,27 @@ export var InnerPanel = function InnerPanel(_ref2) {
159
164
  );
160
165
  };
161
166
  export var CustomWidth = function CustomWidth() {
162
- var state = useOverlayPanelState();
167
+ var _useOverlayPanelState4 = useOverlayPanelState(),
168
+ state = _useOverlayPanelState4.state,
169
+ onClose = _useOverlayPanelState4.onClose;
170
+
171
+ var triggerRef = useRef();
163
172
  return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
164
173
  // readers when an overlay opens.
165
- //
166
- // For a custom width, provide the width via the 'sx' prop
167
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,
168
176
  onPress: state.open
169
- }, "Open Panel"), ___EmotionJSX(OverlayPanel, {
177
+ }, "Open Panel"), state.isOpen && ___EmotionJSX(OverlayPanel, {
170
178
  isOpen: state.isOpen,
179
+ state: state,
180
+ triggerRef: triggerRef,
171
181
  sx: {
172
182
  width: '720px'
173
183
  }
174
184
  }, ___EmotionJSX(Box, null, ___EmotionJSX(Button, {
175
- onPress: state.close
185
+ onPress: function onPress() {
186
+ onClose(state, triggerRef);
187
+ }
176
188
  }, "Close Panel"), ___EmotionJSX(Text, {
177
189
  pt: "md"
178
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
  });
@@ -1,13 +1,20 @@
1
1
  import React from 'react';
2
2
  import axeTest from '../../utils/testUtils/testAxe';
3
3
  import { render, screen } from '../../utils/testUtils/testWrapper';
4
- import { Box } from '../../index';
4
+ import { Box, OverlayPanel } from '../../index';
5
5
  import PopoverContainer from './PopoverContainer';
6
6
  import { jsx as ___EmotionJSX } from "@emotion/react";
7
7
 
8
8
  var getComponent = function getComponent() {
9
9
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
10
10
  return render(___EmotionJSX(React.Fragment, null, ___EmotionJSX(PopoverContainer, props, ___EmotionJSX(Box, null, "I am in a popover"))));
11
+ };
12
+
13
+ var getComponentInOverlayPanel = function getComponentInOverlayPanel() {
14
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15
+ return render(___EmotionJSX(OverlayPanel, {
16
+ isOpen: true
17
+ }, ___EmotionJSX(PopoverContainer, props, ___EmotionJSX(Box, null, "I am in a popover"))));
11
18
  }; // Need to be added to each test file to test accessibility using axe.
12
19
 
13
20
 
@@ -26,4 +33,12 @@ test('should render a popover with no arrow', function () {
26
33
  });
27
34
  var arrow = screen.queryByTestId('popover-arrow');
28
35
  expect(arrow).not.toBeInTheDocument();
36
+ });
37
+ test('popover will not open if wrapped in an overlayPanel', function () {
38
+ getComponentInOverlayPanel({
39
+ popoverProps: {
40
+ 'data-test-id': 'popover-test'
41
+ }
42
+ });
43
+ expect(screen.queryByTestId('popover-test')).not.toBeInTheDocument();
29
44
  });
@@ -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';