hplx-react-elements-dev 1.1.31 → 1.1.32

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 +57 -41
  2. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -18284,47 +18284,51 @@ var InputTag = function InputTag(_a) {
18284
18284
  dropdownArr = _r[0],
18285
18285
  setDropdownArr = _r[1];
18286
18286
 
18287
- var _s = useState(""),
18288
- tagInputValue = _s[0],
18289
- setTagInputValue = _s[1]; // input field state
18287
+ var _s = useState(false),
18288
+ dropDownTag = _s[0],
18289
+ setDropDownTag = _s[1];
18290
+
18291
+ var _t = useState(""),
18292
+ tagInputValue = _t[0],
18293
+ setTagInputValue = _t[1]; // input field state
18290
18294
 
18291
18295
 
18292
- var _t = useState(__spreadArray(__spreadArray([], tagList.filter(Boolean), true), tagString.split(",").filter(Boolean).map(function (item) {
18296
+ var _u = useState(__spreadArray(__spreadArray([], tagList.filter(Boolean), true), tagString.split(",").filter(Boolean).map(function (item) {
18293
18297
  return item.trim();
18294
18298
  }), true)),
18295
- tags = _t[0],
18296
- setTags = _t[1]; // tag array
18299
+ tags = _u[0],
18300
+ setTags = _u[1]; // tag array
18297
18301
 
18298
18302
 
18299
- var _u = useState(-1),
18300
- focusIndex = _u[0],
18301
- setFocusIndex = _u[1];
18303
+ var _v = useState(-1),
18304
+ focusIndex = _v[0],
18305
+ setFocusIndex = _v[1];
18302
18306
 
18303
- var _v = useState(true),
18304
- changeLeft = _v[0],
18305
- setChangeLeft = _v[1];
18307
+ var _w = useState(true),
18308
+ changeLeft = _w[0],
18309
+ setChangeLeft = _w[1];
18306
18310
 
18307
- var _w = useState(-1),
18308
- editIndex = _w[0],
18309
- setEditIndex = _w[1];
18311
+ var _x = useState(-1),
18312
+ editIndex = _x[0],
18313
+ setEditIndex = _x[1];
18310
18314
 
18311
- var _x = useState(""),
18312
- editInputValue = _x[0],
18313
- setEditInputValue = _x[1];
18315
+ var _y = useState(""),
18316
+ editInputValue = _y[0],
18317
+ setEditInputValue = _y[1];
18314
18318
 
18315
18319
  var dropdownClickedRef = useRef(false);
18316
18320
 
18317
- var _y = useState(""),
18318
- content = _y[0],
18319
- setContent = _y[1];
18321
+ var _z = useState(""),
18322
+ content = _z[0],
18323
+ setContent = _z[1];
18320
18324
 
18321
- var _z = useState(0),
18322
- width = _z[0],
18323
- setWidth = _z[1];
18325
+ var _0 = useState(0),
18326
+ width = _0[0],
18327
+ setWidth = _0[1];
18324
18328
 
18325
- var _0 = useState(-1),
18326
- divIndex = _0[0],
18327
- setDivIndex = _0[1];
18329
+ var _1 = useState(-1),
18330
+ divIndex = _1[0],
18331
+ setDivIndex = _1[1];
18328
18332
 
18329
18333
  var handleDragStart = function handleDragStart(e, index) {
18330
18334
  e.dataTransfer.setData("text/plain", index.toString());
@@ -18467,10 +18471,10 @@ var InputTag = function InputTag(_a) {
18467
18471
  } // Set the dropdown offset
18468
18472
 
18469
18473
 
18470
- if (divIndex === -1) {
18474
+ if (divIndex === -1 && !dropDownTag) {
18471
18475
  showDropdown && setdropdownOffset("".concat((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.offsetLeft, "px"));
18472
18476
  }
18473
- }, [options, tags, inputRef, allowDuplicates, showDropdown]); // This function handles the click event of a dropdown item
18477
+ }, [options, tags, inputRef, allowDuplicates, dropDownTag, showDropdown]); // This function handles the click event of a dropdown item
18474
18478
 
18475
18479
  var handleDropdownClick = function handleDropdownClick(selectedItem, index, divIndex) {
18476
18480
  // Set a timeout to add the selected item to the tags after a certain time
@@ -18478,34 +18482,46 @@ var InputTag = function InputTag(_a) {
18478
18482
  // If allowDuplicates flag is true or the selected item is not already in the tags, add the item to the tags
18479
18483
  if (allowDuplicates || !tags.includes(selectedItem.value)) {
18480
18484
  if (divIndex !== -1) {
18485
+ onDropdownClick && onDropdownClick(selectedItem, index, divRef.current[divIndex].textContent);
18486
+
18481
18487
  var newTagList = __spreadArray([], tags, true);
18482
18488
 
18483
18489
  newTagList.splice(divIndex, 0, selectedItem.value);
18484
- setTags(newTagList);
18490
+ setTags(newTagList); // Add the selected item to the input value and update the displayed value
18491
+
18492
+ var inputValue = value.split(",");
18493
+
18494
+ var val = __spreadArray([], inputValue, true);
18495
+
18496
+ val.splice(divIndex, 0, selectedItem.value);
18497
+ var inputVal = val.join(",");
18498
+ setValue(inputVal); // Call handleValChange function if it is defined
18499
+
18500
+ handleValChange && handleValChange(inputVal, "", "dropdown");
18501
+ setDropDownTag(true);
18485
18502
  divRef.current[divIndex].textContent = "";
18486
18503
  setTimeout(function () {
18487
18504
  divRef.current[divIndex + 1].focus();
18505
+ setDropDownTag(false);
18488
18506
  }, 0);
18489
18507
  setDivIndex(divIndex + 1);
18490
- setFocusIndex(-1);
18491
18508
  } else {
18492
18509
  setTags(function (prev) {
18493
18510
  return __spreadArray(__spreadArray([], prev, true), [selectedItem.value], false);
18494
18511
  });
18495
- }
18496
- } // Add the selected item to the input value and update the displayed value
18512
+ onDropdownClick && onDropdownClick(selectedItem, index, tagInputValue); // Add the selected item to the input value and update the displayed value
18497
18513
 
18514
+ var val = value.trim() + ", " + selectedItem.value;
18515
+ setValue(val); // Call handleValChange function if it is defined
18498
18516
 
18499
- var val = value.trim() + ", " + selectedItem.value;
18500
- setValue(val); // Call onDropdownClick function if it is defined
18501
-
18502
- onDropdownClick && onDropdownClick(selectedItem, index, tagInputValue); // Call handleValChange function if it is defined
18517
+ handleValChange && handleValChange(val, "", "dropdown");
18518
+ setTagInputValue("");
18519
+ }
18520
+ } // Reset focus index and dropdown array
18503
18521
 
18504
- handleValChange && handleValChange(val, "", "dropdown"); // Reset focus index and dropdown array
18505
18522
 
18506
18523
  setFocusIndex(-1);
18507
- setDropdownArr(options);
18508
- setTagInputValue(""); // Clear the timeout
18524
+ setDropdownArr(options); // Clear the timeout
18509
18525
 
18510
18526
  sto && clearTimeout(sto);
18511
18527
  }, 100); // Return a function to clear the timeout when the component unmounts or when a new dropdown item is clicked
@@ -18632,7 +18648,7 @@ var InputTag = function InputTag(_a) {
18632
18648
  }, 0);
18633
18649
  setDivIndex(index + 1);
18634
18650
  setFocusIndex(-1);
18635
- focusIndex < 0 && handleValChange && handleValChange(newTagList.filter(Boolean).join(", "), tagInputValue.trim(), "");
18651
+ focusIndex < 0 && handleValChange && handleValChange(newTagList.filter(Boolean).join(", "), inputValue.trim(), "");
18636
18652
  } else if (e.keyCode === 13 && inputValue.trim().length <= 1) {
18637
18653
  setFocusIndex(-1);
18638
18654
 
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "frontend",
10
10
  "healthplix"
11
11
  ],
12
- "version": "1.1.31",
12
+ "version": "1.1.32",
13
13
  "main": "dist/esm/index.js",
14
14
  "module": "dist/esm/index.js",
15
15
  "types": "dist/esm/index.d.ts",