Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
terrylinooo committed Dec 3, 2023
1 parent 716f5b0 commit e98a843
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 3 deletions.
113 changes: 111 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,117 @@ new Disableautofill('#testForm', {
});
```

### Intergate with React

- [CodePen](https://codepen.io/terrylinooo/pen/bGzQBxR)

```javascript
import React, { useEffect, useRef } from 'react';
import Disableautofill from 'disableautofill';

const LoginFormComponent = () => {
const formRef = useRef(null);
let mainInstance = null;

useEffect(() => {
if (formRef.current) {
mainInstance = new Disableautofill(
formRef.current,
{
fields: [
'.test-pass',
'.test-pass2',
],
callback: () => {
return true;
}
}
);
}

return () => {
if (mainInstance) {
mainInstance.destroy();
}
};
}, []);

return (
<form ref={formRef}>
<div class="input-group">
<label>Username</label>
<input type="text" name="username" />
</div>
<div class="input-group">
<label>Password</label>
<input type="password" name="password" class="test-pass" />
</div>
<div class="input-group">
<label>Confirm password</label>
<input type="password" name="confirm_password" class="test-pass2" />
</div>
<div class="button-section">
<button type="submit">Submit</button>
</div>
</form>
);
};

export default LoginFormComponent;
```

### Intergrate with Vue

- [CodePen](https://codepen.io/terrylinooo/pen/BaMGpEq)

```javascript
import { onMounted, onUnmounted, ref, createApp } from 'vue';
import Disableautofill from 'disableautofill';

const App = {
setup() {
const formRef = ref(null);
let mainInstance = null;

onMounted(() => {
if (formRef.value) {
mainInstance = new Disableautofill(formRef.value, {
fields: ['.test-pass', '.test-pass2'],
callback: () => true
});
}
});

onUnmounted(() => {
if (mainInstance) {
mainInstance.destroy();
}
});

return { formRef };
},
template: `
<form ref="formRef">
<div class="input-group">
<label for="username">Username</label>
<input id="username" type="text" name="username" />
</div>
<div class="input-group">
<label for="password">Password</label>
<input id="password" type="password" name="password" class="test-pass" />
</div>
<div class="input-group">
<label for="confirmPassword">Confirm Password</label>
<input id="confirmPassword" type="password" name="confirm_password" class="test-pass2" />
</div>
<div class="button-section">
<button type="submit">Submit</button>
</div>
</form>
`
};
```

## Development

#### `npm run dev`
Expand Down Expand Up @@ -212,8 +323,6 @@ You will see the coverage report like this:

![](https://i.imgur.com/4vQxiB0.png)



### Using Docker

If Docker is your preferred choice, here's what you need to know.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "disableautofill",
"version": "4.0.0-rc.5",
"version": "4.0.0-rc.6",
"description": "The easiest solution for disabling Google Chrome auto-fill, auto-complete functions.",
"main": "dist/disableautofill.umd.js",
"module": "dist/disableautofill.es.js",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ declare global {
if (typeof window !== 'undefined') {
window.Disableautofill = Main;
}

export default Main;

0 comments on commit e98a843

Please sign in to comment.