react-timelane 0.0.0 → 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 (110) hide show
  1. package/dist/components/TimelineAside.d.ts +13 -0
  2. package/dist/components/TimelineBackground.d.ts +5 -0
  3. package/dist/components/TimelineBody.d.ts +13 -0
  4. package/dist/components/TimelineHeader/DaysHeader.d.ts +15 -0
  5. package/dist/components/TimelineHeader/MonthsHeader.d.ts +15 -0
  6. package/dist/components/TimelineHeader/TimelineHeader.d.ts +24 -0
  7. package/dist/components/TimelineHeader/WeeksHeader.d.ts +15 -0
  8. package/dist/components/TimelineHeader/index.d.ts +5 -0
  9. package/dist/components/TimelineHeader/renderingUtils.d.ts +4 -0
  10. package/dist/components/TimelineSelectionLayer.d.ts +6 -0
  11. package/dist/components/TimelineSettingsContext.d.ts +7 -0
  12. package/dist/components/TimelineSettingsProvider.d.ts +7 -0
  13. package/dist/components/TimelineWrapper.d.ts +17 -0
  14. package/dist/components/core/CoreItem/CoreItemComponent.d.ts +14 -0
  15. package/dist/components/core/CoreItem/DragResizeComponent.d.ts +20 -0
  16. package/dist/components/core/CoreSwimlane/AvailableSpaceIndicator.d.ts +21 -0
  17. package/dist/components/core/CoreSwimlane/CoreSwimlane.d.ts +16 -0
  18. package/dist/components/core/CoreSwimlane/DropPreview.d.ts +9 -0
  19. package/dist/components/core/CoreSwimlane/DropTarget.d.ts +11 -0
  20. package/dist/components/core/CoreSwimlane/OverlapIndicator.d.ts +6 -0
  21. package/dist/components/core/CoreSwimlane/utils.d.ts +13 -0
  22. package/dist/components/core/utils.d.ts +15 -0
  23. package/dist/components/layout/TimelineLayout.d.ts +23 -0
  24. package/dist/hooks/useScroll.d.ts +10 -0
  25. package/dist/hooks/useTimelineContext.d.ts +1 -0
  26. package/dist/index.d.ts +13 -0
  27. package/dist/react-timelane.css +1 -0
  28. package/dist/react-timelane.js +4744 -0
  29. package/dist/types/AvailableSpace.d.ts +6 -0
  30. package/dist/types/CoreItem.d.ts +12 -0
  31. package/dist/types/DateBounds.d.ts +4 -0
  32. package/dist/types/Dimensions.d.ts +4 -0
  33. package/dist/types/GrabInfo.d.ts +5 -0
  34. package/dist/types/Grid.d.ts +6 -0
  35. package/dist/types/OffsetBounds.d.ts +4 -0
  36. package/dist/types/Pixels.d.ts +4 -0
  37. package/{src/types/Position.ts → dist/types/Position.d.ts} +2 -2
  38. package/dist/types/Rectangle.d.ts +6 -0
  39. package/dist/types/SwimlaneT.d.ts +5 -0
  40. package/dist/types/TimeRange.d.ts +4 -0
  41. package/dist/types/TimelineSettings.d.ts +11 -0
  42. package/dist/types/index.d.ts +15 -0
  43. package/package.json +1 -1
  44. package/vite.config.ts +1 -1
  45. package/.github/workflows/static.yml +0 -55
  46. package/docs/README.md +0 -54
  47. package/docs/eslint.config.js +0 -28
  48. package/docs/index.html +0 -12
  49. package/docs/package-lock.json +0 -5101
  50. package/docs/package.json +0 -35
  51. package/docs/src/App.css +0 -5
  52. package/docs/src/App.tsx +0 -59
  53. package/docs/src/assets/react.svg +0 -1
  54. package/docs/src/components/AllocationComponent.tsx +0 -82
  55. package/docs/src/components/Timeline.tsx +0 -183
  56. package/docs/src/constants.ts +0 -42
  57. package/docs/src/hooks/useLocalStorage.ts +0 -21
  58. package/docs/src/main.tsx +0 -9
  59. package/docs/src/models/Allocation.ts +0 -11
  60. package/docs/src/models/AllocationId.ts +0 -1
  61. package/docs/src/models/Resource.ts +0 -8
  62. package/docs/src/models/ResourceId.ts +0 -1
  63. package/docs/src/vite-env.d.ts +0 -1
  64. package/docs/tsconfig.json +0 -27
  65. package/docs/vite.config.ts +0 -8
  66. package/src/components/Timeline.scss +0 -297
  67. package/src/components/TimelineAside.tsx +0 -81
  68. package/src/components/TimelineBackground.tsx +0 -53
  69. package/src/components/TimelineBody.tsx +0 -54
  70. package/src/components/TimelineHeader/DaysHeader.tsx +0 -44
  71. package/src/components/TimelineHeader/MonthsHeader.tsx +0 -62
  72. package/src/components/TimelineHeader/TimelineHeader.tsx +0 -64
  73. package/src/components/TimelineHeader/WeeksHeader.tsx +0 -63
  74. package/src/components/TimelineHeader/index.ts +0 -9
  75. package/src/components/TimelineHeader/renderingUtils.tsx +0 -57
  76. package/src/components/TimelineSelectionLayer.tsx +0 -179
  77. package/src/components/TimelineSettingsContext.tsx +0 -27
  78. package/src/components/TimelineSettingsProvider.tsx +0 -24
  79. package/src/components/TimelineWrapper.tsx +0 -51
  80. package/src/components/core/CoreItem/CoreItemComponent.tsx +0 -69
  81. package/src/components/core/CoreItem/DragResizeComponent.tsx +0 -180
  82. package/src/components/core/CoreSwimlane/AvailableSpaceIndicator.tsx +0 -156
  83. package/src/components/core/CoreSwimlane/CoreSwimlane.tsx +0 -245
  84. package/src/components/core/CoreSwimlane/DropPreview.tsx +0 -30
  85. package/src/components/core/CoreSwimlane/DropTarget.tsx +0 -83
  86. package/src/components/core/CoreSwimlane/OverlapIndicator.tsx +0 -22
  87. package/src/components/core/CoreSwimlane/utils.ts +0 -375
  88. package/src/components/core/utils.ts +0 -154
  89. package/src/components/layout/TimelineLayout.tsx +0 -93
  90. package/src/components/layout/layout.scss +0 -107
  91. package/src/global.d.ts +0 -9
  92. package/src/hooks/useScroll.tsx +0 -71
  93. package/src/hooks/useTimelineContext.tsx +0 -6
  94. package/src/index.ts +0 -15
  95. package/src/types/AvailableSpace.ts +0 -6
  96. package/src/types/CoreItem.ts +0 -23
  97. package/src/types/DateBounds.ts +0 -4
  98. package/src/types/Dimensions.ts +0 -4
  99. package/src/types/GrabInfo.ts +0 -6
  100. package/src/types/Grid.ts +0 -6
  101. package/src/types/OffsetBounds.ts +0 -4
  102. package/src/types/Pixels.ts +0 -4
  103. package/src/types/Rectangle.ts +0 -6
  104. package/src/types/SwimlaneT.ts +0 -6
  105. package/src/types/TimeRange.ts +0 -4
  106. package/src/types/TimelineSettings.ts +0 -11
  107. package/src/types/index.ts +0 -15
  108. package/tsconfig.json +0 -32
  109. /package/{src/types/ItemId.ts → dist/types/ItemId.d.ts} +0 -0
  110. /package/{src/types/SwimlaneId.ts → dist/types/SwimlaneId.d.ts} +0 -0
