hplx-react-elements-dev 1.0.75 → 1.0.77

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.
Files changed (2) hide show
  1. package/dist/esm/index.js +56 -26
  2. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -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],
@@ -17757,6 +17758,14 @@ var InputTag = function InputTag(_a) {
17757
17758
 
17758
17759
  var dropdownClickedRef = useRef(false);
17759
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
+
17760
17769
  var handleValueChange = function handleValueChange(e) {
17761
17770
  var sug = [];
17762
17771
  setShowDropdown(true);
@@ -17806,6 +17815,11 @@ var InputTag = function InputTag(_a) {
17806
17815
  document.removeEventListener("mousedown", handleClickOutside);
17807
17816
  };
17808
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]);
17809
17823
 
17810
17824
  var handleFocus = function handleFocus(event) {
17811
17825
  var _a;
@@ -17863,6 +17877,8 @@ var InputTag = function InputTag(_a) {
17863
17877
  };
17864
17878
 
17865
17879
  var addTags = function addTags(e) {
17880
+ var ITEM_HEIGHT = 40;
17881
+
17866
17882
  if (e.keyCode === 13 && tagInputValue.trim()) {
17867
17883
  setTags(__spreadArray(__spreadArray([], tags, true), [tagInputValue.trim()], false));
17868
17884
  setValue(tags.filter(Boolean).join(", "));
@@ -17884,7 +17900,7 @@ var InputTag = function InputTag(_a) {
17884
17900
  var focusI = focusIndex + 1;
17885
17901
 
17886
17902
  if (wrapperRef && wrapperRef.current) {
17887
- wrapperRef.current.scrollBy(0, 18);
17903
+ wrapperRef.current.scrollBy(0, ITEM_HEIGHT);
17888
17904
  }
17889
17905
 
17890
17906
  setFocusIndex(focusI);
@@ -17893,11 +17909,11 @@ var InputTag = function InputTag(_a) {
17893
17909
 
17894
17910
 
17895
17911
  if (e.keyCode === 38) {
17896
- if (focusIndex !== 0) {
17912
+ if (focusIndex > 0) {
17897
17913
  var focusI = focusIndex - 1;
17898
17914
 
17899
17915
  if (wrapperRef && wrapperRef.current) {
17900
- wrapperRef.current.scrollBy(0, -18);
17916
+ wrapperRef.current.scrollBy(0, -ITEM_HEIGHT);
17901
17917
  }
17902
17918
 
17903
17919
  setFocusIndex(focusI);
@@ -17946,34 +17962,48 @@ var InputTag = function InputTag(_a) {
17946
17962
  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)
17947
17963
  }, {
17948
17964
  children: [tags.map(function (item, index) {
17949
- return index === editIndex ? jsxRuntime.exports.jsx("input", {
17950
- type: "text",
17951
- value: editInputValue,
17952
- ref: editRef,
17953
- className: "hplxt-flex 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",
17954
- onChange: function onChange(e) {
17955
- setEditInputValue(e.target.value);
17956
- },
17957
- onKeyDown: addEditTags,
17958
- onBlur: function onBlur() {
17959
- if (editInputValue.trim()) {
17960
- var newArr = __spreadArray([], tags, true);
17961
-
17962
- newArr[index] = editInputValue.trim();
17963
- setTags(newArr);
17964
- setValue(tags.filter(Boolean).join(", "));
17965
- } else deleteTag("", editIndex);
17966
-
17967
- setEditIndex(-1);
17968
- setEditInputValue("");
17969
- }
17970
- }) : jsxRuntime.exports.jsxs("div", __assign({
17965
+ return index === editIndex ? jsxRuntime.exports.jsxs("div", {
17966
+ children: [jsxRuntime.exports.jsx("input", {
17967
+ type: "text",
17968
+ value: editInputValue,
17969
+ ref: editRef,
17970
+ 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",
17971
+ onChange: function onChange(e) {
17972
+ setEditInputValue(e.target.value);
17973
+ setContent(e.target.value);
17974
+ },
17975
+ style: {
17976
+ width: width + 30
17977
+ },
17978
+ onKeyDown: addEditTags,
17979
+ onBlur: function onBlur() {
17980
+ if (editInputValue.trim()) {
17981
+ var newArr = __spreadArray([], tags, true);
17982
+
17983
+ newArr[index] = editInputValue.trim();
17984
+ setTags(newArr);
17985
+ setValue(tags.filter(Boolean).join(", "));
17986
+ } else deleteTag("", editIndex);
17987
+
17988
+ setEditIndex(-1);
17989
+ setEditInputValue("");
17990
+ setContent("");
17991
+ }
17992
+ }), jsxRuntime.exports.jsx("span", __assign({
17993
+ id: "hide",
17994
+ ref: spanRef,
17995
+ className: "hplxt-opacity-0 hplxt-absolute"
17996
+ }, {
17997
+ children: content
17998
+ }))]
17999
+ }, item) : jsxRuntime.exports.jsxs("div", __assign({
17971
18000
  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"
17972
18001
  }, {
17973
18002
  children: [jsxRuntime.exports.jsx("button", __assign({
17974
18003
  onClick: function onClick() {
17975
18004
  setEditIndex(index);
17976
18005
  setEditInputValue(item);
18006
+ setContent(item);
17977
18007
  }
17978
18008
  }, {
17979
18009
  children: jsxRuntime.exports.jsx(Typography, __assign({
@@ -17989,7 +18019,7 @@ var InputTag = function InputTag(_a) {
17989
18019
  return deleteTag(item, index);
17990
18020
  }
17991
18021
  })]
17992
- }));
18022
+ }), item);
17993
18023
  }), jsxRuntime.exports.jsx("input", __assign({
17994
18024
  type: "text",
17995
18025
  value: tagInputValue,
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "frontend",
10
10
  "healthplix"
11
11
  ],
12
- "version": "1.0.75",
12
+ "version": "1.0.77",
13
13
  "main": "dist/esm/index.js",
14
14
  "module": "dist/esm/index.js",
15
15
  "types": "dist/esm/index.d.ts",