@instructure/ui-popover 8.33.1 → 8.33.2-snapshot-5
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 +8 -0
- package/es/Popover/PopoverLocator.js +5 -4
- package/es/Popover/PopoverTriggerLocator.js +1 -0
- package/es/Popover/index.js +26 -88
- package/es/Popover/locator.js +1 -0
- package/es/Popover/props.js +1 -0
- package/lib/Popover/PopoverLocator.js +2 -5
- package/lib/Popover/PopoverTriggerLocator.js +1 -2
- package/lib/Popover/index.js +24 -113
- package/lib/Popover/locator.js +0 -2
- package/lib/Popover/props.js +1 -6
- package/lib/index.js +0 -1
- package/package.json +19 -19
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [8.33.2-snapshot-5](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2-snapshot-5) (2023-01-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-popover
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-popover
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
import { locator } from '@instructure/ui-test-locator'; // @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
|
|
25
|
-
// eslint-disable-next-line no-restricted-imports
|
|
26
24
|
|
|
25
|
+
import { locator } from '@instructure/ui-test-locator';
|
|
26
|
+
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
|
|
27
|
+
// eslint-disable-next-line no-restricted-imports
|
|
27
28
|
import { PositionLocator } from '@instructure/ui-position/es/Position/PositionLocator';
|
|
28
29
|
import { Popover } from './index';
|
|
29
30
|
import { PopoverTriggerLocator } from './PopoverTriggerLocator';
|
|
@@ -38,6 +39,6 @@ export const customMethods = {
|
|
|
38
39
|
return PopoverTriggerLocator.find(...arguments);
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
|
-
export { PopoverTriggerLocator };
|
|
42
|
-
|
|
42
|
+
export { PopoverTriggerLocator };
|
|
43
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
43
44
|
export const PopoverLocator = locator(Popover.selector, customMethods);
|
package/es/Popover/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _dec3, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -23,6 +22,7 @@ var _dec, _dec2, _dec3, _class, _class2;
|
|
|
23
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
23
|
* SOFTWARE.
|
|
25
24
|
*/
|
|
25
|
+
|
|
26
26
|
import React, { Component } from 'react';
|
|
27
27
|
import keycode from 'keycode';
|
|
28
28
|
import { Position, parsePlacement, mirrorHorizontalPlacement } from '@instructure/ui-position';
|
|
@@ -36,6 +36,7 @@ import { logError as error } from '@instructure/console';
|
|
|
36
36
|
import { testable } from '@instructure/ui-testable';
|
|
37
37
|
import { FocusRegion } from '@instructure/ui-a11y-utils';
|
|
38
38
|
import { allowedProps, propTypes } from './props';
|
|
39
|
+
|
|
39
40
|
/**
|
|
40
41
|
---
|
|
41
42
|
category: components
|
|
@@ -43,11 +44,9 @@ tags: overlay, portal, dialog
|
|
|
43
44
|
---
|
|
44
45
|
@tsProps
|
|
45
46
|
**/
|
|
46
|
-
|
|
47
47
|
let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsumer(), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Popover extends Component {
|
|
48
48
|
constructor(props) {
|
|
49
49
|
var _this;
|
|
50
|
-
|
|
51
50
|
super(props);
|
|
52
51
|
_this = this;
|
|
53
52
|
this._handleMouseOver = void 0;
|
|
@@ -61,45 +60,36 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
61
60
|
this._focusRegion = void 0;
|
|
62
61
|
this.mouseOutTimeout = void 0;
|
|
63
62
|
this.ref = null;
|
|
64
|
-
|
|
65
63
|
this.handleRef = el => {
|
|
66
64
|
const elementRef = this.props.elementRef;
|
|
67
65
|
this.ref = el;
|
|
68
|
-
|
|
69
66
|
if (typeof elementRef === 'function') {
|
|
70
67
|
elementRef(el);
|
|
71
68
|
}
|
|
72
69
|
};
|
|
73
|
-
|
|
74
70
|
this.show = event => {
|
|
75
71
|
var _this$props$onShowCon, _this$props;
|
|
76
|
-
|
|
77
72
|
if (typeof this.props.isShowingContent === 'undefined') {
|
|
78
73
|
this.setState({
|
|
79
74
|
isShowingContent: true
|
|
80
75
|
});
|
|
81
76
|
}
|
|
82
|
-
|
|
83
77
|
(_this$props$onShowCon = (_this$props = this.props).onShowContent) === null || _this$props$onShowCon === void 0 ? void 0 : _this$props$onShowCon.call(_this$props, event);
|
|
84
78
|
};
|
|
85
|
-
|
|
86
79
|
this.hide = function (event) {
|
|
87
80
|
let documentClick = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
88
81
|
const _this$props2 = _this.props,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
onHideContent = _this$props2.onHideContent,
|
|
83
|
+
isShowingContent = _this$props2.isShowingContent;
|
|
92
84
|
if (typeof isShowingContent === 'undefined') {
|
|
93
85
|
// uncontrolled, set state, fire callbacks
|
|
94
86
|
_this.setState(_ref => {
|
|
95
87
|
let isShowingContent = _ref.isShowingContent;
|
|
96
|
-
|
|
97
88
|
if (isShowingContent) {
|
|
98
89
|
onHideContent === null || onHideContent === void 0 ? void 0 : onHideContent(event, {
|
|
99
90
|
documentClick
|
|
100
91
|
});
|
|
101
92
|
}
|
|
102
|
-
|
|
103
93
|
return {
|
|
104
94
|
isShowingContent: false
|
|
105
95
|
};
|
|
@@ -111,7 +101,6 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
111
101
|
});
|
|
112
102
|
}
|
|
113
103
|
};
|
|
114
|
-
|
|
115
104
|
this.toggle = event => {
|
|
116
105
|
if (this.shown) {
|
|
117
106
|
this.hide(event);
|
|
@@ -119,42 +108,33 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
119
108
|
this.show(event);
|
|
120
109
|
}
|
|
121
110
|
};
|
|
122
|
-
|
|
123
111
|
this.handleDialogDismiss = (event, documentClick) => {
|
|
124
112
|
if (!this.props.shouldReturnFocus && this.props.shouldFocusContentOnTriggerBlur) {
|
|
125
113
|
const trigger = findDOMNode(this._trigger);
|
|
126
|
-
|
|
127
114
|
if (trigger && typeof trigger.focus === 'function') {
|
|
128
115
|
;
|
|
129
116
|
trigger.focus();
|
|
130
117
|
}
|
|
131
118
|
}
|
|
132
|
-
|
|
133
119
|
this.hide(event, documentClick);
|
|
134
120
|
};
|
|
135
|
-
|
|
136
121
|
this.handleDialogBlur = event => {
|
|
137
122
|
if (event.keyCode === keycode.codes.tab && event.shiftKey && this.props.shouldFocusContentOnTriggerBlur) {
|
|
138
123
|
return;
|
|
139
124
|
}
|
|
140
|
-
|
|
141
125
|
this.hide(event);
|
|
142
126
|
};
|
|
143
|
-
|
|
144
127
|
this.handleTriggerKeyDown = event => {
|
|
145
128
|
if (!this.props.shouldFocusContentOnTriggerBlur) {
|
|
146
129
|
return;
|
|
147
130
|
}
|
|
148
|
-
|
|
149
131
|
if (event.keyCode === keycode.codes.tab && !event.shiftKey) {
|
|
150
132
|
event.preventDefault();
|
|
151
|
-
|
|
152
133
|
this._raf.push(requestAnimationFrame(() => {
|
|
153
134
|
this._dialog && this._dialog.focus();
|
|
154
135
|
}));
|
|
155
136
|
}
|
|
156
137
|
};
|
|
157
|
-
|
|
158
138
|
this.handleTriggerKeyUp = event => {
|
|
159
139
|
if (event.keyCode === keycode.codes.esc && this.shown && this.isTooltip) {
|
|
160
140
|
// if popover is tooltip, it is managing its own focus region so we need
|
|
@@ -163,10 +143,8 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
163
143
|
this.hide(event);
|
|
164
144
|
}
|
|
165
145
|
};
|
|
166
|
-
|
|
167
146
|
this.handleTriggerBlur = event => {
|
|
168
147
|
const on = this.props.on;
|
|
169
|
-
|
|
170
148
|
if (on && on.indexOf('focus') > -1) {
|
|
171
149
|
this._raf.push(requestAnimationFrame(() => {
|
|
172
150
|
if (!containsActiveElement(this._view)) {
|
|
@@ -175,10 +153,8 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
175
153
|
}));
|
|
176
154
|
}
|
|
177
155
|
};
|
|
178
|
-
|
|
179
156
|
this.handlePositioned = position => {
|
|
180
157
|
var _this$props$onPositio, _this$props3;
|
|
181
|
-
|
|
182
158
|
const placement = position.placement;
|
|
183
159
|
this.setState({
|
|
184
160
|
placement,
|
|
@@ -186,10 +162,8 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
186
162
|
});
|
|
187
163
|
(_this$props$onPositio = (_this$props3 = this.props).onPositioned) === null || _this$props$onPositio === void 0 ? void 0 : _this$props$onPositio.call(_this$props3, position);
|
|
188
164
|
};
|
|
189
|
-
|
|
190
165
|
this.handlePositionChanged = position => {
|
|
191
166
|
var _this$props$onPositio2, _this$props4;
|
|
192
|
-
|
|
193
167
|
const placement = position.placement;
|
|
194
168
|
this.setState({
|
|
195
169
|
placement,
|
|
@@ -197,7 +171,6 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
197
171
|
});
|
|
198
172
|
(_this$props$onPositio2 = (_this$props4 = this.props).onPositionChanged) === null || _this$props$onPositio2 === void 0 ? void 0 : _this$props$onPositio2.call(_this$props4, position);
|
|
199
173
|
};
|
|
200
|
-
|
|
201
174
|
this.state = {
|
|
202
175
|
placement: props.placement,
|
|
203
176
|
offsetX: props.offsetX,
|
|
@@ -217,11 +190,9 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
217
190
|
}, 1);
|
|
218
191
|
});
|
|
219
192
|
}
|
|
220
|
-
|
|
221
193
|
get isTooltip() {
|
|
222
194
|
return this.props.shouldRenderOffscreen && !this.props.shouldReturnFocus && !this.props.shouldContainFocus && !this.props.shouldFocusContentOnTriggerBlur;
|
|
223
195
|
}
|
|
224
|
-
|
|
225
196
|
componentDidMount() {
|
|
226
197
|
if (this.isTooltip) {
|
|
227
198
|
// if popover is being used as a tooltip with no focusable content
|
|
@@ -232,29 +203,22 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
232
203
|
shouldCloseOnDocumentClick: true,
|
|
233
204
|
onDismiss: this.hide
|
|
234
205
|
});
|
|
235
|
-
|
|
236
206
|
if (this.shown) {
|
|
237
207
|
this._focusRegion.activate();
|
|
238
208
|
}
|
|
239
209
|
}
|
|
240
210
|
}
|
|
241
|
-
|
|
242
211
|
componentWillUnmount() {
|
|
243
212
|
this._raf.forEach(request => request.cancel());
|
|
244
|
-
|
|
245
213
|
this._raf = [];
|
|
246
|
-
|
|
247
214
|
if (this._focusRegion) {
|
|
248
215
|
this._focusRegion.deactivate();
|
|
249
|
-
|
|
250
216
|
this._focusRegion.blur();
|
|
251
217
|
}
|
|
252
218
|
}
|
|
253
|
-
|
|
254
219
|
shouldComponentUpdate(nextProps, nextState) {
|
|
255
220
|
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
|
256
221
|
}
|
|
257
|
-
|
|
258
222
|
componentDidUpdate(prevProps, prevState) {
|
|
259
223
|
if (this._focusRegion && this.isTooltip) {
|
|
260
224
|
// if focus region exists, popover is acting as a tooltip
|
|
@@ -262,41 +226,38 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
262
226
|
if (!prevProps.isShowingContent && this.props.isShowingContent || !prevState.isShowingContent && this.state.isShowingContent) {
|
|
263
227
|
// changed from hiding to showing
|
|
264
228
|
this._focusRegion.activate();
|
|
265
|
-
|
|
266
229
|
this._focusRegion.focus();
|
|
267
230
|
}
|
|
268
|
-
|
|
269
231
|
if (prevProps.isShowingContent && !this.props.isShowingContent || prevState.isShowingContent && !this.state.isShowingContent) {
|
|
270
232
|
// changed from showing to hiding
|
|
271
233
|
this._focusRegion.deactivate();
|
|
272
234
|
}
|
|
273
|
-
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// since `offsetX`, `offsetY` and `placement` are saved into the state
|
|
274
238
|
// in the constructor and used from the state later,
|
|
275
239
|
// we need to update the state if these props change
|
|
276
|
-
|
|
277
|
-
|
|
278
240
|
if (this.props.offsetX !== prevProps.offsetX || this.props.offsetY !== prevProps.offsetY || this.props.placement !== prevProps.placement || this.props.shouldAlignArrow !== prevProps.shouldAlignArrow || this.props.withArrow !== prevProps.withArrow) {
|
|
279
|
-
this.setState({
|
|
241
|
+
this.setState({
|
|
242
|
+
...this.computeOffsets(this.placement)
|
|
280
243
|
});
|
|
281
244
|
}
|
|
282
245
|
}
|
|
283
|
-
|
|
284
246
|
computeOffsets(placement) {
|
|
285
247
|
let _this$props5 = this.props,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
248
|
+
offsetX = _this$props5.offsetX,
|
|
249
|
+
offsetY = _this$props5.offsetY;
|
|
289
250
|
if (this.props.shouldAlignArrow && this._view) {
|
|
290
|
-
const secondaryPlacement = parsePlacement(placement)[1];
|
|
291
|
-
// declared in ContextView's styles.js
|
|
251
|
+
const secondaryPlacement = parsePlacement(placement)[1];
|
|
292
252
|
|
|
253
|
+
// arrowSize and arrowBorderWidth are component theme variables
|
|
254
|
+
// declared in ContextView's styles.js
|
|
293
255
|
const _ref2 = this._view.props.styles,
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
256
|
+
_ref2$arrowSize = _ref2.arrowSize,
|
|
257
|
+
arrowSize = _ref2$arrowSize === void 0 ? 0 : _ref2$arrowSize,
|
|
258
|
+
_ref2$arrowBorderWidt = _ref2.arrowBorderWidth,
|
|
259
|
+
arrowBorderWidth = _ref2$arrowBorderWidt === void 0 ? 0 : _ref2$arrowBorderWidt;
|
|
298
260
|
const offsetAmount = (px(arrowSize) + px(arrowBorderWidth)) * 2;
|
|
299
|
-
|
|
300
261
|
if (secondaryPlacement === 'start') {
|
|
301
262
|
offsetX = offsetAmount;
|
|
302
263
|
} else if (secondaryPlacement === 'end') {
|
|
@@ -307,25 +268,20 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
307
268
|
offsetY = -offsetAmount;
|
|
308
269
|
}
|
|
309
270
|
}
|
|
310
|
-
|
|
311
271
|
return {
|
|
312
272
|
offsetX,
|
|
313
273
|
offsetY
|
|
314
274
|
};
|
|
315
275
|
}
|
|
316
|
-
|
|
317
276
|
get placement() {
|
|
318
277
|
let placement = this.props.placement;
|
|
319
278
|
const dir = this.props.dir;
|
|
320
279
|
const isRtl = dir === textDirectionContextConsumer.DIRECTION.rtl;
|
|
321
|
-
|
|
322
280
|
if (isRtl) {
|
|
323
281
|
placement = mirrorHorizontalPlacement(placement, ' ');
|
|
324
282
|
}
|
|
325
|
-
|
|
326
283
|
return !this.shown && this.props.shouldRenderOffscreen ? 'offscreen' : placement;
|
|
327
284
|
}
|
|
328
|
-
|
|
329
285
|
get positionProps() {
|
|
330
286
|
return {
|
|
331
287
|
offsetX: this.state.offsetX,
|
|
@@ -342,50 +298,41 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
342
298
|
id: this._id
|
|
343
299
|
};
|
|
344
300
|
}
|
|
345
|
-
|
|
346
301
|
get shown() {
|
|
347
302
|
return typeof this.props.isShowingContent === 'undefined' ? this.state.isShowingContent : this.props.isShowingContent;
|
|
348
303
|
}
|
|
349
|
-
|
|
350
304
|
get defaultFocusElement() {
|
|
351
305
|
return this.props.defaultFocusElement;
|
|
352
306
|
}
|
|
353
|
-
|
|
354
307
|
renderTrigger() {
|
|
355
308
|
let trigger = callRenderProp(this.props.renderTrigger);
|
|
356
|
-
|
|
357
309
|
if (trigger) {
|
|
358
310
|
const _this$props6 = this.props,
|
|
359
|
-
|
|
360
|
-
|
|
311
|
+
on = _this$props6.on,
|
|
312
|
+
shouldContainFocus = _this$props6.shouldContainFocus;
|
|
361
313
|
let onClick = void 0;
|
|
362
314
|
let onFocus = void 0;
|
|
363
315
|
let onMouseOut = void 0;
|
|
364
316
|
let onMouseOver = void 0;
|
|
365
317
|
let expanded;
|
|
366
|
-
|
|
367
318
|
if (on && on.indexOf('click') > -1) {
|
|
368
319
|
onClick = event => {
|
|
369
320
|
this.toggle(event);
|
|
370
321
|
};
|
|
371
322
|
}
|
|
372
|
-
|
|
373
323
|
if (on && on.indexOf('hover') > -1) {
|
|
374
324
|
error(!(on === 'hover'), '[Popover] Specifying only the `"hover"` trigger limits the visibility' + ' of the Popover to just mouse users. Consider also including the `"focus"` trigger ' + 'so that touch and keyboard only users can see the Popover content as well.');
|
|
375
325
|
onMouseOver = this._handleMouseOver;
|
|
376
326
|
onMouseOut = this._handleMouseOut;
|
|
377
327
|
}
|
|
378
|
-
|
|
379
328
|
if (on && on.indexOf('focus') > -1) {
|
|
380
329
|
onFocus = event => {
|
|
381
330
|
this.show(event);
|
|
382
331
|
};
|
|
383
332
|
}
|
|
384
|
-
|
|
385
333
|
if (shouldContainFocus) {
|
|
386
334
|
// only set aria-expanded if popover can contain focus
|
|
387
335
|
expanded = this.shown ? 'true' : 'false';
|
|
388
|
-
|
|
389
336
|
if ('aria-expanded' in this.props) {
|
|
390
337
|
// @ts-expect-error It is an escape hatch, in case someone
|
|
391
338
|
// wants to remove/override aria-expanded even when shouldContainFocus
|
|
@@ -394,7 +341,6 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
394
341
|
} else {
|
|
395
342
|
expanded = void 0;
|
|
396
343
|
}
|
|
397
|
-
|
|
398
344
|
trigger = safeCloneElement(trigger, {
|
|
399
345
|
ref: el => {
|
|
400
346
|
this._trigger = el;
|
|
@@ -410,13 +356,10 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
410
356
|
onMouseOver: createChainedFunction(onMouseOver, this.props.onMouseOver)
|
|
411
357
|
});
|
|
412
358
|
}
|
|
413
|
-
|
|
414
359
|
return trigger;
|
|
415
360
|
}
|
|
416
|
-
|
|
417
361
|
renderContent() {
|
|
418
362
|
let content = callRenderProp(this.props.children);
|
|
419
|
-
|
|
420
363
|
if (this.shown && !this.isTooltip) {
|
|
421
364
|
// if popover is NOT being used as a tooltip, create a Dialog
|
|
422
365
|
// to manage the content FocusRegion, when showing
|
|
@@ -436,7 +379,6 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
436
379
|
shouldCloseOnEscape: this.props.shouldCloseOnEscape
|
|
437
380
|
}, content);
|
|
438
381
|
}
|
|
439
|
-
|
|
440
382
|
if (this.shown || this.props.shouldRenderOffscreen) {
|
|
441
383
|
const color = this.props.color;
|
|
442
384
|
let viewProps = {
|
|
@@ -444,7 +386,6 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
444
386
|
ref: c => this._view = c,
|
|
445
387
|
elementRef: el => {
|
|
446
388
|
var _this$props$contentRe, _this$props7;
|
|
447
|
-
|
|
448
389
|
this._contentElement = el;
|
|
449
390
|
(_this$props$contentRe = (_this$props7 = this.props).contentRef) === null || _this$props$contentRe === void 0 ? void 0 : _this$props$contentRe.call(_this$props7, el);
|
|
450
391
|
},
|
|
@@ -453,26 +394,26 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
453
394
|
shadow: this.props.shadow,
|
|
454
395
|
display: 'block'
|
|
455
396
|
};
|
|
456
|
-
|
|
457
397
|
if (this.isTooltip) {
|
|
458
|
-
viewProps = {
|
|
398
|
+
viewProps = {
|
|
399
|
+
...viewProps,
|
|
459
400
|
// Because of a11y reasons popovers should not be hidden when hovered over
|
|
460
401
|
onMouseOver: this._handleMouseOver,
|
|
461
402
|
onMouseOut: this._handleMouseOut
|
|
462
403
|
};
|
|
463
404
|
}
|
|
464
|
-
|
|
465
405
|
const placement = this.state.placement;
|
|
466
|
-
|
|
467
406
|
if (this.props.withArrow) {
|
|
468
|
-
viewProps = {
|
|
407
|
+
viewProps = {
|
|
408
|
+
...viewProps,
|
|
469
409
|
// TODO: remove background override after contextview is updated
|
|
470
410
|
background: color === 'primary' ? 'default' : 'inverse',
|
|
471
411
|
placement: this.props.dir === textDirectionContextConsumer.DIRECTION.rtl ? mirrorHorizontalPlacement(placement, ' ') : placement
|
|
472
412
|
};
|
|
473
413
|
return /*#__PURE__*/React.createElement(ContextView, viewProps, content);
|
|
474
414
|
} else {
|
|
475
|
-
viewProps = {
|
|
415
|
+
viewProps = {
|
|
416
|
+
...viewProps,
|
|
476
417
|
borderWidth: 'small',
|
|
477
418
|
borderRadius: 'medium',
|
|
478
419
|
...(color === 'primary-inverse' && {
|
|
@@ -485,10 +426,8 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
485
426
|
return null;
|
|
486
427
|
}
|
|
487
428
|
}
|
|
488
|
-
|
|
489
429
|
render() {
|
|
490
430
|
const positionProps = this.positionProps;
|
|
491
|
-
|
|
492
431
|
if (this.props.positionTarget) {
|
|
493
432
|
return /*#__PURE__*/React.createElement("span", {
|
|
494
433
|
ref: this.handleRef
|
|
@@ -500,7 +439,6 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
|
|
|
500
439
|
}), this.renderContent());
|
|
501
440
|
}
|
|
502
441
|
}
|
|
503
|
-
|
|
504
442
|
}, _class2.displayName = "Popover", _class2.componentId = 'Popover', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
505
443
|
defaultIsShowingContent: false,
|
|
506
444
|
placement: 'bottom center',
|
package/es/Popover/locator.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { PopoverLocator } from './PopoverLocator';
|
|
25
26
|
export { PopoverTriggerLocator, customMethods } from './PopoverLocator';
|
|
26
27
|
export { PopoverLocator };
|
package/es/Popover/props.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
import { element } from '@instructure/ui-prop-types';
|
|
26
27
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
@@ -11,15 +11,10 @@ Object.defineProperty(exports, "PopoverTriggerLocator", {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
exports.customMethods = void 0;
|
|
14
|
-
|
|
15
14
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
16
|
-
|
|
17
15
|
var _PositionLocator = require("@instructure/ui-position/lib/Position/PositionLocator");
|
|
18
|
-
|
|
19
16
|
var _index = require("./index");
|
|
20
|
-
|
|
21
17
|
var _PopoverTriggerLocator = require("./PopoverTriggerLocator");
|
|
22
|
-
|
|
23
18
|
/*
|
|
24
19
|
* The MIT License (MIT)
|
|
25
20
|
*
|
|
@@ -43,8 +38,10 @@ var _PopoverTriggerLocator = require("./PopoverTriggerLocator");
|
|
|
43
38
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
44
39
|
* SOFTWARE.
|
|
45
40
|
*/
|
|
41
|
+
|
|
46
42
|
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
|
|
47
43
|
// eslint-disable-next-line no-restricted-imports
|
|
44
|
+
|
|
48
45
|
const customMethods = {
|
|
49
46
|
findContent: function () {
|
|
50
47
|
return _PositionLocator.PositionLocator.findContent(...arguments);
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PopoverTriggerLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* The MIT License (MIT)
|
|
12
10
|
*
|
|
@@ -30,5 +28,6 @@ var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
|
30
28
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
29
|
* SOFTWARE.
|
|
32
30
|
*/
|
|
31
|
+
|
|
33
32
|
const PopoverTriggerLocator = (0, _locator.locator)('[data-popover-trigger]');
|
|
34
33
|
exports.PopoverTriggerLocator = PopoverTriggerLocator;
|