@dhis2-ui/cover 9.11.0 → 9.11.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/{cover.stories.e2e.js → cover.e2e.stories.js} +4 -14
- package/build/cjs/cover.js +2 -12
- package/build/cjs/{cover.stories.js → cover.prod.stories.js} +13 -20
- package/build/cjs/features/accepts_children/index.js +0 -1
- package/build/cjs/features/click_behavior/index.js +3 -3
- package/build/cjs/index.js +0 -1
- package/build/es/{cover.stories.e2e.js → cover.e2e.stories.js} +2 -0
- package/build/es/cover.js +1 -5
- package/build/es/{cover.stories.js → cover.prod.stories.js} +7 -3
- package/build/es/features/click_behavior/index.js +3 -2
- package/package.json +5 -5
|
@@ -4,18 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WithClickHandler = exports.WithChildren = exports.Blocking = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _cover = require("./cover.js");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
11
|
window.onButtonClick = window.Cypress && window.Cypress.cy.stub();
|
|
17
12
|
window.onCover = window.Cypress && window.Cypress.cy.stub();
|
|
18
|
-
var _default = {
|
|
13
|
+
var _default = exports.default = {
|
|
19
14
|
title: 'Cover',
|
|
20
15
|
component: _cover.Cover,
|
|
21
16
|
decorators: [story => /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -24,22 +19,17 @@ var _default = {
|
|
|
24
19
|
id: "1235544169"
|
|
25
20
|
}, ["div.jsx-1235544169{width:400px;height:400px;position:relative;border:1px dotted grey;}"]))]
|
|
26
21
|
};
|
|
27
|
-
exports.default = _default;
|
|
28
|
-
|
|
29
22
|
const WithChildren = () => /*#__PURE__*/_react.default.createElement(_cover.Cover, null, /*#__PURE__*/_react.default.createElement("p", null, "I am a child"));
|
|
30
|
-
|
|
31
23
|
exports.WithChildren = WithChildren;
|
|
32
|
-
|
|
33
24
|
const Blocking = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
25
|
+
"data-test": "button",
|
|
34
26
|
onClick: window.onButtonClick
|
|
35
27
|
}, "Test"), /*#__PURE__*/_react.default.createElement(_cover.Cover, null));
|
|
36
|
-
|
|
37
28
|
exports.Blocking = Blocking;
|
|
38
|
-
|
|
39
29
|
const WithClickHandler = () => /*#__PURE__*/_react.default.createElement(_cover.Cover, {
|
|
40
30
|
onClick: window.onCover
|
|
41
31
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
32
|
+
"data-test": "button",
|
|
42
33
|
onClick: window.onButtonClick
|
|
43
34
|
}, "Test"));
|
|
44
|
-
|
|
45
35
|
exports.WithClickHandler = WithClickHandler;
|
package/build/cjs/cover.js
CHANGED
|
@@ -4,26 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Cover = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
13
|
const createClickHandler = onClick => event => {
|
|
21
14
|
// don't respond to clicks that originated in the children
|
|
22
15
|
if (onClick && event.target === event.currentTarget) {
|
|
23
16
|
onClick({}, event);
|
|
24
17
|
}
|
|
25
18
|
};
|
|
26
|
-
|
|
27
19
|
const Cover = _ref => {
|
|
28
20
|
let {
|
|
29
21
|
children,
|
|
@@ -41,9 +33,8 @@ const Cover = _ref => {
|
|
|
41
33
|
}, children, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
42
34
|
id: "3798453419",
|
|
43
35
|
dynamic: [_uiConstants.layers.applicationTop]
|
|
44
|
-
}, [
|
|
36
|
+
}, [`div.__jsx-style-dynamic-selector{position:absolute;top:0;right:0;bottom:0;left:0;z-index:${_uiConstants.layers.applicationTop};}`, "div.translucent.__jsx-style-dynamic-selector{background:rgba(33,43,54,0.4);}"]));
|
|
45
37
|
};
|
|
46
|
-
|
|
47
38
|
exports.Cover = Cover;
|
|
48
39
|
Cover.defaultProps = {
|
|
49
40
|
dataTest: 'dhis2-uicore-componentcover'
|
|
@@ -52,7 +43,6 @@ Cover.propTypes = {
|
|
|
52
43
|
children: _propTypes.default.node,
|
|
53
44
|
className: _propTypes.default.string,
|
|
54
45
|
dataTest: _propTypes.default.string,
|
|
55
|
-
|
|
56
46
|
/** Adds a semi-transparent background to the cover */
|
|
57
47
|
translucent: _propTypes.default.bool,
|
|
58
48
|
onClick: _propTypes.default.func
|
|
@@ -4,19 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WithClickHandler = exports.WithCenteredContentCircularLoader = exports.Translucent = exports.Default = void 0;
|
|
7
|
-
|
|
8
7
|
var _center = require("@dhis2-ui/center");
|
|
9
|
-
|
|
10
8
|
var _loader = require("@dhis2-ui/loader");
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _cover = require("./cover.js");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const description = `
|
|
13
|
+
Covers sibling components. Useful for covering a component while it is loading.
|
|
14
|
+
|
|
15
|
+
\`\`\`js
|
|
16
|
+
import { Cover } from '@dhis2/ui'
|
|
17
|
+
\`\`\`
|
|
18
|
+
`;
|
|
19
|
+
var _default = exports.default = {
|
|
20
20
|
title: 'Component Cover',
|
|
21
21
|
component: _cover.Cover,
|
|
22
22
|
parameters: {
|
|
@@ -27,8 +27,6 @@ var _default = {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
exports.default = _default;
|
|
31
|
-
|
|
32
30
|
const Template = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
33
31
|
style: {
|
|
34
32
|
width: '400px',
|
|
@@ -37,21 +35,16 @@ const Template = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
|
37
35
|
border: '1px dotted grey'
|
|
38
36
|
}
|
|
39
37
|
}, /*#__PURE__*/_react.default.createElement(_cover.Cover, args), /*#__PURE__*/_react.default.createElement("h1", null, "Text behind the cover"), /*#__PURE__*/_react.default.createElement("p", null, "Lorem ipsum"));
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
exports.Default = Default;
|
|
43
|
-
const Translucent = Template.bind({});
|
|
44
|
-
exports.Translucent = Translucent;
|
|
38
|
+
const Default = exports.Default = Template.bind({});
|
|
39
|
+
const Translucent = exports.Translucent = Template.bind({});
|
|
45
40
|
Translucent.args = {
|
|
46
41
|
translucent: true
|
|
47
42
|
};
|
|
48
|
-
const WithClickHandler = Template.bind({});
|
|
49
|
-
exports.WithClickHandler = WithClickHandler;
|
|
43
|
+
const WithClickHandler = exports.WithClickHandler = Template.bind({});
|
|
50
44
|
WithClickHandler.args = {
|
|
51
45
|
onClick: () => alert('Cover was clicked')
|
|
52
46
|
};
|
|
53
|
-
const WithCenteredContentCircularLoader = Template.bind({});
|
|
54
|
-
exports.WithCenteredContentCircularLoader = WithCenteredContentCircularLoader;
|
|
47
|
+
const WithCenteredContentCircularLoader = exports.WithCenteredContentCircularLoader = Template.bind({});
|
|
55
48
|
WithCenteredContentCircularLoader.args = {
|
|
56
49
|
translucent: true,
|
|
57
50
|
children: /*#__PURE__*/_react.default.createElement(_center.Center, null, /*#__PURE__*/_react.default.createElement(_loader.CircularLoader, null))
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Cover with children is rendered', () => {
|
|
6
5
|
cy.visitStory('Cover', 'With Children');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-componentcover"]').should('be.visible');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Cover with a button below it is rendered', () => {
|
|
6
5
|
cy.visitStory('Cover', 'Blocking');
|
|
7
6
|
});
|
|
@@ -9,7 +8,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
|
|
|
9
8
|
cy.visitStory('Cover', 'With Click Handler');
|
|
10
9
|
});
|
|
11
10
|
(0, _cypressCucumberPreprocessor.When)('the user clicks the button', () => {
|
|
12
|
-
cy.get('button').click();
|
|
11
|
+
cy.get('[data-test="button"]').click();
|
|
13
12
|
});
|
|
14
13
|
(0, _cypressCucumberPreprocessor.When)('the user clicks on the Cover', () => {
|
|
15
14
|
cy.get('[data-test="dhis2-uicore-componentcover"]').click();
|
|
@@ -19,8 +18,9 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
|
|
|
19
18
|
let [rect] = _ref;
|
|
20
19
|
// Get button center coordinates
|
|
21
20
|
const buttonCenterX = rect.left + rect.width / 2;
|
|
22
|
-
const buttonCenterY = rect.top + rect.height / 2;
|
|
21
|
+
const buttonCenterY = rect.top + rect.height / 2;
|
|
23
22
|
|
|
23
|
+
// click body on the button center
|
|
24
24
|
cy.get('body').click(buttonCenterX, buttonCenterY);
|
|
25
25
|
});
|
|
26
26
|
});
|
package/build/cjs/index.js
CHANGED
|
@@ -14,10 +14,12 @@ export default {
|
|
|
14
14
|
};
|
|
15
15
|
export const WithChildren = () => /*#__PURE__*/React.createElement(Cover, null, /*#__PURE__*/React.createElement("p", null, "I am a child"));
|
|
16
16
|
export const Blocking = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
17
|
+
"data-test": "button",
|
|
17
18
|
onClick: window.onButtonClick
|
|
18
19
|
}, "Test"), /*#__PURE__*/React.createElement(Cover, null));
|
|
19
20
|
export const WithClickHandler = () => /*#__PURE__*/React.createElement(Cover, {
|
|
20
21
|
onClick: window.onCover
|
|
21
22
|
}, /*#__PURE__*/React.createElement("button", {
|
|
23
|
+
"data-test": "button",
|
|
22
24
|
onClick: window.onButtonClick
|
|
23
25
|
}, "Test"));
|
package/build/es/cover.js
CHANGED
|
@@ -3,14 +3,12 @@ import { layers } from '@dhis2/ui-constants';
|
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
|
|
7
6
|
const createClickHandler = onClick => event => {
|
|
8
7
|
// don't respond to clicks that originated in the children
|
|
9
8
|
if (onClick && event.target === event.currentTarget) {
|
|
10
9
|
onClick({}, event);
|
|
11
10
|
}
|
|
12
11
|
};
|
|
13
|
-
|
|
14
12
|
const Cover = _ref => {
|
|
15
13
|
let {
|
|
16
14
|
children,
|
|
@@ -28,9 +26,8 @@ const Cover = _ref => {
|
|
|
28
26
|
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
29
27
|
id: "3798453419",
|
|
30
28
|
dynamic: [layers.applicationTop]
|
|
31
|
-
}, [
|
|
29
|
+
}, [`div.__jsx-style-dynamic-selector{position:absolute;top:0;right:0;bottom:0;left:0;z-index:${layers.applicationTop};}`, "div.translucent.__jsx-style-dynamic-selector{background:rgba(33,43,54,0.4);}"]));
|
|
32
30
|
};
|
|
33
|
-
|
|
34
31
|
Cover.defaultProps = {
|
|
35
32
|
dataTest: 'dhis2-uicore-componentcover'
|
|
36
33
|
};
|
|
@@ -38,7 +35,6 @@ Cover.propTypes = {
|
|
|
38
35
|
children: PropTypes.node,
|
|
39
36
|
className: PropTypes.string,
|
|
40
37
|
dataTest: PropTypes.string,
|
|
41
|
-
|
|
42
38
|
/** Adds a semi-transparent background to the cover */
|
|
43
39
|
translucent: PropTypes.bool,
|
|
44
40
|
onClick: PropTypes.func
|
|
@@ -2,7 +2,13 @@ import { Center } from '@dhis2-ui/center';
|
|
|
2
2
|
import { CircularLoader } from '@dhis2-ui/loader';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Cover } from './cover.js';
|
|
5
|
-
const description =
|
|
5
|
+
const description = `
|
|
6
|
+
Covers sibling components. Useful for covering a component while it is loading.
|
|
7
|
+
|
|
8
|
+
\`\`\`js
|
|
9
|
+
import { Cover } from '@dhis2/ui'
|
|
10
|
+
\`\`\`
|
|
11
|
+
`;
|
|
6
12
|
export default {
|
|
7
13
|
title: 'Component Cover',
|
|
8
14
|
component: Cover,
|
|
@@ -14,7 +20,6 @@ export default {
|
|
|
14
20
|
}
|
|
15
21
|
}
|
|
16
22
|
};
|
|
17
|
-
|
|
18
23
|
const Template = args => /*#__PURE__*/React.createElement("div", {
|
|
19
24
|
style: {
|
|
20
25
|
width: '400px',
|
|
@@ -23,7 +28,6 @@ const Template = args => /*#__PURE__*/React.createElement("div", {
|
|
|
23
28
|
border: '1px dotted grey'
|
|
24
29
|
}
|
|
25
30
|
}, /*#__PURE__*/React.createElement(Cover, args), /*#__PURE__*/React.createElement("h1", null, "Text behind the cover"), /*#__PURE__*/React.createElement("p", null, "Lorem ipsum"));
|
|
26
|
-
|
|
27
31
|
export const Default = Template.bind({});
|
|
28
32
|
export const Translucent = Template.bind({});
|
|
29
33
|
Translucent.args = {
|
|
@@ -6,7 +6,7 @@ Given('a Cover with a button in it is rendered', () => {
|
|
|
6
6
|
cy.visitStory('Cover', 'With Click Handler');
|
|
7
7
|
});
|
|
8
8
|
When('the user clicks the button', () => {
|
|
9
|
-
cy.get('button').click();
|
|
9
|
+
cy.get('[data-test="button"]').click();
|
|
10
10
|
});
|
|
11
11
|
When('the user clicks on the Cover', () => {
|
|
12
12
|
cy.get('[data-test="dhis2-uicore-componentcover"]').click();
|
|
@@ -16,8 +16,9 @@ When('the user clicks on the button coordinates', () => {
|
|
|
16
16
|
let [rect] = _ref;
|
|
17
17
|
// Get button center coordinates
|
|
18
18
|
const buttonCenterX = rect.left + rect.width / 2;
|
|
19
|
-
const buttonCenterY = rect.top + rect.height / 2;
|
|
19
|
+
const buttonCenterY = rect.top + rect.height / 2;
|
|
20
20
|
|
|
21
|
+
// click body on the button center
|
|
21
22
|
cy.get('body').click(buttonCenterX, buttonCenterY);
|
|
22
23
|
});
|
|
23
24
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/cover",
|
|
3
|
-
"version": "9.11.
|
|
3
|
+
"version": "9.11.1-beta.2",
|
|
4
4
|
"description": "UI Cover",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "storybook dev -c ../../storybook/config --port 5000",
|
|
26
26
|
"build": "d2-app-scripts build",
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react": "^16.
|
|
31
|
-
"react-dom": "^16.
|
|
30
|
+
"react": "^16.13",
|
|
31
|
+
"react-dom": "^16.13",
|
|
32
32
|
"styled-jsx": "^4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@dhis2/prop-types": "^3.1.2",
|
|
36
|
-
"@dhis2/ui-constants": "9.11.
|
|
36
|
+
"@dhis2/ui-constants": "9.11.1-beta.2",
|
|
37
37
|
"classnames": "^2.3.1",
|
|
38
38
|
"prop-types": "^15.7.2"
|
|
39
39
|
},
|