mantine-gantt 0.0.1

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/dist/cjs/Gantt/DependencyLinks.cjs +103 -0
  4. package/dist/cjs/Gantt/DependencyLinks.cjs.map +1 -0
  5. package/dist/cjs/Gantt/Gantt.cjs +294 -0
  6. package/dist/cjs/Gantt/Gantt.cjs.map +1 -0
  7. package/dist/cjs/Gantt/Gantt.module.css.cjs +7 -0
  8. package/dist/cjs/Gantt/Gantt.module.css.cjs.map +1 -0
  9. package/dist/cjs/Gantt/TaskBar.cjs +151 -0
  10. package/dist/cjs/Gantt/TaskBar.cjs.map +1 -0
  11. package/dist/cjs/Gantt/TaskList.cjs +13 -0
  12. package/dist/cjs/Gantt/TaskList.cjs.map +1 -0
  13. package/dist/cjs/Gantt/TimelineGrid.cjs +54 -0
  14. package/dist/cjs/Gantt/TimelineGrid.cjs.map +1 -0
  15. package/dist/cjs/Gantt/TimelineHeader.cjs +40 -0
  16. package/dist/cjs/Gantt/TimelineHeader.cjs.map +1 -0
  17. package/dist/cjs/Gantt/utils.cjs +105 -0
  18. package/dist/cjs/Gantt/utils.cjs.map +1 -0
  19. package/dist/cjs/index.cjs +21 -0
  20. package/dist/cjs/index.cjs.map +1 -0
  21. package/dist/esm/Gantt/DependencyLinks.mjs +101 -0
  22. package/dist/esm/Gantt/DependencyLinks.mjs.map +1 -0
  23. package/dist/esm/Gantt/Gantt.mjs +292 -0
  24. package/dist/esm/Gantt/Gantt.mjs.map +1 -0
  25. package/dist/esm/Gantt/Gantt.module.css.mjs +5 -0
  26. package/dist/esm/Gantt/Gantt.module.css.mjs.map +1 -0
  27. package/dist/esm/Gantt/TaskBar.mjs +149 -0
  28. package/dist/esm/Gantt/TaskBar.mjs.map +1 -0
  29. package/dist/esm/Gantt/TaskList.mjs +11 -0
  30. package/dist/esm/Gantt/TaskList.mjs.map +1 -0
  31. package/dist/esm/Gantt/TimelineGrid.mjs +52 -0
  32. package/dist/esm/Gantt/TimelineGrid.mjs.map +1 -0
  33. package/dist/esm/Gantt/TimelineHeader.mjs +38 -0
  34. package/dist/esm/Gantt/TimelineHeader.mjs.map +1 -0
  35. package/dist/esm/Gantt/utils.mjs +95 -0
  36. package/dist/esm/Gantt/utils.mjs.map +1 -0
  37. package/dist/esm/index.mjs +7 -0
  38. package/dist/esm/index.mjs.map +1 -0
  39. package/dist/styles.css +1 -0
  40. package/dist/styles.layer.css +1 -0
  41. package/dist/types/Gantt/DependencyLinks.d.ts +17 -0
  42. package/dist/types/Gantt/Gantt.d.ts +7 -0
  43. package/dist/types/Gantt/TaskBar.d.ts +18 -0
  44. package/dist/types/Gantt/TaskList.d.ts +14 -0
  45. package/dist/types/Gantt/TimelineGrid.d.ts +17 -0
  46. package/dist/types/Gantt/TimelineHeader.d.ts +16 -0
  47. package/dist/types/Gantt/index.d.ts +7 -0
  48. package/dist/types/Gantt/types.d.ts +60 -0
  49. package/dist/types/Gantt/utils.d.ts +54 -0
  50. package/dist/types/index.d.mts +3 -0
  51. package/dist/types/index.d.ts +3 -0
  52. package/package.json +44 -0
