diff --git a/src/components/task-list/TaskListHeaderActions.tsx b/src/components/task-list/TaskListHeaderActions.tsx index 9f82cda4..16aaa453 100644 --- a/src/components/task-list/TaskListHeaderActions.tsx +++ b/src/components/task-list/TaskListHeaderActions.tsx @@ -1,6 +1,6 @@ import React from "react"; import { UnfoldLess, UnfoldMore, UnfoldMoreDouble } from "@mui/icons-material"; -import { createTheme, IconButton, ThemeProvider, Tooltip } from "@mui/material"; +import { createTheme, IconButton, Theme, ThemeOptions, ThemeProvider, Tooltip } from "@mui/material"; import style from "./TaskListHeaderActions.module.css"; import { ColorStyles } from "../../types/public-types"; @@ -19,7 +19,7 @@ export const TaskListHeaderActions: React.FC = colors }) => { - const materialLightTheme = createTheme({ + let themeOptions: ThemeOptions = { palette: { primary: { main: colors.barLabelColor // Maps to a primary color (e.g., task bar background) @@ -35,22 +35,6 @@ export const TaskListHeaderActions: React.FC = primary: colors.barLabelColor, // Main text color (bar labels, etc.) secondary: colors.barLabelColor // Context menu text color }, - error: { - main: colors.arrowCriticalColor // Critical task color - }, - warning: { - main: colors.arrowWarningColor // Warning color (e.g., for dependencies) - }, - success: { - main: colors.projectProgressColor // Progress color for successful project completion - }, - info: { - main: colors.todayColor // Info color used for today's highlight - }, - icon: { - primary: colors.barLabelColor, // Color for primary icons - secondary: colors.barLabelColor, // Color for secondary icons - }, }, components: { MuiButton: { @@ -79,7 +63,8 @@ export const TaskListHeaderActions: React.FC = }, }, } - }); + }; + const materialLightTheme: Theme = createTheme(themeOptions); return ( diff --git a/src/components/task-list/columns/add-column.tsx b/src/components/task-list/columns/add-column.tsx index 72faa10c..ecc2d8af 100644 --- a/src/components/task-list/columns/add-column.tsx +++ b/src/components/task-list/columns/add-column.tsx @@ -6,7 +6,7 @@ import styles from "./add-column.module.css"; export const AddColumn: React.FC = (props) => { const { - data: { handleAddTask, icons, style, task } + data: { handleAddTask, icons, colors, task } } = props; const onClick = useCallback(() => { if (task.type === "empty") { @@ -22,7 +22,7 @@ export const AddColumn: React.FC = (props) => { return ( diff --git a/src/components/task-list/columns/date-end-column.tsx b/src/components/task-list/columns/date-end-column.tsx index 26429a9b..9ba3c66c 100644 --- a/src/components/task-list/columns/date-end-column.tsx +++ b/src/components/task-list/columns/date-end-column.tsx @@ -10,7 +10,7 @@ export const DateEndColumn: React.FC = ({ dateFormats, dateLocale, }, - style, + colors, task, }, }) => { @@ -21,7 +21,7 @@ export const DateEndColumn: React.FC = ({ try { return (
{format(task.end, dateFormats.dateColumnFormat, { locale: dateLocale, @@ -31,7 +31,7 @@ export const DateEndColumn: React.FC = ({ } catch (e) { return (
{task.end.toString()}
diff --git a/src/components/task-list/columns/date-start-column.tsx b/src/components/task-list/columns/date-start-column.tsx index a6743f5f..5763e169 100644 --- a/src/components/task-list/columns/date-start-column.tsx +++ b/src/components/task-list/columns/date-start-column.tsx @@ -10,7 +10,7 @@ export const DateStartColumn: React.FC = ({ dateFormats, dateLocale, }, - style, + colors, task, }, }) => { @@ -21,7 +21,7 @@ export const DateStartColumn: React.FC = ({ try { return (
{format(task.start, dateFormats.dateColumnFormat, { locale: dateLocale, @@ -31,7 +31,7 @@ export const DateStartColumn: React.FC = ({ } catch (e) { return (
{task.start.toString()}
diff --git a/src/components/task-list/columns/delete-column.tsx b/src/components/task-list/columns/delete-column.tsx index ba671f87..f013ec5a 100644 --- a/src/components/task-list/columns/delete-column.tsx +++ b/src/components/task-list/columns/delete-column.tsx @@ -6,7 +6,7 @@ import styles from "./delete-column.module.css"; export const DeleteColumn: React.FC = (props) => { const { - data: { handleDeleteTasks, icons, style, task } + data: { handleDeleteTasks, icons, colors, task } } = props; const onClick = useCallback(() => { handleDeleteTasks([task]); @@ -14,7 +14,7 @@ export const DeleteColumn: React.FC = (props) => { return ( diff --git a/src/components/task-list/columns/dependencies-column.tsx b/src/components/task-list/columns/dependencies-column.tsx index 731be4ab..98ffe829 100644 --- a/src/components/task-list/columns/dependencies-column.tsx +++ b/src/components/task-list/columns/dependencies-column.tsx @@ -5,12 +5,12 @@ import { ColumnProps } from "../../../types/public-types"; export const DependenciesColumn: React.FC = ({ data: { dependencies, - style + colors }, }) => { return (
{dependencies.map(({ name }) => name).join(', ')}
diff --git a/src/components/task-list/columns/edit-column.tsx b/src/components/task-list/columns/edit-column.tsx index 893d387a..d95c4544 100644 --- a/src/components/task-list/columns/edit-column.tsx +++ b/src/components/task-list/columns/edit-column.tsx @@ -6,7 +6,7 @@ import styles from "./edit-column.module.css"; export const EditColumn: React.FC = (props) => { const { - data: { handleEditTask, icons, style, task } + data: { handleEditTask, icons, colors, task } } = props; const onClick = useCallback(() => { handleEditTask(task); @@ -14,7 +14,7 @@ export const EditColumn: React.FC = (props) => { return ( diff --git a/src/components/task-list/columns/title-column.tsx b/src/components/task-list/columns/title-column.tsx index 42d0f01b..a49dc6fe 100644 --- a/src/components/task-list/columns/title-column.tsx +++ b/src/components/task-list/columns/title-column.tsx @@ -1,4 +1,4 @@ -import React, { CSSProperties, useCallback } from "react"; +import React, { useCallback } from "react"; import { ColumnProps, Icons, TaskOrEmpty } from "../../../types/public-types"; @@ -24,6 +24,7 @@ const getExpanderSymbol = ( export const TitleColumn: React.FC = (props) => { const { data: { + colors, distances: { expandIconWidth, nestedTaskNameOffset }, icons, isShowTaskNumbers, @@ -33,7 +34,6 @@ export const TitleColumn: React.FC = (props) => { indexStr, task, onExpanderClick, - style } } = props; const { name } = task; @@ -69,7 +69,7 @@ export const TitleColumn: React.FC = (props) => { {expanderSymbol}
{isShowTaskNumbers && {indexStr} } diff --git a/src/components/task-list/task-list-table-row.tsx b/src/components/task-list/task-list-table-row.tsx index fc1c7c2a..122a0c56 100644 --- a/src/components/task-list/task-list-table-row.tsx +++ b/src/components/task-list/task-list-table-row.tsx @@ -162,7 +162,7 @@ const TaskListTableRowInner: React.FC = isShowTaskNumbers, onExpanderClick, task, //: task.type === "empty" ? task : getTaskCurrentState(task), - style + colors }), [ canMoveTasks, @@ -181,7 +181,7 @@ const TaskListTableRowInner: React.FC = isShowTaskNumbers, onExpanderClick, task, - style + colors ] ); const dropPreviewOffset = @@ -300,7 +300,7 @@ const TaskListTableRowInner: React.FC = return (
= > {columns.map((column, index) => { const { Cell, width }= column; + // noinspection TypeScriptValidateTypes return (
= ({ [tasks] ); - const [draggedTask, setDraggedTask] = useState(null); + const [draggedTask, setDraggedTask] = useState(null); const renderedListWithOffset = useMemo(() => { if (!renderedIndexes) { @@ -117,7 +117,6 @@ const TaskListTableDefaultInner: React.FC = ({ tasks={tasks} draggedTask={draggedTask} setDraggedTask={setDraggedTask} - style={colors} /> ); } diff --git a/src/types/public-types.ts b/src/types/public-types.ts index 5f6e38d5..bf7203e0 100644 --- a/src/types/public-types.ts +++ b/src/types/public-types.ts @@ -204,11 +204,11 @@ export type OnArrowDoubleClick = ( export type OnRelationChange = ( /** - * Task, targer, index + * Task, target, index */ from: [Task, DateExtremity, number], /** - * Task, targer, index + * Task, target, index */ to: [Task, DateExtremity, number], /** @@ -819,7 +819,7 @@ export type ColumnData = { isShowTaskNumbers: boolean; onExpanderClick: (task: Task) => void; task: TaskOrEmpty; - style: Partial; + colors: Partial; }; export type ColumnProps = { diff --git a/stories/Comparison.tsx b/stories/Comparison.tsx index 02b6e415..f6be1d60 100644 --- a/stories/Comparison.tsx +++ b/stories/Comparison.tsx @@ -10,10 +10,11 @@ export const Comparison: React.FC = props => { const [tasks, setTasks] = useState(() => { const firstLevelTasks = initTasks(); - const secondLevelTasks = firstLevelTasks.map(task => ({ - ...task, - comparisonLevel: 2, - })); + const secondLevelTasks = firstLevelTasks.map( + (task) => ({ + ...task, + comparisonLevel: 2 + } as TaskOrEmpty)); return [...firstLevelTasks, ...secondLevelTasks]; }); diff --git a/stories/helper.tsx b/stories/helper.tsx index 239ca22e..dbe0be89 100644 --- a/stories/helper.tsx +++ b/stories/helper.tsx @@ -5,11 +5,11 @@ import startOfMinute from "date-fns/startOfMinute"; import startOfDay from "date-fns/startOfDay"; import endOfDay from "date-fns/endOfDay"; -import { Task, TaskOrEmpty } from "../src"; +import { EmptyTask, Task, TaskOrEmpty } from "../src"; const dateFormat = "dd/MM/yyyy HH:mm"; -export function initTasks() { +export function initTasks(): TaskOrEmpty[] { const currentDate = new Date(); const tasks: TaskOrEmpty[] = [ { @@ -165,8 +165,7 @@ export function initTasks() { ]; return tasks.map(taskOrEmpty => { - const task = taskOrEmpty as Task; - if ('start' in taskOrEmpty && 'end' in taskOrEmpty) { + if ("start" in taskOrEmpty && "end" in taskOrEmpty) { const task = taskOrEmpty as Task; return { ...task, @@ -243,41 +242,43 @@ export const onAddTask = (parentTask: Task) => { export const onEditTask = (task: TaskOrEmpty) => { const taskFields = getTaskFields({ name: task.name, - start: task.type === "empty" ? null : task.start, - end: task.type === "empty" ? null : task.end + start: task.type === "empty" ? null : (task as Task).start, + end: task.type === "empty" ? null : (task as Task).end }); - const nextTask: TaskOrEmpty = - task.type === "task" || task.type === "empty" - ? taskFields.start && taskFields.end - ? { - type: "task", - start: taskFields.start, - end: taskFields.end, - comparisonLevel: task.comparisonLevel, - id: task.id, - name: taskFields.name || task.name, - progress: task.type === "empty" ? 0 : task.progress, - dependencies: task.type === "empty" ? undefined : task.dependencies, - parent: task.parent, - styles: task.styles, - isDisabled: task.isDisabled - } - : { - type: "empty", - comparisonLevel: task.comparisonLevel, - id: task.id, - name: taskFields.name || task.name, - parent: task.parent, - styles: task.styles, - isDisabled: task.isDisabled - } + let nextTask: TaskOrEmpty; + if (task.type === "task" || task.type === "empty") { + nextTask = taskFields.start && taskFields.end + ? { + type: "task", + start: taskFields.start, + end: taskFields.end, + comparisonLevel: task.comparisonLevel, + id: task.id, + name: taskFields.name || task.name, + progress: task.type === "empty" ? 0 : (task as Task).progress, + dependencies: task.type === "empty" ? undefined : (task as Task).dependencies, + parent: task.parent, + styles: task.styles, + isDisabled: task.isDisabled + } : { - ...task, + type: "empty", + comparisonLevel: task.comparisonLevel, + id: task.id, name: taskFields.name || task.name, - start: taskFields.start || task.start, - end: taskFields.end || task.end - }; + parent: task.parent, + styles: task.styles, + isDisabled: task.isDisabled + } as EmptyTask; + } else { + nextTask = { + ...task, + name: taskFields.name || task.name, + start: taskFields.start || (task as Task).start, + end: taskFields.end || (task as Task).end + } as Task; + } return Promise.resolve(nextTask); };