maz-ui
Version:
A standalone components library for Vue.Js 3 & Nuxt.Js 3
17 lines (16 loc) • 757 B
TypeScript
type AutofillableField = HTMLInputElement | HTMLTextAreaElement;
/**
* Detects browser autofill on an input or textarea and syncs the value.
*
* Browsers do not fire the `input` event when autofilling, so v-model stays
* out of sync with the DOM (empty state, label does not float, value cleared
* on next re-render). This attaches a CSS animation on `:-webkit-autofill` /
* `:autofill` and listens to `animationstart` to detect autofill and emit
* the value.
*
* @param field The input or textarea element to watch
* @param onSync Callback invoked with the autofilled value
* @returns Cleanup function to stop watching
*/
export declare function onAutofillSync(field: AutofillableField, onSync: (value: string) => void): () => void;
export {};