@@ -0,0 +1,17 @@
1
+ import type { Dayjs } from 'dayjs';
2
+ import React from 'react';
3
+ import type { GetStylesApi } from '@mantine/core';
4
+ import type { GanttFactory } from './types';
5
+ interface TimelineGridProps {
6
+ startDate: Dayjs;
7
+ endDate: Dayjs;
8
+ columnWidth: number;
9
+ rowCount: number;
10
+ rowHeight: number;
11
+ getStyles: GetStylesApi<GanttFactory>;
12
+ }
13
+ export declare function TimelineGrid({ startDate, endDate, columnWidth, rowCount, rowHeight, }: TimelineGridProps): React.JSX.Element;
14
+ export declare namespace TimelineGrid {
15
+ var displayName: string;
16
+ }
17
+ export {};
@@ -0,0 +1,16 @@
1
+ import { type Dayjs } from 'dayjs';
2
+ import React from 'react';
3
+ import type { GetStylesApi } from '@mantine/core';
4
+ import type { GanttFactory } from './types';
5
+ interface TimelineHeaderProps {
6
+ startDate: Dayjs;
7
+ endDate: Dayjs;
8
+ columnWidth: number;
9
+ getStyles: GetStylesApi<GanttFactory>;
10
+ totalWidth: number;
11
+ }
12
+ export declare function TimelineHeader({ startDate, endDate, columnWidth, totalWidth, }: TimelineHeaderProps): React.JSX.Element;
13
+ export declare namespace TimelineHeader {
14
+ var displayName: string;
15
+ }
16
+ export {};
@@ -0,0 +1,7 @@
1
+ export { Gantt } from './Gantt';
2
+ export { TaskBar } from './TaskBar';
3
+ export { TaskList } from './TaskList';
4
+ export { TimelineGrid } from './TimelineGrid';
5
+ export { TimelineHeader } from './TimelineHeader';
6
+ export type { GanttProps, GanttTask, GanttStylesNames, GanttCssVariables, GanttFactory, DragContext, } from './types';
7
+ export { dateToPixel, pixelToDate, snapToGrid, durationToPixels, pixelsToDuration, formatTaskDate, getTaskEndDate, calculateTimelineBounds, generateDayHeaders, generateWeekHeaders, } from './utils';
@@ -0,0 +1,60 @@
1
+ import type { BoxProps, ElementProps, Factory, MantineColor, StylesApiProps } from '@mantine/core';
2
+ /** Represents a single task in the Gantt chart */
3
+ export interface GanttTask {
4
+ /** Unique identifier for the task */
5
+ id: string;
6
+ /** Display name of the task */
7
+ label: string;
8
+ /** Start date in ISO format (YYYY-MM-DD) */
9
+ startDate: string;
10
+ /** Duration in days */
11
+ duration: number;
12
+ /** Progress percentage (0-100) */
13
+ progress: number;
14
+ /** IDs of tasks this task depends on */
15
+ dependencies?: string[];
16
+ /** Custom color for the task bar */
17
+ color?: MantineColor;
18
+ }
19
+ export type GanttStylesNames = 'root' | 'taskList' | 'taskListHeader' | 'taskListBody' | 'taskListRow' | 'taskListCell' | 'timeline' | 'timelineHeader' | 'timelineHeaderRow' | 'timelineHeaderCell' | 'weekHeader' | 'weekHeaderCell' | 'timelineBody' | 'timelineContent' | 'timelineRow' | 'timelineGrid' | 'gridLine' | 'taskBar' | 'taskBarLabel' | 'taskBarProgress' | 'resizeHandle' | 'resizeHandleLeft' | 'linkConnector';
20
+ export type GanttCssVariables = {
21
+ root: '--gantt-column-width' | '--gantt-row-height' | '--gantt-header-height' | '--gantt-task-list-width';
22
+ };
23
+ export interface GanttBaseProps {
24
+ /** Array of tasks to display */
25
+ tasks: GanttTask[];
26
+ /** Callback when a task is updated (moved or resized) */
27
+ onTaskUpdate?: (task: GanttTask) => void;
28
+ /** Callback when a task is clicked */
29
+ onTaskClick?: (task: GanttTask) => void;
30
+ /** Callback when a dependency link is created (fromTaskId, toTaskId) */
31
+ onLinkCreate?: (fromTaskId: string, toTaskId: string) => void;
32
+ /** Width of each day column in pixels, default 40 */
33
+ columnWidth?: number;
34
+ /** Height of each task row in pixels, default 44 */
35
+ rowHeight?: number;
36
+ /** Width of the task list panel in pixels, default 320 */
37
+ taskListWidth?: number;
38
+ /** Start date of the timeline, defaults to earliest task start - 7 days */
39
+ startDate?: Date;
40
+ /** End date of the timeline, defaults to latest task end + 7 days */
41
+ endDate?: Date;
42
+ /** View mode: 'day' | 'week' | 'month', default 'day' */
43
+ viewMode?: 'day' | 'week' | 'month';
44
+ /** Whether to show task titles on hover, default false */
45
+ showTitle?: boolean;
46
+ }
47
+ export type GanttFactory = Factory<{
48
+ props: GanttProps;
49
+ ref: HTMLDivElement;
50
+ stylesNames: GanttStylesNames;
51
+ vars: GanttCssVariables;
52
+ }>;
53
+ export interface GanttProps extends BoxProps, StylesApiProps<GanttFactory>, ElementProps<'div', 'onChange'>, GanttBaseProps {
54
+ }
55
+ /** Context for drag operations */
56
+ export interface DragContext {
57
+ type: 'move' | 'resize';
58
+ taskId: string;
59
+ initialX: number;
60
+ }
@@ -0,0 +1,54 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import type { GanttTask } from './types';
3
+ /**
4
+ * Convert a date to pixel position relative to timeline start
5
+ */
6
+ export declare function dateToPixel(date: string | Date | Dayjs, startDate: Dayjs, columnWidth: number): number;
7
+ /**
8
+ * Convert pixel position to date
9
+ */
10
+ export declare function pixelToDate(x: number, startDate: Dayjs, columnWidth: number): Dayjs;
11
+ /**
12
+ * Snap a value to the nearest grid cell
13
+ */
14
+ export declare function snapToGrid(value: number, gridSize: number): number;
15
+ /**
16
+ * Calculate pixel width from duration
17
+ */
18
+ export declare function durationToPixels(duration: number, columnWidth: number): number;
19
+ /**
20
+ * Calculate duration from pixel width
21
+ */
22
+ export declare function pixelsToDuration(pixels: number, columnWidth: number): number;
23
+ /**
24
+ * Generate timeline header data for days
25
+ */
26
+ export declare function generateDayHeaders(startDate: Dayjs, endDate: Dayjs): Array<{
27
+ date: Dayjs;
28
+ label: string;
29
+ isWeekend: boolean;
30
+ }>;
31
+ /**
32
+ * Generate week headers
33
+ */
34
+ export declare function generateWeekHeaders(startDate: Dayjs, endDate: Dayjs): Array<{
35
+ startDate: Dayjs;
36
+ endDate: Dayjs;
37
+ label: string;
38
+ days: number;
39
+ }>;
40
+ /**
41
+ * Calculate timeline bounds from tasks
42
+ */
43
+ export declare function calculateTimelineBounds(tasks: GanttTask[], startDate?: Date, endDate?: Date, padding?: number): {
44
+ start: Dayjs;
45
+ end: Dayjs;
46
+ };
47
+ /**
48
+ * Format date for display in task list
49
+ */
50
+ export declare function formatTaskDate(date: string | Date | Dayjs): string;
51
+ /**
52
+ * Calculate end date from start date and duration
53
+ */
54
+ export declare function getTaskEndDate(startDate: string, duration: number): Dayjs;
@@ -0,0 +1,3 @@
1
+ export { Gantt } from './Gantt';
2
+ export type { GanttProps, GanttTask, GanttStylesNames, GanttFactory, GanttCssVariables, } from './Gantt';
3
+ export { dateToPixel, pixelToDate, snapToGrid, durationToPixels, formatTaskDate, getTaskEndDate, calculateTimelineBounds, } from './Gantt';
@@ -0,0 +1,3 @@
1
+ export { Gantt } from './Gantt';
2
+ export type { GanttProps, GanttTask, GanttStylesNames, GanttFactory, GanttCssVariables, } from './Gantt';
3
+ export { dateToPixel, pixelToDate, snapToGrid, durationToPixels, formatTaskDate, getTaskEndDate, calculateTimelineBounds, } from './Gantt';
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "mantine-gantt",
3
+ "version": "0.0.1",
4
+ "description": "A gantt chart component for mantine",
5
+ "homepage": "https://github.com/WojakGra/mantine-gantt#readme",
6
+ "packageManager": "yarn@4.0.1",
7
+ "license": "MIT",
8
+ "author": "Jakub Wojdziak <jakub@wojak.works>",
9
+ "keywords": [
10
+ "extension",
11
+ "gantt",
12
+ "mantine"
13
+ ],
14
+ "main": "./dist/cjs/index.cjs",
15
+ "module": "./dist/esm/index.mjs",
16
+ "types": "./dist/types/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "import": {
20
+ "types": "./dist/types/index.d.mts",
21
+ "default": "./dist/esm/index.mjs"
22
+ },
23
+ "require": {
24
+ "types": "./dist/types/index.d.ts",
25
+ "default": "./dist/cjs/index.cjs"
26
+ }
27
+ },
28
+ "./styles.css": "./dist/styles.css",
29
+ "./styles.layer.css": "./dist/styles.layer.css"
30
+ },
31
+ "repository": "https://github.com/WojakGra/mantine-gantt.git",
32
+ "peerDependencies": {
33
+ "@mantine/core": ">=7.0.0",
34
+ "@mantine/hooks": ">=7.0.0",
35
+ "react": "^18.x || ^19.x",
36
+ "react-dom": "^18.x || ^19.x"
37
+ },
38
+ "dependencies": {
39
+ "@dnd-kit/core": "^6.1.0",
40
+ "@dnd-kit/utilities": "^3.2.2",
41
+ "dayjs": "^1.11.10"
42
+ },
43
+ "bugs": "https://github.com/WojakGra/mantine-gantt/issues"
44
+ }