hplx-react-elements-dev 1.0.65 → 1.0.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.
- package/dist/esm/index.js +68 -14
- 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,38 +17813,60 @@ 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.
|
|
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
|
+
onKeyDown: addEditTags,
|
|
17838
|
+
onBlur: function onBlur() {
|
|
17839
|
+
var newArr = __spreadArray([], tags, true);
|
|
17840
|
+
|
|
17841
|
+
newArr[index] = editInputValue;
|
|
17842
|
+
setTags(newArr);
|
|
17843
|
+
setValue(tags.filter(Boolean).join(", "));
|
|
17844
|
+
setEditIndex(-1);
|
|
17845
|
+
setEditInputValue("");
|
|
17846
|
+
}
|
|
17847
|
+
}) : jsxRuntime.exports.jsxs("div", __assign({
|
|
17798
17848
|
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"
|
|
17799
17849
|
}, {
|
|
17800
|
-
children: [jsxRuntime.exports.jsx(
|
|
17801
|
-
variant: "Semibold",
|
|
17802
|
-
type: "Text sm",
|
|
17803
|
-
className: "hplxt-text-Gray-600",
|
|
17850
|
+
children: [jsxRuntime.exports.jsx("button", __assign({
|
|
17804
17851
|
onClick: function onClick() {
|
|
17805
|
-
|
|
17852
|
+
setEditIndex(index);
|
|
17853
|
+
setEditInputValue(item);
|
|
17806
17854
|
}
|
|
17807
17855
|
}, {
|
|
17808
|
-
children:
|
|
17809
|
-
|
|
17856
|
+
children: jsxRuntime.exports.jsx(Typography, __assign({
|
|
17857
|
+
variant: "Semibold",
|
|
17858
|
+
type: "Text sm",
|
|
17859
|
+
className: "hplxt-text-Gray-600"
|
|
17860
|
+
}, {
|
|
17861
|
+
children: item
|
|
17862
|
+
}))
|
|
17863
|
+
}), index), jsxRuntime.exports.jsx("i", {
|
|
17810
17864
|
className: "hx_close hplxt-text-[75%] hplxt-text-Primary-700",
|
|
17811
17865
|
onClick: function onClick() {
|
|
17812
17866
|
return deleteTag(item, index);
|
|
17813
17867
|
}
|
|
17814
17868
|
})]
|
|
17815
|
-
})
|
|
17869
|
+
}));
|
|
17816
17870
|
}), jsxRuntime.exports.jsx("input", __assign({
|
|
17817
17871
|
type: "text",
|
|
17818
17872
|
value: tagInputValue,
|