@instructure/ui-dialog 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 CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [10.16.1-snapshot-0](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-snapshot-0) (2025-04-15)
6
+ ## [10.16.1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1) (2025-04-22)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-dialog
9
9
 
@@ -24,12 +24,13 @@ var _button, _div, _div2, _DialogExample, _DialogExample2, _DialogExample3, _div
24
24
  * SOFTWARE.
25
25
  */
26
26
 
27
- import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
27
+ import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
28
28
  import { fireEvent, render, waitFor } from '@testing-library/react';
29
29
  import { vi } from 'vitest';
30
30
  import { userEvent } from '@testing-library/user-event';
31
31
  import '@testing-library/jest-dom';
32
32
  import { Dialog } from '../index';
33
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
33
34
  const TEST_TEXT = 'test-text';
34
35
  const TEST_LABEL = 'test-label';
35
36
  const renderDialog = props => {
@@ -38,7 +39,12 @@ const renderDialog = props => {
38
39
  label: TEST_LABEL,
39
40
  ...props
40
41
  };
41
- return render(/*#__PURE__*/React.createElement(Dialog, allProps, _button || (_button = /*#__PURE__*/React.createElement("button", null, TEST_TEXT))));
42
+ return render(_jsx(Dialog, {
43
+ ...allProps,
44
+ children: _button || (_button = _jsx("button", {
45
+ children: TEST_TEXT
46
+ }))
47
+ }));
42
48
  };
43
49
  const DialogExample = /*#__PURE__*/forwardRef((props, ref) => {
44
50
  const inputRef = useRef(null);
@@ -52,23 +58,28 @@ const DialogExample = /*#__PURE__*/forwardRef((props, ref) => {
52
58
  focusDialog: () => dialogRef.current.focus(),
53
59
  blurDialog: () => dialogRef.current.blur()
54
60
  }));
55
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", {
56
- "data-testid": "input-trigger",
57
- type: "text",
58
- ref: inputRef
59
- }), /*#__PURE__*/React.createElement(Dialog, Object.assign({
60
- shouldContainFocus: true,
61
- shouldReturnFocus: true,
62
- label: TEST_LABEL
63
- }, props, {
64
- ref: dialogRef
65
- }), props.children || _div || (_div = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", {
66
- type: "text",
67
- "data-testid": "input-one"
68
- }), /*#__PURE__*/React.createElement("input", {
69
- type: "text",
70
- "data-testid": "input-two"
71
- })))));
61
+ return _jsxs("div", {
62
+ children: [_jsx("input", {
63
+ "data-testid": "input-trigger",
64
+ type: "text",
65
+ ref: inputRef
66
+ }), _jsx(Dialog, {
67
+ shouldContainFocus: true,
68
+ shouldReturnFocus: true,
69
+ label: TEST_LABEL,
70
+ ...props,
71
+ ref: dialogRef,
72
+ children: props.children || _div || (_div = _jsxs("div", {
73
+ children: [_jsx("input", {
74
+ type: "text",
75
+ "data-testid": "input-one"
76
+ }), _jsx("input", {
77
+ type: "text",
78
+ "data-testid": "input-two"
79
+ })]
80
+ }))
81
+ })]
82
+ });
72
83
  });
73
84
  DialogExample.displayName = 'DialogExample';
74
85
  const NestedDialogExample = props => {
@@ -77,22 +88,31 @@ const NestedDialogExample = props => {
77
88
  nestedOpen = _useState2[0],
78
89
  setNestedOpen = _useState2[1];
79
90
  const handleTriggerClick = () => setNestedOpen(true);
80
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Dialog, Object.assign({
81
- open: true,
82
- shouldReturnFocus: true,
83
- label: TEST_LABEL
84
- }, props), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", {
85
- onClick: handleTriggerClick,
86
- type: "text",
87
- "data-testid": "nested-input-one"
88
- }), /*#__PURE__*/React.createElement("input", {
89
- onClick: handleTriggerClick,
90
- type: "text",
91
- "data-testid": "nested-input-two"
92
- })), /*#__PURE__*/React.createElement(Dialog, {
93
- open: nestedOpen,
94
- label: TEST_LABEL
95
- }, TEST_TEXT))));
91
+ return _jsx("div", {
92
+ children: _jsx(Dialog, {
93
+ open: true,
94
+ shouldReturnFocus: true,
95
+ label: TEST_LABEL,
96
+ ...props,
97
+ children: _jsxs("div", {
98
+ children: [_jsxs("div", {
99
+ children: [_jsx("input", {
100
+ onClick: handleTriggerClick,
101
+ type: "text",
102
+ "data-testid": "nested-input-one"
103
+ }), _jsx("input", {
104
+ onClick: handleTriggerClick,
105
+ type: "text",
106
+ "data-testid": "nested-input-two"
107
+ })]
108
+ }), _jsx(Dialog, {
109
+ open: nestedOpen,
110
+ label: TEST_LABEL,
111
+ children: TEST_TEXT
112
+ })]
113
+ })
114
+ })
115
+ });
96
116
  };
