awesome-timeline-react 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Jakub Plata
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Awesome Timeline React
2
+
3
+ ## Introduction
4
+
5
+ **Awesome Timeline React** is a component that developers can include in their projects. It provides a Gantt timeline for visualizing and managing events. With simple configuration, powerful performance, and customization options, it's an excellent choice for your project. The component is not published yet; it will be released as a beta version first. If you have any ideas for features or encounter any bugs, please email me at [jakub.plata@yahoo.pl](mailto:jakub.plata@yahoo.pl).
6
+
7
+ ![](https://raw.githubusercontent.com/Plageros/awesome-timeline-react/master/public/gifs/demo-overview.gif)
8
+
9
+ ## Ladle
10
+
11
+ To run ladle stories, type:
12
+
13
+ ```sh
14
+ npm run ladle
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ First, import the `Timeline` component into your project. The following properties are available:
20
+
21
+ - `rows` – an array of objects that define rows. The order within the array will be preserved in the Timeline.
22
+
23
+ - `events` – an array of objects that define events assigned to particular rows. Each object includes:
24
+
25
+ - `id`: `string`
26
+ - `rowId`: `string`
27
+ - `startTime`: `number` (timestamp in seconds)
28
+ - `endTime`: `number` (timestamp in seconds)
29
+ - `props`:
30
+ - `isLocked`: `boolean` (defines if the event is locked, meaning it cannot be moved. Default is `false`)
31
+ - `content`: `JSX.Element | string` (customizable content for each event)
32
+ - `classNames`: `string[]` (array of additional class names for customizing the event)
33
+
34
+ - `staticEvents` – an array of objects that define static events for particular rows, meaning the events are not interactable by the user.
35
+
36
+ - `onDrop` – an external callback for the `onDrop` event that can be injected. The callback receives the following properties:
37
+
38
+ - `eventId`: `string`
39
+ - `oldRowId`: `string`
40
+ - `newRowId`: `string`
41
+ - `startDate`: `number` (timestamp in seconds)
42
+ - `endDate`: `number` (timestamp in seconds)
43
+
44
+ - `additionalClassNames` – contains additional class names that will be included within elements:
45
+ - `timeBar`: `string`
46
+ - `dayRow`: `string`
47
+ - `hourRow`: `string`
48
+ - `line`: `string`
49
+ - `rowsHeader`: `string`
50
+
51
+ ## Awesome Features
52
+
53
+ One of the awesome features (currently hidden from the interface) is adjusting the granulation of the grid. To achieve this, click the wheel on the mouse. This will hide the scroll bar, and you can adjust the grid granulation by scrolling the wheel. Each scroll iteration adjusts the grid by ±15 minutes, depending on the scroll direction.
54
+
55
+ ![](https://raw.githubusercontent.com/Plageros/awesome-timeline-react/master/public/gifs/demo-grid-granulation.gif)
56
+
57
+ ## Roadmap
58
+
59
+ Here, we will store major features planned for future releases (from highest to lowest priority):
60
+
61
+ 1. Resize events
62
+ 2. Real time line
63
+ 3. Customizable prompts after hovering over an event
64
+ 4. Customizable second row of the time bar
65
+ 5. Intersection observer with `display: none` property to further improve performance
@@ -0,0 +1,276 @@
1
+ /// <reference types="react" />
2
+
3
+ import { Context } from "react";
4
+ import { CSSProperties } from "react";
5
+ import { default as React_2 } from "react";
6
+
7
+ declare type ContentType = {
8
+ rows: RowType[];
9
+ events: EventType[];
10
+ staticEvents?: EventType[];
11
+ setEvents: React_2.Dispatch<React_2.SetStateAction<EventType[]>>;
12
+ tick: number | null;
13
+ windowTime: number[];
14
+ cellWidth: number;
15
+ setWindowTime: React_2.Dispatch<React_2.SetStateAction<number[]>>;
16
+ contentWidth: number | null;
17
+ setCellWidth: React_2.Dispatch<React_2.SetStateAction<number>>;
18
+ bodyRef: React_2.MutableRefObject<HTMLDivElement | null>;
19
+ lineClassName?: string;
20
+ };
21
+
22
+ export declare const default_alias: {
23
+ title: string;
24
+ };
25
+
26
+ export declare const default_alias_1: ({
27
+ rows,
28
+ events,
29
+ staticEvents,
30
+ onDrop,
31
+ startDate,
32
+ endDate,
33
+ additionalClassNames,
34
+ }: {
35
+ rows: RowType[];
36
+ events: EventType[];
37
+ staticEvents?: EventType[];
38
+ onDrop?: (props: OnDropProps) => void;
39
+ startDate: Date;
40
+ endDate: Date;
41
+ additionalClassNames?: PartialRecord<keyof ModifableElements, string>;
42
+ }) => React_2.JSX.Element;
43
+
44
+ export declare const default_alias_10: (monthIndex: number) => string;
45
+
46
+ export declare const default_alias_11: (dayIndex: number) => string;
47
+
48
+ export declare const default_alias_12: (
49
+ eventA: EventType,
50
+ eventB: EventType
51
+ ) => 1 | -1;
52
+
53
+ export declare const default_alias_13: ({
54
+ windowTime,
55
+ tick,
56
+ contentWidth,
57
+ blockWidth,
58
+ }: {
59
+ windowTime: number[];
60
+ tick: number | null;
61
+ contentWidth: number | null;
62
+ blockWidth: number;
63
+ }) => {
64
+ dayBlocks: JSX.Element[];
65
+ hourBlocks: JSX.Element[];
66
+ };
67
+
68
+ export declare const default_alias_14: ({
69
+ windowTime,
70
+ contentWidth,
71
+ }: {
72
+ windowTime: number[];
73
+ contentWidth: number | null;
74
+ }) => {
75
+ numberOfHourBlocks: number;
76
+ blockWidth: number;
77
+ };
78
+
79
+ export declare const default_alias_15: ({
80
+ bodyRef,
81
+ rowsContentRef,
82
+ }: {
83
+ bodyRef: React.MutableRefObject<HTMLDivElement | null>;
84
+ rowsContentRef: React.MutableRefObject<HTMLDivElement[] | null>;
85
+ }) => void;
86
+
87
+ export declare const default_alias_16: ({
88
+ rows,
89
+ windowTime,
90
+ tick,
91
+ events,
92
+ staticEvents,
93
+ cellWidth,
94
+ setEvents,
95
+ bodyRef,
96
+ }: ProduceContentType) => React_2.JSX.Element[];
97
+
98
+ export declare const default_alias_17: ({
99
+ windowTime,
100
+ setTick,
101
+ setCellWidth,
102
+ contentRef,
103
+ }: {
104
+ windowTime: number[];
105
+ setTick: React.Dispatch<React.SetStateAction<number | null>>;
106
+ setCellWidth: React.Dispatch<React.SetStateAction<number>>;
107
+ contentRef: React.MutableRefObject<HTMLDivElement | null>;
108
+ }) => void;
109
+
110
+ export declare const default_alias_2: React_2.ForwardRefExoticComponent<
111
+ ContentType & React_2.RefAttributes<HTMLDivElement>
112
+ >;
113
+
114
+ export declare const default_alias_3: ({
115
+ id,
116
+ startPosition,
117
+ width,
118
+ top,
119
+ props,
120
+ }: {
121
+ id: string;
122
+ startPosition: CSSProperties["left"];
123
+ width: CSSProperties["width"];
124
+ top: CSSProperties["top"];
125
+ props?: EventPropsType;
126
+ }) => React_2.JSX.Element;
127
+
128
+ export declare const default_alias_4: ({
129
+ contentWidth,
130
+ cellWidth,
131
+ lineClassName,
132
+ }: {
133
+ contentWidth: number | null;
134
+ cellWidth: number;
135
+ lineClassName?: string;
136
+ }) => React_2.JSX.Element;
137
+
138
+ export declare const default_alias_5: React_2.ForwardRefExoticComponent<
139
+ RowContentProps & {
140
+ children?: React_2.ReactNode;
141
+ } & React_2.RefAttributes<HTMLDivElement>
142
+ >;
143
+
144
+ export declare const default_alias_6: ({
145
+ name,
146
+ id,
147
+ }: {
148
+ name: string;
149
+ id: string;
150
+ }) => React_2.JSX.Element;
151
+
152
+ export declare const default_alias_7: ({
153
+ rows,
154
+ className,
155
+ }: {
156
+ rows: RowType[];
157
+ className?: string;
158
+ }) => React_2.JSX.Element;
159
+
160
+ export declare const default_alias_8: ({
161
+ id,
162
+ startPosition,
163
+ width,
164
+ top,
165
+ height,
166
+ }: {
167
+ id: string;
168
+ startPosition: CSSProperties["left"];
169
+ width: CSSProperties["width"];
170
+ top: CSSProperties["top"];
171
+ height: CSSProperties["height"];
172
+ }) => React_2.JSX.Element;
173
+
174
+ export declare const default_alias_9: ({
175
+ windowTime,
176
+ tick,
177
+ contentWidth,
178
+ scrollWidth,
179
+ additionalClassNames,
180
+ }: {
181
+ windowTime: number[];
182
+ tick: number | null;
183
+ contentWidth: number | null;
184
+ scrollWidth: number;
185
+ additionalClassNames?: PartialRecord<keyof ModifableElements, string>;
186
+ }) => React_2.JSX.Element;
187
+
188
+ declare type DragStartedContext_2 = {
189
+ dragStarted: boolean;
190
+ setDragStarted: React.Dispatch<React.SetStateAction<boolean>>;
191
+ };
192
+
193
+ export declare const DragStartedContext: Context<DragStartedContext_2>;
194
+
195
+ export declare type EventPropsType = {
196
+ isLocked?: boolean;
197
+ content?: JSX.Element | string;
198
+ classNames?: string[];
199
+ };
200
+
201
+ export declare type EventType = {
202
+ id: string;
203
+ rowId: string;
204
+ startTime: number;
205
+ endTime: number;
206
+ props?: EventPropsType;
207
+ };
208
+
209
+ export declare const ExternalPropertiesContext: Context<ExternalPropertiesType>;
210
+
211
+ declare type ExternalPropertiesType = {
212
+ onDrop?: (props: OnDropProps) => void;
213
+ };
214
+
215
+ export declare type ModifableElements = {
216
+ timeBar: string;
217
+ dayRow: string;
218
+ hourRow: string;
219
+ gridLine: string;
220
+ rowsHeader: string;
221
+ };
222
+
223
+ export declare type OnDropProps = {
224
+ eventId: string;
225
+ oldRowId: string;
226
+ newRowId: string;
227
+ startTime: number;
228
+ endTime: number;
229
+ };
230
+
231
+ export declare type PartialRecord<K extends keyof any, T> = Partial<
232
+ Record<K, T>
233
+ >;
234
+
235
+ declare type ProduceContentType = {
236
+ rows: RowType[];
237
+ events: EventType[];
238
+ staticEvents?: EventType[];
239
+ setEvents: React_2.Dispatch<React_2.SetStateAction<EventType[]>>;
240
+ tick: number | null;
241
+ windowTime: number[];
242
+ cellWidth: number;
243
+ bodyRef: React_2.MutableRefObject<HTMLDivElement | null>;
244
+ };
245
+
246
+ declare type RowContentProps = {
247
+ id: string;
248
+ setEvents: React_2.Dispatch<React_2.SetStateAction<EventType[]>>;
249
+ tick: number | null;
250
+ windowTime: number[];
251
+ cellWidth: number;
252
+ };
253
+
254
+ export declare const RowsHeightContext: Context<RowsHeightContextType | null>;
255
+
256
+ declare type RowsHeightContextType = {
257
+ rowsHeight: Record<string, RowsHeightType> | null;
258
+ setRowsHeight: React.Dispatch<
259
+ React.SetStateAction<Record<string, RowsHeightType> | null>
260
+ >;
261
+ allRowsHeight: number;
262
+ setAllRowsHeight: React.Dispatch<React.SetStateAction<number>>;
263
+ };
264
+
265
+ export declare type RowsHeightType = {
266
+ minHeight: number;
267
+ };
268
+
269
+ export declare type RowType = {
270
+ id: string;
271
+ name: string;
272
+ };
273
+
274
+ export declare const TimelinePrimary: () => React_2.JSX.Element;
275
+
276
+ export {};
package/dist/index.css ADDED
@@ -0,0 +1,2 @@
1
+ .rows-header-wrapper{width:100px;height:fit-content;border-right:1px solid yellow;background-color:#272424;color:#fff;box-sizing:border-box;.row-header:not(:last-child){border-bottom:1px solid yellow}box-shadow:4px 0 20px #000}.main-wrapper{display:flex;flex-direction:column;height:100%;width:100%}.body-wrapper{display:flex;flex-direction:row;border-left:1px solid black;border-bottom:1px solid black;border-right:1px solid black;width:100%;overflow:auto;box-sizing:border-box}.day-block{height:100%;text-align:center;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:4px}.hour-block{display:block;width:100%;text-align:center;padding:4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.content-wrapper{position:relative;display:flex;flex-direction:column;width:100%;.row-content:not(:last-child){border-bottom:1px solid #e4dcdc}}.row-header{display:flex;justify-content:center;align-items:center;width:100px;transition:min-height .5s ease-in-out;box-sizing:border-box}.row-content{position:relative;width:100%;padding-top:10px;padding-bottom:10px;overflow:hidden;z-index:0;transition:min-height .5s ease-in-out;box-sizing:border-box}.event{position:absolute;height:20px;border:1px solid black;z-index:1;transition:top .5s ease-in-out;box-sizing:border-box;display:flex;border-radius:5px;box-shadow:inset 0 0 5px gray}.event-content{width:100%;height:100%}.static-event{position:absolute;background-color:#e0e0e0;z-index:0;border:1px solid transparent;box-sizing:border-box;border-radius:5px}.time-bar{display:flex;flex-direction:row;width:100%;height:50px;min-height:50px;border:1px solid yellow;background-color:#272424;color:#fff;box-sizing:border-box}.empty-block{width:100px;min-width:100px;border-right:1px solid yellow;box-sizing:border-box}.time-content{display:flex;flex-direction:column;height:100%}.day-row{display:grid;height:50%;width:auto;border-bottom:1px solid yellow;div:not(:last-child){border-right:1px solid yellow}}.hour-row{display:grid;height:50%;div:not(:last-child){border-right:1px solid yellow;box-sizing:border-box}box-shadow:0 4px 20px #000}.not-clickable{div{pointer-events:none}}.line{height:100%;width:100%;border-right:1px solid #e4dcdc;box-sizing:border-box}.lines-canvas{position:absolute;top:0;display:grid;height:100%;width:100%;overflow:hidden}.hide-last-line{div:last-child{border-right:none}}.row-hidden{visibility:hidden}
2
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/style.css","../src/components/style.css"],"sourcesContent":[".rows-header-wrapper {\r\n width: 100px;\r\n height: fit-content;\r\n border-right: 1px solid yellow;\r\n background-color: rgb(39, 36, 36);\r\n color: white;\r\n box-sizing: border-box;\r\n .row-header:not(:last-child) {\r\n border-bottom: 1px solid yellow;\r\n }\r\n box-shadow: 4px 0px 20px black;\r\n}\r\n\r\n.main-wrapper {\r\n display: flex;\r\n flex-direction: column;\r\n height: 100%;\r\n width: 100%;\r\n}\r\n\r\n.body-wrapper {\r\n display: flex;\r\n flex-direction: row;\r\n border-left: 1px solid black;\r\n border-bottom: 1px solid black;\r\n border-right: 1px solid black;\r\n width: 100%;\r\n overflow: auto;\r\n box-sizing: border-box;\r\n}\r\n\r\n.day-block {\r\n height: 100%;\r\n text-align: center;\r\n box-sizing: border-box;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n padding: 4px;\r\n}\r\n\r\n.hour-block {\r\n display: block;\r\n width: 100%;\r\n text-align: center;\r\n padding: 4px;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n}\r\n",".content-wrapper {\r\n position: relative;\r\n display: flex;\r\n flex-direction: column;\r\n width: 100%;\r\n .row-content:not(:last-child) {\r\n border-bottom: 1px solid #e4dcdc;\r\n }\r\n}\r\n\r\n.row-header {\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n width: 100px;\r\n transition: min-height 0.5s ease-in-out;\r\n box-sizing: border-box;\r\n}\r\n\r\n.row-content {\r\n position: relative;\r\n width: 100%;\r\n padding-top: 10px;\r\n padding-bottom: 10px;\r\n overflow: hidden;\r\n z-index: 0;\r\n transition: min-height 0.5s ease-in-out;\r\n box-sizing: border-box;\r\n}\r\n\r\n.event {\r\n position: absolute;\r\n height: 20px;\r\n border: 1px solid black;\r\n z-index: 1;\r\n transition: top 0.5s ease-in-out;\r\n box-sizing: border-box;\r\n display: flex;\r\n border-radius: 5px;\r\n box-shadow: inset 0px 0px 5px gray;\r\n}\r\n\r\n.event-content {\r\n width: 100%;\r\n height: 100%;\r\n}\r\n\r\n.static-event {\r\n position: absolute;\r\n background-color: #e0e0e0;\r\n z-index: 0;\r\n border: 1px solid transparent;\r\n box-sizing: border-box;\r\n border-radius: 5px;\r\n}\r\n\r\n.time-bar {\r\n display: flex;\r\n flex-direction: row;\r\n width: 100%;\r\n height: 50px;\r\n min-height: 50px;\r\n border: 1px solid yellow;\r\n background-color: rgb(39, 36, 36);\r\n color: white;\r\n box-sizing: border-box;\r\n}\r\n\r\n.empty-block {\r\n width: 100px;\r\n min-width: 100px;\r\n border-right: 1px solid yellow;\r\n box-sizing: border-box;\r\n}\r\n\r\n.time-content {\r\n display: flex;\r\n flex-direction: column;\r\n height: 100%;\r\n}\r\n\r\n.day-row {\r\n display: grid;\r\n height: 50%;\r\n width: auto;\r\n border-bottom: 1px solid yellow;\r\n div:not(:last-child) {\r\n border-right: 1px solid yellow;\r\n }\r\n}\r\n\r\n.hour-row {\r\n display: grid;\r\n height: 50%;\r\n div:not(:last-child) {\r\n border-right: 1px solid yellow;\r\n box-sizing: border-box;\r\n }\r\n box-shadow: 0px 4px 20px black;\r\n}\r\n\r\n.not-clickable {\r\n div {\r\n pointer-events: none;\r\n }\r\n}\r\n\r\n.line {\r\n height: 100%;\r\n width: 100%;\r\n border-right: 1px solid #e4dcdc;\r\n box-sizing: border-box;\r\n}\r\n\r\n.lines-canvas {\r\n position: absolute;\r\n top: 0;\r\n display: grid;\r\n height: 100%;\r\n width: 100%;\r\n overflow: hidden;\r\n}\r\n\r\n.hide-last-line {\r\n div:last-child {\r\n border-right: none;\r\n }\r\n}\r\n\r\n.row-hidden {\r\n visibility: hidden;\r\n}\r\n"],"mappings":"AAAA,CAAC,oBACC,MAAO,MACP,OAAQ,YACR,aAAc,IAAI,MAAM,OACxB,iBAAkB,QAClB,MAAO,KACP,WAAY,WACZ,CAAC,UAAU,KAAK,aACd,cAAe,IAAI,MAAM,MAC3B,CACA,WAAY,IAAI,EAAI,KAAK,IAC3B,CAEA,CAAC,aACC,QAAS,KACT,eAAgB,OAChB,OAAQ,KACR,MAAO,IACT,CAEA,CAAC,aACC,QAAS,KACT,eAAgB,IAChB,YAAa,IAAI,MAAM,MACvB,cAAe,IAAI,MAAM,MACzB,aAAc,IAAI,MAAM,MACxB,MAAO,KACP,SAAU,KACV,WAAY,UACd,CAEA,CAAC,UACC,OAAQ,KACR,WAAY,OACZ,WAAY,WACZ,SAAU,OACV,cAAe,SACf,YAAa,OArCf,QAsCW,GACX,CAEA,CAAC,WACC,QAAS,MACT,MAAO,KACP,WAAY,OA5Cd,QA6CW,IACT,SAAU,OACV,cAAe,SACf,YAAa,MACf,CCjDA,CAAC,gBACC,SAAU,SACV,QAAS,KACT,eAAgB,OAChB,MAAO,KACP,CAAC,WAAW,KAAK,aACf,cAAe,IAAI,MAAM,OAC3B,CACF,CAEA,CAAC,WACC,QAAS,KACT,gBAAiB,OACjB,YAAa,OACb,MAAO,MACP,WAAY,WAAW,IAAK,YAC5B,WAAY,UACd,CAEA,CAdG,YAeD,SAAU,SACV,MAAO,KACP,YAAa,KACb,eAAgB,KAChB,SAAU,OACV,QAAS,EACT,WAAY,WAAW,IAAK,YAC5B,WAAY,UACd,CAEA,CAAC,MACC,SAAU,SACV,OAAQ,KACR,OAAQ,IAAI,MAAM,MAClB,QAAS,EACT,WAAY,IAAI,IAAK,YACrB,WAAY,WACZ,QAAS,KArCX,cAsCiB,IACf,WAAY,MAAM,EAAI,EAAI,IAAI,IAChC,CAEA,CAAC,cACC,MAAO,KACP,OAAQ,IACV,CAEA,CAAC,aACC,SAAU,SACV,iBAAkB,QAClB,QAAS,EACT,OAAQ,IAAI,MAAM,YAClB,WAAY,WApDd,cAqDiB,GACjB,CAEA,CAAC,SACC,QAAS,KACT,eAAgB,IAChB,MAAO,KACP,OAAQ,KACR,WAAY,KACZ,OAAQ,IAAI,MAAM,OAClB,iBAAkB,QAClB,MAAO,KACP,WAAY,UACd,CAEA,CAAC,YACC,MAAO,MACP,UAAW,MACX,aAAc,IAAI,MAAM,OACxB,WAAY,UACd,CAEA,CAAC,aACC,QAAS,KACT,eAAgB,OAChB,OAAQ,IACV,CAEA,CAAC,QACC,QAAS,KACT,OAAQ,IACR,MAAO,KACP,cAAe,IAAI,MAAM,OACzB,GAAG,KAAK,aACN,aAAc,IAAI,MAAM,MAC1B,CACF,CAEA,CAAC,SACC,QAAS,KACT,OAAQ,IACR,GAAG,KAAK,aACN,aAAc,IAAI,MAAM,OACxB,WAAY,UACd,CACA,WAAY,EAAI,IAAI,KAAK,IAC3B,CAEA,CAAC,cACC,IACE,eAAgB,IAClB,CACF,CAEA,CAAC,KACC,OAAQ,KACR,MAAO,KACP,aAAc,IAAI,MAAM,QACxB,WAAY,UACd,CAEA,CAAC,aACC,SAAU,SACV,IAAK,EACL,QAAS,KACT,OAAQ,KACR,MAAO,KACP,SAAU,MACZ,CAEA,CAAC,eACC,GAAG,YACD,aAAc,IAChB,CACF,CAEA,CAAC,WACC,WAAY,MACd","names":[]}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _react = require('react'); var _react2 = _interopRequireDefault(_react);var ee=({windowTime:o,contentWidth:t})=>{let n=_react.useMemo.call(void 0, ()=>(o[1]-o[0])/3600,[o]),i=t?t/n:0;return{numberOfHourBlocks:n,blockWidth:i}},$=ee;var k=_react.createContext.call(void 0, null);var oe=({contentWidth:o,cellWidth:t,lineClassName:n})=>{let i=_react.useMemo.call(void 0, ()=>{let s=[],p=n?"line "+n:"line";if(o)for(let m=t;m<o;m=m+t)s.push(_react2.default.createElement("div",{key:`line_${m}`,className:p}));return s},[t,o]),e=_react.useMemo.call(void 0, ()=>o?o-i.length*t:0,[o,t,i]);return _react2.default.createElement("div",{className:e<1?"lines-canvas hide-last-line":"lines-canvas",style:e<1?{gridTemplateColumns:`repeat(auto-fill, minmax(${t}px, 1fr))`}:{gridTemplateColumns:`repeat(auto-fill, minmax(${e}px, ${t}px))`}},i)},A=oe;var ne=({id:o,startPosition:t,width:n,top:i,height:e})=>_react2.default.createElement("div",{id:`static_event_${o}`,key:`static_event_${o}`,className:"static-event",onDrop:s=>s.stopPropagation(),style:{left:t,width:n,top:i,minHeight:e}}),j=ne;var _immer = require('immer');var P=_react.createContext.call(void 0, {dragStarted:!1,setDragStarted:()=>{}});var z=_react.createContext.call(void 0, {});var le=(o,t)=>o.startTime-t.startTime<0||o.startTime===t.startTime&&o.endTime<t.endTime?-1:1,W=le;var me=_react.forwardRef.call(void 0, (o,t)=>{let{setEvents:n,tick:i,id:e,windowTime:s,cellWidth:p,children:m}=o,{dragStarted:w,setDragStarted:l}=_react.useContext.call(void 0, P),{onDrop:a}=_react.useContext.call(void 0, z),M=_react.useCallback.call(void 0, d=>{d.preventDefault();let c=d.target,{left:b}=c.getBoundingClientRect(),f=d.dataTransfer.getData("eventId"),T=Math.round((d.clientX-b)/p),R=p*T;n(_immer.produce.call(void 0, r=>{let u=r.find(y=>y.id===f);if(u&&i){let y=s[0]+R*i,E=u.endTime-u.startTime,O=s[0]+E+R*i;a&&a({eventId:u.id,oldRowId:u.rowId,newRowId:o.id,startTime:y,endTime:O}),u.startTime=y,u.endTime=O,u.rowId=o.id}r.sort(W)})),l(!1)},[n,i,s,p]),x=_react.useContext.call(void 0, k),g=x&&x.rowsHeight&&x.rowsHeight[e]?x.rowsHeight[e].minHeight:40;return _react2.default.createElement("div",{id:`row_${e}`,ref:t,onDragOver:d=>d.preventDefault(),onDrop:M,className:w?"row-content not-clickable":"row-content","data-index":e,style:{minHeight:g}},m)}),F=me;var he=({id:o,startPosition:t,width:n,top:i,props:e})=>{let{setDragStarted:s}=_react.useContext.call(void 0, P),p=_react.useCallback.call(void 0, l=>{l.stopPropagation(),l.dataTransfer.setData("eventId",o),setTimeout(()=>s(!0),0);let a=l.target;a.style.opacity="50%"},[s]),m=_react.useCallback.call(void 0, l=>{l.stopPropagation(),s(!1);let a=l.target;a.style.opacity="100%"},[s]),w=e!=null&&e.classNames?"event "+e.classNames.join(" "):"event";return _react2.default.createElement("div",{id:`event_${o}`,key:`event_${o}`,className:w,draggable:!(e!=null&&e.isLocked),onDragStart:p,onDragEnd:m,onMouseDown:l=>l.stopPropagation(),onMouseMove:l=>l.stopPropagation(),onDrop:l=>l.stopPropagation(),style:{left:t,width:n,top:i,cursor:e!=null&&e.isLocked?"not-allowed":"pointer"}},_react2.default.createElement("div",{className:"event-content"},e!=null&&e.content?e.content:null))},X=he;var be=({bodyRef:o,rowsContentRef:t})=>{let n=_react.useCallback.call(void 0, e=>{e.forEach(s=>{s.isIntersecting?s.target.classList.remove("row-hidden"):s.target.classList.add("row-hidden")})},[]),i=new IntersectionObserver(n,{root:o.current});_react.useEffect.call(void 0, ()=>(t.current&&t.current.forEach(e=>{i.observe(e)}),()=>i.disconnect()),[i])},Y=be;var Te=({rows:o,windowTime:t,tick:n,events:i,staticEvents:e,cellWidth:s,setEvents:p,bodyRef:m})=>{let w=_react.useContext.call(void 0, k),l=null,a=_react.useRef.call(void 0, []),M=0,x=_react.useMemo.call(void 0, ()=>o.map((g,d)=>{let c=0,b=[],f=0,T=n?i.filter(r=>r.rowId===g.id).map(r=>{if(r.endTime>=t[0]&&r.startTime<=t[1]){let u=0,y=!0;for(let E=0;E<=c;E++)if(b&&b[E]&&b[E].endTime>r.startTime)u+=1;else{c>f&&(f=c),c=0,y=!1;break}return y&&(c=u),b[u]=r,_react2.default.createElement(X,{key:`event_${r.id}`,id:r.id,startPosition:(r.startTime-t[0])/n,width:(r.endTime-r.startTime)/n,top:10+22*u,props:r.props})}}):null;c>f&&(f=c),l===null?l={[g.id]:{minHeight:40+f*22}}:l[g.id]={minHeight:40+f*22},M+=40+f*22;let R=n&&e?e.filter(r=>r.rowId===g.id).map(r=>{if(r.endTime>=t[0]&&r.startTime<=t[1])return _react2.default.createElement(j,{key:`static_event_${r.id}`,id:r.id,startPosition:(r.startTime-t[0])/n,width:(r.endTime-r.startTime)/n,top:10,height:20+f*22})}):null;return _react2.default.createElement(_react2.default.Fragment,{key:`row_content_${g.id}`},_react2.default.createElement(F,{id:g.id,ref:r=>{a.current&&a.current[d]&&r?a.current[d]=r:a.current&&r&&a.current.push(r)},setEvents:p,tick:n,windowTime:t,cellWidth:s},T,R))}),[o,i,n,t,s]);return Y({rowsContentRef:a,bodyRef:m}),_react.useEffect.call(void 0, ()=>{w&&(w.setRowsHeight(l),w.setAllRowsHeight(M))},[x]),x},U=Te;var Zt=_react.forwardRef.call(void 0, ({rows:o,events:t,staticEvents:n,setEvents:i,tick:e,windowTime:s,cellWidth:p,setWindowTime:m,contentWidth:w,setCellWidth:l,bodyRef:a,lineClassName:M},x)=>{let[g,d]=_react.useState.call(void 0, !1),c=_react.useRef.call(void 0, null),[b,f]=_react.useState.call(void 0, !1),{blockWidth:T}=$({windowTime:s,contentWidth:w}),R=_react.useContext.call(void 0, k),r=_react.useCallback.call(void 0, h=>{if(h.preventDefault(),!g)return;let v=h.target,{left:H}=v.getBoundingClientRect(),D=h.clientX-H,B=e?Math.floor(e*T):0;c.current&&c.current-D>=T?(c.current=D,m(S=>[S[0]+B,S[1]+B])):c.current&&D-c.current>=T&&(c.current=D,m(S=>[S[0]-B,S[1]-B]))},[T,m,g]),u=_react.useCallback.call(void 0, h=>{d(!0),h.button===1&&h.preventDefault();let v=h.target,{left:H}=v.getBoundingClientRect();c.current=h.clientX-H},[d]),y=_react.useCallback.call(void 0, ()=>{d(!1)},[d]),E=_react.useCallback.call(void 0, ()=>d(!1),[d]),O=U({rows:o,windowTime:s,tick:e,events:t,staticEvents:n,cellWidth:p,setEvents:i,bodyRef:a}),Q=_react.useCallback.call(void 0, h=>{h.preventDefault(),h.button===1&&f(v=>!v)},[]),V=_react.useCallback.call(void 0, h=>{let v=e?900/e:0;b&&l(H=>{let D=h.deltaY>0?H+v:H-v;return D<v||D>v*12?H:D})},[b,p,e]);return _react.useEffect.call(void 0, ()=>{a.current&&(a.current.style.overflow=b?"hidden":"auto")},[b]),_react2.default.createElement("div",{key:"content",ref:x,className:"content-wrapper",onMouseDown:u,onMouseUp:y,onMouseMove:r,onMouseLeave:E,onAuxClick:Q,onWheel:V,style:{cursor:g?"grabbing":"grab",height:R==null?void 0:R.allRowsHeight}},_react2.default.createElement(A,{contentWidth:w,cellWidth:p,lineClassName:M}),O)});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["c:\\awesome-timeline-react\\dist\\index.js"],"names":[],"mappings":"AAAA,yLAAkE,IAAgI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,4BAAC,CAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAyG,CAAC,CAAC,kCAAE,IAAK,CAAC,CAAC,IAA6K,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,4BAAC,CAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA","file":"C:\\awesome-timeline-react\\dist\\index.js","sourcesContent":[null]}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "awesome-timeline-react",
3
+ "version": "0.1.0",
4
+ "description": "awesome timeline for react applications",
5
+ "scripts": {
6
+ "test": "jest",
7
+ "ladle": "ladle serve",
8
+ "build": "tsup --experimental-dts"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Plageros/awesome-timeline-react.git"
13
+ },
14
+ "keywords": [
15
+ "react",
16
+ "timeline",
17
+ "scheduling",
18
+ "aps"
19
+ ],
20
+ "author": "Jakub Plata",
21
+ "license": "MIT",
22
+ "bugs": {
23
+ "url": "https://github.com/Plageros/awesome-timeline-react/issues"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "main": "dist/index.js",
29
+ "types": "dist/src/index.d.ts",
30
+ "homepage": "https://github.com/Plageros/awesome-timeline-react#readme",
31
+ "devDependencies": {
32
+ "@babel/preset-env": "^7.25.3",
33
+ "@babel/preset-react": "^7.24.7",
34
+ "@babel/preset-typescript": "^7.24.7",
35
+ "@eslint/js": "^9.2.0",
36
+ "@jest/globals": "^29.7.0",
37
+ "@ladle/react": "^4.0.3",
38
+ "@microsoft/api-extractor": "^7.47.5",
39
+ "@types/jest": "^29.5.12",
40
+ "@types/react": "^18.3.1",
41
+ "@types/react-dom": "^18.3.0",
42
+ "babel-jest": "^29.7.0",
43
+ "eslint": "^8.57.0",
44
+ "eslint-plugin-react": "^7.34.1",
45
+ "globals": "^15.1.0",
46
+ "jest": "^29.7.0",
47
+ "react": "^18.3.1",
48
+ "react-dom": "^18.3.1",
49
+ "react-test-renderer": "^18.3.1",
50
+ "ts-jest": "^29.2.4",
51
+ "tsup": "^8.2.4",
52
+ "typescript": "^5.4.5",
53
+ "typescript-eslint": "^7.8.0"
54
+ },
55
+ "dependencies": {
56
+ "immer": "^10.1.1"
57
+ },
58
+ "peerDependencies": {
59
+ "react": "^18",
60
+ "react-dom": "^18"
61
+ }
62
+ }