@dhis2-ui/popover 10.16.3 → 10.16.4

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.
@@ -10,28 +10,24 @@ var _classnames = _interopRequireDefault(require("classnames"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _getArrowPosition = require("./get-arrow-position.js");
13
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
15
  const ARROW_SIZE = exports.ARROW_SIZE = 8;
17
- const Arrow = exports.Arrow = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
18
- let {
19
- hidden,
20
- popperPlacement,
21
- styles
22
- } = _ref;
23
- return /*#__PURE__*/_react.default.createElement("div", {
24
- "data-test": "dhis2-uicore-popoverarrow",
25
- style: styles,
26
- ref: ref,
27
- className: _style.default.dynamic([["1397459397", [ARROW_SIZE, ARROW_SIZE, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, _uiConstants.colors.white, _uiConstants.colors.white]]]) + " " + ((0, _classnames.default)((0, _getArrowPosition.getArrowPosition)(popperPlacement), {
28
- hidden
29
- }) || "")
30
- }, /*#__PURE__*/_react.default.createElement(_style.default, {
31
- id: "1397459397",
32
- dynamic: [ARROW_SIZE, ARROW_SIZE, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, _uiConstants.colors.white, _uiConstants.colors.white]
33
- }, [`div.__jsx-style-dynamic-selector{width:${ARROW_SIZE}px;height:${ARROW_SIZE}px;position:absolute;}`, `div.top.__jsx-style-dynamic-selector{top:-${ARROW_SIZE / 2}px;}`, `div.right.__jsx-style-dynamic-selector{right:-${ARROW_SIZE / 2}px;}`, `div.bottom.__jsx-style-dynamic-selector{bottom:-${ARROW_SIZE / 2}px;}`, `div.left.__jsx-style-dynamic-selector{left:-${ARROW_SIZE / 2}px;}`, "div.hidden.__jsx-style-dynamic-selector{visibility:hidden;}", `div.__jsx-style-dynamic-selector::after{content:'';position:absolute;pointer-events:none;box-sizing:border-box;border-style:solid;border-width:${ARROW_SIZE / 2}px;border-color:transparent transparent ${_uiConstants.colors.white} ${_uiConstants.colors.white};box-shadow:-1px 1px 1px 0 rgba(64,75,90,0.08), -3px 3px 8px -6px rgba(64,75,90,0.15);}`, "div.bottom.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);}", "div.top.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);}", "div.right.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg);}", "div.left.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);}"]));
34
- });
16
+ const Arrow = exports.Arrow = /*#__PURE__*/(0, _react.forwardRef)(({
17
+ hidden,
18
+ popperPlacement,
19
+ styles
20
+ }, ref) => /*#__PURE__*/_react.default.createElement("div", {
21
+ "data-test": "dhis2-uicore-popoverarrow",
22
+ style: styles,
23
+ ref: ref,
24
+ className: _style.default.dynamic([["1397459397", [ARROW_SIZE, ARROW_SIZE, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, _uiConstants.colors.white, _uiConstants.colors.white]]]) + " " + ((0, _classnames.default)((0, _getArrowPosition.getArrowPosition)(popperPlacement), {
25
+ hidden
26
+ }) || "")
27
+ }, /*#__PURE__*/_react.default.createElement(_style.default, {
28
+ id: "1397459397",
29
+ dynamic: [ARROW_SIZE, ARROW_SIZE, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, _uiConstants.colors.white, _uiConstants.colors.white]
30
+ }, [`div.__jsx-style-dynamic-selector{width:${ARROW_SIZE}px;height:${ARROW_SIZE}px;position:absolute;}`, `div.top.__jsx-style-dynamic-selector{top:-${ARROW_SIZE / 2}px;}`, `div.right.__jsx-style-dynamic-selector{right:-${ARROW_SIZE / 2}px;}`, `div.bottom.__jsx-style-dynamic-selector{bottom:-${ARROW_SIZE / 2}px;}`, `div.left.__jsx-style-dynamic-selector{left:-${ARROW_SIZE / 2}px;}`, "div.hidden.__jsx-style-dynamic-selector{visibility:hidden;}", `div.__jsx-style-dynamic-selector::after{content:'';position:absolute;pointer-events:none;box-sizing:border-box;border-style:solid;border-width:${ARROW_SIZE / 2}px;border-color:transparent transparent ${_uiConstants.colors.white} ${_uiConstants.colors.white};box-shadow:-1px 1px 1px 0 rgba(64,75,90,0.08), -3px 3px 8px -6px rgba(64,75,90,0.15);}`, "div.bottom.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);}", "div.top.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);}", "div.right.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg);}", "div.left.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);}"])));
35
31
  Arrow.displayName = 'Arrow';
