@nok-integration/storefront-react 0.20.10 → 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 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 = () => window.scrollTo(0, 0);
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 release = anchorTop(() => beginsOnTheFirstViewport(el));
5781
- const unobserve = onReveal(el, () => {
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 = anchorTop(() => beginsOnTheFirstViewport(el));
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();
@@ -6581,6 +6638,50 @@ function PriceBlock({ price: price2, compareAt: compareAt2, discountPct: discoun
6581
6638
  })]
6582
6639
  });
6583
6640
  }
6641
+ const STATE_KEY = "__daznShop";
6642
+ function current$1(name2) {
6643
+ if (typeof window === "undefined") return null;
6644
+ const state = window.history.state;
6645
+ const ours = state?.[STATE_KEY];
6646
+ if (!ours || ours.href !== window.location.href) return null;
6647
+ const value2 = ours[name2];
6648
+ return typeof value2 === "string" ? value2 : null;
6649
+ }
6650
+ function useInPlaceScreen(name2) {
6651
+ const [value2, setValue] = useState(() => current$1(name2));
6652
+ useEffect(() => {
6653
+ const onPop = () => setValue(current$1(name2));
6654
+ window.addEventListener("popstate", onPop);
6655
+ return () => window.removeEventListener("popstate", onPop);
6656
+ }, [name2]);
6657
+ const open = useCallback((next) => {
6658
+ const history = window.history;
6659
+ const state = history.state ?? {};
6660
+ const href = window.location.href;
6661
+ const ours = state[STATE_KEY]?.href === href ? state[STATE_KEY] : {};
6662
+ history.pushState({
6663
+ ...state,
6664
+ [STATE_KEY]: {
6665
+ ...ours,
6666
+ href,
6667
+ [name2]: next
6668
+ }
6669
+ }, "", href);
6670
+ setValue(next);
6671
+ }, [name2]);
6672
+ const close2 = useCallback(() => {
6673
+ if (current$1(name2) !== null) {
6674
+ window.history.back();
6675
+ return;
6676
+ }
6677
+ setValue(null);
6678
+ }, [name2]);
6679
+ return {
6680
+ value: value2,
6681
+ open,
6682
+ close: close2
6683
+ };
6684
+ }
6584
6685
  const timeline = "_timeline_1cum7_7";
6585
6686
  const row$8 = "_row_1cum7_15";
6586
6687
  const line$3 = "_line_1cum7_20";
@@ -7921,15 +8022,16 @@ function ChevronRight$1() {
7921
8022
  })
7922
8023
  });
7923
8024
  }
