mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-22 03:02:35 +00:00
35 lines
1,019 B
TypeScript
35 lines
1,019 B
TypeScript
import type {
|
|
SearchHistoryConfig,
|
|
SearchTipsConfig,
|
|
} from '@/components/shared/useSearchInputEnhancements';
|
|
|
|
export type SearchInputKeyboardEvent = KeyboardEvent & {
|
|
currentTarget: HTMLInputElement;
|
|
target: Element;
|
|
};
|
|
|
|
export interface SearchInputProps {
|
|
value: () => string;
|
|
onChange: (value: string) => void;
|
|
placeholder?: string;
|
|
title?: string;
|
|
history?: SearchHistoryConfig;
|
|
tips?: SearchTipsConfig;
|
|
inputRef?: (el: HTMLInputElement) => void;
|
|
class?: string;
|
|
inputClass?: string;
|
|
disabled?: boolean;
|
|
onKeyDown?: (event: SearchInputKeyboardEvent) => void;
|
|
typeToSearch?: boolean;
|
|
clearOnEscape?: boolean;
|
|
clearOnFocusedEscape?: boolean;
|
|
focusOnShortcut?: boolean;
|
|
captureBackspace?: boolean;
|
|
shortcutHint?: string;
|
|
onBeforeAutoFocus?: () => boolean;
|
|
}
|
|
|
|
export const getSearchInputShortcutHint = (isSimple: boolean, shortcutHint?: string) =>
|
|
isSimple ? shortcutHint : undefined;
|
|
|
|
export const shouldSearchInputShowTrailingControls = (isSimple: boolean) => !isSimple;
|