@splunk/react-ui 4.21.0 → 4.21.1

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 (83) hide show
  1. package/Accordion.js +425 -325
  2. package/Anchor.js +147 -117
  3. package/Animation.js +142 -94
  4. package/AnimationToggle.js +197 -193
  5. package/Box.js +145 -118
  6. package/Breadcrumbs.js +288 -206
  7. package/Button.js +488 -465
  8. package/ButtonGroup.js +160 -128
  9. package/ButtonSimple.js +543 -462
  10. package/CHANGELOG.md +7 -2
  11. package/Calendar.js +1111 -1001
  12. package/Card.js +771 -598
  13. package/CardLayout.js +205 -147
  14. package/Chip.js +509 -488
  15. package/Clickable.js +414 -352
  16. package/CloseButton.js +165 -142
  17. package/Code.js +1808 -2084
  18. package/Code.js.LICENSE.txt +8 -0
  19. package/CollapsiblePanel.js +586 -519
  20. package/Color.js +1066 -1069
  21. package/ColumnLayout.js +402 -363
  22. package/ComboBox.js +891 -794
  23. package/Concertina.js +997 -802
  24. package/ControlGroup.js +687 -594
  25. package/Date.js +567 -547
  26. package/DefinitionList.js +308 -234
  27. package/Divider.js +149 -118
  28. package/Dropdown.js +459 -416
  29. package/DualListbox.js +1479 -1541
  30. package/EventListener.js +94 -97
  31. package/File.js +1051 -969
  32. package/FormRows.js +883 -696
  33. package/Heading.js +216 -193
  34. package/Image.js +446 -402
  35. package/JSONTree.js +690 -551
  36. package/Layer.js +437 -410
  37. package/Link.js +336 -255
  38. package/List.js +213 -161
  39. package/Markdown.js +509 -487
  40. package/Menu.js +1105 -1056
  41. package/Message.js +475 -441
  42. package/MessageBar.js +387 -373
  43. package/Modal.js +810 -634
  44. package/ModalLayer.js +326 -243
  45. package/Monogram.js +308 -276
  46. package/Multiselect.js +3550 -3364
  47. package/Number.js +729 -687
  48. package/Paginator.js +510 -449
  49. package/Paragraph.js +145 -112
  50. package/Popover.js +1459 -1432
  51. package/Progress.js +301 -246
  52. package/RadioBar.js +610 -527
  53. package/RadioList.js +483 -444
  54. package/Resize.js +530 -489
  55. package/ResultsMenu.js +494 -455
  56. package/ScreenReaderContent.js +142 -111
  57. package/Scroll.js +595 -456
  58. package/ScrollContainerContext.js +197 -206
  59. package/Search.js +744 -650
  60. package/Select.js +2442 -2345
  61. package/SidePanel.js +390 -284
  62. package/Slider.js +669 -676
  63. package/SlidingPanels.js +639 -503
  64. package/SplitButton.js +464 -367
  65. package/StaticContent.js +161 -133
  66. package/StepBar.js +386 -358
  67. package/Switch.js +710 -640
  68. package/TabBar.js +726 -680
  69. package/TabLayout.js +406 -322
  70. package/Table.js +4842 -4616
  71. package/Text.js +1170 -1138
  72. package/TextArea.js +1102 -1090
  73. package/Tooltip.js +624 -581
  74. package/TransitionOpen.js +489 -422
  75. package/Typography.js +176 -153
  76. package/WaitSpinner.js +230 -206
  77. package/package.json +5 -5
  78. package/types/src/JSONTree/JSONTreeContext.d.ts +7 -0
  79. package/types/src/JSONTree/TreeNode.d.ts +5 -0
  80. package/useForceUpdate.js +112 -82
  81. package/useKeyPress.js +74 -71
  82. package/usePrevious.js +65 -65
  83. package/useRovingFocus.js +122 -138
package/Popover.js CHANGED
@@ -1,1482 +1,1509 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ // The require scope
4
- /******/ var __webpack_require__ = {};
5
- /******/
6
- /************************************************************************/
7
- /******/ /* webpack/runtime/compat get default export */
8
- /******/ (() => {
9
- /******/ // getDefaultExport function for compatibility with non-harmony modules
10
- /******/ __webpack_require__.n = (module) => {
11
- /******/ var getter = module && module.__esModule ?
12
- /******/ () => (module['default']) :
13
- /******/ () => (module);
14
- /******/ __webpack_require__.d(getter, { a: getter });
15
- /******/ return getter;
16
- /******/ };
17
- /******/ })();
18
- /******/
19
- /******/ /* webpack/runtime/define property getters */
20
- /******/ (() => {
21
- /******/ // define getter functions for harmony exports
22
- /******/ __webpack_require__.d = (exports, definition) => {
23
- /******/ for(var key in definition) {
24
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
25
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
26
- /******/ }
27
- /******/ }
28
- /******/ };
29
- /******/ })();
30
- /******/
31
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
32
- /******/ (() => {
33
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
34
- /******/ })();
35
- /******/
36
- /******/ /* webpack/runtime/make namespace object */
37
- /******/ (() => {
38
- /******/ // define __esModule on exports
39
- /******/ __webpack_require__.r = (exports) => {
40
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
41
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
42
- /******/ }
43
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
44
- /******/ };
45
- /******/ })();
46
- /******/
47
- /************************************************************************/
48
- var __webpack_exports__ = {};
49
- // ESM COMPAT FLAG
50
- __webpack_require__.r(__webpack_exports__);
51
-
52
- // EXPORTS
53
- __webpack_require__.d(__webpack_exports__, {
54
- PopoverContext: () => (/* reexport */ PopoverContext),
55
- "default": () => (/* reexport */ Popover_Popover)
56
- });
57
-
58
- ;// CONCATENATED MODULE: external "react"
59
- const external_react_namespaceObject = require("react");
60
- var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_namespaceObject);
61
- ;// CONCATENATED MODULE: external "prop-types"
62
- const external_prop_types_namespaceObject = require("prop-types");
63
- var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_namespaceObject);
64
- ;// CONCATENATED MODULE: external "react-dom"
65
- const external_react_dom_namespaceObject = require("react-dom");
66
- ;// CONCATENATED MODULE: external "lodash/clamp"
67
- const clamp_namespaceObject = require("lodash/clamp");
68
- var clamp_default = /*#__PURE__*/__webpack_require__.n(clamp_namespaceObject);
69
- ;// CONCATENATED MODULE: external "lodash/defer"
70
- const defer_namespaceObject = require("lodash/defer");
71
- var defer_default = /*#__PURE__*/__webpack_require__.n(defer_namespaceObject);
72
- ;// CONCATENATED MODULE: external "lodash/every"
73
- const every_namespaceObject = require("lodash/every");
74
- var every_default = /*#__PURE__*/__webpack_require__.n(every_namespaceObject);
75
- ;// CONCATENATED MODULE: external "lodash/has"
76
- const has_namespaceObject = require("lodash/has");
77
- var has_default = /*#__PURE__*/__webpack_require__.n(has_namespaceObject);
78
- ;// CONCATENATED MODULE: external "lodash/includes"
79
- const includes_namespaceObject = require("lodash/includes");
80
- var includes_default = /*#__PURE__*/__webpack_require__.n(includes_namespaceObject);
81
- ;// CONCATENATED MODULE: external "lodash/intersection"
82
- const intersection_namespaceObject = require("lodash/intersection");
83
- var intersection_default = /*#__PURE__*/__webpack_require__.n(intersection_namespaceObject);
84
- ;// CONCATENATED MODULE: external "lodash/isFinite"
85
- const isFinite_namespaceObject = require("lodash/isFinite");
86
- var isFinite_default = /*#__PURE__*/__webpack_require__.n(isFinite_namespaceObject);
87
- ;// CONCATENATED MODULE: external "lodash/isFunction"
88
- const isFunction_namespaceObject = require("lodash/isFunction");
89
- var isFunction_default = /*#__PURE__*/__webpack_require__.n(isFunction_namespaceObject);
90
- ;// CONCATENATED MODULE: external "lodash/keys"
91
- const keys_namespaceObject = require("lodash/keys");
92
- var keys_default = /*#__PURE__*/__webpack_require__.n(keys_namespaceObject);
93
- ;// CONCATENATED MODULE: external "lodash/omit"
94
- const omit_namespaceObject = require("lodash/omit");
95
- var omit_default = /*#__PURE__*/__webpack_require__.n(omit_namespaceObject);
96
- ;// CONCATENATED MODULE: external "lodash/throttle"
97
- const throttle_namespaceObject = require("lodash/throttle");
98
- var throttle_default = /*#__PURE__*/__webpack_require__.n(throttle_namespaceObject);
99
- ;// CONCATENATED MODULE: external "@splunk/themes"
100
- const themes_namespaceObject = require("@splunk/themes");
101
- ;// CONCATENATED MODULE: external "@splunk/react-ui/Animation"
102
- const Animation_namespaceObject = require("@splunk/react-ui/Animation");
103
- ;// CONCATENATED MODULE: external "@splunk/react-ui/EventListener"
104
- const EventListener_namespaceObject = require("@splunk/react-ui/EventListener");
105
- var EventListener_default = /*#__PURE__*/__webpack_require__.n(EventListener_namespaceObject);
106
- ;// CONCATENATED MODULE: external "@splunk/react-ui/Layer"
107
- const Layer_namespaceObject = require("@splunk/react-ui/Layer");
108
- var Layer_default = /*#__PURE__*/__webpack_require__.n(Layer_namespaceObject);
109
- ;// CONCATENATED MODULE: external "@splunk/react-ui/ScrollContainerContext"
110
- const ScrollContainerContext_namespaceObject = require("@splunk/react-ui/ScrollContainerContext");
111
- var ScrollContainerContext_default = /*#__PURE__*/__webpack_require__.n(ScrollContainerContext_namespaceObject);
112
- ;// CONCATENATED MODULE: external "@splunk/ui-utils/focus"
113
- const focus_namespaceObject = require("@splunk/ui-utils/focus");
114
- ;// CONCATENATED MODULE: ./src/Popover/getPlacement.ts
115
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
116
-
117
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
118
-
119
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
120
-
121
- function getInitialStyle(_ref) {
122
- var align = _ref.align,
123
- anchorPos = _ref.anchorPos,
124
- outerContainerEl = _ref.outerContainerEl,
125
- padding = _ref.padding,
126
- placement = _ref.placement;
127
-
128
- switch (placement) {
129
- case 'above':
130
- return {
131
- top: anchorPos.top - outerContainerEl.offsetHeight,
132
- left: align === 'edge' ? anchorPos.left - padding : anchorPos.middle - outerContainerEl.offsetWidth / 2
133
- };
134
-
135
- case 'below':
136
- // Align 'end' is only supported by below
137
- // TODO: SUI-5101 Enable users to align Popover and Dropdown
138
- if (align === 'end') {
139
- return {
140
- top: anchorPos.bottom,
141
- left: anchorPos.right - outerContainerEl.offsetWidth + padding
142
- };
143
- }
144
-
145
- return {
146
- top: anchorPos.bottom,
147
- left: align === 'edge' ? anchorPos.left - padding : anchorPos.middle - outerContainerEl.offsetWidth / 2
148
- };
149
-
150
- case 'left':
151
- return {
152
- top: align === 'edge' ? anchorPos.top - padding : anchorPos.center - outerContainerEl.offsetHeight / 2,
153
- left: anchorPos.left - outerContainerEl.offsetWidth
154
- };
155
-
156
- case 'right':
157
- return {
158
- top: align === 'edge' ? anchorPos.top - padding : anchorPos.center - outerContainerEl.offsetHeight / 2,
159
- left: anchorPos.right
160
- };
161
-
162
- default:
163
- throw new Error("".concat(placement, " is not a valid placement value. Valid options are: 'above', 'below', 'left', or 'right'"));
164
- }
165
- }
166
-
167
- function getPlacement(args) {
168
- var align = args.align,
169
- anchorPos = args.anchorPos,
170
- scrollContainerPos = args.scrollContainerPos,
171
- canCoverAnchor = args.canCoverAnchor,
172
- defaultPlacement = args.defaultPlacement,
173
- outerContainerEl = args.outerContainerEl,
174
- padding = args.padding,
175
- repositionMode = args.repositionMode,
176
- windowHeight = args.windowHeight,
177
- windowWidth = args.windowWidth;
178
- var repositionFlip = repositionMode === 'flip';
179
- var repositionAny = repositionMode === 'any';
180
- var canReposition = repositionFlip || repositionAny;
181
- var placement = args.placement || defaultPlacement; // Translate vertical/horizontal to above/below/left/right
182
-
183
- if (defaultPlacement === 'vertical') {
184
- placement = anchorPos.top > windowHeight - anchorPos.bottom ? 'above' : 'below';
185
- } else if (defaultPlacement === 'horizontal') {
186
- placement = anchorPos.left > windowWidth - anchorPos.right ? 'left' : 'right';
187
- }
188
-
189
- var resolvedPlacement = placement; // Initialize the result variables. These will be mutated as needed and returned.
190
-
191
- var _getInitialStyle = getInitialStyle({
192
- align: align,
193
- anchorPos: anchorPos,
194
- outerContainerEl: outerContainerEl,
195
- padding: padding,
196
- placement: resolvedPlacement
197
- }),
198
- top = _getInitialStyle.top,
199
- left = _getInitialStyle.left;
200
-
201
- var bottom = 'auto';
202
- var maxWidth = windowWidth;
203
- var maxHeight = windowHeight;
204
- var placementStatus = resolvedPlacement; // Boolean convenience variables to simplify positioning logic.
205
-
206
- var canPlaceAbove = anchorPos.top - outerContainerEl.offsetHeight > 0;
207
- var canPlaceBelow = anchorPos.bottom + outerContainerEl.offsetHeight < windowHeight;
208
- var canPlaceLeft = anchorPos.left - outerContainerEl.offsetWidth > 0;
209
- var canPlaceRight = anchorPos.right + outerContainerEl.offsetWidth < windowWidth;
210
- var significantlyMoreSpaceAbove = anchorPos.top * 0.7 > windowHeight - anchorPos.bottom;
211
- var offScreenRight = (align === 'edge' ? anchorPos.left + outerContainerEl.offsetWidth - padding : anchorPos.middle + outerContainerEl.offsetWidth / 2) > windowWidth;
212
- var offScreenLeft = (align === 'edge' ? anchorPos.left - padding : anchorPos.middle - outerContainerEl.offsetWidth / 2) < 0;
213
- var offScreenTop = (align === 'edge' ? anchorPos.top - padding : anchorPos.top - outerContainerEl.offsetHeight / 2) < 0;
214
- var offScreenBottom = (align === 'edge' ? anchorPos.top + outerContainerEl.offsetHeight - padding : anchorPos.bottom + outerContainerEl.offsetHeight / 2) > windowHeight; // Handle each of the four placement options individually.
215
-
216
- if (placementStatus === 'above') {
217
- if (!canPlaceAbove && canReposition) {
218
- if (canPlaceBelow) {
219
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
220
- placement: 'below'
221
- }));
222
- }
223
-
224
- if (repositionAny && canPlaceRight) {
225
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
226
- placement: 'right'
227
- }));
228
- }
229
-
230
- if (repositionAny && canPlaceLeft) {
231
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
232
- placement: 'left'
233
- }));
234
- }
235
-
236
- if (canCoverAnchor) {
237
- placementStatus = 'misaligned';
238
- top = 0;
239
- }
240
- }
241
-
242
- if (placementStatus !== 'misaligned') {
243
- bottom = windowHeight - top - outerContainerEl.offsetHeight;
244
-
245
- if (scrollContainerPos) {
246
- bottom = Math.min(bottom, windowHeight - scrollContainerPos.top);
247
- }
248
-
249
- top = 'auto';
250
- }
251
-
252
- if (offScreenRight) {
253
- left = Math.max(windowWidth - outerContainerEl.offsetWidth, 0);
254
- } else if (offScreenLeft) {
255
- left = 0;
1
+ /******/ (() => {
2
+ // webpackBootstrap
3
+ /******/ "use strict";
4
+ /******/ // The require scope
5
+ /******/ var e = {};
6
+ /******/
7
+ /************************************************************************/
8
+ /******/ /* webpack/runtime/compat get default export */
9
+ /******/ (() => {
10
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
11
+ /******/ e.n = t => {
12
+ /******/ var r = t && t.__esModule ?
13
+ /******/ () => t["default"]
14
+ /******/ : () => t
15
+ /******/;
16
+ e.d(r, {
17
+ a: r
18
+ });
19
+ /******/ return r;
20
+ /******/ };
21
+ /******/ })();
22
+ /******/
23
+ /******/ /* webpack/runtime/define property getters */
24
+ /******/ (() => {
25
+ /******/ // define getter functions for harmony exports
26
+ /******/ e.d = (t, r) => {
27
+ /******/ for (var n in r) {
28
+ /******/ if (e.o(r, n) && !e.o(t, n)) {
29
+ /******/ Object.defineProperty(t, n, {
30
+ enumerable: true,
31
+ get: r[n]
32
+ });
33
+ /******/ }
34
+ /******/ }
35
+ /******/ };
36
+ /******/ })();
37
+ /******/
38
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
39
+ /******/ (() => {
40
+ /******/ e.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t)
41
+ /******/;
42
+ })();
43
+ /******/
44
+ /******/ /* webpack/runtime/make namespace object */
45
+ /******/ (() => {
46
+ /******/ // define __esModule on exports
47
+ /******/ e.r = e => {
48
+ /******/ if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
49
+ /******/ Object.defineProperty(e, Symbol.toStringTag, {
50
+ value: "Module"
51
+ });
52
+ /******/ }
53
+ /******/ Object.defineProperty(e, "__esModule", {
54
+ value: true
55
+ });
56
+ /******/ };
57
+ /******/ })();
58
+ /******/
59
+ /************************************************************************/ var t = {};
60
+ // ESM COMPAT FLAG
61
+ e.r(t);
62
+ // EXPORTS
63
+ e.d(t, {
64
+ PopoverContext: () => /* reexport */ $,
65
+ default: () => /* reexport */ Ze
66
+ });
67
+ // CONCATENATED MODULE: external "react"
68
+ const r = require("react");
69
+ var n = e.n(r);
70
+ // CONCATENATED MODULE: external "prop-types"
71
+ const o = require("prop-types");
72
+ var a = e.n(o);
73
+ // CONCATENATED MODULE: external "react-dom"
74
+ const i = require("react-dom");
75
+ // CONCATENATED MODULE: external "lodash/clamp"
76
+ const l = require("lodash/clamp");
77
+ var c = e.n(l);
78
+ // CONCATENATED MODULE: external "lodash/defer"
79
+ const f = require("lodash/defer");
80
+ var s = e.n(f);
81
+ // CONCATENATED MODULE: external "lodash/every"
82
+ const u = require("lodash/every");
83
+ var p = e.n(u);
84
+ // CONCATENATED MODULE: external "lodash/has"
85
+ const h = require("lodash/has");
86
+ var d = e.n(h);
87
+ // CONCATENATED MODULE: external "lodash/includes"
88
+ const v = require("lodash/includes");
89
+ var m = e.n(v);
90
+ // CONCATENATED MODULE: external "lodash/intersection"
91
+ const b = require("lodash/intersection");
92
+ var y = e.n(b);
93
+ // CONCATENATED MODULE: external "lodash/isFinite"
94
+ const g = require("lodash/isFinite");
95
+ var w = e.n(g);
96
+ // CONCATENATED MODULE: external "lodash/isFunction"
97
+ const S = require("lodash/isFunction");
98
+ var O = e.n(S);
99
+ // CONCATENATED MODULE: external "lodash/keys"
100
+ const P = require("lodash/keys");
101
+ var E = e.n(P);
102
+ // CONCATENATED MODULE: external "lodash/omit"
103
+ const C = require("lodash/omit");
104
+ var j = e.n(C);
105
+ // CONCATENATED MODULE: external "lodash/throttle"
106
+ const k = require("lodash/throttle");
107
+ var x = e.n(k);
108
+ // CONCATENATED MODULE: external "@splunk/themes"
109
+ const A = require("@splunk/themes");
110
+ // CONCATENATED MODULE: external "@splunk/react-ui/Animation"
111
+ const T = require("@splunk/react-ui/Animation");
112
+ // CONCATENATED MODULE: external "@splunk/react-ui/EventListener"
113
+ const R = require("@splunk/react-ui/EventListener");
114
+ var q = e.n(R);
115
+ // CONCATENATED MODULE: external "@splunk/react-ui/Layer"
116
+ const W = require("@splunk/react-ui/Layer");
117
+ var M = e.n(W);
118
+ // CONCATENATED MODULE: external "@splunk/react-ui/ScrollContainerContext"
119
+ const H = require("@splunk/react-ui/ScrollContainerContext");
120
+ var _ = e.n(H);
121
+ // CONCATENATED MODULE: external "@splunk/ui-utils/focus"
122
+ const L = require("@splunk/ui-utils/focus");
123
+ // CONCATENATED MODULE: ./src/Popover/getPlacement.ts
124
+ function D(e, t) {
125
+ var r = Object.keys(e);
126
+ if (Object.getOwnPropertySymbols) {
127
+ var n = Object.getOwnPropertySymbols(e);
128
+ if (t) n = n.filter((function(t) {
129
+ return Object.getOwnPropertyDescriptor(e, t).enumerable;
130
+ }));
131
+ r.push.apply(r, n);
132
+ }
133
+ return r;
256
134
  }
257
-
258
- if (!canCoverAnchor) {
259
- maxHeight = anchorPos.top;
135
+ function I(e) {
136
+ for (var t = 1; t < arguments.length; t++) {
137
+ var r = arguments[t] != null ? arguments[t] : {};
138
+ if (t % 2) {
139
+ D(Object(r), true).forEach((function(t) {
140
+ F(e, t, r[t]);
141
+ }));
142
+ } else if (Object.getOwnPropertyDescriptors) {
143
+ Object.defineProperties(e, Object.getOwnPropertyDescriptors(r));
144
+ } else {
145
+ D(Object(r)).forEach((function(t) {
146
+ Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
147
+ }));
148
+ }
149
+ }
150
+ return e;
260
151
  }
261
- }
262
-
263
- if (placementStatus === 'below') {
264
- if (!canPlaceBelow && canReposition) {
265
- if (canPlaceAbove && significantlyMoreSpaceAbove) {
266
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
267
- placement: 'above'
268
- }));
269
- }
270
-
271
- if (repositionAny && canPlaceRight) {
272
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
273
- placement: 'right'
274
- }));
275
- }
276
-
277
- if (repositionAny && canPlaceLeft) {
278
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
279
- placement: 'left'
280
- }));
281
- }
282
-
283
- if (canCoverAnchor) {
284
- placementStatus = 'misaligned';
285
- top = 0;
286
- }
152
+ function F(e, t, r) {
153
+ if (t in e) {
154
+ Object.defineProperty(e, t, {
155
+ value: r,
156
+ enumerable: true,
157
+ configurable: true,
158
+ writable: true
159
+ });
160
+ } else {
161
+ e[t] = r;
162
+ }
163
+ return e;
287
164
  }
