@code-rhapsodie/react-scheduler 0.4.0 → 0.5.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/dist/components/Calendar/Grid/Grid.d.ts +1 -1
- package/dist/components/Calendar/Grid/styles.d.ts +1 -0
- package/dist/components/Calendar/Grid/types.d.ts +9 -2
- package/dist/components/Calendar/types.d.ts +6 -2
- package/dist/components/LeftColumn/LeftColumnItem/types.d.ts +3 -3
- package/dist/components/LeftColumn/types.d.ts +1 -1
- package/dist/components/Loader/types.d.ts +3 -2
- package/dist/components/PaginationButton/types.d.ts +1 -1
- package/dist/components/Scheduler/Scheduler.d.ts +1 -1
- package/dist/components/Scheduler/types.d.ts +21 -2
- package/dist/components/Tiles/Tile/types.d.ts +20 -1
- package/dist/components/Tiles/types.d.ts +9 -1
- package/dist/context/CalendarProvider/types.d.ts +9 -0
- package/dist/index.cjs +143 -103
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2289 -2041
- package/dist/types/global.d.ts +60 -0
- package/dist/utils/resolveGridCell.d.ts +27 -0
- package/dist/utils/zoomUnits.d.ts +3 -0
- package/package.json +1 -1
- package/readme.md +122 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSX } from "react";
|
|
2
2
|
import { GridProps } from "./types";
|
|
3
|
-
export declare function Grid({ zoom, rows, data, onTileClick, ref }: GridProps & {
|
|
3
|
+
export declare function Grid({ zoom, rows, data, onTileClick, onCellClick, onCellRangeSelect, onTileMove, selectedCell, ref }: GridProps & {
|
|
4
4
|
ref?: React.Ref<HTMLDivElement>;
|
|
5
5
|
}): JSX.Element;
|
|
@@ -4,3 +4,4 @@ export declare const StyledInnerWrapper: IStyledComponent<any, any>;
|
|
|
4
4
|
export declare const StyledCanvas: IStyledComponent<any, any>;
|
|
5
5
|
export declare const StyledCanvasHeader: IStyledComponent<any, any>;
|
|
6
6
|
export declare const StyledSpan: IStyledComponent<any, any>;
|
|
7
|
+
export declare const StyledSelectedCell: IStyledComponent<any, any>;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { PaginatedSchedulerData, SchedulerProjectData } from "@/types/global";
|
|
1
|
+
import { CellClickData, CellRangeSelectData, PaginatedSchedulerData, SchedulerProjectData, SelectedRange, TileMoveData } from "@/types/global";
|
|
2
2
|
export type GridProps = {
|
|
3
3
|
zoom: number;
|
|
4
4
|
rows: number;
|
|
5
5
|
data: PaginatedSchedulerData;
|
|
6
6
|
onTileClick?: (data: SchedulerProjectData) => void;
|
|
7
|
+
onCellClick?: (data: CellClickData) => void;
|
|
8
|
+
onCellRangeSelect?: (data: CellRangeSelectData) => void;
|
|
9
|
+
onTileMove?: (data: TileMoveData) => void;
|
|
10
|
+
/**
|
|
11
|
+
* A cell or range to highlight (e.g. the last selection made via onCellClick/onCellRangeSelect)
|
|
12
|
+
*/
|
|
13
|
+
selectedCell?: SelectedRange | null;
|
|
7
14
|
};
|
|
8
15
|
export type StyledSpanProps = {
|
|
9
|
-
position: "left" | "right";
|
|
16
|
+
$position: "left" | "right";
|
|
10
17
|
};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { SchedulerData, SchedulerItemClickData, SchedulerProjectData } from "@/types/global";
|
|
1
|
+
import { CellClickData, CellRangeSelectData, SchedulerData, SchedulerItemClickData, SchedulerProjectData, SelectedRange, TileMoveData } from "@/types/global";
|
|
2
2
|
export type CalendarProps = {
|
|
3
3
|
data: SchedulerData;
|
|
4
4
|
topBarWidth: number;
|
|
5
5
|
onTileClick?: (data: SchedulerProjectData) => void;
|
|
6
6
|
onItemClick?: (data: SchedulerItemClickData) => void;
|
|
7
|
+
onCellClick?: (data: CellClickData) => void;
|
|
8
|
+
onCellRangeSelect?: (data: CellRangeSelectData) => void;
|
|
9
|
+
onTileMove?: (data: TileMoveData) => void;
|
|
10
|
+
selectedCell?: SelectedRange | null;
|
|
7
11
|
toggleTheme?: () => void;
|
|
8
12
|
};
|
|
9
13
|
export type StyledSpanProps = {
|
|
10
|
-
position: "left" | "right";
|
|
14
|
+
$position: "left" | "right";
|
|
11
15
|
};
|
|
12
16
|
export type ProjectsData = [projectsPerPerson: SchedulerProjectData[][][], rowsPerPerson: number[]];
|
|
@@ -6,9 +6,9 @@ export type LeftColumnItemProps = {
|
|
|
6
6
|
onItemClick?: (data: SchedulerItemClickData) => void;
|
|
7
7
|
};
|
|
8
8
|
export type StyledTextProps = {
|
|
9
|
-
isMain?: boolean;
|
|
9
|
+
$isMain?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export type StyledLeftColumnItemWrapperProps = {
|
|
12
|
-
rows: number;
|
|
13
|
-
clickable: boolean;
|
|
12
|
+
$rows: number;
|
|
13
|
+
$clickable: boolean;
|
|
14
14
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { JSX } from "react";
|
|
2
2
|
import { SchedulerProps } from "./types";
|
|
3
|
-
declare const Scheduler: ({ data, config, startDate, onRangeChange, onTileClick, onFilterData, onClearFilterData, onItemClick, isLoading }: SchedulerProps) => JSX.Element;
|
|
3
|
+
declare const Scheduler: ({ data, config, startDate, onRangeChange, onTileClick, onFilterData, onClearFilterData, onItemClick, onCellClick, onCellRangeSelect, onTileMove, selectedCell, isLoading }: SchedulerProps) => JSX.Element;
|
|
4
4
|
export default Scheduler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, SchedulerData, SchedulerItemClickData, SchedulerProjectData } from "@/types/global";
|
|
1
|
+
import { CellClickData, CellRangeSelectData, Config, SchedulerData, SchedulerItemClickData, SchedulerProjectData, SelectedRange, TileMoveData } from "@/types/global";
|
|
2
2
|
import { ParsedDatesRange } from "@/utils/getDatesRange";
|
|
3
3
|
export type SchedulerProps = {
|
|
4
4
|
data: SchedulerData;
|
|
@@ -10,7 +10,26 @@ export type SchedulerProps = {
|
|
|
10
10
|
onFilterData?: () => void;
|
|
11
11
|
onClearFilterData?: () => void;
|
|
12
12
|
onItemClick?: (data: SchedulerItemClickData) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Fired when clicking an empty cell (a resource row on a given date with no tile),
|
|
15
|
+
* without dragging to a different date
|
|
16
|
+
*/
|
|
17
|
+
onCellClick?: (data: CellClickData) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Fired when dragging across several empty cells on the same resource row, from
|
|
20
|
+
* mouse down to mouse up
|
|
21
|
+
*/
|
|
22
|
+
onCellRangeSelect?: (data: CellRangeSelectData) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Fired when a tile is dragged and dropped onto a new cell, to reschedule it (and
|
|
25
|
+
* optionally reassign it to a different resource row)
|
|
26
|
+
*/
|
|
27
|
+
onTileMove?: (data: TileMoveData) => void;
|
|
28
|
+
/**
|
|
29
|
+
* A cell or range to highlight, e.g. the last selection made via onCellClick/onCellRangeSelect
|
|
30
|
+
*/
|
|
31
|
+
selectedCell?: SelectedRange | null;
|
|
13
32
|
};
|
|
14
33
|
export type StyledOutsideWrapperProps = {
|
|
15
|
-
showScroll: boolean;
|
|
34
|
+
$showScroll: boolean;
|
|
16
35
|
};
|
|
@@ -4,7 +4,26 @@ export type TileProps = {
|
|
|
4
4
|
data: SchedulerProjectData;
|
|
5
5
|
zoom: number;
|
|
6
6
|
onTileClick?: (data: SchedulerProjectData) => void;
|
|
7
|
+
/**
|
|
8
|
+
* When true, the tile can be dragged to reschedule it (an ancestor is
|
|
9
|
+
* expected to handle the drop and call the consumer's onTileMove)
|
|
10
|
+
*/
|
|
11
|
+
draggable?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Fired when the tile starts being dragged, with the number of cells between the
|
|
14
|
+
* tile's start and the point it was grabbed at
|
|
15
|
+
*/
|
|
16
|
+
onDragStart?: (grabOffset: number) => void;
|
|
17
|
+
onDragEnd?: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* When true, the tile is rendered as a non-interactive ghost showing where a dragged
|
|
20
|
+
* tile would land
|
|
21
|
+
*/
|
|
22
|
+
preview?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type StyledTileWrapperProps = {
|
|
25
|
+
$preview?: boolean;
|
|
7
26
|
};
|
|
8
27
|
export type StyledTextProps = {
|
|
9
|
-
bold?: boolean;
|
|
28
|
+
$bold?: boolean;
|
|
10
29
|
};
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { JSX } from "react";
|
|
2
|
-
import { PaginatedSchedulerData, SchedulerProjectData } from "@/types/global";
|
|
2
|
+
import { PaginatedSchedulerData, SchedulerProjectData, TileMoveData } from "@/types/global";
|
|
3
3
|
export type TilesProps = {
|
|
4
4
|
zoom: number;
|
|
5
5
|
data: PaginatedSchedulerData;
|
|
6
6
|
onTileClick?: (data: SchedulerProjectData) => void;
|
|
7
|
+
onTileMove?: (data: TileMoveData) => void;
|
|
8
|
+
onTileDragStart?: (drag: TileDragStart) => void;
|
|
9
|
+
onTileDragEnd?: () => void;
|
|
10
|
+
};
|
|
11
|
+
export type TileDragStart = {
|
|
12
|
+
project: SchedulerProjectData;
|
|
13
|
+
resourceId: string;
|
|
14
|
+
grabOffset: number;
|
|
7
15
|
};
|
|
8
16
|
export type PlacedTiles = JSX.Element[];
|
|
@@ -25,6 +25,15 @@ export type CalendarContextType = {
|
|
|
25
25
|
dayOfYear: number;
|
|
26
26
|
recordsThreshold: number;
|
|
27
27
|
config: Config;
|
|
28
|
+
/**
|
|
29
|
+
* Bumped every time handleGoNext/handleGoPrev navigate, paired with the direction,
|
|
30
|
+
* so a consumer can replay a transition each time (a plain state change is not enough
|
|
31
|
+
* when the same direction is pressed twice in a row).
|
|
32
|
+
*/
|
|
33
|
+
navigation: {
|
|
34
|
+
direction: "next" | "prev";
|
|
35
|
+
tick: number;
|
|
36
|
+
} | null;
|
|
28
37
|
};
|
|
29
38
|
export type CalendarProviderProps = {
|
|
30
39
|
children: ReactNode;
|