hplx-react-elements-dev 1.0.74 → 1.0.76
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 +76 -36
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -17709,7 +17709,7 @@ var InputTag = function InputTag(_a) {
|
|
|
17709
17709
|
showDropdown = _k[0],
|
|
17710
17710
|
setShowDropdown = _k[1];
|
|
17711
17711
|
|
|
17712
|
-
var _l = useState(
|
|
17712
|
+
var _l = useState(""),
|
|
17713
17713
|
dropdownOffset = _l[0],
|
|
17714
17714
|
setdropdownOffset = _l[1];
|
|
17715
17715
|
|
|
@@ -17722,6 +17722,7 @@ var InputTag = function InputTag(_a) {
|
|
|
17722
17722
|
var inputRef = useRef(null);
|
|
17723
17723
|
var ddRef = useRef(null);
|
|
17724
17724
|
var editRef = useRef(null);
|
|
17725
|
+
var spanRef = useRef(null);
|
|
17725
17726
|
|
|
17726
17727
|
var _o = useState([]),
|
|
17727
17728
|
dropdownArr = _o[0],
|
|
@@ -17755,6 +17756,16 @@ var InputTag = function InputTag(_a) {
|
|
|
17755
17756
|
editInputValue = _u[0],
|
|
17756
17757
|
setEditInputValue = _u[1];
|
|
17757
17758
|
|
|
17759
|
+
var dropdownClickedRef = useRef(false);
|
|
17760
|
+
|
|
17761
|
+
var _v = useState(""),
|
|
17762
|
+
content = _v[0],
|
|
17763
|
+
setContent = _v[1];
|
|
17764
|
+
|
|
17765
|
+
var _w = useState(0),
|
|
17766
|
+
width = _w[0],
|
|
17767
|
+
setWidth = _w[1];
|
|
17768
|
+
|
|
17758
17769
|
var handleValueChange = function handleValueChange(e) {
|
|
17759
17770
|
var sug = [];
|
|
17760
17771
|
setShowDropdown(true);
|
|
@@ -17770,22 +17781,22 @@ var InputTag = function InputTag(_a) {
|
|
|
17770
17781
|
};
|
|
17771
17782
|
|
|
17772
17783
|
var handleClickOutside = function handleClickOutside(e) {
|
|
17773
|
-
setDropdownArr(options);
|
|
17774
|
-
|
|
17775
17784
|
if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
|
|
17776
17785
|
setShowDropdown(false);
|
|
17777
17786
|
setFocusIndex(-1);
|
|
17778
17787
|
}
|
|
17788
|
+
|
|
17789
|
+
dropdownClickedRef.current = false;
|
|
17779
17790
|
};
|
|
17780
17791
|
|
|
17781
17792
|
var handleDropdownClick = function handleDropdownClick(selectedItem) {
|
|
17793
|
+
setTagInputValue("");
|
|
17782
17794
|
setTags(function (prev) {
|
|
17783
17795
|
return __spreadArray(__spreadArray([], prev, true), [selectedItem.value], false);
|
|
17784
17796
|
});
|
|
17785
17797
|
setValue(function (prev) {
|
|
17786
17798
|
return prev.trim() + ", " + selectedItem.value;
|
|
17787
17799
|
});
|
|
17788
|
-
setTagInputValue("");
|
|
17789
17800
|
onDropdownClick && onDropdownClick(selectedItem);
|
|
17790
17801
|
handleValChange && handleValChange(value);
|
|
17791
17802
|
setFocusIndex(-1);
|
|
@@ -17804,6 +17815,11 @@ var InputTag = function InputTag(_a) {
|
|
|
17804
17815
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
17805
17816
|
};
|
|
17806
17817
|
});
|
|
17818
|
+
useEffect(function () {
|
|
17819
|
+
var _a;
|
|
17820
|
+
|
|
17821
|
+
setWidth(((_a = spanRef === null || spanRef === void 0 ? void 0 : spanRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0);
|
|
17822
|
+
}, [content]);
|
|
17807
17823
|
|
|
17808
17824
|
var handleFocus = function handleFocus(event) {
|
|
17809
17825
|
var _a;
|
|
@@ -17815,15 +17831,24 @@ var InputTag = function InputTag(_a) {
|
|
|
17815
17831
|
};
|
|
17816
17832
|
|
|
17817
17833
|
var handleBlur = function handleBlur(event) {
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17834
|
+
var sto = setTimeout(function () {
|
|
17835
|
+
if (dropdownClickedRef.current) {
|
|
17836
|
+
dropdownClickedRef.current = false;
|
|
17837
|
+
return;
|
|
17838
|
+
}
|
|
17823
17839
|
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17840
|
+
if (Boolean(tagInputValue) && tagInputValue.trim()) {
|
|
17841
|
+
setTags(__spreadArray(__spreadArray([], tags, true), [tagInputValue.trim()], false));
|
|
17842
|
+
setValue(tags.filter(Boolean).join(", "));
|
|
17843
|
+
setTagInputValue("");
|
|
17844
|
+
}
|
|
17845
|
+
|
|
17846
|
+
setFocusIndex(-1);
|
|
17847
|
+
setActive(false);
|
|
17848
|
+
onBlur && onBlur(event);
|
|
17849
|
+
dropdownClickedRef.current = false;
|
|
17850
|
+
sto && clearTimeout(sto);
|
|
17851
|
+
}, 100);
|
|
17827
17852
|
};
|
|
17828
17853
|
|
|
17829
17854
|
var addEditTags = function addEditTags(e) {
|
|
@@ -17935,34 +17960,48 @@ var InputTag = function InputTag(_a) {
|
|
|
17935
17960
|
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)
|
|
17936
17961
|
}, {
|
|
17937
17962
|
children: [tags.map(function (item, index) {
|
|
17938
|
-
return index === editIndex ? jsxRuntime.exports.
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
|
|
17954
|
-
|
|
17955
|
-
|
|
17956
|
-
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17963
|
+
return index === editIndex ? jsxRuntime.exports.jsxs("div", {
|
|
17964
|
+
children: [jsxRuntime.exports.jsx("input", {
|
|
17965
|
+
type: "text",
|
|
17966
|
+
value: editInputValue,
|
|
17967
|
+
ref: editRef,
|
|
17968
|
+
className: " hplxt-flex-1 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",
|
|
17969
|
+
onChange: function onChange(e) {
|
|
17970
|
+
setEditInputValue(e.target.value);
|
|
17971
|
+
setContent(e.target.value);
|
|
17972
|
+
},
|
|
17973
|
+
style: {
|
|
17974
|
+
width: width + 30
|
|
17975
|
+
},
|
|
17976
|
+
onKeyDown: addEditTags,
|
|
17977
|
+
onBlur: function onBlur() {
|
|
17978
|
+
if (editInputValue.trim()) {
|
|
17979
|
+
var newArr = __spreadArray([], tags, true);
|
|
17980
|
+
|
|
17981
|
+
newArr[index] = editInputValue.trim();
|
|
17982
|
+
setTags(newArr);
|
|
17983
|
+
setValue(tags.filter(Boolean).join(", "));
|
|
17984
|
+
} else deleteTag("", editIndex);
|
|
17985
|
+
|
|
17986
|
+
setEditIndex(-1);
|
|
17987
|
+
setEditInputValue("");
|
|
17988
|
+
setContent("");
|
|
17989
|
+
}
|
|
17990
|
+
}), jsxRuntime.exports.jsx("span", __assign({
|
|
17991
|
+
id: "hide",
|
|
17992
|
+
ref: spanRef,
|
|
17993
|
+
className: "hplxt-opacity-0 hplxt-absolute"
|
|
17994
|
+
}, {
|
|
17995
|
+
children: content
|
|
17996
|
+
}))]
|
|
17997
|
+
}, item) : jsxRuntime.exports.jsxs("div", __assign({
|
|
17960
17998
|
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"
|
|
17961
17999
|
}, {
|
|
17962
18000
|
children: [jsxRuntime.exports.jsx("button", __assign({
|
|
17963
18001
|
onClick: function onClick() {
|
|
17964
18002
|
setEditIndex(index);
|
|
17965
18003
|
setEditInputValue(item);
|
|
18004
|
+
setContent(item);
|
|
17966
18005
|
}
|
|
17967
18006
|
}, {
|
|
17968
18007
|
children: jsxRuntime.exports.jsx(Typography, __assign({
|
|
@@ -17978,7 +18017,7 @@ var InputTag = function InputTag(_a) {
|
|
|
17978
18017
|
return deleteTag(item, index);
|
|
17979
18018
|
}
|
|
17980
18019
|
})]
|
|
17981
|
-
}));
|
|
18020
|
+
}), item);
|
|
17982
18021
|
}), jsxRuntime.exports.jsx("input", __assign({
|
|
17983
18022
|
type: "text",
|
|
17984
18023
|
value: tagInputValue,
|
|
@@ -18012,7 +18051,8 @@ var InputTag = function InputTag(_a) {
|
|
|
18012
18051
|
className: "hplxt-text-Primary-700 ".concat(index === focusIndex ? "hplxt-bg-Blue_gray-100 hplxt-font-inter-1" : "")
|
|
18013
18052
|
}, restOptions, {
|
|
18014
18053
|
onSelect: function onSelect() {
|
|
18015
|
-
|
|
18054
|
+
dropdownClickedRef.current = true;
|
|
18055
|
+
handleDropdownClick(restOptions);
|
|
18016
18056
|
},
|
|
18017
18057
|
ddRef: ddRef,
|
|
18018
18058
|
setChangeLeft: setChangeLeft
|