@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/components/organisms/Calendar/Calendar.d.ts +15 -1
- package/dist/components/organisms/Calendar/Calendar.d.ts.map +1 -1
- package/dist/index.esm.js +39 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
|
@@ -59,6 +59,18 @@ export interface CalendarProps {
|
|
|
59
59
|
onEventClick?: (event: CalendarEvent) => void;
|
|
60
60
|
/** Callback when a date is clicked */
|
|
61
61
|
onDateClick?: (date: Date) => void;
|
|
62
|
+
/** View-specific event click handlers */
|
|
63
|
+
onEventClickByView?: {
|
|
64
|
+
month?: (event: CalendarEvent) => void;
|
|
65
|
+
week?: (event: CalendarEvent) => void;
|
|
66
|
+
day?: (event: CalendarEvent) => void;
|
|
67
|
+
};
|
|
68
|
+
/** View-specific date click handlers */
|
|
69
|
+
onDateClickByView?: {
|
|
70
|
+
month?: (date: Date) => void;
|
|
71
|
+
week?: (date: Date) => void;
|
|
72
|
+
day?: (date: Date) => void;
|
|
73
|
+
};
|
|
62
74
|
/** Initial view mode */
|
|
63
75
|
viewMode?: 'month' | 'week' | 'day';
|
|
64
76
|
/** Initial date to display */
|
|
@@ -73,6 +85,8 @@ export interface CalendarProps {
|
|
|
73
85
|
loading?: boolean;
|
|
74
86
|
/** Custom empty state component */
|
|
75
87
|
emptyState?: React.ReactNode;
|
|
88
|
+
/** Hide the calendar header (navigation, title, view controls) */
|
|
89
|
+
hideHeader?: boolean;
|
|
76
90
|
}
|
|
77
91
|
/**
|
|
78
92
|
* Calendar component - A flexible, reusable calendar for displaying events
|
|
@@ -103,5 +117,5 @@ export interface CalendarProps {
|
|
|
103
117
|
* onEventClick={handleEventClick}
|
|
104
118
|
* />
|
|
105
119
|
*/
|
|
106
|
-
export declare function Calendar({ events, onEventClick, onDateClick, viewMode, initialDate, config, className, style, loading, emptyState }: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
120
|
+
export declare function Calendar({ events, onEventClick, onDateClick, onEventClickByView, onDateClickByView, viewMode, initialDate, config, className, style, loading, emptyState, hideHeader }: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
107
121
|
//# sourceMappingURL=Calendar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/Calendar/Calendar.tsx"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB;IACjB,IAAI,EAAE,IAAI,GAAG,MAAM,CAAC;IACpB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,MAAM,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM,CAAC;IACxD,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;IAC9C,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC3B,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,2CAA2C;IAC3C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,KAAK,CAAC,SAAS,CAAC;IACzD,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wBAAwB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yBAAyB;IACzB,UAAU,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;IACxC,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,iCAAiC;IACjC,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,wCAAwC;IACxC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,sCAAsC;IACtC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,wBAAwB;IACxB,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IACpC,8BAA8B;IAC9B,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/Calendar/Calendar.tsx"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,sCAAsC;IACtC,EAAE,E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Q,CAAC,EACrB,MAAM,EACN,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,QAAkB,EAClB,WAAwB,EACxB,MAAW,EACX,SAAc,EACd,KAAU,EACV,OAAe,EACf,UAAU,EACV,UAAkB,EACrB,EAAE,aAAa,2CA0ff"}
|
package/dist/index.esm.js
CHANGED
|
@@ -2669,14 +2669,38 @@ var styles$8 = {"calendar":"Calendar-module_calendar__3mIJS","loading":"Calendar
|
|
|
2669
2669
|
* onEventClick={handleEventClick}
|
|
2670
2670
|
* />
|
|
2671
2671
|
*/
|
|
2672
|
-
function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initialDate = new Date(), config = {}, className = '', style = {}, loading = false, emptyState }) {
|
|
2672
|
+
function Calendar({ events, onEventClick, onDateClick, onEventClickByView, onDateClickByView, viewMode = 'month', initialDate = new Date(), config = {}, className = '', style = {}, loading = false, emptyState, hideHeader = false }) {
|
|
2673
2673
|
const [currentDate, setCurrentDate] = useState(initialDate);
|
|
2674
2674
|
const [currentViewMode, setCurrentViewMode] = useState(viewMode);
|
|
2675
|
+
const dayViewScrollRef = useRef(null);
|
|
2675
2676
|
const { eventColors = {}, iconRenderer, maxEventsPerDay = 3, mondayStart = false, showWeekNumbers = false, dateFormat = { month: 'long', year: 'numeric' }, locale = 'en-US', dayLabels, monthNames } = config;
|
|
2676
2677
|
const defaultDayLabels = mondayStart
|
|
2677
2678
|
? ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
|
2678
2679
|
: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
2679
2680
|
const finalDayLabels = dayLabels || defaultDayLabels;
|
|
2681
|
+
// Auto-scroll to current time in day view
|
|
2682
|
+
useEffect(() => {
|
|
2683
|
+
if (currentViewMode === 'day' && dayViewScrollRef.current) {
|
|
2684
|
+
// Check if viewing today
|
|
2685
|
+
const now = new Date();
|
|
2686
|
+
const isToday = currentDate.toDateString() === now.toDateString();
|
|
2687
|
+
if (isToday) {
|
|
2688
|
+
// Calculate scroll position based on current time
|
|
2689
|
+
const currentHour = now.getHours();
|
|
2690
|
+
const currentMinute = now.getMinutes();
|
|
2691
|
+
const minutesSinceMidnight = currentHour * 60 + currentMinute;
|
|
2692
|
+
// Each hour is 60px, so calculate pixel position
|
|
2693
|
+
// Scroll to put current time in the upper third of the view
|
|
2694
|
+
const scrollPosition = (minutesSinceMidnight / 60) * 60 - 100; // Subtract 100 to show some context above
|
|
2695
|
+
// Use setTimeout to ensure DOM is ready
|
|
2696
|
+
setTimeout(() => {
|
|
2697
|
+
if (dayViewScrollRef.current) {
|
|
2698
|
+
dayViewScrollRef.current.scrollTop = Math.max(0, scrollPosition);
|
|
2699
|
+
}
|
|
2700
|
+
}, 0);
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
}, [currentViewMode, currentDate]);
|
|
2680
2704
|
const calendarData = useMemo(() => {
|
|
2681
2705
|
const year = currentDate.getFullYear();
|
|
2682
2706
|
const month = currentDate.getMonth();
|
|
@@ -2819,12 +2843,22 @@ function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initi
|
|
|
2819
2843
|
return getContrastColor(bgColor);
|
|
2820
2844
|
};
|
|
2821
2845
|
const handleEventClick = (event) => {
|
|
2822
|
-
|
|
2846
|
+
// Check for view-specific handler first
|
|
2847
|
+
if (onEventClickByView && onEventClickByView[currentViewMode]) {
|
|
2848
|
+
onEventClickByView[currentViewMode](event);
|
|
2849
|
+
}
|
|
2850
|
+
else if (onEventClick) {
|
|
2851
|
+
// Fall back to general handler
|
|
2823
2852
|
onEventClick(event);
|
|
2824
2853
|
}
|
|
2825
2854
|
};
|
|
2826
2855
|
const handleDateClick = (date) => {
|
|
2827
|
-
|
|
2856
|
+
// Check for view-specific handler first
|
|
2857
|
+
if (onDateClickByView && onDateClickByView[currentViewMode]) {
|
|
2858
|
+
onDateClickByView[currentViewMode](date);
|
|
2859
|
+
}
|
|
2860
|
+
else if (onDateClick) {
|
|
2861
|
+
// Fall back to general handler
|
|
2828
2862
|
onDateClick(date);
|
|
2829
2863
|
}
|
|
2830
2864
|
};
|
|
@@ -2844,9 +2878,9 @@ function Calendar({ events, onEventClick, onDateClick, viewMode = 'month', initi
|
|
|
2844
2878
|
if (loading) {
|
|
2845
2879
|
return (jsx("div", { className: `${styles$8.calendar} ${styles$8.loading} ${className}`, style: style, children: jsx("div", { className: styles$8.loadingSpinner, children: "Loading..." }) }));
|
|
2846
2880
|
}
|
|
2847
|
-
return (jsxs("div", { className: `${styles$8.calendar} ${className}`, style: style, children: [jsxs("div", { className: styles$8.header, children: [jsxs("div", { className: styles$8.navigation, children: [jsx("button", { onClick: handlePrevious, className: styles$8.navButton, "aria-label": "Previous", children: jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: jsx("polyline", { points: "15,18 9,12 15,6" }) }) }), jsx("h3", { className: styles$8.title, children: calendarData.displayTitle }), jsx("button", { onClick: handleNext, className: styles$8.navButton, "aria-label": "Next", children: jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: jsx("polyline", { points: "9,6 15,12 9,18" }) }) })] }), jsxs("div", { className: styles$8.controls, children: [jsx("button", { onClick: handleToday, className: styles$8.todayButton, children: "Today" }), jsxs("div", { className: styles$8.viewToggle, children: [jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'month' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('month'), children: "Month" }), jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'week' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('week'), children: "Week" }), jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'day' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('day'), children: "Day" })] })] })] }), currentViewMode !== 'day' && (jsxs("div", { className: styles$8.weekDays, children: [showWeekNumbers && jsx("div", { className: styles$8.weekNumberHeader, children: "Week" }), finalDayLabels.map((day) => (jsx("div", { className: styles$8.weekDay, children: day }, day)))] })), currentViewMode === 'day' ? (
|
|
2881
|
+
return (jsxs("div", { className: `${styles$8.calendar} ${className}`, style: style, children: [!hideHeader && (jsxs("div", { className: styles$8.header, children: [jsxs("div", { className: styles$8.navigation, children: [jsx("button", { onClick: handlePrevious, className: styles$8.navButton, "aria-label": "Previous", children: jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: jsx("polyline", { points: "15,18 9,12 15,6" }) }) }), jsx("h3", { className: styles$8.title, children: calendarData.displayTitle }), jsx("button", { onClick: handleNext, className: styles$8.navButton, "aria-label": "Next", children: jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", children: jsx("polyline", { points: "9,6 15,12 9,18" }) }) })] }), jsxs("div", { className: styles$8.controls, children: [jsx("button", { onClick: handleToday, className: styles$8.todayButton, children: "Today" }), jsxs("div", { className: styles$8.viewToggle, children: [jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'month' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('month'), children: "Month" }), jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'week' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('week'), children: "Week" }), jsx("button", { className: `${styles$8.viewButton} ${currentViewMode === 'day' ? styles$8.active : ''}`, onClick: () => setCurrentViewMode('day'), children: "Day" })] })] })] })), currentViewMode !== 'day' && (jsxs("div", { className: styles$8.weekDays, children: [showWeekNumbers && jsx("div", { className: styles$8.weekNumberHeader, children: "Week" }), finalDayLabels.map((day) => (jsx("div", { className: styles$8.weekDay, children: day }, day)))] })), currentViewMode === 'day' ? (
|
|
2848
2882
|
// Day view layout
|
|
2849
|
-
jsxs("div", { className: styles$8.dayView, children: [jsxs("div", { className: styles$8.dayViewHeader, children: [jsx("div", { className: styles$8.timeColumnHeader }), jsx("div", { className: styles$8.dayColumnHeader, children: currentDate.toLocaleDateString(locale, { weekday: 'short', day: 'numeric' }) })] }), jsx("div", { className: styles$8.dayViewScrollContainer, children: jsxs("div", { className: styles$8.dayViewContent, children: [(() => {
|
|
2883
|
+
jsxs("div", { className: styles$8.dayView, children: [jsxs("div", { className: styles$8.dayViewHeader, children: [jsx("div", { className: styles$8.timeColumnHeader }), jsx("div", { className: styles$8.dayColumnHeader, children: currentDate.toLocaleDateString(locale, { weekday: 'short', day: 'numeric' }) })] }), jsx("div", { className: styles$8.dayViewScrollContainer, ref: dayViewScrollRef, children: jsxs("div", { className: styles$8.dayViewContent, children: [(() => {
|
|
2850
2884
|
const now = new Date();
|
|
2851
2885
|
const currentHour = now.getHours();
|
|
2852
2886
|
const currentMinute = now.getMinutes();
|