hplx-react-elements-dev 1.0.54 → 1.0.55
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.d.ts +1 -0
- package/dist/esm/index.js +228 -3
- package/dist/esm/inputTag/InputTag.d.ts +4 -0
- package/dist/esm/types.d.ts +10 -0
- package/package.json +1 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -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: {}};
|
|
@@ -17412,7 +17422,7 @@ var DoubleInput = function DoubleInput(_a) {
|
|
|
17412
17422
|
};
|
|
17413
17423
|
|
|
17414
17424
|
var handleDropdownClick = function handleDropdownClick(selectedItem) {
|
|
17415
|
-
|
|
17425
|
+
setValueChanged(false);
|
|
17416
17426
|
setValue(selectedItem.value);
|
|
17417
17427
|
onDropdownClick && onDropdownClick(selectedItem);
|
|
17418
17428
|
setShowDropdown(false);
|
|
@@ -17438,7 +17448,7 @@ var DoubleInput = function DoubleInput(_a) {
|
|
|
17438
17448
|
setSuffixValue(input2value);
|
|
17439
17449
|
}, [input2value]);
|
|
17440
17450
|
return jsxRuntime.exports.jsx("div", __assign({
|
|
17441
|
-
className: "
|
|
17451
|
+
className: "doubleInput hplxt-flex "
|
|
17442
17452
|
}, {
|
|
17443
17453
|
children: jsxRuntime.exports.jsxs(Typography, __assign({
|
|
17444
17454
|
variant: "Regular",
|
|
@@ -17551,4 +17561,219 @@ var DoubleInput = function DoubleInput(_a) {
|
|
|
17551
17561
|
}));
|
|
17552
17562
|
};
|
|
17553
17563
|
|
|
17554
|
-
|
|
17564
|
+
var InputTag = function InputTag(_a) {
|
|
17565
|
+
var _b, _c, _d, _e;
|
|
17566
|
+
|
|
17567
|
+
var inputProps = _a.inputProps,
|
|
17568
|
+
className = _a.className,
|
|
17569
|
+
dropdownClassName = _a.dropdownClassName,
|
|
17570
|
+
_f = _a.options,
|
|
17571
|
+
options = _f === void 0 ? [] : _f,
|
|
17572
|
+
_g = _a.tagList,
|
|
17573
|
+
tagList = _g === void 0 ? [] : _g,
|
|
17574
|
+
_h = _a.tagString,
|
|
17575
|
+
tagString = _h === void 0 ? "" : _h,
|
|
17576
|
+
// comma separated string which is created into separate tags
|
|
17577
|
+
_j = _a.handleValChange,
|
|
17578
|
+
// comma separated string which is created into separate tags
|
|
17579
|
+
handleValChange = _j === void 0 ? function (_) {} : _j,
|
|
17580
|
+
_k = _a.onDropdownClick,
|
|
17581
|
+
onDropdownClick = _k === void 0 ? function (_) {} : _k;
|
|
17582
|
+
|
|
17583
|
+
var _l = inputProps || {},
|
|
17584
|
+
disabled = _l.disabled,
|
|
17585
|
+
onFocus = _l.onFocus,
|
|
17586
|
+
onBlur = _l.onBlur;
|
|
17587
|
+
|
|
17588
|
+
var _m = useState(false),
|
|
17589
|
+
active = _m[0],
|
|
17590
|
+
setActive = _m[1];
|
|
17591
|
+
|
|
17592
|
+
var _o = useState(false),
|
|
17593
|
+
showDropdown = _o[0],
|
|
17594
|
+
setShowDropdown = _o[1];
|
|
17595
|
+
|
|
17596
|
+
var _p = useState(""),
|
|
17597
|
+
value = _p[0],
|
|
17598
|
+
setValue = _p[1]; // tag string
|
|
17599
|
+
|
|
17600
|
+
|
|
17601
|
+
var wrapperRef = useRef(null);
|
|
17602
|
+
var inputRef = useRef(null);
|
|
17603
|
+
|
|
17604
|
+
var _q = useState(),
|
|
17605
|
+
dropdownArr = _q[0],
|
|
17606
|
+
setDropdownArr = _q[1];
|
|
17607
|
+
|
|
17608
|
+
var _r = useState(""),
|
|
17609
|
+
tagInputValue = _r[0],
|
|
17610
|
+
setTagInputValue = _r[1]; // input field state
|
|
17611
|
+
|
|
17612
|
+
|
|
17613
|
+
var _s = useState(__spreadArray(__spreadArray([], tagList.filter(Boolean), true), tagString.split(",").filter(Boolean).map(function (item) {
|
|
17614
|
+
return item.trim();
|
|
17615
|
+
}), true)),
|
|
17616
|
+
tags = _s[0],
|
|
17617
|
+
setTags = _s[1]; // tag array
|
|
17618
|
+
|
|
17619
|
+
|
|
17620
|
+
var handleValueChange = function handleValueChange(e) {
|
|
17621
|
+
var sug = [];
|
|
17622
|
+
setShowDropdown(true);
|
|
17623
|
+
|
|
17624
|
+
if (options && options.length > 0) {
|
|
17625
|
+
sug = options === null || options === void 0 ? void 0 : options.filter(function (options) {
|
|
17626
|
+
return options.label.toLowerCase().includes(e.target.value.toLowerCase());
|
|
17627
|
+
});
|
|
17628
|
+
setDropdownArr(sug);
|
|
17629
|
+
}
|
|
17630
|
+
|
|
17631
|
+
setTagInputValue(e.target.value);
|
|
17632
|
+
};
|
|
17633
|
+
|
|
17634
|
+
var handleClickOutside = function handleClickOutside(e) {
|
|
17635
|
+
setDropdownArr(options);
|
|
17636
|
+
|
|
17637
|
+
if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
|
|
17638
|
+
setShowDropdown(false);
|
|
17639
|
+
}
|
|
17640
|
+
};
|
|
17641
|
+
|
|
17642
|
+
var handleDropdownClick = function handleDropdownClick(selectedItem) {
|
|
17643
|
+
setTags(function (prev) {
|
|
17644
|
+
return __spreadArray(__spreadArray([], prev, true), [selectedItem.value], false);
|
|
17645
|
+
});
|
|
17646
|
+
setValue(function (prev) {
|
|
17647
|
+
return prev + ", " + selectedItem.value;
|
|
17648
|
+
});
|
|
17649
|
+
setTagInputValue("");
|
|
17650
|
+
onDropdownClick && onDropdownClick(selectedItem);
|
|
17651
|
+
handleValChange && handleValChange(value);
|
|
17652
|
+
setShowDropdown(false);
|
|
17653
|
+
};
|
|
17654
|
+
|
|
17655
|
+
useEffect(function () {
|
|
17656
|
+
setValue(tagString);
|
|
17657
|
+
setTags(tagString.split(",").filter(Boolean).map(function (item) {
|
|
17658
|
+
return item.trim();
|
|
17659
|
+
}));
|
|
17660
|
+
}, [tagString]); // useEffect(() => {
|
|
17661
|
+
// let incomingTags=value.split("\\s*,\\s*");
|
|
17662
|
+
// incomingTags = incomingTags.filter(Boolean)
|
|
17663
|
+
// setTags(tagList)
|
|
17664
|
+
// }, [tagList]);
|
|
17665
|
+
// useEffect(() => {
|
|
17666
|
+
// let incomingTags=value.split("\\s*,\\s*");
|
|
17667
|
+
// incomingTags = incomingTags.filter(Boolean)
|
|
17668
|
+
// setTags(incomingTags)
|
|
17669
|
+
// }, [value]);
|
|
17670
|
+
|
|
17671
|
+
useEffect(function () {
|
|
17672
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
17673
|
+
return function () {
|
|
17674
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
17675
|
+
};
|
|
17676
|
+
});
|
|
17677
|
+
|
|
17678
|
+
var handleFocus = function handleFocus(event) {
|
|
17679
|
+
setShowDropdown(true);
|
|
17680
|
+
setActive(true);
|
|
17681
|
+
onFocus && onFocus(event);
|
|
17682
|
+
};
|
|
17683
|
+
|
|
17684
|
+
var handleBlur = function handleBlur(event) {
|
|
17685
|
+
setShowDropdown(false);
|
|
17686
|
+
setActive(false);
|
|
17687
|
+
onBlur && onBlur(event);
|
|
17688
|
+
};
|
|
17689
|
+
|
|
17690
|
+
var addTags = function addTags(e) {
|
|
17691
|
+
if (e.keyCode === 13 && tagInputValue) {
|
|
17692
|
+
setTags(__spreadArray(__spreadArray([], tags, true), [tagInputValue], false));
|
|
17693
|
+
setValue(tags.filter(Boolean).join(", "));
|
|
17694
|
+
setTagInputValue("");
|
|
17695
|
+
}
|
|
17696
|
+
|
|
17697
|
+
handleValChange && handleValChange(value);
|
|
17698
|
+
};
|
|
17699
|
+
|
|
17700
|
+
var deleteTag = function deleteTag(_, del_index) {
|
|
17701
|
+
var remainingTags = tags.filter(function (_, index) {
|
|
17702
|
+
return del_index !== index;
|
|
17703
|
+
});
|
|
17704
|
+
setTags(remainingTags);
|
|
17705
|
+
setValue(tags.filter(Boolean).join(", "));
|
|
17706
|
+
};
|
|
17707
|
+
|
|
17708
|
+
var editTag = function editTag(item, index) {
|
|
17709
|
+
setTagInputValue(item);
|
|
17710
|
+
deleteTag(item, index);
|
|
17711
|
+
};
|
|
17712
|
+
|
|
17713
|
+
useEffect(function () {
|
|
17714
|
+
setValue(tags.filter(Boolean).join(", "));
|
|
17715
|
+
handleValChange && handleValChange(tags.filter(Boolean).join(", "));
|
|
17716
|
+
}, [tags]);
|
|
17717
|
+
return jsxRuntime.exports.jsxs("div", __assign({
|
|
17718
|
+
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)
|
|
17719
|
+
}, {
|
|
17720
|
+
children: [tags.map(function (item, index) {
|
|
17721
|
+
return jsxRuntime.exports.jsxs("button", __assign({
|
|
17722
|
+
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"
|
|
17723
|
+
}, {
|
|
17724
|
+
children: [jsxRuntime.exports.jsx(Typography, __assign({
|
|
17725
|
+
variant: "Semibold",
|
|
17726
|
+
type: "Text sm",
|
|
17727
|
+
className: "hplxt-text-Gray-600",
|
|
17728
|
+
onClick: function onClick() {
|
|
17729
|
+
return editTag(item, index);
|
|
17730
|
+
}
|
|
17731
|
+
}, {
|
|
17732
|
+
children: item
|
|
17733
|
+
})), jsxRuntime.exports.jsx("div", {
|
|
17734
|
+
className: "hx_close hplxt-text-[75%] hplxt-text-Primary-700",
|
|
17735
|
+
onClick: function onClick() {
|
|
17736
|
+
return deleteTag(item, index);
|
|
17737
|
+
}
|
|
17738
|
+
})]
|
|
17739
|
+
}), index);
|
|
17740
|
+
}), jsxRuntime.exports.jsx("input", __assign({
|
|
17741
|
+
type: "text",
|
|
17742
|
+
value: tagInputValue,
|
|
17743
|
+
ref: inputRef,
|
|
17744
|
+
className: "hplxt-flex-1 placeholder:hplxt-text-Gray-500 focus-visible:hplxt-outline-0 hplxt-border-0 focus:hplxt-border-0",
|
|
17745
|
+
placeholder: "Enter Text",
|
|
17746
|
+
onChange: function onChange(e) {
|
|
17747
|
+
setTagInputValue(e.target.value);
|
|
17748
|
+
handleValueChange(e);
|
|
17749
|
+
},
|
|
17750
|
+
onKeyDown: addTags
|
|
17751
|
+
}, inputProps, {
|
|
17752
|
+
onFocus: handleFocus,
|
|
17753
|
+
onBlur: handleBlur
|
|
17754
|
+
})), showDropdown && jsxRuntime.exports.jsx("div", __assign({
|
|
17755
|
+
ref: wrapperRef,
|
|
17756
|
+
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),
|
|
17757
|
+
style: {
|
|
17758
|
+
left: "".concat((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.offsetLeft, "px"),
|
|
17759
|
+
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")
|
|
17760
|
+
}
|
|
17761
|
+
}, {
|
|
17762
|
+
children: dropdownArr && dropdownArr.length > 0 && jsxRuntime.exports.jsx("div", {
|
|
17763
|
+
children: dropdownArr.map(function (option) {
|
|
17764
|
+
var restOptions = __rest(option || {}, []);
|
|
17765
|
+
|
|
17766
|
+
return jsxRuntime.exports.jsx(DropdownItems, __assign({
|
|
17767
|
+
className: "hplxt-text-Primary-700"
|
|
17768
|
+
}, restOptions, {
|
|
17769
|
+
onSelect: function onSelect() {
|
|
17770
|
+
return handleDropdownClick(restOptions);
|
|
17771
|
+
}
|
|
17772
|
+
}));
|
|
17773
|
+
})
|
|
17774
|
+
})
|
|
17775
|
+
}))]
|
|
17776
|
+
}));
|
|
17777
|
+
};
|
|
17778
|
+
|
|
17779
|
+
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 };
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -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 {};
|