Form autofill for React and Electron
Usage
Electron
const {
FORM_AUTOFILL_FETCH_CREDENTIALS,
FORM_AUTOFILL_REQUEST_CREDENTIALS,
FORM_AUTOFILL_STORE_CREDENTIALS,
} = require('library/electron/constants');
const {requestCredentials} = require('library/electron/ProviderSafeStorage');
ipcMain.on(FORM_AUTOFILL_REQUEST_CREDENTIALS, requestCredentials(browserWindow, safeStorage));
React
const suggestions = {
'authentication': [
{
label: 'john@gmail.com',
form: {
username: 'john@gmail.com',
password: '12341234',
},
},
...
],
};
const handleSubmit = () => {
const inputValue = 'john@gmail.com';
const findBy = {key: 'username', value: 'john@gmail.com'};
const label = 'john@gmail.com';
FormDelegate.setDropdownSuggestion({formName: 'authentication', inputName: 'username'}, inputValue, findBy, label);
}
const AuthorizationForm = () => (
<FormWrapper name="authentication">
<form onSubmit={handleSubmit}>
<InputWrapper>
<TextInput name="username" placeholder="username" />
</InputWrapper>
<InputWrapper>
<TextInput name="password" placeholder="password" />
</InputWrapper>
</form>
</FormWrapper>
);