package/docs/package.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "name": "react-timelane-docs",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "tsc -b && vite build",
9
- "lint": "eslint .",
10
- "preview": "vite preview"
11
- },
12
- "dependencies": {
13
- "@atlaskit/pragmatic-drag-and-drop": "^1.7.2",
14
- "@emotion/react": "^11.14.0",
15
- "@emotion/styled": "^11.14.0",
16
- "@mui/material": "^7.1.1",
17
- "date-fns": "^4.1.0",
18
- "react": "^19.1.0",
19
- "react-dom": "^19.1.0",
20
- "react-timeline-calendar": "^1.0.3"
21
- },
22
- "devDependencies": {
23
- "@eslint/js": "^9.25.0",
24
- "@types/react": "^19.1.2",
25
- "@types/react-dom": "^19.1.2",
26
- "@vitejs/plugin-react": "^4.4.1",
27
- "eslint": "^9.25.0",
28
- "eslint-plugin-react-hooks": "^5.2.0",
29
- "eslint-plugin-react-refresh": "^0.4.19",
30
- "globals": "^16.0.0",
31
- "typescript": "~5.8.3",
32
- "typescript-eslint": "^8.30.1",
33
- "vite": "^6.3.5"
34
- }
35
- }
package/docs/src/App.css DELETED
@@ -1,5 +0,0 @@
1
- html {
2
- font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell,
3
- Noto Sans, sans-serif, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
4
- sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
5
- }
package/docs/src/App.tsx DELETED
@@ -1,59 +0,0 @@
1
- import { useState } from "react";
2
- import Timeline from "./components/Timeline";
3
- import type Allocation from "./models/Allocation";
4
- import useLocalStorage from "./hooks/useLocalStorage";
5
- import { DEFAULT_ALLOCATIONS, DEFAULT_RESOURCES } from "./constants";
6
- import { TimelineWrapper, type TimelineSettings } from "react-timelane";
7
- import "react-timelane/style.css";
8
- import "./App.css";
9
-
10
- function App() {
11
- const [allocations, setAllocations] = useLocalStorage<Allocation[]>(
12
- "allocations",
13
- DEFAULT_ALLOCATIONS
14
- );
15
-
16
- const [focusedDay, setFocusedDay] = useState<Date | null>(null);
17
-
18
- const defaultSettings: TimelineSettings = {
19
- showMonths: true,
20
- showWeeks: true,
21
- showDays: true,
22
- start: new Date(2025, 3, 1),
23
- end: new Date(2025, 6, 2),
24
- pixelsPerDay: 50,
25
- pixelsPerResource: 100,
26
- allowOverlaps: false,
27
- focusedDate: null,
28
- };
29
-
30
- return (
31
- <>
32
- <h1>Timeline Demo</h1>
33
- <div style={{ width: "100%", height: "600px", border: "1px solid #ccc" }}>
34
- <TimelineWrapper {...defaultSettings}>
35
- <Timeline
36
- resources={DEFAULT_RESOURCES}
37
- allocations={allocations}
38
- onAreaSearchClick={() => {}}
39
- onAllocationCreate={(newAllocation: Allocation) => {
40
- setAllocations((prev) => [...prev, newAllocation]);
41
- }}
42
- onAllocationUpdate={(updatedAllocation: Allocation) => {
43
- console.log("allocation update,", updatedAllocation);
44
- setAllocations((prev) =>
45
- prev.map((a) => {
46
- return a.id === updatedAllocation.id ? updatedAllocation : a;
47
- })
48
- );
49
- }}
50
- focusedDay={focusedDay}
51
- setFocusedDay={setFocusedDay}
52
- />
53
- </TimelineWrapper>
54
- </div>
55
- </>
56
- );
57
- }
58
-
59
- export default App;
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
@@ -1,82 +0,0 @@
1
- import { type MouseEvent, useRef } from "react";
2
- import { format } from "date-fns";
3
- import type Allocation from "../models/Allocation";
4
- import { Tooltip } from "@mui/material";
5
-
6
- const SCALE_THRESHOLD_IN_PX = 30;
7
-
8
- interface AllocationComponentProps {
9
- allocation: Allocation;
10
- isSelected?: boolean;
11
- isDragged?: boolean;
12
- onClick: (allocation: Allocation, e: MouseEvent) => void;
13
- onContextMenu: (allocation: Allocation, e: MouseEvent) => void;
14
- }
15
- export default function AllocationComponent({
16
- allocation,
17
- isSelected = false,
18
- isDragged = false,
19
- onClick,
20
- onContextMenu,
21
- }: AllocationComponentProps) {
22
- const ref = useRef<HTMLDivElement>(null);
23
-
24
- let scale = 1;
25
-
26
- if (ref.current) {
27
- const height = ref.current.getBoundingClientRect().height;
28
-
29
- if (height > 0 && height < SCALE_THRESHOLD_IN_PX) {
30
- scale = height / SCALE_THRESHOLD_IN_PX;
31
- }
32
- }
33
-
34
- return (
35
- <Tooltip
36
- arrow
37
- followCursor
38
- hidden={isDragged}
39
- title={
40
- <div
41
- style={{
42
- fontSize: "1.6em",
43
- }}
44
- >
45
- <div>
46
- {format(new Date(allocation.start), "yyyy-MM-dd")}
47
- &nbsp;-&nbsp;
48
- {format(new Date(allocation.end), "yyyy-MM-dd")}
49
- </div>
50
- <div>{allocation.description}</div>
51
- </div>
52
- }
53
- >
54
- <div
55
- className={`timeline-allocation ${
56
- isSelected ? "timeline-allocation-selected" : ""
57
- }`}
58
- onClick={(e) => onClick(allocation, e)}
59
- onContextMenu={(e) => {
60
- e.preventDefault();
61
- e.stopPropagation();
62
- onContextMenu(allocation, e);
63
- }}
64
- ref={ref}
65
- style={{
66
- background: allocation.color,
67
- }}
68
- data-allocation-id={`${allocation.id}`}
69
- >
70
- <div
71
- className="timeline-allocation-title"
72
- style={{
73
- transform: `scale(${scale})`,
74
- }}
75
- >
76
- {allocation.name} (#{allocation.id})
77
- </div>
78
- <div style={{ fontSize: "small" }}>{allocation.description}</div>
79
- </div>
80
- </Tooltip>
81
- );
82
- }
@@ -1,183 +0,0 @@
1
- import { addDays, min } from "date-fns";
2
- import { useState, type MouseEvent } from "react";
3
- import {
4
- type AvailableSpace,
5
- type SwimlaneT,
6
- type CoreItem,
7
- type ItemId,
8
- TimelineLayout,
9
- TimelineHeader,
10
- TimelineAside,
11
- TimelineBackground,
12
- TimelineBody,
13
- TimelineSelectionLayer,
14
- useScroll,
15
- } from "react-timelane";
16
- import type Allocation from "../models/Allocation";
17
- import type Resource from "../models/Resource";
18
- import AllocationComponent from "./AllocationComponent";
19
- import {
20
- DEFAULT_ALLOCATION_COLOR,
21
- DEFAULT_ALLOCATION_DESCRIPTION,
22
- DEFAULT_ALLOCATION_NAME,
23
- } from "../constants";
24
-
25
- interface TimelineProps {
26
- resources: Resource[];
27
- allocations: Allocation[];
28
- focusedDay?: Date | null;
29
- setFocusedResource?: (resource: Resource | null) => void;
30
- setFocusedDay?: (day: Date | null) => void;
31
- onAllocationCreate?: (allocation: Allocation) => void;
32
- onAllocationUpdate?: (allocation: Allocation) => void;
33
- onAllocationDelete?: (allocation: Allocation) => void;
34
- onAllocationClick?: (allocation: Allocation, e: MouseEvent | null) => void;
35
- onAllocationContextMenu?: (allocation: Allocation, e: MouseEvent) => void;
36
- onAreaSearchClick: (area: Resource) => void;
37
- onAreaClick?: (area: Resource, e: MouseEvent) => void;
38
- }
39
-
40
- export default function Timeline({
41
- resources,
42
- allocations,
43
- focusedDay,
44
- setFocusedDay,
45
- onAllocationCreate = () => {},
46
- onAllocationUpdate = () => {},
47
- }: TimelineProps) {
48
- function handleResourceDoubleClick(
49
- resource: Resource,
50
- when: Date,
51
- availableSpace: AvailableSpace | null
52
- ) {
53
- if (!availableSpace) return;
54
-
55
- const halfSize = Math.floor(resource.capacity / 2);
56
- const start: Date = when;
57
- const end: Date = min([availableSpace.end, addDays(start, 7)]);
58
- const offset: number = availableSpace.minOffset;
59
- const size: number = Math.min(
60
- availableSpace.maxOffset - availableSpace.minOffset,
61
- halfSize
62
- );
63
-
64
- const newAllocation: Allocation = {
65
- id: allocations.length + 1,
66
- name: DEFAULT_ALLOCATION_NAME,
67
- resourceId: resource.id,
68
- description: DEFAULT_ALLOCATION_DESCRIPTION,
69
- start: start,
70
- end: end,
71
- size: size,
72
- offset: offset,
73
- color: DEFAULT_ALLOCATION_COLOR,
74
- };
75
-
76
- onAllocationCreate(newAllocation);
77
- }
78
-
79
- const [selection, setSelection] = useState<ItemId[]>([]);
80
-
81
- const lanes: SwimlaneT[] = resources.map((resource) => ({
82
- id: resource.id,
83
- capacity: resource.capacity,
84
- }));
85
-
86
- const items: CoreItem<Allocation>[] = allocations.map((allocation) => ({
87
- id: allocation.id,
88
- swimlaneId: allocation.resourceId,
89
- start: allocation.start,
90
- end: allocation.end,
91
- size: allocation.size,
92
- offset: allocation.offset,
93
- payload: allocation,
94
- }));
95
-
96
- const { scrollTo } = useScroll();
97
-
98
- return (
99
- <TimelineLayout>
100
- <TimelineLayout.Header>
101
- <TimelineHeader
102
- focusedDay={focusedDay}
103
- setFocusedDay={setFocusedDay}
104
- onDayClick={({ day }) => {
105
- console.log("day clicked", day);
106
- }}
107
- onMonthClick={({ firstDay }) => {
108
- console.log("month clicked", firstDay);
109
- }}
110
- onWeekClick={({ firstDay }) => {
111
- console.log("week clicked", firstDay);
112
- }}
113
- />
114
- </TimelineLayout.Header>
115
- <TimelineLayout.Body>
116
- <TimelineSelectionLayer
117
- onSelect={(selection) => {
118
- console.info(selection);
119
- setSelection(selection);
120
- }}
121
- >
122
- <TimelineBody
123
- lanes={lanes}
124
- items={items}
125
- renderItem={(item, isDragged) => (
126
- <AllocationComponent
127
- allocation={item.payload}
128
- isDragged={isDragged}
129
- onClick={() => {
130
- scrollTo(item.id);
131
- }}
132
- onContextMenu={() => {}}
133
- isSelected={selection.includes(item.id)}
134
- />
135
- )}
136
- onLaneClick={(lane, when) => {
137
- console.log("clicked", lane);
138
- scrollTo({ horz: when });
139
- }}
140
- onLaneDoubleClick={(lane, when, availableSpace) => {
141
- console.log("double clicked", lane);
142
-
143
- const resource: Resource | undefined = resources.find(
144
- (a) => a.id === lane.id
145
- );
146
-
147
- if (resource !== undefined) {
148
- handleResourceDoubleClick(resource, when, availableSpace);
149
- }
150
- }}
151
- onItemUpdate={(item) => {
152
- console.log("item update", item);
153
-
154
- const updatedAllocation: Allocation = {
155
- ...item.payload,
156
- resourceId: item.swimlaneId,
157
- start: item.start,
158
- end: item.end,
159
- size: item.size,
160
- offset: item.offset,
161
- };
162
-
163
- onAllocationUpdate(updatedAllocation);
164
- }}
165
- />
166
- </TimelineSelectionLayer>
167
- </TimelineLayout.Body>
168
- <TimelineLayout.Background>
169
- <TimelineBackground focusedDay={focusedDay} />
170
- </TimelineLayout.Background>
171
- <TimelineLayout.Aside>
172
- <TimelineAside
173
- swimlanes={lanes}
174
- onSwimlaneHeaderClick={(lane) => {
175
- scrollTo({ vert: lane.id });
176
- }}
177
- renderSwimlaneHeader={(lane) => <div>{lane.id}</div>}
178
- />
179
- </TimelineLayout.Aside>
180
- <TimelineLayout.Corner />
181
- </TimelineLayout>
182
- );
183
- }
@@ -1,42 +0,0 @@
1
- import type Allocation from "./models/Allocation";
2
- import type Resource from "./models/Resource";
3
-
4
- export const DEFAULT_ALLOCATION_COLOR = "#A7C7E7";
5
- export const DEFAULT_ALLOCATION_DESCRIPTION = "empty description";
6
- export const DEFAULT_ALLOCATION_NAME = "New Allocation";
7
-
8
- export const DEFAULT_RESOURCES: Resource[] = [
9
- { id: 0, capacity: 100, name: "Area 1", description: "" },
10
- { id: 1, capacity: 100, name: "Area 2", description: "" },
11
- { id: 2, capacity: 100, name: "Area 3", description: "" },
12
- { id: 3, capacity: 100, name: "Area 4", description: "" },
13
- { id: 5, capacity: 100, name: "Area 5", description: "" },
14
- { id: 6, capacity: 100, name: "Area 6", description: "" },
15
- { id: 7, capacity: 100, name: "Area 7", description: "" },
16
- { id: 8, capacity: 100, name: "Area 8", description: "" },
17
- ];
18
-
19
- export const DEFAULT_ALLOCATIONS: Allocation[] = [
20
- {
21
- id: 0,
22
- name: "Allocation 0",
23
- start: new Date(2025, 4, 1),
24
- end: new Date(2025, 4, 20),
25
- size: 50,
26
- offset: 0,
27
- color: DEFAULT_ALLOCATION_COLOR,
28
- description: "",
29
- resourceId: 0,
30
- },
31
- {
32
- id: 1,
33
- name: "Allocation 1",
34
- start: new Date(2025, 4, 10),
35
- end: new Date(2025, 4, 25),
36
- size: 50,
37
- offset: 50,
38
- color: DEFAULT_ALLOCATION_COLOR,
39
- description: "",
40
- resourceId: 1,
41
- },
42
- ];
@@ -1,21 +0,0 @@
1
- import { useState, useEffect, type Dispatch, type SetStateAction } from "react";
2
-
3
- export default function useLocalStorage<T>(
4
- key: string,
5
- defaultValue: T
6
- ): [T, Dispatch<SetStateAction<T>>] {
7
- const [value, setValue] = useState<T>(() => {
8
- const storedValue = localStorage.getItem(key);
9
- if (storedValue) {
10
- return JSON.parse(storedValue);
11
- }
12
- return defaultValue;
13
- });
14
-
15
- useEffect(() => {
16
- if (value === undefined) return;
17
- localStorage.setItem(key, JSON.stringify(value));
18
- }, [value, key]);
19
-
20
- return [value, setValue];
21
- }
package/docs/src/main.tsx DELETED
@@ -1,9 +0,0 @@
1
- import { StrictMode } from "react";
2
- import { createRoot } from "react-dom/client";
3
- import App from "./App.tsx";
4
-
5
- createRoot(document.getElementById("root")!).render(
6
- <StrictMode>
7
- <App />
8
- </StrictMode>
9
- );
@@ -1,11 +0,0 @@
1
- export default interface Allocation {
2
- id: number;
3
- resourceId: number;
4
- name: string;
5
- description: string;
6
- start: Date;
7
- end: Date;
8
- size: number;
9
- offset: number;
10
- color: string;
11
- }
@@ -1 +0,0 @@
1
- export type AllocationId = number;
@@ -1,8 +0,0 @@
1
- import type { ResourceId } from "./ResourceId";
2
-
3
- export default interface Resource {
4
- id: ResourceId;
5
- name: string;
6
- description: string;
7
- capacity: number;
8
- }
@@ -1 +0,0 @@
1
- export type ResourceId = number;
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2020",
5
- "useDefineForClassFields": true,
6
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
- "module": "ESNext",
8
- "skipLibCheck": true,
9
-
10
- /* Bundler mode */
11
- "moduleResolution": "bundler",
12
- "allowImportingTsExtensions": true,
13
- "verbatimModuleSyntax": true,
14
- "moduleDetection": "force",
15
- "noEmit": true,
16
- "jsx": "react-jsx",
17
-
18
- /* Linting */
19
- "strict": true,
20
- "noUnusedLocals": true,
21
- "noUnusedParameters": true,
22
- "erasableSyntaxOnly": true,
23
- "noFallthroughCasesInSwitch": true,
24
- "noUncheckedSideEffectImports": true
25
- },
26
- "include": ["src"]
27
- }
@@ -1,8 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import react from "@vitejs/plugin-react";
3
-
4
- // https://vite.dev/config/
5
- export default defineConfig({
6
- plugins: [react()],
7
- base: "/react-timelane/",
8
- });