+
{
+ onChange(e.target.value);
+ setCursor(0);
+ setOpen(true);
+ }}
+ onFocus={(e) => {
+ setOpen(true);
+ onFocus?.(e);
+ }}
+ onBlur={(e) => {
+ setOpen(false);
+ onBlur?.(e);
+ }}
+ onKeyDown={handleKeyDown}
+ autoComplete="off"
+ className={cn(
+ 'h-9 w-full rounded-[9px] border border-line bg-surface px-3.5 text-sm text-ink outline-none transition-colors placeholder:text-ink-4 focus:border-ink-2',
+ className,
+ )}
+ {...rest}
+ />
+ {showDropdown && (loading || items.length > 0 || showEmpty) && (
+
+ {loading && items.length === 0 && (
+ - Recherche…
+ )}
+ {!loading && showEmpty && (
+ - Aucun résultat
+ )}
+ {items.map((item, i) => {
+ const active = i === cursor;
+ return (
+ - {
+ e.preventDefault();
+ pick(item);
+ }}
+ className={cn(
+ 'cursor-pointer select-none px-3.5 py-2 text-[13px] transition-colors',
+ active ? 'bg-bg text-ink' : 'text-ink-2 hover:bg-bg',
+ )}
+ >
+ {renderItem ? renderItem(item, active) : getLabel(item)}
+
+ );
+ })}
+
+ )}
+
+ );
+}
diff --git a/frontend/src/lib/api/persons.ts b/frontend/src/lib/api/persons.ts
index f729361..7f58eb6 100644
--- a/frontend/src/lib/api/persons.ts
+++ b/frontend/src/lib/api/persons.ts
@@ -4,8 +4,19 @@ import type { Result } from '../../types/api';
export type PersonOrderBy = 'id' | 'firstName' | 'lastName' | 'startYear' | 'createdAt';
-export function getPersons(orderBy: PersonOrderBy = 'id'): Promise