288
-
289
- if (scrollContainerPos) {
290
- top = Math.min(top, scrollContainerPos.bottom);
165
+ function N(e) {
166
+ var t = e.align, r = e.anchorPos, n = e.outerContainerEl, o = e.padding, a = e.placement;
167
+ switch (a) {
168
+ case "above":
169
+ return {
170
+ top: r.top - n.offsetHeight,
171
+ left: t === "edge" ? r.left - o : r.middle - n.offsetWidth / 2
172
+ };
173
+
174
+ case "below":
175
+ // Align 'end' is only supported by below
176
+ // TODO: SUI-5101 Enable users to align Popover and Dropdown
177
+ if (t === "end") {
178
+ return {
179
+ top: r.bottom,
180
+ left: r.right - n.offsetWidth + o
181
+ };
182
+ }
183
+ return {
184
+ top: r.bottom,
185
+ left: t === "edge" ? r.left - o : r.middle - n.offsetWidth / 2
186
+ };
187
+
188
+ case "left":
189
+ return {
190
+ top: t === "edge" ? r.top - o : r.center - n.offsetHeight / 2,
191
+ left: r.left - n.offsetWidth
192
+ };
193
+
194
+ case "right":
195
+ return {
196
+ top: t === "edge" ? r.top - o : r.center - n.offsetHeight / 2,
197
+ left: r.right
198
+ };
199
+
200
+ default:
201
+ throw new Error("".concat(a, " is not a valid placement value. Valid options are: 'above', 'below', 'left', or 'right'"));
202
+ }
291
203
  }
292
-
293
- if (offScreenRight) {
294
- left = Math.max(windowWidth - outerContainerEl.offsetWidth, 0);
295
- } else if (offScreenLeft) {
296
- left = 0;
204
+ function z(e) {
205
+ var t = e.align, r = e.anchorPos, n = e.scrollContainerPos, o = e.canCoverAnchor, a = e.defaultPlacement, i = e.outerContainerEl, l = e.padding, c = e.repositionMode, f = e.windowHeight, s = e.windowWidth;
206
+ var u = c === "flip";
207
+ var p = c === "any";
208
+ var h = u || p;
209
+ var d = e.placement || a;
210
+ // Translate vertical/horizontal to above/below/left/right
211
+ if (a === "vertical") {
212
+ d = r.top > f - r.bottom ? "above" : "below";
213
+ } else if (a === "horizontal") {
214
+ d = r.left > s - r.right ? "left" : "right";
215
+ }
216
+ var v = d;
217
+ // Initialize the result variables. These will be mutated as needed and returned.
218
+ var m = N({
219
+ align: t,
220
+ anchorPos: r,
221
+ outerContainerEl: i,
222
+ padding: l,
223
+ placement: v
224
+ }), b = m.top, y = m.left;
225
+ var g = "auto";
226
+ var w = s;
227
+ var S = f;
228
+ var O = v;
229
+ // Boolean convenience variables to simplify positioning logic.
230
+ var P = r.top - i.offsetHeight > 0;
231
+ var E = r.bottom + i.offsetHeight < f;
232
+ var C = r.left - i.offsetWidth > 0;
233
+ var j = r.right + i.offsetWidth < s;
234
+ var k = r.top * .7 > f - r.bottom;
235
+ var x = (t === "edge" ? r.left + i.offsetWidth - l : r.middle + i.offsetWidth / 2) > s;
236
+ var A = (t === "edge" ? r.left - l : r.middle - i.offsetWidth / 2) < 0;
237
+ var T = (t === "edge" ? r.top - l : r.top - i.offsetHeight / 2) < 0;
238
+ var R = (t === "edge" ? r.top + i.offsetHeight - l : r.bottom + i.offsetHeight / 2) > f;
239
+ // Handle each of the four placement options individually.
240
+ if (O === "above") {
241
+ if (!P && h) {
242
+ if (E) {
243
+ return z(I(I({}, e), {}, {
244
+ placement: "below"
245
+ }));
246
+ }
247
+ if (p && j) {
248
+ return z(I(I({}, e), {}, {
249
+ placement: "right"
250
+ }));
251
+ }
252
+ if (p && C) {
253
+ return z(I(I({}, e), {}, {
254
+ placement: "left"
255
+ }));
256
+ }
257
+ if (o) {
258
+ O = "misaligned";
259
+ b = 0;
260
+ }
261
+ }
262
+ if (O !== "misaligned") {
263
+ g = f - b - i.offsetHeight;
264
+ if (n) {
265
+ g = Math.min(g, f - n.top);
266
+ }
267
+ b = "auto";
268
+ }
269
+ if (x) {
270
+ y = Math.max(s - i.offsetWidth, 0);
271
+ } else if (A) {
272
+ y = 0;
273
+ }
274
+ if (!o) {
275
+ S = r.top;
276
+ }
277
+ }
278
+ if (O === "below") {
279
+ if (!E && h) {
280
+ if (P && k) {
281
+ return z(I(I({}, e), {}, {
282
+ placement: "above"
283
+ }));
284
+ }
285
+ if (p && j) {
286
+ return z(I(I({}, e), {}, {
287
+ placement: "right"
288
+ }));
289
+ }
290
+ if (p && C) {
291
+ return z(I(I({}, e), {}, {
292
+ placement: "left"
293
+ }));
294
+ }
295
+ if (o) {
296
+ O = "misaligned";
297
+ b = 0;
298
+ }
299
+ }
300
+ if (n) {
301
+ b = Math.min(b, n.bottom);
302
+ }
303
+ if (x) {
304
+ y = Math.max(s - i.offsetWidth, 0);
305
+ } else if (A) {
306
+ y = 0;
307
+ }
308
+ if (!o) {
309
+ S = f - r.bottom;
310
+ }
311
+ }
312
+ if (O === "left") {
313
+ if (!C && h) {
314
+ if (j) {
315
+ return z(I(I({}, e), {}, {
316
+ placement: "right"
317
+ }));
318
+ }
319
+ if (p && E) {
320
+ return z(I(I({}, e), {}, {
321
+ placement: "below"
322
+ }));
323
+ }
324
+ if (p && P) {
325
+ return z(I(I({}, e), {}, {
326
+ placement: "above"
327
+ }));
328
+ }
329
+ if (o) {
330
+ O = "misaligned";
331
+ b = 0;
332
+ }
333
+ }
334
+ if (T) {
335
+ b = 0;
336
+ } else if (R) {
337
+ b = Math.max(f - i.offsetHeight, 0);
338
+ }
339
+ if (!o) {
340
+ w = r.left;
341
+ }
342
+ }
343
+ if (O === "right") {
344
+ if (!j && h) {
345
+ if (C) {
346
+ return z(I(I({}, e), {}, {
347
+ placement: "left"
348
+ }));
349
+ }
350
+ if (p && E) {
351
+ return z(I(I({}, e), {}, {
352
+ placement: "below"
353
+ }));
354
+ }
355
+ if (p && P) {
356
+ return z(I(I({}, e), {}, {
357
+ placement: "above"
358
+ }));
359
+ }
360
+ if (o) {
361
+ O = "misaligned";
362
+ b = 0;
363
+ }
364
+ }
365
+ if (T) {
366
+ b = 0;
367
+ } else if (R) {
368
+ b = Math.max(f - i.offsetHeight, 0);
369
+ }
370
+ if (!o) {
371
+ w = s - r.left;
372
+ }
373
+ }
374
+ return {
375
+ placement: O,
376
+ maxHeight: S,
377
+ maxWidth: w,
378
+ outerContainerStyle: {
379
+ top: b,
380
+ left: y,
381
+ bottom: g
382
+ }
383
+ };
297
384
  }
298
-
299
- if (!canCoverAnchor) {
300
- maxHeight = windowHeight - anchorPos.bottom;
385
+ // CONCATENATED MODULE: ./src/Popover/PopoverContext.tsx
386
+ var $ = (0, r.createContext)({});
387
+ // CONCATENATED MODULE: external "react-spring"
388
+ const U = require("react-spring");
389
+ // CONCATENATED MODULE: external "styled-components"
390
+ const K = require("styled-components");
391
+ var V = e.n(K);
392
+ // CONCATENATED MODULE: ./src/Popover/PopoverStyles.ts
393
+ var B = (0, A.pick)({
394
+ enterprise: "8px",
395
+ prisma: 0
396
+ });
397
+ var X = V()(U.animated.div).withConfig({
398
+ displayName: "PopoverStyles__Styled",
399
+ componentId: "sc-1nahsvw-0"
400
+ })([ "position:fixed;z-index:", ";left:-300%;top:-300%;" ], A.variables.zindexPopover);
401
+ var Y = V().div.withConfig({
402
+ displayName: "PopoverStyles__StyledBox",
403
+ componentId: "sc-1nahsvw-1"
404
+ })([ "", ";", ";", ";" ], A.mixins.reset("block"), (function(e) {
405
+ var t = e.$open;
406
+ return !t && (0, K.css)([ "pointer-events:none;" ]);
407
+ }), (function(e) {
408
+ var t = e.$appearance;
409
+ return t !== "none" && (0, K.css)([ "padding:8px;" ]);
410
+ }));
411
+ var G = V().div.withConfig({
412
+ displayName: "PopoverStyles__StyledContent",
413
+ componentId: "sc-1nahsvw-2"
414
+ })([ "", "" ], (0, A.pickVariant)("$appearance", {
415
+ normal: (0, K.css)([ "background-color:", ";color:", ";border:", ";box-shadow:", ";border-radius:", ";" ], A.variables.backgroundColorPopup, A.variables.contentColorDefault, (0,
416
+ A.pick)({
417
+ enterprise: {
418
+ light: A.variables.border,
419
+ dark: A.variables.border
420
+ },
421
+ prisma: "none"
422
+ }), (0, A.pick)({
423
+ enterprise: {
424
+ light: (0, K.css)([ "0 2px 2px ", "" ], A.mixins.colorWithAlpha(A.variables.gray20, .1)),
425
+ dark: "0 1px 2px #000"
426
+ },
427
+ prisma: A.variables.overlayShadow
428
+ }), A.variables.borderRadius),
429
+ // Enterprise Only
430
+ inverted: (0, K.css)([ "background-color:", ";color:", ";" ], (0, A.pick)({
431
+ light: A.variables.gray20,
432
+ dark: A.variables.white
433
+ }), (0, A.pick)({
434
+ light: A.variables.white,
435
+ dark: A.variables.gray30
436
+ }))
437
+ }));
438
+ // Enterprise Only
439
+ var J = V().div.withConfig({
440
+ displayName: "PopoverStyles__StyledArrow",
441
+ componentId: "sc-1nahsvw-3"
442
+ })([ "width:0;height:0;border-left:", " solid transparent;border-right:", " solid transparent;position:absolute;border-bottom-width:", ";border-bottom-style:solid;", "" ], B, B, B, (0,
443
+ A.pickVariant)("$appearance", {
444
+ normal: (0, K.css)([ "border-bottom-color:", ";&::before{content:'';display:block;width:0;height:0;border-left:", " solid transparent;border-right:", " solid transparent;border-bottom:", " solid ", ";position:absolute;top:1px;left:0;margin-left:-", ";}" ], (0,
445
+ A.pick)({
446
+ light: A.variables.borderColor,
447
+ dark: A.variables.black
448
+ }), B, B, B, A.variables.backgroundColor, B),
449
+ inverted: (0, K.css)([ "border-bottom-color:", ";" ], (0, A.pick)({
450
+ light: A.variables.gray20,
451
+ dark: A.variables.white
452
+ }))
453
+ }));
454
+ var Q = V().div.withConfig({
455
+ displayName: "PopoverStyles__StyledLowerRightCorner",
456
+ componentId: "sc-1nahsvw-4"
457
+ })([ "position:fixed;right:0;bottom:0;" ]);
458
+ var Z = V().svg.withConfig({
459
+ displayName: "PopoverStyles__StyledHitArea",
460
+ componentId: "sc-1nahsvw-5"
461
+ })([ "position:fixed;pointer-events:none;path{pointer-events:auto;stroke-width:0;stroke:transparent;fill:transparent;}" ]);
462
+ // CONCATENATED MODULE: ./src/Popover/PopoverHitArea.tsx
463
+ function ee(e, t) {
464
+ return ae(e) || oe(e, t) || re(e, t) || te();
301
465
  }
302
- }
303
-
304
- if (placementStatus === 'left') {
305
- if (!canPlaceLeft && canReposition) {
306
- if (canPlaceRight) {
307
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
308
- placement: 'right'
309
- }));
310
- }
311
-
312
- if (repositionAny && canPlaceBelow) {
313
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
314
- placement: 'below'
315
- }));
316
- }
317
-
318
- if (repositionAny && canPlaceAbove) {
319
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
320
- placement: 'above'
321
- }));
322
- }
323
-
324
- if (canCoverAnchor) {
325
- placementStatus = 'misaligned';
326
- top = 0;
327
- }
466
+ function te() {
467
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
328
468
  }
