tenjin-ui-kit 0.2.65 → 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,18 +45,27 @@ 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)(''),
|
|
49
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
50
|
+
txtValue = _useState4[0],
|
|
51
|
+
setTxtValue = _useState4[1];
|
|
48
52
|
(0, _react.useEffect)(function () {
|
|
49
53
|
if (onChange) {
|
|
50
54
|
onChange(chips);
|
|
51
55
|
}
|
|
52
56
|
}, [chips]);
|
|
57
|
+
var onTextValueChange = function onTextValueChange(e) {
|
|
58
|
+
var value = e.target.value.trim();
|
|
59
|
+
setTxtValue(value.replace(',', ''));
|
|
60
|
+
};
|
|
53
61
|
var handleAddChip = function handleAddChip(event) {
|
|
54
|
-
if (event.key === 'Enter' || event.keyCode === 188 || event.keyCode === 9 || event.type === 'blur') {
|
|
62
|
+
if ((event.key === 'Enter' || event.keyCode === 32 || event.keyCode === 188 || event.keyCode === 9 || event.type === 'blur') && event.target.value.replace(',', '')) {
|
|
55
63
|
var _value = event.target.value;
|
|
56
|
-
var newValue = typeof _value === 'string' ? _value.replace(',', '') : _value;
|
|
64
|
+
var newValue = typeof _value === 'string' ? _value.replace(',', '').trim() : _value.trim();
|
|
65
|
+
// if (chips.includes(newValue)) return; //add if any info or anything needs to be shown
|
|
57
66
|
setChips([].concat(_toConsumableArray(chips), [newValue]));
|
|
58
67
|
onChange([].concat(_toConsumableArray(chips), [newValue]));
|
|
59
|
-
|
|
68
|
+
setTxtValue('');
|
|
60
69
|
event.target.parentNode.querySelector('input').value = '';
|
|
61
70
|
}
|
|
62
71
|
};
|
|
@@ -80,12 +89,15 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
80
89
|
size: "small",
|
|
81
90
|
shrink: true,
|
|
82
91
|
required: isRequired
|
|
83
|
-
}, label), /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({
|
|
92
|
+
}, label), /*#__PURE__*/_react.default.createElement(_material.TextField, _extends({
|
|
93
|
+
value: txtValue
|
|
94
|
+
}, rest, {
|
|
84
95
|
id: id,
|
|
85
96
|
required: isRequired,
|
|
86
97
|
disabled: isDisabled,
|
|
87
98
|
onKeyDown: handleAddChip,
|
|
88
99
|
onBlur: function onBlur(e) {
|
|
100
|
+
setChips([]);
|
|
89
101
|
if (e.target.value !== '') {
|
|
90
102
|
handleAddChip(e);
|
|
91
103
|
}
|
|
@@ -106,12 +118,13 @@ var InputWithChip = function InputWithChip(_ref) {
|
|
|
106
118
|
fontWeight: 500
|
|
107
119
|
}
|
|
108
120
|
},
|
|
121
|
+
onChange: onTextValueChange,
|
|
109
122
|
helperText: errorMessage,
|
|
110
123
|
error: error,
|
|
111
124
|
InputProps: {
|
|
112
|
-
startAdornment: chips.map(function (chip) {
|
|
125
|
+
startAdornment: chips.map(function (chip, index) {
|
|
113
126
|
return /*#__PURE__*/_react.default.createElement(_Chip.default, {
|
|
114
|
-
key: chip,
|
|
127
|
+
key: "".concat(chip, "-").concat(index),
|
|
115
128
|
label: chip,
|
|
116
129
|
onDelete: function onDelete() {
|
|
117
130
|
return handleDeleteChip(chip);
|