guestbell-forms 3.0.42 → 3.0.43
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/build/components/bookingCalendar/BookingCalendar.d.ts +1 -0
- package/build/components/bookingCalendar/BookingCalendar.js +4 -3
- package/build/components/bookingCalendar/BookingCalendar.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarGrid/index.d.ts +2 -0
- package/build/components/bookingCalendar/bookingCalendarGrid/index.js +28 -0
- package/build/components/bookingCalendar/bookingCalendarGrid/index.js.map +1 -0
- package/build/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.js +1 -1
- package/build/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarSelection/index.d.ts +2 -0
- package/build/components/bookingCalendar/bookingCalendarSelection/index.js +28 -0
- package/build/components/bookingCalendar/bookingCalendarSelection/index.js.map +1 -0
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/index.d.ts +2 -0
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/index.js +28 -0
- package/build/components/bookingCalendar/bookingCalendarTimeAxis/index.js.map +1 -0
- package/build/components/bookingCalendar/index.d.ts +10 -0
- package/build/components/bookingCalendar/index.js +110 -0
- package/build/components/bookingCalendar/index.js.map +1 -1
- package/build/components/bookingCalendar/utils.d.ts +1 -1
- package/build/components/bookingCalendar/utils.js +10 -6
- package/build/components/bookingCalendar/utils.js.map +1 -1
- package/build/dist/guestbell-forms.css +7 -5
- package/build/dist/guestbell-forms.css.map +1 -1
- package/build/dist/guestbell-forms.min.css +1 -1
- package/build/dist/report.html +2 -2
- package/build/scss/components/bookingCalendar/bookingCalendar.scss +6 -4
- package/package.json +1 -1
- package/src/lib/components/bookingCalendar/BookingCalendar.tsx +32 -24
- package/src/lib/components/bookingCalendar/bookingCalendarGrid/index.ts +2 -0
- package/src/lib/components/bookingCalendar/bookingCalendarLane/BookingCalendarLane.tsx +1 -1
- package/src/lib/components/bookingCalendar/bookingCalendarSelection/index.ts +2 -0
- package/src/lib/components/bookingCalendar/bookingCalendarTimeAxis/index.ts +2 -0
- package/src/lib/components/bookingCalendar/index.ts +10 -0
- package/src/lib/components/bookingCalendar/utils.ts +9 -6
- package/src/lib/scss/components/bookingCalendar/bookingCalendar.scss +6 -4
- package/src/stories/OverlappingSchedule.stories.ts +16 -0
- package/src/stories/OverlappingSchedule.tsx +174 -0
- package/src/stories/overlappingSchedule.scss +10 -0
@@ -0,0 +1,174 @@
|
|
1
|
+
import moment, { duration, Moment } from 'moment';
|
2
|
+
import * as React from 'react';
|
3
|
+
import {
|
4
|
+
BookingCalendar,
|
5
|
+
BookingCalendarItemT,
|
6
|
+
BookingCalendarRenderItem,
|
7
|
+
BookingCalendarRenderItemProps,
|
8
|
+
} from '../lib';
|
9
|
+
import classNames from 'classnames';
|
10
|
+
import './overlappingSchedule.scss';
|
11
|
+
|
12
|
+
type TItem = BookingCalendarItemT & { overlapping?: boolean };
|
13
|
+
|
14
|
+
const generateBookingItemsBetweenDates = (
|
15
|
+
from: Moment,
|
16
|
+
till: Moment
|
17
|
+
): TItem[] => {
|
18
|
+
const width = till.valueOf() - from.valueOf();
|
19
|
+
const startMs = from.valueOf();
|
20
|
+
const nonOverlappingCount = 10;
|
21
|
+
const laneCount = 5;
|
22
|
+
let i = 0;
|
23
|
+
return new Array(laneCount)
|
24
|
+
.fill(0)
|
25
|
+
.map((_, laneIndex) => [
|
26
|
+
...new Array(nonOverlappingCount).fill(0).map((_, index) => {
|
27
|
+
const _from = startMs + index * (width / nonOverlappingCount);
|
28
|
+
const _width = width / (nonOverlappingCount + 1);
|
29
|
+
return {
|
30
|
+
id: i++,
|
31
|
+
from: moment(_from),
|
32
|
+
till: moment(_from).add(_width, 'ms'),
|
33
|
+
laneKey: laneIndex,
|
34
|
+
};
|
35
|
+
}),
|
36
|
+
...(laneIndex === 0
|
37
|
+
? [
|
38
|
+
{
|
39
|
+
id: i++,
|
40
|
+
from: moment(from),
|
41
|
+
till: moment(till),
|
42
|
+
laneKey: laneIndex,
|
43
|
+
overlapping: true,
|
44
|
+
},
|
45
|
+
]
|
46
|
+
: laneIndex === 1
|
47
|
+
? [
|
48
|
+
{
|
49
|
+
id: i++,
|
50
|
+
from: moment(from).subtract(width / 2, 'ms'),
|
51
|
+
till: moment(till).add(width / 2, 'ms'),
|
52
|
+
laneKey: laneIndex,
|
53
|
+
overlapping: true,
|
54
|
+
},
|
55
|
+
{
|
56
|
+
id: i++,
|
57
|
+
from: moment(from).subtract(width / 2, 'ms'),
|
58
|
+
till: moment(till).add(width / 2, 'ms'),
|
59
|
+
laneKey: laneIndex,
|
60
|
+
overlapping: true,
|
61
|
+
},
|
62
|
+
]
|
63
|
+
: laneIndex === 2
|
64
|
+
? [
|
65
|
+
{
|
66
|
+
id: i++,
|
67
|
+
from: moment(till).subtract(width / 2, 'ms'),
|
68
|
+
till: moment(till),
|
69
|
+
laneKey: laneIndex,
|
70
|
+
overlapping: true,
|
71
|
+
},
|
72
|
+
]
|
73
|
+
: laneIndex === 3
|
74
|
+
? [
|
75
|
+
{
|
76
|
+
id: i++,
|
77
|
+
from: moment(from).add(width / (nonOverlappingCount * 2), 'ms'),
|
78
|
+
till: moment(till).subtract(
|
79
|
+
width / (nonOverlappingCount * 2),
|
80
|
+
'ms'
|
81
|
+
),
|
82
|
+
laneKey: laneIndex,
|
83
|
+
overlapping: true,
|
84
|
+
},
|
85
|
+
]
|
86
|
+
: laneIndex === 4
|
87
|
+
? [
|
88
|
+
{
|
89
|
+
id: i++,
|
90
|
+
from: moment(from).add(width / (nonOverlappingCount * 2), 'ms'),
|
91
|
+
till: moment(till).subtract(
|
92
|
+
width / (nonOverlappingCount * 2),
|
93
|
+
'ms'
|
94
|
+
),
|
95
|
+
laneKey: laneIndex,
|
96
|
+
overlapping: true,
|
97
|
+
},
|
98
|
+
{
|
99
|
+
id: i++,
|
100
|
+
from: moment(from).add(width / (nonOverlappingCount * 2), 'ms'),
|
101
|
+
till: moment(till).subtract(
|
102
|
+
width / (nonOverlappingCount * 2),
|
103
|
+
'ms'
|
104
|
+
),
|
105
|
+
laneKey: laneIndex,
|
106
|
+
overlapping: true,
|
107
|
+
},
|
108
|
+
]
|
109
|
+
: []),
|
110
|
+
])
|
111
|
+
.reduce((acc, val) => acc.concat(val), [])
|
112
|
+
.filter((a) => a /*&&a?.laneKey === 1*/);
|
113
|
+
};
|
114
|
+
|
115
|
+
export const Schedule = () => {
|
116
|
+
const [{ from, till }, setRange] = React.useState({
|
117
|
+
from: moment().startOf('day').subtract(0, 'day'),
|
118
|
+
till: moment().startOf('day').add(7, 'days'),
|
119
|
+
});
|
120
|
+
|
121
|
+
const bookings = React.useMemo(
|
122
|
+
() =>
|
123
|
+
generateBookingItemsBetweenDates(
|
124
|
+
from.clone().subtract(0, 'day'),
|
125
|
+
till.clone().add(0, 'day')
|
126
|
+
),
|
127
|
+
[]
|
128
|
+
);
|
129
|
+
|
130
|
+
const onSelection = React.useCallback((items: TItem[], _from, _till, e) => {
|
131
|
+
console.log(items);
|
132
|
+
if (e.ctrlKey) {
|
133
|
+
setRange({ from: _from, till: _till });
|
134
|
+
}
|
135
|
+
}, []);
|
136
|
+
const RenderItem: React.FC<BookingCalendarRenderItemProps<TItem>> =
|
137
|
+
React.useCallback((props) => {
|
138
|
+
return (
|
139
|
+
<BookingCalendarRenderItem
|
140
|
+
className={classNames({ overlapping__item: props.item.overlapping })}
|
141
|
+
{...props}
|
142
|
+
alwaysShowContent={true}
|
143
|
+
>
|
144
|
+
<div />
|
145
|
+
</BookingCalendarRenderItem>
|
146
|
+
);
|
147
|
+
}, []);
|
148
|
+
return (
|
149
|
+
<div className="container">
|
150
|
+
<BookingCalendar
|
151
|
+
bookings={bookings}
|
152
|
+
from={from}
|
153
|
+
till={till}
|
154
|
+
step={duration(1, 'day')}
|
155
|
+
onRangeChange={setRange}
|
156
|
+
onSelection={onSelection}
|
157
|
+
selectionContent={'Hold CTRL to zoom'}
|
158
|
+
// lanesCount={3}
|
159
|
+
lanesSource={new Array(5).fill(0).map((_, index) => ({
|
160
|
+
laneKey: index,
|
161
|
+
data: { data: 'test' },
|
162
|
+
rowClassName: 'test',
|
163
|
+
}))}
|
164
|
+
zoomLevels={[
|
165
|
+
{ step: duration(1, 'day'), label: 'Day' },
|
166
|
+
{ step: duration(1, 'week'), label: 'Week' },
|
167
|
+
]}
|
168
|
+
BookingCalendarRenderItem={RenderItem}
|
169
|
+
/>
|
170
|
+
</div>
|
171
|
+
);
|
172
|
+
};
|
173
|
+
|
174
|
+
export default Schedule;
|