hplx-react-elements-dev 1.0.64 → 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.
Files changed (2) hide show
  1. package/dist/esm/index.js +110 -63
  2. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -17384,29 +17384,20 @@ var DoubleInput = function DoubleInput(_a) {
17384
17384
  suffixValueChanged = _z[0],
17385
17385
  setSuffixValueChanged = _z[1];
17386
17386
 
17387
- var _0 = useState(false),
17388
- active = _0[0],
17389
- setActive = _0[1];
17390
-
17391
- var _1 = useState(false),
17392
- setSuffixActive = _1[1];
17393
-
17394
17387
  var handleFocus = function handleFocus(event) {
17395
- setActive(true);
17396
17388
  setShowDropdown(true);
17397
17389
  setDropdownArr(options);
17398
17390
  onFocus && onFocus(event);
17399
17391
  };
17400
17392
 
17401
17393
  var handleBlur = function handleBlur(event) {
17402
- setActive(false);
17403
17394
  setShowDropdown(false);
17404
17395
  onBlur && onBlur(event);
17405
17396
  };
17406
17397
 
17407
17398
  var handleClickOutside = function handleClickOutside(e) {
17408
17399
  if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
17409
- !active && valueChanged && onlyDropdownItemsAllowed && setValue("");
17400
+ valueChanged && onlyDropdownItemsAllowed && setValue("");
17410
17401
  setShowDropdown(false);
17411
17402
  }
17412
17403
 
@@ -17528,12 +17519,10 @@ var DoubleInput = function DoubleInput(_a) {
17528
17519
  return handleSuffixValueChange(e);
17529
17520
  },
17530
17521
  onFocus: function onFocus() {
17531
- setSuffixActive(true);
17532
17522
  setShowSuffixDropdown(true);
17533
17523
  setSuffixDropdownArr(suffixOptions);
17534
17524
  },
17535
17525
  onBlur: function onBlur() {
17536
- setSuffixActive(false);
17537
17526
  setShowSuffixDropdown(false);
17538
17527
  }
17539
17528
  }, suffixInputProps)), Boolean(end_icon) && jsxRuntime.exports.jsx("div", __assign({
@@ -17599,69 +17588,78 @@ var DoubleInput = function DoubleInput(_a) {
17599
17588
  };
17600
17589
 
17601
17590
  var InputTag = function InputTag(_a) {
17602
- var _b, _c, _d, _e;
17591
+ var _b, _c;
17603
17592
 
17604
17593
  var inputProps = _a.inputProps,
17605
17594
  className = _a.className,
17606
17595
  dropdownClassName = _a.dropdownClassName,
17607
- _f = _a.options,
17608
- options = _f === void 0 ? [] : _f,
17609
- _g = _a.tagList,
17610
- tagList = _g === void 0 ? [] : _g,
17611
- _h = _a.tagString,
17612
- tagString = _h === void 0 ? "" : _h,
17596
+ _d = _a.options,
17597
+ options = _d === void 0 ? [] : _d,
17598
+ _e = _a.tagList,
17599
+ tagList = _e === void 0 ? [] : _e,
17600
+ _f = _a.tagString,
17601
+ tagString = _f === void 0 ? "" : _f,
17613
17602
  // comma separated string which is created into separate tags
17614
- _j = _a.handleValChange,
17603
+ _g = _a.handleValChange,
17615
17604
  // comma separated string which is created into separate tags
17616
- handleValChange = _j === void 0 ? function (_) {} : _j,
17617
- _k = _a.onDropdownClick,
17618
- onDropdownClick = _k === void 0 ? function (_) {} : _k;
17605
+ handleValChange = _g === void 0 ? function (_) {} : _g,
17606
+ _h = _a.onDropdownClick,
17607
+ onDropdownClick = _h === void 0 ? function (_) {} : _h;
17619
17608
 
17620
- var _l = inputProps || {},
17621
- disabled = _l.disabled,
17622
- onFocus = _l.onFocus,
17623
- onBlur = _l.onBlur;
17609
+ var _j = inputProps || {},
17610
+ disabled = _j.disabled,
17611
+ onFocus = _j.onFocus,
17612
+ onBlur = _j.onBlur;
17624
17613
 
17625
- var _m = useState(false),
17626
- active = _m[0],
17627
- setActive = _m[1];
17614
+ var _k = useState(false),
17615
+ active = _k[0],
17616
+ setActive = _k[1];
17628
17617
 
17629
- var _o = useState(false),
17630
- showDropdown = _o[0],
17631
- setShowDropdown = _o[1];
17618
+ var _l = useState(false),
17619
+ showDropdown = _l[0],
17620
+ setShowDropdown = _l[1];
17632
17621
 
17633
- var _p = useState(""),
17634
- value = _p[0],
17635
- setValue = _p[1]; // tag string
17622
+ var _m = useState(""),
17623
+ value = _m[0],
17624
+ setValue = _m[1]; // tag string
17636
17625
 
17637
17626
 
17638
17627
  var wrapperRef = useRef(null);
17639
17628
  var inputRef = useRef(null);
17640
17629
  var ddRef = useRef(null);
17630
+ var editRef = useRef(null);
17641
17631
 
17642
- var _q = useState([]),
17643
- dropdownArr = _q[0],
17644
- setDropdownArr = _q[1];
17632
+ var _o = useState([]),
17633
+ dropdownArr = _o[0],
17634
+ setDropdownArr = _o[1];
17645
17635
 
17646
- var _r = useState(""),
17647
- tagInputValue = _r[0],
17648
- setTagInputValue = _r[1]; // input field state
17636
+ var _p = useState(""),
17637
+ tagInputValue = _p[0],
17638
+ setTagInputValue = _p[1]; // input field state
17649
17639
 
17650
17640
 
17651
- var _s = useState(__spreadArray(__spreadArray([], tagList.filter(Boolean), true), tagString.split(",").filter(Boolean).map(function (item) {
17641
+ var _q = useState(__spreadArray(__spreadArray([], tagList.filter(Boolean), true), tagString.split(",").filter(Boolean).map(function (item) {
17652
17642
  return item.trim();
17653
17643
  }), true)),
17654
- tags = _s[0],
17655
- setTags = _s[1]; // tag array
17644
+ tags = _q[0],
17645
+ setTags = _q[1]; // tag array
17646
+
17656
17647
 
17648
+ var _r = useState(-1),
17649
+ focusIndex = _r[0],
17650
+ setFocusIndex = _r[1];
17651
+
17652
+ var _s = useState(true),
17653
+ changeLeft = _s[0],
17654
+ setChangeLeft = _s[1];
17657
17655
 
17658
17656
  var _t = useState(-1),
17659
- focusIndex = _t[0],
17660
- setFocusIndex = _t[1];
17657
+ editIndex = _t[0],
17658
+ setEditIndex = _t[1];
17661
17659
 
17662
- var _u = useState(true),
17663
- changeLeft = _u[0],
17664
- setChangeLeft = _u[1];
17660
+ var _u = useState(""),
17661
+ editInputValue = _u[0],
17662
+ setEditInputValue = _u[1];
17665
17663
 
17666
17664
  var handleValueChange = function handleValueChange(e) {
17667
17665
  var sug = [];
@@ -17732,6 +17730,29 @@ var InputTag = function InputTag(_a) {
17732
17730
  onBlur && onBlur(event);
17733
17731
  };
17734
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
+
17735
17756
  var addTags = function addTags(e) {
17736
17757
  if (e.keyCode === 13 && tagInputValue) {
17737
17758
  setTags(__spreadArray(__spreadArray([], tags, true), [tagInputValue], false));
@@ -17792,29 +17813,52 @@ var InputTag = function InputTag(_a) {
17792
17813
  setValue(tags.filter(Boolean).join(", "));
17793
17814
  };
17794
17815
 
17795
- var editTag = function editTag(item, index) {
17796
- setTagInputValue(item);
17797
- deleteTag(item, index);
17798
- };
17799
-
17800
17816
  useEffect(function () {
17801
17817
  setValue(tags.filter(Boolean).join(", "));
17802
17818
  handleValChange && handleValChange(tags.filter(Boolean).join(", "));
17803
17819
  }, [tags]);
17820
+ useEffect(function () {
17821
+ if (editIndex >= 0) {
17822
+ editRef.current && editRef.current.focus();
17823
+ }
17824
+ }, [editIndex]);
17804
17825
  return jsxRuntime.exports.jsxs("div", __assign({
17805
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)
17806
17827
  }, {
17807
17828
  children: [tags.map(function (item, index) {
17808
- return jsxRuntime.exports.jsxs("button", __assign({
17809
- 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"
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
+ }
17810
17857
  }, {
17811
17858
  children: [jsxRuntime.exports.jsx(Typography, __assign({
17812
17859
  variant: "Semibold",
17813
17860
  type: "Text sm",
17814
- className: "hplxt-text-Gray-600",
17815
- onClick: function onClick() {
17816
- return editTag(item, index);
17817
- }
17861
+ className: "hplxt-text-Gray-600"
17818
17862
  }, {
17819
17863
  children: item
17820
17864
  })), jsxRuntime.exports.jsx("div", {
@@ -17839,11 +17883,14 @@ var InputTag = function InputTag(_a) {
17839
17883
  onFocus: handleFocus,
17840
17884
  onBlur: handleBlur
17841
17885
  })), showDropdown && jsxRuntime.exports.jsx("div", __assign({
17886
+ onClick: function onClick() {
17887
+ return inputRef.current && inputRef.current.focus();
17888
+ },
17842
17889
  ref: wrapperRef,
17843
17890
  className: "hplxt-absolute hplxt-border hplxt-border-Gray-300 hplxt-mt-1 hplxt-min-w-max hplxt-rounded-lg hplxt-bg-Indigo-25 hplxt-overflow-y-auto hplxt-shadow-md hplxt-z-10 hplxt-max-h-80 ".concat(dropdownClassName),
17844
17891
  style: {
17845
- left: changeLeft ? '' : "".concat((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.offsetLeft, "px"),
17846
- top: "".concat(((_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.offsetTop) ? ((_d = inputRef.current) === null || _d === void 0 ? void 0 : _d.offsetTop) + 30 : (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.offsetTop, "px")
17892
+ left: changeLeft ? "".concat((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.offsetLeft, "px") : "",
17893
+ top: "".concat((((_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.offsetTop) || 0) + 30, "px")
17847
17894
  }
17848
17895
  }, {
17849
17896
  children: dropdownArr && dropdownArr.length > 0 && jsxRuntime.exports.jsx("div", {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "frontend",
10
10
  "healthplix"
11
11
  ],
12
- "version": "1.0.64",
12
+ "version": "1.0.66",
13
13
  "main": "dist/esm/index.js",
14
14
  "module": "dist/esm/index.js",
15
15
  "types": "dist/esm/index.d.ts",