@dialiq/calendar-component 1.0.0

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 ADDED
@@ -0,0 +1,223 @@
1
+ # Calendar Component
2
+
3
+ A React calendar component with booking management capabilities, designed to work with the booking API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @dialiq/calendar-component
9
+ ```
10
+
11
+ ## Dependencies
12
+
13
+ This package requires the following peer dependencies:
14
+
15
+ ```bash
16
+ npm install react react-dom
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Basic Example
22
+
23
+ ```tsx
24
+ import React from 'react';
25
+ import { Calendar } from '@dialiq/calendar-component';
26
+
27
+ function App() {
28
+ return (
29
+ <div style={{ width: '100%', padding: '20px' }}>
30
+ <Calendar
31
+ businessId="acme-corp"
32
+ title="My Calendar"
33
+ />
34
+ </div>
35
+ );
36
+ }
37
+
38
+ export default App;
39
+ ```
40
+
41
+ ### With Resource Filtering
42
+
43
+ ```tsx
44
+ import { Calendar } from '@dialiq/calendar-component';
45
+
46
+ function UserCalendar() {
47
+ return (
48
+ <Calendar
49
+ businessId="acme-corp"
50
+ resourceId="user_A"
51
+ title="User A's Calendar"
52
+ participants={['user_A']}
53
+ />
54
+ );
55
+ }
56
+ ```
57
+
58
+ ### With Custom API URL
59
+
60
+ ```tsx
61
+ import { Calendar } from '@dialiq/calendar-component';
62
+
63
+ function App() {
64
+ return (
65
+ <Calendar
66
+ businessId="acme-corp"
67
+ title="Company Calendar"
68
+ apiBaseUrl="https://api.example.com"
69
+ />
70
+ );
71
+ }
72
+ ```
73
+
74
+ ### Using Environment Variables
75
+
76
+ The component reads the API URL from environment variables if not explicitly provided:
77
+
78
+ **For Create React App:**
79
+
80
+ Create a `.env` file in your project root:
81
+
82
+ ```
83
+ REACT_APP_CALENDAR_API_URL=https://api.example.com
84
+ ```
85
+
86
+ **For other setups:**
87
+
88
+ Set `window.CALENDAR_API_URL` in your HTML:
89
+
90
+ ```html
91
+ <script>
92
+ window.CALENDAR_API_URL = 'https://api.example.com';
93
+ </script>
94
+ ```
95
+
96
+ ### With Event Handlers
97
+
98
+ ```tsx
99
+ import { Calendar, Booking } from '@dialiq/calendar-component';
100
+
101
+ function App() {
102
+ const handleBookingCreate = (booking: Booking) => {
103
+ console.log('Booking created:', booking);
104
+ };
105
+
106
+ const handleBookingClick = (booking: Booking) => {
107
+ console.log('Booking clicked:', booking);
108
+ };
109
+
110
+ return (
111
+ <Calendar
112
+ businessId="acme-corp"
113
+ title="Interactive Calendar"
114
+ onBookingCreate={handleBookingCreate}
115
+ onBookingClick={handleBookingClick}
116
+ participants={['user_A', 'room_101']}
117
+ />
118
+ );
119
+ }
120
+ ```
121
+
122
+ ## Props
123
+
124
+ ### CalendarProps
125
+
126
+ | Prop | Type | Required | Default | Description |
127
+ |------|------|----------|---------|-------------|
128
+ | `businessId` | `string` | Yes | - | Business ID for API requests |
129
+ | `resourceId` | `string` | No | - | Filter bookings by specific resource |
130
+ | `title` | `string` | No | `'Calendar'` | Calendar title displayed at the top |
131
+ | `apiBaseUrl` | `string` | No | From env or `'http://localhost:8080'` | Base URL for API requests |
132
+ | `defaultView` | `'month' \| 'week' \| 'day'` | No | `'month'` | Default calendar view (currently only month is implemented) |
133
+ | `onBookingCreate` | `(booking: Booking) => void` | No | - | Callback when a booking is created |
134
+ | `onBookingClick` | `(booking: Booking) => void` | No | - | Callback when a booking is clicked |
135
+ | `participants` | `string[]` | No | `[]` | Default participants for new bookings |
136
+
137
+ ## Types
138
+
139
+ ### Booking
140
+
141
+ ```typescript
142
+ interface Booking {
143
+ meeting_id: string;
144
+ start: string;
145
+ end: string;
146
+ metadata?: {
147
+ title?: string;
148
+ description?: string;
149
+ organizer?: string;
150
+ [key: string]: any;
151
+ };
152
+ participants?: string[];
153
+ }
154
+ ```
155
+
156
+ ### CreateBookingRequest
157
+
158
+ ```typescript
159
+ interface CreateBookingRequest {
160
+ participants: string[];
161
+ start: string;
162
+ end: string;
163
+ metadata?: {
164
+ title?: string;
165
+ description?: string;
166
+ organizer?: string;
167
+ [key: string]: any;
168
+ };
169
+ }
170
+ ```
171
+
172
+ ## API Functions
173
+
174
+ The package also exports API functions that can be used independently:
175
+
176
+ ```typescript
177
+ import { createBooking, getResourceSchedule, getAllBookings, getMeetingDetails } from '@dialiq/calendar-component';
178
+
179
+ const booking = await createBooking('business-id', {
180
+ participants: ['user_A', 'room_101'],
181
+ start: '2024-11-20T10:00:00.000Z',
182
+ end: '2024-11-20T11:00:00.000Z',
183
+ metadata: { title: 'Team Meeting' }
184
+ });
185
+
186
+ const schedule = await getResourceSchedule(
187
+ 'business-id',
188
+ 'user_A',
189
+ '2024-11-01T00:00:00.000Z',
190
+ '2024-11-30T23:59:59.000Z'
191
+ );
192
+
193
+ const allBookings = await getAllBookings(
194
+ 'business-id',
195
+ '2024-11-01T00:00:00.000Z',
196
+ '2024-11-30T23:59:59.000Z'
197
+ );
198
+
199
+ const meeting = await getMeetingDetails('business-id', 'meeting-id');
200
+ ```
201
+
202
+ ## Features
203
+
204
+ - 📅 **Monthly Calendar View**: Clean, intuitive calendar interface
205
+ - ➕ **Create Bookings**: Built-in modal for creating new bookings
206
+ - 👥 **Multi-Participant Support**: Book meetings with multiple participants
207
+ - 🔍 **Resource Filtering**: View bookings for specific resources
208
+ - 🎨 **Responsive Design**: Works on desktop and mobile devices
209
+ - ⚙️ **Configurable**: Extensive props for customization
210
+ - 🌐 **Environment Variables**: Flexible API URL configuration
211
+ - 📦 **Standalone Package**: Can be installed and used in any React project
212
+
213
+ ## Development
214
+
215
+ ```bash
216
+ npm install
217
+ npm run build
218
+ npm run dev
219
+ ```
220
+
221
+ ## License
222
+
223
+ MIT
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { CalendarProps } from './types';
3
+ import './Calendar.css';
4
+ declare const Calendar: React.FC<CalendarProps>;
5
+ export default Calendar;
6
+ //# sourceMappingURL=Calendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../src/Calendar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAgBhE,OAAO,EAAE,aAAa,EAAW,MAAM,SAAS,CAAC;AAGjD,OAAO,gBAAgB,CAAC;AAExB,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAkOrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Booking } from './types';
3
+ import './CreateBookingModal.css';
4
+ interface CreateBookingModalProps {
5
+ businessId: string;
6
+ apiBaseUrl?: string;
7
+ initialDate: Date;
8
+ participants: string[];
9
+ onClose: () => void;
10
+ onBookingCreated: (booking: Booking) => void;
11
+ }
12
+ declare const CreateBookingModal: React.FC<CreateBookingModalProps>;
13
+ export default CreateBookingModal;
14
+ //# sourceMappingURL=CreateBookingModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateBookingModal.d.ts","sourceRoot":"","sources":["../src/CreateBookingModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,0BAA0B,CAAC;AAElC,UAAU,uBAAuB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,gBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CA0KzD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
package/dist/api.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Booking, CreateBookingRequest } from './types';
2
+ export declare const createBooking: (businessId: string, booking: CreateBookingRequest, apiBaseUrl?: string) => Promise<Booking>;
3
+ export declare const getResourceSchedule: (businessId: string, resourceId: string, startDate: string, endDate: string, apiBaseUrl?: string) => Promise<Booking[]>;
4
+ export declare const getAllBookings: (businessId: string, startDate: string, endDate: string, apiBaseUrl?: string) => Promise<Booking[]>;
5
+ export declare const getMeetingDetails: (businessId: string, meetingId: string, apiBaseUrl?: string) => Promise<Booking>;
6
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAYxD,eAAO,MAAM,aAAa,GACxB,YAAY,MAAM,EAClB,SAAS,oBAAoB,EAC7B,aAAa,MAAM,KAClB,OAAO,CAAC,OAAO,CAgBjB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,YAAY,MAAM,EAClB,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,SAAS,MAAM,EACf,aAAa,MAAM,KAClB,OAAO,CAAC,OAAO,EAAE,CAcnB,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,SAAS,MAAM,EACf,aAAa,MAAM,KAClB,OAAO,CAAC,OAAO,EAAE,CAcnB,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,YAAY,MAAM,EAClB,WAAW,MAAM,EACjB,aAAa,MAAM,KAClB,OAAO,CAAC,OAAO,CAUjB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as Calendar } from './Calendar';
2
+ export type { CalendarProps, Booking, CreateBookingRequest } from './types';
3
+ export { createBooking, getResourceSchedule, getAllBookings, getMeetingDetails } from './api';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC"}