Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-availability-calendar

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-availability-calendar - npm Package Compare versions

Comparing version 0.2.3 to 0.2.5

2

dist/react-availability-calendar.cjs.development.js

@@ -100,3 +100,3 @@ 'use strict';

var shifted = ranges.map(function (r) {
return [(r[0] + ms) % msInDay, (r[1] + ms) % msInDay];
return [(r[0] - ms) % msInDay, (r[1] - ms) % msInDay];
}); // if the new "midnight" happens in the middle of a range, break it into 2

@@ -103,0 +103,0 @@

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}function r(e){function t(e){return e.endDate.getTime()-e.startDate.getTime()}function a(t,a){return n(e(t).startOf("week").toDate(),e(a).startOf("week").toDate())}function n(e,t){return e&&t&&e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function r(e,t,a,n,r){0===e.length&&(e=[[8634e4,864e5]]);for(var o=function(e,t){var a=e.map((function(e){return[(e[0]+t)%864e5,(e[1]+t)%864e5]})),n=a.map((function(e,t){return e[1]<e[0]?t:-1})).filter((function(e){return e>=0})),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var l;if(r){if(o>=n.length)break;l=n[o++]}else{if((o=n.next()).done)break;l=o.value}var s=a[l];a[l]=[-1,-1],a.push([s[0],864e5]),a.push([0,s[1]])}var i=a.filter((function(e){return e[0]>=0}));return i.sort((function(e,t){return e[0]-t[0]})),i}(e,function(e){if(!e)return 0;var t=new Date,a=new Date(t.toLocaleString("en-US",{timeZone:e}));return 36e5*Math.floor((a.getTime()-t.getTime())/36e5+.5)}(t)),l=[].concat(a),s=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=s;u<=i;u+=864e5){var m=o,d=Array.isArray(m),c=0;for(m=d?m:m[Symbol.iterator]();;){var f;if(d){if(c>=m.length)break;f=m[c++]}else{if((c=m.next()).done)break;f=c.value}var v=f,h=Math.floor(v[0]/36e5),y=Math.floor(v[1]/36e5),D=Math.floor(v[0]/6e4)%60,g=Math.floor(v[1]/6e4)%60,b=new Date(u);l.push({startDate:new Date(b.getFullYear(),b.getMonth(),b.getDate(),h,D),endDate:new Date(b.getFullYear(),b.getMonth(),b.getDate(),y,g),isBlockout:!0})}}return l}return{msInHour:36e5,datesEqual:n,formatAsMonth:function(t){return e(t).format("MMM YYYY")},formatAsDateWithTime:function(t){return e(t).format("ddd, MMM Do h:mma")},formatAsDateJustTime:function(t){return e(t).format("h:mma")},formatAsDate:function(t){return e(t).format("ddd, MMM Do YYYY")},shouldHideWeek:function(e,t,n){return e&&!a(e,t[0])&&n.length>0},shouldShowWeek:function(e,t,n){return!!e&&a(e,t[0])&&n.length>0},availByIndex:function(e,t){return(e||[]).map((function(e){return{hasAvail:t.some((function(t){return n(t.startDate,e)}))}}))},addBlockOutBookings:r,availabilitiesFromBookings:function(e,t,a,n,o,l){var s,i=Math.max((s=n.getTime(),36e5*Math.floor(s/36e5)+36e5),o.getTime()),u=new Date(i);if(l.getTime()<=u.getTime())return[];var m=[{startDate:u,endDate:l}],d=r(e,t,a,u,l).sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()})),c=Array.isArray(d),f=0;for(d=c?d:d[Symbol.iterator]();;){var v;if(c){if(f>=d.length)break;v=d[f++]}else{if((f=d.next()).done)break;v=f.value}var h=v,y=m[m.length-1],D=h.startDate.getTime(),g=h.endDate.getTime();if(h.startDate&&h.endDate&&!(D>=g))if(D<y.startDate.getTime())y.startDate=new Date(Math.max(y.startDate.getTime(),g));else if(D<y.endDate.getTime()){var b=y.endDate;y.endDate=new Date(D),g<b.getTime()&&m.push({startDate:new Date(g),endDate:b})}}return m},toStartAndEnd:function(e){var t={startDate:e.start||e[0],endDate:e.end||e[e.length-1]};return t.startDate.getTime()===t.endDate.getTime()&&(t.endDate=new Date(t.endDate.getTime()+864e5)),t},monthRangeForDate:function(t){return{start:e(t).startOf("month").toDate(),end:e(t).endOf("month").toDate()}},monthDaysForDate:function(t){for(var a=e(t).startOf("month"),n=e(t).endOf("month"),r=a.startOf("week"),o=n.endOf("week").diff(r,"days")+1,l=[],s=[],i=r,u=Math.floor(o/7),m=0;m<u;++m){var d=[];l.push(d);for(var c=0;c<7;++c)d.push(i.toDate()),s.push(i.toDate()),i.add(1,"day")}return{weeks:l,days:s}},chunkify:function(e,a,n){var r=[],o=e,l=Array.isArray(o),s=0;for(o=l?o:o[Symbol.iterator]();;){var i;if(l){if(s>=o.length)break;i=o[s++]}else{if((s=o.next()).done)break;i=s.value}for(var u=i,m=u.endDate.getTime(),d=u.startDate.getTime();d<m;d+=n){var c=d,f={startDate:new Date(c),endDate:new Date(Math.min(m,c+a))};t(f)>=a&&r.push(f)}}return r}}}var o={dayClassBase:"rounded-circle",dayClassSelected:"border-primary",dayClassHasAvailability:"border-info",dayClassDefault:"border border-default",slotsContainerStyleShow:{transition:"transform 300ms",transform:"scale(1)"},slotsContainerStyleHide:{transition:"transform 300ms",transform:"scale(0)"},slotContainerCloseClass:"close",slotButtonClass:"btn btn-primary",toolBarStyle:{flexWrap:"nowrap",width:350,minHeight:50},toolBarButtonsContainerClass:"border btn-group w-100",toolBarButtonClass:"btn",toolBarLabelClass:"btn btn-link",requestAppointmentLabel:"Request Appointment"},l={format:function(e){throw new Error("not implemented")},startOf:function(e){throw new Error("not implemented")},endOf:function(e){throw new Error("not implemented")},add:function(e,t){throw new Error("not implemented")},diff:function(e,t,a){throw new Error("not implemented")},toDate:function(){throw new Error("not implemented")}},s=a.createContext({moment:function(){return l},utils:r((function(){return l})),theme:o}),i=function(){return t.useContext(s)},u=function(e){var n=e.moment,o=e.theme,l=e.children,i=t.useMemo((function(){return r(n)}),[n]);return a.createElement(s.Provider,{value:{moment:n,utils:i,theme:o}},l)};function m(e,t){return"function"==typeof e?t?e(t):e():e}function d(e,t,a,r,o,l){return void 0===e?{Root:t.Root,className:t.className,style:n({},m(t.style,a)),internalProps:t.internalProps}:{Root:t.Root||e.Root,className:t.className||e.className,style:n({},m(t.style,a),{},m(e.style,a)),internalProps:n({},t.internalProps,{},e.internalProps)}}var c=function(e){var t=e.localizer.messages,n=e.label,r=e.onNavigate,o=e.overrides,l=i().theme,s=function(e,t){return d(e?e.ToolBar:void 0,t,{})}(o,{style:l.toolBarStyle,className:l.toolBarButtonsContainerClass}),u=s.Root,m=s.style,c=s.className;return u?a.createElement(u,Object.assign({},{localizer:{messages:t},label:n,onNavigate:r})):a.createElement("div",{style:m},a.createElement("div",{className:c,role:"group"},a.createElement(f,{theme:l,overrides:o,onClick:function(){return r("TODAY")},message:t.today}),a.createElement(f,{theme:l,overrides:o,onClick:function(){return r("PREV")},message:t.previous}),a.createElement(f,{theme:l,overrides:o,onClick:function(){return r("NEXT")},message:t.next}),a.createElement("button",{disabled:!0,className:l.toolBarLabelClass,style:{width:110}},a.createElement("span",null,n))))};function f(e){var t,n=e.message,r=e.onClick,o=d((t=e.overrides)?t.ToolBarButton:void 0,{className:e.theme.toolBarButtonClass},{}),l=o.Root,s=o.internalProps,i=o.className;return void 0!==l?a.createElement(l,{message:n,onClicked:r}):a.createElement("button",Object.assign({className:i,onClick:r},s),n)}var v=["S","M","T","W","Th","F","Sa"],h=function(e){var t,n=d((t=e.overrides)?t.Weekdays:void 0,{style:{display:"flex",justifyContent:"flex-start",flexWrap:"nowrap",flexDirection:"row"}},{}),r=n.Root,o=n.style;return r?a.createElement(r,null):a.createElement("div",{style:o},v.map((function(e){return a.createElement("div",{className:"border border-default",key:e,style:{height:50,width:50,marginBottom:10,display:"flex",justifyContent:"center",alignItems:"center"}},e)})))};function y(e){var t,n=e.theme,r=e.onAvailabilitySelected,o=e.s,l=e.formatAsDateJustTime,s=d((t=e.overrides)?t.AvailSlot:void 0,{style:{marginBottom:10}},{}),i=s.Root,u=s.style;return i?a.createElement(i,Object.assign({},{theme:n,onAvailabilitySelected:r,s:o,formatAsDateJustTime:l})):a.createElement("div",{style:u},a.createElement("button",{className:n.slotButtonClass,disabled:!1,style:{minWidth:200},onClick:function(){return r({startDate:new Date(o.startDate),endDate:new Date(o.endDate)})}},l(new Date(o.startDate))))}var D=function(e){var t=e.viewingDayAvailabilities,n=e.handleUnselect,r=e.onAvailabilitySelected,o=e.show,l=e.slotStepMs,s=e.slotLengthMs,i=e.utils,u=e.theme,m=e.overrides,c=function(e,t){return d(e?e.Availabilities:void 0,t,{})}(m,{style:o?u.slotsContainerStyleShow:u.slotsContainerStyleHide}),f=c.Root,v=c.style;return f?a.createElement(f,Object.assign({},{viewingDayAvailabilities:t,handleUnselect:n,onAvailabilitySelected:r,show:o,slotStepMs:l,slotLengthMs:s,utils:i,theme:u})):a.createElement("div",{style:v},o&&a.createElement("div",{className:"mt-2 mr-1"},a.createElement("button",{type:"button",className:u.slotContainerCloseClass,"aria-label":"Close",style:{outline:"none"},onClick:n},a.createElement("span",{"aria-hidden":"true"},"×")),a.createElement(g,{theme:u,durationMinutes:60,avails:t,onAvailabilitySelected:r,slotLengthMs:s,slotStepMs:l,utils:i,overrides:m})))},g=function(e){var n=e.avails,r=e.slotLengthMs,o=e.slotStepMs,l=e.onAvailabilitySelected,s=e.theme,i=e.utils,u=e.overrides,m=i.chunkify,d=i.msInHour,c=i.formatAsDate,f=i.formatAsDateJustTime,v=t.useMemo((function(){return m(n.map((function(e){return{startDate:e.startDate,endDate:e.endDate}})),r||1*d,o||.5*d)}),[n,d,m,r,o]);return a.createElement("div",null,a.createElement("h4",null,s.requestAppointmentLabel),a.createElement("h5",null,n&&n.length>0?c(n[0].startDate):""),v.map((function(e,t){return a.createElement(y,Object.assign({key:"b_"+t},{theme:s,onAvailabilitySelected:l,s:e,formatAsDateJustTime:f,overrides:u}))})))},b=function(e){var t=e.date,n=e.dayIndexInWeek,r=e.weekIndexInCalRange,o=e.availsByIndex,l=e.selectedDate,s=e.handleSelected,i=e.moment,u=e.utils,m=e.theme,c=e.overrides,f=7*r+n,v=!!l&&u.datesEqual(t,l),h=o[f].hasAvail,y=function(e,t,a){return d(e?e.DayCell:void 0,t,a)}(c,{style:{cursor:"pointer",border:l&&u.datesEqual(t,l)?"4px solid":o[f].hasAvail?"3px solid":"",height:50,width:50,display:"flex",justifyContent:"center",alignItems:"center"}},{isSelected:v,isToday:!1,hasAvail:h}),D=y.Root,g=y.style;return D?a.createElement(D,Object.assign({},{date:t,dayIndexInWeek:n,weekIndexInCalRange:r,availsByIndex:o,selectedDate:l,handleSelected:s,moment:i,utils:u,theme:m})):a.createElement("div",{className:m.dayClassBase+" "+(l&&u.datesEqual(t,l)?m.dayClassSelected:o[f].hasAvail?m.dayClassHasAvailability:m.dayClassDefault),style:g,onClick:function(){return s(t)}},i(t).format("D"))};function p(e){var t=e.week,n=e.selectedDate,r=e.weekIndexInCalRange,o=e.handleSelected,l=e.availsByIndex,s=e.moment,i=e.utils,u=e.theme,m=e.overrides,c=function(e,t){return d(e?e.DayCells:void 0,{style:{display:"flex",justifyContent:"flex-start",flexWrap:"nowrap",flexDirection:"row"}},{})}(m),f=c.Root,v=c.style;return f?a.createElement(f,Object.assign({},{week:t,selectedDate:n,weekIndexInCalRange:r,handleSelected:o,availsByIndex:l,moment:s,utils:i,theme:u})):a.createElement("div",{style:v},t.map((function(e,t){return a.createElement(b,Object.assign({key:"d_"+t},{date:e,selectedDate:n,weekIndexInCalRange:r,dayIndexInWeek:t,handleSelected:o,availsByIndex:l,moment:s,utils:i,theme:u,overrides:m}))})))}var w=function(e){var r=e.availabilities,o=e.onAvailabilitySelected,l=e.slotLengthMs,s=e.slotStepMs,u=e.date,m=e.style,d=e.overrides,c=i(),f=c.moment,v=c.theme,y=c.utils,g=t.useState(null),b=g[0],w=g[1];t.useEffect((function(){w(null)}),[u]);var E=function(e){b&&y.datesEqual(e,b)?w(null):w(e)},C=function(){w(null)},k=t.useMemo((function(){return y.monthDaysForDate(u)}),[u,y]),S=k.days,M=k.weeks,A=t.useMemo((function(){return y.availByIndex(S,r)}),[S,r,y]),x=t.useMemo((function(){return null!==b?(r||[]).filter((function(e){return y.datesEqual(e.startDate,b)})):[]}),[b,r,y]);return a.createElement("div",{style:n({minHeight:368},m)},a.createElement(h,{overrides:d}),M.map((function(e,t){var n=y.shouldShowWeek(b,e,x);return y.shouldHideWeek(b,e,x)?null:a.createElement(a.Fragment,{key:"w_"+t},a.createElement(p,Object.assign({},{week:e,selectedDate:b,weekIndexInCalRange:t,handleSelected:E,availsByIndex:A,moment:f,utils:y,theme:v,overrides:d})),a.createElement(D,Object.assign({},{show:n,onAvailabilitySelected:o,viewingDayAvailabilities:x,handleUnselect:C,slotLengthMs:l,slotStepMs:s,utils:y,theme:v,overrides:d})))})))},E=function(e){var n=e.initialDate,r=e.onAvailabilitySelected,o=e.blockOutPeriods,l=e.providerTimeZone,s=e.bookings,u=e.onCalRangeChange,m=e.slotLengthMs,d=e.slotStepMs,f=e.overrides,v=i(),h=v.moment,y=v.utils,D=t.useState(n||new Date)[0],g=t.useState(y.monthRangeForDate(D)),b=g[0],p=g[1],E=t.useState(D),C=E[0],k=E[1],S=t.useRef(null);t.useEffect((function(){S.current!==b&&(u&&u(b),S.current=b)}),[b,u]);var M=t.useMemo((function(){var e=y.toStartAndEnd(b);return y.availabilitiesFromBookings(o||[],l,s,D,e.startDate,e.endDate)}),[s,l,b,D,o,y]);return a.createElement("div",null,a.createElement(c,{onNavigate:function(e){if("TODAY"===e){var t=new Date;return k(t),void p(y.monthRangeForDate(t))}if("NEXT"===e||"PREV"===e){var a=h(C).add("NEXT"===e?1:-1,"month").toDate();k(a),p(y.monthRangeForDate(a))}},label:y.formatAsMonth(C),localizer:{messages:{today:"Today",previous:"Previous",next:"Next"}},overrides:f}),a.createElement(w,{availabilities:M,date:C,onAvailabilitySelected:r,slotLengthMs:m,slotStepMs:d,overrides:f}))};exports.AvailabilityCalendar=function(e){var t=e.moment,r=e.theme,l=function(e,t){if(null==e)return{};var a,n,r={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(a=o[n])>=0||(r[a]=e[a]);return r}(e,["moment","theme"]);return a.createElement(u,{moment:t,theme:r?n({},o,{},r):o},a.createElement(E,Object.assign({},l)))},exports.createUtils=r,exports.defaultComponents={ToolBar:{},ToolBarButton:{},Weekdays:{},DayCells:{},DayCell:{},Availabilities:{},AvailSlot:{}},exports.defaultTheme=o;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),a=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e}).apply(this,arguments)}function r(e){function t(e){return e.endDate.getTime()-e.startDate.getTime()}function a(t,a){return n(e(t).startOf("week").toDate(),e(a).startOf("week").toDate())}function n(e,t){return e&&t&&e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function r(e,t,a,n,r){0===e.length&&(e=[[8634e4,864e5]]);for(var o=function(e,t){var a=e.map((function(e){return[(e[0]-t)%864e5,(e[1]-t)%864e5]})),n=a.map((function(e,t){return e[1]<e[0]?t:-1})).filter((function(e){return e>=0})),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var l;if(r){if(o>=n.length)break;l=n[o++]}else{if((o=n.next()).done)break;l=o.value}var s=a[l];a[l]=[-1,-1],a.push([s[0],864e5]),a.push([0,s[1]])}var i=a.filter((function(e){return e[0]>=0}));return i.sort((function(e,t){return e[0]-t[0]})),i}(e,function(e){if(!e)return 0;var t=new Date,a=new Date(t.toLocaleString("en-US",{timeZone:e}));return 36e5*Math.floor((a.getTime()-t.getTime())/36e5+.5)}(t)),l=[].concat(a),s=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=s;u<=i;u+=864e5){var m=o,d=Array.isArray(m),c=0;for(m=d?m:m[Symbol.iterator]();;){var f;if(d){if(c>=m.length)break;f=m[c++]}else{if((c=m.next()).done)break;f=c.value}var v=f,h=Math.floor(v[0]/36e5),y=Math.floor(v[1]/36e5),D=Math.floor(v[0]/6e4)%60,g=Math.floor(v[1]/6e4)%60,b=new Date(u);l.push({startDate:new Date(b.getFullYear(),b.getMonth(),b.getDate(),h,D),endDate:new Date(b.getFullYear(),b.getMonth(),b.getDate(),y,g),isBlockout:!0})}}return l}return{msInHour:36e5,datesEqual:n,formatAsMonth:function(t){return e(t).format("MMM YYYY")},formatAsDateWithTime:function(t){return e(t).format("ddd, MMM Do h:mma")},formatAsDateJustTime:function(t){return e(t).format("h:mma")},formatAsDate:function(t){return e(t).format("ddd, MMM Do YYYY")},shouldHideWeek:function(e,t,n){return e&&!a(e,t[0])&&n.length>0},shouldShowWeek:function(e,t,n){return!!e&&a(e,t[0])&&n.length>0},availByIndex:function(e,t){return(e||[]).map((function(e){return{hasAvail:t.some((function(t){return n(t.startDate,e)}))}}))},addBlockOutBookings:r,availabilitiesFromBookings:function(e,t,a,n,o,l){var s,i=Math.max((s=n.getTime(),36e5*Math.floor(s/36e5)+36e5),o.getTime()),u=new Date(i);if(l.getTime()<=u.getTime())return[];var m=[{startDate:u,endDate:l}],d=r(e,t,a,u,l).sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()})),c=Array.isArray(d),f=0;for(d=c?d:d[Symbol.iterator]();;){var v;if(c){if(f>=d.length)break;v=d[f++]}else{if((f=d.next()).done)break;v=f.value}var h=v,y=m[m.length-1],D=h.startDate.getTime(),g=h.endDate.getTime();if(h.startDate&&h.endDate&&!(D>=g))if(D<y.startDate.getTime())y.startDate=new Date(Math.max(y.startDate.getTime(),g));else if(D<y.endDate.getTime()){var b=y.endDate;y.endDate=new Date(D),g<b.getTime()&&m.push({startDate:new Date(g),endDate:b})}}return m},toStartAndEnd:function(e){var t={startDate:e.start||e[0],endDate:e.end||e[e.length-1]};return t.startDate.getTime()===t.endDate.getTime()&&(t.endDate=new Date(t.endDate.getTime()+864e5)),t},monthRangeForDate:function(t){return{start:e(t).startOf("month").toDate(),end:e(t).endOf("month").toDate()}},monthDaysForDate:function(t){for(var a=e(t).startOf("month"),n=e(t).endOf("month"),r=a.startOf("week"),o=n.endOf("week").diff(r,"days")+1,l=[],s=[],i=r,u=Math.floor(o/7),m=0;m<u;++m){var d=[];l.push(d);for(var c=0;c<7;++c)d.push(i.toDate()),s.push(i.toDate()),i.add(1,"day")}return{weeks:l,days:s}},chunkify:function(e,a,n){var r=[],o=e,l=Array.isArray(o),s=0;for(o=l?o:o[Symbol.iterator]();;){var i;if(l){if(s>=o.length)break;i=o[s++]}else{if((s=o.next()).done)break;i=s.value}for(var u=i,m=u.endDate.getTime(),d=u.startDate.getTime();d<m;d+=n){var c=d,f={startDate:new Date(c),endDate:new Date(Math.min(m,c+a))};t(f)>=a&&r.push(f)}}return r}}}var o={dayClassBase:"rounded-circle",dayClassSelected:"border-primary",dayClassHasAvailability:"border-info",dayClassDefault:"border border-default",slotsContainerStyleShow:{transition:"transform 300ms",transform:"scale(1)"},slotsContainerStyleHide:{transition:"transform 300ms",transform:"scale(0)"},slotContainerCloseClass:"close",slotButtonClass:"btn btn-primary",toolBarStyle:{flexWrap:"nowrap",width:350,minHeight:50},toolBarButtonsContainerClass:"border btn-group w-100",toolBarButtonClass:"btn",toolBarLabelClass:"btn btn-link",requestAppointmentLabel:"Request Appointment"},l={format:function(e){throw new Error("not implemented")},startOf:function(e){throw new Error("not implemented")},endOf:function(e){throw new Error("not implemented")},add:function(e,t){throw new Error("not implemented")},diff:function(e,t,a){throw new Error("not implemented")},toDate:function(){throw new Error("not implemented")}},s=a.createContext({moment:function(){return l},utils:r((function(){return l})),theme:o}),i=function(){return t.useContext(s)},u=function(e){var n=e.moment,o=e.theme,l=e.children,i=t.useMemo((function(){return r(n)}),[n]);return a.createElement(s.Provider,{value:{moment:n,utils:i,theme:o}},l)};function m(e,t){return"function"==typeof e?t?e(t):e():e}function d(e,t,a,r,o,l){return void 0===e?{Root:t.Root,className:t.className,style:n({},m(t.style,a)),internalProps:t.internalProps}:{Root:t.Root||e.Root,className:t.className||e.className,style:n({},m(t.style,a),{},m(e.style,a)),internalProps:n({},t.internalProps,{},e.internalProps)}}var c=function(e){var t=e.localizer.messages,n=e.label,r=e.onNavigate,o=e.overrides,l=i().theme,s=function(e,t){return d(e?e.ToolBar:void 0,t,{})}(o,{style:l.toolBarStyle,className:l.toolBarButtonsContainerClass}),u=s.Root,m=s.style,c=s.className;return u?a.createElement(u,Object.assign({},{localizer:{messages:t},label:n,onNavigate:r})):a.createElement("div",{style:m},a.createElement("div",{className:c,role:"group"},a.createElement(f,{theme:l,overrides:o,onClick:function(){return r("TODAY")},message:t.today}),a.createElement(f,{theme:l,overrides:o,onClick:function(){return r("PREV")},message:t.previous}),a.createElement(f,{theme:l,overrides:o,onClick:function(){return r("NEXT")},message:t.next}),a.createElement("button",{disabled:!0,className:l.toolBarLabelClass,style:{width:110}},a.createElement("span",null,n))))};function f(e){var t,n=e.message,r=e.onClick,o=d((t=e.overrides)?t.ToolBarButton:void 0,{className:e.theme.toolBarButtonClass},{}),l=o.Root,s=o.internalProps,i=o.className;return void 0!==l?a.createElement(l,{message:n,onClicked:r}):a.createElement("button",Object.assign({className:i,onClick:r},s),n)}var v=["S","M","T","W","Th","F","Sa"],h=function(e){var t,n=d((t=e.overrides)?t.Weekdays:void 0,{style:{display:"flex",justifyContent:"flex-start",flexWrap:"nowrap",flexDirection:"row"}},{}),r=n.Root,o=n.style;return r?a.createElement(r,null):a.createElement("div",{style:o},v.map((function(e){return a.createElement("div",{className:"border border-default",key:e,style:{height:50,width:50,marginBottom:10,display:"flex",justifyContent:"center",alignItems:"center"}},e)})))};function y(e){var t,n=e.theme,r=e.onAvailabilitySelected,o=e.s,l=e.formatAsDateJustTime,s=d((t=e.overrides)?t.AvailSlot:void 0,{style:{marginBottom:10}},{}),i=s.Root,u=s.style;return i?a.createElement(i,Object.assign({},{theme:n,onAvailabilitySelected:r,s:o,formatAsDateJustTime:l})):a.createElement("div",{style:u},a.createElement("button",{className:n.slotButtonClass,disabled:!1,style:{minWidth:200},onClick:function(){return r({startDate:new Date(o.startDate),endDate:new Date(o.endDate)})}},l(new Date(o.startDate))))}var D=function(e){var t=e.viewingDayAvailabilities,n=e.handleUnselect,r=e.onAvailabilitySelected,o=e.show,l=e.slotStepMs,s=e.slotLengthMs,i=e.utils,u=e.theme,m=e.overrides,c=function(e,t){return d(e?e.Availabilities:void 0,t,{})}(m,{style:o?u.slotsContainerStyleShow:u.slotsContainerStyleHide}),f=c.Root,v=c.style;return f?a.createElement(f,Object.assign({},{viewingDayAvailabilities:t,handleUnselect:n,onAvailabilitySelected:r,show:o,slotStepMs:l,slotLengthMs:s,utils:i,theme:u})):a.createElement("div",{style:v},o&&a.createElement("div",{className:"mt-2 mr-1"},a.createElement("button",{type:"button",className:u.slotContainerCloseClass,"aria-label":"Close",style:{outline:"none"},onClick:n},a.createElement("span",{"aria-hidden":"true"},"×")),a.createElement(g,{theme:u,durationMinutes:60,avails:t,onAvailabilitySelected:r,slotLengthMs:s,slotStepMs:l,utils:i,overrides:m})))},g=function(e){var n=e.avails,r=e.slotLengthMs,o=e.slotStepMs,l=e.onAvailabilitySelected,s=e.theme,i=e.utils,u=e.overrides,m=i.chunkify,d=i.msInHour,c=i.formatAsDate,f=i.formatAsDateJustTime,v=t.useMemo((function(){return m(n.map((function(e){return{startDate:e.startDate,endDate:e.endDate}})),r||1*d,o||.5*d)}),[n,d,m,r,o]);return a.createElement("div",null,a.createElement("h4",null,s.requestAppointmentLabel),a.createElement("h5",null,n&&n.length>0?c(n[0].startDate):""),v.map((function(e,t){return a.createElement(y,Object.assign({key:"b_"+t},{theme:s,onAvailabilitySelected:l,s:e,formatAsDateJustTime:f,overrides:u}))})))},b=function(e){var t=e.date,n=e.dayIndexInWeek,r=e.weekIndexInCalRange,o=e.availsByIndex,l=e.selectedDate,s=e.handleSelected,i=e.moment,u=e.utils,m=e.theme,c=e.overrides,f=7*r+n,v=!!l&&u.datesEqual(t,l),h=o[f].hasAvail,y=function(e,t,a){return d(e?e.DayCell:void 0,t,a)}(c,{style:{cursor:"pointer",border:l&&u.datesEqual(t,l)?"4px solid":o[f].hasAvail?"3px solid":"",height:50,width:50,display:"flex",justifyContent:"center",alignItems:"center"}},{isSelected:v,isToday:!1,hasAvail:h}),D=y.Root,g=y.style;return D?a.createElement(D,Object.assign({},{date:t,dayIndexInWeek:n,weekIndexInCalRange:r,availsByIndex:o,selectedDate:l,handleSelected:s,moment:i,utils:u,theme:m})):a.createElement("div",{className:m.dayClassBase+" "+(l&&u.datesEqual(t,l)?m.dayClassSelected:o[f].hasAvail?m.dayClassHasAvailability:m.dayClassDefault),style:g,onClick:function(){return s(t)}},i(t).format("D"))};function p(e){var t=e.week,n=e.selectedDate,r=e.weekIndexInCalRange,o=e.handleSelected,l=e.availsByIndex,s=e.moment,i=e.utils,u=e.theme,m=e.overrides,c=function(e,t){return d(e?e.DayCells:void 0,{style:{display:"flex",justifyContent:"flex-start",flexWrap:"nowrap",flexDirection:"row"}},{})}(m),f=c.Root,v=c.style;return f?a.createElement(f,Object.assign({},{week:t,selectedDate:n,weekIndexInCalRange:r,handleSelected:o,availsByIndex:l,moment:s,utils:i,theme:u})):a.createElement("div",{style:v},t.map((function(e,t){return a.createElement(b,Object.assign({key:"d_"+t},{date:e,selectedDate:n,weekIndexInCalRange:r,dayIndexInWeek:t,handleSelected:o,availsByIndex:l,moment:s,utils:i,theme:u,overrides:m}))})))}var w=function(e){var r=e.availabilities,o=e.onAvailabilitySelected,l=e.slotLengthMs,s=e.slotStepMs,u=e.date,m=e.style,d=e.overrides,c=i(),f=c.moment,v=c.theme,y=c.utils,g=t.useState(null),b=g[0],w=g[1];t.useEffect((function(){w(null)}),[u]);var E=function(e){b&&y.datesEqual(e,b)?w(null):w(e)},C=function(){w(null)},k=t.useMemo((function(){return y.monthDaysForDate(u)}),[u,y]),S=k.days,M=k.weeks,A=t.useMemo((function(){return y.availByIndex(S,r)}),[S,r,y]),x=t.useMemo((function(){return null!==b?(r||[]).filter((function(e){return y.datesEqual(e.startDate,b)})):[]}),[b,r,y]);return a.createElement("div",{style:n({minHeight:368},m)},a.createElement(h,{overrides:d}),M.map((function(e,t){var n=y.shouldShowWeek(b,e,x);return y.shouldHideWeek(b,e,x)?null:a.createElement(a.Fragment,{key:"w_"+t},a.createElement(p,Object.assign({},{week:e,selectedDate:b,weekIndexInCalRange:t,handleSelected:E,availsByIndex:A,moment:f,utils:y,theme:v,overrides:d})),a.createElement(D,Object.assign({},{show:n,onAvailabilitySelected:o,viewingDayAvailabilities:x,handleUnselect:C,slotLengthMs:l,slotStepMs:s,utils:y,theme:v,overrides:d})))})))},E=function(e){var n=e.initialDate,r=e.onAvailabilitySelected,o=e.blockOutPeriods,l=e.providerTimeZone,s=e.bookings,u=e.onCalRangeChange,m=e.slotLengthMs,d=e.slotStepMs,f=e.overrides,v=i(),h=v.moment,y=v.utils,D=t.useState(n||new Date)[0],g=t.useState(y.monthRangeForDate(D)),b=g[0],p=g[1],E=t.useState(D),C=E[0],k=E[1],S=t.useRef(null);t.useEffect((function(){S.current!==b&&(u&&u(b),S.current=b)}),[b,u]);var M=t.useMemo((function(){var e=y.toStartAndEnd(b);return y.availabilitiesFromBookings(o||[],l,s,D,e.startDate,e.endDate)}),[s,l,b,D,o,y]);return a.createElement("div",null,a.createElement(c,{onNavigate:function(e){if("TODAY"===e){var t=new Date;return k(t),void p(y.monthRangeForDate(t))}if("NEXT"===e||"PREV"===e){var a=h(C).add("NEXT"===e?1:-1,"month").toDate();k(a),p(y.monthRangeForDate(a))}},label:y.formatAsMonth(C),localizer:{messages:{today:"Today",previous:"Previous",next:"Next"}},overrides:f}),a.createElement(w,{availabilities:M,date:C,onAvailabilitySelected:r,slotLengthMs:m,slotStepMs:d,overrides:f}))};exports.AvailabilityCalendar=function(e){var t=e.moment,r=e.theme,l=function(e,t){if(null==e)return{};var a,n,r={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(a=o[n])>=0||(r[a]=e[a]);return r}(e,["moment","theme"]);return a.createElement(u,{moment:t,theme:r?n({},o,{},r):o},a.createElement(E,Object.assign({},l)))},exports.createUtils=r,exports.defaultComponents={ToolBar:{},ToolBarButton:{},Weekdays:{},DayCells:{},DayCell:{},Availabilities:{},AvailSlot:{}},exports.defaultTheme=o;
//# sourceMappingURL=react-availability-calendar.cjs.production.min.js.map

@@ -93,3 +93,3 @@ import React, { useMemo, useContext, useState, useEffect, useRef } from 'react';

var shifted = ranges.map(function (r) {
return [(r[0] + ms) % msInDay, (r[1] + ms) % msInDay];
return [(r[0] - ms) % msInDay, (r[1] - ms) % msInDay];
}); // if the new "midnight" happens in the middle of a range, break it into 2

@@ -96,0 +96,0 @@

{
"version": "0.2.3",
"version": "0.2.5",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc