@resira/ui 0.4.9 → 0.4.10

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 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
@@ -381,7 +381,7 @@ function useReservation() {
381
381
  const [error, setError] = react.useState(null);
382
382
  const submit = react.useCallback(
383
383
  async (data) => {
384
- if (!data.resourceId) {
384
+ if (!data.resourceId && !data.checkoutSessionToken) {
385
385
  setError("No resource selected");
386
386
  return null;
387
387
  }
@@ -3099,9 +3099,10 @@ function ResiraBookingWidget() {
3099
3099
  guestPhone: guest.guestPhone.trim() || void 0,
3100
3100
  notes: guest.notes.trim() || void 0,
3101
3101
  promoCode: discountCode.trim() || void 0,
3102
- termsAccepted: termsAccepted || void 0
3102
+ termsAccepted: termsAccepted || void 0,
3103
+ waiverAccepted: waiverAccepted || void 0
3103
3104
  };
3104
- }, [activeResourceId, selectedProduct, selection, guest, discountCode, termsAccepted, isCheckoutMode, checkoutSession, checkoutSessionToken]);
3105
+ }, [activeResourceId, selectedProduct, selection, guest, discountCode, termsAccepted, waiverAccepted, isCheckoutMode, checkoutSession, checkoutSessionToken]);
3105
3106
  const blockedDates = react.useMemo(() => {
3106
3107
  const dates = calendarData?.dates?.blockedDates ?? availability?.dates?.blockedDates ?? [];
3107
3108
  return new Set(dates);
@@ -3332,7 +3333,9 @@ function ResiraBookingWidget() {
3332
3333
  startTime: selection.startTime,
3333
3334
  endTime: selection.endTime,
3334
3335
  partySize: selection.partySize,
3335
- notes: guest.notes.trim() || void 0
3336
+ notes: guest.notes.trim() || void 0,
3337
+ termsAccepted: termsAccepted || void 0,
3338
+ waiverAccepted: waiverAccepted || void 0
3336
3339
  };
3337
3340
  const result = await submit(payload);
3338
3341
  if (result) {
@@ -3382,6 +3385,10 @@ function ResiraBookingWidget() {
3382
3385
  setTermsError(locale.termsRequired);
3383
3386
  return;
3384
3387
  }
3388
+ if (showWaiver && !waiverAccepted) {
3389
+ setTermsError(locale.termsRequired);
3390
+ return;
3391
+ }
3385
3392
  setTermsError(null);
3386
3393
  const result = await createPayment(paymentPayload);
3387
3394
  if (!result) return;
@@ -3406,7 +3413,8 @@ function ResiraBookingWidget() {
3406
3413
  }
3407
3414
  const resourceId = activeResourceId ?? selectedProduct?.equipmentIds?.[0] ?? "";
3408
3415
  const payload = {
3409
- resourceId,
3416
+ resourceId: isCheckoutMode ? void 0 : resourceId,
3417
+ checkoutSessionToken: isCheckoutMode ? checkoutSessionToken : void 0,
3410
3418
  guestName: guest.guestName.trim(),
3411
3419
  guestEmail: guest.guestEmail.trim() || void 0,
3412
3420
  guestPhone: guest.guestPhone.trim() || void 0,
@@ -3415,7 +3423,9 @@ function ResiraBookingWidget() {
3415
3423
  startTime: selection.startTime,
3416
3424
  endTime: selection.endTime,
3417
3425
  partySize: selection.partySize,
3418
- notes: guest.notes.trim() || void 0
3426
+ notes: guest.notes.trim() || void 0,
3427
+ termsAccepted: termsAccepted || void 0,
3428
+ waiverAccepted: waiverAccepted || void 0
3419
3429
  };
3420
3430
  const result = await submit(payload);
3421
3431
  if (result) {