@sb1/ffe-system-message-react 6.4.1 → 6.4.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/es/SystemErrorMessage.js +59 -0
- package/es/SystemInfoMessage.js +11 -0
- package/es/SystemMessage.js +159 -0
- package/es/SystemNewsMessage.js +11 -0
- package/es/SystemSuccessMessage.js +11 -0
- package/es/index.js +5 -0
- package/package.json +4 -3
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var _excluded = ["alert"];
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
|
|
5
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
+
|
|
7
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { func, string, number, node, oneOf, bool } from 'prop-types';
|
|
11
|
+
import UtropstegnIkon from "@sb1/ffe-icons-react/es/utropstegn-ikon";
|
|
12
|
+
import SystemMessage from './SystemMessage';
|
|
13
|
+
export default function SystemErrorMessage(props) {
|
|
14
|
+
var alert = props.alert,
|
|
15
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
16
|
+
|
|
17
|
+
return /*#__PURE__*/React.createElement(SystemMessage, _extends({
|
|
18
|
+
modifier: "error",
|
|
19
|
+
icon: /*#__PURE__*/React.createElement(UtropstegnIkon, {
|
|
20
|
+
"aria-hidden": "true"
|
|
21
|
+
}),
|
|
22
|
+
role: alert ? 'alert' : false
|
|
23
|
+
}, rest));
|
|
24
|
+
}
|
|
25
|
+
SystemErrorMessage.defaultProps = {
|
|
26
|
+
animationLengthMs: 300,
|
|
27
|
+
locale: 'nb',
|
|
28
|
+
onClose: function onClose(f) {
|
|
29
|
+
return f;
|
|
30
|
+
},
|
|
31
|
+
alert: true
|
|
32
|
+
};
|
|
33
|
+
SystemErrorMessage.propTypes = {
|
|
34
|
+
animationLengthMs: number,
|
|
35
|
+
|
|
36
|
+
/** The content of the system message */
|
|
37
|
+
children: node.isRequired,
|
|
38
|
+
|
|
39
|
+
/** Additional classes added to the surrounding div */
|
|
40
|
+
className: string,
|
|
41
|
+
|
|
42
|
+
/** Override the default icon - use with caution! */
|
|
43
|
+
icon: node,
|
|
44
|
+
|
|
45
|
+
/** 'nb', 'nn', or 'en' */
|
|
46
|
+
locale: oneOf(['en', 'nb', 'nn']),
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The type of system message. Used internally only-
|
|
50
|
+
* @ignore
|
|
51
|
+
**/
|
|
52
|
+
modifier: oneOf(['error', 'info', 'success', 'news']),
|
|
53
|
+
|
|
54
|
+
/** Callback for when the system message has been closed (after animation ends) */
|
|
55
|
+
onClose: func,
|
|
56
|
+
|
|
57
|
+
/** When false, role is not set to alert, avoids message from being read up immediately after page load. Default value is true. */
|
|
58
|
+
alert: bool
|
|
59
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import InfoIkon from "@sb1/ffe-icons-react/es/info-ikon";
|
|
5
|
+
import SystemMessage from './SystemMessage';
|
|
6
|
+
export default function SystemInfoMessage(props) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(SystemMessage, _extends({
|
|
8
|
+
modifier: "info",
|
|
9
|
+
icon: /*#__PURE__*/React.createElement(InfoIkon, null)
|
|
10
|
+
}, props));
|
|
11
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
|
|
3
|
+
var _excluded = ["animationLengthMs", "children", "className", "icon", "locale", "modifier", "onColoredBg"];
|
|
4
|
+
|
|
5
|
+
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); }
|
|
6
|
+
|
|
7
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
|
+
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
+
|
|
13
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
14
|
+
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
+
|
|
17
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
18
|
+
|
|
19
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
+
|
|
21
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
22
|
+
|
|
23
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
24
|
+
|
|
25
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
|
+
|
|
27
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
28
|
+
|
|
29
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
+
|
|
31
|
+
import React, { Component } from 'react';
|
|
32
|
+
import { func, string, number, node, oneOf, bool } from 'prop-types';
|
|
33
|
+
import classNames from 'classnames';
|
|
34
|
+
import KryssIkon from "@sb1/ffe-icons-react/es/kryss-ikon";
|
|
35
|
+
|
|
36
|
+
var SystemMessage = /*#__PURE__*/function (_Component) {
|
|
37
|
+
_inherits(SystemMessage, _Component);
|
|
38
|
+
|
|
39
|
+
var _super = _createSuper(SystemMessage);
|
|
40
|
+
|
|
41
|
+
function SystemMessage() {
|
|
42
|
+
var _this;
|
|
43
|
+
|
|
44
|
+
_classCallCheck(this, SystemMessage);
|
|
45
|
+
|
|
46
|
+
_this = _super.call(this);
|
|
47
|
+
_this.close = _this.close.bind(_assertThisInitialized(_this));
|
|
48
|
+
_this.state = {
|
|
49
|
+
closed: false
|
|
50
|
+
};
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_createClass(SystemMessage, [{
|
|
55
|
+
key: "close",
|
|
56
|
+
value: function close(event) {
|
|
57
|
+
var _this2 = this;
|
|
58
|
+
|
|
59
|
+
var _this$props = this.props,
|
|
60
|
+
animationLengthMs = _this$props.animationLengthMs,
|
|
61
|
+
onClose = _this$props.onClose;
|
|
62
|
+
var self = this._self;
|
|
63
|
+
self.style.height = "".concat(self.offsetHeight, "px");
|
|
64
|
+
setTimeout(function () {
|
|
65
|
+
self.style.height = 0;
|
|
66
|
+
}, 0);
|
|
67
|
+
setTimeout(function () {
|
|
68
|
+
_this2.setState({
|
|
69
|
+
closed: true
|
|
70
|
+
}, function () {
|
|
71
|
+
onClose(event);
|
|
72
|
+
});
|
|
73
|
+
}, animationLengthMs);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "render",
|
|
78
|
+
value: function render() {
|
|
79
|
+
var _this3 = this;
|
|
80
|
+
|
|
81
|
+
var _this$props2 = this.props,
|
|
82
|
+
animationLengthMs = _this$props2.animationLengthMs,
|
|
83
|
+
children = _this$props2.children,
|
|
84
|
+
className = _this$props2.className,
|
|
85
|
+
icon = _this$props2.icon,
|
|
86
|
+
locale = _this$props2.locale,
|
|
87
|
+
modifier = _this$props2.modifier,
|
|
88
|
+
onColoredBg = _this$props2.onColoredBg,
|
|
89
|
+
rest = _objectWithoutProperties(_this$props2, _excluded);
|
|
90
|
+
|
|
91
|
+
if (this.state.closed) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
96
|
+
className: classNames('ffe-system-message-wrapper', "ffe-system-message-wrapper--".concat(modifier), {
|
|
97
|
+
'ffe-system-message-wrapper--coloredbg': onColoredBg
|
|
98
|
+
}, className),
|
|
99
|
+
ref: function ref(_self) {
|
|
100
|
+
_this3._self = _self;
|
|
101
|
+
},
|
|
102
|
+
style: {
|
|
103
|
+
transition: "height ".concat(animationLengthMs / 1000, "s")
|
|
104
|
+
}
|
|
105
|
+
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
106
|
+
className: "ffe-system-message"
|
|
107
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
108
|
+
className: "ffe-system-message__icon"
|
|
109
|
+
}, icon), /*#__PURE__*/React.createElement("p", {
|
|
110
|
+
className: "ffe-system-message__content"
|
|
111
|
+
}, children), /*#__PURE__*/React.createElement("button", {
|
|
112
|
+
"aria-label": locale === 'en' ? 'Close' : 'Lukk',
|
|
113
|
+
className: "ffe-system-message__close",
|
|
114
|
+
onClick: this.close,
|
|
115
|
+
type: "button"
|
|
116
|
+
}, /*#__PURE__*/React.createElement(KryssIkon, {
|
|
117
|
+
"aria-hidden": "true"
|
|
118
|
+
}))));
|
|
119
|
+
}
|
|
120
|
+
}]);
|
|
121
|
+
|
|
122
|
+
return SystemMessage;
|
|
123
|
+
}(Component);
|
|
124
|
+
|
|
125
|
+
SystemMessage.defaultProps = {
|
|
126
|
+
animationLengthMs: 300,
|
|
127
|
+
locale: 'nb',
|
|
128
|
+
onClose: function onClose(f) {
|
|
129
|
+
return f;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
SystemMessage.propTypes = {
|
|
133
|
+
animationLengthMs: number,
|
|
134
|
+
|
|
135
|
+
/** The content of the system message */
|
|
136
|
+
children: node.isRequired,
|
|
137
|
+
|
|
138
|
+
/** Additional classes added to the surrounding div */
|
|
139
|
+
className: string,
|
|
140
|
+
|
|
141
|
+
/** Override the default icon - use with caution! */
|
|
142
|
+
icon: node.isRequired,
|
|
143
|
+
|
|
144
|
+
/** 'nb', 'nn', or 'en' */
|
|
145
|
+
locale: oneOf(['en', 'nb', 'nn']),
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The type of system message. Used internally only-
|
|
149
|
+
* @ignore
|
|
150
|
+
**/
|
|
151
|
+
modifier: oneOf(['error', 'info', 'success', 'news']),
|
|
152
|
+
|
|
153
|
+
/** Callback for when the system message has been closed (after animation ends) */
|
|
154
|
+
onClose: func,
|
|
155
|
+
|
|
156
|
+
/* Adds alternative styling for better contrast on certain backgrounds */
|
|
157
|
+
onColoredBg: bool
|
|
158
|
+
};
|
|
159
|
+
export default SystemMessage;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import InfoIkon from "@sb1/ffe-icons-react/es/info-ikon";
|
|
5
|
+
import SystemMessage from './SystemMessage';
|
|
6
|
+
export default function SystemNewsMessage(props) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(SystemMessage, _extends({
|
|
8
|
+
modifier: "news",
|
|
9
|
+
icon: /*#__PURE__*/React.createElement(InfoIkon, null)
|
|
10
|
+
}, props));
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import HakeIkon from "@sb1/ffe-icons-react/es/hake-ikon";
|
|
5
|
+
import SystemMessage from './SystemMessage';
|
|
6
|
+
export default function SystemSuccessMessage(props) {
|
|
7
|
+
return /*#__PURE__*/React.createElement(SystemMessage, _extends({
|
|
8
|
+
modifier: "success",
|
|
9
|
+
icon: /*#__PURE__*/React.createElement(HakeIkon, null)
|
|
10
|
+
}, props));
|
|
11
|
+
}
|
package/es/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import SystemErrorMessage from './SystemErrorMessage';
|
|
2
|
+
import SystemInfoMessage from './SystemInfoMessage';
|
|
3
|
+
import SystemNewsMessage from './SystemNewsMessage';
|
|
4
|
+
import SystemSuccessMessage from './SystemSuccessMessage';
|
|
5
|
+
export { SystemErrorMessage, SystemInfoMessage, SystemNewsMessage, SystemSuccessMessage };
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-system-message-react",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.2",
|
|
4
4
|
"description": "SpareBank 1 System Message komponent",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SpareBank 1",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib",
|
|
9
|
+
"es",
|
|
9
10
|
"types"
|
|
10
11
|
],
|
|
11
12
|
"main": "lib/index.js",
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@sb1/ffe-buildtool": "^0.4.0",
|
|
32
|
-
"@sb1/ffe-icons-react": "^7.3.
|
|
33
|
+
"@sb1/ffe-icons-react": "^7.3.2",
|
|
33
34
|
"react": "^16.9.0",
|
|
34
35
|
"react-dom": "^16.9.0"
|
|
35
36
|
},
|
|
@@ -41,5 +42,5 @@
|
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "e11a27a9d7504e11ef1ae799c6c206e160bd5606"
|
|
45
46
|
}
|