@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/lib/Popover/index.js
CHANGED
|
@@ -1,62 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.Popover = void 0;
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
15
|
-
|
|
16
11
|
var _Position = require("@instructure/ui-position/lib/Position");
|
|
17
|
-
|
|
18
12
|
var _parsePlacement = require("@instructure/ui-position/lib/parsePlacement.js");
|
|
19
|
-
|
|
20
13
|
var _mirrorHorizontalPlacement = require("@instructure/ui-position/lib/mirrorHorizontalPlacement.js");
|
|
21
|
-
|
|
22
14
|
var _ContextView = require("@instructure/ui-view/lib/ContextView");
|
|
23
|
-
|
|
24
15
|
var _View = require("@instructure/ui-view/lib/View");
|
|
25
|
-
|
|
26
16
|
var _Dialog = require("@instructure/ui-dialog/lib/Dialog");
|
|
27
|
-
|
|
28
17
|
var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
|
|
29
|
-
|
|
30
18
|
var _findDOMNode = require("@instructure/ui-dom-utils/lib/findDOMNode.js");
|
|
31
|
-
|
|
32
19
|
var _containsActiveElement = require("@instructure/ui-dom-utils/lib/containsActiveElement.js");
|
|
33
|
-
|
|
34
20
|
var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
|
|
35
|
-
|
|
36
21
|
var _handleMouseOverOut = require("@instructure/ui-dom-utils/lib/handleMouseOverOut.js");
|
|
37
|
-
|
|
38
22
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
39
|
-
|
|
40
23
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
41
|
-
|
|
42
24
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
43
|
-
|
|
44
25
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
45
|
-
|
|
46
26
|
var _shallowEqual = require("@instructure/ui-utils/lib/shallowEqual.js");
|
|
47
|
-
|
|
48
27
|
var _px = require("@instructure/ui-utils/lib/px.js");
|
|
49
|
-
|
|
50
28
|
var _console = require("@instructure/console");
|
|
51
|
-
|
|
52
29
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
53
|
-
|
|
54
30
|
var _FocusRegion = require("@instructure/ui-a11y-utils/lib/FocusRegion.js");
|
|
55
|
-
|
|
56
31
|
var _props = require("./props");
|
|
57
|
-
|
|
58
32
|
var _dec, _dec2, _dec3, _class, _class2;
|
|
59
|
-
|
|
60
33
|
/**
|
|
61
34
|
---
|
|
62
35
|
category: components
|
|
@@ -67,7 +40,6 @@ tags: overlay, portal, dialog
|
|
|
67
40
|
let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Popover extends _react.Component {
|
|
68
41
|
constructor(props) {
|
|
69
42
|
var _this;
|
|
70
|
-
|
|
71
43
|
super(props);
|
|
72
44
|
_this = this;
|
|
73
45
|
this._handleMouseOver = void 0;
|
|
@@ -81,45 +53,36 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
81
53
|
this._focusRegion = void 0;
|
|
82
54
|
this.mouseOutTimeout = void 0;
|
|
83
55
|
this.ref = null;
|
|
84
|
-
|
|
85
56
|
this.handleRef = el => {
|
|
86
57
|
const elementRef = this.props.elementRef;
|
|
87
58
|
this.ref = el;
|
|
88
|
-
|
|
89
59
|
if (typeof elementRef === 'function') {
|
|
90
60
|
elementRef(el);
|
|
91
61
|
}
|
|
92
62
|
};
|
|
93
|
-
|
|
94
63
|
this.show = event => {
|
|
95
64
|
var _this$props$onShowCon, _this$props;
|
|
96
|
-
|
|
97
65
|
if (typeof this.props.isShowingContent === 'undefined') {
|
|
98
66
|
this.setState({
|
|
99
67
|
isShowingContent: true
|
|
100
68
|
});
|
|
101
69
|
}
|
|
102
|
-
|
|
103
70
|
(_this$props$onShowCon = (_this$props = this.props).onShowContent) === null || _this$props$onShowCon === void 0 ? void 0 : _this$props$onShowCon.call(_this$props, event);
|
|
104
71
|
};
|
|
105
|
-
|
|
106
72
|
this.hide = function (event) {
|
|
107
73
|
let documentClick = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
108
74
|
const _this$props2 = _this.props,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
75
|
+
onHideContent = _this$props2.onHideContent,
|
|
76
|
+
isShowingContent = _this$props2.isShowingContent;
|
|
112
77
|
if (typeof isShowingContent === 'undefined') {
|
|
113
78
|
// uncontrolled, set state, fire callbacks
|
|
114
79
|
_this.setState(_ref => {
|
|
115
80
|
let isShowingContent = _ref.isShowingContent;
|
|
116
|
-
|
|
117
81
|
if (isShowingContent) {
|
|
118
82
|
onHideContent === null || onHideContent === void 0 ? void 0 : onHideContent(event, {
|
|
119
83
|
documentClick
|
|
120
84
|
});
|
|
121
85
|
}
|
|
122
|
-
|
|
123
86
|
return {
|
|
124
87
|
isShowingContent: false
|
|
125
88
|
};
|
|
@@ -131,7 +94,6 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
131
94
|
});
|
|
132
95
|
}
|
|
133
96
|
};
|
|
134
|
-
|
|
135
97
|
this.toggle = event => {
|
|
136
98
|
if (this.shown) {
|
|
137
99
|
this.hide(event);
|
|
@@ -139,42 +101,33 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
139
101
|
this.show(event);
|
|
140
102
|
}
|
|
141
103
|
};
|
|
142
|
-
|
|
143
104
|
this.handleDialogDismiss = (event, documentClick) => {
|
|
144
105
|
if (!this.props.shouldReturnFocus && this.props.shouldFocusContentOnTriggerBlur) {
|
|
145
106
|
const trigger = (0, _findDOMNode.findDOMNode)(this._trigger);
|
|
146
|
-
|
|
147
107
|
if (trigger && typeof trigger.focus === 'function') {
|
|
148
108
|
;
|
|
149
109
|
trigger.focus();
|
|
150
110
|
}
|
|
151
111
|
}
|
|
152
|
-
|
|
153
112
|
this.hide(event, documentClick);
|
|
154
113
|
};
|
|
155
|
-
|
|
156
114
|
this.handleDialogBlur = event => {
|
|
157
115
|
if (event.keyCode === _keycode.default.codes.tab && event.shiftKey && this.props.shouldFocusContentOnTriggerBlur) {
|
|
158
116
|
return;
|
|
159
117
|
}
|
|
160
|
-
|
|
161
118
|
this.hide(event);
|
|
162
119
|
};
|
|
163
|
-
|
|
164
120
|
this.handleTriggerKeyDown = event => {
|
|
165
121
|
if (!this.props.shouldFocusContentOnTriggerBlur) {
|
|
166
122
|
return;
|
|
167
123
|
}
|
|
168
|
-
|
|
169
124
|
if (event.keyCode === _keycode.default.codes.tab && !event.shiftKey) {
|
|
170
125
|
event.preventDefault();
|
|
171
|
-
|
|
172
126
|
this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(() => {
|
|
173
127
|
this._dialog && this._dialog.focus();
|
|
174
128
|
}));
|
|
175
129
|
}
|
|
176
130
|
};
|
|
177
|
-
|
|
178
131
|
this.handleTriggerKeyUp = event => {
|
|
179
132
|
if (event.keyCode === _keycode.default.codes.esc && this.shown && this.isTooltip) {
|
|
180
133
|
// if popover is tooltip, it is managing its own focus region so we need
|
|
@@ -183,10 +136,8 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
183
136
|
this.hide(event);
|
|
184
137
|
}
|
|
185
138
|
};
|
|
186
|
-
|
|
187
139
|
this.handleTriggerBlur = event => {
|
|
188
140
|
const on = this.props.on;
|
|
189
|
-
|
|
190
141
|
if (on && on.indexOf('focus') > -1) {
|
|
191
142
|
this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(() => {
|
|
192
143
|
if (!(0, _containsActiveElement.containsActiveElement)(this._view)) {
|
|
@@ -195,10 +146,8 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
195
146
|
}));
|
|
196
147
|
}
|
|
197
148
|
};
|
|
198
|
-
|
|
199
149
|
this.handlePositioned = position => {
|
|
200
150
|
var _this$props$onPositio, _this$props3;
|
|
201
|
-
|
|
202
151
|
const placement = position.placement;
|
|
203
152
|
this.setState({
|
|
204
153
|
placement,
|
|
@@ -206,10 +155,8 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
206
155
|
});
|
|
207
156
|
(_this$props$onPositio = (_this$props3 = this.props).onPositioned) === null || _this$props$onPositio === void 0 ? void 0 : _this$props$onPositio.call(_this$props3, position);
|
|
208
157
|
};
|
|
209
|
-
|
|
210
158
|
this.handlePositionChanged = position => {
|
|
211
159
|
var _this$props$onPositio2, _this$props4;
|
|
212
|
-
|
|
213
160
|
const placement = position.placement;
|
|
214
161
|
this.setState({
|
|
215
162
|
placement,
|
|
@@ -217,7 +164,6 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
217
164
|
});
|
|
218
165
|
(_this$props$onPositio2 = (_this$props4 = this.props).onPositionChanged) === null || _this$props$onPositio2 === void 0 ? void 0 : _this$props$onPositio2.call(_this$props4, position);
|
|
219
166
|
};
|
|
220
|
-
|
|
221
167
|
this.state = {
|
|
222
168
|
placement: props.placement,
|
|
223
169
|
offsetX: props.offsetX,
|
|
@@ -237,11 +183,9 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
237
183
|
}, 1);
|
|
238
184
|
});
|
|
239
185
|
}
|
|
240
|
-
|
|
241
186
|
get isTooltip() {
|
|
242
187
|
return this.props.shouldRenderOffscreen && !this.props.shouldReturnFocus && !this.props.shouldContainFocus && !this.props.shouldFocusContentOnTriggerBlur;
|
|
243
188
|
}
|
|
244
|
-
|
|
245
189
|
componentDidMount() {
|
|
246
190
|
if (this.isTooltip) {
|
|
247
191
|
// if popover is being used as a tooltip with no focusable content
|
|
@@ -252,29 +196,22 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
252
196
|
shouldCloseOnDocumentClick: true,
|
|
253
197
|
onDismiss: this.hide
|
|
254
198
|
});
|
|
255
|
-
|
|
256
199
|
if (this.shown) {
|
|
257
200
|
this._focusRegion.activate();
|
|
258
201
|
}
|
|
259
202
|
}
|
|
260
203
|
}
|
|
261
|
-
|
|
262
204
|
componentWillUnmount() {
|
|
263
205
|
this._raf.forEach(request => request.cancel());
|
|
264
|
-
|
|
265
206
|
this._raf = [];
|
|
266
|
-
|
|
267
207
|
if (this._focusRegion) {
|
|
268
208
|
this._focusRegion.deactivate();
|
|
269
|
-
|
|
270
209
|
this._focusRegion.blur();
|
|
271
210
|
}
|
|
272
211
|
}
|
|
273
|
-
|
|
274
212
|
shouldComponentUpdate(nextProps, nextState) {
|
|
275
213
|
return !(0, _shallowEqual.shallowEqual)(this.props, nextProps) || !(0, _shallowEqual.shallowEqual)(this.state, nextState);
|
|
276
214
|
}
|
|
277
|
-
|
|
278
215
|
componentDidUpdate(prevProps, prevState) {
|
|
279
216
|
if (this._focusRegion && this.isTooltip) {
|
|
280
217
|
// if focus region exists, popover is acting as a tooltip
|
|
@@ -282,41 +219,38 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
282
219
|
if (!prevProps.isShowingContent && this.props.isShowingContent || !prevState.isShowingContent && this.state.isShowingContent) {
|
|
283
220
|
// changed from hiding to showing
|
|
284
221
|
this._focusRegion.activate();
|
|
285
|
-
|
|
286
222
|
this._focusRegion.focus();
|
|
287
223
|
}
|
|
288
|
-
|
|
289
224
|
if (prevProps.isShowingContent && !this.props.isShowingContent || prevState.isShowingContent && !this.state.isShowingContent) {
|
|
290
225
|
// changed from showing to hiding
|
|
291
226
|
this._focusRegion.deactivate();
|
|
292
227
|
}
|
|
293
|
-
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// since `offsetX`, `offsetY` and `placement` are saved into the state
|
|
294
231
|
// in the constructor and used from the state later,
|
|
295
232
|
// we need to update the state if these props change
|
|
296
|
-
|
|
297
|
-
|
|
298
233
|
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) {
|
|
299
|
-
this.setState({
|
|
234
|
+
this.setState({
|
|
235
|
+
...this.computeOffsets(this.placement)
|
|
300
236
|
});
|
|
301
237
|
}
|
|
302
238
|
}
|
|
303
|
-
|
|
304
239
|
computeOffsets(placement) {
|
|
305
240
|
let _this$props5 = this.props,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
241
|
+
offsetX = _this$props5.offsetX,
|
|
242
|
+
offsetY = _this$props5.offsetY;
|
|
309
243
|
if (this.props.shouldAlignArrow && this._view) {
|
|
310
|
-
const secondaryPlacement = (0, _parsePlacement.parsePlacement)(placement)[1];
|
|
311
|
-
// declared in ContextView's styles.js
|
|
244
|
+
const secondaryPlacement = (0, _parsePlacement.parsePlacement)(placement)[1];
|
|
312
245
|
|
|
246
|
+
// arrowSize and arrowBorderWidth are component theme variables
|
|
247
|
+
// declared in ContextView's styles.js
|
|
313
248
|
const _ref2 = this._view.props.styles,
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
249
|
+
_ref2$arrowSize = _ref2.arrowSize,
|
|
250
|
+
arrowSize = _ref2$arrowSize === void 0 ? 0 : _ref2$arrowSize,
|
|
251
|
+
_ref2$arrowBorderWidt = _ref2.arrowBorderWidth,
|
|
252
|
+
arrowBorderWidth = _ref2$arrowBorderWidt === void 0 ? 0 : _ref2$arrowBorderWidt;
|
|
318
253
|
const offsetAmount = ((0, _px.px)(arrowSize) + (0, _px.px)(arrowBorderWidth)) * 2;
|
|
319
|
-
|
|
320
254
|
if (secondaryPlacement === 'start') {
|
|
321
255
|
offsetX = offsetAmount;
|
|
322
256
|
} else if (secondaryPlacement === 'end') {
|
|
@@ -327,25 +261,20 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
327
261
|
offsetY = -offsetAmount;
|
|
328
262
|
}
|
|
329
263
|
}
|
|
330
|
-
|
|
331
264
|
return {
|
|
332
265
|
offsetX,
|
|
333
266
|
offsetY
|
|
334
267
|
};
|
|
335
268
|
}
|
|
336
|
-
|
|
337
269
|
get placement() {
|
|
338
270
|
let placement = this.props.placement;
|
|
339
271
|
const dir = this.props.dir;
|
|
340
272
|
const isRtl = dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl;
|
|
341
|
-
|
|
342
273
|
if (isRtl) {
|
|
343
274
|
placement = (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ');
|
|
344
275
|
}
|
|
345
|
-
|
|
346
276
|
return !this.shown && this.props.shouldRenderOffscreen ? 'offscreen' : placement;
|
|
347
277
|
}
|
|
348
|
-
|
|
349
278
|
get positionProps() {
|
|
350
279
|
return {
|
|
351
280
|
offsetX: this.state.offsetX,
|
|
@@ -362,50 +291,41 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
362
291
|
id: this._id
|
|
363
292
|
};
|
|
364
293
|
}
|
|
365
|
-
|
|
366
294
|
get shown() {
|
|
367
295
|
return typeof this.props.isShowingContent === 'undefined' ? this.state.isShowingContent : this.props.isShowingContent;
|
|
368
296
|
}
|
|
369
|
-
|
|
370
297
|
get defaultFocusElement() {
|
|
371
298
|
return this.props.defaultFocusElement;
|
|
372
299
|
}
|
|
373
|
-
|
|
374
300
|
renderTrigger() {
|
|
375
301
|
let trigger = (0, _callRenderProp.callRenderProp)(this.props.renderTrigger);
|
|
376
|
-
|
|
377
302
|
if (trigger) {
|
|
378
303
|
const _this$props6 = this.props,
|
|
379
|
-
|
|
380
|
-
|
|
304
|
+
on = _this$props6.on,
|
|
305
|
+
shouldContainFocus = _this$props6.shouldContainFocus;
|
|
381
306
|
let onClick = void 0;
|
|
382
307
|
let onFocus = void 0;
|
|
383
308
|
let onMouseOut = void 0;
|
|
384
309
|
let onMouseOver = void 0;
|
|
385
310
|
let expanded;
|
|
386
|
-
|
|
387
311
|
if (on && on.indexOf('click') > -1) {
|
|
388
312
|
onClick = event => {
|
|
389
313
|
this.toggle(event);
|
|
390
314
|
};
|
|
391
315
|
}
|
|
392
|
-
|
|
393
316
|
if (on && on.indexOf('hover') > -1) {
|
|
394
317
|
(0, _console.logError)(!(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.');
|
|
395
318
|
onMouseOver = this._handleMouseOver;
|
|
396
319
|
onMouseOut = this._handleMouseOut;
|
|
397
320
|
}
|
|
398
|
-
|
|
399
321
|
if (on && on.indexOf('focus') > -1) {
|
|
400
322
|
onFocus = event => {
|
|
401
323
|
this.show(event);
|
|
402
324
|
};
|
|
403
325
|
}
|
|
404
|
-
|
|
405
326
|
if (shouldContainFocus) {
|
|
406
327
|
// only set aria-expanded if popover can contain focus
|
|
407
328
|
expanded = this.shown ? 'true' : 'false';
|
|
408
|
-
|
|
409
329
|
if ('aria-expanded' in this.props) {
|
|
410
330
|
// @ts-expect-error It is an escape hatch, in case someone
|
|
411
331
|
// wants to remove/override aria-expanded even when shouldContainFocus
|
|
@@ -414,7 +334,6 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
414
334
|
} else {
|
|
415
335
|
expanded = void 0;
|
|
416
336
|
}
|
|
417
|
-
|
|
418
337
|
trigger = (0, _safeCloneElement.safeCloneElement)(trigger, {
|
|
419
338
|
ref: el => {
|
|
420
339
|
this._trigger = el;
|
|
@@ -430,13 +349,10 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
430
349
|
onMouseOver: (0, _createChainedFunction.createChainedFunction)(onMouseOver, this.props.onMouseOver)
|
|
431
350
|
});
|
|
432
351
|
}
|
|
433
|
-
|
|
434
352
|
return trigger;
|
|
435
353
|
}
|
|
436
|
-
|
|
437
354
|
renderContent() {
|
|
438
355
|
let content = (0, _callRenderProp.callRenderProp)(this.props.children);
|
|
439
|
-
|
|
440
356
|
if (this.shown && !this.isTooltip) {
|
|
441
357
|
// if popover is NOT being used as a tooltip, create a Dialog
|
|
442
358
|
// to manage the content FocusRegion, when showing
|
|
@@ -456,7 +372,6 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
456
372
|
shouldCloseOnEscape: this.props.shouldCloseOnEscape
|
|
457
373
|
}, content);
|
|
458
374
|
}
|
|
459
|
-
|
|
460
375
|
if (this.shown || this.props.shouldRenderOffscreen) {
|
|
461
376
|
const color = this.props.color;
|
|
462
377
|
let viewProps = {
|
|
@@ -464,7 +379,6 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
464
379
|
ref: c => this._view = c,
|
|
465
380
|
elementRef: el => {
|
|
466
381
|
var _this$props$contentRe, _this$props7;
|
|
467
|
-
|
|
468
382
|
this._contentElement = el;
|
|
469
383
|
(_this$props$contentRe = (_this$props7 = this.props).contentRef) === null || _this$props$contentRe === void 0 ? void 0 : _this$props$contentRe.call(_this$props7, el);
|
|
470
384
|
},
|
|
@@ -473,26 +387,26 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
473
387
|
shadow: this.props.shadow,
|
|
474
388
|
display: 'block'
|
|
475
389
|
};
|
|
476
|
-
|
|
477
390
|
if (this.isTooltip) {
|
|
478
|
-
viewProps = {
|
|
391
|
+
viewProps = {
|
|
392
|
+
...viewProps,
|
|
479
393
|
// Because of a11y reasons popovers should not be hidden when hovered over
|
|
480
394
|
onMouseOver: this._handleMouseOver,
|
|
481
395
|
onMouseOut: this._handleMouseOut
|
|
482
396
|
};
|
|
483
397
|
}
|
|
484
|
-
|
|
485
398
|
const placement = this.state.placement;
|
|
486
|
-
|
|
487
399
|
if (this.props.withArrow) {
|
|
488
|
-
viewProps = {
|
|
400
|
+
viewProps = {
|
|
401
|
+
...viewProps,
|
|
489
402
|
// TODO: remove background override after contextview is updated
|
|
490
403
|
background: color === 'primary' ? 'default' : 'inverse',
|
|
491
404
|
placement: this.props.dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl ? (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ') : placement
|
|
492
405
|
};
|
|
493
406
|
return /*#__PURE__*/_react.default.createElement(_ContextView.ContextView, viewProps, content);
|
|
494
407
|
} else {
|
|
495
|
-
viewProps = {
|
|
408
|
+
viewProps = {
|
|
409
|
+
...viewProps,
|
|
496
410
|
borderWidth: 'small',
|
|
497
411
|
borderRadius: 'medium',
|
|
498
412
|
...(color === 'primary-inverse' && {
|
|
@@ -505,10 +419,8 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
505
419
|
return null;
|
|
506
420
|
}
|
|
507
421
|
}
|
|
508
|
-
|
|
509
422
|
render() {
|
|
510
423
|
const positionProps = this.positionProps;
|
|
511
|
-
|
|
512
424
|
if (this.props.positionTarget) {
|
|
513
425
|
return /*#__PURE__*/_react.default.createElement("span", {
|
|
514
426
|
ref: this.handleRef
|
|
@@ -520,7 +432,6 @@ let Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (
|
|
|
520
432
|
}), this.renderContent());
|
|
521
433
|
}
|
|
522
434
|
}
|
|
523
|
-
|
|
524
435
|
}, _class2.displayName = "Popover", _class2.componentId = 'Popover', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
525
436
|
defaultIsShowingContent: false,
|
|
526
437
|
placement: 'bottom center',
|
package/lib/Popover/locator.js
CHANGED
package/lib/Popover/props.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _element = require("@instructure/ui-prop-types/lib/element.js");
|
|
13
|
-
|
|
14
10
|
var _emotion = require("@instructure/emotion");
|
|
15
|
-
|
|
16
11
|
var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes.js");
|
|
17
|
-
|
|
18
12
|
/*
|
|
19
13
|
* The MIT License (MIT)
|
|
20
14
|
*
|
|
@@ -38,6 +32,7 @@ var _PositionPropTypes = require("@instructure/ui-position/lib/PositionPropTypes
|
|
|
38
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
33
|
* SOFTWARE.
|
|
40
34
|
*/
|
|
35
|
+
|
|
41
36
|
const propTypes = {
|
|
42
37
|
isShowingContent: _propTypes.default.bool,
|
|
43
38
|
defaultIsShowingContent: _propTypes.default.bool,
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-popover",
|
|
3
|
-
"version": "8.33.
|
|
3
|
+
"version": "8.33.2-snapshot-5",
|
|
4
4
|
"description": "A component for hiding or showing content based on user interaction.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,28 +24,28 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.13.10",
|
|
27
|
-
"@instructure/console": "8.33.
|
|
28
|
-
"@instructure/emotion": "8.33.
|
|
29
|
-
"@instructure/ui-a11y-utils": "8.33.
|
|
30
|
-
"@instructure/ui-dialog": "8.33.
|
|
31
|
-
"@instructure/ui-dom-utils": "8.33.
|
|
32
|
-
"@instructure/ui-i18n": "8.33.
|
|
33
|
-
"@instructure/ui-position": "8.33.
|
|
34
|
-
"@instructure/ui-prop-types": "8.33.
|
|
35
|
-
"@instructure/ui-react-utils": "8.33.
|
|
36
|
-
"@instructure/ui-testable": "8.33.
|
|
37
|
-
"@instructure/ui-utils": "8.33.
|
|
38
|
-
"@instructure/ui-view": "8.33.
|
|
39
|
-
"@instructure/uid": "8.33.
|
|
27
|
+
"@instructure/console": "8.33.2-snapshot-5",
|
|
28
|
+
"@instructure/emotion": "8.33.2-snapshot-5",
|
|
29
|
+
"@instructure/ui-a11y-utils": "8.33.2-snapshot-5",
|
|
30
|
+
"@instructure/ui-dialog": "8.33.2-snapshot-5",
|
|
31
|
+
"@instructure/ui-dom-utils": "8.33.2-snapshot-5",
|
|
32
|
+
"@instructure/ui-i18n": "8.33.2-snapshot-5",
|
|
33
|
+
"@instructure/ui-position": "8.33.2-snapshot-5",
|
|
34
|
+
"@instructure/ui-prop-types": "8.33.2-snapshot-5",
|
|
35
|
+
"@instructure/ui-react-utils": "8.33.2-snapshot-5",
|
|
36
|
+
"@instructure/ui-testable": "8.33.2-snapshot-5",
|
|
37
|
+
"@instructure/ui-utils": "8.33.2-snapshot-5",
|
|
38
|
+
"@instructure/ui-view": "8.33.2-snapshot-5",
|
|
39
|
+
"@instructure/uid": "8.33.2-snapshot-5",
|
|
40
40
|
"keycode": "^2",
|
|
41
41
|
"prop-types": "^15"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@instructure/ui-babel-preset": "8.33.
|
|
45
|
-
"@instructure/ui-color-utils": "8.33.
|
|
46
|
-
"@instructure/ui-test-locator": "8.33.
|
|
47
|
-
"@instructure/ui-test-queries": "8.33.
|
|
48
|
-
"@instructure/ui-test-utils": "8.33.
|
|
44
|
+
"@instructure/ui-babel-preset": "8.33.2-snapshot-5",
|
|
45
|
+
"@instructure/ui-color-utils": "8.33.2-snapshot-5",
|
|
46
|
+
"@instructure/ui-test-locator": "8.33.2-snapshot-5",
|
|
47
|
+
"@instructure/ui-test-queries": "8.33.2-snapshot-5",
|
|
48
|
+
"@instructure/ui-test-utils": "8.33.2-snapshot-5"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": ">=16.8 <=18"
|