@targetprocess/popover 12.32.2 → 12.32.3-ci.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/BodyDomNode.tests.tsx +12 -12
- package/__tests__/Popover.tests.tsx +3 -4
- package/__tests__/PositioningTarget.tests.tsx +3 -3
- package/dist/BodyDomNode.d.ts +1 -1
- package/dist/Popover.d.ts +4 -4
- package/dist/PopoverBody.d.ts +1 -1
- package/dist/PopoverContainer.d.ts +3 -3
- package/dist/StatlessPopover.d.ts +1 -1
- package/dist/popover.es.js +100 -121
- package/dist/popover.js +119 -134
- package/dist/types.d.ts +5 -5
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*********************************************************************
|
|
2
|
-
* © Copyright IBM Corp.
|
|
2
|
+
* © Copyright IBM Corp. 2026
|
|
3
3
|
*********************************************************************/
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import ReactDOM from 'react-dom'
|
|
@@ -59,7 +59,7 @@ describe('BodyDomNode', () => {
|
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
it('should call render prop with null initially', () => {
|
|
62
|
-
const renderProp = jest.fn(() => null)
|
|
62
|
+
const renderProp = jest.fn((_node?: HTMLElement | null) => null)
|
|
63
63
|
|
|
64
64
|
mountComponent({children: renderProp})
|
|
65
65
|
|
|
@@ -75,7 +75,7 @@ describe('BodyDomNode', () => {
|
|
|
75
75
|
|
|
76
76
|
it('should call render prop with mounted dom node', async () => {
|
|
77
77
|
const appendChild = jest.fn(child => originalBodyAppendChild.call(document.body, child))
|
|
78
|
-
const renderProp = jest.fn(() => null)
|
|
78
|
+
const renderProp = jest.fn((_node?: HTMLElement | null) => null)
|
|
79
79
|
const componentDidMountCalled = stubComponentDidMount()
|
|
80
80
|
|
|
81
81
|
document.body.appendChild = appendChild
|
|
@@ -120,7 +120,7 @@ describe('BodyDomNode', () => {
|
|
|
120
120
|
dispatchNativeMouseEvent(eventTargetNode)
|
|
121
121
|
dispatchNativeKeyboardEvent(eventTargetNode)
|
|
122
122
|
|
|
123
|
-
expect(onOuterAction).
|
|
123
|
+
expect(onOuterAction).toHaveBeenCalledTimes(2)
|
|
124
124
|
})
|
|
125
125
|
|
|
126
126
|
it('should not call onOuterAction callback if outerActionEvents is not specified', async () => {
|
|
@@ -138,7 +138,7 @@ describe('BodyDomNode', () => {
|
|
|
138
138
|
dispatchNativeMouseEvent(eventTargetNode)
|
|
139
139
|
dispatchNativeKeyboardEvent(eventTargetNode)
|
|
140
140
|
|
|
141
|
-
expect(onOuterAction).not.
|
|
141
|
+
expect(onOuterAction).not.toHaveBeenCalled()
|
|
142
142
|
})
|
|
143
143
|
|
|
144
144
|
it('should not call onOuterAction callback for events that is not specified in outerActionEvents', async () => {
|
|
@@ -160,7 +160,7 @@ describe('BodyDomNode', () => {
|
|
|
160
160
|
mouseEvents.forEach(event => dispatchNativeMouseEvent(eventTargetNode, event))
|
|
161
161
|
keyboardEvents.forEach(event => dispatchNativeKeyboardEvent(eventTargetNode, event))
|
|
162
162
|
|
|
163
|
-
expect(onOuterAction).not.
|
|
163
|
+
expect(onOuterAction).not.toHaveBeenCalled()
|
|
164
164
|
})
|
|
165
165
|
|
|
166
166
|
it('should not call onOuterAction after component will be unmounted', async () => {
|
|
@@ -184,7 +184,7 @@ describe('BodyDomNode', () => {
|
|
|
184
184
|
dispatchNativeMouseEvent(eventTargetNode)
|
|
185
185
|
dispatchNativeKeyboardEvent(eventTargetNode)
|
|
186
186
|
|
|
187
|
-
expect(onOuterAction).not.
|
|
187
|
+
expect(onOuterAction).not.toHaveBeenCalled()
|
|
188
188
|
})
|
|
189
189
|
|
|
190
190
|
it('should not call onOuterAction for events inside component children', async () => {
|
|
@@ -209,7 +209,7 @@ describe('BodyDomNode', () => {
|
|
|
209
209
|
dispatchNativeMouseEvent(eventTargetNode)
|
|
210
210
|
dispatchNativeKeyboardEvent(eventTargetNode)
|
|
211
211
|
|
|
212
|
-
expect(onOuterAction).not.
|
|
212
|
+
expect(onOuterAction).not.toHaveBeenCalled()
|
|
213
213
|
|
|
214
214
|
wrapper.detach()
|
|
215
215
|
})
|
|
@@ -236,8 +236,8 @@ describe('BodyDomNode', () => {
|
|
|
236
236
|
|
|
237
237
|
dispatchNativeMouseEvent(eventTargetNode)
|
|
238
238
|
|
|
239
|
-
expect(onOuterActionBeforeUpdate).
|
|
240
|
-
expect(onOuterActionAfterUpdate).
|
|
239
|
+
expect(onOuterActionBeforeUpdate).toHaveBeenCalledTimes(0)
|
|
240
|
+
expect(onOuterActionAfterUpdate).toHaveBeenCalledTimes(1)
|
|
241
241
|
})
|
|
242
242
|
|
|
243
243
|
it('should not call onOuterAction for removed events after outerActiveEvents array change', async () => {
|
|
@@ -262,7 +262,7 @@ describe('BodyDomNode', () => {
|
|
|
262
262
|
dispatchNativeMouseEvent(eventTargetNode)
|
|
263
263
|
dispatchNativeKeyboardEvent(eventTargetNode)
|
|
264
264
|
|
|
265
|
-
expect(onOuterAction).
|
|
265
|
+
expect(onOuterAction).toHaveBeenCalledTimes(1)
|
|
266
266
|
expect(onOuterAction.mock.calls[0][0].type).toBe('keydown')
|
|
267
267
|
})
|
|
268
268
|
|
|
@@ -282,6 +282,6 @@ describe('BodyDomNode', () => {
|
|
|
282
282
|
dispatchNativeMouseEvent(eventTargetNode)
|
|
283
283
|
dispatchNativeKeyboardEvent(eventTargetNode)
|
|
284
284
|
|
|
285
|
-
expect(onOuterAction).not.
|
|
285
|
+
expect(onOuterAction).not.toHaveBeenCalled()
|
|
286
286
|
})
|
|
287
287
|
})
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/*********************************************************************
|
|
2
|
-
* © Copyright IBM Corp.
|
|
2
|
+
* © Copyright IBM Corp. 2026
|
|
3
3
|
*********************************************************************/
|
|
4
|
-
/* eslint-env jest */
|
|
5
4
|
import React from 'react'
|
|
6
5
|
import {mount} from 'enzyme'
|
|
7
6
|
import {Popover, PopoverProps, PopoverState} from '../Popover'
|
|
@@ -76,7 +75,7 @@ describe('Popover', () => {
|
|
|
76
75
|
</Popover>
|
|
77
76
|
)
|
|
78
77
|
|
|
79
|
-
expect(ref1).
|
|
80
|
-
expect(ref2).
|
|
78
|
+
expect(ref1).toHaveBeenCalled()
|
|
79
|
+
expect(ref2).toHaveBeenCalled()
|
|
81
80
|
})
|
|
82
81
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*********************************************************************
|
|
2
|
-
* © Copyright IBM Corp.
|
|
2
|
+
* © Copyright IBM Corp. 2026
|
|
3
3
|
*********************************************************************/
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import {mount} from 'enzyme'
|
|
@@ -16,7 +16,7 @@ describe('PositioningTarget', () => {
|
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
it('shoud call render prop with null initially', () => {
|
|
19
|
-
const renderProp = jest.fn(() => null)
|
|
19
|
+
const renderProp = jest.fn((_node?: HTMLElement | null) => null)
|
|
20
20
|
|
|
21
21
|
mount(<PositioningTarget>{renderProp}</PositioningTarget>)
|
|
22
22
|
|
|
@@ -25,7 +25,7 @@ describe('PositioningTarget', () => {
|
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
it('should call render prop with div after component will be mounted', async () => {
|
|
28
|
-
const renderProp = jest.fn(() => null)
|
|
28
|
+
const renderProp = jest.fn((_node?: HTMLElement | null) => null)
|
|
29
29
|
const componentDidMountCalled = stubComponentDidMount()
|
|
30
30
|
|
|
31
31
|
mount(<PositioningTarget>{renderProp}</PositioningTarget>)
|
package/dist/BodyDomNode.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*********************************************************************/
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
export
|
|
6
|
+
export type BodyDomNodeProps = {
|
|
7
7
|
children: (node: HTMLElement) => React.ReactNode;
|
|
8
8
|
onOuterAction?: (event: Event) => void;
|
|
9
9
|
outerActionEvents?: string[];
|
package/dist/Popover.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ import { GetPopoverPositionType } from './types';
|
|
|
69
69
|
* Triangle position is calculated automatically depending on relative popover
|
|
70
70
|
* position; it is always placed at the center of the trigger from the according side.
|
|
71
71
|
*/
|
|
72
|
-
export
|
|
72
|
+
export type PopoverProps = {
|
|
73
73
|
closeOnOuterAction?: boolean;
|
|
74
74
|
isOpen?: boolean;
|
|
75
75
|
getPopoverPosition: GetPopoverPositionType;
|
|
@@ -86,7 +86,7 @@ export declare type PopoverProps = {
|
|
|
86
86
|
role?: 'tooltip' | 'dialog';
|
|
87
87
|
trapFocus?: boolean;
|
|
88
88
|
};
|
|
89
|
-
export
|
|
89
|
+
export type PopoverState = {
|
|
90
90
|
isOpen: boolean;
|
|
91
91
|
};
|
|
92
92
|
export declare class Popover extends React.Component<PopoverProps, PopoverState> {
|
|
@@ -106,7 +106,7 @@ export declare class Popover extends React.Component<PopoverProps, PopoverState>
|
|
|
106
106
|
/** Wether to show the triangle. */
|
|
107
107
|
showTip: PropTypes.Requireable<boolean>;
|
|
108
108
|
/** Position string or positioning function. */
|
|
109
|
-
getPopoverPosition: PropTypes.Requireable<string | ((...args: any[]) => any)
|
|
109
|
+
getPopoverPosition: PropTypes.Requireable<NonNullable<string | ((...args: any[]) => any)>>;
|
|
110
110
|
/**
|
|
111
111
|
* Events that trigger `onOuterAction`.
|
|
112
112
|
*/
|
|
@@ -116,7 +116,7 @@ export declare class Popover extends React.Component<PopoverProps, PopoverState>
|
|
|
116
116
|
noPadding: PropTypes.Requireable<boolean>;
|
|
117
117
|
zIndex: PropTypes.Requireable<number>;
|
|
118
118
|
trackScroll: PropTypes.Requireable<boolean>;
|
|
119
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike
|
|
119
|
+
children: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactNodeLike>>;
|
|
120
120
|
role: PropTypes.Requireable<string>;
|
|
121
121
|
trapFocus: PropTypes.Requireable<boolean>;
|
|
122
122
|
};
|
package/dist/PopoverBody.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* © Copyright IBM Corp. 2024
|
|
3
3
|
*********************************************************************/
|
|
4
4
|
import React from 'react';
|
|
5
|
-
export
|
|
5
|
+
export type PopoverBodyProps = {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
className?: string;
|
|
8
8
|
classNameBody?: string;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { DimensionParams, GetPopoverPositionType, PositionParams } from './types';
|
|
7
|
-
|
|
7
|
+
type PopoverContainerProps = {
|
|
8
8
|
containerElement?: HTMLElement;
|
|
9
9
|
positioningTarget: HTMLElement;
|
|
10
10
|
className?: string;
|
|
@@ -19,7 +19,7 @@ declare type PopoverContainerProps = {
|
|
|
19
19
|
trapFocus?: boolean;
|
|
20
20
|
onEscapeAction: (event: Event) => void;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
type PopoverContainerState = {
|
|
23
23
|
adjusted: boolean;
|
|
24
24
|
positionX: number;
|
|
25
25
|
positionY: number;
|
|
@@ -50,7 +50,7 @@ export declare class PopoverContainer extends React.Component<PopoverContainerPr
|
|
|
50
50
|
componentDidMount(): void;
|
|
51
51
|
componentDidUpdate(previousProps: any): void;
|
|
52
52
|
componentWillUnmount(): void;
|
|
53
|
-
getPopoverTipPosition: (popoverPosition: any, containerPosition: any) => "
|
|
53
|
+
getPopoverTipPosition: (popoverPosition: any, containerPosition: any) => "left" | "right" | "bottom" | "top";
|
|
54
54
|
handleKeyDown: (event: any) => void;
|
|
55
55
|
render(): JSX.Element;
|
|
56
56
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*********************************************************************/
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { GetPopoverPositionType } from './types';
|
|
6
|
-
export
|
|
6
|
+
export type StatelessPopoverProps = {
|
|
7
7
|
isOpen: boolean;
|
|
8
8
|
getPopoverPosition: GetPopoverPositionType;
|
|
9
9
|
getContainerElement?: () => HTMLElement;
|
package/dist/popover.es.js
CHANGED
|
@@ -4,98 +4,84 @@ import classNames from 'classnames';
|
|
|
4
4
|
import ReactDOM from 'react-dom';
|
|
5
5
|
import FocusTrap from 'focus-trap-react';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
function _assertThisInitialized(e) {
|
|
8
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
9
|
+
return e;
|
|
10
|
+
}
|
|
11
|
+
function _callSuper(t, o, e) {
|
|
12
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
13
|
+
}
|
|
14
|
+
function _classCallCheck(a, n) {
|
|
15
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
11
16
|
}
|
|
12
|
-
function _defineProperties(
|
|
13
|
-
for (var
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
descriptor.configurable = true;
|
|
17
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
18
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
17
|
+
function _defineProperties(e, r) {
|
|
18
|
+
for (var t = 0; t < r.length; t++) {
|
|
19
|
+
var o = r[t];
|
|
20
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
|
-
function _createClass(
|
|
22
|
-
|
|
23
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
23
|
+
function _createClass(e, r, t) {
|
|
24
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
25
25
|
writable: false
|
|
26
|
-
});
|
|
27
|
-
return Constructor;
|
|
26
|
+
}), e;
|
|
28
27
|
}
|
|
29
28
|
function _extends() {
|
|
30
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
31
|
-
for (var
|
|
32
|
-
var
|
|
33
|
-
for (var
|
|
34
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
35
|
-
target[key] = source[key];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
29
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
30
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
31
|
+
var t = arguments[e];
|
|
32
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
38
33
|
}
|
|
39
|
-
return
|
|
40
|
-
};
|
|
41
|
-
return _extends.apply(this, arguments);
|
|
34
|
+
return n;
|
|
35
|
+
}, _extends.apply(null, arguments);
|
|
42
36
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
37
|
+
function _getPrototypeOf(t) {
|
|
38
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
39
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
40
|
+
}, _getPrototypeOf(t);
|
|
41
|
+
}
|
|
42
|
+
function _inherits(t, e) {
|
|
43
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
44
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
48
45
|
constructor: {
|
|
49
|
-
value:
|
|
46
|
+
value: t,
|
|
50
47
|
writable: true,
|
|
51
48
|
configurable: true
|
|
52
49
|
}
|
|
53
|
-
})
|
|
54
|
-
Object.defineProperty(subClass, "prototype", {
|
|
50
|
+
}), Object.defineProperty(t, "prototype", {
|
|
55
51
|
writable: false
|
|
56
|
-
});
|
|
57
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
52
|
+
}), e && _setPrototypeOf(t, e);
|
|
58
53
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
return
|
|
54
|
+
function _isNativeReflectConstruct() {
|
|
55
|
+
try {
|
|
56
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
57
|
+
} catch (t) {}
|
|
58
|
+
return (_isNativeReflectConstruct = function () {
|
|
59
|
+
return !!t;
|
|
60
|
+
})();
|
|
64
61
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
return _setPrototypeOf(o, p);
|
|
62
|
+
function _possibleConstructorReturn(t, e) {
|
|
63
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
64
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
65
|
+
return _assertThisInitialized(t);
|
|
71
66
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
return self;
|
|
67
|
+
function _setPrototypeOf(t, e) {
|
|
68
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
69
|
+
return t.__proto__ = e, t;
|
|
70
|
+
}, _setPrototypeOf(t, e);
|
|
77
71
|
}
|
|
78
|
-
function
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return _assertThisInitialized(self);
|
|
85
|
-
}
|
|
86
|
-
function _toPrimitive(input, hint) {
|
|
87
|
-
if (typeof input !== "object" || input === null) return input;
|
|
88
|
-
var prim = input[Symbol.toPrimitive];
|
|
89
|
-
if (prim !== undefined) {
|
|
90
|
-
var res = prim.call(input, hint || "default");
|
|
91
|
-
if (typeof res !== "object") return res;
|
|
72
|
+
function _toPrimitive(t, e) {
|
|
73
|
+
if ("object" != typeof t || !t) return t;
|
|
74
|
+
var r;
|
|
75
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
76
|
+
var i = r.call(t, e);
|
|
77
|
+
if ("object" != typeof i) return i;
|
|
92
78
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
93
79
|
}
|
|
94
|
-
return (
|
|
80
|
+
return (String )(t);
|
|
95
81
|
}
|
|
96
|
-
function _toPropertyKey(
|
|
97
|
-
var
|
|
98
|
-
return
|
|
82
|
+
function _toPropertyKey(t) {
|
|
83
|
+
var i = _toPrimitive(t, "string");
|
|
84
|
+
return "symbol" == typeof i ? i : i + "";
|
|
99
85
|
}
|
|
100
86
|
|
|
101
87
|
/*********************************************************************
|
|
@@ -186,7 +172,7 @@ function styleInject(css, ref) {
|
|
|
186
172
|
if ( ref === void 0 ) ref = {};
|
|
187
173
|
var insertAt = ref.insertAt;
|
|
188
174
|
|
|
189
|
-
if (
|
|
175
|
+
if (typeof document === 'undefined') { return; }
|
|
190
176
|
|
|
191
177
|
var head = document.head || document.getElementsByTagName('head')[0];
|
|
192
178
|
var style = document.createElement('style');
|
|
@@ -209,9 +195,9 @@ function styleInject(css, ref) {
|
|
|
209
195
|
}
|
|
210
196
|
}
|
|
211
197
|
|
|
212
|
-
var
|
|
213
|
-
var styles = {"popover-body-container":"popover-body-container__popover__12-32-2","popover-body":"popover-body__popover__12-32-2","popover-body--no-padding":"popover-body--no-padding__popover__12-32-2","popover-tip":"popover-tip__popover__12-32-2","popover-tip--bottom":"popover-tip--bottom__popover__12-32-2","popover-tip--top":"popover-tip--top__popover__12-32-2","popover-tip--left":"popover-tip--left__popover__12-32-2","popover-tip--right":"popover-tip--right__popover__12-32-2"};
|
|
214
|
-
styleInject(
|
|
198
|
+
var css_248z = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n\n.popover-body-container__popover__12-32-3-ci-2 {\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n border-radius: var(--BorderRadiusL, 4px);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n background: var(--BackgroundDefault, #FFFFFF);\n z-index: var(--ZIndexModal, 10001);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n.popover-body__popover__12-32-3-ci-2 {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding: var(--SpaceSM, 12px);\n font-size: var(--FontSizeDefault, 13px);\n color: var(--FontColorDefault, #000000);\n}\n\n.popover-body--no-padding__popover__12-32-3-ci-2 {\n padding: 0;\n }\n\n.popover-tip__popover__12-32-3-ci-2 {\n position: absolute;\n pointer-events: none;\n z-index: calc(1 + var(--ZIndexModal, 10001));\n overflow: hidden;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n\n /*\n To determine tip position, we need to rotate it\n along the \"tip\" point, after that, the \"tip\" point\n can be placed with exactly 50% offset from the origin\n so that it is centered.\n */\n}\n\n.popover-tip__popover__12-32-3-ci-2:before {\n content: '';\n position: absolute;\n display: block;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n background-color: var(--BackgroundDefault, #FFFFFF);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n /*\n geometry FTW\n\n 2*$popoverTipSize\n _______ _______\n | /|\\ |\n | / | \\ | $popoverTipSize\n | / | \\ |\n |/______|______\\|\n since tip is rotated 45 degrees, its width and height is a\n diagonal of a square with side=$popoverTipSize, thus diagonal\n is sqrt(2) * $popoverTipSize.\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\n */\n width: calc(11.2px);\n height: calc(11.2px);\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n\n.popover-tip--bottom__popover__12-32-3-ci-2,\n .popover-tip--top__popover__12-32-3-ci-2 {\n width: 100%;\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\n height: calc(9px);\n }\n\n.popover-tip--left__popover__12-32-3-ci-2,\n .popover-tip--right__popover__12-32-3-ci-2 {\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\n height: 100%;\n width: calc(9px);\n }\n\n.popover-tip--bottom__popover__12-32-3-ci-2:before {\n -webkit-transform-origin: left top;\n transform-origin: left top;\n left: 50%;\n top: 0;\n }\n\n.popover-tip--top__popover__12-32-3-ci-2:before {\n -webkit-transform-origin: right bottom;\n transform-origin: right bottom;\n right: 50%;\n bottom: 0;\n }\n\n.popover-tip--left__popover__12-32-3-ci-2:before {\n -webkit-transform-origin: right top;\n transform-origin: right top;\n right: 0;\n top: 50%;\n }\n\n.popover-tip--right__popover__12-32-3-ci-2:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
|
|
199
|
+
var styles = {"popover-body-container":"popover-body-container__popover__12-32-3-ci-2","popover-body":"popover-body__popover__12-32-3-ci-2","popover-body--no-padding":"popover-body--no-padding__popover__12-32-3-ci-2","popover-tip":"popover-tip__popover__12-32-3-ci-2","popover-tip--bottom":"popover-tip--bottom__popover__12-32-3-ci-2","popover-tip--top":"popover-tip--top__popover__12-32-3-ci-2","popover-tip--left":"popover-tip--left__popover__12-32-3-ci-2","popover-tip--right":"popover-tip--right__popover__12-32-3-ci-2"};
|
|
200
|
+
styleInject(css_248z);
|
|
215
201
|
|
|
216
202
|
/*********************************************************************
|
|
217
203
|
* © Copyright IBM Corp. 2024
|
|
@@ -221,9 +207,9 @@ var PopoverBody = function PopoverBody(_ref) {
|
|
|
221
207
|
className = _ref.className,
|
|
222
208
|
classNameBody = _ref.classNameBody,
|
|
223
209
|
noPadding = _ref.noPadding;
|
|
224
|
-
return React.createElement("div", {
|
|
210
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
225
211
|
className: classNames(className, styles['popover-body-container'])
|
|
226
|
-
}, React.createElement("div", {
|
|
212
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
227
213
|
className: classNames(classNameBody, styles['popover-body'], noPadding && styles['popover-body--no-padding'])
|
|
228
214
|
}, children));
|
|
229
215
|
};
|
|
@@ -289,11 +275,10 @@ var attemptFocus = function attemptFocus(element) {
|
|
|
289
275
|
element.focus();
|
|
290
276
|
return document.activeElement === element;
|
|
291
277
|
};
|
|
292
|
-
var
|
|
293
|
-
var
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (attemptFocus(child) || focusFirstDescendant(child)) {
|
|
278
|
+
var _focusFirstDescendant = function focusFirstDescendant(element) {
|
|
279
|
+
for (var _i = 0, _Array$from = Array.from(element.childNodes); _i < _Array$from.length; _i++) {
|
|
280
|
+
var child = _Array$from[_i];
|
|
281
|
+
if (attemptFocus(child) || _focusFirstDescendant(child)) {
|
|
297
282
|
return true;
|
|
298
283
|
}
|
|
299
284
|
}
|
|
@@ -348,13 +333,12 @@ var getCompositeRect = function getCompositeRect(elementOrVirtualElement, offset
|
|
|
348
333
|
};
|
|
349
334
|
};
|
|
350
335
|
var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
351
|
-
_inherits(PopoverContainer, _React$Component);
|
|
352
336
|
function PopoverContainer() {
|
|
353
337
|
var _this;
|
|
354
338
|
_classCallCheck(this, PopoverContainer);
|
|
355
|
-
_this =
|
|
339
|
+
_this = _callSuper(this, PopoverContainer, arguments);
|
|
356
340
|
_this.mounted = false;
|
|
357
|
-
_this.popoverContentRef = React.createRef();
|
|
341
|
+
_this.popoverContentRef = /*#__PURE__*/React.createRef();
|
|
358
342
|
_this.state = {
|
|
359
343
|
adjusted: false,
|
|
360
344
|
positionX: 0,
|
|
@@ -390,7 +374,8 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
390
374
|
};
|
|
391
375
|
return _this;
|
|
392
376
|
}
|
|
393
|
-
|
|
377
|
+
_inherits(PopoverContainer, _React$Component);
|
|
378
|
+
return _createClass(PopoverContainer, [{
|
|
394
379
|
key: "adjustPosition",
|
|
395
380
|
value: function adjustPosition() {
|
|
396
381
|
var _this2 = this;
|
|
@@ -438,7 +423,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
438
423
|
}
|
|
439
424
|
}
|
|
440
425
|
if (this.popoverContentRef.current && !this.props.trapFocus) {
|
|
441
|
-
if (!
|
|
426
|
+
if (!_focusFirstDescendant(this.popoverContentRef.current)) {
|
|
442
427
|
this.popoverContentRef.current.tabIndex = -1;
|
|
443
428
|
this.popoverContentRef.current.focus();
|
|
444
429
|
}
|
|
@@ -476,7 +461,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
476
461
|
};
|
|
477
462
|
var tipPosition = this.getPopoverTipPosition(position, containerPosition);
|
|
478
463
|
// FIXME: position.top cast to number, because value may be not a number
|
|
479
|
-
return React.createElement("div", {
|
|
464
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
480
465
|
style: _extends({
|
|
481
466
|
position: 'absolute'
|
|
482
467
|
}, containerPosition, {
|
|
@@ -486,7 +471,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
486
471
|
transitionProperty: 'opacity',
|
|
487
472
|
opacity: this.state.adjusted ? 1 : 0
|
|
488
473
|
})
|
|
489
|
-
}, this.props.showTip && tipPosition && React.createElement("div", {
|
|
474
|
+
}, this.props.showTip && tipPosition && /*#__PURE__*/React.createElement("div", {
|
|
490
475
|
className: classNames(styles['popover-tip'], styles["popover-tip--".concat(tipPosition)], 'popover-tip', this.props.classNameTip),
|
|
491
476
|
style: {
|
|
492
477
|
top: tipPosition === 'bottom' && position.top - 8,
|
|
@@ -494,13 +479,13 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
494
479
|
left: tipPosition === 'right' && position.left - 8,
|
|
495
480
|
right: tipPosition === 'left' && position.right - 8
|
|
496
481
|
}
|
|
497
|
-
}), this.props.trapFocus && React.createElement(FocusTrap, {
|
|
482
|
+
}), this.props.trapFocus && /*#__PURE__*/React.createElement(FocusTrap, {
|
|
498
483
|
focusTrapOptions: {
|
|
499
484
|
fallbackFocus: "#".concat(this.popoverContainerId),
|
|
500
485
|
clickOutsideDeactivates: true,
|
|
501
486
|
trapStack: window.__globalTrapStack
|
|
502
487
|
}
|
|
503
|
-
}, React.createElement("div", {
|
|
488
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
504
489
|
id: this.popoverContainerId,
|
|
505
490
|
ref: this.popoverContentRef,
|
|
506
491
|
style: _extends({
|
|
@@ -512,7 +497,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
512
497
|
role: this.props.role,
|
|
513
498
|
"aria-modal": this.props.trapFocus ? 'true' : 'false',
|
|
514
499
|
onKeyDown: this.handleKeyDown
|
|
515
|
-
}, this.props.children)), !this.props.trapFocus && React.createElement("div", {
|
|
500
|
+
}, this.props.children)), !this.props.trapFocus && /*#__PURE__*/React.createElement("div", {
|
|
516
501
|
id: this.popoverContainerId,
|
|
517
502
|
ref: this.popoverContentRef,
|
|
518
503
|
style: _extends({
|
|
@@ -527,25 +512,24 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
527
512
|
}, this.props.children));
|
|
528
513
|
}
|
|
529
514
|
}]);
|
|
530
|
-
return PopoverContainer;
|
|
531
515
|
}(React.Component);
|
|
532
516
|
PopoverContainer.defaultProps = {
|
|
533
517
|
trackScroll: true
|
|
534
518
|
};
|
|
535
519
|
|
|
536
520
|
var PositioningTarget = /*#__PURE__*/function (_React$Component) {
|
|
537
|
-
_inherits(PositioningTarget, _React$Component);
|
|
538
521
|
function PositioningTarget() {
|
|
539
522
|
var _this;
|
|
540
523
|
_classCallCheck(this, PositioningTarget);
|
|
541
|
-
_this =
|
|
524
|
+
_this = _callSuper(this, PositioningTarget, arguments);
|
|
542
525
|
_this.state = {
|
|
543
526
|
target: null
|
|
544
527
|
};
|
|
545
|
-
_this.targetRef = React.createRef();
|
|
528
|
+
_this.targetRef = /*#__PURE__*/React.createRef();
|
|
546
529
|
return _this;
|
|
547
530
|
}
|
|
548
|
-
|
|
531
|
+
_inherits(PositioningTarget, _React$Component);
|
|
532
|
+
return _createClass(PositioningTarget, [{
|
|
549
533
|
key: "componentDidMount",
|
|
550
534
|
value: function componentDidMount() {
|
|
551
535
|
this.setState({
|
|
@@ -555,20 +539,18 @@ var PositioningTarget = /*#__PURE__*/function (_React$Component) {
|
|
|
555
539
|
}, {
|
|
556
540
|
key: "render",
|
|
557
541
|
value: function render() {
|
|
558
|
-
return React.createElement("div", {
|
|
542
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
559
543
|
ref: this.targetRef
|
|
560
544
|
}, this.props.children(this.state.target));
|
|
561
545
|
}
|
|
562
546
|
}]);
|
|
563
|
-
return PositioningTarget;
|
|
564
547
|
}(React.Component);
|
|
565
548
|
|
|
566
549
|
var BodyDomNode = /*#__PURE__*/function (_React$Component) {
|
|
567
|
-
_inherits(BodyDomNode, _React$Component);
|
|
568
550
|
function BodyDomNode() {
|
|
569
551
|
var _this;
|
|
570
552
|
_classCallCheck(this, BodyDomNode);
|
|
571
|
-
_this =
|
|
553
|
+
_this = _callSuper(this, BodyDomNode, arguments);
|
|
572
554
|
_this.state = {
|
|
573
555
|
node: null
|
|
574
556
|
};
|
|
@@ -594,7 +576,8 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
|
|
|
594
576
|
};
|
|
595
577
|
return _this;
|
|
596
578
|
}
|
|
597
|
-
|
|
579
|
+
_inherits(BodyDomNode, _React$Component);
|
|
580
|
+
return _createClass(BodyDomNode, [{
|
|
598
581
|
key: "componentDidMount",
|
|
599
582
|
value: function componentDidMount() {
|
|
600
583
|
var node = document.createElement('div');
|
|
@@ -625,30 +608,29 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
|
|
|
625
608
|
return this.props.children(this.state.node);
|
|
626
609
|
}
|
|
627
610
|
}]);
|
|
628
|
-
return BodyDomNode;
|
|
629
611
|
}(React.Component);
|
|
630
612
|
BodyDomNode.defaultProps = {
|
|
631
613
|
containerElement: document.body
|
|
632
614
|
};
|
|
633
615
|
|
|
634
616
|
var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
635
|
-
_inherits(StatelessPopover, _React$Component);
|
|
636
617
|
function StatelessPopover() {
|
|
637
618
|
var _this;
|
|
638
619
|
_classCallCheck(this, StatelessPopover);
|
|
639
|
-
_this =
|
|
620
|
+
_this = _callSuper(this, StatelessPopover, arguments);
|
|
640
621
|
_this.getContainer = function () {
|
|
641
622
|
return _this.props.getContainerElement && _this.props.getContainerElement() || document.body;
|
|
642
623
|
};
|
|
643
624
|
return _this;
|
|
644
625
|
}
|
|
645
|
-
|
|
626
|
+
_inherits(StatelessPopover, _React$Component);
|
|
627
|
+
return _createClass(StatelessPopover, [{
|
|
646
628
|
key: "renderPortalContent",
|
|
647
629
|
value: function renderPortalContent(_ref) {
|
|
648
630
|
var props = _ref.props,
|
|
649
631
|
container = _ref.container,
|
|
650
632
|
positioningTarget = _ref.positioningTarget;
|
|
651
|
-
var popoverContent = React.createElement(PopoverContainer, {
|
|
633
|
+
var popoverContent = /*#__PURE__*/React.createElement(PopoverContainer, {
|
|
652
634
|
key: "popover-portal",
|
|
653
635
|
getPopoverPosition: this.props.getPopoverPosition,
|
|
654
636
|
relativeToParent: props.inline,
|
|
@@ -663,7 +645,7 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
663
645
|
trapFocus: this.props.trapFocus,
|
|
664
646
|
onEscapeAction: this.props.onEscapeAction
|
|
665
647
|
}, props.body);
|
|
666
|
-
return ReactDOM.createPortal(popoverContent, container);
|
|
648
|
+
return /*#__PURE__*/ReactDOM.createPortal(popoverContent, container);
|
|
667
649
|
}
|
|
668
650
|
}, {
|
|
669
651
|
key: "renderPortal",
|
|
@@ -673,7 +655,7 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
673
655
|
return null;
|
|
674
656
|
}
|
|
675
657
|
var containerElement = this.props.inline ? positioningTarget : this.getContainer();
|
|
676
|
-
return React.createElement(BodyDomNode, {
|
|
658
|
+
return /*#__PURE__*/React.createElement(BodyDomNode, {
|
|
677
659
|
onOuterAction: this.props.onOuterAction,
|
|
678
660
|
outerActionEvents: this.props.outerActionEvents,
|
|
679
661
|
positioningTarget: positioningTarget,
|
|
@@ -690,20 +672,18 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
690
672
|
key: "render",
|
|
691
673
|
value: function render() {
|
|
692
674
|
var _this3 = this;
|
|
693
|
-
return React.createElement(PositioningTarget, null, function (positioningTarget) {
|
|
694
|
-
return positioningTarget ? React.createElement(React.Fragment, null, _this3.props.children, _this3.renderPortal(positioningTarget)) : null;
|
|
675
|
+
return /*#__PURE__*/React.createElement(PositioningTarget, null, function (positioningTarget) {
|
|
676
|
+
return positioningTarget ? /*#__PURE__*/React.createElement(React.Fragment, null, _this3.props.children, _this3.renderPortal(positioningTarget)) : null;
|
|
695
677
|
});
|
|
696
678
|
}
|
|
697
679
|
}]);
|
|
698
|
-
return StatelessPopover;
|
|
699
680
|
}(React.Component);
|
|
700
681
|
|
|
701
682
|
var Popover = /*#__PURE__*/function (_React$Component) {
|
|
702
|
-
_inherits(Popover, _React$Component);
|
|
703
683
|
function Popover() {
|
|
704
684
|
var _this;
|
|
705
685
|
_classCallCheck(this, Popover);
|
|
706
|
-
_this =
|
|
686
|
+
_this = _callSuper(this, Popover, arguments);
|
|
707
687
|
_this.state = {
|
|
708
688
|
isOpen: false
|
|
709
689
|
};
|
|
@@ -730,7 +710,8 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
730
710
|
};
|
|
731
711
|
return _this;
|
|
732
712
|
}
|
|
733
|
-
|
|
713
|
+
_inherits(Popover, _React$Component);
|
|
714
|
+
return _createClass(Popover, [{
|
|
734
715
|
key: "render",
|
|
735
716
|
value: function render() {
|
|
736
717
|
var _this2 = this;
|
|
@@ -741,7 +722,7 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
741
722
|
ref: this.childrenRef
|
|
742
723
|
}) : this.props.children;
|
|
743
724
|
var childrenWithRef = React.Children.map(children, function (child) {
|
|
744
|
-
return React.cloneElement(child, {
|
|
725
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
745
726
|
ref: function ref(current) {
|
|
746
727
|
_this2.childrenRef = current;
|
|
747
728
|
if (typeof child.ref === 'function') {
|
|
@@ -753,7 +734,7 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
753
734
|
});
|
|
754
735
|
});
|
|
755
736
|
this.childrenRef = null;
|
|
756
|
-
return React.createElement(StatelessPopover,
|
|
737
|
+
return /*#__PURE__*/React.createElement(StatelessPopover, _extends({}, this.props, {
|
|
757
738
|
onOuterAction: this.onOuterAction,
|
|
758
739
|
onEscapeAction: this.onEscapeAction,
|
|
759
740
|
isOpen: isOpen,
|
|
@@ -762,7 +743,6 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
762
743
|
}), childrenWithRef);
|
|
763
744
|
}
|
|
764
745
|
}]);
|
|
765
|
-
return Popover;
|
|
766
746
|
}(React.Component);
|
|
767
747
|
Popover.Body = PopoverBody;
|
|
768
748
|
Popover.Position = PopoverPosition;
|
|
@@ -778,5 +758,4 @@ Popover.defaultProps = {
|
|
|
778
758
|
* © Copyright IBM Corp. 2024
|
|
779
759
|
*********************************************************************/
|
|
780
760
|
|
|
781
|
-
export default
|
|
782
|
-
export { Popover, PopoverBody, PopoverPosition };
|
|
761
|
+
export { Popover, PopoverBody, PopoverPosition, Popover as default };
|
package/dist/popover.js
CHANGED
|
@@ -2,106 +2,97 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var React = _interopDefault(require('react'));
|
|
5
|
+
var React = require('react');
|
|
8
6
|
var globalConstants = require('@targetprocess/global-constants');
|
|
9
|
-
var classNames =
|
|
10
|
-
var ReactDOM =
|
|
11
|
-
var FocusTrap =
|
|
7
|
+
var classNames = require('classnames');
|
|
8
|
+
var ReactDOM = require('react-dom');
|
|
9
|
+
var FocusTrap = require('focus-trap-react');
|
|
12
10
|
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
14
|
+
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);
|
|
15
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefaultCompat(ReactDOM);
|
|
16
|
+
var FocusTrap__default = /*#__PURE__*/_interopDefaultCompat(FocusTrap);
|
|
17
|
+
|
|
18
|
+
function _assertThisInitialized(e) {
|
|
19
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
20
|
+
return e;
|
|
17
21
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
function _callSuper(t, o, e) {
|
|
23
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
24
|
+
}
|
|
25
|
+
function _classCallCheck(a, n) {
|
|
26
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
27
|
+
}
|
|
28
|
+
function _defineProperties(e, r) {
|
|
29
|
+
for (var t = 0; t < r.length; t++) {
|
|
30
|
+
var o = r[t];
|
|
31
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
|
-
function _createClass(
|
|
28
|
-
|
|
29
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
30
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
34
|
+
function _createClass(e, r, t) {
|
|
35
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
31
36
|
writable: false
|
|
32
|
-
});
|
|
33
|
-
return Constructor;
|
|
37
|
+
}), e;
|
|
34
38
|
}
|
|
35
39
|
function _extends() {
|
|
36
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
37
|
-
for (var
|
|
38
|
-
var
|
|
39
|
-
for (var
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
41
|
-
target[key] = source[key];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
40
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
41
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
42
|
+
var t = arguments[e];
|
|
43
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
44
44
|
}
|
|
45
|
-
return
|
|
46
|
-
};
|
|
47
|
-
return _extends.apply(this, arguments);
|
|
45
|
+
return n;
|
|
46
|
+
}, _extends.apply(null, arguments);
|
|
48
47
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
48
|
+
function _getPrototypeOf(t) {
|
|
49
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
50
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
51
|
+
}, _getPrototypeOf(t);
|
|
52
|
+
}
|
|
53
|
+
function _inherits(t, e) {
|
|
54
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
55
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
54
56
|
constructor: {
|
|
55
|
-
value:
|
|
57
|
+
value: t,
|
|
56
58
|
writable: true,
|
|
57
59
|
configurable: true
|
|
58
60
|
}
|
|
59
|
-
})
|
|
60
|
-
Object.defineProperty(subClass, "prototype", {
|
|
61
|
+
}), Object.defineProperty(t, "prototype", {
|
|
61
62
|
writable: false
|
|
62
|
-
});
|
|
63
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
64
|
-
}
|
|
65
|
-
function _getPrototypeOf(o) {
|
|
66
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
67
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
68
|
-
};
|
|
69
|
-
return _getPrototypeOf(o);
|
|
63
|
+
}), e && _setPrototypeOf(t, e);
|
|
70
64
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
function _isNativeReflectConstruct() {
|
|
66
|
+
try {
|
|
67
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
68
|
+
} catch (t) {}
|
|
69
|
+
return (_isNativeReflectConstruct = function () {
|
|
70
|
+
return !!t;
|
|
71
|
+
})();
|
|
77
72
|
}
|
|
78
|
-
function
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return self;
|
|
73
|
+
function _possibleConstructorReturn(t, e) {
|
|
74
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
75
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
76
|
+
return _assertThisInitialized(t);
|
|
83
77
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
89
|
-
}
|
|
90
|
-
return _assertThisInitialized(self);
|
|
78
|
+
function _setPrototypeOf(t, e) {
|
|
79
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
80
|
+
return t.__proto__ = e, t;
|
|
81
|
+
}, _setPrototypeOf(t, e);
|
|
91
82
|
}
|
|
92
|
-
function _toPrimitive(
|
|
93
|
-
if (
|
|
94
|
-
var
|
|
95
|
-
if (
|
|
96
|
-
var
|
|
97
|
-
if (
|
|
83
|
+
function _toPrimitive(t, e) {
|
|
84
|
+
if ("object" != typeof t || !t) return t;
|
|
85
|
+
var r;
|
|
86
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
87
|
+
var i = r.call(t, e);
|
|
88
|
+
if ("object" != typeof i) return i;
|
|
98
89
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
99
90
|
}
|
|
100
|
-
return (
|
|
91
|
+
return (String )(t);
|
|
101
92
|
}
|
|
102
|
-
function _toPropertyKey(
|
|
103
|
-
var
|
|
104
|
-
return
|
|
93
|
+
function _toPropertyKey(t) {
|
|
94
|
+
var i = _toPrimitive(t, "string");
|
|
95
|
+
return "symbol" == typeof i ? i : i + "";
|
|
105
96
|
}
|
|
106
97
|
|
|
107
98
|
/*********************************************************************
|
|
@@ -192,7 +183,7 @@ function styleInject(css, ref) {
|
|
|
192
183
|
if ( ref === void 0 ) ref = {};
|
|
193
184
|
var insertAt = ref.insertAt;
|
|
194
185
|
|
|
195
|
-
if (
|
|
186
|
+
if (typeof document === 'undefined') { return; }
|
|
196
187
|
|
|
197
188
|
var head = document.head || document.getElementsByTagName('head')[0];
|
|
198
189
|
var style = document.createElement('style');
|
|
@@ -215,9 +206,9 @@ function styleInject(css, ref) {
|
|
|
215
206
|
}
|
|
216
207
|
}
|
|
217
208
|
|
|
218
|
-
var
|
|
219
|
-
var styles = {"popover-body-container":"popover-body-container__popover__12-32-2","popover-body":"popover-body__popover__12-32-2","popover-body--no-padding":"popover-body--no-padding__popover__12-32-2","popover-tip":"popover-tip__popover__12-32-2","popover-tip--bottom":"popover-tip--bottom__popover__12-32-2","popover-tip--top":"popover-tip--top__popover__12-32-2","popover-tip--left":"popover-tip--left__popover__12-32-2","popover-tip--right":"popover-tip--right__popover__12-32-2"};
|
|
220
|
-
styleInject(
|
|
209
|
+
var css_248z = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n\n.popover-body-container__popover__12-32-3-ci-2 {\n -webkit-box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n box-shadow: var(--BoxShadowL, 0 4px 16px 0 rgba(0, 0, 0, 0.12));\n border-radius: var(--BorderRadiusL, 4px);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n background: var(--BackgroundDefault, #FFFFFF);\n z-index: var(--ZIndexModal, 10001);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n\n.popover-body__popover__12-32-3-ci-2 {\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n padding: var(--SpaceSM, 12px);\n font-size: var(--FontSizeDefault, 13px);\n color: var(--FontColorDefault, #000000);\n}\n\n.popover-body--no-padding__popover__12-32-3-ci-2 {\n padding: 0;\n }\n\n.popover-tip__popover__12-32-3-ci-2 {\n position: absolute;\n pointer-events: none;\n z-index: calc(1 + var(--ZIndexModal, 10001));\n overflow: hidden;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -ms-flex-pack: center;\n justify-content: center;\n\n /*\n To determine tip position, we need to rotate it\n along the \"tip\" point, after that, the \"tip\" point\n can be placed with exactly 50% offset from the origin\n so that it is centered.\n */\n}\n\n.popover-tip__popover__12-32-3-ci-2:before {\n content: '';\n position: absolute;\n display: block;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n background-color: var(--BackgroundDefault, #FFFFFF);\n border: 1px solid var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n /*\n geometry FTW\n\n 2*$popoverTipSize\n _______ _______\n | /|\\ |\n | / | \\ | $popoverTipSize\n | / | \\ |\n |/______|______\\|\n since tip is rotated 45 degrees, its width and height is a\n diagonal of a square with side=$popoverTipSize, thus diagonal\n is sqrt(2) * $popoverTipSize.\n sqrt(2) ~= 1.414, 1.4 used here to prevent too much rounding\n */\n width: calc(11.2px);\n height: calc(11.2px);\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n\n.popover-tip--bottom__popover__12-32-3-ci-2,\n .popover-tip--top__popover__12-32-3-ci-2 {\n width: 100%;\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\n height: calc(9px);\n }\n\n.popover-tip--left__popover__12-32-3-ci-2,\n .popover-tip--right__popover__12-32-3-ci-2 {\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\n height: 100%;\n width: calc(9px);\n }\n\n.popover-tip--bottom__popover__12-32-3-ci-2:before {\n -webkit-transform-origin: left top;\n transform-origin: left top;\n left: 50%;\n top: 0;\n }\n\n.popover-tip--top__popover__12-32-3-ci-2:before {\n -webkit-transform-origin: right bottom;\n transform-origin: right bottom;\n right: 50%;\n bottom: 0;\n }\n\n.popover-tip--left__popover__12-32-3-ci-2:before {\n -webkit-transform-origin: right top;\n transform-origin: right top;\n right: 0;\n top: 50%;\n }\n\n.popover-tip--right__popover__12-32-3-ci-2:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
|
|
210
|
+
var styles = {"popover-body-container":"popover-body-container__popover__12-32-3-ci-2","popover-body":"popover-body__popover__12-32-3-ci-2","popover-body--no-padding":"popover-body--no-padding__popover__12-32-3-ci-2","popover-tip":"popover-tip__popover__12-32-3-ci-2","popover-tip--bottom":"popover-tip--bottom__popover__12-32-3-ci-2","popover-tip--top":"popover-tip--top__popover__12-32-3-ci-2","popover-tip--left":"popover-tip--left__popover__12-32-3-ci-2","popover-tip--right":"popover-tip--right__popover__12-32-3-ci-2"};
|
|
211
|
+
styleInject(css_248z);
|
|
221
212
|
|
|
222
213
|
/*********************************************************************
|
|
223
214
|
* © Copyright IBM Corp. 2024
|
|
@@ -227,10 +218,10 @@ var PopoverBody = function PopoverBody(_ref) {
|
|
|
227
218
|
className = _ref.className,
|
|
228
219
|
classNameBody = _ref.classNameBody,
|
|
229
220
|
noPadding = _ref.noPadding;
|
|
230
|
-
return
|
|
231
|
-
className:
|
|
232
|
-
},
|
|
233
|
-
className:
|
|
221
|
+
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
222
|
+
className: classNames__default.default(className, styles['popover-body-container'])
|
|
223
|
+
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
224
|
+
className: classNames__default.default(classNameBody, styles['popover-body'], noPadding && styles['popover-body--no-padding'])
|
|
234
225
|
}, children));
|
|
235
226
|
};
|
|
236
227
|
|
|
@@ -295,11 +286,10 @@ var attemptFocus = function attemptFocus(element) {
|
|
|
295
286
|
element.focus();
|
|
296
287
|
return document.activeElement === element;
|
|
297
288
|
};
|
|
298
|
-
var
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (attemptFocus(child) || focusFirstDescendant(child)) {
|
|
289
|
+
var _focusFirstDescendant = function focusFirstDescendant(element) {
|
|
290
|
+
for (var _i = 0, _Array$from = Array.from(element.childNodes); _i < _Array$from.length; _i++) {
|
|
291
|
+
var child = _Array$from[_i];
|
|
292
|
+
if (attemptFocus(child) || _focusFirstDescendant(child)) {
|
|
303
293
|
return true;
|
|
304
294
|
}
|
|
305
295
|
}
|
|
@@ -354,13 +344,12 @@ var getCompositeRect = function getCompositeRect(elementOrVirtualElement, offset
|
|
|
354
344
|
};
|
|
355
345
|
};
|
|
356
346
|
var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
357
|
-
_inherits(PopoverContainer, _React$Component);
|
|
358
347
|
function PopoverContainer() {
|
|
359
348
|
var _this;
|
|
360
349
|
_classCallCheck(this, PopoverContainer);
|
|
361
|
-
_this =
|
|
350
|
+
_this = _callSuper(this, PopoverContainer, arguments);
|
|
362
351
|
_this.mounted = false;
|
|
363
|
-
_this.popoverContentRef =
|
|
352
|
+
_this.popoverContentRef = /*#__PURE__*/React__default.default.createRef();
|
|
364
353
|
_this.state = {
|
|
365
354
|
adjusted: false,
|
|
366
355
|
positionX: 0,
|
|
@@ -396,7 +385,8 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
396
385
|
};
|
|
397
386
|
return _this;
|
|
398
387
|
}
|
|
399
|
-
|
|
388
|
+
_inherits(PopoverContainer, _React$Component);
|
|
389
|
+
return _createClass(PopoverContainer, [{
|
|
400
390
|
key: "adjustPosition",
|
|
401
391
|
value: function adjustPosition() {
|
|
402
392
|
var _this2 = this;
|
|
@@ -444,7 +434,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
444
434
|
}
|
|
445
435
|
}
|
|
446
436
|
if (this.popoverContentRef.current && !this.props.trapFocus) {
|
|
447
|
-
if (!
|
|
437
|
+
if (!_focusFirstDescendant(this.popoverContentRef.current)) {
|
|
448
438
|
this.popoverContentRef.current.tabIndex = -1;
|
|
449
439
|
this.popoverContentRef.current.focus();
|
|
450
440
|
}
|
|
@@ -482,7 +472,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
482
472
|
};
|
|
483
473
|
var tipPosition = this.getPopoverTipPosition(position, containerPosition);
|
|
484
474
|
// FIXME: position.top cast to number, because value may be not a number
|
|
485
|
-
return
|
|
475
|
+
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
486
476
|
style: _extends({
|
|
487
477
|
position: 'absolute'
|
|
488
478
|
}, containerPosition, {
|
|
@@ -492,21 +482,21 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
492
482
|
transitionProperty: 'opacity',
|
|
493
483
|
opacity: this.state.adjusted ? 1 : 0
|
|
494
484
|
})
|
|
495
|
-
}, this.props.showTip && tipPosition &&
|
|
496
|
-
className:
|
|
485
|
+
}, this.props.showTip && tipPosition && /*#__PURE__*/React__default.default.createElement("div", {
|
|
486
|
+
className: classNames__default.default(styles['popover-tip'], styles["popover-tip--".concat(tipPosition)], 'popover-tip', this.props.classNameTip),
|
|
497
487
|
style: {
|
|
498
488
|
top: tipPosition === 'bottom' && position.top - 8,
|
|
499
489
|
bottom: tipPosition === 'top' && position.bottom - 8,
|
|
500
490
|
left: tipPosition === 'right' && position.left - 8,
|
|
501
491
|
right: tipPosition === 'left' && position.right - 8
|
|
502
492
|
}
|
|
503
|
-
}), this.props.trapFocus &&
|
|
493
|
+
}), this.props.trapFocus && /*#__PURE__*/React__default.default.createElement(FocusTrap__default.default, {
|
|
504
494
|
focusTrapOptions: {
|
|
505
495
|
fallbackFocus: "#".concat(this.popoverContainerId),
|
|
506
496
|
clickOutsideDeactivates: true,
|
|
507
497
|
trapStack: window.__globalTrapStack
|
|
508
498
|
}
|
|
509
|
-
},
|
|
499
|
+
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
510
500
|
id: this.popoverContainerId,
|
|
511
501
|
ref: this.popoverContentRef,
|
|
512
502
|
style: _extends({
|
|
@@ -518,7 +508,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
518
508
|
role: this.props.role,
|
|
519
509
|
"aria-modal": this.props.trapFocus ? 'true' : 'false',
|
|
520
510
|
onKeyDown: this.handleKeyDown
|
|
521
|
-
}, this.props.children)), !this.props.trapFocus &&
|
|
511
|
+
}, this.props.children)), !this.props.trapFocus && /*#__PURE__*/React__default.default.createElement("div", {
|
|
522
512
|
id: this.popoverContainerId,
|
|
523
513
|
ref: this.popoverContentRef,
|
|
524
514
|
style: _extends({
|
|
@@ -533,25 +523,24 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
533
523
|
}, this.props.children));
|
|
534
524
|
}
|
|
535
525
|
}]);
|
|
536
|
-
|
|
537
|
-
}(React.Component);
|
|
526
|
+
}(React__default.default.Component);
|
|
538
527
|
PopoverContainer.defaultProps = {
|
|
539
528
|
trackScroll: true
|
|
540
529
|
};
|
|
541
530
|
|
|
542
531
|
var PositioningTarget = /*#__PURE__*/function (_React$Component) {
|
|
543
|
-
_inherits(PositioningTarget, _React$Component);
|
|
544
532
|
function PositioningTarget() {
|
|
545
533
|
var _this;
|
|
546
534
|
_classCallCheck(this, PositioningTarget);
|
|
547
|
-
_this =
|
|
535
|
+
_this = _callSuper(this, PositioningTarget, arguments);
|
|
548
536
|
_this.state = {
|
|
549
537
|
target: null
|
|
550
538
|
};
|
|
551
|
-
_this.targetRef =
|
|
539
|
+
_this.targetRef = /*#__PURE__*/React__default.default.createRef();
|
|
552
540
|
return _this;
|
|
553
541
|
}
|
|
554
|
-
|
|
542
|
+
_inherits(PositioningTarget, _React$Component);
|
|
543
|
+
return _createClass(PositioningTarget, [{
|
|
555
544
|
key: "componentDidMount",
|
|
556
545
|
value: function componentDidMount() {
|
|
557
546
|
this.setState({
|
|
@@ -561,20 +550,18 @@ var PositioningTarget = /*#__PURE__*/function (_React$Component) {
|
|
|
561
550
|
}, {
|
|
562
551
|
key: "render",
|
|
563
552
|
value: function render() {
|
|
564
|
-
return
|
|
553
|
+
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
565
554
|
ref: this.targetRef
|
|
566
555
|
}, this.props.children(this.state.target));
|
|
567
556
|
}
|
|
568
557
|
}]);
|
|
569
|
-
|
|
570
|
-
}(React.Component);
|
|
558
|
+
}(React__default.default.Component);
|
|
571
559
|
|
|
572
560
|
var BodyDomNode = /*#__PURE__*/function (_React$Component) {
|
|
573
|
-
_inherits(BodyDomNode, _React$Component);
|
|
574
561
|
function BodyDomNode() {
|
|
575
562
|
var _this;
|
|
576
563
|
_classCallCheck(this, BodyDomNode);
|
|
577
|
-
_this =
|
|
564
|
+
_this = _callSuper(this, BodyDomNode, arguments);
|
|
578
565
|
_this.state = {
|
|
579
566
|
node: null
|
|
580
567
|
};
|
|
@@ -600,7 +587,8 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
|
|
|
600
587
|
};
|
|
601
588
|
return _this;
|
|
602
589
|
}
|
|
603
|
-
|
|
590
|
+
_inherits(BodyDomNode, _React$Component);
|
|
591
|
+
return _createClass(BodyDomNode, [{
|
|
604
592
|
key: "componentDidMount",
|
|
605
593
|
value: function componentDidMount() {
|
|
606
594
|
var node = document.createElement('div');
|
|
@@ -631,30 +619,29 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
|
|
|
631
619
|
return this.props.children(this.state.node);
|
|
632
620
|
}
|
|
633
621
|
}]);
|
|
634
|
-
|
|
635
|
-
}(React.Component);
|
|
622
|
+
}(React__default.default.Component);
|
|
636
623
|
BodyDomNode.defaultProps = {
|
|
637
624
|
containerElement: document.body
|
|
638
625
|
};
|
|
639
626
|
|
|
640
627
|
var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
641
|
-
_inherits(StatelessPopover, _React$Component);
|
|
642
628
|
function StatelessPopover() {
|
|
643
629
|
var _this;
|
|
644
630
|
_classCallCheck(this, StatelessPopover);
|
|
645
|
-
_this =
|
|
631
|
+
_this = _callSuper(this, StatelessPopover, arguments);
|
|
646
632
|
_this.getContainer = function () {
|
|
647
633
|
return _this.props.getContainerElement && _this.props.getContainerElement() || document.body;
|
|
648
634
|
};
|
|
649
635
|
return _this;
|
|
650
636
|
}
|
|
651
|
-
|
|
637
|
+
_inherits(StatelessPopover, _React$Component);
|
|
638
|
+
return _createClass(StatelessPopover, [{
|
|
652
639
|
key: "renderPortalContent",
|
|
653
640
|
value: function renderPortalContent(_ref) {
|
|
654
641
|
var props = _ref.props,
|
|
655
642
|
container = _ref.container,
|
|
656
643
|
positioningTarget = _ref.positioningTarget;
|
|
657
|
-
var popoverContent =
|
|
644
|
+
var popoverContent = /*#__PURE__*/React__default.default.createElement(PopoverContainer, {
|
|
658
645
|
key: "popover-portal",
|
|
659
646
|
getPopoverPosition: this.props.getPopoverPosition,
|
|
660
647
|
relativeToParent: props.inline,
|
|
@@ -669,7 +656,7 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
669
656
|
trapFocus: this.props.trapFocus,
|
|
670
657
|
onEscapeAction: this.props.onEscapeAction
|
|
671
658
|
}, props.body);
|
|
672
|
-
return
|
|
659
|
+
return /*#__PURE__*/ReactDOM__default.default.createPortal(popoverContent, container);
|
|
673
660
|
}
|
|
674
661
|
}, {
|
|
675
662
|
key: "renderPortal",
|
|
@@ -679,7 +666,7 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
679
666
|
return null;
|
|
680
667
|
}
|
|
681
668
|
var containerElement = this.props.inline ? positioningTarget : this.getContainer();
|
|
682
|
-
return
|
|
669
|
+
return /*#__PURE__*/React__default.default.createElement(BodyDomNode, {
|
|
683
670
|
onOuterAction: this.props.onOuterAction,
|
|
684
671
|
outerActionEvents: this.props.outerActionEvents,
|
|
685
672
|
positioningTarget: positioningTarget,
|
|
@@ -696,20 +683,18 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
696
683
|
key: "render",
|
|
697
684
|
value: function render() {
|
|
698
685
|
var _this3 = this;
|
|
699
|
-
return
|
|
700
|
-
return positioningTarget ?
|
|
686
|
+
return /*#__PURE__*/React__default.default.createElement(PositioningTarget, null, function (positioningTarget) {
|
|
687
|
+
return positioningTarget ? /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, _this3.props.children, _this3.renderPortal(positioningTarget)) : null;
|
|
701
688
|
});
|
|
702
689
|
}
|
|
703
690
|
}]);
|
|
704
|
-
|
|
705
|
-
}(React.Component);
|
|
691
|
+
}(React__default.default.Component);
|
|
706
692
|
|
|
707
693
|
var Popover = /*#__PURE__*/function (_React$Component) {
|
|
708
|
-
_inherits(Popover, _React$Component);
|
|
709
694
|
function Popover() {
|
|
710
695
|
var _this;
|
|
711
696
|
_classCallCheck(this, Popover);
|
|
712
|
-
_this =
|
|
697
|
+
_this = _callSuper(this, Popover, arguments);
|
|
713
698
|
_this.state = {
|
|
714
699
|
isOpen: false
|
|
715
700
|
};
|
|
@@ -736,7 +721,8 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
736
721
|
};
|
|
737
722
|
return _this;
|
|
738
723
|
}
|
|
739
|
-
|
|
724
|
+
_inherits(Popover, _React$Component);
|
|
725
|
+
return _createClass(Popover, [{
|
|
740
726
|
key: "render",
|
|
741
727
|
value: function render() {
|
|
742
728
|
var _this2 = this;
|
|
@@ -746,8 +732,8 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
746
732
|
setOpened: this.setOpened,
|
|
747
733
|
ref: this.childrenRef
|
|
748
734
|
}) : this.props.children;
|
|
749
|
-
var childrenWithRef =
|
|
750
|
-
return
|
|
735
|
+
var childrenWithRef = React__default.default.Children.map(children, function (child) {
|
|
736
|
+
return /*#__PURE__*/React__default.default.cloneElement(child, {
|
|
751
737
|
ref: function ref(current) {
|
|
752
738
|
_this2.childrenRef = current;
|
|
753
739
|
if (typeof child.ref === 'function') {
|
|
@@ -759,7 +745,7 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
759
745
|
});
|
|
760
746
|
});
|
|
761
747
|
this.childrenRef = null;
|
|
762
|
-
return
|
|
748
|
+
return /*#__PURE__*/React__default.default.createElement(StatelessPopover, _extends({}, this.props, {
|
|
763
749
|
onOuterAction: this.onOuterAction,
|
|
764
750
|
onEscapeAction: this.onEscapeAction,
|
|
765
751
|
isOpen: isOpen,
|
|
@@ -768,8 +754,7 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
768
754
|
}), childrenWithRef);
|
|
769
755
|
}
|
|
770
756
|
}]);
|
|
771
|
-
|
|
772
|
-
}(React.Component);
|
|
757
|
+
}(React__default.default.Component);
|
|
773
758
|
Popover.Body = PopoverBody;
|
|
774
759
|
Popover.Position = PopoverPosition;
|
|
775
760
|
Popover.defaultProps = {
|
package/dist/types.d.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
* © Copyright IBM Corp. 2024
|
|
3
3
|
*********************************************************************/
|
|
4
4
|
import { CSSProperties } from 'react';
|
|
5
|
-
export
|
|
5
|
+
export type PositionParams = {
|
|
6
6
|
left: number;
|
|
7
7
|
top: number;
|
|
8
8
|
right?: number;
|
|
9
9
|
bottom?: number;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type DimensionParams = {
|
|
12
12
|
height: number;
|
|
13
13
|
width: number;
|
|
14
14
|
};
|
|
15
|
-
export
|
|
16
|
-
export
|
|
15
|
+
export type GetPopoverPositionCallback = (hostRect: DimensionParams, popoverRect: DimensionParams, containerScroll: PositionParams, containerElement?: HTMLElement) => CSSProperties;
|
|
16
|
+
export type DefaultPopoverPositions = {
|
|
17
17
|
bottomLeft: GetPopoverPositionCallback;
|
|
18
18
|
bottom: GetPopoverPositionCallback;
|
|
19
19
|
bottomRight: GetPopoverPositionCallback;
|
|
@@ -27,4 +27,4 @@ export declare type DefaultPopoverPositions = {
|
|
|
27
27
|
right: GetPopoverPositionCallback;
|
|
28
28
|
rightBottom: GetPopoverPositionCallback;
|
|
29
29
|
};
|
|
30
|
-
export
|
|
30
|
+
export type GetPopoverPositionType = GetPopoverPositionCallback | keyof DefaultPopoverPositions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@targetprocess/popover",
|
|
3
|
-
"version": "12.32.2",
|
|
3
|
+
"version": "12.32.3-ci.2",
|
|
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.32.2",
|
|
15
|
+
"@targetprocess/global-constants": "^12.32.3-ci.2",
|
|
16
16
|
"classnames": "^2.2.5",
|
|
17
17
|
"focus-trap-react": "^10.3.0",
|
|
18
18
|
"prop-types": "^15.6.0",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "97a2147da1774427ce1349a0ad34a47342458d76"
|
|
26
26
|
}
|