hplx-react-elements-dev 1.0.90 → 1.0.91
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { AddSuggestionProps } from "../types";
|
|
3
|
-
declare const AddSuggestion: ({
|
|
3
|
+
declare const AddSuggestion: ({ label, handleSuggestionValChange, onSuggestionClick, className, rows, hint_text_icon, hint_text, errorMsg, inputProps, options, suggestionValue, isDynamicHeight, getInputValue, }: AddSuggestionProps) => JSX.Element;
|
|
4
4
|
export default AddSuggestion;
|
package/dist/esm/index.js
CHANGED
|
@@ -5435,87 +5435,71 @@ $$4({ target: 'String', proto: true, forced: forcedStringTrimMethod('trim') }, {
|
|
|
5435
5435
|
});
|
|
5436
5436
|
|
|
5437
5437
|
var AddSuggestion = function AddSuggestion(_a) {
|
|
5438
|
-
var
|
|
5439
|
-
|
|
5440
|
-
|
|
5441
|
-
|
|
5442
|
-
|
|
5443
|
-
_c = _a.start_icon,
|
|
5444
|
-
start_icon = _c === void 0 ? "" : _c,
|
|
5445
|
-
height = _a.height,
|
|
5446
|
-
width = _a.width,
|
|
5447
|
-
_d = _a.end_icon,
|
|
5448
|
-
end_icon = _d === void 0 ? "" : _d,
|
|
5449
|
-
prefix = _a.prefix,
|
|
5450
|
-
suffixButton = _a.suffixButton,
|
|
5451
|
-
suffix = _a.suffix,
|
|
5452
|
-
_e = _a.suffixDropdown,
|
|
5453
|
-
suffixDropdown = _e === void 0 ? [] : _e,
|
|
5454
|
-
_f = _a.isSuffixEditable,
|
|
5455
|
-
isSuffixEditable = _f === void 0 ? false : _f,
|
|
5456
|
-
suffixInputProps = _a.suffixInputProps,
|
|
5457
|
-
_g = _a.suffixPlaceholder,
|
|
5458
|
-
suffixPlaceholder = _g === void 0 ? "" : _g,
|
|
5459
|
-
_h = _a.handleSuggestionValChange,
|
|
5460
|
-
handleSuggestionValChange = _h === void 0 ? function (_) {} : _h,
|
|
5461
|
-
_j = _a.handleSuffixValChange,
|
|
5462
|
-
handleSuffixValChange = _j === void 0 ? function (_) {} : _j,
|
|
5463
|
-
_k = _a.handleSuffixClick,
|
|
5464
|
-
handleSuffixClick = _k === void 0 ? function (_) {} : _k,
|
|
5465
|
-
char_count = _a.char_count,
|
|
5466
|
-
_l = _a.onSuggestionClick,
|
|
5467
|
-
onSuggestionClick = _l === void 0 ? function (_selectedValue) {} : _l,
|
|
5438
|
+
var label = _a.label,
|
|
5439
|
+
_b = _a.handleSuggestionValChange,
|
|
5440
|
+
handleSuggestionValChange = _b === void 0 ? function (_) {} : _b,
|
|
5441
|
+
_c = _a.onSuggestionClick,
|
|
5442
|
+
onSuggestionClick = _c === void 0 ? function (_selectedValue) {} : _c,
|
|
5468
5443
|
className = _a.className,
|
|
5469
|
-
|
|
5470
|
-
rows =
|
|
5471
|
-
|
|
5472
|
-
hint_text_icon =
|
|
5444
|
+
_d = _a.rows,
|
|
5445
|
+
rows = _d === void 0 ? 2 : _d,
|
|
5446
|
+
_e = _a.hint_text_icon,
|
|
5447
|
+
hint_text_icon = _e === void 0 ? "" : _e,
|
|
5473
5448
|
hint_text = _a.hint_text,
|
|
5474
|
-
|
|
5475
|
-
errorMsg =
|
|
5449
|
+
_f = _a.errorMsg,
|
|
5450
|
+
errorMsg = _f === void 0 ? "" : _f,
|
|
5476
5451
|
inputProps = _a.inputProps,
|
|
5477
|
-
inputFieldInputProps = _a.inputFieldInputProps,
|
|
5478
5452
|
options = _a.options,
|
|
5479
|
-
|
|
5480
|
-
suggestionValue =
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
isDynamicHeight = _s === void 0 ? false : _s,
|
|
5485
|
-
fieldColor = _a.fieldColor,
|
|
5486
|
-
suffixClassName = _a.suffixClassName;
|
|
5453
|
+
_g = _a.suggestionValue,
|
|
5454
|
+
suggestionValue = _g === void 0 ? "" : _g,
|
|
5455
|
+
_h = _a.isDynamicHeight,
|
|
5456
|
+
isDynamicHeight = _h === void 0 ? false : _h,
|
|
5457
|
+
getInputValue = _a.getInputValue;
|
|
5487
5458
|
|
|
5488
|
-
var
|
|
5489
|
-
showDropdown =
|
|
5490
|
-
setShowDropdown =
|
|
5459
|
+
var _j = useState(false),
|
|
5460
|
+
showDropdown = _j[0],
|
|
5461
|
+
setShowDropdown = _j[1];
|
|
5491
5462
|
|
|
5492
5463
|
var wrapperRef = useRef(null);
|
|
5493
5464
|
|
|
5494
|
-
var
|
|
5495
|
-
suggestionArr =
|
|
5496
|
-
setSuggestionArr =
|
|
5465
|
+
var _k = useState(),
|
|
5466
|
+
suggestionArr = _k[0],
|
|
5467
|
+
setSuggestionArr = _k[1];
|
|
5497
5468
|
|
|
5498
|
-
var
|
|
5499
|
-
sugVal =
|
|
5500
|
-
setSugVal =
|
|
5469
|
+
var _l = useState(""),
|
|
5470
|
+
sugVal = _l[0],
|
|
5471
|
+
setSugVal = _l[1];
|
|
5472
|
+
|
|
5473
|
+
var suggestionText = function suggestionText(text) {
|
|
5474
|
+
// Find the last occurrence of comma, period, or newline
|
|
5475
|
+
var lastCommaIndex = text.lastIndexOf(",");
|
|
5476
|
+
var lastPeriodIndex = text.lastIndexOf(".");
|
|
5477
|
+
var lastNewlineIndex = text.lastIndexOf("\n"); // Get the maximum index among the three
|
|
5478
|
+
|
|
5479
|
+
var lastIndex = Math.max(lastCommaIndex, lastPeriodIndex, lastNewlineIndex); // Split the string based on the last index
|
|
5480
|
+
|
|
5481
|
+
var firstPart = text.slice(0, lastIndex + 1).trim();
|
|
5482
|
+
var secondPart = text.slice(lastIndex + 1).trim();
|
|
5483
|
+
return [firstPart, secondPart];
|
|
5484
|
+
};
|
|
5501
5485
|
|
|
5502
5486
|
var changeHandler = function changeHandler(e) {
|
|
5487
|
+
setSugVal(e.target.value);
|
|
5503
5488
|
var sug = [];
|
|
5504
5489
|
setShowDropdown(true);
|
|
5505
5490
|
|
|
5506
5491
|
if (options && options.length > 0) {
|
|
5507
5492
|
sug = options === null || options === void 0 ? void 0 : options.filter(function (options) {
|
|
5508
|
-
return options.label.toLowerCase().includes(e.target.value
|
|
5509
|
-
} // last keyboad input after ,
|
|
5493
|
+
return options.label.toLowerCase().includes(suggestionText(e.target.value)[1].toLowerCase());
|
|
5494
|
+
} // last keyboad input after , . or \n
|
|
5510
5495
|
);
|
|
5511
5496
|
setSuggestionArr(sug);
|
|
5512
|
-
}
|
|
5497
|
+
} // if (sug.length === 0 || e.target.value.length === 0) {
|
|
5513
5498
|
|
|
5514
|
-
setSugVal(e.target.value);
|
|
5515
5499
|
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5500
|
+
handleSuggestionValChange && handleSuggestionValChange(e.target.value); // }
|
|
5501
|
+
|
|
5502
|
+
getInputValue && getInputValue(suggestionText(e.target.value)[1].toLowerCase());
|
|
5519
5503
|
};
|
|
5520
5504
|
|
|
5521
5505
|
useEffect(function () {
|
|
@@ -5533,29 +5517,31 @@ var AddSuggestion = function AddSuggestion(_a) {
|
|
|
5533
5517
|
if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
|
|
5534
5518
|
setShowDropdown(false);
|
|
5535
5519
|
}
|
|
5536
|
-
};
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5520
|
+
}; // const checkComma = (val: string) => {
|
|
5521
|
+
// const lastEle = val.trim().charAt(sugVal.length - 1);
|
|
5522
|
+
// if (lastEle === "," || lastEle === "." || lastEle === "\n") {
|
|
5523
|
+
// return " ";
|
|
5524
|
+
// } else {
|
|
5525
|
+
// return ", ";
|
|
5526
|
+
// }
|
|
5527
|
+
// };
|
|
5540
5528
|
|
|
5541
|
-
if (lastEle === ",") {
|
|
5542
|
-
return " ";
|
|
5543
|
-
} else {
|
|
5544
|
-
return ", ";
|
|
5545
|
-
}
|
|
5546
|
-
};
|
|
5547
5529
|
|
|
5548
5530
|
var handleSuggestionClick = function handleSuggestionClick(selectedItem) {
|
|
5549
|
-
var val = selectedItem.
|
|
5531
|
+
var val = selectedItem.value + ", ";
|
|
5550
5532
|
var result = "";
|
|
5551
5533
|
|
|
5552
5534
|
if (suggestionValue === null || suggestionValue === void 0 ? void 0 : suggestionValue.length) {
|
|
5553
|
-
suggestionValue = suggestionValue.slice(
|
|
5554
|
-
|
|
5555
|
-
//
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5535
|
+
// suggestionValue = suggestionValue.slice(
|
|
5536
|
+
// 0,
|
|
5537
|
+
// suggestionValue.lastIndexOf(",")
|
|
5538
|
+
// );
|
|
5539
|
+
// const debris = suggestionValue.trim().split(", "); //explode string into array of strings indexed by /, |. |\s /
|
|
5540
|
+
// // debris.pop(); //pop last element off the array (which we didn't want)
|
|
5541
|
+
// result = debris.join(", ");
|
|
5542
|
+
// suggestionText(suggestionValue[0])
|
|
5543
|
+
result = suggestionText(suggestionValue)[0].trim();
|
|
5544
|
+
val = result + " " + selectedItem.value + ", ";
|
|
5559
5545
|
}
|
|
5560
5546
|
|
|
5561
5547
|
handleSuggestionValChange && handleSuggestionValChange(val);
|
|
@@ -5579,38 +5565,7 @@ var AddSuggestion = function AddSuggestion(_a) {
|
|
|
5579
5565
|
return jsxRuntime.exports.jsxs("div", __assign({
|
|
5580
5566
|
className: "input__wrapper hplxt-relative"
|
|
5581
5567
|
}, {
|
|
5582
|
-
children: [
|
|
5583
|
-
label: label,
|
|
5584
|
-
labelColor: labelColor,
|
|
5585
|
-
labelSize: labelSize,
|
|
5586
|
-
start_icon: start_icon,
|
|
5587
|
-
width: width,
|
|
5588
|
-
height: height,
|
|
5589
|
-
end_icon: end_icon,
|
|
5590
|
-
prefix: prefix,
|
|
5591
|
-
suffixButton: suffixButton,
|
|
5592
|
-
suffix: suffix,
|
|
5593
|
-
suffixDropdown: suffixDropdown,
|
|
5594
|
-
handleSuffixClick: handleSuffixClick,
|
|
5595
|
-
handleSuffixValChange: handleSuffixValChange,
|
|
5596
|
-
char_count: char_count,
|
|
5597
|
-
hint_text: hint_text,
|
|
5598
|
-
hint_text_icon: hint_text_icon,
|
|
5599
|
-
errorMsg: errorMsg,
|
|
5600
|
-
fieldColor: fieldColor,
|
|
5601
|
-
suffixPlaceholder: suffixPlaceholder,
|
|
5602
|
-
isborderRequired: isborderRequired,
|
|
5603
|
-
isSuffixEditable: isSuffixEditable,
|
|
5604
|
-
suffixInputProps: suffixInputProps,
|
|
5605
|
-
suffixClassName: suffixClassName,
|
|
5606
|
-
inputProps: __assign(__assign({}, inputFieldInputProps), {
|
|
5607
|
-
onChange: changeHandler,
|
|
5608
|
-
value: sugVal,
|
|
5609
|
-
onFocus: function onFocus() {
|
|
5610
|
-
return setShowDropdown(true);
|
|
5611
|
-
}
|
|
5612
|
-
})
|
|
5613
|
-
}) : jsxRuntime.exports.jsx(TextAreaField, {
|
|
5568
|
+
children: [jsxRuntime.exports.jsx(TextAreaField, {
|
|
5614
5569
|
label: label,
|
|
5615
5570
|
hint_text: hint_text,
|
|
5616
5571
|
hint_text_icon: hint_text_icon,
|
|
@@ -5623,6 +5578,9 @@ var AddSuggestion = function AddSuggestion(_a) {
|
|
|
5623
5578
|
value: sugVal,
|
|
5624
5579
|
onFocus: function onFocus() {
|
|
5625
5580
|
return setShowDropdown(true);
|
|
5581
|
+
},
|
|
5582
|
+
onKeyDown: function onKeyDown(e) {
|
|
5583
|
+
if (e.code === "Enter" || e.code === "Period" || e.code === "Comma") setShowDropdown(true);
|
|
5626
5584
|
}
|
|
5627
5585
|
})
|
|
5628
5586
|
}), showDropdown && jsxRuntime.exports.jsx("div", __assign({
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -401,6 +401,7 @@ export interface AddSuggestionProps {
|
|
|
401
401
|
handleSuggestionValChange?: (value: any) => void;
|
|
402
402
|
handleSuffixValChange?: (value: any) => void;
|
|
403
403
|
isborderRequired?: boolean;
|
|
404
|
+
getInputValue?: (value: string) => void;
|
|
404
405
|
}
|
|
405
406
|
export interface DoubleInputProps {
|
|
406
407
|
label?: string;
|