@metron-labs/quote-react 0.1.65 → 0.1.67

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.
Files changed (76) hide show
  1. package/dist/app/EstimatingTools.js +12 -8
  2. package/dist/app/QuickQuote.js +10 -10
  3. package/dist/app/stages/BasketStage.d.ts +0 -2
  4. package/dist/app/stages/BasketStage.js +22 -26
  5. package/dist/app/stages/EntryStage.d.ts +0 -2
  6. package/dist/app/stages/EntryStage.js +20 -13
  7. package/dist/app/stages/ProcessingStage.js +1 -1
  8. package/dist/app/stages/ScheduleResultsStage.js +14 -14
  9. package/dist/components/ChevronIcon.d.ts +1 -0
  10. package/dist/components/ChevronIcon.js +4 -0
  11. package/dist/components/InsulationPlaceholder.d.ts +2 -0
  12. package/dist/components/InsulationPlaceholder.js +6 -0
  13. package/dist/components/ProductPlaceholder.d.ts +2 -0
  14. package/dist/components/ProductPlaceholder.js +6 -0
  15. package/dist/components/TrashIcon.d.ts +1 -0
  16. package/dist/components/TrashIcon.js +4 -0
  17. package/dist/components/estimators/ArchitraveEstimator.js +1 -1
  18. package/dist/components/estimators/DeckingEstimator.js +2 -2
  19. package/dist/components/estimators/EstimatorResults.d.ts +1 -1
  20. package/dist/components/estimators/EstimatorResults.js +8 -8
  21. package/dist/components/estimators/EstimatorReviewStage.d.ts +1 -1
  22. package/dist/components/estimators/EstimatorReviewStage.js +1 -1
  23. package/dist/components/estimators/FencingEstimator.js +2 -2
  24. package/dist/components/estimators/PaintEstimator.js +1 -1
  25. package/dist/components/estimators/RoofTrussEstimator.js +1 -1
  26. package/dist/components/estimators/registry.d.ts +1 -1
  27. package/dist/components/estimators/useFixedBasket.js +3 -3
  28. package/dist/embed/quote.js +10 -29
  29. package/dist/index.d.ts +5 -5
  30. package/dist/index.js +3 -3
  31. package/dist/util/ProductImage.d.ts +9 -0
  32. package/dist/util/ProductImage.js +25 -0
  33. package/dist/{lib → util}/api/fetchSchedule.d.ts +1 -1
  34. package/dist/{lib → util}/cart/CartContext.d.ts +1 -2
  35. package/dist/{lib/boq → util/cart}/toCartItem.d.ts +1 -1
  36. package/dist/{lib → util}/estimators/requestUnit.d.ts +1 -1
  37. package/dist/{lib → util}/estimators/resolveProducts.d.ts +1 -1
  38. package/dist/util/exportScheduleExcel.js +17 -3
  39. package/package.json +1 -1
  40. package/dist/lib/productImage.d.ts +0 -1
  41. package/dist/lib/productImage.js +0 -75
  42. /package/dist/{app/components → components/unit}/UnitDisplay.d.ts +0 -0
  43. /package/dist/{app/components → components/unit}/UnitDisplay.js +0 -0
  44. /package/dist/{app/components → components/unit}/UnitLabel.d.ts +0 -0
  45. /package/dist/{app/components → components/unit}/UnitLabel.js +0 -0
  46. /package/dist/{lib → util}/QuoteProvider.d.ts +0 -0
  47. /package/dist/{lib → util}/QuoteProvider.js +0 -0
  48. /package/dist/{lib → util}/analytics.d.ts +0 -0
  49. /package/dist/{lib → util}/analytics.js +0 -0
  50. /package/dist/{lib → util}/api/boqClient.d.ts +0 -0
  51. /package/dist/{lib → util}/api/boqClient.js +0 -0
  52. /package/dist/{lib → util}/api/boqSession.d.ts +0 -0
  53. /package/dist/{lib → util}/api/boqSession.js +0 -0
  54. /package/dist/{lib → util}/api/fetchSchedule.js +0 -0
  55. /package/dist/{lib → util}/api/pollJob.d.ts +0 -0
  56. /package/dist/{lib → util}/api/pollJob.js +0 -0
  57. /package/dist/{lib → util}/assets.d.ts +0 -0
  58. /package/dist/{lib → util}/assets.js +0 -0
  59. /package/dist/{lib → util}/cart/CartContext.js +0 -0
  60. /package/dist/{lib/boq → util/cart}/toCartItem.js +0 -0
  61. /package/dist/{lib → util}/config.d.ts +0 -0
  62. /package/dist/{lib → util}/config.js +0 -0
  63. /package/dist/{lib → util}/estimators/fixedProducts.d.ts +0 -0
  64. /package/dist/{lib → util}/estimators/fixedProducts.js +0 -0
  65. /package/dist/{lib → util}/estimators/requestUnit.js +0 -0
  66. /package/dist/{lib → util}/estimators/resolveProducts.js +0 -0
  67. /package/dist/{lib → util}/estimators/types.d.ts +0 -0
  68. /package/dist/{lib → util}/estimators/types.js +0 -0
  69. /package/dist/{lib → util}/formatters.d.ts +0 -0
  70. /package/dist/{lib → util}/formatters.js +0 -0
  71. /package/dist/{lib/boq → util}/inputLimits.d.ts +0 -0
  72. /package/dist/{lib/boq → util}/inputLimits.js +0 -0
  73. /package/dist/{lib → util}/quoteHistory.d.ts +0 -0
  74. /package/dist/{lib → util}/quoteHistory.js +0 -0
  75. /package/dist/{lib → util}/useEscapeKey.d.ts +0 -0
  76. /package/dist/{lib → util}/useEscapeKey.js +0 -0
package/dist/index.d.ts CHANGED
@@ -2,10 +2,10 @@ export { default as QuickQuote } from "./app/QuickQuote";
2
2
  export type { QuickQuoteProps } from "./app/QuickQuote";
3
3
  export { default as EstimatingTools } from "./app/EstimatingTools";
4
4
  export type { EstimatingToolsProps } from "./app/EstimatingTools";
5
- export { QuoteProvider } from "./lib/QuoteProvider";
6
- export type { QuoteConfig } from "./lib/config";
7
- export { STEP_EVENT, DATALAYER_EVENT } from "./lib/analytics";
8
- export type { Step, WidgetEvent, WidgetName } from "./lib/analytics";
5
+ export { QuoteProvider } from "./util/QuoteProvider";
6
+ export type { QuoteConfig } from "./util/config";
7
+ export { STEP_EVENT, DATALAYER_EVENT } from "./util/analytics";
8
+ export type { Step, WidgetEvent, WidgetName } from "./util/analytics";
9
9
  export { ESTIMATOR_TOOLS } from "./components/estimators/registry";
10
10
  export type { EstimatorToolId } from "./components/estimators/registry";
11
- export type { EstimatorRequirement } from "./lib/estimators/types";
11
+ export type { EstimatorRequirement } from "./util/estimators/types";
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // Public surface of @metron-labs/quote-react.
2
2
  //
3
3
  // Metron's own staff screens also deep-import internals such as
4
- // "@metron-labs/quote-react/lib/formatters" through the "./*" export in package.json.
4
+ // "@metron-labs/quote-react/util/formatters" through the "./*" export in package.json.
5
5
  export { default as QuickQuote } from "./app/QuickQuote";
6
6
  export { default as EstimatingTools } from "./app/EstimatingTools";
7
- export { QuoteProvider } from "./lib/QuoteProvider";
8
- export { STEP_EVENT, DATALAYER_EVENT } from "./lib/analytics";
7
+ export { QuoteProvider } from "./util/QuoteProvider";
8
+ export { STEP_EVENT, DATALAYER_EVENT } from "./util/analytics";
9
9
  export { ESTIMATOR_TOOLS } from "./components/estimators/registry";
