dibk-design 0.3.24
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/LICENSE +674 -0
- package/README.md +3 -0
- package/dist/components/Accordion.js +120 -0
- package/dist/components/Accordion.md +15 -0
- package/dist/components/Accordion.module.scss +180 -0
- package/dist/components/Button.js +104 -0
- package/dist/components/Button.md +48 -0
- package/dist/components/Button.module.scss +141 -0
- package/dist/components/CheckBoxIcon.js +97 -0
- package/dist/components/CheckBoxIcon.md +23 -0
- package/dist/components/CheckBoxIcon.module.scss +39 -0
- package/dist/components/CheckBoxInput.js +91 -0
- package/dist/components/CheckBoxInput.md +39 -0
- package/dist/components/CheckBoxInput.module.scss +18 -0
- package/dist/components/CheckBoxListItem.js +85 -0
- package/dist/components/CheckBoxListItem.md +35 -0
- package/dist/components/CheckBoxListItem.module.scss +59 -0
- package/dist/components/ContentBox.js +106 -0
- package/dist/components/ContentBox.md +46 -0
- package/dist/components/ContentBox.module.scss +105 -0
- package/dist/components/DragAndDropFileInput.js +196 -0
- package/dist/components/DragAndDropFileInput.md +7 -0
- package/dist/components/DragAndDropFileInput.module.scss +36 -0
- package/dist/components/Footer.js +62 -0
- package/dist/components/Footer.md +7 -0
- package/dist/components/Footer.module.scss +11 -0
- package/dist/components/Header.js +75 -0
- package/dist/components/Header.md +7 -0
- package/dist/components/Header.module.scss +30 -0
- package/dist/components/InputField.js +201 -0
- package/dist/components/InputField.md +36 -0
- package/dist/components/InputField.module.scss +91 -0
- package/dist/components/List.js +106 -0
- package/dist/components/List.md +10 -0
- package/dist/components/List.module.scss +19 -0
- package/dist/components/LoadingAnimation.js +74 -0
- package/dist/components/LoadingAnimation.md +5 -0
- package/dist/components/LoadingAnimation.module.scss +26 -0
- package/dist/components/NavigationBar.js +229 -0
- package/dist/components/NavigationBar.md +31 -0
- package/dist/components/NavigationBar.module.scss +176 -0
- package/dist/components/NavigationBarListItem.js +85 -0
- package/dist/components/NavigationBarListItem.md +16 -0
- package/dist/components/Paper.js +71 -0
- package/dist/components/Paper.md +9 -0
- package/dist/components/Paper.module.scss +17 -0
- package/dist/components/RadioButtonIcon.js +92 -0
- package/dist/components/RadioButtonIcon.md +23 -0
- package/dist/components/RadioButtonIcon.module.scss +21 -0
- package/dist/components/RadioButtonInput.js +89 -0
- package/dist/components/RadioButtonInput.md +22 -0
- package/dist/components/RadioButtonInput.module.scss +15 -0
- package/dist/components/RadioButtonListItem.js +86 -0
- package/dist/components/RadioButtonListItem.md +24 -0
- package/dist/components/RadioButtonListItem.module.scss +59 -0
- package/dist/components/Select.js +188 -0
- package/dist/components/Select.md +26 -0
- package/dist/components/Select.module.scss +84 -0
- package/dist/components/Theme.js +131 -0
- package/dist/components/Theme.md +12 -0
- package/dist/components/Theme.module.scss +76 -0
- package/dist/components/WizardNavigation/Step.js +104 -0
- package/dist/components/WizardNavigation/Step.module.scss +75 -0
- package/dist/components/WizardNavigation.js +95 -0
- package/dist/components/WizardNavigation.md +84 -0
- package/dist/components/WizardNavigation.module.scss +4 -0
- package/dist/fonts/Altis-Light.eot +0 -0
- package/dist/fonts/Altis-Light.svg +326 -0
- package/dist/fonts/Altis-Light.ttf +0 -0
- package/dist/fonts/Altis-Light.woff +0 -0
- package/dist/functions/theme.js +60 -0
- package/dist/images/dibk-logo-mobile.svg +91 -0
- package/dist/images/dibk-logo.svg +991 -0
- package/dist/images/spinner.svg +57 -0
- package/dist/index.js +185 -0
- package/dist/style/abstracts/_all.scss +2 -0
- package/dist/style/abstracts/mixins/_all.scss +12 -0
- package/dist/style/abstracts/mixins/_animation.scss +6 -0
- package/dist/style/abstracts/mixins/_appearance.scss +5 -0
- package/dist/style/abstracts/mixins/_border-radius.scss +31 -0
- package/dist/style/abstracts/mixins/_box-shadow.scss +5 -0
- package/dist/style/abstracts/mixins/_box-sizing.scss +5 -0
- package/dist/style/abstracts/mixins/_calc.scss +5 -0
- package/dist/style/abstracts/mixins/_keyframes.scss +14 -0
- package/dist/style/abstracts/mixins/_opacity.scss +5 -0
- package/dist/style/abstracts/mixins/_placeholder.scss +17 -0
- package/dist/style/abstracts/mixins/_scrollbar.scss +26 -0
- package/dist/style/abstracts/mixins/_transform.scss +6 -0
- package/dist/style/abstracts/mixins/_transition.scss +34 -0
- package/dist/style/abstracts/variables/_all.scss +3 -0
- package/dist/style/abstracts/variables/_colors.scss +35 -0
- package/dist/style/abstracts/variables/_typography.scss +1 -0
- package/dist/style/abstracts/variables/_viewports.scss +11 -0
- package/dist/style/base/_all.scss +2 -0
- package/dist/style/base/_reset.scss +15 -0
- package/dist/style/base/_typography.scss +6 -0
- package/dist/style/base/fonts.css +6 -0
- package/dist/style/global.scss +3 -0
- package/dist/style/layout/_all.scss +1 -0
- package/dist/style/layout/_containers.scss +9 -0
- package/package.json +43 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Drag and drop file input examples:
|
|
2
|
+
|
|
3
|
+
```js
|
|
4
|
+
<DragAndDropFileInput id="dragAndDropInput-1" label="Input without selected file" buttonContent="Velg fil" onSelectChange={() => console.log('Select change')} onDragAndDropChange={() => console.log('Drag and drop change')} />
|
|
5
|
+
<DragAndDropFileInput id="dragAndDropInput-2" label="Input with selected file" buttonContent="Velg fil" selectedFileName="important-file.xml" onSelectChange={() => console.log('Select change')} onDragAndDropChange={() => console.log('Drag and drop change')} />
|
|
6
|
+
<DragAndDropFileInput id="dragAndDropInput-3" label="Input with selected file and contentOnly" buttonContent="Velg fil" selectedFileName="important-file2.xml" onSelectChange={() => console.log('Select change')} onDragAndDropChange={() => console.log('Drag and drop change')} contentOnly={true} />
|
|
7
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@import "../style/global.scss";
|
|
2
|
+
|
|
3
|
+
:local(.dragAndDropFileInput) {
|
|
4
|
+
label {
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
font-size: 18px;
|
|
7
|
+
margin: 0 0 4px;
|
|
8
|
+
font-family: "Open Sans",arial,sans-serif;
|
|
9
|
+
line-height: 1.3;
|
|
10
|
+
font-weight: bold;
|
|
11
|
+
font-style: normal;
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:local(.dragAndDropContainer) {
|
|
16
|
+
@include transition(all 0.1s ease-in-out);
|
|
17
|
+
border: 2px dashed #ccc;
|
|
18
|
+
border-radius: 20px;
|
|
19
|
+
width: 100%;
|
|
20
|
+
padding: 20px;
|
|
21
|
+
text-align: center;
|
|
22
|
+
|
|
23
|
+
input {
|
|
24
|
+
display: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
button {
|
|
28
|
+
margin: 14px 0 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:local(.highlighted) {
|
|
32
|
+
background: $color-default;
|
|
33
|
+
border-color: $color-dark-blue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _FooterModule = _interopRequireDefault(require("./Footer.module.scss"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
+
|
|
18
|
+
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); } }
|
|
19
|
+
|
|
20
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
|
+
|
|
22
|
+
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
23
|
+
|
|
24
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
+
|
|
26
|
+
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); }; }
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
31
|
+
|
|
32
|
+
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; } }
|
|
33
|
+
|
|
34
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
+
|
|
36
|
+
var Footer = /*#__PURE__*/function (_React$Component) {
|
|
37
|
+
_inherits(Footer, _React$Component);
|
|
38
|
+
|
|
39
|
+
var _super = _createSuper(Footer);
|
|
40
|
+
|
|
41
|
+
function Footer() {
|
|
42
|
+
_classCallCheck(this, Footer);
|
|
43
|
+
|
|
44
|
+
return _super.apply(this, arguments);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_createClass(Footer, [{
|
|
48
|
+
key: "render",
|
|
49
|
+
value: function render() {
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement("footer", {
|
|
51
|
+
className: _FooterModule.default.footer
|
|
52
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
53
|
+
className: _FooterModule.default.footerContainer
|
|
54
|
+
}, this.props.children));
|
|
55
|
+
}
|
|
56
|
+
}]);
|
|
57
|
+
|
|
58
|
+
return Footer;
|
|
59
|
+
}(_react.default.Component);
|
|
60
|
+
|
|
61
|
+
var _default = Footer;
|
|
62
|
+
exports.default = _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _HeaderModule = _interopRequireDefault(require("./Header.module.scss"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
+
|
|
20
|
+
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); } }
|
|
21
|
+
|
|
22
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
23
|
+
|
|
24
|
+
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
25
|
+
|
|
26
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
27
|
+
|
|
28
|
+
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); }; }
|
|
29
|
+
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
|
+
|
|
34
|
+
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; } }
|
|
35
|
+
|
|
36
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
37
|
+
|
|
38
|
+
var Header = /*#__PURE__*/function (_React$Component) {
|
|
39
|
+
_inherits(Header, _React$Component);
|
|
40
|
+
|
|
41
|
+
var _super = _createSuper(Header);
|
|
42
|
+
|
|
43
|
+
function Header() {
|
|
44
|
+
_classCallCheck(this, Header);
|
|
45
|
+
|
|
46
|
+
return _super.apply(this, arguments);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_createClass(Header, [{
|
|
50
|
+
key: "render",
|
|
51
|
+
value: function render() {
|
|
52
|
+
var headerElement = /*#__PURE__*/_react.default.createElement('h' + this.props.size, {
|
|
53
|
+
className: _HeaderModule.default.header
|
|
54
|
+
}, this.props.content);
|
|
55
|
+
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
57
|
+
className: _HeaderModule.default.headerContainer
|
|
58
|
+
}, " ", headerElement, " ");
|
|
59
|
+
}
|
|
60
|
+
}]);
|
|
61
|
+
|
|
62
|
+
return Header;
|
|
63
|
+
}(_react.default.Component);
|
|
64
|
+
|
|
65
|
+
Header.propTypes = {
|
|
66
|
+
/** Text content inside button */
|
|
67
|
+
content: _propTypes.default.string.isRequired,
|
|
68
|
+
size: _propTypes.default.oneOf([1, 2, 3, 4, 5])
|
|
69
|
+
};
|
|
70
|
+
Header.defaultProps = {
|
|
71
|
+
content: '',
|
|
72
|
+
size: 1
|
|
73
|
+
};
|
|
74
|
+
var _default = Header;
|
|
75
|
+
exports.default = _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
:local(.headerContainer){
|
|
2
|
+
font-size: 22px;
|
|
3
|
+
padding: 10px 0;
|
|
4
|
+
:local(.header){
|
|
5
|
+
margin: 0;
|
|
6
|
+
font-weight: normal;
|
|
7
|
+
line-height: 1.4;
|
|
8
|
+
font-style: normal;
|
|
9
|
+
font-size: 18px;
|
|
10
|
+
}
|
|
11
|
+
:local(h1.header){
|
|
12
|
+
font-family: "Altis-Light","Open Sans",arial,sans-serif;
|
|
13
|
+
font-size: 50px;
|
|
14
|
+
line-height: 1.2;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
text-overflow: ellipsis;
|
|
17
|
+
}
|
|
18
|
+
:local(h2.header){
|
|
19
|
+
font-family: "Open Sans",arial,sans-serif;
|
|
20
|
+
font-size: 24px;
|
|
21
|
+
font-weight: bold;
|
|
22
|
+
line-height: 1.3;
|
|
23
|
+
}
|
|
24
|
+
:local(h3.header){
|
|
25
|
+
font-family: "Open Sans",arial,sans-serif;
|
|
26
|
+
font-size: 18px;
|
|
27
|
+
font-weight: bold;
|
|
28
|
+
line-height: 1.3;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _Button = _interopRequireDefault(require("./Button"));
|
|
15
|
+
|
|
16
|
+
var _reactDatepicker = _interopRequireWildcard(require("react-datepicker"));
|
|
17
|
+
|
|
18
|
+
var _dateFns = require("date-fns");
|
|
19
|
+
|
|
20
|
+
var _nb = _interopRequireDefault(require("date-fns/locale/nb"));
|
|
21
|
+
|
|
22
|
+
var _theme = require("../functions/theme");
|
|
23
|
+
|
|
24
|
+
require("react-datepicker/dist/react-datepicker.css");
|
|
25
|
+
|
|
26
|
+
var _InputFieldModule = _interopRequireDefault(require("./InputField.module.scss"));
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
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
|
+
|
|
34
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
35
|
+
|
|
36
|
+
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); } }
|
|
37
|
+
|
|
38
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
39
|
+
|
|
40
|
+
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
41
|
+
|
|
42
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
43
|
+
|
|
44
|
+
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); }; }
|
|
45
|
+
|
|
46
|
+
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); }
|
|
47
|
+
|
|
48
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
49
|
+
|
|
50
|
+
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; } }
|
|
51
|
+
|
|
52
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
53
|
+
|
|
54
|
+
(0, _reactDatepicker.registerLocale)('nb', _nb.default);
|
|
55
|
+
|
|
56
|
+
var InputField = /*#__PURE__*/function (_React$Component) {
|
|
57
|
+
_inherits(InputField, _React$Component);
|
|
58
|
+
|
|
59
|
+
var _super = _createSuper(InputField);
|
|
60
|
+
|
|
61
|
+
function InputField() {
|
|
62
|
+
_classCallCheck(this, InputField);
|
|
63
|
+
|
|
64
|
+
return _super.apply(this, arguments);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_createClass(InputField, [{
|
|
68
|
+
key: "getThemeErrorInputStyle",
|
|
69
|
+
value: function getThemeErrorInputStyle(theme) {
|
|
70
|
+
return {
|
|
71
|
+
boxShadow: "0 0 3px ".concat((0, _theme.getThemePaletteBackgroundColor)(theme, 'warning')),
|
|
72
|
+
borderColor: (0, _theme.getThemePaletteBackgroundColor)(theme, 'warning')
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "getThemeErrorMessageStyle",
|
|
77
|
+
value: function getThemeErrorMessageStyle(theme) {
|
|
78
|
+
return {
|
|
79
|
+
color: (0, _theme.getThemePaletteBackgroundColor)(theme, 'warning')
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "convertDateToString",
|
|
84
|
+
value: function convertDateToString(date) {
|
|
85
|
+
return date ? (0, _dateFns.format)(new Date(date), this.props.dateFormat, {
|
|
86
|
+
locale: _nb.default
|
|
87
|
+
}) : '';
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "renderValueAsText",
|
|
91
|
+
value: function renderValueAsText(value, defaultContent) {
|
|
92
|
+
return this.props.type === 'date' ? value ? this.convertDateToString(value) : defaultContent : value ? value : defaultContent;
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "renderInputField",
|
|
96
|
+
value: function renderInputField() {
|
|
97
|
+
var _this = this;
|
|
98
|
+
|
|
99
|
+
return this.props.type === 'date' ? /*#__PURE__*/_react.default.createElement(_reactDatepicker.default, {
|
|
100
|
+
name: this.props.name,
|
|
101
|
+
readOnly: this.props.readOnly,
|
|
102
|
+
disabled: this.props.disabled,
|
|
103
|
+
id: this.props.id,
|
|
104
|
+
dateFormat: this.props.dateFormat,
|
|
105
|
+
locale: "nb",
|
|
106
|
+
selectsStart: this.props.selectsStart,
|
|
107
|
+
selectsEnd: this.props.selectsEnd,
|
|
108
|
+
startDate: this.props.startDate ? new Date(this.props.startDate) : null,
|
|
109
|
+
endDate: this.props.endDate ? new Date(this.props.endDate) : null,
|
|
110
|
+
onChange: this.props.onChange ? function (date) {
|
|
111
|
+
return _this.props.onChange(date);
|
|
112
|
+
} : console.log("Missing onChange handler for date picker with id: ".concat(this.props.id)),
|
|
113
|
+
onBlur: this.props.onBlur ? function (date) {
|
|
114
|
+
return _this.props.onBlur(date);
|
|
115
|
+
} : null,
|
|
116
|
+
selected: this.props.value ? new Date(this.props.value) : null,
|
|
117
|
+
placeholderText: this.props.placeholder,
|
|
118
|
+
className: this.props.hasErrors ? _InputFieldModule.default.hasErrors : '',
|
|
119
|
+
style: this.props.hasErrors ? this.getThemeErrorInputStyle(this.props.theme) : null
|
|
120
|
+
}) : /*#__PURE__*/_react.default.createElement("input", {
|
|
121
|
+
name: this.props.name,
|
|
122
|
+
readOnly: this.props.readOnly,
|
|
123
|
+
disabled: this.props.disabled,
|
|
124
|
+
type: this.props.type,
|
|
125
|
+
id: this.props.id,
|
|
126
|
+
onChange: this.props.onChange,
|
|
127
|
+
onBlur: this.props.onBlur,
|
|
128
|
+
value: this.props.value ? this.props.value : '',
|
|
129
|
+
placeholder: this.props.placeholder,
|
|
130
|
+
className: this.props.hasErrors ? _InputFieldModule.default.hasErrors : '',
|
|
131
|
+
"aria-required": this.props.mandatory,
|
|
132
|
+
style: this.props.hasErrors ? this.getThemeErrorInputStyle(this.props.theme) : null
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "render",
|
|
137
|
+
value: function render() {
|
|
138
|
+
var _this2 = this;
|
|
139
|
+
|
|
140
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
141
|
+
className: "".concat(_InputFieldModule.default.inputField, " ").concat(_InputFieldModule.default[this.props.type])
|
|
142
|
+
}, /*#__PURE__*/_react.default.createElement("label", {
|
|
143
|
+
htmlFor: this.props.id
|
|
144
|
+
}, this.props.label, this.props.type === 'file' ? /*#__PURE__*/_react.default.createElement("div", {
|
|
145
|
+
className: _InputFieldModule.default.fileInputContainer
|
|
146
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
147
|
+
className: _InputFieldModule.default.input
|
|
148
|
+
}, this.props.selectedFileName), this.props.buttonContent ? /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
149
|
+
size: "small",
|
|
150
|
+
color: this.props.buttonColor,
|
|
151
|
+
onClick: function onClick() {
|
|
152
|
+
document.getElementById(_this2.props.id).click();
|
|
153
|
+
},
|
|
154
|
+
content: this.props.buttonContent,
|
|
155
|
+
theme: this.props.theme
|
|
156
|
+
}) : '') : ''), !this.props.contentOnly ? this.renderInputField() : /*#__PURE__*/_react.default.createElement("span", null, this.renderValueAsText(this.props.value, this.props.defaultContent)), /*#__PURE__*/_react.default.createElement("span", {
|
|
157
|
+
className: _InputFieldModule.default.errorMessage,
|
|
158
|
+
style: this.getThemeErrorMessageStyle(this.props.theme)
|
|
159
|
+
}, this.props.errorMessage ? this.props.errorMessage : ''));
|
|
160
|
+
}
|
|
161
|
+
}]);
|
|
162
|
+
|
|
163
|
+
return InputField;
|
|
164
|
+
}(_react.default.Component);
|
|
165
|
+
|
|
166
|
+
InputField.propTypes = {
|
|
167
|
+
/** Text content inside list item */
|
|
168
|
+
id: _propTypes.default.string.isRequired,
|
|
169
|
+
onChange: _propTypes.default.func.isRequired,
|
|
170
|
+
onBlur: _propTypes.default.func,
|
|
171
|
+
name: _propTypes.default.string,
|
|
172
|
+
type: _propTypes.default.string,
|
|
173
|
+
value: _propTypes.default.any,
|
|
174
|
+
label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]))]),
|
|
175
|
+
contentOnly: _propTypes.default.bool,
|
|
176
|
+
buttonColor: _propTypes.default.string,
|
|
177
|
+
buttonContent: _propTypes.default.string,
|
|
178
|
+
selectedFileName: _propTypes.default.string,
|
|
179
|
+
dateFormat: _propTypes.default.string,
|
|
180
|
+
placeholder: _propTypes.default.string,
|
|
181
|
+
defaultContent: _propTypes.default.string,
|
|
182
|
+
hasErrors: _propTypes.default.bool,
|
|
183
|
+
errorMessage: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]))]),
|
|
184
|
+
mandatory: _propTypes.default.bool,
|
|
185
|
+
theme: _propTypes.default.object
|
|
186
|
+
};
|
|
187
|
+
InputField.defaultProps = {
|
|
188
|
+
name: '',
|
|
189
|
+
type: 'text',
|
|
190
|
+
label: '',
|
|
191
|
+
contentOnly: false,
|
|
192
|
+
buttonColor: 'default',
|
|
193
|
+
dateFormat: 'd. MMMM, yyyy',
|
|
194
|
+
placeholder: '',
|
|
195
|
+
defaultContent: '',
|
|
196
|
+
hasErrors: false,
|
|
197
|
+
errorMessage: '',
|
|
198
|
+
mandatory: false
|
|
199
|
+
};
|
|
200
|
+
var _default = InputField;
|
|
201
|
+
exports.default = _default;
|