react-smart-date-compare 1.0.2 → 1.1.0
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/README.md +3 -1
- package/dist/components/CompareSection.d.ts.map +1 -1
- package/dist/components/DateRangePicker.d.ts.map +1 -1
- package/dist/components/SmartDateCompare.d.ts.map +1 -1
- package/dist/react-smart-date-compare.css +1 -1
- package/dist/react-smart-date-compare.es.js +548 -496
- package/dist/react-smart-date-compare.umd.js +20 -4
- package/dist/type.d.ts +1 -0
- package/dist/type.d.ts.map +1 -1
- package/package.json +9 -4
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(X,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react"),require("react-dom"),require("date-fns")):typeof define=="function"&&define.amd?define(["exports","react","react-dom","date-fns"],h):(X=typeof globalThis<"u"?globalThis:X||self,h(X.ReactSmartDateCompare={},X.React,X.ReactDOM,X.DateFns))})(this,(function(X,h,pe,t){"use strict";var te={exports:{}},q={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var ae;function ye(){if(ae)return q;ae=1;var n=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function a(p,i,c){var v=null;if(c!==void 0&&(v=""+c),i.key!==void 0&&(v=""+i.key),"key"in i){c={};for(var w in i)w!=="key"&&(c[w]=i[w])}else c=i;return i=c.ref,{$$typeof:n,type:p,key:v,ref:i!==void 0?i:null,props:c}}return q.Fragment=o,q.jsx=a,q.jsxs=a,q}var F={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var ie;function ve(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&(function(){function n(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===$?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case E:return"Profiler";case g:return"StrictMode";case Y:return"Suspense";case Q:return"SuspenseList";case m:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case z:return"Portal";case l:return e.displayName||"Context";case U:return(e._context.displayName||"Context")+".Consumer";case S:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case x:return s=e.displayName||null,s!==null?s:n(e.type)||"Memo";case D:s=e._payload,e=e._init;try{return n(e(s))}catch{}}return null}function o(e){return""+e}function a(e){try{o(e);var s=!1}catch{s=!0}if(s){s=console;var d=s.error,y=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return d.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",y),o(e)}}function p(e){if(e===k)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===D)return"<...>";try{var s=n(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function i(){var e=f.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function v(e){if(R.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function w(e,s){function d(){O||(O=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s))}d.isReactWarning=!0,Object.defineProperty(e,"key",{get:d,configurable:!0})}function C(){var e=n(this.type);return W[e]||(W[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function G(e,s,d,y,J,K){var u=d.ref;return e={$$typeof:Z,type:e,key:s,props:d,_owner:y},(u!==void 0?u:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:C}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:K}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function M(e,s,d,y,J,K){var u=s.children;if(u!==void 0)if(y)if(A(u)){for(y=0;y<u.length;y++)L(u[y]);Object.freeze&&Object.freeze(u)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else L(u);if(R.call(s,"key")){u=n(e);var j=Object.keys(s).filter(function(N){return N!=="key"});y=0<j.length?"{key: someKey, "+j.join(": ..., ")+": ...}":"{key: someKey}",V[u+y]||(j=0<j.length?"{"+j.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
18
|
let props = %s;
|
|
3
19
|
<%s {...props} />
|
|
4
20
|
React keys must be passed directly to JSX without using spread:
|
|
5
21
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,
|
|
7
|
-
${
|
|
8
|
-
${P?A:"text-gray-600 hover:bg-gray-100"}`,style:{paddingLeft:c>0?`${(c+1)*12}px`:void 0,...P?N:{}},onClick:()=>s(n.value),type:"button",children:n.label})},Se=({presets:n,onSelect:s,activePreset:a,primaryColor:p,classNames:i})=>r.jsx("aside",{className:"flex flex-col gap-0.5 p-2",children:n.map(c=>r.jsx(le,{preset:c,onSelect:s,activePreset:a,primaryColor:p,classNames:i},c.value))}),we=({enabled:n,mode:s,onToggle:a,onModeChange:p,primaryColor:i="#3b82f6",compareColor:c="#f97316"})=>r.jsxs("div",{className:"flex flex-col gap-2 text-sm text-gray-700",children:[r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[r.jsxs("div",{className:"relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out",style:{backgroundColor:n?i:"#d1d5db"},onClick:()=>a(!n),children:[r.jsx("input",{type:"checkbox",className:"sr-only",checked:n,onChange:y=>a(y.target.checked)}),r.jsx("span",{"aria-hidden":"true",className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${n?"translate-x-4":"translate-x-0"}`})]}),r.jsx("span",{className:"font-medium",children:"Compare"})]}),n&&r.jsx("div",{className:"flex flex-col gap-1 mt-2 pl-2",style:{borderLeft:`2px solid ${i}40`},children:[{value:"previousPeriodMatchDay",label:"Previous period (match day of week)"},{value:"previousPeriod",label:"Previous period"},{value:"samePeriodLastYear",label:"Previous year"},{value:"custom",label:"Custom"}].map(y=>{const g=s===y.value;return r.jsx("button",{className:"text-left px-3 py-2 rounded-md text-xs transition-colors cursor-pointer",style:g?{backgroundColor:`${c}15`,color:c,fontWeight:600}:{color:"#6b7280"},onClick:()=>p(y.value),children:y.label},y.value)})})]}),je=n=>{const s=t.startOfToday(),a=t.endOfToday();switch(n){case"today":return{startDate:s,endDate:a};case"yesterday":return{startDate:t.subDays(s,1),endDate:t.subDays(a,1)};case"last7days":return{startDate:t.subDays(s,6),endDate:a};case"thisWeekSunToday":return{startDate:t.startOfWeek(s,{weekStartsOn:0}),endDate:a};case"thisWeekMonToday":return{startDate:t.startOfWeek(s,{weekStartsOn:1}),endDate:a};case"lastWeekSunSat":const i=t.subDays(t.startOfWeek(s,{weekStartsOn:0}),7);return{startDate:i,endDate:t.endOfWeek(i,{weekStartsOn:0})};case"lastWeekMonSun":const c=t.subDays(t.startOfWeek(s,{weekStartsOn:1}),7);return{startDate:c,endDate:t.endOfWeek(c,{weekStartsOn:1})};case"last28Days":return{startDate:t.subDays(s,27),endDate:a};case"last30days":return{startDate:t.subDays(s,29),endDate:a};case"thisMonth":return{startDate:t.startOfMonth(s),endDate:t.endOfMonth(s)};case"lastMonth":const y=t.subMonths(s,1);return{startDate:t.startOfMonth(y),endDate:t.endOfMonth(y)};case"ytd":return{startDate:t.startOfYear(s),endDate:a};default:return{startDate:s,endDate:a}}},ie=[{label:"Today",value:"today"},{label:"Yesterday",value:"yesterday"},{label:"This week",value:"__group_thisWeek",children:[{label:"Sun – Today",value:"thisWeekSunToday"},{label:"Mon – Today",value:"thisWeekMonToday"}]},{label:"Last 7 days",value:"last7days"},{label:"Last week",value:"__group_lastWeek",children:[{label:"Sun – Sat",value:"lastWeekSunSat"},{label:"Mon – Sun",value:"lastWeekMonSun"}]},{label:"Last 28 days",value:"last28Days"},{label:"Last 30 days",value:"last30days"},{label:"This month",value:"thisMonth"},{label:"Last month",value:"lastMonth"},{label:"Year to Date",value:"ytd"},{label:"Custom",value:"custom"}],De=({initialRange:n,initialCompareRange:s,presets:a=ie,onApply:p,onCancel:i,enableCompare:c=!1,activeCompareMode:y="previousPeriod",primaryColor:g="#3b82f6",compareColor:M="#f97316",minDate:Y,maxDate:P,weekStartsOn:N,disabledDates:A,disableFuture:T,disablePast:H,locale:B,labels:z,classNames:I})=>{const[S,U]=u.useState(n?.startDate),[f,j]=u.useState(n?.endDate),[G,X]=u.useState(null),[m,w]=u.useState(!1),[k,Z]=u.useState(c),[d,C]=u.useState(y);u.useEffect(()=>{Z(c)},[c]),u.useEffect(()=>{C(y)},[y]);const[O,D]=u.useState("primary");u.useEffect(()=>{D(k&&d==="custom"?"compare":"primary")},[k,d]);const[_,E]=u.useState(s?.startDate),[R,L]=u.useState(s?.endDate),[V,e]=u.useState(""),[o,l]=u.useState(()=>{const x=n?.endDate||new Date;return t.subMonths(t.startOfMonth(x),1)});u.useEffect(()=>{if(k&&!m&&S&&f&&d!=="custom"){let x;d==="previousPeriod"?x=xe(S,f):d==="previousPeriodMatchDay"?x=be(S,f):d==="samePeriodLastYear"&&(x=ve(S,f)),x&&(E(x.compareStart),L(x.compareEnd))}},[S,f,k,d,m]);const h=x=>{Y&&t.isBefore(x,Y)||P&&t.isBefore(P,x)||(m?(O==="compare"?_&&t.isBefore(x,_)?(E(x),L(_)):L(x):S&&t.isBefore(x,S)?(U(x),j(S)):j(x),w(!1)):(e("custom"),O==="compare"?(E(x),L(void 0)):(U(x),j(void 0)),w(!0)))},b=x=>{m&&X(x)},W=x=>{if(x.startsWith("__group_"))return;const ce=(Re,fe)=>{for(const ne of Re){if(ne.value===fe)return ne;if(ne.children){const de=ce(ne.children,fe);if(de)return de}}},ue=ce(a,x);e(x);let F;ue?.range?F=ue.range():F=je(x),U(F.startDate),j(F.endDate),w(!1),D("primary"),l(t.subMonths(t.startOfMonth(F.endDate),1))},v=()=>l(t.subMonths(o,1)),Q=()=>l(t.addMonths(o,1)),q=()=>{S&&f&&p({startDate:S,endDate:f},k&&_&&R?{startDate:_,endDate:R}:void 0,k?d:void 0)},re=x=>r.jsx(ke,{month:x,startDate:S,endDate:f,compareStartDate:k?_:void 0,compareEndDate:k?R:void 0,hoverDate:G,onDateClick:h,onDateHover:b,selecting:m,anchorDate:m?O==="primary"?S:_:void 0,selectionVariant:O,minDate:Y,maxDate:P,weekStartsOn:N,disabledDates:A,disableFuture:T,disablePast:H,locale:B,classNames:I,primaryColor:g,compareColor:M});return r.jsxs("div",{className:`flex bg-white h-[450px] ${I?.root||""}`,children:[r.jsxs("div",{className:`w-48 bg-gray-50/50 border-r border-gray-100 flex flex-col h-full shrink-0 ${I?.sidebar||""}`,children:[r.jsx("div",{className:"flex-1 overflow-y-auto preset-scrollbar",children:r.jsx(Se,{presets:a,onSelect:W,activePreset:V,primaryColor:g,classNames:I})}),r.jsx("div",{className:"p-3 border-t border-gray-200 bg-gray-50/80 backdrop-blur-sm",children:r.jsx(we,{enabled:k,mode:d,onToggle:Z,onModeChange:C,primaryColor:g,compareColor:M})})]}),r.jsxs("div",{className:"flex flex-col flex-1 h-full overflow-hidden",children:[r.jsxs("div",{className:"flex justify-between items-center px-4 py-2 border-b border-gray-100 shrink-0",children:[r.jsx("button",{className:"p-1.5 rounded-full hover:bg-gray-100 text-gray-500 hover:text-gray-900 transition-colors cursor-pointer",onClick:v,children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 19l-7-7 7-7"})})}),r.jsxs("div",{className:"text-xs font-medium text-gray-500 flex flex-col items-center",children:[S&&f?r.jsxs("span",{children:[t.format(S,"MMM d, yyyy",{locale:B})," - ",t.format(f,"MMM d, yyyy",{locale:B})]}):r.jsx("span",{children:z?.selectDateRange||"Select date range"}),k&&_&&R&&r.jsxs("span",{className:"text-[10px] font-medium",style:{color:M},children:[z?.vs||"vs"," ",t.format(_,"MMM d, yyyy",{locale:B})," - ",t.format(R,"MMM d, yyyy",{locale:B})]})]}),r.jsx("button",{className:"p-1.5 rounded-full hover:bg-gray-100 text-gray-500 hover:text-gray-900 transition-colors cursor-pointer",onClick:Q,children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 5l7 7-7 7"})})})]}),r.jsxs("div",{className:`flex flex-col gap-4 p-4 overflow-y-auto flex-1 items-center ${I?.container||""}`,children:[re(o),re(t.addMonths(o,1))]}),r.jsxs("div",{className:`px-4 py-3 border-t border-gray-100 flex items-center justify-between shrink-0 bg-white ${I?.footer||""}`,children:[r.jsx("button",{className:"text-xs font-medium text-gray-500 hover:text-gray-700 underline decoration-gray-300 hover:decoration-gray-500 underline-offset-2 transition-colors cursor-pointer",onClick:()=>{U(void 0),j(void 0),w(!1),e(""),Z(!1)},children:z?.clear||"Reset"}),r.jsxs("div",{className:"flex gap-3",children:[r.jsx("button",{className:`px-3 py-1.5 rounded-md border border-gray-300 bg-white text-xs font-medium text-gray-700 hover:bg-gray-50 transition-colors cursor-pointer ${I?.buttonCancel||""}`,onClick:i,children:z?.cancel||"Cancel"}),r.jsx("button",{className:`px-3 py-1.5 rounded-md border border-transparent text-xs font-medium text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed shadow-sm cursor-pointer ${I?.buttonApply||""}`,style:{backgroundColor:g},onClick:q,disabled:!S||!f,children:z?.apply||"Apply"})]})]})]})]})},Ee=({value:n,defaultValue:s,onChange:a,onApply:p,onCancel:i,presets:c,primaryColor:y,compareColor:g,enableCompare:M=!1,compareMode:Y="previousPeriod",className:P,style:N,minDate:A,maxDate:T,weekStartsOn:H,disabledDates:B,disableFuture:z,disablePast:I,locale:S,labels:U,classNames:f})=>{const[j,G]=u.useState(!1),[X,m]=u.useState(n||s||{startDate:new Date,endDate:new Date}),[w,k]=u.useState(),[Z,d]=u.useState(M),[C,O]=u.useState(Y),[D,_]=u.useState({top:0,left:0}),E=u.useRef(null),R=u.useRef(null);u.useEffect(()=>{n&&m(n)},[n]),u.useEffect(()=>{d(M)},[M]),u.useEffect(()=>{O(Y)},[Y]);const L=()=>{if(!E.current)return;const b=E.current.getBoundingClientRect();_({top:b.bottom+window.scrollY+4,left:b.left+window.scrollX})},V=()=>{j||L(),G(b=>!b)};u.useEffect(()=>{if(!j)return;const b=()=>L();return window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b)}},[j]),u.useEffect(()=>{if(!j)return;const b=W=>{const v=W.target;E.current?.contains(v)||R.current?.contains(v)||(G(!1),i?.())};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[j,i]);const e=(b,W,v)=>{m(b),k(W),d(!!W),v&&O(v),G(!1),a?.({startDate:b.startDate,endDate:b.endDate,compareStartDate:W?.startDate,compareEndDate:W?.endDate}),p?.(b,W)},o=()=>{G(!1),i?.()},l=b=>t.format(b,"MMM d, yyyy",{locale:S}),h=`${l(X.startDate)} - ${l(X.endDate)}`;return r.jsxs("div",{ref:E,className:`relative inline-block text-left ${P||""} ${f?.root||""}`,style:{"--sdc-primary-color":y,"--sdc-compare-color":g,...N},children:[r.jsxs("button",{className:`flex items-center justify-between min-w-[240px] px-3 py-2 bg-white border border-gray-300 rounded hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all shadow-sm ${f?.container||""}`,onClick:V,type:"button","aria-haspopup":"dialog","aria-expanded":j,children:[r.jsxs("div",{className:"flex items-center gap-2 text-gray-700",children:[r.jsx("span",{className:"text-gray-400",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),r.jsx("span",{className:"text-sm font-medium",children:h})]}),w&&r.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded ml-2 font-medium ${f?.dayCompare||""}`,style:{color:g,backgroundColor:`${g}18`},children:["vs ",l(w.startDate)]}),r.jsx("svg",{className:`w-4 h-4 text-gray-400 transition-transform ${j?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]}),j&&me.createPortal(r.jsx("div",{ref:R,style:{position:"absolute",top:D.top,left:D.left,zIndex:99999},role:"dialog","aria-modal":"true",children:r.jsx("div",{className:`bg-white ring-1 ring-black ring-opacity-5 rounded-lg shadow-2xl overflow-hidden ${f?.calendar||""}`,style:{"--sdc-primary-color":y,"--sdc-compare-color":g},children:r.jsx(De,{initialRange:X,initialCompareRange:w,presets:c,onApply:e,onCancel:o,enableCompare:Z,activeCompareMode:C,primaryColor:y,compareColor:g,minDate:A,maxDate:T,weekStartsOn:H,disabledDates:B,disableFuture:z,disablePast:I,locale:S,labels:U,classNames:f})})}),document.body)]})};J.SmartDateCompare=Ee,J.defaultPresets=ie,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})}));
|
|
22
|
+
<%s key={someKey} {...props} />`,y,u,j,u),V[u+y]=!0)}if(u=null,d!==void 0&&(a(d),u=""+d),v(s)&&(a(s.key),u=""+s.key),"key"in s){d={};for(var H in s)H!=="key"&&(d[H]=s[H])}else d=s;return u&&w(d,typeof e=="function"?e.displayName||e.name||"Unknown":e),G(e,u,d,i(),J,K)}function L(e){I(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===D&&(e._payload.status==="fulfilled"?I(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function I(e){return typeof e=="object"&&e!==null&&e.$$typeof===Z}var P=h,Z=Symbol.for("react.transitional.element"),z=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),U=Symbol.for("react.consumer"),l=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),Y=Symbol.for("react.suspense"),Q=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),f=P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=Object.prototype.hasOwnProperty,A=Array.isArray,_=console.createTask?console.createTask:function(){return null};P={react_stack_bottom_frame:function(e){return e()}};var O,W={},T=P.react_stack_bottom_frame.bind(P,c)(),B=_(p(c)),V={};F.Fragment=k,F.jsx=function(e,s,d){var y=1e4>f.recentlyCreatedOwnerStacks++;return M(e,s,d,!1,y?Error("react-stack-top-frame"):T,y?_(p(e)):B)},F.jsxs=function(e,s,d){var y=1e4>f.recentlyCreatedOwnerStacks++;return M(e,s,d,!0,y?Error("react-stack-top-frame"):T,y?_(p(e)):B)}})()),F}var le;function be(){return le||(le=1,process.env.NODE_ENV==="production"?te.exports=ye():te.exports=ve()),te.exports}var r=be();const ge=(n,o)=>{const a=t.differenceInCalendarDays(o,n)+1;return{compareStart:t.subDays(n,a),compareEnd:t.subDays(o,a)}},me=(n,o)=>{const a=t.differenceInCalendarDays(o,n)+1,p=a%7,i=p===0?a:a+(7-p);return{compareStart:t.subDays(n,i),compareEnd:t.subDays(o,i)}},ke=(n,o)=>({compareStart:t.subYears(n,1),compareEnd:t.subYears(o,1)}),we=(n,o)=>{const a=t.startOfMonth(n),p=t.endOfMonth(a),i=t.startOfWeek(a,o),c=t.endOfWeek(p,o);return t.eachDayOfInterval({start:i,end:c})};function re(n,o){const a=n.replace("#",""),p=parseInt(a.substring(0,2),16),i=parseInt(a.substring(2,4),16),c=parseInt(a.substring(4,6),16);return`rgba(${p},${i},${c},${o})`}const Se=({month:n,startDate:o,endDate:a,compareStartDate:p,compareEndDate:i,hoverDate:c,onDateClick:v,onDateHover:w,selecting:C,anchorDate:G,selectionVariant:M="primary",primaryColor:L="#3b82f6",compareColor:I="#f97316",minDate:P,maxDate:Z,weekStartsOn:z=0,disabledDates:k,disableFuture:g,disablePast:E,locale:U,classNames:l})=>{const S=h.useMemo(()=>we(n,{weekStartsOn:z}),[n,z]),Y=S.slice(0,7),Q=x=>{let D=!1;if(P&&t.isBefore(x,t.startOfDay(P))&&(D=!0),Z&&t.isAfter(x,t.startOfDay(Z))&&(D=!0),g&&t.isAfter(x,t.startOfDay(new Date))&&(D=!0),E&&t.isBefore(x,t.startOfDay(new Date))&&(D=!0),k!=null&&k.some(d=>t.isSameDay(x,d))&&(D=!0),D)return{className:"h-8 w-8 flex items-center justify-center text-sm text-gray-300 cursor-not-allowed pointer-events-none"};if(!t.isSameMonth(x,n))return{className:"invisible pointer-events-none h-8 w-8"};const m=x.getTime(),f=["h-8 w-8 flex items-center justify-center text-sm cursor-pointer relative z-10 transition-colors duration-75"];let R={};l!=null&&l.day&&f.push(l.day);let A=!1,_=!1,O=!1;if(p&&i){const d=t.startOfDay(p).getTime(),y=t.startOfDay(i).getTime(),J=Math.min(d,y),K=Math.max(d,y);A=t.isSameDay(x,p),_=t.isSameDay(x,i),m>=J&&m<=K&&(O=!0)}let W=!1,T=!1,B=!1;if(o&&(W=t.isSameDay(x,o)),a&&(T=t.isSameDay(x,a)),o&&a){const d=t.startOfDay(o).getTime(),y=t.startOfDay(a).getTime();m>=Math.min(d,y)&&m<=Math.max(d,y)&&(B=!0)}const V=G??(M==="primary"?o:p);let e=!1;if(C&&V&&c){const d=t.startOfDay(V).getTime(),y=t.startOfDay(c).getTime();m>=Math.min(d,y)&&m<=Math.max(d,y)&&(e=!0)}l!=null&&l.dayInRange&&B&&!W&&!T?f.push(l.dayInRange):l!=null&&l.dayCompare&&O&&!A&&!_?f.push(l.dayCompare):e?M==="compare"?R={backgroundColor:re(I,.12),color:I}:R={backgroundColor:re(L,.12),color:L}:O&&!A&&!_?l!=null&&l.dayCompare?f.push(l.dayCompare):R={backgroundColor:re(I,.12),color:I,fontWeight:500}:B&&!W&&!T?l!=null&&l.dayInRange?f.push(l.dayInRange):R={backgroundColor:re(L,.12),color:L}:!A&&!_&&!W&&!T&&f.push("hover:bg-gray-100 text-gray-700 rounded-full");const s=C&&V&&c&&(t.isSameDay(x,V)||t.isSameDay(x,c));return(A||_||s&&M==="compare")&&(l!=null&&l.dayCompare?f.push(l.dayCompare):R={backgroundColor:I,color:"#fff",fontWeight:600,boxShadow:"0 1px 4px rgba(0,0,0,0.15)"},A&&f.push("rounded-l-full"),_&&f.push("rounded-r-full"),A&&_&&f.push("rounded-full"),s&&f.push("rounded-full")),(W||T||s&&M==="primary")&&(l!=null&&l.daySelected?(f.push(l.daySelected),f.push("z-20")):R={backgroundColor:L,color:"#fff",fontWeight:600,boxShadow:"0 1px 4px rgba(0,0,0,0.15)",zIndex:20},W&&f.push("rounded-l-full"),T&&f.push("rounded-r-full"),W&&T&&f.push("rounded-full"),s&&f.push("rounded-full")),{className:f.join(" "),style:Object.keys(R).length?R:void 0}};return r.jsxs("div",{className:`w-64 select-none mr-2 ${(l==null?void 0:l.calendar)||""}`,children:[r.jsx("div",{className:"text-center text-sm font-semibold text-gray-800 mb-2 h-5 first-letter:uppercase",children:t.format(n,"MMMM yyyy",{locale:U})}),r.jsx("div",{className:"grid grid-cols-7 mb-1",children:Y.map(x=>r.jsx("div",{className:"text-center text-[10px] text-gray-400 font-medium h-6 flex items-center justify-center uppercase tracking-wide",children:t.format(x,"cccccc",{locale:U})},x.toString()))}),r.jsx("div",{className:"grid grid-cols-7 gap-y-0.5",children:S.map(x=>{const{className:D,style:m}=Q(x);return r.jsx("div",{className:D+" text-xs",style:m,onClick:()=>{D.includes("pointer-events-none")||v(x)},onMouseEnter:()=>w(x),children:t.format(x,"d")},x.toISOString())})})]})},ue=({preset:n,onSelect:o,activePreset:a,primaryColor:p="#3b82f6",classNames:i,depth:c=0})=>{const v=n.children&&n.children.length>0,w=v?n.children.some(P=>P.value===a):!1,[C,G]=h.useState(w),M=a===n.value,L=i!=null&&i.presetActive?void 0:{backgroundColor:`${p}15`,color:p,fontWeight:600},I=(i==null?void 0:i.presetActive)||"";return v?r.jsxs("div",{children:[r.jsxs("button",{className:`w-full flex items-center justify-between px-3 py-2 rounded-md text-xs transition-colors cursor-pointer
|
|
23
|
+
${w?I:"text-gray-600 hover:bg-gray-100"}`,style:{paddingLeft:`${(c+1)*12}px`,...w?L:{}},onClick:()=>G(P=>!P),type:"button","aria-expanded":C,children:[r.jsx("span",{children:n.label}),r.jsx("svg",{className:`w-3 h-3 shrink-0 ml-1 text-gray-400 transition-transform duration-200 ${C?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]}),C&&r.jsx("div",{className:"flex flex-col gap-0.5 mt-0.5 ml-2 pl-2 border-l border-gray-200",children:n.children.map(P=>r.jsx(ue,{preset:P,onSelect:o,activePreset:a,primaryColor:p,classNames:i,depth:c+1},P.value))})]}):r.jsx("button",{className:`w-full text-left px-3 py-2 rounded-md text-xs transition-colors cursor-pointer
|
|
24
|
+
${M?I:"text-gray-600 hover:bg-gray-100"}`,style:{paddingLeft:c>0?`${(c+1)*12}px`:void 0,...M?L:{}},onClick:()=>o(n.value),type:"button",children:n.label})},je=({presets:n,onSelect:o,activePreset:a,primaryColor:p,classNames:i})=>r.jsx("aside",{className:"flex flex-col gap-0.5 p-2",children:n.map(c=>r.jsx(ue,{preset:c,onSelect:o,activePreset:a,primaryColor:p,classNames:i},c.value))}),Ee=({enabled:n,mode:o,onToggle:a,onModeChange:p,primaryColor:i="#3b82f6",compareColor:c="#f97316"})=>r.jsxs("div",{className:"flex flex-col gap-2 text-sm text-gray-700",children:[r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[r.jsxs("div",{className:"relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out",style:{backgroundColor:n?i:"#d1d5db"},children:[r.jsx("input",{type:"checkbox",className:"sr-only",checked:n,onChange:v=>a(v.target.checked)}),r.jsx("span",{"aria-hidden":"true",className:`pointer-events-none inline-block h-4 w-4 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${n?"translate-x-4":"translate-x-0"}`})]}),r.jsx("span",{className:"font-medium",children:"Compare"})]}),n&&r.jsx("div",{className:"flex flex-col gap-1 mt-2 pl-2",style:{borderLeft:`2px solid ${i}40`},children:[{value:"previousPeriodMatchDay",label:"Previous period (match day of week)"},{value:"previousPeriod",label:"Previous period"},{value:"samePeriodLastYear",label:"Previous year"},{value:"custom",label:"Custom"}].map(v=>{const w=o===v.value;return r.jsx("button",{className:"text-left px-3 py-2 rounded-md text-xs transition-colors cursor-pointer",style:w?{backgroundColor:`${c}15`,color:c,fontWeight:600}:{color:"#6b7280"},onClick:()=>p(v.value),children:v.label},v.value)})})]}),De=n=>{const o=t.startOfToday(),a=t.endOfToday();switch(n){case"today":return{startDate:o,endDate:a};case"yesterday":return{startDate:t.subDays(o,1),endDate:t.subDays(a,1)};case"last7days":return{startDate:t.subDays(o,6),endDate:a};case"thisWeekSunToday":return{startDate:t.startOfWeek(o,{weekStartsOn:0}),endDate:a};case"thisWeekMonToday":return{startDate:t.startOfWeek(o,{weekStartsOn:1}),endDate:a};case"lastWeekSunSat":const i=t.subDays(t.startOfWeek(o,{weekStartsOn:0}),7);return{startDate:i,endDate:t.endOfWeek(i,{weekStartsOn:0})};case"lastWeekMonSun":const c=t.subDays(t.startOfWeek(o,{weekStartsOn:1}),7);return{startDate:c,endDate:t.endOfWeek(c,{weekStartsOn:1})};case"last28Days":return{startDate:t.subDays(o,27),endDate:a};case"last30days":return{startDate:t.subDays(o,29),endDate:a};case"thisMonth":return{startDate:t.startOfMonth(o),endDate:t.endOfMonth(o)};case"lastMonth":const v=t.subMonths(o,1);return{startDate:t.startOfMonth(v),endDate:t.endOfMonth(v)};case"ytd":return{startDate:t.startOfYear(o),endDate:a};default:return{startDate:o,endDate:a}}},ce=[{label:"Today",value:"today"},{label:"Yesterday",value:"yesterday"},{label:"This week",value:"__group_thisWeek",children:[{label:"Sun – Today",value:"thisWeekSunToday"},{label:"Mon – Today",value:"thisWeekMonToday"}]},{label:"Last 7 days",value:"last7days"},{label:"Last week",value:"__group_lastWeek",children:[{label:"Sun – Sat",value:"lastWeekSunSat"},{label:"Mon – Sun",value:"lastWeekMonSun"}]},{label:"Last 28 days",value:"last28Days"},{label:"Last 30 days",value:"last30days"},{label:"This month",value:"thisMonth"},{label:"Last month",value:"lastMonth"},{label:"Year to Date",value:"ytd"},{label:"Custom",value:"custom"}],Te=({initialRange:n,initialCompareRange:o,presets:a=ce,onApply:p,onCancel:i,enableCompare:c=!1,activeCompareMode:v="previousPeriod",primaryColor:w="#3b82f6",compareColor:C="#f97316",minDate:G,maxDate:M,weekStartsOn:L,disabledDates:I,disableFuture:P,disablePast:Z,locale:z,labels:k,classNames:g})=>{const[E,U]=h.useState(n==null?void 0:n.startDate),[l,S]=h.useState(n==null?void 0:n.endDate),[Y,Q]=h.useState(null),[x,D]=h.useState(!1),[m,$]=h.useState(c),[f,R]=h.useState(v);h.useEffect(()=>{$(c)},[c]),h.useEffect(()=>{R(v)},[v]);const[A,_]=h.useState("primary");h.useEffect(()=>{_(m&&f==="custom"?"compare":"primary")},[m,f]);const[O,W]=h.useState(o==null?void 0:o.startDate),[T,B]=h.useState(o==null?void 0:o.endDate),[V,e]=h.useState(""),[s,d]=h.useState(()=>{const b=(n==null?void 0:n.endDate)||new Date;return t.subMonths(t.startOfMonth(b),1)}),[y,J]=h.useState(!0);h.useEffect(()=>{if(m&&!x&&E&&l&&f!=="custom"){let b;f==="previousPeriod"?b=ge(E,l):f==="previousPeriodMatchDay"?b=me(E,l):f==="samePeriodLastYear"&&(b=ke(E,l)),b&&(W(b.compareStart),B(b.compareEnd))}},[E,l,m,f,x]);const K=b=>{G&&t.isBefore(b,G)||M&&t.isBefore(M,b)||(x?(A==="compare"?O&&t.isBefore(b,O)?(W(b),B(O)):B(b):E&&t.isBefore(b,E)?(U(b),S(E)):S(b),D(!1)):(e("custom"),A==="compare"?(W(b),B(void 0)):(U(b),S(void 0)),D(!0)))},u=b=>{x&&Q(b)},j=b=>{if(b.startsWith("__group_"))return;const fe=(Oe,he)=>{for(const se of Oe){if(se.value===he)return se;if(se.children){const xe=fe(se.children,he);if(xe)return xe}}},oe=fe(a,b);e(b);let ee;oe!=null&&oe.range?ee=oe.range():ee=De(b),U(ee.startDate),S(ee.endDate),D(!1),_("primary"),d(t.subMonths(t.startOfMonth(ee.endDate),1))},H=()=>d(t.subMonths(s,1)),N=()=>d(t.addMonths(s,1)),ne=()=>{E&&l&&p({startDate:E,endDate:l},m&&O&&T?{startDate:O,endDate:T}:void 0,m?f:void 0)},de=b=>r.jsx(Se,{month:b,startDate:E,endDate:l,compareStartDate:m?O:void 0,compareEndDate:m?T:void 0,hoverDate:Y,onDateClick:K,onDateHover:u,selecting:x,anchorDate:x?A==="primary"?E:O:void 0,selectionVariant:A,minDate:G,maxDate:M,weekStartsOn:L,disabledDates:I,disableFuture:P,disablePast:Z,locale:z,classNames:g,primaryColor:w,compareColor:C});return r.jsxs("div",{className:`flex bg-white h-[450px] ${(g==null?void 0:g.root)||""}`,children:[r.jsxs("div",{className:`bg-gray-50/50 border-r border-gray-100 flex flex-col h-full shrink-0 transition-all duration-300 overflow-hidden ${y?"w-48 opacity-100":"w-0 opacity-0 border-none"} ${(g==null?void 0:g.sidebar)||""}`,children:[r.jsx("div",{className:"flex-1 overflow-y-auto preset-scrollbar min-w-[12rem]",children:r.jsx(je,{presets:a,onSelect:j,activePreset:V,primaryColor:w,classNames:g})}),r.jsx("div",{className:"p-3 border-t border-gray-200 bg-gray-50/80 backdrop-blur-sm min-w-[12rem]",children:r.jsx(Ee,{enabled:m,mode:f,onToggle:$,onModeChange:R,primaryColor:w,compareColor:C})})]}),r.jsxs("div",{className:"flex flex-col flex-1 h-full overflow-hidden",children:[r.jsxs("div",{className:"flex justify-between items-center px-4 py-2 border-b border-gray-100 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{className:"p-1.5 rounded-md hover:bg-gray-100 text-gray-500 hover:text-gray-900 transition-colors cursor-pointer",onClick:()=>J(!y),title:y?"Hide sidebar":"Show sidebar",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M4 6h16M4 12h16M4 18h16"})})}),r.jsx("button",{className:"p-1.5 rounded-full hover:bg-gray-100 text-gray-500 hover:text-gray-900 transition-colors cursor-pointer",onClick:H,children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 19l-7-7 7-7"})})})]}),r.jsxs("div",{className:"text-xs font-medium text-gray-500 flex flex-col items-center",children:[E&&l?r.jsxs("span",{children:[t.format(E,"MMM d, yyyy",{locale:z})," - ",t.format(l,"MMM d, yyyy",{locale:z})]}):r.jsx("span",{children:(k==null?void 0:k.selectDateRange)||"Select date range"}),m&&O&&T&&r.jsxs("span",{className:"text-[10px] font-medium",style:{color:C},children:[(k==null?void 0:k.vs)||"vs"," ",t.format(O,"MMM d, yyyy",{locale:z})," - ",t.format(T,"MMM d, yyyy",{locale:z})]})]}),r.jsx("button",{className:"p-1.5 rounded-full hover:bg-gray-100 text-gray-500 hover:text-gray-900 transition-colors cursor-pointer",onClick:N,children:r.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 5l7 7-7 7"})})})]}),r.jsxs("div",{className:`flex flex-col gap-4 p-4 overflow-y-auto flex-1 items-center ${(g==null?void 0:g.container)||""}`,children:[de(s),de(t.addMonths(s,1))]}),r.jsxs("div",{className:`px-4 py-3 border-t border-gray-100 flex items-center justify-between shrink-0 bg-white ${(g==null?void 0:g.footer)||""}`,children:[r.jsx("button",{className:"text-xs font-medium text-gray-500 hover:text-gray-700 underline decoration-gray-300 hover:decoration-gray-500 underline-offset-2 transition-colors cursor-pointer",onClick:()=>{U(void 0),S(void 0),D(!1),e(""),$(!1)},children:(k==null?void 0:k.clear)||"Reset"}),r.jsxs("div",{className:"flex gap-3",children:[r.jsx("button",{className:`px-3 py-1.5 rounded-md border border-gray-300 bg-white text-xs font-medium text-gray-700 hover:bg-gray-50 transition-colors cursor-pointer ${(g==null?void 0:g.buttonCancel)||""}`,onClick:i,children:(k==null?void 0:k.cancel)||"Cancel"}),r.jsx("button",{className:`px-3 py-1.5 rounded-md border border-transparent text-xs font-medium text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed shadow-sm cursor-pointer ${(g==null?void 0:g.buttonApply)||""}`,style:{backgroundColor:w},onClick:ne,disabled:!E||!l,children:(k==null?void 0:k.apply)||"Apply"})]})]})]})]})},_e=({value:n,defaultValue:o,onChange:a,onApply:p,onCancel:i,presets:c,primaryColor:v,compareColor:w,enableCompare:C=!1,showCompareToggle:G=!1,compareMode:M="previousPeriod",className:L,style:I,minDate:P,maxDate:Z,weekStartsOn:z,disabledDates:k,disableFuture:g,disablePast:E,locale:U,labels:l,classNames:S})=>{const[Y,Q]=h.useState(!1),[x,D]=h.useState(n||o||{startDate:new Date,endDate:new Date}),[m,$]=h.useState(),[f,R]=h.useState(C),[A,_]=h.useState(M),[O,W]=h.useState({top:0,left:0}),T=h.useRef(null),B=h.useRef(null);h.useEffect(()=>{n&&D(n)},[n]),h.useEffect(()=>{R(C)},[C]),h.useEffect(()=>{_(M)},[M]);const V=()=>{if(!T.current)return;const u=T.current.getBoundingClientRect();W({top:u.bottom+window.scrollY+4,left:u.left+window.scrollX})},e=()=>{Y||V(),Q(u=>!u)};h.useEffect(()=>{if(!Y)return;const u=()=>V();return window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[Y]),h.useEffect(()=>{if(!Y)return;const u=j=>{var N,ne;const H=j.target;(N=T.current)!=null&&N.contains(H)||(ne=B.current)!=null&&ne.contains(H)||(Q(!1),i==null||i())};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[Y,i]);const s=(u,j,H)=>{D(u),$(j),R(!!j),H&&_(H),Q(!1),a==null||a({startDate:u.startDate,endDate:u.endDate,compareStartDate:j==null?void 0:j.startDate,compareEndDate:j==null?void 0:j.endDate}),p==null||p(u,j)},d=()=>{Q(!1),i==null||i()},y=u=>{u.stopPropagation();const j=!f;R(j),p==null||p(x,j?m:void 0)},J=u=>t.format(u,"MMM d, yyyy",{locale:U}),K=`${J(x.startDate)} - ${J(x.endDate)}`;return r.jsxs("div",{ref:T,className:`relative inline-block text-left sdc-root ${L||""} ${(S==null?void 0:S.root)||""}`,style:{"--sdc-primary-color":v,"--sdc-compare-color":w,...I},children:[r.jsxs("button",{className:`flex items-center justify-between min-w-[240px] px-3 py-2 bg-white border border-gray-300 rounded hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all shadow-sm ${(S==null?void 0:S.container)||""}`,onClick:e,type:"button","aria-haspopup":"dialog","aria-expanded":Y,children:[r.jsxs("div",{className:"flex items-center gap-3 text-gray-700",children:[G&&r.jsx("div",{className:"relative inline-flex h-4 w-7 shrink-0 cursor-pointer rounded-full border border-transparent transition-colors duration-200 ease-in-out",style:{backgroundColor:f?v:"#d1d5db"},onClick:y,title:"Toggle comparison",children:r.jsx("span",{"aria-hidden":"true",className:`pointer-events-none inline-block h-3 w-3 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ${f?"translate-x-3":"translate-x-0"}`})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-gray-400",children:r.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),r.jsx("span",{className:"text-sm font-medium",children:K})]})]}),m&&r.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded ml-2 font-medium ${(S==null?void 0:S.dayCompare)||""}`,style:{color:w,backgroundColor:`${w}18`},children:["vs ",J(m.startDate)]}),r.jsx("svg",{className:`w-4 h-4 text-gray-400 transition-transform ${Y?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 9l-7 7-7-7"})})]}),Y&&pe.createPortal(r.jsx("div",{ref:B,style:{position:"absolute",top:O.top,left:O.left,zIndex:99999},role:"dialog","aria-modal":"true",children:r.jsx("div",{className:`bg-white ring-1 ring-black ring-opacity-5 rounded-lg shadow-2xl overflow-hidden sdc-root ${(S==null?void 0:S.calendar)||""}`,style:{"--sdc-primary-color":v,"--sdc-compare-color":w},children:r.jsx(Te,{initialRange:x,initialCompareRange:m,presets:c,onApply:s,onCancel:d,enableCompare:f,activeCompareMode:A,primaryColor:v,compareColor:w,minDate:P,maxDate:Z,weekStartsOn:z,disabledDates:k,disableFuture:g,disablePast:E,locale:U,labels:l,classNames:S})})}),document.body)]})};X.SmartDateCompare=_e,X.defaultPresets=ce,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/type.d.ts
CHANGED
package/dist/type.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/lib/type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACjB,gBAAgB,GAChB,wBAAwB,GACxB,oBAAoB,GACpB,QAAQ,CAAC;AAEf,MAAM,WAAW,SAAS;IACtB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,SAAS,CAAC;IACxB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IAClC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE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,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,UAAU,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IAEF,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,YAAY,CAAC;IAC7D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;IAGtE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IAC/D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-smart-date-compare",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A highly customizable React date range picker with advanced comparison modes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/react-smart-date-compare.umd.js",
|
|
@@ -20,14 +20,18 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"dev": "vite",
|
|
22
22
|
"build": "vite build && tsc -b tsconfig.build.json",
|
|
23
|
+
"build:docs": "vite build --config vite.docs.config.ts",
|
|
24
|
+
"build:docs:local": "cross-env BUILD_TARGET=local vite build --config vite.docs.config.ts",
|
|
25
|
+
"serve:docs": "npm run build:docs:local && npx serve docs-dist",
|
|
26
|
+
"preview:docs": "vite preview --config vite.docs.config.ts",
|
|
23
27
|
"lint": "eslint .",
|
|
24
28
|
"preview": "vite preview",
|
|
25
29
|
"prepublishOnly": "npm run build"
|
|
26
30
|
},
|
|
27
31
|
"peerDependencies": {
|
|
32
|
+
"date-fns": "^4.1.0",
|
|
28
33
|
"react": "^19.2.0",
|
|
29
|
-
"react-dom": "^19.2.0"
|
|
30
|
-
"date-fns": "^4.1.0"
|
|
34
|
+
"react-dom": "^19.2.0"
|
|
31
35
|
},
|
|
32
36
|
"devDependencies": {
|
|
33
37
|
"@eslint/js": "^9.39.1",
|
|
@@ -38,6 +42,7 @@
|
|
|
38
42
|
"@types/react-dom": "^19.2.3",
|
|
39
43
|
"@vitejs/plugin-react": "^4.3.4",
|
|
40
44
|
"autoprefixer": "^10.4.24",
|
|
45
|
+
"cross-env": "^10.1.0",
|
|
41
46
|
"date-fns": "^4.1.0",
|
|
42
47
|
"eslint": "^9.39.1",
|
|
43
48
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
@@ -66,4 +71,4 @@
|
|
|
66
71
|
"type": "git",
|
|
67
72
|
"url": "git+https://github.com/POTUMANOJKUMAR/react-smart-date-compare.git"
|
|
68
73
|
}
|
|
69
|
-
}
|
|
74
|
+
}
|