@standhigher/besttrack-page-extension 0.5.2 → 0.5.3

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.
package/dist/index.js CHANGED
@@ -913,7 +913,13 @@ function ProductImage({ src, alt, size = 60 }) {
913
913
  }
914
914
  return /* @__PURE__ */ jsx("img", { src: safeSrc, alt, onError: () => setFailed(true), style: box });
915
915
  }
916
- function TrackingProgress({ steps }) {
916
+ var hexColor = /^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i;
917
+ var defaultProgressColor = "#0f172a";
918
+ function progressColor(value) {
919
+ return value && hexColor.test(value) ? value : defaultProgressColor;
920
+ }
921
+ function TrackingProgress({ steps, color }) {
922
+ const active = progressColor(color);
917
923
  const cells = Math.max(steps.length, 1);
918
924
  return /* @__PURE__ */ jsxs("div", { className: "bt-progress", role: "region", "aria-label": "Delivery progress", style: { marginTop: 32, width: "100%", maxWidth: 1200, marginLeft: "auto", marginRight: "auto", overflow: "visible" }, children: [
919
925
  /* @__PURE__ */ jsx("style", { children: trackingProgressStyles }),
@@ -921,12 +927,12 @@ function TrackingProgress({ steps }) {
921
927
  cells > 1 ? /* @__PURE__ */ jsx("div", { className: "bt-progress__line", "aria-hidden": "true", style: { position: "absolute", left: `calc(50% / ${cells})`, right: `calc(50% / ${cells})`, height: 6, display: "flex", zIndex: 0, pointerEvents: "none" }, children: steps.slice(0, -1).map((step, index) => {
922
928
  const done = step.state === "complete" || step.state === "current";
923
929
  const nextDone = steps[index + 1]?.state === "complete" || steps[index + 1]?.state === "current";
924
- return /* @__PURE__ */ jsx("span", { style: { flex: 1, height: 6, borderRadius: 999, background: done && nextDone ? "#1a1a1a" : "rgba(0, 0, 0, 0.25)" } }, step.id + "-line");
930
+ return /* @__PURE__ */ jsx("span", { style: { flex: 1, height: 6, borderRadius: 999, background: done && nextDone ? active : `color-mix(in srgb, ${active} 25%, transparent)` } }, step.id + "-line");
925
931
  }) }) : null,
926
932
  steps.map((step, index) => {
927
933
  const done = step.state === "complete" || step.state === "current";
928
934
  return /* @__PURE__ */ jsxs("div", { style: { minWidth: 0, display: "flex", flexDirection: "column", alignItems: "center", position: "relative", zIndex: 1 }, children: [
929
- /* @__PURE__ */ jsx("span", { className: "bt-progress__icon", "aria-label": step.label + " " + step.state, style: { display: "flex", flexShrink: 0, alignItems: "center", justifyContent: "center", borderRadius: 9999, border: "1px solid #0f172a", background: done ? "#0f172a" : "#fff", color: "#0f172a" }, children: /* @__PURE__ */ jsx(StepIcon, { name: step.icon ?? (index === 0 || index === steps.length - 1 ? "check" : index === 1 ? "bag" : index === 2 ? "truck" : "box"), done }) }),
935
+ /* @__PURE__ */ jsx("span", { className: "bt-progress__icon", "aria-label": step.label + " " + step.state, style: { display: "flex", flexShrink: 0, alignItems: "center", justifyContent: "center", borderRadius: 9999, border: `1px solid ${active}`, background: done ? active : "#fff", color: active }, children: /* @__PURE__ */ jsx(StepIcon, { name: step.icon ?? (index === 0 || index === steps.length - 1 ? "check" : index === 1 ? "bag" : index === 2 ? "truck" : "box"), done }) }),
930
936
  /* @__PURE__ */ jsxs("div", { className: "bt-progress__copy", style: { width: "100%", maxWidth: "100%", boxSizing: "border-box", textAlign: "center", padding: "0 2px" }, children: [
931
937
  /* @__PURE__ */ jsx("p", { className: "bt-progress__label", style: { margin: 0, fontWeight: 500, color: "#334155", overflowWrap: "anywhere", wordBreak: "break-word" }, children: step.label }),
932
938
  step.date ? /* @__PURE__ */ jsx("p", { style: { margin: "6px 0 0", fontSize: 12, lineHeight: "16px", color: "#94a3b8", overflowWrap: "anywhere" }, children: step.date }) : null
@@ -1254,12 +1260,12 @@ var inputStyle = {
1254
1260
  color: "#334155",
1255
1261
  boxSizing: "border-box"
1256
1262
  };
1257
- var hexColor = /^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i;
1263
+ var hexColor2 = /^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i;
1258
1264
  var defaultSubmitButtonColor = "var(--pb-color-primary, #111)";
1259
1265
  function submitButtonBackground(props, loading = false) {
1260
1266
  if (loading) return "#475569";
1261
1267
  const value = text(props, "submitButtonColor");
1262
- return hexColor.test(value) ? value : defaultSubmitButtonColor;
1268
+ return hexColor2.test(value) ? value : defaultSubmitButtonColor;
1263
1269
  }
1264
1270
  function submitButtonStyle(props, loading = false) {
1265
1271
  return {
@@ -1316,7 +1322,7 @@ function eventsFrom(result) {
1316
1322
  if (result?.latestEvent) return [{ id: "latest", title: result.latestEvent, at: result.updatedAt, state: "current" }];
1317
1323
  return [];
1318
1324
  }
1319
- function ProgressResult({ result, showEstimatedDelivery = true }) {
1325
+ function ProgressResult({ result, showEstimatedDelivery = true, color }) {
1320
1326
  const steps = result.progress?.length ? result.progress : defaultProgress(result.status);
1321
1327
  return /* @__PURE__ */ jsxs3(Fragment2, { children: [
1322
1328
  /* @__PURE__ */ jsxs3("p", { style: { margin: 0, fontSize: 20, lineHeight: 1.4, color: "#000", overflowWrap: "anywhere" }, children: [
@@ -1325,7 +1331,7 @@ function ProgressResult({ result, showEstimatedDelivery = true }) {
1325
1331
  ] }),
1326
1332
  /* @__PURE__ */ jsx3("h2", { style: { margin: "clamp(24px, 8%, 48px) 0 0", fontSize: 32, lineHeight: 1.25, fontWeight: 700, color: "#303030", overflowWrap: "anywhere" }, children: result.status }),
1327
1333
  showEstimatedDelivery && result.estimatedDelivery ? /* @__PURE__ */ jsx3(EstimatedDeliveryCard, { dateText: result.estimatedDelivery }) : null,
1328
- /* @__PURE__ */ jsx3(TrackingProgress, { steps })
1334
+ /* @__PURE__ */ jsx3(TrackingProgress, { steps, color })
1329
1335
  ] });
1330
1336
  }
1331
1337
  function DeliveryResult({ heading, contentsHeading, carrierHeading, result, editing }) {
@@ -1376,8 +1382,8 @@ function ReadyToGoQueryEditor(block) {
1376
1382
  /* @__PURE__ */ jsx3("p", { style: { marginTop: "auto", paddingTop: 28, textAlign: "center", fontSize: 12, lineHeight: "17px", fontStyle: "italic", color: "#b8b8b8" }, children: "Powered by BestTrack" })
1377
1383
  ] }) });
1378
1384
  }
1379
- function ReadyToGoProgressEditor() {
1380
- return /* @__PURE__ */ jsx3("section", { "aria-label": "Ready-to-go progress editor", style: { ...pageFont, background: "var(--pb-color-background, #fff)", color: "var(--pb-color-text, #0f172a)", borderBottom: "1px solid #f1f5f9" }, children: /* @__PURE__ */ jsx3("div", { style: { ...contentWidth, textAlign: "center", width: "min(1248px, 100%)" }, children: /* @__PURE__ */ jsx3(ProgressResult, { result: previewReadyToGoTracking(), showEstimatedDelivery: false }) }) });
1385
+ function ReadyToGoProgressEditor(block) {
1386
+ return /* @__PURE__ */ jsx3("section", { "aria-label": "Ready-to-go progress editor", style: { ...pageFont, background: "var(--pb-color-background, #fff)", color: "var(--pb-color-text, #0f172a)", borderBottom: "1px solid #f1f5f9" }, children: /* @__PURE__ */ jsx3("div", { style: { ...contentWidth, textAlign: "center", width: "min(1248px, 100%)" }, children: /* @__PURE__ */ jsx3(ProgressResult, { result: previewReadyToGoTracking(), showEstimatedDelivery: false, color: text(block, "progressColor") }) }) });
1381
1387
  }
1382
1388
  function ReadyToGoDeliveryEditor(block) {
1383
1389
  const { adPreview } = useReadyToGoRuntime();
@@ -1473,7 +1479,7 @@ function ReadyToGoQueryBlock(props) {
1473
1479
  /* @__PURE__ */ jsx3(RuntimeWatermark, { watermark: runtime.watermark })
1474
1480
  ] }) });
1475
1481
  }
1476
- function ReadyToGoProgressBlock() {
1482
+ function ReadyToGoProgressBlock(props) {
1477
1483
  const runtime = useReadyToGoRuntime();
1478
1484
  const result = runtime.result;
1479
1485
  if (runtime.phase === "idle") return null;
@@ -1484,7 +1490,7 @@ function ReadyToGoProgressBlock() {
1484
1490
  /* @__PURE__ */ jsx3(SkeletonRow, {})
1485
1491
  ] }) : null,
1486
1492
  runtime.phase === "error" ? /* @__PURE__ */ jsx3("p", { style: { margin: 0, color: "#b42318" }, children: "Shipment progress is temporarily unavailable." }) : null,
1487
- runtime.phase === "success" && result ? /* @__PURE__ */ jsx3(ProgressResult, { result }) : null
1493
+ runtime.phase === "success" && result ? /* @__PURE__ */ jsx3(ProgressResult, { result, color: text(props, "progressColor") }) : null
1488
1494
  ] }) });
1489
1495
  }
1490
1496
  function ReadyToGoDeliveryBlock(props) {
@@ -1566,10 +1572,12 @@ var readyToGoBlocks = withTemplatePolicy([
1566
1572
  label: "Shipment progress",
1567
1573
  category: "BestTrack Ready-to-go",
1568
1574
  targets: ["web"],
1569
- defaultProps: {},
1575
+ defaultProps: { progressColor: "#0f172a" },
1570
1576
  defaultVariant: "default",
1571
1577
  variants: [{ id: "default", label: "Default" }],
1572
- fields: {},
1578
+ fields: {
1579
+ progressColor: { field: "besttrack.ready-to-go.text", label: "Progress color", control: "color", group: "Style" }
1580
+ },
1573
1581
  render: { web: ReadyToGoProgressBlock, editor: ReadyToGoProgressEditor }
1574
1582
  },
1575
1583
  {
@@ -69,7 +69,7 @@ function validateFeaturedProduct(props) {
69
69
  }
70
70
  var readyToGoContracts = [
71
71
  block("besttrack.ready-to-go.query", 1, ["heading", "submitLabel", "submitButtonColor", "defaultTrackingNumber", "defaultOrderNumber", "defaultQueryMode", "trackingTabLabel", "orderTabLabel"], ["default"]),
72
- block("besttrack.ready-to-go.progress", 1, [], ["default"]),
72
+ block("besttrack.ready-to-go.progress", 1, ["progressColor"], ["default"]),
73
73
  block("besttrack.ready-to-go.delivery", 1, ["heading", "contentsHeading", "carrierHeading"], ["default", "compact"]),
74
74
  block("besttrack.ready-to-go.recommendations", 1, ["heading", "products"], ["default", "grid"], void 0, [], [], ["products"])
75
75
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@standhigher/besttrack-page-extension",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "BestTrack business extension entry point for @standhigher/puck-page-builder.",
5
5
  "type": "module",
6
6
  "files": [
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "embla-carousel-autoplay": "^8.6.0",
24
24
  "embla-carousel-react": "^8.6.0",
25
- "@standhigher/puck-page-builder": "0.12.2"
25
+ "@standhigher/puck-page-builder": "0.12.3"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsup": "^8.5.1",