hplx-react-elements-dev 1.0.54 → 1.0.56

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.
@@ -26,3 +26,4 @@ export { default as MessageToast } from "./messageToast/MessageToast";
26
26
  export { default as NestedDropdown } from "./nestedDropdown/NestedDropdown";
27
27
  export { default as DatePicker } from "./datePicker/DatePicker";
28
28
  export { default as DoubleInput } from "./doubleInput/DoubleInput";
29
+ export { default as InputTag } from "./inputTag/InputTag";
package/dist/esm/index.js CHANGED
@@ -1956,6 +1956,16 @@ function __rest(s, e) {
1956
1956
  t[p[i]] = s[p[i]];
1957
1957
  }
1958
1958
  return t;
1959
+ }
1960
+
1961
+ function __spreadArray(to, from, pack) {
1962
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1963
+ if (ar || !(i in from)) {
1964
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1965
+ ar[i] = from[i];
1966
+ }
1967
+ }
1968
+ return to.concat(ar || Array.prototype.slice.call(from));
1959
1969
  }
1960
1970
 
1961
1971
  var jsxRuntime = {exports: {}};
@@ -2439,15 +2449,18 @@ var InputField = function InputField(_a) {
2439
2449
  }))
2440
2450
  })), showEmailSuggestions && // This div displays a dropdown of email provider options
