react-timelane 0.0.0
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.
- package/.github/workflows/static.yml +55 -0
- package/README.md +54 -0
- package/docs/README.md +54 -0
- package/docs/eslint.config.js +28 -0
- package/docs/index.html +12 -0
- package/docs/package-lock.json +5101 -0
- package/docs/package.json +35 -0
- package/docs/src/App.css +5 -0
- package/docs/src/App.tsx +59 -0
- package/docs/src/assets/react.svg +1 -0
- package/docs/src/components/AllocationComponent.tsx +82 -0
- package/docs/src/components/Timeline.tsx +183 -0
- package/docs/src/constants.ts +42 -0
- package/docs/src/hooks/useLocalStorage.ts +21 -0
- package/docs/src/main.tsx +9 -0
- package/docs/src/models/Allocation.ts +11 -0
- package/docs/src/models/AllocationId.ts +1 -0
- package/docs/src/models/Resource.ts +8 -0
- package/docs/src/models/ResourceId.ts +1 -0
- package/docs/src/vite-env.d.ts +1 -0
- package/docs/tsconfig.json +27 -0
- package/docs/vite.config.ts +8 -0
- package/eslint.config.js +28 -0
- package/index.html +13 -0
- package/package.json +43 -0
- package/src/components/Timeline.scss +297 -0
- package/src/components/TimelineAside.tsx +81 -0
- package/src/components/TimelineBackground.tsx +53 -0
- package/src/components/TimelineBody.tsx +54 -0
- package/src/components/TimelineHeader/DaysHeader.tsx +44 -0
- package/src/components/TimelineHeader/MonthsHeader.tsx +62 -0
- package/src/components/TimelineHeader/TimelineHeader.tsx +64 -0
- package/src/components/TimelineHeader/WeeksHeader.tsx +63 -0
- package/src/components/TimelineHeader/index.ts +9 -0
- package/src/components/TimelineHeader/renderingUtils.tsx +57 -0
- package/src/components/TimelineSelectionLayer.tsx +179 -0
- package/src/components/TimelineSettingsContext.tsx +27 -0
- package/src/components/TimelineSettingsProvider.tsx +24 -0
- package/src/components/TimelineWrapper.tsx +51 -0
- package/src/components/core/CoreItem/CoreItemComponent.tsx +69 -0
- package/src/components/core/CoreItem/DragResizeComponent.tsx +180 -0
- package/src/components/core/CoreSwimlane/AvailableSpaceIndicator.tsx +156 -0
- package/src/components/core/CoreSwimlane/CoreSwimlane.tsx +245 -0
- package/src/components/core/CoreSwimlane/DropPreview.tsx +30 -0
- package/src/components/core/CoreSwimlane/DropTarget.tsx +83 -0
- package/src/components/core/CoreSwimlane/OverlapIndicator.tsx +22 -0
- package/src/components/core/CoreSwimlane/utils.ts +375 -0
- package/src/components/core/utils.ts +154 -0
- package/src/components/layout/TimelineLayout.tsx +93 -0
- package/src/components/layout/layout.scss +107 -0
- package/src/global.d.ts +9 -0
- package/src/hooks/useScroll.tsx +71 -0
- package/src/hooks/useTimelineContext.tsx +6 -0
- package/src/index.ts +15 -0
- package/src/types/AvailableSpace.ts +6 -0
- package/src/types/CoreItem.ts +23 -0
- package/src/types/DateBounds.ts +4 -0
- package/src/types/Dimensions.ts +4 -0
- package/src/types/GrabInfo.ts +6 -0
- package/src/types/Grid.ts +6 -0
- package/src/types/ItemId.ts +1 -0
- package/src/types/OffsetBounds.ts +4 -0
- package/src/types/Pixels.ts +4 -0
- package/src/types/Position.ts +4 -0
- package/src/types/Rectangle.ts +6 -0
- package/src/types/SwimlaneId.ts +1 -0
- package/src/types/SwimlaneT.ts +6 -0
- package/src/types/TimeRange.ts +4 -0
- package/src/types/TimelineSettings.ts +11 -0
- package/src/types/index.ts +15 -0
- package/tsconfig.json +32 -0
- package/vite.config.ts +32 -0
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ItemId, SwimlaneId } from "../types";
|
|
2
|
+
import { useTimelineContext } from "./useTimelineContext";
|
|
3
|
+
import { dateToPixel } from "../components/core/utils";
|
|
4
|
+
|
|
5
|
+
export const useScroll = () => {
|
|
6
|
+
const { settings } = useTimelineContext();
|
|
7
|
+
|
|
8
|
+
function scrollTo(destination: { horz?: Date; vert?: SwimlaneId } | ItemId) {
|
|
9
|
+
if (destination instanceof Object) {
|
|
10
|
+
if (destination.horz !== undefined) {
|
|
11
|
+
scrollToDate(destination.horz);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (destination.vert !== undefined) {
|
|
15
|
+
scrollToLane(destination.vert);
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
scrollToItem(destination);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function scrollToDate(date: Date) {
|
|
23
|
+
window.requestAnimationFrame(() => {
|
|
24
|
+
const el: HTMLElement | null = document.getElementById(
|
|
25
|
+
"timeline-background-date-anchor"
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (el) {
|
|
29
|
+
const offsetLeft: number = dateToPixel(date, settings.start, settings);
|
|
30
|
+
|
|
31
|
+
el.style.setProperty("left", `${offsetLeft}px`);
|
|
32
|
+
|
|
33
|
+
el.scrollIntoView({
|
|
34
|
+
block: "nearest",
|
|
35
|
+
inline: "center",
|
|
36
|
+
behavior: "smooth",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function scrollToLane(laneId: SwimlaneId) {
|
|
43
|
+
window.requestAnimationFrame(() => {
|
|
44
|
+
const el: HTMLElement | null = document.getElementById(
|
|
45
|
+
`timeline-swimlane-${laneId}`
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (el) {
|
|
49
|
+
el.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function scrollToItem(itemId: ItemId) {
|
|
55
|
+
window.requestAnimationFrame(() => {
|
|
56
|
+
const el: HTMLElement | null = document.getElementById(
|
|
57
|
+
`timeline-item-${itemId}`
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if (el) {
|
|
61
|
+
el.scrollIntoView({
|
|
62
|
+
block: "center",
|
|
63
|
+
inline: "center",
|
|
64
|
+
behavior: "smooth",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return { scrollTo, scrollToDate, scrollToItem, scrollToLane };
|
|
71
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { default as TimelineLayout } from "./components/layout/TimelineLayout";
|
|
2
|
+
export { default as TimelineAside } from "./components/TimelineAside";
|
|
3
|
+
export { default as TimelineBackground } from "./components/TimelineBackground";
|
|
4
|
+
export * from "./components/TimelineHeader";
|
|
5
|
+
export { default as TimelineWrapper } from "./components/TimelineWrapper";
|
|
6
|
+
export { default as CoreSwimlane } from "./components/core/CoreSwimlane/CoreSwimlane";
|
|
7
|
+
export { TimelineBody } from "./components/TimelineBody";
|
|
8
|
+
export { TimelineSelectionLayer } from "./components/TimelineSelectionLayer";
|
|
9
|
+
|
|
10
|
+
export * from "./types";
|
|
11
|
+
export * from "./components/core/utils";
|
|
12
|
+
export * from "./components/core/CoreSwimlane/utils";
|
|
13
|
+
|
|
14
|
+
export { useScroll } from "./hooks/useScroll";
|
|
15
|
+
export { useTimelineContext } from "./hooks/useTimelineContext";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ItemId } from "./ItemId";
|
|
2
|
+
import { SwimlaneId } from "./SwimlaneId";
|
|
3
|
+
|
|
4
|
+
export type CoreItem<T = void> = {
|
|
5
|
+
id: ItemId;
|
|
6
|
+
swimlaneId: SwimlaneId;
|
|
7
|
+
start: Date;
|
|
8
|
+
end: Date;
|
|
9
|
+
size: number;
|
|
10
|
+
offset: number;
|
|
11
|
+
payload: T;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function isCoreItem(a: object): a is CoreItem {
|
|
15
|
+
return (
|
|
16
|
+
"id" in a &&
|
|
17
|
+
"swimlaneId" in a &&
|
|
18
|
+
"start" in a &&
|
|
19
|
+
"end" in a &&
|
|
20
|
+
"size" in a &&
|
|
21
|
+
"offset" in a
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ItemId = number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SwimlaneId = number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { type TimeRange } from "./TimeRange";
|
|
2
|
+
export { type Pixels } from "./Pixels";
|
|
3
|
+
export { type Rectangle } from "./Rectangle";
|
|
4
|
+
export { type Position } from "./Position";
|
|
5
|
+
export { type Grid } from "./Grid";
|
|
6
|
+
export { type ItemId } from "./ItemId";
|
|
7
|
+
export { type AvailableSpace } from "./AvailableSpace";
|
|
8
|
+
export { type CoreItem, isCoreItem } from "./CoreItem";
|
|
9
|
+
export { type Dimensions } from "./Dimensions";
|
|
10
|
+
export { type GrabInfo } from "./GrabInfo";
|
|
11
|
+
export { type SwimlaneId } from "./SwimlaneId";
|
|
12
|
+
export { type SwimlaneT } from "./SwimlaneT";
|
|
13
|
+
export { type DateBounds } from "./DateBounds";
|
|
14
|
+
export { type OffsetBounds } from "./OffsetBounds";
|
|
15
|
+
export { type TimelineSettings } from "./TimelineSettings";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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": false,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"allowSyntheticDefaultImports": true,
|
|
18
|
+
"allowArbitraryExtensions": true,
|
|
19
|
+
"allowJs": true,
|
|
20
|
+
"isolatedModules": true,
|
|
21
|
+
|
|
22
|
+
/* Linting */
|
|
23
|
+
"strict": true,
|
|
24
|
+
"noUnusedLocals": true,
|
|
25
|
+
"noUnusedParameters": false,
|
|
26
|
+
"erasableSyntaxOnly": true,
|
|
27
|
+
"noFallthroughCasesInSwitch": true,
|
|
28
|
+
"noUncheckedSideEffectImports": true
|
|
29
|
+
},
|
|
30
|
+
"include": ["src"],
|
|
31
|
+
"exclude": ["docs"]
|
|
32
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
import react from "@vitejs/plugin-react";
|
|
4
|
+
import dts from "vite-plugin-dts";
|
|
5
|
+
// import vitePluginSass from "vite-plugin-sass";
|
|
6
|
+
|
|
7
|
+
// https://vite.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
plugins: [
|
|
10
|
+
react(),
|
|
11
|
+
// vitePluginSass(),
|
|
12
|
+
dts({ include: ["src"] }),
|
|
13
|
+
],
|
|
14
|
+
build: {
|
|
15
|
+
lib: {
|
|
16
|
+
entry: resolve(__dirname, "src/index.ts"),
|
|
17
|
+
formats: ["es"],
|
|
18
|
+
},
|
|
19
|
+
rollupOptions: {
|
|
20
|
+
external: ["react", "react/jsx-runtime"],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
// css: {
|
|
24
|
+
// preprocessorOptions: {
|
|
25
|
+
// scss: {
|
|
26
|
+
// additionalData: `
|
|
27
|
+
// @import "TimelineV3/layout/layout.scss";
|
|
28
|
+
// `,
|
|
29
|
+
// },
|
|
30
|
+
// },
|
|
31
|
+
// },
|
|
32
|
+
});
|