@instructure/ui-popover 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +38 -288
  2. package/es/Popover/{index.js → v1/index.js} +3 -3
  3. package/es/Popover/v2/index.js +499 -0
  4. package/es/Popover/v2/props.js +26 -0
  5. package/es/Popover/v2/styles.js +39 -0
  6. package/es/{index.js → exports/a.js} +1 -1
  7. package/{src/index.ts → es/exports/b.js} +1 -2
  8. package/lib/Popover/{index.js → v1/index.js} +5 -6
  9. package/lib/Popover/v2/index.js +514 -0
  10. package/lib/Popover/v2/props.js +31 -0
  11. package/lib/Popover/v2/styles.js +45 -0
  12. package/lib/{index.js → exports/a.js} +2 -2
  13. package/lib/exports/b.js +12 -0
  14. package/package.json +46 -24
  15. package/src/Popover/{index.tsx → v1/index.tsx} +5 -5
  16. package/src/Popover/v2/README.md +455 -0
  17. package/src/Popover/v2/index.tsx +645 -0
  18. package/src/Popover/v2/props.ts +354 -0
  19. package/src/Popover/v2/styles.ts +45 -0
  20. package/src/exports/a.ts +25 -0
  21. package/src/exports/b.ts +25 -0
  22. package/tsconfig.build.tsbuildinfo +1 -1
  23. package/types/Popover/v1/index.d.ts +83 -0
  24. package/types/Popover/v1/index.d.ts.map +1 -0
  25. package/types/Popover/v1/props.d.ts.map +1 -0
  26. package/types/Popover/v1/styles.d.ts.map +1 -0
  27. package/types/Popover/v1/theme.d.ts.map +1 -0
  28. package/types/Popover/v2/index.d.ts.map +1 -0
  29. package/types/Popover/v2/props.d.ts +225 -0
  30. package/types/Popover/v2/props.d.ts.map +1 -0
  31. package/types/Popover/v2/styles.d.ts +13 -0
  32. package/types/Popover/v2/styles.d.ts.map +1 -0
  33. package/types/exports/a.d.ts +3 -0
  34. package/types/exports/a.d.ts.map +1 -0
  35. package/types/exports/b.d.ts +3 -0
  36. package/types/exports/b.d.ts.map +1 -0
  37. package/types/Popover/index.d.ts.map +0 -1
  38. package/types/Popover/props.d.ts.map +0 -1
  39. package/types/Popover/styles.d.ts.map +0 -1
  40. package/types/Popover/theme.d.ts.map +0 -1
  41. package/types/index.d.ts +0 -3
  42. package/types/index.d.ts.map +0 -1
  43. /package/es/Popover/{props.js → v1/props.js} +0 -0
  44. /package/es/Popover/{styles.js → v1/styles.js} +0 -0
  45. /package/es/Popover/{theme.js → v1/theme.js} +0 -0
  46. /package/lib/Popover/{props.js → v1/props.js} +0 -0
  47. /package/lib/Popover/{styles.js → v1/styles.js} +0 -0
  48. /package/lib/Popover/{theme.js → v1/theme.js} +0 -0
  49. /package/src/Popover/{README.md → v1/README.md} +0 -0
  50. /package/src/Popover/{props.ts → v1/props.ts} +0 -0
  51. /package/src/Popover/{styles.ts → v1/styles.ts} +0 -0
  52. /package/src/Popover/{theme.ts → v1/theme.ts} +0 -0
  53. /package/types/Popover/{props.d.ts → v1/props.d.ts} +0 -0
  54. /package/types/Popover/{styles.d.ts → v1/styles.d.ts} +0 -0
  55. /package/types/Popover/{theme.d.ts → v1/theme.d.ts} +0 -0
  56. /package/types/Popover/{index.d.ts → v2/index.d.ts} +0 -0
