@resira/ui 0.4.6 → 0.4.8
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 +238 -238
- package/dist/index.cjs +119 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +115 -2
- package/dist/index.d.ts +115 -2
- package/dist/index.js +118 -8
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2972 -2972
- package/package.json +59 -59
package/README.md
CHANGED
|
@@ -1,238 +1,238 @@
|
|
|
1
|
-
# @resira/ui v0.3.2
|
|
2
|
-
|
|
3
|
-
React booking UI for Resira. It includes a ready-to-embed widget, modal flow, provider, hooks, and lower-level components for custom booking experiences.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @resira/ui@0.3.2 @resira/sdk@0.3.1
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Peer dependencies:
|
|
12
|
-
|
|
13
|
-
- react >= 18
|
|
14
|
-
- react-dom >= 18
|
|
15
|
-
|
|
16
|
-
## Quick start
|
|
17
|
-
|
|
18
|
-
```tsx
|
|
19
|
-
import { ResiraProvider, ResiraBookingWidget } from "@resira/ui";
|
|
20
|
-
import "@resira/ui/styles.css";
|
|
21
|
-
|
|
22
|
-
export function App() {
|
|
23
|
-
return (
|
|
24
|
-
<ResiraProvider
|
|
25
|
-
apiKey="resira_live_abc123"
|
|
26
|
-
resourceId="prop-1"
|
|
27
|
-
domain="rental"
|
|
28
|
-
>
|
|
29
|
-
<ResiraBookingWidget />
|
|
30
|
-
</ResiraProvider>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
You can also use the higher-level modal component:
|
|
36
|
-
|
|
37
|
-
```tsx
|
|
38
|
-
import { BookingModal } from "@resira/ui";
|
|
39
|
-
import "@resira/ui/styles.css";
|
|
40
|
-
|
|
41
|
-
<BookingModal apiKey="resira_live_abc123" domain="watersport" />;
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Supported domains
|
|
45
|
-
|
|
46
|
-
| Domain | Flow |
|
|
47
|
-
| --- | --- |
|
|
48
|
-
| `rental` | Calendar -> guest details -> terms -> payment |
|
|
49
|
-
| `restaurant` | Time slots -> guest details -> terms -> payment |
|
|
50
|
-
| `watersport` | Service -> time -> guest details -> terms -> payment |
|
|
51
|
-
| `service` | Service -> time -> guest details -> terms -> payment |
|
|
52
|
-
|
|
53
|
-
## ResiraProvider
|
|
54
|
-
|
|
55
|
-
`ResiraProvider` initializes the SDK client, loads public property configuration, resolves theme and locale values, and provides booking state to child components.
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
<ResiraProvider
|
|
59
|
-
apiKey="resira_live_..."
|
|
60
|
-
resourceId="resource-id"
|
|
61
|
-
domain="rental"
|
|
62
|
-
config={{
|
|
63
|
-
theme: {
|
|
64
|
-
primaryColor: "#18181b",
|
|
65
|
-
borderRadius: "16px",
|
|
66
|
-
},
|
|
67
|
-
locale: {
|
|
68
|
-
bookNow: "Book now",
|
|
69
|
-
},
|
|
70
|
-
serviceLayout: "vertical",
|
|
71
|
-
visibleServiceCount: 4,
|
|
72
|
-
groupServicesByCategory: true,
|
|
73
|
-
stripePublishableKey: "pk_live_...",
|
|
74
|
-
showTerms: true,
|
|
75
|
-
showWaiver: false,
|
|
76
|
-
depositPercent: 50,
|
|
77
|
-
}}
|
|
78
|
-
>
|
|
79
|
-
<ResiraBookingWidget />
|
|
80
|
-
</ResiraProvider>
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Provider props
|
|
84
|
-
|
|
85
|
-
| Prop | Type | Required | Description |
|
|
86
|
-
| --- | --- | --- | --- |
|
|
87
|
-
| `apiKey` | `string` | Yes | Resira public API key |
|
|
88
|
-
| `resourceId` | `string` | No | Default resource or property ID. Omit for catalog mode |
|
|
89
|
-
| `domain` | `"rental" \| "restaurant" \| "watersport" \| "service"` | Yes | Booking flow type |
|
|
90
|
-
| `config` | `ResiraProviderConfig` | No | Theme, locale, layout, payment, and rendering overrides |
|
|
91
|
-
| `onClose` | `() => void` | No | Close callback for modal-driven flows |
|
|
92
|
-
|
|
93
|
-
### Important config options
|
|
94
|
-
|
|
95
|
-
| Config field | Type | Description |
|
|
96
|
-
| --- | --- | --- |
|
|
97
|
-
| `theme` | `ResiraTheme` | Theme token overrides |
|
|
98
|
-
| `locale` | `ResiraLocale` | Text and i18n overrides |
|
|
99
|
-
| `domainConfig` | `DomainConfig` | Domain-specific rules such as min/max party size or duration |
|
|
100
|
-
| `classNames` | `ResiraClassNames` | CSS class overrides |
|
|
101
|
-
| `serviceLayout` | `"vertical" \| "horizontal"` | Product selector layout |
|
|
102
|
-
| `visibleServiceCount` | `number` | Number of visible services before scrolling |
|
|
103
|
-
| `groupServicesByCategory` | `boolean` | Group services by linked equipment type |
|
|
104
|
-
| `renderServiceCard` | `(product, selected) => ReactNode` | Custom service card rendering |
|
|
105
|
-
| `baseUrl` | `string` | Optional API origin override |
|
|
106
|
-
| `baseUrls` | `Array<string \| WeightedBaseUrl>` | Optional ordered fallback origin list |
|
|
107
|
-
| `stripePublishableKey` | `string` | Stripe publishable key override |
|
|
108
|
-
| `termsText` | `string` | Terms text override |
|
|
109
|
-
| `waiverText` | `string` | Waiver text override |
|
|
110
|
-
| `showWaiver` | `boolean` | Show waiver checkbox |
|
|
111
|
-
| `showTerms` | `boolean` | Show terms checkbox |
|
|
112
|
-
| `showRemainingSpots` | `boolean` | Show remaining capacity labels |
|
|
113
|
-
| `depositPercent` | `number` | Percent charged upfront |
|
|
114
|
-
|
|
115
|
-
## Styling and customization
|
|
116
|
-
|
|
117
|
-
Import the stylesheet once:
|
|
118
|
-
|
|
119
|
-
```tsx
|
|
120
|
-
import "@resira/ui/styles.css";
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
The main customization layers are:
|
|
124
|
-
|
|
125
|
-
- `theme` tokens on `ResiraProvider`
|
|
126
|
-
- CSS custom properties under `.resira-root`
|
|
127
|
-
- `classNames` and `renderServiceCard` for deeper control
|
|
128
|
-
|
|
129
|
-
For more styling details, see [CUSTOMIZATION.md](./CUSTOMIZATION.md).
|
|
130
|
-
|
|
131
|
-
## Payment and remote config
|
|
132
|
-
|
|
133
|
-
The provider loads public configuration such as:
|
|
134
|
-
|
|
135
|
-
- Stripe publishable key
|
|
136
|
-
- deposit percentage
|
|
137
|
-
- terms requirements
|
|
138
|
-
- refund policy
|
|
139
|
-
|
|
140
|
-
You can override those values locally through `config` when needed.
|
|
141
|
-
|
|
142
|
-
## Hooks and components
|
|
143
|
-
|
|
144
|
-
Main exports:
|
|
145
|
-
|
|
146
|
-
- `ResiraProvider`
|
|
147
|
-
- `useResira`
|
|
148
|
-
- `ResiraBookingWidget`
|
|
149
|
-
- `BookingModal`
|
|
150
|
-
- `BookingCalendar`
|
|
151
|
-
- `TimeSlotPicker`
|
|
152
|
-
- `ResourcePicker`
|
|
153
|
-
- `ProductSelector`
|
|
154
|
-
- `GuestForm`
|
|
155
|
-
- `validateGuestForm`
|
|
156
|
-
- `WaiverConsent`
|
|
157
|
-
- `PaymentForm`
|
|
158
|
-
- `SummaryPreview`
|
|
159
|
-
- `ConfirmationView`
|
|
160
|
-
- `useAvailability`
|
|
161
|
-
- `useReservation`
|
|
162
|
-
- `useResources`
|
|
163
|
-
- `useProducts`
|
|
164
|
-
- `usePaymentIntent`
|
|
165
|
-
- `DishShowcase`
|
|
166
|
-
- `useDish`
|
|
167
|
-
- `useDishes`
|
|
168
|
-
|
|
169
|
-
## DishShowcase
|
|
170
|
-
|
|
171
|
-
The `DishShowcase` component renders a trigger button that opens a nested modal for browsing dishes with 3D model previews and AR viewing. It uses `<model-viewer>` for the 3D experience.
|
|
172
|
-
|
|
173
|
-
### Prerequisites
|
|
174
|
-
|
|
175
|
-
Load the `<model-viewer>` web component in your page:
|
|
176
|
-
|
|
177
|
-
```html
|
|
178
|
-
<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0/model-viewer.min.js"></script>
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Single dish (by ID)
|
|
182
|
-
|
|
183
|
-
The `dishId` is shown on the dish page in the admin dashboard for easy copying.
|
|
184
|
-
|
|
185
|
-
```tsx
|
|
186
|
-
import { DishShowcase } from "@resira/ui";
|
|
187
|
-
|
|
188
|
-
<DishShowcase dishId="dish-uuid">
|
|
189
|
-
View in 3D
|
|
190
|
-
</DishShowcase>
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Browse all dishes
|
|
194
|
-
|
|
195
|
-
```tsx
|
|
196
|
-
<DishShowcase showAll>
|
|
197
|
-
Explore Our Menu
|
|
198
|
-
</DishShowcase>
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Filter by category
|
|
202
|
-
|
|
203
|
-
```tsx
|
|
204
|
-
<DishShowcase showAll category="Main">
|
|
205
|
-
View Main Courses
|
|
206
|
-
</DishShowcase>
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### Props
|
|
210
|
-
|
|
211
|
-
| Prop | Type | Default | Description |
|
|
212
|
-
| --- | --- | --- | --- |
|
|
213
|
-
| `dishId` | `string` | — | Single dish ID, opens directly to 3D viewer |
|
|
214
|
-
| `showAll` | `boolean` | `false` | Show all dishes in a browsable grid |
|
|
215
|
-
| `category` | `string` | — | Filter dishes by category |
|
|
216
|
-
| `className` | `string` | — | Custom CSS class on the trigger button |
|
|
217
|
-
| `style` | `CSSProperties` | — | Custom inline styles on the trigger button |
|
|
218
|
-
| `children` | `ReactNode` | required | Button label / content |
|
|
219
|
-
|
|
220
|
-
### Inside a BookingModal
|
|
221
|
-
|
|
222
|
-
`DishShowcase` works as a nested modal — it renders above the booking modal with its own overlay and focus trap:
|
|
223
|
-
|
|
224
|
-
```tsx
|
|
225
|
-
<BookingModal apiKey="resira_live_..." domain="restaurant">
|
|
226
|
-
<DishShowcase dishId="dish-uuid" style={{ marginBottom: 12 }}>
|
|
227
|
-
Preview this dish in 3D
|
|
228
|
-
</DishShowcase>
|
|
229
|
-
</BookingModal>
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## Notes
|
|
233
|
-
|
|
234
|
-
- The widget supports catalog mode when `resourceId` is omitted.
|
|
235
|
-
- Service and watersport flows group services by linked equipment category by default.
|
|
236
|
-
- Loading and error states now announce themselves to assistive technologies on the main widget surfaces.
|
|
237
|
-
- Client-side API origin stickiness/load-balancing has been removed; routing is deterministic unless you pass explicit fallback origins.
|
|
238
|
-
- The package is intended for browser usage and ships CSS separately via `@resira/ui/styles.css`.
|
|
1
|
+
# @resira/ui v0.3.2
|
|
2
|
+
|
|
3
|
+
React booking UI for Resira. It includes a ready-to-embed widget, modal flow, provider, hooks, and lower-level components for custom booking experiences.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @resira/ui@0.3.2 @resira/sdk@0.3.1
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies:
|
|
12
|
+
|
|
13
|
+
- react >= 18
|
|
14
|
+
- react-dom >= 18
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { ResiraProvider, ResiraBookingWidget } from "@resira/ui";
|
|
20
|
+
import "@resira/ui/styles.css";
|
|
21
|
+
|
|
22
|
+
export function App() {
|
|
23
|
+
return (
|
|
24
|
+
<ResiraProvider
|
|
25
|
+
apiKey="resira_live_abc123"
|
|
26
|
+
resourceId="prop-1"
|
|
27
|
+
domain="rental"
|
|
28
|
+
>
|
|
29
|
+
<ResiraBookingWidget />
|
|
30
|
+
</ResiraProvider>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You can also use the higher-level modal component:
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { BookingModal } from "@resira/ui";
|
|
39
|
+
import "@resira/ui/styles.css";
|
|
40
|
+
|
|
41
|
+
<BookingModal apiKey="resira_live_abc123" domain="watersport" />;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Supported domains
|
|
45
|
+
|
|
46
|
+
| Domain | Flow |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `rental` | Calendar -> guest details -> terms -> payment |
|
|
49
|
+
| `restaurant` | Time slots -> guest details -> terms -> payment |
|
|
50
|
+
| `watersport` | Service -> time -> guest details -> terms -> payment |
|
|
51
|
+
| `service` | Service -> time -> guest details -> terms -> payment |
|
|
52
|
+
|
|
53
|
+
## ResiraProvider
|
|
54
|
+
|
|
55
|
+
`ResiraProvider` initializes the SDK client, loads public property configuration, resolves theme and locale values, and provides booking state to child components.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<ResiraProvider
|
|
59
|
+
apiKey="resira_live_..."
|
|
60
|
+
resourceId="resource-id"
|
|
61
|
+
domain="rental"
|
|
62
|
+
config={{
|
|
63
|
+
theme: {
|
|
64
|
+
primaryColor: "#18181b",
|
|
65
|
+
borderRadius: "16px",
|
|
66
|
+
},
|
|
67
|
+
locale: {
|
|
68
|
+
bookNow: "Book now",
|
|
69
|
+
},
|
|
70
|
+
serviceLayout: "vertical",
|
|
71
|
+
visibleServiceCount: 4,
|
|
72
|
+
groupServicesByCategory: true,
|
|
73
|
+
stripePublishableKey: "pk_live_...",
|
|
74
|
+
showTerms: true,
|
|
75
|
+
showWaiver: false,
|
|
76
|
+
depositPercent: 50,
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<ResiraBookingWidget />
|
|
80
|
+
</ResiraProvider>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Provider props
|
|
84
|
+
|
|
85
|
+
| Prop | Type | Required | Description |
|
|
86
|
+
| --- | --- | --- | --- |
|
|
87
|
+
| `apiKey` | `string` | Yes | Resira public API key |
|
|
88
|
+
| `resourceId` | `string` | No | Default resource or property ID. Omit for catalog mode |
|
|
89
|
+
| `domain` | `"rental" \| "restaurant" \| "watersport" \| "service"` | Yes | Booking flow type |
|
|
90
|
+
| `config` | `ResiraProviderConfig` | No | Theme, locale, layout, payment, and rendering overrides |
|
|
91
|
+
| `onClose` | `() => void` | No | Close callback for modal-driven flows |
|
|
92
|
+
|
|
93
|
+
### Important config options
|
|
94
|
+
|
|
95
|
+
| Config field | Type | Description |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| `theme` | `ResiraTheme` | Theme token overrides |
|
|
98
|
+
| `locale` | `ResiraLocale` | Text and i18n overrides |
|
|
99
|
+
| `domainConfig` | `DomainConfig` | Domain-specific rules such as min/max party size or duration |
|
|
100
|
+
| `classNames` | `ResiraClassNames` | CSS class overrides |
|
|
101
|
+
| `serviceLayout` | `"vertical" \| "horizontal"` | Product selector layout |
|
|
102
|
+
| `visibleServiceCount` | `number` | Number of visible services before scrolling |
|
|
103
|
+
| `groupServicesByCategory` | `boolean` | Group services by linked equipment type |
|
|
104
|
+
| `renderServiceCard` | `(product, selected) => ReactNode` | Custom service card rendering |
|
|
105
|
+
| `baseUrl` | `string` | Optional API origin override |
|
|
106
|
+
| `baseUrls` | `Array<string \| WeightedBaseUrl>` | Optional ordered fallback origin list |
|
|
107
|
+
| `stripePublishableKey` | `string` | Stripe publishable key override |
|
|
108
|
+
| `termsText` | `string` | Terms text override |
|
|
109
|
+
| `waiverText` | `string` | Waiver text override |
|
|
110
|
+
| `showWaiver` | `boolean` | Show waiver checkbox |
|
|
111
|
+
| `showTerms` | `boolean` | Show terms checkbox |
|
|
112
|
+
| `showRemainingSpots` | `boolean` | Show remaining capacity labels |
|
|
113
|
+
| `depositPercent` | `number` | Percent charged upfront |
|
|
114
|
+
|
|
115
|
+
## Styling and customization
|
|
116
|
+
|
|
117
|
+
Import the stylesheet once:
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import "@resira/ui/styles.css";
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The main customization layers are:
|
|
124
|
+
|
|
125
|
+
- `theme` tokens on `ResiraProvider`
|
|
126
|
+
- CSS custom properties under `.resira-root`
|
|
127
|
+
- `classNames` and `renderServiceCard` for deeper control
|
|
128
|
+
|
|
129
|
+
For more styling details, see [CUSTOMIZATION.md](./CUSTOMIZATION.md).
|
|
130
|
+
|
|
131
|
+
## Payment and remote config
|
|
132
|
+
|
|
133
|
+
The provider loads public configuration such as:
|
|
134
|
+
|
|
135
|
+
- Stripe publishable key
|
|
136
|
+
- deposit percentage
|
|
137
|
+
- terms requirements
|
|
138
|
+
- refund policy
|
|
139
|
+
|
|
140
|
+
You can override those values locally through `config` when needed.
|
|
141
|
+
|
|
142
|
+
## Hooks and components
|
|
143
|
+
|
|
144
|
+
Main exports:
|
|
145
|
+
|
|
146
|
+
- `ResiraProvider`
|
|
147
|
+
- `useResira`
|
|
148
|
+
- `ResiraBookingWidget`
|
|
149
|
+
- `BookingModal`
|
|
150
|
+
- `BookingCalendar`
|
|
151
|
+
- `TimeSlotPicker`
|
|
152
|
+
- `ResourcePicker`
|
|
153
|
+
- `ProductSelector`
|
|
154
|
+
- `GuestForm`
|
|
155
|
+
- `validateGuestForm`
|
|
156
|
+
- `WaiverConsent`
|
|
157
|
+
- `PaymentForm`
|
|
158
|
+
- `SummaryPreview`
|
|
159
|
+
- `ConfirmationView`
|
|
160
|
+
- `useAvailability`
|
|
161
|
+
- `useReservation`
|
|
162
|
+
- `useResources`
|
|
163
|
+
- `useProducts`
|
|
164
|
+
- `usePaymentIntent`
|
|
165
|
+
- `DishShowcase`
|
|
166
|
+
- `useDish`
|
|
167
|
+
- `useDishes`
|
|
168
|
+
|
|
169
|
+
## DishShowcase
|
|
170
|
+
|
|
171
|
+
The `DishShowcase` component renders a trigger button that opens a nested modal for browsing dishes with 3D model previews and AR viewing. It uses `<model-viewer>` for the 3D experience.
|
|
172
|
+
|
|
173
|
+
### Prerequisites
|
|
174
|
+
|
|
175
|
+
Load the `<model-viewer>` web component in your page:
|
|
176
|
+
|
|
177
|
+
```html
|
|
178
|
+
<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0/model-viewer.min.js"></script>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Single dish (by ID)
|
|
182
|
+
|
|
183
|
+
The `dishId` is shown on the dish page in the admin dashboard for easy copying.
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
import { DishShowcase } from "@resira/ui";
|
|
187
|
+
|
|
188
|
+
<DishShowcase dishId="dish-uuid">
|
|
189
|
+
View in 3D
|
|
190
|
+
</DishShowcase>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Browse all dishes
|
|
194
|
+
|
|
195
|
+
```tsx
|
|
196
|
+
<DishShowcase showAll>
|
|
197
|
+
Explore Our Menu
|
|
198
|
+
</DishShowcase>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Filter by category
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
<DishShowcase showAll category="Main">
|
|
205
|
+
View Main Courses
|
|
206
|
+
</DishShowcase>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Props
|
|
210
|
+
|
|
211
|
+
| Prop | Type | Default | Description |
|
|
212
|
+
| --- | --- | --- | --- |
|
|
213
|
+
| `dishId` | `string` | — | Single dish ID, opens directly to 3D viewer |
|
|
214
|
+
| `showAll` | `boolean` | `false` | Show all dishes in a browsable grid |
|
|
215
|
+
| `category` | `string` | — | Filter dishes by category |
|
|
216
|
+
| `className` | `string` | — | Custom CSS class on the trigger button |
|
|
217
|
+
| `style` | `CSSProperties` | — | Custom inline styles on the trigger button |
|
|
218
|
+
| `children` | `ReactNode` | required | Button label / content |
|
|
219
|
+
|
|
220
|
+
### Inside a BookingModal
|
|
221
|
+
|
|
222
|
+
`DishShowcase` works as a nested modal — it renders above the booking modal with its own overlay and focus trap:
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
<BookingModal apiKey="resira_live_..." domain="restaurant">
|
|
226
|
+
<DishShowcase dishId="dish-uuid" style={{ marginBottom: 12 }}>
|
|
227
|
+
Preview this dish in 3D
|
|
228
|
+
</DishShowcase>
|
|
229
|
+
</BookingModal>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Notes
|
|
233
|
+
|
|
234
|
+
- The widget supports catalog mode when `resourceId` is omitted.
|
|
235
|
+
- Service and watersport flows group services by linked equipment category by default.
|
|
236
|
+
- Loading and error states now announce themselves to assistive technologies on the main widget surfaces.
|
|
237
|
+
- Client-side API origin stickiness/load-balancing has been removed; routing is deterministic unless you pass explicit fallback origins.
|
|
238
|
+
- The package is intended for browser usage and ships CSS separately via `@resira/ui/styles.css`.
|
package/dist/index.cjs
CHANGED
|
@@ -652,6 +652,101 @@ function useCheckoutSession(token) {
|
|
|
652
652
|
}, [client, token]);
|
|
653
653
|
return { session, loading, error, errorCode };
|
|
654
654
|
}
|
|
655
|
+
function formatPriceCentsUtil(cents, currency) {
|
|
656
|
+
return new Intl.NumberFormat("default", { style: "currency", currency }).format(cents / 100);
|
|
657
|
+
}
|
|
658
|
+
function formatDurationUtil(minutes) {
|
|
659
|
+
if (minutes < 60) return `${minutes} min`;
|
|
660
|
+
const h = Math.floor(minutes / 60);
|
|
661
|
+
const m = minutes % 60;
|
|
662
|
+
return m > 0 ? `${h}h ${m}m` : `${h}h`;
|
|
663
|
+
}
|
|
664
|
+
function enrichProduct(product) {
|
|
665
|
+
const currency = product.currency ?? "EUR";
|
|
666
|
+
const options = [];
|
|
667
|
+
if (product.durationPricing?.length) {
|
|
668
|
+
for (const dp of product.durationPricing) {
|
|
669
|
+
options.push({
|
|
670
|
+
durationMinutes: dp.durationMinutes,
|
|
671
|
+
durationLabel: formatDurationUtil(dp.durationMinutes),
|
|
672
|
+
priceCents: dp.priceCents,
|
|
673
|
+
priceFormatted: formatPriceCentsUtil(dp.priceCents, currency)
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
} else {
|
|
677
|
+
options.push({
|
|
678
|
+
durationMinutes: product.durationMinutes,
|
|
679
|
+
durationLabel: formatDurationUtil(product.durationMinutes),
|
|
680
|
+
priceCents: product.priceCents,
|
|
681
|
+
priceFormatted: formatPriceCentsUtil(product.priceCents, currency)
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
const lowestPriceCents = Math.min(...options.map((o) => o.priceCents));
|
|
685
|
+
return {
|
|
686
|
+
id: product.id,
|
|
687
|
+
name: product.name,
|
|
688
|
+
description: product.description,
|
|
689
|
+
imageUrl: product.imageUrl,
|
|
690
|
+
currency,
|
|
691
|
+
active: product.active,
|
|
692
|
+
pricingModel: product.pricingModel,
|
|
693
|
+
priceCents: product.priceCents,
|
|
694
|
+
priceFormatted: formatPriceCentsUtil(product.priceCents, currency),
|
|
695
|
+
lowestPriceCents,
|
|
696
|
+
lowestPriceFormatted: formatPriceCentsUtil(lowestPriceCents, currency),
|
|
697
|
+
hasMultipleOptions: options.length > 1,
|
|
698
|
+
durationMinutes: product.durationMinutes,
|
|
699
|
+
durationLabel: formatDurationUtil(product.durationMinutes),
|
|
700
|
+
options,
|
|
701
|
+
maxPartySize: product.maxPartySize,
|
|
702
|
+
equipmentIds: product.equipmentIds,
|
|
703
|
+
equipmentNames: product.equipmentNames,
|
|
704
|
+
serviceColor: product.serviceColor,
|
|
705
|
+
sortOrder: product.sortOrder,
|
|
706
|
+
raw: product
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
function useServices() {
|
|
710
|
+
const { client } = useResira();
|
|
711
|
+
const [services, setServices] = react.useState([]);
|
|
712
|
+
const [loading, setLoading] = react.useState(true);
|
|
713
|
+
const [error, setError] = react.useState(null);
|
|
714
|
+
const [fetchCount, setFetchCount] = react.useState(0);
|
|
715
|
+
react.useEffect(() => {
|
|
716
|
+
let cancelled = false;
|
|
717
|
+
setLoading(true);
|
|
718
|
+
setError(null);
|
|
719
|
+
async function load() {
|
|
720
|
+
try {
|
|
721
|
+
const data = await client.listProducts();
|
|
722
|
+
if (!cancelled) {
|
|
723
|
+
setServices((data.products ?? []).map(enrichProduct));
|
|
724
|
+
}
|
|
725
|
+
} catch (err) {
|
|
726
|
+
if (!cancelled) {
|
|
727
|
+
setError(err instanceof Error ? err.message : "Failed to load services");
|
|
728
|
+
}
|
|
729
|
+
} finally {
|
|
730
|
+
if (!cancelled) setLoading(false);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
load();
|
|
734
|
+
return () => {
|
|
735
|
+
cancelled = true;
|
|
736
|
+
};
|
|
737
|
+
}, [client, fetchCount]);
|
|
738
|
+
const refetch = react.useCallback(() => setFetchCount((c) => c + 1), []);
|
|
739
|
+
return { services, loading, error, refetch };
|
|
740
|
+
}
|
|
741
|
+
async function fetchServices(apiKey, opts) {
|
|
742
|
+
const { Resira: Resira2 } = await import('@resira/sdk');
|
|
743
|
+
const client = new Resira2({
|
|
744
|
+
apiKey,
|
|
745
|
+
...opts?.baseUrl ? { baseUrl: opts.baseUrl } : {}
|
|
746
|
+
});
|
|
747
|
+
const data = await client.listProducts();
|
|
748
|
+
return (data.products ?? []).map(enrichProduct);
|
|
749
|
+
}
|
|
655
750
|
var defaultSize = 20;
|
|
656
751
|
function CalendarIcon({ size = defaultSize, className }) {
|
|
657
752
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1876,6 +1971,10 @@ function ServiceOverlayCard({
|
|
|
1876
1971
|
}) {
|
|
1877
1972
|
const currency = product.currency ?? "EUR";
|
|
1878
1973
|
const priceLabel = product.pricingModel === "per_rider" ? "per rider" : product.pricingModel === "per_person" ? locale.perPerson : locale.perSession;
|
|
1974
|
+
const hasMultipleOptions = (product.durationPricing?.length ?? 0) > 1 || (product.riderTierPricing?.length ?? 0) > 1;
|
|
1975
|
+
const lowestPrice = hasMultipleOptions && product.durationPricing?.length ? Math.min(...product.durationPricing.map((dp) => dp.priceCents)) : product.priceCents;
|
|
1976
|
+
const pricePrefix = hasMultipleOptions ? "from " : "";
|
|
1977
|
+
const optionCount = product.durationPricing?.length ?? (product.riderTierPricing?.length ?? 0);
|
|
1879
1978
|
let className = "resira-service-overlay-card";
|
|
1880
1979
|
if (isSelected) className += " resira-service-overlay-card--selected";
|
|
1881
1980
|
if (cardClassName) className += ` ${cardClassName}`;
|
|
@@ -1896,17 +1995,22 @@ function ServiceOverlayCard({
|
|
|
1896
1995
|
] }),
|
|
1897
1996
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "resira-service-overlay-card-bottom", children: [
|
|
1898
1997
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-price", children: [
|
|
1899
|
-
|
|
1998
|
+
pricePrefix,
|
|
1999
|
+
formatPrice2(lowestPrice, currency),
|
|
1900
2000
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-price-unit", children: [
|
|
1901
2001
|
"/",
|
|
1902
2002
|
priceLabel
|
|
1903
2003
|
] })
|
|
1904
2004
|
] }),
|
|
1905
2005
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "resira-service-overlay-card-pills", children: [
|
|
1906
|
-
|
|
2006
|
+
hasMultipleOptions && optionCount > 1 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-pill", children: [
|
|
2007
|
+
/* @__PURE__ */ jsxRuntime.jsx(ClockIcon, { size: 11 }),
|
|
2008
|
+
optionCount,
|
|
2009
|
+
" options"
|
|
2010
|
+
] }) : product.durationMinutes > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-pill", children: [
|
|
1907
2011
|
/* @__PURE__ */ jsxRuntime.jsx(ClockIcon, { size: 11 }),
|
|
1908
2012
|
formatDuration2(product.durationMinutes)
|
|
1909
|
-
] }),
|
|
2013
|
+
] }) : null,
|
|
1910
2014
|
product.maxPartySize && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-pill", children: [
|
|
1911
2015
|
/* @__PURE__ */ jsxRuntime.jsx(UsersIcon, { size: 11 }),
|
|
1912
2016
|
"max ",
|
|
@@ -2987,10 +3091,10 @@ function ResiraBookingWidget() {
|
|
|
2987
3091
|
const currency = selectedProduct?.currency ?? availability?.currency ?? "EUR";
|
|
2988
3092
|
const activeRiderDurationPricing = react.useMemo(() => {
|
|
2989
3093
|
if (selectedProduct?.pricingModel === "per_rider" && selectedProduct.riderTierPricing?.length) {
|
|
2990
|
-
const sorted = [...selectedProduct.riderTierPricing].sort((a, b) => a.riders - b.riders);
|
|
2991
|
-
const exact = sorted.find((t) => t.riders === selection.partySize);
|
|
3094
|
+
const sorted = [...selectedProduct.riderTierPricing].sort((a, b) => (a.riders ?? a.minRiders ?? 0) - (b.riders ?? b.minRiders ?? 0));
|
|
3095
|
+
const exact = sorted.find((t) => t.riders === selection.partySize || t.minRiders != null && t.maxRiders != null && selection.partySize >= t.minRiders && selection.partySize <= t.maxRiders);
|
|
2992
3096
|
if (exact) return exact.durationPricing;
|
|
2993
|
-
const closest = sorted.find((t) => t.riders >= selection.partySize);
|
|
3097
|
+
const closest = sorted.find((t) => (t.riders ?? t.minRiders ?? 0) >= selection.partySize);
|
|
2994
3098
|
return closest?.durationPricing ?? sorted[sorted.length - 1]?.durationPricing ?? [];
|
|
2995
3099
|
}
|
|
2996
3100
|
return null;
|
|
@@ -3123,8 +3227,14 @@ function ResiraBookingWidget() {
|
|
|
3123
3227
|
partySize: clampedPartySize
|
|
3124
3228
|
};
|
|
3125
3229
|
});
|
|
3230
|
+
if (step === "resource" && isServiceBased) {
|
|
3231
|
+
const nextIdx = stepIndex("resource", STEPS) + 1;
|
|
3232
|
+
if (nextIdx < STEPS.length) {
|
|
3233
|
+
setStep(STEPS[nextIdx]);
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3126
3236
|
},
|
|
3127
|
-
[setActiveResourceId, domainConfig.maxPartySize]
|
|
3237
|
+
[setActiveResourceId, domainConfig.maxPartySize, step, isServiceBased, STEPS]
|
|
3128
3238
|
);
|
|
3129
3239
|
const handleResourceSelect = react.useCallback(
|
|
3130
3240
|
(resourceId) => {
|
|
@@ -4342,6 +4452,7 @@ exports.UsersIcon = UsersIcon;
|
|
|
4342
4452
|
exports.ViewfinderIcon = ViewfinderIcon;
|
|
4343
4453
|
exports.WaiverConsent = WaiverConsent;
|
|
4344
4454
|
exports.XIcon = XIcon;
|
|
4455
|
+
exports.fetchServices = fetchServices;
|
|
4345
4456
|
exports.resolveTheme = resolveTheme;
|
|
4346
4457
|
exports.themeToCSS = themeToCSS;
|
|
4347
4458
|
exports.useAvailability = useAvailability;
|
|
@@ -4353,6 +4464,7 @@ exports.useProducts = useProducts;
|
|
|
4353
4464
|
exports.useReservation = useReservation;
|
|
4354
4465
|
exports.useResira = useResira;
|
|
4355
4466
|
exports.useResources = useResources;
|
|
4467
|
+
exports.useServices = useServices;
|
|
4356
4468
|
exports.validateGuestForm = validateGuestForm;
|
|
4357
4469
|
//# sourceMappingURL=index.cjs.map
|
|
4358
4470
|
//# sourceMappingURL=index.cjs.map
|