@instructure/ui-popover 10.16.1-snapshot-0 → 10.16.1-snapshot-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/Popover/__new-tests__/Popover.test.js +102 -39
- package/es/Popover/index.js +28 -16
- package/lib/Popover/__new-tests__/Popover.test.js +134 -71
- package/lib/Popover/index.js +28 -17
- package/package.json +20 -20
- package/src/Popover/__new-tests__/Popover.test.tsx +0 -1
- package/src/Popover/index.tsx +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Popover/__new-tests__/Popover.test.d.ts.map +1 -1
- package/types/Popover/index.d.ts +4 -4
- package/types/Popover/index.d.ts.map +1 -1
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-
|
|
6
|
+
## [10.16.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-snapshot-1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-popover
|
|
9
9
|
|
|
@@ -23,11 +23,11 @@ var _button, _h, _button2, _h2, _div, _button3, _h3, _Popover, _Popover2, _Popov
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { vi } from 'vitest';
|
|
28
27
|
import { fireEvent, render, screen, cleanup } from '@testing-library/react';
|
|
29
28
|
import '@testing-library/jest-dom';
|
|
30
29
|
import Popover from '../index';
|
|
30
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
31
31
|
describe('<Popover />', () => {
|
|
32
32
|
afterEach(() => {
|
|
33
33
|
cleanup();
|
|
@@ -38,10 +38,15 @@ describe('<Popover />', () => {
|
|
|
38
38
|
if (on === 'hover') {
|
|
39
39
|
onValue.push('focus');
|
|
40
40
|
}
|
|
41
|
-
render(
|
|
41
|
+
render(_jsx(Popover, {
|
|
42
42
|
on: onValue,
|
|
43
|
-
renderTrigger: _button || (_button =
|
|
44
|
-
|
|
43
|
+
renderTrigger: _button || (_button = _jsx("button", {
|
|
44
|
+
children: "Trigger"
|
|
45
|
+
})),
|
|
46
|
+
children: _h || (_h = _jsx("h2", {
|
|
47
|
+
children: "Popover Content"
|
|
48
|
+
}))
|
|
49
|
+
}));
|
|
45
50
|
const trigger = screen.getByRole('button', {
|
|
46
51
|
name: 'Trigger'
|
|
47
52
|
});
|
|
@@ -67,9 +72,15 @@ describe('<Popover />', () => {
|
|
|
67
72
|
const props = {
|
|
68
73
|
[handler]: handlerSpy
|
|
69
74
|
};
|
|
70
|
-
render(
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
render(_jsx(Popover, {
|
|
76
|
+
...props,
|
|
77
|
+
renderTrigger: _button2 || (_button2 = _jsx("button", {
|
|
78
|
+
children: "Trigger"
|
|
79
|
+
})),
|
|
80
|
+
children: _h2 || (_h2 = _jsx("h2", {
|
|
81
|
+
children: "Popover content"
|
|
82
|
+
}))
|
|
83
|
+
}));
|
|
73
84
|
const trigger = screen.getByRole('button', {
|
|
74
85
|
name: 'Trigger'
|
|
75
86
|
});
|
|
@@ -93,10 +104,17 @@ describe('<Popover />', () => {
|
|
|
93
104
|
});
|
|
94
105
|
}
|
|
95
106
|
it('should not render content by default', () => {
|
|
96
|
-
render(_div || (_div =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
render(_div || (_div = _jsx("div", {
|
|
108
|
+
children: _jsx(Popover, {
|
|
109
|
+
on: "click",
|
|
110
|
+
renderTrigger: _jsx("button", {
|
|
111
|
+
children: "Trigger button"
|
|
112
|
+
}),
|
|
113
|
+
children: _jsx("h2", {
|
|
114
|
+
children: "Popover Title"
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
})));
|
|
100
118
|
const triggerButton = screen.getByRole('button', {
|
|
101
119
|
name: 'Trigger button'
|
|
102
120
|
});
|
|
@@ -117,12 +135,17 @@ describe('<Popover />', () => {
|
|
|
117
135
|
});
|
|
118
136
|
it('should hide content when trigger is clicked', () => {
|
|
119
137
|
const onHideContent = vi.fn();
|
|
120
|
-
render(
|
|
138
|
+
render(_jsx(Popover, {
|
|
121
139
|
on: "click",
|
|
122
140
|
onHideContent: (_e, o) => onHideContent(o),
|
|
123
141
|
shouldCloseOnDocumentClick: false,
|
|
124
|
-
renderTrigger: _button3 || (_button3 =
|
|
125
|
-
|
|
142
|
+
renderTrigger: _button3 || (_button3 = _jsx("button", {
|
|
143
|
+
children: "Trigger button"
|
|
144
|
+
})),
|
|
145
|
+
children: _h3 || (_h3 = _jsx("h2", {
|
|
146
|
+
children: "Popover Title"
|
|
147
|
+
}))
|
|
148
|
+
}));
|
|
126
149
|
const triggerButton = screen.getByRole('button', {
|
|
127
150
|
name: 'Trigger button'
|
|
128
151
|
});
|
|
@@ -139,30 +162,45 @@ describe('<Popover />', () => {
|
|
|
139
162
|
expect(screen.queryByText('Popover Title')).not.toBeInTheDocument();
|
|
140
163
|
});
|
|
141
164
|
it('should show content if defaultIsShowingContent is true', () => {
|
|
142
|
-
render(_Popover || (_Popover =
|
|
165
|
+
render(_Popover || (_Popover = _jsx(Popover, {
|
|
143
166
|
on: "click",
|
|
144
167
|
defaultIsShowingContent: true,
|
|
145
|
-
renderTrigger:
|
|
146
|
-
|
|
168
|
+
renderTrigger: _jsx("button", {
|
|
169
|
+
children: "Trigger"
|
|
170
|
+
}),
|
|
171
|
+
children: _jsx("h2", {
|
|
172
|
+
children: "Popover content"
|
|
173
|
+
})
|
|
174
|
+
})));
|
|
147
175
|
const popoverContent = screen.queryByText('Popover content');
|
|
148
176
|
expect(popoverContent).toBeInTheDocument();
|
|
149
177
|
});
|
|
150
178
|
describe('controlled', () => {
|
|
151
179
|
it('should show content by default if isShowingContent is true', () => {
|
|
152
|
-
render(_Popover2 || (_Popover2 =
|
|
180
|
+
render(_Popover2 || (_Popover2 = _jsx(Popover, {
|
|
153
181
|
on: "click",
|
|
154
182
|
isShowingContent: true,
|
|
155
|
-
renderTrigger:
|
|
156
|
-
|
|
183
|
+
renderTrigger: _jsx("button", {
|
|
184
|
+
children: "Trigger"
|
|
185
|
+
}),
|
|
186
|
+
children: _jsx("h2", {
|
|
187
|
+
children: "Popover content"
|
|
188
|
+
})
|
|
189
|
+
})));
|
|
157
190
|
const popoverContent = screen.queryByText('Popover content');
|
|
158
191
|
expect(popoverContent).toBeInTheDocument();
|
|
159
192
|
});
|
|
160
193
|
it('should not show content if isShowingContent prop is false', () => {
|
|
161
|
-
render(_Popover3 || (_Popover3 =
|
|
194
|
+
render(_Popover3 || (_Popover3 = _jsx(Popover, {
|
|
162
195
|
on: "click",
|
|
163
196
|
isShowingContent: false,
|
|
164
|
-
renderTrigger:
|
|
165
|
-
|
|
197
|
+
renderTrigger: _jsx("button", {
|
|
198
|
+
children: "Trigger"
|
|
199
|
+
}),
|
|
200
|
+
children: _jsx("h2", {
|
|
201
|
+
children: "Popover content"
|
|
202
|
+
})
|
|
203
|
+
})));
|
|
166
204
|
const triggerButton = screen.getByRole('button', {
|
|
167
205
|
name: 'Trigger'
|
|
168
206
|
});
|
|
@@ -171,23 +209,33 @@ describe('<Popover />', () => {
|
|
|
171
209
|
expect(popoverContent).not.toBeInTheDocument();
|
|
172
210
|
});
|
|
173
211
|
it('should show content if isShowingContent prop is true', () => {
|
|
174
|
-
render(_Popover4 || (_Popover4 =
|
|
212
|
+
render(_Popover4 || (_Popover4 = _jsx(Popover, {
|
|
175
213
|
on: "click",
|
|
176
214
|
isShowingContent: true,
|
|
177
|
-
renderTrigger:
|
|
178
|
-
|
|
215
|
+
renderTrigger: _jsx("button", {
|
|
216
|
+
children: "Trigger"
|
|
217
|
+
}),
|
|
218
|
+
children: _jsx("h2", {
|
|
219
|
+
children: "Popover content"
|
|
220
|
+
})
|
|
221
|
+
})));
|
|
179
222
|
const popoverContent = screen.queryByText('Popover content');
|
|
180
223
|
expect(popoverContent).toBeInTheDocument();
|
|
181
224
|
});
|
|
182
225
|
it('should call onShowContent', () => {
|
|
183
226
|
const onShowContent = vi.fn();
|
|
184
|
-
render(
|
|
227
|
+
render(_jsx(Popover, {
|
|
185
228
|
on: "click",
|
|
186
229
|
isShowingContent: false,
|
|
187
230
|
shouldCloseOnDocumentClick: false,
|
|
188
231
|
onShowContent: onShowContent,
|
|
189
|
-
renderTrigger: _button4 || (_button4 =
|
|
190
|
-
|
|
232
|
+
renderTrigger: _button4 || (_button4 = _jsx("button", {
|
|
233
|
+
children: "Trigger"
|
|
234
|
+
})),
|
|
235
|
+
children: _h4 || (_h4 = _jsx("h2", {
|
|
236
|
+
children: "Popover content"
|
|
237
|
+
}))
|
|
238
|
+
}));
|
|
191
239
|
const trigger = screen.getByRole('button', {
|
|
192
240
|
name: 'Trigger'
|
|
193
241
|
});
|
|
@@ -196,13 +244,18 @@ describe('<Popover />', () => {
|
|
|
196
244
|
});
|
|
197
245
|
it('should call onHideContent', () => {
|
|
198
246
|
const onHideContent = vi.fn();
|
|
199
|
-
render(
|
|
247
|
+
render(_jsx(Popover, {
|
|
200
248
|
on: "click",
|
|
201
249
|
isShowingContent: true,
|
|
202
250
|
shouldCloseOnDocumentClick: false,
|
|
203
251
|
onHideContent: (_e, o) => onHideContent(o),
|
|
204
|
-
renderTrigger: _button5 || (_button5 =
|
|
205
|
-
|
|
252
|
+
renderTrigger: _button5 || (_button5 = _jsx("button", {
|
|
253
|
+
children: "Trigger"
|
|
254
|
+
})),
|
|
255
|
+
children: _h5 || (_h5 = _jsx("h2", {
|
|
256
|
+
children: "Popover content"
|
|
257
|
+
}))
|
|
258
|
+
}));
|
|
206
259
|
const trigger = screen.getByRole('button', {
|
|
207
260
|
name: 'Trigger'
|
|
208
261
|
});
|
|
@@ -212,11 +265,16 @@ describe('<Popover />', () => {
|
|
|
212
265
|
});
|
|
213
266
|
});
|
|
214
267
|
it('should not show content on click', () => {
|
|
215
|
-
render(_Popover5 || (_Popover5 =
|
|
268
|
+
render(_Popover5 || (_Popover5 = _jsx(Popover, {
|
|
216
269
|
on: "click",
|
|
217
270
|
isShowingContent: false,
|
|
218
|
-
renderTrigger:
|
|
219
|
-
|
|
271
|
+
renderTrigger: _jsx("button", {
|
|
272
|
+
children: "Trigger"
|
|
273
|
+
}),
|
|
274
|
+
children: _jsx("h2", {
|
|
275
|
+
children: "Popover content"
|
|
276
|
+
})
|
|
277
|
+
})));
|
|
220
278
|
const triggerButton = screen.getByRole('button', {
|
|
221
279
|
name: 'Trigger'
|
|
222
280
|
});
|
|
@@ -226,11 +284,16 @@ describe('<Popover />', () => {
|
|
|
226
284
|
});
|
|
227
285
|
});
|
|
228
286
|
it('should pass positionContainerDisplay prop to Position', () => {
|
|
229
|
-
render(_Popover6 || (_Popover6 =
|
|
287
|
+
render(_Popover6 || (_Popover6 = _jsx(Popover, {
|
|
230
288
|
on: "click",
|
|
231
|
-
renderTrigger:
|
|
232
|
-
|
|
233
|
-
|
|
289
|
+
renderTrigger: _jsx("button", {
|
|
290
|
+
children: "Trigger"
|
|
291
|
+
}),
|
|
292
|
+
positionContainerDisplay: "block",
|
|
293
|
+
children: _jsx("h2", {
|
|
294
|
+
children: "Popover content"
|
|
295
|
+
})
|
|
296
|
+
})));
|
|
234
297
|
const popover = document.querySelector('[data-position^="Popover_"]');
|
|
235
298
|
expect(popover).toHaveStyle('display: block');
|
|
236
299
|
});
|
package/es/Popover/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var _dec, _dec2, _dec3, _dec4, _class, _Popover;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import
|
|
26
|
+
import { Component } from 'react';
|
|
27
27
|
import keycode from 'keycode';
|
|
28
28
|
import { Position, parsePlacement, mirrorHorizontalPlacement } from '@instructure/ui-position';
|
|
29
29
|
import { ContextView, View } from '@instructure/ui-view';
|
|
@@ -39,6 +39,7 @@ import { withStyle } from '@instructure/emotion';
|
|
|
39
39
|
import generateStyle from './styles';
|
|
40
40
|
import generateComponentTheme from './theme';
|
|
41
41
|
import { allowedProps, propTypes } from './props';
|
|
42
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
42
43
|
/**
|
|
43
44
|
---
|
|
44
45
|
category: components
|
|
@@ -375,7 +376,7 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
375
376
|
if (this.shown && !this.isTooltip) {
|
|
376
377
|
// if popover is NOT being used as a tooltip, create a Dialog
|
|
377
378
|
// to manage the content FocusRegion, when showing
|
|
378
|
-
content =
|
|
379
|
+
content = _jsx(Dialog, {
|
|
379
380
|
open: this.shown,
|
|
380
381
|
label: this.props.screenReaderLabel,
|
|
381
382
|
ref: el => this._dialog = el,
|
|
@@ -388,8 +389,9 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
388
389
|
shouldReturnFocus: this.props.shouldReturnFocus,
|
|
389
390
|
shouldFocusOnOpen: !this.props.shouldFocusContentOnTriggerBlur,
|
|
390
391
|
shouldCloseOnDocumentClick: this.props.shouldCloseOnDocumentClick,
|
|
391
|
-
shouldCloseOnEscape: this.props.shouldCloseOnEscape
|
|
392
|
-
|
|
392
|
+
shouldCloseOnEscape: this.props.shouldCloseOnEscape,
|
|
393
|
+
children: content
|
|
394
|
+
});
|
|
393
395
|
}
|
|
394
396
|
if (this.shown || this.props.shouldRenderOffscreen) {
|
|
395
397
|
const color = this.props.color;
|
|
@@ -423,9 +425,11 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
423
425
|
background: color === 'primary' ? 'default' : 'inverse',
|
|
424
426
|
placement: this.props.dir === textDirectionContextConsumer.DIRECTION.rtl ? mirrorHorizontalPlacement(placement, ' ') : placement
|
|
425
427
|
};
|
|
426
|
-
return
|
|
427
|
-
|
|
428
|
-
|
|
428
|
+
return _jsx(ContextView, {
|
|
429
|
+
...viewProps,
|
|
430
|
+
borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
|
|
431
|
+
children: content
|
|
432
|
+
});
|
|
429
433
|
} else {
|
|
430
434
|
viewProps = {
|
|
431
435
|
...viewProps,
|
|
@@ -435,9 +439,11 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
435
439
|
borderColor: 'transparent'
|
|
436
440
|
})
|
|
437
441
|
};
|
|
438
|
-
return
|
|
439
|
-
|
|
440
|
-
|
|
442
|
+
return _jsx(View, {
|
|
443
|
+
...viewProps,
|
|
444
|
+
borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
|
|
445
|
+
children: content
|
|
446
|
+
});
|
|
441
447
|
}
|
|
442
448
|
} else {
|
|
443
449
|
return null;
|
|
@@ -446,14 +452,20 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
446
452
|
render() {
|
|
447
453
|
const positionProps = this.positionProps;
|
|
448
454
|
if (this.props.positionTarget) {
|
|
449
|
-
return
|
|
450
|
-
ref: this.handleRef
|
|
451
|
-
|
|
455
|
+
return _jsxs("span", {
|
|
456
|
+
ref: this.handleRef,
|
|
457
|
+
children: [this.renderTrigger(), _jsx(Position, {
|
|
458
|
+
...positionProps,
|
|
459
|
+
children: this.renderContent()
|
|
460
|
+
})]
|
|
461
|
+
});
|
|
452
462
|
} else {
|
|
453
|
-
return
|
|
463
|
+
return _jsx(Position, {
|
|
464
|
+
...positionProps,
|
|
454
465
|
renderTarget: this.renderTrigger(),
|
|
455
|
-
elementRef: this.handleRef
|
|
456
|
-
|
|
466
|
+
elementRef: this.handleRef,
|
|
467
|
+
children: this.renderContent()
|
|
468
|
+
});
|
|
457
469
|
}
|
|
458
470
|
}
|
|
459
471
|
}, _Popover.displayName = "Popover", _Popover.componentId = 'Popover', _Popover.allowedProps = allowedProps, _Popover.propTypes = propTypes, _Popover.defaultProps = {
|