@dgshahr/ui-kit 0.0.62 → 0.0.63
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/dist/Form/Input/index.cjs +1 -1
- package/dist/Form/Input/index.d.ts +1 -0
- package/dist/Form/Input/index.d.ts.map +1 -1
- package/dist/Form/Input/index.js +36 -36
- package/dist/Form/OtpInput/index.cjs +1 -1
- package/dist/Form/OtpInput/index.d.ts.map +1 -1
- package/dist/Form/OtpInput/index.js +50 -46
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),g=require("../../clsx-C11secjj.cjs"),h=require("react"),k=require("../../omitObjects-CtiYo0hv.cjs"),C=require("../../TextFieldWrapper-B03flGgW.cjs"),y=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...t,children:[e.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"m15.456 9.595-5.852 5.852-1.061-1.06 5.853-5.853z",clipRule:"evenodd"}),e.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"m9.6 8.532 5.856 5.858-1.06 1.06-5.857-5.857z",clipRule:"evenodd"}),e.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12m10-8.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17",clipRule:"evenodd"})]}),R=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...t,children:[e.jsx("path",{fill:"currentColor",d:"M12.247 20.812c-4.033 0-7.654-2.828-9.686-7.558a.75.75 0 0 1 0-.592c2.034-4.732 5.655-7.557 9.687-7.557s7.657 2.825 9.69 7.557a.75.75 0 0 1 0 .592c-2.032 4.73-5.653 7.554-9.685 7.557zm-8.182-7.853c1.806 3.983 4.846 6.352 8.18 6.352 3.334.002 6.373-2.369 8.18-6.352-1.808-3.986-4.848-6.354-8.182-6.354s-6.37 2.368-8.176 6.354z"}),e.jsx("path",{fill:"currentColor",d:"M12.247 16.789a3.825 3.825 0 1 1 0-7.651 3.825 3.825 0 0 1 0 7.65m0-6.152a2.326 2.326 0 1 0 0 4.651 2.326 2.326 0 0 0 0-4.651"})]}),I=t=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...t,children:e.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M20.417 3.22a.75.75 0 0 1 0 1.06L4.643 20.055a.744.744 0 0 1-1.06 0 .75.75 0 0 1 0-1.06l1.972-1.971c-1.413-1.293-2.613-3.036-3.493-5.089a.75.75 0 0 1 0-.593C3.082 8.977 4.52 7.02 6.22 5.683c3.292-2.606 7.621-2.744 11.048-.375l2.088-2.088a.75.75 0 0 1 1.06 0m-.37 4.82c.724.962 1.36 2.073 1.891 3.299a.74.74 0 0 1 0 .595C19.842 16.79 16.128 19.69 12 19.69a8.8 8.8 0 0 1-2.769-.451.75.75 0 0 1 .474-1.424A7.3 7.3 0 0 0 12 18.19c3.428 0 6.561-2.442 8.43-6.553a14.5 14.5 0 0 0-1.58-2.694.75.75 0 0 1 1.197-.902M7.15 6.862c-1.437 1.13-2.67 2.776-3.58 4.778.794 1.752 1.836 3.23 3.047 4.322l2.138-2.138a3.87 3.87 0 0 1-.67-2.184A3.92 3.92 0 0 1 12 7.722a3.9 3.9 0 0 1 2.187.669l2.001-2.002c-2.853-1.844-6.325-1.676-9.038.472m8.088 4.6a.75.75 0 0 1 .606.872 3.92 3.92 0 0 1-3.141 3.147.75.75 0 0 1-.268-1.476 2.41 2.41 0 0 0 1.932-1.937.754.754 0 0 1 .87-.606M12 9.221a2.418 2.418 0 0 0-2.152 3.509l3.245-3.246A2.4 2.4 0 0 0 12 9.222",clipRule:"evenodd"})}),N=h.forwardRef(function(a,f){const{dir:i="rtl",placeholderDir:m=i,containerClassName:w,leftIcon:u,prefix:d,postfix:x,onClear:n,value:r,...s}=a,j=k.omitObject(s,["labelAddon","labelContent","link","rightIcon","isError","errorMessage","hintMessage","wrapperClassName","showMaxLength"]),[c,v]=h.useState(s.type);function p(){return e.jsx("button",{onClick:()=>{typeof n=="function"&&n()},children:e.jsx(y,{className:"dgs-ui-kit-text-gray-600",width:20,height:20})})}return e.jsxs(C.TextFieldWrapper,{...a,containerClassName:g.clsx("dgs-ui-kit-items-center",w),value:r,children:[d&&e.jsx("span",{className:"dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-500",children:d}),typeof n=="function"&&r&&i==="ltr"&&p(),e.jsx("input",{...j,ref:f,className:g.clsx("dgs-ui-kit-bg-transparent focus:dgs-ui-kit-outline-none dgs-ui-kit-flex-1",i==="rtl"?"dgs-ui-kit-text-right":"!dgs-ui-kit-text-left",m==="rtl"?"placeholder:dgs-ui-kit-text-right":"placeholder:dgs-ui-kit-text-left",{ss02:s.type!="password"},a.className),...i==="ltr"?{style:{direction:"ltr"}}:{},value:r,type:c,onInput:o=>{if(typeof s.onInput=="function"&&s.onInput(o)||c!=="number")return;const l=o.currentTarget;l.value.length>l.maxLength&&(l.value=l.value.slice(0,l.maxLength))}}),typeof n=="function"&&r&&i==="rtl"&&p(),x&&e.jsx("span",{className:"dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-500",children:x}),u&&e.jsx("div",{className:"dgs-ui-kit-text-gray-600",children:u}),s.type==="password"&&e.jsx("button",{onClick:()=>v(o=>o==="text"?"password":"text"),className:"dgs-ui-kit-text-gray-600",children:c==="password"?e.jsx(R,{width:20,height:20}):e.jsx(I,{width:20,height:20})})]})});module.exports=N;
|
|
@@ -5,6 +5,7 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
5
5
|
prefix?: string;
|
|
6
6
|
postfix?: string;
|
|
7
7
|
onClear?: () => void;
|
|
8
|
+
onInput?: (event: React.FormEvent<HTMLInputElement>) => void | boolean;
|
|
8
9
|
}
|
|
9
10
|
declare const Input: import('react').ForwardRefExoticComponent<InputProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
10
11
|
export default Input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Input/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,mBAAmB,EAAwB,MAAM,OAAO,CAAC;AAM1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAExF,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,EACxD,kBAAkB;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Input/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,mBAAmB,EAAwB,MAAM,OAAO,CAAC;AAM1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAExF,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,KAAK,CAAC,EACxD,kBAAkB;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC;CACxE;AAED,QAAA,MAAM,KAAK,yGAyGT,CAAC;AACH,eAAe,KAAK,CAAC"}
|
package/dist/Form/Input/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as d, jsx as
|
|
1
|
+
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { c as f } from "../../clsx-OuTLNxxd.js";
|
|
3
3
|
import { forwardRef as C, useState as y } from "react";
|
|
4
4
|
import { o as I } from "../../omitObjects-CxFrrlkX.js";
|
|
5
5
|
import { T as N } from "../../TextFieldWrapper-Mcwb34qQ.js";
|
|
6
|
-
const M = (
|
|
6
|
+
const M = (e) => /* @__PURE__ */ d(
|
|
7
7
|
"svg",
|
|
8
8
|
{
|
|
9
9
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -11,9 +11,9 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
11
11
|
height: "1em",
|
|
12
12
|
fill: "none",
|
|
13
13
|
viewBox: "0 0 24 24",
|
|
14
|
-
...
|
|
14
|
+
...e,
|
|
15
15
|
children: [
|
|
16
|
-
/* @__PURE__ */
|
|
16
|
+
/* @__PURE__ */ t(
|
|
17
17
|
"path",
|
|
18
18
|
{
|
|
19
19
|
fill: "currentColor",
|
|
@@ -22,7 +22,7 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
22
22
|
clipRule: "evenodd"
|
|
23
23
|
}
|
|
24
24
|
),
|
|
25
|
-
/* @__PURE__ */
|
|
25
|
+
/* @__PURE__ */ t(
|
|
26
26
|
"path",
|
|
27
27
|
{
|
|
28
28
|
fill: "currentColor",
|
|
@@ -31,7 +31,7 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
31
31
|
clipRule: "evenodd"
|
|
32
32
|
}
|
|
33
33
|
),
|
|
34
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ t(
|
|
35
35
|
"path",
|
|
36
36
|
{
|
|
37
37
|
fill: "currentColor",
|
|
@@ -42,7 +42,7 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
42
42
|
)
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
|
-
), R = (
|
|
45
|
+
), R = (e) => /* @__PURE__ */ d(
|
|
46
46
|
"svg",
|
|
47
47
|
{
|
|
48
48
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -50,16 +50,16 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
50
50
|
height: "1em",
|
|
51
51
|
fill: "none",
|
|
52
52
|
viewBox: "0 0 24 24",
|
|
53
|
-
...
|
|
53
|
+
...e,
|
|
54
54
|
children: [
|
|
55
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ t(
|
|
56
56
|
"path",
|
|
57
57
|
{
|
|
58
58
|
fill: "currentColor",
|
|
59
59
|
d: "M12.247 20.812c-4.033 0-7.654-2.828-9.686-7.558a.75.75 0 0 1 0-.592c2.034-4.732 5.655-7.557 9.687-7.557s7.657 2.825 9.69 7.557a.75.75 0 0 1 0 .592c-2.032 4.73-5.653 7.554-9.685 7.557zm-8.182-7.853c1.806 3.983 4.846 6.352 8.18 6.352 3.334.002 6.373-2.369 8.18-6.352-1.808-3.986-4.848-6.354-8.182-6.354s-6.37 2.368-8.176 6.354z"
|
|
60
60
|
}
|
|
61
61
|
),
|
|
62
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ t(
|
|
63
63
|
"path",
|
|
64
64
|
{
|
|
65
65
|
fill: "currentColor",
|
|
@@ -68,7 +68,7 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
68
68
|
)
|
|
69
69
|
]
|
|
70
70
|
}
|
|
71
|
-
), b = (
|
|
71
|
+
), b = (e) => /* @__PURE__ */ t(
|
|
72
72
|
"svg",
|
|
73
73
|
{
|
|
74
74
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -76,8 +76,8 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
76
76
|
height: "1em",
|
|
77
77
|
fill: "none",
|
|
78
78
|
viewBox: "0 0 24 24",
|
|
79
|
-
...
|
|
80
|
-
children: /* @__PURE__ */
|
|
79
|
+
...e,
|
|
80
|
+
children: /* @__PURE__ */ t(
|
|
81
81
|
"path",
|
|
82
82
|
{
|
|
83
83
|
fill: "currentColor",
|
|
@@ -89,16 +89,16 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
89
89
|
}
|
|
90
90
|
), j = C(function(a, m) {
|
|
91
91
|
const {
|
|
92
|
-
dir:
|
|
93
|
-
placeholderDir:
|
|
94
|
-
containerClassName:
|
|
92
|
+
dir: l = "rtl",
|
|
93
|
+
placeholderDir: x = l,
|
|
94
|
+
containerClassName: w,
|
|
95
95
|
leftIcon: u,
|
|
96
96
|
prefix: p,
|
|
97
97
|
postfix: g,
|
|
98
98
|
onClear: r,
|
|
99
99
|
value: o,
|
|
100
|
-
...
|
|
101
|
-
} = a, v = I(
|
|
100
|
+
...i
|
|
101
|
+
} = a, v = I(i, [
|
|
102
102
|
"labelAddon",
|
|
103
103
|
"labelContent",
|
|
104
104
|
"link",
|
|
@@ -108,15 +108,15 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
108
108
|
"hintMessage",
|
|
109
109
|
"wrapperClassName",
|
|
110
110
|
"showMaxLength"
|
|
111
|
-
]), [c, k] = y(
|
|
111
|
+
]), [c, k] = y(i.type);
|
|
112
112
|
function h() {
|
|
113
|
-
return /* @__PURE__ */
|
|
113
|
+
return /* @__PURE__ */ t(
|
|
114
114
|
"button",
|
|
115
115
|
{
|
|
116
116
|
onClick: () => {
|
|
117
117
|
typeof r == "function" && r();
|
|
118
118
|
},
|
|
119
|
-
children: /* @__PURE__ */
|
|
119
|
+
children: /* @__PURE__ */ t(
|
|
120
120
|
M,
|
|
121
121
|
{
|
|
122
122
|
className: "dgs-ui-kit-text-gray-600",
|
|
@@ -131,50 +131,50 @@ const M = (t) => /* @__PURE__ */ d(
|
|
|
131
131
|
N,
|
|
132
132
|
{
|
|
133
133
|
...a,
|
|
134
|
-
containerClassName: f("dgs-ui-kit-items-center",
|
|
134
|
+
containerClassName: f("dgs-ui-kit-items-center", w),
|
|
135
135
|
value: o,
|
|
136
136
|
children: [
|
|
137
|
-
p && /* @__PURE__ */
|
|
138
|
-
typeof r == "function" && o &&
|
|
139
|
-
/* @__PURE__ */
|
|
137
|
+
p && /* @__PURE__ */ t("span", { className: "dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-500", children: p }),
|
|
138
|
+
typeof r == "function" && o && l === "ltr" && h(),
|
|
139
|
+
/* @__PURE__ */ t(
|
|
140
140
|
"input",
|
|
141
141
|
{
|
|
142
142
|
...v,
|
|
143
143
|
ref: m,
|
|
144
144
|
className: f(
|
|
145
145
|
"dgs-ui-kit-bg-transparent focus:dgs-ui-kit-outline-none dgs-ui-kit-flex-1",
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
l === "rtl" ? "dgs-ui-kit-text-right" : "!dgs-ui-kit-text-left",
|
|
147
|
+
x === "rtl" ? "placeholder:dgs-ui-kit-text-right" : "placeholder:dgs-ui-kit-text-left",
|
|
148
148
|
{
|
|
149
|
-
ss02:
|
|
149
|
+
ss02: i.type != "password"
|
|
150
150
|
},
|
|
151
151
|
a.className
|
|
152
152
|
),
|
|
153
|
-
...
|
|
153
|
+
...l === "ltr" ? { style: { direction: "ltr" } } : {},
|
|
154
154
|
value: o,
|
|
155
155
|
type: c,
|
|
156
156
|
onInput: (s) => {
|
|
157
|
-
if (typeof
|
|
157
|
+
if (typeof i.onInput == "function" && i.onInput(s) || c !== "number") return;
|
|
158
158
|
const n = s.currentTarget;
|
|
159
159
|
n.value.length > n.maxLength && (n.value = n.value.slice(0, n.maxLength));
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
),
|
|
163
|
-
typeof r == "function" && o &&
|
|
164
|
-
g && /* @__PURE__ */
|
|
165
|
-
u && /* @__PURE__ */
|
|
166
|
-
|
|
163
|
+
typeof r == "function" && o && l === "rtl" && h(),
|
|
164
|
+
g && /* @__PURE__ */ t("span", { className: "dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-500", children: g }),
|
|
165
|
+
u && /* @__PURE__ */ t("div", { className: "dgs-ui-kit-text-gray-600", children: u }),
|
|
166
|
+
i.type === "password" && /* @__PURE__ */ t(
|
|
167
167
|
"button",
|
|
168
168
|
{
|
|
169
169
|
onClick: () => k((s) => s === "text" ? "password" : "text"),
|
|
170
170
|
className: "dgs-ui-kit-text-gray-600",
|
|
171
|
-
children: c === "password" ? /* @__PURE__ */
|
|
171
|
+
children: c === "password" ? /* @__PURE__ */ t(
|
|
172
172
|
R,
|
|
173
173
|
{
|
|
174
174
|
width: 20,
|
|
175
175
|
height: 20
|
|
176
176
|
}
|
|
177
|
-
) : /* @__PURE__ */
|
|
177
|
+
) : /* @__PURE__ */ t(
|
|
178
178
|
b,
|
|
179
179
|
{
|
|
180
180
|
width: 20,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";require('../../assets/styles.css');const
|
|
1
|
+
"use client";"use strict";require('../../assets/styles.css');const i=require("react/jsx-runtime"),h=require("../../clsx-C11secjj.cjs"),m=require("react"),I=require("../Input/index.cjs"),k=require("../../TextFieldWrapper-B03flGgW.cjs");;/* empty css */const b=y=>{const{inputsNumber:u=4,onChange:a,onEnd:f,className:N,inputsContainerClassName:j,labelContent:p,hintMessage:g,errorMessage:o,isError:C,value:r,...v}=y,c=m.useRef(!1);function l(n){document.getElementById(`dgs-ui-kit-otp-input-${n}`)?.focus()}function w(n,t){const e=[n.code,n.key];if(e.includes("Backspace")||e.includes("Delete")){const s=r.split("");s[t]="",t!==0&&l(t-1),a(s.join(""))}else e.includes("ArrowLeft")?l(t-1):e.includes("ArrowRight")&&l(t+1)}function x(n,t){const e=n.currentTarget.value,s=r.split("");e.length>1?e.split("").forEach((E,d)=>{d<u&&(s[d]=E)}):s[t]=e,a(s.join("")),t+1!==u&&e&&l(t+1)}return m.useEffect(()=>{r.length===u&&c.current?(c.current=!1,typeof f=="function"&&f(r)):r.length<u&&(c.current=!0)},[r]),i.jsxs("div",{className:h.clsx("dgs-ui-kit-space-y-2",N),children:[p?i.jsx(k.FieldLabel,{labelContent:p}):null,i.jsx("div",{className:h.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2 [direction:ltr]",j),children:Array.from(Array(u).keys()).map((n,t)=>i.jsx(I,{containerClassName:"dgs-ui-kit-w-12 dgs-ui-kit-h-12 dgs-ui-kit-p-0",className:"dgs-ui-kit-w-full dgs-ui-kit-h-full !dgs-ui-kit-text-center placeholder:!dgs-ui-kit-text-center",placeholder:"-",autoFocus:t===0,onChange:e=>x(e,t),onKeyUp:e=>w(e,t),onFocus:e=>e.currentTarget.select(),id:`dgs-ui-kit-otp-input-${t}`,value:r[t]||"",showMaxLength:!1,isError:!!o||C,autoComplete:"off",maxLength:1,onPaste:e=>{const s=e.clipboardData.getData("text");Number(s)&&a(s)},onInput:e=>{const s=e.currentTarget;return!!(Number(s.value)&&s.value.length>1)},...v},n))}),o||g?i.jsx(k.FieldBottomInfo,{errorMessage:o,hintMessage:g}):null]})};module.exports=b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/OtpInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAuC,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AACzF,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAGlD,OAAO,kBAAkB,CAAC;AAE1B,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/OtpInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAuC,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AACzF,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAGlD,OAAO,kBAAkB,CAAC;AAE1B,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CAoH/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,81 +1,85 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as I, jsx as o } from "react/jsx-runtime";
|
|
3
3
|
import { c as d } from "../../clsx-OuTLNxxd.js";
|
|
4
|
-
import { useRef as
|
|
5
|
-
import
|
|
6
|
-
import { F as
|
|
4
|
+
import { useRef as b, useEffect as F } from "react";
|
|
5
|
+
import T from "../Input/index.js";
|
|
6
|
+
import { F as j, a as A } from "../../TextFieldWrapper-Mcwb34qQ.js";
|
|
7
7
|
import '../../assets/styles.css';/* empty css */
|
|
8
8
|
const K = (h) => {
|
|
9
9
|
const {
|
|
10
|
-
inputsNumber:
|
|
11
|
-
onChange:
|
|
10
|
+
inputsNumber: r = 4,
|
|
11
|
+
onChange: a,
|
|
12
12
|
onEnd: f,
|
|
13
13
|
className: k,
|
|
14
14
|
inputsContainerClassName: y,
|
|
15
15
|
labelContent: p,
|
|
16
16
|
hintMessage: g,
|
|
17
|
-
errorMessage:
|
|
18
|
-
isError:
|
|
19
|
-
value:
|
|
20
|
-
...
|
|
21
|
-
} = h, c =
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
e?.focus(), e?.select();
|
|
17
|
+
errorMessage: l,
|
|
18
|
+
isError: N,
|
|
19
|
+
value: i,
|
|
20
|
+
...C
|
|
21
|
+
} = h, c = b(!1);
|
|
22
|
+
function u(n) {
|
|
23
|
+
document.getElementById(`dgs-ui-kit-otp-input-${n}`)?.focus();
|
|
25
24
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
const s =
|
|
30
|
-
s[
|
|
31
|
-
} else
|
|
25
|
+
function v(n, t) {
|
|
26
|
+
const e = [n.code, n.key];
|
|
27
|
+
if (e.includes("Backspace") || e.includes("Delete")) {
|
|
28
|
+
const s = i.split("");
|
|
29
|
+
s[t] = "", t !== 0 && u(t - 1), a(s.join(""));
|
|
30
|
+
} else e.includes("ArrowLeft") ? u(t - 1) : e.includes("ArrowRight") && u(t + 1);
|
|
32
31
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
m <
|
|
37
|
-
}) : s[
|
|
32
|
+
function w(n, t) {
|
|
33
|
+
const e = n.currentTarget.value, s = i.split("");
|
|
34
|
+
e.length > 1 ? e.split("").forEach((E, m) => {
|
|
35
|
+
m < r && (s[m] = E);
|
|
36
|
+
}) : s[t] = e, a(s.join("")), t + 1 !== r && e && u(t + 1);
|
|
38
37
|
}
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
}, [
|
|
42
|
-
p ? /* @__PURE__ */
|
|
43
|
-
/* @__PURE__ */
|
|
38
|
+
return F(() => {
|
|
39
|
+
i.length === r && c.current ? (c.current = !1, typeof f == "function" && f(i)) : i.length < r && (c.current = !0);
|
|
40
|
+
}, [i]), /* @__PURE__ */ I("div", { className: d("dgs-ui-kit-space-y-2", k), children: [
|
|
41
|
+
p ? /* @__PURE__ */ o(j, { labelContent: p }) : null,
|
|
42
|
+
/* @__PURE__ */ o(
|
|
44
43
|
"div",
|
|
45
44
|
{
|
|
46
45
|
className: d(
|
|
47
46
|
"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2 [direction:ltr]",
|
|
48
47
|
y
|
|
49
48
|
),
|
|
50
|
-
children: Array.from(Array(
|
|
51
|
-
|
|
49
|
+
children: Array.from(Array(r).keys()).map((n, t) => /* @__PURE__ */ o(
|
|
50
|
+
T,
|
|
52
51
|
{
|
|
53
52
|
containerClassName: "dgs-ui-kit-w-12 dgs-ui-kit-h-12 dgs-ui-kit-p-0",
|
|
54
53
|
className: "dgs-ui-kit-w-full dgs-ui-kit-h-full !dgs-ui-kit-text-center placeholder:!dgs-ui-kit-text-center",
|
|
55
54
|
placeholder: "-",
|
|
56
|
-
autoFocus:
|
|
57
|
-
onChange: (
|
|
58
|
-
onKeyUp: (
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
autoFocus: t === 0,
|
|
56
|
+
onChange: (e) => w(e, t),
|
|
57
|
+
onKeyUp: (e) => v(e, t),
|
|
58
|
+
onFocus: (e) => e.currentTarget.select(),
|
|
59
|
+
id: `dgs-ui-kit-otp-input-${t}`,
|
|
60
|
+
value: i[t] || "",
|
|
61
61
|
showMaxLength: !1,
|
|
62
|
-
isError: !!
|
|
62
|
+
isError: !!l || N,
|
|
63
63
|
autoComplete: "off",
|
|
64
64
|
maxLength: 1,
|
|
65
|
-
onPaste: (
|
|
66
|
-
const s =
|
|
67
|
-
Number(s) &&
|
|
65
|
+
onPaste: (e) => {
|
|
66
|
+
const s = e.clipboardData.getData("text");
|
|
67
|
+
Number(s) && a(s);
|
|
68
68
|
},
|
|
69
|
-
|
|
69
|
+
onInput: (e) => {
|
|
70
|
+
const s = e.currentTarget;
|
|
71
|
+
return !!(Number(s.value) && s.value.length > 1);
|
|
72
|
+
},
|
|
73
|
+
...C
|
|
70
74
|
},
|
|
71
|
-
|
|
75
|
+
n
|
|
72
76
|
))
|
|
73
77
|
}
|
|
74
78
|
),
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
l || g ? /* @__PURE__ */ o(
|
|
80
|
+
A,
|
|
77
81
|
{
|
|
78
|
-
errorMessage:
|
|
82
|
+
errorMessage: l,
|
|
79
83
|
hintMessage: g
|
|
80
84
|
}
|
|
81
85
|
) : null
|