@htmlbricks/hb-calendar-appointments 0.71.35 → 0.71.37
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 +127 -27
- package/manifest.json +34 -22
- package/package.json +1 -1
- package/types/webcomponent.type.d.json +0 -3
- package/types/webcomponent.type.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,46 +1,146 @@
|
|
|
1
|
-
|
|
1
|
+
# `hb-calendar-appointments`
|
|
2
2
|
|
|
3
|
-
**Category:** calendar
|
|
3
|
+
**Category:** calendar · **Tags:** calendar, appointments
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Summary
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
A **month agenda** web component: it shows **only events in the visible month**, grouped **by calendar day**, with **per-day headings** and **clickable rows** for each appointment. An optional **header** switches the month and exposes slots for labels and navigation chrome.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## What it does
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- Filters `events` to the month implied by `date` (month + year).
|
|
12
|
+
- Sorts events by `date` when `events` is parsed from a string.
|
|
13
|
+
- Renders one block per day that has at least one event: weekday (long, locale from `navigator.languages[0]` or `en`), day-of-month number, then rows ordered as in the sorted list.
|
|
14
|
+
- Each row shows a Bootstrap Icons dot (`bi-dot`), time (`HH:mm`), and `label`; optional per-event `color` overrides the icon color via inline style.
|
|
15
|
+
- Month navigation (`disable_header` off) updates `date` and emits **`changeCalendarDate`**.
|
|
16
|
+
- Row click emits **`calendarEventClick`** with the event `id`.
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
The `date-holidays` package is imported and an `IT` instance is constructed in script, but **that object is not used** anywhere in the template or derived data (no holiday-based labels or filtering in the current implementation).
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
| --- | --- | --- |
|
|
17
|
-
| `id` | string (optional) | Element identifier. |
|
|
18
|
-
| `style` | string (optional) | Inline style string. |
|
|
19
|
-
| `date` | Date (optional) | Current calendar month context; pass as ISO string / parsed JSON in HTML. |
|
|
20
|
-
| `events` | array (optional) | JSON array of `{ date: Date; label: string; id: string; link?; icon?; color? }`. |
|
|
21
|
-
| `selected` | Date (optional) | Selected day. |
|
|
22
|
-
| `disable_header` | boolean (optional) | Hide the navigation header when true. |
|
|
20
|
+
## UI / layout
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
| Region | Behavior |
|
|
23
|
+
|--------|------------|
|
|
24
|
+
| **Header** (optional) | Flex row: default title (month name + year via `Intl` + `dayjs`), prev/next controls. Wrapped in `part="calendar-header"`. Inner title span uses `part="calendar-current-time-header"`. Entire header hidden when `disable_header` is enabled (see logic below). |
|
|
25
|
+
| **Slots in header** | `header` wraps title + nav; `calendar_month` replaces default month/year text; `header_month_icon_prev` / `header_month_icon_next` replace default buttons (still wired to `changeMonth(-1)` / `changeMonth(1)` via outer `onclick`). |
|
|
26
|
+
| **Agenda list** | Under `#appointments_container`: for each day bucket, a bold day line (`events_day`) then `event_row` blocks (focusable `role="button"`). If the month has no events, the list area is empty (no placeholder). |
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
Icons are loaded for the shadow tree via `styles/webcomponent.scss` (Bootstrap Icons font). A `<svelte:head>` stylesheet link is also present but does not apply inside shadow DOM by itself.
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
- **`changeCalendarDate`** — `{ date: Date }`
|
|
30
|
-
- **`changeSelectedDate`** — `{ selectedDate: Date }`
|
|
30
|
+
## Logic
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
- **Visible month:** `month` / `year` derived from `date` (`dayjs`).
|
|
33
|
+
- **Filtering:** `monthsEvent` keeps events whose month and year match `date`.
|
|
34
|
+
- **Grouping:** `eventsOfThisMonthByDay` buckets by day-of-month (`D`); first occurrence of a day creates the bucket, further events append to that bucket’s array.
|
|
35
|
+
- **`disable_header`:** In `$effect`, string values are normalized: `true` / `yes` / `""` (empty) → header hidden; otherwise shown.
|
|
36
|
+
- **`events`:** If a string, `JSON.parse`; then sorted ascending by `new Date(a.date)` vs `new Date(b.date)`.
|
|
37
|
+
- **`selected`:** If a string, parsed with `dayjs(selected).toDate()` for in-component use. There is a **`selectDay`** helper that sets `selected` and would emit **`changeSelectedDate`**, but **nothing in the default markup calls `selectDay`**, so that event is **not** produced by the shipped UI (only the typed API / future wiring).
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
- Italian holiday data is built in; adjust expectations for non-IT locales.
|
|
36
|
-
- Shadow DOM exposes named parts for deeper styling.
|
|
37
|
-
- Pass `events` and dates as JSON strings from HTML attributes; runtime parsing depends on the web component bridge.
|
|
39
|
+
## Custom element
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
```text
|
|
42
|
+
hb-calendar-appointments
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Attributes / properties
|
|
46
|
+
|
|
47
|
+
HTML attributes are strings. Align with your bridge; the component’s `$effect` coerces some values.
|
|
48
|
+
|
|
49
|
+
| Name | Typing (`Component`) | Notes |
|
|
50
|
+
|------|----------------------|--------|
|
|
51
|
+
| `id` | `string` (optional) | Passed through like other props; host `id` if set as attribute. |
|
|
52
|
+
| `date` | `Date` (optional) | Default: start of current month (`dayjs().startOf("month")`). Drives which month’s events are shown. From HTML, use an ISO-like string your runtime parses to `Date` / or set the property in JS. |
|
|
53
|
+
| `events` | `IEvent[]` (optional) | JSON array string from attributes; each item: `date`, `label`, `id` required for useful rows; `link`, `icon`, `color` optional (`link` / `icon` are **not read** by the template). |
|
|
54
|
+
| `selected` | `Date` (optional) | Parsed from string in `$effect`. No built-in control updates selection or emits `changeSelectedDate`. |
|
|
55
|
+
| `disable_header` | `boolean` (optional) | Default `false`. For attributes, this codebase often uses **`yes`** / **`no`**; the effect also treats string `"true"`, `"yes"`, and `""` as hide header. |
|
|
56
|
+
|
|
57
|
+
### `IEvent` (from typings)
|
|
58
|
+
|
|
59
|
+
| Field | Type | Used in UI |
|
|
60
|
+
|-------|------|------------|
|
|
61
|
+
| `date` | `Date` | Filter, sort, time column, weekday/day grouping |
|
|
62
|
+
| `label` | `string` | Row text (`aria-label`, visible label) |
|
|
63
|
+
| `id` | `string` | `calendarEventClick` payload |
|
|
64
|
+
| `link` | optional `string` | No |
|
|
65
|
+
| `icon` | optional `string` | No |
|
|
66
|
+
| `color` | optional `string` | Icon color (inline `style`) |
|
|
67
|
+
|
|
68
|
+
## Events (`CustomEvent`)
|
|
69
|
+
|
|
70
|
+
| Name | `detail` | When emitted (current implementation) |
|
|
71
|
+
|------|-----------|----------------------------------------|
|
|
72
|
+
| `calendarEventClick` | `{ eventId: string }` | User activates an `.event_row` (click path in template). |
|
|
73
|
+
| `changeCalendarDate` | `{ date: Date }` | Prev/next month navigation runs `changeMonth`. |
|
|
74
|
+
| `changeSelectedDate` | `{ selectedDate: Date }` | Only if something called `selectDay` — **not wired** in the default Svelte markup. |
|
|
75
|
+
|
|
76
|
+
## Styling
|
|
77
|
+
|
|
78
|
+
### CSS custom properties
|
|
79
|
+
|
|
80
|
+
Documented in `extra/docs.ts`; defaults from code (`styles/webcomponent.scss` + descriptions in docs):
|
|
81
|
+
|
|
82
|
+
| Variable | Kind | Default / source | Role |
|
|
83
|
+
|----------|------|-------------------|------|
|
|
84
|
+
| `--hb-calendar-event-button-color` | color | `var(--bulma-link, #485fc7)` on `:host` | Dot icon color when `event.color` is not set. |
|
|
85
|
+
| `--bulma-radius` | size | theme / `0.25rem` fallback in SCSS | `border-radius` on `.event_row`. |
|
|
86
|
+
| `--bulma-border` | color | theme / `hsl(0deg 0% 86%)` fallback | `outline` on `.event_row:hover`. |
|
|
87
|
+
|
|
88
|
+
### CSS parts (`::part`)
|
|
89
|
+
|
|
90
|
+
| Part | Description |
|
|
91
|
+
|------|-------------|
|
|
92
|
+
| `calendar-header` | Outer header strip (month navigation + title area). |
|
|
93
|
+
| `calendar-current-time-header` | Inner title span (month slot + default month/year text). |
|
|
94
|
+
|
|
95
|
+
## Slots
|
|
96
|
+
|
|
97
|
+
| Slot | Description |
|
|
98
|
+
|------|-------------|
|
|
99
|
+
| `header_month_icon_prev` | Replace default “previous month” control (e.g. icon button). |
|
|
100
|
+
| `header_month_icon_next` | Replace default “next month” control. |
|
|
101
|
+
| `header` | Wraps the whole header row (title + nav); default fills month + controls. |
|
|
102
|
+
| `calendar_month` | Replace/wrap visible month/year label in the header row. |
|
|
103
|
+
|
|
104
|
+
## Typings
|
|
105
|
+
|
|
106
|
+
Authoring types live in `types/webcomponent.type.d.ts`:
|
|
107
|
+
|
|
108
|
+
- **`Component`** — `id`, `date`, `events`, `selected`, `disable_header`
|
|
109
|
+
- **`IEvent`** — event record shape
|
|
110
|
+
- **`Events`** — `calendarEventClick`, `changeCalendarDate`, `changeSelectedDate`
|
|
111
|
+
|
|
112
|
+
Built outputs (`types/html-elements.d.ts`, `types/svelte-elements.d.ts`) are regenerated with `npm run build:wc`.
|
|
113
|
+
|
|
114
|
+
## Example HTML
|
|
40
115
|
|
|
41
116
|
```html
|
|
42
117
|
<hb-calendar-appointments
|
|
43
|
-
|
|
118
|
+
id="agenda-1"
|
|
119
|
+
disable_header="no"
|
|
120
|
+
date="2026-04-01T00:00:00.000Z"
|
|
121
|
+
events='[
|
|
122
|
+
{"id":"a1","label":"Stand-up","date":"2026-04-17T09:00:00.000Z"},
|
|
123
|
+
{"id":"a2","label":"Review","date":"2026-04-17T15:30:00.000Z","color":"#b86bff"}
|
|
124
|
+
]'
|
|
125
|
+
></hb-calendar-appointments>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
With hidden header:
|
|
129
|
+
|
|
130
|
+
```html
|
|
131
|
+
<hb-calendar-appointments
|
|
132
|
+
disable_header="yes"
|
|
44
133
|
events='[{"id":"1","label":"Meeting","date":"2026-03-15T10:00:00.000Z"}]'
|
|
45
134
|
></hb-calendar-appointments>
|
|
46
135
|
```
|
|
136
|
+
|
|
137
|
+
Listen in JavaScript, for example:
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
document.querySelector("hb-calendar-appointments")?.addEventListener("calendarEventClick", (e) => {
|
|
141
|
+
console.log(e.detail.eventId);
|
|
142
|
+
});
|
|
143
|
+
document.querySelector("hb-calendar-appointments")?.addEventListener("changeCalendarDate", (e) => {
|
|
144
|
+
console.log(e.detail.date);
|
|
145
|
+
});
|
|
146
|
+
```
|
package/manifest.json
CHANGED
|
@@ -81,9 +81,6 @@
|
|
|
81
81
|
"selected": {
|
|
82
82
|
"format": "date-time",
|
|
83
83
|
"type": "string"
|
|
84
|
-
},
|
|
85
|
-
"style": {
|
|
86
|
-
"type": "string"
|
|
87
84
|
}
|
|
88
85
|
},
|
|
89
86
|
"type": "object"
|
|
@@ -158,35 +155,50 @@
|
|
|
158
155
|
{
|
|
159
156
|
"name": "--hb-calendar-event-button-color",
|
|
160
157
|
"valueType": "color",
|
|
161
|
-
"defaultValue": "",
|
|
162
|
-
"description": "
|
|
158
|
+
"defaultValue": "(from `--bulma-link`)",
|
|
159
|
+
"description": "Color for the event marker icon (Bootstrap Icon) in each row; host default on `:host` maps to `--bulma-link`."
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "--bulma-radius",
|
|
163
|
+
"valueType": "number",
|
|
164
|
+
"defaultValue": "0.375rem",
|
|
165
|
+
"description": "Corner radius for interactive event rows on hover."
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "--bulma-border",
|
|
169
|
+
"valueType": "color",
|
|
170
|
+
"defaultValue": "(theme)",
|
|
171
|
+
"description": "Outline color for hovered event rows."
|
|
163
172
|
}
|
|
164
173
|
],
|
|
165
174
|
"parts": [
|
|
166
175
|
{
|
|
167
|
-
"name": "calendar-header"
|
|
168
|
-
|
|
169
|
-
{
|
|
170
|
-
"name": "calendar-current-time-header"
|
|
176
|
+
"name": "calendar-header",
|
|
177
|
+
"description": "Outer header strip (month navigation and title); style layout and chrome of the top bar."
|
|
171
178
|
},
|
|
172
179
|
{
|
|
173
|
-
"name": "
|
|
180
|
+
"name": "calendar-current-time-header",
|
|
181
|
+
"description": "Inner header row showing the current month label and controls next to the navigation slots."
|
|
174
182
|
}
|
|
175
183
|
]
|
|
176
184
|
},
|
|
177
185
|
"contributors": [],
|
|
178
186
|
"htmlSlots": [
|
|
179
187
|
{
|
|
180
|
-
"name": "header_month_icon_prev"
|
|
188
|
+
"name": "header_month_icon_prev",
|
|
189
|
+
"description": "Previous-month control inside the header (e.g. custom chevron or icon button)."
|
|
181
190
|
},
|
|
182
191
|
{
|
|
183
|
-
"name": "header_month_icon_next"
|
|
192
|
+
"name": "header_month_icon_next",
|
|
193
|
+
"description": "Next-month control inside the header (e.g. custom chevron or icon button)."
|
|
184
194
|
},
|
|
185
195
|
{
|
|
186
|
-
"name": "header"
|
|
196
|
+
"name": "header",
|
|
197
|
+
"description": "Optional content above the month line; wraps the default title when empty."
|
|
187
198
|
},
|
|
188
199
|
{
|
|
189
|
-
"name": "calendar_month"
|
|
200
|
+
"name": "calendar_month",
|
|
201
|
+
"description": "Replace or wrap the visible month / year label in the header row."
|
|
190
202
|
}
|
|
191
203
|
],
|
|
192
204
|
"i18n": [],
|
|
@@ -197,12 +209,12 @@
|
|
|
197
209
|
"data": {
|
|
198
210
|
"events": [
|
|
199
211
|
{
|
|
200
|
-
"date": "2026-04-
|
|
212
|
+
"date": "2026-04-17T00:28:07.061Z",
|
|
201
213
|
"id": "test",
|
|
202
214
|
"label": "thetest"
|
|
203
215
|
},
|
|
204
216
|
{
|
|
205
|
-
"date": "2026-03-
|
|
217
|
+
"date": "2026-03-31T00:28:07.061Z",
|
|
206
218
|
"id": "test2",
|
|
207
219
|
"label": "thetest start",
|
|
208
220
|
"color": "red"
|
|
@@ -223,12 +235,12 @@
|
|
|
223
235
|
"data": {
|
|
224
236
|
"events": [
|
|
225
237
|
{
|
|
226
|
-
"date": "2026-04-
|
|
238
|
+
"date": "2026-04-17T00:28:07.061Z",
|
|
227
239
|
"id": "test",
|
|
228
240
|
"label": "thetest"
|
|
229
241
|
},
|
|
230
242
|
{
|
|
231
|
-
"date": "2026-03-
|
|
243
|
+
"date": "2026-03-31T00:28:07.061Z",
|
|
232
244
|
"id": "test2",
|
|
233
245
|
"label": "thetest start",
|
|
234
246
|
"color": "red"
|
|
@@ -243,18 +255,18 @@
|
|
|
243
255
|
"data": {
|
|
244
256
|
"events": [
|
|
245
257
|
{
|
|
246
|
-
"date": "2026-04-
|
|
258
|
+
"date": "2026-04-17T00:28:07.061Z",
|
|
247
259
|
"id": "test",
|
|
248
260
|
"label": "thetest"
|
|
249
261
|
},
|
|
250
262
|
{
|
|
251
|
-
"date": "2026-03-
|
|
263
|
+
"date": "2026-03-31T00:28:07.061Z",
|
|
252
264
|
"id": "test2",
|
|
253
265
|
"label": "thetest start",
|
|
254
266
|
"color": "red"
|
|
255
267
|
}
|
|
256
268
|
],
|
|
257
|
-
"selected": "2026-04-
|
|
269
|
+
"selected": "2026-04-17T00:28:07.061Z"
|
|
258
270
|
}
|
|
259
271
|
}
|
|
260
272
|
],
|
|
@@ -279,5 +291,5 @@
|
|
|
279
291
|
"size": {},
|
|
280
292
|
"iifePath": "main.iife.js",
|
|
281
293
|
"repoName": "@htmlbricks/hb-calendar-appointments",
|
|
282
|
-
"version": "0.71.
|
|
294
|
+
"version": "0.71.37"
|
|
283
295
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-calendar-appointments",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.37",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "Month agenda view: events for the current month are grouped by calendar day and listed chronologically with weekday, day number, time, and colored markers. Optional header with month navigation; changing month or selecting a day dispatches `changeCalendarDate`, `changeSelectedDate`, and clicking a row dispatches `calendarEventClick`. Uses Italian public holidays metadata and accepts `events` as JSON.",
|
|
6
6
|
"licenses": [
|