@standhigher/besttrack-page-extension 0.5.5 → 0.5.7
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 +28 -21
- package/dist/validation.js +1 -1
- package/package.json +2 -2
- package/dist/{chunk-KD7KFFFK.js → chunk-KEW42Y26.js} +28 -28
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
isValidTrackingNumber,
|
|
12
12
|
resolveShopifyResources,
|
|
13
13
|
safeTrackingPageUrl
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-KEW42Y26.js";
|
|
15
15
|
|
|
16
16
|
// src/ready-to-go.tsx
|
|
17
17
|
import { createContext, useCallback as useCallback2, useContext, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
@@ -910,12 +910,15 @@ var contentWidth = {
|
|
|
910
910
|
boxSizing: "border-box"
|
|
911
911
|
};
|
|
912
912
|
var trackingProgressStyles = `
|
|
913
|
+
.bt-progress-band { container-type: inline-size; }
|
|
914
|
+
.bt-edd-card { --bt-progress-icon: 44px; }
|
|
913
915
|
.bt-progress { container-type: inline-size; }
|
|
914
916
|
.bt-progress__icon { width: 44px; height: 44px; }
|
|
915
917
|
.bt-progress__line { top: 19px; }
|
|
916
918
|
.bt-progress__copy { margin-top: 16px; }
|
|
917
919
|
.bt-progress__label { font-size: 16px; line-height: 20px; }
|
|
918
920
|
@container (max-width: 640px) {
|
|
921
|
+
.bt-edd-card { --bt-progress-icon: 32px; }
|
|
919
922
|
.bt-progress__icon { width: 32px; height: 32px; }
|
|
920
923
|
.bt-progress__line { top: 13px; }
|
|
921
924
|
.bt-progress__copy { margin-top: 8px; }
|
|
@@ -1051,6 +1054,10 @@ function PackageContents({ items }) {
|
|
|
1051
1054
|
] }, item.id);
|
|
1052
1055
|
}) });
|
|
1053
1056
|
}
|
|
1057
|
+
function formatTrackPageRecommendPrice(price) {
|
|
1058
|
+
if (!price || !Number.isInteger(price.amount)) return "";
|
|
1059
|
+
return `$ ${(price.amount / 100).toFixed(2)}`;
|
|
1060
|
+
}
|
|
1054
1061
|
function RecommendationCards({ items }) {
|
|
1055
1062
|
const autoplay = useMemo(() => Autoplay({ delay: 3e3, stopOnInteraction: false, stopOnMouseEnter: true }), []);
|
|
1056
1063
|
const [emblaRef, emblaApi] = useEmblaCarousel({ loop: true, align: "start", slidesToScroll: 1 }, [autoplay]);
|
|
@@ -1104,11 +1111,12 @@ function RecommendationCards({ items }) {
|
|
|
1104
1111
|
!hideButtons && canScrollPrev ? /* @__PURE__ */ jsx("button", { type: "button", "aria-label": "Previous", onClick: () => emblaApi?.scrollPrev(), style: { ...buttonStyle, left: -40 }, children: arrow("15 18 9 12 15 6") }) : null,
|
|
1105
1112
|
/* @__PURE__ */ jsx("div", { ref: emblaRef, style: { overflow: "hidden" }, children: /* @__PURE__ */ jsx("div", { style: { display: "flex" }, children: items.map((item) => {
|
|
1106
1113
|
const href = safeHref(item.href);
|
|
1114
|
+
const displayPrice = formatTrackPageRecommendPrice(item.price);
|
|
1107
1115
|
const card = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1108
1116
|
/* @__PURE__ */ jsx("div", { style: { width: 262, height: 262, maxWidth: "100%", borderRadius: 8, border: "1px solid #E3E3E3", overflow: "hidden", background: "#f1f5f9" }, children: /* @__PURE__ */ jsx(ProductImage, { src: item.imageUrl, alt: item.title, size: 262 }) }),
|
|
1109
1117
|
/* @__PURE__ */ jsxs("div", { style: { padding: "12px 8px", textAlign: "center", fontSize: 14 }, children: [
|
|
1110
1118
|
/* @__PURE__ */ jsx("p", { style: { margin: 0, color: "#334155" }, children: item.title }),
|
|
1111
|
-
|
|
1119
|
+
displayPrice ? /* @__PURE__ */ jsx("p", { style: { margin: "4px 0 0", fontWeight: 600, color: "#0f172a" }, children: displayPrice }) : null,
|
|
1112
1120
|
item.description ? /* @__PURE__ */ jsx("p", { style: { margin: "4px 0 0", color: "#64748b", fontSize: 13 }, children: item.description }) : null
|
|
1113
1121
|
] })
|
|
1114
1122
|
] });
|
|
@@ -1145,8 +1153,9 @@ function TrackingPageAdSlot({ ad, disableLink = false }) {
|
|
|
1145
1153
|
if (!href || disableLink) return /* @__PURE__ */ jsx("div", { "data-tracking-page-ad": true, style: trackingPageAdSlotStyle, children: content });
|
|
1146
1154
|
return /* @__PURE__ */ jsx("a", { "data-tracking-page-ad": true, href, target: "_blank", rel: "noopener noreferrer", style: trackingPageAdSlotStyle, children: content });
|
|
1147
1155
|
}
|
|
1148
|
-
function EstimatedDeliveryCard({ dateText }) {
|
|
1149
|
-
|
|
1156
|
+
function EstimatedDeliveryCard({ dateText, steps = 5 }) {
|
|
1157
|
+
const trackInset = `max(0px, calc(50% / ${Math.max(steps, 1)} - var(--bt-progress-icon, 44px) / 2))`;
|
|
1158
|
+
return /* @__PURE__ */ jsxs("div", { "aria-label": "Est. Delivery", className: "bt-edd-card", style: { margin: `16px ${trackInset} 0`, width: "auto", boxSizing: "border-box", border: "1px solid transparent", borderRadius: 10, backgroundColor: "#eaf4ff", padding: "20px 22px 18px", textAlign: "left" }, children: [
|
|
1150
1159
|
/* @__PURE__ */ jsx("p", { style: { margin: 0, color: "#202124", fontSize: 13, fontWeight: 700, lineHeight: 1.3 }, children: "Est. Delivery" }),
|
|
1151
1160
|
/* @__PURE__ */ jsx("p", { style: { margin: "6px 0 0", color: "#202124", fontSize: 22, fontWeight: 700, lineHeight: 1.15, letterSpacing: 0, overflowWrap: "anywhere", wordBreak: "break-word" }, children: dateText }),
|
|
1152
1161
|
/* @__PURE__ */ jsx("p", { style: { margin: "6px 0 0", color: "#5f6368", fontSize: 13, fontWeight: 400, lineHeight: 1.35 }, children: "Estimated time may update as tracking progresses." })
|
|
@@ -1449,8 +1458,10 @@ function ProgressResult({ result, showEstimatedDelivery = true, color }) {
|
|
|
1449
1458
|
result.trackingNumber
|
|
1450
1459
|
] }),
|
|
1451
1460
|
/* @__PURE__ */ jsx4("h2", { style: { margin: "clamp(24px, 8%, 48px) 0 0", fontSize: 32, lineHeight: 1.25, fontWeight: 700, color: "#303030", overflowWrap: "anywhere" }, children: result.status }),
|
|
1452
|
-
|
|
1453
|
-
|
|
1461
|
+
/* @__PURE__ */ jsxs4("div", { className: "bt-progress-band", children: [
|
|
1462
|
+
showEstimatedDelivery && result.estimatedDelivery ? /* @__PURE__ */ jsx4(EstimatedDeliveryCard, { dateText: result.estimatedDelivery, steps: steps.length }) : null,
|
|
1463
|
+
/* @__PURE__ */ jsx4(TrackingProgress, { steps, color })
|
|
1464
|
+
] })
|
|
1454
1465
|
] });
|
|
1455
1466
|
}
|
|
1456
1467
|
function DeliveryResult({ heading, contentsHeading, carrierHeading, result, editing }) {
|
|
@@ -1475,7 +1486,6 @@ function DeliveryResult({ heading, contentsHeading, carrierHeading, result, edit
|
|
|
1475
1486
|
}
|
|
1476
1487
|
function ReadyToGoQueryEditor(block) {
|
|
1477
1488
|
return /* @__PURE__ */ jsx4("section", { "aria-label": "Ready-to-go query editor", style: editorHeroStyle, children: /* @__PURE__ */ jsxs4("div", { role: "region", "aria-label": "Ready-to-go tracking query", style: editorFormCardStyle, children: [
|
|
1478
|
-
/* @__PURE__ */ jsx4("h1", { style: { margin: "0 0 24px", textAlign: "center", fontSize: 28, lineHeight: 1.15, overflowWrap: "anywhere" }, children: /* @__PURE__ */ jsx4(InlineText, { block, name: "heading", fallback: "Track your order" }) }),
|
|
1479
1489
|
/* @__PURE__ */ jsxs4("div", { style: { display: "flex", width: "100%", borderBottom: "1px solid #cbd5e1" }, children: [
|
|
1480
1490
|
/* @__PURE__ */ jsx4("div", { style: { ...tabStyle(true), display: "flex", alignItems: "center", justifyContent: "center", cursor: "default" }, children: /* @__PURE__ */ jsx4(InlineText, { block, name: "trackingTabLabel", fallback: "Tracking Number" }) }),
|
|
1481
1491
|
/* @__PURE__ */ jsx4("div", { style: { ...tabStyle(false), display: "flex", alignItems: "center", justifyContent: "center", cursor: "default" }, children: /* @__PURE__ */ jsx4(InlineText, { block, name: "orderTabLabel", fallback: "Order Number" }) })
|
|
@@ -1544,7 +1554,6 @@ function ReadyToGoQueryBlock(props) {
|
|
|
1544
1554
|
const [localError, setLocalError] = useState2("");
|
|
1545
1555
|
const autoQueryStarted = useRef(false);
|
|
1546
1556
|
const previewDemoTrackingNumber = useRef(trackingNumber);
|
|
1547
|
-
const heading = text(props, "heading");
|
|
1548
1557
|
const submitLabel = text(props, "submitLabel", "Track Your Order");
|
|
1549
1558
|
const trackingTabLabel = text(props, "trackingTabLabel", "Tracking Number");
|
|
1550
1559
|
const orderTabLabel = text(props, "orderTabLabel", "Order Number");
|
|
@@ -1582,7 +1591,6 @@ function ReadyToGoQueryBlock(props) {
|
|
|
1582
1591
|
};
|
|
1583
1592
|
const loading = runtime.phase === "loading";
|
|
1584
1593
|
return /* @__PURE__ */ jsx4("section", { style: heroStyle, children: /* @__PURE__ */ jsxs4("div", { role: "region", "aria-label": "Ready-to-go tracking query", style: formCardStyle, children: [
|
|
1585
|
-
heading ? /* @__PURE__ */ jsx4("h1", { style: { margin: "0 0 24px", textAlign: "center", fontSize: 28, lineHeight: 1.15, overflowWrap: "anywhere" }, children: heading }) : null,
|
|
1586
1594
|
/* @__PURE__ */ jsxs4("div", { role: "tablist", "aria-label": "Tracking method", style: { display: "flex", width: "100%", borderBottom: "1px solid #cbd5e1" }, children: [
|
|
1587
1595
|
/* @__PURE__ */ jsx4("button", { type: "button", role: "tab", "aria-selected": mode === "tracking", onClick: () => {
|
|
1588
1596
|
setMode("tracking");
|
|
@@ -1672,7 +1680,7 @@ var readyToGoBlocks = withTemplatePolicy([
|
|
|
1672
1680
|
category: "BestTrack Ready-to-go",
|
|
1673
1681
|
targets: ["web"],
|
|
1674
1682
|
defaultProps: {
|
|
1675
|
-
heading: "
|
|
1683
|
+
heading: "",
|
|
1676
1684
|
submitLabel: "Track Your Order",
|
|
1677
1685
|
submitButtonColor: "#111111",
|
|
1678
1686
|
defaultTrackingNumber: "BT-2048-DEMO",
|
|
@@ -1684,14 +1692,13 @@ var readyToGoBlocks = withTemplatePolicy([
|
|
|
1684
1692
|
defaultVariant: "default",
|
|
1685
1693
|
variants: [{ id: "default", label: "Default" }],
|
|
1686
1694
|
fields: {
|
|
1687
|
-
|
|
1688
|
-
submitLabel: text2("Button label"),
|
|
1695
|
+
submitLabel: text2("Button label", { validation: { maxLength: 52 } }),
|
|
1689
1696
|
submitButtonColor: { field: "besttrack.ready-to-go.text", label: "Button color", control: "color", group: "Style" },
|
|
1690
|
-
defaultTrackingNumber: text2("Default tracking number"),
|
|
1697
|
+
defaultTrackingNumber: text2("Default tracking number", { validation: { maxLength: 52 } }),
|
|
1691
1698
|
defaultOrderNumber: text2("Default order number"),
|
|
1692
1699
|
defaultQueryMode: text2("Default query mode"),
|
|
1693
|
-
trackingTabLabel: text2("Tracking tab label"),
|
|
1694
|
-
orderTabLabel: text2("Order tab label")
|
|
1700
|
+
trackingTabLabel: text2("Tracking tab label", { validation: { maxLength: 52 } }),
|
|
1701
|
+
orderTabLabel: text2("Order tab label", { validation: { maxLength: 52 } })
|
|
1695
1702
|
},
|
|
1696
1703
|
render: { web: ReadyToGoQueryBlock, editor: ReadyToGoQueryEditor }
|
|
1697
1704
|
},
|
|
@@ -1719,9 +1726,9 @@ var readyToGoBlocks = withTemplatePolicy([
|
|
|
1719
1726
|
defaultVariant: "default",
|
|
1720
1727
|
variants: [{ id: "default", label: "Default" }, { id: "compact", label: "Compact", theme: { spacing: "12px" } }],
|
|
1721
1728
|
fields: {
|
|
1722
|
-
heading: text2("Heading"),
|
|
1723
|
-
contentsHeading: text2("Package contents heading"),
|
|
1724
|
-
carrierHeading: text2("Carrier heading"),
|
|
1729
|
+
heading: text2("Heading", { validation: { maxLength: 52 } }),
|
|
1730
|
+
contentsHeading: text2("Package contents heading", { validation: { maxLength: 52 } }),
|
|
1731
|
+
carrierHeading: text2("Carrier heading", { validation: { maxLength: 52 } }),
|
|
1725
1732
|
adImageUrl: { field: "besttrack.ready-to-go.asset", label: "Advertisement image", control: "asset", persist: false, group: "Advertisement" },
|
|
1726
1733
|
adLinkUrl: { field: "besttrack.ready-to-go.url", label: "Advertisement link", control: "url", persist: false, group: "Advertisement", validation: { allowRelativeUrl: true, allowedUrlProtocols: ["https:", "http:"] } }
|
|
1727
1734
|
},
|
|
@@ -1737,17 +1744,17 @@ var readyToGoBlocks = withTemplatePolicy([
|
|
|
1737
1744
|
defaultVariant: "default",
|
|
1738
1745
|
variants: [{ id: "default", label: "Default" }, { id: "grid", label: "Grid", theme: { "color.surface": "#ffffff" } }],
|
|
1739
1746
|
fields: {
|
|
1740
|
-
heading: text2("Heading"),
|
|
1747
|
+
heading: text2("Heading", { validation: { maxLength: 100 } }),
|
|
1741
1748
|
products: { field: "besttrack.ready-to-go.products", label: "\u63A8\u8350\u5546\u54C1 (Shopify)", control: "products", group: "Content" }
|
|
1742
1749
|
},
|
|
1743
1750
|
render: { web: ReadyToGoRecommendationsBlock, editor: ReadyToGoRecommendationsEditor }
|
|
1744
1751
|
}
|
|
1745
|
-
], ["besttrack.ready-to-go.query"]);
|
|
1752
|
+
], ["besttrack.ready-to-go.query", "besttrack.ready-to-go.progress", "besttrack.ready-to-go.delivery"]);
|
|
1746
1753
|
var readyToGoTemplatePolicy = defineTemplatePolicy(
|
|
1747
1754
|
"besttrack.ready-to-go",
|
|
1748
1755
|
"Ready-to-go",
|
|
1749
1756
|
readyToGoBlocks.map((block) => block.type),
|
|
1750
|
-
["besttrack.ready-to-go.query"]
|
|
1757
|
+
["besttrack.ready-to-go.query", "besttrack.ready-to-go.progress", "besttrack.ready-to-go.delivery"]
|
|
1751
1758
|
);
|
|
1752
1759
|
function createReadyToGoTemplate() {
|
|
1753
1760
|
return {
|
package/dist/validation.js
CHANGED
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.7",
|
|
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.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.5.1",
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
// src/tracking-page-url.ts
|
|
2
|
+
function hasControlCharacter(value) {
|
|
3
|
+
return [...value].some((character) => character.charCodeAt(0) < 32);
|
|
4
|
+
}
|
|
5
|
+
function isLocalDevelopmentHost(hostname) {
|
|
6
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
7
|
+
}
|
|
8
|
+
function allowsLocalhostByDefault() {
|
|
9
|
+
return typeof window !== "undefined" && isLocalDevelopmentHost(window.location.hostname);
|
|
10
|
+
}
|
|
11
|
+
function safeTrackingPageUrl(value, options = {}) {
|
|
12
|
+
if (typeof value !== "string" || !value || value.trim() !== value || hasControlCharacter(value)) return void 0;
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(value);
|
|
15
|
+
if (url.username || url.password) return void 0;
|
|
16
|
+
if (url.protocol === "https:" && !isLocalDevelopmentHost(url.hostname)) return url.toString();
|
|
17
|
+
if (url.protocol === "http:" && isLocalDevelopmentHost(url.hostname) && (options.allowLocalhost ?? allowsLocalhostByDefault())) return url.toString();
|
|
18
|
+
return void 0;
|
|
19
|
+
} catch {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function isSafeTrackingPageUrl(value, options) {
|
|
24
|
+
return safeTrackingPageUrl(value, options) !== void 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
1
27
|
// src/tracking-page-runtime.ts
|
|
2
28
|
function isValidTrackingNumber(value) {
|
|
3
29
|
return /^[A-Za-z0-9_-]{6,64}$/.test(value);
|
|
@@ -27,32 +53,6 @@ function formatTrackingPageMoney(value, locale = "en-US") {
|
|
|
27
53
|
}
|
|
28
54
|
}
|
|
29
55
|
|
|
30
|
-
// src/tracking-page-url.ts
|
|
31
|
-
function hasControlCharacter(value) {
|
|
32
|
-
return [...value].some((character) => character.charCodeAt(0) < 32);
|
|
33
|
-
}
|
|
34
|
-
function isLocalDevelopmentHost(hostname) {
|
|
35
|
-
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
36
|
-
}
|
|
37
|
-
function allowsLocalhostByDefault() {
|
|
38
|
-
return typeof window !== "undefined" && isLocalDevelopmentHost(window.location.hostname);
|
|
39
|
-
}
|
|
40
|
-
function safeTrackingPageUrl(value, options = {}) {
|
|
41
|
-
if (typeof value !== "string" || !value || value.trim() !== value || hasControlCharacter(value)) return void 0;
|
|
42
|
-
try {
|
|
43
|
-
const url = new URL(value);
|
|
44
|
-
if (url.username || url.password) return void 0;
|
|
45
|
-
if (url.protocol === "https:" && !isLocalDevelopmentHost(url.hostname)) return url.toString();
|
|
46
|
-
if (url.protocol === "http:" && isLocalDevelopmentHost(url.hostname) && (options.allowLocalhost ?? allowsLocalhostByDefault())) return url.toString();
|
|
47
|
-
return void 0;
|
|
48
|
-
} catch {
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function isSafeTrackingPageUrl(value, options) {
|
|
53
|
-
return safeTrackingPageUrl(value, options) !== void 0;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
56
|
// src/shopify-resource-contract.ts
|
|
57
57
|
var resourcePattern = /^gid:\/\/shopify\/(Product|Collection)\/[1-9]\d*$/;
|
|
58
58
|
function isShopifyResourceReference(value, kind) {
|
|
@@ -112,14 +112,14 @@ function getShopifyResourceResolutionError(reference, resolution) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export {
|
|
115
|
+
safeTrackingPageUrl,
|
|
116
|
+
isSafeTrackingPageUrl,
|
|
115
117
|
isValidTrackingNumber,
|
|
116
118
|
isValidOrderNumber,
|
|
117
119
|
isValidOrderEmail,
|
|
118
120
|
isEmptyTrackingPageResult,
|
|
119
121
|
isTrackingPageResourceReference,
|
|
120
122
|
formatTrackingPageMoney,
|
|
121
|
-
safeTrackingPageUrl,
|
|
122
|
-
isSafeTrackingPageUrl,
|
|
123
123
|
isShopifyResourceReference,
|
|
124
124
|
resolveShopifyResources,
|
|
125
125
|
getResolvedShopifyResource,
|