@glatam/calendar-ui 1.0.0 β 1.0.1
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 +132 -0
- package/package.json +19 -2
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# π API Reference Guide: @glatam/calendar-ui
|
|
2
|
+
|
|
3
|
+
This is the official technical documentation for the `@glatam/calendar-ui` package. Designed under modern, minimalist (Apple-style), and high-performance standards.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## βοΈ 1. API Reference: `<glatam-calendar>`
|
|
8
|
+
|
|
9
|
+
The primary calendar component displaying the full grid.
|
|
10
|
+
|
|
11
|
+
### Properties and Attributes (Props)
|
|
12
|
+
|
|
13
|
+
| JS Property | HTML Attribute | Type | Default | Description |
|
|
14
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
15
|
+
| `role` | `role` | `'provider' \| 'buyer'` | `'provider'` | `provider` allows editing availability; `buyer` disables blocked slots and enables client booking. |
|
|
16
|
+
| `view` | `view` | `'month' \| 'week' \| 'day'` | `'month'` | Sets the active view. |
|
|
17
|
+
| `locale` | `locale` | `string` | `'es'` | Locale code (IETF tag) for native header and date formatting. |
|
|
18
|
+
| `startOfWeekDay` | `start-of-week-day` | `number` | `0` | First day of the week (`0` = Sunday, `1` = Monday). |
|
|
19
|
+
| `rules` | β | `BlockingRule[]` | `[]` | Array of blocking rules (e.g., weekends, holidays). *JS only.* |
|
|
20
|
+
| `slots` | β | `TimeSlot[]` | *(9am to 6pm)* | Array of daily operating hour slots. *JS only.* |
|
|
21
|
+
| `minDate` | `min-date` | `string` | `''` | Minimum selectable date in `YYYY-MM-DD` format. |
|
|
22
|
+
| `maxDate` | `max-date` | `string` | `''` | Maximum selectable date in `YYYY-MM-DD` format. |
|
|
23
|
+
| `showNeighboringMonth`| `show-neighboring-month`| `boolean` | `true` | If `false`, hides neighboring month dates. |
|
|
24
|
+
| `hostTimezone` | `host-timezone` | `string` | `'America/Bogota'` | Timezone of the host or experience venue. |
|
|
25
|
+
| `activeTimezone` | `active-timezone` | `'host' \| 'local'` | `'local'` | `'local'` automatically shifts grid slots to the buyer's local time. |
|
|
26
|
+
| `tileClassName` | β | `Function` | `null` | Callback `({ date, dateString }) => string` to add classes to monthly cells. |
|
|
27
|
+
|
|
28
|
+
### Events
|
|
29
|
+
|
|
30
|
+
| Event Name | Detail Payload (`event.detail`) | Description |
|
|
31
|
+
| :--- | :--- | :--- |
|
|
32
|
+
| **`booking-selected`** | `{ dateString, start, end, hostStart, hostEnd }` | Fired when a buyer clicks an available slot. Outputs client local and host reference times. |
|
|
33
|
+
| **`rules-changed`** | `{ rules: BlockingRule[] }` | Fired when the provider saves a block or task. |
|
|
34
|
+
| **`date-selected`** | `{ dateString: string }` | Fired when a month cell is clicked. |
|
|
35
|
+
| **`range-selected`** | `{ dateString: string, start: string, end: string }` | Fired when dragging a slot range in week/day views. |
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## βοΈ 2. API Reference: `<glatam-calendar-mini>`
|
|
40
|
+
|
|
41
|
+
The inline checkout popup calendar component.
|
|
42
|
+
|
|
43
|
+
### Properties and Attributes (Props)
|
|
44
|
+
|
|
45
|
+
| JS Property | HTML Attribute | Type | Default | Description |
|
|
46
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
47
|
+
| `role` | `role` | `'provider' \| 'buyer'` | `'buyer'` | Defaults to buyer mode for quick selection. |
|
|
48
|
+
| `locale` | `locale` | `string` | `'es'` | Regional language code. |
|
|
49
|
+
| `rules` | β | `BlockingRule[]` | `[]` | Availability rules loaded from your database. |
|
|
50
|
+
| `slots` | β | `TimeSlot[]` | *(9am to 6pm)* | Daily operating hour slots. |
|
|
51
|
+
| `minDate` | `min-date` | `string` | `''` | Minimum selectable date (`YYYY-MM-DD`). |
|
|
52
|
+
| `maxDate` | `max-date` | `string` | `''` | Maximum selectable date (`YYYY-MM-DD`). |
|
|
53
|
+
| `hostTimezone` | `host-timezone` | `string` | `'America/Bogota'` | Host timezone reference. |
|
|
54
|
+
| `activeTimezone` | `active-timezone` | `'host' \| 'local'` | `'local'` | Converts slot times to client local time when set to `'local'`. |
|
|
55
|
+
|
|
56
|
+
### Events
|
|
57
|
+
|
|
58
|
+
| Event Name | Detail Payload (`event.detail`) | Description |
|
|
59
|
+
| :--- | :--- | :--- |
|
|
60
|
+
| **`booking-selected`** | `{ dateString, start, end, hostStart, hostEnd }` | Fired when a slot is booked. |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## π¨ 3. CSS Custom Properties and Shadow Parts
|
|
65
|
+
|
|
66
|
+
### CSS Variables (Theming)
|
|
67
|
+
Customize the calendar theme by declaring these variables in your global CSS stylesheet:
|
|
68
|
+
|
|
69
|
+
```css
|
|
70
|
+
glatam-calendar, glatam-calendar-mini {
|
|
71
|
+
--glatam-primary: #0071e3; /* Apple Blue branding color */
|
|
72
|
+
--glatam-primary-hover: #0077ed;
|
|
73
|
+
--glatam-bg: #ffffff; /* Grid cell background */
|
|
74
|
+
--glatam-surface: #f5f5f7; /* Header and button background */
|
|
75
|
+
--glatam-border: #e5e5ea; /* Grid line color */
|
|
76
|
+
--glatam-text: #1d1d1f; /* Primary text color */
|
|
77
|
+
--glatam-text-secondary: #86868b; /* Subtexts and captions */
|
|
78
|
+
--glatam-grid-border-radius: 12px;
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### CSS Shadow Parts
|
|
83
|
+
Target month cells from your global CSS using the `::part()` selector.
|
|
84
|
+
|
|
85
|
+
Example to highlight Fridays with a green border:
|
|
86
|
+
```css
|
|
87
|
+
glatam-calendar::part(casual-friday), glatam-calendar-mini::part(casual-friday) {
|
|
88
|
+
border: 2px solid #34c759 !important;
|
|
89
|
+
background-color: rgba(52, 199, 89, 0.05);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## π» 4. Integration Examples
|
|
96
|
+
|
|
97
|
+
### A) HTML + Vanilla JS
|
|
98
|
+
```html
|
|
99
|
+
<glatam-calendar id="calendar" role="provider" min-date="2026-07-01"></glatam-calendar>
|
|
100
|
+
|
|
101
|
+
<script type="module">
|
|
102
|
+
import '@glatam/calendar-ui';
|
|
103
|
+
const cal = document.getElementById('calendar');
|
|
104
|
+
cal.rules = [
|
|
105
|
+
{ id: '1', type: 'weekly', daysOfWeek: [0, 6], description: 'Closed on Weekends' }
|
|
106
|
+
];
|
|
107
|
+
cal.addEventListener('rules-changed', (e) => {
|
|
108
|
+
console.log('Saved availability rules:', e.detail.rules);
|
|
109
|
+
});
|
|
110
|
+
</script>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### B) React 18 / Next.js
|
|
114
|
+
*For Next.js App Router, add `"use client"` at the top of the file.*
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { useEffect, useRef } from 'react';
|
|
118
|
+
import '@glatam/calendar-ui';
|
|
119
|
+
|
|
120
|
+
export default function ReactCalendar() {
|
|
121
|
+
const ref = useRef<any>(null);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (ref.current) {
|
|
125
|
+
ref.current.rules = [{ id: 't1', type: 'date-range', startDate: '2026-07-25', description: 'Daily Scrum' }];
|
|
126
|
+
ref.current.tileClassName = ({ date }: { date: Date }) => date.getDay() === 5 ? 'casual-friday' : '';
|
|
127
|
+
}
|
|
128
|
+
}, []);
|
|
129
|
+
|
|
130
|
+
return <glatam-calendar ref={ref} role="buyer" locale="en" min-date="2026-07-18" />;
|
|
131
|
+
}
|
|
132
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glatam/calendar-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Componente web UI para el calendario @glatam/calendar",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Santiago HernΓ‘ndez Saldarriaga",
|
|
@@ -14,12 +14,29 @@
|
|
|
14
14
|
"import": "./dist/glatam-calendar.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/santiagoshs/glatam-calendar.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/santiagoshs/glatam-calendar/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/santiagoshs/glatam-calendar#readme",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"calendar",
|
|
27
|
+
"booking-system",
|
|
28
|
+
"lit-element",
|
|
29
|
+
"web-components",
|
|
30
|
+
"timezone-safety",
|
|
31
|
+
"availability-scheduler",
|
|
32
|
+
"ssr-compatible"
|
|
33
|
+
],
|
|
17
34
|
"scripts": {
|
|
18
35
|
"build": "vite build",
|
|
19
36
|
"dev": "vite"
|
|
20
37
|
},
|
|
21
38
|
"dependencies": {
|
|
22
|
-
"@glatam/calendar-core": "^1.0.
|
|
39
|
+
"@glatam/calendar-core": "^1.0.1",
|
|
23
40
|
"lit": "^3.1.2"
|
|
24
41
|
},
|
|
25
42
|
"devDependencies": {
|