0?u:["plain"],e=c):(u=J(u,c.type),c.alias&&(u=J(u,c.alias)),e=c.content),"string"!=typeof e){i++,t.push(u),n.push(e),r.push(0),o.push(e.length);continue}const d=e.split(Z),p=d.length;l.push({types:u,content:d[0]});for(let t=1;t{const a=t.toLowerCase(),i=((e,t)=>{const[n,r]=(0,c.useState)(Y(t,e)),o=(0,c.useRef)(),a=(0,c.useRef)();return(0,c.useEffect)((()=>{t===o.current&&e===a.current||(o.current=t,a.current=e,r(Y(t,e)))}),[e,t]),n})(a,r),l=(e=>(0,c.useCallback)((t=>{var n=t,{className:r,style:o,line:a}=n,i=_(n,["className","style","line"]);const l=E(S({},i),{className:(0,d.A)("token-line",r)});return"object"==typeof e&&"plain"in e&&(l.style=e.plain),"object"==typeof o&&(l.style=S(S({},l.style||{}),o)),l}),[e]))(i),s=(e=>{const t=(0,c.useCallback)((({types:t,empty:n})=>{if(null!=e)return 1===t.length&&"plain"===t[0]?null!=n?{display:"inline-block"}:void 0:1===t.length&&null!=n?e[t[0]]:Object.assign(null!=n?{display:"inline-block"}:{},...t.map((t=>e[t])))}),[e]);return(0,c.useCallback)((e=>{var n=e,{token:r,className:o,style:a}=n,i=_(n,["token","className","style"]);const l=E(S({},i),{className:(0,d.A)("token",...r.types,o),children:r.content,style:t(r)});return null!=a&&(l.style=S(S({},l.style||{}),a)),l}),[t])})(i),u=(({prism:e,code:t,grammar:n,language:r})=>{const o=(0,c.useRef)(e);return(0,c.useMemo)((()=>{if(null==n)return ee([t]);const e={code:t,grammar:n,language:r,tokens:[]};return o.current.hooks.run("before-tokenize",e),e.tokens=o.current.tokenize(t,n),o.current.hooks.run("after-tokenize",e),ee(e.tokens)}),[t,n,r])})({prism:o,language:a,code:n,grammar:o.languages[a]});return e({tokens:u,className:`prism-code language-${a}`,style:null!=i?i.root:{},getLineProps:l,getTokenProps:s})},ne=e=>(0,c.createElement)(te,E(S({},e),{prism:e.prism||A,theme:e.theme||U,code:e.code,language:e.language}))},8635:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=!0,o="Invariant failed";function a(e,t){if(!e){if(r)throw new Error(o);var n="function"==typeof t?t():t,a=n?"".concat(o,": ").concat(n):o;throw new Error(a)}}},7314:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__addDisposableResource:()=>O,__assign:()=>a,__asyncDelegator:()=>_,__asyncGenerator:()=>E,__asyncValues:()=>C,__await:()=>S,__awaiter:()=>m,__classPrivateFieldGet:()=>P,__classPrivateFieldIn:()=>L,__classPrivateFieldSet:()=>R,__createBinding:()=>g,__decorate:()=>l,__disposeResources:()=>I,__esDecorate:()=>u,__exportStar:()=>y,__extends:()=>o,__generator:()=>h,__importDefault:()=>N,__importStar:()=>j,__makeTemplateObject:()=>A,__metadata:()=>f,__param:()=>s,__propKey:()=>d,__read:()=>v,__rest:()=>i,__runInitializers:()=>c,__setFunctionName:()=>p,__spread:()=>w,__spreadArray:()=>x,__spreadArrays:()=>k,__values:()=>b,default:()=>M});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)};function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=0;l--)(o=e[l])&&(i=(a<3?o(i):a>3?o(t,n,i):o(t,n))||i);return a>3&&i&&Object.defineProperty(t,n,i),i}function s(e,t){return function(n,r){t(n,r,e)}}function u(e,t,n,r,o,a){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var l,s=r.kind,u="getter"===s?"get":"setter"===s?"set":"value",c=!t&&e?r.static?e:e.prototype:null,d=t||(c?Object.getOwnPropertyDescriptor(c,r.name):{}),p=!1,f=n.length-1;f>=0;f--){var m={};for(var h in r)m[h]="access"===h?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(i(e||null))};var g=(0,n[f])("accessor"===s?{get:d.get,set:d.set}:d[u],m);if("accessor"===s){if(void 0===g)continue;if(null===g||"object"!=typeof g)throw new TypeError("Object expected");(l=i(g.get))&&(d.get=l),(l=i(g.set))&&(d.set=l),(l=i(g.init))&&o.unshift(l)}else(l=i(g))&&("field"===s?o.unshift(l):d[u]=l)}c&&Object.defineProperty(c,r.name,d),p=!0}function c(e,t,n){for(var r=arguments.length>2,o=0;o0&&o[o.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(l){o={error:l}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}function w(){for(var e=[],t=0;t1||l(e,t)}))},t&&(r[e]=t(r[e])))}function l(e,t){try{(n=o[e](t)).value instanceof S?Promise.resolve(n.value.v).then(s,u):c(a[0][2],n)}catch(r){c(a[0][3],r)}var n}function s(e){l("next",e)}function u(e){l("throw",e)}function c(e,t){e(t),a.shift(),a.length&&l(a[0][0],a[0][1])}}function _(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:S(e[r](t)),done:!1}:o?o(t):t}:o}}function C(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=b(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}function A(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var T=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function j(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&g(t,e,n);return T(t,e),t}function N(e){return e&&e.__esModule?e:{default:e}}function P(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}function R(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?o.call(e,n):o?o.value=n:t.set(e,n),n}function L(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function O(e,t,n){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var r,o;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");r=t[Symbol.asyncDispose]}if(void 0===r){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");r=t[Symbol.dispose],n&&(o=r)}if("function"!=typeof r)throw new TypeError("Object not disposable.");o&&(r=function(){try{o.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}var D="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var r=new Error(n);return r.name="SuppressedError",r.error=e,r.suppressed=t,r};function I(e){function t(t){e.error=e.hasError?new D(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var n,r=0;return function o(){for(;n=e.stack.pop();)try{if(!n.async&&1===r)return r=0,e.stack.push(n),Promise.resolve().then(o);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(o,(function(e){return t(e),o()}))}else r|=1}catch(i){t(i)}if(1===r)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}const M={__extends:o,__assign:a,__rest:i,__decorate:l,__param:s,__metadata:f,__awaiter:m,__generator:h,__createBinding:g,__exportStar:y,__values:b,__read:v,__spread:w,__spreadArrays:k,__spreadArray:x,__await:S,__asyncGenerator:E,__asyncDelegator:_,__asyncValues:C,__makeTemplateObject:A,__importStar:j,__importDefault:N,__classPrivateFieldGet:P,__classPrivateFieldSet:R,__classPrivateFieldIn:L,__addDisposableResource:O,__disposeResources:I}},2654:e=>{"use strict";e.exports={}},4054:e=>{"use strict";e.exports=JSON.parse('{"/mui-otp-input/docs/-ad9":{"__comp":"5e95c892","__context":{"plugin":"aba21aa0"}},"/mui-otp-input/docs/-d88":{"__comp":"a7bd4aaa","__props":"d1c6cb73"},"/mui-otp-input/docs/-fdd":{"__comp":"a94703ab"},"/mui-otp-input/docs/api-reference/-49f":{"__comp":"17896441","content":"964ae018"},"/mui-otp-input/docs/css/-e0c":{"__comp":"17896441","content":"3492c3da"},"/mui-otp-input/docs/getting-started/-723":{"__comp":"17896441","content":"d589d3a7"},"/mui-otp-input/docs/inheritance/-c53":{"__comp":"17896441","content":"57349a88"},"/mui-otp-input/docs/playground/-cf7":{"__comp":"17896441","content":"a679ac6c"},"/mui-otp-input/docs/react-hook-form/-acd":{"__comp":"17896441","content":"300eb1d2"},"/mui-otp-input/docs/typescript/-3a6":{"__comp":"17896441","content":"1be6b01a"},"/mui-otp-input/-247":{"__comp":"1df93b7f","__context":{"plugin":"a7456010"},"config":"5e9f5e1a"}}')}},e=>{e.O(0,[869],(()=>{return t=5996,e(e.s=t);var t}));e.O()}]);
\ No newline at end of file
diff --git a/assets/js/main.5139a195.js.LICENSE.txt b/assets/js/main.5139a195.js.LICENSE.txt
new file mode 100644
index 0000000..91dc894
--- /dev/null
+++ b/assets/js/main.5139a195.js.LICENSE.txt
@@ -0,0 +1,64 @@
+/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
+ * @license MIT */
+
+/*! Bundled license information:
+
+prismjs/prism.js:
+ (**
+ * Prism: Lightweight, robust, elegant syntax highlighting
+ *
+ * @license MIT
+ * @author Lea Verou
+ * @namespace
+ * @public
+ *)
+*/
+
+/**
+ * @license React
+ * react-dom.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/**
+ * @license React
+ * react-jsx-runtime.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/**
+ * @license React
+ * react.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/**
+ * @license React
+ * scheduler.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+/** @license React v16.13.1
+ * react-is.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
diff --git a/assets/js/runtime~main.397ab6d3.js b/assets/js/runtime~main.397ab6d3.js
new file mode 100644
index 0000000..0bd1f08
--- /dev/null
+++ b/assets/js/runtime~main.397ab6d3.js
@@ -0,0 +1 @@
+(()=>{"use strict";var e,t,r,a,o,n={},i={};function d(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={id:e,loaded:!1,exports:{}};return n[e].call(r.exports,r,r.exports,d),r.loaded=!0,r.exports}d.m=n,d.c=i,e=[],d.O=(t,r,a,o)=>{if(!r){var n=1/0;for(f=0;f=o)&&Object.keys(d.O).every((e=>d.O[e](r[c])))?r.splice(c--,1):(i=!1,o0&&e[f-1][2]>o;f--)e[f]=e[f-1];e[f]=[r,a,o]},d.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return d.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,d.t=function(e,a){if(1&a&&(e=this(e)),8&a)return e;if("object"==typeof e&&e){if(4&a&&e.__esModule)return e;if(16&a&&"function"==typeof e.then)return e}var o=Object.create(null);d.r(o);var n={};t=t||[null,r({}),r([]),r(r)];for(var i=2&a&&e;"object"==typeof i&&!~t.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach((t=>n[t]=()=>e[t]));return n.default=()=>e,d.d(o,n),o},d.d=(e,t)=>{for(var r in t)d.o(t,r)&&!d.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},d.f={},d.e=e=>Promise.all(Object.keys(d.f).reduce(((t,r)=>(d.f[r](e,t),t)),[])),d.u=e=>"assets/js/"+({48:"a94703ab",98:"a7bd4aaa",103:"1be6b01a",120:"3492c3da",235:"a7456010",401:"17896441",443:"964ae018",552:"57349a88",583:"1df93b7f",647:"5e95c892",671:"a679ac6c",742:"aba21aa0",800:"d1c6cb73",924:"d589d3a7",986:"300eb1d2"}[e]||e)+"."+{48:"9c104c47",98:"e9affd5f",103:"da85d5fd",120:"9cb29e91",235:"39c3a440",401:"4135c634",443:"e9c51289",546:"872999a5",552:"5ab44a23",583:"3d68612e",647:"fa7172f7",671:"d8fcf160",742:"722c82ed",800:"406b235d",812:"99102006",924:"219aeb32",986:"1c26037f"}[e]+".js",d.miniCssF=e=>{},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},o="mui-one-time-password-input-docs:",d.l=(e,t,r,n)=>{if(a[e])a[e].push(t);else{var i,c;if(void 0!==r)for(var u=document.getElementsByTagName("script"),f=0;f{i.onerror=i.onload=null,clearTimeout(b);var o=a[e];if(delete a[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach((e=>e(r))),t)return t(r)},b=setTimeout(l.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=l.bind(null,i.onerror),i.onload=l.bind(null,i.onload),c&&document.head.appendChild(i)}},d.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.p="/mui-otp-input/",d.gca=function(e){return e={17896441:"401",a94703ab:"48",a7bd4aaa:"98","1be6b01a":"103","3492c3da":"120",a7456010:"235","964ae018":"443","57349a88":"552","1df93b7f":"583","5e95c892":"647",a679ac6c:"671",aba21aa0:"742",d1c6cb73:"800",d589d3a7:"924","300eb1d2":"986"}[e]||e,d.p+d.u(e)},(()=>{var e={354:0,869:0};d.f.j=(t,r)=>{var a=d.o(e,t)?e[t]:void 0;if(0!==a)if(a)r.push(a[2]);else if(/^(354|869)$/.test(t))e[t]=0;else{var o=new Promise(((r,o)=>a=e[t]=[r,o]));r.push(a[2]=o);var n=d.p+d.u(t),i=new Error;d.l(n,(r=>{if(d.o(e,t)&&(0!==(a=e[t])&&(e[t]=void 0),a)){var o=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;i.message="Loading chunk "+t+" failed.\n("+o+": "+n+")",i.name="ChunkLoadError",i.type=o,i.request=n,a[1](i)}}),"chunk-"+t,t)}},d.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,n=r[0],i=r[1],c=r[2],u=0;if(n.some((t=>0!==e[t]))){for(a in i)d.o(i,a)&&(d.m[a]=i[a]);if(c)var f=c(d)}for(t&&t(r);u
+
+
+
+
+API Reference | MUI OTP input
+
+
+
+
+
+
+
+On this page
+
This article discusses the API and props of MuiOtpInput . Props are defined within MuiOtpInputProps
.
+
value
+
+Type: string
| undefined
+Default: ''
+
+
< MuiOtpInput /> < MuiOtpInput value = " A3B7 " />
+
onChange
+
+Type: (value: string) => void
+Default: undefined
+
+
Gets called once the user updates one of the inputs.
+
const handleChange = ( value ) => { } < MuiOtpInput onChange = { handleChange } />
+
length
+
+Type: number
+Default: 4
+
+
Choose the number of inputs to display, it also represents the length of the final value.
+
< MuiOtpInput length = { 6 } />
+
onComplete
+
+Type: (value: string) => void
+Default: undefined
+
+
Gets called once the user has filled all inputs.
+
const handleComplete = ( value ) => { } < MuiOtpInput length = { 4 } onComplete = { handleComplete } />
+
onBlur
+
+Type: ((value: string, isCompleted: boolean) => void) | undefined
+Default: undefined
+
+
Unlike the normal type of a TextField['onBlur']
prop, here it only triggers when no input of the component is focused.
+
< MuiOtpInput onBlur = { ( ) => console . log ( 'no input of the component is focused' ) } />
+
autoFocus
+
+Type: boolean
+Default: false
+
+
Choose to auto focus the first input.
+
< MuiOtpInput autoFocus />
+
validateChar
+
+Type: (value: string, index: number) => boolean
+Default: () => true
+
+
A function that validates each character during keyPress / paste events. If a user fills in an invalid character (like a letter instead of a number), it will not be displayed.
+
export function matchIsNumeric ( text ) { const isNumber = typeof text === 'number' const isString = matchIsString ( text ) return ( isNumber || ( isString && text !== '' ) ) && ! isNaN ( Number ( text ) ) } const validateChar = ( value , index ) => { return matchIsNumeric ( value ) } < MuiOtpInput length = { 4 } validateChar = { validateChar } />
+
TextFieldsProps
+
While not explicitly documented, the props of the MUI TextField component can be used for each TextField
.
+
See: https://mui.com/material-ui/api/text-field/
+
< MuiOtpInput TextFieldsProps = { { disabled : true , size : 'small' } } />
+
OR if you want to pass different props depending of the index.
+
< MuiOtpInput TextFieldsProps = { ( index ) => ( { size : 'small' , placeholder : String ( index ) } ) } />
+
placeholder
+
+Type: string
| undefined
| (index: number) => string | undefined
+Default: undefined
+
+
Unlike the normal type of a TextField
, here you can manage a distinct placeholder for each field.
+
< MuiOtpInput TextFieldsProps = { { placeholder : '-' } } /> < MuiOtpInput TextFieldsProps = { { placeholder : ( index ) => ` i- ${ index } ` } } />
+
+
\ No newline at end of file
diff --git a/docs/css/index.html b/docs/css/index.html
new file mode 100644
index 0000000..c6510f0
--- /dev/null
+++ b/docs/css/index.html
@@ -0,0 +1,22 @@
+
+
+
+
+
+CSS | MUI OTP input
+
+
+
+
+
+
+
+On this page
+
Like any component, if you want to override a component's styles using custom classes, you can use the className
prop.
+
< MuiOtpInput className = " my-class-name " />
+
Then, you can use the differents global class names (see below) to target an element of MuiOtpInput
.
+
Global class Description .MuiOtpInput-Box
Styles applied to the root element. .MuiOtpInput-TextField
Styles applied to each TextField component. .MuiOtpInput-TextField-{n}
Styles applied to a specific TextField component. ``.MuiOtpInput-TextField-3` to target the third TextField for example. For example: target the .MuiTelInput-TextField
global class name to customize all TextFields.
+
Example with styled-component / emotion
+
import { styled } from 'styled-component' import { MuiOtpInput } from 'mui-one-time-password-input' const MuiOtpInputStyled = styled ( MuiOtpInput ) ` display : flex ; gap : 30 px ; max-width : 650 px ; margin-inline : auto ; ` function MyComponent ( ) { return < MuiOtpInputStyled /> }
+
+
\ No newline at end of file
diff --git a/docs/getting-started/index.html b/docs/getting-started/index.html
new file mode 100644
index 0000000..476c1a3
--- /dev/null
+++ b/docs/getting-started/index.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+Getting Started | MUI OTP input
+
+
+
+
+
+
+
+On this page
+
Install
+
npm install mui-one-time-password-input --save
+
or you can use yarn
+
yarn add mui-one-time-password-input
+
We have completed installing the package.
+
Simple usage
+
Here is a simple usage for using the component:
+
import React from 'react' import { MuiOtpInput } from 'mui-one-time-password-input' const MyComponent = ( ) => { const [ otp , setOtp ] = React . useState ( '' ) const handleChange = ( newValue ) => { setOtp ( newValue ) } return ( < MuiOtpInput value = { otp } onChange = { handleChange } /> ) }
+
Next.js integration
+
Learn how to use MUI OTP Input with Next.js .
+
Once you have installed MUI OTP Input
in your next.js project, it is important to transpile it as it is an ESM package first.
+
const nextConfig = { transpilePackages : [ 'mui-one-time-password-input' ] , } module . exports = nextConfig
+
Congratulations !
+
That's all, now let's deep dive into the props .
+
+
\ No newline at end of file
diff --git a/docs/inheritance/index.html b/docs/inheritance/index.html
new file mode 100644
index 0000000..aee7063
--- /dev/null
+++ b/docs/inheritance/index.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+Box inheritance | MUI OTP input
+
+
+
+
+
+
+
+On this page
+
While not explicitly documented, the props of the MUI Box component are also available on the MuiOtpInput component.
+
See: https://mui.com/material-ui/api/box/
+
Example
+
< MuiOtpInput display = " flex " gap = { 5 } />
+
+
\ No newline at end of file
diff --git a/docs/playground/index.html b/docs/playground/index.html
new file mode 100644
index 0000000..4a88216
--- /dev/null
+++ b/docs/playground/index.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+Playground | MUI OTP input
+
+
+
+
+
+
+
+
+
Need to play around with MuiOtpInput in a live environment before deciding if it's the right fit? No problem.
+
+
+
\ No newline at end of file
diff --git a/docs/react-hook-form/index.html b/docs/react-hook-form/index.html
new file mode 100644
index 0000000..fb72af1
--- /dev/null
+++ b/docs/react-hook-form/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+React Hook Form | MUI OTP input
+
+
+
+
+
+
+
+
+
Here an example if you want to plug MuiOtpInput
to your form using React Hook Form .
+
import React from "react" ; import ReactDOM from "react-dom" ; import Button from "@mui/material/Button" ; import { MuiOtpInput } from "mui-one-time-password-input" ; import { Controller , useForm } from "react-hook-form" ; const App = ( ) => { const { control , handleSubmit } = useForm ( { defaultValues : { otp : "" } } ) ; const onSubmit = ( data ) => { alert ( JSON . stringify ( data ) ) ; } ; return ( < form onSubmit = { handleSubmit ( onSubmit ) } > < Controller name = " otp " control = { control } rules = { { validate : ( value ) => value . length === 6 } } render = { ( { field , fieldState } ) => ( < Box > < MuiOtpInput sx = { { gap : 1 } } { ... field } length = { 6 } /> { fieldState . invalid ? ( < FormHelperText error > OTP invalid </ FormHelperText > ) : null } </ Box > ) } /> < div > < Button type = " submit " variant = " contained " sx = { { mt : 2 } } > Submit </ Button > </ div > </ form > ) }
+
+
+
\ No newline at end of file
diff --git a/docs/typescript/index.html b/docs/typescript/index.html
new file mode 100644
index 0000000..4d4a232
--- /dev/null
+++ b/docs/typescript/index.html
@@ -0,0 +1,19 @@
+
+
+
+
+
+TypeScript | MUI OTP input
+
+
+
+
+
+
+
+
+
This package is written in TypeScript . So you don't need to create your own types. Here an example if you use TypeScript .
+
Nota bene : Props are defined within the MuiOtpInputProps
interface.
+
import React from 'react' import { MuiOtpInput } from 'mui-one-time-password-input' const MyComponent = ( ) => { const [ value , setValue ] = React . useState < string > ( '' ) const handleChange = ( newValue : string ) => { setValue ( newValue ) } const handleComplete = ( finalValue : string ) => { fetch ( '...' ) } return ( < MuiOtpInput value = { value } onChange = { handleChange } onComplete = { handleComplete } length = { 8 } autoFocus validateChar = { ( character : string , index : number ) => true } /> ) }
+
+
\ No newline at end of file
diff --git a/img/favicon.ico b/img/favicon.ico
new file mode 100644
index 0000000..99bd2e4
Binary files /dev/null and b/img/favicon.ico differ
diff --git a/img/logo.svg b/img/logo.svg
new file mode 100644
index 0000000..76adebb
--- /dev/null
+++ b/img/logo.svg
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..6ca6f9d
--- /dev/null
+++ b/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+MUI OTP input
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sitemap.xml b/sitemap.xml
new file mode 100644
index 0000000..eeda39e
--- /dev/null
+++ b/sitemap.xml
@@ -0,0 +1 @@
+https://viclafouch.github.io/mui-otp-input/docs/api-reference/ weekly 0.5 https://viclafouch.github.io/mui-otp-input/docs/css/ weekly 0.5 https://viclafouch.github.io/mui-otp-input/docs/getting-started/ weekly 0.5 https://viclafouch.github.io/mui-otp-input/docs/inheritance/ weekly 0.5 https://viclafouch.github.io/mui-otp-input/docs/playground/ weekly 0.5 https://viclafouch.github.io/mui-otp-input/docs/react-hook-form/ weekly 0.5 https://viclafouch.github.io/mui-otp-input/docs/typescript/ weekly 0.5 https://viclafouch.github.io/mui-otp-input/ weekly 0.5
\ No newline at end of file