react-core-ts 1.4.12 → 1.4.13
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/ReactAutoComplete.js +51 -51
- package/dist/ReactAutoComplete.js.map +1 -1
- package/dist/styles/styles/components/autocomplete.css +655 -0
- package/dist/styles/styles/components/selectedautocomplete.css +130 -0
- package/dist/styles/styles/components/tooltip.css +497 -0
- package/dist/styles/styles/components/treedropdown.css +97 -0
- package/dist/styles/styles/global.css +8 -0
- package/package.json +1 -1
- package/src/ReactAutoComplete.tsx +56 -55
package/package.json
CHANGED
|
@@ -363,53 +363,6 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
363
363
|
}
|
|
364
364
|
}, [dropOpen]);
|
|
365
365
|
|
|
366
|
-
// Handle keyboard navigation
|
|
367
|
-
const handleKeyDown = (e: any) => {
|
|
368
|
-
if (!dropOpen) return;
|
|
369
|
-
|
|
370
|
-
const atBottom = selectedIndex === filteredData.length - 1;
|
|
371
|
-
const atTop = selectedIndex === 0;
|
|
372
|
-
|
|
373
|
-
switch (e.key) {
|
|
374
|
-
case "ArrowDown":
|
|
375
|
-
e.preventDefault();
|
|
376
|
-
if (itemRefs.current && scrollContainerRef.current) {
|
|
377
|
-
if (!atBottom) {
|
|
378
|
-
scrollContainerRef.current.scrollTop += itemRefs.current[selectedIndex]?.offsetHeight || 50;
|
|
379
|
-
} else {
|
|
380
|
-
scrollContainerRef.current.scrollTop = 0;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
setSelectedIndex((prev) => (prev + 1) % filteredData?.length);
|
|
384
|
-
break;
|
|
385
|
-
|
|
386
|
-
case "ArrowUp":
|
|
387
|
-
e.preventDefault();
|
|
388
|
-
if (itemRefs.current && scrollContainerRef.current) {
|
|
389
|
-
if (!atTop) {
|
|
390
|
-
scrollContainerRef.current.scrollTop -= itemRefs.current[selectedIndex]?.offsetHeight || 50;
|
|
391
|
-
} else {
|
|
392
|
-
scrollContainerRef.current.scrollTop = 0;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
setSelectedIndex((prev) => (prev - 1 + filteredData?.length) % filteredData?.length);
|
|
396
|
-
break;
|
|
397
|
-
|
|
398
|
-
case "Enter":
|
|
399
|
-
e.preventDefault();
|
|
400
|
-
handleSuggestionClick(filteredData[selectedIndex], selectedIndex);
|
|
401
|
-
break;
|
|
402
|
-
|
|
403
|
-
case "Escape":
|
|
404
|
-
e.preventDefault();
|
|
405
|
-
setDropOpen(false);
|
|
406
|
-
break;
|
|
407
|
-
|
|
408
|
-
default:
|
|
409
|
-
break;
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
|
|
413
366
|
const handleClear = () => {
|
|
414
367
|
setDropOpen(false);
|
|
415
368
|
setInputValue('');
|
|
@@ -583,14 +536,62 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
583
536
|
return () => clearTimeout(timer);
|
|
584
537
|
} else {
|
|
585
538
|
setShowNoResults(false);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// Handle keyboard navigation
|
|
542
|
+
const handleKeyDown = (e: any) => {
|
|
543
|
+
if (!dropOpen) return;
|
|
544
|
+
|
|
545
|
+
const atBottom = selectedIndex === filteredData.length - 1;
|
|
546
|
+
const atTop = selectedIndex === 0;
|
|
547
|
+
|
|
548
|
+
switch (e.key) {
|
|
549
|
+
case "ArrowDown":
|
|
550
|
+
e.preventDefault();
|
|
551
|
+
if (itemRefs.current && scrollContainerRef.current) {
|
|
552
|
+
if (!atBottom) {
|
|
553
|
+
scrollContainerRef.current.scrollTop += itemRefs.current[selectedIndex]?.offsetHeight || 50;
|
|
554
|
+
} else {
|
|
555
|
+
scrollContainerRef.current.scrollTop = 0;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
setSelectedIndex((prev) => (prev + 1) % filteredData?.length);
|
|
559
|
+
break;
|
|
560
|
+
|
|
561
|
+
case "ArrowUp":
|
|
562
|
+
e.preventDefault();
|
|
563
|
+
if (itemRefs.current && scrollContainerRef.current) {
|
|
564
|
+
if (!atTop) {
|
|
565
|
+
scrollContainerRef.current.scrollTop -= itemRefs.current[selectedIndex]?.offsetHeight || 50;
|
|
566
|
+
} else {
|
|
567
|
+
scrollContainerRef.current.scrollTop = 0;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
setSelectedIndex((prev) => (prev - 1 + filteredData?.length) % filteredData?.length);
|
|
571
|
+
break;
|
|
572
|
+
|
|
573
|
+
case "Enter":
|
|
574
|
+
e.preventDefault();
|
|
575
|
+
handleSuggestionClick(filteredData[selectedIndex], selectedIndex);
|
|
576
|
+
break;
|
|
577
|
+
|
|
578
|
+
case "Escape":
|
|
579
|
+
e.preventDefault();
|
|
580
|
+
setDropOpen(false);
|
|
581
|
+
break;
|
|
582
|
+
|
|
583
|
+
default:
|
|
584
|
+
break;
|
|
591
585
|
}
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
if(filteredData?.length > 0 && !isLoading) {
|
|
589
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
590
|
+
return(() => {
|
|
591
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
592
|
+
})
|
|
592
593
|
}
|
|
593
|
-
}, [inputValue, filteredData, isLoading, timerRef.current]);
|
|
594
|
+
}, [inputValue, filteredData, isLoading, timerRef.current, selectedIndex]);
|
|
594
595
|
|
|
595
596
|
const setDropDown = () => {
|
|
596
597
|
return (
|
|
@@ -607,8 +608,8 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
607
608
|
className={`${
|
|
608
609
|
value?.id === suggestion?.id
|
|
609
610
|
? 'bg-blue-navy text-white'
|
|
610
|
-
:
|
|
611
|
-
}
|
|
611
|
+
: `${index === selectedIndex ? "is-selected" : ""} hover:bg-table-hover`
|
|
612
|
+
} cursor-pointer p-1 text-xxs ps-3.5 pl-[10px] qbs-autocomplete-suggections-items`}
|
|
612
613
|
key={suggestion?.id}
|
|
613
614
|
data-testid={suggestion.name}
|
|
614
615
|
onClick={() => handleSuggestionClick(suggestion, index)}
|