tenjin-ui-kit 0.2.66 → 0.2.67
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.
|
@@ -45,7 +45,7 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
45
45
|
chips = _useState2[0],
|
|
46
46
|
setChips = _useState2[1];
|
|
47
47
|
var theme = (0, _styles.useTheme)();
|
|
48
|
-
var _useState3 = (0, _react.useState)(
|
|
48
|
+
var _useState3 = (0, _react.useState)(''),
|
|
49
49
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
50
50
|
txtValue = _useState4[0],
|
|
51
51
|
setTxtValue = _useState4[1];
|
|
@@ -56,17 +56,17 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
56
56
|
}, [chips]);
|
|
57
57
|
var onTextValueChange = function onTextValueChange(e) {
|
|
58
58
|
var value = e.target.value.trim();
|
|
59
|
-
setTxtValue(value.replace(
|
|
59
|
+
setTxtValue(value.replace(',', ''));
|
|
60
60
|
};
|
|
61
61
|
var handleAddChip = function handleAddChip(event) {
|
|
62
|
-
if ((event.key ===
|
|
62
|
+
if ((event.key === 'Enter' || event.keyCode === 32 || event.keyCode === 188 || event.keyCode === 9 || event.type === 'blur') && event.target.value.replace(',', '')) {
|
|
63
63
|
var _value = event.target.value;
|
|
64
|
-
var newValue = typeof _value ===
|
|
64
|
+
var newValue = typeof _value === 'string' ? _value.replace(',', '').trim() : _value.trim();
|
|
65
65
|
// if (chips.includes(newValue)) return; //add if any info or anything needs to be shown
|
|
66
66
|
setChips([].concat(_toConsumableArray(chips), [newValue]));
|
|
67
67
|
onChange([].concat(_toConsumableArray(chips), [newValue]));
|
|
68
|
-
setTxtValue(
|
|
69
|
-
event.target.parentNode.querySelector(
|
|
68
|
+
setTxtValue('');
|
|
69
|
+
event.target.parentNode.querySelector('input').value = '';
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
var handleDeleteChip = function handleDeleteChip(chipToDelete) {
|
|
@@ -82,8 +82,8 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
82
82
|
}, label && /*#__PURE__*/_react.default.createElement(_material.InputLabel, {
|
|
83
83
|
sx: {
|
|
84
84
|
fontWeight: 500,
|
|
85
|
-
|
|
86
|
-
color:
|
|
85
|
+
'& .MuiFormLabel-asterisk': {
|
|
86
|
+
color: '#FF0000'
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
89
|
size: "small",
|
|
@@ -97,23 +97,24 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
97
97
|
disabled: isDisabled,
|
|
98
98
|
onKeyDown: handleAddChip,
|
|
99
99
|
onBlur: function onBlur(e) {
|
|
100
|
-
|
|
100
|
+
setChips([]);
|
|
101
|
+
if (e.target.value !== '') {
|
|
101
102
|
handleAddChip(e);
|
|
102
103
|
}
|
|
103
104
|
},
|
|
104
105
|
style: {
|
|
105
|
-
backgroundColor: isDisabled &&
|
|
106
|
+
backgroundColor: isDisabled && '#E7E7E7'
|
|
106
107
|
},
|
|
107
108
|
sx: {
|
|
108
|
-
|
|
109
|
-
backgroundColor: isDisabled &&
|
|
109
|
+
'& MuiOutlinedInput': {
|
|
110
|
+
backgroundColor: isDisabled && '#E7E7E7'
|
|
110
111
|
},
|
|
111
|
-
|
|
112
|
+
'& input': {
|
|
112
113
|
// backgroundColor: isDisabled && '#E7E7E7',
|
|
113
|
-
color: isDisabled &&
|
|
114
|
+
color: isDisabled && '#000000'
|
|
114
115
|
},
|
|
115
116
|
marginTop: label ? theme.spacing(2.5) : 0,
|
|
116
|
-
|
|
117
|
+
'& label': {
|
|
117
118
|
fontWeight: 500
|
|
118
119
|
}
|
|
119
120
|
},
|
|
@@ -121,9 +122,9 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
121
122
|
helperText: errorMessage,
|
|
122
123
|
error: error,
|
|
123
124
|
InputProps: {
|
|
124
|
-
startAdornment: chips.map(function (chip) {
|
|
125
|
+
startAdornment: chips.map(function (chip, index) {
|
|
125
126
|
return /*#__PURE__*/_react.default.createElement(_Chip.default, {
|
|
126
|
-
key: chip,
|
|
127
|
+
key: "".concat(chip, "-").concat(index),
|
|
127
128
|
label: chip,
|
|
128
129
|
onDelete: function onDelete() {
|
|
129
130
|
return handleDeleteChip(chip);
|
|
@@ -132,7 +133,7 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
132
133
|
fontSize: "small"
|
|
133
134
|
}),
|
|
134
135
|
style: {
|
|
135
|
-
margin:
|
|
136
|
+
margin: '0.2rem'
|
|
136
137
|
},
|
|
137
138
|
size: "small"
|
|
138
139
|
});
|