[READ-ONLY] a fast, modern browser for the npm registry
at main 30 lines 928 B view raw
1export const noCorrect = { 2 autocapitalize: 'off', 3 autocomplete: 'off', 4 autocorrect: 'off', 5 spellcheck: 'false', 6} as const 7 8/** 9 * Check if an event target is an editable element (input, textarea, or contenteditable). 10 * Useful for keyboard shortcut handlers that should not trigger when the user is typing. 11 */ 12export function isEditableElement(target: EventTarget | null): boolean { 13 if (!target || !(target instanceof HTMLElement)) return false 14 return target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable 15} 16 17/** 18 * Check if a keyboard event matches a specific key without any modifier keys. 19 */ 20export function isKeyWithoutModifiers(event: KeyboardEvent, key: string): boolean { 21 return ( 22 event.key?.toLowerCase() === key.toLowerCase() && 23 !event.altKey && 24 !event.ctrlKey && 25 !event.metaKey && 26 !event.shiftKey 27 ) 28} 29 30export const DATE_INPUT_MAX = '9999-12-31'