@starasia/date 5.3.2 → 5.4.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.
package/dist/date.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(V,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(V=typeof globalThis<"u"?globalThis:V||self,n(V.Date={},V.jsxRuntime,V.React))})(this,function(V,n,w){"use strict";const P=`@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
1
+ (function(O,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(O=typeof globalThis<"u"?globalThis:O||self,n(O.Date={},O.jsxRuntime,O.React))})(this,function(O,n,b){"use strict";const Z=`@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
2
2
 
3
3
  * {
4
4
  margin: 0;
@@ -588,4 +588,135 @@
588
588
  width: 32px;
589
589
  height: 32px;
590
590
  }
591
- `,Z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A=["January","February","March","April","May","June","July","August","September","October","November","December"],rn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function K(a){const[e,s]=w.useState(a),o=w.useRef(null),l=h=>{o.current&&!o.current.contains(h.target)&&s(!1)};return w.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:o,isComponentVisible:e,setIsComponentVisible:s}}const Q="sa-calendar-input-styles";(a=>{if(!document.getElementById(Q)){const e=document.createElement("style");e.id=Q,e.textContent=a,document.head.appendChild(e)}})(P);const O=a=>{if(a==="xs")return 14;if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},sn=a=>{const{size:e="sm",status:s="default",variant:o="outline",clearable:l,onClear:h,...i}=a,g=w.useRef(null),f=()=>{g.current&&i.onClick&&(g.current.focus(),i.onClick(""))},r=s==="disable"||i.disabled,d=!!i.value,y=l&&d&&!r,m=D=>{D.stopPropagation(),h==null||h()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,onClick:f,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:g})}),y?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:m,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},tn=({date:a,setDate:e,dateRange:s,setDateRange:o,onChange:l,minDate:h,maxDate:i,input:g})=>{var $,c,x;const[f,r]=w.useState(null);let d=new Date(a.getFullYear(),a.getMonth(),1),y=d.getDay(),m=[];const D=a.getMonth(),N=new Date().toDateString(),b=!!(s.from&&!s.to),u=b&&f?f:null;for(let p=0;p<42;p++){p===0&&y===0?d.setDate(d.getDate()-7):p===0?d.setDate(d.getDate()+(p-y)):d.setDate(d.getDate()+1);let v={currentMonth:d.getMonth()===D,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:d.toDateString()===(($=s.from)==null?void 0:$.toDateString())||d.toDateString()===(((c=s.to)==null?void 0:c.toDateString())||((x=s.from)==null?void 0:x.toDateString())),isToday:d.toDateString()===N,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};m.push(v)}const t=p=>{e(p)},k=p=>{let v={...s};if(v.from&&v.to)v={from:p,to:null};else if(!v.from)v={from:p,to:null};else{const S=v.from.getTime();p.getTime()>S?v={from:v.from,to:p}:v={from:p,to:v.from}}o(v),l(v)};return n.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>r(null),children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((p,v)=>n.jsx("p",{children:p},v))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:m.map((p,v)=>{const S=s.from&&s.to&&p.date.getTime()>s.from.getTime()&&p.date.getTime()<s.to.getTime(),T=(()=>{if(!u||!s.from)return!1;const Y=p.date.getTime(),z=s.from.getTime(),F=u.getTime();return F>z?Y>z&&Y<F:Y<z&&Y>F})(),C=b&&f&&p.date.toDateString()===f.toDateString(),E=p.isDisabled,I=()=>S||T?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",L=()=>E?"var(--sa-color-gray-400, #b7b9be)":S||T?"var(--sa-color-gray-500, #8c8f97)":"";return n.jsx("p",{className:`${p.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${p.selected||C?"sa-calendar-days-active":""} ${p.isToday&&!p.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:I(),pointerEvents:E?"none":void 0,cursor:E?"not-allowed":"pointer",color:L(),opacity:C&&!p.selected?.75:1,...g?{}:{width:"100%"}},onClick:()=>{E||(t(p.date),k(p.date))},onMouseEnter:()=>{E||r(p.date)},children:p.number},v)})})]})},on=({date:a,setDate:e,filter:s,setViews:o,dateRange:l,setDateRange:h,onChange:i,minDate:g,maxDate:f,input:r})=>{var N;const d=(N=l.from)==null?void 0:N.getFullYear(),y=a.getFullYear(),m=b=>{s?(D(b),e(b)):(o("days"),e(b))},D=b=>{let u={...l};if(u.from&&u.to)u={from:b,to:null};else if(!u.from)u={from:b,to:null};else{const t=u.from.getTime();b.getTime()>t?u={from:u.from,to:b}:u={from:b,to:u.from}}h(u),i(u)};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((b,u)=>{var $,c,x;const t=l.from!=null&&new Date(y,u).getTime()>l.from.getTime()&&new Date(y,u).getTime()<((($=l.to)==null?void 0:$.getTime())||l.from.getTime()),k=g&&new Date(y,u)<g||f&&new Date(y,u)>f;return n.jsx("p",{className:d===y&&(u===((c=l.from)==null?void 0:c.getMonth())||u===((x=l.to)==null?void 0:x.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:t?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:k?"none":void 0,cursor:k?"not-allowed":"pointer",color:k?"var(--sa-color-gray-400, #b7b9be)":t?"var(--sa-color-gray-500, #8c8f97)":"",...r?{}:{width:"100%"}},onClick:()=>{k||m(new Date(y,u))},children:b.slice(0,3)},u)})})},J=a=>{const e=Math.floor(a/10)*10,s=e+10;return{start:e,end:s}},ln=({date:a,filter:e,setViews:s,setDate:o,dateRange:l,setDateRange:h,onChange:i,minDate:g,maxDate:f,input:r})=>{var k,$;let d=[];const y=a.getFullYear(),{start:m,end:D}=J(y),N=(k=l.from)==null?void 0:k.getFullYear(),b=($=l.to)==null?void 0:$.getFullYear();for(let c=m;c<D;c++){const x=new Date(c,0),p=(!g||x>=g)&&(!f||x<=f),v=N!=null&&c===N||b!=null&&c===b,S=l.from!=null&&l.to!=null&&x>l.from&&x<l.to;d.push({year:c,active:v&&p,highlight:S&&p,disabled:!p})}const u=c=>{e?(t(c),o(c)):(o(c),s("months"))},t=c=>{let x={...l};if(x.from&&x.to)x={from:c,to:null};else if(!x.from)x={from:c,to:null};else{const p=x.from.getTime();c.getTime()>p?x={from:x.from,to:c}:x={from:c,to:x.from}}h(x),i(x)};return n.jsx("div",{className:"sa-calendar-years-preview",children:d.map((c,x)=>n.jsx("p",{className:`${c.active?"sa-calendar-months-active":""} ${c.highlight?"sa-calendar-months-highlight":""} ${c.disabled?"sa-calendar-disabled":""}`,onClick:()=>{c.disabled||u(new Date(c.year,0))},style:{backgroundColor:c.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:c.highlight?"var(--sa-color-gray-500, #8c8f97)":c.active?"":c.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:c.disabled?"not-allowed":"pointer",pointerEvents:c.disbled?"none":"all",...r?{}:{width:"100%"}},children:c.year},x))})},X=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),_=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),dn=({setViews:a,views:e,filter:s,date:o,setDate:l})=>{const h=()=>{s||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},g=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},f=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${J(o.getFullYear()).start} ~ ${J(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:h,children:f()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:g,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})};function W(a){const e=new Date(a),s=e.getFullYear(),o=e.getMonth();return`${e.getDate().toString().padStart(2,"0")} ${rn[o]} ${s}`}const R=({label:a,labelPosition:e="outside-top",required:s,optional:o,description:l,helperText:h,errorText:i,fullWidth:g,size:f="sm",children:r})=>{const d=["sa-date-field",`sa-date-field-size-${f}`,g?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),y=a?n.jsxs("div",{className:"sa-date-field-label-row",children:[n.jsx("span",{className:"sa-date-field-label-text",children:a}),o&&n.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),s&&n.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,m=n.jsxs(n.Fragment,{children:[h&&!i&&n.jsx("p",{className:"sa-date-field-helper",children:h}),i&&n.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return a?e==="outside-left"?n.jsxs("div",{className:`${d} sa-date-field-left`,children:[n.jsxs("div",{className:"sa-date-field-left-label",children:[y,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l})]}),n.jsxs("div",{className:"sa-date-field-input-wrap",children:[r,m]})]}):n.jsxs("div",{className:d,children:[y,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),r,m]}):n.jsxs("div",{className:d,children:[l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),r,m]})},nn="sa-calendar-styles";(a=>{if(!document.getElementById(nn)){const e=document.createElement("style");e.id=nn,e.textContent=a,document.head.appendChild(e)}})(P);const cn=w.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,disabled:l,minDate:h,maxDate:i,placeholder:g,size:f="sm",variant:r,status:d,clearable:y,fullWidth:m=!0,withPadding:D=!0,label:N,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c},x)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),C=w.useRef(null),[E,I]=w.useState("days"),[L,Y]=w.useState(new Date),[z,F]=w.useState({from:(a==null?void 0:a.from)??null,to:(a==null?void 0:a.to)??null});w.useEffect(()=>{if(a){const M=a;M.from&&Y(M.from),F(M)}else Y(new Date),F({from:null,to:null})},[a]),w.useEffect(()=>{s&&I(s)},[s]),w.useEffect(()=>{s||I("days")},[S]),w.useEffect(()=>{o||T(!0)},[o]);const G=()=>{var M,j;if(!a)return"";if(s){if(E==="days")return`${W(z.from)} ~ ${W(z.to||z.from)||"-"}`;if(E==="months")return`${A[z.from.getMonth()]} ~ ${z.to?A[z.to.getMonth()]:"-"}`;if(E==="years")return`${(M=z.from)==null?void 0:M.getFullYear()} ~ ${((j=z.to)==null?void 0:j.getFullYear())||"-"}`}else return`${W(z.from)} ~ ${W(z.to||z.from)||"-"}`},B=()=>{if(C.current&&v.current&&o){const M=v.current.getBoundingClientRect(),j=C.current.getBoundingClientRect();window.innerWidth<M.left+j.width?C.current.style.left=`${M.left-j.width+M.width}px`:C.current.style.left=`${M.left}px`,M.top+j.height>window.innerHeight?C.current.style.top=`${M.y-(M.height+j.height-28)}px`:C.current.style.top=`${M.y+M.height}px`}};w.useEffect(()=>{C.current&&v.current&&o&&B()},[C,v,S]),w.useEffect(()=>(window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}),[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?v:null,children:[o?n.jsx(sn,{value:G(),inputMode:"none",onClick:()=>{T(!0)},onChange:()=>{},disabled:l,placeholder:g,size:f,variant:r,status:p,clearable:y,onClear:()=>e(void 0)}):null,S?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${f||"sm"} ${o?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:C,children:[n.jsx(dn,{setViews:I,views:E,filter:s,date:L,setDate:Y}),n.jsx("div",{className:"sa-calendar-body",children:E==="days"?n.jsx(tn,{date:L,setDate:Y,setIsComponentVisible:T,dateRange:z,setDateRange:F,input:o,onChange:e,minDate:h,maxDate:i}):E==="months"?n.jsx(on,{date:L,setDate:Y,filter:s,setViews:I,dateRange:z,setDateRange:F,setIsComponentVisible:T,input:o,onChange:e,minDate:h,maxDate:i}):n.jsx(ln,{date:L,setDate:Y,filter:s,setViews:I,dateRange:z,setDateRange:F,setIsComponentVisible:T,input:o,onChange:e,minDate:h,maxDate:i})})]}):null]});return n.jsx(R,{label:N,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c,fullWidth:m,size:f,children:U})}),en="sa-calendar-input-styles";(a=>{if(!document.getElementById(en)){const e=document.createElement("style");e.id=en,e.textContent=a,document.head.appendChild(e)}})(P);const H=a=>{if(a==="xs")return 14;if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},pn=a=>{const{size:e="sm",status:s="default",variant:o="outline",clearable:l,onClear:h,...i}=a,g=w.useRef(null),f=()=>{g.current&&i.onClick&&(g.current.focus(),i.onClick(""))},r=s==="disable"||i.disabled,d=!!i.value,y=l&&d&&!r,m=D=>{D.stopPropagation(),h==null||h()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,onClick:f,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:g})}),y?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:m,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},hn=({date:a,setDate:e,previewDate:s,setPreviewDate:o,setIsComponentVisible:l,minDate:h,maxDate:i,input:g,onChange:f,hasValue:r})=>{let d=new Date(s.getFullYear(),s.getMonth(),1),y=d.getDay(),m=[];const D=a.toDateString(),N=new Date().toDateString(),b=s.getMonth();for(let t=0;t<42;t++){t===0&&y===0?d.setDate(d.getDate()-7):t===0?d.setDate(d.getDate()+(t-y)):d.setDate(d.getDate()+1);let k={currentMonth:d.getMonth()===b,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:r&&d.toDateString()===D,isToday:d.toDateString()===N,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};m.push(k)}const u=t=>{(!h||t>=h)&&(!i||t<=i)&&(e(t),f(t),o(t),g&&l(!1))};return n.jsxs("div",{className:"sa-calendar-days-preivew",children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((t,k)=>n.jsx("p",{children:t},k))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:m.map((t,k)=>{const $=t.isDisabled;return n.jsx("p",{className:`${t.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${t.selected?"sa-calendar-days-active":""} ${t.isToday&&!t.selected?"sa-calendar-days-today":""}`,style:{color:$?"#ccc":void 0,pointerEvents:$?"none":void 0,cursor:$?"not-allowed":"pointer",...g?{}:{width:"100%"}},onClick:()=>{$||u(t.date)},children:t.number},k)})})]})},fn=({date:a,setDate:e,filter:s,setViews:o,onChange:l,previewDate:h,setPreviewDate:i,minDate:g,maxDate:f,input:r,hasValue:d})=>{const y=a.getMonth(),m=a.getFullYear(),D=h.getFullYear(),N=b=>{(!g||b>=g)&&(!f||b<=f)&&(s?(l(b),e(b),i(b)):(o("days"),i(b)))};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((b,u)=>{const t=g&&new Date(D,u,1)<g||f&&new Date(D,u+1,0)>f;return n.jsx("p",{className:d&&u===y&&D===m?"sa-calendar-months-active":"",style:{color:t?"#ccc":void 0,pointerEvents:t?"none":void 0,cursor:t?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{t||N(new Date(D,u))},children:b.slice(0,3)},u)})})},q=a=>{const e=Math.floor(a/10)*10,s=e+10;return{start:e,end:s}},un=({date:a,filter:e,setViews:s,setDate:o,onChange:l,previewDate:h,setPreviewDate:i,minDate:g,maxDate:f,input:r,hasValue:d})=>{let y=[];const m=h.getFullYear(),{start:D,end:N}=q(m),b=a.getFullYear();for(let t=D;t<N;t++){let k=g&&new Date(t,0,1)<g||f&&new Date(t,11,31)>f;y.push({year:t,active:!!d&&t===b,isDisabled:k})}const u=t=>{(!g||t>=g)&&(!f||t<=f)&&(e?(l(t),o(t),i(t)):(s("months"),i(t)))};return n.jsx("div",{className:"sa-calendar-years-preview",children:y.map((t,k)=>n.jsx("p",{className:t.active?"sa-calendar-months-active":"",style:{color:t.isDisabled?"#ccc":void 0,pointerEvents:t.isDisabled?"none":void 0,cursor:t.isDisabled?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{t.isDisabled||u(new Date(t.year,0))},children:t.year},k))})},gn=({setViews:a,views:e,filter:s,previewDate:o,setPreviewDate:l})=>{const h=()=>{s||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},g=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},f=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:h,children:f()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:g,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})},an="sa-calendar-styles";(a=>{if(!document.getElementById(an)){const e=document.createElement("style");e.id=an,e.textContent=a,document.head.appendChild(e)}})(P);const bn=w.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,disabled:l,minDate:h,maxDate:i,placeholder:g,size:f="sm",variant:r,status:d,clearable:y,fullWidth:m=!0,withPadding:D=!0,label:N,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c},x)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),C=w.useRef(null),[E,I]=w.useState("days"),[L,Y]=w.useState(new Date),[z,F]=w.useState(new Date);w.useEffect(()=>{a?(Y(a),F(a)):(Y(new Date),F(new Date))},[a]),w.useEffect(()=>{s&&I(s)},[s]),w.useEffect(()=>{s||I("days")},[S]),w.useEffect(()=>{o||T(!0)},[o]);const G=()=>a?s==="days"?W(L):s==="months"?`${A[L.getMonth()]} ${L.getFullYear()}`:s==="years"?L.getFullYear():W(L):"",B=()=>{if(C.current&&v.current&&o){const M=v.current.getBoundingClientRect(),j=C.current.getBoundingClientRect();window.innerWidth<M.left+j.width?C.current.style.left=`${M.left-j.width+M.width}px`:C.current.style.left=`${M.left}px`,M.top+j.height>window.innerHeight?C.current.style.top=`${M.y-(M.height+j.height-28)}px`:C.current.style.top=`${M.y+M.height}px`}};w.useEffect(()=>{C.current&&v.current&&o&&B()},[C,v,S]),w.useEffect(()=>(window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}),[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?v:null,children:[o?n.jsx(pn,{value:G(),onClick:()=>T(!0),onChange:()=>{},placeholder:g,disabled:l,size:f,variant:r,status:p,inputMode:"none",clearable:y,onClear:()=>e(void 0)}):null,S?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${f||"sm"} ${o?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:C,children:[n.jsx(gn,{setViews:I,views:E,filter:s,previewDate:z,setPreviewDate:F,isComponentVisible:S}),n.jsx("div",{className:"sa-calendar-body",children:E==="days"?n.jsx(hn,{date:L,setDate:Y,previewDate:z,setPreviewDate:F,setIsComponentVisible:T,input:o,minDate:h,maxDate:i,onChange:e,hasValue:a!=null}):E==="months"?n.jsx(fn,{date:L,setDate:Y,previewDate:z,setPreviewDate:F,filter:s,setViews:I,onChange:e,minDate:h,maxDate:i,input:o,hasValue:a!=null}):n.jsx(un,{date:L,setDate:Y,previewDate:z,setPreviewDate:F,filter:s,setViews:I,onChange:e,minDate:h,maxDate:i,input:o,hasValue:a!=null})})]}):null]});return n.jsx(R,{label:N,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c,fullWidth:m,size:f,children:U})}),vn=w.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,rangedDate:l,disabled:h,minDate:i,maxDate:g,placeholder:f,size:r,variant:d,status:y,clearable:m,fullWidth:D,withPadding:N,label:b,labelPosition:u,required:t,optional:k,description:$,helperText:c,errorText:x},p)=>{const v={onChange:e,value:a,input:o,filter:s,disabled:h,minDate:i,maxDate:g,placeholder:f,size:r,variant:d,status:y,clearable:m,fullWidth:D,withPadding:N,label:b,labelPosition:u,required:t,optional:k,description:$,helperText:c,errorText:x};return n.jsx(n.Fragment,{children:l?n.jsx(cn,{...v,ref:p}):n.jsx(bn,{...v,ref:p})})});V.StarasiaDate=vn,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
591
+ `,ln=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],J=["January","February","March","April","May","June","July","August","September","October","November","December"],yn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function nn(e){const[a,r]=b.useState(e),s=b.useRef(null),o=i=>{s.current&&!s.current.contains(i.target)&&r(!1)};return b.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:s,isComponentVisible:a,setIsComponentVisible:r}}const dn="sa-calendar-input-styles";(e=>{if(!(typeof document>"u")&&!document.getElementById(dn)){const a=document.createElement("style");a.id=dn,a.textContent=e,document.head.appendChild(a)}})(Z);const q=e=>{if(e==="xs")return 14;if(e==="sm")return 16;if(e==="md")return 16;if(e==="lg")return 20},wn=e=>{const{size:a="sm",status:r="default",variant:s="outline",clearable:o,onClear:i,...l}=e,p=b.useRef(null),h=()=>{p.current&&l.onClick&&(p.current.focus(),l.onClick(""))},t=r==="disable"||l.disabled,c=!!l.value,w=o&&c&&!t,C=D=>{D.stopPropagation(),i==null||i()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:q(a),height:q(a),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...l,disabled:t,value:l.value,ref:p})}),w?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:C,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:q(a),height:q(a),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:q(a),height:q(a),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},xn=({date:e,setDate:a,dateRange:r,setDateRange:s,onChange:o,minDate:i,maxDate:l,input:p})=>{var F,g,M;const[h,t]=b.useState(null);let c=new Date(e.getFullYear(),e.getMonth(),1),w=c.getDay(),C=[];const D=e.getMonth(),L=new Date().toDateString(),y=!!(r.from&&!r.to),v=y&&h?h:null;for(let f=0;f<42;f++){f===0&&w===0?c.setDate(c.getDate()-7):f===0?c.setDate(c.getDate()+(f-w)):c.setDate(c.getDate()+1);let x={currentMonth:c.getMonth()===D,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:c.toDateString()===((F=r.from)==null?void 0:F.toDateString())||c.toDateString()===(((g=r.to)==null?void 0:g.toDateString())||((M=r.from)==null?void 0:M.toDateString())),isToday:c.toDateString()===L,year:c.getFullYear(),isDisabled:i&&c<i||l&&c>l};C.push(x)}const d=f=>{a(f)},$=f=>{let x={...r};if(x.from&&x.to)x={from:f,to:null};else if(!x.from)x={from:f,to:null};else{const B=x.from.getTime();f.getTime()>B?x={from:x.from,to:f}:x={from:f,to:x.from}}s(x),o(x)};return n.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>t(null),children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:ln.map((f,x)=>n.jsx("p",{children:f},x))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:C.map((f,x)=>{const B=r.from&&r.to&&f.date.getTime()>r.from.getTime()&&f.date.getTime()<r.to.getTime(),P=(()=>{if(!v||!r.from)return!1;const z=f.date.getTime(),k=r.from.getTime(),I=v.getTime();return I>k?z>k&&z<I:z<k&&z>I})(),Y=y&&h&&f.date.toDateString()===h.toDateString(),S=f.isDisabled,T=()=>B||P?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",m=()=>S?"var(--sa-color-gray-400, #b7b9be)":B||P?"var(--sa-color-gray-500, #8c8f97)":"";return n.jsx("p",{className:`${f.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${f.selected||Y?"sa-calendar-days-active":""} ${f.isToday&&!f.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:T(),pointerEvents:S?"none":void 0,cursor:S?"not-allowed":"pointer",color:m(),opacity:Y&&!f.selected?.75:1,...p?{}:{width:"100%"}},onClick:()=>{S||(d(f.date),$(f.date))},onMouseEnter:()=>{S||t(f.date)},children:f.number},x)})})]})},kn=({date:e,setDate:a,filter:r,setViews:s,dateRange:o,setDateRange:i,onChange:l,minDate:p,maxDate:h,input:t})=>{var L;const c=(L=o.from)==null?void 0:L.getFullYear(),w=e.getFullYear(),C=y=>{r?(D(y),a(y)):(s("days"),a(y))},D=y=>{let v={...o};if(v.from&&v.to)v={from:y,to:null};else if(!v.from)v={from:y,to:null};else{const d=v.from.getTime();y.getTime()>d?v={from:v.from,to:y}:v={from:y,to:v.from}}i(v),l(v)};return n.jsx("div",{className:"sa-calendar-months-preview",children:J.map((y,v)=>{var F,g,M;const d=o.from!=null&&new Date(w,v).getTime()>o.from.getTime()&&new Date(w,v).getTime()<(((F=o.to)==null?void 0:F.getTime())||o.from.getTime()),$=p&&new Date(w,v)<p||h&&new Date(w,v)>h;return n.jsx("p",{className:c===w&&(v===((g=o.from)==null?void 0:g.getMonth())||v===((M=o.to)==null?void 0:M.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:d?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:$?"none":void 0,cursor:$?"not-allowed":"pointer",color:$?"var(--sa-color-gray-400, #b7b9be)":d?"var(--sa-color-gray-500, #8c8f97)":"",...t?{}:{width:"100%"}},onClick:()=>{$||C(new Date(w,v))},children:y.slice(0,3)},v)})})},en=e=>{const a=Math.floor(e/10)*10,r=a+10;return{start:a,end:r}},Mn=({date:e,filter:a,setViews:r,setDate:s,dateRange:o,setDateRange:i,onChange:l,minDate:p,maxDate:h,input:t})=>{var $,F;let c=[];const w=e.getFullYear(),{start:C,end:D}=en(w),L=($=o.from)==null?void 0:$.getFullYear(),y=(F=o.to)==null?void 0:F.getFullYear();for(let g=C;g<D;g++){const M=new Date(g,0),f=(!p||M>=p)&&(!h||M<=h),x=L!=null&&g===L||y!=null&&g===y,B=o.from!=null&&o.to!=null&&M>o.from&&M<o.to;c.push({year:g,active:x&&f,highlight:B&&f,disabled:!f})}const v=g=>{a?(d(g),s(g)):(s(g),r("months"))},d=g=>{let M={...o};if(M.from&&M.to)M={from:g,to:null};else if(!M.from)M={from:g,to:null};else{const f=M.from.getTime();g.getTime()>f?M={from:M.from,to:g}:M={from:g,to:M.from}}i(M),l(M)};return n.jsx("div",{className:"sa-calendar-years-preview",children:c.map((g,M)=>n.jsx("p",{className:`${g.active?"sa-calendar-months-active":""} ${g.highlight?"sa-calendar-months-highlight":""} ${g.disabled?"sa-calendar-disabled":""}`,onClick:()=>{g.disabled||v(new Date(g.year,0))},style:{backgroundColor:g.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:g.highlight?"var(--sa-color-gray-500, #8c8f97)":g.active?"":g.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:g.disabled?"not-allowed":"pointer",pointerEvents:g.disbled?"none":"all",...t?{}:{width:"100%"}},children:g.year},M))})},cn=({...e})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...e,children:n.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),pn=({...e})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...e,children:n.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Nn=({setViews:e,views:a,filter:r,date:s,setDate:o})=>{const i=()=>{r||e(t=>t==="days"?"months":t==="months"?"years":"days")},l=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()+10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()+1,t.getMonth()));return}o(t=>new Date(t.getFullYear(),t.getMonth()+1))},p=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()-10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()-1,t.getMonth()));return}o(t=>new Date(t.getMonth()===0?t.getFullYear()-1:t.getFullYear(),t.getMonth()===0?11:t.getMonth()-1))},h=()=>{if(a==="days")return`${J[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${en(s.getFullYear()).start} ~ ${en(s.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:i,children:h()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:n.jsx(cn,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:l,children:n.jsx(pn,{})})]})]})};function G(e){const a=new Date(e),r=a.getFullYear(),s=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${yn[s]} ${r}`}const an=({label:e,labelPosition:a="outside-top",required:r,optional:s,description:o,helperText:i,errorText:l,fullWidth:p,size:h="sm",children:t})=>{const c=["sa-date-field",`sa-date-field-size-${h}`,p?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),w=e?n.jsxs("div",{className:"sa-date-field-label-row",children:[n.jsx("span",{className:"sa-date-field-label-text",children:e}),s&&n.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),r&&n.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,C=n.jsxs(n.Fragment,{children:[i&&!l&&n.jsx("p",{className:"sa-date-field-helper",children:i}),l&&n.jsx("p",{className:"sa-date-field-error-msg",children:l})]});return e?a==="outside-left"?n.jsxs("div",{className:`${c} sa-date-field-left`,children:[n.jsxs("div",{className:"sa-date-field-left-label",children:[w,o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o})]}),n.jsxs("div",{className:"sa-date-field-input-wrap",children:[t,C]})]}):n.jsxs("div",{className:c,children:[w,o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o}),t,C]}):n.jsxs("div",{className:c,children:[o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o}),t,C]})},un="sa-calendar-styles";(e=>{if(!(typeof document>"u")&&!document.getElementById(un)){const a=document.createElement("style");a.id=un,a.textContent=e,document.head.appendChild(a)}})(Z);const Cn=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,disabled:o,minDate:i,maxDate:l,placeholder:p,size:h="sm",variant:t,status:c,clearable:w,fullWidth:C=!0,withPadding:D=!0,label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g},M)=>{const f=g?"error":c,{ref:x,isComponentVisible:B,setIsComponentVisible:P}=nn(!1),Y=b.useRef(null),[S,T]=b.useState("days"),[m,z]=b.useState(new Date),[k,I]=b.useState({from:(e==null?void 0:e.from)??null,to:(e==null?void 0:e.to)??null});b.useEffect(()=>{if(e){const N=e;N.from&&z(N.from),I(N)}else z(new Date),I({from:null,to:null})},[e]),b.useEffect(()=>{r&&T(r)},[r]),b.useEffect(()=>{r||T("days")},[B]),b.useEffect(()=>{s||P(!0)},[s]);const H=()=>{var N,j;if(!e)return"";if(r){if(S==="days")return`${G(k.from)} ~ ${G(k.to||k.from)||"-"}`;if(S==="months")return`${J[k.from.getMonth()]} ~ ${k.to?J[k.to.getMonth()]:"-"}`;if(S==="years")return`${(N=k.from)==null?void 0:N.getFullYear()} ~ ${((j=k.to)==null?void 0:j.getFullYear())||"-"}`}else return`${G(k.from)} ~ ${G(k.to||k.from)||"-"}`},V=()=>{if(Y.current&&x.current&&s){const N=x.current.getBoundingClientRect(),j=Y.current.getBoundingClientRect();window.innerWidth<N.left+j.width?Y.current.style.left=`${N.left-j.width+N.width}px`:Y.current.style.left=`${N.left}px`,N.top+j.height>window.innerHeight?Y.current.style.top=`${N.y-(N.height+j.height-28)}px`:Y.current.style.top=`${N.y+N.height}px`}};b.useEffect(()=>{Y.current&&x.current&&s&&V()},[Y,x,B]),b.useEffect(()=>(window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),()=>{window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V)}),[]);const K=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?x:null,children:[s?n.jsx(wn,{value:H(),inputMode:"none",onClick:()=>{P(!0)},onChange:()=>{},disabled:o,placeholder:p,size:h,variant:t,status:f,clearable:w,onClear:()=>a(void 0)}):null,B?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${s?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:o?{pointerEvents:"none"}:void 0,ref:Y,children:[n.jsx(Nn,{setViews:T,views:S,filter:r,date:m,setDate:z}),n.jsx("div",{className:"sa-calendar-body",children:S==="days"?n.jsx(xn,{date:m,setDate:z,setIsComponentVisible:P,dateRange:k,setDateRange:I,input:s,onChange:a,minDate:i,maxDate:l}):S==="months"?n.jsx(kn,{date:m,setDate:z,filter:r,setViews:T,dateRange:k,setDateRange:I,setIsComponentVisible:P,input:s,onChange:a,minDate:i,maxDate:l}):n.jsx(Mn,{date:m,setDate:z,filter:r,setViews:T,dateRange:k,setDateRange:I,setIsComponentVisible:P,input:s,onChange:a,minDate:i,maxDate:l})})]}):null]});return n.jsx(an,{label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g,fullWidth:C,size:h,children:K})}),hn="sa-calendar-input-styles";(e=>{if(!(typeof document>"u")&&!document.getElementById(hn)){const a=document.createElement("style");a.id=hn,a.textContent=e,document.head.appendChild(a)}})(Z);const U=e=>{if(e==="xs")return 14;if(e==="sm")return 16;if(e==="md")return 16;if(e==="lg")return 20},$n=e=>{const{size:a="sm",status:r="default",variant:s="outline",clearable:o,onClear:i,...l}=e,p=b.useRef(null),h=()=>{p.current&&l.onClick&&(p.current.focus(),l.onClick(""))},t=r==="disable"||l.disabled,c=!!l.value,w=o&&c&&!t,C=D=>{D.stopPropagation(),i==null||i()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:U(a),height:U(a),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...l,disabled:t,value:l.value,ref:p})}),w?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:C,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:U(a),height:U(a),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:U(a),height:U(a),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},zn=({date:e,setDate:a,previewDate:r,setPreviewDate:s,setIsComponentVisible:o,minDate:i,maxDate:l,input:p,onChange:h,hasValue:t})=>{let c=new Date(r.getFullYear(),r.getMonth(),1),w=c.getDay(),C=[];const D=e.toDateString(),L=new Date().toDateString(),y=r.getMonth();for(let d=0;d<42;d++){d===0&&w===0?c.setDate(c.getDate()-7):d===0?c.setDate(c.getDate()+(d-w)):c.setDate(c.getDate()+1);let $={currentMonth:c.getMonth()===y,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:t&&c.toDateString()===D,isToday:c.toDateString()===L,year:c.getFullYear(),isDisabled:i&&c<i||l&&c>l};C.push($)}const v=d=>{(!i||d>=i)&&(!l||d<=l)&&(a(d),h(d),s(d),p&&o(!1))};return n.jsxs("div",{className:"sa-calendar-days-preivew",children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:ln.map((d,$)=>n.jsx("p",{children:d},$))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:C.map((d,$)=>{const F=d.isDisabled;return n.jsx("p",{className:`${d.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${d.selected?"sa-calendar-days-active":""} ${d.isToday&&!d.selected?"sa-calendar-days-today":""}`,style:{color:F?"#ccc":void 0,pointerEvents:F?"none":void 0,cursor:F?"not-allowed":"pointer",...p?{}:{width:"100%"}},onClick:()=>{F||v(d.date)},children:d.number},$)})})]})},Dn=({date:e,setDate:a,filter:r,setViews:s,onChange:o,previewDate:i,setPreviewDate:l,minDate:p,maxDate:h,input:t,hasValue:c})=>{const w=e.getMonth(),C=e.getFullYear(),D=i.getFullYear(),L=y=>{(!p||y>=p)&&(!h||y<=h)&&(r?(o(y),a(y),l(y)):(s("days"),l(y)))};return n.jsx("div",{className:"sa-calendar-months-preview",children:J.map((y,v)=>{const d=p&&new Date(D,v,1)<p||h&&new Date(D,v+1,0)>h;return n.jsx("p",{className:c&&v===w&&D===C?"sa-calendar-months-active":"",style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...t?{}:{width:"100%"}},onClick:()=>{d||L(new Date(D,v))},children:y.slice(0,3)},v)})})},rn=e=>{const a=Math.floor(e/10)*10,r=a+10;return{start:a,end:r}},En=({date:e,filter:a,setViews:r,setDate:s,onChange:o,previewDate:i,setPreviewDate:l,minDate:p,maxDate:h,input:t,hasValue:c})=>{let w=[];const C=i.getFullYear(),{start:D,end:L}=rn(C),y=e.getFullYear();for(let d=D;d<L;d++){let $=p&&new Date(d,0,1)<p||h&&new Date(d,11,31)>h;w.push({year:d,active:!!c&&d===y,isDisabled:$})}const v=d=>{(!p||d>=p)&&(!h||d<=h)&&(a?(o(d),s(d),l(d)):(r("months"),l(d)))};return n.jsx("div",{className:"sa-calendar-years-preview",children:w.map((d,$)=>n.jsx("p",{className:d.active?"sa-calendar-months-active":"",style:{color:d.isDisabled?"#ccc":void 0,pointerEvents:d.isDisabled?"none":void 0,cursor:d.isDisabled?"not-allowed":"pointer",...t?{}:{width:"100%"}},onClick:()=>{d.isDisabled||v(new Date(d.year,0))},children:d.year},$))})},Yn=({setViews:e,views:a,filter:r,previewDate:s,setPreviewDate:o})=>{const i=()=>{r||e(t=>t==="days"?"months":t==="months"?"years":"days")},l=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()+10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()+1,t.getMonth()));return}o(t=>new Date(t.getFullYear(),t.getMonth()+1))},p=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()-10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()-1,t.getMonth()));return}o(t=>new Date(t.getMonth()===0?t.getFullYear()-1:t.getFullYear(),t.getMonth()===0?11:t.getMonth()-1))},h=()=>{if(a==="days")return`${J[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${rn(s.getFullYear()).start} ~ ${rn(s.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:i,children:h()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:n.jsx(cn,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:l,children:n.jsx(pn,{})})]})]})},fn="sa-calendar-styles";(e=>{if(!(typeof document>"u")&&!document.getElementById(fn)){const a=document.createElement("style");a.id=fn,a.textContent=e,document.head.appendChild(a)}})(Z);const Sn=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,disabled:o,minDate:i,maxDate:l,placeholder:p,size:h="sm",variant:t,status:c,clearable:w,fullWidth:C=!0,withPadding:D=!0,label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g},M)=>{const f=g?"error":c,{ref:x,isComponentVisible:B,setIsComponentVisible:P}=nn(!1),Y=b.useRef(null),[S,T]=b.useState("days"),[m,z]=b.useState(new Date),[k,I]=b.useState(new Date);b.useEffect(()=>{e?(z(e),I(e)):(z(new Date),I(new Date))},[e]),b.useEffect(()=>{r&&T(r)},[r]),b.useEffect(()=>{r||T("days")},[B]),b.useEffect(()=>{s||P(!0)},[s]);const H=()=>e?r==="days"?G(m):r==="months"?`${J[m.getMonth()]} ${m.getFullYear()}`:r==="years"?m.getFullYear():G(m):"",V=()=>{if(Y.current&&x.current&&s){const N=x.current.getBoundingClientRect(),j=Y.current.getBoundingClientRect();window.innerWidth<N.left+j.width?Y.current.style.left=`${N.left-j.width+N.width}px`:Y.current.style.left=`${N.left}px`,N.top+j.height>window.innerHeight?Y.current.style.top=`${N.y-(N.height+j.height-28)}px`:Y.current.style.top=`${N.y+N.height}px`}};b.useEffect(()=>{Y.current&&x.current&&s&&V()},[Y,x,B]),b.useEffect(()=>(window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),()=>{window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V)}),[]);const K=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?x:null,children:[s?n.jsx($n,{value:H(),onClick:()=>P(!0),onChange:()=>{},placeholder:p,disabled:o,size:h,variant:t,status:f,inputMode:"none",clearable:w,onClear:()=>a(void 0)}):null,B?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${s?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:o?{pointerEvents:"none"}:void 0,ref:Y,children:[n.jsx(Yn,{setViews:T,views:S,filter:r,previewDate:k,setPreviewDate:I,isComponentVisible:B}),n.jsx("div",{className:"sa-calendar-body",children:S==="days"?n.jsx(zn,{date:m,setDate:z,previewDate:k,setPreviewDate:I,setIsComponentVisible:P,input:s,minDate:i,maxDate:l,onChange:a,hasValue:e!=null}):S==="months"?n.jsx(Dn,{date:m,setDate:z,previewDate:k,setPreviewDate:I,filter:r,setViews:T,onChange:a,minDate:i,maxDate:l,input:s,hasValue:e!=null}):n.jsx(En,{date:m,setDate:z,previewDate:k,setPreviewDate:I,filter:r,setViews:T,onChange:a,minDate:i,maxDate:l,input:s,hasValue:e!=null})})]}):null]});return n.jsx(an,{label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g,fullWidth:C,size:h,children:K})}),Ln=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,rangedDate:o,disabled:i,minDate:l,maxDate:p,placeholder:h,size:t,variant:c,status:w,clearable:C,fullWidth:D,withPadding:L,label:y,labelPosition:v,required:d,optional:$,description:F,helperText:g,errorText:M},f)=>{const x={onChange:a,value:e,input:s,filter:r,disabled:i,minDate:l,maxDate:p,placeholder:h,size:t,variant:c,status:w,clearable:C,fullWidth:D,withPadding:L,label:y,labelPosition:v,required:d,optional:$,description:F,helperText:g,errorText:M};return n.jsx(n.Fragment,{children:o?n.jsx(Cn,{...x,ref:f}):n.jsx(Sn,{...x,ref:f})})}),Fn=`/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
592
+ date.module.css, injected alongside this sheet) and the .sa-calendar /
593
+ .sa-calendar-input-* shells for the box + masked input. */
594
+
595
+ .sa-time-columns {
596
+ display: flex;
597
+ align-items: stretch;
598
+ gap: var(--sa-spacing-xs, 4px);
599
+ width: max-content;
600
+ }
601
+
602
+ .sa-time-col {
603
+ display: flex;
604
+ flex-direction: column;
605
+ min-width: 56px;
606
+ }
607
+
608
+ .sa-time-col-head {
609
+ font-size: var(--sa-font-size-sm, 12px);
610
+ font-weight: 500;
611
+ color: var(--sa-date-text-subtle);
612
+ text-align: center;
613
+ padding-block: var(--sa-spacing-xs, 4px);
614
+ position: sticky;
615
+ top: 0;
616
+ background: var(--sa-date-bg);
617
+ z-index: 1;
618
+ }
619
+
620
+ .sa-time-col-list {
621
+ display: flex;
622
+ flex-direction: column;
623
+ gap: 2px;
624
+ max-height: 220px;
625
+ overflow-y: auto;
626
+ padding-right: 4px;
627
+ scrollbar-width: thin;
628
+ }
629
+
630
+ .sa-time-col-list::-webkit-scrollbar {
631
+ width: 6px;
632
+ }
633
+ .sa-time-col-list::-webkit-scrollbar-thumb {
634
+ background: var(--sa-date-border-color);
635
+ border-radius: 999px;
636
+ }
637
+
638
+ .sa-time-opt {
639
+ appearance: none;
640
+ border: none;
641
+ outline: none;
642
+ cursor: pointer;
643
+ font-family: inherit;
644
+ font-size: var(--sa-font-size-md, 14px);
645
+ font-weight: 500;
646
+ color: var(--sa-date-text-primary);
647
+ background: transparent;
648
+ border-radius: var(--sa-date-radius);
649
+ padding: var(--sa-spacing-xs, 4px) var(--sa-spacing-sm, 8px);
650
+ text-align: center;
651
+ transition: background-color 0.12s ease, color 0.12s ease;
652
+ white-space: nowrap;
653
+ }
654
+
655
+ .sa-time-opt:hover:not(:disabled):not(.sa-time-opt-active) {
656
+ background: var(--sa-date-brand-subtle);
657
+ }
658
+
659
+ .sa-time-opt-active {
660
+ background: var(--sa-date-brand);
661
+ color: #ffffff;
662
+ }
663
+
664
+ .sa-time-opt:disabled {
665
+ color: var(--sa-date-text-muted);
666
+ cursor: not-allowed;
667
+ }
668
+
669
+ .sa-time-opt:focus-visible {
670
+ outline: 2px solid var(--sa-date-brand);
671
+ outline-offset: 1px;
672
+ }
673
+
674
+ .sa-time-divider {
675
+ width: 1px;
676
+ align-self: stretch;
677
+ background: var(--sa-date-border-subtle);
678
+ margin-inline: 2px;
679
+ }
680
+
681
+ .sa-time-footer {
682
+ display: flex;
683
+ align-items: center;
684
+ justify-content: space-between;
685
+ gap: var(--sa-spacing-sm, 8px);
686
+ border-top: 1px solid var(--sa-date-border-subtle);
687
+ padding-top: var(--sa-spacing-sm, 8px);
688
+ margin-top: 2px;
689
+ }
690
+
691
+ .sa-time-footer-btn {
692
+ appearance: none;
693
+ border: none;
694
+ background: transparent;
695
+ cursor: pointer;
696
+ font-family: inherit;
697
+ font-size: var(--sa-font-size-sm, 12px);
698
+ font-weight: 500;
699
+ color: var(--sa-date-brand);
700
+ border-radius: var(--sa-date-radius);
701
+ padding: var(--sa-spacing-xs, 4px) var(--sa-spacing-sm, 8px);
702
+ transition: background-color 0.12s ease;
703
+ }
704
+
705
+ .sa-time-footer-btn:hover {
706
+ background: var(--sa-date-brand-subtle);
707
+ }
708
+
709
+ .sa-time-footer-btn-muted {
710
+ color: var(--sa-date-text-subtle);
711
+ }
712
+
713
+ .sa-time-footer-btn:focus-visible {
714
+ outline: 2px solid var(--sa-date-brand);
715
+ outline-offset: 1px;
716
+ }
717
+
718
+ /* Clock glyph in the input left slot inherits sizing from the date input. */
719
+ .sa-time-input-wrap {
720
+ width: 100%;
721
+ }
722
+ `,sn=(e,a,r)=>Math.min(r,Math.max(a,e)),A=e=>String(e).padStart(2,"0"),tn=e=>{if(!e)return null;const a=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(e.trim());if(!a)return null;const r=Number(a[1]),s=Number(a[2]),o=a[3]!=null?Number(a[3]):0;return r>23||s>59||o>59?null:{h:r,m:s,s:o}},In=(e,a)=>a?`${A(e.h)}:${A(e.m)}:${A(e.s)}`:`${A(e.h)}:${A(e.m)}`,W=e=>e.h*60+e.m,Tn=(e,a,r)=>{const s=r?`:${A(e.s)}`:"";if(a==="12h"){const o=e.h>=12?"PM":"AM",i=e.h%12===0?12:e.h%12;return`${A(i)}:${A(e.m)}${s} ${o}`}return`${A(e.h)}:${A(e.m)}${s}`},Bn=(e,a,r)=>{const s=e.toLowerCase(),o=/p/.test(s)?"pm":/a/.test(s)?"am":null,i=s.replace(/[^\d]/g,"");if(!i)return null;let l=0,p=0,h=0;if(e.includes(":")){const t=e.split(":").map(c=>c.replace(/[^\d]/g,""));l=Number(t[0]||0),p=Number(t[1]||0),h=r?Number(t[2]||0):0}else i.length<=2?l=Number(i):i.length<=4?(l=Number(i.slice(0,i.length-2)),p=Number(i.slice(-2))):(l=Number(i.slice(0,i.length-4)),p=Number(i.slice(-4,-2)),h=r?Number(i.slice(-2)):0);return o&&(o==="pm"&&l<12&&(l+=12),o==="am"&&l===12&&(l=0)),l>23||p>59||h>59?null:{h:sn(l,0,23),m:sn(p,0,59),s:sn(h,0,59)}},Q=(e,a=1)=>{const r=[];for(let s=0;s<e;s+=a)r.push(s);return r},gn=(e,a)=>{if(typeof document>"u"||document.getElementById(e))return;const r=document.createElement("style");r.id=e,r.textContent=a,document.head.appendChild(r)};gn("sa-calendar-styles",Z),gn("sa-time-styles",Fn);const Pn=e=>e==="xs"?14:e==="lg"?20:16,bn=({s:e})=>n.jsx("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M10 5v5l3 2M17.5 10a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Z",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Vn=({s:e})=>n.jsx("svg",{width:e,height:e,viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5l10 10M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round"})}),X=({label:e,options:a,active:r,onPick:s})=>{const o=b.useRef(null),i=b.useRef(null);return b.useEffect(()=>{var l;(l=i.current)==null||l.scrollIntoView({block:"nearest"})},[r]),n.jsxs("div",{className:"sa-time-col",children:[n.jsx("div",{className:"sa-time-col-head",children:e}),n.jsx("div",{className:"sa-time-col-list",ref:o,children:a.map(l=>{const p=l.value===r;return n.jsx("button",{type:"button",ref:p?i:null,disabled:l.disabled,className:`sa-time-opt${p?" sa-time-opt-active":""}`,onClick:()=>s(l.value),children:l.label},l.value)})})]})},vn=b.forwardRef(({value:e,onChange:a,format:r="24h",withSeconds:s=!1,step:o=1,minTime:i,maxTime:l,input:p=!0,placeholder:h="--:--",disabled:t,clearable:c,size:w="sm",variant:C="outline",status:D,fullWidth:L=!0,withPadding:y=!0,label:v,labelPosition:d,required:$,optional:F,description:g,helperText:M,errorText:f},x)=>{const B=f?"error":D,{ref:P,isComponentVisible:Y,setIsComponentVisible:S}=nn(!1),T=b.useRef(null),m=b.useMemo(()=>tn(e),[e]),z=b.useMemo(()=>tn(i),[i]),k=b.useMemo(()=>tn(l),[l]),[I,H]=b.useState(null);b.useEffect(()=>{p||S(!0)},[p]);const V=()=>{if(!T.current||!P.current||!p)return;const u=P.current.getBoundingClientRect(),E=T.current.getBoundingClientRect();T.current.style.left=window.innerWidth<u.left+E.width?`${u.left-E.width+u.width}px`:`${u.left}px`,T.current.style.top=u.top+E.height>window.innerHeight?`${u.y-(u.height+E.height-28)}px`:`${u.y+u.height}px`};b.useEffect(()=>{V()},[Y]),b.useEffect(()=>(window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),()=>{window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V)}),[]);const K=u=>{const E=W(u);return!(z&&E<W(z)||k&&E>W(k))},N=u=>{a(In(u,s)),H(null)},j=u=>{N({...m??{h:0,m:0,s:0},...u})},mn=()=>{if(I==null)return;if(I.trim()===""){a(null),H(null);return}const u=Bn(I,r,s);u&&K(u)?N(u):H(null)},jn=m?Tn(m,r,s):"",An=I??jn,Hn=c&&!!m&&!t,R=m&&m.h>=12?"PM":"AM",On=b.useMemo(()=>r==="12h"?Q(12).map(u=>{const E=u===0?12:u,_=R==="PM"?E%12+12:E%12;return{value:E,label:A(E),disabled:z&&_*60+59<W(z)||k&&_*60>W(k)||!1}}):Q(24).map(u=>({value:u,label:A(u),disabled:z&&u*60+59<W(z)||k&&u*60>W(k)||!1})),[r,R,z,k]),Wn=b.useMemo(()=>{const u=(m==null?void 0:m.h)??0;return Q(60,o).map(E=>({value:E,label:A(E),disabled:z&&u*60+E<W(z)||k&&u*60+E>W(k)||!1}))},[o,m==null?void 0:m.h,z,k]),Jn=b.useMemo(()=>Q(60).map(u=>({value:u,label:A(u)})),[]),qn=m==null?null:r==="12h"?m.h%12===0?12:m.h%12:m.h,Gn=u=>{if(r==="12h"){const E=R==="PM"?u%12+12:u%12;j({h:E})}else j({h:u})},Un=u=>{const E=m??{h:0,m:0,s:0},_=E.h%12===0?12:E.h%12,_n=u==="PM"?_%12+12:_%12;N({...E,h:_n})},Zn=()=>{const u=new Date,E=Math.floor(u.getMinutes()/o)*o;N({h:u.getHours(),m:E,s:s?u.getSeconds():0})},on=Pn(w),Kn=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:p?"auto":"100%"},ref:p?P:null,children:[p?n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${C} sa-calendar-input-container-${B||"default"} ${w}`,onClick:()=>!t&&S(!0),children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx(bn,{s:on})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",value:An,placeholder:h,disabled:t,onChange:u=>H(u.target.value),onFocus:()=>S(!0),onBlur:mn,onKeyDown:u=>{u.key==="Enter"&&(mn(),S(!1)),u.key==="Escape"&&(H(null),S(!1))}})}),Hn?n.jsx("button",{type:"button","aria-label":"Clear time",className:"sa-calendar-input-clear",onClick:u=>{u.stopPropagation(),a(null),H(null)},children:n.jsx(Vn,{s:on})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx(bn,{s:on})})]}):null,Y?n.jsxs("div",{ref:T,className:`sa-calendar sa-calendar-size-${w} ${p?"":"sa-calendar-no-input"} ${y?"":"sa-calendar-no-padding"}`,style:t?{pointerEvents:"none"}:void 0,children:[n.jsxs("div",{className:"sa-time-columns",children:[n.jsx(X,{label:"Jam",options:On,active:qn,onPick:Gn}),n.jsx("div",{className:"sa-time-divider"}),n.jsx(X,{label:"Menit",options:Wn,active:(m==null?void 0:m.m)??null,onPick:u=>j({m:u})}),s&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sa-time-divider"}),n.jsx(X,{label:"Detik",options:Jn,active:(m==null?void 0:m.s)??null,onPick:u=>j({s:u})})]}),r==="12h"&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sa-time-divider"}),n.jsx(X,{label:"",options:[{value:0,label:"AM"},{value:1,label:"PM"}],active:m==null?null:R==="PM"?1:0,onPick:u=>Un(u===1?"PM":"AM")})]})]}),n.jsxs("div",{className:"sa-time-footer",children:[n.jsx("button",{type:"button",className:"sa-time-footer-btn",onClick:Zn,children:"Sekarang"}),n.jsx("button",{type:"button",className:"sa-time-footer-btn sa-time-footer-btn-muted",onClick:()=>{a(null),H(null)},children:"Hapus"})]})]}):null]});return n.jsx(an,{label:v,labelPosition:d,required:$,optional:F,description:g,helperText:M,errorText:f,fullWidth:L,size:w,children:Kn})});vn.displayName="StarasiaTime",O.StarasiaDate=Ln,O.StarasiaTime=vn,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { StarasiaDate } from "./Date";
2
+ export { StarasiaTime } from "./components/Time";
2
3
  export * from "./interfaces";
@@ -28,6 +28,49 @@ export interface IDateRange {
28
28
  from: Date | null;
29
29
  to: Date | null;
30
30
  }
31
+ export type TimeFormat = "24h" | "12h";
32
+ /**
33
+ * Props for `StarasiaTime` — masked input + popover columns (Hour / Minute /
34
+ * [Second] / [AM·PM]). Mirrors `IDateProps` conventions (size, variant,
35
+ * status, field-wrapper) so it sits 1:1 next to `StarasiaDate`.
36
+ */
37
+ export interface ITimeProps {
38
+ /**
39
+ * Canonical 24h string: `"HH:mm"`, or `"HH:mm:ss"` when `withSeconds`.
40
+ * The emitted value is ALWAYS canonical 24h regardless of `format`.
41
+ */
42
+ value?: string;
43
+ /** Fires with the canonical string, or `null` when cleared. */
44
+ onChange: (value: string | null) => void;
45
+ /** Display only — value stays canonical 24h. Default `"24h"`. */
46
+ format?: TimeFormat;
47
+ /** Include a seconds column + `:ss` in the value. Default `false`. */
48
+ withSeconds?: boolean;
49
+ /** Minute column step: `1 | 5 | 15 | 30`. Default `1`. */
50
+ step?: number;
51
+ /** Earliest selectable time, `"HH:mm"` (inclusive). */
52
+ minTime?: string;
53
+ /** Latest selectable time, `"HH:mm"` (inclusive). */
54
+ maxTime?: string;
55
+ /** Show the masked text trigger. When `false`, columns render inline. Default `true`. */
56
+ input?: boolean;
57
+ /** Default `"--:--"`. */
58
+ placeholder?: string;
59
+ disabled?: boolean;
60
+ clearable?: boolean;
61
+ size?: "xs" | "sm" | "md" | "lg";
62
+ variant?: "outline" | "filled" | "flushed";
63
+ status?: "error" | "warning";
64
+ fullWidth?: boolean;
65
+ withPadding?: boolean;
66
+ label?: React.ReactNode;
67
+ labelPosition?: DateLabelPosition;
68
+ required?: boolean;
69
+ optional?: boolean;
70
+ description?: string;
71
+ helperText?: string;
72
+ errorText?: string;
73
+ }
31
74
  export interface IInputDateProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
32
75
  size?: "xs" | "sm" | "md" | "lg";
33
76
  status?: "error" | "warning" | "disable" | "default";
@@ -0,0 +1,25 @@
1
+ import { TimeFormat } from "../interfaces";
2
+ export interface TimeParts {
3
+ h: number;
4
+ m: number;
5
+ s: number;
6
+ }
7
+ declare const pad2: (n: number) => string;
8
+ /** Parse a canonical "HH:mm" / "HH:mm:ss" string. Returns null when invalid. */
9
+ export declare const parseCanonical: (value?: string) => TimeParts | null;
10
+ /** Serialize parts to the canonical 24h value sent to consumers. */
11
+ export declare const toCanonical: (parts: TimeParts, withSeconds?: boolean) => string;
12
+ /** Minutes since midnight — handy for min/max comparisons. */
13
+ export declare const toMinutes: (p: TimeParts) => number;
14
+ /** Human display string honouring 12h/24h + seconds. */
15
+ export declare const formatDisplay: (parts: TimeParts, format: TimeFormat, withSeconds?: boolean) => string;
16
+ /**
17
+ * Lenient parser for free typing. Accepts "1430", "14:30", "2:5", "0230pm",
18
+ * "2:30 PM". In 24h mode a typed hour > 12 is taken literally; in 12h mode an
19
+ * am/pm token (a / p / am / pm) converts, otherwise the hour is read as-is
20
+ * (so "14" still resolves to 2 PM). Returns null when nothing usable.
21
+ */
22
+ export declare const parseLoose: (raw: string, format: TimeFormat, withSeconds?: boolean) => TimeParts | null;
23
+ /** Build the option list for a column. */
24
+ export declare const range: (count: number, step?: number) => number[];
25
+ export { pad2 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/date",
3
- "version": "5.3.2",
3
+ "version": "5.4.1",
4
4
  "description": "date component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/date.umd.js",