@siamf/otp-timer 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -0
- package/dist/cjs/components/Otptimer.d.ts +23 -0
- package/dist/cjs/components/Otptimer.js +51 -0
- package/dist/cjs/components/Otptimer.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/components/Otptimer.d.ts +23 -0
- package/dist/esm/components/Otptimer.js +46 -0
- package/dist/esm/components/Otptimer.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<br/>
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://res.cloudinary.com/dub0dpenl/image/upload/v1731780157/Personal%20Logo/logo-white_e6fujz.png">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://res.cloudinary.com/dub0dpenl/image/upload/v1731780152/Personal%20Logo/logo-dark_qqwrqu.png">
|
|
5
|
+
<img alt="Siam Ahnaf" src="https://res.cloudinary.com/dub0dpenl/image/upload/v1731780152/Personal%20Logo/logo-dark_qqwrqu.png" height="auto" width="240">
|
|
6
|
+
</picture>
|
|
7
|
+
<br/> <br/>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# @siamf/otp-timer
|
|
11
|
+
|
|
12
|
+
A simple and customizable react otp timer component with typescript support. very simple and more customizable design and smallest bundle size about 13kb. You can use this component into any react and nextjs projects.
|
|
13
|
+
|
|
14
|
+
<a href="https://www.buymeacoffee.com/siamahnaf" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
|
|
15
|
+
|
|
16
|
+
- SSR Friendly
|
|
17
|
+
- Customizable
|
|
18
|
+
- TypeScript Support
|
|
19
|
+
- Smallest Bundle Size(About 13kb)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```shell-script
|
|
25
|
+
$ npm i @siamf/otp-timer
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Demo
|
|
29
|
+
|
|
30
|
+
<img src="https://res.cloudinary.com/dub0dpenl/image/upload/v1672334376/otp-timer-ts_f8ebe8.gif" alt="Girl in a jacket" width="250">
|
|
31
|
+
|
|
32
|
+
## Usage?
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { Otptimer } from "@siamf/otp-timer";
|
|
36
|
+
|
|
37
|
+
const MyComponent = () => {
|
|
38
|
+
|
|
39
|
+
const handleResend = () => {
|
|
40
|
+
//desired function to be performed on clicking resend button
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div>
|
|
45
|
+
<Otptimer minutes={0} seconds={5} onResend={handleResend} />
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default MyComponent;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Options
|
|
54
|
+
|
|
55
|
+
|name|Description|Default Value|
|
|
56
|
+
|:---:| :-------------:|:-----------:|
|
|
57
|
+
|seconds|number of seconds for which timer must be set|30|
|
|
58
|
+
|minutes|number of minutes for which the timer must be set|0|
|
|
59
|
+
|onResend|function that would get triggered on clicking the resend button|n/a|
|
|
60
|
+
|text|content that you want to put down|Resend otp in|
|
|
61
|
+
|ButtonText|button text|Resend|
|
|
62
|
+
|showSpinner|If you want to show any button loading|false|
|
|
63
|
+
|fetching|If you want to show any button loading icon with fetching state|false|
|
|
64
|
+
|spinnerComponent|Your custom spinner component for render|null|
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Styling
|
|
68
|
+
|
|
69
|
+
<table>
|
|
70
|
+
<tr>
|
|
71
|
+
<th> Name </th>
|
|
72
|
+
<th> Type </th>
|
|
73
|
+
<th> Description </th>
|
|
74
|
+
</tr>
|
|
75
|
+
<tr>
|
|
76
|
+
<td> containerClass </td>
|
|
77
|
+
<td> string </td>
|
|
78
|
+
<td> timer Container class name </td>
|
|
79
|
+
</tr>
|
|
80
|
+
<tr>
|
|
81
|
+
<td> textClass </td>
|
|
82
|
+
<td> string </td>
|
|
83
|
+
<td> text class name </td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td> timerClass </td>
|
|
87
|
+
<td> string </td>
|
|
88
|
+
<td> timer class name </td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td> buttonContainerClass </td>
|
|
92
|
+
<td> string </td>
|
|
93
|
+
<td> button container class </td>
|
|
94
|
+
</tr>
|
|
95
|
+
<tr>
|
|
96
|
+
<td> buttonClass </td>
|
|
97
|
+
<td> string </td>
|
|
98
|
+
<td> button class </td>
|
|
99
|
+
</tr>
|
|
100
|
+
<tr>
|
|
101
|
+
<td> buttonStyle </td>
|
|
102
|
+
<td> CSSProperties </td>
|
|
103
|
+
<td> styles for resend button </td>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<td> buttonContainerStyle </td>
|
|
107
|
+
<td> CSSProperties </td>
|
|
108
|
+
<td> styles for resend button container </td>
|
|
109
|
+
</tr>
|
|
110
|
+
<tr>
|
|
111
|
+
<td> textStyle </td>
|
|
112
|
+
<td> CSSProperties </td>
|
|
113
|
+
<td> styles for text </td>
|
|
114
|
+
</tr>
|
|
115
|
+
<tr>
|
|
116
|
+
<td> timerStyle </td>
|
|
117
|
+
<td> CSSProperties </td>
|
|
118
|
+
<td> styles for timer </td>
|
|
119
|
+
</tr>
|
|
120
|
+
<tr>
|
|
121
|
+
<td> textContainerStyle </td>
|
|
122
|
+
<td> CSSProperties </td>
|
|
123
|
+
<td> styles for timer text container </td>
|
|
124
|
+
</tr>
|
|
125
|
+
</table>
|
|
126
|
+
|
|
127
|
+
## Issues
|
|
128
|
+
|
|
129
|
+
You are welcome to create an issue.
|
|
130
|
+
|
|
131
|
+
## Stay in touch
|
|
132
|
+
|
|
133
|
+
- Author - [Siam Ahnaf](https://www.siamahnaf.com/)
|
|
134
|
+
- Website - [https://www.siamahnaf.com/](https://www.siamahnaf.com/)
|
|
135
|
+
- Github - [https://github.com/siamahnaf](https://github.com/siamahnaf)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
seconds?: number;
|
|
4
|
+
minutes?: number;
|
|
5
|
+
text?: string;
|
|
6
|
+
buttonText?: string;
|
|
7
|
+
containerClass?: string;
|
|
8
|
+
buttonContainerClass?: string;
|
|
9
|
+
textClass?: string;
|
|
10
|
+
timerClass?: string;
|
|
11
|
+
buttonStyle?: React.CSSProperties;
|
|
12
|
+
buttonClass?: string;
|
|
13
|
+
textStyle?: React.CSSProperties;
|
|
14
|
+
timerStyle?: React.CSSProperties;
|
|
15
|
+
buttonContainerStyle?: React.CSSProperties;
|
|
16
|
+
textContainerStyle?: React.CSSProperties;
|
|
17
|
+
onResend: () => void;
|
|
18
|
+
fetching?: boolean;
|
|
19
|
+
showSpinner?: boolean;
|
|
20
|
+
spinnerComponent?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare const Otptimer: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default Otptimer;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const Otptimer = (props) => {
|
|
9
|
+
//From props
|
|
10
|
+
const { text = "Resend otp in", containerClass = "otp-timer-container", buttonText = "Resend", textClass = "otp-text", buttonContainerClass = "button-container", timerClass = "otp-timer", buttonStyle, buttonContainerStyle, timerStyle, textStyle, textContainerStyle, onResend, fetching = false, buttonClass, showSpinner = false, spinnerComponent } = props;
|
|
11
|
+
//State
|
|
12
|
+
const [minutes, setMinutes] = react_1.default.useState(props.minutes ? props.minutes : 0);
|
|
13
|
+
const [seconds, setSeconds] = react_1.default.useState(props.seconds ? props.seconds : 30);
|
|
14
|
+
//Handler
|
|
15
|
+
let myInterval;
|
|
16
|
+
const onTimeHandler = () => {
|
|
17
|
+
myInterval = setInterval(() => {
|
|
18
|
+
if (seconds > 0) {
|
|
19
|
+
setSeconds(seconds - 1);
|
|
20
|
+
}
|
|
21
|
+
if (seconds === 0) {
|
|
22
|
+
if (minutes === 0) {
|
|
23
|
+
clearInterval(myInterval);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
setMinutes(minutes - 1);
|
|
27
|
+
setSeconds(59);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}, 1000);
|
|
31
|
+
};
|
|
32
|
+
//Effect
|
|
33
|
+
react_1.default.useEffect(() => {
|
|
34
|
+
onTimeHandler();
|
|
35
|
+
return () => clearInterval(myInterval);
|
|
36
|
+
});
|
|
37
|
+
//Handler
|
|
38
|
+
const resendHandler = () => {
|
|
39
|
+
setSeconds(props.seconds ? props.seconds : 30);
|
|
40
|
+
setMinutes(props.minutes ? props.minutes : 0);
|
|
41
|
+
onTimeHandler();
|
|
42
|
+
onResend();
|
|
43
|
+
};
|
|
44
|
+
//Styling
|
|
45
|
+
const ButtonStyles = Object.assign({ border: "none", background: "none", cursor: "pointer", padding: 0, margin: 0 }, buttonStyle);
|
|
46
|
+
const textContainerStyles = Object.assign({ fontSize: "15px" }, textContainerStyle);
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: minutes === 0 && seconds === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: buttonContainerClass, style: buttonContainerStyle, children: (0, jsx_runtime_1.jsxs)("button", { onClick: resendHandler, className: buttonClass, style: ButtonStyles, children: [(0, jsx_runtime_1.jsx)("span", { children: buttonText }), showSpinner && fetching &&
|
|
48
|
+
spinnerComponent] }) })) : ((0, jsx_runtime_1.jsxs)("div", { className: containerClass, style: textContainerStyles, children: [(0, jsx_runtime_1.jsx)("span", { className: textClass, style: textStyle, children: text }), " ", (0, jsx_runtime_1.jsxs)("span", { className: timerClass, style: timerStyle, children: [(0, jsx_runtime_1.jsx)("span", { children: minutes < 10 ? `0${minutes}` : minutes }), ":", (0, jsx_runtime_1.jsx)("span", { children: seconds < 10 ? `0${seconds}` : seconds })] })] })) }));
|
|
49
|
+
};
|
|
50
|
+
exports.default = Otptimer;
|
|
51
|
+
//# sourceMappingURL=Otptimer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Otptimer.js","sourceRoot":"","sources":["../../../src/components/Otptimer.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAwB1B,MAAM,QAAQ,GAAG,CAAC,KAAY,EAAE,EAAE;IAC9B,YAAY;IACZ,MAAM,EAAE,IAAI,GAAG,eAAe,EAAE,cAAc,GAAG,qBAAqB,EAAE,UAAU,GAAG,QAAQ,EAAE,SAAS,GAAG,UAAU,EAAE,oBAAoB,GAAG,kBAAkB,EAAE,UAAU,GAAG,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,UAAU,EAAE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,WAAW,EAAE,WAAW,GAAG,KAAK,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IACnW,OAAO;IACP,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAS,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,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,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,CAAC,IACN,WAAW,CACjB,CAAA;IACD,MAAM,mBAAmB,mBACrB,QAAQ,EAAE,MAAM,IACb,kBAAkB,CACxB,CAAA;IACD,OAAO,CACH,0CACK,OAAO,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAC9B,gCAAK,SAAS,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,YAC7D,oCAAQ,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,aACvE,2CAAO,UAAU,GAAQ,EACxB,WAAW,IAAI,QAAQ;wBACpB,gBAAgB,IAEf,GACP,CACT,CAAC,CAAC,CAAC,CACA,iCAAK,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,mBAAmB,aACtD,iCAAM,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,YAAG,IAAI,GAAQ,EAAC,GAAG,EAC/D,kCAAM,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,aAC1C,2CAAO,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,GAAQ,OACrD,2CAAO,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,GAAQ,IAClD,IACL,CACT,GACC,CACT,CAAC;AACN,CAAC,CAAC;AACF,kBAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Otptimer } from "./components/Otptimer";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Otptimer = void 0;
|
|
7
|
+
var Otptimer_1 = require("./components/Otptimer");
|
|
8
|
+
Object.defineProperty(exports, "Otptimer", { enumerable: true, get: function () { return __importDefault(Otptimer_1).default; } });
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4D;AAAnD,qHAAA,OAAO,OAAY"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
seconds?: number;
|
|
4
|
+
minutes?: number;
|
|
5
|
+
text?: string;
|
|
6
|
+
buttonText?: string;
|
|
7
|
+
containerClass?: string;
|
|
8
|
+
buttonContainerClass?: string;
|
|
9
|
+
textClass?: string;
|
|
10
|
+
timerClass?: string;
|
|
11
|
+
buttonStyle?: React.CSSProperties;
|
|
12
|
+
buttonClass?: string;
|
|
13
|
+
textStyle?: React.CSSProperties;
|
|
14
|
+
timerStyle?: React.CSSProperties;
|
|
15
|
+
buttonContainerStyle?: React.CSSProperties;
|
|
16
|
+
textContainerStyle?: React.CSSProperties;
|
|
17
|
+
onResend: () => void;
|
|
18
|
+
fetching?: boolean;
|
|
19
|
+
showSpinner?: boolean;
|
|
20
|
+
spinnerComponent?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare const Otptimer: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default Otptimer;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const Otptimer = (props) => {
|
|
4
|
+
//From props
|
|
5
|
+
const { text = "Resend otp in", containerClass = "otp-timer-container", buttonText = "Resend", textClass = "otp-text", buttonContainerClass = "button-container", timerClass = "otp-timer", buttonStyle, buttonContainerStyle, timerStyle, textStyle, textContainerStyle, onResend, fetching = false, buttonClass, showSpinner = false, spinnerComponent } = props;
|
|
6
|
+
//State
|
|
7
|
+
const [minutes, setMinutes] = React.useState(props.minutes ? props.minutes : 0);
|
|
8
|
+
const [seconds, setSeconds] = React.useState(props.seconds ? props.seconds : 30);
|
|
9
|
+
//Handler
|
|
10
|
+
let myInterval;
|
|
11
|
+
const onTimeHandler = () => {
|
|
12
|
+
myInterval = setInterval(() => {
|
|
13
|
+
if (seconds > 0) {
|
|
14
|
+
setSeconds(seconds - 1);
|
|
15
|
+
}
|
|
16
|
+
if (seconds === 0) {
|
|
17
|
+
if (minutes === 0) {
|
|
18
|
+
clearInterval(myInterval);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
setMinutes(minutes - 1);
|
|
22
|
+
setSeconds(59);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, 1000);
|
|
26
|
+
};
|
|
27
|
+
//Effect
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
onTimeHandler();
|
|
30
|
+
return () => clearInterval(myInterval);
|
|
31
|
+
});
|
|
32
|
+
//Handler
|
|
33
|
+
const resendHandler = () => {
|
|
34
|
+
setSeconds(props.seconds ? props.seconds : 30);
|
|
35
|
+
setMinutes(props.minutes ? props.minutes : 0);
|
|
36
|
+
onTimeHandler();
|
|
37
|
+
onResend();
|
|
38
|
+
};
|
|
39
|
+
//Styling
|
|
40
|
+
const ButtonStyles = Object.assign({ border: "none", background: "none", cursor: "pointer", padding: 0, margin: 0 }, buttonStyle);
|
|
41
|
+
const textContainerStyles = Object.assign({ fontSize: "15px" }, textContainerStyle);
|
|
42
|
+
return (_jsx("div", { children: minutes === 0 && seconds === 0 ? (_jsx("div", { className: buttonContainerClass, style: buttonContainerStyle, children: _jsxs("button", { onClick: resendHandler, className: buttonClass, style: ButtonStyles, children: [_jsx("span", { children: buttonText }), showSpinner && fetching &&
|
|
43
|
+
spinnerComponent] }) })) : (_jsxs("div", { className: containerClass, style: textContainerStyles, children: [_jsx("span", { className: textClass, style: textStyle, children: text }), " ", _jsxs("span", { className: timerClass, style: timerStyle, children: [_jsx("span", { children: minutes < 10 ? `0${minutes}` : minutes }), ":", _jsx("span", { children: seconds < 10 ? `0${seconds}` : seconds })] })] })) }));
|
|
44
|
+
};
|
|
45
|
+
export default Otptimer;
|
|
46
|
+
//# sourceMappingURL=Otptimer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Otptimer.js","sourceRoot":"","sources":["../../../src/components/Otptimer.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAwB1B,MAAM,QAAQ,GAAG,CAAC,KAAY,EAAE,EAAE;IAC9B,YAAY;IACZ,MAAM,EAAE,IAAI,GAAG,eAAe,EAAE,cAAc,GAAG,qBAAqB,EAAE,UAAU,GAAG,QAAQ,EAAE,SAAS,GAAG,UAAU,EAAE,oBAAoB,GAAG,kBAAkB,EAAE,UAAU,GAAG,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,UAAU,EAAE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,WAAW,EAAE,WAAW,GAAG,KAAK,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IACnW,OAAO;IACP,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAS,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IACxF,SAAS;IACT,IAAI,UAA0C,CAAA;IAC9C,MAAM,aAAa,GAAG,GAAG,EAAE;QAC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,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAC9B,cAAK,SAAS,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,YAC7D,kBAAQ,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,aACvE,yBAAO,UAAU,GAAQ,EACxB,WAAW,IAAI,QAAQ;wBACpB,gBAAgB,IAEf,GACP,CACT,CAAC,CAAC,CAAC,CACA,eAAK,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,mBAAmB,aACtD,eAAM,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,YAAG,IAAI,GAAQ,EAAC,GAAG,EAC/D,gBAAM,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,aAC1C,yBAAO,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,GAAQ,OACrD,yBAAO,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,GAAQ,IAClD,IACL,CACT,GACC,CACT,CAAC;AACN,CAAC,CAAC;AACF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Otptimer } from "./components/Otptimer";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,uBAAuB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@siamf/otp-timer",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "A simple react otp timer component with resend functionality🤷",
|
|
5
|
+
"homepage": "https://github.com/siamahnaf/otp-timer",
|
|
6
|
+
"main": "dist/cjs/index.js",
|
|
7
|
+
"module": "dist/esm/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rimraf dist && npm run build:esm && npm run build:cjs",
|
|
13
|
+
"build:esm": "tsc",
|
|
14
|
+
"build:cjs": "tsc --module CommonJS --outDir dist/cjs"
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Siam Ahnaf",
|
|
18
|
+
"email": "mail@siamahnaf.com",
|
|
19
|
+
"url": "https://www.siamahnaf.com"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"keywords": [
|
|
23
|
+
"react",
|
|
24
|
+
"nextjs",
|
|
25
|
+
"one-time-password",
|
|
26
|
+
"otp-timer",
|
|
27
|
+
"otptimer",
|
|
28
|
+
"otp",
|
|
29
|
+
"otp-timer",
|
|
30
|
+
"timer",
|
|
31
|
+
"reactotptimer"
|
|
32
|
+
],
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"directory": "https://github.com/siamahnaf/otp-timer",
|
|
36
|
+
"url": "https://github.com/siamahnaf/otp-timer"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^22.12.0",
|
|
40
|
+
"@types/react": "^19.0.8",
|
|
41
|
+
"@types/react-dom": "^19.0.3",
|
|
42
|
+
"react": "^19.0.0",
|
|
43
|
+
"react-dom": "^19.0.0",
|
|
44
|
+
"typescript": "^5.7.3"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": "^18 || ^19",
|
|
48
|
+
"react-dom": "^18 || ^19"
|
|
49
|
+
}
|
|
50
|
+
}
|