@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,116 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _react = _interopRequireDefault(require("react"));
6
+
7
+ var _GlobeIcon = _interopRequireDefault(require("mdi-react/GlobeIcon"));
8
+
9
+ var _ViewDashboardIcon = _interopRequireDefault(require("mdi-react/ViewDashboardIcon"));
10
+
11
+ var _AccountMultipleIcon = _interopRequireDefault(require("mdi-react/AccountMultipleIcon"));
12
+
13
+ var _TransitConnectionVariantIcon = _interopRequireDefault(require("mdi-react/TransitConnectionVariantIcon"));
14
+
15
+ var _EmoticonHappyOutlineIcon = _interopRequireDefault(require("mdi-react/EmoticonHappyOutlineIcon"));
16
+
17
+ var _FingerprintIcon = _interopRequireDefault(require("mdi-react/FingerprintIcon"));
18
+
19
+ var _ScaleBalanceIcon = _interopRequireDefault(require("mdi-react/ScaleBalanceIcon"));
20
+
21
+ var _VerifiedIcon = _interopRequireDefault(require("mdi-react/VerifiedIcon"));
22
+
23
+ var _NavBar = _interopRequireDefault(require("./NavBar"));
24
+
25
+ var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
26
+
27
+ var _testWrapper = require("../../utils/testUtils/testWrapper");
28
+
29
+ var _index = require("../../index");
30
+
31
+ var _react2 = require("@emotion/react");
32
+
33
+ var data = [{
34
+ icon: _GlobeIcon["default"],
35
+ key: 'Overview',
36
+ heading: 'Overview',
37
+ children: ['Users', 'Group', 'Populations', 'Attributes', 'A roles title that is really really really really long']
38
+ }, {
39
+ icon: _ViewDashboardIcon["default"],
40
+ key: 'Dashboard',
41
+ heading: 'Dashboard',
42
+ children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
43
+ }, {
44
+ icon: _AccountMultipleIcon["default"],
45
+ key: 'Identities',
46
+ heading: 'Identities',
47
+ children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
48
+ }, {
49
+ icon: _TransitConnectionVariantIcon["default"],
50
+ key: 'Connections',
51
+ heading: 'Connections',
52
+ children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
53
+ }, {
54
+ icon: _EmoticonHappyOutlineIcon["default"],
55
+ key: 'Experiences',
56
+ heading: 'Experiences',
57
+ children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
58
+ }];
59
+ var secondData = [{
60
+ icon: _FingerprintIcon["default"],
61
+ key: 'MFA',
62
+ heading: 'MFA',
63
+ children: ['Users', {
64
+ subTitle: 'PingOne Services'
65
+ }, 'Group', 'Populations', 'Attributes', 'Roles']
66
+ }, {
67
+ icon: _ScaleBalanceIcon["default"],
68
+ key: 'Risk',
69
+ heading: 'Risk',
70
+ children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
71
+ }, {
72
+ icon: _VerifiedIcon["default"],
73
+ key: 'Verify',
74
+ heading: 'Verify',
75
+ children: ['Users', 'Group', 'Populations', 'Attributes', 'Roles']
76
+ }];
77
+
78
+ var getComponent = function getComponent() {
79
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
80
+ return (0, _testWrapper.render)((0, _react2.jsx)(_NavBar["default"], props, (0, _react2.jsx)(_index.Box, {
81
+ sx: {
82
+ height: '100%',
83
+ maxHeight: '100%',
84
+ overflowY: 'overlay !important'
85
+ }
86
+ }, (0, _react2.jsx)(_index.NavBarSection, {
87
+ items: data,
88
+ hasSeparator: true
89
+ }), (0, _react2.jsx)(_index.NavBarSection, {
90
+ items: secondData,
91
+ title: "test_title"
92
+ }))));
93
+ };
94
+
95
+ (0, _testAxe["default"])(getComponent);
96
+ test('should render basic nav with children', function () {
97
+ getComponent();
98
+
99
+ var nav = _testWrapper.screen.queryByRole('navigation');
100
+
101
+ expect(nav).toBeInTheDocument();
102
+ });
103
+ test('should render title for sections that have titles', function () {
104
+ getComponent();
105
+
106
+ var title = _testWrapper.screen.getByText('test_title');
107
+
108
+ expect(title).toBeInTheDocument();
109
+ });
110
+ test('should render title for itemBodies that have subTitles', function () {
111
+ getComponent();
112
+
113
+ var subTitle = _testWrapper.screen.getByText('PingOne Services');
114
+
115
+ expect(subTitle).toBeInTheDocument();
116
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ _Object$defineProperty(exports, "default", {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return _NavBar["default"];
15
+ }
16
+ });
17
+
18
+ var _NavBar = _interopRequireDefault(require("./NavBar"));
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard");
4
+
5
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
6
+
7
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
8
+
9
+ _Object$defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+
13
+ exports["default"] = void 0;
14
+
15
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
16
+
17
+ var _react = _interopRequireWildcard(require("react"));
18
+
19
+ var _propTypes = _interopRequireDefault(require("prop-types"));
20
+
21
+ var _index = require("../../index");
22
+
23
+ var _react2 = require("@emotion/react");
24
+
25
+ var NavBarItemBody = function NavBarItemBody(props) {
26
+ var _context;
27
+
28
+ return (0, _react2.jsx)(_index.Box, {
29
+ sx: {
30
+ alignItems: 'flex-start',
31
+ mb: '15px'
32
+ }
33
+ }, (0, _map["default"])(_context = props.item.children).call(_context, function (child) {
34
+ return child.subTitle ? (0, _react2.jsx)(_react.Fragment, {
35
+ key: "fragment".concat(child.subTitle)
36
+ }, (0, _react2.jsx)(_index.Separator, {
37
+ variant: "separator.navBarSubtitleSeparator",
38
+ key: "separator".concat(child.subTitle)
39
+ }), (0, _react2.jsx)(_index.Text, {
40
+ key: "text".concat(child.subTitle),
41
+ variant: "text.navBarSubtitle",
42
+ sx: {
43
+ mb: '10px',
44
+ ml: '45px'
45
+ }
46
+ }, child.subTitle)) : child;
47
+ }));
48
+ };
49
+
50
+ NavBarItemBody.propTypes = {
51
+ item: _propTypes["default"].shape({
52
+ children: _propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object]))
53
+ })
54
+ };
55
+ var _default = NavBarItemBody;
56
+ exports["default"] = _default;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports["default"] = void 0;
12
+
13
+ var _react = _interopRequireDefault(require("react"));
14
+
15
+ var _propTypes = _interopRequireDefault(require("prop-types"));
16
+
17
+ var _index = require("../../index");
18
+
19
+ var _react2 = require("@emotion/react");
20
+
21
+ var NavBarItemHeader = function NavBarItemHeader(props) {
22
+ var item = props.item;
23
+ var icon = item.icon;
24
+ return (0, _react2.jsx)(_index.Box, {
25
+ variant: "boxes.navBarItemHeaderContainer",
26
+ isRow: true
27
+ }, icon && (0, _react2.jsx)(_index.Icon, {
28
+ icon: icon,
29
+ size: 20,
30
+ sx: {
31
+ mr: '10px',
32
+ color: 'white',
33
+ fill: 'white'
34
+ }
35
+ }), (0, _react2.jsx)(_index.Text, {
36
+ variant: "navBarHeaderText"
37
+ }, props.item.heading));
38
+ };
39
+
40
+ NavBarItemHeader.propTypes = {
41
+ item: _propTypes["default"].shape({
42
+ heading: _propTypes["default"].string,
43
+ icon: _propTypes["default"].elementType
44
+ })
45
+ };
46
+ var _default = NavBarItemHeader;
47
+ exports["default"] = _default;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ exports["default"] = void 0;
12
+
13
+ var _react = _interopRequireDefault(require("react"));
14
+
15
+ var _propTypes = _interopRequireDefault(require("prop-types"));
16
+
17
+ var _index = require("../../index");
18
+
19
+ var _NavBarItemBody = _interopRequireDefault(require("./NavBarItemBody"));
20
+
21
+ var _NavBarItemHeader = _interopRequireDefault(require("./NavBarItemHeader"));
22
+
23
+ var _react2 = require("@emotion/react");
24
+
25
+ /**
26
+ * Composed component that creates an AccordionGrid group
27
+ * with title, and separator options.
28
+ *
29
+ */
30
+ var NavBarSection = function NavBarSection(props) {
31
+ var hasSeparator = props.hasSeparator,
32
+ title = props.title,
33
+ items = props.items;
34
+ return (0, _react2.jsx)(_react["default"].Fragment, null, title && (0, _react2.jsx)(_index.Text, {
35
+ variant: "text.navBarSubtitle",
36
+ sx: {
37
+ mt: '25px',
38
+ mb: '15px',
39
+ ml: '15px'
40
+ }
41
+ }, title), (0, _react2.jsx)(_index.AccordionGridGroup, {
42
+ items: items
43
+ }, function (item) {
44
+ return (0, _react2.jsx)(_index.Item, {
45
+ headerProps: {
46
+ variant: 'accordion.accordionGridHeaderNav'
47
+ },
48
+ textValue: item
49
+ }, (0, _react2.jsx)(_NavBarItemHeader["default"], {
50
+ item: item
51
+ }), (0, _react2.jsx)(_NavBarItemBody["default"], {
52
+ item: item
53
+ }));
54
+ }), hasSeparator && (0, _react2.jsx)(_index.Box, {
55
+ sx: {
56
+ pl: '15px',
57
+ pr: '15px',
58
+ mt: '25px'
59
+ }
60
+ }, (0, _react2.jsx)(_index.Separator, {
61
+ variant: "separator.navBarSeparator"
62
+ })));
63
+ };
64
+
65
+ NavBarSection.defaultProps = {
66
+ hasSeparator: false
67
+ };
68
+ NavBarSection.propTypes = {
69
+ /** If true, a separator will render at the end of the section */
70
+ hasSeparator: _propTypes["default"].bool,
71
+
72
+ /** If present, this string will render at the top of the section */
73
+ title: _propTypes["default"].string,
74
+
75
+ /**
76
+ * *For performance reasons, use this prop instead of Array.map when iteratively rendering Items*.
77
+ * For use with [dynamic collections](https://react-spectrum.adobe.com/react-stately/collections.html#dynamic-collections).
78
+ */
79
+ items: _propTypes["default"].arrayOf(_propTypes["default"].shape({}))
80
+ };
81
+ var _default = NavBarSection;
82
+ exports["default"] = _default;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
+
7
+ _Object$defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+
11
+ _Object$defineProperty(exports, "default", {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return _NavBarSection["default"];
15
+ }
16
+ });
17
+
18
+ var _NavBarSection = _interopRequireDefault(require("./NavBarSection"));
@@ -18,12 +18,16 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
18
18
 
