@pingux/astro 2.53.0-alpha.1 → 2.53.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.
@@ -278,7 +278,42 @@ declare const _default: {
278
278
  outline: string;
279
279
  };
280
280
  messageCloseButton: any;
281
- modalCloseButton: any;
281
+ modalCloseButton: {
282
+ position: string;
283
+ top: number;
284
+ right: number;
285
+ width: string;
286
+ height: string;
287
+ justifyContent: string;
288
+ appearance: string;
289
+ alignItems: string;
290
+ alignSelf: string;
291
+ display: string;
292
+ flexGrow: number;
293
+ flexShrink: number;
294
+ borderRadius: string;
295
+ cursor: string;
296
+ bg: string;
297
+ p: string;
298
+ path: {
299
+ fill: string;
300
+ };
301
+ outline: string;
302
+ '&.is-focused': {
303
+ outline: string;
304
+ outlineColor: string;
305
+ outlineOffset: string;
306
+ };
307
+ '&.is-hovered': {
308
+ bg: string;
309
+ };
310
+ '&.is-pressed': {
311
+ path: {
312
+ fill: string;
313
+ };
314
+ bg: string;
315
+ };
316
+ };
282
317
  invertedBadgeDeleteButton: {
283
318
  path: {
284
319
  fill: string;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ModalProps } from '../../types';
3
+ declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLElement>>;
4
+ export default Modal;
@@ -22,9 +22,7 @@ var _react = _interopRequireWildcard(require("react"));
22
22
  var _reactAria = require("react-aria");
23
23
  var _CloseIcon = _interopRequireDefault(require("@pingux/mdi-react/CloseIcon"));
24
24
  var _overlays = require("@react-aria/overlays");
25
- var _propTypes = _interopRequireDefault(require("prop-types"));
26
25
  var _hooks = require("../../hooks");
27
- var _modalSizes = require("../../utils/devUtils/constants/modalSizes");
28
26
  var _Box = _interopRequireDefault(require("../Box"));
29
27
  var _Icon = _interopRequireDefault(require("../Icon"));
30
28
  var _IconButton = _interopRequireDefault(require("../IconButton"));
@@ -70,11 +68,8 @@ var Modal = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
70
68
  isOpen: isOpen,
71
69
  close: onClose
72
70
  };
73
- var modalRef = (0, _react.useRef)();
74
- /* istanbul ignore next */
75
- (0, _react.useImperativeHandle)(ref, function () {
76
- return modalRef.current;
77
- });
71
+ var modalRef = (0, _hooks.useLocalOrForwardRef)(ref);
72
+
78
73
  // Handle interacting outside the dialog and pressing
79
74
  // the Escape key to close the modal,
80
75
  // prevent scrolling while the modal is open, and hide content
@@ -91,7 +86,9 @@ var Modal = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
91
86
  classNames = _useStatusClasses.classNames;
92
87
  return (0, _react2.jsx)(_reactAria.OverlayContainer, null, (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
93
88
  variant: "modal.container"
94
- }, (0, _reactAria.mergeProps)(containerProps, underlayProps, others)), (0, _react2.jsx)(_reactAria.FocusScope, {
89
+ }, (0, _reactAria.mergeProps)(containerProps, underlayProps, others), {
90
+ role: "none"
91
+ }), (0, _react2.jsx)(_reactAria.FocusScope, {
95
92
  contain: true,
96
93
  restoreFocus: true,
97
94
  autoFocus: hasAutoFocus
@@ -100,7 +97,8 @@ var Modal = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
100
97
  className: classNames
101
98
  }, propsContentProps, dialogProps, modalProps, {
102
99
  ref: modalRef,
103
- "aria-modal": true
100
+ "aria-modal": true,
101
+ role: "dialog"
104
102
  }), hasCloseButton && (closeButton !== null && closeButton !== void 0 ? closeButton : (0, _react2.jsx)(_IconButton["default"], {
105
103
  "aria-label": "Close modal window",
106
104
  "data-id": "icon-button__close-modal-window",
@@ -112,63 +110,10 @@ var Modal = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
112
110
  name: 'Close Icon'
113
111
  }
114
112
  }))), title && (0, _react2.jsx)(_Text["default"], (0, _extends2["default"])({}, titleProps, {
115
- variant: "variants.modal.title"
113
+ variant: "variants.modal.title",
114
+ role: "heading"
116
115
  }), title), children))));
117
116
  });
