@targetprocess/popover 12.23.1-alpha.0 → 12.23.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/Popover.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  /*********************************************************************
2
2
  * © Copyright IBM Corp. 2024
3
3
  *********************************************************************/
4
- import React from 'react'
4
+ import React, {createRef} from 'react'
5
5
  import PropTypes from 'prop-types'
6
6
  import {PopoverPosition} from './PopoverPosition'
7
7
  import {PopoverBody} from './PopoverBody'
@@ -136,7 +136,7 @@ export class Popover extends React.Component<PopoverProps, PopoverState> {
136
136
  outerActionEvents: ['mousedown', 'touchstart'],
137
137
  getPopoverPosition: 'bottomLeft',
138
138
  role: 'dialog',
139
- trapFocus: true
139
+ trapFocus: 'true'
140
140
  }
141
141
 
142
142
  state = {
@@ -161,10 +161,10 @@ export class Popover extends React.Component<PopoverProps, PopoverState> {
161
161
  if (this.props.onOuterAction) {
162
162
  this.props.onOuterAction(event)
163
163
  }
164
- this.childrenRef?.focus()
164
+ this.childrenRef.current?.focus()
165
165
  }
166
166
 
167
- childrenRef?: HTMLElement
167
+ childrenRef = createRef<HTMLElement>()
168
168
 
169
169
  render() {
170
170
  const isOpen = typeof this.props.isOpen === 'undefined' ? this.state.isOpen : this.props.isOpen
@@ -173,18 +173,8 @@ export class Popover extends React.Component<PopoverProps, PopoverState> {
173
173
  ? this.props.children({isOpen, setOpened: this.setOpened, ref: this.childrenRef})
174
174
  : this.props.children
175
175
  const childrenWithRef = React.Children.map(children, child =>
176
- React.cloneElement(child, {
177
- ref: (current?: HTMLElement) => {
178
- this.childrenRef = current
179
- if (typeof child.ref === 'function') {
180
- child.ref(current)
181
- } else if (child.ref && child.ref.hasOwnProperty('current')) {
182
- child.ref.current = current
183
- }
184
- }
185
- })
176
+ React.cloneElement(child, {ref: this.childrenRef})
186
177
  )
187
- this.childrenRef = null
188
178
 
189
179
  return (
190
180
  <StatelessPopover
@@ -131,22 +131,10 @@ export class PopoverContainer extends React.Component<
131
131
 
132
132
  this.setState({
133
133
  hostRect: {
134
- top:
135
- this.props.relativeToParent || isNaN(positioningBoundingRect.top)
136
- ? 0
137
- : positioningBoundingRect.top,
138
- left:
139
- this.props.relativeToParent || isNaN(positioningBoundingRect.left)
140
- ? 0
141
- : positioningBoundingRect.left,
142
- right:
143
- this.props.relativeToParent || isNaN(positioningBoundingRect.right)
144
- ? 0
145
- : positioningBoundingRect.right,
146
- bottom:
147
- this.props.relativeToParent || isNaN(positioningBoundingRect.bottom)
148
- ? 0
149
- : positioningBoundingRect.bottom,
134
+ top: this.props.relativeToParent ? 0 : positioningBoundingRect.top,
135
+ left: this.props.relativeToParent ? 0 : positioningBoundingRect.left,
136
+ right: this.props.relativeToParent ? 0 : positioningBoundingRect.right,
137
+ bottom: this.props.relativeToParent ? 0 : positioningBoundingRect.bottom,
150
138
  width: positioningBoundingRect.width,
151
139
  height: positioningBoundingRect.height
152
140
  },
@@ -18,12 +18,6 @@ jest.mock('focus-trap', () => {
18
18
  return () => trap
19
19
  })
20
20
 
21
- const ComponentWithRef = React.forwardRef<HTMLElement>((prop, ref) => (
22
- <div>
23
- <span ref={ref}>Ref</span>
24
- </div>
25
- ))
26
-
27
21
  describe('Popover', () => {
28
22
  beforeEach(() => {
29
23
  cleanDocumentBody()
@@ -69,19 +63,4 @@ describe('Popover', () => {
69
63
  expect(onOuterAction.mock.calls.length).toBe(1)
70
64
  expect(onOuterAction.mock.calls[0][0].target).toBeDefined()
71
65
  })
72
-
73
- it('should keep ref in children', () => {
74
- const ref1 = jest.fn()
75
- const ref2 = jest.fn()
76
-
77
- mount(
78
- <Popover getPopoverPosition="bottomLeft">
79
- <ComponentWithRef ref={ref1} />
80
- <ComponentWithRef ref={ref2} />
81
- </Popover>
82
- )
83
-
84
- expect(ref1).toBeCalled()
85
- expect(ref2).toBeCalled()
86
- })
87
66
  })
package/dist/Popover.d.ts CHANGED
@@ -125,7 +125,7 @@ export declare class Popover extends React.Component<PopoverProps, PopoverState>
125
125
  outerActionEvents: string[];
126
126
  getPopoverPosition: string;
127
127
  role: string;
128
- trapFocus: boolean;
128
+ trapFocus: string;
129
129
  };
130
130
  state: {
131
131
  isOpen: boolean;
@@ -133,6 +133,6 @@ export declare class Popover extends React.Component<PopoverProps, PopoverState>
133
133
  setOpened: (isOpen: boolean) => void;
134
134
  onOuterAction: (event: Event) => void;
135
135
  onEscapeAction: (event: Event) => void;
136
- childrenRef?: HTMLElement;
136
+ childrenRef: React.RefObject<HTMLElement>;
137
137
  render(): JSX.Element;
138
138
  }
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { createRef } from 'react';
2
2
  import { SpaceXS } from '@targetprocess/global-constants';
3
3
  import classNames from 'classnames';
4
4
  import ReactDOM from 'react-dom';
@@ -209,8 +209,8 @@ function styleInject(css, ref) {
209
209
  }
210
210
  }
211
211
 
212
- var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body-container__popover__12-23-1-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-23-1-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-23-1-alpha-0 {\n padding: 0;\n }\n.popover-tip__popover__12-23-1-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-23-1-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-23-1-alpha-0,\n .popover-tip--top__popover__12-23-1-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-23-1-alpha-0,\n .popover-tip--right__popover__12-23-1-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-23-1-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-23-1-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-23-1-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-23-1-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-23-1-alpha-0","popover-body":"popover-body__popover__12-23-1-alpha-0","popover-body--no-padding":"popover-body--no-padding__popover__12-23-1-alpha-0","popover-tip":"popover-tip__popover__12-23-1-alpha-0","popover-tip--bottom":"popover-tip--bottom__popover__12-23-1-alpha-0","popover-tip--top":"popover-tip--top__popover__12-23-1-alpha-0","popover-tip--left":"popover-tip--left__popover__12-23-1-alpha-0","popover-tip--right":"popover-tip--right__popover__12-23-1-alpha-0"};
212
+ var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body-container__popover__12-23-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.popover-body__popover__12-23-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.popover-body--no-padding__popover__12-23-2 {\n padding: 0;\n }\n.popover-tip__popover__12-23-2 {\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-23-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: 11.2px;\n height: 11.2px;\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n.popover-tip--bottom__popover__12-23-2,\n .popover-tip--top__popover__12-23-2 {\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-23-2,\n .popover-tip--right__popover__12-23-2 {\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-23-2: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-23-2: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-23-2: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-23-2: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-23-2","popover-body":"popover-body__popover__12-23-2","popover-body--no-padding":"popover-body--no-padding__popover__12-23-2","popover-tip":"popover-tip__popover__12-23-2","popover-tip--bottom":"popover-tip--bottom__popover__12-23-2","popover-tip--top":"popover-tip--top__popover__12-23-2","popover-tip--left":"popover-tip--left__popover__12-23-2","popover-tip--right":"popover-tip--right__popover__12-23-2"};
214
214
  styleInject(css);
215
215
 
216
216
  /*********************************************************************
@@ -401,10 +401,10 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
401
401
  var positioningBoundingRect = getCompositeRect(this.props.positioningTarget, this.props.containerElement);
402
402
  this.setState({
403
403
  hostRect: {
404
- top: this.props.relativeToParent || isNaN(positioningBoundingRect.top) ? 0 : positioningBoundingRect.top,
405
- left: this.props.relativeToParent || isNaN(positioningBoundingRect.left) ? 0 : positioningBoundingRect.left,
406
- right: this.props.relativeToParent || isNaN(positioningBoundingRect.right) ? 0 : positioningBoundingRect.right,
407
- bottom: this.props.relativeToParent || isNaN(positioningBoundingRect.bottom) ? 0 : positioningBoundingRect.bottom,
404
+ top: this.props.relativeToParent ? 0 : positioningBoundingRect.top,
405
+ left: this.props.relativeToParent ? 0 : positioningBoundingRect.left,
406
+ right: this.props.relativeToParent ? 0 : positioningBoundingRect.right,
407
+ bottom: this.props.relativeToParent ? 0 : positioningBoundingRect.bottom,
408
408
  width: positioningBoundingRect.width,
409
409
  height: positioningBoundingRect.height
410
410
  },
@@ -725,8 +725,9 @@ var Popover = /*#__PURE__*/function (_React$Component) {
725
725
  if (_this.props.onOuterAction) {
726
726
  _this.props.onOuterAction(event);
727
727
  }
728
- (_a = _this.childrenRef) === null || _a === void 0 ? void 0 : _a.focus();
728
+ (_a = _this.childrenRef.current) === null || _a === void 0 ? void 0 : _a.focus();
729
729
  };
730
+ _this.childrenRef = createRef();
730
731
  return _this;
731
732
  }
732
733
  _createClass(Popover, [{
@@ -741,17 +742,9 @@ var Popover = /*#__PURE__*/function (_React$Component) {
741
742
  }) : this.props.children;
742
743
  var childrenWithRef = React.Children.map(children, function (child) {
743
744
  return React.cloneElement(child, {
744
- ref: function ref(current) {
745
- _this2.childrenRef = current;
746
- if (typeof child.ref === 'function') {
747
- child.ref(current);
748
- } else if (child.ref && child.ref.hasOwnProperty('current')) {
749
- child.ref.current = current;
750
- }
751
- }
745
+ ref: _this2.childrenRef
752
746
  });
753
747
  });
754
- this.childrenRef = null;
755
748
  return React.createElement(StatelessPopover, Object.assign({}, this.props, {
756
749
  onOuterAction: this.onOuterAction,
757
750
  onEscapeAction: this.onEscapeAction,
@@ -770,7 +763,7 @@ Popover.defaultProps = {
770
763
  outerActionEvents: ['mousedown', 'touchstart'],
771
764
  getPopoverPosition: 'bottomLeft',
772
765
  role: 'dialog',
773
- trapFocus: true
766
+ trapFocus: 'true'
774
767
  };
775
768
 
776
769
  /*********************************************************************
package/dist/popover.js CHANGED
@@ -4,7 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
6
 
7
- var React = _interopDefault(require('react'));
7
+ var React = require('react');
8
+ var React__default = _interopDefault(React);
8
9
  var globalConstants = require('@targetprocess/global-constants');
9
10
  var classNames = _interopDefault(require('classnames'));
10
11
  var ReactDOM = _interopDefault(require('react-dom'));
@@ -215,8 +216,8 @@ function styleInject(css, ref) {
215
216
  }
216
217
  }
217
218
 
218
- var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body-container__popover__12-23-1-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-23-1-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-23-1-alpha-0 {\n padding: 0;\n }\n.popover-tip__popover__12-23-1-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-23-1-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-23-1-alpha-0,\n .popover-tip--top__popover__12-23-1-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-23-1-alpha-0,\n .popover-tip--right__popover__12-23-1-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-23-1-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-23-1-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-23-1-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-23-1-alpha-0:before {\n -webkit-transform-origin: left bottom;\n transform-origin: left bottom;\n left: 0;\n bottom: 50%;\n }\n";
219
- var styles = {"popover-body-container":"popover-body-container__popover__12-23-1-alpha-0","popover-body":"popover-body__popover__12-23-1-alpha-0","popover-body--no-padding":"popover-body--no-padding__popover__12-23-1-alpha-0","popover-tip":"popover-tip__popover__12-23-1-alpha-0","popover-tip--bottom":"popover-tip--bottom__popover__12-23-1-alpha-0","popover-tip--top":"popover-tip--top__popover__12-23-1-alpha-0","popover-tip--left":"popover-tip--left__popover__12-23-1-alpha-0","popover-tip--right":"popover-tip--right__popover__12-23-1-alpha-0"};
219
+ var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.popover-body-container__popover__12-23-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.popover-body__popover__12-23-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.popover-body--no-padding__popover__12-23-2 {\n padding: 0;\n }\n.popover-tip__popover__12-23-2 {\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-23-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: 11.2px;\n height: 11.2px;\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n }\n.popover-tip--bottom__popover__12-23-2,\n .popover-tip--top__popover__12-23-2 {\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-23-2,\n .popover-tip--right__popover__12-23-2 {\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-23-2: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-23-2: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-23-2: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-23-2: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-23-2","popover-body":"popover-body__popover__12-23-2","popover-body--no-padding":"popover-body--no-padding__popover__12-23-2","popover-tip":"popover-tip__popover__12-23-2","popover-tip--bottom":"popover-tip--bottom__popover__12-23-2","popover-tip--top":"popover-tip--top__popover__12-23-2","popover-tip--left":"popover-tip--left__popover__12-23-2","popover-tip--right":"popover-tip--right__popover__12-23-2"};
220
221
  styleInject(css);
221
222
 
222
223
  /*********************************************************************
@@ -227,9 +228,9 @@ var PopoverBody = function PopoverBody(_ref) {
227
228
  className = _ref.className,
228
229
  classNameBody = _ref.classNameBody,
229
230
  noPadding = _ref.noPadding;
230
- return React.createElement("div", {
231
+ return React__default.createElement("div", {
231
232
  className: classNames(className, styles['popover-body-container'])
232
- }, React.createElement("div", {
233
+ }, React__default.createElement("div", {
233
234
  className: classNames(classNameBody, styles['popover-body'], noPadding && styles['popover-body--no-padding'])
234
235
  }, children));
235
236
  };
@@ -360,7 +361,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
360
361
  _classCallCheck(this, PopoverContainer);
361
362
  _this = _possibleConstructorReturn(this, _getPrototypeOf(PopoverContainer).apply(this, arguments));
362
363
  _this.mounted = false;
363
- _this.popoverContentRef = React.createRef();
364
+ _this.popoverContentRef = React__default.createRef();
364
365
  _this.state = {
365
366
  adjusted: false,
366
367
  positionX: 0,
@@ -407,10 +408,10 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
407
408
  var positioningBoundingRect = getCompositeRect(this.props.positioningTarget, this.props.containerElement);
408
409
  this.setState({
409
410
  hostRect: {
410
- top: this.props.relativeToParent || isNaN(positioningBoundingRect.top) ? 0 : positioningBoundingRect.top,
411
- left: this.props.relativeToParent || isNaN(positioningBoundingRect.left) ? 0 : positioningBoundingRect.left,
412
- right: this.props.relativeToParent || isNaN(positioningBoundingRect.right) ? 0 : positioningBoundingRect.right,
413
- bottom: this.props.relativeToParent || isNaN(positioningBoundingRect.bottom) ? 0 : positioningBoundingRect.bottom,
411
+ top: this.props.relativeToParent ? 0 : positioningBoundingRect.top,
412
+ left: this.props.relativeToParent ? 0 : positioningBoundingRect.left,
413
+ right: this.props.relativeToParent ? 0 : positioningBoundingRect.right,
414
+ bottom: this.props.relativeToParent ? 0 : positioningBoundingRect.bottom,
414
415
  width: positioningBoundingRect.width,
415
416
  height: positioningBoundingRect.height
416
417
  },
@@ -482,7 +483,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
482
483
  };
483
484
  var tipPosition = this.getPopoverTipPosition(position, containerPosition);
484
485
  // FIXME: position.top cast to number, because value may be not a number
485
- return React.createElement("div", {
486
+ return React__default.createElement("div", {
486
487
  style: _extends({
487
488
  position: 'absolute'
488
489
  }, containerPosition, {
@@ -492,7 +493,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
492
493
  transitionProperty: 'opacity',
493
494
  opacity: this.state.adjusted ? 1 : 0
494
495
  })
495
- }, this.props.showTip && tipPosition && React.createElement("div", {
496
+ }, this.props.showTip && tipPosition && React__default.createElement("div", {
496
497
  className: classNames(styles['popover-tip'], styles["popover-tip--".concat(tipPosition)], 'popover-tip', this.props.classNameTip),
497
498
  style: {
498
499
  top: tipPosition === 'bottom' && position.top - 8,
@@ -500,12 +501,12 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
500
501
  left: tipPosition === 'right' && position.left - 8,
501
502
  right: tipPosition === 'left' && position.right - 8
502
503
  }
503
- }), this.props.trapFocus && React.createElement(FocusTrap, {
504
+ }), this.props.trapFocus && React__default.createElement(FocusTrap, {
504
505
  focusTrapOptions: {
505
506
  fallbackFocus: "#".concat(this.popoverContainerId),
506
507
  clickOutsideDeactivates: true
507
508
  }
508
- }, React.createElement("div", {
509
+ }, React__default.createElement("div", {
509
510
  id: this.popoverContainerId,
510
511
  ref: this.popoverContentRef,
511
512
  style: _extends({
@@ -517,7 +518,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
517
518
  role: this.props.role,
518
519
  "aria-modal": this.props.trapFocus ? 'true' : 'false',
519
520
  onKeyDown: this.handleKeyDown
520
- }, this.props.children)), !this.props.trapFocus && React.createElement("div", {
521
+ }, this.props.children)), !this.props.trapFocus && React__default.createElement("div", {
521
522
  id: this.popoverContainerId,
522
523
  ref: this.popoverContentRef,
523
524
  style: _extends({
@@ -533,7 +534,7 @@ var PopoverContainer = /*#__PURE__*/function (_React$Component) {
533
534
  }
534
535
  }]);
535
536
  return PopoverContainer;
536
- }(React.Component);
537
+ }(React__default.Component);
537
538
  PopoverContainer.defaultProps = {
538
539
  trackScroll: true
539
540
  };
@@ -547,7 +548,7 @@ var PositioningTarget = /*#__PURE__*/function (_React$Component) {
547
548
  _this.state = {
548
549
  target: null
549
550
  };
550
- _this.targetRef = React.createRef();
551
+ _this.targetRef = React__default.createRef();
551
552
  return _this;
552
553
  }
553
554
  _createClass(PositioningTarget, [{
@@ -560,13 +561,13 @@ var PositioningTarget = /*#__PURE__*/function (_React$Component) {
560
561
  }, {
561
562
  key: "render",
562
563
  value: function render() {
563
- return React.createElement("div", {
564
+ return React__default.createElement("div", {
564
565
  ref: this.targetRef
565
566
  }, this.props.children(this.state.target));
566
567
  }
567
568
  }]);
568
569
  return PositioningTarget;
569
- }(React.Component);
570
+ }(React__default.Component);
570
571
 
571
572
  var BodyDomNode = /*#__PURE__*/function (_React$Component) {
572
573
  _inherits(BodyDomNode, _React$Component);
@@ -631,7 +632,7 @@ var BodyDomNode = /*#__PURE__*/function (_React$Component) {
631
632
  }
632
633
  }]);
633
634
  return BodyDomNode;
634
- }(React.Component);
635
+ }(React__default.Component);
635
636
  BodyDomNode.defaultProps = {
636
637
  containerElement: document.body
637
638
  };
@@ -653,7 +654,7 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
653
654
  var props = _ref.props,
654
655
  container = _ref.container,
655
656
  positioningTarget = _ref.positioningTarget;
656
- var popoverContent = React.createElement(PopoverContainer, {
657
+ var popoverContent = React__default.createElement(PopoverContainer, {
657
658
  key: "popover-portal",
658
659
  getPopoverPosition: this.props.getPopoverPosition,
659
660
  relativeToParent: props.inline,
@@ -678,7 +679,7 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
678
679
  return null;
679
680
  }
680
681
  var containerElement = this.props.inline ? positioningTarget : this.getContainer();
681
- return React.createElement(BodyDomNode, {
682
+ return React__default.createElement(BodyDomNode, {
682
683
  onOuterAction: this.props.onOuterAction,
683
684
  outerActionEvents: this.props.outerActionEvents,
684
685
  positioningTarget: positioningTarget,
@@ -695,13 +696,13 @@ var StatelessPopover = /*#__PURE__*/function (_React$Component) {
695
696
  key: "render",
696
697
  value: function render() {
697
698
  var _this3 = this;
698
- return React.createElement(PositioningTarget, null, function (positioningTarget) {
699
- return positioningTarget ? React.createElement(React.Fragment, null, _this3.props.children, _this3.renderPortal(positioningTarget)) : null;
699
+ return React__default.createElement(PositioningTarget, null, function (positioningTarget) {
700
+ return positioningTarget ? React__default.createElement(React__default.Fragment, null, _this3.props.children, _this3.renderPortal(positioningTarget)) : null;
700
701
  });
701
702
  }
702
703
  }]);
703
704
  return StatelessPopover;
704
- }(React.Component);
705
+ }(React__default.Component);
705
706
 
706
707
  var Popover = /*#__PURE__*/function (_React$Component) {
707
708
  _inherits(Popover, _React$Component);
@@ -731,8 +732,9 @@ var Popover = /*#__PURE__*/function (_React$Component) {
731
732
  if (_this.props.onOuterAction) {
732
733
  _this.props.onOuterAction(event);
733
734
  }
734
- (_a = _this.childrenRef) === null || _a === void 0 ? void 0 : _a.focus();
735
+ (_a = _this.childrenRef.current) === null || _a === void 0 ? void 0 : _a.focus();
735
736
  };
737
+ _this.childrenRef = React.createRef();
736
738
  return _this;
737
739
  }
738
740
  _createClass(Popover, [{
@@ -745,20 +747,12 @@ var Popover = /*#__PURE__*/function (_React$Component) {
745
747
  setOpened: this.setOpened,
746
748
  ref: this.childrenRef
747
749
  }) : this.props.children;
748
- var childrenWithRef = React.Children.map(children, function (child) {
749
- return React.cloneElement(child, {
750
- ref: function ref(current) {
751
- _this2.childrenRef = current;
752
- if (typeof child.ref === 'function') {
753
- child.ref(current);
754
- } else if (child.ref && child.ref.hasOwnProperty('current')) {
755
- child.ref.current = current;
756
- }
757
- }
750
+ var childrenWithRef = React__default.Children.map(children, function (child) {
751
+ return React__default.cloneElement(child, {
752
+ ref: _this2.childrenRef
758
753
  });
759
754
  });
760
- this.childrenRef = null;
761
- return React.createElement(StatelessPopover, Object.assign({}, this.props, {
755
+ return React__default.createElement(StatelessPopover, Object.assign({}, this.props, {
762
756
  onOuterAction: this.onOuterAction,
763
757
  onEscapeAction: this.onEscapeAction,
764
758
  isOpen: isOpen,
@@ -768,7 +762,7 @@ var Popover = /*#__PURE__*/function (_React$Component) {
768
762
  }
769
763
  }]);
770
764
  return Popover;
771
- }(React.Component);
765
+ }(React__default.Component);
772
766
  Popover.Body = PopoverBody;
773
767
  Popover.Position = PopoverPosition;
774
768
  Popover.defaultProps = {
@@ -776,7 +770,7 @@ Popover.defaultProps = {
776
770
  outerActionEvents: ['mousedown', 'touchstart'],
777
771
  getPopoverPosition: 'bottomLeft',
778
772
  role: 'dialog',
779
- trapFocus: true
773
+ trapFocus: 'true'
780
774
  };
781
775
 
782
776
  /*********************************************************************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@targetprocess/popover",
3
- "version": "12.23.1-alpha.0",
3
+ "version": "12.23.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.23.0",
15
+ "@targetprocess/global-constants": "^12.23.2",
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": "43eea6e799937dca9ddfecbaa70e2f0efbab33ce"
25
+ "gitHead": "c6b283ddc95981726daf5eec49385c6ab3a8f0aa"
26
26
  }