19
19
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
20
20
 
21
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
22
+
21
23
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
22
24
 
23
25
  var _react = _interopRequireWildcard(require("react"));
24
26
 
25
27
  var _propTypes = _interopRequireDefault(require("prop-types"));
26
28
 
29
+ var _focus = require("@react-aria/focus");
30
+
27
31
  var _Box = _interopRequireDefault(require("../Box"));
28
32
 
29
33
  var _hooks = require("../../hooks");
@@ -37,12 +41,25 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
37
41
 
38
42
  var children = props.children,
39
43
  isOpen = props.isOpen,
44
+ onCloseProp = props.onClose,
40
45
  className = props.className,
46
+ state = props.state,
41
47
  size = props.size,
42
- others = (0, _objectWithoutProperties2["default"])(props, ["children", "isOpen", "className", "size"]);
48
+ triggerRef = props.triggerRef,
49
+ others = (0, _objectWithoutProperties2["default"])(props, ["children", "isOpen", "onClose", "className", "state", "size", "triggerRef"]);
50
+
51
+ var _useOverlayPanelState = (0, _hooks.useOverlayPanelState)(),
52
+ onClose = _useOverlayPanelState.onClose;
53
+
43
54
  var overlayPanelRef = (0, _react.useRef)();
55
+
56
+ var _useState = (0, _react.useState)(true),
57
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
58
+ contain = _useState2[0],
59
+ setIsContained = _useState2[1];
44
60
  /* istanbul ignore next */
