@dgshahr/ui-kit 0.0.27 → 0.0.28

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"),h=require("../../clsx-C11secjj.cjs"),k=require("react"),q=require("../Input/index.cjs"),m=require("../../TextFieldWrapper-BC0mP63G.cjs");;/* empty css */const v=y=>{const{inputsNumber:o=4,onChange:p,onEnd:f,className:I,inputsContainerClassName:j,labelContent:g,hintMessage:d,errorMessage:c,isError:w,value:i}=y,[r,a]=k.useState([]);function u(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 n=[...r];n[e]="",e!==0&&(n[e-1]="",u(e-1)),a(n)}else t.includes("ArrowLeft")?u(e+1):t.includes("ArrowRight")&&u(e-1)}function N(s,e){const t=s.currentTarget.value,n=[...r];n[e]=t,e+1!==o&&t&&u(e+1),a(n),typeof p=="function"&&p(n.join(""))}return k.useEffect(()=>{if(i){const s=i.split("");a(s);const e=o===i.length;u(i.length),e&&typeof f=="function"&&f(i)}},[i]),l.jsxs("div",{className:h.clsx("dgs-ui-kit-space-y-2",I),children:[g?l.jsx(m.FieldLabel,{labelContent:g}):null,l.jsx("div",{className:h.clsx("dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2",j),children:Array.from(Array(o).keys()).map((s,e)=>l.jsx(q,{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=>C(t,e),id:`dgs-ui-kit-otp-input-${e}`,maxLength:1,value:r[e],showMaxLength:!1,isError:!!c||w},s))}),c||d?l.jsx(m.FieldBottomInfo,{errorMessage:c,hintMessage:d}):null]})};module.exports=v;
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,UAAU,aACR,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,CA4F/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,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 N, jsx as l } from "react/jsx-runtime";
3
- import { c as d } from "../../clsx-OuTLNxxd.js";
4
- import { useState as v, useEffect as V } from "react";
5
- import E from "../Input/index.js";
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 O = (h) => {
8
+ const U = (k) => {
9
9
  const {
10
10
  inputsNumber: u = 4,
11
- onChange: p,
12
- onEnd: f,
13
- className: k,
14
- inputsContainerClassName: y,
15
- labelContent: g,
16
- hintMessage: m,
17
- errorMessage: a,
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: n
20
- } = h, [r, c] = v([]);
21
- function o(s) {
22
- const t = document.getElementById(`dgs-ui-kit-otp-input-${s}`);
23
- t?.focus(), t?.select();
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 w(s, t) {
26
- const e = [s.code, s.key];
27
- if (e.includes("Backspace") || e.includes("Delete")) {
28
- const i = [...r];
29
- i[t] = "", t !== 0 && (i[t - 1] = "", o(t - 1)), c(i);
30
- } else e.includes("ArrowLeft") ? o(t + 1) : e.includes("ArrowRight") && o(t - 1);
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 C(s, t) {
33
- const e = s.currentTarget.value, i = [...r];
34
- i[t] = e, t + 1 !== u && e && o(t + 1), c(i), typeof p == "function" && p(i.join(""));
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 V(() => {
37
- if (n) {
38
- const s = n.split("");
39
- c(s);
40
- const t = u === n.length;
41
- o(n.length), t && typeof f == "function" && f(n);
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
- }, [n]), /* @__PURE__ */ N("div", { className: d("dgs-ui-kit-space-y-2", k), children: [
44
- g ? /* @__PURE__ */ l(F, { labelContent: g }) : null,
45
- /* @__PURE__ */ l(
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: d(
49
+ className: h(
49
50
  "dgs-ui-kit-flex dgs-ui-kit-items-center dgs-ui-kit-gap-2",
50
- y
51
+ C
51
52
  ),
52
- children: Array.from(Array(u).keys()).map((s, t) => /* @__PURE__ */ l(
53
- E,
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: t === 0,
60
- onChange: (e) => C(e, t),
61
- onKeyUp: (e) => w(e, t),
62
- id: `dgs-ui-kit-otp-input-${t}`,
63
- maxLength: 1,
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: !!a || I
66
+ isError: !!f || I,
67
+ autoComplete: "off"
67
68
  },
68
- s
69
+ i
69
70
  ))
70
71
  }
71
72
  ),
72
- a || m ? /* @__PURE__ */ l(
73
+ f || d ? /* @__PURE__ */ r(
73
74
  A,
74
75
  {
75
- errorMessage: a,
76
- hintMessage: m
76
+ errorMessage: f,
77
+ hintMessage: d
77
78
  }
78
79
  ) : null
79
80
  ] });
80
81
  };
81
82
  export {
82
- O as default
83
+ U as default
83
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dgshahr/ui-kit",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "dgshahr ui-kit",
5
5
  "author": "dgshahr",
6
6
  "license": "MIT",