@instructure/ui-popover 8.8.1-snapshot.7 → 8.9.1-snapshot.2

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,6 +3,10 @@
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.9.0](https://github.com/instructure/instructure-ui/compare/v8.8.0...v8.9.0) (2021-09-15)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-popover
9
+
6
10
  # [8.8.0](https://github.com/instructure/instructure-ui/compare/v8.7.0...v8.8.0) (2021-08-27)
7
11
 
8
12
  ### Features
@@ -24,28 +24,26 @@ var _dec, _dec2, _class, _class2, _temp;
24
24
  * SOFTWARE.
25
25
  */
26
26
  import React, { Component } from 'react';
27
- import PropTypes from 'prop-types';
28
27
  import keycode from 'keycode';
29
- import { Position, PositionPropTypes, parsePlacement, mirrorHorizontalPlacement } from '@instructure/ui-position';
28
+ import { Position, parsePlacement, mirrorHorizontalPlacement } from '@instructure/ui-position';
30
29
  import { ContextView, View } from '@instructure/ui-view';
31
30
  import { Dialog } from '@instructure/ui-dialog';
32
31
  import { bidirectional } from '@instructure/ui-i18n';
33
- import { element } from '@instructure/ui-prop-types';
34
32
  import { findDOMNode, containsActiveElement, requestAnimationFrame, handleMouseOverOut } from '@instructure/ui-dom-utils';
35
33
  import { safeCloneElement, callRenderProp } from '@instructure/ui-react-utils';
36
34
  import { createChainedFunction, shallowEqual, px } from '@instructure/ui-utils';
37
35
  import { logError as error } from '@instructure/console';
38
36
  import { uid } from '@instructure/uid';
39
- import { ThemeablePropTypes } from '@instructure/emotion';
40
37
  import { testable } from '@instructure/ui-testable';
41
38
  import { FocusRegion } from '@instructure/ui-a11y-utils';
42
-
39
+ import { allowedProps, propTypes } from './props';
43
40
  /**
44
41
  ---
45
42
  category: components
46
43
  tags: overlay, portal, dialog
47
44
  ---
48
45
  **/
46
+
49
47
  let Popover = (_dec = bidirectional(), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Popover extends Component {
50
48
  constructor(props) {
51
49
  super(props);
@@ -463,219 +461,7 @@ let Popover = (_dec = bidirectional(), _dec2 = testable(), _dec(_class = _dec2(_
463
461
  }
464
462
  }
465
463
 
466
- }, _class2.displayName = "Popover", _class2.componentId = 'Popover', _class2.propTypes = {
467
- /**
468
- * Whether or not the `<Popover />` content is shown
469
- */
470
- isShowingContent: PropTypes.bool,
471
-
472
- /**
473
- * Whether or not to show the content by default, when uncontrolled
474
- */
475
- defaultIsShowingContent: PropTypes.bool,
476
-
477
- /**
478
- * The action that causes the content to display (`click`, `hover`, `focus`)
479
- */
480
- on: PropTypes.oneOfType([PropTypes.oneOf(['click', 'hover', 'focus']), PropTypes.arrayOf(PropTypes.oneOf(['click', 'hover', 'focus']))]),
481
-
482
- /**
483
- * Whether or not an arrow pointing to the trigger should be rendered
484
- */
485
- withArrow: PropTypes.bool,
486
-
487
- /**
488
- * Color variant of the popover content
489
- */
490
- color: PropTypes.oneOf(['primary', 'primary-inverse']),
491
-
492
- /**
493
- * The placement of the content in relation to the trigger
494
- */
495
- placement: PositionPropTypes.placement,
496
-
497
- /**
498
- * Controls the shadow depth for the `<Popover />`
499
- */
500
- shadow: ThemeablePropTypes.shadow,
501
-
502
- /**
503
- * Controls the z-index depth for the `<Popover />` content
504
- */
505
- stacking: ThemeablePropTypes.stacking,
506
-
507
- /**
508
- * A function that returns a reference to the content element
509
- */
510
- contentRef: PropTypes.func,
511
-
512
- /**
513
- * An element or a function returning an element to focus by default
514
- */
515
- defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
516
-
517
- /**
518
- * An accessible label for the `<Popover />` content
519
- */
520
- screenReaderLabel: PropTypes.string,
521
-
522
- /**
523
- * The horizontal offset for the positioned content
524
- */
525
- offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
526
-
527
- /**
528
- * The vertical offset for the positioned content
529
- */
530
- offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
531
-
532
- /**
533
- * The parent in which to constrain the popover.
534
- * One of: 'window', 'scroll-parent', 'parent', 'none', an element,
535
- * or a function returning an element
536
- */
537
- constrain: PositionPropTypes.constrain,
538
-
539
- /**
540
- * Target element for positioning the Popover (if it differs from the trigger)
541
- */
542
- positionTarget: PropTypes.oneOfType([element, PropTypes.func]),
543
-
544
- /**
545
- * An element or a function returning an element to use as the mount node
546
- * for the `<Popover />` (defaults to `document.body`)
547
- */
548
- mountNode: PositionPropTypes.mountNode,
549
-
550
- /**
551
- * Insert the element at the 'top' of the mountNode or at the 'bottom'
552
- */
553
- insertAt: PropTypes.oneOf(['bottom', 'top']),
554
-
555
- /**
556
- * An element, function returning an element, or array of elements that will
557
- * not be hidden from the screen reader when the `<Popover />` is open
558
- */
559
- liveRegion: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.func]),
560
-
561
- /**
562
- * An id is generated if not supplied.
563
- */
564
- id: PropTypes.string,
565
-
566
- /**
567
- * Whether or not the content should offset to align by its arrow
568
- */
569
- shouldAlignArrow: PropTypes.bool,
570
-
571
- /**
572
- * Whether or not position should be tracked or just set on initial render
573
- */
574
- shouldTrackPosition: PropTypes.bool,
575
-
576
- /**
577
- * Should the `<Popover />` render offscreen when visually hidden
578
- */
579
- shouldRenderOffscreen: PropTypes.bool,
580
-
581
- /**
582
- * Whether focus should contained within the `<Popover/>` when it is open
583
- */
584
- shouldContainFocus: PropTypes.bool,
585
-
586
- /**
587
- * Whether focus should be returned to the trigger when the `<Popover/>` is closed
588
- */
589
- shouldReturnFocus: PropTypes.bool,
590
-
591
- /**
592
- * Should the `<Popover />` hide when clicks occur outside the content
593
- */
594
- shouldCloseOnDocumentClick: PropTypes.bool,
595
-
596
- /**
597
- * Should the `<Popover />` hide when the escape key is pressed
598
- */
599
- shouldCloseOnEscape: PropTypes.bool,
600
-
601
- /**
602
- * Should the content become focused when the trigger is blurred
603
- */
604
- shouldFocusContentOnTriggerBlur: PropTypes.bool,
605
-
606
- /**
607
- * Callback fired when content is shown. When controlled, this callback is
608
- * fired when the Popover expects to be shown
609
- */
610
- onShowContent: PropTypes.func,
611
-
612
- /**
613
- * Callback fired when content is hidden. When controlled, this callback is
614
- * fired when the Popover expects to be hidden
615
- */
616
- onHideContent: PropTypes.func,
617
-
618
- /**
619
- * Callback fired when content has been is initially positioned.
620
- * If `shouldRenderOffscreen` is true, it will only fire once, the first
621
- * time the content is shown
622
- */
623
- onPositioned: PropTypes.func,
624
-
625
- /**
626
- * Callback fired when the position changes
627
- */
628
- onPositionChanged: PropTypes.func,
629
-
630
- /**
631
- * Callback fired when component is clicked
632
- */
633
- onClick: PropTypes.func,
634
-
635
- /**
636
- * Callback fired when trigger is focused
637
- */
638
- onFocus: PropTypes.func,
639
-
640
- /**
641
- * Callback fired when component is blurred
642
- */
643
- onBlur: PropTypes.func,
644
-
645
- /**
646
- * Callback fired on keydown
647
- */
648
- onKeyDown: PropTypes.func,
649
-
650
- /**
651
- * Callback fired on keyup
652
- */
653
- onKeyUp: PropTypes.func,
654
-
655
- /**
656
- /**
657
- * Callback fired when mouse is over trigger
658
- */
659
- onMouseOver: PropTypes.func,
660
-
661
- /**
662
- * Callback fired when mouse leaves trigger
663
- */
664
- onMouseOut: PropTypes.func,
665
-
666
- /**
667
- * The element that triggers the popover
668
- */
669
- renderTrigger: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
670
-
671
- /**
672
- * The content to be shown by the popover
673
- */
674
- children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
675
- // eslint-disable-next-line react/require-default-props
676
- dir: PropTypes.oneOf(Object.values(bidirectional.DIRECTION))
677
- }, _class2.defaultProps = {
678
- isShowingContent: void 0,
464
+ }, _class2.displayName = "Popover", _class2.componentId = 'Popover', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
679
465
  defaultIsShowingContent: false,
680
466
  placement: 'bottom center',
681
467
  stacking: 'topmost',
@@ -687,13 +473,7 @@ let Popover = (_dec = bidirectional(), _dec2 = testable(), _dec(_class = _dec2(_
687
473
  contentRef: el => {},
688
474
  withArrow: true,
689
475
  constrain: 'window',
690
- defaultFocusElement: void 0,
691
- screenReaderLabel: void 0,
692
- mountNode: void 0,
693
476
  insertAt: 'bottom',
694
- liveRegion: void 0,
695
- positionTarget: void 0,
696
- id: void 0,
697
477
  shouldAlignArrow: false,
698
478
  shouldTrackPosition: true,
699
479
  shouldRenderOffscreen: false,
@@ -0,0 +1,239 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import PropTypes from 'prop-types';
25
+ import { element } from '@instructure/ui-prop-types';
26
+ import { ThemeablePropTypes } from '@instructure/emotion';
27
+ import { PositionPropTypes } from '@instructure/ui-position';
28
+ const propTypes = {
29
+ /**
30
+ * Whether or not the `<Popover />` content is shown
31
+ */
32
+ isShowingContent: PropTypes.bool,
33
+
34
+ /**
35
+ * Whether or not to show the content by default, when uncontrolled
36
+ */
37
+ defaultIsShowingContent: PropTypes.bool,
38
+
39
+ /**
40
+ * The action that causes the content to display (`click`, `hover`, `focus`)
41
+ */
42
+ on: PropTypes.oneOfType([PropTypes.oneOf(['click', 'hover', 'focus']), PropTypes.arrayOf(PropTypes.oneOf(['click', 'hover', 'focus']))]),
43
+
44
+ /**
45
+ * Whether or not an arrow pointing to the trigger should be rendered
46
+ */
47
+ withArrow: PropTypes.bool,
48
+
49
+ /**
50
+ * Color variant of the popover content
51
+ */
52
+ color: PropTypes.oneOf(['primary', 'primary-inverse']),
53
+
54
+ /**
55
+ * The placement of the content in relation to the trigger
56
+ */
57
+ placement: PositionPropTypes.placement,
58
+
59
+ /**
60
+ * Controls the shadow depth for the `<Popover />`
61
+ */
62
+ shadow: ThemeablePropTypes.shadow,
63
+
64
+ /**
65
+ * Controls the z-index depth for the `<Popover />` content
66
+ */
67
+ stacking: ThemeablePropTypes.stacking,
68
+
69
+ /**
70
+ * A function that returns a reference to the content element
71
+ */
72
+ contentRef: PropTypes.func,
73
+
74
+ /**
75
+ * An element or a function returning an element to focus by default
76
+ */
77
+ defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
78
+
79
+ /**
80
+ * An accessible label for the `<Popover />` content
81
+ */
82
+ screenReaderLabel: PropTypes.string,
83
+
84
+ /**
85
+ * The horizontal offset for the positioned content
86
+ */
87
+ offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
88
+
89
+ /**
90
+ * The vertical offset for the positioned content
91
+ */
92
+ offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
93
+
94
+ /**
95
+ * The parent in which to constrain the popover.
96
+ * One of: 'window', 'scroll-parent', 'parent', 'none', an element,
97
+ * or a function returning an element
98
+ */
99
+ constrain: PositionPropTypes.constrain,
100
+
101
+ /**
102
+ * Target element for positioning the Popover (if it differs from the trigger)
103
+ */
104
+ positionTarget: PropTypes.oneOfType([element, PropTypes.func]),
105
+
106
+ /**
107
+ * An element or a function returning an element to use as the mount node
108
+ * for the `<Popover />` (defaults to `document.body`)
109
+ */
110
+ mountNode: PositionPropTypes.mountNode,
111
+
112
+ /**
113
+ * Insert the element at the 'top' of the mountNode or at the 'bottom'
114
+ */
115
+ insertAt: PropTypes.oneOf(['bottom', 'top']),
116
+
117
+ /**
118
+ * An element, function returning an element, or array of elements that will
119
+ * not be hidden from the screen reader when the `<Popover />` is open
120
+ */
121
+ liveRegion: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.func]),
122
+
123
+ /**
124
+ * An id is generated if not supplied.
125
+ */
126
+ id: PropTypes.string,
127
+
128
+ /**
129
+ * Whether or not the content should offset to align by its arrow
130
+ */
131
+ shouldAlignArrow: PropTypes.bool,
132
+
133
+ /**
134
+ * Whether or not position should be tracked or just set on initial render
135
+ */
136
+ shouldTrackPosition: PropTypes.bool,
137
+
138
+ /**
139
+ * Should the `<Popover />` render offscreen when visually hidden
140
+ */
141
+ shouldRenderOffscreen: PropTypes.bool,
142
+
143
+ /**
144
+ * Whether focus should contained within the `<Popover/>` when it is open
145
+ */
146
+ shouldContainFocus: PropTypes.bool,
147
+
148
+ /**
149
+ * Whether focus should be returned to the trigger when the `<Popover/>` is closed
150
+ */
151
+ shouldReturnFocus: PropTypes.bool,
152
+
153
+ /**
154
+ * Should the `<Popover />` hide when clicks occur outside the content
155
+ */
156
+ shouldCloseOnDocumentClick: PropTypes.bool,
157
+
158
+ /**
159
+ * Should the `<Popover />` hide when the escape key is pressed
160
+ */
161
+ shouldCloseOnEscape: PropTypes.bool,
162
+
163
+ /**
164
+ * Should the content become focused when the trigger is blurred
165
+ */
166
+ shouldFocusContentOnTriggerBlur: PropTypes.bool,
167
+
168
+ /**
169
+ * Callback fired when content is shown. When controlled, this callback is
170
+ * fired when the Popover expects to be shown
171
+ */
172
+ onShowContent: PropTypes.func,
173
+
174
+ /**
175
+ * Callback fired when content is hidden. When controlled, this callback is
176
+ * fired when the Popover expects to be hidden
177
+ */
178
+ onHideContent: PropTypes.func,
179
+
180
+ /**
181
+ * Callback fired when content has been is initially positioned.
182
+ * If `shouldRenderOffscreen` is true, it will only fire once, the first
183
+ * time the content is shown
184
+ */
185
+ onPositioned: PropTypes.func,
186
+
187
+ /**
188
+ * Callback fired when the position changes
189
+ */
190
+ onPositionChanged: PropTypes.func,
191
+
192
+ /**
193
+ * Callback fired when component is clicked
194
+ */
195
+ onClick: PropTypes.func,
196
+
197
+ /**
198
+ * Callback fired when trigger is focused
199
+ */
200
+ onFocus: PropTypes.func,
201
+
202
+ /**
203
+ * Callback fired when component is blurred
204
+ */
205
+ onBlur: PropTypes.func,
206
+
207
+ /**
208
+ * Callback fired on keydown
209
+ */
210
+ onKeyDown: PropTypes.func,
211
+
212
+ /**
213
+ * Callback fired on keyup
214
+ */
215
+ onKeyUp: PropTypes.func,
216
+
217
+ /**
218
+ /**
219
+ * Callback fired when mouse is over trigger
220
+ */
221
+ onMouseOver: PropTypes.func,
222
+
223
+ /**
224
+ * Callback fired when mouse leaves trigger
225
+ */
226
+ onMouseOut: PropTypes.func,
227
+
228
+ /**
229
+ * The element that triggers the popover
230
+ */
231
+ renderTrigger: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
232
+
233
+ /**
234
+ * The content to be shown by the popover
235
+ */
236
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
237
+ };
238
+ 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'];
239
+ export { propTypes, allowedProps };