@dhis2-ui/layer 9.11.0 → 9.11.1-beta.10
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/features/accepts_children/index.js +0 -1
- package/build/cjs/features/click_behavior/index.js +3 -3
- package/build/cjs/features/stacking/index.js +7 -5
- package/build/cjs/index.js +0 -2
- package/build/cjs/layer-context.js +1 -4
- package/build/cjs/{layer.stories.e2e.js → layer.e2e.stories.js} +2 -28
- package/build/cjs/layer.js +3 -17
- package/build/cjs/{layer.stories.js → layer.prod.stories.js} +18 -20
- package/build/cjs/use-layer-context.js +0 -4
- package/build/es/features/click_behavior/index.js +3 -2
- package/build/es/features/stacking/index.js +7 -4
- package/build/es/index.js +2 -1
- package/build/es/{layer.stories.e2e.js → layer.e2e.stories.js} +0 -2
- package/build/es/layer.js +2 -9
- package/build/es/{layer.stories.js → layer.prod.stories.js} +14 -5
- package/package.json +6 -6
|
@@ -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 Layer with a button below it is rendered', () => {
|
|
6
5
|
cy.visitStory('Layer', 'Blocking');
|
|
7
6
|
});
|
|
@@ -9,7 +8,7 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
|
|
|
9
8
|
cy.visitStory('Layer', 'With Click Handler');
|
|
10
9
|
});
|
|
11
10
|
(0, _cypressCucumberPreprocessor.When)('the user clicks the button', () => {
|
|
12
|
-
cy.get('button').click();
|
|
11
|
+
cy.get('button:contains("Test")').click();
|
|
13
12
|
});
|
|
14
13
|
(0, _cypressCucumberPreprocessor.When)('the user clicks on the layer', () => {
|
|
15
14
|
cy.get('[data-test="dhis2-uicore-layer"]').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
|
});
|
|
@@ -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)('two equal sibling Layers are rendered', () => {
|
|
6
5
|
cy.visitStory('Layer', 'Equal Siblings');
|
|
7
6
|
});
|
|
@@ -21,28 +20,31 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
|
|
|
21
20
|
cy.visitStory('Layer', 'Nested Higher Level Ends On Top');
|
|
22
21
|
});
|
|
23
22
|
(0, _cypressCucumberPreprocessor.Then)('the second layer is on top of the first layer', () => {
|
|
24
|
-
|
|
23
|
+
// Wouldn't work if the element wasn't ontop of the second layer.
|
|
24
|
+
// Cypress would fail, stating:
|
|
25
|
+
// "[...] is being covered by another element: [...]"
|
|
26
|
+
cy.get('.backdrop:visible').click();
|
|
25
27
|
cy.window().should(win => {
|
|
26
28
|
expect(win.onLayerClick).to.be.calledOnce;
|
|
27
29
|
expect(win.onLayerClick).to.be.calledWith('second');
|
|
28
30
|
});
|
|
29
31
|
});
|
|
30
32
|
(0, _cypressCucumberPreprocessor.Then)('the alert layer is on top', () => {
|
|
31
|
-
cy.get('
|
|
33
|
+
cy.get('.backdrop:visible').click();
|
|
32
34
|
cy.window().should(win => {
|
|
33
35
|
expect(win.onLayerClick).to.be.calledOnce;
|
|
34
36
|
expect(win.onLayerClick).to.be.calledWith('alert');
|
|
35
37
|
});
|
|
36
38
|
});
|
|
37
39
|
(0, _cypressCucumberPreprocessor.Then)('the layer with level 1001 is on top', () => {
|
|
38
|
-
cy.get('
|
|
40
|
+
cy.get('.backdrop:visible').click();
|
|
39
41
|
cy.window().should(win => {
|
|
40
42
|
expect(win.onLayerClick).to.be.calledOnce;
|
|
41
43
|
expect(win.onLayerClick).to.be.calledWith('1001');
|
|
42
44
|
});
|
|
43
45
|
});
|
|
44
46
|
(0, _cypressCucumberPreprocessor.Then)('the blocking layer is on top', () => {
|
|
45
|
-
cy.get('
|
|
47
|
+
cy.get('.backdrop:visible').click();
|
|
46
48
|
cy.window().should(win => {
|
|
47
49
|
expect(win.onLayerClick).to.be.calledOnce;
|
|
48
50
|
expect(win.onLayerClick).to.be.calledWith('blocking');
|
package/build/cjs/index.js
CHANGED
|
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Provider = exports.LayerContext = exports.Consumer = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
|
-
const LayerContext = /*#__PURE__*/(0, _react.createContext)({
|
|
8
|
+
const LayerContext = exports.LayerContext = /*#__PURE__*/(0, _react.createContext)({
|
|
11
9
|
node: document.body,
|
|
12
10
|
level: 0
|
|
13
11
|
});
|
|
14
|
-
exports.LayerContext = LayerContext;
|
|
15
12
|
const {
|
|
16
13
|
Provider,
|
|
17
14
|
Consumer
|
|
@@ -4,54 +4,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WithClickHandler = exports.NestedLowerLevels = exports.NestedHigherLevels = exports.NestedHigherLevelEndsOnTop = exports.LevelsAreRespectedWhenNesting = exports.InequalSiblings = exports.EqualSiblings = exports.Default = exports.Blocking = void 0;
|
|
7
|
-
|
|
8
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _layer = require("./layer.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.onLayerClick = window.Cypress && window.Cypress.cy.stub();
|
|
18
|
-
|
|
19
13
|
const createNamedLayerClick = name => () => {
|
|
20
14
|
window.onLayerClick(name);
|
|
21
15
|
};
|
|
22
|
-
|
|
23
|
-
var _default = {
|
|
16
|
+
var _default = exports.default = {
|
|
24
17
|
title: 'Layer',
|
|
25
18
|
component: _layer.Layer
|
|
26
19
|
};
|
|
27
|
-
exports.default = _default;
|
|
28
|
-
|
|
29
20
|
const Default = () => /*#__PURE__*/_react.default.createElement(_layer.Layer, null, /*#__PURE__*/_react.default.createElement("p", null, "I am a child"));
|
|
30
|
-
|
|
31
21
|
exports.Default = Default;
|
|
32
|
-
|
|
33
22
|
const Blocking = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
|
34
23
|
onClick: window.onButtonClick
|
|
35
24
|
}, "Test"), /*#__PURE__*/_react.default.createElement(_layer.Layer, null));
|
|
36
|
-
|
|
37
25
|
exports.Blocking = Blocking;
|
|
38
|
-
|
|
39
26
|
const WithClickHandler = () => /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
40
27
|
onBackdropClick: window.onLayerClick
|
|
41
28
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
42
29
|
onClick: window.onButtonClick
|
|
43
30
|
}, "Test"));
|
|
44
|
-
|
|
45
31
|
exports.WithClickHandler = WithClickHandler;
|
|
46
|
-
|
|
47
32
|
const EqualSiblings = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
48
33
|
onBackdropClick: createNamedLayerClick('first')
|
|
49
34
|
}), /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
50
35
|
onBackdropClick: createNamedLayerClick('second')
|
|
51
36
|
}));
|
|
52
|
-
|
|
53
37
|
exports.EqualSiblings = EqualSiblings;
|
|
54
|
-
|
|
55
38
|
const InequalSiblings = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
56
39
|
level: _uiConstants.layers.alert,
|
|
57
40
|
onBackdropClick: createNamedLayerClick('alert')
|
|
@@ -62,9 +45,7 @@ const InequalSiblings = () => /*#__PURE__*/_react.default.createElement(_react.d
|
|
|
62
45
|
level: _uiConstants.layers.applicationTop,
|
|
63
46
|
onBackdropClick: createNamedLayerClick('applicationTop')
|
|
64
47
|
}));
|
|
65
|
-
|
|
66
48
|
exports.InequalSiblings = InequalSiblings;
|
|
67
|
-
|
|
68
49
|
const NestedLowerLevels = () => /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
69
50
|
level: _uiConstants.layers.alert,
|
|
70
51
|
dataTest: "alert",
|
|
@@ -75,9 +56,7 @@ const NestedLowerLevels = () => /*#__PURE__*/_react.default.createElement(_layer
|
|
|
75
56
|
disablePortal: true,
|
|
76
57
|
onBackdropClick: createNamedLayerClick('blocking')
|
|
77
58
|
}));
|
|
78
|
-
|
|
79
59
|
exports.NestedLowerLevels = NestedLowerLevels;
|
|
80
|
-
|
|
81
60
|
const NestedHigherLevels = () => /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
82
61
|
level: _uiConstants.layers.blocking,
|
|
83
62
|
dataTest: "blocking",
|
|
@@ -87,9 +66,7 @@ const NestedHigherLevels = () => /*#__PURE__*/_react.default.createElement(_laye
|
|
|
87
66
|
dataTest: "alert",
|
|
88
67
|
onBackdropClick: createNamedLayerClick('alert')
|
|
89
68
|
}));
|
|
90
|
-
|
|
91
69
|
exports.NestedHigherLevels = NestedHigherLevels;
|
|
92
|
-
|
|
93
70
|
const LevelsAreRespectedWhenNesting = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
94
71
|
level: 1000
|
|
95
72
|
}, /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
@@ -101,9 +78,7 @@ const LevelsAreRespectedWhenNesting = () => /*#__PURE__*/_react.default.createEl
|
|
|
101
78
|
level: 1001,
|
|
102
79
|
onBackdropClick: createNamedLayerClick('1001')
|
|
103
80
|
}));
|
|
104
|
-
|
|
105
81
|
exports.LevelsAreRespectedWhenNesting = LevelsAreRespectedWhenNesting;
|
|
106
|
-
|
|
107
82
|
const NestedHigherLevelEndsOnTop = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
108
83
|
level: _uiConstants.layers.applicationTop
|
|
109
84
|
}, /*#__PURE__*/_react.default.createElement(_layer.Layer, {
|
|
@@ -113,5 +88,4 @@ const NestedHigherLevelEndsOnTop = () => /*#__PURE__*/_react.default.createEleme
|
|
|
113
88
|
level: _uiConstants.layers.blocking,
|
|
114
89
|
onBackdropClick: createNamedLayerClick('blocking')
|
|
115
90
|
}));
|
|
116
|
-
|
|
117
91
|
exports.NestedHigherLevelEndsOnTop = NestedHigherLevelEndsOnTop;
|
package/build/cjs/layer.js
CHANGED
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Layer = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
|
-
var _portal = require("@dhis2-ui/portal");
|
|
11
|
-
|
|
12
8
|
var _propTypes = require("@dhis2/prop-types");
|
|
13
|
-
|
|
9
|
+
var _portal = require("@dhis2-ui/portal");
|
|
14
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
11
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
14
|
const Layer = _ref => {
|
|
23
15
|
let {
|
|
24
16
|
children,
|
|
@@ -45,11 +37,10 @@ const Layer = _ref => {
|
|
|
45
37
|
}), children, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
46
38
|
id: "1893150038",
|
|
47
39
|
dynamic: [level]
|
|
48
|
-
}, [
|
|
40
|
+
}, [`div.__jsx-style-dynamic-selector{z-index:${level};}`]), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
49
41
|
id: "4284133831"
|
|
50
42
|
}, ["div.jsx-4284133831{-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;inset-inline-start:0;min-height:100vh;min-width:100vw;}", "div.fixed.jsx-4284133831{position:fixed;height:100vh;width:100vw;}", "div.absolute.jsx-4284133831{position:absolute;height:100%;width:100%;}", "div.translucent.jsx-4284133831{background-color:rgba(33,43,54,0.4);}", "div.backdrop.jsx-4284133831{position:absolute;inset:0;z-index:-1;}"])));
|
|
51
43
|
};
|
|
52
|
-
|
|
53
44
|
exports.Layer = Layer;
|
|
54
45
|
Layer.defaultProps = {
|
|
55
46
|
position: 'fixed',
|
|
@@ -60,20 +51,15 @@ Layer.propTypes = {
|
|
|
60
51
|
children: _propTypes2.default.node,
|
|
61
52
|
className: _propTypes2.default.string,
|
|
62
53
|
dataTest: _propTypes2.default.string,
|
|
63
|
-
|
|
64
54
|
/** Disable the Portal, useful for nesting layers */
|
|
65
55
|
disablePortal: _propTypes2.default.bool,
|
|
66
|
-
|
|
67
56
|
/** Z-index level */
|
|
68
57
|
level: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
|
|
69
58
|
position: _propTypes2.default.oneOf(['absolute', 'fixed']),
|
|
70
|
-
|
|
71
59
|
/** Adds a semi-transparent background */
|
|
72
60
|
translucent: _propTypes2.default.bool,
|
|
73
|
-
|
|
74
61
|
/** Backdrop click handler */
|
|
75
62
|
onBackdropClick: _propTypes2.default.func,
|
|
76
|
-
|
|
77
63
|
/** Click handler - DEPRECATED */
|
|
78
64
|
onClick: (0, _propTypes.deprecated)(_propTypes2.default.func, 'Please use "onBackdropClick" instead')
|
|
79
65
|
};
|
|
@@ -4,22 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WithOnBackdropClick = 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 _layer = require("./layer.js");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const description = `
|
|
13
|
+
Layers are used for creating different levels of stacking of interface elements.
|
|
14
|
+
See more about stacking guidelines at the [design system](https://github.com/dhis2/design-system/blob/master/principles/layout.md#stacking).
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Layers are used in Modals, Popovers, and Alerts.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
\`\`\`js
|
|
19
|
+
import { Layer } from '@dhis2/ui'
|
|
20
|
+
\`\`\`
|
|
21
|
+
|
|
22
|
+
_**Note:** These demos may take some time to load._
|
|
23
|
+
`;
|
|
24
|
+
var _default = exports.default = {
|
|
20
25
|
title: 'Layer',
|
|
21
26
|
component: _layer.Layer,
|
|
22
|
-
|
|
23
27
|
/**
|
|
24
28
|
* `inlineStories: false` renders these layers in iframes instead of inline.
|
|
25
29
|
* This fixes an issue where all the layers on the docs page render on top
|
|
@@ -36,27 +40,21 @@ var _default = {
|
|
|
36
40
|
}
|
|
37
41
|
},
|
|
38
42
|
// Handle weird treatment of non-literal defaultProps (see Transfer.stories)
|
|
39
|
-
args: {
|
|
43
|
+
args: {
|
|
44
|
+
..._layer.Layer.defaultProps
|
|
40
45
|
}
|
|
41
46
|
};
|
|
42
|
-
exports.default = _default;
|
|
43
|
-
|
|
44
47
|
const Template = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_layer.Layer, args), /*#__PURE__*/_react.default.createElement("h1", null, "Text behind the layer"), /*#__PURE__*/_react.default.createElement("p", null, "Lorem ipsum"));
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
exports.Default = Default;
|
|
48
|
-
const Translucent = Template.bind({});
|
|
49
|
-
exports.Translucent = Translucent;
|
|
48
|
+
const Default = exports.Default = Template.bind({});
|
|
49
|
+
const Translucent = exports.Translucent = Template.bind({});
|
|
50
50
|
Translucent.args = {
|
|
51
51
|
translucent: true
|
|
52
52
|
};
|
|
53
|
-
const WithOnBackdropClick = Template.bind({});
|
|
54
|
-
exports.WithOnBackdropClick = WithOnBackdropClick;
|
|
53
|
+
const WithOnBackdropClick = exports.WithOnBackdropClick = Template.bind({});
|
|
55
54
|
WithOnBackdropClick.args = {
|
|
56
55
|
onBackdropClick: () => alert('layer backdrop was clicked')
|
|
57
56
|
};
|
|
58
|
-
const WithCenteredContentCircularLoader = Template.bind({});
|
|
59
|
-
exports.WithCenteredContentCircularLoader = WithCenteredContentCircularLoader;
|
|
57
|
+
const WithCenteredContentCircularLoader = exports.WithCenteredContentCircularLoader = Template.bind({});
|
|
60
58
|
WithCenteredContentCircularLoader.args = {
|
|
61
59
|
children: /*#__PURE__*/_react.default.createElement(_center.Center, null, /*#__PURE__*/_react.default.createElement(_loader.CircularLoader, null))
|
|
62
60
|
};
|
|
@@ -4,11 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useLayerContext = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _layerContext = require("./layer-context.js");
|
|
11
|
-
|
|
12
9
|
const useLayerContext = () => (0, _react.useContext)(_layerContext.LayerContext);
|
|
13
|
-
|
|
14
10
|
exports.useLayerContext = useLayerContext;
|
|
@@ -6,7 +6,7 @@ Given('a Layer with a button in it is rendered', () => {
|
|
|
6
6
|
cy.visitStory('Layer', 'With Click Handler');
|
|
7
7
|
});
|
|
8
8
|
When('the user clicks the button', () => {
|
|
9
|
-
cy.get('button').click();
|
|
9
|
+
cy.get('button:contains("Test")').click();
|
|
10
10
|
});
|
|
11
11
|
When('the user clicks on the layer', () => {
|
|
12
12
|
cy.get('[data-test="dhis2-uicore-layer"]').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
|
});
|
|
@@ -18,28 +18,31 @@ Given('an applicatioTop layer with a nested alert layer with a blocking sibling'
|
|
|
18
18
|
cy.visitStory('Layer', 'Nested Higher Level Ends On Top');
|
|
19
19
|
});
|
|
20
20
|
Then('the second layer is on top of the first layer', () => {
|
|
21
|
-
|
|
21
|
+
// Wouldn't work if the element wasn't ontop of the second layer.
|
|
22
|
+
// Cypress would fail, stating:
|
|
23
|
+
// "[...] is being covered by another element: [...]"
|
|
24
|
+
cy.get('.backdrop:visible').click();
|
|
22
25
|
cy.window().should(win => {
|
|
23
26
|
expect(win.onLayerClick).to.be.calledOnce;
|
|
24
27
|
expect(win.onLayerClick).to.be.calledWith('second');
|
|
25
28
|
});
|
|
26
29
|
});
|
|
27
30
|
Then('the alert layer is on top', () => {
|
|
28
|
-
cy.get('
|
|
31
|
+
cy.get('.backdrop:visible').click();
|
|
29
32
|
cy.window().should(win => {
|
|
30
33
|
expect(win.onLayerClick).to.be.calledOnce;
|
|
31
34
|
expect(win.onLayerClick).to.be.calledWith('alert');
|
|
32
35
|
});
|
|
33
36
|
});
|
|
34
37
|
Then('the layer with level 1001 is on top', () => {
|
|
35
|
-
cy.get('
|
|
38
|
+
cy.get('.backdrop:visible').click();
|
|
36
39
|
cy.window().should(win => {
|
|
37
40
|
expect(win.onLayerClick).to.be.calledOnce;
|
|
38
41
|
expect(win.onLayerClick).to.be.calledWith('1001');
|
|
39
42
|
});
|
|
40
43
|
});
|
|
41
44
|
Then('the blocking layer is on top', () => {
|
|
42
|
-
cy.get('
|
|
45
|
+
cy.get('.backdrop:visible').click();
|
|
43
46
|
cy.window().should(win => {
|
|
44
47
|
expect(win.onLayerClick).to.be.calledOnce;
|
|
45
48
|
expect(win.onLayerClick).to.be.calledWith('blocking');
|
package/build/es/index.js
CHANGED
|
@@ -3,11 +3,9 @@ import React from 'react';
|
|
|
3
3
|
import { Layer } from './layer.js';
|
|
4
4
|
window.onButtonClick = window.Cypress && window.Cypress.cy.stub();
|
|
5
5
|
window.onLayerClick = window.Cypress && window.Cypress.cy.stub();
|
|
6
|
-
|
|
7
6
|
const createNamedLayerClick = name => () => {
|
|
8
7
|
window.onLayerClick(name);
|
|
9
8
|
};
|
|
10
|
-
|
|
11
9
|
export default {
|
|
12
10
|
title: 'Layer',
|
|
13
11
|
component: Layer
|
package/build/es/layer.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
import { Portal } from '@dhis2-ui/portal';
|
|
3
2
|
import { deprecated } from '@dhis2/prop-types';
|
|
3
|
+
import { Portal } from '@dhis2-ui/portal';
|
|
4
4
|
import cx from 'classnames';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import React from 'react';
|
|
7
|
-
|
|
8
7
|
const Layer = _ref => {
|
|
9
8
|
let {
|
|
10
9
|
children,
|
|
@@ -31,11 +30,10 @@ const Layer = _ref => {
|
|
|
31
30
|
}), children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
32
31
|
id: "1893150038",
|
|
33
32
|
dynamic: [level]
|
|
34
|
-
}, [
|
|
33
|
+
}, [`div.__jsx-style-dynamic-selector{z-index:${level};}`]), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
35
34
|
id: "4284133831"
|
|
36
35
|
}, ["div.jsx-4284133831{-webkit-inset-block-start:0;-ms-intb-rlock-start:0;inset-block-start:0;inset-inline-start:0;min-height:100vh;min-width:100vw;}", "div.fixed.jsx-4284133831{position:fixed;height:100vh;width:100vw;}", "div.absolute.jsx-4284133831{position:absolute;height:100%;width:100%;}", "div.translucent.jsx-4284133831{background-color:rgba(33,43,54,0.4);}", "div.backdrop.jsx-4284133831{position:absolute;inset:0;z-index:-1;}"])));
|
|
37
36
|
};
|
|
38
|
-
|
|
39
37
|
Layer.defaultProps = {
|
|
40
38
|
position: 'fixed',
|
|
41
39
|
dataTest: 'dhis2-uicore-layer',
|
|
@@ -45,20 +43,15 @@ Layer.propTypes = {
|
|
|
45
43
|
children: PropTypes.node,
|
|
46
44
|
className: PropTypes.string,
|
|
47
45
|
dataTest: PropTypes.string,
|
|
48
|
-
|
|
49
46
|
/** Disable the Portal, useful for nesting layers */
|
|
50
47
|
disablePortal: PropTypes.bool,
|
|
51
|
-
|
|
52
48
|
/** Z-index level */
|
|
53
49
|
level: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
54
50
|
position: PropTypes.oneOf(['absolute', 'fixed']),
|
|
55
|
-
|
|
56
51
|
/** Adds a semi-transparent background */
|
|
57
52
|
translucent: PropTypes.bool,
|
|
58
|
-
|
|
59
53
|
/** Backdrop click handler */
|
|
60
54
|
onBackdropClick: PropTypes.func,
|
|
61
|
-
|
|
62
55
|
/** Click handler - DEPRECATED */
|
|
63
56
|
onClick: deprecated(PropTypes.func, 'Please use "onBackdropClick" instead')
|
|
64
57
|
};
|
|
@@ -2,11 +2,21 @@ import { Center } from '@dhis2-ui/center';
|
|
|
2
2
|
import { CircularLoader } from '@dhis2-ui/loader';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Layer } from './layer.js';
|
|
5
|
-
const description =
|
|
5
|
+
const description = `
|
|
6
|
+
Layers are used for creating different levels of stacking of interface elements.
|
|
7
|
+
See more about stacking guidelines at the [design system](https://github.com/dhis2/design-system/blob/master/principles/layout.md#stacking).
|
|
8
|
+
|
|
9
|
+
Layers are used in Modals, Popovers, and Alerts.
|
|
10
|
+
|
|
11
|
+
\`\`\`js
|
|
12
|
+
import { Layer } from '@dhis2/ui'
|
|
13
|
+
\`\`\`
|
|
14
|
+
|
|
15
|
+
_**Note:** These demos may take some time to load._
|
|
16
|
+
`;
|
|
6
17
|
export default {
|
|
7
18
|
title: 'Layer',
|
|
8
19
|
component: Layer,
|
|
9
|
-
|
|
10
20
|
/**
|
|
11
21
|
* `inlineStories: false` renders these layers in iframes instead of inline.
|
|
12
22
|
* This fixes an issue where all the layers on the docs page render on top
|
|
@@ -23,12 +33,11 @@ export default {
|
|
|
23
33
|
}
|
|
24
34
|
},
|
|
25
35
|
// Handle weird treatment of non-literal defaultProps (see Transfer.stories)
|
|
26
|
-
args: {
|
|
36
|
+
args: {
|
|
37
|
+
...Layer.defaultProps
|
|
27
38
|
}
|
|
28
39
|
};
|
|
29
|
-
|
|
30
40
|
const Template = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Layer, args), /*#__PURE__*/React.createElement("h1", null, "Text behind the layer"), /*#__PURE__*/React.createElement("p", null, "Lorem ipsum"));
|
|
31
|
-
|
|
32
41
|
export const Default = Template.bind({});
|
|
33
42
|
export const Translucent = Template.bind({});
|
|
34
43
|
Translucent.args = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/layer",
|
|
3
|
-
"version": "9.11.
|
|
3
|
+
"version": "9.11.1-beta.10",
|
|
4
4
|
"description": "UI Layer",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,19 +22,19 @@
|
|
|
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/portal": "9.11.
|
|
37
|
-
"@dhis2/ui-constants": "9.11.
|
|
36
|
+
"@dhis2-ui/portal": "9.11.1-beta.10",
|
|
37
|
+
"@dhis2/ui-constants": "9.11.1-beta.10",
|
|
38
38
|
"classnames": "^2.3.1",
|
|
39
39
|
"prop-types": "^15.7.2"
|
|
40
40
|
},
|