@kkkarsss/ui 1.1.2 → 1.1.4

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.
@@ -1,7 +1,7 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { Typo } from '../text/typo';
4
- export const CalendarHourSlot = ({ hour, onDrop, onCreateTask, children, }) => {
4
+ export const CalendarHourSlot = ({ hour, onDrop, onCreateTask, children }) => {
5
5
  const [selection, setSelection] = useState(null);
6
6
  const handleDragOver = (e) => {
7
7
  e.preventDefault();
@@ -37,7 +37,10 @@ export const CalendarHourSlot = ({ hour, onDrop, onCreateTask, children, }) => {
37
37
  document.addEventListener('mousemove', onMouseMove);
38
38
  document.addEventListener('mouseup', onMouseUp);
39
39
  };
40
- return (_jsxs("div", { onDragOver: handleDragOver, onDrop: (e) => onDrop?.(e, hour), onMouseDown: handleMouseDown, className: "relative h-20 border-b border-secondary-foreground group hover:z-10 has-[.calendar-item:hover]:z-30 has-[.calendar-item:active]:z-30", children: [_jsx("div", { className: "absolute -left-12 top-0 -translate-y-1/2 w-10 text-right", children: _jsxs(Typo, { size: "xs", color: "secondary", children: [String(hour).padStart(2, '0'), ":00"] }) }), _jsxs("div", { className: "pl-4 py-1 relative h-full", children: [children, selection && (_jsx("div", { className: "absolute left-4 right-1 bg-accent/30 border border-accent rounded-sm z-[40] pointer-events-none", style: {
40
+ return (_jsxs("div", { onDragOver: handleDragOver, onDrop: (e) => onDrop?.(e, hour), onMouseDown: handleMouseDown, className: "relative h-20 border-b border-secondary-foreground group hover:z-10 has-[.calendar-item:hover]:z-30 has-[.calendar-item:active]:z-30", children: [_jsx("div", { className: "absolute -left-12 top-0 -translate-y-1/2 w-10 text-right", children: _jsxs(Typo, { size: "xs", color: "secondary", children: [String(hour).padStart(2, '0'), ":00"] }) }), _jsxs("div", { className: "pl-4 py-1 relative h-full", children: [(() => {
41
+ console.log(`CalendarHourSlot: rendering hour ${hour}, children count: ${Array.isArray(children) ? children.length : children ? 1 : 0}`);
42
+ return null;
43
+ })(), children, selection && (_jsx("div", { className: "absolute left-4 right-1 bg-accent/30 border border-accent rounded-sm z-[40] pointer-events-none", style: {
41
44
  top: `${(selection.startMinutes / 60) * 80}px`,
42
45
  height: `${(selection.currentEstimatedTime / 60) * 80}px`,
43
46
  }, children: _jsxs("div", { className: "p-1", children: [_jsx(Typo, { size: "xs", weight: "500", children: "\u041D\u043E\u0432\u0430\u044F \u0437\u0430\u0434\u0430\u0447\u0430" }), _jsxs(Typo, { size: "xs", color: "secondary", children: [selection.currentEstimatedTime, " \u043C\u0438\u043D"] })] }) }))] })] }));
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { jc } from '../../../utils';
4
4
  export const CalendarItemWrapper = ({ task, position, onDragStart, onResize, renderTask, }) => {
5
+ console.log(`CalendarItemWrapper: task ${task.id} (${task.title}), position:`, position);
5
6
  const [previewEstimatedTime, setPreviewEstimatedTime] = useState(null);
6
7
  const handleMouseDown = (e) => {
7
8
  if (onResize) {
@@ -35,9 +36,7 @@ export const CalendarItemWrapper = ({ task, position, onDragStart, onResize, ren
35
36
  document.addEventListener('mouseup', onMouseUp);
36
37
  }
37
38
  };
38
- const displayHeight = previewEstimatedTime
39
- ? `${(previewEstimatedTime / 60) * 80}px`
40
- : position.height;
39
+ const displayHeight = previewEstimatedTime ? `${(previewEstimatedTime / 60) * 80}px` : position.height;
41
40
  return (_jsx("div", { draggable: !!onDragStart, onDragStart: (e) => {
42
41
  onDragStart?.(e, task.id);
43
42
  setTimeout(() => {
@@ -4,6 +4,7 @@ import { jc } from '../../../utils';
4
4
  import { Flex } from '../../layout';
5
5
  import { Typo } from '../text/typo';
6
6
  export const CalendarItem = ({ title, description, isCompleted, isInWork, onClick, icon, estimatedTime = 30, color, className, }) => {
7
+ console.log(`CalendarItem: rendering ${title}, color: ${color}`);
7
8
  return (_jsxs("div", { className: jc('w-full h-full p-1 rounded-sm border flex flex-col transition-colors relative', !color && (isCompleted ? 'opacity-50 border-secondary bg-accent/50' : 'border-accent bg-accent'), color && (isCompleted ? 'opacity-50' : ''), className), style: {
8
9
  backgroundColor: color ? `${color}80` : undefined,
9
10
  borderColor: color ? color : undefined,
@@ -8,8 +8,20 @@ export * from './calendar-item-wrapper';
8
8
  export * from './calendar-item';
9
9
  const DEFAULT_HOURS = Array.from({ length: 24 }, (_, i) => i);
10
10
  export const CalendarLike = ({ tasks, hours = DEFAULT_HOURS, renderTask, onTaskDrop, onTaskResize, onCreateTask, }) => {
11
- const tasksWithPosition = useMemo(() => calculateTaskPositions(tasks), [tasks]);
12
- const tasksByHour = useMemo(() => groupTasksByHour(tasksWithPosition), [tasksWithPosition]);
11
+ console.log('CalendarLike: render, tasks count:', tasks.length);
12
+ if (tasks.length > 0) {
13
+ console.log('CalendarLike: first task title:', tasks[0].title);
14
+ }
15
+ const tasksWithPosition = useMemo(() => {
16
+ const result = calculateTaskPositions(tasks);
17
+ console.log('CalendarLike: calculateTaskPositions result count:', result.length);
18
+ return result;
19
+ }, [tasks]);
20
+ const tasksByHour = useMemo(() => {
21
+ const result = groupTasksByHour(tasksWithPosition);
22
+ console.log('CalendarLike: groupTasksByHour result keys:', Object.keys(result));
23
+ return result;
24
+ }, [tasksWithPosition]);
13
25
  const handleDragStart = (e, taskId) => {
14
26
  e.dataTransfer.setData('taskId', taskId);
15
27
  };
@@ -21,6 +33,7 @@ export const CalendarLike = ({ tasks, hours = DEFAULT_HOURS, renderTask, onTaskD
21
33
  };
22
34
  return (_jsx("div", { className: "relative border-l border-secondary/20 ml-12 select-none", children: hours.map((hour) => {
23
35
  const tasksForHour = tasksByHour[hour];
36
+ console.log(`CalendarLike: hour ${hour} has ${tasksForHour?.length || 0} tasks`);
24
37
  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
38
  }) }));
26
39
  };
@@ -1,11 +1,18 @@
1
1
  export const calculateTaskPositions = (tasks) => {
2
+ console.log('calculateTaskPositions: input:', tasks);
2
3
  const tasksToRender = [...tasks]
3
4
  .map((t) => ({
4
5
  ...t,
5
6
  dueDate: t.dueDate instanceof Date ? t.dueDate : new Date(t.dueDate),
6
7
  }))
7
- .filter((t) => t.dueDate && !isNaN(t.dueDate.getTime()))
8
+ .filter((t) => {
9
+ const isValid = t.dueDate && !isNaN(t.dueDate.getTime());
10
+ if (!isValid)
11
+ console.warn('calculateTaskPositions: invalid date for task:', t.id, t.dueDate);
12
+ return isValid;
13
+ })
8
14
  .sort((a, b) => a.dueDate.getTime() - b.dueDate.getTime());
15
+ console.log('calculateTaskPositions: tasksToRender:', tasksToRender);
9
16
  const columns = [];
10
17
  tasksToRender.forEach((task) => {
11
18
  const startTime = task.dueDate.getTime();
@@ -55,7 +62,8 @@ export const calculateTaskPositions = (tasks) => {
55
62
  const width = clusterColumnsCount > 1 ? `${100 / clusterColumnsCount}%` : '100%';
56
63
  const left = clusterColumnsCount > 1 ? `${(colIndex * 100) / clusterColumnsCount}%` : '0%';
57
64
  const top = `${(task.dueDate.getMinutes() / 60) * 80}px`;
58
- const height = `${(task.estimatedTime / 60) * 80}px`;
65
+ const height = `${(Math.max(15, task.estimatedTime || 15) / 60) * 80}px`;
66
+ console.log(`calculateTaskPositions: task ${task.id} position:`, { width, left, top, height });
59
67
  result.push({
60
68
  ...task,
61
69
  position: { width, left, top, height },
@@ -66,12 +74,14 @@ export const calculateTaskPositions = (tasks) => {
66
74
  return result;
67
75
  };
68
76
  export const groupTasksByHour = (tasksWithPosition) => {
77
+ console.log('groupTasksByHour: input count:', tasksWithPosition.length);
69
78
  const map = {};
70
79
  tasksWithPosition.forEach((task) => {
71
80
  const hour = task.dueDate.getHours();
72
81
  if (!map[hour])
73
82
  map[hour] = [];
74
83
  map[hour].push(task);
84
+ console.log(`groupTasksByHour: task ${task.id} (${task.title}) assigned to hour ${hour}`);
75
85
  });
76
86
  return map;
77
87
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kkkarsss/ui",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "UI Kit for kkkarsss projects",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",