Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separator support #144

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ All of these props are optional and some also come with a default value. However
| passwordMode | Boolean | `false` | Hide the input value by displaying `*` instead. |
| inputProps | Object | `{}` | The properties of this object get forwarded as props to the input element. In particular, you can use this prop to assign an `id` attribute to the input field to connect it to a `label` element. Use `aria-label` for internationalization of the input field. |
| containerProps | Object | `{}` | The properties of this object get forwarded as props to the container element. |
| classNames | Object | `{}` | Object with CSS class names to add to the specified elements. Supported elements (= object-keys) are `container`, `character`, `characterInactive`, `characterSelected`, `characterFilled` |
| classNames | Object | `{}` | Object with CSS class names to add to the specified elements. Supported elements (= object-keys) are `container`, `character`, `characterInactive`, `characterSelected`, `characterFilled`, `separator` |
| separator | string | `'-'` | Text to use for separators between characters.
| separatorIndices | number[] | `[]` | Zero-based indices where separators should be placed. [2] will place a separator between the 3rd and 4th character.
| onChange | Function | - | Callback function that gets called with the string value whenever it changes. |
| onComplete | Function | - | Callback function that gets called with the string value when the input is fully filled. |
| onFocus | Function | - | Callback function that gets called when the component obtains focus. |
Expand All @@ -77,6 +79,7 @@ Style the input by passing it your custom class names like so:
characterInactive: "character--inactive",
characterSelected: "character--selected",
characterFilled: "character--filled",
separator: "separator",
}}
/>
```
Expand Down
9 changes: 9 additions & 0 deletions docs-src/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ Configure the input to accept 5 digits.

Use any character as placeholder (empty string for no placeholder).

## Custom separators

<br />

<VerificationInput separator=":" separatorIndices={[2]} />

Use any character as separator empty string for spacing only. Specify the indices
where separators should be placed.

```jsx copy
<VerificationInput placeholder="_" />
```
Expand Down
4 changes: 2 additions & 2 deletions docs/404.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: This page could not be found</title><meta name="next-head-count" content="3"/><link rel="preload" href="/react-verification-input/_next/static/css/dddea6f693da53a1.css" as="style"/><link rel="stylesheet" href="/react-verification-input/_next/static/css/dddea6f693da53a1.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/react-verification-input/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/react-verification-input/_next/static/chunks/webpack-a75dfb0dcf3ea940.js" defer=""></script><script src="/react-verification-input/_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="/react-verification-input/_next/static/chunks/main-b79e7c1db0d22be6.js" defer=""></script><script src="/react-verification-input/_next/static/chunks/pages/_app-00abc3efdcbf2bff.js" defer=""></script><script src="/react-verification-input/_next/static/chunks/pages/_error-8353112a01355ec2.js" defer=""></script><script src="/react-verification-input/_next/static/OehuEN9cU3ThEHkQkFzH0/_buildManifest.js" defer=""></script><script src="/react-verification-input/_next/static/OehuEN9cU3ThEHkQkFzH0/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:-apple-system, BlinkMacSystemFont, Roboto, &quot;Segoe UI&quot;, &quot;Fira Sans&quot;, Avenir, &quot;Helvetica Neue&quot;, &quot;Lucida Grande&quot;, sans-serif;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>
<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><title>404: This page could not be found</title><meta name="next-head-count" content="3"/><link rel="preload" href="/react-verification-input/_next/static/css/dddea6f693da53a1.css" as="style"/><link rel="stylesheet" href="/react-verification-input/_next/static/css/dddea6f693da53a1.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/react-verification-input/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="/react-verification-input/_next/static/chunks/webpack-a75dfb0dcf3ea940.js" defer=""></script><script src="/react-verification-input/_next/static/chunks/framework-2c79e2a64abdb08b.js" defer=""></script><script src="/react-verification-input/_next/static/chunks/main-b79e7c1db0d22be6.js" defer=""></script><script src="/react-verification-input/_next/static/chunks/pages/_app-00abc3efdcbf2bff.js" defer=""></script><script src="/react-verification-input/_next/static/chunks/pages/_error-8353112a01355ec2.js" defer=""></script><script src="/react-verification-input/_next/static/QT-zxZVqRpsocCGdM7mS6/_buildManifest.js" defer=""></script><script src="/react-verification-input/_next/static/QT-zxZVqRpsocCGdM7mS6/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:-apple-system, BlinkMacSystemFont, Roboto, &quot;Segoe UI&quot;, &quot;Fira Sans&quot;, Avenir, &quot;Helvetica Neue&quot;, &quot;Lucida Grande&quot;, sans-serif;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>
body { margin: 0; color: #000; background: #fff; }
.next-error-h1 {
border-right: 1px solid rgba(0, 0, 0, .3);
Expand All @@ -9,4 +9,4 @@
.next-error-h1 {
border-right: 1px solid rgba(255, 255, 255, .3);
}
}</style><h1 class="next-error-h1" style="display:inline-block;margin:0;margin-right:20px;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block;text-align:left;line-height:49px;height:49px;vertical-align:middle"><h2 style="font-size:14px;font-weight:normal;line-height:49px;margin:0;padding:0">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"OehuEN9cU3ThEHkQkFzH0","assetPrefix":"/react-verification-input","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
}</style><h1 class="next-error-h1" style="display:inline-block;margin:0;margin-right:20px;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block;text-align:left;line-height:49px;height:49px;vertical-align:middle"><h2 style="font-size:14px;font-weight:normal;line-height:49px;margin:0;padding:0">This page could not be found<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"QT-zxZVqRpsocCGdM7mS6","assetPrefix":"/react-verification-input","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
6 changes: 3 additions & 3 deletions docs/API.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/_next/static/OehuEN9cU3ThEHkQkFzH0/_buildManifest.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/_next/static/QT-zxZVqRpsocCGdM7mS6/_buildManifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading