react-beauty-calendar 2.0.2 → 2.0.4

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 (75) hide show
  1. package/README.md +6 -0
  2. package/dist/@types/booking.d.ts +1 -0
  3. package/dist/@types/calendar-instance.d.ts +39 -7
  4. package/dist/@types/calendar.d.ts +1 -2
  5. package/dist/@types/index.d.ts +2 -2
  6. package/dist/@types/profile.d.ts +1 -1
  7. package/dist/@types/user.d.ts +4 -1
  8. package/dist/build/assets/main.css +1 -1
  9. package/dist/build/main.cjs.js +60 -70
  10. package/dist/build/main.es.js +10714 -8452
  11. package/dist/components/ui/Avatar.d.ts +10 -0
  12. package/dist/components/ui/Button-group.d.ts +11 -0
  13. package/dist/components/ui/Dialog.d.ts +14 -0
  14. package/dist/components/ui/Sidebar.d.ts +70 -0
  15. package/dist/components/ui/sheet.d.ts +12 -0
  16. package/dist/components/ui/skeleton.d.ts +2 -0
  17. package/dist/constants/booking-view-type.constant.d.ts +2 -0
  18. package/dist/constants/card.constant.d.ts +7 -0
  19. package/dist/constants/index.d.ts +4 -10
  20. package/dist/constants/month.constant.d.ts +12 -0
  21. package/dist/constants/user-colors-constants.d.ts +40 -0
  22. package/dist/context/drag/useDragStateAtStore.d.ts +0 -2
  23. package/dist/context/global/booking-info/booking-info.d.ts +1 -0
  24. package/dist/context/global/config/config-store.d.ts +7 -2
  25. package/dist/context/global/days-and-week/day-and-week-store.d.ts +1 -0
  26. package/dist/context/new-event/new-event-store.d.ts +1 -1
  27. package/dist/context/users-info/users-info-store.d.ts +3 -3
  28. package/dist/core/Root.d.ts +1 -1
  29. package/dist/core/avatar/UserAvatar.d.ts +6 -0
  30. package/dist/core/booking-card/BookingCard.d.ts +1 -1
  31. package/dist/core/booking-card/BookingCardOnResize.d.ts +1 -1
  32. package/dist/core/booking-card/CardContent.d.ts +1 -1
  33. package/dist/core/booking-creation-dialog/BookingCreationDialog.d.ts +1 -1
  34. package/dist/core/booking-creation-dialog/ConfirmationModal.d.ts +10 -0
  35. package/dist/core/calendar/AllDayCard.d.ts +2 -0
  36. package/dist/core/calendar/CalendarDays.d.ts +1 -1
  37. package/dist/core/calendar/DateCalendarIndicator.d.ts +1 -1
  38. package/dist/core/calendar/ScheduleSlots.d.ts +3 -9
  39. package/dist/core/calendar/SlotRender.d.ts +1 -1
  40. package/dist/core/calendar/SlotRenderMonth.d.ts +3 -0
  41. package/dist/core/card-slots/CardBlockContent.d.ts +4 -3
  42. package/dist/core/card-slots/CardResizeEventOpened.d.ts +2 -1
  43. package/dist/core/card-slots/MonthIndicator.d.ts +8 -0
  44. package/dist/core/card-slots/SlotTrigger.d.ts +2 -2
  45. package/dist/core/card-slots/TimeInfo.d.ts +2 -4
  46. package/dist/core/card-slots/UniSlot.d.ts +1 -1
  47. package/dist/core/header-calendar/HeaderTodayAction.d.ts +1 -1
  48. package/dist/core/sidebar/Sidebar.d.ts +8 -0
  49. package/dist/core/sidebar/SidebarWrapper.d.ts +7 -0
  50. package/dist/core/slots/Card.d.ts +5 -4
  51. package/dist/core/table-view-type/TableViewType.d.ts +2 -2
  52. package/dist/hooks/useResizableCardHook.d.ts +3 -2
  53. package/dist/mock/booking-mock.d.ts +8 -2
  54. package/dist/user1.webp +0 -0
  55. package/dist/user2.jpeg +0 -0
  56. package/dist/user3.png +0 -0
  57. package/dist/user4.webp +0 -0
  58. package/dist/utils/blockSlotDays.d.ts +12 -0
  59. package/dist/utils/date.utils.d.ts +7 -2
  60. package/dist/utils/forward.d.ts +5 -6
  61. package/dist/utils/index.d.ts +3 -2
  62. package/dist/utils/permissions.d.ts +6 -0
  63. package/dist/utils/props.d.ts +26 -16
  64. package/dist/utils/string.utils.d.ts +1 -0
  65. package/dist/utils/types.d.ts +5 -1
  66. package/package.json +4 -2
  67. package/dist/@types/working-time.d.ts +0 -10
  68. package/dist/constants/day-time-starter.constant.d.ts +0 -2
  69. package/dist/constants/payment.constant.d.ts +0 -11
  70. package/dist/constants/resize-base-value.constant.d.ts +0 -1
  71. package/dist/constants/side-options.constant.d.ts +0 -1
  72. package/dist/constants/system-colors.constant.d.ts +0 -40
  73. package/dist/constants/url-param.constant.d.ts +0 -6
  74. package/dist/constants/week.constant.d.ts +0 -3
  75. package/dist/core/calendar/TableDayOfWeekColumn.d.ts +0 -6
@@ -1,5 +1,5 @@
1
1
  import { Booking } from '../@types';
2
- import { WeekDays } from '../constants/week.constant';
2
+ import { WeekDays } from '../constants';
3
3
  import { DaysOfWeek, NextAndPreviousWeek } from '../context/global/days-and-week/day-and-week-store';
4
4
  export type DatesData = {
5
5
  week: Date[];
@@ -31,7 +31,8 @@ export declare const dateUtils: {
31
31
  newDateKey(date: string, hour: string): string;
32
32
  addMinutesToHour(startAt: string, interval: number): string;
33
33
  convertStringTimeToDateFormat(timeString: string, day?: string): Date;
34
- isSameDayMonthAndYea(initialDate: Date, dateToCompare: Date): boolean;
34
+ setToMidnight(day: string): Date;
35
+ isSameDayMonthAndYear(initialDate: Date, dateToCompare: Date): boolean;
35
36
  isTodayDate(date: Date): boolean;
36
37
  isSameDay(initialDate: Date, dateToCompare: Date): boolean;
37
38
  firstAndLastWeekDays(week: DaysOfWeek): NextAndPreviousWeek;
@@ -39,4 +40,8 @@ export declare const dateUtils: {
39
40
  isFinishDateAnotherDay(finish: Date, start: Date): boolean;
40
41
  compareSameDate(firstDate: Date, secondDate: Date): boolean;
41
42
  isMidnight(closureDate: Date): boolean;
43
+ getDayOfWeek(day: string | Date): WeekDays;
44
+ isWeekend(day: string | Date): boolean;
45
+ isWithinRange(start: Date | null, end: Date | null, target: string | Date): boolean;
46
+ convertDateToTimeString(dateTime: Date): string;
42
47
  };
@@ -1,14 +1,9 @@
1
1
  import { CSSProperties } from 'react';
2
- import { Booking } from '../@types';
2
+ import { Booking, BookingDateAndTime } from '../@types';
3
3
  export type CardContentRef = HTMLDivElement;
4
4
  export interface BookingCardRef {
5
5
  changeCurrentCardResize: () => void;
6
6
  }
7
- export interface TimeInfoRef {
8
- show: () => void;
9
- hide: () => void;
10
- changeIsOpen: (isOpen: boolean) => void;
11
- }
12
7
  export interface BlockTimeRef {
13
8
  ref: (element: HTMLElement | null) => void;
14
9
  style: CSSProperties;
@@ -43,3 +38,7 @@ export interface ResizableTimeSlotRef {
43
38
  export interface CardResizeEventRef {
44
39
  updateCardEventHeight: (finish: Date, start: Date) => void;
45
40
  }
41
+ export interface ConfirmModalRef {
42
+ showConfirmationModal: (booking: Booking, slotData: BookingDateAndTime) => void;
43
+ hideConfirmationModal: () => void;
44
+ }
@@ -2,8 +2,9 @@ import { bookingUtils } from './booking.utils';
2
2
  import { buildEmptyTimeSlotKey } from './buildEmptyTimeSlotKey';
3
3
  import { cardResizeUtils } from './cardResize.utils';
4
4
  import { dateUtils } from './date.utils';
5
- import { TimeInfoRef, BookingCardRef, SlotTriggerForwardRef, BookingCreationDialogRef, BookingCardContentRef } from './forward';
5
+ import { BookingCardRef, SlotTriggerForwardRef, BookingCreationDialogRef, BookingCardContentRef } from './forward';
6
6
  import { generateTimes, generateWorkingTimes } from './hours';
7
7
  import { SlotTriggerProps, CardContentProps, BlockTimeData, EmptySlotProps, TimeInfoProps, useResizableCardHookProps, BlocksTimeStructure, SlotRenderProps, BookingCarContextProps, CalendarHolderProps, ColumnsProps, BookingCarOnResizeProps } from './props';
8
8
  import { stringUtils } from './string.utils';
9
- export { bookingUtils, dateUtils, stringUtils, cardResizeUtils, generateTimes, generateWorkingTimes, buildEmptyTimeSlotKey, type BookingCardRef, type SlotTriggerForwardRef, type BookingCreationDialogRef, type TimeInfoRef, type BookingCardContentRef, type BlockTimeData, type BlocksTimeStructure, type SlotTriggerProps, type CardContentProps, type EmptySlotProps, type TimeInfoProps, type useResizableCardHookProps, type BookingCarContextProps, type SlotRenderProps, type CalendarHolderProps, type ColumnsProps, type BookingCarOnResizeProps, };
9
+ export { bookingUtils, dateUtils, stringUtils, cardResizeUtils, generateTimes, generateWorkingTimes, buildEmptyTimeSlotKey, type BookingCardRef, type SlotTriggerForwardRef, type BookingCreationDialogRef, type BookingCardContentRef, type BlockTimeData, type BlocksTimeStructure, type SlotTriggerProps, type CardContentProps, type EmptySlotProps, type TimeInfoProps, type useResizableCardHookProps, type BookingCarContextProps, type SlotRenderProps, type CalendarHolderProps, type ColumnsProps, type BookingCarOnResizeProps, };
10
+ export { hasPermission, canCreateBooking, canDragBooking, canResizeBooking, } from './permissions';
@@ -0,0 +1,6 @@
1
+ import { UserAccessProfile } from '../@types';
2
+ import { Permissions } from '../@types/user';
3
+ export declare const hasPermission: (actor: UserAccessProfile, permission: Permissions) => boolean;
4
+ export declare const canCreateBooking: (actor: UserAccessProfile, targetActorId?: string) => boolean;
5
+ export declare const canDragBooking: (actor: UserAccessProfile, targetActorId?: string) => boolean;
6
+ export declare const canResizeBooking: (actor: UserAccessProfile, targetActorId?: string) => boolean;
@@ -2,22 +2,24 @@ import { DraggableAttributes } from '@dnd-kit/core';
2
2
  import { SyntheticListenerMap } from '@dnd-kit/core/dist/hooks/utilities';
3
3
  import { ColumnDef } from '@tanstack/react-table';
4
4
  import { CSSProperties, JSX, PropsWithChildren, ReactNode, Ref } from 'react';
5
- import { Booking, BookingDateAndTime, Bookings, UserProfileStatus } from '../@types';
5
+ import { Booking, BookingDateAndTime, Bookings, UserAccessProfile } from '../@types';
6
6
  import { Side } from '../core/booking-options/BookingInfoOptions';
7
7
  import { BlockTimeRef, BookingCardContentRef, BookingCardRef, BookingCreationDialogRef, CardContentRef, ResizableTimeSlotRef, SlotTriggerForwardRef } from './forward';
8
8
  import { ResizableParam, TimesBlock } from './types';
9
9
  export interface CardContentProps {
10
10
  resize?: boolean;
11
11
  bookingInit: Booking;
12
- slotData: BookingDateAndTime;
12
+ slotData: BlocksTimeStructure;
13
+ selected?: boolean;
13
14
  heightStyle: number;
15
+ canResize?: boolean;
14
16
  topHeightIncrement?: number;
15
17
  customClasses?: string;
16
18
  open?: boolean;
17
19
  lastCard?: boolean;
18
20
  half?: boolean;
19
21
  cardsQuantity?: number;
20
- cardIndex?: number;
22
+ index?: number;
21
23
  resizableParam?: ResizableParam;
22
24
  events?: {
23
25
  onUnmount?: () => void;
@@ -32,6 +34,7 @@ export interface CardContentProps {
32
34
  export interface BookingCardProps {
33
35
  booking: Booking;
34
36
  slotData: BookingDateAndTime;
37
+ selected?: boolean;
35
38
  customClasses?: string;
36
39
  hoveringAdditionalCardId?: string;
37
40
  isResizing?: boolean;
@@ -46,7 +49,9 @@ export interface BlockTimeData {
46
49
  time: string;
47
50
  userId?: string;
48
51
  }
49
- export type BlocksTimeStructure = BlockTimeRef & BlockTimeData;
52
+ export type BlocksTimeStructure = {
53
+ bookingQuantity?: number;
54
+ } & BlockTimeRef & BlockTimeData;
50
55
  export interface EmptySlotProps {
51
56
  bookings: Booking[];
52
57
  dayHour: BookingDateAndTime;
@@ -55,17 +60,15 @@ export interface EmptySlotProps {
55
60
  firstDay: boolean;
56
61
  }
57
62
  export interface SlotEvents {
58
- onMouseEnterEvent: () => TimesBlock;
63
+ onMouseEnterEvent: () => void;
59
64
  }
60
65
  export interface SlotTriggerProps {
61
66
  slotData: BlocksTimeStructure;
62
67
  blockTimeString?: string;
63
- dayHour?: BookingDateAndTime;
64
- disabledCss?: string;
65
- events: SlotEvents;
66
68
  bookings?: Bookings;
67
69
  children?: ReactNode;
68
70
  lastPosition?: boolean;
71
+ fromMonth?: boolean;
69
72
  getCreationDialogRef: () => BookingCreationDialogRef | null;
70
73
  ref: Ref<SlotTriggerForwardRef>;
71
74
  }
@@ -88,7 +91,9 @@ export type BookingCarOnResizeProps = Omit<BookingCarContextProps & {
88
91
  export interface useResizableCardHookProps {
89
92
  starter?: boolean;
90
93
  booking: Booking;
94
+ activeUser: UserAccessProfile;
91
95
  skipUpdate?: boolean;
96
+ isMonthView?: boolean;
92
97
  onAddTime?: (datetime: Date) => void;
93
98
  onAddStartTime?: (datetime: Date) => void;
94
99
  onStartAtChange?: (datetime: Date) => void;
@@ -106,12 +111,17 @@ export interface BookingTabsProps {
106
111
  onClose: (event: React.MouseEvent) => void;
107
112
  onOpenChange: (status: boolean) => void;
108
113
  }
114
+ export interface BookingCreationDialogEvent {
115
+ onClose: () => void;
116
+ onOpenChange: (status: boolean) => void;
117
+ }
109
118
  export interface BookingCreationDialogProps {
110
119
  modal?: boolean;
111
120
  side?: Side;
112
121
  buttonTrigger?: JSX.Element;
122
+ fromMonth?: boolean;
123
+ events?: BookingCreationDialogEvent;
113
124
  ref: Ref<BookingCreationDialogRef>;
114
- slotTrigger?: () => SlotTriggerForwardRef | null;
115
125
  }
116
126
  export interface BlockTimeDataChunk {
117
127
  firstBlockTimeData: BlocksTimeStructure;
@@ -121,13 +131,10 @@ export interface BlockTimeDataChunk {
121
131
  }
122
132
  export interface SlotRenderProps {
123
133
  bookings: Booking[];
124
- lunchTimeBlock?: {
125
- startAt: string;
126
- finishAt: string;
127
- };
128
134
  firstDay: boolean;
129
135
  dayHour: BookingDateAndTime;
130
- user?: UserProfileStatus;
136
+ user?: UserAccessProfile;
137
+ index?: number;
131
138
  }
132
139
  export interface CalendarHolderProps {
133
140
  tableAccessors: ColumnDef<unknown>[];
@@ -138,14 +145,17 @@ export interface ColumnsProps<T> {
138
145
  }
139
146
  export interface UniSlotProps {
140
147
  dayHour: BookingDateAndTime;
141
- slotPosition: TimesBlock;
148
+ slotPosition?: TimesBlock;
142
149
  firstDay: boolean;
143
150
  bookings: Booking[];
144
151
  userId?: string;
145
152
  lastPosition?: boolean;
153
+ bookingQuantity?: number;
154
+ fromMonth?: boolean;
155
+ closeRenderedEvent?: () => void;
146
156
  }
147
157
  export interface HeaderTodayActionProps {
148
- onClick: () => void;
158
+ onClickToday: () => void;
149
159
  showCreationModal: () => void;
150
160
  }
151
161
  export interface ResizableTimeSlotProps {
@@ -1,4 +1,5 @@
1
1
  export declare const stringUtils: {
2
2
  capitalize(text: string): string;
3
3
  returnFirstChar(text: string): string;
4
+ getUserFromId: (id: string) => string;
4
5
  };
@@ -14,7 +14,7 @@ export interface RootProps extends RootEventsProps {
14
14
  export interface RootEventsProps {
15
15
  onChangeViewType: (bookingViewType: BookingViewType) => void;
16
16
  onTodayClick: (date: Date) => void;
17
- onCardDropCallback: (booking: Booking, overId: string, slotData: BookingDateAndTime) => Promise<void>;
17
+ onCardDrop: (booking: Booking, overId: string, slotData: BookingDateAndTime) => Promise<void>;
18
18
  onDayChange: (date: Date[], actionType: ActionType) => void;
19
19
  onModalClose: () => void;
20
20
  onSlotClick: (slotData: BlockTimeData) => void;
@@ -39,4 +39,8 @@ interface ShortcutButtons {
39
39
  onClick: () => void;
40
40
  }
41
41
  export type ShortcutButtonsList = ShortcutButtons[];
42
+ export interface Layers {
43
+ left: number;
44
+ right: number;
45
+ }
42
46
  export {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "license": "MIT",
13
13
  "private": false,
14
- "version": "2.0.2",
14
+ "version": "2.0.4",
15
15
  "keywords": [
16
16
  "react",
17
17
  "component",
@@ -51,6 +51,7 @@
51
51
  "@dnd-kit/core": "^6.3.1",
52
52
  "@dnd-kit/modifiers": "^9.0.0",
53
53
  "@radix-ui/react-checkbox": "^1.3.3",
54
+ "@radix-ui/react-dialog": "^1.1.15",
54
55
  "@react-spring/web": "^10.0.3",
55
56
  "@tailwindcss/vite": "^4.0.15",
56
57
  "@tanstack/react-query": "^5.69.0",
@@ -61,6 +62,7 @@
61
62
  "date-fns": "^4.1.0",
62
63
  "dayjs": "^1.11.13",
63
64
  "motion": "^12.12.1",
65
+ "radix-ui": "^1.4.3",
64
66
  "react-resizable": "^3.0.5",
65
67
  "react-router": "^7.4.0",
66
68
  "react-spinners": "^0.16.1",
@@ -82,7 +84,7 @@
82
84
  "@radix-ui/react-popover": "^1.1.6",
83
85
  "@radix-ui/react-select": "^2.1.6",
84
86
  "@radix-ui/react-separator": "^1.1.2",
85
- "@radix-ui/react-slot": "^1.1.2",
87
+ "@radix-ui/react-slot": "^1.2.4",
86
88
  "@radix-ui/react-tabs": "^1.1.3",
87
89
  "@radix-ui/react-toggle": "^1.1.2",
88
90
  "@radix-ui/react-tooltip": "^1.1.8",
@@ -1,10 +0,0 @@
1
- export declare const DayOfWeek: {
2
- readonly SUN: "SUN";
3
- readonly MON: "MON";
4
- readonly TUE: "TUE";
5
- readonly WED: "WED";
6
- readonly THU: "THU";
7
- readonly FRI: "FRI";
8
- readonly SAT: "SAT";
9
- };
10
- export type DayOfWeek = (typeof DayOfWeek)[keyof typeof DayOfWeek];
@@ -1,2 +0,0 @@
1
- export declare const DAY_TIME_STARTER = "00:00";
2
- export declare const INITIAL_START_TIME = "08:00";
@@ -1,11 +0,0 @@
1
- export declare const PAYMENT_TYPE: {
2
- CREDIT_CARD: string;
3
- DEBIT_CARD: string;
4
- PIX: string;
5
- CASH: string;
6
- };
7
- export declare const PAYMENT_STATUS: {
8
- PENDING: string;
9
- PAID: string;
10
- UNPAID: string;
11
- };
@@ -1 +0,0 @@
1
- export declare const BASE_VALUE: number;
@@ -1 +0,0 @@
1
- export declare const SIDE_OPTIONS: readonly ["top", "right", "bottom", "left"];
@@ -1,40 +0,0 @@
1
- export declare const SYSTEM_COLORS_THEME_1: {
2
- readonly "#3b82f6": "#3b82f6";
3
- readonly "#059669": "#059669";
4
- readonly "#dc2626": "#dc2626";
5
- readonly "#7c3aed": "#7c3aed";
6
- readonly "#ea580c": "#ea580c";
7
- readonly "#0891b2": "#0891b2";
8
- readonly "#be185d": "#be185d";
9
- readonly "#374151": "#374151";
10
- };
11
- export declare const SYSTEM_COLORS_THEME_2: {
12
- readonly "#1e40af": "#1e40af";
13
- readonly "#166534": "#166534";
14
- readonly "#b91c1c": "#b91c1c";
15
- readonly "#6b21a8": "#6b21a8";
16
- readonly "#c2410c": "#c2410c";
17
- readonly "#0e7490": "#0e7490";
18
- readonly "#be123c": "#be123c";
19
- readonly "#1f2937": "#1f2937";
20
- };
21
- export declare const SYSTEM_COLORS_THEME_3: {
22
- readonly "#2563eb": "#2563eb";
23
- readonly "#16a34a": "#16a34a";
24
- readonly "#dc2626": "#dc2626";
25
- readonly "#9333ea": "#9333ea";
26
- readonly "#ea580c": "#ea580c";
27
- readonly "#0d9488": "#0d9488";
28
- readonly "#e11d48": "#e11d48";
29
- readonly "#4b5563": "#4b5563";
30
- };
31
- export declare const SYSTEM_COLORS_THEME_4: {
32
- readonly "#1d4ed8": "#1d4ed8";
33
- readonly "#047857": "#047857";
34
- readonly "#b91c1c": "#b91c1c";
35
- readonly "#7c2d12": "#7c2d12";
36
- readonly "#7c3aed": "#7c3aed";
37
- readonly "#0369a1": "#0369a1";
38
- readonly "#be185d": "#be185d";
39
- readonly "#374151": "#374151";
40
- };
@@ -1,6 +0,0 @@
1
- export declare const URL_PARAM: {
2
- readonly "view-type": "view-type";
3
- readonly DAY: "day";
4
- readonly enterprise: "enterprise";
5
- readonly bookings: "bookings";
6
- };
@@ -1,3 +0,0 @@
1
- export declare const WEEK_DAYS: readonly ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
2
- export type WeekDays = (typeof WEEK_DAYS)[number];
3
- export declare const WEEK_DAYS_FULL_NAME: readonly ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"];
@@ -1,6 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- interface CalendarDayProps {
3
- handleClickDay: (day: Date) => void;
4
- }
5
- declare const TableDayOfWeekColumn: ({ handleClickDay, children, }: PropsWithChildren<CalendarDayProps>) => import("react/jsx-runtime").JSX.Element[];
6
- export default TableDayOfWeekColumn;