akfatimeline 2.2.5 → 2.2.7
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/Timeline.js +73 -46
- package/dist/components/Timeline/MasterHeader.jsx +11 -1
- package/dist/components/Timeline/Timeline.jsx +59 -13
- package/dist/components/Timeline/TimelineContent.jsx +1 -28
- package/package.json +1 -1
- package/src/components/Timeline/MasterHeader.jsx +11 -1
- package/src/components/Timeline/Timeline.jsx +59 -13
- package/src/components/Timeline/TimelineContent.jsx +1 -28
package/dist/Timeline.js
CHANGED
|
@@ -3145,7 +3145,9 @@ const MasterHeader = _ref => {
|
|
|
3145
3145
|
zoomStep = 0.25,
|
|
3146
3146
|
showDefaultButtons = true,
|
|
3147
3147
|
// Varsayılan butonları göster/gizle
|
|
3148
|
-
customButtons = []
|
|
3148
|
+
customButtons = [],
|
|
3149
|
+
// Özel butonlar: [{ id, label, onClick, icon?, disabled?, className? }]
|
|
3150
|
+
onCustomButtonClick // Custom button'a tıklandığında tarih string'i geçildiğinde çağrılacak fonksiyon
|
|
3149
3151
|
} = _ref;
|
|
3150
3152
|
const formattedDate = new Date(selectedDate.getTime() + 24 * 60 * 60 * 1000 - selectedDate.getTimezoneOffset() * 60000).toISOString().split("T")[0]; // YYYY-MM-DD formatı
|
|
3151
3153
|
|
|
@@ -3179,7 +3181,16 @@ const MasterHeader = _ref => {
|
|
|
3179
3181
|
}, "Bug\xFCn")), customButtons && customButtons.length > 0 && customButtons.map(button => /*#__PURE__*/external_react_default().createElement("button", {
|
|
3180
3182
|
key: button.id,
|
|
3181
3183
|
className: button.className ? "master-header-btn ".concat(button.className) : "master-header-btn",
|
|
3182
|
-
onClick:
|
|
3184
|
+
onClick: () => {
|
|
3185
|
+
if (button.onClick) {
|
|
3186
|
+
const result = button.onClick();
|
|
3187
|
+
// Eğer onClick bir tarih string'i döndürüyorsa, onCustomButtonClick'i çağır
|
|
3188
|
+
if (typeof result === 'string' && onCustomButtonClick) {
|
|
3189
|
+
onCustomButtonClick(result);
|
|
3190
|
+
}
|
|
3191
|
+
// Normal onClick davranışı da çalışır (eğer result undefined ise)
|
|
3192
|
+
}
|
|
3193
|
+
},
|
|
3183
3194
|
disabled: button.disabled,
|
|
3184
3195
|
title: button.tooltip || button.label
|
|
3185
3196
|
}, button.icon && /*#__PURE__*/external_react_default().createElement("span", {
|
|
@@ -4241,7 +4252,6 @@ const TimelineContent = _ref => {
|
|
|
4241
4252
|
if (!createNewEventOn) return;
|
|
4242
4253
|
if (!isCreating) return;
|
|
4243
4254
|
if (mode === "extend") {
|
|
4244
|
-
console.log(">>> 'extend' mode, skip new event creation");
|
|
4245
4255
|
return;
|
|
4246
4256
|
}
|
|
4247
4257
|
const handleMouseMove = e => {
|
|
@@ -4399,16 +4409,10 @@ const TimelineContent = _ref => {
|
|
|
4399
4409
|
|
|
4400
4410
|
// ------------------- Drag Logic -------------------
|
|
4401
4411
|
const handleDragStartSafe = (e, eventId) => {
|
|
4402
|
-
console.log("[TimelineContent] handleDragStartSafe called:", {
|
|
4403
|
-
eventId,
|
|
4404
|
-
eventsDragOn
|
|
4405
|
-
});
|
|
4406
4412
|
if (!eventsDragOn) {
|
|
4407
|
-
console.log("[TimelineContent] Events drag is disabled, preventing drag start");
|
|
4408
4413
|
e.preventDefault();
|
|
4409
4414
|
return;
|
|
4410
4415
|
}
|
|
4411
|
-
console.log("[TimelineContent] Calling handleDragStart...");
|
|
4412
4416
|
handleDragStart(e, eventId);
|
|
4413
4417
|
};
|
|
4414
4418
|
const handleDragEndSafe = e => {
|
|
@@ -4423,7 +4427,6 @@ const TimelineContent = _ref => {
|
|
|
4423
4427
|
const handleMouseDownExtend = (mouseEvent, event) => {
|
|
4424
4428
|
if (!eventsExtendOn) return;
|
|
4425
4429
|
mouseEvent.stopPropagation();
|
|
4426
|
-
console.log(">>> Extend start ID:", event.id);
|
|
4427
4430
|
setMode("extend");
|
|
4428
4431
|
setExtendingEvent(event);
|
|
4429
4432
|
setOriginalEndDate(event.endDate);
|
|
@@ -4443,7 +4446,6 @@ const TimelineContent = _ref => {
|
|
|
4443
4446
|
}) : evt));
|
|
4444
4447
|
}, [mode, extendingEvent, eventsExtendOn, originalEndDate, startMouseX, setEvents]);
|
|
4445
4448
|
const handleMouseUpExtend = (0,external_react_.useCallback)(() => {
|
|
4446
|
-
console.log(">>> Extend finished ID:", extendingEvent === null || extendingEvent === void 0 ? void 0 : extendingEvent.id);
|
|
4447
4449
|
if (onExtendInfo && extendingEvent) {
|
|
4448
4450
|
// callback
|
|
4449
4451
|
const updatedEvent = events.find(ev => ev.id === extendingEvent.id);
|
|
@@ -4590,15 +4592,6 @@ const TimelineContent = _ref => {
|
|
|
4590
4592
|
const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
4591
4593
|
const preventPastEventsDateOnly = new Date(preventPastEventsDateObj.getFullYear(), preventPastEventsDateObj.getMonth(), preventPastEventsDateObj.getDate());
|
|
4592
4594
|
isPastDate = cellDateOnly < preventPastEventsDateOnly;
|
|
4593
|
-
// Debug: İlk birkaç hücre için log
|
|
4594
|
-
if (colIndex < 3 && groupIndex === 0) {
|
|
4595
|
-
console.log('[TimelineContent] Past date check:', {
|
|
4596
|
-
cellDate: cellDateOnly.toISOString().split('T')[0],
|
|
4597
|
-
preventPastEventsDateValue: preventPastEventsDateOnly.toISOString().split('T')[0],
|
|
4598
|
-
isPastDate,
|
|
4599
|
-
preventPastEvents
|
|
4600
|
-
});
|
|
4601
|
-
}
|
|
4602
4595
|
}
|
|
4603
4596
|
|
|
4604
4597
|
// Disabled tarih kontrolü
|
|
@@ -4712,7 +4705,6 @@ const TimelineContent = _ref => {
|
|
|
4712
4705
|
e.preventDefault();
|
|
4713
4706
|
return;
|
|
4714
4707
|
}
|
|
4715
|
-
console.log("[TimelineContent] Event drag start:", event.id);
|
|
4716
4708
|
handleDragStart(e, event.id);
|
|
4717
4709
|
e.stopPropagation();
|
|
4718
4710
|
|
|
@@ -4781,15 +4773,6 @@ const TimelineContent = _ref => {
|
|
|
4781
4773
|
const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
4782
4774
|
const preventPastEventsDateOnly = new Date(preventPastEventsDateObj.getFullYear(), preventPastEventsDateObj.getMonth(), preventPastEventsDateObj.getDate());
|
|
4783
4775
|
isPastDate = cellDateOnly < preventPastEventsDateOnly;
|
|
4784
|
-
// Debug: İlk birkaç hücre için log
|
|
4785
|
-
if (colIndex < 3 && rowIndex === 0 && groupIndex === 0) {
|
|
4786
|
-
console.log('[TimelineContent] Cell past date check:', {
|
|
4787
|
-
cellDate: cellDateOnly.toISOString().split('T')[0],
|
|
4788
|
-
preventPastEventsDateValue: preventPastEventsDateOnly.toISOString().split('T')[0],
|
|
4789
|
-
isPastDate,
|
|
4790
|
-
preventPastEvents
|
|
4791
|
-
});
|
|
4792
|
-
}
|
|
4793
4776
|
}
|
|
4794
4777
|
|
|
4795
4778
|
// Hafta sonu kontrolü
|
|
@@ -4871,7 +4854,6 @@ const TimelineContent = _ref => {
|
|
|
4871
4854
|
}
|
|
4872
4855
|
e.preventDefault();
|
|
4873
4856
|
e.stopPropagation();
|
|
4874
|
-
console.log("[TimelineContent] onDragOver called for resource:", resource.id);
|
|
4875
4857
|
handleDragOver(e);
|
|
4876
4858
|
},
|
|
4877
4859
|
onDrop: e => {
|
|
@@ -4884,7 +4866,6 @@ const TimelineContent = _ref => {
|
|
|
4884
4866
|
}
|
|
4885
4867
|
e.preventDefault();
|
|
4886
4868
|
e.stopPropagation();
|
|
4887
|
-
console.log("[TimelineContent] onDrop called for resource:", resource.id, "date:", dateObj.fullDate);
|
|
4888
4869
|
handleDrop(e, resource.id, parseDate(dateObj.fullDate));
|
|
4889
4870
|
}
|
|
4890
4871
|
});
|
|
@@ -6022,11 +6003,31 @@ const Timeline_Timeline_Timeline = _ref => {
|
|
|
6022
6003
|
}
|
|
6023
6004
|
}, [programDate]);
|
|
6024
6005
|
|
|
6006
|
+
// onToday prop'u değiştiğinde (tarih string'i ise) selectedDate'i güncelle
|
|
6007
|
+
// Bu, customHeaderButtons'un onClick'inde tarih geçildiğinde kullanılır
|
|
6008
|
+
(0,external_react_.useEffect)(() => {
|
|
6009
|
+
// onToday bir string (tarih) ise, o tarihe git
|
|
6010
|
+
if (onToday && typeof onToday === 'string') {
|
|
6011
|
+
const date = new Date(onToday);
|
|
6012
|
+
if (!isNaN(date.getTime())) {
|
|
6013
|
+
date.setDate(date.getDate() - 3); // Tarihten 3 gün öncesini al
|
|
6014
|
+
setSelectedDate(date);
|
|
6015
|
+
}
|
|
6016
|
+
}
|
|
6017
|
+
}, [onToday]);
|
|
6018
|
+
|
|
6025
6019
|
// ---------------------------------------------------------
|
|
6026
6020
|
// 2) local state
|
|
6027
6021
|
// ---------------------------------------------------------
|
|
6028
6022
|
const [collapsedGroups, setCollapsedGroups] = (0,external_react_.useState)({});
|
|
6029
6023
|
|
|
6024
|
+
// Internal zoom state - eğer setZoomLevel prop'u yoksa kullanılır
|
|
6025
|
+
const [internalZoomLevel, setInternalZoomLevel] = (0,external_react_.useState)(zoomLevel);
|
|
6026
|
+
|
|
6027
|
+
// Effective zoom level - prop varsa prop'u kullan, yoksa internal state'i kullan
|
|
6028
|
+
const effectiveZoomLevel = setZoomLevel ? zoomLevel : internalZoomLevel;
|
|
6029
|
+
const effectiveSetZoomLevel = setZoomLevel || setInternalZoomLevel;
|
|
6030
|
+
|
|
6030
6031
|
// Event Management
|
|
6031
6032
|
const eventManagement = hooks_useEventManagement(events, newEvents => {
|
|
6032
6033
|
setLocalEvents(newEvents);
|
|
@@ -6077,9 +6078,17 @@ const Timeline_Timeline_Timeline = _ref => {
|
|
|
6077
6078
|
// Container genişliği = dayRange * cellWidth
|
|
6078
6079
|
// ---------------------------------------------------------
|
|
6079
6080
|
const baseCellWidth = 56.95; // Temel hücre genişliği (zoom = 1.0 için)
|
|
6080
|
-
const cellWidth = baseCellWidth *
|
|
6081
|
+
const cellWidth = baseCellWidth * effectiveZoomLevel; // Zoom seviyesine göre hücre genişliği
|
|
6081
6082
|
const containerWidth = dayRange * cellWidth;
|
|
6082
6083
|
|
|
6084
|
+
// Internal zoom state'i prop'tan gelen zoomLevel ile senkronize et
|
|
6085
|
+
(0,external_react_.useEffect)(() => {
|
|
6086
|
+
if (setZoomLevel) {
|
|
6087
|
+
// Prop'tan gelen zoomLevel kullanılıyor, internal state'i güncelle
|
|
6088
|
+
setInternalZoomLevel(zoomLevel);
|
|
6089
|
+
}
|
|
6090
|
+
}, [zoomLevel, setZoomLevel]);
|
|
6091
|
+
|
|
6083
6092
|
// ---------------------------------------------------------
|
|
6084
6093
|
// 4) Touch Gestures (Mobil desteği)
|
|
6085
6094
|
// ---------------------------------------------------------
|
|
@@ -6175,12 +6184,29 @@ const Timeline_Timeline_Timeline = _ref => {
|
|
|
6175
6184
|
const handleDateChange = newDate => {
|
|
6176
6185
|
setSelectedDate(new Date(newDate));
|
|
6177
6186
|
};
|
|
6187
|
+
|
|
6188
|
+
// CustomHeaderButtons için tarih değiştirme fonksiyonu
|
|
6189
|
+
// Bu fonksiyon customHeaderButtons'un onClick'inde kullanılabilir
|
|
6190
|
+
const handleCustomDateChange = (0,external_react_.useCallback)(dateString => {
|
|
6191
|
+
if (dateString) {
|
|
6192
|
+
const date = new Date(dateString);
|
|
6193
|
+
if (!isNaN(date.getTime())) {
|
|
6194
|
+
date.setDate(date.getDate() - 3); // Tarihten 3 gün öncesini al
|
|
6195
|
+
setSelectedDate(date);
|
|
6196
|
+
}
|
|
6197
|
+
}
|
|
6198
|
+
}, []);
|
|
6178
6199
|
const handleToday = () => {
|
|
6179
|
-
|
|
6180
|
-
today
|
|
6200
|
+
// Bugünün tarihini al
|
|
6201
|
+
const today = new Date();
|
|
6202
|
+
today.setDate(today.getDate() - 3); // Bugünden 3 gün öncesini ayarla
|
|
6181
6203
|
setSelectedDate(today);
|
|
6182
|
-
|
|
6183
|
-
|
|
6204
|
+
|
|
6205
|
+
// onToday callback'i bir fonksiyon ise çağır
|
|
6206
|
+
// Eğer onToday bir string (tarih) ise veya başka bir değer ise, sadece setSelectedDate yeterli
|
|
6207
|
+
if (typeof onToday === 'function') {
|
|
6208
|
+
onToday();
|
|
6209
|
+
}
|
|
6184
6210
|
};
|
|
6185
6211
|
const handleAdvance = () => {
|
|
6186
6212
|
setSelectedDate(prev => new Date(prev.getTime() + 5 * 24 * 60 * 60 * 1000));
|
|
@@ -6219,15 +6245,15 @@ const Timeline_Timeline_Timeline = _ref => {
|
|
|
6219
6245
|
// 8.5) Zoom handlers
|
|
6220
6246
|
// ---------------------------------------------------------
|
|
6221
6247
|
const handleZoomIn = (0,external_react_.useCallback)(() => {
|
|
6222
|
-
if (
|
|
6223
|
-
|
|
6248
|
+
if (zoomOn) {
|
|
6249
|
+
effectiveSetZoomLevel(prev => Math.min(maxZoomLevel, prev + zoomStep));
|
|
6224
6250
|
}
|
|
6225
|
-
}, [
|
|
6251
|
+
}, [zoomOn, maxZoomLevel, zoomStep, effectiveSetZoomLevel]);
|
|
6226
6252
|
const handleZoomOut = (0,external_react_.useCallback)(() => {
|
|
6227
|
-
if (
|
|
6228
|
-
|
|
6253
|
+
if (zoomOn) {
|
|
6254
|
+
effectiveSetZoomLevel(prev => Math.max(minZoomLevel, prev - zoomStep));
|
|
6229
6255
|
}
|
|
6230
|
-
}, [
|
|
6256
|
+
}, [zoomOn, minZoomLevel, zoomStep, effectiveSetZoomLevel]);
|
|
6231
6257
|
|
|
6232
6258
|
// ---------------------------------------------------------
|
|
6233
6259
|
// 8.6) Keyboard Shortcuts
|
|
@@ -6279,14 +6305,15 @@ const Timeline_Timeline_Timeline = _ref => {
|
|
|
6279
6305
|
onMonthRetreat: handleMonthRetreat,
|
|
6280
6306
|
dayRange: dayRange,
|
|
6281
6307
|
setDayRange: setDayRange,
|
|
6282
|
-
zoomLevel:
|
|
6283
|
-
setZoomLevel:
|
|
6308
|
+
zoomLevel: effectiveZoomLevel,
|
|
6309
|
+
setZoomLevel: effectiveSetZoomLevel,
|
|
6284
6310
|
zoomOn: zoomOn,
|
|
6285
6311
|
minZoomLevel: minZoomLevel,
|
|
6286
6312
|
maxZoomLevel: maxZoomLevel,
|
|
6287
6313
|
zoomStep: zoomStep,
|
|
6288
6314
|
showDefaultButtons: showDefaultHeaderButtons,
|
|
6289
|
-
customButtons: customHeaderButtons
|
|
6315
|
+
customButtons: customHeaderButtons,
|
|
6316
|
+
onCustomButtonClick: handleCustomDateChange
|
|
6290
6317
|
})), /*#__PURE__*/external_react_default().createElement("div", {
|
|
6291
6318
|
className: "timeline-body"
|
|
6292
6319
|
}, /*#__PURE__*/external_react_default().createElement("div", {
|
|
@@ -19,6 +19,7 @@ const MasterHeader = ({
|
|
|
19
19
|
zoomStep = 0.25,
|
|
20
20
|
showDefaultButtons = true, // Varsayılan butonları göster/gizle
|
|
21
21
|
customButtons = [], // Özel butonlar: [{ id, label, onClick, icon?, disabled?, className? }]
|
|
22
|
+
onCustomButtonClick, // Custom button'a tıklandığında tarih string'i geçildiğinde çağrılacak fonksiyon
|
|
22
23
|
}) => {
|
|
23
24
|
const formattedDate = new Date(
|
|
24
25
|
selectedDate.getTime() + 24 * 60 * 60 * 1000 - selectedDate.getTimezoneOffset() * 60000
|
|
@@ -67,7 +68,16 @@ const MasterHeader = ({
|
|
|
67
68
|
<button
|
|
68
69
|
key={button.id}
|
|
69
70
|
className={button.className ? `master-header-btn ${button.className}` : "master-header-btn"}
|
|
70
|
-
onClick={
|
|
71
|
+
onClick={() => {
|
|
72
|
+
if (button.onClick) {
|
|
73
|
+
const result = button.onClick();
|
|
74
|
+
// Eğer onClick bir tarih string'i döndürüyorsa, onCustomButtonClick'i çağır
|
|
75
|
+
if (typeof result === 'string' && onCustomButtonClick) {
|
|
76
|
+
onCustomButtonClick(result);
|
|
77
|
+
}
|
|
78
|
+
// Normal onClick davranışı da çalışır (eğer result undefined ise)
|
|
79
|
+
}
|
|
80
|
+
}}
|
|
71
81
|
disabled={button.disabled}
|
|
72
82
|
title={button.tooltip || button.label}
|
|
73
83
|
>
|
|
@@ -154,10 +154,30 @@ const Timeline = ({
|
|
|
154
154
|
}
|
|
155
155
|
}, [programDate]);
|
|
156
156
|
|
|
157
|
+
// onToday prop'u değiştiğinde (tarih string'i ise) selectedDate'i güncelle
|
|
158
|
+
// Bu, customHeaderButtons'un onClick'inde tarih geçildiğinde kullanılır
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
// onToday bir string (tarih) ise, o tarihe git
|
|
161
|
+
if (onToday && typeof onToday === 'string') {
|
|
162
|
+
const date = new Date(onToday);
|
|
163
|
+
if (!isNaN(date.getTime())) {
|
|
164
|
+
date.setDate(date.getDate() - 3); // Tarihten 3 gün öncesini al
|
|
165
|
+
setSelectedDate(date);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}, [onToday]);
|
|
169
|
+
|
|
157
170
|
// ---------------------------------------------------------
|
|
158
171
|
// 2) local state
|
|
159
172
|
// ---------------------------------------------------------
|
|
160
173
|
const [collapsedGroups, setCollapsedGroups] = useState({});
|
|
174
|
+
|
|
175
|
+
// Internal zoom state - eğer setZoomLevel prop'u yoksa kullanılır
|
|
176
|
+
const [internalZoomLevel, setInternalZoomLevel] = useState(zoomLevel);
|
|
177
|
+
|
|
178
|
+
// Effective zoom level - prop varsa prop'u kullan, yoksa internal state'i kullan
|
|
179
|
+
const effectiveZoomLevel = setZoomLevel ? zoomLevel : internalZoomLevel;
|
|
180
|
+
const effectiveSetZoomLevel = setZoomLevel || setInternalZoomLevel;
|
|
161
181
|
|
|
162
182
|
// Event Management
|
|
163
183
|
const eventManagement = useEventManagement(
|
|
@@ -212,9 +232,17 @@ const Timeline = ({
|
|
|
212
232
|
// Container genişliği = dayRange * cellWidth
|
|
213
233
|
// ---------------------------------------------------------
|
|
214
234
|
const baseCellWidth = 56.95; // Temel hücre genişliği (zoom = 1.0 için)
|
|
215
|
-
const cellWidth = baseCellWidth *
|
|
235
|
+
const cellWidth = baseCellWidth * effectiveZoomLevel; // Zoom seviyesine göre hücre genişliği
|
|
216
236
|
const containerWidth = dayRange * cellWidth;
|
|
217
237
|
|
|
238
|
+
// Internal zoom state'i prop'tan gelen zoomLevel ile senkronize et
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
if (setZoomLevel) {
|
|
241
|
+
// Prop'tan gelen zoomLevel kullanılıyor, internal state'i güncelle
|
|
242
|
+
setInternalZoomLevel(zoomLevel);
|
|
243
|
+
}
|
|
244
|
+
}, [zoomLevel, setZoomLevel]);
|
|
245
|
+
|
|
218
246
|
// ---------------------------------------------------------
|
|
219
247
|
// 4) Touch Gestures (Mobil desteği)
|
|
220
248
|
// ---------------------------------------------------------
|
|
@@ -325,13 +353,30 @@ const Timeline = ({
|
|
|
325
353
|
const handleDateChange = (newDate) => {
|
|
326
354
|
setSelectedDate(new Date(newDate));
|
|
327
355
|
};
|
|
356
|
+
|
|
357
|
+
// CustomHeaderButtons için tarih değiştirme fonksiyonu
|
|
358
|
+
// Bu fonksiyon customHeaderButtons'un onClick'inde kullanılabilir
|
|
359
|
+
const handleCustomDateChange = useCallback((dateString) => {
|
|
360
|
+
if (dateString) {
|
|
361
|
+
const date = new Date(dateString);
|
|
362
|
+
if (!isNaN(date.getTime())) {
|
|
363
|
+
date.setDate(date.getDate() - 3); // Tarihten 3 gün öncesini al
|
|
364
|
+
setSelectedDate(date);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}, []);
|
|
328
368
|
|
|
329
369
|
const handleToday = () => {
|
|
330
|
-
|
|
331
|
-
today
|
|
370
|
+
// Bugünün tarihini al
|
|
371
|
+
const today = new Date();
|
|
372
|
+
today.setDate(today.getDate() - 3); // Bugünden 3 gün öncesini ayarla
|
|
332
373
|
setSelectedDate(today);
|
|
333
|
-
|
|
334
|
-
|
|
374
|
+
|
|
375
|
+
// onToday callback'i bir fonksiyon ise çağır
|
|
376
|
+
// Eğer onToday bir string (tarih) ise veya başka bir değer ise, sadece setSelectedDate yeterli
|
|
377
|
+
if (typeof onToday === 'function') {
|
|
378
|
+
onToday();
|
|
379
|
+
}
|
|
335
380
|
};
|
|
336
381
|
|
|
337
382
|
|
|
@@ -376,16 +421,16 @@ const Timeline = ({
|
|
|
376
421
|
// 8.5) Zoom handlers
|
|
377
422
|
// ---------------------------------------------------------
|
|
378
423
|
const handleZoomIn = useCallback(() => {
|
|
379
|
-
if (
|
|
380
|
-
|
|
424
|
+
if (zoomOn) {
|
|
425
|
+
effectiveSetZoomLevel((prev) => Math.min(maxZoomLevel, prev + zoomStep));
|
|
381
426
|
}
|
|
382
|
-
}, [
|
|
427
|
+
}, [zoomOn, maxZoomLevel, zoomStep, effectiveSetZoomLevel]);
|
|
383
428
|
|
|
384
429
|
const handleZoomOut = useCallback(() => {
|
|
385
|
-
if (
|
|
386
|
-
|
|
430
|
+
if (zoomOn) {
|
|
431
|
+
effectiveSetZoomLevel((prev) => Math.max(minZoomLevel, prev - zoomStep));
|
|
387
432
|
}
|
|
388
|
-
}, [
|
|
433
|
+
}, [zoomOn, minZoomLevel, zoomStep, effectiveSetZoomLevel]);
|
|
389
434
|
|
|
390
435
|
// ---------------------------------------------------------
|
|
391
436
|
// 8.6) Keyboard Shortcuts
|
|
@@ -443,14 +488,15 @@ const Timeline = ({
|
|
|
443
488
|
onMonthRetreat={handleMonthRetreat}
|
|
444
489
|
dayRange={dayRange}
|
|
445
490
|
setDayRange={setDayRange}
|
|
446
|
-
zoomLevel={
|
|
447
|
-
setZoomLevel={
|
|
491
|
+
zoomLevel={effectiveZoomLevel}
|
|
492
|
+
setZoomLevel={effectiveSetZoomLevel}
|
|
448
493
|
zoomOn={zoomOn}
|
|
449
494
|
minZoomLevel={minZoomLevel}
|
|
450
495
|
maxZoomLevel={maxZoomLevel}
|
|
451
496
|
zoomStep={zoomStep}
|
|
452
497
|
showDefaultButtons={showDefaultHeaderButtons}
|
|
453
498
|
customButtons={customHeaderButtons}
|
|
499
|
+
onCustomButtonClick={handleCustomDateChange}
|
|
454
500
|
/>
|
|
455
501
|
</div>
|
|
456
502
|
)}
|
|
@@ -308,7 +308,6 @@ const TimelineContent = ({
|
|
|
308
308
|
if (!createNewEventOn) return;
|
|
309
309
|
if (!isCreating) return;
|
|
310
310
|
if (mode === "extend") {
|
|
311
|
-
console.log(">>> 'extend' mode, skip new event creation");
|
|
312
311
|
return;
|
|
313
312
|
}
|
|
314
313
|
|
|
@@ -474,13 +473,10 @@ const TimelineContent = ({
|
|
|
474
473
|
|
|
475
474
|
// ------------------- Drag Logic -------------------
|
|
476
475
|
const handleDragStartSafe = (e, eventId) => {
|
|
477
|
-
console.log("[TimelineContent] handleDragStartSafe called:", { eventId, eventsDragOn });
|
|
478
476
|
if (!eventsDragOn) {
|
|
479
|
-
console.log("[TimelineContent] Events drag is disabled, preventing drag start");
|
|
480
477
|
e.preventDefault();
|
|
481
478
|
return;
|
|
482
479
|
}
|
|
483
|
-
console.log("[TimelineContent] Calling handleDragStart...");
|
|
484
480
|
handleDragStart(e, eventId);
|
|
485
481
|
};
|
|
486
482
|
const handleDragEndSafe = (e) => {
|
|
@@ -499,7 +495,6 @@ const TimelineContent = ({
|
|
|
499
495
|
const handleMouseDownExtend = (mouseEvent, event) => {
|
|
500
496
|
if (!eventsExtendOn) return;
|
|
501
497
|
mouseEvent.stopPropagation();
|
|
502
|
-
console.log(">>> Extend start ID:", event.id);
|
|
503
498
|
setMode("extend");
|
|
504
499
|
setExtendingEvent(event);
|
|
505
500
|
setOriginalEndDate(event.endDate);
|
|
@@ -525,7 +520,6 @@ const TimelineContent = ({
|
|
|
525
520
|
}, [mode, extendingEvent, eventsExtendOn, originalEndDate, startMouseX, setEvents]);
|
|
526
521
|
|
|
527
522
|
const handleMouseUpExtend = useCallback(() => {
|
|
528
|
-
console.log(">>> Extend finished ID:", extendingEvent?.id);
|
|
529
523
|
if (onExtendInfo && extendingEvent) {
|
|
530
524
|
// callback
|
|
531
525
|
const updatedEvent = events.find((ev) => ev.id === extendingEvent.id);
|
|
@@ -686,15 +680,6 @@ const TimelineContent = ({
|
|
|
686
680
|
const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
687
681
|
const preventPastEventsDateOnly = new Date(preventPastEventsDateObj.getFullYear(), preventPastEventsDateObj.getMonth(), preventPastEventsDateObj.getDate());
|
|
688
682
|
isPastDate = cellDateOnly < preventPastEventsDateOnly;
|
|
689
|
-
// Debug: İlk birkaç hücre için log
|
|
690
|
-
if (colIndex < 3 && groupIndex === 0) {
|
|
691
|
-
console.log('[TimelineContent] Past date check:', {
|
|
692
|
-
cellDate: cellDateOnly.toISOString().split('T')[0],
|
|
693
|
-
preventPastEventsDateValue: preventPastEventsDateOnly.toISOString().split('T')[0],
|
|
694
|
-
isPastDate,
|
|
695
|
-
preventPastEvents
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
683
|
}
|
|
699
684
|
|
|
700
685
|
// Disabled tarih kontrolü
|
|
@@ -821,7 +806,6 @@ const TimelineContent = ({
|
|
|
821
806
|
e.preventDefault();
|
|
822
807
|
return;
|
|
823
808
|
}
|
|
824
|
-
console.log("[TimelineContent] Event drag start:", event.id);
|
|
825
809
|
handleDragStart(e, event.id);
|
|
826
810
|
e.stopPropagation();
|
|
827
811
|
|
|
@@ -912,15 +896,6 @@ const TimelineContent = ({
|
|
|
912
896
|
const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
913
897
|
const preventPastEventsDateOnly = new Date(preventPastEventsDateObj.getFullYear(), preventPastEventsDateObj.getMonth(), preventPastEventsDateObj.getDate());
|
|
914
898
|
isPastDate = cellDateOnly < preventPastEventsDateOnly;
|
|
915
|
-
// Debug: İlk birkaç hücre için log
|
|
916
|
-
if (colIndex < 3 && rowIndex === 0 && groupIndex === 0) {
|
|
917
|
-
console.log('[TimelineContent] Cell past date check:', {
|
|
918
|
-
cellDate: cellDateOnly.toISOString().split('T')[0],
|
|
919
|
-
preventPastEventsDateValue: preventPastEventsDateOnly.toISOString().split('T')[0],
|
|
920
|
-
isPastDate,
|
|
921
|
-
preventPastEvents
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
899
|
}
|
|
925
900
|
|
|
926
901
|
// Hafta sonu kontrolü
|
|
@@ -1008,7 +983,6 @@ const TimelineContent = ({
|
|
|
1008
983
|
}
|
|
1009
984
|
e.preventDefault();
|
|
1010
985
|
e.stopPropagation();
|
|
1011
|
-
console.log("[TimelineContent] onDragOver called for resource:", resource.id);
|
|
1012
986
|
handleDragOver(e);
|
|
1013
987
|
}}
|
|
1014
988
|
onDrop={(e) => {
|
|
@@ -1020,8 +994,7 @@ const TimelineContent = ({
|
|
|
1020
994
|
return false;
|
|
1021
995
|
}
|
|
1022
996
|
e.preventDefault();
|
|
1023
|
-
e.stopPropagation();
|
|
1024
|
-
console.log("[TimelineContent] onDrop called for resource:", resource.id, "date:", dateObj.fullDate);
|
|
997
|
+
e.stopPropagation();
|
|
1025
998
|
handleDrop(e, resource.id, parseDate(dateObj.fullDate));
|
|
1026
999
|
}}
|
|
1027
1000
|
></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "akfatimeline",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"description": "A customizable timeline component for React applications with disableDates, custom header buttons, and past date protection features",
|
|
5
5
|
"main": "./src/library.js",
|
|
6
6
|
"module": "./src/library.js",
|
|
@@ -19,6 +19,7 @@ const MasterHeader = ({
|
|
|
19
19
|
zoomStep = 0.25,
|
|
20
20
|
showDefaultButtons = true, // Varsayılan butonları göster/gizle
|
|
21
21
|
customButtons = [], // Özel butonlar: [{ id, label, onClick, icon?, disabled?, className? }]
|
|
22
|
+
onCustomButtonClick, // Custom button'a tıklandığında tarih string'i geçildiğinde çağrılacak fonksiyon
|
|
22
23
|
}) => {
|
|
23
24
|
const formattedDate = new Date(
|
|
24
25
|
selectedDate.getTime() + 24 * 60 * 60 * 1000 - selectedDate.getTimezoneOffset() * 60000
|
|
@@ -67,7 +68,16 @@ const MasterHeader = ({
|
|
|
67
68
|
<button
|
|
68
69
|
key={button.id}
|
|
69
70
|
className={button.className ? `master-header-btn ${button.className}` : "master-header-btn"}
|
|
70
|
-
onClick={
|
|
71
|
+
onClick={() => {
|
|
72
|
+
if (button.onClick) {
|
|
73
|
+
const result = button.onClick();
|
|
74
|
+
// Eğer onClick bir tarih string'i döndürüyorsa, onCustomButtonClick'i çağır
|
|
75
|
+
if (typeof result === 'string' && onCustomButtonClick) {
|
|
76
|
+
onCustomButtonClick(result);
|
|
77
|
+
}
|
|
78
|
+
// Normal onClick davranışı da çalışır (eğer result undefined ise)
|
|
79
|
+
}
|
|
80
|
+
}}
|
|
71
81
|
disabled={button.disabled}
|
|
72
82
|
title={button.tooltip || button.label}
|
|
73
83
|
>
|
|
@@ -154,10 +154,30 @@ const Timeline = ({
|
|
|
154
154
|
}
|
|
155
155
|
}, [programDate]);
|
|
156
156
|
|
|
157
|
+
// onToday prop'u değiştiğinde (tarih string'i ise) selectedDate'i güncelle
|
|
158
|
+
// Bu, customHeaderButtons'un onClick'inde tarih geçildiğinde kullanılır
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
// onToday bir string (tarih) ise, o tarihe git
|
|
161
|
+
if (onToday && typeof onToday === 'string') {
|
|
162
|
+
const date = new Date(onToday);
|
|
163
|
+
if (!isNaN(date.getTime())) {
|
|
164
|
+
date.setDate(date.getDate() - 3); // Tarihten 3 gün öncesini al
|
|
165
|
+
setSelectedDate(date);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}, [onToday]);
|
|
169
|
+
|
|
157
170
|
// ---------------------------------------------------------
|
|
158
171
|
// 2) local state
|
|
159
172
|
// ---------------------------------------------------------
|
|
160
173
|
const [collapsedGroups, setCollapsedGroups] = useState({});
|
|
174
|
+
|
|
175
|
+
// Internal zoom state - eğer setZoomLevel prop'u yoksa kullanılır
|
|
176
|
+
const [internalZoomLevel, setInternalZoomLevel] = useState(zoomLevel);
|
|
177
|
+
|
|
178
|
+
// Effective zoom level - prop varsa prop'u kullan, yoksa internal state'i kullan
|
|
179
|
+
const effectiveZoomLevel = setZoomLevel ? zoomLevel : internalZoomLevel;
|
|
180
|
+
const effectiveSetZoomLevel = setZoomLevel || setInternalZoomLevel;
|
|
161
181
|
|
|
162
182
|
// Event Management
|
|
163
183
|
const eventManagement = useEventManagement(
|
|
@@ -212,9 +232,17 @@ const Timeline = ({
|
|
|
212
232
|
// Container genişliği = dayRange * cellWidth
|
|
213
233
|
// ---------------------------------------------------------
|
|
214
234
|
const baseCellWidth = 56.95; // Temel hücre genişliği (zoom = 1.0 için)
|
|
215
|
-
const cellWidth = baseCellWidth *
|
|
235
|
+
const cellWidth = baseCellWidth * effectiveZoomLevel; // Zoom seviyesine göre hücre genişliği
|
|
216
236
|
const containerWidth = dayRange * cellWidth;
|
|
217
237
|
|
|
238
|
+
// Internal zoom state'i prop'tan gelen zoomLevel ile senkronize et
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
if (setZoomLevel) {
|
|
241
|
+
// Prop'tan gelen zoomLevel kullanılıyor, internal state'i güncelle
|
|
242
|
+
setInternalZoomLevel(zoomLevel);
|
|
243
|
+
}
|
|
244
|
+
}, [zoomLevel, setZoomLevel]);
|
|
245
|
+
|
|
218
246
|
// ---------------------------------------------------------
|
|
219
247
|
// 4) Touch Gestures (Mobil desteği)
|
|
220
248
|
// ---------------------------------------------------------
|
|
@@ -325,13 +353,30 @@ const Timeline = ({
|
|
|
325
353
|
const handleDateChange = (newDate) => {
|
|
326
354
|
setSelectedDate(new Date(newDate));
|
|
327
355
|
};
|
|
356
|
+
|
|
357
|
+
// CustomHeaderButtons için tarih değiştirme fonksiyonu
|
|
358
|
+
// Bu fonksiyon customHeaderButtons'un onClick'inde kullanılabilir
|
|
359
|
+
const handleCustomDateChange = useCallback((dateString) => {
|
|
360
|
+
if (dateString) {
|
|
361
|
+
const date = new Date(dateString);
|
|
362
|
+
if (!isNaN(date.getTime())) {
|
|
363
|
+
date.setDate(date.getDate() - 3); // Tarihten 3 gün öncesini al
|
|
364
|
+
setSelectedDate(date);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}, []);
|
|
328
368
|
|
|
329
369
|
const handleToday = () => {
|
|
330
|
-
|
|
331
|
-
today
|
|
370
|
+
// Bugünün tarihini al
|
|
371
|
+
const today = new Date();
|
|
372
|
+
today.setDate(today.getDate() - 3); // Bugünden 3 gün öncesini ayarla
|
|
332
373
|
setSelectedDate(today);
|
|
333
|
-
|
|
334
|
-
|
|
374
|
+
|
|
375
|
+
// onToday callback'i bir fonksiyon ise çağır
|
|
376
|
+
// Eğer onToday bir string (tarih) ise veya başka bir değer ise, sadece setSelectedDate yeterli
|
|
377
|
+
if (typeof onToday === 'function') {
|
|
378
|
+
onToday();
|
|
379
|
+
}
|
|
335
380
|
};
|
|
336
381
|
|
|
337
382
|
|
|
@@ -376,16 +421,16 @@ const Timeline = ({
|
|
|
376
421
|
// 8.5) Zoom handlers
|
|
377
422
|
// ---------------------------------------------------------
|
|
378
423
|
const handleZoomIn = useCallback(() => {
|
|
379
|
-
if (
|
|
380
|
-
|
|
424
|
+
if (zoomOn) {
|
|
425
|
+
effectiveSetZoomLevel((prev) => Math.min(maxZoomLevel, prev + zoomStep));
|
|
381
426
|
}
|
|
382
|
-
}, [
|
|
427
|
+
}, [zoomOn, maxZoomLevel, zoomStep, effectiveSetZoomLevel]);
|
|
383
428
|
|
|
384
429
|
const handleZoomOut = useCallback(() => {
|
|
385
|
-
if (
|
|
386
|
-
|
|
430
|
+
if (zoomOn) {
|
|
431
|
+
effectiveSetZoomLevel((prev) => Math.max(minZoomLevel, prev - zoomStep));
|
|
387
432
|
}
|
|
388
|
-
}, [
|
|
433
|
+
}, [zoomOn, minZoomLevel, zoomStep, effectiveSetZoomLevel]);
|
|
389
434
|
|
|
390
435
|
// ---------------------------------------------------------
|
|
391
436
|
// 8.6) Keyboard Shortcuts
|
|
@@ -443,14 +488,15 @@ const Timeline = ({
|
|
|
443
488
|
onMonthRetreat={handleMonthRetreat}
|
|
444
489
|
dayRange={dayRange}
|
|
445
490
|
setDayRange={setDayRange}
|
|
446
|
-
zoomLevel={
|
|
447
|
-
setZoomLevel={
|
|
491
|
+
zoomLevel={effectiveZoomLevel}
|
|
492
|
+
setZoomLevel={effectiveSetZoomLevel}
|
|
448
493
|
zoomOn={zoomOn}
|
|
449
494
|
minZoomLevel={minZoomLevel}
|
|
450
495
|
maxZoomLevel={maxZoomLevel}
|
|
451
496
|
zoomStep={zoomStep}
|
|
452
497
|
showDefaultButtons={showDefaultHeaderButtons}
|
|
453
498
|
customButtons={customHeaderButtons}
|
|
499
|
+
onCustomButtonClick={handleCustomDateChange}
|
|
454
500
|
/>
|
|
455
501
|
</div>
|
|
456
502
|
)}
|
|
@@ -308,7 +308,6 @@ const TimelineContent = ({
|
|
|
308
308
|
if (!createNewEventOn) return;
|
|
309
309
|
if (!isCreating) return;
|
|
310
310
|
if (mode === "extend") {
|
|
311
|
-
console.log(">>> 'extend' mode, skip new event creation");
|
|
312
311
|
return;
|
|
313
312
|
}
|
|
314
313
|
|
|
@@ -474,13 +473,10 @@ const TimelineContent = ({
|
|
|
474
473
|
|
|
475
474
|
// ------------------- Drag Logic -------------------
|
|
476
475
|
const handleDragStartSafe = (e, eventId) => {
|
|
477
|
-
console.log("[TimelineContent] handleDragStartSafe called:", { eventId, eventsDragOn });
|
|
478
476
|
if (!eventsDragOn) {
|
|
479
|
-
console.log("[TimelineContent] Events drag is disabled, preventing drag start");
|
|
480
477
|
e.preventDefault();
|
|
481
478
|
return;
|
|
482
479
|
}
|
|
483
|
-
console.log("[TimelineContent] Calling handleDragStart...");
|
|
484
480
|
handleDragStart(e, eventId);
|
|
485
481
|
};
|
|
486
482
|
const handleDragEndSafe = (e) => {
|
|
@@ -499,7 +495,6 @@ const TimelineContent = ({
|
|
|
499
495
|
const handleMouseDownExtend = (mouseEvent, event) => {
|
|
500
496
|
if (!eventsExtendOn) return;
|
|
501
497
|
mouseEvent.stopPropagation();
|
|
502
|
-
console.log(">>> Extend start ID:", event.id);
|
|
503
498
|
setMode("extend");
|
|
504
499
|
setExtendingEvent(event);
|
|
505
500
|
setOriginalEndDate(event.endDate);
|
|
@@ -525,7 +520,6 @@ const TimelineContent = ({
|
|
|
525
520
|
}, [mode, extendingEvent, eventsExtendOn, originalEndDate, startMouseX, setEvents]);
|
|
526
521
|
|
|
527
522
|
const handleMouseUpExtend = useCallback(() => {
|
|
528
|
-
console.log(">>> Extend finished ID:", extendingEvent?.id);
|
|
529
523
|
if (onExtendInfo && extendingEvent) {
|
|
530
524
|
// callback
|
|
531
525
|
const updatedEvent = events.find((ev) => ev.id === extendingEvent.id);
|
|
@@ -686,15 +680,6 @@ const TimelineContent = ({
|
|
|
686
680
|
const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
687
681
|
const preventPastEventsDateOnly = new Date(preventPastEventsDateObj.getFullYear(), preventPastEventsDateObj.getMonth(), preventPastEventsDateObj.getDate());
|
|
688
682
|
isPastDate = cellDateOnly < preventPastEventsDateOnly;
|
|
689
|
-
// Debug: İlk birkaç hücre için log
|
|
690
|
-
if (colIndex < 3 && groupIndex === 0) {
|
|
691
|
-
console.log('[TimelineContent] Past date check:', {
|
|
692
|
-
cellDate: cellDateOnly.toISOString().split('T')[0],
|
|
693
|
-
preventPastEventsDateValue: preventPastEventsDateOnly.toISOString().split('T')[0],
|
|
694
|
-
isPastDate,
|
|
695
|
-
preventPastEvents
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
683
|
}
|
|
699
684
|
|
|
700
685
|
// Disabled tarih kontrolü
|
|
@@ -821,7 +806,6 @@ const TimelineContent = ({
|
|
|
821
806
|
e.preventDefault();
|
|
822
807
|
return;
|
|
823
808
|
}
|
|
824
|
-
console.log("[TimelineContent] Event drag start:", event.id);
|
|
825
809
|
handleDragStart(e, event.id);
|
|
826
810
|
e.stopPropagation();
|
|
827
811
|
|
|
@@ -912,15 +896,6 @@ const TimelineContent = ({
|
|
|
912
896
|
const cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
913
897
|
const preventPastEventsDateOnly = new Date(preventPastEventsDateObj.getFullYear(), preventPastEventsDateObj.getMonth(), preventPastEventsDateObj.getDate());
|
|
914
898
|
isPastDate = cellDateOnly < preventPastEventsDateOnly;
|
|
915
|
-
// Debug: İlk birkaç hücre için log
|
|
916
|
-
if (colIndex < 3 && rowIndex === 0 && groupIndex === 0) {
|
|
917
|
-
console.log('[TimelineContent] Cell past date check:', {
|
|
918
|
-
cellDate: cellDateOnly.toISOString().split('T')[0],
|
|
919
|
-
preventPastEventsDateValue: preventPastEventsDateOnly.toISOString().split('T')[0],
|
|
920
|
-
isPastDate,
|
|
921
|
-
preventPastEvents
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
899
|
}
|
|
925
900
|
|
|
926
901
|
// Hafta sonu kontrolü
|
|
@@ -1008,7 +983,6 @@ const TimelineContent = ({
|
|
|
1008
983
|
}
|
|
1009
984
|
e.preventDefault();
|
|
1010
985
|
e.stopPropagation();
|
|
1011
|
-
console.log("[TimelineContent] onDragOver called for resource:", resource.id);
|
|
1012
986
|
handleDragOver(e);
|
|
1013
987
|
}}
|
|
1014
988
|
onDrop={(e) => {
|
|
@@ -1020,8 +994,7 @@ const TimelineContent = ({
|
|
|
1020
994
|
return false;
|
|
1021
995
|
}
|
|
1022
996
|
e.preventDefault();
|
|
1023
|
-
e.stopPropagation();
|
|
1024
|
-
console.log("[TimelineContent] onDrop called for resource:", resource.id, "date:", dateObj.fullDate);
|
|
997
|
+
e.stopPropagation();
|
|
1025
998
|
handleDrop(e, resource.id, parseDate(dateObj.fullDate));
|
|
1026
999
|
}}
|
|
1027
1000
|
></div>
|