@standhigher/besttrack-page-extension 0.5.2 → 0.5.4
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 +6 -1
- package/dist/index.js +34 -17
- package/dist/validation.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -312,12 +312,17 @@ type ReadyToGoRuntimeProviderProps = {
|
|
|
312
312
|
transport?: ShopifyTrackPageTransport;
|
|
313
313
|
/** When omitted, URL deep-link auto-query is on only for the Shopify Track Page `transport` path. */
|
|
314
314
|
autoQueryFromUrl?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Preview-only: query the form's demo tracking number on mount.
|
|
317
|
+
* Live storefronts must omit this so consumers still submit the form.
|
|
318
|
+
*/
|
|
319
|
+
autoQueryDemo?: boolean;
|
|
315
320
|
/** Host-decided display state. Omitted values follow the original powered-by hide rule. */
|
|
316
321
|
watermark?: TrackingPageWatermark;
|
|
317
322
|
/** Admin-only promotion preview; live storefronts continue to use result.ad. */
|
|
318
323
|
adPreview?: TrackingPageAd | null;
|
|
319
324
|
};
|
|
320
|
-
declare function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, watermark, adPreview }: ReadyToGoRuntimeProviderProps): react.JSX.Element;
|
|
325
|
+
declare function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, autoQueryDemo, watermark, adPreview }: ReadyToGoRuntimeProviderProps): react.JSX.Element;
|
|
321
326
|
|
|
322
327
|
/**
|
|
323
328
|
* Compatibility metadata for template-aware hosts.
|
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
|
-
|
|
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 ?
|
|
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:
|
|
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
|
|
@@ -1103,6 +1109,7 @@ var initialRuntime = {
|
|
|
1103
1109
|
phase: "idle",
|
|
1104
1110
|
recommendations: { phase: "idle", items: [] },
|
|
1105
1111
|
autoQueryFromUrl: false,
|
|
1112
|
+
autoQueryDemo: false,
|
|
1106
1113
|
async query() {
|
|
1107
1114
|
return void 0;
|
|
1108
1115
|
}
|
|
@@ -1132,7 +1139,7 @@ function previewReadyToGoTracking(trackingNumber = "BT-2048-DEMO") {
|
|
|
1132
1139
|
async function queryMockReadyToGoTracking(request) {
|
|
1133
1140
|
return previewReadyToGoTracking(request.mode === "tracking" ? request.trackingNumber : request.orderNumber);
|
|
1134
1141
|
}
|
|
1135
|
-
function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, watermark, adPreview }) {
|
|
1142
|
+
function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecommendations, transport, autoQueryFromUrl, autoQueryDemo = false, watermark, adPreview }) {
|
|
1136
1143
|
const [state, setState] = useState2({ phase: "idle" });
|
|
1137
1144
|
const [recommendations, setRecommendations] = useState2(() => queryRecommendations || transport ? { phase: "loading", items: [] } : { phase: "success", items: previewReadyToGoTracking().recommendations ?? [] });
|
|
1138
1145
|
const requestId = useRef(0);
|
|
@@ -1178,7 +1185,7 @@ function ReadyToGoRuntimeProvider({ children, query: injectedQuery, queryRecomme
|
|
|
1178
1185
|
() => watermark ?? { visible: !shouldHidePoweredBy() },
|
|
1179
1186
|
[watermark]
|
|
1180
1187
|
);
|
|
1181
|
-
const value = useMemo2(() => ({ ...state, adPreview, query, recommendations, autoQueryFromUrl: resolveAutoQuery, watermark: resolvedWatermark }), [adPreview, query, recommendations, resolveAutoQuery, resolvedWatermark, state]);
|
|
1188
|
+
const value = useMemo2(() => ({ ...state, adPreview, query, recommendations, autoQueryFromUrl: resolveAutoQuery, autoQueryDemo, watermark: resolvedWatermark }), [adPreview, autoQueryDemo, query, recommendations, resolveAutoQuery, resolvedWatermark, state]);
|
|
1182
1189
|
return /* @__PURE__ */ jsx3(ReadyToGoRuntimeContext.Provider, { value, children });
|
|
1183
1190
|
}
|
|
1184
1191
|
function useReadyToGoRuntime() {
|
|
@@ -1254,12 +1261,12 @@ var inputStyle = {
|
|
|
1254
1261
|
color: "#334155",
|
|
1255
1262
|
boxSizing: "border-box"
|
|
1256
1263
|
};
|
|
1257
|
-
var
|
|
1264
|
+
var hexColor2 = /^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i;
|
|
1258
1265
|
var defaultSubmitButtonColor = "var(--pb-color-primary, #111)";
|
|
1259
1266
|
function submitButtonBackground(props, loading = false) {
|
|
1260
1267
|
if (loading) return "#475569";
|
|
1261
1268
|
const value = text(props, "submitButtonColor");
|
|
1262
|
-
return
|
|
1269
|
+
return hexColor2.test(value) ? value : defaultSubmitButtonColor;
|
|
1263
1270
|
}
|
|
1264
1271
|
function submitButtonStyle(props, loading = false) {
|
|
1265
1272
|
return {
|
|
@@ -1316,7 +1323,7 @@ function eventsFrom(result) {
|
|
|
1316
1323
|
if (result?.latestEvent) return [{ id: "latest", title: result.latestEvent, at: result.updatedAt, state: "current" }];
|
|
1317
1324
|
return [];
|
|
1318
1325
|
}
|
|
1319
|
-
function ProgressResult({ result, showEstimatedDelivery = true }) {
|
|
1326
|
+
function ProgressResult({ result, showEstimatedDelivery = true, color }) {
|
|
1320
1327
|
const steps = result.progress?.length ? result.progress : defaultProgress(result.status);
|
|
1321
1328
|
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1322
1329
|
/* @__PURE__ */ jsxs3("p", { style: { margin: 0, fontSize: 20, lineHeight: 1.4, color: "#000", overflowWrap: "anywhere" }, children: [
|
|
@@ -1325,7 +1332,7 @@ function ProgressResult({ result, showEstimatedDelivery = true }) {
|
|
|
1325
1332
|
] }),
|
|
1326
1333
|
/* @__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
1334
|
showEstimatedDelivery && result.estimatedDelivery ? /* @__PURE__ */ jsx3(EstimatedDeliveryCard, { dateText: result.estimatedDelivery }) : null,
|
|
1328
|
-
/* @__PURE__ */ jsx3(TrackingProgress, { steps })
|
|
1335
|
+
/* @__PURE__ */ jsx3(TrackingProgress, { steps, color })
|
|
1329
1336
|
] });
|
|
1330
1337
|
}
|
|
1331
1338
|
function DeliveryResult({ heading, contentsHeading, carrierHeading, result, editing }) {
|
|
@@ -1376,8 +1383,8 @@ function ReadyToGoQueryEditor(block) {
|
|
|
1376
1383
|
/* @__PURE__ */ jsx3("p", { style: { marginTop: "auto", paddingTop: 28, textAlign: "center", fontSize: 12, lineHeight: "17px", fontStyle: "italic", color: "#b8b8b8" }, children: "Powered by BestTrack" })
|
|
1377
1384
|
] }) });
|
|
1378
1385
|
}
|
|
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 }) }) });
|
|
1386
|
+
function ReadyToGoProgressEditor(block) {
|
|
1387
|
+
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
1388
|
}
|
|
1382
1389
|
function ReadyToGoDeliveryEditor(block) {
|
|
1383
1390
|
const { adPreview } = useReadyToGoRuntime();
|
|
@@ -1415,14 +1422,22 @@ function ReadyToGoQueryBlock(props) {
|
|
|
1415
1422
|
const [email, setEmail] = useState2(locationState?.email ?? "");
|
|
1416
1423
|
const [localError, setLocalError] = useState2("");
|
|
1417
1424
|
const autoQueryStarted = useRef(false);
|
|
1425
|
+
const previewDemoTrackingNumber = useRef(trackingNumber);
|
|
1418
1426
|
const heading = text(props, "heading");
|
|
1419
1427
|
const submitLabel = text(props, "submitLabel", "Track Your Order");
|
|
1420
1428
|
const trackingTabLabel = text(props, "trackingTabLabel", "Tracking Number");
|
|
1421
1429
|
const orderTabLabel = text(props, "orderTabLabel", "Order Number");
|
|
1422
1430
|
useEffect2(() => {
|
|
1423
|
-
if (
|
|
1431
|
+
if (autoQueryStarted.current) return;
|
|
1432
|
+
if (locationState?.canAutoQuery) {
|
|
1433
|
+
autoQueryStarted.current = true;
|
|
1434
|
+
void runtime.query(locationState.tab === "tracking" ? { mode: "tracking", trackingNumber: locationState.trackingNumber } : { mode: "order", orderNumber: locationState.orderNumber, email: locationState.email });
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
const demoTrackingNumber = previewDemoTrackingNumber.current.trim();
|
|
1438
|
+
if (!runtime.autoQueryDemo || !demoTrackingNumber) return;
|
|
1424
1439
|
autoQueryStarted.current = true;
|
|
1425
|
-
void runtime.query(
|
|
1440
|
+
void runtime.query({ mode: "tracking", trackingNumber: demoTrackingNumber });
|
|
1426
1441
|
}, [locationState, runtime]);
|
|
1427
1442
|
const submit = (event) => {
|
|
1428
1443
|
event.preventDefault();
|
|
@@ -1473,7 +1488,7 @@ function ReadyToGoQueryBlock(props) {
|
|
|
1473
1488
|
/* @__PURE__ */ jsx3(RuntimeWatermark, { watermark: runtime.watermark })
|
|
1474
1489
|
] }) });
|
|
1475
1490
|
}
|
|
1476
|
-
function ReadyToGoProgressBlock() {
|
|
1491
|
+
function ReadyToGoProgressBlock(props) {
|
|
1477
1492
|
const runtime = useReadyToGoRuntime();
|
|
1478
1493
|
const result = runtime.result;
|
|
1479
1494
|
if (runtime.phase === "idle") return null;
|
|
@@ -1484,7 +1499,7 @@ function ReadyToGoProgressBlock() {
|
|
|
1484
1499
|
/* @__PURE__ */ jsx3(SkeletonRow, {})
|
|
1485
1500
|
] }) : null,
|
|
1486
1501
|
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
|
|
1502
|
+
runtime.phase === "success" && result ? /* @__PURE__ */ jsx3(ProgressResult, { result, showEstimatedDelivery: !runtime.autoQueryDemo, color: text(props, "progressColor") }) : null
|
|
1488
1503
|
] }) });
|
|
1489
1504
|
}
|
|
1490
1505
|
function ReadyToGoDeliveryBlock(props) {
|
|
@@ -1566,10 +1581,12 @@ var readyToGoBlocks = withTemplatePolicy([
|
|
|
1566
1581
|
label: "Shipment progress",
|
|
1567
1582
|
category: "BestTrack Ready-to-go",
|
|
1568
1583
|
targets: ["web"],
|
|
1569
|
-
defaultProps: {},
|
|
1584
|
+
defaultProps: { progressColor: "#0f172a" },
|
|
1570
1585
|
defaultVariant: "default",
|
|
1571
1586
|
variants: [{ id: "default", label: "Default" }],
|
|
1572
|
-
fields: {
|
|
1587
|
+
fields: {
|
|
1588
|
+
progressColor: { field: "besttrack.ready-to-go.text", label: "Progress color", control: "color", group: "Style" }
|
|
1589
|
+
},
|
|
1573
1590
|
render: { web: ReadyToGoProgressBlock, editor: ReadyToGoProgressEditor }
|
|
1574
1591
|
},
|
|
1575
1592
|
{
|
package/dist/validation.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.5.4",
|
|
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.4"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.5.1",
|