@stfrigerio/sito-template 0.1.33 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2690,7 +2690,7 @@ var styles$8 = {"calendar":"Calendar-module_calendar__3mIJS","loading":"Calendar
2690
2690
  * onEventClick={handleEventClick}
2691
2691
  * />
2692
2692
  */
2693
- function Calendar({ events, onEventClick, onDateClick, onEventClickByView, onDateClickByView, viewMode = 'month', initialDate = new Date(), config = {}, className = '', style = {}, loading = false, emptyState, hideHeader = false }) {
2693
+ function Calendar({ events, onEventClick, onDateClick, onEventClickByView, onDateClickByView, onTimeSlotClick, viewMode = 'month', initialDate = new Date(), config = {}, className = '', style = {}, loading = false, emptyState, hideHeader = false }) {
2694
2694
  const [currentDate, setCurrentDate] = React.useState(initialDate);
2695
2695
  const [currentViewMode, setCurrentViewMode] = React.useState(viewMode);
2696
2696
  const dayViewScrollRef = React.useRef(null);
@@ -2883,6 +2883,16 @@ function Calendar({ events, onEventClick, onDateClick, onEventClickByView, onDat
2883
2883
  onDateClick(date);
2884
2884
  }
2885
2885
  };
2886
+ const handleTimeSlotClick = (hour) => {
2887
+ if (onTimeSlotClick) {
2888
+ // Create a date object with the current date and the clicked hour
2889
+ const slotDate = new Date(currentDate);
2890
+ slotDate.setHours(hour, 0, 0, 0);
2891
+ // Format time as HH:00
2892
+ const timeString = `${hour.toString().padStart(2, '0')}:00`;
2893
+ onTimeSlotClick(slotDate, hour, timeString);
2894
+ }
2895
+ };
2886
2896
  const isToday = (date) => {
2887
2897
  const today = new Date();
2888
2898
  return date.toDateString() === today.toDateString();
@@ -2917,7 +2927,13 @@ function Calendar({ events, onEventClick, onDateClick, onEventClickByView, onDat
2917
2927
  const eventHour = parseInt(event.time.split(':')[0]);
2918
2928
  return eventHour === hour;
2919
2929
  });
2920
- return (jsxRuntime.jsxs("div", { className: styles$8.hourSlot, children: [jsxRuntime.jsx("div", { className: styles$8.hourLine }), hourEvents.map((event, eventIndex) => (jsxRuntime.jsxs(framerMotion.motion.div, { className: `${styles$8.dayEvent} ${event.status === 'completed' ? styles$8.completed : ''}`, style: {
2930
+ return (jsxRuntime.jsxs("div", { className: styles$8.hourSlot, onClick: (e) => {
2931
+ // Only trigger if clicking on the slot itself, not on an event
2932
+ if (e.target === e.currentTarget ||
2933
+ e.target.classList.contains(styles$8.hourLine)) {
2934
+ handleTimeSlotClick(hour);
2935
+ }
2936
+ }, style: { cursor: 'pointer' }, children: [jsxRuntime.jsx("div", { className: styles$8.hourLine }), hourEvents.map((event, eventIndex) => (jsxRuntime.jsxs(framerMotion.motion.div, { className: `${styles$8.dayEvent} ${event.status === 'completed' ? styles$8.completed : ''}`, style: {
2921
2937
  backgroundColor: getEventColor(event),
2922
2938
  color: getEventTextColor(event),
2923
2939
  opacity: event.status === 'completed' ? 0.7 : 1