hplx-react-elements-dev 1.0.65 → 1.0.66
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/esm/index.js +66 -11
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -17627,6 +17627,7 @@ var InputTag = function InputTag(_a) {
|
|
|
17627
17627
|
var wrapperRef = useRef(null);
|
|
17628
17628
|
var inputRef = useRef(null);
|
|
17629
17629
|
var ddRef = useRef(null);
|
|
17630
|
+
var editRef = useRef(null);
|
|
17630
17631
|
|
|
17631
17632
|
var _o = useState([]),
|
|
17632
17633
|
dropdownArr = _o[0],
|
|
@@ -17652,6 +17653,14 @@ var InputTag = function InputTag(_a) {
|
|
|
17652
17653
|
changeLeft = _s[0],
|
|
17653
17654
|
setChangeLeft = _s[1];
|
|
17654
17655
|
|
|
17656
|
+
var _t = useState(-1),
|
|
17657
|
+
editIndex = _t[0],
|
|
17658
|
+
setEditIndex = _t[1];
|
|
17659
|
+
|
|
17660
|
+
var _u = useState(""),
|
|
17661
|
+
editInputValue = _u[0],
|
|
17662
|
+
setEditInputValue = _u[1];
|
|
17663
|
+
|
|
17655
17664
|
var handleValueChange = function handleValueChange(e) {
|
|
17656
17665
|
var sug = [];
|
|
17657
17666
|
setShowDropdown(true);
|
|
@@ -17721,6 +17730,29 @@ var InputTag = function InputTag(_a) {
|
|
|
17721
17730
|
onBlur && onBlur(event);
|
|
17722
17731
|
};
|
|
17723
17732
|
|
|
17733
|
+
var addEditTags = function addEditTags(e) {
|
|
17734
|
+
if (e.keyCode === 13 && editInputValue) {
|
|
17735
|
+
var newArr = __spreadArray([], tags, true);
|
|
17736
|
+
|
|
17737
|
+
newArr[editIndex] = editInputValue;
|
|
17738
|
+
setTags(newArr);
|
|
17739
|
+
setValue(tags.filter(Boolean).join(", "));
|
|
17740
|
+
setEditIndex(-1);
|
|
17741
|
+
setEditInputValue("");
|
|
17742
|
+
} // if (Boolean(!tagInputValue) && e.keyCode === 8) {
|
|
17743
|
+
// setEditIndex(tags.length - 1);
|
|
17744
|
+
// setEditInputValue(tags[tags.length - 1]);
|
|
17745
|
+
// editRef.current && editRef.current.focus();
|
|
17746
|
+
// if (Boolean(!editInputValue) && e.keyCode === 8) {
|
|
17747
|
+
// deleteTag("", editIndex);
|
|
17748
|
+
// setEditIndex((prev) => prev - 1);
|
|
17749
|
+
// setEditInputValue(tags[editIndex]);
|
|
17750
|
+
// editRef.current && editRef.current.focus();
|
|
17751
|
+
// }
|
|
17752
|
+
// }
|
|
17753
|
+
|
|
17754
|
+
};
|
|
17755
|
+
|
|
17724
17756
|
var addTags = function addTags(e) {
|
|
17725
17757
|
if (e.keyCode === 13 && tagInputValue) {
|
|
17726
17758
|
setTags(__spreadArray(__spreadArray([], tags, true), [tagInputValue], false));
|
|
@@ -17781,29 +17813,52 @@ var InputTag = function InputTag(_a) {
|
|
|
17781
17813
|
setValue(tags.filter(Boolean).join(", "));
|
|
17782
17814
|
};
|
|
17783
17815
|
|
|
17784
|
-
var editTag = function editTag(item, index) {
|
|
17785
|
-
setTagInputValue(item);
|
|
17786
|
-
deleteTag(item, index);
|
|
17787
|
-
};
|
|
17788
|
-
|
|
17789
17816
|
useEffect(function () {
|
|
17790
17817
|
setValue(tags.filter(Boolean).join(", "));
|
|
17791
17818
|
handleValChange && handleValChange(tags.filter(Boolean).join(", "));
|
|
17792
17819
|
}, [tags]);
|
|
17820
|
+
useEffect(function () {
|
|
17821
|
+
if (editIndex >= 0) {
|
|
17822
|
+
editRef.current && editRef.current.focus();
|
|
17823
|
+
}
|
|
17824
|
+
}, [editIndex]);
|
|
17793
17825
|
return jsxRuntime.exports.jsxs("div", __assign({
|
|
17794
17826
|
className: "inputTag hplxt-w-auto hplxt-h-auto hplxt-gap-1 hplxt-p-1.5 hplxt-flex hplxt-flex-wrap hplxt-border-1 hplxt-rounded-lg hplxt-border-Blue_gray-100 hover:hplxt-border-Primary-300 hover:hplxt-shadow-xs-primary ".concat(active ? "hplxt-border-Primary-300 hplxt-shadow-xs-primary" : "", " ").concat(disabled ? "hplxt-bg-Gray-50" : "", " ").concat(className)
|
|
17795
17827
|
}, {
|
|
17796
17828
|
children: [tags.map(function (item, index) {
|
|
17797
|
-
return jsxRuntime.exports.
|
|
17798
|
-
|
|
17829
|
+
return index === editIndex ? jsxRuntime.exports.jsx("input", {
|
|
17830
|
+
type: "text",
|
|
17831
|
+
value: editInputValue,
|
|
17832
|
+
ref: editRef,
|
|
17833
|
+
className: " placeholder:hplxt-text-Gray-500 focus-visible:hplxt-outline-0 hplxt-border-0 hplxt-rounded hplxt-py-1 hplxt-px-2 hplxt-bg-Primary-50 focus:hplxt-border-0",
|
|
17834
|
+
onChange: function onChange(e) {
|
|
17835
|
+
setEditInputValue(e.target.value);
|
|
17836
|
+
|
|
17837
|
+
if ((editInputValue === null || editInputValue === void 0 ? void 0 : editInputValue.length) === 0) {
|
|
17838
|
+
deleteTag("", editIndex);
|
|
17839
|
+
}
|
|
17840
|
+
},
|
|
17841
|
+
onKeyDown: addEditTags,
|
|
17842
|
+
onBlur: function onBlur() {
|
|
17843
|
+
var newArr = __spreadArray([], tags, true);
|
|
17844
|
+
|
|
17845
|
+
newArr[index] = editInputValue;
|
|
17846
|
+
setTags(newArr);
|
|
17847
|
+
setValue(tags.filter(Boolean).join(", "));
|
|
17848
|
+
setEditIndex(-1);
|
|
17849
|
+
setEditInputValue("");
|
|
17850
|
+
}
|
|
17851
|
+
}) : jsxRuntime.exports.jsxs("button", __assign({
|
|
17852
|
+
className: "hplxt-flex hplxt-items-center hplxt-bg-Primary-50 hplxt-border-1 hplxt-rounded hplxt-border-Primary-100 hplxt-py-1 hplxt-px-2",
|
|
17853
|
+
onClick: function onClick() {
|
|
17854
|
+
setEditIndex(index);
|
|
17855
|
+
setEditInputValue(item);
|
|
17856
|
+
}
|
|
17799
17857
|
}, {
|
|
17800
17858
|
children: [jsxRuntime.exports.jsx(Typography, __assign({
|
|
17801
17859
|
variant: "Semibold",
|
|
17802
17860
|
type: "Text sm",
|
|
17803
|
-
className: "hplxt-text-Gray-600"
|
|
17804
|
-
onClick: function onClick() {
|
|
17805
|
-
return editTag(item, index);
|
|
17806
|
-
}
|
|
17861
|
+
className: "hplxt-text-Gray-600"
|
|
17807
17862
|
}, {
|
|
17808
17863
|
children: item
|
|
17809
17864
|
})), jsxRuntime.exports.jsx("div", {
|