import { isElementType } from '../misc/isElementType' ; import { isContentEditable } from './isContentEditable' ; type GuardedType < T > = T extends ( x : any ) => x is infer R ? R : never ; export function isEditable ( element ) { return ( isEditableInput ( element ) || isElementType ( element , 'textarea' , { readOnly : false } ) || isContentEditable ( element ) ) ; } export enum editableInputTypes { 'text' = 'text' , 'date' = 'date' , 'datetime-local' = 'datetime-local' , 'email' = 'email' , 'month' = 'month' , 'number' = 'number' , 'password' = 'password' , 'search' = 'search' , 'tel' = 'tel' , 'time' = 'time' , 'url' = 'url' , 'week' = 'week' } export type EditableInputType = keyof typeof editableInputTypes ; export function isEditableInput ( element ) { return ( isElementType ( element , 'input' , { readOnly : false } ) && Boolean ( editableInputTypes [ element . type as editableInputTypes ] ) ) ; }