dibk-design 0.4.32 → 0.4.33
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/dist/components/InputField.js +51 -52
- package/package.json +1 -1
|
@@ -100,64 +100,61 @@ var InputField = /*#__PURE__*/function (_React$Component) {
|
|
|
100
100
|
return this.props.type === 'date' ? value ? this.convertDateToString(value) : defaultContent : value ? value : defaultContent;
|
|
101
101
|
}
|
|
102
102
|
}, {
|
|
103
|
-
key: "
|
|
104
|
-
value: function
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
key: "getInputElementProps",
|
|
104
|
+
value: function getInputElementProps(defaultValue, styleRules) {
|
|
105
|
+
var _ref;
|
|
106
|
+
|
|
107
|
+
return _ref = {
|
|
108
|
+
name: this.props.name,
|
|
109
|
+
readOnly: this.props.readOnly,
|
|
110
|
+
disabled: this.props.disabled,
|
|
111
|
+
type: this.props.type,
|
|
112
|
+
id: this.props.id,
|
|
113
|
+
onChange: this.props.onChange,
|
|
114
|
+
onBlur: this.props.onBlur
|
|
115
|
+
}, _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;
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "getDatePickerElementProps",
|
|
119
|
+
value: function getDatePickerElementProps(defaultValue) {
|
|
120
|
+
var _this = this;
|
|
111
121
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
};
|
|
136
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
137
|
-
style: styleRules
|
|
138
|
-
}, /*#__PURE__*/_react.default.createElement(_reactDatepicker.default, props));
|
|
139
|
-
} else {
|
|
140
|
-
var _props2;
|
|
141
|
-
|
|
142
|
-
var _props = (_props2 = {
|
|
143
|
-
name: this.props.name,
|
|
144
|
-
readOnly: this.props.readOnly,
|
|
145
|
-
disabled: this.props.disabled,
|
|
146
|
-
type: this.props.type,
|
|
147
|
-
id: this.props.id,
|
|
148
|
-
onChange: this.props.onChange,
|
|
149
|
-
onBlur: this.props.onBlur
|
|
150
|
-
}, _defineProperty(_props2, defaultValue ? 'defaultValue' : 'value', defaultValue || this.props.value), _defineProperty(_props2, "placeholder", this.props.placeholder), _defineProperty(_props2, "className", this.props.hasErrors ? _InputFieldModule.default.hasErrors : ''), _defineProperty(_props2, 'aria-required', this.props.mandatory), _defineProperty(_props2, "style", styleRules), _props2);
|
|
151
|
-
|
|
152
|
-
return /*#__PURE__*/_react.default.createElement("input", _props);
|
|
153
|
-
}
|
|
122
|
+
return {
|
|
123
|
+
name: this.props.name,
|
|
124
|
+
readOnly: this.props.readOnly,
|
|
125
|
+
disabled: this.props.disabled,
|
|
126
|
+
id: this.props.id,
|
|
127
|
+
dateFormat: this.props.dateFormat,
|
|
128
|
+
locale: 'nb',
|
|
129
|
+
selectsStart: this.props.selectsStart,
|
|
130
|
+
selectsEnd: this.props.selectsEnd,
|
|
131
|
+
startDate: this.props.startDate ? new Date(this.props.startDate) : null,
|
|
132
|
+
endDate: this.props.endDate ? new Date(this.props.endDate) : null,
|
|
133
|
+
minDate: this.props.minDate || null,
|
|
134
|
+
maxDate: this.props.maxDate || null,
|
|
135
|
+
onChange: this.props.onChange ? function (date) {
|
|
136
|
+
return _this.props.onChange(date);
|
|
137
|
+
} : console.log("Missing onChange handler for date picker with id: ".concat(this.props.id)),
|
|
138
|
+
onBlur: this.props.onBlur ? function (date) {
|
|
139
|
+
return _this.props.onBlur(date);
|
|
140
|
+
} : null,
|
|
141
|
+
selected: defaultValue ? new Date(defaultValue) : null,
|
|
142
|
+
placeholderText: this.props.placeholder,
|
|
143
|
+
className: this.props.hasErrors ? _InputFieldModule.default.hasErrors : ''
|
|
144
|
+
};
|
|
154
145
|
}
|
|
155
146
|
}, {
|
|
156
147
|
key: "render",
|
|
157
148
|
value: function render() {
|
|
158
|
-
var
|
|
149
|
+
var _this$props$width,
|
|
150
|
+
_this2 = this;
|
|
159
151
|
|
|
160
152
|
var defaultValue = this.props.defaultValue ? this.props.defaultValue : this.props.value || null;
|
|
153
|
+
|
|
154
|
+
var styleRules = _objectSpread(_objectSpread({}, this.props.hasErrors ? this.getThemeErrorInputStyle(this.props.theme) : null), ((_this$props$width = this.props.width) === null || _this$props$width === void 0 ? void 0 : _this$props$width.length) && {
|
|
155
|
+
maxWidth: this.props.width
|
|
156
|
+
});
|
|
157
|
+
|
|
161
158
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
162
159
|
className: "".concat(_InputFieldModule.default.inputField, " ").concat(_InputFieldModule.default[this.props.type])
|
|
163
160
|
}, /*#__PURE__*/_react.default.createElement(_Label.default, {
|
|
@@ -173,7 +170,9 @@ var InputField = /*#__PURE__*/function (_React$Component) {
|
|
|
173
170
|
},
|
|
174
171
|
content: this.props.buttonContent,
|
|
175
172
|
theme: this.props.theme
|
|
176
|
-
}) : '') : ''), !this.props.contentOnly ? this.
|
|
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))) : /*#__PURE__*/_react.default.createElement("input", this.getInputElementProps(defaultValue, styleRules)) : /*#__PURE__*/_react.default.createElement("span", null, this.renderValueAsText(this.props.value || this.props.defaultValue, this.props.defaultContent)), /*#__PURE__*/_react.default.createElement("span", {
|
|
177
176
|
className: _InputFieldModule.default.errorMessage,
|
|
178
177
|
style: this.getThemeErrorMessageStyle(this.props.theme)
|
|
179
178
|
}, this.props.errorMessage ? this.props.errorMessage : ''));
|