@dhis2-ui/alert 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/alert-bar/action.js +7 -18
- package/build/cjs/alert-bar/actions.js +5 -18
- package/build/cjs/alert-bar/alert-bar.e2e.stories.js +67 -0
- package/build/cjs/alert-bar/alert-bar.js +6 -40
- package/build/cjs/alert-bar/{alert-bar.stories.js → alert-bar.prod.stories.js} +34 -39
- package/build/cjs/alert-bar/alert-bar.styles.js +3 -7
- package/build/cjs/alert-bar/dismiss.js +2 -10
- package/build/cjs/alert-bar/features/api/index.js +1 -2
- package/build/cjs/alert-bar/features/common/index.js +0 -1
- package/build/cjs/alert-bar/features/hide/index.js +5 -3
- package/build/cjs/alert-bar/features/hide.feature +2 -2
- package/build/cjs/alert-bar/icon.js +3 -24
- package/build/cjs/alert-bar/index.js +0 -1
- package/build/cjs/alert-bar/message.js +1 -7
- package/build/cjs/alert-stack/alert-stack.e2e.stories.js +21 -0
- package/build/cjs/alert-stack/alert-stack.js +3 -12
- package/build/cjs/alert-stack/{alert-stack.stories.js → alert-stack.prod.stories.js} +10 -13
- package/build/cjs/alert-stack/features/render_children/alertbars.js +0 -1
- package/build/cjs/alert-stack/index.js +0 -1
- package/build/cjs/index.js +0 -2
- package/build/es/alert-bar/action.js +4 -9
- package/build/es/alert-bar/actions.js +3 -9
- package/build/es/alert-bar/{alert-bar.stories.e2e.js → alert-bar.e2e.stories.js} +19 -11
- package/build/es/alert-bar/alert-bar.js +3 -24
- package/build/es/alert-bar/{alert-bar.stories.js → alert-bar.prod.stories.js} +30 -10
- package/build/es/alert-bar/alert-bar.styles.js +1 -1
- package/build/es/alert-bar/dismiss.js +1 -3
- package/build/es/alert-bar/features/api/index.js +1 -1
- package/build/es/alert-bar/features/hide/index.js +5 -2
- package/build/es/alert-bar/features/hide.feature +2 -2
- package/build/es/alert-bar/icon.js +1 -12
- package/build/es/alert-bar/message.js +0 -2
- package/build/es/alert-stack/{alert-stack.stories.e2e.js → alert-stack.e2e.stories.js} +5 -3
- package/build/es/alert-stack/alert-stack.js +2 -2
- package/build/es/alert-stack/{alert-stack.stories.js → alert-stack.prod.stories.js} +9 -1
- package/package.json +7 -7
- package/build/cjs/alert-bar/alert-bar.stories.e2e.js +0 -51
- package/build/cjs/alert-stack/alert-stack.stories.e2e.js +0 -19
@@ -4,33 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.Action = 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 _propTypes = _interopRequireDefault(require("prop-types"));
|
13
|
-
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
15
|
-
|
16
|
-
function
|
17
|
-
|
18
|
-
function
|
19
|
-
|
20
|
-
function
|
21
|
-
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
23
|
-
|
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; }
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
16
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
24
17
|
class Action extends _react.Component {
|
25
18
|
constructor() {
|
26
19
|
super(...arguments);
|
27
|
-
|
28
20
|
_defineProperty(this, "onClick", event => {
|
29
21
|
this.props.onClick(event);
|
30
22
|
this.props.hide(event);
|
31
23
|
});
|
32
24
|
}
|
33
|
-
|
34
25
|
render() {
|
35
26
|
return /*#__PURE__*/_react.default.createElement("span", {
|
36
27
|
onClick: this.onClick,
|
@@ -39,11 +30,9 @@ class Action extends _react.Component {
|
|
39
30
|
}, this.props.label, /*#__PURE__*/_react.default.createElement(_style.default, {
|
40
31
|
id: "918162538",
|
41
32
|
dynamic: [_uiConstants.spacers.dp12]
|
42
|
-
}, [
|
33
|
+
}, [`span.__jsx-style-dynamic-selector{margin-inline-end:${_uiConstants.spacers.dp12};-webkit-text-decoration:underline;text-decoration:underline;white-space:nowrap;}`, "span.__jsx-style-dynamic-selector:hover{cursor:pointer;}"]));
|
43
34
|
}
|
44
|
-
|
45
35
|
}
|
46
|
-
|
47
36
|
exports.Action = Action;
|
48
37
|
Action.propTypes = {
|
49
38
|
dataTest: _propTypes.default.string.isRequired,
|
@@ -4,53 +4,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.actionsPropType = exports.Actions = void 0;
|
7
|
-
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
9
|
-
|
10
8
|
var _propTypes = require("@dhis2/prop-types");
|
11
|
-
|
12
9
|
var _uiConstants = require("@dhis2/ui-constants");
|
13
|
-
|
14
10
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
15
|
-
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
17
|
-
|
18
12
|
var _action = require("./action.js");
|
19
|
-
|
20
|
-
function
|
21
|
-
|
22
|
-
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); }
|
23
|
-
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
14
|
+
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); }
|
24
15
|
const Actions = _ref => {
|
25
16
|
let {
|
26
17
|
actions,
|
27
18
|
hide,
|
28
19
|
dataTest
|
29
20
|
} = _ref;
|
30
|
-
|
31
21
|
if (!actions) {
|
32
22
|
return null;
|
33
23
|
}
|
34
|
-
|
35
24
|
return /*#__PURE__*/_react.default.createElement("div", {
|
36
25
|
className: _style.default.dynamic([["793807948", [_uiConstants.spacers.dp48, _uiConstants.spacers.dp12]]])
|
37
26
|
}, actions.map(action => /*#__PURE__*/_react.default.createElement(_action.Action, _extends({
|
38
27
|
key: action.label
|
39
28
|
}, action, {
|
40
29
|
hide: hide,
|
41
|
-
dataTest:
|
30
|
+
dataTest: `${dataTest}-action`
|
42
31
|
}))), /*#__PURE__*/_react.default.createElement(_style.default, {
|
43
32
|
id: "793807948",
|
44
33
|
dynamic: [_uiConstants.spacers.dp48, _uiConstants.spacers.dp12]
|
45
|
-
}, [
|
34
|
+
}, [`div.__jsx-style-dynamic-selector{margin-inline-start:${_uiConstants.spacers.dp48};margin-inline-end:-${_uiConstants.spacers.dp12};}`]));
|
46
35
|
};
|
47
|
-
|
48
36
|
exports.Actions = Actions;
|
49
|
-
const actionsPropType = (0, _propTypes.arrayWithLength)(0, 2, _propTypes2.default.shape({
|
37
|
+
const actionsPropType = exports.actionsPropType = (0, _propTypes.arrayWithLength)(0, 2, _propTypes2.default.shape({
|
50
38
|
label: _propTypes2.default.string.isRequired,
|
51
39
|
onClick: _propTypes2.default.func.isRequired
|
52
40
|
}));
|
53
|
-
exports.actionsPropType = actionsPropType;
|
54
41
|
Actions.propTypes = {
|
55
42
|
dataTest: _propTypes2.default.string.isRequired,
|
56
43
|
hide: _propTypes2.default.func.isRequired,
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = exports.WithOnHidden = exports.WithMessage = exports.PermanentWithActions = exports.Permanent = exports.HiddenProp = exports.DisabledIcon = exports.Default = exports.CustomIcon = exports.CustomDuration = void 0;
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
8
|
+
var _index = require("./index.js");
|
9
|
+
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); }
|
10
|
+
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
|
+
window.onHidden = window.Cypress && window.Cypress.cy.stub();
|
12
|
+
var _default = exports.default = {
|
13
|
+
title: 'AlertBar'
|
14
|
+
};
|
15
|
+
const Default = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, null, "Default");
|
16
|
+
exports.Default = Default;
|
17
|
+
const CustomDuration = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
18
|
+
duration: 2000
|
19
|
+
}, "Custom duration");
|
20
|
+
exports.CustomDuration = CustomDuration;
|
21
|
+
const PermanentWithActions = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
22
|
+
permanent: true,
|
23
|
+
actions: [{
|
24
|
+
label: 'Save',
|
25
|
+
onClick: () => {}
|
26
|
+
}, {
|
27
|
+
label: 'Cancel',
|
28
|
+
onClick: () => {}
|
29
|
+
}]
|
30
|
+
}, "With Actions");
|
31
|
+
exports.PermanentWithActions = PermanentWithActions;
|
32
|
+
const DisabledIcon = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
33
|
+
icon: false
|
34
|
+
}, "Message");
|
35
|
+
exports.DisabledIcon = DisabledIcon;
|
36
|
+
const CustomIcon = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
37
|
+
icon: /*#__PURE__*/_react.default.createElement("span", null, "Custom icon")
|
38
|
+
}, "Message");
|
39
|
+
exports.CustomIcon = CustomIcon;
|
40
|
+
const WithMessage = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, null, "With a message");
|
41
|
+
exports.WithMessage = WithMessage;
|
42
|
+
const WithOnHidden = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
43
|
+
onHidden: window.onHidden
|
44
|
+
}, "Message");
|
45
|
+
exports.WithOnHidden = WithOnHidden;
|
46
|
+
const Permanent = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
47
|
+
permanent: true
|
48
|
+
}, "Message");
|
49
|
+
exports.Permanent = Permanent;
|
50
|
+
const HiddenProp = () => {
|
51
|
+
const [hidden, setHidden] = (0, _react.useState)(true);
|
52
|
+
const toggleVisibility = () => setHidden(prevHidden => !prevHidden);
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
54
|
+
style: {
|
55
|
+
display: 'block',
|
56
|
+
position: 'fixed',
|
57
|
+
bottom: 150,
|
58
|
+
left: 10
|
59
|
+
},
|
60
|
+
onClick: toggleVisibility
|
61
|
+
}, hidden ? 'Show' : 'Hide'), /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
62
|
+
permanent: true,
|
63
|
+
hidden: hidden,
|
64
|
+
onHidden: window.onHidden
|
65
|
+
}, "Short text"));
|
66
|
+
};
|
67
|
+
exports.HiddenProp = HiddenProp;
|
@@ -4,33 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.AlertBar = void 0;
|
7
|
-
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
9
|
-
|
10
8
|
var _propTypes = require("@dhis2/prop-types");
|
11
|
-
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
13
|
-
|
14
10
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
15
|
-
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
17
|
-
|
18
12
|
var _actions = require("./actions.js");
|
19
|
-
|
20
13
|
var _alertBarStyles = _interopRequireWildcard(require("./alert-bar.styles.js"));
|
21
|
-
|
22
14
|
var _dismiss = require("./dismiss.js");
|
23
|
-
|
24
15
|
var _icon = require("./icon.js");
|
25
|
-
|
26
16
|
var _message = require("./message.js");
|
27
|
-
|
28
|
-
function
|
29
|
-
|
30
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
31
|
-
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
|
-
|
17
|
+
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); }
|
18
|
+
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; }
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
34
20
|
const AlertBar = _ref => {
|
35
21
|
let {
|
36
22
|
actions,
|
@@ -55,35 +41,29 @@ const AlertBar = _ref => {
|
|
55
41
|
const displayTimeRemaining = (0, _react.useRef)(null);
|
56
42
|
const info = !critical && !success && !warning;
|
57
43
|
const shouldAutoHide = !(permanent || warning || critical);
|
58
|
-
|
59
44
|
const show = () => {
|
60
45
|
setInDOM(true);
|
61
46
|
setInViewport(true);
|
62
47
|
};
|
63
|
-
|
64
48
|
const hide = () => {
|
65
49
|
setInDOM(true);
|
66
50
|
setInViewport(false);
|
67
51
|
};
|
68
|
-
|
69
52
|
const remove = () => {
|
70
53
|
setInDOM(false);
|
71
54
|
setInViewport(false);
|
72
55
|
onHidden && onHidden({}, null);
|
73
56
|
};
|
74
|
-
|
75
57
|
const clearAllTimeouts = () => {
|
76
58
|
clearTimeout(showTimeout.current);
|
77
59
|
clearTimeout(displayTimeout.current);
|
78
60
|
clearTimeout(hideTimeout.current);
|
79
61
|
};
|
80
|
-
|
81
62
|
const runHideAnimation = () => {
|
82
63
|
clearAllTimeouts();
|
83
64
|
hide();
|
84
65
|
hideTimeout.current = setTimeout(remove, _alertBarStyles.ANIMATION_TIME);
|
85
66
|
};
|
86
|
-
|
87
67
|
const startDisplayTimeout = () => {
|
88
68
|
if (shouldAutoHide) {
|
89
69
|
clearAllTimeouts();
|
@@ -92,13 +72,11 @@ const AlertBar = _ref => {
|
|
92
72
|
displayTimeout.current = setTimeout(runHideAnimation, displayTimeRemaining.current);
|
93
73
|
}
|
94
74
|
};
|
95
|
-
|
96
75
|
const runShowAnimation = () => {
|
97
76
|
clearAllTimeouts();
|
98
77
|
show();
|
99
78
|
showTimeout.current = setTimeout(startDisplayTimeout, _alertBarStyles.ANIMATION_TIME);
|
100
79
|
};
|
101
|
-
|
102
80
|
const pauseDisplayTimeout = () => {
|
103
81
|
if (shouldAutoHide) {
|
104
82
|
clearAllTimeouts();
|
@@ -106,32 +84,28 @@ const AlertBar = _ref => {
|
|
106
84
|
displayTimeRemaining.current -= elapsedTime;
|
107
85
|
}
|
108
86
|
};
|
109
|
-
|
110
87
|
const resumeDisplayTimeout = () => {
|
111
88
|
if (shouldAutoHide) {
|
112
89
|
clearAllTimeouts();
|
113
90
|
displayTimeout.current = setTimeout(runHideAnimation, displayTimeRemaining.current);
|
114
91
|
}
|
115
92
|
};
|
116
|
-
|
117
93
|
(0, _react.useEffect)(() => {
|
118
94
|
// Additional check on inDOM prevents the AlertBar from briefly showing
|
119
95
|
// when it is mounted with a hidden prop set to true
|
120
96
|
if (hidden && inDOM) {
|
121
97
|
runHideAnimation();
|
122
98
|
}
|
123
|
-
|
124
99
|
if (!hidden) {
|
125
100
|
runShowAnimation();
|
126
101
|
}
|
127
|
-
|
128
102
|
return clearAllTimeouts;
|
129
103
|
}, [hidden]);
|
130
104
|
return !inDOM ? null : /*#__PURE__*/_react.default.createElement("div", {
|
131
105
|
"data-test": dataTest,
|
132
106
|
onMouseEnter: pauseDisplayTimeout,
|
133
107
|
onMouseLeave: resumeDisplayTimeout,
|
134
|
-
className:
|
108
|
+
className: `jsx-${_alertBarStyles.default.__hash}` + " " + ((0, _classnames.default)(className, {
|
135
109
|
info,
|
136
110
|
success,
|
137
111
|
warning,
|
@@ -139,7 +113,7 @@ const AlertBar = _ref => {
|
|
139
113
|
inViewport
|
140
114
|
}) || "")
|
141
115
|
}, /*#__PURE__*/_react.default.createElement(_icon.Icon, {
|
142
|
-
dataTest:
|
116
|
+
dataTest: `${dataTest}-icon`,
|
143
117
|
icon: icon,
|
144
118
|
critical: critical,
|
145
119
|
success: success,
|
@@ -151,12 +125,11 @@ const AlertBar = _ref => {
|
|
151
125
|
dataTest: dataTest
|
152
126
|
}), /*#__PURE__*/_react.default.createElement(_dismiss.Dismiss, {
|
153
127
|
onClick: runHideAnimation,
|
154
|
-
dataTest:
|
128
|
+
dataTest: `${dataTest}-dismiss`
|
155
129
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
156
130
|
id: _alertBarStyles.default.__hash
|
157
131
|
}, _alertBarStyles.default));
|
158
132
|
};
|
159
|
-
|
160
133
|
exports.AlertBar = AlertBar;
|
161
134
|
const alertTypePropType = (0, _propTypes.mutuallyExclusive)(['success', 'warning', 'critical'], _propTypes2.default.bool);
|
162
135
|
AlertBar.defaultProps = {
|
@@ -168,31 +141,24 @@ AlertBar.propTypes = {
|
|
168
141
|
/** An array of 0-2 action objects
|
169
142
|
`[{label: "Save", onClick: clickHandler}]`*/
|
170
143
|
actions: _actions.actionsPropType,
|
171
|
-
|
172
144
|
/** The message string for the alert */
|
173
145
|
children: _propTypes2.default.string,
|
174
146
|
className: _propTypes2.default.string,
|
175
|
-
|
176
147
|
/** Alert bars with `critical` will not autohide */
|
177
148
|
critical: alertTypePropType,
|
178
149
|
dataTest: _propTypes2.default.string,
|
179
|
-
|
180
150
|
/** How long you want the notification to display, in `ms`, when it's not permanent */
|
181
151
|
duration: _propTypes2.default.number,
|
182
|
-
|
183
152
|
/** AlertBar will be hidden on creation when this is set to true */
|
184
153
|
hidden: _propTypes2.default.bool,
|
185
|
-
|
186
154
|
/**
|
187
155
|
* A specific icon to override the default icon in the bar.
|
188
156
|
* If `false` is provided, no icon will be shown.
|
189
157
|
*/
|
190
158
|
icon: _icon.iconPropType,
|
191
|
-
|
192
159
|
/** When set, AlertBar will not autohide */
|
193
160
|
permanent: _propTypes2.default.bool,
|
194
161
|
success: alertTypePropType,
|
195
|
-
|
196
162
|
/** Alert bars with `warning` will not autohide */
|
197
163
|
warning: alertTypePropType,
|
198
164
|
onHidden: _propTypes2.default.func
|
@@ -4,20 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = exports.WithActionsAndInsufficientSpace = exports.WithActions = exports.TextOverflow = exports.States = exports.RTL = exports.Icons = exports.HiddenProp = exports.Default = exports.AutoHiding = void 0;
|
7
|
-
|
8
7
|
var _uiIcons = require("@dhis2/ui-icons");
|
9
|
-
|
10
8
|
var _react = _interopRequireWildcard(require("react"));
|
11
|
-
|
12
9
|
var _index = require("./index.js");
|
13
|
-
|
14
|
-
function
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
const description =
|
20
|
-
|
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; }
|
12
|
+
const subtitle = `
|
13
|
+
A floating alert that informs the user about temporary information
|
14
|
+
in the context of the current screen.
|
15
|
+
`;
|
16
|
+
const description = `
|
17
|
+
Alert bars notify a user of some information. There are different types of
|
18
|
+
alert bar for displaying different types of content. Use the alert bar type
|
19
|
+
that matches your content type and importance. Note that alert bar can be
|
20
|
+
ignored by the user, so they shouldn't be used for content that needs to
|
21
|
+
block an app flow, use a modal instead.
|
22
|
+
|
23
|
+
Alert bars are always displayed at centered and fixed at the bottom of the
|
24
|
+
screen. Some types of alert bar dismiss after a set time, others must be
|
25
|
+
dismissed by the user.
|
26
|
+
|
27
|
+
See specification: [Design System](https://github.com/dhis2/design-system/blob/master/molecules/alertbar.md)
|
28
|
+
|
29
|
+
\`\`\`js
|
30
|
+
import { AlertBar } from '@dhis2/ui'
|
31
|
+
\`\`\`
|
32
|
+
`;
|
21
33
|
const Wrapper = fn => /*#__PURE__*/_react.default.createElement("div", {
|
22
34
|
style: {
|
23
35
|
height: '260px'
|
@@ -32,7 +44,6 @@ const Wrapper = fn => /*#__PURE__*/_react.default.createElement("div", {
|
|
32
44
|
paddingLeft: 16
|
33
45
|
}
|
34
46
|
}, fn()));
|
35
|
-
|
36
47
|
const alertTypeArgType = {
|
37
48
|
table: {
|
38
49
|
type: {
|
@@ -58,7 +69,7 @@ const actionsArgType = {
|
|
58
69
|
}
|
59
70
|
}
|
60
71
|
};
|
61
|
-
var _default = {
|
72
|
+
var _default = exports.default = {
|
62
73
|
title: 'Alert Bar',
|
63
74
|
component: _index.AlertBar,
|
64
75
|
decorators: [Wrapper],
|
@@ -71,24 +82,25 @@ var _default = {
|
|
71
82
|
}
|
72
83
|
},
|
73
84
|
argTypes: {
|
74
|
-
actions: {
|
85
|
+
actions: {
|
86
|
+
...actionsArgType
|
75
87
|
},
|
76
|
-
critical: {
|
88
|
+
critical: {
|
89
|
+
...alertTypeArgType
|
77
90
|
},
|
78
|
-
success: {
|
91
|
+
success: {
|
92
|
+
...alertTypeArgType
|
79
93
|
},
|
80
|
-
warning: {
|
94
|
+
warning: {
|
95
|
+
...alertTypeArgType
|
81
96
|
},
|
82
|
-
icon: {
|
97
|
+
icon: {
|
98
|
+
...iconArgType
|
83
99
|
}
|
84
100
|
}
|
85
101
|
};
|
86
|
-
exports.default = _default;
|
87
|
-
|
88
102
|
const Default = args => /*#__PURE__*/_react.default.createElement(_index.AlertBar, args, "Default - I will autohide");
|
89
|
-
|
90
103
|
exports.Default = Default;
|
91
|
-
|
92
104
|
const States = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
93
105
|
permanent: true
|
94
106
|
}, "Default (info)"), /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
@@ -101,9 +113,7 @@ const States = () => /*#__PURE__*/_react.default.createElement(_react.default.Fr
|
|
101
113
|
permanent: true,
|
102
114
|
critical: true
|
103
115
|
}, "Critical"));
|
104
|
-
|
105
116
|
exports.States = States;
|
106
|
-
|
107
117
|
const RTL = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
108
118
|
dir: "rtl"
|
109
119
|
}, /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
@@ -118,9 +128,7 @@ const RTL = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragm
|
|
118
128
|
permanent: true,
|
119
129
|
critical: true
|
120
130
|
}, "Critical")));
|
121
|
-
|
122
131
|
exports.RTL = RTL;
|
123
|
-
|
124
132
|
const AutoHiding = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
125
133
|
permanent: true
|
126
134
|
}, "Permanent never auto-hides"), /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
@@ -139,10 +147,8 @@ const AutoHiding = () => /*#__PURE__*/_react.default.createElement(_react.defaul
|
|
139
147
|
console.log('onHidden event', event);
|
140
148
|
}
|
141
149
|
}, "Default auto-hides after 8s"));
|
142
|
-
|
143
150
|
exports.AutoHiding = AutoHiding;
|
144
151
|
AutoHiding.storyName = 'Auto hiding';
|
145
|
-
|
146
152
|
const WithActions = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
147
153
|
permanent: true,
|
148
154
|
actions: [{
|
@@ -153,10 +159,8 @@ const WithActions = () => /*#__PURE__*/_react.default.createElement(_index.Alert
|
|
153
159
|
onClick: () => {}
|
154
160
|
}]
|
155
161
|
}, "With Actions");
|
156
|
-
|
157
162
|
exports.WithActions = WithActions;
|
158
163
|
WithActions.storyName = 'With actions';
|
159
|
-
|
160
164
|
const WithActionsAndInsufficientSpace = () => /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
161
165
|
permanent: true,
|
162
166
|
actions: [{
|
@@ -167,10 +171,8 @@ const WithActionsAndInsufficientSpace = () => /*#__PURE__*/_react.default.create
|
|
167
171
|
onClick: () => {}
|
168
172
|
}]
|
169
173
|
}, "Some text, a pretty normal amount, that conflicts with pretty long actions");
|
170
|
-
|
171
174
|
exports.WithActionsAndInsufficientSpace = WithActionsAndInsufficientSpace;
|
172
175
|
WithActionsAndInsufficientSpace.storyName = 'With actions and insufficient space';
|
173
|
-
|
174
176
|
const Icons = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
175
177
|
permanent: true
|
176
178
|
}, "Default icon"), /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
@@ -180,23 +182,17 @@ const Icons = () => /*#__PURE__*/_react.default.createElement(_react.default.Fra
|
|
180
182
|
permanent: true,
|
181
183
|
icon: /*#__PURE__*/_react.default.createElement(_uiIcons.IconFile16, null)
|
182
184
|
}, "Custom icon"));
|
183
|
-
|
184
185
|
exports.Icons = Icons;
|
185
|
-
|
186
186
|
const TextOverflow = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
187
187
|
permanent: true
|
188
188
|
}, "Short text"), /*#__PURE__*/_react.default.createElement(_index.AlertBar, {
|
189
189
|
permanent: true
|
190
190
|
}, "If the alert bar gets a ver long text, it will grow to a maximum of 600px and the text will overflow across several lines. If there are multiple AlertBars in a stack, they will all grow to the size of the widest sibling."));
|
191
|
-
|
192
191
|
exports.TextOverflow = TextOverflow;
|
193
192
|
TextOverflow.storyName = 'Text overflow';
|
194
|
-
|
195
193
|
const HiddenProp = () => {
|
196
194
|
const [hidden, setHidden] = (0, _react.useState)(true);
|
197
|
-
|
198
195
|
const toggleVisibility = () => setHidden(prevHidden => !prevHidden);
|
199
|
-
|
200
196
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
|
201
197
|
style: {
|
202
198
|
display: 'block',
|
@@ -210,6 +206,5 @@ const HiddenProp = () => {
|
|
210
206
|
hidden: hidden
|
211
207
|
}, "Short text"));
|
212
208
|
};
|
213
|
-
|
214
209
|
exports.HiddenProp = HiddenProp;
|
215
210
|
HiddenProp.storyName = 'Hidden prop';
|
@@ -4,12 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = exports.ANIMATION_TIME = void 0;
|
7
|
-
|
8
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
9
|
-
|
10
|
-
const
|
11
|
-
exports.ANIMATION_TIME = ANIMATION_TIME;
|
12
|
-
const _defaultExport = ["div.jsx-1114274882{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border-radius:4px;box-shadow:".concat(_uiConstants.elevations.e300, ";padding-top:").concat(_uiConstants.spacers.dp8, ";padding-inline-end:").concat(_uiConstants.spacers.dp8, ";padding-bottom:").concat(_uiConstants.spacers.dp8, ";padding-inline-start:").concat(_uiConstants.spacers.dp24, ";margin-bottom:").concat(_uiConstants.spacers.dp16, ";max-width:600px;min-width:300px;font-size:14px;pointer-events:all;}"), "div.info.jsx-1114274882{background-color:".concat(_uiConstants.colors.grey900, ";color:").concat(_uiConstants.colors.white, ";}"), "div.success.jsx-1114274882{background-color:".concat(_uiConstants.colors.green800, ";color:").concat(_uiConstants.colors.white, ";}"), "div.warning.jsx-1114274882{background-color:".concat(_uiConstants.colors.yellow300, ";color:").concat(_uiConstants.colors.yellow900, ";}"), "div.critical.jsx-1114274882{background-color:".concat(_uiConstants.colors.red800, ";color:").concat(_uiConstants.colors.white, ";}"), "@-webkit-keyframes slidein-jsx-1114274882{from{-webkit-transform:translateY(1000px);-ms-transform:translateY(1000px);transform:translateY(1000px);}to{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}}", "@keyframes slidein-jsx-1114274882{from{-webkit-transform:translateY(1000px);-ms-transform:translateY(1000px);transform:translateY(1000px);}to{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}}", "@-webkit-keyframes slideout-jsx-1114274882{from{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}to{-webkit-transform:translateY(1000px);-ms-transform:translateY(1000px);transform:translateY(1000px);}}", "@keyframes slideout-jsx-1114274882{from{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}to{-webkit-transform:translateY(1000px);-ms-transform:translateY(1000px);transform:translateY(1000px);}}", "div.inViewport.jsx-1114274882{-webkit-animation-duration:".concat(ANIMATION_TIME, "ms;animation-duration:").concat(ANIMATION_TIME, "ms;-webkit-animation-name:slidein-jsx-1114274882;animation-name:slidein-jsx-1114274882;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-timing-function:cubic-bezier(0.4,0,0.6,1);animation-timing-function:cubic-bezier(0.4,0,0.6,1);}"), "div.jsx-1114274882{-webkit-animation-duration:".concat(ANIMATION_TIME, "ms;animation-duration:").concat(ANIMATION_TIME, "ms;-webkit-animation-name:slideout-jsx-1114274882;animation-name:slideout-jsx-1114274882;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-timing-function:cubic-bezier(0.4,0,0.6,1);animation-timing-function:cubic-bezier(0.4,0,0.6,1);}")];
|
8
|
+
const ANIMATION_TIME = exports.ANIMATION_TIME = 350;
|
9
|
+
const _defaultExport = [`div.jsx-1114274882{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;border-radius:4px;box-shadow:${_uiConstants.elevations.e300};padding-top:${_uiConstants.spacers.dp8};padding-inline-end:${_uiConstants.spacers.dp8};padding-bottom:${_uiConstants.spacers.dp8};padding-inline-start:${_uiConstants.spacers.dp24};margin-bottom:${_uiConstants.spacers.dp16};max-width:600px;min-width:300px;font-size:14px;pointer-events:all;}`, `div.info.jsx-1114274882{background-color:${_uiConstants.colors.grey900};color:${_uiConstants.colors.white};}`, `div.success.jsx-1114274882{background-color:${_uiConstants.colors.green800};color:${_uiConstants.colors.white};}`, `div.warning.jsx-1114274882{background-color:${_uiConstants.colors.yellow300};color:${_uiConstants.colors.yellow900};}`, `div.critical.jsx-1114274882{background-color:${_uiConstants.colors.red800};color:${_uiConstants.colors.white};}`, "@-webkit-keyframes slidein-jsx-1114274882{from{-webkit-transform:translateY(1000px);-ms-transform:translateY(1000px);transform:translateY(1000px);}to{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}}", "@keyframes slidein-jsx-1114274882{from{-webkit-transform:translateY(1000px);-ms-transform:translateY(1000px);transform:translateY(1000px);}to{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}}", "@-webkit-keyframes slideout-jsx-1114274882{from{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}to{-webkit-transform:translateY(1000px);-ms-transform:translateY(1000px);transform:translateY(1000px);}}", "@keyframes slideout-jsx-1114274882{from{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0);}to{-webkit-transform:translateY(1000px);-ms-transform:translateY(1000px);transform:translateY(1000px);}}", `div.inViewport.jsx-1114274882{-webkit-animation-duration:${ANIMATION_TIME}ms;animation-duration:${ANIMATION_TIME}ms;-webkit-animation-name:slidein-jsx-1114274882;animation-name:slidein-jsx-1114274882;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-timing-function:cubic-bezier(0.4,0,0.6,1);animation-timing-function:cubic-bezier(0.4,0,0.6,1);}`, `div.jsx-1114274882{-webkit-animation-duration:${ANIMATION_TIME}ms;animation-duration:${ANIMATION_TIME}ms;-webkit-animation-name:slideout-jsx-1114274882;animation-name:slideout-jsx-1114274882;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-timing-function:cubic-bezier(0.4,0,0.6,1);animation-timing-function:cubic-bezier(0.4,0,0.6,1);}`];
|
13
10
|
_defaultExport.__hash = "1114274882";
|
14
|
-
var _default = _defaultExport;
|
15
|
-
exports.default = _default;
|
11
|
+
var _default = exports.default = _defaultExport;
|
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.Dismiss = 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 _uiIcons = require("@dhis2/ui-icons");
|
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 Dismiss = _ref => {
|
21
14
|
let {
|
22
15
|
onClick,
|
@@ -29,9 +22,8 @@ const Dismiss = _ref => {
|
|
29
22
|
}, /*#__PURE__*/_react.default.createElement(_uiIcons.IconCross24, null), /*#__PURE__*/_react.default.createElement(_style.default, {
|
30
23
|
id: "1892313381",
|
31
24
|
dynamic: [_uiConstants.spacers.dp16]
|
32
|
-
}, [
|
25
|
+
}, [`div.__jsx-style-dynamic-selector{margin-inline-start:${_uiConstants.spacers.dp16};min-height:32px;min-width:32px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;border-radius:5px;}`, "div.__jsx-style-dynamic-selector:hover{cursor:pointer;background:rgba(0,0,0,0.15);}", "div.__jsx-style-dynamic-selector:active{background:rgba(0,0,0,0.25);}", "div.__jsx-style-dynamic-selector svg{width:18px;height:18px;}"]));
|
33
26
|
};
|
34
|
-
|
35
27
|
exports.Dismiss = Dismiss;
|
36
28
|
Dismiss.propTypes = {
|
37
29
|
dataTest: _propTypes.default.string.isRequired,
|
@@ -1,9 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
4
|
-
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('an AlertBar with onHidden handler is rendered', () => {
|
6
|
-
cy.visitStory('AlertBar', 'With
|
5
|
+
cy.visitStory('AlertBar', 'With on hidden');
|
7
6
|
});
|
8
7
|
(0, _cypressCucumberPreprocessor.Given)('an AlertBar with disabled icon is rendered', () => {
|
9
8
|
cy.visitStory('AlertBar', 'Disabled icon');
|
@@ -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 default AlertBar is rendered', () => {
|
6
5
|
cy.visitStory('AlertBar', 'Default');
|
7
6
|
cy.get('[data-test="dhis2-uicore-alertbar"]').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 permanent AlertBar with hidden and onHidden is rendered', () => {
|
6
5
|
cy.visitStory('AlertBar', 'Hidden prop');
|
7
6
|
});
|
@@ -16,8 +15,11 @@ var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preproces
|
|
16
15
|
(0, _cypressCucumberPreprocessor.When)('the user clicks on the "Cancel" button', () => {
|
17
16
|
cy.get('[data-test="dhis2-uicore-alertbar-action"]:contains("Cancel")').click();
|
18
17
|
});
|
19
|
-
(0, _cypressCucumberPreprocessor.When)('the user click a button which toggles the hidden prop', () => {
|
20
|
-
cy.get('button').click();
|
18
|
+
(0, _cypressCucumberPreprocessor.When)('the user click a button which toggles the hidden prop to false', () => {
|
19
|
+
cy.get('button:contains("Show")').click();
|
20
|
+
});
|
21
|
+
(0, _cypressCucumberPreprocessor.When)('the user click a button which toggles the hidden prop to true', () => {
|
22
|
+
cy.get('button:contains("Hide")').click();
|
21
23
|
});
|
22
24
|
(0, _cypressCucumberPreprocessor.When)('the custom duration has passed', () => {
|
23
25
|
cy.wait(2000);
|