@instructure/ui-modal 10.16.1-snapshot-0 → 10.16.1
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/CHANGELOG.md +1 -1
- package/es/Modal/ModalBody/__new-tests__/ModalBody.test.js +21 -12
- package/es/Modal/ModalBody/index.js +10 -6
- package/es/Modal/ModalFooter/__new-tests__/ModalFooter.test.js +8 -5
- package/es/Modal/ModalFooter/index.js +8 -7
- package/es/Modal/ModalHeader/__new-tests__/ModalHeader.test.js +19 -12
- package/es/Modal/ModalHeader/index.js +10 -9
- package/es/Modal/__new-tests__/Modal.test.js +185 -97
- package/es/Modal/index.js +33 -25
- package/lib/Modal/ModalBody/__new-tests__/ModalBody.test.js +22 -13
- package/lib/Modal/ModalBody/index.js +9 -5
- package/lib/Modal/ModalFooter/__new-tests__/ModalFooter.test.js +9 -6
- package/lib/Modal/ModalFooter/index.js +7 -6
- package/lib/Modal/ModalHeader/__new-tests__/ModalHeader.test.js +20 -13
- package/lib/Modal/ModalHeader/index.js +9 -9
- package/lib/Modal/__new-tests__/Modal.test.js +185 -97
- package/lib/Modal/index.js +32 -24
- package/package.json +19 -19
- package/src/Modal/ModalBody/__new-tests__/ModalBody.test.tsx +0 -2
- package/src/Modal/ModalBody/index.tsx +1 -2
- package/src/Modal/ModalFooter/__new-tests__/ModalFooter.test.tsx +0 -2
- package/src/Modal/ModalFooter/index.tsx +1 -2
- package/src/Modal/ModalHeader/__new-tests__/ModalHeader.test.tsx +0 -2
- package/src/Modal/ModalHeader/index.tsx +4 -5
- package/src/Modal/__new-tests__/Modal.test.tsx +3 -5
- package/src/Modal/index.tsx +1 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Modal/ModalBody/__new-tests__/ModalBody.test.d.ts.map +1 -1
- package/types/Modal/ModalBody/index.d.ts +1 -3
- package/types/Modal/ModalBody/index.d.ts.map +1 -1
- package/types/Modal/ModalFooter/__new-tests__/ModalFooter.test.d.ts.map +1 -1
- package/types/Modal/ModalFooter/index.d.ts +1 -3
- package/types/Modal/ModalFooter/index.d.ts.map +1 -1
- package/types/Modal/ModalHeader/__new-tests__/ModalHeader.test.d.ts.map +1 -1
- package/types/Modal/ModalHeader/index.d.ts +2 -4
- package/types/Modal/ModalHeader/index.d.ts.map +1 -1
- package/types/Modal/index.d.ts +2 -4
- package/types/Modal/index.d.ts.map +1 -1
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
5
|
-
var _react =
|
|
5
|
+
var _react = require("react");
|
|
6
6
|
var _react2 = require("@testing-library/react");
|
|
7
7
|
var _vitest = require("vitest");
|
|
8
8
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
9
9
|
require("@testing-library/jest-dom");
|
|
10
10
|
var _index = require("../index");
|
|
11
11
|
var _View2 = require("@instructure/ui-view/lib/View");
|
|
12
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
13
|
const _excluded = ["label"];
|
|
13
14
|
var _Modal, _Modal2, _Modal$Body, _Modal3, _Modal4, _View, _Modal5, _Modal$Body2, _Modal$Body3, _Modal$Body4, _Modal$Body5, _Modal$Body6, _Modal$Body7, _Modal6, _Modal7, _input, _Modal$Header, _Modal$Body8, _Modal$Footer;
|
|
14
15
|
/*
|
|
@@ -58,25 +59,31 @@ describe('<Modal />', () => {
|
|
|
58
59
|
window.scroll = originalScroll;
|
|
59
60
|
});
|
|
60
61
|
it('should render nothing and have a node with no parent when closed', () => {
|
|
61
|
-
const _render = (0, _react2.render)(_Modal || (_Modal =
|
|
62
|
+
const _render = (0, _react2.render)(_Modal || (_Modal = (0, _jsxRuntime.jsx)(_index.Modal, {
|
|
62
63
|
label: "Modal Dialog",
|
|
63
|
-
shouldReturnFocus: false
|
|
64
|
-
|
|
64
|
+
shouldReturnFocus: false,
|
|
65
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
66
|
+
children: "Foo Bar Baz"
|
|
67
|
+
})
|
|
68
|
+
}))),
|
|
65
69
|
container = _render.container;
|
|
66
70
|
expect(container.firstChild).not.toBeInTheDocument();
|
|
67
71
|
});
|
|
68
72
|
it('should apply theme overrides when open', async () => {
|
|
69
73
|
const testFont = 'test-font';
|
|
70
74
|
const bodyText = 'Modal-body-text';
|
|
71
|
-
const _render2 = (0, _react2.render)(
|
|
75
|
+
const _render2 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Modal, {
|
|
72
76
|
open: true,
|
|
73
77
|
size: "small",
|
|
74
78
|
label: "Modal Dialog",
|
|
75
79
|
shouldReturnFocus: false,
|
|
76
80
|
themeOverride: {
|
|
77
81
|
fontFamily: testFont
|
|
78
|
-
}
|
|
79
|
-
|
|
82
|
+
},
|
|
83
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
84
|
+
children: bodyText
|
|
85
|
+
})
|
|
86
|
+
})),
|
|
80
87
|
findByText = _render2.findByText,
|
|
81
88
|
findByRole = _render2.findByRole;
|
|
82
89
|
const modalBody = await findByText(bodyText);
|
|
@@ -86,12 +93,15 @@ describe('<Modal />', () => {
|
|
|
86
93
|
expect(dialogStyle.fontFamily).toBe(testFont);
|
|
87
94
|
});
|
|
88
95
|
it('should render its own positioning context if constrained to parent', async () => {
|
|
89
|
-
const _render3 = (0, _react2.render)(_Modal2 || (_Modal2 =
|
|
96
|
+
const _render3 = (0, _react2.render)(_Modal2 || (_Modal2 = (0, _jsxRuntime.jsx)(_index.Modal, {
|
|
90
97
|
open: true,
|
|
91
98
|
label: "Modal Dialog",
|
|
92
99
|
shouldReturnFocus: false,
|
|
93
|
-
constrain: "parent"
|
|
94
|
-
|
|
100
|
+
constrain: "parent",
|
|
101
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
102
|
+
children: "Foo Bar Baz"
|
|
103
|
+
})
|
|
104
|
+
}))),
|
|
95
105
|
findByRole = _render3.findByRole;
|
|
96
106
|
const dialog = await findByRole('dialog');
|
|
97
107
|
const constrain = document.querySelector("[class*='constrainContext']");
|
|
@@ -99,19 +109,23 @@ describe('<Modal />', () => {
|
|
|
99
109
|
expect(constrain).toBeInTheDocument();
|
|
100
110
|
});
|
|
101
111
|
it("should not inherit its parent's font color", async () => {
|
|
102
|
-
const _render4 = (0, _react2.render)(
|
|
112
|
+
const _render4 = (0, _react2.render)((0, _jsxRuntime.jsx)("div", {
|
|
103
113
|
style: {
|
|
104
114
|
color: 'rgb(255, 255, 255)'
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
},
|
|
116
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal, {
|
|
117
|
+
open: true,
|
|
118
|
+
label: "Modal Dialog",
|
|
119
|
+
shouldReturnFocus: false,
|
|
120
|
+
constrain: "parent",
|
|
121
|
+
themeOverride: {
|
|
122
|
+
textColor: 'rgb(0, 0, 0)'
|
|
123
|
+
},
|
|
124
|
+
children: _Modal$Body || (_Modal$Body = (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
125
|
+
children: "Foo Bar Baz"
|
|
126
|
+
}))
|
|
127
|
+
})
|
|
128
|
+
})),
|
|
115
129
|
findByRole = _render4.findByRole;
|
|
116
130
|
const dialog = await findByRole('dialog');
|
|
117
131
|
const dialogStyle = window.getComputedStyle(dialog);
|
|
@@ -119,43 +133,57 @@ describe('<Modal />', () => {
|
|
|
119
133
|
expect(dialogStyle.color).toBe('rgb(0, 0, 0)');
|
|
120
134
|
});
|
|
121
135
|
it('should pass `as` prop to the dialog', async () => {
|
|
122
|
-
const _render5 = (0, _react2.render)(_Modal3 || (_Modal3 =
|
|
136
|
+
const _render5 = (0, _react2.render)(_Modal3 || (_Modal3 = (0, _jsxRuntime.jsx)(_index.Modal, {
|
|
123
137
|
open: true,
|
|
124
138
|
label: "Modal Dialog",
|
|
125
|
-
shouldReturnFocus: false
|
|
126
|
-
|
|
139
|
+
shouldReturnFocus: false,
|
|
140
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
141
|
+
children: "Foo Bar Baz"
|
|
142
|
+
})
|
|
143
|
+
}))),
|
|
127
144
|
findByRole = _render5.findByRole,
|
|
128
145
|
rerender = _render5.rerender;
|
|
129
146
|
const dialog = await findByRole('dialog');
|
|
130
147
|
expect(dialog).toBeInTheDocument();
|
|
131
148
|
expect(dialog.tagName).toBe('SPAN');
|
|
132
|
-
rerender(_Modal4 || (_Modal4 =
|
|
149
|
+
rerender(_Modal4 || (_Modal4 = (0, _jsxRuntime.jsx)(_index.Modal, {
|
|
133
150
|
as: "form",
|
|
134
151
|
open: true,
|
|
135
152
|
label: "Modal Dialog",
|
|
136
|
-
shouldReturnFocus: false
|
|
137
|
-
|
|
153
|
+
shouldReturnFocus: false,
|
|
154
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
155
|
+
children: "Foo Bar Baz"
|
|
156
|
+
})
|
|
157
|
+
})));
|
|
138
158
|
const dialogForm = await findByRole('dialog');
|
|
139
159
|
expect(dialogForm.tagName).toBe('FORM');
|
|
140
160
|
});
|
|
141
161
|
it('should handle null children', async () => {
|
|
142
162
|
const bodyText = 'Modal-body-text';
|
|
143
|
-
const _render6 = (0, _react2.render)(
|
|
163
|
+
const _render6 = (0, _react2.render)((0, _jsxRuntime.jsxs)(_index.Modal, {
|
|
144
164
|
open: true,
|
|
145
165
|
label: "Modal Dialog",
|
|
146
|
-
shouldReturnFocus: false
|
|
147
|
-
|
|
166
|
+
shouldReturnFocus: false,
|
|
167
|
+
children: [null, (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
168
|
+
children: bodyText
|
|
169
|
+
}), null]
|
|
170
|
+
})),
|
|
148
171
|
findByText = _render6.findByText;
|
|
149
172
|
const modalBody = await findByText(bodyText);
|
|
150
173
|
expect(modalBody).toBeInTheDocument();
|
|
151
174
|
});
|
|
152
175
|
it('should handle custom children', async () => {
|
|
153
176
|
const bodyText = 'Modal-body-text';
|
|
154
|
-
const _render7 = (0, _react2.render)(
|
|
177
|
+
const _render7 = (0, _react2.render)((0, _jsxRuntime.jsxs)(_index.Modal, {
|
|
155
178
|
open: true,
|
|
156
179
|
label: "Modal Dialog",
|
|
157
|
-
shouldReturnFocus: false
|
|
158
|
-
|
|
180
|
+
shouldReturnFocus: false,
|
|
181
|
+
children: [_View || (_View = (0, _jsxRuntime.jsx)(_View2.View, {
|
|
182
|
+
children: "This is a custom child"
|
|
183
|
+
})), (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
184
|
+
children: bodyText
|
|
185
|
+
})]
|
|
186
|
+
})),
|
|
159
187
|
findByText = _render7.findByText;
|
|
160
188
|
const modalBody = await findByText(bodyText);
|
|
161
189
|
const customChild = await findByText('This is a custom child');
|
|
@@ -163,11 +191,14 @@ describe('<Modal />', () => {
|
|
|
163
191
|
expect(customChild).toBeInTheDocument();
|
|
164
192
|
});
|
|
165
193
|
it('should apply the aria attributes', async () => {
|
|
166
|
-
const _render8 = (0, _react2.render)(_Modal5 || (_Modal5 =
|
|
194
|
+
const _render8 = (0, _react2.render)(_Modal5 || (_Modal5 = (0, _jsxRuntime.jsx)(_index.Modal, {
|
|
167
195
|
open: true,
|
|
168
196
|
label: "Modal Dialog",
|
|
169
|
-
shouldReturnFocus: false
|
|
170
|
-
|
|
197
|
+
shouldReturnFocus: false,
|
|
198
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
199
|
+
children: "Foo Bar Baz"
|
|
200
|
+
})
|
|
201
|
+
}))),
|
|
171
202
|
findByRole = _render8.findByRole;
|
|
172
203
|
const dialog = await findByRole('dialog');
|
|
173
204
|
expect(dialog).toBeInTheDocument();
|
|
@@ -177,15 +208,18 @@ describe('<Modal />', () => {
|
|
|
177
208
|
const onEnter = _vitest.vi.fn();
|
|
178
209
|
const onEntering = _vitest.vi.fn();
|
|
179
210
|
const onEntered = _vitest.vi.fn();
|
|
180
|
-
const _render9 = (0, _react2.render)(
|
|
211
|
+
const _render9 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Modal, {
|
|
181
212
|
open: true,
|
|
182
213
|
onEnter: onEnter,
|
|
183
214
|
onEntering: onEntering,
|
|
184
215
|
onEntered: onEntered,
|
|
185
216
|
transition: "fade",
|
|
186
217
|
label: "Modal Dialog",
|
|
187
|
-
shouldReturnFocus: false
|
|
188
|
-
|
|
218
|
+
shouldReturnFocus: false,
|
|
219
|
+
children: _Modal$Body2 || (_Modal$Body2 = (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
220
|
+
children: "Foo Bar Baz"
|
|
221
|
+
}))
|
|
222
|
+
})),
|
|
189
223
|
findByRole = _render9.findByRole;
|
|
190
224
|
const dialog = await findByRole('dialog');
|
|
191
225
|
expect(dialog).toBeInTheDocument();
|
|
@@ -197,12 +231,15 @@ describe('<Modal />', () => {
|
|
|
197
231
|
});
|
|
198
232
|
it('should support onOpen prop', async () => {
|
|
199
233
|
const onOpen = _vitest.vi.fn();
|
|
200
|
-
const _render10 = (0, _react2.render)(
|
|
234
|
+
const _render10 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Modal, {
|
|
201
235
|
open: true,
|
|
202
236
|
onOpen: onOpen,
|
|
203
237
|
label: "Modal Dialog",
|
|
204
|
-
shouldReturnFocus: false
|
|
205
|
-
|
|
238
|
+
shouldReturnFocus: false,
|
|
239
|
+
children: _Modal$Body3 || (_Modal$Body3 = (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
240
|
+
children: "Foo Bar Baz"
|
|
241
|
+
}))
|
|
242
|
+
})),
|
|
206
243
|
findByRole = _render10.findByRole;
|
|
207
244
|
const dialog = await findByRole('dialog');
|
|
208
245
|
expect(dialog).toBeInTheDocument();
|
|
@@ -212,34 +249,43 @@ describe('<Modal />', () => {
|
|
|
212
249
|
});
|
|
213
250
|
it('should support onClose prop', async () => {
|
|
214
251
|
const onClose = _vitest.vi.fn();
|
|
215
|
-
const _render11 = (0, _react2.render)(
|
|
252
|
+
const _render11 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Modal, {
|
|
216
253
|
open: true,
|
|
217
254
|
onClose: onClose,
|
|
218
255
|
label: "Modal Dialog",
|
|
219
|
-
shouldReturnFocus: false
|
|
220
|
-
|
|
256
|
+
shouldReturnFocus: false,
|
|
257
|
+
children: _Modal$Body4 || (_Modal$Body4 = (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
258
|
+
children: "Foo Bar Baz"
|
|
259
|
+
}))
|
|
260
|
+
})),
|
|
221
261
|
findByRole = _render11.findByRole,
|
|
222
262
|
rerender = _render11.rerender;
|
|
223
263
|
const dialog = await findByRole('dialog');
|
|
224
264
|
expect(dialog).toBeInTheDocument();
|
|
225
|
-
rerender(
|
|
265
|
+
rerender((0, _jsxRuntime.jsx)(_index.Modal, {
|
|
226
266
|
open: false,
|
|
227
267
|
onClose: onClose,
|
|
228
268
|
label: "Modal Dialog",
|
|
229
|
-
shouldReturnFocus: false
|
|
230
|
-
|
|
269
|
+
shouldReturnFocus: false,
|
|
270
|
+
children: _Modal$Body5 || (_Modal$Body5 = (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
271
|
+
children: "Foo Bar Baz"
|
|
272
|
+
}))
|
|
273
|
+
}));
|
|
231
274
|
await (0, _react2.waitFor)(() => {
|
|
232
275
|
expect(onClose).toHaveBeenCalled();
|
|
233
276
|
});
|
|
234
277
|
});
|
|
235
278
|
it('should dismiss when overlay clicked by default', async () => {
|
|
236
279
|
const onDismiss = _vitest.vi.fn();
|
|
237
|
-
const _render12 = (0, _react2.render)(
|
|
280
|
+
const _render12 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Modal, {
|
|
238
281
|
open: true,
|
|
239
282
|
onDismiss: onDismiss,
|
|
240
283
|
label: "Modal Dialog",
|
|
241
|
-
shouldReturnFocus: false
|
|
242
|
-
|
|
284
|
+
shouldReturnFocus: false,
|
|
285
|
+
children: _Modal$Body6 || (_Modal$Body6 = (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
286
|
+
children: "Modal Text"
|
|
287
|
+
}))
|
|
288
|
+
})),
|
|
243
289
|
findByText = _render12.findByText;
|
|
244
290
|
const modalBody = await findByText('Modal Text');
|
|
245
291
|
expect(modalBody).toBeInTheDocument();
|
|
@@ -251,16 +297,24 @@ describe('<Modal />', () => {
|
|
|
251
297
|
it('should NOT dismiss when overlay clicked with shouldCloseOnDocumentClick=false', async () => {
|
|
252
298
|
const onDismiss = _vitest.vi.fn();
|
|
253
299
|
const onClickOuter = _vitest.vi.fn();
|
|
254
|
-
const _render13 = (0, _react2.render)(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
300
|
+
const _render13 = (0, _react2.render)((0, _jsxRuntime.jsxs)("div", {
|
|
301
|
+
children: [(0, _jsxRuntime.jsx)("button", {
|
|
302
|
+
"data-testid": "outer-element",
|
|
303
|
+
onClick: onClickOuter,
|
|
304
|
+
children: "for dismiss"
|
|
305
|
+
}), (0, _jsxRuntime.jsx)(_index.Modal, {
|
|
306
|
+
open: true,
|
|
307
|
+
onDismiss: onDismiss,
|
|
308
|
+
label: "Modal Dialog",
|
|
309
|
+
shouldReturnFocus: false,
|
|
310
|
+
shouldCloseOnDocumentClick: false,
|
|
311
|
+
children: _Modal$Body7 || (_Modal$Body7 = (0, _jsxRuntime.jsxs)(_index.Modal.Body, {
|
|
312
|
+
children: ["Foo Bar Baz ", (0, _jsxRuntime.jsx)("button", {
|
|
313
|
+
children: "click me"
|
|
314
|
+
})]
|
|
315
|
+
}))
|
|
316
|
+
})]
|
|
317
|
+
})),
|
|
264
318
|
findByRole = _render13.findByRole,
|
|
265
319
|
getByTestId = _render13.getByTestId;
|
|
266
320
|
const dialog = await findByRole('dialog');
|
|
@@ -273,22 +327,36 @@ describe('<Modal />', () => {
|
|
|
273
327
|
});
|
|
274
328
|
});
|
|
275
329
|
it('should render children', async () => {
|
|
276
|
-
const _render14 = (0, _react2.render)(_Modal6 || (_Modal6 =
|
|
330
|
+
const _render14 = (0, _react2.render)(_Modal6 || (_Modal6 = (0, _jsxRuntime.jsx)(_index.Modal, {
|
|
277
331
|
open: true,
|
|
278
332
|
label: "Modal Dialog",
|
|
279
|
-
shouldReturnFocus: false
|
|
280
|
-
|
|
333
|
+
shouldReturnFocus: false,
|
|
334
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
335
|
+
children: (0, _jsxRuntime.jsx)("button", {
|
|
336
|
+
children: "Cancel"
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
}))),
|
|
281
340
|
findByText = _render14.findByText;
|
|
282
341
|
const cancelButton = await findByText('Cancel');
|
|
283
342
|
expect(cancelButton).toBeInTheDocument();
|
|
284
343
|
});
|
|
285
344
|
describe('children validation', () => {
|
|
286
345
|
it('should pass validation when children are valid', async () => {
|
|
287
|
-
const _render15 = (0, _react2.render)(_Modal7 || (_Modal7 =
|
|
346
|
+
const _render15 = (0, _react2.render)(_Modal7 || (_Modal7 = (0, _jsxRuntime.jsxs)(_index.Modal, {
|
|
288
347
|
open: true,
|
|
289
348
|
label: "Modal Dialog",
|
|
290
|
-
shouldReturnFocus: false
|
|
291
|
-
|
|
349
|
+
shouldReturnFocus: false,
|
|
350
|
+
children: [(0, _jsxRuntime.jsx)(_index.Modal.Header, {
|
|
351
|
+
children: "Hello World"
|
|
352
|
+
}), (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
353
|
+
children: "Foo Bar Baz"
|
|
354
|
+
}), (0, _jsxRuntime.jsx)(_index.Modal.Footer, {
|
|
355
|
+
children: (0, _jsxRuntime.jsx)("button", {
|
|
356
|
+
children: "Cancel"
|
|
357
|
+
})
|
|
358
|
+
})]
|
|
359
|
+
}))),
|
|
292
360
|
findByRole = _render15.findByRole;
|
|
293
361
|
const dialog = await findByRole('dialog');
|
|
294
362
|
expect(dialog).toBeInTheDocument();
|
|
@@ -298,18 +366,22 @@ describe('<Modal />', () => {
|
|
|
298
366
|
let headerRef = null;
|
|
299
367
|
let bodyRef = null;
|
|
300
368
|
let footerRef = null;
|
|
301
|
-
const _render16 = (0, _react2.render)(
|
|
369
|
+
const _render16 = (0, _react2.render)((0, _jsxRuntime.jsxs)(_index.Modal, {
|
|
302
370
|
open: true,
|
|
303
371
|
label: "Dark Modal",
|
|
304
372
|
shouldReturnFocus: false,
|
|
305
|
-
variant: "inverse"
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
373
|
+
variant: "inverse",
|
|
374
|
+
children: [(0, _jsxRuntime.jsx)(_index.Modal.Header, {
|
|
375
|
+
ref: el => headerRef = el,
|
|
376
|
+
children: "header"
|
|
377
|
+
}), (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
378
|
+
ref: el => bodyRef = el,
|
|
379
|
+
children: "body"
|
|
380
|
+
}), (0, _jsxRuntime.jsx)(_index.Modal.Footer, {
|
|
381
|
+
ref: el => footerRef = el,
|
|
382
|
+
children: "footer"
|
|
383
|
+
})]
|
|
384
|
+
})),
|
|
313
385
|
findByRole = _render16.findByRole;
|
|
314
386
|
const dialog = await findByRole('dialog');
|
|
315
387
|
expect(dialog).toBeInTheDocument();
|
|
@@ -319,14 +391,16 @@ describe('<Modal />', () => {
|
|
|
319
391
|
});
|
|
320
392
|
it('should pass overflow to Modal.Body', async () => {
|
|
321
393
|
let bodyRef = null;
|
|
322
|
-
const _render17 = (0, _react2.render)(
|
|
394
|
+
const _render17 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Modal, {
|
|
323
395
|
open: true,
|
|
324
396
|
label: "Modal",
|
|
325
397
|
shouldReturnFocus: false,
|
|
326
|
-
overflow: "fit"
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
398
|
+
overflow: "fit",
|
|
399
|
+
children: (0, _jsxRuntime.jsx)(_index.Modal.Body, {
|
|
400
|
+
ref: el => bodyRef = el,
|
|
401
|
+
children: "body"
|
|
402
|
+
})
|
|
403
|
+
})),
|
|
330
404
|
findByRole = _render17.findByRole;
|
|
331
405
|
const dialog = await findByRole('dialog');
|
|
332
406
|
expect(dialog).toBeInTheDocument();
|
|
@@ -335,24 +409,38 @@ describe('<Modal />', () => {
|
|
|
335
409
|
});
|
|
336
410
|
describe('managed focus', () => {
|
|
337
411
|
var _ModalExample2;
|
|
338
|
-
class ModalExample extends _react.
|
|
412
|
+
class ModalExample extends _react.Component {
|
|
339
413
|
render() {
|
|
340
414
|
const _this$props = this.props,
|
|
341
415
|
label = _this$props.label,
|
|
342
416
|
props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
|
|
343
|
-
return
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
417
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
418
|
+
children: [_input || (_input = (0, _jsxRuntime.jsx)("input", {
|
|
419
|
+
type: "text"
|
|
420
|
+
})), (0, _jsxRuntime.jsxs)(_index.Modal, {
|
|
421
|
+
label: label,
|
|
422
|
+
...props,
|
|
423
|
+
children: [_Modal$Header || (_Modal$Header = (0, _jsxRuntime.jsx)(_index.Modal.Header, {
|
|
424
|
+
children: (0, _jsxRuntime.jsx)("button", {
|
|
425
|
+
children: "Close"
|
|
426
|
+
})
|
|
427
|
+
})), _Modal$Body8 || (_Modal$Body8 = (0, _jsxRuntime.jsxs)(_index.Modal.Body, {
|
|
428
|
+
children: [(0, _jsxRuntime.jsx)("input", {
|
|
429
|
+
type: "text",
|
|
430
|
+
id: "input-one",
|
|
431
|
+
"data-testid": "input-first"
|
|
432
|
+
}), (0, _jsxRuntime.jsx)("input", {
|
|
433
|
+
type: "text",
|
|
434
|
+
id: "input-two",
|
|
435
|
+
"data-testid": "input-second"
|
|
436
|
+
})]
|
|
437
|
+
})), _Modal$Footer || (_Modal$Footer = (0, _jsxRuntime.jsx)(_index.Modal.Footer, {
|
|
438
|
+
children: (0, _jsxRuntime.jsx)("button", {
|
|
439
|
+
children: "Cancel"
|
|
440
|
+
})
|
|
441
|
+
}))]
|
|
442
|
+
})]
|
|
443
|
+
});
|
|
356
444
|
}
|
|
357
445
|
}
|
|
358
446
|
ModalExample.displayName = "ModalExample";
|
|
@@ -361,7 +449,7 @@ describe('<Modal />', () => {
|
|
|
361
449
|
..._index.Modal.propTypes
|
|
362
450
|
};
|
|
363
451
|
it('should focus closeButton by default', async () => {
|
|
364
|
-
const _render18 = (0, _react2.render)(_ModalExample2 || (_ModalExample2 =
|
|
452
|
+
const _render18 = (0, _react2.render)(_ModalExample2 || (_ModalExample2 = (0, _jsxRuntime.jsx)(ModalExample, {
|
|
365
453
|
open: true,
|
|
366
454
|
label: "A Modal"
|
|
367
455
|
}))),
|
|
@@ -373,7 +461,7 @@ describe('<Modal />', () => {
|
|
|
373
461
|
});
|
|
374
462
|
});
|
|
375
463
|
it('should take a prop for finding default focus', async () => {
|
|
376
|
-
const _render19 = (0, _react2.render)(
|
|
464
|
+
const _render19 = (0, _react2.render)((0, _jsxRuntime.jsx)(ModalExample, {
|
|
377
465
|
open: true,
|
|
378
466
|
label: "A Modal",
|
|
379
467
|
defaultFocusElement: () => document.getElementById('input-one')
|
package/lib/Modal/index.js
CHANGED
|
@@ -42,6 +42,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
42
42
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
43
43
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
44
44
|
var _props = require("./props");
|
|
45
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
45
46
|
const _excluded = ["open", "onOpen", "onClose", "mountNode", "insertAt", "transition", "onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "constrain", "overflow"];
|
|
46
47
|
var _dec, _dec2, _class, _Modal;
|
|
47
48
|
/*
|
|
@@ -67,7 +68,6 @@ var _dec, _dec2, _class, _Modal;
|
|
|
67
68
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
68
69
|
* SOFTWARE.
|
|
69
70
|
*/
|
|
70
|
-
/** @jsx jsx */
|
|
71
71
|
/**
|
|
72
72
|
---
|
|
73
73
|
category: components
|
|
@@ -198,9 +198,10 @@ let Modal = exports.Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _th
|
|
|
198
198
|
|
|
199
199
|
// Adds the <div> to the beginning of the filteredChildren array
|
|
200
200
|
if (headerAndBody.length > 0) {
|
|
201
|
-
filteredChildren.unshift((0,
|
|
202
|
-
css: styles === null || styles === void 0 ? void 0 : styles.joinedHeaderAndBody
|
|
203
|
-
|
|
201
|
+
filteredChildren.unshift((0, _jsxRuntime.jsx)("div", {
|
|
202
|
+
css: styles === null || styles === void 0 ? void 0 : styles.joinedHeaderAndBody,
|
|
203
|
+
children: headerAndBody
|
|
204
|
+
}));
|
|
204
205
|
}
|
|
205
206
|
return _react.Children.map(filteredChildren, child => {
|
|
206
207
|
if (!child) return; // ignore null, falsy children
|
|
@@ -230,7 +231,8 @@ let Modal = exports.Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _th
|
|
|
230
231
|
as = _this$props5.as,
|
|
231
232
|
styles = _this$props5.styles;
|
|
232
233
|
const isFullScreen = size === 'fullscreen';
|
|
233
|
-
const dialog = (0,
|
|
234
|
+
const dialog = (0, _jsxRuntime.jsx)(_Dialog.Dialog, {
|
|
235
|
+
...(0, _passthroughProps.passthroughProps)(props),
|
|
234
236
|
as: as,
|
|
235
237
|
open: true,
|
|
236
238
|
label: label,
|
|
@@ -244,15 +246,18 @@ let Modal = exports.Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _th
|
|
|
244
246
|
css: styles === null || styles === void 0 ? void 0 : styles.modal,
|
|
245
247
|
ref: this.contentRef
|
|
246
248
|
// aria-modal="true" see VO bug https://bugs.webkit.org/show_bug.cgi?id=174667
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
,
|
|
250
|
+
children: this.renderChildren()
|
|
251
|
+
});
|
|
252
|
+
return (0, _jsxRuntime.jsx)(_Mask.Mask, {
|
|
249
253
|
placement: this.maskPlacement,
|
|
250
254
|
fullscreen: constrain === 'window',
|
|
251
255
|
themeOverride: isFullScreen ? {
|
|
252
256
|
borderRadius: '0em',
|
|
253
257
|
borderWidth: '0em'
|
|
254
|
-
} : {}
|
|
255
|
-
|
|
258
|
+
} : {},
|
|
259
|
+
children: dialog
|
|
260
|
+
});
|
|
256
261
|
}
|
|
257
262
|
render() {
|
|
258
263
|
var _this$props$styles;
|
|
@@ -273,24 +278,27 @@ let Modal = exports.Modal = (_dec = (0, _emotion.withStyle)(_styles.default, _th
|
|
|
273
278
|
overflow = _this$props6.overflow,
|
|
274
279
|
passthroughProps = (0, _objectWithoutProperties2.default)(_this$props6, _excluded);
|
|
275
280
|
const portalIsOpen = this.state.open || this.state.transitioning;
|
|
276
|
-
return (0,
|
|
281
|
+
return (0, _jsxRuntime.jsx)(_Portal.Portal, {
|
|
277
282
|
mountNode: mountNode,
|
|
278
283
|
insertAt: insertAt,
|
|
279
284
|
open: portalIsOpen,
|
|
280
|
-
onOpen: this.handlePortalOpen
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
285
|
+
onOpen: this.handlePortalOpen,
|
|
286
|
+
children: (0, _jsxRuntime.jsx)(_Transition.Transition, {
|
|
287
|
+
in: open,
|
|
288
|
+
transitionOnMount: true,
|
|
289
|
+
type: transition,
|
|
290
|
+
onEnter: onEnter,
|
|
291
|
+
onEntering: onEntering,
|
|
292
|
+
onEntered: (0, _createChainedFunction.createChainedFunction)(this.handleTransitionComplete, onEntered, onOpen),
|
|
293
|
+
onExit: onExit,
|
|
294
|
+
onExiting: onExiting,
|
|
295
|
+
onExited: (0, _createChainedFunction.createChainedFunction)(this.handleTransitionComplete, onExited, onClose),
|
|
296
|
+
children: constrain === 'parent' ? (0, _jsxRuntime.jsx)("span", {
|
|
297
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.constrainContext,
|
|
298
|
+
children: this.renderDialog(passthroughProps)
|
|
299
|
+
}) : this.renderDialog(passthroughProps)
|
|
300
|
+
})
|
|
301
|
+
});
|
|
294
302
|
}
|
|
295
303
|
}, _Modal.displayName = "Modal", _Modal.componentId = 'Modal', _Modal.propTypes = _props.propTypes, _Modal.allowedProps = _props.allowedProps, _Modal.defaultProps = {
|
|
296
304
|
open: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-modal",
|
|
3
|
-
"version": "10.16.1
|
|
3
|
+
"version": "10.16.1",
|
|
4
4
|
"description": "A component for displaying content in a dialog overlay",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,30 +24,30 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.26.0",
|
|
27
|
-
"@instructure/console": "10.16.1
|
|
28
|
-
"@instructure/emotion": "10.16.1
|
|
29
|
-
"@instructure/shared-types": "10.16.1
|
|
30
|
-
"@instructure/ui-buttons": "10.16.1
|
|
31
|
-
"@instructure/ui-dialog": "10.16.1
|
|
32
|
-
"@instructure/ui-dom-utils": "10.16.1
|
|
33
|
-
"@instructure/ui-motion": "10.16.1
|
|
34
|
-
"@instructure/ui-overlays": "10.16.1
|
|
35
|
-
"@instructure/ui-portal": "10.16.1
|
|
36
|
-
"@instructure/ui-prop-types": "10.16.1
|
|
37
|
-
"@instructure/ui-react-utils": "10.16.1
|
|
38
|
-
"@instructure/ui-testable": "10.16.1
|
|
39
|
-
"@instructure/ui-utils": "10.16.1
|
|
40
|
-
"@instructure/ui-view": "10.16.1
|
|
27
|
+
"@instructure/console": "10.16.1",
|
|
28
|
+
"@instructure/emotion": "10.16.1",
|
|
29
|
+
"@instructure/shared-types": "10.16.1",
|
|
30
|
+
"@instructure/ui-buttons": "10.16.1",
|
|
31
|
+
"@instructure/ui-dialog": "10.16.1",
|
|
32
|
+
"@instructure/ui-dom-utils": "10.16.1",
|
|
33
|
+
"@instructure/ui-motion": "10.16.1",
|
|
34
|
+
"@instructure/ui-overlays": "10.16.1",
|
|
35
|
+
"@instructure/ui-portal": "10.16.1",
|
|
36
|
+
"@instructure/ui-prop-types": "10.16.1",
|
|
37
|
+
"@instructure/ui-react-utils": "10.16.1",
|
|
38
|
+
"@instructure/ui-testable": "10.16.1",
|
|
39
|
+
"@instructure/ui-utils": "10.16.1",
|
|
40
|
+
"@instructure/ui-view": "10.16.1",
|
|
41
41
|
"prop-types": "^15.8.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=16.14 <=18"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@instructure/ui-babel-preset": "10.16.1
|
|
48
|
-
"@instructure/ui-color-utils": "10.16.1
|
|
49
|
-
"@instructure/ui-position": "10.16.1
|
|
50
|
-
"@instructure/ui-themes": "10.16.1
|
|
47
|
+
"@instructure/ui-babel-preset": "10.16.1",
|
|
48
|
+
"@instructure/ui-color-utils": "10.16.1",
|
|
49
|
+
"@instructure/ui-position": "10.16.1",
|
|
50
|
+
"@instructure/ui-themes": "10.16.1",
|
|
51
51
|
"@testing-library/jest-dom": "^6.6.3",
|
|
52
52
|
"@testing-library/react": "^16.0.1",
|
|
53
53
|
"@testing-library/user-event": "^14.5.2",
|