guestbell-forms 3.0.40 → 3.0.41
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 +4 -2
- package/build/components/bookingCalendar/BookingCalendar.js +34 -9
- package/build/components/bookingCalendar/BookingCalendar.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js +2 -1
- package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.d.ts +1 -1
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js +5 -4
- package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js.map +1 -1
- package/build/components/bookingCalendar/bookingCalendarSelection/classes.d.ts +5 -0
- package/build/components/bookingCalendar/bookingCalendarSelection/classes.js +12 -0
- package/build/components/bookingCalendar/bookingCalendarSelection/classes.js.map +1 -0
- package/build/components/bookingCalendar/common.d.ts +1 -0
- package/build/components/bookingCalendar/common.js.map +1 -1
- package/build/components/bookingCalendar/utils.d.ts +4 -1
- package/build/components/bookingCalendar/utils.js +2 -1
- package/build/components/bookingCalendar/utils.js.map +1 -1
- package/build/dist/guestbell-forms.css +3 -1
- 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 +2 -0
- package/package.json +1 -1
- package/src/lib/components/bookingCalendar/BookingCalendar.tsx +80 -8
- package/src/lib/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.tsx +5 -4
- package/src/lib/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.tsx +20 -12
- package/src/lib/components/bookingCalendar/bookingCalendarSelection/classes.ts +10 -0
- package/src/lib/components/bookingCalendar/common.ts +1 -0
- package/src/lib/components/bookingCalendar/utils.ts +3 -1
- package/src/lib/scss/components/bookingCalendar/bookingCalendar.scss +2 -0
- package/src/stories/Schedule.tsx +15 -3
- package/tsconfig.json +1 -1
@@ -0,0 +1,10 @@
|
|
1
|
+
export interface BookingCalendarSelectionClasses {
|
2
|
+
root?: string;
|
3
|
+
selection?: string;
|
4
|
+
}
|
5
|
+
|
6
|
+
export const bookingCalendarSelectionDefaultClasses: BookingCalendarSelectionClasses =
|
7
|
+
{
|
8
|
+
root: 'bookingCalendar__selection__container',
|
9
|
+
selection: 'bookingCalendar__selection',
|
10
|
+
};
|
@@ -180,7 +180,8 @@ export function splitBookingsToLanes<T extends BookingCalendarItemT, TLaneData>(
|
|
180
180
|
return lanes;
|
181
181
|
}
|
182
182
|
|
183
|
-
|
183
|
+
type Picked = Pick<BookingCalendarItemT, 'from' | 'till'>;
|
184
|
+
export function itemsOverlap(a: Picked, b: Picked) {
|
184
185
|
if (!a?.from || !a?.till || !b?.from || !b?.till) {
|
185
186
|
return false;
|
186
187
|
}
|
@@ -267,6 +268,7 @@ export const generateControlItems = (
|
|
267
268
|
.clone()
|
268
269
|
.add(subtract)
|
269
270
|
.add(step.asMilliseconds() * (index + 1)),
|
271
|
+
id: index
|
270
272
|
}));
|
271
273
|
};
|
272
274
|
|
package/src/stories/Schedule.tsx
CHANGED
@@ -12,20 +12,21 @@ const generateBookingItemsBetweenDates = (
|
|
12
12
|
from: Moment,
|
13
13
|
till: Moment,
|
14
14
|
count = 50
|
15
|
-
) => {
|
15
|
+
): BookingCalendarItemT[] => {
|
16
16
|
const width = till.valueOf() - from.valueOf();
|
17
17
|
const startMs = from.valueOf();
|
18
|
-
return new Array(count).fill(0).map(() => {
|
18
|
+
return new Array(count).fill(0).map((_, index) => {
|
19
19
|
const _from = randomIntFromInterval(0, till.valueOf() - startMs) + startMs;
|
20
20
|
const _width = randomIntFromInterval(width / 100, width / 50);
|
21
21
|
return {
|
22
|
+
id: index,
|
22
23
|
from: moment(_from),
|
23
24
|
till: moment(_from).add(_width, 'ms'),
|
24
25
|
laneKey:
|
25
26
|
randomIntFromInterval(1, 3) === 1
|
26
27
|
? undefined
|
27
28
|
: randomIntFromInterval(1, 3),
|
28
|
-
}
|
29
|
+
};
|
29
30
|
});
|
30
31
|
};
|
31
32
|
|
@@ -47,6 +48,15 @@ export const Schedule = () => {
|
|
47
48
|
() => bookings.filter((b) => itemsOverlap(b, { from, till })),
|
48
49
|
[from, till, bookings]
|
49
50
|
);
|
51
|
+
const onSelection = React.useCallback(
|
52
|
+
(items: BookingCalendarItemT[], _from, _till, e) => {
|
53
|
+
console.log(items);
|
54
|
+
if (e.ctrlKey) {
|
55
|
+
setRange({ from: _from, till: _till });
|
56
|
+
}
|
57
|
+
},
|
58
|
+
[]
|
59
|
+
);
|
50
60
|
return (
|
51
61
|
<div className="container">
|
52
62
|
<BookingCalendar
|
@@ -55,6 +65,8 @@ export const Schedule = () => {
|
|
55
65
|
till={till}
|
56
66
|
step={duration(1, 'day')}
|
57
67
|
onRangeChange={setRange}
|
68
|
+
onSelection={onSelection}
|
69
|
+
selectionContent={'Hold CTRL to zoom'}
|
58
70
|
// lanesCount={3}
|
59
71
|
lanesSource={new Array(3).fill(0).map((_, index) => ({
|
60
72
|
laneKey: index,
|