@dgshahr/ui-kit 1.9.1 → 1.9.2

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 strict";const g=require("react/jsx-runtime"),x=require("react"),D=require("../../DateAndTimePickerFooter-DVZyqJ2K.cjs"),y=require("../../index-BfuaA-Ji.cjs"),j=require("../../clsx-C11secjj.cjs"),A=require("../../index-CZRRnYAI.cjs"),H=x.createContext({timePickerProps:{value:new Date,onChange:()=>{}}}),$=t=>{const{children:e,timePickerProps:n}=t;return g.jsx(H.Provider,{value:{timePickerProps:n},children:e})},V=()=>x.useContext(H),S=[0,1,3,4],B=t=>t[0]?.getBoundingClientRect().height??64,E=(t,e,n,r,s="instant")=>{if(!t)return;const i=e.indexOf(n);i!==-1&&t.scrollTo({top:i*r(),behavior:s})},I=t=>{if(t.length!==2)return!1;const e=Number(t);return!Number.isNaN(e)&&e>=0&&e<=23},F=t=>{if(t.length!==2)return!1;const e=Number(t);return!Number.isNaN(e)&&e>=0&&e<=59},R=t=>{if(!t)return["-","-",":","-","-"];const e=t.hour==null?"--":String(t.hour).padStart(2,"0"),n=t.minute==null?"--":String(t.minute).padStart(2,"0");return[e.charAt(0)??"-",e.charAt(1)??"-",":",n.charAt(0)??"-",n.charAt(1)??"-"]},C=t=>{const e=`${t[0]??"-"}${t[1]??"-"}`,n=`${t[3]}${t[4]}`;return{hour:!e.includes("-")&&I(e)?Number(e):null,minute:!n.includes("-")&&F(n)?Number(n):null}},P=(t,e=!0)=>{const n=S.indexOf(t);if(n===-1)return e?S[0]:S[S.length-1]??0;const r=e?n+1:n-1;return r<0?S[0]:r>=S.length?S[S.length-1]??0:S[r]??0},q=(t,e,n)=>e===0?/[0-2]/.test(t):e===1?+`${n[0]==="-"?"0":n[0]}${t}`<=23:e===3?/[0-5]/.test(t):!0,W=()=>{const t=x.useRef(null);return{inputRef:t,setCaretToEditable:(n,r=!0)=>{const s=t.current;if(!s)return;const i=S.includes(n)?n:P(n,r);typeof i=="number"&&s.setSelectionRange(i,i+1)}}},K=t=>{const{value:e={hour:null,minute:null},onChange:n,disabled:r=!1,className:s,...i}=t,{inputRef:m,setCaretToEditable:l}=W(),[a,u]=x.useState(()=>R(e)),o=x.useRef(e);x.useEffect(()=>{(e.hour!==o.current.hour||e.minute!==o.current.minute)&&(o.current=e,u(R(e)))},[e]);const p=()=>{const f=m.current;if(!f)return;const h=f.selectionStart??0;S.includes(h)||l(h,!0)},b=(f,h)=>{const k=f==="ArrowRight";l(P(h,k),k)},d=(f,h)=>{const k=S.includes(h)?h:P(h,!1),c=[...a];c[k]="-",u(c),n(C(c));const w=f==="Backspace"?P(k,!1):P(k,!0);setTimeout(()=>l(w,f!=="Backspace"),0)},N=(f,h)=>{const k=S.includes(h)?h:P(h,!0),c=[...a];q(f,k,c)&&(c[k]=f,u(c),n(C(c)),setTimeout(()=>l(P(k,!0),!0),0))},T=f=>{if(f.preventDefault(),r)return;const h=m.current;if(!h)return;const k=h.selectionStart??0;if(["ArrowLeft","ArrowRight"].includes(f.key)){b(f.key,k);return}if(["Backspace","Delete"].includes(f.key)){d(f.key,k);return}/^\d$/.test(f.key)&&N(f.key,k)};return g.jsx(A.Input,{ref:m,dir:"ltr",className:s,value:a.join(""),onKeyDown:T,onFocus:p,disabled:r,inputMode:"numeric",pattern:"[0-9:]*",...i})},L=({timePickerProps:t,setActivePart:e,handleSingleTimeChange:n,handleRangeTimeChange:r})=>{const{acceptRange:s,value:i}=t,m=a=>({hour:a?.getHours()??0,minute:a?.getMinutes()??0}),l=s?[{key:"start",id:"from-time",label:"از ساعت",value:m(i?.start),className:"dgsuikit:w-1/2"},{key:"end",id:"to-time",label:"تا ساعت",value:m(i?.end),className:"dgsuikit:w-1/2"}]:[{key:"single",id:"time",label:"ساعت",value:m(i),className:void 0}];return g.jsx("div",{className:j.clsx(s&&"dgsuikit:flex dgsuikit:justify-between dgsuikit:gap-4 dgsuikit:mb-4"),children:l.map(({key:a,id:u,label:o,value:p,className:b})=>g.jsx(K,{id:u,value:p,labelContent:o,className:b,onFocus:()=>{s&&a!=="single"&&e(a)},onChange:d=>{typeof d.hour=="number"&&typeof d.minute=="number"&&(s&&a!=="single"?r(a,d.hour,d.minute):n(d.hour,d.minute))}},u))})},M=({position:t})=>g.jsx("div",{className:j.clsx("dgsuikit:absolute dgsuikit:left-0 dgsuikit:right-0 dgsuikit:h-12 dgsuikit:pointer-events-none","dgsuikit:from-[rgba(255,255,255,0.54)] dgsuikit:to-[rgba(255,255,255,0.90)]",t==="top"?"dgsuikit:bg-gradient-to-t dgsuikit:top-0":"dgsuikit:bg-gradient-to-b dgsuikit:bottom-0")});function O(t,e,n){const r=x.useRef(null),s=x.useRef([]),i=x.useRef(null),m=()=>B(s.current),l=(u=e??0,o="smooth")=>{E(r.current,t,u,m,o),i.current=u},a=u=>{const o=Math.round(u.scrollTop/m()),p=t[Math.max(0,Math.min(o,t.length-1))];p!=null&&p!==i.current&&(i.current=p,n(p))};return x.useEffect(()=>{const u=r.current;if(!u)return;const o=()=>a(u);return u.addEventListener("scroll",o),()=>u.removeEventListener("scroll",o)},[t]),x.useEffect(()=>{e!=null&&l()},[e]),{containerRef:r,itemRefs:s}}const v=t=>{const{items:e,defaultValue:n,onValueChange:r,className:s,formatValue:i=a=>String(a).padStart(2,"0")}=t,{containerRef:m,itemRefs:l}=O(e,n,r);return g.jsxs("div",{className:"dgsuikit:relative dgsuikit:h-28 dgsuikit:w-full",children:[g.jsx("div",{ref:m,className:j.clsx("dgsuikit:h-28 dgsuikit:w-full dgsuikit:py-10 dgsuikit:overflow-y-scroll dgsuikit:snap-y dgsuikit:snap-mandatory dgsuikit:scroll-smooth dgsuikit:no-scrollbar",s),children:e.map((a,u)=>g.jsx("div",{ref:o=>{l.current[u]=o},className:"dgsuikit:h-10 dgsuikit:flex dgsuikit:items-center dgsuikit:justify-center dgsuikit:snap-center dgsuikit:font-p1-regular",children:i(a)},a))}),g.jsx(M,{position:"top"}),g.jsx(M,{position:"bottom"})]})},_=t=>{const{timePickerProps:e,activePart:n,handleSingleTimeChange:r,handleRangeTimeChange:s}=t,{minuteStep:i=1,acceptRange:m,value:l}=e,a=Array.from({length:24},(c,w)=>w),u=Array.from({length:60},(c,w)=>w).filter(c=>c%i===0),o=c=>c.toString().padStart(2,"0"),p=c=>c.toString().padStart(2,"0"),b=c=>{if(m){const w=n==="start"?l?.start:l?.end;return w?w[c]():0}return l?l[c]():0},d=b("getHours"),N=b("getMinutes"),[T,f]=x.useState(N),[h,k]=x.useState(d);return x.useEffect(()=>{m?s(n,h,T):r(h,T)},[h,T]),g.jsxs("div",{className:"dgsuikit:flex dgsuikit:mt-2 dgsuikit:w-full dgsuikit:justify-center",children:[g.jsx(v,{items:u,defaultValue:N,onValueChange:c=>f(c),formatValue:p}),g.jsx(v,{items:a,defaultValue:d,onValueChange:c=>k(c),formatValue:o})]})},G=()=>{const{timePickerProps:t}=V(),{acceptRange:e,value:n,onChange:r}=t,[s,i]=x.useState("start"),m=(o,p,b)=>{const d=new Date(o);return d.setHours(p),d.setMinutes(b),d.setSeconds(0),d.setMilliseconds(0),d},l=y.debounce((o,p)=>{!n||e||n.getHours()===o&&n.getMinutes()===p||r(m(n,o,p))},200),a=y.debounce((o,p,b)=>{if(!n||!e)return;const d=new Date(n[o]??new Date);d.getHours()===p&&d.getMinutes()===b||r({...n,[o]:m(d,p,b)})},200),u={timePickerProps:t,handleSingleTimeChange:l,handleRangeTimeChange:a};return g.jsxs("div",{dir:"rtl",className:"dgsuikit:p-4 dgsuikit:ss02",children:[g.jsx(L,{setActivePart:i,...u}),g.jsx(_,{activePart:s,...u})]})},z=()=>{const{timePickerProps:t}=V(),{showSubmitButton:e=!0,showNowButton:n=!0,onSubmit:r,onChange:s,acceptRange:i}=t,m=()=>{if(i){const l=new Date;l.setHours(l.getHours()+1),s({start:new Date,end:l})}else s(new Date)};return g.jsx(D.DateAndTimePickerFooter,{...e&&{primaryButton:{onClick:r,children:"اعمال"}},...n&&{secondaryButton:{variant:"text",onClick:m,children:"رفتن به اکنون"}},className:"dgsuikit:p-4"})};function J(t){if(!t)return"";if(t instanceof Date){const e=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0");return`${e}:${n}`}if(t.start&&t.end){const e=t.start.getHours().toString().padStart(2,"0"),n=t.start.getMinutes().toString().padStart(2,"0"),r=t.end.getHours().toString().padStart(2,"0"),s=t.end.getMinutes().toString().padStart(2,"0");return`${e}:${n} - ${r}:${s}`}return""}const Q=t=>{const{showSubmitButton:e=!0,showNowButton:n=!0}=t,{Wrapper:r,wrapperProps:s}=D.useDateAndTimePickerWrapper({props:t,standaloneMode:"time",formatValue:J});return g.jsx(r,{...s,children:g.jsxs($,{timePickerProps:t,children:[g.jsx(G,{}),(e||n)&&g.jsx(z,{})]})})};module.exports=Q;
1
+ "use strict";const g=require("react/jsx-runtime"),x=require("react"),D=require("../../DateAndTimePickerFooter-DVZyqJ2K.cjs"),j=require("../../index-BfuaA-Ji.cjs"),N=require("../../clsx-C11secjj.cjs"),A=require("../../index-CZRRnYAI.cjs"),H=x.createContext({timePickerProps:{value:new Date,onChange:()=>{}}}),$=t=>{const{children:e,timePickerProps:n}=t;return g.jsx(H.Provider,{value:{timePickerProps:n},children:e})},V=()=>x.useContext(H),S=[0,1,3,4],B=t=>t[0]?.getBoundingClientRect().height??64,E=(t,e,n,s,r="instant")=>{if(!t)return;const i=e.indexOf(n);i!==-1&&t.scrollTo({top:i*s(),behavior:r})},I=t=>{if(t.length!==2)return!1;const e=Number(t);return!Number.isNaN(e)&&e>=0&&e<=23},F=t=>{if(t.length!==2)return!1;const e=Number(t);return!Number.isNaN(e)&&e>=0&&e<=59},y=t=>{if(!t)return["-","-",":","-","-"];const e=t.hour==null?"--":String(t.hour).padStart(2,"0"),n=t.minute==null?"--":String(t.minute).padStart(2,"0");return[e.charAt(0)??"-",e.charAt(1)??"-",":",n.charAt(0)??"-",n.charAt(1)??"-"]},C=t=>{const e=`${t[0]??"-"}${t[1]??"-"}`,n=`${t[3]}${t[4]}`;return{hour:!e.includes("-")&&I(e)?Number(e):null,minute:!n.includes("-")&&F(n)?Number(n):null}},P=(t,e=!0)=>{const n=S.indexOf(t);if(n===-1)return e?S[0]:S[S.length-1]??0;const s=e?n+1:n-1;return s<0?S[0]:s>=S.length?S[S.length-1]??0:S[s]??0},q=(t,e,n)=>e===0?/[0-2]/.test(t):e===1?+`${n[0]==="-"?"0":n[0]}${t}`<=23:e===3?/[0-5]/.test(t):!0,W=()=>{const t=x.useRef(null);return{inputRef:t,setCaretToEditable:(n,s=!0)=>{const r=t.current;if(!r)return;const i=S.includes(n)?n:P(n,s);typeof i=="number"&&r.setSelectionRange(i,i+1)}}},K=t=>{const{value:e={hour:null,minute:null},onChange:n,disabled:s=!1,className:r,...i}=t,{inputRef:f,setCaretToEditable:l}=W(),[a,u]=x.useState(()=>y(e)),o=x.useRef(e);x.useEffect(()=>{(e.hour!==o.current.hour||e.minute!==o.current.minute)&&(o.current=e,u(y(e)))},[e]);const p=()=>{const m=f.current;if(!m)return;const h=m.selectionStart??0;S.includes(h)||l(h,!0)},b=(m,h)=>{const k=m==="ArrowRight";l(P(h,k),k)},d=(m,h)=>{const k=S.includes(h)?h:P(h,!1),c=[...a];c[k]="-",u(c),n(C(c));const w=m==="Backspace"?P(k,!1):P(k,!0);setTimeout(()=>l(w,m!=="Backspace"),0)},T=(m,h)=>{const k=S.includes(h)?h:P(h,!0),c=[...a];q(m,k,c)&&(c[k]=m,u(c),n(C(c)),setTimeout(()=>l(P(k,!0),!0),0))},R=m=>{if(m.preventDefault(),s)return;const h=f.current;if(!h)return;const k=h.selectionStart??0;if(["ArrowLeft","ArrowRight"].includes(m.key)){b(m.key,k);return}if(["Backspace","Delete"].includes(m.key)){d(m.key,k);return}/^\d$/.test(m.key)&&T(m.key,k)};return g.jsx(A.Input,{ref:f,dir:"ltr",className:r,value:a.join(""),onKeyDown:R,onFocus:p,disabled:s,inputMode:"numeric",pattern:"[0-9:]*",...i})},L=({timePickerProps:t,setActivePart:e,handleSingleTimeChange:n,handleRangeTimeChange:s})=>{const{acceptRange:r,value:i}=t,f=a=>({hour:a?.getHours()??0,minute:a?.getMinutes()??0}),l=r?[{key:"start",id:"from-time",label:"از ساعت",value:f(i?.start),className:"dgsuikit:w-1/2"},{key:"end",id:"to-time",label:"تا ساعت",value:f(i?.end),className:"dgsuikit:w-1/2"}]:[{key:"single",id:"time",label:"ساعت",value:f(i),className:void 0}];return g.jsx("div",{className:N.clsx(r&&"dgsuikit:flex dgsuikit:justify-between dgsuikit:gap-4 dgsuikit:mb-4"),children:l.map(({key:a,id:u,label:o,value:p,className:b})=>g.jsx(K,{id:u,value:p,labelContent:o,className:b,onFocus:()=>{r&&a!=="single"&&e(a)},onChange:d=>{typeof d.hour=="number"&&typeof d.minute=="number"&&(r&&a!=="single"?s(a,d.hour,d.minute):n(d.hour,d.minute))}},u))})},M=({position:t})=>g.jsx("div",{className:N.clsx("dgsuikit:absolute dgsuikit:left-0 dgsuikit:right-0 dgsuikit:h-12 dgsuikit:pointer-events-none","dgsuikit:from-[rgba(255,255,255,0.54)] dgsuikit:to-[rgba(255,255,255,0.90)]",t==="top"?"dgsuikit:bg-gradient-to-t dgsuikit:top-0":"dgsuikit:bg-gradient-to-b dgsuikit:bottom-0")});function O(t,e,n){const s=x.useRef(null),r=x.useRef([]),i=x.useRef(null),f=()=>B(r.current),l=(u=e??0,o="smooth")=>{E(s.current,t,u,f,o),i.current=u},a=u=>{const o=Math.round(u.scrollTop/f()),p=t[Math.max(0,Math.min(o,t.length-1))];p!=null&&p!==i.current&&(i.current=p,n(p))};return x.useEffect(()=>{const u=s.current;if(!u)return;const o=()=>a(u);return u.addEventListener("scroll",o),()=>u.removeEventListener("scroll",o)},[t]),x.useEffect(()=>{e!=null&&l()},[e]),{containerRef:s,itemRefs:r}}const v=t=>{const{items:e,defaultValue:n,onValueChange:s,className:r,formatValue:i=a=>String(a).padStart(2,"0")}=t,{containerRef:f,itemRefs:l}=O(e,n,s);return g.jsxs("div",{className:"dgsuikit:relative dgsuikit:h-28 dgsuikit:w-full",children:[g.jsx("div",{ref:f,className:N.clsx("dgsuikit:h-28 dgsuikit:w-full dgsuikit:py-10 dgsuikit:overflow-y-scroll dgsuikit:snap-y dgsuikit:snap-mandatory dgsuikit:scroll-smooth dgsuikit:no-scrollbar",r),children:e.map((a,u)=>g.jsx("div",{ref:o=>{l.current[u]=o},className:"dgsuikit:h-10 dgsuikit:flex dgsuikit:items-center dgsuikit:justify-center dgsuikit:snap-center dgsuikit:font-p1-regular",children:i(a)},a))}),g.jsx(M,{position:"top"}),g.jsx(M,{position:"bottom"})]})},_=t=>{const{timePickerProps:e,activePart:n,handleSingleTimeChange:s,handleRangeTimeChange:r}=t,{minuteStep:i=1,acceptRange:f,value:l}=e,a=Array.from({length:24},(c,w)=>w),u=Array.from({length:60},(c,w)=>w).filter(c=>c%i===0),o=c=>c.toString().padStart(2,"0"),p=c=>c.toString().padStart(2,"0"),b=c=>{if(f){const w=n==="start"?l?.start:l?.end;return w?w[c]():0}return l?l[c]():0},d=b("getHours"),T=b("getMinutes"),[R,m]=x.useState(T),[h,k]=x.useState(d);return x.useEffect(()=>{f?r(n,h,R):s(h,R)},[h,R]),g.jsxs("div",{className:"dgsuikit:flex dgsuikit:mt-2 dgsuikit:w-full dgsuikit:justify-center",children:[g.jsx(v,{items:u,defaultValue:T,onValueChange:c=>m(c),formatValue:p}),g.jsx(v,{items:a,defaultValue:d,onValueChange:c=>k(c),formatValue:o})]})},G=()=>{const{timePickerProps:t}=V(),{acceptRange:e,value:n,onChange:s}=t,[r,i]=x.useState("start"),f=(o,p,b)=>{const d=new Date(o);return d.setHours(p),d.setMinutes(b),d.setSeconds(0),d.setMilliseconds(0),d},l=j.debounce((o,p)=>{!n||e||n.getHours()===o&&n.getMinutes()===p||s(f(n,o,p))},200),a=j.debounce((o,p,b)=>{if(!n||!e)return;const d=new Date(n[o]??new Date);d.getHours()===p&&d.getMinutes()===b||s({...n,[o]:f(d,p,b)})},200),u={timePickerProps:t,handleSingleTimeChange:l,handleRangeTimeChange:a};return g.jsxs("div",{dir:"rtl",className:"dgsuikit:p-4 dgsuikit:ss02",children:[g.jsx(L,{setActivePart:i,...u}),g.jsx(_,{activePart:r,...u})]})},z=()=>{const{timePickerProps:t}=V(),{showSubmitButton:e=!0,showNowButton:n=!0,onSubmit:s,onChange:r,acceptRange:i}=t,f=()=>{if(i){const l=new Date;l.setHours(l.getHours()+1),r({start:new Date,end:l})}else r(new Date)};return g.jsx(D.DateAndTimePickerFooter,{...e&&{primaryButton:{onClick:s,children:"اعمال"}},...n&&{secondaryButton:{variant:"text",onClick:f,children:"رفتن به اکنون"}},className:"dgsuikit:p-4"})};function J(t){if(!t)return"";if(t instanceof Date){const e=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0");return`${e}:${n}`}if(t.start&&t.end){const e=t.start.getHours().toString().padStart(2,"0"),n=t.start.getMinutes().toString().padStart(2,"0"),s=t.end.getHours().toString().padStart(2,"0"),r=t.end.getMinutes().toString().padStart(2,"0");return`${e}:${n} - ${s}:${r}`}return""}const Q=t=>{const{showSubmitButton:e=!0,showNowButton:n=!0}=t,s=t.acceptRange===void 0?{...t,acceptRange:!1}:t,{Wrapper:r,wrapperProps:i}=D.useDateAndTimePickerWrapper({props:s,standaloneMode:"time",formatValue:J});return g.jsx(r,{...i,children:g.jsxs($,{timePickerProps:s,children:[g.jsx(G,{}),(e||n)&&g.jsx(z,{})]})})};module.exports=Q;
@@ -1,8 +1,8 @@
1
- import { jsx as p, jsxs as x } from "react/jsx-runtime";
1
+ import { jsx as p, jsxs as R } from "react/jsx-runtime";
2
2
  import I, { createContext as E, useContext as j, useRef as y, useState as C, useEffect as M } from "react";
3
- import { D as F, u as W } from "../../DateAndTimePickerFooter-NWsDe_w1.js";
3
+ import { D as W, u as F } from "../../DateAndTimePickerFooter-NWsDe_w1.js";
4
4
  import { d as v } from "../../index-CzwAoGdL.js";
5
- import { c as R } from "../../clsx-OuTLNxxd.js";
5
+ import { c as x } from "../../clsx-OuTLNxxd.js";
6
6
  import { I as K } from "../../index-nXqUoTI3.js";
7
7
  const $ = E({
8
8
  timePickerProps: {
@@ -21,12 +21,12 @@ const $ = E({
21
21
  children: e
22
22
  }
23
23
  );
24
- }, B = () => j($), b = [0, 1, 3, 4], O = (t) => t[0]?.getBoundingClientRect().height ?? 64, _ = (t, e, n, r, i = "instant") => {
24
+ }, B = () => j($), b = [0, 1, 3, 4], O = (t) => t[0]?.getBoundingClientRect().height ?? 64, _ = (t, e, n, r, s = "instant") => {
25
25
  if (!t) return;
26
- const s = e.indexOf(n);
27
- s !== -1 && t.scrollTo({
28
- top: s * r(),
29
- behavior: i
26
+ const i = e.indexOf(n);
27
+ i !== -1 && t.scrollTo({
28
+ top: i * r(),
29
+ behavior: s
30
30
  });
31
31
  }, G = (t) => {
32
32
  if (t.length !== 2) return !1;
@@ -55,18 +55,18 @@ const $ = E({
55
55
  }, z = (t, e, n) => e === 0 ? /[0-2]/.test(t) : e === 1 ? +`${n[0] === "-" ? "0" : n[0]}${t}` <= 23 : e === 3 ? /[0-5]/.test(t) : !0, J = () => {
56
56
  const t = y(null);
57
57
  return { inputRef: t, setCaretToEditable: (n, r = !0) => {
58
- const i = t.current;
59
- if (!i) return;
60
- const s = b.includes(n) ? n : N(n, r);
61
- typeof s == "number" && i.setSelectionRange(s, s + 1);
58
+ const s = t.current;
59
+ if (!s) return;
60
+ const i = b.includes(n) ? n : N(n, r);
61
+ typeof i == "number" && s.setSelectionRange(i, i + 1);
62
62
  } };
63
63
  }, Q = (t) => {
64
64
  const {
65
65
  value: e = { hour: null, minute: null },
66
66
  onChange: n,
67
67
  disabled: r = !1,
68
- className: i,
69
- ...s
68
+ className: s,
69
+ ...i
70
70
  } = t, { inputRef: m, setCaretToEditable: l } = J(), [c, u] = C(() => D(e)), o = I.useRef(e);
71
71
  M(() => {
72
72
  (e.hour !== o.current.hour || e.minute !== o.current.minute) && (o.current = e, u(D(e)));
@@ -107,14 +107,14 @@ const $ = E({
107
107
  {
108
108
  ref: m,
109
109
  dir: "ltr",
110
- className: i,
110
+ className: s,
111
111
  value: c.join(""),
112
112
  onKeyDown: P,
113
113
  onFocus: h,
114
114
  disabled: r,
115
115
  inputMode: "numeric",
116
116
  pattern: "[0-9:]*",
117
- ...s
117
+ ...i
118
118
  }
119
119
  );
120
120
  }, U = ({
@@ -123,22 +123,22 @@ const $ = E({
123
123
  handleSingleTimeChange: n,
124
124
  handleRangeTimeChange: r
125
125
  }) => {
126
- const { acceptRange: i, value: s } = t, m = (c) => ({
126
+ const { acceptRange: s, value: i } = t, m = (c) => ({
127
127
  hour: c?.getHours() ?? 0,
128
128
  minute: c?.getMinutes() ?? 0
129
- }), l = i ? [
129
+ }), l = s ? [
130
130
  {
131
131
  key: "start",
132
132
  id: "from-time",
133
133
  label: "از ساعت",
134
- value: m(s?.start),
134
+ value: m(i?.start),
135
135
  className: "dgsuikit:w-1/2"
136
136
  },
137
137
  {
138
138
  key: "end",
139
139
  id: "to-time",
140
140
  label: "تا ساعت",
141
- value: m(s?.end),
141
+ value: m(i?.end),
142
142
  className: "dgsuikit:w-1/2"
143
143
  }
144
144
  ] : [
@@ -146,15 +146,15 @@ const $ = E({
146
146
  key: "single",
147
147
  id: "time",
148
148
  label: "ساعت",
149
- value: m(s),
149
+ value: m(i),
150
150
  className: void 0
151
151
  }
152
152
  ];
153
153
  return /* @__PURE__ */ p(
154
154
  "div",
155
155
  {
156
- className: R(
157
- i && "dgsuikit:flex dgsuikit:justify-between dgsuikit:gap-4 dgsuikit:mb-4"
156
+ className: x(
157
+ s && "dgsuikit:flex dgsuikit:justify-between dgsuikit:gap-4 dgsuikit:mb-4"
158
158
  ),
159
159
  children: l.map(({ key: c, id: u, label: o, value: h, className: S }) => /* @__PURE__ */ p(
160
160
  Q,
@@ -164,10 +164,10 @@ const $ = E({
164
164
  labelContent: o,
165
165
  className: S,
166
166
  onFocus: () => {
167
- i && c !== "single" && e(c);
167
+ s && c !== "single" && e(c);
168
168
  },
169
169
  onChange: (d) => {
170
- typeof d.hour == "number" && typeof d.minute == "number" && (i && c !== "single" ? r(c, d.hour, d.minute) : n(d.hour, d.minute));
170
+ typeof d.hour == "number" && typeof d.minute == "number" && (s && c !== "single" ? r(c, d.hour, d.minute) : n(d.hour, d.minute));
171
171
  }
172
172
  },
173
173
  u
@@ -177,7 +177,7 @@ const $ = E({
177
177
  }, V = ({ position: t }) => /* @__PURE__ */ p(
178
178
  "div",
179
179
  {
180
- className: R(
180
+ className: x(
181
181
  "dgsuikit:absolute dgsuikit:left-0 dgsuikit:right-0 dgsuikit:h-12 dgsuikit:pointer-events-none",
182
182
  "dgsuikit:from-[rgba(255,255,255,0.54)] dgsuikit:to-[rgba(255,255,255,0.90)]",
183
183
  t === "top" ? "dgsuikit:bg-gradient-to-t dgsuikit:top-0" : "dgsuikit:bg-gradient-to-b dgsuikit:bottom-0"
@@ -185,11 +185,11 @@ const $ = E({
185
185
  }
186
186
  );
187
187
  function X(t, e, n) {
188
- const r = y(null), i = y([]), s = y(null), m = () => O(i.current), l = (u = e ?? 0, o = "smooth") => {
189
- _(r.current, t, u, m, o), s.current = u;
188
+ const r = y(null), s = y([]), i = y(null), m = () => O(s.current), l = (u = e ?? 0, o = "smooth") => {
189
+ _(r.current, t, u, m, o), i.current = u;
190
190
  }, c = (u) => {
191
191
  const o = Math.round(u.scrollTop / m()), h = t[Math.max(0, Math.min(o, t.length - 1))];
192
- h != null && h !== s.current && (s.current = h, n(h));
192
+ h != null && h !== i.current && (i.current = h, n(h));
193
193
  };
194
194
  return M(() => {
195
195
  const u = r.current;
@@ -198,24 +198,24 @@ function X(t, e, n) {
198
198
  return u.addEventListener("scroll", o), () => u.removeEventListener("scroll", o);
199
199
  }, [t]), M(() => {
200
200
  e != null && l();
201
- }, [e]), { containerRef: r, itemRefs: i };
201
+ }, [e]), { containerRef: r, itemRefs: s };
202
202
  }
203
203
  const A = (t) => {
204
204
  const {
205
205
  items: e,
206
206
  defaultValue: n,
207
207
  onValueChange: r,
208
- className: i,
209
- formatValue: s = (c) => String(c).padStart(2, "0")
208
+ className: s,
209
+ formatValue: i = (c) => String(c).padStart(2, "0")
210
210
  } = t, { containerRef: m, itemRefs: l } = X(e, n, r);
211
- return /* @__PURE__ */ x("div", { className: "dgsuikit:relative dgsuikit:h-28 dgsuikit:w-full", children: [
211
+ return /* @__PURE__ */ R("div", { className: "dgsuikit:relative dgsuikit:h-28 dgsuikit:w-full", children: [
212
212
  /* @__PURE__ */ p(
213
213
  "div",
214
214
  {
215
215
  ref: m,
216
- className: R(
216
+ className: x(
217
217
  "dgsuikit:h-28 dgsuikit:w-full dgsuikit:py-10 dgsuikit:overflow-y-scroll dgsuikit:snap-y dgsuikit:snap-mandatory dgsuikit:scroll-smooth dgsuikit:no-scrollbar",
218
- i
218
+ s
219
219
  ),
220
220
  children: e.map((c, u) => /* @__PURE__ */ p(
221
221
  "div",
@@ -224,7 +224,7 @@ const A = (t) => {
224
224
  l.current[u] = o;
225
225
  },
226
226
  className: "dgsuikit:h-10 dgsuikit:flex dgsuikit:items-center dgsuikit:justify-center dgsuikit:snap-center dgsuikit:font-p1-regular",
227
- children: s(c)
227
+ children: i(c)
228
228
  },
229
229
  c
230
230
  ))
@@ -234,8 +234,8 @@ const A = (t) => {
234
234
  /* @__PURE__ */ p(V, { position: "bottom" })
235
235
  ] });
236
236
  }, Y = (t) => {
237
- const { timePickerProps: e, activePart: n, handleSingleTimeChange: r, handleRangeTimeChange: i } = t, { minuteStep: s = 1, acceptRange: m, value: l } = e, c = Array.from({ length: 24 }, (a, w) => w), u = Array.from({ length: 60 }, (a, w) => w).filter(
238
- (a) => a % s === 0
237
+ const { timePickerProps: e, activePart: n, handleSingleTimeChange: r, handleRangeTimeChange: s } = t, { minuteStep: i = 1, acceptRange: m, value: l } = e, c = Array.from({ length: 24 }, (a, w) => w), u = Array.from({ length: 60 }, (a, w) => w).filter(
238
+ (a) => a % i === 0
239
239
  ), o = (a) => a.toString().padStart(2, "0"), h = (a) => a.toString().padStart(2, "0"), S = (a) => {
240
240
  if (m) {
241
241
  const w = n === "start" ? l?.start : l?.end;
@@ -244,8 +244,8 @@ const A = (t) => {
244
244
  return l ? l[a]() : 0;
245
245
  }, d = S("getHours"), T = S("getMinutes"), [P, g] = C(T), [f, k] = C(d);
246
246
  return M(() => {
247
- m ? i(n, f, P) : r(f, P);
248
- }, [f, P]), /* @__PURE__ */ x("div", { className: "dgsuikit:flex dgsuikit:mt-2 dgsuikit:w-full dgsuikit:justify-center", children: [
247
+ m ? s(n, f, P) : r(f, P);
248
+ }, [f, P]), /* @__PURE__ */ R("div", { className: "dgsuikit:flex dgsuikit:mt-2 dgsuikit:w-full dgsuikit:justify-center", children: [
249
249
  /* @__PURE__ */ p(
250
250
  A,
251
251
  {
@@ -266,7 +266,7 @@ const A = (t) => {
266
266
  )
267
267
  ] });
268
268
  }, Z = () => {
269
- const { timePickerProps: t } = B(), { acceptRange: e, value: n, onChange: r } = t, [i, s] = C("start"), m = (o, h, S) => {
269
+ const { timePickerProps: t } = B(), { acceptRange: e, value: n, onChange: r } = t, [s, i] = C("start"), m = (o, h, S) => {
270
270
  const d = new Date(o);
271
271
  return d.setHours(h), d.setMinutes(S), d.setSeconds(0), d.setMilliseconds(0), d;
272
272
  }, l = v((o, h) => {
@@ -279,7 +279,7 @@ const A = (t) => {
279
279
  [o]: m(d, h, S)
280
280
  });
281
281
  }, 200), u = { timePickerProps: t, handleSingleTimeChange: l, handleRangeTimeChange: c };
282
- return /* @__PURE__ */ x(
282
+ return /* @__PURE__ */ R(
283
283
  "div",
284
284
  {
285
285
  dir: "rtl",
@@ -288,14 +288,14 @@ const A = (t) => {
288
288
  /* @__PURE__ */ p(
289
289
  U,
290
290
  {
291
- setActivePart: s,
291
+ setActivePart: i,
292
292
  ...u
293
293
  }
294
294
  ),
295
295
  /* @__PURE__ */ p(
296
296
  Y,
297
297
  {
298
- activePart: i,
298
+ activePart: s,
299
299
  ...u
300
300
  }
301
301
  )
@@ -307,11 +307,11 @@ const A = (t) => {
307
307
  showSubmitButton: e = !0,
308
308
  showNowButton: n = !0,
309
309
  onSubmit: r,
310
- onChange: i,
311
- acceptRange: s
310
+ onChange: s,
311
+ acceptRange: i
312
312
  } = t;
313
313
  return /* @__PURE__ */ p(
314
- F,
314
+ W,
315
315
  {
316
316
  ...e && {
317
317
  primaryButton: {
@@ -323,11 +323,11 @@ const A = (t) => {
323
323
  secondaryButton: {
324
324
  variant: "text",
325
325
  onClick: () => {
326
- if (s) {
326
+ if (i) {
327
327
  const l = /* @__PURE__ */ new Date();
328
- l.setHours(l.getHours() + 1), i({ start: /* @__PURE__ */ new Date(), end: l });
328
+ l.setHours(l.getHours() + 1), s({ start: /* @__PURE__ */ new Date(), end: l });
329
329
  } else
330
- i(/* @__PURE__ */ new Date());
330
+ s(/* @__PURE__ */ new Date());
331
331
  },
332
332
  children: "رفتن به اکنون"
333
333
  }
@@ -343,18 +343,18 @@ function et(t) {
343
343
  return `${e}:${n}`;
344
344
  }
345
345
  if (t.start && t.end) {
346
- const e = t.start.getHours().toString().padStart(2, "0"), n = t.start.getMinutes().toString().padStart(2, "0"), r = t.end.getHours().toString().padStart(2, "0"), i = t.end.getMinutes().toString().padStart(2, "0");
347
- return `${e}:${n} - ${r}:${i}`;
346
+ const e = t.start.getHours().toString().padStart(2, "0"), n = t.start.getMinutes().toString().padStart(2, "0"), r = t.end.getHours().toString().padStart(2, "0"), s = t.end.getMinutes().toString().padStart(2, "0");
347
+ return `${e}:${n} - ${r}:${s}`;
348
348
  }
349
349
  return "";
350
350
  }
351
351
  const at = (t) => {
352
- const { showSubmitButton: e = !0, showNowButton: n = !0 } = t, { Wrapper: r, wrapperProps: i } = W({
353
- props: t,
352
+ const { showSubmitButton: e = !0, showNowButton: n = !0 } = t, r = t.acceptRange === void 0 ? { ...t, acceptRange: !1 } : t, { Wrapper: s, wrapperProps: i } = F({
353
+ props: r,
354
354
  standaloneMode: "time",
355
355
  formatValue: et
356
356
  });
357
- return /* @__PURE__ */ p(r, { ...i, children: /* @__PURE__ */ x(L, { timePickerProps: t, children: [
357
+ return /* @__PURE__ */ p(s, { ...i, children: /* @__PURE__ */ R(L, { timePickerProps: r, children: [
358
358
  /* @__PURE__ */ p(Z, {}),
359
359
  (e || n) && /* @__PURE__ */ p(tt, {})
360
360
  ] }) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dgshahr/ui-kit",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "description": "A modern, accessible, and customizable React component library",
5
5
  "author": "dgshahr",
6
6
  "contributes": [