@object-ui/plugin-calendar 0.3.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/LICENSE +21 -0
- package/README.md +198 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +946 -0
- package/dist/index.umd.cjs +6 -0
- package/dist/src/CalendarView.d.ts +29 -0
- package/dist/src/CalendarView.d.ts.map +1 -0
- package/dist/src/ObjectCalendar.d.ts +13 -0
- package/dist/src/ObjectCalendar.d.ts.map +1 -0
- package/dist/src/calendar-view-renderer.d.ts +9 -0
- package/dist/src/calendar-view-renderer.d.ts.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/package.json +53 -0
- package/src/CalendarView.tsx +504 -0
- package/src/ObjectCalendar.tsx +385 -0
- package/src/calendar-view-renderer.tsx +231 -0
- package/src/index.tsx +37 -0
- package/tsconfig.json +18 -0
- package/vite.config.ts +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ObjectQL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# @object-ui/plugin-calendar
|
|
2
|
+
|
|
3
|
+
Calendar view plugins for Object UI - includes both ObjectQL-integrated and standalone calendar components.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Calendar View** - Monthly calendar with event display
|
|
8
|
+
- **Event Management** - Create, edit, and delete events
|
|
9
|
+
- **ObjectQL Integration** - Connect to ObjectStack data sources
|
|
10
|
+
- **Standalone Mode** - Use with static data or custom backends
|
|
11
|
+
- **Responsive** - Mobile-friendly calendar layouts
|
|
12
|
+
- **Customizable** - Tailwind CSS styling support
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @object-ui/plugin-calendar
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Automatic Registration (Side-Effect Import)
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// In your app entry point (e.g., App.tsx or main.tsx)
|
|
26
|
+
import '@object-ui/plugin-calendar';
|
|
27
|
+
|
|
28
|
+
// Now you can use calendar types in your schemas
|
|
29
|
+
const schema = {
|
|
30
|
+
type: 'calendar-view',
|
|
31
|
+
events: [
|
|
32
|
+
{
|
|
33
|
+
id: '1',
|
|
34
|
+
title: 'Team Meeting',
|
|
35
|
+
start: '2024-01-15T10:00:00',
|
|
36
|
+
end: '2024-01-15T11:00:00'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Manual Registration
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { calendarComponents } from '@object-ui/plugin-calendar';
|
|
46
|
+
import { ComponentRegistry } from '@object-ui/core';
|
|
47
|
+
|
|
48
|
+
// Register calendar components
|
|
49
|
+
Object.entries(calendarComponents).forEach(([type, component]) => {
|
|
50
|
+
ComponentRegistry.register(type, component);
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Schema API
|
|
55
|
+
|
|
56
|
+
### CalendarView
|
|
57
|
+
|
|
58
|
+
Display a monthly calendar with events:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
{
|
|
62
|
+
type: 'calendar-view',
|
|
63
|
+
events?: CalendarEvent[],
|
|
64
|
+
defaultDate?: string, // ISO date string
|
|
65
|
+
onEventClick?: (event) => void,
|
|
66
|
+
onDateClick?: (date) => void,
|
|
67
|
+
className?: string
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Calendar Event Structure
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
interface CalendarEvent {
|
|
75
|
+
id: string;
|
|
76
|
+
title: string;
|
|
77
|
+
start: string; // ISO datetime string
|
|
78
|
+
end: string; // ISO datetime string
|
|
79
|
+
description?: string;
|
|
80
|
+
color?: string; // Tailwind color class
|
|
81
|
+
allDay?: boolean;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
### Basic Calendar
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const schema = {
|
|
91
|
+
type: 'calendar-view',
|
|
92
|
+
events: [
|
|
93
|
+
{
|
|
94
|
+
id: '1',
|
|
95
|
+
title: 'Product Launch',
|
|
96
|
+
start: '2024-02-15T09:00:00',
|
|
97
|
+
end: '2024-02-15T17:00:00',
|
|
98
|
+
color: 'bg-blue-500'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: '2',
|
|
102
|
+
title: 'All-Hands Meeting',
|
|
103
|
+
start: '2024-02-20T14:00:00',
|
|
104
|
+
end: '2024-02-20T15:00:00',
|
|
105
|
+
color: 'bg-green-500'
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
};
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### With ObjectQL Integration
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
const schema = {
|
|
115
|
+
type: 'object-calendar',
|
|
116
|
+
object: 'events',
|
|
117
|
+
titleField: 'name',
|
|
118
|
+
startField: 'startDate',
|
|
119
|
+
endField: 'endDate',
|
|
120
|
+
colorField: 'category.color'
|
|
121
|
+
};
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Interactive Calendar
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
const schema = {
|
|
128
|
+
type: 'calendar-view',
|
|
129
|
+
events: [],
|
|
130
|
+
onEventClick: (event) => {
|
|
131
|
+
console.log('Event clicked:', event);
|
|
132
|
+
// Open event details modal
|
|
133
|
+
},
|
|
134
|
+
onDateClick: (date) => {
|
|
135
|
+
console.log('Date clicked:', date);
|
|
136
|
+
// Create new event
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## ObjectQL Integration
|
|
142
|
+
|
|
143
|
+
When using with ObjectStack, the calendar can automatically fetch and display events:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
import { createObjectStackAdapter } from '@object-ui/data-objectstack';
|
|
147
|
+
|
|
148
|
+
const dataSource = createObjectStackAdapter({
|
|
149
|
+
baseUrl: 'https://api.example.com',
|
|
150
|
+
token: 'your-auth-token'
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const schema = {
|
|
154
|
+
type: 'object-calendar',
|
|
155
|
+
dataSource,
|
|
156
|
+
object: 'calendar_events',
|
|
157
|
+
fields: {
|
|
158
|
+
title: 'title',
|
|
159
|
+
start: 'start_time',
|
|
160
|
+
end: 'end_time',
|
|
161
|
+
color: 'category_color'
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Customization
|
|
167
|
+
|
|
168
|
+
Style the calendar with Tailwind classes:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const schema = {
|
|
172
|
+
type: 'calendar-view',
|
|
173
|
+
className: 'border rounded-lg shadow-lg',
|
|
174
|
+
events: [...]
|
|
175
|
+
};
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## TypeScript Support
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import type { CalendarViewSchema, CalendarEvent } from '@object-ui/plugin-calendar';
|
|
182
|
+
|
|
183
|
+
const event: CalendarEvent = {
|
|
184
|
+
id: '1',
|
|
185
|
+
title: 'Meeting',
|
|
186
|
+
start: '2024-01-15T10:00:00',
|
|
187
|
+
end: '2024-01-15T11:00:00'
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const schema: CalendarViewSchema = {
|
|
191
|
+
type: 'calendar-view',
|
|
192
|
+
events: [event]
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT
|
package/dist/index.d.ts
ADDED