akfatimeline 2.2.6 → 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
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", {
|
|
@@ -5992,6 +6003,19 @@ const Timeline_Timeline_Timeline = _ref => {
|
|
|
5992
6003
|
}
|
|
5993
6004
|
}, [programDate]);
|
|
5994
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
|
+
|
|
5995
6019
|
// ---------------------------------------------------------
|
|
5996
6020
|
// 2) local state
|
|
5997
6021
|
// ---------------------------------------------------------
|
|
@@ -6160,6 +6184,18 @@ const Timeline_Timeline_Timeline = _ref => {
|
|
|
6160
6184
|
const handleDateChange = newDate => {
|
|
6161
6185
|
setSelectedDate(new Date(newDate));
|
|
6162
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
|
+
}, []);
|
|
6163
6199
|
const handleToday = () => {
|
|
6164
6200
|
// Bugünün tarihini al
|
|
6165
6201
|
const today = new Date();
|
|
@@ -6276,7 +6312,8 @@ const Timeline_Timeline_Timeline = _ref => {
|
|
|
6276
6312
|
maxZoomLevel: maxZoomLevel,
|
|
6277
6313
|
zoomStep: zoomStep,
|
|
6278
6314
|
showDefaultButtons: showDefaultHeaderButtons,
|
|
6279
|
-
customButtons: customHeaderButtons
|
|
6315
|
+
customButtons: customHeaderButtons,
|
|
6316
|
+
onCustomButtonClick: handleCustomDateChange
|
|
6280
6317
|
})), /*#__PURE__*/external_react_default().createElement("div", {
|
|
6281
6318
|
className: "timeline-body"
|
|
6282
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,6 +154,19 @@ 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
|
// ---------------------------------------------------------
|
|
@@ -340,6 +353,18 @@ const Timeline = ({
|
|
|
340
353
|
const handleDateChange = (newDate) => {
|
|
341
354
|
setSelectedDate(new Date(newDate));
|
|
342
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
|
+
}, []);
|
|
343
368
|
|
|
344
369
|
const handleToday = () => {
|
|
345
370
|
// Bugünün tarihini al
|
|
@@ -471,6 +496,7 @@ const Timeline = ({
|
|
|
471
496
|
zoomStep={zoomStep}
|
|
472
497
|
showDefaultButtons={showDefaultHeaderButtons}
|
|
473
498
|
customButtons={customHeaderButtons}
|
|
499
|
+
onCustomButtonClick={handleCustomDateChange}
|
|
474
500
|
/>
|
|
475
501
|
</div>
|
|
476
502
|
)}
|
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,6 +154,19 @@ 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
|
// ---------------------------------------------------------
|
|
@@ -340,6 +353,18 @@ const Timeline = ({
|
|
|
340
353
|
const handleDateChange = (newDate) => {
|
|
341
354
|
setSelectedDate(new Date(newDate));
|
|
342
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
|
+
}, []);
|
|
343
368
|
|
|
344
369
|
const handleToday = () => {
|
|
345
370
|
// Bugünün tarihini al
|
|
@@ -471,6 +496,7 @@ const Timeline = ({
|
|
|
471
496
|
zoomStep={zoomStep}
|
|
472
497
|
showDefaultButtons={showDefaultHeaderButtons}
|
|
473
498
|
customButtons={customHeaderButtons}
|
|
499
|
+
onCustomButtonClick={handleCustomDateChange}
|
|
474
500
|
/>
|
|
475
501
|
</div>
|
|
476
502
|
)}
|