@stfrigerio/sito-template 0.1.31 → 0.1.33

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,14 +2690,38 @@ var styles$8 = {"calendar":"Calendar-module_calendar__3mIJS","loading":"Calendar
2690
2690
  * onEventClick={handleEventClick}
2691
2691
  * />
2692
2692
  */
2693
- function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initialDate = new Date(), config = {}, className = '', style = {}, loading = false, emptyState }) {
2693
+ function Calendar({ events, onEventClick, onDateClick, onEventClickByView, onDateClickByView, 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
+ const dayViewScrollRef = React.useRef(null);
2696
2697
  const { eventColors = {}, iconRenderer, maxEventsPerDay = 3, mondayStart = false, showWeekNumbers = false, dateFormat = { month: 'long', year: 'numeric' }, locale = 'en-US', dayLabels, monthNames } = config;
2697
2698
  const defaultDayLabels = mondayStart
2698
2699
  ? ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
2699
2700
  : ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
2700
2701
  const finalDayLabels = dayLabels || defaultDayLabels;
2702
+ // Auto-scroll to current time in day view
2703
+ React.useEffect(() => {
2704
+ if (currentViewMode === 'day' && dayViewScrollRef.current) {
2705
+ // Check if viewing today
2706
+ const now = new Date();
2707
+ const isToday = currentDate.toDateString() === now.toDateString();
2708
+ if (isToday) {
2709
+ // Calculate scroll position based on current time
2710
+ const currentHour = now.getHours();
2711
+ const currentMinute = now.getMinutes();
2712
+ const minutesSinceMidnight = currentHour * 60 + currentMinute;
2713
+ // Each hour is 60px, so calculate pixel position
2714
+ // Scroll to put current time in the upper third of the view
2715
+ const scrollPosition = (minutesSinceMidnight / 60) * 60 - 100; // Subtract 100 to show some context above
2716
+ // Use setTimeout to ensure DOM is ready
2717
+ setTimeout(() => {
2718
+ if (dayViewScrollRef.current) {
2719
+ dayViewScrollRef.current.scrollTop = Math.max(0, scrollPosition);
2720
+ }
2721
+ }, 0);
2722
+ }
2723
+ }
2724
+ }, [currentViewMode, currentDate]);
2701
2725
  const calendarData = React.useMemo(() => {
2702
2726
  const year = currentDate.getFullYear();
2703
2727
  const month = currentDate.getMonth();
@@ -2840,12 +2864,22 @@ function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initi
2840
2864
  return getContrastColor(bgColor);
2841
2865
  };
2842
2866
  const handleEventClick = (event) => {
2843
- if (onEventClick) {
2867
+ // Check for view-specific handler first
2868
+ if (onEventClickByView && onEventClickByView[currentViewMode]) {
2869
+ onEventClickByView[currentViewMode](event);
2870
+ }
2871
+ else if (onEventClick) {
2872
+ // Fall back to general handler
2844
2873
  onEventClick(event);
2845
2874
  }
2846
2875
  };
2847
2876
  const handleDateClick = (date) => {
2848
- if (onDateClick) {
2877
+ // Check for view-specific handler first
2878
+ if (onDateClickByView && onDateClickByView[currentViewMode]) {
2879
+ onDateClickByView[currentViewMode](date);
2880
+ }
2881
+ else if (onDateClick) {
2882
+ // Fall back to general handler
2849
2883
  onDateClick(date);
2850
2884
  }
2851
2885
  };
@@ -2865,9 +2899,9 @@ function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initi
2865
2899
  if (loading) {
2866
2900
  return (jsxRuntime.jsx("div", { className: `${styles$8.calendar} ${styles$8.loading} ${className}`, style: style, children: jsxRuntime.jsx("div", { className: styles$8.loadingSpinner, children: "Loading..." }) }));
2867
2901
  }
2868
- return (jsxRuntime.jsxs("div", { className: `${styles$8.calendar} ${className}`, style: style, children: [jsxRuntime.jsxs("div", { className: styles$8.header, children: [jsxRuntime.jsxs("div", { className: styles$8.navigation, children: [jsxRuntime.jsx("button", { onClick: handlePrevious, className: styles$8.navButton, "aria-label": "Previous", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: jsxRuntime.jsx("polyline", { points: "15,18 9,12 15,6" }) }) }), jsxRuntime.jsx("h3", { className: styles$8.title, children: calendarData.displayTitle }), jsxRuntime.jsx("button", { onClick: handleNext, className: styles$8.navButton, "aria-label": "Next", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: jsxRuntime.jsx("polyline", { points: "9,6 15,12 9,18" }) }) })] }), jsxRuntime.jsxs("div", { className: styles$8.controls, children: [jsxRuntime.jsx("button", { onClick: handleToday, className: styles$8.todayButton, children: "Today" }), jsxRuntime.jsxs("div", { className: styles$8.viewToggle, children: [jsxRuntime.jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'month' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('month'), children: "Month" }), jsxRuntime.jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'week' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('week'), children: "Week" }), jsxRuntime.jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'day' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('day'), children: "Day" })] })] })] }), currentViewMode !== 'day' && (jsxRuntime.jsxs("div", { className: styles$8.weekDays, children: [showWeekNumbers && jsxRuntime.jsx("div", { className: styles$8.weekNumberHeader, children: "Week" }), finalDayLabels.map((day) => (jsxRuntime.jsx("div", { className: styles$8.weekDay, children: day }, day)))] })), currentViewMode === 'day' ? (
2902
+ return (jsxRuntime.jsxs("div", { className: `${styles$8.calendar} ${className}`, style: style, children: [!hideHeader && (jsxRuntime.jsxs("div", { className: styles$8.header, children: [jsxRuntime.jsxs("div", { className: styles$8.navigation, children: [jsxRuntime.jsx("button", { onClick: handlePrevious, className: styles$8.navButton, "aria-label": "Previous", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: jsxRuntime.jsx("polyline", { points: "15,18 9,12 15,6" }) }) }), jsxRuntime.jsx("h3", { className: styles$8.title, children: calendarData.displayTitle }), jsxRuntime.jsx("button", { onClick: handleNext, className: styles$8.navButton, "aria-label": "Next", children: jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: jsxRuntime.jsx("polyline", { points: "9,6 15,12 9,18" }) }) })] }), jsxRuntime.jsxs("div", { className: styles$8.controls, children: [jsxRuntime.jsx("button", { onClick: handleToday, className: styles$8.todayButton, children: "Today" }), jsxRuntime.jsxs("div", { className: styles$8.viewToggle, children: [jsxRuntime.jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'month' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('month'), children: "Month" }), jsxRuntime.jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'week' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('week'), children: "Week" }), jsxRuntime.jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'day' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('day'), children: "Day" })] })] })] })), currentViewMode !== 'day' && (jsxRuntime.jsxs("div", { className: styles$8.weekDays, children: [showWeekNumbers && jsxRuntime.jsx("div", { className: styles$8.weekNumberHeader, children: "Week" }), finalDayLabels.map((day) => (jsxRuntime.jsx("div", { className: styles$8.weekDay, children: day }, day)))] })), currentViewMode === 'day' ? (
2869
2903
  // Day view layout
2870
- jsxRuntime.jsxs("div", { className: styles$8.dayView, children: [jsxRuntime.jsxs("div", { className: styles$8.dayViewHeader, children: [jsxRuntime.jsx("div", { className: styles$8.timeColumnHeader }), jsxRuntime.jsx("div", { className: styles$8.dayColumnHeader, children: currentDate.toLocaleDateString(locale, { weekday: 'short', day: 'numeric' }) })] }), jsxRuntime.jsx("div", { className: styles$8.dayViewScrollContainer, children: jsxRuntime.jsxs("div", { className: styles$8.dayViewContent, children: [(() => {
2904
+ jsxRuntime.jsxs("div", { className: styles$8.dayView, children: [jsxRuntime.jsxs("div", { className: styles$8.dayViewHeader, children: [jsxRuntime.jsx("div", { className: styles$8.timeColumnHeader }), jsxRuntime.jsx("div", { className: styles$8.dayColumnHeader, children: currentDate.toLocaleDateString(locale, { weekday: 'short', day: 'numeric' }) })] }), jsxRuntime.jsx("div", { className: styles$8.dayViewScrollContainer, ref: dayViewScrollRef, children: jsxRuntime.jsxs("div", { className: styles$8.dayViewContent, children: [(() => {
2871
2905
  const now = new Date();
2872
2906
  const currentHour = now.getHours();
2873
2907
  const currentMinute = now.getMinutes();