@voyantjs/extras-ui 0.35.0 → 0.37.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.
@@ -1 +1 @@
1
- {"version":3,"file":"extra-catalog-card.d.ts","sourceRoot":"","sources":["../../src/components/extra-catalog-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAK/D,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,2CA4DlF"}
1
+ {"version":3,"file":"extra-catalog-card.d.ts","sourceRoot":"","sources":["../../src/components/extra-catalog-card.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAM/D,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,2CA8DlF"}
@@ -3,14 +3,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Badge } from "@voyantjs/ui/components/badge";
4
4
  import { Card, CardContent } from "@voyantjs/ui/components/card";
5
5
  import { cn } from "@voyantjs/ui/lib/utils";
6
+ import { useExtrasUiI18nOrDefault } from "../i18n/index.js";
6
7
  /**
7
8
  * Search-result card for an extras hit (sub-line-item add-ons attached
8
9
  * to bookings). Reads: `name`, `category`, `priceCents`, `currency`,
9
10
  * `unit` (per_person | per_booking | per_night), `tags`.
10
11
  */
11
12
  export function ExtraCatalogCard({ hit, onClick, className }) {
13
+ const i18n = useExtrasUiI18nOrDefault();
14
+ const messages = i18n.messages.catalogCard;
12
15
  const f = hit.document.fields;
13
- const name = stringOr(f.name, "Untitled extra");
16
+ const name = stringOr(f.name, messages.untitled);
14
17
  const category = stringOr(f.category, null);
15
18
  const unit = stringOr(f.unit, null);
16
19
  const status = stringOr(f.status, null);
@@ -18,13 +21,17 @@ export function ExtraCatalogCard({ hit, onClick, className }) {
18
21
  const price = numberOr(f.priceCents, null);
19
22
  const currency = stringOr(f.currency ?? f.sellCurrency, null);
20
23
  const priceLabel = price != null && currency
21
- ? new Intl.NumberFormat(undefined, {
22
- style: "currency",
23
- currency,
24
+ ? i18n.formatCurrency(price / 100, currency, {
24
25
  maximumFractionDigits: 2,
25
- }).format(price / 100)
26
+ })
26
27
  : null;
27
- 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 && (_jsxs("span", { className: "ml-1 text-muted-foreground", children: ["/ ", 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))) }))] }) }));
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
+ });
28
35
  }
