dibk-design 0.4.53 → 1.0.1

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.
@@ -94,10 +94,10 @@ var Button = /*#__PURE__*/function (_React$Component) {
94
94
  return (_this$props$href = this.props.href) !== null && _this$props$href !== void 0 && _this$props$href.length ? /*#__PURE__*/_react.default.createElement("a", _extends({}, buttonProps, {
95
95
  className: className,
96
96
  style: themeStyle
97
- }), this.props.content) : /*#__PURE__*/_react.default.createElement("button", _extends({}, buttonProps, {
97
+ }), this.props.content || this.props.children) : /*#__PURE__*/_react.default.createElement("button", _extends({}, buttonProps, {
98
98
  className: className,
99
99
  style: themeStyle
100
- }), this.props.content);
100
+ }), this.props.content || this.props.children);
101
101
  }
102
102
  }]);
103
103
 
@@ -117,7 +117,6 @@ Button.propTypes = {
117
117
  href: _propTypes.default.string
118
118
  };
119
119
  Button.defaultProps = {
120
- content: 'button',
121
120
  color: 'default',
122
121
  size: 'regular',
123
122
  disabled: false,
@@ -6,6 +6,7 @@ Regular buttons example:
6
6
  <Button content="Click me" color="default" disabled />
7
7
  <Button content="Click me" color="primary" disabled />
8
8
  <Button content="Link button" color="primary" href="#" />
9
+ <Button color="default"><span>Button with <b>HTML</b> content</span></Button>
9
10
  ```
10
11
 
11
12
  Rounded buttons example:
@@ -15,6 +16,7 @@ Rounded buttons example:
15
16
  <Button rounded content="Click me" color="primary" />
16
17
  <Button rounded content="Click me" color="default" disabled />
17
18
  <Button rounded content="Click me" color="primary" disabled />
19
+ <Button rounded color="default"><span>Button with <b>HTML</b> content</span></Button>
18
20
  ```
19
21
 
20
22
  Regular buttons with arrow example:
@@ -71,13 +71,10 @@ var CheckBoxIcon = /*#__PURE__*/function (_React$Component) {
71
71
  });
72
72
  }
73
73
 
74
- var ariaExpandedIndex = "aria-expanded";
75
-
76
- var props = _defineProperty({
74
+ var props = {
77
75
  className: "".concat(_CheckBoxIconModule.default.checkBoxIcon, " ").concat(this.props.checked ? _CheckBoxIconModule.default.checked : '', " ").concat(this.props.disabled ? _CheckBoxIconModule.default.disabled : '', " ").concat(this.props.showBox ? _CheckBoxIconModule.default.showBox : '', " ").concat(this.props.hasErrors ? _CheckBoxIconModule.default.hasErrors : ''),
78
76
  style: inlineStyle
79
- }, ariaExpandedIndex, this.props.expandable ? this.props.checked.toString() : null);
80
-
77
+ };
81
78
  return /*#__PURE__*/_react.default.createElement("span", props, /*#__PURE__*/_react.default.createElement("span", {
82
79
  className: _CheckBoxIconModule.default.checkmark
83
80
  }, this.props.checked ? this.props.checkmarkCharacter : ''));
@@ -94,8 +91,7 @@ CheckBoxIcon.propTypes = {
94
91
  showBox: _propTypes.default.bool,
95
92
  theme: _propTypes.default.object,
96
93
  hasErrors: _propTypes.default.bool,
97
- checkmarkCharacter: _propTypes.default.string,
98
- expandable: _propTypes.default.bool
94
+ checkmarkCharacter: _propTypes.default.string
99
95
  };