329
-
330
- if (offScreenTop) {
331
- top = 0;
332
- } else if (offScreenBottom) {
333
- top = Math.max(windowHeight - outerContainerEl.offsetHeight, 0);
469
+ function re(e, t) {
470
+ if (!e) return;
471
+ if (typeof e === "string") return ne(e, t);
472
+ var r = Object.prototype.toString.call(e).slice(8, -1);
473
+ if (r === "Object" && e.constructor) r = e.constructor.name;
474
+ if (r === "Map" || r === "Set") return Array.from(e);
475
+ if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return ne(e, t);
334
476
  }
335
-
336
- if (!canCoverAnchor) {
337
- maxWidth = anchorPos.left;
477
+ function ne(e, t) {
478
+ if (t == null || t > e.length) t = e.length;
479
+ for (var r = 0, n = new Array(t); r < t; r++) {
480
+ n[r] = e[r];
481
+ }
482
+ return n;
338
483
  }
339
- }
340
-
341
- if (placementStatus === 'right') {
342
- if (!canPlaceRight && canReposition) {
343
- if (canPlaceLeft) {
344
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
345
- placement: 'left'
346
- }));
347
- }
348
-
349
- if (repositionAny && canPlaceBelow) {
350
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
351
- placement: 'below'
352
- }));
353
- }
354
-
355
- if (repositionAny && canPlaceAbove) {
356
- return getPlacement(_objectSpread(_objectSpread({}, args), {}, {
357
- placement: 'above'
358
- }));
359
- }
360
-
361
- if (canCoverAnchor) {
362
- placementStatus = 'misaligned';
363
- top = 0;
364
- }
484
+ function oe(e, t) {
485
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(e))) return;
486
+ var r = [];
487
+ var n = true;
488
+ var o = false;
489
+ var a = undefined;
490
+ try {
491
+ for (var i = e[Symbol.iterator](), l; !(n = (l = i.next()).done); n = true) {
492
+ r.push(l.value);
493
+ if (t && r.length === t) break;
494
+ }
495
+ } catch (e) {
496
+ o = true;
497
+ a = e;
498
+ } finally {
499
+ try {
500
+ if (!n && i["return"] != null) i["return"]();
501
+ } finally {
502
+ if (o) throw a;
503
+ }
504
+ }
505
+ return r;
365
506
  }
