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.1.1 to 0.1.2

5

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

@@ -387,3 +387,4 @@ 'use strict';

toolBarButtonClass: 'btn',
toolBarLabelClass: 'btn btn-link'
toolBarLabelClass: 'btn btn-link',
requestAppointmentLabel: 'Request Appointment'
};

@@ -567,3 +568,3 @@

}, [avails, msInHour, chunkify, slotLengthMs, slotStepMs]);
return React__default.createElement("div", null, React__default.createElement("h4", null, "Request Appointment"), React__default.createElement("h5", null, avails && avails.length > 0 ? formatAsDate(avails[0].startDate) : ''), slots.map(function (s, i) {
return React__default.createElement("div", null, React__default.createElement("h4", null, theme.requestAppointmentLabel), React__default.createElement("h5", null, avails && avails.length > 0 ? formatAsDate(avails[0].startDate) : ''), slots.map(function (s, i) {
return React__default.createElement("div", {

@@ -570,0 +571,0 @@ key: 'b_' + i,

2

dist/react-availability-calendar.cjs.production.min.js

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

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

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

toolBarButtonClass: 'btn',
toolBarLabelClass: 'btn btn-link'
toolBarLabelClass: 'btn btn-link',
requestAppointmentLabel: 'Request Appointment'
};

@@ -560,3 +561,3 @@

}, [avails, msInHour, chunkify, slotLengthMs, slotStepMs]);
return React.createElement("div", null, React.createElement("h4", null, "Request Appointment"), React.createElement("h5", null, avails && avails.length > 0 ? formatAsDate(avails[0].startDate) : ''), slots.map(function (s, i) {
return React.createElement("div", null, React.createElement("h4", null, theme.requestAppointmentLabel), React.createElement("h5", null, avails && avails.length > 0 ? formatAsDate(avails[0].startDate) : ''), slots.map(function (s, i) {
return React.createElement("div", {

@@ -563,0 +564,0 @@ key: 'b_' + i,

@@ -17,2 +17,3 @@ import { MomentCtrFunc } from './moment-types/moment-subset';

toolBarLabelClass: string;
requestAppointmentLabel: string;
}

@@ -32,2 +33,3 @@ export interface CalendarThemeProp {

toolBarLabelClass?: string;
requestAppointmentLabel?: string;
}

@@ -34,0 +36,0 @@ export declare const defaultTheme: CalendarTheme;

{
"version": "0.1.1",
"version": "0.1.2",
"license": "MIT",

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

@@ -34,2 +34,6 @@ ## Bootstrapped with [TSDX](https://github.com/palmerhq/tsdx)

### Customer "Request Appointment" label:
pass `theme={{requestAppointmentLabel: "Request Booking or other wording"}}`
### Installation:

@@ -36,0 +40,0 @@

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