dibk-design 0.4.37 → 0.4.38
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.
|
@@ -103,7 +103,7 @@ var InputField = /*#__PURE__*/function (_React$Component) {
|
|
|
103
103
|
}
|
|
104
104
|
}, {
|
|
105
105
|
key: "getInputElementProps",
|
|
106
|
-
value: function getInputElementProps(defaultValue, styleRules) {
|
|
106
|
+
value: function getInputElementProps(defaultValue, defaultKey, styleRules) {
|
|
107
107
|
var _ref;
|
|
108
108
|
|
|
109
109
|
return _ref = {
|
|
@@ -112,14 +112,14 @@ var InputField = /*#__PURE__*/function (_React$Component) {
|
|
|
112
112
|
disabled: this.props.disabled,
|
|
113
113
|
type: this.props.type,
|
|
114
114
|
id: this.props.id,
|
|
115
|
-
key: "".concat(this.props.id, "-").concat((0, _generators.generateRandomString)(6)),
|
|
115
|
+
key: defaultKey || "".concat(this.props.id, "-").concat((0, _generators.generateRandomString)(6)),
|
|
116
116
|
onChange: this.props.onChange,
|
|
117
117
|
onBlur: this.props.onBlur
|
|
118
118
|
}, _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;
|
|
119
119
|
}
|
|
120
120
|
}, {
|
|
121
121
|
key: "getDatePickerElementProps",
|
|
122
|
-
value: function getDatePickerElementProps(defaultValue) {
|
|
122
|
+
value: function getDatePickerElementProps(defaultValue, defaultKey) {
|
|
123
123
|
var _this = this;
|
|
124
124
|
|
|
125
125
|
return {
|
|
@@ -127,7 +127,7 @@ var InputField = /*#__PURE__*/function (_React$Component) {
|
|
|
127
127
|
readOnly: this.props.readOnly,
|
|
128
128
|
disabled: this.props.disabled,
|
|
129
129
|
id: this.props.id,
|
|
130
|
-
key: "".concat(this.props.id, "-").concat((0, _generators.generateRandomString)(6)),
|
|
130
|
+
key: defaultKey || "".concat(this.props.id, "-").concat((0, _generators.generateRandomString)(6)),
|
|
131
131
|
dateFormat: this.props.dateFormat,
|
|
132
132
|
locale: 'nb',
|
|
133
133
|
selectsStart: this.props.selectsStart,
|
|
@@ -154,6 +154,7 @@ var InputField = /*#__PURE__*/function (_React$Component) {
|
|
|
154
154
|
_this2 = this;
|
|
155
155
|
|
|
156
156
|
var defaultValue = this.props.defaultValue ? this.props.defaultValue : this.props.value || null;
|
|
157
|
+
var defaultKey = this.props.elementKey || null;
|
|
157
158
|
|
|
158
159
|
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) && {
|
|
159
160
|
maxWidth: this.props.width
|
|
@@ -176,7 +177,7 @@ var InputField = /*#__PURE__*/function (_React$Component) {
|
|
|
176
177
|
theme: this.props.theme
|
|
177
178
|
}) : '') : ''), !this.props.contentOnly ? this.props.type === 'date' ? /*#__PURE__*/_react.default.createElement("div", {
|
|
178
179
|
style: styleRules
|
|
179
|
-
}, /*#__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", {
|
|
180
|
+
}, /*#__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("span", {
|
|
180
181
|
className: _InputFieldModule.default.errorMessage,
|
|
181
182
|
style: this.getThemeErrorMessageStyle(this.props.theme)
|
|
182
183
|
}, this.props.errorMessage ? this.props.errorMessage : ''));
|
|
@@ -196,6 +197,7 @@ InputField.propTypes = {
|
|
|
196
197
|
width: _propTypes.default.string,
|
|
197
198
|
value: _propTypes.default.any,
|
|
198
199
|
defaultValue: _propTypes.default.any,
|
|
200
|
+
elementKey: _propTypes.default.string,
|
|
199
201
|
label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]))]),
|
|
200
202
|
contentOnly: _propTypes.default.bool,
|
|
201
203
|
buttonColor: _propTypes.default.string,
|
|
@@ -23,6 +23,7 @@ Input field example:
|
|
|
23
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
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" />
|
|
25
25
|
<InputField id="textInput9" value="InputField with value and custom width" width="400px" />
|
|
26
|
+
<InputField id="textInput10" value="InputField with a not auto generated key" elementKey="inputKeyHere" />
|
|
26
27
|
```
|
|
27
28
|
|
|
28
29
|
Themed Input field example:
|