@voyant-travel/bookings-react 0.154.0 → 0.155.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.
@@ -0,0 +1,13 @@
1
+ import type { CatalogSearchHit } from "@voyant-travel/catalog-react";
2
+ export interface ExtraCatalogCardProps {
3
+ hit: CatalogSearchHit;
4
+ onClick?: (hit: CatalogSearchHit) => void;
5
+ className?: string;
6
+ }
7
+ /**
8
+ * Search-result card for an extras hit (sub-line-item add-ons attached
9
+ * to bookings). Reads: `name`, `category`, `priceCents`, `currency`,
10
+ * `unit` (per_person | per_booking | per_night), `tags`.
11
+ */
12
+ export declare function ExtraCatalogCard({ hit, onClick, className }: ExtraCatalogCardProps): import("react").JSX.Element;
13
+ //# sourceMappingURL=extra-catalog-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extra-catalog-card.d.ts","sourceRoot":"","sources":["../../../src/extras/components/extra-catalog-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAMpE,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,gBAAgB,CAAA;IACrB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAAA;IACzC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,qBAAqB,+BA8DlF"}
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Badge } from "@voyant-travel/ui/components/badge";
4
+ import { Card, CardContent } from "@voyant-travel/ui/components/card";
5
+ import { cn } from "@voyant-travel/ui/lib/utils";
6
+ import { useExtrasUiI18nOrDefault } from "../i18n/index.js";
7
+ /**
8
+ * Search-result card for an extras hit (sub-line-item add-ons attached
9
+ * to bookings). Reads: `name`, `category`, `priceCents`, `currency`,
10
+ * `unit` (per_person | per_booking | per_night), `tags`.
11
+ */
12
+ export function ExtraCatalogCard({ hit, onClick, className }) {
13
+ const i18n = useExtrasUiI18nOrDefault();
14
+ const messages = i18n.messages.catalogCard;
15
+ const f = hit.document.fields;
16
+ const name = stringOr(f.name, messages.untitled);
17
+ const category = stringOr(f.category, null);
18
+ const unit = stringOr(f.unit, null);
19
+ const status = stringOr(f.status, null);
20
+ const tags = stringArray(f.tags);
21
+ const price = numberOr(f.priceCents, null);
22
+ const currency = stringOr(f.currency ?? f.sellCurrency, null);
23
+ const priceLabel = price != null && currency
24
+ ? i18n.formatCurrency(price / 100, currency, {
25
+ maximumFractionDigits: 2,
26
+ })
27
+ : null;
28
+ return (_jsx(Card, { className: cn("h-full cursor-pointer transition-colors hover:border-primary/40", onClick == null && "cursor-default", className), onClick: onClick ? () => onClick(hit) : undefined, children: _jsxs(CardContent, { className: "flex h-full flex-col gap-2 p-4", children: [_jsxs("div", { className: "flex items-start justify-between gap-2", children: [_jsx("h3", { className: "line-clamp-2 font-medium text-sm", children: name }), status && (_jsx(Badge, { variant: status === "active" ? "default" : "secondary", className: "shrink-0", children: status }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2 text-muted-foreground text-xs", children: [category && _jsx("span", { children: category }), priceLabel && (_jsxs("span", { className: "ml-auto font-medium text-foreground", children: [priceLabel, unit && (_jsx("span", { className: "ml-1 text-muted-foreground", children: formatTemplate(messages.unitPrefix, { unit: unit.replace(/_/g, " ") }) }))] }))] }), tags.length > 0 && (_jsx("div", { className: "mt-auto flex flex-wrap gap-1", children: tags.slice(0, 4).map((tag) => (_jsx(Badge, { variant: "outline", className: "text-[10px]", children: tag }, tag))) }))] }) }));
29
+ }
30
+ function formatTemplate(template, values) {
31
+ return template.replace(/\{(\w+)\}/g, (_, key) => {
32
+ const value = values[key];
33
+ return value === undefined ? "" : String(value);
34
+ });
35
+ }
36
+ function stringOr(value, fallback) {
37
+ return typeof value === "string" && value.length > 0 ? value : fallback;
38
+ }
39
+ function numberOr(value, fallback) {
40
+ if (typeof value === "number")
41
+ return value;
42
+ if (typeof value === "string") {
43
+ const n = Number(value);
44
+ return Number.isFinite(n) ? n : fallback;
45
+ }
46
+ return fallback;
47
+ }
48
+ function stringArray(value) {
49
+ if (!Array.isArray(value))
50
+ return [];
51
+ return value.filter((v) => typeof v === "string" && v.length > 0);
52
+ }
@@ -0,0 +1,4 @@
1
+ export { ProductCombobox } from "./components/product-combobox.js";
2
+ export { SlotExtrasManifestPanel } from "./components/slot-extras-manifest-panel.js";
3
+ export { type ExtrasUiMessageOverrides, type ExtrasUiMessages, ExtrasUiMessagesProvider, extrasUiEn, extrasUiMessageDefinitions, extrasUiRo, getExtrasUiI18n, resolveExtrasUiMessages, useExtrasUiI18n, useExtrasUiI18nOrDefault, useExtrasUiMessages, useExtrasUiMessagesOrDefault, } from "./i18n/index.js";
4
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/extras/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAA;AACpF,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,wBAAwB,EACxB,UAAU,EACV,0BAA0B,EAC1B,UAAU,EACV,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { ProductCombobox } from "./components/product-combobox.js";
2
+ export { SlotExtrasManifestPanel } from "./components/slot-extras-manifest-panel.js";
3
+ export { ExtrasUiMessagesProvider, extrasUiEn, extrasUiMessageDefinitions, extrasUiRo, getExtrasUiI18n, resolveExtrasUiMessages, useExtrasUiI18n, useExtrasUiI18nOrDefault, useExtrasUiMessages, useExtrasUiMessagesOrDefault, } from "./i18n/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/bookings-react",
3
- "version": "0.154.0",
3
+ "version": "0.155.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -150,24 +150,24 @@
150
150
  "react-dom": "^19.0.0",
151
151
  "react-hook-form": "^7.80.0",
152
152
  "zod": "^4.0.0",
153
- "@voyant-travel/accommodations": "^0.114.0",
153
+ "@voyant-travel/accommodations": "^0.115.0",
154
154
  "@voyant-travel/admin": "^0.123.0",
155
- "@voyant-travel/bookings": "^0.154.0",
156
- "@voyant-travel/catalog": "^0.152.0",
157
- "@voyant-travel/catalog-react": "^0.152.0",
158
- "@voyant-travel/distribution-react": "^0.144.0",
159
- "@voyant-travel/relationships-react": "^0.154.0",
160
- "@voyant-travel/finance": "^0.154.0",
161
- "@voyant-travel/finance-react": "^0.154.0",
162
- "@voyant-travel/identity-react": "^0.154.0",
163
- "@voyant-travel/legal-react": "^0.154.0",
164
- "@voyant-travel/commerce-react": "^0.36.0",
165
- "@voyant-travel/cruises": "^0.153.0",
166
- "@voyant-travel/inventory-react": "^0.36.0",
167
- "@voyant-travel/inventory": "^0.9.1",
168
- "@voyant-travel/storefront-react": "^0.156.0",
155
+ "@voyant-travel/bookings": "^0.155.0",
156
+ "@voyant-travel/catalog": "^0.153.0",
157
+ "@voyant-travel/catalog-react": "^0.153.0",
158
+ "@voyant-travel/distribution-react": "^0.145.0",
159
+ "@voyant-travel/relationships-react": "^0.155.0",
160
+ "@voyant-travel/finance": "^0.155.0",
161
+ "@voyant-travel/finance-react": "^0.155.0",
162
+ "@voyant-travel/identity-react": "^0.155.0",
163
+ "@voyant-travel/legal-react": "^0.155.0",
164
+ "@voyant-travel/commerce-react": "^0.37.0",
165
+ "@voyant-travel/cruises": "^0.154.0",
166
+ "@voyant-travel/inventory-react": "^0.37.0",
167
+ "@voyant-travel/inventory": "^0.9.2",
168
+ "@voyant-travel/storefront-react": "^0.157.0",
169
169
  "@voyant-travel/ui": "^0.109.0",
170
- "@voyant-travel/operations-react": "^0.35.0"
170
+ "@voyant-travel/operations-react": "^0.36.0"
171
171
  },
172
172
  "peerDependenciesMeta": {
173
173
  "@tanstack/react-table": {
@@ -251,26 +251,26 @@
251
251
  "typescript": "^6.0.3",
252
252
  "vitest": "^4.1.9",
253
253
  "zod": "^4.4.3",
254
- "@voyant-travel/accommodations": "^0.114.0",
254
+ "@voyant-travel/accommodations": "^0.115.0",
255
255
  "@voyant-travel/admin": "^0.123.0",
256
- "@voyant-travel/bookings": "^0.154.0",
257
- "@voyant-travel/catalog": "^0.152.0",
258
- "@voyant-travel/catalog-react": "^0.152.0",
259
- "@voyant-travel/distribution-react": "^0.144.0",
260
- "@voyant-travel/relationships-react": "^0.154.0",
261
- "@voyant-travel/finance": "^0.154.0",
262
- "@voyant-travel/finance-react": "^0.154.0",
263
- "@voyant-travel/identity-react": "^0.154.0",
264
- "@voyant-travel/legal-react": "^0.154.0",
265
- "@voyant-travel/commerce-react": "^0.36.0",
266
- "@voyant-travel/cruises": "^0.153.0",
267
- "@voyant-travel/inventory-react": "^0.36.0",
268
- "@voyant-travel/inventory": "^0.9.1",
256
+ "@voyant-travel/bookings": "^0.155.0",
257
+ "@voyant-travel/catalog": "^0.153.0",
258
+ "@voyant-travel/catalog-react": "^0.153.0",
259
+ "@voyant-travel/distribution-react": "^0.145.0",
260
+ "@voyant-travel/relationships-react": "^0.155.0",
261
+ "@voyant-travel/finance": "^0.155.0",
262
+ "@voyant-travel/finance-react": "^0.155.0",
263
+ "@voyant-travel/identity-react": "^0.155.0",
264
+ "@voyant-travel/legal-react": "^0.155.0",
265
+ "@voyant-travel/commerce-react": "^0.37.0",
266
+ "@voyant-travel/cruises": "^0.154.0",
267
+ "@voyant-travel/inventory-react": "^0.37.0",
268
+ "@voyant-travel/inventory": "^0.9.2",
269
269
  "@voyant-travel/react": "^0.104.1",
270
- "@voyant-travel/storefront-react": "^0.156.0",
270
+ "@voyant-travel/storefront-react": "^0.157.0",
271
271
  "@voyant-travel/ui": "^0.109.0",
272
272
  "@voyant-travel/voyant-typescript-config": "^0.1.0",
273
- "@voyant-travel/operations-react": "^0.35.0"
273
+ "@voyant-travel/operations-react": "^0.36.0"
274
274
  },
275
275
  "files": [
276
276
  "dist",