@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.
@@ -1,63 +1,66 @@
1
- /* eslint-env jest */
2
- import React from 'react'
3
- import {mount} from 'enzyme'
4
- import {Popover, PopoverProps, PopoverState} from '../Popover'
5
- import {PopoverBody} from '../PopoverBody'
6
- import {cleanDocumentBody} from '../../../testUtils/domUtils'
7
-
8
- jest.mock('focus-trap', () => {
9
- const trap = {
10
- activate: () => trap,
11
- deactivate: () => trap,
12
- pause: () => {},
13
- unpause: () => {}
14
- }
15
- return () => trap
16
- })
17
-
18
- describe('Popover', () => {
19
- beforeEach(() => {
20
- cleanDocumentBody()
21
- })
22
-
23
- it('should render only its children by default', () => {
24
- const wrapper = mount(
25
- <Popover getPopoverPosition="bottomLeft">
26
- <div className="foo" />
27
- </Popover>
28
- )
29
-
30
- expect(wrapper.find('.foo')).toHaveLength(1)
31
- })
32
-
33
- it('should support render prop as child', () => {
34
- const wrapper = mount<Popover, PopoverProps, PopoverState>(
35
- <Popover>{({isOpen, setOpened}) => <button onClick={() => setOpened(!isOpen)} />}</Popover>
36
- )
37
-
38
- expect(wrapper.state().isOpen).toBe(false)
39
-
40
- wrapper.find('button').simulate('click')
41
-
42
- expect(wrapper.state().isOpen).toBe(true)
43
-
44
- wrapper.find('button').simulate('click')
45
-
46
- expect(wrapper.state().isOpen).toBe(false)
47
- })
48
-
49
- it('should pass event to onOuterAction callback', () => {
50
- const onOuterAction = jest.fn()
51
-
52
- mount(
53
- <Popover isOpen onOuterAction={onOuterAction} body={<PopoverBody>foo</PopoverBody>}>
54
- <button />
55
- </Popover>
56
- )
57
- expect(document.querySelectorAll('.popover-body')).toHaveLength(1)
58
- expect(onOuterAction).not.toHaveBeenCalled()
59
- document.dispatchEvent(new MouseEvent('mousedown', {bubbles: true}))
60
- expect(onOuterAction.mock.calls.length).toBe(1)
61
- expect(onOuterAction.mock.calls[0][0].target).toBeDefined()
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
- import React from 'react'
2
- import {mount} from 'enzyme'
3
- import {PositioningTarget} from '../PositioningTarget'
4
- import {whenComponentDidMountCalled} from '../../../testUtils/componentLifecycleUtils'
5
-
6
- const originalComponentDidMount = PositioningTarget.prototype.componentDidMount
7
-
8
- const stubComponentDidMount = () => whenComponentDidMountCalled(PositioningTarget)
9
-
10
- describe('PositioningTarget', () => {
11
- afterEach(() => {
12
- PositioningTarget.prototype.componentDidMount = originalComponentDidMount
13
- })
14
-
15
- it('shoud call render prop with null initially', () => {
16
- const renderProp = jest.fn(() => null)
17
-
18
- mount(<PositioningTarget>{renderProp}</PositioningTarget>)
19
-
20
- expect(renderProp).toHaveBeenCalled()
21
- expect(renderProp.mock.calls[0][0]).toBeNull()
22
- })
23
-
24
- it('should call render prop with div after component will be mounted', async () => {
25
- const renderProp = jest.fn(() => null)
26
- const componentDidMountCalled = stubComponentDidMount()
27
-
28
- mount(<PositioningTarget>{renderProp}</PositioningTarget>)
29
-
30
- await componentDidMountCalled
31
-
32
- expect(renderProp).toHaveBeenCalledTimes(2)
33
- expect(renderProp.mock.calls[1][0].tagName).toBe('DIV')
34
- })
35
-
36
- it('should render element returned from rendr prop', () => {
37
- const renderProp = () => <button>Test</button>
38
-
39
- const wrapper = mount(<PositioningTarget>{renderProp}</PositioningTarget>)
40
-
41
- expect(wrapper.find('button')).toHaveLength(1)
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
+ })
@@ -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';
@@ -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
- }): JSX.Element;
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';
@@ -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-1-alpha-4 {\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-20-1-alpha-4 {\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-20-1-alpha-4 {\r\n padding: 0;\r\n }\r\n\r\n.popover-tip__popover__12-20-1-alpha-4 {\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-20-1-alpha-4: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-20-1-alpha-4,\r\n .popover-tip--top__popover__12-20-1-alpha-4 {\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-20-1-alpha-4,\r\n .popover-tip--right__popover__12-20-1-alpha-4 {\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-20-1-alpha-4: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-20-1-alpha-4: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-20-1-alpha-4: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-20-1-alpha-4: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";
210
- var styles = {"popover-body-container":"popover-body-container__popover__12-20-1-alpha-4","popover-body":"popover-body__popover__12-20-1-alpha-4","popover-body--no-padding":"popover-body--no-padding__popover__12-20-1-alpha-4","popover-tip":"popover-tip__popover__12-20-1-alpha-4","popover-tip--bottom":"popover-tip--bottom__popover__12-20-1-alpha-4","popover-tip--top":"popover-tip--top__popover__12-20-1-alpha-4","popover-tip--left":"popover-tip--left__popover__12-20-1-alpha-4","popover-tip--right":"popover-tip--right__popover__12-20-1-alpha-4"};
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
- if (!props.inline) {
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
- return this.props.inline ? this.renderPortalContent({
665
- props: this.props,
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: this.getContainer()
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-1-alpha-4 {\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-20-1-alpha-4 {\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-20-1-alpha-4 {\r\n padding: 0;\r\n }\r\n\r\n.popover-tip__popover__12-20-1-alpha-4 {\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-20-1-alpha-4: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-20-1-alpha-4,\r\n .popover-tip--top__popover__12-20-1-alpha-4 {\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-20-1-alpha-4,\r\n .popover-tip--right__popover__12-20-1-alpha-4 {\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-20-1-alpha-4: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-20-1-alpha-4: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-20-1-alpha-4: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-20-1-alpha-4: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";
217
- var styles = {"popover-body-container":"popover-body-container__popover__12-20-1-alpha-4","popover-body":"popover-body__popover__12-20-1-alpha-4","popover-body--no-padding":"popover-body--no-padding__popover__12-20-1-alpha-4","popover-tip":"popover-tip__popover__12-20-1-alpha-4","popover-tip--bottom":"popover-tip--bottom__popover__12-20-1-alpha-4","popover-tip--top":"popover-tip--top__popover__12-20-1-alpha-4","popover-tip--left":"popover-tip--left__popover__12-20-1-alpha-4","popover-tip--right":"popover-tip--right__popover__12-20-1-alpha-4"};
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
- if (!props.inline) {
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
- return this.props.inline ? this.renderPortalContent({
672
- props: this.props,
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: this.getContainer()
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
- import {Popover, PopoverProps} from './Popover'
2
- import {PopoverBody, PopoverBodyProps} from './PopoverBody'
3
- import {GetPopoverPositionType} from './types'
4
- import {PopoverPosition} from './PopoverPosition'
5
-
6
- export {
7
- Popover,
8
- PopoverBody,
9
- PopoverProps,
10
- PopoverBodyProps,
11
- GetPopoverPositionType,
12
- PopoverPosition
13
- }
14
- export default Popover
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.1-alpha.4",
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.1-alpha.4",
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": "ef8076c362ed99ebe19488c7386126c7468c7db5"
25
+ "gitHead": "58801cfa426dcee4f34922ebc0e9cfa8fbd52735"
26
26
  }