@dhis2-ui/popper 10.16.3-alpha.1 → 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.
@@ -11,16 +11,14 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
11
11
  cy.visitStory('Popper', 'Virtual Element As Reference');
12
12
  });
13
13
  (0, _cypressCucumberPreprocessor.Then)('the left of the popper is aligned with the left of the reference element', () => {
14
- cy.all(() => cy.get('button:contains("Reference")'), () => cy.get('[data-test="dhis2-uicore-popper"]')).should(_ref => {
15
- let [$reference, $popper] = _ref;
14
+ cy.all(() => cy.get('button:contains("Reference")'), () => cy.get('[data-test="dhis2-uicore-popper"]')).should(([$reference, $popper]) => {
16
15
  const referenceRect = $reference.get(0).getBoundingClientRect();
17
16
  const popperRect = $popper.get(0).getBoundingClientRect();
18
17
  expect(referenceRect.left).to.be.closeTo(popperRect.left, 1);
19
18
  });
20
19
  });
21
20
  (0, _cypressCucumberPreprocessor.Then)('the top of the popper is adjacent to the bottom of the reference element', () => {
22
- cy.all(() => cy.get('button:contains("Reference")'), () => cy.get('[data-test="dhis2-uicore-popper"]')).should(_ref2 => {
23
- let [$button, $popper] = _ref2;
21
+ cy.all(() => cy.get('button:contains("Reference")'), () => cy.get('[data-test="dhis2-uicore-popper"]')).should(([$button, $popper]) => {
24
22
  const buttonRect = $button.get(0).getBoundingClientRect();
25
23
  const popperRect = $popper.get(0).getBoundingClientRect();
26
24
  expect(buttonRect.bottom).to.be.closeTo(popperRect.top, 1);
@@ -42,29 +42,25 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
42
42
  // Directional assertions
43
43
  // top
44
44
  (0, _cypressCucumberPreprocessor.Then)('the bottom of the popper is adjacent to the top of the reference element', () => {
45
- getRefAndPopperPositions().should(_ref => {
46
- let [refPos, popperPos] = _ref;
45
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
47
46
  expect(refPos.top).to.equal(popperPos.bottom);
48
47
  });
49
48
  });
50
49
  // right
51
50
  (0, _cypressCucumberPreprocessor.Then)('the left of the popper is adjacent to the right of the reference element', () => {
52
- getRefAndPopperPositions().should(_ref2 => {
53
- let [refPos, popperPos] = _ref2;
51
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
54
52
  expect(refPos.right).to.equal(popperPos.left);
55
53
  });
56
54
  });
57
55
  // bottom
58
56
  (0, _cypressCucumberPreprocessor.Then)('the top of the popper is adjacent to the bottom of the reference element', () => {
59
- getRefAndPopperPositions().should(_ref3 => {
60
- let [refPos, popperPos] = _ref3;
57
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
61
58
  expect(refPos.bottom).to.equal(popperPos.top);
62
59
  });
63
60
  });
64
61
  // left
65
62
  (0, _cypressCucumberPreprocessor.Then)('the right of the popper is adjacent to the left of the reference element', () => {
66
- getRefAndPopperPositions().should(_ref4 => {
67
- let [refPos, popperPos] = _ref4;
63
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
68
64
  expect(refPos.left).to.equal(popperPos.right);
69
65
  });
70
66
  });
@@ -72,15 +68,13 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
72
68
  // Horizontal alignments
73
69
  // *-start
74
70
  (0, _cypressCucumberPreprocessor.Then)('it is horizontally left aligned with the reference element', () => {
75
- getRefAndPopperPositions().should(_ref5 => {
76
- let [refPos, popperPos] = _ref5;
71
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
77
72
  expect(refPos.left).to.equal(popperPos.left);
78
73
  });
79
74
  });
80
75
  // * (no suffix)
81
76
  (0, _cypressCucumberPreprocessor.Then)('it is horizontally center aligned with the reference element', () => {
82
- getRefAndPopperPositions().should(_ref6 => {
83
- let [refPos, popperPos] = _ref6;
77
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
84
78
  const refCenterX = refPos.left + refPos.width / 2;
85
79
  const popperCenterX = popperPos.left + popperPos.width / 2;
86
80
  expect(refCenterX).to.equal(popperCenterX);
@@ -88,8 +82,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
88
82
  });
89
83
  // *-end
90
84
  (0, _cypressCucumberPreprocessor.Then)('it is horizontally right aligned with the reference element', () => {
91
- getRefAndPopperPositions().should(_ref7 => {
92
- let [refPos, popperPos] = _ref7;
85
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
93
86
  expect(refPos.right).to.equal(popperPos.right);
94
87
  });
95
88
  });
@@ -97,15 +90,13 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
97
90
  // Vertical alignments
98
91
  // *-start
99
92
  (0, _cypressCucumberPreprocessor.Then)('it is vertically top aligned with the reference element', () => {
100
- getRefAndPopperPositions().should(_ref8 => {
101
- let [refPos, popperPos] = _ref8;
93
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
102
94
  expect(refPos.top).to.equal(popperPos.top);
103
95
  });
104
96
  });
105
97
  // * (no suffix)
106
98
  (0, _cypressCucumberPreprocessor.Then)('it is vertically center aligned with the reference element', () => {
107
- getRefAndPopperPositions().should(_ref9 => {
108
- let [refPos, popperPos] = _ref9;
99
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
109
100
  const refCenterY = refPos.top + refPos.height / 2;
110
101
  const popperCenterY = popperPos.top + popperPos.height / 2;
111
102
  expect(refCenterY).to.equal(popperCenterY);
@@ -113,8 +104,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
113
104
  });
114
105
  // *-end
115
106
  (0, _cypressCucumberPreprocessor.Then)('it is vertically bottom aligned with the reference element', () => {
116
- getRefAndPopperPositions().should(_ref10 => {
117
- let [refPos, popperPos] = _ref10;
107
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
118
108
  expect(refPos.bottom).to.equal(popperPos.bottom);
119
109
  });
120
110
  });
@@ -6,16 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.resizeObserver = exports.getBaseModifiers = exports.deduplicateModifiers = void 0;
7
7
  var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- const attachResizeObservers = _ref => {
10
- let {
11
- state: {
12
- elements
13
- },
14
- options,
15
- instance: {
16
- update
17
- }
18
- } = _ref;
9
+ const attachResizeObservers = ({
10
+ state: {
11
+ elements
12
+ },
13
+ options,
14
+ instance: {
15
+ update
16
+ }
17
+ }) => {
19
18
  const observers = Object.keys(options).reduce((acc, elementKey) => {
20
19
  if (options[elementKey]) {
21
20
  const observer = new _resizeObserverPolyfill.default(update);
@@ -30,47 +29,41 @@ const attachResizeObservers = _ref => {
30
29
  });
31
30
  };
32
31
  };
33
- const getBaseModifiers = _ref2 => {
34
- let {
35
- observePopperResize,
36
- observeReferenceResize
37
- } = _ref2;
38
- return [{
39
- name: 'preventOverflow',
40
- options: {
41
- altAxis: true,
42
- rootBoundary: 'document',
43
- boundary: document.body
44
- }
45
- }, {
46
- name: 'flip',
47
- options: {
48
- rootBoundary: 'document',
49
- boundary: document.body
50
- }
51
- }, {
52
- name: 'resizeObserver',
53
- enabled: true,
54
- phase: 'write',
55
- fn: () => {},
56
- effect: attachResizeObservers,
57
- options: {
58
- popper: observePopperResize,
59
- reference: observeReferenceResize
60
- }
61
- }];
62
- };
32
+ const getBaseModifiers = ({
33
+ observePopperResize,
34
+ observeReferenceResize
35
+ }) => [{
36
+ name: 'preventOverflow',
37
+ options: {
38
+ altAxis: true,
39
+ rootBoundary: 'document',
40
+ boundary: document.body
41
+ }
42
+ }, {
43
+ name: 'flip',
44
+ options: {
45
+ rootBoundary: 'document',
46
+ boundary: document.body
47
+ }
48
+ }, {
49
+ name: 'resizeObserver',
50
+ enabled: true,
51
+ phase: 'write',
52
+ fn: () => {},
53
+ effect: attachResizeObservers,
54
+ options: {
55
+ popper: observePopperResize,
56
+ reference: observeReferenceResize
57
+ }
58
+ }];
63
59
  exports.getBaseModifiers = getBaseModifiers;
64
60
  const deduplicateModifiers = (modifiers, resizeObservers) => {
65
61
  // Deduplicate modifiers from props and baseModifiers,
66
62
  // when duplicates are encountered (by name), use the
67
63
  // modifier from props so each Popper can be fully custom
68
- return getBaseModifiers(resizeObservers).filter(_ref3 => {
69
- let {
70
- name
71
- } = _ref3;
72
- return !modifiers.some(m => m.name === name);
73
- }).concat(modifiers);
64
+ return getBaseModifiers(resizeObservers).filter(({
65
+ name
66
+ }) => !modifiers.some(m => m.name === name)).concat(modifiers);
74
67
  };
75
68
  exports.deduplicateModifiers = deduplicateModifiers;
76
69
  const resizeObserver = exports.resizeObserver = {
@@ -78,16 +71,15 @@ const resizeObserver = exports.resizeObserver = {
78
71
  enabled: true,
79
72
  phase: 'write',
80
73
  fn: () => {},
81
- effect: _ref4 => {
82
- let {
83
- state: {
84
- elements
85
- },
86
- options,
87
- instance: {
88
- update
89
- }
90
- } = _ref4;
74
+ effect: ({
75
+ state: {
76
+ elements
77
+ },
78
+ options,
79
+ instance: {
80
+ update
81
+ }
82
+ }) => {
91
83
  const observers = Object.keys(options).reduce((acc, elementKey) => {
92
84
  if (options[elementKey]) {
93
85
  const observer = new _resizeObserverPolyfill.default(update);
@@ -8,13 +8,11 @@ var _style = _interopRequireDefault(require("styled-jsx/style"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _popper = require("./popper.js");
11
- 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); }
12
- 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; }
11
+ 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); }
13
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- const PopperPlacement = _ref => {
15
- let {
16
- placement
17
- } = _ref;
13
+ const PopperPlacement = ({
14
+ placement
15
+ }) => {
18
16
  const ref = (0, _react.useRef)();
19
17
  return /*#__PURE__*/_react.default.createElement("div", {
20
18
  className: "jsx-305551169" + " " + "box"
@@ -10,8 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactPopper = require("react-popper");
11
11
  var _getReferenceElement = require("./get-reference-element.js");
12
12
  var _modifiers = require("./modifiers.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
  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); }
17
16
  const flipPlacement = placement => {
@@ -26,19 +25,18 @@ const flipPlacement = placement => {
26
25
 
27
26
  // Stable object reference
28
27
  const staticArray = [];
29
- const Popper = _ref => {
30
- let {
31
- children,
32
- className,
33
- dataTest = 'dhis2-uicore-popper',
34
- modifiers = staticArray,
35
- observePopperResize,
36
- observeReferenceResize,
37
- onFirstUpdate,
38
- placement = 'auto',
39
- reference,
40
- strategy
41
- } = _ref;
28
+ const Popper = ({
29
+ children,
30
+ className,
31
+ dataTest = 'dhis2-uicore-popper',
32
+ modifiers = staticArray,
33
+ observePopperResize,
34
+ observeReferenceResize,
35
+ onFirstUpdate,
36
+ placement = 'auto',
37
+ reference,
38
+ strategy
39
+ }) => {
42
40
  const referenceElement = (0, _getReferenceElement.getReferenceElement)(reference);
43
41
  const [popperElement, setPopperElement] = (0, _react.useState)(null);
44
42
  const deduplicatedModifiers = (0, _react.useMemo)(() => (0, _modifiers.deduplicateModifiers)(modifiers, {
@@ -57,7 +55,7 @@ const Popper = _ref => {
57
55
  (0, _react.useEffect)(() => {
58
56
  if (popperElement) {
59
57
  var _popperElement$firstE;
60
- popperElement === null || popperElement === void 0 ? void 0 : (_popperElement$firstE = popperElement.firstElementChild) === null || _popperElement$firstE === void 0 ? void 0 : _popperElement$firstE.focus();
58
+ popperElement === null || popperElement === void 0 || (_popperElement$firstE = popperElement.firstElementChild) === null || _popperElement$firstE === void 0 || _popperElement$firstE.focus();
61
59
  }
62
60
  }, [popperElement]);
63
61
  return /*#__PURE__*/_react.default.createElement("div", _extends({
@@ -7,8 +7,7 @@ exports.default = exports.VirtualElementRef = exports.TopStart = exports.TopEnd
7
7
  var _uiConstants = require("@dhis2/ui-constants");
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _popper = require("./popper.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 description = `
14
13
  A tool for adding additional information or content outside of the document flow, used for example in the Tooltip or Popover components.
@@ -9,16 +9,14 @@ Given('a Popper with placement bottom-start has a virtual element as its referen
9
9
  cy.visitStory('Popper', 'Virtual Element As Reference');
10
10
  });
11
11
  Then('the left of the popper is aligned with the left of the reference element', () => {
12
- cy.all(() => cy.get('button:contains("Reference")'), () => cy.get('[data-test="dhis2-uicore-popper"]')).should(_ref => {
13
- let [$reference, $popper] = _ref;
12
+ cy.all(() => cy.get('button:contains("Reference")'), () => cy.get('[data-test="dhis2-uicore-popper"]')).should(([$reference, $popper]) => {
14
13
  const referenceRect = $reference.get(0).getBoundingClientRect();
15
14
  const popperRect = $popper.get(0).getBoundingClientRect();
16
15
  expect(referenceRect.left).to.be.closeTo(popperRect.left, 1);
17
16
  });
18
17
  });
19
18
  Then('the top of the popper is adjacent to the bottom of the reference element', () => {
20
- cy.all(() => cy.get('button:contains("Reference")'), () => cy.get('[data-test="dhis2-uicore-popper"]')).should(_ref2 => {
21
- let [$button, $popper] = _ref2;
19
+ cy.all(() => cy.get('button:contains("Reference")'), () => cy.get('[data-test="dhis2-uicore-popper"]')).should(([$button, $popper]) => {
22
20
  const buttonRect = $button.get(0).getBoundingClientRect();
23
21
  const popperRect = $popper.get(0).getBoundingClientRect();
24
22
  expect(buttonRect.bottom).to.be.closeTo(popperRect.top, 1);
@@ -41,29 +41,25 @@ Given('the Popper is rendered with placement left-end', () => {
41
41
  // Directional assertions
42
42
  // top
43
43
  Then('the bottom of the popper is adjacent to the top of the reference element', () => {
44
- getRefAndPopperPositions().should(_ref => {
45
- let [refPos, popperPos] = _ref;
44
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
46
45
  expect(refPos.top).to.equal(popperPos.bottom);
47
46
  });
48
47
  });
49
48
  // right
50
49
  Then('the left of the popper is adjacent to the right of the reference element', () => {
51
- getRefAndPopperPositions().should(_ref2 => {
52
- let [refPos, popperPos] = _ref2;
50
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
53
51
  expect(refPos.right).to.equal(popperPos.left);
54
52
  });
55
53
  });
56
54
  // bottom
57
55
  Then('the top of the popper is adjacent to the bottom of the reference element', () => {
58
- getRefAndPopperPositions().should(_ref3 => {
59
- let [refPos, popperPos] = _ref3;
56
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
60
57
  expect(refPos.bottom).to.equal(popperPos.top);
61
58
  });
62
59
  });
63
60
  // left
64
61
  Then('the right of the popper is adjacent to the left of the reference element', () => {
65
- getRefAndPopperPositions().should(_ref4 => {
66
- let [refPos, popperPos] = _ref4;
62
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
67
63
  expect(refPos.left).to.equal(popperPos.right);
68
64
  });
69
65
  });
@@ -71,15 +67,13 @@ Then('the right of the popper is adjacent to the left of the reference element',
71
67
  // Horizontal alignments
72
68
  // *-start
73
69
  Then('it is horizontally left aligned with the reference element', () => {
74
- getRefAndPopperPositions().should(_ref5 => {
75
- let [refPos, popperPos] = _ref5;
70
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
76
71
  expect(refPos.left).to.equal(popperPos.left);
77
72
  });
78
73
  });
79
74
  // * (no suffix)
80
75
  Then('it is horizontally center aligned with the reference element', () => {
81
- getRefAndPopperPositions().should(_ref6 => {
82
- let [refPos, popperPos] = _ref6;
76
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
83
77
  const refCenterX = refPos.left + refPos.width / 2;
84
78
  const popperCenterX = popperPos.left + popperPos.width / 2;
85
79
  expect(refCenterX).to.equal(popperCenterX);
@@ -87,8 +81,7 @@ Then('it is horizontally center aligned with the reference element', () => {
87
81
  });
88
82
  // *-end
89
83
  Then('it is horizontally right aligned with the reference element', () => {
90
- getRefAndPopperPositions().should(_ref7 => {
91
- let [refPos, popperPos] = _ref7;
84
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
92
85
  expect(refPos.right).to.equal(popperPos.right);
93
86
  });
94
87
  });
@@ -96,15 +89,13 @@ Then('it is horizontally right aligned with the reference element', () => {
96
89
  // Vertical alignments
97
90
  // *-start
98
91
  Then('it is vertically top aligned with the reference element', () => {
99
- getRefAndPopperPositions().should(_ref8 => {
100
- let [refPos, popperPos] = _ref8;
92
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
101
93
  expect(refPos.top).to.equal(popperPos.top);
102
94
  });
103
95
  });
104
96
  // * (no suffix)
105
97
  Then('it is vertically center aligned with the reference element', () => {
106
- getRefAndPopperPositions().should(_ref9 => {
107
- let [refPos, popperPos] = _ref9;
98
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
108
99
  const refCenterY = refPos.top + refPos.height / 2;
109
100
  const popperCenterY = popperPos.top + popperPos.height / 2;
110
101
  expect(refCenterY).to.equal(popperCenterY);
@@ -112,8 +103,7 @@ Then('it is vertically center aligned with the reference element', () => {
112
103
  });
113
104
  // *-end
114
105
  Then('it is vertically bottom aligned with the reference element', () => {
115
- getRefAndPopperPositions().should(_ref10 => {
116
- let [refPos, popperPos] = _ref10;
106
+ getRefAndPopperPositions().should(([refPos, popperPos]) => {
117
107
  expect(refPos.bottom).to.equal(popperPos.bottom);
118
108
  });
119
109
  });
@@ -1,14 +1,13 @@
1
1
  import ResizeObserver from 'resize-observer-polyfill';
2
- const attachResizeObservers = _ref => {
3
- let {
4
- state: {
5
- elements
6
- },
7
- options,
8
- instance: {
9
- update
10
- }
11
- } = _ref;
2
+ const attachResizeObservers = ({
3
+ state: {
4
+ elements
5
+ },
6
+ options,
7
+ instance: {
8
+ update
9
+ }
10
+ }) => {
12
11
  const observers = Object.keys(options).reduce((acc, elementKey) => {
13
12
  if (options[elementKey]) {
14
13
  const observer = new ResizeObserver(update);
@@ -23,62 +22,55 @@ const attachResizeObservers = _ref => {
23
22
  });
24
23
  };
25
24
  };
26
- export const getBaseModifiers = _ref2 => {
27
- let {
28
- observePopperResize,
29
- observeReferenceResize
30
- } = _ref2;
31
- return [{
32
- name: 'preventOverflow',
33
- options: {
34
- altAxis: true,
35
- rootBoundary: 'document',
36
- boundary: document.body
37
- }
38
- }, {
39
- name: 'flip',
40
- options: {
41
- rootBoundary: 'document',
42
- boundary: document.body
43
- }
44
- }, {
45
- name: 'resizeObserver',
46
- enabled: true,
47
- phase: 'write',
48
- fn: () => {},
49
- effect: attachResizeObservers,
50
- options: {
51
- popper: observePopperResize,
52
- reference: observeReferenceResize
53
- }
54
- }];
55
- };
25
+ export const getBaseModifiers = ({
26
+ observePopperResize,
27
+ observeReferenceResize
28
+ }) => [{
29
+ name: 'preventOverflow',
30
+ options: {
31
+ altAxis: true,
32
+ rootBoundary: 'document',
33
+ boundary: document.body
34
+ }
35
+ }, {
36
+ name: 'flip',
37
+ options: {
38
+ rootBoundary: 'document',
39
+ boundary: document.body
40
+ }
41
+ }, {
42
+ name: 'resizeObserver',
43
+ enabled: true,
44
+ phase: 'write',
45
+ fn: () => {},
46
+ effect: attachResizeObservers,
47
+ options: {
48
+ popper: observePopperResize,
49
+ reference: observeReferenceResize
50
+ }
51
+ }];
56
52
  export const deduplicateModifiers = (modifiers, resizeObservers) => {
57
53
  // Deduplicate modifiers from props and baseModifiers,
58
54
  // when duplicates are encountered (by name), use the
59
55
  // modifier from props so each Popper can be fully custom
60
- return getBaseModifiers(resizeObservers).filter(_ref3 => {
61
- let {
62
- name
63
- } = _ref3;
64
- return !modifiers.some(m => m.name === name);
65
- }).concat(modifiers);
56
+ return getBaseModifiers(resizeObservers).filter(({
57
+ name
58
+ }) => !modifiers.some(m => m.name === name)).concat(modifiers);
66
59
  };
67
60
  export const resizeObserver = {
68
61
  name: 'resizeObserver',
69
62
  enabled: true,
70
63
  phase: 'write',
71
64
  fn: () => {},
72
- effect: _ref4 => {
73
- let {
74
- state: {
75
- elements
76
- },
77
- options,
78
- instance: {
79
- update
80
- }
81
- } = _ref4;
65
+ effect: ({
66
+ state: {
67
+ elements
68
+ },
69
+ options,
70
+ instance: {
71
+ update
72
+ }
73
+ }) => {
82
74
  const observers = Object.keys(options).reduce((acc, elementKey) => {
83
75
  if (options[elementKey]) {
84
76
  const observer = new ResizeObserver(update);
@@ -2,10 +2,9 @@ import _JSXStyle from "styled-jsx/style";
2
2
  import PropTypes from 'prop-types';
3
3
  import React, { useRef, useState } from 'react';
4
4
  import { Popper } from './popper.js';
5
- const PopperPlacement = _ref => {
6
- let {
7
- placement
8
- } = _ref;
5
+ const PopperPlacement = ({
6
+ placement
7
+ }) => {
9
8
  const ref = useRef();
10
9
  return /*#__PURE__*/React.createElement("div", {
11
10
  className: "jsx-305551169" + " " + "box"
@@ -17,19 +17,18 @@ const flipPlacement = placement => {
17
17
 
18
18
  // Stable object reference
19
19
  const staticArray = [];
20
- const Popper = _ref => {
21
- let {
22
- children,
23
- className,
24
- dataTest = 'dhis2-uicore-popper',
25
- modifiers = staticArray,
26
- observePopperResize,
27
- observeReferenceResize,
28
- onFirstUpdate,
29
- placement = 'auto',
30
- reference,
31
- strategy
32
- } = _ref;
20
+ const Popper = ({
21
+ children,
22
+ className,
23
+ dataTest = 'dhis2-uicore-popper',
24
+ modifiers = staticArray,
25
+ observePopperResize,
26
+ observeReferenceResize,
27
+ onFirstUpdate,
28
+ placement = 'auto',
29
+ reference,
30
+ strategy
31
+ }) => {
33
32
  const referenceElement = getReferenceElement(reference);
34
33
  const [popperElement, setPopperElement] = useState(null);
35
34
  const deduplicatedModifiers = useMemo(() => deduplicateModifiers(modifiers, {
@@ -48,7 +47,7 @@ const Popper = _ref => {
48
47
  useEffect(() => {
49
48
  if (popperElement) {
50
49
  var _popperElement$firstE;
51
- popperElement === null || popperElement === void 0 ? void 0 : (_popperElement$firstE = popperElement.firstElementChild) === null || _popperElement$firstE === void 0 ? void 0 : _popperElement$firstE.focus();
50
+ popperElement === null || popperElement === void 0 || (_popperElement$firstE = popperElement.firstElementChild) === null || _popperElement$firstE === void 0 || _popperElement$firstE.focus();
52
51
  }
53
52
  }, [popperElement]);
54
53
  return /*#__PURE__*/React.createElement("div", _extends({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/popper",
3
- "version": "10.16.3-alpha.1",
3
+ "version": "10.16.4",
4
4
  "description": "UI Popper",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2/ui-constants": "10.16.3-alpha.1",
36
+ "@dhis2/ui-constants": "10.16.4",
37
37
  "@popperjs/core": "^2.11.8",
38
38
  "classnames": "^2.3.1",
39
39
  "prop-types": "^15.7.2",