8025
+ const useBrowserLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
7924
8026
  function OrderTrackingView(props) {
7925
- const [flow, setFlow] = useState(null);
7926
- if (flow !== null) {
8027
+ const flow = useInPlaceScreen("returnFlow");
8028
+ if (flow.value !== null) {
7927
8029
  return jsx(ReturnFlowView, {
7928
8030
  orderRef: props.orderRef,
7929
- ...flow ? {
7930
- returnRef: flow
8031
+ ...flow.value ? {
8032
+ returnRef: flow.value
7931
8033
  } : {},
7932
- onDone: () => setFlow(null)
8034
+ onDone: flow.close
7933
8035
  });
7934
8036
  }
7935
8037
  return jsx(ShopSurface, {
@@ -7937,8 +8039,8 @@ function OrderTrackingView(props) {
7937
8039
  fill: true,
7938
8040
  children: jsx(OrderTrackingContent, {
7939
8041
  ...props,
7940
- onStartReturn: props.onStartReturn ?? (() => setFlow("")),
7941
- onOpenReturn: props.onOpenReturn ?? ((returnRef) => setFlow(returnRef))
8042
+ onStartReturn: props.onStartReturn ?? (() => flow.open("")),
8043
+ onOpenReturn: props.onOpenReturn ?? flow.open
7942
8044
  })
7943
8045
  });
7944
8046
  }
@@ -7969,6 +8071,12 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
7969
8071
  useEffect(() => {
7970
8072
  void load();
7971
8073
  }, [load]);
8074
+ const cancelled = order?.status === "cancelled";
8075
+ const cancelledPage = useRef(null);
8076
+ useBrowserLayoutEffect(() => {
8077
+ if (!cancelled) return;
8078
+ return anchorTop(void 0, void 0, scrollerOf(cancelledPage.current));
8079
+ }, [cancelled]);
7972
8080
  if (state === "loading") {
7973
8081
  return jsxs("div", {
7974
8082
  className: styles$y.page,
@@ -8050,6 +8158,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
8050
8158
  if (order.status === "cancelled") {
8051
8159
  return jsxs("div", {
8052
8160
  className: styles$y.page,
8161
+ ref: cancelledPage,
8053
8162
  children: [jsxs("div", {
8054
8163
  className: styles$y.cancelledHead,
8055
8164
  children: [jsx("h1", {
@@ -8446,11 +8555,11 @@ function Chevron() {
8446
8555
  });
8447
8556
  }
8448
8557
  function OrderListView(props) {
8449
- const [opened, setOpened] = useState(null);
8450
- if (opened !== null) {
8558
+ const opened = useInPlaceScreen("return");
8559
+ if (opened.value !== null) {
8451
8560
  return jsx(ReturnFlowView, {
8452
- returnRef: opened,
8453
- onDone: () => setOpened(null)
8561
+ returnRef: opened.value,
8562
+ onDone: opened.close
8454
8563
  });
8455
8564
  }
8456
8565
  return jsx(ShopSurface, {
@@ -8458,7 +8567,7 @@ function OrderListView(props) {
8458
8567
  fill: true,
8459
8568
  children: jsx(OrderListContent, {
8460
8569
  ...props,
8461
- onOpenReturn: props.onOpenReturn ?? setOpened
8570
+ onOpenReturn: props.onOpenReturn ?? opened.open
8462
8571
  })
8463
8572
  });
8464
8573
  }
@@ -10675,6 +10784,7 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
10675
10784
  function ensureSelection() {
10676
10785
  if (needsSize) {
10677
10786
  setSizeError(true);
10787
+ releaseHolds();
10678
10788
  sizeRef.current?.scrollIntoView({
10679
10789
  behavior: "smooth",
10680
10790
  block: "center"
@@ -10682,6 +10792,7 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
10682
10792
  return false;
10683
10793
  }
10684
10794
  if (needsColour) {
10795
+ releaseHolds();
10685
10796
  colourRef.current?.scrollIntoView({
10686
10797
  behavior: "smooth",
10687
10798
  block: "center"
@@ -11374,7 +11485,8 @@ function useDocumentSnap(ref, enabled = true) {
11374
11485
  useMountEffect(() => {
11375
11486
  const el = ref.current;
11376
11487
  if (!el || !enabled || typeof document === "undefined") return;
11377
- const root2 = document.documentElement;
11488
+ const pane = scrollerOf(el);
11489
+ const root2 = pane ?? document.documentElement;
11378
11490
  const previousType = root2.style.scrollSnapType;
11379
11491
  const previousPadding = root2.style.scrollPaddingTop;
11380
11492
  root2.style.scrollPaddingTop = "0px";
@@ -11396,7 +11508,10 @@ function useDocumentSnap(ref, enabled = true) {
11396
11508
  passive: true
11397
11509
  });
11398
11510
  };
11399
- const top2 = () => window.scrollTo(0, 0);
11511
+ const top2 = () => {
11512
+ scrollToTop();
11513
+ if (pane) scrollToTop(pane);
11514
+ };
11400
11515
  let frame2 = null;
11401
11516
  let release = () => {
11402
11517
  };
@@ -11417,7 +11532,7 @@ function useDocumentSnap(ref, enabled = true) {
11417
11532
  snapOnAtTouch();
11418
11533
  }
11419
11534
  return true;
11420
- });
11535
+ }, void 0, pane);
11421
11536
  };
11422
11537
  anchor2();
11423
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 = () => window.scrollTo(0, 0);
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 release = anchorTop(() => beginsOnTheFirstViewport(el));
5781
- const unobserve = onReveal(el, () => {
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 = anchorTop(() => beginsOnTheFirstViewport(el));
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();
@@ -6581,6 +6638,50 @@ function PriceBlock({ price: price2, compareAt: compareAt2, discountPct: discoun
6581
6638
  })]
6582
6639
  });
6583
6640
  }
6641
+ const STATE_KEY = "__daznShop";
6642
+ function current$1(name2) {
6643
+ if (typeof window === "undefined") return null;
6644
+ const state = window.history.state;
6645
+ const ours = state?.[STATE_KEY];
6646
+ if (!ours || ours.href !== window.location.href) return null;
6647
+ const value2 = ours[name2];
6648
+ return typeof value2 === "string" ? value2 : null;
6649
+ }
6650
+ function useInPlaceScreen(name2) {
6651
+ const [value2, setValue] = useState(() => current$1(name2));
6652
+ useEffect(() => {
6653
+ const onPop = () => setValue(current$1(name2));
6654
+ window.addEventListener("popstate", onPop);
6655
+ return () => window.removeEventListener("popstate", onPop);
6656
+ }, [name2]);
6657
+ const open = useCallback((next) => {
6658
+ const history = window.history;
6659
+ const state = history.state ?? {};
6660
+ const href = window.location.href;
6661
+ const ours = state[STATE_KEY]?.href === href ? state[STATE_KEY] : {};
6662
+ history.pushState({
6663
+ ...state,
6664
+ [STATE_KEY]: {
6665
+ ...ours,
6666
+ href,
6667
+ [name2]: next
6668
+ }
6669
+ }, "", href);
6670
+ setValue(next);
6671
+ }, [name2]);
6672
+ const close2 = useCallback(() => {
6673
+ if (current$1(name2) !== null) {
6674
+ window.history.back();
6675
+ return;
6676
+ }
6677
+ setValue(null);
6678
+ }, [name2]);
6679
+ return {
6680
+ value: value2,
6681
+ open,
6682
+ close: close2
6683
+ };
6684
+ }
6584
6685
  const timeline = "_timeline_1cum7_7";
6585
6686
  const row$8 = "_row_1cum7_15";
6586
6687
  const line$3 = "_line_1cum7_20";
@@ -7921,15 +8022,16 @@ function ChevronRight$1() {
7921
8022
  })
7922
8023
  });
7923
8024
  }
8025
+ const useBrowserLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
7924
8026
  function OrderTrackingView(props) {
7925
- const [flow, setFlow] = useState(null);
7926
- if (flow !== null) {
8027
+ const flow = useInPlaceScreen("returnFlow");
8028
+ if (flow.value !== null) {
7927
8029
  return jsx(ReturnFlowView, {
7928
8030
  orderRef: props.orderRef,
7929
- ...flow ? {
7930
- returnRef: flow
8031
+ ...flow.value ? {
8032
+ returnRef: flow.value
7931
8033
  } : {},
7932
- onDone: () => setFlow(null)
8034
+ onDone: flow.close
7933
8035
  });
7934
8036
  }
7935
8037
  return jsx(ShopSurface, {
@@ -7937,8 +8039,8 @@ function OrderTrackingView(props) {
7937
8039
  fill: true,
7938
8040
  children: jsx(OrderTrackingContent, {
7939
8041
  ...props,
7940
- onStartReturn: props.onStartReturn ?? (() => setFlow("")),
7941
- onOpenReturn: props.onOpenReturn ?? ((returnRef) => setFlow(returnRef))
8042
+ onStartReturn: props.onStartReturn ?? (() => flow.open("")),
8043
+ onOpenReturn: props.onOpenReturn ?? flow.open
7942
8044
  })
7943
8045
  });
7944
8046
  }
@@ -7969,6 +8071,12 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
7969
8071
  useEffect(() => {
7970
8072
  void load();
7971
8073
  }, [load]);
8074
+ const cancelled = order?.status === "cancelled";
8075
+ const cancelledPage = useRef(null);
8076
+ useBrowserLayoutEffect(() => {
8077
+ if (!cancelled) return;
8078
+ return anchorTop(void 0, void 0, scrollerOf(cancelledPage.current));
8079
+ }, [cancelled]);
7972
8080
  if (state === "loading") {
7973
8081
  return jsxs("div", {
7974
8082
  className: styles$y.page,
@@ -8050,6 +8158,7 @@ function OrderTrackingContent({ orderRef, locale: localeProp, onStartReturn, onO
8050
8158
  if (order.status === "cancelled") {
8051
8159
  return jsxs("div", {
8052
8160
  className: styles$y.page,
8161
+ ref: cancelledPage,
8053
8162
  children: [jsxs("div", {
8054
8163
  className: styles$y.cancelledHead,
8055
8164
  children: [jsx("h1", {
@@ -8446,11 +8555,11 @@ function Chevron() {
8446
8555
  });
8447
8556
  }
8448
8557
  function OrderListView(props) {
8449
- const [opened, setOpened] = useState(null);
8450
- if (opened !== null) {
8558
+ const opened = useInPlaceScreen("return");
8559
+ if (opened.value !== null) {
8451
8560
  return jsx(ReturnFlowView, {
8452
- returnRef: opened,
8453
- onDone: () => setOpened(null)
8561
+ returnRef: opened.value,
8562
+ onDone: opened.close
8454
8563
  });
8455
8564
  }
8456
8565
  return jsx(ShopSurface, {
@@ -8458,7 +8567,7 @@ function OrderListView(props) {
8458
8567
  fill: true,
8459
8568
  children: jsx(OrderListContent, {
8460
8569
  ...props,
8461
- onOpenReturn: props.onOpenReturn ?? setOpened
8570
+ onOpenReturn: props.onOpenReturn ?? opened.open
8462
8571
  })
8463
8572
  });
8464
8573
  }
@@ -10675,6 +10784,7 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
10675
10784
  function ensureSelection() {
10676
10785
  if (needsSize) {
10677
10786
  setSizeError(true);
10787
+ releaseHolds();
10678
10788
  sizeRef.current?.scrollIntoView({
10679
10789
  behavior: "smooth",
10680
10790
  block: "center"
@@ -10682,6 +10792,7 @@ function ProductDetail({ product, inventory: inventory2, recommendations = [] })
10682
10792
  return false;
10683
10793
  }
10684
10794
  if (needsColour) {
10795
+ releaseHolds();
10685
10796
  colourRef.current?.scrollIntoView({
10686
10797
  behavior: "smooth",
10687
10798
  block: "center"
@@ -11374,7 +11485,8 @@ function useDocumentSnap(ref, enabled = true) {
11374
11485
  useMountEffect(() => {
11375
11486
  const el = ref.current;
11376
11487
  if (!el || !enabled || typeof document === "undefined") return;
11377
- const root2 = document.documentElement;
11488
+ const pane = scrollerOf(el);
11489
+ const root2 = pane ?? document.documentElement;
11378
11490
  const previousType = root2.style.scrollSnapType;
11379
11491
  const previousPadding = root2.style.scrollPaddingTop;
11380
11492
  root2.style.scrollPaddingTop = "0px";
@@ -11396,7 +11508,10 @@ function useDocumentSnap(ref, enabled = true) {
11396
11508
  passive: true
11397
11509
  });
11398
11510
  };
11399
- const top2 = () => window.scrollTo(0, 0);
11511
+ const top2 = () => {
11512
+ scrollToTop();
11513
+ if (pane) scrollToTop(pane);
11514
+ };
11400
11515
  let frame2 = null;
11401
11516
  let release = () => {
11402
11517
  };
@@ -11417,7 +11532,7 @@ function useDocumentSnap(ref, enabled = true) {
11417
11532
  snapOnAtTouch();
11418
11533
  }
11419
11534
  return true;
11420
- });
11535
+ }, void 0, pane);
11421
11536
  };
11422
11537
  anchor2();
11423
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.10",
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",