@pingux/astro 2.152.0 → 2.153.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +14 -4
- package/lib/cjs/components/Modal/Modal.stories.d.ts +2 -0
- package/lib/cjs/components/Modal/Modal.stories.js +84 -48
- package/lib/cjs/components/Modal/Modal.styles.d.ts +42 -26
- package/lib/cjs/components/Modal/Modal.styles.js +39 -27
- 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 +36 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +3 -0
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +54 -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 +22 -12
- package/lib/cjs/styles/themes/next-gen/variants/variants.js +23 -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 +14 -4
- package/lib/components/Modal/Modal.stories.js +82 -48
- package/lib/components/Modal/Modal.styles.js +37 -26
- 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/themes/next-gen/variants/button.js +6 -5
- package/lib/styles/themes/next-gen/variants/variants.js +23 -13
- package/package.json +1 -1
|
@@ -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, Modal, OverlayProvider, 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';
|
|
@@ -90,21 +90,6 @@ export default {
|
|
|
90
90
|
};
|
|
91
91
|
export var Default = function Default(args) {
|
|
92
92
|
var state = useModalState();
|
|
93
|
-
var ModalBodyContent = ___EmotionJSX(Box, null, ___EmotionJSX(Text, null, "Do you want to continue with this action that you\u2018re performing?"), ___EmotionJSX(Box, {
|
|
94
|
-
isRow: true,
|
|
95
|
-
mr: "auto",
|
|
96
|
-
width: "100%",
|
|
97
|
-
variant: "modal.buttonsContainer"
|
|
98
|
-
}, ___EmotionJSX(Button, {
|
|
99
|
-
variant: "primary",
|
|
100
|
-
onPress: state.close,
|
|
101
|
-
mr: "md",
|
|
102
|
-
"aria-label": "Continue"
|
|
103
|
-
}, "Continue"), ___EmotionJSX(Button, {
|
|
104
|
-
variant: "link",
|
|
105
|
-
onPress: state.close,
|
|
106
|
-
"aria-label": "Cancel"
|
|
107
|
-
}, "Cancel")));
|
|
108
93
|
return (
|
|
109
94
|
// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
|
110
95
|
// readers when an overlay opens.
|
|
@@ -114,10 +99,16 @@ export var Default = function Default(args) {
|
|
|
114
99
|
tabIndex: state.isOpen ? -1 : 0
|
|
115
100
|
}, "Open Modal"), (state.isOpen || state.isTransitioning) && ___EmotionJSX(Modal, _extends({}, args, {
|
|
116
101
|
isOpen: state.isOpen,
|
|
102
|
+
state: state
|
|
103
|
+
}), ___EmotionJSX(ModalHeader, {
|
|
104
|
+
hasCloseButton: true,
|
|
117
105
|
onClose: state.close,
|
|
118
|
-
state: state,
|
|
119
106
|
title: "Continue"
|
|
120
|
-
}),
|
|
107
|
+
}), ___EmotionJSX(ModalBody, null, ___EmotionJSX(Box, null, ___EmotionJSX(Text, null, "Do you want to continue with this action that you\u2018re performing?"))), ___EmotionJSX(ModalFooter, {
|
|
108
|
+
onSubmit: state.close,
|
|
109
|
+
onCancel: state.close,
|
|
110
|
+
primaryButtonText: "Continue"
|
|
111
|
+
})))
|
|
121
112
|
);
|
|
122
113
|
};
|
|
123
114
|
Default.parameters = {
|
|
@@ -137,27 +128,53 @@ export var LargeContent = function LargeContent(args) {
|
|
|
137
128
|
tabIndex: state.isOpen ? -1 : 0
|
|
138
129
|
}, "Open Modal"), state.isOpen && ___EmotionJSX(Modal, _extends({}, args, {
|
|
139
130
|
isOpen: state.isOpen,
|
|
131
|
+
onClose: state.close
|
|
132
|
+
}), ___EmotionJSX(ModalHeader, {
|
|
133
|
+
hasCloseButton: true,
|
|
140
134
|
onClose: state.close,
|
|
141
135
|
title: "Lorem Ipsum"
|
|
142
|
-
}), ___EmotionJSX(Box, {
|
|
136
|
+
}), ___EmotionJSX(ModalBody, null, ___EmotionJSX(Box, {
|
|
143
137
|
gap: "lg"
|
|
144
|
-
}, ___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(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
138
|
+
}, ___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, {
|
|
139
|
+
onSubmit: state.close,
|
|
140
|
+
onCancel: state.close
|
|
141
|
+
})))
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
export var LargeContentWithScroll = function LargeContentWithScroll(args) {
|
|
145
|
+
var state = useModalState();
|
|
146
|
+
return (
|
|
147
|
+
// Application must be wrapped in an OverlayProvider so that it can be hidden from screen
|
|
148
|
+
// readers when an overlay opens.
|
|
149
|
+
___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
|
150
|
+
onPress: state.open,
|
|
151
|
+
"aria-label": "Open modal",
|
|
152
|
+
tabIndex: state.isOpen ? -1 : 0
|
|
153
|
+
}, "Open Modal"), state.isOpen && ___EmotionJSX(Modal, _extends({}, args, {
|
|
154
|
+
isOpen: state.isOpen,
|
|
155
|
+
onClose: state.close
|
|
156
|
+
}), ___EmotionJSX(ModalHeader, {
|
|
157
|
+
hasCloseButton: true,
|
|
158
|
+
onClose: state.close,
|
|
159
|
+
title: "Lorem Ipsum"
|
|
160
|
+
}), ___EmotionJSX(ModalBody, {
|
|
161
|
+
isScrollable: true,
|
|
162
|
+
scrollProps: {
|
|
163
|
+
maxHeight: '400px'
|
|
164
|
+
}
|
|
165
|
+
}, ___EmotionJSX(Box, {
|
|
166
|
+
gap: "lg",
|
|
167
|
+
pr: "lg"
|
|
168
|
+
}, ___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, {
|
|
169
|
+
onSubmit: state.close,
|
|
170
|
+
onCancel: state.close
|
|
171
|
+
})))
|
|
157
172
|
);
|
|
158
173
|
};
|
|
159
174
|
export var WithInputField = function WithInputField() {
|
|
160
175
|
var state = useModalState();
|
|
176
|
+
var _useGetTheme = useGetTheme(),
|
|
177
|
+
isOnyx = _useGetTheme.themeState.isOnyx;
|
|
161
178
|
var _useState = useState(''),
|
|
162
179
|
_useState2 = _slicedToArray(_useState, 2),
|
|
163
180
|
value = _useState2[0],
|
|
@@ -179,8 +196,9 @@ export var WithInputField = function WithInputField() {
|
|
|
179
196
|
isOpen: state.isOpen,
|
|
180
197
|
onClose: state.close,
|
|
181
198
|
hasAutoFocus: true
|
|
182
|
-
}, ___EmotionJSX(Box, {
|
|
183
|
-
gap: "lg"
|
|
199
|
+
}, ___EmotionJSX(ModalBody, null, ___EmotionJSX(Box, {
|
|
200
|
+
gap: "lg",
|
|
201
|
+
pt: isOnyx ? '' : 'lg'
|
|
184
202
|
}, ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet consectetur"), ___EmotionJSX(SelectField, {
|
|
185
203
|
label: "Select an option"
|
|
186
204
|
}, ___EmotionJSX(Item, null, "Red"), ___EmotionJSX(Item, null, "Green"), ___EmotionJSX(Item, null, "Blue")), ___EmotionJSX(RadioGroupField, {
|
|
@@ -219,19 +237,10 @@ export var WithInputField = function WithInputField() {
|
|
|
219
237
|
key: item.key,
|
|
220
238
|
textValue: item.name
|
|
221
239
|
}, item.name);
|
|
222
|
-
}), ___EmotionJSX(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
variant: "primary",
|
|
227
|
-
onPress: state.close,
|
|
228
|
-
mr: "md",
|
|
229
|
-
"aria-label": "Continue"
|
|
230
|
-
}, "Continue"), ___EmotionJSX(Button, {
|
|
231
|
-
variant: "link",
|
|
232
|
-
onPress: state.close,
|
|
233
|
-
"aria-label": "Cancel"
|
|
234
|
-
}, "Cancel")))));
|
|
240
|
+
}))), ___EmotionJSX(ModalFooter, {
|
|
241
|
+
onSubmit: state.close,
|
|
242
|
+
onCancel: state.close
|
|
243
|
+
})));
|
|
235
244
|
};
|
|
236
245
|
WithInputField.parameters = {
|
|
237
246
|
a11y: {
|
|
@@ -242,4 +251,29 @@ WithInputField.parameters = {
|
|
|
242
251
|
}]
|
|
243
252
|
}
|
|
244
253
|
}
|
|
254
|
+
};
|
|
255
|
+
export var WithPopoverMenu = function WithPopoverMenu() {
|
|
256
|
+
var state = useModalState();
|
|
257
|
+
return ___EmotionJSX(OverlayProvider, null, ___EmotionJSX(Button, {
|
|
258
|
+
onPress: state.open,
|
|
259
|
+
"aria-label": "Open modal"
|
|
260
|
+
}, "Open Modal"), state.isOpen && ___EmotionJSX(Modal, {
|
|
261
|
+
isOpen: state.isOpen,
|
|
262
|
+
onClose: state.close
|
|
263
|
+
}, ___EmotionJSX(ModalBody, null, ___EmotionJSX(Box, {
|
|
264
|
+
gap: "lg"
|
|
265
|
+
}, ___EmotionJSX(Text, null, "Lorem ipsum dolor sit amet consectetur"), ___EmotionJSX(PopoverMenu, null, ___EmotionJSX(Button, null, "Click me"), ___EmotionJSX(Menu, {
|
|
266
|
+
onAction: function onAction() {
|
|
267
|
+
return console.log('on action');
|
|
268
|
+
}
|
|
269
|
+
}, ___EmotionJSX(Item, {
|
|
270
|
+
key: "edit"
|
|
271
|
+
}, "Edit"), ___EmotionJSX(Item, {
|
|
272
|
+
key: "duplicate"
|
|
273
|
+
}, "Duplicate"), ___EmotionJSX(Item, {
|
|
274
|
+
key: "delete",
|
|
275
|
+
textValue: "delete"
|
|
276
|
+
}, ___EmotionJSX(Text, {
|
|
277
|
+
color: "critical.bright"
|
|
278
|
+
}, "Delete"))))))));
|
|
245
279
|
};
|
|
@@ -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,40 @@ 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: 'backgroundBase'
|
|
57
|
+
position: 'relative',
|
|
58
|
+
backgroundColor: 'background.base',
|
|
59
|
+
px: 'lg',
|
|
60
|
+
py: 'md'
|
|
73
61
|
};
|
|
74
|
-
var
|
|
75
|
-
position: '
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
80
|
pt: 'lg',
|
|
81
81
|
background: 'white',
|
|
82
82
|
'& > button': {
|
|
83
83
|
flexGrow: 0
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
|
+
var buttonsContainer = {
|
|
87
|
+
p: 0,
|
|
88
|
+
pt: 'lg',
|
|
89
|
+
background: 'white'
|
|
90
|
+
};
|
|
86
91
|
var title = _objectSpread(_objectSpread({}, text.title), {}, {
|
|
87
92
|
mr: 'sm',
|
|
88
93
|
fontWeight: 3
|
|
@@ -91,6 +96,7 @@ export var modalCloseButton = {
|
|
|
91
96
|
position: 'absolute',
|
|
92
97
|
top: 14,
|
|
93
98
|
right: 10,
|
|
99
|
+
alignSelf: 'auto',
|
|
94
100
|
width: '22px',
|
|
95
101
|
height: '22px'
|
|
96
102
|
};
|
|
@@ -99,7 +105,12 @@ export default {
|
|
|
99
105
|
container: container,
|
|
100
106
|
content: content,
|
|
101
107
|
headingContainer: headingContainer,
|
|
102
|
-
|
|
108
|
+
bodyContainer: bodyContainer,
|
|
103
109
|
title: title,
|
|
104
|
-
modalCloseButton: modalCloseButton
|
|
110
|
+
modalCloseButton: modalCloseButton,
|
|
111
|
+
buttonsContainer: buttonsContainer,
|
|
112
|
+
header: header,
|
|
113
|
+
body: body,
|
|
114
|
+
footer: footer,
|
|
115
|
+
closeButton: closeButton
|
|
105
116
|
};
|
|
@@ -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;
|