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.
Files changed (31) hide show
  1. package/build/components/bookingCalendar/BookingCalendar.d.ts +4 -2
  2. package/build/components/bookingCalendar/BookingCalendar.js +34 -9
  3. package/build/components/bookingCalendar/BookingCalendar.js.map +1 -1
  4. package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js +2 -1
  5. package/build/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.js.map +1 -1
  6. package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.d.ts +1 -1
  7. package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js +5 -4
  8. package/build/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.js.map +1 -1
  9. package/build/components/bookingCalendar/bookingCalendarSelection/classes.d.ts +5 -0
  10. package/build/components/bookingCalendar/bookingCalendarSelection/classes.js +12 -0
  11. package/build/components/bookingCalendar/bookingCalendarSelection/classes.js.map +1 -0
  12. package/build/components/bookingCalendar/common.d.ts +1 -0
  13. package/build/components/bookingCalendar/common.js.map +1 -1
  14. package/build/components/bookingCalendar/utils.d.ts +4 -1
  15. package/build/components/bookingCalendar/utils.js +2 -1
  16. package/build/components/bookingCalendar/utils.js.map +1 -1
  17. package/build/dist/guestbell-forms.css +3 -1
  18. package/build/dist/guestbell-forms.css.map +1 -1
  19. package/build/dist/guestbell-forms.min.css +1 -1
  20. package/build/dist/report.html +2 -2
  21. package/build/scss/components/bookingCalendar/bookingCalendar.scss +2 -0
  22. package/package.json +1 -1
  23. package/src/lib/components/bookingCalendar/BookingCalendar.tsx +80 -8
  24. package/src/lib/components/bookingCalendar/bookingCalendarItem/BookingCalendarItem.tsx +5 -4
  25. package/src/lib/components/bookingCalendar/bookingCalendarSelection/BookingCalendarSelection.tsx +20 -12
  26. package/src/lib/components/bookingCalendar/bookingCalendarSelection/classes.ts +10 -0
  27. package/src/lib/components/bookingCalendar/common.ts +1 -0
  28. package/src/lib/components/bookingCalendar/utils.ts +3 -1
  29. package/src/lib/scss/components/bookingCalendar/bookingCalendar.scss +2 -0
  30. package/src/stories/Schedule.tsx +15 -3
  31. 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
+ };
@@ -3,6 +3,7 @@ import moment, { Moment, Duration } from 'moment';
3
3
  export interface BookingCalendarItemT {
4
4
  from: Moment;
5
5
  till: Moment;
6
+ id: string | number;
6
7
  /*
7
8
  Optional index that identifies the lane
8
9
  */
@@ -180,7 +180,8 @@ export function splitBookingsToLanes<T extends BookingCalendarItemT, TLaneData>(
180
180
  return lanes;
181
181
  }
182
182
 
183
- export function itemsOverlap<T extends BookingCalendarItemT>(a: T, b: T) {
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
 
@@ -263,6 +263,8 @@ $border-color-dark: black;
263
263
  animation-duration: 0.2s;
264
264
  animation-name: fadeIn;
265
265
  user-select: none;
266
+ padding: 0.5rem;
267
+ overflow: hidden;
266
268
  }
267
269
 
268
270
  .bookingCalendar__selection--fadeout {
@@ -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
- } as BookingCalendarItemT;
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,
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "rootDir": "./src/lib",
3
+ "rootDir": ".",
4
4
  "outDir": "./dist",
5
5
  "declarationDir": "./dist/dts",
6
6
  "baseUrl": ".",