@dgshahr/ui-kit 0.0.40 → 0.0.41

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.
@@ -1 +1 @@
1
- "use client";"use strict";require('../../assets/styles.css');const l=require("react/jsx-runtime"),d=require("../../clsx-C11secjj.cjs"),q=require("react"),E=require("../Input/index.cjs"),h=require("../../TextFieldWrapper-BbzQMKCb.cjs");;/* empty css */const I=k=>{const{inputsNumber:u=4,onChange:a,onEnd:r,className:m,inputsContainerClassName:y,labelContent:p,hintMessage:f,errorMessage:c,isError:j,value:n}=k;function o(s){const e=document.getElementById(`dgs-ui-kit-otp-input-${s}`);e?.focus(),e?.select()}function C(s,e){const t=[s.code,s.key];if(t.includes("Backspace")||t.includes("Delete")){const i=n.split("");i[e]="",e!==0&&(i[e-1]="",o(e-1)),a(i.join(""))}else t.includes("ArrowLeft")?o(e-1):t.includes("ArrowRight")&&o(e+1)}function w(s,e){const t=s.currentTarget.value,i=n.split("");t.length>1?t.split("").forEach((N,g)=>{g<u&&(i[g]=N)}):i[e]=t,a(i.join("")),e+1!==u&&t&&o(e+1)}return q.useEffect(()=>{n.length===u&&typeof r=="function"&&r(n)},[n,u,r]),l.jsxs("div",{className:d.clsx("dgs-ui-kit-space-y-2",m),children:[p?l.jsx(h.FieldLabel,{labelContent:p}):null,l.jsx("div",{className:d.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2 [direction:ltr]",y),children:Array.from(Array(u).keys()).map((s,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=>w(t,e),onKeyUp:t=>C(t,e),id:`dgs-ui-kit-otp-input-${e}`,value:n[e]||"",showMaxLength:!1,isError:!!c||j,autoComplete:"off",maxLength:1},s))}),c||f?l.jsx(h.FieldBottomInfo,{errorMessage:c,hintMessage:f}):null]})};module.exports=I;
1
+ "use client";"use strict";require('../../assets/styles.css');const l=require("react/jsx-runtime"),h=require("../../clsx-C11secjj.cjs"),k=require("react"),I=require("../Input/index.cjs"),m=require("../../TextFieldWrapper-BbzQMKCb.cjs");;/* empty css */const v=y=>{const{inputsNumber:u=4,onChange:a,onEnd:f,className:j,inputsContainerClassName:C,labelContent:p,hintMessage:g,errorMessage:c,isError:w,value:n}=y,o=k.useRef(!1);function r(s){const e=document.getElementById(`dgs-ui-kit-otp-input-${s}`);e?.focus(),e?.select()}function E(s,e){const t=[s.code,s.key];if(t.includes("Backspace")||t.includes("Delete")){const i=n.split("");i[e]="",e!==0&&(i[e-1]="",r(e-1)),a(i.join(""))}else t.includes("ArrowLeft")?r(e-1):t.includes("ArrowRight")&&r(e+1)}function N(s,e){const t=s.currentTarget.value,i=n.split("");t.length>1?t.split("").forEach((q,d)=>{d<u&&(i[d]=q)}):i[e]=t,a(i.join("")),e+1!==u&&t&&r(e+1)}return k.useEffect(()=>{n.length===u&&o.current?(o.current=!1,typeof f=="function"&&f(n)):n.length<u&&(o.current=!0)},[n]),l.jsxs("div",{className:h.clsx("dgs-ui-kit-space-y-2",j),children:[p?l.jsx(m.FieldLabel,{labelContent:p}):null,l.jsx("div",{className:h.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2 [direction:ltr]",C),children:Array.from(Array(u).keys()).map((s,e)=>l.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:"-",type:"tel",autoFocus:e===0,onChange:t=>N(t,e),onKeyUp:t=>E(t,e),id:`dgs-ui-kit-otp-input-${e}`,value:n[e]||"",showMaxLength:!1,isError:!!c||w,autoComplete:"off",maxLength:1},s))}),c||g?l.jsx(m.FieldBottomInfo,{errorMessage:c,hintMessage:g}):null]})};module.exports=v;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/OtpInput/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA+B,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAC;AAIjF,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,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,CAoG/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
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;AAIzF,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,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,CA2G/B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,65 +1,65 @@
1
1
  "use client";
2
- import { jsxs as E, jsx as u } from "react/jsx-runtime";
3
- import { c as m } from "../../clsx-OuTLNxxd.js";
4
- import { useEffect as I } from "react";
5
- import v from "../Input/index.js";
6
- import { F as j, a as A } from "../../TextFieldWrapper-D9d-4wo1.js";
2
+ import { jsxs as I, jsx as u } from "react/jsx-runtime";
3
+ import { c as d } from "../../clsx-OuTLNxxd.js";
4
+ import { useRef as v, useEffect as j } from "react";
5
+ import A from "../Input/index.js";
6
+ import { F as B, a as F } from "../../TextFieldWrapper-D9d-4wo1.js";
7
7
  import '../../assets/styles.css';/* empty css */
8
- const K = (d) => {
8
+ const R = (h) => {
9
9
  const {
10
- inputsNumber: n = 4,
10
+ inputsNumber: l = 4,
11
11
  onChange: c,
12
- onEnd: a,
13
- className: h,
14
- inputsContainerClassName: k,
12
+ onEnd: f,
13
+ className: k,
14
+ inputsContainerClassName: y,
15
15
  labelContent: p,
16
- hintMessage: f,
16
+ hintMessage: g,
17
17
  errorMessage: r,
18
- isError: y,
19
- value: o
20
- } = d;
21
- function l(s) {
22
- const t = document.getElementById(`dgs-ui-kit-otp-input-${s}`);
23
- t?.focus(), t?.select();
18
+ isError: C,
19
+ value: i
20
+ } = h, a = v(!1);
21
+ function o(s) {
22
+ const e = document.getElementById(`dgs-ui-kit-otp-input-${s}`);
23
+ e?.focus(), e?.select();
24
24
  }
25
- function C(s, t) {
26
- const e = [s.code, s.key];
27
- if (e.includes("Backspace") || e.includes("Delete")) {
28
- const i = o.split("");
29
- i[t] = "", t !== 0 && (i[t - 1] = "", l(t - 1)), c(i.join(""));
30
- } else e.includes("ArrowLeft") ? l(t - 1) : e.includes("ArrowRight") && l(t + 1);
25
+ function w(s, e) {
26
+ const t = [s.code, s.key];
27
+ if (t.includes("Backspace") || t.includes("Delete")) {
28
+ const n = i.split("");
29
+ n[e] = "", e !== 0 && (n[e - 1] = "", o(e - 1)), c(n.join(""));
30
+ } else t.includes("ArrowLeft") ? o(e - 1) : t.includes("ArrowRight") && o(e + 1);
31
31
  }
32
- function w(s, t) {
33
- const e = s.currentTarget.value, i = o.split("");
34
- e.length > 1 ? e.split("").forEach((N, g) => {
35
- g < n && (i[g] = N);
36
- }) : i[t] = e, c(i.join("")), t + 1 !== n && e && l(t + 1);
32
+ function E(s, e) {
33
+ const t = s.currentTarget.value, n = i.split("");
34
+ t.length > 1 ? t.split("").forEach((N, m) => {
35
+ m < l && (n[m] = N);
36
+ }) : n[e] = t, c(n.join("")), e + 1 !== l && t && o(e + 1);
37
37
  }
38
- return I(() => {
39
- o.length === n && typeof a == "function" && a(o);
40
- }, [o, n, a]), /* @__PURE__ */ E("div", { className: m("dgs-ui-kit-space-y-2", h), children: [
41
- p ? /* @__PURE__ */ u(j, { labelContent: p }) : null,
38
+ return j(() => {
39
+ i.length === l && a.current ? (a.current = !1, typeof f == "function" && f(i)) : i.length < l && (a.current = !0);
40
+ }, [i]), /* @__PURE__ */ I("div", { className: d("dgs-ui-kit-space-y-2", k), children: [
41
+ p ? /* @__PURE__ */ u(B, { labelContent: p }) : null,
42
42
  /* @__PURE__ */ u(
43
43
  "div",
44
44
  {
45
- className: m(
45
+ className: d(
46
46
  "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2 [direction:ltr]",
47
- k
47
+ y
48
48
  ),
49
- children: Array.from(Array(n).keys()).map((s, t) => /* @__PURE__ */ u(
50
- v,
49
+ children: Array.from(Array(l).keys()).map((s, e) => /* @__PURE__ */ u(
50
+ A,
51
51
  {
52
52
  containerClassName: "dgs-ui-kit-w-12 dgs-ui-kit-h-12 dgs-ui-kit-p-0",
53
53
  className: "dgs-ui-kit-w-full dgs-ui-kit-h-full !dgs-ui-kit-text-center placeholder:!dgs-ui-kit-text-center",
54
54
  placeholder: "-",
55
55
  type: "tel",
56
- autoFocus: t === 0,
57
- onChange: (e) => w(e, t),
58
- onKeyUp: (e) => C(e, t),
59
- id: `dgs-ui-kit-otp-input-${t}`,
60
- value: o[t] || "",
56
+ autoFocus: e === 0,
57
+ onChange: (t) => E(t, e),
58
+ onKeyUp: (t) => w(t, e),
59
+ id: `dgs-ui-kit-otp-input-${e}`,
60
+ value: i[e] || "",
61
61
  showMaxLength: !1,
62
- isError: !!r || y,
62
+ isError: !!r || C,
63
63
  autoComplete: "off",
64
64
  maxLength: 1
65
65
  },
@@ -67,15 +67,15 @@ const K = (d) => {
67
67
  ))
68
68
  }
69
69
  ),
70
- r || f ? /* @__PURE__ */ u(
71
- A,
70
+ r || g ? /* @__PURE__ */ u(
71
+ F,
72
72
  {
73
73
  errorMessage: r,
74
- hintMessage: f
74
+ hintMessage: g
75
75
  }
76
76
  ) : null
77
77
  ] });
78
78
  };
79
79
  export {
80
- K as default
80
+ R as default
81
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dgshahr/ui-kit",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "dgshahr ui-kit",
5
5
  "author": "dgshahr",
6
6
  "license": "MIT",