29
36
  function stringOr(value, fallback) {
30
37
  return typeof value === "string" && value.length > 0 ? value : fallback;
package/dist/i18n/en.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  export declare const extrasUiEn: {
2
+ catalogCard: {
3
+ untitled: string;
4
+ unitPrefix: string;
5
+ };
2
6
  productCombobox: {
3
7
  placeholder: string;
4
8
  loading: string;
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;CAoBK,CAAA"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;CAwBK,CAAA"}
package/dist/i18n/en.js CHANGED
@@ -1,4 +1,8 @@
1
1
  export const extrasUiEn = {
2
+ catalogCard: {
3
+ untitled: "Untitled extra",
4
+ unitPrefix: "/ {unit}",
5
+ },
2
6
  productCombobox: {
3
7
  placeholder: "Search products...",
4
8
  loading: "Loading...",
@@ -2,6 +2,10 @@ import type { ProductRecord } from "@voyantjs/products-react";
2
2
  export type ProductStatus = ProductRecord["status"];
3
3
  export type ProductBookingMode = ProductRecord["bookingMode"];
4
4
  export type ExtrasUiMessages = {
5
+ catalogCard: {
6
+ untitled: string;
7
+ unitPrefix: string;
8
+ };
5
9
  productCombobox: {
6
10
  placeholder: string;
7
11
  loading: string;
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/i18n/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;AACnD,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,aAAa,CAAC,CAAA;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,eAAe,EAAE;QACf,WAAW,EAAE,MAAM,CAAA;QACnB,OAAO,EAAE,MAAM,CAAA;QACf,KAAK,EAAE,MAAM,CAAA;QACb,YAAY,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;QAC3C,iBAAiB,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;KACtD,CAAA;CACF,CAAA"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/i18n/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;AACnD,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,aAAa,CAAC,CAAA;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE;QACX,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,eAAe,EAAE;QACf,WAAW,EAAE,MAAM,CAAA;QACnB,OAAO,EAAE,MAAM,CAAA;QACf,KAAK,EAAE,MAAM,CAAA;QACb,YAAY,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;QAC3C,iBAAiB,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;KACtD,CAAA;CACF,CAAA"}
@@ -3,6 +3,10 @@ import type { ReactNode } from "react";
3
3
  import type { ExtrasUiMessages } from "./messages.js";
4
4
  export declare const extrasUiMessageDefinitions: {
5
5
  en: {
6
+ catalogCard: {
7
+ untitled: string;
8
+ unitPrefix: string;
9
+ };
6
10
  productCombobox: {
7
11
  placeholder: string;
8
12
  loading: string;
@@ -24,6 +28,10 @@ export declare const extrasUiMessageDefinitions: {
24
28
  };
25
29
  };
26
30
  ro: {
31
+ catalogCard: {
32
+ untitled: string;
33
+ unitPrefix: string;
34
+ };
27
35
  productCombobox: {
28
36
  placeholder: string;
29
37
  loading: string;
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/i18n/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EAEtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAKrD,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGe,CAAA;AAEtD,MAAM,MAAM,wBAAwB,GAAG,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;AAS/E,wBAAgB,uBAAuB,CAAC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AAE;IACD,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACjC,SAAS,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAA;CAC5C,oBAOA;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAClC,SAAS,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAA;CAC5C,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CASrC;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,MAAM,EACN,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,SAAS,CAAA;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACjC,SAAS,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAA;CAC5C,2CAWA;AAED,eAAO,MAAM,eAAe,0CAA0B,CAAA;AACtD,eAAO,MAAM,mBAAmB,wBAA8B,CAAA;AAE9D,wBAAgB,wBAAwB,uCAEvC;AAED,wBAAgB,4BAA4B,qBAE3C"}
package/dist/i18n/ro.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  export declare const extrasUiRo: {
2
+ catalogCard: {
3
+ untitled: string;
4
+ unitPrefix: string;
5
+ };
2
6
  productCombobox: {
3
7
  placeholder: string;
4
8
  loading: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ro.d.ts","sourceRoot":"","sources":["../../src/i18n/ro.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;CAoBK,CAAA"}
1
+ {"version":3,"file":"ro.d.ts","sourceRoot":"","sources":["../../src/i18n/ro.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;CAwBK,CAAA"}
package/dist/i18n/ro.js CHANGED
@@ -1,4 +1,8 @@
1
1
  export const extrasUiRo = {
2
+ catalogCard: {
3
+ untitled: "Extra fara nume",
4
+ unitPrefix: "/ {unit}",
5
+ },
2
6
  productCombobox: {
3
7
  placeholder: "Cauta produse...",
4
8
  loading: "Se incarca...",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/extras-ui",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,13 +46,13 @@
46
46
  "react-dom": "^19.0.0",
47
47
  "react-hook-form": "^7.60.0",
48
48
  "zod": "^4.3.6",
49
- "@voyantjs/catalog-react": "0.35.0",
50
- "@voyantjs/extras-react": "0.35.0",
51
- "@voyantjs/products-react": "0.35.0",
52
- "@voyantjs/ui": "0.35.0"
49
+ "@voyantjs/catalog-react": "0.37.0",
50
+ "@voyantjs/extras-react": "0.37.0",
51
+ "@voyantjs/products-react": "0.37.0",
52
+ "@voyantjs/ui": "0.37.0"
53
53
  },
54
54
  "dependencies": {
55
- "@voyantjs/i18n": "0.35.0"
55
+ "@voyantjs/i18n": "0.37.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@tanstack/react-query": "^5.96.2",
@@ -66,11 +66,11 @@
66
66
  "typescript": "^6.0.2",
67
67
  "vitest": "^4.1.2",
68
68
  "zod": "^4.3.6",
69
- "@voyantjs/catalog-react": "0.35.0",
70
- "@voyantjs/extras-react": "0.35.0",
71
- "@voyantjs/i18n": "0.35.0",
72
- "@voyantjs/products-react": "0.35.0",
73
- "@voyantjs/ui": "0.35.0",
69
+ "@voyantjs/catalog-react": "0.37.0",
70
+ "@voyantjs/extras-react": "0.37.0",
71
+ "@voyantjs/i18n": "0.37.0",
72
+ "@voyantjs/products-react": "0.37.0",
73
+ "@voyantjs/ui": "0.37.0",
74
74
  "@voyantjs/voyant-typescript-config": "0.1.0"
75
75
  },
76
76
  "files": [