@forgebuild/hotal-ui 0.1.0 → 0.2.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 +44 -35
- package/dist/hotal-ui.js +3254 -0
- package/dist/index.d.ts +22 -1
- package/package.json +7 -13
- package/dist/ReservationBar.svelte +0 -489
- package/dist/ReservationBar.svelte.d.ts +0 -20
- package/dist/index.js +0 -1
- package/dist/lib/calendar.d.ts +0 -20
- package/dist/lib/calendar.js +0 -72
package/README.md
CHANGED
|
@@ -1,62 +1,71 @@
|
|
|
1
1
|
# @forgebuild/hotal-ui
|
|
2
2
|
|
|
3
|
-
Reusable
|
|
3
|
+
Reusable Web Components for booking and reservation experiences.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
npm install @forgebuild/hotal-ui
|
|
8
|
+
npm install @forgebuild/hotal-ui
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
No peer dependencies — the Svelte runtime is bundled in. Works via a plain `<script type="module">` tag too:
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module" src="https://esm.sh/@forgebuild/hotal-ui"></script>
|
|
15
|
+
```
|
|
12
16
|
|
|
13
17
|
## Components
|
|
14
18
|
|
|
15
|
-
###
|
|
19
|
+
### `<reservation-bar>`
|
|
16
20
|
|
|
17
|
-
A date / guests / time picker bar with a Reserve link, popovers positioned via Floating UI, and calendar/list panels rendered with the native Popover API.
|
|
21
|
+
A date / guests / time picker bar with a Reserve link, popovers positioned via Floating UI, and calendar/list panels rendered with the native Popover API inside an open shadow root.
|
|
18
22
|
|
|
19
|
-
```
|
|
20
|
-
<script
|
|
21
|
-
import
|
|
23
|
+
```html
|
|
24
|
+
<script type="module">
|
|
25
|
+
import '@forgebuild/hotal-ui';
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
const bar = document.querySelector('reservation-bar');
|
|
28
|
+
|
|
29
|
+
// Function-valued and explicitly-false-when-default-is-true props must be
|
|
30
|
+
// set as JS properties, not HTML attributes (attributes are strings only,
|
|
31
|
+
// and HTML boolean-attribute semantics can't express "false" when the
|
|
32
|
+
// prop's own default is true).
|
|
33
|
+
bar.showReserveButton = false;
|
|
34
|
+
bar.fetchAvailableDates = async (partySize) => {
|
|
24
35
|
const res = await fetch(`/api/available-dates?party_size=${partySize}`);
|
|
25
36
|
const { dates } = await res.json();
|
|
26
37
|
return dates;
|
|
27
|
-
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
bar.addEventListener('reservationchange', (e) => console.log(e.detail));
|
|
28
41
|
</script>
|
|
29
42
|
|
|
30
|
-
<
|
|
31
|
-
reserveHref="/reservations"
|
|
32
|
-
closedWeekdays={[0]}
|
|
33
|
-
fetchAvailableDates={fetchAvailableDates}
|
|
34
|
-
onchange={(detail) => console.log(detail)}
|
|
35
|
-
/>
|
|
43
|
+
<reservation-bar reserve-href="/reservations" sync-with-url closed-weekdays="[0]"></reservation-bar>
|
|
36
44
|
```
|
|
37
45
|
|
|
38
|
-
####
|
|
39
|
-
|
|
40
|
-
| Prop | Type | Default | Description |
|
|
41
|
-
| --- | --- | --- | --- |
|
|
42
|
-
| `minGuests` | `number` | `1` | Minimum selectable party size |
|
|
43
|
-
| `maxGuests` | `number` | `20` | Maximum selectable party size |
|
|
44
|
-
| `defaultGuests` | `number` | `2` | Initial party size |
|
|
45
|
-
| `timeSlots` | `string[]` | `'7:00 PM'`–`'11:00 PM'` in 30-min steps | Selectable time options |
|
|
46
|
-
| `defaultTime` | `string` | `'7:00 PM'` | Initial time |
|
|
47
|
-
| `showReserveButton` | `boolean` | `true` | When `false`, selecting any value auto-navigates to the built reserve URL instead of showing a Reserve link |
|
|
48
|
-
| `reserveHref` | `string` | `'/reservations'` | Base URL the built query string (`?date=&guests=&time=`) is appended to |
|
|
49
|
-
| `syncWithUrl` | `boolean` | `false` | Read initial date/guests/time from `location.search` on mount |
|
|
50
|
-
| `closedWeekdays` | `number[]` | `[]` | Weekdays (`0`=Sun–`6`=Sat) to disable in the calendar |
|
|
51
|
-
| `fetchAvailableDates` | `(partySize: number) => Promise<string[]>` | `undefined` | When provided, drives which calendar dates are selectable; refetches when `guests` changes. When omitted, all non-past/non-closed-weekday dates are selectable |
|
|
52
|
-
| `onchange` | `(detail: { date: string; guests: number; time: string }) => void` | `undefined` | Fires whenever the selection changes |
|
|
46
|
+
#### Attributes / properties
|
|
53
47
|
|
|
54
|
-
|
|
48
|
+
| Name | Attribute | Type | Default | Description |
|
|
49
|
+
| --- | --- | --- | --- | --- |
|
|
50
|
+
| `minGuests` | `min-guests` | `number` | `1` | Minimum selectable party size |
|
|
51
|
+
| `maxGuests` | `max-guests` | `number` | `20` | Maximum selectable party size |
|
|
52
|
+
| `defaultGuests` | `default-guests` | `number` | `2` | Initial party size |
|
|
53
|
+
| `timeSlots` | `time-slots` (JSON array) | `string[]` | `'7:00 PM'`–`'11:00 PM'` in 30-min steps | Selectable time options |
|
|
54
|
+
| `defaultTime` | `default-time` | `string` | `'7:00 PM'` | Initial time |
|
|
55
|
+
| `showReserveButton` | `show-reserve-button` | `boolean` | `true` | When `false`, selecting any value auto-navigates instead of showing a Reserve link. **Set as a JS property to get `false`** — see note above. |
|
|
56
|
+
| `reserveHref` | `reserve-href` | `string` | `'/reservations'` | Base URL the built query string is appended to |
|
|
57
|
+
| `syncWithUrl` | `sync-with-url` | `boolean` | `false` | Read initial date/guests/time from `location.search` on mount |
|
|
58
|
+
| `closedWeekdays` | `closed-weekdays` (JSON array) | `number[]` | `[]` | Weekdays (`0`=Sun–`6`=Sat) to disable in the calendar |
|
|
59
|
+
| `fetchAvailableDates` | — (property only) | `(partySize: number) => Promise<string[]>` | `undefined` | Drives which calendar dates are selectable |
|
|
60
|
+
|
|
61
|
+
#### Events
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
`reservationchange` — `CustomEvent<{ date: string; guests: number; time: string }>`, fires whenever the selection changes.
|
|
64
|
+
|
|
65
|
+
#### Theming
|
|
57
66
|
|
|
58
67
|
```css
|
|
59
|
-
|
|
68
|
+
reservation-bar {
|
|
60
69
|
--rb-bar-bg: rgba(14, 58, 62, 0.9);
|
|
61
70
|
--rb-bar-border: rgba(212, 154, 60, 0.4);
|
|
62
71
|
--rb-text-color: #fff;
|
|
@@ -74,7 +83,7 @@ No CSS framework dependency — theme via CSS custom properties on a wrapping el
|
|
|
74
83
|
npm install
|
|
75
84
|
npm run dev # serves demo/
|
|
76
85
|
npm run check # type-check
|
|
77
|
-
npm run build #
|
|
86
|
+
npm run build # library build → dist/
|
|
78
87
|
```
|
|
79
88
|
|
|
80
89
|
## Publishing
|