100
96
  CheckBoxIcon.defaultProps = {
101
97
  size: '20px',
@@ -103,8 +99,7 @@ CheckBoxIcon.defaultProps = {
103
99
  disabled: false,
104
100
  showBox: true,
105
101
  hasErrors: false,
106
- checkmarkCharacter: '✔',
107
- expandable: false
102
+ checkmarkCharacter: '✔'
108
103
  };
109
104
  var _default = CheckBoxIcon;
110
105
  exports.default = _default;
@@ -51,29 +51,29 @@ var CheckBoxInput = /*#__PURE__*/function (_React$Component) {
51
51
  _createClass(CheckBoxInput, [{
52
52
  key: "render",
53
53
  value: function render() {
54
- return /*#__PURE__*/_react.default.createElement("label", {
55
- className: "".concat(_CheckBoxInputModule.default.checkBoxInput, " ").concat(this.props.contentOnly ? _CheckBoxInputModule.default.contentOnly : '', " ").concat(this.props.disabled ? _CheckBoxInputModule.default.disabled : '', " ").concat(this.props.hasErrors ? _CheckBoxInputModule.default.hasErrors : ''),
54
+ var labelProps = {
55
+ className: "".concat(_CheckBoxInputModule.default.checkBoxInput, " ").concat(this.props.contentOnly ? _CheckBoxInputModule.default.contentOnly : "", " ").concat(this.props.disabled ? _CheckBoxInputModule.default.disabled : "", " ").concat(this.props.hasErrors ? _CheckBoxInputModule.default.hasErrors : ""),
56
56
  htmlFor: this.props.id
57
- }, !this.props.contentOnly ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CheckBoxIcon.default, {
57
+ };
58
+ var iconProps = {
58
59
  checked: this.props.checked,
59
60
  disabled: this.props.disabled,
60
61
  theme: this.props.theme,
61
- hasErrors: this.props.hasErrors,
62
- checkmarkCharacter: this.props.checkmarkCharacter,
63
- expandable: this.props.expandable
64
- }), /*#__PURE__*/_react.default.createElement("input", {
65
- onChange: this.props.onChange,
66
- type: "checkbox",
67
- name: this.props.name,
62
+ showBox: !this.props.contentOnly,
63
+ hasErrors: this.props.contentOnly && this.props.hasErrors,
64
+ checkmarkCharacter: this.props.checkmarkCharacter
65
+ };
66
+ var inputProps = {
68
67
  id: this.props.id,
69
- checked: this.props.checked,
70
- disabled: this.props.disabled
71
- })) : /*#__PURE__*/_react.default.createElement(_CheckBoxIcon.default, {
68
+ name: this.props.name || null,
69
+ type: "checkbox",
72
70
  checked: this.props.checked,
73
71
  disabled: this.props.disabled,
74
- showBox: false,
75
- theme: this.props.theme
76
- }), /*#__PURE__*/_react.default.createElement("span", null, this.props.children));
72
+ onChange: this.props.onChange,
73
+ "aria-expanded": this.props["aria-expanded"],
74
+ "aria-controls": this.props["aria-controls"]
75
+ };
76
+ return /*#__PURE__*/_react.default.createElement("label", labelProps, !this.props.contentOnly ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CheckBoxIcon.default, iconProps), /*#__PURE__*/_react.default.createElement("input", inputProps)) : /*#__PURE__*/_react.default.createElement(_CheckBoxIcon.default, iconProps), /*#__PURE__*/_react.default.createElement("span", null, this.props.children));
77
77
  }
78
78
  }]);
79
79
 
@@ -90,15 +90,16 @@ CheckBoxInput.propTypes = {
90
90
  hasErrors: _propTypes.default.bool,
91
91
  theme: _propTypes.default.object,
92
92
  checkmarkCharacter: _propTypes.default.string,
93
- expandable: _propTypes.default.bool
93
+ "aria-expanded": _propTypes.default.string,
94
+ "aria-controls": _propTypes.default.string
94
95
  };
95
96
  CheckBoxInput.defaultProps = {
96
97
  checked: false,
97
98
  disabled: false,
98
- name: '',
99
+ name: "",
99
100
  contentOnly: false,
100
101
  hasErrors: false,
101
- checkmarkCharacter: '',
102
+ checkmarkCharacter: "",
102
103
  expandable: false
103
104
  };
104
105
  var _default = CheckBoxInput;
@@ -11,12 +11,6 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
- var _reactDatepicker = _interopRequireWildcard(require("react-datepicker"));
15
-
16
- var _dateFns = require("date-fns");
17
-
18
- var _nb = _interopRequireDefault(require("date-fns/locale/nb"));
19
-
20
14
  var _Button = _interopRequireDefault(require("./Button"));