118
- Modal.propTypes = {
119
- /** Used in tandem with `hasCloseButton` to customize how the close button is rendered. */
120
- closeButton: _propTypes["default"].node,
121
- /** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
122
- id: _propTypes["default"].string,
123
- /** Whether to auto focus the first focusable element in the focus scope on mount. */
124
- hasAutoFocus: _propTypes["default"].bool,
125
- /** Whether the modal has a visible close button. */
126
- hasCloseButton: _propTypes["default"].bool,
127
- /** Whether the overlay should close when focus is lost or moves outside it. */
128
- isClosedOnBlur: _propTypes["default"].bool,
129
- /** Whether to close the overlay when the user interacts outside it. */
130
- isDismissable: _propTypes["default"].bool,
131
- /** Whether pressing the escape key to close the overlay should be disabled. */
132
- isKeyboardDismissDisabled: _propTypes["default"].bool,
133
- /** Whether the overlay is currently open. */
134
- isOpen: _propTypes["default"].bool,
135
- /** The accessibility role for the dialog. */
136
- role: _propTypes["default"].oneOf(['dialog', 'alertdialog']),
137
- /** Sets the size of the modal container. */
138
- size: _propTypes["default"].oneOf(_modalSizes.modalSizes),
139
- /** The title for the modal. */
140
- title: _propTypes["default"].node,
141
- /**
142
- * Handler that is called when the overlay should close.
143
- *
144
- * `() => void`
145
- */
146
- onClose: _propTypes["default"].func,
147
- /**
148
- * When a user interacts with the argument element outside of the overlay ref, return true if
149
- * onClose should be called. This gives you a chance to filter out interaction with elements that
150
- * should not dismiss the overlay. By default, onClose will always be called on interaction
151
- * outside the overlay ref.
152
- *
153
- * `(element: HTMLElement) => boolean`
154
- */
155
- shouldCloseOnInteractOutside: _propTypes["default"].func,
156
- /** Defines a string value that labels the current element. */
157
- 'aria-label': _propTypes["default"].string,
158
- /** Identifies the element (or elements) that labels the current element. */
159
- 'aria-labelledby': _propTypes["default"].string,
160
- /** Identifies the element (or elements) that describes the object. */
161
- 'aria-describedby': _propTypes["default"].string,
162
- /**
163
- * Identifies the element (or elements) that provide a detailed, extended description for the
164
- * object.
165
- */
166
- 'aria-details': _propTypes["default"].string,
167
- /** Props object spread directly into the modal content Box. */
168
- contentProps: _propTypes["default"].shape({}),
169
- /** Props object spread directly into the modal container Box. */
170
- containerProps: _propTypes["default"].shape({})
171
- };
172
117
  Modal.defaultProps = {
173
118
  role: 'dialog'
174
119
  };
@@ -0,0 +1,5 @@
1
+ import { StoryFn } from '@storybook/react';
2
+ import { ModalProps } from '../../types';
3
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
4
+ export default _default;
5
+ export declare const Default: StoryFn<ModalProps>;
@@ -12,7 +12,7 @@ var _storybookAddonDesigns = require("storybook-addon-designs");
12
12
  var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
13
13
  var _hooks = require("../../hooks");
14
14
  var _index = require("../../index");
15
- var _figmaLinks = require("../../utils/designUtils/figmaLinks.ts");
15
+ var _figmaLinks = require("../../utils/designUtils/figmaLinks");
16
16
  var _modalSizes = require("../../utils/devUtils/constants/modalSizes");
17
17
  var _Modal = _interopRequireDefault(require("./Modal.mdx"));
18
18
  var _react2 = require("@emotion/react");
@@ -0,0 +1,77 @@
1
+ export declare const modalCloseButton: {
2
+ position: string;
3
+ top: number;
4
+ right: number;
5
+ width: string;
6
+ height: string;
7
+ };
8
+ declare const _default: {
9
+ closeIcon: {
10
+ color: string;
11
+ };
12
+ container: {
13
+ position: string;
14
+ zIndex: number;
15
+ top: number;
16
+ left: number;
17
+ bottom: number;
18
+ right: number;
19
+ background: string;
20
+ display: string;
21
+ alignItems: string;
22
+ justifyContent: string;
23
+ };
24
+ content: {
25
+ position: string;
26
+ outline: string;
27
+ background: string;
28
+ color: string;
29
+ pt: string;
30
+ pr: string;
31
+ pb: string;
32
+ pl: string;
33
+ maxWidth: string;
34
+ boxShadow: string;
35
+ borderRadius: number;
36
+ '&.is-extra-small': {
37
+ maxWidth: string;
38
+ width: string;
39
+ };
40
+ '&.is-small': {
41
+ maxWidth: string;
42
+ width: string;
43
+ };
44
+ '&.is-medium': {
45
+ maxWidth: string;
46
+ width: string;
47
+ };
48
+ '&.is-large': {
49
+ maxWidth: string;
50
+ width: string;
51
+ };
52
+ '&.is-full': {
53
+ maxWidth: string;
54
+ width: string;
55
+ };
56
+ };
57
+ title: {
58
+ mr: string;
59
+ fontWeight: number;
60
+ fontSize: string;
61
+ color: string;
62
+ fontFamily: string;
63
+ display: string;
64
+ overflowWrap: import("../..").overflowWrap;
65
+ maxWidth: string;
66
+ wordWrap: import("../..").wordWrap;
67
+ wordBreak: import("../..").wordBreak;
68
+ };
69
+ modalCloseButton: {
70
+ position: string;
71
+ top: number;
72
+ right: number;
73
+ width: string;
74
+ height: string;
75
+ };
76
+ };
77
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default } from './Modal';
@@ -22,7 +22,9 @@ var _react2 = require("@emotion/react");
22
22
  hasCloseButton: true
