@dgshahr/ui-kit 0.0.27 → 0.0.29
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.map +1 -1
- package/dist/Form/Input/index.js +74 -70
- package/dist/Form/OtpInput/index.cjs +1 -1
- package/dist/Form/OtpInput/index.d.ts +1 -1
- package/dist/Form/OtpInput/index.d.ts.map +1 -1
- package/dist/Form/OtpInput/index.js +52 -51
- 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"),p=require("../../clsx-C11secjj.cjs"),f=require("react"),v=require("../../TextFieldWrapper-BC0mP63G.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"})]}),N=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"})}),I=f.forwardRef(function(r,m){const{dir:s="rtl",placeholderDir:w=s,containerClassName:j,leftIcon:o,prefix:c,postfix:d,isClearOption:a,onClear:u,...l}=r,[x,C]=f.useState(l.type);function h(n){return e.jsx("button",{onClick:()=>{n(""),typeof u=="function"&&u()},children:e.jsx(y,{className:"dgs-ui-kit-text-gray-600",width:20,height:20})})}return e.jsx(v.TextFieldWrapper,{...r,containerClassName:p.clsx("dgs-ui-kit-items-center",j),children:({handleChangeField:n,value:i,setValue:g})=>e.jsxs(e.Fragment,{children:[c&&e.jsx("span",{className:"dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-500",children:c}),a&&i&&i.length>0&&s==="ltr"&&h(g),e.jsx("input",{...l,ref:m,className:p.clsx("dgs-ui-kit-bg-transparent focus:dgs-ui-kit-outline-none dgs-ui-kit-flex-1",s==="rtl"?"dgs-ui-kit-text-right":"!dgs-ui-kit-text-left",w==="rtl"?"placeholder:dgs-ui-kit-text-right":"placeholder:dgs-ui-kit-text-left",{ss02:l.type!="password"},r.className),...s==="ltr"?{style:{direction:"ltr"}}:{},value:i,onChange:n,type:x}),a&&i&&i.length>0&&s==="rtl"&&h(g),d&&e.jsx("span",{className:"dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-500",children:d}),o&&e.jsx("div",{className:"dgs-ui-kit-text-gray-600",children:o}),l.type==="password"&&e.jsx("button",{onClick:()=>C(k=>k==="text"?"password":"text"),className:"dgs-ui-kit-text-gray-600",children:x==="password"?e.jsx(R,{width:20,height:20}):e.jsx(N,{width:20,height:20})})]})})});module.exports=I;
|
|
@@ -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;AAK1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAExF,UAAU,UACR,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,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,KAAK,
|
|
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;AAK1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AAExF,UAAU,UACR,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,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,KAAK,yGAiGT,CAAC;AACH,eAAe,KAAK,CAAC"}
|
package/dist/Form/Input/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { c as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { T as
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as o, jsx as t, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { c as f } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import { forwardRef as N, useState as R } from "react";
|
|
4
|
+
import { T as I } from "../../TextFieldWrapper-Dva9vxfn.js";
|
|
5
|
+
const M = (e) => /* @__PURE__ */ o(
|
|
6
6
|
"svg",
|
|
7
7
|
{
|
|
8
8
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -10,9 +10,9 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
10
10
|
height: "1em",
|
|
11
11
|
fill: "none",
|
|
12
12
|
viewBox: "0 0 24 24",
|
|
13
|
-
...
|
|
13
|
+
...e,
|
|
14
14
|
children: [
|
|
15
|
-
/* @__PURE__ */
|
|
15
|
+
/* @__PURE__ */ t(
|
|
16
16
|
"path",
|
|
17
17
|
{
|
|
18
18
|
fill: "currentColor",
|
|
@@ -21,7 +21,7 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
21
21
|
clipRule: "evenodd"
|
|
22
22
|
}
|
|
23
23
|
),
|
|
24
|
-
/* @__PURE__ */
|
|
24
|
+
/* @__PURE__ */ t(
|
|
25
25
|
"path",
|
|
26
26
|
{
|
|
27
27
|
fill: "currentColor",
|
|
@@ -30,7 +30,7 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
30
30
|
clipRule: "evenodd"
|
|
31
31
|
}
|
|
32
32
|
),
|
|
33
|
-
/* @__PURE__ */
|
|
33
|
+
/* @__PURE__ */ t(
|
|
34
34
|
"path",
|
|
35
35
|
{
|
|
36
36
|
fill: "currentColor",
|
|
@@ -41,7 +41,7 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
41
41
|
)
|
|
42
42
|
]
|
|
43
43
|
}
|
|
44
|
-
),
|
|
44
|
+
), z = (e) => /* @__PURE__ */ o(
|
|
45
45
|
"svg",
|
|
46
46
|
{
|
|
47
47
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -49,16 +49,16 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
49
49
|
height: "1em",
|
|
50
50
|
fill: "none",
|
|
51
51
|
viewBox: "0 0 24 24",
|
|
52
|
-
...
|
|
52
|
+
...e,
|
|
53
53
|
children: [
|
|
54
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ t(
|
|
55
55
|
"path",
|
|
56
56
|
{
|
|
57
57
|
fill: "currentColor",
|
|
58
58
|
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"
|
|
59
59
|
}
|
|
60
60
|
),
|
|
61
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ t(
|
|
62
62
|
"path",
|
|
63
63
|
{
|
|
64
64
|
fill: "currentColor",
|
|
@@ -67,7 +67,7 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
67
67
|
)
|
|
68
68
|
]
|
|
69
69
|
}
|
|
70
|
-
),
|
|
70
|
+
), B = (e) => /* @__PURE__ */ t(
|
|
71
71
|
"svg",
|
|
72
72
|
{
|
|
73
73
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -75,8 +75,8 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
75
75
|
height: "1em",
|
|
76
76
|
fill: "none",
|
|
77
77
|
viewBox: "0 0 24 24",
|
|
78
|
-
...
|
|
79
|
-
children: /* @__PURE__ */
|
|
78
|
+
...e,
|
|
79
|
+
children: /* @__PURE__ */ t(
|
|
80
80
|
"path",
|
|
81
81
|
{
|
|
82
82
|
fill: "currentColor",
|
|
@@ -86,76 +86,80 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
86
86
|
}
|
|
87
87
|
)
|
|
88
88
|
}
|
|
89
|
-
),
|
|
89
|
+
), j = N(function(n, w) {
|
|
90
90
|
const {
|
|
91
|
-
dir:
|
|
92
|
-
placeholderDir:
|
|
93
|
-
containerClassName:
|
|
94
|
-
leftIcon:
|
|
95
|
-
prefix:
|
|
96
|
-
postfix:
|
|
97
|
-
isClearOption:
|
|
98
|
-
onClear:
|
|
99
|
-
...
|
|
100
|
-
} =
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
dir: i = "rtl",
|
|
92
|
+
placeholderDir: x = i,
|
|
93
|
+
containerClassName: C,
|
|
94
|
+
leftIcon: a,
|
|
95
|
+
prefix: d,
|
|
96
|
+
postfix: c,
|
|
97
|
+
isClearOption: h,
|
|
98
|
+
onClear: g,
|
|
99
|
+
...r
|
|
100
|
+
} = n, [u, k] = R(r.type);
|
|
101
|
+
function p(s) {
|
|
102
|
+
return /* @__PURE__ */ t(
|
|
103
|
+
"button",
|
|
104
|
+
{
|
|
105
|
+
onClick: () => {
|
|
106
|
+
s(""), typeof g == "function" && g();
|
|
107
|
+
},
|
|
108
|
+
children: /* @__PURE__ */ t(
|
|
109
|
+
M,
|
|
110
|
+
{
|
|
111
|
+
className: "dgs-ui-kit-text-gray-600",
|
|
112
|
+
width: 20,
|
|
113
|
+
height: 20
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
return /* @__PURE__ */ t(
|
|
120
|
+
I,
|
|
103
121
|
{
|
|
104
|
-
...
|
|
105
|
-
containerClassName:
|
|
106
|
-
children: ({ handleChangeField:
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
...n,
|
|
123
|
+
containerClassName: f("dgs-ui-kit-items-center", C),
|
|
124
|
+
children: ({ handleChangeField: s, value: l, setValue: m }) => /* @__PURE__ */ o(y, { children: [
|
|
125
|
+
d && /* @__PURE__ */ t("span", { className: "dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-500", children: d }),
|
|
126
|
+
h && l && l.length > 0 && i === "ltr" && p(m),
|
|
127
|
+
/* @__PURE__ */ t(
|
|
109
128
|
"input",
|
|
110
129
|
{
|
|
111
|
-
...
|
|
112
|
-
ref:
|
|
113
|
-
className:
|
|
130
|
+
...r,
|
|
131
|
+
ref: w,
|
|
132
|
+
className: f(
|
|
114
133
|
"dgs-ui-kit-bg-transparent focus:dgs-ui-kit-outline-none dgs-ui-kit-flex-1",
|
|
115
|
-
|
|
116
|
-
|
|
134
|
+
i === "rtl" ? "dgs-ui-kit-text-right" : "!dgs-ui-kit-text-left",
|
|
135
|
+
x === "rtl" ? "placeholder:dgs-ui-kit-text-right" : "placeholder:dgs-ui-kit-text-left",
|
|
117
136
|
{
|
|
118
|
-
ss02:
|
|
137
|
+
ss02: r.type != "password"
|
|
119
138
|
},
|
|
120
|
-
|
|
139
|
+
n.className
|
|
121
140
|
),
|
|
122
|
-
...
|
|
123
|
-
value:
|
|
124
|
-
onChange:
|
|
125
|
-
type:
|
|
126
|
-
}
|
|
127
|
-
),
|
|
128
|
-
f && s && s.length > 0 && /* @__PURE__ */ e(
|
|
129
|
-
"button",
|
|
130
|
-
{
|
|
131
|
-
onClick: () => {
|
|
132
|
-
k(""), typeof c == "function" && c();
|
|
133
|
-
},
|
|
134
|
-
children: /* @__PURE__ */ e(
|
|
135
|
-
I,
|
|
136
|
-
{
|
|
137
|
-
className: "dgs-ui-kit-text-gray-600",
|
|
138
|
-
width: 20,
|
|
139
|
-
height: 20
|
|
140
|
-
}
|
|
141
|
-
)
|
|
141
|
+
...i === "ltr" ? { style: { direction: "ltr" } } : {},
|
|
142
|
+
value: l,
|
|
143
|
+
onChange: s,
|
|
144
|
+
type: u
|
|
142
145
|
}
|
|
143
146
|
),
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
h && l && l.length > 0 && i === "rtl" && p(m),
|
|
148
|
+
c && /* @__PURE__ */ t("span", { className: "dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-500", children: c }),
|
|
149
|
+
a && /* @__PURE__ */ t("div", { className: "dgs-ui-kit-text-gray-600", children: a }),
|
|
150
|
+
r.type === "password" && /* @__PURE__ */ t(
|
|
147
151
|
"button",
|
|
148
152
|
{
|
|
149
|
-
onClick: () =>
|
|
153
|
+
onClick: () => k((v) => v === "text" ? "password" : "text"),
|
|
150
154
|
className: "dgs-ui-kit-text-gray-600",
|
|
151
|
-
children:
|
|
152
|
-
|
|
155
|
+
children: u === "password" ? /* @__PURE__ */ t(
|
|
156
|
+
z,
|
|
153
157
|
{
|
|
154
158
|
width: 20,
|
|
155
159
|
height: 20
|
|
156
160
|
}
|
|
157
|
-
) : /* @__PURE__ */
|
|
158
|
-
|
|
161
|
+
) : /* @__PURE__ */ t(
|
|
162
|
+
B,
|
|
159
163
|
{
|
|
160
164
|
width: 20,
|
|
161
165
|
height: 20
|
|
@@ -168,5 +172,5 @@ const I = (t) => /* @__PURE__ */ n(
|
|
|
168
172
|
);
|
|
169
173
|
});
|
|
170
174
|
export {
|
|
171
|
-
|
|
175
|
+
j as default
|
|
172
176
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";require('../../assets/styles.css');const l=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";require('../../assets/styles.css');const l=require("react/jsx-runtime"),k=require("../../clsx-C11secjj.cjs"),y=require("react"),E=require("../Input/index.cjs"),m=require("../../TextFieldWrapper-BC0mP63G.cjs");;/* empty css */const F=j=>{const{inputsNumber:c=4,onChange:o,onEnd:r,className:C,inputsContainerClassName:I,labelContent:d,hintMessage:h,errorMessage:f,isError:v,value:n}=j,[a,p]=y.useState([]);function u(i){const e=document.getElementById(`dgs-ui-kit-otp-input-${i}`);e?.focus(),e?.select()}function w(i,e){const t=[i.code,i.key];if(t.includes("Backspace")||t.includes("Delete")){const s=[...a];s[e]="",e!==0&&(s[e-1]="",u(e-1)),p(s)}else t.includes("ArrowLeft")?u(e+1):t.includes("ArrowRight")&&u(e-1);t.includes(a[e])&&u(e)}function N(i,e){const t=i.currentTarget.value,s=[...a];t.length>1?t.split("").forEach((g,q)=>s[q]=g):s[e]=t,e+1!==c&&t?u(e+1):typeof r=="function"&&s.every(g=>!!g)&&((typeof o=="function"&&!n||typeof o!="function"&&n||typeof o!="function"&&!n||n!==s.join(""))&&r(s.join("")),u(c-1)),p(s),typeof o=="function"&&o(s.join(""))}return y.useEffect(()=>{if(n){const i=n.split("");p(i);const e=c===n.length;u(n.length),e&&typeof r=="function"&&r(n)}},[n]),l.jsxs("div",{className:k.clsx("dgs-ui-kit-space-y-2",C),children:[d?l.jsx(m.FieldLabel,{labelContent:d}):null,l.jsx("div",{className:k.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2",I),children:Array.from(Array(c).keys()).map((i,e)=>l.jsx(E,{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:"-",type:"tel",autoFocus:e===0,onChange:t=>N(t,e),onKeyUp:t=>w(t,e),id:`dgs-ui-kit-otp-input-${e}`,value:a[e],showMaxLength:!1,isError:!!f||v,autoComplete:"off"},i))}),f||h?l.jsx(m.FieldBottomInfo,{errorMessage:f,hintMessage:h}):null]})};module.exports=F;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { TextFieldBaseProps } from '../Wrappers/TextFieldWrapper/TextFieldWrapper';
|
|
3
|
-
interface OtpInputProps extends Pick<TextFieldBaseProps, 'labelContent' | 'errorMessage' | 'isError' | 'hintMessage'> {
|
|
3
|
+
export interface OtpInputProps extends Pick<TextFieldBaseProps, 'labelContent' | 'errorMessage' | 'isError' | 'hintMessage'> {
|
|
4
4
|
inputsNumber?: number;
|
|
5
5
|
onChange?: (value: string) => void;
|
|
6
6
|
onEnd?: (value: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/OtpInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,kBAAkB,CAAC;AAE1B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/OtpInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAI3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,kBAAkB,CAAC;AAE1B,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,cAAc,GAAG,cAAc,GAAG,SAAS,GAAG,aAAa,CAAC;IAC7F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,QAAA,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CA6G/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,83 +1,84 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { c as
|
|
4
|
-
import { useState as
|
|
5
|
-
import
|
|
2
|
+
import { jsxs as E, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { c as h } from "../../clsx-OuTLNxxd.js";
|
|
4
|
+
import { useState as V, useEffect as j } from "react";
|
|
5
|
+
import B from "../Input/index.js";
|
|
6
6
|
import { F, a as A } from "../../TextFieldWrapper-Dva9vxfn.js";
|
|
7
7
|
import '../../assets/styles.css';/* empty css */
|
|
8
|
-
const
|
|
8
|
+
const U = (k) => {
|
|
9
9
|
const {
|
|
10
10
|
inputsNumber: u = 4,
|
|
11
|
-
onChange:
|
|
12
|
-
onEnd:
|
|
13
|
-
className:
|
|
14
|
-
inputsContainerClassName:
|
|
15
|
-
labelContent:
|
|
16
|
-
hintMessage:
|
|
17
|
-
errorMessage:
|
|
11
|
+
onChange: l,
|
|
12
|
+
onEnd: a,
|
|
13
|
+
className: y,
|
|
14
|
+
inputsContainerClassName: C,
|
|
15
|
+
labelContent: m,
|
|
16
|
+
hintMessage: d,
|
|
17
|
+
errorMessage: f,
|
|
18
18
|
isError: I,
|
|
19
|
-
value:
|
|
20
|
-
} =
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
|
|
19
|
+
value: o
|
|
20
|
+
} = k, [c, p] = V([]);
|
|
21
|
+
function n(i) {
|
|
22
|
+
const e = document.getElementById(`dgs-ui-kit-otp-input-${i}`);
|
|
23
|
+
e?.focus(), e?.select();
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
} else
|
|
25
|
+
function v(i, e) {
|
|
26
|
+
const t = [i.code, i.key];
|
|
27
|
+
if (t.includes("Backspace") || t.includes("Delete")) {
|
|
28
|
+
const s = [...c];
|
|
29
|
+
s[e] = "", e !== 0 && (s[e - 1] = "", n(e - 1)), p(s);
|
|
30
|
+
} else t.includes("ArrowLeft") ? n(e + 1) : t.includes("ArrowRight") && n(e - 1);
|
|
31
|
+
t.includes(c[e]) && n(e);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
function w(i, e) {
|
|
34
|
+
const t = i.currentTarget.value, s = [...c];
|
|
35
|
+
t.length > 1 ? t.split("").forEach((g, N) => s[N] = g) : s[e] = t, e + 1 !== u && t ? n(e + 1) : typeof a == "function" && s.every((g) => !!g) && ((typeof l == "function" && !o || typeof l != "function" && o || typeof l != "function" && !o || o !== s.join("")) && a(s.join("")), n(u - 1)), p(s), typeof l == "function" && l(s.join(""));
|
|
35
36
|
}
|
|
36
|
-
return
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
o
|
|
37
|
+
return j(() => {
|
|
38
|
+
if (o) {
|
|
39
|
+
const i = o.split("");
|
|
40
|
+
p(i);
|
|
41
|
+
const e = u === o.length;
|
|
42
|
+
n(o.length), e && typeof a == "function" && a(o);
|
|
42
43
|
}
|
|
43
|
-
}, [
|
|
44
|
-
|
|
45
|
-
/* @__PURE__ */
|
|
44
|
+
}, [o]), /* @__PURE__ */ E("div", { className: h("dgs-ui-kit-space-y-2", y), children: [
|
|
45
|
+
m ? /* @__PURE__ */ r(F, { labelContent: m }) : null,
|
|
46
|
+
/* @__PURE__ */ r(
|
|
46
47
|
"div",
|
|
47
48
|
{
|
|
48
|
-
className:
|
|
49
|
+
className: h(
|
|
49
50
|
"dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2",
|
|
50
|
-
|
|
51
|
+
C
|
|
51
52
|
),
|
|
52
|
-
children: Array.from(Array(u).keys()).map((
|
|
53
|
-
|
|
53
|
+
children: Array.from(Array(u).keys()).map((i, e) => /* @__PURE__ */ r(
|
|
54
|
+
B,
|
|
54
55
|
{
|
|
55
56
|
containerClassName: "dgs-ui-kit-w-12 dgs-ui-kit-h-12 dgs-ui-kit-p-0",
|
|
56
57
|
className: "dgs-ui-kit-w-full dgs-ui-kit-h-full !dgs-ui-kit-text-center placeholder:!dgs-ui-kit-text-center",
|
|
57
58
|
placeholder: "-",
|
|
58
59
|
type: "tel",
|
|
59
|
-
autoFocus:
|
|
60
|
-
onChange: (
|
|
61
|
-
onKeyUp: (
|
|
62
|
-
id: `dgs-ui-kit-otp-input-${
|
|
63
|
-
|
|
64
|
-
value: r[t],
|
|
60
|
+
autoFocus: e === 0,
|
|
61
|
+
onChange: (t) => w(t, e),
|
|
62
|
+
onKeyUp: (t) => v(t, e),
|
|
63
|
+
id: `dgs-ui-kit-otp-input-${e}`,
|
|
64
|
+
value: c[e],
|
|
65
65
|
showMaxLength: !1,
|
|
66
|
-
isError: !!
|
|
66
|
+
isError: !!f || I,
|
|
67
|
+
autoComplete: "off"
|
|
67
68
|
},
|
|
68
|
-
|
|
69
|
+
i
|
|
69
70
|
))
|
|
70
71
|
}
|
|
71
72
|
),
|
|
72
|
-
|
|
73
|
+
f || d ? /* @__PURE__ */ r(
|
|
73
74
|
A,
|
|
74
75
|
{
|
|
75
|
-
errorMessage:
|
|
76
|
-
hintMessage:
|
|
76
|
+
errorMessage: f,
|
|
77
|
+
hintMessage: d
|
|
77
78
|
}
|
|
78
79
|
) : null
|
|
79
80
|
] });
|
|
80
81
|
};
|
|
81
82
|
export {
|
|
82
|
-
|
|
83
|
+
U as default
|
|
83
84
|
};
|