@standhigher/besttrack-page-extension 0.5.0 → 0.5.1
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.d.ts +3 -1
- package/dist/index.js +38 -17
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -314,8 +314,10 @@ type ReadyToGoRuntimeProviderProps = {
|
|
|
314
314
|
autoQueryFromUrl?: boolean;
|
|
315
315
|
/** Host-decided display state. Omitted values follow the original powered-by hide rule. */
|
|
316
316
|
watermark?: TrackingPageWatermark;
|
|
317
|
+
/** Admin-only promotion preview; live storefronts continue to use result.ad. */
|
|
318
|
+
adPreview?: TrackingPageAd | null;
|
|
317
319
|
};
|
|
318
|
-
declare function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, watermark }: ReadyToGoRuntimeProviderProps): react.JSX.Element;
|
|
320
|
+
declare function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, watermark, adPreview }: ReadyToGoRuntimeProviderProps): react.JSX.Element;
|
|
319
321
|
|
|
320
322
|
/**
|
|
321
323
|
* Compatibility metadata for template-aware hosts.
|
package/dist/index.js
CHANGED
|
@@ -968,11 +968,11 @@ function RecommendationCards({ items }) {
|
|
|
968
968
|
}, [emblaApi]);
|
|
969
969
|
useEffect(() => {
|
|
970
970
|
if (!emblaApi) return;
|
|
971
|
+
const frame = window.requestAnimationFrame(onSelect);
|
|
971
972
|
emblaApi.on("select", onSelect);
|
|
972
973
|
emblaApi.on("reInit", onSelect);
|
|
973
|
-
const frame = requestAnimationFrame(onSelect);
|
|
974
974
|
return () => {
|
|
975
|
-
cancelAnimationFrame(frame);
|
|
975
|
+
window.cancelAnimationFrame(frame);
|
|
976
976
|
emblaApi.off("select", onSelect);
|
|
977
977
|
emblaApi.off("reInit", onSelect);
|
|
978
978
|
};
|
|
@@ -981,12 +981,9 @@ function RecommendationCards({ items }) {
|
|
|
981
981
|
if (typeof window.matchMedia !== "function") return;
|
|
982
982
|
const media = window.matchMedia("(max-width: 768px)");
|
|
983
983
|
const update = () => setHideButtons(media.matches);
|
|
984
|
-
|
|
984
|
+
update();
|
|
985
985
|
media.addEventListener("change", update);
|
|
986
|
-
return () =>
|
|
987
|
-
cancelAnimationFrame(frame);
|
|
988
|
-
media.removeEventListener("change", update);
|
|
989
|
-
};
|
|
986
|
+
return () => media.removeEventListener("change", update);
|
|
990
987
|
}, []);
|
|
991
988
|
if (items.length === 0) return null;
|
|
992
989
|
const arrow = (points) => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("polyline", { points }) });
|
|
@@ -1024,14 +1021,30 @@ function RecommendationCards({ items }) {
|
|
|
1024
1021
|
!hideButtons && canScrollNext ? /* @__PURE__ */ jsx("button", { type: "button", "aria-label": "Next", onClick: () => emblaApi?.scrollNext(), style: { ...buttonStyle, right: -40 }, children: arrow("9 18 15 12 9 6") }) : null
|
|
1025
1022
|
] });
|
|
1026
1023
|
}
|
|
1027
|
-
|
|
1024
|
+
var trackingPageAdSlotStyle = {
|
|
1025
|
+
display: "block",
|
|
1026
|
+
width: "100%",
|
|
1027
|
+
maxWidth: 500,
|
|
1028
|
+
aspectRatio: "20 / 9",
|
|
1029
|
+
borderRadius: 8,
|
|
1030
|
+
overflow: "hidden",
|
|
1031
|
+
textDecoration: "none"
|
|
1032
|
+
};
|
|
1033
|
+
var trackingPageAdImageStyle = {
|
|
1034
|
+
display: "block",
|
|
1035
|
+
width: "100%",
|
|
1036
|
+
height: "100%",
|
|
1037
|
+
objectFit: "fill",
|
|
1038
|
+
objectPosition: "center"
|
|
1039
|
+
};
|
|
1040
|
+
function TrackingPageAdSlot({ ad, disableLink = false }) {
|
|
1028
1041
|
const [failedUrl, setFailedUrl] = useState();
|
|
1029
1042
|
const imageUrl = safeImageUrl(ad?.imageUrl);
|
|
1030
1043
|
if (!imageUrl || failedUrl === imageUrl) return null;
|
|
1031
|
-
const content = /* @__PURE__ */ jsx("img", { src: imageUrl, alt: ad?.alt ?? "Promotion", loading: "lazy", onError: () => setFailedUrl(imageUrl), style:
|
|
1044
|
+
const content = /* @__PURE__ */ jsx("img", { src: imageUrl, alt: ad?.alt ?? "Promotion", loading: "lazy", onError: () => setFailedUrl(imageUrl), style: trackingPageAdImageStyle });
|
|
1032
1045
|
const href = safeHref(ad?.href);
|
|
1033
|
-
if (!href) return /* @__PURE__ */ jsx("div", { "data-tracking-page-ad": true, children: content });
|
|
1034
|
-
return /* @__PURE__ */ jsx("a", { "data-tracking-page-ad": true, href, target: "_blank", rel: "noopener noreferrer", children: content });
|
|
1046
|
+
if (!href || disableLink) return /* @__PURE__ */ jsx("div", { "data-tracking-page-ad": true, style: trackingPageAdSlotStyle, children: content });
|
|
1047
|
+
return /* @__PURE__ */ jsx("a", { "data-tracking-page-ad": true, href, target: "_blank", rel: "noopener noreferrer", style: trackingPageAdSlotStyle, children: content });
|
|
1035
1048
|
}
|
|
1036
1049
|
function EstimatedDeliveryCard({ dateText }) {
|
|
1037
1050
|
return /* @__PURE__ */ jsxs("div", { "aria-label": "Est. Delivery", style: { margin: "16px auto 0", width: "100%", boxSizing: "border-box", border: "1px solid transparent", borderRadius: 10, backgroundColor: "#eaf4ff", padding: "20px 22px 18px", textAlign: "left" }, children: [
|
|
@@ -1097,7 +1110,7 @@ function previewReadyToGoTracking(trackingNumber = "BT-2048-DEMO") {
|
|
|
1097
1110
|
async function queryMockReadyToGoTracking(request) {
|
|
1098
1111
|
return previewReadyToGoTracking(request.mode === "tracking" ? request.trackingNumber : request.orderNumber);
|
|
1099
1112
|
}
|
|
1100
|
-
function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, watermark }) {
|
|
1113
|
+
function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, watermark, adPreview }) {
|
|
1101
1114
|
const [state, setState] = useState2({ phase: "idle" });
|
|
1102
1115
|
const [recommendations, setRecommendations] = useState2(() => queryRecommendations || transport ? { phase: "loading", items: [] } : { phase: "success", items: previewReadyToGoTracking().recommendations ?? [] });
|
|
1103
1116
|
const requestId = useRef(0);
|
|
@@ -1143,7 +1156,7 @@ function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecomme
|
|
|
1143
1156
|
() => watermark ?? { visible: !shouldHidePoweredBy() },
|
|
1144
1157
|
[watermark]
|
|
1145
1158
|
);
|
|
1146
|
-
const value = useMemo2(() => ({ ...state, query, recommendations, autoQueryFromUrl: resolveAutoQuery, watermark: resolvedWatermark }), [query, recommendations, resolveAutoQuery, resolvedWatermark, state]);
|
|
1159
|
+
const value = useMemo2(() => ({ ...state, adPreview, query, recommendations, autoQueryFromUrl: resolveAutoQuery, watermark: resolvedWatermark }), [adPreview, query, recommendations, resolveAutoQuery, resolvedWatermark, state]);
|
|
1147
1160
|
return /* @__PURE__ */ jsx3(ReadyToGoRuntimeContext.Provider, { value, children });
|
|
1148
1161
|
}
|
|
1149
1162
|
function useReadyToGoRuntime() {
|
|
@@ -1268,14 +1281,14 @@ function ProgressResult({ result, showEstimatedDelivery = true }) {
|
|
|
1268
1281
|
/* @__PURE__ */ jsx3(TrackingProgress, { steps })
|
|
1269
1282
|
] });
|
|
1270
1283
|
}
|
|
1271
|
-
function DeliveryResult({ heading, contentsHeading, carrierHeading, result }) {
|
|
1284
|
+
function DeliveryResult({ heading, contentsHeading, carrierHeading, result, editing }) {
|
|
1272
1285
|
return /* @__PURE__ */ jsxs3("div", { style: { ...contentWidth, display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 280px), 500px))", gap: 40, justifyContent: "center", alignItems: "start" }, children: [
|
|
1273
1286
|
/* @__PURE__ */ jsxs3("div", { children: [
|
|
1274
1287
|
/* @__PURE__ */ jsx3("h3", { style: { margin: 0, fontSize: 20, lineHeight: "20px", fontWeight: 700 }, children: heading }),
|
|
1275
1288
|
/* @__PURE__ */ jsx3(ShippingTimeline, { events: eventsFrom(result) })
|
|
1276
1289
|
] }),
|
|
1277
1290
|
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", gap: 24 }, children: [
|
|
1278
|
-
/* @__PURE__ */ jsx3(TrackingPageAdSlot, { ad: result.ad }),
|
|
1291
|
+
/* @__PURE__ */ jsx3(TrackingPageAdSlot, { ad: result.ad, disableLink: editing }),
|
|
1279
1292
|
/* @__PURE__ */ jsxs3("div", { children: [
|
|
1280
1293
|
/* @__PURE__ */ jsx3("h3", { style: { margin: "0 0 12px", fontSize: 18, fontWeight: 700 }, children: contentsHeading }),
|
|
1281
1294
|
/* @__PURE__ */ jsx3(PackageContents, { items: result.orderItems ?? [] })
|
|
@@ -1320,13 +1333,15 @@ function ReadyToGoProgressEditor() {
|
|
|
1320
1333
|
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 }) }) });
|
|
1321
1334
|
}
|
|
1322
1335
|
function ReadyToGoDeliveryEditor(block) {
|
|
1336
|
+
const { adPreview } = useReadyToGoRuntime();
|
|
1323
1337
|
return /* @__PURE__ */ jsx3("section", { "aria-label": "Ready-to-go delivery editor", style: { ...pageFont, background: "var(--pb-color-background, #fff)", color: "var(--pb-color-text, #0f172a)", borderBottom: "1px solid #f1f5f9" }, children: /* @__PURE__ */ jsx3(
|
|
1324
1338
|
DeliveryResult,
|
|
1325
1339
|
{
|
|
1326
1340
|
heading: /* @__PURE__ */ jsx3(InlineText, { block, name: "heading", fallback: "Shipping Details" }),
|
|
1327
1341
|
contentsHeading: /* @__PURE__ */ jsx3(InlineText, { block, name: "contentsHeading", fallback: "Package Contents" }),
|
|
1328
1342
|
carrierHeading: /* @__PURE__ */ jsx3(InlineText, { block, name: "carrierHeading", fallback: "Carrier" }),
|
|
1329
|
-
|
|
1343
|
+
editing: true,
|
|
1344
|
+
result: { ...previewReadyToGoTracking(), ad: adPreview ?? void 0 }
|
|
1330
1345
|
}
|
|
1331
1346
|
) });
|
|
1332
1347
|
}
|
|
@@ -1517,7 +1532,13 @@ var readyToGoBlocks = withTemplatePolicy([
|
|
|
1517
1532
|
defaultProps: { heading: "Shipping Details", contentsHeading: "Package Contents", carrierHeading: "Carrier" },
|
|
1518
1533
|
defaultVariant: "default",
|
|
1519
1534
|
variants: [{ id: "default", label: "Default" }, { id: "compact", label: "Compact", theme: { spacing: "12px" } }],
|
|
1520
|
-
fields: {
|
|
1535
|
+
fields: {
|
|
1536
|
+
heading: text2("Heading"),
|
|
1537
|
+
contentsHeading: text2("Package contents heading"),
|
|
1538
|
+
carrierHeading: text2("Carrier heading"),
|
|
1539
|
+
adImageUrl: { field: "besttrack.ready-to-go.asset", label: "Advertisement image", control: "asset", persist: false, group: "Advertisement" },
|
|
1540
|
+
adLinkUrl: { field: "besttrack.ready-to-go.url", label: "Advertisement link", control: "url", persist: false, group: "Advertisement", validation: { allowRelativeUrl: true, allowedUrlProtocols: ["https:", "http:"] } }
|
|
1541
|
+
},
|
|
1521
1542
|
render: { web: ReadyToGoDeliveryBlock, editor: ReadyToGoDeliveryEditor }
|
|
1522
1543
|
},
|
|
1523
1544
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standhigher/besttrack-page-extension",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
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.
|
|
25
|
+
"@standhigher/puck-page-builder": "0.12.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.5.1",
|