@kkkarsss/ui 1.1.0 → 1.1.2
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.
|
@@ -3,7 +3,6 @@ import { useMemo } from 'react';
|
|
|
3
3
|
import { CalendarHourSlot } from './calendar-hour-slot';
|
|
4
4
|
import { CalendarItemWrapper } from './calendar-item-wrapper';
|
|
5
5
|
import { calculateTaskPositions, groupTasksByHour } from './utils';
|
|
6
|
-
import { Offset } from '../../layout';
|
|
7
6
|
export * from './types';
|
|
8
7
|
export * from './calendar-item-wrapper';
|
|
9
8
|
export * from './calendar-item';
|
|
@@ -20,5 +19,8 @@ export const CalendarLike = ({ tasks, hours = DEFAULT_HOURS, renderTask, onTaskD
|
|
|
20
19
|
onTaskDrop(taskId, hour);
|
|
21
20
|
}
|
|
22
21
|
};
|
|
23
|
-
return (_jsx(
|
|
22
|
+
return (_jsx("div", { className: "relative border-l border-secondary/20 ml-12 select-none", children: hours.map((hour) => {
|
|
23
|
+
const tasksForHour = tasksByHour[hour];
|
|
24
|
+
return (_jsx(CalendarHourSlot, { hour: hour, onDrop: handleDrop, onCreateTask: onCreateTask, children: tasksForHour?.map((task) => (_jsx(CalendarItemWrapper, { task: task, position: task.position, onDragStart: handleDragStart, onResize: onTaskResize, renderTask: renderTask }, task.id))) }, hour));
|
|
25
|
+
}) }));
|
|
24
26
|
};
|
|
@@ -56,6 +56,8 @@ const INITIAL_TASKS = [
|
|
|
56
56
|
export const Interactive = {
|
|
57
57
|
render: () => {
|
|
58
58
|
const [tasks, setTasks] = useState(INITIAL_TASKS);
|
|
59
|
+
const [showCompleted, setShowCompleted] = useState(true);
|
|
60
|
+
const filteredTasks = tasks.filter((t) => (showCompleted ? true : !t.isCompleted));
|
|
59
61
|
const handleTaskDrop = (taskId, hour) => {
|
|
60
62
|
console.log(`Task ${taskId} dropped at hour ${hour}`);
|
|
61
63
|
setTasks((prev) => prev.map((t) => {
|
|
@@ -86,6 +88,6 @@ export const Interactive = {
|
|
|
86
88
|
console.log(`Task ${taskId} clicked`);
|
|
87
89
|
alert(`Клик по задаче ${taskId}`);
|
|
88
90
|
};
|
|
89
|
-
return (_jsxs("div", { style: { height: '600px', overflowY: 'auto', background: 'var(--bg-primary)', padding: '20px' }, children: [_jsxs("p", { style: { marginBottom: '20px', color: 'var(--secondary)' }, children: ["\u0418\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u044F: ", _jsx("br", {}), "1. \u041F\u0435\u0440\u0435\u0442\u0430\u0441\u043A\u0438\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043C\u0435\u0436\u0434\u0443 \u0447\u0430\u0441\u0430\u043C\u0438. ", _jsx("br", {}), "2. \u0418\u0437\u043C\u0435\u043D\u044F\u0439\u0442\u0435 \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C \u0437\u0430\u0434\u0430\u0447\u0438, \u043F\u043E\u0442\u044F\u043D\u0443\u0432 \u0437\u0430 \u043D\u0438\u0436\u043D\u0438\u0439 \u043A\u0440\u0430\u0439. ", _jsx("br", {}), "3. \u0421\u043E\u0437\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043D\u043E\u0432\u044B\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043A\u043B\u0438\u043A\u043D\u0443\u0432 \u0438 \u043F\u043E\u0442\u044F\u043D\u0443\u0432 \u043D\u0430 \u0441\u0432\u043E\u0431\u043E\u0434\u043D\u043E\u043C \u043C\u0435\u0441\u0442\u0435. ", _jsx("br", {}), "\u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432\u044B\u0432\u043E\u0434\u044F\u0442\u0441\u044F \u0432 \u043A\u043E\u043D\u0441\u043E\u043B\u044C."] }), _jsx(CalendarLike, { tasks:
|
|
91
|
+
return (_jsxs("div", { style: { height: '600px', overflowY: 'auto', background: 'var(--bg-primary)', padding: '20px' }, children: [_jsxs("p", { style: { marginBottom: '20px', color: 'var(--secondary)' }, children: ["\u0418\u043D\u0441\u0442\u0440\u0443\u043A\u0446\u0438\u044F: ", _jsx("br", {}), "1. \u041F\u0435\u0440\u0435\u0442\u0430\u0441\u043A\u0438\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043C\u0435\u0436\u0434\u0443 \u0447\u0430\u0441\u0430\u043C\u0438. ", _jsx("br", {}), "2. \u0418\u0437\u043C\u0435\u043D\u044F\u0439\u0442\u0435 \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C \u0437\u0430\u0434\u0430\u0447\u0438, \u043F\u043E\u0442\u044F\u043D\u0443\u0432 \u0437\u0430 \u043D\u0438\u0436\u043D\u0438\u0439 \u043A\u0440\u0430\u0439. ", _jsx("br", {}), "3. \u0421\u043E\u0437\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043D\u043E\u0432\u044B\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043A\u043B\u0438\u043A\u043D\u0443\u0432 \u0438 \u043F\u043E\u0442\u044F\u043D\u0443\u0432 \u043D\u0430 \u0441\u0432\u043E\u0431\u043E\u0434\u043D\u043E\u043C \u043C\u0435\u0441\u0442\u0435. ", _jsx("br", {}), "\u0420\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432\u044B\u0432\u043E\u0434\u044F\u0442\u0441\u044F \u0432 \u043A\u043E\u043D\u0441\u043E\u043B\u044C."] }), _jsxs("div", { style: { marginBottom: '20px', color: 'var(--secondary)', display: 'flex', alignItems: 'center', gap: '8px' }, children: [_jsx("input", { type: "checkbox", checked: showCompleted, onChange: (e) => setShowCompleted(e.target.checked), id: "show-completed" }), _jsx("label", { htmlFor: "show-completed", style: { cursor: 'pointer' }, children: "\u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u043D\u044B\u0435" })] }), _jsx(CalendarLike, { tasks: filteredTasks, onTaskDrop: handleTaskDrop, onTaskResize: handleTaskResize, onCreateTask: handleCreateTask, renderTask: (task) => (_jsx(CalendarItem, { title: task.title, description: task.description, color: task.color, isCompleted: task.isCompleted, isInWork: task.isInWork, estimatedTime: task.estimatedTime, icon: task.isInWork ? _jsx(Clock, { size: 12, className: "text-white animate-pulse" }) : undefined, onClick: () => handleTaskClick(task.id) })) })] }));
|
|
90
92
|
},
|
|
91
93
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export const calculateTaskPositions = (tasks) => {
|
|
2
|
-
const tasksToRender = [...tasks]
|
|
2
|
+
const tasksToRender = [...tasks]
|
|
3
|
+
.map((t) => ({
|
|
4
|
+
...t,
|
|
5
|
+
dueDate: t.dueDate instanceof Date ? t.dueDate : new Date(t.dueDate),
|
|
6
|
+
}))
|
|
7
|
+
.filter((t) => t.dueDate && !isNaN(t.dueDate.getTime()))
|
|
8
|
+
.sort((a, b) => a.dueDate.getTime() - b.dueDate.getTime());
|
|
3
9
|
const columns = [];
|
|
4
10
|
tasksToRender.forEach((task) => {
|
|
5
11
|
const startTime = task.dueDate.getTime();
|