@voyantjs/cruises-ui 0.19.0 → 0.21.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 "@voyantjs/catalog-react";
2
+ export interface CruiseCatalogCardProps {
3
+ hit: CatalogSearchHit;
4
+ onClick?: (hit: CatalogSearchHit) => void;
5
+ className?: string;
6
+ }
7
+ /**
8
+ * Search-result card for a cruise hit. Reads sailing-shaped fields:
9
+ * `name`, `shipName`, `departureDate`, `nights`, `status`, `priceFromCents`,
10
+ * `currency`, `embarkationPort`, `tags`.
11
+ */
12
+ export declare function CruiseCatalogCard({ hit, onClick, className }: CruiseCatalogCardProps): import("react/jsx-runtime").JSX.Element;
13
+ //# sourceMappingURL=cruise-catalog-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cruise-catalog-card.d.ts","sourceRoot":"","sources":["../../src/components/cruise-catalog-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAK/D,MAAM,WAAW,sBAAsB;IACrC,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,iBAAiB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,sBAAsB,2CAgEpF"}
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Badge } from "@voyantjs/ui/components/badge";
4
+ import { Card, CardContent } from "@voyantjs/ui/components/card";
5
+ import { cn } from "@voyantjs/ui/lib/utils";
6
+ /**
7
+ * Search-result card for a cruise hit. Reads sailing-shaped fields:
8
+ * `name`, `shipName`, `departureDate`, `nights`, `status`, `priceFromCents`,
9
+ * `currency`, `embarkationPort`, `tags`.
10
+ */
11
+ export function CruiseCatalogCard({ hit, onClick, className }) {
12
+ const f = hit.document.fields;
13
+ const name = stringOr(f.name, "Untitled sailing");
14
+ const shipName = stringOr(f.shipName, null);
15
+ const status = stringOr(f.status, null);
16
+ const departureDate = stringOr(f.departureDate, null);
17
+ const nights = numberOr(f.nights, null);
18
+ const embarkationPort = stringOr(f.embarkationPort, null);
19
+ const tags = stringArray(f.tags);
20
+ const priceFrom = numberOr(f.priceFromCents, null);
21
+ const currency = stringOr(f.currency ?? f.sellCurrency, null);
22
+ const priceLabel = priceFrom != null && currency
23
+ ? `from ${new Intl.NumberFormat(undefined, {
24
+ style: "currency",
25
+ currency,
26
+ maximumFractionDigits: 0,
27
+ }).format(priceFrom / 100)}`
28
+ : null;
29
+ 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: [_jsxs("div", { className: "min-w-0", children: [_jsx("h3", { className: "line-clamp-2 font-medium text-sm", children: name }), shipName && _jsx("p", { className: "text-muted-foreground text-xs", children: shipName })] }), 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: [departureDate && _jsx("span", { children: departureDate }), nights != null && (_jsxs("span", { children: [nights, " night", nights === 1 ? "" : "s"] })), embarkationPort && _jsxs("span", { children: ["\u00B7 ", embarkationPort] }), priceLabel && _jsx("span", { className: "ml-auto font-medium text-foreground", children: priceLabel })] }), 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))) }))] }) }));
30
+ }
31
+ function stringOr(value, fallback) {
32
+ return typeof value === "string" && value.length > 0 ? value : fallback;
33
+ }
34
+ function numberOr(value, fallback) {
35
+ if (typeof value === "number")
36
+ return value;
37
+ if (typeof value === "string") {
38
+ const n = Number(value);
39
+ return Number.isFinite(n) ? n : fallback;
40
+ }
41
+ return fallback;
42
+ }
43
+ function stringArray(value) {
44
+ if (!Array.isArray(value))
45
+ return [];
46
+ return value.filter((v) => typeof v === "string" && v.length > 0);
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/cruises-ui",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,9 @@
15
15
  "import": "./dist/index.js",
16
16
  "default": "./dist/index.js"
17
17
  },
18
+ "./styles.css": {
19
+ "default": "./src/styles.css"
20
+ },
18
21
  "./i18n": {
19
22
  "types": "./dist/i18n/index.d.ts",
20
23
  "import": "./dist/i18n/index.js",
@@ -40,11 +43,12 @@
40
43
  "@tanstack/react-query": "^5.0.0",
41
44
  "react": "^19.0.0",
42
45
  "react-dom": "^19.0.0",
43
- "@voyantjs/cruises-react": "0.19.0",
44
- "@voyantjs/ui": "0.19.0"
46
+ "@voyantjs/catalog-react": "0.21.0",
47
+ "@voyantjs/cruises-react": "0.21.0",
48
+ "@voyantjs/ui": "0.21.0"
45
49
  },
46
50
  "dependencies": {
47
- "@voyantjs/i18n": "0.19.0"
51
+ "@voyantjs/i18n": "0.21.0"
48
52
  },
49
53
  "devDependencies": {
50
54
  "@tanstack/react-query": "^5.96.2",
@@ -55,13 +59,15 @@
55
59
  "react-dom": "^19.2.4",
56
60
  "typescript": "^6.0.2",
57
61
  "vitest": "^4.1.2",
58
- "@voyantjs/cruises-react": "0.19.0",
59
- "@voyantjs/i18n": "0.19.0",
60
- "@voyantjs/voyant-typescript-config": "0.1.0",
61
- "@voyantjs/ui": "0.19.0"
62
+ "@voyantjs/catalog-react": "0.21.0",
63
+ "@voyantjs/cruises-react": "0.21.0",
64
+ "@voyantjs/i18n": "0.21.0",
65
+ "@voyantjs/ui": "0.21.0",
66
+ "@voyantjs/voyant-typescript-config": "0.1.0"
62
67
  },
63
68
  "files": [
64
- "dist"
69
+ "dist",
70
+ "src/styles.css"
65
71
  ],
66
72
  "publishConfig": {
67
73
  "access": "public"
package/src/styles.css ADDED
@@ -0,0 +1,11 @@
1
+ /* Tailwind v4 source-detection helper.
2
+ *
3
+ * Templates that consume this package should `@import` this CSS so Tailwind
4
+ * scans these component files for utility classes:
5
+ *
6
+ * @import "@voyantjs/<domain>-ui/styles.css";
7
+ *
8
+ * Without it, classes that only appear inside this package (e.g. data-attr
9
+ * variants on primitives) won't be compiled into the final bundle.
10
+ */
11
+ @source "./components/**/*.{ts,tsx}";