45
61
 
62
+
46
63
  (0, _react.useImperativeHandle)(ref, function () {
47
64
  return overlayPanelRef.current;
48
65
  });
@@ -52,14 +69,32 @@ var OverlayPanel = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
52
69
  }, "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)),
53
70
  classNames = _useStatusClasses.classNames;
54
71
 
55
- return (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
56
- variant: "overlayPanel.overlayPanel"
72
+ var handleClose = function handleClose(e) {
73
+ e.stopPropagation();
74
+
75
+ if (e.key === 'Escape') {
76
+ setIsContained(false);
77
+ }
78
+ };
79
+
80
+ (0, _react.useEffect)(function () {
81
+ if (!contain && onClose) {
82
+ onClose(state, triggerRef, onCloseProp);
83
+ }
84
+ }, [contain]);
85
+ return (0, _react2.jsx)(_focus.FocusScope, {
86
+ autoFocus: true,
87
+ contain: contain
88
+ }, (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
89
+ variant: "overlayPanel.overlayPanel",
90
+ ref: overlayPanelRef
57
91
  }, others, {
58
- className: classNames
92
+ className: classNames,
93
+ onKeyUp: handleClose
59
94
  }), (0, _react2.jsx)(_Box["default"], {
60
95
  variant: "overlayPanel.overlayPanelBody",
61
96
  className: classNames
62
- }, children));
97
+ }, children)));
63
98
  });