21
15
 
22
16
  var _Label = _interopRequireDefault(require("./Label"));
@@ -27,22 +21,14 @@ var _theme = require("../functions/theme");
27
21
 
28
22
  var _generators = require("../functions/generators");
29
23
 
30
- require("react-datepicker/dist/react-datepicker.css");
31
-
32
24
  var _InputFieldModule = _interopRequireDefault(require("./InputField.module.scss"));
33
25
 
34
- 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); }
35
-
36
- 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; }
37
-
38
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
27
 
40
28
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
29
 
42
30
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
43
31
 
44
- 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; }
45
-
46
32
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
47
33
 
48
34
  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); } }
@@ -63,7 +49,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
63
49
 
64
50
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
65
51
 
66
- (0, _reactDatepicker.registerLocale)('nb', _nb.default);
52
+ 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; }
67
53
 
68
54
  var InputField = /*#__PURE__*/function (_React$Component) {
69
55
  _inherits(InputField, _React$Component);
@@ -71,30 +57,43 @@ var InputField = /*#__PURE__*/function (_React$Component) {
71
57
  var _super = _createSuper(InputField);
72
58
 
73
59
  function InputField() {
60
+ var _this;
61
+
74
62
  _classCallCheck(this, InputField);
75
63
 
76
- return _super.apply(this, arguments);
64
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
65
+ args[_key] = arguments[_key];
66
+ }
67
+
68
+ _this = _super.call.apply(_super, [this].concat(args));
69
+
70
+ _defineProperty(_assertThisInitialized(_this), "formatDate", function (inputDate) {
71
+ if (!inputDate) {
72
+ return null;
73
+ }
74
+
75
+ var date = new Date(inputDate);
76
+ var year = date.getFullYear();
77
+ var month = date.getMonth() + 1 < 10 ? "0".concat(date.getMonth() + 1) : date.getMonth() + 1;
78
+ var day = date.getDate() < 10 ? "0".concat(date.getDate()) : date.getDate();
79
+ return "".concat(day, ".").concat(month, ".").concat(year);
80
+ });
81
+
82
+ return _this;
77
83
  }
78
84
 
79
85
  _createClass(InputField, [{
80
86
  key: "getThemeErrorInputStyle",
81
87
  value: function getThemeErrorInputStyle(theme) {
82
88
  return {
83
- boxShadow: "0 0 3px ".concat((0, _theme.getThemePaletteBackgroundColor)(theme, 'warning')),
84
- borderColor: (0, _theme.getThemePaletteBackgroundColor)(theme, 'warning')
89
+ boxShadow: "0 0 3px ".concat((0, _theme.getThemePaletteBackgroundColor)(theme, "warning")),
90
+ borderColor: (0, _theme.getThemePaletteBackgroundColor)(theme, "warning")
85
91
  };
86
92
  }
87
- }, {
88
- key: "convertDateToString",
89
- value: function convertDateToString(date) {
90
- return date ? (0, _dateFns.format)(new Date(date), this.props.dateFormat, {
91
- locale: _nb.default
92
- }) : '';
93
- }
94
93
  }, {
95
94
  key: "renderValueAsText",
96
95
  value: function renderValueAsText(value, defaultContent) {
97
- return this.props.type === 'date' ? value ? this.convertDateToString(value) : defaultContent : value ? value : defaultContent;
96
+ return this.props.type === "date" ? value ? this.formatDate(value) : defaultContent : value ? value : defaultContent;
98
97
  }
99
98
  }, {
100
99
  key: "getInputElementProps",
@@ -108,39 +107,11 @@ var InputField = /*#__PURE__*/function (_React$Component) {
108
107
  type: this.props.type,
109
108
  id: this.props.id,
110
109
  key: defaultKey || "".concat(this.props.id, "-").concat((0, _generators.generateRandomString)(6)),
110
+ min: this.props.min || null,
111
+ max: this.props.max || null,
111
112
  onChange: this.props.onChange,
112
113
  onBlur: this.props.onBlur
113
- }, _defineProperty(_ref, defaultValue ? 'defaultValue' : 'value', defaultValue || this.props.value), _defineProperty(_ref, "placeholder", this.props.placeholder), _defineProperty(_ref, "className", this.props.hasErrors ? _InputFieldModule.default.hasErrors : ''), _defineProperty(_ref, 'aria-required', this.props.mandatory), _defineProperty(_ref, "style", styleRules), _ref;
114
- }
115
- }, {
116
- key: "getDatePickerElementProps",
117
- value: function getDatePickerElementProps(defaultValue, defaultKey) {
118
- var _this = this;
119
-
120
- return {
121
- name: this.props.name,
122
- readOnly: this.props.readOnly,
123
- disabled: this.props.disabled,
124
- id: this.props.id,
125
- key: defaultKey || "".concat(this.props.id, "-").concat((0, _generators.generateRandomString)(6)),
126
- dateFormat: this.props.dateFormat,
127
- locale: 'nb',
128
- selectsStart: this.props.selectsStart,
129
- selectsEnd: this.props.selectsEnd,
130
- startDate: this.props.startDate ? new Date(this.props.startDate) : null,
131
- endDate: this.props.endDate ? new Date(this.props.endDate) : null,
132
- minDate: this.props.minDate || null,
133
- maxDate: this.props.maxDate || null,
134
- onChange: this.props.onChange ? function (date) {
135
- return _this.props.onChange(date);
136
- } : console.log("Missing onChange handler for date picker with id: ".concat(this.props.id)),
137
- onBlur: this.props.onBlur ? function (date) {
138
- return _this.props.onBlur(date);
139
- } : null,
140
- selected: defaultValue ? new Date(defaultValue) : null,
141
- placeholderText: this.props.placeholder,
142
- className: this.props.hasErrors ? _InputFieldModule.default.hasErrors : ''
143
- };
114
+ }, _defineProperty(_ref, defaultValue ? "defaultValue" : "value", defaultValue || this.props.value), _defineProperty(_ref, "placeholder", this.props.placeholder || null), _defineProperty(_ref, "className", this.props.hasErrors ? _InputFieldModule.default.hasErrors : ""), _defineProperty(_ref, "aria-required", this.props.mandatory), _defineProperty(_ref, "style", styleRules), _ref;
144
115
  }
145
116
  }, {
146
117
  key: "render",
@@ -159,7 +130,7 @@ var InputField = /*#__PURE__*/function (_React$Component) {
159
130
  className: "".concat(_InputFieldModule.default.inputField, " ").concat(_InputFieldModule.default[this.props.type])
160
131
  }, /*#__PURE__*/_react.default.createElement(_Label.default, {
161
132
  htmlFor: this.props.id
162
- }, this.props.label, this.props.type === 'file' ? /*#__PURE__*/_react.default.createElement("div", {
133
+ }, this.props.label, this.props.type === "file" ? /*#__PURE__*/_react.default.createElement("div", {
163
134
  className: _InputFieldModule.default.fileInputContainer
164
135
  }, /*#__PURE__*/_react.default.createElement("span", {
165
136
  className: _InputFieldModule.default.input
@@ -170,9 +141,7 @@ var InputField = /*#__PURE__*/function (_React$Component) {
170
141
  },
171
142
  content: this.props.buttonContent,
172
143
  theme: this.props.theme
173
- }) : '') : ''), !this.props.contentOnly ? this.props.type === 'date' ? /*#__PURE__*/_react.default.createElement("div", {
174
- style: styleRules
175
- }, /*#__PURE__*/_react.default.createElement(_reactDatepicker.default, this.getDatePickerElementProps(defaultValue, defaultKey))) : /*#__PURE__*/_react.default.createElement("input", this.getInputElementProps(defaultValue, defaultKey, styleRules)) : /*#__PURE__*/_react.default.createElement("span", null, this.renderValueAsText(this.props.value || this.props.defaultValue, this.props.defaultContent)), /*#__PURE__*/_react.default.createElement(_ErrorMessage.default, {
144
+ }) : null) : null), !this.props.contentOnly ? /*#__PURE__*/_react.default.createElement("input", this.getInputElementProps(defaultValue, defaultKey, styleRules)) : /*#__PURE__*/_react.default.createElement("span", null, this.renderValueAsText(this.props.value || this.props.defaultValue, this.props.defaultContent)), /*#__PURE__*/_react.default.createElement(_ErrorMessage.default, {
176
145
  content: this.props.errorMessage,
177
146
  theme: this.props.theme
178
147
  }));
