@dhis2-ui/popover 8.2.0 → 8.2.3
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/build/cjs/arrow.js +19 -16
- package/build/cjs/features/arrow_position/index.js +16 -8
- package/build/cjs/modifiers.js +4 -3
- package/build/cjs/popover.js +15 -14
- package/build/cjs/popover.stories.e2e.js +3 -3
- package/build/cjs/popover.stories.js +4 -20
- package/build/es/arrow.js +18 -15
- package/build/es/features/arrow_position/index.js +16 -8
- package/build/es/modifiers.js +4 -3
- package/build/es/popover.js +15 -14
- package/build/es/popover.stories.e2e.js +2 -2
- package/build/es/popover.stories.js +3 -19
- package/package.json +4 -4
package/build/cjs/arrow.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.Arrow = exports.ARROW_SIZE = void 0;
|
|
7
7
|
|
|
8
8
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
9
|
|
|
@@ -25,21 +25,24 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
|
|
26
26
|
const ARROW_SIZE = 8;
|
|
27
27
|
exports.ARROW_SIZE = ARROW_SIZE;
|
|
28
|
-
const Arrow = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
const Arrow = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
29
|
+
let {
|
|
30
|
+
hidden,
|
|
31
|
+
popperPlacement,
|
|
32
|
+
styles
|
|
33
|
+
} = _ref;
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
35
|
+
"data-test": "dhis2-uicore-popoverarrow",
|
|
36
|
+
style: styles,
|
|
37
|
+
ref: ref,
|
|
38
|
+
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), {
|
|
39
|
+
hidden
|
|
40
|
+
}) || "")
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
42
|
+
id: "1397459397",
|
|
43
|
+
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]
|
|
44
|
+
}, ["div.__jsx-style-dynamic-selector{width:".concat(ARROW_SIZE, "px;height:").concat(ARROW_SIZE, "px;position:absolute;}"), "div.top.__jsx-style-dynamic-selector{top:-".concat(ARROW_SIZE / 2, "px;}"), "div.right.__jsx-style-dynamic-selector{right:-".concat(ARROW_SIZE / 2, "px;}"), "div.bottom.__jsx-style-dynamic-selector{bottom:-".concat(ARROW_SIZE / 2, "px;}"), "div.left.__jsx-style-dynamic-selector{left:-".concat(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:".concat(ARROW_SIZE / 2, "px;border-color:transparent transparent ").concat(_uiConstants.colors.white, " ").concat(_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);}"]));
|
|
45
|
+
});
|
|
43
46
|
exports.Arrow = Arrow;
|
|
44
47
|
Arrow.displayName = 'Arrow';
|
|
45
48
|
Arrow.propTypes = {
|
|
@@ -18,7 +18,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
18
18
|
cy.visitStory('Popover', 'Shifted Arrow');
|
|
19
19
|
});
|
|
20
20
|
(0, _steps.Then)('the Arrow is horizontally aligned with the Popper', () => {
|
|
21
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
21
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref => {
|
|
22
|
+
let [$popover, $arrow] = _ref;
|
|
22
23
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
23
24
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
24
25
|
const popoverCenterX = popoverRect.left + popoverRect.width / 2;
|
|
@@ -27,7 +28,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
27
28
|
});
|
|
28
29
|
});
|
|
29
30
|
(0, _steps.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(
|
|
31
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref2 => {
|
|
32
|
+
let [$popover, $arrow] = _ref2;
|
|
31
33
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
32
34
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
33
35
|
const popoverCenterY = popoverRect.top + popoverRect.height / 2;
|
|
@@ -36,7 +38,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
36
38
|
});
|
|
37
39
|
});
|
|
38
40
|
(0, _steps.Then)('the Arrow is vertically aligned with the reference element', () => {
|
|
39
|
-
cy.all(() => cy.get('[data-test="reference-element"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
41
|
+
cy.all(() => cy.get('[data-test="reference-element"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref3 => {
|
|
42
|
+
let [$reference, $arrow] = _ref3;
|
|
40
43
|
const referenceRect = $reference.get(0).getBoundingClientRect();
|
|
41
44
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
42
45
|
const referenceCenterY = referenceRect.top + referenceRect.height / 2;
|
|
@@ -45,7 +48,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
45
48
|
});
|
|
46
49
|
});
|
|
47
50
|
(0, _steps.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(
|
|
51
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref4 => {
|
|
52
|
+
let [$popover, $arrow] = _ref4;
|
|
49
53
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
50
54
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
51
55
|
const arrowCenterY = arrowRect.top + arrowRect.height / 2;
|
|
@@ -53,7 +57,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
53
57
|
});
|
|
54
58
|
});
|
|
55
59
|
(0, _steps.Then)('the Arrow is at the left of the Popper', () => {
|
|
56
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
60
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref5 => {
|
|
61
|
+
let [$popover, $arrow] = _ref5;
|
|
57
62
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
58
63
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
59
64
|
const arrowCenterX = arrowRect.left + arrowRect.width / 2;
|
|
@@ -61,7 +66,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
61
66
|
});
|
|
62
67
|
});
|
|
63
68
|
(0, _steps.Then)('the Arrow is at the top of the Popper', () => {
|
|
64
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
69
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref6 => {
|
|
70
|
+
let [$popover, $arrow] = _ref6;
|
|
65
71
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
66
72
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
67
73
|
const arrowCenterY = arrowRect.top + arrowRect.height / 2;
|
|
@@ -69,7 +75,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
69
75
|
});
|
|
70
76
|
});
|
|
71
77
|
(0, _steps.Then)('the Arrow is at the right of the Popper', () => {
|
|
72
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
78
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref7 => {
|
|
79
|
+
let [$popover, $arrow] = _ref7;
|
|
73
80
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
74
81
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
75
82
|
const arrowCenterX = arrowRect.left + arrowRect.width / 2;
|
|
@@ -77,7 +84,8 @@ var _steps = require("cypress-cucumber-preprocessor/steps");
|
|
|
77
84
|
});
|
|
78
85
|
});
|
|
79
86
|
(0, _steps.Then)('the Arrow is at the top half of the Popper', () => {
|
|
80
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
87
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref8 => {
|
|
88
|
+
let [$popover, $arrow] = _ref8;
|
|
81
89
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
82
90
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
83
91
|
const popoverCenterY = popoverRect.top + popoverRect.height / 2;
|
package/build/cjs/modifiers.js
CHANGED
|
@@ -19,9 +19,10 @@ const computeArrowPadding = () => {
|
|
|
19
19
|
return Math.ceil(padding);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const hideArrowWhenDisplaced =
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const hideArrowWhenDisplaced = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
state
|
|
25
|
+
} = _ref;
|
|
25
26
|
const halfArrow = _arrow.ARROW_SIZE / 2;
|
|
26
27
|
const displacement = state.modifiersData.preventOverflow;
|
|
27
28
|
const referenceRect = state.rects.reference;
|
package/build/cjs/popover.js
CHANGED
|
@@ -29,19 +29,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
29
29
|
|
|
30
30
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
31
31
|
|
|
32
|
-
const Popover =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
const Popover = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
children,
|
|
35
|
+
reference,
|
|
36
|
+
arrow,
|
|
37
|
+
className,
|
|
38
|
+
dataTest,
|
|
39
|
+
elevation,
|
|
40
|
+
maxWidth,
|
|
41
|
+
observePopperResize,
|
|
42
|
+
observeReferenceResize,
|
|
43
|
+
placement,
|
|
44
|
+
onClickOutside
|
|
45
|
+
} = _ref;
|
|
45
46
|
const referenceElement = (0, _popper.getReferenceElement)(reference);
|
|
46
47
|
const [popperElement, setPopperElement] = (0, _react.useState)(null);
|
|
47
48
|
const [arrowElement, setArrowElement] = (0, _react.useState)(null);
|
|
@@ -72,7 +73,7 @@ const Popover = ({
|
|
|
72
73
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
73
74
|
id: "632767479",
|
|
74
75
|
dynamic: [maxWidth, elevation, _uiConstants.colors.white]
|
|
75
|
-
}, [
|
|
76
|
+
}, ["div.__jsx-style-dynamic-selector{max-width:".concat(maxWidth, "px;box-shadow:").concat(elevation, ";background-color:").concat(_uiConstants.colors.white, ";border-radius:4px;}")])));
|
|
76
77
|
};
|
|
77
78
|
|
|
78
79
|
exports.Popover = Popover;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.default = exports.WithOnClickOutside = exports.ShiftedArrow = exports.PlacementTop = exports.PlacementRight = exports.PlacementLeft = exports.PlacementBottom = exports.NoArrow = exports.HiddenArrow = exports.Flipped = exports.Default = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
@@ -36,8 +36,8 @@ const referenceElementStyle = {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
class PopperInBoxWithCenteredReferenceElement extends _react.Component {
|
|
39
|
-
constructor(
|
|
40
|
-
super(...
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
41
|
|
|
42
42
|
_defineProperty(this, "ref", /*#__PURE__*/(0, _react.createRef)());
|
|
43
43
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.default = exports.NoArrow = exports.Default = exports.Customization = void 0;
|
|
7
7
|
|
|
8
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
9
|
|
|
@@ -17,26 +17,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
17
17
|
|
|
18
18
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
19
|
|
|
20
|
-
const subtitle =
|
|
21
|
-
const description =
|
|
22
|
-
Popovers are similar to tooltips: they are for displaying extra information, but popovers are intended for richer information and actions.
|
|
23
|
-
|
|
24
|
-
Popovers are triggered by hovering or tapping on an element. Clicking on a element keeps the popover open until the user clicks or interacts elsewhere on the page.
|
|
25
|
-
|
|
26
|
-
Popovers can contain information in the form of rich markup, as well as actions. Critical actions, or the only action on a page, should not be hidden inside a popover.
|
|
27
|
-
|
|
28
|
-
Before using a popover, consider that some users may never see the information contained within. If that is a problem, display the information right on the page instead. Do not use a popover for content that is essential to the user experience or application.
|
|
29
|
-
|
|
30
|
-
See more about Popovers at [Design System: Popover](https://github.com/dhis2/design-system/blob/master/molecules/popover.md).
|
|
31
|
-
|
|
32
|
-
\`\`\`js
|
|
33
|
-
import { Popover } from '@dhis2/ui'
|
|
34
|
-
\`\`\`
|
|
35
|
-
|
|
36
|
-
_**Note**: Due to the full-page interaction of this component, only one representative example in an iframe sandbox is shown here. See more (interactive) examples in the 'Canvas' tab._
|
|
37
|
-
`;
|
|
20
|
+
const subtitle = "Useful to give a user more information or possible actions without disrupting a page or flow";
|
|
21
|
+
const description = "\nPopovers are similar to tooltips: they are for displaying extra information, but popovers are intended for richer information and actions.\n\nPopovers are triggered by hovering or tapping on an element. Clicking on a element keeps the popover open until the user clicks or interacts elsewhere on the page.\n\nPopovers can contain information in the form of rich markup, as well as actions. Critical actions, or the only action on a page, should not be hidden inside a popover.\n\nBefore using a popover, consider that some users may never see the information contained within. If that is a problem, display the information right on the page instead. Do not use a popover for content that is essential to the user experience or application.\n\nSee more about Popovers at [Design System: Popover](https://github.com/dhis2/design-system/blob/master/molecules/popover.md).\n\n```js\nimport { Popover } from '@dhis2/ui'\n```\n\n_**Note**: Due to the full-page interaction of this component, only one representative example in an iframe sandbox is shown here. See more (interactive) examples in the 'Canvas' tab._\n";
|
|
38
22
|
var _default = {
|
|
39
|
-
title: '
|
|
23
|
+
title: 'Popover',
|
|
40
24
|
component: _popover.Popover,
|
|
41
25
|
parameters: {
|
|
42
26
|
componentSubtitle: subtitle,
|
package/build/es/arrow.js
CHANGED
|
@@ -5,21 +5,24 @@ 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(({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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:".concat(ARROW_SIZE, "px;height:").concat(ARROW_SIZE, "px;position:absolute;}"), "div.top.__jsx-style-dynamic-selector{top:-".concat(ARROW_SIZE / 2, "px;}"), "div.right.__jsx-style-dynamic-selector{right:-".concat(ARROW_SIZE / 2, "px;}"), "div.bottom.__jsx-style-dynamic-selector{bottom:-".concat(ARROW_SIZE / 2, "px;}"), "div.left.__jsx-style-dynamic-selector{left:-".concat(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:".concat(ARROW_SIZE / 2, "px;border-color:transparent transparent ").concat(colors.white, " ").concat(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
|
+
});
|
|
23
26
|
Arrow.displayName = 'Arrow';
|
|
24
27
|
Arrow.propTypes = {
|
|
25
28
|
hidden: PropTypes.bool,
|
|
@@ -15,7 +15,8 @@ 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(
|
|
18
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref => {
|
|
19
|
+
let [$popover, $arrow] = _ref;
|
|
19
20
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
20
21
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
21
22
|
const popoverCenterX = popoverRect.left + popoverRect.width / 2;
|
|
@@ -24,7 +25,8 @@ Then('the Arrow is horizontally aligned with the Popper', () => {
|
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
27
|
Then('the Arrow is vertically aligned with the Popper', () => {
|
|
27
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
28
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref2 => {
|
|
29
|
+
let [$popover, $arrow] = _ref2;
|
|
28
30
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
29
31
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
30
32
|
const popoverCenterY = popoverRect.top + popoverRect.height / 2;
|
|
@@ -33,7 +35,8 @@ Then('the Arrow is vertically aligned with the Popper', () => {
|
|
|
33
35
|
});
|
|
34
36
|
});
|
|
35
37
|
Then('the Arrow is vertically aligned with the reference element', () => {
|
|
36
|
-
cy.all(() => cy.get('[data-test="reference-element"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
38
|
+
cy.all(() => cy.get('[data-test="reference-element"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref3 => {
|
|
39
|
+
let [$reference, $arrow] = _ref3;
|
|
37
40
|
const referenceRect = $reference.get(0).getBoundingClientRect();
|
|
38
41
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
39
42
|
const referenceCenterY = referenceRect.top + referenceRect.height / 2;
|
|
@@ -42,7 +45,8 @@ Then('the Arrow is vertically aligned with the reference element', () => {
|
|
|
42
45
|
});
|
|
43
46
|
});
|
|
44
47
|
Then('the Arrow is at the bottom of the Popper', () => {
|
|
45
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
48
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref4 => {
|
|
49
|
+
let [$popover, $arrow] = _ref4;
|
|
46
50
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
47
51
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
48
52
|
const arrowCenterY = arrowRect.top + arrowRect.height / 2;
|
|
@@ -50,7 +54,8 @@ Then('the Arrow is at the bottom of the Popper', () => {
|
|
|
50
54
|
});
|
|
51
55
|
});
|
|
52
56
|
Then('the Arrow is at the left of the Popper', () => {
|
|
53
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
57
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref5 => {
|
|
58
|
+
let [$popover, $arrow] = _ref5;
|
|
54
59
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
55
60
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
56
61
|
const arrowCenterX = arrowRect.left + arrowRect.width / 2;
|
|
@@ -58,7 +63,8 @@ Then('the Arrow is at the left of the Popper', () => {
|
|
|
58
63
|
});
|
|
59
64
|
});
|
|
60
65
|
Then('the Arrow is at the top of the Popper', () => {
|
|
61
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
66
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref6 => {
|
|
67
|
+
let [$popover, $arrow] = _ref6;
|
|
62
68
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
63
69
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
64
70
|
const arrowCenterY = arrowRect.top + arrowRect.height / 2;
|
|
@@ -66,7 +72,8 @@ Then('the Arrow is at the top of the Popper', () => {
|
|
|
66
72
|
});
|
|
67
73
|
});
|
|
68
74
|
Then('the Arrow is at the right of the Popper', () => {
|
|
69
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
75
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref7 => {
|
|
76
|
+
let [$popover, $arrow] = _ref7;
|
|
70
77
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
71
78
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
72
79
|
const arrowCenterX = arrowRect.left + arrowRect.width / 2;
|
|
@@ -74,7 +81,8 @@ Then('the Arrow is at the right of the Popper', () => {
|
|
|
74
81
|
});
|
|
75
82
|
});
|
|
76
83
|
Then('the Arrow is at the top half of the Popper', () => {
|
|
77
|
-
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(
|
|
84
|
+
cy.all(() => cy.get('[data-test="dhis2-uicore-popover"]'), () => cy.get('[data-test="dhis2-uicore-popoverarrow"]')).should(_ref8 => {
|
|
85
|
+
let [$popover, $arrow] = _ref8;
|
|
78
86
|
const popoverRect = $popover.get(0).getBoundingClientRect();
|
|
79
87
|
const arrowRect = $arrow.get(0).getBoundingClientRect();
|
|
80
88
|
const popoverCenterY = popoverRect.top + popoverRect.height / 2;
|
package/build/es/modifiers.js
CHANGED
|
@@ -10,9 +10,10 @@ const computeArrowPadding = () => {
|
|
|
10
10
|
return Math.ceil(padding);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const hideArrowWhenDisplaced =
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const hideArrowWhenDisplaced = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
state
|
|
16
|
+
} = _ref;
|
|
16
17
|
const halfArrow = ARROW_SIZE / 2;
|
|
17
18
|
const displacement = state.modifiersData.preventOverflow;
|
|
18
19
|
const referenceRect = state.rects.reference;
|
package/build/es/popover.js
CHANGED
|
@@ -10,19 +10,20 @@ import React, { useState, useMemo } from 'react';
|
|
|
10
10
|
import { Arrow } from './arrow.js';
|
|
11
11
|
import { combineModifiers } from './modifiers.js';
|
|
12
12
|
|
|
13
|
-
const Popover =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
const Popover = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
children,
|
|
16
|
+
reference,
|
|
17
|
+
arrow,
|
|
18
|
+
className,
|
|
19
|
+
dataTest,
|
|
20
|
+
elevation,
|
|
21
|
+
maxWidth,
|
|
22
|
+
observePopperResize,
|
|
23
|
+
observeReferenceResize,
|
|
24
|
+
placement,
|
|
25
|
+
onClickOutside
|
|
26
|
+
} = _ref;
|
|
26
27
|
const referenceElement = getReferenceElement(reference);
|
|
27
28
|
const [popperElement, setPopperElement] = useState(null);
|
|
28
29
|
const [arrowElement, setArrowElement] = useState(null);
|
|
@@ -53,7 +54,7 @@ const Popover = ({
|
|
|
53
54
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
54
55
|
id: "632767479",
|
|
55
56
|
dynamic: [maxWidth, elevation, colors.white]
|
|
56
|
-
}, [
|
|
57
|
+
}, ["div.__jsx-style-dynamic-selector{max-width:".concat(maxWidth, "px;box-shadow:").concat(elevation, ";background-color:").concat(colors.white, ";border-radius:4px;}")])));
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
Popover.defaultProps = {
|
|
@@ -20,8 +20,8 @@ const referenceElementStyle = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
class PopperInBoxWithCenteredReferenceElement extends Component {
|
|
23
|
-
constructor(
|
|
24
|
-
super(...
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
25
|
|
|
26
26
|
_defineProperty(this, "ref", /*#__PURE__*/createRef());
|
|
27
27
|
}
|
|
@@ -3,26 +3,10 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import { elevations, sharedPropTypes } from '@dhis2/ui-constants';
|
|
4
4
|
import React, { useRef } from 'react';
|
|
5
5
|
import { Popover } from './popover.js';
|
|
6
|
-
const subtitle =
|
|
7
|
-
const description =
|
|
8
|
-
Popovers are similar to tooltips: they are for displaying extra information, but popovers are intended for richer information and actions.
|
|
9
|
-
|
|
10
|
-
Popovers are triggered by hovering or tapping on an element. Clicking on a element keeps the popover open until the user clicks or interacts elsewhere on the page.
|
|
11
|
-
|
|
12
|
-
Popovers can contain information in the form of rich markup, as well as actions. Critical actions, or the only action on a page, should not be hidden inside a popover.
|
|
13
|
-
|
|
14
|
-
Before using a popover, consider that some users may never see the information contained within. If that is a problem, display the information right on the page instead. Do not use a popover for content that is essential to the user experience or application.
|
|
15
|
-
|
|
16
|
-
See more about Popovers at [Design System: Popover](https://github.com/dhis2/design-system/blob/master/molecules/popover.md).
|
|
17
|
-
|
|
18
|
-
\`\`\`js
|
|
19
|
-
import { Popover } from '@dhis2/ui'
|
|
20
|
-
\`\`\`
|
|
21
|
-
|
|
22
|
-
_**Note**: Due to the full-page interaction of this component, only one representative example in an iframe sandbox is shown here. See more (interactive) examples in the 'Canvas' tab._
|
|
23
|
-
`;
|
|
6
|
+
const subtitle = "Useful to give a user more information or possible actions without disrupting a page or flow";
|
|
7
|
+
const description = "\nPopovers are similar to tooltips: they are for displaying extra information, but popovers are intended for richer information and actions.\n\nPopovers are triggered by hovering or tapping on an element. Clicking on a element keeps the popover open until the user clicks or interacts elsewhere on the page.\n\nPopovers can contain information in the form of rich markup, as well as actions. Critical actions, or the only action on a page, should not be hidden inside a popover.\n\nBefore using a popover, consider that some users may never see the information contained within. If that is a problem, display the information right on the page instead. Do not use a popover for content that is essential to the user experience or application.\n\nSee more about Popovers at [Design System: Popover](https://github.com/dhis2/design-system/blob/master/molecules/popover.md).\n\n```js\nimport { Popover } from '@dhis2/ui'\n```\n\n_**Note**: Due to the full-page interaction of this component, only one representative example in an iframe sandbox is shown here. See more (interactive) examples in the 'Canvas' tab._\n";
|
|
24
8
|
export default {
|
|
25
|
-
title: '
|
|
9
|
+
title: 'Popover',
|
|
26
10
|
component: Popover,
|
|
27
11
|
parameters: {
|
|
28
12
|
componentSubtitle: subtitle,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/popover",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.3",
|
|
4
4
|
"description": "UI Popover",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@dhis2/prop-types": "^3.0.0-beta.1",
|
|
35
|
-
"@dhis2-ui/layer": "8.2.
|
|
36
|
-
"@dhis2-ui/popper": "8.2.
|
|
37
|
-
"@dhis2/ui-constants": "8.2.
|
|
35
|
+
"@dhis2-ui/layer": "8.2.3",
|
|
36
|
+
"@dhis2-ui/popper": "8.2.3",
|
|
37
|
+
"@dhis2/ui-constants": "8.2.3",
|
|
38
38
|
"classnames": "^2.3.1",
|
|
39
39
|
"prop-types": "^15.7.2"
|
|
40
40
|
},
|