366
-
367
- if (offScreenTop) {
368
- top = 0;
369
- } else if (offScreenBottom) {
370
- top = Math.max(windowHeight - outerContainerEl.offsetHeight, 0);
507
+ function ae(e) {
508
+ if (Array.isArray(e)) return e;
371
509
  }
372
-
373
- if (!canCoverAnchor) {
374
- maxWidth = windowWidth - anchorPos.left;
510
+ var ie = {
511
+ anchorRect: a().object,
512
+ popoverEl: a().object,
513
+ popoverPlacement: a().oneOf([ "above", "below", "left", "right", "misaligned" ])
514
+ };
515
+ var le = function e(t) {
516
+ var r = t.anchorRect, n = t.popoverEl, o = t.popoverPlacement;
517
+ if (r != null && n != null && o != null) {
518
+ var a = n.getBoundingClientRect();
519
+ if (o === "above" || o === "below") {
520
+ var i = r.left - a.left;
521
+ var l = r.height;
522
+ var c = 0;
523
+ if (o === "above") {
524
+ l = 0;
525
+ c = r.height;
526
+ }
527
+ var f = "0 ".concat(l);
528
+ var s = "".concat(a.width, " ").concat(l);
529
+ var u = "".concat(i, " ").concat(l);
530
+ var p = "".concat(i, " ").concat(c);
531
+ var h = "".concat(i + r.width, " ").concat(l);
532
+ var d = "".concat(i + r.width, " ").concat(c);
533
+ var v = "\n M ".concat(f, "\n S ").concat(u, " , ").concat(p, "\n L ").concat(u, "\n L ").concat(h, "\n L ").concat(d, "\n S ").concat(h, " , ").concat(s, "\n ");
534
+ return {
535
+ hitAreaPath: v,
536
+ hitAreaStyle: {
537
+ left: a.left,
538
+ top: r.top,
539
+ width: a.width,
540
+ height: r.height
541
+ }
542
+ };
543
+ }
544
+ if (o === "left" || o === "right") {
545
+ var m = r.top - a.top;
546
+ var b = 0;
547
+ var y = r.width;
548
+ if (o === "right") {
549
+ b = r.width;
550
+ y = 0;
551
+ }
552
+ var g = "".concat(b, " 0");
553
+ var w = "".concat(b, " ").concat(a.height);
554
+ var S = "".concat(b, " ").concat(m);
555
+ var O = "".concat(y, " ").concat(m);
556
+ var P = "".concat(b, " ").concat(m + r.height);
557
+ var E = "".concat(y, " ").concat(m + r.height);
558
+ var C = "\n M ".concat(g, "\n S ").concat(S, " , ").concat(O, "\n L ").concat(S, "\n L ").concat(P, "\n L ").concat(E, "\n S ").concat(P, " , ").concat(w, "\n ");
559
+ return {
560
+ hitAreaPath: C,
561
+ hitAreaStyle: {
562
+ left: r.left,
563
+ top: a.top,
564
+ width: r.width,
565
+ height: a.height
566
+ }
567
+ };
568
+ }
569
+ }
570
+ return {
571
+ hitAreaPath: null,
572
+ hitAreaStyle: {}
573
+ };
574
+ };
575
+ var ce = n().forwardRef((function(e, t) {
576
+ var o = e.anchorRect, a = e.popoverEl, i = e.popoverPlacement;
577
+ var l = (0, r.useState)(null), c = ee(l, 2), f = c[0], s = c[1];
578
+ var u = (0, r.useState)({}), p = ee(u, 2), h = p[0], d = p[1];
579
+ (0, r.useEffect)((function() {
580
+ var e = le({
581
+ anchorRect: o,
582
+ popoverEl: a,
583
+ popoverPlacement: i
584
+ }), t = e.hitAreaPath, r = e.hitAreaStyle;
585
+ s(t);
586
+ d(r);
587
+ }), [ o, a, i ]);
588
+ if (f != null) {
589
+
590
+ return n().createElement(Z, {
591
+ "data-test": "popover-hit-area",
592
+ style: h
593
+ }, n().createElement("path", {
594
+ d: f,
595
+ ref: t
596
+ }));
597
+ }
598
+ return null;
599
+ }));
600
+ ce.propTypes = ie;
601
+ /* harmony default export */ const fe = ce;
602
+ // CONCATENATED MODULE: ./src/utils/ssrDocument.ts
603
+ /* eslint-disable @typescript-eslint/no-empty-function */
604
+ var se = {
605
+ body: {
606
+ appendChild: function e() {
607
+ return [];
608
+ }
609
+ },
610
+ addEventListener: function e() {},
611
+ removeEventListener: function e() {},
612
+ activeElement: {
613
+ blur: function e() {},
614
+ nodeName: ""
615
+ },
616
+ querySelector: function e() {
617
+ return null;
618
+ },
619
+ querySelectorAll: function e() {
620
+ return [];
621
+ },
622
+ getElementById: function e() {
623
+ return null;
624
+ },
625
+ createEvent: function e() {
626
+ return {
627
+ initEvent: function e() {}
628
+ };
629
+ },
630
+ createElement: function e() {
631
+ return {
632
+ children: [],
633
+ childNodes: [],
634
+ style: {},
635
+ setAttribute: function e() {},
636
+ getElementsByTagName: function e() {
637
+ return [];
638
+ }
639
+ };
640
+ },
641
+ createElementNS: function e() {
642
+ return {};
643
+ },
644
+ importNode: function e() {
645
+ return null;
646
+ },
647
+ location: {
648
+ hash: "",
649
+ host: "",
650
+ hostname: "",
651
+ href: "",
652
+ origin: "",
653
+ pathname: "",
654
+ protocol: "",
655
+ search: ""
656
+ }
657
+ };
658
+ function ue() {
659
+ var e = typeof document !== "undefined" ? document : se;
660
+ return e;
375
661
  }
376
- }
377
-
378
- return {
379
- placement: placementStatus,
380
- maxHeight: maxHeight,
381
- maxWidth: maxWidth,
382
- outerContainerStyle: {
383
- top: top,
384
- left: left,
385
- bottom: bottom
662
+ // CONCATENATED MODULE: ./src/utils/ssrWindow.ts
663
+ /* eslint-disable @typescript-eslint/no-empty-function */
664
+ var pe = {
665
+ document: se,
666
+ navigator: {
667
+ userAgent: ""
668
+ },
669
+ location: {
670
+ hash: "",
671
+ host: "",
672
+ hostname: "",
673
+ href: "",
674
+ origin: "",
675
+ pathname: "",
676
+ protocol: "",
677
+ search: ""
678
+ },
679
+ history: {
680
+ replaceState: function e() {},
681
+ pushState: function e() {},
682
+ go: function e() {},
683
+ back: function e() {}
684
+ },
685
+ CustomEvent: function e() {
686
+ return this;
687
+ },
688
+ addEventListener: function e() {},
689
+ removeEventListener: function e() {},
690
+ getComputedStyle: function e() {
691
+ return {
692
+ getPropertyValue: function e() {
693
+ return "";
694
+ }
695
+ };
696
+ },
697
+ Image: function e() {},
698
+ Date: function e() {},
699
+ screen: {},
700
+ setTimeout: function e() {},
701
+ clearTimeout: function e() {},
702
+ matchMedia: function e() {
703
+ return {};
704
+ },
705
+ requestAnimationFrame: function e(t) {
706
+ if (typeof setTimeout === "undefined") {
707
+ t();
708
+ return null;
709
+ }
710
+ return setTimeout(t, 0);
711
+ },
712
+ cancelAnimationFrame: function e(t) {
713
+ if (typeof setTimeout === "undefined") {
714
+ return;
715
+ }
716
+ clearTimeout(t);
717
+ }
718
+ };
719
+ function he() {
720
+ var e = typeof window !== "undefined" ? window : pe;
721
+ return e;
386
722
  }
387
- };
388
- }
389
- ;// CONCATENATED MODULE: ./src/Popover/PopoverContext.tsx
390
-
391
- var PopoverContext = /*#__PURE__*/(0,external_react_namespaceObject.createContext)({});
392
-
393
- ;// CONCATENATED MODULE: external "react-spring"
394
- const external_react_spring_namespaceObject = require("react-spring");
395
- ;// CONCATENATED MODULE: external "styled-components"
396
- const external_styled_components_namespaceObject = require("styled-components");
397
- var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_namespaceObject);
398
- ;// CONCATENATED MODULE: ./src/Popover/PopoverStyles.ts
399
-
400
-
401
-
402
- var arrowHeight = (0,themes_namespaceObject.pick)({
403
- enterprise: '8px',
404
- prisma: 0
405
- });
406
- var Styled = external_styled_components_default()(external_react_spring_namespaceObject.animated.div).withConfig({
407
- displayName: "PopoverStyles__Styled",
408
- componentId: "sc-1nahsvw-0"
409
- })(["position:fixed;z-index:", ";left:-300%;top:-300%;"], themes_namespaceObject.variables.zindexPopover);
410
- var StyledBox = external_styled_components_default().div.withConfig({
411
- displayName: "PopoverStyles__StyledBox",
412
- componentId: "sc-1nahsvw-1"
413
- })(["", ";", ";", ";"], themes_namespaceObject.mixins.reset('block'), function (_ref) {
414
- var $open = _ref.$open;
415
- return !$open && (0,external_styled_components_namespaceObject.css)(["pointer-events:none;"]);
416
- }, function (_ref2) {
417
- var $appearance = _ref2.$appearance;
418
- return $appearance !== 'none' && (0,external_styled_components_namespaceObject.css)(["padding:8px;"]);
419
- });
420
- var StyledContent = external_styled_components_default().div.withConfig({
421
- displayName: "PopoverStyles__StyledContent",
422
- componentId: "sc-1nahsvw-2"
423
- })(["", ""], (0,themes_namespaceObject.pickVariant)('$appearance', {
424
- normal: (0,external_styled_components_namespaceObject.css)(["background-color:", ";color:", ";border:", ";box-shadow:", ";border-radius:", ";"], themes_namespaceObject.variables.backgroundColorPopup, themes_namespaceObject.variables.contentColorDefault, (0,themes_namespaceObject.pick)({
425
- enterprise: {
426
- light: themes_namespaceObject.variables.border,
427
- dark: themes_namespaceObject.variables.border
428
- },
429
- prisma: 'none'
430
- }), (0,themes_namespaceObject.pick)({
431
- enterprise: {
432
- light: (0,external_styled_components_namespaceObject.css)(["0 2px 2px ", ""], themes_namespaceObject.mixins.colorWithAlpha(themes_namespaceObject.variables.gray20, 0.1)),
433
- dark: '0 1px 2px #000'
434
- },
435
- prisma: themes_namespaceObject.variables.overlayShadow
436
- }), themes_namespaceObject.variables.borderRadius),
437
- // Enterprise Only
438
- inverted: (0,external_styled_components_namespaceObject.css)(["background-color:", ";color:", ";"], (0,themes_namespaceObject.pick)({
439
- light: themes_namespaceObject.variables.gray20,
440
- dark: themes_namespaceObject.variables.white
441
- }), (0,themes_namespaceObject.pick)({
442
- light: themes_namespaceObject.variables.white,
443
- dark: themes_namespaceObject.variables.gray30
444
- }))
445
- })); // Enterprise Only
446
-
447
- var StyledArrow = external_styled_components_default().div.withConfig({
448
- displayName: "PopoverStyles__StyledArrow",
449
- componentId: "sc-1nahsvw-3"
450
- })(["width:0;height:0;border-left:", " solid transparent;border-right:", " solid transparent;position:absolute;border-bottom-width:", ";border-bottom-style:solid;", ""], arrowHeight, arrowHeight, arrowHeight, (0,themes_namespaceObject.pickVariant)('$appearance', {
451
- normal: (0,external_styled_components_namespaceObject.css)(["border-bottom-color:", ";&::before{content:'';display:block;width:0;height:0;border-left:", " solid transparent;border-right:", " solid transparent;border-bottom:", " solid ", ";position:absolute;top:1px;left:0;margin-left:-", ";}"], (0,themes_namespaceObject.pick)({
452
- light: themes_namespaceObject.variables.borderColor,
453
- dark: themes_namespaceObject.variables.black
454
- }), arrowHeight, arrowHeight, arrowHeight, themes_namespaceObject.variables.backgroundColor, arrowHeight),
455
- inverted: (0,external_styled_components_namespaceObject.css)(["border-bottom-color:", ";"], (0,themes_namespaceObject.pick)({
456
- light: themes_namespaceObject.variables.gray20,
457
- dark: themes_namespaceObject.variables.white
458
- }))
459
- }));
460
- var StyledLowerRightCorner = external_styled_components_default().div.withConfig({
461
- displayName: "PopoverStyles__StyledLowerRightCorner",
462
- componentId: "sc-1nahsvw-4"
463
- })(["position:fixed;right:0;bottom:0;"]);
464
- var StyledHitArea = external_styled_components_default().svg.withConfig({
465
- displayName: "PopoverStyles__StyledHitArea",
466
- componentId: "sc-1nahsvw-5"
467
- })(["position:fixed;pointer-events:none;path{pointer-events:auto;stroke-width:0;stroke:transparent;fill:transparent;}"]);
468
-
469
- ;// CONCATENATED MODULE: ./src/Popover/PopoverHitArea.tsx
470
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
471
-
472
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
473
-
474
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
475
-
476
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
477
-
478
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
479
-
480
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
481
-
482
-
483
-
484
-
485
- var propTypes = {
486
- anchorRect: (external_prop_types_default()).object,
487
- popoverEl: (external_prop_types_default()).object,
488
- popoverPlacement: external_prop_types_default().oneOf(['above', 'below', 'left', 'right', 'misaligned'])
489
- };
490
-
491
- var getHitAreaSettings = function getHitAreaSettings(_ref) {
492
- var anchorRect = _ref.anchorRect,
493
- popoverEl = _ref.popoverEl,
494
- popoverPlacement = _ref.popoverPlacement;
495
-
496
- if (anchorRect != null && popoverEl != null && popoverPlacement != null) {
497
- var menuRect = popoverEl.getBoundingClientRect();
498
-
499
- if (popoverPlacement === 'above' || popoverPlacement === 'below') {
500
- var anchorLeftEdge = anchorRect.left - menuRect.left;
501
- var verticalStart = anchorRect.height;
502
- var verticalEnd = 0;
503
-
504
- if (popoverPlacement === 'above') {
505
- verticalStart = 0;
506
- verticalEnd = anchorRect.height;
507
- }
508
-
509
- var menuStart = "0 ".concat(verticalStart);
510
- var menuEnd = "".concat(menuRect.width, " ").concat(verticalStart);
511
- var anchorStartNear = "".concat(anchorLeftEdge, " ").concat(verticalStart);
512
- var anchorStartFar = "".concat(anchorLeftEdge, " ").concat(verticalEnd);
513
- var anchorEndNear = "".concat(anchorLeftEdge + anchorRect.width, " ").concat(verticalStart);
514
- var anchorEndFar = "".concat(anchorLeftEdge + anchorRect.width, " ").concat(verticalEnd);
515
- var hitAreaPath = "\n M ".concat(menuStart, "\n S ").concat(anchorStartNear, " , ").concat(anchorStartFar, "\n L ").concat(anchorStartNear, "\n L ").concat(anchorEndNear, "\n L ").concat(anchorEndFar, "\n S ").concat(anchorEndNear, " , ").concat(menuEnd, "\n ");
516
- return {
517
- hitAreaPath: hitAreaPath,
518
- hitAreaStyle: {
519
- left: menuRect.left,
520
- top: anchorRect.top,
521
- width: menuRect.width,
522
- height: anchorRect.height
723
+ // CONCATENATED MODULE: ./src/utils/getBoundingClientRect.ts
724
+ function de(e, t) {
725
+ var r = Object.keys(e);
726
+ if (Object.getOwnPropertySymbols) {
727
+ var n = Object.getOwnPropertySymbols(e);
728
+ if (t) n = n.filter((function(t) {
729
+ return Object.getOwnPropertyDescriptor(e, t).enumerable;
730
+ }));
731
+ r.push.apply(r, n);
523
732
  }
524
- };
733
+ return r;
525
734
  }
526
-
527
- if (popoverPlacement === 'left' || popoverPlacement === 'right') {
528
- var anchorTopEdge = anchorRect.top - menuRect.top;
529
- var horizontalStart = 0;
530
- var horizontalEnd = anchorRect.width;
531
-
532
- if (popoverPlacement === 'right') {
533
- horizontalStart = anchorRect.width;
534
- horizontalEnd = 0;
535
- }
536
-
537
- var _menuStart = "".concat(horizontalStart, " 0");
538
-
539
- var _menuEnd = "".concat(horizontalStart, " ").concat(menuRect.height);
540
-
541
- var _anchorStartNear = "".concat(horizontalStart, " ").concat(anchorTopEdge);
542
-
543
- var _anchorStartFar = "".concat(horizontalEnd, " ").concat(anchorTopEdge);
544
-
545
- var _anchorEndNear = "".concat(horizontalStart, " ").concat(anchorTopEdge + anchorRect.height);
546
-
547
- var _anchorEndFar = "".concat(horizontalEnd, " ").concat(anchorTopEdge + anchorRect.height);
548
-
549
- var _hitAreaPath = "\n M ".concat(_menuStart, "\n S ").concat(_anchorStartNear, " , ").concat(_anchorStartFar, "\n L ").concat(_anchorStartNear, "\n L ").concat(_anchorEndNear, "\n L ").concat(_anchorEndFar, "\n S ").concat(_anchorEndNear, " , ").concat(_menuEnd, "\n ");
550
-
551
- return {
552
- hitAreaPath: _hitAreaPath,
553
- hitAreaStyle: {
554
- left: anchorRect.left,
555
- top: menuRect.top,
556
- width: anchorRect.width,
557
- height: menuRect.height
735
+ function ve(e) {
736
+ for (var t = 1; t < arguments.length; t++) {
737
+ var r = arguments[t] != null ? arguments[t] : {};
738
+ if (t % 2) {
739
+ de(Object(r), true).forEach((function(t) {
740
+ me(e, t, r[t]);
741
+ }));
742
+ } else if (Object.getOwnPropertyDescriptors) {
743
+ Object.defineProperties(e, Object.getOwnPropertyDescriptors(r));
744
+ } else {
745
+ de(Object(r)).forEach((function(t) {
746
+ Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
747
+ }));
748
+ }
558
749
  }
559
- };
750
+ return e;
560
751
  }
561
- }
562
-
563
- return {
564
- hitAreaPath: null,
565
- hitAreaStyle: {}
566
- };
567
- };
568
-
569
- var PopoverHitArea = /*#__PURE__*/external_react_default().forwardRef(function (_ref2, ref) {
570
- var anchorRect = _ref2.anchorRect,
571
- popoverEl = _ref2.popoverEl,
572
- popoverPlacement = _ref2.popoverPlacement;
573
-
574
- var _useState = (0,external_react_namespaceObject.useState)(null),
575
- _useState2 = _slicedToArray(_useState, 2),
576
- hitAreaPathState = _useState2[0],
577
- setHitAreaPathState = _useState2[1];
578
-
579
- var _useState3 = (0,external_react_namespaceObject.useState)({}),
580
- _useState4 = _slicedToArray(_useState3, 2),
581
- hitAreaStyleState = _useState4[0],
582
- setHitAreaStyleState = _useState4[1];
583
-
584
- (0,external_react_namespaceObject.useEffect)(function () {
585
- var _getHitAreaSettings = getHitAreaSettings({
586
- anchorRect: anchorRect,
587
- popoverEl: popoverEl,
588
- popoverPlacement: popoverPlacement
589
- }),
590
- hitAreaPath = _getHitAreaSettings.hitAreaPath,
591
- hitAreaStyle = _getHitAreaSettings.hitAreaStyle;
592
-
593
- setHitAreaPathState(hitAreaPath);
594
- setHitAreaStyleState(hitAreaStyle);
595
- }, [anchorRect, popoverEl, popoverPlacement]);
596
-
597
- if (hitAreaPathState != null) {
598
- return /*#__PURE__*/external_react_default().createElement(StyledHitArea, {
599
- "data-test": "popover-hit-area",
600
- style: hitAreaStyleState
601
- }, /*#__PURE__*/external_react_default().createElement("path", {
602
- d: hitAreaPathState,
603
- ref: ref
604
- }));
605
- }
606
-
607
- return null;
608
- });
609
- PopoverHitArea.propTypes = propTypes;
610
- /* harmony default export */ const Popover_PopoverHitArea = (PopoverHitArea);
611
- ;// CONCATENATED MODULE: ./src/utils/ssrDocument.ts
612
- /* eslint-disable @typescript-eslint/no-empty-function */
613
- var ssrDocument = {
614
- body: {
615
- appendChild: function appendChild() {
616
- return [];
752
+ function me(e, t, r) {
753
+ if (t in e) {
754
+ Object.defineProperty(e, t, {
755
+ value: r,
756
+ enumerable: true,
757
+ configurable: true,
758
+ writable: true
759
+ });
760
+ } else {
761
+ e[t] = r;
762
+ }
763
+ return e;
617
764
  }
618
- },
619
- addEventListener: function addEventListener() {},
620
- removeEventListener: function removeEventListener() {},
621
- activeElement: {
622
- blur: function blur() {},
623
- nodeName: ''
624
- },
625
- querySelector: function querySelector() {
626
- return null;
627
- },
628
- querySelectorAll: function querySelectorAll() {
629
- return [];
630
- },
631
- getElementById: function getElementById() {
632
- return null;
633
- },
634
- createEvent: function createEvent() {
635
- return {
636
- initEvent: function initEvent() {}
637
- };
638
- },
639
- createElement: function createElement() {
640
- return {
641
- children: [],
642
- childNodes: [],
643
- style: {},
644
- setAttribute: function setAttribute() {},
645
- getElementsByTagName: function getElementsByTagName() {
646
- return [];
647
- }
648
- };
649
- },
650
- createElementNS: function createElementNS() {
651
- return {};
652
- },
653
- importNode: function importNode() {
654
- return null;
655
- },
656
- location: {
657
- hash: '',
658
- host: '',
659
- hostname: '',
660
- href: '',
661
- origin: '',
662
- pathname: '',
663
- protocol: '',
664
- search: ''
665
- }
666
- };
667
-
668
- function getDocument() {
669
- var doc = typeof document !== 'undefined' ? document : ssrDocument;
670
- return doc;
671
- }
672
-
673
-
674
- ;// CONCATENATED MODULE: ./src/utils/ssrWindow.ts
675
- /* eslint-disable @typescript-eslint/no-empty-function */
676
-
677
- var ssrWindow = {
678
- document: ssrDocument,
679
- navigator: {
680
- userAgent: ''
681
- },
682
- location: {
683
- hash: '',
684
- host: '',
685
- hostname: '',
686
- href: '',
687
- origin: '',
688
- pathname: '',
689
- protocol: '',
690
- search: ''
691
- },
692
- history: {
693
- replaceState: function replaceState() {},
694
- pushState: function pushState() {},
695
- go: function go() {},
696
- back: function back() {}
697
- },
698
- CustomEvent: function CustomEvent() {
699
- return this;
700
- },
701
- addEventListener: function addEventListener() {},
702
- removeEventListener: function removeEventListener() {},
703
- getComputedStyle: function getComputedStyle() {
704
- return {
705
- getPropertyValue: function getPropertyValue() {
706
- return '';
707
- }
708
- };
709
- },
710
- Image: function Image() {},
711
- Date: function Date() {},
712
- screen: {},
713
- setTimeout: function setTimeout() {},
714
- clearTimeout: function clearTimeout() {},
715
- matchMedia: function matchMedia() {
716
- return {};
717
- },
718
- requestAnimationFrame: function requestAnimationFrame(callback) {
719
- if (typeof setTimeout === 'undefined') {
720
- callback();
721
- return null;
765
+ // Checks if browser is Safari
766
+ function be() {
767
+ return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
722
768
  }
723
-
724
- return setTimeout(callback, 0);
725
- },
726
- cancelAnimationFrame: function cancelAnimationFrame(id) {
727
- if (typeof setTimeout === 'undefined') {
728
- return;
769
+ // Formats return value to DOMRect
770
+ function ye(e) {
771
+ return ve(ve({}, e), {}, {
772
+ top: e.y,
773
+ left: e.x,
774
+ right: e.x + e.width,
775
+ bottom: e.y + e.height
776
+ });
729
777
  }
730
-
731
- clearTimeout(id);
732
- }
733
- };
734
-
735
- function getWindow() {
736
- var win = typeof window !== 'undefined' ? window : ssrWindow;
737
- return win;
738
- }
739
-
740
-
741
- ;// CONCATENATED MODULE: ./src/utils/getBoundingClientRect.ts
742
- function getBoundingClientRect_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
743
-
744
- function getBoundingClientRect_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { getBoundingClientRect_ownKeys(Object(source), true).forEach(function (key) { getBoundingClientRect_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { getBoundingClientRect_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
745
-
746
- function getBoundingClientRect_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
747
-
748
- // Checks if browser is Safari
749
-
750
- function isUserAgentSafari() {
751
- return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
752
- } // Formats return value to DOMRect
753
-
754
-
755
- function rectToClientRect(rect) {
756
- return getBoundingClientRect_objectSpread(getBoundingClientRect_objectSpread({}, rect), {}, {
757
- top: rect.y,
758
- left: rect.x,
759
- right: rect.x + rect.width,
760
- bottom: rect.y + rect.height
761
- });
762
- }
763
- /**
778
+ /**
764
779
  * Provides DOMRect information about the size of an element and its position relative to the viewport.
765
780
  * Accounts for Safari's use of visual viewport and adds offsets to set as layout viewport.
766
781
  * @param {Element} element - The element to be evaluated
767
782
  * @param {boolean} offsets - Use when position of element relative to the layout viewport offsets are needed for Safari.
768
783
  * @returns {Omit<DOMRect, 'toJSON'>}
769
784
  * @public
770
- */
771
-
772
-
773
- function getBoundingClientRect(element, offsets) {
774
- var _window$visualViewpor, _window$visualViewpor2;
775
-
776
- var clientRect = element.getBoundingClientRect();
777
- var addVisualOffsets = isUserAgentSafari();
778
-
779
- if (!offsets || !addVisualOffsets) {
780
- return clientRect;
781
- }
782
-
783
- var window = getWindow();
784
- var x = clientRect.left + (((_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 ? void 0 : _window$visualViewpor.offsetLeft) || 0);
785
- var y = clientRect.top + (((_window$visualViewpor2 = window.visualViewport) === null || _window$visualViewpor2 === void 0 ? void 0 : _window$visualViewpor2.offsetTop) || 0);
786
- var width = clientRect.width,
787
- height = clientRect.height;
788
- return rectToClientRect({
789
- width: width,
790
- height: height,
791
- x: x,
792
- y: y
793
- });
794
- }
795
-
796
-
797
- ;// CONCATENATED MODULE: ./src/utils/updateReactRef.ts
798
- /**
785
+ */ function ge(e, t) {
786
+ var r, n;
787
+ var o = e.getBoundingClientRect();
788
+ var a = be();
789
+ if (!t || !a) {
790
+ return o;
791
+ }
792
+ var i = he();
793
+ var l = o.left + (((r = i.visualViewport) === null || r === void 0 ? void 0 : r.offsetLeft) || 0);
794
+ var c = o.top + (((n = i.visualViewport) === null || n === void 0 ? void 0 : n.offsetTop) || 0);
795
+ var f = o.width, s = o.height;
796
+ return ye({
797
+ width: f,
798
+ height: s,
799
+ x: l,
800
+ y: c
801
+ });
802
+ }
803
+ // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
804
+ /**
799
805
  * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
800
806
  *
801
807
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
802
808
  * @param current - The new value of the ref.
803
809
  */
804
- function updateReactRef(ref, current) {
805
- if (ref) {
806
- if (typeof ref === 'function') {
807
- ref(current);
808
- } else {
809
- // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
810
- // the intention here is to signal "we will take care of setting 'current', not you".
811
- ref.current = current; // eslint-disable-line no-param-reassign
812
- }
813
- }
814
- }
815
-
816
-
817
- ;// CONCATENATED MODULE: ./src/Popover/Popover.tsx
818
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
819
-
820
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
821
-
822
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || Popover_unsupportedIterableToArray(arr) || _nonIterableSpread(); }
823
-
824
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
825
-
826
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
827
-
828
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return Popover_arrayLikeToArray(arr); }
829
-
830
- function Popover_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
831
-
832
- function Popover_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { Popover_ownKeys(Object(source), true).forEach(function (key) { Popover_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { Popover_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
833
-
834
- function Popover_slicedToArray(arr, i) { return Popover_arrayWithHoles(arr) || Popover_iterableToArrayLimit(arr, i) || Popover_unsupportedIterableToArray(arr, i) || Popover_nonIterableRest(); }
835
-
836
- function Popover_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
837
-
838
- function Popover_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return Popover_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Popover_arrayLikeToArray(o, minLen); }
839
-
840
- function Popover_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
841
-
842
- function Popover_iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
843
-
844
- function Popover_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
845
-
846
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
847
-
848
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
849
-
850
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
851
-
852
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
853
-
854
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
855
-
856
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
857
-
858
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
859
-
860
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
861
-
862
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
863
-
864
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
865
-
866
- function Popover_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
867
-
868
-
869
-
870
-
871
-
872
-
873
-
874
-
875
-
876
-
877
-
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
- /** @public */
896
-
897
- var possibleCloseReasons = ['clickAway', 'escapeKey', 'offScreen', 'tabKey'];
898
- var Popover_propTypes = {
899
- align: external_prop_types_default().oneOf(['center', 'edge', 'theme', 'end']),
900
- anchor: (external_prop_types_default()).object,
901
- animation: (external_prop_types_default()).bool,
902
- animationConfig: (external_prop_types_default()).object,
903
- appearance: external_prop_types_default().oneOf(['normal', 'inverted', 'none']),
904
- autoCloseWhenOffScreen: (external_prop_types_default()).bool,
905
- canCoverAnchor: (external_prop_types_default()).bool,
906
- children: external_prop_types_default().oneOfType([(external_prop_types_default()).node, (external_prop_types_default()).func]),
907
- closeReasons: external_prop_types_default().arrayOf(external_prop_types_default().oneOf(possibleCloseReasons)),
908
- defaultPlacement: external_prop_types_default().oneOf(['above', 'below', 'left', 'right', 'vertical', 'horizontal']),
909
- elementRef: external_prop_types_default().oneOfType([(external_prop_types_default()).func, (external_prop_types_default()).object]),
910
- id: (external_prop_types_default()).string,
911
- hitAreaRef: external_prop_types_default().oneOfType([(external_prop_types_default()).func, (external_prop_types_default()).object]),
912
- onRequestClose: (external_prop_types_default()).func,
913
- open: (external_prop_types_default()).bool,
914
- outerRef: external_prop_types_default().oneOfType([(external_prop_types_default()).func, (external_prop_types_default()).object]),
915
- pointTo: external_prop_types_default().shape({
916
- x: (external_prop_types_default()).number,
917
- y: (external_prop_types_default()).number
918
- }),
919
- repositionMode: external_prop_types_default().oneOf(['none', 'flip', 'any']),
920
- retainFocus: (external_prop_types_default()).bool,
921
- takeFocus: (external_prop_types_default()).bool,
922
- splunkTheme: (external_prop_types_default()).object
923
- };
924
- var defaultProps = {
925
- align: 'theme',
926
- animation: true,
927
- animationConfig: {},
928
- appearance: 'normal',
929
- autoCloseWhenOffScreen: true,
930
- canCoverAnchor: false,
931
- closeReasons: possibleCloseReasons,
932
- defaultPlacement: 'below',
933
- open: false,
934
- repositionMode: 'flip',
935
- retainFocus: true,
936
- takeFocus: false
937
- };
938
-
939
- // eslint-disable-next-line @typescript-eslint/ban-types
940
- function everyApproxEqual(a, b) {
941
- var threshold = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
942
- return !!a && !!b && every_default()(a, function (val, key) {
943
- if (isFinite_default()(val)) {
944
- return Math.abs(b[key] - val) <= threshold;
810
+ function we(e, t) {
811
+ if (e) {
812
+ if (typeof e === "function") {
813
+ e(t);
814
+ } else {
815
+ // the public signature of this util uses React.Ref<T> to mirror the way React types refs.
816
+ // the intention here is to signal "we will take care of setting 'current', not you".
817
+ e.current = t;
818
+ // eslint-disable-line no-param-reassign
819
+ }
820
+ }
945
821
  }
946
-
947
- return b[key] === val;
948
- });
949
- }
950
-
951
- function isHTMLElement(container) {
952
- return container !== window && container !== window.document;
953
- }
954
- /**
955
- * `Popover` is used to create layovers such as dropdowns, contextual menus, or tooltips. Use
956
- * this only when the other components don't provide sufficient functionality or control. A controlled
957
- * `Dropdown` covers use cases where you might consider using `Popover` directly.
958
- */
959
-
960
-
961
- var Popover = /*#__PURE__*/function (_Component) {
962
- _inherits(Popover, _Component);
963
-
964
- var _super = _createSuper(Popover);
965
-
966
- _createClass(Popover, null, [{
967
- key: "getArrowStyle",
968
- // @docs-props-type PopoverPropsBase
969
- value: function getArrowStyle(_ref) {
970
- var anchorPos = _ref.anchorPos,
971
- arrowHeight = _ref.arrowHeight,
972
- placement = _ref.placement,
973
- outerContainerStyle = _ref.outerContainerStyle,
974
- outerContainerEl = _ref.outerContainerEl;
975
-
976
- if (placement === 'misaligned') {
977
- return [{
978
- display: 'none'
979
- }];
980
- }
981
-
982
- var style = {
983
- display: 'block'
984
- };
985
- var maxVertDiff = outerContainerEl.offsetHeight / 2 - 22;
986
- var minVertDiff = -(outerContainerEl.offsetHeight / 2 - 15);
987
- var initVertDiff = anchorPos.center - (outerContainerStyle.top + outerContainerEl.offsetHeight / 2) - arrowHeight / 2;
988
- var vertDiff = clamp_default()(initVertDiff, minVertDiff, maxVertDiff);
989
- var horizontalDiff = anchorPos.middle - (outerContainerStyle.left + outerContainerEl.offsetWidth / 2) - arrowHeight;
990
- var transformMetadata = {
991
- left: {
992
- translateX: arrowHeight / 2,
993
- translateY: vertDiff,
994
- rotate: 90
995
- },
996
- right: {
997
- translateX: -arrowHeight / 2,
998
- translateY: vertDiff,
999
- rotate: -90
1000
- },
1001
- above: {
1002
- translateX: horizontalDiff,
1003
- translateY: 0,
1004
- rotate: 180
1005
- },
1006
- below: {
1007
- translateX: horizontalDiff,
1008
- translateY: 0,
1009
- rotate: 0
822
+ // CONCATENATED MODULE: ./src/Popover/Popover.tsx
823
+ function Se(e) {
824
+ "@babel/helpers - typeof";
825
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
826
+ Se = function e(t) {
827
+ return typeof t;
828
+ };
829
+ } else {
830
+ Se = function e(t) {
831
+ return t && typeof Symbol === "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
832
+ };
1010
833
  }
1011
- };
1012
- var transformMeta = transformMetadata[placement];
1013
- style.transform = "translate(".concat(transformMeta.translateX, "px, ").concat(transformMeta.translateY, "px) rotate(").concat(transformMeta.rotate, "deg)"); // set new positions
1014
-
1015
- var origin1 = {
1016
- left: 'right',
1017
- right: 'left',
1018
- above: 'bottom',
1019
- below: 'top'
1020
- };
1021
- style[origin1[placement]] = '1px';
1022
- var origin2 = {
1023
- left: 'top',
1024
- right: 'top',
1025
- above: 'left',
1026
- below: 'left'
1027
- };
1028
- style[origin2[placement]] = '50%';
1029
- return [style, transformMeta];
834
+ return Se(e);
1030
835
  }
1031
- }]);
1032
-
1033
- function Popover(props) {
1034
- var _this;
1035
-
1036
- _classCallCheck(this, Popover);
1037
-
1038
- _this = _super.call(this, props);
1039
-
1040
- Popover_defineProperty(_assertThisInitialized(_this), "outerContainerEl", null);
1041
-
1042
- Popover_defineProperty(_assertThisInitialized(_this), "innerContainerEl", null);
1043
-
1044
- Popover_defineProperty(_assertThisInitialized(_this), "arrow", null);
1045
-
1046
- Popover_defineProperty(_assertThisInitialized(_this), "windowSizeMeasurementEl", null);
1047
-
1048
- Popover_defineProperty(_assertThisInitialized(_this), "handleScroll", void 0);
1049
-
1050
- Popover_defineProperty(_assertThisInitialized(_this), "handleWindowScroll", void 0);
1051
-
1052
- Popover_defineProperty(_assertThisInitialized(_this), "allowAnimationUpdates", true);
1053
-
1054
- Popover_defineProperty(_assertThisInitialized(_this), "getElPosition", function (anchorEl) {
1055
- var offsets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1056
- var rect = getBoundingClientRect(anchorEl, offsets);
1057
- var a = {
1058
- width: anchorEl.offsetWidth,
1059
- height: anchorEl.offsetHeight
1060
- };
1061
- var pointTo = _this.props.pointTo;
1062
- var pointToHorizontal = pointTo && has_default()(pointTo, 'x');
1063
- var pointToVertical = pointTo && has_default()(pointTo, 'y');
1064
- a.left = pointToHorizontal ? rect.left + ((pointTo === null || pointTo === void 0 ? void 0 : pointTo.x) || 0) : rect.left;
1065
- a.top = pointToVertical ? rect.top + ((pointTo === null || pointTo === void 0 ? void 0 : pointTo.y) || 0) : rect.top;
1066
- a.right = pointToHorizontal ? a.left + a.width : rect.left + a.width || rect.right;
1067
- a.bottom = pointToVertical ? a.top + a.height : rect.top + a.height || rect.bottom;
1068
- a.middle = pointToHorizontal ? a.left : rect.left + (a.right - rect.left) / 2;
1069
- a.center = pointToVertical ? a.top : rect.top + (a.bottom - rect.top) / 2;
1070
- return a;
1071
- });
1072
-
1073
- Popover_defineProperty(_assertThisInitialized(_this), "setPlacement", function (scrolling) {
1074
- var window = getWindow();
1075
-
1076
- _this.setState(function (state) {
1077
- var _state$arrowStyleTran;
1078
-
1079
- var _this$props = _this.props,
1080
- align = _this$props.align,
1081
- anchor = _this$props.anchor,
1082
- autoCloseWhenOffScreen = _this$props.autoCloseWhenOffScreen,
1083
- canCoverAnchor = _this$props.canCoverAnchor,
1084
- defaultPlacement = _this$props.defaultPlacement,
1085
- open = _this$props.open,
1086
- repositionMode = _this$props.repositionMode,
1087
- splunkTheme = _this$props.splunkTheme;
1088
- var scrollContainer = _this.context || window;
1089
- var isPrisma = splunkTheme.isPrisma; // If these conditions are not met, we cannot set the popover.
1090
-
1091
- if (!open || !_this.outerContainerEl || !anchor || !state.anchorEl || !_this.windowSizeMeasurementEl) {
1092
- if (false) {}
1093
-
1094
- return null;
836
+ function Oe() {
837
+ Oe = Object.assign || function(e) {
838
+ for (var t = 1; t < arguments.length; t++) {
839
+ var r = arguments[t];
840
+ for (var n in r) {
841
+ if (Object.prototype.hasOwnProperty.call(r, n)) {
842
+ e[n] = r[n];
843
+ }
844
+ }
845
+ }
846
+ return e;
847
+ };
848
+ return Oe.apply(this, arguments);
849
+ }
850
+ function Pe(e) {
851
+ return je(e) || Ce(e) || Re(e) || Ee();
852
+ }
853
+ function Ee() {
854
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
855
+ }
856
+ function Ce(e) {
857
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(e)) return Array.from(e);
858
+ }
859
+ function je(e) {
860
+ if (Array.isArray(e)) return qe(e);
861
+ }
862
+ function ke(e, t) {
863
+ var r = Object.keys(e);
864
+ if (Object.getOwnPropertySymbols) {
865
+ var n = Object.getOwnPropertySymbols(e);
866
+ if (t) n = n.filter((function(t) {
867
+ return Object.getOwnPropertyDescriptor(e, t).enumerable;
868
+ }));
869
+ r.push.apply(r, n);
1095
870
  }
1096
-
1097
- var anchorPosViewport = _this.getElPosition(state.anchorEl);
1098
-
1099
- var anchorPos = _this.getElPosition(state.anchorEl, true);
1100
-
1101
- var scrollContainerPos = isHTMLElement(scrollContainer) ? _this.getElPosition(scrollContainer) : undefined;
1102
-
1103
- if (scrolling && autoCloseWhenOffScreen) {
1104
- if (_this.autoCloseWhenOffScreen(anchorPosViewport, scrollContainerPos)) {
1105
- return null;
1106
- }
871
+ return r;
872
+ }
873
+ function xe(e) {
874
+ for (var t = 1; t < arguments.length; t++) {
875
+ var r = arguments[t] != null ? arguments[t] : {};
876
+ if (t % 2) {
877
+ ke(Object(r), true).forEach((function(t) {
878
+ Ke(e, t, r[t]);
879
+ }));
880
+ } else if (Object.getOwnPropertyDescriptors) {
881
+ Object.defineProperties(e, Object.getOwnPropertyDescriptors(r));
882
+ } else {
883
+ ke(Object(r)).forEach((function(t) {
884
+ Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
885
+ }));
886
+ }
1107
887
  }
1108
-
1109
- var arrowHeight = isPrisma ? 0 : 8;
1110
- var padding = 8;
1111
- var defaultAlignment = isPrisma ? 'edge' : 'center';
1112
-
1113
- var _getPlacement = getPlacement({
1114
- align: align === 'theme' ? defaultAlignment : align,
1115
- anchorPos: anchorPos,
1116
- scrollContainerPos: scrollContainerPos,
1117
- canCoverAnchor: canCoverAnchor,
1118
- defaultPlacement: defaultPlacement,
1119
- repositionMode: repositionMode,
1120
- outerContainerEl: _this.outerContainerEl,
1121
- padding: padding,
1122
- windowWidth: _this.windowSizeMeasurementEl.offsetLeft,
1123
- windowHeight: _this.windowSizeMeasurementEl.offsetTop
1124
- }),
1125
- placement = _getPlacement.placement,
1126
- outerContainerStyle = _getPlacement.outerContainerStyle,
1127
- maxHeight = _getPlacement.maxHeight,
1128
- maxWidth = _getPlacement.maxWidth;
1129
-
1130
- var _ref2 = _this.arrow ? Popover.getArrowStyle({
1131
- anchorPos: anchorPos,
1132
- arrowHeight: arrowHeight,
1133
- outerContainerStyle: outerContainerStyle,
1134
- placement: placement,
1135
- outerContainerEl: _this.outerContainerEl
1136
- }) : [],
1137
- _ref3 = Popover_slicedToArray(_ref2, 2),
1138
- arrowStyle = _ref3[0],
1139
- arrowStyleTransformMeta = _ref3[1];
1140
-
1141
- var hasArrow = _this.props.appearance !== 'none' && !isPrisma;
1142
- var baseCheck = everyApproxEqual(anchorPos, state.anchorPos) && everyApproxEqual(outerContainerStyle, state.outerContainerStyle) && placement === state.placement && maxHeight === state.maxHeight && maxWidth === state.maxWidth;
1143
- var arrowCheck = everyApproxEqual(omit_default()(arrowStyle, 'transform'), omit_default()(state.arrowStyle, 'transform')) && everyApproxEqual(arrowStyleTransformMeta !== null && arrowStyleTransformMeta !== void 0 ? arrowStyleTransformMeta : {}, (_state$arrowStyleTran = state.arrowStyleTransformMeta) !== null && _state$arrowStyleTran !== void 0 ? _state$arrowStyleTran : {}); // If none of the position data has changed, do not set state.
1144
-
1145
- if (baseCheck && (!hasArrow || hasArrow && arrowCheck)) {
1146
- return null;
888
+ return e;
889
+ }
890
+ function Ae(e, t) {
891
+ return Me(e) || We(e, t) || Re(e, t) || Te();
892
+ }
893
+ function Te() {
894
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
895
+ }
896
+ function Re(e, t) {
897
+ if (!e) return;
898
+ if (typeof e === "string") return qe(e, t);
899
+ var r = Object.prototype.toString.call(e).slice(8, -1);
900
+ if (r === "Object" && e.constructor) r = e.constructor.name;
901
+ if (r === "Map" || r === "Set") return Array.from(e);
902
+ if (r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)) return qe(e, t);
903
+ }
904
+ function qe(e, t) {
905
+ if (t == null || t > e.length) t = e.length;
906
+ for (var r = 0, n = new Array(t); r < t; r++) {
907
+ n[r] = e[r];
1147
908
  }
1148
-
1149
- return {
1150
- anchorPos: anchorPos,
1151
- arrowStyle: arrowStyle,
1152
- arrowStyleTransformMeta: arrowStyleTransformMeta,
1153
- outerContainerStyle: outerContainerStyle,
1154
- placement: placement,
1155
- maxHeight: maxHeight,
1156
- maxWidth: maxWidth
1157
- };
1158
- });
1159
- });
1160
-
1161
- Popover_defineProperty(_assertThisInitialized(_this), "handleNewAnchor", function (anchor) {
1162
- var anchorEl;
1163
-
1164
- if (anchor && !(anchor instanceof HTMLElement)) {
1165
- if (false) {}
1166
-
1167
- anchorEl = (0,external_react_dom_namespaceObject.findDOMNode)(anchor); // eslint-disable-line react/no-find-dom-node
1168
- } else {
1169
- anchorEl = anchor !== null && anchor !== void 0 ? anchor : undefined;
1170
- }
1171
-
1172
- var anchorPos = anchorEl ? _this.getElPosition(anchorEl) : undefined;
1173
-
1174
- _this.setState({
1175
- anchorEl: anchorEl,
1176
- anchorPos: anchorPos
1177
- }); // eslint-disable-line react/no-unused-state
1178
-
1179
- });
1180
-
1181
- Popover_defineProperty(_assertThisInitialized(_this), "handleInnerContainerMount", function (el) {
1182
- _this.innerContainerEl = el;
1183
-
1184
- if (el && _this.props.takeFocus) {
1185
- defer_default()(focus_namespaceObject.takeFocus, el);
1186
- }
1187
-
1188
- updateReactRef(_this.props.elementRef, el);
1189
- });
1190
-
1191
- Popover_defineProperty(_assertThisInitialized(_this), "handleOuterContainerMount", function (el) {
1192
- _this.outerContainerEl = el;
1193
- updateReactRef(_this.props.outerRef, el);
1194
- });
1195
-
1196
- Popover_defineProperty(_assertThisInitialized(_this), "handleTab", function (e) {
1197
- if (_this.innerContainerEl) {
1198
- if (_this.props.retainFocus) {
1199
- (0,focus_namespaceObject.handleTab)(_this.innerContainerEl, e);
1200
- } else if ((0,focus_namespaceObject.isTabKey)(e)) {
1201
- var tabbableElements = (0,focus_namespaceObject.getSortedTabbableElements)(_this.innerContainerEl);
1202
-
1203
- if (tabbableElements.length > 0) {
1204
- var finalTabbale = e.shiftKey ? tabbableElements[0] : tabbableElements[tabbableElements.length - 1];
1205
-
1206
- if (finalTabbale === e.target) {
1207
- _this.handleRequestClose({
1208
- event: e,
1209
- reason: 'tabKey'
1210
- });
909
+ return n;
910
+ }
911
+ function We(e, t) {
912
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(e))) return;
913
+ var r = [];
914
+ var n = true;
915
+ var o = false;
916
+ var a = undefined;
917
+ try {
918
+ for (var i = e[Symbol.iterator](), l; !(n = (l = i.next()).done); n = true) {
919
+ r.push(l.value);
920
+ if (t && r.length === t) break;
921
+ }
922
+ } catch (e) {
923
+ o = true;
924
+ a = e;
925
+ } finally {
926
+ try {
927
+ if (!n && i["return"] != null) i["return"]();
928
+ } finally {
929
+ if (o) throw a;
1211
930
  }
1212
- }
1213
- }
1214
- }
1215
- });
1216
-
1217
- Popover_defineProperty(_assertThisInitialized(_this), "handleRequestClose", function (data) {
1218
- if (_this.props.open) {
1219
- _this.requestClose(data);
1220
- }
1221
- });
1222
-
1223
- Popover_defineProperty(_assertThisInitialized(_this), "handleAnimationEnd", function () {
1224
- if (_this.allowAnimationUpdates) {
1225
- _this.setState({
1226
- animating: false
1227
- });
1228
- }
1229
- });
1230
-
1231
- Popover_defineProperty(_assertThisInitialized(_this), "renderLayer", function () {
1232
- var _this$props2 = _this.props,
1233
- animation = _this$props2.animation,
1234
- animationConfig = _this$props2.animationConfig,
1235
- appearance = _this$props2.appearance,
1236
- children = _this$props2.children,
1237
- id = _this$props2.id,
1238
- open = _this$props2.open,
1239
- retainFocus = _this$props2.retainFocus,
1240
- splunkTheme = _this$props2.splunkTheme;
1241
- var _this$state = _this.state,
1242
- anchorPos = _this$state.anchorPos,
1243
- arrowStyle = _this$state.arrowStyle,
1244
- outerContainerStyle = _this$state.outerContainerStyle,
1245
- placement = _this$state.placement;
1246
- var isPrisma = splunkTheme.isPrisma;
1247
- var displayAppearance = isPrisma && appearance === 'inverted' ? 'normal' : appearance;
1248
- var _this$state2 = _this.state,
1249
- maxHeight = _this$state2.maxHeight,
1250
- maxWidth = _this$state2.maxWidth; // eslint-disable-line prefer-const
1251
- // Accommodate the arrow in the maxHeight and maxWidth.
1252
-
1253
- if (appearance !== 'none') {
1254
- if (isFinite_default()(maxHeight)) {
1255
- maxHeight -= 20;
1256
931
  }
1257
-
1258
- if (isFinite_default()(maxWidth)) {
1259
- maxWidth -= 20;
932
+ return r;
933
+ }
934
+ function Me(e) {
935
+ if (Array.isArray(e)) return e;
936
+ }
937
+ function He(e, t) {
938
+ if (!(e instanceof t)) {
939
+ throw new TypeError("Cannot call a class as a function");
1260
940
  }
1261
- }
1262
-
1263
- var childData = {
1264
- anchorHeight: anchorPos ? anchorPos.height : null,
1265
- anchorWidth: anchorPos ? anchorPos.width : null,
1266
- placement: placement || null,
1267
- maxHeight: maxHeight || null,
1268
- maxWidth: maxWidth || null
1269
- };
1270
- var motionStyle = animation ? {
1271
- opacity: open ? 1 : 0
1272
- } : {
1273
- opacity: 1
1274
- };
1275
- /* eslint-disable jsx-a11y/no-static-element-interactions */
1276
-
1277
- return /*#__PURE__*/external_react_default().createElement(Animation_namespaceObject.Spring, {
1278
- from: {
1279
- opacity: animation ? 0 : 1
1280
- },
1281
- to: motionStyle,
1282
- config: Popover_objectSpread({
1283
- tension: 300,
1284
- friction: 40
1285
- }, animationConfig),
1286
- onRest: _this.handleAnimationEnd
1287
- }, function (interpolatedStyles) {
1288
- return /*#__PURE__*/external_react_default().createElement(Styled, {
1289
- "data-test": "outer-popover",
1290
- style: Popover_objectSpread(Popover_objectSpread({}, outerContainerStyle), interpolatedStyles),
1291
- ref: _this.handleOuterContainerMount
1292
- }, (open || _this.state.animating) && /*#__PURE__*/external_react_default().createElement(StyledBox, _extends({
1293
- $appearance: displayAppearance,
1294
- $open: open,
1295
- "data-test": "popover",
1296
- ref: _this.handleInnerContainerMount,
1297
- tabIndex: -1,
1298
- id: id,
1299
- onKeyDown: _this.handleTab // TODO: remove anchor once prop type generation is fixed
1300
-
1301
- }, omit_default()(_this.props, ['anchor'].concat(_toConsumableArray(keys_default()(Popover.propTypes))))), /*#__PURE__*/external_react_default().createElement(PopoverContext.Provider, {
1302
- value: {
1303
- retainFocus: retainFocus
1304
- }
1305
- }, /*#__PURE__*/external_react_default().createElement((external_react_default()).Fragment, null, appearance === 'none' && children, appearance !== 'none' && !isPrisma && /*#__PURE__*/external_react_default().createElement(StyledArrow, {
1306
- $appearance: displayAppearance,
1307
- ref: function ref(arrow) {
1308
- _this.arrow = arrow;
1309
- },
1310
- style: arrowStyle
1311
- }), appearance !== 'none' && /*#__PURE__*/external_react_default().createElement(StyledContent, {
1312
- $appearance: displayAppearance
1313
- }, isFunction_default()(children) ? children(childData) : children)))), /*#__PURE__*/external_react_default().createElement(StyledLowerRightCorner, {
1314
- ref: function ref(el) {
1315
- _this.windowSizeMeasurementEl = el;
1316
- }
1317
- }));
1318
- });
1319
- /* eslint-enable jsx-a11y/no-static-element-interactions */
1320
- });
1321
-
1322
- _this.handleScroll = throttle_default()(_this.setPlacement.bind(_assertThisInitialized(_this), true), 0);
1323
- _this.handleWindowScroll = throttle_default()(_this.setPlacement.bind(_assertThisInitialized(_this), true), 0);
1324
- _this.setPlacement = throttle_default()(_this.setPlacement, 0, {
1325
- leading: false
1326
- });
1327
- _this.state = {
1328
- animating: false,
1329
- prevOpen: props.open // eslint-disable-line react/no-unused-state
1330
-
1331
- };
1332
- return _this;
1333
- }
1334
-
1335
- _createClass(Popover, [{
1336
- key: "componentDidMount",
1337
- value: function componentDidMount() {
1338
- this.handleNewAnchor(this.props.anchor);
1339
941
  }
1340
- }, {
1341
- key: "componentDidUpdate",
1342
- value: function componentDidUpdate(prevProps) {
1343
- if (prevProps.anchor !== this.props.anchor) {
1344
- this.handleNewAnchor(this.props.anchor);
1345
- }
1346
-
1347
- if (!this.innerContainerEl) {
1348
- return;
1349
- }
1350
-
1351
- if (this.props.open || this.state.animating) {
1352
- this.setPlacement(); // make sure that the popover both was not open before and is actually open now
1353
- // this prevents bugs like #4 in SUI-2054 where popover contents re-rendering due to animation
1354
- // causes the popover contents to receive focus even though the popover closing
1355
-
1356
- if (!prevProps.open && this.props.open && this.props.takeFocus) {
1357
- (0,focus_namespaceObject.takeFocus)(this.innerContainerEl);
942
+ function _e(e, t) {
943
+ for (var r = 0; r < t.length; r++) {
944
+ var n = t[r];
945
+ n.enumerable = n.enumerable || false;
946
+ n.configurable = true;
947
+ if ("value" in n) n.writable = true;
948
+ Object.defineProperty(e, n.key, n);
1358
949
  }
1359
- }
1360
950
  }
1361
- }, {
1362
- key: "componentWillUnmount",
1363
- value: function componentWillUnmount() {
1364
- this.setPlacement.cancel(); // guaranteed by constructor
1365
-
1366
- this.handleScroll.cancel();
1367
- this.allowAnimationUpdates = false;
951
+ function Le(e, t, r) {
952
+ if (t) _e(e.prototype, t);
953
+ if (r) _e(e, r);
954
+ return e;
1368
955
  }
1369
- }, {
1370
- key: "autoCloseWhenOffScreen",
1371
- value: function autoCloseWhenOffScreen(anchorPosition, scrollContainerPosition) {
1372
- var window = getWindow();
1373
-
1374
- if (anchorPosition.top < 0 || anchorPosition.top > window.innerHeight || anchorPosition.left < 0 || anchorPosition.left > window.innerWidth) {
1375
- this.requestClose({
1376
- reason: 'offScreen'
956
+ function De(e, t) {
957
+ if (typeof t !== "function" && t !== null) {
958
+ throw new TypeError("Super expression must either be null or a function");
959
+ }
960
+ e.prototype = Object.create(t && t.prototype, {
961
+ constructor: {
962
+ value: e,
963
+ writable: true,
964
+ configurable: true
965
+ }
1377
966
  });
1378
- return true;
1379
- }
1380
-
1381
- if (scrollContainerPosition) {
1382
- if (anchorPosition.height + anchorPosition.top < scrollContainerPosition.top || anchorPosition.top > scrollContainerPosition.bottom || anchorPosition.width + anchorPosition.left < scrollContainerPosition.left || anchorPosition.left > scrollContainerPosition.right) {
1383
- this.requestClose({
1384
- reason: 'offScreen'
1385
- });
1386
- return true;
967
+ if (t) Ie(e, t);
968
+ }
969
+ function Ie(e, t) {
970
+ Ie = Object.setPrototypeOf || function e(t, r) {
971
+ t.__proto__ = r;
972
+ return t;
973
+ };
974
+ return Ie(e, t);
975
+ }
976
+ function Fe(e) {
977
+ var t = $e();
978
+ return function r() {
979
+ var n = Ue(e), o;
980
+ if (t) {
981
+ var a = Ue(this).constructor;
982
+ o = Reflect.construct(n, arguments, a);
983
+ } else {
984
+ o = n.apply(this, arguments);
985
+ }
986
+ return Ne(this, o);
987
+ };
988
+ }
989
+ function Ne(e, t) {
990
+ if (t && (Se(t) === "object" || typeof t === "function")) {
991
+ return t;
1387
992
  }
1388
- }
1389
-
1390
- return false;
993
+ return ze(e);
1391
994
  }
1392
- }, {
1393
- key: "requestClose",
1394
- value: function requestClose(data) {
1395
- if (includes_default()(this.props.closeReasons, data.reason)) {
1396
- var _this$props$onRequest, _this$props3;
1397
-
1398
- (_this$props$onRequest = (_this$props3 = this.props).onRequestClose) === null || _this$props$onRequest === void 0 ? void 0 : _this$props$onRequest.call(_this$props3, data);
1399
- }
995
+ function ze(e) {
996
+ if (e === void 0) {
997
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
998
+ }
999
+ return e;
1400
1000
  }
1401
- }, {
1402
- key: "render",
1403
- value: function render() {
1404
- var window = getWindow();
1405
- var open = this.props.open || this.state.animating;
1406
- var scrollContainer = this.context || window;
1407
- var hasCustomizedScrollContainer = scrollContainer !== window;
1408
- var _this$state3 = this.state,
1409
- anchorPos = _this$state3.anchorPos,
1410
- placement = _this$state3.placement; // EventListeners only need to be rendered when open,
1411
- // otherwise leads to negative performance impacts
1412
-
1413
- var eventListeners = open ? [hasCustomizedScrollContainer && /*#__PURE__*/external_react_default().createElement((EventListener_default()), {
1414
- target: scrollContainer,
1415
- eventType: "scroll",
1416
- listener: this.handleScroll,
1417
- options: {
1418
- passive: false,
1419
- capture: true
1420
- },
1421
- key: "eventListener"
1422
- }), /*#__PURE__*/external_react_default().createElement((EventListener_default()), {
1423
- target: window,
1424
- eventType: "resize",
1425
- listener: this.setPlacement,
1426
- key: "eventListenerOnWindowResize"
1427
- }), /*#__PURE__*/external_react_default().createElement((EventListener_default()), {
1428
- target: window,
1429
- eventType: "scroll",
1430
- listener: this.handleWindowScroll,
1431
- options: {
1432
- passive: false,
1433
- capture: true
1434
- },
1435
- key: "eventListenerOnWindowScroll"
1436
- })] : [];
1437
- return [].concat(eventListeners, [/*#__PURE__*/external_react_default().createElement((Layer_default()), {
1438
- closeReasons: intersection_default()(this.props.closeReasons.filter(function (reason) {
1439
- return reason !== 'offScreen';
1440
- }), (Layer_default()).possibleCloseReasons),
1441
- open: open,
1442
- onRequestClose: this.handleRequestClose,
1443
- key: "Layer"
1444
- }, open && this.innerContainerEl && this.props.hitAreaRef && /*#__PURE__*/external_react_default().createElement(Popover_PopoverHitArea, {
1445
- anchorRect: anchorPos,
1446
- popoverEl: this.innerContainerEl,
1447
- popoverPlacement: placement,
1448
- ref: this.props.hitAreaRef
1449
- }), open && this.renderLayer())]);
1001
+ function $e() {
1002
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
1003
+ if (Reflect.construct.sham) return false;
1004
+ if (typeof Proxy === "function") return true;
1005
+ try {
1006
+ Date.prototype.toString.call(Reflect.construct(Date, [], (function() {})));
1007
+ return true;
1008
+ } catch (e) {
1009
+ return false;
1010
+ }
1450
1011
  }
1451
- }]);
1452
-
1453
- return Popover;
1454
- }(external_react_namespaceObject.Component);
1455
-
1456
- Popover_defineProperty(Popover, "contextType", (ScrollContainerContext_default()));
1457
-
1458
- Popover_defineProperty(Popover, "defaultProps", defaultProps);
1459
-
1460
- Popover_defineProperty(Popover, "propTypes", Popover_propTypes);
1461
-
1462
- Popover_defineProperty(Popover, "getDerivedStateFromProps", function (props, state) {
1463
- if (props.open !== state.prevOpen) {
1464
- return {
1465
- animating: props.animation,
1466
- prevOpen: props.open
1012
+ function Ue(e) {
1013
+ Ue = Object.setPrototypeOf ? Object.getPrototypeOf : function e(t) {
1014
+ return t.__proto__ || Object.getPrototypeOf(t);
1015
+ };
1016
+ return Ue(e);
1017
+ }
1018
+ function Ke(e, t, r) {
1019
+ if (t in e) {
1020
+ Object.defineProperty(e, t, {
1021
+ value: r,
1022
+ enumerable: true,
1023
+ configurable: true,
1024
+ writable: true
1025
+ });
1026
+ } else {
1027
+ e[t] = r;
1028
+ }
1029
+ return e;
1030
+ }
1031
+ /** @public */ var Ve = [ "clickAway", "escapeKey", "offScreen", "tabKey" ];
1032
+ var Be = {
1033
+ align: a().oneOf([ "center", "edge", "theme", "end" ]),
1034
+ anchor: a().object,
1035
+ animation: a().bool,
1036
+ animationConfig: a().object,
1037
+ appearance: a().oneOf([ "normal", "inverted", "none" ]),
1038
+ autoCloseWhenOffScreen: a().bool,
1039
+ canCoverAnchor: a().bool,
1040
+ children: a().oneOfType([ a().node, a().func ]),
1041
+ closeReasons: a().arrayOf(a().oneOf(Ve)),
1042
+ defaultPlacement: a().oneOf([ "above", "below", "left", "right", "vertical", "horizontal" ]),
1043
+ elementRef: a().oneOfType([ a().func, a().object ]),
1044
+ id: a().string,
1045
+ hitAreaRef: a().oneOfType([ a().func, a().object ]),
1046
+ onRequestClose: a().func,
1047
+ open: a().bool,
1048
+ outerRef: a().oneOfType([ a().func, a().object ]),
1049
+ pointTo: a().shape({
1050
+ x: a().number,
1051
+ y: a().number
1052
+ }),
1053
+ repositionMode: a().oneOf([ "none", "flip", "any" ]),
1054
+ retainFocus: a().bool,
1055
+ takeFocus: a().bool,
1056
+ splunkTheme: a().object
1467
1057
  };
1468
- }
1469
-
1470
- return null;
1471
- });
1472
-
1473
- var PopoverWithTheme = (0,themes_namespaceObject.withSplunkTheme)(Popover);
1474
- PopoverWithTheme.propTypes = Popover.propTypes;
1475
- /* harmony default export */ const Popover_Popover = (PopoverWithTheme);
1476
- ;// CONCATENATED MODULE: ./src/Popover/index.ts
1477
-
1478
-
1479
-
1480
- module.exports = __webpack_exports__;
1481
- /******/ })()
1482
- ;
1058
+ var Xe = {
1059
+ align: "theme",
1060
+ animation: true,
1061
+ animationConfig: {},
1062
+ appearance: "normal",
1063
+ autoCloseWhenOffScreen: true,
1064
+ canCoverAnchor: false,
1065
+ closeReasons: Ve,
1066
+ defaultPlacement: "below",
1067
+ open: false,
1068
+ repositionMode: "flip",
1069
+ retainFocus: true,
1070
+ takeFocus: false
1071
+ };
1072
+ // eslint-disable-next-line @typescript-eslint/ban-types
1073
+ function Ye(e, t) {
1074
+ var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1075
+ return !!e && !!t && p()(e, (function(e, n) {
1076
+ if (w()(e)) {
1077
+ return Math.abs(t[n] - e) <= r;
1078
+ }
1079
+ return t[n] === e;
1080
+ }));
1081
+ }
1082
+ function Ge(e) {
1083
+ return e !== window && e !== window.document;
1084
+ }
1085
+ /**
1086
+ * `Popover` is used to create layovers such as dropdowns, contextual menus, or tooltips. Use
1087
+ * this only when the other components don't provide sufficient functionality or control. A controlled
1088
+ * `Dropdown` covers use cases where you might consider using `Popover` directly.
1089
+ */ var Je = function(e) {
1090
+ De(r, e);
1091
+ var t = Fe(r);
1092
+ Le(r, null, [ {
1093
+ key: "getArrowStyle",
1094
+ // @docs-props-type PopoverPropsBase
1095
+ value: function e(t) {
1096
+ var r = t.anchorPos, n = t.arrowHeight, o = t.placement, a = t.outerContainerStyle, i = t.outerContainerEl;
1097
+ if (o === "misaligned") {
1098
+ return [ {
1099
+ display: "none"
1100
+ } ];
1101
+ }
1102
+ var l = {
1103
+ display: "block"
1104
+ };
1105
+ var f = i.offsetHeight / 2 - 22;
1106
+ var s = -(i.offsetHeight / 2 - 15);
1107
+ var u = r.center - (a.top + i.offsetHeight / 2) - n / 2;
1108
+ var p = c()(u, s, f);
1109
+ var h = r.middle - (a.left + i.offsetWidth / 2) - n;
1110
+ var d = {
1111
+ left: {
1112
+ translateX: n / 2,
1113
+ translateY: p,
1114
+ rotate: 90
1115
+ },
1116
+ right: {
1117
+ translateX: -n / 2,
1118
+ translateY: p,
1119
+ rotate: -90
1120
+ },
1121
+ above: {
1122
+ translateX: h,
1123
+ translateY: 0,
1124
+ rotate: 180
1125
+ },
1126
+ below: {
1127
+ translateX: h,
1128
+ translateY: 0,
1129
+ rotate: 0
1130
+ }
1131
+ };
1132
+ var v = d[o];
1133
+ l.transform = "translate(".concat(v.translateX, "px, ").concat(v.translateY, "px) rotate(").concat(v.rotate, "deg)");
1134
+ // set new positions
1135
+ var m = {
1136
+ left: "right",
1137
+ right: "left",
1138
+ above: "bottom",
1139
+ below: "top"
1140
+ };
1141
+ l[m[o]] = "1px";
1142
+ var b = {
1143
+ left: "top",
1144
+ right: "top",
1145
+ above: "left",
1146
+ below: "left"
1147
+ };
1148
+ l[b[o]] = "50%";
1149
+ return [ l, v ];
1150
+ }
1151
+ } ]);
1152
+ function r(e) {
1153
+ var o;
1154
+ He(this, r);
1155
+ o = t.call(this, e);
1156
+ Ke(ze(o), "outerContainerEl", null);
1157
+ Ke(ze(o), "innerContainerEl", null);
1158
+ Ke(ze(o), "arrow", null);
1159
+ Ke(ze(o), "windowSizeMeasurementEl", null);
1160
+ Ke(ze(o), "handleScroll", void 0);
1161
+ Ke(ze(o), "handleWindowScroll", void 0);
1162
+ Ke(ze(o), "allowAnimationUpdates", true);
1163
+ Ke(ze(o), "getElPosition", (function(e) {
1164
+ var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1165
+ var r = ge(e, t);
1166
+ var n = {
1167
+ width: e.offsetWidth,
1168
+ height: e.offsetHeight
1169
+ };
1170
+ var a = o.props.pointTo;
1171
+ var i = a && d()(a, "x");
1172
+ var l = a && d()(a, "y");
1173
+ n.left = i ? r.left + ((a === null || a === void 0 ? void 0 : a.x) || 0) : r.left;
1174
+ n.top = l ? r.top + ((a === null || a === void 0 ? void 0 : a.y) || 0) : r.top;
1175
+ n.right = i ? n.left + n.width : r.left + n.width || r.right;
1176
+ n.bottom = l ? n.top + n.height : r.top + n.height || r.bottom;
1177
+ n.middle = i ? n.left : r.left + (n.right - r.left) / 2;
1178
+ n.center = l ? n.top : r.top + (n.bottom - r.top) / 2;
1179
+ return n;
1180
+ }));
1181
+ Ke(ze(o), "setPlacement", (function(e) {
1182
+ var t = he();
1183
+ o.setState((function(n) {
1184
+ var a;
1185
+ var i = o.props, l = i.align, c = i.anchor, f = i.autoCloseWhenOffScreen, s = i.canCoverAnchor, u = i.defaultPlacement, p = i.open, h = i.repositionMode, d = i.splunkTheme;
1186
+ var v = o.context || t;
1187
+ var m = d.isPrisma;
1188
+ // If these conditions are not met, we cannot set the popover.
1189
+ if (!p || !o.outerContainerEl || !c || !n.anchorEl || !o.windowSizeMeasurementEl) {
1190
+ if (false) {}
1191
+ return null;
1192
+ }
1193
+ var b = o.getElPosition(n.anchorEl);
1194
+ var y = o.getElPosition(n.anchorEl, true);
1195
+ var g = Ge(v) ? o.getElPosition(v) : undefined;
1196
+ if (e && f) {
1197
+ if (o.autoCloseWhenOffScreen(b, g)) {
1198
+ return null;
1199
+ }
1200
+ }
1201
+ var w = m ? 0 : 8;
1202
+ var S = 8;
1203
+ var O = m ? "edge" : "center";
1204
+ var P = z({
1205
+ align: l === "theme" ? O : l,
1206
+ anchorPos: y,
1207
+ scrollContainerPos: g,
1208
+ canCoverAnchor: s,
1209
+ defaultPlacement: u,
1210
+ repositionMode: h,
1211
+ outerContainerEl: o.outerContainerEl,
1212
+ padding: S,
1213
+ windowWidth: o.windowSizeMeasurementEl.offsetLeft,
1214
+ windowHeight: o.windowSizeMeasurementEl.offsetTop
1215
+ }), E = P.placement, C = P.outerContainerStyle, k = P.maxHeight, x = P.maxWidth;
1216
+ var A = o.arrow ? r.getArrowStyle({
1217
+ anchorPos: y,
1218
+ arrowHeight: w,
1219
+ outerContainerStyle: C,
1220
+ placement: E,
1221
+ outerContainerEl: o.outerContainerEl
1222
+ }) : [], T = Ae(A, 2), R = T[0], q = T[1];
1223
+ var W = o.props.appearance !== "none" && !m;
1224
+ var M = Ye(y, n.anchorPos) && Ye(C, n.outerContainerStyle) && E === n.placement && k === n.maxHeight && x === n.maxWidth;
1225
+ var H = Ye(j()(R, "transform"), j()(n.arrowStyle, "transform")) && Ye(q !== null && q !== void 0 ? q : {}, (a = n.arrowStyleTransformMeta) !== null && a !== void 0 ? a : {});
1226
+ // If none of the position data has changed, do not set state.
1227
+ if (M && (!W || W && H)) {
1228
+ return null;
1229
+ }
1230
+ return {
1231
+ anchorPos: y,
1232
+ arrowStyle: R,
1233
+ arrowStyleTransformMeta: q,
1234
+ outerContainerStyle: C,
1235
+ placement: E,
1236
+ maxHeight: k,
1237
+ maxWidth: x
1238
+ };
1239
+ }));
1240
+ }));
1241
+ Ke(ze(o), "handleNewAnchor", (function(e) {
1242
+ var t;
1243
+ if (e && !(e instanceof HTMLElement)) {
1244
+ if (false) {}
1245
+ t = (0, i.findDOMNode)(e);
1246
+ // eslint-disable-line react/no-find-dom-node
1247
+ } else {
1248
+ t = e !== null && e !== void 0 ? e : undefined;
1249
+ }
1250
+ var r = t ? o.getElPosition(t) : undefined;
1251
+ o.setState({
1252
+ anchorEl: t,
1253
+ anchorPos: r
1254
+ });
1255
+ // eslint-disable-line react/no-unused-state
1256
+ }));
1257
+ Ke(ze(o), "handleInnerContainerMount", (function(e) {
1258
+ o.innerContainerEl = e;
1259
+ if (e && o.props.takeFocus) {
1260
+ s()(L.takeFocus, e);
1261
+ }
1262
+ we(o.props.elementRef, e);
1263
+ }));
1264
+ Ke(ze(o), "handleOuterContainerMount", (function(e) {
1265
+ o.outerContainerEl = e;
1266
+ we(o.props.outerRef, e);
1267
+ }));
1268
+ Ke(ze(o), "handleTab", (function(e) {
1269
+ if (o.innerContainerEl) {
1270
+ if (o.props.retainFocus) {
1271
+ (0, L.handleTab)(o.innerContainerEl, e);
1272
+ } else if ((0, L.isTabKey)(e)) {
1273
+ var t = (0, L.getSortedTabbableElements)(o.innerContainerEl);
1274
+ if (t.length > 0) {
1275
+ var r = e.shiftKey ? t[0] : t[t.length - 1];
1276
+ if (r === e.target) {
1277
+ o.handleRequestClose({
1278
+ event: e,
1279
+ reason: "tabKey"
1280
+ });
1281
+ }
1282
+ }
1283
+ }
1284
+ }
1285
+ }));
1286
+ Ke(ze(o), "handleRequestClose", (function(e) {
1287
+ if (o.props.open) {
1288
+ o.requestClose(e);
1289
+ }
1290
+ }));
1291
+ Ke(ze(o), "handleAnimationEnd", (function() {
1292
+ if (o.allowAnimationUpdates) {
1293
+ o.setState({
1294
+ animating: false
1295
+ });
1296
+ }
1297
+ }));
1298
+ Ke(ze(o), "renderLayer", (function() {
1299
+ var e = o.props, t = e.animation, a = e.animationConfig, i = e.appearance, l = e.children, c = e.id, f = e.open, s = e.retainFocus, u = e.splunkTheme;
1300
+ var p = o.state, h = p.anchorPos, d = p.arrowStyle, v = p.outerContainerStyle, m = p.placement;
1301
+ var b = u.isPrisma;
1302
+ var y = b && i === "inverted" ? "normal" : i;
1303
+ var g = o.state, S = g.maxHeight, P = g.maxWidth;
1304
+ // eslint-disable-line prefer-const
1305
+ // Accommodate the arrow in the maxHeight and maxWidth.
1306
+ if (i !== "none") {
1307
+ if (w()(S)) {
1308
+ S -= 20;
1309
+ }
1310
+ if (w()(P)) {
1311
+ P -= 20;
1312
+ }
1313
+ }
1314
+ var C = {
1315
+ anchorHeight: h ? h.height : null,
1316
+ anchorWidth: h ? h.width : null,
1317
+ placement: m || null,
1318
+ maxHeight: S || null,
1319
+ maxWidth: P || null
1320
+ };
1321
+ var k = t ? {
1322
+ opacity: f ? 1 : 0
1323
+ } : {
1324
+ opacity: 1
1325
+ };
1326
+ /* eslint-disable jsx-a11y/no-static-element-interactions */
1327
+ return n().createElement(T.Spring, {
1328
+ from: {
1329
+ opacity: t ? 0 : 1
1330
+ },
1331
+ to: k,
1332
+ config: xe({
1333
+ tension: 300,
1334
+ friction: 40
1335
+ }, a),
1336
+ onRest: o.handleAnimationEnd
1337
+ }, (function(e) {
1338
+
1339
+ return n().createElement(X, {
1340
+ "data-test": "outer-popover",
1341
+ style: xe(xe({}, v), e),
1342
+ ref: o.handleOuterContainerMount
1343
+ }, (f || o.state.animating) && n().createElement(Y, Oe({
1344
+ $appearance: y,
1345
+ $open: f,
1346
+ "data-test": "popover",
1347
+ ref: o.handleInnerContainerMount,
1348
+ tabIndex: -1,
1349
+ id: c,
1350
+ onKeyDown: o.handleTab
1351
+ }, j()(o.props, [ "anchor" ].concat(Pe(E()(r.propTypes))))), n().createElement($.Provider, {
1352
+ value: {
1353
+ retainFocus: s
1354
+ }
1355
+ }, n().createElement(n().Fragment, null, i === "none" && l, i !== "none" && !b && n().createElement(J, {
1356
+ $appearance: y,
1357
+ ref: function e(t) {
1358
+ o.arrow = t;
1359
+ },
1360
+ style: d
1361
+ }), i !== "none" && n().createElement(G, {
1362
+ $appearance: y
1363
+ }, O()(l) ? l(C) : l)))), n().createElement(Q, {
1364
+ ref: function e(t) {
1365
+ o.windowSizeMeasurementEl = t;
1366
+ }
1367
+ }));
1368
+ }));
1369
+ /* eslint-enable jsx-a11y/no-static-element-interactions */ }));
1370
+ o.handleScroll = x()(o.setPlacement.bind(ze(o), true), 0);
1371
+ o.handleWindowScroll = x()(o.setPlacement.bind(ze(o), true), 0);
1372
+ o.setPlacement = x()(o.setPlacement, 0, {
1373
+ leading: false
1374
+ });
1375
+ o.state = {
1376
+ animating: false,
1377
+ prevOpen: e.open
1378
+ };
1379
+ return o;
1380
+ }
1381
+ Le(r, [ {
1382
+ key: "componentDidMount",
1383
+ value: function e() {
1384
+ this.handleNewAnchor(this.props.anchor);
1385
+ }
1386
+ }, {
1387
+ key: "componentDidUpdate",
1388
+ value: function e(t) {
1389
+ if (t.anchor !== this.props.anchor) {
1390
+ this.handleNewAnchor(this.props.anchor);
1391
+ }
1392
+ if (!this.innerContainerEl) {
1393
+ return;
1394
+ }
1395
+ if (this.props.open || this.state.animating) {
1396
+ this.setPlacement();
1397
+ // make sure that the popover both was not open before and is actually open now
1398
+ // this prevents bugs like #4 in SUI-2054 where popover contents re-rendering due to animation
1399
+ // causes the popover contents to receive focus even though the popover closing
1400
+ if (!t.open && this.props.open && this.props.takeFocus) {
1401
+ (0, L.takeFocus)(this.innerContainerEl);
1402
+ }
1403
+ }
1404
+ }
1405
+ }, {
1406
+ key: "componentWillUnmount",
1407
+ value: function e() {
1408
+ this.setPlacement.cancel();
1409
+ // guaranteed by constructor
1410
+ this.handleScroll.cancel();
1411
+ this.allowAnimationUpdates = false;
1412
+ }
1413
+ }, {
1414
+ key: "autoCloseWhenOffScreen",
1415
+ value: function e(t, r) {
1416
+ var n = he();
1417
+ if (t.top < 0 || t.top > n.innerHeight || t.left < 0 || t.left > n.innerWidth) {
1418
+ this.requestClose({
1419
+ reason: "offScreen"
1420
+ });
1421
+ return true;
1422
+ }
1423
+ if (r) {
1424
+ if (t.height + t.top < r.top || t.top > r.bottom || t.width + t.left < r.left || t.left > r.right) {
1425
+ this.requestClose({
1426
+ reason: "offScreen"
1427
+ });
1428
+ return true;
1429
+ }
1430
+ }
1431
+ return false;
1432
+ }
1433
+ }, {
1434
+ key: "requestClose",
1435
+ value: function e(t) {
1436
+ if (m()(this.props.closeReasons, t.reason)) {
1437
+ var r, n;
1438
+ (r = (n = this.props).onRequestClose) === null || r === void 0 ? void 0 : r.call(n, t);
1439
+ }
1440
+ }
1441
+ }, {
1442
+ key: "render",
1443
+ value: function e() {
1444
+ var t = he();
1445
+ var r = this.props.open || this.state.animating;
1446
+ var o = this.context || t;
1447
+ var a = o !== t;
1448
+ var i = this.state, l = i.anchorPos, c = i.placement;
1449
+ // EventListeners only need to be rendered when open,
1450
+ // otherwise leads to negative performance impacts
1451
+ var f = r ? [ a && n().createElement(q(), {
1452
+ target: o,
1453
+ eventType: "scroll",
1454
+ listener: this.handleScroll,
1455
+ options: {
1456
+ passive: false,
1457
+ capture: true
1458
+ },
1459
+ key: "eventListener"
1460
+ }), n().createElement(q(), {
1461
+ target: t,
1462
+ eventType: "resize",
1463
+ listener: this.setPlacement,
1464
+ key: "eventListenerOnWindowResize"
1465
+ }), n().createElement(q(), {
1466
+ target: t,
1467
+ eventType: "scroll",
1468
+ listener: this.handleWindowScroll,
1469
+ options: {
1470
+ passive: false,
1471
+ capture: true
1472
+ },
1473
+ key: "eventListenerOnWindowScroll"
1474
+ }) ] : [];
1475
+ return [].concat(f, [ n().createElement(M(), {
1476
+ closeReasons: y()(this.props.closeReasons.filter((function(e) {
1477
+ return e !== "offScreen";
1478
+ })), M().possibleCloseReasons),
1479
+ open: r,
1480
+ onRequestClose: this.handleRequestClose,
1481
+ key: "Layer"
1482
+ }, r && this.innerContainerEl && this.props.hitAreaRef && n().createElement(fe, {
1483
+ anchorRect: l,
1484
+ popoverEl: this.innerContainerEl,
1485
+ popoverPlacement: c,
1486
+ ref: this.props.hitAreaRef
1487
+ }), r && this.renderLayer()) ]);
1488
+ }
1489
+ } ]);
1490
+ return r;
1491
+ }(r.Component);
1492
+ Ke(Je, "contextType", _());
1493
+ Ke(Je, "defaultProps", Xe);
1494
+ Ke(Je, "propTypes", Be);
1495
+ Ke(Je, "getDerivedStateFromProps", (function(e, t) {
1496
+ if (e.open !== t.prevOpen) {
1497
+ return {
1498
+ animating: e.animation,
1499
+ prevOpen: e.open
1500
+ };
1501
+ }
1502
+ return null;
1503
+ }));
1504
+ var Qe = (0, A.withSplunkTheme)(Je);
1505
+ Qe.propTypes = Je.propTypes;
1506
+ /* harmony default export */ const Ze = Qe;
1507
+ // CONCATENATED MODULE: ./src/Popover/index.ts
1508
+ module.exports = t;
1509
+ /******/})();