@nuitee/booking-widget 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +268 -0
- package/USAGE.md +289 -0
- package/dist/booking-widget-standalone.js +1848 -0
- package/dist/booking-widget.css +1711 -0
- package/dist/booking-widget.js +1256 -0
- package/dist/core/booking-api.js +755 -0
- package/dist/core/stripe-config.js +8 -0
- package/dist/core/styles.css +1711 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +5 -0
- package/dist/index.js +5 -0
- package/dist/react/BookingWidget.jsx +1192 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +3 -0
- package/dist/react/styles.css +1711 -0
- package/dist/vue/BookingWidget.vue +1062 -0
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.js +3 -0
- package/dist/vue/styles.css +1711 -0
- package/package.json +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# Booking Engine Widget
|
|
2
|
+
|
|
3
|
+
A customizable booking widget modal you can embed in any website. It works with **vanilla JavaScript**, **React**, and **Vue**. API and payment configuration are loaded by the widget at runtime; you only need to install the package and pass options (e.g. `propertyKey` for real data).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Modern UI with smooth transitions
|
|
8
|
+
- Responsive layout
|
|
9
|
+
- **Vanilla JS**, **React**, and **Vue** integrations
|
|
10
|
+
- Step-by-step flow: dates → rooms → rates → checkout → confirmation
|
|
11
|
+
- Room selection with images and amenities
|
|
12
|
+
- Rate selection with pricing
|
|
13
|
+
- Full checkout with Stripe (handled by the widget)
|
|
14
|
+
- Customizable colors
|
|
15
|
+
- Lucide icons (shadcn-style)
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### NPM
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @nuitee/booking-widget
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Yarn
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add @nuitee/booking-widget
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### PNPM
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm add @nuitee/booking-widget
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### With React
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @nuitee/booking-widget react react-dom lucide-react
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### With Vue
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install @nuitee/booking-widget vue lucide-vue-next
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
*(Use `lucide-vue-next` for Vue 3 or the appropriate Lucide Vue package for your version.)*
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
### Vanilla JavaScript (ES modules)
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
import BookingWidget from '@nuitee/booking-widget';
|
|
59
|
+
import '@nuitee/booking-widget/css';
|
|
60
|
+
|
|
61
|
+
const widget = new BookingWidget({
|
|
62
|
+
containerId: 'booking-widget-container',
|
|
63
|
+
propertyKey: 'your-property-key', // optional; omit for demo data
|
|
64
|
+
colors: {
|
|
65
|
+
background: '#1a1a1a',
|
|
66
|
+
text: '#e0e0e0',
|
|
67
|
+
primary: '#3b82f6',
|
|
68
|
+
primaryText: '#ffffff'
|
|
69
|
+
},
|
|
70
|
+
onOpen: () => console.log('Widget opened'),
|
|
71
|
+
onClose: () => console.log('Widget closed'),
|
|
72
|
+
onComplete: (bookingData) => console.log('Booking completed', bookingData)
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
widget.open();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Vanilla JavaScript (CommonJS)
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
const BookingWidget = require('@nuitee/booking-widget');
|
|
82
|
+
require('@nuitee/booking-widget/css');
|
|
83
|
+
|
|
84
|
+
const widget = new BookingWidget({
|
|
85
|
+
containerId: 'booking-widget-container',
|
|
86
|
+
propertyKey: 'your-property-key'
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
widget.open();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Vanilla JavaScript (standalone script)
|
|
93
|
+
|
|
94
|
+
No bundler: load the script and CSS, then create the widget.
|
|
95
|
+
|
|
96
|
+
```html
|
|
97
|
+
<link rel="stylesheet" href="node_modules/@nuitee/booking-widget/dist/booking-widget.css">
|
|
98
|
+
<script src="node_modules/@nuitee/booking-widget/dist/booking-widget-standalone.js"></script>
|
|
99
|
+
|
|
100
|
+
<div id="booking-widget-container"></div>
|
|
101
|
+
|
|
102
|
+
<script>
|
|
103
|
+
const widget = new BookingWidget({
|
|
104
|
+
containerId: 'booking-widget-container',
|
|
105
|
+
cssUrl: 'node_modules/@nuitee/booking-widget/dist/booking-widget.css',
|
|
106
|
+
propertyKey: 'your-property-key',
|
|
107
|
+
onOpen: () => console.log('Opened'),
|
|
108
|
+
onClose: () => console.log('Closed'),
|
|
109
|
+
onComplete: (data) => console.log('Completed', data)
|
|
110
|
+
});
|
|
111
|
+
widget.init();
|
|
112
|
+
widget.open();
|
|
113
|
+
</script>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### React
|
|
117
|
+
|
|
118
|
+
```jsx
|
|
119
|
+
import { useState } from 'react';
|
|
120
|
+
import BookingWidget from '@nuitee/booking-widget/react';
|
|
121
|
+
import '@nuitee/booking-widget/css';
|
|
122
|
+
|
|
123
|
+
function App() {
|
|
124
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<>
|
|
128
|
+
<button onClick={() => setIsOpen(true)}>Book now</button>
|
|
129
|
+
<BookingWidget
|
|
130
|
+
isOpen={isOpen}
|
|
131
|
+
onClose={() => setIsOpen(false)}
|
|
132
|
+
propertyKey="your-property-key"
|
|
133
|
+
colors={{
|
|
134
|
+
background: '#1a1a1a',
|
|
135
|
+
text: '#e0e0e0',
|
|
136
|
+
primary: '#3b82f6',
|
|
137
|
+
primaryText: '#ffffff'
|
|
138
|
+
}}
|
|
139
|
+
onComplete={(data) => {
|
|
140
|
+
console.log('Booking completed', data);
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
</>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Vue
|
|
149
|
+
|
|
150
|
+
```vue
|
|
151
|
+
<template>
|
|
152
|
+
<div>
|
|
153
|
+
<button @click="isOpen = true">Book now</button>
|
|
154
|
+
<BookingWidget
|
|
155
|
+
:is-open="isOpen"
|
|
156
|
+
:property-key="propertyKey"
|
|
157
|
+
:colors="customColors"
|
|
158
|
+
@close="isOpen = false"
|
|
159
|
+
@complete="handleComplete"
|
|
160
|
+
/>
|
|
161
|
+
</div>
|
|
162
|
+
</template>
|
|
163
|
+
|
|
164
|
+
<script>
|
|
165
|
+
import BookingWidget from '@nuitee/booking-widget/vue';
|
|
166
|
+
import '@nuitee/booking-widget/css';
|
|
167
|
+
|
|
168
|
+
export default {
|
|
169
|
+
components: { BookingWidget },
|
|
170
|
+
data() {
|
|
171
|
+
return {
|
|
172
|
+
isOpen: false,
|
|
173
|
+
propertyKey: 'your-property-key',
|
|
174
|
+
customColors: {
|
|
175
|
+
background: '#1a1a1a',
|
|
176
|
+
text: '#e0e0e0',
|
|
177
|
+
primary: '#3b82f6',
|
|
178
|
+
primaryText: '#ffffff'
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
methods: {
|
|
183
|
+
handleComplete(data) {
|
|
184
|
+
console.log('Booking completed', data);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
</script>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Property key and data
|
|
194
|
+
|
|
195
|
+
- **Real rooms/rates/booking:** pass `propertyKey` (string) so the widget can load data for that property. Omit it to use built-in demo data.
|
|
196
|
+
- **Vanilla:** `new BookingWidget({ propertyKey: '...', ... })`
|
|
197
|
+
- **React:** `<BookingWidget propertyKey="..." ... />`
|
|
198
|
+
- **Vue:** `<BookingWidget :property-key="propertyKey" ... />`
|
|
199
|
+
|
|
200
|
+
API base URLs, Stripe, and related config are provided by the widget at runtime; you do not configure them in your app.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## API reference
|
|
205
|
+
|
|
206
|
+
### Constructor options (Vanilla JS)
|
|
207
|
+
|
|
208
|
+
| Option | Type | Description |
|
|
209
|
+
|--------|------|-------------|
|
|
210
|
+
| `containerId` | string | ID of the container element (default: `'booking-widget-container'`) |
|
|
211
|
+
| `cssUrl` | string | URL to the CSS file (optional if CSS is already loaded) |
|
|
212
|
+
| `propertyKey` | string | Property key for real data; omit for demo |
|
|
213
|
+
| `onOpen` | function | Callback when the widget opens |
|
|
214
|
+
| `onClose` | function | Callback when the widget closes |
|
|
215
|
+
| `onComplete` | function | Callback when booking is completed `(bookingData) => void` |
|
|
216
|
+
| `colors` | object | `{ background, text, primary, primaryText }` |
|
|
217
|
+
|
|
218
|
+
### React / Vue props
|
|
219
|
+
|
|
220
|
+
| Prop | Type | Description |
|
|
221
|
+
|------|------|-------------|
|
|
222
|
+
| `isOpen` | boolean | Controls widget visibility |
|
|
223
|
+
| `onClose` | function | Called when the user closes the widget |
|
|
224
|
+
| `onComplete` | function | Called when booking is completed |
|
|
225
|
+
| `onOpen` | function | Optional; called when the widget opens |
|
|
226
|
+
| `propertyKey` | string | Property key for real data; omit for demo |
|
|
227
|
+
| `colors` | object | Optional; same shape as above |
|
|
228
|
+
|
|
229
|
+
### Vanilla methods
|
|
230
|
+
|
|
231
|
+
- `open()` — open the modal (calls `init()` if needed)
|
|
232
|
+
- `close()` — close the modal
|
|
233
|
+
- `goToStep(step)` — go to step: `'dates'`, `'rooms'`, `'rates'`, `'checkout'`, `'confirmation'`
|
|
234
|
+
- `init()` — mount the widget into the container (required for standalone before `open()`)
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Import paths
|
|
239
|
+
|
|
240
|
+
- `@nuitee/booking-widget` — main entry (vanilla JS)
|
|
241
|
+
- `@nuitee/booking-widget/react` — React component
|
|
242
|
+
- `@nuitee/booking-widget/vue` — Vue component
|
|
243
|
+
- `@nuitee/booking-widget/css` — styles
|
|
244
|
+
- `@nuitee/booking-widget/standalone` — standalone script entry
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Examples
|
|
249
|
+
|
|
250
|
+
- `index.html` — vanilla integration
|
|
251
|
+
- `examples/react-app/` — React app example
|
|
252
|
+
- `examples/vue-app/` — Vue app example
|
|
253
|
+
|
|
254
|
+
See **[USAGE.md](./USAGE.md)** for more detailed usage by framework.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Development
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
npm install
|
|
262
|
+
npm run build
|
|
263
|
+
npm run dev
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
MIT
|
package/USAGE.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Booking Engine Widget — Usage by framework
|
|
2
|
+
|
|
3
|
+
This guide describes how to **install** and **use** the booking widget in your app (React, Vue, or vanilla JavaScript). API and payment configuration are loaded by the widget at runtime; you only need to add the package and pass the options described below.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
1. [Installation](#installation)
|
|
10
|
+
2. [React](#react)
|
|
11
|
+
3. [Vue](#vue)
|
|
12
|
+
4. [Vanilla JavaScript (standalone / script tag)](#vanilla-javascript-standalone--script-tag)
|
|
13
|
+
5. [Vanilla JavaScript (ES modules)](#vanilla-javascript-es-modules)
|
|
14
|
+
6. [Configuration reference](#configuration-reference)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
### Base install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @nuitee/booking-widget
|
|
24
|
+
# or
|
|
25
|
+
yarn add @nuitee/booking-widget
|
|
26
|
+
# or
|
|
27
|
+
pnpm add @nuitee/booking-widget
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The widget includes its own dependencies (e.g. `@stripe/stripe-js`, `lucide-react`). You do **not** need to install API keys or config in your app; the widget loads what it needs at runtime.
|
|
31
|
+
|
|
32
|
+
### If you use React
|
|
33
|
+
|
|
34
|
+
Install the widget plus React and React DOM (and Lucide if your project uses it):
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @nuitee/booking-widget react react-dom lucide-react
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### If you use Vue
|
|
41
|
+
|
|
42
|
+
Install the widget and Vue (Vue is a peer dependency):
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install @nuitee/booking-widget vue
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For Vue 3 with Lucide:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install @nuitee/booking-widget vue lucide-vue-next
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## React
|
|
57
|
+
|
|
58
|
+
### 1. Import and mount
|
|
59
|
+
|
|
60
|
+
```jsx
|
|
61
|
+
import { useState } from 'react';
|
|
62
|
+
import BookingWidget from '@nuitee/booking-widget/react';
|
|
63
|
+
import '@nuitee/booking-widget/css';
|
|
64
|
+
|
|
65
|
+
function App() {
|
|
66
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
<button onClick={() => setIsOpen(true)}>Book now</button>
|
|
71
|
+
<BookingWidget
|
|
72
|
+
isOpen={isOpen}
|
|
73
|
+
onClose={() => setIsOpen(false)}
|
|
74
|
+
onComplete={(data) => console.log('Booking completed', data)}
|
|
75
|
+
propertyKey="your-property-key"
|
|
76
|
+
/>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- **Real data:** pass `propertyKey` (string). Omit it to use demo data.
|
|
83
|
+
- **Callbacks:** `onClose` when the user closes the widget; `onComplete(data)` when the booking is completed.
|
|
84
|
+
|
|
85
|
+
### 2. With custom colors
|
|
86
|
+
|
|
87
|
+
```jsx
|
|
88
|
+
<BookingWidget
|
|
89
|
+
isOpen={isOpen}
|
|
90
|
+
onClose={() => setIsOpen(false)}
|
|
91
|
+
onComplete={handleComplete}
|
|
92
|
+
propertyKey="your-property-key"
|
|
93
|
+
colors={{
|
|
94
|
+
background: '#1a1a1a',
|
|
95
|
+
text: '#e0e0e0',
|
|
96
|
+
primary: '#3b82f6',
|
|
97
|
+
primaryText: '#ffffff',
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Vue
|
|
105
|
+
|
|
106
|
+
### 1. Import and mount
|
|
107
|
+
|
|
108
|
+
```vue
|
|
109
|
+
<template>
|
|
110
|
+
<div>
|
|
111
|
+
<button @click="isOpen = true">Book now</button>
|
|
112
|
+
<BookingWidget
|
|
113
|
+
:is-open="isOpen"
|
|
114
|
+
:property-key="propertyKey"
|
|
115
|
+
@close="isOpen = false"
|
|
116
|
+
@complete="handleComplete"
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
</template>
|
|
120
|
+
|
|
121
|
+
<script>
|
|
122
|
+
import BookingWidget from '@nuitee/booking-widget/vue';
|
|
123
|
+
import '@nuitee/booking-widget/css';
|
|
124
|
+
|
|
125
|
+
export default {
|
|
126
|
+
components: { BookingWidget },
|
|
127
|
+
data() {
|
|
128
|
+
return {
|
|
129
|
+
isOpen: false,
|
|
130
|
+
propertyKey: 'your-property-key',
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
methods: {
|
|
134
|
+
handleComplete(data) {
|
|
135
|
+
console.log('Booking completed', data);
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
</script>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
- **Real data:** pass `propertyKey`. Omit for demo data.
|
|
143
|
+
- **Events:** `@close` when the user closes; `@complete` when the booking is done.
|
|
144
|
+
|
|
145
|
+
### 2. With custom colors
|
|
146
|
+
|
|
147
|
+
```vue
|
|
148
|
+
<BookingWidget
|
|
149
|
+
:is-open="isOpen"
|
|
150
|
+
:property-key="propertyKey"
|
|
151
|
+
:colors="customColors"
|
|
152
|
+
@close="isOpen = false"
|
|
153
|
+
@complete="handleComplete"
|
|
154
|
+
/>
|
|
155
|
+
|
|
156
|
+
<!-- in data -->
|
|
157
|
+
customColors: {
|
|
158
|
+
background: '#1a1a1a',
|
|
159
|
+
text: '#e0e0e0',
|
|
160
|
+
primary: '#3b82f6',
|
|
161
|
+
primaryText: '#ffffff',
|
|
162
|
+
},
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Vanilla JavaScript (standalone / script tag)
|
|
168
|
+
|
|
169
|
+
Use the **standalone bundle** when you are not using a bundler: load the script and CSS, then create the widget with a container ID and options.
|
|
170
|
+
|
|
171
|
+
### 1. Load assets
|
|
172
|
+
|
|
173
|
+
```html
|
|
174
|
+
<link rel="stylesheet" href="node_modules/@nuitee/booking-widget/dist/booking-widget.css">
|
|
175
|
+
<script src="node_modules/@nuitee/booking-widget/dist/booking-widget-standalone.js"></script>
|
|
176
|
+
|
|
177
|
+
<div id="booking-widget-container"></div>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Replace `node_modules/...` with your actual path or a CDN URL if you host the built files.
|
|
181
|
+
|
|
182
|
+
### 2. Create the widget
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<script>
|
|
186
|
+
const widget = new BookingWidget({
|
|
187
|
+
containerId: 'booking-widget-container',
|
|
188
|
+
cssUrl: 'node_modules/@nuitee/booking-widget/dist/booking-widget.css',
|
|
189
|
+
propertyKey: 'your-property-key',
|
|
190
|
+
onOpen: () => console.log('Opened'),
|
|
191
|
+
onClose: () => console.log('Closed'),
|
|
192
|
+
onComplete: (data) => console.log('Completed', data),
|
|
193
|
+
});
|
|
194
|
+
widget.init();
|
|
195
|
+
widget.open();
|
|
196
|
+
</script>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
For the standalone bundle you must call `init()` before `open()` so the widget mounts into the container.
|
|
200
|
+
|
|
201
|
+
### 3. With custom colors
|
|
202
|
+
|
|
203
|
+
```javascript
|
|
204
|
+
const widget = new BookingWidget({
|
|
205
|
+
containerId: 'booking-widget-container',
|
|
206
|
+
propertyKey: 'your-property-key',
|
|
207
|
+
colors: {
|
|
208
|
+
background: '#1a1a1a',
|
|
209
|
+
text: '#e0e0e0',
|
|
210
|
+
primary: '#3b82f6',
|
|
211
|
+
primaryText: '#ffffff',
|
|
212
|
+
},
|
|
213
|
+
onClose: () => {},
|
|
214
|
+
onComplete: (data) => console.log(data),
|
|
215
|
+
});
|
|
216
|
+
widget.init();
|
|
217
|
+
widget.open();
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Vanilla JavaScript (ES modules)
|
|
223
|
+
|
|
224
|
+
When using a bundler (Vite, Webpack, etc.), import the widget and CSS:
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
import BookingWidget from '@nuitee/booking-widget';
|
|
228
|
+
import '@nuitee/booking-widget/css';
|
|
229
|
+
|
|
230
|
+
const widget = new BookingWidget({
|
|
231
|
+
containerId: 'booking-widget-container',
|
|
232
|
+
propertyKey: 'your-property-key',
|
|
233
|
+
onClose: () => {},
|
|
234
|
+
onComplete: (data) => console.log(data),
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
widget.open();
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
You do **not** need to call `init()` when using the main entry; `open()` will mount the widget if needed.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Configuration reference
|
|
245
|
+
|
|
246
|
+
Only the following props/options are for you to set. API URLs, Stripe, and booking submission are handled by the widget and are not configured in your app.
|
|
247
|
+
|
|
248
|
+
### React / Vue props
|
|
249
|
+
|
|
250
|
+
| Prop | Type | Description |
|
|
251
|
+
|------|------|-------------|
|
|
252
|
+
| `isOpen` | boolean | Controls visibility of the modal. |
|
|
253
|
+
| `onClose` | function | Called when the user closes the widget. |
|
|
254
|
+
| `onComplete` | function | Called when the booking is completed, with booking data. |
|
|
255
|
+
| `onOpen` | function | Optional. Called when the widget opens. |
|
|
256
|
+
| `propertyKey` | string | Property key for real rooms/rates/booking; omit for demo data. |
|
|
257
|
+
| `colors` | object | Optional. `{ background, text, primary, primaryText }`. |
|
|
258
|
+
|
|
259
|
+
### Vanilla constructor options
|
|
260
|
+
|
|
261
|
+
| Option | Type | Description |
|
|
262
|
+
|--------|------|-------------|
|
|
263
|
+
| `containerId` | string | ID of the DOM container (default: `'booking-widget-container'`). |
|
|
264
|
+
| `cssUrl` | string | URL of the widget CSS (for standalone when CSS is not loaded by a build step). |
|
|
265
|
+
| `propertyKey` | string | Property key for real data; omit for demo. |
|
|
266
|
+
| `onClose` | function | Called when the user closes the widget. |
|
|
267
|
+
| `onComplete` | function | Called when the booking is completed. |
|
|
268
|
+
| `onOpen` | function | Optional. Called when the widget opens. |
|
|
269
|
+
| `colors` | object | Optional. `{ background, text, primary, primaryText }`. |
|
|
270
|
+
|
|
271
|
+
### Vanilla methods
|
|
272
|
+
|
|
273
|
+
- **`widget.open()`** — Open the modal. With the main entry (ES modules), this will init if needed; with standalone, call `init()` first.
|
|
274
|
+
- **`widget.close()`** — Close the modal.
|
|
275
|
+
- **`widget.goToStep(step)`** — Go to step: `'dates'`, `'rooms'`, `'rates'`, `'summary'`, `'payment'`, `'confirmation'`.
|
|
276
|
+
- **`widget.init()`** — Mount the widget into the container. **Required** for the standalone bundle before calling `open()`.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Summary
|
|
281
|
+
|
|
282
|
+
| Goal | What to do |
|
|
283
|
+
|------|------------|
|
|
284
|
+
| Use in React | `npm install @nuitee/booking-widget react react-dom`, import `@nuitee/booking-widget/react` and `@nuitee/booking-widget/css`, pass `isOpen`, `onClose`, `onComplete`, and optionally `propertyKey`. |
|
|
285
|
+
| Use in Vue | `npm install @nuitee/booking-widget vue`, import `@nuitee/booking-widget/vue` and `@nuitee/booking-widget/css`, pass `:is-open`, `@close`, `@complete`, and optionally `:property-key`. |
|
|
286
|
+
| Use in vanilla (no build) | Load the standalone script and CSS, `new BookingWidget({ containerId, propertyKey, ... })`, then `init()` and `open()`. |
|
|
287
|
+
| Use in vanilla (with build) | Import `@nuitee/booking-widget` and `@nuitee/booking-widget/css`, pass `propertyKey` and callbacks, then `open()`. |
|
|
288
|
+
| Real rooms/rates/booking | Pass `propertyKey`. The widget uses its own runtime config for API and payments. |
|
|
289
|
+
| Custom colors | Pass `colors: { background, text, primary, primaryText }`. |
|