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