@@ -0,0 +1,514 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Popover = void 0;
8
+ var _react = require("react");
9
+ var _keycode = _interopRequireDefault(require("keycode"));
10
+ var _Position = require("@instructure/ui-position/lib/Position");
11
+ var _parsePlacement = require("@instructure/ui-position/lib/parsePlacement.js");
12
+ var _mirrorHorizontalPlacement = require("@instructure/ui-position/lib/mirrorHorizontalPlacement.js");
13
+ var _latest = require("@instructure/ui-view/latest");
14
+ var _Dialog = require("@instructure/ui-dialog/lib/Dialog");
15
+ var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
16
+ var _findDOMNode = require("@instructure/ui-dom-utils/lib/findDOMNode.js");
17
+ var _containsActiveElement = require("@instructure/ui-dom-utils/lib/containsActiveElement.js");
18
+ var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
19
+ var _handleMouseOverOut = require("@instructure/ui-dom-utils/lib/handleMouseOverOut.js");
20
+ var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
21
+ var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
22
+ var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
23
+ var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
24
+ var _shallowEqual = require("@instructure/ui-utils/lib/shallowEqual.js");
25
+ var _px = require("@instructure/ui-utils/lib/px.js");
26
+ var _combineDataCid = require("@instructure/ui-utils/lib/combineDataCid.js");
27
+ var _console = require("@instructure/console");
28
+ var _FocusRegion = require("@instructure/ui-a11y-utils/lib/FocusRegion.js");
29
+ var _emotion = require("@instructure/emotion");
30
+ var _styles = _interopRequireDefault(require("./styles"));
31
+ var _props = require("./props");
32
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
33
+ var _dec, _dec2, _dec3, _class, _Popover;
34
+ /*
35
+ * The MIT License (MIT)
36
+ *
37
+ * Copyright (c) 2015 - present Instructure, Inc.
38
+ *
39
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
40
+ * of this software and associated documentation files (the "Software"), to deal
41
+ * in the Software without restriction, including without limitation the rights
42
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43
+ * copies of the Software, and to permit persons to whom the Software is
44
+ * furnished to do so, subject to the following conditions:
45
+ *
46
+ * The above copyright notice and this permission notice shall be included in all
47
+ * copies or substantial portions of the Software.
48
+ *
49
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55
+ * SOFTWARE.
56
+ */
57
+ /**
58
+ ---
59
+ category: components
60
+ tags: overlay, portal, dialog
61
+ ---
62
+ **/
63
+ let Popover = exports.Popover = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec3 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class = _dec3(_class = (_Popover = class Popover extends _react.Component {
64
+ constructor(props) {
65
+ super(props);
66
+ this._handleMouseOver = void 0;
67
+ this._handleMouseOut = void 0;
68
+ this._id = void 0;
69
+ this._raf = [];
70
+ this._trigger = null;
71
+ this._view = null;
72
+ this._dialog = null;
73
+ this._contentElement = null;
74
+ this._focusRegion = void 0;
75
+ // renderTrigger needs to be a variable because if it's a function it will
76
+ // recreate the trigger on each render which will trigger MouseOver events
77
+ // that will make the tooltip reappear and the trigger cannot accept
78
+ // onClick events (since the state change caused by MouseDown recreates it)
79
+ this._renderTrigger = void 0;
80
+ this._renderTriggerProp = void 0;
81
+ this.mouseOutTimeout = void 0;
82
+ this.ref = null;
83
+ this.handleRef = el => {
84
+ const elementRef = this.props.elementRef;
85
+ this.ref = el;
86
+ if (typeof elementRef === 'function') {
87
+ elementRef(el);
88
+ }
89
+ };
90
+ this.show = event => {
91
+ var _this$props$onShowCon, _this$props;
92
+ if (typeof this.props.isShowingContent === 'undefined') {
93
+ this.setState({
94
+ isShowingContent: true
95
+ });
96
+ }
97
+ (_this$props$onShowCon = (_this$props = this.props).onShowContent) === null || _this$props$onShowCon === void 0 ? void 0 : _this$props$onShowCon.call(_this$props, event);
98
+ };
99
+ this.hide = (event, documentClick = false) => {
100
+ const _this$props2 = this.props,
101
+ onHideContent = _this$props2.onHideContent,
102
+ isShowingContent = _this$props2.isShowingContent;
103
+ if (typeof isShowingContent === 'undefined') {
104
+ // uncontrolled, set state, fire callbacks
105
+ this.setState(({
106
+ isShowingContent
107
+ }) => {
108
+ if (isShowingContent) {
109
+ onHideContent === null || onHideContent === void 0 ? void 0 : onHideContent(event, {
110
+ documentClick
111
+ });
112
+ }
113
+ return {
114
+ isShowingContent: false
115
+ };
116
+ });
117
+ } else if (isShowingContent) {
118
+ // controlled, fire callback
119
+ onHideContent === null || onHideContent === void 0 ? void 0 : onHideContent(event, {
120
+ documentClick
121
+ });
122
+ }
123
+ };
124
+ this.toggle = event => {
125
+ if (this.shown) {
126
+ this.hide(event);
127
+ } else {
128
+ this.show(event);
129
+ }
130
+ };
131
+ this.handleDialogDismiss = (event, documentClick) => {
132
+ if (!this.props.shouldReturnFocus && this.props.shouldFocusContentOnTriggerBlur) {
133
+ const trigger = (0, _findDOMNode.findDOMNode)(this._trigger);
134
+ if (trigger && typeof trigger.focus === 'function') {
135
+ ;
136
+ trigger.focus();
137
+ }
138
+ }
139
+ this.hide(event, documentClick);
140
+ };
141
+ this.handleDialogBlur = event => {
142
+ if (event.keyCode === _keycode.default.codes.tab && event.shiftKey && this.props.shouldFocusContentOnTriggerBlur) {
143
+ return;
144
+ }
145
+ this.hide(event);
146
+ };
147
+ this.handleTriggerKeyDown = event => {
148
+ if (!this.props.shouldFocusContentOnTriggerBlur) {
149
+ return;
150
+ }
151
+ if (event.keyCode === _keycode.default.codes.tab && !event.shiftKey) {
152
+ event.preventDefault();
153
+ this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(() => {
154
+ this._dialog && this._dialog.focus();
155
+ }));
156
+ }
157
+ };
158
+ this.handleTriggerKeyUp = event => {
159
+ if (event.keyCode === _keycode.default.codes.esc && this.shown && this.isTooltip) {
160
+ // if popover is tooltip, it is managing its own focus region so we need
161
+ // to prevent esc keyup event from reaching FocusRegionManager
162
+ event.preventDefault();
163
+ this.hide(event);
164
+ }
165
+ };
166
+ this.handleTriggerBlur = event => {
167
+ const on = this.props.on;
168
+ if (on && on.indexOf('focus') > -1) {
169
+ this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(() => {
170
+ if (!(0, _containsActiveElement.containsActiveElement)(this._view)) {
171
+ this.hide(event);
172
+ }
173
+ }));
174
+ }
175
+ };
176
+ this.handlePositioned = position => {
177
+ var _this$props$onPositio, _this$props3;
178
+ const placement = position.placement;
179
+ this.setState({
180
+ placement,
181
+ ...this.computeOffsets(placement)
182
+ });
183
+ (_this$props$onPositio = (_this$props3 = this.props).onPositioned) === null || _this$props$onPositio === void 0 ? void 0 : _this$props$onPositio.call(_this$props3, position);
184
+ };
185
+ this.handlePositionChanged = position => {
186
+ var _this$props$onPositio2, _this$props4;
187
+ const placement = position.placement;
188
+ this.setState({
189
+ placement,
190
+ ...this.computeOffsets(placement)
191
+ });
192
+ (_this$props$onPositio2 = (_this$props4 = this.props).onPositionChanged) === null || _this$props$onPositio2 === void 0 ? void 0 : _this$props$onPositio2.call(_this$props4, position);
193
+ };
194
+ this._renderTriggerProp = this.props.renderTrigger;
195
+ this._renderTrigger = (0, _callRenderProp.callRenderProp)(this.props.renderTrigger);
196
+ this.state = {
197
+ placement: props.placement,
198
+ offsetX: props.offsetX,
199
+ offsetY: props.offsetY,
200
+ isShowingContent: typeof props.isShowingContent === 'undefined' ? props.defaultIsShowingContent : void 0
201
+ };
202
+ this._id = this.props.id || props.deterministicId();
203
+ this._raf = [];
204
+ this._handleMouseOver = _handleMouseOverOut.handleMouseOverOut.bind(null, event => {
205
+ this.show(event);
206
+ clearTimeout(this.mouseOutTimeout);
207
+ });
208
+ this._handleMouseOut = _handleMouseOverOut.handleMouseOverOut.bind(null, event => {
209
+ // this is needed bc the trigger mouseOut fires before tooltip mouseOver
210
+ this.mouseOutTimeout = setTimeout(() => {
211
+ this.hide(event);
212
+ }, 1);
213
+ });
214
+ }
215
+ get isTooltip() {
216
+ return this.props.shouldRenderOffscreen && !this.props.shouldReturnFocus && !this.props.shouldContainFocus && !this.props.shouldFocusContentOnTriggerBlur;
217
+ }
218
+ componentDidMount() {
219
+ if (this.isTooltip) {
220
+ // if popover is being used as a tooltip with no focusable content
221
+ // manage its FocusRegion internally rather than registering it with
222
+ // the FocusRegionManager via Dialog
223
+ this._focusRegion = new _FocusRegion.FocusRegion(this._contentElement, {
224
+ shouldCloseOnEscape: this.props.shouldCloseOnEscape,
225
+ shouldCloseOnDocumentClick: false,
226
+ onDismiss: this.hide,
227
+ isTooltip: true
228
+ });
229
+ if (this.shown) {
230
+ this._focusRegion.activate();
231
+ }
232
+ }
233
+ }
234
+ componentWillUnmount() {
235
+ this._raf.forEach(request => request.cancel());
236
+ this._raf = [];
237
+ if (this._focusRegion) {
238
+ this._focusRegion.deactivate();
239
+ this._focusRegion.blur();
240
+ }
241
+ }
242
+ shouldComponentUpdate(nextProps, nextState) {
243
+ return !(0, _shallowEqual.shallowEqual)(this.props, nextProps) || !(0, _shallowEqual.shallowEqual)(this.state, nextState);
244
+ }
245
+ componentDidUpdate(prevProps, prevState) {
246
+ if (this._focusRegion && this.isTooltip) {
247
+ // if focus region exists, popover is acting as a tooltip
248
+ // so we manually activate and deactivate the region when showing/hiding
249
+ if (!prevProps.isShowingContent && this.props.isShowingContent || !prevState.isShowingContent && this.state.isShowingContent) {
250
+ // changed from hiding to showing
251
+ this._focusRegion.activate();
252
+ this._focusRegion.focus();
253
+ }
254
+ if (prevProps.isShowingContent && !this.props.isShowingContent || prevState.isShowingContent && !this.state.isShowingContent) {
255
+ // changed from showing to hiding
256
+ this._focusRegion.deactivate();
257
+ }
258
+ }
259
+
260
+ // since `offsetX`, `offsetY` and `placement` are saved into the state
261
+ // in the constructor and used from the state later,
262
+ // we need to update the state if these props change
263
+ 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) {
264
+ this.setState({
265
+ ...this.computeOffsets(this.placement)
266
+ });
267
+ }
268
+ }
269
+
270
+ /**
271
+ * Offsets the popover by the arrow size
272
+ */
273
+ computeOffsets(placement) {
274
+ let _this$props5 = this.props,
275
+ offsetX = _this$props5.offsetX,
276
+ offsetY = _this$props5.offsetY;
277
+ if (this.props.shouldAlignArrow && this._view) {
278
+ const secondaryPlacement = (0, _parsePlacement.parsePlacement)(placement)[1];
279
+
280
+ // arrowSize and arrowBorderWidth are component theme variables
281
+ // declared in ContextView's styles.js
282
+ const _ref = this._view.props.styles,
283
+ _ref$arrowSize = _ref.arrowSize,
284
+ arrowSize = _ref$arrowSize === void 0 ? 0 : _ref$arrowSize,
285
+ _ref$arrowBorderWidth = _ref.arrowBorderWidth,
286
+ arrowBorderWidth = _ref$arrowBorderWidth === void 0 ? 0 : _ref$arrowBorderWidth;
287
+ const offsetAmount = ((0, _px.px)(arrowSize) + (0, _px.px)(arrowBorderWidth)) * 2;
288
+ if (secondaryPlacement === 'start') {
289
+ offsetX = offsetAmount;
290
+ } else if (secondaryPlacement === 'end') {
291
+ offsetX = -offsetAmount;
292
+ } else if (secondaryPlacement === 'top') {
293
+ offsetY = offsetAmount;
294
+ } else if (secondaryPlacement === 'bottom') {
295
+ offsetY = -offsetAmount;
296
+ }
297
+ }
298
+ return {
299
+ offsetX,
300
+ offsetY
301
+ };
302
+ }
303
+ get placement() {
304
+ let placement = this.props.placement;
305
+ const dir = this.props.dir;
306
+ const isRtl = dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl;
307
+ if (isRtl) {
308
+ placement = (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ');
309
+ }
310
+ return !this.shown && this.props.shouldRenderOffscreen ? 'offscreen' : placement;
311
+ }
312
+ get positionProps() {
313
+ return {
314
+ offsetX: this.state.offsetX,
315
+ offsetY: this.state.offsetY,
316
+ shouldTrackPosition: this.props.shouldTrackPosition && this.shown,
317
+ insertAt: this.props.insertAt,
318
+ placement: this.placement,
319
+ constrain: this.props.constrain,
320
+ onPositioned: this.handlePositioned,
321
+ onPositionChanged: this.handlePositionChanged,
322
+ target: this.props.positionTarget,
323
+ containerDisplay: this.props.positionContainerDisplay,
324
+ mountNode: this.props.mountNode,
325
+ id: this._id
326
+ };
327
+ }
328
+ get shown() {
329
+ return typeof this.props.isShowingContent === 'undefined' ? this.state.isShowingContent : this.props.isShowingContent;
330
+ }
331
+ get defaultFocusElement() {
332
+ return this.props.defaultFocusElement;
333
+ }
334
+ renderTrigger() {
335
+ if (this._renderTriggerProp != this.props.renderTrigger) {
336
+ this._renderTriggerProp = this.props.renderTrigger;
337
+ this._renderTrigger = (0, _callRenderProp.callRenderProp)(this.props.renderTrigger);
338
+ }
339
+ let trigger = this._renderTrigger;
340
+ if (trigger) {
341
+ const on = this.props.on;
342
+ let onClick = void 0;
343
+ let onFocus = void 0;
344
+ let onMouseOut = void 0;
345
+ let onMouseOver = void 0;
346
+ let expanded;
347
+ if (on && on.indexOf('click') > -1) {
348
+ onClick = event => {
349
+ this.toggle(event);
350
+ };
351
+ }
352
+ if (on && on.indexOf('hover') > -1) {
353
+ (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.');
354
+ onMouseOver = this._handleMouseOver;
355
+ onMouseOut = this._handleMouseOut;
356
+ }
357
+ if (on && on.indexOf('focus') > -1) {
358
+ onFocus = event => {
359
+ this.show(event);
360
+ };
361
+ }
362
+ if (this.props.shouldSetAriaExpanded) {
363
+ // only set aria-expanded if popover can contain focus
364
+ expanded = this.shown ? 'true' : 'false';
365
+ if ('aria-expanded' in this.props) {
366
+ // @ts-expect-error It is an escape hatch, in case someone
367
+ // wants to remove/override aria-expanded even when shouldSetAriaExpanded is set
368
+ expanded = this.props['aria-expanded'];
369
+ }
370
+ } else {
371
+ expanded = void 0;
372
+ }
373
+ trigger = (0, _safeCloneElement.safeCloneElement)(trigger, {
374
+ ref: el => {
375
+ this._trigger = el;
376
+ },
377
+ 'aria-expanded': expanded,
378
+ 'data-popover-trigger': true,
379
+ onKeyDown: (0, _createChainedFunction.createChainedFunction)(this.handleTriggerKeyDown, this.props.onKeyDown),
380
+ onKeyUp: (0, _createChainedFunction.createChainedFunction)(this.handleTriggerKeyUp, this.props.onKeyUp),
381
+ onClick: (0, _createChainedFunction.createChainedFunction)(onClick, this.props.onClick),
382
+ onBlur: (0, _createChainedFunction.createChainedFunction)(this.handleTriggerBlur, this.props.onBlur),
383
+ onFocus: (0, _createChainedFunction.createChainedFunction)(onFocus, this.props.onFocus),
384
+ onMouseOut: (0, _createChainedFunction.createChainedFunction)(onMouseOut, this.props.onMouseOut),
385
+ onMouseOver: (0, _createChainedFunction.createChainedFunction)(onMouseOver, this.props.onMouseOver)
386
+ });
387
+ }
388
+ return trigger;
389
+ }
390
+ renderContent() {
391
+ let content = (0, _callRenderProp.callRenderProp)(this.props.children);
392
+ if (this.shown && !this.isTooltip) {
393
+ // if popover is NOT being used as a tooltip, create a Dialog
394
+ // to manage the content FocusRegion, when showing
395
+ content = (0, _jsxRuntime.jsx)(_Dialog.Dialog, {
396
+ open: this.shown,
397
+ label: this.props.screenReaderLabel,
398
+ ref: el => {
399
+ this._dialog = el;
400
+ },
401
+ display: "block",
402
+ onBlur: this.handleDialogBlur,
403
+ onDismiss: this.handleDialogDismiss,
404
+ liveRegion: this.props.liveRegion,
405
+ defaultFocusElement: this.props.defaultFocusElement,
406
+ shouldContainFocus: this.props.shouldContainFocus,
407
+ shouldReturnFocus: this.props.shouldReturnFocus,
408
+ shouldFocusOnOpen: !this.props.shouldFocusContentOnTriggerBlur,
409
+ shouldCloseOnDocumentClick: this.props.shouldCloseOnDocumentClick,
410
+ shouldCloseOnEscape: this.props.shouldCloseOnEscape,
411
+ children: content
412
+ });
413
+ }
414
+ if (this.shown || this.props.shouldRenderOffscreen) {
415
+ const color = this.props.color;
416
+ let viewProps = {
417
+ // TODO: try to type `ref` better, LegacyRef<T> was not compatible
418
+ ref: c => this._view = c,
419
+ elementRef: el => {
420
+ var _this$props$contentRe, _this$props6;
421
+ this._contentElement = el;
422
+ (_this$props$contentRe = (_this$props6 = this.props).contentRef) === null || _this$props$contentRe === void 0 ? void 0 : _this$props$contentRe.call(_this$props6, el);
423
+ },
424
+ background: color,
425
+ stacking: this.props.stacking,
426
+ shadow: this.props.shadow,
427
+ display: 'block'
428
+ };
429
+ if (this.isTooltip) {
430
+ viewProps = {
431
+ ...viewProps,
432
+ // Because of a11y reasons popovers should not be hidden when hovered over
433
+ onMouseOver: this._handleMouseOver,
434
+ onMouseOut: this._handleMouseOut
435
+ };
436
+ }
437
+ const placement = this.state.placement;
438
+ const styles = this.props.styles;
439
+ if (this.props.withArrow) {
440
+ viewProps = {
441
+ ...viewProps,
442
+ // TODO: remove background override after contextview is updated
443
+ background: color === 'primary' ? 'default' : 'inverse',
444
+ placement: this.props.dir === _textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION.rtl ? (0, _mirrorHorizontalPlacement.mirrorHorizontalPlacement)(placement, ' ') : placement
445
+ };
446
+ return (0, _jsxRuntime.jsx)(_latest.ContextView, {
447
+ ...viewProps,
448
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
449
+ children: content
450
+ });
451
+ } else {
452
+ viewProps = {
453
+ ...viewProps,
454
+ borderWidth: this.props.borderWidth || 'small',
455
+ borderRadius: 'medium',
456
+ ...(color === 'primary-inverse' && {
457
+ borderColor: 'transparent'
458
+ })
459
+ };
460
+ return (0, _jsxRuntime.jsx)(_latest.View, {
461
+ ...viewProps,
462
+ borderColor: styles === null || styles === void 0 ? void 0 : styles.borderColor,
463
+ borderRadius: styles === null || styles === void 0 ? void 0 : styles.borderRadius,
464
+ children: content
465
+ });
466
+ }
467
+ } else {
468
+ return null;
469
+ }
470
+ }
471
+ render() {
472
+ const positionProps = this.positionProps;
473
+ if (this.props.positionTarget) {
474
+ return (0, _jsxRuntime.jsxs)("span", {
475
+ ref: this.handleRef,
476
+ children: [this.renderTrigger(), (0, _jsxRuntime.jsx)(_Position.Position, {
477
+ ...positionProps,
478
+ "data-cid": (0, _combineDataCid.combineDataCid)('Popover', this.props),
479
+ children: this.renderContent()
480
+ })]
481
+ });
482
+ } else {
483
+ return (0, _jsxRuntime.jsx)(_Position.Position, {
484
+ "data-cid": (0, _combineDataCid.combineDataCid)('Popover', this.props),
485
+ ...positionProps,
486
+ renderTarget: this.renderTrigger(),
487
+ elementRef: this.handleRef,
488
+ children: this.renderContent()
489
+ });
490
+ }
491
+ }
492
+ }, _Popover.displayName = "Popover", _Popover.componentId = 'Popover', _Popover.allowedProps = _props.allowedProps, _Popover.defaultProps = {
493
+ defaultIsShowingContent: false,
494
+ placement: 'bottom center',
495
+ stacking: 'topmost',
496
+ shadow: 'above',
497
+ offsetX: 0,
498
+ offsetY: 0,
499
+ color: 'primary',
500
+ on: ['hover', 'focus'],
501
+ withArrow: true,
502
+ constrain: 'window',
503
+ insertAt: 'bottom',
504
+ shouldAlignArrow: false,
505
+ shouldTrackPosition: true,
506
+ shouldRenderOffscreen: false,
507
+ shouldContainFocus: false,
508
+ shouldReturnFocus: true,
509
+ shouldCloseOnDocumentClick: true,
510
+ shouldFocusContentOnTriggerBlur: false,
511
+ shouldCloseOnEscape: true,
512
+ shouldSetAriaExpanded: true
513
+ }, _Popover)) || _class) || _class) || _class);
514
+ var _default = exports.default = Popover;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.allowedProps = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ const allowedProps = exports.allowedProps = ['isShowingContent', 'defaultIsShowingContent', 'on', 'withArrow', 'color', 'placement', 'shadow', 'stacking', 'contentRef', 'defaultFocusElement', 'screenReaderLabel', 'offsetX', 'offsetY', 'constrain', 'positionTarget', 'positionContainerDisplay', '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', 'borderWidth', 'shouldSetAriaExpanded'];
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ /*
8
+ * The MIT License (MIT)
9
+ *
10
+ * Copyright (c) 2015 - present Instructure, Inc.
11
+ *
12
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ * of this software and associated documentation files (the "Software"), to deal
14
+ * in the Software without restriction, including without limitation the rights
15
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ * copies of the Software, and to permit persons to whom the Software is
17
+ * furnished to do so, subject to the following conditions:
18
+ *
19
+ * The above copyright notice and this permission notice shall be included in all
20
+ * copies or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ * SOFTWARE.
29
+ */
30
+
31
+ /**
32
+ * ---
33
+ * private: true
34
+ * ---
35
+ * Generates the style object from the theme and provided additional information
36
+ * @param {Object} componentTheme The theme variable object.
37
+ * @return {Object} The final style object, which will be used in the component
38
+ */
39
+ const generateStyle = componentTheme => {
40
+ return {
41
+ borderColor: componentTheme.borderColor,
42
+ borderRadius: componentTheme.borderRadius
43
+ };
44
+ };
45
+ var _default = exports.default = generateStyle;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "Popover", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _Popover.Popover;
9
+ return _v.Popover;
10
10
  }
11
11
  });
12
- var _Popover = require("./Popover");
12
+ var _v = require("../Popover/v1");
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Popover", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _v.Popover;
10
+ }
11
+ });
12
+ var _v = require("../Popover/v2");