@instructure/ui-popover 8.12.1-snapshot.7 → 8.13.1-snapshot.9
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 +6 -0
- package/es/Popover/PopoverLocator.js +9 -3
- package/es/Popover/index.js +78 -75
- package/es/Popover/props.js +1 -176
- package/lib/Popover/PopoverLocator.js +11 -4
- package/lib/Popover/index.js +79 -76
- package/lib/Popover/props.js +2 -177
- package/package.json +20 -20
- package/src/Popover/index.tsx +102 -170
- package/src/Popover/props.ts +168 -138
- package/types/Popover/index.d.ts +72 -87
- package/types/Popover/index.d.ts.map +1 -1
- package/types/Popover/props.d.ts +166 -20
- package/types/Popover/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **ui-popover,ui-tooltip:** fixed Tooltip triggers being transformed to links/buttons ([07b0037](https://github.com/instructure/instructure-ui/commit/07b0037b0ddaf6d4f19cca140fc82fc9a2f1efc9))
|
|
11
|
+
|
|
6
12
|
# [8.12.0](https://github.com/instructure/instructure-ui/compare/v8.11.1...v8.12.0) (2021-11-17)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @instructure/ui-popover
|
|
@@ -27,9 +27,15 @@ import { PositionLocator } from '@instructure/ui-position/es/Position/PositionLo
|
|
|
27
27
|
import { Popover } from './index';
|
|
28
28
|
import { PopoverTriggerLocator } from './PopoverTriggerLocator';
|
|
29
29
|
export const customMethods = {
|
|
30
|
-
findContent: (
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
findContent: function () {
|
|
31
|
+
return PositionLocator.findContent(...arguments);
|
|
32
|
+
},
|
|
33
|
+
findPositionTarget: function () {
|
|
34
|
+
return PositionLocator.findTarget(...arguments);
|
|
35
|
+
},
|
|
36
|
+
findTrigger: function () {
|
|
37
|
+
return PopoverTriggerLocator.find(...arguments);
|
|
38
|
+
}
|
|
33
39
|
};
|
|
34
40
|
export { PopoverTriggerLocator };
|
|
35
41
|
export const PopoverLocator = locator(Popover.selector, customMethods);
|
package/es/Popover/index.js
CHANGED
|
@@ -42,14 +42,25 @@ import { allowedProps, propTypes } from './props';
|
|
|
42
42
|
category: components
|
|
43
43
|
tags: overlay, portal, dialog
|
|
44
44
|
---
|
|
45
|
+
@tsProps
|
|
45
46
|
**/
|
|
46
47
|
|
|
47
48
|
let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Popover extends Component {
|
|
48
49
|
constructor(props) {
|
|
50
|
+
var _this;
|
|
51
|
+
|
|
49
52
|
super(props);
|
|
53
|
+
_this = this;
|
|
50
54
|
this._handleMouseOver = void 0;
|
|
51
55
|
this._handleMouseOut = void 0;
|
|
56
|
+
this._id = void 0;
|
|
52
57
|
this._raf = [];
|
|
58
|
+
this._trigger = void 0;
|
|
59
|
+
this._view = null;
|
|
60
|
+
this._dialog = null;
|
|
61
|
+
this._contentElement = null;
|
|
62
|
+
this._focusRegion = void 0;
|
|
63
|
+
this.mouseOutTimeout = void 0;
|
|
53
64
|
this.ref = null;
|
|
54
65
|
|
|
55
66
|
this.handleRef = el => {
|
|
@@ -62,27 +73,30 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
62
73
|
};
|
|
63
74
|
|
|
64
75
|
this.show = event => {
|
|
76
|
+
var _this$props$onShowCon, _this$props;
|
|
77
|
+
|
|
65
78
|
if (typeof this.props.isShowingContent === 'undefined') {
|
|
66
79
|
this.setState({
|
|
67
80
|
isShowingContent: true
|
|
68
81
|
});
|
|
69
82
|
}
|
|
70
83
|
|
|
71
|
-
this.props.onShowContent(event);
|
|
84
|
+
(_this$props$onShowCon = (_this$props = this.props).onShowContent) === null || _this$props$onShowCon === void 0 ? void 0 : _this$props$onShowCon.call(_this$props, event);
|
|
72
85
|
};
|
|
73
86
|
|
|
74
|
-
this.hide = (event
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
this.hide = function (event) {
|
|
88
|
+
let documentClick = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
89
|
+
const _this$props2 = _this.props,
|
|
90
|
+
onHideContent = _this$props2.onHideContent,
|
|
91
|
+
isShowingContent = _this$props2.isShowingContent;
|
|
78
92
|
|
|
79
93
|
if (typeof isShowingContent === 'undefined') {
|
|
80
94
|
// uncontrolled, set state, fire callbacks
|
|
81
|
-
|
|
82
|
-
isShowingContent
|
|
83
|
-
|
|
95
|
+
_this.setState(_ref => {
|
|
96
|
+
let isShowingContent = _ref.isShowingContent;
|
|
97
|
+
|
|
84
98
|
if (isShowingContent) {
|
|
85
|
-
onHideContent(event, {
|
|
99
|
+
onHideContent === null || onHideContent === void 0 ? void 0 : onHideContent(event, {
|
|
86
100
|
documentClick
|
|
87
101
|
});
|
|
88
102
|
}
|
|
@@ -93,7 +107,7 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
93
107
|
});
|
|
94
108
|
} else if (isShowingContent) {
|
|
95
109
|
// controlled, fire callback
|
|
96
|
-
onHideContent(event, {
|
|
110
|
+
onHideContent === null || onHideContent === void 0 ? void 0 : onHideContent(event, {
|
|
97
111
|
documentClick
|
|
98
112
|
});
|
|
99
113
|
}
|
|
@@ -107,16 +121,17 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
107
121
|
}
|
|
108
122
|
};
|
|
109
123
|
|
|
110
|
-
this.handleDialogDismiss = (
|
|
124
|
+
this.handleDialogDismiss = (event, documentClick) => {
|
|
111
125
|
if (!this.props.shouldReturnFocus && this.props.shouldFocusContentOnTriggerBlur) {
|
|
112
126
|
const trigger = findDOMNode(this._trigger);
|
|
113
127
|
|
|
114
128
|
if (trigger && typeof trigger.focus === 'function') {
|
|
129
|
+
;
|
|
115
130
|
trigger.focus();
|
|
116
131
|
}
|
|
117
132
|
}
|
|
118
133
|
|
|
119
|
-
this.hide(
|
|
134
|
+
this.hide(event, documentClick);
|
|
120
135
|
};
|
|
121
136
|
|
|
122
137
|
this.handleDialogBlur = event => {
|
|
@@ -151,7 +166,9 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
151
166
|
};
|
|
152
167
|
|
|
153
168
|
this.handleTriggerBlur = event => {
|
|
154
|
-
|
|
169
|
+
const on = this.props.on;
|
|
170
|
+
|
|
171
|
+
if (on && on.indexOf('focus') > -1) {
|
|
155
172
|
this._raf.push(requestAnimationFrame(() => {
|
|
156
173
|
if (!containsActiveElement(this._view)) {
|
|
157
174
|
this.hide(event);
|
|
@@ -161,33 +178,33 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
161
178
|
};
|
|
162
179
|
|
|
163
180
|
this.handlePositioned = position => {
|
|
181
|
+
var _this$props$onPositio, _this$props3;
|
|
182
|
+
|
|
164
183
|
const placement = position.placement;
|
|
165
184
|
this.setState({
|
|
166
185
|
placement,
|
|
167
186
|
...this.computeOffsets(placement)
|
|
168
187
|
});
|
|
169
|
-
this.props.onPositioned(position);
|
|
188
|
+
(_this$props$onPositio = (_this$props3 = this.props).onPositioned) === null || _this$props$onPositio === void 0 ? void 0 : _this$props$onPositio.call(_this$props3, position);
|
|
170
189
|
};
|
|
171
190
|
|
|
172
191
|
this.handlePositionChanged = position => {
|
|
192
|
+
var _this$props$onPositio2, _this$props4;
|
|
193
|
+
|
|
173
194
|
const placement = position.placement;
|
|
174
195
|
this.setState({
|
|
175
196
|
placement,
|
|
176
197
|
...this.computeOffsets(placement)
|
|
177
198
|
});
|
|
178
|
-
this.props.onPositionChanged(position);
|
|
199
|
+
(_this$props$onPositio2 = (_this$props4 = this.props).onPositionChanged) === null || _this$props$onPositio2 === void 0 ? void 0 : _this$props$onPositio2.call(_this$props4, position);
|
|
179
200
|
};
|
|
180
201
|
|
|
181
202
|
this.state = {
|
|
182
203
|
placement: props.placement,
|
|
183
204
|
offsetX: props.offsetX,
|
|
184
|
-
offsetY: props.offsetY
|
|
205
|
+
offsetY: props.offsetY,
|
|
206
|
+
isShowingContent: typeof props.isShowingContent === 'undefined' ? props.defaultIsShowingContent : void 0
|
|
185
207
|
};
|
|
186
|
-
|
|
187
|
-
if (typeof props.isShowingContent === 'undefined') {
|
|
188
|
-
this.state.isShowingContent = props.defaultIsShowingContent;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
208
|
this._id = this.props.id || uid('Popover');
|
|
192
209
|
this._raf = [];
|
|
193
210
|
this._handleMouseOver = handleMouseOverOut.bind(null, event => {
|
|
@@ -200,7 +217,6 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
200
217
|
this.hide(event);
|
|
201
218
|
}, 1);
|
|
202
219
|
});
|
|
203
|
-
this.mouseOutTimeout = void 0;
|
|
204
220
|
}
|
|
205
221
|
|
|
206
222
|
get isTooltip() {
|
|
@@ -236,11 +252,11 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
236
252
|
}
|
|
237
253
|
}
|
|
238
254
|
|
|
239
|
-
shouldComponentUpdate(nextProps, nextState
|
|
255
|
+
shouldComponentUpdate(nextProps, nextState) {
|
|
240
256
|
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
|
|
241
257
|
}
|
|
242
258
|
|
|
243
|
-
componentDidUpdate(prevProps, prevState
|
|
259
|
+
componentDidUpdate(prevProps, prevState) {
|
|
244
260
|
if (this._focusRegion && this.isTooltip) {
|
|
245
261
|
// if focus region exists, popover is acting as a tooltip
|
|
246
262
|
// so we manually activate and deactivate the region when showing/hiding
|
|
@@ -267,19 +283,19 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
267
283
|
}
|
|
268
284
|
|
|
269
285
|
computeOffsets(placement) {
|
|
270
|
-
let _this$
|
|
271
|
-
offsetX = _this$
|
|
272
|
-
offsetY = _this$
|
|
286
|
+
let _this$props5 = this.props,
|
|
287
|
+
offsetX = _this$props5.offsetX,
|
|
288
|
+
offsetY = _this$props5.offsetY;
|
|
273
289
|
|
|
274
290
|
if (this.props.shouldAlignArrow && this._view) {
|
|
275
291
|
const secondaryPlacement = parsePlacement(placement)[1]; // arrowSize and arrowBorderWidth are component theme variables
|
|
276
292
|
// declared in ContextView's styles.js
|
|
277
293
|
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
arrowSize =
|
|
281
|
-
|
|
282
|
-
arrowBorderWidth =
|
|
294
|
+
const _ref2 = this._view.props.styles,
|
|
295
|
+
_ref2$arrowSize = _ref2.arrowSize,
|
|
296
|
+
arrowSize = _ref2$arrowSize === void 0 ? 0 : _ref2$arrowSize,
|
|
297
|
+
_ref2$arrowBorderWidt = _ref2.arrowBorderWidth,
|
|
298
|
+
arrowBorderWidth = _ref2$arrowBorderWidt === void 0 ? 0 : _ref2$arrowBorderWidt;
|
|
283
299
|
const offsetAmount = (px(arrowSize) + px(arrowBorderWidth)) * 2;
|
|
284
300
|
|
|
285
301
|
if (secondaryPlacement === 'start') {
|
|
@@ -339,28 +355,28 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
339
355
|
let trigger = callRenderProp(this.props.renderTrigger);
|
|
340
356
|
|
|
341
357
|
if (trigger) {
|
|
342
|
-
const _this$
|
|
343
|
-
on = _this$
|
|
344
|
-
shouldContainFocus = _this$
|
|
345
|
-
let onClick;
|
|
346
|
-
let onFocus;
|
|
347
|
-
let onMouseOut;
|
|
348
|
-
let onMouseOver;
|
|
358
|
+
const _this$props6 = this.props,
|
|
359
|
+
on = _this$props6.on,
|
|
360
|
+
shouldContainFocus = _this$props6.shouldContainFocus;
|
|
361
|
+
let onClick = void 0;
|
|
362
|
+
let onFocus = void 0;
|
|
363
|
+
let onMouseOut = void 0;
|
|
364
|
+
let onMouseOver = void 0;
|
|
349
365
|
let expanded;
|
|
350
366
|
|
|
351
|
-
if (on.indexOf('click') > -1) {
|
|
367
|
+
if (on && on.indexOf('click') > -1) {
|
|
352
368
|
onClick = event => {
|
|
353
369
|
this.toggle(event);
|
|
354
370
|
};
|
|
355
371
|
}
|
|
356
372
|
|
|
357
|
-
if (on.indexOf('hover') > -1) {
|
|
373
|
+
if (on && on.indexOf('hover') > -1) {
|
|
358
374
|
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.');
|
|
359
375
|
onMouseOver = this._handleMouseOver;
|
|
360
376
|
onMouseOut = this._handleMouseOut;
|
|
361
377
|
}
|
|
362
378
|
|
|
363
|
-
if (on.indexOf('focus') > -1) {
|
|
379
|
+
if (on && on.indexOf('focus') > -1) {
|
|
364
380
|
onFocus = event => {
|
|
365
381
|
this.show(event);
|
|
366
382
|
};
|
|
@@ -370,11 +386,13 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
370
386
|
// only set aria-expanded if popover can contain focus
|
|
371
387
|
expanded = this.shown ? 'true' : 'false';
|
|
372
388
|
} else {
|
|
373
|
-
expanded =
|
|
389
|
+
expanded = void 0;
|
|
374
390
|
}
|
|
375
391
|
|
|
376
392
|
trigger = safeCloneElement(trigger, {
|
|
377
|
-
ref: el =>
|
|
393
|
+
ref: el => {
|
|
394
|
+
this._trigger = el;
|
|
395
|
+
},
|
|
378
396
|
'aria-expanded': expanded,
|
|
379
397
|
'data-popover-trigger': true,
|
|
380
398
|
onKeyDown: createChainedFunction(this.handleTriggerKeyDown, this.props.onKeyDown),
|
|
@@ -414,30 +432,40 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
414
432
|
}
|
|
415
433
|
|
|
416
434
|
if (this.shown || this.props.shouldRenderOffscreen) {
|
|
417
|
-
let ViewElement;
|
|
418
435
|
const color = this.props.color;
|
|
419
436
|
let viewProps = {
|
|
437
|
+
// TODO: try to type `ref` better, LegacyRef<T> was not compatible
|
|
420
438
|
ref: c => this._view = c,
|
|
421
439
|
elementRef: el => {
|
|
440
|
+
var _this$props$contentRe, _this$props7;
|
|
441
|
+
|
|
422
442
|
this._contentElement = el;
|
|
423
|
-
this.props.contentRef(el);
|
|
443
|
+
(_this$props$contentRe = (_this$props7 = this.props).contentRef) === null || _this$props$contentRe === void 0 ? void 0 : _this$props$contentRe.call(_this$props7, el);
|
|
424
444
|
},
|
|
425
445
|
background: color,
|
|
426
446
|
stacking: this.props.stacking,
|
|
427
447
|
shadow: this.props.shadow,
|
|
428
448
|
display: 'block'
|
|
429
449
|
};
|
|
450
|
+
|
|
451
|
+
if (this.isTooltip) {
|
|
452
|
+
viewProps = { ...viewProps,
|
|
453
|
+
// Because of a11y reasons popovers should not be hidden when hovered over
|
|
454
|
+
onMouseOver: this._handleMouseOver,
|
|
455
|
+
onMouseOut: this._handleMouseOut
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
|
|
430
459
|
const placement = this.state.placement;
|
|
431
460
|
|
|
432
461
|
if (this.props.withArrow) {
|
|
433
|
-
ViewElement = ContextView;
|
|
434
462
|
viewProps = { ...viewProps,
|
|
435
463
|
// TODO: remove background override after contextview is updated
|
|
436
464
|
background: color === 'primary' ? 'default' : 'inverse',
|
|
437
465
|
placement: this.props.dir === textDirectionContextConsumer.DIRECTION.rtl ? mirrorHorizontalPlacement(placement, ' ') : placement
|
|
438
466
|
};
|
|
467
|
+
return /*#__PURE__*/React.createElement(ContextView, viewProps, content);
|
|
439
468
|
} else {
|
|
440
|
-
ViewElement = View;
|
|
441
469
|
viewProps = { ...viewProps,
|
|
442
470
|
borderWidth: 'small',
|
|
443
471
|
borderRadius: 'medium',
|
|
@@ -445,17 +473,8 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
445
473
|
borderColor: 'transparent'
|
|
446
474
|
})
|
|
447
475
|
};
|
|
476
|
+
return /*#__PURE__*/React.createElement(View, viewProps, content);
|
|
448
477
|
}
|
|
449
|
-
|
|
450
|
-
if (this.isTooltip) {
|
|
451
|
-
viewProps = { ...viewProps,
|
|
452
|
-
// Because of a11y reasons popovers should not be hidden when hovered over
|
|
453
|
-
onMouseOver: this._handleMouseOver,
|
|
454
|
-
onMouseOut: this._handleMouseOut
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return /*#__PURE__*/React.createElement(ViewElement, viewProps, content);
|
|
459
478
|
} else {
|
|
460
479
|
return null;
|
|
461
480
|
}
|
|
@@ -485,7 +504,6 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
485
504
|
offsetY: 0,
|
|
486
505
|
color: 'primary',
|
|
487
506
|
on: ['hover', 'focus'],
|
|
488
|
-
contentRef: el => {},
|
|
489
507
|
withArrow: true,
|
|
490
508
|
constrain: 'window',
|
|
491
509
|
insertAt: 'bottom',
|
|
@@ -496,22 +514,7 @@ let Popover = (_dec = textDirectionContextConsumer(), _dec2 = testable(), _dec(_
|
|
|
496
514
|
shouldReturnFocus: true,
|
|
497
515
|
shouldCloseOnDocumentClick: true,
|
|
498
516
|
shouldFocusContentOnTriggerBlur: false,
|
|
499
|
-
shouldCloseOnEscape: true
|
|
500
|
-
onShowContent: event => {},
|
|
501
|
-
onHideContent: (event, {
|
|
502
|
-
documentClick
|
|
503
|
-
}) => {},
|
|
504
|
-
onClick: event => {},
|
|
505
|
-
onFocus: event => {},
|
|
506
|
-
onBlur: event => {},
|
|
507
|
-
onMouseOver: event => {},
|
|
508
|
-
onMouseOut: event => {},
|
|
509
|
-
onKeyDown: event => {},
|
|
510
|
-
onKeyUp: event => {},
|
|
511
|
-
onPositioned: position => {},
|
|
512
|
-
onPositionChanged: position => {},
|
|
513
|
-
renderTrigger: null,
|
|
514
|
-
children: null
|
|
517
|
+
shouldCloseOnEscape: true
|
|
515
518
|
}, _temp)) || _class) || _class);
|
|
516
519
|
export default Popover;
|
|
517
520
|
export { Popover };
|
package/es/Popover/props.js
CHANGED
|
@@ -25,222 +25,47 @@ import PropTypes from 'prop-types';
|
|
|
25
25
|
import { element } from '@instructure/ui-prop-types';
|
|
26
26
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
27
27
|
import { PositionPropTypes } from '@instructure/ui-position';
|
|
28
|
-
// Copied list from "PositionPropTypes.placement" so that it appears as options in the properties table.
|
|
29
|
-
// TODO: try to use "PositionPropTypes.placement" again once Popover is fully typed and uses @tsProps
|
|
30
|
-
const placementPropValues = ['top', 'bottom', 'start', 'end', 'top start', 'top center', 'top end', 'top stretch', 'bottom start', 'bottom center', 'bottom end', 'bottom stretch', 'start top', 'start center', 'start bottom', 'start stretch', 'end top', 'end center', 'end bottom', 'end stretch', 'center start', 'center end', 'offscreen'];
|
|
31
28
|
const propTypes = {
|
|
32
|
-
/**
|
|
33
|
-
* Whether or not the `<Popover />` content is shown
|
|
34
|
-
*/
|
|
35
29
|
isShowingContent: PropTypes.bool,
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Whether or not to show the content by default, when uncontrolled
|
|
39
|
-
*/
|
|
40
30
|
defaultIsShowingContent: PropTypes.bool,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The action that causes the content to display (`click`, `hover`, `focus`)
|
|
44
|
-
*/
|
|
45
31
|
on: PropTypes.oneOfType([PropTypes.oneOf(['click', 'hover', 'focus']), PropTypes.arrayOf(PropTypes.oneOf(['click', 'hover', 'focus']))]),
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Whether or not an arrow pointing to the trigger should be rendered
|
|
49
|
-
*/
|
|
50
32
|
withArrow: PropTypes.bool,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Color variant of the popover content
|
|
54
|
-
*/
|
|
55
33
|
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The placement of the content in relation to the trigger
|
|
59
|
-
*/
|
|
60
|
-
placement: PropTypes.oneOf(placementPropValues),
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Controls the shadow depth for the `<Popover />`
|
|
64
|
-
*/
|
|
34
|
+
placement: PositionPropTypes.placement,
|
|
65
35
|
shadow: ThemeablePropTypes.shadow,
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Controls the z-index depth for the `<Popover />` content
|
|
69
|
-
*/
|
|
70
36
|
stacking: ThemeablePropTypes.stacking,
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A function that returns a reference to the content element
|
|
74
|
-
*/
|
|
75
37
|
contentRef: PropTypes.func,
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* An element or a function returning an element to focus by default
|
|
79
|
-
*/
|
|
80
38
|
defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* An accessible label for the `<Popover />` content
|
|
84
|
-
*/
|
|
85
39
|
screenReaderLabel: PropTypes.string,
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The horizontal offset for the positioned content
|
|
89
|
-
*/
|
|
90
40
|
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* The vertical offset for the positioned content
|
|
94
|
-
*/
|
|
95
41
|
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The parent in which to constrain the popover.
|
|
99
|
-
* One of: 'window', 'scroll-parent', 'parent', 'none', an element,
|
|
100
|
-
* or a function returning an element
|
|
101
|
-
*/
|
|
102
42
|
constrain: PositionPropTypes.constrain,
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Target element for positioning the Popover (if it differs from the trigger)
|
|
106
|
-
*/
|
|
107
43
|
positionTarget: PropTypes.oneOfType([element, PropTypes.func]),
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* An element or a function returning an element to use as the mount node
|
|
111
|
-
* for the `<Popover />` (defaults to `document.body`)
|
|
112
|
-
*/
|
|
113
44
|
mountNode: PositionPropTypes.mountNode,
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Insert the element at the 'top' of the mountNode or at the 'bottom'
|
|
117
|
-
*/
|
|
118
45
|
insertAt: PropTypes.oneOf(['bottom', 'top']),
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* An element, function returning an element, or array of elements that will
|
|
122
|
-
* not be hidden from the screen reader when the `<Popover />` is open
|
|
123
|
-
*/
|
|
124
46
|
liveRegion: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.func]),
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* An id is generated if not supplied.
|
|
128
|
-
*/
|
|
129
47
|
id: PropTypes.string,
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Whether or not the content should offset to align by its arrow
|
|
133
|
-
*/
|
|
134
48
|
shouldAlignArrow: PropTypes.bool,
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Whether or not position should be tracked or just set on initial render
|
|
138
|
-
*/
|
|
139
49
|
shouldTrackPosition: PropTypes.bool,
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Should the `<Popover />` render offscreen when visually hidden
|
|
143
|
-
*/
|
|
144
50
|
shouldRenderOffscreen: PropTypes.bool,
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Whether focus should contained within the `<Popover/>` when it is open
|
|
148
|
-
*/
|
|
149
51
|
shouldContainFocus: PropTypes.bool,
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Whether focus should be returned to the trigger when the `<Popover/>` is closed
|
|
153
|
-
*/
|
|
154
52
|
shouldReturnFocus: PropTypes.bool,
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Should the `<Popover />` hide when clicks occur outside the content
|
|
158
|
-
*/
|
|
159
53
|
shouldCloseOnDocumentClick: PropTypes.bool,
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Should the `<Popover />` hide when the escape key is pressed
|
|
163
|
-
*/
|
|
164
54
|
shouldCloseOnEscape: PropTypes.bool,
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Should the content become focused when the trigger is blurred
|
|
168
|
-
*/
|
|
169
55
|
shouldFocusContentOnTriggerBlur: PropTypes.bool,
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Callback fired when content is shown. When controlled, this callback is
|
|
173
|
-
* fired when the Popover expects to be shown
|
|
174
|
-
*/
|
|
175
56
|
onShowContent: PropTypes.func,
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Callback fired when content is hidden. When controlled, this callback is
|
|
179
|
-
* fired when the Popover expects to be hidden
|
|
180
|
-
*/
|
|
181
57
|
onHideContent: PropTypes.func,
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Callback fired when content has been is initially positioned.
|
|
185
|
-
* If `shouldRenderOffscreen` is true, it will only fire once, the first
|
|
186
|
-
* time the content is shown
|
|
187
|
-
*/
|
|
188
58
|
onPositioned: PropTypes.func,
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Callback fired when the position changes
|
|
192
|
-
*/
|
|
193
59
|
onPositionChanged: PropTypes.func,
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Callback fired when component is clicked
|
|
197
|
-
*/
|
|
198
60
|
onClick: PropTypes.func,
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Callback fired when trigger is focused
|
|
202
|
-
*/
|
|
203
61
|
onFocus: PropTypes.func,
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Callback fired when component is blurred
|
|
207
|
-
*/
|
|
208
62
|
onBlur: PropTypes.func,
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Callback fired on keydown
|
|
212
|
-
*/
|
|
213
63
|
onKeyDown: PropTypes.func,
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Callback fired on keyup
|
|
217
|
-
*/
|
|
218
64
|
onKeyUp: PropTypes.func,
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
/**
|
|
222
|
-
* Callback fired when mouse is over trigger
|
|
223
|
-
*/
|
|
224
65
|
onMouseOver: PropTypes.func,
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Callback fired when mouse leaves trigger
|
|
228
|
-
*/
|
|
229
66
|
onMouseOut: PropTypes.func,
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* The element that triggers the popover
|
|
233
|
-
*/
|
|
234
67
|
renderTrigger: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* The content to be shown by the popover
|
|
238
|
-
*/
|
|
239
68
|
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Provides a reference to the underlying HTML root element
|
|
243
|
-
*/
|
|
244
69
|
elementRef: PropTypes.func
|
|
245
70
|
};
|
|
246
71
|
const allowedProps = ['isShowingContent', 'defaultIsShowingContent', 'on', 'withArrow', 'color', 'placement', 'shadow', 'stacking', 'contentRef', 'defaultFocusElement', 'screenReaderLabel', 'offsetX', 'offsetY', 'constrain', 'positionTarget', 'mountNode', 'insertAt', 'liveRegion', 'id', 'shouldAlignArrow', 'shouldTrackPosition', 'shouldRenderOffscreen', 'shouldContainFocus', 'shouldReturnFocus', 'shouldCloseOnDocumentClick', 'shouldCloseOnEscape', 'shouldFocusContentOnTriggerBlur', 'onShowContent', 'onHideContent', 'onPositioned', 'onPositionChanged', 'onClick', 'onFocus', 'onBlur', 'onKeyDown', 'onKeyUp', 'onMouseOver', 'onMouseOut', 'renderTrigger', 'children', 'elementRef'];
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.PopoverLocator = void 0;
|
|
6
7
|
Object.defineProperty(exports, "PopoverTriggerLocator", {
|
|
7
8
|
enumerable: true,
|
|
8
9
|
get: function () {
|
|
9
10
|
return _PopoverTriggerLocator.PopoverTriggerLocator;
|
|
10
11
|
}
|
|
11
12
|
});
|
|
12
|
-
exports.
|
|
13
|
+
exports.customMethods = void 0;
|
|
13
14
|
|
|
14
15
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
15
16
|
|
|
@@ -44,9 +45,15 @@ var _PopoverTriggerLocator = require("./PopoverTriggerLocator");
|
|
|
44
45
|
*/
|
|
45
46
|
// eslint-disable-next-line no-restricted-imports
|
|
46
47
|
const customMethods = {
|
|
47
|
-
findContent: (
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
findContent: function () {
|
|
49
|
+
return _PositionLocator.PositionLocator.findContent(...arguments);
|
|
50
|
+
},
|
|
51
|
+
findPositionTarget: function () {
|
|
52
|
+
return _PositionLocator.PositionLocator.findTarget(...arguments);
|
|
53
|
+
},
|
|
54
|
+
findTrigger: function () {
|
|
55
|
+
return _PopoverTriggerLocator.PopoverTriggerLocator.find(...arguments);
|
|
56
|
+
}
|
|
50
57
|
};
|
|
51
58
|
exports.customMethods = customMethods;
|
|
52
59
|
const PopoverLocator = (0, _locator.locator)(_index.Popover.selector, customMethods);
|