tenjin-ui-kit 0.2.66 → 0.2.68
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) {
|
|
@@ -76,14 +76,15 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
|
+
console.log(chips, '0000000000000');
|
|
79
80
|
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_material.FormControl, {
|
|
80
81
|
variant: "standard",
|
|
81
82
|
fullWidth: fullWidth
|
|
82
83
|
}, label && /*#__PURE__*/_react.default.createElement(_material.InputLabel, {
|
|
83
84
|
sx: {
|
|
84
85
|
fontWeight: 500,
|
|
85
|
-
|
|
86
|
-
color:
|
|
86
|
+
'& .MuiFormLabel-asterisk': {
|
|
87
|
+
color: '#FF0000'
|
|
87
88
|
}
|
|
88
89
|
},
|
|
89
90
|
size: "small",
|
|
@@ -97,23 +98,26 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
97
98
|
disabled: isDisabled,
|
|
98
99
|
onKeyDown: handleAddChip,
|
|
99
100
|
onBlur: function onBlur(e) {
|
|
100
|
-
if (
|
|
101
|
+
if (!(chips !== null && chips !== void 0 && chips.length) > 0) {
|
|
102
|
+
setChips([]);
|
|
103
|
+
}
|
|
104
|
+
if (e.target.value !== '') {
|
|
101
105
|
handleAddChip(e);
|
|
102
106
|
}
|
|
103
107
|
},
|
|
104
108
|
style: {
|
|
105
|
-
backgroundColor: isDisabled &&
|
|
109
|
+
backgroundColor: isDisabled && '#E7E7E7'
|
|
106
110
|
},
|
|
107
111
|
sx: {
|
|
108
|
-
|
|
109
|
-
backgroundColor: isDisabled &&
|
|
112
|
+
'& MuiOutlinedInput': {
|
|
113
|
+
backgroundColor: isDisabled && '#E7E7E7'
|
|
110
114
|
},
|
|
111
|
-
|
|
115
|
+
'& input': {
|
|
112
116
|
// backgroundColor: isDisabled && '#E7E7E7',
|
|
113
|
-
color: isDisabled &&
|
|
117
|
+
color: isDisabled && '#000000'
|
|
114
118
|
},
|
|
115
119
|
marginTop: label ? theme.spacing(2.5) : 0,
|
|
116
|
-
|
|
120
|
+
'& label': {
|
|
117
121
|
fontWeight: 500
|
|
118
122
|
}
|
|
119
123
|
},
|
|
@@ -121,9 +125,9 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
121
125
|
helperText: errorMessage,
|
|
122
126
|
error: error,
|
|
123
127
|
InputProps: {
|
|
124
|
-
startAdornment: chips.map(function (chip) {
|
|
128
|
+
startAdornment: chips.map(function (chip, index) {
|
|
125
129
|
return /*#__PURE__*/_react.default.createElement(_Chip.default, {
|
|
126
|
-
key: chip,
|
|
130
|
+
key: "".concat(chip, "-").concat(index),
|
|
127
131
|
label: chip,
|
|
128
132
|
onDelete: function onDelete() {
|
|
129
133
|
return handleDeleteChip(chip);
|
|
@@ -132,7 +136,7 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
132
136
|
fontSize: "small"
|
|
133
137
|
}),
|
|
134
138
|
style: {
|
|
135
|
-
margin:
|
|
139
|
+
margin: '0.2rem'
|
|
136
140
|
},
|
|
137
141
|
size: "small"
|
|
138
142
|
});
|