fix
This commit is contained in:
parent
61392ac245
commit
6054f6dd9d
|
|
@ -18,6 +18,7 @@ export const TypeaheadOptions: FC<{
|
||||||
}) => boolean;
|
}) => boolean;
|
||||||
onSelect?: (value: string) => void;
|
onSelect?: (value: string) => void;
|
||||||
searching?: boolean;
|
searching?: boolean;
|
||||||
|
searchText?: string;
|
||||||
width?: number;
|
width?: number;
|
||||||
}> = ({
|
}> = ({
|
||||||
popup,
|
popup,
|
||||||
|
|
@ -29,6 +30,7 @@ export const TypeaheadOptions: FC<{
|
||||||
selected,
|
selected,
|
||||||
onSelect,
|
onSelect,
|
||||||
searching,
|
searching,
|
||||||
|
searchText,
|
||||||
showEmpty,
|
showEmpty,
|
||||||
width,
|
width,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
@ -87,7 +89,22 @@ export const TypeaheadOptions: FC<{
|
||||||
<>
|
<>
|
||||||
{options.length === 0 && (
|
{options.length === 0 && (
|
||||||
<div className="c-p-4 c-w-full c-text-center c-text-sm c-text-slate-400">
|
<div className="c-p-4 c-w-full c-text-center c-text-sm c-text-slate-400">
|
||||||
— Empty —
|
{!searchText ? (
|
||||||
|
<>— Empty —</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
Search
|
||||||
|
<span
|
||||||
|
className={css`
|
||||||
|
font-style: italic;
|
||||||
|
padding: 0px 5px;
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
"{searchText}"
|
||||||
|
</span>
|
||||||
|
not found
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,8 @@ export const Typeahead: FC<{
|
||||||
local.open = true;
|
local.open = true;
|
||||||
if (e.key === "ArrowDown") {
|
if (e.key === "ArrowDown") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
const idx = options.findIndex((item) => {
|
const idx = options.findIndex((item) => {
|
||||||
if (item.value === local.select?.value) return true;
|
if (item.value === local.select?.value) return true;
|
||||||
});
|
});
|
||||||
|
|
@ -229,6 +231,7 @@ export const Typeahead: FC<{
|
||||||
}
|
}
|
||||||
if (e.key === "ArrowUp") {
|
if (e.key === "ArrowUp") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
const idx = options.findIndex((item) => {
|
const idx = options.findIndex((item) => {
|
||||||
if (item.value === local.select?.value) return true;
|
if (item.value === local.select?.value) return true;
|
||||||
|
|
@ -392,6 +395,7 @@ export const Typeahead: FC<{
|
||||||
open={local.open}
|
open={local.open}
|
||||||
options={options}
|
options={options}
|
||||||
searching={local.search.searching}
|
searching={local.search.searching}
|
||||||
|
searchText={local.search.input}
|
||||||
onSelect={(value) => {
|
onSelect={(value) => {
|
||||||
local.open = false;
|
local.open = false;
|
||||||
resetSearch();
|
resetSearch();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue