@voyantjs/suppliers-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.
@@ -1,7 +1,16 @@
1
- import type { SupplierRate, SupplierService } from "@voyantjs/suppliers-react";
2
- export declare function SupplierServiceRow({ service, rates, expanded, onToggle, onEdit, onDelete, onAddRate, onEditRate, onDeleteRate, }: {
1
+ import { type SupplierRate, type SupplierService } from "@voyantjs/suppliers-react";
2
+ export declare function SupplierServiceRow({ service, supplierId, rates, expanded, onToggle, onEdit, onDelete, onAddRate, onEditRate, onDeleteRate, }: {
3
3
  service: SupplierService;
4
- rates: SupplierRate[];
4
+ /**
5
+ * Optional. When set (and `rates` is not), the row fetches rates lazily on
6
+ * expand via `useSupplierServiceRates`.
7
+ */
8
+ supplierId?: string;
9
+ /**
10
+ * Optional. When provided, the caller owns rate fetching. When omitted and
11
+ * `supplierId` is set, rates are fetched internally on expand.
12
+ */
13
+ rates?: SupplierRate[];
5
14
  expanded: boolean;
6
15
  onToggle: () => void;
7
16
  onEdit: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"supplier-service-row.d.ts","sourceRoot":"","sources":["../../src/components/supplier-service-row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAM9E,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,GACb,EAAE;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,KAAK,EAAE,YAAY,EAAE,CAAA;IACrB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,UAAU,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAA;IACxC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC,2CAsJA"}
1
+ {"version":3,"file":"supplier-service-row.d.ts","sourceRoot":"","sources":["../../src/components/supplier-service-row.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EAErB,MAAM,2BAA2B,CAAA;AAMlC,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,UAAU,EACV,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,GACb,EAAE;IACD,OAAO,EAAE,eAAe,CAAA;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,EAAE,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,UAAU,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAA;IACxC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CACvC,2CA0JA"}
@@ -1,11 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSupplierServiceRates, } from "@voyantjs/suppliers-react";
2
3
  import { Badge, Button } from "@voyantjs/ui/components";
3
4
  import { ChevronDown, ChevronRight, Pencil, Plus, Trash2 } from "lucide-react";
4
5
  import { useSuppliersUiI18nOrDefault } from "../i18n";
5
- export function SupplierServiceRow({ service, rates, expanded, onToggle, onEdit, onDelete, onAddRate, onEditRate, onDeleteRate, }) {
6
+ export function SupplierServiceRow({ service, supplierId, rates, expanded, onToggle, onEdit, onDelete, onAddRate, onEditRate, onDeleteRate, }) {
6
7
  const i18n = useSuppliersUiI18nOrDefault();
7
8
  const { messages } = i18n;
8
- return (_jsxs("div", { className: "rounded-md border", children: [_jsxs("div", { className: "flex items-center gap-3 p-3", children: [_jsx("button", { type: "button", onClick: onToggle, className: "text-muted-foreground hover:text-foreground", children: expanded ? _jsx(ChevronDown, { className: "h-4 w-4" }) : _jsx(ChevronRight, { className: "h-4 w-4" }) }), _jsxs("div", { className: "flex-1", children: [_jsx("span", { className: "text-sm font-medium", children: service.name }), _jsxs("div", { className: "mt-0.5 flex items-center gap-2", children: [_jsx(Badge, { variant: "outline", className: "text-xs", children: messages.common.serviceTypeLabels[service.serviceType] }), service.duration ? (_jsx("span", { className: "text-xs text-muted-foreground", children: service.duration })) : null, service.capacity ? (_jsx("span", { className: "text-xs text-muted-foreground", children: messages.common.maxPax.replace("{count}", String(service.capacity)) })) : null, !service.active ? (_jsx(Badge, { variant: "secondary", className: "text-xs", children: messages.common.inactive })) : null] })] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: onEdit, "aria-label": messages.common.edit, title: messages.common.edit, children: _jsx(Pencil, { className: "h-3.5 w-3.5" }) }), _jsx(Button, { variant: "ghost", size: "sm", onClick: onDelete, "aria-label": messages.common.delete, title: messages.common.delete, children: _jsx(Trash2, { className: "h-3.5 w-3.5" }) })] })] }), expanded ? (_jsxs("div", { className: "border-t bg-muted/30 p-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between", children: [_jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: messages.supplierServiceRow.rates }), _jsxs(Button, { variant: "outline", size: "sm", onClick: onAddRate, children: [_jsx(Plus, { className: "mr-1 h-3 w-3" }), messages.supplierServiceRow.addRate] })] }), rates.length === 0 ? (_jsx("p", { className: "py-2 text-center text-xs text-muted-foreground", children: messages.supplierServiceRow.noRates })) : (_jsx("div", { className: "rounded border bg-background", children: _jsxs("table", { className: "w-full text-xs", children: [_jsx("thead", { children: _jsxs("tr", { className: "border-b text-muted-foreground", children: [_jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.name }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.amount }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.unit }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.valid }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.pax }), _jsx("th", { className: "w-16 p-2" })] }) }), _jsx("tbody", { children: rates.map((rate) => (_jsxs("tr", { className: "border-b last:border-b-0", children: [_jsx("td", { className: "p-2", children: rate.name }), _jsx("td", { className: "p-2 font-mono", children: i18n.formatCurrency(rate.amountCents / 100, rate.currency) }), _jsx("td", { className: "p-2", children: messages.common.rateUnitLabels[rate.unit] }), _jsx("td", { className: "p-2", children: rate.validFrom || rate.validTo
9
+ const { data: fetchedRates } = useSupplierServiceRates(supplierId ?? "", service.id, {
10
+ enabled: expanded && !rates && !!supplierId,
11
+ });
12
+ const resolvedRates = rates ?? fetchedRates?.data ?? [];
13
+ return (_jsxs("div", { className: "rounded-md border", children: [_jsxs("div", { className: "flex items-center gap-3 p-3", children: [_jsx("button", { type: "button", onClick: onToggle, className: "text-muted-foreground hover:text-foreground", children: expanded ? _jsx(ChevronDown, { className: "h-4 w-4" }) : _jsx(ChevronRight, { className: "h-4 w-4" }) }), _jsxs("div", { className: "flex-1", children: [_jsx("span", { className: "text-sm font-medium", children: service.name }), _jsxs("div", { className: "mt-0.5 flex items-center gap-2", children: [_jsx(Badge, { variant: "outline", className: "text-xs", children: messages.common.serviceTypeLabels[service.serviceType] }), service.duration ? (_jsx("span", { className: "text-xs text-muted-foreground", children: service.duration })) : null, service.capacity ? (_jsx("span", { className: "text-xs text-muted-foreground", children: messages.common.maxPax.replace("{count}", String(service.capacity)) })) : null, !service.active ? (_jsx(Badge, { variant: "secondary", className: "text-xs", children: messages.common.inactive })) : null] })] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: onEdit, "aria-label": messages.common.edit, title: messages.common.edit, children: _jsx(Pencil, { className: "h-3.5 w-3.5" }) }), _jsx(Button, { variant: "ghost", size: "sm", onClick: onDelete, "aria-label": messages.common.delete, title: messages.common.delete, children: _jsx(Trash2, { className: "h-3.5 w-3.5" }) })] })] }), expanded ? (_jsxs("div", { className: "border-t bg-muted/30 p-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between", children: [_jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: messages.supplierServiceRow.rates }), _jsxs(Button, { variant: "outline", size: "sm", onClick: onAddRate, children: [_jsx(Plus, { className: "mr-1 h-3 w-3" }), messages.supplierServiceRow.addRate] })] }), resolvedRates.length === 0 ? (_jsx("p", { className: "py-2 text-center text-xs text-muted-foreground", children: messages.supplierServiceRow.noRates })) : (_jsx("div", { className: "rounded border bg-background", children: _jsxs("table", { className: "w-full text-xs", children: [_jsx("thead", { children: _jsxs("tr", { className: "border-b text-muted-foreground", children: [_jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.name }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.amount }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.unit }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.valid }), _jsx("th", { className: "p-2 text-left font-medium", children: messages.supplierServiceRow.columns.pax }), _jsx("th", { className: "w-16 p-2" })] }) }), _jsx("tbody", { children: resolvedRates.map((rate) => (_jsxs("tr", { className: "border-b last:border-b-0", children: [_jsx("td", { className: "p-2", children: rate.name }), _jsx("td", { className: "p-2 font-mono", children: i18n.formatCurrency(rate.amountCents / 100, rate.currency) }), _jsx("td", { className: "p-2", children: messages.common.rateUnitLabels[rate.unit] }), _jsx("td", { className: "p-2", children: rate.validFrom || rate.validTo
9
14
  ? `${rate.validFrom ?? messages.supplierServiceRow.validFallback} — ${rate.validTo ?? messages.supplierServiceRow.validFallback}`
10
15
  : messages.common.none }), _jsx("td", { className: "p-2", children: rate.minPax || rate.maxPax
11
16
  ? `${rate.minPax ?? messages.common.unknown}-${rate.maxPax ?? messages.common.unknown}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyantjs/suppliers-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",
@@ -41,11 +44,11 @@
41
44
  "@tanstack/react-table": "^8.0.0",
42
45
  "react": "^19.0.0",
43
46
  "react-dom": "^19.0.0",
44
- "@voyantjs/suppliers-react": "0.19.0",
45
- "@voyantjs/ui": "0.19.0"
47
+ "@voyantjs/suppliers-react": "0.21.0",
48
+ "@voyantjs/ui": "0.21.0"
46
49
  },
47
50
  "dependencies": {
48
- "@voyantjs/i18n": "0.19.0"
51
+ "@voyantjs/i18n": "0.21.0"
49
52
  },
50
53
  "devDependencies": {
51
54
  "@tanstack/react-query": "^5.96.2",
@@ -57,13 +60,14 @@
57
60
  "react-dom": "^19.2.4",
58
61
  "typescript": "^6.0.2",
59
62
  "vitest": "^4.1.2",
60
- "@voyantjs/suppliers-react": "0.19.0",
61
- "@voyantjs/i18n": "0.19.0",
62
- "@voyantjs/voyant-typescript-config": "0.1.0",
63
- "@voyantjs/ui": "0.19.0"
63
+ "@voyantjs/i18n": "0.21.0",
64
+ "@voyantjs/suppliers-react": "0.21.0",
65
+ "@voyantjs/ui": "0.21.0",
66
+ "@voyantjs/voyant-typescript-config": "0.1.0"
64
67
  },
65
68
  "files": [
66
- "dist"
69
+ "dist",
70
+ "src/styles.css"
67
71
  ],
68
72
  "publishConfig": {
69
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}";