@nok-integration/storefront-react 0.18.1 → 0.18.2
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 +8 -3
- package/dist/index.mjs +53 -5
- package/dist/standalone/storefront.mjs +53 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3580,9 +3580,14 @@ export declare interface OrderConfirmationViewProps {
|
|
|
3580
3580
|
/**
|
|
3581
3581
|
* The frame's "Done". Omit it and no button renders.
|
|
3582
3582
|
*
|
|
3583
|
-
*
|
|
3584
|
-
*
|
|
3585
|
-
*
|
|
3583
|
+
* **It leaves the shop.** DAZN settled this on 21 Aug 2026: "Done = DAZN home, X = DAZN
|
|
3584
|
+
* Shop home". The two are not the same destination and wiring both to the shop home —
|
|
3585
|
+
* which is what the first integration did — loses the only way out of the shop at the
|
|
3586
|
+
* end of a purchase.
|
|
3587
|
+
*
|
|
3588
|
+
* We cannot make that trip ourselves: the DAZN app's own home is not a route on our
|
|
3589
|
+
* `/v1` surface and not something a `navigate('/')` can reach. So this stays the host's
|
|
3590
|
+
* callback, and the header's `onClose` is the one that goes to the shop home.
|
|
3586
3591
|
*/
|
|
3587
3592
|
onDone?: () => void;
|
|
3588
3593
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useContext, useEffect, useState, useRef, useCallback, useMemo, createContext, forwardRef } from "react";
|
|
4
4
|
var client = {};
|
|
5
5
|
var catalog = {};
|
|
6
6
|
var zod = {};
|
|
@@ -5542,6 +5542,38 @@ function withAuthorization(init, token) {
|
|
|
5542
5542
|
headers.set("authorization", `Bearer ${token}`);
|
|
5543
5543
|
return { ...init, headers };
|
|
5544
5544
|
}
|
|
5545
|
+
const ScreenTitleContext = createContext({ title: void 0, claim: () => () => {
|
|
5546
|
+
} });
|
|
5547
|
+
const SuppressedContext = createContext(false);
|
|
5548
|
+
function ScreenTitleProvider({ children }) {
|
|
5549
|
+
const [title2, setTitle] = useState(void 0);
|
|
5550
|
+
const held = useRef(void 0);
|
|
5551
|
+
const claim = useCallback((next) => {
|
|
5552
|
+
held.current = next;
|
|
5553
|
+
setTitle(next);
|
|
5554
|
+
return () => {
|
|
5555
|
+
if (held.current !== next) return;
|
|
5556
|
+
held.current = void 0;
|
|
5557
|
+
setTitle(void 0);
|
|
5558
|
+
};
|
|
5559
|
+
}, []);
|
|
5560
|
+
const value2 = useMemo(() => ({ title: title2, claim }), [title2, claim]);
|
|
5561
|
+
return /* @__PURE__ */ jsx(ScreenTitleContext.Provider, { value: value2, children });
|
|
5562
|
+
}
|
|
5563
|
+
function useScreenTitle() {
|
|
5564
|
+
return useContext(ScreenTitleContext).title;
|
|
5565
|
+
}
|
|
5566
|
+
function useSetScreenTitle(title2) {
|
|
5567
|
+
const { claim } = useContext(ScreenTitleContext);
|
|
5568
|
+
const suppressed = useContext(SuppressedContext);
|
|
5569
|
+
useEffect(() => {
|
|
5570
|
+
if (suppressed || title2 === void 0) return;
|
|
5571
|
+
return claim(title2);
|
|
5572
|
+
}, [claim, title2, suppressed]);
|
|
5573
|
+
}
|
|
5574
|
+
function NoScreenTitle({ children }) {
|
|
5575
|
+
return /* @__PURE__ */ jsx(SuppressedContext.Provider, { value: true, children });
|
|
5576
|
+
}
|
|
5545
5577
|
const ShopContext = createContext(null);
|
|
5546
5578
|
function DaznShopProvider({
|
|
5547
5579
|
children,
|
|
@@ -5631,7 +5663,7 @@ function DaznShopProvider({
|
|
|
5631
5663
|
}),
|
|
5632
5664
|
[api, market, theme, notifications, locale, assetBaseUrl, emit, subscribe, navigate]
|
|
5633
5665
|
);
|
|
5634
|
-
return /* @__PURE__ */ jsx(ShopContext.Provider, { value: value2, children });
|
|
5666
|
+
return /* @__PURE__ */ jsx(ShopContext.Provider, { value: value2, children: /* @__PURE__ */ jsx(ScreenTitleProvider, { children }) });
|
|
5635
5667
|
}
|
|
5636
5668
|
function useShopOptional() {
|
|
5637
5669
|
return useContext(ShopContext);
|
|
@@ -7542,6 +7574,19 @@ const styles$w = {
|
|
|
7542
7574
|
function OrderConfirmationView(props) {
|
|
7543
7575
|
return /* @__PURE__ */ jsx(ShopSurface, { tone: "light", fill: true, children: /* @__PURE__ */ jsx(OrderConfirmationContent, { ...props }) });
|
|
7544
7576
|
}
|
|
7577
|
+
const CONFIRMATION_LABELS = {
|
|
7578
|
+
packing: "Order placed",
|
|
7579
|
+
on_its_way: "On the way"
|
|
7580
|
+
};
|
|
7581
|
+
function confirmationProgress(progress2) {
|
|
7582
|
+
return progress2.map((entry) => {
|
|
7583
|
+
if (entry.step === "delivered" && !entry.at) {
|
|
7584
|
+
return { ...entry, label: "Estimated delivery" };
|
|
7585
|
+
}
|
|
7586
|
+
const relabelled = CONFIRMATION_LABELS[entry.step];
|
|
7587
|
+
return relabelled ? { ...entry, label: relabelled } : { ...entry };
|
|
7588
|
+
});
|
|
7589
|
+
}
|
|
7545
7590
|
function OrderConfirmationContent({ orderRef, locale: localeProp, onDone }) {
|
|
7546
7591
|
const { api } = useShop();
|
|
7547
7592
|
const locale = useLocale(localeProp);
|
|
@@ -7581,7 +7626,7 @@ function OrderConfirmationContent({ orderRef, locale: localeProp, onDone }) {
|
|
|
7581
7626
|
/* @__PURE__ */ jsx(
|
|
7582
7627
|
OrderTimeline,
|
|
7583
7628
|
{
|
|
7584
|
-
progress: order.progress,
|
|
7629
|
+
progress: confirmationProgress(order.progress),
|
|
7585
7630
|
...order.estimated_delivery ? { estimatedDelivery: order.estimated_delivery } : {},
|
|
7586
7631
|
locale
|
|
7587
7632
|
}
|
|
@@ -8454,6 +8499,7 @@ const styles$j = {
|
|
|
8454
8499
|
lines
|
|
8455
8500
|
};
|
|
8456
8501
|
function CartView(props = {}) {
|
|
8502
|
+
useSetScreenTitle("Cart");
|
|
8457
8503
|
return /* @__PURE__ */ jsx(ShopSurface, { tone: "light", fill: true, className: styles$j.surface, children: /* @__PURE__ */ jsx(CartViewContent, { ...props }) });
|
|
8458
8504
|
}
|
|
8459
8505
|
function CartViewContent({
|
|
@@ -8644,7 +8690,7 @@ function CartSheetProvider({ children }) {
|
|
|
8644
8690
|
const api = useMemo(() => ({ open, close: close2, isOpen }), [open, close2, isOpen]);
|
|
8645
8691
|
return /* @__PURE__ */ jsxs(CartSheetContext.Provider, { value: api, children: [
|
|
8646
8692
|
children,
|
|
8647
|
-
isOpen && /* @__PURE__ */ jsx(BottomSheet, { open: true, onClose: close2, title: "Cart", children: /* @__PURE__ */ jsx(CartView, { onContinueShopping: close2 }) })
|
|
8693
|
+
isOpen && /* @__PURE__ */ jsx(BottomSheet, { open: true, onClose: close2, title: "Cart", children: /* @__PURE__ */ jsx(NoScreenTitle, { children: /* @__PURE__ */ jsx(CartView, { onContinueShopping: close2 }) }) })
|
|
8648
8694
|
] });
|
|
8649
8695
|
}
|
|
8650
8696
|
const gallery = "_gallery_10mch_1";
|
|
@@ -10124,6 +10170,8 @@ function ShopBar({
|
|
|
10124
10170
|
className
|
|
10125
10171
|
}) {
|
|
10126
10172
|
const cartCount = useCartCount();
|
|
10173
|
+
const screenTitle = useScreenTitle();
|
|
10174
|
+
const shownTitle = title2 ?? screenTitle;
|
|
10127
10175
|
const atTop = useScrolledUnder(floating2 && scrolled2 === void 0);
|
|
10128
10176
|
const isScrolled = scrolled2 ?? atTop;
|
|
10129
10177
|
const cartLabel = cartCount === null ? "Cart" : cartCount === 0 ? "Cart, empty" : `Cart, ${cartCount} item${cartCount === 1 ? "" : "s"}`;
|
|
@@ -10135,7 +10183,7 @@ function ShopBar({
|
|
|
10135
10183
|
].filter(Boolean).join(" ");
|
|
10136
10184
|
return /* @__PURE__ */ jsxs("header", { className: classes, children: [
|
|
10137
10185
|
onBack ? /* @__PURE__ */ jsx("button", { type: "button", className: styles$1.iconBtn, "aria-label": backLabel, onClick: onBack, children: /* @__PURE__ */ jsx(ChevronLeft, {}) }) : /* @__PURE__ */ jsx("span", { className: styles$1.spacer, "aria-hidden": "true" }),
|
|
10138
|
-
|
|
10186
|
+
shownTitle ? /* @__PURE__ */ jsx("span", { className: styles$1.title, children: shownTitle }) : null,
|
|
10139
10187
|
/* @__PURE__ */ jsxs("div", { className: styles$1.right, children: [
|
|
10140
10188
|
showCart ? /* @__PURE__ */ jsxs(CartTrigger, { className: styles$1.iconBtn, "aria-label": cartLabel, children: [
|
|
10141
10189
|
/* @__PURE__ */ jsx(CartIcon, {}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useContext, useEffect, useState, useRef, useCallback, useMemo, createContext, forwardRef } from "react";
|
|
4
4
|
var client = {};
|
|
5
5
|
var catalog = {};
|
|
6
6
|
var zod = {};
|
|
@@ -5542,6 +5542,38 @@ function withAuthorization(init, token) {
|
|
|
5542
5542
|
headers.set("authorization", `Bearer ${token}`);
|
|
5543
5543
|
return { ...init, headers };
|
|
5544
5544
|
}
|
|
5545
|
+
const ScreenTitleContext = createContext({ title: void 0, claim: () => () => {
|
|
5546
|
+
} });
|
|
5547
|
+
const SuppressedContext = createContext(false);
|
|
5548
|
+
function ScreenTitleProvider({ children }) {
|
|
5549
|
+
const [title2, setTitle] = useState(void 0);
|
|
5550
|
+
const held = useRef(void 0);
|
|
5551
|
+
const claim = useCallback((next) => {
|
|
5552
|
+
held.current = next;
|
|
5553
|
+
setTitle(next);
|
|
5554
|
+
return () => {
|
|
5555
|
+
if (held.current !== next) return;
|
|
5556
|
+
held.current = void 0;
|
|
5557
|
+
setTitle(void 0);
|
|
5558
|
+
};
|
|
5559
|
+
}, []);
|
|
5560
|
+
const value2 = useMemo(() => ({ title: title2, claim }), [title2, claim]);
|
|
5561
|
+
return /* @__PURE__ */ jsx(ScreenTitleContext.Provider, { value: value2, children });
|
|
5562
|
+
}
|
|
5563
|
+
function useScreenTitle() {
|
|
5564
|
+
return useContext(ScreenTitleContext).title;
|
|
5565
|
+
}
|
|
5566
|
+
function useSetScreenTitle(title2) {
|
|
5567
|
+
const { claim } = useContext(ScreenTitleContext);
|
|
5568
|
+
const suppressed = useContext(SuppressedContext);
|
|
5569
|
+
useEffect(() => {
|
|
5570
|
+
if (suppressed || title2 === void 0) return;
|
|
5571
|
+
return claim(title2);
|
|
5572
|
+
}, [claim, title2, suppressed]);
|
|
5573
|
+
}
|
|
5574
|
+
function NoScreenTitle({ children }) {
|
|
5575
|
+
return /* @__PURE__ */ jsx(SuppressedContext.Provider, { value: true, children });
|
|
5576
|
+
}
|
|
5545
5577
|
const ShopContext = createContext(null);
|
|
5546
5578
|
function DaznShopProvider({
|
|
5547
5579
|
children,
|
|
@@ -5631,7 +5663,7 @@ function DaznShopProvider({
|
|
|
5631
5663
|
}),
|
|
5632
5664
|
[api, market, theme, notifications, locale, assetBaseUrl, emit, subscribe, navigate]
|
|
5633
5665
|
);
|
|
5634
|
-
return /* @__PURE__ */ jsx(ShopContext.Provider, { value: value2, children });
|
|
5666
|
+
return /* @__PURE__ */ jsx(ShopContext.Provider, { value: value2, children: /* @__PURE__ */ jsx(ScreenTitleProvider, { children }) });
|
|
5635
5667
|
}
|
|
5636
5668
|
function useShopOptional() {
|
|
5637
5669
|
return useContext(ShopContext);
|
|
@@ -7542,6 +7574,19 @@ const styles$w = {
|
|
|
7542
7574
|
function OrderConfirmationView(props) {
|
|
7543
7575
|
return /* @__PURE__ */ jsx(ShopSurface, { tone: "light", fill: true, children: /* @__PURE__ */ jsx(OrderConfirmationContent, { ...props }) });
|
|
7544
7576
|
}
|
|
7577
|
+
const CONFIRMATION_LABELS = {
|
|
7578
|
+
packing: "Order placed",
|
|
7579
|
+
on_its_way: "On the way"
|
|
7580
|
+
};
|
|
7581
|
+
function confirmationProgress(progress2) {
|
|
7582
|
+
return progress2.map((entry) => {
|
|
7583
|
+
if (entry.step === "delivered" && !entry.at) {
|
|
7584
|
+
return { ...entry, label: "Estimated delivery" };
|
|
7585
|
+
}
|
|
7586
|
+
const relabelled = CONFIRMATION_LABELS[entry.step];
|
|
7587
|
+
return relabelled ? { ...entry, label: relabelled } : { ...entry };
|
|
7588
|
+
});
|
|
7589
|
+
}
|
|
7545
7590
|
function OrderConfirmationContent({ orderRef, locale: localeProp, onDone }) {
|
|
7546
7591
|
const { api } = useShop();
|
|
7547
7592
|
const locale = useLocale(localeProp);
|
|
@@ -7581,7 +7626,7 @@ function OrderConfirmationContent({ orderRef, locale: localeProp, onDone }) {
|
|
|
7581
7626
|
/* @__PURE__ */ jsx(
|
|
7582
7627
|
OrderTimeline,
|
|
7583
7628
|
{
|
|
7584
|
-
progress: order.progress,
|
|
7629
|
+
progress: confirmationProgress(order.progress),
|
|
7585
7630
|
...order.estimated_delivery ? { estimatedDelivery: order.estimated_delivery } : {},
|
|
7586
7631
|
locale
|
|
7587
7632
|
}
|
|
@@ -8454,6 +8499,7 @@ const styles$j = {
|
|
|
8454
8499
|
lines
|
|
8455
8500
|
};
|
|
8456
8501
|
function CartView(props = {}) {
|
|
8502
|
+
useSetScreenTitle("Cart");
|
|
8457
8503
|
return /* @__PURE__ */ jsx(ShopSurface, { tone: "light", fill: true, className: styles$j.surface, children: /* @__PURE__ */ jsx(CartViewContent, { ...props }) });
|
|
8458
8504
|
}
|
|
8459
8505
|
function CartViewContent({
|
|
@@ -8644,7 +8690,7 @@ function CartSheetProvider({ children }) {
|
|
|
8644
8690
|
const api = useMemo(() => ({ open, close: close2, isOpen }), [open, close2, isOpen]);
|
|
8645
8691
|
return /* @__PURE__ */ jsxs(CartSheetContext.Provider, { value: api, children: [
|
|
8646
8692
|
children,
|
|
8647
|
-
isOpen && /* @__PURE__ */ jsx(BottomSheet, { open: true, onClose: close2, title: "Cart", children: /* @__PURE__ */ jsx(CartView, { onContinueShopping: close2 }) })
|
|
8693
|
+
isOpen && /* @__PURE__ */ jsx(BottomSheet, { open: true, onClose: close2, title: "Cart", children: /* @__PURE__ */ jsx(NoScreenTitle, { children: /* @__PURE__ */ jsx(CartView, { onContinueShopping: close2 }) }) })
|
|
8648
8694
|
] });
|
|
8649
8695
|
}
|
|
8650
8696
|
const gallery = "_gallery_10mch_1";
|
|
@@ -10124,6 +10170,8 @@ function ShopBar({
|
|
|
10124
10170
|
className
|
|
10125
10171
|
}) {
|
|
10126
10172
|
const cartCount = useCartCount();
|
|
10173
|
+
const screenTitle = useScreenTitle();
|
|
10174
|
+
const shownTitle = title2 ?? screenTitle;
|
|
10127
10175
|
const atTop = useScrolledUnder(floating2 && scrolled2 === void 0);
|
|
10128
10176
|
const isScrolled = scrolled2 ?? atTop;
|
|
10129
10177
|
const cartLabel = cartCount === null ? "Cart" : cartCount === 0 ? "Cart, empty" : `Cart, ${cartCount} item${cartCount === 1 ? "" : "s"}`;
|
|
@@ -10135,7 +10183,7 @@ function ShopBar({
|
|
|
10135
10183
|
].filter(Boolean).join(" ");
|
|
10136
10184
|
return /* @__PURE__ */ jsxs("header", { className: classes, children: [
|
|
10137
10185
|
onBack ? /* @__PURE__ */ jsx("button", { type: "button", className: styles$1.iconBtn, "aria-label": backLabel, onClick: onBack, children: /* @__PURE__ */ jsx(ChevronLeft, {}) }) : /* @__PURE__ */ jsx("span", { className: styles$1.spacer, "aria-hidden": "true" }),
|
|
10138
|
-
|
|
10186
|
+
shownTitle ? /* @__PURE__ */ jsx("span", { className: styles$1.title, children: shownTitle }) : null,
|
|
10139
10187
|
/* @__PURE__ */ jsxs("div", { className: styles$1.right, children: [
|
|
10140
10188
|
showCart ? /* @__PURE__ */ jsxs(CartTrigger, { className: styles$1.iconBtn, "aria-label": cartLabel, children: [
|
|
10141
10189
|
/* @__PURE__ */ jsx(CartIcon, {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nok-integration/storefront-react",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Mountable React storefront components: catalogue, product detail and cart, mounted directly into a host DOM tree. No iframe.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|