2441
2451
  jsxRuntime.exports.jsx("div", __assign({
2442
- className: "hplxt-absolute hplxt-mt-1 hplxt-left-10 hplxt-right-10 hplxt-min-w-max hplxt-rounded-lg hplxt-bg-White hplxt-overflow-y-scroll hplxt-shadow-md hplxt-z-10 hplxt-max-h-80 ".concat(showEmailDropdown ? "hplxt-block" : "hplxt-hidden")
2452
+ className: "hplxt-absolute ".concat(showEmailDropdown ? "hplxt-block" : "hplxt-hidden", " hplxt-mt-1 hplxt-min-w-max hplxt-rounded-lg hplxt-border hplxt-border-Blue_gray-200 hplxt-bg-White hplxt-overflow-y-scroll hplxt-shadow-md hplxt-z-10 hplxt-max-h-72 ")
2443
2453
  }, {
2444
- children: emailProviders === null || emailProviders === void 0 ? void 0 : emailProviders.map(function (option) {
2445
- return jsxRuntime.exports.jsx(DropdownItems, {
2446
- label: option,
2447
- onSelect: function onSelect() {
2448
- handleEmailProviderSelection(option);
2449
- }
2450
- }, option);
2454
+ children: jsxRuntime.exports.jsx("div", {
2455
+ children: emailProviders === null || emailProviders === void 0 ? void 0 : emailProviders.map(function (option) {
2456
+ return jsxRuntime.exports.jsx(DropdownItems, {
2457
+ className: "hplxt-text-Primary-700",
2458
+ label: option,
2459
+ onSelect: function onSelect() {
2460
+ handleEmailProviderSelection(option);
2461
+ }
2462
+ }, option);
2463
+ })
2451
2464
  })
2452
2465
  })), (Boolean(hint_text) || Boolean(errorMsg)) && jsxRuntime.exports.jsx("div", __assign({
2453
2466
  className: "".concat(errorMsg ? "hplxt-text-Error-500" : "hplxt-text-Gray-500 hplxt-mt-1")
@@ -17412,7 +17425,7 @@ var DoubleInput = function DoubleInput(_a) {
17412
17425
  };
17413
17426
 
17414
17427
  var handleDropdownClick = function handleDropdownClick(selectedItem) {
17415
- setSuffixValueChanged(false);
17428
+ setValueChanged(false);
17416
17429
  setValue(selectedItem.value);
17417
17430
  onDropdownClick && onDropdownClick(selectedItem);
17418
17431
  setShowDropdown(false);
@@ -17438,7 +17451,7 @@ var DoubleInput = function DoubleInput(_a) {
17438
17451
  setSuffixValue(input2value);
17439
17452
  }, [input2value]);
17440
17453
  return jsxRuntime.exports.jsx("div", __assign({
17441
- className: "inputfield hplxt-flex "
17454
+ className: "doubleInput hplxt-flex "
17442
17455
  }, {
17443
17456
  children: jsxRuntime.exports.jsxs(Typography, __assign({
17444
17457
  variant: "Regular",
@@ -17551,4 +17564,219 @@ var DoubleInput = function DoubleInput(_a) {
17551
17564
  }));
17552
17565
  };
17553
17566
 
17554
- export { AddSuggestion, Avatar, Badge, BadgeGroup, Button, ButtonGroups, Card, Checkbox, CheckboxGroup, CheckboxGroupItem, CollapsibleCard, DatePicker, DoubleInput, DropdownField, DropdownItems as DropdownItem, InputField, InputFieldSplit, MessageToast, NestedDropdown, OtpField, ProgressBar, ProgressCircle, RadioBtn, Slider, TextAreaField, ToggleSwitch, Tooltip, Typography };
17567
+ var InputTag = function InputTag(_a) {
17568
+ var _b, _c, _d, _e;
17569
+
17570
+ var inputProps = _a.inputProps,
17571
+ className = _a.className,
17572
+ dropdownClassName = _a.dropdownClassName,
17573
+ _f = _a.options,
17574
+ options = _f === void 0 ? [] : _f,
17575
+ _g = _a.tagList,
17576
+ tagList = _g === void 0 ? [] : _g,
17577
+ _h = _a.tagString,
17578
+ tagString = _h === void 0 ? "" : _h,
17579
+ // comma separated string which is created into separate tags
17580
+ _j = _a.handleValChange,
17581
+ // comma separated string which is created into separate tags
17582
+ handleValChange = _j === void 0 ? function (_) {} : _j,
17583
+ _k = _a.onDropdownClick,
17584
+ onDropdownClick = _k === void 0 ? function (_) {} : _k;
17585
+
17586
+ var _l = inputProps || {},
17587
+ disabled = _l.disabled,
17588
+ onFocus = _l.onFocus,
17589
+ onBlur = _l.onBlur;
17590
+
17591
+ var _m = useState(false),
17592
+ active = _m[0],
17593
+ setActive = _m[1];
17594
+
17595
+ var _o = useState(false),
17596
+ showDropdown = _o[0],
17597
+ setShowDropdown = _o[1];
17598
+
17599
+ var _p = useState(""),
17600
+ value = _p[0],
17601
+ setValue = _p[1]; // tag string
17602
+
17603
+
17604
+ var wrapperRef = useRef(null);
17605
+ var inputRef = useRef(null);
17606
+
17607
+ var _q = useState(),
17608
+ dropdownArr = _q[0],
17609
+ setDropdownArr = _q[1];
17610
+
17611
+ var _r = useState(""),
17612
+ tagInputValue = _r[0],
17613
+ setTagInputValue = _r[1]; // input field state
17614
+
17615
+
17616
+ var _s = useState(__spreadArray(__spreadArray([], tagList.filter(Boolean), true), tagString.split(",").filter(Boolean).map(function (item) {
17617
+ return item.trim();
17618
+ }), true)),
17619
+ tags = _s[0],
17620
+ setTags = _s[1]; // tag array
17621
+
17622
+
17623
+ var handleValueChange = function handleValueChange(e) {
17624
+ var sug = [];
17625
+ setShowDropdown(true);
17626
+
17627
+ if (options && options.length > 0) {
17628
+ sug = options === null || options === void 0 ? void 0 : options.filter(function (options) {
17629
+ return options.label.toLowerCase().includes(e.target.value.toLowerCase());
17630
+ });
17631
+ setDropdownArr(sug);
17632
+ }
17633
+
17634
+ setTagInputValue(e.target.value);
17635
+ };
17636
+
17637
+ var handleClickOutside = function handleClickOutside(e) {
17638
+ setDropdownArr(options);
17639
+
17640
+ if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
17641
+ setShowDropdown(false);
17642
+ }
17643
+ };
17644
+
17645
+ var handleDropdownClick = function handleDropdownClick(selectedItem) {
17646
+ setTags(function (prev) {
17647
+ return __spreadArray(__spreadArray([], prev, true), [selectedItem.value], false);
17648
+ });
17649
+ setValue(function (prev) {
17650
+ return prev + ", " + selectedItem.value;
17651
+ });
17652
+ setTagInputValue("");
17653
+ onDropdownClick && onDropdownClick(selectedItem);
17654
+ handleValChange && handleValChange(value);
17655
+ setShowDropdown(false);
17656
+ };
17657
+
17658
+ useEffect(function () {
17659
+ setValue(tagString);
17660
+ setTags(tagString.split(",").filter(Boolean).map(function (item) {
17661
+ return item.trim();
17662
+ }));
17663
+ }, [tagString]); // useEffect(() => {
17664
+ // let incomingTags=value.split("\\s*,\\s*");
17665
+ // incomingTags = incomingTags.filter(Boolean)
17666
+ // setTags(tagList)
17667
+ // }, [tagList]);
17668
+ // useEffect(() => {
17669
+ // let incomingTags=value.split("\\s*,\\s*");
17670
+ // incomingTags = incomingTags.filter(Boolean)
17671
+ // setTags(incomingTags)
17672
+ // }, [value]);
17673
+
17674
+ useEffect(function () {
17675
+ document.addEventListener("mousedown", handleClickOutside);
17676
+ return function () {
17677
+ document.removeEventListener("mousedown", handleClickOutside);
17678
+ };
17679
+ });
17680
+
17681
+ var handleFocus = function handleFocus(event) {
17682
+ setShowDropdown(true);
17683
+ setActive(true);
17684
+ onFocus && onFocus(event);
17685
+ };
17686
+
17687
+ var handleBlur = function handleBlur(event) {
17688
+ setShowDropdown(false);
17689
+ setActive(false);
17690
+ onBlur && onBlur(event);
17691
+ };
17692
+
17693
+ var addTags = function addTags(e) {
17694
+ if (e.keyCode === 13 && tagInputValue) {
17695
+ setTags(__spreadArray(__spreadArray([], tags, true), [tagInputValue], false));
17696
+ setValue(tags.filter(Boolean).join(", "));
17697
+ setTagInputValue("");
17698
+ }
17699
+
17700
+ handleValChange && handleValChange(value);
17701
+ };
17702
+
17703
+ var deleteTag = function deleteTag(_, del_index) {
17704
+ var remainingTags = tags.filter(function (_, index) {
17705
+ return del_index !== index;
17706
+ });
17707
+ setTags(remainingTags);
17708
+ setValue(tags.filter(Boolean).join(", "));
17709
+ };
17710
+
17711
+ var editTag = function editTag(item, index) {
17712
+ setTagInputValue(item);
17713
+ deleteTag(item, index);
17714
+ };
17715
+
17716
+ useEffect(function () {
17717
+ setValue(tags.filter(Boolean).join(", "));
17718
+ handleValChange && handleValChange(tags.filter(Boolean).join(", "));
17719
+ }, [tags]);
17720
+ return jsxRuntime.exports.jsxs("div", __assign({
17721
+ 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)
17722
+ }, {
17723
+ children: [tags.map(function (item, index) {
17724
+ return jsxRuntime.exports.jsxs("button", __assign({
17725
+ 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"
17726
+ }, {
17727
+ children: [jsxRuntime.exports.jsx(Typography, __assign({
17728
+ variant: "Semibold",
17729
+ type: "Text sm",
17730
+ className: "hplxt-text-Gray-600",
17731
+ onClick: function onClick() {
17732
+ return editTag(item, index);
17733
+ }
17734
+ }, {
17735
+ children: item
17736
+ })), jsxRuntime.exports.jsx("div", {
17737
+ className: "hx_close hplxt-text-[75%] hplxt-text-Primary-700",
17738
+ onClick: function onClick() {
17739
+ return deleteTag(item, index);
17740
+ }
17741
+ })]
17742
+ }), index);
17743
+ }), jsxRuntime.exports.jsx("input", __assign({
17744
+ type: "text",
17745
+ value: tagInputValue,
17746
+ ref: inputRef,
17747
+ className: "hplxt-flex-1 placeholder:hplxt-text-Gray-500 focus-visible:hplxt-outline-0 hplxt-border-0 focus:hplxt-border-0",
17748
+ placeholder: "Enter Text",
17749
+ onChange: function onChange(e) {
17750
+ setTagInputValue(e.target.value);
17751
+ handleValueChange(e);
17752
+ },
17753
+ onKeyDown: addTags
17754
+ }, inputProps, {
17755
+ onFocus: handleFocus,
17756
+ onBlur: handleBlur
17757
+ })), showDropdown && jsxRuntime.exports.jsx("div", __assign({
17758
+ ref: wrapperRef,
17759
+ 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),
17760
+ style: {
17761
+ left: "".concat((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.offsetLeft, "px"),
17762
+ 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")
17763
+ }
17764
+ }, {
17765
+ children: dropdownArr && dropdownArr.length > 0 && jsxRuntime.exports.jsx("div", {
17766
+ children: dropdownArr.map(function (option) {
17767
+ var restOptions = __rest(option || {}, []);
17768
+
17769
+ return jsxRuntime.exports.jsx(DropdownItems, __assign({
17770
+ className: "hplxt-text-Primary-700"
17771
+ }, restOptions, {
17772
+ onSelect: function onSelect() {
17773
+ return handleDropdownClick(restOptions);
17774
+ }
17775
+ }));
17776
+ })
17777
+ })
17778
+ }))]
17779
+ }));
17780
+ };
17781
+
17782
+ export { AddSuggestion, Avatar, Badge, BadgeGroup, Button, ButtonGroups, Card, Checkbox, CheckboxGroup, CheckboxGroupItem, CollapsibleCard, DatePicker, DoubleInput, DropdownField, DropdownItems as DropdownItem, InputField, InputFieldSplit, InputTag, MessageToast, NestedDropdown, OtpField, ProgressBar, ProgressCircle, RadioBtn, Slider, TextAreaField, ToggleSwitch, Tooltip, Typography };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { InputTagProps } from "../types";
3
+ declare const InputTag: ({ inputProps, className, dropdownClassName, options, tagList, tagString, handleValChange, onDropdownClick, }: InputTagProps) => JSX.Element;
4
+ export default InputTag;
@@ -416,4 +416,14 @@ export interface DoubleInputProps {
416
416
  hint_text_icon?: string;
417
417
  hint_text?: string;
418
418
  }
419
+ export interface InputTagProps {
420
+ className?: string;
421
+ tagList?: Array<string>;
422
+ tagString?: string;
423
+ dropdownClassName?: string;
424
+ onDropdownClick?: (value: any) => void;
425
+ options?: Array<DropdownItemsProps>;
426
+ inputProps?: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
427
+ handleValChange?: (value: any) => void;
428
+ }
419
429
  export {};
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "frontend",
10
10
  "healthplix"
11
11
  ],
12
- "version": "1.0.54",
12
+ "version": "1.0.56",
13
13
  "main": "dist/esm/index.js",
14
14
  "module": "dist/esm/index.js",
15
15
  "types": "dist/esm/index.d.ts",