97
117
  NestedDialogExample.displayName = 'NestedDialogExample';
98
118
  describe('<Dialog />', () => {
@@ -164,13 +184,17 @@ describe('<Dialog />', () => {
164
184
  });
165
185
  describe('managed focus', () => {
166
186
  it('should provide focus method', async () => {
167
- const _render = render(/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DialogExample, {
168
- open: true,
169
- contentElement: () => getByTestId('non-tabbable')
170
- }, TEST_TEXT), _div2 || (_div2 = /*#__PURE__*/React.createElement("div", {
171
- tabIndex: -1,
172
- "data-testid": "non-tabbable"
173
- }, TEST_TEXT)))),
187
+ const _render = render(_jsxs("div", {
188
+ children: [_jsx(DialogExample, {
189
+ open: true,
190
+ contentElement: () => getByTestId('non-tabbable'),
191
+ children: TEST_TEXT
192
+ }), _div2 || (_div2 = _jsx("div", {
193
+ tabIndex: -1,
194
+ "data-testid": "non-tabbable",
195
+ children: TEST_TEXT
196
+ }))]
197
+ })),
174
198
  getByTestId = _render.getByTestId;
175
199
  const nonTabbableContent = getByTestId('non-tabbable');
176
200
  userEvent.tab();
@@ -181,7 +205,7 @@ describe('<Dialog />', () => {
181
205
  it('should warn when trying to focus or blur a closed dialog', () => {
182
206
  const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {});
183
207
  let ref;
184
- render(/*#__PURE__*/React.createElement(DialogExample, {
208
+ render(_jsx(DialogExample, {
185
209
  open: false,
186
210
  ref: el => ref = el
187
211
  }));
@@ -192,7 +216,7 @@ describe('<Dialog />', () => {
192
216
  consoleError.mockRestore();
193
217
  });
194
218
  it('should focus the first tabbable element by default', async () => {
195
- const _render2 = render(_DialogExample || (_DialogExample = /*#__PURE__*/React.createElement(DialogExample, {
219
+ const _render2 = render(_DialogExample || (_DialogExample = _jsx(DialogExample, {
196
220
  open: true
197
221
  }))),
198
222
  getByTestId = _render2.getByTestId;
@@ -202,7 +226,7 @@ describe('<Dialog />', () => {
202
226
  });
203
227
  });
204
228
  it('should focus the first tabbable element when open prop becomes true', async () => {
205
- const _render3 = render(_DialogExample2 || (_DialogExample2 = /*#__PURE__*/React.createElement(DialogExample, {
229
+ const _render3 = render(_DialogExample2 || (_DialogExample2 = _jsx(DialogExample, {
206
230
  open: false
207
231
  }))),
208
232
  rerender = _render3.rerender,
@@ -211,7 +235,7 @@ describe('<Dialog />', () => {
211
235
  await waitFor(() => {
212
236
  expect(document.activeElement).toBe(inputTrigger);
213
237
  });
214
- rerender(_DialogExample3 || (_DialogExample3 = /*#__PURE__*/React.createElement(DialogExample, {
238
+ rerender(_DialogExample3 || (_DialogExample3 = _jsx(DialogExample, {
215
239
  open: true
216
240
  })));
217
241
  const inputOne = getByTestId('input-one');
@@ -220,7 +244,7 @@ describe('<Dialog />', () => {
220
244
  });
221
245
  });
222
246
  it('should take a prop for finding default focus', async () => {
223
- const _render4 = render(/*#__PURE__*/React.createElement(DialogExample, {
247
+ const _render4 = render(_jsx(DialogExample, {
224
248
  open: true,
225
249
  defaultFocusElement: () => getByTestId('input-two')
226
250
  })),
@@ -231,13 +255,15 @@ describe('<Dialog />', () => {
231
255
  });
232
256
  });
233
257
  it('should still focus the defaultFocusElement when it is focusable but not tabbable', async () => {
234
- const _render5 = render(/*#__PURE__*/React.createElement(DialogExample, {
258
+ const _render5 = render(_jsx(DialogExample, {
235
259
  open: true,
236
- defaultFocusElement: () => getByTestId('non-tabbable')
237
- }, _div3 || (_div3 = /*#__PURE__*/React.createElement("div", {
238
- tabIndex: -1,
239
- "data-testid": "non-tabbable"
240
- }, TEST_TEXT)))),
260
+ defaultFocusElement: () => getByTestId('non-tabbable'),
261
+ children: _div3 || (_div3 = _jsx("div", {
262
+ tabIndex: -1,
263
+ "data-testid": "non-tabbable",
264
+ children: TEST_TEXT
265
+ }))
266
+ })),
241
267
  getByTestId = _render5.getByTestId;
242
268
  const nonTabbableContent = getByTestId('non-tabbable');
243
269
  await waitFor(() => {
@@ -245,13 +271,17 @@ describe('<Dialog />', () => {
245
271
  });
246
272
  });
247
273
  it('should focus the contentElement by default if focusable and no defaultFocusElement is provided', async () => {
248
- const _render6 = render(/*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(DialogExample, {
249
- open: true,
250
- contentElement: () => getByTestId('non-tabbable')
251
- }, TEST_TEXT), _div4 || (_div4 = /*#__PURE__*/React.createElement("div", {
252
- tabIndex: -1,
253
- "data-testid": "non-tabbable"
254
- }, TEST_TEXT)))),
274
+ const _render6 = render(_jsxs("div", {
275
+ children: [_jsx(DialogExample, {
276
+ open: true,
277
+ contentElement: () => getByTestId('non-tabbable'),
278
+ children: TEST_TEXT
279
+ }), _div4 || (_div4 = _jsx("div", {
280
+ tabIndex: -1,
281
+ "data-testid": "non-tabbable",
282
+ children: TEST_TEXT
283
+ }))]
284
+ })),
255
285
  getByTestId = _render6.getByTestId;
256
286
  const nonTabbableContent = getByTestId('non-tabbable');
257
287
  await waitFor(() => {
@@ -259,34 +289,36 @@ describe('<Dialog />', () => {
259
289
  });
260
290
  });
261
291
  it('should focus the document body if there is no defaultFocusElement, tabbable elements, or focusable contentElement', async () => {
262
- const _render7 = render(_DialogExample4 || (_DialogExample4 = /*#__PURE__*/React.createElement(DialogExample, {
263
- open: false
264
- }, TEST_TEXT))),
292
+ const _render7 = render(_DialogExample4 || (_DialogExample4 = _jsx(DialogExample, {
293
+ open: false,
294
+ children: TEST_TEXT
295
+ }))),
265
296
  rerender = _render7.rerender,
266
297
  getByTestId = _render7.getByTestId;
267
298
  const inputTrigger = getByTestId('input-trigger');
268
299
  inputTrigger.focus();
269
- rerender(_DialogExample5 || (_DialogExample5 = /*#__PURE__*/React.createElement(DialogExample, {
270
- open: true
271
- }, TEST_TEXT)));
300
+ rerender(_DialogExample5 || (_DialogExample5 = _jsx(DialogExample, {
301
+ open: true,
302
+ children: TEST_TEXT
303
+ })));
272
304
  await waitFor(() => {
273
305
  expect(document.activeElement).toBe(document.body);
274
306
  });
275
307
  });
276
308
  it('should return focus', async () => {
277
- const _render8 = render(_DialogExample6 || (_DialogExample6 = /*#__PURE__*/React.createElement(DialogExample, {
309
+ const _render8 = render(_DialogExample6 || (_DialogExample6 = _jsx(DialogExample, {
278
310
  open: false
279
311
  }))),
280
312
  rerender = _render8.rerender,
281
313
  getByTestId = _render8.getByTestId;
282
314
  expect(document.activeElement).toBe(getByTestId('input-trigger'));
283
- rerender(_DialogExample7 || (_DialogExample7 = /*#__PURE__*/React.createElement(DialogExample, {
315
+ rerender(_DialogExample7 || (_DialogExample7 = _jsx(DialogExample, {
284
316
  open: true
285
317
  })));
286
318
  await waitFor(() => {
287
319
  expect(document.activeElement).toBe(getByTestId('input-one'));
288
320
  });
289
- rerender(_DialogExample8 || (_DialogExample8 = /*#__PURE__*/React.createElement(DialogExample, {
321
+ rerender(_DialogExample8 || (_DialogExample8 = _jsx(DialogExample, {
290
322
  open: false
291
323
  })));
292
324
  await waitFor(() => {
@@ -296,7 +328,7 @@ describe('<Dialog />', () => {
296
328
  describe('when focus leaves the first and last tabbable', () => {
297
329
  it(`should NOT call onBlur when shouldContainFocus=true and tab pressing last tabbable`, async () => {
298
330
  const onBlur = vi.fn();
299
- const _render9 = render(/*#__PURE__*/React.createElement(DialogExample, {
331
+ const _render9 = render(_jsx(DialogExample, {
300
332
  open: true,
301
333
  onBlur: onBlur,
302
334
  shouldContainFocus: true,
@@ -316,7 +348,7 @@ describe('<Dialog />', () => {
316
348
  });
317
349
  it('should NOT call onBlur when shouldContainFocus=true and Shift+Tab pressing first tabbable', async () => {
318
350
  const onBlur = vi.fn();
319
- const _render10 = render(/*#__PURE__*/React.createElement(DialogExample, {
351
+ const _render10 = render(_jsx(DialogExample, {
320
352
  open: true,
321
353
  shouldContainFocus: true,
322
354
  defaultFocusElement: () => getByTestId('input-one'),
@@ -340,7 +372,7 @@ describe('<Dialog />', () => {
340
372
  });
341
373
  it('should call onBlur when shouldContainFocus=false and tab pressing last tabbable', async () => {
342
374
  const onBlur = vi.fn();
343
- const _render11 = render(/*#__PURE__*/React.createElement(DialogExample, {
375
+ const _render11 = render(_jsx(DialogExample, {
344
376
  open: true,
345
377
  shouldContainFocus: false,
346
378
  defaultFocusElement: () => getByTestId('input-two'),
@@ -362,7 +394,7 @@ describe('<Dialog />', () => {
362
394
  });
363
395
  it('should call onBlur when shouldContainFocus=false and pressing Shift+Tab on the first tabbable', async () => {
364
396
  const onBlur = vi.fn();
365
- const _render12 = render(/*#__PURE__*/React.createElement(DialogExample, {
397
+ const _render12 = render(_jsx(DialogExample, {
366
398
  open: true,
367
399
  shouldContainFocus: false,
368
400
  defaultFocusElement: () => getByTestId('input-one'),
@@ -25,12 +25,13 @@ const _excluded = ["open", "contentElement"],
25
25
  * SOFTWARE.
26
26
  */
27
27
 
28
- import React, { Component } from 'react';
28
+ import { Component } from 'react';
29
29
  import { omitProps, getElementType } from '@instructure/ui-react-utils';
30
30
  import { findDOMNode, requestAnimationFrame } from '@instructure/ui-dom-utils';
31
31
  import { logError as error } from '@instructure/console';
32
32
  import { FocusRegionManager } from '@instructure/ui-a11y-utils';
33
33
  import { propTypes, allowedProps } from './props';
34
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
34
35
  /**
35
36
  ---
36
37
  category: components/utilities
@@ -130,12 +131,14 @@ class Dialog extends Component {
130
131
 
131
132
  // In case the HTML role attribute is explicitly passed, use props.role
132
133
  const role = this.props.role || (this.props.label ? 'dialog' : void 0);
133
- return this.props.open ? /*#__PURE__*/React.createElement(ElementType, Object.assign({}, omitProps(this.props, Dialog.allowedProps), {
134
+ return this.props.open ? _jsx(ElementType, {
135
+ ...omitProps(this.props, Dialog.allowedProps),
134
136
  role: role,
135
137
  "aria-label": this.props.label,
136
138
  className: this.props.className,
137
- ref: this.getRef
138
- }), this.props.children) : null;
139
+ ref: this.getRef,
140
+ children: this.props.children
141
+ }) : null;
139
142
  }
140
143
  }
141
144
  Dialog.displayName = "Dialog";