@targetprocess/popover 12.20.1-alpha.4 → 12.20.2-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/BodyDomNode.tsx +79 -76
- package/CHANGELOG.md +22 -22
- package/Popover.tsx +191 -188
- package/PopoverBody.tsx +40 -37
- package/PopoverContainer.tsx +325 -322
- package/PopoverPosition.ts +62 -59
- package/PositioningTarget.tsx +29 -26
- package/StatlessPopover.tsx +98 -101
- package/__tests__/BodyDomNode.tests.tsx +287 -284
- package/__tests__/Popover.tests.tsx +66 -63
- package/__tests__/PositioningTarget.tests.tsx +46 -43
- package/dist/BodyDomNode.d.ts +3 -0
- package/dist/Popover.d.ts +3 -0
- package/dist/PopoverBody.d.ts +3 -0
- package/dist/PopoverContainer.d.ts +3 -0
- package/dist/PositioningTarget.d.ts +3 -0
- package/dist/StatlessPopover.d.ts +4 -1
- package/dist/index.d.ts +3 -0
- package/dist/popover.es.js +22 -11
- package/dist/popover.js +22 -11
- package/dist/types.d.ts +3 -0
- package/index.ts +17 -14
- package/package.json +3 -3
- package/style/index.css +107 -104
- package/types.ts +40 -37
|
@@ -1,63 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
expect(
|
|
61
|
-
expect(onOuterAction.
|
|
62
|
-
|
|
63
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
/* eslint-env jest */
|
|
5
|
+
import React from 'react'
|
|
6
|
+
import {mount} from 'enzyme'
|
|
7
|
+
import {Popover, PopoverProps, PopoverState} from '../Popover'
|
|
8
|
+
import {PopoverBody} from '../PopoverBody'
|
|
9
|
+
import {cleanDocumentBody} from '../../../testUtils/domUtils'
|
|
10
|
+
|
|
11
|
+
jest.mock('focus-trap', () => {
|
|
12
|
+
const trap = {
|
|
13
|
+
activate: () => trap,
|
|
14
|
+
deactivate: () => trap,
|
|
15
|
+
pause: () => {},
|
|
16
|
+
unpause: () => {}
|
|
17
|
+
}
|
|
18
|
+
return () => trap
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('Popover', () => {
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
cleanDocumentBody()
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should render only its children by default', () => {
|
|
27
|
+
const wrapper = mount(
|
|
28
|
+
<Popover getPopoverPosition="bottomLeft">
|
|
29
|
+
<div className="foo" />
|
|
30
|
+
</Popover>
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
expect(wrapper.find('.foo')).toHaveLength(1)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should support render prop as child', () => {
|
|
37
|
+
const wrapper = mount<Popover, PopoverProps, PopoverState>(
|
|
38
|
+
<Popover>{({isOpen, setOpened}) => <button onClick={() => setOpened(!isOpen)} />}</Popover>
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
expect(wrapper.state().isOpen).toBe(false)
|
|
42
|
+
|
|
43
|
+
wrapper.find('button').simulate('click')
|
|
44
|
+
|
|
45
|
+
expect(wrapper.state().isOpen).toBe(true)
|
|
46
|
+
|
|
47
|
+
wrapper.find('button').simulate('click')
|
|
48
|
+
|
|
49
|
+
expect(wrapper.state().isOpen).toBe(false)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should pass event to onOuterAction callback', () => {
|
|
53
|
+
const onOuterAction = jest.fn()
|
|
54
|
+
|
|
55
|
+
mount(
|
|
56
|
+
<Popover isOpen onOuterAction={onOuterAction} body={<PopoverBody>foo</PopoverBody>}>
|
|
57
|
+
<button />
|
|
58
|
+
</Popover>
|
|
59
|
+
)
|
|
60
|
+
expect(document.querySelectorAll('.popover-body')).toHaveLength(1)
|
|
61
|
+
expect(onOuterAction).not.toHaveBeenCalled()
|
|
62
|
+
document.dispatchEvent(new MouseEvent('mousedown', {bubbles: true}))
|
|
63
|
+
expect(onOuterAction.mock.calls.length).toBe(1)
|
|
64
|
+
expect(onOuterAction.mock.calls[0][0].target).toBeDefined()
|
|
65
|
+
})
|
|
66
|
+
})
|
|
@@ -1,43 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
import React from 'react'
|
|
5
|
+
import {mount} from 'enzyme'
|
|
6
|
+
import {PositioningTarget} from '../PositioningTarget'
|
|
7
|
+
import {whenComponentDidMountCalled} from '../../../testUtils/componentLifecycleUtils'
|
|
8
|
+
|
|
9
|
+
const originalComponentDidMount = PositioningTarget.prototype.componentDidMount
|
|
10
|
+
|
|
11
|
+
const stubComponentDidMount = () => whenComponentDidMountCalled(PositioningTarget)
|
|
12
|
+
|
|
13
|
+
describe('PositioningTarget', () => {
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
PositioningTarget.prototype.componentDidMount = originalComponentDidMount
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('shoud call render prop with null initially', () => {
|
|
19
|
+
const renderProp = jest.fn(() => null)
|
|
20
|
+
|
|
21
|
+
mount(<PositioningTarget>{renderProp}</PositioningTarget>)
|
|
22
|
+
|
|
23
|
+
expect(renderProp).toHaveBeenCalled()
|
|
24
|
+
expect(renderProp.mock.calls[0][0]).toBeNull()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('should call render prop with div after component will be mounted', async () => {
|
|
28
|
+
const renderProp = jest.fn(() => null)
|
|
29
|
+
const componentDidMountCalled = stubComponentDidMount()
|
|
30
|
+
|
|
31
|
+
mount(<PositioningTarget>{renderProp}</PositioningTarget>)
|
|
32
|
+
|
|
33
|
+
await componentDidMountCalled
|
|
34
|
+
|
|
35
|
+
expect(renderProp).toHaveBeenCalledTimes(2)
|
|
36
|
+
expect(renderProp.mock.calls[1][0].tagName).toBe('DIV')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('should render element returned from rendr prop', () => {
|
|
40
|
+
const renderProp = () => <button>Test</button>
|
|
41
|
+
|
|
42
|
+
const wrapper = mount(<PositioningTarget>{renderProp}</PositioningTarget>)
|
|
43
|
+
|
|
44
|
+
expect(wrapper.find('button')).toHaveLength(1)
|
|
45
|
+
})
|
|
46
|
+
})
|
package/dist/BodyDomNode.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
export declare type BodyDomNodeProps = {
|
package/dist/Popover.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import { GetPopoverPositionType } from './types';
|
package/dist/PopoverBody.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
1
4
|
import React from 'react';
|
|
2
5
|
export declare type PopoverBodyProps = {
|
|
3
6
|
children?: React.ReactNode;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
import { DimensionParams, GetPopoverPositionType, PositionParams } from './types';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import PropTypes from 'prop-types';
|
|
3
6
|
export declare class PositioningTarget extends React.Component<{
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import { GetPopoverPositionType } from './types';
|
|
3
6
|
export declare type StatelessPopoverProps = {
|
|
@@ -21,7 +24,7 @@ export declare class StatelessPopover extends React.Component<StatelessPopoverPr
|
|
|
21
24
|
props: StatelessPopoverProps;
|
|
22
25
|
container?: HTMLElement;
|
|
23
26
|
positioningTarget: HTMLElement;
|
|
24
|
-
}):
|
|
27
|
+
}): React.ReactPortal;
|
|
25
28
|
getContainer: () => HTMLElement;
|
|
26
29
|
renderPortal(positioningTarget: HTMLElement): JSX.Element;
|
|
27
30
|
render(): JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
1
4
|
import { Popover, PopoverProps } from './Popover';
|
|
2
5
|
import { PopoverBody, PopoverBodyProps } from './PopoverBody';
|
|
3
6
|
import { GetPopoverPositionType } from './types';
|
package/dist/popover.es.js
CHANGED
|
@@ -98,6 +98,9 @@ function _toPropertyKey(arg) {
|
|
|
98
98
|
return typeof key === "symbol" ? key : String(key);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/*********************************************************************
|
|
102
|
+
* © Copyright IBM Corp. 2024
|
|
103
|
+
*********************************************************************/
|
|
101
104
|
var PopoverPosition = {
|
|
102
105
|
bottomLeft: function bottomLeft(hostRect, popoverRect, containerScroll) {
|
|
103
106
|
return {
|
|
@@ -206,10 +209,13 @@ function styleInject(css, ref) {
|
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
211
|
|
|
209
|
-
var css = ".popover-body-container__popover__12-20-
|
|
210
|
-
var styles = {"popover-body-container":"popover-body-container__popover__12-20-
|
|
212
|
+
var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body-container__popover__12-20-2-alpha-0 {\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.popover-body__popover__12-20-2-alpha-0 {\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.popover-body--no-padding__popover__12-20-2-alpha-0 {\n padding: 0;\n }\n.popover-tip__popover__12-20-2-alpha-0 {\n position: absolute;\n pointer-events: none;\n z-index: calc(var(--ZIndexModal, 10001) + 1);\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.popover-tip__popover__12-20-2-alpha-0: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: 11.2px;\n height: 11.2px;\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n.popover-tip--bottom__popover__12-20-2-alpha-0,\n .popover-tip--top__popover__12-20-2-alpha-0 {\n width: 100%;\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\n height: 9px;\n }\n.popover-tip--left__popover__12-20-2-alpha-0,\n .popover-tip--right__popover__12-20-2-alpha-0 {\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\n height: 100%;\n width: 9px;\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.popover-tip--bottom__popover__12-20-2-alpha-0:before {\n -webkit-transform-origin: left top;\n transform-origin: left top;\n left: 50%;\n top: 0;\n }\n.popover-tip--top__popover__12-20-2-alpha-0:before {\n -webkit-transform-origin: right bottom;\n transform-origin: right bottom;\n right: 50%;\n bottom: 0;\n }\n.popover-tip--left__popover__12-20-2-alpha-0:before {\n -webkit-transform-origin: right top;\n transform-origin: right top;\n right: 0;\n top: 50%;\n }\n.popover-tip--right__popover__12-20-2-alpha-0:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
|
|
213
|
+
var styles = {"popover-body-container":"popover-body-container__popover__12-20-2-alpha-0","popover-body":"popover-body__popover__12-20-2-alpha-0","popover-body--no-padding":"popover-body--no-padding__popover__12-20-2-alpha-0","popover-tip":"popover-tip__popover__12-20-2-alpha-0","popover-tip--bottom":"popover-tip--bottom__popover__12-20-2-alpha-0","popover-tip--top":"popover-tip--top__popover__12-20-2-alpha-0","popover-tip--left":"popover-tip--left__popover__12-20-2-alpha-0","popover-tip--right":"popover-tip--right__popover__12-20-2-alpha-0"};
|
|
211
214
|
styleInject(css);
|
|
212
215
|
|
|
216
|
+
/*********************************************************************
|
|
217
|
+
* © Copyright IBM Corp. 2024
|
|
218
|
+
*********************************************************************/
|
|
213
219
|
var PopoverBody = function PopoverBody(_ref) {
|
|
214
220
|
var children = _ref.children,
|
|
215
221
|
className = _ref.className,
|
|
@@ -222,6 +228,9 @@ var PopoverBody = function PopoverBody(_ref) {
|
|
|
222
228
|
}, children));
|
|
223
229
|
};
|
|
224
230
|
|
|
231
|
+
/*********************************************************************
|
|
232
|
+
* © Copyright IBM Corp. 2024
|
|
233
|
+
*********************************************************************/
|
|
225
234
|
var throttle = function throttle(func, limit) {
|
|
226
235
|
var lastFunc = null;
|
|
227
236
|
var lastRan = null;
|
|
@@ -244,6 +253,9 @@ var throttle = function throttle(func, limit) {
|
|
|
244
253
|
};
|
|
245
254
|
};
|
|
246
255
|
|
|
256
|
+
/*********************************************************************
|
|
257
|
+
* © Copyright IBM Corp. 2024
|
|
258
|
+
*********************************************************************/
|
|
247
259
|
var generateId = function generateId(prefix) {
|
|
248
260
|
return "".concat(prefix).concat(Math.random().toString(36).substring(7));
|
|
249
261
|
};
|
|
@@ -649,10 +661,7 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
649
661
|
trapFocus: this.props.trapFocus,
|
|
650
662
|
onEscapeAction: this.props.onEscapeAction
|
|
651
663
|
}, props.body);
|
|
652
|
-
|
|
653
|
-
return ReactDOM.createPortal(popoverContent, container);
|
|
654
|
-
}
|
|
655
|
-
return popoverContent;
|
|
664
|
+
return ReactDOM.createPortal(popoverContent, container);
|
|
656
665
|
}
|
|
657
666
|
}, {
|
|
658
667
|
key: "renderPortal",
|
|
@@ -661,14 +670,12 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
661
670
|
if (!this.props.isOpen) {
|
|
662
671
|
return null;
|
|
663
672
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
positioningTarget: positioningTarget
|
|
667
|
-
}) : React.createElement(BodyDomNode, {
|
|
673
|
+
var containerElement = this.props.inline ? positioningTarget : this.getContainer();
|
|
674
|
+
return React.createElement(BodyDomNode, {
|
|
668
675
|
onOuterAction: this.props.onOuterAction,
|
|
669
676
|
outerActionEvents: this.props.outerActionEvents,
|
|
670
677
|
positioningTarget: positioningTarget,
|
|
671
|
-
containerElement:
|
|
678
|
+
containerElement: containerElement
|
|
672
679
|
}, function (container) {
|
|
673
680
|
return container ? _this2.renderPortalContent({
|
|
674
681
|
props: _this2.props,
|
|
@@ -758,5 +765,9 @@ Popover.defaultProps = {
|
|
|
758
765
|
trapFocus: 'true'
|
|
759
766
|
};
|
|
760
767
|
|
|
768
|
+
/*********************************************************************
|
|
769
|
+
* © Copyright IBM Corp. 2024
|
|
770
|
+
*********************************************************************/
|
|
771
|
+
|
|
761
772
|
export default Popover;
|
|
762
773
|
export { Popover, PopoverBody, PopoverPosition };
|
package/dist/popover.js
CHANGED
|
@@ -105,6 +105,9 @@ function _toPropertyKey(arg) {
|
|
|
105
105
|
return typeof key === "symbol" ? key : String(key);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/*********************************************************************
|
|
109
|
+
* © Copyright IBM Corp. 2024
|
|
110
|
+
*********************************************************************/
|
|
108
111
|
var PopoverPosition = {
|
|
109
112
|
bottomLeft: function bottomLeft(hostRect, popoverRect, containerScroll) {
|
|
110
113
|
return {
|
|
@@ -213,10 +216,13 @@ function styleInject(css, ref) {
|
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
|
|
216
|
-
var css = ".popover-body-container__popover__12-20-
|
|
217
|
-
var styles = {"popover-body-container":"popover-body-container__popover__12-20-
|
|
219
|
+
var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body-container__popover__12-20-2-alpha-0 {\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.popover-body__popover__12-20-2-alpha-0 {\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.popover-body--no-padding__popover__12-20-2-alpha-0 {\n padding: 0;\n }\n.popover-tip__popover__12-20-2-alpha-0 {\n position: absolute;\n pointer-events: none;\n z-index: calc(var(--ZIndexModal, 10001) + 1);\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.popover-tip__popover__12-20-2-alpha-0: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: 11.2px;\n height: 11.2px;\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n.popover-tip--bottom__popover__12-20-2-alpha-0,\n .popover-tip--top__popover__12-20-2-alpha-0 {\n width: 100%;\n border-top: 1px var(--BackgroundDefault, #FFFFFF);\n border-bottom: 1px var(--BackgroundDefault, #FFFFFF);\n height: 9px;\n }\n.popover-tip--left__popover__12-20-2-alpha-0,\n .popover-tip--right__popover__12-20-2-alpha-0 {\n border-left: 1px var(--BackgroundDefault, #FFFFFF);\n border-right: 1px var(--BackgroundDefault, #FFFFFF);\n height: 100%;\n width: 9px;\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.popover-tip--bottom__popover__12-20-2-alpha-0:before {\n -webkit-transform-origin: left top;\n transform-origin: left top;\n left: 50%;\n top: 0;\n }\n.popover-tip--top__popover__12-20-2-alpha-0:before {\n -webkit-transform-origin: right bottom;\n transform-origin: right bottom;\n right: 50%;\n bottom: 0;\n }\n.popover-tip--left__popover__12-20-2-alpha-0:before {\n -webkit-transform-origin: right top;\n transform-origin: right top;\n right: 0;\n top: 50%;\n }\n.popover-tip--right__popover__12-20-2-alpha-0:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
|
|
220
|
+
var styles = {"popover-body-container":"popover-body-container__popover__12-20-2-alpha-0","popover-body":"popover-body__popover__12-20-2-alpha-0","popover-body--no-padding":"popover-body--no-padding__popover__12-20-2-alpha-0","popover-tip":"popover-tip__popover__12-20-2-alpha-0","popover-tip--bottom":"popover-tip--bottom__popover__12-20-2-alpha-0","popover-tip--top":"popover-tip--top__popover__12-20-2-alpha-0","popover-tip--left":"popover-tip--left__popover__12-20-2-alpha-0","popover-tip--right":"popover-tip--right__popover__12-20-2-alpha-0"};
|
|
218
221
|
styleInject(css);
|
|
219
222
|
|
|
223
|
+
/*********************************************************************
|
|
224
|
+
* © Copyright IBM Corp. 2024
|
|
225
|
+
*********************************************************************/
|
|
220
226
|
var PopoverBody = function PopoverBody(_ref) {
|
|
221
227
|
var children = _ref.children,
|
|
222
228
|
className = _ref.className,
|
|
@@ -229,6 +235,9 @@ var PopoverBody = function PopoverBody(_ref) {
|
|
|
229
235
|
}, children));
|
|
230
236
|
};
|
|
231
237
|
|
|
238
|
+
/*********************************************************************
|
|
239
|
+
* © Copyright IBM Corp. 2024
|
|
240
|
+
*********************************************************************/
|
|
232
241
|
var throttle = function throttle(func, limit) {
|
|
233
242
|
var lastFunc = null;
|
|
234
243
|
var lastRan = null;
|
|
@@ -251,6 +260,9 @@ var throttle = function throttle(func, limit) {
|
|
|
251
260
|
};
|
|
252
261
|
};
|
|
253
262
|
|
|
263
|
+
/*********************************************************************
|
|
264
|
+
* © Copyright IBM Corp. 2024
|
|
265
|
+
*********************************************************************/
|
|
254
266
|
var generateId = function generateId(prefix) {
|
|
255
267
|
return "".concat(prefix).concat(Math.random().toString(36).substring(7));
|
|
256
268
|
};
|
|
@@ -656,10 +668,7 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
656
668
|
trapFocus: this.props.trapFocus,
|
|
657
669
|
onEscapeAction: this.props.onEscapeAction
|
|
658
670
|
}, props.body);
|
|
659
|
-
|
|
660
|
-
return ReactDOM.createPortal(popoverContent, container);
|
|
661
|
-
}
|
|
662
|
-
return popoverContent;
|
|
671
|
+
return ReactDOM.createPortal(popoverContent, container);
|
|
663
672
|
}
|
|
664
673
|
}, {
|
|
665
674
|
key: "renderPortal",
|
|
@@ -668,14 +677,12 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
668
677
|
if (!this.props.isOpen) {
|
|
669
678
|
return null;
|
|
670
679
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
positioningTarget: positioningTarget
|
|
674
|
-
}) : React__default.createElement(BodyDomNode, {
|
|
680
|
+
var containerElement = this.props.inline ? positioningTarget : this.getContainer();
|
|
681
|
+
return React__default.createElement(BodyDomNode, {
|
|
675
682
|
onOuterAction: this.props.onOuterAction,
|
|
676
683
|
outerActionEvents: this.props.outerActionEvents,
|
|
677
684
|
positioningTarget: positioningTarget,
|
|
678
|
-
containerElement:
|
|
685
|
+
containerElement: containerElement
|
|
679
686
|
}, function (container) {
|
|
680
687
|
return container ? _this2.renderPortalContent({
|
|
681
688
|
props: _this2.props,
|
|
@@ -765,6 +772,10 @@ Popover.defaultProps = {
|
|
|
765
772
|
trapFocus: 'true'
|
|
766
773
|
};
|
|
767
774
|
|
|
775
|
+
/*********************************************************************
|
|
776
|
+
* © Copyright IBM Corp. 2024
|
|
777
|
+
*********************************************************************/
|
|
778
|
+
|
|
768
779
|
exports.Popover = Popover;
|
|
769
780
|
exports.PopoverBody = PopoverBody;
|
|
770
781
|
exports.PopoverPosition = PopoverPosition;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
1
4
|
import { CSSProperties } from 'react';
|
|
2
5
|
export declare type PositionParams = {
|
|
3
6
|
left: number;
|
package/index.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
import {Popover, PopoverProps} from './Popover'
|
|
5
|
+
import {PopoverBody, PopoverBodyProps} from './PopoverBody'
|
|
6
|
+
import {GetPopoverPositionType} from './types'
|
|
7
|
+
import {PopoverPosition} from './PopoverPosition'
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
Popover,
|
|
11
|
+
PopoverBody,
|
|
12
|
+
PopoverProps,
|
|
13
|
+
PopoverBodyProps,
|
|
14
|
+
GetPopoverPositionType,
|
|
15
|
+
PopoverPosition
|
|
16
|
+
}
|
|
17
|
+
export default Popover
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@targetprocess/popover",
|
|
3
|
-
"version": "12.20.
|
|
3
|
+
"version": "12.20.2-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.20.
|
|
15
|
+
"@targetprocess/global-constants": "^12.20.2-alpha.0",
|
|
16
16
|
"classnames": "^2.2.5",
|
|
17
17
|
"focus-trap-react": "^7.0.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": "58801cfa426dcee4f34922ebc0e9cfa8fbd52735"
|
|
26
26
|
}
|