@balby/booking-search 1.0.1 → 1.0.3
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 +2 -2
- package/dist/components/booking-search/date-range-picker.d.ts +2 -0
- package/dist/components/booking-search/guest-selector.d.ts +2 -0
- package/dist/components/booking-search/index.d.ts +24 -0
- package/dist/components/booking-search/location-combobox.d.ts +2 -0
- package/dist/components/booking-search/ui/command.d.ts +67 -0
- package/dist/components/booking-search/ui/dialog.d.ts +14 -0
- package/dist/components/booking-search/ui/popover.d.ts +7 -0
- package/dist/demo.d.ts +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +329 -1819
- package/dist/lib/utils.d.ts +2 -0
- package/dist/types/booking.d.ts +153 -0
- package/package.json +4 -4
- package/src/demo.tsx +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents availability and price for a single day
|
|
3
|
+
*/
|
|
4
|
+
export interface AvailabilityDay {
|
|
5
|
+
/** Date in ISO format (YYYY-MM-DD) */
|
|
6
|
+
date: string;
|
|
7
|
+
/** Price for this date */
|
|
8
|
+
price: number;
|
|
9
|
+
/** Whether the date is available for booking */
|
|
10
|
+
isAvailable: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Selectable location for booking search
|
|
14
|
+
*/
|
|
15
|
+
export interface SearchLocation {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
/** Type of location (city, hotel, region, etc.) */
|
|
19
|
+
type?: string;
|
|
20
|
+
/** ISO country code */
|
|
21
|
+
countryCode?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Guest data
|
|
25
|
+
*/
|
|
26
|
+
export interface GuestData {
|
|
27
|
+
adults: number;
|
|
28
|
+
children: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Payload emitted by the component when user performs a search
|
|
32
|
+
*/
|
|
33
|
+
export interface BookingSearchPayload {
|
|
34
|
+
/** Selected location */
|
|
35
|
+
location: SearchLocation | null;
|
|
36
|
+
/** Check-in date */
|
|
37
|
+
checkIn: Date | null;
|
|
38
|
+
/** Check-out date */
|
|
39
|
+
checkOut: Date | null;
|
|
40
|
+
/** Number of adults */
|
|
41
|
+
adults: number;
|
|
42
|
+
/** Number of children */
|
|
43
|
+
children: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Props for the main BookingSearch component
|
|
47
|
+
*/
|
|
48
|
+
export interface BookingSearchProps {
|
|
49
|
+
/** Availability and prices for dates */
|
|
50
|
+
availability: AvailabilityDay[];
|
|
51
|
+
/** List of available locations for search */
|
|
52
|
+
locations: SearchLocation[];
|
|
53
|
+
/** Callback called when user initiates a search */
|
|
54
|
+
onSearch: (payload: BookingSearchPayload) => void;
|
|
55
|
+
/** Initial values (optional) */
|
|
56
|
+
defaultValues?: Partial<BookingSearchPayload>;
|
|
57
|
+
/** Search button text */
|
|
58
|
+
searchButtonText?: string;
|
|
59
|
+
/** Placeholder for location field */
|
|
60
|
+
locationPlaceholder?: string;
|
|
61
|
+
/** Minimum number of nights required */
|
|
62
|
+
minNights?: number;
|
|
63
|
+
/** Maximum number of adults */
|
|
64
|
+
maxAdults?: number;
|
|
65
|
+
/** Maximum number of children */
|
|
66
|
+
maxChildren?: number;
|
|
67
|
+
/** Custom CSS class */
|
|
68
|
+
className?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Props for the LocationCombobox component
|
|
72
|
+
*/
|
|
73
|
+
export interface LocationComboboxProps {
|
|
74
|
+
/** List of locations to display */
|
|
75
|
+
locations: SearchLocation[];
|
|
76
|
+
/** Currently selected location */
|
|
77
|
+
value: SearchLocation | null;
|
|
78
|
+
/** Callback when location changes */
|
|
79
|
+
onChange: (location: SearchLocation | null) => void;
|
|
80
|
+
/** Optional title for the combobox */
|
|
81
|
+
title?: string;
|
|
82
|
+
/** Placeholder text */
|
|
83
|
+
placeholder?: string;
|
|
84
|
+
/** Whether the combobox is disabled */
|
|
85
|
+
disabled?: boolean;
|
|
86
|
+
/** Custom CSS class */
|
|
87
|
+
className?: string;
|
|
88
|
+
/** Tab index */
|
|
89
|
+
tabIndex?: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Props for the DateRangePicker component
|
|
93
|
+
*/
|
|
94
|
+
export interface DateRangePickerProps {
|
|
95
|
+
/** Availability and prices for dates */
|
|
96
|
+
availability: AvailabilityDay[];
|
|
97
|
+
/** Selected date range */
|
|
98
|
+
value: {
|
|
99
|
+
from: Date | null;
|
|
100
|
+
to: Date | null;
|
|
101
|
+
};
|
|
102
|
+
/** Callback when date range changes */
|
|
103
|
+
onChange: (range: {
|
|
104
|
+
from: Date | null;
|
|
105
|
+
to: Date | null;
|
|
106
|
+
}) => void;
|
|
107
|
+
/** Minimum number of nights required */
|
|
108
|
+
minNights?: number;
|
|
109
|
+
/** Whether the picker is disabled */
|
|
110
|
+
disabled?: boolean;
|
|
111
|
+
/** Custom CSS class */
|
|
112
|
+
className?: string;
|
|
113
|
+
/** Tab index */
|
|
114
|
+
tabIndex?: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Props for the GuestSelector component
|
|
118
|
+
*/
|
|
119
|
+
export interface GuestSelectorProps {
|
|
120
|
+
/** Current guest data */
|
|
121
|
+
value: GuestData;
|
|
122
|
+
/** Callback when guest data changes */
|
|
123
|
+
onChange: (guests: GuestData) => void;
|
|
124
|
+
/** Maximum number of adults */
|
|
125
|
+
maxAdults?: number;
|
|
126
|
+
/** Maximum number of children */
|
|
127
|
+
maxChildren?: number;
|
|
128
|
+
/** Whether the selector is disabled */
|
|
129
|
+
disabled?: boolean;
|
|
130
|
+
/** Custom CSS class */
|
|
131
|
+
className?: string;
|
|
132
|
+
/** Tab index */
|
|
133
|
+
tabIndex?: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Props for the GuestStepper component (internal)
|
|
137
|
+
*/
|
|
138
|
+
export interface GuestStepperProps {
|
|
139
|
+
/** Label for the stepper */
|
|
140
|
+
label: string;
|
|
141
|
+
/** Optional description */
|
|
142
|
+
description?: string;
|
|
143
|
+
/** Current value */
|
|
144
|
+
value: number;
|
|
145
|
+
/** Callback to increment */
|
|
146
|
+
onIncrement: () => void;
|
|
147
|
+
/** Callback to decrement */
|
|
148
|
+
onDecrement: () => void;
|
|
149
|
+
/** Minimum value */
|
|
150
|
+
min?: number;
|
|
151
|
+
/** Maximum value */
|
|
152
|
+
max?: number;
|
|
153
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balby/booking-search",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"scripts": {
|
|
44
44
|
"dev": "bun run build:css && bun --watch index.ts",
|
|
45
45
|
"dev:css": "bun run build:css && bunx concurrently \"bun --watch index.ts\" \"bun run watch:css\"",
|
|
46
|
-
"build": "bun run build:css && bun build src/index.ts --outdir=dist --target=browser --format=esm",
|
|
46
|
+
"build": "bun run build:css && bun build src/index.ts --outdir=dist --target=browser --format=esm --external react --external react-dom --external react/jsx-runtime",
|
|
47
47
|
"build:css": "tailwindcss -i ./src/styles/globals.css -o ./src/styles/output.css --minify",
|
|
48
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
48
49
|
"watch:css": "tailwindcss -i ./src/styles/globals.css -o ./src/styles/output.css --watch",
|
|
49
50
|
"type-check": "tsc --noEmit",
|
|
50
51
|
"test": "bun test src/components/booking-search/tests/",
|
|
51
52
|
"test:coverage": "bun test --coverage src/components/booking-search/tests/",
|
|
52
|
-
"prepublishOnly": "bun run type-check && bun run test && bun run build"
|
|
53
|
-
"ts:check": "tsc --noEmit"
|
|
53
|
+
"prepublishOnly": "bun run type-check && bun run test && bun run build"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@happy-dom/global-registrator": "^20.0.11",
|
package/src/demo.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import { createRoot } from "react-dom/client"
|
|
3
|
-
import { BookingSearch } from "./components/booking-search"
|
|
3
|
+
import { BookingSearch } from "./components/booking-search";
|
|
4
4
|
import type { BookingSearchPayload, SearchLocation, AvailabilityDay } from "./types/booking"
|
|
5
5
|
import "./styles/output.css"
|
|
6
6
|
|