64
99
  OverlayPanel.propTypes = {
65
100
  /** Sets the open state of the menu. */
@@ -71,7 +106,19 @@ OverlayPanel.propTypes = {
71
106
  /** JSX styling that is passed into the component. */
72
107
  sx: _propTypes["default"].shape({
73
108
  width: _propTypes["default"].string
74
- })
109
+ }),
110
+
111
+ /** State object that is passed in from the useOverlayPanelState hook */
112
+ state: _propTypes["default"].shape({
113
+ close: _propTypes["default"].func
114
+ }),
115
+
116
+ /** Callback function that runs when the esc key is used to close the OverlayPanel. */
117
+ onClose: _propTypes["default"].func,
118
+
119
+ /** Ref that is connected to the button that triggers the overlay state.
120
+ Focus will return to this ref when the keyboard is used to close the OverlayPanel. */
121
+ triggerRef: _propTypes["default"].shape({})
75
122
  };
76
123
  OverlayPanel.defaultProps = {
77
124
  size: 'medium'
@@ -22,8 +22,6 @@ var _collections = require("@react-stately/collections");
22
22
 
23
23
  var _hooks = require("../../hooks");
24
24
 
25
- var _Button = _interopRequireDefault(require("../Button/Button"));
26
-
27
25
  var _OverlayPanel = _interopRequireDefault(require("./OverlayPanel"));
28
26
 
29
27
  var _index = require("../../index");
@@ -63,15 +61,26 @@ exports["default"] = _default;
63
61
 
64
62
  var Default = function Default(_ref) {
65
63
  var args = (0, _extends2["default"])({}, _ref);
66
- var state = (0, _hooks.useOverlayPanelState)();
64
+
65
+ var _useOverlayPanelState = (0, _hooks.useOverlayPanelState)(),
66
+ state = _useOverlayPanelState.state,
67
+ onClose = _useOverlayPanelState.onClose;
68
+
69
+ var triggerRef = (0, _react.useRef)();
67
70
  return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
68
- // readers when an overlay opens.
69
- (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.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."), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_Button["default"], {
71
+ // readers when an overlay is open.
72
+ (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.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."), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_index.Button, {
73
+ ref: triggerRef,
70
74
  onPress: state.open
71
- }, "Open Panel"), (0, _react2.jsx)(_OverlayPanel["default"], (0, _extends2["default"])({
72
- isOpen: state.isOpen
73
- }, args), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_Button["default"], {
74
- onPress: state.close
75
+ }, "Open Panel"), state.isOpen && (0, _react2.jsx)(_OverlayPanel["default"], (0, _extends2["default"])({
76
+ isOpen: state.isOpen,
77
+ state: state
78
+ }, args, {
79
+ triggerRef: triggerRef
80
+ }), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Button, {
81
+ onPress: function onPress() {
82
+ onClose(state, triggerRef);
83
+ }
75
84
  }, "Close Panel"), (0, _react2.jsx)(_index.Text, {
76
85
  pt: "md"
77
86
  }, "Children render here."))))
