@pingux/astro 2.148.0-alpha.0 → 2.148.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/IconButton/IconButton.styles.d.ts +38 -0
- package/lib/cjs/components/IconButton/IconButton.styles.js +8 -7
- package/lib/cjs/components/Modal/Convenience/ModalBody.stories.d.ts +7 -0
- package/lib/cjs/components/Modal/Convenience/ModalBody.stories.js +30 -0
- package/lib/cjs/components/Modal/Convenience/ModalFooter.stories.d.ts +5 -0
- package/lib/cjs/components/Modal/Convenience/ModalFooter.stories.js +35 -0
- package/lib/cjs/components/Modal/Convenience/ModalHeader.stories.d.ts +5 -0
- package/lib/cjs/components/Modal/Convenience/ModalHeader.stories.js +36 -0
- package/lib/cjs/components/Modal/Modal.js +13 -4
- package/lib/cjs/components/Modal/Modal.stories.d.ts +1 -0
- package/lib/cjs/components/Modal/Modal.stories.js +67 -50
- package/lib/cjs/components/Modal/Modal.styles.d.ts +43 -26
- package/lib/cjs/components/Modal/Modal.styles.js +41 -28
- package/lib/cjs/components/Modal/ModalBody.d.ts +9 -0
- package/lib/cjs/components/Modal/ModalBody.js +34 -0
- package/lib/cjs/components/Modal/ModalBody.test.d.ts +1 -0
- package/lib/cjs/components/Modal/ModalBody.test.js +64 -0
- package/lib/cjs/components/Modal/ModalFooter.d.ts +4 -0
- package/lib/cjs/components/Modal/ModalFooter.js +48 -0
- package/lib/cjs/components/Modal/ModalFooter.test.d.ts +1 -0
- package/lib/cjs/components/Modal/ModalFooter.test.js +98 -0
- package/lib/cjs/components/Modal/ModalHeader.d.ts +4 -0
- package/lib/cjs/components/Modal/ModalHeader.js +61 -0
- package/lib/cjs/components/Modal/ModalHeader.test.d.ts +1 -0
- package/lib/cjs/components/Modal/ModalHeader.test.js +96 -0
- package/lib/cjs/components/Modal/index.d.ts +3 -0
- package/lib/cjs/components/Modal/index.js +22 -1
- package/lib/cjs/components/Modal/tests/Modal.integration.test.js +4 -0
- package/lib/cjs/components/Modal/tests/Modal.unit.test.js +4 -0
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.d.ts +46 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +3 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.d.ts +18 -1
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/variants.js +18 -1
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +59 -18
- package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +32 -6
- package/lib/cjs/styles/themes/next-gen/variants/button.js +6 -5
- package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +27 -12
- package/lib/cjs/styles/themes/next-gen/variants/variants.js +28 -13
- package/lib/cjs/types/Modal.d.ts +19 -0
- package/lib/components/IconButton/IconButton.styles.js +9 -8
- package/lib/components/Modal/Convenience/ModalBody.stories.js +20 -0
- package/lib/components/Modal/Convenience/ModalFooter.stories.js +25 -0
- package/lib/components/Modal/Convenience/ModalHeader.stories.js +26 -0
- package/lib/components/Modal/Modal.js +13 -4
- package/lib/components/Modal/Modal.stories.js +67 -51
- package/lib/components/Modal/Modal.styles.js +39 -27
- package/lib/components/Modal/ModalBody.js +20 -0
- package/lib/components/Modal/ModalBody.test.js +61 -0
- package/lib/components/Modal/ModalFooter.js +34 -0
- package/lib/components/Modal/ModalFooter.test.js +95 -0
- package/lib/components/Modal/ModalHeader.js +47 -0
- package/lib/components/Modal/ModalHeader.test.js +93 -0
- package/lib/components/Modal/index.js +4 -1
- package/lib/components/Modal/tests/Modal.integration.test.js +4 -0
- package/lib/components/Modal/tests/Modal.unit.test.js +4 -0
- package/lib/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +3 -0
- package/lib/styles/themeOverrides/nextGenDarkMode/variants/variants.js +18 -1
- package/lib/styles/themes/next-gen/variants/button.js +6 -5
- package/lib/styles/themes/next-gen/variants/variants.js +28 -13
- package/package.json +1 -1
|
@@ -7,9 +7,11 @@ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-st
|
|
|
7
7
|
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
8
8
|
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
9
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
10
|
+
import _toArray from "@babel/runtime-corejs3/helpers/esm/toArray";
|
|
10
11
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
11
12
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
12
13
|
var _excluded = ["className", "closeButton", "hasAutoFocus", "hasCloseButton", "id", "isClosedOnBlur", "isDismissable", "isKeyboardDismissDisabled", "isOpen", "role", "size", "state", "title", "onClose", "shouldCloseOnInteractOutside", "children", "contentProps", "containerProps", "headerContainerProps"];
|
|
14
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
13
15
|
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
16
|
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
17
|
import React, { forwardRef } from 'react';
|
|
@@ -21,6 +23,7 @@ import Box from '../Box';
|
|
|
21
23
|
import Icon from '../Icon';
|
|
22
24
|
import IconButton from '../IconButton';
|
|
23
25
|
import Text from '../Text';
|
|
26
|
+
import ModalHeader from './ModalHeader';
|
|
24
27
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
25
28
|
var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
29
|
var _useStatusClasses2;
|
|
@@ -84,7 +87,12 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
84
87
|
var isOpenNoTransition = (state === null || state === void 0 ? void 0 : state.isTransitioning) === undefined && isOpen === true;
|
|
85
88
|
var _useStatusClasses = useStatusClasses(className, (_useStatusClasses2 = {}, _defineProperty(_useStatusClasses2, "is-".concat(size || 'custom'), size), _defineProperty(_useStatusClasses2, "isOpen", isOpen), _defineProperty(_useStatusClasses2, "isTransitioning", state === null || state === void 0 ? void 0 : state.isTransitioning), _defineProperty(_useStatusClasses2, "isOpenNoTransition", isOpenNoTransition), _useStatusClasses2)),
|
|
86
89
|
classNames = _useStatusClasses.classNames;
|
|
87
|
-
var
|
|
90
|
+
var _React$Children$toArr = React.Children.toArray(children),
|
|
91
|
+
_React$Children$toArr2 = _toArray(_React$Children$toArr),
|
|
92
|
+
header = _React$Children$toArr2[0],
|
|
93
|
+
siblings = _sliceInstanceProperty(_React$Children$toArr2).call(_React$Children$toArr2, 1);
|
|
94
|
+
var hasHeaderContent = /*#__PURE__*/React.isValidElement(header) && header.type === ModalHeader;
|
|
95
|
+
var titleContent = !hasHeaderContent && title && (isOnyx ? ___EmotionJSX(Box, {
|
|
88
96
|
variant: "modal.header"
|
|
89
97
|
}, ___EmotionJSX(Text, _extends({}, titleProps, {
|
|
90
98
|
variant: "modalTitle",
|
|
@@ -107,7 +115,7 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
107
115
|
}, propsContentProps, dialogProps, modalProps, {
|
|
108
116
|
ref: modalRef,
|
|
109
117
|
"aria-modal": true
|
|
110
|
-
}), ___EmotionJSX(Box, _extends({
|
|
118
|
+
}), titleContent && ___EmotionJSX(Box, _extends({
|
|
111
119
|
variant: "modal.headingContainer"
|
|
112
120
|
}, headerContainerProps), hasCloseButton && (closeButton !== null && closeButton !== void 0 ? closeButton : ___EmotionJSX(IconButton, {
|
|
113
121
|
"aria-label": "Close modal window",
|
|
@@ -119,8 +127,9 @@ var Modal = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
119
127
|
title: {
|
|
120
128
|
name: 'Close Icon'
|
|
121
129
|
}
|
|
122
|
-
}))), titleContent), ___EmotionJSX(Box, {
|
|
123
|
-
pt: "md"
|
|
130
|
+
}))), titleContent), isOnyx ? children : ___EmotionJSX(Box, {
|
|
131
|
+
pt: "md",
|
|
132
|
+
px: "lg"
|
|
124
133
|
}, children)))));
|
|
125
134
|
});
|
|
126
135
|
Modal.defaultProps = {
|
|
@@ -3,8 +3,8 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
4
|
import { withDesign } from 'storybook-addon-designs';
|
|
5
5
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
|
6
|
-
import { useModalState } from '../../hooks';
|
|
7
|
-
import { Box, Button, Item, Menu, Modal, OverlayProvider, PopoverMenu, RadioField, RadioGroupField, SearchField, SelectField, Text } from '../../index';
|
|
6
|
+
import { useGetTheme, useModalState } from '../../hooks';
|
|
7
|
+
import { Box, Button, Item, Menu, Modal, ModalBody, ModalFooter, ModalHeader, OverlayProvider, PopoverMenu, RadioField, RadioGroupField, SearchField, SelectField, Text } from '../../index';
|
|
8
8
|
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
|
|
9
9
|
import { modalSizes } from '../../utils/devUtils/constants/modalSizes';
|
|
10
10
|
import ModalReadme from './Modal.mdx';
|
|
@@ -89,21 +89,6 @@ export default {
|
|
|
89
89
|
};
|
|
90
90
|
export var Default = function Default(args) {
|
|
91
91
|
var state = useModalState();
|
|
92
|
-
var ModalBodyContent = ___EmotionJSX(Box, null, ___EmotionJSX(Text, null, "Do you want to continue with this action that you\u2018re performing?"), ___EmotionJSX(Box, {
|
|
93
|
-
isRow: true,
|
|
94
|
-
mr: "auto",
|
|
95
|
-
width: "100%",
|
|
96
|
-
variant: "modal.buttonsContainer"
|
|
97
|
-
}, ___EmotionJSX(Button, {
|
|
98
|
-
variant: "primary",
|
|
99
|
-
onPress: state.close,
|
|
100
|
-
mr: "md",
|
|
101
|
-
"aria-label": "Continue"
|
|
102
|
-
}, "Continue"), ___EmotionJSX(Button, {
|
|
103
|
-
variant: "link",
|
|
104
|
-
onPress: state.close,
|
|
105
|
-
"aria-label": "Cancel"
|
|
106
|
-
}, "Cancel")));
|
|
107
92
|
return (
|
|
108
93
|
// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
|
109
94
|
// readers when an overlay opens.
|
|
@@ -113,10 +98,16 @@ export var Default = function Default(args) {
|
|
|
113
98
|
tabIndex: state.isOpen ? -1 : 0
|
|
114
99
|
}, "Open Modal"), (state.isOpen || state.isTransitioning) && ___EmotionJSX(Modal, _extends({}, args, {
|
|
115
100
|
isOpen: state.isOpen,
|
|
101
|
+
state: state
|
|
102
|
+
}), ___EmotionJSX(ModalHeader, {
|
|
103
|
+
hasCloseButton: true,
|
|
116
104
|
onClose: state.close,
|
|
117
|
-
state: state,
|
|
118
105
|
title: "Continue"
|
|
119
|
-
}),
|
|
106
|
+
}), ___EmotionJSX(ModalBody, null, ___EmotionJSX(Box, null, ___EmotionJSX(Text, null, "Do you want to continue with this action that you\u2018re performing?"))), ___EmotionJSX(ModalFooter, {
|
|
107
|
+
onSubmit: state.close,
|
|
108
|
+
onCancel: state.close,
|
|
109
|
+
primaryButtonText: "Continue"
|
|
110
|
+
})))
|
|
120
111
|
);
|
|
121
112
|
};
|
|
122
113
|
Default.parameters = {
|
|
@@ -136,27 +127,53 @@ export var LargeContent = function LargeContent(args) {
|
|
|
136
127
|
tabIndex: state.isOpen ? -1 : 0
|
|
137
128
|
}, "Open Modal"), state.isOpen && ___EmotionJSX(Modal, _extends({}, args, {
|
|
138
129
|
isOpen: state.isOpen,
|
|
130
|
+
onClose: state.close
|
|
131
|
+
}), ___EmotionJSX(ModalHeader, {
|
|
132
|
+
hasCloseButton: true,
|
|
139
133
|
onClose: state.close,
|
|
140
134
|
title: "Lorem Ipsum"
|
|
141
|
-
}), ___EmotionJSX(Box, {
|
|
135
|
+
}), ___EmotionJSX(ModalBody, null, ___EmotionJSX(Box, {
|
|
142
136
|
gap: "lg"
|
|
143
|
-
}, ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore."), ___EmotionJSX(Text, null, "Eu fugiat nulla pariatur."), ___EmotionJSX(Text, null, "Excepteur sint occaecat cupidatat non proident."), ___EmotionJSX(Text, null, "Sunt in culpa qui officia deserunt mollit anim id est laborum."), ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore."), ___EmotionJSX(Text, null, "Eu fugiat nulla pariatur."), ___EmotionJSX(Text, null, "Excepteur sint occaecat cupidatat non proident."), ___EmotionJSX(Text, null, "Sunt in culpa qui officia deserunt mollit anim id est laborum."), ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore.")), ___EmotionJSX(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
137
|
+
}, ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore."), ___EmotionJSX(Text, null, "Eu fugiat nulla pariatur."), ___EmotionJSX(Text, null, "Excepteur sint occaecat cupidatat non proident."), ___EmotionJSX(Text, null, "Sunt in culpa qui officia deserunt mollit anim id est laborum."), ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore."), ___EmotionJSX(Text, null, "Eu fugiat nulla pariatur."), ___EmotionJSX(Text, null, "Excepteur sint occaecat cupidatat non proident."), ___EmotionJSX(Text, null, "Sunt in culpa qui officia deserunt mollit anim id est laborum."), ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore."))), ___EmotionJSX(ModalFooter, {
|
|
138
|
+
onSubmit: state.close,
|
|
139
|
+
onCancel: state.close
|
|
140
|
+
})))
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
export var LargeContentWithScroll = function LargeContentWithScroll(args) {
|
|
144
|
+
var state = useModalState();
|
|
145
|
+
return (
|
|
146
|
+
// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
|
147
|
+
// readers when an overlay opens.
|
|
148
|
+
___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
|
149
|
+
onPress: state.open,
|
|
150
|
+
"aria-label": "Open modal",
|
|
151
|
+
tabIndex: state.isOpen ? -1 : 0
|
|
152
|
+
}, "Open Modal"), state.isOpen && ___EmotionJSX(Modal, _extends({}, args, {
|
|
153
|
+
isOpen: state.isOpen,
|
|
154
|
+
onClose: state.close
|
|
155
|
+
}), ___EmotionJSX(ModalHeader, {
|
|
156
|
+
hasCloseButton: true,
|
|
157
|
+
onClose: state.close,
|
|
158
|
+
title: "Lorem Ipsum"
|
|
159
|
+
}), ___EmotionJSX(ModalBody, {
|
|
160
|
+
isScrollable: true,
|
|
161
|
+
scrollProps: {
|
|
162
|
+
maxHeight: '400px'
|
|
163
|
+
}
|
|
164
|
+
}, ___EmotionJSX(Box, {
|
|
165
|
+
gap: "lg",
|
|
166
|
+
pr: "lg"
|
|
167
|
+
}, ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore."), ___EmotionJSX(Text, null, "Eu fugiat nulla pariatur."), ___EmotionJSX(Text, null, "Excepteur sint occaecat cupidatat non proident."), ___EmotionJSX(Text, null, "Sunt in culpa qui officia deserunt mollit anim id est laborum."), ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore."), ___EmotionJSX(Text, null, "Eu fugiat nulla pariatur."), ___EmotionJSX(Text, null, "Excepteur sint occaecat cupidatat non proident."), ___EmotionJSX(Text, null, "Sunt in culpa qui officia deserunt mollit anim id est laborum."), ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), ___EmotionJSX(Text, null, "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."), ___EmotionJSX(Text, null, "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris."), ___EmotionJSX(Text, null, "Nisi ut aliquip ex ea commodo consequat."), ___EmotionJSX(Text, null, "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore."))), ___EmotionJSX(ModalFooter, {
|
|
168
|
+
onSubmit: state.close,
|
|
169
|
+
onCancel: state.close
|
|
170
|
+
})))
|
|
156
171
|
);
|
|
157
172
|
};
|
|
158
173
|
export var WithInputField = function WithInputField() {
|
|
159
174
|
var state = useModalState();
|
|
175
|
+
var _useGetTheme = useGetTheme(),
|
|
176
|
+
isOnyx = _useGetTheme.themeState.isOnyx;
|
|
160
177
|
var _useState = useState(''),
|
|
161
178
|
_useState2 = _slicedToArray(_useState, 2),
|
|
162
179
|
value = _useState2[0],
|
|
@@ -177,8 +194,9 @@ export var WithInputField = function WithInputField() {
|
|
|
177
194
|
}, "Open Modal"), state.isOpen && ___EmotionJSX(Modal, {
|
|
178
195
|
isOpen: state.isOpen,
|
|
179
196
|
onClose: state.close
|
|
180
|
-
}, ___EmotionJSX(Box, {
|
|
181
|
-
gap: "lg"
|
|
197
|
+
}, ___EmotionJSX(ModalBody, null, ___EmotionJSX(Box, {
|
|
198
|
+
gap: "lg",
|
|
199
|
+
pt: isOnyx ? '' : 'lg'
|
|
182
200
|
}, ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet consectetur"), ___EmotionJSX(SelectField, {
|
|
183
201
|
label: "Select an option"
|
|
184
202
|
}, ___EmotionJSX(Item, null, "Red"), ___EmotionJSX(Item, null, "Green"), ___EmotionJSX(Item, null, "Blue")), ___EmotionJSX(RadioGroupField, {
|
|
@@ -217,19 +235,10 @@ export var WithInputField = function WithInputField() {
|
|
|
217
235
|
key: item.key,
|
|
218
236
|
textValue: item.name
|
|
219
237
|
}, item.name);
|
|
220
|
-
}), ___EmotionJSX(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
variant: "primary",
|
|
225
|
-
onPress: state.close,
|
|
226
|
-
mr: "md",
|
|
227
|
-
"aria-label": "Continue"
|
|
228
|
-
}, "Continue"), ___EmotionJSX(Button, {
|
|
229
|
-
variant: "link",
|
|
230
|
-
onPress: state.close,
|
|
231
|
-
"aria-label": "Cancel"
|
|
232
|
-
}, "Cancel")))));
|
|
238
|
+
}))), ___EmotionJSX(ModalFooter, {
|
|
239
|
+
onSubmit: state.close,
|
|
240
|
+
onCancel: state.close
|
|
241
|
+
})));
|
|
233
242
|
};
|
|
234
243
|
export var WithPopoverMenu = function WithPopoverMenu() {
|
|
235
244
|
var state = useModalState();
|
|
@@ -239,9 +248,13 @@ export var WithPopoverMenu = function WithPopoverMenu() {
|
|
|
239
248
|
}, "Open Modal"), state.isOpen && ___EmotionJSX(Modal, {
|
|
240
249
|
isOpen: state.isOpen,
|
|
241
250
|
onClose: state.close
|
|
242
|
-
}, ___EmotionJSX(
|
|
251
|
+
}, ___EmotionJSX(ModalHeader, {
|
|
252
|
+
hasCloseButton: true,
|
|
253
|
+
onClose: state.close,
|
|
254
|
+
title: "Lorem Ipsum"
|
|
255
|
+
}), ___EmotionJSX(ModalBody, null, ___EmotionJSX(Box, {
|
|
243
256
|
gap: "lg"
|
|
244
|
-
}, ___EmotionJSX(
|
|
257
|
+
}, ___EmotionJSX(PopoverMenu, null, ___EmotionJSX(Button, null, "Click me"), ___EmotionJSX(Menu, {
|
|
245
258
|
onAction: function onAction() {
|
|
246
259
|
return console.log('on action');
|
|
247
260
|
}
|
|
@@ -254,7 +267,10 @@ export var WithPopoverMenu = function WithPopoverMenu() {
|
|
|
254
267
|
textValue: "delete"
|
|
255
268
|
}, ___EmotionJSX(Text, {
|
|
256
269
|
color: "critical.bright"
|
|
257
|
-
}, "Delete"))))))
|
|
270
|
+
}, "Delete")))))), ___EmotionJSX(ModalFooter, {
|
|
271
|
+
onSubmit: state.close,
|
|
272
|
+
onCancel: state.close
|
|
273
|
+
})));
|
|
258
274
|
};
|
|
259
275
|
WithInputField.parameters = {
|
|
260
276
|
a11y: {
|
|
@@ -23,22 +23,15 @@ var container = {
|
|
|
23
23
|
background: '#00000040',
|
|
24
24
|
display: 'flex',
|
|
25
25
|
alignItems: 'center',
|
|
26
|
-
|
|
26
|
+
overflowY: 'auto'
|
|
27
27
|
};
|
|
28
28
|
var content = {
|
|
29
|
-
position: 'relative',
|
|
30
29
|
outline: 'none',
|
|
31
30
|
background: 'white',
|
|
32
31
|
color: 'black',
|
|
33
|
-
pt: 'md',
|
|
34
|
-
pr: 'lg',
|
|
35
|
-
pb: 'lg',
|
|
36
|
-
pl: 'lg',
|
|
37
32
|
boxShadow: 'standard',
|
|
38
33
|
borderRadius: 3,
|
|
39
|
-
|
|
40
|
-
// 100% of the window minus 40px on top and bottom
|
|
41
|
-
overflowY: 'auto',
|
|
34
|
+
margin: 'auto',
|
|
42
35
|
'&.is-extra-small': {
|
|
43
36
|
maxWidth: 'none',
|
|
44
37
|
width: 'container.xs'
|
|
@@ -61,28 +54,41 @@ var content = {
|
|
|
61
54
|
}
|
|
62
55
|
};
|
|
63
56
|
var headingContainer = {
|
|
64
|
-
position: '
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
mr: '-lg',
|
|
69
|
-
pt: 'md',
|
|
70
|
-
pr: 'lg',
|
|
71
|
-
pb: 'md',
|
|
72
|
-
backgroundColor: 'background.base'
|
|
57
|
+
position: 'relative',
|
|
58
|
+
backgroundColor: 'background.base',
|
|
59
|
+
px: 'lg',
|
|
60
|
+
py: 'md'
|
|
73
61
|
};
|
|
74
|
-
var
|
|
75
|
-
position: '
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
62
|
+
var header = {
|
|
63
|
+
position: 'relative',
|
|
64
|
+
backgroundColor: 'background.base',
|
|
65
|
+
pb: 'md'
|
|
66
|
+
};
|
|
67
|
+
var body = {};
|
|
68
|
+
export var closeButton = {
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
top: 0,
|
|
71
|
+
right: -14,
|
|
72
|
+
alignSelf: 'auto',
|
|
73
|
+
width: '22px',
|
|
74
|
+
height: '22px'
|
|
75
|
+
};
|
|
76
|
+
var bodyContainer = {
|
|
77
|
+
px: 'lg'
|
|
78
|
+
};
|
|
79
|
+
var footer = {
|
|
80
|
+
py: 'lg',
|
|
81
81
|
background: 'white',
|
|
82
82
|
'& > button': {
|
|
83
83
|
flexGrow: 0
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
+
var buttonsContainer = {
|
|
87
|
+
p: 0,
|
|
88
|
+
pb: 'lg',
|
|
89
|
+
pt: 'lg',
|
|
90
|
+
background: 'white'
|
|
91
|
+
};
|
|
86
92
|
var title = _objectSpread(_objectSpread({}, text.title), {}, {
|
|
87
93
|
mr: 'sm',
|
|
88
94
|
fontWeight: 3
|
|
@@ -91,6 +97,7 @@ export var modalCloseButton = {
|
|
|
91
97
|
position: 'absolute',
|
|
92
98
|
top: 14,
|
|
93
99
|
right: 10,
|
|
100
|
+
alignSelf: 'auto',
|
|
94
101
|
width: '22px',
|
|
95
102
|
height: '22px'
|
|
96
103
|
};
|
|
@@ -99,7 +106,12 @@ export default {
|
|
|
99
106
|
container: container,
|
|
100
107
|
content: content,
|
|
101
108
|
headingContainer: headingContainer,
|
|
102
|
-
|
|
109
|
+
bodyContainer: bodyContainer,
|
|
103
110
|
title: title,
|
|
104
|
-
modalCloseButton: modalCloseButton
|
|
111
|
+
modalCloseButton: modalCloseButton,
|
|
112
|
+
buttonsContainer: buttonsContainer,
|
|
113
|
+
header: header,
|
|
114
|
+
body: body,
|
|
115
|
+
footer: footer,
|
|
116
|
+
closeButton: closeButton
|
|
105
117
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import Box from '../Box';
|
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
5
|
+
var ModalBody = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
6
|
+
var children = props.children,
|
|
7
|
+
isScrollable = props.isScrollable,
|
|
8
|
+
_props$scrollProps = props.scrollProps,
|
|
9
|
+
scrollProps = _props$scrollProps === void 0 ? {} : _props$scrollProps,
|
|
10
|
+
containerProps = props.containerProps;
|
|
11
|
+
return ___EmotionJSX(Box, _extends({
|
|
12
|
+
variant: "modal.body",
|
|
13
|
+
ref: ref
|
|
14
|
+
}, containerProps), isScrollable ? ___EmotionJSX(Box, _extends({
|
|
15
|
+
width: "calc(100% + 24px)",
|
|
16
|
+
overflowY: "auto"
|
|
17
|
+
}, scrollProps), children) : children);
|
|
18
|
+
});
|
|
19
|
+
ModalBody.displayName = 'ModalBody';
|
|
20
|
+
export default ModalBody;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
|
4
|
+
import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
|
|
5
|
+
import ModalBody from './ModalBody';
|
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
7
|
+
var defaultProps = {
|
|
8
|
+
children: ''
|
|
9
|
+
};
|
|
10
|
+
var testId = 'scrollBoxTestId';
|
|
11
|
+
var scrollProps = {
|
|
12
|
+
'data-testid': testId,
|
|
13
|
+
'maxHeight': '100px'
|
|
14
|
+
};
|
|
15
|
+
var getComponent = function getComponent() {
|
|
16
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
17
|
+
return render(___EmotionJSX(ModalBody, _extends({}, defaultProps, props)));
|
|
18
|
+
};
|
|
19
|
+
// Needs to be added to each components test file
|
|
20
|
+
universalComponentTests({
|
|
21
|
+
renderComponent: function renderComponent(props) {
|
|
22
|
+
return ___EmotionJSX(ModalBody, props);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
describe('ModalBody', function () {
|
|
26
|
+
test('rendered', function () {
|
|
27
|
+
getComponent({
|
|
28
|
+
children: 'Lorem Ipsum'
|
|
29
|
+
});
|
|
30
|
+
screen.getByText(/lorem ipsum/i);
|
|
31
|
+
});
|
|
32
|
+
test('children as React node', function () {
|
|
33
|
+
var ChildrenNode = function ChildrenNode() {
|
|
34
|
+
return ___EmotionJSX("div", {
|
|
35
|
+
"data-testid": "custom-node"
|
|
36
|
+
}, "Custom Node");
|
|
37
|
+
};
|
|
38
|
+
getComponent({
|
|
39
|
+
children: ___EmotionJSX(ChildrenNode, null)
|
|
40
|
+
});
|
|
41
|
+
screen.getByTestId('custom-node');
|
|
42
|
+
screen.getByText(/custom node/i);
|
|
43
|
+
});
|
|
44
|
+
test('isScrollable adds ScrollBox wrapper', function () {
|
|
45
|
+
var ChildrenNode = function ChildrenNode() {
|
|
46
|
+
return ___EmotionJSX("div", {
|
|
47
|
+
"data-testid": "custom-node"
|
|
48
|
+
}, "Custom Node");
|
|
49
|
+
};
|
|
50
|
+
getComponent({
|
|
51
|
+
scrollProps: scrollProps,
|
|
52
|
+
isScrollable: true,
|
|
53
|
+
children: ___EmotionJSX(ChildrenNode, null)
|
|
54
|
+
});
|
|
55
|
+
var scrollBoxComponent = screen.getByTestId(testId);
|
|
56
|
+
expect(scrollBoxComponent).toBeInTheDocument();
|
|
57
|
+
expect(scrollBoxComponent).toHaveStyle({
|
|
58
|
+
maxHeight: '100px'
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import Button from '../Button';
|
|
4
|
+
import ButtonBar from '../ButtonBar';
|
|
5
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
6
|
+
var ModalFooter = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
7
|
+
var onSubmit = props.onSubmit,
|
|
8
|
+
onCancel = props.onCancel,
|
|
9
|
+
footerProps = props.footerProps,
|
|
10
|
+
children = props.children,
|
|
11
|
+
_props$primaryButtonT = props.primaryButtonText,
|
|
12
|
+
primaryButtonText = _props$primaryButtonT === void 0 ? 'Save' : _props$primaryButtonT,
|
|
13
|
+
_props$secondaryButto = props.secondaryButtonText,
|
|
14
|
+
secondaryButtonText = _props$secondaryButto === void 0 ? 'Cancel' : _props$secondaryButto;
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
17
|
+
if (children) return ___EmotionJSX(React.Fragment, null, children);
|
|
18
|
+
return ___EmotionJSX(ButtonBar, _extends({
|
|
19
|
+
variant: "modal.footer",
|
|
20
|
+
as: "footer",
|
|
21
|
+
ref: ref
|
|
22
|
+
}, footerProps), ___EmotionJSX(Button, {
|
|
23
|
+
variant: "primary",
|
|
24
|
+
onPress: onSubmit,
|
|
25
|
+
mr: "md",
|
|
26
|
+
"aria-label": primaryButtonText
|
|
27
|
+
}, primaryButtonText), ___EmotionJSX(Button, {
|
|
28
|
+
variant: "link",
|
|
29
|
+
onPress: onCancel,
|
|
30
|
+
"aria-label": secondaryButtonText
|
|
31
|
+
}, secondaryButtonText));
|
|
32
|
+
});
|
|
33
|
+
ModalFooter.displayName = 'ModalFooter';
|
|
34
|
+
export default ModalFooter;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
2
|
+
import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
|
|
3
|
+
import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
|
|
4
|
+
import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
|
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
6
|
+
import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/set-prototype-of";
|
|
7
|
+
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
8
|
+
import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
|
|
9
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
10
|
+
import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
|
11
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
|
12
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
13
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context2; _forEachInstanceProperty(_context2 = ["next", "throw", "return"]).call(_context2, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context3; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context3 = this.tryEntries).call(_context3, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import userEvent from '@testing-library/user-event';
|
|
16
|
+
import { render, screen } from '../../utils/testUtils/testWrapper';
|
|
17
|
+
import { universalComponentTests } from '../../utils/testUtils/universalComponentTest';
|
|
18
|
+
import ModalFooter from './ModalFooter';
|
|
19
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
20
|
+
var defaultProps = {
|
|
21
|
+
children: ''
|
|
22
|
+
};
|
|
23
|
+
var getComponent = function getComponent() {
|
|
24
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
25
|
+
return render(___EmotionJSX(ModalFooter, _extends({}, defaultProps, props)));
|
|
26
|
+
};
|
|
27
|
+
// Needs to be added to each components test file
|
|
28
|
+
universalComponentTests({
|
|
29
|
+
renderComponent: function renderComponent(props) {
|
|
30
|
+
return ___EmotionJSX(ModalFooter, props);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
describe('ModalFooter', function () {
|
|
34
|
+
test('rendered', function () {
|
|
35
|
+
getComponent({
|
|
36
|
+
children: 'ModalFooter'
|
|
37
|
+
});
|
|
38
|
+
screen.getByText(/modalfooter/i);
|
|
39
|
+
});
|
|
40
|
+
test('onSubmit and onCancel are called when buttons are clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
41
|
+
var onSubmit, onCancel, saveButton, cancelButton;
|
|
42
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
onSubmit = jest.fn();
|
|
46
|
+
onCancel = jest.fn();
|
|
47
|
+
getComponent({
|
|
48
|
+
onSubmit: onSubmit,
|
|
49
|
+
onCancel: onCancel
|
|
50
|
+
});
|
|
51
|
+
saveButton = screen.getByRole('button', {
|
|
52
|
+
name: /save/i
|
|
53
|
+
});
|
|
54
|
+
cancelButton = screen.getByRole('button', {
|
|
55
|
+
name: /cancel/i
|
|
56
|
+
});
|
|
57
|
+
_context.next = 7;
|
|
58
|
+
return userEvent.click(saveButton);
|
|
59
|
+
case 7:
|
|
60
|
+
_context.next = 9;
|
|
61
|
+
return userEvent.click(cancelButton);
|
|
62
|
+
case 9:
|
|
63
|
+
expect(onSubmit).toHaveBeenCalledTimes(1);
|
|
64
|
+
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
65
|
+
case 11:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}, _callee);
|
|
70
|
+
})));
|
|
71
|
+
test('does not render buttons when children are provided', function () {
|
|
72
|
+
getComponent({
|
|
73
|
+
children: ___EmotionJSX("div", null, "Custom Footer")
|
|
74
|
+
});
|
|
75
|
+
expect(screen.getByText(/custom footer/i)).toBeInTheDocument();
|
|
76
|
+
expect(screen.queryByRole('button', {
|
|
77
|
+
name: /save/i
|
|
78
|
+
})).not.toBeInTheDocument();
|
|
79
|
+
expect(screen.queryByRole('button', {
|
|
80
|
+
name: /cancel/i
|
|
81
|
+
})).not.toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
test('primaryButtonText and secondaryButtonText props change button text', function () {
|
|
84
|
+
getComponent({
|
|
85
|
+
primaryButtonText: 'Submit',
|
|
86
|
+
secondaryButtonText: 'Dismiss'
|
|
87
|
+
});
|
|
88
|
+
expect(screen.getByRole('button', {
|
|
89
|
+
name: /submit/i
|
|
90
|
+
})).toBeInTheDocument();
|
|
91
|
+
expect(screen.getByRole('button', {
|
|
92
|
+
name: /dismiss/i
|
|
93
|
+
})).toBeInTheDocument();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import CloseIcon from '@pingux/mdi-react/CloseIcon';
|
|
4
|
+
import Box from '../Box';
|
|
5
|
+
import Icon from '../Icon';
|
|
6
|
+
import IconButton from '../IconButton';
|
|
7
|
+
import Text from '../Text';
|
|
8
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
9
|
+
var ModalHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
10
|
+
var closeButton = props.closeButton,
|
|
11
|
+
hasCloseButton = props.hasCloseButton,
|
|
12
|
+
title = props.title,
|
|
13
|
+
onClose = props.onClose,
|
|
14
|
+
containerProps = props.containerProps,
|
|
15
|
+
titleProps = props.titleProps,
|
|
16
|
+
hasNoSeparator = props.hasNoSeparator;
|
|
17
|
+
var titleContent = typeof title === 'string' && title ? ___EmotionJSX(Box, {
|
|
18
|
+
flex: "1"
|
|
19
|
+
}, ___EmotionJSX(Text, _extends({}, titleProps, {
|
|
20
|
+
variant: "modalTitle",
|
|
21
|
+
role: "heading",
|
|
22
|
+
"aria-level": 1
|
|
23
|
+
}), title)) : title;
|
|
24
|
+
return ___EmotionJSX(Box, _extends({
|
|
25
|
+
variant: "modal.header",
|
|
26
|
+
isRow: true,
|
|
27
|
+
justifyContent: "space-between",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
as: "header",
|
|
30
|
+
ref: ref,
|
|
31
|
+
sx: {
|
|
32
|
+
borderBottomWidth: hasNoSeparator ? '0px' : '1px'
|
|
33
|
+
}
|
|
34
|
+
}, containerProps), titleContent, hasCloseButton && (closeButton !== null && closeButton !== void 0 ? closeButton : ___EmotionJSX(IconButton, {
|
|
35
|
+
"aria-label": "Close modal window",
|
|
36
|
+
"data-id": "icon-button__close-modal-window",
|
|
37
|
+
variant: "modalHeaderCloseButton",
|
|
38
|
+
onPress: onClose
|
|
39
|
+
}, ___EmotionJSX(Icon, {
|
|
40
|
+
icon: CloseIcon,
|
|
41
|
+
title: {
|
|
42
|
+
name: 'Close Icon'
|
|
43
|
+
}
|
|
44
|
+
}))));
|
|
45
|
+
});
|
|
46
|
+
ModalHeader.displayName = 'ModalHeader';
|
|
47
|
+
export default ModalHeader;
|