@stfrigerio/sito-template 0.1.33 → 0.1.35
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 +3 -1
- package/dist/components/organisms/Calendar/Calendar.d.ts.map +1 -1
- package/dist/components/organisms/charts/MoodChart/MoodChart.d.ts.map +1 -1
- package/dist/index.esm.js +51 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +51 -13
- 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
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,
|
|
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
|
|
@@ -3041,8 +3057,10 @@ var styles$7 = {"container":"MoodChart-module_container__MB1Vr","chart":"MoodCha
|
|
|
3041
3057
|
const MoodChart = ({ moodData, width = 800, height = 400 }) => {
|
|
3042
3058
|
const svgRef = React.useRef(null);
|
|
3043
3059
|
const containerRef = React.useRef(null);
|
|
3060
|
+
const tooltipRef = React.useRef(null);
|
|
3044
3061
|
const [selectedMood, setSelectedMood] = React.useState(null);
|
|
3045
3062
|
const [tooltipPosition, setTooltipPosition] = React.useState({ x: 0, y: 0 });
|
|
3063
|
+
const [isHoveringTooltip, setIsHoveringTooltip] = React.useState(false);
|
|
3046
3064
|
const margin = { top: 20, right: 20, bottom: 50, left: 40 };
|
|
3047
3065
|
const chartWidth = width - margin.left - margin.right;
|
|
3048
3066
|
const chartHeight = height - margin.top - margin.bottom;
|
|
@@ -3120,11 +3138,26 @@ const MoodChart = ({ moodData, width = 800, height = 400 }) => {
|
|
|
3120
3138
|
.style('cursor', 'pointer')
|
|
3121
3139
|
.on('mouseenter', (event, d) => {
|
|
3122
3140
|
const rect = svgRef.current?.getBoundingClientRect();
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3141
|
+
const containerRect = containerRef.current?.getBoundingClientRect();
|
|
3142
|
+
if (rect && containerRect) {
|
|
3143
|
+
let x = event.clientX - rect.left + 10;
|
|
3144
|
+
let y = event.clientY - rect.top - 10;
|
|
3145
|
+
// Check if tooltip would overflow on the right
|
|
3146
|
+
const estimatedTooltipWidth = 250; // Approximate tooltip width
|
|
3147
|
+
const rightEdgeBuffer = 20; // Buffer from the right edge
|
|
3148
|
+
if (x + estimatedTooltipWidth > chartWidth + margin.left - rightEdgeBuffer) {
|
|
3149
|
+
// Position tooltip to the left of the cursor, but keep it close
|
|
3150
|
+
x = event.clientX - rect.left - estimatedTooltipWidth - 10;
|
|
3151
|
+
// Ensure it doesn't go off the left edge
|
|
3152
|
+
if (x < 0) {
|
|
3153
|
+
x = 10;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
// Ensure tooltip doesn't go above the container
|
|
3157
|
+
if (y < 0) {
|
|
3158
|
+
y = 10;
|
|
3159
|
+
}
|
|
3160
|
+
setTooltipPosition({ x, y });
|
|
3128
3161
|
}
|
|
3129
3162
|
setSelectedMood(d);
|
|
3130
3163
|
d3__namespace.select(event.currentTarget)
|
|
@@ -3133,28 +3166,33 @@ const MoodChart = ({ moodData, width = 800, height = 400 }) => {
|
|
|
3133
3166
|
.attr('r', 8);
|
|
3134
3167
|
})
|
|
3135
3168
|
.on('mouseleave', (event) => {
|
|
3136
|
-
//
|
|
3169
|
+
// Add delay to allow mouse to move to tooltip
|
|
3137
3170
|
setTimeout(() => {
|
|
3138
|
-
|
|
3139
|
-
|
|
3171
|
+
if (!isHoveringTooltip) {
|
|
3172
|
+
setSelectedMood(null);
|
|
3173
|
+
}
|
|
3174
|
+
}, 250);
|
|
3140
3175
|
d3__namespace.select(event.currentTarget)
|
|
3141
3176
|
.transition()
|
|
3142
3177
|
.duration(200)
|
|
3143
3178
|
.attr('r', 5);
|
|
3144
3179
|
});
|
|
3145
|
-
}, [processedData, chartWidth, chartHeight, colorScale, margin]);
|
|
3180
|
+
}, [processedData, chartWidth, chartHeight, colorScale, margin, isHoveringTooltip]);
|
|
3146
3181
|
// Clean up tooltip on unmount
|
|
3147
3182
|
React.useEffect(() => {
|
|
3148
3183
|
return () => {
|
|
3149
3184
|
setSelectedMood(null);
|
|
3150
3185
|
};
|
|
3151
3186
|
}, []);
|
|
3152
|
-
return (jsxRuntime.jsxs("div", { className: styles$7.container, ref: containerRef,
|
|
3187
|
+
return (jsxRuntime.jsxs("div", { className: styles$7.container, ref: containerRef, children: [jsxRuntime.jsx("svg", { ref: svgRef, width: width, height: height, className: styles$7.chart }), selectedMood && (jsxRuntime.jsxs("div", { ref: tooltipRef, className: styles$7.tooltip, style: {
|
|
3153
3188
|
position: 'absolute',
|
|
3154
|
-
pointerEvents: '
|
|
3189
|
+
pointerEvents: 'auto',
|
|
3155
3190
|
left: tooltipPosition.x,
|
|
3156
3191
|
top: tooltipPosition.y,
|
|
3157
3192
|
zIndex: 1000
|
|
3193
|
+
}, onMouseEnter: () => setIsHoveringTooltip(true), onMouseLeave: () => {
|
|
3194
|
+
setIsHoveringTooltip(false);
|
|
3195
|
+
setSelectedMood(null);
|
|
3158
3196
|
}, children: [jsxRuntime.jsxs("div", { className: styles$7.tooltipHeader, children: [jsxRuntime.jsx("div", { className: styles$7.tooltipDate, children: selectedMood.date.toLocaleDateString() }), jsxRuntime.jsxs("div", { className: styles$7.tooltipRating, children: [jsxRuntime.jsx("span", { className: styles$7.ratingValue, children: selectedMood.rating }), jsxRuntime.jsx("span", { className: styles$7.ratingMax, children: "/10" })] })] }), selectedMood.tags.length > 0 && (jsxRuntime.jsx("div", { className: styles$7.tooltipTags, children: selectedMood.tags.map((tag, index) => (jsxRuntime.jsx("span", { className: styles$7.tag, children: tag }, index))) })), selectedMood.comment && (jsxRuntime.jsx("div", { className: styles$7.tooltipComment, children: selectedMood.comment }))] }))] }));
|
|
3159
3197
|
};
|
|
3160
3198
|
|