react-big-schedule 8.1.0 → 9.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.
- package/README.md +24 -1129
- package/dist/calendar/Calendar.d.ts +28 -0
- package/dist/calendar/Calendar.js +95 -0
- package/dist/calendar/Toolbar.d.ts +18 -0
- package/dist/calendar/Toolbar.js +6 -0
- package/dist/calendar/recurrence.check.d.ts +1 -0
- package/dist/calendar/recurrence.check.js +49 -0
- package/dist/calendar/recurrence.d.ts +8 -0
- package/dist/calendar/recurrence.js +90 -0
- package/dist/calendar/timezone.d.ts +6 -0
- package/dist/calendar/timezone.js +14 -0
- package/dist/calendar/types.d.ts +187 -0
- package/dist/calendar/types.js +1 -0
- package/dist/calendar/useEventSources.d.ts +11 -0
- package/dist/calendar/useEventSources.js +89 -0
- package/dist/calendar/useRecurrence.d.ts +4 -0
- package/dist/calendar/useRecurrence.js +15 -0
- package/dist/calendar/utils.d.ts +38 -0
- package/dist/calendar/utils.js +143 -0
- package/dist/calendar/views/DayGridView.d.ts +3 -0
- package/dist/calendar/views/DayGridView.js +375 -0
- package/dist/calendar/views/ListView.d.ts +4 -0
- package/dist/calendar/views/ListView.js +56 -0
- package/dist/calendar/views/MultiMonthView.d.ts +4 -0
- package/dist/calendar/views/MultiMonthView.js +36 -0
- package/dist/calendar/views/TimeGridView.d.ts +3 -0
- package/dist/calendar/views/TimeGridView.js +334 -0
- package/dist/calendar/views/daygrid/DayCell.d.ts +19 -0
- package/dist/calendar/views/daygrid/DayCell.js +17 -0
- package/dist/calendar/views/daygrid/EventChip.d.ts +19 -0
- package/dist/calendar/views/daygrid/EventChip.js +40 -0
- package/dist/calendar/views/daygrid/layout.d.ts +30 -0
- package/dist/calendar/views/daygrid/layout.js +63 -0
- package/dist/calendar/views/list/bucket.d.ts +8 -0
- package/dist/calendar/views/list/bucket.js +37 -0
- package/dist/calendar/views/multimonth/Cell.d.ts +12 -0
- package/dist/calendar/views/multimonth/Cell.js +44 -0
- package/dist/calendar/views/multimonth/Continuous.d.ts +8 -0
- package/dist/calendar/views/multimonth/Continuous.js +28 -0
- package/dist/calendar/views/multimonth/MonthGrid.d.ts +10 -0
- package/dist/calendar/views/multimonth/MonthGrid.js +36 -0
- package/dist/calendar/views/multimonth/shared.d.ts +27 -0
- package/dist/calendar/views/multimonth/shared.js +40 -0
- package/dist/calendar/views/timegrid/DayColumn.d.ts +49 -0
- package/dist/calendar/views/timegrid/DayColumn.js +86 -0
- package/dist/calendar/views/timegrid/model.d.ts +55 -0
- package/dist/calendar/views/timegrid/model.js +102 -0
- package/dist/components/AddMore.d.ts +13 -0
- package/dist/components/AddMore.js +9 -42
- package/dist/components/AddMorePopover.d.ts +13 -0
- package/dist/components/AddMorePopover.js +24 -95
- package/dist/components/AgendaEventItem.d.ts +10 -0
- package/dist/components/AgendaEventItem.js +33 -81
- package/dist/components/AgendaResourceEvents.d.ts +10 -0
- package/dist/components/AgendaResourceEvents.js +37 -91
- package/dist/components/AgendaView.d.ts +9 -0
- package/dist/components/AgendaView.js +10 -69
- package/dist/components/BodyView.d.ts +11 -0
- package/dist/components/BodyView.js +36 -67
- package/dist/components/DnDContext.d.ts +48 -0
- package/dist/components/DnDContext.js +200 -221
- package/dist/components/DnDSource.d.ts +49 -0
- package/dist/components/DnDSource.js +125 -120
- package/dist/components/EventItem.d.ts +41 -0
- package/dist/components/EventItem.js +585 -787
- package/dist/components/EventItemPopover.d.ts +12 -0
- package/dist/components/EventItemPopover.js +19 -143
- package/dist/components/HeaderView.d.ts +14 -0
- package/dist/components/HeaderView.js +123 -186
- package/dist/components/ResourceEvents.d.ts +54 -0
- package/dist/components/ResourceEvents.js +534 -703
- package/dist/components/ResourceView.d.ts +26 -0
- package/dist/components/ResourceView.js +64 -184
- package/dist/components/SchedulerData.d.ts +136 -0
- package/dist/components/SchedulerData.js +1296 -1226
- package/dist/components/SchedulerHeader.d.ts +25 -0
- package/dist/components/SchedulerHeader.js +50 -150
- package/dist/components/SelectedArea.d.ts +8 -0
- package/dist/components/SelectedArea.js +11 -26
- package/dist/components/Summary.d.ts +11 -0
- package/dist/components/Summary.js +21 -50
- package/dist/components/WrapperFun.d.ts +2 -0
- package/dist/components/WrapperFun.js +5 -10
- package/dist/components/index.d.ts +44 -0
- package/dist/components/index.js +428 -654
- package/dist/components/ui/Icons.d.ts +8 -0
- package/dist/components/ui/Icons.js +7 -0
- package/dist/components/ui/MiniCalendar.d.ts +9 -0
- package/dist/components/ui/MiniCalendar.js +17 -0
- package/dist/components/ui/Popover.d.ts +13 -0
- package/dist/components/ui/Popover.js +80 -0
- package/dist/config/default.d.ts +36 -0
- package/dist/config/default.js +17 -26
- package/dist/config/i18n.d.ts +27 -0
- package/dist/config/i18n.js +21 -37
- package/dist/config/scheduler.d.ts +12 -0
- package/dist/config/scheduler.js +126 -119
- package/dist/css/style.css +2 -316
- package/dist/helper/behaviors.d.ts +14 -0
- package/dist/helper/behaviors.js +75 -75
- package/dist/helper/utility.d.ts +26 -0
- package/dist/helper/utility.js +23 -30
- package/dist/index.d.ts +6 -477
- package/dist/index.js +4 -2
- package/dist/sample-data/sample1.d.ts +11 -0
- package/dist/sample-data/sample1.js +427 -372
- package/dist/types.d.ts +267 -0
- package/dist/types.js +1 -0
- package/package.json +30 -27
|
@@ -1,124 +1,129 @@
|
|
|
1
1
|
import { DATETIME_FORMAT, DnDTypes, ViewType } from '../config/default';
|
|
2
2
|
export default class DnDSource {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return this.resolveDragObjFunc(props);
|
|
15
|
-
},
|
|
16
|
-
// endDrag: (props, monitor, component) => {
|
|
17
|
-
endDrag: (props, monitor) => {
|
|
18
|
-
this.dragSlotId = undefined;
|
|
19
|
-
if (!monitor.didDrop()) return;
|
|
20
|
-
const {
|
|
21
|
-
moveEvent,
|
|
22
|
-
newEvent,
|
|
23
|
-
schedulerData
|
|
24
|
-
} = props;
|
|
25
|
-
const {
|
|
26
|
-
events,
|
|
27
|
-
config,
|
|
28
|
-
viewType,
|
|
29
|
-
localeDayjs
|
|
30
|
-
} = schedulerData;
|
|
31
|
-
const item = monitor.getItem();
|
|
32
|
-
const type = monitor.getItemType();
|
|
33
|
-
const dropResult = monitor.getDropResult();
|
|
34
|
-
let {
|
|
35
|
-
slotId
|
|
36
|
-
} = dropResult;
|
|
37
|
-
let {
|
|
38
|
-
slotName
|
|
39
|
-
} = dropResult;
|
|
40
|
-
let newStart = dropResult.start;
|
|
41
|
-
let newEnd = dropResult.end;
|
|
42
|
-
const {
|
|
43
|
-
initialStart
|
|
44
|
-
} = dropResult;
|
|
45
|
-
// const { initialEnd } = dropResult;
|
|
46
|
-
let action = 'New';
|
|
47
|
-
const isEvent = type === DnDTypes.EVENT;
|
|
48
|
-
if (isEvent) {
|
|
49
|
-
const event = item;
|
|
50
|
-
if (dropResult.isVertical) {
|
|
51
|
-
// the vertical drop already resolved the final start/end (see DnDContext.getVerticalMove)
|
|
52
|
-
} else if (config.relativeMove) {
|
|
53
|
-
newStart = localeDayjs(event.start).add(localeDayjs(newStart).diff(localeDayjs(new Date(initialStart))), 'ms').format(DATETIME_FORMAT);
|
|
54
|
-
} else if (viewType !== ViewType.Day) {
|
|
55
|
-
const tmpDayjs = localeDayjs(newStart);
|
|
56
|
-
newStart = localeDayjs(event.start).year(tmpDayjs.year()).month(tmpDayjs.month()).date(tmpDayjs.date()).format(DATETIME_FORMAT);
|
|
57
|
-
}
|
|
58
|
-
newEnd = localeDayjs(newStart).add(localeDayjs(event.end).diff(localeDayjs(event.start)), 'ms').format(DATETIME_FORMAT);
|
|
59
|
-
|
|
60
|
-
// if crossResourceMove disabled, slot returns old value
|
|
61
|
-
if (config.crossResourceMove === false) {
|
|
62
|
-
slotId = schedulerData._getEventSlotId(item);
|
|
63
|
-
slotName = undefined;
|
|
64
|
-
const slot = schedulerData.getSlotById(slotId);
|
|
65
|
-
if (slot) slotName = slot.name;
|
|
66
|
-
}
|
|
67
|
-
action = 'Move';
|
|
68
|
-
}
|
|
69
|
-
let hasConflict = false;
|
|
70
|
-
if (config.checkConflict) {
|
|
71
|
-
const start = localeDayjs(newStart);
|
|
72
|
-
const end = localeDayjs(newEnd);
|
|
73
|
-
events.forEach(e => {
|
|
74
|
-
if (schedulerData._getEventSlotId(e) === slotId && (!isEvent || e.id !== item.id)) {
|
|
75
|
-
const eStart = localeDayjs(e.start);
|
|
76
|
-
const eEnd = localeDayjs(e.end);
|
|
77
|
-
if (start >= eStart && start < eEnd || end > eStart && end <= eEnd || eStart >= start && eStart < end || eEnd > start && eEnd <= end) hasConflict = true;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (hasConflict) {
|
|
82
|
-
const {
|
|
83
|
-
conflictOccurred
|
|
84
|
-
} = props;
|
|
85
|
-
if (conflictOccurred !== undefined) {
|
|
86
|
-
conflictOccurred(schedulerData, action, item, type, slotId, slotName, newStart, newEnd);
|
|
87
|
-
} else {
|
|
88
|
-
console.log('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
|
|
89
|
-
}
|
|
90
|
-
} else if (isEvent) {
|
|
91
|
-
if (moveEvent !== undefined) {
|
|
92
|
-
moveEvent(schedulerData, item, slotId, slotName, newStart, newEnd);
|
|
93
|
-
}
|
|
94
|
-
} else if (newEvent !== undefined) newEvent(schedulerData, slotId, slotName, newStart, newEnd, type, item);
|
|
95
|
-
},
|
|
96
|
-
canDrag: props => {
|
|
97
|
-
const {
|
|
98
|
-
schedulerData,
|
|
99
|
-
resourceEvents
|
|
100
|
-
} = props;
|
|
101
|
-
const item = this.resolveDragObjFunc(props);
|
|
102
|
-
if (schedulerData._isResizing()) return false;
|
|
103
|
-
const {
|
|
104
|
-
config
|
|
105
|
-
} = schedulerData;
|
|
106
|
-
return config.movable && (resourceEvents === undefined || !resourceEvents.groupOnly) && (item.movable === undefined || item.movable !== false);
|
|
3
|
+
// `never`: each component passes a resolver typed for its own props object (a DnDSourceProps subtype)
|
|
4
|
+
resolveDragObjFunc;
|
|
5
|
+
dndType;
|
|
6
|
+
DnDEnabled;
|
|
7
|
+
dragSlotId;
|
|
8
|
+
constructor(resolveDragObjFunc, DnDEnabled, dndType = DnDTypes.EVENT) {
|
|
9
|
+
this.resolveDragObjFunc = resolveDragObjFunc;
|
|
10
|
+
this.dndType = dndType;
|
|
11
|
+
this.DnDEnabled = DnDEnabled;
|
|
12
|
+
// vertical view: the time row the user grabbed the event in (an event is drawn once per row it covers)
|
|
13
|
+
this.dragSlotId = undefined;
|
|
107
14
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
15
|
+
getDragSpec = () => ({
|
|
16
|
+
// beginDrag: (props, monitor, component) => this.resolveDragObjFunc(props),
|
|
17
|
+
beginDrag: (props) => {
|
|
18
|
+
this.dragSlotId = props.slotId;
|
|
19
|
+
return this.resolveDragObjFunc(props);
|
|
20
|
+
},
|
|
21
|
+
// endDrag: (props, monitor, component) => {
|
|
22
|
+
endDrag: (props, monitor) => {
|
|
23
|
+
this.dragSlotId = undefined;
|
|
24
|
+
if (!monitor.didDrop())
|
|
25
|
+
return;
|
|
26
|
+
const { moveEvent, newEvent, schedulerData } = props;
|
|
27
|
+
const { events, config, viewType, localeDayjs } = schedulerData;
|
|
28
|
+
const item = monitor.getItem();
|
|
29
|
+
const type = monitor.getItemType();
|
|
30
|
+
// didDrop() is true here, so a drop result exists
|
|
31
|
+
const dropResult = monitor.getDropResult();
|
|
32
|
+
let { slotId } = dropResult;
|
|
33
|
+
let { slotName } = dropResult;
|
|
34
|
+
let newStart = dropResult.start;
|
|
35
|
+
let newEnd = dropResult.end;
|
|
36
|
+
const { initialStart } = dropResult;
|
|
37
|
+
// const { initialEnd } = dropResult;
|
|
38
|
+
let action = 'New';
|
|
39
|
+
const isEvent = type === DnDTypes.EVENT;
|
|
40
|
+
if (isEvent) {
|
|
41
|
+
const event = item; // an EVENT drag always carries an event
|
|
42
|
+
if (dropResult.isVertical) {
|
|
43
|
+
// the vertical drop already resolved the final start/end (see DnDContext.getVerticalMove)
|
|
44
|
+
}
|
|
45
|
+
else if (config.relativeMove) {
|
|
46
|
+
newStart = localeDayjs(event.start)
|
|
47
|
+
.add(localeDayjs(newStart).diff(localeDayjs(new Date(initialStart))), 'ms')
|
|
48
|
+
.format(DATETIME_FORMAT);
|
|
49
|
+
}
|
|
50
|
+
else if (viewType !== ViewType.Day) {
|
|
51
|
+
const tmpDayjs = localeDayjs(newStart);
|
|
52
|
+
newStart = localeDayjs(event.start)
|
|
53
|
+
.year(tmpDayjs.year())
|
|
54
|
+
.month(tmpDayjs.month())
|
|
55
|
+
.date(tmpDayjs.date())
|
|
56
|
+
.format(DATETIME_FORMAT);
|
|
57
|
+
}
|
|
58
|
+
newEnd = localeDayjs(newStart)
|
|
59
|
+
.add(localeDayjs(event.end).diff(localeDayjs(event.start)), 'ms')
|
|
60
|
+
.format(DATETIME_FORMAT);
|
|
61
|
+
// if crossResourceMove disabled, slot returns old value
|
|
62
|
+
if (config.crossResourceMove === false) {
|
|
63
|
+
slotId = schedulerData._getEventSlotId(event);
|
|
64
|
+
slotName = undefined;
|
|
65
|
+
const slot = schedulerData.getSlotById(slotId);
|
|
66
|
+
if (slot)
|
|
67
|
+
slotName = slot.name;
|
|
68
|
+
}
|
|
69
|
+
action = 'Move';
|
|
70
|
+
}
|
|
71
|
+
let hasConflict = false;
|
|
72
|
+
if (config.checkConflict) {
|
|
73
|
+
const start = localeDayjs(newStart);
|
|
74
|
+
const end = localeDayjs(newEnd);
|
|
75
|
+
events.forEach(e => {
|
|
76
|
+
if (schedulerData._getEventSlotId(e) === slotId && (!isEvent || e.id !== item.id)) {
|
|
77
|
+
const eStart = localeDayjs(e.start);
|
|
78
|
+
const eEnd = localeDayjs(e.end);
|
|
79
|
+
if ((start >= eStart && start < eEnd) ||
|
|
80
|
+
(end > eStart && end <= eEnd) ||
|
|
81
|
+
(eStart >= start && eStart < end) ||
|
|
82
|
+
(eEnd > start && eEnd <= end))
|
|
83
|
+
hasConflict = true;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (hasConflict) {
|
|
88
|
+
const { conflictOccurred } = props;
|
|
89
|
+
if (conflictOccurred !== undefined) {
|
|
90
|
+
conflictOccurred(schedulerData, action, item, type, slotId, slotName, newStart, newEnd);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.log('Conflict occurred, set conflictOccurred func in Scheduler to handle it');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (isEvent) {
|
|
97
|
+
if (moveEvent !== undefined) {
|
|
98
|
+
moveEvent(schedulerData, item, slotId, slotName, newStart, newEnd);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (newEvent !== undefined)
|
|
102
|
+
newEvent(schedulerData, slotId, slotName, newStart, newEnd, type, item);
|
|
103
|
+
},
|
|
104
|
+
canDrag: (props) => {
|
|
105
|
+
const { schedulerData, resourceEvents } = props;
|
|
106
|
+
const item = this.resolveDragObjFunc(props);
|
|
107
|
+
if (schedulerData._isResizing())
|
|
108
|
+
return false;
|
|
109
|
+
const { config } = schedulerData;
|
|
110
|
+
return (config.movable &&
|
|
111
|
+
(resourceEvents === undefined || !resourceEvents.groupOnly) &&
|
|
112
|
+
(item.movable === undefined || item.movable !== false));
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
// Returns the drag specification for use with useDrag hook
|
|
116
|
+
// This should be called with props from the component using the hook
|
|
117
|
+
getDragOptions = (props) => {
|
|
118
|
+
const spec = this.getDragSpec();
|
|
119
|
+
return {
|
|
120
|
+
type: this.dndType,
|
|
121
|
+
item: () => spec.beginDrag(props),
|
|
122
|
+
end: (_item, monitor) => spec.endDrag(props, monitor),
|
|
123
|
+
canDrag: () => spec.canDrag(props),
|
|
124
|
+
collect: monitor => ({
|
|
125
|
+
isDragging: monitor.isDragging(),
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
122
128
|
};
|
|
123
|
-
|
|
124
|
-
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DnDTypes } from '../config/default';
|
|
2
|
+
import type { EventPopoverCallbacks, Id, NewEventDraft, SchedulerEvent } from '../types';
|
|
3
|
+
import type DnDSource from './DnDSource';
|
|
4
|
+
import type SchedulerData from './SchedulerData';
|
|
5
|
+
type ConflictEvent = SchedulerEvent | NewEventDraft;
|
|
6
|
+
export interface EventItemProps extends EventPopoverCallbacks {
|
|
7
|
+
schedulerData: SchedulerData;
|
|
8
|
+
eventItem: SchedulerEvent;
|
|
9
|
+
isStart: boolean;
|
|
10
|
+
isEnd: boolean;
|
|
11
|
+
left: number;
|
|
12
|
+
width: number;
|
|
13
|
+
top: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
isInPopover: boolean;
|
|
16
|
+
leftIndex: number;
|
|
17
|
+
rightIndex: number;
|
|
18
|
+
/** Row (slot) the event is drawn in; used by the vertical resource view. */
|
|
19
|
+
slotId?: Id;
|
|
20
|
+
dndSource?: DnDSource;
|
|
21
|
+
updateEventStart?: (schedulerData: SchedulerData, eventItem: SchedulerEvent, newStart: string) => void;
|
|
22
|
+
updateEventEnd?: (schedulerData: SchedulerData, eventItem: SchedulerEvent, newEnd: string) => void;
|
|
23
|
+
moveEvent?: (schedulerData: SchedulerData, eventItem: SchedulerEvent, slotId: Id, slotName: string | undefined, start: string, end: string) => void;
|
|
24
|
+
conflictOccurred?: (schedulerData: SchedulerData, action: string, eventItem: ConflictEvent, type: DnDTypes, slotId: Id, slotName: string | null | undefined, start: string, end: string) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface EventItemState {
|
|
27
|
+
left: number;
|
|
28
|
+
top: number;
|
|
29
|
+
width: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
contentMousePosX: number;
|
|
32
|
+
eventItemLeftRect: number;
|
|
33
|
+
eventItemRightRect: number;
|
|
34
|
+
startX?: number;
|
|
35
|
+
endX?: number;
|
|
36
|
+
}
|
|
37
|
+
declare function EventItemWithDnD(props: EventItemProps): import("react").JSX.Element;
|
|
38
|
+
declare namespace EventItemWithDnD {
|
|
39
|
+
var displayName: string;
|
|
40
|
+
}
|
|
41
|
+
export default EventItemWithDnD;
|