react-availability-calendar
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -5,14 +5,13 @@ /// <reference types="react" /> | ||
overrides?: { | ||
ToolBar: import("./overrides").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
ToolBar: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides/general").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides/general").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides/general").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
isSelected: boolean; | ||
isToday: boolean; | ||
hasAvail: boolean; | ||
}>; | ||
Availabilities: import("./overrides").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
Availabilities: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
} | undefined; | ||
}) => JSX.Element; |
@@ -44,14 +44,13 @@ import React from 'react'; | ||
overrides?: { | ||
ToolBar: import("./overrides").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
ToolBar: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides/general").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides/general").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides/general").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
isSelected: boolean; | ||
isToday: boolean; | ||
hasAvail: boolean; | ||
}>; | ||
Availabilities: import("./overrides").OverridableComponentProps<AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
Availabilities: import("./overrides/general").OverridableComponentProps<AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
} | undefined; | ||
}) => JSX.Element; |
@@ -5,13 +5,13 @@ /// <reference types="react" /> | ||
overrides?: { | ||
ToolBar: import("./overrides").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides").OverridableComponentProps<DayCellProps, {}, { | ||
ToolBar: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides/general").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides/general").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides/general").OverridableComponentProps<DayCellProps, {}, { | ||
isSelected: boolean; | ||
hasAvail: boolean; | ||
}>; | ||
Availabilities: import("./overrides").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
Availabilities: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
} | undefined; | ||
}) => JSX.Element; |
@@ -5,14 +5,13 @@ /// <reference types="react" /> | ||
overrides?: { | ||
ToolBar: import("./overrides").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
ToolBar: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides/general").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides/general").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides/general").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
isSelected: boolean; | ||
isToday: boolean; | ||
hasAvail: boolean; | ||
}>; | ||
Availabilities: import("./overrides").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
Availabilities: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
} | undefined; | ||
}) => JSX.Element; |
import { DayCellProps, DayCellsProps, ToolBarProps, AvailSlotsProps, ToolBarButtonProps, AvailSlotProps } from '../types'; | ||
declare type StyleOrFunc<StyleProps> = CSSProperties | ((p: StyleProps) => CSSProperties); | ||
export interface OverridableComponentProps<ComponentProps, InternalProps, StyleProps> { | ||
style?: StyleOrFunc<StyleProps>; | ||
className?: string; | ||
Root?: React.ElementType<ComponentProps>; | ||
internalProps?: InternalProps; | ||
} | ||
export interface ResolvedOverride<ComponentProps, InternalProps> { | ||
style?: CSSProperties; | ||
className?: string; | ||
Root?: React.ElementType<ComponentProps>; | ||
internalProps?: InternalProps; | ||
} | ||
import { CSSProperties } from 'react'; | ||
import { OverridableComponentProps, ResolvedOverride } from './general'; | ||
declare const DefaultToolBar: OverridableComponentProps<ToolBarProps, {}, {}>; | ||
@@ -40,3 +27,2 @@ declare const DefaultToolBarButton: OverridableComponentProps<ToolBarButtonProps, {}, {}>; | ||
export declare type Overrides = typeof defaultComponents; | ||
export declare function getOverride<O extends OverridableComponentProps<T, U, K>, T, U, K>(o: O | undefined, defaultSpec: O, styleProps?: K, _t?: T, _u?: U, _k?: K): ResolvedOverride<T, U>; | ||
export declare function getToolBarOverride(overrides: Overrides | undefined, defaultSpec: typeof DefaultToolBar): ResolvedOverride<ToolBarProps, {}>; | ||
@@ -43,0 +29,0 @@ export declare function getToolBarButtonOverride(overrides: Overrides | undefined, defaultSpec: typeof DefaultToolBarButton): ResolvedOverride<ToolBarButtonProps, {}>; |
@@ -453,2 +453,36 @@ 'use strict'; | ||
function resolveStyle(style, styleProps) { | ||
if (typeof style === 'function') { | ||
return styleProps ? style(styleProps) : style({}); | ||
} | ||
return style; | ||
} | ||
function resolveClassName(className, styleProps) { | ||
if (typeof className === 'function') { | ||
return styleProps ? className(styleProps) : className({}); | ||
} | ||
return className; | ||
} | ||
function getOverride(o, defaultSpec, styleProps, _t, _u, _k) { | ||
if (o === undefined) { | ||
return { | ||
Root: defaultSpec.Root, | ||
className: resolveClassName(defaultSpec.className, styleProps), | ||
style: _extends({}, resolveStyle(defaultSpec.style, styleProps)), | ||
internalProps: defaultSpec.internalProps | ||
}; | ||
} | ||
return { | ||
Root: o.Root || defaultSpec.Root, | ||
className: resolveClassName(o.className, styleProps) || resolveClassName(defaultSpec.className, styleProps), | ||
style: _extends({}, resolveStyle(defaultSpec.style, styleProps), {}, resolveStyle(o.style, styleProps)), | ||
internalProps: _extends({}, defaultSpec.internalProps, {}, o.internalProps) | ||
}; | ||
} | ||
var DefaultToolBar = {}; | ||
@@ -537,27 +571,2 @@ var DefaultToolBarButton = {}; | ||
function resolveStyle(style, styleProps) { | ||
if (typeof style === 'function') { | ||
return styleProps ? style(styleProps) : style({}); | ||
} | ||
return style; | ||
} | ||
function getOverride(o, defaultSpec, styleProps, _t, _u, _k) { | ||
if (o === undefined) { | ||
return { | ||
Root: defaultSpec.Root, | ||
className: defaultSpec.className, | ||
style: _extends({}, resolveStyle(defaultSpec.style, styleProps)), | ||
internalProps: defaultSpec.internalProps | ||
}; | ||
} | ||
return { | ||
Root: defaultSpec.Root || o.Root, | ||
className: defaultSpec.className || o.className, | ||
style: _extends({}, resolveStyle(defaultSpec.style, styleProps), {}, resolveStyle(o.style, styleProps)), | ||
internalProps: _extends({}, defaultSpec.internalProps, {}, o.internalProps) | ||
}; | ||
} | ||
function getToolBarOverride(overrides, defaultSpec) { | ||
@@ -869,2 +878,3 @@ var o = overrides ? overrides.ToolBar : undefined; | ||
var _getDayCellOverride = getDayCellOverride(overrides, { | ||
className: theme.dayClassBase + ' ' + (selectedDate && utils.datesEqual(date, selectedDate) ? theme.dayClassSelected : availsByIndex[dayIndexInCalRange].hasAvail ? theme.dayClassHasAvailability : theme.dayClassDefault), | ||
style: { | ||
@@ -884,3 +894,4 @@ cursor: 'pointer', | ||
Root = _getDayCellOverride.Root, | ||
style = _getDayCellOverride.style; | ||
style = _getDayCellOverride.style, | ||
className = _getDayCellOverride.className; | ||
@@ -902,3 +913,3 @@ if (Root) { | ||
return React__default.createElement("div", { | ||
className: theme.dayClassBase + ' ' + (selectedDate && utils.datesEqual(date, selectedDate) ? theme.dayClassSelected : availsByIndex[dayIndexInCalRange].hasAvail ? theme.dayClassHasAvailability : theme.dayClassDefault), | ||
className: className, | ||
style: style, | ||
@@ -905,0 +916,0 @@ onClick: function onClick() { |
@@ -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(e,t){t=t>0?Math.min(864e5,t):Math.max(-864e5,t);var a=(e=Math.min(864e5,Math.max(0,e)))-t;return a<0?a+864e5:a}function n(t,a){return r(e(t).startOf("week").toDate(),e(a).startOf("week").toDate())}function r(e,t){return e&&t&&e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function o(e,t,n,r,o){for(var l=function(e,t){var n=e.map((function(e){return[a(e[0],t)%864e5,a(e[1],t)%864e5]})),r=n.map((function(e,t){return e[1]<e[0]?t:-1})).filter((function(e){return e>=0})),o=Array.isArray(r),l=0;for(r=o?r:r[Symbol.iterator]();;){var i;if(o){if(l>=r.length)break;i=r[l++]}else{if((l=r.next()).done)break;i=l.value}var s=n[i];n[i]=[-1,-1],n.push([s[0],864e5]),n.push([0,s[1]])}var u=n.filter((function(e){return e[0]>=0}));return u.sort((function(e,t){return e[0]-t[0]})),u}(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)),i=[].concat(n),s=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),m=s;m<=u;m+=864e5){var d=new Date(m),c=l,f=Array.isArray(c),v=0;for(c=f?c:c[Symbol.iterator]();;){var h;if(f){if(v>=c.length)break;h=c[v++]}else{if((v=c.next()).done)break;h=v.value}var y=h,D=Math.floor(y[0]/36e5),g=Math.floor(y[1]/36e5),b=Math.floor(y[0]/6e4)%60,p=Math.floor(y[1]/6e4)%60;i.push({startDate:new Date(d.getFullYear(),d.getMonth(),d.getDate(),D,b),endDate:new Date(d.getFullYear(),d.getMonth(),d.getDate(),g,p)})}i.push({startDate:new Date(d.getFullYear(),d.getMonth(),d.getDate(),23,59),endDate:new Date(d.getFullYear(),d.getMonth(),d.getDate(),24)})}return i}return{msInHour:36e5,datesEqual:r,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 r(t.startDate,e)}))}}))},addBlockOutBookings:o,availabilitiesFromBookings:function(e,t,a,n,r,l){var i,s=Math.max((i=n.getTime(),36e5*Math.floor(i/36e5)+36e5),r.getTime()),u=new Date(s);if(l.getTime()<=u.getTime())return[];var m=[{startDate:u,endDate:l}],d=o(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=[],i=[],s=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(s.toDate()),i.push(s.toDate()),s.add(1,"day")}return{weeks:l,days:i}},chunkify:function(e,a,n){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+=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")}},i=a.createContext({moment:function(){return l},utils:r((function(){return l})),theme:o}),s=function(){return t.useContext(i)},u=function(e){var n=e.moment,o=e.theme,l=e.children,s=t.useMemo((function(){return r(n)}),[n]);return a.createElement(i.Provider,{value:{moment:n,utils:s,theme:o}},l)};function m(e,t){return"function"==typeof e?e(t||{}):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=s().theme,i=function(e,t){return d(e?e.ToolBar:void 0,t,{})}(o,{style:l.toolBarStyle,className:l.toolBarButtonsContainerClass}),u=i.Root,m=i.style,c=i.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,i=o.internalProps,s=o.className;return void 0!==l?a.createElement(l,{message:n,onClicked:r}):a.createElement("button",Object.assign({className:s,onClick:r},i),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,i=d((t=e.overrides)?t.AvailSlot:void 0,{style:{marginBottom:10}},{}),s=i.Root,u=i.style;return s?a.createElement(s,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,i=e.slotLengthMs,s=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:i,utils:s,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:i,slotStepMs:l,utils:s,overrides:m})))},g=function(e){var n=e.avails,r=e.slotLengthMs,o=e.slotStepMs,l=e.onAvailabilitySelected,i=e.theme,s=e.utils,u=e.overrides,m=s.chunkify,d=s.msInHour,c=s.formatAsDate,f=s.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,i.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:i,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,i=e.handleSelected,s=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,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:i,moment:s,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 i(t)}},s(t).format("D"))};function p(e){var t=e.week,n=e.selectedDate,r=e.weekIndexInCalRange,o=e.handleSelected,l=e.availsByIndex,i=e.moment,s=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:i,utils:s,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:i,utils:s,theme:u,overrides:m}))})))}var w=function(e){var r=e.availabilities,o=e.onAvailabilitySelected,l=e.slotLengthMs,i=e.slotStepMs,u=e.date,m=e.style,d=e.overrides,c=s(),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)},M=t.useMemo((function(){return y.monthDaysForDate(u)}),[u,y]),k=M.days,S=M.weeks,A=t.useMemo((function(){return y.availByIndex(k,r)}),[k,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}),S.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:i,utils:y,theme:v,overrides:d})))})))},E=function(e){var n=e.initialDate,r=e.onAvailabilitySelected,o=e.blockOutPeriods,l=e.providerTimeZone,i=e.bookings,u=e.onCalRangeChange,m=e.slotLengthMs,d=e.slotStepMs,f=e.overrides,v=s(),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],M=E[1],k=t.useRef(null);t.useEffect((function(){k.current!==b&&(u&&u(b),k.current=b)}),[b,u]);var S=t.useMemo((function(){var e=y.toStartAndEnd(b);return y.availabilitiesFromBookings(o||[],l,i,D,e.startDate,e.endDate)}),[i,l,b,D,o,y]);return a.createElement("div",null,a.createElement(c,{onNavigate:function(e){if("TODAY"===e){var t=new Date;return M(t),void p(y.monthRangeForDate(t))}if("NEXT"===e||"PREV"===e){var a=h(C).add("NEXT"===e?1:-1,"month").toDate();M(a),p(y.monthRangeForDate(a))}},label:y.formatAsMonth(C),localizer:{messages:{today:"Today",previous:"Previous",next:"Next"}},overrides:f}),a.createElement(w,{availabilities:S,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(e,t){t=t>0?Math.min(864e5,t):Math.max(-864e5,t);var a=(e=Math.min(864e5,Math.max(0,e)))-t;return a<0?a+864e5:a}function n(t,a){return r(e(t).startOf("week").toDate(),e(a).startOf("week").toDate())}function r(e,t){return e&&t&&e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function o(e,t,n,r,o){for(var l=function(e,t){var n=e.map((function(e){return[a(e[0],t)%864e5,a(e[1],t)%864e5]})),r=n.map((function(e,t){return e[1]<e[0]?t:-1})).filter((function(e){return e>=0})),o=Array.isArray(r),l=0;for(r=o?r:r[Symbol.iterator]();;){var s;if(o){if(l>=r.length)break;s=r[l++]}else{if((l=r.next()).done)break;s=l.value}var i=n[s];n[s]=[-1,-1],n.push([i[0],864e5]),n.push([0,i[1]])}var u=n.filter((function(e){return e[0]>=0}));return u.sort((function(e,t){return e[0]-t[0]})),u}(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)),s=[].concat(n),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),u=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),m=i;m<=u;m+=864e5){var d=new Date(m),c=l,f=Array.isArray(c),v=0;for(c=f?c:c[Symbol.iterator]();;){var h;if(f){if(v>=c.length)break;h=c[v++]}else{if((v=c.next()).done)break;h=v.value}var y=h,D=Math.floor(y[0]/36e5),g=Math.floor(y[1]/36e5),b=Math.floor(y[0]/6e4)%60,p=Math.floor(y[1]/6e4)%60;s.push({startDate:new Date(d.getFullYear(),d.getMonth(),d.getDate(),D,b),endDate:new Date(d.getFullYear(),d.getMonth(),d.getDate(),g,p)})}s.push({startDate:new Date(d.getFullYear(),d.getMonth(),d.getDate(),23,59),endDate:new Date(d.getFullYear(),d.getMonth(),d.getDate(),24)})}return s}return{msInHour:36e5,datesEqual:r,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 r(t.startDate,e)}))}}))},addBlockOutBookings:o,availabilitiesFromBookings:function(e,t,a,n,r,l){var s,i=Math.max((s=n.getTime(),36e5*Math.floor(s/36e5)+36e5),r.getTime()),u=new Date(i);if(l.getTime()<=u.getTime())return[];var m=[{startDate:u,endDate:l}],d=o(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?e(t||{}):e}function d(e,t){return"function"==typeof e?e(t||{}):e}function c(e,t,a,r,o,l){return void 0===e?{Root:t.Root,className:d(t.className,a),style:n({},m(t.style,a)),internalProps:t.internalProps}:{Root:e.Root||t.Root,className:d(e.className,a)||d(t.className,a),style:n({},m(t.style,a),{},m(e.style,a)),internalProps:n({},t.internalProps,{},e.internalProps)}}var f=function(e){var t=e.localizer.messages,n=e.label,r=e.onNavigate,o=e.overrides,l=i().theme,s=function(e,t){return c(e?e.ToolBar:void 0,t,{})}(o,{style:l.toolBarStyle,className:l.toolBarButtonsContainerClass}),u=s.Root,m=s.style,d=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:d,role:"group"},a.createElement(v,{theme:l,overrides:o,onClick:function(){return r("TODAY")},message:t.today}),a.createElement(v,{theme:l,overrides:o,onClick:function(){return r("PREV")},message:t.previous}),a.createElement(v,{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 v(e){var t,n=e.message,r=e.onClick,o=c((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 h=["S","M","T","W","Th","F","Sa"],y=function(e){var t,n=c((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},h.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 D(e){var t,n=e.theme,r=e.onAvailabilitySelected,o=e.s,l=e.formatAsDateJustTime,s=c((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 g=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,d=function(e,t){return c(e?e.Availabilities:void 0,t,{})}(m,{style:o?u.slotsContainerStyleShow:u.slotsContainerStyleHide}),f=d.Root,v=d.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(b,{theme:u,durationMinutes:60,avails:t,onAvailabilitySelected:r,slotLengthMs:s,slotStepMs:l,utils:i,overrides:m})))},b=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(D,Object.assign({key:"b_"+t},{theme:s,onAvailabilitySelected:l,s:e,formatAsDateJustTime:f,overrides:u}))})))},p=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,d=e.overrides,f=7*r+n,v=!!l&&u.datesEqual(t,l),h=o[f].hasAvail,y=function(e,t,a){return c(e?e.DayCell:void 0,t,a)}(d,{className:m.dayClassBase+" "+(l&&u.datesEqual(t,l)?m.dayClassSelected:o[f].hasAvail?m.dayClassHasAvailability:m.dayClassDefault),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,hasAvail:h}),D=y.Root,g=y.style,b=y.className;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:b,style:g,onClick:function(){return s(t)}},i(t).format("D"))};function w(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,d=function(e,t){return c(e?e.DayCells:void 0,{style:{display:"flex",justifyContent:"flex-start",flexWrap:"nowrap",flexDirection:"row"}},{})}(m),f=d.Root,v=d.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(p,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 E=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,h=c.utils,D=t.useState(null),b=D[0],p=D[1];t.useEffect((function(){p(null)}),[u]);var E=function(e){b&&h.datesEqual(e,b)?p(null):p(e)},C=function(){p(null)},M=t.useMemo((function(){return h.monthDaysForDate(u)}),[u,h]),k=M.days,S=M.weeks,A=t.useMemo((function(){return h.availByIndex(k,r)}),[k,r,h]),x=t.useMemo((function(){return null!==b?(r||[]).filter((function(e){return h.datesEqual(e.startDate,b)})):[]}),[b,r,h]);return a.createElement("div",{style:n({minHeight:368},m)},a.createElement(y,{overrides:d}),S.map((function(e,t){var n=h.shouldShowWeek(b,e,x);return h.shouldHideWeek(b,e,x)?null:a.createElement(a.Fragment,{key:"w_"+t},a.createElement(w,Object.assign({},{week:e,selectedDate:b,weekIndexInCalRange:t,handleSelected:E,availsByIndex:A,moment:f,utils:h,theme:v,overrides:d})),a.createElement(g,Object.assign({},{show:n,onAvailabilitySelected:o,viewingDayAvailabilities:x,handleUnselect:C,slotLengthMs:l,slotStepMs:s,utils:h,theme:v,overrides:d})))})))},C=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,c=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],w=t.useState(D),C=w[0],M=w[1],k=t.useRef(null);t.useEffect((function(){k.current!==b&&(u&&u(b),k.current=b)}),[b,u]);var S=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(f,{onNavigate:function(e){if("TODAY"===e){var t=new Date;return M(t),void p(y.monthRangeForDate(t))}if("NEXT"===e||"PREV"===e){var a=h(C).add("NEXT"===e?1:-1,"month").toDate();M(a),p(y.monthRangeForDate(a))}},label:y.formatAsMonth(C),localizer:{messages:{today:"Today",previous:"Previous",next:"Next"}},overrides:c}),a.createElement(E,{availabilities:S,date:C,onAvailabilitySelected:r,slotLengthMs:m,slotStepMs:d,overrides:c}))};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(C,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 |
@@ -446,2 +446,36 @@ import React, { useMemo, useContext, useState, useEffect, useRef } from 'react'; | ||
function resolveStyle(style, styleProps) { | ||
if (typeof style === 'function') { | ||
return styleProps ? style(styleProps) : style({}); | ||
} | ||
return style; | ||
} | ||
function resolveClassName(className, styleProps) { | ||
if (typeof className === 'function') { | ||
return styleProps ? className(styleProps) : className({}); | ||
} | ||
return className; | ||
} | ||
function getOverride(o, defaultSpec, styleProps, _t, _u, _k) { | ||
if (o === undefined) { | ||
return { | ||
Root: defaultSpec.Root, | ||
className: resolveClassName(defaultSpec.className, styleProps), | ||
style: _extends({}, resolveStyle(defaultSpec.style, styleProps)), | ||
internalProps: defaultSpec.internalProps | ||
}; | ||
} | ||
return { | ||
Root: o.Root || defaultSpec.Root, | ||
className: resolveClassName(o.className, styleProps) || resolveClassName(defaultSpec.className, styleProps), | ||
style: _extends({}, resolveStyle(defaultSpec.style, styleProps), {}, resolveStyle(o.style, styleProps)), | ||
internalProps: _extends({}, defaultSpec.internalProps, {}, o.internalProps) | ||
}; | ||
} | ||
var DefaultToolBar = {}; | ||
@@ -530,27 +564,2 @@ var DefaultToolBarButton = {}; | ||
function resolveStyle(style, styleProps) { | ||
if (typeof style === 'function') { | ||
return styleProps ? style(styleProps) : style({}); | ||
} | ||
return style; | ||
} | ||
function getOverride(o, defaultSpec, styleProps, _t, _u, _k) { | ||
if (o === undefined) { | ||
return { | ||
Root: defaultSpec.Root, | ||
className: defaultSpec.className, | ||
style: _extends({}, resolveStyle(defaultSpec.style, styleProps)), | ||
internalProps: defaultSpec.internalProps | ||
}; | ||
} | ||
return { | ||
Root: defaultSpec.Root || o.Root, | ||
className: defaultSpec.className || o.className, | ||
style: _extends({}, resolveStyle(defaultSpec.style, styleProps), {}, resolveStyle(o.style, styleProps)), | ||
internalProps: _extends({}, defaultSpec.internalProps, {}, o.internalProps) | ||
}; | ||
} | ||
function getToolBarOverride(overrides, defaultSpec) { | ||
@@ -862,2 +871,3 @@ var o = overrides ? overrides.ToolBar : undefined; | ||
var _getDayCellOverride = getDayCellOverride(overrides, { | ||
className: theme.dayClassBase + ' ' + (selectedDate && utils.datesEqual(date, selectedDate) ? theme.dayClassSelected : availsByIndex[dayIndexInCalRange].hasAvail ? theme.dayClassHasAvailability : theme.dayClassDefault), | ||
style: { | ||
@@ -877,3 +887,4 @@ cursor: 'pointer', | ||
Root = _getDayCellOverride.Root, | ||
style = _getDayCellOverride.style; | ||
style = _getDayCellOverride.style, | ||
className = _getDayCellOverride.className; | ||
@@ -895,3 +906,3 @@ if (Root) { | ||
return React.createElement("div", { | ||
className: theme.dayClassBase + ' ' + (selectedDate && utils.datesEqual(date, selectedDate) ? theme.dayClassSelected : availsByIndex[dayIndexInCalRange].hasAvail ? theme.dayClassHasAvailability : theme.dayClassDefault), | ||
className: className, | ||
style: style, | ||
@@ -898,0 +909,0 @@ onClick: function onClick() { |
@@ -5,14 +5,13 @@ /// <reference types="react" /> | ||
overrides?: { | ||
ToolBar: import("./overrides").OverridableComponentProps<ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
ToolBar: import("./overrides/general").OverridableComponentProps<ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides/general").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides/general").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides/general").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
isSelected: boolean; | ||
isToday: boolean; | ||
hasAvail: boolean; | ||
}>; | ||
Availabilities: import("./overrides").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
Availabilities: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
} | undefined; | ||
}) => JSX.Element; |
/// <reference types="react" /> | ||
export declare const Weekdays: ({ overrides }: { | ||
overrides?: { | ||
ToolBar: import("./overrides").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
ToolBar: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarProps, {}, {}>; | ||
ToolBarButton: import("./overrides/general").OverridableComponentProps<import("./types").ToolBarButtonProps, {}, {}>; | ||
Weekdays: import("./overrides/general").OverridableComponentProps<{}, {}, {}>; | ||
DayCells: import("./overrides/general").OverridableComponentProps<import("./types").DayCellsProps, {}, {}>; | ||
DayCell: import("./overrides/general").OverridableComponentProps<import("./types").DayCellProps, {}, { | ||
isSelected: boolean; | ||
isToday: boolean; | ||
hasAvail: boolean; | ||
}>; | ||
Availabilities: import("./overrides").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
Availabilities: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotsProps, {}, {}>; | ||
AvailSlot: import("./overrides/general").OverridableComponentProps<import("./types").AvailSlotProps, {}, {}>; | ||
} | undefined; | ||
}) => JSX.Element; |
{ | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
346815
26
2614