@resira/ui 0.4.0 → 0.4.1

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`.