@khanacademy/wonder-blocks-popover 2.0.4 → 2.0.6
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 +23 -0
- package/dist/components/close-button.js.flow +1 -2
- package/dist/components/focus-manager.js.flow +1 -2
- package/dist/components/initial-focus.js.flow +1 -2
- package/dist/components/popover-anchor.js.flow +1 -2
- package/dist/components/popover-content-core.js.flow +1 -2
- package/dist/components/popover-content.js.flow +1 -2
- package/dist/components/popover-context.js.flow +1 -2
- package/dist/components/popover-dialog.js.flow +1 -2
- package/dist/components/popover-event-listener.js.flow +1 -2
- package/dist/components/popover.js.flow +1 -2
- package/dist/es/index.js +135 -197
- package/dist/index.js +135 -197
- package/dist/index.js.flow +1 -2
- package/dist/util/util.js.flow +1 -2
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -55,39 +55,20 @@ function _extends() {
|
|
|
55
55
|
return _extends.apply(this, arguments);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function _setPrototypeOf(o, p) {
|
|
59
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
60
|
-
o.__proto__ = p;
|
|
61
|
-
return o;
|
|
62
|
-
};
|
|
63
|
-
return _setPrototypeOf(o, p);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function _inheritsLoose(subClass, superClass) {
|
|
67
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
68
|
-
subClass.prototype.constructor = subClass;
|
|
69
|
-
_setPrototypeOf(subClass, superClass);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
58
|
const defaultContext = {
|
|
73
59
|
close: undefined,
|
|
74
60
|
placement: "top"
|
|
75
61
|
};
|
|
76
62
|
var PopoverContext = React__namespace.createContext(defaultContext);
|
|
77
63
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
function PopoverAnchor() {
|
|
81
|
-
return _React$Component.apply(this, arguments) || this;
|
|
82
|
-
}
|
|
83
|
-
var _proto = PopoverAnchor.prototype;
|
|
84
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
64
|
+
class PopoverAnchor extends React__namespace.Component {
|
|
65
|
+
componentDidMount() {
|
|
85
66
|
const anchorNode = ReactDOM__namespace.findDOMNode(this);
|
|
86
67
|
if (anchorNode) {
|
|
87
68
|
this.props.anchorRef(anchorNode);
|
|
88
69
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
91
72
|
const {
|
|
92
73
|
children,
|
|
93
74
|
id,
|
|
@@ -114,22 +95,16 @@ let PopoverAnchor = function (_React$Component) {
|
|
|
114
95
|
} : onClick
|
|
115
96
|
}));
|
|
116
97
|
}
|
|
117
|
-
};
|
|
118
|
-
return PopoverAnchor;
|
|
119
|
-
}(React__namespace.Component);
|
|
120
|
-
|
|
121
|
-
let PopoverDialog = function (_React$Component) {
|
|
122
|
-
_inheritsLoose(PopoverDialog, _React$Component);
|
|
123
|
-
function PopoverDialog() {
|
|
124
|
-
return _React$Component.apply(this, arguments) || this;
|
|
125
98
|
}
|
|
126
|
-
|
|
127
|
-
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
class PopoverDialog extends React__namespace.Component {
|
|
102
|
+
componentDidUpdate(prevProps) {
|
|
128
103
|
if (prevProps.placement !== this.props.placement) {
|
|
129
104
|
this.props.onUpdate(this.props.placement);
|
|
130
105
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
133
108
|
const {
|
|
134
109
|
placement,
|
|
135
110
|
children,
|
|
@@ -156,9 +131,8 @@ let PopoverDialog = function (_React$Component) {
|
|
|
156
131
|
placement: placement,
|
|
157
132
|
offset: tailOffset
|
|
158
133
|
})));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
}(React__namespace.Component);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
162
136
|
const styles$2 = aphrodite.StyleSheet.create({
|
|
163
137
|
hide: {
|
|
164
138
|
pointerEvents: "none",
|
|
@@ -185,13 +159,11 @@ function findFocusableNodes(root) {
|
|
|
185
159
|
return Array.from(root.querySelectorAll(FOCUSABLE_ELEMENTS));
|
|
186
160
|
}
|
|
187
161
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
_this.setInitialFocusableElement = node => {
|
|
194
|
-
const firstFocusableElement = _this.maybeGetInitialFocusElement(node) || _this.maybeGetFirstFocusableElement(node) || node;
|
|
162
|
+
class InitialFocus extends React__namespace.Component {
|
|
163
|
+
constructor(...args) {
|
|
164
|
+
super(...args);
|
|
165
|
+
this.setInitialFocusableElement = node => {
|
|
166
|
+
const firstFocusableElement = this.maybeGetInitialFocusElement(node) || this.maybeGetFirstFocusableElement(node) || node;
|
|
195
167
|
if (firstFocusableElement === node) {
|
|
196
168
|
node.tabIndex = -1;
|
|
197
169
|
}
|
|
@@ -199,17 +171,15 @@ let InitialFocus = function (_React$Component) {
|
|
|
199
171
|
firstFocusableElement.focus();
|
|
200
172
|
}, 0);
|
|
201
173
|
};
|
|
202
|
-
return _this;
|
|
203
174
|
}
|
|
204
|
-
|
|
205
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
175
|
+
componentDidMount() {
|
|
206
176
|
const node = ReactDOM__namespace.findDOMNode(this);
|
|
207
177
|
if (!node) {
|
|
208
178
|
return;
|
|
209
179
|
}
|
|
210
180
|
this.setInitialFocusableElement(node);
|
|
211
|
-
}
|
|
212
|
-
|
|
181
|
+
}
|
|
182
|
+
maybeGetInitialFocusElement(node) {
|
|
213
183
|
const {
|
|
214
184
|
initialFocusId
|
|
215
185
|
} = this.props;
|
|
@@ -217,45 +187,42 @@ let InitialFocus = function (_React$Component) {
|
|
|
217
187
|
return null;
|
|
218
188
|
}
|
|
219
189
|
return node.querySelector(`#${initialFocusId}`);
|
|
220
|
-
}
|
|
221
|
-
|
|
190
|
+
}
|
|
191
|
+
maybeGetFirstFocusableElement(node) {
|
|
222
192
|
const focusableElements = findFocusableNodes(node);
|
|
223
193
|
if (!focusableElements.length) {
|
|
224
194
|
return null;
|
|
225
195
|
}
|
|
226
196
|
return focusableElements[0];
|
|
227
|
-
}
|
|
228
|
-
|
|
197
|
+
}
|
|
198
|
+
render() {
|
|
229
199
|
return this.props.children;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
}(React__namespace.Component);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
233
202
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
_this.focusableElementsInPopover = [];
|
|
242
|
-
_this.addEventListeners = () => {
|
|
203
|
+
class FocusManager extends React__namespace.Component {
|
|
204
|
+
constructor(...args) {
|
|
205
|
+
super(...args);
|
|
206
|
+
this.nextElementAfterPopover = void 0;
|
|
207
|
+
this.rootNode = void 0;
|
|
208
|
+
this.focusableElementsInPopover = [];
|
|
209
|
+
this.addEventListeners = () => {
|
|
243
210
|
const {
|
|
244
211
|
anchorElement
|
|
245
|
-
} =
|
|
212
|
+
} = this.props;
|
|
246
213
|
if (anchorElement) {
|
|
247
|
-
anchorElement.addEventListener("keydown",
|
|
214
|
+
anchorElement.addEventListener("keydown", this.handleKeydownPreviousFocusableElement, true);
|
|
248
215
|
}
|
|
249
|
-
|
|
250
|
-
if (
|
|
251
|
-
|
|
216
|
+
this.nextElementAfterPopover = this.getNextFocusableElement();
|
|
217
|
+
if (this.nextElementAfterPopover) {
|
|
218
|
+
this.nextElementAfterPopover.addEventListener("keydown", this.handleKeydownNextFocusableElement, true);
|
|
252
219
|
}
|
|
253
220
|
};
|
|
254
|
-
|
|
221
|
+
this.getNextFocusableElement = () => {
|
|
255
222
|
const {
|
|
256
223
|
anchorElement
|
|
257
|
-
} =
|
|
258
|
-
if (!anchorElement ||
|
|
224
|
+
} = this.props;
|
|
225
|
+
if (!anchorElement || this.nextElementAfterPopover) {
|
|
259
226
|
return;
|
|
260
227
|
}
|
|
261
228
|
const focusableElements = findFocusableNodes(document);
|
|
@@ -266,7 +233,7 @@ let FocusManager = function (_React$Component) {
|
|
|
266
233
|
}
|
|
267
234
|
return;
|
|
268
235
|
};
|
|
269
|
-
|
|
236
|
+
this.getComponentRootNode = node => {
|
|
270
237
|
if (!node) {
|
|
271
238
|
return;
|
|
272
239
|
}
|
|
@@ -274,42 +241,40 @@ let FocusManager = function (_React$Component) {
|
|
|
274
241
|
if (!rootNode) {
|
|
275
242
|
throw new Error("Assertion error: root node should exist after mount");
|
|
276
243
|
}
|
|
277
|
-
|
|
278
|
-
|
|
244
|
+
this.rootNode = rootNode;
|
|
245
|
+
this.focusableElementsInPopover = findFocusableNodes(this.rootNode);
|
|
279
246
|
};
|
|
280
|
-
|
|
281
|
-
if (
|
|
282
|
-
|
|
247
|
+
this.handleFocusPreviousFocusableElement = () => {
|
|
248
|
+
if (this.props.anchorElement) {
|
|
249
|
+
this.props.anchorElement.focus();
|
|
283
250
|
}
|
|
284
251
|
};
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
|
|
252
|
+
this.handleFocusNextFocusableElement = () => {
|
|
253
|
+
if (this.nextElementAfterPopover) {
|
|
254
|
+
this.nextElementAfterPopover.focus();
|
|
288
255
|
}
|
|
289
256
|
};
|
|
290
|
-
|
|
257
|
+
this.handleKeydownPreviousFocusableElement = e => {
|
|
291
258
|
if (e.key === "Tab" && !e.shiftKey) {
|
|
292
259
|
e.preventDefault();
|
|
293
|
-
|
|
260
|
+
this.focusableElementsInPopover[0].focus();
|
|
294
261
|
}
|
|
295
262
|
};
|
|
296
|
-
|
|
263
|
+
this.handleKeydownNextFocusableElement = e => {
|
|
297
264
|
if (e.key === "Tab" && e.shiftKey) {
|
|
298
265
|
e.preventDefault();
|
|
299
|
-
const lastElementIndex =
|
|
300
|
-
|
|
266
|
+
const lastElementIndex = this.focusableElementsInPopover.length - 1;
|
|
267
|
+
this.focusableElementsInPopover[lastElementIndex].focus();
|
|
301
268
|
}
|
|
302
269
|
};
|
|
303
|
-
return _this;
|
|
304
270
|
}
|
|
305
|
-
|
|
306
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
271
|
+
componentDidMount() {
|
|
307
272
|
this.addEventListeners();
|
|
308
|
-
}
|
|
309
|
-
|
|
273
|
+
}
|
|
274
|
+
componentDidUpdate() {
|
|
310
275
|
this.addEventListeners();
|
|
311
|
-
}
|
|
312
|
-
|
|
276
|
+
}
|
|
277
|
+
componentWillUnmount() {
|
|
313
278
|
const {
|
|
314
279
|
anchorElement
|
|
315
280
|
} = this.props;
|
|
@@ -320,8 +285,8 @@ let FocusManager = function (_React$Component) {
|
|
|
320
285
|
if (this.nextElementAfterPopover) {
|
|
321
286
|
this.nextElementAfterPopover.removeEventListener("keydown", this.handleKeydownNextFocusableElement, true);
|
|
322
287
|
}
|
|
323
|
-
}
|
|
324
|
-
|
|
288
|
+
}
|
|
289
|
+
render() {
|
|
325
290
|
const {
|
|
326
291
|
children
|
|
327
292
|
} = this.props;
|
|
@@ -342,103 +307,94 @@ let FocusManager = function (_React$Component) {
|
|
|
342
307
|
position: "fixed"
|
|
343
308
|
}
|
|
344
309
|
}));
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
}(React__namespace.Component);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
348
312
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
354
|
-
_this.state = {
|
|
313
|
+
class PopoverEventListener extends React__namespace.Component {
|
|
314
|
+
constructor(...args) {
|
|
315
|
+
super(...args);
|
|
316
|
+
this.state = {
|
|
355
317
|
isFirstClick: true
|
|
356
318
|
};
|
|
357
|
-
|
|
319
|
+
this._handleKeyup = e => {
|
|
358
320
|
if (e.key === "Escape") {
|
|
359
321
|
e.preventDefault();
|
|
360
322
|
e.stopPropagation();
|
|
361
|
-
|
|
323
|
+
this.props.onClose();
|
|
362
324
|
}
|
|
363
325
|
};
|
|
364
|
-
|
|
326
|
+
this._handleClick = e => {
|
|
365
327
|
var _this$props$contentRe;
|
|
366
|
-
if (
|
|
367
|
-
|
|
328
|
+
if (this.state.isFirstClick) {
|
|
329
|
+
this.setState({
|
|
368
330
|
isFirstClick: false
|
|
369
331
|
});
|
|
370
332
|
return;
|
|
371
333
|
}
|
|
372
|
-
const node = ReactDOM__namespace.findDOMNode((_this$props$contentRe =
|
|
334
|
+
const node = ReactDOM__namespace.findDOMNode((_this$props$contentRe = this.props.contentRef) == null ? void 0 : _this$props$contentRe.current);
|
|
373
335
|
if (node && !node.contains(e.target)) {
|
|
374
336
|
e.preventDefault();
|
|
375
337
|
e.stopPropagation();
|
|
376
|
-
|
|
338
|
+
this.props.onClose();
|
|
377
339
|
}
|
|
378
340
|
};
|
|
379
|
-
return _this;
|
|
380
341
|
}
|
|
381
|
-
|
|
382
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
342
|
+
componentDidMount() {
|
|
383
343
|
window.addEventListener("keyup", this._handleKeyup);
|
|
384
344
|
window.addEventListener("click", this._handleClick);
|
|
385
|
-
}
|
|
386
|
-
|
|
345
|
+
}
|
|
346
|
+
componentWillUnmount() {
|
|
387
347
|
window.removeEventListener("keyup", this._handleKeyup);
|
|
388
348
|
window.removeEventListener("click", this._handleClick);
|
|
389
|
-
}
|
|
390
|
-
|
|
349
|
+
}
|
|
350
|
+
render() {
|
|
391
351
|
return null;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
}(React__namespace.Component);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
395
354
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
_this.state = {
|
|
402
|
-
opened: !!_this.props.opened,
|
|
355
|
+
class Popover extends React__namespace.Component {
|
|
356
|
+
constructor(...args) {
|
|
357
|
+
super(...args);
|
|
358
|
+
this.state = {
|
|
359
|
+
opened: !!this.props.opened,
|
|
403
360
|
anchorElement: null,
|
|
404
|
-
placement:
|
|
361
|
+
placement: this.props.placement
|
|
405
362
|
};
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
363
|
+
this.contentRef = React__namespace.createRef();
|
|
364
|
+
this.handleClose = () => {
|
|
365
|
+
this.setState({
|
|
409
366
|
opened: false
|
|
410
367
|
}, () => {
|
|
411
|
-
_this
|
|
368
|
+
var _this$props$onClose, _this$props;
|
|
369
|
+
(_this$props$onClose = (_this$props = this.props).onClose) == null ? void 0 : _this$props$onClose.call(_this$props);
|
|
412
370
|
});
|
|
413
371
|
};
|
|
414
|
-
|
|
415
|
-
if (
|
|
416
|
-
|
|
372
|
+
this.handleOpen = () => {
|
|
373
|
+
if (this.props.dismissEnabled && this.state.opened) {
|
|
374
|
+
this.setState({
|
|
417
375
|
opened: false
|
|
418
376
|
});
|
|
419
377
|
} else {
|
|
420
|
-
|
|
378
|
+
this.setState({
|
|
421
379
|
opened: true
|
|
422
380
|
});
|
|
423
381
|
}
|
|
424
382
|
};
|
|
425
|
-
|
|
383
|
+
this.updateRef = ref => {
|
|
426
384
|
const actualRef = ref && ReactDOM__namespace.findDOMNode(ref);
|
|
427
|
-
if (actualRef &&
|
|
428
|
-
|
|
385
|
+
if (actualRef && this.state.anchorElement !== actualRef) {
|
|
386
|
+
this.setState({
|
|
429
387
|
anchorElement: actualRef
|
|
430
388
|
});
|
|
431
389
|
}
|
|
432
390
|
};
|
|
433
|
-
return _this;
|
|
434
391
|
}
|
|
435
|
-
|
|
392
|
+
static getDerivedStateFromProps(props, state) {
|
|
436
393
|
return {
|
|
437
394
|
opened: typeof props.opened === "boolean" ? props.opened : state.opened
|
|
438
395
|
};
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
_proto.renderContent = function renderContent() {
|
|
396
|
+
}
|
|
397
|
+
renderContent() {
|
|
442
398
|
const {
|
|
443
399
|
content
|
|
444
400
|
} = this.props;
|
|
@@ -448,8 +404,8 @@ let Popover = function (_React$Component) {
|
|
|
448
404
|
return React__namespace.cloneElement(popoverContents, {
|
|
449
405
|
ref: this.contentRef
|
|
450
406
|
});
|
|
451
|
-
}
|
|
452
|
-
|
|
407
|
+
}
|
|
408
|
+
renderPopper(uniqueId) {
|
|
453
409
|
const {
|
|
454
410
|
initialFocusId,
|
|
455
411
|
placement
|
|
@@ -470,11 +426,11 @@ let Popover = function (_React$Component) {
|
|
|
470
426
|
placement
|
|
471
427
|
})
|
|
472
428
|
}), this.renderContent())));
|
|
473
|
-
}
|
|
474
|
-
|
|
429
|
+
}
|
|
430
|
+
getHost() {
|
|
475
431
|
return wonderBlocksModal.maybeGetPortalMountedModalHostElement(this.state.anchorElement) || document.body;
|
|
476
|
-
}
|
|
477
|
-
|
|
432
|
+
}
|
|
433
|
+
render() {
|
|
478
434
|
const {
|
|
479
435
|
children,
|
|
480
436
|
dismissEnabled,
|
|
@@ -503,20 +459,14 @@ let Popover = function (_React$Component) {
|
|
|
503
459
|
onClose: this.handleClose,
|
|
504
460
|
contentRef: this.contentRef
|
|
505
461
|
}));
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
}(React__namespace.Component);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
509
464
|
Popover.defaultProps = {
|
|
510
465
|
placement: "top"
|
|
511
466
|
};
|
|
512
467
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
function CloseButton() {
|
|
516
|
-
return _React$Component.apply(this, arguments) || this;
|
|
517
|
-
}
|
|
518
|
-
var _proto = CloseButton.prototype;
|
|
519
|
-
_proto.render = function render() {
|
|
468
|
+
class CloseButton extends React__namespace.Component {
|
|
469
|
+
render() {
|
|
520
470
|
const {
|
|
521
471
|
light,
|
|
522
472
|
"aria-label": ariaLabel,
|
|
@@ -536,21 +486,15 @@ let CloseButton = function (_React$Component) {
|
|
|
536
486
|
testId: testId
|
|
537
487
|
});
|
|
538
488
|
});
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
}(React__namespace.Component);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
542
491
|
CloseButton.defaultProps = {
|
|
543
492
|
light: true,
|
|
544
493
|
"aria-label": "Close Popover"
|
|
545
494
|
};
|
|
546
495
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
function PopoverContentCore() {
|
|
550
|
-
return _React$Component.apply(this, arguments) || this;
|
|
551
|
-
}
|
|
552
|
-
var _proto = PopoverContentCore.prototype;
|
|
553
|
-
_proto.render = function render() {
|
|
496
|
+
class PopoverContentCore extends React__namespace.Component {
|
|
497
|
+
render() {
|
|
554
498
|
const {
|
|
555
499
|
children,
|
|
556
500
|
closeButtonLight,
|
|
@@ -569,9 +513,8 @@ let PopoverContentCore = function (_React$Component) {
|
|
|
569
513
|
style: styles$1.closeButton,
|
|
570
514
|
testId: `${testId || "popover"}-close-btn`
|
|
571
515
|
}), children);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
}(React__namespace.Component);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
575
518
|
PopoverContentCore.defaultProps = {
|
|
576
519
|
color: "white",
|
|
577
520
|
closeButtonLight: false,
|
|
@@ -606,17 +549,15 @@ const styles$1 = aphrodite.StyleSheet.create({
|
|
|
606
549
|
});
|
|
607
550
|
|
|
608
551
|
const StyledImage = wonderBlocksCore.addStyle("img");
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
|
614
|
-
_this.maybeRenderImage = ({
|
|
552
|
+
class PopoverContent extends React__namespace.Component {
|
|
553
|
+
constructor(...args) {
|
|
554
|
+
super(...args);
|
|
555
|
+
this.maybeRenderImage = ({
|
|
615
556
|
placement
|
|
616
557
|
}) => {
|
|
617
558
|
const {
|
|
618
559
|
image
|
|
619
|
-
} =
|
|
560
|
+
} = this.props;
|
|
620
561
|
if (!image) {
|
|
621
562
|
return null;
|
|
622
563
|
}
|
|
@@ -624,10 +565,10 @@ let PopoverContent = function (_React$Component) {
|
|
|
624
565
|
style: [styles.image, placement === "bottom" && styles.imageToBottom]
|
|
625
566
|
}, image);
|
|
626
567
|
};
|
|
627
|
-
|
|
568
|
+
this.maybeRenderIcon = () => {
|
|
628
569
|
const {
|
|
629
570
|
icon
|
|
630
|
-
} =
|
|
571
|
+
} = this.props;
|
|
631
572
|
if (!icon) {
|
|
632
573
|
return null;
|
|
633
574
|
}
|
|
@@ -638,10 +579,10 @@ let PopoverContent = function (_React$Component) {
|
|
|
638
579
|
style: styles.icon
|
|
639
580
|
}));
|
|
640
581
|
};
|
|
641
|
-
|
|
582
|
+
this.maybeRenderActions = close => {
|
|
642
583
|
const {
|
|
643
584
|
actions
|
|
644
|
-
} =
|
|
585
|
+
} = this.props;
|
|
645
586
|
if (!actions) {
|
|
646
587
|
return null;
|
|
647
588
|
}
|
|
@@ -651,10 +592,8 @@ let PopoverContent = function (_React$Component) {
|
|
|
651
592
|
close: close
|
|
652
593
|
}) : actions);
|
|
653
594
|
};
|
|
654
|
-
return _this;
|
|
655
595
|
}
|
|
656
|
-
|
|
657
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
596
|
+
componentDidMount() {
|
|
658
597
|
const {
|
|
659
598
|
icon,
|
|
660
599
|
image
|
|
@@ -662,15 +601,15 @@ let PopoverContent = function (_React$Component) {
|
|
|
662
601
|
if (image && icon) {
|
|
663
602
|
throw new Error("'image' and 'icon' cannot be used at the same time. You can fix this by either removing 'image' or 'icon' from your instance.");
|
|
664
603
|
}
|
|
665
|
-
}
|
|
666
|
-
|
|
604
|
+
}
|
|
605
|
+
validateProps({
|
|
667
606
|
placement
|
|
668
607
|
}) {
|
|
669
608
|
if (this.props.image && (placement === "left" || placement === "right")) {
|
|
670
609
|
throw new Error("'image' can only be vertically placed. You can fix this by either changing `placement` to `top` or `bottom` or removing the `image` prop inside `content`.");
|
|
671
610
|
}
|
|
672
|
-
}
|
|
673
|
-
|
|
611
|
+
}
|
|
612
|
+
render() {
|
|
674
613
|
const {
|
|
675
614
|
closeButtonLabel,
|
|
676
615
|
closeButtonVisible,
|
|
@@ -707,9 +646,8 @@ let PopoverContent = function (_React$Component) {
|
|
|
707
646
|
style: styles.title
|
|
708
647
|
}, title), React__namespace.createElement(wonderBlocksTypography.Body, null, content))), this.maybeRenderActions(close));
|
|
709
648
|
});
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
}(React__namespace.Component);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
713
651
|
PopoverContent.defaultProps = {
|
|
714
652
|
closeButtonVisible: false
|
|
715
653
|
};
|
package/dist/index.js.flow
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Flowtype definitions for
|
|
2
|
+
* Flowtype definitions for data
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import Popover from "./components/popover";
|
|
9
8
|
import PopoverContent from "./components/popover-content";
|
|
10
9
|
import PopoverContentCore from "./components/popover-content-core";
|
package/dist/util/util.js.flow
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Flowtype definitions for
|
|
2
|
+
* Flowtype definitions for data
|
|
3
3
|
* Generated by Flowgen from a Typescript Definition
|
|
4
4
|
* Flowgen v1.21.0
|
|
5
5
|
* @flow
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
declare export function findFocusableNodes(
|
|
9
8
|
root: HTMLElement | Document
|
|
10
9
|
): Array<HTMLElement>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-popover",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.18.6",
|
|
19
19
|
"@khanacademy/wonder-blocks-color": "^2.0.1",
|
|
20
|
-
"@khanacademy/wonder-blocks-core": "^5.0.
|
|
21
|
-
"@khanacademy/wonder-blocks-icon": "^2.0.
|
|
22
|
-
"@khanacademy/wonder-blocks-icon-button": "^4.0.
|
|
23
|
-
"@khanacademy/wonder-blocks-modal": "^4.0.
|
|
20
|
+
"@khanacademy/wonder-blocks-core": "^5.0.4",
|
|
21
|
+
"@khanacademy/wonder-blocks-icon": "^2.0.6",
|
|
22
|
+
"@khanacademy/wonder-blocks-icon-button": "^4.0.6",
|
|
23
|
+
"@khanacademy/wonder-blocks-modal": "^4.0.6",
|
|
24
24
|
"@khanacademy/wonder-blocks-spacing": "^4.0.1",
|
|
25
|
-
"@khanacademy/wonder-blocks-tooltip": "^2.0.
|
|
26
|
-
"@khanacademy/wonder-blocks-typography": "^2.0.
|
|
25
|
+
"@khanacademy/wonder-blocks-tooltip": "^2.0.6",
|
|
26
|
+
"@khanacademy/wonder-blocks-typography": "^2.0.6"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@popperjs/core": "^2.10.1",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"react-popper": "^2.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"wb-dev-build-settings": "^0.9.
|
|
36
|
+
"wb-dev-build-settings": "^0.9.5"
|
|
37
37
|
}
|
|
38
38
|
}
|