@@ -198,7 +167,6 @@ InputField.propTypes = {
198
167
  buttonColor: _propTypes.default.string,
199
168
  buttonContent: _propTypes.default.string,
200
169
  selectedFileName: _propTypes.default.string,
201
- dateFormat: _propTypes.default.string,
202
170
  placeholder: _propTypes.default.string,
203
171
  defaultContent: _propTypes.default.string,
204
172
  hasErrors: _propTypes.default.bool,
@@ -207,16 +175,16 @@ InputField.propTypes = {
207
175
  theme: _propTypes.default.object
208
176
  };
209
177
  InputField.defaultProps = {
210
- name: '',
211
- type: 'text',
212
- label: '',
178
+ name: "",
179
+ type: "text",
180
+ label: "",
213
181
  contentOnly: false,
214
- buttonColor: 'default',
215
- dateFormat: 'd. MMMM, yyyy',
216
- placeholder: '',
217
- defaultContent: '',
182
+ buttonColor: "default",
183
+ dateFormat: "d. MMMM, yyyy",
184
+ placeholder: "",
185
+ defaultContent: "",
218
186
  hasErrors: false,
219
- errorMessage: '',
187
+ errorMessage: "",
220
188
  mandatory: false,
221
189
  onChange: function onChange() {
222
190
  return false;
@@ -15,13 +15,12 @@ Input field example:
15
15
  <InputField id="textInput10" onChange={() => {console.log('onChange')}} label="InputField without value, contentOnly set to true and defaultContent" contentOnly={true} defaultContent="Please insert a value" />
16
16
  <InputField id="fileInput1" onChange={()=>{console.log('onchange')}} type="file" label="InputField with label, value and type set to file" />
17
17
  <InputField id="fileInput1" onChange={()=>{console.log('onchange')}} type="file" label="InputField with label, value, fileName, buttonContent and type set to file" selectedFileName="file.txt" buttonContent="Legg til fil" />
18
- <InputField id="dateInput1" onChange={(date) => console.log("date", date)} type="date" label="Datepicker without value" value="" />
19
- <InputField id="dateInput2" onChange={(date) => console.log("date", date)} type="date" label="Datepicker with value" value="2020-05-10T13:12:04" />
20
- <InputField id="dateInput3" onChange={(date) => console.log("date", date)} type="date" label="Datepicker with value, errors and error message" value="2020-05-10T13:12:04" hasErrors={true} errorMessage="Wrong date value" />
21
- <InputField id="dateInput4" onChange={(date) => console.log("date", date)} type="date" label="Datepicker with value and contentOnly set to true" value="2020-05-10T13:12:04" contentOnly={true} />
22
- <InputField id="dateInput5" onChange={(date) => console.log("date", date)} type="date" label="Datepicker with value for start date" value="2020-05-10T13:12:04" selectsStart startDate="2020-05-10T13:12:04" endDate="2020-05-19T13:12:04" />
23
- <InputField id="dateInput6" onChange={(date) => console.log("date", date)} type="date" label="Datepicker with value for end date" value="2020-05-19T13:12:04" selectsEnd startDate="2020-05-10T13:12:04" endDate="2020-05-19T13:12:04" />
24
- <InputField id="dateInput7" onChange={(date) => console.log("date", date)} type="date" label="Datepicker with defaultContent and contentOnly set to true" contentOnly={true} defaultContent="Please insert a value" />
18
+ <InputField id="dateInput1" onChange={(date) => console.log("date", date)} type="date" label="Date input without value" value="" />
19
+ <InputField id="dateInput2" onChange={(date) => console.log("date", date)} type="date" label="Date input with value" value="2020-05-10" />
20
+ <InputField id="dateInput3" onChange={(date) => console.log("date", date)} type="date" label="Date input with value, errors and error message" value="2020-05-10" hasErrors={true} errorMessage="Wrong date value" />
21
+ <InputField id="dateInput4" onChange={(date) => console.log("date", date)} type="date" label="Date input with value and contentOnly set to true" value="2020-05-10" contentOnly={true} />
22
+ <InputField id="dateInput5" onChange={(date) => console.log("date", date)} type="date" label="Date input with min and max date" value="2020-05-10" selectsStart min="2020-05-04" max="2020-05-19" />
23
+ <InputField id="dateInput6" onChange={(date) => console.log("date", date)} type="date" label="Date input with defaultContent and contentOnly set to true" contentOnly={true} defaultContent="Please insert a value" />
25
24
  <InputField id="textInput9" value="InputField with value and custom width" width="400px" />
26
25
  <InputField id="textInput10" value="InputField with a not auto generated key" elementKey="inputKeyHere" />
27
26
  ```
@@ -34,7 +33,7 @@ import customTheme from 'data/customTheme';
34
33
  <InputField id="themedTextInput4" onChange={()=>{console.log('onchange')}} value="InputField with link in label" label={['InputField with ', <a key="labelLink" href="#">link</a>, ' in label']} theme={customTheme} />
35
34
  <InputField id="themedTextInput5" onChange={()=>{console.log('onchange')}} value="InputField with label, value, errors and error message" label="InputField with label, value, errors and error message" hasErrors={true} errorMessage="Wrong value" theme={customTheme} />
36
35
  <InputField id="themedFileInput1" onChange={()=>{console.log('onchange')}} type="file" label="InputField with label, value, fileName, buttonContent and type set to file" selectedFileName="file.txt" buttonContent="Legg til fil" theme={customTheme} />
37
- <InputField id="themedDateInput3" onChange={(date) => console.log("date", date)} type="date" label="Datepicker with value, errors and error message" value="2020-05-10T13:12:04" hasErrors={true} errorMessage="Wrong date value" theme={customTheme} />
36
+ <InputField id="themedDateInput3" onChange={(date) => console.log("date", date)} type="date" label="Date input with value, errors and error message" value="2020-05-10" hasErrors={true} errorMessage="Wrong date value" theme={customTheme} />
38
37
  <InputField id="themedDateInput4" value="InputField with value, error and custom width" width="420px" hasErrors={true} theme={customTheme} errorMessage="Wrong value" />
39
38
 
40
39
  </React.Fragment>
@@ -69,13 +69,10 @@ var RadioButtonIcon = /*#__PURE__*/function (_React$Component) {
69
69
  });
70
70
  }
71
71
 
72
- var ariaExpandedIndex = "aria-expanded";
73
-
74
- var props = _defineProperty({
72
+ var props = {
75
73
  className: "".concat(_RadioButtonIconModule.default.radioButtonIcon, " ").concat(this.props.checked ? _RadioButtonIconModule.default.checked : '', " ").concat(this.props.disabled ? _RadioButtonIconModule.default.disabled : '', " ").concat(this.props.hasErrors ? _RadioButtonIconModule.default.hasErrors : ''),
76
74
  style: inlineStyle
77
- }, ariaExpandedIndex, this.props.expandable ? this.props.checked.toString() : null);
78
-
75
+ };
79
76
  return /*#__PURE__*/_react.default.createElement("span", props);
80
77
  }
81
78
  }]);
@@ -88,15 +85,13 @@ RadioButtonIcon.propTypes = {
88
85
  checked: _propTypes.default.bool,
89
86
  disabled: _propTypes.default.bool,
90
87
  theme: _propTypes.default.object,
91
- hasErrors: _propTypes.default.bool,
92
- expandable: _propTypes.default.bool
88
+ hasErrors: _propTypes.default.bool
93
89
  };
94
90
  RadioButtonIcon.defaultProps = {
95
91
  size: '10px',
96
92
  checked: false,
97
93
  disabled: false,
98
- hasErrors: false,
99
- expandable: false
94
+ hasErrors: false
100
95
  };
101
96
  var _default = RadioButtonIcon;
102
97
  exports.default = _default;
@@ -51,23 +51,28 @@ var RadioButtonInput = /*#__PURE__*/function (_React$Component) {
51
51
  _createClass(RadioButtonInput, [{
52
52
  key: "render",
53
53
  value: function render() {
54
- return /*#__PURE__*/_react.default.createElement("label", {
55
- htmlFor: this.props.id,
56
- className: "".concat(_RadioButtonInputModule.default.radioButtonInput, " ").concat(this.props.checked ? _RadioButtonInputModule.default.checked : '', " ").concat(this.props.disabled ? _RadioButtonInputModule.default.disabled : '', " ").concat(this.props.hasErrors ? _RadioButtonInputModule.default.hasErrors : '')
57
- }, !this.props.contentOnly ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_RadioButtonIcon.default, {
54
+ var labelProps = {
55
+ className: "".concat(_RadioButtonInputModule.default.radioButtonInput, " ").concat(this.props.checked ? _RadioButtonInputModule.default.checked : "", " ").concat(this.props.disabled ? _RadioButtonInputModule.default.disabled : "", " ").concat(this.props.hasErrors ? _RadioButtonInputModule.default.hasErrors : ""),
56
+ htmlFor: this.props.id
57
+ };
58
+ var iconProps = {
58
59
  checked: this.props.checked,
59
60
  disabled: this.props.disabled,
60
61
  theme: this.props.theme,
61
- hasErrors: this.props.hasErrors,
62
- expandable: this.props.expandable
63
- }), /*#__PURE__*/_react.default.createElement("input", {
64
- type: "radio",
65
- onChange: this.props.onChange,
62
+ hasErrors: this.props.contentOnly && this.props.hasErrors
63
+ };
64
+ var inputProps = {
66
65
  id: this.props.id,
67
- name: this.props.name,
66
+ name: this.props.name || null,
67
+ type: "radio",
68
68
  value: this.props.inputValue,
69
- checked: this.props.checked
70
- })) : '', /*#__PURE__*/_react.default.createElement("span", null, this.props.children));
69
+ checked: this.props.checked,
70
+ disabled: this.props.disabled,
71
+ onChange: this.props.onChange,
72
+ "aria-expanded": this.props["aria-expanded"],
73
+ "aria-controls": this.props["aria-controls"]
74
+ };
75
+ return /*#__PURE__*/_react.default.createElement("label", labelProps, !this.props.contentOnly ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_RadioButtonIcon.default, iconProps), /*#__PURE__*/_react.default.createElement("input", inputProps)) : null, /*#__PURE__*/_react.default.createElement("span", null, this.props.children));
71
76
  }
72
77
  }]);
73
78
 
@@ -77,22 +82,22 @@ var RadioButtonInput = /*#__PURE__*/function (_React$Component) {
77
82
  RadioButtonInput.propTypes = {
78
83
  checked: _propTypes.default.bool,
79
84
  disabled: _propTypes.default.bool,
80
- inputValue: _propTypes.default.string.isRequired,
81
- name: _propTypes.default.string,
82
85
  id: _propTypes.default.string.isRequired,
86
+ name: _propTypes.default.string,
83
87
  onChange: _propTypes.default.func,
84
88
  contentOnly: _propTypes.default.bool,
85
- theme: _propTypes.default.object,
86
89
  hasErrors: _propTypes.default.bool,
87
- expandable: _propTypes.default.bool
90
+ theme: _propTypes.default.object,
91
+ inputValue: _propTypes.default.string.isRequired,
92
+ "aria-expanded": _propTypes.default.string,
93
+ "aria-controls": _propTypes.default.string
88
94
  };
89
95
  RadioButtonInput.defaultProps = {
90
- name: '',
96
+ name: "",
91
97
  checked: false,
92
98
  disabled: false,
93
99
  contentOnly: false,
94
- hasErrors: false,
95
- expandable: false
100
+ hasErrors: false
96
101
  };
97
102
  var _default = RadioButtonInput;
98
103
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dibk-design",
3
- "version": "0.4.53",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -11,7 +11,6 @@
11
11
  "dependencies": {
12
12
  "prop-types": "^15.6.2",
13
13
  "react": "^17.0.1",
14
- "react-datepicker": "^4.1.1",
15
14
  "react-dom": "^17.0.1",
16
15
  "react-router-dom": "^6.2.2",
17
16
  "react-scripts": "^4.0.0"