@dotss/ui 1.3.0 → 1.3.1

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.
@@ -97,4 +97,4 @@
97
97
  min-width: 100%;
98
98
  height: 6px;
99
99
  min-height: 6px;
100
- `,xt=30,Je=5,bt=d.forwardRef(function({children:n,onChange:r,onChangeMonth:u,value:o,date:p,minDate:h,maxDate:y,holidayDates:je,disableDates:_,showWeekHead:Ce=!1,multiple:M=!1,period:re=!1,enableMonthSelect:J=!1,showToday:Ae=!1,edgeSpacing:he=0,renderEvent:F,inlineCSS:et,monthProps:ne,...tt},rt){const{spacing:ve}=pt.default(),[$,ie]=d.useState((typeof p=="string"||typeof p=="number"?new Date(p):p)||new Date),[x,Q]=d.useState(()=>Array.isArray(o)&&o.length>0?g(o[0]):g(o)),[Y,se]=d.useState(()=>Array.isArray(o)&&o.length>1?g(o[o.length-1]):null),[j,Te]=d.useState(0),[b,X]=d.useState(1),[Re,He]=d.useState(!1),[me,ye]=d.useState(!1),Z=d.useRef(null),D=d.useRef(null),oe=d.useRef(0),We=d.useRef(0),H=d.useRef(0),A=d.useRef(!1),C=d.useRef(b),ge=d.useRef(),ae=d.useRef(null),De=d.useRef(null),v=$.getFullYear(),ce=$.getMonth(),Fe=Me(v,ce),z=q(ce),N=g(o),B=g(je),K=g(_),we=G($,h)||pe($,h),$e=O($,y)||pe($,y),le=new Date(v,ce-1),ue=new Date(v,ce+1),L=`${v}. ${z}`,E=`${v}년 ${z}월`,P=re&&!!x&&!!Y,Ye=[{year:le.getFullYear(),month:q(le.getMonth()),weeks:Me(le.getFullYear(),le.getMonth())},{year:v,month:z,weeks:Fe},{year:ue.getFullYear(),month:q(ue.getMonth()),weeks:Me(ue.getFullYear(),ue.getMonth())}],xe=typeof F=="function",nt=Ye[1].weeks.length*(xt+(xe?10:0)+ve.content(2))+ve.content(2),ze=(t,l)=>()=>{D.current&&(D.current.style.transition="none",D.current.style.cursor="grabbing"),oe.current=t,We.current=l},I=d.useCallback(()=>{if(!A.current)return;const t=j-H.current,l=Math.abs(j-t),s=j*.1;D.current&&(D.current.style.transform=`translate3d(-${j*b}px, 0, 0)`,D.current.style.cursor="grab",D.current.style.transition="transform 0.2s"),oe.current=0,H.current=0,A.current=!1,!(l<=s)&&(j<t?X(c=>c+1):j>t&&X(c=>c-1))},[j,b]),be=(t,l)=>()=>{if(!(A.current||b!==1)&&!l){if(!re){r==null||r(t,g);return}if(R(t,x)&&Array.isArray(o)&&o.length===1){Q(null),se(null),r==null||r([],g);return}else if(R(t,x)&&!Array.isArray(o)&&R(t,o)){Q(null),se(null),r==null||r([],g);return}if(!x){Q(t),r==null||r(t,g);return}if(!Y&&x){const[s,c]=O(t,x)?[x,t]:[t,x];Q(s),se(c);const i=Ze([s,c],_);r==null||r(i,g);return}x&&Y&&(Q(t),se(null),r==null||r(t,g))}},it=t=>{M&&(A.current=!0,ze(t.clientX,t.clientY)())},st=t=>{M&&ze(t.touches[0].clientX,t.touches[0].clientY)()},Le=()=>{Re||(D.current&&(D.current.style.transition="transform 0.2s"),X(t=>t-1))},Ee=()=>{Re||(D.current&&(D.current.style.transition="transform 0.2s"),X(t=>t+1))},fe=t=>{t.stopPropagation(),ye(l=>!l)},ot=()=>ye(!1),at=t=>{if(!t)return;const[l,s]=t.toString().split(".").map(Number);ie(new Date(l,s-1)),u&&typeof u=="function"&&u(g(new Date(l,s-1)),g),ye(!1)},Ie=(t,l)=>s=>{const c=new Date(t);let i=null;if(s.stopPropagation(),s.key==="ArrowRight")i=new Date(c),i.setDate(c.getDate()+1);else if(s.key==="ArrowLeft")i=new Date(c),i.setDate(c.getDate()-1);else if(s.key==="ArrowDown")i=new Date(c),i.setDate(c.getDate()+7);else if(s.key==="ArrowUp")i=new Date(c),i.setDate(c.getDate()-7);else if(s.key==="Home")i=new Date(c),i.setDate(c.getDate()-c.getDay());else if(s.key==="End")i=new Date(c),i.setDate(c.getDate()+(6-c.getDay()));else if(s.key==="PageUp")i=new Date(c),i.setMonth(c.getMonth()-1);else if(s.key==="PageDown")i=new Date(c),i.setMonth(c.getMonth()+1);else if(s.key==="Enter"||s.key===" "){s.preventDefault(),be(t,l)();return}else if(s.key==="Escape"){s.preventDefault(),r==null||r([],g);return}if(i&&Z.current){const w=c.getMonth(),m=c.getFullYear(),k=i.getMonth(),f=i.getFullYear(),T=g(i),W=Z.current.querySelector(`[data-date="${T}"]`);if(W){if(w!==k||m!==f){i>c?(Ee(),setTimeout(()=>{W.focus()},0)):(Le(),setTimeout(()=>{W.focus()},0));return}W.focus()}}};return d.useLayoutEffect(()=>{var t;Te(((t=Z.current)==null?void 0:t.clientWidth)||0)},[M]),d.useEffect(()=>{const t=()=>{var l;Te(((l=Z.current)==null?void 0:l.clientWidth)||0)};return window.addEventListener("resize",t),window.addEventListener("scroll",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t)}},[M]),d.useEffect(()=>{const t=D.current,l=(i,w,m)=>{if(!t||!A.current&&oe.current===0)return;H.current=i-oe.current;const k=w-We.current;if(A.current=A.current||Math.abs(H.current)>Je&&Math.abs(k)<Je*2,A.current&&m.cancelable&&(m.preventDefault(),m.stopPropagation()),A.current){if(we&&H.current>0){I();return}if($e&&H.current<0){I();return}Math.abs(H.current)>=10&&(t.style.transform=`translate3d(${H.current-j*b}px, 0, 0)`,t.style.cursor="grabbing")}},s=i=>l(i.touches[0].clientX,i.touches[0].clientY,i),c=i=>{A.current&&l(i.clientX,i.clientY,i)};return t==null||t.addEventListener("mousemove",c),t==null||t.addEventListener("touchmove",s),()=>{t==null||t.removeEventListener("mousemove",c),t==null||t.removeEventListener("touchmove",s)}},[j,b,I,$e,we]),d.useEffect(()=>{He(!0),ge.current=setTimeout(()=>{if(D.current&&(D.current.style.transition="none"),b>C.current){X(1);const t=new Date($.setMonth($.getMonth()+1));ie(t),u&&typeof u=="function"&&u(g(t),g),C.current=1}else if(b<C.current){const t=new Date($.setMonth($.getMonth()-1));ie(t),u&&typeof u=="function"&&u(g(t),g),X(1),C.current=1}else C.current=b;He(!1)},200)},[b,$,u]),d.useLayoutEffect(()=>{if(!re||!Array.isArray(o))return;const t=Ze(o,_);o.length<t.length&&(r==null||r(t,g))},[re,o,r,_]),d.useEffect(()=>{let t;return me&&(t=setTimeout(()=>{if(De.current){const l=De.current.querySelector("ul"),s=l==null?void 0:l.querySelector(`[data-value="${L}"]`);s==null||s.scrollIntoView({block:"start"})}},200)),()=>{clearTimeout(t)}},[me,L]),d.useEffect(()=>()=>{ge.current&&clearTimeout(ge.current)},[]),d.useEffect(()=>{p&&ie((typeof p=="string"||typeof p=="number"?new Date(p):p)||new Date)},[p]),a.jsxs(yt,{ref:rt,"aria-label":"달력",role:"application",...tt,css:et,children:[M?a.jsxs(gt,{children:[a.jsx(Xe.default,{name:"ChevronLeftLine",size:"small",onClick:Le,disabled:we,"aria-label":`이전 달로 이동, 현재 ${E}`}),J&&a.jsxs(Ge,{ref:ae,clickable:!0,onClick:fe,"aria-label":E,...ne,children:[L,a.jsx(Ne.default,{iconOnly:!0,isMenuOpen:!1,size:"xSmall",variant:"text",menuId:"date-picker-month-menu",onClick:fe,"aria-label":`달 변경, 현재 ${E}`,startAdornment:a.jsx(_e.default,{name:"ArrowDownFill",size:"xSmall"})})]}),!J&&a.jsx(Ge,{ref:ae,id:"date-picker-title",clickable:!1,"aria-label":E,...ne,children:L}),a.jsx(Xe.default,{name:"ChevronRightLine",size:"small",onClick:Ee,disabled:$e,"aria-label":`다음 달로 이동, 현재 ${E}`})]}):a.jsxs(a.Fragment,{children:[J&&a.jsxs(Be,{ref:ae,clickable:!0,onClick:fe,"aria-label":E,...ne,children:[L,a.jsx(Ne.default,{iconOnly:!0,isMenuOpen:!1,size:"xSmall",variant:"text",menuId:"date-picker-month-menu",onClick:fe,"aria-label":`달 변경, 현재 ${E}`,startAdornment:a.jsx(_e.default,{name:"ArrowDownFill",size:"xSmall"})})]}),!J&&a.jsx(Be,{id:"date-picker-title",clickable:!1,...ne,children:L})]}),J&&a.jsx(ft.default,{id:"date-picker-month-menu",anchorRef:ae,ref:De,open:me,onClose:ot,onChange:at,value:L,placement:M?"bottom-center":"bottom-left",width:160,fitToAnchorWidth:!1,maxHeight:368,children:Array.from({length:130},(t,l)=>{const s=1970+l;return Array.from({length:12},(c,i)=>{const w=i+1,m=w<10?`0${w}`:w,k=new Date(s,i+1,0).getDate(),f=`${s}-${m}-${k}`,T=`${s}-${m}-01`;return G(f,h)||O(T,y)?null:a.jsx(dt.default,{value:`${s}. ${m}`,"aria-label":`${s}년 ${m}월 선택`,children:`${s}. ${m}`},`${s}-${m}`)})})}),a.jsxs(ut.default,{flexDirection:"column",role:"grid","aria-label":`${v}년 ${z}월 달력`,children:[Ce&&a.jsxs(Dt,{id:"date-picker-week-head",role:"row",edgeSpacing:he,children:[a.jsx("span",{role:"columnheader",children:"일"}),a.jsx("span",{role:"columnheader",children:"월"}),a.jsx("span",{role:"columnheader",children:"화"}),a.jsx("span",{role:"columnheader",children:"수"}),a.jsx("span",{role:"columnheader",children:"목"}),a.jsx("span",{role:"columnheader",children:"금"}),a.jsx("span",{role:"columnheader",children:"토"})]}),a.jsx(wt,{ref:Z,role:"presentation",children:a.jsxs($t,{role:"presentation",ref:D,onMouseDown:it,onMouseUp:I,onMouseLeave:I,onTouchStart:st,onTouchEnd:I,onTouchCancel:I,style:{transform:M?`translate3d(-${j*b}px, 0, 0)`:void 0,cursor:M?"grab":void 0,maxHeight:nt},children:[M&&Ye.map(({year:t,month:l,weeks:s},c)=>a.jsx(Ke,{role:"rowgroup",edgeSpacing:he,className:c===1?"week-body-current":"",children:s.map((i,w)=>a.jsx(Pe,{role:"row",children:i.map((m,k)=>{const f=`${t}-${l}-${V(m||0)}`,T=!m,W=R(f,new Date),ke=Array.isArray(B)?B.includes(f):B===f,ee=Array.isArray(N)?N.includes(f):N===f,U=!m||(Array.isArray(K)?K.includes(f):K===f)||O(f,y)||G(f,h),Se=P&&R(f,x),de=P&&R(f,Y),ct=P&&O(f,x)&&G(f,Y),Oe=pe(f,$),lt=Oe&&w===0&&m===1||Oe&&ee,qe=F==null?void 0:F(f);return a.jsxs(Ue,{as:"button",role:"gridcell",variant:Se?"start":de?"end":ct?"middle":void 0,onClick:be(f,U),today:Ae&&W,holiday:ke,tabIndex:lt?0:-1,"aria-rowindex":w+1,"aria-colindex":k+1,selected:ee,"aria-selected":ee,"aria-disabled":U,"aria-hidden":m===null,"data-date":f,onKeyDown:Ie(f,U),children:[a.jsx("div",{"aria-label":`${Qe(f)}`,children:a.jsx("span",{children:m})}),!T&&qe,!T&&xe&&!qe&&a.jsx(Ve,{})]},`${t}-${l}-week-row-${k}-${m?f:`${w}-${k}`}`)})},`${t}-${l}-week-row-${String(i)}`))},`week-body-${t}-${l}`)),!M&&a.jsx(Ke,{role:"rowgroup",edgeSpacing:he,children:Fe.map((t,l)=>a.jsx(Pe,{role:"row",children:t.map((s,c)=>{const i=`${v}-${z}-${V(s||0)}`,w=!s,m=R(i,new Date),k=Array.isArray(B)?B.includes(i):B===i,f=Array.isArray(N)?N.includes(i):N===i,T=!s||(Array.isArray(K)?K.includes(i):K===i)||O(i,y)||G(i,h),W=P&&R(i,x),ke=P&&R(i,Y),ee=P&&O(i,x)&&G(i,Y),U=pe(i,$),Se=U&&l===0&&s===1||U&&f,de=F==null?void 0:F(i);return a.jsxs(Ue,{as:"button",variant:W?"start":ke?"end":ee?"middle":void 0,role:"gridcell",onClick:be(i,T),today:Ae&&m,holiday:k,"aria-rowindex":l+1,"aria-colindex":c+1,selected:f,"aria-selected":f,"aria-disabled":T,"aria-hidden":s===null,tabIndex:Se?0:-1,"data-date":i,onKeyDown:Ie(i,T),children:[a.jsx("div",{"aria-label":`${Qe(i)}`,children:a.jsx("span",{children:s})}),!w&&de,!w&&xe&&!de&&a.jsx(Ve,{})]},`${v}-${z}-week-row-${t}-${s?i:`${l}-${c}`}`)})},`${v}-${z}-week-row-${String(t)}`))})]})})]}),n]})});function Me(e,n){let r=[];const u=new Date(e,n,1),o=new Date(e,n+1,0).getDate(),p=u.getDay();let h=Array.from({length:p}).fill(null);for(let y=1;y<=o;y+=1)h.push(y),(h.length===7||y===o)&&(r.push(h),h=[]);return r=r.map(y=>Array.from({length:7}).map((je,_)=>y[_]||null)),r}function q(e){return String(e+1).length===1?`0${e+1}`:e+1}function V(e){return String(e).length===1?`0${e}`:e}function g(e){if(Array.isArray(e))return e.map(n=>n instanceof Date?`${n.getFullYear()}-${q(n.getMonth())}-${V(n.getDate())}`:n);if(e instanceof Date)return`${e.getFullYear()}-${q(e.getMonth())}-${V(e.getDate())}`;if(typeof e=="number"){const n=new Date(e);return`${n.getFullYear()}-${q(n.getMonth())}-${V(n.getDate())}`}return e}function Qe(e){const[n,r,u]=e.split("-");return`${n}년 ${Number(r)}월 ${Number(u)}일`}function O(e,n){if(!e||!n)return!1;const r=e instanceof Date?e:new Date(e);r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0);const u=r.getTime(),o=n instanceof Date?n:new Date(n);o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0);const p=o.getTime();return u>p}function G(e,n){if(!e||!n)return!1;const r=e instanceof Date?e:new Date(e);r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0);const u=r.getTime(),o=n instanceof Date?n:new Date(n);o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0);const p=o.getTime();return u<p}function pe(e,n){if(!e||!n)return!1;const r=e instanceof Date?e:new Date(e),u=n instanceof Date?n:new Date(n);return`${r.getFullYear()}-${r.getMonth()}`==`${u.getFullYear()}-${u.getMonth()}`}function R(e,n){if(!e||!n)return!1;const r=e instanceof Date?e:new Date(e);r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0);const u=r.getTime(),o=n instanceof Date?n:new Date(n);o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0);const p=o.getTime();return u===p}function Ze(e,n){if(!e||!Array.isArray(e)||e.length===0)return[];const r=e.map(y=>y instanceof Date?y:y===null?new Date:new Date(y)),u=new Date(Math.min(...r.map(y=>y.getTime()))),o=new Date(Math.max(...r.map(y=>y.getTime()))),p=[],h=new Date(u);for(;h<=o;){if(Array.isArray(n)&&n.includes(h)){h.setDate(h.getDate()+1);continue}else if(n===h){h.setDate(h.getDate()+1);continue}p.push(`${h.getFullYear()}-${q(h.getMonth())}-${V(h.getDate())}`),h.setDate(h.getDate()+1)}return p}exports.default=bt;
100
+ `,xt=30,Je=5,bt=d.forwardRef(function({children:n,onChange:r,onChangeMonth:u,value:o,date:p,minDate:h,maxDate:y,holidayDates:je,disableDates:_,showWeekHead:Ce=!1,multiple:M=!1,period:re=!1,enableMonthSelect:J=!1,showToday:Ae=!1,edgeSpacing:he=0,renderEvent:F,inlineCSS:et,monthProps:ne,...tt},rt){const{spacing:ve}=pt.default(),[$,ie]=d.useState((typeof p=="string"||typeof p=="number"?new Date(p):p)||new Date),[x,Q]=d.useState(()=>Array.isArray(o)&&o.length>0?g(o[0]):g(o)),[Y,se]=d.useState(()=>Array.isArray(o)&&o.length>1?g(o[o.length-1]):null),[j,Te]=d.useState(0),[b,X]=d.useState(1),[Re,He]=d.useState(!1),[me,ye]=d.useState(!1),Z=d.useRef(null),D=d.useRef(null),oe=d.useRef(0),We=d.useRef(0),H=d.useRef(0),A=d.useRef(!1),C=d.useRef(b),ge=d.useRef(),ae=d.useRef(null),De=d.useRef(null),v=$.getFullYear(),ce=$.getMonth(),Fe=Me(v,ce),z=q(ce),N=g(o),B=g(je),K=g(_),we=G($,h)||pe($,h),$e=O($,y)||pe($,y),le=new Date(v,ce-1),ue=new Date(v,ce+1),L=`${v}. ${z}`,E=`${v}년 ${z}월`,P=re&&!!x&&!!Y,Ye=[{year:le.getFullYear(),month:q(le.getMonth()),weeks:Me(le.getFullYear(),le.getMonth())},{year:v,month:z,weeks:Fe},{year:ue.getFullYear(),month:q(ue.getMonth()),weeks:Me(ue.getFullYear(),ue.getMonth())}],xe=typeof F=="function",nt=Ye[1].weeks.length*(xt+(xe?10:0)+ve.content(2))+ve.content(2),ze=(t,l)=>()=>{D.current&&(D.current.style.transition="none",D.current.style.cursor="grabbing"),oe.current=t,We.current=l},I=d.useCallback(()=>{if(!A.current)return;const t=j-H.current,l=Math.abs(j-t),s=j*.1;D.current&&(D.current.style.transform=`translate3d(-${j*b}px, 0, 0)`,D.current.style.cursor="grab",D.current.style.transition="transform 0.2s"),oe.current=0,H.current=0,A.current=!1,!(l<=s)&&(j<t?X(c=>c+1):j>t&&X(c=>c-1))},[j,b]),be=(t,l)=>()=>{if(!(A.current||b!==1)&&!l){if(!re){r==null||r(t,g);return}if(R(t,x)&&Array.isArray(o)&&o.length===1){Q(null),se(null),r==null||r([],g);return}else if(R(t,x)&&!Array.isArray(o)&&R(t,o)){Q(null),se(null),r==null||r([],g);return}if(!x){Q(t),r==null||r(t,g);return}if(!Y&&x){const[s,c]=O(t,x)?[x,t]:[t,x];Q(s),se(c);const i=Ze([s,c],_);r==null||r(i,g);return}x&&Y&&(Q(t),se(null),r==null||r(t,g))}},it=t=>{M&&(A.current=!0,ze(t.clientX,t.clientY)())},st=t=>{M&&ze(t.touches[0].clientX,t.touches[0].clientY)()},Le=()=>{Re||(D.current&&(D.current.style.transition="transform 0.2s"),X(t=>t-1))},Ee=()=>{Re||(D.current&&(D.current.style.transition="transform 0.2s"),X(t=>t+1))},fe=t=>{t.stopPropagation(),ye(l=>!l)},ot=()=>ye(!1),at=t=>{if(!t)return;const[l,s]=t.toString().split(".").map(Number);ie(new Date(l,s-1)),u&&typeof u=="function"&&u(g(new Date(l,s-1)),g),ye(!1)},Ie=(t,l)=>s=>{const c=new Date(t);let i=null;if(s.stopPropagation(),s.key==="ArrowRight")i=new Date(c),i.setDate(c.getDate()+1);else if(s.key==="ArrowLeft")i=new Date(c),i.setDate(c.getDate()-1);else if(s.key==="ArrowDown")i=new Date(c),i.setDate(c.getDate()+7);else if(s.key==="ArrowUp")i=new Date(c),i.setDate(c.getDate()-7);else if(s.key==="Home")i=new Date(c),i.setDate(c.getDate()-c.getDay());else if(s.key==="End")i=new Date(c),i.setDate(c.getDate()+(6-c.getDay()));else if(s.key==="PageUp")i=new Date(c),i.setMonth(c.getMonth()-1);else if(s.key==="PageDown")i=new Date(c),i.setMonth(c.getMonth()+1);else if(s.key==="Enter"||s.key===" "){s.preventDefault(),be(t,l)();return}else if(s.key==="Escape"){s.preventDefault(),r==null||r([],g);return}if(i&&Z.current){const w=c.getMonth(),m=c.getFullYear(),k=i.getMonth(),f=i.getFullYear(),T=g(i),W=Z.current.querySelector(`[data-date="${T}"]`);if(W){if(w!==k||m!==f){i>c?(Ee(),setTimeout(()=>{W.focus()},0)):(Le(),setTimeout(()=>{W.focus()},0));return}W.focus()}}};return d.useLayoutEffect(()=>{var t;Te(((t=Z.current)==null?void 0:t.clientWidth)||0)},[M]),d.useEffect(()=>{const t=()=>{var l;Te(((l=Z.current)==null?void 0:l.clientWidth)||0)};return window.addEventListener("resize",t),window.addEventListener("scroll",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t)}},[M]),d.useEffect(()=>{const t=D.current,l=(i,w,m)=>{if(!t||!A.current&&oe.current===0)return;H.current=i-oe.current;const k=w-We.current;if(A.current=A.current||Math.abs(H.current)>Je&&Math.abs(k)<Je*2,A.current&&m.cancelable&&(m.preventDefault(),m.stopPropagation()),A.current){if(we&&H.current>0){I();return}if($e&&H.current<0){I();return}Math.abs(H.current)>=10&&(t.style.transform=`translate3d(${H.current-j*b}px, 0, 0)`,t.style.cursor="grabbing")}},s=i=>l(i.touches[0].clientX,i.touches[0].clientY,i),c=i=>{A.current&&l(i.clientX,i.clientY,i)};return t==null||t.addEventListener("mousemove",c),t==null||t.addEventListener("touchmove",s),()=>{t==null||t.removeEventListener("mousemove",c),t==null||t.removeEventListener("touchmove",s)}},[j,b,I,$e,we]),d.useEffect(()=>{He(!0),ge.current=setTimeout(()=>{if(D.current&&(D.current.style.transition="none"),b>C.current){X(1);const t=new Date($.setMonth($.getMonth()+1,1));ie(t),u&&typeof u=="function"&&u(g(t),g),C.current=1}else if(b<C.current){const t=new Date($.setMonth($.getMonth()-1,1));ie(t),u&&typeof u=="function"&&u(g(t),g),X(1),C.current=1}else C.current=b;He(!1)},200)},[b,$,u]),d.useLayoutEffect(()=>{if(!re||!Array.isArray(o))return;const t=Ze(o,_);o.length<t.length&&(r==null||r(t,g))},[re,o,r,_]),d.useEffect(()=>{let t;return me&&(t=setTimeout(()=>{if(De.current){const l=De.current.querySelector("ul"),s=l==null?void 0:l.querySelector(`[data-value="${L}"]`);s==null||s.scrollIntoView({block:"start"})}},200)),()=>{clearTimeout(t)}},[me,L]),d.useEffect(()=>()=>{ge.current&&clearTimeout(ge.current)},[]),d.useEffect(()=>{p&&ie((typeof p=="string"||typeof p=="number"?new Date(p):p)||new Date)},[p]),a.jsxs(yt,{ref:rt,"aria-label":"달력",role:"application",...tt,css:et,children:[M?a.jsxs(gt,{children:[a.jsx(Xe.default,{name:"ChevronLeftLine",size:"small",onClick:Le,disabled:we,"aria-label":`이전 달로 이동, 현재 ${E}`}),J&&a.jsxs(Ge,{ref:ae,clickable:!0,onClick:fe,"aria-label":E,...ne,children:[L,a.jsx(Ne.default,{iconOnly:!0,isMenuOpen:!1,size:"xSmall",variant:"text",menuId:"date-picker-month-menu",onClick:fe,"aria-label":`달 변경, 현재 ${E}`,startAdornment:a.jsx(_e.default,{name:"ArrowDownFill",size:"xSmall"})})]}),!J&&a.jsx(Ge,{ref:ae,id:"date-picker-title",clickable:!1,"aria-label":E,...ne,children:L}),a.jsx(Xe.default,{name:"ChevronRightLine",size:"small",onClick:Ee,disabled:$e,"aria-label":`다음 달로 이동, 현재 ${E}`})]}):a.jsxs(a.Fragment,{children:[J&&a.jsxs(Be,{ref:ae,clickable:!0,onClick:fe,"aria-label":E,...ne,children:[L,a.jsx(Ne.default,{iconOnly:!0,isMenuOpen:!1,size:"xSmall",variant:"text",menuId:"date-picker-month-menu",onClick:fe,"aria-label":`달 변경, 현재 ${E}`,startAdornment:a.jsx(_e.default,{name:"ArrowDownFill",size:"xSmall"})})]}),!J&&a.jsx(Be,{id:"date-picker-title",clickable:!1,...ne,children:L})]}),J&&a.jsx(ft.default,{id:"date-picker-month-menu",anchorRef:ae,ref:De,open:me,onClose:ot,onChange:at,value:L,placement:M?"bottom-center":"bottom-left",width:160,fitToAnchorWidth:!1,maxHeight:368,children:Array.from({length:130},(t,l)=>{const s=1970+l;return Array.from({length:12},(c,i)=>{const w=i+1,m=w<10?`0${w}`:w,k=new Date(s,i+1,0).getDate(),f=`${s}-${m}-${k}`,T=`${s}-${m}-01`;return G(f,h)||O(T,y)?null:a.jsx(dt.default,{value:`${s}. ${m}`,"aria-label":`${s}년 ${m}월 선택`,children:`${s}. ${m}`},`${s}-${m}`)})})}),a.jsxs(ut.default,{flexDirection:"column",role:"grid","aria-label":`${v}년 ${z}월 달력`,children:[Ce&&a.jsxs(Dt,{id:"date-picker-week-head",role:"row",edgeSpacing:he,children:[a.jsx("span",{role:"columnheader",children:"일"}),a.jsx("span",{role:"columnheader",children:"월"}),a.jsx("span",{role:"columnheader",children:"화"}),a.jsx("span",{role:"columnheader",children:"수"}),a.jsx("span",{role:"columnheader",children:"목"}),a.jsx("span",{role:"columnheader",children:"금"}),a.jsx("span",{role:"columnheader",children:"토"})]}),a.jsx(wt,{ref:Z,role:"presentation",children:a.jsxs($t,{role:"presentation",ref:D,onMouseDown:it,onMouseUp:I,onMouseLeave:I,onTouchStart:st,onTouchEnd:I,onTouchCancel:I,style:{transform:M?`translate3d(-${j*b}px, 0, 0)`:void 0,cursor:M?"grab":void 0,maxHeight:nt},children:[M&&Ye.map(({year:t,month:l,weeks:s},c)=>a.jsx(Ke,{role:"rowgroup",edgeSpacing:he,className:c===1?"week-body-current":"",children:s.map((i,w)=>a.jsx(Pe,{role:"row",children:i.map((m,k)=>{const f=`${t}-${l}-${V(m||0)}`,T=!m,W=R(f,new Date),ke=Array.isArray(B)?B.includes(f):B===f,ee=Array.isArray(N)?N.includes(f):N===f,U=!m||(Array.isArray(K)?K.includes(f):K===f)||O(f,y)||G(f,h),Se=P&&R(f,x),de=P&&R(f,Y),ct=P&&O(f,x)&&G(f,Y),Oe=pe(f,$),lt=Oe&&w===0&&m===1||Oe&&ee,qe=F==null?void 0:F(f);return a.jsxs(Ue,{as:"button",role:"gridcell",variant:Se?"start":de?"end":ct?"middle":void 0,onClick:be(f,U),today:Ae&&W,holiday:ke,tabIndex:lt?0:-1,"aria-rowindex":w+1,"aria-colindex":k+1,selected:ee,"aria-selected":ee,"aria-disabled":U,"aria-hidden":m===null,"data-date":f,onKeyDown:Ie(f,U),children:[a.jsx("div",{"aria-label":`${Qe(f)}`,children:a.jsx("span",{children:m})}),!T&&qe,!T&&xe&&!qe&&a.jsx(Ve,{})]},`${t}-${l}-week-row-${k}-${m?f:`${w}-${k}`}`)})},`${t}-${l}-week-row-${String(i)}`))},`week-body-${t}-${l}`)),!M&&a.jsx(Ke,{role:"rowgroup",edgeSpacing:he,children:Fe.map((t,l)=>a.jsx(Pe,{role:"row",children:t.map((s,c)=>{const i=`${v}-${z}-${V(s||0)}`,w=!s,m=R(i,new Date),k=Array.isArray(B)?B.includes(i):B===i,f=Array.isArray(N)?N.includes(i):N===i,T=!s||(Array.isArray(K)?K.includes(i):K===i)||O(i,y)||G(i,h),W=P&&R(i,x),ke=P&&R(i,Y),ee=P&&O(i,x)&&G(i,Y),U=pe(i,$),Se=U&&l===0&&s===1||U&&f,de=F==null?void 0:F(i);return a.jsxs(Ue,{as:"button",variant:W?"start":ke?"end":ee?"middle":void 0,role:"gridcell",onClick:be(i,T),today:Ae&&m,holiday:k,"aria-rowindex":l+1,"aria-colindex":c+1,selected:f,"aria-selected":f,"aria-disabled":T,"aria-hidden":s===null,tabIndex:Se?0:-1,"data-date":i,onKeyDown:Ie(i,T),children:[a.jsx("div",{"aria-label":`${Qe(i)}`,children:a.jsx("span",{children:s})}),!w&&de,!w&&xe&&!de&&a.jsx(Ve,{})]},`${v}-${z}-week-row-${t}-${s?i:`${l}-${c}`}`)})},`${v}-${z}-week-row-${String(t)}`))})]})})]}),n]})});function Me(e,n){let r=[];const u=new Date(e,n,1),o=new Date(e,n+1,0).getDate(),p=u.getDay();let h=Array.from({length:p}).fill(null);for(let y=1;y<=o;y+=1)h.push(y),(h.length===7||y===o)&&(r.push(h),h=[]);return r=r.map(y=>Array.from({length:7}).map((je,_)=>y[_]||null)),r}function q(e){return String(e+1).length===1?`0${e+1}`:e+1}function V(e){return String(e).length===1?`0${e}`:e}function g(e){if(Array.isArray(e))return e.map(n=>n instanceof Date?`${n.getFullYear()}-${q(n.getMonth())}-${V(n.getDate())}`:n);if(e instanceof Date)return`${e.getFullYear()}-${q(e.getMonth())}-${V(e.getDate())}`;if(typeof e=="number"){const n=new Date(e);return`${n.getFullYear()}-${q(n.getMonth())}-${V(n.getDate())}`}return e}function Qe(e){const[n,r,u]=e.split("-");return`${n}년 ${Number(r)}월 ${Number(u)}일`}function O(e,n){if(!e||!n)return!1;const r=e instanceof Date?e:new Date(e);r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0);const u=r.getTime(),o=n instanceof Date?n:new Date(n);o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0);const p=o.getTime();return u>p}function G(e,n){if(!e||!n)return!1;const r=e instanceof Date?e:new Date(e);r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0);const u=r.getTime(),o=n instanceof Date?n:new Date(n);o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0);const p=o.getTime();return u<p}function pe(e,n){if(!e||!n)return!1;const r=e instanceof Date?e:new Date(e),u=n instanceof Date?n:new Date(n);return`${r.getFullYear()}-${r.getMonth()}`==`${u.getFullYear()}-${u.getMonth()}`}function R(e,n){if(!e||!n)return!1;const r=e instanceof Date?e:new Date(e);r.setHours(0),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0);const u=r.getTime(),o=n instanceof Date?n:new Date(n);o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0);const p=o.getTime();return u===p}function Ze(e,n){if(!e||!Array.isArray(e)||e.length===0)return[];const r=e.map(y=>y instanceof Date?y:y===null?new Date:new Date(y)),u=new Date(Math.min(...r.map(y=>y.getTime()))),o=new Date(Math.max(...r.map(y=>y.getTime()))),p=[],h=new Date(u);for(;h<=o;){if(Array.isArray(n)&&n.includes(h)){h.setDate(h.getDate()+1);continue}else if(n===h){h.setDate(h.getDate()+1);continue}p.push(`${h.getFullYear()}-${q(h.getMonth())}-${V(h.getDate())}`),h.setDate(h.getDate()+1)}return p}exports.default=bt;
@@ -451,10 +451,10 @@ const be = k.div`
451
451
  zt(!0), $t.current = setTimeout(() => {
452
452
  if (g.current && (g.current.style.transition = "none"), b > rt.current) {
453
453
  K(1);
454
- const e = new Date(w.setMonth(w.getMonth() + 1));
454
+ const e = new Date(w.setMonth(w.getMonth() + 1, 1));
455
455
  at(e), l && typeof l == "function" && l(y(e), y), rt.current = 1;
456
456
  } else if (b < rt.current) {
457
- const e = new Date(w.setMonth(w.getMonth() - 1));
457
+ const e = new Date(w.setMonth(w.getMonth() - 1, 1));
458
458
  at(e), l && typeof l == "function" && l(y(e), y), K(1), rt.current = 1;
459
459
  } else
460
460
  rt.current = b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotss/ui",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "React UI components for Dotss",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",