@instructure/ui-popover 11.7.3-snapshot-7 → 11.7.3-snapshot-26

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 CHANGED
@@ -3,9 +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
- ## [11.7.3-snapshot-7](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-7) (2026-04-29)
6
+ ## [11.7.3-snapshot-26](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-26) (2026-05-05)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-popover
8
+
9
+ ### Bug Fixes
10
+
11
+ * **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
9
12
 
10
13
 
11
14
 
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _dec3, _class, _Popover;
1
+ var _dec, _dec2, _dec3, _class;
2
2
  /*
3
3
  * The MIT License (MIT)
4
4
  *
@@ -45,144 +45,41 @@ category: components
45
45
  tags: overlay, portal, dialog
46
46
  ---
47
47
  **/
48
- let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsumer(), _dec3 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = _dec3(_class = (_Popover = class Popover extends Component {
48
+ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsumer(), _dec3 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = _dec3(_class = class Popover extends Component {
49
+ static displayName = "Popover";
50
+ static componentId = 'Popover';
51
+ static allowedProps = allowedProps;
52
+ static defaultProps = {
53
+ defaultIsShowingContent: false,
54
+ placement: 'bottom center',
55
+ stacking: 'topmost',
56
+ shadow: 'resting',
57
+ offsetX: 0,
58
+ offsetY: 0,
59
+ color: 'primary',
60
+ on: ['hover', 'focus'],
61
+ withArrow: true,
62
+ constrain: 'window',
63
+ insertAt: 'bottom',
64
+ shouldAlignArrow: false,
65
+ shouldTrackPosition: true,
66
+ shouldRenderOffscreen: false,
67
+ shouldContainFocus: false,
68
+ shouldReturnFocus: true,
69
+ shouldCloseOnDocumentClick: true,
70
+ shouldFocusContentOnTriggerBlur: false,
71
+ shouldCloseOnEscape: true,
72
+ shouldSetAriaExpanded: true
73
+ };
49
74
  constructor(props) {
50
75
  super(props);
51
- this._handleMouseOver = void 0;
52
- this._handleMouseOut = void 0;
53
- this._id = void 0;
54
- this._raf = [];
55
- this._trigger = null;
56
- this._view = null;
57
- this._dialog = null;
58
- this._contentElement = null;
59
- this._focusRegion = void 0;
60
- // renderTrigger needs to be a variable because if it's a function it will
61
- // recreate the trigger on each render which will trigger MouseOver events
62
- // that will make the tooltip reappear and the trigger cannot accept
63
- // onClick events (since the state change caused by MouseDown recreates it)
64
- this._renderTrigger = void 0;
65
- this._renderTriggerProp = void 0;
66
- this.mouseOutTimeout = void 0;
67
- this.ref = null;
68
- this.handleRef = el => {
69
- const elementRef = this.props.elementRef;
70
- this.ref = el;
71
- if (typeof elementRef === 'function') {
72
- elementRef(el);
73
- }
74
- };
75
- this.show = event => {
76
- var _this$props$onShowCon, _this$props;
77
- if (typeof this.props.isShowingContent === 'undefined') {
78
- this.setState({
79
- isShowingContent: true
80
- });
81
- }
82
- (_this$props$onShowCon = (_this$props = this.props).onShowContent) === null || _this$props$onShowCon === void 0 ? void 0 : _this$props$onShowCon.call(_this$props, event);
83
- };
84
- this.hide = (event, documentClick = false) => {
85
- const _this$props2 = this.props,
86
- onHideContent = _this$props2.onHideContent,
87
- isShowingContent = _this$props2.isShowingContent;
88
- if (typeof isShowingContent === 'undefined') {
89
- // uncontrolled, set state, fire callbacks
90
- this.setState(({
91
- isShowingContent
92
- }) => {
93
- if (isShowingContent) {
94
- onHideContent === null || onHideContent === void 0 ? void 0 : onHideContent(event, {
95
- documentClick
96
- });
97
- }
98
- return {
99
- isShowingContent: false
100
- };
101
- });
102
- } else if (isShowingContent) {
103
- // controlled, fire callback
104
- onHideContent === null || onHideContent === void 0 ? void 0 : onHideContent(event, {
105
- documentClick
106
- });
107
- }
108
- };
109
- this.toggle = event => {
110
- if (this.shown) {
111
- this.hide(event);
112
- } else {
113
- this.show(event);
114
- }
115
- };
116
- this.handleDialogDismiss = (event, documentClick) => {
117
- if (!this.props.shouldReturnFocus && this.props.shouldFocusContentOnTriggerBlur) {
118
- const trigger = findDOMNode(this._trigger);
119
- if (trigger && typeof trigger.focus === 'function') {
120
- ;
121
- trigger.focus();
122
- }
123
- }
124
- this.hide(event, documentClick);
125
- };
126
- this.handleDialogBlur = event => {
127
- if (event.keyCode === keycode.codes.tab && event.shiftKey && this.props.shouldFocusContentOnTriggerBlur) {
128
- return;
129
- }
130
- this.hide(event);
131
- };
132
- this.handleTriggerKeyDown = event => {
133
- if (!this.props.shouldFocusContentOnTriggerBlur) {
134
- return;
135
- }
136
- if (event.keyCode === keycode.codes.tab && !event.shiftKey) {
137
- event.preventDefault();
138
- this._raf.push(requestAnimationFrame(() => {
139
- this._dialog && this._dialog.focus();
140
- }));
141
- }
142
- };
143
- this.handleTriggerKeyUp = event => {
144
- if (event.keyCode === keycode.codes.esc && this.shown && this.isTooltip) {
145
- // if popover is tooltip, it is managing its own focus region so we need
146
- // to prevent esc keyup event from reaching FocusRegionManager
147
- event.preventDefault();
148
- this.hide(event);
149
- }
150
- };
151
- this.handleTriggerBlur = event => {
152
- const on = this.props.on;
153
- if (on && on.indexOf('focus') > -1) {
154
- this._raf.push(requestAnimationFrame(() => {
155
- if (!containsActiveElement(this._view)) {
156
- this.hide(event);
157
- }
158
- }));
159
- }
160
- };
161
- this.handlePositioned = position => {
162
- var _this$props$onPositio, _this$props3;
163
- const placement = position.placement;
164
- this.setState({
165
- placement,
166
- ...this.computeOffsets(placement)
167
- });
168
- (_this$props$onPositio = (_this$props3 = this.props).onPositioned) === null || _this$props$onPositio === void 0 ? void 0 : _this$props$onPositio.call(_this$props3, position);
169
- };
170
- this.handlePositionChanged = position => {
171
- var _this$props$onPositio2, _this$props4;
172
- const placement = position.placement;
173
- this.setState({
174
- placement,
175
- ...this.computeOffsets(placement)
176
- });
177
- (_this$props$onPositio2 = (_this$props4 = this.props).onPositionChanged) === null || _this$props$onPositio2 === void 0 ? void 0 : _this$props$onPositio2.call(_this$props4, position);
178
- };
179
76
  this._renderTriggerProp = this.props.renderTrigger;
180
77
  this._renderTrigger = callRenderProp(this.props.renderTrigger);
181
78
  this.state = {
182
79
  placement: props.placement,
183
80
  offsetX: props.offsetX,
184
81
  offsetY: props.offsetY,
185
- isShowingContent: typeof props.isShowingContent === 'undefined' ? props.defaultIsShowingContent : void 0
82
+ isShowingContent: typeof props.isShowingContent === 'undefined' ? props.defaultIsShowingContent : undefined
186
83
  };
187
84
  this._id = this.props.id || props.deterministicId();
188
85
  this._raf = [];
@@ -197,6 +94,32 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
197
94
  }, 1);
198
95
  });
199
96
  }
97
+ _handleMouseOver;
98
+ _handleMouseOut;
99
+ _id;
100
+ _raf = [];
101
+ _trigger = null;
102
+ _view = null;
103
+ _dialog = null;
104
+ _contentElement = null;
105
+ _focusRegion;
106
+ // renderTrigger needs to be a variable because if it's a function it will
107
+ // recreate the trigger on each render which will trigger MouseOver events
108
+ // that will make the tooltip reappear and the trigger cannot accept
109
+ // onClick events (since the state change caused by MouseDown recreates it)
110
+ _renderTrigger;
111
+ _renderTriggerProp;
112
+ mouseOutTimeout;
113
+ ref = null;
114
+ handleRef = el => {
115
+ const {
116
+ elementRef
117
+ } = this.props;
118
+ this.ref = el;
119
+ if (typeof elementRef === 'function') {
120
+ elementRef(el);
121
+ }
122
+ };
200
123
  get isTooltip() {
201
124
  return this.props.shouldRenderOffscreen && !this.props.shouldReturnFocus && !this.props.shouldContainFocus && !this.props.shouldFocusContentOnTriggerBlur;
202
125
  }
@@ -256,19 +179,19 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
256
179
  * Offsets the popover by the arrow size
257
180
  */
258
181
  computeOffsets(placement) {
259
- let _this$props5 = this.props,
260
- offsetX = _this$props5.offsetX,
261
- offsetY = _this$props5.offsetY;
182
+ let {
183
+ offsetX,
184
+ offsetY
185
+ } = this.props;
262
186
  if (this.props.shouldAlignArrow && this._view) {
263
187
  const secondaryPlacement = parsePlacement(placement)[1];
264
188
 
265
189
  // arrowSize and arrowBorderWidth are component theme variables
266
190
  // declared in ContextView's styles.js
267
- const _ref = this._view.props.styles,
268
- _ref$arrowSize = _ref.arrowSize,
269
- arrowSize = _ref$arrowSize === void 0 ? 0 : _ref$arrowSize,
270
- _ref$arrowBorderWidth = _ref.arrowBorderWidth,
271
- arrowBorderWidth = _ref$arrowBorderWidth === void 0 ? 0 : _ref$arrowBorderWidth;
191
+ const {
192
+ arrowSize = 0,
193
+ arrowBorderWidth = 0
194
+ } = this._view.props.styles;
272
195
  const offsetAmount = (px(arrowSize) + px(arrowBorderWidth)) * 2;
273
196
  if (secondaryPlacement === 'start') {
274
197
  offsetX = offsetAmount;
@@ -286,8 +209,12 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
286
209
  };
287
210
  }
288
211
  get placement() {
289
- let placement = this.props.placement;
290
- const dir = this.props.dir;
212
+ let {
213
+ placement
214
+ } = this.props;
215
+ const {
216
+ dir
217
+ } = this.props;
291
218
  const isRtl = dir === textDirectionContextConsumer.DIRECTION.rtl;
292
219
  if (isRtl) {
293
220
  placement = mirrorHorizontalPlacement(placement, ' ');
@@ -316,6 +243,110 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
316
243
  get defaultFocusElement() {
317
244
  return this.props.defaultFocusElement;
318
245
  }
246
+ show = event => {
247
+ if (typeof this.props.isShowingContent === 'undefined') {
248
+ this.setState({
249
+ isShowingContent: true
250
+ });
251
+ }
252
+ this.props.onShowContent?.(event);
253
+ };
254
+ hide = (event, documentClick = false) => {
255
+ const {
256
+ onHideContent,
257
+ isShowingContent
258
+ } = this.props;
259
+ if (typeof isShowingContent === 'undefined') {
260
+ // uncontrolled, set state, fire callbacks
261
+ this.setState(({
262
+ isShowingContent
263
+ }) => {
264
+ if (isShowingContent) {
265
+ onHideContent?.(event, {
266
+ documentClick
267
+ });
268
+ }
269
+ return {
270
+ isShowingContent: false
271
+ };
272
+ });
273
+ } else if (isShowingContent) {
274
+ // controlled, fire callback
275
+ onHideContent?.(event, {
276
+ documentClick
277
+ });
278
+ }
279
+ };
280
+ toggle = event => {
281
+ if (this.shown) {
282
+ this.hide(event);
283
+ } else {
284
+ this.show(event);
285
+ }
286
+ };
287
+ handleDialogDismiss = (event, documentClick) => {
288
+ if (!this.props.shouldReturnFocus && this.props.shouldFocusContentOnTriggerBlur) {
289
+ const trigger = findDOMNode(this._trigger);
290
+ if (trigger && typeof trigger.focus === 'function') {
291
+ ;
292
+ trigger.focus();
293
+ }
294
+ }
295
+ this.hide(event, documentClick);
296
+ };
297
+ handleDialogBlur = event => {
298
+ if (event.keyCode === keycode.codes.tab && event.shiftKey && this.props.shouldFocusContentOnTriggerBlur) {
299
+ return;
300
+ }
301
+ this.hide(event);
302
+ };
303
+ handleTriggerKeyDown = event => {
304
+ if (!this.props.shouldFocusContentOnTriggerBlur) {
305
+ return;
306
+ }
307
+ if (event.keyCode === keycode.codes.tab && !event.shiftKey) {
308
+ event.preventDefault();
309
+ this._raf.push(requestAnimationFrame(() => {
310
+ this._dialog && this._dialog.focus();
311
+ }));
312
+ }
313
+ };
314
+ handleTriggerKeyUp = event => {
315
+ if (event.keyCode === keycode.codes.esc && this.shown && this.isTooltip) {
316
+ // if popover is tooltip, it is managing its own focus region so we need
317
+ // to prevent esc keyup event from reaching FocusRegionManager
318
+ event.preventDefault();
319
+ this.hide(event);
320
+ }
321
+ };
322
+ handleTriggerBlur = event => {
323
+ const {
324
+ on
325
+ } = this.props;
326
+ if (on && on.indexOf('focus') > -1) {
327
+ this._raf.push(requestAnimationFrame(() => {
328
+ if (!containsActiveElement(this._view)) {
329
+ this.hide(event);
330
+ }
331
+ }));
332
+ }
333
+ };
334
+ handlePositioned = position => {
335
+ const placement = position.placement;
336
+ this.setState({
337
+ placement,
338
+ ...this.computeOffsets(placement)
339
+ });
340
+ this.props.onPositioned?.(position);
341
+ };
342
+ handlePositionChanged = position => {
343
+ const placement = position.placement;
344
+ this.setState({
345
+ placement,
346
+ ...this.computeOffsets(placement)
347
+ });
348
+ this.props.onPositionChanged?.(position);
349
+ };
319
350
  renderTrigger() {
320
351
  if (this._renderTriggerProp != this.props.renderTrigger) {
321
352
  this._renderTriggerProp = this.props.renderTrigger;
@@ -323,11 +354,13 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
323
354
  }
324
355
  let trigger = this._renderTrigger;
325
356
  if (trigger) {
326
- const on = this.props.on;
327
- let onClick = void 0;
328
- let onFocus = void 0;
329
- let onMouseOut = void 0;
330
- let onMouseOver = void 0;
357
+ const {
358
+ on
359
+ } = this.props;
360
+ let onClick = undefined;
361
+ let onFocus = undefined;
362
+ let onMouseOut = undefined;
363
+ let onMouseOver = undefined;
331
364
  let expanded;
332
365
  if (on && on.indexOf('click') > -1) {
333
366
  onClick = event => {
@@ -353,7 +386,7 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
353
386
  expanded = this.props['aria-expanded'];
354
387
  }
355
388
  } else {
356
- expanded = void 0;
389
+ expanded = undefined;
357
390
  }
358
391
  trigger = safeCloneElement(trigger, {
359
392
  ref: el => {
@@ -402,9 +435,8 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
402
435
  // TODO: try to type `ref` better, LegacyRef<T> was not compatible
403
436
  ref: c => this._view = c,
404
437
  elementRef: el => {
405
- var _this$props$contentRe, _this$props6;
406
438
  this._contentElement = el;
407
- (_this$props$contentRe = (_this$props6 = this.props).contentRef) === null || _this$props$contentRe === void 0 ? void 0 : _this$props$contentRe.call(_this$props6, el);
439
+ this.props.contentRef?.(el);
408
440
  },
409
441
  background: color,
410
442
  stacking: this.props.stacking,
@@ -419,8 +451,12 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
419
451
  onMouseOut: this._handleMouseOut
420
452
  };
421
453
  }
422
- const placement = this.state.placement;
423
- const styles = this.props.styles;
454
+ const {
455
+ placement
456
+ } = this.state;
457
+ const {
458
+ styles
459
+ } = this.props;
424
460
  if (this.props.withArrow) {
425
461
  viewProps = {
426
462
  ...viewProps,
@@ -430,7 +466,7 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
430
466
  };
431
467
  return _jsx(ContextView, {
432
468
  ...viewProps,
433
- borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
469
+ borderColor: styles?.borderColor,
434
470
  children: content
435
471
  });
436
472
  } else {
@@ -444,7 +480,7 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
444
480
  };
445
481
  return _jsx(View, {
446
482
  ...viewProps,
447
- borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
483
+ borderColor: styles?.borderColor,
448
484
  children: content
449
485
  });
450
486
  }
@@ -473,27 +509,6 @@ let Popover = (_dec = withDeterministicId(), _dec2 = textDirectionContextConsume
473
509
  });
474
510
  }
475
511
  }
476
- }, _Popover.displayName = "Popover", _Popover.componentId = 'Popover', _Popover.allowedProps = allowedProps, _Popover.defaultProps = {
477
- defaultIsShowingContent: false,
478
- placement: 'bottom center',
479
- stacking: 'topmost',
480
- shadow: 'resting',
481
- offsetX: 0,
482
- offsetY: 0,
483
- color: 'primary',
484
- on: ['hover', 'focus'],
485
- withArrow: true,
486
- constrain: 'window',
487
- insertAt: 'bottom',
488
- shouldAlignArrow: false,
489
- shouldTrackPosition: true,
490
- shouldRenderOffscreen: false,
491
- shouldContainFocus: false,
492
- shouldReturnFocus: true,
493
- shouldCloseOnDocumentClick: true,
494
- shouldFocusContentOnTriggerBlur: false,
495
- shouldCloseOnEscape: true,
496
- shouldSetAriaExpanded: true
497
- }, _Popover)) || _class) || _class) || _class);
512
+ }) || _class) || _class) || _class);
498
513
  export default Popover;
499
514
  export { Popover };
@@ -28,10 +28,11 @@
28
28
  * @return {Object} The final theme object with the overrides and component variables
29
29
  */
30
30
  const generateComponentTheme = theme => {
31
- var _colors$contrasts;
32
- const colors = theme.colors;
31
+ const {
32
+ colors
33
+ } = theme;
33
34
  const componentVariables = {
34
- borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.grey3045
35
+ borderColor: colors?.contrasts?.grey3045
35
36
  };
36
37
  return {
37
38
  ...componentVariables