@@ -82,8 +91,17 @@ exports.Default = Default;
82
91
 
83
92
  var InnerPanel = function InnerPanel(_ref2) {
84
93
  var args = (0, _extends2["default"])({}, _ref2);
85
- var state = (0, _hooks.useOverlayPanelState)();
86
- var innerState = (0, _hooks.useOverlayPanelState)();
94
+
95
+ var _useOverlayPanelState2 = (0, _hooks.useOverlayPanelState)(),
96
+ state = _useOverlayPanelState2.state,
97
+ onClose = _useOverlayPanelState2.onClose;
98
+
99
+ var _useOverlayPanelState3 = (0, _hooks.useOverlayPanelState)(),
100
+ innerState = _useOverlayPanelState3.state,
101
+ onCloseInner = _useOverlayPanelState3.onClose;
102
+
103
+ var outerTriggerRef = (0, _react.useRef)();
104
+ var innerTriggerRef = (0, _react.useRef)();
87
105
 
88
106
  var _useState = (0, _react.useState)(false),
89
107
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
@@ -99,15 +117,22 @@ var InnerPanel = function InnerPanel(_ref2) {
99
117
  innerState.close();
100
118
  }
101
119
 
102
- state.close();
120
+ onClose(state, outerTriggerRef);
121
+ };
122
+
123
+ var closeInnerPanel = function closeInnerPanel() {
124
+ onCloseInner(innerState, innerTriggerRef);
103
125
  };
104
126
 
105
127
  var inner = (0, _react2.jsx)(_react["default"].Fragment, null, innerState.isOpen && (0, _react2.jsx)(_OverlayPanel["default"], (0, _extends2["default"])({
106
128
  variant: "overlayPanel.overlayPanelInner" // applies higher z-index
107
129
  ,
108
130
  isOpen: innerState.isOpen
109
- }, args), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_Button["default"], {
110
- onPress: innerState.close
131
+ }, args, {
132
+ state: innerState,
133
+ triggerRef: innerTriggerRef
134
+ }), (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Button, {
135
+ onPress: closeInnerPanel
111
136
  }, "Close Inner Panel"), (0, _react2.jsx)(_index.Text, {
112
137
  pt: "md"
113
138
  }, "Children render here."))));
