aha-components 1.5.1 → 1.5.3
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/DatePicker.esm.js +1 -1
- package/dist/DatePicker.esm.js.map +1 -1
- package/dist/DatePicker.js +1 -1
- package/dist/DatePicker.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.stories.d.ts +5 -0
- package/dist/components/DatePicker/index.d.ts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/DatePicker.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("react-dom"),r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},r.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var a={primaryColor:"#FB6011"},o=t.createContext(a),i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],l=["January","February","March","April","May","June","July","August","September","October","November","December"],s=function(e,t){if(void 0===t&&(t="YYYY-MM-DD"),!e)return"";var n=e.getFullYear(),r=e.getMonth(),a=String(r+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getDate());return t.replace(/YYYY/g,"").replace(/YY/g,"").replace(/MMMM/g,"").replace(/MMM/g,"").replace(/MM/g,"").replace(/DD/g,"").replace(/D/g,"").replace(/M/g,"").replace(new RegExp("","g"),String(n)).replace(new RegExp("","g"),String(n).slice(-2)).replace(new RegExp("","g"),l[r]).replace(new RegExp("","g"),i[r]).replace(new RegExp("","g"),a).replace(new RegExp("","g"),String(r+1)).replace(new RegExp("","g"),o).replace(new RegExp("","g"),s)},d=function(e,t){return new Date(e,t+1,0).getDate()},u=function(e,t){return!(!e||!t)&&(e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())},p=function(e,t,n){return!(t&&e<t)&&!(n&&e>n)},c=function(e,t,n){if(!t||!n)return!1;var r=e.getTime(),a=t.getTime(),o=n.getTime();return r>=a&&r<=o},g=function(i){var g=i.mode,f=void 0===g?"date":g,h=i.disabled,x=void 0!==h&&h,y=i.error,D=void 0!==y&&y,m=i.placeholder,v=void 0===m?"Select date":m,b=i.startPlaceholder,F=void 0===b?"Start date":b,C=i.endPlaceholder,w=void 0===C?"End date":C,k=i.size,M=void 0===k?"medium":k,j=i.allowClear,S=void 0!==j&&j,R=i.format,E=void 0===R?"range"===f?"MMM D, YYYY":"YYYY-MM-DD":R,L=i.onFocus,T=i.onBlur,Y=i.onOpenChange,A=i.className,B=void 0===A?"":A,W=i.style,z=i.dropdownClassName,H=void 0===z?"":z,V=i.dropdownStyle,I=i.defaultOpen,O=void 0!==I&&I,P=i.open,N=i.minDate,J=i.maxDate,q=i.separator,X=void 0===q?" - ":q,Z=i.presetRanges,G=void 0!==Z&&Z,_=i.calendarCount,K=void 0===_?1:_,Q=i.showApplyCancel,U=void 0!==Q&&Q,$=i.applyText,ee=void 0===$?"Apply":$,te=i.cancelText,ne=void 0===te?"Cancel":te,re=i.onApply,ae=i.onCancel,oe=(t.useContext(o)||a).primaryColor,ie=void 0===oe?"#FB6011":oe,le="range"===f,se=t.useState(function(){return"date"===f&&"defaultValue"in i&&i.defaultValue||null}),de=se[0],ue=se[1],pe=t.useState(function(){return"range"===f&&"defaultValue"in i&&i.defaultValue||{startDate:null,endDate:null}}),ce=pe[0],ge=pe[1],fe=t.useState(O),he=fe[0],xe=fe[1],ye=t.useState(!0),De=ye[0],me=ye[1],ve=t.useState(null),be=ve[0],Fe=ve[1],Ce=t.useState(function(){var e,t;if("date"===f&&"value"in i&&i.value&&(t=i.value))return{year:t.getFullYear(),month:t.getMonth()};if("range"===f&&"value"in i&&i.value&&(t=(e=i.value).startDate||e.endDate))return{year:t.getFullYear(),month:t.getMonth()};if("date"===f&&"defaultValue"in i&&i.defaultValue&&(t=i.defaultValue))return{year:t.getFullYear(),month:t.getMonth()};if("range"===f&&"defaultValue"in i&&i.defaultValue&&(t=(e=i.defaultValue).startDate||e.endDate))return{year:t.getFullYear(),month:t.getMonth()};var n=new Date;return{year:n.getFullYear(),month:n.getMonth()}}),we=Ce[0],ke=Ce[1],Me=t.useState(function(){if(2===K&&le){var e=new Date(we.year,we.month+1,1);return{year:e.getFullYear(),month:e.getMonth()}}return null}),je=Me[0],Se=Me[1];t.useEffect(function(){if(2===K&&le){var e=new Date(we.year,we.month+1,1);Se({year:e.getFullYear(),month:e.getMonth()})}else Se(null)},[we,K,le]);var Re=t.useRef(null),Ee=t.useRef(null),Le=t.useRef(null),Te=t.useRef(null),Ye=t.useRef(null),Ae=t.useState(null),Be=Ae[0],We=Ae[1],ze=t.useRef(!1),He="value"in i&&void 0!==i.value,Ve=void 0!==P,Ie=le?null:He&&"date"===f&&"value"in i?i.value:de,Oe=le?He&&"range"===f&&"value"in i?i.value||{startDate:null,endDate:null}:ce:{startDate:null,endDate:null},Pe=Ve?P:he;t.useEffect(function(){if(Pe&&!ze.current){if(le){var e=Oe.startDate||Oe.endDate;if(e){var t=e.getFullYear(),n=e.getMonth();we.year===t&&we.month===n||ke({year:t,month:n})}}else if(Ie){t=Ie.getFullYear(),n=Ie.getMonth();we.year===t&&we.month===n||ke({year:t,month:n})}ze.current=!0}else Pe||(ze.current=!1)},[Pe,Ie,Oe,le,we]),t.useEffect(function(){if(Pe&&Re.current){var e=function(){if(Re.current){var e=Re.current.getBoundingClientRect();We({top:e.bottom+window.scrollY+4,left:e.left+window.scrollX,width:e.width})}};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),function(){window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}}We(null)},[Pe]),t.useEffect(function(){var e=function(e){var t=e.target;Re.current&&!Re.current.contains(t)&&Ye.current&&!Ye.current.contains(t)&&(Ve||xe(!1),null==Y||Y(!1))};if(Pe)return document.addEventListener("mousedown",e,!0),document.addEventListener("touchstart",e,!0),function(){document.removeEventListener("mousedown",e,!0),document.removeEventListener("touchstart",e,!0)}},[Pe,Ve,Y]);var Ne,Je=t.useCallback(function(e){var t;p(e,N,J)&&(He||ue(e),"date"===f&&"onChange"in i&&(null===(t=i.onChange)||void 0===t||t.call(i,e)),Ve||xe(!1),null==Y||Y(!1))},[He,Ve,f,i,Y,N,J]),qe=t.useCallback(function(e){var t;if(p(e,N,J)){var n,r=U&&be?be:Oe;De?r.endDate&&e>r.endDate?(n={startDate:r.endDate,endDate:e},me(!1)):(n={startDate:e,endDate:r.endDate},r.endDate?(me(!0),U||(Ve||xe(!1),null==Y||Y(!1))):me(!1)):r.startDate&&e<r.startDate?(n={startDate:e,endDate:r.startDate},me(!1)):(n={startDate:r.startDate,endDate:e},me(!0),U||(Ve||xe(!1),null==Y||Y(!1))),U?Fe(n):(He||ge(n),"range"===f&&"onChange"in i&&(null===(t=i.onChange)||void 0===t||t.call(i,n)))}},[De,Oe,be,U,He,Ve,f,i,Y,N,J]),Xe=function(e){var t,n;if(e.stopPropagation(),le){var r={startDate:null,endDate:null};He||ge(r),"range"===f&&"onChange"in i&&(null===(t=i.onChange)||void 0===t||t.call(i,r)),me(!0)}else He||ue(null),"date"===f&&"onChange"in i&&(null===(n=i.onChange)||void 0===n||n.call(i,null))},Ze=function(){if(!x){var e=!Pe;Ve||xe(e),null==Y||Y(e),e&&le?(me(!Oe.startDate),U&&Fe(Oe)):!e&&U&&Fe(null)}},Ge=t.useMemo(function(){var e=new Date;e.setHours(0,0,0,0);var t=new Date(e),n=new Date(e);n.setDate(e.getDate()-6);var r=new Date(e),a=new Date(e),o=e.getDate();a.setMonth(e.getMonth()-1),a.getDate()!==o&&a.setDate(0);var i=new Date(e),l=new Date(e);return l.setFullYear(e.getFullYear()-1),[{label:"Last week",range:{startDate:n,endDate:t}},{label:"Last month",range:{startDate:a,endDate:r}},{label:"Last year",range:{startDate:l,endDate:i}}]},[]),_e=function(e){var t;U?Fe(e):(He||ge(e),"range"===f&&"onChange"in i&&(null===(t=i.onChange)||void 0===t||t.call(i,e)),Ve||xe(!1),null==Y||Y(!1))},Ke=function(){ke(function(e){return 0===e.month?{year:e.year-1,month:11}:{year:e.year,month:e.month-1}})},Qe=function(){ke(function(e){return 11===e.month?{year:e.year+1,month:0}:{year:e.year,month:e.month+1}})},Ue=t.useCallback(function(e,t){for(var n=d(e,t),r=[],a=1;a<=n;a++)r.push(new Date(e,t,a));return r},[]),$e=t.useMemo(function(){return Ue(we.year,we.month)},[we,Ue]),et=t.useMemo(function(){return 2===K&&le&&je?Ue(je.year,je.month):null},[K,le,je,Ue]),tt=function(){je&&Se(function(e){return e?0===e.month?{year:e.year-1,month:11}:{year:e.year,month:e.month-1}:null})},nt=function(){je&&Se(function(e){return e?11===e.month?{year:e.year+1,month:0}:{year:e.year,month:e.month+1}:null})},rt={small:{height:"32px",paddingTop:"3px",paddingBottom:"3px",fontSize:"16px",lineHeight:"24px"},mediumSmall:{height:"36px",paddingTop:"5px",paddingBottom:"5px",fontSize:"16px",lineHeight:"24px"},medium:{height:"40px",paddingTop:"7px",paddingBottom:"7px",fontSize:"16px",lineHeight:"24px"},large:{height:"48px",paddingTop:"11px",paddingBottom:"11px",fontSize:"16px",lineHeight:"24px"}},at=S&&!x&&(le?Oe.startDate||Oe.endDate:Ie),ot=Ie?s(Ie,E):"",it=Oe.startDate?s(Oe.startDate,E):"",lt=Oe.endDate?s(Oe.endDate,E):"",st=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:"\n @keyframes dropdownFadeIn {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n "}),e.jsxs("div",{ref:Re,className:"aha-date-picker ".concat(B),style:r({position:"relative",display:"inline-flex",alignItems:"center",boxSizing:"border-box",fontFamily:"DM Sans, sans-serif",borderRadius:"8px",border:"1px solid ".concat(D?"#F04438":Pe?ie:"#D7D3D0"),backgroundColor:x?"#FAFAF9":"#FFFFFF",cursor:x?"not-allowed":"pointer",transition:"all 0.2s",paddingLeft:"40px",paddingRight:"36px",paddingTop:rt[M].paddingTop,paddingBottom:rt[M].paddingBottom,fontSize:rt[M].fontSize,lineHeight:rt[M].lineHeight,fontWeight:400,WebkitTapHighlightColor:"transparent",WebkitTouchCallout:"none",touchAction:"manipulation",userSelect:"none"},W),onClick:Ze,onFocus:function(e){null==L||L(e)},onBlur:function(e){null==T||T(e)},tabIndex:x?-1:0,children:[e.jsx("span",{style:{position:"absolute",left:"12px",display:"flex",alignItems:"center",color:x?"#98A2B3":"#78716C",zIndex:1,pointerEvents:"none"},children:e.jsx(function(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.6667 2.66667H12V2C12 1.63181 11.7015 1.33333 11.3333 1.33333C10.9651 1.33333 10.6667 1.63181 10.6667 2V2.66667H5.33333V2C5.33333 1.63181 5.03486 1.33333 4.66667 1.33333C4.29848 1.33333 4 1.63181 4 2V2.66667H3.33333C2.59695 2.66667 2 3.26362 2 4V13.3333C2 14.0697 2.59695 14.6667 3.33333 14.6667H12.6667C13.403 14.6667 14 14.0697 14 13.3333V4C14 3.26362 13.403 2.66667 12.6667 2.66667ZM12.6667 13.3333H3.33333V7.33333H12.6667V13.3333ZM12.6667 6H3.33333V4H12.6667V6Z",fill:"currentColor"})})},{})}),le?e.jsxs("div",{style:{display:"flex",alignItems:"center",flex:1,gap:"8px",minWidth:0},children:[e.jsx("input",{ref:Le,type:"text",value:it,readOnly:!0,placeholder:F,disabled:x,onClick:function(e){e.stopPropagation(),x||(me(!0),Pe||Ze())},style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"16px",lineHeight:"24px",fontWeight:400,color:x?"#98A2B3":Oe.startDate?"#1C1917":"#79716B",fontFamily:"DM Sans, sans-serif",minWidth:0,cursor:x?"not-allowed":"pointer",WebkitAppearance:"none",appearance:"none"}}),e.jsx("span",{style:{color:x?"#98A2B3":"#78716C",fontSize:"16px",flexShrink:0},children:X}),e.jsx("input",{ref:Te,type:"text",value:lt,readOnly:!0,placeholder:w,disabled:x,onClick:function(e){e.stopPropagation(),x||(me(!1),Pe||Ze())},style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"16px",lineHeight:"24px",fontWeight:400,color:x?"#98A2B3":Oe.endDate?"#1C1917":"#79716B",fontFamily:"DM Sans, sans-serif",minWidth:0,cursor:x?"not-allowed":"pointer",WebkitAppearance:"none",appearance:"none"}})]}):e.jsx("input",{ref:Ee,type:"text",value:ot,readOnly:!0,placeholder:v,disabled:x,onClick:function(e){e.stopPropagation(),x||Ze()},style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"16px",lineHeight:"24px",fontWeight:400,color:x?"#98A2B3":Ie?"#1C1917":"#79716B",fontFamily:"DM Sans, sans-serif",minWidth:0,cursor:x?"not-allowed":"pointer",WebkitAppearance:"none",appearance:"none"}}),e.jsxs("div",{style:{position:"absolute",right:"12px",display:"flex",alignItems:"center",gap:"4px"},children:[at&&e.jsx(function(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",onClick:Xe,style:{cursor:"pointer",flexShrink:0,color:"#78716C"},children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})},{}),e.jsx(function(t){var n=t.isOpen;return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:n?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease-in-out",flexShrink:0},children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"#78716C",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})},{isOpen:Pe})]})]}),Pe&&Be&&n.createPortal(e.jsx("div",{ref:Ye,className:"aha-date-picker-dropdown ".concat(H),style:r({position:"absolute",top:"".concat(Be.top,"px"),left:"".concat(Be.left,"px"),zIndex:1050,backgroundColor:"#FFFFFF",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",border:"1px solid #E7E5E4",padding:"0",opacity:0,transform:"translateY(-8px)",animation:"dropdownFadeIn 0.2s ease-out forwards",display:"flex",flexDirection:"column"},V),children:e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,flexDirection:le&&G&&1===K?"column":"row"},children:[le&&G&&2===K&&e.jsx("div",{style:{width:"140px",borderRight:"1px solid #E7E5E4",padding:"12px 0",backgroundColor:"#FFFFFF",borderTopLeftRadius:"8px",borderBottomLeftRadius:U?"0":"8px"},children:Ge.map(function(t,n){var r=be?u(t.range.startDate,be.startDate)&&u(t.range.endDate,be.endDate):u(t.range.startDate,Oe.startDate)&&u(t.range.endDate,Oe.endDate);return e.jsx("div",{onClick:function(){return _e(t.range)},style:{padding:"8px 16px",cursor:"pointer",fontSize:"14px",fontFamily:"DM Sans, sans-serif",color:r?ie:"#1C1917",backgroundColor:r?"#FAFAF9":"transparent",fontWeight:r?500:400,transition:"all 0.2s"},onMouseEnter:function(e){r||(e.currentTarget.style.backgroundColor="#F5F5F4")},onMouseLeave:function(e){r||(e.currentTarget.style.backgroundColor="transparent")},children:t.label},n)})}),e.jsxs("div",{children:[e.jsx("div",{style:{flex:1,padding:"16px",display:"flex",flexDirection:2===K?"row":"column",gap:2===K?"24px":"0"},children:(Ne=function(t,n,r,a,o){return void 0===o&&(o=0),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:2===K&&le?"center":"space-between",marginBottom:"16px",position:"relative"},children:[!(2===K&&le&&1===o)&&e.jsx("button",{type:"button",onClick:r,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",cursor:"pointer",borderRadius:"4px",color:"#78716C",transition:"all 0.2s",position:2===K&&le?"absolute":"relative",left:2===K&&le?0:void 0},onMouseEnter:function(e){e.currentTarget.style.backgroundColor="#FAFAF9"},onMouseLeave:function(e){e.currentTarget.style.backgroundColor="transparent"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M10 12L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("div",{style:{fontSize:"16px",fontWeight:500,color:"#1C1917",fontFamily:"DM Sans, sans-serif"},children:[l[t.month]," ",t.year]}),!(2===K&&le&&0===o)&&e.jsx("button",{type:"button",onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",cursor:"pointer",borderRadius:"4px",color:"#78716C",transition:"all 0.2s",position:2===K&&le?"absolute":"relative",right:2===K&&le?0:void 0},onMouseEnter:function(e){e.currentTarget.style.backgroundColor="#FAFAF9"},onMouseLeave:function(e){e.currentTarget.style.backgroundColor="transparent"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),le&&G&&1===K&&e.jsx("div",{style:{width:"252px",display:"flex",flexWrap:"wrap",paddingBottom:"16px"},children:Ge.map(function(t,n){var r=be?u(t.range.startDate,be.startDate)&&u(t.range.endDate,be.endDate):u(t.range.startDate,Oe.startDate)&&u(t.range.endDate,Oe.endDate);return e.jsx("button",{type:"button",onClick:function(){return _e(t.range)},style:{padding:"4px 9px",cursor:"pointer",fontSize:"14px",fontFamily:"DM Sans, sans-serif",color:r?ie:"#1C1917",backgroundColor:r?"#FAFAF9":"transparent",border:"none",fontWeight:r?500:400,transition:"all 0.2s",borderRadius:"4px"},children:t.label},n)})}),e.jsx("div",{style:{width:"252px",display:"grid",gridTemplateColumns:"repeat(7, 1fr)",marginBottom:"8px"},children:st.map(function(t){return e.jsx("div",{style:{width:"36px",textAlign:"center",fontSize:"12px",fontWeight:500,color:"#78716C",fontFamily:"DM Sans, sans-serif",padding:"4px"},children:t},t)})}),e.jsx("div",{style:{width:"252px",display:"grid",gridTemplateColumns:"repeat(7, 1fr)",rowGap:"4px",columnGap:"0px"},children:function(){for(var r,a,o=(r=t.year,a=t.month,new Date(r,a,1).getDay()),i=(0===o?7:o)-1,l=[],s=0;s<i;s++)l.push(e.jsx("div",{},"empty-".concat(s)));return n.forEach(function(r,a){if(r){var o=i+a,s=r.getMonth()===t.month,g=u(r,new Date),f=!p(r,N,J);if(le){var h=U&&be?be:Oe,x=u(r,h.startDate),y=u(r,h.endDate),D=c(r,h.startDate,h.endDate),m=o%7==0,v=o%7==6,b=x,F=y,C=a>0?n[a-1]:null,w=a<n.length-1?n[a+1]:null;C&&c(C,h.startDate,h.endDate),w&&c(w,h.startDate,h.endDate);var k=a-7,M=a+7,j=k>=0?n[k]:null,S=M<n.length?n[M]:null;j&&c(j,h.startDate,h.endDate),S&&c(S,h.startDate,h.endDate);var R={display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px",border:"none",cursor:f?"not-allowed":"pointer",fontSize:"14px",fontFamily:"DM Sans, sans-serif",transition:"all 0.2s",opacity:f?.4:1,position:"relative",padding:0,margin:0};if(b||F)R.background=ie,R.borderRadius="50%",R.color="#FFFFFF",R.fontWeight=500;else if(D){R.background="#F5F5F4",R.color=s?f?"#D7D3D0":"#1C1917":"#78716C",R.fontWeight=400;var E=1===r.getDate(),L=d(t.year,t.month),T=r.getDate()===L,Y=m||E,A=v||T;Y&&A?R.borderRadius="18px":Y?(R.borderTopLeftRadius="18px",R.borderBottomLeftRadius="18px",R.borderTopRightRadius="0",R.borderBottomRightRadius="0"):A?(R.borderTopRightRadius="18px",R.borderBottomRightRadius="18px",R.borderTopLeftRadius="0",R.borderBottomLeftRadius="0"):R.borderRadius="0"}else R.background="transparent",R.borderRadius="50%",R.color=s?f?"#D7D3D0":"#1C1917":"#78716C",R.fontWeight=400;l.push(e.jsxs("button",{type:"button",disabled:f,onClick:function(){return qe(r)},style:R,onMouseEnter:function(e){f||b||F||(e.currentTarget.style.backgroundColor=D?"#E7E5E4":"#FAFAF9")},onMouseLeave:function(e){b||F||(e.currentTarget.style.backgroundColor=D?"#F5F5F4":"transparent")},children:[r.getDate(),g&&!b&&!F&&!D&&e.jsx("div",{style:{position:"absolute",bottom:"2px",left:"50%",transform:"translateX(-50%)",width:"4px",height:"4px",borderRadius:"50%",backgroundColor:ie}})]},"date-".concat(a)))}else{var B=u(r,Ie);l.push(e.jsxs("button",{type:"button",disabled:f,onClick:function(){return Je(r)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px",border:"none",background:B?ie:"transparent",cursor:f?"not-allowed":"pointer",borderRadius:"4px",fontSize:"14px",fontWeight:B?500:400,color:B?"#FFFFFF":s?f?"#D7D3D0":"#1C1917":"#78716C",fontFamily:"DM Sans, sans-serif",transition:"all 0.2s",opacity:f?.4:1,position:"relative",padding:0,margin:0},onMouseEnter:function(e){f||B||(e.currentTarget.style.backgroundColor="#FAFAF9")},onMouseLeave:function(e){B||(e.currentTarget.style.backgroundColor="transparent")},children:[r.getDate(),g&&!B&&e.jsx("div",{style:{position:"absolute",bottom:"2px",left:"50%",transform:"translateX(-50%)",width:"4px",height:"4px",borderRadius:"50%",backgroundColor:ie}})]},"date-".concat(a)))}}}),l}()})]},o)},e.jsxs(e.Fragment,{children:[Ne(we,$e,Ke,Qe,0),2===K&&le&&je&&et&&Ne(je,et,tt,nt,1)]}))}),le&&U&&e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",padding:"12px 16px",borderTop:"1px solid #E7E5E4",borderBottomLeftRadius:"8px",borderBottomRightRadius:"8px"},children:[e.jsx("button",{type:"button",onClick:function(){Fe(null),null==ae||ae(),Ve||xe(!1),null==Y||Y(!1)},style:{padding:"8px 16px",border:"1px solid #E7E5E4",borderRadius:"8px",background:"#FFFFFF",color:"#1C1917",fontSize:"14px",fontWeight:500,fontFamily:"DM Sans, sans-serif",cursor:"pointer",transition:"all 0.2s"},onMouseEnter:function(e){e.currentTarget.style.backgroundColor="#FAFAF9"},onMouseLeave:function(e){e.currentTarget.style.backgroundColor="#FFFFFF"},children:ne}),e.jsx("button",{type:"button",onClick:function(){var e;be&&(He||ge(be),"range"===f&&"onChange"in i&&(null===(e=i.onChange)||void 0===e||e.call(i,be)),null==re||re(be),Ve||xe(!1),null==Y||Y(!1),Fe(null))},disabled:!be||!be.startDate||!be.endDate,style:{padding:"8px 16px",border:"none",borderRadius:"8px",background:be&&be.startDate&&be.endDate?ie:"#D7D3D0",color:"#FFFFFF",fontSize:"14px",fontWeight:500,fontFamily:"DM Sans, sans-serif",cursor:be&&be.startDate&&be.endDate?"pointer":"not-allowed",transition:"all 0.2s"},onMouseEnter:function(e){be&&be.startDate&&be.endDate&&(e.currentTarget.style.backgroundColor="#FD843A")},onMouseLeave:function(e){be&&be.startDate&&be.endDate&&(e.currentTarget.style.backgroundColor=ie)},children:ee})]})]})]})}),document.body)]})};g.displayName="DatePicker",exports.default=g;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("react-dom"),r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},r.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var a={primaryColor:"#FB6011"},o=t.createContext(a),i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],l=["January","February","March","April","May","June","July","August","September","October","November","December"],s=function(e,t){if(void 0===t&&(t="YYYY-MM-DD"),!e)return"";var n=e.getFullYear(),r=e.getMonth(),a=String(r+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getDate());return t.replace(/YYYY/g,"").replace(/YY/g,"").replace(/MMMM/g,"").replace(/MMM/g,"").replace(/MM/g,"").replace(/DD/g,"").replace(/D/g,"").replace(/M/g,"").replace(new RegExp("","g"),String(n)).replace(new RegExp("","g"),String(n).slice(-2)).replace(new RegExp("","g"),l[r]).replace(new RegExp("","g"),i[r]).replace(new RegExp("","g"),a).replace(new RegExp("","g"),String(r+1)).replace(new RegExp("","g"),o).replace(new RegExp("","g"),s)},d=function(e,t){return new Date(e,t+1,0).getDate()},u=function(e,t){return!(!e||!t)&&(e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate())},c=function(e,t,n){return!(t&&e<t)&&!(n&&e>n)},p=function(i){var p=i.mode,f=void 0===p?"date":p,g=i.disabled,x=void 0!==g&&g,h=i.error,D=void 0!==h&&h,m=i.placeholder,y=void 0===m?"Select date":m,v=i.startPlaceholder,b=void 0===v?"Start date":v,F=i.endPlaceholder,w=void 0===F?"End date":F,M=i.size,C=void 0===M?"medium":M,Y=i.allowClear,k=void 0!==Y&&Y,j=i.format,S=void 0===j?"range"===f?"MMM D, YYYY":"YYYY-MM-DD":j,R=i.onFocus,E=i.onBlur,B=i.onOpenChange,T=i.className,A=void 0===T?"":T,L=i.style,W=i.dropdownClassName,z=void 0===W?"":W,H=i.dropdownStyle,V=i.defaultOpen,N=void 0!==V&&V,I=i.open,O=i.minDate,P=i.maxDate,J=i.separator,q=void 0===J?" - ":J,X=i.presetRanges,Z=void 0!==X&&X,G=i.calendarCount,_=void 0===G?1:G,K=i.showApplyCancel,Q=void 0!==K&&K,U=i.applyText,$=void 0===U?"Apply":U,ee=i.cancelText,te=void 0===ee?"Cancel":ee,ne=i.onApply,re=i.onCancel,ae=i.showSelectedRange,oe=void 0!==ae&&ae,ie=i.startSelectedRangeText,le=void 0===ie?"Select dates":ie,se=i.endSelectedRangeText,de=void 0===se?"Select dates":se,ue=i.rangeDisplayMode,ce=void 0===ue?"range":ue,pe=(t.useContext(o)||a).primaryColor,fe=void 0===pe?"#FB6011":pe,ge="range"===f,xe=t.useState(function(){return"date"===f&&"defaultValue"in i&&i.defaultValue||null}),he=xe[0],De=xe[1],me=t.useState(function(){return"range"===f&&"defaultValue"in i&&i.defaultValue||{startDate:null,endDate:null}}),ye=me[0],ve=me[1],be=t.useState(N),Fe=be[0],we=be[1],Me=t.useState(!0),Ce=Me[0],Ye=Me[1],ke=t.useState(null),je=ke[0],Se=ke[1],Re=t.useState(function(){var e,t;if("date"===f&&"value"in i&&i.value&&(t=i.value))return{year:t.getFullYear(),month:t.getMonth()};if("range"===f&&"value"in i&&i.value&&(t=(e=i.value).startDate||e.endDate))return{year:t.getFullYear(),month:t.getMonth()};if("date"===f&&"defaultValue"in i&&i.defaultValue&&(t=i.defaultValue))return{year:t.getFullYear(),month:t.getMonth()};if("range"===f&&"defaultValue"in i&&i.defaultValue&&(t=(e=i.defaultValue).startDate||e.endDate))return{year:t.getFullYear(),month:t.getMonth()};var n=new Date;return{year:n.getFullYear(),month:n.getMonth()}}),Ee=Re[0],Be=Re[1],Te=t.useState(function(){if(2===_&&ge){var e=new Date(Ee.year,Ee.month+1,1);return{year:e.getFullYear(),month:e.getMonth()}}return null}),Ae=Te[0],Le=Te[1];t.useEffect(function(){if(2===_&&ge){var e=new Date(Ee.year,Ee.month+1,1);Le({year:e.getFullYear(),month:e.getMonth()})}else Le(null)},[Ee,_,ge]);var We=t.useRef(null),ze=t.useRef(null),He=t.useRef(null),Ve=t.useRef(null),Ne=t.useRef(null),Ie=t.useState(null),Oe=Ie[0],Pe=Ie[1],Je=t.useRef(!1),qe=t.useRef(!1),Xe=t.useRef(null),Ze="value"in i&&void 0!==i.value,Ge=void 0!==I,_e=ge?null:Ze&&"date"===f&&"value"in i?i.value:he,Ke=ge?Ze&&"range"===f&&"value"in i?i.value||{startDate:null,endDate:null}:ye:{startDate:null,endDate:null},Qe=Ge?I:Fe;t.useEffect(function(){if(Qe&&!Je.current){if(ge){var e=Ke.startDate||Ke.endDate;if(e){var t=e.getFullYear(),n=e.getMonth();Be({year:t,month:n})}else{var r=new Date;Be({year:r.getFullYear(),month:r.getMonth()})}}else if(_e){t=_e.getFullYear(),n=_e.getMonth();Be({year:t,month:n})}else{r=new Date;Be({year:r.getFullYear(),month:r.getMonth()})}Je.current=!0}else Qe||(Je.current=!1)},[Qe,_e,Ke,ge]),t.useEffect(function(){if(Qe&&We.current){qe.current=!1,Xe.current=null;var e=function(){if(We.current){var e=We.current.getBoundingClientRect();if(qe.current&&null!==Xe.current){var t,n=Xe.current;if(Ne.current){var r=Ne.current.offsetHeight;t="top"===n?e.top+window.scrollY-r-4:e.bottom+window.scrollY+4}else t="top"===n?e.top+window.scrollY-400-4:e.bottom+window.scrollY+4;return void Pe({top:t,left:e.left+window.scrollX,width:e.width,placement:n})}var a=e.bottom+window.scrollY+4,o="bottom";Pe({top:a,left:e.left+window.scrollX,width:e.width,placement:o}),requestAnimationFrame(function(){requestAnimationFrame(function(){!function(){if(Ne.current){var t=Ne.current.offsetHeight,n=window.innerHeight-e.bottom-4,r=e.top-4;(n<t&&r>=t||n<t&&r<t&&r>n)&&(a=e.top+window.scrollY-t-4,o="top"),qe.current=!0,Xe.current=o}Pe({top:a,left:e.left+window.scrollX,width:e.width,placement:o})}()})})}};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),function(){window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}}Pe(null),qe.current=!1,Xe.current=null},[Qe]),t.useEffect(function(){var e=function(e){var t=e.target;We.current&&!We.current.contains(t)&&Ne.current&&!Ne.current.contains(t)&&(Ge||we(!1),null==B||B(!1))};if(Qe)return document.addEventListener("mousedown",e,!0),document.addEventListener("touchstart",e,!0),function(){document.removeEventListener("mousedown",e,!0),document.removeEventListener("touchstart",e,!0)}},[Qe,Ge,B]);var Ue,$e,et,tt,nt=t.useCallback(function(e){var t;c(e,O,P)&&(Ze||De(e),"date"===f&&"onChange"in i&&(null===(t=i.onChange)||void 0===t||t.call(i,e)),Ge||we(!1),null==B||B(!1))},[Ze,Ge,f,i,B,O,P]),rt=t.useCallback(function(e){var t;if(c(e,O,P)){var n,r=Q&&je?je:Ke;r.startDate&&r.endDate?(n={startDate:e,endDate:null},Ye(!1)):Ce?r.endDate&&e>r.endDate?(n={startDate:r.endDate,endDate:e},Ye(!1)):(n={startDate:e,endDate:r.endDate},r.endDate?(Ye(!0),Q||(Ge||we(!1),null==B||B(!1))):Ye(!1)):r.startDate&&e<r.startDate?(n={startDate:e,endDate:r.startDate},Ye(!1)):(n={startDate:r.startDate,endDate:e},Ye(!0),Q||(Ge||we(!1),null==B||B(!1))),Q?Se(n):(Ze||ve(n),"range"===f&&"onChange"in i&&(null===(t=i.onChange)||void 0===t||t.call(i,n)))}},[Ce,Ke,je,Q,Ze,Ge,f,i,B,O,P]),at=function(e){var t,n;if(e.stopPropagation(),ge){var r={startDate:null,endDate:null};Ze||ve(r),"range"===f&&"onChange"in i&&(null===(t=i.onChange)||void 0===t||t.call(i,r)),Ye(!0)}else Ze||De(null),"date"===f&&"onChange"in i&&(null===(n=i.onChange)||void 0===n||n.call(i,null));if(!Qe){var a=new Date;Be({year:a.getFullYear(),month:a.getMonth()})}},ot=function(){if(!x){var e=!Qe;if(Ge||we(e),null==B||B(e),e){if(ge){if(Ye(!Ke.startDate),Q&&Se(Ke),!Ke.startDate&&!Ke.endDate){var t=new Date;Be({year:t.getFullYear(),month:t.getMonth()})}}else if(!_e){t=new Date;Be({year:t.getFullYear(),month:t.getMonth()})}}else!e&&Q&&Se(null)}},it=t.useMemo(function(){var e=new Date;e.setHours(0,0,0,0);var t=new Date(e),n=new Date(e);n.setDate(e.getDate()-6);var r=new Date(e),a=new Date(e),o=e.getDate();a.setMonth(e.getMonth()-1),a.getDate()!==o&&a.setDate(0);var i=new Date(e),l=new Date(e);return l.setFullYear(e.getFullYear()-1),[{label:"Last week",range:{startDate:n,endDate:t}},{label:"Last month",range:{startDate:a,endDate:r}},{label:"Last year",range:{startDate:l,endDate:i}}]},[]),lt=t.useMemo(function(){return Array.isArray(Z)?Z:!0===Z?it:[]},[Z,it]),st=lt.length>0,dt=function(e){var t;if(e.startDate){var n=e.startDate.getFullYear(),r=e.startDate.getMonth();Be({year:n,month:r})}Q?Se(e):(Ze||ve(e),"range"===f&&"onChange"in i&&(null===(t=i.onChange)||void 0===t||t.call(i,e)),Ge||we(!1),null==B||B(!1))},ut=function(){Be(function(e){return 0===e.month?{year:e.year-1,month:11}:{year:e.year,month:e.month-1}})},ct=function(){Be(function(e){return 11===e.month?{year:e.year+1,month:0}:{year:e.year,month:e.month+1}})},pt=t.useCallback(function(e,t){for(var n=d(e,t),r=[],a=1;a<=n;a++)r.push(new Date(e,t,a));return r},[]),ft=t.useMemo(function(){return pt(Ee.year,Ee.month)},[Ee,pt]),gt=t.useMemo(function(){return 2===_&&ge&&Ae?pt(Ae.year,Ae.month):null},[_,ge,Ae,pt]),xt=function(){Ae&&Le(function(e){return e?0===e.month?{year:e.year-1,month:11}:{year:e.year,month:e.month-1}:null})},ht=function(){Ae&&Le(function(e){return e?11===e.month?{year:e.year+1,month:0}:{year:e.year,month:e.month+1}:null})},Dt={small:{height:"32px",paddingTop:"3px",paddingBottom:"3px",fontSize:"16px",lineHeight:"24px"},mediumSmall:{height:"36px",paddingTop:"5px",paddingBottom:"5px",fontSize:"16px",lineHeight:"24px"},medium:{height:"40px",paddingTop:"7px",paddingBottom:"7px",fontSize:"16px",lineHeight:"24px"},large:{height:"48px",paddingTop:"11px",paddingBottom:"11px",fontSize:"16px",lineHeight:"24px"}},mt=k&&!x&&(ge?Ke.startDate||Ke.endDate:_e),yt=_e?s(_e,S):"",vt=Ke.startDate?s(Ke.startDate,S):"",bt=Ke.endDate?s(Ke.endDate,S):"",Ft=t.useMemo(function(){if(!ge||"text"!==ce)return"";if(Ke.startDate&&Ke.endDate){var e=s(Ke.startDate,"MMM D, YYYY"),t=s(Ke.endDate,"MMM D, YYYY");return"".concat(e," ").concat(q," ").concat(t)}return Ke.startDate?s(Ke.startDate,"MMM D, YYYY"):Ke.endDate?s(Ke.endDate,"MMM D, YYYY"):""},[ge,ce,Ke,q]),wt=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:"\n @keyframes dropdownFadeIn {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n @keyframes dropdownFadeInTop {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n "}),e.jsxs("div",{ref:We,className:"aha-date-picker ".concat(A),style:r({position:"relative",display:"inline-flex",alignItems:"center",boxSizing:"border-box",fontFamily:"DM Sans, sans-serif",borderRadius:"8px",border:"1px solid ".concat(D?"#F04438":Qe?fe:"#D7D3D0"),backgroundColor:x?"#FAFAF9":"#FFFFFF",cursor:x?"not-allowed":"pointer",transition:"all 0.2s",paddingLeft:"40px",paddingRight:mt?"30px":"12px",paddingTop:Dt[C].paddingTop,paddingBottom:Dt[C].paddingBottom,fontSize:Dt[C].fontSize,lineHeight:Dt[C].lineHeight,fontWeight:400,WebkitTapHighlightColor:"transparent",WebkitTouchCallout:"none",touchAction:"manipulation",userSelect:"none"},L),onClick:ot,onFocus:function(e){null==R||R(e)},onBlur:function(e){null==E||E(e)},tabIndex:x?-1:0,children:[e.jsx("span",{style:{position:"absolute",left:"12px",display:"flex",alignItems:"center",color:x?"#98A2B3":"#78716C",zIndex:1,pointerEvents:"none"},children:e.jsx(function(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.6667 2.66667H12V2C12 1.63181 11.7015 1.33333 11.3333 1.33333C10.9651 1.33333 10.6667 1.63181 10.6667 2V2.66667H5.33333V2C5.33333 1.63181 5.03486 1.33333 4.66667 1.33333C4.29848 1.33333 4 1.63181 4 2V2.66667H3.33333C2.59695 2.66667 2 3.26362 2 4V13.3333C2 14.0697 2.59695 14.6667 3.33333 14.6667H12.6667C13.403 14.6667 14 14.0697 14 13.3333V4C14 3.26362 13.403 2.66667 12.6667 2.66667ZM12.6667 13.3333H3.33333V7.33333H12.6667V13.3333ZM12.6667 6H3.33333V4H12.6667V6Z",fill:"currentColor"})})},{})}),ge?"text"===ce?e.jsx("input",{ref:ze,type:"text",value:Ft,readOnly:!0,placeholder:y,disabled:x,onClick:function(e){e.stopPropagation(),x||ot()},style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"16px",lineHeight:"24px",fontWeight:400,color:x?"#98A2B3":Ke.startDate||Ke.endDate?"#1C1917":"#79716B",fontFamily:"DM Sans, sans-serif",minWidth:0,cursor:x?"not-allowed":"pointer",WebkitAppearance:"none",appearance:"none"}}):e.jsxs("div",{style:{display:"flex",alignItems:"center",flex:1,gap:"8px",minWidth:0},children:[e.jsx("input",{ref:He,type:"text",value:vt,readOnly:!0,placeholder:b,disabled:x,onClick:function(e){if(e.stopPropagation(),!x)if(Ye(!0),Qe){if(!Ke.startDate&&!Ke.endDate){var t=new Date;Be({year:t.getFullYear(),month:t.getMonth()})}}else ot()},style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"16px",lineHeight:"24px",fontWeight:400,color:x?"#98A2B3":Ke.startDate?"#1C1917":"#79716B",fontFamily:"DM Sans, sans-serif",minWidth:0,cursor:x?"not-allowed":"pointer",WebkitAppearance:"none",appearance:"none"}}),e.jsx("span",{style:{color:x?"#98A2B3":"#78716C",fontSize:"16px",flexShrink:0},children:q}),e.jsx("input",{ref:Ve,type:"text",value:bt,readOnly:!0,placeholder:w,disabled:x,onClick:function(e){if(e.stopPropagation(),!x)if(Ye(!1),Qe){if(!Ke.startDate&&!Ke.endDate){var t=new Date;Be({year:t.getFullYear(),month:t.getMonth()})}}else ot()},style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"16px",lineHeight:"24px",fontWeight:400,color:x?"#98A2B3":Ke.endDate?"#1C1917":"#79716B",fontFamily:"DM Sans, sans-serif",minWidth:0,cursor:x?"not-allowed":"pointer",WebkitAppearance:"none",appearance:"none"}})]}):e.jsx("input",{ref:ze,type:"text",value:yt,readOnly:!0,placeholder:y,disabled:x,onClick:function(e){e.stopPropagation(),x||ot()},style:{flex:1,border:"none",outline:"none",background:"transparent",fontSize:"16px",lineHeight:"24px",fontWeight:400,color:x?"#98A2B3":_e?"#1C1917":"#79716B",fontFamily:"DM Sans, sans-serif",minWidth:0,cursor:x?"not-allowed":"pointer",WebkitAppearance:"none",appearance:"none"}}),mt&&e.jsx("div",{style:{position:"absolute",right:"10px",display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(function(){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",onClick:at,style:{cursor:"pointer",flexShrink:0,color:"#78716C"},children:e.jsx("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})},{})})]}),Qe&&Oe&&n.createPortal(e.jsx("div",{ref:Ne,className:"aha-date-picker-dropdown ".concat(z),style:r({position:"absolute",top:"".concat(Oe.top,"px"),left:"".concat(Oe.left,"px"),zIndex:1050,backgroundColor:"#FFFFFF",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",border:"1px solid #E7E5E4",padding:"0",opacity:0,transform:"top"===(Oe.placement||"bottom")?"translateY(8px)":"translateY(-8px)",animation:"top"===(Oe.placement||"bottom")?"dropdownFadeInTop 0.2s ease-out forwards":"dropdownFadeIn 0.2s ease-out forwards",display:"flex",flexDirection:"column"},H),children:e.jsxs("div",{style:{display:"flex",flex:1,minHeight:0,flexDirection:ge&&st&&1===_?"column":"row"},children:[ge&&st&&2===_&&e.jsx("div",{style:{width:"140px",borderRight:"1px solid #E7E5E4",padding:"12px 0",backgroundColor:"#FFFFFF",borderTopLeftRadius:"8px",borderBottomLeftRadius:Q?"0":"8px"},children:lt.map(function(t,n){var r=je?u(t.range.startDate,je.startDate)&&u(t.range.endDate,je.endDate):u(t.range.startDate,Ke.startDate)&&u(t.range.endDate,Ke.endDate);return e.jsx("div",{onClick:function(){return dt(t.range)},style:{padding:"8px 16px",cursor:"pointer",fontSize:"14px",fontFamily:"DM Sans, sans-serif",color:r?fe:"#1C1917",backgroundColor:r?"#FAFAF9":"transparent",fontWeight:r?500:400,transition:"all 0.2s"},onMouseEnter:function(e){r||(e.currentTarget.style.backgroundColor="#F5F5F4")},onMouseLeave:function(e){r||(e.currentTarget.style.backgroundColor="transparent")},children:t.label},n)})}),e.jsxs("div",{children:[e.jsx("div",{style:{flex:1,padding:"16px",display:"flex",flexDirection:2===_?"row":"column",gap:2===_?"24px":"0"},children:(tt=function(t,n,r,a,o){return void 0===o&&(o=0),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:2===_&&ge?"center":"space-between",marginBottom:"16px",position:"relative"},children:[!(2===_&&ge&&1===o)&&e.jsx("button",{type:"button",onClick:r,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",cursor:"pointer",borderRadius:"4px",color:"#78716C",transition:"all 0.2s",position:2===_&&ge?"absolute":"relative",left:2===_&&ge?0:void 0},onMouseEnter:function(e){e.currentTarget.style.backgroundColor="#FAFAF9"},onMouseLeave:function(e){e.currentTarget.style.backgroundColor="transparent"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M10 12L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsxs("div",{style:{fontSize:"16px",fontWeight:500,color:"#1C1917",fontFamily:"DM Sans, sans-serif"},children:[l[t.month]," ",t.year]}),!(2===_&&ge&&0===o)&&e.jsx("button",{type:"button",onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",cursor:"pointer",borderRadius:"4px",color:"#78716C",transition:"all 0.2s",position:2===_&&ge?"absolute":"relative",right:2===_&&ge?0:void 0},onMouseEnter:function(e){e.currentTarget.style.backgroundColor="#FAFAF9"},onMouseLeave:function(e){e.currentTarget.style.backgroundColor="transparent"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:e.jsx("path",{d:"M6 4L10 8L6 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),ge&&oe&&1===_&&0===o&&(i=Q&&je?je:Ke,p=i.startDate?s(i.startDate,"MMM D, YYYY"):le,f=i.endDate?s(i.endDate,"MMM D, YYYY"):de,e.jsxs("div",{className:"flex items-center gap-2",style:{fontSize:"14px",marginBottom:"16px"},children:[e.jsx("div",{className:"flex-1 text-center border border-[#D7D3D0] rounded-md px-2 py-[6px] ".concat(i.startDate?"text-[#44403C]":"text-[#79716B]"),children:p}),e.jsx("div",{children:q}),e.jsx("div",{className:"flex-1 text-center border border-[#D7D3D0] rounded-md px-2 py-[6px] ".concat(i.endDate?"text-[#44403C]":"text-[#79716B]"),children:f})]})),ge&&st&&1===_&&e.jsx("div",{style:{width:"252px",display:"flex",flexWrap:"wrap",paddingBottom:"16px"},children:lt.map(function(t,n){var r=je?u(t.range.startDate,je.startDate)&&u(t.range.endDate,je.endDate):u(t.range.startDate,Ke.startDate)&&u(t.range.endDate,Ke.endDate);return e.jsx("button",{type:"button",onClick:function(){return dt(t.range)},style:{padding:"4px 8px",cursor:"pointer",fontSize:"14px",fontFamily:"DM Sans, sans-serif",color:r?fe:"#1C1917",backgroundColor:r?"#FAFAF9":"transparent",border:"none",fontWeight:r?500:400,transition:"all 0.2s",borderRadius:"4px"},children:t.label},n)})}),e.jsx("div",{style:{width:"252px",display:"grid",gridTemplateColumns:"repeat(7, 1fr)",marginBottom:"8px"},children:wt.map(function(t){return e.jsx("div",{style:{width:"36px",textAlign:"center",fontSize:"12px",fontWeight:500,color:"#78716C",fontFamily:"DM Sans, sans-serif",padding:"4px"},children:t},t)})}),e.jsx("div",{style:{width:"252px",display:"grid",gridTemplateColumns:"repeat(7, 1fr)",rowGap:"4px",columnGap:"0px"},children:function(){for(var r,a,o=(r=t.year,a=t.month,new Date(r,a,1).getDay()),i=(0===o?7:o)-1,l=[],s=0;s<i;s++)l.push(e.jsx("div",{},"empty-".concat(s)));return n.forEach(function(n,r){if(n){var a=i+r,o=n.getMonth()===t.month,s=u(n,new Date),p=!c(n,O,P);if(ge){var f=Q&&je?je:Ke,g=u(n,f.startDate),x=u(n,f.endDate),h=function(e,t,n){if(!t||!n)return!1;var r=e.getTime(),a=t.getTime(),o=n.getTime();return r>=a&&r<=o}(n,f.startDate,f.endDate),D=a%7==0,m=a%7==6,y=g,v=x,b={display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px",border:"none",cursor:p?"not-allowed":"pointer",fontSize:"14px",fontFamily:"DM Sans, sans-serif",transition:"all 0.2s",opacity:p?.4:1,position:"relative",padding:0,margin:0};if(y||v)b.background=fe,b.borderRadius="50%",b.color="#FFFFFF",b.fontWeight=500;else if(h){b.background="#F5F5F4",b.color=o?p?"#D7D3D0":"#1C1917":"#78716C",b.fontWeight=400;var F=1===n.getDate(),w=d(t.year,t.month),M=n.getDate()===w,C=D||F,Y=m||M;C&&Y?b.borderRadius="18px":C?(b.borderTopLeftRadius="18px",b.borderBottomLeftRadius="18px",b.borderTopRightRadius="0",b.borderBottomRightRadius="0"):Y?(b.borderTopRightRadius="18px",b.borderBottomRightRadius="18px",b.borderTopLeftRadius="0",b.borderBottomLeftRadius="0"):b.borderRadius="0"}else b.background="transparent",b.borderRadius="50%",b.color=o?p?"#D7D3D0":"#1C1917":"#78716C",b.fontWeight=400;l.push(e.jsxs("button",{type:"button",disabled:p,onClick:function(){return rt(n)},style:b,onMouseEnter:function(e){p||y||v||(e.currentTarget.style.backgroundColor=h?"#E7E5E4":"#FAFAF9")},onMouseLeave:function(e){y||v||(e.currentTarget.style.backgroundColor=h?"#F5F5F4":"transparent")},children:[n.getDate(),s&&e.jsx("div",{style:{position:"absolute",bottom:"3px",left:"50%",transform:"translateX(-50%)",width:"4px",height:"4px",borderRadius:"50%",backgroundColor:y||v?"#FFFFFF":fe}})]},"date-".concat(r)))}else{var k=u(n,_e);l.push(e.jsxs("button",{type:"button",disabled:p,onClick:function(){return nt(n)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px",border:"none",background:k?fe:"transparent",cursor:p?"not-allowed":"pointer",borderRadius:"4px",fontSize:"14px",fontWeight:k?500:400,color:k?"#FFFFFF":o?p?"#D7D3D0":"#1C1917":"#78716C",fontFamily:"DM Sans, sans-serif",transition:"all 0.2s",opacity:p?.4:1,position:"relative",padding:0,margin:0},onMouseEnter:function(e){p||k||(e.currentTarget.style.backgroundColor="#FAFAF9")},onMouseLeave:function(e){k||(e.currentTarget.style.backgroundColor="transparent")},children:[n.getDate(),s&&!k&&e.jsx("div",{style:{position:"absolute",bottom:"2px",left:"50%",transform:"translateX(-50%)",width:"4px",height:"4px",borderRadius:"50%",backgroundColor:fe}})]},"date-".concat(r)))}}}),l}()})]},o);var i,p,f},e.jsxs(e.Fragment,{children:[tt(Ee,ft,ut,ct,0),2===_&&ge&&Ae&>&&tt(Ae,gt,xt,ht,1)]}))}),ge&&oe&&2===_&&!Q&&(Ue=Ke,$e=Ue.startDate?s(Ue.startDate,"MMM D, YYYY"):le,et=Ue.endDate?s(Ue.endDate,"MMM D, YYYY"):de,e.jsx("div",{className:"flex items-center gap-2",style:{padding:"12px 16px",borderTop:"1px solid #E7E5E4",borderBottomLeftRadius:"8px",borderBottomRightRadius:"8px"},children:e.jsxs("div",{className:"w-[260px] flex items-center gap-2",style:{fontSize:"14px"},children:[e.jsx("div",{className:"flex-1 text-center border border-[#D7D3D0] rounded-md px-2 py-[6px] ".concat(Ue.startDate?"text-[#44403C]":"text-[#79716B]"),children:$e}),e.jsx("div",{children:q}),e.jsx("div",{className:"flex-1 text-center border border-[#D7D3D0] rounded-md px-2 py-[6px] ".concat(Ue.endDate?"text-[#44403C]":"text-[#79716B]"),children:et})]})})),ge&&Q&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",padding:"12px 16px",borderTop:"1px solid #E7E5E4",borderBottomLeftRadius:"8px",borderBottomRightRadius:"8px"},children:[oe&&2===_&&function(){var t=je||Ke,n=t.startDate?s(t.startDate,"MMM D, YYYY"):le,r=t.endDate?s(t.endDate,"MMM D, YYYY"):de;return e.jsxs("div",{className:"w-[260px] flex items-center gap-2",style:{fontSize:"14px"},children:[e.jsx("div",{className:"flex-1 text-center border border-[#D7D3D0] rounded-md px-2 py-[6px] ".concat(t.startDate?"text-[#44403C]":"text-[#79716B]"),children:n}),e.jsx("div",{children:q}),e.jsx("div",{className:"flex-1 text-center border border-[#D7D3D0] rounded-md px-2 py-[6px] ".concat(t.endDate?"text-[#44403C]":"text-[#79716B]"),children:r})]})}(),e.jsxs("div",{className:"".concat(2===_?"":"w-full"),style:{display:"flex",gap:"8px",flexShrink:0,marginLeft:"auto"},children:[e.jsx("button",{type:"button",onClick:function(){Se(null),null==re||re(),Ge||we(!1),null==B||B(!1)},style:{flex:1,padding:"8px 16px",border:"1px solid #E7E5E4",borderRadius:"8px",background:"#FFFFFF",color:"#1C1917",fontSize:"14px",fontWeight:500,fontFamily:"DM Sans, sans-serif",cursor:"pointer",transition:"all 0.2s"},onMouseEnter:function(e){e.currentTarget.style.backgroundColor="#FAFAF9"},onMouseLeave:function(e){e.currentTarget.style.backgroundColor="#FFFFFF"},children:te}),e.jsx("button",{type:"button",onClick:function(){var e;je&&(Ze||ve(je),"range"===f&&"onChange"in i&&(null===(e=i.onChange)||void 0===e||e.call(i,je)),null==ne||ne(je),Ge||we(!1),null==B||B(!1),Se(null))},disabled:!je||!je.startDate||!je.endDate,style:{flex:1,padding:"8px 16px",border:"none",borderRadius:"8px",background:je&&je.startDate&&je.endDate?fe:"#D7D3D0",color:"#FFFFFF",fontSize:"14px",fontWeight:500,fontFamily:"DM Sans, sans-serif",cursor:je&&je.startDate&&je.endDate?"pointer":"not-allowed",transition:"all 0.2s"},onMouseEnter:function(e){je&&je.startDate&&je.endDate&&(e.currentTarget.style.backgroundColor="#FD843A")},onMouseLeave:function(e){je&&je.startDate&&je.endDate&&(e.currentTarget.style.backgroundColor=fe)},children:$})]})]})]})]})}),document.body)]})};p.displayName="DatePicker",exports.default=p;
|
|
2
2
|
//# sourceMappingURL=DatePicker.js.map
|