36
32
  Arrow.propTypes = {
37
33
  hidden: _propTypes.default.bool,
@@ -17,8 +17,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
17
17
  cy.visitStory('Popover', 'Shifted Arrow');
18
18
  });
19
19
  (0, _cypressCucumberPreprocessor.Then)('the Arrow is horizontally aligned with the Popper', () => {
20
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref => {
21
- let [$popover, $arrow] = _ref;
20
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
22
21
  const popoverRect = $popover.get(0).getBoundingClientRect();
23
22
  const arrowRect = $arrow.get(0).getBoundingClientRect();
24
23
  const popoverCenterX = popoverRect.left + popoverRect.width / 2;
@@ -27,8 +26,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
27
26
  });
28
27
  });
29
28
  (0, _cypressCucumberPreprocessor.Then)('the Arrow is vertically aligned with the Popper', () => {
30
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref2 => {
31
- let [$popover, $arrow] = _ref2;
29
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
32
30
  const popoverRect = $popover.get(0).getBoundingClientRect();
33
31
  const arrowRect = $arrow.get(0).getBoundingClientRect();
34
32
  const popoverCenterY = popoverRect.top + popoverRect.height / 2;
@@ -37,8 +35,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
37
35
  });
38
36
  });
39
37
  (0, _cypressCucumberPreprocessor.Then)('the Arrow is vertically aligned with the reference element', () => {
40
- cy.all(() => cy.get('[data-test="reference-element"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref3 => {
41
- let [$reference, $arrow] = _ref3;
38
+ cy.all(() => cy.get('[data-test="reference-element"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$reference, $arrow]) => {
42
39
  const referenceRect = $reference.get(0).getBoundingClientRect();
43
40
  const arrowRect = $arrow.get(0).getBoundingClientRect();
44
41
  const referenceCenterY = referenceRect.top + referenceRect.height / 2;
@@ -47,8 +44,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
47
44
  });
48
45
  });
49
46
  (0, _cypressCucumberPreprocessor.Then)('the Arrow is at the bottom of the Popper', () => {
50
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref4 => {
51
- let [$popover, $arrow] = _ref4;
47
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
52
48
  const popoverRect = $popover.get(0).getBoundingClientRect();
53
49
  const arrowRect = $arrow.get(0).getBoundingClientRect();
54
50
  const arrowCenterY = arrowRect.top + arrowRect.height / 2;
@@ -56,8 +52,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
56
52
  });
57
53
  });
58
54
  (0, _cypressCucumberPreprocessor.Then)('the Arrow is at the left of the Popper', () => {
59
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref5 => {
60
- let [$popover, $arrow] = _ref5;
55
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
61
56
  const popoverRect = $popover.get(0).getBoundingClientRect();
62
57
  const arrowRect = $arrow.get(0).getBoundingClientRect();
63
58
  const arrowCenterX = arrowRect.left + arrowRect.width / 2;
@@ -65,8 +60,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
65
60
  });
66
61
  });
67
62
  (0, _cypressCucumberPreprocessor.Then)('the Arrow is at the top of the Popper', () => {
68
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref6 => {
69
- let [$popover, $arrow] = _ref6;
63
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
70
64
  const popoverRect = $popover.get(0).getBoundingClientRect();
71
65
  const arrowRect = $arrow.get(0).getBoundingClientRect();
72
66
  const arrowCenterY = arrowRect.top + arrowRect.height / 2;
@@ -74,8 +68,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
74
68
  });
75
69
  });
