@resira/ui 0.4.3 → 0.4.6
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 +112 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +112 -30
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2972 -2879
- 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
|
@@ -1606,6 +1606,99 @@ function formatDuration(minutes) {
|
|
|
1606
1606
|
return `${h}h ${m}m`;
|
|
1607
1607
|
}
|
|
1608
1608
|
var PLACEHOLDER_IMG = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='240' fill='%23e2e8f0'%3E%3Crect width='400' height='240' rx='8'/%3E%3Ctext x='50%25' y='50%25' dominant-baseline='middle' text-anchor='middle' font-family='system-ui' font-size='16' fill='%2394a3b8'%3ENo image%3C/text%3E%3C/svg%3E";
|
|
1609
|
+
function resolveImages(resource) {
|
|
1610
|
+
if (resource.images && resource.images.length > 0) return resource.images;
|
|
1611
|
+
if (resource.imageUrl) return [{ url: resource.imageUrl }];
|
|
1612
|
+
return [];
|
|
1613
|
+
}
|
|
1614
|
+
function ChevronLeftIcon2() {
|
|
1615
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 12L6 8L10 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1616
|
+
}
|
|
1617
|
+
function ChevronRightIcon2() {
|
|
1618
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 4L10 8L6 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
1619
|
+
}
|
|
1620
|
+
function ResourceImageCarousel({
|
|
1621
|
+
images,
|
|
1622
|
+
alt
|
|
1623
|
+
}) {
|
|
1624
|
+
const [idx, setIdx] = react.useState(0);
|
|
1625
|
+
const hasMultiple = images.length > 1;
|
|
1626
|
+
const current = images[idx] ?? images[0];
|
|
1627
|
+
const goPrev = react.useCallback(
|
|
1628
|
+
(e) => {
|
|
1629
|
+
e.stopPropagation();
|
|
1630
|
+
setIdx((i) => (i - 1 + images.length) % images.length);
|
|
1631
|
+
},
|
|
1632
|
+
[images.length]
|
|
1633
|
+
);
|
|
1634
|
+
const goNext = react.useCallback(
|
|
1635
|
+
(e) => {
|
|
1636
|
+
e.stopPropagation();
|
|
1637
|
+
setIdx((i) => (i + 1) % images.length);
|
|
1638
|
+
},
|
|
1639
|
+
[images.length]
|
|
1640
|
+
);
|
|
1641
|
+
if (!current) {
|
|
1642
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1643
|
+
"img",
|
|
1644
|
+
{
|
|
1645
|
+
src: PLACEHOLDER_IMG,
|
|
1646
|
+
alt,
|
|
1647
|
+
loading: "lazy"
|
|
1648
|
+
}
|
|
1649
|
+
);
|
|
1650
|
+
}
|
|
1651
|
+
const ds = current.displaySettings;
|
|
1652
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "resira-resource-carousel", children: [
|
|
1653
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1654
|
+
"img",
|
|
1655
|
+
{
|
|
1656
|
+
src: current.url,
|
|
1657
|
+
alt,
|
|
1658
|
+
loading: "lazy",
|
|
1659
|
+
style: {
|
|
1660
|
+
objectFit: ds?.objectFit ?? "cover",
|
|
1661
|
+
objectPosition: ds?.objectPosition ?? "center center",
|
|
1662
|
+
transform: ds?.zoom && ds.zoom !== 1 ? `scale(${ds.zoom})` : void 0
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
),
|
|
1666
|
+
hasMultiple && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1667
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1668
|
+
"button",
|
|
1669
|
+
{
|
|
1670
|
+
type: "button",
|
|
1671
|
+
className: "resira-resource-carousel-btn resira-resource-carousel-prev",
|
|
1672
|
+
onClick: goPrev,
|
|
1673
|
+
"aria-label": "Previous image",
|
|
1674
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon2, {})
|
|
1675
|
+
}
|
|
1676
|
+
),
|
|
1677
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1678
|
+
"button",
|
|
1679
|
+
{
|
|
1680
|
+
type: "button",
|
|
1681
|
+
className: "resira-resource-carousel-btn resira-resource-carousel-next",
|
|
1682
|
+
onClick: goNext,
|
|
1683
|
+
"aria-label": "Next image",
|
|
1684
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon2, {})
|
|
1685
|
+
}
|
|
1686
|
+
),
|
|
1687
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "resira-resource-carousel-dots", children: images.map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1688
|
+
"span",
|
|
1689
|
+
{
|
|
1690
|
+
className: `resira-resource-carousel-dot${i === idx ? " resira-resource-carousel-dot--active" : ""}`
|
|
1691
|
+
},
|
|
1692
|
+
i
|
|
1693
|
+
)) }),
|
|
1694
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-resource-carousel-count", children: [
|
|
1695
|
+
idx + 1,
|
|
1696
|
+
"/",
|
|
1697
|
+
images.length
|
|
1698
|
+
] })
|
|
1699
|
+
] })
|
|
1700
|
+
] });
|
|
1701
|
+
}
|
|
1609
1702
|
function ResourcePicker({
|
|
1610
1703
|
resources,
|
|
1611
1704
|
selectedIds,
|
|
@@ -1641,14 +1734,17 @@ function ResourcePicker({
|
|
|
1641
1734
|
onClick: () => onSelect(resource.id),
|
|
1642
1735
|
"aria-pressed": isSelected,
|
|
1643
1736
|
children: [
|
|
1644
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "resira-resource-card-image", children:
|
|
1645
|
-
|
|
1646
|
-
{
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1737
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "resira-resource-card-image", children: (() => {
|
|
1738
|
+
const images = resolveImages(resource);
|
|
1739
|
+
return images.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(ResourceImageCarousel, { images, alt: resource.name }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1740
|
+
"img",
|
|
1741
|
+
{
|
|
1742
|
+
src: PLACEHOLDER_IMG,
|
|
1743
|
+
alt: resource.name,
|
|
1744
|
+
loading: "lazy"
|
|
1745
|
+
}
|
|
1746
|
+
);
|
|
1747
|
+
})() }),
|
|
1652
1748
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "resira-resource-card-content", children: [
|
|
1653
1749
|
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "resira-resource-card-name", children: resource.name }),
|
|
1654
1750
|
resource.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "resira-resource-card-description", children: resource.description }),
|
|
@@ -1716,17 +1812,18 @@ function groupProductsByCategory(products, resources) {
|
|
|
1716
1812
|
const groupId = categoryType?.toLowerCase() ?? UNCATEGORIZED_CATEGORY_KEY;
|
|
1717
1813
|
const label = categoryType ? formatCategoryLabel(categoryType) : UNCATEGORIZED_CATEGORY_LABEL;
|
|
1718
1814
|
if (!groups.has(groupId)) {
|
|
1815
|
+
const catImage = categoryResource?.images?.[0]?.url ?? categoryResource?.imageUrl ?? void 0;
|
|
1719
1816
|
groups.set(groupId, {
|
|
1720
1817
|
id: groupId,
|
|
1721
1818
|
label,
|
|
1722
|
-
imageUrl:
|
|
1819
|
+
imageUrl: catImage,
|
|
1723
1820
|
products: []
|
|
1724
1821
|
});
|
|
1725
1822
|
}
|
|
1726
1823
|
const group = groups.get(groupId);
|
|
1727
1824
|
group.products.push(product);
|
|
1728
|
-
if (!group.imageUrl && categoryResource
|
|
1729
|
-
group.imageUrl = categoryResource.imageUrl;
|
|
1825
|
+
if (!group.imageUrl && categoryResource) {
|
|
1826
|
+
group.imageUrl = categoryResource.images?.[0]?.url ?? categoryResource.imageUrl;
|
|
1730
1827
|
}
|
|
1731
1828
|
});
|
|
1732
1829
|
return Array.from(groups.values());
|
|
@@ -1779,10 +1876,6 @@ function ServiceOverlayCard({
|
|
|
1779
1876
|
}) {
|
|
1780
1877
|
const currency = product.currency ?? "EUR";
|
|
1781
1878
|
const priceLabel = product.pricingModel === "per_rider" ? "per rider" : product.pricingModel === "per_person" ? locale.perPerson : locale.perSession;
|
|
1782
|
-
const hasMultipleOptions = (product.durationPricing?.length ?? 0) > 1 || (product.riderTierPricing?.length ?? 0) > 1;
|
|
1783
|
-
const lowestPrice = hasMultipleOptions && product.durationPricing?.length ? Math.min(...product.durationPricing.map((dp) => dp.priceCents)) : product.priceCents;
|
|
1784
|
-
const pricePrefix = hasMultipleOptions ? "from " : "";
|
|
1785
|
-
const optionCount = product.durationPricing?.length ?? (product.riderTierPricing?.length ?? 0);
|
|
1786
1879
|
let className = "resira-service-overlay-card";
|
|
1787
1880
|
if (isSelected) className += " resira-service-overlay-card--selected";
|
|
1788
1881
|
if (cardClassName) className += ` ${cardClassName}`;
|
|
@@ -1803,22 +1896,17 @@ function ServiceOverlayCard({
|
|
|
1803
1896
|
] }),
|
|
1804
1897
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "resira-service-overlay-card-bottom", children: [
|
|
1805
1898
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-price", children: [
|
|
1806
|
-
|
|
1807
|
-
formatPrice2(lowestPrice, currency),
|
|
1899
|
+
formatPrice2(product.priceCents, currency),
|
|
1808
1900
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-price-unit", children: [
|
|
1809
1901
|
"/",
|
|
1810
1902
|
priceLabel
|
|
1811
1903
|
] })
|
|
1812
1904
|
] }),
|
|
1813
1905
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "resira-service-overlay-card-pills", children: [
|
|
1814
|
-
|
|
1815
|
-
/* @__PURE__ */ jsxRuntime.jsx(ClockIcon, { size: 11 }),
|
|
1816
|
-
optionCount,
|
|
1817
|
-
" options"
|
|
1818
|
-
] }) : product.durationMinutes > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-pill", children: [
|
|
1906
|
+
product.durationMinutes > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-pill", children: [
|
|
1819
1907
|
/* @__PURE__ */ jsxRuntime.jsx(ClockIcon, { size: 11 }),
|
|
1820
1908
|
formatDuration2(product.durationMinutes)
|
|
1821
|
-
] })
|
|
1909
|
+
] }),
|
|
1822
1910
|
product.maxPartySize && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "resira-service-overlay-card-pill", children: [
|
|
1823
1911
|
/* @__PURE__ */ jsxRuntime.jsx(UsersIcon, { size: 11 }),
|
|
1824
1912
|
"max ",
|
|
@@ -3035,14 +3123,8 @@ function ResiraBookingWidget() {
|
|
|
3035
3123
|
partySize: clampedPartySize
|
|
3036
3124
|
};
|
|
3037
3125
|
});
|
|
3038
|
-
if (step === "resource" && isServiceBased) {
|
|
3039
|
-
const nextIdx = stepIndex("resource", STEPS) + 1;
|
|
3040
|
-
if (nextIdx < STEPS.length) {
|
|
3041
|
-
setStep(STEPS[nextIdx]);
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
3126
|
},
|
|
3045
|
-
[setActiveResourceId, domainConfig.maxPartySize
|
|
3127
|
+
[setActiveResourceId, domainConfig.maxPartySize]
|
|
3046
3128
|
);
|
|
3047
3129
|
const handleResourceSelect = react.useCallback(
|
|
3048
3130
|
(resourceId) => {
|