@hotelcard/ui 0.0.9 → 0.0.12
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 +136 -0
- package/dist/index.cjs +1068 -243
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +658 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +248 -2
- package/dist/index.d.ts +248 -2
- package/dist/index.js +994 -178
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -78,6 +78,9 @@ function App() {
|
|
|
78
78
|
| `Dropdown` | Select dropdown |
|
|
79
79
|
| `Modal` | Modal dialog |
|
|
80
80
|
| `SectionHeader` | Section title with "Show all" button |
|
|
81
|
+
| `WhenContent` | Date/month picker for search (accepts labels as props) |
|
|
82
|
+
| `DualCalendar` | Calendar component for date range selection |
|
|
83
|
+
| `GuestContent` | Guest selector with adults, children (with ages), and pet toggle |
|
|
81
84
|
|
|
82
85
|
### Icons
|
|
83
86
|
|
|
@@ -173,6 +176,67 @@ import { Modal } from '@hotelcard/ui';
|
|
|
173
176
|
</Modal>
|
|
174
177
|
```
|
|
175
178
|
|
|
179
|
+
### WhenContent (Date Picker)
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { WhenContent } from '@hotelcard/ui';
|
|
183
|
+
|
|
184
|
+
<WhenContent
|
|
185
|
+
initialDateRange={{ start: null, end: null }}
|
|
186
|
+
initialMonthFilter={null}
|
|
187
|
+
onChange={(dateRange) => setDateRange(dateRange)}
|
|
188
|
+
onMonthFilterChange={(months) => setMonthFilter(months)}
|
|
189
|
+
variant="dropdown"
|
|
190
|
+
showApplyButton={true}
|
|
191
|
+
onApply={() => closeDropdown()}
|
|
192
|
+
labels={{
|
|
193
|
+
dates: 'Dates', // Tab label
|
|
194
|
+
flexible: 'Flexible', // Tab label
|
|
195
|
+
anytime: 'Anytime', // Button label
|
|
196
|
+
selectMonths: 'When do you want to travel?',
|
|
197
|
+
apply: 'Apply', // Button label
|
|
198
|
+
}}
|
|
199
|
+
locale="de" // Optional: 'de', 'en', 'fr', 'it'
|
|
200
|
+
/>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Note**: All text labels are passed as props. The consuming app provides translated strings.
|
|
204
|
+
|
|
205
|
+
### GuestContent (Guest Selector)
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
import { GuestContent, type GuestCounts } from '@hotelcard/ui';
|
|
209
|
+
|
|
210
|
+
const [guests, setGuests] = useState<GuestCounts>({
|
|
211
|
+
adults: 2,
|
|
212
|
+
children: 0,
|
|
213
|
+
childrenAges: [],
|
|
214
|
+
});
|
|
215
|
+
const [petFilter, setPetFilter] = useState(0);
|
|
216
|
+
|
|
217
|
+
<GuestContent
|
|
218
|
+
guests={guests}
|
|
219
|
+
onChange={setGuests}
|
|
220
|
+
petFilter={petFilter}
|
|
221
|
+
onPetChange={setPetFilter}
|
|
222
|
+
showPetToggle={true}
|
|
223
|
+
labels={{
|
|
224
|
+
adults: 'Adults',
|
|
225
|
+
children: 'Children',
|
|
226
|
+
pet: 'Pet',
|
|
227
|
+
ageOfChild: 'Age of child',
|
|
228
|
+
age: 'Age',
|
|
229
|
+
decreaseAdults: 'Decrease adults',
|
|
230
|
+
increaseAdults: 'Increase adults',
|
|
231
|
+
decreaseChildren: 'Decrease children',
|
|
232
|
+
increaseChildren: 'Increase children',
|
|
233
|
+
togglePets: 'Toggle pets',
|
|
234
|
+
}}
|
|
235
|
+
/>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Note**: All text labels are passed as props. The consuming app provides translated strings.
|
|
239
|
+
|
|
176
240
|
### Checkbox & RadioButton
|
|
177
241
|
|
|
178
242
|
```tsx
|
|
@@ -200,6 +264,7 @@ All components export their prop types:
|
|
|
200
264
|
|
|
201
265
|
```typescript
|
|
202
266
|
import type {
|
|
267
|
+
// Component Props
|
|
203
268
|
ButtonProps,
|
|
204
269
|
BadgeProps,
|
|
205
270
|
InputProps,
|
|
@@ -213,11 +278,82 @@ import type {
|
|
|
213
278
|
RatingProps,
|
|
214
279
|
DividerProps,
|
|
215
280
|
SectionHeaderProps,
|
|
281
|
+
WhenContentProps,
|
|
282
|
+
WhenContentLabels,
|
|
283
|
+
DateRange,
|
|
284
|
+
GuestContentProps,
|
|
285
|
+
GuestContentLabels,
|
|
286
|
+
GuestCounts,
|
|
287
|
+
ChildAgeError,
|
|
288
|
+
|
|
289
|
+
// Data Types
|
|
290
|
+
Hotel,
|
|
291
|
+
Booking,
|
|
292
|
+
User,
|
|
293
|
+
Address,
|
|
294
|
+
Membership,
|
|
295
|
+
SearchParams,
|
|
296
|
+
SearchFilters,
|
|
216
297
|
} from '@hotelcard/ui';
|
|
217
298
|
```
|
|
218
299
|
|
|
219
300
|
---
|
|
220
301
|
|
|
302
|
+
## Hooks
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
import { useDebounce, useResponsive, useWindowData } from '@hotelcard/ui';
|
|
306
|
+
|
|
307
|
+
// Debounce a value
|
|
308
|
+
const debouncedSearch = useDebounce(searchTerm, 300);
|
|
309
|
+
|
|
310
|
+
// Responsive breakpoint detection
|
|
311
|
+
const { isDesktop } = useResponsive(); // >= 1024px
|
|
312
|
+
|
|
313
|
+
// Window/context data
|
|
314
|
+
const { locale, currency } = useWindowData();
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## Utilities
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import { formatPrice, formatDate, formatDateRange, calculateDiscount } from '@hotelcard/ui';
|
|
323
|
+
|
|
324
|
+
// Format price with currency
|
|
325
|
+
formatPrice(199, 'CHF'); // "CHF 199"
|
|
326
|
+
|
|
327
|
+
// Format date
|
|
328
|
+
formatDate('2024-03-15', 'de-CH'); // "15. März 2024"
|
|
329
|
+
|
|
330
|
+
// Format date range
|
|
331
|
+
formatDateRange('2024-03-15', '2024-03-18', 'de-CH'); // "15. - 18. März 2024"
|
|
332
|
+
|
|
333
|
+
// Calculate discount percentage
|
|
334
|
+
calculateDiscount(400, 200); // 50
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## Context Provider (Optional)
|
|
340
|
+
|
|
341
|
+
For apps that need shared configuration:
|
|
342
|
+
|
|
343
|
+
```tsx
|
|
344
|
+
import { HotelCardUIProvider } from '@hotelcard/ui';
|
|
345
|
+
|
|
346
|
+
<HotelCardUIProvider
|
|
347
|
+
locale="de"
|
|
348
|
+
currency="CHF"
|
|
349
|
+
isDesktop={false}
|
|
350
|
+
>
|
|
351
|
+
<App />
|
|
352
|
+
</HotelCardUIProvider>
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
221
357
|
## Styling
|
|
222
358
|
|
|
223
359
|
Components use CSS variables for theming. Import the styles once in your app entry:
|