@@ -117,11 +142,14 @@ var InnerPanel = function InnerPanel(_ref2) {
117
142
  sx: {
118
143
  p: '0px'
119
144
  }
120
- }, args), (0, _react2.jsx)(_index.Box, {
145
+ }, args, {
146
+ state: state,
147
+ triggerRef: outerTriggerRef
148
+ }), (0, _react2.jsx)(_index.Box, {
121
149
  sx: {
122
150
  p: '12px'
123
151
  }
124
- }, (0, _react2.jsx)(_Button["default"], {
152
+ }, (0, _react2.jsx)(_index.Button, {
125
153
  onPress: closeOuterPanel
126
154
  }, "Close Panel"), (0, _react2.jsx)(_index.Text, {
127
155
  pt: "md",
@@ -140,38 +168,16 @@ var InnerPanel = function InnerPanel(_ref2) {
140
168
  mr: "auto"
141
169
  }, "Form 2")), (0, _react2.jsx)(_index.Separator, {
142
170
  margin: "0"
143
- }), (0, _react2.jsx)(_index.ListItem, {
144
- title: "Form 3"
145
- }, (0, _react2.jsx)(_index.Text, {
146
- variant: "itemTitle",
147
- alignSelf: "center",
148
- mr: "auto"
149
- }, "Form 3")), (0, _react2.jsx)(_index.Separator, {
150
- margin: "0"
151
- }), (0, _react2.jsx)(_index.ListItem, {
152
- title: "Form 4"
153
- }, (0, _react2.jsx)(_index.Text, {
154
- variant: "itemTitle",
155
- alignSelf: "center",
156
- mr: "auto"
157
- }, "Form 4")), (0, _react2.jsx)(_index.Separator, {
158
- margin: "0"
159
- }), (0, _react2.jsx)(_index.ListItem, {
160
- title: "Form 5"
161
- }, (0, _react2.jsx)(_index.Text, {
162
- variant: "itemTitle",
163
- alignSelf: "center",
164
- mr: "auto"
165
- }, "Form 5")), (0, _react2.jsx)(_index.Separator, {
166
- margin: "0"
167
- })), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_Button["default"], {
171
+ })), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_index.Button, {
168
172
  onPress: toggleMessagesOpen
169
- }, "Toggle Messages"), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_Button["default"], {
173
+ }, "Toggle Messages"), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_index.Button, {
174
+ ref: innerTriggerRef,
170
175
  onPress: innerState.open
171
176
  }, "Open Inner Panel"), inner)));
172
177
  return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
173
178
  // readers when an overlay opens.
174
- (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_Button["default"], {
179
+ (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.Button, {
180
+ ref: outerTriggerRef,
175
181
  onPress: state.open
176
182
  }, "Open Panel"), outer), messagesOpen && (0, _react2.jsx)(_index.Messages, {
177
183
  sx: {
@@ -187,20 +193,27 @@ var InnerPanel = function InnerPanel(_ref2) {
187
193
  exports.InnerPanel = InnerPanel;
188
194
 
189
195
  var CustomWidth = function CustomWidth() {
190
- var state = (0, _hooks.useOverlayPanelState)();
196
+ var _useOverlayPanelState4 = (0, _hooks.useOverlayPanelState)(),
197
+ state = _useOverlayPanelState4.state,
198
+ onClose = _useOverlayPanelState4.onClose;
199
+
200
+ var triggerRef = (0, _react.useRef)();
191
201
  return (// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
192
202
  // readers when an overlay opens.
193
- //
194
- // For a custom width, provide the width via the 'sx' prop
195
- (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.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."), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_Button["default"], {
203
+ (0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.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."), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_index.Button, {
204
+ ref: triggerRef,
196
205
  onPress: state.open
197
- }, "Open Panel"), (0, _react2.jsx)(_OverlayPanel["default"], {
206
+ }, "Open Panel"), state.isOpen && (0, _react2.jsx)(_OverlayPanel["default"], {
198
207
  isOpen: state.isOpen,
208
+ state: state,
209
+ triggerRef: triggerRef,
199
210
  sx: {
200
211
  width: '720px'
201
212
  }
202
- }, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_Button["default"], {
203
- onPress: state.close
213
+ }, (0, _react2.jsx)(_index.Box, null, (0, _react2.jsx)(_index.Button, {
214
+ onPress: function onPress() {
215
+ onClose(state, triggerRef);
216
+ }
204
217
  }, "Close Panel"), (0, _react2.jsx)(_index.Text, {
205
218
  pt: "md"
206
219
  }, "Children render here."))))