@hotelcard/ui 0.0.8 → 0.0.11
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 +96 -0
- package/dist/index.cjs +876 -243
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +457 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +180 -2
- package/dist/index.d.ts +180 -2
- package/dist/index.js +803 -178
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -78,6 +78,8 @@ 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 |
|
|
81
83
|
|
|
82
84
|
### Icons
|
|
83
85
|
|
|
@@ -173,6 +175,32 @@ import { Modal } from '@hotelcard/ui';
|
|
|
173
175
|
</Modal>
|
|
174
176
|
```
|
|
175
177
|
|
|
178
|
+
### WhenContent (Date Picker)
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
import { WhenContent } from '@hotelcard/ui';
|
|
182
|
+
|
|
183
|
+
<WhenContent
|
|
184
|
+
initialDateRange={{ start: null, end: null }}
|
|
185
|
+
initialMonthFilter={null}
|
|
186
|
+
onChange={(dateRange) => setDateRange(dateRange)}
|
|
187
|
+
onMonthFilterChange={(months) => setMonthFilter(months)}
|
|
188
|
+
variant="dropdown"
|
|
189
|
+
showApplyButton={true}
|
|
190
|
+
onApply={() => closeDropdown()}
|
|
191
|
+
labels={{
|
|
192
|
+
dates: 'Dates', // Tab label
|
|
193
|
+
flexible: 'Flexible', // Tab label
|
|
194
|
+
anytime: 'Anytime', // Button label
|
|
195
|
+
selectMonths: 'When do you want to travel?',
|
|
196
|
+
apply: 'Apply', // Button label
|
|
197
|
+
}}
|
|
198
|
+
locale="de" // Optional: 'de', 'en', 'fr', 'it'
|
|
199
|
+
/>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Note**: All text labels are passed as props. The consuming app provides translated strings.
|
|
203
|
+
|
|
176
204
|
### Checkbox & RadioButton
|
|
177
205
|
|
|
178
206
|
```tsx
|
|
@@ -200,6 +228,7 @@ All components export their prop types:
|
|
|
200
228
|
|
|
201
229
|
```typescript
|
|
202
230
|
import type {
|
|
231
|
+
// Component Props
|
|
203
232
|
ButtonProps,
|
|
204
233
|
BadgeProps,
|
|
205
234
|
InputProps,
|
|
@@ -213,11 +242,78 @@ import type {
|
|
|
213
242
|
RatingProps,
|
|
214
243
|
DividerProps,
|
|
215
244
|
SectionHeaderProps,
|
|
245
|
+
WhenContentProps,
|
|
246
|
+
WhenContentLabels,
|
|
247
|
+
DateRange,
|
|
248
|
+
|
|
249
|
+
// Data Types
|
|
250
|
+
Hotel,
|
|
251
|
+
Booking,
|
|
252
|
+
User,
|
|
253
|
+
Address,
|
|
254
|
+
Membership,
|
|
255
|
+
SearchParams,
|
|
256
|
+
SearchFilters,
|
|
216
257
|
} from '@hotelcard/ui';
|
|
217
258
|
```
|
|
218
259
|
|
|
219
260
|
---
|
|
220
261
|
|
|
262
|
+
## Hooks
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
import { useDebounce, useResponsive, useWindowData } from '@hotelcard/ui';
|
|
266
|
+
|
|
267
|
+
// Debounce a value
|
|
268
|
+
const debouncedSearch = useDebounce(searchTerm, 300);
|
|
269
|
+
|
|
270
|
+
// Responsive breakpoint detection
|
|
271
|
+
const { isDesktop } = useResponsive(); // >= 1024px
|
|
272
|
+
|
|
273
|
+
// Window/context data
|
|
274
|
+
const { locale, currency } = useWindowData();
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Utilities
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
import { formatPrice, formatDate, formatDateRange, calculateDiscount } from '@hotelcard/ui';
|
|
283
|
+
|
|
284
|
+
// Format price with currency
|
|
285
|
+
formatPrice(199, 'CHF'); // "CHF 199"
|
|
286
|
+
|
|
287
|
+
// Format date
|
|
288
|
+
formatDate('2024-03-15', 'de-CH'); // "15. März 2024"
|
|
289
|
+
|
|
290
|
+
// Format date range
|
|
291
|
+
formatDateRange('2024-03-15', '2024-03-18', 'de-CH'); // "15. - 18. März 2024"
|
|
292
|
+
|
|
293
|
+
// Calculate discount percentage
|
|
294
|
+
calculateDiscount(400, 200); // 50
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Context Provider (Optional)
|
|
300
|
+
|
|
301
|
+
For apps that need shared configuration:
|
|
302
|
+
|
|
303
|
+
```tsx
|
|
304
|
+
import { HotelCardUIProvider } from '@hotelcard/ui';
|
|
305
|
+
|
|
306
|
+
<HotelCardUIProvider
|
|
307
|
+
locale="de"
|
|
308
|
+
currency="CHF"
|
|
309
|
+
isDesktop={false}
|
|
310
|
+
>
|
|
311
|
+
<App />
|
|
312
|
+
</HotelCardUIProvider>
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
221
317
|
## Styling
|
|
222
318
|
|
|
223
319
|
Components use CSS variables for theming. Import the styles once in your app entry:
|