23
23
  }, modalProps))));
24
24
  };
25
- var getComposedComponent = function getComposedComponent(defaultState, modalProps) {
25
+ var getComposedComponent = function getComposedComponent() {
26
+ var defaultState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27
+ var modalProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26
28
  return (0, _testWrapper.render)((0, _react2.jsx)(ComposedComponent, {
27
29
  defaultState: defaultState,
28
30
  modalProps: modalProps
@@ -33,12 +35,12 @@ test('clicking the trigger should open the modal', function () {
33
35
  expect(_testWrapper.screen.queryByRole('dialog')).not.toBeInTheDocument();
34
36
 
35
37
  // Open it with the button trigger
36
- _userEvent["default"].click(_testWrapper.screen.queryByRole('button'));
38
+ _userEvent["default"].click(_testWrapper.screen.getByRole('button'));
37
39
  expect(_testWrapper.screen.queryByRole('dialog')).toBeInTheDocument();
38
40
  });
39
41
  test('keyboard interaction with the trigger should open the modal', function () {
40
42
  getComposedComponent();
41
- var button = _testWrapper.screen.queryByRole('button');
43
+ var button = _testWrapper.screen.getByRole('button');
42
44
  expect(_testWrapper.screen.queryByRole('dialog')).not.toBeInTheDocument();
43
45
 
44
46
  // Open it with the button trigger
@@ -79,11 +81,11 @@ test('keyboard interactions on the close button should close the modal', functio
79
81
  });
80
82
  test('assign aria-hidden to elements outside the modal when the modal is opened', function () {
81
83
  getComposedComponent();
82
- var button = _testWrapper.screen.queryByRole('button');
84
+ var button = _testWrapper.screen.getByRole('button');
83
85
  var buttonParent = button.closest('div');
84
86
  expect(buttonParent).not.toHaveAttribute('aria-hidden');
85
87
 
86
88
  // Open the modal
87
- _userEvent["default"].click(_testWrapper.screen.queryByRole('button'));
89
+ _userEvent["default"].click(_testWrapper.screen.getByRole('button'));
88
90
  expect(buttonParent).toHaveAttribute('aria-hidden');
89
91
  });
@@ -32,32 +32,32 @@ test('default modal', function () {
32
32
  });
33
33
  test('should spread undocumented props to the container element', function () {
34
34
  getComponent({
35
- 'data-prop': 'test'
35
+ 'data-testid': 'test'
36
36
  });
37
- var container = (0, _testWrapper.queryByAttribute)('data-prop', document, 'test');
37
+ var container = _testWrapper.screen.queryByTestId('test');
38
38
  var modal = _testWrapper.screen.getByRole('dialog');
39
39
  expect(container).toContainElement(modal);
40
- expect(modal).not.toHaveAttribute('data-prop', 'test');
40
+ expect(modal).not.toHaveAttribute('data-testid', 'test');
41
41
  });
42
42
  test('should spread container props to the container element even if documented', function () {
43
43
  getComponent({
44
44
  containerProps: {
45
- id: 'test'
45
+ 'data-testid': 'test'
46
46
  }
47
47
  });
48
- var container = (0, _testWrapper.queryByAttribute)('id', document, 'test');
48
+ var container = _testWrapper.screen.queryByTestId('test');
49
49
  var modal = _testWrapper.screen.getByRole('dialog');
50
50
  expect(container).toContainElement(modal);
51
- expect(modal).not.toHaveAttribute('id', 'test');
51
+ expect(modal).not.toHaveAttribute('data-testid', 'test');
52
52
  });
53
53
  test('should spread content props to the modal dialog even if undocumented', function () {
54
54
  getComponent({
55
55
  contentProps: {
56
- 'data-prop': 'test'
56
+ 'data-testid': 'test'
57
57
  }
58
58
  });
59
59
  var modal = _testWrapper.screen.getByRole('dialog');
60
- expect(modal).toHaveAttribute('data-prop', 'test');
60
+ expect(modal).toHaveAttribute('data-testid', 'test');
61
61
  });
62
62
  test('should display title for modal', function () {
63
63
  var title = 'my title';
@@ -0,0 +1,58 @@
1
+ import { ReactNode } from 'react';
2
+ import { DOMAttributes } from './shared/dom';
3
+ import { ModalSizeProps } from './shared/style';
4
+ import { TestingAttributes } from './shared/test';
5
+ export interface ModalProps extends DOMAttributes, TestingAttributes {
6
+ /** Used in tandem with `hasCloseButton` to customize how the close button is rendered. */
7
+ closeButton?: ReactNode;
8
+ /** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
9
+ id?: string;
10
+ /** Whether to auto focus the first focusable element in the focus scope on mount. */
11
+ hasAutoFocus?: boolean;
12
+ /** Whether the modal has a visible close button. */
13
+ hasCloseButton?: boolean;
14
+ /** Whether the overlay should close when focus is lost or moves outside it. */
15
+ isClosedOnBlur?: boolean;
16
+ /** Whether to close the overlay when the user interacts outside it. */
17
+ isDismissable?: boolean;
18
+ /** Whether pressing the escape key to close the overlay should be disabled. */
19
+ isKeyboardDismissDisabled?: boolean;
20
+ /** Whether the overlay is currently open. */
21
+ isOpen?: boolean;
22
+ /** The accessibility role for the dialog. */
23
+ role?: 'dialog' | 'alertdialog';
24
+ /** Sets the size of the modal container. */
25
+ size?: ModalSizeProps;
26
+ /** The title for the modal. */
27
+ title?: ReactNode;
28
+ /**
29
+ * Handler that is called when the overlay should close.
30
+ *
31
+ * `() => void`
32
+ */
33
+ onClose?: () => void;
34
+ /**
35
+ * When a user interacts with the argument element outside of the overlay ref, return true if
36
+ * onClose should be called. This gives you a chance to filter out interaction with elements that
37
+ * should not dismiss the overlay. By default, onClose will always be called on interaction
38
+ * outside the overlay ref.
39
+ *
40
+ * `(element: HTMLElement) => boolean`
41
+ */
42
+ shouldCloseOnInteractOutside?: (element: Element) => boolean;
43
+ /** Defines a string value that labels the current element. */
44
+ 'aria-label'?: string;
45
+ /** Identifies the element (or elements) that labels the current element. */
46
+ 'aria-labelledby'?: string;
47
+ /** Identifies the element (or elements) that describes the object. */
48
+ 'aria-describedby'?: string;
49
+ /**
50
+ * Identifies the element (or elements) that provide a detailed, extended description for the
51
+ * object.
52
+ */
53
+ 'aria-details'?: string;
54
+ /** Props object spread directly into the modal content Box. */
55
+ contentProps?: object;
56
+ /** Props object spread directly into the modal container Box. */
57
+ containerProps?: object;
58
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
@@ -21,6 +21,7 @@ export * from './listItem';
21
21
  export * from './loader';
22
22
  export * from './menu';
23
23
  export * from './menuItem';
24
+ export * from './Modal';
24
25
  export * from './overlayPanel';
25
26
  export * from './popoverContainer';
26
27
  export * from './popoverMenu';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34;
3
+ var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30, _context31, _context32, _context33, _context34, _context35;
4
4
  var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
5
5
  var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
6
6
  var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
@@ -260,8 +260,19 @@ _forEachInstanceProperty(_context23 = _Object$keys(_menuItem)).call(_context23,
260
260
  }
261
261
  });
262
262
  });
263
+ var _Modal = require("./Modal");
264
+ _forEachInstanceProperty(_context24 = _Object$keys(_Modal)).call(_context24, function (key) {
265
+ if (key === "default" || key === "__esModule") return;
266
+ if (key in exports && exports[key] === _Modal[key]) return;
267
+ _Object$defineProperty(exports, key, {
268
+ enumerable: true,
269
+ get: function get() {
270
+ return _Modal[key];
271
+ }
272
+ });
273
+ });
263
274
  var _overlayPanel = require("./overlayPanel");
264
- _forEachInstanceProperty(_context24 = _Object$keys(_overlayPanel)).call(_context24, function (key) {
275
+ _forEachInstanceProperty(_context25 = _Object$keys(_overlayPanel)).call(_context25, function (key) {
265
276
  if (key === "default" || key === "__esModule") return;
266
277
  if (key in exports && exports[key] === _overlayPanel[key]) return;
267
278
  _Object$defineProperty(exports, key, {
@@ -272,7 +283,7 @@ _forEachInstanceProperty(_context24 = _Object$keys(_overlayPanel)).call(_context
272
283
  });
273
284
  });
274
285
  var _popoverContainer = require("./popoverContainer");
275
- _forEachInstanceProperty(_context25 = _Object$keys(_popoverContainer)).call(_context25, function (key) {
286
+ _forEachInstanceProperty(_context26 = _Object$keys(_popoverContainer)).call(_context26, function (key) {
276
287
  if (key === "default" || key === "__esModule") return;
277
288
  if (key in exports && exports[key] === _popoverContainer[key]) return;
278
289
  _Object$defineProperty(exports, key, {
@@ -283,7 +294,7 @@ _forEachInstanceProperty(_context25 = _Object$keys(_popoverContainer)).call(_con
283
294
  });
284
295
  });
285
296
  var _popoverMenu = require("./popoverMenu");
286
- _forEachInstanceProperty(_context26 = _Object$keys(_popoverMenu)).call(_context26, function (key) {
297
+ _forEachInstanceProperty(_context27 = _Object$keys(_popoverMenu)).call(_context27, function (key) {
287
298
  if (key === "default" || key === "__esModule") return;
288
299
  if (key in exports && exports[key] === _popoverMenu[key]) return;
289
300
  _Object$defineProperty(exports, key, {
@@ -294,7 +305,7 @@ _forEachInstanceProperty(_context26 = _Object$keys(_popoverMenu)).call(_context2
294
305
  });
295
306
  });
296
307
  var _requirementsList = require("./requirementsList");
297
- _forEachInstanceProperty(_context27 = _Object$keys(_requirementsList)).call(_context27, function (key) {
308
+ _forEachInstanceProperty(_context28 = _Object$keys(_requirementsList)).call(_context28, function (key) {
298
309
  if (key === "default" || key === "__esModule") return;
299
310
  if (key in exports && exports[key] === _requirementsList[key]) return;
300
311
  _Object$defineProperty(exports, key, {
@@ -305,7 +316,7 @@ _forEachInstanceProperty(_context27 = _Object$keys(_requirementsList)).call(_con
305
316
  });
306
317
  });
307
318
  var _rockerButtonGroup = require("./rockerButtonGroup");
308
- _forEachInstanceProperty(_context28 = _Object$keys(_rockerButtonGroup)).call(_context28, function (key) {
319
+ _forEachInstanceProperty(_context29 = _Object$keys(_rockerButtonGroup)).call(_context29, function (key) {
309
320
  if (key === "default" || key === "__esModule") return;
310
321
  if (key in exports && exports[key] === _rockerButtonGroup[key]) return;
311
322
  _Object$defineProperty(exports, key, {
@@ -316,7 +327,7 @@ _forEachInstanceProperty(_context28 = _Object$keys(_rockerButtonGroup)).call(_co
316
327
  });
317
328
  });
318
329
  var _scrollBox = require("./scrollBox");
319
- _forEachInstanceProperty(_context29 = _Object$keys(_scrollBox)).call(_context29, function (key) {
330
+ _forEachInstanceProperty(_context30 = _Object$keys(_scrollBox)).call(_context30, function (key) {
320
331
  if (key === "default" || key === "__esModule") return;
321
332
  if (key in exports && exports[key] === _scrollBox[key]) return;
322
333
  _Object$defineProperty(exports, key, {
@@ -327,7 +338,7 @@ _forEachInstanceProperty(_context29 = _Object$keys(_scrollBox)).call(_context29,
327
338
  });
328
339
  });
329
340
  var _separator = require("./separator");
330
- _forEachInstanceProperty(_context30 = _Object$keys(_separator)).call(_context30, function (key) {
341
+ _forEachInstanceProperty(_context31 = _Object$keys(_separator)).call(_context31, function (key) {
331
342
  if (key === "default" || key === "__esModule") return;
332
343
  if (key in exports && exports[key] === _separator[key]) return;
333
344
  _Object$defineProperty(exports, key, {
@@ -338,7 +349,7 @@ _forEachInstanceProperty(_context30 = _Object$keys(_separator)).call(_context30,
338
349
  });
339
350
  });
340
351
  var _shared = require("./shared");
341
- _forEachInstanceProperty(_context31 = _Object$keys(_shared)).call(_context31, function (key) {
352
+ _forEachInstanceProperty(_context32 = _Object$keys(_shared)).call(_context32, function (key) {
342
353
  if (key === "default" || key === "__esModule") return;
343
354
  if (key in exports && exports[key] === _shared[key]) return;
344
355
  _Object$defineProperty(exports, key, {
@@ -349,7 +360,7 @@ _forEachInstanceProperty(_context31 = _Object$keys(_shared)).call(_context31, fu
349
360
  });
350
361
  });
351
362
  var _table = require("./table");
352
- _forEachInstanceProperty(_context32 = _Object$keys(_table)).call(_context32, function (key) {
363
+ _forEachInstanceProperty(_context33 = _Object$keys(_table)).call(_context33, function (key) {
353
364
  if (key === "default" || key === "__esModule") return;
354
365
  if (key in exports && exports[key] === _table[key]) return;
355
366
  _Object$defineProperty(exports, key, {
@@ -360,7 +371,7 @@ _forEachInstanceProperty(_context32 = _Object$keys(_table)).call(_context32, fun
360
371
  });
361
372
  });
362
373
  var _text = require("./text");
363
- _forEachInstanceProperty(_context33 = _Object$keys(_text)).call(_context33, function (key) {
374
+ _forEachInstanceProperty(_context34 = _Object$keys(_text)).call(_context34, function (key) {
364
375
  if (key === "default" || key === "__esModule") return;
365
376
  if (key in exports && exports[key] === _text[key]) return;
366
377
  _Object$defineProperty(exports, key, {
@@ -371,7 +382,7 @@ _forEachInstanceProperty(_context33 = _Object$keys(_text)).call(_context33, func
371
382
  });
372
383
  });
373
384
  var _tooltipTrigger = require("./tooltipTrigger");
374
- _forEachInstanceProperty(_context34 = _Object$keys(_tooltipTrigger)).call(_context34, function (key) {
385
+ _forEachInstanceProperty(_context35 = _Object$keys(_tooltipTrigger)).call(_context35, function (key) {
375
386
  if (key === "default" || key === "__esModule") return;
376
387
  if (key in exports && exports[key] === _tooltipTrigger[key]) return;
377
388
  _Object$defineProperty(exports, key, {
@@ -17,6 +17,7 @@ export type Alignment = 'start' | 'end' | 'middle';
17
17
  export type SizeAxis = 'width' | 'height';
18
18
  export type PlacementAxis = Axis | 'center';
19
19
  export type PanelSize = 'small' | 'medium' | 'large' | 'full' | 'custom';
20
+ export type ModalSizeProps = 'extra-small' | 'small' | 'medium' | 'large' | 'full';
20
21
  type IconTShirtSize = 'xs' | 'sm' | 'md';
21
22
  type pixelSize = 'em' | 'px' | 'rem';
22
23
  export type IconSize = IconTShirtSize | number | `${number}${pixelSize}`;
@@ -12,13 +12,11 @@ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectW
12
12
  var _excluded = ["className", "closeButton", "hasAutoFocus", "hasCloseButton", "id", "isClosedOnBlur", "isDismissable", "isKeyboardDismissDisabled", "isOpen", "role", "size", "title", "onClose", "shouldCloseOnInteractOutside", "children", "contentProps", "containerProps"];
13
13
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
14
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
15
- import React, { forwardRef, useImperativeHandle, useRef } from 'react';
15
+ import React, { forwardRef } from 'react';
16
16
  import { FocusScope, mergeProps, OverlayContainer, useDialog } from 'react-aria';
17
17
  import CloseIcon from '@pingux/mdi-react/CloseIcon';
18
18
  import { useModalOverlay } from '@react-aria/overlays';
19
- import PropTypes from 'prop-types';
20
- import { useStatusClasses } from '../../hooks';
21
- import { modalSizes } from '../../utils/devUtils/constants/modalSizes';
19
+ import { useLocalOrForwardRef, useStatusClasses } from '../../hooks';
22
20
  import Box from '../Box';
23
21
  import Icon from '../Icon';
24
22
  import IconButton from '../IconButton';
@@ -59,11 +57,8 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
59
57
  isOpen: isOpen,
60
58
  close: onClose
61
59
  };
62
- var modalRef = useRef();
63
- /* istanbul ignore next */
64
- useImperativeHandle(ref, function () {
65
- return modalRef.current;
66
- });
60
+ var modalRef = useLocalOrForwardRef(ref);
61
+
67
62
  // Handle interacting outside the dialog and pressing
68
63
  // the Escape key to close the modal,
69
64
  // prevent scrolling while the modal is open, and hide content
@@ -80,7 +75,9 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
80
75
  classNames = _useStatusClasses.classNames;
81
76
  return ___EmotionJSX(OverlayContainer, null, ___EmotionJSX(Box, _extends({
82
77
  variant: "modal.container"
83
- }, mergeProps(containerProps, underlayProps, others)), ___EmotionJSX(FocusScope, {
78
+ }, mergeProps(containerProps, underlayProps, others), {
79
+ role: "none"
80
+ }), ___EmotionJSX(FocusScope, {
84
81
  contain: true,
85
82
  restoreFocus: true,
86
83
  autoFocus: hasAutoFocus
@@ -89,7 +86,8 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
89
86
  className: classNames
90
87
  }, propsContentProps, dialogProps, modalProps, {
91
88
  ref: modalRef,
92
- "aria-modal": true
89
+ "aria-modal": true,
90
+ role: "dialog"
93
91
  }), hasCloseButton && (closeButton !== null && closeButton !== void 0 ? closeButton : ___EmotionJSX(IconButton, {
94
92
  "aria-label": "Close modal window",
95
93
  "data-id": "icon-button__close-modal-window",
@@ -101,63 +99,10 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
101
99
  name: 'Close Icon'
102
100
  }
103
101
  }))), title && ___EmotionJSX(Text, _extends({}, titleProps, {
104
- variant: "variants.modal.title"
102
+ variant: "variants.modal.title",
103
+ role: "heading"
105
104
  }), title), children))));
106
105
  });
107
- Modal.propTypes = {
108
- /** Used in tandem with `hasCloseButton` to customize how the close button is rendered. */
109
- closeButton: PropTypes.node,
110
- /** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
111
- id: PropTypes.string,
112
- /** Whether to auto focus the first focusable element in the focus scope on mount. */
113
- hasAutoFocus: PropTypes.bool,
114
- /** Whether the modal has a visible close button. */
115
- hasCloseButton: PropTypes.bool,
116
- /** Whether the overlay should close when focus is lost or moves outside it. */
117
- isClosedOnBlur: PropTypes.bool,
118
- /** Whether to close the overlay when the user interacts outside it. */
119
- isDismissable: PropTypes.bool,
120
- /** Whether pressing the escape key to close the overlay should be disabled. */
121
- isKeyboardDismissDisabled: PropTypes.bool,
122
- /** Whether the overlay is currently open. */
123
- isOpen: PropTypes.bool,
124
- /** The accessibility role for the dialog. */
125
- role: PropTypes.oneOf(['dialog', 'alertdialog']),
126
- /** Sets the size of the modal container. */
127
- size: PropTypes.oneOf(modalSizes),
128
- /** The title for the modal. */
129
- title: PropTypes.node,
130
- /**
131
- * Handler that is called when the overlay should close.
132
- *
133
- * `() => void`
134
- */
135
- onClose: PropTypes.func,
136
- /**
137
- * When a user interacts with the argument element outside of the overlay ref, return true if
138
- * onClose should be called. This gives you a chance to filter out interaction with elements that
139
- * should not dismiss the overlay. By default, onClose will always be called on interaction
140
- * outside the overlay ref.
141
- *
142
- * `(element: HTMLElement) => boolean`
143
- */
144
- shouldCloseOnInteractOutside: PropTypes.func,
145
- /** Defines a string value that labels the current element. */
146
- 'aria-label': PropTypes.string,
147
- /** Identifies the element (or elements) that labels the current element. */
148
- 'aria-labelledby': PropTypes.string,
149
- /** Identifies the element (or elements) that describes the object. */
150
- 'aria-describedby': PropTypes.string,
151
- /**
152
- * Identifies the element (or elements) that provide a detailed, extended description for the
153
- * object.
154
- */
155
- 'aria-details': PropTypes.string,
156
- /** Props object spread directly into the modal content Box. */
157
- contentProps: PropTypes.shape({}),
158
- /** Props object spread directly into the modal container Box. */
159
- containerProps: PropTypes.shape({})
160
- };
161
106
  Modal.defaultProps = {
162
107
  role: 'dialog'
163
108
  };
@@ -4,7 +4,7 @@ import { withDesign } from 'storybook-addon-designs';
4
4
  import DocsLayout from '../../../.storybook/storybookDocsLayout';
5
5
  import { useModalState } from '../../hooks';
6
6
  import { Box, Button, Modal, OverlayProvider, Text } from '../../index';
7
- import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.ts';
7
+ import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
8
8
  import { modalSizes } from '../../utils/devUtils/constants/modalSizes';
9
9
  import ModalReadme from './Modal.mdx';
10
10
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -21,7 +21,9 @@ var ComposedComponent = function ComposedComponent(props) {
21
21
  hasCloseButton: true
22
22
  }, modalProps))));
23
23
  };
24
- var getComposedComponent = function getComposedComponent(defaultState, modalProps) {
24
+ var getComposedComponent = function getComposedComponent() {
25
+ var defaultState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ var modalProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25
27
  return render(___EmotionJSX(ComposedComponent, {
26
28
  defaultState: defaultState,
27
29
  modalProps: modalProps
@@ -32,12 +34,12 @@ test('clicking the trigger should open the modal', function () {
32
34
  expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
33
35
 
34
36
  // Open it with the button trigger
35
- userEvent.click(screen.queryByRole('button'));
37
+ userEvent.click(screen.getByRole('button'));
36
38
  expect(screen.queryByRole('dialog')).toBeInTheDocument();
37
39
  });
38
40
  test('keyboard interaction with the trigger should open the modal', function () {
39
41
  getComposedComponent();
40
- var button = screen.queryByRole('button');
42
+ var button = screen.getByRole('button');
41
43
  expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
42
44
 
43
45
  // Open it with the button trigger
@@ -78,11 +80,11 @@ test('keyboard interactions on the close button should close the modal', functio
78
80
  });
79
81
  test('assign aria-hidden to elements outside the modal when the modal is opened', function () {
80
82
  getComposedComponent();
81
- var button = screen.queryByRole('button');
83
+ var button = screen.getByRole('button');
82
84
  var buttonParent = button.closest('div');
83
85
  expect(buttonParent).not.toHaveAttribute('aria-hidden');
84
86
 
85
87
  // Open the modal
86
- userEvent.click(screen.queryByRole('button'));
88
+ userEvent.click(screen.getByRole('button'));
87
89
  expect(buttonParent).toHaveAttribute('aria-hidden');
88
90
  });
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
  import { Modal, OverlayProvider } from '../../../index';
4
- import { queryByAttribute, render, screen } from '../../../utils/testUtils/testWrapper';
4
+ import { render, screen } from '../../../utils/testUtils/testWrapper';
5
5
  import { universalComponentTests } from '../../../utils/testUtils/universalComponentTest';
6
6
 
7
7
  // For testing the modal alone
@@ -30,32 +30,32 @@ test('default modal', function () {
30
30
  });
31
31
  test('should spread undocumented props to the container element', function () {
32
32
  getComponent({
33
- 'data-prop': 'test'
33
+ 'data-testid': 'test'
34
34
  });
35
- var container = queryByAttribute('data-prop', document, 'test');
35
+ var container = screen.queryByTestId('test');
36
36
  var modal = screen.getByRole('dialog');
37
37
  expect(container).toContainElement(modal);
38
- expect(modal).not.toHaveAttribute('data-prop', 'test');
38
+ expect(modal).not.toHaveAttribute('data-testid', 'test');
39
39
  });
40
40
  test('should spread container props to the container element even if documented', function () {
41
41
  getComponent({
42
42
  containerProps: {
43
- id: 'test'
43
+ 'data-testid': 'test'
44
44
  }
45
45
  });
46
- var container = queryByAttribute('id', document, 'test');
46
+ var container = screen.queryByTestId('test');
47
47
  var modal = screen.getByRole('dialog');
48
48
  expect(container).toContainElement(modal);
49
- expect(modal).not.toHaveAttribute('id', 'test');
49
+ expect(modal).not.toHaveAttribute('data-testid', 'test');
50
50
  });
51
51
  test('should spread content props to the modal dialog even if undocumented', function () {
52
52
  getComponent({
53
53
  contentProps: {
54
- 'data-prop': 'test'
54
+ 'data-testid': 'test'
55
55
  }
56
56
  });
57
57
  var modal = screen.getByRole('dialog');
58
- expect(modal).toHaveAttribute('data-prop', 'test');
58
+ expect(modal).toHaveAttribute('data-testid', 'test');
59
59
  });
60
60
  test('should display title for modal', function () {
61
61
  var title = 'my title';
@@ -0,0 +1 @@
1
+ export {};
@@ -21,6 +21,7 @@ export * from './listItem';
21
21
  export * from './loader';
22
22
  export * from './menu';
23
23
  export * from './menuItem';
24
+ export * from './Modal';
24
25
  export * from './overlayPanel';
25
26
  export * from './popoverContainer';
26
27
  export * from './popoverMenu';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.53.0-alpha.1",
3
+ "version": "2.53.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",