76
70
  (0, _cypressCucumberPreprocessor.Then)('the Arrow is at the right of the Popper', () => {
77
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref7 => {
78
- let [$popover, $arrow] = _ref7;
71
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
79
72
  const popoverRect = $popover.get(0).getBoundingClientRect();
80
73
  const arrowRect = $arrow.get(0).getBoundingClientRect();
81
74
  const arrowCenterX = arrowRect.left + arrowRect.width / 2;
@@ -83,8 +76,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
83
76
  });
84
77
  });
85
78
  (0, _cypressCucumberPreprocessor.Then)('the Arrow is at the top half of the Popper', () => {
86
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref8 => {
87
- let [$popover, $arrow] = _ref8;
79
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
88
80
  const popoverRect = $popover.get(0).getBoundingClientRect();
89
81
  const arrowRect = $arrow.get(0).getBoundingClientRect();
90
82
  const popoverCenterY = popoverRect.top + popoverRect.height / 2;
@@ -14,10 +14,9 @@ const computeArrowPadding = () => {
14
14
  const padding = BORDER_RADIUS + overflowInPx;
15
15
  return Math.ceil(padding);
16
16
  };
17
- const hideArrowWhenDisplaced = _ref => {
18
- let {
19
- state
20
- } = _ref;
17
+ const hideArrowWhenDisplaced = ({
18
+ state
19
+ }) => {
21
20
  const halfArrow = _arrow.ARROW_SIZE / 2;
22
21
  const displacement = state.modifiersData.preventOverflow;
23
22
  const referenceRect = state.rects.reference;
@@ -7,8 +7,7 @@ exports.default = exports.WithOnClickOutside = exports.ShiftedArrow = exports.Pl
7
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _popover = require("./popover.js");
10
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
12
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
14
13
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -28,8 +27,8 @@ const referenceElementStyle = {
28
27
  padding: 6
29
28
  };
30
29
  class PopperInBoxWithCenteredReferenceElement extends _react.Component {
31
- constructor() {
32
- super(...arguments);
30
+ constructor(...args) {
31
+ super(...args);
33
32
  _defineProperty(this, "ref", /*#__PURE__*/(0, _react.createRef)());
34
33
  }
35
34
  render() {
@@ -12,24 +12,22 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
  var _arrow = require("./arrow.js");
14
14
  var _modifiers = require("./modifiers.js");
15
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
17
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
19
- const Popover = _ref => {
20
- let {
21
- children,
22
- reference,
23
- arrow = true,
24
- className,
25
- dataTest = 'dhis2-uicore-popover',
26
- elevation = _uiConstants.elevations.popover,
27
- maxWidth = 360,
28
- observePopperResize,
29
- observeReferenceResize,
30
- placement = 'top',
31
- onClickOutside
32
- } = _ref;
18
+ const Popover = ({
19
+ children,
20
+ reference,
21
+ arrow = true,
22
+ className,
23
+ dataTest = 'dhis2-uicore-popover',
24
+ elevation = _uiConstants.elevations.popover,
25
+ maxWidth = 360,
26
+ observePopperResize,
27
+ observeReferenceResize,
28
+ placement = 'top',
29
+ onClickOutside
30
+ }) => {
33
31
  const referenceElement = (0, _popper.getReferenceElement)(reference);
34
32
  const [popperElement, setPopperElement] = (0, _react.useState)(null);
35
33
  const [arrowElement, setArrowElement] = (0, _react.useState)(null);
@@ -7,8 +7,7 @@ exports.default = exports.NoArrow = exports.Default = exports.Customization = vo
7
7
  var _uiConstants = require("@dhis2/ui-constants");
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _popover = require("./popover.js");
10
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
11
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
13
12
  const subtitle = `Useful to give a user more information or possible actions without disrupting a page or flow`;
14
13
  const description = `
package/build/es/arrow.js CHANGED
@@ -5,24 +5,21 @@ import PropTypes from 'prop-types';
5
5
  import React, { forwardRef } from 'react';
6
6
  import { getArrowPosition } from './get-arrow-position.js';
7
7
  const ARROW_SIZE = 8;
8
- const Arrow = /*#__PURE__*/forwardRef((_ref, ref) => {
9
- let {
10
- hidden,
11
- popperPlacement,
12
- styles
13
- } = _ref;
14
- return /*#__PURE__*/React.createElement("div", {
15
- "data-test": "dhis2-uicore-popoverarrow",
16
- style: styles,
17
- ref: ref,
18
- className: _JSXStyle.dynamic([["1397459397", [ARROW_SIZE, ARROW_SIZE, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, colors.white, colors.white]]]) + " " + (cx(getArrowPosition(popperPlacement), {
19
- hidden
20
- }) || "")
21
- }, /*#__PURE__*/React.createElement(_JSXStyle, {
22
- id: "1397459397",
23
- dynamic: [ARROW_SIZE, ARROW_SIZE, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, colors.white, colors.white]
24
- }, [`div.__jsx-style-dynamic-selector{width:${ARROW_SIZE}px;height:${ARROW_SIZE}px;position:absolute;}`, `div.top.__jsx-style-dynamic-selector{top:-${ARROW_SIZE / 2}px;}`, `div.right.__jsx-style-dynamic-selector{right:-${ARROW_SIZE / 2}px;}`, `div.bottom.__jsx-style-dynamic-selector{bottom:-${ARROW_SIZE / 2}px;}`, `div.left.__jsx-style-dynamic-selector{left:-${ARROW_SIZE / 2}px;}`, "div.hidden.__jsx-style-dynamic-selector{visibility:hidden;}", `div.__jsx-style-dynamic-selector::after{content:'';position:absolute;pointer-events:none;box-sizing:border-box;border-style:solid;border-width:${ARROW_SIZE / 2}px;border-color:transparent transparent ${colors.white} ${colors.white};box-shadow:-1px 1px 1px 0 rgba(64,75,90,0.08), -3px 3px 8px -6px rgba(64,75,90,0.15);}`, "div.bottom.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);}", "div.top.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);}", "div.right.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg);}", "div.left.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);}"]));
25
- });
8
+ const Arrow = /*#__PURE__*/forwardRef(({
9
+ hidden,
10
+ popperPlacement,
11
+ styles
12
+ }, ref) => /*#__PURE__*/React.createElement("div", {
13
+ "data-test": "dhis2-uicore-popoverarrow",
14
+ style: styles,
15
+ ref: ref,
16
+ className: _JSXStyle.dynamic([["1397459397", [ARROW_SIZE, ARROW_SIZE, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, colors.white, colors.white]]]) + " " + (cx(getArrowPosition(popperPlacement), {
17
+ hidden
18
+ }) || "")
19
+ }, /*#__PURE__*/React.createElement(_JSXStyle, {
20
+ id: "1397459397",
21
+ dynamic: [ARROW_SIZE, ARROW_SIZE, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, ARROW_SIZE / 2, colors.white, colors.white]
22
+ }, [`div.__jsx-style-dynamic-selector{width:${ARROW_SIZE}px;height:${ARROW_SIZE}px;position:absolute;}`, `div.top.__jsx-style-dynamic-selector{top:-${ARROW_SIZE / 2}px;}`, `div.right.__jsx-style-dynamic-selector{right:-${ARROW_SIZE / 2}px;}`, `div.bottom.__jsx-style-dynamic-selector{bottom:-${ARROW_SIZE / 2}px;}`, `div.left.__jsx-style-dynamic-selector{left:-${ARROW_SIZE / 2}px;}`, "div.hidden.__jsx-style-dynamic-selector{visibility:hidden;}", `div.__jsx-style-dynamic-selector::after{content:'';position:absolute;pointer-events:none;box-sizing:border-box;border-style:solid;border-width:${ARROW_SIZE / 2}px;border-color:transparent transparent ${colors.white} ${colors.white};box-shadow:-1px 1px 1px 0 rgba(64,75,90,0.08), -3px 3px 8px -6px rgba(64,75,90,0.15);}`, "div.bottom.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);}", "div.top.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);}", "div.right.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg);}", "div.left.__jsx-style-dynamic-selector::after{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);}"])));
26
23
  Arrow.displayName = 'Arrow';
27
24
  Arrow.propTypes = {
28
25
  hidden: PropTypes.bool,
@@ -15,8 +15,7 @@ Given('a Popover with position left is shifted into view', () => {
15
15
  cy.visitStory('Popover', 'Shifted Arrow');
16
16
  });
17
17
  Then('the Arrow is horizontally aligned with the Popper', () => {
18
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref => {
19
- let [$popover, $arrow] = _ref;
18
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
20
19
  const popoverRect = $popover.get(0).getBoundingClientRect();
21
20
  const arrowRect = $arrow.get(0).getBoundingClientRect();
22
21
  const popoverCenterX = popoverRect.left + popoverRect.width / 2;
@@ -25,8 +24,7 @@ Then('the Arrow is horizontally aligned with the Popper', () => {
25
24
  });
26
25
  });
27
26
  Then('the Arrow is vertically aligned with the Popper', () => {
28
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref2 => {
29
- let [$popover, $arrow] = _ref2;
27
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
30
28
  const popoverRect = $popover.get(0).getBoundingClientRect();
31
29
  const arrowRect = $arrow.get(0).getBoundingClientRect();
32
30
  const popoverCenterY = popoverRect.top + popoverRect.height / 2;
@@ -35,8 +33,7 @@ Then('the Arrow is vertically aligned with the Popper', () => {
35
33
  });
36
34
  });
37
35
  Then('the Arrow is vertically aligned with the reference element', () => {
38
- cy.all(() => cy.get('[data-test="reference-element"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref3 => {
39
- let [$reference, $arrow] = _ref3;
36
+ cy.all(() => cy.get('[data-test="reference-element"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$reference, $arrow]) => {
40
37
  const referenceRect = $reference.get(0).getBoundingClientRect();
41
38
  const arrowRect = $arrow.get(0).getBoundingClientRect();
42
39
  const referenceCenterY = referenceRect.top + referenceRect.height / 2;
@@ -45,8 +42,7 @@ Then('the Arrow is vertically aligned with the reference element', () => {
45
42
  });
46
43
  });
47
44
  Then('the Arrow is at the bottom of the Popper', () => {
48
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref4 => {
49
- let [$popover, $arrow] = _ref4;
45
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
50
46
  const popoverRect = $popover.get(0).getBoundingClientRect();
51
47
  const arrowRect = $arrow.get(0).getBoundingClientRect();
52
48
  const arrowCenterY = arrowRect.top + arrowRect.height / 2;
@@ -54,8 +50,7 @@ Then('the Arrow is at the bottom of the Popper', () => {
54
50
  });
55
51
  });
56
52
  Then('the Arrow is at the left of the Popper', () => {
57
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref5 => {
58
- let [$popover, $arrow] = _ref5;
53
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
59
54
  const popoverRect = $popover.get(0).getBoundingClientRect();
60
55
  const arrowRect = $arrow.get(0).getBoundingClientRect();
61
56
  const arrowCenterX = arrowRect.left + arrowRect.width / 2;
@@ -63,8 +58,7 @@ Then('the Arrow is at the left of the Popper', () => {
63
58
  });
64
59
  });
65
60
  Then('the Arrow is at the top of the Popper', () => {
66
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref6 => {
67
- let [$popover, $arrow] = _ref6;
61
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
68
62
  const popoverRect = $popover.get(0).getBoundingClientRect();
69
63
  const arrowRect = $arrow.get(0).getBoundingClientRect();
70
64
  const arrowCenterY = arrowRect.top + arrowRect.height / 2;
@@ -72,8 +66,7 @@ Then('the Arrow is at the top of the Popper', () => {
72
66
  });
73
67
  });
74
68
  Then('the Arrow is at the right of the Popper', () => {
75
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref7 => {
76
- let [$popover, $arrow] = _ref7;
69
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
77
70
  const popoverRect = $popover.get(0).getBoundingClientRect();
78
71
  const arrowRect = $arrow.get(0).getBoundingClientRect();
79
72
  const arrowCenterX = arrowRect.left + arrowRect.width / 2;
@@ -81,8 +74,7 @@ Then('the Arrow is at the right of the Popper', () => {
81
74
  });
82
75
  });
83
76
  Then('the Arrow is at the top half of the Popper', () => {
84
- cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref8 => {
85
- let [$popover, $arrow] = _ref8;
77
+ cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(([$popover, $arrow]) => {
86
78
  const popoverRect = $popover.get(0).getBoundingClientRect();
87
79
  const arrowRect = $arrow.get(0).getBoundingClientRect();
88
80
  const popoverCenterY = popoverRect.top + popoverRect.height / 2;
@@ -8,10 +8,9 @@ const computeArrowPadding = () => {
8
8
  const padding = BORDER_RADIUS + overflowInPx;
9
9
  return Math.ceil(padding);
10
10
  };
11
- const hideArrowWhenDisplaced = _ref => {
12
- let {
13
- state
14
- } = _ref;
11
+ const hideArrowWhenDisplaced = ({
12
+ state
13
+ }) => {
15
14
  const halfArrow = ARROW_SIZE / 2;
16
15
  const displacement = state.modifiersData.preventOverflow;
17
16
  const referenceRect = state.rects.reference;
@@ -19,8 +19,8 @@ const referenceElementStyle = {
19
19
  padding: 6
20
20
  };
21
21
  class PopperInBoxWithCenteredReferenceElement extends Component {
22
- constructor() {
23
- super(...arguments);
22
+ constructor(...args) {
23
+ super(...args);
24
24
  _defineProperty(this, "ref", /*#__PURE__*/createRef());
25
25
  }
26
26
  render() {
@@ -7,20 +7,19 @@ import PropTypes from 'prop-types';
7
7
  import React, { useState, useMemo } from 'react';
8
8
  import { Arrow } from './arrow.js';
9
9
  import { combineModifiers } from './modifiers.js';
10
- const Popover = _ref => {
11
- let {
12
- children,
13
- reference,
14
- arrow = true,
15
- className,
16
- dataTest = 'dhis2-uicore-popover',
17
- elevation = elevations.popover,
18
- maxWidth = 360,
19
- observePopperResize,
20
- observeReferenceResize,
21
- placement = 'top',
22
- onClickOutside
23
- } = _ref;
10
+ const Popover = ({
11
+ children,
12
+ reference,
13
+ arrow = true,
14
+ className,
15
+ dataTest = 'dhis2-uicore-popover',
16
+ elevation = elevations.popover,
17
+ maxWidth = 360,
18
+ observePopperResize,
19
+ observeReferenceResize,
20
+ placement = 'top',
21
+ onClickOutside
22
+ }) => {
24
23
  const referenceElement = getReferenceElement(reference);
25
24
  const [popperElement, setPopperElement] = useState(null);
26
25
  const [arrowElement, setArrowElement] = useState(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/popover",
3
- "version": "10.16.3",
3
+ "version": "10.16.4",
4
4
  "description": "UI Popover",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,9 +33,9 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2-ui/layer": "10.16.3",
37
- "@dhis2-ui/popper": "10.16.3",
38
- "@dhis2/ui-constants": "10.16.3",
36
+ "@dhis2-ui/layer": "10.16.4",
37
+ "@dhis2-ui/popper": "10.16.4",
38
+ "@dhis2/ui-constants": "10.16.4",
39
39
  "classnames": "^2.3.1",
40
40
  "prop-types": "^15.7.2"
41
41
  },