@@ -0,0 +1,9 @@
1
+ type Props = {
2
+ description?: string;
3
+ photoUrl?: string | null;
4
+ className?: string;
5
+ width?: number;
6
+ height?: number;
7
+ };
8
+ export default function ProductImage({ description, photoUrl, className, width, height }: Props): import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { assetUrl } from "./assets";
3
+ import InsulationPlaceholder from "../components/InsulationPlaceholder";
4
+ import ProductPlaceholder from "../components/ProductPlaceholder";
5
+ // Bundled stand-in photos for common materials, matched on the description. Order matters:
6
+ // "loft insulation" must win over the generic insulation drawing below.
7
+ const PHOTOS = [
8
+ { match: ["building sand"], path: "/schedule-products/building-sand.webp" },
9
+ { match: ["drywall screw"], path: "/schedule-products/drywall-screws.webp" },
10
+ { match: ["scrim"], path: "/schedule-products/scrim-tape.webp" },
11
+ { match: ["loft insulation", "loft roll"], path: "/schedule-products/loft-insulation-roll.webp" },
12
+ { match: ["wall tie"], path: "/schedule-products/wall-ties.webp" },
13
+ { match: ["red multi", "multi stock", "brick"], path: "/schedule-products/red-multi-stock-bricks.webp" },
14
+ ];
15
+ // The catalogue's own product photo when it has one, then a bundled photo, then a drawing.
16
+ // Decorative wherever it's used, since the product name always sits beside it.
17
+ export default function ProductImage({ description, photoUrl, className, width, height }) {
18
+ const text = (description || "").toLowerCase();
19
+ const bundled = PHOTOS.find((entry) => entry.match.some((word) => text.includes(word)));
20
+ const src = photoUrl || (bundled && assetUrl(bundled.path));
21
+ if (src)
22
+ return _jsx("img", { className: className, src: src, alt: "", width: width, height: height });
23
+ const Placeholder = text.includes("insulation") ? InsulationPlaceholder : ProductPlaceholder;
24
+ return _jsx(Placeholder, { className: className, width: width, height: height });
25
+ }
@@ -1,4 +1,4 @@
1
- import type { PhotoExtractedLine, ScheduleResult } from "../../util/types";
1
+ import type { PhotoExtractedLine, ScheduleResult } from "../types";
2
2
  export interface ScheduleJobStatus {
3
3
  status: "pending" | "processing" | "completed" | "failed";
4
4
  result: ScheduleResult | null;
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
- import type { CartItem } from "../../util/types";
2
+ import type { CartItem } from "../types";
3
3
  interface CartApi {
4
4
  cart: Record<string, CartItem>;
5
5
  count: number;
@@ -10,7 +10,6 @@ interface CartApi {
10
10
  updateCartSellUnits: (lineId: string, sellUnitsOverride: number) => void;
11
11
  updateCartConversions: (conversions: Record<string, Partial<CartItem>>) => void;
12
12
  clearCart: () => void;
13
- /** Show the basket. Each app decides what that means for its own navigation. */
14
13
  openBasket: () => void;
15
14
  }
16
15
  /** The inputs that can change a conversion, including the selected parent of a dependent line. */
@@ -1,4 +1,4 @@
1
- import type { CartItem, MatchCandidate } from "../../util/types";
1
+ import type { CartItem, MatchCandidate } from "../types";
2
2
  /**
3
3
  * Flattens a catalogue candidate's nested `conversion` block onto a CartItem, which
4
4
  * util/pricing.ts reads to derive sell units. Extracted from ScheduleResultsStage so
@@ -1,4 +1,4 @@
1
- import type { MatchCandidate } from "../../util/types";
1
+ import type { MatchCandidate } from "../types";
2
2
  /**
3
3
  * The unit to ask the basket for, given the product chosen for an estimator line. Only for
4
4
  * estimator lines: a customer's "3 rolls" matched to a 2-roll pack is a different question.
@@ -1,4 +1,4 @@
1
- import type { MatchCandidate } from "../../util/types";
1
+ import type { MatchCandidate } from "../types";
2
2
  import type { EstimatorToolId } from "../../components/estimators/registry";
3
3
  import type { EstimatorRequirement } from "./types";
4
4
  export interface ResolvedRequirement {
@@ -1,4 +1,4 @@
1
- import { unitDisplayText } from "../app/components/UnitDisplay";
1
+ import { unitDisplayText } from "../components/unit/UnitDisplay";
2
2
  import { getPricingBreakdown } from "./pricing";
3
3
  // xlsx is several hundred KB and only needed on download, so it loads on first use.
4
4
  const loadXlsx = () => import("xlsx");
@@ -95,7 +95,10 @@ export async function exportScheduleExcel(rows) {
95
95
  totalRow[0] = "Estimated total";
96
96
  totalRow[TOTAL_COL] = grandTotal;
97
97
  wsData.push(totalRow);
98
- wsData.push(["DISCLAIMER: These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence.", ...Array(HEADER.length - 1).fill(null)]);
98
+ wsData.push([
99
+ "DISCLAIMER: These matches are generated automatically and should be reviewed before procurement, especially any items flagged as medium or low confidence.",
100
+ ...Array(HEADER.length - 1).fill(null),
101
+ ]);
99
102
  const ws = XLSX.utils.aoa_to_sheet(wsData);
100
103
  ws["!cols"] = [
101
104
  { wch: 12 },
@@ -130,7 +133,18 @@ export async function exportScheduleExcel(rows) {
130
133
  XLSX.utils.book_append_sheet(wb, ws, "Schedule match");
131
134
  XLSX.writeFile(wb, `schedule-quote-${dateStr}.xlsx`);
132
135
  }
133
- const BASKET_HEADER = ["Product ID", "Description", "Costing mode", "Required amount", "Req unit", "Sell unit size", "Sell unit", "Required sell units", "Unit price", "Line total"];
136
+ const BASKET_HEADER = [
137
+ "Product ID",
138
+ "Description",
139
+ "Costing mode",
140
+ "Required amount",
141
+ "Req unit",
142
+ "Sell unit size",
143
+ "Sell unit",
144
+ "Required sell units",
145
+ "Unit price",
146
+ "Line total",
147
+ ];
134
148
  /** Basket has its own (much smaller) row shape than the full schedule match, so it gets its own export rather than forcing CartItem into ScheduleExportRow. */
135
149
  export async function exportBasketExcel(items, account) {
136
150
  const XLSX = await loadXlsx();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metron-labs/quote-react",
3
- "version": "0.1.65",
3
+ "version": "0.1.67",
4
4
  "description": "Metron Labs quote and estimating calculator components for React",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": [
@@ -1 +0,0 @@
1
- export declare function productImageSrc(description: string | undefined, productId?: string, pdpPhotoUrl?: string | null): string;
@@ -1,75 +0,0 @@
1
- import { assetUrl } from "./assets";
2
- function encodeSvg(svg) {
3
- return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
4
- }
5
- // Bundled stand-in photos for common materials, matched on the description. Order matters:
6
- // "loft insulation" must win over the generic insulation drawing below.
7
- const PHOTOS = [
8
- { match: ["building sand"], path: "/schedule-products/building-sand.webp" },
9
- { match: ["drywall screw"], path: "/schedule-products/drywall-screws.webp" },
10
- { match: ["scrim"], path: "/schedule-products/scrim-tape.webp" },
11
- { match: ["loft insulation", "loft roll"], path: "/schedule-products/loft-insulation-roll.webp" },
12
- { match: ["wall tie"], path: "/schedule-products/wall-ties.webp" },
13
- { match: ["red multi", "multi stock", "brick"], path: "/schedule-products/red-multi-stock-bricks.webp" },
14
- ];
15
- // Materials Market PDP photos used as a demo fallback when a candidate has no own photo.
16
- // Keep specific matches above broad ones because several descriptions contain "cement".
17
- const CATALOGUE_PHOTOS = [
18
- { match: ["mortar"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/Blue+Circle+Quality+Assured+Mortar+Mix+-+Photo.jpg" },
19
- { match: ["mot type 1"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/MOT+-+Photo+1.jpg" },
20
- { match: ["soft sand", "building sand"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/Soft+Building+Sand+-+Photo+1.jpg" },
21
- { match: ["cement"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/blue+circle+general+cement+bagged.jpg" },
22
- { match: ["brick"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/class+B+engineering+brick+smooth+red+perforated+65mm+-+Photo+1+comp.jpg" },
23
- { match: ["dense block", "concrete block"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/100mm+solid+dense+concrete+block+-+Photo+1+-+1920+comp.jpg" },
24
- { match: ["metal c stud", "c stud"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/70mm+c+stud+angle.jpg" },
25
- { match: ["timber", "carcassing", "sawn", "c24", "c16"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/47mm+x+100mm+sawn+treated+c16+-+Photo+1+1920.jpg" },
26
- { match: ["osb"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/18mm+structural+OSB+-+Photo+1+comp.jpg" },
27
- { match: ["dpc"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/225mm+damp+proof+course.jpg" },
28
- { match: ["soil pipe", "soil bend", "underground", "drainage"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/110mm+Soil+Pipe+Single+Socket+Black+3m+-+High+Res.jpg" },
29
- { match: ["nail"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/galvanised+round+wire+nail+vertical.jpg" },
30
- { match: ["retaining clip", "retaining clips", "insulation disc", "insulation disks"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/multiple+zinc+insulation+discs.jpg" },
31
- { match: ["wall tie"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/Type+4+Wall+Ties+-+Photo.jpg" },
32
- { match: ["loft insulation", "loft roll", "insulation roll"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/200mm+knauf+loft+roll+44+unwrapping.jpg" },
33
- { match: ["pir insulation", "insulation board", "celotex", "unilin", "indiboard"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/100mm+celotex+sheet+logo.jpg" },
34
- { match: ["plasterboard", "wallboard"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/12.5mm+wallboard+tapered+edge+corner.jpg" },
35
- { match: ["drywall screw"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/close+up+drywall+course+thread.jpg" },
36
- { match: ["scrim", "jointing tape", "paper tape"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/50mm+scrim+tape.jpg" },
37
- { match: ["adhesive", "high grab", "evostik", "stixall", "gripfill", "sealant", "ct1"], url: "https://res.cloudinary.com/materials-market/image/upload/c_fill,w_750/assets/product-images-final/Instant+Nails+Solvent+Free+Grab+Adhesive+White+290ml+-+Photo.jpg" },
38
- ];
39
- // The catalogue's own product photo when it has one, then a bundled photo, then a drawing.
40
- // ponytail: productId is unused for now; callers already pass it for when bundled images
41
- // are keyed by product.
42
- export function productImageSrc(description, productId, pdpPhotoUrl) {
43
- if (pdpPhotoUrl)
44
- return pdpPhotoUrl;
45
- const text = (description || "").toLowerCase();
46
- const cataloguePhoto = CATALOGUE_PHOTOS.find((entry) => entry.match.some((word) => text.includes(word)));
47
- if (cataloguePhoto)
48
- return cataloguePhoto.url;
49
- const photo = PHOTOS.find((entry) => entry.match.some((word) => text.includes(word)));
50
- if (photo)
51
- return assetUrl(photo.path);
52
- if (text.includes("insulation")) {
53
- return encodeSvg(`
54
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 420">
55
- <rect width="640" height="420" fill="#fbf1cf"/>
56
- <rect x="88" y="78" width="432" height="264" rx="16" fill="#f0c43f"/>
57
- <rect x="120" y="110" width="368" height="200" rx="10" fill="#ffd95e"/>
58
- <g stroke="#e2b12e" stroke-width="8" opacity="0.75">
59
- <line x1="140" y1="140" x2="468" y2="140"/>
60
- <line x1="140" y1="190" x2="468" y2="190"/>
61
- <line x1="140" y1="240" x2="468" y2="240"/>
62
- </g>
63
- </svg>
64
- `);
65
- }
66
- return encodeSvg(`
67
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 420">
68
- <rect width="640" height="420" fill="#edf1f5"/>
69
- <rect x="132" y="108" width="376" height="204" rx="18" fill="#d5dde6"/>
70
- <rect x="168" y="144" width="304" height="24" rx="12" fill="#9aa6b2"/>
71
- <rect x="168" y="188" width="250" height="24" rx="12" fill="#aab5c0"/>
72
- <rect x="168" y="232" width="220" height="24" rx="12" fill="#aab5c0"/>
73
- </svg>
74
- `);
75
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes