@nok-integration/storefront-react 0.29.11 → 0.29.13
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 +2 -1
- package/dist/index.mjs +120 -35
- package/dist/standalone/storefront.mjs +120 -35
- package/dist/standalone/styles.css +23 -18
- package/dist/styles.css +23 -18
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5289,7 +5289,7 @@ declare class ProductCache {
|
|
|
5289
5289
|
* the size error). Add-to-cart calls the engine through the session so a 401 silently
|
|
5290
5290
|
* re-handshakes.
|
|
5291
5291
|
*/
|
|
5292
|
-
export declare function ProductDetail({ product, inventory, recommendations, claim, breadcrumb, help, }: ProductDetailProps): JSX.Element;
|
|
5292
|
+
export declare function ProductDetail({ product, inventory, recommendations, claim, breadcrumb, help, initialVariantSku, }: ProductDetailProps): JSX.Element;
|
|
5293
5293
|
|
|
5294
5294
|
export declare interface ProductDetailProps {
|
|
5295
5295
|
product: Product;
|
|
@@ -5303,6 +5303,7 @@ export declare interface ProductDetailProps {
|
|
|
5303
5303
|
claim?: (sku: string) => Promise<void>;
|
|
5304
5304
|
breadcrumb?: ReactNode;
|
|
5305
5305
|
help?: ReactNode;
|
|
5306
|
+
initialVariantSku?: string;
|
|
5306
5307
|
}
|
|
5307
5308
|
|
|
5308
5309
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -5692,6 +5692,72 @@ function withAuthorization(init, token) {
|
|
|
5692
5692
|
headers
|
|
5693
5693
|
};
|
|
5694
5694
|
}
|
|
5695
|
+
const KEY = "dazn-shop.set-aside";
|
|
5696
|
+
const KEPT_FOR = 30 * 24 * 60 * 60 * 1e3;
|
|
5697
|
+
function read() {
|
|
5698
|
+
try {
|
|
5699
|
+
const raw = localStorage.getItem(KEY);
|
|
5700
|
+
if (!raw) return null;
|
|
5701
|
+
const value2 = JSON.parse(raw);
|
|
5702
|
+
if (!Array.isArray(value2.lines) || typeof value2.at !== "number") return null;
|
|
5703
|
+
if (Date.now() - value2.at > KEPT_FOR) {
|
|
5704
|
+
localStorage.removeItem(KEY);
|
|
5705
|
+
return null;
|
|
5706
|
+
}
|
|
5707
|
+
const lines2 = value2.lines.filter((l) => !!l && typeof l.sku === "string" && Number.isInteger(l.qty) && l.qty > 0);
|
|
5708
|
+
return {
|
|
5709
|
+
lines: lines2,
|
|
5710
|
+
armed: value2.armed === true,
|
|
5711
|
+
at: value2.at
|
|
5712
|
+
};
|
|
5713
|
+
} catch {
|
|
5714
|
+
return null;
|
|
5715
|
+
}
|
|
5716
|
+
}
|
|
5717
|
+
function write(value2) {
|
|
5718
|
+
try {
|
|
5719
|
+
if (value2) localStorage.setItem(KEY, JSON.stringify(value2));
|
|
5720
|
+
else localStorage.removeItem(KEY);
|
|
5721
|
+
} catch {
|
|
5722
|
+
return;
|
|
5723
|
+
}
|
|
5724
|
+
}
|
|
5725
|
+
function setAside(lines2) {
|
|
5726
|
+
if (lines2.length === 0 || read()) return;
|
|
5727
|
+
write({
|
|
5728
|
+
lines: lines2,
|
|
5729
|
+
armed: false,
|
|
5730
|
+
at: Date.now()
|
|
5731
|
+
});
|
|
5732
|
+
}
|
|
5733
|
+
function armSetAside() {
|
|
5734
|
+
const stored2 = read();
|
|
5735
|
+
if (stored2) write({
|
|
5736
|
+
...stored2,
|
|
5737
|
+
armed: true
|
|
5738
|
+
});
|
|
5739
|
+
}
|
|
5740
|
+
let restoring = false;
|
|
5741
|
+
async function restoreSetAside(cart2, writer, query, { force = false } = {}) {
|
|
5742
|
+
const stored2 = read();
|
|
5743
|
+
if (!stored2 || restoring) return cart2;
|
|
5744
|
+
if (!force && (!stored2.armed || cart2.vip)) return cart2;
|
|
5745
|
+
restoring = true;
|
|
5746
|
+
write(null);
|
|
5747
|
+
let latest = cart2;
|
|
5748
|
+
try {
|
|
5749
|
+
for (const line2 of stored2.lines) {
|
|
5750
|
+
if (latest.items.some((i) => i.sku === line2.sku)) continue;
|
|
5751
|
+
latest = await writer.addItem({
|
|
5752
|
+
sku: line2.sku,
|
|
5753
|
+
qty: line2.qty
|
|
5754
|
+
}, query).catch(() => latest);
|
|
5755
|
+
}
|
|
5756
|
+
} finally {
|
|
5757
|
+
restoring = false;
|
|
5758
|
+
}
|
|
5759
|
+
return latest;
|
|
5760
|
+
}
|
|
5695
5761
|
const ScreenTitleContext = createContext({
|
|
5696
5762
|
title: void 0,
|
|
5697
5763
|
trailing: "default",
|
|
@@ -5885,24 +5951,24 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5885
5951
|
carts.set(cart2);
|
|
5886
5952
|
return cart2;
|
|
5887
5953
|
};
|
|
5888
|
-
const
|
|
5954
|
+
const read2 = (fn) => (...args) => {
|
|
5889
5955
|
const before = carts.revision;
|
|
5890
5956
|
return fn(...args).then((cart2) => carts.revision === before ? remember2(cart2) : cart2);
|
|
5891
5957
|
};
|
|
5892
|
-
const
|
|
5958
|
+
const write2 = (fn) => (...args) => fn(...args).then(remember2);
|
|
5893
5959
|
return {
|
|
5894
5960
|
...client2,
|
|
5895
5961
|
cart: {
|
|
5896
5962
|
...client2.cart,
|
|
5897
|
-
create:
|
|
5898
|
-
get:
|
|
5899
|
-
addItem:
|
|
5900
|
-
updateItem:
|
|
5901
|
-
removeItem:
|
|
5963
|
+
create: read2(client2.cart.create),
|
|
5964
|
+
get: (...args) => read2(client2.cart.get)(...args).then((cart2) => restoreSetAside(cart2, client2.cart, args[0]).then((latest) => latest === cart2 ? cart2 : remember2(latest))),
|
|
5965
|
+
addItem: write2(client2.cart.addItem),
|
|
5966
|
+
updateItem: write2(client2.cart.updateItem),
|
|
5967
|
+
removeItem: write2(client2.cart.removeItem)
|
|
5902
5968
|
},
|
|
5903
5969
|
vip: {
|
|
5904
5970
|
...client2.vip,
|
|
5905
|
-
addToCart:
|
|
5971
|
+
addToCart: write2(client2.vip.addToCart)
|
|
5906
5972
|
}
|
|
5907
5973
|
};
|
|
5908
5974
|
}, [client2, carts]);
|
|
@@ -11129,18 +11195,18 @@ function StickyCtaBar({ children, info: info2, variant = "floating", className }
|
|
|
11129
11195
|
})]
|
|
11130
11196
|
});
|
|
11131
11197
|
}
|
|
11132
|
-
const surface = "
|
|
11133
|
-
const screen = "
|
|
11134
|
-
const body$4 = "
|
|
11135
|
-
const items = "
|
|
11136
|
-
const sectionHeader = "
|
|
11137
|
-
const sectionTitle = "
|
|
11138
|
-
const count = "
|
|
11139
|
-
const lines = "
|
|
11140
|
-
const footer = "
|
|
11141
|
-
const empty = "
|
|
11142
|
-
const cta$4 = "
|
|
11143
|
-
const ctaError = "
|
|
11198
|
+
const surface = "_surface_1rn0i_15";
|
|
11199
|
+
const screen = "_screen_1rn0i_20";
|
|
11200
|
+
const body$4 = "_body_1rn0i_12";
|
|
11201
|
+
const items = "_items_1rn0i_34";
|
|
11202
|
+
const sectionHeader = "_sectionHeader_1rn0i_40";
|
|
11203
|
+
const sectionTitle = "_sectionTitle_1rn0i_46";
|
|
11204
|
+
const count = "_count_1rn0i_67";
|
|
11205
|
+
const lines = "_lines_1rn0i_91";
|
|
11206
|
+
const footer = "_footer_1rn0i_101";
|
|
11207
|
+
const empty = "_empty_1rn0i_105";
|
|
11208
|
+
const cta$4 = "_cta_1rn0i_152";
|
|
11209
|
+
const ctaError = "_ctaError_1rn0i_160";
|
|
11144
11210
|
const styles$o = {
|
|
11145
11211
|
surface,
|
|
11146
11212
|
screen,
|
|
@@ -11158,6 +11224,12 @@ const styles$o = {
|
|
|
11158
11224
|
function CartView(props = {}) {
|
|
11159
11225
|
const t = useT();
|
|
11160
11226
|
useSetScreenTitle(t("Cart"), "none");
|
|
11227
|
+
useSetScreenNav([{
|
|
11228
|
+
label: t("DAZN Shop"),
|
|
11229
|
+
to: "/"
|
|
11230
|
+
}, {
|
|
11231
|
+
label: t("Cart")
|
|
11232
|
+
}], "light");
|
|
11161
11233
|
return jsx(ShopSurface, {
|
|
11162
11234
|
tone: "light",
|
|
11163
11235
|
fill: true,
|
|
@@ -12234,7 +12306,7 @@ const styles$e = {
|
|
|
12234
12306
|
cta: cta$3,
|
|
12235
12307
|
shop
|
|
12236
12308
|
};
|
|
12237
|
-
function ProductDetail({ product, inventory: inventory2, recommendations = [], claim, breadcrumb: breadcrumb2, help: help2 }) {
|
|
12309
|
+
function ProductDetail({ product, inventory: inventory2, recommendations = [], claim, breadcrumb: breadcrumb2, help: help2, initialVariantSku }) {
|
|
12238
12310
|
const t = useT();
|
|
12239
12311
|
const toast2 = useToast();
|
|
12240
12312
|
const { api, emit } = useShop();
|
|
@@ -12266,11 +12338,12 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [], c
|
|
|
12266
12338
|
const hasSizes = useMemo(() => sizeOptions(variants).length > 0, [variants]);
|
|
12267
12339
|
const hasColours = baseColours.length > 0;
|
|
12268
12340
|
const structured = hasSizes || hasColours;
|
|
12269
|
-
const
|
|
12270
|
-
const [
|
|
12341
|
+
const preselected = initialVariantSku ? variants.find((v) => v.sku === initialVariantSku) : void 0;
|
|
12342
|
+
const [selectedSize, setSelectedSize] = useState(preselected?.attributes.size ?? null);
|
|
12343
|
+
const [selectedColour, setSelectedColour] = useState(preselected?.attributes.colour ?? preselected?.attributes.color ?? (hasColours ? baseColours.find((c) => c.available)?.value ?? baseColours[0].value : null));
|
|
12271
12344
|
const sizes2 = useMemo(() => sizeOptions(variants, selectedColour), [variants, selectedColour]);
|
|
12272
12345
|
const colours = useMemo(() => colourOptions(variants, selectedSize), [variants, selectedSize]);
|
|
12273
|
-
const [genericSku, setGenericSku] = useState(null);
|
|
12346
|
+
const [genericSku, setGenericSku] = useState(preselected && !structured ? preselected.sku : null);
|
|
12274
12347
|
const [busy, setBusy] = useState(null);
|
|
12275
12348
|
const [sizeError, setSizeError] = useState(false);
|
|
12276
12349
|
const [reminded, setReminded] = useState([]);
|
|
@@ -13323,9 +13396,12 @@ function ProductView({ sku, initialData, showRecommendations = true, onNotFound
|
|
|
13323
13396
|
if (product) {
|
|
13324
13397
|
return jsx(ProductDetail, {
|
|
13325
13398
|
product,
|
|
13399
|
+
...sku === product.sku ? {} : {
|
|
13400
|
+
initialVariantSku: sku
|
|
13401
|
+
},
|
|
13326
13402
|
inventory: inventory2,
|
|
13327
13403
|
recommendations
|
|
13328
|
-
}, product.sku);
|
|
13404
|
+
}, sku === product.sku ? product.sku : `${product.sku}:${sku}`);
|
|
13329
13405
|
}
|
|
13330
13406
|
if (loading) return jsx(ScreenSkeleton, {
|
|
13331
13407
|
tone: "light"
|
|
@@ -15137,8 +15213,12 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15137
15213
|
}
|
|
15138
15214
|
try {
|
|
15139
15215
|
const current2 = await api.cart.get().catch(() => null);
|
|
15140
|
-
if (current2
|
|
15141
|
-
|
|
15216
|
+
if (current2 && current2.items.length > 0) {
|
|
15217
|
+
if (!current2.vip) setAside(current2.items.map((line2) => ({
|
|
15218
|
+
sku: line2.sku,
|
|
15219
|
+
qty: line2.qty
|
|
15220
|
+
})));
|
|
15221
|
+
for (const line2 of current2.items) await api.cart.removeItem(line2.sku).catch(() => null);
|
|
15142
15222
|
}
|
|
15143
15223
|
const target = locatorOf(token);
|
|
15144
15224
|
if (!target) throw new Error("invalid invite link");
|
|
@@ -15147,6 +15227,7 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15147
15227
|
sku: variantSku,
|
|
15148
15228
|
qty: 1
|
|
15149
15229
|
});
|
|
15230
|
+
armSetAside();
|
|
15150
15231
|
emit({
|
|
15151
15232
|
type: "cart_updated",
|
|
15152
15233
|
itemCount: cart2.items.reduce((n, i) => n + i.qty, 0),
|
|
@@ -15161,6 +15242,10 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15161
15242
|
window.location.assign(checkout_url);
|
|
15162
15243
|
} catch (err) {
|
|
15163
15244
|
const code = codeOf(err);
|
|
15245
|
+
const now = await api.cart.get().catch(() => null);
|
|
15246
|
+
if (now && !now.vip) await restoreSetAside(now, api.cart, void 0, {
|
|
15247
|
+
force: true
|
|
15248
|
+
});
|
|
15164
15249
|
if (code === "unauthorized") {
|
|
15165
15250
|
emit({
|
|
15166
15251
|
type: "session_required",
|
|
@@ -15323,7 +15408,7 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
15323
15408
|
};
|
|
15324
15409
|
let at = TOP;
|
|
15325
15410
|
let returning = false;
|
|
15326
|
-
let
|
|
15411
|
+
let restoring2 = false;
|
|
15327
15412
|
let holding = false;
|
|
15328
15413
|
const settle = () => {
|
|
15329
15414
|
returning = false;
|
|
@@ -15340,13 +15425,13 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
15340
15425
|
release();
|
|
15341
15426
|
const back = returnOffset(here());
|
|
15342
15427
|
returning = back !== null;
|
|
15343
|
-
|
|
15428
|
+
restoring2 = returning;
|
|
15344
15429
|
at = back ?? TOP;
|
|
15345
15430
|
holding = true;
|
|
15346
15431
|
if (frame2 !== null && typeof window.cancelAnimationFrame === "function") {
|
|
15347
15432
|
window.cancelAnimationFrame(frame2);
|
|
15348
15433
|
}
|
|
15349
|
-
if (
|
|
15434
|
+
if (restoring2) snapOn();
|
|
15350
15435
|
else snapOff();
|
|
15351
15436
|
top2();
|
|
15352
15437
|
frame2 = typeof window.requestAnimationFrame === "function" ? window.requestAnimationFrame(() => {
|
|
@@ -15354,7 +15439,7 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
15354
15439
|
snapOn();
|
|
15355
15440
|
}) : null;
|
|
15356
15441
|
release = anchorTop(() => {
|
|
15357
|
-
if (snapping && !
|
|
15442
|
+
if (snapping && !restoring2) {
|
|
15358
15443
|
const layout = layoutOf();
|
|
15359
15444
|
if (layout !== snappedLayout) {
|
|
15360
15445
|
snappedLayout = layout;
|
|
@@ -16333,17 +16418,17 @@ function useScrolledUnder(enabled) {
|
|
|
16333
16418
|
const [scrolled2, setScrolled] = useState(false);
|
|
16334
16419
|
useEffect(() => {
|
|
16335
16420
|
if (!enabled) return;
|
|
16336
|
-
const
|
|
16421
|
+
const read2 = (event) => {
|
|
16337
16422
|
const target = event?.target;
|
|
16338
16423
|
const top2 = target && target !== document && target instanceof HTMLElement ? target.scrollTop : window.scrollY || document.documentElement.scrollTop;
|
|
16339
16424
|
setScrolled(top2 > 0);
|
|
16340
16425
|
};
|
|
16341
|
-
|
|
16342
|
-
document.addEventListener("scroll",
|
|
16426
|
+
read2();
|
|
16427
|
+
document.addEventListener("scroll", read2, {
|
|
16343
16428
|
capture: true,
|
|
16344
16429
|
passive: true
|
|
16345
16430
|
});
|
|
16346
|
-
return () => document.removeEventListener("scroll",
|
|
16431
|
+
return () => document.removeEventListener("scroll", read2, {
|
|
16347
16432
|
capture: true
|
|
16348
16433
|
});
|
|
16349
16434
|
}, [enabled]);
|
|
@@ -5692,6 +5692,72 @@ function withAuthorization(init, token) {
|
|
|
5692
5692
|
headers
|
|
5693
5693
|
};
|
|
5694
5694
|
}
|
|
5695
|
+
const KEY = "dazn-shop.set-aside";
|
|
5696
|
+
const KEPT_FOR = 30 * 24 * 60 * 60 * 1e3;
|
|
5697
|
+
function read() {
|
|
5698
|
+
try {
|
|
5699
|
+
const raw = localStorage.getItem(KEY);
|
|
5700
|
+
if (!raw) return null;
|
|
5701
|
+
const value2 = JSON.parse(raw);
|
|
5702
|
+
if (!Array.isArray(value2.lines) || typeof value2.at !== "number") return null;
|
|
5703
|
+
if (Date.now() - value2.at > KEPT_FOR) {
|
|
5704
|
+
localStorage.removeItem(KEY);
|
|
5705
|
+
return null;
|
|
5706
|
+
}
|
|
5707
|
+
const lines2 = value2.lines.filter((l) => !!l && typeof l.sku === "string" && Number.isInteger(l.qty) && l.qty > 0);
|
|
5708
|
+
return {
|
|
5709
|
+
lines: lines2,
|
|
5710
|
+
armed: value2.armed === true,
|
|
5711
|
+
at: value2.at
|
|
5712
|
+
};
|
|
5713
|
+
} catch {
|
|
5714
|
+
return null;
|
|
5715
|
+
}
|
|
5716
|
+
}
|
|
5717
|
+
function write(value2) {
|
|
5718
|
+
try {
|
|
5719
|
+
if (value2) localStorage.setItem(KEY, JSON.stringify(value2));
|
|
5720
|
+
else localStorage.removeItem(KEY);
|
|
5721
|
+
} catch {
|
|
5722
|
+
return;
|
|
5723
|
+
}
|
|
5724
|
+
}
|
|
5725
|
+
function setAside(lines2) {
|
|
5726
|
+
if (lines2.length === 0 || read()) return;
|
|
5727
|
+
write({
|
|
5728
|
+
lines: lines2,
|
|
5729
|
+
armed: false,
|
|
5730
|
+
at: Date.now()
|
|
5731
|
+
});
|
|
5732
|
+
}
|
|
5733
|
+
function armSetAside() {
|
|
5734
|
+
const stored2 = read();
|
|
5735
|
+
if (stored2) write({
|
|
5736
|
+
...stored2,
|
|
5737
|
+
armed: true
|
|
5738
|
+
});
|
|
5739
|
+
}
|
|
5740
|
+
let restoring = false;
|
|
5741
|
+
async function restoreSetAside(cart2, writer, query, { force = false } = {}) {
|
|
5742
|
+
const stored2 = read();
|
|
5743
|
+
if (!stored2 || restoring) return cart2;
|
|
5744
|
+
if (!force && (!stored2.armed || cart2.vip)) return cart2;
|
|
5745
|
+
restoring = true;
|
|
5746
|
+
write(null);
|
|
5747
|
+
let latest = cart2;
|
|
5748
|
+
try {
|
|
5749
|
+
for (const line2 of stored2.lines) {
|
|
5750
|
+
if (latest.items.some((i) => i.sku === line2.sku)) continue;
|
|
5751
|
+
latest = await writer.addItem({
|
|
5752
|
+
sku: line2.sku,
|
|
5753
|
+
qty: line2.qty
|
|
5754
|
+
}, query).catch(() => latest);
|
|
5755
|
+
}
|
|
5756
|
+
} finally {
|
|
5757
|
+
restoring = false;
|
|
5758
|
+
}
|
|
5759
|
+
return latest;
|
|
5760
|
+
}
|
|
5695
5761
|
const ScreenTitleContext = createContext({
|
|
5696
5762
|
title: void 0,
|
|
5697
5763
|
trailing: "default",
|
|
@@ -5885,24 +5951,24 @@ function DaznShopProvider({ children, ...config }) {
|
|
|
5885
5951
|
carts.set(cart2);
|
|
5886
5952
|
return cart2;
|
|
5887
5953
|
};
|
|
5888
|
-
const
|
|
5954
|
+
const read2 = (fn) => (...args) => {
|
|
5889
5955
|
const before = carts.revision;
|
|
5890
5956
|
return fn(...args).then((cart2) => carts.revision === before ? remember2(cart2) : cart2);
|
|
5891
5957
|
};
|
|
5892
|
-
const
|
|
5958
|
+
const write2 = (fn) => (...args) => fn(...args).then(remember2);
|
|
5893
5959
|
return {
|
|
5894
5960
|
...client2,
|
|
5895
5961
|
cart: {
|
|
5896
5962
|
...client2.cart,
|
|
5897
|
-
create:
|
|
5898
|
-
get:
|
|
5899
|
-
addItem:
|
|
5900
|
-
updateItem:
|
|
5901
|
-
removeItem:
|
|
5963
|
+
create: read2(client2.cart.create),
|
|
5964
|
+
get: (...args) => read2(client2.cart.get)(...args).then((cart2) => restoreSetAside(cart2, client2.cart, args[0]).then((latest) => latest === cart2 ? cart2 : remember2(latest))),
|
|
5965
|
+
addItem: write2(client2.cart.addItem),
|
|
5966
|
+
updateItem: write2(client2.cart.updateItem),
|
|
5967
|
+
removeItem: write2(client2.cart.removeItem)
|
|
5902
5968
|
},
|
|
5903
5969
|
vip: {
|
|
5904
5970
|
...client2.vip,
|
|
5905
|
-
addToCart:
|
|
5971
|
+
addToCart: write2(client2.vip.addToCart)
|
|
5906
5972
|
}
|
|
5907
5973
|
};
|
|
5908
5974
|
}, [client2, carts]);
|
|
@@ -11129,18 +11195,18 @@ function StickyCtaBar({ children, info: info2, variant = "floating", className }
|
|
|
11129
11195
|
})]
|
|
11130
11196
|
});
|
|
11131
11197
|
}
|
|
11132
|
-
const surface = "
|
|
11133
|
-
const screen = "
|
|
11134
|
-
const body$4 = "
|
|
11135
|
-
const items = "
|
|
11136
|
-
const sectionHeader = "
|
|
11137
|
-
const sectionTitle = "
|
|
11138
|
-
const count = "
|
|
11139
|
-
const lines = "
|
|
11140
|
-
const footer = "
|
|
11141
|
-
const empty = "
|
|
11142
|
-
const cta$4 = "
|
|
11143
|
-
const ctaError = "
|
|
11198
|
+
const surface = "_surface_1rn0i_15";
|
|
11199
|
+
const screen = "_screen_1rn0i_20";
|
|
11200
|
+
const body$4 = "_body_1rn0i_12";
|
|
11201
|
+
const items = "_items_1rn0i_34";
|
|
11202
|
+
const sectionHeader = "_sectionHeader_1rn0i_40";
|
|
11203
|
+
const sectionTitle = "_sectionTitle_1rn0i_46";
|
|
11204
|
+
const count = "_count_1rn0i_67";
|
|
11205
|
+
const lines = "_lines_1rn0i_91";
|
|
11206
|
+
const footer = "_footer_1rn0i_101";
|
|
11207
|
+
const empty = "_empty_1rn0i_105";
|
|
11208
|
+
const cta$4 = "_cta_1rn0i_152";
|
|
11209
|
+
const ctaError = "_ctaError_1rn0i_160";
|
|
11144
11210
|
const styles$o = {
|
|
11145
11211
|
surface,
|
|
11146
11212
|
screen,
|
|
@@ -11158,6 +11224,12 @@ const styles$o = {
|
|
|
11158
11224
|
function CartView(props = {}) {
|
|
11159
11225
|
const t = useT();
|
|
11160
11226
|
useSetScreenTitle(t("Cart"), "none");
|
|
11227
|
+
useSetScreenNav([{
|
|
11228
|
+
label: t("DAZN Shop"),
|
|
11229
|
+
to: "/"
|
|
11230
|
+
}, {
|
|
11231
|
+
label: t("Cart")
|
|
11232
|
+
}], "light");
|
|
11161
11233
|
return jsx(ShopSurface, {
|
|
11162
11234
|
tone: "light",
|
|
11163
11235
|
fill: true,
|
|
@@ -12234,7 +12306,7 @@ const styles$e = {
|
|
|
12234
12306
|
cta: cta$3,
|
|
12235
12307
|
shop
|
|
12236
12308
|
};
|
|
12237
|
-
function ProductDetail({ product, inventory: inventory2, recommendations = [], claim, breadcrumb: breadcrumb2, help: help2 }) {
|
|
12309
|
+
function ProductDetail({ product, inventory: inventory2, recommendations = [], claim, breadcrumb: breadcrumb2, help: help2, initialVariantSku }) {
|
|
12238
12310
|
const t = useT();
|
|
12239
12311
|
const toast2 = useToast();
|
|
12240
12312
|
const { api, emit } = useShop();
|
|
@@ -12266,11 +12338,12 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [], c
|
|
|
12266
12338
|
const hasSizes = useMemo(() => sizeOptions(variants).length > 0, [variants]);
|
|
12267
12339
|
const hasColours = baseColours.length > 0;
|
|
12268
12340
|
const structured = hasSizes || hasColours;
|
|
12269
|
-
const
|
|
12270
|
-
const [
|
|
12341
|
+
const preselected = initialVariantSku ? variants.find((v) => v.sku === initialVariantSku) : void 0;
|
|
12342
|
+
const [selectedSize, setSelectedSize] = useState(preselected?.attributes.size ?? null);
|
|
12343
|
+
const [selectedColour, setSelectedColour] = useState(preselected?.attributes.colour ?? preselected?.attributes.color ?? (hasColours ? baseColours.find((c) => c.available)?.value ?? baseColours[0].value : null));
|
|
12271
12344
|
const sizes2 = useMemo(() => sizeOptions(variants, selectedColour), [variants, selectedColour]);
|
|
12272
12345
|
const colours = useMemo(() => colourOptions(variants, selectedSize), [variants, selectedSize]);
|
|
12273
|
-
const [genericSku, setGenericSku] = useState(null);
|
|
12346
|
+
const [genericSku, setGenericSku] = useState(preselected && !structured ? preselected.sku : null);
|
|
12274
12347
|
const [busy, setBusy] = useState(null);
|
|
12275
12348
|
const [sizeError, setSizeError] = useState(false);
|
|
12276
12349
|
const [reminded, setReminded] = useState([]);
|
|
@@ -13323,9 +13396,12 @@ function ProductView({ sku, initialData, showRecommendations = true, onNotFound
|
|
|
13323
13396
|
if (product) {
|
|
13324
13397
|
return jsx(ProductDetail, {
|
|
13325
13398
|
product,
|
|
13399
|
+
...sku === product.sku ? {} : {
|
|
13400
|
+
initialVariantSku: sku
|
|
13401
|
+
},
|
|
13326
13402
|
inventory: inventory2,
|
|
13327
13403
|
recommendations
|
|
13328
|
-
}, product.sku);
|
|
13404
|
+
}, sku === product.sku ? product.sku : `${product.sku}:${sku}`);
|
|
13329
13405
|
}
|
|
13330
13406
|
if (loading) return jsx(ScreenSkeleton, {
|
|
13331
13407
|
tone: "light"
|
|
@@ -15137,8 +15213,12 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15137
15213
|
}
|
|
15138
15214
|
try {
|
|
15139
15215
|
const current2 = await api.cart.get().catch(() => null);
|
|
15140
|
-
if (current2
|
|
15141
|
-
|
|
15216
|
+
if (current2 && current2.items.length > 0) {
|
|
15217
|
+
if (!current2.vip) setAside(current2.items.map((line2) => ({
|
|
15218
|
+
sku: line2.sku,
|
|
15219
|
+
qty: line2.qty
|
|
15220
|
+
})));
|
|
15221
|
+
for (const line2 of current2.items) await api.cart.removeItem(line2.sku).catch(() => null);
|
|
15142
15222
|
}
|
|
15143
15223
|
const target = locatorOf(token);
|
|
15144
15224
|
if (!target) throw new Error("invalid invite link");
|
|
@@ -15147,6 +15227,7 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15147
15227
|
sku: variantSku,
|
|
15148
15228
|
qty: 1
|
|
15149
15229
|
});
|
|
15230
|
+
armSetAside();
|
|
15150
15231
|
emit({
|
|
15151
15232
|
type: "cart_updated",
|
|
15152
15233
|
itemCount: cart2.items.reduce((n, i) => n + i.qty, 0),
|
|
@@ -15161,6 +15242,10 @@ function ActiveLanding({ token, invite, screen: screen2 }) {
|
|
|
15161
15242
|
window.location.assign(checkout_url);
|
|
15162
15243
|
} catch (err) {
|
|
15163
15244
|
const code = codeOf(err);
|
|
15245
|
+
const now = await api.cart.get().catch(() => null);
|
|
15246
|
+
if (now && !now.vip) await restoreSetAside(now, api.cart, void 0, {
|
|
15247
|
+
force: true
|
|
15248
|
+
});
|
|
15164
15249
|
if (code === "unauthorized") {
|
|
15165
15250
|
emit({
|
|
15166
15251
|
type: "session_required",
|
|
@@ -15323,7 +15408,7 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
15323
15408
|
};
|
|
15324
15409
|
let at = TOP;
|
|
15325
15410
|
let returning = false;
|
|
15326
|
-
let
|
|
15411
|
+
let restoring2 = false;
|
|
15327
15412
|
let holding = false;
|
|
15328
15413
|
const settle = () => {
|
|
15329
15414
|
returning = false;
|
|
@@ -15340,13 +15425,13 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
15340
15425
|
release();
|
|
15341
15426
|
const back = returnOffset(here());
|
|
15342
15427
|
returning = back !== null;
|
|
15343
|
-
|
|
15428
|
+
restoring2 = returning;
|
|
15344
15429
|
at = back ?? TOP;
|
|
15345
15430
|
holding = true;
|
|
15346
15431
|
if (frame2 !== null && typeof window.cancelAnimationFrame === "function") {
|
|
15347
15432
|
window.cancelAnimationFrame(frame2);
|
|
15348
15433
|
}
|
|
15349
|
-
if (
|
|
15434
|
+
if (restoring2) snapOn();
|
|
15350
15435
|
else snapOff();
|
|
15351
15436
|
top2();
|
|
15352
15437
|
frame2 = typeof window.requestAnimationFrame === "function" ? window.requestAnimationFrame(() => {
|
|
@@ -15354,7 +15439,7 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
15354
15439
|
snapOn();
|
|
15355
15440
|
}) : null;
|
|
15356
15441
|
release = anchorTop(() => {
|
|
15357
|
-
if (snapping && !
|
|
15442
|
+
if (snapping && !restoring2) {
|
|
15358
15443
|
const layout = layoutOf();
|
|
15359
15444
|
if (layout !== snappedLayout) {
|
|
15360
15445
|
snappedLayout = layout;
|
|
@@ -16333,17 +16418,17 @@ function useScrolledUnder(enabled) {
|
|
|
16333
16418
|
const [scrolled2, setScrolled] = useState(false);
|
|
16334
16419
|
useEffect(() => {
|
|
16335
16420
|
if (!enabled) return;
|
|
16336
|
-
const
|
|
16421
|
+
const read2 = (event) => {
|
|
16337
16422
|
const target = event?.target;
|
|
16338
16423
|
const top2 = target && target !== document && target instanceof HTMLElement ? target.scrollTop : window.scrollY || document.documentElement.scrollTop;
|
|
16339
16424
|
setScrolled(top2 > 0);
|
|
16340
16425
|
};
|
|
16341
|
-
|
|
16342
|
-
document.addEventListener("scroll",
|
|
16426
|
+
read2();
|
|
16427
|
+
document.addEventListener("scroll", read2, {
|
|
16343
16428
|
capture: true,
|
|
16344
16429
|
passive: true
|
|
16345
16430
|
});
|
|
16346
|
-
return () => document.removeEventListener("scroll",
|
|
16431
|
+
return () => document.removeEventListener("scroll", read2, {
|
|
16347
16432
|
capture: true
|
|
16348
16433
|
});
|
|
16349
16434
|
}, [enabled]);
|
|
@@ -3098,33 +3098,33 @@
|
|
|
3098
3098
|
._actions_23dkv_70 > * {
|
|
3099
3099
|
flex: 1 1 0;
|
|
3100
3100
|
}
|
|
3101
|
-
.
|
|
3101
|
+
._surface_1rn0i_15 {
|
|
3102
3102
|
display: flex;
|
|
3103
3103
|
flex-direction: column;
|
|
3104
3104
|
}
|
|
3105
|
-
.
|
|
3105
|
+
._screen_1rn0i_20 {
|
|
3106
3106
|
display: flex;
|
|
3107
3107
|
flex-direction: column;
|
|
3108
3108
|
flex: 1 1 auto;
|
|
3109
3109
|
}
|
|
3110
|
-
.
|
|
3110
|
+
._body_1rn0i_12 {
|
|
3111
3111
|
display: flex;
|
|
3112
3112
|
flex-direction: column;
|
|
3113
3113
|
gap: var(--space-20);
|
|
3114
3114
|
padding: var(--space-20) var(--space-16) 0;
|
|
3115
3115
|
flex: 1 1 auto;
|
|
3116
3116
|
}
|
|
3117
|
-
.
|
|
3117
|
+
._items_1rn0i_34 {
|
|
3118
3118
|
display: flex;
|
|
3119
3119
|
flex-direction: column;
|
|
3120
3120
|
gap: var(--space-20);
|
|
3121
3121
|
}
|
|
3122
|
-
.
|
|
3122
|
+
._sectionHeader_1rn0i_40 {
|
|
3123
3123
|
display: flex;
|
|
3124
3124
|
align-items: center;
|
|
3125
3125
|
gap: var(--space-12);
|
|
3126
3126
|
}
|
|
3127
|
-
.
|
|
3127
|
+
._sectionTitle_1rn0i_46 {
|
|
3128
3128
|
margin: 0;
|
|
3129
3129
|
font-size: var(--type-heading-md-size);
|
|
3130
3130
|
line-height: 1.38;
|
|
@@ -3132,7 +3132,7 @@
|
|
|
3132
3132
|
flex: 1 0 0;
|
|
3133
3133
|
min-width: 0;
|
|
3134
3134
|
}
|
|
3135
|
-
.
|
|
3135
|
+
._count_1rn0i_67 {
|
|
3136
3136
|
display: inline-flex;
|
|
3137
3137
|
align-items: center;
|
|
3138
3138
|
justify-content: center;
|
|
@@ -3147,7 +3147,7 @@
|
|
|
3147
3147
|
font-variant-numeric: tabular-nums;
|
|
3148
3148
|
flex-shrink: 0;
|
|
3149
3149
|
}
|
|
3150
|
-
.
|
|
3150
|
+
._lines_1rn0i_91 {
|
|
3151
3151
|
list-style: none;
|
|
3152
3152
|
margin: 0;
|
|
3153
3153
|
padding: 0;
|
|
@@ -3155,33 +3155,38 @@
|
|
|
3155
3155
|
flex-direction: column;
|
|
3156
3156
|
gap: var(--space-20);
|
|
3157
3157
|
}
|
|
3158
|
-
.
|
|
3158
|
+
._footer_1rn0i_101 {
|
|
3159
3159
|
display: contents;
|
|
3160
3160
|
}
|
|
3161
|
-
.
|
|
3161
|
+
._empty_1rn0i_105 {
|
|
3162
3162
|
display: contents;
|
|
3163
3163
|
}
|
|
3164
3164
|
@media (min-width: 1200px) {
|
|
3165
|
-
|
|
3165
|
+
._screen_1rn0i_20 {
|
|
3166
|
+
width: 100%;
|
|
3167
|
+
max-width: 480px;
|
|
3168
|
+
margin-inline: auto;
|
|
3169
|
+
}
|
|
3170
|
+
[data-shop-panel] ._empty_1rn0i_105 p {
|
|
3166
3171
|
max-width: none;
|
|
3167
3172
|
white-space: nowrap;
|
|
3168
3173
|
}
|
|
3169
|
-
[data-shop-panel] .
|
|
3174
|
+
[data-shop-panel] ._empty_1rn0i_105 button {
|
|
3170
3175
|
width: 154px;
|
|
3171
3176
|
padding: 0;
|
|
3172
3177
|
}
|
|
3173
|
-
[data-shop-panel] .
|
|
3178
|
+
[data-shop-panel] ._count_1rn0i_67 {
|
|
3174
3179
|
border: 1px solid var(--color-border-default);
|
|
3175
3180
|
background: transparent;
|
|
3176
3181
|
}
|
|
3177
|
-
[data-shop-panel] .
|
|
3182
|
+
[data-shop-panel] ._surface_1rn0i_15 {
|
|
3178
3183
|
justify-content: center;
|
|
3179
3184
|
background: var(--color-surface-base);
|
|
3180
3185
|
}
|
|
3181
|
-
[data-shop-panel] .
|
|
3186
|
+
[data-shop-panel] ._body_1rn0i_12 {
|
|
3182
3187
|
padding: var(--space-4) var(--space-24) var(--space-24);
|
|
3183
3188
|
}
|
|
3184
|
-
[data-shop-panel] .
|
|
3189
|
+
[data-shop-panel] ._footer_1rn0i_101 {
|
|
3185
3190
|
position: sticky;
|
|
3186
3191
|
bottom: 0;
|
|
3187
3192
|
z-index: 50;
|
|
@@ -3192,14 +3197,14 @@
|
|
|
3192
3197
|
border-top: 1px solid #e6e6e6;
|
|
3193
3198
|
background: var(--color-surface-base);
|
|
3194
3199
|
}
|
|
3195
|
-
[data-shop-panel] .
|
|
3200
|
+
[data-shop-panel] ._cta_1rn0i_152 {
|
|
3196
3201
|
position: static;
|
|
3197
3202
|
padding: 0;
|
|
3198
3203
|
border-top: none;
|
|
3199
3204
|
background: transparent;
|
|
3200
3205
|
}
|
|
3201
3206
|
}
|
|
3202
|
-
.
|
|
3207
|
+
._ctaError_1rn0i_160 {
|
|
3203
3208
|
margin: 0;
|
|
3204
3209
|
font-size: var(--type-caption-sm-size);
|
|
3205
3210
|
line-height: var(--type-caption-sm-line);
|
package/dist/styles.css
CHANGED
|
@@ -3098,33 +3098,33 @@
|
|
|
3098
3098
|
._actions_23dkv_70 > * {
|
|
3099
3099
|
flex: 1 1 0;
|
|
3100
3100
|
}
|
|
3101
|
-
.
|
|
3101
|
+
._surface_1rn0i_15 {
|
|
3102
3102
|
display: flex;
|
|
3103
3103
|
flex-direction: column;
|
|
3104
3104
|
}
|
|
3105
|
-
.
|
|
3105
|
+
._screen_1rn0i_20 {
|
|
3106
3106
|
display: flex;
|
|
3107
3107
|
flex-direction: column;
|
|
3108
3108
|
flex: 1 1 auto;
|
|
3109
3109
|
}
|
|
3110
|
-
.
|
|
3110
|
+
._body_1rn0i_12 {
|
|
3111
3111
|
display: flex;
|
|
3112
3112
|
flex-direction: column;
|
|
3113
3113
|
gap: var(--space-20);
|
|
3114
3114
|
padding: var(--space-20) var(--space-16) 0;
|
|
3115
3115
|
flex: 1 1 auto;
|
|
3116
3116
|
}
|
|
3117
|
-
.
|
|
3117
|
+
._items_1rn0i_34 {
|
|
3118
3118
|
display: flex;
|
|
3119
3119
|
flex-direction: column;
|
|
3120
3120
|
gap: var(--space-20);
|
|
3121
3121
|
}
|
|
3122
|
-
.
|
|
3122
|
+
._sectionHeader_1rn0i_40 {
|
|
3123
3123
|
display: flex;
|
|
3124
3124
|
align-items: center;
|
|
3125
3125
|
gap: var(--space-12);
|
|
3126
3126
|
}
|
|
3127
|
-
.
|
|
3127
|
+
._sectionTitle_1rn0i_46 {
|
|
3128
3128
|
margin: 0;
|
|
3129
3129
|
font-size: var(--type-heading-md-size);
|
|
3130
3130
|
line-height: 1.38;
|
|
@@ -3132,7 +3132,7 @@
|
|
|
3132
3132
|
flex: 1 0 0;
|
|
3133
3133
|
min-width: 0;
|
|
3134
3134
|
}
|
|
3135
|
-
.
|
|
3135
|
+
._count_1rn0i_67 {
|
|
3136
3136
|
display: inline-flex;
|
|
3137
3137
|
align-items: center;
|
|
3138
3138
|
justify-content: center;
|
|
@@ -3147,7 +3147,7 @@
|
|
|
3147
3147
|
font-variant-numeric: tabular-nums;
|
|
3148
3148
|
flex-shrink: 0;
|
|
3149
3149
|
}
|
|
3150
|
-
.
|
|
3150
|
+
._lines_1rn0i_91 {
|
|
3151
3151
|
list-style: none;
|
|
3152
3152
|
margin: 0;
|
|
3153
3153
|
padding: 0;
|
|
@@ -3155,33 +3155,38 @@
|
|
|
3155
3155
|
flex-direction: column;
|
|
3156
3156
|
gap: var(--space-20);
|
|
3157
3157
|
}
|
|
3158
|
-
.
|
|
3158
|
+
._footer_1rn0i_101 {
|
|
3159
3159
|
display: contents;
|
|
3160
3160
|
}
|
|
3161
|
-
.
|
|
3161
|
+
._empty_1rn0i_105 {
|
|
3162
3162
|
display: contents;
|
|
3163
3163
|
}
|
|
3164
3164
|
@media (min-width: 1200px) {
|
|
3165
|
-
|
|
3165
|
+
._screen_1rn0i_20 {
|
|
3166
|
+
width: 100%;
|
|
3167
|
+
max-width: 480px;
|
|
3168
|
+
margin-inline: auto;
|
|
3169
|
+
}
|
|
3170
|
+
[data-shop-panel] ._empty_1rn0i_105 p {
|
|
3166
3171
|
max-width: none;
|
|
3167
3172
|
white-space: nowrap;
|
|
3168
3173
|
}
|
|
3169
|
-
[data-shop-panel] .
|
|
3174
|
+
[data-shop-panel] ._empty_1rn0i_105 button {
|
|
3170
3175
|
width: 154px;
|
|
3171
3176
|
padding: 0;
|
|
3172
3177
|
}
|
|
3173
|
-
[data-shop-panel] .
|
|
3178
|
+
[data-shop-panel] ._count_1rn0i_67 {
|
|
3174
3179
|
border: 1px solid var(--color-border-default);
|
|
3175
3180
|
background: transparent;
|
|
3176
3181
|
}
|
|
3177
|
-
[data-shop-panel] .
|
|
3182
|
+
[data-shop-panel] ._surface_1rn0i_15 {
|
|
3178
3183
|
justify-content: center;
|
|
3179
3184
|
background: var(--color-surface-base);
|
|
3180
3185
|
}
|
|
3181
|
-
[data-shop-panel] .
|
|
3186
|
+
[data-shop-panel] ._body_1rn0i_12 {
|
|
3182
3187
|
padding: var(--space-4) var(--space-24) var(--space-24);
|
|
3183
3188
|
}
|
|
3184
|
-
[data-shop-panel] .
|
|
3189
|
+
[data-shop-panel] ._footer_1rn0i_101 {
|
|
3185
3190
|
position: sticky;
|
|
3186
3191
|
bottom: 0;
|
|
3187
3192
|
z-index: 50;
|
|
@@ -3192,14 +3197,14 @@
|
|
|
3192
3197
|
border-top: 1px solid #e6e6e6;
|
|
3193
3198
|
background: var(--color-surface-base);
|
|
3194
3199
|
}
|
|
3195
|
-
[data-shop-panel] .
|
|
3200
|
+
[data-shop-panel] ._cta_1rn0i_152 {
|
|
3196
3201
|
position: static;
|
|
3197
3202
|
padding: 0;
|
|
3198
3203
|
border-top: none;
|
|
3199
3204
|
background: transparent;
|
|
3200
3205
|
}
|
|
3201
3206
|
}
|
|
3202
|
-
.
|
|
3207
|
+
._ctaError_1rn0i_160 {
|
|
3203
3208
|
margin: 0;
|
|
3204
3209
|
font-size: var(--type-caption-sm-size);
|
|
3205
3210
|
line-height: var(--type-caption-sm-line);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nok-integration/storefront-react",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.13",
|
|
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",
|