@nok-integration/storefront-react 0.20.11 → 0.20.12
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.mjs +132 -67
- package/dist/standalone/storefront.mjs +132 -67
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5175,9 +5175,113 @@ function requireClient() {
|
|
|
5175
5175
|
return client;
|
|
5176
5176
|
}
|
|
5177
5177
|
var clientExports = requireClient();
|
|
5178
|
+
const HOLD_MS = 2500;
|
|
5179
|
+
function withoutRestoration() {
|
|
5180
|
+
const history = typeof window !== "undefined" ? window.history : void 0;
|
|
5181
|
+
if (!history || !("scrollRestoration" in history)) return () => {
|
|
5182
|
+
};
|
|
5183
|
+
const previous = history.scrollRestoration;
|
|
5184
|
+
history.scrollRestoration = "manual";
|
|
5185
|
+
return () => {
|
|
5186
|
+
history.scrollRestoration = previous;
|
|
5187
|
+
};
|
|
5188
|
+
}
|
|
5189
|
+
function scrollToTop(box2) {
|
|
5190
|
+
const target = box2 ?? document.documentElement;
|
|
5191
|
+
const behaviour = target.style.scrollBehavior;
|
|
5192
|
+
target.style.scrollBehavior = "auto";
|
|
5193
|
+
if (box2) box2.scrollTop = 0;
|
|
5194
|
+
else window.scrollTo(0, 0);
|
|
5195
|
+
target.style.scrollBehavior = behaviour;
|
|
5196
|
+
}
|
|
5197
|
+
function scrollerOf(el) {
|
|
5198
|
+
if (!el || typeof getComputedStyle !== "function") return null;
|
|
5199
|
+
for (let node = el.parentElement; node; node = node.parentElement) {
|
|
5200
|
+
if (node === document.documentElement) return null;
|
|
5201
|
+
const { overflowY } = getComputedStyle(node);
|
|
5202
|
+
if (overflowY !== "auto" && overflowY !== "scroll" && overflowY !== "overlay") continue;
|
|
5203
|
+
if (node !== document.body) return node;
|
|
5204
|
+
const root2 = getComputedStyle(document.documentElement).overflowY;
|
|
5205
|
+
return root2 === "visible" || root2 === "" ? null : node;
|
|
5206
|
+
}
|
|
5207
|
+
return null;
|
|
5208
|
+
}
|
|
5209
|
+
const RELEASES = ["touchmove", "wheel", "keydown", "pointerdown"];
|
|
5210
|
+
function movesThePage(event) {
|
|
5211
|
+
if (event.type === "pointerdown") return event.pointerType !== "touch";
|
|
5212
|
+
return true;
|
|
5213
|
+
}
|
|
5214
|
+
const holds = /* @__PURE__ */ new Set();
|
|
5215
|
+
function releaseHolds() {
|
|
5216
|
+
for (const end2 of Array.from(holds)) end2();
|
|
5217
|
+
}
|
|
5218
|
+
function anchorTop(onMoved = () => true, onEnd, box2 = null) {
|
|
5219
|
+
let released = false;
|
|
5220
|
+
const top2 = () => {
|
|
5221
|
+
if (released) return;
|
|
5222
|
+
const document_ = window.scrollY || document.documentElement.scrollTop || 0;
|
|
5223
|
+
const pane = box2 ? box2.scrollTop : 0;
|
|
5224
|
+
if (document_ <= 0 && pane <= 0) return;
|
|
5225
|
+
if (!onMoved()) return;
|
|
5226
|
+
if (document_ > 0) scrollToTop();
|
|
5227
|
+
if (box2 && pane > 0) scrollToTop(box2);
|
|
5228
|
+
};
|
|
5229
|
+
const end2 = (how2) => {
|
|
5230
|
+
if (released) return;
|
|
5231
|
+
released = true;
|
|
5232
|
+
holds.delete(moved);
|
|
5233
|
+
if (frame2 !== null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame2);
|
|
5234
|
+
clearTimeout(timer2);
|
|
5235
|
+
window.removeEventListener("scroll", top2);
|
|
5236
|
+
box2?.removeEventListener("scroll", top2);
|
|
5237
|
+
for (const type of RELEASES) window.removeEventListener(type, release);
|
|
5238
|
+
onEnd?.(how2);
|
|
5239
|
+
};
|
|
5240
|
+
const release = (event) => {
|
|
5241
|
+
if (movesThePage(event)) end2("moved");
|
|
5242
|
+
};
|
|
5243
|
+
const moved = () => end2("moved");
|
|
5244
|
+
top2();
|
|
5245
|
+
const frame2 = typeof requestAnimationFrame === "function" ? requestAnimationFrame(top2) : null;
|
|
5246
|
+
const timer2 = setTimeout(() => end2("lapsed"), HOLD_MS);
|
|
5247
|
+
window.addEventListener("scroll", top2, {
|
|
5248
|
+
passive: true
|
|
5249
|
+
});
|
|
5250
|
+
box2?.addEventListener("scroll", top2, {
|
|
5251
|
+
passive: true
|
|
5252
|
+
});
|
|
5253
|
+
for (const type of RELEASES) window.addEventListener(type, release, {
|
|
5254
|
+
passive: true
|
|
5255
|
+
});
|
|
5256
|
+
holds.add(moved);
|
|
5257
|
+
return () => end2("released");
|
|
5258
|
+
}
|
|
5259
|
+
function onReveal(el, revealed) {
|
|
5260
|
+
if (typeof IntersectionObserver === "undefined") return () => {
|
|
5261
|
+
};
|
|
5262
|
+
let seen = false;
|
|
5263
|
+
let visible = true;
|
|
5264
|
+
const observer = new IntersectionObserver((entries) => {
|
|
5265
|
+
const entry = entries[entries.length - 1];
|
|
5266
|
+
if (!entry) return;
|
|
5267
|
+
const now = entry.isIntersecting;
|
|
5268
|
+
if (seen && now && !visible) revealed();
|
|
5269
|
+
seen = true;
|
|
5270
|
+
visible = now;
|
|
5271
|
+
});
|
|
5272
|
+
observer.observe(el);
|
|
5273
|
+
return () => observer.disconnect();
|
|
5274
|
+
}
|
|
5275
|
+
function onResize(el, resized) {
|
|
5276
|
+
if (typeof ResizeObserver === "undefined") return () => {
|
|
5277
|
+
};
|
|
5278
|
+
const observer = new ResizeObserver(() => resized());
|
|
5279
|
+
observer.observe(el);
|
|
5280
|
+
return () => observer.disconnect();
|
|
5281
|
+
}
|
|
5178
5282
|
function anchorToTop() {
|
|
5179
5283
|
if (typeof window === "undefined") return;
|
|
5180
|
-
const top2 = () =>
|
|
5284
|
+
const top2 = () => scrollToTop();
|
|
5181
5285
|
top2();
|
|
5182
5286
|
if (typeof window.requestAnimationFrame === "function") window.requestAnimationFrame(top2);
|
|
5183
5287
|
}
|
|
@@ -5702,65 +5806,6 @@ function useTopOffset(ref, property, enabled = true) {
|
|
|
5702
5806
|
};
|
|
5703
5807
|
}, [ref, property, enabled]);
|
|
5704
5808
|
}
|
|
5705
|
-
const HOLD_MS = 2500;
|
|
5706
|
-
function withoutRestoration() {
|
|
5707
|
-
const history = typeof window !== "undefined" ? window.history : void 0;
|
|
5708
|
-
if (!history || !("scrollRestoration" in history)) return () => {
|
|
5709
|
-
};
|
|
5710
|
-
const previous = history.scrollRestoration;
|
|
5711
|
-
history.scrollRestoration = "manual";
|
|
5712
|
-
return () => {
|
|
5713
|
-
history.scrollRestoration = previous;
|
|
5714
|
-
};
|
|
5715
|
-
}
|
|
5716
|
-
const RELEASES = ["touchmove", "wheel", "keydown", "pointerdown"];
|
|
5717
|
-
function movesThePage(event) {
|
|
5718
|
-
if (event.type === "pointerdown") return event.pointerType !== "touch";
|
|
5719
|
-
return true;
|
|
5720
|
-
}
|
|
5721
|
-
function anchorTop(onMoved = () => true) {
|
|
5722
|
-
let released = false;
|
|
5723
|
-
const top2 = () => {
|
|
5724
|
-
if (released) return;
|
|
5725
|
-
const scrolled2 = window.scrollY || document.documentElement.scrollTop || 0;
|
|
5726
|
-
if (scrolled2 > 0 && onMoved()) window.scrollTo(0, 0);
|
|
5727
|
-
};
|
|
5728
|
-
const release = (event) => {
|
|
5729
|
-
if (released) return;
|
|
5730
|
-
if (event && !movesThePage(event)) return;
|
|
5731
|
-
released = true;
|
|
5732
|
-
if (frame2 !== null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame2);
|
|
5733
|
-
clearTimeout(timer2);
|
|
5734
|
-
window.removeEventListener("scroll", top2);
|
|
5735
|
-
for (const type of RELEASES) window.removeEventListener(type, release);
|
|
5736
|
-
};
|
|
5737
|
-
top2();
|
|
5738
|
-
const frame2 = typeof requestAnimationFrame === "function" ? requestAnimationFrame(top2) : null;
|
|
5739
|
-
const timer2 = setTimeout(release, HOLD_MS);
|
|
5740
|
-
window.addEventListener("scroll", top2, {
|
|
5741
|
-
passive: true
|
|
5742
|
-
});
|
|
5743
|
-
for (const type of RELEASES) window.addEventListener(type, release, {
|
|
5744
|
-
passive: true
|
|
5745
|
-
});
|
|
5746
|
-
return () => release();
|
|
5747
|
-
}
|
|
5748
|
-
function onReveal(el, revealed) {
|
|
5749
|
-
if (typeof IntersectionObserver === "undefined") return () => {
|
|
5750
|
-
};
|
|
5751
|
-
let seen = false;
|
|
5752
|
-
let visible = true;
|
|
5753
|
-
const observer = new IntersectionObserver((entries) => {
|
|
5754
|
-
const entry = entries[entries.length - 1];
|
|
5755
|
-
if (!entry) return;
|
|
5756
|
-
const now = entry.isIntersecting;
|
|
5757
|
-
if (seen && now && !visible) revealed();
|
|
5758
|
-
seen = true;
|
|
5759
|
-
visible = now;
|
|
5760
|
-
});
|
|
5761
|
-
observer.observe(el);
|
|
5762
|
-
return () => observer.disconnect();
|
|
5763
|
-
}
|
|
5764
5809
|
const useMountEffect$1 = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
5765
5810
|
function documentTop(el) {
|
|
5766
5811
|
let top2 = 0;
|
|
@@ -5777,12 +5822,24 @@ function useScreenAnchor(ref, enabled = true) {
|
|
|
5777
5822
|
const el = ref.current;
|
|
5778
5823
|
if (!el || !enabled) return;
|
|
5779
5824
|
const restore = withoutRestoration();
|
|
5780
|
-
let
|
|
5781
|
-
const
|
|
5825
|
+
let moved = false;
|
|
5826
|
+
const hold = () => anchorTop(() => beginsOnTheFirstViewport(el), (end2) => {
|
|
5827
|
+
if (end2 === "moved") moved = true;
|
|
5828
|
+
}, scrollerOf(el));
|
|
5829
|
+
let release = hold();
|
|
5830
|
+
const again = () => {
|
|
5782
5831
|
release();
|
|
5783
|
-
release =
|
|
5832
|
+
release = hold();
|
|
5833
|
+
};
|
|
5834
|
+
const unobserve = onReveal(el, () => {
|
|
5835
|
+
moved = false;
|
|
5836
|
+
again();
|
|
5837
|
+
});
|
|
5838
|
+
const settled = onResize(el, () => {
|
|
5839
|
+
if (!moved) again();
|
|
5784
5840
|
});
|
|
5785
5841
|
return () => {
|
|
5842
|
+
settled();
|
|
5786
5843
|
unobserve();
|
|
5787
5844
|
release();
|
|
5788
5845
|
restore();
|
|
@@ -8015,9 +8072,10 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
|
|
|
8015
8072
|
void load();
|
|
8016
8073
|
}, [load]);
|
|
8017
8074
|
const cancelled = order?.status === "cancelled";
|
|
8075
|
+
const cancelledPage = useRef(null);
|
|
8018
8076
|
useBrowserLayoutEffect(() => {
|
|
8019
8077
|
if (!cancelled) return;
|
|
8020
|
-
return anchorTop();
|
|
8078
|
+
return anchorTop(void 0, void 0, scrollerOf(cancelledPage.current));
|
|
8021
8079
|
}, [cancelled]);
|
|
8022
8080
|
if (state === "loading") {
|
|
8023
8081
|
return jsxs("div", {
|
|
@@ -8100,6 +8158,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
|
|
|
8100
8158
|
if (order.status === "cancelled") {
|
|
8101
8159
|
return jsxs("div", {
|
|
8102
8160
|
className: styles$y.page,
|
|
8161
|
+
ref: cancelledPage,
|
|
8103
8162
|
children: [jsxs("div", {
|
|
8104
8163
|
className: styles$y.cancelledHead,
|
|
8105
8164
|
children: [jsx("h1", {
|
|
@@ -10725,6 +10784,7 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
|
|
|
10725
10784
|
function ensureSelection() {
|
|
10726
10785
|
if (needsSize) {
|
|
10727
10786
|
setSizeError(true);
|
|
10787
|
+
releaseHolds();
|
|
10728
10788
|
sizeRef.current?.scrollIntoView({
|
|
10729
10789
|
behavior: "smooth",
|
|
10730
10790
|
block: "center"
|
|
@@ -10732,6 +10792,7 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
|
|
|
10732
10792
|
return false;
|
|
10733
10793
|
}
|
|
10734
10794
|
if (needsColour) {
|
|
10795
|
+
releaseHolds();
|
|
10735
10796
|
colourRef.current?.scrollIntoView({
|
|
10736
10797
|
behavior: "smooth",
|
|
10737
10798
|
block: "center"
|
|
@@ -11424,7 +11485,8 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
11424
11485
|
useMountEffect(() => {
|
|
11425
11486
|
const el = ref.current;
|
|
11426
11487
|
if (!el || !enabled || typeof document === "undefined") return;
|
|
11427
|
-
const
|
|
11488
|
+
const pane = scrollerOf(el);
|
|
11489
|
+
const root2 = pane ?? document.documentElement;
|
|
11428
11490
|
const previousType = root2.style.scrollSnapType;
|
|
11429
11491
|
const previousPadding = root2.style.scrollPaddingTop;
|
|
11430
11492
|
root2.style.scrollPaddingTop = "0px";
|
|
@@ -11446,7 +11508,10 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
11446
11508
|
passive: true
|
|
11447
11509
|
});
|
|
11448
11510
|
};
|
|
11449
|
-
const top2 = () =>
|
|
11511
|
+
const top2 = () => {
|
|
11512
|
+
scrollToTop();
|
|
11513
|
+
if (pane) scrollToTop(pane);
|
|
11514
|
+
};
|
|
11450
11515
|
let frame2 = null;
|
|
11451
11516
|
let release = () => {
|
|
11452
11517
|
};
|
|
@@ -11467,7 +11532,7 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
11467
11532
|
snapOnAtTouch();
|
|
11468
11533
|
}
|
|
11469
11534
|
return true;
|
|
11470
|
-
});
|
|
11535
|
+
}, void 0, pane);
|
|
11471
11536
|
};
|
|
11472
11537
|
anchor2();
|
|
11473
11538
|
const history = window.history;
|
|
@@ -5175,9 +5175,113 @@ function requireClient() {
|
|
|
5175
5175
|
return client;
|
|
5176
5176
|
}
|
|
5177
5177
|
var clientExports = requireClient();
|
|
5178
|
+
const HOLD_MS = 2500;
|
|
5179
|
+
function withoutRestoration() {
|
|
5180
|
+
const history = typeof window !== "undefined" ? window.history : void 0;
|
|
5181
|
+
if (!history || !("scrollRestoration" in history)) return () => {
|
|
5182
|
+
};
|
|
5183
|
+
const previous = history.scrollRestoration;
|
|
5184
|
+
history.scrollRestoration = "manual";
|
|
5185
|
+
return () => {
|
|
5186
|
+
history.scrollRestoration = previous;
|
|
5187
|
+
};
|
|
5188
|
+
}
|
|
5189
|
+
function scrollToTop(box2) {
|
|
5190
|
+
const target = box2 ?? document.documentElement;
|
|
5191
|
+
const behaviour = target.style.scrollBehavior;
|
|
5192
|
+
target.style.scrollBehavior = "auto";
|
|
5193
|
+
if (box2) box2.scrollTop = 0;
|
|
5194
|
+
else window.scrollTo(0, 0);
|
|
5195
|
+
target.style.scrollBehavior = behaviour;
|
|
5196
|
+
}
|
|
5197
|
+
function scrollerOf(el) {
|
|
5198
|
+
if (!el || typeof getComputedStyle !== "function") return null;
|
|
5199
|
+
for (let node = el.parentElement; node; node = node.parentElement) {
|
|
5200
|
+
if (node === document.documentElement) return null;
|
|
5201
|
+
const { overflowY } = getComputedStyle(node);
|
|
5202
|
+
if (overflowY !== "auto" && overflowY !== "scroll" && overflowY !== "overlay") continue;
|
|
5203
|
+
if (node !== document.body) return node;
|
|
5204
|
+
const root2 = getComputedStyle(document.documentElement).overflowY;
|
|
5205
|
+
return root2 === "visible" || root2 === "" ? null : node;
|
|
5206
|
+
}
|
|
5207
|
+
return null;
|
|
5208
|
+
}
|
|
5209
|
+
const RELEASES = ["touchmove", "wheel", "keydown", "pointerdown"];
|
|
5210
|
+
function movesThePage(event) {
|
|
5211
|
+
if (event.type === "pointerdown") return event.pointerType !== "touch";
|
|
5212
|
+
return true;
|
|
5213
|
+
}
|
|
5214
|
+
const holds = /* @__PURE__ */ new Set();
|
|
5215
|
+
function releaseHolds() {
|
|
5216
|
+
for (const end2 of Array.from(holds)) end2();
|
|
5217
|
+
}
|
|
5218
|
+
function anchorTop(onMoved = () => true, onEnd, box2 = null) {
|
|
5219
|
+
let released = false;
|
|
5220
|
+
const top2 = () => {
|
|
5221
|
+
if (released) return;
|
|
5222
|
+
const document_ = window.scrollY || document.documentElement.scrollTop || 0;
|
|
5223
|
+
const pane = box2 ? box2.scrollTop : 0;
|
|
5224
|
+
if (document_ <= 0 && pane <= 0) return;
|
|
5225
|
+
if (!onMoved()) return;
|
|
5226
|
+
if (document_ > 0) scrollToTop();
|
|
5227
|
+
if (box2 && pane > 0) scrollToTop(box2);
|
|
5228
|
+
};
|
|
5229
|
+
const end2 = (how2) => {
|
|
5230
|
+
if (released) return;
|
|
5231
|
+
released = true;
|
|
5232
|
+
holds.delete(moved);
|
|
5233
|
+
if (frame2 !== null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame2);
|
|
5234
|
+
clearTimeout(timer2);
|
|
5235
|
+
window.removeEventListener("scroll", top2);
|
|
5236
|
+
box2?.removeEventListener("scroll", top2);
|
|
5237
|
+
for (const type of RELEASES) window.removeEventListener(type, release);
|
|
5238
|
+
onEnd?.(how2);
|
|
5239
|
+
};
|
|
5240
|
+
const release = (event) => {
|
|
5241
|
+
if (movesThePage(event)) end2("moved");
|
|
5242
|
+
};
|
|
5243
|
+
const moved = () => end2("moved");
|
|
5244
|
+
top2();
|
|
5245
|
+
const frame2 = typeof requestAnimationFrame === "function" ? requestAnimationFrame(top2) : null;
|
|
5246
|
+
const timer2 = setTimeout(() => end2("lapsed"), HOLD_MS);
|
|
5247
|
+
window.addEventListener("scroll", top2, {
|
|
5248
|
+
passive: true
|
|
5249
|
+
});
|
|
5250
|
+
box2?.addEventListener("scroll", top2, {
|
|
5251
|
+
passive: true
|
|
5252
|
+
});
|
|
5253
|
+
for (const type of RELEASES) window.addEventListener(type, release, {
|
|
5254
|
+
passive: true
|
|
5255
|
+
});
|
|
5256
|
+
holds.add(moved);
|
|
5257
|
+
return () => end2("released");
|
|
5258
|
+
}
|
|
5259
|
+
function onReveal(el, revealed) {
|
|
5260
|
+
if (typeof IntersectionObserver === "undefined") return () => {
|
|
5261
|
+
};
|
|
5262
|
+
let seen = false;
|
|
5263
|
+
let visible = true;
|
|
5264
|
+
const observer = new IntersectionObserver((entries) => {
|
|
5265
|
+
const entry = entries[entries.length - 1];
|
|
5266
|
+
if (!entry) return;
|
|
5267
|
+
const now = entry.isIntersecting;
|
|
5268
|
+
if (seen && now && !visible) revealed();
|
|
5269
|
+
seen = true;
|
|
5270
|
+
visible = now;
|
|
5271
|
+
});
|
|
5272
|
+
observer.observe(el);
|
|
5273
|
+
return () => observer.disconnect();
|
|
5274
|
+
}
|
|
5275
|
+
function onResize(el, resized) {
|
|
5276
|
+
if (typeof ResizeObserver === "undefined") return () => {
|
|
5277
|
+
};
|
|
5278
|
+
const observer = new ResizeObserver(() => resized());
|
|
5279
|
+
observer.observe(el);
|
|
5280
|
+
return () => observer.disconnect();
|
|
5281
|
+
}
|
|
5178
5282
|
function anchorToTop() {
|
|
5179
5283
|
if (typeof window === "undefined") return;
|
|
5180
|
-
const top2 = () =>
|
|
5284
|
+
const top2 = () => scrollToTop();
|
|
5181
5285
|
top2();
|
|
5182
5286
|
if (typeof window.requestAnimationFrame === "function") window.requestAnimationFrame(top2);
|
|
5183
5287
|
}
|
|
@@ -5702,65 +5806,6 @@ function useTopOffset(ref, property, enabled = true) {
|
|
|
5702
5806
|
};
|
|
5703
5807
|
}, [ref, property, enabled]);
|
|
5704
5808
|
}
|
|
5705
|
-
const HOLD_MS = 2500;
|
|
5706
|
-
function withoutRestoration() {
|
|
5707
|
-
const history = typeof window !== "undefined" ? window.history : void 0;
|
|
5708
|
-
if (!history || !("scrollRestoration" in history)) return () => {
|
|
5709
|
-
};
|
|
5710
|
-
const previous = history.scrollRestoration;
|
|
5711
|
-
history.scrollRestoration = "manual";
|
|
5712
|
-
return () => {
|
|
5713
|
-
history.scrollRestoration = previous;
|
|
5714
|
-
};
|
|
5715
|
-
}
|
|
5716
|
-
const RELEASES = ["touchmove", "wheel", "keydown", "pointerdown"];
|
|
5717
|
-
function movesThePage(event) {
|
|
5718
|
-
if (event.type === "pointerdown") return event.pointerType !== "touch";
|
|
5719
|
-
return true;
|
|
5720
|
-
}
|
|
5721
|
-
function anchorTop(onMoved = () => true) {
|
|
5722
|
-
let released = false;
|
|
5723
|
-
const top2 = () => {
|
|
5724
|
-
if (released) return;
|
|
5725
|
-
const scrolled2 = window.scrollY || document.documentElement.scrollTop || 0;
|
|
5726
|
-
if (scrolled2 > 0 && onMoved()) window.scrollTo(0, 0);
|
|
5727
|
-
};
|
|
5728
|
-
const release = (event) => {
|
|
5729
|
-
if (released) return;
|
|
5730
|
-
if (event && !movesThePage(event)) return;
|
|
5731
|
-
released = true;
|
|
5732
|
-
if (frame2 !== null && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame2);
|
|
5733
|
-
clearTimeout(timer2);
|
|
5734
|
-
window.removeEventListener("scroll", top2);
|
|
5735
|
-
for (const type of RELEASES) window.removeEventListener(type, release);
|
|
5736
|
-
};
|
|
5737
|
-
top2();
|
|
5738
|
-
const frame2 = typeof requestAnimationFrame === "function" ? requestAnimationFrame(top2) : null;
|
|
5739
|
-
const timer2 = setTimeout(release, HOLD_MS);
|
|
5740
|
-
window.addEventListener("scroll", top2, {
|
|
5741
|
-
passive: true
|
|
5742
|
-
});
|
|
5743
|
-
for (const type of RELEASES) window.addEventListener(type, release, {
|
|
5744
|
-
passive: true
|
|
5745
|
-
});
|
|
5746
|
-
return () => release();
|
|
5747
|
-
}
|
|
5748
|
-
function onReveal(el, revealed) {
|
|
5749
|
-
if (typeof IntersectionObserver === "undefined") return () => {
|
|
5750
|
-
};
|
|
5751
|
-
let seen = false;
|
|
5752
|
-
let visible = true;
|
|
5753
|
-
const observer = new IntersectionObserver((entries) => {
|
|
5754
|
-
const entry = entries[entries.length - 1];
|
|
5755
|
-
if (!entry) return;
|
|
5756
|
-
const now = entry.isIntersecting;
|
|
5757
|
-
if (seen && now && !visible) revealed();
|
|
5758
|
-
seen = true;
|
|
5759
|
-
visible = now;
|
|
5760
|
-
});
|
|
5761
|
-
observer.observe(el);
|
|
5762
|
-
return () => observer.disconnect();
|
|
5763
|
-
}
|
|
5764
5809
|
const useMountEffect$1 = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
5765
5810
|
function documentTop(el) {
|
|
5766
5811
|
let top2 = 0;
|
|
@@ -5777,12 +5822,24 @@ function useScreenAnchor(ref, enabled = true) {
|
|
|
5777
5822
|
const el = ref.current;
|
|
5778
5823
|
if (!el || !enabled) return;
|
|
5779
5824
|
const restore = withoutRestoration();
|
|
5780
|
-
let
|
|
5781
|
-
const
|
|
5825
|
+
let moved = false;
|
|
5826
|
+
const hold = () => anchorTop(() => beginsOnTheFirstViewport(el), (end2) => {
|
|
5827
|
+
if (end2 === "moved") moved = true;
|
|
5828
|
+
}, scrollerOf(el));
|
|
5829
|
+
let release = hold();
|
|
5830
|
+
const again = () => {
|
|
5782
5831
|
release();
|
|
5783
|
-
release =
|
|
5832
|
+
release = hold();
|
|
5833
|
+
};
|
|
5834
|
+
const unobserve = onReveal(el, () => {
|
|
5835
|
+
moved = false;
|
|
5836
|
+
again();
|
|
5837
|
+
});
|
|
5838
|
+
const settled = onResize(el, () => {
|
|
5839
|
+
if (!moved) again();
|
|
5784
5840
|
});
|
|
5785
5841
|
return () => {
|
|
5842
|
+
settled();
|
|
5786
5843
|
unobserve();
|
|
5787
5844
|
release();
|
|
5788
5845
|
restore();
|
|
@@ -8015,9 +8072,10 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
|
|
|
8015
8072
|
void load();
|
|
8016
8073
|
}, [load]);
|
|
8017
8074
|
const cancelled = order?.status === "cancelled";
|
|
8075
|
+
const cancelledPage = useRef(null);
|
|
8018
8076
|
useBrowserLayoutEffect(() => {
|
|
8019
8077
|
if (!cancelled) return;
|
|
8020
|
-
return anchorTop();
|
|
8078
|
+
return anchorTop(void 0, void 0, scrollerOf(cancelledPage.current));
|
|
8021
8079
|
}, [cancelled]);
|
|
8022
8080
|
if (state === "loading") {
|
|
8023
8081
|
return jsxs("div", {
|
|
@@ -8100,6 +8158,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
|
|
|
8100
8158
|
if (order.status === "cancelled") {
|
|
8101
8159
|
return jsxs("div", {
|
|
8102
8160
|
className: styles$y.page,
|
|
8161
|
+
ref: cancelledPage,
|
|
8103
8162
|
children: [jsxs("div", {
|
|
8104
8163
|
className: styles$y.cancelledHead,
|
|
8105
8164
|
children: [jsx("h1", {
|
|
@@ -10725,6 +10784,7 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
|
|
|
10725
10784
|
function ensureSelection() {
|
|
10726
10785
|
if (needsSize) {
|
|
10727
10786
|
setSizeError(true);
|
|
10787
|
+
releaseHolds();
|
|
10728
10788
|
sizeRef.current?.scrollIntoView({
|
|
10729
10789
|
behavior: "smooth",
|
|
10730
10790
|
block: "center"
|
|
@@ -10732,6 +10792,7 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
|
|
|
10732
10792
|
return false;
|
|
10733
10793
|
}
|
|
10734
10794
|
if (needsColour) {
|
|
10795
|
+
releaseHolds();
|
|
10735
10796
|
colourRef.current?.scrollIntoView({
|
|
10736
10797
|
behavior: "smooth",
|
|
10737
10798
|
block: "center"
|
|
@@ -11424,7 +11485,8 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
11424
11485
|
useMountEffect(() => {
|
|
11425
11486
|
const el = ref.current;
|
|
11426
11487
|
if (!el || !enabled || typeof document === "undefined") return;
|
|
11427
|
-
const
|
|
11488
|
+
const pane = scrollerOf(el);
|
|
11489
|
+
const root2 = pane ?? document.documentElement;
|
|
11428
11490
|
const previousType = root2.style.scrollSnapType;
|
|
11429
11491
|
const previousPadding = root2.style.scrollPaddingTop;
|
|
11430
11492
|
root2.style.scrollPaddingTop = "0px";
|
|
@@ -11446,7 +11508,10 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
11446
11508
|
passive: true
|
|
11447
11509
|
});
|
|
11448
11510
|
};
|
|
11449
|
-
const top2 = () =>
|
|
11511
|
+
const top2 = () => {
|
|
11512
|
+
scrollToTop();
|
|
11513
|
+
if (pane) scrollToTop(pane);
|
|
11514
|
+
};
|
|
11450
11515
|
let frame2 = null;
|
|
11451
11516
|
let release = () => {
|
|
11452
11517
|
};
|
|
@@ -11467,7 +11532,7 @@ function useDocumentSnap(ref, enabled = true) {
|
|
|
11467
11532
|
snapOnAtTouch();
|
|
11468
11533
|
}
|
|
11469
11534
|
return true;
|
|
11470
|
-
});
|
|
11535
|
+
}, void 0, pane);
|
|
11471
11536
|
};
|
|
11472
11537
|
anchor2();
|
|
11473
11538
|
const history = window.history;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nok-integration/storefront-react",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.12",
|
|
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",
|