@targetprocess/popover 12.19.5-alpha.4 → 12.19.6-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Popover.tsx +1 -2
- package/PopoverContainer.tsx +7 -17
- package/dist/Popover.d.ts +0 -1
- package/dist/popover.es.js +9 -104
- package/dist/popover.js +9 -104
- package/package.json +3 -3
package/Popover.tsx
CHANGED
|
@@ -128,8 +128,7 @@ export class Popover extends React.Component<PopoverProps, PopoverState> {
|
|
|
128
128
|
static defaultProps = {
|
|
129
129
|
zIndex: 19999,
|
|
130
130
|
outerActionEvents: ['mousedown', 'touchstart'],
|
|
131
|
-
getPopoverPosition: 'bottomLeft'
|
|
132
|
-
role: 'dialog'
|
|
131
|
+
getPopoverPosition: 'bottomLeft'
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
state = {
|
package/PopoverContainer.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import {PopoverPosition} from './PopoverPosition'
|
|
|
7
7
|
import styles from './style/index.css'
|
|
8
8
|
import {DimensionParams, GetPopoverPositionType, PositionParams} from './types'
|
|
9
9
|
import {throttle} from '../../base/utils/throttle'
|
|
10
|
-
import {focusFirstDescendant
|
|
10
|
+
import {focusFirstDescendant} from '../../base/utils/ariaUtils'
|
|
11
11
|
|
|
12
12
|
type PopoverContainerProps = {
|
|
13
13
|
containerElement?: HTMLElement
|
|
@@ -154,9 +154,11 @@ export class PopoverContainer extends React.Component<
|
|
|
154
154
|
this.mounted = true
|
|
155
155
|
this.adjustPosition()
|
|
156
156
|
|
|
157
|
-
if (this.
|
|
158
|
-
this.popoverContentRef.current
|
|
159
|
-
|
|
157
|
+
if (this.popoverContentRef.current) {
|
|
158
|
+
if (!focusFirstDescendant(this.popoverContentRef.current)) {
|
|
159
|
+
this.popoverContentRef.current.tabIndex = 0
|
|
160
|
+
this.popoverContentRef.current.focus()
|
|
161
|
+
}
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
if (this.props.trackScroll) {
|
|
@@ -166,13 +168,6 @@ export class PopoverContainer extends React.Component<
|
|
|
166
168
|
this.props.containerElement.addEventListener('scroll', this.onScroll)
|
|
167
169
|
}
|
|
168
170
|
}
|
|
169
|
-
|
|
170
|
-
if (this.popoverContentRef.current && this.props.role === 'dialog') {
|
|
171
|
-
if (!focusFirstDescendant(this.popoverContentRef.current)) {
|
|
172
|
-
this.popoverContentRef.current.tabIndex = 0
|
|
173
|
-
this.popoverContentRef.current.focus()
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
171
|
}
|
|
177
172
|
|
|
178
173
|
componentDidUpdate(previousProps) {
|
|
@@ -182,10 +177,6 @@ export class PopoverContainer extends React.Component<
|
|
|
182
177
|
) {
|
|
183
178
|
this.adjustPosition()
|
|
184
179
|
}
|
|
185
|
-
|
|
186
|
-
if (this.popoverContentRef.current && this.props.role === 'dialog') {
|
|
187
|
-
trapFocus(this.popoverContentRef.current)
|
|
188
|
-
}
|
|
189
180
|
}
|
|
190
181
|
|
|
191
182
|
componentWillUnmount() {
|
|
@@ -218,7 +209,6 @@ export class PopoverContainer extends React.Component<
|
|
|
218
209
|
|
|
219
210
|
handleKeyDown = event => {
|
|
220
211
|
if (event.key === 'Escape') {
|
|
221
|
-
event.stopPropagation()
|
|
222
212
|
this.props.onEscapeAction(event)
|
|
223
213
|
}
|
|
224
214
|
}
|
|
@@ -276,6 +266,7 @@ export class PopoverContainer extends React.Component<
|
|
|
276
266
|
)}
|
|
277
267
|
<div
|
|
278
268
|
ref={this.popoverContentRef}
|
|
269
|
+
aria-modal="true"
|
|
279
270
|
style={{
|
|
280
271
|
position: 'absolute',
|
|
281
272
|
pointerEvents: 'all',
|
|
@@ -283,7 +274,6 @@ export class PopoverContainer extends React.Component<
|
|
|
283
274
|
}}
|
|
284
275
|
className={this.props.className}
|
|
285
276
|
role={this.props.role}
|
|
286
|
-
aria-modal={this.props.role === 'dialog' ? 'true' : 'false'}
|
|
287
277
|
onKeyDown={this.handleKeyDown}
|
|
288
278
|
>
|
|
289
279
|
{this.props.children}
|
package/dist/Popover.d.ts
CHANGED
package/dist/popover.es.js
CHANGED
|
@@ -3,33 +3,6 @@ import { SpaceXS } from '@targetprocess/global-constants';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
|
|
6
|
-
function _iterableToArrayLimit(r, l) {
|
|
7
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
8
|
-
if (null != t) {
|
|
9
|
-
var e,
|
|
10
|
-
n,
|
|
11
|
-
i,
|
|
12
|
-
u,
|
|
13
|
-
a = [],
|
|
14
|
-
f = !0,
|
|
15
|
-
o = !1;
|
|
16
|
-
try {
|
|
17
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
18
|
-
if (Object(t) !== t) return;
|
|
19
|
-
f = !1;
|
|
20
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
21
|
-
} catch (r) {
|
|
22
|
-
o = !0, n = r;
|
|
23
|
-
} finally {
|
|
24
|
-
try {
|
|
25
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
26
|
-
} finally {
|
|
27
|
-
if (o) throw n;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return a;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
6
|
function _classCallCheck(instance, Constructor) {
|
|
34
7
|
if (!(instance instanceof Constructor)) {
|
|
35
8
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -109,28 +82,6 @@ function _possibleConstructorReturn(self, call) {
|
|
|
109
82
|
}
|
|
110
83
|
return _assertThisInitialized(self);
|
|
111
84
|
}
|
|
112
|
-
function _slicedToArray(arr, i) {
|
|
113
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
114
|
-
}
|
|
115
|
-
function _arrayWithHoles(arr) {
|
|
116
|
-
if (Array.isArray(arr)) return arr;
|
|
117
|
-
}
|
|
118
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
119
|
-
if (!o) return;
|
|
120
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
121
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
122
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
123
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
124
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
125
|
-
}
|
|
126
|
-
function _arrayLikeToArray(arr, len) {
|
|
127
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
128
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
129
|
-
return arr2;
|
|
130
|
-
}
|
|
131
|
-
function _nonIterableRest() {
|
|
132
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
133
|
-
}
|
|
134
85
|
function _toPrimitive(input, hint) {
|
|
135
86
|
if (typeof input !== "object" || input === null) return input;
|
|
136
87
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -254,8 +205,8 @@ function styleInject(css, ref) {
|
|
|
254
205
|
}
|
|
255
206
|
}
|
|
256
207
|
|
|
257
|
-
var css = ".popover-body-container__popover__12-19-
|
|
258
|
-
var styles = {"popover-body-container":"popover-body-container__popover__12-19-
|
|
208
|
+
var css = ".popover-body-container__popover__12-19-6-alpha-0 {\r\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n border-radius: var(--BorderRadiusL, 4px);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n background: var(--BackgroundDefault, #FFFFFF);\r\n z-index: var(--ZIndexModal, 10001);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n}\r\n\r\n.popover-body__popover__12-19-6-alpha-0 {\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n padding: var(--SpaceSM, 12px);\r\n font-size: var(--FontSizeDefault, 13px);\r\n color: var(--FontColorDefault, #000000);\r\n}\r\n\r\n.popover-body--no-padding__popover__12-19-6-alpha-0 {\r\n padding: 0;\r\n }\r\n\r\n.popover-tip__popover__12-19-6-alpha-0 {\r\n position: absolute;\r\n pointer-events: none;\r\n z-index: calc(var(--ZIndexModal, 10001) + 1);\r\n overflow: hidden;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n -webkit-box-pack: center;\r\n -ms-flex-pack: center;\r\n justify-content: center;\r\n}\r\n\r\n.popover-tip__popover__12-19-6-alpha-0:before {\r\n content: '';\r\n position: absolute;\r\n display: block;\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n background-color: var(--BackgroundDefault, #FFFFFF);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n /*\r\n geometry FTW\r\n\r\n 2*$popoverTipSize\r\n _______ _______\r\n | /|\\ |\r\n | / | \\ | $popoverTipSize\r\n | / | \\ |\r\n |/______|______\\|\r\n since tip is rotated 45 degrees, its width and height is a\r\n diagonal of a square with side=$popoverTipSize, thus diagonal\r\n is sqrt(2) * $popoverTipSize.\r\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\r\n */\r\n width: 11.2px;\r\n height: 11.2px;\r\n -webkit-transform: rotate(45deg);\r\n transform: rotate(45deg);\r\n }\r\n\r\n.popover-tip--bottom__popover__12-19-6-alpha-0,\r\n .popover-tip--top__popover__12-19-6-alpha-0 {\r\n width: 100%;\r\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 9px;\r\n }\r\n\r\n.popover-tip--left__popover__12-19-6-alpha-0,\r\n .popover-tip--right__popover__12-19-6-alpha-0 {\r\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 100%;\r\n width: 9px;\r\n }\r\n\r\n/*\r\n To determine tip position, we need to rotate it\r\n along the \"tip\" point, after that, the \"tip\" point\r\n can be placed with exactly 50% offset from the origin\r\n so that it is centered.\r\n */\r\n\r\n.popover-tip--bottom__popover__12-19-6-alpha-0:before {\r\n -webkit-transform-origin: left top;\r\n transform-origin: left top;\r\n left: 50%;\r\n top: 0;\r\n }\r\n\r\n.popover-tip--top__popover__12-19-6-alpha-0:before {\r\n -webkit-transform-origin: right bottom;\r\n transform-origin: right bottom;\r\n right: 50%;\r\n bottom: 0;\r\n }\r\n\r\n.popover-tip--left__popover__12-19-6-alpha-0:before {\r\n -webkit-transform-origin: right top;\r\n transform-origin: right top;\r\n right: 0;\r\n top: 50%;\r\n }\r\n\r\n.popover-tip--right__popover__12-19-6-alpha-0:before {\r\n -webkit-transform-origin: left bottom;\r\n transform-origin: left bottom;\r\n left: 0;\r\n bottom: 50%;\r\n }\r\n";
|
|
209
|
+
var styles = {"popover-body-container":"popover-body-container__popover__12-19-6-alpha-0","popover-body":"popover-body__popover__12-19-6-alpha-0","popover-body--no-padding":"popover-body--no-padding__popover__12-19-6-alpha-0","popover-tip":"popover-tip__popover__12-19-6-alpha-0","popover-tip--bottom":"popover-tip--bottom__popover__12-19-6-alpha-0","popover-tip--top":"popover-tip--top__popover__12-19-6-alpha-0","popover-tip--left":"popover-tip--left__popover__12-19-6-alpha-0","popover-tip--right":"popover-tip--right__popover__12-19-6-alpha-0"};
|
|
259
210
|
styleInject(css);
|
|
260
211
|
|
|
261
212
|
var PopoverBody = function PopoverBody(_ref) {
|
|
@@ -299,9 +250,6 @@ var isFocusable = function isFocusable(element) {
|
|
|
299
250
|
if ('disabled' in element && element.disabled) {
|
|
300
251
|
return false;
|
|
301
252
|
}
|
|
302
|
-
if (element.tabIndex === 0) {
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
305
253
|
switch (element.nodeName) {
|
|
306
254
|
case 'A':
|
|
307
255
|
return element.href;
|
|
@@ -332,40 +280,6 @@ var focusFirstDescendant = function focusFirstDescendant(element) {
|
|
|
332
280
|
}
|
|
333
281
|
return false;
|
|
334
282
|
};
|
|
335
|
-
var findAllFocusableElementsInside = function findAllFocusableElementsInside(containerElement) {
|
|
336
|
-
var focusableElements = [];
|
|
337
|
-
var traverseDOM = function traverseDOM(element) {
|
|
338
|
-
if (isFocusable(element)) {
|
|
339
|
-
focusableElements.push(element);
|
|
340
|
-
}
|
|
341
|
-
var _arr2 = Array.from(element.childNodes);
|
|
342
|
-
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
|
|
343
|
-
var child = _arr2[_i2];
|
|
344
|
-
traverseDOM(child);
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
traverseDOM(containerElement);
|
|
348
|
-
return focusableElements;
|
|
349
|
-
};
|
|
350
|
-
var trapFocus = function trapFocus(element) {
|
|
351
|
-
var focusableEls = findAllFocusableElementsInside(element);
|
|
352
|
-
var _focusableEls = _slicedToArray(focusableEls, 1),
|
|
353
|
-
firstFocusableEl = _focusableEls[0];
|
|
354
|
-
var lastFocusableEl = focusableEls.pop();
|
|
355
|
-
element.addEventListener('keydown', function (event) {
|
|
356
|
-
var isTabPressed = event.key === 'Tab';
|
|
357
|
-
if (!isTabPressed) {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
if (event.shiftKey && document.activeElement === firstFocusableEl) {
|
|
361
|
-
lastFocusableEl.focus();
|
|
362
|
-
event.preventDefault();
|
|
363
|
-
} else if (document.activeElement === lastFocusableEl) {
|
|
364
|
-
firstFocusableEl.focus();
|
|
365
|
-
event.preventDefault();
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
};
|
|
369
283
|
|
|
370
284
|
var isScrollParent = function isScrollParent(element) {
|
|
371
285
|
// Firefox wants us to check `-x` and `-y` variations as well
|
|
@@ -449,7 +363,6 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
449
363
|
};
|
|
450
364
|
_this.handleKeyDown = function (event) {
|
|
451
365
|
if (event.key === 'Escape') {
|
|
452
|
-
event.stopPropagation();
|
|
453
366
|
_this.props.onEscapeAction(event);
|
|
454
367
|
}
|
|
455
368
|
};
|
|
@@ -495,9 +408,11 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
495
408
|
value: function componentDidMount() {
|
|
496
409
|
this.mounted = true;
|
|
497
410
|
this.adjustPosition();
|
|
498
|
-
if (this.
|
|
499
|
-
this.popoverContentRef.current
|
|
500
|
-
|
|
411
|
+
if (this.popoverContentRef.current) {
|
|
412
|
+
if (!focusFirstDescendant(this.popoverContentRef.current)) {
|
|
413
|
+
this.popoverContentRef.current.tabIndex = 0;
|
|
414
|
+
this.popoverContentRef.current.focus();
|
|
415
|
+
}
|
|
501
416
|
}
|
|
502
417
|
if (this.props.trackScroll) {
|
|
503
418
|
document.addEventListener('scroll', this.onScroll);
|
|
@@ -506,12 +421,6 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
506
421
|
this.props.containerElement.addEventListener('scroll', this.onScroll);
|
|
507
422
|
}
|
|
508
423
|
}
|
|
509
|
-
if (this.popoverContentRef.current && this.props.role === 'dialog') {
|
|
510
|
-
if (!focusFirstDescendant(this.popoverContentRef.current)) {
|
|
511
|
-
this.popoverContentRef.current.tabIndex = 0;
|
|
512
|
-
this.popoverContentRef.current.focus();
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
424
|
}
|
|
516
425
|
}, {
|
|
517
426
|
key: "componentDidUpdate",
|
|
@@ -519,9 +428,6 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
519
428
|
if (this.props.containerElement !== previousProps.containerElement || this.props.getPopoverPosition !== previousProps.getPopoverPosition) {
|
|
520
429
|
this.adjustPosition();
|
|
521
430
|
}
|
|
522
|
-
if (this.popoverContentRef.current && this.props.role === 'dialog') {
|
|
523
|
-
trapFocus(this.popoverContentRef.current);
|
|
524
|
-
}
|
|
525
431
|
}
|
|
526
432
|
}, {
|
|
527
433
|
key: "componentWillUnmount",
|
|
@@ -568,13 +474,13 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
568
474
|
}
|
|
569
475
|
}), React.createElement("div", {
|
|
570
476
|
ref: this.popoverContentRef,
|
|
477
|
+
"aria-modal": "true",
|
|
571
478
|
style: _extends({
|
|
572
479
|
position: 'absolute',
|
|
573
480
|
pointerEvents: 'all'
|
|
574
481
|
}, position),
|
|
575
482
|
className: this.props.className,
|
|
576
483
|
role: this.props.role,
|
|
577
|
-
"aria-modal": this.props.role === 'dialog' ? 'true' : 'false',
|
|
578
484
|
onKeyDown: this.handleKeyDown
|
|
579
485
|
}, this.props.children));
|
|
580
486
|
}
|
|
@@ -816,8 +722,7 @@ Popover.Position = PopoverPosition;
|
|
|
816
722
|
Popover.defaultProps = {
|
|
817
723
|
zIndex: 19999,
|
|
818
724
|
outerActionEvents: ['mousedown', 'touchstart'],
|
|
819
|
-
getPopoverPosition: 'bottomLeft'
|
|
820
|
-
role: 'dialog'
|
|
725
|
+
getPopoverPosition: 'bottomLeft'
|
|
821
726
|
};
|
|
822
727
|
|
|
823
728
|
export default Popover;
|
package/dist/popover.js
CHANGED
|
@@ -10,33 +10,6 @@ var globalConstants = require('@targetprocess/global-constants');
|
|
|
10
10
|
var classNames = _interopDefault(require('classnames'));
|
|
11
11
|
var ReactDOM = _interopDefault(require('react-dom'));
|
|
12
12
|
|
|
13
|
-
function _iterableToArrayLimit(r, l) {
|
|
14
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
15
|
-
if (null != t) {
|
|
16
|
-
var e,
|
|
17
|
-
n,
|
|
18
|
-
i,
|
|
19
|
-
u,
|
|
20
|
-
a = [],
|
|
21
|
-
f = !0,
|
|
22
|
-
o = !1;
|
|
23
|
-
try {
|
|
24
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
25
|
-
if (Object(t) !== t) return;
|
|
26
|
-
f = !1;
|
|
27
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
28
|
-
} catch (r) {
|
|
29
|
-
o = !0, n = r;
|
|
30
|
-
} finally {
|
|
31
|
-
try {
|
|
32
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
33
|
-
} finally {
|
|
34
|
-
if (o) throw n;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return a;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
13
|
function _classCallCheck(instance, Constructor) {
|
|
41
14
|
if (!(instance instanceof Constructor)) {
|
|
42
15
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -116,28 +89,6 @@ function _possibleConstructorReturn(self, call) {
|
|
|
116
89
|
}
|
|
117
90
|
return _assertThisInitialized(self);
|
|
118
91
|
}
|
|
119
|
-
function _slicedToArray(arr, i) {
|
|
120
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
121
|
-
}
|
|
122
|
-
function _arrayWithHoles(arr) {
|
|
123
|
-
if (Array.isArray(arr)) return arr;
|
|
124
|
-
}
|
|
125
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
126
|
-
if (!o) return;
|
|
127
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
128
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
129
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
130
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
131
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
132
|
-
}
|
|
133
|
-
function _arrayLikeToArray(arr, len) {
|
|
134
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
135
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
136
|
-
return arr2;
|
|
137
|
-
}
|
|
138
|
-
function _nonIterableRest() {
|
|
139
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
140
|
-
}
|
|
141
92
|
function _toPrimitive(input, hint) {
|
|
142
93
|
if (typeof input !== "object" || input === null) return input;
|
|
143
94
|
var prim = input[Symbol.toPrimitive];
|
|
@@ -261,8 +212,8 @@ function styleInject(css, ref) {
|
|
|
261
212
|
}
|
|
262
213
|
}
|
|
263
214
|
|
|
264
|
-
var css = ".popover-body-container__popover__12-19-
|
|
265
|
-
var styles = {"popover-body-container":"popover-body-container__popover__12-19-
|
|
215
|
+
var css = ".popover-body-container__popover__12-19-6-alpha-0 {\r\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\r\n border-radius: var(--BorderRadiusL, 4px);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n background: var(--BackgroundDefault, #FFFFFF);\r\n z-index: var(--ZIndexModal, 10001);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n}\r\n\r\n.popover-body__popover__12-19-6-alpha-0 {\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n padding: var(--SpaceSM, 12px);\r\n font-size: var(--FontSizeDefault, 13px);\r\n color: var(--FontColorDefault, #000000);\r\n}\r\n\r\n.popover-body--no-padding__popover__12-19-6-alpha-0 {\r\n padding: 0;\r\n }\r\n\r\n.popover-tip__popover__12-19-6-alpha-0 {\r\n position: absolute;\r\n pointer-events: none;\r\n z-index: calc(var(--ZIndexModal, 10001) + 1);\r\n overflow: hidden;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n -webkit-box-pack: center;\r\n -ms-flex-pack: center;\r\n justify-content: center;\r\n}\r\n\r\n.popover-tip__popover__12-19-6-alpha-0:before {\r\n content: '';\r\n position: absolute;\r\n display: block;\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n background-color: var(--BackgroundDefault, #FFFFFF);\r\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n /*\r\n geometry FTW\r\n\r\n 2*$popoverTipSize\r\n _______ _______\r\n | /|\\ |\r\n | / | \\ | $popoverTipSize\r\n | / | \\ |\r\n |/______|______\\|\r\n since tip is rotated 45 degrees, its width and height is a\r\n diagonal of a square with side=$popoverTipSize, thus diagonal\r\n is sqrt(2) * $popoverTipSize.\r\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\r\n */\r\n width: 11.2px;\r\n height: 11.2px;\r\n -webkit-transform: rotate(45deg);\r\n transform: rotate(45deg);\r\n }\r\n\r\n.popover-tip--bottom__popover__12-19-6-alpha-0,\r\n .popover-tip--top__popover__12-19-6-alpha-0 {\r\n width: 100%;\r\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 9px;\r\n }\r\n\r\n.popover-tip--left__popover__12-19-6-alpha-0,\r\n .popover-tip--right__popover__12-19-6-alpha-0 {\r\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\r\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\r\n height: 100%;\r\n width: 9px;\r\n }\r\n\r\n/*\r\n To determine tip position, we need to rotate it\r\n along the \"tip\" point, after that, the \"tip\" point\r\n can be placed with exactly 50% offset from the origin\r\n so that it is centered.\r\n */\r\n\r\n.popover-tip--bottom__popover__12-19-6-alpha-0:before {\r\n -webkit-transform-origin: left top;\r\n transform-origin: left top;\r\n left: 50%;\r\n top: 0;\r\n }\r\n\r\n.popover-tip--top__popover__12-19-6-alpha-0:before {\r\n -webkit-transform-origin: right bottom;\r\n transform-origin: right bottom;\r\n right: 50%;\r\n bottom: 0;\r\n }\r\n\r\n.popover-tip--left__popover__12-19-6-alpha-0:before {\r\n -webkit-transform-origin: right top;\r\n transform-origin: right top;\r\n right: 0;\r\n top: 50%;\r\n }\r\n\r\n.popover-tip--right__popover__12-19-6-alpha-0:before {\r\n -webkit-transform-origin: left bottom;\r\n transform-origin: left bottom;\r\n left: 0;\r\n bottom: 50%;\r\n }\r\n";
|
|
216
|
+
var styles = {"popover-body-container":"popover-body-container__popover__12-19-6-alpha-0","popover-body":"popover-body__popover__12-19-6-alpha-0","popover-body--no-padding":"popover-body--no-padding__popover__12-19-6-alpha-0","popover-tip":"popover-tip__popover__12-19-6-alpha-0","popover-tip--bottom":"popover-tip--bottom__popover__12-19-6-alpha-0","popover-tip--top":"popover-tip--top__popover__12-19-6-alpha-0","popover-tip--left":"popover-tip--left__popover__12-19-6-alpha-0","popover-tip--right":"popover-tip--right__popover__12-19-6-alpha-0"};
|
|
266
217
|
styleInject(css);
|
|
267
218
|
|
|
268
219
|
var PopoverBody = function PopoverBody(_ref) {
|
|
@@ -306,9 +257,6 @@ var isFocusable = function isFocusable(element) {
|
|
|
306
257
|
if ('disabled' in element && element.disabled) {
|
|
307
258
|
return false;
|
|
308
259
|
}
|
|
309
|
-
if (element.tabIndex === 0) {
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
260
|
switch (element.nodeName) {
|
|
313
261
|
case 'A':
|
|
314
262
|
return element.href;
|
|
@@ -339,40 +287,6 @@ var focusFirstDescendant = function focusFirstDescendant(element) {
|
|
|
339
287
|
}
|
|
340
288
|
return false;
|
|
341
289
|
};
|
|
342
|
-
var findAllFocusableElementsInside = function findAllFocusableElementsInside(containerElement) {
|
|
343
|
-
var focusableElements = [];
|
|
344
|
-
var traverseDOM = function traverseDOM(element) {
|
|
345
|
-
if (isFocusable(element)) {
|
|
346
|
-
focusableElements.push(element);
|
|
347
|
-
}
|
|
348
|
-
var _arr2 = Array.from(element.childNodes);
|
|
349
|
-
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
|
|
350
|
-
var child = _arr2[_i2];
|
|
351
|
-
traverseDOM(child);
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
traverseDOM(containerElement);
|
|
355
|
-
return focusableElements;
|
|
356
|
-
};
|
|
357
|
-
var trapFocus = function trapFocus(element) {
|
|
358
|
-
var focusableEls = findAllFocusableElementsInside(element);
|
|
359
|
-
var _focusableEls = _slicedToArray(focusableEls, 1),
|
|
360
|
-
firstFocusableEl = _focusableEls[0];
|
|
361
|
-
var lastFocusableEl = focusableEls.pop();
|
|
362
|
-
element.addEventListener('keydown', function (event) {
|
|
363
|
-
var isTabPressed = event.key === 'Tab';
|
|
364
|
-
if (!isTabPressed) {
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
if (event.shiftKey && document.activeElement === firstFocusableEl) {
|
|
368
|
-
lastFocusableEl.focus();
|
|
369
|
-
event.preventDefault();
|
|
370
|
-
} else if (document.activeElement === lastFocusableEl) {
|
|
371
|
-
firstFocusableEl.focus();
|
|
372
|
-
event.preventDefault();
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
};
|
|
376
290
|
|
|
377
291
|
var isScrollParent = function isScrollParent(element) {
|
|
378
292
|
// Firefox wants us to check `-x` and `-y` variations as well
|
|
@@ -456,7 +370,6 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
456
370
|
};
|
|
457
371
|
_this.handleKeyDown = function (event) {
|
|
458
372
|
if (event.key === 'Escape') {
|
|
459
|
-
event.stopPropagation();
|
|
460
373
|
_this.props.onEscapeAction(event);
|
|
461
374
|
}
|
|
462
375
|
};
|
|
@@ -502,9 +415,11 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
502
415
|
value: function componentDidMount() {
|
|
503
416
|
this.mounted = true;
|
|
504
417
|
this.adjustPosition();
|
|
505
|
-
if (this.
|
|
506
|
-
this.popoverContentRef.current
|
|
507
|
-
|
|
418
|
+
if (this.popoverContentRef.current) {
|
|
419
|
+
if (!focusFirstDescendant(this.popoverContentRef.current)) {
|
|
420
|
+
this.popoverContentRef.current.tabIndex = 0;
|
|
421
|
+
this.popoverContentRef.current.focus();
|
|
422
|
+
}
|
|
508
423
|
}
|
|
509
424
|
if (this.props.trackScroll) {
|
|
510
425
|
document.addEventListener('scroll', this.onScroll);
|
|
@@ -513,12 +428,6 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
513
428
|
this.props.containerElement.addEventListener('scroll', this.onScroll);
|
|
514
429
|
}
|
|
515
430
|
}
|
|
516
|
-
if (this.popoverContentRef.current && this.props.role === 'dialog') {
|
|
517
|
-
if (!focusFirstDescendant(this.popoverContentRef.current)) {
|
|
518
|
-
this.popoverContentRef.current.tabIndex = 0;
|
|
519
|
-
this.popoverContentRef.current.focus();
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
431
|
}
|
|
523
432
|
}, {
|
|
524
433
|
key: "componentDidUpdate",
|
|
@@ -526,9 +435,6 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
526
435
|
if (this.props.containerElement !== previousProps.containerElement || this.props.getPopoverPosition !== previousProps.getPopoverPosition) {
|
|
527
436
|
this.adjustPosition();
|
|
528
437
|
}
|
|
529
|
-
if (this.popoverContentRef.current && this.props.role === 'dialog') {
|
|
530
|
-
trapFocus(this.popoverContentRef.current);
|
|
531
|
-
}
|
|
532
438
|
}
|
|
533
439
|
}, {
|
|
534
440
|
key: "componentWillUnmount",
|
|
@@ -575,13 +481,13 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
575
481
|
}
|
|
576
482
|
}), React__default.createElement("div", {
|
|
577
483
|
ref: this.popoverContentRef,
|
|
484
|
+
"aria-modal": "true",
|
|
578
485
|
style: _extends({
|
|
579
486
|
position: 'absolute',
|
|
580
487
|
pointerEvents: 'all'
|
|
581
488
|
}, position),
|
|
582
489
|
className: this.props.className,
|
|
583
490
|
role: this.props.role,
|
|
584
|
-
"aria-modal": this.props.role === 'dialog' ? 'true' : 'false',
|
|
585
491
|
onKeyDown: this.handleKeyDown
|
|
586
492
|
}, this.props.children));
|
|
587
493
|
}
|
|
@@ -823,8 +729,7 @@ Popover.Position = PopoverPosition;
|
|
|
823
729
|
Popover.defaultProps = {
|
|
824
730
|
zIndex: 19999,
|
|
825
731
|
outerActionEvents: ['mousedown', 'touchstart'],
|
|
826
|
-
getPopoverPosition: 'bottomLeft'
|
|
827
|
-
role: 'dialog'
|
|
732
|
+
getPopoverPosition: 'bottomLeft'
|
|
828
733
|
};
|
|
829
734
|
|
|
830
735
|
exports.Popover = Popover;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@targetprocess/popover",
|
|
3
|
-
"version": "12.19.
|
|
3
|
+
"version": "12.19.6-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/popover.js",
|
|
6
6
|
"module": "dist/popover.es.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"prepack": "node -r ../../.ts-node.js ../../config/rollup.config.js ."
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@targetprocess/global-constants": "^12.
|
|
15
|
+
"@targetprocess/global-constants": "^12.19.6-alpha.0",
|
|
16
16
|
"classnames": "^2.2.5",
|
|
17
17
|
"prop-types": "^15.6.0",
|
|
18
18
|
"react": "^16.7.0",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "09c2de637be6694aef61a9dbe734ecb9cc9e8e59"
|
|
25
25
|
}
|